aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/acpi/container.c6
-rw-r--r--drivers/acpi/osl.c6
-rw-r--r--drivers/acpi/scan.c6
-rw-r--r--drivers/acpi/video.c12
-rw-r--r--drivers/base/platform.c153
-rw-r--r--drivers/base/power/sysfs.c1
-rw-r--r--drivers/block/DAC960.c31
-rw-r--r--drivers/block/Kconfig12
-rw-r--r--drivers/block/Kconfig.iosched69
-rw-r--r--drivers/block/Makefile14
-rw-r--r--drivers/block/as-iosched.c1985
-rw-r--r--drivers/block/cciss.c12
-rw-r--r--drivers/block/cfq-iosched.c2428
-rw-r--r--drivers/block/deadline-iosched.c878
-rw-r--r--drivers/block/elevator.c802
-rw-r--r--drivers/block/genhd.c726
-rw-r--r--drivers/block/ioctl.c275
-rw-r--r--drivers/block/ll_rw_blk.c3613
-rw-r--r--drivers/block/noop-iosched.c46
-rw-r--r--drivers/block/scsi_ioctl.c589
-rw-r--r--drivers/block/swim3.c20
-rw-r--r--drivers/bluetooth/bcm203x.c4
-rw-r--r--drivers/bluetooth/bfusb.c4
-rw-r--r--drivers/bluetooth/bluecard_cs.c3
-rw-r--r--drivers/bluetooth/bpa10x.c4
-rw-r--r--drivers/bluetooth/bt3c_cs.c3
-rw-r--r--drivers/bluetooth/btuart_cs.c3
-rw-r--r--drivers/bluetooth/dtl1_cs.c3
-rw-r--r--drivers/bluetooth/hci_bcsp.c3
-rw-r--r--drivers/bluetooth/hci_h4.c4
-rw-r--r--drivers/bluetooth/hci_ldisc.c4
-rw-r--r--drivers/bluetooth/hci_usb.c4
-rw-r--r--drivers/bluetooth/hci_vhci.c4
-rw-r--r--drivers/cdrom/mcdx.c4
-rw-r--r--drivers/char/agp/ali-agp.c1
-rw-r--r--drivers/char/agp/amd-k7-agp.c8
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/agp/ati-agp.c8
-rw-r--r--drivers/char/agp/backend.c6
-rw-r--r--drivers/char/agp/efficeon-agp.c3
-rw-r--r--drivers/char/agp/frontend.c15
-rw-r--r--drivers/char/agp/generic.c10
-rw-r--r--drivers/char/agp/i460-agp.c7
-rw-r--r--drivers/char/agp/intel-agp.c1
-rw-r--r--drivers/char/agp/nvidia-agp.c1
-rw-r--r--drivers/char/agp/sgi-agp.c2
-rw-r--r--drivers/char/agp/sis-agp.c1
-rw-r--r--drivers/char/agp/sworks-agp.c29
-rw-r--r--drivers/char/agp/uninorth-agp.c1
-rw-r--r--drivers/char/agp/via-agp.c1
-rw-r--r--drivers/char/consolemap.c12
-rw-r--r--drivers/char/drm/ffb_context.c6
-rw-r--r--drivers/char/drm/ffb_drv.c6
-rw-r--r--drivers/char/ip2/i2ellis.c4
-rw-r--r--drivers/char/ipmi/ipmi_bt_sm.c38
-rw-r--r--drivers/char/ipmi/ipmi_kcs_sm.c48
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c952
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c4
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c183
-rw-r--r--drivers/char/ipmi/ipmi_si_sm.h1
-rw-r--r--drivers/char/ipmi/ipmi_smic_sm.c15
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c259
-rw-r--r--drivers/char/istallion.c7
-rw-r--r--drivers/char/mxser.c47
-rw-r--r--drivers/char/n_hdlc.c3
-rw-r--r--drivers/char/pcmcia/synclink_cs.c3
-rw-r--r--drivers/char/rocket.c6
-rw-r--r--drivers/char/rtc.c65
-rw-r--r--drivers/char/selection.c3
-rw-r--r--drivers/char/stallion.c6
-rw-r--r--drivers/char/synclink.c10
-rw-r--r--drivers/char/synclinkmp.c9
-rw-r--r--drivers/char/tpm/tpm_nsc.c48
-rw-r--r--drivers/char/tty_io.c9
-rw-r--r--drivers/char/vt_ioctl.c5
-rw-r--r--drivers/connector/Kconfig8
-rw-r--r--drivers/connector/Makefile1
-rw-r--r--drivers/connector/cn_proc.c222
-rw-r--r--drivers/cpufreq/cpufreq.c3
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c18
-rw-r--r--drivers/cpufreq/cpufreq_stats.c12
-rw-r--r--drivers/dio/dio.c3
-rw-r--r--drivers/eisa/eisa-bus.c8
-rw-r--r--drivers/fc4/fc.c32
-rw-r--r--drivers/fc4/soc.c3
-rw-r--r--drivers/fc4/socal.c3
-rw-r--r--drivers/firmware/dell_rbu.c121
-rw-r--r--drivers/firmware/edd.c3
-rw-r--r--drivers/firmware/efivars.c10
-rw-r--r--drivers/hwmon/hwmon.c1
-rw-r--r--drivers/hwmon/max1619.c14
-rw-r--r--drivers/hwmon/w83781d.c6
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c6
-rw-r--r--drivers/ide/ide-cd.c22
-rw-r--r--drivers/ide/ide-disk.c4
-rw-r--r--drivers/ide/ide-floppy.c4
-rw-r--r--drivers/ide/ide-probe.c9
-rw-r--r--drivers/ide/ide-tape.c4
-rw-r--r--drivers/ide/ide-taskfile.c18
-rw-r--r--drivers/ide/ide.c6
-rw-r--r--drivers/ide/legacy/ide-cs.c6
-rw-r--r--drivers/ide/pci/hpt366.c3
-rw-r--r--drivers/ide/pci/it821x.c3
-rw-r--r--drivers/ide/ppc/pmac.c9
-rw-r--r--drivers/ieee1394/amdtp.c3
-rw-r--r--drivers/infiniband/core/agent.c3
-rw-r--r--drivers/infiniband/core/mad.c6
-rw-r--r--drivers/infiniband/core/packer.c2
-rw-r--r--drivers/infiniband/core/sysfs.c3
-rw-r--r--drivers/infiniband/core/ud_header.c1
-rw-r--r--drivers/infiniband/core/verbs.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_catas.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c3
-rw-r--r--drivers/input/input.c27
-rw-r--r--drivers/input/keyboard/lkkbd.c101
-rw-r--r--drivers/input/keyboard/locomokbd.c63
-rw-r--r--drivers/input/misc/uinput.c10
-rw-r--r--drivers/input/mouse/logips2pp.c3
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c5
-rw-r--r--drivers/isdn/hisax/avm_pci.c12
-rw-r--r--drivers/isdn/hisax/avma1_cs.c4
-rw-r--r--drivers/isdn/hisax/config.c9
-rw-r--r--drivers/isdn/hisax/hfc_2bds0.c18
-rw-r--r--drivers/isdn/hisax/hfc_2bs0.c12
-rw-r--r--drivers/isdn/hisax/hfc_usb.c292
-rw-r--r--drivers/isdn/hisax/hfc_usb.h6
-rw-r--r--drivers/isdn/hisax/hscx.c12
-rw-r--r--drivers/isdn/hisax/icc.c12
-rw-r--r--drivers/isdn/hisax/ipacx.c12
-rw-r--r--drivers/isdn/hisax/isac.c15
-rw-r--r--drivers/isdn/hisax/isar.c6
-rw-r--r--drivers/isdn/hisax/jade.c12
-rw-r--r--drivers/isdn/hisax/netjet.c32
-rw-r--r--drivers/isdn/hisax/st5481_usb.c12
-rw-r--r--drivers/isdn/hisax/w6692.c12
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c3
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c21
-rw-r--r--drivers/isdn/i4l/isdn_tty.c27
-rw-r--r--drivers/isdn/icn/icn.c3
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c9
-rw-r--r--drivers/isdn/pcbit/drv.c6
-rw-r--r--drivers/isdn/sc/init.c3
-rw-r--r--drivers/isdn/sc/message.c3
-rw-r--r--drivers/macintosh/Kconfig19
-rw-r--r--drivers/macintosh/Makefile9
-rw-r--r--drivers/macintosh/adbhid.c3
-rw-r--r--drivers/macintosh/smu.c174
-rw-r--r--drivers/macintosh/therm_pm72.c3
-rw-r--r--drivers/macintosh/via-pmu.c10
-rw-r--r--drivers/macintosh/windfarm.h131
-rw-r--r--drivers/macintosh/windfarm_core.c426
-rw-r--r--drivers/macintosh/windfarm_cpufreq_clamp.c105
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c263
-rw-r--r--drivers/macintosh/windfarm_pid.c145
-rw-r--r--drivers/macintosh/windfarm_pid.h84
-rw-r--r--drivers/macintosh/windfarm_pm81.c879
-rw-r--r--drivers/macintosh/windfarm_pm91.c814
-rw-r--r--drivers/macintosh/windfarm_smu_controls.c282
-rw-r--r--drivers/macintosh/windfarm_smu_sensors.c479
-rw-r--r--drivers/md/raid5.c3
-rw-r--r--drivers/md/raid6main.c3
-rw-r--r--drivers/media/dvb/bt8xx/dst.c8
-rw-r--r--drivers/media/dvb/frontends/cx24110.c1
-rw-r--r--drivers/media/dvb/frontends/dvb_dummy_fe.c4
-rw-r--r--drivers/media/dvb/frontends/l64781.c3
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.c3
-rw-r--r--drivers/media/dvb/frontends/mt312.c3
-rw-r--r--drivers/media/dvb/frontends/or51132.c3
-rw-r--r--drivers/media/video/arv.c12
-rw-r--r--drivers/media/video/bttv-driver.c6
-rw-r--r--drivers/media/video/indycam.c262
-rw-r--r--drivers/media/video/indycam.h88
-rw-r--r--drivers/media/video/msp3400.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c4
-rw-r--r--drivers/media/video/saa7191.c533
-rw-r--r--drivers/media/video/saa7191.h172
-rw-r--r--drivers/media/video/v4l1-compat.c6
-rw-r--r--drivers/media/video/videocodec.c6
-rw-r--r--drivers/media/video/videodev.c3
-rw-r--r--drivers/media/video/vino.c1170
-rw-r--r--drivers/media/video/zoran_card.c14
-rw-r--r--drivers/media/video/zoran_driver.c4
-rw-r--r--drivers/message/fusion/mptlan.c10
-rw-r--r--drivers/message/fusion/mptscsih.c6
-rw-r--r--drivers/message/i2o/exec-osm.c1
-rw-r--r--drivers/message/i2o/iop.c15
-rw-r--r--drivers/mfd/mcp-core.c2
-rw-r--r--drivers/mmc/mmc.c2
-rw-r--r--drivers/mmc/wbsd.c3
-rw-r--r--drivers/mtd/Kconfig40
-rw-r--r--drivers/mtd/Makefile5
-rw-r--r--drivers/mtd/afs.c16
-rw-r--r--drivers/mtd/chips/Kconfig22
-rw-r--r--drivers/mtd/chips/Makefile4
-rw-r--r--drivers/mtd/chips/amd_flash.c80
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c487
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c160
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c183
-rw-r--r--drivers/mtd/chips/cfi_probe.c98
-rw-r--r--drivers/mtd/chips/cfi_util.c25
-rw-r--r--drivers/mtd/chips/chipreg.c6
-rw-r--r--drivers/mtd/chips/fwh_lock.h6
-rw-r--r--drivers/mtd/chips/gen_probe.c33
-rw-r--r--drivers/mtd/chips/jedec.c206
-rw-r--r--drivers/mtd/chips/jedec_probe.c48
-rw-r--r--drivers/mtd/chips/map_absent.c8
-rw-r--r--drivers/mtd/chips/sharp.c23
-rw-r--r--drivers/mtd/cmdlinepart.c56
-rw-r--r--drivers/mtd/devices/Kconfig8
-rw-r--r--drivers/mtd/devices/blkmtd.c17
-rw-r--r--drivers/mtd/devices/block2mtd.c8
-rw-r--r--drivers/mtd/devices/doc2000.c42
-rw-r--r--drivers/mtd/devices/doc2001.c24
-rw-r--r--drivers/mtd/devices/doc2001plus.c20
-rw-r--r--drivers/mtd/devices/docecc.c40
-rw-r--r--drivers/mtd/devices/docprobe.c84
-rw-r--r--drivers/mtd/devices/lart.c8
-rw-r--r--drivers/mtd/devices/phram.c14
-rw-r--r--drivers/mtd/devices/pmc551.c24
-rw-r--r--drivers/mtd/devices/slram.c30
-rw-r--r--drivers/mtd/ftl.c128
-rw-r--r--drivers/mtd/inftlcore.c60
-rw-r--r--drivers/mtd/inftlmount.c26
-rw-r--r--drivers/mtd/maps/Kconfig115
-rw-r--r--drivers/mtd/maps/Makefile7
-rw-r--r--drivers/mtd/maps/alchemy-flash.c12
-rw-r--r--drivers/mtd/maps/amd76xrom.c20
-rw-r--r--drivers/mtd/maps/arctic-mtd.c6
-rw-r--r--drivers/mtd/maps/autcpu12-nvram.c18
-rw-r--r--drivers/mtd/maps/bast-flash.c22
-rw-r--r--drivers/mtd/maps/beech-mtd.c6
-rw-r--r--drivers/mtd/maps/cdb89712.c34
-rw-r--r--drivers/mtd/maps/ceiva.c3
-rw-r--r--drivers/mtd/maps/cfi_flagadm.c12
-rw-r--r--drivers/mtd/maps/cstm_mips_ixx.c24
-rw-r--r--drivers/mtd/maps/dbox2-flash.c38
-rw-r--r--drivers/mtd/maps/dc21285.c34
-rw-r--r--drivers/mtd/maps/dilnetpc.c32
-rw-r--r--drivers/mtd/maps/dmv182.c8
-rw-r--r--drivers/mtd/maps/ebony.c6
-rw-r--r--drivers/mtd/maps/edb7312.c10
-rw-r--r--drivers/mtd/maps/epxa10db-flash.c12
-rw-r--r--drivers/mtd/maps/fortunet.c4
-rw-r--r--drivers/mtd/maps/h720x-flash.c16
-rw-r--r--drivers/mtd/maps/ichxrom.c21
-rw-r--r--drivers/mtd/maps/impa7.c16
-rw-r--r--drivers/mtd/maps/integrator-flash.c20
-rw-r--r--drivers/mtd/maps/ipaq-flash.c37
-rw-r--r--drivers/mtd/maps/iq80310.c7
-rw-r--r--drivers/mtd/maps/ixp2000.c35
-rw-r--r--drivers/mtd/maps/ixp4xx.c56
-rw-r--r--drivers/mtd/maps/l440gx.c18
-rw-r--r--drivers/mtd/maps/lubbock-flash.c17
-rw-r--r--drivers/mtd/maps/mainstone-flash.c22
-rw-r--r--drivers/mtd/maps/mbx860.c6
-rw-r--r--drivers/mtd/maps/mtx-1_flash.c96
-rw-r--r--drivers/mtd/maps/netsc520.c32
-rw-r--r--drivers/mtd/maps/nettel.c8
-rw-r--r--drivers/mtd/maps/ocelot.c10
-rw-r--r--drivers/mtd/maps/octagon-5066.c36
-rw-r--r--drivers/mtd/maps/omap-toto-flash.c23
-rw-r--r--drivers/mtd/maps/omap_nor.c2
-rw-r--r--drivers/mtd/maps/pci.c6
-rw-r--r--drivers/mtd/maps/pcmciamtd.c30
-rw-r--r--drivers/mtd/maps/physmap.c8
-rw-r--r--drivers/mtd/maps/plat-ram.c13
-rw-r--r--drivers/mtd/maps/pnc2000.c8
-rw-r--r--drivers/mtd/maps/pq2fads.c88
-rw-r--r--drivers/mtd/maps/redwood.c4
-rw-r--r--drivers/mtd/maps/sa1100-flash.c9
-rw-r--r--drivers/mtd/maps/sbc8240.c4
-rw-r--r--drivers/mtd/maps/sbc_gxx.c46
-rw-r--r--drivers/mtd/maps/sc520cdp.c6
-rw-r--r--drivers/mtd/maps/scx200_docflash.c46
-rw-r--r--drivers/mtd/maps/sharpsl-flash.c12
-rw-r--r--drivers/mtd/maps/solutionengine.c4
-rw-r--r--drivers/mtd/maps/sun_uflash.c16
-rw-r--r--drivers/mtd/maps/tqm834x.c291
-rw-r--r--drivers/mtd/maps/tqm8xxl.c26
-rw-r--r--drivers/mtd/maps/ts5500_flash.c44
-rw-r--r--drivers/mtd/maps/tsunami_flash.c6
-rw-r--r--drivers/mtd/maps/uclinux.c4
-rw-r--r--drivers/mtd/maps/vmax301.c24
-rw-r--r--drivers/mtd/maps/walnut.c16
-rw-r--r--drivers/mtd/maps/wr_sbc82xx_flash.c6
-rw-r--r--drivers/mtd/mtd_blkdevs.c44
-rw-r--r--drivers/mtd/mtdblock.c53
-rw-r--r--drivers/mtd/mtdchar.c86
-rw-r--r--drivers/mtd/mtdconcat.c13
-rw-r--r--drivers/mtd/mtdcore.c62
-rw-r--r--drivers/mtd/mtdpart.c99
-rw-r--r--drivers/mtd/nand/Kconfig26
-rw-r--r--drivers/mtd/nand/au1550nd.c165
-rw-r--r--drivers/mtd/nand/autcpu12.c22
-rw-r--r--drivers/mtd/nand/diskonchip.c100
-rw-r--r--drivers/mtd/nand/edb7312.c48
-rw-r--r--drivers/mtd/nand/h1910.c48
-rw-r--r--drivers/mtd/nand/nand_base.c534
-rw-r--r--drivers/mtd/nand/nand_bbt.c248
-rw-r--r--drivers/mtd/nand/nand_ecc.c44
-rw-r--r--drivers/mtd/nand/nand_ids.c30
-rw-r--r--drivers/mtd/nand/nandsim.c162
-rw-r--r--drivers/mtd/nand/ppchameleonevb.c6
-rw-r--r--drivers/mtd/nand/rtc_from4.c58
-rw-r--r--drivers/mtd/nand/s3c2410.c61
-rw-r--r--drivers/mtd/nand/sharpsl.c41
-rw-r--r--drivers/mtd/nand/spia.c6
-rw-r--r--drivers/mtd/nand/toto.c20
-rw-r--r--drivers/mtd/nftlcore.c92
-rw-r--r--drivers/mtd/nftlmount.c56
-rw-r--r--drivers/mtd/onenand/Kconfig38
-rw-r--r--drivers/mtd/onenand/Makefile11
-rw-r--r--drivers/mtd/onenand/generic.c147
-rw-r--r--drivers/mtd/onenand/onenand_base.c1588
-rw-r--r--drivers/mtd/onenand/onenand_bbt.c246
-rw-r--r--drivers/mtd/redboot.c4
-rw-r--r--drivers/mtd/rfd_ftl.c855
-rw-r--r--drivers/net/3c59x.c586
-rw-r--r--drivers/net/bnx2.c468
-rw-r--r--drivers/net/bnx2.h119
-rw-r--r--drivers/net/bnx2_fw.h4053
-rw-r--r--drivers/net/depca.c24
-rw-r--r--drivers/net/e1000/e1000_ethtool.c2
-rw-r--r--drivers/net/e1000/e1000_hw.c101
-rw-r--r--drivers/net/e1000/e1000_hw.h42
-rw-r--r--drivers/net/e1000/e1000_main.c31
-rw-r--r--drivers/net/fec.c240
-rw-r--r--drivers/net/fec.h10
-rw-r--r--drivers/net/fec_8xx/Kconfig2
-rw-r--r--drivers/net/hamradio/dmascc.c10
-rw-r--r--drivers/net/ixgb/ixgb_ethtool.c2
-rw-r--r--drivers/net/ixgb/ixgb_hw.c31
-rw-r--r--drivers/net/ixgb/ixgb_hw.h17
-rw-r--r--drivers/net/ixgb/ixgb_main.c2
-rw-r--r--drivers/net/jazzsonic.c28
-rw-r--r--drivers/net/macsonic.c27
-rw-r--r--drivers/net/phy/cicada.c1
-rw-r--r--drivers/net/phy/davicom.c1
-rw-r--r--drivers/net/phy/lxt.c1
-rw-r--r--drivers/net/phy/marvell.c1
-rw-r--r--drivers/net/phy/mdio_bus.c1
-rw-r--r--drivers/net/phy/phy.c1
-rw-r--r--drivers/net/phy/phy_device.c1
-rw-r--r--drivers/net/phy/qsemi.c1
-rw-r--r--drivers/net/s2io.c10
-rw-r--r--drivers/net/wireless/airo.c2
-rw-r--r--drivers/net/wireless/airo.h9
-rw-r--r--drivers/net/wireless/airo_cs.c6
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c1
-rw-r--r--drivers/parport/probe.c21
-rw-r--r--drivers/parport/share.c19
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c15
-rw-r--r--drivers/pci/hotplug/pciehprm_nonacpi.c1
-rw-r--r--drivers/pci/pci-driver.c1
-rw-r--r--drivers/pcmcia/cistpl.c12
-rw-r--r--drivers/pcmcia/cs.c6
-rw-r--r--drivers/pnp/card.c4
-rw-r--r--drivers/pnp/core.c5
-rw-r--r--drivers/pnp/driver.c2
-rw-r--r--drivers/pnp/isapnp/core.c2
-rw-r--r--drivers/pnp/manager.c2
-rw-r--r--drivers/pnp/pnpacpi/core.c6
-rw-r--r--drivers/pnp/resource.c2
-rw-r--r--drivers/rapidio/Kconfig18
-rw-r--r--drivers/rapidio/Makefile6
-rw-r--r--drivers/rapidio/rio-access.c175
-rw-r--r--drivers/rapidio/rio-driver.c229
-rw-r--r--drivers/rapidio/rio-scan.c945
-rw-r--r--drivers/rapidio/rio-sysfs.c230
-rw-r--r--drivers/rapidio/rio.c510
-rw-r--r--drivers/rapidio/rio.h60
-rw-r--r--drivers/rapidio/switches/Makefile5
-rw-r--r--drivers/rapidio/switches/tsi500.c60
-rw-r--r--drivers/s390/block/dasd.c12
-rw-r--r--drivers/s390/block/dasd_devmap.c3
-rw-r--r--drivers/s390/block/dasd_diag.c64
-rw-r--r--drivers/s390/block/dasd_diag.h10
-rw-r--r--drivers/s390/char/con3215.c3
-rw-r--r--drivers/s390/char/keyboard.c15
-rw-r--r--drivers/s390/char/raw3270.c3
-rw-r--r--drivers/s390/char/tape_core.c9
-rw-r--r--drivers/s390/char/vmcp.c4
-rw-r--r--drivers/s390/cio/ccwgroup.c6
-rw-r--r--drivers/s390/cio/cmf.c3
-rw-r--r--drivers/s390/cio/device_ops.c6
-rw-r--r--drivers/s390/cio/qdio.c17
-rw-r--r--drivers/s390/crypto/z90main.c7
-rw-r--r--drivers/s390/net/claw.c36
-rw-r--r--drivers/s390/net/fsm.c3
-rw-r--r--drivers/s390/net/iucv.c12
-rw-r--r--drivers/s390/net/lcs.c3
-rw-r--r--drivers/s390/net/qeth_eddp.c3
-rw-r--r--drivers/s390/scsi/zfcp_aux.c3
-rw-r--r--drivers/sbus/char/cpwatchdog.c24
-rw-r--r--drivers/sbus/char/display7seg.c32
-rw-r--r--drivers/sbus/char/envctrl.c31
-rw-r--r--drivers/sbus/char/openprom.c33
-rw-r--r--drivers/scsi/3w-9xxx.c3
-rw-r--r--drivers/scsi/NCR5380.c5
-rw-r--r--drivers/scsi/aacraid/commsup.c14
-rw-r--r--drivers/scsi/aacraid/rkt.c6
-rw-r--r--drivers/scsi/aacraid/rx.c6
-rw-r--r--drivers/scsi/aacraid/sa.c6
-rw-r--r--drivers/scsi/advansys.c12
-rw-r--r--drivers/scsi/aha1542.c36
-rw-r--r--drivers/scsi/aic7xxx_old.c3
-rw-r--r--drivers/scsi/arm/queue.c3
-rw-r--r--drivers/scsi/atari_dma_emul.c2
-rw-r--r--drivers/scsi/dc395x.c3
-rw-r--r--drivers/scsi/dpt_i2o.c61
-rw-r--r--drivers/scsi/eata.c3
-rw-r--r--drivers/scsi/ide-scsi.c10
-rw-r--r--drivers/scsi/ips.c18
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c6
-rw-r--r--drivers/scsi/lpfc/lpfc_mbox.c7
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c12
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c7
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c5
-rw-r--r--drivers/scsi/megaraid/megaraid_mm.c11
-rw-r--r--drivers/scsi/osst.c9
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c16
-rw-r--r--drivers/scsi/raid_class.c2
-rw-r--r--drivers/scsi/scsi_transport_sas.c2
-rw-r--r--drivers/scsi/sg.c9
-rw-r--r--drivers/scsi/st.c3
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c1
-rw-r--r--drivers/scsi/u14-34f.c9
-rw-r--r--drivers/serial/8250.c76
-rw-r--r--drivers/serial/8250.h1
-rw-r--r--drivers/serial/8250_au1x00.c102
-rw-r--r--drivers/serial/Kconfig8
-rw-r--r--drivers/serial/Makefile1
-rw-r--r--drivers/serial/crisv10.c9
-rw-r--r--drivers/serial/mcfserial.c37
-rw-r--r--drivers/serial/serial_core.c1
-rw-r--r--drivers/serial/sunsu.c2
-rw-r--r--drivers/sh/superhyway/superhyway-sysfs.c2
-rw-r--r--drivers/sh/superhyway/superhyway.c75
-rw-r--r--drivers/tc/.gitignore1
-rw-r--r--drivers/video/68328fb.c1
-rw-r--r--drivers/video/Kconfig214
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/acornfb.c1
-rw-r--r--drivers/video/amba-clcd.c1
-rw-r--r--drivers/video/amifb.c1
-rw-r--r--drivers/video/arcfb.c26
-rw-r--r--drivers/video/asiliantfb.c1
-rw-r--r--drivers/video/aty/ati_ids.h1
-rw-r--r--drivers/video/aty/aty128fb.c1
-rw-r--r--drivers/video/aty/atyfb_base.c59
-rw-r--r--drivers/video/aty/radeon_base.c3
-rw-r--r--drivers/video/aty/radeonfb.h3
-rw-r--r--drivers/video/bw2.c1
-rw-r--r--drivers/video/cfbcopyarea.c36
-rw-r--r--drivers/video/cfbfillrect.c24
-rw-r--r--drivers/video/cfbimgblt.c22
-rw-r--r--drivers/video/cg14.c1
-rw-r--r--drivers/video/cg3.c1
-rw-r--r--drivers/video/cg6.c7
-rw-r--r--drivers/video/chipsfb.c1
-rw-r--r--drivers/video/cirrusfb.c1
-rw-r--r--drivers/video/clps711xfb.c1
-rw-r--r--drivers/video/console/Kconfig9
-rw-r--r--drivers/video/console/Makefile3
-rw-r--r--drivers/video/console/bitblit.c7
-rw-r--r--drivers/video/console/fbcon.c114
-rw-r--r--drivers/video/console/fbcon.h2
-rw-r--r--drivers/video/console/font_rl.c4374
-rw-r--r--drivers/video/console/fonts.c4
-rw-r--r--drivers/video/console/softcursor.c (renamed from drivers/video/softcursor.c)8
-rw-r--r--drivers/video/controlfb.c1
-rw-r--r--drivers/video/cyber2000fb.c1
-rw-r--r--drivers/video/cyblafb.c1
-rw-r--r--drivers/video/dnfb.c1
-rw-r--r--drivers/video/epson1355fb.c1
-rw-r--r--drivers/video/fbmon.c48
-rw-r--r--drivers/video/ffb.c3
-rw-r--r--drivers/video/fm2fb.c1
-rw-r--r--drivers/video/gbefb.c19
-rw-r--r--drivers/video/geode/Kconfig1
-rw-r--r--drivers/video/geode/gx1fb_core.c1
-rw-r--r--drivers/video/hitfb.c1
-rw-r--r--drivers/video/hpfb.c1
-rw-r--r--drivers/video/i810/i810-i2c.c135
-rw-r--r--drivers/video/i810/i810.h3
-rw-r--r--drivers/video/i810/i810_main.c22
-rw-r--r--drivers/video/i810/i810_regs.h1
-rw-r--r--drivers/video/imsttfb.c1
-rw-r--r--drivers/video/imxfb.c1
-rw-r--r--drivers/video/intelfb/intelfb.h6
-rw-r--r--drivers/video/intelfb/intelfbdrv.c10
-rw-r--r--drivers/video/intelfb/intelfbhw.c5
-rw-r--r--drivers/video/kyro/fbdev.c1
-rw-r--r--drivers/video/leo.c1
-rw-r--r--drivers/video/logo/Kconfig2
-rw-r--r--drivers/video/macfb.c1
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.c4
-rw-r--r--drivers/video/matrox/matroxfb_accel.c2
-rw-r--r--drivers/video/matrox/matroxfb_base.c29
-rw-r--r--drivers/video/matrox/matroxfb_base.h5
-rw-r--r--drivers/video/matrox/matroxfb_crtc2.c1
-rw-r--r--drivers/video/maxinefb.c1
-rw-r--r--drivers/video/modedb.c84
-rw-r--r--drivers/video/neofb.c1
-rw-r--r--drivers/video/nvidia/nv_local.h2
-rw-r--r--drivers/video/nvidia/nv_of.c64
-rw-r--r--drivers/video/nvidia/nv_proto.h18
-rw-r--r--drivers/video/nvidia/nv_setup.c16
-rw-r--r--drivers/video/nvidia/nvidia.c128
-rw-r--r--drivers/video/offb.c1
-rw-r--r--drivers/video/p9100.c1
-rw-r--r--drivers/video/platinumfb.c1
-rw-r--r--drivers/video/pm2fb.c17
-rw-r--r--drivers/video/pmag-ba-fb.c1
-rw-r--r--drivers/video/pmagb-b-fb.c1
-rw-r--r--drivers/video/pvr2fb.c1
-rw-r--r--drivers/video/pxafb.c1
-rw-r--r--drivers/video/q40fb.c1
-rw-r--r--drivers/video/radeonfb.c1
-rw-r--r--drivers/video/s1d13xxxfb.c1
-rw-r--r--drivers/video/s3c2410fb.c2
-rw-r--r--drivers/video/sa1100fb.c1
-rw-r--r--drivers/video/savage/savagefb.h206
-rw-r--r--drivers/video/savage/savagefb_driver.c840
-rw-r--r--drivers/video/sgivwfb.c25
-rw-r--r--drivers/video/sis/sis_main.c2
-rw-r--r--drivers/video/skeletonfb.c9
-rw-r--r--drivers/video/sstfb.c1
-rw-r--r--drivers/video/stifb.c1
-rw-r--r--drivers/video/tcx.c1
-rw-r--r--drivers/video/tdfxfb.c1
-rw-r--r--drivers/video/tgafb.c1
-rw-r--r--drivers/video/tridentfb.c1
-rw-r--r--drivers/video/tx3912fb.c1
-rw-r--r--drivers/video/valkyriefb.c1
-rw-r--r--drivers/video/vesafb.c59
-rw-r--r--drivers/video/vfb.c1
-rw-r--r--drivers/video/vga16fb.c1
-rw-r--r--drivers/video/w100fb.c1
-rw-r--r--drivers/w1/w1_ds2433.c6
542 files changed, 25611 insertions, 20030 deletions
diff --git a/drivers/Makefile b/drivers/Makefile
index 65670be6ff1a..fac1e1603097 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -7,6 +7,7 @@
7 7
8obj-$(CONFIG_PCI) += pci/ usb/ 8obj-$(CONFIG_PCI) += pci/ usb/
9obj-$(CONFIG_PARISC) += parisc/ 9obj-$(CONFIG_PARISC) += parisc/
10obj-$(CONFIG_RAPIDIO) += rapidio/
10obj-y += video/ 11obj-y += video/
11obj-$(CONFIG_ACPI) += acpi/ 12obj-$(CONFIG_ACPI) += acpi/
12# PnP must come after ACPI since it will eventually need to check if acpi 13# PnP must come after ACPI since it will eventually need to check if acpi
@@ -67,3 +68,4 @@ obj-$(CONFIG_INFINIBAND) += infiniband/
67obj-$(CONFIG_SGI_IOC4) += sn/ 68obj-$(CONFIG_SGI_IOC4) += sn/
68obj-y += firmware/ 69obj-y += firmware/
69obj-$(CONFIG_CRYPTO) += crypto/ 70obj-$(CONFIG_CRYPTO) += crypto/
71obj-$(CONFIG_SUPERH) += sh/
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 10dd695a1dd9..27ec12c1fab0 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -118,11 +118,9 @@ static int acpi_container_remove(struct acpi_device *device, int type)
118{ 118{
119 acpi_status status = AE_OK; 119 acpi_status status = AE_OK;
120 struct acpi_container *pc = NULL; 120 struct acpi_container *pc = NULL;
121 pc = (struct acpi_container *)acpi_driver_data(device);
122
123 if (pc)
124 kfree(pc);
125 121
122 pc = (struct acpi_container *)acpi_driver_data(device);
123 kfree(pc);
126 return status; 124 return status;
127} 125}
128 126
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index d528c750a380..e3cd0b16031a 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -313,8 +313,7 @@ acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
313 313
314void acpi_os_sleep(acpi_integer ms) 314void acpi_os_sleep(acpi_integer ms)
315{ 315{
316 current->state = TASK_INTERRUPTIBLE; 316 schedule_timeout_interruptible(msecs_to_jiffies(ms));
317 schedule_timeout(((signed long)ms * HZ) / 1000);
318} 317}
319 318
320EXPORT_SYMBOL(acpi_os_sleep); 319EXPORT_SYMBOL(acpi_os_sleep);
@@ -838,8 +837,7 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
838 837
839 ret = down_trylock(sem); 838 ret = down_trylock(sem);
840 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { 839 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
841 current->state = TASK_INTERRUPTIBLE; 840 schedule_timeout_interruptible(1);
842 schedule_timeout(1);
843 ret = down_trylock(sem); 841 ret = down_trylock(sem);
844 } 842 }
845 843
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c6db591479de..23e2c6968a11 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -28,8 +28,7 @@ static int acpi_bus_trim(struct acpi_device *start, int rmdevice);
28static void acpi_device_release(struct kobject *kobj) 28static void acpi_device_release(struct kobject *kobj)
29{ 29{
30 struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj); 30 struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj);
31 if (dev->pnp.cid_list) 31 kfree(dev->pnp.cid_list);
32 kfree(dev->pnp.cid_list);
33 kfree(dev); 32 kfree(dev);
34} 33}
35 34
@@ -1117,8 +1116,7 @@ acpi_add_single_object(struct acpi_device **child,
1117 if (!result) 1116 if (!result)
1118 *child = device; 1117 *child = device;
1119 else { 1118 else {
1120 if (device->pnp.cid_list) 1119 kfree(device->pnp.cid_list);
1121 kfree(device->pnp.cid_list);
1122 kfree(device); 1120 kfree(device);
1123 } 1121 }
1124 1122
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index e383d6109ae1..f051b151580d 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -334,8 +334,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
334 return_VALUE(0); 334 return_VALUE(0);
335 335
336 err: 336 err:
337 if (buffer.pointer) 337 kfree(buffer.pointer);
338 kfree(buffer.pointer);
339 338
340 return_VALUE(status); 339 return_VALUE(status);
341} 340}
@@ -1488,8 +1487,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1488 } 1487 }
1489 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END; 1488 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
1490 1489
1491 if (video->attached_array) 1490 kfree(video->attached_array);
1492 kfree(video->attached_array);
1493 1491
1494 video->attached_array = active_device_list; 1492 video->attached_array = active_device_list;
1495 video->attached_count = count; 1493 video->attached_count = count;
@@ -1645,8 +1643,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1645 printk(KERN_WARNING PREFIX 1643 printk(KERN_WARNING PREFIX
1646 "hhuuhhuu bug in acpi video driver.\n"); 1644 "hhuuhhuu bug in acpi video driver.\n");
1647 1645
1648 if (data->brightness) 1646 kfree(data->brightness);
1649 kfree(data->brightness);
1650 1647
1651 kfree(data); 1648 kfree(data);
1652 } 1649 }
@@ -1831,8 +1828,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1831 acpi_video_bus_put_devices(video); 1828 acpi_video_bus_put_devices(video);
1832 acpi_video_bus_remove_fs(device); 1829 acpi_video_bus_remove_fs(device);
1833 1830
1834 if (video->attached_array) 1831 kfree(video->attached_array);
1835 kfree(video->attached_array);
1836 kfree(video); 1832 kfree(video);
1837 1833
1838 return_VALUE(0); 1834 return_VALUE(0);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index d597c922af11..6d4736e89f1a 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -116,12 +116,115 @@ int platform_add_devices(struct platform_device **devs, int num)
116 return ret; 116 return ret;
117} 117}
118 118
119struct platform_object {
120 struct platform_device pdev;
121 char name[1];
122};
123
119/** 124/**
120 * platform_device_register - add a platform-level device 125 * platform_device_put
126 * @pdev: platform device to free
127 *
128 * Free all memory associated with a platform device. This function
129 * must _only_ be externally called in error cases. All other usage
130 * is a bug.
131 */
132void platform_device_put(struct platform_device *pdev)
133{
134 if (pdev)
135 put_device(&pdev->dev);
136}
137EXPORT_SYMBOL_GPL(platform_device_put);
138
139static void platform_device_release(struct device *dev)
140{
141 struct platform_object *pa = container_of(dev, struct platform_object, pdev.dev);
142
143 kfree(pa->pdev.dev.platform_data);
144 kfree(pa->pdev.resource);
145 kfree(pa);
146}
147
148/**
149 * platform_device_alloc
150 * @name: base name of the device we're adding
151 * @id: instance id
152 *
153 * Create a platform device object which can have other objects attached
154 * to it, and which will have attached objects freed when it is released.
155 */
156struct platform_device *platform_device_alloc(const char *name, unsigned int id)
157{
158 struct platform_object *pa;
159
160 pa = kzalloc(sizeof(struct platform_object) + strlen(name), GFP_KERNEL);
161 if (pa) {
162 strcpy(pa->name, name);
163 pa->pdev.name = pa->name;
164 pa->pdev.id = id;
165 device_initialize(&pa->pdev.dev);
166 pa->pdev.dev.release = platform_device_release;
167 }
168
169 return pa ? &pa->pdev : NULL;
170}
171EXPORT_SYMBOL_GPL(platform_device_alloc);
172
173/**
174 * platform_device_add_resources
175 * @pdev: platform device allocated by platform_device_alloc to add resources to
176 * @res: set of resources that needs to be allocated for the device
177 * @num: number of resources
178 *
179 * Add a copy of the resources to the platform device. The memory
180 * associated with the resources will be freed when the platform
181 * device is released.
182 */
183int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num)
184{
185 struct resource *r;
186
187 r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL);
188 if (r) {
189 memcpy(r, res, sizeof(struct resource) * num);
190 pdev->resource = r;
191 pdev->num_resources = num;
192 }
193 return r ? 0 : -ENOMEM;
194}
195EXPORT_SYMBOL_GPL(platform_device_add_resources);
196
197/**
198 * platform_device_add_data
199 * @pdev: platform device allocated by platform_device_alloc to add resources to
200 * @data: platform specific data for this platform device
201 * @size: size of platform specific data
202 *
203 * Add a copy of platform specific data to the platform device's platform_data
204 * pointer. The memory associated with the platform data will be freed
205 * when the platform device is released.
206 */
207int platform_device_add_data(struct platform_device *pdev, void *data, size_t size)
208{
209 void *d;
210
211 d = kmalloc(size, GFP_KERNEL);
212 if (d) {
213 memcpy(d, data, size);
214 pdev->dev.platform_data = d;
215 }
216 return d ? 0 : -ENOMEM;
217}
218EXPORT_SYMBOL_GPL(platform_device_add_data);
219
220/**
221 * platform_device_add - add a platform device to device hierarchy
121 * @pdev: platform device we're adding 222 * @pdev: platform device we're adding
122 * 223 *
224 * This is part 2 of platform_device_register(), though may be called
225 * separately _iff_ pdev was allocated by platform_device_alloc().
123 */ 226 */
124int platform_device_register(struct platform_device * pdev) 227int platform_device_add(struct platform_device *pdev)
125{ 228{
126 int i, ret = 0; 229 int i, ret = 0;
127 230
@@ -174,6 +277,18 @@ int platform_device_register(struct platform_device * pdev)
174 release_resource(&pdev->resource[i]); 277 release_resource(&pdev->resource[i]);
175 return ret; 278 return ret;
176} 279}
280EXPORT_SYMBOL_GPL(platform_device_add);
281
282/**
283 * platform_device_register - add a platform-level device
284 * @pdev: platform device we're adding
285 *
286 */
287int platform_device_register(struct platform_device * pdev)
288{
289 device_initialize(&pdev->dev);
290 return platform_device_add(pdev);
291}
177 292
178/** 293/**
179 * platform_device_unregister - remove a platform-level device 294 * platform_device_unregister - remove a platform-level device
@@ -197,18 +312,6 @@ void platform_device_unregister(struct platform_device * pdev)
197 } 312 }
198} 313}
199 314
200struct platform_object {
201 struct platform_device pdev;
202 struct resource resources[0];
203};
204
205static void platform_device_release_simple(struct device *dev)
206{
207 struct platform_device *pdev = to_platform_device(dev);
208
209 kfree(container_of(pdev, struct platform_object, pdev));
210}
211
212/** 315/**
213 * platform_device_register_simple 316 * platform_device_register_simple
214 * @name: base name of the device we're adding 317 * @name: base name of the device we're adding
@@ -225,33 +328,29 @@ static void platform_device_release_simple(struct device *dev)
225struct platform_device *platform_device_register_simple(char *name, unsigned int id, 328struct platform_device *platform_device_register_simple(char *name, unsigned int id,
226 struct resource *res, unsigned int num) 329 struct resource *res, unsigned int num)
227{ 330{
228 struct platform_object *pobj; 331 struct platform_device *pdev;
229 int retval; 332 int retval;
230 333
231 pobj = kzalloc(sizeof(*pobj) + sizeof(struct resource) * num, GFP_KERNEL); 334 pdev = platform_device_alloc(name, id);
232 if (!pobj) { 335 if (!pdev) {
233 retval = -ENOMEM; 336 retval = -ENOMEM;
234 goto error; 337 goto error;
235 } 338 }
236 339
237 pobj->pdev.name = name;
238 pobj->pdev.id = id;
239 pobj->pdev.dev.release = platform_device_release_simple;
240
241 if (num) { 340 if (num) {
242 memcpy(pobj->resources, res, sizeof(struct resource) * num); 341 retval = platform_device_add_resources(pdev, res, num);
243 pobj->pdev.resource = pobj->resources; 342 if (retval)
244 pobj->pdev.num_resources = num; 343 goto error;
245 } 344 }
246 345
247 retval = platform_device_register(&pobj->pdev); 346 retval = platform_device_add(pdev);
248 if (retval) 347 if (retval)
249 goto error; 348 goto error;
250 349
251 return &pobj->pdev; 350 return pdev;
252 351
253error: 352error:
254 kfree(pobj); 353 platform_device_put(pdev);
255 return ERR_PTR(retval); 354 return ERR_PTR(retval);
256} 355}
257 356
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 89c57875f3e5..f3a0c562bcb5 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/device.h> 5#include <linux/device.h>
6#include <linux/string.h>
6#include "power.h" 7#include "power.h"
7 8
8 9
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 3760edfdc65c..70eaa5c7ac08 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -417,14 +417,12 @@ static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller)
417 * Remember the beginning of the group, but don't free it 417 * Remember the beginning of the group, but don't free it
418 * until we've reached the beginning of the next group. 418 * until we've reached the beginning of the next group.
419 */ 419 */
420 if (CommandGroup != NULL) 420 kfree(CommandGroup);
421 kfree(CommandGroup); 421 CommandGroup = Command;
422 CommandGroup = Command;
423 } 422 }
424 Controller->Commands[i] = NULL; 423 Controller->Commands[i] = NULL;
425 } 424 }
426 if (CommandGroup != NULL) 425 kfree(CommandGroup);
427 kfree(CommandGroup);
428 426
429 if (Controller->CombinedStatusBuffer != NULL) 427 if (Controller->CombinedStatusBuffer != NULL)
430 { 428 {
@@ -435,30 +433,23 @@ static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller)
435 433
436 if (ScatterGatherPool != NULL) 434 if (ScatterGatherPool != NULL)
437 pci_pool_destroy(ScatterGatherPool); 435 pci_pool_destroy(ScatterGatherPool);
438 if (Controller->FirmwareType == DAC960_V1_Controller) return; 436 if (Controller->FirmwareType == DAC960_V1_Controller)
437 return;
439 438
440 if (RequestSensePool != NULL) 439 if (RequestSensePool != NULL)
441 pci_pool_destroy(RequestSensePool); 440 pci_pool_destroy(RequestSensePool);
442 441
443 for (i = 0; i < DAC960_MaxLogicalDrives; i++) 442 for (i = 0; i < DAC960_MaxLogicalDrives; i++) {
444 if (Controller->V2.LogicalDeviceInformation[i] != NULL)
445 {
446 kfree(Controller->V2.LogicalDeviceInformation[i]); 443 kfree(Controller->V2.LogicalDeviceInformation[i]);
447 Controller->V2.LogicalDeviceInformation[i] = NULL; 444 Controller->V2.LogicalDeviceInformation[i] = NULL;
448 } 445 }
449 446
450 for (i = 0; i < DAC960_V2_MaxPhysicalDevices; i++) 447 for (i = 0; i < DAC960_V2_MaxPhysicalDevices; i++)
451 { 448 {
452 if (Controller->V2.PhysicalDeviceInformation[i] != NULL) 449 kfree(Controller->V2.PhysicalDeviceInformation[i]);
453 { 450 Controller->V2.PhysicalDeviceInformation[i] = NULL;
454 kfree(Controller->V2.PhysicalDeviceInformation[i]); 451 kfree(Controller->V2.InquiryUnitSerialNumber[i]);
455 Controller->V2.PhysicalDeviceInformation[i] = NULL; 452 Controller->V2.InquiryUnitSerialNumber[i] = NULL;
456 }
457 if (Controller->V2.InquiryUnitSerialNumber[i] != NULL)
458 {
459 kfree(Controller->V2.InquiryUnitSerialNumber[i]);
460 Controller->V2.InquiryUnitSerialNumber[i] = NULL;
461 }
462 } 453 }
463} 454}
464 455
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 51b0af1cebee..7b1cd93892be 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -409,16 +409,6 @@ config BLK_DEV_INITRD
409 for details. 409 for details.
410 410
411 411
412#XXX - it makes sense to enable this only for 32-bit subarch's, not for x86_64
413#for instance.
414config LBD
415 bool "Support for Large Block Devices"
416 depends on X86 || (MIPS && 32BIT) || PPC32 || ARCH_S390_31 || SUPERH || UML
417 help
418 Say Y here if you want to attach large (bigger than 2TB) discs to
419 your machine, or if you want to have a raid or loopback device
420 bigger than 2TB. Otherwise say N.
421
422config CDROM_PKTCDVD 412config CDROM_PKTCDVD
423 tristate "Packet writing on CD/DVD media" 413 tristate "Packet writing on CD/DVD media"
424 depends on !UML 414 depends on !UML
@@ -455,8 +445,6 @@ config CDROM_PKTCDVD_WCACHE
455 445
456source "drivers/s390/block/Kconfig" 446source "drivers/s390/block/Kconfig"
457 447
458source "drivers/block/Kconfig.iosched"
459
460config ATA_OVER_ETH 448config ATA_OVER_ETH
461 tristate "ATA over Ethernet support" 449 tristate "ATA over Ethernet support"
462 depends on NET 450 depends on NET
diff --git a/drivers/block/Kconfig.iosched b/drivers/block/Kconfig.iosched
deleted file mode 100644
index 5b90d2fa63b8..000000000000
--- a/drivers/block/Kconfig.iosched
+++ /dev/null
@@ -1,69 +0,0 @@
1
2menu "IO Schedulers"
3
4config IOSCHED_NOOP
5 bool
6 default y
7 ---help---
8 The no-op I/O scheduler is a minimal scheduler that does basic merging
9 and sorting. Its main uses include non-disk based block devices like
10 memory devices, and specialised software or hardware environments
11 that do their own scheduling and require only minimal assistance from
12 the kernel.
13
14config IOSCHED_AS
15 tristate "Anticipatory I/O scheduler"
16 default y
17 ---help---
18 The anticipatory I/O scheduler is the default disk scheduler. It is
19 generally a good choice for most environments, but is quite large and
20 complex when compared to the deadline I/O scheduler, it can also be
21 slower in some cases especially some database loads.
22
23config IOSCHED_DEADLINE
24 tristate "Deadline I/O scheduler"
25 default y
26 ---help---
27 The deadline I/O scheduler is simple and compact, and is often as
28 good as the anticipatory I/O scheduler, and in some database
29 workloads, better. In the case of a single process performing I/O to
30 a disk at any one time, its behaviour is almost identical to the
31 anticipatory I/O scheduler and so is a good choice.
32
33config IOSCHED_CFQ
34 tristate "CFQ I/O scheduler"
35 default y
36 ---help---
37 The CFQ I/O scheduler tries to distribute bandwidth equally
38 among all processes in the system. It should provide a fair
39 working environment, suitable for desktop systems.
40
41choice
42 prompt "Default I/O scheduler"
43 default DEFAULT_AS
44 help
45 Select the I/O scheduler which will be used by default for all
46 block devices.
47
48 config DEFAULT_AS
49 bool "Anticipatory" if IOSCHED_AS
50
51 config DEFAULT_DEADLINE
52 bool "Deadline" if IOSCHED_DEADLINE
53
54 config DEFAULT_CFQ
55 bool "CFQ" if IOSCHED_CFQ
56
57 config DEFAULT_NOOP
58 bool "No-op"
59
60endchoice
61
62config DEFAULT_IOSCHED
63 string
64 default "anticipatory" if DEFAULT_AS
65 default "deadline" if DEFAULT_DEADLINE
66 default "cfq" if DEFAULT_CFQ
67 default "noop" if DEFAULT_NOOP
68
69endmenu
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 1cf09a1c065b..3ec1f8df87b1 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -4,21 +4,7 @@
4# 12 June 2000, Christoph Hellwig <hch@infradead.org> 4# 12 June 2000, Christoph Hellwig <hch@infradead.org>
5# Rewritten to use lists instead of if-statements. 5# Rewritten to use lists instead of if-statements.
6# 6#
7# Note : at this point, these files are compiled on all systems.
8# In the future, some of these should be built conditionally.
9#
10
11#
12# NOTE that ll_rw_blk.c must come early in linkage order - it starts the
13# kblockd threads
14#
15
16obj-y := elevator.o ll_rw_blk.o ioctl.o genhd.o scsi_ioctl.o
17 7
18obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o
19obj-$(CONFIG_IOSCHED_AS) += as-iosched.o
20obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o
21obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o
22obj-$(CONFIG_MAC_FLOPPY) += swim3.o 8obj-$(CONFIG_MAC_FLOPPY) += swim3.o
23obj-$(CONFIG_BLK_DEV_FD) += floppy.o 9obj-$(CONFIG_BLK_DEV_FD) += floppy.o
24obj-$(CONFIG_BLK_DEV_FD98) += floppy98.o 10obj-$(CONFIG_BLK_DEV_FD98) += floppy98.o
diff --git a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c
deleted file mode 100644
index c6744ff38294..000000000000
--- a/drivers/block/as-iosched.c
+++ /dev/null
@@ -1,1985 +0,0 @@
1/*
2 * linux/drivers/block/as-iosched.c
3 *
4 * Anticipatory & deadline i/o scheduler.
5 *
6 * Copyright (C) 2002 Jens Axboe <axboe@suse.de>
7 * Nick Piggin <piggin@cyberone.com.au>
8 *
9 */
10#include <linux/kernel.h>
11#include <linux/fs.h>
12#include <linux/blkdev.h>
13#include <linux/elevator.h>
14#include <linux/bio.h>
15#include <linux/config.h>
16#include <linux/module.h>
17#include <linux/slab.h>
18#include <linux/init.h>
19#include <linux/compiler.h>
20#include <linux/hash.h>
21#include <linux/rbtree.h>
22#include <linux/interrupt.h>
23
24#define REQ_SYNC 1
25#define REQ_ASYNC 0
26
27/*
28 * See Documentation/block/as-iosched.txt
29 */
30
31/*
32 * max time before a read is submitted.
33 */
34#define default_read_expire (HZ / 8)
35
36/*
37 * ditto for writes, these limits are not hard, even
38 * if the disk is capable of satisfying them.
39 */
40#define default_write_expire (HZ / 4)
41
42/*
43 * read_batch_expire describes how long we will allow a stream of reads to
44 * persist before looking to see whether it is time to switch over to writes.
45 */
46#define default_read_batch_expire (HZ / 2)
47
48/*
49 * write_batch_expire describes how long we want a stream of writes to run for.
50 * This is not a hard limit, but a target we set for the auto-tuning thingy.
51 * See, the problem is: we can send a lot of writes to disk cache / TCQ in
52 * a short amount of time...
53 */
54#define default_write_batch_expire (HZ / 8)
55
56/*
57 * max time we may wait to anticipate a read (default around 6ms)
58 */
59#define default_antic_expire ((HZ / 150) ? HZ / 150 : 1)
60
61/*
62 * Keep track of up to 20ms thinktimes. We can go as big as we like here,
63 * however huge values tend to interfere and not decay fast enough. A program
64 * might be in a non-io phase of operation. Waiting on user input for example,
65 * or doing a lengthy computation. A small penalty can be justified there, and
66 * will still catch out those processes that constantly have large thinktimes.
67 */
68#define MAX_THINKTIME (HZ/50UL)
69
70/* Bits in as_io_context.state */
71enum as_io_states {
72 AS_TASK_RUNNING=0, /* Process has not exitted */
73 AS_TASK_IOSTARTED, /* Process has started some IO */
74 AS_TASK_IORUNNING, /* Process has completed some IO */
75};
76
77enum anticipation_status {
78 ANTIC_OFF=0, /* Not anticipating (normal operation) */
79 ANTIC_WAIT_REQ, /* The last read has not yet completed */
80 ANTIC_WAIT_NEXT, /* Currently anticipating a request vs
81 last read (which has completed) */
82 ANTIC_FINISHED, /* Anticipating but have found a candidate
83 * or timed out */
84};
85
86struct as_data {
87 /*
88 * run time data
89 */
90
91 struct request_queue *q; /* the "owner" queue */
92
93 /*
94 * requests (as_rq s) are present on both sort_list and fifo_list
95 */
96 struct rb_root sort_list[2];
97 struct list_head fifo_list[2];
98
99 struct as_rq *next_arq[2]; /* next in sort order */
100 sector_t last_sector[2]; /* last REQ_SYNC & REQ_ASYNC sectors */
101 struct list_head *hash; /* request hash */
102
103 unsigned long exit_prob; /* probability a task will exit while
104 being waited on */
105 unsigned long new_ttime_total; /* mean thinktime on new proc */
106 unsigned long new_ttime_mean;
107 u64 new_seek_total; /* mean seek on new proc */
108 sector_t new_seek_mean;
109
110 unsigned long current_batch_expires;
111 unsigned long last_check_fifo[2];
112 int changed_batch; /* 1: waiting for old batch to end */
113 int new_batch; /* 1: waiting on first read complete */
114 int batch_data_dir; /* current batch REQ_SYNC / REQ_ASYNC */
115 int write_batch_count; /* max # of reqs in a write batch */
116 int current_write_count; /* how many requests left this batch */
117 int write_batch_idled; /* has the write batch gone idle? */
118 mempool_t *arq_pool;
119
120 enum anticipation_status antic_status;
121 unsigned long antic_start; /* jiffies: when it started */
122 struct timer_list antic_timer; /* anticipatory scheduling timer */
123 struct work_struct antic_work; /* Deferred unplugging */
124 struct io_context *io_context; /* Identify the expected process */
125 int ioc_finished; /* IO associated with io_context is finished */
126 int nr_dispatched;
127
128 /*
129 * settings that change how the i/o scheduler behaves
130 */
131 unsigned long fifo_expire[2];
132 unsigned long batch_expire[2];
133 unsigned long antic_expire;
134};
135
136#define list_entry_fifo(ptr) list_entry((ptr), struct as_rq, fifo)
137
138/*
139 * per-request data.
140 */
141enum arq_state {
142 AS_RQ_NEW=0, /* New - not referenced and not on any lists */
143 AS_RQ_QUEUED, /* In the request queue. It belongs to the
144 scheduler */
145 AS_RQ_DISPATCHED, /* On the dispatch list. It belongs to the
146 driver now */
147 AS_RQ_PRESCHED, /* Debug poisoning for requests being used */
148 AS_RQ_REMOVED,
149 AS_RQ_MERGED,
150 AS_RQ_POSTSCHED, /* when they shouldn't be */
151};
152
153struct as_rq {
154 /*
155 * rbtree index, key is the starting offset
156 */
157 struct rb_node rb_node;
158 sector_t rb_key;
159
160 struct request *request;
161
162 struct io_context *io_context; /* The submitting task */
163
164 /*
165 * request hash, key is the ending offset (for back merge lookup)
166 */
167 struct list_head hash;
168 unsigned int on_hash;
169
170 /*
171 * expire fifo
172 */
173 struct list_head fifo;
174 unsigned long expires;
175
176 unsigned int is_sync;
177 enum arq_state state;
178};
179
180#define RQ_DATA(rq) ((struct as_rq *) (rq)->elevator_private)
181
182static kmem_cache_t *arq_pool;
183
184/*
185 * IO Context helper functions
186 */
187
188/* Called to deallocate the as_io_context */
189static void free_as_io_context(struct as_io_context *aic)
190{
191 kfree(aic);
192}
193
194/* Called when the task exits */
195static void exit_as_io_context(struct as_io_context *aic)
196{
197 WARN_ON(!test_bit(AS_TASK_RUNNING, &aic->state));
198 clear_bit(AS_TASK_RUNNING, &aic->state);
199}
200
201static struct as_io_context *alloc_as_io_context(void)
202{
203 struct as_io_context *ret;
204
205 ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
206 if (ret) {
207 ret->dtor = free_as_io_context;
208 ret->exit = exit_as_io_context;
209 ret->state = 1 << AS_TASK_RUNNING;
210 atomic_set(&ret->nr_queued, 0);
211 atomic_set(&ret->nr_dispatched, 0);
212 spin_lock_init(&ret->lock);
213 ret->ttime_total = 0;
214 ret->ttime_samples = 0;
215 ret->ttime_mean = 0;
216 ret->seek_total = 0;
217 ret->seek_samples = 0;
218 ret->seek_mean = 0;
219 }
220
221 return ret;
222}
223
224/*
225 * If the current task has no AS IO context then create one and initialise it.
226 * Then take a ref on the task's io context and return it.
227 */
228static struct io_context *as_get_io_context(void)
229{
230 struct io_context *ioc = get_io_context(GFP_ATOMIC);
231 if (ioc && !ioc->aic) {
232 ioc->aic = alloc_as_io_context();
233 if (!ioc->aic) {
234 put_io_context(ioc);
235 ioc = NULL;
236 }
237 }
238 return ioc;
239}
240
241static void as_put_io_context(struct as_rq *arq)
242{
243 struct as_io_context *aic;
244
245 if (unlikely(!arq->io_context))
246 return;
247
248 aic = arq->io_context->aic;
249
250 if (arq->is_sync == REQ_SYNC && aic) {
251 spin_lock(&aic->lock);
252 set_bit(AS_TASK_IORUNNING, &aic->state);
253 aic->last_end_request = jiffies;
254 spin_unlock(&aic->lock);
255 }
256
257 put_io_context(arq->io_context);
258}
259
260/*
261 * the back merge hash support functions
262 */
263static const int as_hash_shift = 6;
264#define AS_HASH_BLOCK(sec) ((sec) >> 3)
265#define AS_HASH_FN(sec) (hash_long(AS_HASH_BLOCK((sec)), as_hash_shift))
266#define AS_HASH_ENTRIES (1 << as_hash_shift)
267#define rq_hash_key(rq) ((rq)->sector + (rq)->nr_sectors)
268#define list_entry_hash(ptr) list_entry((ptr), struct as_rq, hash)
269
270static inline void __as_del_arq_hash(struct as_rq *arq)
271{
272 arq->on_hash = 0;
273 list_del_init(&arq->hash);
274}
275
276static inline void as_del_arq_hash(struct as_rq *arq)
277{
278 if (arq->on_hash)
279 __as_del_arq_hash(arq);
280}
281
282static void as_add_arq_hash(struct as_data *ad, struct as_rq *arq)
283{
284 struct request *rq = arq->request;
285
286 BUG_ON(arq->on_hash);
287
288 arq->on_hash = 1;
289 list_add(&arq->hash, &ad->hash[AS_HASH_FN(rq_hash_key(rq))]);
290}
291
292/*
293 * move hot entry to front of chain
294 */
295static inline void as_hot_arq_hash(struct as_data *ad, struct as_rq *arq)
296{
297 struct request *rq = arq->request;
298 struct list_head *head = &ad->hash[AS_HASH_FN(rq_hash_key(rq))];
299
300 if (!arq->on_hash) {
301 WARN_ON(1);
302 return;
303 }
304
305 if (arq->hash.prev != head) {
306 list_del(&arq->hash);
307 list_add(&arq->hash, head);
308 }
309}
310
311static struct request *as_find_arq_hash(struct as_data *ad, sector_t offset)
312{
313 struct list_head *hash_list = &ad->hash[AS_HASH_FN(offset)];
314 struct list_head *entry, *next = hash_list->next;
315
316 while ((entry = next) != hash_list) {
317 struct as_rq *arq = list_entry_hash(entry);
318 struct request *__rq = arq->request;
319
320 next = entry->next;
321
322 BUG_ON(!arq->on_hash);
323
324 if (!rq_mergeable(__rq)) {
325 as_del_arq_hash(arq);
326 continue;
327 }
328
329 if (rq_hash_key(__rq) == offset)
330 return __rq;
331 }
332
333 return NULL;
334}
335
336/*
337 * rb tree support functions
338 */
339#define RB_NONE (2)
340#define RB_EMPTY(root) ((root)->rb_node == NULL)
341#define ON_RB(node) ((node)->rb_color != RB_NONE)
342#define RB_CLEAR(node) ((node)->rb_color = RB_NONE)
343#define rb_entry_arq(node) rb_entry((node), struct as_rq, rb_node)
344#define ARQ_RB_ROOT(ad, arq) (&(ad)->sort_list[(arq)->is_sync])
345#define rq_rb_key(rq) (rq)->sector
346
347/*
348 * as_find_first_arq finds the first (lowest sector numbered) request
349 * for the specified data_dir. Used to sweep back to the start of the disk
350 * (1-way elevator) after we process the last (highest sector) request.
351 */
352static struct as_rq *as_find_first_arq(struct as_data *ad, int data_dir)
353{
354 struct rb_node *n = ad->sort_list[data_dir].rb_node;
355
356 if (n == NULL)
357 return NULL;
358
359 for (;;) {
360 if (n->rb_left == NULL)
361 return rb_entry_arq(n);
362
363 n = n->rb_left;
364 }
365}
366
367/*
368 * Add the request to the rb tree if it is unique. If there is an alias (an
369 * existing request against the same sector), which can happen when using
370 * direct IO, then return the alias.
371 */
372static struct as_rq *as_add_arq_rb(struct as_data *ad, struct as_rq *arq)
373{
374 struct rb_node **p = &ARQ_RB_ROOT(ad, arq)->rb_node;
375 struct rb_node *parent = NULL;
376 struct as_rq *__arq;
377 struct request *rq = arq->request;
378
379 arq->rb_key = rq_rb_key(rq);
380
381 while (*p) {
382 parent = *p;
383 __arq = rb_entry_arq(parent);
384
385 if (arq->rb_key < __arq->rb_key)
386 p = &(*p)->rb_left;
387 else if (arq->rb_key > __arq->rb_key)
388 p = &(*p)->rb_right;
389 else
390 return __arq;
391 }
392
393 rb_link_node(&arq->rb_node, parent, p);
394 rb_insert_color(&arq->rb_node, ARQ_RB_ROOT(ad, arq));
395
396 return NULL;
397}
398
399static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq)
400{
401 if (!ON_RB(&arq->rb_node)) {
402 WARN_ON(1);
403 return;
404 }
405
406 rb_erase(&arq->rb_node, ARQ_RB_ROOT(ad, arq));
407 RB_CLEAR(&arq->rb_node);
408}
409
410static struct request *
411as_find_arq_rb(struct as_data *ad, sector_t sector, int data_dir)
412{
413 struct rb_node *n = ad->sort_list[data_dir].rb_node;
414 struct as_rq *arq;
415
416 while (n) {
417 arq = rb_entry_arq(n);
418
419 if (sector < arq->rb_key)
420 n = n->rb_left;
421 else if (sector > arq->rb_key)
422 n = n->rb_right;
423 else
424 return arq->request;
425 }
426
427 return NULL;
428}
429
430/*
431 * IO Scheduler proper
432 */
433
434#define MAXBACK (1024 * 1024) /*
435 * Maximum distance the disk will go backward
436 * for a request.
437 */
438
439#define BACK_PENALTY 2
440
441/*
442 * as_choose_req selects the preferred one of two requests of the same data_dir
443 * ignoring time - eg. timeouts, which is the job of as_dispatch_request
444 */
445static struct as_rq *
446as_choose_req(struct as_data *ad, struct as_rq *arq1, struct as_rq *arq2)
447{
448 int data_dir;
449 sector_t last, s1, s2, d1, d2;
450 int r1_wrap=0, r2_wrap=0; /* requests are behind the disk head */
451 const sector_t maxback = MAXBACK;
452
453 if (arq1 == NULL || arq1 == arq2)
454 return arq2;
455 if (arq2 == NULL)
456 return arq1;
457
458 data_dir = arq1->is_sync;
459
460 last = ad->last_sector[data_dir];
461 s1 = arq1->request->sector;
462 s2 = arq2->request->sector;
463
464 BUG_ON(data_dir != arq2->is_sync);
465
466 /*
467 * Strict one way elevator _except_ in the case where we allow
468 * short backward seeks which are biased as twice the cost of a
469 * similar forward seek.
470 */
471 if (s1 >= last)
472 d1 = s1 - last;
473 else if (s1+maxback >= last)
474 d1 = (last - s1)*BACK_PENALTY;
475 else {
476 r1_wrap = 1;
477 d1 = 0; /* shut up, gcc */
478 }
479
480 if (s2 >= last)
481 d2 = s2 - last;
482 else if (s2+maxback >= last)
483 d2 = (last - s2)*BACK_PENALTY;
484 else {
485 r2_wrap = 1;
486 d2 = 0;
487 }
488
489 /* Found required data */
490 if (!r1_wrap && r2_wrap)
491 return arq1;
492 else if (!r2_wrap && r1_wrap)
493 return arq2;
494 else if (r1_wrap && r2_wrap) {
495 /* both behind the head */
496 if (s1 <= s2)
497 return arq1;
498 else
499 return arq2;
500 }
501
502 /* Both requests in front of the head */
503 if (d1 < d2)
504 return arq1;
505 else if (d2 < d1)
506 return arq2;
507 else {
508 if (s1 >= s2)
509 return arq1;
510 else
511 return arq2;
512 }
513}
514
515/*
516 * as_find_next_arq finds the next request after @prev in elevator order.
517 * this with as_choose_req form the basis for how the scheduler chooses
518 * what request to process next. Anticipation works on top of this.
519 */
520static struct as_rq *as_find_next_arq(struct as_data *ad, struct as_rq *last)
521{
522 const int data_dir = last->is_sync;
523 struct as_rq *ret;
524 struct rb_node *rbnext = rb_next(&last->rb_node);
525 struct rb_node *rbprev = rb_prev(&last->rb_node);
526 struct as_rq *arq_next, *arq_prev;
527
528 BUG_ON(!ON_RB(&last->rb_node));
529
530 if (rbprev)
531 arq_prev = rb_entry_arq(rbprev);
532 else
533 arq_prev = NULL;
534
535 if (rbnext)
536 arq_next = rb_entry_arq(rbnext);
537 else {
538 arq_next = as_find_first_arq(ad, data_dir);
539 if (arq_next == last)
540 arq_next = NULL;
541 }
542
543 ret = as_choose_req(ad, arq_next, arq_prev);
544
545 return ret;
546}
547
548/*
549 * anticipatory scheduling functions follow
550 */
551
552/*
553 * as_antic_expired tells us when we have anticipated too long.
554 * The funny "absolute difference" math on the elapsed time is to handle
555 * jiffy wraps, and disks which have been idle for 0x80000000 jiffies.
556 */
557static int as_antic_expired(struct as_data *ad)
558{
559 long delta_jif;
560
561 delta_jif = jiffies - ad->antic_start;
562 if (unlikely(delta_jif < 0))
563 delta_jif = -delta_jif;
564 if (delta_jif < ad->antic_expire)
565 return 0;
566
567 return 1;
568}
569
570/*
571 * as_antic_waitnext starts anticipating that a nice request will soon be
572 * submitted. See also as_antic_waitreq
573 */
574static void as_antic_waitnext(struct as_data *ad)
575{
576 unsigned long timeout;
577
578 BUG_ON(ad->antic_status != ANTIC_OFF
579 && ad->antic_status != ANTIC_WAIT_REQ);
580
581 timeout = ad->antic_start + ad->antic_expire;
582
583 mod_timer(&ad->antic_timer, timeout);
584
585 ad->antic_status = ANTIC_WAIT_NEXT;
586}
587
588/*
589 * as_antic_waitreq starts anticipating. We don't start timing the anticipation
590 * until the request that we're anticipating on has finished. This means we
591 * are timing from when the candidate process wakes up hopefully.
592 */
593static void as_antic_waitreq(struct as_data *ad)
594{
595 BUG_ON(ad->antic_status == ANTIC_FINISHED);
596 if (ad->antic_status == ANTIC_OFF) {
597 if (!ad->io_context || ad->ioc_finished)
598 as_antic_waitnext(ad);
599 else
600 ad->antic_status = ANTIC_WAIT_REQ;
601 }
602}
603
604/*
605 * This is called directly by the functions in this file to stop anticipation.
606 * We kill the timer and schedule a call to the request_fn asap.
607 */
608static void as_antic_stop(struct as_data *ad)
609{
610 int status = ad->antic_status;
611
612 if (status == ANTIC_WAIT_REQ || status == ANTIC_WAIT_NEXT) {
613 if (status == ANTIC_WAIT_NEXT)
614 del_timer(&ad->antic_timer);
615 ad->antic_status = ANTIC_FINISHED;
616 /* see as_work_handler */
617 kblockd_schedule_work(&ad->antic_work);
618 }
619}
620
621/*
622 * as_antic_timeout is the timer function set by as_antic_waitnext.
623 */
624static void as_antic_timeout(unsigned long data)
625{
626 struct request_queue *q = (struct request_queue *)data;
627 struct as_data *ad = q->elevator->elevator_data;
628 unsigned long flags;
629
630 spin_lock_irqsave(q->queue_lock, flags);
631 if (ad->antic_status == ANTIC_WAIT_REQ
632 || ad->antic_status == ANTIC_WAIT_NEXT) {
633 struct as_io_context *aic = ad->io_context->aic;
634
635 ad->antic_status = ANTIC_FINISHED;
636 kblockd_schedule_work(&ad->antic_work);
637
638 if (aic->ttime_samples == 0) {
639 /* process anticipated on has exitted or timed out*/
640 ad->exit_prob = (7*ad->exit_prob + 256)/8;
641 }
642 }
643 spin_unlock_irqrestore(q->queue_lock, flags);
644}
645
646/*
647 * as_close_req decides if one request is considered "close" to the
648 * previous one issued.
649 */
650static int as_close_req(struct as_data *ad, struct as_rq *arq)
651{
652 unsigned long delay; /* milliseconds */
653 sector_t last = ad->last_sector[ad->batch_data_dir];
654 sector_t next = arq->request->sector;
655 sector_t delta; /* acceptable close offset (in sectors) */
656
657 if (ad->antic_status == ANTIC_OFF || !ad->ioc_finished)
658 delay = 0;
659 else
660 delay = ((jiffies - ad->antic_start) * 1000) / HZ;
661
662 if (delay <= 1)
663 delta = 64;
664 else if (delay <= 20 && delay <= ad->antic_expire)
665 delta = 64 << (delay-1);
666 else
667 return 1;
668
669 return (last - (delta>>1) <= next) && (next <= last + delta);
670}
671
672/*
673 * as_can_break_anticipation returns true if we have been anticipating this
674 * request.
675 *
676 * It also returns true if the process against which we are anticipating
677 * submits a write - that's presumably an fsync, O_SYNC write, etc. We want to
678 * dispatch it ASAP, because we know that application will not be submitting
679 * any new reads.
680 *
681 * If the task which has submitted the request has exitted, break anticipation.
682 *
683 * If this task has queued some other IO, do not enter enticipation.
684 */
685static int as_can_break_anticipation(struct as_data *ad, struct as_rq *arq)
686{
687 struct io_context *ioc;
688 struct as_io_context *aic;
689 sector_t s;
690
691 ioc = ad->io_context;
692 BUG_ON(!ioc);
693
694 if (arq && ioc == arq->io_context) {
695 /* request from same process */
696 return 1;
697 }
698
699 if (ad->ioc_finished && as_antic_expired(ad)) {
700 /*
701 * In this situation status should really be FINISHED,
702 * however the timer hasn't had the chance to run yet.
703 */
704 return 1;
705 }
706
707 aic = ioc->aic;
708 if (!aic)
709 return 0;
710
711 if (!test_bit(AS_TASK_RUNNING, &aic->state)) {
712 /* process anticipated on has exitted */
713 if (aic->ttime_samples == 0)
714 ad->exit_prob = (7*ad->exit_prob + 256)/8;
715 return 1;
716 }
717
718 if (atomic_read(&aic->nr_queued) > 0) {
719 /* process has more requests queued */
720 return 1;
721 }
722
723 if (atomic_read(&aic->nr_dispatched) > 0) {
724 /* process has more requests dispatched */
725 return 1;
726 }
727
728 if (arq && arq->is_sync == REQ_SYNC && as_close_req(ad, arq)) {
729 /*
730 * Found a close request that is not one of ours.
731 *
732 * This makes close requests from another process reset
733 * our thinktime delay. Is generally useful when there are
734 * two or more cooperating processes working in the same
735 * area.
736 */
737 spin_lock(&aic->lock);
738 aic->last_end_request = jiffies;
739 spin_unlock(&aic->lock);
740 return 1;
741 }
742
743
744 if (aic->ttime_samples == 0) {
745 if (ad->new_ttime_mean > ad->antic_expire)
746 return 1;
747 if (ad->exit_prob > 128)
748 return 1;
749 } else if (aic->ttime_mean > ad->antic_expire) {
750 /* the process thinks too much between requests */
751 return 1;
752 }
753
754 if (!arq)
755 return 0;
756
757 if (ad->last_sector[REQ_SYNC] < arq->request->sector)
758 s = arq->request->sector - ad->last_sector[REQ_SYNC];
759 else
760 s = ad->last_sector[REQ_SYNC] - arq->request->sector;
761
762 if (aic->seek_samples == 0) {
763 /*
764 * Process has just started IO. Use past statistics to
765 * guage success possibility
766 */
767 if (ad->new_seek_mean > s) {
768 /* this request is better than what we're expecting */
769 return 1;
770 }
771
772 } else {
773 if (aic->seek_mean > s) {
774 /* this request is better than what we're expecting */
775 return 1;
776 }
777 }
778
779 return 0;
780}
781
782/*
783 * as_can_anticipate indicates weather we should either run arq
784 * or keep anticipating a better request.
785 */
786static int as_can_anticipate(struct as_data *ad, struct as_rq *arq)
787{
788 if (!ad->io_context)
789 /*
790 * Last request submitted was a write
791 */
792 return 0;
793
794 if (ad->antic_status == ANTIC_FINISHED)
795 /*
796 * Don't restart if we have just finished. Run the next request
797 */
798 return 0;
799
800 if (as_can_break_anticipation(ad, arq))
801 /*
802 * This request is a good candidate. Don't keep anticipating,
803 * run it.
804 */
805 return 0;
806
807 /*
808 * OK from here, we haven't finished, and don't have a decent request!
809 * Status is either ANTIC_OFF so start waiting,
810 * ANTIC_WAIT_REQ so continue waiting for request to finish
811 * or ANTIC_WAIT_NEXT so continue waiting for an acceptable request.
812 *
813 */
814
815 return 1;
816}
817
818static void as_update_thinktime(struct as_data *ad, struct as_io_context *aic, unsigned long ttime)
819{
820 /* fixed point: 1.0 == 1<<8 */
821 if (aic->ttime_samples == 0) {
822 ad->new_ttime_total = (7*ad->new_ttime_total + 256*ttime) / 8;
823 ad->new_ttime_mean = ad->new_ttime_total / 256;
824
825 ad->exit_prob = (7*ad->exit_prob)/8;
826 }
827 aic->ttime_samples = (7*aic->ttime_samples + 256) / 8;
828 aic->ttime_total = (7*aic->ttime_total + 256*ttime) / 8;
829 aic->ttime_mean = (aic->ttime_total + 128) / aic->ttime_samples;
830}
831
832static void as_update_seekdist(struct as_data *ad, struct as_io_context *aic, sector_t sdist)
833{
834 u64 total;
835
836 if (aic->seek_samples == 0) {
837 ad->new_seek_total = (7*ad->new_seek_total + 256*(u64)sdist)/8;
838 ad->new_seek_mean = ad->new_seek_total / 256;
839 }
840
841 /*
842 * Don't allow the seek distance to get too large from the
843 * odd fragment, pagein, etc
844 */
845 if (aic->seek_samples <= 60) /* second&third seek */
846 sdist = min(sdist, (aic->seek_mean * 4) + 2*1024*1024);
847 else
848 sdist = min(sdist, (aic->seek_mean * 4) + 2*1024*64);
849
850 aic->seek_samples = (7*aic->seek_samples + 256) / 8;
851 aic->seek_total = (7*aic->seek_total + (u64)256*sdist) / 8;
852 total = aic->seek_total + (aic->seek_samples/2);
853 do_div(total, aic->seek_samples);
854 aic->seek_mean = (sector_t)total;
855}
856
857/*
858 * as_update_iohist keeps a decaying histogram of IO thinktimes, and
859 * updates @aic->ttime_mean based on that. It is called when a new
860 * request is queued.
861 */
862static void as_update_iohist(struct as_data *ad, struct as_io_context *aic, struct request *rq)
863{
864 struct as_rq *arq = RQ_DATA(rq);
865 int data_dir = arq->is_sync;
866 unsigned long thinktime;
867 sector_t seek_dist;
868
869 if (aic == NULL)
870 return;
871
872 if (data_dir == REQ_SYNC) {
873 unsigned long in_flight = atomic_read(&aic->nr_queued)
874 + atomic_read(&aic->nr_dispatched);
875 spin_lock(&aic->lock);
876 if (test_bit(AS_TASK_IORUNNING, &aic->state) ||
877 test_bit(AS_TASK_IOSTARTED, &aic->state)) {
878 /* Calculate read -> read thinktime */
879 if (test_bit(AS_TASK_IORUNNING, &aic->state)
880 && in_flight == 0) {
881 thinktime = jiffies - aic->last_end_request;
882 thinktime = min(thinktime, MAX_THINKTIME-1);
883 } else
884 thinktime = 0;
885 as_update_thinktime(ad, aic, thinktime);
886
887 /* Calculate read -> read seek distance */
888 if (aic->last_request_pos < rq->sector)
889 seek_dist = rq->sector - aic->last_request_pos;
890 else
891 seek_dist = aic->last_request_pos - rq->sector;
892 as_update_seekdist(ad, aic, seek_dist);
893 }
894 aic->last_request_pos = rq->sector + rq->nr_sectors;
895 set_bit(AS_TASK_IOSTARTED, &aic->state);
896 spin_unlock(&aic->lock);
897 }
898}
899
900/*
901 * as_update_arq must be called whenever a request (arq) is added to
902 * the sort_list. This function keeps caches up to date, and checks if the
903 * request might be one we are "anticipating"
904 */
905static void as_update_arq(struct as_data *ad, struct as_rq *arq)
906{
907 const int data_dir = arq->is_sync;
908
909 /* keep the next_arq cache up to date */
910 ad->next_arq[data_dir] = as_choose_req(ad, arq, ad->next_arq[data_dir]);
911
912 /*
913 * have we been anticipating this request?
914 * or does it come from the same process as the one we are anticipating
915 * for?
916 */
917 if (ad->antic_status == ANTIC_WAIT_REQ
918 || ad->antic_status == ANTIC_WAIT_NEXT) {
919 if (as_can_break_anticipation(ad, arq))
920 as_antic_stop(ad);
921 }
922}
923
924/*
925 * Gathers timings and resizes the write batch automatically
926 */
927static void update_write_batch(struct as_data *ad)
928{
929 unsigned long batch = ad->batch_expire[REQ_ASYNC];
930 long write_time;
931
932 write_time = (jiffies - ad->current_batch_expires) + batch;
933 if (write_time < 0)
934 write_time = 0;
935
936 if (write_time > batch && !ad->write_batch_idled) {
937 if (write_time > batch * 3)
938 ad->write_batch_count /= 2;
939 else
940 ad->write_batch_count--;
941 } else if (write_time < batch && ad->current_write_count == 0) {
942 if (batch > write_time * 3)
943 ad->write_batch_count *= 2;
944 else
945 ad->write_batch_count++;
946 }
947
948 if (ad->write_batch_count < 1)
949 ad->write_batch_count = 1;
950}
951
952/*
953 * as_completed_request is to be called when a request has completed and
954 * returned something to the requesting process, be it an error or data.
955 */
956static void as_completed_request(request_queue_t *q, struct request *rq)
957{
958 struct as_data *ad = q->elevator->elevator_data;
959 struct as_rq *arq = RQ_DATA(rq);
960
961 WARN_ON(!list_empty(&rq->queuelist));
962
963 if (arq->state != AS_RQ_REMOVED) {
964 printk("arq->state %d\n", arq->state);
965 WARN_ON(1);
966 goto out;
967 }
968
969 if (ad->changed_batch && ad->nr_dispatched == 1) {
970 kblockd_schedule_work(&ad->antic_work);
971 ad->changed_batch = 0;
972
973 if (ad->batch_data_dir == REQ_SYNC)
974 ad->new_batch = 1;
975 }
976 WARN_ON(ad->nr_dispatched == 0);
977 ad->nr_dispatched--;
978
979 /*
980 * Start counting the batch from when a request of that direction is
981 * actually serviced. This should help devices with big TCQ windows
982 * and writeback caches
983 */
984 if (ad->new_batch && ad->batch_data_dir == arq->is_sync) {
985 update_write_batch(ad);
986 ad->current_batch_expires = jiffies +
987 ad->batch_expire[REQ_SYNC];
988 ad->new_batch = 0;
989 }
990
991 if (ad->io_context == arq->io_context && ad->io_context) {
992 ad->antic_start = jiffies;
993 ad->ioc_finished = 1;
994 if (ad->antic_status == ANTIC_WAIT_REQ) {
995 /*
996 * We were waiting on this request, now anticipate
997 * the next one
998 */
999 as_antic_waitnext(ad);
1000 }
1001 }
1002
1003 as_put_io_context(arq);
1004out:
1005 arq->state = AS_RQ_POSTSCHED;
1006}
1007
1008/*
1009 * as_remove_queued_request removes a request from the pre dispatch queue
1010 * without updating refcounts. It is expected the caller will drop the
1011 * reference unless it replaces the request at somepart of the elevator
1012 * (ie. the dispatch queue)
1013 */
1014static void as_remove_queued_request(request_queue_t *q, struct request *rq)
1015{
1016 struct as_rq *arq = RQ_DATA(rq);
1017 const int data_dir = arq->is_sync;
1018 struct as_data *ad = q->elevator->elevator_data;
1019
1020 WARN_ON(arq->state != AS_RQ_QUEUED);
1021
1022 if (arq->io_context && arq->io_context->aic) {
1023 BUG_ON(!atomic_read(&arq->io_context->aic->nr_queued));
1024 atomic_dec(&arq->io_context->aic->nr_queued);
1025 }
1026
1027 /*
1028 * Update the "next_arq" cache if we are about to remove its
1029 * entry
1030 */
1031 if (ad->next_arq[data_dir] == arq)
1032 ad->next_arq[data_dir] = as_find_next_arq(ad, arq);
1033
1034 list_del_init(&arq->fifo);
1035 as_del_arq_hash(arq);
1036 as_del_arq_rb(ad, arq);
1037}
1038
1039/*
1040 * as_fifo_expired returns 0 if there are no expired reads on the fifo,
1041 * 1 otherwise. It is ratelimited so that we only perform the check once per
1042 * `fifo_expire' interval. Otherwise a large number of expired requests
1043 * would create a hopeless seekstorm.
1044 *
1045 * See as_antic_expired comment.
1046 */
1047static int as_fifo_expired(struct as_data *ad, int adir)
1048{
1049 struct as_rq *arq;
1050 long delta_jif;
1051
1052 delta_jif = jiffies - ad->last_check_fifo[adir];
1053 if (unlikely(delta_jif < 0))
1054 delta_jif = -delta_jif;
1055 if (delta_jif < ad->fifo_expire[adir])
1056 return 0;
1057
1058 ad->last_check_fifo[adir] = jiffies;
1059
1060 if (list_empty(&ad->fifo_list[adir]))
1061 return 0;
1062
1063 arq = list_entry_fifo(ad->fifo_list[adir].next);
1064
1065 return time_after(jiffies, arq->expires);
1066}
1067
1068/*
1069 * as_batch_expired returns true if the current batch has expired. A batch
1070 * is a set of reads or a set of writes.
1071 */
1072static inline int as_batch_expired(struct as_data *ad)
1073{
1074 if (ad->changed_batch || ad->new_batch)
1075 return 0;
1076
1077 if (ad->batch_data_dir == REQ_SYNC)
1078 /* TODO! add a check so a complete fifo gets written? */
1079 return time_after(jiffies, ad->current_batch_expires);
1080
1081 return time_after(jiffies, ad->current_batch_expires)
1082 || ad->current_write_count == 0;
1083}
1084
1085/*
1086 * move an entry to dispatch queue
1087 */
1088static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
1089{
1090 struct request *rq = arq->request;
1091 const int data_dir = arq->is_sync;
1092
1093 BUG_ON(!ON_RB(&arq->rb_node));
1094
1095 as_antic_stop(ad);
1096 ad->antic_status = ANTIC_OFF;
1097
1098 /*
1099 * This has to be set in order to be correctly updated by
1100 * as_find_next_arq
1101 */
1102 ad->last_sector[data_dir] = rq->sector + rq->nr_sectors;
1103
1104 if (data_dir == REQ_SYNC) {
1105 /* In case we have to anticipate after this */
1106 copy_io_context(&ad->io_context, &arq->io_context);
1107 } else {
1108 if (ad->io_context) {
1109 put_io_context(ad->io_context);
1110 ad->io_context = NULL;
1111 }
1112
1113 if (ad->current_write_count != 0)
1114 ad->current_write_count--;
1115 }
1116 ad->ioc_finished = 0;
1117
1118 ad->next_arq[data_dir] = as_find_next_arq(ad, arq);
1119
1120 /*
1121 * take it off the sort and fifo list, add to dispatch queue
1122 */
1123 while (!list_empty(&rq->queuelist)) {
1124 struct request *__rq = list_entry_rq(rq->queuelist.next);
1125 struct as_rq *__arq = RQ_DATA(__rq);
1126
1127 list_del(&__rq->queuelist);
1128
1129 elv_dispatch_add_tail(ad->q, __rq);
1130
1131 if (__arq->io_context && __arq->io_context->aic)
1132 atomic_inc(&__arq->io_context->aic->nr_dispatched);
1133
1134 WARN_ON(__arq->state != AS_RQ_QUEUED);
1135 __arq->state = AS_RQ_DISPATCHED;
1136
1137 ad->nr_dispatched++;
1138 }
1139
1140 as_remove_queued_request(ad->q, rq);
1141 WARN_ON(arq->state != AS_RQ_QUEUED);
1142
1143 elv_dispatch_sort(ad->q, rq);
1144
1145 arq->state = AS_RQ_DISPATCHED;
1146 if (arq->io_context && arq->io_context->aic)
1147 atomic_inc(&arq->io_context->aic->nr_dispatched);
1148 ad->nr_dispatched++;
1149}
1150
1151/*
1152 * as_dispatch_request selects the best request according to
1153 * read/write expire, batch expire, etc, and moves it to the dispatch
1154 * queue. Returns 1 if a request was found, 0 otherwise.
1155 */
1156static int as_dispatch_request(request_queue_t *q, int force)
1157{
1158 struct as_data *ad = q->elevator->elevator_data;
1159 struct as_rq *arq;
1160 const int reads = !list_empty(&ad->fifo_list[REQ_SYNC]);
1161 const int writes = !list_empty(&ad->fifo_list[REQ_ASYNC]);
1162
1163 if (unlikely(force)) {
1164 /*
1165 * Forced dispatch, accounting is useless. Reset
1166 * accounting states and dump fifo_lists. Note that
1167 * batch_data_dir is reset to REQ_SYNC to avoid
1168 * screwing write batch accounting as write batch
1169 * accounting occurs on W->R transition.
1170 */
1171 int dispatched = 0;
1172
1173 ad->batch_data_dir = REQ_SYNC;
1174 ad->changed_batch = 0;
1175 ad->new_batch = 0;
1176
1177 while (ad->next_arq[REQ_SYNC]) {
1178 as_move_to_dispatch(ad, ad->next_arq[REQ_SYNC]);
1179 dispatched++;
1180 }
1181 ad->last_check_fifo[REQ_SYNC] = jiffies;
1182
1183 while (ad->next_arq[REQ_ASYNC]) {
1184 as_move_to_dispatch(ad, ad->next_arq[REQ_ASYNC]);
1185 dispatched++;
1186 }
1187 ad->last_check_fifo[REQ_ASYNC] = jiffies;
1188
1189 return dispatched;
1190 }
1191
1192 /* Signal that the write batch was uncontended, so we can't time it */
1193 if (ad->batch_data_dir == REQ_ASYNC && !reads) {
1194 if (ad->current_write_count == 0 || !writes)
1195 ad->write_batch_idled = 1;
1196 }
1197
1198 if (!(reads || writes)
1199 || ad->antic_status == ANTIC_WAIT_REQ
1200 || ad->antic_status == ANTIC_WAIT_NEXT
1201 || ad->changed_batch)
1202 return 0;
1203
1204 if (!(reads && writes && as_batch_expired(ad)) ) {
1205 /*
1206 * batch is still running or no reads or no writes
1207 */
1208 arq = ad->next_arq[ad->batch_data_dir];
1209
1210 if (ad->batch_data_dir == REQ_SYNC && ad->antic_expire) {
1211 if (as_fifo_expired(ad, REQ_SYNC))
1212 goto fifo_expired;
1213
1214 if (as_can_anticipate(ad, arq)) {
1215 as_antic_waitreq(ad);
1216 return 0;
1217 }
1218 }
1219
1220 if (arq) {
1221 /* we have a "next request" */
1222 if (reads && !writes)
1223 ad->current_batch_expires =
1224 jiffies + ad->batch_expire[REQ_SYNC];
1225 goto dispatch_request;
1226 }
1227 }
1228
1229 /*
1230 * at this point we are not running a batch. select the appropriate
1231 * data direction (read / write)
1232 */
1233
1234 if (reads) {
1235 BUG_ON(RB_EMPTY(&ad->sort_list[REQ_SYNC]));
1236
1237 if (writes && ad->batch_data_dir == REQ_SYNC)
1238 /*
1239 * Last batch was a read, switch to writes
1240 */
1241 goto dispatch_writes;
1242
1243 if (ad->batch_data_dir == REQ_ASYNC) {
1244 WARN_ON(ad->new_batch);
1245 ad->changed_batch = 1;
1246 }
1247 ad->batch_data_dir = REQ_SYNC;
1248 arq = list_entry_fifo(ad->fifo_list[ad->batch_data_dir].next);
1249 ad->last_check_fifo[ad->batch_data_dir] = jiffies;
1250 goto dispatch_request;
1251 }
1252
1253 /*
1254 * the last batch was a read
1255 */
1256
1257 if (writes) {
1258dispatch_writes:
1259 BUG_ON(RB_EMPTY(&ad->sort_list[REQ_ASYNC]));
1260
1261 if (ad->batch_data_dir == REQ_SYNC) {
1262 ad->changed_batch = 1;
1263
1264 /*
1265 * new_batch might be 1 when the queue runs out of
1266 * reads. A subsequent submission of a write might
1267 * cause a change of batch before the read is finished.
1268 */
1269 ad->new_batch = 0;
1270 }
1271 ad->batch_data_dir = REQ_ASYNC;
1272 ad->current_write_count = ad->write_batch_count;
1273 ad->write_batch_idled = 0;
1274 arq = ad->next_arq[ad->batch_data_dir];
1275 goto dispatch_request;
1276 }
1277
1278 BUG();
1279 return 0;
1280
1281dispatch_request:
1282 /*
1283 * If a request has expired, service it.
1284 */
1285
1286 if (as_fifo_expired(ad, ad->batch_data_dir)) {
1287fifo_expired:
1288 arq = list_entry_fifo(ad->fifo_list[ad->batch_data_dir].next);
1289 BUG_ON(arq == NULL);
1290 }
1291
1292 if (ad->changed_batch) {
1293 WARN_ON(ad->new_batch);
1294
1295 if (ad->nr_dispatched)
1296 return 0;
1297
1298 if (ad->batch_data_dir == REQ_ASYNC)
1299 ad->current_batch_expires = jiffies +
1300 ad->batch_expire[REQ_ASYNC];
1301 else
1302 ad->new_batch = 1;
1303
1304 ad->changed_batch = 0;
1305 }
1306
1307 /*
1308 * arq is the selected appropriate request.
1309 */
1310 as_move_to_dispatch(ad, arq);
1311
1312 return 1;
1313}
1314
1315/*
1316 * Add arq to a list behind alias
1317 */
1318static inline void
1319as_add_aliased_request(struct as_data *ad, struct as_rq *arq, struct as_rq *alias)
1320{
1321 struct request *req = arq->request;
1322 struct list_head *insert = alias->request->queuelist.prev;
1323
1324 /*
1325 * Transfer list of aliases
1326 */
1327 while (!list_empty(&req->queuelist)) {
1328 struct request *__rq = list_entry_rq(req->queuelist.next);
1329 struct as_rq *__arq = RQ_DATA(__rq);
1330
1331 list_move_tail(&__rq->queuelist, &alias->request->queuelist);
1332
1333 WARN_ON(__arq->state != AS_RQ_QUEUED);
1334 }
1335
1336 /*
1337 * Another request with the same start sector on the rbtree.
1338 * Link this request to that sector. They are untangled in
1339 * as_move_to_dispatch
1340 */
1341 list_add(&arq->request->queuelist, insert);
1342
1343 /*
1344 * Don't want to have to handle merges.
1345 */
1346 as_del_arq_hash(arq);
1347 arq->request->flags |= REQ_NOMERGE;
1348}
1349
1350/*
1351 * add arq to rbtree and fifo
1352 */
1353static void as_add_request(request_queue_t *q, struct request *rq)
1354{
1355 struct as_data *ad = q->elevator->elevator_data;
1356 struct as_rq *arq = RQ_DATA(rq);
1357 struct as_rq *alias;
1358 int data_dir;
1359
1360 if (arq->state != AS_RQ_PRESCHED) {
1361 printk("arq->state: %d\n", arq->state);
1362 WARN_ON(1);
1363 }
1364 arq->state = AS_RQ_NEW;
1365
1366 if (rq_data_dir(arq->request) == READ
1367 || current->flags&PF_SYNCWRITE)
1368 arq->is_sync = 1;
1369 else
1370 arq->is_sync = 0;
1371 data_dir = arq->is_sync;
1372
1373 arq->io_context = as_get_io_context();
1374
1375 if (arq->io_context) {
1376 as_update_iohist(ad, arq->io_context->aic, arq->request);
1377 atomic_inc(&arq->io_context->aic->nr_queued);
1378 }
1379
1380 alias = as_add_arq_rb(ad, arq);
1381 if (!alias) {
1382 /*
1383 * set expire time (only used for reads) and add to fifo list
1384 */
1385 arq->expires = jiffies + ad->fifo_expire[data_dir];
1386 list_add_tail(&arq->fifo, &ad->fifo_list[data_dir]);
1387
1388 if (rq_mergeable(arq->request))
1389 as_add_arq_hash(ad, arq);
1390 as_update_arq(ad, arq); /* keep state machine up to date */
1391
1392 } else {
1393 as_add_aliased_request(ad, arq, alias);
1394
1395 /*
1396 * have we been anticipating this request?
1397 * or does it come from the same process as the one we are
1398 * anticipating for?
1399 */
1400 if (ad->antic_status == ANTIC_WAIT_REQ
1401 || ad->antic_status == ANTIC_WAIT_NEXT) {
1402 if (as_can_break_anticipation(ad, arq))
1403 as_antic_stop(ad);
1404 }
1405 }
1406
1407 arq->state = AS_RQ_QUEUED;
1408}
1409
1410static void as_activate_request(request_queue_t *q, struct request *rq)
1411{
1412 struct as_rq *arq = RQ_DATA(rq);
1413
1414 WARN_ON(arq->state != AS_RQ_DISPATCHED);
1415 arq->state = AS_RQ_REMOVED;
1416 if (arq->io_context && arq->io_context->aic)
1417 atomic_dec(&arq->io_context->aic->nr_dispatched);
1418}
1419
1420static void as_deactivate_request(request_queue_t *q, struct request *rq)
1421{
1422 struct as_rq *arq = RQ_DATA(rq);
1423
1424 WARN_ON(arq->state != AS_RQ_REMOVED);
1425 arq->state = AS_RQ_DISPATCHED;
1426 if (arq->io_context && arq->io_context->aic)
1427 atomic_inc(&arq->io_context->aic->nr_dispatched);
1428}
1429
1430/*
1431 * as_queue_empty tells us if there are requests left in the device. It may
1432 * not be the case that a driver can get the next request even if the queue
1433 * is not empty - it is used in the block layer to check for plugging and
1434 * merging opportunities
1435 */
1436static int as_queue_empty(request_queue_t *q)
1437{
1438 struct as_data *ad = q->elevator->elevator_data;
1439
1440 return list_empty(&ad->fifo_list[REQ_ASYNC])
1441 && list_empty(&ad->fifo_list[REQ_SYNC]);
1442}
1443
1444static struct request *
1445as_former_request(request_queue_t *q, struct request *rq)
1446{
1447 struct as_rq *arq = RQ_DATA(rq);
1448 struct rb_node *rbprev = rb_prev(&arq->rb_node);
1449 struct request *ret = NULL;
1450
1451 if (rbprev)
1452 ret = rb_entry_arq(rbprev)->request;
1453
1454 return ret;
1455}
1456
1457static struct request *
1458as_latter_request(request_queue_t *q, struct request *rq)
1459{
1460 struct as_rq *arq = RQ_DATA(rq);
1461 struct rb_node *rbnext = rb_next(&arq->rb_node);
1462 struct request *ret = NULL;
1463
1464 if (rbnext)
1465 ret = rb_entry_arq(rbnext)->request;
1466
1467 return ret;
1468}
1469
1470static int
1471as_merge(request_queue_t *q, struct request **req, struct bio *bio)
1472{
1473 struct as_data *ad = q->elevator->elevator_data;
1474 sector_t rb_key = bio->bi_sector + bio_sectors(bio);
1475 struct request *__rq;
1476 int ret;
1477
1478 /*
1479 * see if the merge hash can satisfy a back merge
1480 */
1481 __rq = as_find_arq_hash(ad, bio->bi_sector);
1482 if (__rq) {
1483 BUG_ON(__rq->sector + __rq->nr_sectors != bio->bi_sector);
1484
1485 if (elv_rq_merge_ok(__rq, bio)) {
1486 ret = ELEVATOR_BACK_MERGE;
1487 goto out;
1488 }
1489 }
1490
1491 /*
1492 * check for front merge
1493 */
1494 __rq = as_find_arq_rb(ad, rb_key, bio_data_dir(bio));
1495 if (__rq) {
1496 BUG_ON(rb_key != rq_rb_key(__rq));
1497
1498 if (elv_rq_merge_ok(__rq, bio)) {
1499 ret = ELEVATOR_FRONT_MERGE;
1500 goto out;
1501 }
1502 }
1503
1504 return ELEVATOR_NO_MERGE;
1505out:
1506 if (ret) {
1507 if (rq_mergeable(__rq))
1508 as_hot_arq_hash(ad, RQ_DATA(__rq));
1509 }
1510 *req = __rq;
1511 return ret;
1512}
1513
1514static void as_merged_request(request_queue_t *q, struct request *req)
1515{
1516 struct as_data *ad = q->elevator->elevator_data;
1517 struct as_rq *arq = RQ_DATA(req);
1518
1519 /*
1520 * hash always needs to be repositioned, key is end sector
1521 */
1522 as_del_arq_hash(arq);
1523 as_add_arq_hash(ad, arq);
1524
1525 /*
1526 * if the merge was a front merge, we need to reposition request
1527 */
1528 if (rq_rb_key(req) != arq->rb_key) {
1529 struct as_rq *alias, *next_arq = NULL;
1530
1531 if (ad->next_arq[arq->is_sync] == arq)
1532 next_arq = as_find_next_arq(ad, arq);
1533
1534 /*
1535 * Note! We should really be moving any old aliased requests
1536 * off this request and try to insert them into the rbtree. We
1537 * currently don't bother. Ditto the next function.
1538 */
1539 as_del_arq_rb(ad, arq);
1540 if ((alias = as_add_arq_rb(ad, arq)) ) {
1541 list_del_init(&arq->fifo);
1542 as_add_aliased_request(ad, arq, alias);
1543 if (next_arq)
1544 ad->next_arq[arq->is_sync] = next_arq;
1545 }
1546 /*
1547 * Note! At this stage of this and the next function, our next
1548 * request may not be optimal - eg the request may have "grown"
1549 * behind the disk head. We currently don't bother adjusting.
1550 */
1551 }
1552}
1553
1554static void
1555as_merged_requests(request_queue_t *q, struct request *req,
1556 struct request *next)
1557{
1558 struct as_data *ad = q->elevator->elevator_data;
1559 struct as_rq *arq = RQ_DATA(req);
1560 struct as_rq *anext = RQ_DATA(next);
1561
1562 BUG_ON(!arq);
1563 BUG_ON(!anext);
1564
1565 /*
1566 * reposition arq (this is the merged request) in hash, and in rbtree
1567 * in case of a front merge
1568 */
1569 as_del_arq_hash(arq);
1570 as_add_arq_hash(ad, arq);
1571
1572 if (rq_rb_key(req) != arq->rb_key) {
1573 struct as_rq *alias, *next_arq = NULL;
1574
1575 if (ad->next_arq[arq->is_sync] == arq)
1576 next_arq = as_find_next_arq(ad, arq);
1577
1578 as_del_arq_rb(ad, arq);
1579 if ((alias = as_add_arq_rb(ad, arq)) ) {
1580 list_del_init(&arq->fifo);
1581 as_add_aliased_request(ad, arq, alias);
1582 if (next_arq)
1583 ad->next_arq[arq->is_sync] = next_arq;
1584 }
1585 }
1586
1587 /*
1588 * if anext expires before arq, assign its expire time to arq
1589 * and move into anext position (anext will be deleted) in fifo
1590 */
1591 if (!list_empty(&arq->fifo) && !list_empty(&anext->fifo)) {
1592 if (time_before(anext->expires, arq->expires)) {
1593 list_move(&arq->fifo, &anext->fifo);
1594 arq->expires = anext->expires;
1595 /*
1596 * Don't copy here but swap, because when anext is
1597 * removed below, it must contain the unused context
1598 */
1599 swap_io_context(&arq->io_context, &anext->io_context);
1600 }
1601 }
1602
1603 /*
1604 * Transfer list of aliases
1605 */
1606 while (!list_empty(&next->queuelist)) {
1607 struct request *__rq = list_entry_rq(next->queuelist.next);
1608 struct as_rq *__arq = RQ_DATA(__rq);
1609
1610 list_move_tail(&__rq->queuelist, &req->queuelist);
1611
1612 WARN_ON(__arq->state != AS_RQ_QUEUED);
1613 }
1614
1615 /*
1616 * kill knowledge of next, this one is a goner
1617 */
1618 as_remove_queued_request(q, next);
1619 as_put_io_context(anext);
1620
1621 anext->state = AS_RQ_MERGED;
1622}
1623
1624/*
1625 * This is executed in a "deferred" process context, by kblockd. It calls the
1626 * driver's request_fn so the driver can submit that request.
1627 *
1628 * IMPORTANT! This guy will reenter the elevator, so set up all queue global
1629 * state before calling, and don't rely on any state over calls.
1630 *
1631 * FIXME! dispatch queue is not a queue at all!
1632 */
1633static void as_work_handler(void *data)
1634{
1635 struct request_queue *q = data;
1636 unsigned long flags;
1637
1638 spin_lock_irqsave(q->queue_lock, flags);
1639 if (!as_queue_empty(q))
1640 q->request_fn(q);
1641 spin_unlock_irqrestore(q->queue_lock, flags);
1642}
1643
1644static void as_put_request(request_queue_t *q, struct request *rq)
1645{
1646 struct as_data *ad = q->elevator->elevator_data;
1647 struct as_rq *arq = RQ_DATA(rq);
1648
1649 if (!arq) {
1650 WARN_ON(1);
1651 return;
1652 }
1653
1654 if (unlikely(arq->state != AS_RQ_POSTSCHED &&
1655 arq->state != AS_RQ_PRESCHED &&
1656 arq->state != AS_RQ_MERGED)) {
1657 printk("arq->state %d\n", arq->state);
1658 WARN_ON(1);
1659 }
1660
1661 mempool_free(arq, ad->arq_pool);
1662 rq->elevator_private = NULL;
1663}
1664
1665static int as_set_request(request_queue_t *q, struct request *rq,
1666 struct bio *bio, gfp_t gfp_mask)
1667{
1668 struct as_data *ad = q->elevator->elevator_data;
1669 struct as_rq *arq = mempool_alloc(ad->arq_pool, gfp_mask);
1670
1671 if (arq) {
1672 memset(arq, 0, sizeof(*arq));
1673 RB_CLEAR(&arq->rb_node);
1674 arq->request = rq;
1675 arq->state = AS_RQ_PRESCHED;
1676 arq->io_context = NULL;
1677 INIT_LIST_HEAD(&arq->hash);
1678 arq->on_hash = 0;
1679 INIT_LIST_HEAD(&arq->fifo);
1680 rq->elevator_private = arq;
1681 return 0;
1682 }
1683
1684 return 1;
1685}
1686
1687static int as_may_queue(request_queue_t *q, int rw, struct bio *bio)
1688{
1689 int ret = ELV_MQUEUE_MAY;
1690 struct as_data *ad = q->elevator->elevator_data;
1691 struct io_context *ioc;
1692 if (ad->antic_status == ANTIC_WAIT_REQ ||
1693 ad->antic_status == ANTIC_WAIT_NEXT) {
1694 ioc = as_get_io_context();
1695 if (ad->io_context == ioc)
1696 ret = ELV_MQUEUE_MUST;
1697 put_io_context(ioc);
1698 }
1699
1700 return ret;
1701}
1702
1703static void as_exit_queue(elevator_t *e)
1704{
1705 struct as_data *ad = e->elevator_data;
1706
1707 del_timer_sync(&ad->antic_timer);
1708 kblockd_flush();
1709
1710 BUG_ON(!list_empty(&ad->fifo_list[REQ_SYNC]));
1711 BUG_ON(!list_empty(&ad->fifo_list[REQ_ASYNC]));
1712
1713 mempool_destroy(ad->arq_pool);
1714 put_io_context(ad->io_context);
1715 kfree(ad->hash);
1716 kfree(ad);
1717}
1718
1719/*
1720 * initialize elevator private data (as_data), and alloc a arq for
1721 * each request on the free lists
1722 */
1723static int as_init_queue(request_queue_t *q, elevator_t *e)
1724{
1725 struct as_data *ad;
1726 int i;
1727
1728 if (!arq_pool)
1729 return -ENOMEM;
1730
1731 ad = kmalloc_node(sizeof(*ad), GFP_KERNEL, q->node);
1732 if (!ad)
1733 return -ENOMEM;
1734 memset(ad, 0, sizeof(*ad));
1735
1736 ad->q = q; /* Identify what queue the data belongs to */
1737
1738 ad->hash = kmalloc_node(sizeof(struct list_head)*AS_HASH_ENTRIES,
1739 GFP_KERNEL, q->node);
1740 if (!ad->hash) {
1741 kfree(ad);
1742 return -ENOMEM;
1743 }
1744
1745 ad->arq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
1746 mempool_free_slab, arq_pool, q->node);
1747 if (!ad->arq_pool) {
1748 kfree(ad->hash);
1749 kfree(ad);
1750 return -ENOMEM;
1751 }
1752
1753 /* anticipatory scheduling helpers */
1754 ad->antic_timer.function = as_antic_timeout;
1755 ad->antic_timer.data = (unsigned long)q;
1756 init_timer(&ad->antic_timer);
1757 INIT_WORK(&ad->antic_work, as_work_handler, q);
1758
1759 for (i = 0; i < AS_HASH_ENTRIES; i++)
1760 INIT_LIST_HEAD(&ad->hash[i]);
1761
1762 INIT_LIST_HEAD(&ad->fifo_list[REQ_SYNC]);
1763 INIT_LIST_HEAD(&ad->fifo_list[REQ_ASYNC]);
1764 ad->sort_list[REQ_SYNC] = RB_ROOT;
1765 ad->sort_list[REQ_ASYNC] = RB_ROOT;
1766 ad->fifo_expire[REQ_SYNC] = default_read_expire;
1767 ad->fifo_expire[REQ_ASYNC] = default_write_expire;
1768 ad->antic_expire = default_antic_expire;
1769 ad->batch_expire[REQ_SYNC] = default_read_batch_expire;
1770 ad->batch_expire[REQ_ASYNC] = default_write_batch_expire;
1771 e->elevator_data = ad;
1772
1773 ad->current_batch_expires = jiffies + ad->batch_expire[REQ_SYNC];
1774 ad->write_batch_count = ad->batch_expire[REQ_ASYNC] / 10;
1775 if (ad->write_batch_count < 2)
1776 ad->write_batch_count = 2;
1777
1778 return 0;
1779}
1780
1781/*
1782 * sysfs parts below
1783 */
1784struct as_fs_entry {
1785 struct attribute attr;
1786 ssize_t (*show)(struct as_data *, char *);
1787 ssize_t (*store)(struct as_data *, const char *, size_t);
1788};
1789
1790static ssize_t
1791as_var_show(unsigned int var, char *page)
1792{
1793 return sprintf(page, "%d\n", var);
1794}
1795
1796static ssize_t
1797as_var_store(unsigned long *var, const char *page, size_t count)
1798{
1799 char *p = (char *) page;
1800
1801 *var = simple_strtoul(p, &p, 10);
1802 return count;
1803}
1804
1805static ssize_t as_est_show(struct as_data *ad, char *page)
1806{
1807 int pos = 0;
1808
1809 pos += sprintf(page+pos, "%lu %% exit probability\n", 100*ad->exit_prob/256);
1810 pos += sprintf(page+pos, "%lu ms new thinktime\n", ad->new_ttime_mean);
1811 pos += sprintf(page+pos, "%llu sectors new seek distance\n", (unsigned long long)ad->new_seek_mean);
1812
1813 return pos;
1814}
1815
1816#define SHOW_FUNCTION(__FUNC, __VAR) \
1817static ssize_t __FUNC(struct as_data *ad, char *page) \
1818{ \
1819 return as_var_show(jiffies_to_msecs((__VAR)), (page)); \
1820}
1821SHOW_FUNCTION(as_readexpire_show, ad->fifo_expire[REQ_SYNC]);
1822SHOW_FUNCTION(as_writeexpire_show, ad->fifo_expire[REQ_ASYNC]);
1823SHOW_FUNCTION(as_anticexpire_show, ad->antic_expire);
1824SHOW_FUNCTION(as_read_batchexpire_show, ad->batch_expire[REQ_SYNC]);
1825SHOW_FUNCTION(as_write_batchexpire_show, ad->batch_expire[REQ_ASYNC]);
1826#undef SHOW_FUNCTION
1827
1828#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \
1829static ssize_t __FUNC(struct as_data *ad, const char *page, size_t count) \
1830{ \
1831 int ret = as_var_store(__PTR, (page), count); \
1832 if (*(__PTR) < (MIN)) \
1833 *(__PTR) = (MIN); \
1834 else if (*(__PTR) > (MAX)) \
1835 *(__PTR) = (MAX); \
1836 *(__PTR) = msecs_to_jiffies(*(__PTR)); \
1837 return ret; \
1838}
1839STORE_FUNCTION(as_readexpire_store, &ad->fifo_expire[REQ_SYNC], 0, INT_MAX);
1840STORE_FUNCTION(as_writeexpire_store, &ad->fifo_expire[REQ_ASYNC], 0, INT_MAX);
1841STORE_FUNCTION(as_anticexpire_store, &ad->antic_expire, 0, INT_MAX);
1842STORE_FUNCTION(as_read_batchexpire_store,
1843 &ad->batch_expire[REQ_SYNC], 0, INT_MAX);
1844STORE_FUNCTION(as_write_batchexpire_store,
1845 &ad->batch_expire[REQ_ASYNC], 0, INT_MAX);
1846#undef STORE_FUNCTION
1847
1848static struct as_fs_entry as_est_entry = {
1849 .attr = {.name = "est_time", .mode = S_IRUGO },
1850 .show = as_est_show,
1851};
1852static struct as_fs_entry as_readexpire_entry = {
1853 .attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR },
1854 .show = as_readexpire_show,
1855 .store = as_readexpire_store,
1856};
1857static struct as_fs_entry as_writeexpire_entry = {
1858 .attr = {.name = "write_expire", .mode = S_IRUGO | S_IWUSR },
1859 .show = as_writeexpire_show,
1860 .store = as_writeexpire_store,
1861};
1862static struct as_fs_entry as_anticexpire_entry = {
1863 .attr = {.name = "antic_expire", .mode = S_IRUGO | S_IWUSR },
1864 .show = as_anticexpire_show,
1865 .store = as_anticexpire_store,
1866};
1867static struct as_fs_entry as_read_batchexpire_entry = {
1868 .attr = {.name = "read_batch_expire", .mode = S_IRUGO | S_IWUSR },
1869 .show = as_read_batchexpire_show,
1870 .store = as_read_batchexpire_store,
1871};
1872static struct as_fs_entry as_write_batchexpire_entry = {
1873 .attr = {.name = "write_batch_expire", .mode = S_IRUGO | S_IWUSR },
1874 .show = as_write_batchexpire_show,
1875 .store = as_write_batchexpire_store,
1876};
1877
1878static struct attribute *default_attrs[] = {
1879 &as_est_entry.attr,
1880 &as_readexpire_entry.attr,
1881 &as_writeexpire_entry.attr,
1882 &as_anticexpire_entry.attr,
1883 &as_read_batchexpire_entry.attr,
1884 &as_write_batchexpire_entry.attr,
1885 NULL,
1886};
1887
1888#define to_as(atr) container_of((atr), struct as_fs_entry, attr)
1889
1890static ssize_t
1891as_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
1892{
1893 elevator_t *e = container_of(kobj, elevator_t, kobj);
1894 struct as_fs_entry *entry = to_as(attr);
1895
1896 if (!entry->show)
1897 return -EIO;
1898
1899 return entry->show(e->elevator_data, page);
1900}
1901
1902static ssize_t
1903as_attr_store(struct kobject *kobj, struct attribute *attr,
1904 const char *page, size_t length)
1905{
1906 elevator_t *e = container_of(kobj, elevator_t, kobj);
1907 struct as_fs_entry *entry = to_as(attr);
1908
1909 if (!entry->store)
1910 return -EIO;
1911
1912 return entry->store(e->elevator_data, page, length);
1913}
1914
1915static struct sysfs_ops as_sysfs_ops = {
1916 .show = as_attr_show,
1917 .store = as_attr_store,
1918};
1919
1920static struct kobj_type as_ktype = {
1921 .sysfs_ops = &as_sysfs_ops,
1922 .default_attrs = default_attrs,
1923};
1924
1925static struct elevator_type iosched_as = {
1926 .ops = {
1927 .elevator_merge_fn = as_merge,
1928 .elevator_merged_fn = as_merged_request,
1929 .elevator_merge_req_fn = as_merged_requests,
1930 .elevator_dispatch_fn = as_dispatch_request,
1931 .elevator_add_req_fn = as_add_request,
1932 .elevator_activate_req_fn = as_activate_request,
1933 .elevator_deactivate_req_fn = as_deactivate_request,
1934 .elevator_queue_empty_fn = as_queue_empty,
1935 .elevator_completed_req_fn = as_completed_request,
1936 .elevator_former_req_fn = as_former_request,
1937 .elevator_latter_req_fn = as_latter_request,
1938 .elevator_set_req_fn = as_set_request,
1939 .elevator_put_req_fn = as_put_request,
1940 .elevator_may_queue_fn = as_may_queue,
1941 .elevator_init_fn = as_init_queue,
1942 .elevator_exit_fn = as_exit_queue,
1943 },
1944
1945 .elevator_ktype = &as_ktype,
1946 .elevator_name = "anticipatory",
1947 .elevator_owner = THIS_MODULE,
1948};
1949
1950static int __init as_init(void)
1951{
1952 int ret;
1953
1954 arq_pool = kmem_cache_create("as_arq", sizeof(struct as_rq),
1955 0, 0, NULL, NULL);
1956 if (!arq_pool)
1957 return -ENOMEM;
1958
1959 ret = elv_register(&iosched_as);
1960 if (!ret) {
1961 /*
1962 * don't allow AS to get unregistered, since we would have
1963 * to browse all tasks in the system and release their
1964 * as_io_context first
1965 */
1966 __module_get(THIS_MODULE);
1967 return 0;
1968 }
1969
1970 kmem_cache_destroy(arq_pool);
1971 return ret;
1972}
1973
1974static void __exit as_exit(void)
1975{
1976 elv_unregister(&iosched_as);
1977 kmem_cache_destroy(arq_pool);
1978}
1979
1980module_init(as_init);
1981module_exit(as_exit);
1982
1983MODULE_AUTHOR("Nick Piggin");
1984MODULE_LICENSE("GPL");
1985MODULE_DESCRIPTION("anticipatory IO scheduler");
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 482786068ff9..e239a6c29230 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1097,14 +1097,11 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
1097cleanup1: 1097cleanup1:
1098 if (buff) { 1098 if (buff) {
1099 for(i=0; i<sg_used; i++) 1099 for(i=0; i<sg_used; i++)
1100 if(buff[i] != NULL) 1100 kfree(buff[i]);
1101 kfree(buff[i]);
1102 kfree(buff); 1101 kfree(buff);
1103 } 1102 }
1104 if (buff_size) 1103 kfree(buff_size);
1105 kfree(buff_size); 1104 kfree(ioc);
1106 if (ioc)
1107 kfree(ioc);
1108 return(status); 1105 return(status);
1109 } 1106 }
1110 default: 1107 default:
@@ -3167,8 +3164,7 @@ clean4:
3167 if(hba[i]->scsi_rejects.complete) 3164 if(hba[i]->scsi_rejects.complete)
3168 kfree(hba[i]->scsi_rejects.complete); 3165 kfree(hba[i]->scsi_rejects.complete);
3169#endif 3166#endif
3170 if(hba[i]->cmd_pool_bits) 3167 kfree(hba[i]->cmd_pool_bits);
3171 kfree(hba[i]->cmd_pool_bits);
3172 if(hba[i]->cmd_pool) 3168 if(hba[i]->cmd_pool)
3173 pci_free_consistent(hba[i]->pdev, 3169 pci_free_consistent(hba[i]->pdev,
3174 NR_CMDS * sizeof(CommandList_struct), 3170 NR_CMDS * sizeof(CommandList_struct),
diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c
deleted file mode 100644
index ecacca9c877e..000000000000
--- a/drivers/block/cfq-iosched.c
+++ /dev/null
@@ -1,2428 +0,0 @@
1/*
2 * linux/drivers/block/cfq-iosched.c
3 *
4 * CFQ, or complete fairness queueing, disk scheduler.
5 *
6 * Based on ideas from a previously unfinished io
7 * scheduler (round robin per-process disk scheduling) and Andrea Arcangeli.
8 *
9 * Copyright (C) 2003 Jens Axboe <axboe@suse.de>
10 */
11#include <linux/kernel.h>
12#include <linux/fs.h>
13#include <linux/blkdev.h>
14#include <linux/elevator.h>
15#include <linux/bio.h>
16#include <linux/config.h>
17#include <linux/module.h>
18#include <linux/slab.h>
19#include <linux/init.h>
20#include <linux/compiler.h>
21#include <linux/hash.h>
22#include <linux/rbtree.h>
23#include <linux/mempool.h>
24#include <linux/ioprio.h>
25#include <linux/writeback.h>
26
27/*
28 * tunables
29 */
30static int cfq_quantum = 4; /* max queue in one round of service */
31static int cfq_queued = 8; /* minimum rq allocate limit per-queue*/
32static int cfq_fifo_expire[2] = { HZ / 4, HZ / 8 };
33static int cfq_back_max = 16 * 1024; /* maximum backwards seek, in KiB */
34static int cfq_back_penalty = 2; /* penalty of a backwards seek */
35
36static int cfq_slice_sync = HZ / 10;
37static int cfq_slice_async = HZ / 25;
38static int cfq_slice_async_rq = 2;
39static int cfq_slice_idle = HZ / 100;
40
41#define CFQ_IDLE_GRACE (HZ / 10)
42#define CFQ_SLICE_SCALE (5)
43
44#define CFQ_KEY_ASYNC (0)
45#define CFQ_KEY_ANY (0xffff)
46
47/*
48 * disable queueing at the driver/hardware level
49 */
50static int cfq_max_depth = 2;
51
52/*
53 * for the hash of cfqq inside the cfqd
54 */
55#define CFQ_QHASH_SHIFT 6
56#define CFQ_QHASH_ENTRIES (1 << CFQ_QHASH_SHIFT)
57#define list_entry_qhash(entry) hlist_entry((entry), struct cfq_queue, cfq_hash)
58
59/*
60 * for the hash of crq inside the cfqq
61 */
62#define CFQ_MHASH_SHIFT 6
63#define CFQ_MHASH_BLOCK(sec) ((sec) >> 3)
64#define CFQ_MHASH_ENTRIES (1 << CFQ_MHASH_SHIFT)
65#define CFQ_MHASH_FN(sec) hash_long(CFQ_MHASH_BLOCK(sec), CFQ_MHASH_SHIFT)
66#define rq_hash_key(rq) ((rq)->sector + (rq)->nr_sectors)
67#define list_entry_hash(ptr) hlist_entry((ptr), struct cfq_rq, hash)
68
69#define list_entry_cfqq(ptr) list_entry((ptr), struct cfq_queue, cfq_list)
70#define list_entry_fifo(ptr) list_entry((ptr), struct request, queuelist)
71
72#define RQ_DATA(rq) (rq)->elevator_private
73
74/*
75 * rb-tree defines
76 */
77#define RB_NONE (2)
78#define RB_EMPTY(node) ((node)->rb_node == NULL)
79#define RB_CLEAR_COLOR(node) (node)->rb_color = RB_NONE
80#define RB_CLEAR(node) do { \
81 (node)->rb_parent = NULL; \
82 RB_CLEAR_COLOR((node)); \
83 (node)->rb_right = NULL; \
84 (node)->rb_left = NULL; \
85} while (0)
86#define RB_CLEAR_ROOT(root) ((root)->rb_node = NULL)
87#define rb_entry_crq(node) rb_entry((node), struct cfq_rq, rb_node)
88#define rq_rb_key(rq) (rq)->sector
89
90static kmem_cache_t *crq_pool;
91static kmem_cache_t *cfq_pool;
92static kmem_cache_t *cfq_ioc_pool;
93
94#define CFQ_PRIO_LISTS IOPRIO_BE_NR
95#define cfq_class_idle(cfqq) ((cfqq)->ioprio_class == IOPRIO_CLASS_IDLE)
96#define cfq_class_be(cfqq) ((cfqq)->ioprio_class == IOPRIO_CLASS_BE)
97#define cfq_class_rt(cfqq) ((cfqq)->ioprio_class == IOPRIO_CLASS_RT)
98
99#define ASYNC (0)
100#define SYNC (1)
101
102#define cfq_cfqq_dispatched(cfqq) \
103 ((cfqq)->on_dispatch[ASYNC] + (cfqq)->on_dispatch[SYNC])
104
105#define cfq_cfqq_class_sync(cfqq) ((cfqq)->key != CFQ_KEY_ASYNC)
106
107#define cfq_cfqq_sync(cfqq) \
108 (cfq_cfqq_class_sync(cfqq) || (cfqq)->on_dispatch[SYNC])
109
110/*
111 * Per block device queue structure
112 */
113struct cfq_data {
114 atomic_t ref;
115 request_queue_t *queue;
116
117 /*
118 * rr list of queues with requests and the count of them
119 */
120 struct list_head rr_list[CFQ_PRIO_LISTS];
121 struct list_head busy_rr;
122 struct list_head cur_rr;
123 struct list_head idle_rr;
124 unsigned int busy_queues;
125
126 /*
127 * non-ordered list of empty cfqq's
128 */
129 struct list_head empty_list;
130
131 /*
132 * cfqq lookup hash
133 */
134 struct hlist_head *cfq_hash;
135
136 /*
137 * global crq hash for all queues
138 */
139 struct hlist_head *crq_hash;
140
141 unsigned int max_queued;
142
143 mempool_t *crq_pool;
144
145 int rq_in_driver;
146
147 /*
148 * schedule slice state info
149 */
150 /*
151 * idle window management
152 */
153 struct timer_list idle_slice_timer;
154 struct work_struct unplug_work;
155
156 struct cfq_queue *active_queue;
157 struct cfq_io_context *active_cic;
158 int cur_prio, cur_end_prio;
159 unsigned int dispatch_slice;
160
161 struct timer_list idle_class_timer;
162
163 sector_t last_sector;
164 unsigned long last_end_request;
165
166 unsigned int rq_starved;
167
168 /*
169 * tunables, see top of file
170 */
171 unsigned int cfq_quantum;
172 unsigned int cfq_queued;
173 unsigned int cfq_fifo_expire[2];
174 unsigned int cfq_back_penalty;
175 unsigned int cfq_back_max;
176 unsigned int cfq_slice[2];
177 unsigned int cfq_slice_async_rq;
178 unsigned int cfq_slice_idle;
179 unsigned int cfq_max_depth;
180};
181
182/*
183 * Per process-grouping structure
184 */
185struct cfq_queue {
186 /* reference count */
187 atomic_t ref;
188 /* parent cfq_data */
189 struct cfq_data *cfqd;
190 /* cfqq lookup hash */
191 struct hlist_node cfq_hash;
192 /* hash key */
193 unsigned int key;
194 /* on either rr or empty list of cfqd */
195 struct list_head cfq_list;
196 /* sorted list of pending requests */
197 struct rb_root sort_list;
198 /* if fifo isn't expired, next request to serve */
199 struct cfq_rq *next_crq;
200 /* requests queued in sort_list */
201 int queued[2];
202 /* currently allocated requests */
203 int allocated[2];
204 /* fifo list of requests in sort_list */
205 struct list_head fifo;
206
207 unsigned long slice_start;
208 unsigned long slice_end;
209 unsigned long slice_left;
210 unsigned long service_last;
211
212 /* number of requests that are on the dispatch list */
213 int on_dispatch[2];
214
215 /* io prio of this group */
216 unsigned short ioprio, org_ioprio;
217 unsigned short ioprio_class, org_ioprio_class;
218
219 /* various state flags, see below */
220 unsigned int flags;
221};
222
223struct cfq_rq {
224 struct rb_node rb_node;
225 sector_t rb_key;
226 struct request *request;
227 struct hlist_node hash;
228
229 struct cfq_queue *cfq_queue;
230 struct cfq_io_context *io_context;
231
232 unsigned int crq_flags;
233};
234
235enum cfqq_state_flags {
236 CFQ_CFQQ_FLAG_on_rr = 0,
237 CFQ_CFQQ_FLAG_wait_request,
238 CFQ_CFQQ_FLAG_must_alloc,
239 CFQ_CFQQ_FLAG_must_alloc_slice,
240 CFQ_CFQQ_FLAG_must_dispatch,
241 CFQ_CFQQ_FLAG_fifo_expire,
242 CFQ_CFQQ_FLAG_idle_window,
243 CFQ_CFQQ_FLAG_prio_changed,
244 CFQ_CFQQ_FLAG_expired,
245};
246
247#define CFQ_CFQQ_FNS(name) \
248static inline void cfq_mark_cfqq_##name(struct cfq_queue *cfqq) \
249{ \
250 cfqq->flags |= (1 << CFQ_CFQQ_FLAG_##name); \
251} \
252static inline void cfq_clear_cfqq_##name(struct cfq_queue *cfqq) \
253{ \
254 cfqq->flags &= ~(1 << CFQ_CFQQ_FLAG_##name); \
255} \
256static inline int cfq_cfqq_##name(const struct cfq_queue *cfqq) \
257{ \
258 return (cfqq->flags & (1 << CFQ_CFQQ_FLAG_##name)) != 0; \
259}
260
261CFQ_CFQQ_FNS(on_rr);
262CFQ_CFQQ_FNS(wait_request);
263CFQ_CFQQ_FNS(must_alloc);
264CFQ_CFQQ_FNS(must_alloc_slice);
265CFQ_CFQQ_FNS(must_dispatch);
266CFQ_CFQQ_FNS(fifo_expire);
267CFQ_CFQQ_FNS(idle_window);
268CFQ_CFQQ_FNS(prio_changed);
269CFQ_CFQQ_FNS(expired);
270#undef CFQ_CFQQ_FNS
271
272enum cfq_rq_state_flags {
273 CFQ_CRQ_FLAG_is_sync = 0,
274};
275
276#define CFQ_CRQ_FNS(name) \
277static inline void cfq_mark_crq_##name(struct cfq_rq *crq) \
278{ \
279 crq->crq_flags |= (1 << CFQ_CRQ_FLAG_##name); \
280} \
281static inline void cfq_clear_crq_##name(struct cfq_rq *crq) \
282{ \
283 crq->crq_flags &= ~(1 << CFQ_CRQ_FLAG_##name); \
284} \
285static inline int cfq_crq_##name(const struct cfq_rq *crq) \
286{ \
287 return (crq->crq_flags & (1 << CFQ_CRQ_FLAG_##name)) != 0; \
288}
289
290CFQ_CRQ_FNS(is_sync);
291#undef CFQ_CRQ_FNS
292
293static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned int, unsigned short);
294static void cfq_dispatch_insert(request_queue_t *, struct cfq_rq *);
295static void cfq_put_cfqd(struct cfq_data *cfqd);
296
297#define process_sync(tsk) ((tsk)->flags & PF_SYNCWRITE)
298
299/*
300 * lots of deadline iosched dupes, can be abstracted later...
301 */
302static inline void cfq_del_crq_hash(struct cfq_rq *crq)
303{
304 hlist_del_init(&crq->hash);
305}
306
307static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq)
308{
309 const int hash_idx = CFQ_MHASH_FN(rq_hash_key(crq->request));
310
311 hlist_add_head(&crq->hash, &cfqd->crq_hash[hash_idx]);
312}
313
314static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset)
315{
316 struct hlist_head *hash_list = &cfqd->crq_hash[CFQ_MHASH_FN(offset)];
317 struct hlist_node *entry, *next;
318
319 hlist_for_each_safe(entry, next, hash_list) {
320 struct cfq_rq *crq = list_entry_hash(entry);
321 struct request *__rq = crq->request;
322
323 if (!rq_mergeable(__rq)) {
324 cfq_del_crq_hash(crq);
325 continue;
326 }
327
328 if (rq_hash_key(__rq) == offset)
329 return __rq;
330 }
331
332 return NULL;
333}
334
335/*
336 * scheduler run of queue, if there are requests pending and no one in the
337 * driver that will restart queueing
338 */
339static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)
340{
341 if (!cfqd->rq_in_driver && cfqd->busy_queues)
342 kblockd_schedule_work(&cfqd->unplug_work);
343}
344
345static int cfq_queue_empty(request_queue_t *q)
346{
347 struct cfq_data *cfqd = q->elevator->elevator_data;
348
349 return !cfqd->busy_queues;
350}
351
352/*
353 * Lifted from AS - choose which of crq1 and crq2 that is best served now.
354 * We choose the request that is closest to the head right now. Distance
355 * behind the head are penalized and only allowed to a certain extent.
356 */
357static struct cfq_rq *
358cfq_choose_req(struct cfq_data *cfqd, struct cfq_rq *crq1, struct cfq_rq *crq2)
359{
360 sector_t last, s1, s2, d1 = 0, d2 = 0;
361 int r1_wrap = 0, r2_wrap = 0; /* requests are behind the disk head */
362 unsigned long back_max;
363
364 if (crq1 == NULL || crq1 == crq2)
365 return crq2;
366 if (crq2 == NULL)
367 return crq1;
368
369 if (cfq_crq_is_sync(crq1) && !cfq_crq_is_sync(crq2))
370 return crq1;
371 else if (cfq_crq_is_sync(crq2) && !cfq_crq_is_sync(crq1))
372 return crq2;
373
374 s1 = crq1->request->sector;
375 s2 = crq2->request->sector;
376
377 last = cfqd->last_sector;
378
379 /*
380 * by definition, 1KiB is 2 sectors
381 */
382 back_max = cfqd->cfq_back_max * 2;
383
384 /*
385 * Strict one way elevator _except_ in the case where we allow
386 * short backward seeks which are biased as twice the cost of a
387 * similar forward seek.
388 */
389 if (s1 >= last)
390 d1 = s1 - last;
391 else if (s1 + back_max >= last)
392 d1 = (last - s1) * cfqd->cfq_back_penalty;
393 else
394 r1_wrap = 1;
395
396 if (s2 >= last)
397 d2 = s2 - last;
398 else if (s2 + back_max >= last)
399 d2 = (last - s2) * cfqd->cfq_back_penalty;
400 else
401 r2_wrap = 1;
402
403 /* Found required data */
404 if (!r1_wrap && r2_wrap)
405 return crq1;
406 else if (!r2_wrap && r1_wrap)
407 return crq2;
408 else if (r1_wrap && r2_wrap) {
409 /* both behind the head */
410 if (s1 <= s2)
411 return crq1;
412 else
413 return crq2;
414 }
415
416 /* Both requests in front of the head */
417 if (d1 < d2)
418 return crq1;
419 else if (d2 < d1)
420 return crq2;
421 else {
422 if (s1 >= s2)
423 return crq1;
424 else
425 return crq2;
426 }
427}
428
429/*
430 * would be nice to take fifo expire time into account as well
431 */
432static struct cfq_rq *
433cfq_find_next_crq(struct cfq_data *cfqd, struct cfq_queue *cfqq,
434 struct cfq_rq *last)
435{
436 struct cfq_rq *crq_next = NULL, *crq_prev = NULL;
437 struct rb_node *rbnext, *rbprev;
438
439 if (!(rbnext = rb_next(&last->rb_node))) {
440 rbnext = rb_first(&cfqq->sort_list);
441 if (rbnext == &last->rb_node)
442 rbnext = NULL;
443 }
444
445 rbprev = rb_prev(&last->rb_node);
446
447 if (rbprev)
448 crq_prev = rb_entry_crq(rbprev);
449 if (rbnext)
450 crq_next = rb_entry_crq(rbnext);
451
452 return cfq_choose_req(cfqd, crq_next, crq_prev);
453}
454
455static void cfq_update_next_crq(struct cfq_rq *crq)
456{
457 struct cfq_queue *cfqq = crq->cfq_queue;
458
459 if (cfqq->next_crq == crq)
460 cfqq->next_crq = cfq_find_next_crq(cfqq->cfqd, cfqq, crq);
461}
462
463static void cfq_resort_rr_list(struct cfq_queue *cfqq, int preempted)
464{
465 struct cfq_data *cfqd = cfqq->cfqd;
466 struct list_head *list, *entry;
467
468 BUG_ON(!cfq_cfqq_on_rr(cfqq));
469
470 list_del(&cfqq->cfq_list);
471
472 if (cfq_class_rt(cfqq))
473 list = &cfqd->cur_rr;
474 else if (cfq_class_idle(cfqq))
475 list = &cfqd->idle_rr;
476 else {
477 /*
478 * if cfqq has requests in flight, don't allow it to be
479 * found in cfq_set_active_queue before it has finished them.
480 * this is done to increase fairness between a process that
481 * has lots of io pending vs one that only generates one
482 * sporadically or synchronously
483 */
484 if (cfq_cfqq_dispatched(cfqq))
485 list = &cfqd->busy_rr;
486 else
487 list = &cfqd->rr_list[cfqq->ioprio];
488 }
489
490 /*
491 * if queue was preempted, just add to front to be fair. busy_rr
492 * isn't sorted.
493 */
494 if (preempted || list == &cfqd->busy_rr) {
495 list_add(&cfqq->cfq_list, list);
496 return;
497 }
498
499 /*
500 * sort by when queue was last serviced
501 */
502 entry = list;
503 while ((entry = entry->prev) != list) {
504 struct cfq_queue *__cfqq = list_entry_cfqq(entry);
505
506 if (!__cfqq->service_last)
507 break;
508 if (time_before(__cfqq->service_last, cfqq->service_last))
509 break;
510 }
511
512 list_add(&cfqq->cfq_list, entry);
513}
514
515/*
516 * add to busy list of queues for service, trying to be fair in ordering
517 * the pending list according to last request service
518 */
519static inline void
520cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
521{
522 BUG_ON(cfq_cfqq_on_rr(cfqq));
523 cfq_mark_cfqq_on_rr(cfqq);
524 cfqd->busy_queues++;
525
526 cfq_resort_rr_list(cfqq, 0);
527}
528
529static inline void
530cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
531{
532 BUG_ON(!cfq_cfqq_on_rr(cfqq));
533 cfq_clear_cfqq_on_rr(cfqq);
534 list_move(&cfqq->cfq_list, &cfqd->empty_list);
535
536 BUG_ON(!cfqd->busy_queues);
537 cfqd->busy_queues--;
538}
539
540/*
541 * rb tree support functions
542 */
543static inline void cfq_del_crq_rb(struct cfq_rq *crq)
544{
545 struct cfq_queue *cfqq = crq->cfq_queue;
546 struct cfq_data *cfqd = cfqq->cfqd;
547 const int sync = cfq_crq_is_sync(crq);
548
549 BUG_ON(!cfqq->queued[sync]);
550 cfqq->queued[sync]--;
551
552 cfq_update_next_crq(crq);
553
554 rb_erase(&crq->rb_node, &cfqq->sort_list);
555 RB_CLEAR_COLOR(&crq->rb_node);
556
557 if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY(&cfqq->sort_list))
558 cfq_del_cfqq_rr(cfqd, cfqq);
559}
560
561static struct cfq_rq *
562__cfq_add_crq_rb(struct cfq_rq *crq)
563{
564 struct rb_node **p = &crq->cfq_queue->sort_list.rb_node;
565 struct rb_node *parent = NULL;
566 struct cfq_rq *__crq;
567
568 while (*p) {
569 parent = *p;
570 __crq = rb_entry_crq(parent);
571
572 if (crq->rb_key < __crq->rb_key)
573 p = &(*p)->rb_left;
574 else if (crq->rb_key > __crq->rb_key)
575 p = &(*p)->rb_right;
576 else
577 return __crq;
578 }
579
580 rb_link_node(&crq->rb_node, parent, p);
581 return NULL;
582}
583
584static void cfq_add_crq_rb(struct cfq_rq *crq)
585{
586 struct cfq_queue *cfqq = crq->cfq_queue;
587 struct cfq_data *cfqd = cfqq->cfqd;
588 struct request *rq = crq->request;
589 struct cfq_rq *__alias;
590
591 crq->rb_key = rq_rb_key(rq);
592 cfqq->queued[cfq_crq_is_sync(crq)]++;
593
594 /*
595 * looks a little odd, but the first insert might return an alias.
596 * if that happens, put the alias on the dispatch list
597 */
598 while ((__alias = __cfq_add_crq_rb(crq)) != NULL)
599 cfq_dispatch_insert(cfqd->queue, __alias);
600
601 rb_insert_color(&crq->rb_node, &cfqq->sort_list);
602
603 if (!cfq_cfqq_on_rr(cfqq))
604 cfq_add_cfqq_rr(cfqd, cfqq);
605
606 /*
607 * check if this request is a better next-serve candidate
608 */
609 cfqq->next_crq = cfq_choose_req(cfqd, cfqq->next_crq, crq);
610}
611
612static inline void
613cfq_reposition_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
614{
615 rb_erase(&crq->rb_node, &cfqq->sort_list);
616 cfqq->queued[cfq_crq_is_sync(crq)]--;
617
618 cfq_add_crq_rb(crq);
619}
620
621static struct request *cfq_find_rq_rb(struct cfq_data *cfqd, sector_t sector)
622
623{
624 struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, current->pid, CFQ_KEY_ANY);
625 struct rb_node *n;
626
627 if (!cfqq)
628 goto out;
629
630 n = cfqq->sort_list.rb_node;
631 while (n) {
632 struct cfq_rq *crq = rb_entry_crq(n);
633
634 if (sector < crq->rb_key)
635 n = n->rb_left;
636 else if (sector > crq->rb_key)
637 n = n->rb_right;
638 else
639 return crq->request;
640 }
641
642out:
643 return NULL;
644}
645
646static void cfq_activate_request(request_queue_t *q, struct request *rq)
647{
648 struct cfq_data *cfqd = q->elevator->elevator_data;
649
650 cfqd->rq_in_driver++;
651}
652
653static void cfq_deactivate_request(request_queue_t *q, struct request *rq)
654{
655 struct cfq_data *cfqd = q->elevator->elevator_data;
656
657 WARN_ON(!cfqd->rq_in_driver);
658 cfqd->rq_in_driver--;
659}
660
661static void cfq_remove_request(struct request *rq)
662{
663 struct cfq_rq *crq = RQ_DATA(rq);
664
665 list_del_init(&rq->queuelist);
666 cfq_del_crq_rb(crq);
667 cfq_del_crq_hash(crq);
668}
669
670static int
671cfq_merge(request_queue_t *q, struct request **req, struct bio *bio)
672{
673 struct cfq_data *cfqd = q->elevator->elevator_data;
674 struct request *__rq;
675 int ret;
676
677 __rq = cfq_find_rq_hash(cfqd, bio->bi_sector);
678 if (__rq && elv_rq_merge_ok(__rq, bio)) {
679 ret = ELEVATOR_BACK_MERGE;
680 goto out;
681 }
682
683 __rq = cfq_find_rq_rb(cfqd, bio->bi_sector + bio_sectors(bio));
684 if (__rq && elv_rq_merge_ok(__rq, bio)) {
685 ret = ELEVATOR_FRONT_MERGE;
686 goto out;
687 }
688
689 return ELEVATOR_NO_MERGE;
690out:
691 *req = __rq;
692 return ret;
693}
694
695static void cfq_merged_request(request_queue_t *q, struct request *req)
696{
697 struct cfq_data *cfqd = q->elevator->elevator_data;
698 struct cfq_rq *crq = RQ_DATA(req);
699
700 cfq_del_crq_hash(crq);
701 cfq_add_crq_hash(cfqd, crq);
702
703 if (rq_rb_key(req) != crq->rb_key) {
704 struct cfq_queue *cfqq = crq->cfq_queue;
705
706 cfq_update_next_crq(crq);
707 cfq_reposition_crq_rb(cfqq, crq);
708 }
709}
710
711static void
712cfq_merged_requests(request_queue_t *q, struct request *rq,
713 struct request *next)
714{
715 cfq_merged_request(q, rq);
716
717 /*
718 * reposition in fifo if next is older than rq
719 */
720 if (!list_empty(&rq->queuelist) && !list_empty(&next->queuelist) &&
721 time_before(next->start_time, rq->start_time))
722 list_move(&rq->queuelist, &next->queuelist);
723
724 cfq_remove_request(next);
725}
726
727static inline void
728__cfq_set_active_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
729{
730 if (cfqq) {
731 /*
732 * stop potential idle class queues waiting service
733 */
734 del_timer(&cfqd->idle_class_timer);
735
736 cfqq->slice_start = jiffies;
737 cfqq->slice_end = 0;
738 cfqq->slice_left = 0;
739 cfq_clear_cfqq_must_alloc_slice(cfqq);
740 cfq_clear_cfqq_fifo_expire(cfqq);
741 cfq_clear_cfqq_expired(cfqq);
742 }
743
744 cfqd->active_queue = cfqq;
745}
746
747/*
748 * 0
749 * 0,1
750 * 0,1,2
751 * 0,1,2,3
752 * 0,1,2,3,4
753 * 0,1,2,3,4,5
754 * 0,1,2,3,4,5,6
755 * 0,1,2,3,4,5,6,7
756 */
757static int cfq_get_next_prio_level(struct cfq_data *cfqd)
758{
759 int prio, wrap;
760
761 prio = -1;
762 wrap = 0;
763 do {
764 int p;
765
766 for (p = cfqd->cur_prio; p <= cfqd->cur_end_prio; p++) {
767 if (!list_empty(&cfqd->rr_list[p])) {
768 prio = p;
769 break;
770 }
771 }
772
773 if (prio != -1)
774 break;
775 cfqd->cur_prio = 0;
776 if (++cfqd->cur_end_prio == CFQ_PRIO_LISTS) {
777 cfqd->cur_end_prio = 0;
778 if (wrap)
779 break;
780 wrap = 1;
781 }
782 } while (1);
783
784 if (unlikely(prio == -1))
785 return -1;
786
787 BUG_ON(prio >= CFQ_PRIO_LISTS);
788
789 list_splice_init(&cfqd->rr_list[prio], &cfqd->cur_rr);
790
791 cfqd->cur_prio = prio + 1;
792 if (cfqd->cur_prio > cfqd->cur_end_prio) {
793 cfqd->cur_end_prio = cfqd->cur_prio;
794 cfqd->cur_prio = 0;
795 }
796 if (cfqd->cur_end_prio == CFQ_PRIO_LISTS) {
797 cfqd->cur_prio = 0;
798 cfqd->cur_end_prio = 0;
799 }
800
801 return prio;
802}
803
804static struct cfq_queue *cfq_set_active_queue(struct cfq_data *cfqd)
805{
806 struct cfq_queue *cfqq;
807
808 /*
809 * if current queue is expired but not done with its requests yet,
810 * wait for that to happen
811 */
812 if ((cfqq = cfqd->active_queue) != NULL) {
813 if (cfq_cfqq_expired(cfqq) && cfq_cfqq_dispatched(cfqq))
814 return NULL;
815 }
816
817 /*
818 * if current list is non-empty, grab first entry. if it is empty,
819 * get next prio level and grab first entry then if any are spliced
820 */
821 if (!list_empty(&cfqd->cur_rr) || cfq_get_next_prio_level(cfqd) != -1)
822 cfqq = list_entry_cfqq(cfqd->cur_rr.next);
823
824 /*
825 * if we have idle queues and no rt or be queues had pending
826 * requests, either allow immediate service if the grace period
827 * has passed or arm the idle grace timer
828 */
829 if (!cfqq && !list_empty(&cfqd->idle_rr)) {
830 unsigned long end = cfqd->last_end_request + CFQ_IDLE_GRACE;
831
832 if (time_after_eq(jiffies, end))
833 cfqq = list_entry_cfqq(cfqd->idle_rr.next);
834 else
835 mod_timer(&cfqd->idle_class_timer, end);
836 }
837
838 __cfq_set_active_queue(cfqd, cfqq);
839 return cfqq;
840}
841
842/*
843 * current cfqq expired its slice (or was too idle), select new one
844 */
845static void
846__cfq_slice_expired(struct cfq_data *cfqd, struct cfq_queue *cfqq,
847 int preempted)
848{
849 unsigned long now = jiffies;
850
851 if (cfq_cfqq_wait_request(cfqq))
852 del_timer(&cfqd->idle_slice_timer);
853
854 if (!preempted && !cfq_cfqq_dispatched(cfqq))
855 cfqq->service_last = now;
856
857 cfq_clear_cfqq_must_dispatch(cfqq);
858 cfq_clear_cfqq_wait_request(cfqq);
859
860 /*
861 * store what was left of this slice, if the queue idled out
862 * or was preempted
863 */
864 if (time_after(now, cfqq->slice_end))
865 cfqq->slice_left = now - cfqq->slice_end;
866 else
867 cfqq->slice_left = 0;
868
869 if (cfq_cfqq_on_rr(cfqq))
870 cfq_resort_rr_list(cfqq, preempted);
871
872 if (cfqq == cfqd->active_queue)
873 cfqd->active_queue = NULL;
874
875 if (cfqd->active_cic) {
876 put_io_context(cfqd->active_cic->ioc);
877 cfqd->active_cic = NULL;
878 }
879
880 cfqd->dispatch_slice = 0;
881}
882
883static inline void cfq_slice_expired(struct cfq_data *cfqd, int preempted)
884{
885 struct cfq_queue *cfqq = cfqd->active_queue;
886
887 if (cfqq) {
888 /*
889 * use deferred expiry, if there are requests in progress as
890 * not to disturb the slice of the next queue
891 */
892 if (cfq_cfqq_dispatched(cfqq))
893 cfq_mark_cfqq_expired(cfqq);
894 else
895 __cfq_slice_expired(cfqd, cfqq, preempted);
896 }
897}
898
899static int cfq_arm_slice_timer(struct cfq_data *cfqd, struct cfq_queue *cfqq)
900
901{
902 WARN_ON(!RB_EMPTY(&cfqq->sort_list));
903 WARN_ON(cfqq != cfqd->active_queue);
904
905 /*
906 * idle is disabled, either manually or by past process history
907 */
908 if (!cfqd->cfq_slice_idle)
909 return 0;
910 if (!cfq_cfqq_idle_window(cfqq))
911 return 0;
912 /*
913 * task has exited, don't wait
914 */
915 if (cfqd->active_cic && !cfqd->active_cic->ioc->task)
916 return 0;
917
918 cfq_mark_cfqq_must_dispatch(cfqq);
919 cfq_mark_cfqq_wait_request(cfqq);
920
921 if (!timer_pending(&cfqd->idle_slice_timer)) {
922 unsigned long slice_left = min(cfqq->slice_end - 1, (unsigned long) cfqd->cfq_slice_idle);
923
924 cfqd->idle_slice_timer.expires = jiffies + slice_left;
925 add_timer(&cfqd->idle_slice_timer);
926 }
927
928 return 1;
929}
930
931static void cfq_dispatch_insert(request_queue_t *q, struct cfq_rq *crq)
932{
933 struct cfq_data *cfqd = q->elevator->elevator_data;
934 struct cfq_queue *cfqq = crq->cfq_queue;
935
936 cfqq->next_crq = cfq_find_next_crq(cfqd, cfqq, crq);
937 cfq_remove_request(crq->request);
938 cfqq->on_dispatch[cfq_crq_is_sync(crq)]++;
939 elv_dispatch_sort(q, crq->request);
940}
941
942/*
943 * return expired entry, or NULL to just start from scratch in rbtree
944 */
945static inline struct cfq_rq *cfq_check_fifo(struct cfq_queue *cfqq)
946{
947 struct cfq_data *cfqd = cfqq->cfqd;
948 struct request *rq;
949 struct cfq_rq *crq;
950
951 if (cfq_cfqq_fifo_expire(cfqq))
952 return NULL;
953
954 if (!list_empty(&cfqq->fifo)) {
955 int fifo = cfq_cfqq_class_sync(cfqq);
956
957 crq = RQ_DATA(list_entry_fifo(cfqq->fifo.next));
958 rq = crq->request;
959 if (time_after(jiffies, rq->start_time + cfqd->cfq_fifo_expire[fifo])) {
960 cfq_mark_cfqq_fifo_expire(cfqq);
961 return crq;
962 }
963 }
964
965 return NULL;
966}
967
968/*
969 * Scale schedule slice based on io priority. Use the sync time slice only
970 * if a queue is marked sync and has sync io queued. A sync queue with async
971 * io only, should not get full sync slice length.
972 */
973static inline int
974cfq_prio_to_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq)
975{
976 const int base_slice = cfqd->cfq_slice[cfq_cfqq_sync(cfqq)];
977
978 WARN_ON(cfqq->ioprio >= IOPRIO_BE_NR);
979
980 return base_slice + (base_slice/CFQ_SLICE_SCALE * (4 - cfqq->ioprio));
981}
982
983static inline void
984cfq_set_prio_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq)
985{
986 cfqq->slice_end = cfq_prio_to_slice(cfqd, cfqq) + jiffies;
987}
988
989static inline int
990cfq_prio_to_maxrq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
991{
992 const int base_rq = cfqd->cfq_slice_async_rq;
993
994 WARN_ON(cfqq->ioprio >= IOPRIO_BE_NR);
995
996 return 2 * (base_rq + base_rq * (CFQ_PRIO_LISTS - 1 - cfqq->ioprio));
997}
998
999/*
1000 * get next queue for service
1001 */
1002static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd, int force)
1003{
1004 unsigned long now = jiffies;
1005 struct cfq_queue *cfqq;
1006
1007 cfqq = cfqd->active_queue;
1008 if (!cfqq)
1009 goto new_queue;
1010
1011 if (cfq_cfqq_expired(cfqq))
1012 goto new_queue;
1013
1014 /*
1015 * slice has expired
1016 */
1017 if (!cfq_cfqq_must_dispatch(cfqq) && time_after(now, cfqq->slice_end))
1018 goto expire;
1019
1020 /*
1021 * if queue has requests, dispatch one. if not, check if
1022 * enough slice is left to wait for one
1023 */
1024 if (!RB_EMPTY(&cfqq->sort_list))
1025 goto keep_queue;
1026 else if (!force && cfq_cfqq_class_sync(cfqq) &&
1027 time_before(now, cfqq->slice_end)) {
1028 if (cfq_arm_slice_timer(cfqd, cfqq))
1029 return NULL;
1030 }
1031
1032expire:
1033 cfq_slice_expired(cfqd, 0);
1034new_queue:
1035 cfqq = cfq_set_active_queue(cfqd);
1036keep_queue:
1037 return cfqq;
1038}
1039
1040static int
1041__cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1042 int max_dispatch)
1043{
1044 int dispatched = 0;
1045
1046 BUG_ON(RB_EMPTY(&cfqq->sort_list));
1047
1048 do {
1049 struct cfq_rq *crq;
1050
1051 /*
1052 * follow expired path, else get first next available
1053 */
1054 if ((crq = cfq_check_fifo(cfqq)) == NULL)
1055 crq = cfqq->next_crq;
1056
1057 /*
1058 * finally, insert request into driver dispatch list
1059 */
1060 cfq_dispatch_insert(cfqd->queue, crq);
1061
1062 cfqd->dispatch_slice++;
1063 dispatched++;
1064
1065 if (!cfqd->active_cic) {
1066 atomic_inc(&crq->io_context->ioc->refcount);
1067 cfqd->active_cic = crq->io_context;
1068 }
1069
1070 if (RB_EMPTY(&cfqq->sort_list))
1071 break;
1072
1073 } while (dispatched < max_dispatch);
1074
1075 /*
1076 * if slice end isn't set yet, set it. if at least one request was
1077 * sync, use the sync time slice value
1078 */
1079 if (!cfqq->slice_end)
1080 cfq_set_prio_slice(cfqd, cfqq);
1081
1082 /*
1083 * expire an async queue immediately if it has used up its slice. idle
1084 * queue always expire after 1 dispatch round.
1085 */
1086 if ((!cfq_cfqq_sync(cfqq) &&
1087 cfqd->dispatch_slice >= cfq_prio_to_maxrq(cfqd, cfqq)) ||
1088 cfq_class_idle(cfqq))
1089 cfq_slice_expired(cfqd, 0);
1090
1091 return dispatched;
1092}
1093
1094static int
1095cfq_dispatch_requests(request_queue_t *q, int force)
1096{
1097 struct cfq_data *cfqd = q->elevator->elevator_data;
1098 struct cfq_queue *cfqq;
1099
1100 if (!cfqd->busy_queues)
1101 return 0;
1102
1103 cfqq = cfq_select_queue(cfqd, force);
1104 if (cfqq) {
1105 int max_dispatch;
1106
1107 /*
1108 * if idle window is disabled, allow queue buildup
1109 */
1110 if (!cfq_cfqq_idle_window(cfqq) &&
1111 cfqd->rq_in_driver >= cfqd->cfq_max_depth)
1112 return 0;
1113
1114 cfq_clear_cfqq_must_dispatch(cfqq);
1115 cfq_clear_cfqq_wait_request(cfqq);
1116 del_timer(&cfqd->idle_slice_timer);
1117
1118 if (!force) {
1119 max_dispatch = cfqd->cfq_quantum;
1120 if (cfq_class_idle(cfqq))
1121 max_dispatch = 1;
1122 } else
1123 max_dispatch = INT_MAX;
1124
1125 return __cfq_dispatch_requests(cfqd, cfqq, max_dispatch);
1126 }
1127
1128 return 0;
1129}
1130
1131/*
1132 * task holds one reference to the queue, dropped when task exits. each crq
1133 * in-flight on this queue also holds a reference, dropped when crq is freed.
1134 *
1135 * queue lock must be held here.
1136 */
1137static void cfq_put_queue(struct cfq_queue *cfqq)
1138{
1139 struct cfq_data *cfqd = cfqq->cfqd;
1140
1141 BUG_ON(atomic_read(&cfqq->ref) <= 0);
1142
1143 if (!atomic_dec_and_test(&cfqq->ref))
1144 return;
1145
1146 BUG_ON(rb_first(&cfqq->sort_list));
1147 BUG_ON(cfqq->allocated[READ] + cfqq->allocated[WRITE]);
1148 BUG_ON(cfq_cfqq_on_rr(cfqq));
1149
1150 if (unlikely(cfqd->active_queue == cfqq)) {
1151 __cfq_slice_expired(cfqd, cfqq, 0);
1152 cfq_schedule_dispatch(cfqd);
1153 }
1154
1155 cfq_put_cfqd(cfqq->cfqd);
1156
1157 /*
1158 * it's on the empty list and still hashed
1159 */
1160 list_del(&cfqq->cfq_list);
1161 hlist_del(&cfqq->cfq_hash);
1162 kmem_cache_free(cfq_pool, cfqq);
1163}
1164
1165static inline struct cfq_queue *
1166__cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned int key, unsigned int prio,
1167 const int hashval)
1168{
1169 struct hlist_head *hash_list = &cfqd->cfq_hash[hashval];
1170 struct hlist_node *entry, *next;
1171
1172 hlist_for_each_safe(entry, next, hash_list) {
1173 struct cfq_queue *__cfqq = list_entry_qhash(entry);
1174 const unsigned short __p = IOPRIO_PRIO_VALUE(__cfqq->ioprio_class, __cfqq->ioprio);
1175
1176 if (__cfqq->key == key && (__p == prio || prio == CFQ_KEY_ANY))
1177 return __cfqq;
1178 }
1179
1180 return NULL;
1181}
1182
1183static struct cfq_queue *
1184cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned int key, unsigned short prio)
1185{
1186 return __cfq_find_cfq_hash(cfqd, key, prio, hash_long(key, CFQ_QHASH_SHIFT));
1187}
1188
1189static void cfq_free_io_context(struct cfq_io_context *cic)
1190{
1191 struct cfq_io_context *__cic;
1192 struct list_head *entry, *next;
1193
1194 list_for_each_safe(entry, next, &cic->list) {
1195 __cic = list_entry(entry, struct cfq_io_context, list);
1196 kmem_cache_free(cfq_ioc_pool, __cic);
1197 }
1198
1199 kmem_cache_free(cfq_ioc_pool, cic);
1200}
1201
1202/*
1203 * Called with interrupts disabled
1204 */
1205static void cfq_exit_single_io_context(struct cfq_io_context *cic)
1206{
1207 struct cfq_data *cfqd = cic->cfqq->cfqd;
1208 request_queue_t *q = cfqd->queue;
1209
1210 WARN_ON(!irqs_disabled());
1211
1212 spin_lock(q->queue_lock);
1213
1214 if (unlikely(cic->cfqq == cfqd->active_queue)) {
1215 __cfq_slice_expired(cfqd, cic->cfqq, 0);
1216 cfq_schedule_dispatch(cfqd);
1217 }
1218
1219 cfq_put_queue(cic->cfqq);
1220 cic->cfqq = NULL;
1221 spin_unlock(q->queue_lock);
1222}
1223
1224/*
1225 * Another task may update the task cic list, if it is doing a queue lookup
1226 * on its behalf. cfq_cic_lock excludes such concurrent updates
1227 */
1228static void cfq_exit_io_context(struct cfq_io_context *cic)
1229{
1230 struct cfq_io_context *__cic;
1231 struct list_head *entry;
1232 unsigned long flags;
1233
1234 local_irq_save(flags);
1235
1236 /*
1237 * put the reference this task is holding to the various queues
1238 */
1239 list_for_each(entry, &cic->list) {
1240 __cic = list_entry(entry, struct cfq_io_context, list);
1241 cfq_exit_single_io_context(__cic);
1242 }
1243
1244 cfq_exit_single_io_context(cic);
1245 local_irq_restore(flags);
1246}
1247
1248static struct cfq_io_context *
1249cfq_alloc_io_context(struct cfq_data *cfqd, gfp_t gfp_mask)
1250{
1251 struct cfq_io_context *cic = kmem_cache_alloc(cfq_ioc_pool, gfp_mask);
1252
1253 if (cic) {
1254 INIT_LIST_HEAD(&cic->list);
1255 cic->cfqq = NULL;
1256 cic->key = NULL;
1257 cic->last_end_request = jiffies;
1258 cic->ttime_total = 0;
1259 cic->ttime_samples = 0;
1260 cic->ttime_mean = 0;
1261 cic->dtor = cfq_free_io_context;
1262 cic->exit = cfq_exit_io_context;
1263 }
1264
1265 return cic;
1266}
1267
1268static void cfq_init_prio_data(struct cfq_queue *cfqq)
1269{
1270 struct task_struct *tsk = current;
1271 int ioprio_class;
1272
1273 if (!cfq_cfqq_prio_changed(cfqq))
1274 return;
1275
1276 ioprio_class = IOPRIO_PRIO_CLASS(tsk->ioprio);
1277 switch (ioprio_class) {
1278 default:
1279 printk(KERN_ERR "cfq: bad prio %x\n", ioprio_class);
1280 case IOPRIO_CLASS_NONE:
1281 /*
1282 * no prio set, place us in the middle of the BE classes
1283 */
1284 cfqq->ioprio = task_nice_ioprio(tsk);
1285 cfqq->ioprio_class = IOPRIO_CLASS_BE;
1286 break;
1287 case IOPRIO_CLASS_RT:
1288 cfqq->ioprio = task_ioprio(tsk);
1289 cfqq->ioprio_class = IOPRIO_CLASS_RT;
1290 break;
1291 case IOPRIO_CLASS_BE:
1292 cfqq->ioprio = task_ioprio(tsk);
1293 cfqq->ioprio_class = IOPRIO_CLASS_BE;
1294 break;
1295 case IOPRIO_CLASS_IDLE:
1296 cfqq->ioprio_class = IOPRIO_CLASS_IDLE;
1297 cfqq->ioprio = 7;
1298 cfq_clear_cfqq_idle_window(cfqq);
1299 break;
1300 }
1301
1302 /*
1303 * keep track of original prio settings in case we have to temporarily
1304 * elevate the priority of this queue
1305 */
1306 cfqq->org_ioprio = cfqq->ioprio;
1307 cfqq->org_ioprio_class = cfqq->ioprio_class;
1308
1309 if (cfq_cfqq_on_rr(cfqq))
1310 cfq_resort_rr_list(cfqq, 0);
1311
1312 cfq_clear_cfqq_prio_changed(cfqq);
1313}
1314
1315static inline void changed_ioprio(struct cfq_queue *cfqq)
1316{
1317 if (cfqq) {
1318 struct cfq_data *cfqd = cfqq->cfqd;
1319
1320 spin_lock(cfqd->queue->queue_lock);
1321 cfq_mark_cfqq_prio_changed(cfqq);
1322 cfq_init_prio_data(cfqq);
1323 spin_unlock(cfqd->queue->queue_lock);
1324 }
1325}
1326
1327/*
1328 * callback from sys_ioprio_set, irqs are disabled
1329 */
1330static int cfq_ioc_set_ioprio(struct io_context *ioc, unsigned int ioprio)
1331{
1332 struct cfq_io_context *cic = ioc->cic;
1333
1334 changed_ioprio(cic->cfqq);
1335
1336 list_for_each_entry(cic, &cic->list, list)
1337 changed_ioprio(cic->cfqq);
1338
1339 return 0;
1340}
1341
1342static struct cfq_queue *
1343cfq_get_queue(struct cfq_data *cfqd, unsigned int key, unsigned short ioprio,
1344 gfp_t gfp_mask)
1345{
1346 const int hashval = hash_long(key, CFQ_QHASH_SHIFT);
1347 struct cfq_queue *cfqq, *new_cfqq = NULL;
1348
1349retry:
1350 cfqq = __cfq_find_cfq_hash(cfqd, key, ioprio, hashval);
1351
1352 if (!cfqq) {
1353 if (new_cfqq) {
1354 cfqq = new_cfqq;
1355 new_cfqq = NULL;
1356 } else if (gfp_mask & __GFP_WAIT) {
1357 spin_unlock_irq(cfqd->queue->queue_lock);
1358 new_cfqq = kmem_cache_alloc(cfq_pool, gfp_mask);
1359 spin_lock_irq(cfqd->queue->queue_lock);
1360 goto retry;
1361 } else {
1362 cfqq = kmem_cache_alloc(cfq_pool, gfp_mask);
1363 if (!cfqq)
1364 goto out;
1365 }
1366
1367 memset(cfqq, 0, sizeof(*cfqq));
1368
1369 INIT_HLIST_NODE(&cfqq->cfq_hash);
1370 INIT_LIST_HEAD(&cfqq->cfq_list);
1371 RB_CLEAR_ROOT(&cfqq->sort_list);
1372 INIT_LIST_HEAD(&cfqq->fifo);
1373
1374 cfqq->key = key;
1375 hlist_add_head(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]);
1376 atomic_set(&cfqq->ref, 0);
1377 cfqq->cfqd = cfqd;
1378 atomic_inc(&cfqd->ref);
1379 cfqq->service_last = 0;
1380 /*
1381 * set ->slice_left to allow preemption for a new process
1382 */
1383 cfqq->slice_left = 2 * cfqd->cfq_slice_idle;
1384 cfq_mark_cfqq_idle_window(cfqq);
1385 cfq_mark_cfqq_prio_changed(cfqq);
1386 cfq_init_prio_data(cfqq);
1387 }
1388
1389 if (new_cfqq)
1390 kmem_cache_free(cfq_pool, new_cfqq);
1391
1392 atomic_inc(&cfqq->ref);
1393out:
1394 WARN_ON((gfp_mask & __GFP_WAIT) && !cfqq);
1395 return cfqq;
1396}
1397
1398/*
1399 * Setup general io context and cfq io context. There can be several cfq
1400 * io contexts per general io context, if this process is doing io to more
1401 * than one device managed by cfq. Note that caller is holding a reference to
1402 * cfqq, so we don't need to worry about it disappearing
1403 */
1404static struct cfq_io_context *
1405cfq_get_io_context(struct cfq_data *cfqd, pid_t pid, gfp_t gfp_mask)
1406{
1407 struct io_context *ioc = NULL;
1408 struct cfq_io_context *cic;
1409
1410 might_sleep_if(gfp_mask & __GFP_WAIT);
1411
1412 ioc = get_io_context(gfp_mask);
1413 if (!ioc)
1414 return NULL;
1415
1416 if ((cic = ioc->cic) == NULL) {
1417 cic = cfq_alloc_io_context(cfqd, gfp_mask);
1418
1419 if (cic == NULL)
1420 goto err;
1421
1422 /*
1423 * manually increment generic io_context usage count, it
1424 * cannot go away since we are already holding one ref to it
1425 */
1426 ioc->cic = cic;
1427 ioc->set_ioprio = cfq_ioc_set_ioprio;
1428 cic->ioc = ioc;
1429 cic->key = cfqd;
1430 atomic_inc(&cfqd->ref);
1431 } else {
1432 struct cfq_io_context *__cic;
1433
1434 /*
1435 * the first cic on the list is actually the head itself
1436 */
1437 if (cic->key == cfqd)
1438 goto out;
1439
1440 /*
1441 * cic exists, check if we already are there. linear search
1442 * should be ok here, the list will usually not be more than
1443 * 1 or a few entries long
1444 */
1445 list_for_each_entry(__cic, &cic->list, list) {
1446 /*
1447 * this process is already holding a reference to
1448 * this queue, so no need to get one more
1449 */
1450 if (__cic->key == cfqd) {
1451 cic = __cic;
1452 goto out;
1453 }
1454 }
1455
1456 /*
1457 * nope, process doesn't have a cic assoicated with this
1458 * cfqq yet. get a new one and add to list
1459 */
1460 __cic = cfq_alloc_io_context(cfqd, gfp_mask);
1461 if (__cic == NULL)
1462 goto err;
1463
1464 __cic->ioc = ioc;
1465 __cic->key = cfqd;
1466 atomic_inc(&cfqd->ref);
1467 list_add(&__cic->list, &cic->list);
1468 cic = __cic;
1469 }
1470
1471out:
1472 return cic;
1473err:
1474 put_io_context(ioc);
1475 return NULL;
1476}
1477
1478static void
1479cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_io_context *cic)
1480{
1481 unsigned long elapsed, ttime;
1482
1483 /*
1484 * if this context already has stuff queued, thinktime is from
1485 * last queue not last end
1486 */
1487#if 0
1488 if (time_after(cic->last_end_request, cic->last_queue))
1489 elapsed = jiffies - cic->last_end_request;
1490 else
1491 elapsed = jiffies - cic->last_queue;
1492#else
1493 elapsed = jiffies - cic->last_end_request;
1494#endif
1495
1496 ttime = min(elapsed, 2UL * cfqd->cfq_slice_idle);
1497
1498 cic->ttime_samples = (7*cic->ttime_samples + 256) / 8;
1499 cic->ttime_total = (7*cic->ttime_total + 256*ttime) / 8;
1500 cic->ttime_mean = (cic->ttime_total + 128) / cic->ttime_samples;
1501}
1502
1503#define sample_valid(samples) ((samples) > 80)
1504
1505/*
1506 * Disable idle window if the process thinks too long or seeks so much that
1507 * it doesn't matter
1508 */
1509static void
1510cfq_update_idle_window(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1511 struct cfq_io_context *cic)
1512{
1513 int enable_idle = cfq_cfqq_idle_window(cfqq);
1514
1515 if (!cic->ioc->task || !cfqd->cfq_slice_idle)
1516 enable_idle = 0;
1517 else if (sample_valid(cic->ttime_samples)) {
1518 if (cic->ttime_mean > cfqd->cfq_slice_idle)
1519 enable_idle = 0;
1520 else
1521 enable_idle = 1;
1522 }
1523
1524 if (enable_idle)
1525 cfq_mark_cfqq_idle_window(cfqq);
1526 else
1527 cfq_clear_cfqq_idle_window(cfqq);
1528}
1529
1530
1531/*
1532 * Check if new_cfqq should preempt the currently active queue. Return 0 for
1533 * no or if we aren't sure, a 1 will cause a preempt.
1534 */
1535static int
1536cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
1537 struct cfq_rq *crq)
1538{
1539 struct cfq_queue *cfqq = cfqd->active_queue;
1540
1541 if (cfq_class_idle(new_cfqq))
1542 return 0;
1543
1544 if (!cfqq)
1545 return 1;
1546
1547 if (cfq_class_idle(cfqq))
1548 return 1;
1549 if (!cfq_cfqq_wait_request(new_cfqq))
1550 return 0;
1551 /*
1552 * if it doesn't have slice left, forget it
1553 */
1554 if (new_cfqq->slice_left < cfqd->cfq_slice_idle)
1555 return 0;
1556 if (cfq_crq_is_sync(crq) && !cfq_cfqq_sync(cfqq))
1557 return 1;
1558
1559 return 0;
1560}
1561
1562/*
1563 * cfqq preempts the active queue. if we allowed preempt with no slice left,
1564 * let it have half of its nominal slice.
1565 */
1566static void cfq_preempt_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
1567{
1568 struct cfq_queue *__cfqq, *next;
1569
1570 list_for_each_entry_safe(__cfqq, next, &cfqd->cur_rr, cfq_list)
1571 cfq_resort_rr_list(__cfqq, 1);
1572
1573 if (!cfqq->slice_left)
1574 cfqq->slice_left = cfq_prio_to_slice(cfqd, cfqq) / 2;
1575
1576 cfqq->slice_end = cfqq->slice_left + jiffies;
1577 __cfq_slice_expired(cfqd, cfqq, 1);
1578 __cfq_set_active_queue(cfqd, cfqq);
1579}
1580
1581/*
1582 * should really be a ll_rw_blk.c helper
1583 */
1584static void cfq_start_queueing(struct cfq_data *cfqd, struct cfq_queue *cfqq)
1585{
1586 request_queue_t *q = cfqd->queue;
1587
1588 if (!blk_queue_plugged(q))
1589 q->request_fn(q);
1590 else
1591 __generic_unplug_device(q);
1592}
1593
1594/*
1595 * Called when a new fs request (crq) is added (to cfqq). Check if there's
1596 * something we should do about it
1597 */
1598static void
1599cfq_crq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1600 struct cfq_rq *crq)
1601{
1602 struct cfq_io_context *cic;
1603
1604 cfqq->next_crq = cfq_choose_req(cfqd, cfqq->next_crq, crq);
1605
1606 /*
1607 * we never wait for an async request and we don't allow preemption
1608 * of an async request. so just return early
1609 */
1610 if (!cfq_crq_is_sync(crq))
1611 return;
1612
1613 cic = crq->io_context;
1614
1615 cfq_update_io_thinktime(cfqd, cic);
1616 cfq_update_idle_window(cfqd, cfqq, cic);
1617
1618 cic->last_queue = jiffies;
1619
1620 if (cfqq == cfqd->active_queue) {
1621 /*
1622 * if we are waiting for a request for this queue, let it rip
1623 * immediately and flag that we must not expire this queue
1624 * just now
1625 */
1626 if (cfq_cfqq_wait_request(cfqq)) {
1627 cfq_mark_cfqq_must_dispatch(cfqq);
1628 del_timer(&cfqd->idle_slice_timer);
1629 cfq_start_queueing(cfqd, cfqq);
1630 }
1631 } else if (cfq_should_preempt(cfqd, cfqq, crq)) {
1632 /*
1633 * not the active queue - expire current slice if it is
1634 * idle and has expired it's mean thinktime or this new queue
1635 * has some old slice time left and is of higher priority
1636 */
1637 cfq_preempt_queue(cfqd, cfqq);
1638 cfq_mark_cfqq_must_dispatch(cfqq);
1639 cfq_start_queueing(cfqd, cfqq);
1640 }
1641}
1642
1643static void cfq_insert_request(request_queue_t *q, struct request *rq)
1644{
1645 struct cfq_data *cfqd = q->elevator->elevator_data;
1646 struct cfq_rq *crq = RQ_DATA(rq);
1647 struct cfq_queue *cfqq = crq->cfq_queue;
1648
1649 cfq_init_prio_data(cfqq);
1650
1651 cfq_add_crq_rb(crq);
1652
1653 list_add_tail(&rq->queuelist, &cfqq->fifo);
1654
1655 if (rq_mergeable(rq))
1656 cfq_add_crq_hash(cfqd, crq);
1657
1658 cfq_crq_enqueued(cfqd, cfqq, crq);
1659}
1660
1661static void cfq_completed_request(request_queue_t *q, struct request *rq)
1662{
1663 struct cfq_rq *crq = RQ_DATA(rq);
1664 struct cfq_queue *cfqq = crq->cfq_queue;
1665 struct cfq_data *cfqd = cfqq->cfqd;
1666 const int sync = cfq_crq_is_sync(crq);
1667 unsigned long now;
1668
1669 now = jiffies;
1670
1671 WARN_ON(!cfqd->rq_in_driver);
1672 WARN_ON(!cfqq->on_dispatch[sync]);
1673 cfqd->rq_in_driver--;
1674 cfqq->on_dispatch[sync]--;
1675
1676 if (!cfq_class_idle(cfqq))
1677 cfqd->last_end_request = now;
1678
1679 if (!cfq_cfqq_dispatched(cfqq)) {
1680 if (cfq_cfqq_on_rr(cfqq)) {
1681 cfqq->service_last = now;
1682 cfq_resort_rr_list(cfqq, 0);
1683 }
1684 if (cfq_cfqq_expired(cfqq)) {
1685 __cfq_slice_expired(cfqd, cfqq, 0);
1686 cfq_schedule_dispatch(cfqd);
1687 }
1688 }
1689
1690 if (cfq_crq_is_sync(crq))
1691 crq->io_context->last_end_request = now;
1692}
1693
1694static struct request *
1695cfq_former_request(request_queue_t *q, struct request *rq)
1696{
1697 struct cfq_rq *crq = RQ_DATA(rq);
1698 struct rb_node *rbprev = rb_prev(&crq->rb_node);
1699
1700 if (rbprev)
1701 return rb_entry_crq(rbprev)->request;
1702
1703 return NULL;
1704}
1705
1706static struct request *
1707cfq_latter_request(request_queue_t *q, struct request *rq)
1708{
1709 struct cfq_rq *crq = RQ_DATA(rq);
1710 struct rb_node *rbnext = rb_next(&crq->rb_node);
1711
1712 if (rbnext)
1713 return rb_entry_crq(rbnext)->request;
1714
1715 return NULL;
1716}
1717
1718/*
1719 * we temporarily boost lower priority queues if they are holding fs exclusive
1720 * resources. they are boosted to normal prio (CLASS_BE/4)
1721 */
1722static void cfq_prio_boost(struct cfq_queue *cfqq)
1723{
1724 const int ioprio_class = cfqq->ioprio_class;
1725 const int ioprio = cfqq->ioprio;
1726
1727 if (has_fs_excl()) {
1728 /*
1729 * boost idle prio on transactions that would lock out other
1730 * users of the filesystem
1731 */
1732 if (cfq_class_idle(cfqq))
1733 cfqq->ioprio_class = IOPRIO_CLASS_BE;
1734 if (cfqq->ioprio > IOPRIO_NORM)
1735 cfqq->ioprio = IOPRIO_NORM;
1736 } else {
1737 /*
1738 * check if we need to unboost the queue
1739 */
1740 if (cfqq->ioprio_class != cfqq->org_ioprio_class)
1741 cfqq->ioprio_class = cfqq->org_ioprio_class;
1742 if (cfqq->ioprio != cfqq->org_ioprio)
1743 cfqq->ioprio = cfqq->org_ioprio;
1744 }
1745
1746 /*
1747 * refile between round-robin lists if we moved the priority class
1748 */
1749 if ((ioprio_class != cfqq->ioprio_class || ioprio != cfqq->ioprio) &&
1750 cfq_cfqq_on_rr(cfqq))
1751 cfq_resort_rr_list(cfqq, 0);
1752}
1753
1754static inline pid_t cfq_queue_pid(struct task_struct *task, int rw)
1755{
1756 if (rw == READ || process_sync(task))
1757 return task->pid;
1758
1759 return CFQ_KEY_ASYNC;
1760}
1761
1762static inline int
1763__cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1764 struct task_struct *task, int rw)
1765{
1766#if 1
1767 if ((cfq_cfqq_wait_request(cfqq) || cfq_cfqq_must_alloc(cfqq)) &&
1768 !cfq_cfqq_must_alloc_slice(cfqq)) {
1769 cfq_mark_cfqq_must_alloc_slice(cfqq);
1770 return ELV_MQUEUE_MUST;
1771 }
1772
1773 return ELV_MQUEUE_MAY;
1774#else
1775 if (!cfqq || task->flags & PF_MEMALLOC)
1776 return ELV_MQUEUE_MAY;
1777 if (!cfqq->allocated[rw] || cfq_cfqq_must_alloc(cfqq)) {
1778 if (cfq_cfqq_wait_request(cfqq))
1779 return ELV_MQUEUE_MUST;
1780
1781 /*
1782 * only allow 1 ELV_MQUEUE_MUST per slice, otherwise we
1783 * can quickly flood the queue with writes from a single task
1784 */
1785 if (rw == READ || !cfq_cfqq_must_alloc_slice(cfqq)) {
1786 cfq_mark_cfqq_must_alloc_slice(cfqq);
1787 return ELV_MQUEUE_MUST;
1788 }
1789
1790 return ELV_MQUEUE_MAY;
1791 }
1792 if (cfq_class_idle(cfqq))
1793 return ELV_MQUEUE_NO;
1794 if (cfqq->allocated[rw] >= cfqd->max_queued) {
1795 struct io_context *ioc = get_io_context(GFP_ATOMIC);
1796 int ret = ELV_MQUEUE_NO;
1797
1798 if (ioc && ioc->nr_batch_requests)
1799 ret = ELV_MQUEUE_MAY;
1800
1801 put_io_context(ioc);
1802 return ret;
1803 }
1804
1805 return ELV_MQUEUE_MAY;
1806#endif
1807}
1808
1809static int cfq_may_queue(request_queue_t *q, int rw, struct bio *bio)
1810{
1811 struct cfq_data *cfqd = q->elevator->elevator_data;
1812 struct task_struct *tsk = current;
1813 struct cfq_queue *cfqq;
1814
1815 /*
1816 * don't force setup of a queue from here, as a call to may_queue
1817 * does not necessarily imply that a request actually will be queued.
1818 * so just lookup a possibly existing queue, or return 'may queue'
1819 * if that fails
1820 */
1821 cfqq = cfq_find_cfq_hash(cfqd, cfq_queue_pid(tsk, rw), tsk->ioprio);
1822 if (cfqq) {
1823 cfq_init_prio_data(cfqq);
1824 cfq_prio_boost(cfqq);
1825
1826 return __cfq_may_queue(cfqd, cfqq, tsk, rw);
1827 }
1828
1829 return ELV_MQUEUE_MAY;
1830}
1831
1832static void cfq_check_waiters(request_queue_t *q, struct cfq_queue *cfqq)
1833{
1834 struct cfq_data *cfqd = q->elevator->elevator_data;
1835 struct request_list *rl = &q->rq;
1836
1837 if (cfqq->allocated[READ] <= cfqd->max_queued || cfqd->rq_starved) {
1838 smp_mb();
1839 if (waitqueue_active(&rl->wait[READ]))
1840 wake_up(&rl->wait[READ]);
1841 }
1842
1843 if (cfqq->allocated[WRITE] <= cfqd->max_queued || cfqd->rq_starved) {
1844 smp_mb();
1845 if (waitqueue_active(&rl->wait[WRITE]))
1846 wake_up(&rl->wait[WRITE]);
1847 }
1848}
1849
1850/*
1851 * queue lock held here
1852 */
1853static void cfq_put_request(request_queue_t *q, struct request *rq)
1854{
1855 struct cfq_data *cfqd = q->elevator->elevator_data;
1856 struct cfq_rq *crq = RQ_DATA(rq);
1857
1858 if (crq) {
1859 struct cfq_queue *cfqq = crq->cfq_queue;
1860 const int rw = rq_data_dir(rq);
1861
1862 BUG_ON(!cfqq->allocated[rw]);
1863 cfqq->allocated[rw]--;
1864
1865 put_io_context(crq->io_context->ioc);
1866
1867 mempool_free(crq, cfqd->crq_pool);
1868 rq->elevator_private = NULL;
1869
1870 cfq_check_waiters(q, cfqq);
1871 cfq_put_queue(cfqq);
1872 }
1873}
1874
1875/*
1876 * Allocate cfq data structures associated with this request.
1877 */
1878static int
1879cfq_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
1880 gfp_t gfp_mask)
1881{
1882 struct cfq_data *cfqd = q->elevator->elevator_data;
1883 struct task_struct *tsk = current;
1884 struct cfq_io_context *cic;
1885 const int rw = rq_data_dir(rq);
1886 pid_t key = cfq_queue_pid(tsk, rw);
1887 struct cfq_queue *cfqq;
1888 struct cfq_rq *crq;
1889 unsigned long flags;
1890
1891 might_sleep_if(gfp_mask & __GFP_WAIT);
1892
1893 cic = cfq_get_io_context(cfqd, key, gfp_mask);
1894
1895 spin_lock_irqsave(q->queue_lock, flags);
1896
1897 if (!cic)
1898 goto queue_fail;
1899
1900 if (!cic->cfqq) {
1901 cfqq = cfq_get_queue(cfqd, key, tsk->ioprio, gfp_mask);
1902 if (!cfqq)
1903 goto queue_fail;
1904
1905 cic->cfqq = cfqq;
1906 } else
1907 cfqq = cic->cfqq;
1908
1909 cfqq->allocated[rw]++;
1910 cfq_clear_cfqq_must_alloc(cfqq);
1911 cfqd->rq_starved = 0;
1912 atomic_inc(&cfqq->ref);
1913 spin_unlock_irqrestore(q->queue_lock, flags);
1914
1915 crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
1916 if (crq) {
1917 RB_CLEAR(&crq->rb_node);
1918 crq->rb_key = 0;
1919 crq->request = rq;
1920 INIT_HLIST_NODE(&crq->hash);
1921 crq->cfq_queue = cfqq;
1922 crq->io_context = cic;
1923
1924 if (rw == READ || process_sync(tsk))
1925 cfq_mark_crq_is_sync(crq);
1926 else
1927 cfq_clear_crq_is_sync(crq);
1928
1929 rq->elevator_private = crq;
1930 return 0;
1931 }
1932
1933 spin_lock_irqsave(q->queue_lock, flags);
1934 cfqq->allocated[rw]--;
1935 if (!(cfqq->allocated[0] + cfqq->allocated[1]))
1936 cfq_mark_cfqq_must_alloc(cfqq);
1937 cfq_put_queue(cfqq);
1938queue_fail:
1939 if (cic)
1940 put_io_context(cic->ioc);
1941 /*
1942 * mark us rq allocation starved. we need to kickstart the process
1943 * ourselves if there are no pending requests that can do it for us.
1944 * that would be an extremely rare OOM situation
1945 */
1946 cfqd->rq_starved = 1;
1947 cfq_schedule_dispatch(cfqd);
1948 spin_unlock_irqrestore(q->queue_lock, flags);
1949 return 1;
1950}
1951
1952static void cfq_kick_queue(void *data)
1953{
1954 request_queue_t *q = data;
1955 struct cfq_data *cfqd = q->elevator->elevator_data;
1956 unsigned long flags;
1957
1958 spin_lock_irqsave(q->queue_lock, flags);
1959
1960 if (cfqd->rq_starved) {
1961 struct request_list *rl = &q->rq;
1962
1963 /*
1964 * we aren't guaranteed to get a request after this, but we
1965 * have to be opportunistic
1966 */
1967 smp_mb();
1968 if (waitqueue_active(&rl->wait[READ]))
1969 wake_up(&rl->wait[READ]);
1970 if (waitqueue_active(&rl->wait[WRITE]))
1971 wake_up(&rl->wait[WRITE]);
1972 }
1973
1974 blk_remove_plug(q);
1975 q->request_fn(q);
1976 spin_unlock_irqrestore(q->queue_lock, flags);
1977}
1978
1979/*
1980 * Timer running if the active_queue is currently idling inside its time slice
1981 */
1982static void cfq_idle_slice_timer(unsigned long data)
1983{
1984 struct cfq_data *cfqd = (struct cfq_data *) data;
1985 struct cfq_queue *cfqq;
1986 unsigned long flags;
1987
1988 spin_lock_irqsave(cfqd->queue->queue_lock, flags);
1989
1990 if ((cfqq = cfqd->active_queue) != NULL) {
1991 unsigned long now = jiffies;
1992
1993 /*
1994 * expired
1995 */
1996 if (time_after(now, cfqq->slice_end))
1997 goto expire;
1998
1999 /*
2000 * only expire and reinvoke request handler, if there are
2001 * other queues with pending requests
2002 */
2003 if (!cfqd->busy_queues) {
2004 cfqd->idle_slice_timer.expires = min(now + cfqd->cfq_slice_idle, cfqq->slice_end);
2005 add_timer(&cfqd->idle_slice_timer);
2006 goto out_cont;
2007 }
2008
2009 /*
2010 * not expired and it has a request pending, let it dispatch
2011 */
2012 if (!RB_EMPTY(&cfqq->sort_list)) {
2013 cfq_mark_cfqq_must_dispatch(cfqq);
2014 goto out_kick;
2015 }
2016 }
2017expire:
2018 cfq_slice_expired(cfqd, 0);
2019out_kick:
2020 cfq_schedule_dispatch(cfqd);
2021out_cont:
2022 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
2023}
2024
2025/*
2026 * Timer running if an idle class queue is waiting for service
2027 */
2028static void cfq_idle_class_timer(unsigned long data)
2029{
2030 struct cfq_data *cfqd = (struct cfq_data *) data;
2031 unsigned long flags, end;
2032
2033 spin_lock_irqsave(cfqd->queue->queue_lock, flags);
2034
2035 /*
2036 * race with a non-idle queue, reset timer
2037 */
2038 end = cfqd->last_end_request + CFQ_IDLE_GRACE;
2039 if (!time_after_eq(jiffies, end)) {
2040 cfqd->idle_class_timer.expires = end;
2041 add_timer(&cfqd->idle_class_timer);
2042 } else
2043 cfq_schedule_dispatch(cfqd);
2044
2045 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
2046}
2047
2048static void cfq_shutdown_timer_wq(struct cfq_data *cfqd)
2049{
2050 del_timer_sync(&cfqd->idle_slice_timer);
2051 del_timer_sync(&cfqd->idle_class_timer);
2052 blk_sync_queue(cfqd->queue);
2053}
2054
2055static void cfq_put_cfqd(struct cfq_data *cfqd)
2056{
2057 request_queue_t *q = cfqd->queue;
2058
2059 if (!atomic_dec_and_test(&cfqd->ref))
2060 return;
2061
2062 cfq_shutdown_timer_wq(cfqd);
2063 blk_put_queue(q);
2064
2065 mempool_destroy(cfqd->crq_pool);
2066 kfree(cfqd->crq_hash);
2067 kfree(cfqd->cfq_hash);
2068 kfree(cfqd);
2069}
2070
2071static void cfq_exit_queue(elevator_t *e)
2072{
2073 struct cfq_data *cfqd = e->elevator_data;
2074
2075 cfq_shutdown_timer_wq(cfqd);
2076 cfq_put_cfqd(cfqd);
2077}
2078
2079static int cfq_init_queue(request_queue_t *q, elevator_t *e)
2080{
2081 struct cfq_data *cfqd;
2082 int i;
2083
2084 cfqd = kmalloc(sizeof(*cfqd), GFP_KERNEL);
2085 if (!cfqd)
2086 return -ENOMEM;
2087
2088 memset(cfqd, 0, sizeof(*cfqd));
2089
2090 for (i = 0; i < CFQ_PRIO_LISTS; i++)
2091 INIT_LIST_HEAD(&cfqd->rr_list[i]);
2092
2093 INIT_LIST_HEAD(&cfqd->busy_rr);
2094 INIT_LIST_HEAD(&cfqd->cur_rr);
2095 INIT_LIST_HEAD(&cfqd->idle_rr);
2096 INIT_LIST_HEAD(&cfqd->empty_list);
2097
2098 cfqd->crq_hash = kmalloc(sizeof(struct hlist_head) * CFQ_MHASH_ENTRIES, GFP_KERNEL);
2099 if (!cfqd->crq_hash)
2100 goto out_crqhash;
2101
2102 cfqd->cfq_hash = kmalloc(sizeof(struct hlist_head) * CFQ_QHASH_ENTRIES, GFP_KERNEL);
2103 if (!cfqd->cfq_hash)
2104 goto out_cfqhash;
2105
2106 cfqd->crq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, crq_pool);
2107 if (!cfqd->crq_pool)
2108 goto out_crqpool;
2109
2110 for (i = 0; i < CFQ_MHASH_ENTRIES; i++)
2111 INIT_HLIST_HEAD(&cfqd->crq_hash[i]);
2112 for (i = 0; i < CFQ_QHASH_ENTRIES; i++)
2113 INIT_HLIST_HEAD(&cfqd->cfq_hash[i]);
2114
2115 e->elevator_data = cfqd;
2116
2117 cfqd->queue = q;
2118 atomic_inc(&q->refcnt);
2119
2120 cfqd->max_queued = q->nr_requests / 4;
2121 q->nr_batching = cfq_queued;
2122
2123 init_timer(&cfqd->idle_slice_timer);
2124 cfqd->idle_slice_timer.function = cfq_idle_slice_timer;
2125 cfqd->idle_slice_timer.data = (unsigned long) cfqd;
2126
2127 init_timer(&cfqd->idle_class_timer);
2128 cfqd->idle_class_timer.function = cfq_idle_class_timer;
2129 cfqd->idle_class_timer.data = (unsigned long) cfqd;
2130
2131 INIT_WORK(&cfqd->unplug_work, cfq_kick_queue, q);
2132
2133 atomic_set(&cfqd->ref, 1);
2134
2135 cfqd->cfq_queued = cfq_queued;
2136 cfqd->cfq_quantum = cfq_quantum;
2137 cfqd->cfq_fifo_expire[0] = cfq_fifo_expire[0];
2138 cfqd->cfq_fifo_expire[1] = cfq_fifo_expire[1];
2139 cfqd->cfq_back_max = cfq_back_max;
2140 cfqd->cfq_back_penalty = cfq_back_penalty;
2141 cfqd->cfq_slice[0] = cfq_slice_async;
2142 cfqd->cfq_slice[1] = cfq_slice_sync;
2143 cfqd->cfq_slice_async_rq = cfq_slice_async_rq;
2144 cfqd->cfq_slice_idle = cfq_slice_idle;
2145 cfqd->cfq_max_depth = cfq_max_depth;
2146
2147 return 0;
2148out_crqpool:
2149 kfree(cfqd->cfq_hash);
2150out_cfqhash:
2151 kfree(cfqd->crq_hash);
2152out_crqhash:
2153 kfree(cfqd);
2154 return -ENOMEM;
2155}
2156
2157static void cfq_slab_kill(void)
2158{
2159 if (crq_pool)
2160 kmem_cache_destroy(crq_pool);
2161 if (cfq_pool)
2162 kmem_cache_destroy(cfq_pool);
2163 if (cfq_ioc_pool)
2164 kmem_cache_destroy(cfq_ioc_pool);
2165}
2166
2167static int __init cfq_slab_setup(void)
2168{
2169 crq_pool = kmem_cache_create("crq_pool", sizeof(struct cfq_rq), 0, 0,
2170 NULL, NULL);
2171 if (!crq_pool)
2172 goto fail;
2173
2174 cfq_pool = kmem_cache_create("cfq_pool", sizeof(struct cfq_queue), 0, 0,
2175 NULL, NULL);
2176 if (!cfq_pool)
2177 goto fail;
2178
2179 cfq_ioc_pool = kmem_cache_create("cfq_ioc_pool",
2180 sizeof(struct cfq_io_context), 0, 0, NULL, NULL);
2181 if (!cfq_ioc_pool)
2182 goto fail;
2183
2184 return 0;
2185fail:
2186 cfq_slab_kill();
2187 return -ENOMEM;
2188}
2189
2190/*
2191 * sysfs parts below -->
2192 */
2193struct cfq_fs_entry {
2194 struct attribute attr;
2195 ssize_t (*show)(struct cfq_data *, char *);
2196 ssize_t (*store)(struct cfq_data *, const char *, size_t);
2197};
2198
2199static ssize_t
2200cfq_var_show(unsigned int var, char *page)
2201{
2202 return sprintf(page, "%d\n", var);
2203}
2204
2205static ssize_t
2206cfq_var_store(unsigned int *var, const char *page, size_t count)
2207{
2208 char *p = (char *) page;
2209
2210 *var = simple_strtoul(p, &p, 10);
2211 return count;
2212}
2213
2214#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
2215static ssize_t __FUNC(struct cfq_data *cfqd, char *page) \
2216{ \
2217 unsigned int __data = __VAR; \
2218 if (__CONV) \
2219 __data = jiffies_to_msecs(__data); \
2220 return cfq_var_show(__data, (page)); \
2221}
2222SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum, 0);
2223SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued, 0);
2224SHOW_FUNCTION(cfq_fifo_expire_sync_show, cfqd->cfq_fifo_expire[1], 1);
2225SHOW_FUNCTION(cfq_fifo_expire_async_show, cfqd->cfq_fifo_expire[0], 1);
2226SHOW_FUNCTION(cfq_back_max_show, cfqd->cfq_back_max, 0);
2227SHOW_FUNCTION(cfq_back_penalty_show, cfqd->cfq_back_penalty, 0);
2228SHOW_FUNCTION(cfq_slice_idle_show, cfqd->cfq_slice_idle, 1);
2229SHOW_FUNCTION(cfq_slice_sync_show, cfqd->cfq_slice[1], 1);
2230SHOW_FUNCTION(cfq_slice_async_show, cfqd->cfq_slice[0], 1);
2231SHOW_FUNCTION(cfq_slice_async_rq_show, cfqd->cfq_slice_async_rq, 0);
2232SHOW_FUNCTION(cfq_max_depth_show, cfqd->cfq_max_depth, 0);
2233#undef SHOW_FUNCTION
2234
2235#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
2236static ssize_t __FUNC(struct cfq_data *cfqd, const char *page, size_t count) \
2237{ \
2238 unsigned int __data; \
2239 int ret = cfq_var_store(&__data, (page), count); \
2240 if (__data < (MIN)) \
2241 __data = (MIN); \
2242 else if (__data > (MAX)) \
2243 __data = (MAX); \
2244 if (__CONV) \
2245 *(__PTR) = msecs_to_jiffies(__data); \
2246 else \
2247 *(__PTR) = __data; \
2248 return ret; \
2249}
2250STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0);
2251STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, UINT_MAX, 0);
2252STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1, UINT_MAX, 1);
2253STORE_FUNCTION(cfq_fifo_expire_async_store, &cfqd->cfq_fifo_expire[0], 1, UINT_MAX, 1);
2254STORE_FUNCTION(cfq_back_max_store, &cfqd->cfq_back_max, 0, UINT_MAX, 0);
2255STORE_FUNCTION(cfq_back_penalty_store, &cfqd->cfq_back_penalty, 1, UINT_MAX, 0);
2256STORE_FUNCTION(cfq_slice_idle_store, &cfqd->cfq_slice_idle, 0, UINT_MAX, 1);
2257STORE_FUNCTION(cfq_slice_sync_store, &cfqd->cfq_slice[1], 1, UINT_MAX, 1);
2258STORE_FUNCTION(cfq_slice_async_store, &cfqd->cfq_slice[0], 1, UINT_MAX, 1);
2259STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1, UINT_MAX, 0);
2260STORE_FUNCTION(cfq_max_depth_store, &cfqd->cfq_max_depth, 1, UINT_MAX, 0);
2261#undef STORE_FUNCTION
2262
2263static struct cfq_fs_entry cfq_quantum_entry = {
2264 .attr = {.name = "quantum", .mode = S_IRUGO | S_IWUSR },
2265 .show = cfq_quantum_show,
2266 .store = cfq_quantum_store,
2267};
2268static struct cfq_fs_entry cfq_queued_entry = {
2269 .attr = {.name = "queued", .mode = S_IRUGO | S_IWUSR },
2270 .show = cfq_queued_show,
2271 .store = cfq_queued_store,
2272};
2273static struct cfq_fs_entry cfq_fifo_expire_sync_entry = {
2274 .attr = {.name = "fifo_expire_sync", .mode = S_IRUGO | S_IWUSR },
2275 .show = cfq_fifo_expire_sync_show,
2276 .store = cfq_fifo_expire_sync_store,
2277};
2278static struct cfq_fs_entry cfq_fifo_expire_async_entry = {
2279 .attr = {.name = "fifo_expire_async", .mode = S_IRUGO | S_IWUSR },
2280 .show = cfq_fifo_expire_async_show,
2281 .store = cfq_fifo_expire_async_store,
2282};
2283static struct cfq_fs_entry cfq_back_max_entry = {
2284 .attr = {.name = "back_seek_max", .mode = S_IRUGO | S_IWUSR },
2285 .show = cfq_back_max_show,
2286 .store = cfq_back_max_store,
2287};
2288static struct cfq_fs_entry cfq_back_penalty_entry = {
2289 .attr = {.name = "back_seek_penalty", .mode = S_IRUGO | S_IWUSR },
2290 .show = cfq_back_penalty_show,
2291 .store = cfq_back_penalty_store,
2292};
2293static struct cfq_fs_entry cfq_slice_sync_entry = {
2294 .attr = {.name = "slice_sync", .mode = S_IRUGO | S_IWUSR },
2295 .show = cfq_slice_sync_show,
2296 .store = cfq_slice_sync_store,
2297};
2298static struct cfq_fs_entry cfq_slice_async_entry = {
2299 .attr = {.name = "slice_async", .mode = S_IRUGO | S_IWUSR },
2300 .show = cfq_slice_async_show,
2301 .store = cfq_slice_async_store,
2302};
2303static struct cfq_fs_entry cfq_slice_async_rq_entry = {
2304 .attr = {.name = "slice_async_rq", .mode = S_IRUGO | S_IWUSR },
2305 .show = cfq_slice_async_rq_show,
2306 .store = cfq_slice_async_rq_store,
2307};
2308static struct cfq_fs_entry cfq_slice_idle_entry = {
2309 .attr = {.name = "slice_idle", .mode = S_IRUGO | S_IWUSR },
2310 .show = cfq_slice_idle_show,
2311 .store = cfq_slice_idle_store,
2312};
2313static struct cfq_fs_entry cfq_max_depth_entry = {
2314 .attr = {.name = "max_depth", .mode = S_IRUGO | S_IWUSR },
2315 .show = cfq_max_depth_show,
2316 .store = cfq_max_depth_store,
2317};
2318
2319static struct attribute *default_attrs[] = {
2320 &cfq_quantum_entry.attr,
2321 &cfq_queued_entry.attr,
2322 &cfq_fifo_expire_sync_entry.attr,
2323 &cfq_fifo_expire_async_entry.attr,
2324 &cfq_back_max_entry.attr,
2325 &cfq_back_penalty_entry.attr,
2326 &cfq_slice_sync_entry.attr,
2327 &cfq_slice_async_entry.attr,
2328 &cfq_slice_async_rq_entry.attr,
2329 &cfq_slice_idle_entry.attr,
2330 &cfq_max_depth_entry.attr,
2331 NULL,
2332};
2333
2334#define to_cfq(atr) container_of((atr), struct cfq_fs_entry, attr)
2335
2336static ssize_t
2337cfq_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
2338{
2339 elevator_t *e = container_of(kobj, elevator_t, kobj);
2340 struct cfq_fs_entry *entry = to_cfq(attr);
2341
2342 if (!entry->show)
2343 return -EIO;
2344
2345 return entry->show(e->elevator_data, page);
2346}
2347
2348static ssize_t
2349cfq_attr_store(struct kobject *kobj, struct attribute *attr,
2350 const char *page, size_t length)
2351{
2352 elevator_t *e = container_of(kobj, elevator_t, kobj);
2353 struct cfq_fs_entry *entry = to_cfq(attr);
2354
2355 if (!entry->store)
2356 return -EIO;
2357
2358 return entry->store(e->elevator_data, page, length);
2359}
2360
2361static struct sysfs_ops cfq_sysfs_ops = {
2362 .show = cfq_attr_show,
2363 .store = cfq_attr_store,
2364};
2365
2366static struct kobj_type cfq_ktype = {
2367 .sysfs_ops = &cfq_sysfs_ops,
2368 .default_attrs = default_attrs,
2369};
2370
2371static struct elevator_type iosched_cfq = {
2372 .ops = {
2373 .elevator_merge_fn = cfq_merge,
2374 .elevator_merged_fn = cfq_merged_request,
2375 .elevator_merge_req_fn = cfq_merged_requests,
2376 .elevator_dispatch_fn = cfq_dispatch_requests,
2377 .elevator_add_req_fn = cfq_insert_request,
2378 .elevator_activate_req_fn = cfq_activate_request,
2379 .elevator_deactivate_req_fn = cfq_deactivate_request,
2380 .elevator_queue_empty_fn = cfq_queue_empty,
2381 .elevator_completed_req_fn = cfq_completed_request,
2382 .elevator_former_req_fn = cfq_former_request,
2383 .elevator_latter_req_fn = cfq_latter_request,
2384 .elevator_set_req_fn = cfq_set_request,
2385 .elevator_put_req_fn = cfq_put_request,
2386 .elevator_may_queue_fn = cfq_may_queue,
2387 .elevator_init_fn = cfq_init_queue,
2388 .elevator_exit_fn = cfq_exit_queue,
2389 },
2390 .elevator_ktype = &cfq_ktype,
2391 .elevator_name = "cfq",
2392 .elevator_owner = THIS_MODULE,
2393};
2394
2395static int __init cfq_init(void)
2396{
2397 int ret;
2398
2399 /*
2400 * could be 0 on HZ < 1000 setups
2401 */
2402 if (!cfq_slice_async)
2403 cfq_slice_async = 1;
2404 if (!cfq_slice_idle)
2405 cfq_slice_idle = 1;
2406
2407 if (cfq_slab_setup())
2408 return -ENOMEM;
2409
2410 ret = elv_register(&iosched_cfq);
2411 if (ret)
2412 cfq_slab_kill();
2413
2414 return ret;
2415}
2416
2417static void __exit cfq_exit(void)
2418{
2419 elv_unregister(&iosched_cfq);
2420 cfq_slab_kill();
2421}
2422
2423module_init(cfq_init);
2424module_exit(cfq_exit);
2425
2426MODULE_AUTHOR("Jens Axboe");
2427MODULE_LICENSE("GPL");
2428MODULE_DESCRIPTION("Completely Fair Queueing IO scheduler");
diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c
deleted file mode 100644
index 7929471d7df7..000000000000
--- a/drivers/block/deadline-iosched.c
+++ /dev/null
@@ -1,878 +0,0 @@
1/*
2 * linux/drivers/block/deadline-iosched.c
3 *
4 * Deadline i/o scheduler.
5 *
6 * Copyright (C) 2002 Jens Axboe <axboe@suse.de>
7 */
8#include <linux/kernel.h>
9#include <linux/fs.h>
10#include <linux/blkdev.h>
11#include <linux/elevator.h>
12#include <linux/bio.h>
13#include <linux/config.h>
14#include <linux/module.h>
15#include <linux/slab.h>
16#include <linux/init.h>
17#include <linux/compiler.h>
18#include <linux/hash.h>
19#include <linux/rbtree.h>
20
21/*
22 * See Documentation/block/deadline-iosched.txt
23 */
24static int read_expire = HZ / 2; /* max time before a read is submitted. */
25static int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */
26static int writes_starved = 2; /* max times reads can starve a write */
27static int fifo_batch = 16; /* # of sequential requests treated as one
28 by the above parameters. For throughput. */
29
30static const int deadline_hash_shift = 5;
31#define DL_HASH_BLOCK(sec) ((sec) >> 3)
32#define DL_HASH_FN(sec) (hash_long(DL_HASH_BLOCK((sec)), deadline_hash_shift))
33#define DL_HASH_ENTRIES (1 << deadline_hash_shift)
34#define rq_hash_key(rq) ((rq)->sector + (rq)->nr_sectors)
35#define list_entry_hash(ptr) list_entry((ptr), struct deadline_rq, hash)
36#define ON_HASH(drq) (drq)->on_hash
37
38struct deadline_data {
39 /*
40 * run time data
41 */
42
43 /*
44 * requests (deadline_rq s) are present on both sort_list and fifo_list
45 */
46 struct rb_root sort_list[2];
47 struct list_head fifo_list[2];
48
49 /*
50 * next in sort order. read, write or both are NULL
51 */
52 struct deadline_rq *next_drq[2];
53 struct list_head *hash; /* request hash */
54 unsigned int batching; /* number of sequential requests made */
55 sector_t last_sector; /* head position */
56 unsigned int starved; /* times reads have starved writes */
57
58 /*
59 * settings that change how the i/o scheduler behaves
60 */
61 int fifo_expire[2];
62 int fifo_batch;
63 int writes_starved;
64 int front_merges;
65
66 mempool_t *drq_pool;
67};
68
69/*
70 * pre-request data.
71 */
72struct deadline_rq {
73 /*
74 * rbtree index, key is the starting offset
75 */
76 struct rb_node rb_node;
77 sector_t rb_key;
78
79 struct request *request;
80
81 /*
82 * request hash, key is the ending offset (for back merge lookup)
83 */
84 struct list_head hash;
85 char on_hash;
86
87 /*
88 * expire fifo
89 */
90 struct list_head fifo;
91 unsigned long expires;
92};
93
94static void deadline_move_request(struct deadline_data *dd, struct deadline_rq *drq);
95
96static kmem_cache_t *drq_pool;
97
98#define RQ_DATA(rq) ((struct deadline_rq *) (rq)->elevator_private)
99
100/*
101 * the back merge hash support functions
102 */
103static inline void __deadline_del_drq_hash(struct deadline_rq *drq)
104{
105 drq->on_hash = 0;
106 list_del_init(&drq->hash);
107}
108
109static inline void deadline_del_drq_hash(struct deadline_rq *drq)
110{
111 if (ON_HASH(drq))
112 __deadline_del_drq_hash(drq);
113}
114
115static inline void
116deadline_add_drq_hash(struct deadline_data *dd, struct deadline_rq *drq)
117{
118 struct request *rq = drq->request;
119
120 BUG_ON(ON_HASH(drq));
121
122 drq->on_hash = 1;
123 list_add(&drq->hash, &dd->hash[DL_HASH_FN(rq_hash_key(rq))]);
124}
125
126/*
127 * move hot entry to front of chain
128 */
129static inline void
130deadline_hot_drq_hash(struct deadline_data *dd, struct deadline_rq *drq)
131{
132 struct request *rq = drq->request;
133 struct list_head *head = &dd->hash[DL_HASH_FN(rq_hash_key(rq))];
134
135 if (ON_HASH(drq) && drq->hash.prev != head) {
136 list_del(&drq->hash);
137 list_add(&drq->hash, head);
138 }
139}
140
141static struct request *
142deadline_find_drq_hash(struct deadline_data *dd, sector_t offset)
143{
144 struct list_head *hash_list = &dd->hash[DL_HASH_FN(offset)];
145 struct list_head *entry, *next = hash_list->next;
146
147 while ((entry = next) != hash_list) {
148 struct deadline_rq *drq = list_entry_hash(entry);
149 struct request *__rq = drq->request;
150
151 next = entry->next;
152
153 BUG_ON(!ON_HASH(drq));
154
155 if (!rq_mergeable(__rq)) {
156 __deadline_del_drq_hash(drq);
157 continue;
158 }
159
160 if (rq_hash_key(__rq) == offset)
161 return __rq;
162 }
163
164 return NULL;
165}
166
167/*
168 * rb tree support functions
169 */
170#define RB_NONE (2)
171#define RB_EMPTY(root) ((root)->rb_node == NULL)
172#define ON_RB(node) ((node)->rb_color != RB_NONE)
173#define RB_CLEAR(node) ((node)->rb_color = RB_NONE)
174#define rb_entry_drq(node) rb_entry((node), struct deadline_rq, rb_node)
175#define DRQ_RB_ROOT(dd, drq) (&(dd)->sort_list[rq_data_dir((drq)->request)])
176#define rq_rb_key(rq) (rq)->sector
177
178static struct deadline_rq *
179__deadline_add_drq_rb(struct deadline_data *dd, struct deadline_rq *drq)
180{
181 struct rb_node **p = &DRQ_RB_ROOT(dd, drq)->rb_node;
182 struct rb_node *parent = NULL;
183 struct deadline_rq *__drq;
184
185 while (*p) {
186 parent = *p;
187 __drq = rb_entry_drq(parent);
188
189 if (drq->rb_key < __drq->rb_key)
190 p = &(*p)->rb_left;
191 else if (drq->rb_key > __drq->rb_key)
192 p = &(*p)->rb_right;
193 else
194 return __drq;
195 }
196
197 rb_link_node(&drq->rb_node, parent, p);
198 return NULL;
199}
200
201static void
202deadline_add_drq_rb(struct deadline_data *dd, struct deadline_rq *drq)
203{
204 struct deadline_rq *__alias;
205
206 drq->rb_key = rq_rb_key(drq->request);
207
208retry:
209 __alias = __deadline_add_drq_rb(dd, drq);
210 if (!__alias) {
211 rb_insert_color(&drq->rb_node, DRQ_RB_ROOT(dd, drq));
212 return;
213 }
214
215 deadline_move_request(dd, __alias);
216 goto retry;
217}
218
219static inline void
220deadline_del_drq_rb(struct deadline_data *dd, struct deadline_rq *drq)
221{
222 const int data_dir = rq_data_dir(drq->request);
223
224 if (dd->next_drq[data_dir] == drq) {
225 struct rb_node *rbnext = rb_next(&drq->rb_node);
226
227 dd->next_drq[data_dir] = NULL;
228 if (rbnext)
229 dd->next_drq[data_dir] = rb_entry_drq(rbnext);
230 }
231
232 BUG_ON(!ON_RB(&drq->rb_node));
233 rb_erase(&drq->rb_node, DRQ_RB_ROOT(dd, drq));
234 RB_CLEAR(&drq->rb_node);
235}
236
237static struct request *
238deadline_find_drq_rb(struct deadline_data *dd, sector_t sector, int data_dir)
239{
240 struct rb_node *n = dd->sort_list[data_dir].rb_node;
241 struct deadline_rq *drq;
242
243 while (n) {
244 drq = rb_entry_drq(n);
245
246 if (sector < drq->rb_key)
247 n = n->rb_left;
248 else if (sector > drq->rb_key)
249 n = n->rb_right;
250 else
251 return drq->request;
252 }
253
254 return NULL;
255}
256
257/*
258 * deadline_find_first_drq finds the first (lowest sector numbered) request
259 * for the specified data_dir. Used to sweep back to the start of the disk
260 * (1-way elevator) after we process the last (highest sector) request.
261 */
262static struct deadline_rq *
263deadline_find_first_drq(struct deadline_data *dd, int data_dir)
264{
265 struct rb_node *n = dd->sort_list[data_dir].rb_node;
266
267 for (;;) {
268 if (n->rb_left == NULL)
269 return rb_entry_drq(n);
270
271 n = n->rb_left;
272 }
273}
274
275/*
276 * add drq to rbtree and fifo
277 */
278static void
279deadline_add_request(struct request_queue *q, struct request *rq)
280{
281 struct deadline_data *dd = q->elevator->elevator_data;
282 struct deadline_rq *drq = RQ_DATA(rq);
283
284 const int data_dir = rq_data_dir(drq->request);
285
286 deadline_add_drq_rb(dd, drq);
287 /*
288 * set expire time (only used for reads) and add to fifo list
289 */
290 drq->expires = jiffies + dd->fifo_expire[data_dir];
291 list_add_tail(&drq->fifo, &dd->fifo_list[data_dir]);
292
293 if (rq_mergeable(rq))
294 deadline_add_drq_hash(dd, drq);
295}
296
297/*
298 * remove rq from rbtree, fifo, and hash
299 */
300static void deadline_remove_request(request_queue_t *q, struct request *rq)
301{
302 struct deadline_rq *drq = RQ_DATA(rq);
303 struct deadline_data *dd = q->elevator->elevator_data;
304
305 list_del_init(&drq->fifo);
306 deadline_del_drq_rb(dd, drq);
307 deadline_del_drq_hash(drq);
308}
309
310static int
311deadline_merge(request_queue_t *q, struct request **req, struct bio *bio)
312{
313 struct deadline_data *dd = q->elevator->elevator_data;
314 struct request *__rq;
315 int ret;
316
317 /*
318 * see if the merge hash can satisfy a back merge
319 */
320 __rq = deadline_find_drq_hash(dd, bio->bi_sector);
321 if (__rq) {
322 BUG_ON(__rq->sector + __rq->nr_sectors != bio->bi_sector);
323
324 if (elv_rq_merge_ok(__rq, bio)) {
325 ret = ELEVATOR_BACK_MERGE;
326 goto out;
327 }
328 }
329
330 /*
331 * check for front merge
332 */
333 if (dd->front_merges) {
334 sector_t rb_key = bio->bi_sector + bio_sectors(bio);
335
336 __rq = deadline_find_drq_rb(dd, rb_key, bio_data_dir(bio));
337 if (__rq) {
338 BUG_ON(rb_key != rq_rb_key(__rq));
339
340 if (elv_rq_merge_ok(__rq, bio)) {
341 ret = ELEVATOR_FRONT_MERGE;
342 goto out;
343 }
344 }
345 }
346
347 return ELEVATOR_NO_MERGE;
348out:
349 if (ret)
350 deadline_hot_drq_hash(dd, RQ_DATA(__rq));
351 *req = __rq;
352 return ret;
353}
354
355static void deadline_merged_request(request_queue_t *q, struct request *req)
356{
357 struct deadline_data *dd = q->elevator->elevator_data;
358 struct deadline_rq *drq = RQ_DATA(req);
359
360 /*
361 * hash always needs to be repositioned, key is end sector
362 */
363 deadline_del_drq_hash(drq);
364 deadline_add_drq_hash(dd, drq);
365
366 /*
367 * if the merge was a front merge, we need to reposition request
368 */
369 if (rq_rb_key(req) != drq->rb_key) {
370 deadline_del_drq_rb(dd, drq);
371 deadline_add_drq_rb(dd, drq);
372 }
373}
374
375static void
376deadline_merged_requests(request_queue_t *q, struct request *req,
377 struct request *next)
378{
379 struct deadline_data *dd = q->elevator->elevator_data;
380 struct deadline_rq *drq = RQ_DATA(req);
381 struct deadline_rq *dnext = RQ_DATA(next);
382
383 BUG_ON(!drq);
384 BUG_ON(!dnext);
385
386 /*
387 * reposition drq (this is the merged request) in hash, and in rbtree
388 * in case of a front merge
389 */
390 deadline_del_drq_hash(drq);
391 deadline_add_drq_hash(dd, drq);
392
393 if (rq_rb_key(req) != drq->rb_key) {
394 deadline_del_drq_rb(dd, drq);
395 deadline_add_drq_rb(dd, drq);
396 }
397
398 /*
399 * if dnext expires before drq, assign its expire time to drq
400 * and move into dnext position (dnext will be deleted) in fifo
401 */
402 if (!list_empty(&drq->fifo) && !list_empty(&dnext->fifo)) {
403 if (time_before(dnext->expires, drq->expires)) {
404 list_move(&drq->fifo, &dnext->fifo);
405 drq->expires = dnext->expires;
406 }
407 }
408
409 /*
410 * kill knowledge of next, this one is a goner
411 */
412 deadline_remove_request(q, next);
413}
414
415/*
416 * move request from sort list to dispatch queue.
417 */
418static inline void
419deadline_move_to_dispatch(struct deadline_data *dd, struct deadline_rq *drq)
420{
421 request_queue_t *q = drq->request->q;
422
423 deadline_remove_request(q, drq->request);
424 elv_dispatch_add_tail(q, drq->request);
425}
426
427/*
428 * move an entry to dispatch queue
429 */
430static void
431deadline_move_request(struct deadline_data *dd, struct deadline_rq *drq)
432{
433 const int data_dir = rq_data_dir(drq->request);
434 struct rb_node *rbnext = rb_next(&drq->rb_node);
435
436 dd->next_drq[READ] = NULL;
437 dd->next_drq[WRITE] = NULL;
438
439 if (rbnext)
440 dd->next_drq[data_dir] = rb_entry_drq(rbnext);
441
442 dd->last_sector = drq->request->sector + drq->request->nr_sectors;
443
444 /*
445 * take it off the sort and fifo list, move
446 * to dispatch queue
447 */
448 deadline_move_to_dispatch(dd, drq);
449}
450
451#define list_entry_fifo(ptr) list_entry((ptr), struct deadline_rq, fifo)
452
453/*
454 * deadline_check_fifo returns 0 if there are no expired reads on the fifo,
455 * 1 otherwise. Requires !list_empty(&dd->fifo_list[data_dir])
456 */
457static inline int deadline_check_fifo(struct deadline_data *dd, int ddir)
458{
459 struct deadline_rq *drq = list_entry_fifo(dd->fifo_list[ddir].next);
460
461 /*
462 * drq is expired!
463 */
464 if (time_after(jiffies, drq->expires))
465 return 1;
466
467 return 0;
468}
469
470/*
471 * deadline_dispatch_requests selects the best request according to
472 * read/write expire, fifo_batch, etc
473 */
474static int deadline_dispatch_requests(request_queue_t *q, int force)
475{
476 struct deadline_data *dd = q->elevator->elevator_data;
477 const int reads = !list_empty(&dd->fifo_list[READ]);
478 const int writes = !list_empty(&dd->fifo_list[WRITE]);
479 struct deadline_rq *drq;
480 int data_dir;
481
482 /*
483 * batches are currently reads XOR writes
484 */
485 if (dd->next_drq[WRITE])
486 drq = dd->next_drq[WRITE];
487 else
488 drq = dd->next_drq[READ];
489
490 if (drq) {
491 /* we have a "next request" */
492
493 if (dd->last_sector != drq->request->sector)
494 /* end the batch on a non sequential request */
495 dd->batching += dd->fifo_batch;
496
497 if (dd->batching < dd->fifo_batch)
498 /* we are still entitled to batch */
499 goto dispatch_request;
500 }
501
502 /*
503 * at this point we are not running a batch. select the appropriate
504 * data direction (read / write)
505 */
506
507 if (reads) {
508 BUG_ON(RB_EMPTY(&dd->sort_list[READ]));
509
510 if (writes && (dd->starved++ >= dd->writes_starved))
511 goto dispatch_writes;
512
513 data_dir = READ;
514
515 goto dispatch_find_request;
516 }
517
518 /*
519 * there are either no reads or writes have been starved
520 */
521
522 if (writes) {
523dispatch_writes:
524 BUG_ON(RB_EMPTY(&dd->sort_list[WRITE]));
525
526 dd->starved = 0;
527
528 data_dir = WRITE;
529
530 goto dispatch_find_request;
531 }
532
533 return 0;
534
535dispatch_find_request:
536 /*
537 * we are not running a batch, find best request for selected data_dir
538 */
539 if (deadline_check_fifo(dd, data_dir)) {
540 /* An expired request exists - satisfy it */
541 dd->batching = 0;
542 drq = list_entry_fifo(dd->fifo_list[data_dir].next);
543
544 } else if (dd->next_drq[data_dir]) {
545 /*
546 * The last req was the same dir and we have a next request in
547 * sort order. No expired requests so continue on from here.
548 */
549 drq = dd->next_drq[data_dir];
550 } else {
551 /*
552 * The last req was the other direction or we have run out of
553 * higher-sectored requests. Go back to the lowest sectored
554 * request (1 way elevator) and start a new batch.
555 */
556 dd->batching = 0;
557 drq = deadline_find_first_drq(dd, data_dir);
558 }
559
560dispatch_request:
561 /*
562 * drq is the selected appropriate request.
563 */
564 dd->batching++;
565 deadline_move_request(dd, drq);
566
567 return 1;
568}
569
570static int deadline_queue_empty(request_queue_t *q)
571{
572 struct deadline_data *dd = q->elevator->elevator_data;
573
574 return list_empty(&dd->fifo_list[WRITE])
575 && list_empty(&dd->fifo_list[READ]);
576}
577
578static struct request *
579deadline_former_request(request_queue_t *q, struct request *rq)
580{
581 struct deadline_rq *drq = RQ_DATA(rq);
582 struct rb_node *rbprev = rb_prev(&drq->rb_node);
583
584 if (rbprev)
585 return rb_entry_drq(rbprev)->request;
586
587 return NULL;
588}
589
590static struct request *
591deadline_latter_request(request_queue_t *q, struct request *rq)
592{
593 struct deadline_rq *drq = RQ_DATA(rq);
594 struct rb_node *rbnext = rb_next(&drq->rb_node);
595
596 if (rbnext)
597 return rb_entry_drq(rbnext)->request;
598
599 return NULL;
600}
601
602static void deadline_exit_queue(elevator_t *e)
603{
604 struct deadline_data *dd = e->elevator_data;
605
606 BUG_ON(!list_empty(&dd->fifo_list[READ]));
607 BUG_ON(!list_empty(&dd->fifo_list[WRITE]));
608
609 mempool_destroy(dd->drq_pool);
610 kfree(dd->hash);
611 kfree(dd);
612}
613
614/*
615 * initialize elevator private data (deadline_data), and alloc a drq for
616 * each request on the free lists
617 */
618static int deadline_init_queue(request_queue_t *q, elevator_t *e)
619{
620 struct deadline_data *dd;
621 int i;
622
623 if (!drq_pool)
624 return -ENOMEM;
625
626 dd = kmalloc_node(sizeof(*dd), GFP_KERNEL, q->node);
627 if (!dd)
628 return -ENOMEM;
629 memset(dd, 0, sizeof(*dd));
630
631 dd->hash = kmalloc_node(sizeof(struct list_head)*DL_HASH_ENTRIES,
632 GFP_KERNEL, q->node);
633 if (!dd->hash) {
634 kfree(dd);
635 return -ENOMEM;
636 }
637
638 dd->drq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
639 mempool_free_slab, drq_pool, q->node);
640 if (!dd->drq_pool) {
641 kfree(dd->hash);
642 kfree(dd);
643 return -ENOMEM;
644 }
645
646 for (i = 0; i < DL_HASH_ENTRIES; i++)
647 INIT_LIST_HEAD(&dd->hash[i]);
648
649 INIT_LIST_HEAD(&dd->fifo_list[READ]);
650 INIT_LIST_HEAD(&dd->fifo_list[WRITE]);
651 dd->sort_list[READ] = RB_ROOT;
652 dd->sort_list[WRITE] = RB_ROOT;
653 dd->fifo_expire[READ] = read_expire;
654 dd->fifo_expire[WRITE] = write_expire;
655 dd->writes_starved = writes_starved;
656 dd->front_merges = 1;
657 dd->fifo_batch = fifo_batch;
658 e->elevator_data = dd;
659 return 0;
660}
661
662static void deadline_put_request(request_queue_t *q, struct request *rq)
663{
664 struct deadline_data *dd = q->elevator->elevator_data;
665 struct deadline_rq *drq = RQ_DATA(rq);
666
667 mempool_free(drq, dd->drq_pool);
668 rq->elevator_private = NULL;
669}
670
671static int
672deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
673 gfp_t gfp_mask)
674{
675 struct deadline_data *dd = q->elevator->elevator_data;
676 struct deadline_rq *drq;
677
678 drq = mempool_alloc(dd->drq_pool, gfp_mask);
679 if (drq) {
680 memset(drq, 0, sizeof(*drq));
681 RB_CLEAR(&drq->rb_node);
682 drq->request = rq;
683
684 INIT_LIST_HEAD(&drq->hash);
685 drq->on_hash = 0;
686
687 INIT_LIST_HEAD(&drq->fifo);
688
689 rq->elevator_private = drq;
690 return 0;
691 }
692
693 return 1;
694}
695
696/*
697 * sysfs parts below
698 */
699struct deadline_fs_entry {
700 struct attribute attr;
701 ssize_t (*show)(struct deadline_data *, char *);
702 ssize_t (*store)(struct deadline_data *, const char *, size_t);
703};
704
705static ssize_t
706deadline_var_show(int var, char *page)
707{
708 return sprintf(page, "%d\n", var);
709}
710
711static ssize_t
712deadline_var_store(int *var, const char *page, size_t count)
713{
714 char *p = (char *) page;
715
716 *var = simple_strtol(p, &p, 10);
717 return count;
718}
719
720#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
721static ssize_t __FUNC(struct deadline_data *dd, char *page) \
722{ \
723 int __data = __VAR; \
724 if (__CONV) \
725 __data = jiffies_to_msecs(__data); \
726 return deadline_var_show(__data, (page)); \
727}
728SHOW_FUNCTION(deadline_readexpire_show, dd->fifo_expire[READ], 1);
729SHOW_FUNCTION(deadline_writeexpire_show, dd->fifo_expire[WRITE], 1);
730SHOW_FUNCTION(deadline_writesstarved_show, dd->writes_starved, 0);
731SHOW_FUNCTION(deadline_frontmerges_show, dd->front_merges, 0);
732SHOW_FUNCTION(deadline_fifobatch_show, dd->fifo_batch, 0);
733#undef SHOW_FUNCTION
734
735#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
736static ssize_t __FUNC(struct deadline_data *dd, const char *page, size_t count) \
737{ \
738 int __data; \
739 int ret = deadline_var_store(&__data, (page), count); \
740 if (__data < (MIN)) \
741 __data = (MIN); \
742 else if (__data > (MAX)) \
743 __data = (MAX); \
744 if (__CONV) \
745 *(__PTR) = msecs_to_jiffies(__data); \
746 else \
747 *(__PTR) = __data; \
748 return ret; \
749}
750STORE_FUNCTION(deadline_readexpire_store, &dd->fifo_expire[READ], 0, INT_MAX, 1);
751STORE_FUNCTION(deadline_writeexpire_store, &dd->fifo_expire[WRITE], 0, INT_MAX, 1);
752STORE_FUNCTION(deadline_writesstarved_store, &dd->writes_starved, INT_MIN, INT_MAX, 0);
753STORE_FUNCTION(deadline_frontmerges_store, &dd->front_merges, 0, 1, 0);
754STORE_FUNCTION(deadline_fifobatch_store, &dd->fifo_batch, 0, INT_MAX, 0);
755#undef STORE_FUNCTION
756
757static struct deadline_fs_entry deadline_readexpire_entry = {
758 .attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR },
759 .show = deadline_readexpire_show,
760 .store = deadline_readexpire_store,
761};
762static struct deadline_fs_entry deadline_writeexpire_entry = {
763 .attr = {.name = "write_expire", .mode = S_IRUGO | S_IWUSR },
764 .show = deadline_writeexpire_show,
765 .store = deadline_writeexpire_store,
766};
767static struct deadline_fs_entry deadline_writesstarved_entry = {
768 .attr = {.name = "writes_starved", .mode = S_IRUGO | S_IWUSR },
769 .show = deadline_writesstarved_show,
770 .store = deadline_writesstarved_store,
771};
772static struct deadline_fs_entry deadline_frontmerges_entry = {
773 .attr = {.name = "front_merges", .mode = S_IRUGO | S_IWUSR },
774 .show = deadline_frontmerges_show,
775 .store = deadline_frontmerges_store,
776};
777static struct deadline_fs_entry deadline_fifobatch_entry = {
778 .attr = {.name = "fifo_batch", .mode = S_IRUGO | S_IWUSR },
779 .show = deadline_fifobatch_show,
780 .store = deadline_fifobatch_store,
781};
782
783static struct attribute *default_attrs[] = {
784 &deadline_readexpire_entry.attr,
785 &deadline_writeexpire_entry.attr,
786 &deadline_writesstarved_entry.attr,
787 &deadline_frontmerges_entry.attr,
788 &deadline_fifobatch_entry.attr,
789 NULL,
790};
791
792#define to_deadline(atr) container_of((atr), struct deadline_fs_entry, attr)
793
794static ssize_t
795deadline_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
796{
797 elevator_t *e = container_of(kobj, elevator_t, kobj);
798 struct deadline_fs_entry *entry = to_deadline(attr);
799
800 if (!entry->show)
801 return -EIO;
802
803 return entry->show(e->elevator_data, page);
804}
805
806static ssize_t
807deadline_attr_store(struct kobject *kobj, struct attribute *attr,
808 const char *page, size_t length)
809{
810 elevator_t *e = container_of(kobj, elevator_t, kobj);
811 struct deadline_fs_entry *entry = to_deadline(attr);
812
813 if (!entry->store)
814 return -EIO;
815
816 return entry->store(e->elevator_data, page, length);
817}
818
819static struct sysfs_ops deadline_sysfs_ops = {
820 .show = deadline_attr_show,
821 .store = deadline_attr_store,
822};
823
824static struct kobj_type deadline_ktype = {
825 .sysfs_ops = &deadline_sysfs_ops,
826 .default_attrs = default_attrs,
827};
828
829static struct elevator_type iosched_deadline = {
830 .ops = {
831 .elevator_merge_fn = deadline_merge,
832 .elevator_merged_fn = deadline_merged_request,
833 .elevator_merge_req_fn = deadline_merged_requests,
834 .elevator_dispatch_fn = deadline_dispatch_requests,
835 .elevator_add_req_fn = deadline_add_request,
836 .elevator_queue_empty_fn = deadline_queue_empty,
837 .elevator_former_req_fn = deadline_former_request,
838 .elevator_latter_req_fn = deadline_latter_request,
839 .elevator_set_req_fn = deadline_set_request,
840 .elevator_put_req_fn = deadline_put_request,
841 .elevator_init_fn = deadline_init_queue,
842 .elevator_exit_fn = deadline_exit_queue,
843 },
844
845 .elevator_ktype = &deadline_ktype,
846 .elevator_name = "deadline",
847 .elevator_owner = THIS_MODULE,
848};
849
850static int __init deadline_init(void)
851{
852 int ret;
853
854 drq_pool = kmem_cache_create("deadline_drq", sizeof(struct deadline_rq),
855 0, 0, NULL, NULL);
856
857 if (!drq_pool)
858 return -ENOMEM;
859
860 ret = elv_register(&iosched_deadline);
861 if (ret)
862 kmem_cache_destroy(drq_pool);
863
864 return ret;
865}
866
867static void __exit deadline_exit(void)
868{
869 kmem_cache_destroy(drq_pool);
870 elv_unregister(&iosched_deadline);
871}
872
873module_init(deadline_init);
874module_exit(deadline_exit);
875
876MODULE_AUTHOR("Jens Axboe");
877MODULE_LICENSE("GPL");
878MODULE_DESCRIPTION("deadline IO scheduler");
diff --git a/drivers/block/elevator.c b/drivers/block/elevator.c
deleted file mode 100644
index d4a49a3df829..000000000000
--- a/drivers/block/elevator.c
+++ /dev/null
@@ -1,802 +0,0 @@
1/*
2 * linux/drivers/block/elevator.c
3 *
4 * Block device elevator/IO-scheduler.
5 *
6 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
7 *
8 * 30042000 Jens Axboe <axboe@suse.de> :
9 *
10 * Split the elevator a bit so that it is possible to choose a different
11 * one or even write a new "plug in". There are three pieces:
12 * - elevator_fn, inserts a new request in the queue list
13 * - elevator_merge_fn, decides whether a new buffer can be merged with
14 * an existing request
15 * - elevator_dequeue_fn, called when a request is taken off the active list
16 *
17 * 20082000 Dave Jones <davej@suse.de> :
18 * Removed tests for max-bomb-segments, which was breaking elvtune
19 * when run without -bN
20 *
21 * Jens:
22 * - Rework again to work with bio instead of buffer_heads
23 * - loose bi_dev comparisons, partition handling is right now
24 * - completely modularize elevator setup and teardown
25 *
26 */
27#include <linux/kernel.h>
28#include <linux/fs.h>
29#include <linux/blkdev.h>
30#include <linux/elevator.h>
31#include <linux/bio.h>
32#include <linux/config.h>
33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/init.h>
36#include <linux/compiler.h>
37#include <linux/delay.h>
38
39#include <asm/uaccess.h>
40
41static DEFINE_SPINLOCK(elv_list_lock);
42static LIST_HEAD(elv_list);
43
44/*
45 * can we safely merge with this request?
46 */
47inline int elv_rq_merge_ok(struct request *rq, struct bio *bio)
48{
49 if (!rq_mergeable(rq))
50 return 0;
51
52 /*
53 * different data direction or already started, don't merge
54 */
55 if (bio_data_dir(bio) != rq_data_dir(rq))
56 return 0;
57
58 /*
59 * same device and no special stuff set, merge is ok
60 */
61 if (rq->rq_disk == bio->bi_bdev->bd_disk &&
62 !rq->waiting && !rq->special)
63 return 1;
64
65 return 0;
66}
67EXPORT_SYMBOL(elv_rq_merge_ok);
68
69inline int elv_try_merge(struct request *__rq, struct bio *bio)
70{
71 int ret = ELEVATOR_NO_MERGE;
72
73 /*
74 * we can merge and sequence is ok, check if it's possible
75 */
76 if (elv_rq_merge_ok(__rq, bio)) {
77 if (__rq->sector + __rq->nr_sectors == bio->bi_sector)
78 ret = ELEVATOR_BACK_MERGE;
79 else if (__rq->sector - bio_sectors(bio) == bio->bi_sector)
80 ret = ELEVATOR_FRONT_MERGE;
81 }
82
83 return ret;
84}
85EXPORT_SYMBOL(elv_try_merge);
86
87static struct elevator_type *elevator_find(const char *name)
88{
89 struct elevator_type *e = NULL;
90 struct list_head *entry;
91
92 list_for_each(entry, &elv_list) {
93 struct elevator_type *__e;
94
95 __e = list_entry(entry, struct elevator_type, list);
96
97 if (!strcmp(__e->elevator_name, name)) {
98 e = __e;
99 break;
100 }
101 }
102
103 return e;
104}
105
106static void elevator_put(struct elevator_type *e)
107{
108 module_put(e->elevator_owner);
109}
110
111static struct elevator_type *elevator_get(const char *name)
112{
113 struct elevator_type *e;
114
115 spin_lock_irq(&elv_list_lock);
116
117 e = elevator_find(name);
118 if (e && !try_module_get(e->elevator_owner))
119 e = NULL;
120
121 spin_unlock_irq(&elv_list_lock);
122
123 return e;
124}
125
126static int elevator_attach(request_queue_t *q, struct elevator_type *e,
127 struct elevator_queue *eq)
128{
129 int ret = 0;
130
131 memset(eq, 0, sizeof(*eq));
132 eq->ops = &e->ops;
133 eq->elevator_type = e;
134
135 q->elevator = eq;
136
137 if (eq->ops->elevator_init_fn)
138 ret = eq->ops->elevator_init_fn(q, eq);
139
140 return ret;
141}
142
143static char chosen_elevator[16];
144
145static void elevator_setup_default(void)
146{
147 struct elevator_type *e;
148
149 /*
150 * If default has not been set, use the compiled-in selection.
151 */
152 if (!chosen_elevator[0])
153 strcpy(chosen_elevator, CONFIG_DEFAULT_IOSCHED);
154
155 /*
156 * If the given scheduler is not available, fall back to no-op.
157 */
158 if (!(e = elevator_find(chosen_elevator)))
159 strcpy(chosen_elevator, "noop");
160 elevator_put(e);
161}
162
163static int __init elevator_setup(char *str)
164{
165 strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
166 return 0;
167}
168
169__setup("elevator=", elevator_setup);
170
171int elevator_init(request_queue_t *q, char *name)
172{
173 struct elevator_type *e = NULL;
174 struct elevator_queue *eq;
175 int ret = 0;
176
177 INIT_LIST_HEAD(&q->queue_head);
178 q->last_merge = NULL;
179 q->end_sector = 0;
180 q->boundary_rq = NULL;
181
182 elevator_setup_default();
183
184 if (!name)
185 name = chosen_elevator;
186
187 e = elevator_get(name);
188 if (!e)
189 return -EINVAL;
190
191 eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL);
192 if (!eq) {
193 elevator_put(e->elevator_type);
194 return -ENOMEM;
195 }
196
197 ret = elevator_attach(q, e, eq);
198 if (ret) {
199 kfree(eq);
200 elevator_put(e->elevator_type);
201 }
202
203 return ret;
204}
205
206void elevator_exit(elevator_t *e)
207{
208 if (e->ops->elevator_exit_fn)
209 e->ops->elevator_exit_fn(e);
210
211 elevator_put(e->elevator_type);
212 e->elevator_type = NULL;
213 kfree(e);
214}
215
216/*
217 * Insert rq into dispatch queue of q. Queue lock must be held on
218 * entry. If sort != 0, rq is sort-inserted; otherwise, rq will be
219 * appended to the dispatch queue. To be used by specific elevators.
220 */
221void elv_dispatch_sort(request_queue_t *q, struct request *rq)
222{
223 sector_t boundary;
224 struct list_head *entry;
225
226 if (q->last_merge == rq)
227 q->last_merge = NULL;
228
229 boundary = q->end_sector;
230
231 list_for_each_prev(entry, &q->queue_head) {
232 struct request *pos = list_entry_rq(entry);
233
234 if (pos->flags & (REQ_SOFTBARRIER|REQ_HARDBARRIER|REQ_STARTED))
235 break;
236 if (rq->sector >= boundary) {
237 if (pos->sector < boundary)
238 continue;
239 } else {
240 if (pos->sector >= boundary)
241 break;
242 }
243 if (rq->sector >= pos->sector)
244 break;
245 }
246
247 list_add(&rq->queuelist, entry);
248}
249
250int elv_merge(request_queue_t *q, struct request **req, struct bio *bio)
251{
252 elevator_t *e = q->elevator;
253 int ret;
254
255 if (q->last_merge) {
256 ret = elv_try_merge(q->last_merge, bio);
257 if (ret != ELEVATOR_NO_MERGE) {
258 *req = q->last_merge;
259 return ret;
260 }
261 }
262
263 if (e->ops->elevator_merge_fn)
264 return e->ops->elevator_merge_fn(q, req, bio);
265
266 return ELEVATOR_NO_MERGE;
267}
268
269void elv_merged_request(request_queue_t *q, struct request *rq)
270{
271 elevator_t *e = q->elevator;
272
273 if (e->ops->elevator_merged_fn)
274 e->ops->elevator_merged_fn(q, rq);
275
276 q->last_merge = rq;
277}
278
279void elv_merge_requests(request_queue_t *q, struct request *rq,
280 struct request *next)
281{
282 elevator_t *e = q->elevator;
283
284 if (e->ops->elevator_merge_req_fn)
285 e->ops->elevator_merge_req_fn(q, rq, next);
286
287 q->last_merge = rq;
288}
289
290void elv_requeue_request(request_queue_t *q, struct request *rq)
291{
292 elevator_t *e = q->elevator;
293
294 /*
295 * it already went through dequeue, we need to decrement the
296 * in_flight count again
297 */
298 if (blk_account_rq(rq)) {
299 q->in_flight--;
300 if (blk_sorted_rq(rq) && e->ops->elevator_deactivate_req_fn)
301 e->ops->elevator_deactivate_req_fn(q, rq);
302 }
303
304 rq->flags &= ~REQ_STARTED;
305
306 /*
307 * if this is the flush, requeue the original instead and drop the flush
308 */
309 if (rq->flags & REQ_BAR_FLUSH) {
310 clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags);
311 rq = rq->end_io_data;
312 }
313
314 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
315}
316
317void __elv_add_request(request_queue_t *q, struct request *rq, int where,
318 int plug)
319{
320 if (rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)) {
321 /*
322 * barriers implicitly indicate back insertion
323 */
324 if (where == ELEVATOR_INSERT_SORT)
325 where = ELEVATOR_INSERT_BACK;
326
327 /*
328 * this request is scheduling boundary, update end_sector
329 */
330 if (blk_fs_request(rq)) {
331 q->end_sector = rq_end_sector(rq);
332 q->boundary_rq = rq;
333 }
334 } else if (!(rq->flags & REQ_ELVPRIV) && where == ELEVATOR_INSERT_SORT)
335 where = ELEVATOR_INSERT_BACK;
336
337 if (plug)
338 blk_plug_device(q);
339
340 rq->q = q;
341
342 switch (where) {
343 case ELEVATOR_INSERT_FRONT:
344 rq->flags |= REQ_SOFTBARRIER;
345
346 list_add(&rq->queuelist, &q->queue_head);
347 break;
348
349 case ELEVATOR_INSERT_BACK:
350 rq->flags |= REQ_SOFTBARRIER;
351
352 while (q->elevator->ops->elevator_dispatch_fn(q, 1))
353 ;
354 list_add_tail(&rq->queuelist, &q->queue_head);
355 /*
356 * We kick the queue here for the following reasons.
357 * - The elevator might have returned NULL previously
358 * to delay requests and returned them now. As the
359 * queue wasn't empty before this request, ll_rw_blk
360 * won't run the queue on return, resulting in hang.
361 * - Usually, back inserted requests won't be merged
362 * with anything. There's no point in delaying queue
363 * processing.
364 */
365 blk_remove_plug(q);
366 q->request_fn(q);
367 break;
368
369 case ELEVATOR_INSERT_SORT:
370 BUG_ON(!blk_fs_request(rq));
371 rq->flags |= REQ_SORTED;
372 if (q->last_merge == NULL && rq_mergeable(rq))
373 q->last_merge = rq;
374 /*
375 * Some ioscheds (cfq) run q->request_fn directly, so
376 * rq cannot be accessed after calling
377 * elevator_add_req_fn.
378 */
379 q->elevator->ops->elevator_add_req_fn(q, rq);
380 break;
381
382 default:
383 printk(KERN_ERR "%s: bad insertion point %d\n",
384 __FUNCTION__, where);
385 BUG();
386 }
387
388 if (blk_queue_plugged(q)) {
389 int nrq = q->rq.count[READ] + q->rq.count[WRITE]
390 - q->in_flight;
391
392 if (nrq >= q->unplug_thresh)
393 __generic_unplug_device(q);
394 }
395}
396
397void elv_add_request(request_queue_t *q, struct request *rq, int where,
398 int plug)
399{
400 unsigned long flags;
401
402 spin_lock_irqsave(q->queue_lock, flags);
403 __elv_add_request(q, rq, where, plug);
404 spin_unlock_irqrestore(q->queue_lock, flags);
405}
406
407static inline struct request *__elv_next_request(request_queue_t *q)
408{
409 struct request *rq;
410
411 if (unlikely(list_empty(&q->queue_head) &&
412 !q->elevator->ops->elevator_dispatch_fn(q, 0)))
413 return NULL;
414
415 rq = list_entry_rq(q->queue_head.next);
416
417 /*
418 * if this is a barrier write and the device has to issue a
419 * flush sequence to support it, check how far we are
420 */
421 if (blk_fs_request(rq) && blk_barrier_rq(rq)) {
422 BUG_ON(q->ordered == QUEUE_ORDERED_NONE);
423
424 if (q->ordered == QUEUE_ORDERED_FLUSH &&
425 !blk_barrier_preflush(rq))
426 rq = blk_start_pre_flush(q, rq);
427 }
428
429 return rq;
430}
431
432struct request *elv_next_request(request_queue_t *q)
433{
434 struct request *rq;
435 int ret;
436
437 while ((rq = __elv_next_request(q)) != NULL) {
438 if (!(rq->flags & REQ_STARTED)) {
439 elevator_t *e = q->elevator;
440
441 /*
442 * This is the first time the device driver
443 * sees this request (possibly after
444 * requeueing). Notify IO scheduler.
445 */
446 if (blk_sorted_rq(rq) &&
447 e->ops->elevator_activate_req_fn)
448 e->ops->elevator_activate_req_fn(q, rq);
449
450 /*
451 * just mark as started even if we don't start
452 * it, a request that has been delayed should
453 * not be passed by new incoming requests
454 */
455 rq->flags |= REQ_STARTED;
456 }
457
458 if (!q->boundary_rq || q->boundary_rq == rq) {
459 q->end_sector = rq_end_sector(rq);
460 q->boundary_rq = NULL;
461 }
462
463 if ((rq->flags & REQ_DONTPREP) || !q->prep_rq_fn)
464 break;
465
466 ret = q->prep_rq_fn(q, rq);
467 if (ret == BLKPREP_OK) {
468 break;
469 } else if (ret == BLKPREP_DEFER) {
470 /*
471 * the request may have been (partially) prepped.
472 * we need to keep this request in the front to
473 * avoid resource deadlock. REQ_STARTED will
474 * prevent other fs requests from passing this one.
475 */
476 rq = NULL;
477 break;
478 } else if (ret == BLKPREP_KILL) {
479 int nr_bytes = rq->hard_nr_sectors << 9;
480
481 if (!nr_bytes)
482 nr_bytes = rq->data_len;
483
484 blkdev_dequeue_request(rq);
485 rq->flags |= REQ_QUIET;
486 end_that_request_chunk(rq, 0, nr_bytes);
487 end_that_request_last(rq);
488 } else {
489 printk(KERN_ERR "%s: bad return=%d\n", __FUNCTION__,
490 ret);
491 break;
492 }
493 }
494
495 return rq;
496}
497
498void elv_dequeue_request(request_queue_t *q, struct request *rq)
499{
500 BUG_ON(list_empty(&rq->queuelist));
501
502 list_del_init(&rq->queuelist);
503
504 /*
505 * the time frame between a request being removed from the lists
506 * and to it is freed is accounted as io that is in progress at
507 * the driver side.
508 */
509 if (blk_account_rq(rq))
510 q->in_flight++;
511}
512
513int elv_queue_empty(request_queue_t *q)
514{
515 elevator_t *e = q->elevator;
516
517 if (!list_empty(&q->queue_head))
518 return 0;
519
520 if (e->ops->elevator_queue_empty_fn)
521 return e->ops->elevator_queue_empty_fn(q);
522
523 return 1;
524}
525
526struct request *elv_latter_request(request_queue_t *q, struct request *rq)
527{
528 struct list_head *next;
529
530 elevator_t *e = q->elevator;
531
532 if (e->ops->elevator_latter_req_fn)
533 return e->ops->elevator_latter_req_fn(q, rq);
534
535 next = rq->queuelist.next;
536 if (next != &q->queue_head && next != &rq->queuelist)
537 return list_entry_rq(next);
538
539 return NULL;
540}
541
542struct request *elv_former_request(request_queue_t *q, struct request *rq)
543{
544 struct list_head *prev;
545
546 elevator_t *e = q->elevator;
547
548 if (e->ops->elevator_former_req_fn)
549 return e->ops->elevator_former_req_fn(q, rq);
550
551 prev = rq->queuelist.prev;
552 if (prev != &q->queue_head && prev != &rq->queuelist)
553 return list_entry_rq(prev);
554
555 return NULL;
556}
557
558int elv_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
559 gfp_t gfp_mask)
560{
561 elevator_t *e = q->elevator;
562
563 if (e->ops->elevator_set_req_fn)
564 return e->ops->elevator_set_req_fn(q, rq, bio, gfp_mask);
565
566 rq->elevator_private = NULL;
567 return 0;
568}
569
570void elv_put_request(request_queue_t *q, struct request *rq)
571{
572 elevator_t *e = q->elevator;
573
574 if (e->ops->elevator_put_req_fn)
575 e->ops->elevator_put_req_fn(q, rq);
576}
577
578int elv_may_queue(request_queue_t *q, int rw, struct bio *bio)
579{
580 elevator_t *e = q->elevator;
581
582 if (e->ops->elevator_may_queue_fn)
583 return e->ops->elevator_may_queue_fn(q, rw, bio);
584
585 return ELV_MQUEUE_MAY;
586}
587
588void elv_completed_request(request_queue_t *q, struct request *rq)
589{
590 elevator_t *e = q->elevator;
591
592 /*
593 * request is released from the driver, io must be done
594 */
595 if (blk_account_rq(rq)) {
596 q->in_flight--;
597 if (blk_sorted_rq(rq) && e->ops->elevator_completed_req_fn)
598 e->ops->elevator_completed_req_fn(q, rq);
599 }
600}
601
602int elv_register_queue(struct request_queue *q)
603{
604 elevator_t *e = q->elevator;
605
606 e->kobj.parent = kobject_get(&q->kobj);
607 if (!e->kobj.parent)
608 return -EBUSY;
609
610 snprintf(e->kobj.name, KOBJ_NAME_LEN, "%s", "iosched");
611 e->kobj.ktype = e->elevator_type->elevator_ktype;
612
613 return kobject_register(&e->kobj);
614}
615
616void elv_unregister_queue(struct request_queue *q)
617{
618 if (q) {
619 elevator_t *e = q->elevator;
620 kobject_unregister(&e->kobj);
621 kobject_put(&q->kobj);
622 }
623}
624
625int elv_register(struct elevator_type *e)
626{
627 spin_lock_irq(&elv_list_lock);
628 if (elevator_find(e->elevator_name))
629 BUG();
630 list_add_tail(&e->list, &elv_list);
631 spin_unlock_irq(&elv_list_lock);
632
633 printk(KERN_INFO "io scheduler %s registered", e->elevator_name);
634 if (!strcmp(e->elevator_name, chosen_elevator))
635 printk(" (default)");
636 printk("\n");
637 return 0;
638}
639EXPORT_SYMBOL_GPL(elv_register);
640
641void elv_unregister(struct elevator_type *e)
642{
643 struct task_struct *g, *p;
644
645 /*
646 * Iterate every thread in the process to remove the io contexts.
647 */
648 read_lock(&tasklist_lock);
649 do_each_thread(g, p) {
650 struct io_context *ioc = p->io_context;
651 if (ioc && ioc->cic) {
652 ioc->cic->exit(ioc->cic);
653 ioc->cic->dtor(ioc->cic);
654 ioc->cic = NULL;
655 }
656 if (ioc && ioc->aic) {
657 ioc->aic->exit(ioc->aic);
658 ioc->aic->dtor(ioc->aic);
659 ioc->aic = NULL;
660 }
661 } while_each_thread(g, p);
662 read_unlock(&tasklist_lock);
663
664 spin_lock_irq(&elv_list_lock);
665 list_del_init(&e->list);
666 spin_unlock_irq(&elv_list_lock);
667}
668EXPORT_SYMBOL_GPL(elv_unregister);
669
670/*
671 * switch to new_e io scheduler. be careful not to introduce deadlocks -
672 * we don't free the old io scheduler, before we have allocated what we
673 * need for the new one. this way we have a chance of going back to the old
674 * one, if the new one fails init for some reason.
675 */
676static void elevator_switch(request_queue_t *q, struct elevator_type *new_e)
677{
678 elevator_t *old_elevator, *e;
679
680 /*
681 * Allocate new elevator
682 */
683 e = kmalloc(sizeof(elevator_t), GFP_KERNEL);
684 if (!e)
685 goto error;
686
687 /*
688 * Turn on BYPASS and drain all requests w/ elevator private data
689 */
690 spin_lock_irq(q->queue_lock);
691
692 set_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
693
694 while (q->elevator->ops->elevator_dispatch_fn(q, 1))
695 ;
696
697 while (q->rq.elvpriv) {
698 spin_unlock_irq(q->queue_lock);
699 msleep(10);
700 spin_lock_irq(q->queue_lock);
701 }
702
703 spin_unlock_irq(q->queue_lock);
704
705 /*
706 * unregister old elevator data
707 */
708 elv_unregister_queue(q);
709 old_elevator = q->elevator;
710
711 /*
712 * attach and start new elevator
713 */
714 if (elevator_attach(q, new_e, e))
715 goto fail;
716
717 if (elv_register_queue(q))
718 goto fail_register;
719
720 /*
721 * finally exit old elevator and turn off BYPASS.
722 */
723 elevator_exit(old_elevator);
724 clear_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
725 return;
726
727fail_register:
728 /*
729 * switch failed, exit the new io scheduler and reattach the old
730 * one again (along with re-adding the sysfs dir)
731 */
732 elevator_exit(e);
733 e = NULL;
734fail:
735 q->elevator = old_elevator;
736 elv_register_queue(q);
737 clear_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
738 kfree(e);
739error:
740 elevator_put(new_e);
741 printk(KERN_ERR "elevator: switch to %s failed\n",new_e->elevator_name);
742}
743
744ssize_t elv_iosched_store(request_queue_t *q, const char *name, size_t count)
745{
746 char elevator_name[ELV_NAME_MAX];
747 struct elevator_type *e;
748
749 memset(elevator_name, 0, sizeof(elevator_name));
750 strncpy(elevator_name, name, sizeof(elevator_name));
751
752 if (elevator_name[strlen(elevator_name) - 1] == '\n')
753 elevator_name[strlen(elevator_name) - 1] = '\0';
754
755 e = elevator_get(elevator_name);
756 if (!e) {
757 printk(KERN_ERR "elevator: type %s not found\n", elevator_name);
758 return -EINVAL;
759 }
760
761 if (!strcmp(elevator_name, q->elevator->elevator_type->elevator_name)) {
762 elevator_put(e);
763 return count;
764 }
765
766 elevator_switch(q, e);
767 return count;
768}
769
770ssize_t elv_iosched_show(request_queue_t *q, char *name)
771{
772 elevator_t *e = q->elevator;
773 struct elevator_type *elv = e->elevator_type;
774 struct list_head *entry;
775 int len = 0;
776
777 spin_lock_irq(q->queue_lock);
778 list_for_each(entry, &elv_list) {
779 struct elevator_type *__e;
780
781 __e = list_entry(entry, struct elevator_type, list);
782 if (!strcmp(elv->elevator_name, __e->elevator_name))
783 len += sprintf(name+len, "[%s] ", elv->elevator_name);
784 else
785 len += sprintf(name+len, "%s ", __e->elevator_name);
786 }
787 spin_unlock_irq(q->queue_lock);
788
789 len += sprintf(len+name, "\n");
790 return len;
791}
792
793EXPORT_SYMBOL(elv_dispatch_sort);
794EXPORT_SYMBOL(elv_add_request);
795EXPORT_SYMBOL(__elv_add_request);
796EXPORT_SYMBOL(elv_requeue_request);
797EXPORT_SYMBOL(elv_next_request);
798EXPORT_SYMBOL(elv_dequeue_request);
799EXPORT_SYMBOL(elv_queue_empty);
800EXPORT_SYMBOL(elv_completed_request);
801EXPORT_SYMBOL(elevator_exit);
802EXPORT_SYMBOL(elevator_init);
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
deleted file mode 100644
index 54aec4a1ae13..000000000000
--- a/drivers/block/genhd.c
+++ /dev/null
@@ -1,726 +0,0 @@
1/*
2 * gendisk handling
3 */
4
5#include <linux/config.h>
6#include <linux/module.h>
7#include <linux/fs.h>
8#include <linux/genhd.h>
9#include <linux/kernel.h>
10#include <linux/blkdev.h>
11#include <linux/init.h>
12#include <linux/spinlock.h>
13#include <linux/seq_file.h>
14#include <linux/slab.h>
15#include <linux/kmod.h>
16#include <linux/kobj_map.h>
17#include <linux/buffer_head.h>
18
19#define MAX_PROBE_HASH 255 /* random */
20
21static struct subsystem block_subsys;
22
23static DECLARE_MUTEX(block_subsys_sem);
24
25/*
26 * Can be deleted altogether. Later.
27 *
28 */
29static struct blk_major_name {
30 struct blk_major_name *next;
31 int major;
32 char name[16];
33} *major_names[MAX_PROBE_HASH];
34
35/* index in the above - for now: assume no multimajor ranges */
36static inline int major_to_index(int major)
37{
38 return major % MAX_PROBE_HASH;
39}
40
41#ifdef CONFIG_PROC_FS
42/* get block device names in somewhat random order */
43int get_blkdev_list(char *p, int used)
44{
45 struct blk_major_name *n;
46 int i, len;
47
48 len = snprintf(p, (PAGE_SIZE-used), "\nBlock devices:\n");
49
50 down(&block_subsys_sem);
51 for (i = 0; i < ARRAY_SIZE(major_names); i++) {
52 for (n = major_names[i]; n; n = n->next) {
53 /*
54 * If the curent string plus the 5 extra characters
55 * in the line would run us off the page, then we're done
56 */
57 if ((len + used + strlen(n->name) + 5) >= PAGE_SIZE)
58 goto page_full;
59 len += sprintf(p+len, "%3d %s\n",
60 n->major, n->name);
61 }
62 }
63page_full:
64 up(&block_subsys_sem);
65
66 return len;
67}
68#endif
69
70int register_blkdev(unsigned int major, const char *name)
71{
72 struct blk_major_name **n, *p;
73 int index, ret = 0;
74
75 down(&block_subsys_sem);
76
77 /* temporary */
78 if (major == 0) {
79 for (index = ARRAY_SIZE(major_names)-1; index > 0; index--) {
80 if (major_names[index] == NULL)
81 break;
82 }
83
84 if (index == 0) {
85 printk("register_blkdev: failed to get major for %s\n",
86 name);
87 ret = -EBUSY;
88 goto out;
89 }
90 major = index;
91 ret = major;
92 }
93
94 p = kmalloc(sizeof(struct blk_major_name), GFP_KERNEL);
95 if (p == NULL) {
96 ret = -ENOMEM;
97 goto out;
98 }
99
100 p->major = major;
101 strlcpy(p->name, name, sizeof(p->name));
102 p->next = NULL;
103 index = major_to_index(major);
104
105 for (n = &major_names[index]; *n; n = &(*n)->next) {
106 if ((*n)->major == major)
107 break;
108 }
109 if (!*n)
110 *n = p;
111 else
112 ret = -EBUSY;
113
114 if (ret < 0) {
115 printk("register_blkdev: cannot get major %d for %s\n",
116 major, name);
117 kfree(p);
118 }
119out:
120 up(&block_subsys_sem);
121 return ret;
122}
123
124EXPORT_SYMBOL(register_blkdev);
125
126/* todo: make void - error printk here */
127int unregister_blkdev(unsigned int major, const char *name)
128{
129 struct blk_major_name **n;
130 struct blk_major_name *p = NULL;
131 int index = major_to_index(major);
132 int ret = 0;
133
134 down(&block_subsys_sem);
135 for (n = &major_names[index]; *n; n = &(*n)->next)
136 if ((*n)->major == major)
137 break;
138 if (!*n || strcmp((*n)->name, name))
139 ret = -EINVAL;
140 else {
141 p = *n;
142 *n = p->next;
143 }
144 up(&block_subsys_sem);
145 kfree(p);
146
147 return ret;
148}
149
150EXPORT_SYMBOL(unregister_blkdev);
151
152static struct kobj_map *bdev_map;
153
154/*
155 * Register device numbers dev..(dev+range-1)
156 * range must be nonzero
157 * The hash chain is sorted on range, so that subranges can override.
158 */
159void blk_register_region(dev_t dev, unsigned long range, struct module *module,
160 struct kobject *(*probe)(dev_t, int *, void *),
161 int (*lock)(dev_t, void *), void *data)
162{
163 kobj_map(bdev_map, dev, range, module, probe, lock, data);
164}
165
166EXPORT_SYMBOL(blk_register_region);
167
168void blk_unregister_region(dev_t dev, unsigned long range)
169{
170 kobj_unmap(bdev_map, dev, range);
171}
172
173EXPORT_SYMBOL(blk_unregister_region);
174
175static struct kobject *exact_match(dev_t dev, int *part, void *data)
176{
177 struct gendisk *p = data;
178 return &p->kobj;
179}
180
181static int exact_lock(dev_t dev, void *data)
182{
183 struct gendisk *p = data;
184
185 if (!get_disk(p))
186 return -1;
187 return 0;
188}
189
190/**
191 * add_disk - add partitioning information to kernel list
192 * @disk: per-device partitioning information
193 *
194 * This function registers the partitioning information in @disk
195 * with the kernel.
196 */
197void add_disk(struct gendisk *disk)
198{
199 disk->flags |= GENHD_FL_UP;
200 blk_register_region(MKDEV(disk->major, disk->first_minor),
201 disk->minors, NULL, exact_match, exact_lock, disk);
202 register_disk(disk);
203 blk_register_queue(disk);
204}
205
206EXPORT_SYMBOL(add_disk);
207EXPORT_SYMBOL(del_gendisk); /* in partitions/check.c */
208
209void unlink_gendisk(struct gendisk *disk)
210{
211 blk_unregister_queue(disk);
212 blk_unregister_region(MKDEV(disk->major, disk->first_minor),
213 disk->minors);
214}
215
216#define to_disk(obj) container_of(obj,struct gendisk,kobj)
217
218/**
219 * get_gendisk - get partitioning information for a given device
220 * @dev: device to get partitioning information for
221 *
222 * This function gets the structure containing partitioning
223 * information for the given device @dev.
224 */
225struct gendisk *get_gendisk(dev_t dev, int *part)
226{
227 struct kobject *kobj = kobj_lookup(bdev_map, dev, part);
228 return kobj ? to_disk(kobj) : NULL;
229}
230
231#ifdef CONFIG_PROC_FS
232/* iterator */
233static void *part_start(struct seq_file *part, loff_t *pos)
234{
235 struct list_head *p;
236 loff_t l = *pos;
237
238 down(&block_subsys_sem);
239 list_for_each(p, &block_subsys.kset.list)
240 if (!l--)
241 return list_entry(p, struct gendisk, kobj.entry);
242 return NULL;
243}
244
245static void *part_next(struct seq_file *part, void *v, loff_t *pos)
246{
247 struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
248 ++*pos;
249 return p==&block_subsys.kset.list ? NULL :
250 list_entry(p, struct gendisk, kobj.entry);
251}
252
253static void part_stop(struct seq_file *part, void *v)
254{
255 up(&block_subsys_sem);
256}
257
258static int show_partition(struct seq_file *part, void *v)
259{
260 struct gendisk *sgp = v;
261 int n;
262 char buf[BDEVNAME_SIZE];
263
264 if (&sgp->kobj.entry == block_subsys.kset.list.next)
265 seq_puts(part, "major minor #blocks name\n\n");
266
267 /* Don't show non-partitionable removeable devices or empty devices */
268 if (!get_capacity(sgp) ||
269 (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE)))
270 return 0;
271 if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)
272 return 0;
273
274 /* show the full disk and all non-0 size partitions of it */
275 seq_printf(part, "%4d %4d %10llu %s\n",
276 sgp->major, sgp->first_minor,
277 (unsigned long long)get_capacity(sgp) >> 1,
278 disk_name(sgp, 0, buf));
279 for (n = 0; n < sgp->minors - 1; n++) {
280 if (!sgp->part[n])
281 continue;
282 if (sgp->part[n]->nr_sects == 0)
283 continue;
284 seq_printf(part, "%4d %4d %10llu %s\n",
285 sgp->major, n + 1 + sgp->first_minor,
286 (unsigned long long)sgp->part[n]->nr_sects >> 1 ,
287 disk_name(sgp, n + 1, buf));
288 }
289
290 return 0;
291}
292
293struct seq_operations partitions_op = {
294 .start =part_start,
295 .next = part_next,
296 .stop = part_stop,
297 .show = show_partition
298};
299#endif
300
301
302extern int blk_dev_init(void);
303
304static struct kobject *base_probe(dev_t dev, int *part, void *data)
305{
306 if (request_module("block-major-%d-%d", MAJOR(dev), MINOR(dev)) > 0)
307 /* Make old-style 2.4 aliases work */
308 request_module("block-major-%d", MAJOR(dev));
309 return NULL;
310}
311
312static int __init genhd_device_init(void)
313{
314 bdev_map = kobj_map_init(base_probe, &block_subsys_sem);
315 blk_dev_init();
316 subsystem_register(&block_subsys);
317 return 0;
318}
319
320subsys_initcall(genhd_device_init);
321
322
323
324/*
325 * kobject & sysfs bindings for block devices
326 */
327static ssize_t disk_attr_show(struct kobject *kobj, struct attribute *attr,
328 char *page)
329{
330 struct gendisk *disk = to_disk(kobj);
331 struct disk_attribute *disk_attr =
332 container_of(attr,struct disk_attribute,attr);
333 ssize_t ret = -EIO;
334
335 if (disk_attr->show)
336 ret = disk_attr->show(disk,page);
337 return ret;
338}
339
340static ssize_t disk_attr_store(struct kobject * kobj, struct attribute * attr,
341 const char *page, size_t count)
342{
343 struct gendisk *disk = to_disk(kobj);
344 struct disk_attribute *disk_attr =
345 container_of(attr,struct disk_attribute,attr);
346 ssize_t ret = 0;
347
348 if (disk_attr->store)
349 ret = disk_attr->store(disk, page, count);
350 return ret;
351}
352
353static struct sysfs_ops disk_sysfs_ops = {
354 .show = &disk_attr_show,
355 .store = &disk_attr_store,
356};
357
358static ssize_t disk_uevent_store(struct gendisk * disk,
359 const char *buf, size_t count)
360{
361 kobject_hotplug(&disk->kobj, KOBJ_ADD);
362 return count;
363}
364static ssize_t disk_dev_read(struct gendisk * disk, char *page)
365{
366 dev_t base = MKDEV(disk->major, disk->first_minor);
367 return print_dev_t(page, base);
368}
369static ssize_t disk_range_read(struct gendisk * disk, char *page)
370{
371 return sprintf(page, "%d\n", disk->minors);
372}
373static ssize_t disk_removable_read(struct gendisk * disk, char *page)
374{
375 return sprintf(page, "%d\n",
376 (disk->flags & GENHD_FL_REMOVABLE ? 1 : 0));
377
378}
379static ssize_t disk_size_read(struct gendisk * disk, char *page)
380{
381 return sprintf(page, "%llu\n", (unsigned long long)get_capacity(disk));
382}
383
384static ssize_t disk_stats_read(struct gendisk * disk, char *page)
385{
386 preempt_disable();
387 disk_round_stats(disk);
388 preempt_enable();
389 return sprintf(page,
390 "%8u %8u %8llu %8u "
391 "%8u %8u %8llu %8u "
392 "%8u %8u %8u"
393 "\n",
394 disk_stat_read(disk, ios[0]), disk_stat_read(disk, merges[0]),
395 (unsigned long long)disk_stat_read(disk, sectors[0]),
396 jiffies_to_msecs(disk_stat_read(disk, ticks[0])),
397 disk_stat_read(disk, ios[1]), disk_stat_read(disk, merges[1]),
398 (unsigned long long)disk_stat_read(disk, sectors[1]),
399 jiffies_to_msecs(disk_stat_read(disk, ticks[1])),
400 disk->in_flight,
401 jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
402 jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
403}
404static struct disk_attribute disk_attr_uevent = {
405 .attr = {.name = "uevent", .mode = S_IWUSR },
406 .store = disk_uevent_store
407};
408static struct disk_attribute disk_attr_dev = {
409 .attr = {.name = "dev", .mode = S_IRUGO },
410 .show = disk_dev_read
411};
412static struct disk_attribute disk_attr_range = {
413 .attr = {.name = "range", .mode = S_IRUGO },
414 .show = disk_range_read
415};
416static struct disk_attribute disk_attr_removable = {
417 .attr = {.name = "removable", .mode = S_IRUGO },
418 .show = disk_removable_read
419};
420static struct disk_attribute disk_attr_size = {
421 .attr = {.name = "size", .mode = S_IRUGO },
422 .show = disk_size_read
423};
424static struct disk_attribute disk_attr_stat = {
425 .attr = {.name = "stat", .mode = S_IRUGO },
426 .show = disk_stats_read
427};
428
429static struct attribute * default_attrs[] = {
430 &disk_attr_uevent.attr,
431 &disk_attr_dev.attr,
432 &disk_attr_range.attr,
433 &disk_attr_removable.attr,
434 &disk_attr_size.attr,
435 &disk_attr_stat.attr,
436 NULL,
437};
438
439static void disk_release(struct kobject * kobj)
440{
441 struct gendisk *disk = to_disk(kobj);
442 kfree(disk->random);
443 kfree(disk->part);
444 free_disk_stats(disk);
445 kfree(disk);
446}
447
448static struct kobj_type ktype_block = {
449 .release = disk_release,
450 .sysfs_ops = &disk_sysfs_ops,
451 .default_attrs = default_attrs,
452};
453
454extern struct kobj_type ktype_part;
455
456static int block_hotplug_filter(struct kset *kset, struct kobject *kobj)
457{
458 struct kobj_type *ktype = get_ktype(kobj);
459
460 return ((ktype == &ktype_block) || (ktype == &ktype_part));
461}
462
463static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
464 int num_envp, char *buffer, int buffer_size)
465{
466 struct kobj_type *ktype = get_ktype(kobj);
467 struct device *physdev;
468 struct gendisk *disk;
469 struct hd_struct *part;
470 int length = 0;
471 int i = 0;
472
473 if (ktype == &ktype_block) {
474 disk = container_of(kobj, struct gendisk, kobj);
475 add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
476 &length, "MINOR=%u", disk->first_minor);
477 } else if (ktype == &ktype_part) {
478 disk = container_of(kobj->parent, struct gendisk, kobj);
479 part = container_of(kobj, struct hd_struct, kobj);
480 add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
481 &length, "MINOR=%u",
482 disk->first_minor + part->partno);
483 } else
484 return 0;
485
486 add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length,
487 "MAJOR=%u", disk->major);
488
489 /* add physical device, backing this device */
490 physdev = disk->driverfs_dev;
491 if (physdev) {
492 char *path = kobject_get_path(&physdev->kobj, GFP_KERNEL);
493
494 add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
495 &length, "PHYSDEVPATH=%s", path);
496 kfree(path);
497
498 if (physdev->bus)
499 add_hotplug_env_var(envp, num_envp, &i,
500 buffer, buffer_size, &length,
501 "PHYSDEVBUS=%s",
502 physdev->bus->name);
503
504 if (physdev->driver)
505 add_hotplug_env_var(envp, num_envp, &i,
506 buffer, buffer_size, &length,
507 "PHYSDEVDRIVER=%s",
508 physdev->driver->name);
509 }
510
511 /* terminate, set to next free slot, shrink available space */
512 envp[i] = NULL;
513 envp = &envp[i];
514 num_envp -= i;
515 buffer = &buffer[length];
516 buffer_size -= length;
517
518 return 0;
519}
520
521static struct kset_hotplug_ops block_hotplug_ops = {
522 .filter = block_hotplug_filter,
523 .hotplug = block_hotplug,
524};
525
526/* declare block_subsys. */
527static decl_subsys(block, &ktype_block, &block_hotplug_ops);
528
529
530/*
531 * aggregate disk stat collector. Uses the same stats that the sysfs
532 * entries do, above, but makes them available through one seq_file.
533 * Watching a few disks may be efficient through sysfs, but watching
534 * all of them will be more efficient through this interface.
535 *
536 * The output looks suspiciously like /proc/partitions with a bunch of
537 * extra fields.
538 */
539
540/* iterator */
541static void *diskstats_start(struct seq_file *part, loff_t *pos)
542{
543 loff_t k = *pos;
544 struct list_head *p;
545
546 down(&block_subsys_sem);
547 list_for_each(p, &block_subsys.kset.list)
548 if (!k--)
549 return list_entry(p, struct gendisk, kobj.entry);
550 return NULL;
551}
552
553static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
554{
555 struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
556 ++*pos;
557 return p==&block_subsys.kset.list ? NULL :
558 list_entry(p, struct gendisk, kobj.entry);
559}
560
561static void diskstats_stop(struct seq_file *part, void *v)
562{
563 up(&block_subsys_sem);
564}
565
566static int diskstats_show(struct seq_file *s, void *v)
567{
568 struct gendisk *gp = v;
569 char buf[BDEVNAME_SIZE];
570 int n = 0;
571
572 /*
573 if (&sgp->kobj.entry == block_subsys.kset.list.next)
574 seq_puts(s, "major minor name"
575 " rio rmerge rsect ruse wio wmerge "
576 "wsect wuse running use aveq"
577 "\n\n");
578 */
579
580 preempt_disable();
581 disk_round_stats(gp);
582 preempt_enable();
583 seq_printf(s, "%4d %4d %s %u %u %llu %u %u %u %llu %u %u %u %u\n",
584 gp->major, n + gp->first_minor, disk_name(gp, n, buf),
585 disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]),
586 (unsigned long long)disk_stat_read(gp, sectors[0]),
587 jiffies_to_msecs(disk_stat_read(gp, ticks[0])),
588 disk_stat_read(gp, ios[1]), disk_stat_read(gp, merges[1]),
589 (unsigned long long)disk_stat_read(gp, sectors[1]),
590 jiffies_to_msecs(disk_stat_read(gp, ticks[1])),
591 gp->in_flight,
592 jiffies_to_msecs(disk_stat_read(gp, io_ticks)),
593 jiffies_to_msecs(disk_stat_read(gp, time_in_queue)));
594
595 /* now show all non-0 size partitions of it */
596 for (n = 0; n < gp->minors - 1; n++) {
597 struct hd_struct *hd = gp->part[n];
598
599 if (hd && hd->nr_sects)
600 seq_printf(s, "%4d %4d %s %u %u %u %u\n",
601 gp->major, n + gp->first_minor + 1,
602 disk_name(gp, n + 1, buf),
603 hd->ios[0], hd->sectors[0],
604 hd->ios[1], hd->sectors[1]);
605 }
606
607 return 0;
608}
609
610struct seq_operations diskstats_op = {
611 .start = diskstats_start,
612 .next = diskstats_next,
613 .stop = diskstats_stop,
614 .show = diskstats_show
615};
616
617struct gendisk *alloc_disk(int minors)
618{
619 return alloc_disk_node(minors, -1);
620}
621
622struct gendisk *alloc_disk_node(int minors, int node_id)
623{
624 struct gendisk *disk;
625
626 disk = kmalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
627 if (disk) {
628 memset(disk, 0, sizeof(struct gendisk));
629 if (!init_disk_stats(disk)) {
630 kfree(disk);
631 return NULL;
632 }
633 if (minors > 1) {
634 int size = (minors - 1) * sizeof(struct hd_struct *);
635 disk->part = kmalloc_node(size, GFP_KERNEL, node_id);
636 if (!disk->part) {
637 kfree(disk);
638 return NULL;
639 }
640 memset(disk->part, 0, size);
641 }
642 disk->minors = minors;
643 kobj_set_kset_s(disk,block_subsys);
644 kobject_init(&disk->kobj);
645 rand_initialize_disk(disk);
646 }
647 return disk;
648}
649
650EXPORT_SYMBOL(alloc_disk);
651EXPORT_SYMBOL(alloc_disk_node);
652
653struct kobject *get_disk(struct gendisk *disk)
654{
655 struct module *owner;
656 struct kobject *kobj;
657
658 if (!disk->fops)
659 return NULL;
660 owner = disk->fops->owner;
661 if (owner && !try_module_get(owner))
662 return NULL;
663 kobj = kobject_get(&disk->kobj);
664 if (kobj == NULL) {
665 module_put(owner);
666 return NULL;
667 }
668 return kobj;
669
670}
671
672EXPORT_SYMBOL(get_disk);
673
674void put_disk(struct gendisk *disk)
675{
676 if (disk)
677 kobject_put(&disk->kobj);
678}
679
680EXPORT_SYMBOL(put_disk);
681
682void set_device_ro(struct block_device *bdev, int flag)
683{
684 if (bdev->bd_contains != bdev)
685 bdev->bd_part->policy = flag;
686 else
687 bdev->bd_disk->policy = flag;
688}
689
690EXPORT_SYMBOL(set_device_ro);
691
692void set_disk_ro(struct gendisk *disk, int flag)
693{
694 int i;
695 disk->policy = flag;
696 for (i = 0; i < disk->minors - 1; i++)
697 if (disk->part[i]) disk->part[i]->policy = flag;
698}
699
700EXPORT_SYMBOL(set_disk_ro);
701
702int bdev_read_only(struct block_device *bdev)
703{
704 if (!bdev)
705 return 0;
706 else if (bdev->bd_contains != bdev)
707 return bdev->bd_part->policy;
708 else
709 return bdev->bd_disk->policy;
710}
711
712EXPORT_SYMBOL(bdev_read_only);
713
714int invalidate_partition(struct gendisk *disk, int index)
715{
716 int res = 0;
717 struct block_device *bdev = bdget_disk(disk, index);
718 if (bdev) {
719 fsync_bdev(bdev);
720 res = __invalidate_device(bdev);
721 bdput(bdev);
722 }
723 return res;
724}
725
726EXPORT_SYMBOL(invalidate_partition);
diff --git a/drivers/block/ioctl.c b/drivers/block/ioctl.c
deleted file mode 100644
index 6e278474f9a8..000000000000
--- a/drivers/block/ioctl.c
+++ /dev/null
@@ -1,275 +0,0 @@
1#include <linux/sched.h> /* for capable() */
2#include <linux/blkdev.h>
3#include <linux/blkpg.h>
4#include <linux/backing-dev.h>
5#include <linux/buffer_head.h>
6#include <linux/smp_lock.h>
7#include <asm/uaccess.h>
8
9static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)
10{
11 struct block_device *bdevp;
12 struct gendisk *disk;
13 struct blkpg_ioctl_arg a;
14 struct blkpg_partition p;
15 long long start, length;
16 int part;
17 int i;
18
19 if (!capable(CAP_SYS_ADMIN))
20 return -EACCES;
21 if (copy_from_user(&a, arg, sizeof(struct blkpg_ioctl_arg)))
22 return -EFAULT;
23 if (copy_from_user(&p, a.data, sizeof(struct blkpg_partition)))
24 return -EFAULT;
25 disk = bdev->bd_disk;
26 if (bdev != bdev->bd_contains)
27 return -EINVAL;
28 part = p.pno;
29 if (part <= 0 || part >= disk->minors)
30 return -EINVAL;
31 switch (a.op) {
32 case BLKPG_ADD_PARTITION:
33 start = p.start >> 9;
34 length = p.length >> 9;
35 /* check for fit in a hd_struct */
36 if (sizeof(sector_t) == sizeof(long) &&
37 sizeof(long long) > sizeof(long)) {
38 long pstart = start, plength = length;
39 if (pstart != start || plength != length
40 || pstart < 0 || plength < 0)
41 return -EINVAL;
42 }
43 /* partition number in use? */
44 down(&bdev->bd_sem);
45 if (disk->part[part - 1]) {
46 up(&bdev->bd_sem);
47 return -EBUSY;
48 }
49 /* overlap? */
50 for (i = 0; i < disk->minors - 1; i++) {
51 struct hd_struct *s = disk->part[i];
52
53 if (!s)
54 continue;
55 if (!(start+length <= s->start_sect ||
56 start >= s->start_sect + s->nr_sects)) {
57 up(&bdev->bd_sem);
58 return -EBUSY;
59 }
60 }
61 /* all seems OK */
62 add_partition(disk, part, start, length);
63 up(&bdev->bd_sem);
64 return 0;
65 case BLKPG_DEL_PARTITION:
66 if (!disk->part[part-1])
67 return -ENXIO;
68 if (disk->part[part - 1]->nr_sects == 0)
69 return -ENXIO;
70 bdevp = bdget_disk(disk, part);
71 if (!bdevp)
72 return -ENOMEM;
73 down(&bdevp->bd_sem);
74 if (bdevp->bd_openers) {
75 up(&bdevp->bd_sem);
76 bdput(bdevp);
77 return -EBUSY;
78 }
79 /* all seems OK */
80 fsync_bdev(bdevp);
81 invalidate_bdev(bdevp, 0);
82
83 down(&bdev->bd_sem);
84 delete_partition(disk, part);
85 up(&bdev->bd_sem);
86 up(&bdevp->bd_sem);
87 bdput(bdevp);
88
89 return 0;
90 default:
91 return -EINVAL;
92 }
93}
94
95static int blkdev_reread_part(struct block_device *bdev)
96{
97 struct gendisk *disk = bdev->bd_disk;
98 int res;
99
100 if (disk->minors == 1 || bdev != bdev->bd_contains)
101 return -EINVAL;
102 if (!capable(CAP_SYS_ADMIN))
103 return -EACCES;
104 if (down_trylock(&bdev->bd_sem))
105 return -EBUSY;
106 res = rescan_partitions(disk, bdev);
107 up(&bdev->bd_sem);
108 return res;
109}
110
111static int put_ushort(unsigned long arg, unsigned short val)
112{
113 return put_user(val, (unsigned short __user *)arg);
114}
115
116static int put_int(unsigned long arg, int val)
117{
118 return put_user(val, (int __user *)arg);
119}
120
121static int put_long(unsigned long arg, long val)
122{
123 return put_user(val, (long __user *)arg);
124}
125
126static int put_ulong(unsigned long arg, unsigned long val)
127{
128 return put_user(val, (unsigned long __user *)arg);
129}
130
131static int put_u64(unsigned long arg, u64 val)
132{
133 return put_user(val, (u64 __user *)arg);
134}
135
136static int blkdev_locked_ioctl(struct file *file, struct block_device *bdev,
137 unsigned cmd, unsigned long arg)
138{
139 struct backing_dev_info *bdi;
140 int ret, n;
141
142 switch (cmd) {
143 case BLKRAGET:
144 case BLKFRAGET:
145 if (!arg)
146 return -EINVAL;
147 bdi = blk_get_backing_dev_info(bdev);
148 if (bdi == NULL)
149 return -ENOTTY;
150 return put_long(arg, (bdi->ra_pages * PAGE_CACHE_SIZE) / 512);
151 case BLKROGET:
152 return put_int(arg, bdev_read_only(bdev) != 0);
153 case BLKBSZGET: /* get the logical block size (cf. BLKSSZGET) */
154 return put_int(arg, block_size(bdev));
155 case BLKSSZGET: /* get block device hardware sector size */
156 return put_int(arg, bdev_hardsect_size(bdev));
157 case BLKSECTGET:
158 return put_ushort(arg, bdev_get_queue(bdev)->max_sectors);
159 case BLKRASET:
160 case BLKFRASET:
161 if(!capable(CAP_SYS_ADMIN))
162 return -EACCES;
163 bdi = blk_get_backing_dev_info(bdev);
164 if (bdi == NULL)
165 return -ENOTTY;
166 bdi->ra_pages = (arg * 512) / PAGE_CACHE_SIZE;
167 return 0;
168 case BLKBSZSET:
169 /* set the logical block size */
170 if (!capable(CAP_SYS_ADMIN))
171 return -EACCES;
172 if (!arg)
173 return -EINVAL;
174 if (get_user(n, (int __user *) arg))
175 return -EFAULT;
176 if (bd_claim(bdev, file) < 0)
177 return -EBUSY;
178 ret = set_blocksize(bdev, n);
179 bd_release(bdev);
180 return ret;
181 case BLKPG:
182 return blkpg_ioctl(bdev, (struct blkpg_ioctl_arg __user *) arg);
183 case BLKRRPART:
184 return blkdev_reread_part(bdev);
185 case BLKGETSIZE:
186 if ((bdev->bd_inode->i_size >> 9) > ~0UL)
187 return -EFBIG;
188 return put_ulong(arg, bdev->bd_inode->i_size >> 9);
189 case BLKGETSIZE64:
190 return put_u64(arg, bdev->bd_inode->i_size);
191 }
192 return -ENOIOCTLCMD;
193}
194
195static int blkdev_driver_ioctl(struct inode *inode, struct file *file,
196 struct gendisk *disk, unsigned cmd, unsigned long arg)
197{
198 int ret;
199 if (disk->fops->unlocked_ioctl)
200 return disk->fops->unlocked_ioctl(file, cmd, arg);
201
202 if (disk->fops->ioctl) {
203 lock_kernel();
204 ret = disk->fops->ioctl(inode, file, cmd, arg);
205 unlock_kernel();
206 return ret;
207 }
208
209 return -ENOTTY;
210}
211
212int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
213 unsigned long arg)
214{
215 struct block_device *bdev = inode->i_bdev;
216 struct gendisk *disk = bdev->bd_disk;
217 int ret, n;
218
219 switch(cmd) {
220 case BLKFLSBUF:
221 if (!capable(CAP_SYS_ADMIN))
222 return -EACCES;
223
224 ret = blkdev_driver_ioctl(inode, file, disk, cmd, arg);
225 /* -EINVAL to handle old uncorrected drivers */
226 if (ret != -EINVAL && ret != -ENOTTY)
227 return ret;
228
229 lock_kernel();
230 fsync_bdev(bdev);
231 invalidate_bdev(bdev, 0);
232 unlock_kernel();
233 return 0;
234
235 case BLKROSET:
236 ret = blkdev_driver_ioctl(inode, file, disk, cmd, arg);
237 /* -EINVAL to handle old uncorrected drivers */
238 if (ret != -EINVAL && ret != -ENOTTY)
239 return ret;
240 if (!capable(CAP_SYS_ADMIN))
241 return -EACCES;
242 if (get_user(n, (int __user *)(arg)))
243 return -EFAULT;
244 lock_kernel();
245 set_device_ro(bdev, n);
246 unlock_kernel();
247 return 0;
248 }
249
250 lock_kernel();
251 ret = blkdev_locked_ioctl(file, bdev, cmd, arg);
252 unlock_kernel();
253 if (ret != -ENOIOCTLCMD)
254 return ret;
255
256 return blkdev_driver_ioctl(inode, file, disk, cmd, arg);
257}
258
259/* Most of the generic ioctls are handled in the normal fallback path.
260 This assumes the blkdev's low level compat_ioctl always returns
261 ENOIOCTLCMD for unknown ioctls. */
262long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
263{
264 struct block_device *bdev = file->f_dentry->d_inode->i_bdev;
265 struct gendisk *disk = bdev->bd_disk;
266 int ret = -ENOIOCTLCMD;
267 if (disk->fops->compat_ioctl) {
268 lock_kernel();
269 ret = disk->fops->compat_ioctl(file, cmd, arg);
270 unlock_kernel();
271 }
272 return ret;
273}
274
275EXPORT_SYMBOL_GPL(blkdev_ioctl);
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
deleted file mode 100644
index 2747741677fb..000000000000
--- a/drivers/block/ll_rw_blk.c
+++ /dev/null
@@ -1,3613 +0,0 @@
1/*
2 * linux/drivers/block/ll_rw_blk.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 * Copyright (C) 1994, Karl Keyte: Added support for disk statistics
6 * Elevator latency, (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
7 * Queue request tables / lock, selectable elevator, Jens Axboe <axboe@suse.de>
8 * kernel-doc documentation started by NeilBrown <neilb@cse.unsw.edu.au> - July2000
9 * bio rewrite, highmem i/o, etc, Jens Axboe <axboe@suse.de> - may 2001
10 */
11
12/*
13 * This handles all read/write requests to block devices
14 */
15#include <linux/config.h>
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/backing-dev.h>
19#include <linux/bio.h>
20#include <linux/blkdev.h>
21#include <linux/highmem.h>
22#include <linux/mm.h>
23#include <linux/kernel_stat.h>
24#include <linux/string.h>
25#include <linux/init.h>
26#include <linux/bootmem.h> /* for max_pfn/max_low_pfn */
27#include <linux/completion.h>
28#include <linux/slab.h>
29#include <linux/swap.h>
30#include <linux/writeback.h>
31#include <linux/blkdev.h>
32
33/*
34 * for max sense size
35 */
36#include <scsi/scsi_cmnd.h>
37
38static void blk_unplug_work(void *data);
39static void blk_unplug_timeout(unsigned long data);
40static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io);
41
42/*
43 * For the allocated request tables
44 */
45static kmem_cache_t *request_cachep;
46
47/*
48 * For queue allocation
49 */
50static kmem_cache_t *requestq_cachep;
51
52/*
53 * For io context allocations
54 */
55static kmem_cache_t *iocontext_cachep;
56
57static wait_queue_head_t congestion_wqh[2] = {
58 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
59 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
60 };
61
62/*
63 * Controlling structure to kblockd
64 */
65static struct workqueue_struct *kblockd_workqueue;
66
67unsigned long blk_max_low_pfn, blk_max_pfn;
68
69EXPORT_SYMBOL(blk_max_low_pfn);
70EXPORT_SYMBOL(blk_max_pfn);
71
72/* Amount of time in which a process may batch requests */
73#define BLK_BATCH_TIME (HZ/50UL)
74
75/* Number of requests a "batching" process may submit */
76#define BLK_BATCH_REQ 32
77
78/*
79 * Return the threshold (number of used requests) at which the queue is
80 * considered to be congested. It include a little hysteresis to keep the
81 * context switch rate down.
82 */
83static inline int queue_congestion_on_threshold(struct request_queue *q)
84{
85 return q->nr_congestion_on;
86}
87
88/*
89 * The threshold at which a queue is considered to be uncongested
90 */
91static inline int queue_congestion_off_threshold(struct request_queue *q)
92{
93 return q->nr_congestion_off;
94}
95
96static void blk_queue_congestion_threshold(struct request_queue *q)
97{
98 int nr;
99
100 nr = q->nr_requests - (q->nr_requests / 8) + 1;
101 if (nr > q->nr_requests)
102 nr = q->nr_requests;
103 q->nr_congestion_on = nr;
104
105 nr = q->nr_requests - (q->nr_requests / 8) - (q->nr_requests / 16) - 1;
106 if (nr < 1)
107 nr = 1;
108 q->nr_congestion_off = nr;
109}
110
111/*
112 * A queue has just exitted congestion. Note this in the global counter of
113 * congested queues, and wake up anyone who was waiting for requests to be
114 * put back.
115 */
116static void clear_queue_congested(request_queue_t *q, int rw)
117{
118 enum bdi_state bit;
119 wait_queue_head_t *wqh = &congestion_wqh[rw];
120
121 bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
122 clear_bit(bit, &q->backing_dev_info.state);
123 smp_mb__after_clear_bit();
124 if (waitqueue_active(wqh))
125 wake_up(wqh);
126}
127
128/*
129 * A queue has just entered congestion. Flag that in the queue's VM-visible
130 * state flags and increment the global gounter of congested queues.
131 */
132static void set_queue_congested(request_queue_t *q, int rw)
133{
134 enum bdi_state bit;
135
136 bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
137 set_bit(bit, &q->backing_dev_info.state);
138}
139
140/**
141 * blk_get_backing_dev_info - get the address of a queue's backing_dev_info
142 * @bdev: device
143 *
144 * Locates the passed device's request queue and returns the address of its
145 * backing_dev_info
146 *
147 * Will return NULL if the request queue cannot be located.
148 */
149struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev)
150{
151 struct backing_dev_info *ret = NULL;
152 request_queue_t *q = bdev_get_queue(bdev);
153
154 if (q)
155 ret = &q->backing_dev_info;
156 return ret;
157}
158
159EXPORT_SYMBOL(blk_get_backing_dev_info);
160
161void blk_queue_activity_fn(request_queue_t *q, activity_fn *fn, void *data)
162{
163 q->activity_fn = fn;
164 q->activity_data = data;
165}
166
167EXPORT_SYMBOL(blk_queue_activity_fn);
168
169/**
170 * blk_queue_prep_rq - set a prepare_request function for queue
171 * @q: queue
172 * @pfn: prepare_request function
173 *
174 * It's possible for a queue to register a prepare_request callback which
175 * is invoked before the request is handed to the request_fn. The goal of
176 * the function is to prepare a request for I/O, it can be used to build a
177 * cdb from the request data for instance.
178 *
179 */
180void blk_queue_prep_rq(request_queue_t *q, prep_rq_fn *pfn)
181{
182 q->prep_rq_fn = pfn;
183}
184
185EXPORT_SYMBOL(blk_queue_prep_rq);
186
187/**
188 * blk_queue_merge_bvec - set a merge_bvec function for queue
189 * @q: queue
190 * @mbfn: merge_bvec_fn
191 *
192 * Usually queues have static limitations on the max sectors or segments that
193 * we can put in a request. Stacking drivers may have some settings that
194 * are dynamic, and thus we have to query the queue whether it is ok to
195 * add a new bio_vec to a bio at a given offset or not. If the block device
196 * has such limitations, it needs to register a merge_bvec_fn to control
197 * the size of bio's sent to it. Note that a block device *must* allow a
198 * single page to be added to an empty bio. The block device driver may want
199 * to use the bio_split() function to deal with these bio's. By default
200 * no merge_bvec_fn is defined for a queue, and only the fixed limits are
201 * honored.
202 */
203void blk_queue_merge_bvec(request_queue_t *q, merge_bvec_fn *mbfn)
204{
205 q->merge_bvec_fn = mbfn;
206}
207
208EXPORT_SYMBOL(blk_queue_merge_bvec);
209
210/**
211 * blk_queue_make_request - define an alternate make_request function for a device
212 * @q: the request queue for the device to be affected
213 * @mfn: the alternate make_request function
214 *
215 * Description:
216 * The normal way for &struct bios to be passed to a device
217 * driver is for them to be collected into requests on a request
218 * queue, and then to allow the device driver to select requests
219 * off that queue when it is ready. This works well for many block
220 * devices. However some block devices (typically virtual devices
221 * such as md or lvm) do not benefit from the processing on the
222 * request queue, and are served best by having the requests passed
223 * directly to them. This can be achieved by providing a function
224 * to blk_queue_make_request().
225 *
226 * Caveat:
227 * The driver that does this *must* be able to deal appropriately
228 * with buffers in "highmemory". This can be accomplished by either calling
229 * __bio_kmap_atomic() to get a temporary kernel mapping, or by calling
230 * blk_queue_bounce() to create a buffer in normal memory.
231 **/
232void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn)
233{
234 /*
235 * set defaults
236 */
237 q->nr_requests = BLKDEV_MAX_RQ;
238 blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
239 blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
240 q->make_request_fn = mfn;
241 q->backing_dev_info.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
242 q->backing_dev_info.state = 0;
243 q->backing_dev_info.capabilities = BDI_CAP_MAP_COPY;
244 blk_queue_max_sectors(q, MAX_SECTORS);
245 blk_queue_hardsect_size(q, 512);
246 blk_queue_dma_alignment(q, 511);
247 blk_queue_congestion_threshold(q);
248 q->nr_batching = BLK_BATCH_REQ;
249
250 q->unplug_thresh = 4; /* hmm */
251 q->unplug_delay = (3 * HZ) / 1000; /* 3 milliseconds */
252 if (q->unplug_delay == 0)
253 q->unplug_delay = 1;
254
255 INIT_WORK(&q->unplug_work, blk_unplug_work, q);
256
257 q->unplug_timer.function = blk_unplug_timeout;
258 q->unplug_timer.data = (unsigned long)q;
259
260 /*
261 * by default assume old behaviour and bounce for any highmem page
262 */
263 blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
264
265 blk_queue_activity_fn(q, NULL, NULL);
266}
267
268EXPORT_SYMBOL(blk_queue_make_request);
269
270static inline void rq_init(request_queue_t *q, struct request *rq)
271{
272 INIT_LIST_HEAD(&rq->queuelist);
273
274 rq->errors = 0;
275 rq->rq_status = RQ_ACTIVE;
276 rq->bio = rq->biotail = NULL;
277 rq->ioprio = 0;
278 rq->buffer = NULL;
279 rq->ref_count = 1;
280 rq->q = q;
281 rq->waiting = NULL;
282 rq->special = NULL;
283 rq->data_len = 0;
284 rq->data = NULL;
285 rq->nr_phys_segments = 0;
286 rq->sense = NULL;
287 rq->end_io = NULL;
288 rq->end_io_data = NULL;
289}
290
291/**
292 * blk_queue_ordered - does this queue support ordered writes
293 * @q: the request queue
294 * @flag: see below
295 *
296 * Description:
297 * For journalled file systems, doing ordered writes on a commit
298 * block instead of explicitly doing wait_on_buffer (which is bad
299 * for performance) can be a big win. Block drivers supporting this
300 * feature should call this function and indicate so.
301 *
302 **/
303void blk_queue_ordered(request_queue_t *q, int flag)
304{
305 switch (flag) {
306 case QUEUE_ORDERED_NONE:
307 if (q->flush_rq)
308 kmem_cache_free(request_cachep, q->flush_rq);
309 q->flush_rq = NULL;
310 q->ordered = flag;
311 break;
312 case QUEUE_ORDERED_TAG:
313 q->ordered = flag;
314 break;
315 case QUEUE_ORDERED_FLUSH:
316 q->ordered = flag;
317 if (!q->flush_rq)
318 q->flush_rq = kmem_cache_alloc(request_cachep,
319 GFP_KERNEL);
320 break;
321 default:
322 printk("blk_queue_ordered: bad value %d\n", flag);
323 break;
324 }
325}
326
327EXPORT_SYMBOL(blk_queue_ordered);
328
329/**
330 * blk_queue_issue_flush_fn - set function for issuing a flush
331 * @q: the request queue
332 * @iff: the function to be called issuing the flush
333 *
334 * Description:
335 * If a driver supports issuing a flush command, the support is notified
336 * to the block layer by defining it through this call.
337 *
338 **/
339void blk_queue_issue_flush_fn(request_queue_t *q, issue_flush_fn *iff)
340{
341 q->issue_flush_fn = iff;
342}
343
344EXPORT_SYMBOL(blk_queue_issue_flush_fn);
345
346/*
347 * Cache flushing for ordered writes handling
348 */
349static void blk_pre_flush_end_io(struct request *flush_rq)
350{
351 struct request *rq = flush_rq->end_io_data;
352 request_queue_t *q = rq->q;
353
354 elv_completed_request(q, flush_rq);
355
356 rq->flags |= REQ_BAR_PREFLUSH;
357
358 if (!flush_rq->errors)
359 elv_requeue_request(q, rq);
360 else {
361 q->end_flush_fn(q, flush_rq);
362 clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags);
363 q->request_fn(q);
364 }
365}
366
367static void blk_post_flush_end_io(struct request *flush_rq)
368{
369 struct request *rq = flush_rq->end_io_data;
370 request_queue_t *q = rq->q;
371
372 elv_completed_request(q, flush_rq);
373
374 rq->flags |= REQ_BAR_POSTFLUSH;
375
376 q->end_flush_fn(q, flush_rq);
377 clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags);
378 q->request_fn(q);
379}
380
381struct request *blk_start_pre_flush(request_queue_t *q, struct request *rq)
382{
383 struct request *flush_rq = q->flush_rq;
384
385 BUG_ON(!blk_barrier_rq(rq));
386
387 if (test_and_set_bit(QUEUE_FLAG_FLUSH, &q->queue_flags))
388 return NULL;
389
390 rq_init(q, flush_rq);
391 flush_rq->elevator_private = NULL;
392 flush_rq->flags = REQ_BAR_FLUSH;
393 flush_rq->rq_disk = rq->rq_disk;
394 flush_rq->rl = NULL;
395
396 /*
397 * prepare_flush returns 0 if no flush is needed, just mark both
398 * pre and post flush as done in that case
399 */
400 if (!q->prepare_flush_fn(q, flush_rq)) {
401 rq->flags |= REQ_BAR_PREFLUSH | REQ_BAR_POSTFLUSH;
402 clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags);
403 return rq;
404 }
405
406 /*
407 * some drivers dequeue requests right away, some only after io
408 * completion. make sure the request is dequeued.
409 */
410 if (!list_empty(&rq->queuelist))
411 blkdev_dequeue_request(rq);
412
413 flush_rq->end_io_data = rq;
414 flush_rq->end_io = blk_pre_flush_end_io;
415
416 __elv_add_request(q, flush_rq, ELEVATOR_INSERT_FRONT, 0);
417 return flush_rq;
418}
419
420static void blk_start_post_flush(request_queue_t *q, struct request *rq)
421{
422 struct request *flush_rq = q->flush_rq;
423
424 BUG_ON(!blk_barrier_rq(rq));
425
426 rq_init(q, flush_rq);
427 flush_rq->elevator_private = NULL;
428 flush_rq->flags = REQ_BAR_FLUSH;
429 flush_rq->rq_disk = rq->rq_disk;
430 flush_rq->rl = NULL;
431
432 if (q->prepare_flush_fn(q, flush_rq)) {
433 flush_rq->end_io_data = rq;
434 flush_rq->end_io = blk_post_flush_end_io;
435
436 __elv_add_request(q, flush_rq, ELEVATOR_INSERT_FRONT, 0);
437 q->request_fn(q);
438 }
439}
440
441static inline int blk_check_end_barrier(request_queue_t *q, struct request *rq,
442 int sectors)
443{
444 if (sectors > rq->nr_sectors)
445 sectors = rq->nr_sectors;
446
447 rq->nr_sectors -= sectors;
448 return rq->nr_sectors;
449}
450
451static int __blk_complete_barrier_rq(request_queue_t *q, struct request *rq,
452 int sectors, int queue_locked)
453{
454 if (q->ordered != QUEUE_ORDERED_FLUSH)
455 return 0;
456 if (!blk_fs_request(rq) || !blk_barrier_rq(rq))
457 return 0;
458 if (blk_barrier_postflush(rq))
459 return 0;
460
461 if (!blk_check_end_barrier(q, rq, sectors)) {
462 unsigned long flags = 0;
463
464 if (!queue_locked)
465 spin_lock_irqsave(q->queue_lock, flags);
466
467 blk_start_post_flush(q, rq);
468
469 if (!queue_locked)
470 spin_unlock_irqrestore(q->queue_lock, flags);
471 }
472
473 return 1;
474}
475
476/**
477 * blk_complete_barrier_rq - complete possible barrier request
478 * @q: the request queue for the device
479 * @rq: the request
480 * @sectors: number of sectors to complete
481 *
482 * Description:
483 * Used in driver end_io handling to determine whether to postpone
484 * completion of a barrier request until a post flush has been done. This
485 * is the unlocked variant, used if the caller doesn't already hold the
486 * queue lock.
487 **/
488int blk_complete_barrier_rq(request_queue_t *q, struct request *rq, int sectors)
489{
490 return __blk_complete_barrier_rq(q, rq, sectors, 0);
491}
492EXPORT_SYMBOL(blk_complete_barrier_rq);
493
494/**
495 * blk_complete_barrier_rq_locked - complete possible barrier request
496 * @q: the request queue for the device
497 * @rq: the request
498 * @sectors: number of sectors to complete
499 *
500 * Description:
501 * See blk_complete_barrier_rq(). This variant must be used if the caller
502 * holds the queue lock.
503 **/
504int blk_complete_barrier_rq_locked(request_queue_t *q, struct request *rq,
505 int sectors)
506{
507 return __blk_complete_barrier_rq(q, rq, sectors, 1);
508}
509EXPORT_SYMBOL(blk_complete_barrier_rq_locked);
510
511/**
512 * blk_queue_bounce_limit - set bounce buffer limit for queue
513 * @q: the request queue for the device
514 * @dma_addr: bus address limit
515 *
516 * Description:
517 * Different hardware can have different requirements as to what pages
518 * it can do I/O directly to. A low level driver can call
519 * blk_queue_bounce_limit to have lower memory pages allocated as bounce
520 * buffers for doing I/O to pages residing above @page. By default
521 * the block layer sets this to the highest numbered "low" memory page.
522 **/
523void blk_queue_bounce_limit(request_queue_t *q, u64 dma_addr)
524{
525 unsigned long bounce_pfn = dma_addr >> PAGE_SHIFT;
526
527 /*
528 * set appropriate bounce gfp mask -- unfortunately we don't have a
529 * full 4GB zone, so we have to resort to low memory for any bounces.
530 * ISA has its own < 16MB zone.
531 */
532 if (bounce_pfn < blk_max_low_pfn) {
533 BUG_ON(dma_addr < BLK_BOUNCE_ISA);
534 init_emergency_isa_pool();
535 q->bounce_gfp = GFP_NOIO | GFP_DMA;
536 } else
537 q->bounce_gfp = GFP_NOIO;
538
539 q->bounce_pfn = bounce_pfn;
540}
541
542EXPORT_SYMBOL(blk_queue_bounce_limit);
543
544/**
545 * blk_queue_max_sectors - set max sectors for a request for this queue
546 * @q: the request queue for the device
547 * @max_sectors: max sectors in the usual 512b unit
548 *
549 * Description:
550 * Enables a low level driver to set an upper limit on the size of
551 * received requests.
552 **/
553void blk_queue_max_sectors(request_queue_t *q, unsigned short max_sectors)
554{
555 if ((max_sectors << 9) < PAGE_CACHE_SIZE) {
556 max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
557 printk("%s: set to minimum %d\n", __FUNCTION__, max_sectors);
558 }
559
560 q->max_sectors = q->max_hw_sectors = max_sectors;
561}
562
563EXPORT_SYMBOL(blk_queue_max_sectors);
564
565/**
566 * blk_queue_max_phys_segments - set max phys segments for a request for this queue
567 * @q: the request queue for the device
568 * @max_segments: max number of segments
569 *
570 * Description:
571 * Enables a low level driver to set an upper limit on the number of
572 * physical data segments in a request. This would be the largest sized
573 * scatter list the driver could handle.
574 **/
575void blk_queue_max_phys_segments(request_queue_t *q, unsigned short max_segments)
576{
577 if (!max_segments) {
578 max_segments = 1;
579 printk("%s: set to minimum %d\n", __FUNCTION__, max_segments);
580 }
581
582 q->max_phys_segments = max_segments;
583}
584
585EXPORT_SYMBOL(blk_queue_max_phys_segments);
586
587/**
588 * blk_queue_max_hw_segments - set max hw segments for a request for this queue
589 * @q: the request queue for the device
590 * @max_segments: max number of segments
591 *
592 * Description:
593 * Enables a low level driver to set an upper limit on the number of
594 * hw data segments in a request. This would be the largest number of
595 * address/length pairs the host adapter can actually give as once
596 * to the device.
597 **/
598void blk_queue_max_hw_segments(request_queue_t *q, unsigned short max_segments)
599{
600 if (!max_segments) {
601 max_segments = 1;
602 printk("%s: set to minimum %d\n", __FUNCTION__, max_segments);
603 }
604
605 q->max_hw_segments = max_segments;
606}
607
608EXPORT_SYMBOL(blk_queue_max_hw_segments);
609
610/**
611 * blk_queue_max_segment_size - set max segment size for blk_rq_map_sg
612 * @q: the request queue for the device
613 * @max_size: max size of segment in bytes
614 *
615 * Description:
616 * Enables a low level driver to set an upper limit on the size of a
617 * coalesced segment
618 **/
619void blk_queue_max_segment_size(request_queue_t *q, unsigned int max_size)
620{
621 if (max_size < PAGE_CACHE_SIZE) {
622 max_size = PAGE_CACHE_SIZE;
623 printk("%s: set to minimum %d\n", __FUNCTION__, max_size);
624 }
625
626 q->max_segment_size = max_size;
627}
628
629EXPORT_SYMBOL(blk_queue_max_segment_size);
630
631/**
632 * blk_queue_hardsect_size - set hardware sector size for the queue
633 * @q: the request queue for the device
634 * @size: the hardware sector size, in bytes
635 *
636 * Description:
637 * This should typically be set to the lowest possible sector size
638 * that the hardware can operate on (possible without reverting to
639 * even internal read-modify-write operations). Usually the default
640 * of 512 covers most hardware.
641 **/
642void blk_queue_hardsect_size(request_queue_t *q, unsigned short size)
643{
644 q->hardsect_size = size;
645}
646
647EXPORT_SYMBOL(blk_queue_hardsect_size);
648
649/*
650 * Returns the minimum that is _not_ zero, unless both are zero.
651 */
652#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
653
654/**
655 * blk_queue_stack_limits - inherit underlying queue limits for stacked drivers
656 * @t: the stacking driver (top)
657 * @b: the underlying device (bottom)
658 **/
659void blk_queue_stack_limits(request_queue_t *t, request_queue_t *b)
660{
661 /* zero is "infinity" */
662 t->max_sectors = t->max_hw_sectors =
663 min_not_zero(t->max_sectors,b->max_sectors);
664
665 t->max_phys_segments = min(t->max_phys_segments,b->max_phys_segments);
666 t->max_hw_segments = min(t->max_hw_segments,b->max_hw_segments);
667 t->max_segment_size = min(t->max_segment_size,b->max_segment_size);
668 t->hardsect_size = max(t->hardsect_size,b->hardsect_size);
669}
670
671EXPORT_SYMBOL(blk_queue_stack_limits);
672
673/**
674 * blk_queue_segment_boundary - set boundary rules for segment merging
675 * @q: the request queue for the device
676 * @mask: the memory boundary mask
677 **/
678void blk_queue_segment_boundary(request_queue_t *q, unsigned long mask)
679{
680 if (mask < PAGE_CACHE_SIZE - 1) {
681 mask = PAGE_CACHE_SIZE - 1;
682 printk("%s: set to minimum %lx\n", __FUNCTION__, mask);
683 }
684
685 q->seg_boundary_mask = mask;
686}
687
688EXPORT_SYMBOL(blk_queue_segment_boundary);
689
690/**
691 * blk_queue_dma_alignment - set dma length and memory alignment
692 * @q: the request queue for the device
693 * @mask: alignment mask
694 *
695 * description:
696 * set required memory and length aligment for direct dma transactions.
697 * this is used when buiding direct io requests for the queue.
698 *
699 **/
700void blk_queue_dma_alignment(request_queue_t *q, int mask)
701{
702 q->dma_alignment = mask;
703}
704
705EXPORT_SYMBOL(blk_queue_dma_alignment);
706
707/**
708 * blk_queue_find_tag - find a request by its tag and queue
709 *
710 * @q: The request queue for the device
711 * @tag: The tag of the request
712 *
713 * Notes:
714 * Should be used when a device returns a tag and you want to match
715 * it with a request.
716 *
717 * no locks need be held.
718 **/
719struct request *blk_queue_find_tag(request_queue_t *q, int tag)
720{
721 struct blk_queue_tag *bqt = q->queue_tags;
722
723 if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
724 return NULL;
725
726 return bqt->tag_index[tag];
727}
728
729EXPORT_SYMBOL(blk_queue_find_tag);
730
731/**
732 * __blk_queue_free_tags - release tag maintenance info
733 * @q: the request queue for the device
734 *
735 * Notes:
736 * blk_cleanup_queue() will take care of calling this function, if tagging
737 * has been used. So there's no need to call this directly.
738 **/
739static void __blk_queue_free_tags(request_queue_t *q)
740{
741 struct blk_queue_tag *bqt = q->queue_tags;
742
743 if (!bqt)
744 return;
745
746 if (atomic_dec_and_test(&bqt->refcnt)) {
747 BUG_ON(bqt->busy);
748 BUG_ON(!list_empty(&bqt->busy_list));
749
750 kfree(bqt->tag_index);
751 bqt->tag_index = NULL;
752
753 kfree(bqt->tag_map);
754 bqt->tag_map = NULL;
755
756 kfree(bqt);
757 }
758
759 q->queue_tags = NULL;
760 q->queue_flags &= ~(1 << QUEUE_FLAG_QUEUED);
761}
762
763/**
764 * blk_queue_free_tags - release tag maintenance info
765 * @q: the request queue for the device
766 *
767 * Notes:
768 * This is used to disabled tagged queuing to a device, yet leave
769 * queue in function.
770 **/
771void blk_queue_free_tags(request_queue_t *q)
772{
773 clear_bit(QUEUE_FLAG_QUEUED, &q->queue_flags);
774}
775
776EXPORT_SYMBOL(blk_queue_free_tags);
777
778static int
779init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth)
780{
781 struct request **tag_index;
782 unsigned long *tag_map;
783 int nr_ulongs;
784
785 if (depth > q->nr_requests * 2) {
786 depth = q->nr_requests * 2;
787 printk(KERN_ERR "%s: adjusted depth to %d\n",
788 __FUNCTION__, depth);
789 }
790
791 tag_index = kmalloc(depth * sizeof(struct request *), GFP_ATOMIC);
792 if (!tag_index)
793 goto fail;
794
795 nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG;
796 tag_map = kmalloc(nr_ulongs * sizeof(unsigned long), GFP_ATOMIC);
797 if (!tag_map)
798 goto fail;
799
800 memset(tag_index, 0, depth * sizeof(struct request *));
801 memset(tag_map, 0, nr_ulongs * sizeof(unsigned long));
802 tags->real_max_depth = depth;
803 tags->max_depth = depth;
804 tags->tag_index = tag_index;
805 tags->tag_map = tag_map;
806
807 return 0;
808fail:
809 kfree(tag_index);
810 return -ENOMEM;
811}
812
813/**
814 * blk_queue_init_tags - initialize the queue tag info
815 * @q: the request queue for the device
816 * @depth: the maximum queue depth supported
817 * @tags: the tag to use
818 **/
819int blk_queue_init_tags(request_queue_t *q, int depth,
820 struct blk_queue_tag *tags)
821{
822 int rc;
823
824 BUG_ON(tags && q->queue_tags && tags != q->queue_tags);
825
826 if (!tags && !q->queue_tags) {
827 tags = kmalloc(sizeof(struct blk_queue_tag), GFP_ATOMIC);
828 if (!tags)
829 goto fail;
830
831 if (init_tag_map(q, tags, depth))
832 goto fail;
833
834 INIT_LIST_HEAD(&tags->busy_list);
835 tags->busy = 0;
836 atomic_set(&tags->refcnt, 1);
837 } else if (q->queue_tags) {
838 if ((rc = blk_queue_resize_tags(q, depth)))
839 return rc;
840 set_bit(QUEUE_FLAG_QUEUED, &q->queue_flags);
841 return 0;
842 } else
843 atomic_inc(&tags->refcnt);
844
845 /*
846 * assign it, all done
847 */
848 q->queue_tags = tags;
849 q->queue_flags |= (1 << QUEUE_FLAG_QUEUED);
850 return 0;
851fail:
852 kfree(tags);
853 return -ENOMEM;
854}
855
856EXPORT_SYMBOL(blk_queue_init_tags);
857
858/**
859 * blk_queue_resize_tags - change the queueing depth
860 * @q: the request queue for the device
861 * @new_depth: the new max command queueing depth
862 *
863 * Notes:
864 * Must be called with the queue lock held.
865 **/
866int blk_queue_resize_tags(request_queue_t *q, int new_depth)
867{
868 struct blk_queue_tag *bqt = q->queue_tags;
869 struct request **tag_index;
870 unsigned long *tag_map;
871 int max_depth, nr_ulongs;
872
873 if (!bqt)
874 return -ENXIO;
875
876 /*
877 * if we already have large enough real_max_depth. just
878 * adjust max_depth. *NOTE* as requests with tag value
879 * between new_depth and real_max_depth can be in-flight, tag
880 * map can not be shrunk blindly here.
881 */
882 if (new_depth <= bqt->real_max_depth) {
883 bqt->max_depth = new_depth;
884 return 0;
885 }
886
887 /*
888 * save the old state info, so we can copy it back
889 */
890 tag_index = bqt->tag_index;
891 tag_map = bqt->tag_map;
892 max_depth = bqt->real_max_depth;
893
894 if (init_tag_map(q, bqt, new_depth))
895 return -ENOMEM;
896
897 memcpy(bqt->tag_index, tag_index, max_depth * sizeof(struct request *));
898 nr_ulongs = ALIGN(max_depth, BITS_PER_LONG) / BITS_PER_LONG;
899 memcpy(bqt->tag_map, tag_map, nr_ulongs * sizeof(unsigned long));
900
901 kfree(tag_index);
902 kfree(tag_map);
903 return 0;
904}
905
906EXPORT_SYMBOL(blk_queue_resize_tags);
907
908/**
909 * blk_queue_end_tag - end tag operations for a request
910 * @q: the request queue for the device
911 * @rq: the request that has completed
912 *
913 * Description:
914 * Typically called when end_that_request_first() returns 0, meaning
915 * all transfers have been done for a request. It's important to call
916 * this function before end_that_request_last(), as that will put the
917 * request back on the free list thus corrupting the internal tag list.
918 *
919 * Notes:
920 * queue lock must be held.
921 **/
922void blk_queue_end_tag(request_queue_t *q, struct request *rq)
923{
924 struct blk_queue_tag *bqt = q->queue_tags;
925 int tag = rq->tag;
926
927 BUG_ON(tag == -1);
928
929 if (unlikely(tag >= bqt->real_max_depth))
930 /*
931 * This can happen after tag depth has been reduced.
932 * FIXME: how about a warning or info message here?
933 */
934 return;
935
936 if (unlikely(!__test_and_clear_bit(tag, bqt->tag_map))) {
937 printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n",
938 __FUNCTION__, tag);
939 return;
940 }
941
942 list_del_init(&rq->queuelist);
943 rq->flags &= ~REQ_QUEUED;
944 rq->tag = -1;
945
946 if (unlikely(bqt->tag_index[tag] == NULL))
947 printk(KERN_ERR "%s: tag %d is missing\n",
948 __FUNCTION__, tag);
949
950 bqt->tag_index[tag] = NULL;
951 bqt->busy--;
952}
953
954EXPORT_SYMBOL(blk_queue_end_tag);
955
956/**
957 * blk_queue_start_tag - find a free tag and assign it
958 * @q: the request queue for the device
959 * @rq: the block request that needs tagging
960 *
961 * Description:
962 * This can either be used as a stand-alone helper, or possibly be
963 * assigned as the queue &prep_rq_fn (in which case &struct request
964 * automagically gets a tag assigned). Note that this function
965 * assumes that any type of request can be queued! if this is not
966 * true for your device, you must check the request type before
967 * calling this function. The request will also be removed from
968 * the request queue, so it's the drivers responsibility to readd
969 * it if it should need to be restarted for some reason.
970 *
971 * Notes:
972 * queue lock must be held.
973 **/
974int blk_queue_start_tag(request_queue_t *q, struct request *rq)
975{
976 struct blk_queue_tag *bqt = q->queue_tags;
977 int tag;
978
979 if (unlikely((rq->flags & REQ_QUEUED))) {
980 printk(KERN_ERR
981 "%s: request %p for device [%s] already tagged %d",
982 __FUNCTION__, rq,
983 rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag);
984 BUG();
985 }
986
987 tag = find_first_zero_bit(bqt->tag_map, bqt->max_depth);
988 if (tag >= bqt->max_depth)
989 return 1;
990
991 __set_bit(tag, bqt->tag_map);
992
993 rq->flags |= REQ_QUEUED;
994 rq->tag = tag;
995 bqt->tag_index[tag] = rq;
996 blkdev_dequeue_request(rq);
997 list_add(&rq->queuelist, &bqt->busy_list);
998 bqt->busy++;
999 return 0;
1000}
1001
1002EXPORT_SYMBOL(blk_queue_start_tag);
1003
1004/**
1005 * blk_queue_invalidate_tags - invalidate all pending tags
1006 * @q: the request queue for the device
1007 *
1008 * Description:
1009 * Hardware conditions may dictate a need to stop all pending requests.
1010 * In this case, we will safely clear the block side of the tag queue and
1011 * readd all requests to the request queue in the right order.
1012 *
1013 * Notes:
1014 * queue lock must be held.
1015 **/
1016void blk_queue_invalidate_tags(request_queue_t *q)
1017{
1018 struct blk_queue_tag *bqt = q->queue_tags;
1019 struct list_head *tmp, *n;
1020 struct request *rq;
1021
1022 list_for_each_safe(tmp, n, &bqt->busy_list) {
1023 rq = list_entry_rq(tmp);
1024
1025 if (rq->tag == -1) {
1026 printk(KERN_ERR
1027 "%s: bad tag found on list\n", __FUNCTION__);
1028 list_del_init(&rq->queuelist);
1029 rq->flags &= ~REQ_QUEUED;
1030 } else
1031 blk_queue_end_tag(q, rq);
1032
1033 rq->flags &= ~REQ_STARTED;
1034 __elv_add_request(q, rq, ELEVATOR_INSERT_BACK, 0);
1035 }
1036}
1037
1038EXPORT_SYMBOL(blk_queue_invalidate_tags);
1039
1040static char *rq_flags[] = {
1041 "REQ_RW",
1042 "REQ_FAILFAST",
1043 "REQ_SORTED",
1044 "REQ_SOFTBARRIER",
1045 "REQ_HARDBARRIER",
1046 "REQ_CMD",
1047 "REQ_NOMERGE",
1048 "REQ_STARTED",
1049 "REQ_DONTPREP",
1050 "REQ_QUEUED",
1051 "REQ_ELVPRIV",
1052 "REQ_PC",
1053 "REQ_BLOCK_PC",
1054 "REQ_SENSE",
1055 "REQ_FAILED",
1056 "REQ_QUIET",
1057 "REQ_SPECIAL",
1058 "REQ_DRIVE_CMD",
1059 "REQ_DRIVE_TASK",
1060 "REQ_DRIVE_TASKFILE",
1061 "REQ_PREEMPT",
1062 "REQ_PM_SUSPEND",
1063 "REQ_PM_RESUME",
1064 "REQ_PM_SHUTDOWN",
1065};
1066
1067void blk_dump_rq_flags(struct request *rq, char *msg)
1068{
1069 int bit;
1070
1071 printk("%s: dev %s: flags = ", msg,
1072 rq->rq_disk ? rq->rq_disk->disk_name : "?");
1073 bit = 0;
1074 do {
1075 if (rq->flags & (1 << bit))
1076 printk("%s ", rq_flags[bit]);
1077 bit++;
1078 } while (bit < __REQ_NR_BITS);
1079
1080 printk("\nsector %llu, nr/cnr %lu/%u\n", (unsigned long long)rq->sector,
1081 rq->nr_sectors,
1082 rq->current_nr_sectors);
1083 printk("bio %p, biotail %p, buffer %p, data %p, len %u\n", rq->bio, rq->biotail, rq->buffer, rq->data, rq->data_len);
1084
1085 if (rq->flags & (REQ_BLOCK_PC | REQ_PC)) {
1086 printk("cdb: ");
1087 for (bit = 0; bit < sizeof(rq->cmd); bit++)
1088 printk("%02x ", rq->cmd[bit]);
1089 printk("\n");
1090 }
1091}
1092
1093EXPORT_SYMBOL(blk_dump_rq_flags);
1094
1095void blk_recount_segments(request_queue_t *q, struct bio *bio)
1096{
1097 struct bio_vec *bv, *bvprv = NULL;
1098 int i, nr_phys_segs, nr_hw_segs, seg_size, hw_seg_size, cluster;
1099 int high, highprv = 1;
1100
1101 if (unlikely(!bio->bi_io_vec))
1102 return;
1103
1104 cluster = q->queue_flags & (1 << QUEUE_FLAG_CLUSTER);
1105 hw_seg_size = seg_size = nr_phys_segs = nr_hw_segs = 0;
1106 bio_for_each_segment(bv, bio, i) {
1107 /*
1108 * the trick here is making sure that a high page is never
1109 * considered part of another segment, since that might
1110 * change with the bounce page.
1111 */
1112 high = page_to_pfn(bv->bv_page) >= q->bounce_pfn;
1113 if (high || highprv)
1114 goto new_hw_segment;
1115 if (cluster) {
1116 if (seg_size + bv->bv_len > q->max_segment_size)
1117 goto new_segment;
1118 if (!BIOVEC_PHYS_MERGEABLE(bvprv, bv))
1119 goto new_segment;
1120 if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bv))
1121 goto new_segment;
1122 if (BIOVEC_VIRT_OVERSIZE(hw_seg_size + bv->bv_len))
1123 goto new_hw_segment;
1124
1125 seg_size += bv->bv_len;
1126 hw_seg_size += bv->bv_len;
1127 bvprv = bv;
1128 continue;
1129 }
1130new_segment:
1131 if (BIOVEC_VIRT_MERGEABLE(bvprv, bv) &&
1132 !BIOVEC_VIRT_OVERSIZE(hw_seg_size + bv->bv_len)) {
1133 hw_seg_size += bv->bv_len;
1134 } else {
1135new_hw_segment:
1136 if (hw_seg_size > bio->bi_hw_front_size)
1137 bio->bi_hw_front_size = hw_seg_size;
1138 hw_seg_size = BIOVEC_VIRT_START_SIZE(bv) + bv->bv_len;
1139 nr_hw_segs++;
1140 }
1141
1142 nr_phys_segs++;
1143 bvprv = bv;
1144 seg_size = bv->bv_len;
1145 highprv = high;
1146 }
1147 if (hw_seg_size > bio->bi_hw_back_size)
1148 bio->bi_hw_back_size = hw_seg_size;
1149 if (nr_hw_segs == 1 && hw_seg_size > bio->bi_hw_front_size)
1150 bio->bi_hw_front_size = hw_seg_size;
1151 bio->bi_phys_segments = nr_phys_segs;
1152 bio->bi_hw_segments = nr_hw_segs;
1153 bio->bi_flags |= (1 << BIO_SEG_VALID);
1154}
1155
1156
1157static int blk_phys_contig_segment(request_queue_t *q, struct bio *bio,
1158 struct bio *nxt)
1159{
1160 if (!(q->queue_flags & (1 << QUEUE_FLAG_CLUSTER)))
1161 return 0;
1162
1163 if (!BIOVEC_PHYS_MERGEABLE(__BVEC_END(bio), __BVEC_START(nxt)))
1164 return 0;
1165 if (bio->bi_size + nxt->bi_size > q->max_segment_size)
1166 return 0;
1167
1168 /*
1169 * bio and nxt are contigous in memory, check if the queue allows
1170 * these two to be merged into one
1171 */
1172 if (BIO_SEG_BOUNDARY(q, bio, nxt))
1173 return 1;
1174
1175 return 0;
1176}
1177
1178static int blk_hw_contig_segment(request_queue_t *q, struct bio *bio,
1179 struct bio *nxt)
1180{
1181 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID)))
1182 blk_recount_segments(q, bio);
1183 if (unlikely(!bio_flagged(nxt, BIO_SEG_VALID)))
1184 blk_recount_segments(q, nxt);
1185 if (!BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), __BVEC_START(nxt)) ||
1186 BIOVEC_VIRT_OVERSIZE(bio->bi_hw_front_size + bio->bi_hw_back_size))
1187 return 0;
1188 if (bio->bi_size + nxt->bi_size > q->max_segment_size)
1189 return 0;
1190
1191 return 1;
1192}
1193
1194/*
1195 * map a request to scatterlist, return number of sg entries setup. Caller
1196 * must make sure sg can hold rq->nr_phys_segments entries
1197 */
1198int blk_rq_map_sg(request_queue_t *q, struct request *rq, struct scatterlist *sg)
1199{
1200 struct bio_vec *bvec, *bvprv;
1201 struct bio *bio;
1202 int nsegs, i, cluster;
1203
1204 nsegs = 0;
1205 cluster = q->queue_flags & (1 << QUEUE_FLAG_CLUSTER);
1206
1207 /*
1208 * for each bio in rq
1209 */
1210 bvprv = NULL;
1211 rq_for_each_bio(bio, rq) {
1212 /*
1213 * for each segment in bio
1214 */
1215 bio_for_each_segment(bvec, bio, i) {
1216 int nbytes = bvec->bv_len;
1217
1218 if (bvprv && cluster) {
1219 if (sg[nsegs - 1].length + nbytes > q->max_segment_size)
1220 goto new_segment;
1221
1222 if (!BIOVEC_PHYS_MERGEABLE(bvprv, bvec))
1223 goto new_segment;
1224 if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bvec))
1225 goto new_segment;
1226
1227 sg[nsegs - 1].length += nbytes;
1228 } else {
1229new_segment:
1230 memset(&sg[nsegs],0,sizeof(struct scatterlist));
1231 sg[nsegs].page = bvec->bv_page;
1232 sg[nsegs].length = nbytes;
1233 sg[nsegs].offset = bvec->bv_offset;
1234
1235 nsegs++;
1236 }
1237 bvprv = bvec;
1238 } /* segments in bio */
1239 } /* bios in rq */
1240
1241 return nsegs;
1242}
1243
1244EXPORT_SYMBOL(blk_rq_map_sg);
1245
1246/*
1247 * the standard queue merge functions, can be overridden with device
1248 * specific ones if so desired
1249 */
1250
1251static inline int ll_new_mergeable(request_queue_t *q,
1252 struct request *req,
1253 struct bio *bio)
1254{
1255 int nr_phys_segs = bio_phys_segments(q, bio);
1256
1257 if (req->nr_phys_segments + nr_phys_segs > q->max_phys_segments) {
1258 req->flags |= REQ_NOMERGE;
1259 if (req == q->last_merge)
1260 q->last_merge = NULL;
1261 return 0;
1262 }
1263
1264 /*
1265 * A hw segment is just getting larger, bump just the phys
1266 * counter.
1267 */
1268 req->nr_phys_segments += nr_phys_segs;
1269 return 1;
1270}
1271
1272static inline int ll_new_hw_segment(request_queue_t *q,
1273 struct request *req,
1274 struct bio *bio)
1275{
1276 int nr_hw_segs = bio_hw_segments(q, bio);
1277 int nr_phys_segs = bio_phys_segments(q, bio);
1278
1279 if (req->nr_hw_segments + nr_hw_segs > q->max_hw_segments
1280 || req->nr_phys_segments + nr_phys_segs > q->max_phys_segments) {
1281 req->flags |= REQ_NOMERGE;
1282 if (req == q->last_merge)
1283 q->last_merge = NULL;
1284 return 0;
1285 }
1286
1287 /*
1288 * This will form the start of a new hw segment. Bump both
1289 * counters.
1290 */
1291 req->nr_hw_segments += nr_hw_segs;
1292 req->nr_phys_segments += nr_phys_segs;
1293 return 1;
1294}
1295
1296static int ll_back_merge_fn(request_queue_t *q, struct request *req,
1297 struct bio *bio)
1298{
1299 int len;
1300
1301 if (req->nr_sectors + bio_sectors(bio) > q->max_sectors) {
1302 req->flags |= REQ_NOMERGE;
1303 if (req == q->last_merge)
1304 q->last_merge = NULL;
1305 return 0;
1306 }
1307 if (unlikely(!bio_flagged(req->biotail, BIO_SEG_VALID)))
1308 blk_recount_segments(q, req->biotail);
1309 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID)))
1310 blk_recount_segments(q, bio);
1311 len = req->biotail->bi_hw_back_size + bio->bi_hw_front_size;
1312 if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(req->biotail), __BVEC_START(bio)) &&
1313 !BIOVEC_VIRT_OVERSIZE(len)) {
1314 int mergeable = ll_new_mergeable(q, req, bio);
1315
1316 if (mergeable) {
1317 if (req->nr_hw_segments == 1)
1318 req->bio->bi_hw_front_size = len;
1319 if (bio->bi_hw_segments == 1)
1320 bio->bi_hw_back_size = len;
1321 }
1322 return mergeable;
1323 }
1324
1325 return ll_new_hw_segment(q, req, bio);
1326}
1327
1328static int ll_front_merge_fn(request_queue_t *q, struct request *req,
1329 struct bio *bio)
1330{
1331 int len;
1332
1333 if (req->nr_sectors + bio_sectors(bio) > q->max_sectors) {
1334 req->flags |= REQ_NOMERGE;
1335 if (req == q->last_merge)
1336 q->last_merge = NULL;
1337 return 0;
1338 }
1339 len = bio->bi_hw_back_size + req->bio->bi_hw_front_size;
1340 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID)))
1341 blk_recount_segments(q, bio);
1342 if (unlikely(!bio_flagged(req->bio, BIO_SEG_VALID)))
1343 blk_recount_segments(q, req->bio);
1344 if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), __BVEC_START(req->bio)) &&
1345 !BIOVEC_VIRT_OVERSIZE(len)) {
1346 int mergeable = ll_new_mergeable(q, req, bio);
1347
1348 if (mergeable) {
1349 if (bio->bi_hw_segments == 1)
1350 bio->bi_hw_front_size = len;
1351 if (req->nr_hw_segments == 1)
1352 req->biotail->bi_hw_back_size = len;
1353 }
1354 return mergeable;
1355 }
1356
1357 return ll_new_hw_segment(q, req, bio);
1358}
1359
1360static int ll_merge_requests_fn(request_queue_t *q, struct request *req,
1361 struct request *next)
1362{
1363 int total_phys_segments;
1364 int total_hw_segments;
1365
1366 /*
1367 * First check if the either of the requests are re-queued
1368 * requests. Can't merge them if they are.
1369 */
1370 if (req->special || next->special)
1371 return 0;
1372
1373 /*
1374 * Will it become too large?
1375 */
1376 if ((req->nr_sectors + next->nr_sectors) > q->max_sectors)
1377 return 0;
1378
1379 total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
1380 if (blk_phys_contig_segment(q, req->biotail, next->bio))
1381 total_phys_segments--;
1382
1383 if (total_phys_segments > q->max_phys_segments)
1384 return 0;
1385
1386 total_hw_segments = req->nr_hw_segments + next->nr_hw_segments;
1387 if (blk_hw_contig_segment(q, req->biotail, next->bio)) {
1388 int len = req->biotail->bi_hw_back_size + next->bio->bi_hw_front_size;
1389 /*
1390 * propagate the combined length to the end of the requests
1391 */
1392 if (req->nr_hw_segments == 1)
1393 req->bio->bi_hw_front_size = len;
1394 if (next->nr_hw_segments == 1)
1395 next->biotail->bi_hw_back_size = len;
1396 total_hw_segments--;
1397 }
1398
1399 if (total_hw_segments > q->max_hw_segments)
1400 return 0;
1401
1402 /* Merge is OK... */
1403 req->nr_phys_segments = total_phys_segments;
1404 req->nr_hw_segments = total_hw_segments;
1405 return 1;
1406}
1407
1408/*
1409 * "plug" the device if there are no outstanding requests: this will
1410 * force the transfer to start only after we have put all the requests
1411 * on the list.
1412 *
1413 * This is called with interrupts off and no requests on the queue and
1414 * with the queue lock held.
1415 */
1416void blk_plug_device(request_queue_t *q)
1417{
1418 WARN_ON(!irqs_disabled());
1419
1420 /*
1421 * don't plug a stopped queue, it must be paired with blk_start_queue()
1422 * which will restart the queueing
1423 */
1424 if (test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags))
1425 return;
1426
1427 if (!test_and_set_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags))
1428 mod_timer(&q->unplug_timer, jiffies + q->unplug_delay);
1429}
1430
1431EXPORT_SYMBOL(blk_plug_device);
1432
1433/*
1434 * remove the queue from the plugged list, if present. called with
1435 * queue lock held and interrupts disabled.
1436 */
1437int blk_remove_plug(request_queue_t *q)
1438{
1439 WARN_ON(!irqs_disabled());
1440
1441 if (!test_and_clear_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags))
1442 return 0;
1443
1444 del_timer(&q->unplug_timer);
1445 return 1;
1446}
1447
1448EXPORT_SYMBOL(blk_remove_plug);
1449
1450/*
1451 * remove the plug and let it rip..
1452 */
1453void __generic_unplug_device(request_queue_t *q)
1454{
1455 if (unlikely(test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags)))
1456 return;
1457
1458 if (!blk_remove_plug(q))
1459 return;
1460
1461 q->request_fn(q);
1462}
1463EXPORT_SYMBOL(__generic_unplug_device);
1464
1465/**
1466 * generic_unplug_device - fire a request queue
1467 * @q: The &request_queue_t in question
1468 *
1469 * Description:
1470 * Linux uses plugging to build bigger requests queues before letting
1471 * the device have at them. If a queue is plugged, the I/O scheduler
1472 * is still adding and merging requests on the queue. Once the queue
1473 * gets unplugged, the request_fn defined for the queue is invoked and
1474 * transfers started.
1475 **/
1476void generic_unplug_device(request_queue_t *q)
1477{
1478 spin_lock_irq(q->queue_lock);
1479 __generic_unplug_device(q);
1480 spin_unlock_irq(q->queue_lock);
1481}
1482EXPORT_SYMBOL(generic_unplug_device);
1483
1484static void blk_backing_dev_unplug(struct backing_dev_info *bdi,
1485 struct page *page)
1486{
1487 request_queue_t *q = bdi->unplug_io_data;
1488
1489 /*
1490 * devices don't necessarily have an ->unplug_fn defined
1491 */
1492 if (q->unplug_fn)
1493 q->unplug_fn(q);
1494}
1495
1496static void blk_unplug_work(void *data)
1497{
1498 request_queue_t *q = data;
1499
1500 q->unplug_fn(q);
1501}
1502
1503static void blk_unplug_timeout(unsigned long data)
1504{
1505 request_queue_t *q = (request_queue_t *)data;
1506
1507 kblockd_schedule_work(&q->unplug_work);
1508}
1509
1510/**
1511 * blk_start_queue - restart a previously stopped queue
1512 * @q: The &request_queue_t in question
1513 *
1514 * Description:
1515 * blk_start_queue() will clear the stop flag on the queue, and call
1516 * the request_fn for the queue if it was in a stopped state when
1517 * entered. Also see blk_stop_queue(). Queue lock must be held.
1518 **/
1519void blk_start_queue(request_queue_t *q)
1520{
1521 clear_bit(QUEUE_FLAG_STOPPED, &q->queue_flags);
1522
1523 /*
1524 * one level of recursion is ok and is much faster than kicking
1525 * the unplug handling
1526 */
1527 if (!test_and_set_bit(QUEUE_FLAG_REENTER, &q->queue_flags)) {
1528 q->request_fn(q);
1529 clear_bit(QUEUE_FLAG_REENTER, &q->queue_flags);
1530 } else {
1531 blk_plug_device(q);
1532 kblockd_schedule_work(&q->unplug_work);
1533 }
1534}
1535
1536EXPORT_SYMBOL(blk_start_queue);
1537
1538/**
1539 * blk_stop_queue - stop a queue
1540 * @q: The &request_queue_t in question
1541 *
1542 * Description:
1543 * The Linux block layer assumes that a block driver will consume all
1544 * entries on the request queue when the request_fn strategy is called.
1545 * Often this will not happen, because of hardware limitations (queue
1546 * depth settings). If a device driver gets a 'queue full' response,
1547 * or if it simply chooses not to queue more I/O at one point, it can
1548 * call this function to prevent the request_fn from being called until
1549 * the driver has signalled it's ready to go again. This happens by calling
1550 * blk_start_queue() to restart queue operations. Queue lock must be held.
1551 **/
1552void blk_stop_queue(request_queue_t *q)
1553{
1554 blk_remove_plug(q);
1555 set_bit(QUEUE_FLAG_STOPPED, &q->queue_flags);
1556}
1557EXPORT_SYMBOL(blk_stop_queue);
1558
1559/**
1560 * blk_sync_queue - cancel any pending callbacks on a queue
1561 * @q: the queue
1562 *
1563 * Description:
1564 * The block layer may perform asynchronous callback activity
1565 * on a queue, such as calling the unplug function after a timeout.
1566 * A block device may call blk_sync_queue to ensure that any
1567 * such activity is cancelled, thus allowing it to release resources
1568 * the the callbacks might use. The caller must already have made sure
1569 * that its ->make_request_fn will not re-add plugging prior to calling
1570 * this function.
1571 *
1572 */
1573void blk_sync_queue(struct request_queue *q)
1574{
1575 del_timer_sync(&q->unplug_timer);
1576 kblockd_flush();
1577}
1578EXPORT_SYMBOL(blk_sync_queue);
1579
1580/**
1581 * blk_run_queue - run a single device queue
1582 * @q: The queue to run
1583 */
1584void blk_run_queue(struct request_queue *q)
1585{
1586 unsigned long flags;
1587
1588 spin_lock_irqsave(q->queue_lock, flags);
1589 blk_remove_plug(q);
1590 if (!elv_queue_empty(q))
1591 q->request_fn(q);
1592 spin_unlock_irqrestore(q->queue_lock, flags);
1593}
1594EXPORT_SYMBOL(blk_run_queue);
1595
1596/**
1597 * blk_cleanup_queue: - release a &request_queue_t when it is no longer needed
1598 * @q: the request queue to be released
1599 *
1600 * Description:
1601 * blk_cleanup_queue is the pair to blk_init_queue() or
1602 * blk_queue_make_request(). It should be called when a request queue is
1603 * being released; typically when a block device is being de-registered.
1604 * Currently, its primary task it to free all the &struct request
1605 * structures that were allocated to the queue and the queue itself.
1606 *
1607 * Caveat:
1608 * Hopefully the low level driver will have finished any
1609 * outstanding requests first...
1610 **/
1611void blk_cleanup_queue(request_queue_t * q)
1612{
1613 struct request_list *rl = &q->rq;
1614
1615 if (!atomic_dec_and_test(&q->refcnt))
1616 return;
1617
1618 if (q->elevator)
1619 elevator_exit(q->elevator);
1620
1621 blk_sync_queue(q);
1622
1623 if (rl->rq_pool)
1624 mempool_destroy(rl->rq_pool);
1625
1626 if (q->queue_tags)
1627 __blk_queue_free_tags(q);
1628
1629 blk_queue_ordered(q, QUEUE_ORDERED_NONE);
1630
1631 kmem_cache_free(requestq_cachep, q);
1632}
1633
1634EXPORT_SYMBOL(blk_cleanup_queue);
1635
1636static int blk_init_free_list(request_queue_t *q)
1637{
1638 struct request_list *rl = &q->rq;
1639
1640 rl->count[READ] = rl->count[WRITE] = 0;
1641 rl->starved[READ] = rl->starved[WRITE] = 0;
1642 rl->elvpriv = 0;
1643 init_waitqueue_head(&rl->wait[READ]);
1644 init_waitqueue_head(&rl->wait[WRITE]);
1645
1646 rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
1647 mempool_free_slab, request_cachep, q->node);
1648
1649 if (!rl->rq_pool)
1650 return -ENOMEM;
1651
1652 return 0;
1653}
1654
1655static int __make_request(request_queue_t *, struct bio *);
1656
1657request_queue_t *blk_alloc_queue(gfp_t gfp_mask)
1658{
1659 return blk_alloc_queue_node(gfp_mask, -1);
1660}
1661EXPORT_SYMBOL(blk_alloc_queue);
1662
1663request_queue_t *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
1664{
1665 request_queue_t *q;
1666
1667 q = kmem_cache_alloc_node(requestq_cachep, gfp_mask, node_id);
1668 if (!q)
1669 return NULL;
1670
1671 memset(q, 0, sizeof(*q));
1672 init_timer(&q->unplug_timer);
1673 atomic_set(&q->refcnt, 1);
1674
1675 q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug;
1676 q->backing_dev_info.unplug_io_data = q;
1677
1678 return q;
1679}
1680EXPORT_SYMBOL(blk_alloc_queue_node);
1681
1682/**
1683 * blk_init_queue - prepare a request queue for use with a block device
1684 * @rfn: The function to be called to process requests that have been
1685 * placed on the queue.
1686 * @lock: Request queue spin lock
1687 *
1688 * Description:
1689 * If a block device wishes to use the standard request handling procedures,
1690 * which sorts requests and coalesces adjacent requests, then it must
1691 * call blk_init_queue(). The function @rfn will be called when there
1692 * are requests on the queue that need to be processed. If the device
1693 * supports plugging, then @rfn may not be called immediately when requests
1694 * are available on the queue, but may be called at some time later instead.
1695 * Plugged queues are generally unplugged when a buffer belonging to one
1696 * of the requests on the queue is needed, or due to memory pressure.
1697 *
1698 * @rfn is not required, or even expected, to remove all requests off the
1699 * queue, but only as many as it can handle at a time. If it does leave
1700 * requests on the queue, it is responsible for arranging that the requests
1701 * get dealt with eventually.
1702 *
1703 * The queue spin lock must be held while manipulating the requests on the
1704 * request queue.
1705 *
1706 * Function returns a pointer to the initialized request queue, or NULL if
1707 * it didn't succeed.
1708 *
1709 * Note:
1710 * blk_init_queue() must be paired with a blk_cleanup_queue() call
1711 * when the block device is deactivated (such as at module unload).
1712 **/
1713
1714request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock)
1715{
1716 return blk_init_queue_node(rfn, lock, -1);
1717}
1718EXPORT_SYMBOL(blk_init_queue);
1719
1720request_queue_t *
1721blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
1722{
1723 request_queue_t *q = blk_alloc_queue_node(GFP_KERNEL, node_id);
1724
1725 if (!q)
1726 return NULL;
1727
1728 q->node = node_id;
1729 if (blk_init_free_list(q))
1730 goto out_init;
1731
1732 /*
1733 * if caller didn't supply a lock, they get per-queue locking with
1734 * our embedded lock
1735 */
1736 if (!lock) {
1737 spin_lock_init(&q->__queue_lock);
1738 lock = &q->__queue_lock;
1739 }
1740
1741 q->request_fn = rfn;
1742 q->back_merge_fn = ll_back_merge_fn;
1743 q->front_merge_fn = ll_front_merge_fn;
1744 q->merge_requests_fn = ll_merge_requests_fn;
1745 q->prep_rq_fn = NULL;
1746 q->unplug_fn = generic_unplug_device;
1747 q->queue_flags = (1 << QUEUE_FLAG_CLUSTER);
1748 q->queue_lock = lock;
1749
1750 blk_queue_segment_boundary(q, 0xffffffff);
1751
1752 blk_queue_make_request(q, __make_request);
1753 blk_queue_max_segment_size(q, MAX_SEGMENT_SIZE);
1754
1755 blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
1756 blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
1757
1758 /*
1759 * all done
1760 */
1761 if (!elevator_init(q, NULL)) {
1762 blk_queue_congestion_threshold(q);
1763 return q;
1764 }
1765
1766 blk_cleanup_queue(q);
1767out_init:
1768 kmem_cache_free(requestq_cachep, q);
1769 return NULL;
1770}
1771EXPORT_SYMBOL(blk_init_queue_node);
1772
1773int blk_get_queue(request_queue_t *q)
1774{
1775 if (likely(!test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
1776 atomic_inc(&q->refcnt);
1777 return 0;
1778 }
1779
1780 return 1;
1781}
1782
1783EXPORT_SYMBOL(blk_get_queue);
1784
1785static inline void blk_free_request(request_queue_t *q, struct request *rq)
1786{
1787 if (rq->flags & REQ_ELVPRIV)
1788 elv_put_request(q, rq);
1789 mempool_free(rq, q->rq.rq_pool);
1790}
1791
1792static inline struct request *
1793blk_alloc_request(request_queue_t *q, int rw, struct bio *bio,
1794 int priv, gfp_t gfp_mask)
1795{
1796 struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask);
1797
1798 if (!rq)
1799 return NULL;
1800
1801 /*
1802 * first three bits are identical in rq->flags and bio->bi_rw,
1803 * see bio.h and blkdev.h
1804 */
1805 rq->flags = rw;
1806
1807 if (priv) {
1808 if (unlikely(elv_set_request(q, rq, bio, gfp_mask))) {
1809 mempool_free(rq, q->rq.rq_pool);
1810 return NULL;
1811 }
1812 rq->flags |= REQ_ELVPRIV;
1813 }
1814
1815 return rq;
1816}
1817
1818/*
1819 * ioc_batching returns true if the ioc is a valid batching request and
1820 * should be given priority access to a request.
1821 */
1822static inline int ioc_batching(request_queue_t *q, struct io_context *ioc)
1823{
1824 if (!ioc)
1825 return 0;
1826
1827 /*
1828 * Make sure the process is able to allocate at least 1 request
1829 * even if the batch times out, otherwise we could theoretically
1830 * lose wakeups.
1831 */
1832 return ioc->nr_batch_requests == q->nr_batching ||
1833 (ioc->nr_batch_requests > 0
1834 && time_before(jiffies, ioc->last_waited + BLK_BATCH_TIME));
1835}
1836
1837/*
1838 * ioc_set_batching sets ioc to be a new "batcher" if it is not one. This
1839 * will cause the process to be a "batcher" on all queues in the system. This
1840 * is the behaviour we want though - once it gets a wakeup it should be given
1841 * a nice run.
1842 */
1843static void ioc_set_batching(request_queue_t *q, struct io_context *ioc)
1844{
1845 if (!ioc || ioc_batching(q, ioc))
1846 return;
1847
1848 ioc->nr_batch_requests = q->nr_batching;
1849 ioc->last_waited = jiffies;
1850}
1851
1852static void __freed_request(request_queue_t *q, int rw)
1853{
1854 struct request_list *rl = &q->rq;
1855
1856 if (rl->count[rw] < queue_congestion_off_threshold(q))
1857 clear_queue_congested(q, rw);
1858
1859 if (rl->count[rw] + 1 <= q->nr_requests) {
1860 if (waitqueue_active(&rl->wait[rw]))
1861 wake_up(&rl->wait[rw]);
1862
1863 blk_clear_queue_full(q, rw);
1864 }
1865}
1866
1867/*
1868 * A request has just been released. Account for it, update the full and
1869 * congestion status, wake up any waiters. Called under q->queue_lock.
1870 */
1871static void freed_request(request_queue_t *q, int rw, int priv)
1872{
1873 struct request_list *rl = &q->rq;
1874
1875 rl->count[rw]--;
1876 if (priv)
1877 rl->elvpriv--;
1878
1879 __freed_request(q, rw);
1880
1881 if (unlikely(rl->starved[rw ^ 1]))
1882 __freed_request(q, rw ^ 1);
1883}
1884
1885#define blkdev_free_rq(list) list_entry((list)->next, struct request, queuelist)
1886/*
1887 * Get a free request, queue_lock must be held.
1888 * Returns NULL on failure, with queue_lock held.
1889 * Returns !NULL on success, with queue_lock *not held*.
1890 */
1891static struct request *get_request(request_queue_t *q, int rw, struct bio *bio,
1892 gfp_t gfp_mask)
1893{
1894 struct request *rq = NULL;
1895 struct request_list *rl = &q->rq;
1896 struct io_context *ioc = current_io_context(GFP_ATOMIC);
1897 int priv;
1898
1899 if (rl->count[rw]+1 >= q->nr_requests) {
1900 /*
1901 * The queue will fill after this allocation, so set it as
1902 * full, and mark this process as "batching". This process
1903 * will be allowed to complete a batch of requests, others
1904 * will be blocked.
1905 */
1906 if (!blk_queue_full(q, rw)) {
1907 ioc_set_batching(q, ioc);
1908 blk_set_queue_full(q, rw);
1909 }
1910 }
1911
1912 switch (elv_may_queue(q, rw, bio)) {
1913 case ELV_MQUEUE_NO:
1914 goto rq_starved;
1915 case ELV_MQUEUE_MAY:
1916 break;
1917 case ELV_MQUEUE_MUST:
1918 goto get_rq;
1919 }
1920
1921 if (blk_queue_full(q, rw) && !ioc_batching(q, ioc)) {
1922 /*
1923 * The queue is full and the allocating process is not a
1924 * "batcher", and not exempted by the IO scheduler
1925 */
1926 goto out;
1927 }
1928
1929get_rq:
1930 /*
1931 * Only allow batching queuers to allocate up to 50% over the defined
1932 * limit of requests, otherwise we could have thousands of requests
1933 * allocated with any setting of ->nr_requests
1934 */
1935 if (rl->count[rw] >= (3 * q->nr_requests / 2))
1936 goto out;
1937
1938 rl->count[rw]++;
1939 rl->starved[rw] = 0;
1940 if (rl->count[rw] >= queue_congestion_on_threshold(q))
1941 set_queue_congested(q, rw);
1942
1943 priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
1944 if (priv)
1945 rl->elvpriv++;
1946
1947 spin_unlock_irq(q->queue_lock);
1948
1949 rq = blk_alloc_request(q, rw, bio, priv, gfp_mask);
1950 if (!rq) {
1951 /*
1952 * Allocation failed presumably due to memory. Undo anything
1953 * we might have messed up.
1954 *
1955 * Allocating task should really be put onto the front of the
1956 * wait queue, but this is pretty rare.
1957 */
1958 spin_lock_irq(q->queue_lock);
1959 freed_request(q, rw, priv);
1960
1961 /*
1962 * in the very unlikely event that allocation failed and no
1963 * requests for this direction was pending, mark us starved
1964 * so that freeing of a request in the other direction will
1965 * notice us. another possible fix would be to split the
1966 * rq mempool into READ and WRITE
1967 */
1968rq_starved:
1969 if (unlikely(rl->count[rw] == 0))
1970 rl->starved[rw] = 1;
1971
1972 goto out;
1973 }
1974
1975 if (ioc_batching(q, ioc))
1976 ioc->nr_batch_requests--;
1977
1978 rq_init(q, rq);
1979 rq->rl = rl;
1980out:
1981 return rq;
1982}
1983
1984/*
1985 * No available requests for this queue, unplug the device and wait for some
1986 * requests to become available.
1987 *
1988 * Called with q->queue_lock held, and returns with it unlocked.
1989 */
1990static struct request *get_request_wait(request_queue_t *q, int rw,
1991 struct bio *bio)
1992{
1993 struct request *rq;
1994
1995 rq = get_request(q, rw, bio, GFP_NOIO);
1996 while (!rq) {
1997 DEFINE_WAIT(wait);
1998 struct request_list *rl = &q->rq;
1999
2000 prepare_to_wait_exclusive(&rl->wait[rw], &wait,
2001 TASK_UNINTERRUPTIBLE);
2002
2003 rq = get_request(q, rw, bio, GFP_NOIO);
2004
2005 if (!rq) {
2006 struct io_context *ioc;
2007
2008 __generic_unplug_device(q);
2009 spin_unlock_irq(q->queue_lock);
2010 io_schedule();
2011
2012 /*
2013 * After sleeping, we become a "batching" process and
2014 * will be able to allocate at least one request, and
2015 * up to a big batch of them for a small period time.
2016 * See ioc_batching, ioc_set_batching
2017 */
2018 ioc = current_io_context(GFP_NOIO);
2019 ioc_set_batching(q, ioc);
2020
2021 spin_lock_irq(q->queue_lock);
2022 }
2023 finish_wait(&rl->wait[rw], &wait);
2024 }
2025
2026 return rq;
2027}
2028
2029struct request *blk_get_request(request_queue_t *q, int rw, gfp_t gfp_mask)
2030{
2031 struct request *rq;
2032
2033 BUG_ON(rw != READ && rw != WRITE);
2034
2035 spin_lock_irq(q->queue_lock);
2036 if (gfp_mask & __GFP_WAIT) {
2037 rq = get_request_wait(q, rw, NULL);
2038 } else {
2039 rq = get_request(q, rw, NULL, gfp_mask);
2040 if (!rq)
2041 spin_unlock_irq(q->queue_lock);
2042 }
2043 /* q->queue_lock is unlocked at this point */
2044
2045 return rq;
2046}
2047EXPORT_SYMBOL(blk_get_request);
2048
2049/**
2050 * blk_requeue_request - put a request back on queue
2051 * @q: request queue where request should be inserted
2052 * @rq: request to be inserted
2053 *
2054 * Description:
2055 * Drivers often keep queueing requests until the hardware cannot accept
2056 * more, when that condition happens we need to put the request back
2057 * on the queue. Must be called with queue lock held.
2058 */
2059void blk_requeue_request(request_queue_t *q, struct request *rq)
2060{
2061 if (blk_rq_tagged(rq))
2062 blk_queue_end_tag(q, rq);
2063
2064 elv_requeue_request(q, rq);
2065}
2066
2067EXPORT_SYMBOL(blk_requeue_request);
2068
2069/**
2070 * blk_insert_request - insert a special request in to a request queue
2071 * @q: request queue where request should be inserted
2072 * @rq: request to be inserted
2073 * @at_head: insert request at head or tail of queue
2074 * @data: private data
2075 *
2076 * Description:
2077 * Many block devices need to execute commands asynchronously, so they don't
2078 * block the whole kernel from preemption during request execution. This is
2079 * accomplished normally by inserting aritficial requests tagged as
2080 * REQ_SPECIAL in to the corresponding request queue, and letting them be
2081 * scheduled for actual execution by the request queue.
2082 *
2083 * We have the option of inserting the head or the tail of the queue.
2084 * Typically we use the tail for new ioctls and so forth. We use the head
2085 * of the queue for things like a QUEUE_FULL message from a device, or a
2086 * host that is unable to accept a particular command.
2087 */
2088void blk_insert_request(request_queue_t *q, struct request *rq,
2089 int at_head, void *data)
2090{
2091 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
2092 unsigned long flags;
2093
2094 /*
2095 * tell I/O scheduler that this isn't a regular read/write (ie it
2096 * must not attempt merges on this) and that it acts as a soft
2097 * barrier
2098 */
2099 rq->flags |= REQ_SPECIAL | REQ_SOFTBARRIER;
2100
2101 rq->special = data;
2102
2103 spin_lock_irqsave(q->queue_lock, flags);
2104
2105 /*
2106 * If command is tagged, release the tag
2107 */
2108 if (blk_rq_tagged(rq))
2109 blk_queue_end_tag(q, rq);
2110
2111 drive_stat_acct(rq, rq->nr_sectors, 1);
2112 __elv_add_request(q, rq, where, 0);
2113
2114 if (blk_queue_plugged(q))
2115 __generic_unplug_device(q);
2116 else
2117 q->request_fn(q);
2118 spin_unlock_irqrestore(q->queue_lock, flags);
2119}
2120
2121EXPORT_SYMBOL(blk_insert_request);
2122
2123/**
2124 * blk_rq_map_user - map user data to a request, for REQ_BLOCK_PC usage
2125 * @q: request queue where request should be inserted
2126 * @rq: request structure to fill
2127 * @ubuf: the user buffer
2128 * @len: length of user data
2129 *
2130 * Description:
2131 * Data will be mapped directly for zero copy io, if possible. Otherwise
2132 * a kernel bounce buffer is used.
2133 *
2134 * A matching blk_rq_unmap_user() must be issued at the end of io, while
2135 * still in process context.
2136 *
2137 * Note: The mapped bio may need to be bounced through blk_queue_bounce()
2138 * before being submitted to the device, as pages mapped may be out of
2139 * reach. It's the callers responsibility to make sure this happens. The
2140 * original bio must be passed back in to blk_rq_unmap_user() for proper
2141 * unmapping.
2142 */
2143int blk_rq_map_user(request_queue_t *q, struct request *rq, void __user *ubuf,
2144 unsigned int len)
2145{
2146 unsigned long uaddr;
2147 struct bio *bio;
2148 int reading;
2149
2150 if (len > (q->max_sectors << 9))
2151 return -EINVAL;
2152 if (!len || !ubuf)
2153 return -EINVAL;
2154
2155 reading = rq_data_dir(rq) == READ;
2156
2157 /*
2158 * if alignment requirement is satisfied, map in user pages for
2159 * direct dma. else, set up kernel bounce buffers
2160 */
2161 uaddr = (unsigned long) ubuf;
2162 if (!(uaddr & queue_dma_alignment(q)) && !(len & queue_dma_alignment(q)))
2163 bio = bio_map_user(q, NULL, uaddr, len, reading);
2164 else
2165 bio = bio_copy_user(q, uaddr, len, reading);
2166
2167 if (!IS_ERR(bio)) {
2168 rq->bio = rq->biotail = bio;
2169 blk_rq_bio_prep(q, rq, bio);
2170
2171 rq->buffer = rq->data = NULL;
2172 rq->data_len = len;
2173 return 0;
2174 }
2175
2176 /*
2177 * bio is the err-ptr
2178 */
2179 return PTR_ERR(bio);
2180}
2181
2182EXPORT_SYMBOL(blk_rq_map_user);
2183
2184/**
2185 * blk_rq_map_user_iov - map user data to a request, for REQ_BLOCK_PC usage
2186 * @q: request queue where request should be inserted
2187 * @rq: request to map data to
2188 * @iov: pointer to the iovec
2189 * @iov_count: number of elements in the iovec
2190 *
2191 * Description:
2192 * Data will be mapped directly for zero copy io, if possible. Otherwise
2193 * a kernel bounce buffer is used.
2194 *
2195 * A matching blk_rq_unmap_user() must be issued at the end of io, while
2196 * still in process context.
2197 *
2198 * Note: The mapped bio may need to be bounced through blk_queue_bounce()
2199 * before being submitted to the device, as pages mapped may be out of
2200 * reach. It's the callers responsibility to make sure this happens. The
2201 * original bio must be passed back in to blk_rq_unmap_user() for proper
2202 * unmapping.
2203 */
2204int blk_rq_map_user_iov(request_queue_t *q, struct request *rq,
2205 struct sg_iovec *iov, int iov_count)
2206{
2207 struct bio *bio;
2208
2209 if (!iov || iov_count <= 0)
2210 return -EINVAL;
2211
2212 /* we don't allow misaligned data like bio_map_user() does. If the
2213 * user is using sg, they're expected to know the alignment constraints
2214 * and respect them accordingly */
2215 bio = bio_map_user_iov(q, NULL, iov, iov_count, rq_data_dir(rq)== READ);
2216 if (IS_ERR(bio))
2217 return PTR_ERR(bio);
2218
2219 rq->bio = rq->biotail = bio;
2220 blk_rq_bio_prep(q, rq, bio);
2221 rq->buffer = rq->data = NULL;
2222 rq->data_len = bio->bi_size;
2223 return 0;
2224}
2225
2226EXPORT_SYMBOL(blk_rq_map_user_iov);
2227
2228/**
2229 * blk_rq_unmap_user - unmap a request with user data
2230 * @bio: bio to be unmapped
2231 * @ulen: length of user buffer
2232 *
2233 * Description:
2234 * Unmap a bio previously mapped by blk_rq_map_user().
2235 */
2236int blk_rq_unmap_user(struct bio *bio, unsigned int ulen)
2237{
2238 int ret = 0;
2239
2240 if (bio) {
2241 if (bio_flagged(bio, BIO_USER_MAPPED))
2242 bio_unmap_user(bio);
2243 else
2244 ret = bio_uncopy_user(bio);
2245 }
2246
2247 return 0;
2248}
2249
2250EXPORT_SYMBOL(blk_rq_unmap_user);
2251
2252/**
2253 * blk_rq_map_kern - map kernel data to a request, for REQ_BLOCK_PC usage
2254 * @q: request queue where request should be inserted
2255 * @rq: request to fill
2256 * @kbuf: the kernel buffer
2257 * @len: length of user data
2258 * @gfp_mask: memory allocation flags
2259 */
2260int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf,
2261 unsigned int len, gfp_t gfp_mask)
2262{
2263 struct bio *bio;
2264
2265 if (len > (q->max_sectors << 9))
2266 return -EINVAL;
2267 if (!len || !kbuf)
2268 return -EINVAL;
2269
2270 bio = bio_map_kern(q, kbuf, len, gfp_mask);
2271 if (IS_ERR(bio))
2272 return PTR_ERR(bio);
2273
2274 if (rq_data_dir(rq) == WRITE)
2275 bio->bi_rw |= (1 << BIO_RW);
2276
2277 rq->bio = rq->biotail = bio;
2278 blk_rq_bio_prep(q, rq, bio);
2279
2280 rq->buffer = rq->data = NULL;
2281 rq->data_len = len;
2282 return 0;
2283}
2284
2285EXPORT_SYMBOL(blk_rq_map_kern);
2286
2287/**
2288 * blk_execute_rq_nowait - insert a request into queue for execution
2289 * @q: queue to insert the request in
2290 * @bd_disk: matching gendisk
2291 * @rq: request to insert
2292 * @at_head: insert request at head or tail of queue
2293 * @done: I/O completion handler
2294 *
2295 * Description:
2296 * Insert a fully prepared request at the back of the io scheduler queue
2297 * for execution. Don't wait for completion.
2298 */
2299void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk,
2300 struct request *rq, int at_head,
2301 void (*done)(struct request *))
2302{
2303 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
2304
2305 rq->rq_disk = bd_disk;
2306 rq->flags |= REQ_NOMERGE;
2307 rq->end_io = done;
2308 elv_add_request(q, rq, where, 1);
2309 generic_unplug_device(q);
2310}
2311
2312/**
2313 * blk_execute_rq - insert a request into queue for execution
2314 * @q: queue to insert the request in
2315 * @bd_disk: matching gendisk
2316 * @rq: request to insert
2317 * @at_head: insert request at head or tail of queue
2318 *
2319 * Description:
2320 * Insert a fully prepared request at the back of the io scheduler queue
2321 * for execution and wait for completion.
2322 */
2323int blk_execute_rq(request_queue_t *q, struct gendisk *bd_disk,
2324 struct request *rq, int at_head)
2325{
2326 DECLARE_COMPLETION(wait);
2327 char sense[SCSI_SENSE_BUFFERSIZE];
2328 int err = 0;
2329
2330 /*
2331 * we need an extra reference to the request, so we can look at
2332 * it after io completion
2333 */
2334 rq->ref_count++;
2335
2336 if (!rq->sense) {
2337 memset(sense, 0, sizeof(sense));
2338 rq->sense = sense;
2339 rq->sense_len = 0;
2340 }
2341
2342 rq->waiting = &wait;
2343 blk_execute_rq_nowait(q, bd_disk, rq, at_head, blk_end_sync_rq);
2344 wait_for_completion(&wait);
2345 rq->waiting = NULL;
2346
2347 if (rq->errors)
2348 err = -EIO;
2349
2350 return err;
2351}
2352
2353EXPORT_SYMBOL(blk_execute_rq);
2354
2355/**
2356 * blkdev_issue_flush - queue a flush
2357 * @bdev: blockdev to issue flush for
2358 * @error_sector: error sector
2359 *
2360 * Description:
2361 * Issue a flush for the block device in question. Caller can supply
2362 * room for storing the error offset in case of a flush error, if they
2363 * wish to. Caller must run wait_for_completion() on its own.
2364 */
2365int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector)
2366{
2367 request_queue_t *q;
2368
2369 if (bdev->bd_disk == NULL)
2370 return -ENXIO;
2371
2372 q = bdev_get_queue(bdev);
2373 if (!q)
2374 return -ENXIO;
2375 if (!q->issue_flush_fn)
2376 return -EOPNOTSUPP;
2377
2378 return q->issue_flush_fn(q, bdev->bd_disk, error_sector);
2379}
2380
2381EXPORT_SYMBOL(blkdev_issue_flush);
2382
2383static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io)
2384{
2385 int rw = rq_data_dir(rq);
2386
2387 if (!blk_fs_request(rq) || !rq->rq_disk)
2388 return;
2389
2390 if (!new_io) {
2391 __disk_stat_inc(rq->rq_disk, merges[rw]);
2392 } else {
2393 disk_round_stats(rq->rq_disk);
2394 rq->rq_disk->in_flight++;
2395 }
2396}
2397
2398/*
2399 * add-request adds a request to the linked list.
2400 * queue lock is held and interrupts disabled, as we muck with the
2401 * request queue list.
2402 */
2403static inline void add_request(request_queue_t * q, struct request * req)
2404{
2405 drive_stat_acct(req, req->nr_sectors, 1);
2406
2407 if (q->activity_fn)
2408 q->activity_fn(q->activity_data, rq_data_dir(req));
2409
2410 /*
2411 * elevator indicated where it wants this request to be
2412 * inserted at elevator_merge time
2413 */
2414 __elv_add_request(q, req, ELEVATOR_INSERT_SORT, 0);
2415}
2416
2417/*
2418 * disk_round_stats() - Round off the performance stats on a struct
2419 * disk_stats.
2420 *
2421 * The average IO queue length and utilisation statistics are maintained
2422 * by observing the current state of the queue length and the amount of
2423 * time it has been in this state for.
2424 *
2425 * Normally, that accounting is done on IO completion, but that can result
2426 * in more than a second's worth of IO being accounted for within any one
2427 * second, leading to >100% utilisation. To deal with that, we call this
2428 * function to do a round-off before returning the results when reading
2429 * /proc/diskstats. This accounts immediately for all queue usage up to
2430 * the current jiffies and restarts the counters again.
2431 */
2432void disk_round_stats(struct gendisk *disk)
2433{
2434 unsigned long now = jiffies;
2435
2436 if (now == disk->stamp)
2437 return;
2438
2439 if (disk->in_flight) {
2440 __disk_stat_add(disk, time_in_queue,
2441 disk->in_flight * (now - disk->stamp));
2442 __disk_stat_add(disk, io_ticks, (now - disk->stamp));
2443 }
2444 disk->stamp = now;
2445}
2446
2447/*
2448 * queue lock must be held
2449 */
2450static void __blk_put_request(request_queue_t *q, struct request *req)
2451{
2452 struct request_list *rl = req->rl;
2453
2454 if (unlikely(!q))
2455 return;
2456 if (unlikely(--req->ref_count))
2457 return;
2458
2459 elv_completed_request(q, req);
2460
2461 req->rq_status = RQ_INACTIVE;
2462 req->rl = NULL;
2463
2464 /*
2465 * Request may not have originated from ll_rw_blk. if not,
2466 * it didn't come out of our reserved rq pools
2467 */
2468 if (rl) {
2469 int rw = rq_data_dir(req);
2470 int priv = req->flags & REQ_ELVPRIV;
2471
2472 BUG_ON(!list_empty(&req->queuelist));
2473
2474 blk_free_request(q, req);
2475 freed_request(q, rw, priv);
2476 }
2477}
2478
2479void blk_put_request(struct request *req)
2480{
2481 unsigned long flags;
2482 request_queue_t *q = req->q;
2483
2484 /*
2485 * Gee, IDE calls in w/ NULL q. Fix IDE and remove the
2486 * following if (q) test.
2487 */
2488 if (q) {
2489 spin_lock_irqsave(q->queue_lock, flags);
2490 __blk_put_request(q, req);
2491 spin_unlock_irqrestore(q->queue_lock, flags);
2492 }
2493}
2494
2495EXPORT_SYMBOL(blk_put_request);
2496
2497/**
2498 * blk_end_sync_rq - executes a completion event on a request
2499 * @rq: request to complete
2500 */
2501void blk_end_sync_rq(struct request *rq)
2502{
2503 struct completion *waiting = rq->waiting;
2504
2505 rq->waiting = NULL;
2506 __blk_put_request(rq->q, rq);
2507
2508 /*
2509 * complete last, if this is a stack request the process (and thus
2510 * the rq pointer) could be invalid right after this complete()
2511 */
2512 complete(waiting);
2513}
2514EXPORT_SYMBOL(blk_end_sync_rq);
2515
2516/**
2517 * blk_congestion_wait - wait for a queue to become uncongested
2518 * @rw: READ or WRITE
2519 * @timeout: timeout in jiffies
2520 *
2521 * Waits for up to @timeout jiffies for a queue (any queue) to exit congestion.
2522 * If no queues are congested then just wait for the next request to be
2523 * returned.
2524 */
2525long blk_congestion_wait(int rw, long timeout)
2526{
2527 long ret;
2528 DEFINE_WAIT(wait);
2529 wait_queue_head_t *wqh = &congestion_wqh[rw];
2530
2531 prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
2532 ret = io_schedule_timeout(timeout);
2533 finish_wait(wqh, &wait);
2534 return ret;
2535}
2536
2537EXPORT_SYMBOL(blk_congestion_wait);
2538
2539/*
2540 * Has to be called with the request spinlock acquired
2541 */
2542static int attempt_merge(request_queue_t *q, struct request *req,
2543 struct request *next)
2544{
2545 if (!rq_mergeable(req) || !rq_mergeable(next))
2546 return 0;
2547
2548 /*
2549 * not contigious
2550 */
2551 if (req->sector + req->nr_sectors != next->sector)
2552 return 0;
2553
2554 if (rq_data_dir(req) != rq_data_dir(next)
2555 || req->rq_disk != next->rq_disk
2556 || next->waiting || next->special)
2557 return 0;
2558
2559 /*
2560 * If we are allowed to merge, then append bio list
2561 * from next to rq and release next. merge_requests_fn
2562 * will have updated segment counts, update sector
2563 * counts here.
2564 */
2565 if (!q->merge_requests_fn(q, req, next))
2566 return 0;
2567
2568 /*
2569 * At this point we have either done a back merge
2570 * or front merge. We need the smaller start_time of
2571 * the merged requests to be the current request
2572 * for accounting purposes.
2573 */
2574 if (time_after(req->start_time, next->start_time))
2575 req->start_time = next->start_time;
2576
2577 req->biotail->bi_next = next->bio;
2578 req->biotail = next->biotail;
2579
2580 req->nr_sectors = req->hard_nr_sectors += next->hard_nr_sectors;
2581
2582 elv_merge_requests(q, req, next);
2583
2584 if (req->rq_disk) {
2585 disk_round_stats(req->rq_disk);
2586 req->rq_disk->in_flight--;
2587 }
2588
2589 req->ioprio = ioprio_best(req->ioprio, next->ioprio);
2590
2591 __blk_put_request(q, next);
2592 return 1;
2593}
2594
2595static inline int attempt_back_merge(request_queue_t *q, struct request *rq)
2596{
2597 struct request *next = elv_latter_request(q, rq);
2598
2599 if (next)
2600 return attempt_merge(q, rq, next);
2601
2602 return 0;
2603}
2604
2605static inline int attempt_front_merge(request_queue_t *q, struct request *rq)
2606{
2607 struct request *prev = elv_former_request(q, rq);
2608
2609 if (prev)
2610 return attempt_merge(q, prev, rq);
2611
2612 return 0;
2613}
2614
2615/**
2616 * blk_attempt_remerge - attempt to remerge active head with next request
2617 * @q: The &request_queue_t belonging to the device
2618 * @rq: The head request (usually)
2619 *
2620 * Description:
2621 * For head-active devices, the queue can easily be unplugged so quickly
2622 * that proper merging is not done on the front request. This may hurt
2623 * performance greatly for some devices. The block layer cannot safely
2624 * do merging on that first request for these queues, but the driver can
2625 * call this function and make it happen any way. Only the driver knows
2626 * when it is safe to do so.
2627 **/
2628void blk_attempt_remerge(request_queue_t *q, struct request *rq)
2629{
2630 unsigned long flags;
2631
2632 spin_lock_irqsave(q->queue_lock, flags);
2633 attempt_back_merge(q, rq);
2634 spin_unlock_irqrestore(q->queue_lock, flags);
2635}
2636
2637EXPORT_SYMBOL(blk_attempt_remerge);
2638
2639static int __make_request(request_queue_t *q, struct bio *bio)
2640{
2641 struct request *req;
2642 int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, err, sync;
2643 unsigned short prio;
2644 sector_t sector;
2645
2646 sector = bio->bi_sector;
2647 nr_sectors = bio_sectors(bio);
2648 cur_nr_sectors = bio_cur_sectors(bio);
2649 prio = bio_prio(bio);
2650
2651 rw = bio_data_dir(bio);
2652 sync = bio_sync(bio);
2653
2654 /*
2655 * low level driver can indicate that it wants pages above a
2656 * certain limit bounced to low memory (ie for highmem, or even
2657 * ISA dma in theory)
2658 */
2659 blk_queue_bounce(q, &bio);
2660
2661 spin_lock_prefetch(q->queue_lock);
2662
2663 barrier = bio_barrier(bio);
2664 if (unlikely(barrier) && (q->ordered == QUEUE_ORDERED_NONE)) {
2665 err = -EOPNOTSUPP;
2666 goto end_io;
2667 }
2668
2669 spin_lock_irq(q->queue_lock);
2670
2671 if (unlikely(barrier) || elv_queue_empty(q))
2672 goto get_rq;
2673
2674 el_ret = elv_merge(q, &req, bio);
2675 switch (el_ret) {
2676 case ELEVATOR_BACK_MERGE:
2677 BUG_ON(!rq_mergeable(req));
2678
2679 if (!q->back_merge_fn(q, req, bio))
2680 break;
2681
2682 req->biotail->bi_next = bio;
2683 req->biotail = bio;
2684 req->nr_sectors = req->hard_nr_sectors += nr_sectors;
2685 req->ioprio = ioprio_best(req->ioprio, prio);
2686 drive_stat_acct(req, nr_sectors, 0);
2687 if (!attempt_back_merge(q, req))
2688 elv_merged_request(q, req);
2689 goto out;
2690
2691 case ELEVATOR_FRONT_MERGE:
2692 BUG_ON(!rq_mergeable(req));
2693
2694 if (!q->front_merge_fn(q, req, bio))
2695 break;
2696
2697 bio->bi_next = req->bio;
2698 req->bio = bio;
2699
2700 /*
2701 * may not be valid. if the low level driver said
2702 * it didn't need a bounce buffer then it better
2703 * not touch req->buffer either...
2704 */
2705 req->buffer = bio_data(bio);
2706 req->current_nr_sectors = cur_nr_sectors;
2707 req->hard_cur_sectors = cur_nr_sectors;
2708 req->sector = req->hard_sector = sector;
2709 req->nr_sectors = req->hard_nr_sectors += nr_sectors;
2710 req->ioprio = ioprio_best(req->ioprio, prio);
2711 drive_stat_acct(req, nr_sectors, 0);
2712 if (!attempt_front_merge(q, req))
2713 elv_merged_request(q, req);
2714 goto out;
2715
2716 /* ELV_NO_MERGE: elevator says don't/can't merge. */
2717 default:
2718 ;
2719 }
2720
2721get_rq:
2722 /*
2723 * Grab a free request. This is might sleep but can not fail.
2724 * Returns with the queue unlocked.
2725 */
2726 req = get_request_wait(q, rw, bio);
2727
2728 /*
2729 * After dropping the lock and possibly sleeping here, our request
2730 * may now be mergeable after it had proven unmergeable (above).
2731 * We don't worry about that case for efficiency. It won't happen
2732 * often, and the elevators are able to handle it.
2733 */
2734
2735 req->flags |= REQ_CMD;
2736
2737 /*
2738 * inherit FAILFAST from bio (for read-ahead, and explicit FAILFAST)
2739 */
2740 if (bio_rw_ahead(bio) || bio_failfast(bio))
2741 req->flags |= REQ_FAILFAST;
2742
2743 /*
2744 * REQ_BARRIER implies no merging, but lets make it explicit
2745 */
2746 if (unlikely(barrier))
2747 req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE);
2748
2749 req->errors = 0;
2750 req->hard_sector = req->sector = sector;
2751 req->hard_nr_sectors = req->nr_sectors = nr_sectors;
2752 req->current_nr_sectors = req->hard_cur_sectors = cur_nr_sectors;
2753 req->nr_phys_segments = bio_phys_segments(q, bio);
2754 req->nr_hw_segments = bio_hw_segments(q, bio);
2755 req->buffer = bio_data(bio); /* see ->buffer comment above */
2756 req->waiting = NULL;
2757 req->bio = req->biotail = bio;
2758 req->ioprio = prio;
2759 req->rq_disk = bio->bi_bdev->bd_disk;
2760 req->start_time = jiffies;
2761
2762 spin_lock_irq(q->queue_lock);
2763 if (elv_queue_empty(q))
2764 blk_plug_device(q);
2765 add_request(q, req);
2766out:
2767 if (sync)
2768 __generic_unplug_device(q);
2769
2770 spin_unlock_irq(q->queue_lock);
2771 return 0;
2772
2773end_io:
2774 bio_endio(bio, nr_sectors << 9, err);
2775 return 0;
2776}
2777
2778/*
2779 * If bio->bi_dev is a partition, remap the location
2780 */
2781static inline void blk_partition_remap(struct bio *bio)
2782{
2783 struct block_device *bdev = bio->bi_bdev;
2784
2785 if (bdev != bdev->bd_contains) {
2786 struct hd_struct *p = bdev->bd_part;
2787 const int rw = bio_data_dir(bio);
2788
2789 p->sectors[rw] += bio_sectors(bio);
2790 p->ios[rw]++;
2791
2792 bio->bi_sector += p->start_sect;
2793 bio->bi_bdev = bdev->bd_contains;
2794 }
2795}
2796
2797static void handle_bad_sector(struct bio *bio)
2798{
2799 char b[BDEVNAME_SIZE];
2800
2801 printk(KERN_INFO "attempt to access beyond end of device\n");
2802 printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n",
2803 bdevname(bio->bi_bdev, b),
2804 bio->bi_rw,
2805 (unsigned long long)bio->bi_sector + bio_sectors(bio),
2806 (long long)(bio->bi_bdev->bd_inode->i_size >> 9));
2807
2808 set_bit(BIO_EOF, &bio->bi_flags);
2809}
2810
2811/**
2812 * generic_make_request: hand a buffer to its device driver for I/O
2813 * @bio: The bio describing the location in memory and on the device.
2814 *
2815 * generic_make_request() is used to make I/O requests of block
2816 * devices. It is passed a &struct bio, which describes the I/O that needs
2817 * to be done.
2818 *
2819 * generic_make_request() does not return any status. The
2820 * success/failure status of the request, along with notification of
2821 * completion, is delivered asynchronously through the bio->bi_end_io
2822 * function described (one day) else where.
2823 *
2824 * The caller of generic_make_request must make sure that bi_io_vec
2825 * are set to describe the memory buffer, and that bi_dev and bi_sector are
2826 * set to describe the device address, and the
2827 * bi_end_io and optionally bi_private are set to describe how
2828 * completion notification should be signaled.
2829 *
2830 * generic_make_request and the drivers it calls may use bi_next if this
2831 * bio happens to be merged with someone else, and may change bi_dev and
2832 * bi_sector for remaps as it sees fit. So the values of these fields
2833 * should NOT be depended on after the call to generic_make_request.
2834 */
2835void generic_make_request(struct bio *bio)
2836{
2837 request_queue_t *q;
2838 sector_t maxsector;
2839 int ret, nr_sectors = bio_sectors(bio);
2840
2841 might_sleep();
2842 /* Test device or partition size, when known. */
2843 maxsector = bio->bi_bdev->bd_inode->i_size >> 9;
2844 if (maxsector) {
2845 sector_t sector = bio->bi_sector;
2846
2847 if (maxsector < nr_sectors || maxsector - nr_sectors < sector) {
2848 /*
2849 * This may well happen - the kernel calls bread()
2850 * without checking the size of the device, e.g., when
2851 * mounting a device.
2852 */
2853 handle_bad_sector(bio);
2854 goto end_io;
2855 }
2856 }
2857
2858 /*
2859 * Resolve the mapping until finished. (drivers are
2860 * still free to implement/resolve their own stacking
2861 * by explicitly returning 0)
2862 *
2863 * NOTE: we don't repeat the blk_size check for each new device.
2864 * Stacking drivers are expected to know what they are doing.
2865 */
2866 do {
2867 char b[BDEVNAME_SIZE];
2868
2869 q = bdev_get_queue(bio->bi_bdev);
2870 if (!q) {
2871 printk(KERN_ERR
2872 "generic_make_request: Trying to access "
2873 "nonexistent block-device %s (%Lu)\n",
2874 bdevname(bio->bi_bdev, b),
2875 (long long) bio->bi_sector);
2876end_io:
2877 bio_endio(bio, bio->bi_size, -EIO);
2878 break;
2879 }
2880
2881 if (unlikely(bio_sectors(bio) > q->max_hw_sectors)) {
2882 printk("bio too big device %s (%u > %u)\n",
2883 bdevname(bio->bi_bdev, b),
2884 bio_sectors(bio),
2885 q->max_hw_sectors);
2886 goto end_io;
2887 }
2888
2889 if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
2890 goto end_io;
2891
2892 /*
2893 * If this device has partitions, remap block n
2894 * of partition p to block n+start(p) of the disk.
2895 */
2896 blk_partition_remap(bio);
2897
2898 ret = q->make_request_fn(q, bio);
2899 } while (ret);
2900}
2901
2902EXPORT_SYMBOL(generic_make_request);
2903
2904/**
2905 * submit_bio: submit a bio to the block device layer for I/O
2906 * @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
2907 * @bio: The &struct bio which describes the I/O
2908 *
2909 * submit_bio() is very similar in purpose to generic_make_request(), and
2910 * uses that function to do most of the work. Both are fairly rough
2911 * interfaces, @bio must be presetup and ready for I/O.
2912 *
2913 */
2914void submit_bio(int rw, struct bio *bio)
2915{
2916 int count = bio_sectors(bio);
2917
2918 BIO_BUG_ON(!bio->bi_size);
2919 BIO_BUG_ON(!bio->bi_io_vec);
2920 bio->bi_rw |= rw;
2921 if (rw & WRITE)
2922 mod_page_state(pgpgout, count);
2923 else
2924 mod_page_state(pgpgin, count);
2925
2926 if (unlikely(block_dump)) {
2927 char b[BDEVNAME_SIZE];
2928 printk(KERN_DEBUG "%s(%d): %s block %Lu on %s\n",
2929 current->comm, current->pid,
2930 (rw & WRITE) ? "WRITE" : "READ",
2931 (unsigned long long)bio->bi_sector,
2932 bdevname(bio->bi_bdev,b));
2933 }
2934
2935 generic_make_request(bio);
2936}
2937
2938EXPORT_SYMBOL(submit_bio);
2939
2940static void blk_recalc_rq_segments(struct request *rq)
2941{
2942 struct bio *bio, *prevbio = NULL;
2943 int nr_phys_segs, nr_hw_segs;
2944 unsigned int phys_size, hw_size;
2945 request_queue_t *q = rq->q;
2946
2947 if (!rq->bio)
2948 return;
2949
2950 phys_size = hw_size = nr_phys_segs = nr_hw_segs = 0;
2951 rq_for_each_bio(bio, rq) {
2952 /* Force bio hw/phys segs to be recalculated. */
2953 bio->bi_flags &= ~(1 << BIO_SEG_VALID);
2954
2955 nr_phys_segs += bio_phys_segments(q, bio);
2956 nr_hw_segs += bio_hw_segments(q, bio);
2957 if (prevbio) {
2958 int pseg = phys_size + prevbio->bi_size + bio->bi_size;
2959 int hseg = hw_size + prevbio->bi_size + bio->bi_size;
2960
2961 if (blk_phys_contig_segment(q, prevbio, bio) &&
2962 pseg <= q->max_segment_size) {
2963 nr_phys_segs--;
2964 phys_size += prevbio->bi_size + bio->bi_size;
2965 } else
2966 phys_size = 0;
2967
2968 if (blk_hw_contig_segment(q, prevbio, bio) &&
2969 hseg <= q->max_segment_size) {
2970 nr_hw_segs--;
2971 hw_size += prevbio->bi_size + bio->bi_size;
2972 } else
2973 hw_size = 0;
2974 }
2975 prevbio = bio;
2976 }
2977
2978 rq->nr_phys_segments = nr_phys_segs;
2979 rq->nr_hw_segments = nr_hw_segs;
2980}
2981
2982static void blk_recalc_rq_sectors(struct request *rq, int nsect)
2983{
2984 if (blk_fs_request(rq)) {
2985 rq->hard_sector += nsect;
2986 rq->hard_nr_sectors -= nsect;
2987
2988 /*
2989 * Move the I/O submission pointers ahead if required.
2990 */
2991 if ((rq->nr_sectors >= rq->hard_nr_sectors) &&
2992 (rq->sector <= rq->hard_sector)) {
2993 rq->sector = rq->hard_sector;
2994 rq->nr_sectors = rq->hard_nr_sectors;
2995 rq->hard_cur_sectors = bio_cur_sectors(rq->bio);
2996 rq->current_nr_sectors = rq->hard_cur_sectors;
2997 rq->buffer = bio_data(rq->bio);
2998 }
2999
3000 /*
3001 * if total number of sectors is less than the first segment
3002 * size, something has gone terribly wrong
3003 */
3004 if (rq->nr_sectors < rq->current_nr_sectors) {
3005 printk("blk: request botched\n");
3006 rq->nr_sectors = rq->current_nr_sectors;
3007 }
3008 }
3009}
3010
3011static int __end_that_request_first(struct request *req, int uptodate,
3012 int nr_bytes)
3013{
3014 int total_bytes, bio_nbytes, error, next_idx = 0;
3015 struct bio *bio;
3016
3017 /*
3018 * extend uptodate bool to allow < 0 value to be direct io error
3019 */
3020 error = 0;
3021 if (end_io_error(uptodate))
3022 error = !uptodate ? -EIO : uptodate;
3023
3024 /*
3025 * for a REQ_BLOCK_PC request, we want to carry any eventual
3026 * sense key with us all the way through
3027 */
3028 if (!blk_pc_request(req))
3029 req->errors = 0;
3030
3031 if (!uptodate) {
3032 if (blk_fs_request(req) && !(req->flags & REQ_QUIET))
3033 printk("end_request: I/O error, dev %s, sector %llu\n",
3034 req->rq_disk ? req->rq_disk->disk_name : "?",
3035 (unsigned long long)req->sector);
3036 }
3037
3038 if (blk_fs_request(req) && req->rq_disk) {
3039 const int rw = rq_data_dir(req);
3040
3041 __disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9);
3042 }
3043
3044 total_bytes = bio_nbytes = 0;
3045 while ((bio = req->bio) != NULL) {
3046 int nbytes;
3047
3048 if (nr_bytes >= bio->bi_size) {
3049 req->bio = bio->bi_next;
3050 nbytes = bio->bi_size;
3051 bio_endio(bio, nbytes, error);
3052 next_idx = 0;
3053 bio_nbytes = 0;
3054 } else {
3055 int idx = bio->bi_idx + next_idx;
3056
3057 if (unlikely(bio->bi_idx >= bio->bi_vcnt)) {
3058 blk_dump_rq_flags(req, "__end_that");
3059 printk("%s: bio idx %d >= vcnt %d\n",
3060 __FUNCTION__,
3061 bio->bi_idx, bio->bi_vcnt);
3062 break;
3063 }
3064
3065 nbytes = bio_iovec_idx(bio, idx)->bv_len;
3066 BIO_BUG_ON(nbytes > bio->bi_size);
3067
3068 /*
3069 * not a complete bvec done
3070 */
3071 if (unlikely(nbytes > nr_bytes)) {
3072 bio_nbytes += nr_bytes;
3073 total_bytes += nr_bytes;
3074 break;
3075 }
3076
3077 /*
3078 * advance to the next vector
3079 */
3080 next_idx++;
3081 bio_nbytes += nbytes;
3082 }
3083
3084 total_bytes += nbytes;
3085 nr_bytes -= nbytes;
3086
3087 if ((bio = req->bio)) {
3088 /*
3089 * end more in this run, or just return 'not-done'
3090 */
3091 if (unlikely(nr_bytes <= 0))
3092 break;
3093 }
3094 }
3095
3096 /*
3097 * completely done
3098 */
3099 if (!req->bio)
3100 return 0;
3101
3102 /*
3103 * if the request wasn't completed, update state
3104 */
3105 if (bio_nbytes) {
3106 bio_endio(bio, bio_nbytes, error);
3107 bio->bi_idx += next_idx;
3108 bio_iovec(bio)->bv_offset += nr_bytes;
3109 bio_iovec(bio)->bv_len -= nr_bytes;
3110 }
3111
3112 blk_recalc_rq_sectors(req, total_bytes >> 9);
3113 blk_recalc_rq_segments(req);
3114 return 1;
3115}
3116
3117/**
3118 * end_that_request_first - end I/O on a request
3119 * @req: the request being processed
3120 * @uptodate: 1 for success, 0 for I/O error, < 0 for specific error
3121 * @nr_sectors: number of sectors to end I/O on
3122 *
3123 * Description:
3124 * Ends I/O on a number of sectors attached to @req, and sets it up
3125 * for the next range of segments (if any) in the cluster.
3126 *
3127 * Return:
3128 * 0 - we are done with this request, call end_that_request_last()
3129 * 1 - still buffers pending for this request
3130 **/
3131int end_that_request_first(struct request *req, int uptodate, int nr_sectors)
3132{
3133 return __end_that_request_first(req, uptodate, nr_sectors << 9);
3134}
3135
3136EXPORT_SYMBOL(end_that_request_first);
3137
3138/**
3139 * end_that_request_chunk - end I/O on a request
3140 * @req: the request being processed
3141 * @uptodate: 1 for success, 0 for I/O error, < 0 for specific error
3142 * @nr_bytes: number of bytes to complete
3143 *
3144 * Description:
3145 * Ends I/O on a number of bytes attached to @req, and sets it up
3146 * for the next range of segments (if any). Like end_that_request_first(),
3147 * but deals with bytes instead of sectors.
3148 *
3149 * Return:
3150 * 0 - we are done with this request, call end_that_request_last()
3151 * 1 - still buffers pending for this request
3152 **/
3153int end_that_request_chunk(struct request *req, int uptodate, int nr_bytes)
3154{
3155 return __end_that_request_first(req, uptodate, nr_bytes);
3156}
3157
3158EXPORT_SYMBOL(end_that_request_chunk);
3159
3160/*
3161 * queue lock must be held
3162 */
3163void end_that_request_last(struct request *req)
3164{
3165 struct gendisk *disk = req->rq_disk;
3166
3167 if (unlikely(laptop_mode) && blk_fs_request(req))
3168 laptop_io_completion();
3169
3170 if (disk && blk_fs_request(req)) {
3171 unsigned long duration = jiffies - req->start_time;
3172 const int rw = rq_data_dir(req);
3173
3174 __disk_stat_inc(disk, ios[rw]);
3175 __disk_stat_add(disk, ticks[rw], duration);
3176 disk_round_stats(disk);
3177 disk->in_flight--;
3178 }
3179 if (req->end_io)
3180 req->end_io(req);
3181 else
3182 __blk_put_request(req->q, req);
3183}
3184
3185EXPORT_SYMBOL(end_that_request_last);
3186
3187void end_request(struct request *req, int uptodate)
3188{
3189 if (!end_that_request_first(req, uptodate, req->hard_cur_sectors)) {
3190 add_disk_randomness(req->rq_disk);
3191 blkdev_dequeue_request(req);
3192 end_that_request_last(req);
3193 }
3194}
3195
3196EXPORT_SYMBOL(end_request);
3197
3198void blk_rq_bio_prep(request_queue_t *q, struct request *rq, struct bio *bio)
3199{
3200 /* first three bits are identical in rq->flags and bio->bi_rw */
3201 rq->flags |= (bio->bi_rw & 7);
3202
3203 rq->nr_phys_segments = bio_phys_segments(q, bio);
3204 rq->nr_hw_segments = bio_hw_segments(q, bio);
3205 rq->current_nr_sectors = bio_cur_sectors(bio);
3206 rq->hard_cur_sectors = rq->current_nr_sectors;
3207 rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio);
3208 rq->buffer = bio_data(bio);
3209
3210 rq->bio = rq->biotail = bio;
3211}
3212
3213EXPORT_SYMBOL(blk_rq_bio_prep);
3214
3215int kblockd_schedule_work(struct work_struct *work)
3216{
3217 return queue_work(kblockd_workqueue, work);
3218}
3219
3220EXPORT_SYMBOL(kblockd_schedule_work);
3221
3222void kblockd_flush(void)
3223{
3224 flush_workqueue(kblockd_workqueue);
3225}
3226EXPORT_SYMBOL(kblockd_flush);
3227
3228int __init blk_dev_init(void)
3229{
3230 kblockd_workqueue = create_workqueue("kblockd");
3231 if (!kblockd_workqueue)
3232 panic("Failed to create kblockd\n");
3233
3234 request_cachep = kmem_cache_create("blkdev_requests",
3235 sizeof(struct request), 0, SLAB_PANIC, NULL, NULL);
3236
3237 requestq_cachep = kmem_cache_create("blkdev_queue",
3238 sizeof(request_queue_t), 0, SLAB_PANIC, NULL, NULL);
3239
3240 iocontext_cachep = kmem_cache_create("blkdev_ioc",
3241 sizeof(struct io_context), 0, SLAB_PANIC, NULL, NULL);
3242
3243 blk_max_low_pfn = max_low_pfn;
3244 blk_max_pfn = max_pfn;
3245
3246 return 0;
3247}
3248
3249/*
3250 * IO Context helper functions
3251 */
3252void put_io_context(struct io_context *ioc)
3253{
3254 if (ioc == NULL)
3255 return;
3256
3257 BUG_ON(atomic_read(&ioc->refcount) == 0);
3258
3259 if (atomic_dec_and_test(&ioc->refcount)) {
3260 if (ioc->aic && ioc->aic->dtor)
3261 ioc->aic->dtor(ioc->aic);
3262 if (ioc->cic && ioc->cic->dtor)
3263 ioc->cic->dtor(ioc->cic);
3264
3265 kmem_cache_free(iocontext_cachep, ioc);
3266 }
3267}
3268EXPORT_SYMBOL(put_io_context);
3269
3270/* Called by the exitting task */
3271void exit_io_context(void)
3272{
3273 unsigned long flags;
3274 struct io_context *ioc;
3275
3276 local_irq_save(flags);
3277 task_lock(current);
3278 ioc = current->io_context;
3279 current->io_context = NULL;
3280 ioc->task = NULL;
3281 task_unlock(current);
3282 local_irq_restore(flags);
3283
3284 if (ioc->aic && ioc->aic->exit)
3285 ioc->aic->exit(ioc->aic);
3286 if (ioc->cic && ioc->cic->exit)
3287 ioc->cic->exit(ioc->cic);
3288
3289 put_io_context(ioc);
3290}
3291
3292/*
3293 * If the current task has no IO context then create one and initialise it.
3294 * Otherwise, return its existing IO context.
3295 *
3296 * This returned IO context doesn't have a specifically elevated refcount,
3297 * but since the current task itself holds a reference, the context can be
3298 * used in general code, so long as it stays within `current` context.
3299 */
3300struct io_context *current_io_context(gfp_t gfp_flags)
3301{
3302 struct task_struct *tsk = current;
3303 struct io_context *ret;
3304
3305 ret = tsk->io_context;
3306 if (likely(ret))
3307 return ret;
3308
3309 ret = kmem_cache_alloc(iocontext_cachep, gfp_flags);
3310 if (ret) {
3311 atomic_set(&ret->refcount, 1);
3312 ret->task = current;
3313 ret->set_ioprio = NULL;
3314 ret->last_waited = jiffies; /* doesn't matter... */
3315 ret->nr_batch_requests = 0; /* because this is 0 */
3316 ret->aic = NULL;
3317 ret->cic = NULL;
3318 tsk->io_context = ret;
3319 }
3320
3321 return ret;
3322}
3323EXPORT_SYMBOL(current_io_context);
3324
3325/*
3326 * If the current task has no IO context then create one and initialise it.
3327 * If it does have a context, take a ref on it.
3328 *
3329 * This is always called in the context of the task which submitted the I/O.
3330 */
3331struct io_context *get_io_context(gfp_t gfp_flags)
3332{
3333 struct io_context *ret;
3334 ret = current_io_context(gfp_flags);
3335 if (likely(ret))
3336 atomic_inc(&ret->refcount);
3337 return ret;
3338}
3339EXPORT_SYMBOL(get_io_context);
3340
3341void copy_io_context(struct io_context **pdst, struct io_context **psrc)
3342{
3343 struct io_context *src = *psrc;
3344 struct io_context *dst = *pdst;
3345
3346 if (src) {
3347 BUG_ON(atomic_read(&src->refcount) == 0);
3348 atomic_inc(&src->refcount);
3349 put_io_context(dst);
3350 *pdst = src;
3351 }
3352}
3353EXPORT_SYMBOL(copy_io_context);
3354
3355void swap_io_context(struct io_context **ioc1, struct io_context **ioc2)
3356{
3357 struct io_context *temp;
3358 temp = *ioc1;
3359 *ioc1 = *ioc2;
3360 *ioc2 = temp;
3361}
3362EXPORT_SYMBOL(swap_io_context);
3363
3364/*
3365 * sysfs parts below
3366 */
3367struct queue_sysfs_entry {
3368 struct attribute attr;
3369 ssize_t (*show)(struct request_queue *, char *);
3370 ssize_t (*store)(struct request_queue *, const char *, size_t);
3371};
3372
3373static ssize_t
3374queue_var_show(unsigned int var, char *page)
3375{
3376 return sprintf(page, "%d\n", var);
3377}
3378
3379static ssize_t
3380queue_var_store(unsigned long *var, const char *page, size_t count)
3381{
3382 char *p = (char *) page;
3383
3384 *var = simple_strtoul(p, &p, 10);
3385 return count;
3386}
3387
3388static ssize_t queue_requests_show(struct request_queue *q, char *page)
3389{
3390 return queue_var_show(q->nr_requests, (page));
3391}
3392
3393static ssize_t
3394queue_requests_store(struct request_queue *q, const char *page, size_t count)
3395{
3396 struct request_list *rl = &q->rq;
3397
3398 int ret = queue_var_store(&q->nr_requests, page, count);
3399 if (q->nr_requests < BLKDEV_MIN_RQ)
3400 q->nr_requests = BLKDEV_MIN_RQ;
3401 blk_queue_congestion_threshold(q);
3402
3403 if (rl->count[READ] >= queue_congestion_on_threshold(q))
3404 set_queue_congested(q, READ);
3405 else if (rl->count[READ] < queue_congestion_off_threshold(q))
3406 clear_queue_congested(q, READ);
3407
3408 if (rl->count[WRITE] >= queue_congestion_on_threshold(q))
3409 set_queue_congested(q, WRITE);
3410 else if (rl->count[WRITE] < queue_congestion_off_threshold(q))
3411 clear_queue_congested(q, WRITE);
3412
3413 if (rl->count[READ] >= q->nr_requests) {
3414 blk_set_queue_full(q, READ);
3415 } else if (rl->count[READ]+1 <= q->nr_requests) {
3416 blk_clear_queue_full(q, READ);
3417 wake_up(&rl->wait[READ]);
3418 }
3419
3420 if (rl->count[WRITE] >= q->nr_requests) {
3421 blk_set_queue_full(q, WRITE);
3422 } else if (rl->count[WRITE]+1 <= q->nr_requests) {
3423 blk_clear_queue_full(q, WRITE);
3424 wake_up(&rl->wait[WRITE]);
3425 }
3426 return ret;
3427}
3428
3429static ssize_t queue_ra_show(struct request_queue *q, char *page)
3430{
3431 int ra_kb = q->backing_dev_info.ra_pages << (PAGE_CACHE_SHIFT - 10);
3432
3433 return queue_var_show(ra_kb, (page));
3434}
3435
3436static ssize_t
3437queue_ra_store(struct request_queue *q, const char *page, size_t count)
3438{
3439 unsigned long ra_kb;
3440 ssize_t ret = queue_var_store(&ra_kb, page, count);
3441
3442 spin_lock_irq(q->queue_lock);
3443 if (ra_kb > (q->max_sectors >> 1))
3444 ra_kb = (q->max_sectors >> 1);
3445
3446 q->backing_dev_info.ra_pages = ra_kb >> (PAGE_CACHE_SHIFT - 10);
3447 spin_unlock_irq(q->queue_lock);
3448
3449 return ret;
3450}
3451
3452static ssize_t queue_max_sectors_show(struct request_queue *q, char *page)
3453{
3454 int max_sectors_kb = q->max_sectors >> 1;
3455
3456 return queue_var_show(max_sectors_kb, (page));
3457}
3458
3459static ssize_t
3460queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
3461{
3462 unsigned long max_sectors_kb,
3463 max_hw_sectors_kb = q->max_hw_sectors >> 1,
3464 page_kb = 1 << (PAGE_CACHE_SHIFT - 10);
3465 ssize_t ret = queue_var_store(&max_sectors_kb, page, count);
3466 int ra_kb;
3467
3468 if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
3469 return -EINVAL;
3470 /*
3471 * Take the queue lock to update the readahead and max_sectors
3472 * values synchronously:
3473 */
3474 spin_lock_irq(q->queue_lock);
3475 /*
3476 * Trim readahead window as well, if necessary:
3477 */
3478 ra_kb = q->backing_dev_info.ra_pages << (PAGE_CACHE_SHIFT - 10);
3479 if (ra_kb > max_sectors_kb)
3480 q->backing_dev_info.ra_pages =
3481 max_sectors_kb >> (PAGE_CACHE_SHIFT - 10);
3482
3483 q->max_sectors = max_sectors_kb << 1;
3484 spin_unlock_irq(q->queue_lock);
3485
3486 return ret;
3487}
3488
3489static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page)
3490{
3491 int max_hw_sectors_kb = q->max_hw_sectors >> 1;
3492
3493 return queue_var_show(max_hw_sectors_kb, (page));
3494}
3495
3496
3497static struct queue_sysfs_entry queue_requests_entry = {
3498 .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },
3499 .show = queue_requests_show,
3500 .store = queue_requests_store,
3501};
3502
3503static struct queue_sysfs_entry queue_ra_entry = {
3504 .attr = {.name = "read_ahead_kb", .mode = S_IRUGO | S_IWUSR },
3505 .show = queue_ra_show,
3506 .store = queue_ra_store,
3507};
3508
3509static struct queue_sysfs_entry queue_max_sectors_entry = {
3510 .attr = {.name = "max_sectors_kb", .mode = S_IRUGO | S_IWUSR },
3511 .show = queue_max_sectors_show,
3512 .store = queue_max_sectors_store,
3513};
3514
3515static struct queue_sysfs_entry queue_max_hw_sectors_entry = {
3516 .attr = {.name = "max_hw_sectors_kb", .mode = S_IRUGO },
3517 .show = queue_max_hw_sectors_show,
3518};
3519
3520static struct queue_sysfs_entry queue_iosched_entry = {
3521 .attr = {.name = "scheduler", .mode = S_IRUGO | S_IWUSR },
3522 .show = elv_iosched_show,
3523 .store = elv_iosched_store,
3524};
3525
3526static struct attribute *default_attrs[] = {
3527 &queue_requests_entry.attr,
3528 &queue_ra_entry.attr,
3529 &queue_max_hw_sectors_entry.attr,
3530 &queue_max_sectors_entry.attr,
3531 &queue_iosched_entry.attr,
3532 NULL,
3533};
3534
3535#define to_queue(atr) container_of((atr), struct queue_sysfs_entry, attr)
3536
3537static ssize_t
3538queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
3539{
3540 struct queue_sysfs_entry *entry = to_queue(attr);
3541 struct request_queue *q;
3542
3543 q = container_of(kobj, struct request_queue, kobj);
3544 if (!entry->show)
3545 return -EIO;
3546
3547 return entry->show(q, page);
3548}
3549
3550static ssize_t
3551queue_attr_store(struct kobject *kobj, struct attribute *attr,
3552 const char *page, size_t length)
3553{
3554 struct queue_sysfs_entry *entry = to_queue(attr);
3555 struct request_queue *q;
3556
3557 q = container_of(kobj, struct request_queue, kobj);
3558 if (!entry->store)
3559 return -EIO;
3560
3561 return entry->store(q, page, length);
3562}
3563
3564static struct sysfs_ops queue_sysfs_ops = {
3565 .show = queue_attr_show,
3566 .store = queue_attr_store,
3567};
3568
3569static struct kobj_type queue_ktype = {
3570 .sysfs_ops = &queue_sysfs_ops,
3571 .default_attrs = default_attrs,
3572};
3573
3574int blk_register_queue(struct gendisk *disk)
3575{
3576 int ret;
3577
3578 request_queue_t *q = disk->queue;
3579
3580 if (!q || !q->request_fn)
3581 return -ENXIO;
3582
3583 q->kobj.parent = kobject_get(&disk->kobj);
3584 if (!q->kobj.parent)
3585 return -EBUSY;
3586
3587 snprintf(q->kobj.name, KOBJ_NAME_LEN, "%s", "queue");
3588 q->kobj.ktype = &queue_ktype;
3589
3590 ret = kobject_register(&q->kobj);
3591 if (ret < 0)
3592 return ret;
3593
3594 ret = elv_register_queue(q);
3595 if (ret) {
3596 kobject_unregister(&q->kobj);
3597 return ret;
3598 }
3599
3600 return 0;
3601}
3602
3603void blk_unregister_queue(struct gendisk *disk)
3604{
3605 request_queue_t *q = disk->queue;
3606
3607 if (q && q->request_fn) {
3608 elv_unregister_queue(q);
3609
3610 kobject_unregister(&q->kobj);
3611 kobject_put(&disk->kobj);
3612 }
3613}
diff --git a/drivers/block/noop-iosched.c b/drivers/block/noop-iosched.c
deleted file mode 100644
index e54f006e7e60..000000000000
--- a/drivers/block/noop-iosched.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * elevator noop
3 */
4#include <linux/blkdev.h>
5#include <linux/elevator.h>
6#include <linux/bio.h>
7#include <linux/module.h>
8#include <linux/init.h>
9
10static void elevator_noop_add_request(request_queue_t *q, struct request *rq)
11{
12 rq->flags |= REQ_NOMERGE;
13 elv_dispatch_add_tail(q, rq);
14}
15
16static int elevator_noop_dispatch(request_queue_t *q, int force)
17{
18 return 0;
19}
20
21static struct elevator_type elevator_noop = {
22 .ops = {
23 .elevator_dispatch_fn = elevator_noop_dispatch,
24 .elevator_add_req_fn = elevator_noop_add_request,
25 },
26 .elevator_name = "noop",
27 .elevator_owner = THIS_MODULE,
28};
29
30static int __init noop_init(void)
31{
32 return elv_register(&elevator_noop);
33}
34
35static void __exit noop_exit(void)
36{
37 elv_unregister(&elevator_noop);
38}
39
40module_init(noop_init);
41module_exit(noop_exit);
42
43
44MODULE_AUTHOR("Jens Axboe");
45MODULE_LICENSE("GPL");
46MODULE_DESCRIPTION("No-op IO scheduler");
diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c
deleted file mode 100644
index 382dea7b224c..000000000000
--- a/drivers/block/scsi_ioctl.c
+++ /dev/null
@@ -1,589 +0,0 @@
1/*
2 * Copyright (C) 2001 Jens Axboe <axboe@suse.de>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public Licens
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
17 *
18 */
19#include <linux/kernel.h>
20#include <linux/errno.h>
21#include <linux/string.h>
22#include <linux/module.h>
23#include <linux/blkdev.h>
24#include <linux/completion.h>
25#include <linux/cdrom.h>
26#include <linux/slab.h>
27#include <linux/times.h>
28#include <asm/uaccess.h>
29
30#include <scsi/scsi.h>
31#include <scsi/scsi_ioctl.h>
32#include <scsi/scsi_cmnd.h>
33
34/* Command group 3 is reserved and should never be used. */
35const unsigned char scsi_command_size[8] =
36{
37 6, 10, 10, 12,
38 16, 12, 10, 10
39};
40
41EXPORT_SYMBOL(scsi_command_size);
42
43#define BLK_DEFAULT_TIMEOUT (60 * HZ)
44
45#include <scsi/sg.h>
46
47static int sg_get_version(int __user *p)
48{
49 static int sg_version_num = 30527;
50 return put_user(sg_version_num, p);
51}
52
53static int scsi_get_idlun(request_queue_t *q, int __user *p)
54{
55 return put_user(0, p);
56}
57
58static int scsi_get_bus(request_queue_t *q, int __user *p)
59{
60 return put_user(0, p);
61}
62
63static int sg_get_timeout(request_queue_t *q)
64{
65 return q->sg_timeout / (HZ / USER_HZ);
66}
67
68static int sg_set_timeout(request_queue_t *q, int __user *p)
69{
70 int timeout, err = get_user(timeout, p);
71
72 if (!err)
73 q->sg_timeout = timeout * (HZ / USER_HZ);
74
75 return err;
76}
77
78static int sg_get_reserved_size(request_queue_t *q, int __user *p)
79{
80 return put_user(q->sg_reserved_size, p);
81}
82
83static int sg_set_reserved_size(request_queue_t *q, int __user *p)
84{
85 int size, err = get_user(size, p);
86
87 if (err)
88 return err;
89
90 if (size < 0)
91 return -EINVAL;
92 if (size > (q->max_sectors << 9))
93 size = q->max_sectors << 9;
94
95 q->sg_reserved_size = size;
96 return 0;
97}
98
99/*
100 * will always return that we are ATAPI even for a real SCSI drive, I'm not
101 * so sure this is worth doing anything about (why would you care??)
102 */
103static int sg_emulated_host(request_queue_t *q, int __user *p)
104{
105 return put_user(1, p);
106}
107
108#define CMD_READ_SAFE 0x01
109#define CMD_WRITE_SAFE 0x02
110#define CMD_WARNED 0x04
111#define safe_for_read(cmd) [cmd] = CMD_READ_SAFE
112#define safe_for_write(cmd) [cmd] = CMD_WRITE_SAFE
113
114static int verify_command(struct file *file, unsigned char *cmd)
115{
116 static unsigned char cmd_type[256] = {
117
118 /* Basic read-only commands */
119 safe_for_read(TEST_UNIT_READY),
120 safe_for_read(REQUEST_SENSE),
121 safe_for_read(READ_6),
122 safe_for_read(READ_10),
123 safe_for_read(READ_12),
124 safe_for_read(READ_16),
125 safe_for_read(READ_BUFFER),
126 safe_for_read(READ_DEFECT_DATA),
127 safe_for_read(READ_LONG),
128 safe_for_read(INQUIRY),
129 safe_for_read(MODE_SENSE),
130 safe_for_read(MODE_SENSE_10),
131 safe_for_read(LOG_SENSE),
132 safe_for_read(START_STOP),
133 safe_for_read(GPCMD_VERIFY_10),
134 safe_for_read(VERIFY_16),
135
136 /* Audio CD commands */
137 safe_for_read(GPCMD_PLAY_CD),
138 safe_for_read(GPCMD_PLAY_AUDIO_10),
139 safe_for_read(GPCMD_PLAY_AUDIO_MSF),
140 safe_for_read(GPCMD_PLAY_AUDIO_TI),
141 safe_for_read(GPCMD_PAUSE_RESUME),
142
143 /* CD/DVD data reading */
144 safe_for_read(GPCMD_READ_BUFFER_CAPACITY),
145 safe_for_read(GPCMD_READ_CD),
146 safe_for_read(GPCMD_READ_CD_MSF),
147 safe_for_read(GPCMD_READ_DISC_INFO),
148 safe_for_read(GPCMD_READ_CDVD_CAPACITY),
149 safe_for_read(GPCMD_READ_DVD_STRUCTURE),
150 safe_for_read(GPCMD_READ_HEADER),
151 safe_for_read(GPCMD_READ_TRACK_RZONE_INFO),
152 safe_for_read(GPCMD_READ_SUBCHANNEL),
153 safe_for_read(GPCMD_READ_TOC_PMA_ATIP),
154 safe_for_read(GPCMD_REPORT_KEY),
155 safe_for_read(GPCMD_SCAN),
156 safe_for_read(GPCMD_GET_CONFIGURATION),
157 safe_for_read(GPCMD_READ_FORMAT_CAPACITIES),
158 safe_for_read(GPCMD_GET_EVENT_STATUS_NOTIFICATION),
159 safe_for_read(GPCMD_GET_PERFORMANCE),
160 safe_for_read(GPCMD_SEEK),
161 safe_for_read(GPCMD_STOP_PLAY_SCAN),
162
163 /* Basic writing commands */
164 safe_for_write(WRITE_6),
165 safe_for_write(WRITE_10),
166 safe_for_write(WRITE_VERIFY),
167 safe_for_write(WRITE_12),
168 safe_for_write(WRITE_VERIFY_12),
169 safe_for_write(WRITE_16),
170 safe_for_write(WRITE_LONG),
171 safe_for_write(WRITE_LONG_2),
172 safe_for_write(ERASE),
173 safe_for_write(GPCMD_MODE_SELECT_10),
174 safe_for_write(MODE_SELECT),
175 safe_for_write(LOG_SELECT),
176 safe_for_write(GPCMD_BLANK),
177 safe_for_write(GPCMD_CLOSE_TRACK),
178 safe_for_write(GPCMD_FLUSH_CACHE),
179 safe_for_write(GPCMD_FORMAT_UNIT),
180 safe_for_write(GPCMD_REPAIR_RZONE_TRACK),
181 safe_for_write(GPCMD_RESERVE_RZONE_TRACK),
182 safe_for_write(GPCMD_SEND_DVD_STRUCTURE),
183 safe_for_write(GPCMD_SEND_EVENT),
184 safe_for_write(GPCMD_SEND_KEY),
185 safe_for_write(GPCMD_SEND_OPC),
186 safe_for_write(GPCMD_SEND_CUE_SHEET),
187 safe_for_write(GPCMD_SET_SPEED),
188 safe_for_write(GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL),
189 safe_for_write(GPCMD_LOAD_UNLOAD),
190 safe_for_write(GPCMD_SET_STREAMING),
191 };
192 unsigned char type = cmd_type[cmd[0]];
193
194 /* Anybody who can open the device can do a read-safe command */
195 if (type & CMD_READ_SAFE)
196 return 0;
197
198 /* Write-safe commands just require a writable open.. */
199 if (type & CMD_WRITE_SAFE) {
200 if (file->f_mode & FMODE_WRITE)
201 return 0;
202 }
203
204 /* And root can do any command.. */
205 if (capable(CAP_SYS_RAWIO))
206 return 0;
207
208 if (!type) {
209 cmd_type[cmd[0]] = CMD_WARNED;
210 printk(KERN_WARNING "scsi: unknown opcode 0x%02x\n", cmd[0]);
211 }
212
213 /* Otherwise fail it with an "Operation not permitted" */
214 return -EPERM;
215}
216
217static int sg_io(struct file *file, request_queue_t *q,
218 struct gendisk *bd_disk, struct sg_io_hdr *hdr)
219{
220 unsigned long start_time;
221 int writing = 0, ret = 0;
222 struct request *rq;
223 struct bio *bio;
224 char sense[SCSI_SENSE_BUFFERSIZE];
225 unsigned char cmd[BLK_MAX_CDB];
226
227 if (hdr->interface_id != 'S')
228 return -EINVAL;
229 if (hdr->cmd_len > BLK_MAX_CDB)
230 return -EINVAL;
231 if (copy_from_user(cmd, hdr->cmdp, hdr->cmd_len))
232 return -EFAULT;
233 if (verify_command(file, cmd))
234 return -EPERM;
235
236 if (hdr->dxfer_len > (q->max_sectors << 9))
237 return -EIO;
238
239 if (hdr->dxfer_len)
240 switch (hdr->dxfer_direction) {
241 default:
242 return -EINVAL;
243 case SG_DXFER_TO_FROM_DEV:
244 case SG_DXFER_TO_DEV:
245 writing = 1;
246 break;
247 case SG_DXFER_FROM_DEV:
248 break;
249 }
250
251 rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL);
252 if (!rq)
253 return -ENOMEM;
254
255 if (hdr->iovec_count) {
256 const int size = sizeof(struct sg_iovec) * hdr->iovec_count;
257 struct sg_iovec *iov;
258
259 iov = kmalloc(size, GFP_KERNEL);
260 if (!iov) {
261 ret = -ENOMEM;
262 goto out;
263 }
264
265 if (copy_from_user(iov, hdr->dxferp, size)) {
266 kfree(iov);
267 ret = -EFAULT;
268 goto out;
269 }
270
271 ret = blk_rq_map_user_iov(q, rq, iov, hdr->iovec_count);
272 kfree(iov);
273 } else if (hdr->dxfer_len)
274 ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len);
275
276 if (ret)
277 goto out;
278
279 /*
280 * fill in request structure
281 */
282 rq->cmd_len = hdr->cmd_len;
283 memcpy(rq->cmd, cmd, hdr->cmd_len);
284 if (sizeof(rq->cmd) != hdr->cmd_len)
285 memset(rq->cmd + hdr->cmd_len, 0, sizeof(rq->cmd) - hdr->cmd_len);
286
287 memset(sense, 0, sizeof(sense));
288 rq->sense = sense;
289 rq->sense_len = 0;
290
291 rq->flags |= REQ_BLOCK_PC;
292 bio = rq->bio;
293
294 /*
295 * bounce this after holding a reference to the original bio, it's
296 * needed for proper unmapping
297 */
298 if (rq->bio)
299 blk_queue_bounce(q, &rq->bio);
300
301 rq->timeout = (hdr->timeout * HZ) / 1000;
302 if (!rq->timeout)
303 rq->timeout = q->sg_timeout;
304 if (!rq->timeout)
305 rq->timeout = BLK_DEFAULT_TIMEOUT;
306
307 start_time = jiffies;
308
309 /* ignore return value. All information is passed back to caller
310 * (if he doesn't check that is his problem).
311 * N.B. a non-zero SCSI status is _not_ necessarily an error.
312 */
313 blk_execute_rq(q, bd_disk, rq, 0);
314
315 /* write to all output members */
316 hdr->status = 0xff & rq->errors;
317 hdr->masked_status = status_byte(rq->errors);
318 hdr->msg_status = msg_byte(rq->errors);
319 hdr->host_status = host_byte(rq->errors);
320 hdr->driver_status = driver_byte(rq->errors);
321 hdr->info = 0;
322 if (hdr->masked_status || hdr->host_status || hdr->driver_status)
323 hdr->info |= SG_INFO_CHECK;
324 hdr->resid = rq->data_len;
325 hdr->duration = ((jiffies - start_time) * 1000) / HZ;
326 hdr->sb_len_wr = 0;
327
328 if (rq->sense_len && hdr->sbp) {
329 int len = min((unsigned int) hdr->mx_sb_len, rq->sense_len);
330
331 if (!copy_to_user(hdr->sbp, rq->sense, len))
332 hdr->sb_len_wr = len;
333 }
334
335 if (blk_rq_unmap_user(bio, hdr->dxfer_len))
336 ret = -EFAULT;
337
338 /* may not have succeeded, but output values written to control
339 * structure (struct sg_io_hdr). */
340out:
341 blk_put_request(rq);
342 return ret;
343}
344
345#define OMAX_SB_LEN 16 /* For backward compatibility */
346
347static int sg_scsi_ioctl(struct file *file, request_queue_t *q,
348 struct gendisk *bd_disk, Scsi_Ioctl_Command __user *sic)
349{
350 struct request *rq;
351 int err;
352 unsigned int in_len, out_len, bytes, opcode, cmdlen;
353 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
354
355 /*
356 * get in an out lengths, verify they don't exceed a page worth of data
357 */
358 if (get_user(in_len, &sic->inlen))
359 return -EFAULT;
360 if (get_user(out_len, &sic->outlen))
361 return -EFAULT;
362 if (in_len > PAGE_SIZE || out_len > PAGE_SIZE)
363 return -EINVAL;
364 if (get_user(opcode, sic->data))
365 return -EFAULT;
366
367 bytes = max(in_len, out_len);
368 if (bytes) {
369 buffer = kmalloc(bytes, q->bounce_gfp | GFP_USER| __GFP_NOWARN);
370 if (!buffer)
371 return -ENOMEM;
372
373 memset(buffer, 0, bytes);
374 }
375
376 rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
377
378 cmdlen = COMMAND_SIZE(opcode);
379
380 /*
381 * get command and data to send to device, if any
382 */
383 err = -EFAULT;
384 rq->cmd_len = cmdlen;
385 if (copy_from_user(rq->cmd, sic->data, cmdlen))
386 goto error;
387
388 if (copy_from_user(buffer, sic->data + cmdlen, in_len))
389 goto error;
390
391 err = verify_command(file, rq->cmd);
392 if (err)
393 goto error;
394
395 switch (opcode) {
396 case SEND_DIAGNOSTIC:
397 case FORMAT_UNIT:
398 rq->timeout = FORMAT_UNIT_TIMEOUT;
399 break;
400 case START_STOP:
401 rq->timeout = START_STOP_TIMEOUT;
402 break;
403 case MOVE_MEDIUM:
404 rq->timeout = MOVE_MEDIUM_TIMEOUT;
405 break;
406 case READ_ELEMENT_STATUS:
407 rq->timeout = READ_ELEMENT_STATUS_TIMEOUT;
408 break;
409 case READ_DEFECT_DATA:
410 rq->timeout = READ_DEFECT_DATA_TIMEOUT;
411 break;
412 default:
413 rq->timeout = BLK_DEFAULT_TIMEOUT;
414 break;
415 }
416
417 memset(sense, 0, sizeof(sense));
418 rq->sense = sense;
419 rq->sense_len = 0;
420
421 rq->data = buffer;
422 rq->data_len = bytes;
423 rq->flags |= REQ_BLOCK_PC;
424
425 blk_execute_rq(q, bd_disk, rq, 0);
426 err = rq->errors & 0xff; /* only 8 bit SCSI status */
427 if (err) {
428 if (rq->sense_len && rq->sense) {
429 bytes = (OMAX_SB_LEN > rq->sense_len) ?
430 rq->sense_len : OMAX_SB_LEN;
431 if (copy_to_user(sic->data, rq->sense, bytes))
432 err = -EFAULT;
433 }
434 } else {
435 if (copy_to_user(sic->data, buffer, out_len))
436 err = -EFAULT;
437 }
438
439error:
440 kfree(buffer);
441 blk_put_request(rq);
442 return err;
443}
444
445int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
446{
447 request_queue_t *q;
448 struct request *rq;
449 int close = 0, err;
450
451 q = bd_disk->queue;
452 if (!q)
453 return -ENXIO;
454
455 if (blk_get_queue(q))
456 return -ENXIO;
457
458 switch (cmd) {
459 /*
460 * new sgv3 interface
461 */
462 case SG_GET_VERSION_NUM:
463 err = sg_get_version(arg);
464 break;
465 case SCSI_IOCTL_GET_IDLUN:
466 err = scsi_get_idlun(q, arg);
467 break;
468 case SCSI_IOCTL_GET_BUS_NUMBER:
469 err = scsi_get_bus(q, arg);
470 break;
471 case SG_SET_TIMEOUT:
472 err = sg_set_timeout(q, arg);
473 break;
474 case SG_GET_TIMEOUT:
475 err = sg_get_timeout(q);
476 break;
477 case SG_GET_RESERVED_SIZE:
478 err = sg_get_reserved_size(q, arg);
479 break;
480 case SG_SET_RESERVED_SIZE:
481 err = sg_set_reserved_size(q, arg);
482 break;
483 case SG_EMULATED_HOST:
484 err = sg_emulated_host(q, arg);
485 break;
486 case SG_IO: {
487 struct sg_io_hdr hdr;
488
489 err = -EFAULT;
490 if (copy_from_user(&hdr, arg, sizeof(hdr)))
491 break;
492 err = sg_io(file, q, bd_disk, &hdr);
493 if (err == -EFAULT)
494 break;
495
496 if (copy_to_user(arg, &hdr, sizeof(hdr)))
497 err = -EFAULT;
498 break;
499 }
500 case CDROM_SEND_PACKET: {
501 struct cdrom_generic_command cgc;
502 struct sg_io_hdr hdr;
503
504 err = -EFAULT;
505 if (copy_from_user(&cgc, arg, sizeof(cgc)))
506 break;
507 cgc.timeout = clock_t_to_jiffies(cgc.timeout);
508 memset(&hdr, 0, sizeof(hdr));
509 hdr.interface_id = 'S';
510 hdr.cmd_len = sizeof(cgc.cmd);
511 hdr.dxfer_len = cgc.buflen;
512 err = 0;
513 switch (cgc.data_direction) {
514 case CGC_DATA_UNKNOWN:
515 hdr.dxfer_direction = SG_DXFER_UNKNOWN;
516 break;
517 case CGC_DATA_WRITE:
518 hdr.dxfer_direction = SG_DXFER_TO_DEV;
519 break;
520 case CGC_DATA_READ:
521 hdr.dxfer_direction = SG_DXFER_FROM_DEV;
522 break;
523 case CGC_DATA_NONE:
524 hdr.dxfer_direction = SG_DXFER_NONE;
525 break;
526 default:
527 err = -EINVAL;
528 }
529 if (err)
530 break;
531
532 hdr.dxferp = cgc.buffer;
533 hdr.sbp = cgc.sense;
534 if (hdr.sbp)
535 hdr.mx_sb_len = sizeof(struct request_sense);
536 hdr.timeout = cgc.timeout;
537 hdr.cmdp = ((struct cdrom_generic_command __user*) arg)->cmd;
538 hdr.cmd_len = sizeof(cgc.cmd);
539
540 err = sg_io(file, q, bd_disk, &hdr);
541 if (err == -EFAULT)
542 break;
543
544 if (hdr.status)
545 err = -EIO;
546
547 cgc.stat = err;
548 cgc.buflen = hdr.resid;
549 if (copy_to_user(arg, &cgc, sizeof(cgc)))
550 err = -EFAULT;
551
552 break;
553 }
554
555 /*
556 * old junk scsi send command ioctl
557 */
558 case SCSI_IOCTL_SEND_COMMAND:
559 printk(KERN_WARNING "program %s is using a deprecated SCSI ioctl, please convert it to SG_IO\n", current->comm);
560 err = -EINVAL;
561 if (!arg)
562 break;
563
564 err = sg_scsi_ioctl(file, q, bd_disk, arg);
565 break;
566 case CDROMCLOSETRAY:
567 close = 1;
568 case CDROMEJECT:
569 rq = blk_get_request(q, WRITE, __GFP_WAIT);
570 rq->flags |= REQ_BLOCK_PC;
571 rq->data = NULL;
572 rq->data_len = 0;
573 rq->timeout = BLK_DEFAULT_TIMEOUT;
574 memset(rq->cmd, 0, sizeof(rq->cmd));
575 rq->cmd[0] = GPCMD_START_STOP_UNIT;
576 rq->cmd[4] = 0x02 + (close != 0);
577 rq->cmd_len = 6;
578 err = blk_execute_rq(q, bd_disk, rq, 0);
579 blk_put_request(rq);
580 break;
581 default:
582 err = -ENOTTY;
583 }
584
585 blk_put_queue(q);
586 return err;
587}
588
589EXPORT_SYMBOL(scsi_cmd_ioctl);
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index e425ad3eebba..af7cb2bfd670 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -28,6 +28,7 @@
28#include <linux/devfs_fs_kernel.h> 28#include <linux/devfs_fs_kernel.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/spinlock.h>
31#include <asm/io.h> 32#include <asm/io.h>
32#include <asm/dbdma.h> 33#include <asm/dbdma.h>
33#include <asm/prom.h> 34#include <asm/prom.h>
@@ -176,6 +177,7 @@ struct swim3 {
176 177
177struct floppy_state { 178struct floppy_state {
178 enum swim_state state; 179 enum swim_state state;
180 spinlock_t lock;
179 struct swim3 __iomem *swim3; /* hardware registers */ 181 struct swim3 __iomem *swim3; /* hardware registers */
180 struct dbdma_regs __iomem *dma; /* DMA controller registers */ 182 struct dbdma_regs __iomem *dma; /* DMA controller registers */
181 int swim3_intr; /* interrupt number for SWIM3 */ 183 int swim3_intr; /* interrupt number for SWIM3 */
@@ -304,7 +306,6 @@ static void do_fd_request(request_queue_t * q)
304#endif /* CONFIG_PMAC_MEDIABAY */ 306#endif /* CONFIG_PMAC_MEDIABAY */
305 start_request(&floppy_states[i]); 307 start_request(&floppy_states[i]);
306 } 308 }
307 sti();
308} 309}
309 310
310static void start_request(struct floppy_state *fs) 311static void start_request(struct floppy_state *fs)
@@ -370,7 +371,7 @@ static void set_timeout(struct floppy_state *fs, int nticks,
370{ 371{
371 unsigned long flags; 372 unsigned long flags;
372 373
373 save_flags(flags); cli(); 374 spin_lock_irqsave(&fs->lock, flags);
374 if (fs->timeout_pending) 375 if (fs->timeout_pending)
375 del_timer(&fs->timeout); 376 del_timer(&fs->timeout);
376 fs->timeout.expires = jiffies + nticks; 377 fs->timeout.expires = jiffies + nticks;
@@ -378,7 +379,7 @@ static void set_timeout(struct floppy_state *fs, int nticks,
378 fs->timeout.data = (unsigned long) fs; 379 fs->timeout.data = (unsigned long) fs;
379 add_timer(&fs->timeout); 380 add_timer(&fs->timeout);
380 fs->timeout_pending = 1; 381 fs->timeout_pending = 1;
381 restore_flags(flags); 382 spin_unlock_irqrestore(&fs->lock, flags);
382} 383}
383 384
384static inline void scan_track(struct floppy_state *fs) 385static inline void scan_track(struct floppy_state *fs)
@@ -790,14 +791,13 @@ static int grab_drive(struct floppy_state *fs, enum swim_state state,
790{ 791{
791 unsigned long flags; 792 unsigned long flags;
792 793
793 save_flags(flags); 794 spin_lock_irqsave(&fs->lock, flags);
794 cli();
795 if (fs->state != idle) { 795 if (fs->state != idle) {
796 ++fs->wanted; 796 ++fs->wanted;
797 while (fs->state != available) { 797 while (fs->state != available) {
798 if (interruptible && signal_pending(current)) { 798 if (interruptible && signal_pending(current)) {
799 --fs->wanted; 799 --fs->wanted;
800 restore_flags(flags); 800 spin_unlock_irqrestore(&fs->lock, flags);
801 return -EINTR; 801 return -EINTR;
802 } 802 }
803 interruptible_sleep_on(&fs->wait); 803 interruptible_sleep_on(&fs->wait);
@@ -805,7 +805,7 @@ static int grab_drive(struct floppy_state *fs, enum swim_state state,
805 --fs->wanted; 805 --fs->wanted;
806 } 806 }
807 fs->state = state; 807 fs->state = state;
808 restore_flags(flags); 808 spin_unlock_irqrestore(&fs->lock, flags);
809 return 0; 809 return 0;
810} 810}
811 811
@@ -813,11 +813,10 @@ static void release_drive(struct floppy_state *fs)
813{ 813{
814 unsigned long flags; 814 unsigned long flags;
815 815
816 save_flags(flags); 816 spin_lock_irqsave(&fs->lock, flags);
817 cli();
818 fs->state = idle; 817 fs->state = idle;
819 start_request(fs); 818 start_request(fs);
820 restore_flags(flags); 819 spin_unlock_irqrestore(&fs->lock, flags);
821} 820}
822 821
823static int fd_eject(struct floppy_state *fs) 822static int fd_eject(struct floppy_state *fs)
@@ -1109,6 +1108,7 @@ static int swim3_add_device(struct device_node *swim)
1109 pmac_call_feature(PMAC_FTR_SWIM3_ENABLE, swim, 0, 1); 1108 pmac_call_feature(PMAC_FTR_SWIM3_ENABLE, swim, 0, 1);
1110 1109
1111 memset(fs, 0, sizeof(*fs)); 1110 memset(fs, 0, sizeof(*fs));
1111 spin_lock_init(&fs->lock);
1112 fs->state = idle; 1112 fs->state = idle;
1113 fs->swim3 = (struct swim3 __iomem *) 1113 fs->swim3 = (struct swim3 __iomem *)
1114 ioremap(swim->addrs[0].address, 0x200); 1114 ioremap(swim->addrs[0].address, 0x200);
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 5fd3e4cb7525..8e7fb3551775 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -179,14 +179,12 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
179 if (ignore || (intf->cur_altsetting->desc.bInterfaceNumber != 0)) 179 if (ignore || (intf->cur_altsetting->desc.bInterfaceNumber != 0))
180 return -ENODEV; 180 return -ENODEV;
181 181
182 data = kmalloc(sizeof(*data), GFP_KERNEL); 182 data = kzalloc(sizeof(*data), GFP_KERNEL);
183 if (!data) { 183 if (!data) {
184 BT_ERR("Can't allocate memory for data structure"); 184 BT_ERR("Can't allocate memory for data structure");
185 return -ENOMEM; 185 return -ENOMEM;
186 } 186 }
187 187
188 memset(data, 0, sizeof(*data));
189
190 data->udev = udev; 188 data->udev = udev;
191 data->state = BCM203X_LOAD_MINIDRV; 189 data->state = BCM203X_LOAD_MINIDRV;
192 190
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index 1e9db0156ea7..067e27893e4a 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -673,13 +673,11 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
673 } 673 }
674 674
675 /* Initialize control structure and load firmware */ 675 /* Initialize control structure and load firmware */
676 if (!(bfusb = kmalloc(sizeof(struct bfusb), GFP_KERNEL))) { 676 if (!(bfusb = kzalloc(sizeof(struct bfusb), GFP_KERNEL))) {
677 BT_ERR("Can't allocate memory for control structure"); 677 BT_ERR("Can't allocate memory for control structure");
678 goto done; 678 goto done;
679 } 679 }
680 680
681 memset(bfusb, 0, sizeof(struct bfusb));
682
683 bfusb->udev = udev; 681 bfusb->udev = udev;
684 bfusb->bulk_in_ep = bulk_in_ep->desc.bEndpointAddress; 682 bfusb->bulk_in_ep = bulk_in_ep->desc.bEndpointAddress;
685 bfusb->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress; 683 bfusb->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress;
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 26fe9c0e1d20..f36c563d72c4 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -870,10 +870,9 @@ static dev_link_t *bluecard_attach(void)
870 int ret; 870 int ret;
871 871
872 /* Create new info device */ 872 /* Create new info device */
873 info = kmalloc(sizeof(*info), GFP_KERNEL); 873 info = kzalloc(sizeof(*info), GFP_KERNEL);
874 if (!info) 874 if (!info)
875 return NULL; 875 return NULL;
876 memset(info, 0, sizeof(*info));
877 876
878 link = &info->link; 877 link = &info->link;
879 link->priv = info; 878 link->priv = info;
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 0db0400519c9..ecbeb7eaba8e 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -553,14 +553,12 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *
553 if (intf->cur_altsetting->desc.bInterfaceNumber > 0) 553 if (intf->cur_altsetting->desc.bInterfaceNumber > 0)
554 return -ENODEV; 554 return -ENODEV;
555 555
556 data = kmalloc(sizeof(*data), GFP_KERNEL); 556 data = kzalloc(sizeof(*data), GFP_KERNEL);
557 if (!data) { 557 if (!data) {
558 BT_ERR("Can't allocate data structure"); 558 BT_ERR("Can't allocate data structure");
559 return -ENOMEM; 559 return -ENOMEM;
560 } 560 }
561 561
562 memset(data, 0, sizeof(*data));
563
564 data->udev = udev; 562 data->udev = udev;
565 563
566 rwlock_init(&data->lock); 564 rwlock_init(&data->lock);
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 2e0338d80f32..d2a0add19cc8 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -671,10 +671,9 @@ static dev_link_t *bt3c_attach(void)
671 int ret; 671 int ret;
672 672
673 /* Create new info device */ 673 /* Create new info device */
674 info = kmalloc(sizeof(*info), GFP_KERNEL); 674 info = kzalloc(sizeof(*info), GFP_KERNEL);
675 if (!info) 675 if (!info)
676 return NULL; 676 return NULL;
677 memset(info, 0, sizeof(*info));
678 677
679 link = &info->link; 678 link = &info->link;
680 link->priv = info; 679 link->priv = info;
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 89486ea7a021..529a28a3209d 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -590,10 +590,9 @@ static dev_link_t *btuart_attach(void)
590 int ret; 590 int ret;
591 591
592 /* Create new info device */ 592 /* Create new info device */
593 info = kmalloc(sizeof(*info), GFP_KERNEL); 593 info = kzalloc(sizeof(*info), GFP_KERNEL);
594 if (!info) 594 if (!info)
595 return NULL; 595 return NULL;
596 memset(info, 0, sizeof(*info));
597 596
598 link = &info->link; 597 link = &info->link;
599 link->priv = info; 598 link->priv = info;
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 84c1f8839422..dec5980a1cd6 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -569,10 +569,9 @@ static dev_link_t *dtl1_attach(void)
569 int ret; 569 int ret;
570 570
571 /* Create new info device */ 571 /* Create new info device */
572 info = kmalloc(sizeof(*info), GFP_KERNEL); 572 info = kzalloc(sizeof(*info), GFP_KERNEL);
573 if (!info) 573 if (!info)
574 return NULL; 574 return NULL;
575 memset(info, 0, sizeof(*info));
576 575
577 link = &info->link; 576 link = &info->link;
578 link->priv = info; 577 link->priv = info;
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 0a4761415ac3..8fddfdfd0fbd 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -715,10 +715,9 @@ static int bcsp_open(struct hci_uart *hu)
715 715
716 BT_DBG("hu %p", hu); 716 BT_DBG("hu %p", hu);
717 717
718 bcsp = kmalloc(sizeof(*bcsp), GFP_ATOMIC); 718 bcsp = kzalloc(sizeof(*bcsp), GFP_ATOMIC);
719 if (!bcsp) 719 if (!bcsp)
720 return -ENOMEM; 720 return -ENOMEM;
721 memset(bcsp, 0, sizeof(*bcsp));
722 721
723 hu->priv = bcsp; 722 hu->priv = bcsp;
724 skb_queue_head_init(&bcsp->unack); 723 skb_queue_head_init(&bcsp->unack);
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 12e369a66fc2..4804d474dc87 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -76,12 +76,10 @@ static int h4_open(struct hci_uart *hu)
76 76
77 BT_DBG("hu %p", hu); 77 BT_DBG("hu %p", hu);
78 78
79 h4 = kmalloc(sizeof(*h4), GFP_ATOMIC); 79 h4 = kzalloc(sizeof(*h4), GFP_ATOMIC);
80 if (!h4) 80 if (!h4)
81 return -ENOMEM; 81 return -ENOMEM;
82 82
83 memset(h4, 0, sizeof(*h4));
84
85 skb_queue_head_init(&h4->txq); 83 skb_queue_head_init(&h4->txq);
86 84
87 hu->priv = h4; 85 hu->priv = h4;
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 4a775f6ea390..573ff6c1be5f 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -272,13 +272,11 @@ static int hci_uart_tty_open(struct tty_struct *tty)
272 if (hu) 272 if (hu)
273 return -EEXIST; 273 return -EEXIST;
274 274
275 if (!(hu = kmalloc(sizeof(struct hci_uart), GFP_KERNEL))) { 275 if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) {
276 BT_ERR("Can't allocate controll structure"); 276 BT_ERR("Can't allocate controll structure");
277 return -ENFILE; 277 return -ENFILE;
278 } 278 }
279 279
280 memset(hu, 0, sizeof(struct hci_uart));
281
282 tty->disc_data = hu; 280 tty->disc_data = hu;
283 hu->tty = tty; 281 hu->tty = tty;
284 282
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 6756cb20b753..f510b25b2c59 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -875,13 +875,11 @@ static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id
875 goto done; 875 goto done;
876 } 876 }
877 877
878 if (!(husb = kmalloc(sizeof(struct hci_usb), GFP_KERNEL))) { 878 if (!(husb = kzalloc(sizeof(struct hci_usb), GFP_KERNEL))) {
879 BT_ERR("Can't allocate: control structure"); 879 BT_ERR("Can't allocate: control structure");
880 goto done; 880 goto done;
881 } 881 }
882 882
883 memset(husb, 0, sizeof(struct hci_usb));
884
885 husb->udev = udev; 883 husb->udev = udev;
886 husb->bulk_out_ep = bulk_out_ep; 884 husb->bulk_out_ep = bulk_out_ep;
887 husb->bulk_in_ep = bulk_in_ep; 885 husb->bulk_in_ep = bulk_in_ep;
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 52cbd45c308f..85738223ff0c 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -261,12 +261,10 @@ static int vhci_open(struct inode *inode, struct file *file)
261 struct vhci_data *vhci; 261 struct vhci_data *vhci;
262 struct hci_dev *hdev; 262 struct hci_dev *hdev;
263 263
264 vhci = kmalloc(sizeof(struct vhci_data), GFP_KERNEL); 264 vhci = kzalloc(sizeof(struct vhci_data), GFP_KERNEL);
265 if (!vhci) 265 if (!vhci)
266 return -ENOMEM; 266 return -ENOMEM;
267 267
268 memset(vhci, 0, sizeof(struct vhci_data));
269
270 skb_queue_head_init(&vhci->readq); 268 skb_queue_head_init(&vhci->readq);
271 init_waitqueue_head(&vhci->read_wait); 269 init_waitqueue_head(&vhci->read_wait);
272 270
diff --git a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
index b89420e6d704..a0b580c22d80 100644
--- a/drivers/cdrom/mcdx.c
+++ b/drivers/cdrom/mcdx.c
@@ -1085,7 +1085,7 @@ static int __init mcdx_init_drive(int drive)
1085 1085
1086 xtrace(INIT, "kmalloc space for stuffpt's\n"); 1086 xtrace(INIT, "kmalloc space for stuffpt's\n");
1087 xtrace(MALLOC, "init() malloc %d bytes\n", size); 1087 xtrace(MALLOC, "init() malloc %d bytes\n", size);
1088 if (!(stuffp = kmalloc(size, GFP_KERNEL))) { 1088 if (!(stuffp = kzalloc(size, GFP_KERNEL))) {
1089 xwarn("init() malloc failed\n"); 1089 xwarn("init() malloc failed\n");
1090 return 1; 1090 return 1;
1091 } 1091 }
@@ -1101,8 +1101,6 @@ static int __init mcdx_init_drive(int drive)
1101 sizeof(*stuffp), stuffp); 1101 sizeof(*stuffp), stuffp);
1102 1102
1103 /* set default values */ 1103 /* set default values */
1104 memset(stuffp, 0, sizeof(*stuffp));
1105
1106 stuffp->present = 0; /* this should be 0 already */ 1104 stuffp->present = 0; /* this should be 0 already */
1107 stuffp->toc = NULL; /* this should be NULL already */ 1105 stuffp->toc = NULL; /* this should be NULL already */
1108 1106
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index b02fc2267159..ba54b5872578 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -389,6 +389,7 @@ 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,
392 .name = "agpgart-ali", 393 .name = "agpgart-ali",
393 .id_table = agp_ali_pci_table, 394 .id_table = agp_ali_pci_table,
394 .probe = agp_ali_probe, 395 .probe = agp_ali_probe,
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index 3a41672e4d66..40fcd88b2cea 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -94,19 +94,16 @@ static int amd_create_gatt_pages(int nr_tables)
94 int retval = 0; 94 int retval = 0;
95 int i; 95 int i;
96 96
97 tables = kmalloc((nr_tables + 1) * sizeof(struct amd_page_map *), 97 tables = kzalloc((nr_tables + 1) * sizeof(struct amd_page_map *),GFP_KERNEL);
98 GFP_KERNEL);
99 if (tables == NULL) 98 if (tables == NULL)
100 return -ENOMEM; 99 return -ENOMEM;
101 100
102 memset (tables, 0, sizeof(struct amd_page_map *) * (nr_tables + 1));
103 for (i = 0; i < nr_tables; i++) { 101 for (i = 0; i < nr_tables; i++) {
104 entry = kmalloc(sizeof(struct amd_page_map), GFP_KERNEL); 102 entry = kzalloc(sizeof(struct amd_page_map), GFP_KERNEL);
105 if (entry == NULL) { 103 if (entry == NULL) {
106 retval = -ENOMEM; 104 retval = -ENOMEM;
107 break; 105 break;
108 } 106 }
109 memset (entry, 0, sizeof(struct amd_page_map));
110 tables[i] = entry; 107 tables[i] = entry;
111 retval = amd_create_page_map(entry); 108 retval = amd_create_page_map(entry);
112 if (retval != 0) 109 if (retval != 0)
@@ -518,6 +515,7 @@ static struct pci_device_id agp_amdk7_pci_table[] = {
518MODULE_DEVICE_TABLE(pci, agp_amdk7_pci_table); 515MODULE_DEVICE_TABLE(pci, agp_amdk7_pci_table);
519 516
520static struct pci_driver agp_amdk7_pci_driver = { 517static struct pci_driver agp_amdk7_pci_driver = {
518 .owner = THIS_MODULE,
521 .name = "agpgart-amdk7", 519 .name = "agpgart-amdk7",
522 .id_table = agp_amdk7_pci_table, 520 .id_table = agp_amdk7_pci_table,
523 .probe = agp_amdk7_probe, 521 .probe = agp_amdk7_probe,
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 0e6c3a31d344..8f748fddca94 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -13,6 +13,7 @@
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/agp_backend.h> 15#include <linux/agp_backend.h>
16#include <linux/mmzone.h>
16#include <asm/page.h> /* PAGE_SIZE */ 17#include <asm/page.h> /* PAGE_SIZE */
17#include "agp.h" 18#include "agp.h"
18 19
@@ -702,6 +703,7 @@ static struct pci_device_id agp_amd64_pci_table[] = {
702MODULE_DEVICE_TABLE(pci, agp_amd64_pci_table); 703MODULE_DEVICE_TABLE(pci, agp_amd64_pci_table);
703 704
704static struct pci_driver agp_amd64_pci_driver = { 705static struct pci_driver agp_amd64_pci_driver = {
706 .owner = THIS_MODULE,
705 .name = "agpgart-amd64", 707 .name = "agpgart-amd64",
706 .id_table = agp_amd64_pci_table, 708 .id_table = agp_amd64_pci_table,
707 .probe = agp_amd64_probe, 709 .probe = agp_amd64_probe,
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 0b6e72642d6e..fbd415565463 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -118,14 +118,12 @@ static int ati_create_gatt_pages(int nr_tables)
118 int retval = 0; 118 int retval = 0;
119 int i; 119 int i;
120 120
121 tables = kmalloc((nr_tables + 1) * sizeof(ati_page_map *), 121 tables = kzalloc((nr_tables + 1) * sizeof(ati_page_map *),GFP_KERNEL);
122 GFP_KERNEL);
123 if (tables == NULL) 122 if (tables == NULL)
124 return -ENOMEM; 123 return -ENOMEM;
125 124
126 memset(tables, 0, sizeof(ati_page_map *) * (nr_tables + 1));
127 for (i = 0; i < nr_tables; i++) { 125 for (i = 0; i < nr_tables; i++) {
128 entry = kmalloc(sizeof(ati_page_map), GFP_KERNEL); 126 entry = kzalloc(sizeof(ati_page_map), GFP_KERNEL);
129 if (entry == NULL) { 127 if (entry == NULL) {
130 while (i>0) { 128 while (i>0) {
131 kfree (tables[i-1]); 129 kfree (tables[i-1]);
@@ -136,7 +134,6 @@ static int ati_create_gatt_pages(int nr_tables)
136 retval = -ENOMEM; 134 retval = -ENOMEM;
137 break; 135 break;
138 } 136 }
139 memset(entry, 0, sizeof(ati_page_map));
140 tables[i] = entry; 137 tables[i] = entry;
141 retval = ati_create_page_map(entry); 138 retval = ati_create_page_map(entry);
142 if (retval != 0) break; 139 if (retval != 0) break;
@@ -524,6 +521,7 @@ static struct pci_device_id agp_ati_pci_table[] = {
524MODULE_DEVICE_TABLE(pci, agp_ati_pci_table); 521MODULE_DEVICE_TABLE(pci, agp_ati_pci_table);
525 522
526static struct pci_driver agp_ati_pci_driver = { 523static struct pci_driver agp_ati_pci_driver = {
524 .owner = THIS_MODULE,
527 .name = "agpgart-ati", 525 .name = "agpgart-ati",
528 .id_table = agp_ati_pci_table, 526 .id_table = agp_ati_pci_table,
529 .probe = agp_ati_probe, 527 .probe = agp_ati_probe,
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 82b43c541c8d..73f333f491bd 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -222,12 +222,12 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
222 222
223struct agp_bridge_data *agp_alloc_bridge(void) 223struct agp_bridge_data *agp_alloc_bridge(void)
224{ 224{
225 struct agp_bridge_data *bridge = kmalloc(sizeof(*bridge), GFP_KERNEL); 225 struct agp_bridge_data *bridge;
226 226
227 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
227 if (!bridge) 228 if (!bridge)
228 return NULL; 229 return NULL;
229 230
230 memset(bridge, 0, sizeof(*bridge));
231 atomic_set(&bridge->agp_in_use, 0); 231 atomic_set(&bridge->agp_in_use, 0);
232 atomic_set(&bridge->current_memory_agp, 0); 232 atomic_set(&bridge->current_memory_agp, 0);
233 233
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index ac19fdcd21c1..d41e0a62e32e 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -219,7 +219,7 @@ static int efficeon_create_gatt_table(struct agp_bridge_data *bridge)
219 219
220 efficeon_private.l1_table[index] = page; 220 efficeon_private.l1_table[index] = page;
221 221
222 value = virt_to_gart(page) | pati | present | index; 222 value = virt_to_gart((unsigned long *)page) | pati | present | index;
223 223
224 pci_write_config_dword(agp_bridge->dev, 224 pci_write_config_dword(agp_bridge->dev,
225 EFFICEON_ATTPAGE, value); 225 EFFICEON_ATTPAGE, value);
@@ -429,6 +429,7 @@ 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,
432 .name = "agpgart-efficeon", 433 .name = "agpgart-efficeon",
433 .id_table = agp_efficeon_pci_table, 434 .id_table = agp_efficeon_pci_table,
434 .probe = agp_efficeon_probe, 435 .probe = agp_efficeon_probe,
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 3dfb6648547b..17f520c9d471 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -189,13 +189,12 @@ static int agp_create_segment(struct agp_client *client, struct agp_region *regi
189 struct agp_segment *user_seg; 189 struct agp_segment *user_seg;
190 size_t i; 190 size_t i;
191 191
192 seg = kmalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL); 192 seg = kzalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
193 if (seg == NULL) { 193 if (seg == NULL) {
194 kfree(region->seg_list); 194 kfree(region->seg_list);
195 region->seg_list = NULL; 195 region->seg_list = NULL;
196 return -ENOMEM; 196 return -ENOMEM;
197 } 197 }
198 memset(seg, 0, (sizeof(struct agp_segment_priv) * region->seg_count));
199 user_seg = region->seg_list; 198 user_seg = region->seg_list;
200 199
201 for (i = 0; i < region->seg_count; i++) { 200 for (i = 0; i < region->seg_count; i++) {
@@ -332,14 +331,11 @@ static struct agp_controller *agp_create_controller(pid_t id)
332{ 331{
333 struct agp_controller *controller; 332 struct agp_controller *controller;
334 333
335 controller = kmalloc(sizeof(struct agp_controller), GFP_KERNEL); 334 controller = kzalloc(sizeof(struct agp_controller), GFP_KERNEL);
336
337 if (controller == NULL) 335 if (controller == NULL)
338 return NULL; 336 return NULL;
339 337
340 memset(controller, 0, sizeof(struct agp_controller));
341 controller->pid = id; 338 controller->pid = id;
342
343 return controller; 339 return controller;
344} 340}
345 341
@@ -540,12 +536,10 @@ static struct agp_client *agp_create_client(pid_t id)
540{ 536{
541 struct agp_client *new_client; 537 struct agp_client *new_client;
542 538
543 new_client = kmalloc(sizeof(struct agp_client), GFP_KERNEL); 539 new_client = kzalloc(sizeof(struct agp_client), GFP_KERNEL);
544
545 if (new_client == NULL) 540 if (new_client == NULL)
546 return NULL; 541 return NULL;
547 542
548 memset(new_client, 0, sizeof(struct agp_client));
549 new_client->pid = id; 543 new_client->pid = id;
550 agp_insert_client(new_client); 544 agp_insert_client(new_client);
551 return new_client; 545 return new_client;
@@ -709,11 +703,10 @@ static int agp_open(struct inode *inode, struct file *file)
709 if (minor != AGPGART_MINOR) 703 if (minor != AGPGART_MINOR)
710 goto err_out; 704 goto err_out;
711 705
712 priv = kmalloc(sizeof(struct agp_file_private), GFP_KERNEL); 706 priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL);
713 if (priv == NULL) 707 if (priv == NULL)
714 goto err_out_nomem; 708 goto err_out_nomem;
715 709
716 memset(priv, 0, sizeof(struct agp_file_private));
717 set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags); 710 set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
718 priv->my_pid = current->pid; 711 priv->my_pid = current->pid;
719 712
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index ac9da0ca36b7..c4a38715c6f9 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -105,12 +105,10 @@ struct agp_memory *agp_create_memory(int scratch_pages)
105{ 105{
106 struct agp_memory *new; 106 struct agp_memory *new;
107 107
108 new = kmalloc(sizeof(struct agp_memory), GFP_KERNEL); 108 new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL);
109
110 if (new == NULL) 109 if (new == NULL)
111 return NULL; 110 return NULL;
112 111
113 memset(new, 0, sizeof(struct agp_memory));
114 new->key = agp_get_key(); 112 new->key = agp_get_key();
115 113
116 if (new->key < 0) { 114 if (new->key < 0) {
@@ -414,7 +412,8 @@ static void agp_v2_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_
414 u32 tmp; 412 u32 tmp;
415 413
416 if (*requested_mode & AGP2_RESERVED_MASK) { 414 if (*requested_mode & AGP2_RESERVED_MASK) {
417 printk(KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); 415 printk(KERN_INFO PFX "reserved bits set (%x) in mode 0x%x. Fixed.\n",
416 *requested_mode & AGP2_RESERVED_MASK, *requested_mode);
418 *requested_mode &= ~AGP2_RESERVED_MASK; 417 *requested_mode &= ~AGP2_RESERVED_MASK;
419 } 418 }
420 419
@@ -492,7 +491,8 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_
492 u32 tmp; 491 u32 tmp;
493 492
494 if (*requested_mode & AGP3_RESERVED_MASK) { 493 if (*requested_mode & AGP3_RESERVED_MASK) {
495 printk(KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); 494 printk(KERN_INFO PFX "reserved bits set (%x) in mode 0x%x. Fixed.\n",
495 *requested_mode & AGP3_RESERVED_MASK, *requested_mode);
496 *requested_mode &= ~AGP3_RESERVED_MASK; 496 *requested_mode &= ~AGP3_RESERVED_MASK;
497 } 497 }
498 498
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index a2d9e5e48bbe..58944cd271ea 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -227,10 +227,9 @@ static int i460_configure (void)
227 */ 227 */
228 if (I460_IO_PAGE_SHIFT > PAGE_SHIFT) { 228 if (I460_IO_PAGE_SHIFT > PAGE_SHIFT) {
229 size = current_size->num_entries * sizeof(i460.lp_desc[0]); 229 size = current_size->num_entries * sizeof(i460.lp_desc[0]);
230 i460.lp_desc = kmalloc(size, GFP_KERNEL); 230 i460.lp_desc = kzalloc(size, GFP_KERNEL);
231 if (!i460.lp_desc) 231 if (!i460.lp_desc)
232 return -ENOMEM; 232 return -ENOMEM;
233 memset(i460.lp_desc, 0, size);
234 } 233 }
235 return 0; 234 return 0;
236} 235}
@@ -366,13 +365,12 @@ static int i460_alloc_large_page (struct lp_desc *lp)
366 } 365 }
367 366
368 map_size = ((I460_KPAGES_PER_IOPAGE + BITS_PER_LONG - 1) & -BITS_PER_LONG)/8; 367 map_size = ((I460_KPAGES_PER_IOPAGE + BITS_PER_LONG - 1) & -BITS_PER_LONG)/8;
369 lp->alloced_map = kmalloc(map_size, GFP_KERNEL); 368 lp->alloced_map = kzalloc(map_size, GFP_KERNEL);
370 if (!lp->alloced_map) { 369 if (!lp->alloced_map) {
371 free_pages((unsigned long) lpage, order); 370 free_pages((unsigned long) lpage, order);
372 printk(KERN_ERR PFX "Out of memory, we're in trouble...\n"); 371 printk(KERN_ERR PFX "Out of memory, we're in trouble...\n");
373 return -ENOMEM; 372 return -ENOMEM;
374 } 373 }
375 memset(lp->alloced_map, 0, map_size);
376 374
377 lp->paddr = virt_to_gart(lpage); 375 lp->paddr = virt_to_gart(lpage);
378 lp->refcount = 0; 376 lp->refcount = 0;
@@ -619,6 +617,7 @@ static struct pci_device_id agp_intel_i460_pci_table[] = {
619MODULE_DEVICE_TABLE(pci, agp_intel_i460_pci_table); 617MODULE_DEVICE_TABLE(pci, agp_intel_i460_pci_table);
620 618
621static struct pci_driver agp_intel_i460_pci_driver = { 619static struct pci_driver agp_intel_i460_pci_driver = {
620 .owner = THIS_MODULE,
622 .name = "agpgart-intel-i460", 621 .name = "agpgart-intel-i460",
623 .id_table = agp_intel_i460_pci_table, 622 .id_table = agp_intel_i460_pci_table,
624 .probe = agp_intel_i460_probe, 623 .probe = agp_intel_i460_probe,
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 1f7d415f432c..bf4cc9ffd5b1 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -1824,6 +1824,7 @@ static struct pci_device_id agp_intel_pci_table[] = {
1824MODULE_DEVICE_TABLE(pci, agp_intel_pci_table); 1824MODULE_DEVICE_TABLE(pci, agp_intel_pci_table);
1825 1825
1826static struct pci_driver agp_intel_pci_driver = { 1826static struct pci_driver agp_intel_pci_driver = {
1827 .owner = THIS_MODULE,
1827 .name = "agpgart-intel", 1828 .name = "agpgart-intel",
1828 .id_table = agp_intel_pci_table, 1829 .id_table = agp_intel_pci_table,
1829 .probe = agp_intel_probe, 1830 .probe = agp_intel_probe,
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 80dafa3030bd..3aed0c5e2f92 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -398,6 +398,7 @@ 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,
401 .name = "agpgart-nvidia", 402 .name = "agpgart-nvidia",
402 .id_table = agp_nvidia_pci_table, 403 .id_table = agp_nvidia_pci_table,
403 .probe = agp_nvidia_probe, 404 .probe = agp_nvidia_probe,
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 7957fc91f6ad..4df7734b51c2 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -289,6 +289,8 @@ static int __devinit agp_sgi_init(void)
289 j = 0; 289 j = 0;
290 list_for_each_entry(info, &tioca_list, ca_list) { 290 list_for_each_entry(info, &tioca_list, ca_list) {
291 struct list_head *tmp; 291 struct list_head *tmp;
292 if (list_empty(info->ca_devices))
293 continue;
292 list_for_each(tmp, info->ca_devices) { 294 list_for_each(tmp, info->ca_devices) {
293 u8 cap_ptr; 295 u8 cap_ptr;
294 pdev = pci_dev_b(tmp); 296 pdev = pci_dev_b(tmp);
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index ebc05554045c..a701361a8890 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -332,6 +332,7 @@ 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,
335 .name = "agpgart-sis", 336 .name = "agpgart-sis",
336 .id_table = agp_sis_pci_table, 337 .id_table = agp_sis_pci_table,
337 .probe = agp_sis_probe, 338 .probe = agp_sis_probe,
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index 71ea59a1dbeb..5a5392dd1254 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -102,19 +102,17 @@ static int serverworks_create_gatt_pages(int nr_tables)
102 int retval = 0; 102 int retval = 0;
103 int i; 103 int i;
104 104
105 tables = kmalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *), 105 tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *),
106 GFP_KERNEL); 106 GFP_KERNEL);
107 if (tables == NULL) { 107 if (tables == NULL)
108 return -ENOMEM; 108 return -ENOMEM;
109 } 109
110 memset(tables, 0, sizeof(struct serverworks_page_map *) * (nr_tables + 1));
111 for (i = 0; i < nr_tables; i++) { 110 for (i = 0; i < nr_tables; i++) {
112 entry = kmalloc(sizeof(struct serverworks_page_map), GFP_KERNEL); 111 entry = kzalloc(sizeof(struct serverworks_page_map), GFP_KERNEL);
113 if (entry == NULL) { 112 if (entry == NULL) {
114 retval = -ENOMEM; 113 retval = -ENOMEM;
115 break; 114 break;
116 } 115 }
117 memset(entry, 0, sizeof(struct serverworks_page_map));
118 tables[i] = entry; 116 tables[i] = entry;
119 retval = serverworks_create_page_map(entry); 117 retval = serverworks_create_page_map(entry);
120 if (retval != 0) break; 118 if (retval != 0) break;
@@ -244,13 +242,27 @@ static int serverworks_fetch_size(void)
244 */ 242 */
245static void serverworks_tlbflush(struct agp_memory *temp) 243static void serverworks_tlbflush(struct agp_memory *temp)
246{ 244{
245 unsigned long timeout;
246
247 writeb(1, serverworks_private.registers+SVWRKS_POSTFLUSH); 247 writeb(1, serverworks_private.registers+SVWRKS_POSTFLUSH);
248 while (readb(serverworks_private.registers+SVWRKS_POSTFLUSH) == 1) 248 timeout = jiffies + 3*HZ;
249 while (readb(serverworks_private.registers+SVWRKS_POSTFLUSH) == 1) {
249 cpu_relax(); 250 cpu_relax();
251 if (time_after(jiffies, timeout)) {
252 printk(KERN_ERR PFX "TLB post flush took more than 3 seconds\n");
253 break;
254 }
255 }
250 256
251 writel(1, serverworks_private.registers+SVWRKS_DIRFLUSH); 257 writel(1, serverworks_private.registers+SVWRKS_DIRFLUSH);
252 while(readl(serverworks_private.registers+SVWRKS_DIRFLUSH) == 1) 258 timeout = jiffies + 3*HZ;
259 while (readl(serverworks_private.registers+SVWRKS_DIRFLUSH) == 1) {
253 cpu_relax(); 260 cpu_relax();
261 if (time_after(jiffies, timeout)) {
262 printk(KERN_ERR PFX "TLB Dir flush took more than 3 seconds\n");
263 break;
264 }
265 }
254} 266}
255 267
256static int serverworks_configure(void) 268static int serverworks_configure(void)
@@ -533,6 +545,7 @@ static struct pci_device_id agp_serverworks_pci_table[] = {
533MODULE_DEVICE_TABLE(pci, agp_serverworks_pci_table); 545MODULE_DEVICE_TABLE(pci, agp_serverworks_pci_table);
534 546
535static struct pci_driver agp_serverworks_pci_driver = { 547static struct pci_driver agp_serverworks_pci_driver = {
548 .owner = THIS_MODULE,
536 .name = "agpgart-serverworks", 549 .name = "agpgart-serverworks",
537 .id_table = agp_serverworks_pci_table, 550 .id_table = agp_serverworks_pci_table,
538 .probe = agp_serverworks_probe, 551 .probe = agp_serverworks_probe,
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index c8255312b8c1..183c50acab27 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -658,6 +658,7 @@ static struct pci_device_id agp_uninorth_pci_table[] = {
658MODULE_DEVICE_TABLE(pci, agp_uninorth_pci_table); 658MODULE_DEVICE_TABLE(pci, agp_uninorth_pci_table);
659 659
660static struct pci_driver agp_uninorth_pci_driver = { 660static struct pci_driver agp_uninorth_pci_driver = {
661 .owner = THIS_MODULE,
661 .name = "agpgart-uninorth", 662 .name = "agpgart-uninorth",
662 .id_table = agp_uninorth_pci_table, 663 .id_table = agp_uninorth_pci_table,
663 .probe = agp_uninorth_probe, 664 .probe = agp_uninorth_probe,
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index c847df575cf5..5d9a13700074 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -518,6 +518,7 @@ MODULE_DEVICE_TABLE(pci, agp_via_pci_table);
518 518
519 519
520static struct pci_driver agp_via_pci_driver = { 520static struct pci_driver agp_via_pci_driver = {
521 .owner = THIS_MODULE,
521 .name = "agpgart-via", 522 .name = "agpgart-via",
522 .id_table = agp_via_pci_table, 523 .id_table = agp_via_pci_table,
523 .probe = agp_via_probe, 524 .probe = agp_via_probe,
diff --git a/drivers/char/consolemap.c b/drivers/char/consolemap.c
index 406dea914635..c85a4fa60da7 100644
--- a/drivers/char/consolemap.c
+++ b/drivers/char/consolemap.c
@@ -345,17 +345,15 @@ static void con_release_unimap(struct uni_pagedir *p)
345 for (i = 0; i < 32; i++) { 345 for (i = 0; i < 32; i++) {
346 if ((p1 = p->uni_pgdir[i]) != NULL) { 346 if ((p1 = p->uni_pgdir[i]) != NULL) {
347 for (j = 0; j < 32; j++) 347 for (j = 0; j < 32; j++)
348 if (p1[j]) 348 kfree(p1[j]);
349 kfree(p1[j]);
350 kfree(p1); 349 kfree(p1);
351 } 350 }
352 p->uni_pgdir[i] = NULL; 351 p->uni_pgdir[i] = NULL;
353 } 352 }
354 for (i = 0; i < 4; i++) 353 for (i = 0; i < 4; i++) {
355 if (p->inverse_translations[i]) { 354 kfree(p->inverse_translations[i]);
356 kfree(p->inverse_translations[i]); 355 p->inverse_translations[i] = NULL;
357 p->inverse_translations[i] = NULL; 356 }
358 }
359} 357}
360 358
361void con_free_unimap(struct vc_data *vc) 359void con_free_unimap(struct vc_data *vc)
diff --git a/drivers/char/drm/ffb_context.c b/drivers/char/drm/ffb_context.c
index 8a6cc2751bc9..1383727b443a 100644
--- a/drivers/char/drm/ffb_context.c
+++ b/drivers/char/drm/ffb_context.c
@@ -526,10 +526,8 @@ int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
526 if (idx < 0 || idx >= FFB_MAX_CTXS) 526 if (idx < 0 || idx >= FFB_MAX_CTXS)
527 return -EINVAL; 527 return -EINVAL;
528 528
529 if (fpriv->hw_state[idx] != NULL) { 529 kfree(fpriv->hw_state[idx]);
530 kfree(fpriv->hw_state[idx]); 530 fpriv->hw_state[idx] = NULL;
531 fpriv->hw_state[idx] = NULL;
532 }
533 return 0; 531 return 0;
534} 532}
535 533
diff --git a/drivers/char/drm/ffb_drv.c b/drivers/char/drm/ffb_drv.c
index 5c121d6df9f2..c13f9abb41e9 100644
--- a/drivers/char/drm/ffb_drv.c
+++ b/drivers/char/drm/ffb_drv.c
@@ -245,14 +245,12 @@ static void ffb_driver_release(drm_device_t * dev, struct file *filp)
245 245
246static void ffb_driver_pretakedown(drm_device_t * dev) 246static void ffb_driver_pretakedown(drm_device_t * dev)
247{ 247{
248 if (dev->dev_private) 248 kfree(dev->dev_private);
249 kfree(dev->dev_private);
250} 249}
251 250
252static int ffb_driver_postcleanup(drm_device_t * dev) 251static int ffb_driver_postcleanup(drm_device_t * dev)
253{ 252{
254 if (ffb_position != NULL) 253 kfree(ffb_position);
255 kfree(ffb_position);
256 return 0; 254 return 0;
257} 255}
258 256
diff --git a/drivers/char/ip2/i2ellis.c b/drivers/char/ip2/i2ellis.c
index f834d05ccc97..dd761a1e4f08 100644
--- a/drivers/char/ip2/i2ellis.c
+++ b/drivers/char/ip2/i2ellis.c
@@ -106,9 +106,7 @@ iiEllisInit(void)
106static void 106static void
107iiEllisCleanup(void) 107iiEllisCleanup(void)
108{ 108{
109 if ( pDelayTimer != NULL ) { 109 kfree(pDelayTimer);
110 kfree ( pDelayTimer );
111 }
112} 110}
113 111
114//****************************************************************************** 112//******************************************************************************
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
index 33862670e285..58dcdee1cd71 100644
--- a/drivers/char/ipmi/ipmi_bt_sm.c
+++ b/drivers/char/ipmi/ipmi_bt_sm.c
@@ -28,6 +28,8 @@
28 28
29#include <linux/kernel.h> /* For printk. */ 29#include <linux/kernel.h> /* For printk. */
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/module.h>
32#include <linux/moduleparam.h>
31#include <linux/ipmi_msgdefs.h> /* for completion codes */ 33#include <linux/ipmi_msgdefs.h> /* for completion codes */
32#include "ipmi_si_sm.h" 34#include "ipmi_si_sm.h"
33 35
@@ -36,6 +38,8 @@ static int bt_debug = 0x00; /* Production value 0, see following flags */
36#define BT_DEBUG_ENABLE 1 38#define BT_DEBUG_ENABLE 1
37#define BT_DEBUG_MSG 2 39#define BT_DEBUG_MSG 2
38#define BT_DEBUG_STATES 4 40#define BT_DEBUG_STATES 4
41module_param(bt_debug, int, 0644);
42MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
39 43
40/* Typical "Get BT Capabilities" values are 2-3 retries, 5-10 seconds, 44/* Typical "Get BT Capabilities" values are 2-3 retries, 5-10 seconds,
41 and 64 byte buffers. However, one HP implementation wants 255 bytes of 45 and 64 byte buffers. However, one HP implementation wants 255 bytes of
@@ -43,7 +47,7 @@ static int bt_debug = 0x00; /* Production value 0, see following flags */
43 Since the Open IPMI architecture is single-message oriented at this 47 Since the Open IPMI architecture is single-message oriented at this
44 stage, the queue depth of BT is of no concern. */ 48 stage, the queue depth of BT is of no concern. */
45 49
46#define BT_NORMAL_TIMEOUT 2000000 /* seconds in microseconds */ 50#define BT_NORMAL_TIMEOUT 5000000 /* seconds in microseconds */
47#define BT_RETRY_LIMIT 2 51#define BT_RETRY_LIMIT 2
48#define BT_RESET_DELAY 6000000 /* 6 seconds after warm reset */ 52#define BT_RESET_DELAY 6000000 /* 6 seconds after warm reset */
49 53
@@ -202,7 +206,7 @@ static int bt_get_result(struct si_sm_data *bt,
202 msg_len = bt->read_count - 2; /* account for length & seq */ 206 msg_len = bt->read_count - 2; /* account for length & seq */
203 /* Always NetFn, Cmd, cCode */ 207 /* Always NetFn, Cmd, cCode */
204 if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) { 208 if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) {
205 printk(KERN_WARNING "BT results: bad msg_len = %d\n", msg_len); 209 printk(KERN_DEBUG "BT results: bad msg_len = %d\n", msg_len);
206 data[0] = bt->write_data[1] | 0x4; /* Kludge a response */ 210 data[0] = bt->write_data[1] | 0x4; /* Kludge a response */
207 data[1] = bt->write_data[3]; 211 data[1] = bt->write_data[3];
208 data[2] = IPMI_ERR_UNSPECIFIED; 212 data[2] = IPMI_ERR_UNSPECIFIED;
@@ -240,7 +244,7 @@ static void reset_flags(struct si_sm_data *bt)
240 BT_CONTROL(BT_B_BUSY); 244 BT_CONTROL(BT_B_BUSY);
241 BT_CONTROL(BT_CLR_WR_PTR); 245 BT_CONTROL(BT_CLR_WR_PTR);
242 BT_CONTROL(BT_SMS_ATN); 246 BT_CONTROL(BT_SMS_ATN);
243#ifdef DEVELOPMENT_ONLY_NOT_FOR_PRODUCTION 247
244 if (BT_STATUS & BT_B2H_ATN) { 248 if (BT_STATUS & BT_B2H_ATN) {
245 int i; 249 int i;
246 BT_CONTROL(BT_H_BUSY); 250 BT_CONTROL(BT_H_BUSY);
@@ -250,7 +254,6 @@ static void reset_flags(struct si_sm_data *bt)
250 BMC2HOST; 254 BMC2HOST;
251 BT_CONTROL(BT_H_BUSY); 255 BT_CONTROL(BT_H_BUSY);
252 } 256 }
253#endif
254} 257}
255 258
256static inline void write_all_bytes(struct si_sm_data *bt) 259static inline void write_all_bytes(struct si_sm_data *bt)
@@ -295,7 +298,7 @@ static inline int read_all_bytes(struct si_sm_data *bt)
295 printk ("\n"); 298 printk ("\n");
296 } 299 }
297 if (bt->seq != bt->write_data[2]) /* idiot check */ 300 if (bt->seq != bt->write_data[2]) /* idiot check */
298 printk(KERN_WARNING "BT: internal error: sequence mismatch\n"); 301 printk(KERN_DEBUG "BT: internal error: sequence mismatch\n");
299 302
300 /* per the spec, the (NetFn, Seq, Cmd) tuples should match */ 303 /* per the spec, the (NetFn, Seq, Cmd) tuples should match */
301 if ((bt->read_data[3] == bt->write_data[3]) && /* Cmd */ 304 if ((bt->read_data[3] == bt->write_data[3]) && /* Cmd */
@@ -321,18 +324,17 @@ static void error_recovery(struct si_sm_data *bt, char *reason)
321 bt->timeout = BT_NORMAL_TIMEOUT; /* various places want to retry */ 324 bt->timeout = BT_NORMAL_TIMEOUT; /* various places want to retry */
322 325
323 status = BT_STATUS; 326 status = BT_STATUS;
324 printk(KERN_WARNING "BT: %s in %s %s ", reason, STATE2TXT, 327 printk(KERN_DEBUG "BT: %s in %s %s\n", reason, STATE2TXT,
325 STATUS2TXT(buf)); 328 STATUS2TXT(buf));
326 329
327 (bt->error_retries)++; 330 (bt->error_retries)++;
328 if (bt->error_retries > BT_RETRY_LIMIT) { 331 if (bt->error_retries > BT_RETRY_LIMIT) {
329 printk("retry limit (%d) exceeded\n", BT_RETRY_LIMIT); 332 printk(KERN_DEBUG "retry limit (%d) exceeded\n", BT_RETRY_LIMIT);
330 bt->state = BT_STATE_HOSED; 333 bt->state = BT_STATE_HOSED;
331 if (!bt->nonzero_status) 334 if (!bt->nonzero_status)
332 printk(KERN_ERR "IPMI: BT stuck, try power cycle\n"); 335 printk(KERN_ERR "IPMI: BT stuck, try power cycle\n");
333 else if (bt->seq == FIRST_SEQ + BT_RETRY_LIMIT) { 336 else if (bt->error_retries <= BT_RETRY_LIMIT + 1) {
334 /* most likely during insmod */ 337 printk(KERN_DEBUG "IPMI: BT reset (takes 5 secs)\n");
335 printk(KERN_WARNING "IPMI: BT reset (takes 5 secs)\n");
336 bt->state = BT_STATE_RESET1; 338 bt->state = BT_STATE_RESET1;
337 } 339 }
338 return; 340 return;
@@ -340,11 +342,11 @@ static void error_recovery(struct si_sm_data *bt, char *reason)
340 342
341 /* Sometimes the BMC queues get in an "off-by-one" state...*/ 343 /* Sometimes the BMC queues get in an "off-by-one" state...*/
342 if ((bt->state == BT_STATE_B2H_WAIT) && (status & BT_B2H_ATN)) { 344 if ((bt->state == BT_STATE_B2H_WAIT) && (status & BT_B2H_ATN)) {
343 printk("retry B2H_WAIT\n"); 345 printk(KERN_DEBUG "retry B2H_WAIT\n");
344 return; 346 return;
345 } 347 }
346 348
347 printk("restart command\n"); 349 printk(KERN_DEBUG "restart command\n");
348 bt->state = BT_STATE_RESTART; 350 bt->state = BT_STATE_RESTART;
349} 351}
350 352
@@ -372,17 +374,6 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
372 return SI_SM_HOSED; 374 return SI_SM_HOSED;
373 375
374 if (bt->state != BT_STATE_IDLE) { /* do timeout test */ 376 if (bt->state != BT_STATE_IDLE) { /* do timeout test */
375
376 /* Certain states, on error conditions, can lock up a CPU
377 because they are effectively in an infinite loop with
378 CALL_WITHOUT_DELAY (right back here with time == 0).
379 Prevent infinite lockup by ALWAYS decrementing timeout. */
380
381 /* FIXME: bt_event is sometimes called with time > BT_NORMAL_TIMEOUT
382 (noticed in ipmi_smic_sm.c January 2004) */
383
384 if ((time <= 0) || (time >= BT_NORMAL_TIMEOUT))
385 time = 100;
386 bt->timeout -= time; 377 bt->timeout -= time;
387 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) { 378 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) {
388 error_recovery(bt, "timed out"); 379 error_recovery(bt, "timed out");
@@ -483,6 +474,7 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
483 break; 474 break;
484 475
485 case BT_STATE_RESTART: /* don't reset retries! */ 476 case BT_STATE_RESTART: /* don't reset retries! */
477 reset_flags(bt);
486 bt->write_data[2] = ++bt->seq; 478 bt->write_data[2] = ++bt->seq;
487 bt->read_count = 0; 479 bt->read_count = 0;
488 bt->nonzero_status = 0; 480 bt->nonzero_status = 0;
diff --git a/drivers/char/ipmi/ipmi_kcs_sm.c b/drivers/char/ipmi/ipmi_kcs_sm.c
index d21853a594a3..da1554194d3d 100644
--- a/drivers/char/ipmi/ipmi_kcs_sm.c
+++ b/drivers/char/ipmi/ipmi_kcs_sm.c
@@ -38,16 +38,25 @@
38 */ 38 */
39 39
40#include <linux/kernel.h> /* For printk. */ 40#include <linux/kernel.h> /* For printk. */
41#include <linux/module.h>
42#include <linux/moduleparam.h>
41#include <linux/string.h> 43#include <linux/string.h>
44#include <linux/jiffies.h>
42#include <linux/ipmi_msgdefs.h> /* for completion codes */ 45#include <linux/ipmi_msgdefs.h> /* for completion codes */
43#include "ipmi_si_sm.h" 46#include "ipmi_si_sm.h"
44 47
45/* Set this if you want a printout of why the state machine was hosed 48/* kcs_debug is a bit-field
46 when it gets hosed. */ 49 * KCS_DEBUG_ENABLE - turned on for now
47#define DEBUG_HOSED_REASON 50 * KCS_DEBUG_MSG - commands and their responses
51 * KCS_DEBUG_STATES - state machine
52 */
53#define KCS_DEBUG_STATES 4
54#define KCS_DEBUG_MSG 2
55#define KCS_DEBUG_ENABLE 1
48 56
49/* Print the state machine state on entry every time. */ 57static int kcs_debug;
50#undef DEBUG_STATE 58module_param(kcs_debug, int, 0644);
59MODULE_PARM_DESC(kcs_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
51 60
52/* The states the KCS driver may be in. */ 61/* The states the KCS driver may be in. */
53enum kcs_states { 62enum kcs_states {
@@ -91,6 +100,7 @@ enum kcs_states {
91#define IBF_RETRY_TIMEOUT 1000000 100#define IBF_RETRY_TIMEOUT 1000000
92#define OBF_RETRY_TIMEOUT 1000000 101#define OBF_RETRY_TIMEOUT 1000000
93#define MAX_ERROR_RETRIES 10 102#define MAX_ERROR_RETRIES 10
103#define ERROR0_OBF_WAIT_JIFFIES (2*HZ)
94 104
95struct si_sm_data 105struct si_sm_data
96{ 106{
@@ -107,6 +117,7 @@ struct si_sm_data
107 unsigned int error_retries; 117 unsigned int error_retries;
108 long ibf_timeout; 118 long ibf_timeout;
109 long obf_timeout; 119 long obf_timeout;
120 unsigned long error0_timeout;
110}; 121};
111 122
112static unsigned int init_kcs_data(struct si_sm_data *kcs, 123static unsigned int init_kcs_data(struct si_sm_data *kcs,
@@ -175,11 +186,11 @@ static inline void start_error_recovery(struct si_sm_data *kcs, char *reason)
175{ 186{
176 (kcs->error_retries)++; 187 (kcs->error_retries)++;
177 if (kcs->error_retries > MAX_ERROR_RETRIES) { 188 if (kcs->error_retries > MAX_ERROR_RETRIES) {
178#ifdef DEBUG_HOSED_REASON 189 if (kcs_debug & KCS_DEBUG_ENABLE)
179 printk("ipmi_kcs_sm: kcs hosed: %s\n", reason); 190 printk(KERN_DEBUG "ipmi_kcs_sm: kcs hosed: %s\n", reason);
180#endif
181 kcs->state = KCS_HOSED; 191 kcs->state = KCS_HOSED;
182 } else { 192 } else {
193 kcs->error0_timeout = jiffies + ERROR0_OBF_WAIT_JIFFIES;
183 kcs->state = KCS_ERROR0; 194 kcs->state = KCS_ERROR0;
184 } 195 }
185} 196}
@@ -248,14 +259,21 @@ static void restart_kcs_transaction(struct si_sm_data *kcs)
248static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data, 259static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data,
249 unsigned int size) 260 unsigned int size)
250{ 261{
262 unsigned int i;
263
251 if ((size < 2) || (size > MAX_KCS_WRITE_SIZE)) { 264 if ((size < 2) || (size > MAX_KCS_WRITE_SIZE)) {
252 return -1; 265 return -1;
253 } 266 }
254
255 if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED)) { 267 if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED)) {
256 return -2; 268 return -2;
257 } 269 }
258 270 if (kcs_debug & KCS_DEBUG_MSG) {
271 printk(KERN_DEBUG "start_kcs_transaction -");
272 for (i = 0; i < size; i ++) {
273 printk(" %02x", (unsigned char) (data [i]));
274 }
275 printk ("\n");
276 }
259 kcs->error_retries = 0; 277 kcs->error_retries = 0;
260 memcpy(kcs->write_data, data, size); 278 memcpy(kcs->write_data, data, size);
261 kcs->write_count = size; 279 kcs->write_count = size;
@@ -305,9 +323,9 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time)
305 323
306 status = read_status(kcs); 324 status = read_status(kcs);
307 325
308#ifdef DEBUG_STATE 326 if (kcs_debug & KCS_DEBUG_STATES)
309 printk(" State = %d, %x\n", kcs->state, status); 327 printk(KERN_DEBUG "KCS: State = %d, %x\n", kcs->state, status);
310#endif 328
311 /* All states wait for ibf, so just do it here. */ 329 /* All states wait for ibf, so just do it here. */
312 if (!check_ibf(kcs, status, time)) 330 if (!check_ibf(kcs, status, time))
313 return SI_SM_CALL_WITH_DELAY; 331 return SI_SM_CALL_WITH_DELAY;
@@ -409,6 +427,10 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time)
409 427
410 case KCS_ERROR0: 428 case KCS_ERROR0:
411 clear_obf(kcs, status); 429 clear_obf(kcs, status);
430 status = read_status(kcs);
431 if (GET_STATUS_OBF(status)) /* controller isn't responding */
432 if (time_before(jiffies, kcs->error0_timeout))
433 return SI_SM_CALL_WITH_TICK_DELAY;
412 write_cmd(kcs, KCS_GET_STATUS_ABORT); 434 write_cmd(kcs, KCS_GET_STATUS_ABORT);
413 kcs->state = KCS_ERROR1; 435 kcs->state = KCS_ERROR1;
414 break; 436 break;
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 32fa82c78c73..c1d06ba449b6 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -38,13 +38,13 @@
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/poll.h> 39#include <linux/poll.h>
40#include <linux/spinlock.h> 40#include <linux/spinlock.h>
41#include <linux/rwsem.h>
42#include <linux/slab.h> 41#include <linux/slab.h>
43#include <linux/ipmi.h> 42#include <linux/ipmi.h>
44#include <linux/ipmi_smi.h> 43#include <linux/ipmi_smi.h>
45#include <linux/notifier.h> 44#include <linux/notifier.h>
46#include <linux/init.h> 45#include <linux/init.h>
47#include <linux/proc_fs.h> 46#include <linux/proc_fs.h>
47#include <linux/rcupdate.h>
48 48
49#define PFX "IPMI message handler: " 49#define PFX "IPMI message handler: "
50 50
@@ -65,10 +65,19 @@ struct proc_dir_entry *proc_ipmi_root = NULL;
65 the max message timer. This is in milliseconds. */ 65 the max message timer. This is in milliseconds. */
66#define MAX_MSG_TIMEOUT 60000 66#define MAX_MSG_TIMEOUT 60000
67 67
68
69/*
70 * The main "user" data structure.
71 */
68struct ipmi_user 72struct ipmi_user
69{ 73{
70 struct list_head link; 74 struct list_head link;
71 75
76 /* Set to "0" when the user is destroyed. */
77 int valid;
78
79 struct kref refcount;
80
72 /* The upper layer that handles receive messages. */ 81 /* The upper layer that handles receive messages. */
73 struct ipmi_user_hndl *handler; 82 struct ipmi_user_hndl *handler;
74 void *handler_data; 83 void *handler_data;
@@ -87,6 +96,15 @@ struct cmd_rcvr
87 ipmi_user_t user; 96 ipmi_user_t user;
88 unsigned char netfn; 97 unsigned char netfn;
89 unsigned char cmd; 98 unsigned char cmd;
99
100 /*
101 * This is used to form a linked lised during mass deletion.
102 * Since this is in an RCU list, we cannot use the link above
103 * or change any data until the RCU period completes. So we
104 * use this next variable during mass deletion so we can have
105 * a list and don't have to wait and restart the search on
106 * every individual deletion of a command. */
107 struct cmd_rcvr *next;
90}; 108};
91 109
92struct seq_table 110struct seq_table
@@ -150,13 +168,11 @@ struct ipmi_smi
150 /* What interface number are we? */ 168 /* What interface number are we? */
151 int intf_num; 169 int intf_num;
152 170
153 /* The list of upper layers that are using me. We read-lock 171 struct kref refcount;
154 this when delivering messages to the upper layer to keep 172
155 the user from going away while we are processing the 173 /* The list of upper layers that are using me. seq_lock
156 message. This means that you cannot add or delete a user 174 * protects this. */
157 from the receive callback. */ 175 struct list_head users;
158 rwlock_t users_lock;
159 struct list_head users;
160 176
161 /* Used for wake ups at startup. */ 177 /* Used for wake ups at startup. */
162 wait_queue_head_t waitq; 178 wait_queue_head_t waitq;
@@ -193,7 +209,7 @@ struct ipmi_smi
193 209
194 /* The list of command receivers that are registered for commands 210 /* The list of command receivers that are registered for commands
195 on this interface. */ 211 on this interface. */
196 rwlock_t cmd_rcvr_lock; 212 struct semaphore cmd_rcvrs_lock;
197 struct list_head cmd_rcvrs; 213 struct list_head cmd_rcvrs;
198 214
199 /* Events that were queues because no one was there to receive 215 /* Events that were queues because no one was there to receive
@@ -296,16 +312,17 @@ struct ipmi_smi
296 unsigned int events; 312 unsigned int events;
297}; 313};
298 314
315/* Used to mark an interface entry that cannot be used but is not a
316 * free entry, either, primarily used at creation and deletion time so
317 * a slot doesn't get reused too quickly. */
318#define IPMI_INVALID_INTERFACE_ENTRY ((ipmi_smi_t) ((long) 1))
319#define IPMI_INVALID_INTERFACE(i) (((i) == NULL) \
320 || (i == IPMI_INVALID_INTERFACE_ENTRY))
321
299#define MAX_IPMI_INTERFACES 4 322#define MAX_IPMI_INTERFACES 4
300static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES]; 323static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES];
301 324
302/* Used to keep interfaces from going away while operations are 325/* Directly protects the ipmi_interfaces data structure. */
303 operating on interfaces. Grab read if you are not modifying the
304 interfaces, write if you are. */
305static DECLARE_RWSEM(interfaces_sem);
306
307/* Directly protects the ipmi_interfaces data structure. This is
308 claimed in the timer interrupt. */
309static DEFINE_SPINLOCK(interfaces_lock); 326static DEFINE_SPINLOCK(interfaces_lock);
310 327
311/* List of watchers that want to know when smi's are added and 328/* List of watchers that want to know when smi's are added and
@@ -313,20 +330,72 @@ static DEFINE_SPINLOCK(interfaces_lock);
313static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers); 330static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers);
314static DECLARE_RWSEM(smi_watchers_sem); 331static DECLARE_RWSEM(smi_watchers_sem);
315 332
333
334static void free_recv_msg_list(struct list_head *q)
335{
336 struct ipmi_recv_msg *msg, *msg2;
337
338 list_for_each_entry_safe(msg, msg2, q, link) {
339 list_del(&msg->link);
340 ipmi_free_recv_msg(msg);
341 }
342}
343
344static void clean_up_interface_data(ipmi_smi_t intf)
345{
346 int i;
347 struct cmd_rcvr *rcvr, *rcvr2;
348 struct list_head list;
349
350 free_recv_msg_list(&intf->waiting_msgs);
351 free_recv_msg_list(&intf->waiting_events);
352
353 /* Wholesale remove all the entries from the list in the
354 * interface and wait for RCU to know that none are in use. */
355 down(&intf->cmd_rcvrs_lock);
356 list_add_rcu(&list, &intf->cmd_rcvrs);
357 list_del_rcu(&intf->cmd_rcvrs);
358 up(&intf->cmd_rcvrs_lock);
359 synchronize_rcu();
360
361 list_for_each_entry_safe(rcvr, rcvr2, &list, link)
362 kfree(rcvr);
363
364 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
365 if ((intf->seq_table[i].inuse)
366 && (intf->seq_table[i].recv_msg))
367 {
368 ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
369 }
370 }
371}
372
373static void intf_free(struct kref *ref)
374{
375 ipmi_smi_t intf = container_of(ref, struct ipmi_smi, refcount);
376
377 clean_up_interface_data(intf);
378 kfree(intf);
379}
380
316int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) 381int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
317{ 382{
318 int i; 383 int i;
384 unsigned long flags;
319 385
320 down_read(&interfaces_sem);
321 down_write(&smi_watchers_sem); 386 down_write(&smi_watchers_sem);
322 list_add(&(watcher->link), &smi_watchers); 387 list_add(&(watcher->link), &smi_watchers);
388 up_write(&smi_watchers_sem);
389 spin_lock_irqsave(&interfaces_lock, flags);
323 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 390 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
324 if (ipmi_interfaces[i] != NULL) { 391 ipmi_smi_t intf = ipmi_interfaces[i];
325 watcher->new_smi(i); 392 if (IPMI_INVALID_INTERFACE(intf))
326 } 393 continue;
394 spin_unlock_irqrestore(&interfaces_lock, flags);
395 watcher->new_smi(i);
396 spin_lock_irqsave(&interfaces_lock, flags);
327 } 397 }
328 up_write(&smi_watchers_sem); 398 spin_unlock_irqrestore(&interfaces_lock, flags);
329 up_read(&interfaces_sem);
330 return 0; 399 return 0;
331} 400}
332 401
@@ -471,8 +540,8 @@ static void deliver_response(struct ipmi_recv_msg *msg)
471 } 540 }
472 ipmi_free_recv_msg(msg); 541 ipmi_free_recv_msg(msg);
473 } else { 542 } else {
474 msg->user->handler->ipmi_recv_hndl(msg, 543 ipmi_user_t user = msg->user;
475 msg->user->handler_data); 544 user->handler->ipmi_recv_hndl(msg, user->handler_data);
476 } 545 }
477} 546}
478 547
@@ -662,15 +731,18 @@ int ipmi_create_user(unsigned int if_num,
662 if (! new_user) 731 if (! new_user)
663 return -ENOMEM; 732 return -ENOMEM;
664 733
665 down_read(&interfaces_sem); 734 spin_lock_irqsave(&interfaces_lock, flags);
666 if ((if_num >= MAX_IPMI_INTERFACES) || ipmi_interfaces[if_num] == NULL) 735 intf = ipmi_interfaces[if_num];
667 { 736 if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) {
668 rv = -EINVAL; 737 spin_unlock_irqrestore(&interfaces_lock, flags);
669 goto out_unlock; 738 return -EINVAL;
670 } 739 }
671 740
672 intf = ipmi_interfaces[if_num]; 741 /* Note that each existing user holds a refcount to the interface. */
742 kref_get(&intf->refcount);
743 spin_unlock_irqrestore(&interfaces_lock, flags);
673 744
745 kref_init(&new_user->refcount);
674 new_user->handler = handler; 746 new_user->handler = handler;
675 new_user->handler_data = handler_data; 747 new_user->handler_data = handler_data;
676 new_user->intf = intf; 748 new_user->intf = intf;
@@ -678,98 +750,92 @@ int ipmi_create_user(unsigned int if_num,
678 750
679 if (!try_module_get(intf->handlers->owner)) { 751 if (!try_module_get(intf->handlers->owner)) {
680 rv = -ENODEV; 752 rv = -ENODEV;
681 goto out_unlock; 753 goto out_err;
682 } 754 }
683 755
684 if (intf->handlers->inc_usecount) { 756 if (intf->handlers->inc_usecount) {
685 rv = intf->handlers->inc_usecount(intf->send_info); 757 rv = intf->handlers->inc_usecount(intf->send_info);
686 if (rv) { 758 if (rv) {
687 module_put(intf->handlers->owner); 759 module_put(intf->handlers->owner);
688 goto out_unlock; 760 goto out_err;
689 } 761 }
690 } 762 }
691 763
692 write_lock_irqsave(&intf->users_lock, flags); 764 new_user->valid = 1;
693 list_add_tail(&new_user->link, &intf->users); 765 spin_lock_irqsave(&intf->seq_lock, flags);
694 write_unlock_irqrestore(&intf->users_lock, flags); 766 list_add_rcu(&new_user->link, &intf->users);
695 767 spin_unlock_irqrestore(&intf->seq_lock, flags);
696 out_unlock: 768 *user = new_user;
697 if (rv) { 769 return 0;
698 kfree(new_user);
699 } else {
700 *user = new_user;
701 }
702 770
703 up_read(&interfaces_sem); 771 out_err:
772 kfree(new_user);
773 kref_put(&intf->refcount, intf_free);
704 return rv; 774 return rv;
705} 775}
706 776
707static int ipmi_destroy_user_nolock(ipmi_user_t user) 777static void free_user(struct kref *ref)
778{
779 ipmi_user_t user = container_of(ref, struct ipmi_user, refcount);
780 kfree(user);
781}
782
783int ipmi_destroy_user(ipmi_user_t user)
708{ 784{
709 int rv = -ENODEV; 785 int rv = -ENODEV;
710 ipmi_user_t t_user; 786 ipmi_smi_t intf = user->intf;
711 struct cmd_rcvr *rcvr, *rcvr2;
712 int i; 787 int i;
713 unsigned long flags; 788 unsigned long flags;
789 struct cmd_rcvr *rcvr;
790 struct list_head *entry1, *entry2;
791 struct cmd_rcvr *rcvrs = NULL;
714 792
715 /* Find the user and delete them from the list. */ 793 user->valid = 1;
716 list_for_each_entry(t_user, &(user->intf->users), link) {
717 if (t_user == user) {
718 list_del(&t_user->link);
719 rv = 0;
720 break;
721 }
722 }
723 794
724 if (rv) { 795 /* Remove the user from the interface's sequence table. */
725 goto out_unlock; 796 spin_lock_irqsave(&intf->seq_lock, flags);
726 } 797 list_del_rcu(&user->link);
727 798
728 /* Remove the user from the interfaces sequence table. */
729 spin_lock_irqsave(&(user->intf->seq_lock), flags);
730 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { 799 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
731 if (user->intf->seq_table[i].inuse 800 if (intf->seq_table[i].inuse
732 && (user->intf->seq_table[i].recv_msg->user == user)) 801 && (intf->seq_table[i].recv_msg->user == user))
733 { 802 {
734 user->intf->seq_table[i].inuse = 0; 803 intf->seq_table[i].inuse = 0;
735 } 804 }
736 } 805 }
737 spin_unlock_irqrestore(&(user->intf->seq_lock), flags); 806 spin_unlock_irqrestore(&intf->seq_lock, flags);
738 807
739 /* Remove the user from the command receiver's table. */ 808 /*
740 write_lock_irqsave(&(user->intf->cmd_rcvr_lock), flags); 809 * Remove the user from the command receiver's table. First
741 list_for_each_entry_safe(rcvr, rcvr2, &(user->intf->cmd_rcvrs), link) { 810 * we build a list of everything (not using the standard link,
811 * since other things may be using it till we do
812 * synchronize_rcu()) then free everything in that list.
813 */
814 down(&intf->cmd_rcvrs_lock);
815 list_for_each_safe_rcu(entry1, entry2, &intf->cmd_rcvrs) {
816 rcvr = list_entry(entry1, struct cmd_rcvr, link);
742 if (rcvr->user == user) { 817 if (rcvr->user == user) {
743 list_del(&rcvr->link); 818 list_del_rcu(&rcvr->link);
744 kfree(rcvr); 819 rcvr->next = rcvrs;
820 rcvrs = rcvr;
745 } 821 }
746 } 822 }
747 write_unlock_irqrestore(&(user->intf->cmd_rcvr_lock), flags); 823 up(&intf->cmd_rcvrs_lock);
824 synchronize_rcu();
825 while (rcvrs) {
826 rcvr = rcvrs;
827 rcvrs = rcvr->next;
828 kfree(rcvr);
829 }
748 830
749 kfree(user); 831 module_put(intf->handlers->owner);
832 if (intf->handlers->dec_usecount)
833 intf->handlers->dec_usecount(intf->send_info);
750 834
751 out_unlock: 835 kref_put(&intf->refcount, intf_free);
752 836
753 return rv; 837 kref_put(&user->refcount, free_user);
754}
755
756int ipmi_destroy_user(ipmi_user_t user)
757{
758 int rv;
759 ipmi_smi_t intf = user->intf;
760 unsigned long flags;
761 838
762 down_read(&interfaces_sem);
763 write_lock_irqsave(&intf->users_lock, flags);
764 rv = ipmi_destroy_user_nolock(user);
765 if (!rv) {
766 module_put(intf->handlers->owner);
767 if (intf->handlers->dec_usecount)
768 intf->handlers->dec_usecount(intf->send_info);
769 }
770
771 write_unlock_irqrestore(&intf->users_lock, flags);
772 up_read(&interfaces_sem);
773 return rv; 839 return rv;
774} 840}
775 841
@@ -823,62 +889,78 @@ int ipmi_get_my_LUN(ipmi_user_t user,
823 889
824int ipmi_set_gets_events(ipmi_user_t user, int val) 890int ipmi_set_gets_events(ipmi_user_t user, int val)
825{ 891{
826 unsigned long flags; 892 unsigned long flags;
827 struct ipmi_recv_msg *msg, *msg2; 893 ipmi_smi_t intf = user->intf;
894 struct ipmi_recv_msg *msg, *msg2;
895 struct list_head msgs;
828 896
829 read_lock(&(user->intf->users_lock)); 897 INIT_LIST_HEAD(&msgs);
830 spin_lock_irqsave(&(user->intf->events_lock), flags); 898
899 spin_lock_irqsave(&intf->events_lock, flags);
831 user->gets_events = val; 900 user->gets_events = val;
832 901
833 if (val) { 902 if (val) {
834 /* Deliver any queued events. */ 903 /* Deliver any queued events. */
835 list_for_each_entry_safe(msg, msg2, &(user->intf->waiting_events), link) { 904 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link) {
836 list_del(&msg->link); 905 list_del(&msg->link);
837 msg->user = user; 906 list_add_tail(&msg->link, &msgs);
838 deliver_response(msg);
839 } 907 }
840 } 908 }
841 909
842 spin_unlock_irqrestore(&(user->intf->events_lock), flags); 910 /* Hold the events lock while doing this to preserve order. */
843 read_unlock(&(user->intf->users_lock)); 911 list_for_each_entry_safe(msg, msg2, &msgs, link) {
912 msg->user = user;
913 kref_get(&user->refcount);
914 deliver_response(msg);
915 }
916
917 spin_unlock_irqrestore(&intf->events_lock, flags);
844 918
845 return 0; 919 return 0;
846} 920}
847 921
922static struct cmd_rcvr *find_cmd_rcvr(ipmi_smi_t intf,
923 unsigned char netfn,
924 unsigned char cmd)
925{
926 struct cmd_rcvr *rcvr;
927
928 list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link) {
929 if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd))
930 return rcvr;
931 }
932 return NULL;
933}
934
848int ipmi_register_for_cmd(ipmi_user_t user, 935int ipmi_register_for_cmd(ipmi_user_t user,
849 unsigned char netfn, 936 unsigned char netfn,
850 unsigned char cmd) 937 unsigned char cmd)
851{ 938{
852 struct cmd_rcvr *cmp; 939 ipmi_smi_t intf = user->intf;
853 unsigned long flags; 940 struct cmd_rcvr *rcvr;
854 struct cmd_rcvr *rcvr; 941 struct cmd_rcvr *entry;
855 int rv = 0; 942 int rv = 0;
856 943
857 944
858 rcvr = kmalloc(sizeof(*rcvr), GFP_KERNEL); 945 rcvr = kmalloc(sizeof(*rcvr), GFP_KERNEL);
859 if (! rcvr) 946 if (! rcvr)
860 return -ENOMEM; 947 return -ENOMEM;
948 rcvr->cmd = cmd;
949 rcvr->netfn = netfn;
950 rcvr->user = user;
861 951
862 read_lock(&(user->intf->users_lock)); 952 down(&intf->cmd_rcvrs_lock);
863 write_lock_irqsave(&(user->intf->cmd_rcvr_lock), flags);
864 /* Make sure the command/netfn is not already registered. */ 953 /* Make sure the command/netfn is not already registered. */
865 list_for_each_entry(cmp, &(user->intf->cmd_rcvrs), link) { 954 entry = find_cmd_rcvr(intf, netfn, cmd);
866 if ((cmp->netfn == netfn) && (cmp->cmd == cmd)) { 955 if (entry) {
867 rv = -EBUSY; 956 rv = -EBUSY;
868 break; 957 goto out_unlock;
869 }
870 }
871
872 if (! rv) {
873 rcvr->cmd = cmd;
874 rcvr->netfn = netfn;
875 rcvr->user = user;
876 list_add_tail(&(rcvr->link), &(user->intf->cmd_rcvrs));
877 } 958 }
878 959
879 write_unlock_irqrestore(&(user->intf->cmd_rcvr_lock), flags); 960 list_add_rcu(&rcvr->link, &intf->cmd_rcvrs);
880 read_unlock(&(user->intf->users_lock));
881 961
962 out_unlock:
963 up(&intf->cmd_rcvrs_lock);
882 if (rv) 964 if (rv)
883 kfree(rcvr); 965 kfree(rcvr);
884 966
@@ -889,31 +971,28 @@ int ipmi_unregister_for_cmd(ipmi_user_t user,
889 unsigned char netfn, 971 unsigned char netfn,
890 unsigned char cmd) 972 unsigned char cmd)
891{ 973{
892 unsigned long flags; 974 ipmi_smi_t intf = user->intf;
893 struct cmd_rcvr *rcvr; 975 struct cmd_rcvr *rcvr;
894 int rv = -ENOENT;
895 976
896 read_lock(&(user->intf->users_lock)); 977 down(&intf->cmd_rcvrs_lock);
897 write_lock_irqsave(&(user->intf->cmd_rcvr_lock), flags);
898 /* Make sure the command/netfn is not already registered. */ 978 /* Make sure the command/netfn is not already registered. */
899 list_for_each_entry(rcvr, &(user->intf->cmd_rcvrs), link) { 979 rcvr = find_cmd_rcvr(intf, netfn, cmd);
900 if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) { 980 if ((rcvr) && (rcvr->user == user)) {
901 rv = 0; 981 list_del_rcu(&rcvr->link);
902 list_del(&rcvr->link); 982 up(&intf->cmd_rcvrs_lock);
903 kfree(rcvr); 983 synchronize_rcu();
904 break; 984 kfree(rcvr);
905 } 985 return 0;
986 } else {
987 up(&intf->cmd_rcvrs_lock);
988 return -ENOENT;
906 } 989 }
907 write_unlock_irqrestore(&(user->intf->cmd_rcvr_lock), flags);
908 read_unlock(&(user->intf->users_lock));
909
910 return rv;
911} 990}
912 991
913void ipmi_user_set_run_to_completion(ipmi_user_t user, int val) 992void ipmi_user_set_run_to_completion(ipmi_user_t user, int val)
914{ 993{
915 user->intf->handlers->set_run_to_completion(user->intf->send_info, 994 ipmi_smi_t intf = user->intf;
916 val); 995 intf->handlers->set_run_to_completion(intf->send_info, val);
917} 996}
918 997
919static unsigned char 998static unsigned char
@@ -1010,19 +1089,19 @@ static inline void format_lan_msg(struct ipmi_smi_msg *smi_msg,
1010 supplied in certain circumstances (mainly at panic time). If 1089 supplied in certain circumstances (mainly at panic time). If
1011 messages are supplied, they will be freed, even if an error 1090 messages are supplied, they will be freed, even if an error
1012 occurs. */ 1091 occurs. */
1013static inline int i_ipmi_request(ipmi_user_t user, 1092static int i_ipmi_request(ipmi_user_t user,
1014 ipmi_smi_t intf, 1093 ipmi_smi_t intf,
1015 struct ipmi_addr *addr, 1094 struct ipmi_addr *addr,
1016 long msgid, 1095 long msgid,
1017 struct kernel_ipmi_msg *msg, 1096 struct kernel_ipmi_msg *msg,
1018 void *user_msg_data, 1097 void *user_msg_data,
1019 void *supplied_smi, 1098 void *supplied_smi,
1020 struct ipmi_recv_msg *supplied_recv, 1099 struct ipmi_recv_msg *supplied_recv,
1021 int priority, 1100 int priority,
1022 unsigned char source_address, 1101 unsigned char source_address,
1023 unsigned char source_lun, 1102 unsigned char source_lun,
1024 int retries, 1103 int retries,
1025 unsigned int retry_time_ms) 1104 unsigned int retry_time_ms)
1026{ 1105{
1027 int rv = 0; 1106 int rv = 0;
1028 struct ipmi_smi_msg *smi_msg; 1107 struct ipmi_smi_msg *smi_msg;
@@ -1051,6 +1130,8 @@ static inline int i_ipmi_request(ipmi_user_t user,
1051 } 1130 }
1052 1131
1053 recv_msg->user = user; 1132 recv_msg->user = user;
1133 if (user)
1134 kref_get(&user->refcount);
1054 recv_msg->msgid = msgid; 1135 recv_msg->msgid = msgid;
1055 /* Store the message to send in the receive message so timeout 1136 /* Store the message to send in the receive message so timeout
1056 responses can get the proper response data. */ 1137 responses can get the proper response data. */
@@ -1725,11 +1806,11 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1725 unsigned char version_major, 1806 unsigned char version_major,
1726 unsigned char version_minor, 1807 unsigned char version_minor,
1727 unsigned char slave_addr, 1808 unsigned char slave_addr,
1728 ipmi_smi_t *intf) 1809 ipmi_smi_t *new_intf)
1729{ 1810{
1730 int i, j; 1811 int i, j;
1731 int rv; 1812 int rv;
1732 ipmi_smi_t new_intf; 1813 ipmi_smi_t intf;
1733 unsigned long flags; 1814 unsigned long flags;
1734 1815
1735 1816
@@ -1745,189 +1826,142 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1745 return -ENODEV; 1826 return -ENODEV;
1746 } 1827 }
1747 1828
1748 new_intf = kmalloc(sizeof(*new_intf), GFP_KERNEL); 1829 intf = kmalloc(sizeof(*intf), GFP_KERNEL);
1749 if (!new_intf) 1830 if (!intf)
1750 return -ENOMEM; 1831 return -ENOMEM;
1751 memset(new_intf, 0, sizeof(*new_intf)); 1832 memset(intf, 0, sizeof(*intf));
1752 1833 intf->intf_num = -1;
1753 new_intf->proc_dir = NULL; 1834 kref_init(&intf->refcount);
1835 intf->version_major = version_major;
1836 intf->version_minor = version_minor;
1837 for (j = 0; j < IPMI_MAX_CHANNELS; j++) {
1838 intf->channels[j].address = IPMI_BMC_SLAVE_ADDR;
1839 intf->channels[j].lun = 2;
1840 }
1841 if (slave_addr != 0)
1842 intf->channels[0].address = slave_addr;
1843 INIT_LIST_HEAD(&intf->users);
1844 intf->handlers = handlers;
1845 intf->send_info = send_info;
1846 spin_lock_init(&intf->seq_lock);
1847 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) {
1848 intf->seq_table[j].inuse = 0;
1849 intf->seq_table[j].seqid = 0;
1850 }
1851 intf->curr_seq = 0;
1852#ifdef CONFIG_PROC_FS
1853 spin_lock_init(&intf->proc_entry_lock);
1854#endif
1855 spin_lock_init(&intf->waiting_msgs_lock);
1856 INIT_LIST_HEAD(&intf->waiting_msgs);
1857 spin_lock_init(&intf->events_lock);
1858 INIT_LIST_HEAD(&intf->waiting_events);
1859 intf->waiting_events_count = 0;
1860 init_MUTEX(&intf->cmd_rcvrs_lock);
1861 INIT_LIST_HEAD(&intf->cmd_rcvrs);
1862 init_waitqueue_head(&intf->waitq);
1863
1864 spin_lock_init(&intf->counter_lock);
1865 intf->proc_dir = NULL;
1754 1866
1755 rv = -ENOMEM; 1867 rv = -ENOMEM;
1756 1868 spin_lock_irqsave(&interfaces_lock, flags);
1757 down_write(&interfaces_sem);
1758 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 1869 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
1759 if (ipmi_interfaces[i] == NULL) { 1870 if (ipmi_interfaces[i] == NULL) {
1760 new_intf->intf_num = i; 1871 intf->intf_num = i;
1761 new_intf->version_major = version_major; 1872 /* Reserve the entry till we are done. */
1762 new_intf->version_minor = version_minor; 1873 ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY;
1763 for (j = 0; j < IPMI_MAX_CHANNELS; j++) {
1764 new_intf->channels[j].address
1765 = IPMI_BMC_SLAVE_ADDR;
1766 new_intf->channels[j].lun = 2;
1767 }
1768 if (slave_addr != 0)
1769 new_intf->channels[0].address = slave_addr;
1770 rwlock_init(&(new_intf->users_lock));
1771 INIT_LIST_HEAD(&(new_intf->users));
1772 new_intf->handlers = handlers;
1773 new_intf->send_info = send_info;
1774 spin_lock_init(&(new_intf->seq_lock));
1775 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) {
1776 new_intf->seq_table[j].inuse = 0;
1777 new_intf->seq_table[j].seqid = 0;
1778 }
1779 new_intf->curr_seq = 0;
1780#ifdef CONFIG_PROC_FS
1781 spin_lock_init(&(new_intf->proc_entry_lock));
1782#endif
1783 spin_lock_init(&(new_intf->waiting_msgs_lock));
1784 INIT_LIST_HEAD(&(new_intf->waiting_msgs));
1785 spin_lock_init(&(new_intf->events_lock));
1786 INIT_LIST_HEAD(&(new_intf->waiting_events));
1787 new_intf->waiting_events_count = 0;
1788 rwlock_init(&(new_intf->cmd_rcvr_lock));
1789 init_waitqueue_head(&new_intf->waitq);
1790 INIT_LIST_HEAD(&(new_intf->cmd_rcvrs));
1791
1792 spin_lock_init(&(new_intf->counter_lock));
1793
1794 spin_lock_irqsave(&interfaces_lock, flags);
1795 ipmi_interfaces[i] = new_intf;
1796 spin_unlock_irqrestore(&interfaces_lock, flags);
1797
1798 rv = 0; 1874 rv = 0;
1799 *intf = new_intf;
1800 break; 1875 break;
1801 } 1876 }
1802 } 1877 }
1878 spin_unlock_irqrestore(&interfaces_lock, flags);
1879 if (rv)
1880 goto out;
1803 1881
1804 downgrade_write(&interfaces_sem); 1882 /* FIXME - this is an ugly kludge, this sets the intf for the
1805 1883 caller before sending any messages with it. */
1806 if (rv == 0) 1884 *new_intf = intf;
1807 rv = add_proc_entries(*intf, i);
1808
1809 if (rv == 0) {
1810 if ((version_major > 1)
1811 || ((version_major == 1) && (version_minor >= 5)))
1812 {
1813 /* Start scanning the channels to see what is
1814 available. */
1815 (*intf)->null_user_handler = channel_handler;
1816 (*intf)->curr_channel = 0;
1817 rv = send_channel_info_cmd(*intf, 0);
1818 if (rv)
1819 goto out;
1820 1885
1821 /* Wait for the channel info to be read. */ 1886 if ((version_major > 1)
1822 up_read(&interfaces_sem); 1887 || ((version_major == 1) && (version_minor >= 5)))
1823 wait_event((*intf)->waitq, 1888 {
1824 ((*intf)->curr_channel>=IPMI_MAX_CHANNELS)); 1889 /* Start scanning the channels to see what is
1825 down_read(&interfaces_sem); 1890 available. */
1891 intf->null_user_handler = channel_handler;
1892 intf->curr_channel = 0;
1893 rv = send_channel_info_cmd(intf, 0);
1894 if (rv)
1895 goto out;
1826 1896
1827 if (ipmi_interfaces[i] != new_intf) 1897 /* Wait for the channel info to be read. */
1828 /* Well, it went away. Just return. */ 1898 wait_event(intf->waitq,
1829 goto out; 1899 intf->curr_channel >= IPMI_MAX_CHANNELS);
1830 } else { 1900 } else {
1831 /* Assume a single IPMB channel at zero. */ 1901 /* Assume a single IPMB channel at zero. */
1832 (*intf)->channels[0].medium = IPMI_CHANNEL_MEDIUM_IPMB; 1902 intf->channels[0].medium = IPMI_CHANNEL_MEDIUM_IPMB;
1833 (*intf)->channels[0].protocol 1903 intf->channels[0].protocol = IPMI_CHANNEL_PROTOCOL_IPMB;
1834 = IPMI_CHANNEL_PROTOCOL_IPMB;
1835 }
1836
1837 /* Call all the watcher interfaces to tell
1838 them that a new interface is available. */
1839 call_smi_watchers(i);
1840 } 1904 }
1841 1905
1842 out: 1906 if (rv == 0)
1843 up_read(&interfaces_sem); 1907 rv = add_proc_entries(intf, i);
1844 1908
1909 out:
1845 if (rv) { 1910 if (rv) {
1846 if (new_intf->proc_dir) 1911 if (intf->proc_dir)
1847 remove_proc_entries(new_intf); 1912 remove_proc_entries(intf);
1848 kfree(new_intf); 1913 kref_put(&intf->refcount, intf_free);
1914 if (i < MAX_IPMI_INTERFACES) {
1915 spin_lock_irqsave(&interfaces_lock, flags);
1916 ipmi_interfaces[i] = NULL;
1917 spin_unlock_irqrestore(&interfaces_lock, flags);
1918 }
1919 } else {
1920 spin_lock_irqsave(&interfaces_lock, flags);
1921 ipmi_interfaces[i] = intf;
1922 spin_unlock_irqrestore(&interfaces_lock, flags);
1923 call_smi_watchers(i);
1849 } 1924 }
1850 1925
1851 return rv; 1926 return rv;
1852} 1927}
1853 1928
1854static void free_recv_msg_list(struct list_head *q)
1855{
1856 struct ipmi_recv_msg *msg, *msg2;
1857
1858 list_for_each_entry_safe(msg, msg2, q, link) {
1859 list_del(&msg->link);
1860 ipmi_free_recv_msg(msg);
1861 }
1862}
1863
1864static void free_cmd_rcvr_list(struct list_head *q)
1865{
1866 struct cmd_rcvr *rcvr, *rcvr2;
1867
1868 list_for_each_entry_safe(rcvr, rcvr2, q, link) {
1869 list_del(&rcvr->link);
1870 kfree(rcvr);
1871 }
1872}
1873
1874static void clean_up_interface_data(ipmi_smi_t intf)
1875{
1876 int i;
1877
1878 free_recv_msg_list(&(intf->waiting_msgs));
1879 free_recv_msg_list(&(intf->waiting_events));
1880 free_cmd_rcvr_list(&(intf->cmd_rcvrs));
1881
1882 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
1883 if ((intf->seq_table[i].inuse)
1884 && (intf->seq_table[i].recv_msg))
1885 {
1886 ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
1887 }
1888 }
1889}
1890
1891int ipmi_unregister_smi(ipmi_smi_t intf) 1929int ipmi_unregister_smi(ipmi_smi_t intf)
1892{ 1930{
1893 int rv = -ENODEV;
1894 int i; 1931 int i;
1895 struct ipmi_smi_watcher *w; 1932 struct ipmi_smi_watcher *w;
1896 unsigned long flags; 1933 unsigned long flags;
1897 1934
1898 down_write(&interfaces_sem); 1935 spin_lock_irqsave(&interfaces_lock, flags);
1899 if (list_empty(&(intf->users))) 1936 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
1900 { 1937 if (ipmi_interfaces[i] == intf) {
1901 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 1938 /* Set the interface number reserved until we
1902 if (ipmi_interfaces[i] == intf) { 1939 * are done. */
1903 remove_proc_entries(intf); 1940 ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY;
1904 spin_lock_irqsave(&interfaces_lock, flags); 1941 intf->intf_num = -1;
1905 ipmi_interfaces[i] = NULL; 1942 break;
1906 clean_up_interface_data(intf);
1907 spin_unlock_irqrestore(&interfaces_lock,flags);
1908 kfree(intf);
1909 rv = 0;
1910 goto out_call_watcher;
1911 }
1912 } 1943 }
1913 } else {
1914 rv = -EBUSY;
1915 } 1944 }
1916 up_write(&interfaces_sem); 1945 spin_unlock_irqrestore(&interfaces_lock,flags);
1917 1946
1918 return rv; 1947 if (i == MAX_IPMI_INTERFACES)
1948 return -ENODEV;
1919 1949
1920 out_call_watcher: 1950 remove_proc_entries(intf);
1921 downgrade_write(&interfaces_sem);
1922 1951
1923 /* Call all the watcher interfaces to tell them that 1952 /* Call all the watcher interfaces to tell them that
1924 an interface is gone. */ 1953 an interface is gone. */
1925 down_read(&smi_watchers_sem); 1954 down_read(&smi_watchers_sem);
1926 list_for_each_entry(w, &smi_watchers, link) { 1955 list_for_each_entry(w, &smi_watchers, link)
1927 w->smi_gone(i); 1956 w->smi_gone(i);
1928 }
1929 up_read(&smi_watchers_sem); 1957 up_read(&smi_watchers_sem);
1930 up_read(&interfaces_sem); 1958
1959 /* Allow the entry to be reused now. */
1960 spin_lock_irqsave(&interfaces_lock, flags);
1961 ipmi_interfaces[i] = NULL;
1962 spin_unlock_irqrestore(&interfaces_lock,flags);
1963
1964 kref_put(&intf->refcount, intf_free);
1931 return 0; 1965 return 0;
1932} 1966}
1933 1967
@@ -1998,14 +2032,14 @@ static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf,
1998static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, 2032static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
1999 struct ipmi_smi_msg *msg) 2033 struct ipmi_smi_msg *msg)
2000{ 2034{
2001 struct cmd_rcvr *rcvr; 2035 struct cmd_rcvr *rcvr;
2002 int rv = 0; 2036 int rv = 0;
2003 unsigned char netfn; 2037 unsigned char netfn;
2004 unsigned char cmd; 2038 unsigned char cmd;
2005 ipmi_user_t user = NULL; 2039 ipmi_user_t user = NULL;
2006 struct ipmi_ipmb_addr *ipmb_addr; 2040 struct ipmi_ipmb_addr *ipmb_addr;
2007 struct ipmi_recv_msg *recv_msg; 2041 struct ipmi_recv_msg *recv_msg;
2008 unsigned long flags; 2042 unsigned long flags;
2009 2043
2010 if (msg->rsp_size < 10) { 2044 if (msg->rsp_size < 10) {
2011 /* Message not big enough, just ignore it. */ 2045 /* Message not big enough, just ignore it. */
@@ -2023,16 +2057,14 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2023 netfn = msg->rsp[4] >> 2; 2057 netfn = msg->rsp[4] >> 2;
2024 cmd = msg->rsp[8]; 2058 cmd = msg->rsp[8];
2025 2059
2026 read_lock(&(intf->cmd_rcvr_lock)); 2060 rcu_read_lock();
2027 2061 rcvr = find_cmd_rcvr(intf, netfn, cmd);
2028 /* Find the command/netfn. */ 2062 if (rcvr) {
2029 list_for_each_entry(rcvr, &(intf->cmd_rcvrs), link) { 2063 user = rcvr->user;
2030 if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) { 2064 kref_get(&user->refcount);
2031 user = rcvr->user; 2065 } else
2032 break; 2066 user = NULL;
2033 } 2067 rcu_read_unlock();
2034 }
2035 read_unlock(&(intf->cmd_rcvr_lock));
2036 2068
2037 if (user == NULL) { 2069 if (user == NULL) {
2038 /* We didn't find a user, deliver an error response. */ 2070 /* We didn't find a user, deliver an error response. */
@@ -2079,6 +2111,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2079 message, so requeue it for handling 2111 message, so requeue it for handling
2080 later. */ 2112 later. */
2081 rv = 1; 2113 rv = 1;
2114 kref_put(&user->refcount, free_user);
2082 } else { 2115 } else {
2083 /* Extract the source address from the data. */ 2116 /* Extract the source address from the data. */
2084 ipmb_addr = (struct ipmi_ipmb_addr *) &recv_msg->addr; 2117 ipmb_addr = (struct ipmi_ipmb_addr *) &recv_msg->addr;
@@ -2179,14 +2212,14 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf,
2179static int handle_lan_get_msg_cmd(ipmi_smi_t intf, 2212static int handle_lan_get_msg_cmd(ipmi_smi_t intf,
2180 struct ipmi_smi_msg *msg) 2213 struct ipmi_smi_msg *msg)
2181{ 2214{
2182 struct cmd_rcvr *rcvr; 2215 struct cmd_rcvr *rcvr;
2183 int rv = 0; 2216 int rv = 0;
2184 unsigned char netfn; 2217 unsigned char netfn;
2185 unsigned char cmd; 2218 unsigned char cmd;
2186 ipmi_user_t user = NULL; 2219 ipmi_user_t user = NULL;
2187 struct ipmi_lan_addr *lan_addr; 2220 struct ipmi_lan_addr *lan_addr;
2188 struct ipmi_recv_msg *recv_msg; 2221 struct ipmi_recv_msg *recv_msg;
2189 unsigned long flags; 2222 unsigned long flags;
2190 2223
2191 if (msg->rsp_size < 12) { 2224 if (msg->rsp_size < 12) {
2192 /* Message not big enough, just ignore it. */ 2225 /* Message not big enough, just ignore it. */
@@ -2204,19 +2237,17 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf,
2204 netfn = msg->rsp[6] >> 2; 2237 netfn = msg->rsp[6] >> 2;
2205 cmd = msg->rsp[10]; 2238 cmd = msg->rsp[10];
2206 2239
2207 read_lock(&(intf->cmd_rcvr_lock)); 2240 rcu_read_lock();
2208 2241 rcvr = find_cmd_rcvr(intf, netfn, cmd);
2209 /* Find the command/netfn. */ 2242 if (rcvr) {
2210 list_for_each_entry(rcvr, &(intf->cmd_rcvrs), link) { 2243 user = rcvr->user;
2211 if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) { 2244 kref_get(&user->refcount);
2212 user = rcvr->user; 2245 } else
2213 break; 2246 user = NULL;
2214 } 2247 rcu_read_unlock();
2215 }
2216 read_unlock(&(intf->cmd_rcvr_lock));
2217 2248
2218 if (user == NULL) { 2249 if (user == NULL) {
2219 /* We didn't find a user, deliver an error response. */ 2250 /* We didn't find a user, just give up. */
2220 spin_lock_irqsave(&intf->counter_lock, flags); 2251 spin_lock_irqsave(&intf->counter_lock, flags);
2221 intf->unhandled_commands++; 2252 intf->unhandled_commands++;
2222 spin_unlock_irqrestore(&intf->counter_lock, flags); 2253 spin_unlock_irqrestore(&intf->counter_lock, flags);
@@ -2235,6 +2266,7 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf,
2235 message, so requeue it for handling 2266 message, so requeue it for handling
2236 later. */ 2267 later. */
2237 rv = 1; 2268 rv = 1;
2269 kref_put(&user->refcount, free_user);
2238 } else { 2270 } else {
2239 /* Extract the source address from the data. */ 2271 /* Extract the source address from the data. */
2240 lan_addr = (struct ipmi_lan_addr *) &recv_msg->addr; 2272 lan_addr = (struct ipmi_lan_addr *) &recv_msg->addr;
@@ -2286,8 +2318,6 @@ static void copy_event_into_recv_msg(struct ipmi_recv_msg *recv_msg,
2286 recv_msg->msg.data_len = msg->rsp_size - 3; 2318 recv_msg->msg.data_len = msg->rsp_size - 3;
2287} 2319}
2288 2320
2289/* This will be called with the intf->users_lock read-locked, so no need
2290 to do that here. */
2291static int handle_read_event_rsp(ipmi_smi_t intf, 2321static int handle_read_event_rsp(ipmi_smi_t intf,
2292 struct ipmi_smi_msg *msg) 2322 struct ipmi_smi_msg *msg)
2293{ 2323{
@@ -2313,7 +2343,7 @@ static int handle_read_event_rsp(ipmi_smi_t intf,
2313 2343
2314 INIT_LIST_HEAD(&msgs); 2344 INIT_LIST_HEAD(&msgs);
2315 2345
2316 spin_lock_irqsave(&(intf->events_lock), flags); 2346 spin_lock_irqsave(&intf->events_lock, flags);
2317 2347
2318 spin_lock(&intf->counter_lock); 2348 spin_lock(&intf->counter_lock);
2319 intf->events++; 2349 intf->events++;
@@ -2321,12 +2351,14 @@ static int handle_read_event_rsp(ipmi_smi_t intf,
2321 2351
2322 /* Allocate and fill in one message for every user that is getting 2352 /* Allocate and fill in one message for every user that is getting
2323 events. */ 2353 events. */
2324 list_for_each_entry(user, &(intf->users), link) { 2354 rcu_read_lock();
2355 list_for_each_entry_rcu(user, &intf->users, link) {
2325 if (! user->gets_events) 2356 if (! user->gets_events)
2326 continue; 2357 continue;
2327 2358
2328 recv_msg = ipmi_alloc_recv_msg(); 2359 recv_msg = ipmi_alloc_recv_msg();
2329 if (! recv_msg) { 2360 if (! recv_msg) {
2361 rcu_read_unlock();
2330 list_for_each_entry_safe(recv_msg, recv_msg2, &msgs, link) { 2362 list_for_each_entry_safe(recv_msg, recv_msg2, &msgs, link) {
2331 list_del(&recv_msg->link); 2363 list_del(&recv_msg->link);
2332 ipmi_free_recv_msg(recv_msg); 2364 ipmi_free_recv_msg(recv_msg);
@@ -2342,8 +2374,10 @@ static int handle_read_event_rsp(ipmi_smi_t intf,
2342 2374
2343 copy_event_into_recv_msg(recv_msg, msg); 2375 copy_event_into_recv_msg(recv_msg, msg);
2344 recv_msg->user = user; 2376 recv_msg->user = user;
2377 kref_get(&user->refcount);
2345 list_add_tail(&(recv_msg->link), &msgs); 2378 list_add_tail(&(recv_msg->link), &msgs);
2346 } 2379 }
2380 rcu_read_unlock();
2347 2381
2348 if (deliver_count) { 2382 if (deliver_count) {
2349 /* Now deliver all the messages. */ 2383 /* Now deliver all the messages. */
@@ -2382,9 +2416,8 @@ static int handle_bmc_rsp(ipmi_smi_t intf,
2382 struct ipmi_smi_msg *msg) 2416 struct ipmi_smi_msg *msg)
2383{ 2417{
2384 struct ipmi_recv_msg *recv_msg; 2418 struct ipmi_recv_msg *recv_msg;
2385 int found = 0;
2386 struct ipmi_user *user;
2387 unsigned long flags; 2419 unsigned long flags;
2420 struct ipmi_user *user;
2388 2421
2389 recv_msg = (struct ipmi_recv_msg *) msg->user_data; 2422 recv_msg = (struct ipmi_recv_msg *) msg->user_data;
2390 if (recv_msg == NULL) 2423 if (recv_msg == NULL)
@@ -2396,16 +2429,9 @@ static int handle_bmc_rsp(ipmi_smi_t intf,
2396 return 0; 2429 return 0;
2397 } 2430 }
2398 2431
2432 user = recv_msg->user;
2399 /* Make sure the user still exists. */ 2433 /* Make sure the user still exists. */
2400 list_for_each_entry(user, &(intf->users), link) { 2434 if (user && !user->valid) {
2401 if (user == recv_msg->user) {
2402 /* Found it, so we can deliver it */
2403 found = 1;
2404 break;
2405 }
2406 }
2407
2408 if ((! found) && recv_msg->user) {
2409 /* The user for the message went away, so give up. */ 2435 /* The user for the message went away, so give up. */
2410 spin_lock_irqsave(&intf->counter_lock, flags); 2436 spin_lock_irqsave(&intf->counter_lock, flags);
2411 intf->unhandled_local_responses++; 2437 intf->unhandled_local_responses++;
@@ -2486,7 +2512,7 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
2486 { 2512 {
2487 /* It's a response to a response we sent. For this we 2513 /* It's a response to a response we sent. For this we
2488 deliver a send message response to the user. */ 2514 deliver a send message response to the user. */
2489 struct ipmi_recv_msg *recv_msg = msg->user_data; 2515 struct ipmi_recv_msg *recv_msg = msg->user_data;
2490 2516
2491 requeue = 0; 2517 requeue = 0;
2492 if (msg->rsp_size < 2) 2518 if (msg->rsp_size < 2)
@@ -2498,13 +2524,18 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
2498 /* Invalid channel number */ 2524 /* Invalid channel number */
2499 goto out; 2525 goto out;
2500 2526
2501 if (recv_msg) { 2527 if (!recv_msg)
2502 recv_msg->recv_type = IPMI_RESPONSE_RESPONSE_TYPE; 2528 goto out;
2503 recv_msg->msg.data = recv_msg->msg_data; 2529
2504 recv_msg->msg.data_len = 1; 2530 /* Make sure the user still exists. */
2505 recv_msg->msg_data[0] = msg->rsp[2]; 2531 if (!recv_msg->user || !recv_msg->user->valid)
2506 deliver_response(recv_msg); 2532 goto out;
2507 } 2533
2534 recv_msg->recv_type = IPMI_RESPONSE_RESPONSE_TYPE;
2535 recv_msg->msg.data = recv_msg->msg_data;
2536 recv_msg->msg.data_len = 1;
2537 recv_msg->msg_data[0] = msg->rsp[2];
2538 deliver_response(recv_msg);
2508 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 2539 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2))
2509 && (msg->rsp[1] == IPMI_GET_MSG_CMD)) 2540 && (msg->rsp[1] == IPMI_GET_MSG_CMD))
2510 { 2541 {
@@ -2570,14 +2601,11 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
2570 int rv; 2601 int rv;
2571 2602
2572 2603
2573 /* Lock the user lock so the user can't go away while we are
2574 working on it. */
2575 read_lock(&(intf->users_lock));
2576
2577 if ((msg->data_size >= 2) 2604 if ((msg->data_size >= 2)
2578 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2)) 2605 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2))
2579 && (msg->data[1] == IPMI_SEND_MSG_CMD) 2606 && (msg->data[1] == IPMI_SEND_MSG_CMD)
2580 && (msg->user_data == NULL)) { 2607 && (msg->user_data == NULL))
2608 {
2581 /* This is the local response to a command send, start 2609 /* This is the local response to a command send, start
2582 the timer for these. The user_data will not be 2610 the timer for these. The user_data will not be
2583 NULL if this is a response send, and we will let 2611 NULL if this is a response send, and we will let
@@ -2612,46 +2640,46 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
2612 } 2640 }
2613 2641
2614 ipmi_free_smi_msg(msg); 2642 ipmi_free_smi_msg(msg);
2615 goto out_unlock; 2643 goto out;
2616 } 2644 }
2617 2645
2618 /* To preserve message order, if the list is not empty, we 2646 /* To preserve message order, if the list is not empty, we
2619 tack this message onto the end of the list. */ 2647 tack this message onto the end of the list. */
2620 spin_lock_irqsave(&(intf->waiting_msgs_lock), flags); 2648 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
2621 if (!list_empty(&(intf->waiting_msgs))) { 2649 if (!list_empty(&intf->waiting_msgs)) {
2622 list_add_tail(&(msg->link), &(intf->waiting_msgs)); 2650 list_add_tail(&msg->link, &intf->waiting_msgs);
2623 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); 2651 spin_unlock(&intf->waiting_msgs_lock);
2624 goto out_unlock; 2652 goto out;
2625 } 2653 }
2626 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); 2654 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
2627 2655
2628 rv = handle_new_recv_msg(intf, msg); 2656 rv = handle_new_recv_msg(intf, msg);
2629 if (rv > 0) { 2657 if (rv > 0) {
2630 /* Could not handle the message now, just add it to a 2658 /* Could not handle the message now, just add it to a
2631 list to handle later. */ 2659 list to handle later. */
2632 spin_lock_irqsave(&(intf->waiting_msgs_lock), flags); 2660 spin_lock(&intf->waiting_msgs_lock);
2633 list_add_tail(&(msg->link), &(intf->waiting_msgs)); 2661 list_add_tail(&msg->link, &intf->waiting_msgs);
2634 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); 2662 spin_unlock(&intf->waiting_msgs_lock);
2635 } else if (rv == 0) { 2663 } else if (rv == 0) {
2636 ipmi_free_smi_msg(msg); 2664 ipmi_free_smi_msg(msg);
2637 } 2665 }
2638 2666
2639 out_unlock: 2667 out:
2640 read_unlock(&(intf->users_lock)); 2668 return;
2641} 2669}
2642 2670
2643void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf) 2671void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
2644{ 2672{
2645 ipmi_user_t user; 2673 ipmi_user_t user;
2646 2674
2647 read_lock(&(intf->users_lock)); 2675 rcu_read_lock();
2648 list_for_each_entry(user, &(intf->users), link) { 2676 list_for_each_entry_rcu(user, &intf->users, link) {
2649 if (! user->handler->ipmi_watchdog_pretimeout) 2677 if (! user->handler->ipmi_watchdog_pretimeout)
2650 continue; 2678 continue;
2651 2679
2652 user->handler->ipmi_watchdog_pretimeout(user->handler_data); 2680 user->handler->ipmi_watchdog_pretimeout(user->handler_data);
2653 } 2681 }
2654 read_unlock(&(intf->users_lock)); 2682 rcu_read_unlock();
2655} 2683}
2656 2684
2657static void 2685static void
@@ -2691,8 +2719,65 @@ smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
2691 return smi_msg; 2719 return smi_msg;
2692} 2720}
2693 2721
2694static void 2722static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
2695ipmi_timeout_handler(long timeout_period) 2723 struct list_head *timeouts, long timeout_period,
2724 int slot, unsigned long *flags)
2725{
2726 struct ipmi_recv_msg *msg;
2727
2728 if (!ent->inuse)
2729 return;
2730
2731 ent->timeout -= timeout_period;
2732 if (ent->timeout > 0)
2733 return;
2734
2735 if (ent->retries_left == 0) {
2736 /* The message has used all its retries. */
2737 ent->inuse = 0;
2738 msg = ent->recv_msg;
2739 list_add_tail(&msg->link, timeouts);
2740 spin_lock(&intf->counter_lock);
2741 if (ent->broadcast)
2742 intf->timed_out_ipmb_broadcasts++;
2743 else if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE)
2744 intf->timed_out_lan_commands++;
2745 else
2746 intf->timed_out_ipmb_commands++;
2747 spin_unlock(&intf->counter_lock);
2748 } else {
2749 struct ipmi_smi_msg *smi_msg;
2750 /* More retries, send again. */
2751
2752 /* Start with the max timer, set to normal
2753 timer after the message is sent. */
2754 ent->timeout = MAX_MSG_TIMEOUT;
2755 ent->retries_left--;
2756 spin_lock(&intf->counter_lock);
2757 if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE)
2758 intf->retransmitted_lan_commands++;
2759 else
2760 intf->retransmitted_ipmb_commands++;
2761 spin_unlock(&intf->counter_lock);
2762
2763 smi_msg = smi_from_recv_msg(intf, ent->recv_msg, slot,
2764 ent->seqid);
2765 if (! smi_msg)
2766 return;
2767
2768 spin_unlock_irqrestore(&intf->seq_lock, *flags);
2769 /* Send the new message. We send with a zero
2770 * priority. It timed out, I doubt time is
2771 * that critical now, and high priority
2772 * messages are really only for messages to the
2773 * local MC, which don't get resent. */
2774 intf->handlers->sender(intf->send_info,
2775 smi_msg, 0);
2776 spin_lock_irqsave(&intf->seq_lock, *flags);
2777 }
2778}
2779
2780static void ipmi_timeout_handler(long timeout_period)
2696{ 2781{
2697 ipmi_smi_t intf; 2782 ipmi_smi_t intf;
2698 struct list_head timeouts; 2783 struct list_head timeouts;
@@ -2706,14 +2791,14 @@ ipmi_timeout_handler(long timeout_period)
2706 spin_lock(&interfaces_lock); 2791 spin_lock(&interfaces_lock);
2707 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2792 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
2708 intf = ipmi_interfaces[i]; 2793 intf = ipmi_interfaces[i];
2709 if (intf == NULL) 2794 if (IPMI_INVALID_INTERFACE(intf))
2710 continue; 2795 continue;
2711 2796 kref_get(&intf->refcount);
2712 read_lock(&(intf->users_lock)); 2797 spin_unlock(&interfaces_lock);
2713 2798
2714 /* See if any waiting messages need to be processed. */ 2799 /* See if any waiting messages need to be processed. */
2715 spin_lock_irqsave(&(intf->waiting_msgs_lock), flags); 2800 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
2716 list_for_each_entry_safe(smi_msg, smi_msg2, &(intf->waiting_msgs), link) { 2801 list_for_each_entry_safe(smi_msg, smi_msg2, &intf->waiting_msgs, link) {
2717 if (! handle_new_recv_msg(intf, smi_msg)) { 2802 if (! handle_new_recv_msg(intf, smi_msg)) {
2718 list_del(&smi_msg->link); 2803 list_del(&smi_msg->link);
2719 ipmi_free_smi_msg(smi_msg); 2804 ipmi_free_smi_msg(smi_msg);
@@ -2723,73 +2808,23 @@ ipmi_timeout_handler(long timeout_period)
2723 break; 2808 break;
2724 } 2809 }
2725 } 2810 }
2726 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); 2811 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
2727 2812
2728 /* Go through the seq table and find any messages that 2813 /* Go through the seq table and find any messages that
2729 have timed out, putting them in the timeouts 2814 have timed out, putting them in the timeouts
2730 list. */ 2815 list. */
2731 spin_lock_irqsave(&(intf->seq_lock), flags); 2816 spin_lock_irqsave(&intf->seq_lock, flags);
2732 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) { 2817 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++)
2733 struct seq_table *ent = &(intf->seq_table[j]); 2818 check_msg_timeout(intf, &(intf->seq_table[j]),
2734 if (!ent->inuse) 2819 &timeouts, timeout_period, j,
2735 continue; 2820 &flags);
2736 2821 spin_unlock_irqrestore(&intf->seq_lock, flags);
2737 ent->timeout -= timeout_period; 2822
2738 if (ent->timeout > 0) 2823 list_for_each_entry_safe(msg, msg2, &timeouts, link)
2739 continue;
2740
2741 if (ent->retries_left == 0) {
2742 /* The message has used all its retries. */
2743 ent->inuse = 0;
2744 msg = ent->recv_msg;
2745 list_add_tail(&(msg->link), &timeouts);
2746 spin_lock(&intf->counter_lock);
2747 if (ent->broadcast)
2748 intf->timed_out_ipmb_broadcasts++;
2749 else if (ent->recv_msg->addr.addr_type
2750 == IPMI_LAN_ADDR_TYPE)
2751 intf->timed_out_lan_commands++;
2752 else
2753 intf->timed_out_ipmb_commands++;
2754 spin_unlock(&intf->counter_lock);
2755 } else {
2756 struct ipmi_smi_msg *smi_msg;
2757 /* More retries, send again. */
2758
2759 /* Start with the max timer, set to normal
2760 timer after the message is sent. */
2761 ent->timeout = MAX_MSG_TIMEOUT;
2762 ent->retries_left--;
2763 spin_lock(&intf->counter_lock);
2764 if (ent->recv_msg->addr.addr_type
2765 == IPMI_LAN_ADDR_TYPE)
2766 intf->retransmitted_lan_commands++;
2767 else
2768 intf->retransmitted_ipmb_commands++;
2769 spin_unlock(&intf->counter_lock);
2770 smi_msg = smi_from_recv_msg(intf,
2771 ent->recv_msg, j, ent->seqid);
2772 if (! smi_msg)
2773 continue;
2774
2775 spin_unlock_irqrestore(&(intf->seq_lock),flags);
2776 /* Send the new message. We send with a zero
2777 * priority. It timed out, I doubt time is
2778 * that critical now, and high priority
2779 * messages are really only for messages to the
2780 * local MC, which don't get resent. */
2781 intf->handlers->sender(intf->send_info,
2782 smi_msg, 0);
2783 spin_lock_irqsave(&(intf->seq_lock), flags);
2784 }
2785 }
2786 spin_unlock_irqrestore(&(intf->seq_lock), flags);
2787
2788 list_for_each_entry_safe(msg, msg2, &timeouts, link) {
2789 handle_msg_timeout(msg); 2824 handle_msg_timeout(msg);
2790 }
2791 2825
2792 read_unlock(&(intf->users_lock)); 2826 kref_put(&intf->refcount, intf_free);
2827 spin_lock(&interfaces_lock);
2793 } 2828 }
2794 spin_unlock(&interfaces_lock); 2829 spin_unlock(&interfaces_lock);
2795} 2830}
@@ -2802,7 +2837,7 @@ static void ipmi_request_event(void)
2802 spin_lock(&interfaces_lock); 2837 spin_lock(&interfaces_lock);
2803 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2838 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
2804 intf = ipmi_interfaces[i]; 2839 intf = ipmi_interfaces[i];
2805 if (intf == NULL) 2840 if (IPMI_INVALID_INTERFACE(intf))
2806 continue; 2841 continue;
2807 2842
2808 intf->handlers->request_events(intf->send_info); 2843 intf->handlers->request_events(intf->send_info);
@@ -2884,6 +2919,13 @@ struct ipmi_recv_msg *ipmi_alloc_recv_msg(void)
2884 return rv; 2919 return rv;
2885} 2920}
2886 2921
2922void ipmi_free_recv_msg(struct ipmi_recv_msg *msg)
2923{
2924 if (msg->user)
2925 kref_put(&msg->user->refcount, free_user);
2926 msg->done(msg);
2927}
2928
2887#ifdef CONFIG_IPMI_PANIC_EVENT 2929#ifdef CONFIG_IPMI_PANIC_EVENT
2888 2930
2889static void dummy_smi_done_handler(struct ipmi_smi_msg *msg) 2931static void dummy_smi_done_handler(struct ipmi_smi_msg *msg)
@@ -2964,7 +3006,7 @@ static void send_panic_events(char *str)
2964 /* For every registered interface, send the event. */ 3006 /* For every registered interface, send the event. */
2965 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3007 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
2966 intf = ipmi_interfaces[i]; 3008 intf = ipmi_interfaces[i];
2967 if (intf == NULL) 3009 if (IPMI_INVALID_INTERFACE(intf))
2968 continue; 3010 continue;
2969 3011
2970 /* Send the event announcing the panic. */ 3012 /* Send the event announcing the panic. */
@@ -2995,7 +3037,7 @@ static void send_panic_events(char *str)
2995 int j; 3037 int j;
2996 3038
2997 intf = ipmi_interfaces[i]; 3039 intf = ipmi_interfaces[i];
2998 if (intf == NULL) 3040 if (IPMI_INVALID_INTERFACE(intf))
2999 continue; 3041 continue;
3000 3042
3001 /* First job here is to figure out where to send the 3043 /* First job here is to figure out where to send the
@@ -3131,7 +3173,7 @@ static int panic_event(struct notifier_block *this,
3131 /* For every registered interface, set it to run to completion. */ 3173 /* For every registered interface, set it to run to completion. */
3132 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3174 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
3133 intf = ipmi_interfaces[i]; 3175 intf = ipmi_interfaces[i];
3134 if (intf == NULL) 3176 if (IPMI_INVALID_INTERFACE(intf))
3135 continue; 3177 continue;
3136 3178
3137 intf->handlers->set_run_to_completion(intf->send_info, 1); 3179 intf->handlers->set_run_to_completion(intf->send_info, 1);
@@ -3160,9 +3202,8 @@ static int ipmi_init_msghandler(void)
3160 printk(KERN_INFO "ipmi message handler version " 3202 printk(KERN_INFO "ipmi message handler version "
3161 IPMI_DRIVER_VERSION "\n"); 3203 IPMI_DRIVER_VERSION "\n");
3162 3204
3163 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3205 for (i = 0; i < MAX_IPMI_INTERFACES; i++)
3164 ipmi_interfaces[i] = NULL; 3206 ipmi_interfaces[i] = NULL;
3165 }
3166 3207
3167#ifdef CONFIG_PROC_FS 3208#ifdef CONFIG_PROC_FS
3168 proc_ipmi_root = proc_mkdir("ipmi", NULL); 3209 proc_ipmi_root = proc_mkdir("ipmi", NULL);
@@ -3258,3 +3299,4 @@ EXPORT_SYMBOL(ipmi_get_my_LUN);
3258EXPORT_SYMBOL(ipmi_smi_add_proc_entry); 3299EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
3259EXPORT_SYMBOL(proc_ipmi_root); 3300EXPORT_SYMBOL(proc_ipmi_root);
3260EXPORT_SYMBOL(ipmi_user_set_run_to_completion); 3301EXPORT_SYMBOL(ipmi_user_set_run_to_completion);
3302EXPORT_SYMBOL(ipmi_free_recv_msg);
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index f66947722e12..e053eade0366 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -56,7 +56,7 @@ static int poweroff_powercycle;
56 56
57/* parameter definition to allow user to flag power cycle */ 57/* parameter definition to allow user to flag power cycle */
58module_param(poweroff_powercycle, int, 0644); 58module_param(poweroff_powercycle, int, 0644);
59MODULE_PARM_DESC(poweroff_powercycles, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); 59MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down.");
60 60
61/* Stuff from the get device id command. */ 61/* Stuff from the get device id command. */
62static unsigned int mfg_id; 62static unsigned int mfg_id;
@@ -611,9 +611,7 @@ static int ipmi_poweroff_init (void)
611 } 611 }
612#endif 612#endif
613 613
614#ifdef CONFIG_PROC_FS
615 rv = ipmi_smi_watcher_register(&smi_watcher); 614 rv = ipmi_smi_watcher_register(&smi_watcher);
616#endif
617 if (rv) { 615 if (rv) {
618 unregister_sysctl_table(ipmi_table_header); 616 unregister_sysctl_table(ipmi_table_header);
619 printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv); 617 printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index b6e5cbfb09f8..ea89dca3dbb5 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -51,6 +51,8 @@
51#include <linux/list.h> 51#include <linux/list.h>
52#include <linux/pci.h> 52#include <linux/pci.h>
53#include <linux/ioport.h> 53#include <linux/ioport.h>
54#include <linux/notifier.h>
55#include <linux/kthread.h>
54#include <asm/irq.h> 56#include <asm/irq.h>
55#ifdef CONFIG_HIGH_RES_TIMERS 57#ifdef CONFIG_HIGH_RES_TIMERS
56#include <linux/hrtime.h> 58#include <linux/hrtime.h>
@@ -125,6 +127,7 @@ struct ipmi_device_id {
125 127
126struct smi_info 128struct smi_info
127{ 129{
130 int intf_num;
128 ipmi_smi_t intf; 131 ipmi_smi_t intf;
129 struct si_sm_data *si_sm; 132 struct si_sm_data *si_sm;
130 struct si_sm_handlers *handlers; 133 struct si_sm_handlers *handlers;
@@ -192,8 +195,7 @@ struct smi_info
192 unsigned long last_timeout_jiffies; 195 unsigned long last_timeout_jiffies;
193 196
194 /* Used to gracefully stop the timer without race conditions. */ 197 /* Used to gracefully stop the timer without race conditions. */
195 volatile int stop_operation; 198 atomic_t stop_operation;
196 volatile int timer_stopped;
197 199
198 /* The driver will disable interrupts when it gets into a 200 /* The driver will disable interrupts when it gets into a
199 situation where it cannot handle messages due to lack of 201 situation where it cannot handle messages due to lack of
@@ -220,8 +222,16 @@ struct smi_info
220 unsigned long events; 222 unsigned long events;
221 unsigned long watchdog_pretimeouts; 223 unsigned long watchdog_pretimeouts;
222 unsigned long incoming_messages; 224 unsigned long incoming_messages;
225
226 struct task_struct *thread;
223}; 227};
224 228
229static struct notifier_block *xaction_notifier_list;
230static int register_xaction_notifier(struct notifier_block * nb)
231{
232 return notifier_chain_register(&xaction_notifier_list, nb);
233}
234
225static void si_restart_short_timer(struct smi_info *smi_info); 235static void si_restart_short_timer(struct smi_info *smi_info);
226 236
227static void deliver_recv_msg(struct smi_info *smi_info, 237static void deliver_recv_msg(struct smi_info *smi_info,
@@ -281,6 +291,11 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
281 do_gettimeofday(&t); 291 do_gettimeofday(&t);
282 printk("**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec); 292 printk("**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec);
283#endif 293#endif
294 err = notifier_call_chain(&xaction_notifier_list, 0, smi_info);
295 if (err & NOTIFY_STOP_MASK) {
296 rv = SI_SM_CALL_WITHOUT_DELAY;
297 goto out;
298 }
284 err = smi_info->handlers->start_transaction( 299 err = smi_info->handlers->start_transaction(
285 smi_info->si_sm, 300 smi_info->si_sm,
286 smi_info->curr_msg->data, 301 smi_info->curr_msg->data,
@@ -291,6 +306,7 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
291 306
292 rv = SI_SM_CALL_WITHOUT_DELAY; 307 rv = SI_SM_CALL_WITHOUT_DELAY;
293 } 308 }
309 out:
294 spin_unlock(&(smi_info->msg_lock)); 310 spin_unlock(&(smi_info->msg_lock));
295 311
296 return rv; 312 return rv;
@@ -766,6 +782,29 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion)
766 spin_unlock_irqrestore(&(smi_info->si_lock), flags); 782 spin_unlock_irqrestore(&(smi_info->si_lock), flags);
767} 783}
768 784
785static int ipmi_thread(void *data)
786{
787 struct smi_info *smi_info = data;
788 unsigned long flags;
789 enum si_sm_result smi_result;
790
791 set_user_nice(current, 19);
792 while (!kthread_should_stop()) {
793 spin_lock_irqsave(&(smi_info->si_lock), flags);
794 smi_result=smi_event_handler(smi_info, 0);
795 spin_unlock_irqrestore(&(smi_info->si_lock), flags);
796 if (smi_result == SI_SM_CALL_WITHOUT_DELAY) {
797 /* do nothing */
798 }
799 else if (smi_result == SI_SM_CALL_WITH_DELAY)
800 udelay(1);
801 else
802 schedule_timeout_interruptible(1);
803 }
804 return 0;
805}
806
807
769static void poll(void *send_info) 808static void poll(void *send_info)
770{ 809{
771 struct smi_info *smi_info = send_info; 810 struct smi_info *smi_info = send_info;
@@ -819,15 +858,13 @@ static void smi_timeout(unsigned long data)
819 enum si_sm_result smi_result; 858 enum si_sm_result smi_result;
820 unsigned long flags; 859 unsigned long flags;
821 unsigned long jiffies_now; 860 unsigned long jiffies_now;
822 unsigned long time_diff; 861 long time_diff;
823#ifdef DEBUG_TIMING 862#ifdef DEBUG_TIMING
824 struct timeval t; 863 struct timeval t;
825#endif 864#endif
826 865
827 if (smi_info->stop_operation) { 866 if (atomic_read(&smi_info->stop_operation))
828 smi_info->timer_stopped = 1;
829 return; 867 return;
830 }
831 868
832 spin_lock_irqsave(&(smi_info->si_lock), flags); 869 spin_lock_irqsave(&(smi_info->si_lock), flags);
833#ifdef DEBUG_TIMING 870#ifdef DEBUG_TIMING
@@ -835,7 +872,7 @@ static void smi_timeout(unsigned long data)
835 printk("**Timer: %d.%9.9d\n", t.tv_sec, t.tv_usec); 872 printk("**Timer: %d.%9.9d\n", t.tv_sec, t.tv_usec);
836#endif 873#endif
837 jiffies_now = jiffies; 874 jiffies_now = jiffies;
838 time_diff = ((jiffies_now - smi_info->last_timeout_jiffies) 875 time_diff = (((long)jiffies_now - (long)smi_info->last_timeout_jiffies)
839 * SI_USEC_PER_JIFFY); 876 * SI_USEC_PER_JIFFY);
840 smi_result = smi_event_handler(smi_info, time_diff); 877 smi_result = smi_event_handler(smi_info, time_diff);
841 878
@@ -900,7 +937,7 @@ static irqreturn_t si_irq_handler(int irq, void *data, struct pt_regs *regs)
900 smi_info->interrupts++; 937 smi_info->interrupts++;
901 spin_unlock(&smi_info->count_lock); 938 spin_unlock(&smi_info->count_lock);
902 939
903 if (smi_info->stop_operation) 940 if (atomic_read(&smi_info->stop_operation))
904 goto out; 941 goto out;
905 942
906#ifdef DEBUG_TIMING 943#ifdef DEBUG_TIMING
@@ -1419,7 +1456,7 @@ static u32 ipmi_acpi_gpe(void *context)
1419 smi_info->interrupts++; 1456 smi_info->interrupts++;
1420 spin_unlock(&smi_info->count_lock); 1457 spin_unlock(&smi_info->count_lock);
1421 1458
1422 if (smi_info->stop_operation) 1459 if (atomic_read(&smi_info->stop_operation))
1423 goto out; 1460 goto out;
1424 1461
1425#ifdef DEBUG_TIMING 1462#ifdef DEBUG_TIMING
@@ -1919,7 +1956,8 @@ static int try_get_dev_id(struct smi_info *smi_info)
1919 smi_result = smi_info->handlers->event(smi_info->si_sm, 0); 1956 smi_result = smi_info->handlers->event(smi_info->si_sm, 0);
1920 for (;;) 1957 for (;;)
1921 { 1958 {
1922 if (smi_result == SI_SM_CALL_WITH_DELAY) { 1959 if (smi_result == SI_SM_CALL_WITH_DELAY ||
1960 smi_result == SI_SM_CALL_WITH_TICK_DELAY) {
1923 schedule_timeout_uninterruptible(1); 1961 schedule_timeout_uninterruptible(1);
1924 smi_result = smi_info->handlers->event( 1962 smi_result = smi_info->handlers->event(
1925 smi_info->si_sm, 100); 1963 smi_info->si_sm, 100);
@@ -2052,6 +2090,9 @@ static int oem_data_avail_to_receive_msg_avail(struct smi_info *smi_info)
2052 * IPMI Version = 0x51 IPMI 1.5 2090 * IPMI Version = 0x51 IPMI 1.5
2053 * Manufacturer ID = A2 02 00 Dell IANA 2091 * Manufacturer ID = A2 02 00 Dell IANA
2054 * 2092 *
2093 * Additionally, PowerEdge systems with IPMI < 1.5 may also assert
2094 * OEM0_DATA_AVAIL and needs to be treated as RECEIVE_MSG_AVAIL.
2095 *
2055 */ 2096 */
2056#define DELL_POWEREDGE_8G_BMC_DEVICE_ID 0x20 2097#define DELL_POWEREDGE_8G_BMC_DEVICE_ID 0x20
2057#define DELL_POWEREDGE_8G_BMC_DEVICE_REV 0x80 2098#define DELL_POWEREDGE_8G_BMC_DEVICE_REV 0x80
@@ -2061,16 +2102,87 @@ static void setup_dell_poweredge_oem_data_handler(struct smi_info *smi_info)
2061{ 2102{
2062 struct ipmi_device_id *id = &smi_info->device_id; 2103 struct ipmi_device_id *id = &smi_info->device_id;
2063 const char mfr[3]=DELL_IANA_MFR_ID; 2104 const char mfr[3]=DELL_IANA_MFR_ID;
2064 if (! memcmp(mfr, id->manufacturer_id, sizeof(mfr)) 2105 if (! memcmp(mfr, id->manufacturer_id, sizeof(mfr))) {
2065 && (id->device_id == DELL_POWEREDGE_8G_BMC_DEVICE_ID) 2106 if (id->device_id == DELL_POWEREDGE_8G_BMC_DEVICE_ID &&
2066 && (id->device_revision == DELL_POWEREDGE_8G_BMC_DEVICE_REV) 2107 id->device_revision == DELL_POWEREDGE_8G_BMC_DEVICE_REV &&
2067 && (id->ipmi_version == DELL_POWEREDGE_8G_BMC_IPMI_VERSION)) 2108 id->ipmi_version == DELL_POWEREDGE_8G_BMC_IPMI_VERSION) {
2068 { 2109 smi_info->oem_data_avail_handler =
2069 smi_info->oem_data_avail_handler = 2110 oem_data_avail_to_receive_msg_avail;
2070 oem_data_avail_to_receive_msg_avail; 2111 }
2112 else if (ipmi_version_major(id) < 1 ||
2113 (ipmi_version_major(id) == 1 &&
2114 ipmi_version_minor(id) < 5)) {
2115 smi_info->oem_data_avail_handler =
2116 oem_data_avail_to_receive_msg_avail;
2117 }
2071 } 2118 }
2072} 2119}
2073 2120
2121#define CANNOT_RETURN_REQUESTED_LENGTH 0xCA
2122static void return_hosed_msg_badsize(struct smi_info *smi_info)
2123{
2124 struct ipmi_smi_msg *msg = smi_info->curr_msg;
2125
2126 /* Make it a reponse */
2127 msg->rsp[0] = msg->data[0] | 4;
2128 msg->rsp[1] = msg->data[1];
2129 msg->rsp[2] = CANNOT_RETURN_REQUESTED_LENGTH;
2130 msg->rsp_size = 3;
2131 smi_info->curr_msg = NULL;
2132 deliver_recv_msg(smi_info, msg);
2133}
2134
2135/*
2136 * dell_poweredge_bt_xaction_handler
2137 * @info - smi_info.device_id must be populated
2138 *
2139 * Dell PowerEdge servers with the BT interface (x6xx and 1750) will
2140 * not respond to a Get SDR command if the length of the data
2141 * requested is exactly 0x3A, which leads to command timeouts and no
2142 * data returned. This intercepts such commands, and causes userspace
2143 * callers to try again with a different-sized buffer, which succeeds.
2144 */
2145
2146#define STORAGE_NETFN 0x0A
2147#define STORAGE_CMD_GET_SDR 0x23
2148static int dell_poweredge_bt_xaction_handler(struct notifier_block *self,
2149 unsigned long unused,
2150 void *in)
2151{
2152 struct smi_info *smi_info = in;
2153 unsigned char *data = smi_info->curr_msg->data;
2154 unsigned int size = smi_info->curr_msg->data_size;
2155 if (size >= 8 &&
2156 (data[0]>>2) == STORAGE_NETFN &&
2157 data[1] == STORAGE_CMD_GET_SDR &&
2158 data[7] == 0x3A) {
2159 return_hosed_msg_badsize(smi_info);
2160 return NOTIFY_STOP;
2161 }
2162 return NOTIFY_DONE;
2163}
2164
2165static struct notifier_block dell_poweredge_bt_xaction_notifier = {
2166 .notifier_call = dell_poweredge_bt_xaction_handler,
2167};
2168
2169/*
2170 * setup_dell_poweredge_bt_xaction_handler
2171 * @info - smi_info.device_id must be filled in already
2172 *
2173 * Fills in smi_info.device_id.start_transaction_pre_hook
2174 * when we know what function to use there.
2175 */
2176static void
2177setup_dell_poweredge_bt_xaction_handler(struct smi_info *smi_info)
2178{
2179 struct ipmi_device_id *id = &smi_info->device_id;
2180 const char mfr[3]=DELL_IANA_MFR_ID;
2181 if (! memcmp(mfr, id->manufacturer_id, sizeof(mfr)) &&
2182 smi_info->si_type == SI_BT)
2183 register_xaction_notifier(&dell_poweredge_bt_xaction_notifier);
2184}
2185
2074/* 2186/*
2075 * setup_oem_data_handler 2187 * setup_oem_data_handler
2076 * @info - smi_info.device_id must be filled in already 2188 * @info - smi_info.device_id must be filled in already
@@ -2084,6 +2196,18 @@ static void setup_oem_data_handler(struct smi_info *smi_info)
2084 setup_dell_poweredge_oem_data_handler(smi_info); 2196 setup_dell_poweredge_oem_data_handler(smi_info);
2085} 2197}
2086 2198
2199static void setup_xaction_handlers(struct smi_info *smi_info)
2200{
2201 setup_dell_poweredge_bt_xaction_handler(smi_info);
2202}
2203
2204static inline void wait_for_timer_and_thread(struct smi_info *smi_info)
2205{
2206 if (smi_info->thread != ERR_PTR(-ENOMEM))
2207 kthread_stop(smi_info->thread);
2208 del_timer_sync(&smi_info->si_timer);
2209}
2210
2087/* Returns 0 if initialized, or negative on an error. */ 2211/* Returns 0 if initialized, or negative on an error. */
2088static int init_one_smi(int intf_num, struct smi_info **smi) 2212static int init_one_smi(int intf_num, struct smi_info **smi)
2089{ 2213{
@@ -2179,6 +2303,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2179 goto out_err; 2303 goto out_err;
2180 2304
2181 setup_oem_data_handler(new_smi); 2305 setup_oem_data_handler(new_smi);
2306 setup_xaction_handlers(new_smi);
2182 2307
2183 /* Try to claim any interrupts. */ 2308 /* Try to claim any interrupts. */
2184 new_smi->irq_setup(new_smi); 2309 new_smi->irq_setup(new_smi);
@@ -2190,8 +2315,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2190 new_smi->run_to_completion = 0; 2315 new_smi->run_to_completion = 0;
2191 2316
2192 new_smi->interrupt_disabled = 0; 2317 new_smi->interrupt_disabled = 0;
2193 new_smi->timer_stopped = 0; 2318 atomic_set(&new_smi->stop_operation, 0);
2194 new_smi->stop_operation = 0; 2319 new_smi->intf_num = intf_num;
2195 2320
2196 /* Start clearing the flags before we enable interrupts or the 2321 /* Start clearing the flags before we enable interrupts or the
2197 timer to avoid racing with the timer. */ 2322 timer to avoid racing with the timer. */
@@ -2209,7 +2334,11 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2209 new_smi->si_timer.function = smi_timeout; 2334 new_smi->si_timer.function = smi_timeout;
2210 new_smi->last_timeout_jiffies = jiffies; 2335 new_smi->last_timeout_jiffies = jiffies;
2211 new_smi->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; 2336 new_smi->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES;
2337
2212 add_timer(&(new_smi->si_timer)); 2338 add_timer(&(new_smi->si_timer));
2339 if (new_smi->si_type != SI_BT)
2340 new_smi->thread = kthread_run(ipmi_thread, new_smi,
2341 "kipmi%d", new_smi->intf_num);
2213 2342
2214 rv = ipmi_register_smi(&handlers, 2343 rv = ipmi_register_smi(&handlers,
2215 new_smi, 2344 new_smi,
@@ -2251,12 +2380,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2251 return 0; 2380 return 0;
2252 2381
2253 out_err_stop_timer: 2382 out_err_stop_timer:
2254 new_smi->stop_operation = 1; 2383 atomic_inc(&new_smi->stop_operation);
2255 2384 wait_for_timer_and_thread(new_smi);
2256 /* Wait for the timer to stop. This avoids problems with race
2257 conditions removing the timer here. */
2258 while (!new_smi->timer_stopped)
2259 schedule_timeout_uninterruptible(1);
2260 2385
2261 out_err: 2386 out_err:
2262 if (new_smi->intf) 2387 if (new_smi->intf)
@@ -2362,8 +2487,7 @@ static void __exit cleanup_one_si(struct smi_info *to_clean)
2362 spin_lock_irqsave(&(to_clean->si_lock), flags); 2487 spin_lock_irqsave(&(to_clean->si_lock), flags);
2363 spin_lock(&(to_clean->msg_lock)); 2488 spin_lock(&(to_clean->msg_lock));
2364 2489
2365 to_clean->stop_operation = 1; 2490 atomic_inc(&to_clean->stop_operation);
2366
2367 to_clean->irq_cleanup(to_clean); 2491 to_clean->irq_cleanup(to_clean);
2368 2492
2369 spin_unlock(&(to_clean->msg_lock)); 2493 spin_unlock(&(to_clean->msg_lock));
@@ -2374,10 +2498,7 @@ static void __exit cleanup_one_si(struct smi_info *to_clean)
2374 interrupt. */ 2498 interrupt. */
2375 synchronize_sched(); 2499 synchronize_sched();
2376 2500
2377 /* Wait for the timer to stop. This avoids problems with race 2501 wait_for_timer_and_thread(to_clean);
2378 conditions removing the timer here. */
2379 while (!to_clean->timer_stopped)
2380 schedule_timeout_uninterruptible(1);
2381 2502
2382 /* Interrupts and timeouts are stopped, now make sure the 2503 /* Interrupts and timeouts are stopped, now make sure the
2383 interface is in a clean state. */ 2504 interface is in a clean state. */
diff --git a/drivers/char/ipmi/ipmi_si_sm.h b/drivers/char/ipmi/ipmi_si_sm.h
index 62791dd42985..bf3d4962d6a5 100644
--- a/drivers/char/ipmi/ipmi_si_sm.h
+++ b/drivers/char/ipmi/ipmi_si_sm.h
@@ -62,6 +62,7 @@ enum si_sm_result
62{ 62{
63 SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */ 63 SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
64 SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */ 64 SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */
65 SI_SM_CALL_WITH_TICK_DELAY, /* Delay at least 1 tick before calling again. */
65 SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */ 66 SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */
66 SI_SM_IDLE, /* The SM is in idle state. */ 67 SI_SM_IDLE, /* The SM is in idle state. */
67 SI_SM_HOSED, /* The hardware violated the state machine. */ 68 SI_SM_HOSED, /* The hardware violated the state machine. */
diff --git a/drivers/char/ipmi/ipmi_smic_sm.c b/drivers/char/ipmi/ipmi_smic_sm.c
index add2aa2732f0..39d7e5ef1a2b 100644
--- a/drivers/char/ipmi/ipmi_smic_sm.c
+++ b/drivers/char/ipmi/ipmi_smic_sm.c
@@ -43,6 +43,8 @@
43 43
44#include <linux/kernel.h> /* For printk. */ 44#include <linux/kernel.h> /* For printk. */
45#include <linux/string.h> 45#include <linux/string.h>
46#include <linux/module.h>
47#include <linux/moduleparam.h>
46#include <linux/ipmi_msgdefs.h> /* for completion codes */ 48#include <linux/ipmi_msgdefs.h> /* for completion codes */
47#include "ipmi_si_sm.h" 49#include "ipmi_si_sm.h"
48 50
@@ -56,6 +58,8 @@
56#define SMIC_DEBUG_ENABLE 1 58#define SMIC_DEBUG_ENABLE 1
57 59
58static int smic_debug = 1; 60static int smic_debug = 1;
61module_param(smic_debug, int, 0644);
62MODULE_PARM_DESC(smic_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
59 63
60enum smic_states { 64enum smic_states {
61 SMIC_IDLE, 65 SMIC_IDLE,
@@ -76,11 +80,17 @@ enum smic_states {
76#define SMIC_MAX_ERROR_RETRIES 3 80#define SMIC_MAX_ERROR_RETRIES 3
77 81
78/* Timeouts in microseconds. */ 82/* Timeouts in microseconds. */
79#define SMIC_RETRY_TIMEOUT 100000 83#define SMIC_RETRY_TIMEOUT 2000000
80 84
81/* SMIC Flags Register Bits */ 85/* SMIC Flags Register Bits */
82#define SMIC_RX_DATA_READY 0x80 86#define SMIC_RX_DATA_READY 0x80
83#define SMIC_TX_DATA_READY 0x40 87#define SMIC_TX_DATA_READY 0x40
88/*
89 * SMIC_SMI and SMIC_EVM_DATA_AVAIL are only used by
90 * a few systems, and then only by Systems Management
91 * Interrupts, not by the OS. Always ignore these bits.
92 *
93 */
84#define SMIC_SMI 0x10 94#define SMIC_SMI 0x10
85#define SMIC_EVM_DATA_AVAIL 0x08 95#define SMIC_EVM_DATA_AVAIL 0x08
86#define SMIC_SMS_DATA_AVAIL 0x04 96#define SMIC_SMS_DATA_AVAIL 0x04
@@ -364,8 +374,7 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
364 switch (smic->state) { 374 switch (smic->state) {
365 case SMIC_IDLE: 375 case SMIC_IDLE:
366 /* in IDLE we check for available messages */ 376 /* in IDLE we check for available messages */
367 if (flags & (SMIC_SMI | 377 if (flags & SMIC_SMS_DATA_AVAIL)
368 SMIC_EVM_DATA_AVAIL | SMIC_SMS_DATA_AVAIL))
369 { 378 {
370 return SI_SM_ATTN; 379 return SI_SM_ATTN;
371 } 380 }
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 2da64bf7469c..1f3159eb1ede 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -47,6 +47,9 @@
47#include <linux/reboot.h> 47#include <linux/reboot.h>
48#include <linux/wait.h> 48#include <linux/wait.h>
49#include <linux/poll.h> 49#include <linux/poll.h>
50#include <linux/string.h>
51#include <linux/ctype.h>
52#include <asm/atomic.h>
50#ifdef CONFIG_X86_LOCAL_APIC 53#ifdef CONFIG_X86_LOCAL_APIC
51#include <asm/apic.h> 54#include <asm/apic.h>
52#endif 55#endif
@@ -158,27 +161,120 @@ static struct fasync_struct *fasync_q = NULL;
158static char pretimeout_since_last_heartbeat = 0; 161static char pretimeout_since_last_heartbeat = 0;
159static char expect_close; 162static char expect_close;
160 163
164static DECLARE_RWSEM(register_sem);
165
166/* Parameters to ipmi_set_timeout */
167#define IPMI_SET_TIMEOUT_NO_HB 0
168#define IPMI_SET_TIMEOUT_HB_IF_NECESSARY 1
169#define IPMI_SET_TIMEOUT_FORCE_HB 2
170
171static int ipmi_set_timeout(int do_heartbeat);
172
161/* If true, the driver will start running as soon as it is configured 173/* If true, the driver will start running as soon as it is configured
162 and ready. */ 174 and ready. */
163static int start_now = 0; 175static int start_now = 0;
164 176
165module_param(timeout, int, 0); 177static int set_param_int(const char *val, struct kernel_param *kp)
178{
179 char *endp;
180 int l;
181 int rv = 0;
182
183 if (!val)
184 return -EINVAL;
185 l = simple_strtoul(val, &endp, 0);
186 if (endp == val)
187 return -EINVAL;
188
189 down_read(&register_sem);
190 *((int *)kp->arg) = l;
191 if (watchdog_user)
192 rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
193 up_read(&register_sem);
194
195 return rv;
196}
197
198static int get_param_int(char *buffer, struct kernel_param *kp)
199{
200 return sprintf(buffer, "%i", *((int *)kp->arg));
201}
202
203typedef int (*action_fn)(const char *intval, char *outval);
204
205static int action_op(const char *inval, char *outval);
206static int preaction_op(const char *inval, char *outval);
207static int preop_op(const char *inval, char *outval);
208static void check_parms(void);
209
210static int set_param_str(const char *val, struct kernel_param *kp)
211{
212 action_fn fn = (action_fn) kp->arg;
213 int rv = 0;
214 const char *end;
215 char valcp[16];
216 int len;
217
218 /* Truncate leading and trailing spaces. */
219 while (isspace(*val))
220 val++;
221 end = val + strlen(val) - 1;
222 while ((end >= val) && isspace(*end))
223 end--;
224 len = end - val + 1;
225 if (len > sizeof(valcp) - 1)
226 return -EINVAL;
227 memcpy(valcp, val, len);
228 valcp[len] = '\0';
229
230 down_read(&register_sem);
231 rv = fn(valcp, NULL);
232 if (rv)
233 goto out_unlock;
234
235 check_parms();
236 if (watchdog_user)
237 rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
238
239 out_unlock:
240 up_read(&register_sem);
241 return rv;
242}
243
244static int get_param_str(char *buffer, struct kernel_param *kp)
245{
246 action_fn fn = (action_fn) kp->arg;
247 int rv;
248
249 rv = fn(NULL, buffer);
250 if (rv)
251 return rv;
252 return strlen(buffer);
253}
254
255module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644);
166MODULE_PARM_DESC(timeout, "Timeout value in seconds."); 256MODULE_PARM_DESC(timeout, "Timeout value in seconds.");
167module_param(pretimeout, int, 0); 257
258module_param_call(pretimeout, set_param_int, get_param_int, &pretimeout, 0644);
168MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds."); 259MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds.");
169module_param_string(action, action, sizeof(action), 0); 260
261module_param_call(action, set_param_str, get_param_str, action_op, 0644);
170MODULE_PARM_DESC(action, "Timeout action. One of: " 262MODULE_PARM_DESC(action, "Timeout action. One of: "
171 "reset, none, power_cycle, power_off."); 263 "reset, none, power_cycle, power_off.");
172module_param_string(preaction, preaction, sizeof(preaction), 0); 264
265module_param_call(preaction, set_param_str, get_param_str, preaction_op, 0644);
173MODULE_PARM_DESC(preaction, "Pretimeout action. One of: " 266MODULE_PARM_DESC(preaction, "Pretimeout action. One of: "
174 "pre_none, pre_smi, pre_nmi, pre_int."); 267 "pre_none, pre_smi, pre_nmi, pre_int.");
175module_param_string(preop, preop, sizeof(preop), 0); 268
269module_param_call(preop, set_param_str, get_param_str, preop_op, 0644);
176MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: " 270MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: "
177 "preop_none, preop_panic, preop_give_data."); 271 "preop_none, preop_panic, preop_give_data.");
272
178module_param(start_now, int, 0); 273module_param(start_now, int, 0);
179MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as" 274MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as"
180 "soon as the driver is loaded."); 275 "soon as the driver is loaded.");
181module_param(nowayout, int, 0); 276
277module_param(nowayout, int, 0644);
182MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 278MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
183 279
184/* Default state of the timer. */ 280/* Default state of the timer. */
@@ -200,6 +296,8 @@ static int ipmi_start_timer_on_heartbeat = 0;
200static unsigned char ipmi_version_major; 296static unsigned char ipmi_version_major;
201static unsigned char ipmi_version_minor; 297static unsigned char ipmi_version_minor;
202 298
299/* If a pretimeout occurs, this is used to allow only one panic to happen. */
300static atomic_t preop_panic_excl = ATOMIC_INIT(-1);
203 301
204static int ipmi_heartbeat(void); 302static int ipmi_heartbeat(void);
205static void panic_halt_ipmi_heartbeat(void); 303static void panic_halt_ipmi_heartbeat(void);
@@ -294,11 +392,6 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg,
294 return rv; 392 return rv;
295} 393}
296 394
297/* Parameters to ipmi_set_timeout */
298#define IPMI_SET_TIMEOUT_NO_HB 0
299#define IPMI_SET_TIMEOUT_HB_IF_NECESSARY 1
300#define IPMI_SET_TIMEOUT_FORCE_HB 2
301
302static int ipmi_set_timeout(int do_heartbeat) 395static int ipmi_set_timeout(int do_heartbeat)
303{ 396{
304 int send_heartbeat_now; 397 int send_heartbeat_now;
@@ -732,8 +825,6 @@ static struct miscdevice ipmi_wdog_miscdev = {
732 .fops = &ipmi_wdog_fops 825 .fops = &ipmi_wdog_fops
733}; 826};
734 827
735static DECLARE_RWSEM(register_sem);
736
737static void ipmi_wdog_msg_handler(struct ipmi_recv_msg *msg, 828static void ipmi_wdog_msg_handler(struct ipmi_recv_msg *msg,
738 void *handler_data) 829 void *handler_data)
739{ 830{
@@ -749,9 +840,10 @@ static void ipmi_wdog_msg_handler(struct ipmi_recv_msg *msg,
749static void ipmi_wdog_pretimeout_handler(void *handler_data) 840static void ipmi_wdog_pretimeout_handler(void *handler_data)
750{ 841{
751 if (preaction_val != WDOG_PRETIMEOUT_NONE) { 842 if (preaction_val != WDOG_PRETIMEOUT_NONE) {
752 if (preop_val == WDOG_PREOP_PANIC) 843 if (preop_val == WDOG_PREOP_PANIC) {
753 panic("Watchdog pre-timeout"); 844 if (atomic_inc_and_test(&preop_panic_excl))
754 else if (preop_val == WDOG_PREOP_GIVE_DATA) { 845 panic("Watchdog pre-timeout");
846 } else if (preop_val == WDOG_PREOP_GIVE_DATA) {
755 spin_lock(&ipmi_read_lock); 847 spin_lock(&ipmi_read_lock);
756 data_to_read = 1; 848 data_to_read = 1;
757 wake_up_interruptible(&read_q); 849 wake_up_interruptible(&read_q);
@@ -825,7 +917,8 @@ ipmi_nmi(void *dev_id, struct pt_regs *regs, int cpu, int handled)
825 an error and not work unless we re-enable 917 an error and not work unless we re-enable
826 the timer. So do so. */ 918 the timer. So do so. */
827 pretimeout_since_last_heartbeat = 1; 919 pretimeout_since_last_heartbeat = 1;
828 panic(PFX "pre-timeout"); 920 if (atomic_inc_and_test(&preop_panic_excl))
921 panic(PFX "pre-timeout");
829 } 922 }
830 923
831 return NOTIFY_DONE; 924 return NOTIFY_DONE;
@@ -839,6 +932,7 @@ static struct nmi_handler ipmi_nmi_handler =
839 .handler = ipmi_nmi, 932 .handler = ipmi_nmi,
840 .priority = 0, /* Call us last. */ 933 .priority = 0, /* Call us last. */
841}; 934};
935int nmi_handler_registered;
842#endif 936#endif
843 937
844static int wdog_reboot_handler(struct notifier_block *this, 938static int wdog_reboot_handler(struct notifier_block *this,
@@ -921,59 +1015,86 @@ static struct ipmi_smi_watcher smi_watcher =
921 .smi_gone = ipmi_smi_gone 1015 .smi_gone = ipmi_smi_gone
922}; 1016};
923 1017
924static int __init ipmi_wdog_init(void) 1018static int action_op(const char *inval, char *outval)
925{ 1019{
926 int rv; 1020 if (outval)
1021 strcpy(outval, action);
1022
1023 if (!inval)
1024 return 0;
927 1025
928 if (strcmp(action, "reset") == 0) { 1026 if (strcmp(inval, "reset") == 0)
929 action_val = WDOG_TIMEOUT_RESET; 1027 action_val = WDOG_TIMEOUT_RESET;
930 } else if (strcmp(action, "none") == 0) { 1028 else if (strcmp(inval, "none") == 0)
931 action_val = WDOG_TIMEOUT_NONE; 1029 action_val = WDOG_TIMEOUT_NONE;
932 } else if (strcmp(action, "power_cycle") == 0) { 1030 else if (strcmp(inval, "power_cycle") == 0)
933 action_val = WDOG_TIMEOUT_POWER_CYCLE; 1031 action_val = WDOG_TIMEOUT_POWER_CYCLE;
934 } else if (strcmp(action, "power_off") == 0) { 1032 else if (strcmp(inval, "power_off") == 0)
935 action_val = WDOG_TIMEOUT_POWER_DOWN; 1033 action_val = WDOG_TIMEOUT_POWER_DOWN;
936 } else { 1034 else
937 action_val = WDOG_TIMEOUT_RESET; 1035 return -EINVAL;
938 printk(KERN_INFO PFX "Unknown action '%s', defaulting to" 1036 strcpy(action, inval);
939 " reset\n", action); 1037 return 0;
940 } 1038}
1039
1040static int preaction_op(const char *inval, char *outval)
1041{
1042 if (outval)
1043 strcpy(outval, preaction);
941 1044
942 if (strcmp(preaction, "pre_none") == 0) { 1045 if (!inval)
1046 return 0;
1047
1048 if (strcmp(inval, "pre_none") == 0)
943 preaction_val = WDOG_PRETIMEOUT_NONE; 1049 preaction_val = WDOG_PRETIMEOUT_NONE;
944 } else if (strcmp(preaction, "pre_smi") == 0) { 1050 else if (strcmp(inval, "pre_smi") == 0)
945 preaction_val = WDOG_PRETIMEOUT_SMI; 1051 preaction_val = WDOG_PRETIMEOUT_SMI;
946#ifdef HAVE_NMI_HANDLER 1052#ifdef HAVE_NMI_HANDLER
947 } else if (strcmp(preaction, "pre_nmi") == 0) { 1053 else if (strcmp(inval, "pre_nmi") == 0)
948 preaction_val = WDOG_PRETIMEOUT_NMI; 1054 preaction_val = WDOG_PRETIMEOUT_NMI;
949#endif 1055#endif
950 } else if (strcmp(preaction, "pre_int") == 0) { 1056 else if (strcmp(inval, "pre_int") == 0)
951 preaction_val = WDOG_PRETIMEOUT_MSG_INT; 1057 preaction_val = WDOG_PRETIMEOUT_MSG_INT;
952 } else { 1058 else
953 preaction_val = WDOG_PRETIMEOUT_NONE; 1059 return -EINVAL;
954 printk(KERN_INFO PFX "Unknown preaction '%s', defaulting to" 1060 strcpy(preaction, inval);
955 " none\n", preaction); 1061 return 0;
956 } 1062}
1063
1064static int preop_op(const char *inval, char *outval)
1065{
1066 if (outval)
1067 strcpy(outval, preop);
957 1068
958 if (strcmp(preop, "preop_none") == 0) { 1069 if (!inval)
1070 return 0;
1071
1072 if (strcmp(inval, "preop_none") == 0)
959 preop_val = WDOG_PREOP_NONE; 1073 preop_val = WDOG_PREOP_NONE;
960 } else if (strcmp(preop, "preop_panic") == 0) { 1074 else if (strcmp(inval, "preop_panic") == 0)
961 preop_val = WDOG_PREOP_PANIC; 1075 preop_val = WDOG_PREOP_PANIC;
962 } else if (strcmp(preop, "preop_give_data") == 0) { 1076 else if (strcmp(inval, "preop_give_data") == 0)
963 preop_val = WDOG_PREOP_GIVE_DATA; 1077 preop_val = WDOG_PREOP_GIVE_DATA;
964 } else { 1078 else
965 preop_val = WDOG_PREOP_NONE; 1079 return -EINVAL;
966 printk(KERN_INFO PFX "Unknown preop '%s', defaulting to" 1080 strcpy(preop, inval);
967 " none\n", preop); 1081 return 0;
968 } 1082}
969 1083
1084static void check_parms(void)
1085{
970#ifdef HAVE_NMI_HANDLER 1086#ifdef HAVE_NMI_HANDLER
1087 int do_nmi = 0;
1088 int rv;
1089
971 if (preaction_val == WDOG_PRETIMEOUT_NMI) { 1090 if (preaction_val == WDOG_PRETIMEOUT_NMI) {
1091 do_nmi = 1;
972 if (preop_val == WDOG_PREOP_GIVE_DATA) { 1092 if (preop_val == WDOG_PREOP_GIVE_DATA) {
973 printk(KERN_WARNING PFX "Pretimeout op is to give data" 1093 printk(KERN_WARNING PFX "Pretimeout op is to give data"
974 " but NMI pretimeout is enabled, setting" 1094 " but NMI pretimeout is enabled, setting"
975 " pretimeout op to none\n"); 1095 " pretimeout op to none\n");
976 preop_val = WDOG_PREOP_NONE; 1096 preop_op("preop_none", NULL);
1097 do_nmi = 0;
977 } 1098 }
978#ifdef CONFIG_X86_LOCAL_APIC 1099#ifdef CONFIG_X86_LOCAL_APIC
979 if (nmi_watchdog == NMI_IO_APIC) { 1100 if (nmi_watchdog == NMI_IO_APIC) {
@@ -983,18 +1104,48 @@ static int __init ipmi_wdog_init(void)
983 " Disabling IPMI nmi pretimeout.\n", 1104 " Disabling IPMI nmi pretimeout.\n",
984 nmi_watchdog); 1105 nmi_watchdog);
985 preaction_val = WDOG_PRETIMEOUT_NONE; 1106 preaction_val = WDOG_PRETIMEOUT_NONE;
986 } else { 1107 do_nmi = 0;
1108 }
987#endif 1109#endif
1110 }
1111 if (do_nmi && !nmi_handler_registered) {
988 rv = request_nmi(&ipmi_nmi_handler); 1112 rv = request_nmi(&ipmi_nmi_handler);
989 if (rv) { 1113 if (rv) {
990 printk(KERN_WARNING PFX "Can't register nmi handler\n"); 1114 printk(KERN_WARNING PFX
991 return rv; 1115 "Can't register nmi handler\n");
992 } 1116 return;
993#ifdef CONFIG_X86_LOCAL_APIC 1117 } else
994 } 1118 nmi_handler_registered = 1;
995#endif 1119 } else if (!do_nmi && nmi_handler_registered) {
1120 release_nmi(&ipmi_nmi_handler);
1121 nmi_handler_registered = 0;
996 } 1122 }
997#endif 1123#endif
1124}
1125
1126static int __init ipmi_wdog_init(void)
1127{
1128 int rv;
1129
1130 if (action_op(action, NULL)) {
1131 action_op("reset", NULL);
1132 printk(KERN_INFO PFX "Unknown action '%s', defaulting to"
1133 " reset\n", action);
1134 }
1135
1136 if (preaction_op(preaction, NULL)) {
1137 preaction_op("pre_none", NULL);
1138 printk(KERN_INFO PFX "Unknown preaction '%s', defaulting to"
1139 " none\n", preaction);
1140 }
1141
1142 if (preop_op(preop, NULL)) {
1143 preop_op("preop_none", NULL);
1144 printk(KERN_INFO PFX "Unknown preop '%s', defaulting to"
1145 " none\n", preop);
1146 }
1147
1148 check_parms();
998 1149
999 rv = ipmi_smi_watcher_register(&smi_watcher); 1150 rv = ipmi_smi_watcher_register(&smi_watcher);
1000 if (rv) { 1151 if (rv) {
@@ -1021,7 +1172,7 @@ static __exit void ipmi_unregister_watchdog(void)
1021 down_write(&register_sem); 1172 down_write(&register_sem);
1022 1173
1023#ifdef HAVE_NMI_HANDLER 1174#ifdef HAVE_NMI_HANDLER
1024 if (preaction_val == WDOG_PRETIMEOUT_NMI) 1175 if (nmi_handler_registered)
1025 release_nmi(&ipmi_nmi_handler); 1176 release_nmi(&ipmi_nmi_handler);
1026#endif 1177#endif
1027 1178
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index e3ddbdb85a2f..ce3bc0d45f1f 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -860,10 +860,9 @@ static void __exit istallion_module_exit(void)
860 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) 860 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
861 printk("STALLION: failed to un-register serial memory device, " 861 printk("STALLION: failed to un-register serial memory device, "
862 "errno=%d\n", -i); 862 "errno=%d\n", -i);
863 if (stli_tmpwritebuf != (char *) NULL) 863
864 kfree(stli_tmpwritebuf); 864 kfree(stli_tmpwritebuf);
865 if (stli_txcookbuf != (char *) NULL) 865 kfree(stli_txcookbuf);
866 kfree(stli_txcookbuf);
867 866
868 for (i = 0; (i < stli_nrbrds); i++) { 867 for (i = 0; (i < stli_nrbrds); i++) {
869 if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) 868 if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL)
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 45d012d85e8c..3b965a651da4 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -470,6 +470,8 @@ static struct tty_operations mxser_ops = {
470 .stop = mxser_stop, 470 .stop = mxser_stop,
471 .start = mxser_start, 471 .start = mxser_start,
472 .hangup = mxser_hangup, 472 .hangup = mxser_hangup,
473 .break_ctl = mxser_rs_break,
474 .wait_until_sent = mxser_wait_until_sent,
473 .tiocmget = mxser_tiocmget, 475 .tiocmget = mxser_tiocmget,
474 .tiocmset = mxser_tiocmset, 476 .tiocmset = mxser_tiocmset,
475}; 477};
@@ -492,14 +494,18 @@ static int __init mxser_module_init(void)
492 494
493static void __exit mxser_module_exit(void) 495static void __exit mxser_module_exit(void)
494{ 496{
495 int i, err = 0; 497 int i, err;
496 498
497 if (verbose) 499 if (verbose)
498 printk(KERN_DEBUG "Unloading module mxser ...\n"); 500 printk(KERN_DEBUG "Unloading module mxser ...\n");
499 501
500 if ((err |= tty_unregister_driver(mxvar_sdriver))) 502 err = tty_unregister_driver(mxvar_sdriver);
503 if (!err)
504 put_tty_driver(mxvar_sdriver);
505 else
501 printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); 506 printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n");
502 507
508
503 for (i = 0; i < MXSER_BOARDS; i++) { 509 for (i = 0; i < MXSER_BOARDS; i++) {
504 struct pci_dev *pdev; 510 struct pci_dev *pdev;
505 511
@@ -688,7 +694,6 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs
688static int mxser_init(void) 694static int mxser_init(void)
689{ 695{
690 int i, m, retval, b, n; 696 int i, m, retval, b, n;
691 int ret1;
692 struct pci_dev *pdev = NULL; 697 struct pci_dev *pdev = NULL;
693 int index; 698 int index;
694 unsigned char busnum, devnum; 699 unsigned char busnum, devnum;
@@ -722,24 +727,6 @@ static int mxser_init(void)
722 mxvar_sdriver->termios = mxvar_termios; 727 mxvar_sdriver->termios = mxvar_termios;
723 mxvar_sdriver->termios_locked = mxvar_termios_locked; 728 mxvar_sdriver->termios_locked = mxvar_termios_locked;
724 729
725 mxvar_sdriver->open = mxser_open;
726 mxvar_sdriver->close = mxser_close;
727 mxvar_sdriver->write = mxser_write;
728 mxvar_sdriver->put_char = mxser_put_char;
729 mxvar_sdriver->flush_chars = mxser_flush_chars;
730 mxvar_sdriver->write_room = mxser_write_room;
731 mxvar_sdriver->chars_in_buffer = mxser_chars_in_buffer;
732 mxvar_sdriver->flush_buffer = mxser_flush_buffer;
733 mxvar_sdriver->ioctl = mxser_ioctl;
734 mxvar_sdriver->throttle = mxser_throttle;
735 mxvar_sdriver->unthrottle = mxser_unthrottle;
736 mxvar_sdriver->set_termios = mxser_set_termios;
737 mxvar_sdriver->stop = mxser_stop;
738 mxvar_sdriver->start = mxser_start;
739 mxvar_sdriver->hangup = mxser_hangup;
740 mxvar_sdriver->break_ctl = mxser_rs_break;
741 mxvar_sdriver->wait_until_sent = mxser_wait_until_sent;
742
743 mxvar_diagflag = 0; 730 mxvar_diagflag = 0;
744 memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct)); 731 memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct));
745 memset(&mxvar_log, 0, sizeof(struct mxser_log)); 732 memset(&mxvar_log, 0, sizeof(struct mxser_log));
@@ -870,14 +857,11 @@ static int mxser_init(void)
870 } 857 }
871#endif 858#endif
872 859
873 ret1 = 0; 860 retval = tty_register_driver(mxvar_sdriver);
874 if (!(ret1 = tty_register_driver(mxvar_sdriver))) { 861 if (retval) {
875 return 0;
876 } else
877 printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n"); 862 printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n");
863 put_tty_driver(mxvar_sdriver);
878 864
879
880 if (ret1) {
881 for (i = 0; i < MXSER_BOARDS; i++) { 865 for (i = 0; i < MXSER_BOARDS; i++) {
882 if (mxsercfg[i].board_type == -1) 866 if (mxsercfg[i].board_type == -1)
883 continue; 867 continue;
@@ -886,10 +870,10 @@ static int mxser_init(void)
886 //todo: release io, vector 870 //todo: release io, vector
887 } 871 }
888 } 872 }
889 return -1; 873 return retval;
890 } 874 }
891 875
892 return (0); 876 return 0;
893} 877}
894 878
895static void mxser_do_softint(void *private_) 879static void mxser_do_softint(void *private_)
@@ -933,6 +917,9 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
933 struct mxser_struct *info; 917 struct mxser_struct *info;
934 int retval, line; 918 int retval, line;
935 919
920 /* initialize driver_data in case something fails */
921 tty->driver_data = NULL;
922
936 line = tty->index; 923 line = tty->index;
937 if (line == MXSER_PORTS) 924 if (line == MXSER_PORTS)
938 return 0; 925 return 0;
@@ -995,7 +982,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
995 if (tty->index == MXSER_PORTS) 982 if (tty->index == MXSER_PORTS)
996 return; 983 return;
997 if (!info) 984 if (!info)
998 BUG(); 985 return;
999 986
1000 spin_lock_irqsave(&info->slock, flags); 987 spin_lock_irqsave(&info->slock, flags);
1001 988
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
index 5079beda69b5..c3660d8781a4 100644
--- a/drivers/char/n_hdlc.c
+++ b/drivers/char/n_hdlc.c
@@ -264,8 +264,7 @@ static void n_hdlc_release(struct n_hdlc *n_hdlc)
264 } else 264 } else
265 break; 265 break;
266 } 266 }
267 if (n_hdlc->tbuf) 267 kfree(n_hdlc->tbuf);
268 kfree(n_hdlc->tbuf);
269 kfree(n_hdlc); 268 kfree(n_hdlc);
270 269
271} /* end of n_hdlc_release() */ 270} /* end of n_hdlc_release() */
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 02d7f046c10a..2c326ea53421 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2994,8 +2994,7 @@ int rx_alloc_buffers(MGSLPC_INFO *info)
2994 2994
2995void rx_free_buffers(MGSLPC_INFO *info) 2995void rx_free_buffers(MGSLPC_INFO *info)
2996{ 2996{
2997 if (info->rx_buf) 2997 kfree(info->rx_buf);
2998 kfree(info->rx_buf);
2999 info->rx_buf = NULL; 2998 info->rx_buf = NULL;
3000} 2999}
3001 3000
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 928b850cc679..d3bc731fbb27 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -2512,10 +2512,8 @@ static void rp_cleanup_module(void)
2512 "rocketport driver\n", -retval); 2512 "rocketport driver\n", -retval);
2513 put_tty_driver(rocket_driver); 2513 put_tty_driver(rocket_driver);
2514 2514
2515 for (i = 0; i < MAX_RP_PORTS; i++) { 2515 for (i = 0; i < MAX_RP_PORTS; i++)
2516 if (rp_table[i]) 2516 kfree(rp_table[i]);
2517 kfree(rp_table[i]);
2518 }
2519 2517
2520 for (i = 0; i < NUM_BOARDS; i++) { 2518 for (i = 0; i < NUM_BOARDS; i++) {
2521 if (rcktpt_io_addr[i] <= 0 || is_PCI[i]) 2519 if (rcktpt_io_addr[i] <= 0 || is_PCI[i])
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 63fff7c1244a..a7f099fb7dfe 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -149,8 +149,22 @@ static void get_rtc_alm_time (struct rtc_time *alm_tm);
149#ifdef RTC_IRQ 149#ifdef RTC_IRQ
150static void rtc_dropped_irq(unsigned long data); 150static void rtc_dropped_irq(unsigned long data);
151 151
152static void set_rtc_irq_bit(unsigned char bit); 152static void set_rtc_irq_bit_locked(unsigned char bit);
153static void mask_rtc_irq_bit(unsigned char bit); 153static void mask_rtc_irq_bit_locked(unsigned char bit);
154
155static inline void set_rtc_irq_bit(unsigned char bit)
156{
157 spin_lock_irq(&rtc_lock);
158 set_rtc_irq_bit_locked(bit);
159 spin_unlock_irq(&rtc_lock);
160}
161
162static void mask_rtc_irq_bit(unsigned char bit)
163{
164 spin_lock_irq(&rtc_lock);
165 mask_rtc_irq_bit_locked(bit);
166 spin_unlock_irq(&rtc_lock);
167}
154#endif 168#endif
155 169
156static int rtc_proc_open(struct inode *inode, struct file *file); 170static int rtc_proc_open(struct inode *inode, struct file *file);
@@ -401,18 +415,19 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
401 } 415 }
402 case RTC_PIE_OFF: /* Mask periodic int. enab. bit */ 416 case RTC_PIE_OFF: /* Mask periodic int. enab. bit */
403 { 417 {
404 mask_rtc_irq_bit(RTC_PIE); 418 unsigned long flags; /* can be called from isr via rtc_control() */
419 spin_lock_irqsave (&rtc_lock, flags);
420 mask_rtc_irq_bit_locked(RTC_PIE);
405 if (rtc_status & RTC_TIMER_ON) { 421 if (rtc_status & RTC_TIMER_ON) {
406 spin_lock_irq (&rtc_lock);
407 rtc_status &= ~RTC_TIMER_ON; 422 rtc_status &= ~RTC_TIMER_ON;
408 del_timer(&rtc_irq_timer); 423 del_timer(&rtc_irq_timer);
409 spin_unlock_irq (&rtc_lock);
410 } 424 }
425 spin_unlock_irqrestore (&rtc_lock, flags);
411 return 0; 426 return 0;
412 } 427 }
413 case RTC_PIE_ON: /* Allow periodic ints */ 428 case RTC_PIE_ON: /* Allow periodic ints */
414 { 429 {
415 430 unsigned long flags; /* can be called from isr via rtc_control() */
416 /* 431 /*
417 * We don't really want Joe User enabling more 432 * We don't really want Joe User enabling more
418 * than 64Hz of interrupts on a multi-user machine. 433 * than 64Hz of interrupts on a multi-user machine.
@@ -421,14 +436,14 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
421 (!capable(CAP_SYS_RESOURCE))) 436 (!capable(CAP_SYS_RESOURCE)))
422 return -EACCES; 437 return -EACCES;
423 438
439 spin_lock_irqsave (&rtc_lock, flags);
424 if (!(rtc_status & RTC_TIMER_ON)) { 440 if (!(rtc_status & RTC_TIMER_ON)) {
425 spin_lock_irq (&rtc_lock);
426 rtc_irq_timer.expires = jiffies + HZ/rtc_freq + 2*HZ/100; 441 rtc_irq_timer.expires = jiffies + HZ/rtc_freq + 2*HZ/100;
427 add_timer(&rtc_irq_timer); 442 add_timer(&rtc_irq_timer);
428 rtc_status |= RTC_TIMER_ON; 443 rtc_status |= RTC_TIMER_ON;
429 spin_unlock_irq (&rtc_lock);
430 } 444 }
431 set_rtc_irq_bit(RTC_PIE); 445 set_rtc_irq_bit_locked(RTC_PIE);
446 spin_unlock_irqrestore (&rtc_lock, flags);
432 return 0; 447 return 0;
433 } 448 }
434 case RTC_UIE_OFF: /* Mask ints from RTC updates. */ 449 case RTC_UIE_OFF: /* Mask ints from RTC updates. */
@@ -609,6 +624,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
609 { 624 {
610 int tmp = 0; 625 int tmp = 0;
611 unsigned char val; 626 unsigned char val;
627 unsigned long flags; /* can be called from isr via rtc_control() */
612 628
613 /* 629 /*
614 * The max we can do is 8192Hz. 630 * The max we can do is 8192Hz.
@@ -631,9 +647,9 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
631 if (arg != (1<<tmp)) 647 if (arg != (1<<tmp))
632 return -EINVAL; 648 return -EINVAL;
633 649
634 spin_lock_irq(&rtc_lock); 650 spin_lock_irqsave(&rtc_lock, flags);
635 if (hpet_set_periodic_freq(arg)) { 651 if (hpet_set_periodic_freq(arg)) {
636 spin_unlock_irq(&rtc_lock); 652 spin_unlock_irqrestore(&rtc_lock, flags);
637 return 0; 653 return 0;
638 } 654 }
639 rtc_freq = arg; 655 rtc_freq = arg;
@@ -641,7 +657,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
641 val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0; 657 val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0;
642 val |= (16 - tmp); 658 val |= (16 - tmp);
643 CMOS_WRITE(val, RTC_FREQ_SELECT); 659 CMOS_WRITE(val, RTC_FREQ_SELECT);
644 spin_unlock_irq(&rtc_lock); 660 spin_unlock_irqrestore(&rtc_lock, flags);
645 return 0; 661 return 0;
646 } 662 }
647#endif 663#endif
@@ -844,12 +860,15 @@ int rtc_control(rtc_task_t *task, unsigned int cmd, unsigned long arg)
844#ifndef RTC_IRQ 860#ifndef RTC_IRQ
845 return -EIO; 861 return -EIO;
846#else 862#else
847 spin_lock_irq(&rtc_task_lock); 863 unsigned long flags;
864 if (cmd != RTC_PIE_ON && cmd != RTC_PIE_OFF && cmd != RTC_IRQP_SET)
865 return -EINVAL;
866 spin_lock_irqsave(&rtc_task_lock, flags);
848 if (rtc_callback != task) { 867 if (rtc_callback != task) {
849 spin_unlock_irq(&rtc_task_lock); 868 spin_unlock_irqrestore(&rtc_task_lock, flags);
850 return -ENXIO; 869 return -ENXIO;
851 } 870 }
852 spin_unlock_irq(&rtc_task_lock); 871 spin_unlock_irqrestore(&rtc_task_lock, flags);
853 return rtc_do_ioctl(cmd, arg, 1); 872 return rtc_do_ioctl(cmd, arg, 1);
854#endif 873#endif
855} 874}
@@ -1306,40 +1325,32 @@ static void get_rtc_alm_time(struct rtc_time *alm_tm)
1306 * meddles with the interrupt enable/disable bits. 1325 * meddles with the interrupt enable/disable bits.
1307 */ 1326 */
1308 1327
1309static void mask_rtc_irq_bit(unsigned char bit) 1328static void mask_rtc_irq_bit_locked(unsigned char bit)
1310{ 1329{
1311 unsigned char val; 1330 unsigned char val;
1312 1331
1313 spin_lock_irq(&rtc_lock); 1332 if (hpet_mask_rtc_irq_bit(bit))
1314 if (hpet_mask_rtc_irq_bit(bit)) {
1315 spin_unlock_irq(&rtc_lock);
1316 return; 1333 return;
1317 }
1318 val = CMOS_READ(RTC_CONTROL); 1334 val = CMOS_READ(RTC_CONTROL);
1319 val &= ~bit; 1335 val &= ~bit;
1320 CMOS_WRITE(val, RTC_CONTROL); 1336 CMOS_WRITE(val, RTC_CONTROL);
1321 CMOS_READ(RTC_INTR_FLAGS); 1337 CMOS_READ(RTC_INTR_FLAGS);
1322 1338
1323 rtc_irq_data = 0; 1339 rtc_irq_data = 0;
1324 spin_unlock_irq(&rtc_lock);
1325} 1340}
1326 1341
1327static void set_rtc_irq_bit(unsigned char bit) 1342static void set_rtc_irq_bit_locked(unsigned char bit)
1328{ 1343{
1329 unsigned char val; 1344 unsigned char val;
1330 1345
1331 spin_lock_irq(&rtc_lock); 1346 if (hpet_set_rtc_irq_bit(bit))
1332 if (hpet_set_rtc_irq_bit(bit)) {
1333 spin_unlock_irq(&rtc_lock);
1334 return; 1347 return;
1335 }
1336 val = CMOS_READ(RTC_CONTROL); 1348 val = CMOS_READ(RTC_CONTROL);
1337 val |= bit; 1349 val |= bit;
1338 CMOS_WRITE(val, RTC_CONTROL); 1350 CMOS_WRITE(val, RTC_CONTROL);
1339 CMOS_READ(RTC_INTR_FLAGS); 1351 CMOS_READ(RTC_INTR_FLAGS);
1340 1352
1341 rtc_irq_data = 0; 1353 rtc_irq_data = 0;
1342 spin_unlock_irq(&rtc_lock);
1343} 1354}
1344#endif 1355#endif
1345 1356
diff --git a/drivers/char/selection.c b/drivers/char/selection.c
index 16d630f58bb4..5b187c895c18 100644
--- a/drivers/char/selection.c
+++ b/drivers/char/selection.c
@@ -246,8 +246,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
246 clear_selection(); 246 clear_selection();
247 return -ENOMEM; 247 return -ENOMEM;
248 } 248 }
249 if (sel_buffer) 249 kfree(sel_buffer);
250 kfree(sel_buffer);
251 sel_buffer = bp; 250 sel_buffer = bp;
252 251
253 obp = bp; 252 obp = bp;
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 1c686414e0a1..95af2a941595 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -785,8 +785,7 @@ static void __exit stallion_module_exit(void)
785 "errno=%d\n", -i); 785 "errno=%d\n", -i);
786 class_destroy(stallion_class); 786 class_destroy(stallion_class);
787 787
788 if (stl_tmpwritebuf != (char *) NULL) 788 kfree(stl_tmpwritebuf);
789 kfree(stl_tmpwritebuf);
790 789
791 for (i = 0; (i < stl_nrbrds); i++) { 790 for (i = 0; (i < stl_nrbrds); i++) {
792 if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL) 791 if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
@@ -804,8 +803,7 @@ static void __exit stallion_module_exit(void)
804 continue; 803 continue;
805 if (portp->tty != (struct tty_struct *) NULL) 804 if (portp->tty != (struct tty_struct *) NULL)
806 stl_hangup(portp->tty); 805 stl_hangup(portp->tty);
807 if (portp->tx.buf != (char *) NULL) 806 kfree(portp->tx.buf);
808 kfree(portp->tx.buf);
809 kfree(portp); 807 kfree(portp);
810 } 808 }
811 kfree(panelp); 809 kfree(panelp);
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 0133dc0e25d0..5d1ffa3bd4c3 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -4016,9 +4016,7 @@ static int mgsl_alloc_intermediate_rxbuffer_memory(struct mgsl_struct *info)
4016 */ 4016 */
4017static void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info) 4017static void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info)
4018{ 4018{
4019 if ( info->intermediate_rxbuffer ) 4019 kfree(info->intermediate_rxbuffer);
4020 kfree(info->intermediate_rxbuffer);
4021
4022 info->intermediate_rxbuffer = NULL; 4020 info->intermediate_rxbuffer = NULL;
4023 4021
4024} /* end of mgsl_free_intermediate_rxbuffer_memory() */ 4022} /* end of mgsl_free_intermediate_rxbuffer_memory() */
@@ -4072,10 +4070,8 @@ static void mgsl_free_intermediate_txbuffer_memory(struct mgsl_struct *info)
4072 int i; 4070 int i;
4073 4071
4074 for ( i=0; i<info->num_tx_holding_buffers; ++i ) { 4072 for ( i=0; i<info->num_tx_holding_buffers; ++i ) {
4075 if ( info->tx_holding_buffers[i].buffer ) { 4073 kfree(info->tx_holding_buffers[i].buffer);
4076 kfree(info->tx_holding_buffers[i].buffer); 4074 info->tx_holding_buffers[i].buffer = NULL;
4077 info->tx_holding_buffers[i].buffer=NULL;
4078 }
4079 } 4075 }
4080 4076
4081 info->get_tx_holding_index = 0; 4077 info->get_tx_holding_index = 0;
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index f185724448b1..7c063c5abc55 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -2788,10 +2788,8 @@ static void shutdown(SLMP_INFO * info)
2788 del_timer(&info->tx_timer); 2788 del_timer(&info->tx_timer);
2789 del_timer(&info->status_timer); 2789 del_timer(&info->status_timer);
2790 2790
2791 if (info->tx_buf) { 2791 kfree(info->tx_buf);
2792 kfree(info->tx_buf); 2792 info->tx_buf = NULL;
2793 info->tx_buf = NULL;
2794 }
2795 2793
2796 spin_lock_irqsave(&info->lock,flags); 2794 spin_lock_irqsave(&info->lock,flags);
2797 2795
@@ -3611,8 +3609,7 @@ int alloc_tmp_rx_buf(SLMP_INFO *info)
3611 3609
3612void free_tmp_rx_buf(SLMP_INFO *info) 3610void free_tmp_rx_buf(SLMP_INFO *info)
3613{ 3611{
3614 if (info->tmp_rx_buf) 3612 kfree(info->tmp_rx_buf);
3615 kfree(info->tmp_rx_buf);
3616 info->tmp_rx_buf = NULL; 3613 info->tmp_rx_buf = NULL;
3617} 3614}
3618 3615
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index 8d125c974a2d..680a8e331887 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -287,10 +287,6 @@ static int __init init_nsc(void)
287 int lo, hi; 287 int lo, hi;
288 int nscAddrBase = TPM_ADDR; 288 int nscAddrBase = TPM_ADDR;
289 289
290 driver_register(&nsc_drv);
291
292 /* select PM channel 1 */
293 tpm_write_index(nscAddrBase,NSC_LDN_INDEX, 0x12);
294 290
295 /* verify that it is a National part (SID) */ 291 /* verify that it is a National part (SID) */
296 if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) { 292 if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) {
@@ -300,6 +296,8 @@ static int __init init_nsc(void)
300 return -ENODEV; 296 return -ENODEV;
301 } 297 }
302 298
299 driver_register(&nsc_drv);
300
303 hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); 301 hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
304 lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); 302 lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);
305 tpm_nsc.base = (hi<<8) | lo; 303 tpm_nsc.base = (hi<<8) | lo;
@@ -307,11 +305,11 @@ static int __init init_nsc(void)
307 /* enable the DPM module */ 305 /* enable the DPM module */
308 tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); 306 tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01);
309 307
310 pdev = kmalloc(sizeof(struct platform_device), GFP_KERNEL); 308 pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
311 if ( !pdev ) 309 if (!pdev) {
312 return -ENOMEM; 310 rc = -ENOMEM;
313 311 goto err_unreg_drv;
314 memset(pdev, 0, sizeof(struct platform_device)); 312 }
315 313
316 pdev->name = "tpm_nscl0"; 314 pdev->name = "tpm_nscl0";
317 pdev->id = -1; 315 pdev->id = -1;
@@ -319,26 +317,16 @@ static int __init init_nsc(void)
319 pdev->dev.release = tpm_nsc_remove; 317 pdev->dev.release = tpm_nsc_remove;
320 pdev->dev.driver = &nsc_drv; 318 pdev->dev.driver = &nsc_drv;
321 319
322 if ((rc=platform_device_register(pdev)) < 0) { 320 if ((rc = platform_device_register(pdev)) < 0)
323 kfree(pdev); 321 goto err_free_dev;
324 pdev = NULL;
325 return rc;
326 }
327 322
328 if (request_region(tpm_nsc.base, 2, "tpm_nsc0") == NULL ) { 323 if (request_region(tpm_nsc.base, 2, "tpm_nsc0") == NULL ) {
329 platform_device_unregister(pdev); 324 rc = -EBUSY;
330 kfree(pdev); 325 goto err_unreg_dev;
331 pdev = NULL;
332 return -EBUSY;
333 } 326 }
334 327
335 if ((rc = tpm_register_hardware(&pdev->dev, &tpm_nsc)) < 0) { 328 if ((rc = tpm_register_hardware(&pdev->dev, &tpm_nsc)) < 0)
336 release_region(tpm_nsc.base, 2); 329 goto err_rel_reg;
337 platform_device_unregister(pdev);
338 kfree(pdev);
339 pdev = NULL;
340 return rc;
341 }
342 330
343 dev_dbg(&pdev->dev, "NSC TPM detected\n"); 331 dev_dbg(&pdev->dev, "NSC TPM detected\n");
344 dev_dbg(&pdev->dev, 332 dev_dbg(&pdev->dev,
@@ -374,6 +362,16 @@ static int __init init_nsc(void)
374 tpm_read_index(nscAddrBase, 0x27) & 0x1F); 362 tpm_read_index(nscAddrBase, 0x27) & 0x1F);
375 363
376 return 0; 364 return 0;
365
366err_rel_reg:
367 release_region(tpm_nsc.base, 2);
368err_unreg_dev:
369 platform_device_unregister(pdev);
370err_free_dev:
371 kfree(pdev);
372err_unreg_drv:
373 driver_unregister(&nsc_drv);
374 return rc;
377} 375}
378 376
379static void __exit cleanup_nsc(void) 377static void __exit cleanup_nsc(void)
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index c586bfa852ee..4b1eef51ec59 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1416,14 +1416,11 @@ end_init:
1416 1416
1417 /* Release locally allocated memory ... nothing placed in slots */ 1417 /* Release locally allocated memory ... nothing placed in slots */
1418free_mem_out: 1418free_mem_out:
1419 if (o_tp) 1419 kfree(o_tp);
1420 kfree(o_tp);
1421 if (o_tty) 1420 if (o_tty)
1422 free_tty_struct(o_tty); 1421 free_tty_struct(o_tty);
1423 if (ltp) 1422 kfree(ltp);
1424 kfree(ltp); 1423 kfree(tp);
1425 if (tp)
1426 kfree(tp);
1427 free_tty_struct(tty); 1424 free_tty_struct(tty);
1428 1425
1429fail_no_mem: 1426fail_no_mem:
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 003dda147cd0..24011e7c81ff 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -80,6 +80,9 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str
80 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry))) 80 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
81 return -EFAULT; 81 return -EFAULT;
82 82
83 if (!capable(CAP_SYS_TTY_CONFIG))
84 perm = 0;
85
83 switch (cmd) { 86 switch (cmd) {
84 case KDGKBENT: 87 case KDGKBENT:
85 key_map = key_maps[s]; 88 key_map = key_maps[s];
@@ -193,7 +196,7 @@ do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
193 int ret; 196 int ret;
194 197
195 if (!capable(CAP_SYS_TTY_CONFIG)) 198 if (!capable(CAP_SYS_TTY_CONFIG))
196 return -EPERM; 199 perm = 0;
197 200
198 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL); 201 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
199 if (!kbs) { 202 if (!kbs) {
diff --git a/drivers/connector/Kconfig b/drivers/connector/Kconfig
index 0bc2059c1e08..e0bdc0db9640 100644
--- a/drivers/connector/Kconfig
+++ b/drivers/connector/Kconfig
@@ -10,4 +10,12 @@ config CONNECTOR
10 Connector support can also be built as a module. If so, the module 10 Connector support can also be built as a module. If so, the module
11 will be called cn.ko. 11 will be called cn.ko.
12 12
13config PROC_EVENTS
14 boolean "Report process events to userspace"
15 depends on CONNECTOR=y
16 default y
17 ---help---
18 Provide a connector that reports process events to userspace. Send
19 events such as fork, exec, id change (uid, gid, suid, etc), and exit.
20
13endmenu 21endmenu
diff --git a/drivers/connector/Makefile b/drivers/connector/Makefile
index 12ca79e8234d..1f255e46e916 100644
--- a/drivers/connector/Makefile
+++ b/drivers/connector/Makefile
@@ -1,3 +1,4 @@
1obj-$(CONFIG_CONNECTOR) += cn.o 1obj-$(CONFIG_CONNECTOR) += cn.o
2obj-$(CONFIG_PROC_EVENTS) += cn_proc.o
2 3
3cn-y += cn_queue.o connector.o 4cn-y += cn_queue.o connector.o
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
new file mode 100644
index 000000000000..fcdf0fff13a6
--- /dev/null
+++ b/drivers/connector/cn_proc.c
@@ -0,0 +1,222 @@
1/*
2 * cn_proc.c - process events connector
3 *
4 * Copyright (C) Matt Helsley, IBM Corp. 2005
5 * Based on cn_fork.c by Guillaume Thouvenin <guillaume.thouvenin@bull.net>
6 * Original copyright notice follows:
7 * Copyright (C) 2005 BULL SA.
8 *
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/init.h>
28#include <asm/atomic.h>
29
30#include <linux/cn_proc.h>
31
32#define CN_PROC_MSG_SIZE (sizeof(struct cn_msg) + sizeof(struct proc_event))
33
34static atomic_t proc_event_num_listeners = ATOMIC_INIT(0);
35static struct cb_id cn_proc_event_id = { CN_IDX_PROC, CN_VAL_PROC };
36
37/* proc_counts is used as the sequence number of the netlink message */
38static DEFINE_PER_CPU(__u32, proc_event_counts) = { 0 };
39
40static inline void get_seq(__u32 *ts, int *cpu)
41{
42 *ts = get_cpu_var(proc_event_counts)++;
43 *cpu = smp_processor_id();
44 put_cpu_var(proc_counts);
45}
46
47void proc_fork_connector(struct task_struct *task)
48{
49 struct cn_msg *msg;
50 struct proc_event *ev;
51 __u8 buffer[CN_PROC_MSG_SIZE];
52
53 if (atomic_read(&proc_event_num_listeners) < 1)
54 return;
55
56 msg = (struct cn_msg*)buffer;
57 ev = (struct proc_event*)msg->data;
58 get_seq(&msg->seq, &ev->cpu);
59 ev->what = PROC_EVENT_FORK;
60 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.child_pid = task->pid;
63 ev->event_data.fork.child_tgid = task->tgid;
64
65 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
66 msg->ack = 0; /* not used */
67 msg->len = sizeof(*ev);
68 /* If cn_netlink_send() failed, the data is not sent */
69 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
70}
71
72void proc_exec_connector(struct task_struct *task)
73{
74 struct cn_msg *msg;
75 struct proc_event *ev;
76 __u8 buffer[CN_PROC_MSG_SIZE];
77
78 if (atomic_read(&proc_event_num_listeners) < 1)
79 return;
80
81 msg = (struct cn_msg*)buffer;
82 ev = (struct proc_event*)msg->data;
83 get_seq(&msg->seq, &ev->cpu);
84 ev->what = PROC_EVENT_EXEC;
85 ev->event_data.exec.process_pid = task->pid;
86 ev->event_data.exec.process_tgid = task->tgid;
87
88 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
89 msg->ack = 0; /* not used */
90 msg->len = sizeof(*ev);
91 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
92}
93
94void proc_id_connector(struct task_struct *task, int which_id)
95{
96 struct cn_msg *msg;
97 struct proc_event *ev;
98 __u8 buffer[CN_PROC_MSG_SIZE];
99
100 if (atomic_read(&proc_event_num_listeners) < 1)
101 return;
102
103 msg = (struct cn_msg*)buffer;
104 ev = (struct proc_event*)msg->data;
105 ev->what = which_id;
106 ev->event_data.id.process_pid = task->pid;
107 ev->event_data.id.process_tgid = task->tgid;
108 if (which_id == PROC_EVENT_UID) {
109 ev->event_data.id.r.ruid = task->uid;
110 ev->event_data.id.e.euid = task->euid;
111 } else if (which_id == PROC_EVENT_GID) {
112 ev->event_data.id.r.rgid = task->gid;
113 ev->event_data.id.e.egid = task->egid;
114 } else
115 return;
116 get_seq(&msg->seq, &ev->cpu);
117
118 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
119 msg->ack = 0; /* not used */
120 msg->len = sizeof(*ev);
121 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
122}
123
124void proc_exit_connector(struct task_struct *task)
125{
126 struct cn_msg *msg;
127 struct proc_event *ev;
128 __u8 buffer[CN_PROC_MSG_SIZE];
129
130 if (atomic_read(&proc_event_num_listeners) < 1)
131 return;
132
133 msg = (struct cn_msg*)buffer;
134 ev = (struct proc_event*)msg->data;
135 get_seq(&msg->seq, &ev->cpu);
136 ev->what = PROC_EVENT_EXIT;
137 ev->event_data.exit.process_pid = task->pid;
138 ev->event_data.exit.process_tgid = task->tgid;
139 ev->event_data.exit.exit_code = task->exit_code;
140 ev->event_data.exit.exit_signal = task->exit_signal;
141
142 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
143 msg->ack = 0; /* not used */
144 msg->len = sizeof(*ev);
145 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
146}
147
148/*
149 * Send an acknowledgement message to userspace
150 *
151 * Use 0 for success, EFOO otherwise.
152 * Note: this is the negative of conventional kernel error
153 * values because it's not being returned via syscall return
154 * mechanisms.
155 */
156static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
157{
158 struct cn_msg *msg;
159 struct proc_event *ev;
160 __u8 buffer[CN_PROC_MSG_SIZE];
161
162 if (atomic_read(&proc_event_num_listeners) < 1)
163 return;
164
165 msg = (struct cn_msg*)buffer;
166 ev = (struct proc_event*)msg->data;
167 msg->seq = rcvd_seq;
168 ev->cpu = -1;
169 ev->what = PROC_EVENT_NONE;
170 ev->event_data.ack.err = err;
171 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
172 msg->ack = rcvd_ack + 1;
173 msg->len = sizeof(*ev);
174 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
175}
176
177/**
178 * cn_proc_mcast_ctl
179 * @data: message sent from userspace via the connector
180 */
181static void cn_proc_mcast_ctl(void *data)
182{
183 struct cn_msg *msg = data;
184 enum proc_cn_mcast_op *mc_op = NULL;
185 int err = 0;
186
187 if (msg->len != sizeof(*mc_op))
188 return;
189
190 mc_op = (enum proc_cn_mcast_op*)msg->data;
191 switch (*mc_op) {
192 case PROC_CN_MCAST_LISTEN:
193 atomic_inc(&proc_event_num_listeners);
194 break;
195 case PROC_CN_MCAST_IGNORE:
196 atomic_dec(&proc_event_num_listeners);
197 break;
198 default:
199 err = EINVAL;
200 break;
201 }
202 cn_proc_ack(err, msg->seq, msg->ack);
203}
204
205/*
206 * cn_proc_init - initialization entry point
207 *
208 * Adds the connector callback to the connector driver.
209 */
210static int __init cn_proc_init(void)
211{
212 int err;
213
214 if ((err = cn_add_callback(&cn_proc_event_id, "cn_proc",
215 &cn_proc_mcast_ctl))) {
216 printk(KERN_WARNING "cn_proc failed to register\n");
217 return err;
218 }
219 return 0;
220}
221
222module_init(cn_proc_init);
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6c6121b85a54..25acf478c9e8 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -593,12 +593,11 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
593 goto module_out; 593 goto module_out;
594 } 594 }
595 595
596 policy = kmalloc(sizeof(struct cpufreq_policy), GFP_KERNEL); 596 policy = kzalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
597 if (!policy) { 597 if (!policy) {
598 ret = -ENOMEM; 598 ret = -ENOMEM;
599 goto nomem_out; 599 goto nomem_out;
600 } 600 }
601 memset(policy, 0, sizeof(struct cpufreq_policy));
602 601
603 policy->cpu = cpu; 602 policy->cpu = cpu;
604 policy->cpus = cpumask_of_cpu(cpu); 603 policy->cpus = cpumask_of_cpu(cpu);
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index c1fc9c62bb51..17741111246b 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -48,7 +48,10 @@
48 * All times here are in uS. 48 * All times here are in uS.
49 */ 49 */
50static unsigned int def_sampling_rate; 50static unsigned int def_sampling_rate;
51#define MIN_SAMPLING_RATE (def_sampling_rate / 2) 51#define MIN_SAMPLING_RATE_RATIO (2)
52/* for correct statistics, we need at least 10 ticks between each measure */
53#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
54#define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
52#define MAX_SAMPLING_RATE (500 * def_sampling_rate) 55#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
53#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 56#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
54#define DEF_SAMPLING_DOWN_FACTOR (1) 57#define DEF_SAMPLING_DOWN_FACTOR (1)
@@ -416,13 +419,16 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
416 if (dbs_enable == 1) { 419 if (dbs_enable == 1) {
417 unsigned int latency; 420 unsigned int latency;
418 /* policy latency is in nS. Convert it to uS first */ 421 /* policy latency is in nS. Convert it to uS first */
422 latency = policy->cpuinfo.transition_latency / 1000;
423 if (latency == 0)
424 latency = 1;
419 425
420 latency = policy->cpuinfo.transition_latency; 426 def_sampling_rate = latency *
421 if (latency < 1000)
422 latency = 1000;
423
424 def_sampling_rate = (latency / 1000) *
425 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; 427 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
428
429 if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
430 def_sampling_rate = MIN_STAT_SAMPLING_RATE;
431
426 dbs_tuners_ins.sampling_rate = def_sampling_rate; 432 dbs_tuners_ins.sampling_rate = def_sampling_rate;
427 dbs_tuners_ins.ignore_nice = 0; 433 dbs_tuners_ins.ignore_nice = 0;
428 434
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 3597f25d5efa..0bddb8e694d9 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -193,11 +193,15 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
193 unsigned int cpu = policy->cpu; 193 unsigned int cpu = policy->cpu;
194 if (cpufreq_stats_table[cpu]) 194 if (cpufreq_stats_table[cpu])
195 return -EBUSY; 195 return -EBUSY;
196 if ((stat = kmalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) 196 if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL)
197 return -ENOMEM; 197 return -ENOMEM;
198 memset(stat, 0, sizeof (struct cpufreq_stats));
199 198
200 data = cpufreq_cpu_get(cpu); 199 data = cpufreq_cpu_get(cpu);
200 if (data == NULL) {
201 ret = -EINVAL;
202 goto error_get_fail;
203 }
204
201 if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group))) 205 if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group)))
202 goto error_out; 206 goto error_out;
203 207
@@ -217,12 +221,11 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
217 alloc_size += count * count * sizeof(int); 221 alloc_size += count * count * sizeof(int);
218#endif 222#endif
219 stat->max_state = count; 223 stat->max_state = count;
220 stat->time_in_state = kmalloc(alloc_size, GFP_KERNEL); 224 stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
221 if (!stat->time_in_state) { 225 if (!stat->time_in_state) {
222 ret = -ENOMEM; 226 ret = -ENOMEM;
223 goto error_out; 227 goto error_out;
224 } 228 }
225 memset(stat->time_in_state, 0, alloc_size);
226 stat->freq_table = (unsigned int *)(stat->time_in_state + count); 229 stat->freq_table = (unsigned int *)(stat->time_in_state + count);
227 230
228#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 231#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
@@ -245,6 +248,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
245 return 0; 248 return 0;
246error_out: 249error_out:
247 cpufreq_cpu_put(data); 250 cpufreq_cpu_put(data);
251error_get_fail:
248 kfree(stat); 252 kfree(stat);
249 cpufreq_stats_table[cpu] = NULL; 253 cpufreq_stats_table[cpu] = NULL;
250 return ret; 254 return ret;
diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c
index a620f7d9ac8e..17502d6efae7 100644
--- a/drivers/dio/dio.c
+++ b/drivers/dio/dio.c
@@ -224,11 +224,10 @@ static int __init dio_init(void)
224 set_fs(fs); 224 set_fs(fs);
225 225
226 /* Found a board, allocate it an entry in the list */ 226 /* Found a board, allocate it an entry in the list */
227 dev = kmalloc(sizeof(struct dio_dev), GFP_KERNEL); 227 dev = kzalloc(sizeof(struct dio_dev), GFP_KERNEL);
228 if (!dev) 228 if (!dev)
229 return 0; 229 return 0;
230 230
231 memset(dev, 0, sizeof(struct dio_dev));
232 dev->bus = &dio_bus; 231 dev->bus = &dio_bus;
233 dev->dev.parent = &dio_bus.dev; 232 dev->dev.parent = &dio_bus.dev;
234 dev->dev.bus = &dio_bus_type; 233 dev->dev.bus = &dio_bus_type;
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index 1937743c8e29..4196137e66de 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -281,13 +281,11 @@ static int __init eisa_probe (struct eisa_root_device *root)
281 /* First try to get hold of slot 0. If there is no device 281 /* First try to get hold of slot 0. If there is no device
282 * here, simply fail, unless root->force_probe is set. */ 282 * here, simply fail, unless root->force_probe is set. */
283 283
284 if (!(edev = kmalloc (sizeof (*edev), GFP_KERNEL))) { 284 if (!(edev = kzalloc (sizeof (*edev), GFP_KERNEL))) {
285 printk (KERN_ERR "EISA: Couldn't allocate mainboard slot\n"); 285 printk (KERN_ERR "EISA: Couldn't allocate mainboard slot\n");
286 return -ENOMEM; 286 return -ENOMEM;
287 } 287 }
288 288
289 memset (edev, 0, sizeof (*edev));
290
291 if (eisa_request_resources (root, edev, 0)) { 289 if (eisa_request_resources (root, edev, 0)) {
292 printk (KERN_WARNING \ 290 printk (KERN_WARNING \
293 "EISA: Cannot allocate resource for mainboard\n"); 291 "EISA: Cannot allocate resource for mainboard\n");
@@ -317,13 +315,11 @@ static int __init eisa_probe (struct eisa_root_device *root)
317 force_probe: 315 force_probe:
318 316
319 for (c = 0, i = 1; i <= root->slots; i++) { 317 for (c = 0, i = 1; i <= root->slots; i++) {
320 if (!(edev = kmalloc (sizeof (*edev), GFP_KERNEL))) { 318 if (!(edev = kzalloc (sizeof (*edev), GFP_KERNEL))) {
321 printk (KERN_ERR "EISA: Out of memory for slot %d\n", 319 printk (KERN_ERR "EISA: Out of memory for slot %d\n",
322 i); 320 i);
323 continue; 321 continue;
324 } 322 }
325
326 memset (edev, 0, sizeof (*edev));
327 323
328 if (eisa_request_resources (root, edev, i)) { 324 if (eisa_request_resources (root, edev, i)) {
329 printk (KERN_WARNING \ 325 printk (KERN_WARNING \
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c
index e4710d1d1f9d..5c8943509cc1 100644
--- a/drivers/fc4/fc.c
+++ b/drivers/fc4/fc.c
@@ -266,13 +266,12 @@ static void fcp_report_map_done(fc_channel *fc, int i, int status)
266 printk ("FC: Bad magic from REPORT_AL_MAP on %s - %08x\n", fc->name, p->magic); 266 printk ("FC: Bad magic from REPORT_AL_MAP on %s - %08x\n", fc->name, p->magic);
267 fc->state = FC_STATE_OFFLINE; 267 fc->state = FC_STATE_OFFLINE;
268 } else { 268 } else {
269 fc->posmap = (fcp_posmap *)kmalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL); 269 fc->posmap = (fcp_posmap *)kzalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL);
270 if (!fc->posmap) { 270 if (!fc->posmap) {
271 printk("FC: Not enough memory, offlining channel\n"); 271 printk("FC: Not enough memory, offlining channel\n");
272 fc->state = FC_STATE_OFFLINE; 272 fc->state = FC_STATE_OFFLINE;
273 } else { 273 } else {
274 int k; 274 int k;
275 memset(fc->posmap, 0, sizeof(fcp_posmap)+p->len);
276 /* FIXME: This is where SOCAL transfers our AL-PA. 275 /* FIXME: This is where SOCAL transfers our AL-PA.
277 Keep it here till we found out what other cards do... */ 276 Keep it here till we found out what other cards do... */
278 fc->sid = (p->magic & 0xff); 277 fc->sid = (p->magic & 0xff);
@@ -351,14 +350,12 @@ void fcp_register(fc_channel *fc, u8 type, int unregister)
351 fc->dma_scsi_rsp = fc->dma_scsi_cmd + slots * sizeof (fcp_cmd); 350 fc->dma_scsi_rsp = fc->dma_scsi_cmd + slots * sizeof (fcp_cmd);
352 fc->scsi_bitmap_end = (slots + 63) & ~63; 351 fc->scsi_bitmap_end = (slots + 63) & ~63;
353 size = fc->scsi_bitmap_end / 8; 352 size = fc->scsi_bitmap_end / 8;
354 fc->scsi_bitmap = kmalloc (size, GFP_KERNEL); 353 fc->scsi_bitmap = kzalloc (size, GFP_KERNEL);
355 memset (fc->scsi_bitmap, 0, size);
356 set_bit (0, fc->scsi_bitmap); 354 set_bit (0, fc->scsi_bitmap);
357 for (i = fc->can_queue; i < fc->scsi_bitmap_end; i++) 355 for (i = fc->can_queue; i < fc->scsi_bitmap_end; i++)
358 set_bit (i, fc->scsi_bitmap); 356 set_bit (i, fc->scsi_bitmap);
359 fc->scsi_free = fc->can_queue; 357 fc->scsi_free = fc->can_queue;
360 fc->cmd_slots = (fcp_cmnd **)kmalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL); 358 fc->cmd_slots = (fcp_cmnd **)kzalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL);
361 memset(fc->cmd_slots, 0, slots * sizeof(fcp_cmnd*));
362 fc->abort_count = 0; 359 fc->abort_count = 0;
363 } else { 360 } else {
364 fc->scsi_name[0] = 0; 361 fc->scsi_name[0] = 0;
@@ -541,12 +538,11 @@ int fcp_initialize(fc_channel *fcchain, int count)
541 FCND(("fcp_inititialize %08lx\n", (long)fcp_init)) 538 FCND(("fcp_inititialize %08lx\n", (long)fcp_init))
542 FCND(("fc_channels %08lx\n", (long)fc_channels)) 539 FCND(("fc_channels %08lx\n", (long)fc_channels))
543 FCND((" SID %d DID %d\n", fcchain->sid, fcchain->did)) 540 FCND((" SID %d DID %d\n", fcchain->sid, fcchain->did))
544 l = kmalloc(sizeof (ls) + count, GFP_KERNEL); 541 l = kzalloc(sizeof (ls) + count, GFP_KERNEL);
545 if (!l) { 542 if (!l) {
546 printk ("FC: Cannot allocate memory for initialization\n"); 543 printk ("FC: Cannot allocate memory for initialization\n");
547 return -ENOMEM; 544 return -ENOMEM;
548 } 545 }
549 memset (l, 0, sizeof(ls) + count);
550 l->magic = LSMAGIC; 546 l->magic = LSMAGIC;
551 l->count = count; 547 l->count = count;
552 FCND(("FCP Init for %d channels\n", count)) 548 FCND(("FCP Init for %d channels\n", count))
@@ -555,17 +551,15 @@ int fcp_initialize(fc_channel *fcchain, int count)
555 l->timer.function = fcp_login_timeout; 551 l->timer.function = fcp_login_timeout;
556 l->timer.data = (unsigned long)l; 552 l->timer.data = (unsigned long)l;
557 atomic_set (&l->todo, count); 553 atomic_set (&l->todo, count);
558 l->logi = kmalloc (count * 3 * sizeof(logi), GFP_KERNEL); 554 l->logi = kzalloc (count * 3 * sizeof(logi), GFP_KERNEL);
559 l->fcmds = kmalloc (count * sizeof(fcp_cmnd), GFP_KERNEL); 555 l->fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL);
560 if (!l->logi || !l->fcmds) { 556 if (!l->logi || !l->fcmds) {
561 if (l->logi) kfree (l->logi); 557 kfree (l->logi);
562 if (l->fcmds) kfree (l->fcmds); 558 kfree (l->fcmds);
563 kfree (l); 559 kfree (l);
564 printk ("FC: Cannot allocate DMA memory for initialization\n"); 560 printk ("FC: Cannot allocate DMA memory for initialization\n");
565 return -ENOMEM; 561 return -ENOMEM;
566 } 562 }
567 memset (l->logi, 0, count * 3 * sizeof(logi));
568 memset (l->fcmds, 0, count * sizeof(fcp_cmnd));
569 for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) { 563 for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) {
570 fc->state = FC_STATE_UNINITED; 564 fc->state = FC_STATE_UNINITED;
571 fc->rst_pkt = NULL; /* kmalloc when first used */ 565 fc->rst_pkt = NULL; /* kmalloc when first used */
@@ -678,13 +672,11 @@ int fcp_forceoffline(fc_channel *fcchain, int count)
678 l.timer.function = fcp_login_timeout; 672 l.timer.function = fcp_login_timeout;
679 l.timer.data = (unsigned long)&l; 673 l.timer.data = (unsigned long)&l;
680 atomic_set (&l.todo, count); 674 atomic_set (&l.todo, count);
681 l.fcmds = kmalloc (count * sizeof(fcp_cmnd), GFP_KERNEL); 675 l.fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL);
682 if (!l.fcmds) { 676 if (!l.fcmds) {
683 kfree (l.fcmds);
684 printk ("FC: Cannot allocate memory for forcing offline\n"); 677 printk ("FC: Cannot allocate memory for forcing offline\n");
685 return -ENOMEM; 678 return -ENOMEM;
686 } 679 }
687 memset (l.fcmds, 0, count * sizeof(fcp_cmnd));
688 FCND(("Initializing OFFLINE packets\n")) 680 FCND(("Initializing OFFLINE packets\n"))
689 for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) { 681 for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) {
690 fc->state = FC_STATE_UNINITED; 682 fc->state = FC_STATE_UNINITED;
@@ -1114,9 +1106,8 @@ int fc_do_plogi(fc_channel *fc, unsigned char alpa, fc_wwn *node, fc_wwn *nport)
1114 logi *l; 1106 logi *l;
1115 int status; 1107 int status;
1116 1108
1117 l = (logi *)kmalloc(2 * sizeof(logi), GFP_KERNEL); 1109 l = (logi *)kzalloc(2 * sizeof(logi), GFP_KERNEL);
1118 if (!l) return -ENOMEM; 1110 if (!l) return -ENOMEM;
1119 memset(l, 0, 2 * sizeof(logi));
1120 l->code = LS_PLOGI; 1111 l->code = LS_PLOGI;
1121 memcpy (&l->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn)); 1112 memcpy (&l->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn));
1122 memcpy (&l->node_wwn, &fc->wwn_node, sizeof(fc_wwn)); 1113 memcpy (&l->node_wwn, &fc->wwn_node, sizeof(fc_wwn));
@@ -1149,9 +1140,8 @@ int fc_do_prli(fc_channel *fc, unsigned char alpa)
1149 prli *p; 1140 prli *p;
1150 int status; 1141 int status;
1151 1142
1152 p = (prli *)kmalloc(2 * sizeof(prli), GFP_KERNEL); 1143 p = (prli *)kzalloc(2 * sizeof(prli), GFP_KERNEL);
1153 if (!p) return -ENOMEM; 1144 if (!p) return -ENOMEM;
1154 memset(p, 0, 2 * sizeof(prli));
1155 p->code = LS_PRLI; 1145 p->code = LS_PRLI;
1156 p->params[0] = 0x08002000; 1146 p->params[0] = 0x08002000;
1157 p->params[3] = 0x00000022; 1147 p->params[3] = 0x00000022;
diff --git a/drivers/fc4/soc.c b/drivers/fc4/soc.c
index 247b46302777..ec1f94738c59 100644
--- a/drivers/fc4/soc.c
+++ b/drivers/fc4/soc.c
@@ -556,10 +556,9 @@ static inline void soc_init(struct sbus_dev *sdev, int no)
556 int size, i; 556 int size, i;
557 int irq; 557 int irq;
558 558
559 s = kmalloc (sizeof (struct soc), GFP_KERNEL); 559 s = kzalloc (sizeof (struct soc), GFP_KERNEL);
560 if (s == NULL) 560 if (s == NULL)
561 return; 561 return;
562 memset (s, 0, sizeof(struct soc));
563 spin_lock_init(&s->lock); 562 spin_lock_init(&s->lock);
564 s->soc_no = no; 563 s->soc_no = no;
565 564
diff --git a/drivers/fc4/socal.c b/drivers/fc4/socal.c
index b2377dbd84a1..922e9613b2cf 100644
--- a/drivers/fc4/socal.c
+++ b/drivers/fc4/socal.c
@@ -665,9 +665,8 @@ static inline void socal_init(struct sbus_dev *sdev, int no)
665 int size, i; 665 int size, i;
666 int irq, node; 666 int irq, node;
667 667
668 s = kmalloc (sizeof (struct socal), GFP_KERNEL); 668 s = kzalloc (sizeof (struct socal), GFP_KERNEL);
669 if (!s) return; 669 if (!s) return;
670 memset (s, 0, sizeof(struct socal));
671 spin_lock_init(&s->lock); 670 spin_lock_init(&s->lock);
672 s->socal_no = no; 671 s->socal_no = no;
673 672
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 125929c9048f..ba17292eb290 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -50,7 +50,7 @@
50MODULE_AUTHOR("Abhay Salunke <abhay_salunke@dell.com>"); 50MODULE_AUTHOR("Abhay Salunke <abhay_salunke@dell.com>");
51MODULE_DESCRIPTION("Driver for updating BIOS image on DELL systems"); 51MODULE_DESCRIPTION("Driver for updating BIOS image on DELL systems");
52MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
53MODULE_VERSION("3.0"); 53MODULE_VERSION("3.1");
54 54
55#define BIOS_SCAN_LIMIT 0xffffffff 55#define BIOS_SCAN_LIMIT 0xffffffff
56#define MAX_IMAGE_LENGTH 16 56#define MAX_IMAGE_LENGTH 16
@@ -73,6 +73,11 @@ module_param_string(image_type, image_type, sizeof (image_type), 0);
73MODULE_PARM_DESC(image_type, 73MODULE_PARM_DESC(image_type,
74 "BIOS image type. choose- mono or packet or init"); 74 "BIOS image type. choose- mono or packet or init");
75 75
76static unsigned long allocation_floor = 0x100000;
77module_param(allocation_floor, ulong, 0644);
78MODULE_PARM_DESC(allocation_floor,
79 "Minimum address for allocations when using Packet mode");
80
76struct packet_data { 81struct packet_data {
77 struct list_head list; 82 struct list_head list;
78 size_t length; 83 size_t length;
@@ -99,61 +104,122 @@ static int create_packet(void *data, size_t length)
99{ 104{
100 struct packet_data *newpacket; 105 struct packet_data *newpacket;
101 int ordernum = 0; 106 int ordernum = 0;
107 int retval = 0;
108 unsigned int packet_array_size = 0;
109 void **invalid_addr_packet_array = 0;
110 void *packet_data_temp_buf = 0;
111 unsigned int idx = 0;
102 112
103 pr_debug("create_packet: entry \n"); 113 pr_debug("create_packet: entry \n");
104 114
105 if (!rbu_data.packetsize) { 115 if (!rbu_data.packetsize) {
106 pr_debug("create_packet: packetsize not specified\n"); 116 pr_debug("create_packet: packetsize not specified\n");
107 return -EINVAL; 117 retval = -EINVAL;
118 goto out_noalloc;
108 } 119 }
120
109 spin_unlock(&rbu_data.lock); 121 spin_unlock(&rbu_data.lock);
110 newpacket = kmalloc(sizeof (struct packet_data), GFP_KERNEL); 122
111 spin_lock(&rbu_data.lock); 123 newpacket = kzalloc(sizeof (struct packet_data), GFP_KERNEL);
112 124
113 if (!newpacket) { 125 if (!newpacket) {
114 printk(KERN_WARNING 126 printk(KERN_WARNING
115 "dell_rbu:%s: failed to allocate new " 127 "dell_rbu:%s: failed to allocate new "
116 "packet\n", __FUNCTION__); 128 "packet\n", __FUNCTION__);
117 return -ENOMEM; 129 retval = -ENOMEM;
130 spin_lock(&rbu_data.lock);
131 goto out_noalloc;
118 } 132 }
119 133
120 ordernum = get_order(length); 134 ordernum = get_order(length);
135
121 /* 136 /*
122 * there is no upper limit on memory 137 * BIOS errata mean we cannot allocate packets below 1MB or they will
123 * address for packetized mechanism 138 * be overwritten by BIOS.
139 *
140 * array to temporarily hold packets
141 * that are below the allocation floor
142 *
143 * NOTE: very simplistic because we only need the floor to be at 1MB
144 * due to BIOS errata. This shouldn't be used for higher floors
145 * or you will run out of mem trying to allocate the array.
124 */ 146 */
125 spin_unlock(&rbu_data.lock); 147 packet_array_size = max(
126 newpacket->data = (unsigned char *) __get_free_pages(GFP_KERNEL, 148 (unsigned int)(allocation_floor / rbu_data.packetsize),
127 ordernum); 149 (unsigned int)1);
128 spin_lock(&rbu_data.lock); 150 invalid_addr_packet_array = kzalloc(packet_array_size * sizeof(void*),
151 GFP_KERNEL);
129 152
130 pr_debug("create_packet: newpacket %p\n", newpacket->data); 153 if (!invalid_addr_packet_array) {
131
132 if (!newpacket->data) {
133 printk(KERN_WARNING 154 printk(KERN_WARNING
134 "dell_rbu:%s: failed to allocate new " 155 "dell_rbu:%s: failed to allocate "
135 "packet\n", __FUNCTION__); 156 "invalid_addr_packet_array \n",
136 kfree(newpacket); 157 __FUNCTION__);
137 return -ENOMEM; 158 retval = -ENOMEM;
159 spin_lock(&rbu_data.lock);
160 goto out_alloc_packet;
138 } 161 }
139 162
163 while (!packet_data_temp_buf) {
164 packet_data_temp_buf = (unsigned char *)
165 __get_free_pages(GFP_KERNEL, ordernum);
166 if (!packet_data_temp_buf) {
167 printk(KERN_WARNING
168 "dell_rbu:%s: failed to allocate new "
169 "packet\n", __FUNCTION__);
170 retval = -ENOMEM;
171 spin_lock(&rbu_data.lock);
172 goto out_alloc_packet_array;
173 }
174
175 if ((unsigned long)virt_to_phys(packet_data_temp_buf)
176 < allocation_floor) {
177 pr_debug("packet 0x%lx below floor at 0x%lx.\n",
178 (unsigned long)virt_to_phys(
179 packet_data_temp_buf),
180 allocation_floor);
181 invalid_addr_packet_array[idx++] = packet_data_temp_buf;
182 packet_data_temp_buf = 0;
183 }
184 }
185 spin_lock(&rbu_data.lock);
186
187 newpacket->data = packet_data_temp_buf;
188
189 pr_debug("create_packet: newpacket at physical addr %lx\n",
190 (unsigned long)virt_to_phys(newpacket->data));
191
192 /* packets may not have fixed size */
193 newpacket->length = length;
140 newpacket->ordernum = ordernum; 194 newpacket->ordernum = ordernum;
141 ++rbu_data.num_packets; 195 ++rbu_data.num_packets;
142 /* 196
143 * initialize the newly created packet headers 197 /* initialize the newly created packet headers */
144 */
145 INIT_LIST_HEAD(&newpacket->list); 198 INIT_LIST_HEAD(&newpacket->list);
146 list_add_tail(&newpacket->list, &packet_data_head.list); 199 list_add_tail(&newpacket->list, &packet_data_head.list);
147 /*
148 * packets may not have fixed size
149 */
150 newpacket->length = length;
151 200
152 memcpy(newpacket->data, data, length); 201 memcpy(newpacket->data, data, length);
153 202
154 pr_debug("create_packet: exit \n"); 203 pr_debug("create_packet: exit \n");
155 204
156 return 0; 205out_alloc_packet_array:
206 /* always free packet array */
207 for (;idx>0;idx--) {
208 pr_debug("freeing unused packet below floor 0x%lx.\n",
209 (unsigned long)virt_to_phys(
210 invalid_addr_packet_array[idx-1]));
211 free_pages((unsigned long)invalid_addr_packet_array[idx-1],
212 ordernum);
213 }
214 kfree(invalid_addr_packet_array);
215
216out_alloc_packet:
217 /* if error, free data */
218 if (retval)
219 kfree(newpacket);
220
221out_noalloc:
222 return retval;
157} 223}
158 224
159static int packetize_data(void *data, size_t length) 225static int packetize_data(void *data, size_t length)
@@ -693,3 +759,6 @@ static __exit void dcdrbu_exit(void)
693 759
694module_exit(dcdrbu_exit); 760module_exit(dcdrbu_exit);
695module_init(dcdrbu_init); 761module_init(dcdrbu_init);
762
763/* vim:noet:ts=8:sw=8
764*/
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 6996476669f1..b4502ed65793 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -715,7 +715,6 @@ edd_device_register(struct edd_device *edev, int i)
715 715
716 if (!edev) 716 if (!edev)
717 return 1; 717 return 1;
718 memset(edev, 0, sizeof (*edev));
719 edd_dev_set_info(edev, i); 718 edd_dev_set_info(edev, i);
720 kobject_set_name(&edev->kobj, "int13_dev%02x", 719 kobject_set_name(&edev->kobj, "int13_dev%02x",
721 0x80 + i); 720 0x80 + i);
@@ -756,7 +755,7 @@ edd_init(void)
756 return rc; 755 return rc;
757 756
758 for (i = 0; i < edd_num_devices() && !rc; i++) { 757 for (i = 0; i < edd_num_devices() && !rc; i++) {
759 edev = kmalloc(sizeof (*edev), GFP_KERNEL); 758 edev = kzalloc(sizeof (*edev), GFP_KERNEL);
760 if (!edev) 759 if (!edev)
761 return -ENOMEM; 760 return -ENOMEM;
762 761
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 33b17c6a46fb..bda5bce681b6 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -614,16 +614,14 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
614 char *short_name; 614 char *short_name;
615 struct efivar_entry *new_efivar; 615 struct efivar_entry *new_efivar;
616 616
617 short_name = kmalloc(short_name_size + 1, GFP_KERNEL); 617 short_name = kzalloc(short_name_size + 1, GFP_KERNEL);
618 new_efivar = kmalloc(sizeof(struct efivar_entry), GFP_KERNEL); 618 new_efivar = kzalloc(sizeof(struct efivar_entry), GFP_KERNEL);
619 619
620 if (!short_name || !new_efivar) { 620 if (!short_name || !new_efivar) {
621 kfree(short_name); 621 kfree(short_name);
622 kfree(new_efivar); 622 kfree(new_efivar);
623 return 1; 623 return 1;
624 } 624 }
625 memset(short_name, 0, short_name_size+1);
626 memset(new_efivar, 0, sizeof(struct efivar_entry));
627 625
628 memcpy(new_efivar->var.VariableName, variable_name, 626 memcpy(new_efivar->var.VariableName, variable_name,
629 variable_name_size); 627 variable_name_size);
@@ -674,14 +672,12 @@ efivars_init(void)
674 if (!efi_enabled) 672 if (!efi_enabled)
675 return -ENODEV; 673 return -ENODEV;
676 674
677 variable_name = kmalloc(variable_name_size, GFP_KERNEL); 675 variable_name = kzalloc(variable_name_size, GFP_KERNEL);
678 if (!variable_name) { 676 if (!variable_name) {
679 printk(KERN_ERR "efivars: Memory allocation failed.\n"); 677 printk(KERN_ERR "efivars: Memory allocation failed.\n");
680 return -ENOMEM; 678 return -ENOMEM;
681 } 679 }
682 680
683 memset(variable_name, 0, variable_name_size);
684
685 printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION, 681 printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION,
686 EFIVARS_DATE); 682 EFIVARS_DATE);
687 683
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 6f48579799b5..dddd3eb9b387 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -16,6 +16,7 @@
16#include <linux/kdev_t.h> 16#include <linux/kdev_t.h>
17#include <linux/idr.h> 17#include <linux/idr.h>
18#include <linux/hwmon.h> 18#include <linux/hwmon.h>
19#include <linux/gfp.h>
19 20
20#define HWMON_ID_PREFIX "hwmon" 21#define HWMON_ID_PREFIX "hwmon"
21#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" 22#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d"
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 6a82ffae1bfd..69e7e125683b 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -193,7 +193,7 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
193 int err = 0; 193 int err = 0;
194 const char *name = ""; 194 const char *name = "";
195 u8 reg_config=0, reg_convrate=0, reg_status=0; 195 u8 reg_config=0, reg_convrate=0, reg_status=0;
196 u8 man_id, chip_id; 196
197 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 197 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
198 goto exit; 198 goto exit;
199 199
@@ -238,16 +238,15 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
238 } 238 }
239 239
240 if (kind <= 0) { /* identification */ 240 if (kind <= 0) { /* identification */
241 u8 man_id, chip_id;
241 242
242 man_id = i2c_smbus_read_byte_data(new_client, 243 man_id = i2c_smbus_read_byte_data(new_client,
243 MAX1619_REG_R_MAN_ID); 244 MAX1619_REG_R_MAN_ID);
244 chip_id = i2c_smbus_read_byte_data(new_client, 245 chip_id = i2c_smbus_read_byte_data(new_client,
245 MAX1619_REG_R_CHIP_ID); 246 MAX1619_REG_R_CHIP_ID);
246 247
247 if ((man_id == 0x4D) && (chip_id == 0x04)){ 248 if ((man_id == 0x4D) && (chip_id == 0x04))
248 kind = max1619; 249 kind = max1619;
249 }
250 }
251 250
252 if (kind <= 0) { /* identification failed */ 251 if (kind <= 0) { /* identification failed */
253 dev_info(&adapter->dev, 252 dev_info(&adapter->dev,
@@ -255,11 +254,10 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
255 "chip_id=0x%02X).\n", man_id, chip_id); 254 "chip_id=0x%02X).\n", man_id, chip_id);
256 goto exit_free; 255 goto exit_free;
257 } 256 }
258 257 }
259 258
260 if (kind == max1619){ 259 if (kind == max1619)
261 name = "max1619"; 260 name = "max1619";
262 }
263 261
264 /* We can fill in the remaining client fields */ 262 /* We can fill in the remaining client fields */
265 strlcpy(new_client->name, name, I2C_NAME_SIZE); 263 strlcpy(new_client->name, name, I2C_NAME_SIZE);
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 9265f32122fa..ffdb3a03e2b5 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -976,11 +976,9 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind,
976ERROR_SC_3: 976ERROR_SC_3:
977 i2c_detach_client(data->lm75[0]); 977 i2c_detach_client(data->lm75[0]);
978ERROR_SC_2: 978ERROR_SC_2:
979 if (data->lm75[1]) 979 kfree(data->lm75[1]);
980 kfree(data->lm75[1]);
981ERROR_SC_1: 980ERROR_SC_1:
982 if (data->lm75[0]) 981 kfree(data->lm75[0]);
983 kfree(data->lm75[0]);
984ERROR_SC_0: 982ERROR_SC_0:
985 return err; 983 return err;
986} 984}
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index f51ab652300a..56c7d987590f 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -245,10 +245,8 @@ static void __exit amd756_s4882_exit(void)
245 kfree(s4882_adapter); 245 kfree(s4882_adapter);
246 s4882_adapter = NULL; 246 s4882_adapter = NULL;
247 } 247 }
248 if (s4882_algo) { 248 kfree(s4882_algo);
249 kfree(s4882_algo); 249 s4882_algo = NULL;
250 s4882_algo = NULL;
251 }
252 250
253 /* Restore physical bus */ 251 /* Restore physical bus */
254 if (i2c_add_adapter(&amd756_smbus)) 252 if (i2c_add_adapter(&amd756_smbus))
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 8b9d85526596..c2f47923d174 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -3292,12 +3292,9 @@ static void ide_cd_release(struct kref *kref)
3292 ide_drive_t *drive = info->drive; 3292 ide_drive_t *drive = info->drive;
3293 struct gendisk *g = info->disk; 3293 struct gendisk *g = info->disk;
3294 3294
3295 if (info->buffer != NULL) 3295 kfree(info->buffer);
3296 kfree(info->buffer); 3296 kfree(info->toc);
3297 if (info->toc != NULL) 3297 kfree(info->changer_info);
3298 kfree(info->toc);
3299 if (info->changer_info != NULL)
3300 kfree(info->changer_info);
3301 if (devinfo->handle == drive && unregister_cdrom(devinfo)) 3298 if (devinfo->handle == drive && unregister_cdrom(devinfo))
3302 printk(KERN_ERR "%s: %s failed to unregister device from the cdrom " 3299 printk(KERN_ERR "%s: %s failed to unregister device from the cdrom "
3303 "driver.\n", __FUNCTION__, drive->name); 3300 "driver.\n", __FUNCTION__, drive->name);
@@ -3455,7 +3452,7 @@ static int ide_cd_probe(struct device *dev)
3455 printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); 3452 printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
3456 goto failed; 3453 goto failed;
3457 } 3454 }
3458 info = kmalloc(sizeof(struct cdrom_info), GFP_KERNEL); 3455 info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL);
3459 if (info == NULL) { 3456 if (info == NULL) {
3460 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); 3457 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
3461 goto failed; 3458 goto failed;
@@ -3469,8 +3466,6 @@ static int ide_cd_probe(struct device *dev)
3469 3466
3470 ide_register_subdriver(drive, &ide_cdrom_driver); 3467 ide_register_subdriver(drive, &ide_cdrom_driver);
3471 3468
3472 memset(info, 0, sizeof (struct cdrom_info));
3473
3474 kref_init(&info->kref); 3469 kref_init(&info->kref);
3475 3470
3476 info->drive = drive; 3471 info->drive = drive;
@@ -3489,12 +3484,9 @@ static int ide_cd_probe(struct device *dev)
3489 if (ide_cdrom_setup(drive)) { 3484 if (ide_cdrom_setup(drive)) {
3490 struct cdrom_device_info *devinfo = &info->devinfo; 3485 struct cdrom_device_info *devinfo = &info->devinfo;
3491 ide_unregister_subdriver(drive, &ide_cdrom_driver); 3486 ide_unregister_subdriver(drive, &ide_cdrom_driver);
3492 if (info->buffer != NULL) 3487 kfree(info->buffer);
3493 kfree(info->buffer); 3488 kfree(info->toc);
3494 if (info->toc != NULL) 3489 kfree(info->changer_info);
3495 kfree(info->toc);
3496 if (info->changer_info != NULL)
3497 kfree(info->changer_info);
3498 if (devinfo->handle == drive && unregister_cdrom(devinfo)) 3490 if (devinfo->handle == drive && unregister_cdrom(devinfo))
3499 printk (KERN_ERR "%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name); 3491 printk (KERN_ERR "%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name);
3500 kfree(info); 3492 kfree(info);
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 234f5de3e929..e827b39e4b3c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1215,7 +1215,7 @@ static int ide_disk_probe(struct device *dev)
1215 if (drive->media != ide_disk) 1215 if (drive->media != ide_disk)
1216 goto failed; 1216 goto failed;
1217 1217
1218 idkp = kmalloc(sizeof(*idkp), GFP_KERNEL); 1218 idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
1219 if (!idkp) 1219 if (!idkp)
1220 goto failed; 1220 goto failed;
1221 1221
@@ -1228,8 +1228,6 @@ static int ide_disk_probe(struct device *dev)
1228 1228
1229 ide_register_subdriver(drive, &idedisk_driver); 1229 ide_register_subdriver(drive, &idedisk_driver);
1230 1230
1231 memset(idkp, 0, sizeof(*idkp));
1232
1233 kref_init(&idkp->kref); 1231 kref_init(&idkp->kref);
1234 1232
1235 idkp->drive = drive; 1233 idkp->drive = drive;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 29c22fc278c6..e83f54d37f96 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -2146,7 +2146,7 @@ static int ide_floppy_probe(struct device *dev)
2146 printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); 2146 printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
2147 goto failed; 2147 goto failed;
2148 } 2148 }
2149 if ((floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { 2149 if ((floppy = (idefloppy_floppy_t *) kzalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
2150 printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); 2150 printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
2151 goto failed; 2151 goto failed;
2152 } 2152 }
@@ -2159,8 +2159,6 @@ static int ide_floppy_probe(struct device *dev)
2159 2159
2160 ide_register_subdriver(drive, &idefloppy_driver); 2160 ide_register_subdriver(drive, &idefloppy_driver);
2161 2161
2162 memset(floppy, 0, sizeof(*floppy));
2163
2164 kref_init(&floppy->kref); 2162 kref_init(&floppy->kref);
2165 2163
2166 floppy->drive = drive; 2164 floppy->drive = drive;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index c1128ae5cd2f..02167a5b751d 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -596,14 +596,13 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
596 * Also note that 0 everywhere means "can't do X" 596 * Also note that 0 everywhere means "can't do X"
597 */ 597 */
598 598
599 drive->id = kmalloc(SECTOR_WORDS *4, GFP_KERNEL); 599 drive->id = kzalloc(SECTOR_WORDS *4, GFP_KERNEL);
600 drive->id_read = 0; 600 drive->id_read = 0;
601 if(drive->id == NULL) 601 if(drive->id == NULL)
602 { 602 {
603 printk(KERN_ERR "ide: out of memory for id data.\n"); 603 printk(KERN_ERR "ide: out of memory for id data.\n");
604 return 0; 604 return 0;
605 } 605 }
606 memset(drive->id, 0, SECTOR_WORDS * 4);
607 strcpy(drive->id->model, "UNKNOWN"); 606 strcpy(drive->id->model, "UNKNOWN");
608 607
609 /* skip probing? */ 608 /* skip probing? */
@@ -1316,10 +1315,8 @@ static void drive_release_dev (struct device *dev)
1316 drive->devfs_name[0] = '\0'; 1315 drive->devfs_name[0] = '\0';
1317 } 1316 }
1318 ide_remove_drive_from_hwgroup(drive); 1317 ide_remove_drive_from_hwgroup(drive);
1319 if (drive->id != NULL) { 1318 kfree(drive->id);
1320 kfree(drive->id); 1319 drive->id = NULL;
1321 drive->id = NULL;
1322 }
1323 drive->present = 0; 1320 drive->present = 0;
1324 /* Messed up locking ... */ 1321 /* Messed up locking ... */
1325 spin_unlock_irq(&ide_lock); 1322 spin_unlock_irq(&ide_lock);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 47f2b832555f..0ac7eb8f40d5 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4850,7 +4850,7 @@ static int ide_tape_probe(struct device *dev)
4850 printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name); 4850 printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name);
4851 printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n"); 4851 printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n");
4852 } 4852 }
4853 tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL); 4853 tape = (idetape_tape_t *) kzalloc (sizeof (idetape_tape_t), GFP_KERNEL);
4854 if (tape == NULL) { 4854 if (tape == NULL) {
4855 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); 4855 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
4856 goto failed; 4856 goto failed;
@@ -4864,8 +4864,6 @@ static int ide_tape_probe(struct device *dev)
4864 4864
4865 ide_register_subdriver(drive, &idetape_driver); 4865 ide_register_subdriver(drive, &idetape_driver);
4866 4866
4867 memset(tape, 0, sizeof(*tape));
4868
4869 kref_init(&tape->kref); 4867 kref_init(&tape->kref);
4870 4868
4871 tape->drive = drive; 4869 tape->drive = drive;
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index ace8edad6e96..7ec18fa3b5ff 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -528,9 +528,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
528 528
529// printk("IDE Taskfile ...\n"); 529// printk("IDE Taskfile ...\n");
530 530
531 req_task = kmalloc(tasksize, GFP_KERNEL); 531 req_task = kzalloc(tasksize, GFP_KERNEL);
532 if (req_task == NULL) return -ENOMEM; 532 if (req_task == NULL) return -ENOMEM;
533 memset(req_task, 0, tasksize);
534 if (copy_from_user(req_task, buf, tasksize)) { 533 if (copy_from_user(req_task, buf, tasksize)) {
535 kfree(req_task); 534 kfree(req_task);
536 return -EFAULT; 535 return -EFAULT;
@@ -541,12 +540,11 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
541 540
542 if (taskout) { 541 if (taskout) {
543 int outtotal = tasksize; 542 int outtotal = tasksize;
544 outbuf = kmalloc(taskout, GFP_KERNEL); 543 outbuf = kzalloc(taskout, GFP_KERNEL);
545 if (outbuf == NULL) { 544 if (outbuf == NULL) {
546 err = -ENOMEM; 545 err = -ENOMEM;
547 goto abort; 546 goto abort;
548 } 547 }
549 memset(outbuf, 0, taskout);
550 if (copy_from_user(outbuf, buf + outtotal, taskout)) { 548 if (copy_from_user(outbuf, buf + outtotal, taskout)) {
551 err = -EFAULT; 549 err = -EFAULT;
552 goto abort; 550 goto abort;
@@ -555,12 +553,11 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
555 553
556 if (taskin) { 554 if (taskin) {
557 int intotal = tasksize + taskout; 555 int intotal = tasksize + taskout;
558 inbuf = kmalloc(taskin, GFP_KERNEL); 556 inbuf = kzalloc(taskin, GFP_KERNEL);
559 if (inbuf == NULL) { 557 if (inbuf == NULL) {
560 err = -ENOMEM; 558 err = -ENOMEM;
561 goto abort; 559 goto abort;
562 } 560 }
563 memset(inbuf, 0, taskin);
564 if (copy_from_user(inbuf, buf + intotal, taskin)) { 561 if (copy_from_user(inbuf, buf + intotal, taskin)) {
565 err = -EFAULT; 562 err = -EFAULT;
566 goto abort; 563 goto abort;
@@ -649,10 +646,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
649 } 646 }
650abort: 647abort:
651 kfree(req_task); 648 kfree(req_task);
652 if (outbuf != NULL) 649 kfree(outbuf);
653 kfree(outbuf); 650 kfree(inbuf);
654 if (inbuf != NULL)
655 kfree(inbuf);
656 651
657// printk("IDE Taskfile ioctl ended. rc = %i\n", err); 652// printk("IDE Taskfile ioctl ended. rc = %i\n", err);
658 653
@@ -709,10 +704,9 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
709 704
710 if (args[3]) { 705 if (args[3]) {
711 argsize = 4 + (SECTOR_WORDS * 4 * args[3]); 706 argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
712 argbuf = kmalloc(argsize, GFP_KERNEL); 707 argbuf = kzalloc(argsize, GFP_KERNEL);
713 if (argbuf == NULL) 708 if (argbuf == NULL)
714 return -ENOMEM; 709 return -ENOMEM;
715 memcpy(argbuf, args, 4);
716 } 710 }
717 if (set_transfer(drive, &tfargs)) { 711 if (set_transfer(drive, &tfargs)) {
718 xfer_rate = args[1]; 712 xfer_rate = args[1];
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 73ca8f73917d..9fe19808d815 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -864,9 +864,8 @@ static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int r
864 down(&ide_setting_sem); 864 down(&ide_setting_sem);
865 while ((*p) && strcmp((*p)->name, name) < 0) 865 while ((*p) && strcmp((*p)->name, name) < 0)
866 p = &((*p)->next); 866 p = &((*p)->next);
867 if ((setting = kmalloc(sizeof(*setting), GFP_KERNEL)) == NULL) 867 if ((setting = kzalloc(sizeof(*setting), GFP_KERNEL)) == NULL)
868 goto abort; 868 goto abort;
869 memset(setting, 0, sizeof(*setting));
870 if ((setting->name = kmalloc(strlen(name) + 1, GFP_KERNEL)) == NULL) 869 if ((setting->name = kmalloc(strlen(name) + 1, GFP_KERNEL)) == NULL)
871 goto abort; 870 goto abort;
872 strcpy(setting->name, name); 871 strcpy(setting->name, name);
@@ -889,8 +888,7 @@ static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int r
889 return 0; 888 return 0;
890abort: 889abort:
891 up(&ide_setting_sem); 890 up(&ide_setting_sem);
892 if (setting) 891 kfree(setting);
893 kfree(setting);
894 return -1; 892 return -1;
895} 893}
896 894
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index a35a58bef1a4..1dafffa7e513 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -116,9 +116,8 @@ static dev_link_t *ide_attach(void)
116 DEBUG(0, "ide_attach()\n"); 116 DEBUG(0, "ide_attach()\n");
117 117
118 /* Create new ide device */ 118 /* Create new ide device */
119 info = kmalloc(sizeof(*info), GFP_KERNEL); 119 info = kzalloc(sizeof(*info), GFP_KERNEL);
120 if (!info) return NULL; 120 if (!info) return NULL;
121 memset(info, 0, sizeof(*info));
122 link = &info->link; link->priv = info; 121 link = &info->link; link->priv = info;
123 122
124 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 123 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -221,9 +220,8 @@ static void ide_config(dev_link_t *link)
221 220
222 DEBUG(0, "ide_config(0x%p)\n", link); 221 DEBUG(0, "ide_config(0x%p)\n", link);
223 222
224 stk = kmalloc(sizeof(*stk), GFP_KERNEL); 223 stk = kzalloc(sizeof(*stk), GFP_KERNEL);
225 if (!stk) goto err_mem; 224 if (!stk) goto err_mem;
226 memset(stk, 0, sizeof(*stk));
227 cfg = &stk->parse.cftable_entry; 225 cfg = &stk->parse.cftable_entry;
228 226
229 tuple.TupleData = (cisdata_t *)&stk->buf; 227 tuple.TupleData = (cisdata_t *)&stk->buf;
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 127619a109ed..7b589d948bf9 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1516,7 +1516,7 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase)
1516 1516
1517static void __devinit init_iops_hpt366(ide_hwif_t *hwif) 1517static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
1518{ 1518{
1519 struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL); 1519 struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL);
1520 unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4); 1520 unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4);
1521 u8 did, rid; 1521 u8 did, rid;
1522 1522
@@ -1524,7 +1524,6 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
1524 printk(KERN_WARNING "hpt366: out of memory.\n"); 1524 printk(KERN_WARNING "hpt366: out of memory.\n");
1525 return; 1525 return;
1526 } 1526 }
1527 memset(info, 0, sizeof(struct hpt_info));
1528 ide_set_hwifdata(hwif, info); 1527 ide_set_hwifdata(hwif, info);
1529 1528
1530 if(dmabase) { 1529 if(dmabase) {
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index e440036e651f..108fda83fea4 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -642,14 +642,13 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
642 642
643static void __devinit init_hwif_it821x(ide_hwif_t *hwif) 643static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
644{ 644{
645 struct it821x_dev *idev = kmalloc(sizeof(struct it821x_dev), GFP_KERNEL); 645 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL);
646 u8 conf; 646 u8 conf;
647 647
648 if(idev == NULL) { 648 if(idev == NULL) {
649 printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n"); 649 printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n");
650 goto fallback; 650 goto fallback;
651 } 651 }
652 memset(idev, 0, sizeof(struct it821x_dev));
653 ide_set_hwifdata(hwif, idev); 652 ide_set_hwifdata(hwif, idev);
654 653
655 pci_read_config_byte(hwif->pci_dev, 0x50, &conf); 654 pci_read_config_byte(hwif->pci_dev, 0x50, &conf);
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index d8c3d8ebad30..b3e65a65d202 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -497,16 +497,19 @@ pmu_hd_blink_init(void)
497 if (pmu_get_model() != PMU_KEYLARGO_BASED) 497 if (pmu_get_model() != PMU_KEYLARGO_BASED)
498 return 0; 498 return 0;
499 499
500 dt = find_devices("device-tree"); 500 dt = of_find_node_by_path("/");
501 if (dt == NULL) 501 if (dt == NULL)
502 return 0; 502 return 0;
503 model = (const char *)get_property(dt, "model", NULL); 503 model = (const char *)get_property(dt, "model", NULL);
504 if (model == NULL) 504 if (model == NULL)
505 return 0; 505 return 0;
506 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 && 506 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
507 strncmp(model, "iBook", strlen("iBook")) != 0) 507 strncmp(model, "iBook", strlen("iBook")) != 0) {
508 of_node_put(dt);
508 return 0; 509 return 0;
509 510 }
511 of_node_put(dt);
512
510 pmu_blink_on.complete = 1; 513 pmu_blink_on.complete = 1;
511 pmu_blink_off.complete = 1; 514 pmu_blink_off.complete = 1;
512 spin_lock_init(&pmu_blink_lock); 515 spin_lock_init(&pmu_blink_lock);
diff --git a/drivers/ieee1394/amdtp.c b/drivers/ieee1394/amdtp.c
index e8e28569a668..75897509c401 100644
--- a/drivers/ieee1394/amdtp.c
+++ b/drivers/ieee1394/amdtp.c
@@ -320,8 +320,7 @@ static void ohci1394_stop_it_ctx(struct ti_ohci *ohci, int ctx, int synchronous)
320 if ((control & OHCI1394_CONTEXT_ACTIVE) == 0) 320 if ((control & OHCI1394_CONTEXT_ACTIVE) == 0)
321 break; 321 break;
322 322
323 set_current_state(TASK_INTERRUPTIBLE); 323 schedule_timeout_interruptible(1);
324 schedule_timeout(1);
325 } 324 }
326 } 325 }
327} 326}
diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index 7545775d38ef..34b724afd28d 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -37,6 +37,9 @@
37 * $Id: agent.c 1389 2004-12-27 22:56:47Z roland $ 37 * $Id: agent.c 1389 2004-12-27 22:56:47Z roland $
38 */ 38 */
39 39
40#include <linux/slab.h>
41#include <linux/string.h>
42
40#include "agent.h" 43#include "agent.h"
41#include "smi.h" 44#include "smi.h"
42 45
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 3d8175e5f054..41d6b4017acb 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -508,8 +508,7 @@ static void unregister_mad_agent(struct ib_mad_agent_private *mad_agent_priv)
508 wait_event(mad_agent_priv->wait, 508 wait_event(mad_agent_priv->wait,
509 !atomic_read(&mad_agent_priv->refcount)); 509 !atomic_read(&mad_agent_priv->refcount));
510 510
511 if (mad_agent_priv->reg_req) 511 kfree(mad_agent_priv->reg_req);
512 kfree(mad_agent_priv->reg_req);
513 ib_dereg_mr(mad_agent_priv->agent.mr); 512 ib_dereg_mr(mad_agent_priv->agent.mr);
514 kfree(mad_agent_priv); 513 kfree(mad_agent_priv);
515} 514}
@@ -2500,8 +2499,7 @@ error:
2500static void destroy_mad_qp(struct ib_mad_qp_info *qp_info) 2499static void destroy_mad_qp(struct ib_mad_qp_info *qp_info)
2501{ 2500{
2502 ib_destroy_qp(qp_info->qp); 2501 ib_destroy_qp(qp_info->qp);
2503 if (qp_info->snoop_table) 2502 kfree(qp_info->snoop_table);
2504 kfree(qp_info->snoop_table);
2505} 2503}
2506 2504
2507/* 2505/*
diff --git a/drivers/infiniband/core/packer.c b/drivers/infiniband/core/packer.c
index 35df5010e723..c972d7235764 100644
--- a/drivers/infiniband/core/packer.c
+++ b/drivers/infiniband/core/packer.c
@@ -33,6 +33,8 @@
33 * $Id: packer.c 1349 2004-12-16 21:09:43Z roland $ 33 * $Id: packer.c 1349 2004-12-16 21:09:43Z roland $
34 */ 34 */
35 35
36#include <linux/string.h>
37
36#include <rdma/ib_pack.h> 38#include <rdma/ib_pack.h>
37 39
38static u64 value_read(int offset, int size, void *structure) 40static u64 value_read(int offset, int size, void *structure)
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index b8120650e711..08648b1a387e 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -36,6 +36,9 @@
36 36
37#include "core_priv.h" 37#include "core_priv.h"
38 38
39#include <linux/slab.h>
40#include <linux/string.h>
41
39#include <rdma/ib_mad.h> 42#include <rdma/ib_mad.h>
40 43
41struct ib_port { 44struct ib_port {
diff --git a/drivers/infiniband/core/ud_header.c b/drivers/infiniband/core/ud_header.c
index 527b23450ab3..997c07db6d8f 100644
--- a/drivers/infiniband/core/ud_header.c
+++ b/drivers/infiniband/core/ud_header.c
@@ -34,6 +34,7 @@
34 */ 34 */
35 35
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/string.h>
37 38
38#include <rdma/ib_pack.h> 39#include <rdma/ib_pack.h>
39 40
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 72d3ef786db5..4186cc888ea5 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -40,6 +40,7 @@
40 40
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/err.h> 42#include <linux/err.h>
43#include <linux/string.h>
43 44
44#include <rdma/ib_verbs.h> 45#include <rdma/ib_verbs.h>
45#include <rdma/ib_cache.h> 46#include <rdma/ib_cache.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c
index 7ac52af43b99..25ebab64bc42 100644
--- a/drivers/infiniband/hw/mthca/mthca_catas.c
+++ b/drivers/infiniband/hw/mthca/mthca_catas.c
@@ -32,6 +32,9 @@
32 * $Id$ 32 * $Id$
33 */ 33 */
34 34
35#include <linux/jiffies.h>
36#include <linux/timer.h>
37
35#include "mthca_dev.h" 38#include "mthca_dev.h"
36 39
37enum { 40enum {
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 292f55be8cbd..26d5161fde07 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -32,6 +32,9 @@
32 * $Id: mthca_srq.c 3047 2005-08-10 03:59:35Z roland $ 32 * $Id: mthca_srq.c 3047 2005-08-10 03:59:35Z roland $
33 */ 33 */
34 34
35#include <linux/slab.h>
36#include <linux/string.h>
37
35#include "mthca_dev.h" 38#include "mthca_dev.h"
36#include "mthca_cmd.h" 39#include "mthca_cmd.h"
37#include "mthca_memfree.h" 40#include "mthca_memfree.h"
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1a1654caedd5..0879915b14d5 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -377,7 +377,7 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int
377 377
378 list_for_each_entry(dev, &input_dev_list, node) { 378 list_for_each_entry(dev, &input_dev_list, node) {
379 379
380 path = dev->dynalloc ? kobject_get_path(&dev->cdev.kobj, GFP_KERNEL) : NULL; 380 path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
381 381
382 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", 382 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
383 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); 383 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
@@ -741,15 +741,21 @@ static void input_register_classdevice(struct input_dev *dev)
741 sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group); 741 sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
742} 742}
743 743
744void input_register_device(struct input_dev *dev) 744int input_register_device(struct input_dev *dev)
745{ 745{
746 struct input_handle *handle; 746 struct input_handle *handle;
747 struct input_handler *handler; 747 struct input_handler *handler;
748 struct input_device_id *id; 748 struct input_device_id *id;
749 749
750 set_bit(EV_SYN, dev->evbit); 750 if (!dev->dynalloc) {
751 printk(KERN_WARNING "input: device %s is statically allocated, will not register\n"
752 "Please convert to input_allocate_device() or contact dtor_core@ameritech.net\n",
753 dev->name ? dev->name : "<Unknown>");
754 return -EINVAL;
755 }
751 756
752 init_MUTEX(&dev->sem); 757 init_MUTEX(&dev->sem);
758 set_bit(EV_SYN, dev->evbit);
753 759
754 /* 760 /*
755 * If delay and period are pre-set by the driver, then autorepeating 761 * If delay and period are pre-set by the driver, then autorepeating
@@ -767,8 +773,7 @@ void input_register_device(struct input_dev *dev)
767 INIT_LIST_HEAD(&dev->h_list); 773 INIT_LIST_HEAD(&dev->h_list);
768 list_add_tail(&dev->node, &input_dev_list); 774 list_add_tail(&dev->node, &input_dev_list);
769 775
770 if (dev->dynalloc) 776 input_register_classdevice(dev);
771 input_register_classdevice(dev);
772 777
773 list_for_each_entry(handler, &input_handler_list, node) 778 list_for_each_entry(handler, &input_handler_list, node)
774 if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) 779 if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
@@ -776,8 +781,9 @@ void input_register_device(struct input_dev *dev)
776 if ((handle = handler->connect(handler, dev, id))) 781 if ((handle = handler->connect(handler, dev, id)))
777 input_link_handle(handle); 782 input_link_handle(handle);
778 783
779
780 input_wakeup_procfs_readers(); 784 input_wakeup_procfs_readers();
785
786 return 0;
781} 787}
782 788
783void input_unregister_device(struct input_dev *dev) 789void input_unregister_device(struct input_dev *dev)
@@ -797,11 +803,10 @@ void input_unregister_device(struct input_dev *dev)
797 803
798 list_del_init(&dev->node); 804 list_del_init(&dev->node);
799 805
800 if (dev->dynalloc) { 806 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
801 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); 807 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
802 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); 808 sysfs_remove_group(&dev->cdev.kobj, &input_dev_group);
803 class_device_unregister(&dev->cdev); 809 class_device_unregister(&dev->cdev);
804 }
805 810
806 input_wakeup_procfs_readers(); 811 input_wakeup_procfs_readers();
807} 812}
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 9481132532d0..77c4d9669ad0 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM_KEYCODES] = {
273 [0xfb] = KEY_APOSTROPHE, 273 [0xfb] = KEY_APOSTROPHE,
274}; 274};
275 275
276#define CHECK_LED(LED, BITS) do { \ 276#define CHECK_LED(LK, VAR_ON, VAR_OFF, LED, BITS) do { \
277 if (test_bit (LED, lk->dev->led)) \ 277 if (test_bit (LED, (LK)->dev->led)) \
278 leds_on |= BITS; \ 278 VAR_ON |= BITS; \
279 else \ 279 else \
280 leds_off |= BITS; \ 280 VAR_OFF |= BITS; \
281 } while (0) 281 } while (0)
282 282
283/* 283/*
@@ -298,6 +298,42 @@ struct lkkbd {
298 int ctrlclick_volume; 298 int ctrlclick_volume;
299}; 299};
300 300
301#ifdef LKKBD_DEBUG
302/*
303 * Responses from the keyboard and mapping back to their names.
304 */
305static struct {
306 unsigned char value;
307 unsigned char *name;
308} lk_response[] = {
309#define RESPONSE(x) { .value = (x), .name = #x, }
310 RESPONSE (LK_STUCK_KEY),
311 RESPONSE (LK_SELFTEST_FAILED),
312 RESPONSE (LK_ALL_KEYS_UP),
313 RESPONSE (LK_METRONOME),
314 RESPONSE (LK_OUTPUT_ERROR),
315 RESPONSE (LK_INPUT_ERROR),
316 RESPONSE (LK_KBD_LOCKED),
317 RESPONSE (LK_KBD_TEST_MODE_ACK),
318 RESPONSE (LK_PREFIX_KEY_DOWN),
319 RESPONSE (LK_MODE_CHANGE_ACK),
320 RESPONSE (LK_RESPONSE_RESERVED),
321#undef RESPONSE
322};
323
324static unsigned char *
325response_name (unsigned char value)
326{
327 int i;
328
329 for (i = 0; i < ARRAY_SIZE (lk_response); i++)
330 if (lk_response[i].value == value)
331 return lk_response[i].name;
332
333 return "<unknown>";
334}
335#endif /* LKKBD_DEBUG */
336
301/* 337/*
302 * Calculate volume parameter byte for a given volume. 338 * Calculate volume parameter byte for a given volume.
303 */ 339 */
@@ -440,43 +476,24 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
440 input_report_key (lk->dev, lk->keycode[i], 0); 476 input_report_key (lk->dev, lk->keycode[i], 0);
441 input_sync (lk->dev); 477 input_sync (lk->dev);
442 break; 478 break;
443 case LK_METRONOME: 479
444 DBG (KERN_INFO "Got LK_METRONOME and don't " 480 case 0x01:
445 "know how to handle...\n"); 481 DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
482 lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
483 lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
484 schedule_work (&lk->tq);
446 break; 485 break;
486
487 case LK_METRONOME:
447 case LK_OUTPUT_ERROR: 488 case LK_OUTPUT_ERROR:
448 DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
449 "know how to handle...\n");
450 break;
451 case LK_INPUT_ERROR: 489 case LK_INPUT_ERROR:
452 DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
453 "know how to handle...\n");
454 break;
455 case LK_KBD_LOCKED: 490 case LK_KBD_LOCKED:
456 DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
457 "know how to handle...\n");
458 break;
459 case LK_KBD_TEST_MODE_ACK: 491 case LK_KBD_TEST_MODE_ACK:
460 DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
461 "know how to handle...\n");
462 break;
463 case LK_PREFIX_KEY_DOWN: 492 case LK_PREFIX_KEY_DOWN:
464 DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
465 "know how to handle...\n");
466 break;
467 case LK_MODE_CHANGE_ACK: 493 case LK_MODE_CHANGE_ACK:
468 DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
469 "it properly...\n");
470 break;
471 case LK_RESPONSE_RESERVED: 494 case LK_RESPONSE_RESERVED:
472 DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't " 495 DBG (KERN_INFO "Got %s and don't know how to handle...\n",
473 "know how to handle...\n"); 496 response_name (data));
474 break;
475 case 0x01:
476 DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
477 lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
478 lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
479 schedule_work (&lk->tq);
480 break; 497 break;
481 498
482 default: 499 default:
@@ -509,10 +526,10 @@ lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code,
509 526
510 switch (type) { 527 switch (type) {
511 case EV_LED: 528 case EV_LED:
512 CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK); 529 CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
513 CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE); 530 CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
514 CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK); 531 CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
515 CHECK_LED (LED_SLEEP, LK_LED_WAIT); 532 CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
516 if (leds_on != 0) { 533 if (leds_on != 0) {
517 lk->serio->write (lk->serio, LK_CMD_LED_ON); 534 lk->serio->write (lk->serio, LK_CMD_LED_ON);
518 lk->serio->write (lk->serio, leds_on); 535 lk->serio->write (lk->serio, leds_on);
@@ -574,10 +591,10 @@ lkkbd_reinit (void *data)
574 lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS); 591 lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS);
575 592
576 /* Set LEDs */ 593 /* Set LEDs */
577 CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK); 594 CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
578 CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE); 595 CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
579 CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK); 596 CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
580 CHECK_LED (LED_SLEEP, LK_LED_WAIT); 597 CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
581 if (leds_on != 0) { 598 if (leds_on != 0) {
582 lk->serio->write (lk->serio, LK_CMD_LED_ON); 599 lk->serio->write (lk->serio, LK_CMD_LED_ON);
583 lk->serio->write (lk->serio, leds_on); 600 lk->serio->write (lk->serio, leds_on);
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
index 8935290256b3..2c510881874a 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -76,7 +76,7 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = {
76 76
77struct locomokbd { 77struct locomokbd {
78 unsigned char keycode[LOCOMOKBD_NUMKEYS]; 78 unsigned char keycode[LOCOMOKBD_NUMKEYS];
79 struct input_dev input; 79 struct input_dev *input;
80 char phys[32]; 80 char phys[32];
81 81
82 struct locomo_dev *ldev; 82 struct locomo_dev *ldev;
@@ -136,8 +136,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *
136 136
137 spin_lock_irqsave(&locomokbd->lock, flags); 137 spin_lock_irqsave(&locomokbd->lock, flags);
138 138
139 if (regs) 139 input_regs(locomokbd->input, regs);
140 input_regs(&locomokbd->input, regs);
141 140
142 locomokbd_charge_all(membase); 141 locomokbd_charge_all(membase);
143 142
@@ -152,16 +151,16 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *
152 scancode = SCANCODE(col, row); 151 scancode = SCANCODE(col, row);
153 if (rowd & KB_ROWMASK(row)) { 152 if (rowd & KB_ROWMASK(row)) {
154 num_pressed += 1; 153 num_pressed += 1;
155 input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 1); 154 input_report_key(locomokbd->input, locomokbd->keycode[scancode], 1);
156 } else { 155 } else {
157 input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 0); 156 input_report_key(locomokbd->input, locomokbd->keycode[scancode], 0);
158 } 157 }
159 } 158 }
160 locomokbd_reset_col(membase, col); 159 locomokbd_reset_col(membase, col);
161 } 160 }
162 locomokbd_activate_all(membase); 161 locomokbd_activate_all(membase);
163 162
164 input_sync(&locomokbd->input); 163 input_sync(locomokbd->input);
165 164
166 /* if any keys are pressed, enable the timer */ 165 /* if any keys are pressed, enable the timer */
167 if (num_pressed) 166 if (num_pressed)
@@ -196,13 +195,15 @@ static void locomokbd_timer_callback(unsigned long data)
196static int locomokbd_probe(struct locomo_dev *dev) 195static int locomokbd_probe(struct locomo_dev *dev)
197{ 196{
198 struct locomokbd *locomokbd; 197 struct locomokbd *locomokbd;
198 struct input_dev *input_dev;
199 int i, ret; 199 int i, ret;
200 200
201 locomokbd = kmalloc(sizeof(struct locomokbd), GFP_KERNEL); 201 locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL);
202 if (!locomokbd) 202 input_dev = input_allocate_device();
203 return -ENOMEM; 203 if (!locomokbd || !input_dev) {
204 204 ret = -ENOMEM;
205 memset(locomokbd, 0, sizeof(struct locomokbd)); 205 goto free;
206 }
206 207
207 /* try and claim memory region */ 208 /* try and claim memory region */
208 if (!request_mem_region((unsigned long) dev->mapbase, 209 if (!request_mem_region((unsigned long) dev->mapbase,
@@ -224,27 +225,26 @@ static int locomokbd_probe(struct locomo_dev *dev)
224 locomokbd->timer.function = locomokbd_timer_callback; 225 locomokbd->timer.function = locomokbd_timer_callback;
225 locomokbd->timer.data = (unsigned long) locomokbd; 226 locomokbd->timer.data = (unsigned long) locomokbd;
226 227
227 locomokbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 228 locomokbd->input = input_dev;
229 strcpy(locomokbd->phys, "locomokbd/input0");
230
231 input_dev->name = "LoCoMo keyboard";
232 input_dev->phys = locomokbd->phys;
233 input_dev->id.bustype = BUS_HOST;
234 input_dev->id.vendor = 0x0001;
235 input_dev->id.product = 0x0001;
236 input_dev->id.version = 0x0100;
237 input_dev->private = locomokbd;
228 238
229 init_input_dev(&locomokbd->input); 239 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
230 locomokbd->input.keycode = locomokbd->keycode; 240 input_dev->keycode = locomokbd->keycode;
231 locomokbd->input.keycodesize = sizeof(unsigned char); 241 input_dev->keycodesize = sizeof(unsigned char);
232 locomokbd->input.keycodemax = ARRAY_SIZE(locomokbd_keycode); 242 input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode);
233 locomokbd->input.private = locomokbd;
234 243
235 memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); 244 memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode));
236 for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) 245 for (i = 0; i < LOCOMOKBD_NUMKEYS; i++)
237 set_bit(locomokbd->keycode[i], locomokbd->input.keybit); 246 set_bit(locomokbd->keycode[i], input_dev->keybit);
238 clear_bit(0, locomokbd->input.keybit); 247 clear_bit(0, input_dev->keybit);
239
240 strcpy(locomokbd->phys, "locomokbd/input0");
241
242 locomokbd->input.name = "LoCoMo keyboard";
243 locomokbd->input.phys = locomokbd->phys;
244 locomokbd->input.id.bustype = BUS_XTKBD;
245 locomokbd->input.id.vendor = 0x0001;
246 locomokbd->input.id.product = 0x0001;
247 locomokbd->input.id.version = 0x0100;
248 248
249 /* attempt to get the interrupt */ 249 /* attempt to get the interrupt */
250 ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); 250 ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd);
@@ -253,9 +253,7 @@ static int locomokbd_probe(struct locomo_dev *dev)
253 goto out; 253 goto out;
254 } 254 }
255 255
256 input_register_device(&locomokbd->input); 256 input_register_device(locomokbd->input);
257
258 printk(KERN_INFO "input: LoCoMo keyboard on locomokbd\n");
259 257
260 return 0; 258 return 0;
261 259
@@ -263,6 +261,7 @@ out:
263 release_mem_region((unsigned long) dev->mapbase, dev->length); 261 release_mem_region((unsigned long) dev->mapbase, dev->length);
264 locomo_set_drvdata(dev, NULL); 262 locomo_set_drvdata(dev, NULL);
265free: 263free:
264 input_free_device(input_dev);
266 kfree(locomokbd); 265 kfree(locomokbd);
267 266
268 return ret; 267 return ret;
@@ -276,7 +275,7 @@ static int locomokbd_remove(struct locomo_dev *dev)
276 275
277 del_timer_sync(&locomokbd->timer); 276 del_timer_sync(&locomokbd->timer);
278 277
279 input_unregister_device(&locomokbd->input); 278 input_unregister_device(locomokbd->input);
280 locomo_set_drvdata(dev, NULL); 279 locomo_set_drvdata(dev, NULL);
281 280
282 release_mem_region((unsigned long) dev->mapbase, dev->length); 281 release_mem_region((unsigned long) dev->mapbase, dev->length);
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 4015a91f4b6e..948c1cc01bc9 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -271,8 +271,7 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
271 goto exit; 271 goto exit;
272 } 272 }
273 273
274 if (dev->name) 274 kfree(dev->name);
275 kfree(dev->name);
276 275
277 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; 276 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1;
278 dev->name = name = kmalloc(size, GFP_KERNEL); 277 dev->name = name = kmalloc(size, GFP_KERNEL);
@@ -372,11 +371,8 @@ static int uinput_burn_device(struct uinput_device *udev)
372 if (test_bit(UIST_CREATED, &udev->state)) 371 if (test_bit(UIST_CREATED, &udev->state))
373 uinput_destroy_device(udev); 372 uinput_destroy_device(udev);
374 373
375 if (udev->dev->name) 374 kfree(udev->dev->name);
376 kfree(udev->dev->name); 375 kfree(udev->dev->phys);
377 if (udev->dev->phys)
378 kfree(udev->dev->phys);
379
380 kfree(udev->dev); 376 kfree(udev->dev);
381 kfree(udev); 377 kfree(udev);
382 378
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 0f69ff46c1ae..31a59f7abfaf 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -217,6 +217,9 @@ static struct ps2pp_info *get_model_info(unsigned char model)
217 { 61, PS2PP_KIND_MX, /* MX700 */ 217 { 61, PS2PP_KIND_MX, /* MX700 */
218 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | 218 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
219 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, 219 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },
220 { 66, PS2PP_KIND_MX, /* MX3100 reciver */
221 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
222 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN | PS2PP_HWHEEL },
220 { 73, 0, PS2PP_SIDE_BTN }, 223 { 73, 0, PS2PP_SIDE_BTN },
221 { 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, 224 { 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
222 { 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, 225 { 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index db9bad2b3d16..27391c32f3eb 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -212,11 +212,8 @@ static void avmcs_detach(dev_link_t *link)
212 212
213 /* Unlink device structure, free pieces */ 213 /* Unlink device structure, free pieces */
214 *linkp = link->next; 214 *linkp = link->next;
215 if (link->priv) { 215 kfree(link->priv);
216 kfree(link->priv);
217 }
218 kfree(link); 216 kfree(link);
219
220} /* avmcs_detach */ 217} /* avmcs_detach */
221 218
222/*====================================================================== 219/*======================================================================
diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
index 625799ab0d14..5d8ee7368f7b 100644
--- a/drivers/isdn/hisax/avm_pci.c
+++ b/drivers/isdn/hisax/avm_pci.c
@@ -552,14 +552,10 @@ close_hdlcstate(struct BCState *bcs)
552{ 552{
553 modehdlc(bcs, 0, 0); 553 modehdlc(bcs, 0, 0);
554 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { 554 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
555 if (bcs->hw.hdlc.rcvbuf) { 555 kfree(bcs->hw.hdlc.rcvbuf);
556 kfree(bcs->hw.hdlc.rcvbuf); 556 bcs->hw.hdlc.rcvbuf = NULL;
557 bcs->hw.hdlc.rcvbuf = NULL; 557 kfree(bcs->blog);
558 } 558 bcs->blog = NULL;
559 if (bcs->blog) {
560 kfree(bcs->blog);
561 bcs->blog = NULL;
562 }
563 skb_queue_purge(&bcs->rqueue); 559 skb_queue_purge(&bcs->rqueue);
564 skb_queue_purge(&bcs->squeue); 560 skb_queue_purge(&bcs->squeue);
565 if (bcs->tx_skb) { 561 if (bcs->tx_skb) {
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 0e22991635e7..5f5a5ae740d2 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -236,9 +236,7 @@ static void avma1cs_detach(dev_link_t *link)
236 236
237 /* Unlink device structure, free pieces */ 237 /* Unlink device structure, free pieces */
238 *linkp = link->next; 238 *linkp = link->next;
239 if (link->priv) { 239 kfree(link->priv);
240 kfree(link->priv);
241 }
242 kfree(link); 240 kfree(link);
243 241
244} /* avma1cs_detach */ 242} /* avma1cs_detach */
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index fbaab4352902..8159bcecd0c2 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -787,8 +787,7 @@ static void ll_unload(struct IsdnCardState *cs)
787 ic.command = ISDN_STAT_UNLOAD; 787 ic.command = ISDN_STAT_UNLOAD;
788 ic.driver = cs->myid; 788 ic.driver = cs->myid;
789 cs->iif.statcallb(&ic); 789 cs->iif.statcallb(&ic);
790 if (cs->status_buf) 790 kfree(cs->status_buf);
791 kfree(cs->status_buf);
792 cs->status_read = NULL; 791 cs->status_read = NULL;
793 cs->status_write = NULL; 792 cs->status_write = NULL;
794 cs->status_end = NULL; 793 cs->status_end = NULL;
@@ -807,10 +806,8 @@ static void closecard(int cardnr)
807 806
808 skb_queue_purge(&csta->rq); 807 skb_queue_purge(&csta->rq);
809 skb_queue_purge(&csta->sq); 808 skb_queue_purge(&csta->sq);
810 if (csta->rcvbuf) { 809 kfree(csta->rcvbuf);
811 kfree(csta->rcvbuf); 810 csta->rcvbuf = NULL;
812 csta->rcvbuf = NULL;
813 }
814 if (csta->tx_skb) { 811 if (csta->tx_skb) {
815 dev_kfree_skb(csta->tx_skb); 812 dev_kfree_skb(csta->tx_skb);
816 csta->tx_skb = NULL; 813 csta->tx_skb = NULL;
diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c
index 7cf87793e790..637a261c9312 100644
--- a/drivers/isdn/hisax/hfc_2bds0.c
+++ b/drivers/isdn/hisax/hfc_2bds0.c
@@ -1052,18 +1052,12 @@ init2bds0(struct IsdnCardState *cs)
1052void 1052void
1053release2bds0(struct IsdnCardState *cs) 1053release2bds0(struct IsdnCardState *cs)
1054{ 1054{
1055 if (cs->bcs[0].hw.hfc.send) { 1055 kfree(cs->bcs[0].hw.hfc.send);
1056 kfree(cs->bcs[0].hw.hfc.send); 1056 cs->bcs[0].hw.hfc.send = NULL;
1057 cs->bcs[0].hw.hfc.send = NULL; 1057 kfree(cs->bcs[1].hw.hfc.send);
1058 } 1058 cs->bcs[1].hw.hfc.send = NULL;
1059 if (cs->bcs[1].hw.hfc.send) { 1059 kfree(cs->hw.hfcD.send);
1060 kfree(cs->bcs[1].hw.hfc.send); 1060 cs->hw.hfcD.send = NULL;
1061 cs->bcs[1].hw.hfc.send = NULL;
1062 }
1063 if (cs->hw.hfcD.send) {
1064 kfree(cs->hw.hfcD.send);
1065 cs->hw.hfcD.send = NULL;
1066 }
1067} 1061}
1068 1062
1069void 1063void
diff --git a/drivers/isdn/hisax/hfc_2bs0.c b/drivers/isdn/hisax/hfc_2bs0.c
index f978a5af8662..c964539cc43e 100644
--- a/drivers/isdn/hisax/hfc_2bs0.c
+++ b/drivers/isdn/hisax/hfc_2bs0.c
@@ -582,12 +582,8 @@ inithfc(struct IsdnCardState *cs)
582void 582void
583releasehfc(struct IsdnCardState *cs) 583releasehfc(struct IsdnCardState *cs)
584{ 584{
585 if (cs->bcs[0].hw.hfc.send) { 585 kfree(cs->bcs[0].hw.hfc.send);
586 kfree(cs->bcs[0].hw.hfc.send); 586 cs->bcs[0].hw.hfc.send = NULL;
587 cs->bcs[0].hw.hfc.send = NULL; 587 kfree(cs->bcs[1].hw.hfc.send);
588 } 588 cs->bcs[1].hw.hfc.send = NULL;
589 if (cs->bcs[1].hw.hfc.send) {
590 kfree(cs->bcs[1].hw.hfc.send);
591 cs->bcs[1].hw.hfc.send = NULL;
592 }
593} 589}
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index e2c3af49d72b..32bf0d5d0f9a 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * hfc_usb.c 2 * hfc_usb.c
3 * 3 *
4 * $Id: hfc_usb.c,v 4.34 2005/01/26 17:25:53 martinb1 Exp $ 4 * $Id: hfc_usb.c,v 4.36 2005/04/08 09:55:13 martinb1 Exp $
5 * 5 *
6 * modular HiSax ISDN driver for Colognechip HFC-S USB chip 6 * modular HiSax ISDN driver for Colognechip HFC-S USB chip
7 * 7 *
@@ -44,12 +44,8 @@
44#include "hisax_if.h" 44#include "hisax_if.h"
45#include "hfc_usb.h" 45#include "hfc_usb.h"
46 46
47/*
48* Version Information
49* (do not modify the CVS Makros $Revision: 4.34 $ and $Date: 2005/01/26 17:25:53 $ !)
50*/
51static const char *hfcusb_revision = 47static const char *hfcusb_revision =
52 "Revision: 4.34 $ Date: 2005/01/26 17:25:53 $ "; 48 "$Revision: 4.36 $ $Date: 2005/04/08 09:55:13 $ ";
53 49
54/* Hisax debug support 50/* Hisax debug support
55* use "modprobe debug=x" where x is bitfield of USB_DBG & ISDN_DBG 51* use "modprobe debug=x" where x is bitfield of USB_DBG & ISDN_DBG
@@ -63,81 +59,89 @@ module_param(debug, uint, 0);
63static int hfc_debug; 59static int hfc_debug;
64#endif 60#endif
65 61
62/* private vendor specific data */
63typedef struct {
64 __u8 led_scheme; // led display scheme
65 signed short led_bits[8]; // array of 8 possible LED bitmask settings
66 char *vend_name; // device name
67} hfcsusb_vdata;
66 68
67/****************************************/ 69/****************************************/
68/* data defining the devices to be used */ 70/* data defining the devices to be used */
69/****************************************/ 71/****************************************/
70static struct usb_device_id hfc_usb_idtab[] = { 72static struct usb_device_id hfcusb_idtab[] = {
71 {USB_DEVICE(0x0959, 0x2bd0)}, /* Colognechip USB eval TA */ 73 {
72 {USB_DEVICE(0x0675, 0x1688)}, /* DrayTek miniVigor 128 USB ISDN TA */ 74 .idVendor = 0x0959,
73 {USB_DEVICE(0x07b0, 0x0007)}, /* Billion USB TA 2 */ 75 .idProduct = 0x2bd0,
74 {USB_DEVICE(0x0742, 0x2008)}, /* Stollmann USB TA */ 76 .driver_info = (unsigned long) &((hfcsusb_vdata)
75 {USB_DEVICE(0x0742, 0x2009)}, /* Aceex USB ISDN TA */ 77 {LED_OFF, {4, 0, 2, 1},
76 {USB_DEVICE(0x0742, 0x200A)}, /* OEM USB ISDN TA */ 78 "ISDN USB TA (Cologne Chip HFC-S USB based)"}),
77 {USB_DEVICE(0x08e3, 0x0301)}, /* OliTec ISDN USB */ 79 },
78 {USB_DEVICE(0x07fa, 0x0846)}, /* Bewan ISDN USB TA */ 80 {
79 {USB_DEVICE(0x07fa, 0x0847)}, /* Djinn Numeris USB */ 81 .idVendor = 0x0675,
80 {USB_DEVICE(0x07b0, 0x0006)}, /* Twister ISDN USB TA */ 82 .idProduct = 0x1688,
81 {} /* end with an all-zeroes entry */ 83 .driver_info = (unsigned long) &((hfcsusb_vdata)
84 {LED_SCHEME1, {1, 2, 0, 0},
85 "DrayTek miniVigor 128 USB ISDN TA"}),
86 },
87 {
88 .idVendor = 0x07b0,
89 .idProduct = 0x0007,
90 .driver_info = (unsigned long) &((hfcsusb_vdata)
91 {LED_SCHEME1, {0x80, -64, -32, -16},
92 "Billion tiny USB ISDN TA 128"}),
93 },
94 {
95 .idVendor = 0x0742,
96 .idProduct = 0x2008,
97 .driver_info = (unsigned long) &((hfcsusb_vdata)
98 {LED_SCHEME1, {4, 0, 2, 1},
99 "Stollmann USB TA"}),
100 },
101 {
102 .idVendor = 0x0742,
103 .idProduct = 0x2009,
104 .driver_info = (unsigned long) &((hfcsusb_vdata)
105 {LED_SCHEME1, {4, 0, 2, 1},
106 "Aceex USB ISDN TA"}),
107 },
108 {
109 .idVendor = 0x0742,
110 .idProduct = 0x200A,
111 .driver_info = (unsigned long) &((hfcsusb_vdata)
112 {LED_SCHEME1, {4, 0, 2, 1},
113 "OEM USB ISDN TA"}),
114 },
115 {
116 .idVendor = 0x08e3,
117 .idProduct = 0x0301,
118 .driver_info = (unsigned long) &((hfcsusb_vdata)
119 {LED_SCHEME1, {2, 0, 1, 4},
120 "Olitec USB RNIS"}),
121 },
122 {
123 .idVendor = 0x07fa,
124 .idProduct = 0x0846,
125 .driver_info = (unsigned long) &((hfcsusb_vdata)
126 {LED_SCHEME1, {0x80, -64, -32, -16},
127 "Bewan Modem RNIS USB"}),
128 },
129 {
130 .idVendor = 0x07fa,
131 .idProduct = 0x0847,
132 .driver_info = (unsigned long) &((hfcsusb_vdata)
133 {LED_SCHEME1, {0x80, -64, -32, -16},
134 "Djinn Numeris USB"}),
135 },
136 {
137 .idVendor = 0x07b0,
138 .idProduct = 0x0006,
139 .driver_info = (unsigned long) &((hfcsusb_vdata)
140 {LED_SCHEME1, {0x80, -64, -32, -16},
141 "Twister ISDN TA"}),
142 },
82}; 143};
83 144
84/* driver internal device specific data:
85* VendorID, ProductID, Devicename, LED_SCHEME,
86* LED's BitMask in HFCUSB_P_DATA Register : LED_USB, LED_S0, LED_B1, LED_B2
87*/
88static vendor_data vdata[] = {
89 /* CologneChip Eval TA */
90 {0x0959, 0x2bd0, "ISDN USB TA (Cologne Chip HFC-S USB based)",
91 LED_OFF, {4, 0, 2, 1}
92 }
93 ,
94 /* DrayTek miniVigor 128 USB ISDN TA */
95 {0x0675, 0x1688, "DrayTek miniVigor 128 USB ISDN TA",
96 LED_SCHEME1, {1, 2, 0, 0}
97 }
98 ,
99 /* Billion TA */
100 {0x07b0, 0x0007, "Billion tiny USB ISDN TA 128",
101 LED_SCHEME1, {0x80, -64, -32, -16}
102 }
103 ,
104 /* Stollmann TA */
105 {0x0742, 0x2008, "Stollmann USB TA",
106 LED_SCHEME1, {4, 0, 2, 1}
107 }
108 ,
109 /* Aceex USB ISDN TA */
110 {0x0742, 0x2009, "Aceex USB ISDN TA",
111 LED_SCHEME1, {4, 0, 2, 1}
112 }
113 ,
114 /* OEM USB ISDN TA */
115 {0x0742, 0x200A, "OEM USB ISDN TA",
116 LED_SCHEME1, {4, 0, 2, 1}
117 }
118 ,
119 /* Olitec TA */
120 {0x08e3, 0x0301, "Olitec USB RNIS",
121 LED_SCHEME1, {2, 0, 1, 4}
122 }
123 ,
124 /* Bewan TA */
125 {0x07fa, 0x0846, "Bewan Modem RNIS USB",
126 LED_SCHEME1, {0x80, -64, -32, -16}
127 }
128 ,
129 /* Bewan TA */
130 {0x07fa, 0x0847, "Djinn Numeris USB",
131 LED_SCHEME1, {0x80, -64, -32, -16}
132 }
133 ,
134 /* Twister ISDN TA */
135 {0x07b0, 0x0006, "Twister ISDN TA",
136 LED_SCHEME1, {0x80, -64, -32, -16}
137 }
138 ,
139 {0, 0, 0} /* EOL element */
140};
141 145
142/***************************************************************/ 146/***************************************************************/
143/* structure defining input+output fifos (interrupt/bulk mode) */ 147/* structure defining input+output fifos (interrupt/bulk mode) */
@@ -211,8 +215,6 @@ typedef struct hfcusb_data {
211 volatile __u8 l1_state; /* actual l1 state */ 215 volatile __u8 l1_state; /* actual l1 state */
212 struct timer_list t3_timer; /* timer 3 for activation/deactivation */ 216 struct timer_list t3_timer; /* timer 3 for activation/deactivation */
213 struct timer_list t4_timer; /* timer 4 for activation/deactivation */ 217 struct timer_list t4_timer; /* timer 4 for activation/deactivation */
214 struct timer_list led_timer; /* timer flashing leds */
215
216} hfcusb_data; 218} hfcusb_data;
217 219
218 220
@@ -227,7 +229,7 @@ symbolic(struct hfcusb_symbolic_list list[], const int num)
227 for (i = 0; list[i].name != NULL; i++) 229 for (i = 0; list[i].name != NULL; i++)
228 if (list[i].num == num) 230 if (list[i].num == num)
229 return (list[i].name); 231 return (list[i].name);
230 return "<unkown>"; 232 return "<unkown ERROR>";
231} 233}
232 234
233 235
@@ -335,93 +337,57 @@ set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset)
335 } 337 }
336} 338}
337 339
338/******************************************/
339/* invert B-channel LEDs if data is sent */
340/******************************************/
341static void
342led_timer(hfcusb_data * hfc)
343{
344 static int cnt = 0;
345
346 if (cnt) {
347 if (hfc->led_b_active & 1)
348 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[2],
349 0);
350 if (hfc->led_b_active & 2)
351 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[3],
352 0);
353 } else {
354 if (!(hfc->led_b_active & 1) || hfc->led_new_data & 1)
355 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[2],
356 1);
357 if (!(hfc->led_b_active & 2) || hfc->led_new_data & 2)
358 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[3],
359 1);
360 }
361
362 write_led(hfc, hfc->led_state);
363 hfc->led_new_data = 0;
364
365 cnt = !cnt;
366
367 /* restart 4 hz timer */
368 if (!timer_pending(&hfc->led_timer)) {
369 add_timer(&hfc->led_timer);
370 hfc->led_timer.expires = jiffies + (LED_TIME * HZ) / 1000;
371 }
372}
373
374/**************************/ 340/**************************/
375/* handle LED requests */ 341/* handle LED requests */
376/**************************/ 342/**************************/
377static void 343static void
378handle_led(hfcusb_data * hfc, int event) 344handle_led(hfcusb_data * hfc, int event)
379{ 345{
346 hfcsusb_vdata *driver_info =
347 (hfcsusb_vdata *) hfcusb_idtab[hfc->vend_idx].driver_info;
348
380 /* if no scheme -> no LED action */ 349 /* if no scheme -> no LED action */
381 if (vdata[hfc->vend_idx].led_scheme == LED_OFF) 350 if (driver_info->led_scheme == LED_OFF)
382 return; 351 return;
383 352
384 switch (event) { 353 switch (event) {
385 case LED_POWER_ON: 354 case LED_POWER_ON:
386 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[0], 355 set_led_bit(hfc, driver_info->led_bits[0],
387 0); 356 0);
388 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[1], 357 set_led_bit(hfc, driver_info->led_bits[1],
389 1); 358 1);
390 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[2], 359 set_led_bit(hfc, driver_info->led_bits[2],
391 1); 360 1);
392 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[3], 361 set_led_bit(hfc, driver_info->led_bits[3],
393 1); 362 1);
394 break; 363 break;
395 case LED_POWER_OFF: /* no Power off handling */ 364 case LED_POWER_OFF: /* no Power off handling */
396 break; 365 break;
397 case LED_S0_ON: 366 case LED_S0_ON:
398 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[1], 367 set_led_bit(hfc, driver_info->led_bits[1],
399 0); 368 0);
400 break; 369 break;
401 case LED_S0_OFF: 370 case LED_S0_OFF:
402 set_led_bit(hfc, vdata[hfc->vend_idx].led_bits[1], 371 set_led_bit(hfc, driver_info->led_bits[1],
403 1); 372 1);
404 break; 373 break;
405 case LED_B1_ON: 374 case LED_B1_ON:
406 hfc->led_b_active |= 1; 375 set_led_bit(hfc, driver_info->led_bits[2],
376 0);
407 break; 377 break;
408 case LED_B1_OFF: 378 case LED_B1_OFF:
409 hfc->led_b_active &= ~1; 379 set_led_bit(hfc, driver_info->led_bits[2],
410 break; 380 1);
411 case LED_B1_DATA:
412 hfc->led_new_data |= 1;
413 break; 381 break;
414 case LED_B2_ON: 382 case LED_B2_ON:
415 hfc->led_b_active |= 2; 383 set_led_bit(hfc, driver_info->led_bits[3],
384 0);
416 break; 385 break;
417 case LED_B2_OFF: 386 case LED_B2_OFF:
418 hfc->led_b_active &= ~2; 387 set_led_bit(hfc, driver_info->led_bits[3],
419 break; 388 1);
420 case LED_B2_DATA:
421 hfc->led_new_data |= 2;
422 break; 389 break;
423 } 390 }
424
425 write_led(hfc, hfc->led_state); 391 write_led(hfc, hfc->led_state);
426} 392}
427 393
@@ -725,14 +691,6 @@ tx_iso_complete(struct urb *urb, struct pt_regs *regs)
725 current_len + 1; 691 current_len + 1;
726 692
727 tx_offset += (current_len + 1); 693 tx_offset += (current_len + 1);
728 if (!transp_mode) {
729 if (fifon == HFCUSB_B1_TX)
730 handle_led(hfc,
731 LED_B1_DATA);
732 if (fifon == HFCUSB_B2_TX)
733 handle_led(hfc,
734 LED_B2_DATA);
735 }
736 } else { 694 } else {
737 urb->iso_frame_desc[k].offset = 695 urb->iso_frame_desc[k].offset =
738 tx_offset++; 696 tx_offset++;
@@ -966,14 +924,6 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
966 skb_trim(fifo->skbuff, 0); 924 skb_trim(fifo->skbuff, 0);
967 } 925 }
968 } 926 }
969
970 /* LED flashing only in HDLC mode */
971 if (!transp_mode) {
972 if (fifon == HFCUSB_B1_RX)
973 handle_led(hfc, LED_B1_DATA);
974 if (fifon == HFCUSB_B2_RX)
975 handle_led(hfc, LED_B2_DATA);
976 }
977} 927}
978 928
979/***********************************************/ 929/***********************************************/
@@ -1339,17 +1289,6 @@ usb_init(hfcusb_data * hfc)
1339 hfc->t4_timer.data = (long) hfc; 1289 hfc->t4_timer.data = (long) hfc;
1340 hfc->t4_timer.function = (void *) l1_timer_expire_t4; 1290 hfc->t4_timer.function = (void *) l1_timer_expire_t4;
1341 1291
1342 /* init the led timer */
1343 init_timer(&hfc->led_timer);
1344 hfc->led_timer.data = (long) hfc;
1345 hfc->led_timer.function = (void *) led_timer;
1346
1347 /* trigger 4 hz led timer */
1348 if (!timer_pending(&hfc->led_timer)) {
1349 hfc->led_timer.expires = jiffies + (LED_TIME * HZ) / 1000;
1350 add_timer(&hfc->led_timer);
1351 }
1352
1353 /* init the background machinery for control requests */ 1292 /* init the background machinery for control requests */
1354 hfc->ctrl_read.bRequestType = 0xc0; 1293 hfc->ctrl_read.bRequestType = 0xc0;
1355 hfc->ctrl_read.bRequest = 1; 1294 hfc->ctrl_read.bRequest = 1;
@@ -1440,13 +1379,18 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1440 attr, cfg_found, cidx, ep_addr; 1379 attr, cfg_found, cidx, ep_addr;
1441 int cmptbl[16], small_match, iso_packet_size, packet_size, 1380 int cmptbl[16], small_match, iso_packet_size, packet_size,
1442 alt_used = 0; 1381 alt_used = 0;
1382 hfcsusb_vdata *driver_info;
1443 1383
1444 vend_idx = 0xffff; 1384 vend_idx = 0xffff;
1445 for (i = 0; vdata[i].vendor; i++) { 1385 for (i = 0; hfcusb_idtab[i].idVendor; i++) {
1446 if (dev->descriptor.idVendor == vdata[i].vendor 1386 if (dev->descriptor.idVendor == hfcusb_idtab[i].idVendor
1447 && dev->descriptor.idProduct == vdata[i].prod_id) 1387 && dev->descriptor.idProduct ==
1388 hfcusb_idtab[i].idProduct) {
1448 vend_idx = i; 1389 vend_idx = i;
1390 continue;
1391 }
1449 } 1392 }
1393
1450#ifdef CONFIG_HISAX_DEBUG 1394#ifdef CONFIG_HISAX_DEBUG
1451 DBG(USB_DBG, 1395 DBG(USB_DBG,
1452 "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", ifnum, 1396 "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", ifnum,
@@ -1457,10 +1401,6 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1457 ifnum, iface->desc.bAlternateSetting, intf->minor); 1401 ifnum, iface->desc.bAlternateSetting, intf->minor);
1458 1402
1459 if (vend_idx != 0xffff) { 1403 if (vend_idx != 0xffff) {
1460#ifdef CONFIG_HISAX_DEBUG
1461 DBG(USB_DBG, "HFC-S USB: found vendor idx:%d name:%s",
1462 vend_idx, vdata[vend_idx].vend_name);
1463#endif
1464 /* if vendor and product ID is OK, start probing alternate settings */ 1404 /* if vendor and product ID is OK, start probing alternate settings */
1465 alt_idx = 0; 1405 alt_idx = 0;
1466 small_match = 0xffff; 1406 small_match = 0xffff;
@@ -1687,9 +1627,11 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1687 usb_sndctrlpipe(context->dev, 0); 1627 usb_sndctrlpipe(context->dev, 0);
1688 context->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL); 1628 context->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);
1689 1629
1690 printk(KERN_INFO 1630 driver_info =
1691 "HFC-S USB: detected \"%s\"\n", 1631 (hfcsusb_vdata *) hfcusb_idtab[vend_idx].
1692 vdata[vend_idx].vend_name); 1632 driver_info;
1633 printk(KERN_INFO "HFC-S USB: detected \"%s\"\n",
1634 driver_info->vend_name);
1693#ifdef CONFIG_HISAX_DEBUG 1635#ifdef CONFIG_HISAX_DEBUG
1694 DBG(USB_DBG, 1636 DBG(USB_DBG,
1695 "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d)\n", 1637 "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d)\n",
@@ -1740,8 +1682,6 @@ hfc_usb_disconnect(struct usb_interface
1740 del_timer(&context->t3_timer); 1682 del_timer(&context->t3_timer);
1741 if (timer_pending(&context->t4_timer)) 1683 if (timer_pending(&context->t4_timer))
1742 del_timer(&context->t4_timer); 1684 del_timer(&context->t4_timer);
1743 if (timer_pending(&context->led_timer))
1744 del_timer(&context->led_timer);
1745 /* tell all fifos to terminate */ 1685 /* tell all fifos to terminate */
1746 for (i = 0; i < HFCUSB_NUM_FIFOS; i++) { 1686 for (i = 0; i < HFCUSB_NUM_FIFOS; i++) {
1747 if (context->fifos[i].usb_transfer_mode == USB_ISOC) { 1687 if (context->fifos[i].usb_transfer_mode == USB_ISOC) {
@@ -1785,9 +1725,11 @@ hfc_usb_disconnect(struct usb_interface
1785/* our driver information structure */ 1725/* our driver information structure */
1786/************************************/ 1726/************************************/
1787static struct usb_driver hfc_drv = { 1727static struct usb_driver hfc_drv = {
1788 .owner = THIS_MODULE,.name = 1728 .owner = THIS_MODULE,
1789 "hfc_usb",.id_table = hfc_usb_idtab,.probe = 1729 .name = "hfc_usb",
1790 hfc_usb_probe,.disconnect = hfc_usb_disconnect, 1730 .id_table = hfcusb_idtab,
1731 .probe = hfc_usb_probe,
1732 .disconnect = hfc_usb_disconnect,
1791}; 1733};
1792static void __exit 1734static void __exit
1793hfc_usb_exit(void) 1735hfc_usb_exit(void)
@@ -1825,4 +1767,4 @@ module_exit(hfc_usb_exit);
1825MODULE_AUTHOR(DRIVER_AUTHOR); 1767MODULE_AUTHOR(DRIVER_AUTHOR);
1826MODULE_DESCRIPTION(DRIVER_DESC); 1768MODULE_DESCRIPTION(DRIVER_DESC);
1827MODULE_LICENSE("GPL"); 1769MODULE_LICENSE("GPL");
1828MODULE_DEVICE_TABLE(usb, hfc_usb_idtab); 1770MODULE_DEVICE_TABLE(usb, hfcusb_idtab);
diff --git a/drivers/isdn/hisax/hfc_usb.h b/drivers/isdn/hisax/hfc_usb.h
index 280dd29b30d6..ec52c1a7c22a 100644
--- a/drivers/isdn/hisax/hfc_usb.h
+++ b/drivers/isdn/hisax/hfc_usb.h
@@ -1,7 +1,7 @@
1/* 1/*
2* hfc_usb.h 2* hfc_usb.h
3* 3*
4* $Id: hfc_usb.h,v 4.1 2005/01/26 17:25:53 martinb1 Exp $ 4* $Id: hfc_usb.h,v 4.2 2005/04/07 15:27:17 martinb1 Exp $
5*/ 5*/
6 6
7#ifndef __HFC_USB_H__ 7#ifndef __HFC_USB_H__
@@ -91,7 +91,7 @@
91/**********/ 91/**********/
92/* macros */ 92/* macros */
93/**********/ 93/**********/
94#define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),0,0,HFC_CTRL_TIMEOUT) 94#define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT)
95#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) 95#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT)
96 96
97 97
@@ -186,6 +186,7 @@ static int validconf[][19] = {
186 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} // EOL element 186 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} // EOL element
187}; 187};
188 188
189#ifdef CONFIG_HISAX_DEBUG
189// string description of chosen config 190// string description of chosen config
190static char *conf_str[] = { 191static char *conf_str[] = {
191 "4 Interrupt IN + 3 Isochron OUT", 192 "4 Interrupt IN + 3 Isochron OUT",
@@ -193,6 +194,7 @@ static char *conf_str[] = {
193 "4 Isochron IN + 3 Isochron OUT", 194 "4 Isochron IN + 3 Isochron OUT",
194 "3 Isochron IN + 3 Isochron OUT" 195 "3 Isochron IN + 3 Isochron OUT"
195}; 196};
197#endif
196 198
197 199
198typedef struct { 200typedef struct {
diff --git a/drivers/isdn/hisax/hscx.c b/drivers/isdn/hisax/hscx.c
index 66dbaee77bfb..c8f9951f7914 100644
--- a/drivers/isdn/hisax/hscx.c
+++ b/drivers/isdn/hisax/hscx.c
@@ -156,14 +156,10 @@ close_hscxstate(struct BCState *bcs)
156{ 156{
157 modehscx(bcs, 0, bcs->channel); 157 modehscx(bcs, 0, bcs->channel);
158 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { 158 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
159 if (bcs->hw.hscx.rcvbuf) { 159 kfree(bcs->hw.hscx.rcvbuf);
160 kfree(bcs->hw.hscx.rcvbuf); 160 bcs->hw.hscx.rcvbuf = NULL;
161 bcs->hw.hscx.rcvbuf = NULL; 161 kfree(bcs->blog);
162 } 162 bcs->blog = NULL;
163 if (bcs->blog) {
164 kfree(bcs->blog);
165 bcs->blog = NULL;
166 }
167 skb_queue_purge(&bcs->rqueue); 163 skb_queue_purge(&bcs->rqueue);
168 skb_queue_purge(&bcs->squeue); 164 skb_queue_purge(&bcs->squeue);
169 if (bcs->tx_skb) { 165 if (bcs->tx_skb) {
diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
index b4ca5859b177..c615752b96aa 100644
--- a/drivers/isdn/hisax/icc.c
+++ b/drivers/isdn/hisax/icc.c
@@ -571,14 +571,10 @@ setstack_icc(struct PStack *st, struct IsdnCardState *cs)
571 571
572static void 572static void
573DC_Close_icc(struct IsdnCardState *cs) { 573DC_Close_icc(struct IsdnCardState *cs) {
574 if (cs->dc.icc.mon_rx) { 574 kfree(cs->dc.icc.mon_rx);
575 kfree(cs->dc.icc.mon_rx); 575 cs->dc.icc.mon_rx = NULL;
576 cs->dc.icc.mon_rx = NULL; 576 kfree(cs->dc.icc.mon_tx);
577 } 577 cs->dc.icc.mon_tx = NULL;
578 if (cs->dc.icc.mon_tx) {
579 kfree(cs->dc.icc.mon_tx);
580 cs->dc.icc.mon_tx = NULL;
581 }
582} 578}
583 579
584static void 580static void
diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
index efba2f448017..2e9afae1254a 100644
--- a/drivers/isdn/hisax/ipacx.c
+++ b/drivers/isdn/hisax/ipacx.c
@@ -762,14 +762,10 @@ bch_close_state(struct BCState *bcs)
762{ 762{
763 bch_mode(bcs, 0, bcs->channel); 763 bch_mode(bcs, 0, bcs->channel);
764 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { 764 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
765 if (bcs->hw.hscx.rcvbuf) { 765 kfree(bcs->hw.hscx.rcvbuf);
766 kfree(bcs->hw.hscx.rcvbuf); 766 bcs->hw.hscx.rcvbuf = NULL;
767 bcs->hw.hscx.rcvbuf = NULL; 767 kfree(bcs->blog);
768 } 768 bcs->blog = NULL;
769 if (bcs->blog) {
770 kfree(bcs->blog);
771 bcs->blog = NULL;
772 }
773 skb_queue_purge(&bcs->rqueue); 769 skb_queue_purge(&bcs->rqueue);
774 skb_queue_purge(&bcs->squeue); 770 skb_queue_purge(&bcs->squeue);
775 if (bcs->tx_skb) { 771 if (bcs->tx_skb) {
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
index 85e063a08d23..565b7892c267 100644
--- a/drivers/isdn/hisax/isac.c
+++ b/drivers/isdn/hisax/isac.c
@@ -570,15 +570,12 @@ setstack_isac(struct PStack *st, struct IsdnCardState *cs)
570} 570}
571 571
572static void 572static void
573DC_Close_isac(struct IsdnCardState *cs) { 573DC_Close_isac(struct IsdnCardState *cs)
574 if (cs->dc.isac.mon_rx) { 574{
575 kfree(cs->dc.isac.mon_rx); 575 kfree(cs->dc.isac.mon_rx);
576 cs->dc.isac.mon_rx = NULL; 576 cs->dc.isac.mon_rx = NULL;
577 } 577 kfree(cs->dc.isac.mon_tx);
578 if (cs->dc.isac.mon_tx) { 578 cs->dc.isac.mon_tx = NULL;
579 kfree(cs->dc.isac.mon_tx);
580 cs->dc.isac.mon_tx = NULL;
581 }
582} 579}
583 580
584static void 581static void
diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
index 642a87c51295..674af673ff96 100644
--- a/drivers/isdn/hisax/isar.c
+++ b/drivers/isdn/hisax/isar.c
@@ -1688,10 +1688,8 @@ close_isarstate(struct BCState *bcs)
1688{ 1688{
1689 modeisar(bcs, 0, bcs->channel); 1689 modeisar(bcs, 0, bcs->channel);
1690 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { 1690 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
1691 if (bcs->hw.isar.rcvbuf) { 1691 kfree(bcs->hw.isar.rcvbuf);
1692 kfree(bcs->hw.isar.rcvbuf); 1692 bcs->hw.isar.rcvbuf = NULL;
1693 bcs->hw.isar.rcvbuf = NULL;
1694 }
1695 skb_queue_purge(&bcs->rqueue); 1693 skb_queue_purge(&bcs->rqueue);
1696 skb_queue_purge(&bcs->squeue); 1694 skb_queue_purge(&bcs->squeue);
1697 if (bcs->tx_skb) { 1695 if (bcs->tx_skb) {
diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
index 363ae3179bbd..2659fecc2674 100644
--- a/drivers/isdn/hisax/jade.c
+++ b/drivers/isdn/hisax/jade.c
@@ -195,14 +195,10 @@ close_jadestate(struct BCState *bcs)
195{ 195{
196 modejade(bcs, 0, bcs->channel); 196 modejade(bcs, 0, bcs->channel);
197 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { 197 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
198 if (bcs->hw.hscx.rcvbuf) { 198 kfree(bcs->hw.hscx.rcvbuf);
199 kfree(bcs->hw.hscx.rcvbuf); 199 bcs->hw.hscx.rcvbuf = NULL;
200 bcs->hw.hscx.rcvbuf = NULL; 200 kfree(bcs->blog);
201 } 201 bcs->blog = NULL;
202 if (bcs->blog) {
203 kfree(bcs->blog);
204 bcs->blog = NULL;
205 }
206 skb_queue_purge(&bcs->rqueue); 202 skb_queue_purge(&bcs->rqueue);
207 skb_queue_purge(&bcs->squeue); 203 skb_queue_purge(&bcs->squeue);
208 if (bcs->tx_skb) { 204 if (bcs->tx_skb) {
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
index 94da03c30c51..47a47ef0968b 100644
--- a/drivers/isdn/hisax/netjet.c
+++ b/drivers/isdn/hisax/netjet.c
@@ -855,14 +855,10 @@ close_tigerstate(struct BCState *bcs)
855{ 855{
856 mode_tiger(bcs, 0, bcs->channel); 856 mode_tiger(bcs, 0, bcs->channel);
857 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { 857 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
858 if (bcs->hw.tiger.rcvbuf) { 858 kfree(bcs->hw.tiger.rcvbuf);
859 kfree(bcs->hw.tiger.rcvbuf); 859 bcs->hw.tiger.rcvbuf = NULL;
860 bcs->hw.tiger.rcvbuf = NULL; 860 kfree(bcs->hw.tiger.sendbuf);
861 } 861 bcs->hw.tiger.sendbuf = NULL;
862 if (bcs->hw.tiger.sendbuf) {
863 kfree(bcs->hw.tiger.sendbuf);
864 bcs->hw.tiger.sendbuf = NULL;
865 }
866 skb_queue_purge(&bcs->rqueue); 862 skb_queue_purge(&bcs->rqueue);
867 skb_queue_purge(&bcs->squeue); 863 skb_queue_purge(&bcs->squeue);
868 if (bcs->tx_skb) { 864 if (bcs->tx_skb) {
@@ -967,20 +963,12 @@ inittiger(struct IsdnCardState *cs)
967static void 963static void
968releasetiger(struct IsdnCardState *cs) 964releasetiger(struct IsdnCardState *cs)
969{ 965{
970 if (cs->bcs[0].hw.tiger.send) { 966 kfree(cs->bcs[0].hw.tiger.send);
971 kfree(cs->bcs[0].hw.tiger.send); 967 cs->bcs[0].hw.tiger.send = NULL;
972 cs->bcs[0].hw.tiger.send = NULL; 968 cs->bcs[1].hw.tiger.send = NULL;
973 } 969 kfree(cs->bcs[0].hw.tiger.rec);
974 if (cs->bcs[1].hw.tiger.send) { 970 cs->bcs[0].hw.tiger.rec = NULL;
975 cs->bcs[1].hw.tiger.send = NULL; 971 cs->bcs[1].hw.tiger.rec = NULL;
976 }
977 if (cs->bcs[0].hw.tiger.rec) {
978 kfree(cs->bcs[0].hw.tiger.rec);
979 cs->bcs[0].hw.tiger.rec = NULL;
980 }
981 if (cs->bcs[1].hw.tiger.rec) {
982 cs->bcs[1].hw.tiger.rec = NULL;
983 }
984} 972}
985 973
986void 974void
diff --git a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c
index 89fbeb58485d..b096b64b0253 100644
--- a/drivers/isdn/hisax/st5481_usb.c
+++ b/drivers/isdn/hisax/st5481_usb.c
@@ -335,14 +335,12 @@ void st5481_release_usb(struct st5481_adapter *adapter)
335 335
336 // Stop and free Control and Interrupt URBs 336 // Stop and free Control and Interrupt URBs
337 usb_kill_urb(ctrl->urb); 337 usb_kill_urb(ctrl->urb);
338 if (ctrl->urb->transfer_buffer) 338 kfree(ctrl->urb->transfer_buffer);
339 kfree(ctrl->urb->transfer_buffer);
340 usb_free_urb(ctrl->urb); 339 usb_free_urb(ctrl->urb);
341 ctrl->urb = NULL; 340 ctrl->urb = NULL;
342 341
343 usb_kill_urb(intr->urb); 342 usb_kill_urb(intr->urb);
344 if (intr->urb->transfer_buffer) 343 kfree(intr->urb->transfer_buffer);
345 kfree(intr->urb->transfer_buffer);
346 usb_free_urb(intr->urb); 344 usb_free_urb(intr->urb);
347 ctrl->urb = NULL; 345 ctrl->urb = NULL;
348} 346}
@@ -457,8 +455,7 @@ st5481_setup_isocpipes(struct urb* urb[2], struct usb_device *dev,
457 err: 455 err:
458 for (j = 0; j < 2; j++) { 456 for (j = 0; j < 2; j++) {
459 if (urb[j]) { 457 if (urb[j]) {
460 if (urb[j]->transfer_buffer) 458 kfree(urb[j]->transfer_buffer);
461 kfree(urb[j]->transfer_buffer);
462 urb[j]->transfer_buffer = NULL; 459 urb[j]->transfer_buffer = NULL;
463 usb_free_urb(urb[j]); 460 usb_free_urb(urb[j]);
464 urb[j] = NULL; 461 urb[j] = NULL;
@@ -473,8 +470,7 @@ void st5481_release_isocpipes(struct urb* urb[2])
473 470
474 for (j = 0; j < 2; j++) { 471 for (j = 0; j < 2; j++) {
475 usb_kill_urb(urb[j]); 472 usb_kill_urb(urb[j]);
476 if (urb[j]->transfer_buffer) 473 kfree(urb[j]->transfer_buffer);
477 kfree(urb[j]->transfer_buffer);
478 usb_free_urb(urb[j]); 474 usb_free_urb(urb[j]);
479 urb[j] = NULL; 475 urb[j] = NULL;
480 } 476 }
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index 7baf8e488471..0352ee5f706c 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -819,14 +819,10 @@ close_w6692state(struct BCState *bcs)
819{ 819{
820 W6692Bmode(bcs, 0, bcs->channel); 820 W6692Bmode(bcs, 0, bcs->channel);
821 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { 821 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
822 if (bcs->hw.w6692.rcvbuf) { 822 kfree(bcs->hw.w6692.rcvbuf);
823 kfree(bcs->hw.w6692.rcvbuf); 823 bcs->hw.w6692.rcvbuf = NULL;
824 bcs->hw.w6692.rcvbuf = NULL; 824 kfree(bcs->blog);
825 } 825 bcs->blog = NULL;
826 if (bcs->blog) {
827 kfree(bcs->blog);
828 bcs->blog = NULL;
829 }
830 skb_queue_purge(&bcs->rqueue); 826 skb_queue_purge(&bcs->rqueue);
831 skb_queue_purge(&bcs->squeue); 827 skb_queue_purge(&bcs->squeue);
832 if (bcs->tx_skb) { 828 if (bcs->tx_skb) {
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 639582f61f41..87f59a0e2a95 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -359,8 +359,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep)
359 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { 359 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
360 /* read access -> output card info data */ 360 /* read access -> output card info data */
361 361
362 if (filep->private_data) 362 kfree(filep->private_data); /* release memory */
363 kfree(filep->private_data); /* release memory */
364 } 363 }
365 unlock_kernel(); 364 unlock_kernel();
366 return (retval); 365 return (retval);
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index d97a9be5469c..1a19a0f89428 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -364,10 +364,8 @@ isdn_ppp_release(int min, struct file *file)
364 isdn_net_hangup(&p->dev); 364 isdn_net_hangup(&p->dev);
365 } 365 }
366 for (i = 0; i < NUM_RCV_BUFFS; i++) { 366 for (i = 0; i < NUM_RCV_BUFFS; i++) {
367 if (is->rq[i].buf) { 367 kfree(is->rq[i].buf);
368 kfree(is->rq[i].buf); 368 is->rq[i].buf = NULL;
369 is->rq[i].buf = NULL;
370 }
371 } 369 }
372 is->first = is->rq + NUM_RCV_BUFFS - 1; /* receive queue */ 370 is->first = is->rq + NUM_RCV_BUFFS - 1; /* receive queue */
373 is->last = is->rq; 371 is->last = is->rq;
@@ -378,14 +376,10 @@ isdn_ppp_release(int min, struct file *file)
378 is->slcomp = NULL; 376 is->slcomp = NULL;
379#endif 377#endif
380#ifdef CONFIG_IPPP_FILTER 378#ifdef CONFIG_IPPP_FILTER
381 if (is->pass_filter) { 379 kfree(is->pass_filter);
382 kfree(is->pass_filter); 380 is->pass_filter = NULL;
383 is->pass_filter = NULL; 381 kfree(is->active_filter);
384 } 382 is->active_filter = NULL;
385 if (is->active_filter) {
386 kfree(is->active_filter);
387 is->active_filter = NULL;
388 }
389#endif 383#endif
390 384
391/* TODO: if this was the previous master: link the stuff to the new master */ 385/* TODO: if this was the previous master: link the stuff to the new master */
@@ -914,8 +908,7 @@ isdn_ppp_cleanup(void)
914 kfree(ippp_table[i]); 908 kfree(ippp_table[i]);
915 909
916#ifdef CONFIG_ISDN_MPP 910#ifdef CONFIG_ISDN_MPP
917 if (isdn_ppp_bundle_arr) 911 kfree(isdn_ppp_bundle_arr);
918 kfree(isdn_ppp_bundle_arr);
919#endif /* CONFIG_ISDN_MPP */ 912#endif /* CONFIG_ISDN_MPP */
920 913
921} 914}
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index b37ef1f06b3d..8c404b4e2482 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -712,22 +712,14 @@ isdn_tty_modem_hup(modem_info * info, int local)
712#endif 712#endif
713 info->emu.vpar[4] = 0; 713 info->emu.vpar[4] = 0;
714 info->emu.vpar[5] = 8; 714 info->emu.vpar[5] = 8;
715 if (info->dtmf_state) { 715 kfree(info->dtmf_state);
716 kfree(info->dtmf_state); 716 info->dtmf_state = NULL;
717 info->dtmf_state = NULL; 717 kfree(info->silence_state);
718 } 718 info->silence_state = NULL;
719 if (info->silence_state) { 719 kfree(info->adpcms);
720 kfree(info->silence_state); 720 info->adpcms = NULL;
721 info->silence_state = NULL; 721 kfree(info->adpcmr);
722 } 722 info->adpcmr = NULL;
723 if (info->adpcms) {
724 kfree(info->adpcms);
725 info->adpcms = NULL;
726 }
727 if (info->adpcmr) {
728 kfree(info->adpcmr);
729 info->adpcmr = NULL;
730 }
731#endif 723#endif
732 if ((info->msr & UART_MSR_RI) && 724 if ((info->msr & UART_MSR_RI) &&
733 (info->emu.mdmreg[REG_RUNG] & BIT_RUNG)) 725 (info->emu.mdmreg[REG_RUNG] & BIT_RUNG))
@@ -1721,8 +1713,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
1721 */ 1713 */
1722 timeout = jiffies + HZ; 1714 timeout = jiffies + HZ;
1723 while (!(info->lsr & UART_LSR_TEMT)) { 1715 while (!(info->lsr & UART_LSR_TEMT)) {
1724 set_current_state(TASK_INTERRUPTIBLE); 1716 schedule_timeout_interruptible(20);
1725 schedule_timeout(20);
1726 if (time_after(jiffies,timeout)) 1717 if (time_after(jiffies,timeout))
1727 break; 1718 break;
1728 } 1719 }
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
index 386df71eee74..6649f8bc9951 100644
--- a/drivers/isdn/icn/icn.c
+++ b/drivers/isdn/icn/icn.c
@@ -947,8 +947,7 @@ icn_loadproto(u_char __user * buffer, icn_card * card)
947 icn_maprelease_channel(card, 0); 947 icn_maprelease_channel(card, 0);
948 return -EIO; 948 return -EIO;
949 } 949 }
950 set_current_state(TASK_INTERRUPTIBLE); 950 schedule_timeout_interruptible(10);
951 schedule_timeout(10);
952 } 951 }
953 } 952 }
954 writeb(0x20, &sbuf_n); 953 writeb(0x20, &sbuf_n);
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index 14e1f8fbc61f..33d339700411 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -1161,12 +1161,9 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
1161 if (a) { 1161 if (a) {
1162 if (!card->leased) { 1162 if (!card->leased) {
1163 card->leased = 1; 1163 card->leased = 1;
1164 while (card->ptype == ISDN_PTYPE_UNKNOWN) { 1164 while (card->ptype == ISDN_PTYPE_UNKNOWN)
1165 set_current_state(TASK_INTERRUPTIBLE); 1165 schedule_timeout_interruptible(10);
1166 schedule_timeout(10); 1166 schedule_timeout_interruptible(10);
1167 }
1168 set_current_state(TASK_INTERRUPTIBLE);
1169 schedule_timeout(10);
1170 sprintf(cbuf, "00;FV2ON\n01;EAZ1\n02;EAZ2\n"); 1167 sprintf(cbuf, "00;FV2ON\n01;EAZ1\n02;EAZ2\n");
1171 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); 1168 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card);
1172 printk(KERN_INFO 1169 printk(KERN_INFO
diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 5de861f40816..94f21486bb24 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -561,10 +561,8 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg,
561 else 561 else
562 pcbit_fsm_event(dev, chan, EV_USR_RELEASE_REQ, NULL); 562 pcbit_fsm_event(dev, chan, EV_USR_RELEASE_REQ, NULL);
563 563
564 if (cbdata.data.setup.CalledPN) 564 kfree(cbdata.data.setup.CalledPN);
565 kfree(cbdata.data.setup.CalledPN); 565 kfree(cbdata.data.setup.CallingPN);
566 if (cbdata.data.setup.CallingPN)
567 kfree(cbdata.data.setup.CallingPN);
568 break; 566 break;
569 567
570 case MSG_CONN_CONF: 568 case MSG_CONN_CONF:
diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
index 1ebed041672d..62b7acfad8a4 100644
--- a/drivers/isdn/sc/init.c
+++ b/drivers/isdn/sc/init.c
@@ -529,8 +529,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
529 */ 529 */
530 x = 0; 530 x = 0;
531 while((inb(iobase + FIFOSTAT_OFFSET) & RF_HAS_DATA) && x < 100) { 531 while((inb(iobase + FIFOSTAT_OFFSET) & RF_HAS_DATA) && x < 100) {
532 set_current_state(TASK_INTERRUPTIBLE); 532 schedule_timeout_interruptible(1);
533 schedule_timeout(1);
534 x++; 533 x++;
535 } 534 }
536 if(x == 100) { 535 if(x == 100) {
diff --git a/drivers/isdn/sc/message.c b/drivers/isdn/sc/message.c
index ca204da3257d..0a0fe6b8039b 100644
--- a/drivers/isdn/sc/message.c
+++ b/drivers/isdn/sc/message.c
@@ -208,8 +208,7 @@ int send_and_receive(int card,
208 tries = 0; 208 tries = 0;
209 /* wait for the response */ 209 /* wait for the response */
210 while (tries < timeout) { 210 while (tries < timeout) {
211 set_current_state(TASK_INTERRUPTIBLE); 211 schedule_timeout_interruptible(1);
212 schedule_timeout(1);
213 212
214 pr_debug("SAR waiting..\n"); 213 pr_debug("SAR waiting..\n");
215 214
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index bc3e096d84f7..a0ea44c3e8b1 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -169,6 +169,25 @@ config THERM_PM72
169 This driver provides thermostat and fan control for the desktop 169 This driver provides thermostat and fan control for the desktop
170 G5 machines. 170 G5 machines.
171 171
172config WINDFARM
173 tristate "New PowerMac thermal control infrastructure"
174
175config WINDFARM_PM81
176 tristate "Support for thermal management on iMac G5"
177 depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU
178 select I2C_PMAC_SMU
179 help
180 This driver provides thermal control for the iMacG5
181
182config WINDFARM_PM91
183 tristate "Support for thermal management on PowerMac9,1"
184 depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU
185 select I2C_PMAC_SMU
186 help
187 This driver provides thermal control for the PowerMac9,1
188 which is the recent (SMU based) single CPU desktop G5
189
190
172config ANSLCD 191config ANSLCD
173 tristate "Support for ANS LCD display" 192 tristate "Support for ANS LCD display"
174 depends on ADB_CUDA && PPC_PMAC 193 depends on ADB_CUDA && PPC_PMAC
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index 236291bd48a4..f4657aa81fb0 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -26,3 +26,12 @@ obj-$(CONFIG_ADB_MACIO) += macio-adb.o
26obj-$(CONFIG_THERM_PM72) += therm_pm72.o 26obj-$(CONFIG_THERM_PM72) += therm_pm72.o
27obj-$(CONFIG_THERM_WINDTUNNEL) += therm_windtunnel.o 27obj-$(CONFIG_THERM_WINDTUNNEL) += therm_windtunnel.o
28obj-$(CONFIG_THERM_ADT746X) += therm_adt746x.o 28obj-$(CONFIG_THERM_ADT746X) += therm_adt746x.o
29obj-$(CONFIG_WINDFARM) += windfarm_core.o
30obj-$(CONFIG_WINDFARM_PM81) += windfarm_smu_controls.o \
31 windfarm_smu_sensors.o \
32 windfarm_lm75_sensor.o windfarm_pid.o \
33 windfarm_cpufreq_clamp.o windfarm_pm81.o
34obj-$(CONFIG_WINDFARM_PM91) += windfarm_smu_controls.o \
35 windfarm_smu_sensors.o \
36 windfarm_lm75_sensor.o windfarm_pid.o \
37 windfarm_cpufreq_clamp.o windfarm_pm91.o
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index 8f02c155fdc0..c0b46bceb5df 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -857,8 +857,7 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
857static void adbhid_input_unregister(int id) 857static void adbhid_input_unregister(int id)
858{ 858{
859 input_unregister_device(adbhid[id]->input); 859 input_unregister_device(adbhid[id]->input);
860 if (adbhid[id]->keycode) 860 kfree(adbhid[id]->keycode);
861 kfree(adbhid[id]->keycode);
862 kfree(adbhid[id]); 861 kfree(adbhid[id]);
863 adbhid[id] = NULL; 862 adbhid[id] = NULL;
864} 863}
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index 34f3c7e2d832..e8378274d710 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -47,13 +47,13 @@
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <asm/of_device.h> 48#include <asm/of_device.h>
49 49
50#define VERSION "0.6" 50#define VERSION "0.7"
51#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." 51#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp."
52 52
53#undef DEBUG_SMU 53#undef DEBUG_SMU
54 54
55#ifdef DEBUG_SMU 55#ifdef DEBUG_SMU
56#define DPRINTK(fmt, args...) do { printk(KERN_DEBUG fmt , ##args); } while (0) 56#define DPRINTK(fmt, args...) do { udbg_printf(KERN_DEBUG fmt , ##args); } while (0)
57#else 57#else
58#define DPRINTK(fmt, args...) do { } while (0) 58#define DPRINTK(fmt, args...) do { } while (0)
59#endif 59#endif
@@ -92,7 +92,7 @@ struct smu_device {
92 * for now, just hard code that 92 * for now, just hard code that
93 */ 93 */
94static struct smu_device *smu; 94static struct smu_device *smu;
95 95static DECLARE_MUTEX(smu_part_access);
96 96
97/* 97/*
98 * SMU driver low level stuff 98 * SMU driver low level stuff
@@ -113,9 +113,11 @@ static void smu_start_cmd(void)
113 113
114 DPRINTK("SMU: starting cmd %x, %d bytes data\n", cmd->cmd, 114 DPRINTK("SMU: starting cmd %x, %d bytes data\n", cmd->cmd,
115 cmd->data_len); 115 cmd->data_len);
116 DPRINTK("SMU: data buffer: %02x %02x %02x %02x ...\n", 116 DPRINTK("SMU: data buffer: %02x %02x %02x %02x %02x %02x %02x %02x\n",
117 ((u8 *)cmd->data_buf)[0], ((u8 *)cmd->data_buf)[1], 117 ((u8 *)cmd->data_buf)[0], ((u8 *)cmd->data_buf)[1],
118 ((u8 *)cmd->data_buf)[2], ((u8 *)cmd->data_buf)[3]); 118 ((u8 *)cmd->data_buf)[2], ((u8 *)cmd->data_buf)[3],
119 ((u8 *)cmd->data_buf)[4], ((u8 *)cmd->data_buf)[5],
120 ((u8 *)cmd->data_buf)[6], ((u8 *)cmd->data_buf)[7]);
119 121
120 /* Fill the SMU command buffer */ 122 /* Fill the SMU command buffer */
121 smu->cmd_buf->cmd = cmd->cmd; 123 smu->cmd_buf->cmd = cmd->cmd;
@@ -440,7 +442,7 @@ int smu_present(void)
440EXPORT_SYMBOL(smu_present); 442EXPORT_SYMBOL(smu_present);
441 443
442 444
443int smu_init (void) 445int __init smu_init (void)
444{ 446{
445 struct device_node *np; 447 struct device_node *np;
446 u32 *data; 448 u32 *data;
@@ -588,6 +590,8 @@ static void smu_expose_childs(void *unused)
588 sprintf(name, "smu-i2c-%02x", *reg); 590 sprintf(name, "smu-i2c-%02x", *reg);
589 of_platform_device_create(np, name, &smu->of_dev->dev); 591 of_platform_device_create(np, name, &smu->of_dev->dev);
590 } 592 }
593 if (device_is_compatible(np, "smu-sensors"))
594 of_platform_device_create(np, "smu-sensors", &smu->of_dev->dev);
591 } 595 }
592 596
593} 597}
@@ -845,6 +849,156 @@ int smu_queue_i2c(struct smu_i2c_cmd *cmd)
845 return 0; 849 return 0;
846} 850}
847 851
852/*
853 * Handling of "partitions"
854 */
855
856static int smu_read_datablock(u8 *dest, unsigned int addr, unsigned int len)
857{
858 DECLARE_COMPLETION(comp);
859 unsigned int chunk;
860 struct smu_cmd cmd;
861 int rc;
862 u8 params[8];
863
864 /* We currently use a chunk size of 0xe. We could check the
865 * SMU firmware version and use bigger sizes though
866 */
867 chunk = 0xe;
868
869 while (len) {
870 unsigned int clen = min(len, chunk);
871
872 cmd.cmd = SMU_CMD_MISC_ee_COMMAND;
873 cmd.data_len = 7;
874 cmd.data_buf = params;
875 cmd.reply_len = chunk;
876 cmd.reply_buf = dest;
877 cmd.done = smu_done_complete;
878 cmd.misc = &comp;
879 params[0] = SMU_CMD_MISC_ee_GET_DATABLOCK_REC;
880 params[1] = 0x4;
881 *((u32 *)&params[2]) = addr;
882 params[6] = clen;
883
884 rc = smu_queue_cmd(&cmd);
885 if (rc)
886 return rc;
887 wait_for_completion(&comp);
888 if (cmd.status != 0)
889 return rc;
890 if (cmd.reply_len != clen) {
891 printk(KERN_DEBUG "SMU: short read in "
892 "smu_read_datablock, got: %d, want: %d\n",
893 cmd.reply_len, clen);
894 return -EIO;
895 }
896 len -= clen;
897 addr += clen;
898 dest += clen;
899 }
900 return 0;
901}
902
903static struct smu_sdbp_header *smu_create_sdb_partition(int id)
904{
905 DECLARE_COMPLETION(comp);
906 struct smu_simple_cmd cmd;
907 unsigned int addr, len, tlen;
908 struct smu_sdbp_header *hdr;
909 struct property *prop;
910
911 /* First query the partition info */
912 smu_queue_simple(&cmd, SMU_CMD_PARTITION_COMMAND, 2,
913 smu_done_complete, &comp,
914 SMU_CMD_PARTITION_LATEST, id);
915 wait_for_completion(&comp);
916
917 /* Partition doesn't exist (or other error) */
918 if (cmd.cmd.status != 0 || cmd.cmd.reply_len != 6)
919 return NULL;
920
921 /* Fetch address and length from reply */
922 addr = *((u16 *)cmd.buffer);
923 len = cmd.buffer[3] << 2;
924 /* Calucluate total length to allocate, including the 17 bytes
925 * for "sdb-partition-XX" that we append at the end of the buffer
926 */
927 tlen = sizeof(struct property) + len + 18;
928
929 prop = kcalloc(tlen, 1, GFP_KERNEL);
930 if (prop == NULL)
931 return NULL;
932 hdr = (struct smu_sdbp_header *)(prop + 1);
933 prop->name = ((char *)prop) + tlen - 18;
934 sprintf(prop->name, "sdb-partition-%02x", id);
935 prop->length = len;
936 prop->value = (unsigned char *)hdr;
937 prop->next = NULL;
938
939 /* Read the datablock */
940 if (smu_read_datablock((u8 *)hdr, addr, len)) {
941 printk(KERN_DEBUG "SMU: datablock read failed while reading "
942 "partition %02x !\n", id);
943 goto failure;
944 }
945
946 /* Got it, check a few things and create the property */
947 if (hdr->id != id) {
948 printk(KERN_DEBUG "SMU: Reading partition %02x and got "
949 "%02x !\n", id, hdr->id);
950 goto failure;
951 }
952 if (prom_add_property(smu->of_node, prop)) {
953 printk(KERN_DEBUG "SMU: Failed creating sdb-partition-%02x "
954 "property !\n", id);
955 goto failure;
956 }
957
958 return hdr;
959 failure:
960 kfree(prop);
961 return NULL;
962}
963
964/* Note: Only allowed to return error code in pointers (using ERR_PTR)
965 * when interruptible is 1
966 */
967struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
968 int interruptible)
969{
970 char pname[32];
971 struct smu_sdbp_header *part;
972
973 if (!smu)
974 return NULL;
975
976 sprintf(pname, "sdb-partition-%02x", id);
977
978 if (interruptible) {
979 int rc;
980 rc = down_interruptible(&smu_part_access);
981 if (rc)
982 return ERR_PTR(rc);
983 } else
984 down(&smu_part_access);
985
986 part = (struct smu_sdbp_header *)get_property(smu->of_node,
987 pname, size);
988 if (part == NULL) {
989 part = smu_create_sdb_partition(id);
990 if (part != NULL && size)
991 *size = part->len << 2;
992 }
993 up(&smu_part_access);
994 return part;
995}
996
997struct smu_sdbp_header *smu_get_sdb_partition(int id, unsigned int *size)
998{
999 return __smu_get_sdb_partition(id, size, 0);
1000}
1001EXPORT_SYMBOL(smu_get_sdb_partition);
848 1002
849 1003
850/* 1004/*
@@ -918,6 +1072,14 @@ static ssize_t smu_write(struct file *file, const char __user *buf,
918 else if (hdr.cmdtype == SMU_CMDTYPE_WANTS_EVENTS) { 1072 else if (hdr.cmdtype == SMU_CMDTYPE_WANTS_EVENTS) {
919 pp->mode = smu_file_events; 1073 pp->mode = smu_file_events;
920 return 0; 1074 return 0;
1075 } else if (hdr.cmdtype == SMU_CMDTYPE_GET_PARTITION) {
1076 struct smu_sdbp_header *part;
1077 part = __smu_get_sdb_partition(hdr.cmd, NULL, 1);
1078 if (part == NULL)
1079 return -EINVAL;
1080 else if (IS_ERR(part))
1081 return PTR_ERR(part);
1082 return 0;
921 } else if (hdr.cmdtype != SMU_CMDTYPE_SMU) 1083 } else if (hdr.cmdtype != SMU_CMDTYPE_SMU)
922 return -EINVAL; 1084 return -EINVAL;
923 else if (pp->mode != smu_file_commands) 1085 else if (pp->mode != smu_file_commands)
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index cc507ceef153..3fc8cdd94c3d 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -1678,10 +1678,9 @@ static int main_control_loop(void *x)
1678 } 1678 }
1679 1679
1680 // FIXME: Deal with signals 1680 // FIXME: Deal with signals
1681 set_current_state(TASK_INTERRUPTIBLE);
1682 elapsed = jiffies - start; 1681 elapsed = jiffies - start;
1683 if (elapsed < HZ) 1682 if (elapsed < HZ)
1684 schedule_timeout(HZ - elapsed); 1683 schedule_timeout_interruptible(HZ - elapsed);
1685 } 1684 }
1686 1685
1687 out: 1686 out:
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 9bc6cc6e3845..564043508569 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2053,6 +2053,7 @@ pmu_register_sleep_notifier(struct pmu_sleep_notifier *n)
2053 __list_add(&n->list, list->prev, list); 2053 __list_add(&n->list, list->prev, list);
2054 return 0; 2054 return 0;
2055} 2055}
2056EXPORT_SYMBOL(pmu_register_sleep_notifier);
2056 2057
2057int 2058int
2058pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n) 2059pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
@@ -2063,6 +2064,7 @@ pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
2063 n->list.next = NULL; 2064 n->list.next = NULL;
2064 return 0; 2065 return 0;
2065} 2066}
2067EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
2066#endif /* CONFIG_PM */ 2068#endif /* CONFIG_PM */
2067 2069
2068#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 2070#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
@@ -2667,10 +2669,10 @@ powerbook_sleep_3400(void)
2667 asleep = 1; 2669 asleep = 1;
2668 2670
2669 /* Put the CPU into sleep mode */ 2671 /* Put the CPU into sleep mode */
2670 asm volatile("mfspr %0,1008" : "=r" (hid0) :); 2672 hid0 = mfspr(SPRN_HID0);
2671 hid0 = (hid0 & ~(HID0_NAP | HID0_DOZE)) | HID0_SLEEP; 2673 hid0 = (hid0 & ~(HID0_NAP | HID0_DOZE)) | HID0_SLEEP;
2672 asm volatile("mtspr 1008,%0" : : "r" (hid0)); 2674 mtspr(SPRN_HID0, hid0);
2673 _nmask_and_or_msr(0, MSR_POW | MSR_EE); 2675 mtmsr(mfmsr() | MSR_POW | MSR_EE);
2674 udelay(10); 2676 udelay(10);
2675 2677
2676 /* OK, we're awake again, start restoring things */ 2678 /* OK, we're awake again, start restoring things */
@@ -3139,8 +3141,6 @@ EXPORT_SYMBOL(pmu_i2c_stdsub_write);
3139EXPORT_SYMBOL(pmu_i2c_simple_read); 3141EXPORT_SYMBOL(pmu_i2c_simple_read);
3140EXPORT_SYMBOL(pmu_i2c_simple_write); 3142EXPORT_SYMBOL(pmu_i2c_simple_write);
3141#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 3143#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
3142EXPORT_SYMBOL(pmu_register_sleep_notifier);
3143EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
3144EXPORT_SYMBOL(pmu_enable_irled); 3144EXPORT_SYMBOL(pmu_enable_irled);
3145EXPORT_SYMBOL(pmu_battery_count); 3145EXPORT_SYMBOL(pmu_battery_count);
3146EXPORT_SYMBOL(pmu_batteries); 3146EXPORT_SYMBOL(pmu_batteries);
diff --git a/drivers/macintosh/windfarm.h b/drivers/macintosh/windfarm.h
new file mode 100644
index 000000000000..3f0cb0312ea3
--- /dev/null
+++ b/drivers/macintosh/windfarm.h
@@ -0,0 +1,131 @@
1/*
2 * Windfarm PowerMac thermal control.
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 */
9
10#ifndef __WINDFARM_H__
11#define __WINDFARM_H__
12
13#include <linux/kref.h>
14#include <linux/list.h>
15#include <linux/module.h>
16#include <linux/notifier.h>
17
18/* Display a 16.16 fixed point value */
19#define FIX32TOPRINT(f) ((f) >> 16),((((f) & 0xffff) * 1000) >> 16)
20
21/*
22 * Control objects
23 */
24
25struct wf_control;
26
27struct wf_control_ops {
28 int (*set_value)(struct wf_control *ct, s32 val);
29 int (*get_value)(struct wf_control *ct, s32 *val);
30 s32 (*get_min)(struct wf_control *ct);
31 s32 (*get_max)(struct wf_control *ct);
32 void (*release)(struct wf_control *ct);
33 struct module *owner;
34};
35
36struct wf_control {
37 struct list_head link;
38 struct wf_control_ops *ops;
39 char *name;
40 int type;
41 struct kref ref;
42};
43
44#define WF_CONTROL_TYPE_GENERIC 0
45#define WF_CONTROL_RPM_FAN 1
46#define WF_CONTROL_PWM_FAN 2
47
48
49/* Note about lifetime rules: wf_register_control() will initialize
50 * the kref and wf_unregister_control will decrement it, thus the
51 * object creating/disposing a given control shouldn't assume it
52 * still exists after wf_unregister_control has been called.
53 * wf_find_control will inc the refcount for you
54 */
55extern int wf_register_control(struct wf_control *ct);
56extern void wf_unregister_control(struct wf_control *ct);
57extern struct wf_control * wf_find_control(const char *name);
58extern int wf_get_control(struct wf_control *ct);
59extern void wf_put_control(struct wf_control *ct);
60
61static inline int wf_control_set_max(struct wf_control *ct)
62{
63 s32 vmax = ct->ops->get_max(ct);
64 return ct->ops->set_value(ct, vmax);
65}
66
67static inline int wf_control_set_min(struct wf_control *ct)
68{
69 s32 vmin = ct->ops->get_min(ct);
70 return ct->ops->set_value(ct, vmin);
71}
72
73/*
74 * Sensor objects
75 */
76
77struct wf_sensor;
78
79struct wf_sensor_ops {
80 int (*get_value)(struct wf_sensor *sr, s32 *val);
81 void (*release)(struct wf_sensor *sr);
82 struct module *owner;
83};
84
85struct wf_sensor {
86 struct list_head link;
87 struct wf_sensor_ops *ops;
88 char *name;
89 struct kref ref;
90};
91
92/* Same lifetime rules as controls */
93extern int wf_register_sensor(struct wf_sensor *sr);
94extern void wf_unregister_sensor(struct wf_sensor *sr);
95extern struct wf_sensor * wf_find_sensor(const char *name);
96extern int wf_get_sensor(struct wf_sensor *sr);
97extern void wf_put_sensor(struct wf_sensor *sr);
98
99/* For use by clients. Note that we are a bit racy here since
100 * notifier_block doesn't have a module owner field. I may fix
101 * it one day ...
102 *
103 * LOCKING NOTE !
104 *
105 * All "events" except WF_EVENT_TICK are called with an internal mutex
106 * held which will deadlock if you call basically any core routine.
107 * So don't ! Just take note of the event and do your actual operations
108 * from the ticker.
109 *
110 */
111extern int wf_register_client(struct notifier_block *nb);
112extern int wf_unregister_client(struct notifier_block *nb);
113
114/* Overtemp conditions. Those are refcounted */
115extern void wf_set_overtemp(void);
116extern void wf_clear_overtemp(void);
117extern int wf_is_overtemp(void);
118
119#define WF_EVENT_NEW_CONTROL 0 /* param is wf_control * */
120#define WF_EVENT_NEW_SENSOR 1 /* param is wf_sensor * */
121#define WF_EVENT_OVERTEMP 2 /* no param */
122#define WF_EVENT_NORMALTEMP 3 /* overtemp condition cleared */
123#define WF_EVENT_TICK 4 /* 1 second tick */
124
125/* Note: If that driver gets more broad use, we could replace the
126 * simplistic overtemp bits with "environmental conditions". That
127 * could then be used to also notify of things like fan failure,
128 * case open, battery conditions, ...
129 */
130
131#endif /* __WINDFARM_H__ */
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
new file mode 100644
index 000000000000..6c2a471ea6c0
--- /dev/null
+++ b/drivers/macintosh/windfarm_core.c
@@ -0,0 +1,426 @@
1/*
2 * Windfarm PowerMac thermal control. Core
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 *
9 * This core code tracks the list of sensors & controls, register
10 * clients, and holds the kernel thread used for control.
11 *
12 * TODO:
13 *
14 * Add some information about sensor/control type and data format to
15 * sensors/controls, and have the sysfs attribute stuff be moved
16 * generically here instead of hard coded in the platform specific
17 * driver as it us currently
18 *
19 * This however requires solving some annoying lifetime issues with
20 * sysfs which doesn't seem to have lifetime rules for struct attribute,
21 * I may have to create full features kobjects for every sensor/control
22 * instead which is a bit of an overkill imho
23 */
24
25#include <linux/types.h>
26#include <linux/errno.h>
27#include <linux/kernel.h>
28#include <linux/init.h>
29#include <linux/spinlock.h>
30#include <linux/smp_lock.h>
31#include <linux/kthread.h>
32#include <linux/jiffies.h>
33#include <linux/reboot.h>
34#include <linux/device.h>
35#include <linux/platform_device.h>
36
37#include "windfarm.h"
38
39#define VERSION "0.2"
40
41#undef DEBUG
42
43#ifdef DEBUG
44#define DBG(args...) printk(args)
45#else
46#define DBG(args...) do { } while(0)
47#endif
48
49static LIST_HEAD(wf_controls);
50static LIST_HEAD(wf_sensors);
51static DECLARE_MUTEX(wf_lock);
52static struct notifier_block *wf_client_list;
53static int wf_client_count;
54static unsigned int wf_overtemp;
55static unsigned int wf_overtemp_counter;
56struct task_struct *wf_thread;
57
58/*
59 * Utilities & tick thread
60 */
61
62static inline void wf_notify(int event, void *param)
63{
64 notifier_call_chain(&wf_client_list, event, param);
65}
66
67int wf_critical_overtemp(void)
68{
69 static char * critical_overtemp_path = "/sbin/critical_overtemp";
70 char *argv[] = { critical_overtemp_path, NULL };
71 static char *envp[] = { "HOME=/",
72 "TERM=linux",
73 "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
74 NULL };
75
76 return call_usermodehelper(critical_overtemp_path, argv, envp, 0);
77}
78EXPORT_SYMBOL_GPL(wf_critical_overtemp);
79
80static int wf_thread_func(void *data)
81{
82 unsigned long next, delay;
83
84 next = jiffies;
85
86 DBG("wf: thread started\n");
87
88 while(!kthread_should_stop()) {
89 try_to_freeze();
90
91 if (time_after_eq(jiffies, next)) {
92 wf_notify(WF_EVENT_TICK, NULL);
93 if (wf_overtemp) {
94 wf_overtemp_counter++;
95 /* 10 seconds overtemp, notify userland */
96 if (wf_overtemp_counter > 10)
97 wf_critical_overtemp();
98 /* 30 seconds, shutdown */
99 if (wf_overtemp_counter > 30) {
100 printk(KERN_ERR "windfarm: Overtemp "
101 "for more than 30"
102 " seconds, shutting down\n");
103 machine_power_off();
104 }
105 }
106 next += HZ;
107 }
108
109 delay = next - jiffies;
110 if (delay <= HZ)
111 schedule_timeout_interruptible(delay);
112
113 /* there should be no signal, but oh well */
114 if (signal_pending(current)) {
115 printk(KERN_WARNING "windfarm: thread got sigl !\n");
116 break;
117 }
118 }
119
120 DBG("wf: thread stopped\n");
121
122 return 0;
123}
124
125static void wf_start_thread(void)
126{
127 wf_thread = kthread_run(wf_thread_func, NULL, "kwindfarm");
128 if (IS_ERR(wf_thread)) {
129 printk(KERN_ERR "windfarm: failed to create thread,err %ld\n",
130 PTR_ERR(wf_thread));
131 wf_thread = NULL;
132 }
133}
134
135
136static void wf_stop_thread(void)
137{
138 if (wf_thread)
139 kthread_stop(wf_thread);
140 wf_thread = NULL;
141}
142
143/*
144 * Controls
145 */
146
147static void wf_control_release(struct kref *kref)
148{
149 struct wf_control *ct = container_of(kref, struct wf_control, ref);
150
151 DBG("wf: Deleting control %s\n", ct->name);
152
153 if (ct->ops && ct->ops->release)
154 ct->ops->release(ct);
155 else
156 kfree(ct);
157}
158
159int wf_register_control(struct wf_control *new_ct)
160{
161 struct wf_control *ct;
162
163 down(&wf_lock);
164 list_for_each_entry(ct, &wf_controls, link) {
165 if (!strcmp(ct->name, new_ct->name)) {
166 printk(KERN_WARNING "windfarm: trying to register"
167 " duplicate control %s\n", ct->name);
168 up(&wf_lock);
169 return -EEXIST;
170 }
171 }
172 kref_init(&new_ct->ref);
173 list_add(&new_ct->link, &wf_controls);
174
175 DBG("wf: Registered control %s\n", new_ct->name);
176
177 wf_notify(WF_EVENT_NEW_CONTROL, new_ct);
178 up(&wf_lock);
179
180 return 0;
181}
182EXPORT_SYMBOL_GPL(wf_register_control);
183
184void wf_unregister_control(struct wf_control *ct)
185{
186 down(&wf_lock);
187 list_del(&ct->link);
188 up(&wf_lock);
189
190 DBG("wf: Unregistered control %s\n", ct->name);
191
192 kref_put(&ct->ref, wf_control_release);
193}
194EXPORT_SYMBOL_GPL(wf_unregister_control);
195
196struct wf_control * wf_find_control(const char *name)
197{
198 struct wf_control *ct;
199
200 down(&wf_lock);
201 list_for_each_entry(ct, &wf_controls, link) {
202 if (!strcmp(ct->name, name)) {
203 if (wf_get_control(ct))
204 ct = NULL;
205 up(&wf_lock);
206 return ct;
207 }
208 }
209 up(&wf_lock);
210 return NULL;
211}
212EXPORT_SYMBOL_GPL(wf_find_control);
213
214int wf_get_control(struct wf_control *ct)
215{
216 if (!try_module_get(ct->ops->owner))
217 return -ENODEV;
218 kref_get(&ct->ref);
219 return 0;
220}
221EXPORT_SYMBOL_GPL(wf_get_control);
222
223void wf_put_control(struct wf_control *ct)
224{
225 struct module *mod = ct->ops->owner;
226 kref_put(&ct->ref, wf_control_release);
227 module_put(mod);
228}
229EXPORT_SYMBOL_GPL(wf_put_control);
230
231
232/*
233 * Sensors
234 */
235
236
237static void wf_sensor_release(struct kref *kref)
238{
239 struct wf_sensor *sr = container_of(kref, struct wf_sensor, ref);
240
241 DBG("wf: Deleting sensor %s\n", sr->name);
242
243 if (sr->ops && sr->ops->release)
244 sr->ops->release(sr);
245 else
246 kfree(sr);
247}
248
249int wf_register_sensor(struct wf_sensor *new_sr)
250{
251 struct wf_sensor *sr;
252
253 down(&wf_lock);
254 list_for_each_entry(sr, &wf_sensors, link) {
255 if (!strcmp(sr->name, new_sr->name)) {
256 printk(KERN_WARNING "windfarm: trying to register"
257 " duplicate sensor %s\n", sr->name);
258 up(&wf_lock);
259 return -EEXIST;
260 }
261 }
262 kref_init(&new_sr->ref);
263 list_add(&new_sr->link, &wf_sensors);
264
265 DBG("wf: Registered sensor %s\n", new_sr->name);
266
267 wf_notify(WF_EVENT_NEW_SENSOR, new_sr);
268 up(&wf_lock);
269
270 return 0;
271}
272EXPORT_SYMBOL_GPL(wf_register_sensor);
273
274void wf_unregister_sensor(struct wf_sensor *sr)
275{
276 down(&wf_lock);
277 list_del(&sr->link);
278 up(&wf_lock);
279
280 DBG("wf: Unregistered sensor %s\n", sr->name);
281
282 wf_put_sensor(sr);
283}
284EXPORT_SYMBOL_GPL(wf_unregister_sensor);
285
286struct wf_sensor * wf_find_sensor(const char *name)
287{
288 struct wf_sensor *sr;
289
290 down(&wf_lock);
291 list_for_each_entry(sr, &wf_sensors, link) {
292 if (!strcmp(sr->name, name)) {
293 if (wf_get_sensor(sr))
294 sr = NULL;
295 up(&wf_lock);
296 return sr;
297 }
298 }
299 up(&wf_lock);
300 return NULL;
301}
302EXPORT_SYMBOL_GPL(wf_find_sensor);
303
304int wf_get_sensor(struct wf_sensor *sr)
305{
306 if (!try_module_get(sr->ops->owner))
307 return -ENODEV;
308 kref_get(&sr->ref);
309 return 0;
310}
311EXPORT_SYMBOL_GPL(wf_get_sensor);
312
313void wf_put_sensor(struct wf_sensor *sr)
314{
315 struct module *mod = sr->ops->owner;
316 kref_put(&sr->ref, wf_sensor_release);
317 module_put(mod);
318}
319EXPORT_SYMBOL_GPL(wf_put_sensor);
320
321
322/*
323 * Client & notification
324 */
325
326int wf_register_client(struct notifier_block *nb)
327{
328 int rc;
329 struct wf_control *ct;
330 struct wf_sensor *sr;
331
332 down(&wf_lock);
333 rc = notifier_chain_register(&wf_client_list, nb);
334 if (rc != 0)
335 goto bail;
336 wf_client_count++;
337 list_for_each_entry(ct, &wf_controls, link)
338 wf_notify(WF_EVENT_NEW_CONTROL, ct);
339 list_for_each_entry(sr, &wf_sensors, link)
340 wf_notify(WF_EVENT_NEW_SENSOR, sr);
341 if (wf_client_count == 1)
342 wf_start_thread();
343 bail:
344 up(&wf_lock);
345 return rc;
346}
347EXPORT_SYMBOL_GPL(wf_register_client);
348
349int wf_unregister_client(struct notifier_block *nb)
350{
351 down(&wf_lock);
352 notifier_chain_unregister(&wf_client_list, nb);
353 wf_client_count++;
354 if (wf_client_count == 0)
355 wf_stop_thread();
356 up(&wf_lock);
357
358 return 0;
359}
360EXPORT_SYMBOL_GPL(wf_unregister_client);
361
362void wf_set_overtemp(void)
363{
364 down(&wf_lock);
365 wf_overtemp++;
366 if (wf_overtemp == 1) {
367 printk(KERN_WARNING "windfarm: Overtemp condition detected !\n");
368 wf_overtemp_counter = 0;
369 wf_notify(WF_EVENT_OVERTEMP, NULL);
370 }
371 up(&wf_lock);
372}
373EXPORT_SYMBOL_GPL(wf_set_overtemp);
374
375void wf_clear_overtemp(void)
376{
377 down(&wf_lock);
378 WARN_ON(wf_overtemp == 0);
379 if (wf_overtemp == 0) {
380 up(&wf_lock);
381 return;
382 }
383 wf_overtemp--;
384 if (wf_overtemp == 0) {
385 printk(KERN_WARNING "windfarm: Overtemp condition cleared !\n");
386 wf_notify(WF_EVENT_NORMALTEMP, NULL);
387 }
388 up(&wf_lock);
389}
390EXPORT_SYMBOL_GPL(wf_clear_overtemp);
391
392int wf_is_overtemp(void)
393{
394 return (wf_overtemp != 0);
395}
396EXPORT_SYMBOL_GPL(wf_is_overtemp);
397
398static struct platform_device wf_platform_device = {
399 .name = "windfarm",
400};
401
402static int __init windfarm_core_init(void)
403{
404 DBG("wf: core loaded\n");
405
406 platform_device_register(&wf_platform_device);
407 return 0;
408}
409
410static void __exit windfarm_core_exit(void)
411{
412 BUG_ON(wf_client_count != 0);
413
414 DBG("wf: core unloaded\n");
415
416 platform_device_unregister(&wf_platform_device);
417}
418
419
420module_init(windfarm_core_init);
421module_exit(windfarm_core_exit);
422
423MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
424MODULE_DESCRIPTION("Core component of PowerMac thermal control");
425MODULE_LICENSE("GPL");
426
diff --git a/drivers/macintosh/windfarm_cpufreq_clamp.c b/drivers/macintosh/windfarm_cpufreq_clamp.c
new file mode 100644
index 000000000000..607dbaca69c9
--- /dev/null
+++ b/drivers/macintosh/windfarm_cpufreq_clamp.c
@@ -0,0 +1,105 @@
1#include <linux/config.h>
2#include <linux/types.h>
3#include <linux/errno.h>
4#include <linux/kernel.h>
5#include <linux/delay.h>
6#include <linux/slab.h>
7#include <linux/init.h>
8#include <linux/wait.h>
9#include <linux/cpufreq.h>
10
11#include "windfarm.h"
12
13#define VERSION "0.3"
14
15static int clamped;
16static struct wf_control *clamp_control;
17
18static int clamp_notifier_call(struct notifier_block *self,
19 unsigned long event, void *data)
20{
21 struct cpufreq_policy *p = data;
22 unsigned long max_freq;
23
24 if (event != CPUFREQ_ADJUST)
25 return 0;
26
27 max_freq = clamped ? (p->cpuinfo.min_freq) : (p->cpuinfo.max_freq);
28 cpufreq_verify_within_limits(p, 0, max_freq);
29
30 return 0;
31}
32
33static struct notifier_block clamp_notifier = {
34 .notifier_call = clamp_notifier_call,
35};
36
37static int clamp_set(struct wf_control *ct, s32 value)
38{
39 if (value)
40 printk(KERN_INFO "windfarm: Clamping CPU frequency to "
41 "minimum !\n");
42 else
43 printk(KERN_INFO "windfarm: CPU frequency unclamped !\n");
44 clamped = value;
45 cpufreq_update_policy(0);
46 return 0;
47}
48
49static int clamp_get(struct wf_control *ct, s32 *value)
50{
51 *value = clamped;
52 return 0;
53}
54
55static s32 clamp_min(struct wf_control *ct)
56{
57 return 0;
58}
59
60static s32 clamp_max(struct wf_control *ct)
61{
62 return 1;
63}
64
65static struct wf_control_ops clamp_ops = {
66 .set_value = clamp_set,
67 .get_value = clamp_get,
68 .get_min = clamp_min,
69 .get_max = clamp_max,
70 .owner = THIS_MODULE,
71};
72
73static int __init wf_cpufreq_clamp_init(void)
74{
75 struct wf_control *clamp;
76
77 clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL);
78 if (clamp == NULL)
79 return -ENOMEM;
80 cpufreq_register_notifier(&clamp_notifier, CPUFREQ_POLICY_NOTIFIER);
81 clamp->ops = &clamp_ops;
82 clamp->name = "cpufreq-clamp";
83 if (wf_register_control(clamp))
84 goto fail;
85 clamp_control = clamp;
86 return 0;
87 fail:
88 kfree(clamp);
89 return -ENODEV;
90}
91
92static void __exit wf_cpufreq_clamp_exit(void)
93{
94 if (clamp_control)
95 wf_unregister_control(clamp_control);
96}
97
98
99module_init(wf_cpufreq_clamp_init);
100module_exit(wf_cpufreq_clamp_exit);
101
102MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
103MODULE_DESCRIPTION("CPU frequency clamp for PowerMacs thermal control");
104MODULE_LICENSE("GPL");
105
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
new file mode 100644
index 000000000000..a0a41ad0f2b5
--- /dev/null
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -0,0 +1,263 @@
1/*
2 * Windfarm PowerMac thermal control. LM75 sensor
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 */
9
10#include <linux/types.h>
11#include <linux/errno.h>
12#include <linux/kernel.h>
13#include <linux/delay.h>
14#include <linux/slab.h>
15#include <linux/init.h>
16#include <linux/wait.h>
17#include <linux/i2c.h>
18#include <linux/i2c-dev.h>
19#include <asm/prom.h>
20#include <asm/machdep.h>
21#include <asm/io.h>
22#include <asm/system.h>
23#include <asm/sections.h>
24
25#include "windfarm.h"
26
27#define VERSION "0.1"
28
29#undef DEBUG
30
31#ifdef DEBUG
32#define DBG(args...) printk(args)
33#else
34#define DBG(args...) do { } while(0)
35#endif
36
37struct wf_lm75_sensor {
38 int ds1775 : 1;
39 int inited : 1;
40 struct i2c_client i2c;
41 struct wf_sensor sens;
42};
43#define wf_to_lm75(c) container_of(c, struct wf_lm75_sensor, sens)
44#define i2c_to_lm75(c) container_of(c, struct wf_lm75_sensor, i2c)
45
46static int wf_lm75_attach(struct i2c_adapter *adapter);
47static int wf_lm75_detach(struct i2c_client *client);
48
49static struct i2c_driver wf_lm75_driver = {
50 .owner = THIS_MODULE,
51 .name = "wf_lm75",
52 .flags = I2C_DF_NOTIFY,
53 .attach_adapter = wf_lm75_attach,
54 .detach_client = wf_lm75_detach,
55};
56
57static int wf_lm75_get(struct wf_sensor *sr, s32 *value)
58{
59 struct wf_lm75_sensor *lm = wf_to_lm75(sr);
60 s32 data;
61
62 if (lm->i2c.adapter == NULL)
63 return -ENODEV;
64
65 /* Init chip if necessary */
66 if (!lm->inited) {
67 u8 cfg_new, cfg = (u8)i2c_smbus_read_byte_data(&lm->i2c, 1);
68
69 DBG("wf_lm75: Initializing %s, cfg was: %02x\n",
70 sr->name, cfg);
71
72 /* clear shutdown bit, keep other settings as left by
73 * the firmware for now
74 */
75 cfg_new = cfg & ~0x01;
76 i2c_smbus_write_byte_data(&lm->i2c, 1, cfg_new);
77 lm->inited = 1;
78
79 /* If we just powered it up, let's wait 200 ms */
80 msleep(200);
81 }
82
83 /* Read temperature register */
84 data = (s32)le16_to_cpu(i2c_smbus_read_word_data(&lm->i2c, 0));
85 data <<= 8;
86 *value = data;
87
88 return 0;
89}
90
91static void wf_lm75_release(struct wf_sensor *sr)
92{
93 struct wf_lm75_sensor *lm = wf_to_lm75(sr);
94
95 /* check if client is registered and detach from i2c */
96 if (lm->i2c.adapter) {
97 i2c_detach_client(&lm->i2c);
98 lm->i2c.adapter = NULL;
99 }
100
101 kfree(lm);
102}
103
104static struct wf_sensor_ops wf_lm75_ops = {
105 .get_value = wf_lm75_get,
106 .release = wf_lm75_release,
107 .owner = THIS_MODULE,
108};
109
110static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
111 u8 addr, int ds1775,
112 const char *loc)
113{
114 struct wf_lm75_sensor *lm;
115
116 DBG("wf_lm75: creating %s device at address 0x%02x\n",
117 ds1775 ? "ds1775" : "lm75", addr);
118
119 lm = kmalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL);
120 if (lm == NULL)
121 return NULL;
122 memset(lm, 0, sizeof(struct wf_lm75_sensor));
123
124 /* Usual rant about sensor names not beeing very consistent in
125 * the device-tree, oh well ...
126 * Add more entries below as you deal with more setups
127 */
128 if (!strcmp(loc, "Hard drive") || !strcmp(loc, "DRIVE BAY"))
129 lm->sens.name = "hd-temp";
130 else
131 goto fail;
132
133 lm->inited = 0;
134 lm->sens.ops = &wf_lm75_ops;
135 lm->ds1775 = ds1775;
136 lm->i2c.addr = (addr >> 1) & 0x7f;
137 lm->i2c.adapter = adapter;
138 lm->i2c.driver = &wf_lm75_driver;
139 strncpy(lm->i2c.name, lm->sens.name, I2C_NAME_SIZE-1);
140
141 if (i2c_attach_client(&lm->i2c)) {
142 printk(KERN_ERR "windfarm: failed to attach %s %s to i2c\n",
143 ds1775 ? "ds1775" : "lm75", lm->i2c.name);
144 goto fail;
145 }
146
147 if (wf_register_sensor(&lm->sens)) {
148 i2c_detach_client(&lm->i2c);
149 goto fail;
150 }
151
152 return lm;
153 fail:
154 kfree(lm);
155 return NULL;
156}
157
158static int wf_lm75_attach(struct i2c_adapter *adapter)
159{
160 u8 bus_id;
161 struct device_node *smu, *bus, *dev;
162
163 /* We currently only deal with LM75's hanging off the SMU
164 * i2c busses. If we extend that driver to other/older
165 * machines, we should split this function into SMU-i2c,
166 * keywest-i2c, PMU-i2c, ...
167 */
168
169 DBG("wf_lm75: adapter %s detected\n", adapter->name);
170
171 if (strncmp(adapter->name, "smu-i2c-", 8) != 0)
172 return 0;
173 smu = of_find_node_by_type(NULL, "smu");
174 if (smu == NULL)
175 return 0;
176
177 /* Look for the bus in the device-tree */
178 bus_id = (u8)simple_strtoul(adapter->name + 8, NULL, 16);
179
180 DBG("wf_lm75: bus ID is %x\n", bus_id);
181
182 /* Look for sensors subdir */
183 for (bus = NULL;
184 (bus = of_get_next_child(smu, bus)) != NULL;) {
185 u32 *reg;
186
187 if (strcmp(bus->name, "i2c"))
188 continue;
189 reg = (u32 *)get_property(bus, "reg", NULL);
190 if (reg == NULL)
191 continue;
192 if (bus_id == *reg)
193 break;
194 }
195 of_node_put(smu);
196 if (bus == NULL) {
197 printk(KERN_WARNING "windfarm: SMU i2c bus 0x%x not found"
198 " in device-tree !\n", bus_id);
199 return 0;
200 }
201
202 DBG("wf_lm75: bus found, looking for device...\n");
203
204 /* Now look for lm75(s) in there */
205 for (dev = NULL;
206 (dev = of_get_next_child(bus, dev)) != NULL;) {
207 const char *loc =
208 get_property(dev, "hwsensor-location", NULL);
209 u32 *reg = (u32 *)get_property(dev, "reg", NULL);
210 DBG(" dev: %s... (loc: %p, reg: %p)\n", dev->name, loc, reg);
211 if (loc == NULL || reg == NULL)
212 continue;
213 /* real lm75 */
214 if (device_is_compatible(dev, "lm75"))
215 wf_lm75_create(adapter, *reg, 0, loc);
216 /* ds1775 (compatible, better resolution */
217 else if (device_is_compatible(dev, "ds1775"))
218 wf_lm75_create(adapter, *reg, 1, loc);
219 }
220
221 of_node_put(bus);
222
223 return 0;
224}
225
226static int wf_lm75_detach(struct i2c_client *client)
227{
228 struct wf_lm75_sensor *lm = i2c_to_lm75(client);
229
230 DBG("wf_lm75: i2c detatch called for %s\n", lm->sens.name);
231
232 /* Mark client detached */
233 lm->i2c.adapter = NULL;
234
235 /* release sensor */
236 wf_unregister_sensor(&lm->sens);
237
238 return 0;
239}
240
241static int __init wf_lm75_sensor_init(void)
242{
243 int rc;
244
245 rc = i2c_add_driver(&wf_lm75_driver);
246 if (rc < 0)
247 return rc;
248 return 0;
249}
250
251static void __exit wf_lm75_sensor_exit(void)
252{
253 i2c_del_driver(&wf_lm75_driver);
254}
255
256
257module_init(wf_lm75_sensor_init);
258module_exit(wf_lm75_sensor_exit);
259
260MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
261MODULE_DESCRIPTION("LM75 sensor objects for PowerMacs thermal control");
262MODULE_LICENSE("GPL");
263
diff --git a/drivers/macintosh/windfarm_pid.c b/drivers/macintosh/windfarm_pid.c
new file mode 100644
index 000000000000..2e803b368757
--- /dev/null
+++ b/drivers/macintosh/windfarm_pid.c
@@ -0,0 +1,145 @@
1/*
2 * Windfarm PowerMac thermal control. Generic PID helpers
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 */
9
10#include <linux/types.h>
11#include <linux/errno.h>
12#include <linux/kernel.h>
13#include <linux/string.h>
14#include <linux/module.h>
15
16#include "windfarm_pid.h"
17
18#undef DEBUG
19
20#ifdef DEBUG
21#define DBG(args...) printk(args)
22#else
23#define DBG(args...) do { } while(0)
24#endif
25
26void wf_pid_init(struct wf_pid_state *st, struct wf_pid_param *param)
27{
28 memset(st, 0, sizeof(struct wf_pid_state));
29 st->param = *param;
30 st->first = 1;
31}
32EXPORT_SYMBOL_GPL(wf_pid_init);
33
34s32 wf_pid_run(struct wf_pid_state *st, s32 new_sample)
35{
36 s64 error, integ, deriv;
37 s32 target;
38 int i, hlen = st->param.history_len;
39
40 /* Calculate error term */
41 error = new_sample - st->param.itarget;
42
43 /* Get samples into our history buffer */
44 if (st->first) {
45 for (i = 0; i < hlen; i++) {
46 st->samples[i] = new_sample;
47 st->errors[i] = error;
48 }
49 st->first = 0;
50 st->index = 0;
51 } else {
52 st->index = (st->index + 1) % hlen;
53 st->samples[st->index] = new_sample;
54 st->errors[st->index] = error;
55 }
56
57 /* Calculate integral term */
58 for (i = 0, integ = 0; i < hlen; i++)
59 integ += st->errors[(st->index + hlen - i) % hlen];
60 integ *= st->param.interval;
61
62 /* Calculate derivative term */
63 deriv = st->errors[st->index] -
64 st->errors[(st->index + hlen - 1) % hlen];
65 deriv /= st->param.interval;
66
67 /* Calculate target */
68 target = (s32)((integ * (s64)st->param.gr + deriv * (s64)st->param.gd +
69 error * (s64)st->param.gp) >> 36);
70 if (st->param.additive)
71 target += st->target;
72 target = max(target, st->param.min);
73 target = min(target, st->param.max);
74 st->target = target;
75
76 return st->target;
77}
78EXPORT_SYMBOL_GPL(wf_pid_run);
79
80void wf_cpu_pid_init(struct wf_cpu_pid_state *st,
81 struct wf_cpu_pid_param *param)
82{
83 memset(st, 0, sizeof(struct wf_cpu_pid_state));
84 st->param = *param;
85 st->first = 1;
86}
87EXPORT_SYMBOL_GPL(wf_cpu_pid_init);
88
89s32 wf_cpu_pid_run(struct wf_cpu_pid_state *st, s32 new_power, s32 new_temp)
90{
91 s64 error, integ, deriv, prop;
92 s32 target, sval, adj;
93 int i, hlen = st->param.history_len;
94
95 /* Calculate error term */
96 error = st->param.pmaxadj - new_power;
97
98 /* Get samples into our history buffer */
99 if (st->first) {
100 for (i = 0; i < hlen; i++) {
101 st->powers[i] = new_power;
102 st->errors[i] = error;
103 }
104 st->temps[0] = st->temps[1] = new_temp;
105 st->first = 0;
106 st->index = st->tindex = 0;
107 } else {
108 st->index = (st->index + 1) % hlen;
109 st->powers[st->index] = new_power;
110 st->errors[st->index] = error;
111 st->tindex = (st->tindex + 1) % 2;
112 st->temps[st->tindex] = new_temp;
113 }
114
115 /* Calculate integral term */
116 for (i = 0, integ = 0; i < hlen; i++)
117 integ += st->errors[(st->index + hlen - i) % hlen];
118 integ *= st->param.interval;
119 integ *= st->param.gr;
120 sval = st->param.tmax - ((integ >> 20) & 0xffffffff);
121 adj = min(st->param.ttarget, sval);
122
123 DBG("integ: %lx, sval: %lx, adj: %lx\n", integ, sval, adj);
124
125 /* Calculate derivative term */
126 deriv = st->temps[st->tindex] -
127 st->temps[(st->tindex + 2 - 1) % 2];
128 deriv /= st->param.interval;
129 deriv *= st->param.gd;
130
131 /* Calculate proportional term */
132 prop = (new_temp - adj);
133 prop *= st->param.gp;
134
135 DBG("deriv: %lx, prop: %lx\n", deriv, prop);
136
137 /* Calculate target */
138 target = st->target + (s32)((deriv + prop) >> 36);
139 target = max(target, st->param.min);
140 target = min(target, st->param.max);
141 st->target = target;
142
143 return st->target;
144}
145EXPORT_SYMBOL_GPL(wf_cpu_pid_run);
diff --git a/drivers/macintosh/windfarm_pid.h b/drivers/macintosh/windfarm_pid.h
new file mode 100644
index 000000000000..a364c2a2499c
--- /dev/null
+++ b/drivers/macintosh/windfarm_pid.h
@@ -0,0 +1,84 @@
1/*
2 * Windfarm PowerMac thermal control. Generic PID helpers
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 *
9 * This is a pair of generic PID helpers that can be used by
10 * control loops. One is the basic PID implementation, the
11 * other one is more specifically tailored to the loops used
12 * for CPU control with 2 input sample types (temp and power)
13 */
14
15/*
16 * *** Simple PID ***
17 */
18
19#define WF_PID_MAX_HISTORY 32
20
21/* This parameter array is passed to the PID algorithm. Currently,
22 * we don't support changing parameters on the fly as it's not needed
23 * but could be implemented (with necessary adjustment of the history
24 * buffer
25 */
26struct wf_pid_param {
27 int interval; /* Interval between samples in seconds */
28 int history_len; /* Size of history buffer */
29 int additive; /* 1: target relative to previous value */
30 s32 gd, gp, gr; /* PID gains */
31 s32 itarget; /* PID input target */
32 s32 min,max; /* min and max target values */
33};
34
35struct wf_pid_state {
36 int first; /* first run of the loop */
37 int index; /* index of current sample */
38 s32 target; /* current target value */
39 s32 samples[WF_PID_MAX_HISTORY]; /* samples history buffer */
40 s32 errors[WF_PID_MAX_HISTORY]; /* error history buffer */
41
42 struct wf_pid_param param;
43};
44
45extern void wf_pid_init(struct wf_pid_state *st, struct wf_pid_param *param);
46extern s32 wf_pid_run(struct wf_pid_state *st, s32 sample);
47
48
49/*
50 * *** CPU PID ***
51 */
52
53#define WF_CPU_PID_MAX_HISTORY 32
54
55/* This parameter array is passed to the CPU PID algorithm. Currently,
56 * we don't support changing parameters on the fly as it's not needed
57 * but could be implemented (with necessary adjustment of the history
58 * buffer
59 */
60struct wf_cpu_pid_param {
61 int interval; /* Interval between samples in seconds */
62 int history_len; /* Size of history buffer */
63 s32 gd, gp, gr; /* PID gains */
64 s32 pmaxadj; /* PID max power adjust */
65 s32 ttarget; /* PID input target */
66 s32 tmax; /* PID input max */
67 s32 min,max; /* min and max target values */
68};
69
70struct wf_cpu_pid_state {
71 int first; /* first run of the loop */
72 int index; /* index of current power */
73 int tindex; /* index of current temp */
74 s32 target; /* current target value */
75 s32 powers[WF_PID_MAX_HISTORY]; /* power history buffer */
76 s32 errors[WF_PID_MAX_HISTORY]; /* error history buffer */
77 s32 temps[2]; /* temp. history buffer */
78
79 struct wf_cpu_pid_param param;
80};
81
82extern void wf_cpu_pid_init(struct wf_cpu_pid_state *st,
83 struct wf_cpu_pid_param *param);
84extern s32 wf_cpu_pid_run(struct wf_cpu_pid_state *st, s32 power, s32 temp);
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c
new file mode 100644
index 000000000000..322c74b2687f
--- /dev/null
+++ b/drivers/macintosh/windfarm_pm81.c
@@ -0,0 +1,879 @@
1/*
2 * Windfarm PowerMac thermal control. iMac G5
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 *
9 * The algorithm used is the PID control algorithm, used the same
10 * way the published Darwin code does, using the same values that
11 * are present in the Darwin 8.2 snapshot property lists (note however
12 * that none of the code has been re-used, it's a complete re-implementation
13 *
14 * The various control loops found in Darwin config file are:
15 *
16 * PowerMac8,1 and PowerMac8,2
17 * ===========================
18 *
19 * System Fans control loop. Different based on models. In addition to the
20 * usual PID algorithm, the control loop gets 2 additional pairs of linear
21 * scaling factors (scale/offsets) expressed as 4.12 fixed point values
22 * signed offset, unsigned scale)
23 *
24 * The targets are modified such as:
25 * - the linked control (second control) gets the target value as-is
26 * (typically the drive fan)
27 * - the main control (first control) gets the target value scaled with
28 * the first pair of factors, and is then modified as below
29 * - the value of the target of the CPU Fan control loop is retreived,
30 * scaled with the second pair of factors, and the max of that and
31 * the scaled target is applied to the main control.
32 *
33 * # model_id: 2
34 * controls : system-fan, drive-bay-fan
35 * sensors : hd-temp
36 * PID params : G_d = 0x15400000
37 * G_p = 0x00200000
38 * G_r = 0x000002fd
39 * History = 2 entries
40 * Input target = 0x3a0000
41 * Interval = 5s
42 * linear-factors : offset = 0xff38 scale = 0x0ccd
43 * offset = 0x0208 scale = 0x07ae
44 *
45 * # model_id: 3
46 * controls : system-fan, drive-bay-fan
47 * sensors : hd-temp
48 * PID params : G_d = 0x08e00000
49 * G_p = 0x00566666
50 * G_r = 0x0000072b
51 * History = 2 entries
52 * Input target = 0x350000
53 * Interval = 5s
54 * linear-factors : offset = 0xff38 scale = 0x0ccd
55 * offset = 0x0000 scale = 0x0000
56 *
57 * # model_id: 5
58 * controls : system-fan
59 * sensors : hd-temp
60 * PID params : G_d = 0x15400000
61 * G_p = 0x00233333
62 * G_r = 0x000002fd
63 * History = 2 entries
64 * Input target = 0x3a0000
65 * Interval = 5s
66 * linear-factors : offset = 0x0000 scale = 0x1000
67 * offset = 0x0091 scale = 0x0bae
68 *
69 * CPU Fan control loop. The loop is identical for all models. it
70 * has an additional pair of scaling factor. This is used to scale the
71 * systems fan control loop target result (the one before it gets scaled
72 * by the System Fans control loop itself). Then, the max value of the
73 * calculated target value and system fan value is sent to the fans
74 *
75 * controls : cpu-fan
76 * sensors : cpu-temp cpu-power
77 * PID params : From SMU sdb partition
78 * linear-factors : offset = 0xfb50 scale = 0x1000
79 *
80 * CPU Slew control loop. Not implemented. The cpufreq driver in linux is
81 * completely separate for now, though we could find a way to link it, either
82 * as a client reacting to overtemp notifications, or directling monitoring
83 * the CPU temperature
84 *
85 * WARNING ! The CPU control loop requires the CPU tmax for the current
86 * operating point. However, we currently are completely separated from
87 * the cpufreq driver and thus do not know what the current operating
88 * point is. Fortunately, we also do not have any hardware supporting anything
89 * but operating point 0 at the moment, thus we just peek that value directly
90 * from the SDB partition. If we ever end up with actually slewing the system
91 * clock and thus changing operating points, we'll have to find a way to
92 * communicate with the CPU freq driver;
93 *
94 */
95
96#include <linux/types.h>
97#include <linux/errno.h>
98#include <linux/kernel.h>
99#include <linux/delay.h>
100#include <linux/slab.h>
101#include <linux/init.h>
102#include <linux/spinlock.h>
103#include <linux/wait.h>
104#include <linux/kmod.h>
105#include <linux/device.h>
106#include <linux/platform_device.h>
107#include <asm/prom.h>
108#include <asm/machdep.h>
109#include <asm/io.h>
110#include <asm/system.h>
111#include <asm/sections.h>
112#include <asm/smu.h>
113
114#include "windfarm.h"
115#include "windfarm_pid.h"
116
117#define VERSION "0.4"
118
119#undef DEBUG
120
121#ifdef DEBUG
122#define DBG(args...) printk(args)
123#else
124#define DBG(args...) do { } while(0)
125#endif
126
127/* define this to force CPU overtemp to 74 degree, useful for testing
128 * the overtemp code
129 */
130#undef HACKED_OVERTEMP
131
132static int wf_smu_mach_model; /* machine model id */
133
134static struct device *wf_smu_dev;
135
136/* Controls & sensors */
137static struct wf_sensor *sensor_cpu_power;
138static struct wf_sensor *sensor_cpu_temp;
139static struct wf_sensor *sensor_hd_temp;
140static struct wf_control *fan_cpu_main;
141static struct wf_control *fan_hd;
142static struct wf_control *fan_system;
143static struct wf_control *cpufreq_clamp;
144
145/* Set to kick the control loop into life */
146static int wf_smu_all_controls_ok, wf_smu_all_sensors_ok, wf_smu_started;
147
148/* Failure handling.. could be nicer */
149#define FAILURE_FAN 0x01
150#define FAILURE_SENSOR 0x02
151#define FAILURE_OVERTEMP 0x04
152
153static unsigned int wf_smu_failure_state;
154static int wf_smu_readjust, wf_smu_skipping;
155
156/*
157 * ****** System Fans Control Loop ******
158 *
159 */
160
161/* Parameters for the System Fans control loop. Parameters
162 * not in this table such as interval, history size, ...
163 * are common to all versions and thus hard coded for now.
164 */
165struct wf_smu_sys_fans_param {
166 int model_id;
167 s32 itarget;
168 s32 gd, gp, gr;
169
170 s16 offset0;
171 u16 scale0;
172 s16 offset1;
173 u16 scale1;
174};
175
176#define WF_SMU_SYS_FANS_INTERVAL 5
177#define WF_SMU_SYS_FANS_HISTORY_SIZE 2
178
179/* State data used by the system fans control loop
180 */
181struct wf_smu_sys_fans_state {
182 int ticks;
183 s32 sys_setpoint;
184 s32 hd_setpoint;
185 s16 offset0;
186 u16 scale0;
187 s16 offset1;
188 u16 scale1;
189 struct wf_pid_state pid;
190};
191
192/*
193 * Configs for SMU Sytem Fan control loop
194 */
195static struct wf_smu_sys_fans_param wf_smu_sys_all_params[] = {
196 /* Model ID 2 */
197 {
198 .model_id = 2,
199 .itarget = 0x3a0000,
200 .gd = 0x15400000,
201 .gp = 0x00200000,
202 .gr = 0x000002fd,
203 .offset0 = 0xff38,
204 .scale0 = 0x0ccd,
205 .offset1 = 0x0208,
206 .scale1 = 0x07ae,
207 },
208 /* Model ID 3 */
209 {
210 .model_id = 2,
211 .itarget = 0x350000,
212 .gd = 0x08e00000,
213 .gp = 0x00566666,
214 .gr = 0x0000072b,
215 .offset0 = 0xff38,
216 .scale0 = 0x0ccd,
217 .offset1 = 0x0000,
218 .scale1 = 0x0000,
219 },
220 /* Model ID 5 */
221 {
222 .model_id = 2,
223 .itarget = 0x3a0000,
224 .gd = 0x15400000,
225 .gp = 0x00233333,
226 .gr = 0x000002fd,
227 .offset0 = 0x0000,
228 .scale0 = 0x1000,
229 .offset1 = 0x0091,
230 .scale1 = 0x0bae,
231 },
232};
233#define WF_SMU_SYS_FANS_NUM_CONFIGS ARRAY_SIZE(wf_smu_sys_all_params)
234
235static struct wf_smu_sys_fans_state *wf_smu_sys_fans;
236
237/*
238 * ****** CPU Fans Control Loop ******
239 *
240 */
241
242
243#define WF_SMU_CPU_FANS_INTERVAL 1
244#define WF_SMU_CPU_FANS_MAX_HISTORY 16
245#define WF_SMU_CPU_FANS_SIBLING_SCALE 0x00001000
246#define WF_SMU_CPU_FANS_SIBLING_OFFSET 0xfffffb50
247
248/* State data used by the cpu fans control loop
249 */
250struct wf_smu_cpu_fans_state {
251 int ticks;
252 s32 cpu_setpoint;
253 s32 scale;
254 s32 offset;
255 struct wf_cpu_pid_state pid;
256};
257
258static struct wf_smu_cpu_fans_state *wf_smu_cpu_fans;
259
260
261
262/*
263 * ***** Implementation *****
264 *
265 */
266
267static void wf_smu_create_sys_fans(void)
268{
269 struct wf_smu_sys_fans_param *param = NULL;
270 struct wf_pid_param pid_param;
271 int i;
272
273 /* First, locate the params for this model */
274 for (i = 0; i < WF_SMU_SYS_FANS_NUM_CONFIGS; i++)
275 if (wf_smu_sys_all_params[i].model_id == wf_smu_mach_model) {
276 param = &wf_smu_sys_all_params[i];
277 break;
278 }
279
280 /* No params found, put fans to max */
281 if (param == NULL) {
282 printk(KERN_WARNING "windfarm: System fan config not found "
283 "for this machine model, max fan speed\n");
284 goto fail;
285 }
286
287 /* Alloc & initialize state */
288 wf_smu_sys_fans = kmalloc(sizeof(struct wf_smu_sys_fans_state),
289 GFP_KERNEL);
290 if (wf_smu_sys_fans == NULL) {
291 printk(KERN_WARNING "windfarm: Memory allocation error"
292 " max fan speed\n");
293 goto fail;
294 }
295 wf_smu_sys_fans->ticks = 1;
296 wf_smu_sys_fans->scale0 = param->scale0;
297 wf_smu_sys_fans->offset0 = param->offset0;
298 wf_smu_sys_fans->scale1 = param->scale1;
299 wf_smu_sys_fans->offset1 = param->offset1;
300
301 /* Fill PID params */
302 pid_param.gd = param->gd;
303 pid_param.gp = param->gp;
304 pid_param.gr = param->gr;
305 pid_param.interval = WF_SMU_SYS_FANS_INTERVAL;
306 pid_param.history_len = WF_SMU_SYS_FANS_HISTORY_SIZE;
307 pid_param.itarget = param->itarget;
308 pid_param.min = fan_system->ops->get_min(fan_system);
309 pid_param.max = fan_system->ops->get_max(fan_system);
310 if (fan_hd) {
311 pid_param.min =
312 max(pid_param.min,fan_hd->ops->get_min(fan_hd));
313 pid_param.max =
314 min(pid_param.max,fan_hd->ops->get_max(fan_hd));
315 }
316 wf_pid_init(&wf_smu_sys_fans->pid, &pid_param);
317
318 DBG("wf: System Fan control initialized.\n");
319 DBG(" itarged=%d.%03d, min=%d RPM, max=%d RPM\n",
320 FIX32TOPRINT(pid_param.itarget), pid_param.min, pid_param.max);
321 return;
322
323 fail:
324
325 if (fan_system)
326 wf_control_set_max(fan_system);
327 if (fan_hd)
328 wf_control_set_max(fan_hd);
329}
330
331static void wf_smu_sys_fans_tick(struct wf_smu_sys_fans_state *st)
332{
333 s32 new_setpoint, temp, scaled, cputarget;
334 int rc;
335
336 if (--st->ticks != 0) {
337 if (wf_smu_readjust)
338 goto readjust;
339 return;
340 }
341 st->ticks = WF_SMU_SYS_FANS_INTERVAL;
342
343 rc = sensor_hd_temp->ops->get_value(sensor_hd_temp, &temp);
344 if (rc) {
345 printk(KERN_WARNING "windfarm: HD temp sensor error %d\n",
346 rc);
347 wf_smu_failure_state |= FAILURE_SENSOR;
348 return;
349 }
350
351 DBG("wf_smu: System Fans tick ! HD temp: %d.%03d\n",
352 FIX32TOPRINT(temp));
353
354 if (temp > (st->pid.param.itarget + 0x50000))
355 wf_smu_failure_state |= FAILURE_OVERTEMP;
356
357 new_setpoint = wf_pid_run(&st->pid, temp);
358
359 DBG("wf_smu: new_setpoint: %d RPM\n", (int)new_setpoint);
360
361 scaled = ((((s64)new_setpoint) * (s64)st->scale0) >> 12) + st->offset0;
362
363 DBG("wf_smu: scaled setpoint: %d RPM\n", (int)scaled);
364
365 cputarget = wf_smu_cpu_fans ? wf_smu_cpu_fans->pid.target : 0;
366 cputarget = ((((s64)cputarget) * (s64)st->scale1) >> 12) + st->offset1;
367 scaled = max(scaled, cputarget);
368 scaled = max(scaled, st->pid.param.min);
369 scaled = min(scaled, st->pid.param.max);
370
371 DBG("wf_smu: adjusted setpoint: %d RPM\n", (int)scaled);
372
373 if (st->sys_setpoint == scaled && new_setpoint == st->hd_setpoint)
374 return;
375 st->sys_setpoint = scaled;
376 st->hd_setpoint = new_setpoint;
377 readjust:
378 if (fan_system && wf_smu_failure_state == 0) {
379 rc = fan_system->ops->set_value(fan_system, st->sys_setpoint);
380 if (rc) {
381 printk(KERN_WARNING "windfarm: Sys fan error %d\n",
382 rc);
383 wf_smu_failure_state |= FAILURE_FAN;
384 }
385 }
386 if (fan_hd && wf_smu_failure_state == 0) {
387 rc = fan_hd->ops->set_value(fan_hd, st->hd_setpoint);
388 if (rc) {
389 printk(KERN_WARNING "windfarm: HD fan error %d\n",
390 rc);
391 wf_smu_failure_state |= FAILURE_FAN;
392 }
393 }
394}
395
396static void wf_smu_create_cpu_fans(void)
397{
398 struct wf_cpu_pid_param pid_param;
399 struct smu_sdbp_header *hdr;
400 struct smu_sdbp_cpupiddata *piddata;
401 struct smu_sdbp_fvt *fvt;
402 s32 tmax, tdelta, maxpow, powadj;
403
404 /* First, locate the PID params in SMU SBD */
405 hdr = smu_get_sdb_partition(SMU_SDB_CPUPIDDATA_ID, NULL);
406 if (hdr == 0) {
407 printk(KERN_WARNING "windfarm: CPU PID fan config not found "
408 "max fan speed\n");
409 goto fail;
410 }
411 piddata = (struct smu_sdbp_cpupiddata *)&hdr[1];
412
413 /* Get the FVT params for operating point 0 (the only supported one
414 * for now) in order to get tmax
415 */
416 hdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL);
417 if (hdr) {
418 fvt = (struct smu_sdbp_fvt *)&hdr[1];
419 tmax = ((s32)fvt->maxtemp) << 16;
420 } else
421 tmax = 0x5e0000; /* 94 degree default */
422
423 /* Alloc & initialize state */
424 wf_smu_cpu_fans = kmalloc(sizeof(struct wf_smu_cpu_fans_state),
425 GFP_KERNEL);
426 if (wf_smu_cpu_fans == NULL)
427 goto fail;
428 wf_smu_cpu_fans->ticks = 1;
429
430 wf_smu_cpu_fans->scale = WF_SMU_CPU_FANS_SIBLING_SCALE;
431 wf_smu_cpu_fans->offset = WF_SMU_CPU_FANS_SIBLING_OFFSET;
432
433 /* Fill PID params */
434 pid_param.interval = WF_SMU_CPU_FANS_INTERVAL;
435 pid_param.history_len = piddata->history_len;
436 if (pid_param.history_len > WF_CPU_PID_MAX_HISTORY) {
437 printk(KERN_WARNING "windfarm: History size overflow on "
438 "CPU control loop (%d)\n", piddata->history_len);
439 pid_param.history_len = WF_CPU_PID_MAX_HISTORY;
440 }
441 pid_param.gd = piddata->gd;
442 pid_param.gp = piddata->gp;
443 pid_param.gr = piddata->gr / pid_param.history_len;
444
445 tdelta = ((s32)piddata->target_temp_delta) << 16;
446 maxpow = ((s32)piddata->max_power) << 16;
447 powadj = ((s32)piddata->power_adj) << 16;
448
449 pid_param.tmax = tmax;
450 pid_param.ttarget = tmax - tdelta;
451 pid_param.pmaxadj = maxpow - powadj;
452
453 pid_param.min = fan_cpu_main->ops->get_min(fan_cpu_main);
454 pid_param.max = fan_cpu_main->ops->get_max(fan_cpu_main);
455
456 wf_cpu_pid_init(&wf_smu_cpu_fans->pid, &pid_param);
457
458 DBG("wf: CPU Fan control initialized.\n");
459 DBG(" ttarged=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM\n",
460 FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax),
461 pid_param.min, pid_param.max);
462
463 return;
464
465 fail:
466 printk(KERN_WARNING "windfarm: CPU fan config not found\n"
467 "for this machine model, max fan speed\n");
468
469 if (cpufreq_clamp)
470 wf_control_set_max(cpufreq_clamp);
471 if (fan_cpu_main)
472 wf_control_set_max(fan_cpu_main);
473}
474
475static void wf_smu_cpu_fans_tick(struct wf_smu_cpu_fans_state *st)
476{
477 s32 new_setpoint, temp, power, systarget;
478 int rc;
479
480 if (--st->ticks != 0) {
481 if (wf_smu_readjust)
482 goto readjust;
483 return;
484 }
485 st->ticks = WF_SMU_CPU_FANS_INTERVAL;
486
487 rc = sensor_cpu_temp->ops->get_value(sensor_cpu_temp, &temp);
488 if (rc) {
489 printk(KERN_WARNING "windfarm: CPU temp sensor error %d\n",
490 rc);
491 wf_smu_failure_state |= FAILURE_SENSOR;
492 return;
493 }
494
495 rc = sensor_cpu_power->ops->get_value(sensor_cpu_power, &power);
496 if (rc) {
497 printk(KERN_WARNING "windfarm: CPU power sensor error %d\n",
498 rc);
499 wf_smu_failure_state |= FAILURE_SENSOR;
500 return;
501 }
502
503 DBG("wf_smu: CPU Fans tick ! CPU temp: %d.%03d, power: %d.%03d\n",
504 FIX32TOPRINT(temp), FIX32TOPRINT(power));
505
506#ifdef HACKED_OVERTEMP
507 if (temp > 0x4a0000)
508 wf_smu_failure_state |= FAILURE_OVERTEMP;
509#else
510 if (temp > st->pid.param.tmax)
511 wf_smu_failure_state |= FAILURE_OVERTEMP;
512#endif
513 new_setpoint = wf_cpu_pid_run(&st->pid, power, temp);
514
515 DBG("wf_smu: new_setpoint: %d RPM\n", (int)new_setpoint);
516
517 systarget = wf_smu_sys_fans ? wf_smu_sys_fans->pid.target : 0;
518 systarget = ((((s64)systarget) * (s64)st->scale) >> 12)
519 + st->offset;
520 new_setpoint = max(new_setpoint, systarget);
521 new_setpoint = max(new_setpoint, st->pid.param.min);
522 new_setpoint = min(new_setpoint, st->pid.param.max);
523
524 DBG("wf_smu: adjusted setpoint: %d RPM\n", (int)new_setpoint);
525
526 if (st->cpu_setpoint == new_setpoint)
527 return;
528 st->cpu_setpoint = new_setpoint;
529 readjust:
530 if (fan_cpu_main && wf_smu_failure_state == 0) {
531 rc = fan_cpu_main->ops->set_value(fan_cpu_main,
532 st->cpu_setpoint);
533 if (rc) {
534 printk(KERN_WARNING "windfarm: CPU main fan"
535 " error %d\n", rc);
536 wf_smu_failure_state |= FAILURE_FAN;
537 }
538 }
539}
540
541
542/*
543 * ****** Attributes ******
544 *
545 */
546
547#define BUILD_SHOW_FUNC_FIX(name, data) \
548static ssize_t show_##name(struct device *dev, \
549 struct device_attribute *attr, \
550 char *buf) \
551{ \
552 ssize_t r; \
553 s32 val = 0; \
554 data->ops->get_value(data, &val); \
555 r = sprintf(buf, "%d.%03d", FIX32TOPRINT(val)); \
556 return r; \
557} \
558static DEVICE_ATTR(name,S_IRUGO,show_##name, NULL);
559
560
561#define BUILD_SHOW_FUNC_INT(name, data) \
562static ssize_t show_##name(struct device *dev, \
563 struct device_attribute *attr, \
564 char *buf) \
565{ \
566 s32 val = 0; \
567 data->ops->get_value(data, &val); \
568 return sprintf(buf, "%d", val); \
569} \
570static DEVICE_ATTR(name,S_IRUGO,show_##name, NULL);
571
572BUILD_SHOW_FUNC_INT(cpu_fan, fan_cpu_main);
573BUILD_SHOW_FUNC_INT(sys_fan, fan_system);
574BUILD_SHOW_FUNC_INT(hd_fan, fan_hd);
575
576BUILD_SHOW_FUNC_FIX(cpu_temp, sensor_cpu_temp);
577BUILD_SHOW_FUNC_FIX(cpu_power, sensor_cpu_power);
578BUILD_SHOW_FUNC_FIX(hd_temp, sensor_hd_temp);
579
580/*
581 * ****** Setup / Init / Misc ... ******
582 *
583 */
584
585static void wf_smu_tick(void)
586{
587 unsigned int last_failure = wf_smu_failure_state;
588 unsigned int new_failure;
589
590 if (!wf_smu_started) {
591 DBG("wf: creating control loops !\n");
592 wf_smu_create_sys_fans();
593 wf_smu_create_cpu_fans();
594 wf_smu_started = 1;
595 }
596
597 /* Skipping ticks */
598 if (wf_smu_skipping && --wf_smu_skipping)
599 return;
600
601 wf_smu_failure_state = 0;
602 if (wf_smu_sys_fans)
603 wf_smu_sys_fans_tick(wf_smu_sys_fans);
604 if (wf_smu_cpu_fans)
605 wf_smu_cpu_fans_tick(wf_smu_cpu_fans);
606
607 wf_smu_readjust = 0;
608 new_failure = wf_smu_failure_state & ~last_failure;
609
610 /* If entering failure mode, clamp cpufreq and ramp all
611 * fans to full speed.
612 */
613 if (wf_smu_failure_state && !last_failure) {
614 if (cpufreq_clamp)
615 wf_control_set_max(cpufreq_clamp);
616 if (fan_system)
617 wf_control_set_max(fan_system);
618 if (fan_cpu_main)
619 wf_control_set_max(fan_cpu_main);
620 if (fan_hd)
621 wf_control_set_max(fan_hd);
622 }
623
624 /* If leaving failure mode, unclamp cpufreq and readjust
625 * all fans on next iteration
626 */
627 if (!wf_smu_failure_state && last_failure) {
628 if (cpufreq_clamp)
629 wf_control_set_min(cpufreq_clamp);
630 wf_smu_readjust = 1;
631 }
632
633 /* Overtemp condition detected, notify and start skipping a couple
634 * ticks to let the temperature go down
635 */
636 if (new_failure & FAILURE_OVERTEMP) {
637 wf_set_overtemp();
638 wf_smu_skipping = 2;
639 }
640
641 /* We only clear the overtemp condition if overtemp is cleared
642 * _and_ no other failure is present. Since a sensor error will
643 * clear the overtemp condition (can't measure temperature) at
644 * the control loop levels, but we don't want to keep it clear
645 * here in this case
646 */
647 if (new_failure == 0 && last_failure & FAILURE_OVERTEMP)
648 wf_clear_overtemp();
649}
650
651static void wf_smu_new_control(struct wf_control *ct)
652{
653 if (wf_smu_all_controls_ok)
654 return;
655
656 if (fan_cpu_main == NULL && !strcmp(ct->name, "cpu-fan")) {
657 if (wf_get_control(ct) == 0) {
658 fan_cpu_main = ct;
659 device_create_file(wf_smu_dev, &dev_attr_cpu_fan);
660 }
661 }
662
663 if (fan_system == NULL && !strcmp(ct->name, "system-fan")) {
664 if (wf_get_control(ct) == 0) {
665 fan_system = ct;
666 device_create_file(wf_smu_dev, &dev_attr_sys_fan);
667 }
668 }
669
670 if (cpufreq_clamp == NULL && !strcmp(ct->name, "cpufreq-clamp")) {
671 if (wf_get_control(ct) == 0)
672 cpufreq_clamp = ct;
673 }
674
675 /* Darwin property list says the HD fan is only for model ID
676 * 0, 1, 2 and 3
677 */
678
679 if (wf_smu_mach_model > 3) {
680 if (fan_system && fan_cpu_main && cpufreq_clamp)
681 wf_smu_all_controls_ok = 1;
682 return;
683 }
684
685 if (fan_hd == NULL && !strcmp(ct->name, "drive-bay-fan")) {
686 if (wf_get_control(ct) == 0) {
687 fan_hd = ct;
688 device_create_file(wf_smu_dev, &dev_attr_hd_fan);
689 }
690 }
691
692 if (fan_system && fan_hd && fan_cpu_main && cpufreq_clamp)
693 wf_smu_all_controls_ok = 1;
694}
695
696static void wf_smu_new_sensor(struct wf_sensor *sr)
697{
698 if (wf_smu_all_sensors_ok)
699 return;
700
701 if (sensor_cpu_power == NULL && !strcmp(sr->name, "cpu-power")) {
702 if (wf_get_sensor(sr) == 0) {
703 sensor_cpu_power = sr;
704 device_create_file(wf_smu_dev, &dev_attr_cpu_power);
705 }
706 }
707
708 if (sensor_cpu_temp == NULL && !strcmp(sr->name, "cpu-temp")) {
709 if (wf_get_sensor(sr) == 0) {
710 sensor_cpu_temp = sr;
711 device_create_file(wf_smu_dev, &dev_attr_cpu_temp);
712 }
713 }
714
715 if (sensor_hd_temp == NULL && !strcmp(sr->name, "hd-temp")) {
716 if (wf_get_sensor(sr) == 0) {
717 sensor_hd_temp = sr;
718 device_create_file(wf_smu_dev, &dev_attr_hd_temp);
719 }
720 }
721
722 if (sensor_cpu_power && sensor_cpu_temp && sensor_hd_temp)
723 wf_smu_all_sensors_ok = 1;
724}
725
726
727static int wf_smu_notify(struct notifier_block *self,
728 unsigned long event, void *data)
729{
730 switch(event) {
731 case WF_EVENT_NEW_CONTROL:
732 DBG("wf: new control %s detected\n",
733 ((struct wf_control *)data)->name);
734 wf_smu_new_control(data);
735 wf_smu_readjust = 1;
736 break;
737 case WF_EVENT_NEW_SENSOR:
738 DBG("wf: new sensor %s detected\n",
739 ((struct wf_sensor *)data)->name);
740 wf_smu_new_sensor(data);
741 break;
742 case WF_EVENT_TICK:
743 if (wf_smu_all_controls_ok && wf_smu_all_sensors_ok)
744 wf_smu_tick();
745 }
746
747 return 0;
748}
749
750static struct notifier_block wf_smu_events = {
751 .notifier_call = wf_smu_notify,
752};
753
754static int wf_init_pm(void)
755{
756 struct smu_sdbp_header *hdr;
757
758 hdr = smu_get_sdb_partition(SMU_SDB_SENSORTREE_ID, NULL);
759 if (hdr != 0) {
760 struct smu_sdbp_sensortree *st =
761 (struct smu_sdbp_sensortree *)&hdr[1];
762 wf_smu_mach_model = st->model_id;
763 }
764
765 printk(KERN_INFO "windfarm: Initializing for iMacG5 model ID %d\n",
766 wf_smu_mach_model);
767
768 return 0;
769}
770
771static int wf_smu_probe(struct device *ddev)
772{
773 wf_smu_dev = ddev;
774
775 wf_register_client(&wf_smu_events);
776
777 return 0;
778}
779
780static int wf_smu_remove(struct device *ddev)
781{
782 wf_unregister_client(&wf_smu_events);
783
784 /* XXX We don't have yet a guarantee that our callback isn't
785 * in progress when returning from wf_unregister_client, so
786 * we add an arbitrary delay. I'll have to fix that in the core
787 */
788 msleep(1000);
789
790 /* Release all sensors */
791 /* One more crappy race: I don't think we have any guarantee here
792 * that the attribute callback won't race with the sensor beeing
793 * disposed of, and I'm not 100% certain what best way to deal
794 * with that except by adding locks all over... I'll do that
795 * eventually but heh, who ever rmmod this module anyway ?
796 */
797 if (sensor_cpu_power) {
798 device_remove_file(wf_smu_dev, &dev_attr_cpu_power);
799 wf_put_sensor(sensor_cpu_power);
800 }
801 if (sensor_cpu_temp) {
802 device_remove_file(wf_smu_dev, &dev_attr_cpu_temp);
803 wf_put_sensor(sensor_cpu_temp);
804 }
805 if (sensor_hd_temp) {
806 device_remove_file(wf_smu_dev, &dev_attr_hd_temp);
807 wf_put_sensor(sensor_hd_temp);
808 }
809
810 /* Release all controls */
811 if (fan_cpu_main) {
812 device_remove_file(wf_smu_dev, &dev_attr_cpu_fan);
813 wf_put_control(fan_cpu_main);
814 }
815 if (fan_hd) {
816 device_remove_file(wf_smu_dev, &dev_attr_hd_fan);
817 wf_put_control(fan_hd);
818 }
819 if (fan_system) {
820 device_remove_file(wf_smu_dev, &dev_attr_sys_fan);
821 wf_put_control(fan_system);
822 }
823 if (cpufreq_clamp)
824 wf_put_control(cpufreq_clamp);
825
826 /* Destroy control loops state structures */
827 if (wf_smu_sys_fans)
828 kfree(wf_smu_sys_fans);
829 if (wf_smu_cpu_fans)
830 kfree(wf_smu_cpu_fans);
831
832 wf_smu_dev = NULL;
833
834 return 0;
835}
836
837static struct device_driver wf_smu_driver = {
838 .name = "windfarm",
839 .bus = &platform_bus_type,
840 .probe = wf_smu_probe,
841 .remove = wf_smu_remove,
842};
843
844
845static int __init wf_smu_init(void)
846{
847 int rc = -ENODEV;
848
849 if (machine_is_compatible("PowerMac8,1") ||
850 machine_is_compatible("PowerMac8,2"))
851 rc = wf_init_pm();
852
853 if (rc == 0) {
854#ifdef MODULE
855 request_module("windfarm_smu_controls");
856 request_module("windfarm_smu_sensors");
857 request_module("windfarm_lm75_sensor");
858
859#endif /* MODULE */
860 driver_register(&wf_smu_driver);
861 }
862
863 return rc;
864}
865
866static void __exit wf_smu_exit(void)
867{
868
869 driver_unregister(&wf_smu_driver);
870}
871
872
873module_init(wf_smu_init);
874module_exit(wf_smu_exit);
875
876MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
877MODULE_DESCRIPTION("Thermal control logic for iMac G5");
878MODULE_LICENSE("GPL");
879
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c
new file mode 100644
index 000000000000..43243cf7410b
--- /dev/null
+++ b/drivers/macintosh/windfarm_pm91.c
@@ -0,0 +1,814 @@
1/*
2 * Windfarm PowerMac thermal control. SMU based 1 CPU desktop control loops
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 *
9 * The algorithm used is the PID control algorithm, used the same
10 * way the published Darwin code does, using the same values that
11 * are present in the Darwin 8.2 snapshot property lists (note however
12 * that none of the code has been re-used, it's a complete re-implementation
13 *
14 * The various control loops found in Darwin config file are:
15 *
16 * PowerMac9,1
17 * ===========
18 *
19 * Has 3 control loops: CPU fans is similar to PowerMac8,1 (though it doesn't
20 * try to play with other control loops fans). Drive bay is rather basic PID
21 * with one sensor and one fan. Slots area is a bit different as the Darwin
22 * driver is supposed to be capable of working in a special "AGP" mode which
23 * involves the presence of an AGP sensor and an AGP fan (possibly on the
24 * AGP card itself). I can't deal with that special mode as I don't have
25 * access to those additional sensor/fans for now (though ultimately, it would
26 * be possible to add sensor objects for them) so I'm only implementing the
27 * basic PCI slot control loop
28 */
29
30#include <linux/types.h>
31#include <linux/errno.h>
32#include <linux/kernel.h>
33#include <linux/delay.h>
34#include <linux/slab.h>
35#include <linux/init.h>
36#include <linux/spinlock.h>
37#include <linux/wait.h>
38#include <linux/kmod.h>
39#include <linux/device.h>
40#include <linux/platform_device.h>
41#include <asm/prom.h>
42#include <asm/machdep.h>
43#include <asm/io.h>
44#include <asm/system.h>
45#include <asm/sections.h>
46#include <asm/smu.h>
47
48#include "windfarm.h"
49#include "windfarm_pid.h"
50
51#define VERSION "0.4"
52
53#undef DEBUG
54
55#ifdef DEBUG
56#define DBG(args...) printk(args)
57#else
58#define DBG(args...) do { } while(0)
59#endif
60
61/* define this to force CPU overtemp to 74 degree, useful for testing
62 * the overtemp code
63 */
64#undef HACKED_OVERTEMP
65
66static struct device *wf_smu_dev;
67
68/* Controls & sensors */
69static struct wf_sensor *sensor_cpu_power;
70static struct wf_sensor *sensor_cpu_temp;
71static struct wf_sensor *sensor_hd_temp;
72static struct wf_sensor *sensor_slots_power;
73static struct wf_control *fan_cpu_main;
74static struct wf_control *fan_cpu_second;
75static struct wf_control *fan_cpu_third;
76static struct wf_control *fan_hd;
77static struct wf_control *fan_slots;
78static struct wf_control *cpufreq_clamp;
79
80/* Set to kick the control loop into life */
81static int wf_smu_all_controls_ok, wf_smu_all_sensors_ok, wf_smu_started;
82
83/* Failure handling.. could be nicer */
84#define FAILURE_FAN 0x01
85#define FAILURE_SENSOR 0x02
86#define FAILURE_OVERTEMP 0x04
87
88static unsigned int wf_smu_failure_state;
89static int wf_smu_readjust, wf_smu_skipping;
90
91/*
92 * ****** CPU Fans Control Loop ******
93 *
94 */
95
96
97#define WF_SMU_CPU_FANS_INTERVAL 1
98#define WF_SMU_CPU_FANS_MAX_HISTORY 16
99
100/* State data used by the cpu fans control loop
101 */
102struct wf_smu_cpu_fans_state {
103 int ticks;
104 s32 cpu_setpoint;
105 struct wf_cpu_pid_state pid;
106};
107
108static struct wf_smu_cpu_fans_state *wf_smu_cpu_fans;
109
110
111
112/*
113 * ****** Drive Fan Control Loop ******
114 *
115 */
116
117struct wf_smu_drive_fans_state {
118 int ticks;
119 s32 setpoint;
120 struct wf_pid_state pid;
121};
122
123static struct wf_smu_drive_fans_state *wf_smu_drive_fans;
124
125/*
126 * ****** Slots Fan Control Loop ******
127 *
128 */
129
130struct wf_smu_slots_fans_state {
131 int ticks;
132 s32 setpoint;
133 struct wf_pid_state pid;
134};
135
136static struct wf_smu_slots_fans_state *wf_smu_slots_fans;
137
138/*
139 * ***** Implementation *****
140 *
141 */
142
143
144static void wf_smu_create_cpu_fans(void)
145{
146 struct wf_cpu_pid_param pid_param;
147 struct smu_sdbp_header *hdr;
148 struct smu_sdbp_cpupiddata *piddata;
149 struct smu_sdbp_fvt *fvt;
150 s32 tmax, tdelta, maxpow, powadj;
151
152 /* First, locate the PID params in SMU SBD */
153 hdr = smu_get_sdb_partition(SMU_SDB_CPUPIDDATA_ID, NULL);
154 if (hdr == 0) {
155 printk(KERN_WARNING "windfarm: CPU PID fan config not found "
156 "max fan speed\n");
157 goto fail;
158 }
159 piddata = (struct smu_sdbp_cpupiddata *)&hdr[1];
160
161 /* Get the FVT params for operating point 0 (the only supported one
162 * for now) in order to get tmax
163 */
164 hdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL);
165 if (hdr) {
166 fvt = (struct smu_sdbp_fvt *)&hdr[1];
167 tmax = ((s32)fvt->maxtemp) << 16;
168 } else
169 tmax = 0x5e0000; /* 94 degree default */
170
171 /* Alloc & initialize state */
172 wf_smu_cpu_fans = kmalloc(sizeof(struct wf_smu_cpu_fans_state),
173 GFP_KERNEL);
174 if (wf_smu_cpu_fans == NULL)
175 goto fail;
176 wf_smu_cpu_fans->ticks = 1;
177
178 /* Fill PID params */
179 pid_param.interval = WF_SMU_CPU_FANS_INTERVAL;
180 pid_param.history_len = piddata->history_len;
181 if (pid_param.history_len > WF_CPU_PID_MAX_HISTORY) {
182 printk(KERN_WARNING "windfarm: History size overflow on "
183 "CPU control loop (%d)\n", piddata->history_len);
184 pid_param.history_len = WF_CPU_PID_MAX_HISTORY;
185 }
186 pid_param.gd = piddata->gd;
187 pid_param.gp = piddata->gp;
188 pid_param.gr = piddata->gr / pid_param.history_len;
189
190 tdelta = ((s32)piddata->target_temp_delta) << 16;
191 maxpow = ((s32)piddata->max_power) << 16;
192 powadj = ((s32)piddata->power_adj) << 16;
193
194 pid_param.tmax = tmax;
195 pid_param.ttarget = tmax - tdelta;
196 pid_param.pmaxadj = maxpow - powadj;
197
198 pid_param.min = fan_cpu_main->ops->get_min(fan_cpu_main);
199 pid_param.max = fan_cpu_main->ops->get_max(fan_cpu_main);
200
201 wf_cpu_pid_init(&wf_smu_cpu_fans->pid, &pid_param);
202
203 DBG("wf: CPU Fan control initialized.\n");
204 DBG(" ttarged=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM\n",
205 FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax),
206 pid_param.min, pid_param.max);
207
208 return;
209
210 fail:
211 printk(KERN_WARNING "windfarm: CPU fan config not found\n"
212 "for this machine model, max fan speed\n");
213
214 if (cpufreq_clamp)
215 wf_control_set_max(cpufreq_clamp);
216 if (fan_cpu_main)
217 wf_control_set_max(fan_cpu_main);
218}
219
220static void wf_smu_cpu_fans_tick(struct wf_smu_cpu_fans_state *st)
221{
222 s32 new_setpoint, temp, power;
223 int rc;
224
225 if (--st->ticks != 0) {
226 if (wf_smu_readjust)
227 goto readjust;
228 return;
229 }
230 st->ticks = WF_SMU_CPU_FANS_INTERVAL;
231
232 rc = sensor_cpu_temp->ops->get_value(sensor_cpu_temp, &temp);
233 if (rc) {
234 printk(KERN_WARNING "windfarm: CPU temp sensor error %d\n",
235 rc);
236 wf_smu_failure_state |= FAILURE_SENSOR;
237 return;
238 }
239
240 rc = sensor_cpu_power->ops->get_value(sensor_cpu_power, &power);
241 if (rc) {
242 printk(KERN_WARNING "windfarm: CPU power sensor error %d\n",
243 rc);
244 wf_smu_failure_state |= FAILURE_SENSOR;
245 return;
246 }
247
248 DBG("wf_smu: CPU Fans tick ! CPU temp: %d.%03d, power: %d.%03d\n",
249 FIX32TOPRINT(temp), FIX32TOPRINT(power));
250
251#ifdef HACKED_OVERTEMP
252 if (temp > 0x4a0000)
253 wf_smu_failure_state |= FAILURE_OVERTEMP;
254#else
255 if (temp > st->pid.param.tmax)
256 wf_smu_failure_state |= FAILURE_OVERTEMP;
257#endif
258 new_setpoint = wf_cpu_pid_run(&st->pid, power, temp);
259
260 DBG("wf_smu: new_setpoint: %d RPM\n", (int)new_setpoint);
261
262 if (st->cpu_setpoint == new_setpoint)
263 return;
264 st->cpu_setpoint = new_setpoint;
265 readjust:
266 if (fan_cpu_main && wf_smu_failure_state == 0) {
267 rc = fan_cpu_main->ops->set_value(fan_cpu_main,
268 st->cpu_setpoint);
269 if (rc) {
270 printk(KERN_WARNING "windfarm: CPU main fan"
271 " error %d\n", rc);
272 wf_smu_failure_state |= FAILURE_FAN;
273 }
274 }
275 if (fan_cpu_second && wf_smu_failure_state == 0) {
276 rc = fan_cpu_second->ops->set_value(fan_cpu_second,
277 st->cpu_setpoint);
278 if (rc) {
279 printk(KERN_WARNING "windfarm: CPU second fan"
280 " error %d\n", rc);
281 wf_smu_failure_state |= FAILURE_FAN;
282 }
283 }
284 if (fan_cpu_third && wf_smu_failure_state == 0) {
285 rc = fan_cpu_main->ops->set_value(fan_cpu_third,
286 st->cpu_setpoint);
287 if (rc) {
288 printk(KERN_WARNING "windfarm: CPU third fan"
289 " error %d\n", rc);
290 wf_smu_failure_state |= FAILURE_FAN;
291 }
292 }
293}
294
295static void wf_smu_create_drive_fans(void)
296{
297 struct wf_pid_param param = {
298 .interval = 5,
299 .history_len = 2,
300 .gd = 0x01e00000,
301 .gp = 0x00500000,
302 .gr = 0x00000000,
303 .itarget = 0x00200000,
304 };
305
306 /* Alloc & initialize state */
307 wf_smu_drive_fans = kmalloc(sizeof(struct wf_smu_drive_fans_state),
308 GFP_KERNEL);
309 if (wf_smu_drive_fans == NULL) {
310 printk(KERN_WARNING "windfarm: Memory allocation error"
311 " max fan speed\n");
312 goto fail;
313 }
314 wf_smu_drive_fans->ticks = 1;
315
316 /* Fill PID params */
317 param.additive = (fan_hd->type == WF_CONTROL_RPM_FAN);
318 param.min = fan_hd->ops->get_min(fan_hd);
319 param.max = fan_hd->ops->get_max(fan_hd);
320 wf_pid_init(&wf_smu_drive_fans->pid, &param);
321
322 DBG("wf: Drive Fan control initialized.\n");
323 DBG(" itarged=%d.%03d, min=%d RPM, max=%d RPM\n",
324 FIX32TOPRINT(param.itarget), param.min, param.max);
325 return;
326
327 fail:
328 if (fan_hd)
329 wf_control_set_max(fan_hd);
330}
331
332static void wf_smu_drive_fans_tick(struct wf_smu_drive_fans_state *st)
333{
334 s32 new_setpoint, temp;
335 int rc;
336
337 if (--st->ticks != 0) {
338 if (wf_smu_readjust)
339 goto readjust;
340 return;
341 }
342 st->ticks = st->pid.param.interval;
343
344 rc = sensor_hd_temp->ops->get_value(sensor_hd_temp, &temp);
345 if (rc) {
346 printk(KERN_WARNING "windfarm: HD temp sensor error %d\n",
347 rc);
348 wf_smu_failure_state |= FAILURE_SENSOR;
349 return;
350 }
351
352 DBG("wf_smu: Drive Fans tick ! HD temp: %d.%03d\n",
353 FIX32TOPRINT(temp));
354
355 if (temp > (st->pid.param.itarget + 0x50000))
356 wf_smu_failure_state |= FAILURE_OVERTEMP;
357
358 new_setpoint = wf_pid_run(&st->pid, temp);
359
360 DBG("wf_smu: new_setpoint: %d\n", (int)new_setpoint);
361
362 if (st->setpoint == new_setpoint)
363 return;
364 st->setpoint = new_setpoint;
365 readjust:
366 if (fan_hd && wf_smu_failure_state == 0) {
367 rc = fan_hd->ops->set_value(fan_hd, st->setpoint);
368 if (rc) {
369 printk(KERN_WARNING "windfarm: HD fan error %d\n",
370 rc);
371 wf_smu_failure_state |= FAILURE_FAN;
372 }
373 }
374}
375
376static void wf_smu_create_slots_fans(void)
377{
378 struct wf_pid_param param = {
379 .interval = 1,
380 .history_len = 8,
381 .gd = 0x00000000,
382 .gp = 0x00000000,
383 .gr = 0x00020000,
384 .itarget = 0x00000000
385 };
386
387 /* Alloc & initialize state */
388 wf_smu_slots_fans = kmalloc(sizeof(struct wf_smu_slots_fans_state),
389 GFP_KERNEL);
390 if (wf_smu_slots_fans == NULL) {
391 printk(KERN_WARNING "windfarm: Memory allocation error"
392 " max fan speed\n");
393 goto fail;
394 }
395 wf_smu_slots_fans->ticks = 1;
396
397 /* Fill PID params */
398 param.additive = (fan_slots->type == WF_CONTROL_RPM_FAN);
399 param.min = fan_slots->ops->get_min(fan_slots);
400 param.max = fan_slots->ops->get_max(fan_slots);
401 wf_pid_init(&wf_smu_slots_fans->pid, &param);
402
403 DBG("wf: Slots Fan control initialized.\n");
404 DBG(" itarged=%d.%03d, min=%d RPM, max=%d RPM\n",
405 FIX32TOPRINT(param.itarget), param.min, param.max);
406 return;
407
408 fail:
409 if (fan_slots)
410 wf_control_set_max(fan_slots);
411}
412
413static void wf_smu_slots_fans_tick(struct wf_smu_slots_fans_state *st)
414{
415 s32 new_setpoint, power;
416 int rc;
417
418 if (--st->ticks != 0) {
419 if (wf_smu_readjust)
420 goto readjust;
421 return;
422 }
423 st->ticks = st->pid.param.interval;
424
425 rc = sensor_slots_power->ops->get_value(sensor_slots_power, &power);
426 if (rc) {
427 printk(KERN_WARNING "windfarm: Slots power sensor error %d\n",
428 rc);
429 wf_smu_failure_state |= FAILURE_SENSOR;
430 return;
431 }
432
433 DBG("wf_smu: Slots Fans tick ! Slots power: %d.%03d\n",
434 FIX32TOPRINT(power));
435
436#if 0 /* Check what makes a good overtemp condition */
437 if (power > (st->pid.param.itarget + 0x50000))
438 wf_smu_failure_state |= FAILURE_OVERTEMP;
439#endif
440
441 new_setpoint = wf_pid_run(&st->pid, power);
442
443 DBG("wf_smu: new_setpoint: %d\n", (int)new_setpoint);
444
445 if (st->setpoint == new_setpoint)
446 return;
447 st->setpoint = new_setpoint;
448 readjust:
449 if (fan_slots && wf_smu_failure_state == 0) {
450 rc = fan_slots->ops->set_value(fan_slots, st->setpoint);
451 if (rc) {
452 printk(KERN_WARNING "windfarm: Slots fan error %d\n",
453 rc);
454 wf_smu_failure_state |= FAILURE_FAN;
455 }
456 }
457}
458
459
460/*
461 * ****** Attributes ******
462 *
463 */
464
465#define BUILD_SHOW_FUNC_FIX(name, data) \
466static ssize_t show_##name(struct device *dev, \
467 struct device_attribute *attr, \
468 char *buf) \
469{ \
470 ssize_t r; \
471 s32 val = 0; \
472 data->ops->get_value(data, &val); \
473 r = sprintf(buf, "%d.%03d", FIX32TOPRINT(val)); \
474 return r; \
475} \
476static DEVICE_ATTR(name,S_IRUGO,show_##name, NULL);
477
478
479#define BUILD_SHOW_FUNC_INT(name, data) \
480static ssize_t show_##name(struct device *dev, \
481 struct device_attribute *attr, \
482 char *buf) \
483{ \
484 s32 val = 0; \
485 data->ops->get_value(data, &val); \
486 return sprintf(buf, "%d", val); \
487} \
488static DEVICE_ATTR(name,S_IRUGO,show_##name, NULL);
489
490BUILD_SHOW_FUNC_INT(cpu_fan, fan_cpu_main);
491BUILD_SHOW_FUNC_INT(hd_fan, fan_hd);
492BUILD_SHOW_FUNC_INT(slots_fan, fan_slots);
493
494BUILD_SHOW_FUNC_FIX(cpu_temp, sensor_cpu_temp);
495BUILD_SHOW_FUNC_FIX(cpu_power, sensor_cpu_power);
496BUILD_SHOW_FUNC_FIX(hd_temp, sensor_hd_temp);
497BUILD_SHOW_FUNC_FIX(slots_power, sensor_slots_power);
498
499/*
500 * ****** Setup / Init / Misc ... ******
501 *
502 */
503
504static void wf_smu_tick(void)
505{
506 unsigned int last_failure = wf_smu_failure_state;
507 unsigned int new_failure;
508
509 if (!wf_smu_started) {
510 DBG("wf: creating control loops !\n");
511 wf_smu_create_drive_fans();
512 wf_smu_create_slots_fans();
513 wf_smu_create_cpu_fans();
514 wf_smu_started = 1;
515 }
516
517 /* Skipping ticks */
518 if (wf_smu_skipping && --wf_smu_skipping)
519 return;
520
521 wf_smu_failure_state = 0;
522 if (wf_smu_drive_fans)
523 wf_smu_drive_fans_tick(wf_smu_drive_fans);
524 if (wf_smu_slots_fans)
525 wf_smu_slots_fans_tick(wf_smu_slots_fans);
526 if (wf_smu_cpu_fans)
527 wf_smu_cpu_fans_tick(wf_smu_cpu_fans);
528
529 wf_smu_readjust = 0;
530 new_failure = wf_smu_failure_state & ~last_failure;
531
532 /* If entering failure mode, clamp cpufreq and ramp all
533 * fans to full speed.
534 */
535 if (wf_smu_failure_state && !last_failure) {
536 if (cpufreq_clamp)
537 wf_control_set_max(cpufreq_clamp);
538 if (fan_cpu_main)
539 wf_control_set_max(fan_cpu_main);
540 if (fan_cpu_second)
541 wf_control_set_max(fan_cpu_second);
542 if (fan_cpu_third)
543 wf_control_set_max(fan_cpu_third);
544 if (fan_hd)
545 wf_control_set_max(fan_hd);
546 if (fan_slots)
547 wf_control_set_max(fan_slots);
548 }
549
550 /* If leaving failure mode, unclamp cpufreq and readjust
551 * all fans on next iteration
552 */
553 if (!wf_smu_failure_state && last_failure) {
554 if (cpufreq_clamp)
555 wf_control_set_min(cpufreq_clamp);
556 wf_smu_readjust = 1;
557 }
558
559 /* Overtemp condition detected, notify and start skipping a couple
560 * ticks to let the temperature go down
561 */
562 if (new_failure & FAILURE_OVERTEMP) {
563 wf_set_overtemp();
564 wf_smu_skipping = 2;
565 }
566
567 /* We only clear the overtemp condition if overtemp is cleared
568 * _and_ no other failure is present. Since a sensor error will
569 * clear the overtemp condition (can't measure temperature) at
570 * the control loop levels, but we don't want to keep it clear
571 * here in this case
572 */
573 if (new_failure == 0 && last_failure & FAILURE_OVERTEMP)
574 wf_clear_overtemp();
575}
576
577
578static void wf_smu_new_control(struct wf_control *ct)
579{
580 if (wf_smu_all_controls_ok)
581 return;
582
583 if (fan_cpu_main == NULL && !strcmp(ct->name, "cpu-rear-fan-0")) {
584 if (wf_get_control(ct) == 0) {
585 fan_cpu_main = ct;
586 device_create_file(wf_smu_dev, &dev_attr_cpu_fan);
587 }
588 }
589
590 if (fan_cpu_second == NULL && !strcmp(ct->name, "cpu-rear-fan-1")) {
591 if (wf_get_control(ct) == 0)
592 fan_cpu_second = ct;
593 }
594
595 if (fan_cpu_third == NULL && !strcmp(ct->name, "cpu-front-fan-0")) {
596 if (wf_get_control(ct) == 0)
597 fan_cpu_third = ct;
598 }
599
600 if (cpufreq_clamp == NULL && !strcmp(ct->name, "cpufreq-clamp")) {
601 if (wf_get_control(ct) == 0)
602 cpufreq_clamp = ct;
603 }
604
605 if (fan_hd == NULL && !strcmp(ct->name, "drive-bay-fan")) {
606 if (wf_get_control(ct) == 0) {
607 fan_hd = ct;
608 device_create_file(wf_smu_dev, &dev_attr_hd_fan);
609 }
610 }
611
612 if (fan_slots == NULL && !strcmp(ct->name, "slots-fan")) {
613 if (wf_get_control(ct) == 0) {
614 fan_slots = ct;
615 device_create_file(wf_smu_dev, &dev_attr_slots_fan);
616 }
617 }
618
619 if (fan_cpu_main && (fan_cpu_second || fan_cpu_third) && fan_hd &&
620 fan_slots && cpufreq_clamp)
621 wf_smu_all_controls_ok = 1;
622}
623
624static void wf_smu_new_sensor(struct wf_sensor *sr)
625{
626 if (wf_smu_all_sensors_ok)
627 return;
628
629 if (sensor_cpu_power == NULL && !strcmp(sr->name, "cpu-power")) {
630 if (wf_get_sensor(sr) == 0) {
631 sensor_cpu_power = sr;
632 device_create_file(wf_smu_dev, &dev_attr_cpu_power);
633 }
634 }
635
636 if (sensor_cpu_temp == NULL && !strcmp(sr->name, "cpu-temp")) {
637 if (wf_get_sensor(sr) == 0) {
638 sensor_cpu_temp = sr;
639 device_create_file(wf_smu_dev, &dev_attr_cpu_temp);
640 }
641 }
642
643 if (sensor_hd_temp == NULL && !strcmp(sr->name, "hd-temp")) {
644 if (wf_get_sensor(sr) == 0) {
645 sensor_hd_temp = sr;
646 device_create_file(wf_smu_dev, &dev_attr_hd_temp);
647 }
648 }
649
650 if (sensor_slots_power == NULL && !strcmp(sr->name, "slots-power")) {
651 if (wf_get_sensor(sr) == 0) {
652 sensor_slots_power = sr;
653 device_create_file(wf_smu_dev, &dev_attr_slots_power);
654 }
655 }
656
657 if (sensor_cpu_power && sensor_cpu_temp &&
658 sensor_hd_temp && sensor_slots_power)
659 wf_smu_all_sensors_ok = 1;
660}
661
662
663static int wf_smu_notify(struct notifier_block *self,
664 unsigned long event, void *data)
665{
666 switch(event) {
667 case WF_EVENT_NEW_CONTROL:
668 DBG("wf: new control %s detected\n",
669 ((struct wf_control *)data)->name);
670 wf_smu_new_control(data);
671 wf_smu_readjust = 1;
672 break;
673 case WF_EVENT_NEW_SENSOR:
674 DBG("wf: new sensor %s detected\n",
675 ((struct wf_sensor *)data)->name);
676 wf_smu_new_sensor(data);
677 break;
678 case WF_EVENT_TICK:
679 if (wf_smu_all_controls_ok && wf_smu_all_sensors_ok)
680 wf_smu_tick();
681 }
682
683 return 0;
684}
685
686static struct notifier_block wf_smu_events = {
687 .notifier_call = wf_smu_notify,
688};
689
690static int wf_init_pm(void)
691{
692 printk(KERN_INFO "windfarm: Initializing for Desktop G5 model\n");
693
694 return 0;
695}
696
697static int wf_smu_probe(struct device *ddev)
698{
699 wf_smu_dev = ddev;
700
701 wf_register_client(&wf_smu_events);
702
703 return 0;
704}
705
706static int wf_smu_remove(struct device *ddev)
707{
708 wf_unregister_client(&wf_smu_events);
709
710 /* XXX We don't have yet a guarantee that our callback isn't
711 * in progress when returning from wf_unregister_client, so
712 * we add an arbitrary delay. I'll have to fix that in the core
713 */
714 msleep(1000);
715
716 /* Release all sensors */
717 /* One more crappy race: I don't think we have any guarantee here
718 * that the attribute callback won't race with the sensor beeing
719 * disposed of, and I'm not 100% certain what best way to deal
720 * with that except by adding locks all over... I'll do that
721 * eventually but heh, who ever rmmod this module anyway ?
722 */
723 if (sensor_cpu_power) {
724 device_remove_file(wf_smu_dev, &dev_attr_cpu_power);
725 wf_put_sensor(sensor_cpu_power);
726 }
727 if (sensor_cpu_temp) {
728 device_remove_file(wf_smu_dev, &dev_attr_cpu_temp);
729 wf_put_sensor(sensor_cpu_temp);
730 }
731 if (sensor_hd_temp) {
732 device_remove_file(wf_smu_dev, &dev_attr_hd_temp);
733 wf_put_sensor(sensor_hd_temp);
734 }
735 if (sensor_slots_power) {
736 device_remove_file(wf_smu_dev, &dev_attr_slots_power);
737 wf_put_sensor(sensor_slots_power);
738 }
739
740 /* Release all controls */
741 if (fan_cpu_main) {
742 device_remove_file(wf_smu_dev, &dev_attr_cpu_fan);
743 wf_put_control(fan_cpu_main);
744 }
745 if (fan_cpu_second)
746 wf_put_control(fan_cpu_second);
747 if (fan_cpu_third)
748 wf_put_control(fan_cpu_third);
749 if (fan_hd) {
750 device_remove_file(wf_smu_dev, &dev_attr_hd_fan);
751 wf_put_control(fan_hd);
752 }
753 if (fan_slots) {
754 device_remove_file(wf_smu_dev, &dev_attr_slots_fan);
755 wf_put_control(fan_slots);
756 }
757 if (cpufreq_clamp)
758 wf_put_control(cpufreq_clamp);
759
760 /* Destroy control loops state structures */
761 if (wf_smu_slots_fans)
762 kfree(wf_smu_cpu_fans);
763 if (wf_smu_drive_fans)
764 kfree(wf_smu_cpu_fans);
765 if (wf_smu_cpu_fans)
766 kfree(wf_smu_cpu_fans);
767
768 wf_smu_dev = NULL;
769
770 return 0;
771}
772
773static struct device_driver wf_smu_driver = {
774 .name = "windfarm",
775 .bus = &platform_bus_type,
776 .probe = wf_smu_probe,
777 .remove = wf_smu_remove,
778};
779
780
781static int __init wf_smu_init(void)
782{
783 int rc = -ENODEV;
784
785 if (machine_is_compatible("PowerMac9,1"))
786 rc = wf_init_pm();
787
788 if (rc == 0) {
789#ifdef MODULE
790 request_module("windfarm_smu_controls");
791 request_module("windfarm_smu_sensors");
792 request_module("windfarm_lm75_sensor");
793
794#endif /* MODULE */
795 driver_register(&wf_smu_driver);
796 }
797
798 return rc;
799}
800
801static void __exit wf_smu_exit(void)
802{
803
804 driver_unregister(&wf_smu_driver);
805}
806
807
808module_init(wf_smu_init);
809module_exit(wf_smu_exit);
810
811MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
812MODULE_DESCRIPTION("Thermal control logic for PowerMac9,1");
813MODULE_LICENSE("GPL");
814
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c
new file mode 100644
index 000000000000..2c3158c81ff2
--- /dev/null
+++ b/drivers/macintosh/windfarm_smu_controls.c
@@ -0,0 +1,282 @@
1/*
2 * Windfarm PowerMac thermal control. SMU based controls
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 */
9
10#include <linux/types.h>
11#include <linux/errno.h>
12#include <linux/kernel.h>
13#include <linux/delay.h>
14#include <linux/slab.h>
15#include <linux/init.h>
16#include <linux/wait.h>
17#include <asm/prom.h>
18#include <asm/machdep.h>
19#include <asm/io.h>
20#include <asm/system.h>
21#include <asm/sections.h>
22#include <asm/smu.h>
23
24#include "windfarm.h"
25
26#define VERSION "0.3"
27
28#undef DEBUG
29
30#ifdef DEBUG
31#define DBG(args...) printk(args)
32#else
33#define DBG(args...) do { } while(0)
34#endif
35
36/*
37 * SMU fans control object
38 */
39
40static LIST_HEAD(smu_fans);
41
42struct smu_fan_control {
43 struct list_head link;
44 int fan_type; /* 0 = rpm, 1 = pwm */
45 u32 reg; /* index in SMU */
46 s32 value; /* current value */
47 s32 min, max; /* min/max values */
48 struct wf_control ctrl;
49};
50#define to_smu_fan(c) container_of(c, struct smu_fan_control, ctrl)
51
52static int smu_set_fan(int pwm, u8 id, u16 value)
53{
54 struct smu_cmd cmd;
55 u8 buffer[16];
56 DECLARE_COMPLETION(comp);
57 int rc;
58
59 /* Fill SMU command structure */
60 cmd.cmd = SMU_CMD_FAN_COMMAND;
61 cmd.data_len = 14;
62 cmd.reply_len = 16;
63 cmd.data_buf = cmd.reply_buf = buffer;
64 cmd.status = 0;
65 cmd.done = smu_done_complete;
66 cmd.misc = &comp;
67
68 /* Fill argument buffer */
69 memset(buffer, 0, 16);
70 buffer[0] = pwm ? 0x10 : 0x00;
71 buffer[1] = 0x01 << id;
72 *((u16 *)&buffer[2 + id * 2]) = value;
73
74 rc = smu_queue_cmd(&cmd);
75 if (rc)
76 return rc;
77 wait_for_completion(&comp);
78 return cmd.status;
79}
80
81static void smu_fan_release(struct wf_control *ct)
82{
83 struct smu_fan_control *fct = to_smu_fan(ct);
84
85 kfree(fct);
86}
87
88static int smu_fan_set(struct wf_control *ct, s32 value)
89{
90 struct smu_fan_control *fct = to_smu_fan(ct);
91
92 if (value < fct->min)
93 value = fct->min;
94 if (value > fct->max)
95 value = fct->max;
96 fct->value = value;
97
98 return smu_set_fan(fct->fan_type, fct->reg, value);
99}
100
101static int smu_fan_get(struct wf_control *ct, s32 *value)
102{
103 struct smu_fan_control *fct = to_smu_fan(ct);
104 *value = fct->value; /* todo: read from SMU */
105 return 0;
106}
107
108static s32 smu_fan_min(struct wf_control *ct)
109{
110 struct smu_fan_control *fct = to_smu_fan(ct);
111 return fct->min;
112}
113
114static s32 smu_fan_max(struct wf_control *ct)
115{
116 struct smu_fan_control *fct = to_smu_fan(ct);
117 return fct->max;
118}
119
120static struct wf_control_ops smu_fan_ops = {
121 .set_value = smu_fan_set,
122 .get_value = smu_fan_get,
123 .get_min = smu_fan_min,
124 .get_max = smu_fan_max,
125 .release = smu_fan_release,
126 .owner = THIS_MODULE,
127};
128
129static struct smu_fan_control *smu_fan_create(struct device_node *node,
130 int pwm_fan)
131{
132 struct smu_fan_control *fct;
133 s32 *v; u32 *reg;
134 char *l;
135
136 fct = kmalloc(sizeof(struct smu_fan_control), GFP_KERNEL);
137 if (fct == NULL)
138 return NULL;
139 fct->ctrl.ops = &smu_fan_ops;
140 l = (char *)get_property(node, "location", NULL);
141 if (l == NULL)
142 goto fail;
143
144 fct->fan_type = pwm_fan;
145 fct->ctrl.type = pwm_fan ? WF_CONTROL_PWM_FAN : WF_CONTROL_RPM_FAN;
146
147 /* We use the name & location here the same way we do for SMU sensors,
148 * see the comment in windfarm_smu_sensors.c. The locations are a bit
149 * less consistent here between the iMac and the desktop models, but
150 * that is good enough for our needs for now at least.
151 *
152 * One problem though is that Apple seem to be inconsistent with case
153 * and the kernel doesn't have strcasecmp =P
154 */
155
156 fct->ctrl.name = NULL;
157
158 /* Names used on desktop models */
159 if (!strcmp(l, "Rear Fan 0") || !strcmp(l, "Rear Fan") ||
160 !strcmp(l, "Rear fan 0") || !strcmp(l, "Rear fan"))
161 fct->ctrl.name = "cpu-rear-fan-0";
162 else if (!strcmp(l, "Rear Fan 1") || !strcmp(l, "Rear fan 1"))
163 fct->ctrl.name = "cpu-rear-fan-1";
164 else if (!strcmp(l, "Front Fan 0") || !strcmp(l, "Front Fan") ||
165 !strcmp(l, "Front fan 0") || !strcmp(l, "Front fan"))
166 fct->ctrl.name = "cpu-front-fan-0";
167 else if (!strcmp(l, "Front Fan 1") || !strcmp(l, "Front fan 1"))
168 fct->ctrl.name = "cpu-front-fan-1";
169 else if (!strcmp(l, "Slots Fan") || !strcmp(l, "Slots fan"))
170 fct->ctrl.name = "slots-fan";
171 else if (!strcmp(l, "Drive Bay") || !strcmp(l, "Drive bay"))
172 fct->ctrl.name = "drive-bay-fan";
173
174 /* Names used on iMac models */
175 if (!strcmp(l, "System Fan") || !strcmp(l, "System fan"))
176 fct->ctrl.name = "system-fan";
177 else if (!strcmp(l, "CPU Fan") || !strcmp(l, "CPU fan"))
178 fct->ctrl.name = "cpu-fan";
179 else if (!strcmp(l, "Hard Drive") || !strcmp(l, "Hard drive"))
180 fct->ctrl.name = "drive-bay-fan";
181
182 /* Unrecognized fan, bail out */
183 if (fct->ctrl.name == NULL)
184 goto fail;
185
186 /* Get min & max values*/
187 v = (s32 *)get_property(node, "min-value", NULL);
188 if (v == NULL)
189 goto fail;
190 fct->min = *v;
191 v = (s32 *)get_property(node, "max-value", NULL);
192 if (v == NULL)
193 goto fail;
194 fct->max = *v;
195
196 /* Get "reg" value */
197 reg = (u32 *)get_property(node, "reg", NULL);
198 if (reg == NULL)
199 goto fail;
200 fct->reg = *reg;
201
202 if (wf_register_control(&fct->ctrl))
203 goto fail;
204
205 return fct;
206 fail:
207 kfree(fct);
208 return NULL;
209}
210
211
212static int __init smu_controls_init(void)
213{
214 struct device_node *smu, *fans, *fan;
215
216 if (!smu_present())
217 return -ENODEV;
218
219 smu = of_find_node_by_type(NULL, "smu");
220 if (smu == NULL)
221 return -ENODEV;
222
223 /* Look for RPM fans */
224 for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;)
225 if (!strcmp(fans->name, "rpm-fans"))
226 break;
227 for (fan = NULL;
228 fans && (fan = of_get_next_child(fans, fan)) != NULL;) {
229 struct smu_fan_control *fct;
230
231 fct = smu_fan_create(fan, 0);
232 if (fct == NULL) {
233 printk(KERN_WARNING "windfarm: Failed to create SMU "
234 "RPM fan %s\n", fan->name);
235 continue;
236 }
237 list_add(&fct->link, &smu_fans);
238 }
239 of_node_put(fans);
240
241
242 /* Look for PWM fans */
243 for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;)
244 if (!strcmp(fans->name, "pwm-fans"))
245 break;
246 for (fan = NULL;
247 fans && (fan = of_get_next_child(fans, fan)) != NULL;) {
248 struct smu_fan_control *fct;
249
250 fct = smu_fan_create(fan, 1);
251 if (fct == NULL) {
252 printk(KERN_WARNING "windfarm: Failed to create SMU "
253 "PWM fan %s\n", fan->name);
254 continue;
255 }
256 list_add(&fct->link, &smu_fans);
257 }
258 of_node_put(fans);
259 of_node_put(smu);
260
261 return 0;
262}
263
264static void __exit smu_controls_exit(void)
265{
266 struct smu_fan_control *fct;
267
268 while (!list_empty(&smu_fans)) {
269 fct = list_entry(smu_fans.next, struct smu_fan_control, link);
270 list_del(&fct->link);
271 wf_unregister_control(&fct->ctrl);
272 }
273}
274
275
276module_init(smu_controls_init);
277module_exit(smu_controls_exit);
278
279MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
280MODULE_DESCRIPTION("SMU control objects for PowerMacs thermal control");
281MODULE_LICENSE("GPL");
282
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c
new file mode 100644
index 000000000000..b558cc209d49
--- /dev/null
+++ b/drivers/macintosh/windfarm_smu_sensors.c
@@ -0,0 +1,479 @@
1/*
2 * Windfarm PowerMac thermal control. SMU based sensors
3 *
4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 */
9
10#include <linux/types.h>
11#include <linux/errno.h>
12#include <linux/kernel.h>
13#include <linux/delay.h>
14#include <linux/slab.h>
15#include <linux/init.h>
16#include <linux/wait.h>
17#include <asm/prom.h>
18#include <asm/machdep.h>
19#include <asm/io.h>
20#include <asm/system.h>
21#include <asm/sections.h>
22#include <asm/smu.h>
23
24#include "windfarm.h"
25
26#define VERSION "0.2"
27
28#undef DEBUG
29
30#ifdef DEBUG
31#define DBG(args...) printk(args)
32#else
33#define DBG(args...) do { } while(0)
34#endif
35
36/*
37 * Various SMU "partitions" calibration objects for which we
38 * keep pointers here for use by bits & pieces of the driver
39 */
40static struct smu_sdbp_cpuvcp *cpuvcp;
41static int cpuvcp_version;
42static struct smu_sdbp_cpudiode *cpudiode;
43static struct smu_sdbp_slotspow *slotspow;
44static u8 *debugswitches;
45
46/*
47 * SMU basic sensors objects
48 */
49
50static LIST_HEAD(smu_ads);
51
52struct smu_ad_sensor {
53 struct list_head link;
54 u32 reg; /* index in SMU */
55 struct wf_sensor sens;
56};
57#define to_smu_ads(c) container_of(c, struct smu_ad_sensor, sens)
58
59static void smu_ads_release(struct wf_sensor *sr)
60{
61 struct smu_ad_sensor *ads = to_smu_ads(sr);
62
63 kfree(ads);
64}
65
66static int smu_read_adc(u8 id, s32 *value)
67{
68 struct smu_simple_cmd cmd;
69 DECLARE_COMPLETION(comp);
70 int rc;
71
72 rc = smu_queue_simple(&cmd, SMU_CMD_READ_ADC, 1,
73 smu_done_complete, &comp, id);
74 if (rc)
75 return rc;
76 wait_for_completion(&comp);
77 if (cmd.cmd.status != 0)
78 return cmd.cmd.status;
79 if (cmd.cmd.reply_len != 2) {
80 printk(KERN_ERR "winfarm: read ADC 0x%x returned %d bytes !\n",
81 id, cmd.cmd.reply_len);
82 return -EIO;
83 }
84 *value = *((u16 *)cmd.buffer);
85 return 0;
86}
87
88static int smu_cputemp_get(struct wf_sensor *sr, s32 *value)
89{
90 struct smu_ad_sensor *ads = to_smu_ads(sr);
91 int rc;
92 s32 val;
93 s64 scaled;
94
95 rc = smu_read_adc(ads->reg, &val);
96 if (rc) {
97 printk(KERN_ERR "windfarm: read CPU temp failed, err %d\n",
98 rc);
99 return rc;
100 }
101
102 /* Ok, we have to scale & adjust, taking units into account */
103 scaled = (s64)(((u64)val) * (u64)cpudiode->m_value);
104 scaled >>= 3;
105 scaled += ((s64)cpudiode->b_value) << 9;
106 *value = (s32)(scaled << 1);
107
108 return 0;
109}
110
111static int smu_cpuamp_get(struct wf_sensor *sr, s32 *value)
112{
113 struct smu_ad_sensor *ads = to_smu_ads(sr);
114 s32 val, scaled;
115 int rc;
116
117 rc = smu_read_adc(ads->reg, &val);
118 if (rc) {
119 printk(KERN_ERR "windfarm: read CPU current failed, err %d\n",
120 rc);
121 return rc;
122 }
123
124 /* Ok, we have to scale & adjust, taking units into account */
125 scaled = (s32)(val * (u32)cpuvcp->curr_scale);
126 scaled += (s32)cpuvcp->curr_offset;
127 *value = scaled << 4;
128
129 return 0;
130}
131
132static int smu_cpuvolt_get(struct wf_sensor *sr, s32 *value)
133{
134 struct smu_ad_sensor *ads = to_smu_ads(sr);
135 s32 val, scaled;
136 int rc;
137
138 rc = smu_read_adc(ads->reg, &val);
139 if (rc) {
140 printk(KERN_ERR "windfarm: read CPU voltage failed, err %d\n",
141 rc);
142 return rc;
143 }
144
145 /* Ok, we have to scale & adjust, taking units into account */
146 scaled = (s32)(val * (u32)cpuvcp->volt_scale);
147 scaled += (s32)cpuvcp->volt_offset;
148 *value = scaled << 4;
149
150 return 0;
151}
152
153static int smu_slotspow_get(struct wf_sensor *sr, s32 *value)
154{
155 struct smu_ad_sensor *ads = to_smu_ads(sr);
156 s32 val, scaled;
157 int rc;
158
159 rc = smu_read_adc(ads->reg, &val);
160 if (rc) {
161 printk(KERN_ERR "windfarm: read slots power failed, err %d\n",
162 rc);
163 return rc;
164 }
165
166 /* Ok, we have to scale & adjust, taking units into account */
167 scaled = (s32)(val * (u32)slotspow->pow_scale);
168 scaled += (s32)slotspow->pow_offset;
169 *value = scaled << 4;
170
171 return 0;
172}
173
174
175static struct wf_sensor_ops smu_cputemp_ops = {
176 .get_value = smu_cputemp_get,
177 .release = smu_ads_release,
178 .owner = THIS_MODULE,
179};
180static struct wf_sensor_ops smu_cpuamp_ops = {
181 .get_value = smu_cpuamp_get,
182 .release = smu_ads_release,
183 .owner = THIS_MODULE,
184};
185static struct wf_sensor_ops smu_cpuvolt_ops = {
186 .get_value = smu_cpuvolt_get,
187 .release = smu_ads_release,
188 .owner = THIS_MODULE,
189};
190static struct wf_sensor_ops smu_slotspow_ops = {
191 .get_value = smu_slotspow_get,
192 .release = smu_ads_release,
193 .owner = THIS_MODULE,
194};
195
196
197static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
198{
199 struct smu_ad_sensor *ads;
200 char *c, *l;
201 u32 *v;
202
203 ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL);
204 if (ads == NULL)
205 return NULL;
206 c = (char *)get_property(node, "device_type", NULL);
207 l = (char *)get_property(node, "location", NULL);
208 if (c == NULL || l == NULL)
209 goto fail;
210
211 /* We currently pick the sensors based on the OF name and location
212 * properties, while Darwin uses the sensor-id's.
213 * The problem with the IDs is that they are model specific while it
214 * looks like apple has been doing a reasonably good job at keeping
215 * the names and locations consistents so I'll stick with the names
216 * and locations for now.
217 */
218 if (!strcmp(c, "temp-sensor") &&
219 !strcmp(l, "CPU T-Diode")) {
220 ads->sens.ops = &smu_cputemp_ops;
221 ads->sens.name = "cpu-temp";
222 } else if (!strcmp(c, "current-sensor") &&
223 !strcmp(l, "CPU Current")) {
224 ads->sens.ops = &smu_cpuamp_ops;
225 ads->sens.name = "cpu-current";
226 } else if (!strcmp(c, "voltage-sensor") &&
227 !strcmp(l, "CPU Voltage")) {
228 ads->sens.ops = &smu_cpuvolt_ops;
229 ads->sens.name = "cpu-voltage";
230 } else if (!strcmp(c, "power-sensor") &&
231 !strcmp(l, "Slots Power")) {
232 ads->sens.ops = &smu_slotspow_ops;
233 ads->sens.name = "slots-power";
234 if (slotspow == NULL) {
235 DBG("wf: slotspow partition (%02x) not found\n",
236 SMU_SDB_SLOTSPOW_ID);
237 goto fail;
238 }
239 } else
240 goto fail;
241
242 v = (u32 *)get_property(node, "reg", NULL);
243 if (v == NULL)
244 goto fail;
245 ads->reg = *v;
246
247 if (wf_register_sensor(&ads->sens))
248 goto fail;
249 return ads;
250 fail:
251 kfree(ads);
252 return NULL;
253}
254
255/*
256 * SMU Power combo sensor object
257 */
258
259struct smu_cpu_power_sensor {
260 struct list_head link;
261 struct wf_sensor *volts;
262 struct wf_sensor *amps;
263 int fake_volts : 1;
264 int quadratic : 1;
265 struct wf_sensor sens;
266};
267#define to_smu_cpu_power(c) container_of(c, struct smu_cpu_power_sensor, sens)
268
269static struct smu_cpu_power_sensor *smu_cpu_power;
270
271static void smu_cpu_power_release(struct wf_sensor *sr)
272{
273 struct smu_cpu_power_sensor *pow = to_smu_cpu_power(sr);
274
275 if (pow->volts)
276 wf_put_sensor(pow->volts);
277 if (pow->amps)
278 wf_put_sensor(pow->amps);
279 kfree(pow);
280}
281
282static int smu_cpu_power_get(struct wf_sensor *sr, s32 *value)
283{
284 struct smu_cpu_power_sensor *pow = to_smu_cpu_power(sr);
285 s32 volts, amps, power;
286 u64 tmps, tmpa, tmpb;
287 int rc;
288
289 rc = pow->amps->ops->get_value(pow->amps, &amps);
290 if (rc)
291 return rc;
292
293 if (pow->fake_volts) {
294 *value = amps * 12 - 0x30000;
295 return 0;
296 }
297
298 rc = pow->volts->ops->get_value(pow->volts, &volts);
299 if (rc)
300 return rc;
301
302 power = (s32)((((u64)volts) * ((u64)amps)) >> 16);
303 if (!pow->quadratic) {
304 *value = power;
305 return 0;
306 }
307 tmps = (((u64)power) * ((u64)power)) >> 16;
308 tmpa = ((u64)cpuvcp->power_quads[0]) * tmps;
309 tmpb = ((u64)cpuvcp->power_quads[1]) * ((u64)power);
310 *value = (tmpa >> 28) + (tmpb >> 28) + (cpuvcp->power_quads[2] >> 12);
311
312 return 0;
313}
314
315static struct wf_sensor_ops smu_cpu_power_ops = {
316 .get_value = smu_cpu_power_get,
317 .release = smu_cpu_power_release,
318 .owner = THIS_MODULE,
319};
320
321
322static struct smu_cpu_power_sensor *
323smu_cpu_power_create(struct wf_sensor *volts, struct wf_sensor *amps)
324{
325 struct smu_cpu_power_sensor *pow;
326
327 pow = kmalloc(sizeof(struct smu_cpu_power_sensor), GFP_KERNEL);
328 if (pow == NULL)
329 return NULL;
330 pow->sens.ops = &smu_cpu_power_ops;
331 pow->sens.name = "cpu-power";
332
333 wf_get_sensor(volts);
334 pow->volts = volts;
335 wf_get_sensor(amps);
336 pow->amps = amps;
337
338 /* Some early machines need a faked voltage */
339 if (debugswitches && ((*debugswitches) & 0x80)) {
340 printk(KERN_INFO "windfarm: CPU Power sensor using faked"
341 " voltage !\n");
342 pow->fake_volts = 1;
343 } else
344 pow->fake_volts = 0;
345
346 /* Try to use quadratic transforms on PowerMac8,1 and 9,1 for now,
347 * I yet have to figure out what's up with 8,2 and will have to
348 * adjust for later, unless we can 100% trust the SDB partition...
349 */
350 if ((machine_is_compatible("PowerMac8,1") ||
351 machine_is_compatible("PowerMac8,2") ||
352 machine_is_compatible("PowerMac9,1")) &&
353 cpuvcp_version >= 2) {
354 pow->quadratic = 1;
355 DBG("windfarm: CPU Power using quadratic transform\n");
356 } else
357 pow->quadratic = 0;
358
359 if (wf_register_sensor(&pow->sens))
360 goto fail;
361 return pow;
362 fail:
363 kfree(pow);
364 return NULL;
365}
366
367static int smu_fetch_param_partitions(void)
368{
369 struct smu_sdbp_header *hdr;
370
371 /* Get CPU voltage/current/power calibration data */
372 hdr = smu_get_sdb_partition(SMU_SDB_CPUVCP_ID, NULL);
373 if (hdr == NULL) {
374 DBG("wf: cpuvcp partition (%02x) not found\n",
375 SMU_SDB_CPUVCP_ID);
376 return -ENODEV;
377 }
378 cpuvcp = (struct smu_sdbp_cpuvcp *)&hdr[1];
379 /* Keep version around */
380 cpuvcp_version = hdr->version;
381
382 /* Get CPU diode calibration data */
383 hdr = smu_get_sdb_partition(SMU_SDB_CPUDIODE_ID, NULL);
384 if (hdr == NULL) {
385 DBG("wf: cpudiode partition (%02x) not found\n",
386 SMU_SDB_CPUDIODE_ID);
387 return -ENODEV;
388 }
389 cpudiode = (struct smu_sdbp_cpudiode *)&hdr[1];
390
391 /* Get slots power calibration data if any */
392 hdr = smu_get_sdb_partition(SMU_SDB_SLOTSPOW_ID, NULL);
393 if (hdr != NULL)
394 slotspow = (struct smu_sdbp_slotspow *)&hdr[1];
395
396 /* Get debug switches if any */
397 hdr = smu_get_sdb_partition(SMU_SDB_DEBUG_SWITCHES_ID, NULL);
398 if (hdr != NULL)
399 debugswitches = (u8 *)&hdr[1];
400
401 return 0;
402}
403
404static int __init smu_sensors_init(void)
405{
406 struct device_node *smu, *sensors, *s;
407 struct smu_ad_sensor *volt_sensor = NULL, *curr_sensor = NULL;
408 int rc;
409
410 if (!smu_present())
411 return -ENODEV;
412
413 /* Get parameters partitions */
414 rc = smu_fetch_param_partitions();
415 if (rc)
416 return rc;
417
418 smu = of_find_node_by_type(NULL, "smu");
419 if (smu == NULL)
420 return -ENODEV;
421
422 /* Look for sensors subdir */
423 for (sensors = NULL;
424 (sensors = of_get_next_child(smu, sensors)) != NULL;)
425 if (!strcmp(sensors->name, "sensors"))
426 break;
427
428 of_node_put(smu);
429
430 /* Create basic sensors */
431 for (s = NULL;
432 sensors && (s = of_get_next_child(sensors, s)) != NULL;) {
433 struct smu_ad_sensor *ads;
434
435 ads = smu_ads_create(s);
436 if (ads == NULL)
437 continue;
438 list_add(&ads->link, &smu_ads);
439 /* keep track of cpu voltage & current */
440 if (!strcmp(ads->sens.name, "cpu-voltage"))
441 volt_sensor = ads;
442 else if (!strcmp(ads->sens.name, "cpu-current"))
443 curr_sensor = ads;
444 }
445
446 of_node_put(sensors);
447
448 /* Create CPU power sensor if possible */
449 if (volt_sensor && curr_sensor)
450 smu_cpu_power = smu_cpu_power_create(&volt_sensor->sens,
451 &curr_sensor->sens);
452
453 return 0;
454}
455
456static void __exit smu_sensors_exit(void)
457{
458 struct smu_ad_sensor *ads;
459
460 /* dispose of power sensor */
461 if (smu_cpu_power)
462 wf_unregister_sensor(&smu_cpu_power->sens);
463
464 /* dispose of basic sensors */
465 while (!list_empty(&smu_ads)) {
466 ads = list_entry(smu_ads.next, struct smu_ad_sensor, link);
467 list_del(&ads->link);
468 wf_unregister_sensor(&ads->sens);
469 }
470}
471
472
473module_init(smu_sensors_init);
474module_exit(smu_sensors_exit);
475
476MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
477MODULE_DESCRIPTION("SMU sensor objects for PowerMacs thermal control");
478MODULE_LICENSE("GPL");
479
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 6497295ebfb9..1223e98ecd70 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1587,8 +1587,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1587 /* make sure we don't swamp the stripe cache if someone else 1587 /* make sure we don't swamp the stripe cache if someone else
1588 * is trying to get access 1588 * is trying to get access
1589 */ 1589 */
1590 set_current_state(TASK_UNINTERRUPTIBLE); 1590 schedule_timeout_uninterruptible(1);
1591 schedule_timeout(1);
1592 } 1591 }
1593 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 0); 1592 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 0);
1594 spin_lock(&sh->lock); 1593 spin_lock(&sh->lock);
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 6437a95ffc1c..775786947701 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -1746,8 +1746,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1746 /* make sure we don't swamp the stripe cache if someone else 1746 /* make sure we don't swamp the stripe cache if someone else
1747 * is trying to get access 1747 * is trying to get access
1748 */ 1748 */
1749 set_current_state(TASK_UNINTERRUPTIBLE); 1749 schedule_timeout_uninterruptible(1);
1750 schedule_timeout(1);
1751 } 1750 }
1752 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 0); 1751 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 0);
1753 spin_lock(&sh->lock); 1752 spin_lock(&sh->lock);
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 34a837a1abf4..b3c9d7327ac1 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1331,9 +1331,7 @@ struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
1331{ 1331{
1332 /* check if the ASIC is there */ 1332 /* check if the ASIC is there */
1333 if (dst_probe(state) < 0) { 1333 if (dst_probe(state) < 0) {
1334 if (state) 1334 kfree(state);
1335 kfree(state);
1336
1337 return NULL; 1335 return NULL;
1338 } 1336 }
1339 /* determine settings based on type */ 1337 /* determine settings based on type */
@@ -1349,9 +1347,7 @@ struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
1349 break; 1347 break;
1350 default: 1348 default:
1351 dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist."); 1349 dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist.");
1352 if (state) 1350 kfree(state);
1353 kfree(state);
1354
1355 return NULL; 1351 return NULL;
1356 } 1352 }
1357 1353
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c
index d4b97989e3ed..654d7dc879d9 100644
--- a/drivers/media/dvb/frontends/cx24110.c
+++ b/drivers/media/dvb/frontends/cx24110.c
@@ -27,6 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/jiffies.h>
30 31
31#include "dvb_frontend.h" 32#include "dvb_frontend.h"
32#include "cx24110.h" 33#include "cx24110.h"
diff --git a/drivers/media/dvb/frontends/dvb_dummy_fe.c b/drivers/media/dvb/frontends/dvb_dummy_fe.c
index 794be520d590..645946a992d9 100644
--- a/drivers/media/dvb/frontends/dvb_dummy_fe.c
+++ b/drivers/media/dvb/frontends/dvb_dummy_fe.c
@@ -148,7 +148,7 @@ struct dvb_frontend* dvb_dummy_fe_qpsk_attach()
148 return &state->frontend; 148 return &state->frontend;
149 149
150error: 150error:
151 if (state) kfree(state); 151 kfree(state);
152 return NULL; 152 return NULL;
153} 153}
154 154
@@ -171,7 +171,7 @@ struct dvb_frontend* dvb_dummy_fe_qam_attach()
171 return &state->frontend; 171 return &state->frontend;
172 172
173error: 173error:
174 if (state) kfree(state); 174 kfree(state);
175 return NULL; 175 return NULL;
176} 176}
177 177
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
index faaad1ae8559..19b4bf7c21a7 100644
--- a/drivers/media/dvb/frontends/l64781.c
+++ b/drivers/media/dvb/frontends/l64781.c
@@ -559,7 +559,8 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
559 return &state->frontend; 559 return &state->frontend;
560 560
561error: 561error:
562 if (reg0x3e >= 0) l64781_writereg (state, 0x3e, reg0x3e); /* restore reg 0x3e */ 562 if (reg0x3e >= 0)
563 l64781_writereg (state, 0x3e, reg0x3e); /* restore reg 0x3e */
563 kfree(state); 564 kfree(state);
564 return NULL; 565 return NULL;
565} 566}
diff --git a/drivers/media/dvb/frontends/lgdt330x.c b/drivers/media/dvb/frontends/lgdt330x.c
index 8dde72bd1046..7852b83b82d4 100644
--- a/drivers/media/dvb/frontends/lgdt330x.c
+++ b/drivers/media/dvb/frontends/lgdt330x.c
@@ -731,8 +731,7 @@ struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
731 return &state->frontend; 731 return &state->frontend;
732 732
733error: 733error:
734 if (state) 734 kfree(state);
735 kfree(state);
736 dprintk("%s: ERROR\n",__FUNCTION__); 735 dprintk("%s: ERROR\n",__FUNCTION__);
737 return NULL; 736 return NULL;
738} 737}
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index e38454901dd1..9c67f406d581 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -677,8 +677,7 @@ struct dvb_frontend* mt312_attach(const struct mt312_config* config,
677 return &state->frontend; 677 return &state->frontend;
678 678
679error: 679error:
680 if (state) 680 kfree(state);
681 kfree(state);
682 return NULL; 681 return NULL;
683} 682}
684 683
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c
index 817b044c7fd1..fc74c40d6477 100644
--- a/drivers/media/dvb/frontends/or51132.c
+++ b/drivers/media/dvb/frontends/or51132.c
@@ -577,8 +577,7 @@ struct dvb_frontend* or51132_attach(const struct or51132_config* config,
577 return &state->frontend; 577 return &state->frontend;
578 578
579error: 579error:
580 if (state) 580 kfree(state);
581 kfree(state);
582 return NULL; 581 return NULL;
583} 582}
584 583
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 87fd3a7bb392..0823ddaf7004 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -865,10 +865,8 @@ out_dev:
865 865
866out_irq: 866out_irq:
867#endif 867#endif
868 for (i = 0; i < MAX_AR_HEIGHT; i++) { 868 for (i = 0; i < MAX_AR_HEIGHT; i++)
869 if (ar->frame[i]) 869 kfree(ar->frame[i]);
870 kfree(ar->frame[i]);
871 }
872 870
873out_line_buff: 871out_line_buff:
874#if USE_INT 872#if USE_INT
@@ -899,10 +897,8 @@ static void __exit ar_cleanup_module(void)
899#if USE_INT 897#if USE_INT
900 free_irq(M32R_IRQ_INT3, ar); 898 free_irq(M32R_IRQ_INT3, ar);
901#endif 899#endif
902 for (i = 0; i < MAX_AR_HEIGHT; i++) { 900 for (i = 0; i < MAX_AR_HEIGHT; i++)
903 if (ar->frame[i]) 901 kfree(ar->frame[i]);
904 kfree(ar->frame[i]);
905 }
906#if USE_INT 902#if USE_INT
907 kfree(ar->line_buff); 903 kfree(ar->line_buff);
908#endif 904#endif
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index c062a017491e..d538a994ff04 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -1951,8 +1951,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
1951 } 1951 }
1952 1952
1953 down(&fh->cap.lock); 1953 down(&fh->cap.lock);
1954 if (fh->ov.clips) 1954 kfree(fh->ov.clips);
1955 kfree(fh->ov.clips);
1956 fh->ov.clips = clips; 1955 fh->ov.clips = clips;
1957 fh->ov.nclips = n; 1956 fh->ov.nclips = n;
1958 1957
@@ -2723,8 +2722,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2723 fh->ov.w.height = fb->fmt.height; 2722 fh->ov.w.height = fb->fmt.height;
2724 btv->init.ov.w.width = fb->fmt.width; 2723 btv->init.ov.w.width = fb->fmt.width;
2725 btv->init.ov.w.height = fb->fmt.height; 2724 btv->init.ov.w.height = fb->fmt.height;
2726 if (fh->ov.clips) 2725 kfree(fh->ov.clips);
2727 kfree(fh->ov.clips);
2728 fh->ov.clips = NULL; 2726 fh->ov.clips = NULL;
2729 fh->ov.nclips = 0; 2727 fh->ov.nclips = 0;
2730 2728
diff --git a/drivers/media/video/indycam.c b/drivers/media/video/indycam.c
index 26dd06ec89a2..deeef125eb92 100644
--- a/drivers/media/video/indycam.c
+++ b/drivers/media/video/indycam.c
@@ -27,15 +27,15 @@
27 27
28#include "indycam.h" 28#include "indycam.h"
29 29
30//#define INDYCAM_DEBUG 30#define INDYCAM_MODULE_VERSION "0.0.5"
31
32#define INDYCAM_MODULE_VERSION "0.0.3"
33 31
34MODULE_DESCRIPTION("SGI IndyCam driver"); 32MODULE_DESCRIPTION("SGI IndyCam driver");
35MODULE_VERSION(INDYCAM_MODULE_VERSION); 33MODULE_VERSION(INDYCAM_MODULE_VERSION);
36MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); 34MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>");
37MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
38 36
37// #define INDYCAM_DEBUG
38
39#ifdef INDYCAM_DEBUG 39#ifdef INDYCAM_DEBUG
40#define dprintk(x...) printk("IndyCam: " x); 40#define dprintk(x...) printk("IndyCam: " x);
41#define indycam_regdump(client) indycam_regdump_debug(client) 41#define indycam_regdump(client) indycam_regdump_debug(client)
@@ -46,14 +46,14 @@ MODULE_LICENSE("GPL");
46 46
47struct indycam { 47struct indycam {
48 struct i2c_client *client; 48 struct i2c_client *client;
49 int version; 49 u8 version;
50}; 50};
51 51
52static struct i2c_driver i2c_driver_indycam; 52static struct i2c_driver i2c_driver_indycam;
53 53
54static const unsigned char initseq[] = { 54static const u8 initseq[] = {
55 INDYCAM_CONTROL_AGCENA, /* INDYCAM_CONTROL */ 55 INDYCAM_CONTROL_AGCENA, /* INDYCAM_CONTROL */
56 INDYCAM_SHUTTER_DEFAULT, /* INDYCAM_SHUTTER */ 56 INDYCAM_SHUTTER_60, /* INDYCAM_SHUTTER */
57 INDYCAM_GAIN_DEFAULT, /* INDYCAM_GAIN */ 57 INDYCAM_GAIN_DEFAULT, /* INDYCAM_GAIN */
58 0x00, /* INDYCAM_BRIGHTNESS (read-only) */ 58 0x00, /* INDYCAM_BRIGHTNESS (read-only) */
59 INDYCAM_RED_BALANCE_DEFAULT, /* INDYCAM_RED_BALANCE */ 59 INDYCAM_RED_BALANCE_DEFAULT, /* INDYCAM_RED_BALANCE */
@@ -64,12 +64,11 @@ static const unsigned char initseq[] = {
64 64
65/* IndyCam register handling */ 65/* IndyCam register handling */
66 66
67static int indycam_read_reg(struct i2c_client *client, unsigned char reg, 67static int indycam_read_reg(struct i2c_client *client, u8 reg, u8 *value)
68 unsigned char *value)
69{ 68{
70 int ret; 69 int ret;
71 70
72 if (reg == INDYCAM_RESET) { 71 if (reg == INDYCAM_REG_RESET) {
73 dprintk("indycam_read_reg(): " 72 dprintk("indycam_read_reg(): "
74 "skipping write-only register %d\n", reg); 73 "skipping write-only register %d\n", reg);
75 *value = 0; 74 *value = 0;
@@ -77,24 +76,24 @@ static int indycam_read_reg(struct i2c_client *client, unsigned char reg,
77 } 76 }
78 77
79 ret = i2c_smbus_read_byte_data(client, reg); 78 ret = i2c_smbus_read_byte_data(client, reg);
79
80 if (ret < 0) { 80 if (ret < 0) {
81 printk(KERN_ERR "IndyCam: indycam_read_reg(): read failed, " 81 printk(KERN_ERR "IndyCam: indycam_read_reg(): read failed, "
82 "register = 0x%02x\n", reg); 82 "register = 0x%02x\n", reg);
83 return ret; 83 return ret;
84 } 84 }
85 85
86 *value = (unsigned char)ret; 86 *value = (u8)ret;
87 87
88 return 0; 88 return 0;
89} 89}
90 90
91static int indycam_write_reg(struct i2c_client *client, unsigned char reg, 91static int indycam_write_reg(struct i2c_client *client, u8 reg, u8 value)
92 unsigned char value)
93{ 92{
94 int err; 93 int err;
95 94
96 if ((reg == INDYCAM_BRIGHTNESS) 95 if ((reg == INDYCAM_REG_BRIGHTNESS)
97 || (reg == INDYCAM_VERSION)) { 96 || (reg == INDYCAM_REG_VERSION)) {
98 dprintk("indycam_write_reg(): " 97 dprintk("indycam_write_reg(): "
99 "skipping read-only register %d\n", reg); 98 "skipping read-only register %d\n", reg);
100 return 0; 99 return 0;
@@ -102,6 +101,7 @@ static int indycam_write_reg(struct i2c_client *client, unsigned char reg,
102 101
103 dprintk("Writing Reg %d = 0x%02x\n", reg, value); 102 dprintk("Writing Reg %d = 0x%02x\n", reg, value);
104 err = i2c_smbus_write_byte_data(client, reg, value); 103 err = i2c_smbus_write_byte_data(client, reg, value);
104
105 if (err) { 105 if (err) {
106 printk(KERN_ERR "IndyCam: indycam_write_reg(): write failed, " 106 printk(KERN_ERR "IndyCam: indycam_write_reg(): write failed, "
107 "register = 0x%02x, value = 0x%02x\n", reg, value); 107 "register = 0x%02x, value = 0x%02x\n", reg, value);
@@ -109,13 +109,12 @@ static int indycam_write_reg(struct i2c_client *client, unsigned char reg,
109 return err; 109 return err;
110} 110}
111 111
112static int indycam_write_block(struct i2c_client *client, unsigned char reg, 112static int indycam_write_block(struct i2c_client *client, u8 reg,
113 unsigned char length, unsigned char *data) 113 u8 length, u8 *data)
114{ 114{
115 unsigned char i; 115 int i, err;
116 int err;
117 116
118 for (i = reg; i < length; i++) { 117 for (i = 0; i < length; i++) {
119 err = indycam_write_reg(client, reg + i, data[i]); 118 err = indycam_write_reg(client, reg + i, data[i]);
120 if (err) 119 if (err)
121 return err; 120 return err;
@@ -130,7 +129,7 @@ static int indycam_write_block(struct i2c_client *client, unsigned char reg,
130static void indycam_regdump_debug(struct i2c_client *client) 129static void indycam_regdump_debug(struct i2c_client *client)
131{ 130{
132 int i; 131 int i;
133 unsigned char val; 132 u8 val;
134 133
135 for (i = 0; i < 9; i++) { 134 for (i = 0; i < 9; i++) {
136 indycam_read_reg(client, i, &val); 135 indycam_read_reg(client, i, &val);
@@ -139,76 +138,144 @@ static void indycam_regdump_debug(struct i2c_client *client)
139} 138}
140#endif 139#endif
141 140
142static int indycam_get_controls(struct i2c_client *client, 141static int indycam_get_control(struct i2c_client *client,
143 struct indycam_control *ctrl) 142 struct indycam_control *ctrl)
144{ 143{
145 unsigned char ctrl_reg; 144 struct indycam *camera = i2c_get_clientdata(client);
146 145 u8 reg;
147 indycam_read_reg(client, INDYCAM_CONTROL, &ctrl_reg); 146 int ret = 0;
148 ctrl->agc = (ctrl_reg & INDYCAM_CONTROL_AGCENA) 147
149 ? INDYCAM_VALUE_ENABLED 148 switch (ctrl->type) {
150 : INDYCAM_VALUE_DISABLED; 149 case INDYCAM_CONTROL_AGC:
151 ctrl->awb = (ctrl_reg & INDYCAM_CONTROL_AWBCTL) 150 case INDYCAM_CONTROL_AWB:
152 ? INDYCAM_VALUE_ENABLED 151 ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, &reg);
153 : INDYCAM_VALUE_DISABLED; 152 if (ret)
154 indycam_read_reg(client, INDYCAM_SHUTTER, 153 return -EIO;
155 (unsigned char *)&ctrl->shutter); 154 if (ctrl->type == INDYCAM_CONTROL_AGC)
156 indycam_read_reg(client, INDYCAM_GAIN, 155 ctrl->value = (reg & INDYCAM_CONTROL_AGCENA)
157 (unsigned char *)&ctrl->gain); 156 ? 1 : 0;
158 indycam_read_reg(client, INDYCAM_RED_BALANCE, 157 else
159 (unsigned char *)&ctrl->red_balance); 158 ctrl->value = (reg & INDYCAM_CONTROL_AWBCTL)
160 indycam_read_reg(client, INDYCAM_BLUE_BALANCE, 159 ? 1 : 0;
161 (unsigned char *)&ctrl->blue_balance); 160 break;
162 indycam_read_reg(client, INDYCAM_RED_SATURATION, 161 case INDYCAM_CONTROL_SHUTTER:
163 (unsigned char *)&ctrl->red_saturation); 162 ret = indycam_read_reg(client, INDYCAM_REG_SHUTTER, &reg);
164 indycam_read_reg(client, INDYCAM_BLUE_SATURATION, 163 if (ret)
165 (unsigned char *)&ctrl->blue_saturation); 164 return -EIO;
166 indycam_read_reg(client, INDYCAM_GAMMA, 165 ctrl->value = ((s32)reg == 0x00) ? 0xff : ((s32)reg - 1);
167 (unsigned char *)&ctrl->gamma); 166 break;
167 case INDYCAM_CONTROL_GAIN:
168 ret = indycam_read_reg(client, INDYCAM_REG_GAIN, &reg);
169 if (ret)
170 return -EIO;
171 ctrl->value = (s32)reg;
172 break;
173 case INDYCAM_CONTROL_RED_BALANCE:
174 ret = indycam_read_reg(client, INDYCAM_REG_RED_BALANCE, &reg);
175 if (ret)
176 return -EIO;
177 ctrl->value = (s32)reg;
178 break;
179 case INDYCAM_CONTROL_BLUE_BALANCE:
180 ret = indycam_read_reg(client, INDYCAM_REG_BLUE_BALANCE, &reg);
181 if (ret)
182 return -EIO;
183 ctrl->value = (s32)reg;
184 break;
185 case INDYCAM_CONTROL_RED_SATURATION:
186 ret = indycam_read_reg(client,
187 INDYCAM_REG_RED_SATURATION, &reg);
188 if (ret)
189 return -EIO;
190 ctrl->value = (s32)reg;
191 break;
192 case INDYCAM_CONTROL_BLUE_SATURATION:
193 ret = indycam_read_reg(client,
194 INDYCAM_REG_BLUE_SATURATION, &reg);
195 if (ret)
196 return -EIO;
197 ctrl->value = (s32)reg;
198 break;
199 case INDYCAM_CONTROL_GAMMA:
200 if (camera->version == CAMERA_VERSION_MOOSE) {
201 ret = indycam_read_reg(client,
202 INDYCAM_REG_GAMMA, &reg);
203 if (ret)
204 return -EIO;
205 ctrl->value = (s32)reg;
206 } else {
207 ctrl->value = INDYCAM_GAMMA_DEFAULT;
208 }
209 break;
210 default:
211 ret = -EINVAL;
212 }
168 213
169 return 0; 214 return ret;
170} 215}
171 216
172static int indycam_set_controls(struct i2c_client *client, 217static int indycam_set_control(struct i2c_client *client,
173 struct indycam_control *ctrl) 218 struct indycam_control *ctrl)
174{ 219{
175 unsigned char ctrl_reg; 220 struct indycam *camera = i2c_get_clientdata(client);
221 u8 reg;
222 int ret = 0;
223
224 switch (ctrl->type) {
225 case INDYCAM_CONTROL_AGC:
226 case INDYCAM_CONTROL_AWB:
227 ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, &reg);
228 if (ret)
229 break;
176 230
177 indycam_read_reg(client, INDYCAM_CONTROL, &ctrl_reg); 231 if (ctrl->type == INDYCAM_CONTROL_AGC) {
178 if (ctrl->agc != INDYCAM_VALUE_UNCHANGED) { 232 if (ctrl->value)
179 if (ctrl->agc) 233 reg |= INDYCAM_CONTROL_AGCENA;
180 ctrl_reg |= INDYCAM_CONTROL_AGCENA; 234 else
181 else 235 reg &= ~INDYCAM_CONTROL_AGCENA;
182 ctrl_reg &= ~INDYCAM_CONTROL_AGCENA; 236 } else {
183 } 237 if (ctrl->value)
184 if (ctrl->awb != INDYCAM_VALUE_UNCHANGED) { 238 reg |= INDYCAM_CONTROL_AWBCTL;
185 if (ctrl->awb) 239 else
186 ctrl_reg |= INDYCAM_CONTROL_AWBCTL; 240 reg &= ~INDYCAM_CONTROL_AWBCTL;
187 else 241 }
188 ctrl_reg &= ~INDYCAM_CONTROL_AWBCTL; 242
243 ret = indycam_write_reg(client, INDYCAM_REG_CONTROL, reg);
244 break;
245 case INDYCAM_CONTROL_SHUTTER:
246 reg = (ctrl->value == 0xff) ? 0x00 : (ctrl->value + 1);
247 ret = indycam_write_reg(client, INDYCAM_REG_SHUTTER, reg);
248 break;
249 case INDYCAM_CONTROL_GAIN:
250 ret = indycam_write_reg(client, INDYCAM_REG_GAIN, ctrl->value);
251 break;
252 case INDYCAM_CONTROL_RED_BALANCE:
253 ret = indycam_write_reg(client, INDYCAM_REG_RED_BALANCE,
254 ctrl->value);
255 break;
256 case INDYCAM_CONTROL_BLUE_BALANCE:
257 ret = indycam_write_reg(client, INDYCAM_REG_BLUE_BALANCE,
258 ctrl->value);
259 break;
260 case INDYCAM_CONTROL_RED_SATURATION:
261 ret = indycam_write_reg(client, INDYCAM_REG_RED_SATURATION,
262 ctrl->value);
263 break;
264 case INDYCAM_CONTROL_BLUE_SATURATION:
265 ret = indycam_write_reg(client, INDYCAM_REG_BLUE_SATURATION,
266 ctrl->value);
267 break;
268 case INDYCAM_CONTROL_GAMMA:
269 if (camera->version == CAMERA_VERSION_MOOSE) {
270 ret = indycam_write_reg(client, INDYCAM_REG_GAMMA,
271 ctrl->value);
272 }
273 break;
274 default:
275 ret = -EINVAL;
189 } 276 }
190 indycam_write_reg(client, INDYCAM_CONTROL, ctrl_reg);
191
192 if (ctrl->shutter >= 0)
193 indycam_write_reg(client, INDYCAM_SHUTTER, ctrl->shutter);
194 if (ctrl->gain >= 0)
195 indycam_write_reg(client, INDYCAM_GAIN, ctrl->gain);
196 if (ctrl->red_balance >= 0)
197 indycam_write_reg(client, INDYCAM_RED_BALANCE,
198 ctrl->red_balance);
199 if (ctrl->blue_balance >= 0)
200 indycam_write_reg(client, INDYCAM_BLUE_BALANCE,
201 ctrl->blue_balance);
202 if (ctrl->red_saturation >= 0)
203 indycam_write_reg(client, INDYCAM_RED_SATURATION,
204 ctrl->red_saturation);
205 if (ctrl->blue_saturation >= 0)
206 indycam_write_reg(client, INDYCAM_BLUE_SATURATION,
207 ctrl->blue_saturation);
208 if (ctrl->gamma >= 0)
209 indycam_write_reg(client, INDYCAM_GAMMA, ctrl->gamma);
210 277
211 return 0; 278 return ret;
212} 279}
213 280
214/* I2C-interface */ 281/* I2C-interface */
@@ -247,7 +314,8 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind)
247 if (err) 314 if (err)
248 goto out_free_camera; 315 goto out_free_camera;
249 316
250 camera->version = i2c_smbus_read_byte_data(client, INDYCAM_VERSION); 317 camera->version = i2c_smbus_read_byte_data(client,
318 INDYCAM_REG_VERSION);
251 if (camera->version != CAMERA_VERSION_INDY && 319 if (camera->version != CAMERA_VERSION_INDY &&
252 camera->version != CAMERA_VERSION_MOOSE) { 320 camera->version != CAMERA_VERSION_MOOSE) {
253 err = -ENODEV; 321 err = -ENODEV;
@@ -260,8 +328,7 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind)
260 indycam_regdump(client); 328 indycam_regdump(client);
261 329
262 // initialize 330 // initialize
263 err = indycam_write_block(client, 0, sizeof(initseq), 331 err = indycam_write_block(client, 0, sizeof(initseq), (u8 *)&initseq);
264 (unsigned char *)&initseq);
265 if (err) { 332 if (err) {
266 printk(KERN_ERR "IndyCam initalization failed\n"); 333 printk(KERN_ERR "IndyCam initalization failed\n");
267 err = -EIO; 334 err = -EIO;
@@ -271,11 +338,10 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind)
271 indycam_regdump(client); 338 indycam_regdump(client);
272 339
273 // white balance 340 // white balance
274 err = indycam_write_reg(client, INDYCAM_CONTROL, 341 err = indycam_write_reg(client, INDYCAM_REG_CONTROL,
275 INDYCAM_CONTROL_AGCENA | INDYCAM_CONTROL_AWBCTL); 342 INDYCAM_CONTROL_AGCENA | INDYCAM_CONTROL_AWBCTL);
276 if (err) { 343 if (err) {
277 printk(KERN_ERR "IndyCam white balance " 344 printk(KERN_ERR "IndyCam: White balancing camera failed\n");
278 "initialization failed\n");
279 err = -EIO; 345 err = -EIO;
280 goto out_detach_client; 346 goto out_detach_client;
281 } 347 }
@@ -371,13 +437,11 @@ static int indycam_command(struct i2c_client *client, unsigned int cmd,
371 /* TODO: convert values for indycam_set_controls() */ 437 /* TODO: convert values for indycam_set_controls() */
372 break; 438 break;
373 } 439 }
374 case DECODER_INDYCAM_GET_CONTROLS: { 440 case DECODER_INDYCAM_GET_CONTROL: {
375 struct indycam_control *ctrl = arg; 441 return indycam_get_control(client, arg);
376 indycam_get_controls(client, ctrl);
377 } 442 }
378 case DECODER_INDYCAM_SET_CONTROLS: { 443 case DECODER_INDYCAM_SET_CONTROL: {
379 struct indycam_control *ctrl = arg; 444 return indycam_set_control(client, arg);
380 indycam_set_controls(client, ctrl);
381 } 445 }
382 default: 446 default:
383 return -EINVAL; 447 return -EINVAL;
@@ -388,12 +452,12 @@ static int indycam_command(struct i2c_client *client, unsigned int cmd,
388 452
389static struct i2c_driver i2c_driver_indycam = { 453static struct i2c_driver i2c_driver_indycam = {
390 .owner = THIS_MODULE, 454 .owner = THIS_MODULE,
391 .name = "indycam", 455 .name = "indycam",
392 .id = I2C_DRIVERID_INDYCAM, 456 .id = I2C_DRIVERID_INDYCAM,
393 .flags = I2C_DF_NOTIFY, 457 .flags = I2C_DF_NOTIFY,
394 .attach_adapter = indycam_probe, 458 .attach_adapter = indycam_probe,
395 .detach_client = indycam_detach, 459 .detach_client = indycam_detach,
396 .command = indycam_command, 460 .command = indycam_command,
397}; 461};
398 462
399static int __init indycam_init(void) 463static int __init indycam_init(void)
diff --git a/drivers/media/video/indycam.h b/drivers/media/video/indycam.h
index d9ddb6b79a03..e6ee82063ed8 100644
--- a/drivers/media/video/indycam.h
+++ b/drivers/media/video/indycam.h
@@ -22,21 +22,21 @@
22#define INDYCAM_VERSION_MINOR(x) ((x) & 0x0f) 22#define INDYCAM_VERSION_MINOR(x) ((x) & 0x0f)
23 23
24/* Register bus addresses */ 24/* Register bus addresses */
25#define INDYCAM_CONTROL 0x00 25#define INDYCAM_REG_CONTROL 0x00
26#define INDYCAM_SHUTTER 0x01 26#define INDYCAM_REG_SHUTTER 0x01
27#define INDYCAM_GAIN 0x02 27#define INDYCAM_REG_GAIN 0x02
28#define INDYCAM_BRIGHTNESS 0x03 /* read-only */ 28#define INDYCAM_REG_BRIGHTNESS 0x03 /* read-only */
29#define INDYCAM_RED_BALANCE 0x04 29#define INDYCAM_REG_RED_BALANCE 0x04
30#define INDYCAM_BLUE_BALANCE 0x05 30#define INDYCAM_REG_BLUE_BALANCE 0x05
31#define INDYCAM_RED_SATURATION 0x06 31#define INDYCAM_REG_RED_SATURATION 0x06
32#define INDYCAM_BLUE_SATURATION 0x07 32#define INDYCAM_REG_BLUE_SATURATION 0x07
33#define INDYCAM_GAMMA 0x08 33#define INDYCAM_REG_GAMMA 0x08
34#define INDYCAM_VERSION 0x0e /* read-only */ 34#define INDYCAM_REG_VERSION 0x0e /* read-only */
35#define INDYCAM_RESET 0x0f /* write-only */ 35#define INDYCAM_REG_RESET 0x0f /* write-only */
36 36
37#define INDYCAM_LED 0x46 37#define INDYCAM_REG_LED 0x46
38#define INDYCAM_ORIENTATION 0x47 38#define INDYCAM_REG_ORIENTATION 0x47
39#define INDYCAM_BUTTON 0x48 39#define INDYCAM_REG_BUTTON 0x48
40 40
41/* Field definitions of registers */ 41/* Field definitions of registers */
42#define INDYCAM_CONTROL_AGCENA (1<<0) /* automatic gain control */ 42#define INDYCAM_CONTROL_AGCENA (1<<0) /* automatic gain control */
@@ -59,13 +59,14 @@
59#define INDYCAM_ORIENTATION_BOTTOM_TO_TOP 0x40 59#define INDYCAM_ORIENTATION_BOTTOM_TO_TOP 0x40
60#define INDYCAM_BUTTON_RELEASED 0x10 60#define INDYCAM_BUTTON_RELEASED 0x10
61 61
62/* Values for controls */
62#define INDYCAM_SHUTTER_MIN 0x00 63#define INDYCAM_SHUTTER_MIN 0x00
63#define INDYCAM_SHUTTER_MAX 0xff 64#define INDYCAM_SHUTTER_MAX 0xff
64#define INDYCAM_GAIN_MIN 0x00 65#define INDYCAM_GAIN_MIN 0x00
65#define INDYCAM_GAIN_MAX 0xff 66#define INDYCAM_GAIN_MAX 0xff
66#define INDYCAM_RED_BALANCE_MIN 0x00 /* the effect is the opposite? */ 67#define INDYCAM_RED_BALANCE_MIN 0x00
67#define INDYCAM_RED_BALANCE_MAX 0xff 68#define INDYCAM_RED_BALANCE_MAX 0xff
68#define INDYCAM_BLUE_BALANCE_MIN 0x00 /* the effect is the opposite? */ 69#define INDYCAM_BLUE_BALANCE_MIN 0x00
69#define INDYCAM_BLUE_BALANCE_MAX 0xff 70#define INDYCAM_BLUE_BALANCE_MAX 0xff
70#define INDYCAM_RED_SATURATION_MIN 0x00 71#define INDYCAM_RED_SATURATION_MIN 0x00
71#define INDYCAM_RED_SATURATION_MAX 0xff 72#define INDYCAM_RED_SATURATION_MAX 0xff
@@ -74,34 +75,9 @@
74#define INDYCAM_GAMMA_MIN 0x00 75#define INDYCAM_GAMMA_MIN 0x00
75#define INDYCAM_GAMMA_MAX 0xff 76#define INDYCAM_GAMMA_MAX 0xff
76 77
77/* Driver interface definitions */ 78#define INDYCAM_AGC_DEFAULT 1
78 79#define INDYCAM_AWB_DEFAULT 0
79#define INDYCAM_VALUE_ENABLED 1 80#define INDYCAM_SHUTTER_DEFAULT 0xff
80#define INDYCAM_VALUE_DISABLED 0
81#define INDYCAM_VALUE_UNCHANGED -1
82
83/* When setting controls, a value of -1 leaves the control unchanged. */
84struct indycam_control {
85 int agc; /* boolean */
86 int awb; /* boolean */
87 int shutter;
88 int gain;
89 int red_balance;
90 int blue_balance;
91 int red_saturation;
92 int blue_saturation;
93 int gamma;
94};
95
96#define DECODER_INDYCAM_GET_CONTROLS _IOR('d', 193, struct indycam_control)
97#define DECODER_INDYCAM_SET_CONTROLS _IOW('d', 194, struct indycam_control)
98
99/* Default values for controls */
100
101#define INDYCAM_AGC_DEFAULT INDYCAM_VALUE_ENABLED
102#define INDYCAM_AWB_DEFAULT INDYCAM_VALUE_ENABLED
103
104#define INDYCAM_SHUTTER_DEFAULT INDYCAM_SHUTTER_60
105#define INDYCAM_GAIN_DEFAULT 0x80 81#define INDYCAM_GAIN_DEFAULT 0x80
106#define INDYCAM_RED_BALANCE_DEFAULT 0x18 82#define INDYCAM_RED_BALANCE_DEFAULT 0x18
107#define INDYCAM_BLUE_BALANCE_DEFAULT 0xa4 83#define INDYCAM_BLUE_BALANCE_DEFAULT 0xa4
@@ -109,4 +85,24 @@ struct indycam_control {
109#define INDYCAM_BLUE_SATURATION_DEFAULT 0xc0 85#define INDYCAM_BLUE_SATURATION_DEFAULT 0xc0
110#define INDYCAM_GAMMA_DEFAULT 0x80 86#define INDYCAM_GAMMA_DEFAULT 0x80
111 87
88/* Driver interface definitions */
89
90#define INDYCAM_CONTROL_AGC 0 /* boolean */
91#define INDYCAM_CONTROL_AWB 1 /* boolean */
92#define INDYCAM_CONTROL_SHUTTER 2
93#define INDYCAM_CONTROL_GAIN 3
94#define INDYCAM_CONTROL_RED_BALANCE 4
95#define INDYCAM_CONTROL_BLUE_BALANCE 5
96#define INDYCAM_CONTROL_RED_SATURATION 6
97#define INDYCAM_CONTROL_BLUE_SATURATION 7
98#define INDYCAM_CONTROL_GAMMA 8
99
100struct indycam_control {
101 u8 type;
102 s32 value;
103};
104
105#define DECODER_INDYCAM_GET_CONTROL _IOR('d', 193, struct indycam_control)
106#define DECODER_INDYCAM_SET_CONTROL _IOW('d', 194, struct indycam_control)
107
112#endif 108#endif
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index 262890cb20a7..e75e7948fd9d 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -741,8 +741,8 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
741 set_current_state(TASK_INTERRUPTIBLE); 741 set_current_state(TASK_INTERRUPTIBLE);
742 schedule(); 742 schedule();
743 } else { 743 } else {
744 set_current_state(TASK_INTERRUPTIBLE); 744 schedule_timeout_interruptible
745 schedule_timeout(msecs_to_jiffies(timeout)); 745 (msecs_to_jiffies(timeout));
746 } 746 }
747 } 747 }
748 748
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index badf2f9e3072..61a2d6b50eef 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -342,8 +342,8 @@ static int tvaudio_sleep(struct saa7134_dev *dev, int timeout)
342 set_current_state(TASK_INTERRUPTIBLE); 342 set_current_state(TASK_INTERRUPTIBLE);
343 schedule(); 343 schedule();
344 } else { 344 } else {
345 set_current_state(TASK_INTERRUPTIBLE); 345 schedule_timeout_interruptible
346 schedule_timeout(msecs_to_jiffies(timeout)); 346 (msecs_to_jiffies(timeout));
347 } 347 }
348 } 348 }
349 remove_wait_queue(&dev->thread.wq, &wait); 349 remove_wait_queue(&dev->thread.wq, &wait);
diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c
index 3ddbb62312be..cbca896e8cfa 100644
--- a/drivers/media/video/saa7191.c
+++ b/drivers/media/video/saa7191.c
@@ -26,71 +26,95 @@
26 26
27#include "saa7191.h" 27#include "saa7191.h"
28 28
29#define SAA7191_MODULE_VERSION "0.0.3" 29#define SAA7191_MODULE_VERSION "0.0.5"
30 30
31MODULE_DESCRIPTION("Philips SAA7191 video decoder driver"); 31MODULE_DESCRIPTION("Philips SAA7191 video decoder driver");
32MODULE_VERSION(SAA7191_MODULE_VERSION); 32MODULE_VERSION(SAA7191_MODULE_VERSION);
33MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); 33MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>");
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35 35
36// #define SAA7191_DEBUG
37
38#ifdef SAA7191_DEBUG
39#define dprintk(x...) printk("SAA7191: " x);
40#else
41#define dprintk(x...)
42#endif
43
44#define SAA7191_SYNC_COUNT 30
45#define SAA7191_SYNC_DELAY 100 /* milliseconds */
46
36struct saa7191 { 47struct saa7191 {
37 struct i2c_client *client; 48 struct i2c_client *client;
38 49
39 /* the register values are stored here as the actual 50 /* the register values are stored here as the actual
40 * I2C-registers are write-only */ 51 * I2C-registers are write-only */
41 unsigned char reg[25]; 52 u8 reg[25];
42 53
43 unsigned char norm; 54 int input;
44 unsigned char input; 55 int norm;
45}; 56};
46 57
47static struct i2c_driver i2c_driver_saa7191; 58static struct i2c_driver i2c_driver_saa7191;
48 59
49static const unsigned char initseq[] = { 60static const u8 initseq[] = {
50 0, /* Subaddress */ 61 0, /* Subaddress */
51 0x50, /* SAA7191_REG_IDEL */ 62
52 0x30, /* SAA7191_REG_HSYB */ 63 0x50, /* (0x50) SAA7191_REG_IDEL */
53 0x00, /* SAA7191_REG_HSYS */ 64
54 0xe8, /* SAA7191_REG_HCLB */ 65 /* 50 Hz signal timing */
55 0xb6, /* SAA7191_REG_HCLS */ 66 0x30, /* (0x30) SAA7191_REG_HSYB */
56 0xf4, /* SAA7191_REG_HPHI */ 67 0x00, /* (0x00) SAA7191_REG_HSYS */
57 0x01, /* SAA7191_REG_LUMA - chrominance trap active (CVBS) */ 68 0xe8, /* (0xe8) SAA7191_REG_HCLB */
58 0x00, /* SAA7191_REG_HUEC */ 69 0xb6, /* (0xb6) SAA7191_REG_HCLS */
59 0xf8, /* SAA7191_REG_CKTQ */ 70 0xf4, /* (0xf4) SAA7191_REG_HPHI */
60 0xf8, /* SAA7191_REG_CKTS */ 71
61 0x90, /* SAA7191_REG_PLSE */ 72 /* control */
62 0x90, /* SAA7191_REG_SESE */ 73 SAA7191_LUMA_APER_1, /* (0x01) SAA7191_REG_LUMA - CVBS mode */
63 0x00, /* SAA7191_REG_GAIN */ 74 0x00, /* (0x00) SAA7191_REG_HUEC */
64 0x0c, /* SAA7191_REG_STDC - not SECAM, slow time constant */ 75 0xf8, /* (0xf8) SAA7191_REG_CKTQ */
65 0x78, /* SAA7191_REG_IOCK - chrominance from CVBS, GPSW1 & 2 off */ 76 0xf8, /* (0xf8) SAA7191_REG_CKTS */
66 0x99, /* SAA7191_REG_CTL3 - automatic field detection */ 77 0x90, /* (0x90) SAA7191_REG_PLSE */
67 0x00, /* SAA7191_REG_CTL4 */ 78 0x90, /* (0x90) SAA7191_REG_SESE */
68 0x2c, /* SAA7191_REG_CHCV */ 79 0x00, /* (0x00) SAA7191_REG_GAIN */
80 SAA7191_STDC_NFEN | SAA7191_STDC_HRMV, /* (0x0c) SAA7191_REG_STDC
81 * - not SECAM,
82 * slow time constant */
83 SAA7191_IOCK_OEDC | SAA7191_IOCK_OEHS | SAA7191_IOCK_OEVS
84 | SAA7191_IOCK_OEDY, /* (0x78) SAA7191_REG_IOCK
85 * - chroma from CVBS, GPSW1 & 2 off */
86 SAA7191_CTL3_AUFD | SAA7191_CTL3_SCEN | SAA7191_CTL3_OFTS
87 | SAA7191_CTL3_YDEL0, /* (0x99) SAA7191_REG_CTL3
88 * - automatic field detection */
89 0x00, /* (0x00) SAA7191_REG_CTL4 */
90 0x2c, /* (0x2c) SAA7191_REG_CHCV - PAL nominal value */
69 0x00, /* unused */ 91 0x00, /* unused */
70 0x00, /* unused */ 92 0x00, /* unused */
71 0x34, /* SAA7191_REG_HS6B */ 93
72 0x0a, /* SAA7191_REG_HS6S */ 94 /* 60 Hz signal timing */
73 0xf4, /* SAA7191_REG_HC6B */ 95 0x34, /* (0x34) SAA7191_REG_HS6B */
74 0xce, /* SAA7191_REG_HC6S */ 96 0x0a, /* (0x0a) SAA7191_REG_HS6S */
75 0xf4, /* SAA7191_REG_HP6I */ 97 0xf4, /* (0xf4) SAA7191_REG_HC6B */
98 0xce, /* (0xce) SAA7191_REG_HC6S */
99 0xf4, /* (0xf4) SAA7191_REG_HP6I */
76}; 100};
77 101
78/* SAA7191 register handling */ 102/* SAA7191 register handling */
79 103
80static unsigned char saa7191_read_reg(struct i2c_client *client, 104static u8 saa7191_read_reg(struct i2c_client *client,
81 unsigned char reg) 105 u8 reg)
82{ 106{
83 return ((struct saa7191 *)i2c_get_clientdata(client))->reg[reg]; 107 return ((struct saa7191 *)i2c_get_clientdata(client))->reg[reg];
84} 108}
85 109
86static int saa7191_read_status(struct i2c_client *client, 110static int saa7191_read_status(struct i2c_client *client,
87 unsigned char *value) 111 u8 *value)
88{ 112{
89 int ret; 113 int ret;
90 114
91 ret = i2c_master_recv(client, value, 1); 115 ret = i2c_master_recv(client, value, 1);
92 if (ret < 0) { 116 if (ret < 0) {
93 printk(KERN_ERR "SAA7191: saa7191_read_status(): read failed"); 117 printk(KERN_ERR "SAA7191: saa7191_read_status(): read failed\n");
94 return ret; 118 return ret;
95 } 119 }
96 120
@@ -98,17 +122,16 @@ static int saa7191_read_status(struct i2c_client *client,
98} 122}
99 123
100 124
101static int saa7191_write_reg(struct i2c_client *client, unsigned char reg, 125static int saa7191_write_reg(struct i2c_client *client, u8 reg,
102 unsigned char value) 126 u8 value)
103{ 127{
104
105 ((struct saa7191 *)i2c_get_clientdata(client))->reg[reg] = value; 128 ((struct saa7191 *)i2c_get_clientdata(client))->reg[reg] = value;
106 return i2c_smbus_write_byte_data(client, reg, value); 129 return i2c_smbus_write_byte_data(client, reg, value);
107} 130}
108 131
109/* the first byte of data must be the first subaddress number (register) */ 132/* the first byte of data must be the first subaddress number (register) */
110static int saa7191_write_block(struct i2c_client *client, 133static int saa7191_write_block(struct i2c_client *client,
111 unsigned char length, unsigned char *data) 134 u8 length, u8 *data)
112{ 135{
113 int i; 136 int i;
114 int ret; 137 int ret;
@@ -121,7 +144,7 @@ static int saa7191_write_block(struct i2c_client *client,
121 ret = i2c_master_send(client, data, length); 144 ret = i2c_master_send(client, data, length);
122 if (ret < 0) { 145 if (ret < 0) {
123 printk(KERN_ERR "SAA7191: saa7191_write_block(): " 146 printk(KERN_ERR "SAA7191: saa7191_write_block(): "
124 "write failed"); 147 "write failed\n");
125 return ret; 148 return ret;
126 } 149 }
127 150
@@ -132,8 +155,9 @@ static int saa7191_write_block(struct i2c_client *client,
132 155
133static int saa7191_set_input(struct i2c_client *client, int input) 156static int saa7191_set_input(struct i2c_client *client, int input)
134{ 157{
135 unsigned char luma = saa7191_read_reg(client, SAA7191_REG_LUMA); 158 struct saa7191 *decoder = i2c_get_clientdata(client);
136 unsigned char iock = saa7191_read_reg(client, SAA7191_REG_IOCK); 159 u8 luma = saa7191_read_reg(client, SAA7191_REG_LUMA);
160 u8 iock = saa7191_read_reg(client, SAA7191_REG_IOCK);
137 int err; 161 int err;
138 162
139 switch (input) { 163 switch (input) {
@@ -159,32 +183,20 @@ static int saa7191_set_input(struct i2c_client *client, int input)
159 if (err) 183 if (err)
160 return -EIO; 184 return -EIO;
161 185
186 decoder->input = input;
187
162 return 0; 188 return 0;
163} 189}
164 190
165static int saa7191_set_norm(struct i2c_client *client, int norm) 191static int saa7191_set_norm(struct i2c_client *client, int norm)
166{ 192{
167 struct saa7191 *decoder = i2c_get_clientdata(client); 193 struct saa7191 *decoder = i2c_get_clientdata(client);
168 unsigned char stdc = saa7191_read_reg(client, SAA7191_REG_STDC); 194 u8 stdc = saa7191_read_reg(client, SAA7191_REG_STDC);
169 unsigned char ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3); 195 u8 ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3);
170 unsigned char chcv = saa7191_read_reg(client, SAA7191_REG_CHCV); 196 u8 chcv = saa7191_read_reg(client, SAA7191_REG_CHCV);
171 int err; 197 int err;
172 198
173 switch(norm) { 199 switch(norm) {
174 case SAA7191_NORM_AUTO: {
175 unsigned char status;
176
177 // does status depend on current norm ?
178 if (saa7191_read_status(client, &status))
179 return -EIO;
180
181 stdc &= ~SAA7191_STDC_SECS;
182 ctl3 &= ~SAA7191_CTL3_FSEL;
183 ctl3 |= SAA7191_CTL3_AUFD;
184 chcv = (status & SAA7191_STATUS_FIDT)
185 ? SAA7191_CHCV_NTSC : SAA7191_CHCV_PAL;
186 break;
187 }
188 case SAA7191_NORM_PAL: 200 case SAA7191_NORM_PAL:
189 stdc &= ~SAA7191_STDC_SECS; 201 stdc &= ~SAA7191_STDC_SECS;
190 ctl3 &= ~(SAA7191_CTL3_AUFD | SAA7191_CTL3_FSEL); 202 ctl3 &= ~(SAA7191_CTL3_AUFD | SAA7191_CTL3_FSEL);
@@ -217,60 +229,335 @@ static int saa7191_set_norm(struct i2c_client *client, int norm)
217 229
218 decoder->norm = norm; 230 decoder->norm = norm;
219 231
232 dprintk("ctl3: %02x stdc: %02x chcv: %02x\n", ctl3,
233 stdc, chcv);
234 dprintk("norm: %d\n", norm);
235
220 return 0; 236 return 0;
221} 237}
222 238
223static int saa7191_get_controls(struct i2c_client *client, 239static int saa7191_wait_for_signal(struct i2c_client *client, u8 *status)
224 struct saa7191_control *ctrl)
225{ 240{
226 unsigned char hue = saa7191_read_reg(client, SAA7191_REG_HUEC); 241 int i = 0;
227 unsigned char stdc = saa7191_read_reg(client, SAA7191_REG_STDC);
228 242
229 if (hue < 0x80) { 243 dprintk("Checking for signal...\n");
230 hue += 0x80; 244
231 } else { 245 for (i = 0; i < SAA7191_SYNC_COUNT; i++) {
232 hue -= 0x80; 246 if (saa7191_read_status(client, status))
247 return -EIO;
248
249 if (((*status) & SAA7191_STATUS_HLCK) == 0) {
250 dprintk("Signal found\n");
251 return 0;
252 }
253
254 msleep(SAA7191_SYNC_DELAY);
233 } 255 }
234 ctrl->hue = hue;
235 256
236 ctrl->vtrc = (stdc & SAA7191_STDC_VTRC) 257 dprintk("No signal\n");
237 ? SAA7191_VALUE_ENABLED : SAA7191_VALUE_DISABLED;
238 258
239 return 0; 259 return -EBUSY;
240} 260}
241 261
242static int saa7191_set_controls(struct i2c_client *client, 262static int saa7191_autodetect_norm_extended(struct i2c_client *client)
243 struct saa7191_control *ctrl)
244{ 263{
245 int err; 264 u8 stdc = saa7191_read_reg(client, SAA7191_REG_STDC);
265 u8 ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3);
266 u8 status;
267 int err = 0;
246 268
247 if (ctrl->hue >= 0) { 269 dprintk("SAA7191 extended signal auto-detection...\n");
248 unsigned char hue = ctrl->hue & 0xff; 270
249 if (hue < 0x80) { 271 stdc &= ~SAA7191_STDC_SECS;
250 hue += 0x80; 272 ctl3 &= ~(SAA7191_CTL3_FSEL);
251 } else { 273
252 hue -= 0x80; 274 err = saa7191_write_reg(client, SAA7191_REG_STDC, stdc);
275 if (err) {
276 err = -EIO;
277 goto out;
278 }
279 err = saa7191_write_reg(client, SAA7191_REG_CTL3, ctl3);
280 if (err) {
281 err = -EIO;
282 goto out;
283 }
284
285 ctl3 |= SAA7191_CTL3_AUFD;
286 err = saa7191_write_reg(client, SAA7191_REG_CTL3, ctl3);
287 if (err) {
288 err = -EIO;
289 goto out;
290 }
291
292 msleep(SAA7191_SYNC_DELAY);
293
294 err = saa7191_wait_for_signal(client, &status);
295 if (err)
296 goto out;
297
298 if (status & SAA7191_STATUS_FIDT) {
299 /* 60Hz signal -> NTSC */
300 dprintk("60Hz signal: NTSC\n");
301 return saa7191_set_norm(client, SAA7191_NORM_NTSC);
302 }
303
304 /* 50Hz signal */
305 dprintk("50Hz signal: Trying PAL...\n");
306
307 /* try PAL first */
308 err = saa7191_set_norm(client, SAA7191_NORM_PAL);
309 if (err)
310 goto out;
311
312 msleep(SAA7191_SYNC_DELAY);
313
314 err = saa7191_wait_for_signal(client, &status);
315 if (err)
316 goto out;
317
318 /* not 50Hz ? */
319 if (status & SAA7191_STATUS_FIDT) {
320 dprintk("No 50Hz signal\n");
321 err = -EAGAIN;
322 goto out;
323 }
324
325 if (status & SAA7191_STATUS_CODE) {
326 dprintk("PAL\n");
327 return 0;
328 }
329
330 dprintk("No color detected with PAL - Trying SECAM...\n");
331
332 /* no color detected ? -> try SECAM */
333 err = saa7191_set_norm(client,
334 SAA7191_NORM_SECAM);
335 if (err)
336 goto out;
337
338 msleep(SAA7191_SYNC_DELAY);
339
340 err = saa7191_wait_for_signal(client, &status);
341 if (err)
342 goto out;
343
344 /* not 50Hz ? */
345 if (status & SAA7191_STATUS_FIDT) {
346 dprintk("No 50Hz signal\n");
347 err = -EAGAIN;
348 goto out;
349 }
350
351 if (status & SAA7191_STATUS_CODE) {
352 /* Color detected -> SECAM */
353 dprintk("SECAM\n");
354 return 0;
355 }
356
357 dprintk("No color detected with SECAM - Going back to PAL.\n");
358
359 /* still no color detected ?
360 * -> set norm back to PAL */
361 err = saa7191_set_norm(client,
362 SAA7191_NORM_PAL);
363 if (err)
364 goto out;
365
366out:
367 ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3);
368 if (ctl3 & SAA7191_CTL3_AUFD) {
369 ctl3 &= ~(SAA7191_CTL3_AUFD);
370 err = saa7191_write_reg(client, SAA7191_REG_CTL3, ctl3);
371 if (err) {
372 err = -EIO;
253 } 373 }
254 err = saa7191_write_reg(client, SAA7191_REG_HUEC, hue);
255 if (err)
256 return -EIO;
257 } 374 }
258 if (ctrl->vtrc >= 0) {
259 unsigned char stdc =
260 saa7191_read_reg(client, SAA7191_REG_STDC);
261 375
262 if (ctrl->vtrc) { 376 return err;
263 stdc |= SAA7191_STDC_VTRC; 377}
264 } else { 378
265 stdc &= ~SAA7191_STDC_VTRC; 379static int saa7191_autodetect_norm(struct i2c_client *client)
380{
381 u8 status;
382
383 dprintk("SAA7191 signal auto-detection...\n");
384
385 dprintk("Reading status...\n");
386
387 if (saa7191_read_status(client, &status))
388 return -EIO;
389
390 dprintk("Checking for signal...\n");
391
392 /* no signal ? */
393 if (status & SAA7191_STATUS_HLCK) {
394 dprintk("No signal\n");
395 return -EBUSY;
396 }
397
398 dprintk("Signal found\n");
399
400 if (status & SAA7191_STATUS_FIDT) {
401 /* 60hz signal -> NTSC */
402 dprintk("NTSC\n");
403 return saa7191_set_norm(client, SAA7191_NORM_NTSC);
404 } else {
405 /* 50hz signal -> PAL */
406 dprintk("PAL\n");
407 return saa7191_set_norm(client, SAA7191_NORM_PAL);
408 }
409}
410
411static int saa7191_get_control(struct i2c_client *client,
412 struct saa7191_control *ctrl)
413{
414 u8 reg;
415 int ret = 0;
416
417 switch (ctrl->type) {
418 case SAA7191_CONTROL_BANDPASS:
419 case SAA7191_CONTROL_BANDPASS_WEIGHT:
420 case SAA7191_CONTROL_CORING:
421 reg = saa7191_read_reg(client, SAA7191_REG_LUMA);
422 switch (ctrl->type) {
423 case SAA7191_CONTROL_BANDPASS:
424 ctrl->value = ((s32)reg & SAA7191_LUMA_BPSS_MASK)
425 >> SAA7191_LUMA_BPSS_SHIFT;
426 break;
427 case SAA7191_CONTROL_BANDPASS_WEIGHT:
428 ctrl->value = ((s32)reg & SAA7191_LUMA_APER_MASK)
429 >> SAA7191_LUMA_APER_SHIFT;
430 break;
431 case SAA7191_CONTROL_CORING:
432 ctrl->value = ((s32)reg & SAA7191_LUMA_CORI_MASK)
433 >> SAA7191_LUMA_CORI_SHIFT;
434 break;
266 } 435 }
436 break;
437 case SAA7191_CONTROL_FORCE_COLOUR:
438 case SAA7191_CONTROL_CHROMA_GAIN:
439 reg = saa7191_read_reg(client, SAA7191_REG_GAIN);
440 if (ctrl->type == SAA7191_CONTROL_FORCE_COLOUR)
441 ctrl->value = ((s32)reg & SAA7191_GAIN_COLO) ? 1 : 0;
442 else
443 ctrl->value = ((s32)reg & SAA7191_GAIN_LFIS_MASK)
444 >> SAA7191_GAIN_LFIS_SHIFT;
445 break;
446 case SAA7191_CONTROL_HUE:
447 reg = saa7191_read_reg(client, SAA7191_REG_HUEC);
448 if (reg < 0x80)
449 reg += 0x80;
450 else
451 reg -= 0x80;
452 ctrl->value = (s32)reg;
453 break;
454 case SAA7191_CONTROL_VTRC:
455 reg = saa7191_read_reg(client, SAA7191_REG_STDC);
456 ctrl->value = ((s32)reg & SAA7191_STDC_VTRC) ? 1 : 0;
457 break;
458 case SAA7191_CONTROL_LUMA_DELAY:
459 reg = saa7191_read_reg(client, SAA7191_REG_CTL3);
460 ctrl->value = ((s32)reg & SAA7191_CTL3_YDEL_MASK)
461 >> SAA7191_CTL3_YDEL_SHIFT;
462 if (ctrl->value >= 4)
463 ctrl->value -= 8;
464 break;
465 case SAA7191_CONTROL_VNR:
466 reg = saa7191_read_reg(client, SAA7191_REG_CTL4);
467 ctrl->value = ((s32)reg & SAA7191_CTL4_VNOI_MASK)
468 >> SAA7191_CTL4_VNOI_SHIFT;
469 break;
470 default:
471 ret = -EINVAL;
472 }
267 473
268 err = saa7191_write_reg(client, SAA7191_REG_STDC, stdc); 474 return ret;
269 if (err) 475}
270 return -EIO; 476
477static int saa7191_set_control(struct i2c_client *client,
478 struct saa7191_control *ctrl)
479{
480 u8 reg;
481 int ret = 0;
482
483 switch (ctrl->type) {
484 case SAA7191_CONTROL_BANDPASS:
485 case SAA7191_CONTROL_BANDPASS_WEIGHT:
486 case SAA7191_CONTROL_CORING:
487 reg = saa7191_read_reg(client, SAA7191_REG_LUMA);
488 switch (ctrl->type) {
489 case SAA7191_CONTROL_BANDPASS:
490 reg &= ~SAA7191_LUMA_BPSS_MASK;
491 reg |= (ctrl->value << SAA7191_LUMA_BPSS_SHIFT)
492 & SAA7191_LUMA_BPSS_MASK;
493 break;
494 case SAA7191_CONTROL_BANDPASS_WEIGHT:
495 reg &= ~SAA7191_LUMA_APER_MASK;
496 reg |= (ctrl->value << SAA7191_LUMA_APER_SHIFT)
497 & SAA7191_LUMA_APER_MASK;
498 break;
499 case SAA7191_CONTROL_CORING:
500 reg &= ~SAA7191_LUMA_CORI_MASK;
501 reg |= (ctrl->value << SAA7191_LUMA_CORI_SHIFT)
502 & SAA7191_LUMA_CORI_MASK;
503 break;
504 }
505 ret = saa7191_write_reg(client, SAA7191_REG_LUMA, reg);
506 break;
507 case SAA7191_CONTROL_FORCE_COLOUR:
508 case SAA7191_CONTROL_CHROMA_GAIN:
509 reg = saa7191_read_reg(client, SAA7191_REG_GAIN);
510 if (ctrl->type == SAA7191_CONTROL_FORCE_COLOUR) {
511 if (ctrl->value)
512 reg |= SAA7191_GAIN_COLO;
513 else
514 reg &= ~SAA7191_GAIN_COLO;
515 } else {
516 reg &= ~SAA7191_GAIN_LFIS_MASK;
517 reg |= (ctrl->value << SAA7191_GAIN_LFIS_SHIFT)
518 & SAA7191_GAIN_LFIS_MASK;
519 }
520 ret = saa7191_write_reg(client, SAA7191_REG_GAIN, reg);
521 break;
522 case SAA7191_CONTROL_HUE:
523 reg = ctrl->value & 0xff;
524 if (reg < 0x80)
525 reg += 0x80;
526 else
527 reg -= 0x80;
528 ret = saa7191_write_reg(client, SAA7191_REG_HUEC, reg);
529 break;
530 case SAA7191_CONTROL_VTRC:
531 reg = saa7191_read_reg(client, SAA7191_REG_STDC);
532 if (ctrl->value)
533 reg |= SAA7191_STDC_VTRC;
534 else
535 reg &= ~SAA7191_STDC_VTRC;
536 ret = saa7191_write_reg(client, SAA7191_REG_STDC, reg);
537 break;
538 case SAA7191_CONTROL_LUMA_DELAY: {
539 s32 value = ctrl->value;
540 if (value < 0)
541 value += 8;
542 reg = saa7191_read_reg(client, SAA7191_REG_CTL3);
543 reg &= ~SAA7191_CTL3_YDEL_MASK;
544 reg |= (value << SAA7191_CTL3_YDEL_SHIFT)
545 & SAA7191_CTL3_YDEL_MASK;
546 ret = saa7191_write_reg(client, SAA7191_REG_CTL3, reg);
547 break;
548 }
549 case SAA7191_CONTROL_VNR:
550 reg = saa7191_read_reg(client, SAA7191_REG_CTL4);
551 reg &= ~SAA7191_CTL4_VNOI_MASK;
552 reg |= (ctrl->value << SAA7191_CTL4_VNOI_SHIFT)
553 & SAA7191_CTL4_VNOI_MASK;
554 ret = saa7191_write_reg(client, SAA7191_REG_CTL4, reg);
555 break;
556 default:
557 ret = -EINVAL;
271 } 558 }
272 559
273 return 0; 560 return ret;
274} 561}
275 562
276/* I2C-interface */ 563/* I2C-interface */
@@ -309,11 +596,7 @@ static int saa7191_attach(struct i2c_adapter *adap, int addr, int kind)
309 if (err) 596 if (err)
310 goto out_free_decoder; 597 goto out_free_decoder;
311 598
312 decoder->input = SAA7191_INPUT_COMPOSITE; 599 err = saa7191_write_block(client, sizeof(initseq), (u8 *)initseq);
313 decoder->norm = SAA7191_NORM_AUTO;
314
315 err = saa7191_write_block(client, sizeof(initseq),
316 (unsigned char *)initseq);
317 if (err) { 600 if (err) {
318 printk(KERN_ERR "SAA7191 initialization failed\n"); 601 printk(KERN_ERR "SAA7191 initialization failed\n");
319 goto out_detach_client; 602 goto out_detach_client;
@@ -321,6 +604,14 @@ static int saa7191_attach(struct i2c_adapter *adap, int addr, int kind)
321 604
322 printk(KERN_INFO "SAA7191 initialized\n"); 605 printk(KERN_INFO "SAA7191 initialized\n");
323 606
607 decoder->input = SAA7191_INPUT_COMPOSITE;
608 decoder->norm = SAA7191_NORM_PAL;
609
610 err = saa7191_autodetect_norm(client);
611 if (err && (err != -EBUSY)) {
612 printk(KERN_ERR "SAA7191: Signal auto-detection failed\n");
613 }
614
324 return 0; 615 return 0;
325 616
326out_detach_client: 617out_detach_client:
@@ -368,7 +659,7 @@ static int saa7191_command(struct i2c_client *client, unsigned int cmd,
368 } 659 }
369 case DECODER_GET_STATUS: { 660 case DECODER_GET_STATUS: {
370 int *iarg = arg; 661 int *iarg = arg;
371 unsigned char status; 662 u8 status;
372 int res = 0; 663 int res = 0;
373 664
374 if (saa7191_read_status(client, &status)) { 665 if (saa7191_read_status(client, &status)) {
@@ -404,7 +695,7 @@ static int saa7191_command(struct i2c_client *client, unsigned int cmd,
404 695
405 switch (*iarg) { 696 switch (*iarg) {
406 case VIDEO_MODE_AUTO: 697 case VIDEO_MODE_AUTO:
407 return saa7191_set_norm(client, SAA7191_NORM_AUTO); 698 return saa7191_autodetect_norm(client);
408 case VIDEO_MODE_PAL: 699 case VIDEO_MODE_PAL:
409 return saa7191_set_norm(client, SAA7191_NORM_PAL); 700 return saa7191_set_norm(client, SAA7191_NORM_PAL);
410 case VIDEO_MODE_NTSC: 701 case VIDEO_MODE_NTSC:
@@ -446,38 +737,48 @@ static int saa7191_command(struct i2c_client *client, unsigned int cmd,
446 int err; 737 int err;
447 738
448 val = (pic->hue >> 8) - 0x80; 739 val = (pic->hue >> 8) - 0x80;
740
449 err = saa7191_write_reg(client, SAA7191_REG_HUEC, val); 741 err = saa7191_write_reg(client, SAA7191_REG_HUEC, val);
450 if (err) 742 if (err)
451 return -EIO; 743 return -EIO;
744
452 break; 745 break;
453 } 746 }
454 case DECODER_SAA7191_GET_STATUS: { 747 case DECODER_SAA7191_GET_STATUS: {
455 struct saa7191_status *status = arg; 748 struct saa7191_status *status = arg;
456 unsigned char status_reg; 749 u8 status_reg;
457 750
458 if (saa7191_read_status(client, &status_reg)) 751 if (saa7191_read_status(client, &status_reg))
459 return -EIO; 752 return -EIO;
753
460 status->signal = ((status_reg & SAA7191_STATUS_HLCK) == 0) 754 status->signal = ((status_reg & SAA7191_STATUS_HLCK) == 0)
461 ? SAA7191_VALUE_ENABLED : SAA7191_VALUE_DISABLED; 755 ? 1 : 0;
462 status->ntsc = (status_reg & SAA7191_STATUS_FIDT) 756 status->signal_60hz = (status_reg & SAA7191_STATUS_FIDT)
463 ? SAA7191_VALUE_ENABLED : SAA7191_VALUE_DISABLED; 757 ? 1 : 0;
464 status->color = (status_reg & SAA7191_STATUS_CODE) 758 status->color = (status_reg & SAA7191_STATUS_CODE) ? 1 : 0;
465 ? SAA7191_VALUE_ENABLED : SAA7191_VALUE_DISABLED;
466 759
467 status->input = decoder->input; 760 status->input = decoder->input;
468 status->norm = decoder->norm; 761 status->norm = decoder->norm;
762
763 break;
469 } 764 }
470 case DECODER_SAA7191_SET_NORM: { 765 case DECODER_SAA7191_SET_NORM: {
471 int *norm = arg; 766 int *norm = arg;
472 return saa7191_set_norm(client, *norm); 767
768 switch (*norm) {
769 case SAA7191_NORM_AUTO:
770 return saa7191_autodetect_norm(client);
771 case SAA7191_NORM_AUTO_EXT:
772 return saa7191_autodetect_norm_extended(client);
773 default:
774 return saa7191_set_norm(client, *norm);
775 }
473 } 776 }
474 case DECODER_SAA7191_GET_CONTROLS: { 777 case DECODER_SAA7191_GET_CONTROL: {
475 struct saa7191_control *ctrl = arg; 778 return saa7191_get_control(client, arg);
476 return saa7191_get_controls(client, ctrl);
477 } 779 }
478 case DECODER_SAA7191_SET_CONTROLS: { 780 case DECODER_SAA7191_SET_CONTROL: {
479 struct saa7191_control *ctrl = arg; 781 return saa7191_set_control(client, arg);
480 return saa7191_set_controls(client, ctrl);
481 } 782 }
482 default: 783 default:
483 return -EINVAL; 784 return -EINVAL;
@@ -488,12 +789,12 @@ static int saa7191_command(struct i2c_client *client, unsigned int cmd,
488 789
489static struct i2c_driver i2c_driver_saa7191 = { 790static struct i2c_driver i2c_driver_saa7191 = {
490 .owner = THIS_MODULE, 791 .owner = THIS_MODULE,
491 .name = "saa7191", 792 .name = "saa7191",
492 .id = I2C_DRIVERID_SAA7191, 793 .id = I2C_DRIVERID_SAA7191,
493 .flags = I2C_DF_NOTIFY, 794 .flags = I2C_DF_NOTIFY,
494 .attach_adapter = saa7191_probe, 795 .attach_adapter = saa7191_probe,
495 .detach_client = saa7191_detach, 796 .detach_client = saa7191_detach,
496 .command = saa7191_command 797 .command = saa7191_command
497}; 798};
498 799
499static int saa7191_init(void) 800static int saa7191_init(void)
diff --git a/drivers/media/video/saa7191.h b/drivers/media/video/saa7191.h
index 272045031435..a2310da1940d 100644
--- a/drivers/media/video/saa7191.h
+++ b/drivers/media/video/saa7191.h
@@ -24,8 +24,8 @@
24#define SAA7191_REG_HPHI 0x05 24#define SAA7191_REG_HPHI 0x05
25#define SAA7191_REG_LUMA 0x06 25#define SAA7191_REG_LUMA 0x06
26#define SAA7191_REG_HUEC 0x07 26#define SAA7191_REG_HUEC 0x07
27#define SAA7191_REG_CKTQ 0x08 27#define SAA7191_REG_CKTQ 0x08 /* bits 3-7 */
28#define SAA7191_REG_CKTS 0x09 28#define SAA7191_REG_CKTS 0x09 /* bits 3-7 */
29#define SAA7191_REG_PLSE 0x0a 29#define SAA7191_REG_PLSE 0x0a
30#define SAA7191_REG_SESE 0x0b 30#define SAA7191_REG_SESE 0x0b
31#define SAA7191_REG_GAIN 0x0c 31#define SAA7191_REG_GAIN 0x0c
@@ -43,30 +43,82 @@
43 43
44/* Status Register definitions */ 44/* Status Register definitions */
45#define SAA7191_STATUS_CODE 0x01 /* color detected flag */ 45#define SAA7191_STATUS_CODE 0x01 /* color detected flag */
46#define SAA7191_STATUS_FIDT 0x20 /* format type NTSC/PAL */ 46#define SAA7191_STATUS_FIDT 0x20 /* signal type 50/60 Hz */
47#define SAA7191_STATUS_HLCK 0x40 /* PLL unlocked/locked */ 47#define SAA7191_STATUS_HLCK 0x40 /* PLL unlocked(1)/locked(0) */
48#define SAA7191_STATUS_STTC 0x80 /* tv/vtr time constant */ 48#define SAA7191_STATUS_STTC 0x80 /* tv/vtr time constant */
49 49
50/* Luminance Control Register definitions */ 50/* Luminance Control Register definitions */
51/* input mode select bit:
52 * 0=CVBS (chrominance trap active), 1=S-Video (trap bypassed) */
51#define SAA7191_LUMA_BYPS 0x80 53#define SAA7191_LUMA_BYPS 0x80
52 54/* pre-filter (only when chrominance trap is active) */
53/* Chroma Gain Control Settings Register definitions */ 55#define SAA7191_LUMA_PREF 0x40
54/* 0=automatic colour-killer enabled, 1=forced colour on */ 56/* aperture bandpass to select different characteristics with maximums
57 * (bits 4-5) */
58#define SAA7191_LUMA_BPSS_MASK 0x30
59#define SAA7191_LUMA_BPSS_SHIFT 4
60#define SAA7191_LUMA_BPSS_3 0x30
61#define SAA7191_LUMA_BPSS_2 0x20
62#define SAA7191_LUMA_BPSS_1 0x10
63#define SAA7191_LUMA_BPSS_0 0x00
64/* coring range for high frequency components according to 8-bit luminance
65 * (bits 2-3)
66 * 0=coring off, n= (+-)n LSB */
67#define SAA7191_LUMA_CORI_MASK 0x0c
68#define SAA7191_LUMA_CORI_SHIFT 2
69#define SAA7191_LUMA_CORI_3 0x0c
70#define SAA7191_LUMA_CORI_2 0x08
71#define SAA7191_LUMA_CORI_1 0x04
72#define SAA7191_LUMA_CORI_0 0x00
73/* aperture bandpass filter weights high frequency components of luminance
74 * signal (bits 0-1)
75 * 0=factor 0, 1=0.25, 2=0.5, 3=1 */
76#define SAA7191_LUMA_APER_MASK 0x03
77#define SAA7191_LUMA_APER_SHIFT 0
78#define SAA7191_LUMA_APER_3 0x03
79#define SAA7191_LUMA_APER_2 0x02
80#define SAA7191_LUMA_APER_1 0x01
81#define SAA7191_LUMA_APER_0 0x00
82
83/* Chrominance Gain Control Settings Register definitions */
84/* colour on: 0=automatic colour-killer enabled, 1=forced colour on */
55#define SAA7191_GAIN_COLO 0x80 85#define SAA7191_GAIN_COLO 0x80
86/* chrominance gain control (AGC filter)
87 * 0=loop filter time constant slow, 1=medium, 2=fast, 3=actual gain */
88#define SAA7191_GAIN_LFIS_MASK 0x60
89#define SAA7191_GAIN_LFIS_SHIFT 5
90#define SAA7191_GAIN_LFIS_3 0x60
91#define SAA7191_GAIN_LFIS_2 0x40
92#define SAA7191_GAIN_LFIS_1 0x20
93#define SAA7191_GAIN_LFIS_0 0x00
56 94
57/* Standard/Mode Control Register definitions */ 95/* Standard/Mode Control Register definitions */
58/* tv/vtr mode bit: 0=TV mode (slow time constant), 96/* tv/vtr mode bit: 0=TV mode (slow time constant),
59 * 1=VTR mode (fast time constant) */ 97 * 1=VTR mode (fast time constant) */
60#define SAA7191_STDC_VTRC 0x80 98#define SAA7191_STDC_VTRC 0x80
99/* SAA7191B-specific functions enable (RTCO, ODD and GPSW0 outputs)
100 * 0=outputs set to high-impedance (circuit equals SAA7191), 1=enabled */
101#define SAA7191_STDC_NFEN 0x08
102/* HREF generation: 0=like SAA7191, 1=HREF is 8xLLC2 clocks earlier */
103#define SAA7191_STDC_HRMV 0x04
104/* general purpose switch 0
105 * (not used with VINO afaik) */
106#define SAA7191_STDC_GPSW0 0x02
61/* SECAM mode bit: 0=other standards, 1=SECAM */ 107/* SECAM mode bit: 0=other standards, 1=SECAM */
62#define SAA7191_STDC_SECS 0x01 108#define SAA7191_STDC_SECS 0x01
63/* the bit fields above must be or'd with this value */
64#define SAA7191_STDC_VALUE 0x0c
65 109
66/* I/O and Clock Control Register definitions */ 110/* I/O and Clock Control Register definitions */
67/* horizontal clock PLL: 0=PLL closed, 111/* horizontal clock PLL: 0=PLL closed,
68 * 1=PLL circuit open and horizontal freq fixed */ 112 * 1=PLL circuit open and horizontal freq fixed */
69#define SAA7191_IOCK_HPLL 0x80 113#define SAA7191_IOCK_HPLL 0x80
114/* colour-difference output enable (outputs UV0-UV7) */
115#define SAA7191_IOCK_OEDC 0x40
116/* H-sync output enable */
117#define SAA7191_IOCK_OEHS 0x20
118/* V-sync output enable */
119#define SAA7191_IOCK_OEVS 0x10
120/* luminance output enable (outputs Y0-Y7) */
121#define SAA7191_IOCK_OEDY 0x08
70/* S-VHS bit (chrominance from CVBS or from chrominance input): 122/* S-VHS bit (chrominance from CVBS or from chrominance input):
71 * 0=controlled by BYPS-bit, 1=from chrominance input */ 123 * 0=controlled by BYPS-bit, 1=from chrominance input */
72#define SAA7191_IOCK_CHRS 0x04 124#define SAA7191_IOCK_CHRS 0x04
@@ -83,11 +135,40 @@
83/* field select: (if AUFD=0) 135/* field select: (if AUFD=0)
84 * 0=50Hz (625 lines), 1=60Hz (525 lines) */ 136 * 0=50Hz (625 lines), 1=60Hz (525 lines) */
85#define SAA7191_CTL3_FSEL 0x40 137#define SAA7191_CTL3_FSEL 0x40
86/* the bit fields above must be or'd with this value */ 138/* SECAM cross-colour reduction enable */
87#define SAA7191_CTL3_VALUE 0x19 139#define SAA7191_CTL3_SXCR 0x20
140/* sync and clamping pulse enable (HCL and HSY outputs) */
141#define SAA7191_CTL3_SCEN 0x10
142/* output format: 0=4:1:1, 1=4:2:2 (4:2:2 for VINO) */
143#define SAA7191_CTL3_OFTS 0x08
144/* luminance delay compensation
145 * 0=0*2/LLC, 1=+1*2/LLC, 2=+2*2/LLC, 3=+3*2/LLC,
146 * 4=-4*2/LLC, 5=-3*2/LLC, 6=-2*2/LLC, 7=-1*2/LLC
147 * step size = 2/LLC = 67.8ns for 50Hz, 81.5ns for 60Hz */
148#define SAA7191_CTL3_YDEL_MASK 0x07
149#define SAA7191_CTL3_YDEL_SHIFT 0
150#define SAA7191_CTL3_YDEL2 0x04
151#define SAA7191_CTL3_YDEL1 0x02
152#define SAA7191_CTL3_YDEL0 0x01
153
154/* Miscellaneous Control #2 Register definitions */
155/* select HREF position
156 * 0=normal, HREF is matched to YUV output port,
157 * 1=HREF is matched to CVBS input port */
158#define SAA7191_CTL4_HRFS 0x04
159/* vertical noise reduction
160 * 0=normal, 1=searching window, 2=auto-deflection, 3=reduction bypassed */
161#define SAA7191_CTL4_VNOI_MASK 0x03
162#define SAA7191_CTL4_VNOI_SHIFT 0
163#define SAA7191_CTL4_VNOI_3 0x03
164#define SAA7191_CTL4_VNOI_2 0x02
165#define SAA7191_CTL4_VNOI_1 0x01
166#define SAA7191_CTL4_VNOI_0 0x00
88 167
89/* Chrominance Gain Control Register definitions 168/* Chrominance Gain Control Register definitions
90 * (nominal value for UV CCIR level) */ 169 * - for QAM-modulated input signals, effects output amplitude
170 * (SECAM gain fixed)
171 * (nominal values for UV CCIR level) */
91#define SAA7191_CHCV_NTSC 0x2c 172#define SAA7191_CHCV_NTSC 0x2c
92#define SAA7191_CHCV_PAL 0x59 173#define SAA7191_CHCV_PAL 0x59
93 174
@@ -99,16 +180,13 @@
99#define SAA7191_NORM_PAL 1 180#define SAA7191_NORM_PAL 1
100#define SAA7191_NORM_NTSC 2 181#define SAA7191_NORM_NTSC 2
101#define SAA7191_NORM_SECAM 3 182#define SAA7191_NORM_SECAM 3
102 183#define SAA7191_NORM_AUTO_EXT 4 /* extended auto-detection */
103#define SAA7191_VALUE_ENABLED 1
104#define SAA7191_VALUE_DISABLED 0
105#define SAA7191_VALUE_UNCHANGED -1
106 184
107struct saa7191_status { 185struct saa7191_status {
108 /* 0=no signal, 1=signal active*/ 186 /* 0=no signal, 1=signal detected */
109 int signal; 187 int signal;
110 /* 0=50hz (pal) signal, 1=60hz (ntsc) signal */ 188 /* 0=50hz (pal) signal, 1=60hz (ntsc) signal */
111 int ntsc; 189 int signal_60hz;
112 /* 0=no color detected, 1=color detected */ 190 /* 0=no color detected, 1=color detected */
113 int color; 191 int color;
114 192
@@ -118,22 +196,60 @@ struct saa7191_status {
118 int norm; 196 int norm;
119}; 197};
120 198
121#define SAA7191_HUE_MIN 0x00 199#define SAA7191_BANDPASS_MIN 0x00
122#define SAA7191_HUE_MAX 0xff 200#define SAA7191_BANDPASS_MAX 0x03
123#define SAA7191_HUE_DEFAULT 0x80 201#define SAA7191_BANDPASS_DEFAULT 0x00
202
203#define SAA7191_BANDPASS_WEIGHT_MIN 0x00
204#define SAA7191_BANDPASS_WEIGHT_MAX 0x03
205#define SAA7191_BANDPASS_WEIGHT_DEFAULT 0x01
206
207#define SAA7191_CORING_MIN 0x00
208#define SAA7191_CORING_MAX 0x03
209#define SAA7191_CORING_DEFAULT 0x00
210
211#define SAA7191_HUE_MIN 0x00
212#define SAA7191_HUE_MAX 0xff
213#define SAA7191_HUE_DEFAULT 0x80
214
215#define SAA7191_VTRC_MIN 0x00
216#define SAA7191_VTRC_MAX 0x01
217#define SAA7191_VTRC_DEFAULT 0x00
218
219#define SAA7191_FORCE_COLOUR_MIN 0x00
220#define SAA7191_FORCE_COLOUR_MAX 0x01
221#define SAA7191_FORCE_COLOUR_DEFAULT 0x00
222
223#define SAA7191_CHROMA_GAIN_MIN 0x00
224#define SAA7191_CHROMA_GAIN_MAX 0x03
225#define SAA7191_CHROMA_GAIN_DEFAULT 0x00
226
227#define SAA7191_LUMA_DELAY_MIN -0x04
228#define SAA7191_LUMA_DELAY_MAX 0x03
229#define SAA7191_LUMA_DELAY_DEFAULT 0x01
230
231#define SAA7191_VNR_MIN 0x00
232#define SAA7191_VNR_MAX 0x03
233#define SAA7191_VNR_DEFAULT 0x00
124 234
125#define SAA7191_VTRC_MIN 0x00 235#define SAA7191_CONTROL_BANDPASS 0
126#define SAA7191_VTRC_MAX 0x01 236#define SAA7191_CONTROL_BANDPASS_WEIGHT 1
127#define SAA7191_VTRC_DEFAULT 0x00 237#define SAA7191_CONTROL_CORING 2
238#define SAA7191_CONTROL_FORCE_COLOUR 3 /* boolean */
239#define SAA7191_CONTROL_CHROMA_GAIN 4
240#define SAA7191_CONTROL_HUE 5
241#define SAA7191_CONTROL_VTRC 6 /* boolean */
242#define SAA7191_CONTROL_LUMA_DELAY 7
243#define SAA7191_CONTROL_VNR 8
128 244
129struct saa7191_control { 245struct saa7191_control {
130 int hue; 246 u8 type;
131 int vtrc; 247 s32 value;
132}; 248};
133 249
134#define DECODER_SAA7191_GET_STATUS _IOR('d', 195, struct saa7191_status) 250#define DECODER_SAA7191_GET_STATUS _IOR('d', 195, struct saa7191_status)
135#define DECODER_SAA7191_SET_NORM _IOW('d', 196, int) 251#define DECODER_SAA7191_SET_NORM _IOW('d', 196, int)
136#define DECODER_SAA7191_GET_CONTROLS _IOR('d', 197, struct saa7191_control) 252#define DECODER_SAA7191_GET_CONTROL _IOR('d', 197, struct saa7191_control)
137#define DECODER_SAA7191_SET_CONTROLS _IOW('d', 198, struct saa7191_control) 253#define DECODER_SAA7191_SET_CONTROL _IOW('d', 198, struct saa7191_control)
138 254
139#endif 255#endif
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index 59bb71381a1b..d679ca23ded7 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -1006,10 +1006,8 @@ v4l_compat_translate_ioctl(struct inode *inode,
1006 break; 1006 break;
1007 } 1007 }
1008 1008
1009 if (cap2) 1009 kfree(cap2);
1010 kfree(cap2); 1010 kfree(fmt2);
1011 if (fmt2)
1012 kfree(fmt2);
1013 return err; 1011 return err;
1014} 1012}
1015 1013
diff --git a/drivers/media/video/videocodec.c b/drivers/media/video/videocodec.c
index c9d5f1a873cc..839db622040d 100644
--- a/drivers/media/video/videocodec.c
+++ b/drivers/media/video/videocodec.c
@@ -353,8 +353,7 @@ videocodec_build_table (void)
353 dprintk(3, "videocodec_build table: %d entries, %d bytes\n", i, 353 dprintk(3, "videocodec_build table: %d entries, %d bytes\n", i,
354 size); 354 size);
355 355
356 if (videocodec_buf) 356 kfree(videocodec_buf);
357 kfree(videocodec_buf);
358 videocodec_buf = (char *) kmalloc(size, GFP_KERNEL); 357 videocodec_buf = (char *) kmalloc(size, GFP_KERNEL);
359 358
360 i = 0; 359 i = 0;
@@ -471,8 +470,7 @@ videocodec_exit (void)
471{ 470{
472#ifdef CONFIG_PROC_FS 471#ifdef CONFIG_PROC_FS
473 remove_proc_entry("videocodecs", NULL); 472 remove_proc_entry("videocodecs", NULL);
474 if (videocodec_buf) 473 kfree(videocodec_buf);
475 kfree(videocodec_buf);
476#endif 474#endif
477} 475}
478 476
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 06df15f75de9..83c49f9610d0 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -215,8 +215,7 @@ video_usercopy(struct inode *inode, struct file *file,
215 } 215 }
216 216
217out: 217out:
218 if (mbuf) 218 kfree(mbuf);
219 kfree(mbuf);
220 return err; 219 return err;
221} 220}
222 221
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index ed4394e854ab..71b28e9e0850 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -12,15 +12,11 @@
12 12
13/* 13/*
14 * TODO: 14 * TODO:
15 * - remove "hacks" from memory allocation code and implement nopage() 15 * - remove "mark pages reserved-hacks" from memory allocation code
16 * and implement nopage()
16 * - check decimation, calculating and reporting image size when 17 * - check decimation, calculating and reporting image size when
17 * using decimation 18 * using decimation
18 * - check vino_acquire_input(), vino_set_input() and channel 19 * - implement read(), user mode buffers and overlay (?)
19 * ownership handling
20 * - report VINO error-interrupts via ioctls ?
21 * - implement picture controls (all implemented?)
22 * - use macros for boolean values (?)
23 * - implement user mode buffers and overlay (?)
24 */ 20 */
25 21
26#include <linux/init.h> 22#include <linux/init.h>
@@ -60,18 +56,16 @@
60 * debug info. 56 * debug info.
61 * Note that the debug output also slows down the driver significantly */ 57 * Note that the debug output also slows down the driver significantly */
62// #define VINO_DEBUG 58// #define VINO_DEBUG
59// #define VINO_DEBUG_INT
63 60
64#define VINO_MODULE_VERSION "0.0.3" 61#define VINO_MODULE_VERSION "0.0.5"
65#define VINO_VERSION_CODE KERNEL_VERSION(0, 0, 3) 62#define VINO_VERSION_CODE KERNEL_VERSION(0, 0, 5)
66 63
67MODULE_DESCRIPTION("SGI VINO Video4Linux2 driver"); 64MODULE_DESCRIPTION("SGI VINO Video4Linux2 driver");
68MODULE_VERSION(VINO_MODULE_VERSION); 65MODULE_VERSION(VINO_MODULE_VERSION);
69MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); 66MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>");
70MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
71 68
72#define mem_map_reserve(p) set_bit(PG_reserved, &((p)->flags))
73#define mem_map_unreserve(p) clear_bit(PG_reserved, &((p)->flags))
74
75#ifdef VINO_DEBUG 69#ifdef VINO_DEBUG
76#define dprintk(x...) printk("VINO: " x); 70#define dprintk(x...) printk("VINO: " x);
77#else 71#else
@@ -91,15 +85,16 @@ MODULE_LICENSE("GPL");
91#define VINO_MIN_HEIGHT 32 85#define VINO_MIN_HEIGHT 32
92 86
93#define VINO_CLIPPING_START_ODD_D1 1 87#define VINO_CLIPPING_START_ODD_D1 1
94#define VINO_CLIPPING_START_ODD_PAL 1 88#define VINO_CLIPPING_START_ODD_PAL 15
95#define VINO_CLIPPING_START_ODD_NTSC 1 89#define VINO_CLIPPING_START_ODD_NTSC 12
96 90
97#define VINO_CLIPPING_START_EVEN_D1 2 91#define VINO_CLIPPING_START_EVEN_D1 2
98#define VINO_CLIPPING_START_EVEN_PAL 2 92#define VINO_CLIPPING_START_EVEN_PAL 15
99#define VINO_CLIPPING_START_EVEN_NTSC 2 93#define VINO_CLIPPING_START_EVEN_NTSC 12
100 94
101#define VINO_INPUT_CHANNEL_COUNT 3 95#define VINO_INPUT_CHANNEL_COUNT 3
102 96
97/* the number is the index for vino_inputs */
103#define VINO_INPUT_NONE -1 98#define VINO_INPUT_NONE -1
104#define VINO_INPUT_COMPOSITE 0 99#define VINO_INPUT_COMPOSITE 0
105#define VINO_INPUT_SVIDEO 1 100#define VINO_INPUT_SVIDEO 1
@@ -107,15 +102,13 @@ MODULE_LICENSE("GPL");
107 102
108#define VINO_PAGE_RATIO (PAGE_SIZE / VINO_PAGE_SIZE) 103#define VINO_PAGE_RATIO (PAGE_SIZE / VINO_PAGE_SIZE)
109 104
110#define VINO_FIFO_THRESHOLD_DEFAULT 512 105#define VINO_FIFO_THRESHOLD_DEFAULT 16
111 106
112/*#define VINO_FRAMEBUFFER_SIZE (VINO_PAL_WIDTH * VINO_PAL_HEIGHT * 4 \
113 + 2 * PAGE_SIZE)*/
114#define VINO_FRAMEBUFFER_SIZE ((VINO_PAL_WIDTH \ 107#define VINO_FRAMEBUFFER_SIZE ((VINO_PAL_WIDTH \
115 * VINO_PAL_HEIGHT * 4 \ 108 * VINO_PAL_HEIGHT * 4 \
116 + 3 * PAGE_SIZE) & ~(PAGE_SIZE - 1)) 109 + 3 * PAGE_SIZE) & ~(PAGE_SIZE - 1))
117 110
118#define VINO_FRAMEBUFFER_MAX_COUNT 8 111#define VINO_FRAMEBUFFER_COUNT_MAX 8
119 112
120#define VINO_FRAMEBUFFER_UNUSED 0 113#define VINO_FRAMEBUFFER_UNUSED 0
121#define VINO_FRAMEBUFFER_IN_USE 1 114#define VINO_FRAMEBUFFER_IN_USE 1
@@ -131,24 +124,27 @@ MODULE_LICENSE("GPL");
131#define VINO_DUMMY_DESC_COUNT 4 124#define VINO_DUMMY_DESC_COUNT 4
132#define VINO_DESC_FETCH_DELAY 5 /* microseconds */ 125#define VINO_DESC_FETCH_DELAY 5 /* microseconds */
133 126
127#define VINO_MAX_FRAME_SKIP_COUNT 128
128
134/* the number is the index for vino_data_formats */ 129/* the number is the index for vino_data_formats */
135#define VINO_DATA_FMT_NONE -1 130#define VINO_DATA_FMT_NONE -1
136#define VINO_DATA_FMT_GREY 0 131#define VINO_DATA_FMT_GREY 0
137#define VINO_DATA_FMT_RGB332 1 132#define VINO_DATA_FMT_RGB332 1
138#define VINO_DATA_FMT_RGB32 2 133#define VINO_DATA_FMT_RGB32 2
139#define VINO_DATA_FMT_YUV 3 134#define VINO_DATA_FMT_YUV 3
140//#define VINO_DATA_FMT_RGB24 4
141 135
142#define VINO_DATA_FMT_COUNT 4 136#define VINO_DATA_FMT_COUNT 4
143 137
138/* the number is the index for vino_data_norms */
144#define VINO_DATA_NORM_NONE -1 139#define VINO_DATA_NORM_NONE -1
145#define VINO_DATA_NORM_NTSC 0 140#define VINO_DATA_NORM_NTSC 0
146#define VINO_DATA_NORM_PAL 1 141#define VINO_DATA_NORM_PAL 1
147#define VINO_DATA_NORM_SECAM 2 142#define VINO_DATA_NORM_SECAM 2
148#define VINO_DATA_NORM_D1 3 143#define VINO_DATA_NORM_D1 3
149/* The following is a special entry that can be used to 144/* The following are special entries that can be used to
150 * autodetect the norm. */ 145 * autodetect the norm. */
151#define VINO_DATA_NORM_AUTO 0xff 146#define VINO_DATA_NORM_AUTO 0xfe
147#define VINO_DATA_NORM_AUTO_EXT 0xff
152 148
153#define VINO_DATA_NORM_COUNT 4 149#define VINO_DATA_NORM_COUNT 4
154 150
@@ -232,7 +228,7 @@ struct vino_framebuffer_fifo {
232 unsigned int head; 228 unsigned int head;
233 unsigned int tail; 229 unsigned int tail;
234 230
235 unsigned int data[VINO_FRAMEBUFFER_MAX_COUNT]; 231 unsigned int data[VINO_FRAMEBUFFER_COUNT_MAX];
236}; 232};
237 233
238struct vino_framebuffer_queue { 234struct vino_framebuffer_queue {
@@ -246,13 +242,20 @@ struct vino_framebuffer_queue {
246 struct vino_framebuffer_fifo in; 242 struct vino_framebuffer_fifo in;
247 struct vino_framebuffer_fifo out; 243 struct vino_framebuffer_fifo out;
248 244
249 struct vino_framebuffer *buffer[VINO_FRAMEBUFFER_MAX_COUNT]; 245 struct vino_framebuffer *buffer[VINO_FRAMEBUFFER_COUNT_MAX];
250 246
251 spinlock_t queue_lock; 247 spinlock_t queue_lock;
252 struct semaphore queue_sem; 248 struct semaphore queue_sem;
253 wait_queue_head_t frame_wait_queue; 249 wait_queue_head_t frame_wait_queue;
254}; 250};
255 251
252struct vino_interrupt_data {
253 struct timeval timestamp;
254 unsigned int frame_counter;
255 unsigned int skip_count;
256 unsigned int skip;
257};
258
256struct vino_channel_settings { 259struct vino_channel_settings {
257 unsigned int channel; 260 unsigned int channel;
258 261
@@ -285,6 +288,8 @@ struct vino_channel_settings {
285 288
286 unsigned int users; 289 unsigned int users;
287 290
291 struct vino_interrupt_data int_data;
292
288 /* V4L support */ 293 /* V4L support */
289 struct video_device *v4l_device; 294 struct video_device *v4l_device;
290}; 295};
@@ -315,7 +320,7 @@ struct vino_settings {
315/* Module parameters */ 320/* Module parameters */
316 321
317/* 322/*
318 * Using vino_pixel_conversion the ARGB32-format pixels supplied 323 * Using vino_pixel_conversion the ABGR32-format pixels supplied
319 * by the VINO chip can be converted to more common formats 324 * by the VINO chip can be converted to more common formats
320 * like RGBA32 (or probably RGB24 in the future). This way we 325 * like RGBA32 (or probably RGB24 in the future). This way we
321 * can give out data that can be specified correctly with 326 * can give out data that can be specified correctly with
@@ -329,7 +334,9 @@ struct vino_settings {
329 * Use non-zero value to enable conversion. 334 * Use non-zero value to enable conversion.
330 */ 335 */
331static int vino_pixel_conversion = 0; 336static int vino_pixel_conversion = 0;
337
332module_param_named(pixelconv, vino_pixel_conversion, int, 0); 338module_param_named(pixelconv, vino_pixel_conversion, int, 0);
339
333MODULE_PARM_DESC(pixelconv, 340MODULE_PARM_DESC(pixelconv,
334 "enable pixel conversion (non-zero value enables)"); 341 "enable pixel conversion (non-zero value enables)");
335 342
@@ -345,15 +352,22 @@ static const char *vino_bus_name = "GIO64 bus";
345static const char *vino_v4l_device_name_a = "SGI VINO Channel A"; 352static const char *vino_v4l_device_name_a = "SGI VINO Channel A";
346static const char *vino_v4l_device_name_b = "SGI VINO Channel B"; 353static const char *vino_v4l_device_name_b = "SGI VINO Channel B";
347 354
355static void vino_capture_tasklet(unsigned long channel);
356
357DECLARE_TASKLET(vino_tasklet_a, vino_capture_tasklet, VINO_CHANNEL_A);
358DECLARE_TASKLET(vino_tasklet_b, vino_capture_tasklet, VINO_CHANNEL_B);
359
348static const struct vino_input vino_inputs[] = { 360static const struct vino_input vino_inputs[] = {
349 { 361 {
350 .name = "Composite", 362 .name = "Composite",
351 .std = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM, 363 .std = V4L2_STD_NTSC | V4L2_STD_PAL
364 | V4L2_STD_SECAM,
352 },{ 365 },{
353 .name = "S-Video", 366 .name = "S-Video",
354 .std = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM, 367 .std = V4L2_STD_NTSC | V4L2_STD_PAL
368 | V4L2_STD_SECAM,
355 },{ 369 },{
356 .name = "D1 (IndyCam)", 370 .name = "D1/IndyCam",
357 .std = V4L2_STD_NTSC, 371 .std = V4L2_STD_NTSC,
358 } 372 }
359}; 373};
@@ -376,15 +390,10 @@ static const struct vino_data_format vino_data_formats[] = {
376 .colorspace = V4L2_COLORSPACE_SRGB, 390 .colorspace = V4L2_COLORSPACE_SRGB,
377 },{ 391 },{
378 .description = "YUV 4:2:2", 392 .description = "YUV 4:2:2",
379 .bpp = 4, 393 .bpp = 2,
380 .pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped? 394 .pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped?
381 .colorspace = V4L2_COLORSPACE_SMPTE170M, 395 .colorspace = V4L2_COLORSPACE_SMPTE170M,
382 }/*,{ 396 }
383 .description = "24-bit RGB",
384 .bpp = 3,
385 .pixelformat = V4L2_PIX_FMT_RGB24,
386 .colorspace = V4L2_COLORSPACE_SRGB,
387 }*/
388}; 397};
389 398
390static const struct vino_data_norm vino_data_norms[] = { 399static const struct vino_data_norm vino_data_norms[] = {
@@ -397,18 +406,18 @@ static const struct vino_data_norm vino_data_norms[] = {
397 .width = VINO_NTSC_WIDTH, 406 .width = VINO_NTSC_WIDTH,
398 .height = VINO_NTSC_HEIGHT, 407 .height = VINO_NTSC_HEIGHT,
399 .odd = { 408 .odd = {
400 .top = VINO_CLIPPING_START_ODD_NTSC, 409 .top = VINO_CLIPPING_START_ODD_NTSC,
401 .left = 0, 410 .left = 0,
402 .bottom = VINO_CLIPPING_START_ODD_NTSC 411 .bottom = VINO_CLIPPING_START_ODD_NTSC
403 + VINO_NTSC_HEIGHT / 2 - 1, 412 + VINO_NTSC_HEIGHT / 2 - 1,
404 .right = VINO_NTSC_WIDTH, 413 .right = VINO_NTSC_WIDTH,
405 }, 414 },
406 .even = { 415 .even = {
407 .top = VINO_CLIPPING_START_EVEN_NTSC, 416 .top = VINO_CLIPPING_START_EVEN_NTSC,
408 .left = 0, 417 .left = 0,
409 .bottom = VINO_CLIPPING_START_EVEN_NTSC 418 .bottom = VINO_CLIPPING_START_EVEN_NTSC
410 + VINO_NTSC_HEIGHT / 2 - 1, 419 + VINO_NTSC_HEIGHT / 2 - 1,
411 .right = VINO_NTSC_WIDTH, 420 .right = VINO_NTSC_WIDTH,
412 }, 421 },
413 },{ 422 },{
414 .description = "PAL", 423 .description = "PAL",
@@ -419,18 +428,18 @@ static const struct vino_data_norm vino_data_norms[] = {
419 .width = VINO_PAL_WIDTH, 428 .width = VINO_PAL_WIDTH,
420 .height = VINO_PAL_HEIGHT, 429 .height = VINO_PAL_HEIGHT,
421 .odd = { 430 .odd = {
422 .top = VINO_CLIPPING_START_ODD_PAL, 431 .top = VINO_CLIPPING_START_ODD_PAL,
423 .left = 0, 432 .left = 0,
424 .bottom = VINO_CLIPPING_START_ODD_PAL 433 .bottom = VINO_CLIPPING_START_ODD_PAL
425 + VINO_PAL_HEIGHT / 2 - 1, 434 + VINO_PAL_HEIGHT / 2 - 1,
426 .right = VINO_PAL_WIDTH, 435 .right = VINO_PAL_WIDTH,
427 }, 436 },
428 .even = { 437 .even = {
429 .top = VINO_CLIPPING_START_EVEN_PAL, 438 .top = VINO_CLIPPING_START_EVEN_PAL,
430 .left = 0, 439 .left = 0,
431 .bottom = VINO_CLIPPING_START_EVEN_PAL 440 .bottom = VINO_CLIPPING_START_EVEN_PAL
432 + VINO_PAL_HEIGHT / 2 - 1, 441 + VINO_PAL_HEIGHT / 2 - 1,
433 .right = VINO_PAL_WIDTH, 442 .right = VINO_PAL_WIDTH,
434 }, 443 },
435 },{ 444 },{
436 .description = "SECAM", 445 .description = "SECAM",
@@ -441,21 +450,21 @@ static const struct vino_data_norm vino_data_norms[] = {
441 .width = VINO_PAL_WIDTH, 450 .width = VINO_PAL_WIDTH,
442 .height = VINO_PAL_HEIGHT, 451 .height = VINO_PAL_HEIGHT,
443 .odd = { 452 .odd = {
444 .top = VINO_CLIPPING_START_ODD_PAL, 453 .top = VINO_CLIPPING_START_ODD_PAL,
445 .left = 0, 454 .left = 0,
446 .bottom = VINO_CLIPPING_START_ODD_PAL 455 .bottom = VINO_CLIPPING_START_ODD_PAL
447 + VINO_PAL_HEIGHT / 2 - 1, 456 + VINO_PAL_HEIGHT / 2 - 1,
448 .right = VINO_PAL_WIDTH, 457 .right = VINO_PAL_WIDTH,
449 }, 458 },
450 .even = { 459 .even = {
451 .top = VINO_CLIPPING_START_EVEN_PAL, 460 .top = VINO_CLIPPING_START_EVEN_PAL,
452 .left = 0, 461 .left = 0,
453 .bottom = VINO_CLIPPING_START_EVEN_PAL 462 .bottom = VINO_CLIPPING_START_EVEN_PAL
454 + VINO_PAL_HEIGHT / 2 - 1, 463 + VINO_PAL_HEIGHT / 2 - 1,
455 .right = VINO_PAL_WIDTH, 464 .right = VINO_PAL_WIDTH,
456 }, 465 },
457 },{ 466 },{
458 .description = "NTSC (D1 input)", 467 .description = "NTSC/D1",
459 .std = V4L2_STD_NTSC, 468 .std = V4L2_STD_NTSC,
460 .fps_min = 6, 469 .fps_min = 6,
461 .fps_max = 30, 470 .fps_max = 30,
@@ -463,18 +472,18 @@ static const struct vino_data_norm vino_data_norms[] = {
463 .width = VINO_NTSC_WIDTH, 472 .width = VINO_NTSC_WIDTH,
464 .height = VINO_NTSC_HEIGHT, 473 .height = VINO_NTSC_HEIGHT,
465 .odd = { 474 .odd = {
466 .top = VINO_CLIPPING_START_ODD_D1, 475 .top = VINO_CLIPPING_START_ODD_D1,
467 .left = 0, 476 .left = 0,
468 .bottom = VINO_CLIPPING_START_ODD_D1 477 .bottom = VINO_CLIPPING_START_ODD_D1
469 + VINO_NTSC_HEIGHT / 2 - 1, 478 + VINO_NTSC_HEIGHT / 2 - 1,
470 .right = VINO_NTSC_WIDTH, 479 .right = VINO_NTSC_WIDTH,
471 }, 480 },
472 .even = { 481 .even = {
473 .top = VINO_CLIPPING_START_EVEN_D1, 482 .top = VINO_CLIPPING_START_EVEN_D1,
474 .left = 0, 483 .left = 0,
475 .bottom = VINO_CLIPPING_START_EVEN_D1 484 .bottom = VINO_CLIPPING_START_EVEN_D1
476 + VINO_NTSC_HEIGHT / 2 - 1, 485 + VINO_NTSC_HEIGHT / 2 - 1,
477 .right = VINO_NTSC_WIDTH, 486 .right = VINO_NTSC_WIDTH,
478 }, 487 },
479 } 488 }
480}; 489};
@@ -491,7 +500,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
491 .step = 1, 500 .step = 1,
492 .default_value = INDYCAM_AGC_DEFAULT, 501 .default_value = INDYCAM_AGC_DEFAULT,
493 .flags = 0, 502 .flags = 0,
494 .reserved = { 0, 0 }, 503 .reserved = { INDYCAM_CONTROL_AGC, 0 },
495 },{ 504 },{
496 .id = V4L2_CID_AUTO_WHITE_BALANCE, 505 .id = V4L2_CID_AUTO_WHITE_BALANCE,
497 .type = V4L2_CTRL_TYPE_BOOLEAN, 506 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -501,7 +510,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
501 .step = 1, 510 .step = 1,
502 .default_value = INDYCAM_AWB_DEFAULT, 511 .default_value = INDYCAM_AWB_DEFAULT,
503 .flags = 0, 512 .flags = 0,
504 .reserved = { 0, 0 }, 513 .reserved = { INDYCAM_CONTROL_AWB, 0 },
505 },{ 514 },{
506 .id = V4L2_CID_GAIN, 515 .id = V4L2_CID_GAIN,
507 .type = V4L2_CTRL_TYPE_INTEGER, 516 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -511,7 +520,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
511 .step = 1, 520 .step = 1,
512 .default_value = INDYCAM_GAIN_DEFAULT, 521 .default_value = INDYCAM_GAIN_DEFAULT,
513 .flags = 0, 522 .flags = 0,
514 .reserved = { 0, 0 }, 523 .reserved = { INDYCAM_CONTROL_GAIN, 0 },
515 },{ 524 },{
516 .id = V4L2_CID_PRIVATE_BASE, 525 .id = V4L2_CID_PRIVATE_BASE,
517 .type = V4L2_CTRL_TYPE_INTEGER, 526 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -521,7 +530,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
521 .step = 1, 530 .step = 1,
522 .default_value = INDYCAM_RED_SATURATION_DEFAULT, 531 .default_value = INDYCAM_RED_SATURATION_DEFAULT,
523 .flags = 0, 532 .flags = 0,
524 .reserved = { 0, 0 }, 533 .reserved = { INDYCAM_CONTROL_RED_SATURATION, 0 },
525 },{ 534 },{
526 .id = V4L2_CID_PRIVATE_BASE + 1, 535 .id = V4L2_CID_PRIVATE_BASE + 1,
527 .type = V4L2_CTRL_TYPE_INTEGER, 536 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -531,7 +540,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
531 .step = 1, 540 .step = 1,
532 .default_value = INDYCAM_BLUE_SATURATION_DEFAULT, 541 .default_value = INDYCAM_BLUE_SATURATION_DEFAULT,
533 .flags = 0, 542 .flags = 0,
534 .reserved = { 0, 0 }, 543 .reserved = { INDYCAM_CONTROL_BLUE_SATURATION, 0 },
535 },{ 544 },{
536 .id = V4L2_CID_RED_BALANCE, 545 .id = V4L2_CID_RED_BALANCE,
537 .type = V4L2_CTRL_TYPE_INTEGER, 546 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -541,7 +550,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
541 .step = 1, 550 .step = 1,
542 .default_value = INDYCAM_RED_BALANCE_DEFAULT, 551 .default_value = INDYCAM_RED_BALANCE_DEFAULT,
543 .flags = 0, 552 .flags = 0,
544 .reserved = { 0, 0 }, 553 .reserved = { INDYCAM_CONTROL_RED_BALANCE, 0 },
545 },{ 554 },{
546 .id = V4L2_CID_BLUE_BALANCE, 555 .id = V4L2_CID_BLUE_BALANCE,
547 .type = V4L2_CTRL_TYPE_INTEGER, 556 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -551,7 +560,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
551 .step = 1, 560 .step = 1,
552 .default_value = INDYCAM_BLUE_BALANCE_DEFAULT, 561 .default_value = INDYCAM_BLUE_BALANCE_DEFAULT,
553 .flags = 0, 562 .flags = 0,
554 .reserved = { 0, 0 }, 563 .reserved = { INDYCAM_CONTROL_BLUE_BALANCE, 0 },
555 },{ 564 },{
556 .id = V4L2_CID_EXPOSURE, 565 .id = V4L2_CID_EXPOSURE,
557 .type = V4L2_CTRL_TYPE_INTEGER, 566 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -561,7 +570,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
561 .step = 1, 570 .step = 1,
562 .default_value = INDYCAM_SHUTTER_DEFAULT, 571 .default_value = INDYCAM_SHUTTER_DEFAULT,
563 .flags = 0, 572 .flags = 0,
564 .reserved = { 0, 0 }, 573 .reserved = { INDYCAM_CONTROL_SHUTTER, 0 },
565 },{ 574 },{
566 .id = V4L2_CID_GAMMA, 575 .id = V4L2_CID_GAMMA,
567 .type = V4L2_CTRL_TYPE_INTEGER, 576 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -571,11 +580,11 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
571 .step = 1, 580 .step = 1,
572 .default_value = INDYCAM_GAMMA_DEFAULT, 581 .default_value = INDYCAM_GAMMA_DEFAULT,
573 .flags = 0, 582 .flags = 0,
574 .reserved = { 0, 0 }, 583 .reserved = { INDYCAM_CONTROL_GAMMA, 0 },
575 } 584 }
576}; 585};
577 586
578#define VINO_SAA7191_V4L2_CONTROL_COUNT 2 587#define VINO_SAA7191_V4L2_CONTROL_COUNT 9
579 588
580struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = { 589struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = {
581 { 590 {
@@ -587,9 +596,59 @@ struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = {
587 .step = 1, 596 .step = 1,
588 .default_value = SAA7191_HUE_DEFAULT, 597 .default_value = SAA7191_HUE_DEFAULT,
589 .flags = 0, 598 .flags = 0,
590 .reserved = { 0, 0 }, 599 .reserved = { SAA7191_CONTROL_HUE, 0 },
591 },{ 600 },{
592 .id = V4L2_CID_PRIVATE_BASE, 601 .id = V4L2_CID_PRIVATE_BASE,
602 .type = V4L2_CTRL_TYPE_INTEGER,
603 .name = "Luminance Bandpass",
604 .minimum = SAA7191_BANDPASS_MIN,
605 .maximum = SAA7191_BANDPASS_MAX,
606 .step = 1,
607 .default_value = SAA7191_BANDPASS_DEFAULT,
608 .flags = 0,
609 .reserved = { SAA7191_CONTROL_BANDPASS, 0 },
610 },{
611 .id = V4L2_CID_PRIVATE_BASE + 1,
612 .type = V4L2_CTRL_TYPE_INTEGER,
613 .name = "Luminance Bandpass Weight",
614 .minimum = SAA7191_BANDPASS_WEIGHT_MIN,
615 .maximum = SAA7191_BANDPASS_WEIGHT_MAX,
616 .step = 1,
617 .default_value = SAA7191_BANDPASS_WEIGHT_DEFAULT,
618 .flags = 0,
619 .reserved = { SAA7191_CONTROL_BANDPASS_WEIGHT, 0 },
620 },{
621 .id = V4L2_CID_PRIVATE_BASE + 2,
622 .type = V4L2_CTRL_TYPE_INTEGER,
623 .name = "HF Luminance Coring",
624 .minimum = SAA7191_CORING_MIN,
625 .maximum = SAA7191_CORING_MAX,
626 .step = 1,
627 .default_value = SAA7191_CORING_DEFAULT,
628 .flags = 0,
629 .reserved = { SAA7191_CONTROL_CORING, 0 },
630 },{
631 .id = V4L2_CID_PRIVATE_BASE + 3,
632 .type = V4L2_CTRL_TYPE_BOOLEAN,
633 .name = "Force Colour",
634 .minimum = SAA7191_FORCE_COLOUR_MIN,
635 .maximum = SAA7191_FORCE_COLOUR_MAX,
636 .step = 1,
637 .default_value = SAA7191_FORCE_COLOUR_DEFAULT,
638 .flags = 0,
639 .reserved = { SAA7191_CONTROL_FORCE_COLOUR, 0 },
640 },{
641 .id = V4L2_CID_PRIVATE_BASE + 4,
642 .type = V4L2_CTRL_TYPE_INTEGER,
643 .name = "Chrominance Gain Control",
644 .minimum = SAA7191_CHROMA_GAIN_MIN,
645 .maximum = SAA7191_CHROMA_GAIN_MAX,
646 .step = 1,
647 .default_value = SAA7191_CHROMA_GAIN_DEFAULT,
648 .flags = 0,
649 .reserved = { SAA7191_CONTROL_CHROMA_GAIN, 0 },
650 },{
651 .id = V4L2_CID_PRIVATE_BASE + 5,
593 .type = V4L2_CTRL_TYPE_BOOLEAN, 652 .type = V4L2_CTRL_TYPE_BOOLEAN,
594 .name = "VTR Time Constant", 653 .name = "VTR Time Constant",
595 .minimum = SAA7191_VTRC_MIN, 654 .minimum = SAA7191_VTRC_MIN,
@@ -597,7 +656,27 @@ struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = {
597 .step = 1, 656 .step = 1,
598 .default_value = SAA7191_VTRC_DEFAULT, 657 .default_value = SAA7191_VTRC_DEFAULT,
599 .flags = 0, 658 .flags = 0,
600 .reserved = { 0, 0 }, 659 .reserved = { SAA7191_CONTROL_VTRC, 0 },
660 },{
661 .id = V4L2_CID_PRIVATE_BASE + 6,
662 .type = V4L2_CTRL_TYPE_INTEGER,
663 .name = "Luminance Delay Compensation",
664 .minimum = SAA7191_LUMA_DELAY_MIN,
665 .maximum = SAA7191_LUMA_DELAY_MAX,
666 .step = 1,
667 .default_value = SAA7191_LUMA_DELAY_DEFAULT,
668 .flags = 0,
669 .reserved = { SAA7191_CONTROL_LUMA_DELAY, 0 },
670 },{
671 .id = V4L2_CID_PRIVATE_BASE + 7,
672 .type = V4L2_CTRL_TYPE_INTEGER,
673 .name = "Vertical Noise Reduction",
674 .minimum = SAA7191_VNR_MIN,
675 .maximum = SAA7191_VNR_MAX,
676 .step = 1,
677 .default_value = SAA7191_VNR_DEFAULT,
678 .flags = 0,
679 .reserved = { SAA7191_CONTROL_VNR, 0 },
601 } 680 }
602}; 681};
603 682
@@ -639,9 +718,10 @@ static struct i2c_algo_sgi_data i2c_sgi_vino_data =
639 */ 718 */
640static int i2c_vino_client_reg(struct i2c_client *client) 719static int i2c_vino_client_reg(struct i2c_client *client)
641{ 720{
721 unsigned long flags;
642 int ret = 0; 722 int ret = 0;
643 723
644 spin_lock(&vino_drvdata->input_lock); 724 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
645 switch (client->driver->id) { 725 switch (client->driver->id) {
646 case I2C_DRIVERID_SAA7191: 726 case I2C_DRIVERID_SAA7191:
647 if (vino_drvdata->decoder.driver) 727 if (vino_drvdata->decoder.driver)
@@ -658,16 +738,17 @@ static int i2c_vino_client_reg(struct i2c_client *client)
658 default: 738 default:
659 ret = -ENODEV; 739 ret = -ENODEV;
660 } 740 }
661 spin_unlock(&vino_drvdata->input_lock); 741 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
662 742
663 return ret; 743 return ret;
664} 744}
665 745
666static int i2c_vino_client_unreg(struct i2c_client *client) 746static int i2c_vino_client_unreg(struct i2c_client *client)
667{ 747{
748 unsigned long flags;
668 int ret = 0; 749 int ret = 0;
669 750
670 spin_lock(&vino_drvdata->input_lock); 751 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
671 if (client == vino_drvdata->decoder.driver) { 752 if (client == vino_drvdata->decoder.driver) {
672 if (vino_drvdata->decoder.owner != VINO_NO_CHANNEL) 753 if (vino_drvdata->decoder.owner != VINO_NO_CHANNEL)
673 ret = -EBUSY; 754 ret = -EBUSY;
@@ -679,7 +760,7 @@ static int i2c_vino_client_unreg(struct i2c_client *client)
679 else 760 else
680 vino_drvdata->camera.driver = NULL; 761 vino_drvdata->camera.driver = NULL;
681 } 762 }
682 spin_unlock(&vino_drvdata->input_lock); 763 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
683 764
684 return ret; 765 return ret;
685} 766}
@@ -727,7 +808,7 @@ static void vino_free_buffer_with_count(struct vino_framebuffer *fb,
727 dprintk("vino_free_buffer_with_count(): count = %d\n", count); 808 dprintk("vino_free_buffer_with_count(): count = %d\n", count);
728 809
729 for (i = 0; i < count; i++) { 810 for (i = 0; i < count; i++) {
730 mem_map_unreserve(virt_to_page(fb->desc_table.virtual[i])); 811 ClearPageReserved(virt_to_page(fb->desc_table.virtual[i]));
731 dma_unmap_single(NULL, 812 dma_unmap_single(NULL,
732 fb->desc_table.dma_cpu[VINO_PAGE_RATIO * i], 813 fb->desc_table.dma_cpu[VINO_PAGE_RATIO * i],
733 PAGE_SIZE, DMA_FROM_DEVICE); 814 PAGE_SIZE, DMA_FROM_DEVICE);
@@ -805,7 +886,7 @@ static int vino_allocate_buffer(struct vino_framebuffer *fb,
805 dma_data_addr + VINO_PAGE_SIZE * j; 886 dma_data_addr + VINO_PAGE_SIZE * j;
806 } 887 }
807 888
808 mem_map_reserve(virt_to_page(fb->desc_table.virtual[i])); 889 SetPageReserved(virt_to_page(fb->desc_table.virtual[i]));
809 } 890 }
810 891
811 /* page_count needs to be set anyway, because the descriptor table has 892 /* page_count needs to be set anyway, because the descriptor table has
@@ -892,7 +973,7 @@ static int vino_prepare_user_buffer(struct vino_framebuffer *fb,
892 dma_data_addr + VINO_PAGE_SIZE * j; 973 dma_data_addr + VINO_PAGE_SIZE * j;
893 } 974 }
894 975
895 mem_map_reserve(virt_to_page(fb->desc_table.virtual[i])); 976 SetPageReserved(virt_to_page(fb->desc_table.virtual[i]));
896 } 977 }
897 978
898 /* page_count needs to be set anyway, because the descriptor table has 979 /* page_count needs to be set anyway, because the descriptor table has
@@ -933,7 +1014,7 @@ static void vino_sync_buffer(struct vino_framebuffer *fb)
933 1014
934/* Framebuffer fifo functions (need to be locked externally) */ 1015/* Framebuffer fifo functions (need to be locked externally) */
935 1016
936static void vino_fifo_init(struct vino_framebuffer_fifo *f, 1017static inline void vino_fifo_init(struct vino_framebuffer_fifo *f,
937 unsigned int length) 1018 unsigned int length)
938{ 1019{
939 f->length = 0; 1020 f->length = 0;
@@ -941,16 +1022,18 @@ static void vino_fifo_init(struct vino_framebuffer_fifo *f,
941 f->head = 0; 1022 f->head = 0;
942 f->tail = 0; 1023 f->tail = 0;
943 1024
944 if (length > VINO_FRAMEBUFFER_MAX_COUNT) 1025 if (length > VINO_FRAMEBUFFER_COUNT_MAX)
945 length = VINO_FRAMEBUFFER_MAX_COUNT; 1026 length = VINO_FRAMEBUFFER_COUNT_MAX;
946 1027
947 f->length = length; 1028 f->length = length;
948} 1029}
949 1030
950/* returns true/false */ 1031/* returns true/false */
951static int vino_fifo_has_id(struct vino_framebuffer_fifo *f, unsigned int id) 1032static inline int vino_fifo_has_id(struct vino_framebuffer_fifo *f,
1033 unsigned int id)
952{ 1034{
953 unsigned int i; 1035 unsigned int i;
1036
954 for (i = f->head; i == (f->tail - 1); i = (i + 1) % f->length) { 1037 for (i = f->head; i == (f->tail - 1); i = (i + 1) % f->length) {
955 if (f->data[i] == id) 1038 if (f->data[i] == id)
956 return 1; 1039 return 1;
@@ -959,13 +1042,15 @@ static int vino_fifo_has_id(struct vino_framebuffer_fifo *f, unsigned int id)
959 return 0; 1042 return 0;
960} 1043}
961 1044
1045#if 0
962/* returns true/false */ 1046/* returns true/false */
963static int vino_fifo_full(struct vino_framebuffer_fifo *f) 1047static inline int vino_fifo_full(struct vino_framebuffer_fifo *f)
964{ 1048{
965 return (f->used == f->length); 1049 return (f->used == f->length);
966} 1050}
1051#endif
967 1052
968static unsigned int vino_fifo_get_used(struct vino_framebuffer_fifo *f) 1053static inline unsigned int vino_fifo_get_used(struct vino_framebuffer_fifo *f)
969{ 1054{
970 return f->used; 1055 return f->used;
971} 1056}
@@ -1076,8 +1161,8 @@ static int vino_queue_init(struct vino_framebuffer_queue *q,
1076 1161
1077 down(&q->queue_sem); 1162 down(&q->queue_sem);
1078 1163
1079 if (*length > VINO_FRAMEBUFFER_MAX_COUNT) 1164 if (*length > VINO_FRAMEBUFFER_COUNT_MAX)
1080 *length = VINO_FRAMEBUFFER_MAX_COUNT; 1165 *length = VINO_FRAMEBUFFER_COUNT_MAX;
1081 1166
1082 q->length = 0; 1167 q->length = 0;
1083 1168
@@ -1313,6 +1398,7 @@ out:
1313 return ret; 1398 return ret;
1314} 1399}
1315 1400
1401#if 0
1316static int vino_queue_get_total(struct vino_framebuffer_queue *q, 1402static int vino_queue_get_total(struct vino_framebuffer_queue *q,
1317 unsigned int *total) 1403 unsigned int *total)
1318{ 1404{
@@ -1338,6 +1424,7 @@ out:
1338 1424
1339 return ret; 1425 return ret;
1340} 1426}
1427#endif
1341 1428
1342static struct vino_framebuffer *vino_queue_peek(struct 1429static struct vino_framebuffer *vino_queue_peek(struct
1343 vino_framebuffer_queue *q, 1430 vino_framebuffer_queue *q,
@@ -1471,12 +1558,14 @@ static void vino_update_line_size(struct vino_channel_settings *vcs)
1471 1558
1472 dprintk("update_line_size(): before: w = %d, d = %d, " 1559 dprintk("update_line_size(): before: w = %d, d = %d, "
1473 "line_size = %d\n", w, d, vcs->line_size); 1560 "line_size = %d\n", w, d, vcs->line_size);
1561
1474 /* line size must be multiple of 8 bytes */ 1562 /* line size must be multiple of 8 bytes */
1475 lsize = (bpp * (w / d)) & ~7; 1563 lsize = (bpp * (w / d)) & ~7;
1476 w = (lsize / bpp) * d; 1564 w = (lsize / bpp) * d;
1477 1565
1478 vcs->clipping.right = vcs->clipping.left + w; 1566 vcs->clipping.right = vcs->clipping.left + w;
1479 vcs->line_size = lsize; 1567 vcs->line_size = lsize;
1568
1480 dprintk("update_line_size(): after: w = %d, d = %d, " 1569 dprintk("update_line_size(): after: w = %d, d = %d, "
1481 "line_size = %d\n", w, d, vcs->line_size); 1570 "line_size = %d\n", w, d, vcs->line_size);
1482} 1571}
@@ -1532,7 +1621,7 @@ static void vino_set_clipping(struct vino_channel_settings *vcs,
1532} 1621}
1533 1622
1534/* execute with input_lock locked */ 1623/* execute with input_lock locked */
1535static void vino_set_default_clipping(struct vino_channel_settings *vcs) 1624static inline void vino_set_default_clipping(struct vino_channel_settings *vcs)
1536{ 1625{
1537 vino_set_clipping(vcs, 0, 0, vino_data_norms[vcs->data_norm].width, 1626 vino_set_clipping(vcs, 0, 0, vino_data_norms[vcs->data_norm].width,
1538 vino_data_norms[vcs->data_norm].height); 1627 vino_data_norms[vcs->data_norm].height);
@@ -1556,8 +1645,7 @@ static void vino_set_scaling(struct vino_channel_settings *vcs,
1556 1645
1557 if (d < 1) { 1646 if (d < 1) {
1558 d = 1; 1647 d = 1;
1559 } 1648 } else if (d > 8) {
1560 if (d > 8) {
1561 d = 8; 1649 d = 8;
1562 } 1650 }
1563 1651
@@ -1570,7 +1658,7 @@ static void vino_set_scaling(struct vino_channel_settings *vcs,
1570} 1658}
1571 1659
1572/* execute with input_lock locked */ 1660/* execute with input_lock locked */
1573static void vino_reset_scaling(struct vino_channel_settings *vcs) 1661static inline void vino_set_default_scaling(struct vino_channel_settings *vcs)
1574{ 1662{
1575 vino_set_scaling(vcs, vcs->clipping.right - vcs->clipping.left, 1663 vino_set_scaling(vcs, vcs->clipping.right - vcs->clipping.left,
1576 vcs->clipping.bottom - vcs->clipping.top); 1664 vcs->clipping.bottom - vcs->clipping.top);
@@ -1649,7 +1737,8 @@ static void vino_set_framerate(struct vino_channel_settings *vcs,
1649} 1737}
1650 1738
1651/* execute with input_lock locked */ 1739/* execute with input_lock locked */
1652static void vino_set_default_framerate(struct vino_channel_settings *vcs) 1740static inline void vino_set_default_framerate(struct
1741 vino_channel_settings *vcs)
1653{ 1742{
1654 vino_set_framerate(vcs, vino_data_norms[vcs->data_norm].fps_max); 1743 vino_set_framerate(vcs, vino_data_norms[vcs->data_norm].fps_max);
1655} 1744}
@@ -1687,6 +1776,9 @@ static int vino_dma_setup(struct vino_channel_settings *vcs,
1687 * should be more than enough time */ 1776 * should be more than enough time */
1688 udelay(VINO_DESC_FETCH_DELAY); 1777 udelay(VINO_DESC_FETCH_DELAY);
1689 1778
1779 dprintk("vino_dma_setup(): start desc = %08x, next 4 desc = %08x\n",
1780 ch->start_desc_tbl, ch->next_4_desc);
1781
1690 /* set the alpha register */ 1782 /* set the alpha register */
1691 ch->alpha = vcs->alpha; 1783 ch->alpha = vcs->alpha;
1692 1784
@@ -1700,9 +1792,6 @@ static int vino_dma_setup(struct vino_channel_settings *vcs,
1700 VINO_CLIP_EVEN(norm->even.top + 1792 VINO_CLIP_EVEN(norm->even.top +
1701 vcs->clipping.bottom / 2 - 1) | 1793 vcs->clipping.bottom / 2 - 1) |
1702 VINO_CLIP_X(vcs->clipping.right); 1794 VINO_CLIP_X(vcs->clipping.right);
1703 /* FIXME: end-of-field bug workaround
1704 VINO_CLIP_X(VINO_PAL_WIDTH);
1705 */
1706 1795
1707 /* set the size of actual content in the buffer (DECIMATION !) */ 1796 /* set the size of actual content in the buffer (DECIMATION !) */
1708 fb->data_size = ((vcs->clipping.right - vcs->clipping.left) / 1797 fb->data_size = ((vcs->clipping.right - vcs->clipping.left) /
@@ -1802,7 +1891,7 @@ static int vino_dma_setup(struct vino_channel_settings *vcs,
1802} 1891}
1803 1892
1804/* (execute only with vino_lock locked) */ 1893/* (execute only with vino_lock locked) */
1805static void vino_dma_start(struct vino_channel_settings *vcs) 1894static inline void vino_dma_start(struct vino_channel_settings *vcs)
1806{ 1895{
1807 u32 ctrl = vino->control; 1896 u32 ctrl = vino->control;
1808 1897
@@ -1813,12 +1902,14 @@ static void vino_dma_start(struct vino_channel_settings *vcs)
1813} 1902}
1814 1903
1815/* (execute only with vino_lock locked) */ 1904/* (execute only with vino_lock locked) */
1816static void vino_dma_stop(struct vino_channel_settings *vcs) 1905static inline void vino_dma_stop(struct vino_channel_settings *vcs)
1817{ 1906{
1818 u32 ctrl = vino->control; 1907 u32 ctrl = vino->control;
1819 1908
1820 ctrl &= (vcs->channel == VINO_CHANNEL_A) ? 1909 ctrl &= (vcs->channel == VINO_CHANNEL_A) ?
1821 ~VINO_CTRL_A_DMA_ENBL : ~VINO_CTRL_B_DMA_ENBL; 1910 ~VINO_CTRL_A_DMA_ENBL : ~VINO_CTRL_B_DMA_ENBL;
1911 ctrl &= (vcs->channel == VINO_CHANNEL_A) ?
1912 ~VINO_CTRL_A_INT : ~VINO_CTRL_B_INT;
1822 vino->control = ctrl; 1913 vino->control = ctrl;
1823 dprintk("vino_dma_stop():\n"); 1914 dprintk("vino_dma_stop():\n");
1824} 1915}
@@ -1902,7 +1993,7 @@ static int vino_capture_next(struct vino_channel_settings *vcs, int start)
1902 struct vino_framebuffer *fb; 1993 struct vino_framebuffer *fb;
1903 unsigned int incoming, id; 1994 unsigned int incoming, id;
1904 int err = 0; 1995 int err = 0;
1905 unsigned long flags, flags2; 1996 unsigned long flags;
1906 1997
1907 dprintk("vino_capture_next():\n"); 1998 dprintk("vino_capture_next():\n");
1908 1999
@@ -1943,10 +2034,6 @@ static int vino_capture_next(struct vino_channel_settings *vcs, int start)
1943 goto out; 2034 goto out;
1944 } 2035 }
1945 2036
1946 spin_lock_irqsave(&fb->state_lock, flags2);
1947 fb->state = VINO_FRAMEBUFFER_UNUSED;
1948 spin_unlock_irqrestore(&fb->state_lock, flags2);
1949
1950 if (start) { 2037 if (start) {
1951 vcs->capturing = 1; 2038 vcs->capturing = 1;
1952 } 2039 }
@@ -1964,7 +2051,7 @@ out:
1964 return err; 2051 return err;
1965} 2052}
1966 2053
1967static int vino_is_capturing(struct vino_channel_settings *vcs) 2054static inline int vino_is_capturing(struct vino_channel_settings *vcs)
1968{ 2055{
1969 int ret; 2056 int ret;
1970 unsigned long flags; 2057 unsigned long flags;
@@ -2076,6 +2163,7 @@ static void vino_capture_stop(struct vino_channel_settings *vcs)
2076 dprintk("vino_capture_stop():\n"); 2163 dprintk("vino_capture_stop():\n");
2077 2164
2078 spin_lock_irqsave(&vcs->capture_lock, flags); 2165 spin_lock_irqsave(&vcs->capture_lock, flags);
2166
2079 /* unset capturing to stop queue processing */ 2167 /* unset capturing to stop queue processing */
2080 vcs->capturing = 0; 2168 vcs->capturing = 0;
2081 2169
@@ -2121,6 +2209,7 @@ out:
2121 spin_unlock_irqrestore(&vcs->capture_lock, flags); 2209 spin_unlock_irqrestore(&vcs->capture_lock, flags);
2122} 2210}
2123 2211
2212#if 0
2124static int vino_capture_failed(struct vino_channel_settings *vcs) 2213static int vino_capture_failed(struct vino_channel_settings *vcs)
2125{ 2214{
2126 struct vino_framebuffer *fb; 2215 struct vino_framebuffer *fb;
@@ -2165,9 +2254,31 @@ static int vino_capture_failed(struct vino_channel_settings *vcs)
2165 2254
2166 return 0; 2255 return 0;
2167} 2256}
2257#endif
2258
2259static void vino_skip_frame(struct vino_channel_settings *vcs)
2260{
2261 struct vino_framebuffer *fb;
2262 unsigned long flags;
2263 unsigned int id;
2264
2265 spin_lock_irqsave(&vcs->capture_lock, flags);
2266 fb = vino_queue_peek(&vcs->fb_queue, &id);
2267 if (!fb) {
2268 spin_unlock_irqrestore(&vcs->capture_lock, flags);
2269 dprintk("vino_skip_frame(): vino_queue_peek() failed!\n");
2270 return;
2271 }
2272 spin_unlock_irqrestore(&vcs->capture_lock, flags);
2273
2274 spin_lock_irqsave(&fb->state_lock, flags);
2275 fb->state = VINO_FRAMEBUFFER_UNUSED;
2276 spin_unlock_irqrestore(&fb->state_lock, flags);
2277
2278 vino_capture_next(vcs, 0);
2279}
2168 2280
2169static void vino_frame_done(struct vino_channel_settings *vcs, 2281static void vino_frame_done(struct vino_channel_settings *vcs)
2170 unsigned int fc)
2171{ 2282{
2172 struct vino_framebuffer *fb; 2283 struct vino_framebuffer *fb;
2173 unsigned long flags; 2284 unsigned long flags;
@@ -2181,8 +2292,9 @@ static void vino_frame_done(struct vino_channel_settings *vcs,
2181 } 2292 }
2182 spin_unlock_irqrestore(&vcs->capture_lock, flags); 2293 spin_unlock_irqrestore(&vcs->capture_lock, flags);
2183 2294
2184 fb->frame_counter = fc; 2295 fb->frame_counter = vcs->int_data.frame_counter;
2185 do_gettimeofday(&fb->timestamp); 2296 memcpy(&fb->timestamp, &vcs->int_data.timestamp,
2297 sizeof(struct timeval));
2186 2298
2187 spin_lock_irqsave(&fb->state_lock, flags); 2299 spin_lock_irqsave(&fb->state_lock, flags);
2188 if (fb->state == VINO_FRAMEBUFFER_IN_USE) 2300 if (fb->state == VINO_FRAMEBUFFER_IN_USE)
@@ -2194,72 +2306,175 @@ static void vino_frame_done(struct vino_channel_settings *vcs,
2194 vino_capture_next(vcs, 0); 2306 vino_capture_next(vcs, 0);
2195} 2307}
2196 2308
2309static void vino_capture_tasklet(unsigned long channel) {
2310 struct vino_channel_settings *vcs;
2311
2312 vcs = (channel == VINO_CHANNEL_A)
2313 ? &vino_drvdata->a : &vino_drvdata->b;
2314
2315 if (vcs->int_data.skip)
2316 vcs->int_data.skip_count++;
2317
2318 if (vcs->int_data.skip && (vcs->int_data.skip_count
2319 <= VINO_MAX_FRAME_SKIP_COUNT)) {
2320 vino_skip_frame(vcs);
2321 } else {
2322 vcs->int_data.skip_count = 0;
2323 vino_frame_done(vcs);
2324 }
2325}
2326
2197static irqreturn_t vino_interrupt(int irq, void *dev_id, struct pt_regs *regs) 2327static irqreturn_t vino_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2198{ 2328{
2199 u32 intr; 2329 u32 ctrl, intr;
2200 unsigned int fc_a, fc_b; 2330 unsigned int fc_a, fc_b;
2201 int done_a = 0; 2331 int handled_a = 0, skip_a = 0, done_a = 0;
2202 int done_b = 0; 2332 int handled_b = 0, skip_b = 0, done_b = 0;
2333
2334#ifdef VINO_DEBUG_INT
2335 int loop = 0;
2336 unsigned int line_count = vino->a.line_count,
2337 page_index = vino->a.page_index,
2338 field_counter = vino->a.field_counter,
2339 start_desc_tbl = vino->a.start_desc_tbl,
2340 next_4_desc = vino->a.next_4_desc;
2341 unsigned int line_count_2,
2342 page_index_2,
2343 field_counter_2,
2344 start_desc_tbl_2,
2345 next_4_desc_2;
2346#endif
2203 2347
2204 spin_lock(&vino_drvdata->vino_lock); 2348 spin_lock(&vino_drvdata->vino_lock);
2205 2349
2206 intr = vino->intr_status; 2350 while ((intr = vino->intr_status)) {
2207 fc_a = vino->a.field_counter / 2; 2351 fc_a = vino->a.field_counter >> 1;
2208 fc_b = vino->b.field_counter / 2; 2352 fc_b = vino->b.field_counter >> 1;
2209 2353
2210 // TODO: handle error-interrupts in some special way ? 2354 /* handle error-interrupts in some special way ?
2211 2355 * --> skips frames */
2212 if (intr & VINO_INTSTAT_A) { 2356 if (intr & VINO_INTSTAT_A) {
2213 if (intr & VINO_INTSTAT_A_EOF) { 2357 if (intr & VINO_INTSTAT_A_EOF) {
2214 vino_drvdata->a.field++; 2358 vino_drvdata->a.field++;
2215 if (vino_drvdata->a.field > 1) { 2359 if (vino_drvdata->a.field > 1) {
2360 vino_dma_stop(&vino_drvdata->a);
2361 vino_clear_interrupt(&vino_drvdata->a);
2362 vino_drvdata->a.field = 0;
2363 done_a = 1;
2364 } else {
2365 if (vino->a.page_index
2366 != vino_drvdata->a.line_size) {
2367 vino->a.line_count = 0;
2368 vino->a.page_index =
2369 vino_drvdata->
2370 a.line_size;
2371 vino->a.next_4_desc =
2372 vino->a.start_desc_tbl;
2373 }
2374 }
2375 dprintk("channel A end-of-field "
2376 "interrupt: %04x\n", intr);
2377 } else {
2216 vino_dma_stop(&vino_drvdata->a); 2378 vino_dma_stop(&vino_drvdata->a);
2217 vino_clear_interrupt(&vino_drvdata->a); 2379 vino_clear_interrupt(&vino_drvdata->a);
2218 vino_drvdata->a.field = 0; 2380 vino_drvdata->a.field = 0;
2219 done_a = 1; 2381 skip_a = 1;
2382 dprintk("channel A error interrupt: %04x\n",
2383 intr);
2220 } 2384 }
2221 dprintk("intr: channel A end-of-field interrupt: " 2385
2222 "%04x\n", intr); 2386#ifdef VINO_DEBUG_INT
2223 } else { 2387 line_count_2 = vino->a.line_count;
2224 vino_dma_stop(&vino_drvdata->a); 2388 page_index_2 = vino->a.page_index;
2225 vino_clear_interrupt(&vino_drvdata->a); 2389 field_counter_2 = vino->a.field_counter;
2226 done_a = 1; 2390 start_desc_tbl_2 = vino->a.start_desc_tbl;
2227 dprintk("channel A error interrupt: %04x\n", intr); 2391 next_4_desc_2 = vino->a.next_4_desc;
2392
2393 printk("intr = %04x, loop = %d, field = %d\n",
2394 intr, loop, vino_drvdata->a.field);
2395 printk("1- line count = %04d, page index = %04d, "
2396 "start = %08x, next = %08x\n"
2397 " fieldc = %d, framec = %d\n",
2398 line_count, page_index, start_desc_tbl,
2399 next_4_desc, field_counter, fc_a);
2400 printk("12-line count = %04d, page index = %04d, "
2401 " start = %08x, next = %08x\n",
2402 line_count_2, page_index_2, start_desc_tbl_2,
2403 next_4_desc_2);
2404
2405 if (done_a)
2406 printk("\n");
2407#endif
2228 } 2408 }
2229 } 2409
2230 if (intr & VINO_INTSTAT_B) { 2410 if (intr & VINO_INTSTAT_B) {
2231 if (intr & VINO_INTSTAT_B_EOF) { 2411 if (intr & VINO_INTSTAT_B_EOF) {
2232 vino_drvdata->b.field++; 2412 vino_drvdata->b.field++;
2233 if (vino_drvdata->b.field > 1) { 2413 if (vino_drvdata->b.field > 1) {
2414 vino_dma_stop(&vino_drvdata->b);
2415 vino_clear_interrupt(&vino_drvdata->b);
2416 vino_drvdata->b.field = 0;
2417 done_b = 1;
2418 }
2419 dprintk("channel B end-of-field "
2420 "interrupt: %04x\n", intr);
2421 } else {
2234 vino_dma_stop(&vino_drvdata->b); 2422 vino_dma_stop(&vino_drvdata->b);
2235 vino_clear_interrupt(&vino_drvdata->b); 2423 vino_clear_interrupt(&vino_drvdata->b);
2236 vino_drvdata->b.field = 0; 2424 vino_drvdata->b.field = 0;
2237 done_b = 1; 2425 skip_b = 1;
2426 dprintk("channel B error interrupt: %04x\n",
2427 intr);
2238 } 2428 }
2239 dprintk("intr: channel B end-of-field interrupt: "
2240 "%04x\n", intr);
2241 } else {
2242 vino_dma_stop(&vino_drvdata->b);
2243 vino_clear_interrupt(&vino_drvdata->b);
2244 done_b = 1;
2245 dprintk("channel B error interrupt: %04x\n", intr);
2246 } 2429 }
2247 }
2248 2430
2249 /* always remember to clear interrupt status */ 2431 /* Always remember to clear interrupt status.
2250 vino->intr_status = ~intr; 2432 * Disable VINO interrupts while we do this. */
2433 ctrl = vino->control;
2434 vino->control = ctrl & ~(VINO_CTRL_A_INT | VINO_CTRL_B_INT);
2435 vino->intr_status = ~intr;
2436 vino->control = ctrl;
2251 2437
2252 spin_unlock(&vino_drvdata->vino_lock); 2438 spin_unlock(&vino_drvdata->vino_lock);
2253 2439
2254 if (done_a) { 2440 if ((!handled_a) && (done_a || skip_a)) {
2255 vino_frame_done(&vino_drvdata->a, fc_a); 2441 if (!skip_a) {
2256 dprintk("channel A frame done, interrupt: %d\n", intr); 2442 do_gettimeofday(&vino_drvdata->
2257 } 2443 a.int_data.timestamp);
2258 if (done_b) { 2444 vino_drvdata->a.int_data.frame_counter = fc_a;
2259 vino_frame_done(&vino_drvdata->b, fc_b); 2445 }
2260 dprintk("channel B frame done, interrupt: %d\n", intr); 2446 vino_drvdata->a.int_data.skip = skip_a;
2447
2448 dprintk("channel A %s, interrupt: %d\n",
2449 skip_a ? "skipping frame" : "frame done",
2450 intr);
2451 tasklet_hi_schedule(&vino_tasklet_a);
2452 handled_a = 1;
2453 }
2454
2455 if ((!handled_b) && (done_b || skip_b)) {
2456 if (!skip_b) {
2457 do_gettimeofday(&vino_drvdata->
2458 b.int_data.timestamp);
2459 vino_drvdata->b.int_data.frame_counter = fc_b;
2460 }
2461 vino_drvdata->b.int_data.skip = skip_b;
2462
2463 dprintk("channel B %s, interrupt: %d\n",
2464 skip_b ? "skipping frame" : "frame done",
2465 intr);
2466 tasklet_hi_schedule(&vino_tasklet_b);
2467 handled_b = 1;
2468 }
2469
2470#ifdef VINO_DEBUG_INT
2471 loop++;
2472#endif
2473 spin_lock(&vino_drvdata->vino_lock);
2261 } 2474 }
2262 2475
2476 spin_unlock(&vino_drvdata->vino_lock);
2477
2263 return IRQ_HANDLED; 2478 return IRQ_HANDLED;
2264} 2479}
2265 2480
@@ -2279,11 +2494,13 @@ static int vino_get_saa7191_input(int input)
2279 } 2494 }
2280} 2495}
2281 2496
2282static int vino_get_saa7191_norm(int norm) 2497static int vino_get_saa7191_norm(unsigned int data_norm)
2283{ 2498{
2284 switch (norm) { 2499 switch (data_norm) {
2285 case VINO_DATA_NORM_AUTO: 2500 case VINO_DATA_NORM_AUTO:
2286 return SAA7191_NORM_AUTO; 2501 return SAA7191_NORM_AUTO;
2502 case VINO_DATA_NORM_AUTO_EXT:
2503 return SAA7191_NORM_AUTO_EXT;
2287 case VINO_DATA_NORM_PAL: 2504 case VINO_DATA_NORM_PAL:
2288 return SAA7191_NORM_PAL; 2505 return SAA7191_NORM_PAL;
2289 case VINO_DATA_NORM_NTSC: 2506 case VINO_DATA_NORM_NTSC:
@@ -2297,6 +2514,57 @@ static int vino_get_saa7191_norm(int norm)
2297 } 2514 }
2298} 2515}
2299 2516
2517static int vino_get_from_saa7191_norm(int saa7191_norm)
2518{
2519 switch (saa7191_norm) {
2520 case SAA7191_NORM_PAL:
2521 return VINO_DATA_NORM_PAL;
2522 case SAA7191_NORM_NTSC:
2523 return VINO_DATA_NORM_NTSC;
2524 case SAA7191_NORM_SECAM:
2525 return VINO_DATA_NORM_SECAM;
2526 default:
2527 printk(KERN_ERR "VINO: vino_get_from_saa7191_norm(): "
2528 "invalid norm!\n");
2529 return VINO_DATA_NORM_NONE;
2530 }
2531}
2532
2533static int vino_saa7191_set_norm(unsigned int *data_norm)
2534{
2535 int saa7191_norm, new_data_norm;
2536 int err = 0;
2537
2538 saa7191_norm = vino_get_saa7191_norm(*data_norm);
2539
2540 err = i2c_decoder_command(DECODER_SAA7191_SET_NORM,
2541 &saa7191_norm);
2542 if (err)
2543 goto out;
2544
2545 if ((*data_norm == VINO_DATA_NORM_AUTO)
2546 || (*data_norm == VINO_DATA_NORM_AUTO_EXT)) {
2547 struct saa7191_status status;
2548
2549 err = i2c_decoder_command(DECODER_SAA7191_GET_STATUS,
2550 &status);
2551 if (err)
2552 goto out;
2553
2554 new_data_norm =
2555 vino_get_from_saa7191_norm(status.norm);
2556 if (new_data_norm == VINO_DATA_NORM_NONE) {
2557 err = -EINVAL;
2558 goto out;
2559 }
2560
2561 *data_norm = (unsigned int)new_data_norm;
2562 }
2563
2564out:
2565 return err;
2566}
2567
2300/* execute with input_lock locked */ 2568/* execute with input_lock locked */
2301static int vino_is_input_owner(struct vino_channel_settings *vcs) 2569static int vino_is_input_owner(struct vino_channel_settings *vcs)
2302{ 2570{
@@ -2313,11 +2581,12 @@ static int vino_is_input_owner(struct vino_channel_settings *vcs)
2313 2581
2314static int vino_acquire_input(struct vino_channel_settings *vcs) 2582static int vino_acquire_input(struct vino_channel_settings *vcs)
2315{ 2583{
2584 unsigned long flags;
2316 int ret = 0; 2585 int ret = 0;
2317 2586
2318 dprintk("vino_acquire_input():\n"); 2587 dprintk("vino_acquire_input():\n");
2319 2588
2320 spin_lock(&vino_drvdata->input_lock); 2589 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2321 2590
2322 /* First try D1 and then SAA7191 */ 2591 /* First try D1 and then SAA7191 */
2323 if (vino_drvdata->camera.driver 2592 if (vino_drvdata->camera.driver
@@ -2332,23 +2601,48 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
2332 vcs->data_norm = VINO_DATA_NORM_D1; 2601 vcs->data_norm = VINO_DATA_NORM_D1;
2333 } else if (vino_drvdata->decoder.driver 2602 } else if (vino_drvdata->decoder.driver
2334 && (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) { 2603 && (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) {
2604 int input, data_norm;
2335 int saa7191_input; 2605 int saa7191_input;
2336 int saa7191_norm;
2337 2606
2338 if (i2c_use_client(vino_drvdata->decoder.driver)) { 2607 if (i2c_use_client(vino_drvdata->decoder.driver)) {
2339 ret = -ENODEV; 2608 ret = -ENODEV;
2340 goto out; 2609 goto out;
2341 } 2610 }
2342 2611
2343 vino_drvdata->decoder.owner = vcs->channel; 2612 input = VINO_INPUT_COMPOSITE;
2344 vcs->input = VINO_INPUT_COMPOSITE; 2613
2345 vcs->data_norm = VINO_DATA_NORM_PAL; 2614 saa7191_input = vino_get_saa7191_input(input);
2615 ret = i2c_decoder_command(DECODER_SET_INPUT,
2616 &saa7191_input);
2617 if (ret) {
2618 ret = -EINVAL;
2619 goto out;
2620 }
2621
2622 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2346 2623
2347 saa7191_input = vino_get_saa7191_input(vcs->input); 2624 /* Don't hold spinlocks while auto-detecting norm
2348 i2c_decoder_command(DECODER_SET_INPUT, &saa7191_input); 2625 * as it may take a while... */
2349 2626
2350 saa7191_norm = vino_get_saa7191_norm(vcs->data_norm); 2627 data_norm = VINO_DATA_NORM_AUTO_EXT;
2351 i2c_decoder_command(DECODER_SAA7191_SET_NORM, &saa7191_norm); 2628
2629 ret = vino_saa7191_set_norm(&data_norm);
2630 if ((ret == -EBUSY) || (ret == -EAGAIN)) {
2631 data_norm = VINO_DATA_NORM_PAL;
2632 ret = vino_saa7191_set_norm(&data_norm);
2633 }
2634
2635 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2636
2637 if (ret) {
2638 ret = -EINVAL;
2639 goto out;
2640 }
2641
2642 vino_drvdata->decoder.owner = vcs->channel;
2643
2644 vcs->input = input;
2645 vcs->data_norm = data_norm;
2352 } else { 2646 } else {
2353 vcs->input = (vcs->channel == VINO_CHANNEL_A) ? 2647 vcs->input = (vcs->channel == VINO_CHANNEL_A) ?
2354 vino_drvdata->b.input : vino_drvdata->a.input; 2648 vino_drvdata->b.input : vino_drvdata->a.input;
@@ -2361,15 +2655,14 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
2361 goto out; 2655 goto out;
2362 } 2656 }
2363 2657
2364 if (vino_is_input_owner(vcs)) { 2658 vino_set_default_clipping(vcs);
2365 vino_set_default_clipping(vcs); 2659 vino_set_default_scaling(vcs);
2366 vino_set_default_framerate(vcs); 2660 vino_set_default_framerate(vcs);
2367 }
2368 2661
2369 dprintk("vino_acquire_input(): %s\n", vino_inputs[vcs->input].name); 2662 dprintk("vino_acquire_input(): %s\n", vino_inputs[vcs->input].name);
2370 2663
2371out: 2664out:
2372 spin_unlock(&vino_drvdata->input_lock); 2665 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2373 2666
2374 return ret; 2667 return ret;
2375} 2668}
@@ -2378,16 +2671,17 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2378{ 2671{
2379 struct vino_channel_settings *vcs2 = (vcs->channel == VINO_CHANNEL_A) ? 2672 struct vino_channel_settings *vcs2 = (vcs->channel == VINO_CHANNEL_A) ?
2380 &vino_drvdata->b : &vino_drvdata->a; 2673 &vino_drvdata->b : &vino_drvdata->a;
2674 unsigned long flags;
2381 int ret = 0; 2675 int ret = 0;
2382 2676
2383 dprintk("vino_set_input():\n"); 2677 dprintk("vino_set_input():\n");
2384 2678
2385 spin_lock(&vino_drvdata->input_lock); 2679 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2386 2680
2387 if (vcs->input == input) 2681 if (vcs->input == input)
2388 goto out; 2682 goto out;
2389 2683
2390 switch(input) { 2684 switch (input) {
2391 case VINO_INPUT_COMPOSITE: 2685 case VINO_INPUT_COMPOSITE:
2392 case VINO_INPUT_SVIDEO: 2686 case VINO_INPUT_SVIDEO:
2393 if (!vino_drvdata->decoder.driver) { 2687 if (!vino_drvdata->decoder.driver) {
@@ -2404,19 +2698,43 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2404 } 2698 }
2405 2699
2406 if (vino_drvdata->decoder.owner == vcs->channel) { 2700 if (vino_drvdata->decoder.owner == vcs->channel) {
2701 int data_norm;
2407 int saa7191_input; 2702 int saa7191_input;
2408 int saa7191_norm;
2409 2703
2410 vcs->input = input; 2704 saa7191_input = vino_get_saa7191_input(input);
2411 vcs->data_norm = VINO_DATA_NORM_PAL; 2705 ret = i2c_decoder_command(DECODER_SET_INPUT,
2706 &saa7191_input);
2707 if (ret) {
2708 vino_drvdata->decoder.owner = VINO_NO_CHANNEL;
2709 ret = -EINVAL;
2710 goto out;
2711 }
2712
2713 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2714
2715 /* Don't hold spinlocks while auto-detecting norm
2716 * as it may take a while... */
2717
2718 data_norm = VINO_DATA_NORM_AUTO_EXT;
2719
2720 ret = vino_saa7191_set_norm(&data_norm);
2721 if ((ret == -EBUSY) || (ret == -EAGAIN)) {
2722 data_norm = VINO_DATA_NORM_PAL;
2723 ret = vino_saa7191_set_norm(&data_norm);
2724 }
2412 2725
2413 saa7191_input = vino_get_saa7191_input(vcs->input); 2726 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2414 i2c_decoder_command(DECODER_SET_INPUT, &saa7191_input); 2727
2415 saa7191_norm = vino_get_saa7191_norm(vcs->data_norm); 2728 if (ret) {
2416 i2c_decoder_command(DECODER_SAA7191_SET_NORM, 2729 vino_drvdata->decoder.owner = VINO_NO_CHANNEL;
2417 &saa7191_norm); 2730 ret = -EINVAL;
2731 goto out;
2732 }
2733
2734 vcs->input = input;
2735 vcs->data_norm = data_norm;
2418 } else { 2736 } else {
2419 if (vcs2->input != input) { 2737 if (input != vcs2->input) {
2420 ret = -EBUSY; 2738 ret = -EBUSY;
2421 goto out; 2739 goto out;
2422 } 2740 }
@@ -2471,12 +2789,13 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2471 } 2789 }
2472 2790
2473 vino_set_default_clipping(vcs); 2791 vino_set_default_clipping(vcs);
2792 vino_set_default_scaling(vcs);
2474 vino_set_default_framerate(vcs); 2793 vino_set_default_framerate(vcs);
2475 2794
2476 dprintk("vino_set_input(): %s\n", vino_inputs[vcs->input].name); 2795 dprintk("vino_set_input(): %s\n", vino_inputs[vcs->input].name);
2477 2796
2478out: 2797out:
2479 spin_unlock(&vino_drvdata->input_lock); 2798 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2480 2799
2481 return ret; 2800 return ret;
2482} 2801}
@@ -2485,10 +2804,11 @@ static void vino_release_input(struct vino_channel_settings *vcs)
2485{ 2804{
2486 struct vino_channel_settings *vcs2 = (vcs->channel == VINO_CHANNEL_A) ? 2805 struct vino_channel_settings *vcs2 = (vcs->channel == VINO_CHANNEL_A) ?
2487 &vino_drvdata->b : &vino_drvdata->a; 2806 &vino_drvdata->b : &vino_drvdata->a;
2807 unsigned long flags;
2488 2808
2489 dprintk("vino_release_input():\n"); 2809 dprintk("vino_release_input():\n");
2490 2810
2491 spin_lock(&vino_drvdata->input_lock); 2811 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2492 2812
2493 /* Release ownership of the channel 2813 /* Release ownership of the channel
2494 * and if the other channel takes input from 2814 * and if the other channel takes input from
@@ -2511,34 +2831,61 @@ static void vino_release_input(struct vino_channel_settings *vcs)
2511 } 2831 }
2512 vcs->input = VINO_INPUT_NONE; 2832 vcs->input = VINO_INPUT_NONE;
2513 2833
2514 spin_unlock(&vino_drvdata->input_lock); 2834 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2515} 2835}
2516 2836
2517/* execute with input_lock locked */ 2837/* execute with input_lock locked */
2518static int vino_set_data_norm(struct vino_channel_settings *vcs, 2838static int vino_set_data_norm(struct vino_channel_settings *vcs,
2519 unsigned int data_norm) 2839 unsigned int data_norm,
2840 unsigned long *flags)
2520{ 2841{
2521 int saa7191_norm; 2842 int err = 0;
2843
2844 if (data_norm == vcs->data_norm)
2845 return 0;
2522 2846
2523 switch (vcs->input) { 2847 switch (vcs->input) {
2524 case VINO_INPUT_D1: 2848 case VINO_INPUT_D1:
2525 /* only one "norm" supported */ 2849 /* only one "norm" supported */
2526 if (data_norm != VINO_DATA_NORM_D1) 2850 if ((data_norm != VINO_DATA_NORM_D1)
2851 && (data_norm != VINO_DATA_NORM_AUTO)
2852 && (data_norm != VINO_DATA_NORM_AUTO_EXT))
2527 return -EINVAL; 2853 return -EINVAL;
2528 break; 2854 break;
2529 case VINO_INPUT_COMPOSITE: 2855 case VINO_INPUT_COMPOSITE:
2530 case VINO_INPUT_SVIDEO: 2856 case VINO_INPUT_SVIDEO: {
2857 if ((data_norm != VINO_DATA_NORM_PAL)
2858 && (data_norm != VINO_DATA_NORM_NTSC)
2859 && (data_norm != VINO_DATA_NORM_SECAM)
2860 && (data_norm != VINO_DATA_NORM_AUTO)
2861 && (data_norm != VINO_DATA_NORM_AUTO_EXT))
2862 return -EINVAL;
2531 2863
2532 saa7191_norm = vino_get_saa7191_norm(data_norm); 2864 spin_unlock_irqrestore(&vino_drvdata->input_lock, *flags);
2865
2866 /* Don't hold spinlocks while setting norm
2867 * as it may take a while... */
2868
2869 err = vino_saa7191_set_norm(&data_norm);
2870
2871 spin_lock_irqsave(&vino_drvdata->input_lock, *flags);
2872
2873 if (err)
2874 goto out;
2533 2875
2534 i2c_decoder_command(DECODER_SAA7191_SET_NORM, &saa7191_norm);
2535 vcs->data_norm = data_norm; 2876 vcs->data_norm = data_norm;
2877
2878 vino_set_default_clipping(vcs);
2879 vino_set_default_scaling(vcs);
2880 vino_set_default_framerate(vcs);
2536 break; 2881 break;
2882 }
2537 default: 2883 default:
2538 return -EINVAL; 2884 return -EINVAL;
2539 } 2885 }
2540 2886
2541 return 0; 2887out:
2888 return err;
2542} 2889}
2543 2890
2544/* V4L2 helper functions */ 2891/* V4L2 helper functions */
@@ -2558,8 +2905,9 @@ static int vino_find_data_format(__u32 pixelformat)
2558static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index) 2905static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index)
2559{ 2906{
2560 int data_norm = VINO_DATA_NORM_NONE; 2907 int data_norm = VINO_DATA_NORM_NONE;
2908 unsigned long flags;
2561 2909
2562 spin_lock(&vino_drvdata->input_lock); 2910 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2563 switch(vcs->input) { 2911 switch(vcs->input) {
2564 case VINO_INPUT_COMPOSITE: 2912 case VINO_INPUT_COMPOSITE:
2565 case VINO_INPUT_SVIDEO: 2913 case VINO_INPUT_SVIDEO:
@@ -2577,7 +2925,7 @@ static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index)
2577 } 2925 }
2578 break; 2926 break;
2579 } 2927 }
2580 spin_unlock(&vino_drvdata->input_lock); 2928 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2581 2929
2582 return data_norm; 2930 return data_norm;
2583} 2931}
@@ -2585,8 +2933,9 @@ static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index)
2585static int vino_enum_input(struct vino_channel_settings *vcs, __u32 index) 2933static int vino_enum_input(struct vino_channel_settings *vcs, __u32 index)
2586{ 2934{
2587 int input = VINO_INPUT_NONE; 2935 int input = VINO_INPUT_NONE;
2936 unsigned long flags;
2588 2937
2589 spin_lock(&vino_drvdata->input_lock); 2938 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2590 if (vino_drvdata->decoder.driver && vino_drvdata->camera.driver) { 2939 if (vino_drvdata->decoder.driver && vino_drvdata->camera.driver) {
2591 switch (index) { 2940 switch (index) {
2592 case 0: 2941 case 0:
@@ -2615,7 +2964,7 @@ static int vino_enum_input(struct vino_channel_settings *vcs, __u32 index)
2615 break; 2964 break;
2616 } 2965 }
2617 } 2966 }
2618 spin_unlock(&vino_drvdata->input_lock); 2967 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2619 2968
2620 return input; 2969 return input;
2621} 2970}
@@ -2704,15 +3053,16 @@ static int vino_v4l2_enuminput(struct vino_channel_settings *vcs,
2704} 3053}
2705 3054
2706static int vino_v4l2_g_input(struct vino_channel_settings *vcs, 3055static int vino_v4l2_g_input(struct vino_channel_settings *vcs,
2707 struct v4l2_input *i) 3056 unsigned int *i)
2708{ 3057{
2709 __u32 index; 3058 __u32 index;
2710 int input; 3059 int input;
3060 unsigned long flags;
2711 3061
2712 spin_lock(&vino_drvdata->input_lock); 3062 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2713 input = vcs->input; 3063 input = vcs->input;
2714 index = vino_find_input_index(vcs); 3064 index = vino_find_input_index(vcs);
2715 spin_unlock(&vino_drvdata->input_lock); 3065 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2716 3066
2717 dprintk("input = %d\n", input); 3067 dprintk("input = %d\n", input);
2718 3068
@@ -2720,23 +3070,18 @@ static int vino_v4l2_g_input(struct vino_channel_settings *vcs,
2720 return -EINVAL; 3070 return -EINVAL;
2721 } 3071 }
2722 3072
2723 memset(i, 0, sizeof(struct v4l2_input)); 3073 *i = index;
2724
2725 i->index = index;
2726 i->type = V4L2_INPUT_TYPE_CAMERA;
2727 i->std = vino_inputs[input].std;
2728 strcpy(i->name, vino_inputs[input].name);
2729 3074
2730 return 0; 3075 return 0;
2731} 3076}
2732 3077
2733static int vino_v4l2_s_input(struct vino_channel_settings *vcs, 3078static int vino_v4l2_s_input(struct vino_channel_settings *vcs,
2734 struct v4l2_input *i) 3079 unsigned int *i)
2735{ 3080{
2736 int input; 3081 int input;
2737 dprintk("requested input = %d\n", i->index); 3082 dprintk("requested input = %d\n", *i);
2738 3083
2739 input = vino_enum_input(vcs, i->index); 3084 input = vino_enum_input(vcs, *i);
2740 if (input == VINO_INPUT_NONE) 3085 if (input == VINO_INPUT_NONE)
2741 return -EINVAL; 3086 return -EINVAL;
2742 3087
@@ -2747,7 +3092,9 @@ static int vino_v4l2_enumstd(struct vino_channel_settings *vcs,
2747 struct v4l2_standard *s) 3092 struct v4l2_standard *s)
2748{ 3093{
2749 int index = s->index; 3094 int index = s->index;
2750 int data_norm = vino_enum_data_norm(vcs, index); 3095 int data_norm;
3096
3097 data_norm = vino_enum_data_norm(vcs, index);
2751 dprintk("standard index = %d\n", index); 3098 dprintk("standard index = %d\n", index);
2752 3099
2753 if (data_norm == VINO_DATA_NORM_NONE) 3100 if (data_norm == VINO_DATA_NORM_NONE)
@@ -2771,13 +3118,55 @@ static int vino_v4l2_enumstd(struct vino_channel_settings *vcs,
2771 return 0; 3118 return 0;
2772} 3119}
2773 3120
3121static int vino_v4l2_querystd(struct vino_channel_settings *vcs,
3122 v4l2_std_id *std)
3123{
3124 unsigned long flags;
3125 int err = 0;
3126
3127 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3128
3129 switch (vcs->input) {
3130 case VINO_INPUT_D1:
3131 *std = vino_inputs[vcs->input].std;
3132 break;
3133 case VINO_INPUT_COMPOSITE:
3134 case VINO_INPUT_SVIDEO: {
3135 struct saa7191_status status;
3136
3137 i2c_decoder_command(DECODER_SAA7191_GET_STATUS, &status);
3138
3139 if (status.signal) {
3140 if (status.signal_60hz) {
3141 *std = V4L2_STD_NTSC;
3142 } else {
3143 *std = V4L2_STD_PAL | V4L2_STD_SECAM;
3144 }
3145 } else {
3146 *std = vino_inputs[vcs->input].std;
3147 }
3148 break;
3149 }
3150 default:
3151 err = -EINVAL;
3152 }
3153
3154 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3155
3156 return err;
3157}
3158
2774static int vino_v4l2_g_std(struct vino_channel_settings *vcs, 3159static int vino_v4l2_g_std(struct vino_channel_settings *vcs,
2775 v4l2_std_id *std) 3160 v4l2_std_id *std)
2776{ 3161{
2777 spin_lock(&vino_drvdata->input_lock); 3162 unsigned long flags;
2778 dprintk("current standard = %d\n", vcs->data_norm); 3163
3164 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3165
2779 *std = vino_data_norms[vcs->data_norm].std; 3166 *std = vino_data_norms[vcs->data_norm].std;
2780 spin_unlock(&vino_drvdata->input_lock); 3167 dprintk("current standard = %d\n", vcs->data_norm);
3168
3169 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2781 3170
2782 return 0; 3171 return 0;
2783} 3172}
@@ -2785,13 +3174,18 @@ static int vino_v4l2_g_std(struct vino_channel_settings *vcs,
2785static int vino_v4l2_s_std(struct vino_channel_settings *vcs, 3174static int vino_v4l2_s_std(struct vino_channel_settings *vcs,
2786 v4l2_std_id *std) 3175 v4l2_std_id *std)
2787{ 3176{
3177 unsigned long flags;
2788 int ret = 0; 3178 int ret = 0;
2789 3179
2790 spin_lock(&vino_drvdata->input_lock); 3180 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3181
3182 if (!vino_is_input_owner(vcs)) {
3183 ret = -EBUSY;
3184 goto out;
3185 }
2791 3186
2792 /* check if the standard is valid for the current input */ 3187 /* check if the standard is valid for the current input */
2793 if (vino_is_input_owner(vcs) 3188 if ((*std) & vino_inputs[vcs->input].std) {
2794 && (vino_inputs[vcs->input].std & (*std))) {
2795 dprintk("standard accepted\n"); 3189 dprintk("standard accepted\n");
2796 3190
2797 /* change the video norm for SAA7191 3191 /* change the video norm for SAA7191
@@ -2800,24 +3194,33 @@ static int vino_v4l2_s_std(struct vino_channel_settings *vcs,
2800 if (vcs->input == VINO_INPUT_D1) 3194 if (vcs->input == VINO_INPUT_D1)
2801 goto out; 3195 goto out;
2802 3196
2803 if ((*std) & V4L2_STD_PAL) { 3197 if (((*std) & V4L2_STD_PAL)
2804 vino_set_data_norm(vcs, VINO_DATA_NORM_PAL); 3198 && ((*std) & V4L2_STD_NTSC)
2805 vcs->data_norm = VINO_DATA_NORM_PAL; 3199 && ((*std) & V4L2_STD_SECAM)) {
3200 ret = vino_set_data_norm(vcs, VINO_DATA_NORM_AUTO_EXT,
3201 &flags);
3202 } else if ((*std) & V4L2_STD_PAL) {
3203 ret = vino_set_data_norm(vcs, VINO_DATA_NORM_PAL,
3204 &flags);
2806 } else if ((*std) & V4L2_STD_NTSC) { 3205 } else if ((*std) & V4L2_STD_NTSC) {
2807 vino_set_data_norm(vcs, VINO_DATA_NORM_NTSC); 3206 ret = vino_set_data_norm(vcs, VINO_DATA_NORM_NTSC,
2808 vcs->data_norm = VINO_DATA_NORM_NTSC; 3207 &flags);
2809 } else if ((*std) & V4L2_STD_SECAM) { 3208 } else if ((*std) & V4L2_STD_SECAM) {
2810 vino_set_data_norm(vcs, VINO_DATA_NORM_SECAM); 3209 ret = vino_set_data_norm(vcs, VINO_DATA_NORM_SECAM,
2811 vcs->data_norm = VINO_DATA_NORM_SECAM; 3210 &flags);
2812 } else { 3211 } else {
2813 ret = -EINVAL; 3212 ret = -EINVAL;
2814 } 3213 }
3214
3215 if (ret) {
3216 ret = -EINVAL;
3217 }
2815 } else { 3218 } else {
2816 ret = -EINVAL; 3219 ret = -EINVAL;
2817 } 3220 }
2818 3221
2819out: 3222out:
2820 spin_unlock(&vino_drvdata->input_lock); 3223 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2821 3224
2822 return ret; 3225 return ret;
2823} 3226}
@@ -2855,6 +3258,7 @@ static int vino_v4l2_try_fmt(struct vino_channel_settings *vcs,
2855 struct v4l2_format *f) 3258 struct v4l2_format *f)
2856{ 3259{
2857 struct vino_channel_settings tempvcs; 3260 struct vino_channel_settings tempvcs;
3261 unsigned long flags;
2858 3262
2859 switch (f->type) { 3263 switch (f->type) {
2860 case V4L2_BUF_TYPE_VIDEO_CAPTURE: { 3264 case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
@@ -2863,13 +3267,13 @@ static int vino_v4l2_try_fmt(struct vino_channel_settings *vcs,
2863 dprintk("requested: w = %d, h = %d\n", 3267 dprintk("requested: w = %d, h = %d\n",
2864 pf->width, pf->height); 3268 pf->width, pf->height);
2865 3269
2866 spin_lock(&vino_drvdata->input_lock); 3270 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2867 memcpy(&tempvcs, vcs, sizeof(struct vino_channel_settings)); 3271 memcpy(&tempvcs, vcs, sizeof(struct vino_channel_settings));
2868 spin_unlock(&vino_drvdata->input_lock); 3272 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2869 3273
2870 tempvcs.data_format = vino_find_data_format(pf->pixelformat); 3274 tempvcs.data_format = vino_find_data_format(pf->pixelformat);
2871 if (tempvcs.data_format == VINO_DATA_FMT_NONE) { 3275 if (tempvcs.data_format == VINO_DATA_FMT_NONE) {
2872 tempvcs.data_format = VINO_DATA_FMT_RGB32; 3276 tempvcs.data_format = VINO_DATA_FMT_GREY;
2873 pf->pixelformat = 3277 pf->pixelformat =
2874 vino_data_formats[tempvcs.data_format]. 3278 vino_data_formats[tempvcs.data_format].
2875 pixelformat; 3279 pixelformat;
@@ -2908,10 +3312,13 @@ static int vino_v4l2_try_fmt(struct vino_channel_settings *vcs,
2908static int vino_v4l2_g_fmt(struct vino_channel_settings *vcs, 3312static int vino_v4l2_g_fmt(struct vino_channel_settings *vcs,
2909 struct v4l2_format *f) 3313 struct v4l2_format *f)
2910{ 3314{
3315 unsigned long flags;
3316
2911 switch (f->type) { 3317 switch (f->type) {
2912 case V4L2_BUF_TYPE_VIDEO_CAPTURE: { 3318 case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
2913 struct v4l2_pix_format *pf = &f->fmt.pix; 3319 struct v4l2_pix_format *pf = &f->fmt.pix;
2914 spin_lock(&vino_drvdata->input_lock); 3320
3321 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2915 3322
2916 pf->width = (vcs->clipping.right - vcs->clipping.left) / 3323 pf->width = (vcs->clipping.right - vcs->clipping.left) /
2917 vcs->decimation; 3324 vcs->decimation;
@@ -2930,7 +3337,7 @@ static int vino_v4l2_g_fmt(struct vino_channel_settings *vcs,
2930 3337
2931 pf->priv = 0; 3338 pf->priv = 0;
2932 3339
2933 spin_unlock(&vino_drvdata->input_lock); 3340 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2934 break; 3341 break;
2935 } 3342 }
2936 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 3343 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
@@ -2945,20 +3352,18 @@ static int vino_v4l2_s_fmt(struct vino_channel_settings *vcs,
2945 struct v4l2_format *f) 3352 struct v4l2_format *f)
2946{ 3353{
2947 int data_format; 3354 int data_format;
3355 unsigned long flags;
2948 3356
2949 switch (f->type) { 3357 switch (f->type) {
2950 case V4L2_BUF_TYPE_VIDEO_CAPTURE: { 3358 case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
2951 struct v4l2_pix_format *pf = &f->fmt.pix; 3359 struct v4l2_pix_format *pf = &f->fmt.pix;
2952 spin_lock(&vino_drvdata->input_lock);
2953 3360
2954 if (!vino_is_input_owner(vcs)) { 3361 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
2955 spin_unlock(&vino_drvdata->input_lock);
2956 return -EINVAL;
2957 }
2958 3362
2959 data_format = vino_find_data_format(pf->pixelformat); 3363 data_format = vino_find_data_format(pf->pixelformat);
3364
2960 if (data_format == VINO_DATA_FMT_NONE) { 3365 if (data_format == VINO_DATA_FMT_NONE) {
2961 vcs->data_format = VINO_DATA_FMT_RGB32; 3366 vcs->data_format = VINO_DATA_FMT_GREY;
2962 pf->pixelformat = 3367 pf->pixelformat =
2963 vino_data_formats[vcs->data_format]. 3368 vino_data_formats[vcs->data_format].
2964 pixelformat; 3369 pixelformat;
@@ -2985,7 +3390,7 @@ static int vino_v4l2_s_fmt(struct vino_channel_settings *vcs,
2985 3390
2986 pf->priv = 0; 3391 pf->priv = 0;
2987 3392
2988 spin_unlock(&vino_drvdata->input_lock); 3393 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
2989 break; 3394 break;
2990 } 3395 }
2991 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 3396 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
@@ -3000,12 +3405,15 @@ static int vino_v4l2_cropcap(struct vino_channel_settings *vcs,
3000 struct v4l2_cropcap *ccap) 3405 struct v4l2_cropcap *ccap)
3001{ 3406{
3002 const struct vino_data_norm *norm; 3407 const struct vino_data_norm *norm;
3408 unsigned long flags;
3003 3409
3004 switch (ccap->type) { 3410 switch (ccap->type) {
3005 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 3411 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
3006 spin_lock(&vino_drvdata->input_lock); 3412 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3413
3007 norm = &vino_data_norms[vcs->data_norm]; 3414 norm = &vino_data_norms[vcs->data_norm];
3008 spin_unlock(&vino_drvdata->input_lock); 3415
3416 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3009 3417
3010 ccap->bounds.left = 0; 3418 ccap->bounds.left = 0;
3011 ccap->bounds.top = 0; 3419 ccap->bounds.top = 0;
@@ -3028,16 +3436,18 @@ static int vino_v4l2_cropcap(struct vino_channel_settings *vcs,
3028static int vino_v4l2_g_crop(struct vino_channel_settings *vcs, 3436static int vino_v4l2_g_crop(struct vino_channel_settings *vcs,
3029 struct v4l2_crop *c) 3437 struct v4l2_crop *c)
3030{ 3438{
3439 unsigned long flags;
3440
3031 switch (c->type) { 3441 switch (c->type) {
3032 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 3442 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
3033 spin_lock(&vino_drvdata->input_lock); 3443 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3034 3444
3035 c->c.left = vcs->clipping.left; 3445 c->c.left = vcs->clipping.left;
3036 c->c.top = vcs->clipping.top; 3446 c->c.top = vcs->clipping.top;
3037 c->c.width = vcs->clipping.right - vcs->clipping.left; 3447 c->c.width = vcs->clipping.right - vcs->clipping.left;
3038 c->c.height = vcs->clipping.bottom - vcs->clipping.top; 3448 c->c.height = vcs->clipping.bottom - vcs->clipping.top;
3039 3449
3040 spin_unlock(&vino_drvdata->input_lock); 3450 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3041 break; 3451 break;
3042 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 3452 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
3043 default: 3453 default:
@@ -3050,18 +3460,16 @@ static int vino_v4l2_g_crop(struct vino_channel_settings *vcs,
3050static int vino_v4l2_s_crop(struct vino_channel_settings *vcs, 3460static int vino_v4l2_s_crop(struct vino_channel_settings *vcs,
3051 struct v4l2_crop *c) 3461 struct v4l2_crop *c)
3052{ 3462{
3463 unsigned long flags;
3464
3053 switch (c->type) { 3465 switch (c->type) {
3054 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 3466 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
3055 spin_lock(&vino_drvdata->input_lock); 3467 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3056 3468
3057 if (!vino_is_input_owner(vcs)) {
3058 spin_unlock(&vino_drvdata->input_lock);
3059 return -EINVAL;
3060 }
3061 vino_set_clipping(vcs, c->c.left, c->c.top, 3469 vino_set_clipping(vcs, c->c.left, c->c.top,
3062 c->c.width, c->c.height); 3470 c->c.width, c->c.height);
3063 3471
3064 spin_unlock(&vino_drvdata->input_lock); 3472 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3065 break; 3473 break;
3066 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 3474 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
3067 default: 3475 default:
@@ -3074,6 +3482,8 @@ static int vino_v4l2_s_crop(struct vino_channel_settings *vcs,
3074static int vino_v4l2_g_parm(struct vino_channel_settings *vcs, 3482static int vino_v4l2_g_parm(struct vino_channel_settings *vcs,
3075 struct v4l2_streamparm *sp) 3483 struct v4l2_streamparm *sp)
3076{ 3484{
3485 unsigned long flags;
3486
3077 switch (sp->type) { 3487 switch (sp->type) {
3078 case V4L2_BUF_TYPE_VIDEO_CAPTURE: { 3488 case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
3079 struct v4l2_captureparm *cp = &sp->parm.capture; 3489 struct v4l2_captureparm *cp = &sp->parm.capture;
@@ -3082,9 +3492,11 @@ static int vino_v4l2_g_parm(struct vino_channel_settings *vcs,
3082 cp->capability = V4L2_CAP_TIMEPERFRAME; 3492 cp->capability = V4L2_CAP_TIMEPERFRAME;
3083 cp->timeperframe.numerator = 1; 3493 cp->timeperframe.numerator = 1;
3084 3494
3085 spin_lock(&vino_drvdata->input_lock); 3495 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3496
3086 cp->timeperframe.denominator = vcs->fps; 3497 cp->timeperframe.denominator = vcs->fps;
3087 spin_unlock(&vino_drvdata->input_lock); 3498
3499 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3088 3500
3089 // TODO: cp->readbuffers = xxx; 3501 // TODO: cp->readbuffers = xxx;
3090 break; 3502 break;
@@ -3100,15 +3512,13 @@ static int vino_v4l2_g_parm(struct vino_channel_settings *vcs,
3100static int vino_v4l2_s_parm(struct vino_channel_settings *vcs, 3512static int vino_v4l2_s_parm(struct vino_channel_settings *vcs,
3101 struct v4l2_streamparm *sp) 3513 struct v4l2_streamparm *sp)
3102{ 3514{
3515 unsigned long flags;
3516
3103 switch (sp->type) { 3517 switch (sp->type) {
3104 case V4L2_BUF_TYPE_VIDEO_CAPTURE: { 3518 case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
3105 struct v4l2_captureparm *cp = &sp->parm.capture; 3519 struct v4l2_captureparm *cp = &sp->parm.capture;
3106 3520
3107 spin_lock(&vino_drvdata->input_lock); 3521 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3108 if (!vino_is_input_owner(vcs)) {
3109 spin_unlock(&vino_drvdata->input_lock);
3110 return -EINVAL;
3111 }
3112 3522
3113 if ((cp->timeperframe.numerator == 0) || 3523 if ((cp->timeperframe.numerator == 0) ||
3114 (cp->timeperframe.denominator == 0)) { 3524 (cp->timeperframe.denominator == 0)) {
@@ -3118,7 +3528,8 @@ static int vino_v4l2_s_parm(struct vino_channel_settings *vcs,
3118 vino_set_framerate(vcs, cp->timeperframe.denominator / 3528 vino_set_framerate(vcs, cp->timeperframe.denominator /
3119 cp->timeperframe.numerator); 3529 cp->timeperframe.numerator);
3120 } 3530 }
3121 spin_unlock(&vino_drvdata->input_lock); 3531
3532 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3122 3533
3123 // TODO: set buffers according to cp->readbuffers 3534 // TODO: set buffers according to cp->readbuffers
3124 break; 3535 break;
@@ -3145,21 +3556,23 @@ static int vino_v4l2_reqbufs(struct vino_channel_settings *vcs,
3145 return -EINVAL; 3556 return -EINVAL;
3146 } 3557 }
3147 3558
3148 if (vino_is_capturing(vcs)) {
3149 dprintk("busy, capturing\n");
3150 return -EBUSY;
3151 }
3152
3153 dprintk("count = %d\n", rb->count); 3559 dprintk("count = %d\n", rb->count);
3154 if (rb->count > 0) { 3560 if (rb->count > 0) {
3561 if (vino_is_capturing(vcs)) {
3562 dprintk("busy, capturing\n");
3563 return -EBUSY;
3564 }
3565
3155 if (vino_queue_has_mapped_buffers(&vcs->fb_queue)) { 3566 if (vino_queue_has_mapped_buffers(&vcs->fb_queue)) {
3156 dprintk("busy, buffers still mapped\n"); 3567 dprintk("busy, buffers still mapped\n");
3157 return -EBUSY; 3568 return -EBUSY;
3158 } else { 3569 } else {
3570 vcs->streaming = 0;
3159 vino_queue_free(&vcs->fb_queue); 3571 vino_queue_free(&vcs->fb_queue);
3160 vino_queue_init(&vcs->fb_queue, &rb->count); 3572 vino_queue_init(&vcs->fb_queue, &rb->count);
3161 } 3573 }
3162 } else { 3574 } else {
3575 vcs->streaming = 0;
3163 vino_capture_stop(vcs); 3576 vino_capture_stop(vcs);
3164 vino_queue_free(&vcs->fb_queue); 3577 vino_queue_free(&vcs->fb_queue);
3165 } 3578 }
@@ -3302,12 +3715,12 @@ static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs,
3302 err = vino_queue_get_incoming(&vcs->fb_queue, &incoming); 3715 err = vino_queue_get_incoming(&vcs->fb_queue, &incoming);
3303 if (err) { 3716 if (err) {
3304 dprintk("vino_queue_get_incoming() failed\n"); 3717 dprintk("vino_queue_get_incoming() failed\n");
3305 return -EIO; 3718 return -EINVAL;
3306 } 3719 }
3307 err = vino_queue_get_outgoing(&vcs->fb_queue, &outgoing); 3720 err = vino_queue_get_outgoing(&vcs->fb_queue, &outgoing);
3308 if (err) { 3721 if (err) {
3309 dprintk("vino_queue_get_outgoing() failed\n"); 3722 dprintk("vino_queue_get_outgoing() failed\n");
3310 return -EIO; 3723 return -EINVAL;
3311 } 3724 }
3312 3725
3313 dprintk("incoming = %d, outgoing = %d\n", incoming, outgoing); 3726 dprintk("incoming = %d, outgoing = %d\n", incoming, outgoing);
@@ -3327,8 +3740,10 @@ static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs,
3327 if (err) { 3740 if (err) {
3328 err = vino_wait_for_frame(vcs); 3741 err = vino_wait_for_frame(vcs);
3329 if (err) { 3742 if (err) {
3330 /* interrupted */ 3743 /* interrupted or
3331 vino_capture_failed(vcs); 3744 * no frames captured because
3745 * of frame skipping */
3746 // vino_capture_failed(vcs);
3332 return -EIO; 3747 return -EIO;
3333 } 3748 }
3334 } 3749 }
@@ -3341,10 +3756,12 @@ static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs,
3341 } 3756 }
3342 3757
3343 err = vino_check_buffer(vcs, fb); 3758 err = vino_check_buffer(vcs, fb);
3759
3760 vino_v4l2_get_buffer_status(vcs, fb, b);
3761
3344 if (err) 3762 if (err)
3345 return -EIO; 3763 return -EIO;
3346 3764
3347 vino_v4l2_get_buffer_status(vcs, fb, b);
3348 break; 3765 break;
3349 } 3766 }
3350 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 3767 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
@@ -3401,8 +3818,8 @@ static int vino_v4l2_streamoff(struct vino_channel_settings *vcs)
3401 if (!vcs->streaming) 3818 if (!vcs->streaming)
3402 return 0; 3819 return 0;
3403 3820
3404 vino_capture_stop(vcs);
3405 vcs->streaming = 0; 3821 vcs->streaming = 0;
3822 vino_capture_stop(vcs);
3406 3823
3407 return 0; 3824 return 0;
3408} 3825}
@@ -3410,10 +3827,11 @@ static int vino_v4l2_streamoff(struct vino_channel_settings *vcs)
3410static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, 3827static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs,
3411 struct v4l2_queryctrl *queryctrl) 3828 struct v4l2_queryctrl *queryctrl)
3412{ 3829{
3830 unsigned long flags;
3413 int i; 3831 int i;
3414 int err = 0; 3832 int err = 0;
3415 3833
3416 spin_lock(&vino_drvdata->input_lock); 3834 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3417 3835
3418 switch (vcs->input) { 3836 switch (vcs->input) {
3419 case VINO_INPUT_D1: 3837 case VINO_INPUT_D1:
@@ -3423,6 +3841,7 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs,
3423 memcpy(queryctrl, 3841 memcpy(queryctrl,
3424 &vino_indycam_v4l2_controls[i], 3842 &vino_indycam_v4l2_controls[i],
3425 sizeof(struct v4l2_queryctrl)); 3843 sizeof(struct v4l2_queryctrl));
3844 queryctrl->reserved[0] = 0;
3426 goto found; 3845 goto found;
3427 } 3846 }
3428 } 3847 }
@@ -3437,6 +3856,7 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs,
3437 memcpy(queryctrl, 3856 memcpy(queryctrl,
3438 &vino_saa7191_v4l2_controls[i], 3857 &vino_saa7191_v4l2_controls[i],
3439 sizeof(struct v4l2_queryctrl)); 3858 sizeof(struct v4l2_queryctrl));
3859 queryctrl->reserved[0] = 0;
3440 goto found; 3860 goto found;
3441 } 3861 }
3442 } 3862 }
@@ -3448,7 +3868,7 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs,
3448 } 3868 }
3449 3869
3450 found: 3870 found:
3451 spin_unlock(&vino_drvdata->input_lock); 3871 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3452 3872
3453 return err; 3873 return err;
3454} 3874}
@@ -3456,70 +3876,72 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs,
3456static int vino_v4l2_g_ctrl(struct vino_channel_settings *vcs, 3876static int vino_v4l2_g_ctrl(struct vino_channel_settings *vcs,
3457 struct v4l2_control *control) 3877 struct v4l2_control *control)
3458{ 3878{
3459 struct indycam_control indycam_ctrl; 3879 unsigned long flags;
3460 struct saa7191_control saa7191_ctrl; 3880 int i;
3461 int err = 0; 3881 int err = 0;
3462 3882
3463 spin_lock(&vino_drvdata->input_lock); 3883 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3464 3884
3465 switch (vcs->input) { 3885 switch (vcs->input) {
3466 case VINO_INPUT_D1: 3886 case VINO_INPUT_D1: {
3467 i2c_camera_command(DECODER_INDYCAM_GET_CONTROLS, 3887 struct indycam_control indycam_ctrl;
3468 &indycam_ctrl);
3469 3888
3470 switch(control->id) { 3889 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) {
3471 case V4L2_CID_AUTOGAIN: 3890 if (vino_indycam_v4l2_controls[i].id ==
3472 control->value = indycam_ctrl.agc; 3891 control->id) {
3473 break; 3892 goto found1;
3474 case V4L2_CID_AUTO_WHITE_BALANCE: 3893 }
3475 control->value = indycam_ctrl.awb; 3894 }
3476 break; 3895
3477 case V4L2_CID_GAIN: 3896 err = -EINVAL;
3478 control->value = indycam_ctrl.gain; 3897 goto out;
3479 break; 3898
3480 case V4L2_CID_PRIVATE_BASE: 3899found1:
3481 control->value = indycam_ctrl.red_saturation; 3900 indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0];
3482 break; 3901
3483 case V4L2_CID_PRIVATE_BASE + 1: 3902 err = i2c_camera_command(DECODER_INDYCAM_GET_CONTROL,
3484 control->value = indycam_ctrl.blue_saturation; 3903 &indycam_ctrl);
3485 break; 3904 if (err) {
3486 case V4L2_CID_RED_BALANCE:
3487 control->value = indycam_ctrl.red_balance;
3488 break;
3489 case V4L2_CID_BLUE_BALANCE:
3490 control->value = indycam_ctrl.blue_balance;
3491 break;
3492 case V4L2_CID_EXPOSURE:
3493 control->value = indycam_ctrl.shutter;
3494 break;
3495 case V4L2_CID_GAMMA:
3496 control->value = indycam_ctrl.gamma;
3497 break;
3498 default:
3499 err = -EINVAL; 3905 err = -EINVAL;
3906 goto out;
3500 } 3907 }
3908
3909 control->value = indycam_ctrl.value;
3501 break; 3910 break;
3911 }
3502 case VINO_INPUT_COMPOSITE: 3912 case VINO_INPUT_COMPOSITE:
3503 case VINO_INPUT_SVIDEO: 3913 case VINO_INPUT_SVIDEO: {
3504 i2c_decoder_command(DECODER_SAA7191_GET_CONTROLS, 3914 struct saa7191_control saa7191_ctrl;
3505 &saa7191_ctrl);
3506 3915
3507 switch(control->id) { 3916 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) {
3508 case V4L2_CID_HUE: 3917 if (vino_saa7191_v4l2_controls[i].id ==
3509 control->value = saa7191_ctrl.hue; 3918 control->id) {
3510 break; 3919 goto found2;
3511 case V4L2_CID_PRIVATE_BASE: 3920 }
3512 control->value = saa7191_ctrl.vtrc; 3921 }
3513 break; 3922
3514 default: 3923 err = -EINVAL;
3924 goto out;
3925
3926found2:
3927 saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0];
3928
3929 err = i2c_decoder_command(DECODER_SAA7191_GET_CONTROL,
3930 &saa7191_ctrl);
3931 if (err) {
3515 err = -EINVAL; 3932 err = -EINVAL;
3933 goto out;
3516 } 3934 }
3935
3936 control->value = saa7191_ctrl.value;
3517 break; 3937 break;
3938 }
3518 default: 3939 default:
3519 err = -EINVAL; 3940 err = -EINVAL;
3520 } 3941 }
3521 3942
3522 spin_unlock(&vino_drvdata->input_lock); 3943out:
3944 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3523 3945
3524 return err; 3946 return err;
3525} 3947}
@@ -3527,15 +3949,21 @@ static int vino_v4l2_g_ctrl(struct vino_channel_settings *vcs,
3527static int vino_v4l2_s_ctrl(struct vino_channel_settings *vcs, 3949static int vino_v4l2_s_ctrl(struct vino_channel_settings *vcs,
3528 struct v4l2_control *control) 3950 struct v4l2_control *control)
3529{ 3951{
3530 struct indycam_control indycam_ctrl; 3952 unsigned long flags;
3531 struct saa7191_control saa7191_ctrl;
3532 int i; 3953 int i;
3533 int err = 0; 3954 int err = 0;
3534 3955
3535 spin_lock(&vino_drvdata->input_lock); 3956 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
3957
3958 if (!vino_is_input_owner(vcs)) {
3959 err = -EBUSY;
3960 goto out;
3961 }
3536 3962
3537 switch (vcs->input) { 3963 switch (vcs->input) {
3538 case VINO_INPUT_D1: 3964 case VINO_INPUT_D1: {
3965 struct indycam_control indycam_ctrl;
3966
3539 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { 3967 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) {
3540 if (vino_indycam_v4l2_controls[i].id == 3968 if (vino_indycam_v4l2_controls[i].id ==
3541 control->id) { 3969 control->id) {
@@ -3544,65 +3972,31 @@ static int vino_v4l2_s_ctrl(struct vino_channel_settings *vcs,
3544 && (control->value <= 3972 && (control->value <=
3545 vino_indycam_v4l2_controls[i]. 3973 vino_indycam_v4l2_controls[i].
3546 maximum)) { 3974 maximum)) {
3547 goto ok1; 3975 goto found1;
3548 } else { 3976 } else {
3549 err = -ERANGE; 3977 err = -ERANGE;
3550 goto error; 3978 goto out;
3551 } 3979 }
3552 } 3980 }
3553 } 3981 }
3982
3554 err = -EINVAL; 3983 err = -EINVAL;
3555 goto error; 3984 goto out;
3556 3985
3557ok1: 3986found1:
3558 indycam_ctrl.agc = INDYCAM_VALUE_UNCHANGED; 3987 indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0];
3559 indycam_ctrl.awb = INDYCAM_VALUE_UNCHANGED; 3988 indycam_ctrl.value = control->value;
3560 indycam_ctrl.shutter = INDYCAM_VALUE_UNCHANGED;
3561 indycam_ctrl.gain = INDYCAM_VALUE_UNCHANGED;
3562 indycam_ctrl.red_balance = INDYCAM_VALUE_UNCHANGED;
3563 indycam_ctrl.blue_balance = INDYCAM_VALUE_UNCHANGED;
3564 indycam_ctrl.red_saturation = INDYCAM_VALUE_UNCHANGED;
3565 indycam_ctrl.blue_saturation = INDYCAM_VALUE_UNCHANGED;
3566 indycam_ctrl.gamma = INDYCAM_VALUE_UNCHANGED;
3567
3568 switch(control->id) {
3569 case V4L2_CID_AUTOGAIN:
3570 indycam_ctrl.agc = control->value;
3571 break;
3572 case V4L2_CID_AUTO_WHITE_BALANCE:
3573 indycam_ctrl.awb = control->value;
3574 break;
3575 case V4L2_CID_GAIN:
3576 indycam_ctrl.gain = control->value;
3577 break;
3578 case V4L2_CID_PRIVATE_BASE:
3579 indycam_ctrl.red_saturation = control->value;
3580 break;
3581 case V4L2_CID_PRIVATE_BASE + 1:
3582 indycam_ctrl.blue_saturation = control->value;
3583 break;
3584 case V4L2_CID_RED_BALANCE:
3585 indycam_ctrl.red_balance = control->value;
3586 break;
3587 case V4L2_CID_BLUE_BALANCE:
3588 indycam_ctrl.blue_balance = control->value;
3589 break;
3590 case V4L2_CID_EXPOSURE:
3591 indycam_ctrl.shutter = control->value;
3592 break;
3593 case V4L2_CID_GAMMA:
3594 indycam_ctrl.gamma = control->value;
3595 break;
3596 default:
3597 err = -EINVAL;
3598 }
3599 3989
3600 if (!err) 3990 err = i2c_camera_command(DECODER_INDYCAM_SET_CONTROL,
3601 i2c_camera_command(DECODER_INDYCAM_SET_CONTROLS, 3991 &indycam_ctrl);
3602 &indycam_ctrl); 3992 if (err)
3993 err = -EINVAL;
3603 break; 3994 break;
3995 }
3604 case VINO_INPUT_COMPOSITE: 3996 case VINO_INPUT_COMPOSITE:
3605 case VINO_INPUT_SVIDEO: 3997 case VINO_INPUT_SVIDEO: {
3998 struct saa7191_control saa7191_ctrl;
3999
3606 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { 4000 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) {
3607 if (vino_saa7191_v4l2_controls[i].id == 4001 if (vino_saa7191_v4l2_controls[i].id ==
3608 control->id) { 4002 control->id) {
@@ -3611,41 +4005,32 @@ ok1:
3611 && (control->value <= 4005 && (control->value <=
3612 vino_saa7191_v4l2_controls[i]. 4006 vino_saa7191_v4l2_controls[i].
3613 maximum)) { 4007 maximum)) {
3614 goto ok2; 4008 goto found2;
3615 } else { 4009 } else {
3616 err = -ERANGE; 4010 err = -ERANGE;
3617 goto error; 4011 goto out;
3618 } 4012 }
3619 } 4013 }
3620 } 4014 }
3621 err = -EINVAL; 4015 err = -EINVAL;
3622 goto error; 4016 goto out;
3623
3624ok2:
3625 saa7191_ctrl.hue = SAA7191_VALUE_UNCHANGED;
3626 saa7191_ctrl.vtrc = SAA7191_VALUE_UNCHANGED;
3627 4017
3628 switch(control->id) { 4018found2:
3629 case V4L2_CID_HUE: 4019 saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0];
3630 saa7191_ctrl.hue = control->value; 4020 saa7191_ctrl.value = control->value;
3631 break;
3632 case V4L2_CID_PRIVATE_BASE:
3633 saa7191_ctrl.vtrc = control->value;
3634 break;
3635 default:
3636 err = -EINVAL;
3637 }
3638 4021
3639 if (!err) 4022 err = i2c_decoder_command(DECODER_SAA7191_SET_CONTROL,
3640 i2c_decoder_command(DECODER_SAA7191_SET_CONTROLS, 4023 &saa7191_ctrl);
3641 &saa7191_ctrl); 4024 if (err)
4025 err = -EINVAL;
3642 break; 4026 break;
4027 }
3643 default: 4028 default:
3644 err = -EINVAL; 4029 err = -EINVAL;
3645 } 4030 }
3646 4031
3647error: 4032out:
3648 spin_unlock(&vino_drvdata->input_lock); 4033 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3649 4034
3650 return err; 4035 return err;
3651} 4036}
@@ -3865,9 +4250,9 @@ static unsigned int vino_poll(struct file *file, poll_table *pt)
3865over: 4250over:
3866 dprintk("poll(): data %savailable\n", 4251 dprintk("poll(): data %savailable\n",
3867 (outgoing > 0) ? "" : "not "); 4252 (outgoing > 0) ? "" : "not ");
3868 if (outgoing > 0) { 4253
4254 if (outgoing > 0)
3869 ret = POLLIN | POLLRDNORM; 4255 ret = POLLIN | POLLRDNORM;
3870 }
3871 4256
3872error: 4257error:
3873 4258
@@ -3880,6 +4265,7 @@ static int vino_do_ioctl(struct inode *inode, struct file *file,
3880 struct video_device *dev = video_devdata(file); 4265 struct video_device *dev = video_devdata(file);
3881 struct vino_channel_settings *vcs = video_get_drvdata(dev); 4266 struct vino_channel_settings *vcs = video_get_drvdata(dev);
3882 4267
4268#ifdef VINO_DEBUG
3883 switch (_IOC_TYPE(cmd)) { 4269 switch (_IOC_TYPE(cmd)) {
3884 case 'v': 4270 case 'v':
3885 dprintk("ioctl(): V4L1 unsupported (0x%08x)\n", cmd); 4271 dprintk("ioctl(): V4L1 unsupported (0x%08x)\n", cmd);
@@ -3891,9 +4277,9 @@ static int vino_do_ioctl(struct inode *inode, struct file *file,
3891 default: 4277 default:
3892 dprintk("ioctl(): unsupported command 0x%08x\n", cmd); 4278 dprintk("ioctl(): unsupported command 0x%08x\n", cmd);
3893 } 4279 }
4280#endif
3894 4281
3895 switch (cmd) { 4282 switch (cmd) {
3896 /* TODO: V4L1 interface (use compatibility layer?) */
3897 /* V4L2 interface */ 4283 /* V4L2 interface */
3898 case VIDIOC_QUERYCAP: { 4284 case VIDIOC_QUERYCAP: {
3899 vino_v4l2_querycap(arg); 4285 vino_v4l2_querycap(arg);
@@ -3911,6 +4297,9 @@ static int vino_do_ioctl(struct inode *inode, struct file *file,
3911 case VIDIOC_ENUMSTD: { 4297 case VIDIOC_ENUMSTD: {
3912 return vino_v4l2_enumstd(vcs, arg); 4298 return vino_v4l2_enumstd(vcs, arg);
3913 } 4299 }
4300 case VIDIOC_QUERYSTD: {
4301 return vino_v4l2_querystd(vcs, arg);
4302 }
3914 case VIDIOC_G_STD: { 4303 case VIDIOC_G_STD: {
3915 return vino_v4l2_g_std(vcs, arg); 4304 return vino_v4l2_g_std(vcs, arg);
3916 } 4305 }
@@ -4100,8 +4489,7 @@ static int vino_probe(void)
4100 return -ENODEV; 4489 return -ENODEV;
4101 } 4490 }
4102 4491
4103 printk(KERN_INFO "VINO with chip ID %ld, revision %ld found\n", 4492 printk(KERN_INFO "VINO revision %ld found\n", VINO_REV_NUM(rev_id));
4104 VINO_ID_VALUE(rev_id), VINO_REV_NUM(rev_id));
4105 4493
4106 return 0; 4494 return 0;
4107} 4495}
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index eed2acea1779..39a0d238900e 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -1057,10 +1057,8 @@ zr36057_init (struct zoran *zr)
1057 KERN_ERR 1057 KERN_ERR
1058 "%s: zr36057_init() - kmalloc (STAT_COM) failed\n", 1058 "%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
1059 ZR_DEVNAME(zr)); 1059 ZR_DEVNAME(zr));
1060 if (vdev) 1060 kfree(vdev);
1061 kfree(vdev); 1061 kfree((void *)mem);
1062 if (mem)
1063 kfree((void *)mem);
1064 return -ENOMEM; 1062 return -ENOMEM;
1065 } 1063 }
1066 memset((void *) mem, 0, mem_needed); 1064 memset((void *) mem, 0, mem_needed);
@@ -1105,15 +1103,15 @@ zoran_release (struct zoran *zr)
1105 /* unregister videocodec bus */ 1103 /* unregister videocodec bus */
1106 if (zr->codec) { 1104 if (zr->codec) {
1107 struct videocodec_master *master = zr->codec->master_data; 1105 struct videocodec_master *master = zr->codec->master_data;
1106
1108 videocodec_detach(zr->codec); 1107 videocodec_detach(zr->codec);
1109 if (master) 1108 kfree(master);
1110 kfree(master);
1111 } 1109 }
1112 if (zr->vfe) { 1110 if (zr->vfe) {
1113 struct videocodec_master *master = zr->vfe->master_data; 1111 struct videocodec_master *master = zr->vfe->master_data;
1112
1114 videocodec_detach(zr->vfe); 1113 videocodec_detach(zr->vfe);
1115 if (master) 1114 kfree(master);
1116 kfree(master);
1117 } 1115 }
1118 1116
1119 /* unregister i2c bus */ 1117 /* unregister i2c bus */
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 53adeb70f2ca..07bde9acd672 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -996,8 +996,6 @@ zoran_jpg_queue_frame (struct file *file,
996 return -EINVAL; 996 return -EINVAL;
997 } 997 }
998 998
999 spin_lock_irqsave(&zr->spinlock, flags);
1000
1001 if (fh->jpg_buffers.active == ZORAN_FREE) { 999 if (fh->jpg_buffers.active == ZORAN_FREE) {
1002 if (zr->jpg_buffers.active == ZORAN_FREE) { 1000 if (zr->jpg_buffers.active == ZORAN_FREE) {
1003 zr->jpg_buffers = fh->jpg_buffers; 1001 zr->jpg_buffers = fh->jpg_buffers;
@@ -1016,6 +1014,8 @@ zoran_jpg_queue_frame (struct file *file,
1016 zr36057_enable_jpg(zr, mode); 1014 zr36057_enable_jpg(zr, mode);
1017 } 1015 }
1018 1016
1017 spin_lock_irqsave(&zr->spinlock, flags);
1018
1019 if (!res) { 1019 if (!res) {
1020 switch (zr->jpg_buffers.buffer[num].state) { 1020 switch (zr->jpg_buffers.buffer[num].state) {
1021 case BUZ_STATE_DONE: 1021 case BUZ_STATE_DONE:
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index ed3c891e388f..014085d8ec85 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -511,7 +511,7 @@ mpt_lan_close(struct net_device *dev)
511{ 511{
512 struct mpt_lan_priv *priv = netdev_priv(dev); 512 struct mpt_lan_priv *priv = netdev_priv(dev);
513 MPT_ADAPTER *mpt_dev = priv->mpt_dev; 513 MPT_ADAPTER *mpt_dev = priv->mpt_dev;
514 unsigned int timeout; 514 unsigned long timeout;
515 int i; 515 int i;
516 516
517 dlprintk((KERN_INFO MYNAM ": mpt_lan_close called\n")); 517 dlprintk((KERN_INFO MYNAM ": mpt_lan_close called\n"));
@@ -526,11 +526,9 @@ mpt_lan_close(struct net_device *dev)
526 526
527 mpt_lan_reset(dev); 527 mpt_lan_reset(dev);
528 528
529 timeout = 2 * HZ; 529 timeout = jiffies + 2 * HZ;
530 while (atomic_read(&priv->buckets_out) && --timeout) { 530 while (atomic_read(&priv->buckets_out) && time_before(jiffies, timeout))
531 set_current_state(TASK_INTERRUPTIBLE); 531 schedule_timeout_interruptible(1);
532 schedule_timeout(1);
533 }
534 532
535 for (i = 0; i < priv->max_buckets_out; i++) { 533 for (i = 0; i < priv->max_buckets_out; i++) {
536 if (priv->RcvCtl[i].skb != NULL) { 534 if (priv->RcvCtl[i].skb != NULL) {
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 5cb07eb224d7..4330ed0cedaa 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1013,10 +1013,8 @@ mptscsih_remove(struct pci_dev *pdev)
1013 spin_lock_irqsave(&dvtaskQ_lock, flags); 1013 spin_lock_irqsave(&dvtaskQ_lock, flags);
1014 if (dvtaskQ_active) { 1014 if (dvtaskQ_active) {
1015 spin_unlock_irqrestore(&dvtaskQ_lock, flags); 1015 spin_unlock_irqrestore(&dvtaskQ_lock, flags);
1016 while(dvtaskQ_active && --count) { 1016 while(dvtaskQ_active && --count)
1017 set_current_state(TASK_INTERRUPTIBLE); 1017 schedule_timeout_interruptible(1);
1018 schedule_timeout(1);
1019 }
1020 } else { 1018 } else {
1021 spin_unlock_irqrestore(&dvtaskQ_lock, flags); 1019 spin_unlock_irqrestore(&dvtaskQ_lock, flags);
1022 } 1020 }
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index b675b4ebbebd..9c339a2505b0 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -33,6 +33,7 @@
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/sched.h> /* wait_event_interruptible_timeout() needs this */
36#include <asm/param.h> /* HZ */ 37#include <asm/param.h> /* HZ */
37#include "core.h" 38#include "core.h"
38 39
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 61b837de4b6a..4eb53258842e 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -93,8 +93,7 @@ u32 i2o_msg_get_wait(struct i2o_controller *c,
93 c->name); 93 c->name);
94 return I2O_QUEUE_EMPTY; 94 return I2O_QUEUE_EMPTY;
95 } 95 }
96 set_current_state(TASK_UNINTERRUPTIBLE); 96 schedule_timeout_uninterruptible(1);
97 schedule_timeout(1);
98 } 97 }
99 98
100 return m; 99 return m;
@@ -485,8 +484,7 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
485 osm_warn("%s: Timeout Initializing\n", c->name); 484 osm_warn("%s: Timeout Initializing\n", c->name);
486 return -ETIMEDOUT; 485 return -ETIMEDOUT;
487 } 486 }
488 set_current_state(TASK_UNINTERRUPTIBLE); 487 schedule_timeout_uninterruptible(1);
489 schedule_timeout(1);
490 } 488 }
491 489
492 m = c->out_queue.phys; 490 m = c->out_queue.phys;
@@ -548,8 +546,7 @@ static int i2o_iop_reset(struct i2o_controller *c)
548 if (time_after(jiffies, timeout)) 546 if (time_after(jiffies, timeout))
549 break; 547 break;
550 548
551 set_current_state(TASK_UNINTERRUPTIBLE); 549 schedule_timeout_uninterruptible(1);
552 schedule_timeout(1);
553 } 550 }
554 551
555 switch (*status) { 552 switch (*status) {
@@ -577,8 +574,7 @@ static int i2o_iop_reset(struct i2o_controller *c)
577 rc = -ETIMEDOUT; 574 rc = -ETIMEDOUT;
578 goto exit; 575 goto exit;
579 } 576 }
580 set_current_state(TASK_UNINTERRUPTIBLE); 577 schedule_timeout_uninterruptible(1);
581 schedule_timeout(1);
582 578
583 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET); 579 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET);
584 } 580 }
@@ -989,8 +985,7 @@ int i2o_status_get(struct i2o_controller *c)
989 return -ETIMEDOUT; 985 return -ETIMEDOUT;
990 } 986 }
991 987
992 set_current_state(TASK_UNINTERRUPTIBLE); 988 schedule_timeout_uninterruptible(1);
993 schedule_timeout(1);
994 } 989 }
995 990
996#ifdef DEBUG 991#ifdef DEBUG
diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c
index c75d713c01e4..55ba23075c90 100644
--- a/drivers/mfd/mcp-core.c
+++ b/drivers/mfd/mcp-core.c
@@ -15,6 +15,8 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/smp.h> 16#include <linux/smp.h>
17#include <linux/device.h> 17#include <linux/device.h>
18#include <linux/slab.h>
19#include <linux/string.h>
18 20
19#include <asm/dma.h> 21#include <asm/dma.h>
20#include <asm/system.h> 22#include <asm/system.h>
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ceae379a4d4c..da528390acf8 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1263,7 +1263,7 @@ EXPORT_SYMBOL(mmc_suspend_host);
1263 */ 1263 */
1264int mmc_resume_host(struct mmc_host *host) 1264int mmc_resume_host(struct mmc_host *host)
1265{ 1265{
1266 mmc_detect_change(host, 0); 1266 mmc_rescan(host);
1267 1267
1268 return 0; 1268 return 0;
1269} 1269}
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index 4ff67e7363d9..e954b8354fef 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -1602,8 +1602,7 @@ static void __devexit wbsd_release_dma(struct wbsd_host* host)
1602 if (host->dma_addr) 1602 if (host->dma_addr)
1603 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE, 1603 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
1604 DMA_BIDIRECTIONAL); 1604 DMA_BIDIRECTIONAL);
1605 if (host->dma_buffer) 1605 kfree(host->dma_buffer);
1606 kfree(host->dma_buffer);
1607 if (host->dma >= 0) 1606 if (host->dma >= 0)
1608 free_dma(host->dma); 1607 free_dma(host->dma);
1609 1608
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 027054dea032..f6b775e63ac8 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1,4 +1,4 @@
1# $Id: Kconfig,v 1.7 2004/11/22 11:33:56 ijc Exp $ 1# $Id: Kconfig,v 1.11 2005/11/07 11:14:19 gleixner Exp $
2 2
3menu "Memory Technology Devices (MTD)" 3menu "Memory Technology Devices (MTD)"
4 4
@@ -10,7 +10,7 @@ config MTD
10 will provide the generic support for MTD drivers to register 10 will provide the generic support for MTD drivers to register
11 themselves with the kernel and for potential users of MTD devices 11 themselves with the kernel and for potential users of MTD devices
12 to enumerate the devices which are present and obtain a handle on 12 to enumerate the devices which are present and obtain a handle on
13 them. It will also allow you to select individual drivers for 13 them. It will also allow you to select individual drivers for
14 particular hardware and users of MTD devices. If unsure, say N. 14 particular hardware and users of MTD devices. If unsure, say N.
15 15
16config MTD_DEBUG 16config MTD_DEBUG
@@ -61,11 +61,11 @@ config MTD_REDBOOT_PARTS
61 61
62 If you need code which can detect and parse this table, and register 62 If you need code which can detect and parse this table, and register
63 MTD 'partitions' corresponding to each image in the table, enable 63 MTD 'partitions' corresponding to each image in the table, enable
64 this option. 64 this option.
65 65
66 You will still need the parsing functions to be called by the driver 66 You will still need the parsing functions to be called by the driver
67 for your particular device. It won't happen automatically. The 67 for your particular device. It won't happen automatically. The
68 SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for 68 SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
69 example. 69 example.
70 70
71config MTD_REDBOOT_DIRECTORY_BLOCK 71config MTD_REDBOOT_DIRECTORY_BLOCK
@@ -81,10 +81,10 @@ config MTD_REDBOOT_DIRECTORY_BLOCK
81 partition table. A zero or positive value gives an absolete 81 partition table. A zero or positive value gives an absolete
82 erase block number. A negative value specifies a number of 82 erase block number. A negative value specifies a number of
83 sectors before the end of the device. 83 sectors before the end of the device.
84 84
85 For example "2" means block number 2, "-1" means the last 85 For example "2" means block number 2, "-1" means the last
86 block and "-2" means the penultimate block. 86 block and "-2" means the penultimate block.
87 87
88config MTD_REDBOOT_PARTS_UNALLOCATED 88config MTD_REDBOOT_PARTS_UNALLOCATED
89 bool " Include unallocated flash regions" 89 bool " Include unallocated flash regions"
90 depends on MTD_REDBOOT_PARTS 90 depends on MTD_REDBOOT_PARTS
@@ -105,11 +105,11 @@ config MTD_CMDLINE_PARTS
105 ---help--- 105 ---help---
106 Allow generic configuration of the MTD paritition tables via the kernel 106 Allow generic configuration of the MTD paritition tables via the kernel
107 command line. Multiple flash resources are supported for hardware where 107 command line. Multiple flash resources are supported for hardware where
108 different kinds of flash memory are available. 108 different kinds of flash memory are available.
109 109
110 You will still need the parsing functions to be called by the driver 110 You will still need the parsing functions to be called by the driver
111 for your particular device. It won't happen automatically. The 111 for your particular device. It won't happen automatically. The
112 SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for 112 SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
113 example. 113 example.
114 114
115 The format for the command line is as follows: 115 The format for the command line is as follows:
@@ -118,12 +118,12 @@ config MTD_CMDLINE_PARTS
118 <mtddef> := <mtd-id>:<partdef>[,<partdef>] 118 <mtddef> := <mtd-id>:<partdef>[,<partdef>]
119 <partdef> := <size>[@offset][<name>][ro] 119 <partdef> := <size>[@offset][<name>][ro]
120 <mtd-id> := unique id used in mapping driver/device 120 <mtd-id> := unique id used in mapping driver/device
121 <size> := standard linux memsize OR "-" to denote all 121 <size> := standard linux memsize OR "-" to denote all
122 remaining space 122 remaining space
123 <name> := (NAME) 123 <name> := (NAME)
124 124
125 Due to the way Linux handles the command line, no spaces are 125 Due to the way Linux handles the command line, no spaces are
126 allowed in the partition definition, including mtd id's and partition 126 allowed in the partition definition, including mtd id's and partition
127 names. 127 names.
128 128
129 Examples: 129 Examples:
@@ -240,7 +240,7 @@ config INFTL
240 tristate "INFTL (Inverse NAND Flash Translation Layer) support" 240 tristate "INFTL (Inverse NAND Flash Translation Layer) support"
241 depends on MTD 241 depends on MTD
242 ---help--- 242 ---help---
243 This provides support for the Inverse NAND Flash Translation 243 This provides support for the Inverse NAND Flash Translation
244 Layer which is used on M-Systems' newer DiskOnChip devices. It 244 Layer which is used on M-Systems' newer DiskOnChip devices. It
245 uses a kind of pseudo-file system on a flash device to emulate 245 uses a kind of pseudo-file system on a flash device to emulate
246 a block device with 512-byte sectors, on top of which you put 246 a block device with 512-byte sectors, on top of which you put
@@ -253,6 +253,16 @@ config INFTL
253 permitted to copy, modify and distribute the code as you wish. Just 253 permitted to copy, modify and distribute the code as you wish. Just
254 not use it. 254 not use it.
255 255
256config RFD_FTL
257 tristate "Resident Flash Disk (Flash Translation Layer) support"
258 depends on MTD
259 ---help---
260 This provides support for the flash translation layer known
261 as the Resident Flash Disk (RFD), as used by the Embedded BIOS
262 of General Software. There is a blurb at:
263
264 http://www.gensw.com/pages/prod/bios/rfd.htm
265
256source "drivers/mtd/chips/Kconfig" 266source "drivers/mtd/chips/Kconfig"
257 267
258source "drivers/mtd/maps/Kconfig" 268source "drivers/mtd/maps/Kconfig"
@@ -261,5 +271,7 @@ source "drivers/mtd/devices/Kconfig"
261 271
262source "drivers/mtd/nand/Kconfig" 272source "drivers/mtd/nand/Kconfig"
263 273
274source "drivers/mtd/onenand/Kconfig"
275
264endmenu 276endmenu
265 277
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index e4ad588327f7..fc9374407c2b 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -1,7 +1,7 @@
1# 1#
2# Makefile for the memory technology device drivers. 2# Makefile for the memory technology device drivers.
3# 3#
4# $Id: Makefile.common,v 1.5 2004/08/10 20:51:49 dwmw2 Exp $ 4# $Id: Makefile.common,v 1.7 2005/07/11 10:39:27 gleixner Exp $
5 5
6# Core functionality. 6# Core functionality.
7mtd-y := mtdcore.o 7mtd-y := mtdcore.o
@@ -20,8 +20,9 @@ obj-$(CONFIG_MTD_BLOCK_RO) += mtdblock_ro.o mtd_blkdevs.o
20obj-$(CONFIG_FTL) += ftl.o mtd_blkdevs.o 20obj-$(CONFIG_FTL) += ftl.o mtd_blkdevs.o
21obj-$(CONFIG_NFTL) += nftl.o mtd_blkdevs.o 21obj-$(CONFIG_NFTL) += nftl.o mtd_blkdevs.o
22obj-$(CONFIG_INFTL) += inftl.o mtd_blkdevs.o 22obj-$(CONFIG_INFTL) += inftl.o mtd_blkdevs.o
23obj-$(CONFIG_RFD_FTL) += rfd_ftl.o mtd_blkdevs.o
23 24
24nftl-objs := nftlcore.o nftlmount.o 25nftl-objs := nftlcore.o nftlmount.o
25inftl-objs := inftlcore.o inftlmount.o 26inftl-objs := inftlcore.o inftlmount.o
26 27
27obj-y += chips/ maps/ devices/ nand/ 28obj-y += chips/ maps/ devices/ nand/ onenand/
diff --git a/drivers/mtd/afs.c b/drivers/mtd/afs.c
index 7363e101eb0f..6a45be04564b 100644
--- a/drivers/mtd/afs.c
+++ b/drivers/mtd/afs.c
@@ -1,27 +1,27 @@
1/*====================================================================== 1/*======================================================================
2 2
3 drivers/mtd/afs.c: ARM Flash Layout/Partitioning 3 drivers/mtd/afs.c: ARM Flash Layout/Partitioning
4 4
5 Copyright (C) 2000 ARM Limited 5 Copyright (C) 2000 ARM Limited
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 20
21 This is access code for flashes using ARM's flash partitioning 21 This is access code for flashes using ARM's flash partitioning
22 standards. 22 standards.
23 23
24 $Id: afs.c,v 1.13 2004/02/27 22:09:59 rmk Exp $ 24 $Id: afs.c,v 1.15 2005/11/07 11:14:19 gleixner Exp $
25 25
26======================================================================*/ 26======================================================================*/
27 27
@@ -163,7 +163,7 @@ afs_read_iis(struct mtd_info *mtd, struct image_info_struct *iis, u_int ptr)
163 return ret; 163 return ret;
164} 164}
165 165
166static int parse_afs_partitions(struct mtd_info *mtd, 166static int parse_afs_partitions(struct mtd_info *mtd,
167 struct mtd_partition **pparts, 167 struct mtd_partition **pparts,
168 unsigned long origin) 168 unsigned long origin)
169{ 169{
diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
index df95d2158b16..eafa23f5cbd6 100644
--- a/drivers/mtd/chips/Kconfig
+++ b/drivers/mtd/chips/Kconfig
@@ -1,5 +1,5 @@
1# drivers/mtd/chips/Kconfig 1# drivers/mtd/chips/Kconfig
2# $Id: Kconfig,v 1.15 2005/06/06 23:04:35 tpoynor Exp $ 2# $Id: Kconfig,v 1.18 2005/11/07 11:14:22 gleixner Exp $
3 3
4menu "RAM/ROM/Flash chip drivers" 4menu "RAM/ROM/Flash chip drivers"
5 depends on MTD!=n 5 depends on MTD!=n
@@ -39,7 +39,7 @@ config MTD_CFI_ADV_OPTIONS
39 If you need to specify a specific endianness for access to flash 39 If you need to specify a specific endianness for access to flash
40 chips, or if you wish to reduce the size of the kernel by including 40 chips, or if you wish to reduce the size of the kernel by including
41 support for only specific arrangements of flash chips, say 'Y'. This 41 support for only specific arrangements of flash chips, say 'Y'. This
42 option does not directly affect the code, but will enable other 42 option does not directly affect the code, but will enable other
43 configuration options which allow you to do so. 43 configuration options which allow you to do so.
44 44
45 If unsure, say 'N'. 45 If unsure, say 'N'.
@@ -56,7 +56,7 @@ config MTD_CFI_NOSWAP
56 data bits when writing the 'magic' commands to the chips. Saying 56 data bits when writing the 'magic' commands to the chips. Saying
57 'NO', which is the default when CONFIG_MTD_CFI_ADV_OPTIONS isn't 57 'NO', which is the default when CONFIG_MTD_CFI_ADV_OPTIONS isn't
58 enabled, means that the CPU will not do any swapping; the chips 58 enabled, means that the CPU will not do any swapping; the chips
59 are expected to be wired to the CPU in 'host-endian' form. 59 are expected to be wired to the CPU in 'host-endian' form.
60 Specific arrangements are possible with the BIG_ENDIAN_BYTE and 60 Specific arrangements are possible with the BIG_ENDIAN_BYTE and
61 LITTLE_ENDIAN_BYTE, if the bytes are reversed. 61 LITTLE_ENDIAN_BYTE, if the bytes are reversed.
62 62
@@ -79,10 +79,10 @@ config MTD_CFI_GEOMETRY
79 bool "Specific CFI Flash geometry selection" 79 bool "Specific CFI Flash geometry selection"
80 depends on MTD_CFI_ADV_OPTIONS 80 depends on MTD_CFI_ADV_OPTIONS
81 help 81 help
82 This option does not affect the code directly, but will enable 82 This option does not affect the code directly, but will enable
83 some other configuration options which would allow you to reduce 83 some other configuration options which would allow you to reduce
84 the size of the kernel by including support for only certain 84 the size of the kernel by including support for only certain
85 arrangements of CFI chips. If unsure, say 'N' and all options 85 arrangements of CFI chips. If unsure, say 'N' and all options
86 which are supported by the current code will be enabled. 86 which are supported by the current code will be enabled.
87 87
88config MTD_MAP_BANK_WIDTH_1 88config MTD_MAP_BANK_WIDTH_1
@@ -197,7 +197,7 @@ config MTD_CFI_AMDSTD
197 help 197 help
198 The Common Flash Interface defines a number of different command 198 The Common Flash Interface defines a number of different command
199 sets which a CFI-compliant chip may claim to implement. This code 199 sets which a CFI-compliant chip may claim to implement. This code
200 provides support for one of those command sets, used on chips 200 provides support for one of those command sets, used on chips
201 including the AMD Am29LV320. 201 including the AMD Am29LV320.
202 202
203config MTD_CFI_AMDSTD_RETRY 203config MTD_CFI_AMDSTD_RETRY
@@ -237,14 +237,14 @@ config MTD_RAM
237 tristate "Support for RAM chips in bus mapping" 237 tristate "Support for RAM chips in bus mapping"
238 depends on MTD 238 depends on MTD
239 help 239 help
240 This option enables basic support for RAM chips accessed through 240 This option enables basic support for RAM chips accessed through
241 a bus mapping driver. 241 a bus mapping driver.
242 242
243config MTD_ROM 243config MTD_ROM
244 tristate "Support for ROM chips in bus mapping" 244 tristate "Support for ROM chips in bus mapping"
245 depends on MTD 245 depends on MTD
246 help 246 help
247 This option enables basic support for ROM chips accessed through 247 This option enables basic support for ROM chips accessed through
248 a bus mapping driver. 248 a bus mapping driver.
249 249
250config MTD_ABSENT 250config MTD_ABSENT
@@ -275,7 +275,7 @@ config MTD_AMDSTD
275 depends on MTD && MTD_OBSOLETE_CHIPS 275 depends on MTD && MTD_OBSOLETE_CHIPS
276 help 276 help
277 This option enables support for flash chips using AMD-compatible 277 This option enables support for flash chips using AMD-compatible
278 commands, including some which are not CFI-compatible and hence 278 commands, including some which are not CFI-compatible and hence
279 cannot be used with the CONFIG_MTD_CFI_AMDSTD option. 279 cannot be used with the CONFIG_MTD_CFI_AMDSTD option.
280 280
281 It also works on AMD compatible chips that do conform to CFI. 281 It also works on AMD compatible chips that do conform to CFI.
@@ -285,7 +285,7 @@ config MTD_SHARP
285 depends on MTD && MTD_OBSOLETE_CHIPS 285 depends on MTD && MTD_OBSOLETE_CHIPS
286 help 286 help
287 This option enables support for flash chips using Sharp-compatible 287 This option enables support for flash chips using Sharp-compatible
288 commands, including some which are not CFI-compatible and hence 288 commands, including some which are not CFI-compatible and hence
289 cannot be used with the CONFIG_MTD_CFI_INTELxxx options. 289 cannot be used with the CONFIG_MTD_CFI_INTELxxx options.
290 290
291config MTD_JEDEC 291config MTD_JEDEC
diff --git a/drivers/mtd/chips/Makefile b/drivers/mtd/chips/Makefile
index 6830489828c6..8afe3092c4e3 100644
--- a/drivers/mtd/chips/Makefile
+++ b/drivers/mtd/chips/Makefile
@@ -1,7 +1,7 @@
1# 1#
2# linux/drivers/chips/Makefile 2# linux/drivers/chips/Makefile
3# 3#
4# $Id: Makefile.common,v 1.4 2004/07/12 16:07:30 dwmw2 Exp $ 4# $Id: Makefile.common,v 1.5 2005/11/07 11:14:22 gleixner Exp $
5 5
6# *** BIG UGLY NOTE *** 6# *** BIG UGLY NOTE ***
7# 7#
@@ -11,7 +11,7 @@
11# the CFI command set drivers are linked before gen_probe.o 11# the CFI command set drivers are linked before gen_probe.o
12 12
13obj-$(CONFIG_MTD) += chipreg.o 13obj-$(CONFIG_MTD) += chipreg.o
14obj-$(CONFIG_MTD_AMDSTD) += amd_flash.o 14obj-$(CONFIG_MTD_AMDSTD) += amd_flash.o
15obj-$(CONFIG_MTD_CFI) += cfi_probe.o 15obj-$(CONFIG_MTD_CFI) += cfi_probe.o
16obj-$(CONFIG_MTD_CFI_UTIL) += cfi_util.o 16obj-$(CONFIG_MTD_CFI_UTIL) += cfi_util.o
17obj-$(CONFIG_MTD_CFI_STAA) += cfi_cmdset_0020.o 17obj-$(CONFIG_MTD_CFI_STAA) += cfi_cmdset_0020.o
diff --git a/drivers/mtd/chips/amd_flash.c b/drivers/mtd/chips/amd_flash.c
index 2dafeba3f3d5..fdb91b6f1d97 100644
--- a/drivers/mtd/chips/amd_flash.c
+++ b/drivers/mtd/chips/amd_flash.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Author: Jonas Holmberg <jonas.holmberg@axis.com> 4 * Author: Jonas Holmberg <jonas.holmberg@axis.com>
5 * 5 *
6 * $Id: amd_flash.c,v 1.27 2005/02/04 07:43:09 jonashg Exp $ 6 * $Id: amd_flash.c,v 1.28 2005/11/07 11:14:22 gleixner Exp $
7 * 7 *
8 * Copyright (c) 2001 Axis Communications AB 8 * Copyright (c) 2001 Axis Communications AB
9 * 9 *
@@ -93,9 +93,9 @@
93#define D6_MASK 0x40 93#define D6_MASK 0x40
94 94
95struct amd_flash_private { 95struct amd_flash_private {
96 int device_type; 96 int device_type;
97 int interleave; 97 int interleave;
98 int numchips; 98 int numchips;
99 unsigned long chipshift; 99 unsigned long chipshift;
100// const char *im_name; 100// const char *im_name;
101 struct flchip chips[0]; 101 struct flchip chips[0];
@@ -253,7 +253,7 @@ static int amd_flash_do_unlock(struct mtd_info *mtd, loff_t ofs, size_t len,
253 int i; 253 int i;
254 int retval = 0; 254 int retval = 0;
255 int lock_status; 255 int lock_status;
256 256
257 map = mtd->priv; 257 map = mtd->priv;
258 258
259 /* Pass the whole chip through sector by sector and check for each 259 /* Pass the whole chip through sector by sector and check for each
@@ -273,7 +273,7 @@ static int amd_flash_do_unlock(struct mtd_info *mtd, loff_t ofs, size_t len,
273 unlock_sector(map, eraseoffset, is_unlock); 273 unlock_sector(map, eraseoffset, is_unlock);
274 274
275 lock_status = is_sector_locked(map, eraseoffset); 275 lock_status = is_sector_locked(map, eraseoffset);
276 276
277 if (is_unlock && lock_status) { 277 if (is_unlock && lock_status) {
278 printk("Cannot unlock sector at address %x length %xx\n", 278 printk("Cannot unlock sector at address %x length %xx\n",
279 eraseoffset, merip->erasesize); 279 eraseoffset, merip->erasesize);
@@ -305,7 +305,7 @@ static int amd_flash_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
305/* 305/*
306 * Reads JEDEC manufacturer ID and device ID and returns the index of the first 306 * Reads JEDEC manufacturer ID and device ID and returns the index of the first
307 * matching table entry (-1 if not found or alias for already found chip). 307 * matching table entry (-1 if not found or alias for already found chip).
308 */ 308 */
309static int probe_new_chip(struct mtd_info *mtd, __u32 base, 309static int probe_new_chip(struct mtd_info *mtd, __u32 base,
310 struct flchip *chips, 310 struct flchip *chips,
311 struct amd_flash_private *private, 311 struct amd_flash_private *private,
@@ -636,7 +636,7 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
636 { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, 636 { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 },
637 { .offset = 0x1F0000, .erasesize = 0x02000, .numblocks = 8 } 637 { .offset = 0x1F0000, .erasesize = 0x02000, .numblocks = 8 }
638 } 638 }
639 } 639 }
640 }; 640 };
641 641
642 struct mtd_info *mtd; 642 struct mtd_info *mtd;
@@ -701,7 +701,7 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
701 701
702 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * 702 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) *
703 mtd->numeraseregions, GFP_KERNEL); 703 mtd->numeraseregions, GFP_KERNEL);
704 if (!mtd->eraseregions) { 704 if (!mtd->eraseregions) {
705 printk(KERN_WARNING "%s: Failed to allocate " 705 printk(KERN_WARNING "%s: Failed to allocate "
706 "memory for MTD erase region info\n", map->name); 706 "memory for MTD erase region info\n", map->name);
707 kfree(mtd); 707 kfree(mtd);
@@ -739,12 +739,12 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
739 mtd->type = MTD_NORFLASH; 739 mtd->type = MTD_NORFLASH;
740 mtd->flags = MTD_CAP_NORFLASH; 740 mtd->flags = MTD_CAP_NORFLASH;
741 mtd->name = map->name; 741 mtd->name = map->name;
742 mtd->erase = amd_flash_erase; 742 mtd->erase = amd_flash_erase;
743 mtd->read = amd_flash_read; 743 mtd->read = amd_flash_read;
744 mtd->write = amd_flash_write; 744 mtd->write = amd_flash_write;
745 mtd->sync = amd_flash_sync; 745 mtd->sync = amd_flash_sync;
746 mtd->suspend = amd_flash_suspend; 746 mtd->suspend = amd_flash_suspend;
747 mtd->resume = amd_flash_resume; 747 mtd->resume = amd_flash_resume;
748 mtd->lock = amd_flash_lock; 748 mtd->lock = amd_flash_lock;
749 mtd->unlock = amd_flash_unlock; 749 mtd->unlock = amd_flash_unlock;
750 750
@@ -789,7 +789,7 @@ retry:
789 map->name, chip->state); 789 map->name, chip->state);
790 set_current_state(TASK_UNINTERRUPTIBLE); 790 set_current_state(TASK_UNINTERRUPTIBLE);
791 add_wait_queue(&chip->wq, &wait); 791 add_wait_queue(&chip->wq, &wait);
792 792
793 spin_unlock_bh(chip->mutex); 793 spin_unlock_bh(chip->mutex);
794 794
795 schedule(); 795 schedule();
@@ -802,7 +802,7 @@ retry:
802 timeo = jiffies + HZ; 802 timeo = jiffies + HZ;
803 803
804 goto retry; 804 goto retry;
805 } 805 }
806 806
807 adr += chip->start; 807 adr += chip->start;
808 808
@@ -889,7 +889,7 @@ retry:
889 map->name, chip->state); 889 map->name, chip->state);
890 set_current_state(TASK_UNINTERRUPTIBLE); 890 set_current_state(TASK_UNINTERRUPTIBLE);
891 add_wait_queue(&chip->wq, &wait); 891 add_wait_queue(&chip->wq, &wait);
892 892
893 spin_unlock_bh(chip->mutex); 893 spin_unlock_bh(chip->mutex);
894 894
895 schedule(); 895 schedule();
@@ -901,7 +901,7 @@ retry:
901 timeo = jiffies + HZ; 901 timeo = jiffies + HZ;
902 902
903 goto retry; 903 goto retry;
904 } 904 }
905 905
906 chip->state = FL_WRITING; 906 chip->state = FL_WRITING;
907 907
@@ -911,7 +911,7 @@ retry:
911 wide_write(map, datum, adr); 911 wide_write(map, datum, adr);
912 912
913 times_left = 500000; 913 times_left = 500000;
914 while (times_left-- && flash_is_busy(map, adr, private->interleave)) { 914 while (times_left-- && flash_is_busy(map, adr, private->interleave)) {
915 if (need_resched()) { 915 if (need_resched()) {
916 spin_unlock_bh(chip->mutex); 916 spin_unlock_bh(chip->mutex);
917 schedule(); 917 schedule();
@@ -989,7 +989,7 @@ static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len,
989 if (ret) { 989 if (ret) {
990 return ret; 990 return ret;
991 } 991 }
992 992
993 ofs += n; 993 ofs += n;
994 buf += n; 994 buf += n;
995 (*retlen) += n; 995 (*retlen) += n;
@@ -1002,7 +1002,7 @@ static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len,
1002 } 1002 }
1003 } 1003 }
1004 } 1004 }
1005 1005
1006 /* We are now aligned, write as much as possible. */ 1006 /* We are now aligned, write as much as possible. */
1007 while(len >= map->buswidth) { 1007 while(len >= map->buswidth) {
1008 __u32 datum; 1008 __u32 datum;
@@ -1063,7 +1063,7 @@ static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len,
1063 if (ret) { 1063 if (ret) {
1064 return ret; 1064 return ret;
1065 } 1065 }
1066 1066
1067 (*retlen) += n; 1067 (*retlen) += n;
1068 } 1068 }
1069 1069
@@ -1085,7 +1085,7 @@ retry:
1085 if (chip->state != FL_READY){ 1085 if (chip->state != FL_READY){
1086 set_current_state(TASK_UNINTERRUPTIBLE); 1086 set_current_state(TASK_UNINTERRUPTIBLE);
1087 add_wait_queue(&chip->wq, &wait); 1087 add_wait_queue(&chip->wq, &wait);
1088 1088
1089 spin_unlock_bh(chip->mutex); 1089 spin_unlock_bh(chip->mutex);
1090 1090
1091 schedule(); 1091 schedule();
@@ -1098,7 +1098,7 @@ retry:
1098 timeo = jiffies + HZ; 1098 timeo = jiffies + HZ;
1099 1099
1100 goto retry; 1100 goto retry;
1101 } 1101 }
1102 1102
1103 chip->state = FL_ERASING; 1103 chip->state = FL_ERASING;
1104 1104
@@ -1106,30 +1106,30 @@ retry:
1106 ENABLE_VPP(map); 1106 ENABLE_VPP(map);
1107 send_cmd(map, chip->start, CMD_SECTOR_ERASE_UNLOCK_DATA); 1107 send_cmd(map, chip->start, CMD_SECTOR_ERASE_UNLOCK_DATA);
1108 send_cmd_to_addr(map, chip->start, CMD_SECTOR_ERASE_UNLOCK_DATA_2, adr); 1108 send_cmd_to_addr(map, chip->start, CMD_SECTOR_ERASE_UNLOCK_DATA_2, adr);
1109 1109
1110 timeo = jiffies + (HZ * 20); 1110 timeo = jiffies + (HZ * 20);
1111 1111
1112 spin_unlock_bh(chip->mutex); 1112 spin_unlock_bh(chip->mutex);
1113 msleep(1000); 1113 msleep(1000);
1114 spin_lock_bh(chip->mutex); 1114 spin_lock_bh(chip->mutex);
1115 1115
1116 while (flash_is_busy(map, adr, private->interleave)) { 1116 while (flash_is_busy(map, adr, private->interleave)) {
1117 1117
1118 if (chip->state != FL_ERASING) { 1118 if (chip->state != FL_ERASING) {
1119 /* Someone's suspended the erase. Sleep */ 1119 /* Someone's suspended the erase. Sleep */
1120 set_current_state(TASK_UNINTERRUPTIBLE); 1120 set_current_state(TASK_UNINTERRUPTIBLE);
1121 add_wait_queue(&chip->wq, &wait); 1121 add_wait_queue(&chip->wq, &wait);
1122 1122
1123 spin_unlock_bh(chip->mutex); 1123 spin_unlock_bh(chip->mutex);
1124 printk(KERN_INFO "%s: erase suspended. Sleeping\n", 1124 printk(KERN_INFO "%s: erase suspended. Sleeping\n",
1125 map->name); 1125 map->name);
1126 schedule(); 1126 schedule();
1127 remove_wait_queue(&chip->wq, &wait); 1127 remove_wait_queue(&chip->wq, &wait);
1128 1128
1129 if (signal_pending(current)) { 1129 if (signal_pending(current)) {
1130 return -EINTR; 1130 return -EINTR;
1131 } 1131 }
1132 1132
1133 timeo = jiffies + (HZ*2); /* FIXME */ 1133 timeo = jiffies + (HZ*2); /* FIXME */
1134 spin_lock_bh(chip->mutex); 1134 spin_lock_bh(chip->mutex);
1135 continue; 1135 continue;
@@ -1145,7 +1145,7 @@ retry:
1145 1145
1146 return -EIO; 1146 return -EIO;
1147 } 1147 }
1148 1148
1149 /* Latency issues. Drop the lock, wait a while and retry */ 1149 /* Latency issues. Drop the lock, wait a while and retry */
1150 spin_unlock_bh(chip->mutex); 1150 spin_unlock_bh(chip->mutex);
1151 1151
@@ -1153,7 +1153,7 @@ retry:
1153 schedule(); 1153 schedule();
1154 else 1154 else
1155 udelay(1); 1155 udelay(1);
1156 1156
1157 spin_lock_bh(chip->mutex); 1157 spin_lock_bh(chip->mutex);
1158 } 1158 }
1159 1159
@@ -1180,7 +1180,7 @@ retry:
1180 return -EIO; 1180 return -EIO;
1181 } 1181 }
1182 } 1182 }
1183 1183
1184 DISABLE_VPP(map); 1184 DISABLE_VPP(map);
1185 chip->state = FL_READY; 1185 chip->state = FL_READY;
1186 wake_up(&chip->wq); 1186 wake_up(&chip->wq);
@@ -1246,7 +1246,7 @@ static int amd_flash_erase(struct mtd_info *mtd, struct erase_info *instr)
1246 * with the erase region at that address. 1246 * with the erase region at that address.
1247 */ 1247 */
1248 1248
1249 while ((i < mtd->numeraseregions) && 1249 while ((i < mtd->numeraseregions) &&
1250 ((instr->addr + instr->len) >= regions[i].offset)) { 1250 ((instr->addr + instr->len) >= regions[i].offset)) {
1251 i++; 1251 i++;
1252 } 1252 }
@@ -1293,10 +1293,10 @@ static int amd_flash_erase(struct mtd_info *mtd, struct erase_info *instr)
1293 } 1293 }
1294 } 1294 }
1295 } 1295 }
1296 1296
1297 instr->state = MTD_ERASE_DONE; 1297 instr->state = MTD_ERASE_DONE;
1298 mtd_erase_callback(instr); 1298 mtd_erase_callback(instr);
1299 1299
1300 return 0; 1300 return 0;
1301} 1301}
1302 1302
@@ -1324,7 +1324,7 @@ static void amd_flash_sync(struct mtd_info *mtd)
1324 case FL_JEDEC_QUERY: 1324 case FL_JEDEC_QUERY:
1325 chip->oldstate = chip->state; 1325 chip->oldstate = chip->state;
1326 chip->state = FL_SYNCING; 1326 chip->state = FL_SYNCING;
1327 /* No need to wake_up() on this state change - 1327 /* No need to wake_up() on this state change -
1328 * as the whole point is that nobody can do anything 1328 * as the whole point is that nobody can do anything
1329 * with the chip now anyway. 1329 * with the chip now anyway.
1330 */ 1330 */
@@ -1335,13 +1335,13 @@ static void amd_flash_sync(struct mtd_info *mtd)
1335 default: 1335 default:
1336 /* Not an idle state */ 1336 /* Not an idle state */
1337 add_wait_queue(&chip->wq, &wait); 1337 add_wait_queue(&chip->wq, &wait);
1338 1338
1339 spin_unlock_bh(chip->mutex); 1339 spin_unlock_bh(chip->mutex);
1340 1340
1341 schedule(); 1341 schedule();
1342 1342
1343 remove_wait_queue(&chip->wq, &wait); 1343 remove_wait_queue(&chip->wq, &wait);
1344 1344
1345 goto retry; 1345 goto retry;
1346 } 1346 }
1347 } 1347 }
@@ -1351,7 +1351,7 @@ static void amd_flash_sync(struct mtd_info *mtd)
1351 chip = &private->chips[i]; 1351 chip = &private->chips[i];
1352 1352
1353 spin_lock_bh(chip->mutex); 1353 spin_lock_bh(chip->mutex);
1354 1354
1355 if (chip->state == FL_SYNCING) { 1355 if (chip->state == FL_SYNCING) {
1356 chip->state = chip->oldstate; 1356 chip->state = chip->oldstate;
1357 wake_up(&chip->wq); 1357 wake_up(&chip->wq);
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 0cfcd88468e0..143f01a4c170 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -4,9 +4,9 @@
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.178 2005/05/19 17:05:43 nico Exp $ 7 * $Id: cfi_cmdset_0001.c,v 1.185 2005/11/07 11:14:22 gleixner Exp $
8 *
8 * 9 *
9 *
10 * 10/10/2000 Nicolas Pitre <nico@cam.org> 10 * 10/10/2000 Nicolas Pitre <nico@cam.org>
11 * - completely revamped method functions so they are aware and 11 * - completely revamped method functions so they are aware and
12 * independent of the flash geometry (buswidth, interleave, etc.) 12 * independent of the flash geometry (buswidth, interleave, etc.)
@@ -51,6 +51,7 @@
51static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 51static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
52static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 52static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
53static int cfi_intelext_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 53static int cfi_intelext_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
54static int cfi_intelext_writev(struct mtd_info *, const struct kvec *, unsigned long, loff_t, size_t *);
54static int cfi_intelext_erase_varsize(struct mtd_info *, struct erase_info *); 55static int cfi_intelext_erase_varsize(struct mtd_info *, struct erase_info *);
55static void cfi_intelext_sync (struct mtd_info *); 56static void cfi_intelext_sync (struct mtd_info *);
56static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len); 57static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len);
@@ -105,6 +106,7 @@ static struct mtd_chip_driver cfi_intelext_chipdrv = {
105static void cfi_tell_features(struct cfi_pri_intelext *extp) 106static void cfi_tell_features(struct cfi_pri_intelext *extp)
106{ 107{
107 int i; 108 int i;
109 printk(" Extended Query version %c.%c\n", extp->MajorVersion, extp->MinorVersion);
108 printk(" Feature/Command Support: %4.4X\n", extp->FeatureSupport); 110 printk(" Feature/Command Support: %4.4X\n", extp->FeatureSupport);
109 printk(" - Chip Erase: %s\n", extp->FeatureSupport&1?"supported":"unsupported"); 111 printk(" - Chip Erase: %s\n", extp->FeatureSupport&1?"supported":"unsupported");
110 printk(" - Suspend Erase: %s\n", extp->FeatureSupport&2?"supported":"unsupported"); 112 printk(" - Suspend Erase: %s\n", extp->FeatureSupport&2?"supported":"unsupported");
@@ -116,36 +118,43 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
116 printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported"); 118 printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported");
117 printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported"); 119 printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported");
118 printk(" - Simultaneous operations: %s\n", extp->FeatureSupport&512?"supported":"unsupported"); 120 printk(" - Simultaneous operations: %s\n", extp->FeatureSupport&512?"supported":"unsupported");
119 for (i=10; i<32; i++) { 121 printk(" - Extended Flash Array: %s\n", extp->FeatureSupport&1024?"supported":"unsupported");
120 if (extp->FeatureSupport & (1<<i)) 122 for (i=11; i<32; i++) {
123 if (extp->FeatureSupport & (1<<i))
121 printk(" - Unknown Bit %X: supported\n", i); 124 printk(" - Unknown Bit %X: supported\n", i);
122 } 125 }
123 126
124 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport); 127 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport);
125 printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported"); 128 printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported");
126 for (i=1; i<8; i++) { 129 for (i=1; i<8; i++) {
127 if (extp->SuspendCmdSupport & (1<<i)) 130 if (extp->SuspendCmdSupport & (1<<i))
128 printk(" - Unknown Bit %X: supported\n", i); 131 printk(" - Unknown Bit %X: supported\n", i);
129 } 132 }
130 133
131 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask); 134 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask);
132 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no"); 135 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no");
133 printk(" - Valid Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no"); 136 printk(" - Lock-Down Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no");
134 for (i=2; i<16; i++) { 137 for (i=2; i<3; i++) {
135 if (extp->BlkStatusRegMask & (1<<i)) 138 if (extp->BlkStatusRegMask & (1<<i))
136 printk(" - Unknown Bit %X Active: yes\n",i); 139 printk(" - Unknown Bit %X Active: yes\n",i);
137 } 140 }
138 141 printk(" - EFA Lock Bit: %s\n", extp->BlkStatusRegMask&16?"yes":"no");
139 printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n", 142 printk(" - EFA Lock-Down Bit: %s\n", extp->BlkStatusRegMask&32?"yes":"no");
143 for (i=6; i<16; i++) {
144 if (extp->BlkStatusRegMask & (1<<i))
145 printk(" - Unknown Bit %X Active: yes\n",i);
146 }
147
148 printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n",
140 extp->VccOptimal >> 4, extp->VccOptimal & 0xf); 149 extp->VccOptimal >> 4, extp->VccOptimal & 0xf);
141 if (extp->VppOptimal) 150 if (extp->VppOptimal)
142 printk(" Vpp Programming Supply Optimum Program/Erase Voltage: %d.%d V\n", 151 printk(" Vpp Programming Supply Optimum Program/Erase Voltage: %d.%d V\n",
143 extp->VppOptimal >> 4, extp->VppOptimal & 0xf); 152 extp->VppOptimal >> 4, extp->VppOptimal & 0xf);
144} 153}
145#endif 154#endif
146 155
147#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE 156#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
148/* Some Intel Strata Flash prior to FPO revision C has bugs in this area */ 157/* Some Intel Strata Flash prior to FPO revision C has bugs in this area */
149static void fixup_intel_strataflash(struct mtd_info *mtd, void* param) 158static void fixup_intel_strataflash(struct mtd_info *mtd, void* param)
150{ 159{
151 struct map_info *map = mtd->priv; 160 struct map_info *map = mtd->priv;
@@ -176,7 +185,7 @@ static void fixup_st_m28w320ct(struct mtd_info *mtd, void* param)
176{ 185{
177 struct map_info *map = mtd->priv; 186 struct map_info *map = mtd->priv;
178 struct cfi_private *cfi = map->fldrv_priv; 187 struct cfi_private *cfi = map->fldrv_priv;
179 188
180 cfi->cfiq->BufWriteTimeoutTyp = 0; /* Not supported */ 189 cfi->cfiq->BufWriteTimeoutTyp = 0; /* Not supported */
181 cfi->cfiq->BufWriteTimeoutMax = 0; /* Not supported */ 190 cfi->cfiq->BufWriteTimeoutMax = 0; /* Not supported */
182} 191}
@@ -185,7 +194,7 @@ static void fixup_st_m28w320cb(struct mtd_info *mtd, void* param)
185{ 194{
186 struct map_info *map = mtd->priv; 195 struct map_info *map = mtd->priv;
187 struct cfi_private *cfi = map->fldrv_priv; 196 struct cfi_private *cfi = map->fldrv_priv;
188 197
189 /* Note this is done after the region info is endian swapped */ 198 /* Note this is done after the region info is endian swapped */
190 cfi->cfiq->EraseRegionInfo[1] = 199 cfi->cfiq->EraseRegionInfo[1] =
191 (cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e; 200 (cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e;
@@ -207,12 +216,13 @@ static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
207 if (cfi->cfiq->BufWriteTimeoutTyp) { 216 if (cfi->cfiq->BufWriteTimeoutTyp) {
208 printk(KERN_INFO "Using buffer write method\n" ); 217 printk(KERN_INFO "Using buffer write method\n" );
209 mtd->write = cfi_intelext_write_buffers; 218 mtd->write = cfi_intelext_write_buffers;
219 mtd->writev = cfi_intelext_writev;
210 } 220 }
211} 221}
212 222
213static struct cfi_fixup cfi_fixup_table[] = { 223static struct cfi_fixup cfi_fixup_table[] = {
214#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE 224#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
215 { CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL }, 225 { CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL },
216#endif 226#endif
217#ifdef CMDSET0001_DISABLE_WRITE_SUSPEND 227#ifdef CMDSET0001_DISABLE_WRITE_SUSPEND
218 { CFI_MFR_ANY, CFI_ID_ANY, fixup_no_write_suspend, NULL }, 228 { CFI_MFR_ANY, CFI_ID_ANY, fixup_no_write_suspend, NULL },
@@ -252,12 +262,21 @@ read_pri_intelext(struct map_info *map, __u16 adr)
252 if (!extp) 262 if (!extp)
253 return NULL; 263 return NULL;
254 264
265 if (extp->MajorVersion != '1' ||
266 (extp->MinorVersion < '0' || extp->MinorVersion > '4')) {
267 printk(KERN_ERR " Unknown Intel/Sharp Extended Query "
268 "version %c.%c.\n", extp->MajorVersion,
269 extp->MinorVersion);
270 kfree(extp);
271 return NULL;
272 }
273
255 /* Do some byteswapping if necessary */ 274 /* Do some byteswapping if necessary */
256 extp->FeatureSupport = le32_to_cpu(extp->FeatureSupport); 275 extp->FeatureSupport = le32_to_cpu(extp->FeatureSupport);
257 extp->BlkStatusRegMask = le16_to_cpu(extp->BlkStatusRegMask); 276 extp->BlkStatusRegMask = le16_to_cpu(extp->BlkStatusRegMask);
258 extp->ProtRegAddr = le16_to_cpu(extp->ProtRegAddr); 277 extp->ProtRegAddr = le16_to_cpu(extp->ProtRegAddr);
259 278
260 if (extp->MajorVersion == '1' && extp->MinorVersion == '3') { 279 if (extp->MajorVersion == '1' && extp->MinorVersion >= '3') {
261 unsigned int extra_size = 0; 280 unsigned int extra_size = 0;
262 int nb_parts, i; 281 int nb_parts, i;
263 282
@@ -266,7 +285,10 @@ read_pri_intelext(struct map_info *map, __u16 adr)
266 sizeof(struct cfi_intelext_otpinfo); 285 sizeof(struct cfi_intelext_otpinfo);
267 286
268 /* Burst Read info */ 287 /* Burst Read info */
269 extra_size += 6; 288 extra_size += 2;
289 if (extp_size < sizeof(*extp) + extra_size)
290 goto need_more;
291 extra_size += extp->extra[extra_size-1];
270 292
271 /* Number of hardware-partitions */ 293 /* Number of hardware-partitions */
272 extra_size += 1; 294 extra_size += 1;
@@ -274,6 +296,10 @@ read_pri_intelext(struct map_info *map, __u16 adr)
274 goto need_more; 296 goto need_more;
275 nb_parts = extp->extra[extra_size - 1]; 297 nb_parts = extp->extra[extra_size - 1];
276 298
299 /* skip the sizeof(partregion) field in CFI 1.4 */
300 if (extp->MinorVersion >= '4')
301 extra_size += 2;
302
277 for (i = 0; i < nb_parts; i++) { 303 for (i = 0; i < nb_parts; i++) {
278 struct cfi_intelext_regioninfo *rinfo; 304 struct cfi_intelext_regioninfo *rinfo;
279 rinfo = (struct cfi_intelext_regioninfo *)&extp->extra[extra_size]; 305 rinfo = (struct cfi_intelext_regioninfo *)&extp->extra[extra_size];
@@ -285,6 +311,9 @@ read_pri_intelext(struct map_info *map, __u16 adr)
285 * sizeof(struct cfi_intelext_blockinfo); 311 * sizeof(struct cfi_intelext_blockinfo);
286 } 312 }
287 313
314 if (extp->MinorVersion >= '4')
315 extra_size += sizeof(struct cfi_intelext_programming_regioninfo);
316
288 if (extp_size < sizeof(*extp) + extra_size) { 317 if (extp_size < sizeof(*extp) + extra_size) {
289 need_more: 318 need_more:
290 extp_size = sizeof(*extp) + extra_size; 319 extp_size = sizeof(*extp) + extra_size;
@@ -298,7 +327,7 @@ read_pri_intelext(struct map_info *map, __u16 adr)
298 goto again; 327 goto again;
299 } 328 }
300 } 329 }
301 330
302 return extp; 331 return extp;
303} 332}
304 333
@@ -339,7 +368,7 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
339 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot; 368 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
340 369
341 if (cfi->cfi_mode == CFI_MODE_CFI) { 370 if (cfi->cfi_mode == CFI_MODE_CFI) {
342 /* 371 /*
343 * It's a real CFI chip, not one for which the probe 372 * It's a real CFI chip, not one for which the probe
344 * routine faked a CFI structure. So we read the feature 373 * routine faked a CFI structure. So we read the feature
345 * table from it. 374 * table from it.
@@ -354,14 +383,14 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
354 } 383 }
355 384
356 /* Install our own private info structure */ 385 /* Install our own private info structure */
357 cfi->cmdset_priv = extp; 386 cfi->cmdset_priv = extp;
358 387
359 cfi_fixup(mtd, cfi_fixup_table); 388 cfi_fixup(mtd, cfi_fixup_table);
360 389
361#ifdef DEBUG_CFI_FEATURES 390#ifdef DEBUG_CFI_FEATURES
362 /* Tell the user about it in lots of lovely detail */ 391 /* Tell the user about it in lots of lovely detail */
363 cfi_tell_features(extp); 392 cfi_tell_features(extp);
364#endif 393#endif
365 394
366 if(extp->SuspendCmdSupport & 1) { 395 if(extp->SuspendCmdSupport & 1) {
367 printk(KERN_NOTICE "cfi_cmdset_0001: Erase suspend on write enabled\n"); 396 printk(KERN_NOTICE "cfi_cmdset_0001: Erase suspend on write enabled\n");
@@ -379,10 +408,10 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
379 cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; 408 cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
380 cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp; 409 cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp;
381 cfi->chips[i].ref_point_counter = 0; 410 cfi->chips[i].ref_point_counter = 0;
382 } 411 }
383 412
384 map->fldrv = &cfi_intelext_chipdrv; 413 map->fldrv = &cfi_intelext_chipdrv;
385 414
386 return cfi_intelext_setup(mtd); 415 return cfi_intelext_setup(mtd);
387} 416}
388 417
@@ -399,13 +428,13 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
399 mtd->size = devsize * cfi->numchips; 428 mtd->size = devsize * cfi->numchips;
400 429
401 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; 430 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
402 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) 431 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
403 * mtd->numeraseregions, GFP_KERNEL); 432 * mtd->numeraseregions, GFP_KERNEL);
404 if (!mtd->eraseregions) { 433 if (!mtd->eraseregions) {
405 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n"); 434 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n");
406 goto setup_err; 435 goto setup_err;
407 } 436 }
408 437
409 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { 438 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
410 unsigned long ernum, ersize; 439 unsigned long ernum, ersize;
411 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; 440 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
@@ -429,7 +458,7 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
429 } 458 }
430 459
431 for (i=0; i<mtd->numeraseregions;i++){ 460 for (i=0; i<mtd->numeraseregions;i++){
432 printk(KERN_DEBUG "%d: offset=0x%x,size=0x%x,blocks=%d\n", 461 printk(KERN_DEBUG "erase region %d: offset=0x%x,size=0x%x,blocks=%d\n",
433 i,mtd->eraseregions[i].offset, 462 i,mtd->eraseregions[i].offset,
434 mtd->eraseregions[i].erasesize, 463 mtd->eraseregions[i].erasesize,
435 mtd->eraseregions[i].numblocks); 464 mtd->eraseregions[i].numblocks);
@@ -455,8 +484,7 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
455 484
456 setup_err: 485 setup_err:
457 if(mtd) { 486 if(mtd) {
458 if(mtd->eraseregions) 487 kfree(mtd->eraseregions);
459 kfree(mtd->eraseregions);
460 kfree(mtd); 488 kfree(mtd);
461 } 489 }
462 kfree(cfi->cmdset_priv); 490 kfree(cfi->cmdset_priv);
@@ -481,7 +509,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
481 * arrangement at this point. This can be rearranged in the future 509 * arrangement at this point. This can be rearranged in the future
482 * if someone feels motivated enough. --nico 510 * if someone feels motivated enough. --nico
483 */ 511 */
484 if (extp && extp->MajorVersion == '1' && extp->MinorVersion == '3' 512 if (extp && extp->MajorVersion == '1' && extp->MinorVersion >= '3'
485 && extp->FeatureSupport & (1 << 9)) { 513 && extp->FeatureSupport & (1 << 9)) {
486 struct cfi_private *newcfi; 514 struct cfi_private *newcfi;
487 struct flchip *chip; 515 struct flchip *chip;
@@ -493,12 +521,16 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
493 sizeof(struct cfi_intelext_otpinfo); 521 sizeof(struct cfi_intelext_otpinfo);
494 522
495 /* Burst Read info */ 523 /* Burst Read info */
496 offs += 6; 524 offs += extp->extra[offs+1]+2;
497 525
498 /* Number of partition regions */ 526 /* Number of partition regions */
499 numregions = extp->extra[offs]; 527 numregions = extp->extra[offs];
500 offs += 1; 528 offs += 1;
501 529
530 /* skip the sizeof(partregion) field in CFI 1.4 */
531 if (extp->MinorVersion >= '4')
532 offs += 2;
533
502 /* Number of hardware partitions */ 534 /* Number of hardware partitions */
503 numparts = 0; 535 numparts = 0;
504 for (i = 0; i < numregions; i++) { 536 for (i = 0; i < numregions; i++) {
@@ -510,6 +542,20 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
510 sizeof(struct cfi_intelext_blockinfo); 542 sizeof(struct cfi_intelext_blockinfo);
511 } 543 }
512 544
545 /* Programming Region info */
546 if (extp->MinorVersion >= '4') {
547 struct cfi_intelext_programming_regioninfo *prinfo;
548 prinfo = (struct cfi_intelext_programming_regioninfo *)&extp->extra[offs];
549 MTD_PROGREGION_SIZE(mtd) = cfi->interleave << prinfo->ProgRegShift;
550 MTD_PROGREGION_CTRLMODE_VALID(mtd) = cfi->interleave * prinfo->ControlValid;
551 MTD_PROGREGION_CTRLMODE_INVALID(mtd) = cfi->interleave * prinfo->ControlInvalid;
552 mtd->flags |= MTD_PROGRAM_REGIONS;
553 printk(KERN_DEBUG "%s: program region size/ctrl_valid/ctrl_inval = %d/%d/%d\n",
554 map->name, MTD_PROGREGION_SIZE(mtd),
555 MTD_PROGREGION_CTRLMODE_VALID(mtd),
556 MTD_PROGREGION_CTRLMODE_INVALID(mtd));
557 }
558
513 /* 559 /*
514 * All functions below currently rely on all chips having 560 * All functions below currently rely on all chips having
515 * the same geometry so we'll just assume that all hardware 561 * the same geometry so we'll just assume that all hardware
@@ -654,8 +700,8 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
654 break; 700 break;
655 701
656 if (time_after(jiffies, timeo)) { 702 if (time_after(jiffies, timeo)) {
657 printk(KERN_ERR "Waiting for chip to be ready timed out. Status %lx\n", 703 printk(KERN_ERR "%s: Waiting for chip to be ready timed out. Status %lx\n",
658 status.x[0]); 704 map->name, status.x[0]);
659 return -EIO; 705 return -EIO;
660 } 706 }
661 spin_unlock(chip->mutex); 707 spin_unlock(chip->mutex);
@@ -664,7 +710,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
664 /* Someone else might have been playing with it. */ 710 /* Someone else might have been playing with it. */
665 goto retry; 711 goto retry;
666 } 712 }
667 713
668 case FL_READY: 714 case FL_READY:
669 case FL_CFI_QUERY: 715 case FL_CFI_QUERY:
670 case FL_JEDEC_QUERY: 716 case FL_JEDEC_QUERY:
@@ -702,8 +748,8 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
702 map_write(map, CMD(0x70), adr); 748 map_write(map, CMD(0x70), adr);
703 chip->state = FL_ERASING; 749 chip->state = FL_ERASING;
704 chip->oldstate = FL_READY; 750 chip->oldstate = FL_READY;
705 printk(KERN_ERR "Chip not ready after erase " 751 printk(KERN_ERR "%s: Chip not ready after erase "
706 "suspended: status = 0x%lx\n", status.x[0]); 752 "suspended: status = 0x%lx\n", map->name, status.x[0]);
707 return -EIO; 753 return -EIO;
708 } 754 }
709 755
@@ -783,14 +829,14 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
783 switch(chip->oldstate) { 829 switch(chip->oldstate) {
784 case FL_ERASING: 830 case FL_ERASING:
785 chip->state = chip->oldstate; 831 chip->state = chip->oldstate;
786 /* What if one interleaved chip has finished and the 832 /* What if one interleaved chip has finished and the
787 other hasn't? The old code would leave the finished 833 other hasn't? The old code would leave the finished
788 one in READY mode. That's bad, and caused -EROFS 834 one in READY mode. That's bad, and caused -EROFS
789 errors to be returned from do_erase_oneblock because 835 errors to be returned from do_erase_oneblock because
790 that's the only bit it checked for at the time. 836 that's the only bit it checked for at the time.
791 As the state machine appears to explicitly allow 837 As the state machine appears to explicitly allow
792 sending the 0x70 (Read Status) command to an erasing 838 sending the 0x70 (Read Status) command to an erasing
793 chip and expecting it to be ignored, that's what we 839 chip and expecting it to be ignored, that's what we
794 do. */ 840 do. */
795 map_write(map, CMD(0xd0), adr); 841 map_write(map, CMD(0xd0), adr);
796 map_write(map, CMD(0x70), adr); 842 map_write(map, CMD(0x70), adr);
@@ -810,7 +856,7 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
810 DISABLE_VPP(map); 856 DISABLE_VPP(map);
811 break; 857 break;
812 default: 858 default:
813 printk(KERN_ERR "put_chip() called with oldstate %d!!\n", chip->oldstate); 859 printk(KERN_ERR "%s: put_chip() called with oldstate %d!!\n", map->name, chip->oldstate);
814 } 860 }
815 wake_up(&chip->wq); 861 wake_up(&chip->wq);
816} 862}
@@ -1026,8 +1072,8 @@ static int do_point_onechip (struct map_info *map, struct flchip *chip, loff_t a
1026 1072
1027 adr += chip->start; 1073 adr += chip->start;
1028 1074
1029 /* Ensure cmd read/writes are aligned. */ 1075 /* Ensure cmd read/writes are aligned. */
1030 cmd_addr = adr & ~(map_bankwidth(map)-1); 1076 cmd_addr = adr & ~(map_bankwidth(map)-1);
1031 1077
1032 spin_lock(chip->mutex); 1078 spin_lock(chip->mutex);
1033 1079
@@ -1055,7 +1101,7 @@ static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, si
1055 1101
1056 if (!map->virt || (from + len > mtd->size)) 1102 if (!map->virt || (from + len > mtd->size))
1057 return -EINVAL; 1103 return -EINVAL;
1058 1104
1059 *mtdbuf = (void *)map->virt + from; 1105 *mtdbuf = (void *)map->virt + from;
1060 *retlen = 0; 1106 *retlen = 0;
1061 1107
@@ -1082,7 +1128,7 @@ static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, si
1082 1128
1083 *retlen += thislen; 1129 *retlen += thislen;
1084 len -= thislen; 1130 len -= thislen;
1085 1131
1086 ofs = 0; 1132 ofs = 0;
1087 chipnum++; 1133 chipnum++;
1088 } 1134 }
@@ -1121,7 +1167,7 @@ static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t fro
1121 if(chip->ref_point_counter == 0) 1167 if(chip->ref_point_counter == 0)
1122 chip->state = FL_READY; 1168 chip->state = FL_READY;
1123 } else 1169 } else
1124 printk(KERN_ERR "Warning: unpoint called on non pointed region\n"); /* Should this give an error? */ 1170 printk(KERN_ERR "%s: Warning: unpoint called on non pointed region\n", map->name); /* Should this give an error? */
1125 1171
1126 put_chip(map, chip, chip->start); 1172 put_chip(map, chip, chip->start);
1127 spin_unlock(chip->mutex); 1173 spin_unlock(chip->mutex);
@@ -1140,8 +1186,8 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
1140 1186
1141 adr += chip->start; 1187 adr += chip->start;
1142 1188
1143 /* Ensure cmd read/writes are aligned. */ 1189 /* Ensure cmd read/writes are aligned. */
1144 cmd_addr = adr & ~(map_bankwidth(map)-1); 1190 cmd_addr = adr & ~(map_bankwidth(map)-1);
1145 1191
1146 spin_lock(chip->mutex); 1192 spin_lock(chip->mutex);
1147 ret = get_chip(map, chip, cmd_addr, FL_READY); 1193 ret = get_chip(map, chip, cmd_addr, FL_READY);
@@ -1196,7 +1242,7 @@ static int cfi_intelext_read (struct mtd_info *mtd, loff_t from, size_t len, siz
1196 *retlen += thislen; 1242 *retlen += thislen;
1197 len -= thislen; 1243 len -= thislen;
1198 buf += thislen; 1244 buf += thislen;
1199 1245
1200 ofs = 0; 1246 ofs = 0;
1201 chipnum++; 1247 chipnum++;
1202 } 1248 }
@@ -1213,12 +1259,17 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1213 1259
1214 adr += chip->start; 1260 adr += chip->start;
1215 1261
1216 /* Let's determine this according to the interleave only once */ 1262 /* Let's determine those according to the interleave only once */
1217 status_OK = CMD(0x80); 1263 status_OK = CMD(0x80);
1218 switch (mode) { 1264 switch (mode) {
1219 case FL_WRITING: write_cmd = CMD(0x40); break; 1265 case FL_WRITING:
1220 case FL_OTP_WRITE: write_cmd = CMD(0xc0); break; 1266 write_cmd = (cfi->cfiq->P_ID != 0x0200) ? CMD(0x40) : CMD(0x41);
1221 default: return -EINVAL; 1267 break;
1268 case FL_OTP_WRITE:
1269 write_cmd = CMD(0xc0);
1270 break;
1271 default:
1272 return -EINVAL;
1222 } 1273 }
1223 1274
1224 spin_lock(chip->mutex); 1275 spin_lock(chip->mutex);
@@ -1259,12 +1310,13 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1259 status = map_read(map, adr); 1310 status = map_read(map, adr);
1260 if (map_word_andequal(map, status, status_OK, status_OK)) 1311 if (map_word_andequal(map, status, status_OK, status_OK))
1261 break; 1312 break;
1262 1313
1263 /* OK Still waiting */ 1314 /* OK Still waiting */
1264 if (time_after(jiffies, timeo)) { 1315 if (time_after(jiffies, timeo)) {
1316 map_write(map, CMD(0x70), adr);
1265 chip->state = FL_STATUS; 1317 chip->state = FL_STATUS;
1266 xip_enable(map, chip, adr); 1318 xip_enable(map, chip, adr);
1267 printk(KERN_ERR "waiting for chip to be ready timed out in word write\n"); 1319 printk(KERN_ERR "%s: word write error (status timeout)\n", map->name);
1268 ret = -EIO; 1320 ret = -EIO;
1269 goto out; 1321 goto out;
1270 } 1322 }
@@ -1276,27 +1328,39 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1276 if (!z) { 1328 if (!z) {
1277 chip->word_write_time--; 1329 chip->word_write_time--;
1278 if (!chip->word_write_time) 1330 if (!chip->word_write_time)
1279 chip->word_write_time++; 1331 chip->word_write_time = 1;
1280 } 1332 }
1281 if (z > 1) 1333 if (z > 1)
1282 chip->word_write_time++; 1334 chip->word_write_time++;
1283 1335
1284 /* Done and happy. */ 1336 /* Done and happy. */
1285 chip->state = FL_STATUS; 1337 chip->state = FL_STATUS;
1286 1338
1287 /* check for lock bit */ 1339 /* check for errors */
1288 if (map_word_bitsset(map, status, CMD(0x02))) { 1340 if (map_word_bitsset(map, status, CMD(0x1a))) {
1289 /* clear status */ 1341 unsigned long chipstatus = MERGESTATUS(status);
1342
1343 /* reset status */
1290 map_write(map, CMD(0x50), adr); 1344 map_write(map, CMD(0x50), adr);
1291 /* put back into read status register mode */
1292 map_write(map, CMD(0x70), adr); 1345 map_write(map, CMD(0x70), adr);
1293 ret = -EROFS; 1346 xip_enable(map, chip, adr);
1347
1348 if (chipstatus & 0x02) {
1349 ret = -EROFS;
1350 } else if (chipstatus & 0x08) {
1351 printk(KERN_ERR "%s: word write error (bad VPP)\n", map->name);
1352 ret = -EIO;
1353 } else {
1354 printk(KERN_ERR "%s: word write error (status 0x%lx)\n", map->name, chipstatus);
1355 ret = -EINVAL;
1356 }
1357
1358 goto out;
1294 } 1359 }
1295 1360
1296 xip_enable(map, chip, adr); 1361 xip_enable(map, chip, adr);
1297 out: put_chip(map, chip, adr); 1362 out: put_chip(map, chip, adr);
1298 spin_unlock(chip->mutex); 1363 spin_unlock(chip->mutex);
1299
1300 return ret; 1364 return ret;
1301} 1365}
1302 1366
@@ -1329,7 +1393,7 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1329 1393
1330 ret = do_write_oneword(map, &cfi->chips[chipnum], 1394 ret = do_write_oneword(map, &cfi->chips[chipnum],
1331 bus_ofs, datum, FL_WRITING); 1395 bus_ofs, datum, FL_WRITING);
1332 if (ret) 1396 if (ret)
1333 return ret; 1397 return ret;
1334 1398
1335 len -= n; 1399 len -= n;
@@ -1338,13 +1402,13 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1338 (*retlen) += n; 1402 (*retlen) += n;
1339 1403
1340 if (ofs >> cfi->chipshift) { 1404 if (ofs >> cfi->chipshift) {
1341 chipnum ++; 1405 chipnum ++;
1342 ofs = 0; 1406 ofs = 0;
1343 if (chipnum == cfi->numchips) 1407 if (chipnum == cfi->numchips)
1344 return 0; 1408 return 0;
1345 } 1409 }
1346 } 1410 }
1347 1411
1348 while(len >= map_bankwidth(map)) { 1412 while(len >= map_bankwidth(map)) {
1349 map_word datum = map_word_load(map, buf); 1413 map_word datum = map_word_load(map, buf);
1350 1414
@@ -1359,7 +1423,7 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1359 len -= map_bankwidth(map); 1423 len -= map_bankwidth(map);
1360 1424
1361 if (ofs >> cfi->chipshift) { 1425 if (ofs >> cfi->chipshift) {
1362 chipnum ++; 1426 chipnum ++;
1363 ofs = 0; 1427 ofs = 0;
1364 if (chipnum == cfi->numchips) 1428 if (chipnum == cfi->numchips)
1365 return 0; 1429 return 0;
@@ -1374,9 +1438,9 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1374 1438
1375 ret = do_write_oneword(map, &cfi->chips[chipnum], 1439 ret = do_write_oneword(map, &cfi->chips[chipnum],
1376 ofs, datum, FL_WRITING); 1440 ofs, datum, FL_WRITING);
1377 if (ret) 1441 if (ret)
1378 return ret; 1442 return ret;
1379 1443
1380 (*retlen) += len; 1444 (*retlen) += len;
1381 } 1445 }
1382 1446
@@ -1384,20 +1448,24 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1384} 1448}
1385 1449
1386 1450
1387static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, 1451static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1388 unsigned long adr, const u_char *buf, int len) 1452 unsigned long adr, const struct kvec **pvec,
1453 unsigned long *pvec_seek, int len)
1389{ 1454{
1390 struct cfi_private *cfi = map->fldrv_priv; 1455 struct cfi_private *cfi = map->fldrv_priv;
1391 map_word status, status_OK; 1456 map_word status, status_OK, write_cmd, datum;
1392 unsigned long cmd_adr, timeo; 1457 unsigned long cmd_adr, timeo;
1393 int wbufsize, z, ret=0, bytes, words; 1458 int wbufsize, z, ret=0, word_gap, words;
1459 const struct kvec *vec;
1460 unsigned long vec_seek;
1394 1461
1395 wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; 1462 wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
1396 adr += chip->start; 1463 adr += chip->start;
1397 cmd_adr = adr & ~(wbufsize-1); 1464 cmd_adr = adr & ~(wbufsize-1);
1398 1465
1399 /* Let's determine this according to the interleave only once */ 1466 /* Let's determine this according to the interleave only once */
1400 status_OK = CMD(0x80); 1467 status_OK = CMD(0x80);
1468 write_cmd = (cfi->cfiq->P_ID != 0x0200) ? CMD(0xe8) : CMD(0xe9);
1401 1469
1402 spin_lock(chip->mutex); 1470 spin_lock(chip->mutex);
1403 ret = get_chip(map, chip, cmd_adr, FL_WRITING); 1471 ret = get_chip(map, chip, cmd_adr, FL_WRITING);
@@ -1411,7 +1479,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1411 xip_disable(map, chip, cmd_adr); 1479 xip_disable(map, chip, cmd_adr);
1412 1480
1413 /* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set 1481 /* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set
1414 [...], the device will not accept any more Write to Buffer commands". 1482 [...], the device will not accept any more Write to Buffer commands".
1415 So we must check here and reset those bits if they're set. Otherwise 1483 So we must check here and reset those bits if they're set. Otherwise
1416 we're just pissing in the wind */ 1484 we're just pissing in the wind */
1417 if (chip->state != FL_STATUS) 1485 if (chip->state != FL_STATUS)
@@ -1429,7 +1497,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1429 1497
1430 z = 0; 1498 z = 0;
1431 for (;;) { 1499 for (;;) {
1432 map_write(map, CMD(0xe8), cmd_adr); 1500 map_write(map, write_cmd, cmd_adr);
1433 1501
1434 status = map_read(map, cmd_adr); 1502 status = map_read(map, cmd_adr);
1435 if (map_word_andequal(map, status, status_OK, status_OK)) 1503 if (map_word_andequal(map, status, status_OK, status_OK))
@@ -1447,41 +1515,66 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1447 map_write(map, CMD(0x50), cmd_adr); 1515 map_write(map, CMD(0x50), cmd_adr);
1448 map_write(map, CMD(0x70), cmd_adr); 1516 map_write(map, CMD(0x70), cmd_adr);
1449 xip_enable(map, chip, cmd_adr); 1517 xip_enable(map, chip, cmd_adr);
1450 printk(KERN_ERR "Chip not ready for buffer write. status = %lx, Xstatus = %lx\n", 1518 printk(KERN_ERR "%s: Chip not ready for buffer write. status = %lx, Xstatus = %lx\n",
1451 status.x[0], Xstatus.x[0]); 1519 map->name, status.x[0], Xstatus.x[0]);
1452 ret = -EIO; 1520 ret = -EIO;
1453 goto out; 1521 goto out;
1454 } 1522 }
1455 } 1523 }
1456 1524
1525 /* Figure out the number of words to write */
1526 word_gap = (-adr & (map_bankwidth(map)-1));
1527 words = (len - word_gap + map_bankwidth(map) - 1) / map_bankwidth(map);
1528 if (!word_gap) {
1529 words--;
1530 } else {
1531 word_gap = map_bankwidth(map) - word_gap;
1532 adr -= word_gap;
1533 datum = map_word_ff(map);
1534 }
1535
1457 /* Write length of data to come */ 1536 /* Write length of data to come */
1458 bytes = len & (map_bankwidth(map)-1); 1537 map_write(map, CMD(words), cmd_adr );
1459 words = len / map_bankwidth(map);
1460 map_write(map, CMD(words - !bytes), cmd_adr );
1461 1538
1462 /* Write data */ 1539 /* Write data */
1463 z = 0; 1540 vec = *pvec;
1464 while(z < words * map_bankwidth(map)) { 1541 vec_seek = *pvec_seek;
1465 map_word datum = map_word_load(map, buf); 1542 do {
1466 map_write(map, datum, adr+z); 1543 int n = map_bankwidth(map) - word_gap;
1544 if (n > vec->iov_len - vec_seek)
1545 n = vec->iov_len - vec_seek;
1546 if (n > len)
1547 n = len;
1467 1548
1468 z += map_bankwidth(map); 1549 if (!word_gap && len < map_bankwidth(map))
1469 buf += map_bankwidth(map); 1550 datum = map_word_ff(map);
1470 }
1471 1551
1472 if (bytes) { 1552 datum = map_word_load_partial(map, datum,
1473 map_word datum; 1553 vec->iov_base + vec_seek,
1554 word_gap, n);
1474 1555
1475 datum = map_word_ff(map); 1556 len -= n;
1476 datum = map_word_load_partial(map, datum, buf, 0, bytes); 1557 word_gap += n;
1477 map_write(map, datum, adr+z); 1558 if (!len || word_gap == map_bankwidth(map)) {
1478 } 1559 map_write(map, datum, adr);
1560 adr += map_bankwidth(map);
1561 word_gap = 0;
1562 }
1563
1564 vec_seek += n;
1565 if (vec_seek == vec->iov_len) {
1566 vec++;
1567 vec_seek = 0;
1568 }
1569 } while (len);
1570 *pvec = vec;
1571 *pvec_seek = vec_seek;
1479 1572
1480 /* GO GO GO */ 1573 /* GO GO GO */
1481 map_write(map, CMD(0xd0), cmd_adr); 1574 map_write(map, CMD(0xd0), cmd_adr);
1482 chip->state = FL_WRITING; 1575 chip->state = FL_WRITING;
1483 1576
1484 INVALIDATE_CACHE_UDELAY(map, chip, 1577 INVALIDATE_CACHE_UDELAY(map, chip,
1485 cmd_adr, len, 1578 cmd_adr, len,
1486 chip->buffer_write_time); 1579 chip->buffer_write_time);
1487 1580
@@ -1507,13 +1600,14 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1507 1600
1508 /* OK Still waiting */ 1601 /* OK Still waiting */
1509 if (time_after(jiffies, timeo)) { 1602 if (time_after(jiffies, timeo)) {
1603 map_write(map, CMD(0x70), cmd_adr);
1510 chip->state = FL_STATUS; 1604 chip->state = FL_STATUS;
1511 xip_enable(map, chip, cmd_adr); 1605 xip_enable(map, chip, cmd_adr);
1512 printk(KERN_ERR "waiting for chip to be ready timed out in bufwrite\n"); 1606 printk(KERN_ERR "%s: buffer write error (status timeout)\n", map->name);
1513 ret = -EIO; 1607 ret = -EIO;
1514 goto out; 1608 goto out;
1515 } 1609 }
1516 1610
1517 /* Latency issues. Drop the lock, wait a while and retry */ 1611 /* Latency issues. Drop the lock, wait a while and retry */
1518 z++; 1612 z++;
1519 UDELAY(map, chip, cmd_adr, 1); 1613 UDELAY(map, chip, cmd_adr, 1);
@@ -1521,21 +1615,34 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1521 if (!z) { 1615 if (!z) {
1522 chip->buffer_write_time--; 1616 chip->buffer_write_time--;
1523 if (!chip->buffer_write_time) 1617 if (!chip->buffer_write_time)
1524 chip->buffer_write_time++; 1618 chip->buffer_write_time = 1;
1525 } 1619 }
1526 if (z > 1) 1620 if (z > 1)
1527 chip->buffer_write_time++; 1621 chip->buffer_write_time++;
1528 1622
1529 /* Done and happy. */ 1623 /* Done and happy. */
1530 chip->state = FL_STATUS; 1624 chip->state = FL_STATUS;
1531 1625
1532 /* check for lock bit */ 1626 /* check for errors */
1533 if (map_word_bitsset(map, status, CMD(0x02))) { 1627 if (map_word_bitsset(map, status, CMD(0x1a))) {
1534 /* clear status */ 1628 unsigned long chipstatus = MERGESTATUS(status);
1629
1630 /* reset status */
1535 map_write(map, CMD(0x50), cmd_adr); 1631 map_write(map, CMD(0x50), cmd_adr);
1536 /* put back into read status register mode */ 1632 map_write(map, CMD(0x70), cmd_adr);
1537 map_write(map, CMD(0x70), adr); 1633 xip_enable(map, chip, cmd_adr);
1538 ret = -EROFS; 1634
1635 if (chipstatus & 0x02) {
1636 ret = -EROFS;
1637 } else if (chipstatus & 0x08) {
1638 printk(KERN_ERR "%s: buffer write error (bad VPP)\n", map->name);
1639 ret = -EIO;
1640 } else {
1641 printk(KERN_ERR "%s: buffer write error (status 0x%lx)\n", map->name, chipstatus);
1642 ret = -EINVAL;
1643 }
1644
1645 goto out;
1539 } 1646 }
1540 1647
1541 xip_enable(map, chip, cmd_adr); 1648 xip_enable(map, chip, cmd_adr);
@@ -1544,70 +1651,65 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1544 return ret; 1651 return ret;
1545} 1652}
1546 1653
1547static int cfi_intelext_write_buffers (struct mtd_info *mtd, loff_t to, 1654static int cfi_intelext_writev (struct mtd_info *mtd, const struct kvec *vecs,
1548 size_t len, size_t *retlen, const u_char *buf) 1655 unsigned long count, loff_t to, size_t *retlen)
1549{ 1656{
1550 struct map_info *map = mtd->priv; 1657 struct map_info *map = mtd->priv;
1551 struct cfi_private *cfi = map->fldrv_priv; 1658 struct cfi_private *cfi = map->fldrv_priv;
1552 int wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; 1659 int wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
1553 int ret = 0; 1660 int ret = 0;
1554 int chipnum; 1661 int chipnum;
1555 unsigned long ofs; 1662 unsigned long ofs, vec_seek, i;
1663 size_t len = 0;
1664
1665 for (i = 0; i < count; i++)
1666 len += vecs[i].iov_len;
1556 1667
1557 *retlen = 0; 1668 *retlen = 0;
1558 if (!len) 1669 if (!len)
1559 return 0; 1670 return 0;
1560 1671
1561 chipnum = to >> cfi->chipshift; 1672 chipnum = to >> cfi->chipshift;
1562 ofs = to - (chipnum << cfi->chipshift); 1673 ofs = to - (chipnum << cfi->chipshift);
1563 1674 vec_seek = 0;
1564 /* If it's not bus-aligned, do the first word write */
1565 if (ofs & (map_bankwidth(map)-1)) {
1566 size_t local_len = (-ofs)&(map_bankwidth(map)-1);
1567 if (local_len > len)
1568 local_len = len;
1569 ret = cfi_intelext_write_words(mtd, to, local_len,
1570 retlen, buf);
1571 if (ret)
1572 return ret;
1573 ofs += local_len;
1574 buf += local_len;
1575 len -= local_len;
1576
1577 if (ofs >> cfi->chipshift) {
1578 chipnum ++;
1579 ofs = 0;
1580 if (chipnum == cfi->numchips)
1581 return 0;
1582 }
1583 }
1584 1675
1585 while(len) { 1676 do {
1586 /* We must not cross write block boundaries */ 1677 /* We must not cross write block boundaries */
1587 int size = wbufsize - (ofs & (wbufsize-1)); 1678 int size = wbufsize - (ofs & (wbufsize-1));
1588 1679
1589 if (size > len) 1680 if (size > len)
1590 size = len; 1681 size = len;
1591 ret = do_write_buffer(map, &cfi->chips[chipnum], 1682 ret = do_write_buffer(map, &cfi->chips[chipnum],
1592 ofs, buf, size); 1683 ofs, &vecs, &vec_seek, size);
1593 if (ret) 1684 if (ret)
1594 return ret; 1685 return ret;
1595 1686
1596 ofs += size; 1687 ofs += size;
1597 buf += size;
1598 (*retlen) += size; 1688 (*retlen) += size;
1599 len -= size; 1689 len -= size;
1600 1690
1601 if (ofs >> cfi->chipshift) { 1691 if (ofs >> cfi->chipshift) {
1602 chipnum ++; 1692 chipnum ++;
1603 ofs = 0; 1693 ofs = 0;
1604 if (chipnum == cfi->numchips) 1694 if (chipnum == cfi->numchips)
1605 return 0; 1695 return 0;
1606 } 1696 }
1607 } 1697 } while (len);
1698
1608 return 0; 1699 return 0;
1609} 1700}
1610 1701
1702static int cfi_intelext_write_buffers (struct mtd_info *mtd, loff_t to,
1703 size_t len, size_t *retlen, const u_char *buf)
1704{
1705 struct kvec vec;
1706
1707 vec.iov_base = (void *) buf;
1708 vec.iov_len = len;
1709
1710 return cfi_intelext_writev(mtd, &vec, 1, to, retlen);
1711}
1712
1611static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip, 1713static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1612 unsigned long adr, int len, void *thunk) 1714 unsigned long adr, int len, void *thunk)
1613{ 1715{
@@ -1673,23 +1775,17 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1673 status = map_read(map, adr); 1775 status = map_read(map, adr);
1674 if (map_word_andequal(map, status, status_OK, status_OK)) 1776 if (map_word_andequal(map, status, status_OK, status_OK))
1675 break; 1777 break;
1676 1778
1677 /* OK Still waiting */ 1779 /* OK Still waiting */
1678 if (time_after(jiffies, timeo)) { 1780 if (time_after(jiffies, timeo)) {
1679 map_word Xstatus;
1680 map_write(map, CMD(0x70), adr); 1781 map_write(map, CMD(0x70), adr);
1681 chip->state = FL_STATUS; 1782 chip->state = FL_STATUS;
1682 Xstatus = map_read(map, adr);
1683 /* Clear status bits */
1684 map_write(map, CMD(0x50), adr);
1685 map_write(map, CMD(0x70), adr);
1686 xip_enable(map, chip, adr); 1783 xip_enable(map, chip, adr);
1687 printk(KERN_ERR "waiting for erase at %08lx to complete timed out. status = %lx, Xstatus = %lx.\n", 1784 printk(KERN_ERR "%s: block erase error: (status timeout)\n", map->name);
1688 adr, status.x[0], Xstatus.x[0]);
1689 ret = -EIO; 1785 ret = -EIO;
1690 goto out; 1786 goto out;
1691 } 1787 }
1692 1788
1693 /* Latency issues. Drop the lock, wait a while and retry */ 1789 /* Latency issues. Drop the lock, wait a while and retry */
1694 UDELAY(map, chip, adr, 1000000/HZ); 1790 UDELAY(map, chip, adr, 1000000/HZ);
1695 } 1791 }
@@ -1699,43 +1795,40 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1699 chip->state = FL_STATUS; 1795 chip->state = FL_STATUS;
1700 status = map_read(map, adr); 1796 status = map_read(map, adr);
1701 1797
1702 /* check for lock bit */ 1798 /* check for errors */
1703 if (map_word_bitsset(map, status, CMD(0x3a))) { 1799 if (map_word_bitsset(map, status, CMD(0x3a))) {
1704 unsigned long chipstatus; 1800 unsigned long chipstatus = MERGESTATUS(status);
1705 1801
1706 /* Reset the error bits */ 1802 /* Reset the error bits */
1707 map_write(map, CMD(0x50), adr); 1803 map_write(map, CMD(0x50), adr);
1708 map_write(map, CMD(0x70), adr); 1804 map_write(map, CMD(0x70), adr);
1709 xip_enable(map, chip, adr); 1805 xip_enable(map, chip, adr);
1710 1806
1711 chipstatus = MERGESTATUS(status);
1712
1713 if ((chipstatus & 0x30) == 0x30) { 1807 if ((chipstatus & 0x30) == 0x30) {
1714 printk(KERN_NOTICE "Chip reports improper command sequence: status 0x%lx\n", chipstatus); 1808 printk(KERN_ERR "%s: block erase error: (bad command sequence, status 0x%lx)\n", map->name, chipstatus);
1715 ret = -EIO; 1809 ret = -EINVAL;
1716 } else if (chipstatus & 0x02) { 1810 } else if (chipstatus & 0x02) {
1717 /* Protection bit set */ 1811 /* Protection bit set */
1718 ret = -EROFS; 1812 ret = -EROFS;
1719 } else if (chipstatus & 0x8) { 1813 } else if (chipstatus & 0x8) {
1720 /* Voltage */ 1814 /* Voltage */
1721 printk(KERN_WARNING "Chip reports voltage low on erase: status 0x%lx\n", chipstatus); 1815 printk(KERN_ERR "%s: block erase error: (bad VPP)\n", map->name);
1722 ret = -EIO; 1816 ret = -EIO;
1723 } else if (chipstatus & 0x20) { 1817 } else if (chipstatus & 0x20 && retries--) {
1724 if (retries--) { 1818 printk(KERN_DEBUG "block erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus);
1725 printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus); 1819 timeo = jiffies + HZ;
1726 timeo = jiffies + HZ; 1820 put_chip(map, chip, adr);
1727 put_chip(map, chip, adr); 1821 spin_unlock(chip->mutex);
1728 spin_unlock(chip->mutex); 1822 goto retry;
1729 goto retry; 1823 } else {
1730 } 1824 printk(KERN_ERR "%s: block erase failed at 0x%08lx (status 0x%lx)\n", map->name, adr, chipstatus);
1731 printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%lx\n", adr, chipstatus);
1732 ret = -EIO; 1825 ret = -EIO;
1733 } 1826 }
1734 } else { 1827
1735 xip_enable(map, chip, adr); 1828 goto out;
1736 ret = 0;
1737 } 1829 }
1738 1830
1831 xip_enable(map, chip, adr);
1739 out: put_chip(map, chip, adr); 1832 out: put_chip(map, chip, adr);
1740 spin_unlock(chip->mutex); 1833 spin_unlock(chip->mutex);
1741 return ret; 1834 return ret;
@@ -1755,7 +1848,7 @@ int cfi_intelext_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
1755 1848
1756 instr->state = MTD_ERASE_DONE; 1849 instr->state = MTD_ERASE_DONE;
1757 mtd_erase_callback(instr); 1850 mtd_erase_callback(instr);
1758 1851
1759 return 0; 1852 return 0;
1760} 1853}
1761 1854
@@ -1776,7 +1869,7 @@ static void cfi_intelext_sync (struct mtd_info *mtd)
1776 if (!ret) { 1869 if (!ret) {
1777 chip->oldstate = chip->state; 1870 chip->oldstate = chip->state;
1778 chip->state = FL_SYNCING; 1871 chip->state = FL_SYNCING;
1779 /* No need to wake_up() on this state change - 1872 /* No need to wake_up() on this state change -
1780 * as the whole point is that nobody can do anything 1873 * as the whole point is that nobody can do anything
1781 * with the chip now anyway. 1874 * with the chip now anyway.
1782 */ 1875 */
@@ -1790,7 +1883,7 @@ static void cfi_intelext_sync (struct mtd_info *mtd)
1790 chip = &cfi->chips[i]; 1883 chip = &cfi->chips[i];
1791 1884
1792 spin_lock(chip->mutex); 1885 spin_lock(chip->mutex);
1793 1886
1794 if (chip->state == FL_SYNCING) { 1887 if (chip->state == FL_SYNCING) {
1795 chip->state = chip->oldstate; 1888 chip->state = chip->oldstate;
1796 chip->oldstate = FL_READY; 1889 chip->oldstate = FL_READY;
@@ -1847,7 +1940,7 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
1847 1940
1848 ENABLE_VPP(map); 1941 ENABLE_VPP(map);
1849 xip_disable(map, chip, adr); 1942 xip_disable(map, chip, adr);
1850 1943
1851 map_write(map, CMD(0x60), adr); 1944 map_write(map, CMD(0x60), adr);
1852 if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) { 1945 if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) {
1853 map_write(map, CMD(0x01), adr); 1946 map_write(map, CMD(0x01), adr);
@@ -1875,25 +1968,22 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
1875 status = map_read(map, adr); 1968 status = map_read(map, adr);
1876 if (map_word_andequal(map, status, status_OK, status_OK)) 1969 if (map_word_andequal(map, status, status_OK, status_OK))
1877 break; 1970 break;
1878 1971
1879 /* OK Still waiting */ 1972 /* OK Still waiting */
1880 if (time_after(jiffies, timeo)) { 1973 if (time_after(jiffies, timeo)) {
1881 map_word Xstatus;
1882 map_write(map, CMD(0x70), adr); 1974 map_write(map, CMD(0x70), adr);
1883 chip->state = FL_STATUS; 1975 chip->state = FL_STATUS;
1884 Xstatus = map_read(map, adr);
1885 xip_enable(map, chip, adr); 1976 xip_enable(map, chip, adr);
1886 printk(KERN_ERR "waiting for unlock to complete timed out. status = %lx, Xstatus = %lx.\n", 1977 printk(KERN_ERR "%s: block unlock error: (status timeout)\n", map->name);
1887 status.x[0], Xstatus.x[0]);
1888 put_chip(map, chip, adr); 1978 put_chip(map, chip, adr);
1889 spin_unlock(chip->mutex); 1979 spin_unlock(chip->mutex);
1890 return -EIO; 1980 return -EIO;
1891 } 1981 }
1892 1982
1893 /* Latency issues. Drop the lock, wait a while and retry */ 1983 /* Latency issues. Drop the lock, wait a while and retry */
1894 UDELAY(map, chip, adr, 1); 1984 UDELAY(map, chip, adr, 1);
1895 } 1985 }
1896 1986
1897 /* Done and happy. */ 1987 /* Done and happy. */
1898 chip->state = FL_STATUS; 1988 chip->state = FL_STATUS;
1899 xip_enable(map, chip, adr); 1989 xip_enable(map, chip, adr);
@@ -1913,9 +2003,9 @@ static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
1913 ofs, len, 0); 2003 ofs, len, 0);
1914#endif 2004#endif
1915 2005
1916 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock, 2006 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock,
1917 ofs, len, DO_XXLOCK_ONEBLOCK_LOCK); 2007 ofs, len, DO_XXLOCK_ONEBLOCK_LOCK);
1918 2008
1919#ifdef DEBUG_LOCK_BITS 2009#ifdef DEBUG_LOCK_BITS
1920 printk(KERN_DEBUG "%s: lock status after, ret=%d\n", 2010 printk(KERN_DEBUG "%s: lock status after, ret=%d\n",
1921 __FUNCTION__, ret); 2011 __FUNCTION__, ret);
@@ -1939,20 +2029,20 @@ static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1939 2029
1940 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock, 2030 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock,
1941 ofs, len, DO_XXLOCK_ONEBLOCK_UNLOCK); 2031 ofs, len, DO_XXLOCK_ONEBLOCK_UNLOCK);
1942 2032
1943#ifdef DEBUG_LOCK_BITS 2033#ifdef DEBUG_LOCK_BITS
1944 printk(KERN_DEBUG "%s: lock status after, ret=%d\n", 2034 printk(KERN_DEBUG "%s: lock status after, ret=%d\n",
1945 __FUNCTION__, ret); 2035 __FUNCTION__, ret);
1946 cfi_varsize_frob(mtd, do_printlockstatus_oneblock, 2036 cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
1947 ofs, len, 0); 2037 ofs, len, 0);
1948#endif 2038#endif
1949 2039
1950 return ret; 2040 return ret;
1951} 2041}
1952 2042
1953#ifdef CONFIG_MTD_OTP 2043#ifdef CONFIG_MTD_OTP
1954 2044
1955typedef int (*otp_op_t)(struct map_info *map, struct flchip *chip, 2045typedef int (*otp_op_t)(struct map_info *map, struct flchip *chip,
1956 u_long data_offset, u_char *buf, u_int size, 2046 u_long data_offset, u_char *buf, u_int size,
1957 u_long prot_offset, u_int groupno, u_int groupsize); 2047 u_long prot_offset, u_int groupno, u_int groupsize);
1958 2048
@@ -2003,7 +2093,7 @@ do_otp_write(struct map_info *map, struct flchip *chip, u_long offset,
2003 2093
2004 datum = map_word_load_partial(map, datum, buf, gap, n); 2094 datum = map_word_load_partial(map, datum, buf, gap, n);
2005 ret = do_write_oneword(map, chip, bus_ofs, datum, FL_OTP_WRITE); 2095 ret = do_write_oneword(map, chip, bus_ofs, datum, FL_OTP_WRITE);
2006 if (ret) 2096 if (ret)
2007 return ret; 2097 return ret;
2008 2098
2009 offset += n; 2099 offset += n;
@@ -2196,7 +2286,7 @@ static int cfi_intelext_lock_user_prot_reg(struct mtd_info *mtd,
2196 NULL, do_otp_lock, 1); 2286 NULL, do_otp_lock, 1);
2197} 2287}
2198 2288
2199static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, 2289static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd,
2200 struct otp_info *buf, size_t len) 2290 struct otp_info *buf, size_t len)
2201{ 2291{
2202 size_t retlen; 2292 size_t retlen;
@@ -2239,7 +2329,7 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
2239 if (chip->oldstate == FL_READY) { 2329 if (chip->oldstate == FL_READY) {
2240 chip->oldstate = chip->state; 2330 chip->oldstate = chip->state;
2241 chip->state = FL_PM_SUSPENDED; 2331 chip->state = FL_PM_SUSPENDED;
2242 /* No need to wake_up() on this state change - 2332 /* No need to wake_up() on this state change -
2243 * as the whole point is that nobody can do anything 2333 * as the whole point is that nobody can do anything
2244 * with the chip now anyway. 2334 * with the chip now anyway.
2245 */ 2335 */
@@ -2267,9 +2357,9 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
2267 if (ret) { 2357 if (ret) {
2268 for (i--; i >=0; i--) { 2358 for (i--; i >=0; i--) {
2269 chip = &cfi->chips[i]; 2359 chip = &cfi->chips[i];
2270 2360
2271 spin_lock(chip->mutex); 2361 spin_lock(chip->mutex);
2272 2362
2273 if (chip->state == FL_PM_SUSPENDED) { 2363 if (chip->state == FL_PM_SUSPENDED) {
2274 /* No need to force it into a known state here, 2364 /* No need to force it into a known state here,
2275 because we're returning failure, and it didn't 2365 because we're returning failure, and it didn't
@@ -2280,8 +2370,8 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
2280 } 2370 }
2281 spin_unlock(chip->mutex); 2371 spin_unlock(chip->mutex);
2282 } 2372 }
2283 } 2373 }
2284 2374
2285 return ret; 2375 return ret;
2286} 2376}
2287 2377
@@ -2293,11 +2383,11 @@ static void cfi_intelext_resume(struct mtd_info *mtd)
2293 struct flchip *chip; 2383 struct flchip *chip;
2294 2384
2295 for (i=0; i<cfi->numchips; i++) { 2385 for (i=0; i<cfi->numchips; i++) {
2296 2386
2297 chip = &cfi->chips[i]; 2387 chip = &cfi->chips[i];
2298 2388
2299 spin_lock(chip->mutex); 2389 spin_lock(chip->mutex);
2300 2390
2301 /* Go to known state. Chip may have been power cycled */ 2391 /* Go to known state. Chip may have been power cycled */
2302 if (chip->state == FL_PM_SUSPENDED) { 2392 if (chip->state == FL_PM_SUSPENDED) {
2303 map_write(map, CMD(0xFF), cfi->chips[i].start); 2393 map_write(map, CMD(0xFF), cfi->chips[i].start);
@@ -2319,7 +2409,7 @@ static int cfi_intelext_reset(struct mtd_info *mtd)
2319 struct flchip *chip = &cfi->chips[i]; 2409 struct flchip *chip = &cfi->chips[i];
2320 2410
2321 /* force the completion of any ongoing operation 2411 /* force the completion of any ongoing operation
2322 and switch to array mode so any bootloader in 2412 and switch to array mode so any bootloader in
2323 flash is accessible for soft reboot. */ 2413 flash is accessible for soft reboot. */
2324 spin_lock(chip->mutex); 2414 spin_lock(chip->mutex);
2325 ret = get_chip(map, chip, chip->start, FL_SYNCING); 2415 ret = get_chip(map, chip, chip->start, FL_SYNCING);
@@ -2356,20 +2446,23 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
2356 kfree(mtd->eraseregions); 2446 kfree(mtd->eraseregions);
2357} 2447}
2358 2448
2359static char im_name_1[]="cfi_cmdset_0001"; 2449static char im_name_0001[] = "cfi_cmdset_0001";
2360static char im_name_3[]="cfi_cmdset_0003"; 2450static char im_name_0003[] = "cfi_cmdset_0003";
2451static char im_name_0200[] = "cfi_cmdset_0200";
2361 2452
2362static int __init cfi_intelext_init(void) 2453static int __init cfi_intelext_init(void)
2363{ 2454{
2364 inter_module_register(im_name_1, THIS_MODULE, &cfi_cmdset_0001); 2455 inter_module_register(im_name_0001, THIS_MODULE, &cfi_cmdset_0001);
2365 inter_module_register(im_name_3, THIS_MODULE, &cfi_cmdset_0001); 2456 inter_module_register(im_name_0003, THIS_MODULE, &cfi_cmdset_0001);
2457 inter_module_register(im_name_0200, THIS_MODULE, &cfi_cmdset_0001);
2366 return 0; 2458 return 0;
2367} 2459}
2368 2460
2369static void __exit cfi_intelext_exit(void) 2461static void __exit cfi_intelext_exit(void)
2370{ 2462{
2371 inter_module_unregister(im_name_1); 2463 inter_module_unregister(im_name_0001);
2372 inter_module_unregister(im_name_3); 2464 inter_module_unregister(im_name_0003);
2465 inter_module_unregister(im_name_0200);
2373} 2466}
2374 2467
2375module_init(cfi_intelext_init); 2468module_init(cfi_intelext_init);
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 8505f118f2db..aed10bd5c3c3 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -10,14 +10,14 @@
10 * 10 *
11 * 4_by_16 work by Carolyn J. Smith 11 * 4_by_16 work by Carolyn J. Smith
12 * 12 *
13 * XIP support hooks by Vitaly Wool (based on code for Intel flash 13 * XIP support hooks by Vitaly Wool (based on code for Intel flash
14 * by Nicolas Pitre) 14 * by Nicolas Pitre)
15 * 15 *
16 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com 16 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com
17 * 17 *
18 * This code is GPL 18 * This code is GPL
19 * 19 *
20 * $Id: cfi_cmdset_0002.c,v 1.118 2005/07/04 22:34:29 gleixner Exp $ 20 * $Id: cfi_cmdset_0002.c,v 1.122 2005/11/07 11:14:22 gleixner Exp $
21 * 21 *
22 */ 22 */
23 23
@@ -93,7 +93,7 @@ static void cfi_tell_features(struct cfi_pri_amdstd *extp)
93 }; 93 };
94 94
95 printk(" Silicon revision: %d\n", extp->SiliconRevision >> 1); 95 printk(" Silicon revision: %d\n", extp->SiliconRevision >> 1);
96 printk(" Address sensitive unlock: %s\n", 96 printk(" Address sensitive unlock: %s\n",
97 (extp->SiliconRevision & 1) ? "Not required" : "Required"); 97 (extp->SiliconRevision & 1) ? "Not required" : "Required");
98 98
99 if (extp->EraseSuspend < ARRAY_SIZE(erase_suspend)) 99 if (extp->EraseSuspend < ARRAY_SIZE(erase_suspend))
@@ -118,9 +118,9 @@ static void cfi_tell_features(struct cfi_pri_amdstd *extp)
118 else 118 else
119 printk(" Page mode: %d word page\n", extp->PageMode << 2); 119 printk(" Page mode: %d word page\n", extp->PageMode << 2);
120 120
121 printk(" Vpp Supply Minimum Program/Erase Voltage: %d.%d V\n", 121 printk(" Vpp Supply Minimum Program/Erase Voltage: %d.%d V\n",
122 extp->VppMin >> 4, extp->VppMin & 0xf); 122 extp->VppMin >> 4, extp->VppMin & 0xf);
123 printk(" Vpp Supply Maximum Program/Erase Voltage: %d.%d V\n", 123 printk(" Vpp Supply Maximum Program/Erase Voltage: %d.%d V\n",
124 extp->VppMax >> 4, extp->VppMax & 0xf); 124 extp->VppMax >> 4, extp->VppMax & 0xf);
125 125
126 if (extp->TopBottom < ARRAY_SIZE(top_bottom)) 126 if (extp->TopBottom < ARRAY_SIZE(top_bottom))
@@ -177,7 +177,7 @@ static void fixup_use_erase_chip(struct mtd_info *mtd, void *param)
177 ((cfi->cfiq->EraseRegionInfo[0] & 0xffff) == 0)) { 177 ((cfi->cfiq->EraseRegionInfo[0] & 0xffff) == 0)) {
178 mtd->erase = cfi_amdstd_erase_chip; 178 mtd->erase = cfi_amdstd_erase_chip;
179 } 179 }
180 180
181} 181}
182 182
183static struct cfi_fixup cfi_fixup_table[] = { 183static struct cfi_fixup cfi_fixup_table[] = {
@@ -239,7 +239,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
239 239
240 if (cfi->cfi_mode==CFI_MODE_CFI){ 240 if (cfi->cfi_mode==CFI_MODE_CFI){
241 unsigned char bootloc; 241 unsigned char bootloc;
242 /* 242 /*
243 * It's a real CFI chip, not one for which the probe 243 * It's a real CFI chip, not one for which the probe
244 * routine faked a CFI structure. So we read the feature 244 * routine faked a CFI structure. So we read the feature
245 * table from it. 245 * table from it.
@@ -253,8 +253,18 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
253 return NULL; 253 return NULL;
254 } 254 }
255 255
256 if (extp->MajorVersion != '1' ||
257 (extp->MinorVersion < '0' || extp->MinorVersion > '4')) {
258 printk(KERN_ERR " Unknown Amd/Fujitsu Extended Query "
259 "version %c.%c.\n", extp->MajorVersion,
260 extp->MinorVersion);
261 kfree(extp);
262 kfree(mtd);
263 return NULL;
264 }
265
256 /* Install our own private info structure */ 266 /* Install our own private info structure */
257 cfi->cmdset_priv = extp; 267 cfi->cmdset_priv = extp;
258 268
259 /* Apply cfi device specific fixups */ 269 /* Apply cfi device specific fixups */
260 cfi_fixup(mtd, cfi_fixup_table); 270 cfi_fixup(mtd, cfi_fixup_table);
@@ -262,7 +272,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
262#ifdef DEBUG_CFI_FEATURES 272#ifdef DEBUG_CFI_FEATURES
263 /* Tell the user about it in lots of lovely detail */ 273 /* Tell the user about it in lots of lovely detail */
264 cfi_tell_features(extp); 274 cfi_tell_features(extp);
265#endif 275#endif
266 276
267 bootloc = extp->TopBottom; 277 bootloc = extp->TopBottom;
268 if ((bootloc != 2) && (bootloc != 3)) { 278 if ((bootloc != 2) && (bootloc != 3)) {
@@ -273,11 +283,11 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
273 283
274 if (bootloc == 3 && cfi->cfiq->NumEraseRegions > 1) { 284 if (bootloc == 3 && cfi->cfiq->NumEraseRegions > 1) {
275 printk(KERN_WARNING "%s: Swapping erase regions for broken CFI table.\n", map->name); 285 printk(KERN_WARNING "%s: Swapping erase regions for broken CFI table.\n", map->name);
276 286
277 for (i=0; i<cfi->cfiq->NumEraseRegions / 2; i++) { 287 for (i=0; i<cfi->cfiq->NumEraseRegions / 2; i++) {
278 int j = (cfi->cfiq->NumEraseRegions-1)-i; 288 int j = (cfi->cfiq->NumEraseRegions-1)-i;
279 __u32 swap; 289 __u32 swap;
280 290
281 swap = cfi->cfiq->EraseRegionInfo[i]; 291 swap = cfi->cfiq->EraseRegionInfo[i];
282 cfi->cfiq->EraseRegionInfo[i] = cfi->cfiq->EraseRegionInfo[j]; 292 cfi->cfiq->EraseRegionInfo[i] = cfi->cfiq->EraseRegionInfo[j];
283 cfi->cfiq->EraseRegionInfo[j] = swap; 293 cfi->cfiq->EraseRegionInfo[j] = swap;
@@ -288,11 +298,11 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
288 cfi->addr_unlock2 = 0x2aa; 298 cfi->addr_unlock2 = 0x2aa;
289 /* Modify the unlock address if we are in compatibility mode */ 299 /* Modify the unlock address if we are in compatibility mode */
290 if ( /* x16 in x8 mode */ 300 if ( /* x16 in x8 mode */
291 ((cfi->device_type == CFI_DEVICETYPE_X8) && 301 ((cfi->device_type == CFI_DEVICETYPE_X8) &&
292 (cfi->cfiq->InterfaceDesc == 2)) || 302 (cfi->cfiq->InterfaceDesc == 2)) ||
293 /* x32 in x16 mode */ 303 /* x32 in x16 mode */
294 ((cfi->device_type == CFI_DEVICETYPE_X16) && 304 ((cfi->device_type == CFI_DEVICETYPE_X16) &&
295 (cfi->cfiq->InterfaceDesc == 4))) 305 (cfi->cfiq->InterfaceDesc == 4)))
296 { 306 {
297 cfi->addr_unlock1 = 0xaaa; 307 cfi->addr_unlock1 = 0xaaa;
298 cfi->addr_unlock2 = 0x555; 308 cfi->addr_unlock2 = 0x555;
@@ -310,10 +320,10 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
310 cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp; 320 cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
311 cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; 321 cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
312 cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp; 322 cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp;
313 } 323 }
314 324
315 map->fldrv = &cfi_amdstd_chipdrv; 325 map->fldrv = &cfi_amdstd_chipdrv;
316 326
317 return cfi_amdstd_setup(mtd); 327 return cfi_amdstd_setup(mtd);
318} 328}
319 329
@@ -326,24 +336,24 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
326 unsigned long offset = 0; 336 unsigned long offset = 0;
327 int i,j; 337 int i,j;
328 338
329 printk(KERN_NOTICE "number of %s chips: %d\n", 339 printk(KERN_NOTICE "number of %s chips: %d\n",
330 (cfi->cfi_mode == CFI_MODE_CFI)?"CFI":"JEDEC",cfi->numchips); 340 (cfi->cfi_mode == CFI_MODE_CFI)?"CFI":"JEDEC",cfi->numchips);
331 /* Select the correct geometry setup */ 341 /* Select the correct geometry setup */
332 mtd->size = devsize * cfi->numchips; 342 mtd->size = devsize * cfi->numchips;
333 343
334 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; 344 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
335 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) 345 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
336 * mtd->numeraseregions, GFP_KERNEL); 346 * mtd->numeraseregions, GFP_KERNEL);
337 if (!mtd->eraseregions) { 347 if (!mtd->eraseregions) {
338 printk(KERN_WARNING "Failed to allocate memory for MTD erase region info\n"); 348 printk(KERN_WARNING "Failed to allocate memory for MTD erase region info\n");
339 goto setup_err; 349 goto setup_err;
340 } 350 }
341 351
342 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { 352 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
343 unsigned long ernum, ersize; 353 unsigned long ernum, ersize;
344 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; 354 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
345 ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1; 355 ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1;
346 356
347 if (mtd->erasesize < ersize) { 357 if (mtd->erasesize < ersize) {
348 mtd->erasesize = ersize; 358 mtd->erasesize = ersize;
349 } 359 }
@@ -378,8 +388,7 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
378 388
379 setup_err: 389 setup_err:
380 if(mtd) { 390 if(mtd) {
381 if(mtd->eraseregions) 391 kfree(mtd->eraseregions);
382 kfree(mtd->eraseregions);
383 kfree(mtd); 392 kfree(mtd);
384 } 393 }
385 kfree(cfi->cmdset_priv); 394 kfree(cfi->cmdset_priv);
@@ -430,7 +439,7 @@ static int __xipram chip_good(struct map_info *map, unsigned long addr, map_word
430 oldd = map_read(map, addr); 439 oldd = map_read(map, addr);
431 curd = map_read(map, addr); 440 curd = map_read(map, addr);
432 441
433 return map_word_equal(map, oldd, curd) && 442 return map_word_equal(map, oldd, curd) &&
434 map_word_equal(map, curd, expected); 443 map_word_equal(map, curd, expected);
435} 444}
436 445
@@ -462,7 +471,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
462 /* Someone else might have been playing with it. */ 471 /* Someone else might have been playing with it. */
463 goto retry; 472 goto retry;
464 } 473 }
465 474
466 case FL_READY: 475 case FL_READY:
467 case FL_CFI_QUERY: 476 case FL_CFI_QUERY:
468 case FL_JEDEC_QUERY: 477 case FL_JEDEC_QUERY:
@@ -505,7 +514,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
505 printk(KERN_ERR "MTD %s(): chip not ready after erase suspend\n", __func__); 514 printk(KERN_ERR "MTD %s(): chip not ready after erase suspend\n", __func__);
506 return -EIO; 515 return -EIO;
507 } 516 }
508 517
509 spin_unlock(chip->mutex); 518 spin_unlock(chip->mutex);
510 cfi_udelay(1); 519 cfi_udelay(1);
511 spin_lock(chip->mutex); 520 spin_lock(chip->mutex);
@@ -608,7 +617,7 @@ static void __xipram xip_enable(struct map_info *map, struct flchip *chip,
608 * When a delay is required for the flash operation to complete, the 617 * When a delay is required for the flash operation to complete, the
609 * xip_udelay() function is polling for both the given timeout and pending 618 * xip_udelay() function is polling for both the given timeout and pending
610 * (but still masked) hardware interrupts. Whenever there is an interrupt 619 * (but still masked) hardware interrupts. Whenever there is an interrupt
611 * pending then the flash erase operation is suspended, array mode restored 620 * pending then the flash erase operation is suspended, array mode restored
612 * and interrupts unmasked. Task scheduling might also happen at that 621 * and interrupts unmasked. Task scheduling might also happen at that
613 * point. The CPU eventually returns from the interrupt or the call to 622 * point. The CPU eventually returns from the interrupt or the call to
614 * schedule() and the suspended flash operation is resumed for the remaining 623 * schedule() and the suspended flash operation is resumed for the remaining
@@ -632,9 +641,9 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
632 ((chip->state == FL_ERASING && (extp->EraseSuspend & 2))) && 641 ((chip->state == FL_ERASING && (extp->EraseSuspend & 2))) &&
633 (cfi_interleave_is_1(cfi) || chip->oldstate == FL_READY)) { 642 (cfi_interleave_is_1(cfi) || chip->oldstate == FL_READY)) {
634 /* 643 /*
635 * Let's suspend the erase operation when supported. 644 * Let's suspend the erase operation when supported.
636 * Note that we currently don't try to suspend 645 * Note that we currently don't try to suspend
637 * interleaved chips if there is already another 646 * interleaved chips if there is already another
638 * operation suspended (imagine what happens 647 * operation suspended (imagine what happens
639 * when one chip was already done with the current 648 * when one chip was already done with the current
640 * operation while another chip suspended it, then 649 * operation while another chip suspended it, then
@@ -770,8 +779,8 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
770 779
771 adr += chip->start; 780 adr += chip->start;
772 781
773 /* Ensure cmd read/writes are aligned. */ 782 /* Ensure cmd read/writes are aligned. */
774 cmd_addr = adr & ~(map_bankwidth(map)-1); 783 cmd_addr = adr & ~(map_bankwidth(map)-1);
775 784
776 spin_lock(chip->mutex); 785 spin_lock(chip->mutex);
777 ret = get_chip(map, chip, cmd_addr, FL_READY); 786 ret = get_chip(map, chip, cmd_addr, FL_READY);
@@ -851,7 +860,7 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
851#endif 860#endif
852 set_current_state(TASK_UNINTERRUPTIBLE); 861 set_current_state(TASK_UNINTERRUPTIBLE);
853 add_wait_queue(&chip->wq, &wait); 862 add_wait_queue(&chip->wq, &wait);
854 863
855 spin_unlock(chip->mutex); 864 spin_unlock(chip->mutex);
856 865
857 schedule(); 866 schedule();
@@ -863,7 +872,7 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
863 timeo = jiffies + HZ; 872 timeo = jiffies + HZ;
864 873
865 goto retry; 874 goto retry;
866 } 875 }
867 876
868 adr += chip->start; 877 adr += chip->start;
869 878
@@ -872,14 +881,14 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
872 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 881 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
873 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 882 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
874 cfi_send_gen_cmd(0x88, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 883 cfi_send_gen_cmd(0x88, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
875 884
876 map_copy_from(map, buf, adr, len); 885 map_copy_from(map, buf, adr, len);
877 886
878 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 887 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
879 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 888 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
880 cfi_send_gen_cmd(0x90, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 889 cfi_send_gen_cmd(0x90, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
881 cfi_send_gen_cmd(0x00, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 890 cfi_send_gen_cmd(0x00, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
882 891
883 wake_up(&chip->wq); 892 wake_up(&chip->wq);
884 spin_unlock(chip->mutex); 893 spin_unlock(chip->mutex);
885 894
@@ -988,7 +997,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
988 chip->word_write_time); 997 chip->word_write_time);
989 998
990 /* See comment above for timeout value. */ 999 /* See comment above for timeout value. */
991 timeo = jiffies + uWriteTimeout; 1000 timeo = jiffies + uWriteTimeout;
992 for (;;) { 1001 for (;;) {
993 if (chip->state != FL_WRITING) { 1002 if (chip->state != FL_WRITING) {
994 /* Someone's suspended the write. Sleep */ 1003 /* Someone's suspended the write. Sleep */
@@ -1004,16 +1013,16 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1004 continue; 1013 continue;
1005 } 1014 }
1006 1015
1007 if (chip_ready(map, adr)) 1016 if (time_after(jiffies, timeo) && !chip_ready(map, adr)){
1008 break;
1009
1010 if (time_after(jiffies, timeo)) {
1011 xip_enable(map, chip, adr); 1017 xip_enable(map, chip, adr);
1012 printk(KERN_WARNING "MTD %s(): software timeout\n", __func__); 1018 printk(KERN_WARNING "MTD %s(): software timeout\n", __func__);
1013 xip_disable(map, chip, adr); 1019 xip_disable(map, chip, adr);
1014 break; 1020 break;
1015 } 1021 }
1016 1022
1023 if (chip_ready(map, adr))
1024 break;
1025
1017 /* Latency issues. Drop the lock, wait a while and retry */ 1026 /* Latency issues. Drop the lock, wait a while and retry */
1018 UDELAY(map, chip, adr, 1); 1027 UDELAY(map, chip, adr, 1);
1019 } 1028 }
@@ -1023,7 +1032,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1023 map_write( map, CMD(0xF0), chip->start ); 1032 map_write( map, CMD(0xF0), chip->start );
1024 /* FIXME - should have reset delay before continuing */ 1033 /* FIXME - should have reset delay before continuing */
1025 1034
1026 if (++retry_cnt <= MAX_WORD_RETRIES) 1035 if (++retry_cnt <= MAX_WORD_RETRIES)
1027 goto retry; 1036 goto retry;
1028 1037
1029 ret = -EIO; 1038 ret = -EIO;
@@ -1091,27 +1100,27 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1091 1100
1092 /* Number of bytes to copy from buffer */ 1101 /* Number of bytes to copy from buffer */
1093 n = min_t(int, len, map_bankwidth(map)-i); 1102 n = min_t(int, len, map_bankwidth(map)-i);
1094 1103
1095 tmp_buf = map_word_load_partial(map, tmp_buf, buf, i, n); 1104 tmp_buf = map_word_load_partial(map, tmp_buf, buf, i, n);
1096 1105
1097 ret = do_write_oneword(map, &cfi->chips[chipnum], 1106 ret = do_write_oneword(map, &cfi->chips[chipnum],
1098 bus_ofs, tmp_buf); 1107 bus_ofs, tmp_buf);
1099 if (ret) 1108 if (ret)
1100 return ret; 1109 return ret;
1101 1110
1102 ofs += n; 1111 ofs += n;
1103 buf += n; 1112 buf += n;
1104 (*retlen) += n; 1113 (*retlen) += n;
1105 len -= n; 1114 len -= n;
1106 1115
1107 if (ofs >> cfi->chipshift) { 1116 if (ofs >> cfi->chipshift) {
1108 chipnum ++; 1117 chipnum ++;
1109 ofs = 0; 1118 ofs = 0;
1110 if (chipnum == cfi->numchips) 1119 if (chipnum == cfi->numchips)
1111 return 0; 1120 return 0;
1112 } 1121 }
1113 } 1122 }
1114 1123
1115 /* We are now aligned, write as much as possible */ 1124 /* We are now aligned, write as much as possible */
1116 while(len >= map_bankwidth(map)) { 1125 while(len >= map_bankwidth(map)) {
1117 map_word datum; 1126 map_word datum;
@@ -1129,7 +1138,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1129 len -= map_bankwidth(map); 1138 len -= map_bankwidth(map);
1130 1139
1131 if (ofs >> cfi->chipshift) { 1140 if (ofs >> cfi->chipshift) {
1132 chipnum ++; 1141 chipnum ++;
1133 ofs = 0; 1142 ofs = 0;
1134 if (chipnum == cfi->numchips) 1143 if (chipnum == cfi->numchips)
1135 return 0; 1144 return 0;
@@ -1167,12 +1176,12 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1167 spin_unlock(cfi->chips[chipnum].mutex); 1176 spin_unlock(cfi->chips[chipnum].mutex);
1168 1177
1169 tmp_buf = map_word_load_partial(map, tmp_buf, buf, 0, len); 1178 tmp_buf = map_word_load_partial(map, tmp_buf, buf, 0, len);
1170 1179
1171 ret = do_write_oneword(map, &cfi->chips[chipnum], 1180 ret = do_write_oneword(map, &cfi->chips[chipnum],
1172 ofs, tmp_buf); 1181 ofs, tmp_buf);
1173 if (ret) 1182 if (ret)
1174 return ret; 1183 return ret;
1175 1184
1176 (*retlen) += len; 1185 (*retlen) += len;
1177 } 1186 }
1178 1187
@@ -1184,7 +1193,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1184 * FIXME: interleaved mode not tested, and probably not supported! 1193 * FIXME: interleaved mode not tested, and probably not supported!
1185 */ 1194 */
1186static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, 1195static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1187 unsigned long adr, const u_char *buf, 1196 unsigned long adr, const u_char *buf,
1188 int len) 1197 int len)
1189{ 1198{
1190 struct cfi_private *cfi = map->fldrv_priv; 1199 struct cfi_private *cfi = map->fldrv_priv;
@@ -1214,7 +1223,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1214 XIP_INVAL_CACHED_RANGE(map, adr, len); 1223 XIP_INVAL_CACHED_RANGE(map, adr, len);
1215 ENABLE_VPP(map); 1224 ENABLE_VPP(map);
1216 xip_disable(map, chip, cmd_adr); 1225 xip_disable(map, chip, cmd_adr);
1217 1226
1218 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1227 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
1219 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 1228 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
1220 //cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1229 //cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
@@ -1248,8 +1257,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1248 adr, map_bankwidth(map), 1257 adr, map_bankwidth(map),
1249 chip->word_write_time); 1258 chip->word_write_time);
1250 1259
1251 timeo = jiffies + uWriteTimeout; 1260 timeo = jiffies + uWriteTimeout;
1252 1261
1253 for (;;) { 1262 for (;;) {
1254 if (chip->state != FL_WRITING) { 1263 if (chip->state != FL_WRITING) {
1255 /* Someone's suspended the write. Sleep */ 1264 /* Someone's suspended the write. Sleep */
@@ -1265,13 +1274,13 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1265 continue; 1274 continue;
1266 } 1275 }
1267 1276
1277 if (time_after(jiffies, timeo) && !chip_ready(map, adr))
1278 break;
1279
1268 if (chip_ready(map, adr)) { 1280 if (chip_ready(map, adr)) {
1269 xip_enable(map, chip, adr); 1281 xip_enable(map, chip, adr);
1270 goto op_done; 1282 goto op_done;
1271 } 1283 }
1272
1273 if( time_after(jiffies, timeo))
1274 break;
1275 1284
1276 /* Latency issues. Drop the lock, wait a while and retry */ 1285 /* Latency issues. Drop the lock, wait a while and retry */
1277 UDELAY(map, chip, adr, 1); 1286 UDELAY(map, chip, adr, 1);
@@ -1343,7 +1352,7 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
1343 if (size % map_bankwidth(map)) 1352 if (size % map_bankwidth(map))
1344 size -= size % map_bankwidth(map); 1353 size -= size % map_bankwidth(map);
1345 1354
1346 ret = do_write_buffer(map, &cfi->chips[chipnum], 1355 ret = do_write_buffer(map, &cfi->chips[chipnum],
1347 ofs, buf, size); 1356 ofs, buf, size);
1348 if (ret) 1357 if (ret)
1349 return ret; 1358 return ret;
@@ -1354,7 +1363,7 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
1354 len -= size; 1363 len -= size;
1355 1364
1356 if (ofs >> cfi->chipshift) { 1365 if (ofs >> cfi->chipshift) {
1357 chipnum ++; 1366 chipnum ++;
1358 ofs = 0; 1367 ofs = 0;
1359 if (chipnum == cfi->numchips) 1368 if (chipnum == cfi->numchips)
1360 return 0; 1369 return 0;
@@ -1571,7 +1580,7 @@ int cfi_amdstd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
1571 1580
1572 instr->state = MTD_ERASE_DONE; 1581 instr->state = MTD_ERASE_DONE;
1573 mtd_erase_callback(instr); 1582 mtd_erase_callback(instr);
1574 1583
1575 return 0; 1584 return 0;
1576} 1585}
1577 1586
@@ -1594,7 +1603,7 @@ static int cfi_amdstd_erase_chip(struct mtd_info *mtd, struct erase_info *instr)
1594 1603
1595 instr->state = MTD_ERASE_DONE; 1604 instr->state = MTD_ERASE_DONE;
1596 mtd_erase_callback(instr); 1605 mtd_erase_callback(instr);
1597 1606
1598 return 0; 1607 return 0;
1599} 1608}
1600 1609
@@ -1621,7 +1630,7 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1621 case FL_JEDEC_QUERY: 1630 case FL_JEDEC_QUERY:
1622 chip->oldstate = chip->state; 1631 chip->oldstate = chip->state;
1623 chip->state = FL_SYNCING; 1632 chip->state = FL_SYNCING;
1624 /* No need to wake_up() on this state change - 1633 /* No need to wake_up() on this state change -
1625 * as the whole point is that nobody can do anything 1634 * as the whole point is that nobody can do anything
1626 * with the chip now anyway. 1635 * with the chip now anyway.
1627 */ 1636 */
@@ -1632,13 +1641,13 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1632 default: 1641 default:
1633 /* Not an idle state */ 1642 /* Not an idle state */
1634 add_wait_queue(&chip->wq, &wait); 1643 add_wait_queue(&chip->wq, &wait);
1635 1644
1636 spin_unlock(chip->mutex); 1645 spin_unlock(chip->mutex);
1637 1646
1638 schedule(); 1647 schedule();
1639 1648
1640 remove_wait_queue(&chip->wq, &wait); 1649 remove_wait_queue(&chip->wq, &wait);
1641 1650
1642 goto retry; 1651 goto retry;
1643 } 1652 }
1644 } 1653 }
@@ -1649,7 +1658,7 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1649 chip = &cfi->chips[i]; 1658 chip = &cfi->chips[i];
1650 1659
1651 spin_lock(chip->mutex); 1660 spin_lock(chip->mutex);
1652 1661
1653 if (chip->state == FL_SYNCING) { 1662 if (chip->state == FL_SYNCING) {
1654 chip->state = chip->oldstate; 1663 chip->state = chip->oldstate;
1655 wake_up(&chip->wq); 1664 wake_up(&chip->wq);
@@ -1679,7 +1688,7 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1679 case FL_JEDEC_QUERY: 1688 case FL_JEDEC_QUERY:
1680 chip->oldstate = chip->state; 1689 chip->oldstate = chip->state;
1681 chip->state = FL_PM_SUSPENDED; 1690 chip->state = FL_PM_SUSPENDED;
1682 /* No need to wake_up() on this state change - 1691 /* No need to wake_up() on this state change -
1683 * as the whole point is that nobody can do anything 1692 * as the whole point is that nobody can do anything
1684 * with the chip now anyway. 1693 * with the chip now anyway.
1685 */ 1694 */
@@ -1700,7 +1709,7 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1700 chip = &cfi->chips[i]; 1709 chip = &cfi->chips[i];
1701 1710
1702 spin_lock(chip->mutex); 1711 spin_lock(chip->mutex);
1703 1712
1704 if (chip->state == FL_PM_SUSPENDED) { 1713 if (chip->state == FL_PM_SUSPENDED) {
1705 chip->state = chip->oldstate; 1714 chip->state = chip->oldstate;
1706 wake_up(&chip->wq); 1715 wake_up(&chip->wq);
@@ -1708,7 +1717,7 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1708 spin_unlock(chip->mutex); 1717 spin_unlock(chip->mutex);
1709 } 1718 }
1710 } 1719 }
1711 1720
1712 return ret; 1721 return ret;
1713} 1722}
1714 1723
@@ -1721,11 +1730,11 @@ static void cfi_amdstd_resume(struct mtd_info *mtd)
1721 struct flchip *chip; 1730 struct flchip *chip;
1722 1731
1723 for (i=0; i<cfi->numchips; i++) { 1732 for (i=0; i<cfi->numchips; i++) {
1724 1733
1725 chip = &cfi->chips[i]; 1734 chip = &cfi->chips[i];
1726 1735
1727 spin_lock(chip->mutex); 1736 spin_lock(chip->mutex);
1728 1737
1729 if (chip->state == FL_PM_SUSPENDED) { 1738 if (chip->state == FL_PM_SUSPENDED) {
1730 chip->state = FL_READY; 1739 chip->state = FL_READY;
1731 map_write(map, CMD(0xF0), chip->start); 1740 map_write(map, CMD(0xF0), chip->start);
@@ -1742,6 +1751,7 @@ static void cfi_amdstd_destroy(struct mtd_info *mtd)
1742{ 1751{
1743 struct map_info *map = mtd->priv; 1752 struct map_info *map = mtd->priv;
1744 struct cfi_private *cfi = map->fldrv_priv; 1753 struct cfi_private *cfi = map->fldrv_priv;
1754
1745 kfree(cfi->cmdset_priv); 1755 kfree(cfi->cmdset_priv);
1746 kfree(cfi->cfiq); 1756 kfree(cfi->cfiq);
1747 kfree(cfi); 1757 kfree(cfi);
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index c894f8801578..c4a19d2dc67f 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -4,8 +4,8 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0020.c,v 1.19 2005/07/13 15:52:45 dwmw2 Exp $ 7 * $Id: cfi_cmdset_0020.c,v 1.22 2005/11/07 11:14:22 gleixner Exp $
8 * 8 *
9 * 10/10/2000 Nicolas Pitre <nico@cam.org> 9 * 10/10/2000 Nicolas Pitre <nico@cam.org>
10 * - completely revamped method functions so they are aware and 10 * - completely revamped method functions so they are aware and
11 * independent of the flash geometry (buswidth, interleave, etc.) 11 * independent of the flash geometry (buswidth, interleave, etc.)
@@ -81,17 +81,17 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
81 printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported"); 81 printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported");
82 printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported"); 82 printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported");
83 for (i=9; i<32; i++) { 83 for (i=9; i<32; i++) {
84 if (extp->FeatureSupport & (1<<i)) 84 if (extp->FeatureSupport & (1<<i))
85 printk(" - Unknown Bit %X: supported\n", i); 85 printk(" - Unknown Bit %X: supported\n", i);
86 } 86 }
87 87
88 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport); 88 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport);
89 printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported"); 89 printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported");
90 for (i=1; i<8; i++) { 90 for (i=1; i<8; i++) {
91 if (extp->SuspendCmdSupport & (1<<i)) 91 if (extp->SuspendCmdSupport & (1<<i))
92 printk(" - Unknown Bit %X: supported\n", i); 92 printk(" - Unknown Bit %X: supported\n", i);
93 } 93 }
94 94
95 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask); 95 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask);
96 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no"); 96 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no");
97 printk(" - Valid Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no"); 97 printk(" - Valid Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no");
@@ -99,11 +99,11 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
99 if (extp->BlkStatusRegMask & (1<<i)) 99 if (extp->BlkStatusRegMask & (1<<i))
100 printk(" - Unknown Bit %X Active: yes\n",i); 100 printk(" - Unknown Bit %X Active: yes\n",i);
101 } 101 }
102 102
103 printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n", 103 printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n",
104 extp->VccOptimal >> 8, extp->VccOptimal & 0xf); 104 extp->VccOptimal >> 8, extp->VccOptimal & 0xf);
105 if (extp->VppOptimal) 105 if (extp->VppOptimal)
106 printk(" Vpp Programming Supply Optimum Program/Erase Voltage: %d.%d V\n", 106 printk(" Vpp Programming Supply Optimum Program/Erase Voltage: %d.%d V\n",
107 extp->VppOptimal >> 8, extp->VppOptimal & 0xf); 107 extp->VppOptimal >> 8, extp->VppOptimal & 0xf);
108} 108}
109#endif 109#endif
@@ -121,7 +121,7 @@ struct mtd_info *cfi_cmdset_0020(struct map_info *map, int primary)
121 int i; 121 int i;
122 122
123 if (cfi->cfi_mode) { 123 if (cfi->cfi_mode) {
124 /* 124 /*
125 * It's a real CFI chip, not one for which the probe 125 * It's a real CFI chip, not one for which the probe
126 * routine faked a CFI structure. So we read the feature 126 * routine faked a CFI structure. So we read the feature
127 * table from it. 127 * table from it.
@@ -133,24 +133,33 @@ struct mtd_info *cfi_cmdset_0020(struct map_info *map, int primary)
133 if (!extp) 133 if (!extp)
134 return NULL; 134 return NULL;
135 135
136 if (extp->MajorVersion != '1' ||
137 (extp->MinorVersion < '0' || extp->MinorVersion > '3')) {
138 printk(KERN_ERR " Unknown ST Microelectronics"
139 " Extended Query version %c.%c.\n",
140 extp->MajorVersion, extp->MinorVersion);
141 kfree(extp);
142 return NULL;
143 }
144
136 /* Do some byteswapping if necessary */ 145 /* Do some byteswapping if necessary */
137 extp->FeatureSupport = cfi32_to_cpu(extp->FeatureSupport); 146 extp->FeatureSupport = cfi32_to_cpu(extp->FeatureSupport);
138 extp->BlkStatusRegMask = cfi32_to_cpu(extp->BlkStatusRegMask); 147 extp->BlkStatusRegMask = cfi32_to_cpu(extp->BlkStatusRegMask);
139 148
140#ifdef DEBUG_CFI_FEATURES 149#ifdef DEBUG_CFI_FEATURES
141 /* Tell the user about it in lots of lovely detail */ 150 /* Tell the user about it in lots of lovely detail */
142 cfi_tell_features(extp); 151 cfi_tell_features(extp);
143#endif 152#endif
144 153
145 /* Install our own private info structure */ 154 /* Install our own private info structure */
146 cfi->cmdset_priv = extp; 155 cfi->cmdset_priv = extp;
147 } 156 }
148 157
149 for (i=0; i< cfi->numchips; i++) { 158 for (i=0; i< cfi->numchips; i++) {
150 cfi->chips[i].word_write_time = 128; 159 cfi->chips[i].word_write_time = 128;
151 cfi->chips[i].buffer_write_time = 128; 160 cfi->chips[i].buffer_write_time = 128;
152 cfi->chips[i].erase_time = 1024; 161 cfi->chips[i].erase_time = 1024;
153 } 162 }
154 163
155 return cfi_staa_setup(map); 164 return cfi_staa_setup(map);
156} 165}
@@ -178,15 +187,15 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
178 mtd->size = devsize * cfi->numchips; 187 mtd->size = devsize * cfi->numchips;
179 188
180 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; 189 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
181 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) 190 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
182 * mtd->numeraseregions, GFP_KERNEL); 191 * mtd->numeraseregions, GFP_KERNEL);
183 if (!mtd->eraseregions) { 192 if (!mtd->eraseregions) {
184 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n"); 193 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n");
185 kfree(cfi->cmdset_priv); 194 kfree(cfi->cmdset_priv);
186 kfree(mtd); 195 kfree(mtd);
187 return NULL; 196 return NULL;
188 } 197 }
189 198
190 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { 199 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
191 unsigned long ernum, ersize; 200 unsigned long ernum, ersize;
192 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; 201 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
@@ -219,7 +228,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
219 mtd->eraseregions[i].numblocks); 228 mtd->eraseregions[i].numblocks);
220 } 229 }
221 230
222 /* Also select the correct geometry setup too */ 231 /* Also select the correct geometry setup too */
223 mtd->erase = cfi_staa_erase_varsize; 232 mtd->erase = cfi_staa_erase_varsize;
224 mtd->read = cfi_staa_read; 233 mtd->read = cfi_staa_read;
225 mtd->write = cfi_staa_write_buffers; 234 mtd->write = cfi_staa_write_buffers;
@@ -250,8 +259,8 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
250 259
251 adr += chip->start; 260 adr += chip->start;
252 261
253 /* Ensure cmd read/writes are aligned. */ 262 /* Ensure cmd read/writes are aligned. */
254 cmd_addr = adr & ~(map_bankwidth(map)-1); 263 cmd_addr = adr & ~(map_bankwidth(map)-1);
255 264
256 /* Let's determine this according to the interleave only once */ 265 /* Let's determine this according to the interleave only once */
257 status_OK = CMD(0x80); 266 status_OK = CMD(0x80);
@@ -267,7 +276,7 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
267 case FL_ERASING: 276 case FL_ERASING:
268 if (!(((struct cfi_pri_intelext *)cfi->cmdset_priv)->FeatureSupport & 2)) 277 if (!(((struct cfi_pri_intelext *)cfi->cmdset_priv)->FeatureSupport & 2))
269 goto sleep; /* We don't support erase suspend */ 278 goto sleep; /* We don't support erase suspend */
270 279
271 map_write (map, CMD(0xb0), cmd_addr); 280 map_write (map, CMD(0xb0), cmd_addr);
272 /* If the flash has finished erasing, then 'erase suspend' 281 /* If the flash has finished erasing, then 'erase suspend'
273 * appears to make some (28F320) flash devices switch to 282 * appears to make some (28F320) flash devices switch to
@@ -282,7 +291,7 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
282 status = map_read(map, cmd_addr); 291 status = map_read(map, cmd_addr);
283 if (map_word_andequal(map, status, status_OK, status_OK)) 292 if (map_word_andequal(map, status, status_OK, status_OK))
284 break; 293 break;
285 294
286 if (time_after(jiffies, timeo)) { 295 if (time_after(jiffies, timeo)) {
287 /* Urgh */ 296 /* Urgh */
288 map_write(map, CMD(0xd0), cmd_addr); 297 map_write(map, CMD(0xd0), cmd_addr);
@@ -294,17 +303,17 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
294 "suspended: status = 0x%lx\n", status.x[0]); 303 "suspended: status = 0x%lx\n", status.x[0]);
295 return -EIO; 304 return -EIO;
296 } 305 }
297 306
298 spin_unlock_bh(chip->mutex); 307 spin_unlock_bh(chip->mutex);
299 cfi_udelay(1); 308 cfi_udelay(1);
300 spin_lock_bh(chip->mutex); 309 spin_lock_bh(chip->mutex);
301 } 310 }
302 311
303 suspended = 1; 312 suspended = 1;
304 map_write(map, CMD(0xff), cmd_addr); 313 map_write(map, CMD(0xff), cmd_addr);
305 chip->state = FL_READY; 314 chip->state = FL_READY;
306 break; 315 break;
307 316
308#if 0 317#if 0
309 case FL_WRITING: 318 case FL_WRITING:
310 /* Not quite yet */ 319 /* Not quite yet */
@@ -325,7 +334,7 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
325 chip->state = FL_READY; 334 chip->state = FL_READY;
326 break; 335 break;
327 } 336 }
328 337
329 /* Urgh. Chip not yet ready to talk to us. */ 338 /* Urgh. Chip not yet ready to talk to us. */
330 if (time_after(jiffies, timeo)) { 339 if (time_after(jiffies, timeo)) {
331 spin_unlock_bh(chip->mutex); 340 spin_unlock_bh(chip->mutex);
@@ -355,17 +364,17 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
355 364
356 if (suspended) { 365 if (suspended) {
357 chip->state = chip->oldstate; 366 chip->state = chip->oldstate;
358 /* What if one interleaved chip has finished and the 367 /* What if one interleaved chip has finished and the
359 other hasn't? The old code would leave the finished 368 other hasn't? The old code would leave the finished
360 one in READY mode. That's bad, and caused -EROFS 369 one in READY mode. That's bad, and caused -EROFS
361 errors to be returned from do_erase_oneblock because 370 errors to be returned from do_erase_oneblock because
362 that's the only bit it checked for at the time. 371 that's the only bit it checked for at the time.
363 As the state machine appears to explicitly allow 372 As the state machine appears to explicitly allow
364 sending the 0x70 (Read Status) command to an erasing 373 sending the 0x70 (Read Status) command to an erasing
365 chip and expecting it to be ignored, that's what we 374 chip and expecting it to be ignored, that's what we
366 do. */ 375 do. */
367 map_write(map, CMD(0xd0), cmd_addr); 376 map_write(map, CMD(0xd0), cmd_addr);
368 map_write(map, CMD(0x70), cmd_addr); 377 map_write(map, CMD(0x70), cmd_addr);
369 } 378 }
370 379
371 wake_up(&chip->wq); 380 wake_up(&chip->wq);
@@ -405,14 +414,14 @@ static int cfi_staa_read (struct mtd_info *mtd, loff_t from, size_t len, size_t
405 *retlen += thislen; 414 *retlen += thislen;
406 len -= thislen; 415 len -= thislen;
407 buf += thislen; 416 buf += thislen;
408 417
409 ofs = 0; 418 ofs = 0;
410 chipnum++; 419 chipnum++;
411 } 420 }
412 return ret; 421 return ret;
413} 422}
414 423
415static inline int do_write_buffer(struct map_info *map, struct flchip *chip, 424static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
416 unsigned long adr, const u_char *buf, int len) 425 unsigned long adr, const u_char *buf, int len)
417{ 426{
418 struct cfi_private *cfi = map->fldrv_priv; 427 struct cfi_private *cfi = map->fldrv_priv;
@@ -420,7 +429,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
420 unsigned long cmd_adr, timeo; 429 unsigned long cmd_adr, timeo;
421 DECLARE_WAITQUEUE(wait, current); 430 DECLARE_WAITQUEUE(wait, current);
422 int wbufsize, z; 431 int wbufsize, z;
423 432
424 /* M58LW064A requires bus alignment for buffer wriets -- saw */ 433 /* M58LW064A requires bus alignment for buffer wriets -- saw */
425 if (adr & (map_bankwidth(map)-1)) 434 if (adr & (map_bankwidth(map)-1))
426 return -EINVAL; 435 return -EINVAL;
@@ -428,10 +437,10 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
428 wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; 437 wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
429 adr += chip->start; 438 adr += chip->start;
430 cmd_adr = adr & ~(wbufsize-1); 439 cmd_adr = adr & ~(wbufsize-1);
431 440
432 /* Let's determine this according to the interleave only once */ 441 /* Let's determine this according to the interleave only once */
433 status_OK = CMD(0x80); 442 status_OK = CMD(0x80);
434 443
435 timeo = jiffies + HZ; 444 timeo = jiffies + HZ;
436 retry: 445 retry:
437 446
@@ -439,7 +448,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
439 printk("%s: chip->state[%d]\n", __FUNCTION__, chip->state); 448 printk("%s: chip->state[%d]\n", __FUNCTION__, chip->state);
440#endif 449#endif
441 spin_lock_bh(chip->mutex); 450 spin_lock_bh(chip->mutex);
442 451
443 /* Check that the chip's ready to talk to us. 452 /* Check that the chip's ready to talk to us.
444 * Later, we can actually think about interrupting it 453 * Later, we can actually think about interrupting it
445 * if it's in FL_ERASING state. 454 * if it's in FL_ERASING state.
@@ -448,7 +457,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
448 switch (chip->state) { 457 switch (chip->state) {
449 case FL_READY: 458 case FL_READY:
450 break; 459 break;
451 460
452 case FL_CFI_QUERY: 461 case FL_CFI_QUERY:
453 case FL_JEDEC_QUERY: 462 case FL_JEDEC_QUERY:
454 map_write(map, CMD(0x70), cmd_adr); 463 map_write(map, CMD(0x70), cmd_adr);
@@ -513,7 +522,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
513 522
514 /* Write length of data to come */ 523 /* Write length of data to come */
515 map_write(map, CMD(len/map_bankwidth(map)-1), cmd_adr ); 524 map_write(map, CMD(len/map_bankwidth(map)-1), cmd_adr );
516 525
517 /* Write data */ 526 /* Write data */
518 for (z = 0; z < len; 527 for (z = 0; z < len;
519 z += map_bankwidth(map), buf += map_bankwidth(map)) { 528 z += map_bankwidth(map), buf += map_bankwidth(map)) {
@@ -560,7 +569,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
560 printk(KERN_ERR "waiting for chip to be ready timed out in bufwrite\n"); 569 printk(KERN_ERR "waiting for chip to be ready timed out in bufwrite\n");
561 return -EIO; 570 return -EIO;
562 } 571 }
563 572
564 /* Latency issues. Drop the lock, wait a while and retry */ 573 /* Latency issues. Drop the lock, wait a while and retry */
565 spin_unlock_bh(chip->mutex); 574 spin_unlock_bh(chip->mutex);
566 cfi_udelay(1); 575 cfi_udelay(1);
@@ -572,9 +581,9 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
572 if (!chip->buffer_write_time) 581 if (!chip->buffer_write_time)
573 chip->buffer_write_time++; 582 chip->buffer_write_time++;
574 } 583 }
575 if (z > 1) 584 if (z > 1)
576 chip->buffer_write_time++; 585 chip->buffer_write_time++;
577 586
578 /* Done and happy. */ 587 /* Done and happy. */
579 DISABLE_VPP(map); 588 DISABLE_VPP(map);
580 chip->state = FL_STATUS; 589 chip->state = FL_STATUS;
@@ -598,7 +607,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
598 return 0; 607 return 0;
599} 608}
600 609
601static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to, 610static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
602 size_t len, size_t *retlen, const u_char *buf) 611 size_t len, size_t *retlen, const u_char *buf)
603{ 612{
604 struct map_info *map = mtd->priv; 613 struct map_info *map = mtd->priv;
@@ -620,7 +629,7 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
620 printk("%s: chipnum[%x] wbufsize[%x]\n", __FUNCTION__, chipnum, wbufsize); 629 printk("%s: chipnum[%x] wbufsize[%x]\n", __FUNCTION__, chipnum, wbufsize);
621 printk("%s: ofs[%x] len[%x]\n", __FUNCTION__, ofs, len); 630 printk("%s: ofs[%x] len[%x]\n", __FUNCTION__, ofs, len);
622#endif 631#endif
623 632
624 /* Write buffer is worth it only if more than one word to write... */ 633 /* Write buffer is worth it only if more than one word to write... */
625 while (len > 0) { 634 while (len > 0) {
626 /* We must not cross write block boundaries */ 635 /* We must not cross write block boundaries */
@@ -629,7 +638,7 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
629 if (size > len) 638 if (size > len)
630 size = len; 639 size = len;
631 640
632 ret = do_write_buffer(map, &cfi->chips[chipnum], 641 ret = do_write_buffer(map, &cfi->chips[chipnum],
633 ofs, buf, size); 642 ofs, buf, size);
634 if (ret) 643 if (ret)
635 return ret; 644 return ret;
@@ -640,13 +649,13 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
640 len -= size; 649 len -= size;
641 650
642 if (ofs >> cfi->chipshift) { 651 if (ofs >> cfi->chipshift) {
643 chipnum ++; 652 chipnum ++;
644 ofs = 0; 653 ofs = 0;
645 if (chipnum == cfi->numchips) 654 if (chipnum == cfi->numchips)
646 return 0; 655 return 0;
647 } 656 }
648 } 657 }
649 658
650 return 0; 659 return 0;
651} 660}
652 661
@@ -756,7 +765,7 @@ retry:
756 status = map_read(map, adr); 765 status = map_read(map, adr);
757 if (map_word_andequal(map, status, status_OK, status_OK)) 766 if (map_word_andequal(map, status, status_OK, status_OK))
758 break; 767 break;
759 768
760 /* Urgh. Chip not yet ready to talk to us. */ 769 /* Urgh. Chip not yet ready to talk to us. */
761 if (time_after(jiffies, timeo)) { 770 if (time_after(jiffies, timeo)) {
762 spin_unlock_bh(chip->mutex); 771 spin_unlock_bh(chip->mutex);
@@ -789,7 +798,7 @@ retry:
789 map_write(map, CMD(0x20), adr); 798 map_write(map, CMD(0x20), adr);
790 map_write(map, CMD(0xD0), adr); 799 map_write(map, CMD(0xD0), adr);
791 chip->state = FL_ERASING; 800 chip->state = FL_ERASING;
792 801
793 spin_unlock_bh(chip->mutex); 802 spin_unlock_bh(chip->mutex);
794 msleep(1000); 803 msleep(1000);
795 spin_lock_bh(chip->mutex); 804 spin_lock_bh(chip->mutex);
@@ -814,7 +823,7 @@ retry:
814 status = map_read(map, adr); 823 status = map_read(map, adr);
815 if (map_word_andequal(map, status, status_OK, status_OK)) 824 if (map_word_andequal(map, status, status_OK, status_OK))
816 break; 825 break;
817 826
818 /* OK Still waiting */ 827 /* OK Still waiting */
819 if (time_after(jiffies, timeo)) { 828 if (time_after(jiffies, timeo)) {
820 map_write(map, CMD(0x70), adr); 829 map_write(map, CMD(0x70), adr);
@@ -824,13 +833,13 @@ retry:
824 spin_unlock_bh(chip->mutex); 833 spin_unlock_bh(chip->mutex);
825 return -EIO; 834 return -EIO;
826 } 835 }
827 836
828 /* Latency issues. Drop the lock, wait a while and retry */ 837 /* Latency issues. Drop the lock, wait a while and retry */
829 spin_unlock_bh(chip->mutex); 838 spin_unlock_bh(chip->mutex);
830 cfi_udelay(1); 839 cfi_udelay(1);
831 spin_lock_bh(chip->mutex); 840 spin_lock_bh(chip->mutex);
832 } 841 }
833 842
834 DISABLE_VPP(map); 843 DISABLE_VPP(map);
835 ret = 0; 844 ret = 0;
836 845
@@ -855,7 +864,7 @@ retry:
855 /* Reset the error bits */ 864 /* Reset the error bits */
856 map_write(map, CMD(0x50), adr); 865 map_write(map, CMD(0x50), adr);
857 map_write(map, CMD(0x70), adr); 866 map_write(map, CMD(0x70), adr);
858 867
859 if ((chipstatus & 0x30) == 0x30) { 868 if ((chipstatus & 0x30) == 0x30) {
860 printk(KERN_NOTICE "Chip reports improper command sequence: status 0x%x\n", chipstatus); 869 printk(KERN_NOTICE "Chip reports improper command sequence: status 0x%x\n", chipstatus);
861 ret = -EIO; 870 ret = -EIO;
@@ -904,17 +913,17 @@ int cfi_staa_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
904 913
905 i = 0; 914 i = 0;
906 915
907 /* Skip all erase regions which are ended before the start of 916 /* Skip all erase regions which are ended before the start of
908 the requested erase. Actually, to save on the calculations, 917 the requested erase. Actually, to save on the calculations,
909 we skip to the first erase region which starts after the 918 we skip to the first erase region which starts after the
910 start of the requested erase, and then go back one. 919 start of the requested erase, and then go back one.
911 */ 920 */
912 921
913 while (i < mtd->numeraseregions && instr->addr >= regions[i].offset) 922 while (i < mtd->numeraseregions && instr->addr >= regions[i].offset)
914 i++; 923 i++;
915 i--; 924 i--;
916 925
917 /* OK, now i is pointing at the erase region in which this 926 /* OK, now i is pointing at the erase region in which this
918 erase request starts. Check the start of the requested 927 erase request starts. Check the start of the requested
919 erase range is aligned with the erase size which is in 928 erase range is aligned with the erase size which is in
920 effect here. 929 effect here.
@@ -937,7 +946,7 @@ int cfi_staa_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
937 the address actually falls 946 the address actually falls
938 */ 947 */
939 i--; 948 i--;
940 949
941 if ((instr->addr + instr->len) & (regions[i].erasesize-1)) 950 if ((instr->addr + instr->len) & (regions[i].erasesize-1))
942 return -EINVAL; 951 return -EINVAL;
943 952
@@ -949,7 +958,7 @@ int cfi_staa_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
949 958
950 while(len) { 959 while(len) {
951 ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr); 960 ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr);
952 961
953 if (ret) 962 if (ret)
954 return ret; 963 return ret;
955 964
@@ -962,15 +971,15 @@ int cfi_staa_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
962 if (adr >> cfi->chipshift) { 971 if (adr >> cfi->chipshift) {
963 adr = 0; 972 adr = 0;
964 chipnum++; 973 chipnum++;
965 974
966 if (chipnum >= cfi->numchips) 975 if (chipnum >= cfi->numchips)
967 break; 976 break;
968 } 977 }
969 } 978 }
970 979
971 instr->state = MTD_ERASE_DONE; 980 instr->state = MTD_ERASE_DONE;
972 mtd_erase_callback(instr); 981 mtd_erase_callback(instr);
973 982
974 return 0; 983 return 0;
975} 984}
976 985
@@ -996,7 +1005,7 @@ static void cfi_staa_sync (struct mtd_info *mtd)
996 case FL_JEDEC_QUERY: 1005 case FL_JEDEC_QUERY:
997 chip->oldstate = chip->state; 1006 chip->oldstate = chip->state;
998 chip->state = FL_SYNCING; 1007 chip->state = FL_SYNCING;
999 /* No need to wake_up() on this state change - 1008 /* No need to wake_up() on this state change -
1000 * as the whole point is that nobody can do anything 1009 * as the whole point is that nobody can do anything
1001 * with the chip now anyway. 1010 * with the chip now anyway.
1002 */ 1011 */
@@ -1007,11 +1016,11 @@ static void cfi_staa_sync (struct mtd_info *mtd)
1007 default: 1016 default:
1008 /* Not an idle state */ 1017 /* Not an idle state */
1009 add_wait_queue(&chip->wq, &wait); 1018 add_wait_queue(&chip->wq, &wait);
1010 1019
1011 spin_unlock_bh(chip->mutex); 1020 spin_unlock_bh(chip->mutex);
1012 schedule(); 1021 schedule();
1013 remove_wait_queue(&chip->wq, &wait); 1022 remove_wait_queue(&chip->wq, &wait);
1014 1023
1015 goto retry; 1024 goto retry;
1016 } 1025 }
1017 } 1026 }
@@ -1022,7 +1031,7 @@ static void cfi_staa_sync (struct mtd_info *mtd)
1022 chip = &cfi->chips[i]; 1031 chip = &cfi->chips[i];
1023 1032
1024 spin_lock_bh(chip->mutex); 1033 spin_lock_bh(chip->mutex);
1025 1034
1026 if (chip->state == FL_SYNCING) { 1035 if (chip->state == FL_SYNCING) {
1027 chip->state = chip->oldstate; 1036 chip->state = chip->oldstate;
1028 wake_up(&chip->wq); 1037 wake_up(&chip->wq);
@@ -1057,9 +1066,9 @@ retry:
1057 1066
1058 case FL_STATUS: 1067 case FL_STATUS:
1059 status = map_read(map, adr); 1068 status = map_read(map, adr);
1060 if (map_word_andequal(map, status, status_OK, status_OK)) 1069 if (map_word_andequal(map, status, status_OK, status_OK))
1061 break; 1070 break;
1062 1071
1063 /* Urgh. Chip not yet ready to talk to us. */ 1072 /* Urgh. Chip not yet ready to talk to us. */
1064 if (time_after(jiffies, timeo)) { 1073 if (time_after(jiffies, timeo)) {
1065 spin_unlock_bh(chip->mutex); 1074 spin_unlock_bh(chip->mutex);
@@ -1088,7 +1097,7 @@ retry:
1088 map_write(map, CMD(0x60), adr); 1097 map_write(map, CMD(0x60), adr);
1089 map_write(map, CMD(0x01), adr); 1098 map_write(map, CMD(0x01), adr);
1090 chip->state = FL_LOCKING; 1099 chip->state = FL_LOCKING;
1091 1100
1092 spin_unlock_bh(chip->mutex); 1101 spin_unlock_bh(chip->mutex);
1093 msleep(1000); 1102 msleep(1000);
1094 spin_lock_bh(chip->mutex); 1103 spin_lock_bh(chip->mutex);
@@ -1102,7 +1111,7 @@ retry:
1102 status = map_read(map, adr); 1111 status = map_read(map, adr);
1103 if (map_word_andequal(map, status, status_OK, status_OK)) 1112 if (map_word_andequal(map, status, status_OK, status_OK))
1104 break; 1113 break;
1105 1114
1106 /* OK Still waiting */ 1115 /* OK Still waiting */
1107 if (time_after(jiffies, timeo)) { 1116 if (time_after(jiffies, timeo)) {
1108 map_write(map, CMD(0x70), adr); 1117 map_write(map, CMD(0x70), adr);
@@ -1112,13 +1121,13 @@ retry:
1112 spin_unlock_bh(chip->mutex); 1121 spin_unlock_bh(chip->mutex);
1113 return -EIO; 1122 return -EIO;
1114 } 1123 }
1115 1124
1116 /* Latency issues. Drop the lock, wait a while and retry */ 1125 /* Latency issues. Drop the lock, wait a while and retry */
1117 spin_unlock_bh(chip->mutex); 1126 spin_unlock_bh(chip->mutex);
1118 cfi_udelay(1); 1127 cfi_udelay(1);
1119 spin_lock_bh(chip->mutex); 1128 spin_lock_bh(chip->mutex);
1120 } 1129 }
1121 1130
1122 /* Done and happy. */ 1131 /* Done and happy. */
1123 chip->state = FL_STATUS; 1132 chip->state = FL_STATUS;
1124 DISABLE_VPP(map); 1133 DISABLE_VPP(map);
@@ -1162,8 +1171,8 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
1162 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); 1171 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
1163 printk("after lock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor))); 1172 printk("after lock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor)));
1164 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); 1173 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
1165#endif 1174#endif
1166 1175
1167 if (ret) 1176 if (ret)
1168 return ret; 1177 return ret;
1169 1178
@@ -1173,7 +1182,7 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
1173 if (adr >> cfi->chipshift) { 1182 if (adr >> cfi->chipshift) {
1174 adr = 0; 1183 adr = 0;
1175 chipnum++; 1184 chipnum++;
1176 1185
1177 if (chipnum >= cfi->numchips) 1186 if (chipnum >= cfi->numchips)
1178 break; 1187 break;
1179 } 1188 }
@@ -1208,7 +1217,7 @@ retry:
1208 status = map_read(map, adr); 1217 status = map_read(map, adr);
1209 if (map_word_andequal(map, status, status_OK, status_OK)) 1218 if (map_word_andequal(map, status, status_OK, status_OK))
1210 break; 1219 break;
1211 1220
1212 /* Urgh. Chip not yet ready to talk to us. */ 1221 /* Urgh. Chip not yet ready to talk to us. */
1213 if (time_after(jiffies, timeo)) { 1222 if (time_after(jiffies, timeo)) {
1214 spin_unlock_bh(chip->mutex); 1223 spin_unlock_bh(chip->mutex);
@@ -1237,7 +1246,7 @@ retry:
1237 map_write(map, CMD(0x60), adr); 1246 map_write(map, CMD(0x60), adr);
1238 map_write(map, CMD(0xD0), adr); 1247 map_write(map, CMD(0xD0), adr);
1239 chip->state = FL_UNLOCKING; 1248 chip->state = FL_UNLOCKING;
1240 1249
1241 spin_unlock_bh(chip->mutex); 1250 spin_unlock_bh(chip->mutex);
1242 msleep(1000); 1251 msleep(1000);
1243 spin_lock_bh(chip->mutex); 1252 spin_lock_bh(chip->mutex);
@@ -1251,7 +1260,7 @@ retry:
1251 status = map_read(map, adr); 1260 status = map_read(map, adr);
1252 if (map_word_andequal(map, status, status_OK, status_OK)) 1261 if (map_word_andequal(map, status, status_OK, status_OK))
1253 break; 1262 break;
1254 1263
1255 /* OK Still waiting */ 1264 /* OK Still waiting */
1256 if (time_after(jiffies, timeo)) { 1265 if (time_after(jiffies, timeo)) {
1257 map_write(map, CMD(0x70), adr); 1266 map_write(map, CMD(0x70), adr);
@@ -1261,13 +1270,13 @@ retry:
1261 spin_unlock_bh(chip->mutex); 1270 spin_unlock_bh(chip->mutex);
1262 return -EIO; 1271 return -EIO;
1263 } 1272 }
1264 1273
1265 /* Latency issues. Drop the unlock, wait a while and retry */ 1274 /* Latency issues. Drop the unlock, wait a while and retry */
1266 spin_unlock_bh(chip->mutex); 1275 spin_unlock_bh(chip->mutex);
1267 cfi_udelay(1); 1276 cfi_udelay(1);
1268 spin_lock_bh(chip->mutex); 1277 spin_lock_bh(chip->mutex);
1269 } 1278 }
1270 1279
1271 /* Done and happy. */ 1280 /* Done and happy. */
1272 chip->state = FL_STATUS; 1281 chip->state = FL_STATUS;
1273 DISABLE_VPP(map); 1282 DISABLE_VPP(map);
@@ -1292,7 +1301,7 @@ static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1292 { 1301 {
1293 unsigned long temp_adr = adr; 1302 unsigned long temp_adr = adr;
1294 unsigned long temp_len = len; 1303 unsigned long temp_len = len;
1295 1304
1296 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); 1305 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
1297 while (temp_len) { 1306 while (temp_len) {
1298 printk("before unlock %x: block status register is %x\n",temp_adr,cfi_read_query(map, temp_adr+(2*ofs_factor))); 1307 printk("before unlock %x: block status register is %x\n",temp_adr,cfi_read_query(map, temp_adr+(2*ofs_factor)));
@@ -1310,7 +1319,7 @@ static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1310 printk("after unlock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor))); 1319 printk("after unlock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor)));
1311 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); 1320 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
1312#endif 1321#endif
1313 1322
1314 return ret; 1323 return ret;
1315} 1324}
1316 1325
@@ -1334,7 +1343,7 @@ static int cfi_staa_suspend(struct mtd_info *mtd)
1334 case FL_JEDEC_QUERY: 1343 case FL_JEDEC_QUERY:
1335 chip->oldstate = chip->state; 1344 chip->oldstate = chip->state;
1336 chip->state = FL_PM_SUSPENDED; 1345 chip->state = FL_PM_SUSPENDED;
1337 /* No need to wake_up() on this state change - 1346 /* No need to wake_up() on this state change -
1338 * as the whole point is that nobody can do anything 1347 * as the whole point is that nobody can do anything
1339 * with the chip now anyway. 1348 * with the chip now anyway.
1340 */ 1349 */
@@ -1353,9 +1362,9 @@ static int cfi_staa_suspend(struct mtd_info *mtd)
1353 if (ret) { 1362 if (ret) {
1354 for (i--; i >=0; i--) { 1363 for (i--; i >=0; i--) {
1355 chip = &cfi->chips[i]; 1364 chip = &cfi->chips[i];
1356 1365
1357 spin_lock_bh(chip->mutex); 1366 spin_lock_bh(chip->mutex);
1358 1367
1359 if (chip->state == FL_PM_SUSPENDED) { 1368 if (chip->state == FL_PM_SUSPENDED) {
1360 /* No need to force it into a known state here, 1369 /* No need to force it into a known state here,
1361 because we're returning failure, and it didn't 1370 because we're returning failure, and it didn't
@@ -1365,8 +1374,8 @@ static int cfi_staa_suspend(struct mtd_info *mtd)
1365 } 1374 }
1366 spin_unlock_bh(chip->mutex); 1375 spin_unlock_bh(chip->mutex);
1367 } 1376 }
1368 } 1377 }
1369 1378
1370 return ret; 1379 return ret;
1371} 1380}
1372 1381
@@ -1378,11 +1387,11 @@ static void cfi_staa_resume(struct mtd_info *mtd)
1378 struct flchip *chip; 1387 struct flchip *chip;
1379 1388
1380 for (i=0; i<cfi->numchips; i++) { 1389 for (i=0; i<cfi->numchips; i++) {
1381 1390
1382 chip = &cfi->chips[i]; 1391 chip = &cfi->chips[i];
1383 1392
1384 spin_lock_bh(chip->mutex); 1393 spin_lock_bh(chip->mutex);
1385 1394
1386 /* Go to known state. Chip may have been power cycled */ 1395 /* Go to known state. Chip may have been power cycled */
1387 if (chip->state == FL_PM_SUSPENDED) { 1396 if (chip->state == FL_PM_SUSPENDED) {
1388 map_write(map, CMD(0xFF), 0); 1397 map_write(map, CMD(0xFF), 0);
diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c
index cf750038ce6a..90eb30e06b7c 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.83 2004/11/16 18:19:02 nico Exp $ 4 $Id: cfi_probe.c,v 1.84 2005/11/07 11:14:23 gleixner Exp $
5*/ 5*/
6 6
7#include <linux/config.h> 7#include <linux/config.h>
@@ -20,7 +20,7 @@
20#include <linux/mtd/cfi.h> 20#include <linux/mtd/cfi.h>
21#include <linux/mtd/gen_probe.h> 21#include <linux/mtd/gen_probe.h>
22 22
23//#define DEBUG_CFI 23//#define DEBUG_CFI
24 24
25#ifdef DEBUG_CFI 25#ifdef DEBUG_CFI
26static void print_cfi_ident(struct cfi_ident *); 26static void print_cfi_ident(struct cfi_ident *);
@@ -103,7 +103,7 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
103 unsigned long *chip_map, struct cfi_private *cfi) 103 unsigned long *chip_map, struct cfi_private *cfi)
104{ 104{
105 int i; 105 int i;
106 106
107 if ((base + 0) >= map->size) { 107 if ((base + 0) >= map->size) {
108 printk(KERN_NOTICE 108 printk(KERN_NOTICE
109 "Probe at base[0x00](0x%08lx) past the end of the map(0x%08lx)\n", 109 "Probe at base[0x00](0x%08lx) past the end of the map(0x%08lx)\n",
@@ -128,7 +128,7 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
128 } 128 }
129 129
130 if (!cfi->numchips) { 130 if (!cfi->numchips) {
131 /* This is the first time we're called. Set up the CFI 131 /* This is the first time we're called. Set up the CFI
132 stuff accordingly and return */ 132 stuff accordingly and return */
133 return cfi_chip_setup(map, cfi); 133 return cfi_chip_setup(map, cfi);
134 } 134 }
@@ -138,13 +138,13 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
138 unsigned long start; 138 unsigned long start;
139 if(!test_bit(i, chip_map)) { 139 if(!test_bit(i, chip_map)) {
140 /* Skip location; no valid chip at this address */ 140 /* Skip location; no valid chip at this address */
141 continue; 141 continue;
142 } 142 }
143 start = i << cfi->chipshift; 143 start = i << cfi->chipshift;
144 /* This chip should be in read mode if it's one 144 /* This chip should be in read mode if it's one
145 we've already touched. */ 145 we've already touched. */
146 if (qry_present(map, start, cfi)) { 146 if (qry_present(map, start, cfi)) {
147 /* Eep. This chip also had the QRY marker. 147 /* Eep. This chip also had the QRY marker.
148 * Is it an alias for the new one? */ 148 * Is it an alias for the new one? */
149 cfi_send_gen_cmd(0xF0, 0, start, map, cfi, cfi->device_type, NULL); 149 cfi_send_gen_cmd(0xF0, 0, start, map, cfi, cfi->device_type, NULL);
150 cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL); 150 cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL);
@@ -156,13 +156,13 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
156 map->name, base, start); 156 map->name, base, start);
157 return 0; 157 return 0;
158 } 158 }
159 /* Yes, it's actually got QRY for data. Most 159 /* Yes, it's actually got QRY for data. Most
160 * unfortunate. Stick the new chip in read mode 160 * unfortunate. Stick the new chip in read mode
161 * too and if it's the same, assume it's an alias. */ 161 * too and if it's the same, assume it's an alias. */
162 /* FIXME: Use other modes to do a proper check */ 162 /* FIXME: Use other modes to do a proper check */
163 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); 163 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
164 cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL); 164 cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL);
165 165
166 if (qry_present(map, base, cfi)) { 166 if (qry_present(map, base, cfi)) {
167 xip_allowed(base, map); 167 xip_allowed(base, map);
168 printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n", 168 printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n",
@@ -171,12 +171,12 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
171 } 171 }
172 } 172 }
173 } 173 }
174 174
175 /* OK, if we got to here, then none of the previous chips appear to 175 /* OK, if we got to here, then none of the previous chips appear to
176 be aliases for the current one. */ 176 be aliases for the current one. */
177 set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */ 177 set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */
178 cfi->numchips++; 178 cfi->numchips++;
179 179
180 /* Put it back into Read Mode */ 180 /* Put it back into Read Mode */
181 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); 181 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
182 cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); 182 cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
@@ -185,11 +185,11 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
185 printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", 185 printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n",
186 map->name, cfi->interleave, cfi->device_type*8, base, 186 map->name, cfi->interleave, cfi->device_type*8, base,
187 map->bankwidth*8); 187 map->bankwidth*8);
188 188
189 return 1; 189 return 1;
190} 190}
191 191
192static int __xipram cfi_chip_setup(struct map_info *map, 192static int __xipram cfi_chip_setup(struct map_info *map,
193 struct cfi_private *cfi) 193 struct cfi_private *cfi)
194{ 194{
195 int ofs_factor = cfi->interleave*cfi->device_type; 195 int ofs_factor = cfi->interleave*cfi->device_type;
@@ -209,11 +209,11 @@ static int __xipram cfi_chip_setup(struct map_info *map,
209 printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name); 209 printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name);
210 return 0; 210 return 0;
211 } 211 }
212 212
213 memset(cfi->cfiq,0,sizeof(struct cfi_ident)); 213 memset(cfi->cfiq,0,sizeof(struct cfi_ident));
214 214
215 cfi->cfi_mode = CFI_MODE_CFI; 215 cfi->cfi_mode = CFI_MODE_CFI;
216 216
217 /* Read the CFI info structure */ 217 /* Read the CFI info structure */
218 xip_disable_qry(base, map, cfi); 218 xip_disable_qry(base, map, cfi);
219 for (i=0; i<(sizeof(struct cfi_ident) + num_erase_regions * 4); i++) 219 for (i=0; i<(sizeof(struct cfi_ident) + num_erase_regions * 4); i++)
@@ -231,7 +231,7 @@ static int __xipram cfi_chip_setup(struct map_info *map,
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_query(map, base);
234 cfi->id = cfi_read_query(map, base + ofs_factor); 234 cfi->id = cfi_read_query(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);
@@ -255,10 +255,10 @@ static int __xipram cfi_chip_setup(struct map_info *map,
255 255
256 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { 256 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
257 cfi->cfiq->EraseRegionInfo[i] = le32_to_cpu(cfi->cfiq->EraseRegionInfo[i]); 257 cfi->cfiq->EraseRegionInfo[i] = le32_to_cpu(cfi->cfiq->EraseRegionInfo[i]);
258 258
259#ifdef DEBUG_CFI 259#ifdef DEBUG_CFI
260 printk(" Erase Region #%d: BlockSize 0x%4.4X bytes, %d blocks\n", 260 printk(" Erase Region #%d: BlockSize 0x%4.4X bytes, %d blocks\n",
261 i, (cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff, 261 i, (cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff,
262 (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1); 262 (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1);
263#endif 263#endif
264 } 264 }
@@ -271,33 +271,33 @@ static int __xipram cfi_chip_setup(struct map_info *map,
271} 271}
272 272
273#ifdef DEBUG_CFI 273#ifdef DEBUG_CFI
274static char *vendorname(__u16 vendor) 274static char *vendorname(__u16 vendor)
275{ 275{
276 switch (vendor) { 276 switch (vendor) {
277 case P_ID_NONE: 277 case P_ID_NONE:
278 return "None"; 278 return "None";
279 279
280 case P_ID_INTEL_EXT: 280 case P_ID_INTEL_EXT:
281 return "Intel/Sharp Extended"; 281 return "Intel/Sharp Extended";
282 282
283 case P_ID_AMD_STD: 283 case P_ID_AMD_STD:
284 return "AMD/Fujitsu Standard"; 284 return "AMD/Fujitsu Standard";
285 285
286 case P_ID_INTEL_STD: 286 case P_ID_INTEL_STD:
287 return "Intel/Sharp Standard"; 287 return "Intel/Sharp Standard";
288 288
289 case P_ID_AMD_EXT: 289 case P_ID_AMD_EXT:
290 return "AMD/Fujitsu Extended"; 290 return "AMD/Fujitsu Extended";
291 291
292 case P_ID_WINBOND: 292 case P_ID_WINBOND:
293 return "Winbond Standard"; 293 return "Winbond Standard";
294 294
295 case P_ID_ST_ADV: 295 case P_ID_ST_ADV:
296 return "ST Advanced"; 296 return "ST Advanced";
297 297
298 case P_ID_MITSUBISHI_STD: 298 case P_ID_MITSUBISHI_STD:
299 return "Mitsubishi Standard"; 299 return "Mitsubishi Standard";
300 300
301 case P_ID_MITSUBISHI_EXT: 301 case P_ID_MITSUBISHI_EXT:
302 return "Mitsubishi Extended"; 302 return "Mitsubishi Extended";
303 303
@@ -306,13 +306,13 @@ static char *vendorname(__u16 vendor)
306 306
307 case P_ID_INTEL_PERFORMANCE: 307 case P_ID_INTEL_PERFORMANCE:
308 return "Intel Performance Code"; 308 return "Intel Performance Code";
309 309
310 case P_ID_INTEL_DATA: 310 case P_ID_INTEL_DATA:
311 return "Intel Data"; 311 return "Intel Data";
312 312
313 case P_ID_RESERVED: 313 case P_ID_RESERVED:
314 return "Not Allowed / Reserved for Future Use"; 314 return "Not Allowed / Reserved for Future Use";
315 315
316 default: 316 default:
317 return "Unknown"; 317 return "Unknown";
318 } 318 }
@@ -325,21 +325,21 @@ static void print_cfi_ident(struct cfi_ident *cfip)
325 if (cfip->qry[0] != 'Q' || cfip->qry[1] != 'R' || cfip->qry[2] != 'Y') { 325 if (cfip->qry[0] != 'Q' || cfip->qry[1] != 'R' || cfip->qry[2] != 'Y') {
326 printk("Invalid CFI ident structure.\n"); 326 printk("Invalid CFI ident structure.\n");
327 return; 327 return;
328 } 328 }
329#endif 329#endif
330 printk("Primary Vendor Command Set: %4.4X (%s)\n", cfip->P_ID, vendorname(cfip->P_ID)); 330 printk("Primary Vendor Command Set: %4.4X (%s)\n", cfip->P_ID, vendorname(cfip->P_ID));
331 if (cfip->P_ADR) 331 if (cfip->P_ADR)
332 printk("Primary Algorithm Table at %4.4X\n", cfip->P_ADR); 332 printk("Primary Algorithm Table at %4.4X\n", cfip->P_ADR);
333 else 333 else
334 printk("No Primary Algorithm Table\n"); 334 printk("No Primary Algorithm Table\n");
335 335
336 printk("Alternative Vendor Command Set: %4.4X (%s)\n", cfip->A_ID, vendorname(cfip->A_ID)); 336 printk("Alternative Vendor Command Set: %4.4X (%s)\n", cfip->A_ID, vendorname(cfip->A_ID));
337 if (cfip->A_ADR) 337 if (cfip->A_ADR)
338 printk("Alternate Algorithm Table at %4.4X\n", cfip->A_ADR); 338 printk("Alternate Algorithm Table at %4.4X\n", cfip->A_ADR);
339 else 339 else
340 printk("No Alternate Algorithm Table\n"); 340 printk("No Alternate Algorithm Table\n");
341 341
342 342
343 printk("Vcc Minimum: %2d.%d V\n", cfip->VccMin >> 4, cfip->VccMin & 0xf); 343 printk("Vcc Minimum: %2d.%d V\n", cfip->VccMin >> 4, cfip->VccMin & 0xf);
344 printk("Vcc Maximum: %2d.%d V\n", cfip->VccMax >> 4, cfip->VccMax & 0xf); 344 printk("Vcc Maximum: %2d.%d V\n", cfip->VccMax >> 4, cfip->VccMax & 0xf);
345 if (cfip->VppMin) { 345 if (cfip->VppMin) {
@@ -348,61 +348,61 @@ static void print_cfi_ident(struct cfi_ident *cfip)
348 } 348 }
349 else 349 else
350 printk("No Vpp line\n"); 350 printk("No Vpp line\n");
351 351
352 printk("Typical byte/word write timeout: %d µs\n", 1<<cfip->WordWriteTimeoutTyp); 352 printk("Typical byte/word write timeout: %d µs\n", 1<<cfip->WordWriteTimeoutTyp);
353 printk("Maximum byte/word write timeout: %d µs\n", (1<<cfip->WordWriteTimeoutMax) * (1<<cfip->WordWriteTimeoutTyp)); 353 printk("Maximum byte/word write timeout: %d µs\n", (1<<cfip->WordWriteTimeoutMax) * (1<<cfip->WordWriteTimeoutTyp));
354 354
355 if (cfip->BufWriteTimeoutTyp || cfip->BufWriteTimeoutMax) { 355 if (cfip->BufWriteTimeoutTyp || cfip->BufWriteTimeoutMax) {
356 printk("Typical full buffer write timeout: %d µs\n", 1<<cfip->BufWriteTimeoutTyp); 356 printk("Typical full buffer write timeout: %d µs\n", 1<<cfip->BufWriteTimeoutTyp);
357 printk("Maximum full buffer write timeout: %d µs\n", (1<<cfip->BufWriteTimeoutMax) * (1<<cfip->BufWriteTimeoutTyp)); 357 printk("Maximum full buffer write timeout: %d µs\n", (1<<cfip->BufWriteTimeoutMax) * (1<<cfip->BufWriteTimeoutTyp));
358 } 358 }
359 else 359 else
360 printk("Full buffer write not supported\n"); 360 printk("Full buffer write not supported\n");
361 361
362 printk("Typical block erase timeout: %d ms\n", 1<<cfip->BlockEraseTimeoutTyp); 362 printk("Typical block erase timeout: %d ms\n", 1<<cfip->BlockEraseTimeoutTyp);
363 printk("Maximum block erase timeout: %d ms\n", (1<<cfip->BlockEraseTimeoutMax) * (1<<cfip->BlockEraseTimeoutTyp)); 363 printk("Maximum block erase timeout: %d ms\n", (1<<cfip->BlockEraseTimeoutMax) * (1<<cfip->BlockEraseTimeoutTyp));
364 if (cfip->ChipEraseTimeoutTyp || cfip->ChipEraseTimeoutMax) { 364 if (cfip->ChipEraseTimeoutTyp || cfip->ChipEraseTimeoutMax) {
365 printk("Typical chip erase timeout: %d ms\n", 1<<cfip->ChipEraseTimeoutTyp); 365 printk("Typical chip erase timeout: %d ms\n", 1<<cfip->ChipEraseTimeoutTyp);
366 printk("Maximum chip erase timeout: %d ms\n", (1<<cfip->ChipEraseTimeoutMax) * (1<<cfip->ChipEraseTimeoutTyp)); 366 printk("Maximum chip erase timeout: %d ms\n", (1<<cfip->ChipEraseTimeoutMax) * (1<<cfip->ChipEraseTimeoutTyp));
367 } 367 }
368 else 368 else
369 printk("Chip erase not supported\n"); 369 printk("Chip erase not supported\n");
370 370
371 printk("Device size: 0x%X bytes (%d MiB)\n", 1 << cfip->DevSize, 1<< (cfip->DevSize - 20)); 371 printk("Device size: 0x%X bytes (%d MiB)\n", 1 << cfip->DevSize, 1<< (cfip->DevSize - 20));
372 printk("Flash Device Interface description: 0x%4.4X\n", cfip->InterfaceDesc); 372 printk("Flash Device Interface description: 0x%4.4X\n", cfip->InterfaceDesc);
373 switch(cfip->InterfaceDesc) { 373 switch(cfip->InterfaceDesc) {
374 case 0: 374 case 0:
375 printk(" - x8-only asynchronous interface\n"); 375 printk(" - x8-only asynchronous interface\n");
376 break; 376 break;
377 377
378 case 1: 378 case 1:
379 printk(" - x16-only asynchronous interface\n"); 379 printk(" - x16-only asynchronous interface\n");
380 break; 380 break;
381 381
382 case 2: 382 case 2:
383 printk(" - supports x8 and x16 via BYTE# with asynchronous interface\n"); 383 printk(" - supports x8 and x16 via BYTE# with asynchronous interface\n");
384 break; 384 break;
385 385
386 case 3: 386 case 3:
387 printk(" - x32-only asynchronous interface\n"); 387 printk(" - x32-only asynchronous interface\n");
388 break; 388 break;
389 389
390 case 4: 390 case 4:
391 printk(" - supports x16 and x32 via Word# with asynchronous interface\n"); 391 printk(" - supports x16 and x32 via Word# with asynchronous interface\n");
392 break; 392 break;
393 393
394 case 65535: 394 case 65535:
395 printk(" - Not Allowed / Reserved\n"); 395 printk(" - Not Allowed / Reserved\n");
396 break; 396 break;
397 397
398 default: 398 default:
399 printk(" - Unknown\n"); 399 printk(" - Unknown\n");
400 break; 400 break;
401 } 401 }
402 402
403 printk("Max. bytes in buffer write: 0x%x\n", 1<< cfip->MaxBufWriteSize); 403 printk("Max. bytes in buffer write: 0x%x\n", 1<< cfip->MaxBufWriteSize);
404 printk("Number of Erase Block Regions: %d\n", cfip->NumEraseRegions); 404 printk("Number of Erase Block Regions: %d\n", cfip->NumEraseRegions);
405 405
406} 406}
407#endif /* DEBUG_CFI */ 407#endif /* DEBUG_CFI */
408 408
diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c
index 2b2ede2bfcca..d8e7a026ba5a 100644
--- a/drivers/mtd/chips/cfi_util.c
+++ b/drivers/mtd/chips/cfi_util.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * This code is covered by the GPL. 8 * This code is covered by the GPL.
9 * 9 *
10 * $Id: cfi_util.c,v 1.8 2004/12/14 19:55:56 nico Exp $ 10 * $Id: cfi_util.c,v 1.10 2005/11/07 11:14:23 gleixner Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -56,7 +56,7 @@ __xipram cfi_read_pri(struct map_info *map, __u16 adr, __u16 size, const char* n
56 56
57 /* Read in the Extended Query Table */ 57 /* Read in the Extended Query Table */
58 for (i=0; i<size; i++) { 58 for (i=0; i<size; i++) {
59 ((unsigned char *)extp)[i] = 59 ((unsigned char *)extp)[i] =
60 cfi_read_query(map, base+((adr+i)*ofs_factor)); 60 cfi_read_query(map, base+((adr+i)*ofs_factor));
61 } 61 }
62 62
@@ -70,15 +70,6 @@ __xipram cfi_read_pri(struct map_info *map, __u16 adr, __u16 size, const char* n
70 local_irq_enable(); 70 local_irq_enable();
71#endif 71#endif
72 72
73 if (extp->MajorVersion != '1' ||
74 (extp->MinorVersion < '0' || extp->MinorVersion > '3')) {
75 printk(KERN_WARNING " Unknown %s Extended Query "
76 "version %c.%c.\n", name, extp->MajorVersion,
77 extp->MinorVersion);
78 kfree(extp);
79 extp = NULL;
80 }
81
82 out: return extp; 73 out: return extp;
83} 74}
84 75
@@ -122,17 +113,17 @@ int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
122 113
123 i = 0; 114 i = 0;
124 115
125 /* Skip all erase regions which are ended before the start of 116 /* Skip all erase regions which are ended before the start of
126 the requested erase. Actually, to save on the calculations, 117 the requested erase. Actually, to save on the calculations,
127 we skip to the first erase region which starts after the 118 we skip to the first erase region which starts after the
128 start of the requested erase, and then go back one. 119 start of the requested erase, and then go back one.
129 */ 120 */
130 121
131 while (i < mtd->numeraseregions && ofs >= regions[i].offset) 122 while (i < mtd->numeraseregions && ofs >= regions[i].offset)
132 i++; 123 i++;
133 i--; 124 i--;
134 125
135 /* OK, now i is pointing at the erase region in which this 126 /* OK, now i is pointing at the erase region in which this
136 erase request starts. Check the start of the requested 127 erase request starts. Check the start of the requested
137 erase range is aligned with the erase size which is in 128 erase range is aligned with the erase size which is in
138 effect here. 129 effect here.
@@ -155,7 +146,7 @@ int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
155 the address actually falls 146 the address actually falls
156 */ 147 */
157 i--; 148 i--;
158 149
159 if ((ofs + len) & (regions[i].erasesize-1)) 150 if ((ofs + len) & (regions[i].erasesize-1))
160 return -EINVAL; 151 return -EINVAL;
161 152
@@ -168,7 +159,7 @@ int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
168 int size = regions[i].erasesize; 159 int size = regions[i].erasesize;
169 160
170 ret = (*frob)(map, &cfi->chips[chipnum], adr, size, thunk); 161 ret = (*frob)(map, &cfi->chips[chipnum], adr, size, thunk);
171 162
172 if (ret) 163 if (ret)
173 return ret; 164 return ret;
174 165
@@ -182,7 +173,7 @@ int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
182 if (adr >> cfi->chipshift) { 173 if (adr >> cfi->chipshift) {
183 adr = 0; 174 adr = 0;
184 chipnum++; 175 chipnum++;
185 176
186 if (chipnum >= cfi->numchips) 177 if (chipnum >= cfi->numchips)
187 break; 178 break;
188 } 179 }
diff --git a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c
index d7d739a108ae..c2127840a183 100644
--- a/drivers/mtd/chips/chipreg.c
+++ b/drivers/mtd/chips/chipreg.c
@@ -41,7 +41,7 @@ static struct mtd_chip_driver *get_mtd_chip_driver (const char *name)
41 41
42 list_for_each(pos, &chip_drvs_list) { 42 list_for_each(pos, &chip_drvs_list) {
43 this = list_entry(pos, typeof(*this), list); 43 this = list_entry(pos, typeof(*this), list);
44 44
45 if (!strcmp(this->name, name)) { 45 if (!strcmp(this->name, name)) {
46 ret = this; 46 ret = this;
47 break; 47 break;
@@ -73,7 +73,7 @@ struct mtd_info *do_map_probe(const char *name, struct map_info *map)
73 73
74 ret = drv->probe(map); 74 ret = drv->probe(map);
75 75
76 /* We decrease the use count here. It may have been a 76 /* We decrease the use count here. It may have been a
77 probe-only module, which is no longer required from this 77 probe-only module, which is no longer required from this
78 point, having given us a handle on (and increased the use 78 point, having given us a handle on (and increased the use
79 count of) the actual driver code. 79 count of) the actual driver code.
@@ -82,7 +82,7 @@ struct mtd_info *do_map_probe(const char *name, struct map_info *map)
82 82
83 if (ret) 83 if (ret)
84 return ret; 84 return ret;
85 85
86 return NULL; 86 return NULL;
87} 87}
88/* 88/*
diff --git a/drivers/mtd/chips/fwh_lock.h b/drivers/mtd/chips/fwh_lock.h
index e1a5b76596c5..77303ce5dcf1 100644
--- a/drivers/mtd/chips/fwh_lock.h
+++ b/drivers/mtd/chips/fwh_lock.h
@@ -25,7 +25,7 @@ struct fwh_xxlock_thunk {
25 * so this code has not been tested with interleaved chips, 25 * so this code has not been tested with interleaved chips,
26 * and will likely fail in that context. 26 * and will likely fail in that context.
27 */ 27 */
28static int fwh_xxlock_oneblock(struct map_info *map, struct flchip *chip, 28static int fwh_xxlock_oneblock(struct map_info *map, struct flchip *chip,
29 unsigned long adr, int len, void *thunk) 29 unsigned long adr, int len, void *thunk)
30{ 30{
31 struct cfi_private *cfi = map->fldrv_priv; 31 struct cfi_private *cfi = map->fldrv_priv;
@@ -44,7 +44,7 @@ static int fwh_xxlock_oneblock(struct map_info *map, struct flchip *chip,
44 * - on 64k boundariesand 44 * - on 64k boundariesand
45 * - bit 1 set high 45 * - bit 1 set high
46 * - block lock registers are 4MiB lower - overflow subtract (danger) 46 * - block lock registers are 4MiB lower - overflow subtract (danger)
47 * 47 *
48 * The address manipulation is first done on the logical address 48 * The address manipulation is first done on the logical address
49 * which is 0 at the start of the chip, and then the offset of 49 * which is 0 at the start of the chip, and then the offset of
50 * the individual chip is addted to it. Any other order a weird 50 * the individual chip is addted to it. Any other order a weird
@@ -93,7 +93,7 @@ static int fwh_unlock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len)
93 93
94 ret = cfi_varsize_frob(mtd, fwh_xxlock_oneblock, ofs, len, 94 ret = cfi_varsize_frob(mtd, fwh_xxlock_oneblock, ofs, len,
95 (void *)&FWH_XXLOCK_ONEBLOCK_UNLOCK); 95 (void *)&FWH_XXLOCK_ONEBLOCK_UNLOCK);
96 96
97 return ret; 97 return ret;
98} 98}
99 99
diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c
index dc065b22f79e..41bd59d20d85 100644
--- a/drivers/mtd/chips/gen_probe.c
+++ b/drivers/mtd/chips/gen_probe.c
@@ -2,7 +2,7 @@
2 * Routines common to all CFI-type probes. 2 * Routines common to all CFI-type probes.
3 * (C) 2001-2003 Red Hat, Inc. 3 * (C) 2001-2003 Red Hat, Inc.
4 * GPL'd 4 * GPL'd
5 * $Id: gen_probe.c,v 1.22 2005/01/24 23:49:50 rmk Exp $ 5 * $Id: gen_probe.c,v 1.24 2005/11/07 11:14:23 gleixner Exp $
6 */ 6 */
7 7
8#include <linux/kernel.h> 8#include <linux/kernel.h>
@@ -26,7 +26,7 @@ struct mtd_info *mtd_do_chip_probe(struct map_info *map, struct chip_probe *cp)
26 26
27 /* First probe the map to see if we have CFI stuff there. */ 27 /* First probe the map to see if we have CFI stuff there. */
28 cfi = genprobe_ident_chips(map, cp); 28 cfi = genprobe_ident_chips(map, cp);
29 29
30 if (!cfi) 30 if (!cfi)
31 return NULL; 31 return NULL;
32 32
@@ -36,12 +36,12 @@ struct mtd_info *mtd_do_chip_probe(struct map_info *map, struct chip_probe *cp)
36 mtd = check_cmd_set(map, 1); /* First the primary cmdset */ 36 mtd = check_cmd_set(map, 1); /* First the primary cmdset */
37 if (!mtd) 37 if (!mtd)
38 mtd = check_cmd_set(map, 0); /* Then the secondary */ 38 mtd = check_cmd_set(map, 0); /* Then the secondary */
39 39
40 if (mtd) 40 if (mtd)
41 return mtd; 41 return mtd;
42 42
43 printk(KERN_WARNING"gen_probe: No supported Vendor Command Set found\n"); 43 printk(KERN_WARNING"gen_probe: No supported Vendor Command Set found\n");
44 44
45 kfree(cfi->cfiq); 45 kfree(cfi->cfiq);
46 kfree(cfi); 46 kfree(cfi);
47 map->fldrv_priv = NULL; 47 map->fldrv_priv = NULL;
@@ -60,14 +60,14 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi
60 60
61 memset(&cfi, 0, sizeof(cfi)); 61 memset(&cfi, 0, sizeof(cfi));
62 62
63 /* Call the probetype-specific code with all permutations of 63 /* Call the probetype-specific code with all permutations of
64 interleave and device type, etc. */ 64 interleave and device type, etc. */
65 if (!genprobe_new_chip(map, cp, &cfi)) { 65 if (!genprobe_new_chip(map, cp, &cfi)) {
66 /* The probe didn't like it */ 66 /* The probe didn't like it */
67 printk(KERN_DEBUG "%s: Found no %s device at location zero\n", 67 printk(KERN_DEBUG "%s: Found no %s device at location zero\n",
68 cp->name, map->name); 68 cp->name, map->name);
69 return NULL; 69 return NULL;
70 } 70 }
71 71
72#if 0 /* Let the CFI probe routine do this sanity check. The Intel and AMD 72#if 0 /* Let the CFI probe routine do this sanity check. The Intel and AMD
73 probe routines won't ever return a broken CFI structure anyway, 73 probe routines won't ever return a broken CFI structure anyway,
@@ -92,13 +92,13 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi
92 } else { 92 } else {
93 BUG(); 93 BUG();
94 } 94 }
95 95
96 cfi.numchips = 1; 96 cfi.numchips = 1;
97 97
98 /* 98 /*
99 * Allocate memory for bitmap of valid chips. 99 * Allocate memory for bitmap of valid chips.
100 * Align bitmap storage size to full byte. 100 * Align bitmap storage size to full byte.
101 */ 101 */
102 max_chips = map->size >> cfi.chipshift; 102 max_chips = map->size >> cfi.chipshift;
103 mapsize = (max_chips / 8) + ((max_chips % 8) ? 1 : 0); 103 mapsize = (max_chips / 8) + ((max_chips % 8) ? 1 : 0);
104 chip_map = kmalloc(mapsize, GFP_KERNEL); 104 chip_map = kmalloc(mapsize, GFP_KERNEL);
@@ -122,7 +122,7 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi
122 } 122 }
123 123
124 /* 124 /*
125 * Now allocate the space for the structures we need to return to 125 * Now allocate the space for the structures we need to return to
126 * our caller, and copy the appropriate data into them. 126 * our caller, and copy the appropriate data into them.
127 */ 127 */
128 128
@@ -154,7 +154,7 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi
154 return retcfi; 154 return retcfi;
155} 155}
156 156
157 157
158static int genprobe_new_chip(struct map_info *map, struct chip_probe *cp, 158static int genprobe_new_chip(struct map_info *map, struct chip_probe *cp,
159 struct cfi_private *cfi) 159 struct cfi_private *cfi)
160{ 160{
@@ -189,7 +189,7 @@ extern cfi_cmdset_fn_t cfi_cmdset_0001;
189extern cfi_cmdset_fn_t cfi_cmdset_0002; 189extern cfi_cmdset_fn_t cfi_cmdset_0002;
190extern cfi_cmdset_fn_t cfi_cmdset_0020; 190extern cfi_cmdset_fn_t cfi_cmdset_0020;
191 191
192static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map, 192static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map,
193 int primary) 193 int primary)
194{ 194{
195 struct cfi_private *cfi = map->fldrv_priv; 195 struct cfi_private *cfi = map->fldrv_priv;
@@ -199,7 +199,7 @@ static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map,
199 cfi_cmdset_fn_t *probe_function; 199 cfi_cmdset_fn_t *probe_function;
200 200
201 sprintf(probename, "cfi_cmdset_%4.4X", type); 201 sprintf(probename, "cfi_cmdset_%4.4X", type);
202 202
203 probe_function = inter_module_get_request(probename, probename); 203 probe_function = inter_module_get_request(probename, probename);
204 204
205 if (probe_function) { 205 if (probe_function) {
@@ -221,7 +221,7 @@ static struct mtd_info *check_cmd_set(struct map_info *map, int primary)
221{ 221{
222 struct cfi_private *cfi = map->fldrv_priv; 222 struct cfi_private *cfi = map->fldrv_priv;
223 __u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID; 223 __u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;
224 224
225 if (type == P_ID_NONE || type == P_ID_RESERVED) 225 if (type == P_ID_NONE || type == P_ID_RESERVED)
226 return NULL; 226 return NULL;
227 227
@@ -235,6 +235,7 @@ static struct mtd_info *check_cmd_set(struct map_info *map, int primary)
235#ifdef CONFIG_MTD_CFI_INTELEXT 235#ifdef CONFIG_MTD_CFI_INTELEXT
236 case 0x0001: 236 case 0x0001:
237 case 0x0003: 237 case 0x0003:
238 case 0x0200:
238 return cfi_cmdset_0001(map, primary); 239 return cfi_cmdset_0001(map, primary);
239#endif 240#endif
240#ifdef CONFIG_MTD_CFI_AMDSTD 241#ifdef CONFIG_MTD_CFI_AMDSTD
diff --git a/drivers/mtd/chips/jedec.c b/drivers/mtd/chips/jedec.c
index 4f6778f3ee3e..c40b48dabed3 100644
--- a/drivers/mtd/chips/jedec.c
+++ b/drivers/mtd/chips/jedec.c
@@ -1,6 +1,6 @@
1 1
2/* JEDEC Flash Interface. 2/* JEDEC Flash Interface.
3 * This is an older type of interface for self programming flash. It is 3 * This is an older type of interface for self programming flash. It is
4 * commonly use in older AMD chips and is obsolete compared with CFI. 4 * commonly use in older AMD chips and is obsolete compared with CFI.
5 * It is called JEDEC because the JEDEC association distributes the ID codes 5 * It is called JEDEC because the JEDEC association distributes the ID codes
6 * for the chips. 6 * for the chips.
@@ -88,9 +88,9 @@ static const struct JEDECTable JEDEC_table[] = {
88 88
89static const struct JEDECTable *jedec_idtoinf(__u8 mfr,__u8 id); 89static const struct JEDECTable *jedec_idtoinf(__u8 mfr,__u8 id);
90static void jedec_sync(struct mtd_info *mtd) {}; 90static void jedec_sync(struct mtd_info *mtd) {};
91static int jedec_read(struct mtd_info *mtd, loff_t from, size_t len, 91static int jedec_read(struct mtd_info *mtd, loff_t from, size_t len,
92 size_t *retlen, u_char *buf); 92 size_t *retlen, u_char *buf);
93static int jedec_read_banked(struct mtd_info *mtd, loff_t from, size_t len, 93static int jedec_read_banked(struct mtd_info *mtd, loff_t from, size_t len,
94 size_t *retlen, u_char *buf); 94 size_t *retlen, u_char *buf);
95 95
96static struct mtd_info *jedec_probe(struct map_info *map); 96static struct mtd_info *jedec_probe(struct map_info *map);
@@ -122,7 +122,7 @@ static struct mtd_info *jedec_probe(struct map_info *map)
122 122
123 memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private)); 123 memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private));
124 priv = (struct jedec_private *)&MTD[1]; 124 priv = (struct jedec_private *)&MTD[1];
125 125
126 my_bank_size = map->size; 126 my_bank_size = map->size;
127 127
128 if (map->size/my_bank_size > MAX_JEDEC_CHIPS) 128 if (map->size/my_bank_size > MAX_JEDEC_CHIPS)
@@ -131,13 +131,13 @@ static struct mtd_info *jedec_probe(struct map_info *map)
131 kfree(MTD); 131 kfree(MTD);
132 return NULL; 132 return NULL;
133 } 133 }
134 134
135 for (Base = 0; Base < map->size; Base += my_bank_size) 135 for (Base = 0; Base < map->size; Base += my_bank_size)
136 { 136 {
137 // Perhaps zero could designate all tests? 137 // Perhaps zero could designate all tests?
138 if (map->buswidth == 0) 138 if (map->buswidth == 0)
139 map->buswidth = 1; 139 map->buswidth = 1;
140 140
141 if (map->buswidth == 1){ 141 if (map->buswidth == 1){
142 if (jedec_probe8(map,Base,priv) == 0) { 142 if (jedec_probe8(map,Base,priv) == 0) {
143 printk("did recognize jedec chip\n"); 143 printk("did recognize jedec chip\n");
@@ -150,7 +150,7 @@ static struct mtd_info *jedec_probe(struct map_info *map)
150 if (map->buswidth == 4) 150 if (map->buswidth == 4)
151 jedec_probe32(map,Base,priv); 151 jedec_probe32(map,Base,priv);
152 } 152 }
153 153
154 // Get the biggest sector size 154 // Get the biggest sector size
155 SectorSize = 0; 155 SectorSize = 0;
156 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) 156 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++)
@@ -160,7 +160,7 @@ static struct mtd_info *jedec_probe(struct map_info *map)
160 if (priv->chips[I].sectorsize > SectorSize) 160 if (priv->chips[I].sectorsize > SectorSize)
161 SectorSize = priv->chips[I].sectorsize; 161 SectorSize = priv->chips[I].sectorsize;
162 } 162 }
163 163
164 // Quickly ensure that the other sector sizes are factors of the largest 164 // Quickly ensure that the other sector sizes are factors of the largest
165 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) 165 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++)
166 { 166 {
@@ -169,9 +169,9 @@ static struct mtd_info *jedec_probe(struct map_info *map)
169 printk("mtd: Failed. Device has incompatible mixed sector sizes\n"); 169 printk("mtd: Failed. Device has incompatible mixed sector sizes\n");
170 kfree(MTD); 170 kfree(MTD);
171 return NULL; 171 return NULL;
172 } 172 }
173 } 173 }
174 174
175 /* Generate a part name that includes the number of different chips and 175 /* Generate a part name that includes the number of different chips and
176 other configuration information */ 176 other configuration information */
177 count = 1; 177 count = 1;
@@ -181,13 +181,13 @@ static struct mtd_info *jedec_probe(struct map_info *map)
181 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) 181 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++)
182 { 182 {
183 const struct JEDECTable *JEDEC; 183 const struct JEDECTable *JEDEC;
184 184
185 if (priv->chips[I+1].jedec == priv->chips[I].jedec) 185 if (priv->chips[I+1].jedec == priv->chips[I].jedec)
186 { 186 {
187 count++; 187 count++;
188 continue; 188 continue;
189 } 189 }
190 190
191 // Locate the chip in the jedec table 191 // Locate the chip in the jedec table
192 JEDEC = jedec_idtoinf(priv->chips[I].jedec >> 8,priv->chips[I].jedec); 192 JEDEC = jedec_idtoinf(priv->chips[I].jedec >> 8,priv->chips[I].jedec);
193 if (JEDEC == 0) 193 if (JEDEC == 0)
@@ -196,11 +196,11 @@ static struct mtd_info *jedec_probe(struct map_info *map)
196 kfree(MTD); 196 kfree(MTD);
197 return NULL; 197 return NULL;
198 } 198 }
199 199
200 if (Uniq != 0) 200 if (Uniq != 0)
201 strcat(Part,","); 201 strcat(Part,",");
202 Uniq++; 202 Uniq++;
203 203
204 if (count != 1) 204 if (count != 1)
205 sprintf(Part+strlen(Part),"%x*[%s]",count,JEDEC->name); 205 sprintf(Part+strlen(Part),"%x*[%s]",count,JEDEC->name);
206 else 206 else
@@ -208,7 +208,7 @@ static struct mtd_info *jedec_probe(struct map_info *map)
208 if (strlen(Part) > sizeof(Part)*2/3) 208 if (strlen(Part) > sizeof(Part)*2/3)
209 break; 209 break;
210 count = 1; 210 count = 1;
211 } 211 }
212 212
213 /* Determine if the chips are organized in a linear fashion, or if there 213 /* Determine if the chips are organized in a linear fashion, or if there
214 are empty banks. Note, the last bank does not count here, only the 214 are empty banks. Note, the last bank does not count here, only the
@@ -233,7 +233,7 @@ static struct mtd_info *jedec_probe(struct map_info *map)
233 { 233 {
234 if (priv->bank_fill[I] != my_bank_size) 234 if (priv->bank_fill[I] != my_bank_size)
235 priv->is_banked = 1; 235 priv->is_banked = 1;
236 236
237 /* This even could be eliminated, but new de-optimized read/write 237 /* This even could be eliminated, but new de-optimized read/write
238 functions have to be written */ 238 functions have to be written */
239 printk("priv->bank_fill[%d] is %lx, priv->bank_fill[0] is %lx\n",I,priv->bank_fill[I],priv->bank_fill[0]); 239 printk("priv->bank_fill[%d] is %lx, priv->bank_fill[0] is %lx\n",I,priv->bank_fill[I],priv->bank_fill[0]);
@@ -242,7 +242,7 @@ static struct mtd_info *jedec_probe(struct map_info *map)
242 printk("mtd: Failed. Cannot handle unsymmetric banking\n"); 242 printk("mtd: Failed. Cannot handle unsymmetric banking\n");
243 kfree(MTD); 243 kfree(MTD);
244 return NULL; 244 return NULL;
245 } 245 }
246 } 246 }
247 } 247 }
248 } 248 }
@@ -250,7 +250,7 @@ static struct mtd_info *jedec_probe(struct map_info *map)
250 strcat(Part,", banked"); 250 strcat(Part,", banked");
251 251
252 // printk("Part: '%s'\n",Part); 252 // printk("Part: '%s'\n",Part);
253 253
254 memset(MTD,0,sizeof(*MTD)); 254 memset(MTD,0,sizeof(*MTD));
255 // strlcpy(MTD->name,Part,sizeof(MTD->name)); 255 // strlcpy(MTD->name,Part,sizeof(MTD->name));
256 MTD->name = map->name; 256 MTD->name = map->name;
@@ -291,7 +291,7 @@ static int checkparity(u_char C)
291 291
292/* Take an array of JEDEC numbers that represent interleved flash chips 292/* Take an array of JEDEC numbers that represent interleved flash chips
293 and process them. Check to make sure they are good JEDEC numbers, look 293 and process them. Check to make sure they are good JEDEC numbers, look
294 them up and then add them to the chip list */ 294 them up and then add them to the chip list */
295static int handle_jedecs(struct map_info *map,__u8 *Mfg,__u8 *Id,unsigned Count, 295static int handle_jedecs(struct map_info *map,__u8 *Mfg,__u8 *Id,unsigned Count,
296 unsigned long base,struct jedec_private *priv) 296 unsigned long base,struct jedec_private *priv)
297{ 297{
@@ -306,16 +306,16 @@ static int handle_jedecs(struct map_info *map,__u8 *Mfg,__u8 *Id,unsigned Count,
306 if (checkparity(Mfg[I]) == 0 || checkparity(Id[I]) == 0) 306 if (checkparity(Mfg[I]) == 0 || checkparity(Id[I]) == 0)
307 return 0; 307 return 0;
308 } 308 }
309 309
310 // Finally, just make sure all the chip sizes are the same 310 // Finally, just make sure all the chip sizes are the same
311 JEDEC = jedec_idtoinf(Mfg[0],Id[0]); 311 JEDEC = jedec_idtoinf(Mfg[0],Id[0]);
312 312
313 if (JEDEC == 0) 313 if (JEDEC == 0)
314 { 314 {
315 printk("mtd: Found JEDEC flash chip, but do not have a table entry for %x:%x\n",Mfg[0],Mfg[1]); 315 printk("mtd: Found JEDEC flash chip, but do not have a table entry for %x:%x\n",Mfg[0],Mfg[1]);
316 return 0; 316 return 0;
317 } 317 }
318 318
319 Size = JEDEC->size; 319 Size = JEDEC->size;
320 SectorSize = JEDEC->sectorsize; 320 SectorSize = JEDEC->sectorsize;
321 for (I = 0; I != Count; I++) 321 for (I = 0; I != Count; I++)
@@ -331,7 +331,7 @@ static int handle_jedecs(struct map_info *map,__u8 *Mfg,__u8 *Id,unsigned Count,
331 { 331 {
332 printk("mtd: Failed. Interleved flash does not have matching characteristics\n"); 332 printk("mtd: Failed. Interleved flash does not have matching characteristics\n");
333 return 0; 333 return 0;
334 } 334 }
335 } 335 }
336 336
337 // Load the Chips 337 // Load the Chips
@@ -345,13 +345,13 @@ static int handle_jedecs(struct map_info *map,__u8 *Mfg,__u8 *Id,unsigned Count,
345 { 345 {
346 printk("mtd: Device has too many chips. Increase MAX_JEDEC_CHIPS\n"); 346 printk("mtd: Device has too many chips. Increase MAX_JEDEC_CHIPS\n");
347 return 0; 347 return 0;
348 } 348 }
349 349
350 // Add them to the table 350 // Add them to the table
351 for (J = 0; J != Count; J++) 351 for (J = 0; J != Count; J++)
352 { 352 {
353 unsigned long Bank; 353 unsigned long Bank;
354 354
355 JEDEC = jedec_idtoinf(Mfg[J],Id[J]); 355 JEDEC = jedec_idtoinf(Mfg[J],Id[J]);
356 priv->chips[I].jedec = (Mfg[J] << 8) | Id[J]; 356 priv->chips[I].jedec = (Mfg[J] << 8) | Id[J];
357 priv->chips[I].size = JEDEC->size; 357 priv->chips[I].size = JEDEC->size;
@@ -364,17 +364,17 @@ static int handle_jedecs(struct map_info *map,__u8 *Mfg,__u8 *Id,unsigned Count,
364 // log2 n :| 364 // log2 n :|
365 priv->chips[I].addrshift = 0; 365 priv->chips[I].addrshift = 0;
366 for (Bank = Count; Bank != 1; Bank >>= 1, priv->chips[I].addrshift++); 366 for (Bank = Count; Bank != 1; Bank >>= 1, priv->chips[I].addrshift++);
367 367
368 // Determine how filled this bank is. 368 // Determine how filled this bank is.
369 Bank = base & (~(my_bank_size-1)); 369 Bank = base & (~(my_bank_size-1));
370 if (priv->bank_fill[Bank/my_bank_size] < base + 370 if (priv->bank_fill[Bank/my_bank_size] < base +
371 (JEDEC->size << priv->chips[I].addrshift) - Bank) 371 (JEDEC->size << priv->chips[I].addrshift) - Bank)
372 priv->bank_fill[Bank/my_bank_size] = base + (JEDEC->size << priv->chips[I].addrshift) - Bank; 372 priv->bank_fill[Bank/my_bank_size] = base + (JEDEC->size << priv->chips[I].addrshift) - Bank;
373 I++; 373 I++;
374 } 374 }
375 375
376 priv->size += priv->chips[I-1].size*Count; 376 priv->size += priv->chips[I-1].size*Count;
377 377
378 return priv->chips[I-1].size; 378 return priv->chips[I-1].size;
379} 379}
380 380
@@ -392,7 +392,7 @@ static const struct JEDECTable *jedec_idtoinf(__u8 mfr,__u8 id)
392// Look for flash using an 8 bit bus interface 392// Look for flash using an 8 bit bus interface
393static int jedec_probe8(struct map_info *map,unsigned long base, 393static int jedec_probe8(struct map_info *map,unsigned long base,
394 struct jedec_private *priv) 394 struct jedec_private *priv)
395{ 395{
396 #define flread(x) map_read8(map,base+x) 396 #define flread(x) map_read8(map,base+x)
397 #define flwrite(v,x) map_write8(map,v,base+x) 397 #define flwrite(v,x) map_write8(map,v,base+x)
398 398
@@ -410,20 +410,20 @@ static int jedec_probe8(struct map_info *map,unsigned long base,
410 OldVal = flread(base); 410 OldVal = flread(base);
411 for (I = 0; OldVal != flread(base) && I < 10000; I++) 411 for (I = 0; OldVal != flread(base) && I < 10000; I++)
412 OldVal = flread(base); 412 OldVal = flread(base);
413 413
414 // Reset the chip 414 // Reset the chip
415 flwrite(Reset,0x555); 415 flwrite(Reset,0x555);
416 416
417 // Send the sequence 417 // Send the sequence
418 flwrite(AutoSel1,0x555); 418 flwrite(AutoSel1,0x555);
419 flwrite(AutoSel2,0x2AA); 419 flwrite(AutoSel2,0x2AA);
420 flwrite(AutoSel3,0x555); 420 flwrite(AutoSel3,0x555);
421 421
422 // Get the JEDEC numbers 422 // Get the JEDEC numbers
423 Mfg[0] = flread(0); 423 Mfg[0] = flread(0);
424 Id[0] = flread(1); 424 Id[0] = flread(1);
425 // printk("Mfg is %x, Id is %x\n",Mfg[0],Id[0]); 425 // printk("Mfg is %x, Id is %x\n",Mfg[0],Id[0]);
426 426
427 Size = handle_jedecs(map,Mfg,Id,1,base,priv); 427 Size = handle_jedecs(map,Mfg,Id,1,base,priv);
428 // printk("handle_jedecs Size is %x\n",(unsigned int)Size); 428 // printk("handle_jedecs Size is %x\n",(unsigned int)Size);
429 if (Size == 0) 429 if (Size == 0)
@@ -431,13 +431,13 @@ static int jedec_probe8(struct map_info *map,unsigned long base,
431 flwrite(Reset,0x555); 431 flwrite(Reset,0x555);
432 return 0; 432 return 0;
433 } 433 }
434 434
435 435
436 // Reset. 436 // Reset.
437 flwrite(Reset,0x555); 437 flwrite(Reset,0x555);
438 438
439 return 1; 439 return 1;
440 440
441 #undef flread 441 #undef flread
442 #undef flwrite 442 #undef flwrite
443} 443}
@@ -470,17 +470,17 @@ static int jedec_probe32(struct map_info *map,unsigned long base,
470 OldVal = flread(base); 470 OldVal = flread(base);
471 for (I = 0; OldVal != flread(base) && I < 10000; I++) 471 for (I = 0; OldVal != flread(base) && I < 10000; I++)
472 OldVal = flread(base); 472 OldVal = flread(base);
473 473
474 // Reset the chip 474 // Reset the chip
475 flwrite(Reset,0x555); 475 flwrite(Reset,0x555);
476 476
477 // Send the sequence 477 // Send the sequence
478 flwrite(AutoSel1,0x555); 478 flwrite(AutoSel1,0x555);
479 flwrite(AutoSel2,0x2AA); 479 flwrite(AutoSel2,0x2AA);
480 flwrite(AutoSel3,0x555); 480 flwrite(AutoSel3,0x555);
481 481
482 // Test #1, JEDEC numbers are readable from 0x??00/0x??01 482 // Test #1, JEDEC numbers are readable from 0x??00/0x??01
483 if (flread(0) != flread(0x100) || 483 if (flread(0) != flread(0x100) ||
484 flread(1) != flread(0x101)) 484 flread(1) != flread(0x101))
485 { 485 {
486 flwrite(Reset,0x555); 486 flwrite(Reset,0x555);
@@ -494,14 +494,14 @@ static int jedec_probe32(struct map_info *map,unsigned long base,
494 OldVal = flread(1); 494 OldVal = flread(1);
495 for (I = 0; I != 4; I++) 495 for (I = 0; I != 4; I++)
496 Id[I] = (OldVal >> (I*8)); 496 Id[I] = (OldVal >> (I*8));
497 497
498 Size = handle_jedecs(map,Mfg,Id,4,base,priv); 498 Size = handle_jedecs(map,Mfg,Id,4,base,priv);
499 if (Size == 0) 499 if (Size == 0)
500 { 500 {
501 flwrite(Reset,0x555); 501 flwrite(Reset,0x555);
502 return 0; 502 return 0;
503 } 503 }
504 504
505 /* Check if there is address wrap around within a single bank, if this 505 /* Check if there is address wrap around within a single bank, if this
506 returns JEDEC numbers then we assume that it is wrap around. Notice 506 returns JEDEC numbers then we assume that it is wrap around. Notice
507 we call this routine with the JEDEC return still enabled, if two or 507 we call this routine with the JEDEC return still enabled, if two or
@@ -519,27 +519,27 @@ static int jedec_probe32(struct map_info *map,unsigned long base,
519 519
520 // Reset. 520 // Reset.
521 flwrite(0xF0F0F0F0,0x555); 521 flwrite(0xF0F0F0F0,0x555);
522 522
523 return 1; 523 return 1;
524 524
525 #undef flread 525 #undef flread
526 #undef flwrite 526 #undef flwrite
527} 527}
528 528
529/* Linear read. */ 529/* Linear read. */
530static int jedec_read(struct mtd_info *mtd, loff_t from, size_t len, 530static int jedec_read(struct mtd_info *mtd, loff_t from, size_t len,
531 size_t *retlen, u_char *buf) 531 size_t *retlen, u_char *buf)
532{ 532{
533 struct map_info *map = mtd->priv; 533 struct map_info *map = mtd->priv;
534 534
535 map_copy_from(map, buf, from, len); 535 map_copy_from(map, buf, from, len);
536 *retlen = len; 536 *retlen = len;
537 return 0; 537 return 0;
538} 538}
539 539
540/* Banked read. Take special care to jump past the holes in the bank 540/* Banked read. Take special care to jump past the holes in the bank
541 mapping. This version assumes symetry in the holes.. */ 541 mapping. This version assumes symetry in the holes.. */
542static int jedec_read_banked(struct mtd_info *mtd, loff_t from, size_t len, 542static int jedec_read_banked(struct mtd_info *mtd, loff_t from, size_t len,
543 size_t *retlen, u_char *buf) 543 size_t *retlen, u_char *buf)
544{ 544{
545 struct map_info *map = mtd->priv; 545 struct map_info *map = mtd->priv;
@@ -555,17 +555,17 @@ static int jedec_read_banked(struct mtd_info *mtd, loff_t from, size_t len,
555 if (priv->bank_fill[0] - offset < len) 555 if (priv->bank_fill[0] - offset < len)
556 get = priv->bank_fill[0] - offset; 556 get = priv->bank_fill[0] - offset;
557 557
558 bank /= priv->bank_fill[0]; 558 bank /= priv->bank_fill[0];
559 map_copy_from(map,buf + *retlen,bank*my_bank_size + offset,get); 559 map_copy_from(map,buf + *retlen,bank*my_bank_size + offset,get);
560 560
561 len -= get; 561 len -= get;
562 *retlen += get; 562 *retlen += get;
563 from += get; 563 from += get;
564 } 564 }
565 return 0; 565 return 0;
566} 566}
567 567
568/* Pass the flags value that the flash return before it re-entered read 568/* Pass the flags value that the flash return before it re-entered read
569 mode. */ 569 mode. */
570static void jedec_flash_failed(unsigned char code) 570static void jedec_flash_failed(unsigned char code)
571{ 571{
@@ -579,17 +579,17 @@ static void jedec_flash_failed(unsigned char code)
579 printk("mtd: Programming didn't take\n"); 579 printk("mtd: Programming didn't take\n");
580} 580}
581 581
582/* This uses the erasure function described in the AMD Flash Handbook, 582/* This uses the erasure function described in the AMD Flash Handbook,
583 it will work for flashes with a fixed sector size only. Flashes with 583 it will work for flashes with a fixed sector size only. Flashes with
584 a selection of sector sizes (ie the AMD Am29F800B) will need a different 584 a selection of sector sizes (ie the AMD Am29F800B) will need a different
585 routine. This routine tries to parallize erasing multiple chips/sectors 585 routine. This routine tries to parallize erasing multiple chips/sectors
586 where possible */ 586 where possible */
587static int flash_erase(struct mtd_info *mtd, struct erase_info *instr) 587static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
588{ 588{
589 // Does IO to the currently selected chip 589 // Does IO to the currently selected chip
590 #define flread(x) map_read8(map,chip->base+((x)<<chip->addrshift)) 590 #define flread(x) map_read8(map,chip->base+((x)<<chip->addrshift))
591 #define flwrite(v,x) map_write8(map,v,chip->base+((x)<<chip->addrshift)) 591 #define flwrite(v,x) map_write8(map,v,chip->base+((x)<<chip->addrshift))
592 592
593 unsigned long Time = 0; 593 unsigned long Time = 0;
594 unsigned long NoTime = 0; 594 unsigned long NoTime = 0;
595 unsigned long start = instr->addr, len = instr->len; 595 unsigned long start = instr->addr, len = instr->len;
@@ -603,7 +603,7 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
603 (len % mtd->erasesize) != 0 || 603 (len % mtd->erasesize) != 0 ||
604 (len/mtd->erasesize) == 0) 604 (len/mtd->erasesize) == 0)
605 return -EINVAL; 605 return -EINVAL;
606 606
607 jedec_flash_chip_scan(priv,start,len); 607 jedec_flash_chip_scan(priv,start,len);
608 608
609 // Start the erase sequence on each chip 609 // Start the erase sequence on each chip
@@ -611,16 +611,16 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
611 { 611 {
612 unsigned long off; 612 unsigned long off;
613 struct jedec_flash_chip *chip = priv->chips + I; 613 struct jedec_flash_chip *chip = priv->chips + I;
614 614
615 if (chip->length == 0) 615 if (chip->length == 0)
616 continue; 616 continue;
617 617
618 if (chip->start + chip->length > chip->size) 618 if (chip->start + chip->length > chip->size)
619 { 619 {
620 printk("DIE\n"); 620 printk("DIE\n");
621 return -EIO; 621 return -EIO;
622 } 622 }
623 623
624 flwrite(0xF0,chip->start + 0x555); 624 flwrite(0xF0,chip->start + 0x555);
625 flwrite(0xAA,chip->start + 0x555); 625 flwrite(0xAA,chip->start + 0x555);
626 flwrite(0x55,chip->start + 0x2AA); 626 flwrite(0x55,chip->start + 0x2AA);
@@ -628,8 +628,8 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
628 flwrite(0xAA,chip->start + 0x555); 628 flwrite(0xAA,chip->start + 0x555);
629 flwrite(0x55,chip->start + 0x2AA); 629 flwrite(0x55,chip->start + 0x2AA);
630 630
631 /* Once we start selecting the erase sectors the delay between each 631 /* Once we start selecting the erase sectors the delay between each
632 command must not exceed 50us or it will immediately start erasing 632 command must not exceed 50us or it will immediately start erasing
633 and ignore the other sectors */ 633 and ignore the other sectors */
634 for (off = 0; off < len; off += chip->sectorsize) 634 for (off = 0; off < len; off += chip->sectorsize)
635 { 635 {
@@ -641,19 +641,19 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
641 { 641 {
642 printk("mtd: Ack! We timed out the erase timer!\n"); 642 printk("mtd: Ack! We timed out the erase timer!\n");
643 return -EIO; 643 return -EIO;
644 } 644 }
645 } 645 }
646 } 646 }
647 647
648 /* We could split this into a timer routine and return early, performing 648 /* We could split this into a timer routine and return early, performing
649 background erasure.. Maybe later if the need warrents */ 649 background erasure.. Maybe later if the need warrents */
650 650
651 /* Poll the flash for erasure completion, specs say this can take as long 651 /* Poll the flash for erasure completion, specs say this can take as long
652 as 480 seconds to do all the sectors (for a 2 meg flash). 652 as 480 seconds to do all the sectors (for a 2 meg flash).
653 Erasure time is dependent on chip age, temp and wear.. */ 653 Erasure time is dependent on chip age, temp and wear.. */
654 654
655 /* This being a generic routine assumes a 32 bit bus. It does read32s 655 /* This being a generic routine assumes a 32 bit bus. It does read32s
656 and bundles interleved chips into the same grouping. This will work 656 and bundles interleved chips into the same grouping. This will work
657 for all bus widths */ 657 for all bus widths */
658 Time = 0; 658 Time = 0;
659 NoTime = 0; 659 NoTime = 0;
@@ -664,20 +664,20 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
664 unsigned todo[4] = {0,0,0,0}; 664 unsigned todo[4] = {0,0,0,0};
665 unsigned todo_left = 0; 665 unsigned todo_left = 0;
666 unsigned J; 666 unsigned J;
667 667
668 if (chip->length == 0) 668 if (chip->length == 0)
669 continue; 669 continue;
670 670
671 /* Find all chips in this data line, realistically this is all 671 /* Find all chips in this data line, realistically this is all
672 or nothing up to the interleve count */ 672 or nothing up to the interleve count */
673 for (J = 0; priv->chips[J].jedec != 0 && J < MAX_JEDEC_CHIPS; J++) 673 for (J = 0; priv->chips[J].jedec != 0 && J < MAX_JEDEC_CHIPS; J++)
674 { 674 {
675 if ((priv->chips[J].base & (~((1<<chip->addrshift)-1))) == 675 if ((priv->chips[J].base & (~((1<<chip->addrshift)-1))) ==
676 (chip->base & (~((1<<chip->addrshift)-1)))) 676 (chip->base & (~((1<<chip->addrshift)-1))))
677 { 677 {
678 todo_left++; 678 todo_left++;
679 todo[priv->chips[J].base & ((1<<chip->addrshift)-1)] = 1; 679 todo[priv->chips[J].base & ((1<<chip->addrshift)-1)] = 1;
680 } 680 }
681 } 681 }
682 682
683 /* printk("todo: %x %x %x %x\n",(short)todo[0],(short)todo[1], 683 /* printk("todo: %x %x %x %x\n",(short)todo[0],(short)todo[1],
@@ -687,7 +687,7 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
687 { 687 {
688 __u32 Last[4]; 688 __u32 Last[4];
689 unsigned long Count = 0; 689 unsigned long Count = 0;
690 690
691 /* During erase bit 7 is held low and bit 6 toggles, we watch this, 691 /* During erase bit 7 is held low and bit 6 toggles, we watch this,
692 should it stop toggling or go high then the erase is completed, 692 should it stop toggling or go high then the erase is completed,
693 or this is not really flash ;> */ 693 or this is not really flash ;> */
@@ -718,23 +718,23 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
718 __u8 Byte3 = (Last[(Count-3)%4] >> (J*8)) & 0xFF; 718 __u8 Byte3 = (Last[(Count-3)%4] >> (J*8)) & 0xFF;
719 if (todo[J] == 0) 719 if (todo[J] == 0)
720 continue; 720 continue;
721 721
722 if ((Byte1 & (1 << 7)) == 0 && Byte1 != Byte2) 722 if ((Byte1 & (1 << 7)) == 0 && Byte1 != Byte2)
723 { 723 {
724// printk("Check %x %x %x\n",(short)J,(short)Byte1,(short)Byte2); 724// printk("Check %x %x %x\n",(short)J,(short)Byte1,(short)Byte2);
725 continue; 725 continue;
726 } 726 }
727 727
728 if (Byte1 == Byte2) 728 if (Byte1 == Byte2)
729 { 729 {
730 jedec_flash_failed(Byte3); 730 jedec_flash_failed(Byte3);
731 return -EIO; 731 return -EIO;
732 } 732 }
733 733
734 todo[J] = 0; 734 todo[J] = 0;
735 todo_left--; 735 todo_left--;
736 } 736 }
737 737
738/* if (NoTime == 0) 738/* if (NoTime == 0)
739 Time += HZ/10 - schedule_timeout(HZ/10);*/ 739 Time += HZ/10 - schedule_timeout(HZ/10);*/
740 NoTime = 0; 740 NoTime = 0;
@@ -751,7 +751,7 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
751 break; 751 break;
752 } 752 }
753 Count++; 753 Count++;
754 754
755/* // Count time, max of 15s per sector (according to AMD) 755/* // Count time, max of 15s per sector (according to AMD)
756 if (Time > 15*len/mtd->erasesize*HZ) 756 if (Time > 15*len/mtd->erasesize*HZ)
757 { 757 {
@@ -759,38 +759,38 @@ static int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
759 return -EIO; 759 return -EIO;
760 } */ 760 } */
761 } 761 }
762 762
763 // Skip to the next chip if we used chip erase 763 // Skip to the next chip if we used chip erase
764 if (chip->length == chip->size) 764 if (chip->length == chip->size)
765 off = chip->size; 765 off = chip->size;
766 else 766 else
767 off += chip->sectorsize; 767 off += chip->sectorsize;
768 768
769 if (off >= chip->length) 769 if (off >= chip->length)
770 break; 770 break;
771 NoTime = 1; 771 NoTime = 1;
772 } 772 }
773 773
774 for (J = 0; priv->chips[J].jedec != 0 && J < MAX_JEDEC_CHIPS; J++) 774 for (J = 0; priv->chips[J].jedec != 0 && J < MAX_JEDEC_CHIPS; J++)
775 { 775 {
776 if ((priv->chips[J].base & (~((1<<chip->addrshift)-1))) == 776 if ((priv->chips[J].base & (~((1<<chip->addrshift)-1))) ==
777 (chip->base & (~((1<<chip->addrshift)-1)))) 777 (chip->base & (~((1<<chip->addrshift)-1))))
778 priv->chips[J].length = 0; 778 priv->chips[J].length = 0;
779 } 779 }
780 } 780 }
781 781
782 //printk("done\n"); 782 //printk("done\n");
783 instr->state = MTD_ERASE_DONE; 783 instr->state = MTD_ERASE_DONE;
784 mtd_erase_callback(instr); 784 mtd_erase_callback(instr);
785 return 0; 785 return 0;
786 786
787 #undef flread 787 #undef flread
788 #undef flwrite 788 #undef flwrite
789} 789}
790 790
791/* This is the simple flash writing function. It writes to every byte, in 791/* This is the simple flash writing function. It writes to every byte, in
792 sequence. It takes care of how to properly address the flash if 792 sequence. It takes care of how to properly address the flash if
793 the flash is interleved. It can only be used if all the chips in the 793 the flash is interleved. It can only be used if all the chips in the
794 array are identical!*/ 794 array are identical!*/
795static int flash_write(struct mtd_info *mtd, loff_t start, size_t len, 795static int flash_write(struct mtd_info *mtd, loff_t start, size_t len,
796 size_t *retlen, const u_char *buf) 796 size_t *retlen, const u_char *buf)
@@ -800,25 +800,25 @@ static int flash_write(struct mtd_info *mtd, loff_t start, size_t len,
800 of addrshift (interleave index) and then adds the control register index. */ 800 of addrshift (interleave index) and then adds the control register index. */
801 #define flread(x) map_read8(map,base+(off&((1<<chip->addrshift)-1))+((x)<<chip->addrshift)) 801 #define flread(x) map_read8(map,base+(off&((1<<chip->addrshift)-1))+((x)<<chip->addrshift))
802 #define flwrite(v,x) map_write8(map,v,base+(off&((1<<chip->addrshift)-1))+((x)<<chip->addrshift)) 802 #define flwrite(v,x) map_write8(map,v,base+(off&((1<<chip->addrshift)-1))+((x)<<chip->addrshift))
803 803
804 struct map_info *map = mtd->priv; 804 struct map_info *map = mtd->priv;
805 struct jedec_private *priv = map->fldrv_priv; 805 struct jedec_private *priv = map->fldrv_priv;
806 unsigned long base; 806 unsigned long base;
807 unsigned long off; 807 unsigned long off;
808 size_t save_len = len; 808 size_t save_len = len;
809 809
810 if (start + len > mtd->size) 810 if (start + len > mtd->size)
811 return -EIO; 811 return -EIO;
812 812
813 //printk("Here"); 813 //printk("Here");
814 814
815 //printk("flash_write: start is %x, len is %x\n",start,(unsigned long)len); 815 //printk("flash_write: start is %x, len is %x\n",start,(unsigned long)len);
816 while (len != 0) 816 while (len != 0)
817 { 817 {
818 struct jedec_flash_chip *chip = priv->chips; 818 struct jedec_flash_chip *chip = priv->chips;
819 unsigned long bank; 819 unsigned long bank;
820 unsigned long boffset; 820 unsigned long boffset;
821 821
822 // Compute the base of the flash. 822 // Compute the base of the flash.
823 off = ((unsigned long)start) % (chip->size << chip->addrshift); 823 off = ((unsigned long)start) % (chip->size << chip->addrshift);
824 base = start - off; 824 base = start - off;
@@ -828,10 +828,10 @@ static int flash_write(struct mtd_info *mtd, loff_t start, size_t len,
828 boffset = base & (priv->bank_fill[0]-1); 828 boffset = base & (priv->bank_fill[0]-1);
829 bank = (bank/priv->bank_fill[0])*my_bank_size; 829 bank = (bank/priv->bank_fill[0])*my_bank_size;
830 base = bank + boffset; 830 base = bank + boffset;
831 831
832 // printk("Flasing %X %X %X\n",base,chip->size,len); 832 // printk("Flasing %X %X %X\n",base,chip->size,len);
833 // printk("off is %x, compare with %x\n",off,chip->size << chip->addrshift); 833 // printk("off is %x, compare with %x\n",off,chip->size << chip->addrshift);
834 834
835 // Loop over this page 835 // Loop over this page
836 for (; off != (chip->size << chip->addrshift) && len != 0; start++, len--, off++,buf++) 836 for (; off != (chip->size << chip->addrshift) && len != 0; start++, len--, off++,buf++)
837 { 837 {
@@ -845,7 +845,7 @@ static int flash_write(struct mtd_info *mtd, loff_t start, size_t len,
845 } 845 }
846 if (((~oldbyte) & *buf) != 0) 846 if (((~oldbyte) & *buf) != 0)
847 printk("mtd: warn: Trying to set a 0 to a 1\n"); 847 printk("mtd: warn: Trying to set a 0 to a 1\n");
848 848
849 // Write 849 // Write
850 flwrite(0xAA,0x555); 850 flwrite(0xAA,0x555);
851 flwrite(0x55,0x2AA); 851 flwrite(0x55,0x2AA);
@@ -854,10 +854,10 @@ static int flash_write(struct mtd_info *mtd, loff_t start, size_t len,
854 Last[0] = map_read8(map,base + off); 854 Last[0] = map_read8(map,base + off);
855 Last[1] = map_read8(map,base + off); 855 Last[1] = map_read8(map,base + off);
856 Last[2] = map_read8(map,base + off); 856 Last[2] = map_read8(map,base + off);
857 857
858 /* Wait for the flash to finish the operation. We store the last 4 858 /* Wait for the flash to finish the operation. We store the last 4
859 status bytes that have been retrieved so we can determine why 859 status bytes that have been retrieved so we can determine why
860 it failed. The toggle bits keep toggling when there is a 860 it failed. The toggle bits keep toggling when there is a
861 failure */ 861 failure */
862 for (Count = 3; Last[(Count - 1) % 4] != Last[(Count - 2) % 4] && 862 for (Count = 3; Last[(Count - 1) % 4] != Last[(Count - 2) % 4] &&
863 Count < 10000; Count++) 863 Count < 10000; Count++)
@@ -866,7 +866,7 @@ static int flash_write(struct mtd_info *mtd, loff_t start, size_t len,
866 { 866 {
867 jedec_flash_failed(Last[(Count - 3) % 4]); 867 jedec_flash_failed(Last[(Count - 3) % 4]);
868 return -EIO; 868 return -EIO;
869 } 869 }
870 } 870 }
871 } 871 }
872 *retlen = save_len; 872 *retlen = save_len;
@@ -885,24 +885,24 @@ static void jedec_flash_chip_scan(struct jedec_private *priv,unsigned long start
885 // Zero the records 885 // Zero the records
886 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) 886 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++)
887 priv->chips[I].start = priv->chips[I].length = 0; 887 priv->chips[I].start = priv->chips[I].length = 0;
888 888
889 // Intersect the region with each chip 889 // Intersect the region with each chip
890 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) 890 for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++)
891 { 891 {
892 struct jedec_flash_chip *chip = priv->chips + I; 892 struct jedec_flash_chip *chip = priv->chips + I;
893 unsigned long ByteStart; 893 unsigned long ByteStart;
894 unsigned long ChipEndByte = chip->offset + (chip->size << chip->addrshift); 894 unsigned long ChipEndByte = chip->offset + (chip->size << chip->addrshift);
895 895
896 // End is before this chip or the start is after it 896 // End is before this chip or the start is after it
897 if (start+len < chip->offset || 897 if (start+len < chip->offset ||
898 ChipEndByte - (1 << chip->addrshift) < start) 898 ChipEndByte - (1 << chip->addrshift) < start)
899 continue; 899 continue;
900 900
901 if (start < chip->offset) 901 if (start < chip->offset)
902 { 902 {
903 ByteStart = chip->offset; 903 ByteStart = chip->offset;
904 chip->start = 0; 904 chip->start = 0;
905 } 905 }
906 else 906 else
907 { 907 {
908 chip->start = (start - chip->offset + (1 << chip->addrshift)-1) >> chip->addrshift; 908 chip->start = (start - chip->offset + (1 << chip->addrshift)-1) >> chip->addrshift;
diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c
index 30da428eb7b9..edb306c03c0a 100644
--- a/drivers/mtd/chips/jedec_probe.c
+++ b/drivers/mtd/chips/jedec_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: jedec_probe.c,v 1.63 2005/02/14 16:30:32 bjd Exp $ 4 $Id: jedec_probe.c,v 1.66 2005/11/07 11:14:23 gleixner Exp $
5 See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5) 5 See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5)
6 for the standard this probe goes back to. 6 for the standard this probe goes back to.
7 7
@@ -1719,7 +1719,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
1719 1719
1720static struct mtd_info *jedec_probe(struct map_info *map); 1720static struct mtd_info *jedec_probe(struct map_info *map);
1721 1721
1722static inline u32 jedec_read_mfr(struct map_info *map, __u32 base, 1722static inline u32 jedec_read_mfr(struct map_info *map, __u32 base,
1723 struct cfi_private *cfi) 1723 struct cfi_private *cfi)
1724{ 1724{
1725 map_word result; 1725 map_word result;
@@ -1730,7 +1730,7 @@ static inline u32 jedec_read_mfr(struct map_info *map, __u32 base,
1730 return result.x[0] & mask; 1730 return result.x[0] & mask;
1731} 1731}
1732 1732
1733static inline u32 jedec_read_id(struct map_info *map, __u32 base, 1733static inline u32 jedec_read_id(struct map_info *map, __u32 base,
1734 struct cfi_private *cfi) 1734 struct cfi_private *cfi)
1735{ 1735{
1736 map_word result; 1736 map_word result;
@@ -1741,7 +1741,7 @@ static inline u32 jedec_read_id(struct map_info *map, __u32 base,
1741 return result.x[0] & mask; 1741 return result.x[0] & mask;
1742} 1742}
1743 1743
1744static inline void jedec_reset(u32 base, struct map_info *map, 1744static inline void jedec_reset(u32 base, struct map_info *map,
1745 struct cfi_private *cfi) 1745 struct cfi_private *cfi)
1746{ 1746{
1747 /* Reset */ 1747 /* Reset */
@@ -1765,7 +1765,7 @@ static inline void jedec_reset(u32 base, struct map_info *map,
1765 * so ensure we're in read mode. Send both the Intel and the AMD command 1765 * so ensure we're in read mode. Send both the Intel and the AMD command
1766 * for this. Intel uses 0xff for this, AMD uses 0xff for NOP, so 1766 * for this. Intel uses 0xff for this, AMD uses 0xff for NOP, so
1767 * this should be safe. 1767 * this should be safe.
1768 */ 1768 */
1769 cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); 1769 cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
1770 /* FIXME - should have reset delay before continuing */ 1770 /* FIXME - should have reset delay before continuing */
1771} 1771}
@@ -1807,14 +1807,14 @@ static int cfi_jedec_setup(struct cfi_private *p_cfi, int index)
1807 printk("Found: %s\n",jedec_table[index].name); 1807 printk("Found: %s\n",jedec_table[index].name);
1808 1808
1809 num_erase_regions = jedec_table[index].NumEraseRegions; 1809 num_erase_regions = jedec_table[index].NumEraseRegions;
1810 1810
1811 p_cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL); 1811 p_cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL);
1812 if (!p_cfi->cfiq) { 1812 if (!p_cfi->cfiq) {
1813 //xx printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name); 1813 //xx printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name);
1814 return 0; 1814 return 0;
1815 } 1815 }
1816 1816
1817 memset(p_cfi->cfiq,0,sizeof(struct cfi_ident)); 1817 memset(p_cfi->cfiq,0,sizeof(struct cfi_ident));
1818 1818
1819 p_cfi->cfiq->P_ID = jedec_table[index].CmdSet; 1819 p_cfi->cfiq->P_ID = jedec_table[index].CmdSet;
1820 p_cfi->cfiq->NumEraseRegions = jedec_table[index].NumEraseRegions; 1820 p_cfi->cfiq->NumEraseRegions = jedec_table[index].NumEraseRegions;
@@ -1969,7 +1969,7 @@ static inline int jedec_match( __u32 base,
1969 cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL); 1969 cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
1970 /* FIXME - should have a delay before continuing */ 1970 /* FIXME - should have a delay before continuing */
1971 1971
1972 match_done: 1972 match_done:
1973 return rc; 1973 return rc;
1974} 1974}
1975 1975
@@ -1998,23 +1998,23 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
1998 "Probe at base(0x%08x) past the end of the map(0x%08lx)\n", 1998 "Probe at base(0x%08x) past the end of the map(0x%08lx)\n",
1999 base, map->size -1); 1999 base, map->size -1);
2000 return 0; 2000 return 0;
2001 2001
2002 } 2002 }
2003 /* Ensure the unlock addresses we try stay inside the map */ 2003 /* Ensure the unlock addresses we try stay inside the map */
2004 probe_offset1 = cfi_build_cmd_addr( 2004 probe_offset1 = cfi_build_cmd_addr(
2005 cfi->addr_unlock1, 2005 cfi->addr_unlock1,
2006 cfi_interleave(cfi), 2006 cfi_interleave(cfi),
2007 cfi->device_type); 2007 cfi->device_type);
2008 probe_offset2 = cfi_build_cmd_addr( 2008 probe_offset2 = cfi_build_cmd_addr(
2009 cfi->addr_unlock1, 2009 cfi->addr_unlock1,
2010 cfi_interleave(cfi), 2010 cfi_interleave(cfi),
2011 cfi->device_type); 2011 cfi->device_type);
2012 if ( ((base + probe_offset1 + map_bankwidth(map)) >= map->size) || 2012 if ( ((base + probe_offset1 + map_bankwidth(map)) >= map->size) ||
2013 ((base + probe_offset2 + map_bankwidth(map)) >= map->size)) 2013 ((base + probe_offset2 + map_bankwidth(map)) >= map->size))
2014 { 2014 {
2015 goto retry; 2015 goto retry;
2016 } 2016 }
2017 2017
2018 /* Reset */ 2018 /* Reset */
2019 jedec_reset(base, map, cfi); 2019 jedec_reset(base, map, cfi);
2020 2020
@@ -2027,13 +2027,13 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
2027 /* FIXME - should have a delay before continuing */ 2027 /* FIXME - should have a delay before continuing */
2028 2028
2029 if (!cfi->numchips) { 2029 if (!cfi->numchips) {
2030 /* This is the first time we're called. Set up the CFI 2030 /* This is the first time we're called. Set up the CFI
2031 stuff accordingly and return */ 2031 stuff accordingly and return */
2032 2032
2033 cfi->mfr = jedec_read_mfr(map, base, cfi); 2033 cfi->mfr = jedec_read_mfr(map, base, cfi);
2034 cfi->id = jedec_read_id(map, base, cfi); 2034 cfi->id = jedec_read_id(map, base, cfi);
2035 DEBUG(MTD_DEBUG_LEVEL3, 2035 DEBUG(MTD_DEBUG_LEVEL3,
2036 "Search for id:(%02x %02x) interleave(%d) type(%d)\n", 2036 "Search for id:(%02x %02x) interleave(%d) type(%d)\n",
2037 cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type); 2037 cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type);
2038 for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) { 2038 for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) {
2039 if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) { 2039 if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) {
@@ -2062,7 +2062,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
2062 return 0; 2062 return 0;
2063 } 2063 }
2064 } 2064 }
2065 2065
2066 /* Check each previous chip locations to see if it's an alias */ 2066 /* Check each previous chip locations to see if it's an alias */
2067 for (i=0; i < (base >> cfi->chipshift); i++) { 2067 for (i=0; i < (base >> cfi->chipshift); i++) {
2068 unsigned long start; 2068 unsigned long start;
@@ -2083,7 +2083,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
2083 map->name, base, start); 2083 map->name, base, start);
2084 return 0; 2084 return 0;
2085 } 2085 }
2086 2086
2087 /* Yes, it's actually got the device IDs as data. Most 2087 /* Yes, it's actually got the device IDs as data. Most
2088 * unfortunate. Stick the new chip in read mode 2088 * unfortunate. Stick the new chip in read mode
2089 * too and if it's the same, assume it's an alias. */ 2089 * too and if it's the same, assume it's an alias. */
@@ -2097,20 +2097,20 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
2097 } 2097 }
2098 } 2098 }
2099 } 2099 }
2100 2100
2101 /* OK, if we got to here, then none of the previous chips appear to 2101 /* OK, if we got to here, then none of the previous chips appear to
2102 be aliases for the current one. */ 2102 be aliases for the current one. */
2103 set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */ 2103 set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */
2104 cfi->numchips++; 2104 cfi->numchips++;
2105 2105
2106ok_out: 2106ok_out:
2107 /* Put it back into Read Mode */ 2107 /* Put it back into Read Mode */
2108 jedec_reset(base, map, cfi); 2108 jedec_reset(base, map, cfi);
2109 2109
2110 printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", 2110 printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n",
2111 map->name, cfi_interleave(cfi), cfi->device_type*8, base, 2111 map->name, cfi_interleave(cfi), cfi->device_type*8, base,
2112 map->bankwidth*8); 2112 map->bankwidth*8);
2113 2113
2114 return 1; 2114 return 1;
2115} 2115}
2116 2116
diff --git a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c
index c6c83833cc32..a611de9b1515 100644
--- a/drivers/mtd/chips/map_absent.c
+++ b/drivers/mtd/chips/map_absent.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * Common code to handle absent "placeholder" devices 2 * Common code to handle absent "placeholder" devices
3 * Copyright 2001 Resilience Corporation <ebrower@resilience.com> 3 * Copyright 2001 Resilience Corporation <ebrower@resilience.com>
4 * $Id: map_absent.c,v 1.5 2004/11/16 18:29:00 dwmw2 Exp $ 4 * $Id: map_absent.c,v 1.6 2005/11/07 11:14:23 gleixner Exp $
5 * 5 *
6 * This map driver is used to allocate "placeholder" MTD 6 * This map driver is used to allocate "placeholder" MTD
7 * devices on systems that have socketed/removable media. 7 * devices on systems that have socketed/removable media.
8 * Use of this driver as a fallback preserves the expected 8 * Use of this driver as a fallback preserves the expected
9 * registration of MTD device nodes regardless of probe outcome. 9 * registration of MTD device nodes regardless of probe outcome.
10 * A usage example is as follows: 10 * A usage example is as follows:
11 * 11 *
@@ -80,7 +80,7 @@ static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t
80static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) 80static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
81{ 81{
82 *retlen = 0; 82 *retlen = 0;
83 return -ENODEV; 83 return -ENODEV;
84} 84}
85 85
86static int map_absent_erase(struct mtd_info *mtd, struct erase_info *instr) 86static int map_absent_erase(struct mtd_info *mtd, struct erase_info *instr)
diff --git a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c
index c3cf0f63bc93..2d26bdef82d5 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.14 2004/08/09 13:19:43 dwmw2 Exp $ 7 * $Id: sharp.c,v 1.16 2005/11/07 11:14:23 gleixner Exp $
8 * 8 *
9 * Devices supported: 9 * Devices supported:
10 * LH28F016SCT Symmetrical block flash memory, 2Mx8 10 * LH28F016SCT Symmetrical block flash memory, 2Mx8
@@ -31,6 +31,7 @@
31#include <linux/mtd/cfi.h> 31#include <linux/mtd/cfi.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/slab.h>
34 35
35#define CMD_RESET 0xffffffff 36#define CMD_RESET 0xffffffff
36#define CMD_READ_ID 0x90909090 37#define CMD_READ_ID 0x90909090
@@ -214,7 +215,7 @@ static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
214/* This function returns with the chip->mutex lock held. */ 215/* This function returns with the chip->mutex lock held. */
215static int sharp_wait(struct map_info *map, struct flchip *chip) 216static int sharp_wait(struct map_info *map, struct flchip *chip)
216{ 217{
217 __u16 status; 218 int status, i;
218 unsigned long timeo = jiffies + HZ; 219 unsigned long timeo = jiffies + HZ;
219 DECLARE_WAITQUEUE(wait, current); 220 DECLARE_WAITQUEUE(wait, current);
220 int adr = 0; 221 int adr = 0;
@@ -227,13 +228,11 @@ retry:
227 map_write32(map,CMD_READ_STATUS,adr); 228 map_write32(map,CMD_READ_STATUS,adr);
228 chip->state = FL_STATUS; 229 chip->state = FL_STATUS;
229 case FL_STATUS: 230 case FL_STATUS:
230 status = map_read32(map,adr); 231 for(i=0;i<100;i++){
231//printk("status=%08x\n",status); 232 status = map_read32(map,adr);
232 233 if((status & SR_READY)==SR_READY)
233 udelay(100); 234 break;
234 if((status & SR_READY)!=SR_READY){ 235 udelay(1);
235//printk(".status=%08x\n",status);
236 udelay(100);
237 } 236 }
238 break; 237 break;
239 default: 238 default:
@@ -460,12 +459,12 @@ static int sharp_do_wait_for_ready(struct map_info *map, struct flchip *chip,
460 remove_wait_queue(&chip->wq, &wait); 459 remove_wait_queue(&chip->wq, &wait);
461 460
462 //spin_lock_bh(chip->mutex); 461 //spin_lock_bh(chip->mutex);
463 462
464 if (signal_pending(current)){ 463 if (signal_pending(current)){
465 ret = -EINTR; 464 ret = -EINTR;
466 goto out; 465 goto out;
467 } 466 }
468 467
469 } 468 }
470 ret = -ETIME; 469 ret = -ETIME;
471out: 470out:
@@ -564,7 +563,7 @@ static int sharp_suspend(struct mtd_info *mtd)
564static void sharp_resume(struct mtd_info *mtd) 563static void sharp_resume(struct mtd_info *mtd)
565{ 564{
566 printk("sharp_resume()\n"); 565 printk("sharp_resume()\n");
567 566
568} 567}
569 568
570static void sharp_destroy(struct mtd_info *mtd) 569static void sharp_destroy(struct mtd_info *mtd)
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index ef24837019d3..6b8bb2e4dcfd 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -1,24 +1,24 @@
1/* 1/*
2 * $Id: cmdlinepart.c,v 1.18 2005/06/07 15:04:26 joern Exp $ 2 * $Id: cmdlinepart.c,v 1.19 2005/11/07 11:14:19 gleixner Exp $
3 * 3 *
4 * Read flash partition table from command line 4 * Read flash partition table from command line
5 * 5 *
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH 6 * Copyright 2002 SYSGO Real-Time Solutions GmbH
7 * 7 *
8 * The format for the command line is as follows: 8 * The format for the command line is as follows:
9 * 9 *
10 * mtdparts=<mtddef>[;<mtddef] 10 * mtdparts=<mtddef>[;<mtddef]
11 * <mtddef> := <mtd-id>:<partdef>[,<partdef>] 11 * <mtddef> := <mtd-id>:<partdef>[,<partdef>]
12 * <partdef> := <size>[@offset][<name>][ro] 12 * <partdef> := <size>[@offset][<name>][ro]
13 * <mtd-id> := unique name used in mapping driver/device (mtd->name) 13 * <mtd-id> := unique name used in mapping driver/device (mtd->name)
14 * <size> := standard linux memsize OR "-" to denote all remaining space 14 * <size> := standard linux memsize OR "-" to denote all remaining space
15 * <name> := '(' NAME ')' 15 * <name> := '(' NAME ')'
16 * 16 *
17 * Examples: 17 * Examples:
18 * 18 *
19 * 1 NOR Flash, with 1 single writable partition: 19 * 1 NOR Flash, with 1 single writable partition:
20 * edb7312-nor:- 20 * edb7312-nor:-
21 * 21 *
22 * 1 NOR Flash with 2 partitions, 1 NAND with one 22 * 1 NOR Flash with 2 partitions, 1 NAND with one
23 * edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home) 23 * edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
24 */ 24 */
@@ -60,17 +60,17 @@ static int cmdline_parsed = 0;
60 60
61/* 61/*
62 * Parse one partition definition for an MTD. Since there can be many 62 * Parse one partition definition for an MTD. Since there can be many
63 * comma separated partition definitions, this function calls itself 63 * comma separated partition definitions, this function calls itself
64 * recursively until no more partition definitions are found. Nice side 64 * recursively until no more partition definitions are found. Nice side
65 * effect: the memory to keep the mtd_partition structs and the names 65 * effect: the memory to keep the mtd_partition structs and the names
66 * is allocated upon the last definition being found. At that point the 66 * is allocated upon the last definition being found. At that point the
67 * syntax has been verified ok. 67 * syntax has been verified ok.
68 */ 68 */
69static struct mtd_partition * newpart(char *s, 69static struct mtd_partition * newpart(char *s,
70 char **retptr, 70 char **retptr,
71 int *num_parts, 71 int *num_parts,
72 int this_part, 72 int this_part,
73 unsigned char **extra_mem_ptr, 73 unsigned char **extra_mem_ptr,
74 int extra_mem_size) 74 int extra_mem_size)
75{ 75{
76 struct mtd_partition *parts; 76 struct mtd_partition *parts;
@@ -102,7 +102,7 @@ static struct mtd_partition * newpart(char *s,
102 mask_flags = 0; /* this is going to be a regular partition */ 102 mask_flags = 0; /* this is going to be a regular partition */
103 delim = 0; 103 delim = 0;
104 /* check for offset */ 104 /* check for offset */
105 if (*s == '@') 105 if (*s == '@')
106 { 106 {
107 s++; 107 s++;
108 offset = memparse(s, &s); 108 offset = memparse(s, &s);
@@ -112,7 +112,7 @@ static struct mtd_partition * newpart(char *s,
112 { 112 {
113 delim = ')'; 113 delim = ')';
114 } 114 }
115 115
116 if (delim) 116 if (delim)
117 { 117 {
118 char *p; 118 char *p;
@@ -131,12 +131,12 @@ static struct mtd_partition * newpart(char *s,
131 name = NULL; 131 name = NULL;
132 name_len = 13; /* Partition_000 */ 132 name_len = 13; /* Partition_000 */
133 } 133 }
134 134
135 /* record name length for memory allocation later */ 135 /* record name length for memory allocation later */
136 extra_mem_size += name_len + 1; 136 extra_mem_size += name_len + 1;
137 137
138 /* test for options */ 138 /* test for options */
139 if (strncmp(s, "ro", 2) == 0) 139 if (strncmp(s, "ro", 2) == 0)
140 { 140 {
141 mask_flags |= MTD_WRITEABLE; 141 mask_flags |= MTD_WRITEABLE;
142 s += 2; 142 s += 2;
@@ -151,7 +151,7 @@ static struct mtd_partition * newpart(char *s,
151 return NULL; 151 return NULL;
152 } 152 }
153 /* more partitions follow, parse them */ 153 /* more partitions follow, parse them */
154 if ((parts = newpart(s + 1, &s, num_parts, 154 if ((parts = newpart(s + 1, &s, num_parts,
155 this_part + 1, &extra_mem, extra_mem_size)) == 0) 155 this_part + 1, &extra_mem, extra_mem_size)) == 0)
156 return NULL; 156 return NULL;
157 } 157 }
@@ -187,7 +187,7 @@ static struct mtd_partition * newpart(char *s,
187 extra_mem += name_len + 1; 187 extra_mem += name_len + 1;
188 188
189 dbg(("partition %d: name <%s>, offset %x, size %x, mask flags %x\n", 189 dbg(("partition %d: name <%s>, offset %x, size %x, mask flags %x\n",
190 this_part, 190 this_part,
191 parts[this_part].name, 191 parts[this_part].name,
192 parts[this_part].offset, 192 parts[this_part].offset,
193 parts[this_part].size, 193 parts[this_part].size,
@@ -204,8 +204,8 @@ static struct mtd_partition * newpart(char *s,
204 return parts; 204 return parts;
205} 205}
206 206
207/* 207/*
208 * Parse the command line. 208 * Parse the command line.
209 */ 209 */
210static int mtdpart_setup_real(char *s) 210static int mtdpart_setup_real(char *s)
211{ 211{
@@ -230,7 +230,7 @@ static int mtdpart_setup_real(char *s)
230 230
231 dbg(("parsing <%s>\n", p+1)); 231 dbg(("parsing <%s>\n", p+1));
232 232
233 /* 233 /*
234 * parse one mtd. have it reserve memory for the 234 * parse one mtd. have it reserve memory for the
235 * struct cmdline_mtd_partition and the mtd-id string. 235 * struct cmdline_mtd_partition and the mtd-id string.
236 */ 236 */
@@ -239,7 +239,7 @@ static int mtdpart_setup_real(char *s)
239 &num_parts, /* out: number of parts */ 239 &num_parts, /* out: number of parts */
240 0, /* first partition */ 240 0, /* first partition */
241 (unsigned char**)&this_mtd, /* out: extra mem */ 241 (unsigned char**)&this_mtd, /* out: extra mem */
242 mtd_id_len + 1 + sizeof(*this_mtd) + 242 mtd_id_len + 1 + sizeof(*this_mtd) +
243 sizeof(void*)-1 /*alignment*/); 243 sizeof(void*)-1 /*alignment*/);
244 if(!parts) 244 if(!parts)
245 { 245 {
@@ -254,21 +254,21 @@ static int mtdpart_setup_real(char *s)
254 } 254 }
255 255
256 /* align this_mtd */ 256 /* align this_mtd */
257 this_mtd = (struct cmdline_mtd_partition *) 257 this_mtd = (struct cmdline_mtd_partition *)
258 ALIGN((unsigned long)this_mtd, sizeof(void*)); 258 ALIGN((unsigned long)this_mtd, sizeof(void*));
259 /* enter results */ 259 /* enter results */
260 this_mtd->parts = parts; 260 this_mtd->parts = parts;
261 this_mtd->num_parts = num_parts; 261 this_mtd->num_parts = num_parts;
262 this_mtd->mtd_id = (char*)(this_mtd + 1); 262 this_mtd->mtd_id = (char*)(this_mtd + 1);
263 strlcpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1); 263 strlcpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1);
264 264
265 /* link into chain */ 265 /* link into chain */
266 this_mtd->next = partitions; 266 this_mtd->next = partitions;
267 partitions = this_mtd; 267 partitions = this_mtd;
268 268
269 dbg(("mtdid=<%s> num_parts=<%d>\n", 269 dbg(("mtdid=<%s> num_parts=<%d>\n",
270 this_mtd->mtd_id, this_mtd->num_parts)); 270 this_mtd->mtd_id, this_mtd->num_parts));
271 271
272 272
273 /* EOS - we're done */ 273 /* EOS - we're done */
274 if (*s == 0) 274 if (*s == 0)
@@ -292,7 +292,7 @@ static int mtdpart_setup_real(char *s)
292 * information. It returns partitions for the requested mtd device, or 292 * information. It returns partitions for the requested mtd device, or
293 * the first one in the chain if a NULL mtd_id is passed in. 293 * the first one in the chain if a NULL mtd_id is passed in.
294 */ 294 */
295static int parse_cmdline_partitions(struct mtd_info *master, 295static int parse_cmdline_partitions(struct mtd_info *master,
296 struct mtd_partition **pparts, 296 struct mtd_partition **pparts,
297 unsigned long origin) 297 unsigned long origin)
298{ 298{
@@ -322,7 +322,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
322 part->parts[i].size = master->size - offset; 322 part->parts[i].size = master->size - offset;
323 if (offset + part->parts[i].size > master->size) 323 if (offset + part->parts[i].size > master->size)
324 { 324 {
325 printk(KERN_WARNING ERRP 325 printk(KERN_WARNING ERRP
326 "%s: partitioning exceeds flash size, truncating\n", 326 "%s: partitioning exceeds flash size, truncating\n",
327 part->mtd_id); 327 part->mtd_id);
328 part->parts[i].size = master->size - offset; 328 part->parts[i].size = master->size - offset;
@@ -338,8 +338,8 @@ static int parse_cmdline_partitions(struct mtd_info *master,
338} 338}
339 339
340 340
341/* 341/*
342 * This is the handler for our kernel parameter, called from 342 * This is the handler for our kernel parameter, called from
343 * main.c::checksetup(). Note that we can not yet kmalloc() anything, 343 * main.c::checksetup(). Note that we can not yet kmalloc() anything,
344 * so we only save the commandline for later processing. 344 * so we only save the commandline for later processing.
345 * 345 *
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index c4a56a4ac5e2..9a2aa4033c6a 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -1,5 +1,5 @@
1# drivers/mtd/maps/Kconfig 1# drivers/mtd/maps/Kconfig
2# $Id: Kconfig,v 1.15 2004/12/22 17:51:15 joern Exp $ 2# $Id: Kconfig,v 1.18 2005/11/07 11:14:24 gleixner Exp $
3 3
4menu "Self-contained MTD device drivers" 4menu "Self-contained MTD device drivers"
5 depends on MTD!=n 5 depends on MTD!=n
@@ -110,7 +110,7 @@ config MTDRAM_ABS_POS
110 If you have system RAM accessible by the CPU but not used by Linux 110 If you have system RAM accessible by the CPU but not used by Linux
111 in normal operation, you can give the physical address at which the 111 in normal operation, you can give the physical address at which the
112 available RAM starts, and the MTDRAM driver will use it instead of 112 available RAM starts, and the MTDRAM driver will use it instead of
113 allocating space from Linux's available memory. Otherwise, leave 113 allocating space from Linux's available memory. Otherwise, leave
114 this set to zero. Most people will want to leave this as zero. 114 this set to zero. Most people will want to leave this as zero.
115 115
116config MTD_BLKMTD 116config MTD_BLKMTD
@@ -165,7 +165,7 @@ config MTD_DOC2001
165 select MTD_DOCPROBE 165 select MTD_DOCPROBE
166 select MTD_NAND_IDS 166 select MTD_NAND_IDS
167 ---help--- 167 ---help---
168 This provides an alternative MTD device driver for the M-Systems 168 This provides an alternative MTD device driver for the M-Systems
169 DiskOnChip Millennium devices. Use this if you have problems with 169 DiskOnChip Millennium devices. Use this if you have problems with
170 the combined DiskOnChip 2000 and Millennium driver above. To get 170 the combined DiskOnChip 2000 and Millennium driver above. To get
171 the DiskOnChip probe code to load and use this driver instead of 171 the DiskOnChip probe code to load and use this driver instead of
@@ -192,7 +192,7 @@ config MTD_DOC2001PLUS
192 192
193 If you use this device, you probably also want to enable the INFTL 193 If you use this device, you probably also want to enable the INFTL
194 'Inverse NAND Flash Translation Layer' option below, which is used 194 'Inverse NAND Flash Translation Layer' option below, which is used
195 to emulate a block device by using a kind of file system on the 195 to emulate a block device by using a kind of file system on the
196 flash chips. 196 flash chips.
197 197
198 NOTE: This driver will soon be replaced by the new DiskOnChip driver 198 NOTE: This driver will soon be replaced by the new DiskOnChip driver
diff --git a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c
index 662e807801ed..f9db52f6bf00 100644
--- a/drivers/mtd/devices/blkmtd.c
+++ b/drivers/mtd/devices/blkmtd.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: blkmtd.c,v 1.24 2004/11/16 18:29:01 dwmw2 Exp $ 2 * $Id: blkmtd.c,v 1.27 2005/11/07 11:14:24 gleixner Exp $
3 * 3 *
4 * blkmtd.c - use a block device as a fake MTD 4 * blkmtd.c - use a block device as a fake MTD
5 * 5 *
@@ -39,7 +39,7 @@
39 39
40/* Default erase size in K, always make it a multiple of PAGE_SIZE */ 40/* Default erase size in K, always make it a multiple of PAGE_SIZE */
41#define CONFIG_MTD_BLKDEV_ERASESIZE (128 << 10) /* 128KiB */ 41#define CONFIG_MTD_BLKDEV_ERASESIZE (128 << 10) /* 128KiB */
42#define VERSION "$Revision: 1.24 $" 42#define VERSION "$Revision: 1.27 $"
43 43
44/* Info for the block device */ 44/* Info for the block device */
45struct blkmtd_dev { 45struct blkmtd_dev {
@@ -117,7 +117,7 @@ static int bi_write_complete(struct bio *bio, unsigned int bytes_done, int error
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);
120 120
121 complete((struct completion*)bio->bi_private); 121 complete((struct completion*)bio->bi_private);
122 return 0; 122 return 0;
123} 123}
@@ -135,7 +135,7 @@ static int blkmtd_readpage(struct blkmtd_dev *dev, struct page *page)
135 unlock_page(page); 135 unlock_page(page);
136 return 0; 136 return 0;
137 } 137 }
138 138
139 ClearPageUptodate(page); 139 ClearPageUptodate(page);
140 ClearPageError(page); 140 ClearPageError(page);
141 141
@@ -539,11 +539,8 @@ static void free_device(struct blkmtd_dev *dev)
539{ 539{
540 DEBUG(2, "blkmtd: free_device() dev = %p\n", dev); 540 DEBUG(2, "blkmtd: free_device() dev = %p\n", dev);
541 if(dev) { 541 if(dev) {
542 if(dev->mtd_info.eraseregions) 542 kfree(dev->mtd_info.eraseregions);
543 kfree(dev->mtd_info.eraseregions); 543 kfree(dev->mtd_info.name);
544 if(dev->mtd_info.name)
545 kfree(dev->mtd_info.name);
546
547 if(dev->blkdev) { 544 if(dev->blkdev) {
548 invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping); 545 invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
549 close_bdev_excl(dev->blkdev); 546 close_bdev_excl(dev->blkdev);
@@ -710,7 +707,7 @@ static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size
710 dev->mtd_info.erasesize >> 10, 707 dev->mtd_info.erasesize >> 10,
711 readonly ? "(read-only)" : ""); 708 readonly ? "(read-only)" : "");
712 } 709 }
713 710
714 return dev; 711 return dev;
715 712
716 devinit_err: 713 devinit_err:
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 4a7a805e7564..0aaa0ced9aba 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.28 2005/03/19 22:40:44 gleixner Exp $ 2 * $Id: block2mtd.c,v 1.29 2005/11/07 11:14:24 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.28 $" 22#define VERSION "$Revision: 1.29 $"
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)
@@ -111,7 +111,7 @@ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len)
111 return PTR_ERR(page); 111 return PTR_ERR(page);
112 112
113 max = (u_long*)page_address(page) + PAGE_SIZE; 113 max = (u_long*)page_address(page) + PAGE_SIZE;
114 for (p=(u_long*)page_address(page); p<max; p++) 114 for (p=(u_long*)page_address(page); p<max; p++)
115 if (*p != -1UL) { 115 if (*p != -1UL) {
116 lock_page(page); 116 lock_page(page);
117 memset(page_address(page), 0xff, PAGE_SIZE); 117 memset(page_address(page), 0xff, PAGE_SIZE);
@@ -206,7 +206,7 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf,
206 if (retlen) 206 if (retlen)
207 *retlen = 0; 207 *retlen = 0;
208 while (len) { 208 while (len) {
209 if ((offset+len) > PAGE_SIZE) 209 if ((offset+len) > PAGE_SIZE)
210 cpylen = PAGE_SIZE - offset; // multiple pages 210 cpylen = PAGE_SIZE - offset; // multiple pages
211 else 211 else
212 cpylen = len; // this page 212 cpylen = len; // this page
diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
index 5fc532895a24..be5e88b3888d 100644
--- a/drivers/mtd/devices/doc2000.c
+++ b/drivers/mtd/devices/doc2000.c
@@ -4,7 +4,7 @@
4 * (c) 1999 Machine Vision Holdings, Inc. 4 * (c) 1999 Machine Vision Holdings, Inc.
5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> 5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
6 * 6 *
7 * $Id: doc2000.c,v 1.66 2005/01/05 18:05:12 dwmw2 Exp $ 7 * $Id: doc2000.c,v 1.67 2005/11/07 11:14:24 gleixner Exp $
8 */ 8 */
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
@@ -58,7 +58,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
58 size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); 58 size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
59static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, 59static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
60 size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); 60 size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
61static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, 61static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
62 unsigned long count, loff_t to, size_t *retlen, 62 unsigned long count, loff_t to, size_t *retlen,
63 u_char *eccbuf, struct nand_oobinfo *oobsel); 63 u_char *eccbuf, struct nand_oobinfo *oobsel);
64static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 64static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
@@ -76,14 +76,14 @@ static void DoC_Delay(struct DiskOnChip *doc, unsigned short cycles)
76{ 76{
77 volatile char dummy; 77 volatile char dummy;
78 int i; 78 int i;
79 79
80 for (i = 0; i < cycles; i++) { 80 for (i = 0; i < cycles; i++) {
81 if (DoC_is_Millennium(doc)) 81 if (DoC_is_Millennium(doc))
82 dummy = ReadDOC(doc->virtadr, NOP); 82 dummy = ReadDOC(doc->virtadr, NOP);
83 else 83 else
84 dummy = ReadDOC(doc->virtadr, DOCStatus); 84 dummy = ReadDOC(doc->virtadr, DOCStatus);
85 } 85 }
86 86
87} 87}
88 88
89/* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */ 89/* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
@@ -220,8 +220,8 @@ static int DoC_Address(struct DiskOnChip *doc, int numbytes, unsigned long ofs,
220 WriteDOC(ofs & 0xff, docptr, WritePipeTerm); 220 WriteDOC(ofs & 0xff, docptr, WritePipeTerm);
221 221
222 DoC_Delay(doc, 2); /* Needed for some slow flash chips. mf. */ 222 DoC_Delay(doc, 2); /* Needed for some slow flash chips. mf. */
223 223
224 /* FIXME: The SlowIO's for millennium could be replaced by 224 /* FIXME: The SlowIO's for millennium could be replaced by
225 a single WritePipeTerm here. mf. */ 225 a single WritePipeTerm here. mf. */
226 226
227 /* Lower the ALE line */ 227 /* Lower the ALE line */
@@ -377,9 +377,9 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
377 if (mfr == 0xff || mfr == 0) 377 if (mfr == 0xff || mfr == 0)
378 return 0; 378 return 0;
379 379
380 /* Check it's the same as the first chip we identified. 380 /* Check it's the same as the first chip we identified.
381 * M-Systems say that any given DiskOnChip device should only 381 * M-Systems say that any given DiskOnChip device should only
382 * contain _one_ type of flash part, although that's not a 382 * contain _one_ type of flash part, although that's not a
383 * hardware restriction. */ 383 * hardware restriction. */
384 if (doc->mfr) { 384 if (doc->mfr) {
385 if (doc->mfr == mfr && doc->id == id) 385 if (doc->mfr == mfr && doc->id == id)
@@ -397,7 +397,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
397 for (j = 0; nand_manuf_ids[j].id != 0x0; j++) { 397 for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {
398 if (nand_manuf_ids[j].id == mfr) 398 if (nand_manuf_ids[j].id == mfr)
399 break; 399 break;
400 } 400 }
401 printk(KERN_INFO 401 printk(KERN_INFO
402 "Flash chip found: Manufacturer ID: %2.2X, " 402 "Flash chip found: Manufacturer ID: %2.2X, "
403 "Chip ID: %2.2X (%s:%s)\n", mfr, id, 403 "Chip ID: %2.2X (%s:%s)\n", mfr, id,
@@ -405,7 +405,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
405 if (!doc->mfr) { 405 if (!doc->mfr) {
406 doc->mfr = mfr; 406 doc->mfr = mfr;
407 doc->id = id; 407 doc->id = id;
408 doc->chipshift = 408 doc->chipshift =
409 ffs((nand_flash_ids[i].chipsize << 20)) - 1; 409 ffs((nand_flash_ids[i].chipsize << 20)) - 1;
410 doc->page256 = (nand_flash_ids[i].pagesize == 256) ? 1 : 0; 410 doc->page256 = (nand_flash_ids[i].pagesize == 256) ? 1 : 0;
411 doc->pageadrlen = doc->chipshift > 25 ? 3 : 2; 411 doc->pageadrlen = doc->chipshift > 25 ? 3 : 2;
@@ -467,7 +467,7 @@ static void DoC_ScanChips(struct DiskOnChip *this, int maxchips)
467 467
468 ret = 0; 468 ret = 0;
469 469
470 /* Fill out the chip array with {floor, chipno} for each 470 /* Fill out the chip array with {floor, chipno} for each
471 * detected chip in the device. */ 471 * detected chip in the device. */
472 for (floor = 0; floor < MAX_FLOORS; floor++) { 472 for (floor = 0; floor < MAX_FLOORS; floor++) {
473 for (chip = 0; chip < numchips[floor]; chip++) { 473 for (chip = 0; chip < numchips[floor]; chip++) {
@@ -757,12 +757,12 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
757 (long)from, eccbuf[0], eccbuf[1], eccbuf[2], 757 (long)from, eccbuf[0], eccbuf[1], eccbuf[2],
758 eccbuf[3], eccbuf[4], eccbuf[5]); 758 eccbuf[3], eccbuf[4], eccbuf[5]);
759#endif 759#endif
760 760
761 /* disable the ECC engine */ 761 /* disable the ECC engine */
762 WriteDOC(DOC_ECC_DIS, docptr , ECCConf); 762 WriteDOC(DOC_ECC_DIS, docptr , ECCConf);
763 } 763 }
764 764
765 /* according to 11.4.1, we need to wait for the busy line 765 /* according to 11.4.1, we need to wait for the busy line
766 * drop if we read to the end of the page. */ 766 * drop if we read to the end of the page. */
767 if(0 == ((from + len) & 0x1ff)) 767 if(0 == ((from + len) & 0x1ff))
768 { 768 {
@@ -941,7 +941,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
941 941
942 /* Let the caller know we completed it */ 942 /* Let the caller know we completed it */
943 *retlen += len; 943 *retlen += len;
944 944
945 if (eccbuf) { 945 if (eccbuf) {
946 unsigned char x[8]; 946 unsigned char x[8];
947 size_t dummy; 947 size_t dummy;
@@ -950,10 +950,10 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
950 /* Write the ECC data to flash */ 950 /* Write the ECC data to flash */
951 for (di=0; di<6; di++) 951 for (di=0; di<6; di++)
952 x[di] = eccbuf[di]; 952 x[di] = eccbuf[di];
953 953
954 x[6]=0x55; 954 x[6]=0x55;
955 x[7]=0x55; 955 x[7]=0x55;
956 956
957 ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x); 957 ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x);
958 if (ret) { 958 if (ret) {
959 up(&this->lock); 959 up(&this->lock);
@@ -970,7 +970,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
970 return 0; 970 return 0;
971} 971}
972 972
973static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, 973static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
974 unsigned long count, loff_t to, size_t *retlen, 974 unsigned long count, loff_t to, size_t *retlen,
975 u_char *eccbuf, struct nand_oobinfo *oobsel) 975 u_char *eccbuf, struct nand_oobinfo *oobsel)
976{ 976{
@@ -1022,7 +1022,7 @@ static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1022 break; 1022 break;
1023 1023
1024 to += thislen; 1024 to += thislen;
1025 } 1025 }
1026 1026
1027 up(&writev_buf_sem); 1027 up(&writev_buf_sem);
1028 *retlen = totretlen; 1028 *retlen = totretlen;
@@ -1080,7 +1080,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
1080 /* Reading the full OOB data drops us off of the end of the page, 1080 /* Reading the full OOB data drops us off of the end of the page,
1081 * causing the flash device to go into busy mode, so we need 1081 * causing the flash device to go into busy mode, so we need
1082 * to wait until ready 11.4.1 and Toshiba TC58256FT docs */ 1082 * to wait until ready 11.4.1 and Toshiba TC58256FT docs */
1083 1083
1084 ret = DoC_WaitReady(this); 1084 ret = DoC_WaitReady(this);
1085 1085
1086 up(&this->lock); 1086 up(&this->lock);
@@ -1190,7 +1190,7 @@ static int doc_write_oob_nolock(struct mtd_info *mtd, loff_t ofs, size_t len,
1190 return 0; 1190 return 0;
1191 1191
1192} 1192}
1193 1193
1194static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 1194static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
1195 size_t * retlen, const u_char * buf) 1195 size_t * retlen, const u_char * buf)
1196{ 1196{
@@ -1222,7 +1222,7 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr)
1222 } 1222 }
1223 1223
1224 instr->state = MTD_ERASING; 1224 instr->state = MTD_ERASING;
1225 1225
1226 /* FIXME: Do this in the background. Use timers or schedule_task() */ 1226 /* FIXME: Do this in the background. Use timers or schedule_task() */
1227 while(len) { 1227 while(len) {
1228 mychip = &this->chips[ofs >> this->chipshift]; 1228 mychip = &this->chips[ofs >> this->chipshift];
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
index 1e704915ef08..fcb28a6fd89f 100644
--- a/drivers/mtd/devices/doc2001.c
+++ b/drivers/mtd/devices/doc2001.c
@@ -4,7 +4,7 @@
4 * (c) 1999 Machine Vision Holdings, Inc. 4 * (c) 1999 Machine Vision Holdings, Inc.
5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> 5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
6 * 6 *
7 * $Id: doc2001.c,v 1.48 2005/01/05 18:05:12 dwmw2 Exp $ 7 * $Id: doc2001.c,v 1.49 2005/11/07 11:14:24 gleixner Exp $
8 */ 8 */
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
@@ -196,10 +196,10 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
196 DoC_Command(doc->virtadr, NAND_CMD_RESET, CDSN_CTRL_WP); 196 DoC_Command(doc->virtadr, NAND_CMD_RESET, CDSN_CTRL_WP);
197 DoC_WaitReady(doc->virtadr); 197 DoC_WaitReady(doc->virtadr);
198 198
199 /* Read the NAND chip ID: 1. Send ReadID command */ 199 /* Read the NAND chip ID: 1. Send ReadID command */
200 DoC_Command(doc->virtadr, NAND_CMD_READID, CDSN_CTRL_WP); 200 DoC_Command(doc->virtadr, NAND_CMD_READID, CDSN_CTRL_WP);
201 201
202 /* Read the NAND chip ID: 2. Send address byte zero */ 202 /* Read the NAND chip ID: 2. Send address byte zero */
203 DoC_Address(doc->virtadr, 1, 0x00, CDSN_CTRL_WP, 0x00); 203 DoC_Address(doc->virtadr, 1, 0x00, CDSN_CTRL_WP, 0x00);
204 204
205 /* Read the manufacturer and device id codes of the flash device through 205 /* Read the manufacturer and device id codes of the flash device through
@@ -223,7 +223,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
223 for (j = 0; nand_manuf_ids[j].id != 0x0; j++) { 223 for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {
224 if (nand_manuf_ids[j].id == mfr) 224 if (nand_manuf_ids[j].id == mfr)
225 break; 225 break;
226 } 226 }
227 printk(KERN_INFO "Flash chip found: Manufacturer ID: %2.2X, " 227 printk(KERN_INFO "Flash chip found: Manufacturer ID: %2.2X, "
228 "Chip ID: %2.2X (%s:%s)\n", 228 "Chip ID: %2.2X (%s:%s)\n",
229 mfr, id, nand_manuf_ids[j].name, nand_flash_ids[i].name); 229 mfr, id, nand_manuf_ids[j].name, nand_flash_ids[i].name);
@@ -275,7 +275,7 @@ static void DoC_ScanChips(struct DiskOnChip *this)
275 return; 275 return;
276 } 276 }
277 277
278 /* Fill out the chip array with {floor, chipno} for each 278 /* Fill out the chip array with {floor, chipno} for each
279 * detected chip in the device. */ 279 * detected chip in the device. */
280 for (floor = 0, ret = 0; floor < MAX_FLOORS_MIL; floor++) { 280 for (floor = 0, ret = 0; floor < MAX_FLOORS_MIL; floor++) {
281 for (chip = 0 ; chip < numchips[floor] ; chip++) { 281 for (chip = 0 ; chip < numchips[floor] ; chip++) {
@@ -309,7 +309,7 @@ static int DoCMil_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
309 tmp2 = ReadDOC(doc2->virtadr, AliasResolution); 309 tmp2 = ReadDOC(doc2->virtadr, AliasResolution);
310 if (tmp1 != tmp2) 310 if (tmp1 != tmp2)
311 return 0; 311 return 0;
312 312
313 WriteDOC((tmp1+1) % 0xff, doc1->virtadr, AliasResolution); 313 WriteDOC((tmp1+1) % 0xff, doc1->virtadr, AliasResolution);
314 tmp2 = ReadDOC(doc2->virtadr, AliasResolution); 314 tmp2 = ReadDOC(doc2->virtadr, AliasResolution);
315 if (tmp2 == (tmp1+1) % 0xff) 315 if (tmp2 == (tmp1+1) % 0xff)
@@ -425,7 +425,7 @@ static int doc_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
425 return -EINVAL; 425 return -EINVAL;
426 426
427 /* Don't allow a single read to cross a 512-byte block boundary */ 427 /* Don't allow a single read to cross a 512-byte block boundary */
428 if (from + len > ((from | 0x1ff) + 1)) 428 if (from + len > ((from | 0x1ff) + 1))
429 len = ((from | 0x1ff) + 1) - from; 429 len = ((from | 0x1ff) + 1) - from;
430 430
431 /* Find the chip which is to be used and select it */ 431 /* Find the chip which is to be used and select it */
@@ -552,7 +552,7 @@ static int doc_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
552 552
553#if 0 553#if 0
554 /* Don't allow a single write to cross a 512-byte block boundary */ 554 /* Don't allow a single write to cross a 512-byte block boundary */
555 if (to + len > ( (to | 0x1ff) + 1)) 555 if (to + len > ( (to | 0x1ff) + 1))
556 len = ((to | 0x1ff) + 1) - to; 556 len = ((to | 0x1ff) + 1) - to;
557#else 557#else
558 /* Don't allow writes which aren't exactly one block */ 558 /* Don't allow writes which aren't exactly one block */
@@ -632,7 +632,7 @@ static int doc_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
632 632
633 /* write the block status BLOCK_USED (0x5555) at the end of ECC data 633 /* write the block status BLOCK_USED (0x5555) at the end of ECC data
634 FIXME: this is only a hack for programming the IPL area for LinuxBIOS 634 FIXME: this is only a hack for programming the IPL area for LinuxBIOS
635 and should be replace with proper codes in user space utilities */ 635 and should be replace with proper codes in user space utilities */
636 WriteDOC(0x55, docptr, Mil_CDSN_IO); 636 WriteDOC(0x55, docptr, Mil_CDSN_IO);
637 WriteDOC(0x55, docptr, Mil_CDSN_IO + 1); 637 WriteDOC(0x55, docptr, Mil_CDSN_IO + 1);
638 638
@@ -802,7 +802,7 @@ int doc_erase (struct mtd_info *mtd, struct erase_info *instr)
802 void __iomem *docptr = this->virtadr; 802 void __iomem *docptr = this->virtadr;
803 struct Nand *mychip = &this->chips[ofs >> this->chipshift]; 803 struct Nand *mychip = &this->chips[ofs >> this->chipshift];
804 804
805 if (len != mtd->erasesize) 805 if (len != mtd->erasesize)
806 printk(KERN_WARNING "Erase not right size (%x != %x)n", 806 printk(KERN_WARNING "Erase not right size (%x != %x)n",
807 len, mtd->erasesize); 807 len, mtd->erasesize);
808 808
@@ -870,9 +870,9 @@ static void __exit cleanup_doc2001(void)
870 while ((mtd=docmillist)) { 870 while ((mtd=docmillist)) {
871 this = mtd->priv; 871 this = mtd->priv;
872 docmillist = this->nextdoc; 872 docmillist = this->nextdoc;
873 873
874 del_mtd_device(mtd); 874 del_mtd_device(mtd);
875 875
876 iounmap(this->virtadr); 876 iounmap(this->virtadr);
877 kfree(this->chips); 877 kfree(this->chips);
878 kfree(mtd); 878 kfree(mtd);
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c
index ed47bafb2ce2..0595cc7324b2 100644
--- a/drivers/mtd/devices/doc2001plus.c
+++ b/drivers/mtd/devices/doc2001plus.c
@@ -6,7 +6,7 @@
6 * (c) 1999 Machine Vision Holdings, Inc. 6 * (c) 1999 Machine Vision Holdings, Inc.
7 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> 7 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
8 * 8 *
9 * $Id: doc2001plus.c,v 1.13 2005/01/05 18:05:12 dwmw2 Exp $ 9 * $Id: doc2001plus.c,v 1.14 2005/11/07 11:14:24 gleixner Exp $
10 * 10 *
11 * Released under GPL 11 * Released under GPL
12 */ 12 */
@@ -293,10 +293,10 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
293 DoC_Command(docptr, NAND_CMD_RESET, 0); 293 DoC_Command(docptr, NAND_CMD_RESET, 0);
294 DoC_WaitReady(docptr); 294 DoC_WaitReady(docptr);
295 295
296 /* Read the NAND chip ID: 1. Send ReadID command */ 296 /* Read the NAND chip ID: 1. Send ReadID command */
297 DoC_Command(docptr, NAND_CMD_READID, 0); 297 DoC_Command(docptr, NAND_CMD_READID, 0);
298 298
299 /* Read the NAND chip ID: 2. Send address byte zero */ 299 /* Read the NAND chip ID: 2. Send address byte zero */
300 DoC_Address(doc, 1, 0x00, 0, 0x00); 300 DoC_Address(doc, 1, 0x00, 0, 0x00);
301 301
302 WriteDOC(0, docptr, Mplus_FlashControl); 302 WriteDOC(0, docptr, Mplus_FlashControl);
@@ -365,7 +365,7 @@ static void DoC_ScanChips(struct DiskOnChip *this)
365 this->interleave = 1; 365 this->interleave = 1;
366 366
367 /* Check the ASIC agrees */ 367 /* Check the ASIC agrees */
368 if ( (this->interleave << 2) != 368 if ( (this->interleave << 2) !=
369 (ReadDOC(this->virtadr, Mplus_Configuration) & 4)) { 369 (ReadDOC(this->virtadr, Mplus_Configuration) & 4)) {
370 u_char conf = ReadDOC(this->virtadr, Mplus_Configuration); 370 u_char conf = ReadDOC(this->virtadr, Mplus_Configuration);
371 printk(KERN_NOTICE "Setting DiskOnChip Millennium Plus interleave to %s\n", 371 printk(KERN_NOTICE "Setting DiskOnChip Millennium Plus interleave to %s\n",
@@ -398,7 +398,7 @@ static void DoC_ScanChips(struct DiskOnChip *this)
398 return; 398 return;
399 } 399 }
400 400
401 /* Fill out the chip array with {floor, chipno} for each 401 /* Fill out the chip array with {floor, chipno} for each
402 * detected chip in the device. */ 402 * detected chip in the device. */
403 for (floor = 0, ret = 0; floor < MAX_FLOORS_MPLUS; floor++) { 403 for (floor = 0, ret = 0; floor < MAX_FLOORS_MPLUS; floor++) {
404 for (chip = 0 ; chip < numchips[floor] ; chip++) { 404 for (chip = 0 ; chip < numchips[floor] ; chip++) {
@@ -432,7 +432,7 @@ static int DoCMilPlus_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
432 tmp2 = ReadDOC(doc2->virtadr, Mplus_AliasResolution); 432 tmp2 = ReadDOC(doc2->virtadr, Mplus_AliasResolution);
433 if (tmp1 != tmp2) 433 if (tmp1 != tmp2)
434 return 0; 434 return 0;
435 435
436 WriteDOC((tmp1+1) % 0xff, doc1->virtadr, Mplus_AliasResolution); 436 WriteDOC((tmp1+1) % 0xff, doc1->virtadr, Mplus_AliasResolution);
437 tmp2 = ReadDOC(doc2->virtadr, Mplus_AliasResolution); 437 tmp2 = ReadDOC(doc2->virtadr, Mplus_AliasResolution);
438 if (tmp2 == (tmp1+1) % 0xff) 438 if (tmp2 == (tmp1+1) % 0xff)
@@ -624,7 +624,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
624 return -EINVAL; 624 return -EINVAL;
625 625
626 /* Don't allow a single read to cross a 512-byte block boundary */ 626 /* Don't allow a single read to cross a 512-byte block boundary */
627 if (from + len > ((from | 0x1ff) + 1)) 627 if (from + len > ((from | 0x1ff) + 1))
628 len = ((from | 0x1ff) + 1) - from; 628 len = ((from | 0x1ff) + 1) - from;
629 629
630 DoC_CheckASIC(docptr); 630 DoC_CheckASIC(docptr);
@@ -1066,7 +1066,7 @@ int doc_erase(struct mtd_info *mtd, struct erase_info *instr)
1066 1066
1067 DoC_CheckASIC(docptr); 1067 DoC_CheckASIC(docptr);
1068 1068
1069 if (len != mtd->erasesize) 1069 if (len != mtd->erasesize)
1070 printk(KERN_WARNING "MTD: Erase not right size (%x != %x)n", 1070 printk(KERN_WARNING "MTD: Erase not right size (%x != %x)n",
1071 len, mtd->erasesize); 1071 len, mtd->erasesize);
1072 1072
@@ -1136,9 +1136,9 @@ static void __exit cleanup_doc2001plus(void)
1136 while ((mtd=docmilpluslist)) { 1136 while ((mtd=docmilpluslist)) {
1137 this = mtd->priv; 1137 this = mtd->priv;
1138 docmilpluslist = this->nextdoc; 1138 docmilpluslist = this->nextdoc;
1139 1139
1140 del_mtd_device(mtd); 1140 del_mtd_device(mtd);
1141 1141
1142 iounmap(this->virtadr); 1142 iounmap(this->virtadr);
1143 kfree(this->chips); 1143 kfree(this->chips);
1144 kfree(mtd); 1144 kfree(mtd);
diff --git a/drivers/mtd/devices/docecc.c b/drivers/mtd/devices/docecc.c
index 24f670b5a4f3..cd3db72bef96 100644
--- a/drivers/mtd/devices/docecc.c
+++ b/drivers/mtd/devices/docecc.c
@@ -4,10 +4,10 @@
4 * GNU GPL License. The rest is simply to convert the disk on chip 4 * GNU GPL License. The rest is simply to convert the disk on chip
5 * syndrom into a standard syndom. 5 * syndrom into a standard syndom.
6 * 6 *
7 * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 7 * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
8 * Copyright (C) 2000 Netgem S.A. 8 * Copyright (C) 2000 Netgem S.A.
9 * 9 *
10 * $Id: docecc.c,v 1.5 2003/05/21 15:15:06 dwmw2 Exp $ 10 * $Id: docecc.c,v 1.7 2005/11/07 11:14:25 gleixner Exp $
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
@@ -122,7 +122,7 @@ for(ci=(n)-1;ci >=0;ci--)\
122 a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1) 122 a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
123 we consider the integer "i" whose binary representation with a(0) being LSB 123 we consider the integer "i" whose binary representation with a(0) being LSB
124 and a(m-1) MSB is (a(0),a(1),...,a(m-1)) and locate the entry 124 and a(m-1) MSB is (a(0),a(1),...,a(m-1)) and locate the entry
125 "index_of[i]". Now, @^index_of[i] is that element whose polynomial 125 "index_of[i]". Now, @^index_of[i] is that element whose polynomial
126 representation is (a(0),a(1),a(2),...,a(m-1)). 126 representation is (a(0),a(1),a(2),...,a(m-1)).
127 NOTE: 127 NOTE:
128 The element alpha_to[2^m-1] = 0 always signifying that the 128 The element alpha_to[2^m-1] = 0 always signifying that the
@@ -130,7 +130,7 @@ for(ci=(n)-1;ci >=0;ci--)\
130 Similarily, the element index_of[0] = A0 always signifying 130 Similarily, the element index_of[0] = A0 always signifying
131 that the power of alpha which has the polynomial representation 131 that the power of alpha which has the polynomial representation
132 (0,0,...,0) is "infinity". 132 (0,0,...,0) is "infinity".
133 133
134*/ 134*/
135 135
136static void 136static void
@@ -176,7 +176,7 @@ generate_gf(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1])
176 * are written back. NOTE! This array must be at least NN-KK elements long. 176 * are written back. NOTE! This array must be at least NN-KK elements long.
177 * The corrected data are written in eras_val[]. They must be xor with the data 177 * The corrected data are written in eras_val[]. They must be xor with the data
178 * to retrieve the correct data : data[erase_pos[i]] ^= erase_val[i] . 178 * to retrieve the correct data : data[erase_pos[i]] ^= erase_val[i] .
179 * 179 *
180 * First "no_eras" erasures are declared by the calling program. Then, the 180 * First "no_eras" erasures are declared by the calling program. Then, the
181 * maximum # of errors correctable is t_after_eras = floor((NN-KK-no_eras)/2). 181 * maximum # of errors correctable is t_after_eras = floor((NN-KK-no_eras)/2).
182 * If the number of channel errors is not greater than "t_after_eras" the 182 * If the number of channel errors is not greater than "t_after_eras" the
@@ -189,7 +189,7 @@ generate_gf(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1])
189 * */ 189 * */
190static int 190static int
191eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1], 191eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
192 gf bb[NN - KK + 1], gf eras_val[NN-KK], int eras_pos[NN-KK], 192 gf bb[NN - KK + 1], gf eras_val[NN-KK], int eras_pos[NN-KK],
193 int no_eras) 193 int no_eras)
194{ 194{
195 int deg_lambda, el, deg_omega; 195 int deg_lambda, el, deg_omega;
@@ -212,7 +212,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
212 count = 0; 212 count = 0;
213 goto finish; 213 goto finish;
214 } 214 }
215 215
216 for(i=1;i<=NN-KK;i++){ 216 for(i=1;i<=NN-KK;i++){
217 s[i] = bb[0]; 217 s[i] = bb[0];
218 } 218 }
@@ -220,7 +220,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
220 if(bb[j] == 0) 220 if(bb[j] == 0)
221 continue; 221 continue;
222 tmp = Index_of[bb[j]]; 222 tmp = Index_of[bb[j]];
223 223
224 for(i=1;i<=NN-KK;i++) 224 for(i=1;i<=NN-KK;i++)
225 s[i] ^= Alpha_to[modnn(tmp + (B0+i-1)*PRIM*j)]; 225 s[i] ^= Alpha_to[modnn(tmp + (B0+i-1)*PRIM*j)];
226 } 226 }
@@ -234,7 +234,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
234 tmp = modnn(tmp + 2 * KK * (B0+i-1)*PRIM); 234 tmp = modnn(tmp + 2 * KK * (B0+i-1)*PRIM);
235 s[i] = tmp; 235 s[i] = tmp;
236 } 236 }
237 237
238 CLEAR(&lambda[1],NN-KK); 238 CLEAR(&lambda[1],NN-KK);
239 lambda[0] = 1; 239 lambda[0] = 1;
240 240
@@ -252,7 +252,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
252#if DEBUG_ECC >= 1 252#if DEBUG_ECC >= 1
253 /* Test code that verifies the erasure locator polynomial just constructed 253 /* Test code that verifies the erasure locator polynomial just constructed
254 Needed only for decoder debugging. */ 254 Needed only for decoder debugging. */
255 255
256 /* find roots of the erasure location polynomial */ 256 /* find roots of the erasure location polynomial */
257 for(i=1;i<=no_eras;i++) 257 for(i=1;i<=no_eras;i++)
258 reg[i] = Index_of[lambda[i]]; 258 reg[i] = Index_of[lambda[i]];
@@ -286,7 +286,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
286 } 286 }
287 for(i=0;i<NN-KK+1;i++) 287 for(i=0;i<NN-KK+1;i++)
288 b[i] = Index_of[lambda[i]]; 288 b[i] = Index_of[lambda[i]];
289 289
290 /* 290 /*
291 * Begin Berlekamp-Massey algorithm to determine error+erasure 291 * Begin Berlekamp-Massey algorithm to determine error+erasure
292 * locator polynomial 292 * locator polynomial
@@ -389,7 +389,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
389 omega[i] = Index_of[tmp]; 389 omega[i] = Index_of[tmp];
390 } 390 }
391 omega[NN-KK] = A0; 391 omega[NN-KK] = A0;
392 392
393 /* 393 /*
394 * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 = 394 * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
395 * inv(X(l))**(B0-1) and den = lambda_pr(inv(X(l))) all in poly-form 395 * inv(X(l))**(B0-1) and den = lambda_pr(inv(X(l))) all in poly-form
@@ -402,7 +402,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
402 } 402 }
403 num2 = Alpha_to[modnn(root[j] * (B0 - 1) + NN)]; 403 num2 = Alpha_to[modnn(root[j] * (B0 - 1) + NN)];
404 den = 0; 404 den = 0;
405 405
406 /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */ 406 /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
407 for (i = min(deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) { 407 for (i = min(deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) {
408 if(lambda[i+1] != A0) 408 if(lambda[i+1] != A0)
@@ -436,11 +436,11 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
436/* The sector bytes are packed into NB_DATA MM bits words */ 436/* The sector bytes are packed into NB_DATA MM bits words */
437#define NB_DATA (((SECTOR_SIZE + 1) * 8 + 6) / MM) 437#define NB_DATA (((SECTOR_SIZE + 1) * 8 + 6) / MM)
438 438
439/* 439/*
440 * Correct the errors in 'sector[]' by using 'ecc1[]' which is the 440 * Correct the errors in 'sector[]' by using 'ecc1[]' which is the
441 * content of the feedback shift register applyied to the sector and 441 * content of the feedback shift register applyied to the sector and
442 * the ECC. Return the number of errors corrected (and correct them in 442 * the ECC. Return the number of errors corrected (and correct them in
443 * sector), or -1 if error 443 * sector), or -1 if error
444 */ 444 */
445int doc_decode_ecc(unsigned char sector[SECTOR_SIZE], unsigned char ecc1[6]) 445int doc_decode_ecc(unsigned char sector[SECTOR_SIZE], unsigned char ecc1[6])
446{ 446{
@@ -454,7 +454,7 @@ int doc_decode_ecc(unsigned char sector[SECTOR_SIZE], unsigned char ecc1[6])
454 Alpha_to = kmalloc((NN + 1) * sizeof(dtype), GFP_KERNEL); 454 Alpha_to = kmalloc((NN + 1) * sizeof(dtype), GFP_KERNEL);
455 if (!Alpha_to) 455 if (!Alpha_to)
456 return -1; 456 return -1;
457 457
458 Index_of = kmalloc((NN + 1) * sizeof(dtype), GFP_KERNEL); 458 Index_of = kmalloc((NN + 1) * sizeof(dtype), GFP_KERNEL);
459 if (!Index_of) { 459 if (!Index_of) {
460 kfree(Alpha_to); 460 kfree(Alpha_to);
@@ -470,7 +470,7 @@ int doc_decode_ecc(unsigned char sector[SECTOR_SIZE], unsigned char ecc1[6])
470 bb[2] = ((ecc1[2] & 0xf0) >> 4) | ((ecc1[3] & 0x3f) << 4); 470 bb[2] = ((ecc1[2] & 0xf0) >> 4) | ((ecc1[3] & 0x3f) << 4);
471 bb[3] = ((ecc1[3] & 0xc0) >> 6) | ((ecc1[0] & 0xff) << 2); 471 bb[3] = ((ecc1[3] & 0xc0) >> 6) | ((ecc1[0] & 0xff) << 2);
472 472
473 nb_errors = eras_dec_rs(Alpha_to, Index_of, bb, 473 nb_errors = eras_dec_rs(Alpha_to, Index_of, bb,
474 error_val, error_pos, 0); 474 error_val, error_pos, 0);
475 if (nb_errors <= 0) 475 if (nb_errors <= 0)
476 goto the_end; 476 goto the_end;
@@ -489,7 +489,7 @@ int doc_decode_ecc(unsigned char sector[SECTOR_SIZE], unsigned char ecc1[6])
489 can be modified since pos is even */ 489 can be modified since pos is even */
490 index = (pos >> 3) ^ 1; 490 index = (pos >> 3) ^ 1;
491 bitpos = pos & 7; 491 bitpos = pos & 7;
492 if ((index >= 0 && index < SECTOR_SIZE) || 492 if ((index >= 0 && index < SECTOR_SIZE) ||
493 index == (SECTOR_SIZE + 1)) { 493 index == (SECTOR_SIZE + 1)) {
494 val = error_val[i] >> (2 + bitpos); 494 val = error_val[i] >> (2 + bitpos);
495 parity ^= val; 495 parity ^= val;
@@ -500,7 +500,7 @@ int doc_decode_ecc(unsigned char sector[SECTOR_SIZE], unsigned char ecc1[6])
500 bitpos = (bitpos + 10) & 7; 500 bitpos = (bitpos + 10) & 7;
501 if (bitpos == 0) 501 if (bitpos == 0)
502 bitpos = 8; 502 bitpos = 8;
503 if ((index >= 0 && index < SECTOR_SIZE) || 503 if ((index >= 0 && index < SECTOR_SIZE) ||
504 index == (SECTOR_SIZE + 1)) { 504 index == (SECTOR_SIZE + 1)) {
505 val = error_val[i] << (8 - bitpos); 505 val = error_val[i] << (8 - bitpos);
506 parity ^= val; 506 parity ^= val;
@@ -509,7 +509,7 @@ int doc_decode_ecc(unsigned char sector[SECTOR_SIZE], unsigned char ecc1[6])
509 } 509 }
510 } 510 }
511 } 511 }
512 512
513 /* use parity to test extra errors */ 513 /* use parity to test extra errors */
514 if ((parity & 0xff) != 0) 514 if ((parity & 0xff) != 0)
515 nb_errors = -1; 515 nb_errors = -1;
diff --git a/drivers/mtd/devices/docprobe.c b/drivers/mtd/devices/docprobe.c
index 197d67045e1e..13178b9dd00a 100644
--- a/drivers/mtd/devices/docprobe.c
+++ b/drivers/mtd/devices/docprobe.c
@@ -4,22 +4,22 @@
4/* (C) 1999 Machine Vision Holdings, Inc. */ 4/* (C) 1999 Machine Vision Holdings, Inc. */
5/* (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> */ 5/* (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> */
6 6
7/* $Id: docprobe.c,v 1.44 2005/01/05 12:40:36 dwmw2 Exp $ */ 7/* $Id: docprobe.c,v 1.46 2005/11/07 11:14:25 gleixner Exp $ */
8 8
9 9
10 10
11/* DOC_PASSIVE_PROBE: 11/* DOC_PASSIVE_PROBE:
12 In order to ensure that the BIOS checksum is correct at boot time, and 12 In order to ensure that the BIOS checksum is correct at boot time, and
13 hence that the onboard BIOS extension gets executed, the DiskOnChip 13 hence that the onboard BIOS extension gets executed, the DiskOnChip
14 goes into reset mode when it is read sequentially: all registers 14 goes into reset mode when it is read sequentially: all registers
15 return 0xff until the chip is woken up again by writing to the 15 return 0xff until the chip is woken up again by writing to the
16 DOCControl register. 16 DOCControl register.
17 17
18 Unfortunately, this means that the probe for the DiskOnChip is unsafe, 18 Unfortunately, this means that the probe for the DiskOnChip is unsafe,
19 because one of the first things it does is write to where it thinks 19 because one of the first things it does is write to where it thinks
20 the DOCControl register should be - which may well be shared memory 20 the DOCControl register should be - which may well be shared memory
21 for another device. I've had machines which lock up when this is 21 for another device. I've had machines which lock up when this is
22 attempted. Hence the possibility to do a passive probe, which will fail 22 attempted. Hence the possibility to do a passive probe, which will fail
23 to detect a chip in reset mode, but is at least guaranteed not to lock 23 to detect a chip in reset mode, but is at least guaranteed not to lock
24 the machine. 24 the machine.
25 25
@@ -33,9 +33,9 @@
33 33
34 The old Millennium-only driver has been retained just in case there 34 The old Millennium-only driver has been retained just in case there
35 are problems with the new code. If the combined driver doesn't work 35 are problems with the new code. If the combined driver doesn't work
36 for you, you can try the old one by undefining DOC_SINGLE_DRIVER 36 for you, you can try the old one by undefining DOC_SINGLE_DRIVER
37 below and also enabling it in your configuration. If this fixes the 37 below and also enabling it in your configuration. If this fixes the
38 problems, please send a report to the MTD mailing list at 38 problems, please send a report to the MTD mailing list at
39 <linux-mtd@lists.infradead.org>. 39 <linux-mtd@lists.infradead.org>.
40*/ 40*/
41#define DOC_SINGLE_DRIVER 41#define DOC_SINGLE_DRIVER
@@ -68,16 +68,16 @@ MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe
68static unsigned long __initdata doc_locations[] = { 68static unsigned long __initdata doc_locations[] = {
69#if defined (__alpha__) || defined(__i386__) || defined(__x86_64__) 69#if defined (__alpha__) || defined(__i386__) || defined(__x86_64__)
70#ifdef CONFIG_MTD_DOCPROBE_HIGH 70#ifdef CONFIG_MTD_DOCPROBE_HIGH
71 0xfffc8000, 0xfffca000, 0xfffcc000, 0xfffce000, 71 0xfffc8000, 0xfffca000, 0xfffcc000, 0xfffce000,
72 0xfffd0000, 0xfffd2000, 0xfffd4000, 0xfffd6000, 72 0xfffd0000, 0xfffd2000, 0xfffd4000, 0xfffd6000,
73 0xfffd8000, 0xfffda000, 0xfffdc000, 0xfffde000, 73 0xfffd8000, 0xfffda000, 0xfffdc000, 0xfffde000,
74 0xfffe0000, 0xfffe2000, 0xfffe4000, 0xfffe6000, 74 0xfffe0000, 0xfffe2000, 0xfffe4000, 0xfffe6000,
75 0xfffe8000, 0xfffea000, 0xfffec000, 0xfffee000, 75 0xfffe8000, 0xfffea000, 0xfffec000, 0xfffee000,
76#else /* CONFIG_MTD_DOCPROBE_HIGH */ 76#else /* CONFIG_MTD_DOCPROBE_HIGH */
77 0xc8000, 0xca000, 0xcc000, 0xce000, 77 0xc8000, 0xca000, 0xcc000, 0xce000,
78 0xd0000, 0xd2000, 0xd4000, 0xd6000, 78 0xd0000, 0xd2000, 0xd4000, 0xd6000,
79 0xd8000, 0xda000, 0xdc000, 0xde000, 79 0xd8000, 0xda000, 0xdc000, 0xde000,
80 0xe0000, 0xe2000, 0xe4000, 0xe6000, 80 0xe0000, 0xe2000, 0xe4000, 0xe6000,
81 0xe8000, 0xea000, 0xec000, 0xee000, 81 0xe8000, 0xea000, 0xec000, 0xee000,
82#endif /* CONFIG_MTD_DOCPROBE_HIGH */ 82#endif /* CONFIG_MTD_DOCPROBE_HIGH */
83#elif defined(__PPC__) 83#elif defined(__PPC__)
@@ -111,35 +111,35 @@ static inline int __init doccheck(void __iomem *potential, unsigned long physadr
111 return 0; 111 return 0;
112#endif /* CONFIG_MTD_DOCPROBE_55AA */ 112#endif /* CONFIG_MTD_DOCPROBE_55AA */
113 113
114#ifndef DOC_PASSIVE_PROBE 114#ifndef DOC_PASSIVE_PROBE
115 /* It's not possible to cleanly detect the DiskOnChip - the 115 /* It's not possible to cleanly detect the DiskOnChip - the
116 * bootup procedure will put the device into reset mode, and 116 * bootup procedure will put the device into reset mode, and
117 * it's not possible to talk to it without actually writing 117 * it's not possible to talk to it without actually writing
118 * to the DOCControl register. So we store the current contents 118 * to the DOCControl register. So we store the current contents
119 * of the DOCControl register's location, in case we later decide 119 * of the DOCControl register's location, in case we later decide
120 * that it's not a DiskOnChip, and want to put it back how we 120 * that it's not a DiskOnChip, and want to put it back how we
121 * found it. 121 * found it.
122 */ 122 */
123 tmp2 = ReadDOC(window, DOCControl); 123 tmp2 = ReadDOC(window, DOCControl);
124 124
125 /* Reset the DiskOnChip ASIC */ 125 /* Reset the DiskOnChip ASIC */
126 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, 126 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
127 window, DOCControl); 127 window, DOCControl);
128 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, 128 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
129 window, DOCControl); 129 window, DOCControl);
130 130
131 /* Enable the DiskOnChip ASIC */ 131 /* Enable the DiskOnChip ASIC */
132 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, 132 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL,
133 window, DOCControl); 133 window, DOCControl);
134 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, 134 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL,
135 window, DOCControl); 135 window, DOCControl);
136#endif /* !DOC_PASSIVE_PROBE */ 136#endif /* !DOC_PASSIVE_PROBE */
137 137
138 /* We need to read the ChipID register four times. For some 138 /* We need to read the ChipID register four times. For some
139 newer DiskOnChip 2000 units, the first three reads will 139 newer DiskOnChip 2000 units, the first three reads will
140 return the DiskOnChip Millennium ident. Don't ask. */ 140 return the DiskOnChip Millennium ident. Don't ask. */
141 ChipID = ReadDOC(window, ChipID); 141 ChipID = ReadDOC(window, ChipID);
142 142
143 switch (ChipID) { 143 switch (ChipID) {
144 case DOC_ChipID_Doc2k: 144 case DOC_ChipID_Doc2k:
145 /* Check the TOGGLE bit in the ECC register */ 145 /* Check the TOGGLE bit in the ECC register */
@@ -149,7 +149,7 @@ static inline int __init doccheck(void __iomem *potential, unsigned long physadr
149 if (tmp != tmpb && tmp == tmpc) 149 if (tmp != tmpb && tmp == tmpc)
150 return ChipID; 150 return ChipID;
151 break; 151 break;
152 152
153 case DOC_ChipID_DocMil: 153 case DOC_ChipID_DocMil:
154 /* Check for the new 2000 with Millennium ASIC */ 154 /* Check for the new 2000 with Millennium ASIC */
155 ReadDOC(window, ChipID); 155 ReadDOC(window, ChipID);
@@ -164,7 +164,7 @@ static inline int __init doccheck(void __iomem *potential, unsigned long physadr
164 if (tmp != tmpb && tmp == tmpc) 164 if (tmp != tmpb && tmp == tmpc)
165 return ChipID; 165 return ChipID;
166 break; 166 break;
167 167
168 case DOC_ChipID_DocMilPlus16: 168 case DOC_ChipID_DocMilPlus16:
169 case DOC_ChipID_DocMilPlus32: 169 case DOC_ChipID_DocMilPlus32:
170 case 0: 170 case 0:
@@ -179,7 +179,7 @@ static inline int __init doccheck(void __iomem *potential, unsigned long physadr
179 DOC_MODE_BDECT; 179 DOC_MODE_BDECT;
180 WriteDOC(tmp, window, Mplus_DOCControl); 180 WriteDOC(tmp, window, Mplus_DOCControl);
181 WriteDOC(~tmp, window, Mplus_CtrlConfirm); 181 WriteDOC(~tmp, window, Mplus_CtrlConfirm);
182 182
183 mdelay(1); 183 mdelay(1);
184 /* Enable the DiskOnChip ASIC */ 184 /* Enable the DiskOnChip ASIC */
185 tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | 185 tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT |
@@ -187,7 +187,7 @@ static inline int __init doccheck(void __iomem *potential, unsigned long physadr
187 WriteDOC(tmp, window, Mplus_DOCControl); 187 WriteDOC(tmp, window, Mplus_DOCControl);
188 WriteDOC(~tmp, window, Mplus_CtrlConfirm); 188 WriteDOC(~tmp, window, Mplus_CtrlConfirm);
189 mdelay(1); 189 mdelay(1);
190#endif /* !DOC_PASSIVE_PROBE */ 190#endif /* !DOC_PASSIVE_PROBE */
191 191
192 ChipID = ReadDOC(window, ChipID); 192 ChipID = ReadDOC(window, ChipID);
193 193
@@ -227,7 +227,7 @@ static inline int __init doccheck(void __iomem *potential, unsigned long physadr
227 WriteDOC(tmp2, window, DOCControl); 227 WriteDOC(tmp2, window, DOCControl);
228#endif 228#endif
229 return 0; 229 return 0;
230} 230}
231 231
232static int docfound; 232static int docfound;
233 233
@@ -244,10 +244,10 @@ static void __init DoC_Probe(unsigned long physadr)
244 void (*initroutine)(struct mtd_info *) = NULL; 244 void (*initroutine)(struct mtd_info *) = NULL;
245 245
246 docptr = ioremap(physadr, DOC_IOREMAP_LEN); 246 docptr = ioremap(physadr, DOC_IOREMAP_LEN);
247 247
248 if (!docptr) 248 if (!docptr)
249 return; 249 return;
250 250
251 if ((ChipID = doccheck(docptr, physadr))) { 251 if ((ChipID = doccheck(docptr, physadr))) {
252 if (ChipID == DOC_ChipID_Doc2kTSOP) { 252 if (ChipID == DOC_ChipID_Doc2kTSOP) {
253 /* Remove this at your own peril. The hardware driver works but nothing prevents you from erasing bad blocks */ 253 /* Remove this at your own peril. The hardware driver works but nothing prevents you from erasing bad blocks */
@@ -263,9 +263,9 @@ static void __init DoC_Probe(unsigned long physadr)
263 iounmap(docptr); 263 iounmap(docptr);
264 return; 264 return;
265 } 265 }
266 266
267 this = (struct DiskOnChip *)(&mtd[1]); 267 this = (struct DiskOnChip *)(&mtd[1]);
268 268
269 memset((char *)mtd,0, sizeof(struct mtd_info)); 269 memset((char *)mtd,0, sizeof(struct mtd_info));
270 memset((char *)this, 0, sizeof(struct DiskOnChip)); 270 memset((char *)this, 0, sizeof(struct DiskOnChip));
271 271
@@ -281,13 +281,13 @@ static void __init DoC_Probe(unsigned long physadr)
281 im_funcname = "DoC2k_init"; 281 im_funcname = "DoC2k_init";
282 im_modname = "doc2000"; 282 im_modname = "doc2000";
283 break; 283 break;
284 284
285 case DOC_ChipID_Doc2k: 285 case DOC_ChipID_Doc2k:
286 name="2000"; 286 name="2000";
287 im_funcname = "DoC2k_init"; 287 im_funcname = "DoC2k_init";
288 im_modname = "doc2000"; 288 im_modname = "doc2000";
289 break; 289 break;
290 290
291 case DOC_ChipID_DocMil: 291 case DOC_ChipID_DocMil:
292 name="Millennium"; 292 name="Millennium";
293#ifdef DOC_SINGLE_DRIVER 293#ifdef DOC_SINGLE_DRIVER
@@ -331,7 +331,7 @@ static void __init DoC_Probe(unsigned long physadr)
331static int __init init_doc(void) 331static int __init init_doc(void)
332{ 332{
333 int i; 333 int i;
334 334
335 if (doc_config_location) { 335 if (doc_config_location) {
336 printk(KERN_INFO "Using configured DiskOnChip probe address 0x%lx\n", doc_config_location); 336 printk(KERN_INFO "Using configured DiskOnChip probe address 0x%lx\n", doc_config_location);
337 DoC_Probe(doc_config_location); 337 DoC_Probe(doc_config_location);
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
index df987a53ed9c..1e876fcb0408 100644
--- a/drivers/mtd/devices/lart.c
+++ b/drivers/mtd/devices/lart.c
@@ -2,7 +2,7 @@
2/* 2/*
3 * MTD driver for the 28F160F3 Flash Memory (non-CFI) on LART. 3 * MTD driver for the 28F160F3 Flash Memory (non-CFI) on LART.
4 * 4 *
5 * $Id: lart.c,v 1.7 2004/08/09 13:19:44 dwmw2 Exp $ 5 * $Id: lart.c,v 1.9 2005/11/07 11:14:25 gleixner Exp $
6 * 6 *
7 * Author: Abraham vd Merwe <abraham@2d3d.co.za> 7 * Author: Abraham vd Merwe <abraham@2d3d.co.za>
8 * 8 *
@@ -122,7 +122,7 @@ static char module_name[] = "lart";
122 122
123/* 123/*
124 * The data line mapping on LART is as follows: 124 * The data line mapping on LART is as follows:
125 * 125 *
126 * U2 CPU | U3 CPU 126 * U2 CPU | U3 CPU
127 * ------------------- 127 * -------------------
128 * 0 20 | 0 12 128 * 0 20 | 0 12
@@ -181,7 +181,7 @@ static char module_name[] = "lart";
181 (((x) & 0x00004000) >> 13) \ 181 (((x) & 0x00004000) >> 13) \
182 ) 182 )
183 183
184/* 184/*
185 * The address line mapping on LART is as follows: 185 * The address line mapping on LART is as follows:
186 * 186 *
187 * U3 CPU | U2 CPU 187 * U3 CPU | U2 CPU
@@ -204,7 +204,7 @@ static char module_name[] = "lart";
204 * 12 15 | 12 15 204 * 12 15 | 12 15
205 * 13 14 | 13 14 205 * 13 14 | 13 14
206 * 14 16 | 14 16 206 * 14 16 | 14 16
207 * 207 *
208 * MAIN BLOCK BOUNDARY 208 * MAIN BLOCK BOUNDARY
209 * 209 *
210 * 15 17 | 15 18 210 * 15 17 | 15 18
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 765c0179c8df..e8685ee6c1e4 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -1,5 +1,5 @@
1/** 1/**
2 * $Id: phram.c,v 1.14 2005/03/07 21:43:38 joern Exp $ 2 * $Id: phram.c,v 1.16 2005/11/07 11:14:25 gleixner Exp $
3 * 3 *
4 * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de> 4 * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de>
5 * Copyright (c) 2003-2004 Jörn Engel <joern@wh.fh-wedel.de> 5 * Copyright (c) 2003-2004 Jörn Engel <joern@wh.fh-wedel.de>
@@ -41,10 +41,10 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
41 41
42 if (instr->addr + instr->len > mtd->size) 42 if (instr->addr + instr->len > mtd->size)
43 return -EINVAL; 43 return -EINVAL;
44 44
45 memset(start + instr->addr, 0xff, instr->len); 45 memset(start + instr->addr, 0xff, instr->len);
46 46
47 /* This'll catch a few races. Free the thing before returning :) 47 /* This'll catch a few races. Free the thing before returning :)
48 * I don't feel at all ashamed. This kind of thing is possible anyway 48 * I don't feel at all ashamed. This kind of thing is possible anyway
49 * with flash, but unlikely. 49 * with flash, but unlikely.
50 */ 50 */
@@ -63,7 +63,7 @@ static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
63 63
64 if (from + len > mtd->size) 64 if (from + len > mtd->size)
65 return -EINVAL; 65 return -EINVAL;
66 66
67 *mtdbuf = start + from; 67 *mtdbuf = start + from;
68 *retlen = len; 68 *retlen = len;
69 return 0; 69 return 0;
@@ -84,7 +84,7 @@ static int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
84 84
85 if (len > mtd->size - from) 85 if (len > mtd->size - from)
86 len = mtd->size - from; 86 len = mtd->size - from;
87 87
88 memcpy(buf, start + from, len); 88 memcpy(buf, start + from, len);
89 89
90 *retlen = len; 90 *retlen = len;
@@ -101,7 +101,7 @@ static int phram_write(struct mtd_info *mtd, loff_t to, size_t len,
101 101
102 if (len > mtd->size - to) 102 if (len > mtd->size - to)
103 len = mtd->size - to; 103 len = mtd->size - to;
104 104
105 memcpy(start + to, buf, len); 105 memcpy(start + to, buf, len);
106 106
107 *retlen = len; 107 *retlen = len;
@@ -159,7 +159,7 @@ static int register_device(char *name, unsigned long start, unsigned long len)
159 } 159 }
160 160
161 list_add_tail(&new->list, &phram_list); 161 list_add_tail(&new->list, &phram_list);
162 return 0; 162 return 0;
163 163
164out2: 164out2:
165 iounmap(new->mtd.priv); 165 iounmap(new->mtd.priv);
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index 5b3defadf884..de48b35f5609 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: pmc551.c,v 1.30 2005/01/05 18:05:13 dwmw2 Exp $ 2 * $Id: pmc551.c,v 1.32 2005/11/07 11:14:25 gleixner Exp $
3 * 3 *
4 * PMC551 PCI Mezzanine Ram Device 4 * PMC551 PCI Mezzanine Ram Device
5 * 5 *
@@ -27,7 +27,7 @@
27 * it as high speed swap or for a high speed disk device of some 27 * it as high speed swap or for a high speed disk device of some
28 * sort. Which becomes very useful on diskless systems in the 28 * sort. Which becomes very useful on diskless systems in the
29 * embedded market I might add. 29 * embedded market I might add.
30 * 30 *
31 * Notes: 31 * Notes:
32 * Due to what I assume is more buggy SROM, the 64M PMC551 I 32 * Due to what I assume is more buggy SROM, the 64M PMC551 I
33 * have available claims that all 4 of it's DRAM banks have 64M 33 * have available claims that all 4 of it's DRAM banks have 64M
@@ -63,10 +63,10 @@
63 * Minyard set up the card to utilize a 1M sliding apature. 63 * Minyard set up the card to utilize a 1M sliding apature.
64 * 64 *
65 * Corey Minyard <minyard@nortelnetworks.com> 65 * Corey Minyard <minyard@nortelnetworks.com>
66 * * Modified driver to utilize a sliding aperture instead of 66 * * Modified driver to utilize a sliding aperture instead of
67 * mapping all memory into kernel space which turned out to 67 * mapping all memory into kernel space which turned out to
68 * be very wasteful. 68 * be very wasteful.
69 * * Located a bug in the SROM's initialization sequence that 69 * * Located a bug in the SROM's initialization sequence that
70 * made the memory unusable, added a fix to code to touch up 70 * made the memory unusable, added a fix to code to touch up
71 * the DRAM some. 71 * the DRAM some.
72 * 72 *
@@ -390,7 +390,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
390 bcmd |= (0x40|0x20); 390 bcmd |= (0x40|0x20);
391 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); 391 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
392 392
393 /* 393 /*
394 * Take care and turn off the memory on the device while we 394 * Take care and turn off the memory on the device while we
395 * tweak the configurations 395 * tweak the configurations
396 */ 396 */
@@ -408,7 +408,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
408 * Grab old BAR0 config so that we can figure out memory size 408 * Grab old BAR0 config so that we can figure out memory size
409 * This is another bit of kludge going on. The reason for the 409 * This is another bit of kludge going on. The reason for the
410 * redundancy is I am hoping to retain the original configuration 410 * redundancy is I am hoping to retain the original configuration
411 * previously assigned to the card by the BIOS or some previous 411 * previously assigned to the card by the BIOS or some previous
412 * fixup routine in the kernel. So we read the old config into cfg, 412 * fixup routine in the kernel. So we read the old config into cfg,
413 * then write all 1's to the memory space, read back the result into 413 * then write all 1's to the memory space, read back the result into
414 * "size", and then write back all the old config. 414 * "size", and then write back all the old config.
@@ -480,7 +480,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
480 } while ( (PCI_COMMAND_IO) & cmd ); 480 } while ( (PCI_COMMAND_IO) & cmd );
481 481
482 /* 482 /*
483 * Turn on auto refresh 483 * Turn on auto refresh
484 * The loop is taken directly from Ramix's example code. I assume that 484 * The loop is taken directly from Ramix's example code. I assume that
485 * this must be held high for some duration of time, but I can find no 485 * this must be held high for some duration of time, but I can find no
486 * documentation refrencing the reasons why. 486 * documentation refrencing the reasons why.
@@ -615,7 +615,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
615 pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd ); 615 pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd );
616 printk( KERN_DEBUG "pmc551: EEPROM is under %s control\n" 616 printk( KERN_DEBUG "pmc551: EEPROM is under %s control\n"
617 "pmc551: System Control Register is %slocked to PCI access\n" 617 "pmc551: System Control Register is %slocked to PCI access\n"
618 "pmc551: System Control Register is %slocked to EEPROM access\n", 618 "pmc551: System Control Register is %slocked to EEPROM access\n",
619 (bcmd&0x1)?"software":"hardware", 619 (bcmd&0x1)?"software":"hardware",
620 (bcmd&0x20)?"":"un", (bcmd&0x40)?"":"un"); 620 (bcmd&0x20)?"":"un", (bcmd&0x40)?"":"un");
621#endif 621#endif
@@ -744,7 +744,7 @@ static int __init init_pmc551(void)
744 priv->start = ioremap(((PCI_Device->resource[0].start) 744 priv->start = ioremap(((PCI_Device->resource[0].start)
745 & PCI_BASE_ADDRESS_MEM_MASK), 745 & PCI_BASE_ADDRESS_MEM_MASK),
746 priv->asize); 746 priv->asize);
747 747
748 if (!priv->start) { 748 if (!priv->start) {
749 printk(KERN_NOTICE "pmc551: Unable to map IO space\n"); 749 printk(KERN_NOTICE "pmc551: Unable to map IO space\n");
750 kfree(mtd->priv); 750 kfree(mtd->priv);
@@ -765,7 +765,7 @@ static int __init init_pmc551(void)
765 priv->curr_map0 ); 765 priv->curr_map0 );
766 766
767#ifdef CONFIG_MTD_PMC551_DEBUG 767#ifdef CONFIG_MTD_PMC551_DEBUG
768 printk( KERN_DEBUG "pmc551: aperture set to %d\n", 768 printk( KERN_DEBUG "pmc551: aperture set to %d\n",
769 (priv->base_map0 & 0xF0)>>4 ); 769 (priv->base_map0 & 0xF0)>>4 );
770#endif 770#endif
771 771
@@ -823,13 +823,13 @@ static void __exit cleanup_pmc551(void)
823 while((mtd=pmc551list)) { 823 while((mtd=pmc551list)) {
824 priv = mtd->priv; 824 priv = mtd->priv;
825 pmc551list = priv->nextpmc551; 825 pmc551list = priv->nextpmc551;
826 826
827 if(priv->start) { 827 if(priv->start) {
828 printk (KERN_DEBUG "pmc551: unmapping %dM starting at 0x%p\n", 828 printk (KERN_DEBUG "pmc551: unmapping %dM starting at 0x%p\n",
829 priv->asize>>20, priv->start); 829 priv->asize>>20, priv->start);
830 iounmap (priv->start); 830 iounmap (priv->start);
831 } 831 }
832 832
833 kfree (mtd->priv); 833 kfree (mtd->priv);
834 del_mtd_device (mtd); 834 del_mtd_device (mtd);
835 kfree (mtd); 835 kfree (mtd);
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 84fa91392a8c..6faee6c6958c 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -1,6 +1,6 @@
1/*====================================================================== 1/*======================================================================
2 2
3 $Id: slram.c,v 1.34 2005/01/06 21:16:42 jwboyer Exp $ 3 $Id: slram.c,v 1.36 2005/11/07 11:14:25 gleixner Exp $
4 4
5 This driver provides a method to access memory not used by the kernel 5 This driver provides a method to access memory not used by the kernel
6 itself (i.e. if the kernel commandline mem=xxx is used). To actually 6 itself (i.e. if the kernel commandline mem=xxx is used). To actually
@@ -18,14 +18,14 @@
18 <start>: start of the memory region, decimal or hex (0xabcdef) 18 <start>: start of the memory region, decimal or hex (0xabcdef)
19 <end/offset>: end of the memory region. It's possible to use +0x1234 19 <end/offset>: end of the memory region. It's possible to use +0x1234
20 to specify the offset instead of the absolute address 20 to specify the offset instead of the absolute address
21 21
22 NOTE: 22 NOTE:
23 With slram it's only possible to map a contigous memory region. Therfore 23 With slram it's only possible to map a contigous memory region. Therfore
24 if there's a device mapped somewhere in the region specified slram will 24 if there's a device mapped somewhere in the region specified slram will
25 fail to load (see kernel log if modprobe fails). 25 fail to load (see kernel log if modprobe fails).
26 26
27 - 27 -
28 28
29 Jochen Schaeuble <psionic@psionic.de> 29 Jochen Schaeuble <psionic@psionic.de>
30 30
31======================================================================*/ 31======================================================================*/
@@ -89,10 +89,10 @@ static int slram_erase(struct mtd_info *mtd, struct erase_info *instr)
89 if (instr->addr + instr->len > mtd->size) { 89 if (instr->addr + instr->len > mtd->size) {
90 return(-EINVAL); 90 return(-EINVAL);
91 } 91 }
92 92
93 memset(priv->start + instr->addr, 0xff, instr->len); 93 memset(priv->start + instr->addr, 0xff, instr->len);
94 94
95 /* This'll catch a few races. Free the thing before returning :) 95 /* This'll catch a few races. Free the thing before returning :)
96 * I don't feel at all ashamed. This kind of thing is possible anyway 96 * I don't feel at all ashamed. This kind of thing is possible anyway
97 * with flash, but unlikely. 97 * with flash, but unlikely.
98 */ 98 */
@@ -170,12 +170,12 @@ static int register_device(char *name, unsigned long start, unsigned long length
170 } 170 }
171 (*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); 171 (*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
172 (*curmtd)->next = NULL; 172 (*curmtd)->next = NULL;
173 173
174 if ((*curmtd)->mtdinfo) { 174 if ((*curmtd)->mtdinfo) {
175 memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info)); 175 memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info));
176 (*curmtd)->mtdinfo->priv = 176 (*curmtd)->mtdinfo->priv =
177 kmalloc(sizeof(slram_priv_t), GFP_KERNEL); 177 kmalloc(sizeof(slram_priv_t), GFP_KERNEL);
178 178
179 if (!(*curmtd)->mtdinfo->priv) { 179 if (!(*curmtd)->mtdinfo->priv) {
180 kfree((*curmtd)->mtdinfo); 180 kfree((*curmtd)->mtdinfo);
181 (*curmtd)->mtdinfo = NULL; 181 (*curmtd)->mtdinfo = NULL;
@@ -188,7 +188,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
188 E("slram: Cannot allocate new MTD device.\n"); 188 E("slram: Cannot allocate new MTD device.\n");
189 return(-ENOMEM); 189 return(-ENOMEM);
190 } 190 }
191 191
192 if (!(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start = 192 if (!(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start =
193 ioremap(start, length))) { 193 ioremap(start, length))) {
194 E("slram: ioremap failed\n"); 194 E("slram: ioremap failed\n");
@@ -223,7 +223,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
223 T("slram: Mapped from 0x%p to 0x%p\n", 223 T("slram: Mapped from 0x%p to 0x%p\n",
224 ((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start, 224 ((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start,
225 ((slram_priv_t *)(*curmtd)->mtdinfo->priv)->end); 225 ((slram_priv_t *)(*curmtd)->mtdinfo->priv)->end);
226 return(0); 226 return(0);
227} 227}
228 228
229static void unregister_devices(void) 229static void unregister_devices(void)
@@ -256,7 +256,7 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength)
256 char *buffer; 256 char *buffer;
257 unsigned long devstart; 257 unsigned long devstart;
258 unsigned long devlength; 258 unsigned long devlength;
259 259
260 if ((!devname) || (!szstart) || (!szlength)) { 260 if ((!devname) || (!szstart) || (!szlength)) {
261 unregister_devices(); 261 unregister_devices();
262 return(-EINVAL); 262 return(-EINVAL);
@@ -264,7 +264,7 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength)
264 264
265 devstart = simple_strtoul(szstart, &buffer, 0); 265 devstart = simple_strtoul(szstart, &buffer, 0);
266 devstart = handle_unit(devstart, buffer); 266 devstart = handle_unit(devstart, buffer);
267 267
268 if (*(szlength) != '+') { 268 if (*(szlength) != '+') {
269 devlength = simple_strtoul(szlength, &buffer, 0); 269 devlength = simple_strtoul(szlength, &buffer, 0);
270 devlength = handle_unit(devlength, buffer) - devstart; 270 devlength = handle_unit(devlength, buffer) - devstart;
@@ -278,7 +278,7 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength)
278 E("slram: Illegal start / length parameter.\n"); 278 E("slram: Illegal start / length parameter.\n");
279 return(-EINVAL); 279 return(-EINVAL);
280 } 280 }
281 281
282 if ((devstart = register_device(devname, devstart, devlength))){ 282 if ((devstart = register_device(devname, devstart, devlength))){
283 unregister_devices(); 283 unregister_devices();
284 return((int)devstart); 284 return((int)devstart);
@@ -335,7 +335,7 @@ static int init_slram(void)
335 } 335 }
336#else 336#else
337 int count; 337 int count;
338 338
339 for (count = 0; (map[count]) && (count < SLRAM_MAX_DEVICES_PARAMS); 339 for (count = 0; (map[count]) && (count < SLRAM_MAX_DEVICES_PARAMS);
340 count++) { 340 count++) {
341 } 341 }
@@ -350,10 +350,10 @@ static int init_slram(void)
350 if (parse_cmdline(devname, map[i * 3 + 1], map[i * 3 + 2])!=0) { 350 if (parse_cmdline(devname, map[i * 3 + 1], map[i * 3 + 2])!=0) {
351 return(-EINVAL); 351 return(-EINVAL);
352 } 352 }
353 353
354 } 354 }
355#endif /* !MODULE */ 355#endif /* !MODULE */
356 356
357 return(0); 357 return(0);
358} 358}
359 359
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index d32c1b3a8ce3..de7e231d6d18 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.55 2005/01/17 13:47:21 hvr Exp $ 2 * $Id: ftl.c,v 1.58 2005/11/07 11:14:19 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
@@ -53,7 +53,7 @@
53 Use of the FTL format for non-PCMCIA applications may be an 53 Use of the FTL format for non-PCMCIA applications may be an
54 infringement of these patents. For additional information, 54 infringement of these patents. For additional information,
55 contact M-Systems (http://www.m-sys.com) directly. 55 contact M-Systems (http://www.m-sys.com) directly.
56 56
57======================================================================*/ 57======================================================================*/
58#include <linux/mtd/blktrans.h> 58#include <linux/mtd/blktrans.h>
59#include <linux/module.h> 59#include <linux/module.h>
@@ -160,7 +160,7 @@ static void ftl_erase_callback(struct erase_info *done);
160 Scan_header() checks to see if a memory region contains an FTL 160 Scan_header() checks to see if a memory region contains an FTL
161 partition. build_maps() reads all the erase unit headers, builds 161 partition. build_maps() reads all the erase unit headers, builds
162 the erase unit map, and then builds the virtual page map. 162 the erase unit map, and then builds the virtual page map.
163 163
164======================================================================*/ 164======================================================================*/
165 165
166static int scan_header(partition_t *part) 166static int scan_header(partition_t *part)
@@ -176,10 +176,10 @@ static int scan_header(partition_t *part)
176 (offset + sizeof(header)) < max_offset; 176 (offset + sizeof(header)) < max_offset;
177 offset += part->mbd.mtd->erasesize ? : 0x2000) { 177 offset += part->mbd.mtd->erasesize ? : 0x2000) {
178 178
179 err = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &ret, 179 err = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &ret,
180 (unsigned char *)&header); 180 (unsigned char *)&header);
181 181
182 if (err) 182 if (err)
183 return err; 183 return err;
184 184
185 if (strcmp(header.DataOrgTuple+3, "FTL100") == 0) break; 185 if (strcmp(header.DataOrgTuple+3, "FTL100") == 0) break;
@@ -232,10 +232,10 @@ static int build_maps(partition_t *part)
232 for (i = 0; i < le16_to_cpu(part->header.NumEraseUnits); i++) { 232 for (i = 0; i < le16_to_cpu(part->header.NumEraseUnits); i++) {
233 offset = ((i + le16_to_cpu(part->header.FirstPhysicalEUN)) 233 offset = ((i + le16_to_cpu(part->header.FirstPhysicalEUN))
234 << part->header.EraseUnitSize); 234 << part->header.EraseUnitSize);
235 ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &retval, 235 ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &retval,
236 (unsigned char *)&header); 236 (unsigned char *)&header);
237 237
238 if (ret) 238 if (ret)
239 goto out_XferInfo; 239 goto out_XferInfo;
240 240
241 ret = -1; 241 ret = -1;
@@ -274,7 +274,7 @@ static int build_maps(partition_t *part)
274 "don't add up!\n"); 274 "don't add up!\n");
275 goto out_XferInfo; 275 goto out_XferInfo;
276 } 276 }
277 277
278 /* Set up virtual page map */ 278 /* Set up virtual page map */
279 blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize; 279 blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize;
280 part->VirtualBlockMap = vmalloc(blocks * sizeof(u_int32_t)); 280 part->VirtualBlockMap = vmalloc(blocks * sizeof(u_int32_t));
@@ -296,12 +296,12 @@ static int build_maps(partition_t *part)
296 part->EUNInfo[i].Free = 0; 296 part->EUNInfo[i].Free = 0;
297 part->EUNInfo[i].Deleted = 0; 297 part->EUNInfo[i].Deleted = 0;
298 offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset); 298 offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset);
299 299
300 ret = part->mbd.mtd->read(part->mbd.mtd, offset, 300 ret = part->mbd.mtd->read(part->mbd.mtd, offset,
301 part->BlocksPerUnit * sizeof(u_int32_t), &retval, 301 part->BlocksPerUnit * sizeof(u_int32_t), &retval,
302 (unsigned char *)part->bam_cache); 302 (unsigned char *)part->bam_cache);
303 303
304 if (ret) 304 if (ret)
305 goto out_bam_cache; 305 goto out_bam_cache;
306 306
307 for (j = 0; j < part->BlocksPerUnit; j++) { 307 for (j = 0; j < part->BlocksPerUnit; j++) {
@@ -316,7 +316,7 @@ static int build_maps(partition_t *part)
316 part->EUNInfo[i].Deleted++; 316 part->EUNInfo[i].Deleted++;
317 } 317 }
318 } 318 }
319 319
320 ret = 0; 320 ret = 0;
321 goto out; 321 goto out;
322 322
@@ -336,7 +336,7 @@ out:
336 336
337 Erase_xfer() schedules an asynchronous erase operation for a 337 Erase_xfer() schedules an asynchronous erase operation for a
338 transfer unit. 338 transfer unit.
339 339
340======================================================================*/ 340======================================================================*/
341 341
342static int erase_xfer(partition_t *part, 342static int erase_xfer(partition_t *part,
@@ -351,10 +351,10 @@ static int erase_xfer(partition_t *part,
351 xfer->state = XFER_ERASING; 351 xfer->state = XFER_ERASING;
352 352
353 /* Is there a free erase slot? Always in MTD. */ 353 /* Is there a free erase slot? Always in MTD. */
354 354
355 355
356 erase=kmalloc(sizeof(struct erase_info), GFP_KERNEL); 356 erase=kmalloc(sizeof(struct erase_info), GFP_KERNEL);
357 if (!erase) 357 if (!erase)
358 return -ENOMEM; 358 return -ENOMEM;
359 359
360 erase->mtd = part->mbd.mtd; 360 erase->mtd = part->mbd.mtd;
@@ -362,7 +362,7 @@ static int erase_xfer(partition_t *part,
362 erase->addr = xfer->Offset; 362 erase->addr = xfer->Offset;
363 erase->len = 1 << part->header.EraseUnitSize; 363 erase->len = 1 << part->header.EraseUnitSize;
364 erase->priv = (u_long)part; 364 erase->priv = (u_long)part;
365 365
366 ret = part->mbd.mtd->erase(part->mbd.mtd, erase); 366 ret = part->mbd.mtd->erase(part->mbd.mtd, erase);
367 367
368 if (!ret) 368 if (!ret)
@@ -377,7 +377,7 @@ static int erase_xfer(partition_t *part,
377 377
378 Prepare_xfer() takes a freshly erased transfer unit and gives 378 Prepare_xfer() takes a freshly erased transfer unit and gives
379 it an appropriate header. 379 it an appropriate header.
380 380
381======================================================================*/ 381======================================================================*/
382 382
383static void ftl_erase_callback(struct erase_info *erase) 383static void ftl_erase_callback(struct erase_info *erase)
@@ -385,7 +385,7 @@ static void ftl_erase_callback(struct erase_info *erase)
385 partition_t *part; 385 partition_t *part;
386 struct xfer_info_t *xfer; 386 struct xfer_info_t *xfer;
387 int i; 387 int i;
388 388
389 /* Look up the transfer unit */ 389 /* Look up the transfer unit */
390 part = (partition_t *)(erase->priv); 390 part = (partition_t *)(erase->priv);
391 391
@@ -422,7 +422,7 @@ static int prepare_xfer(partition_t *part, int i)
422 422
423 xfer = &part->XferInfo[i]; 423 xfer = &part->XferInfo[i];
424 xfer->state = XFER_FAILED; 424 xfer->state = XFER_FAILED;
425 425
426 DEBUG(1, "ftl_cs: preparing xfer unit at 0x%x\n", xfer->Offset); 426 DEBUG(1, "ftl_cs: preparing xfer unit at 0x%x\n", xfer->Offset);
427 427
428 /* Write the transfer unit header */ 428 /* Write the transfer unit header */
@@ -446,7 +446,7 @@ static int prepare_xfer(partition_t *part, int i)
446 446
447 for (i = 0; i < nbam; i++, offset += sizeof(u_int32_t)) { 447 for (i = 0; i < nbam; i++, offset += sizeof(u_int32_t)) {
448 448
449 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int32_t), 449 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int32_t),
450 &retlen, (u_char *)&ctl); 450 &retlen, (u_char *)&ctl);
451 451
452 if (ret) 452 if (ret)
@@ -454,7 +454,7 @@ static int prepare_xfer(partition_t *part, int i)
454 } 454 }
455 xfer->state = XFER_PREPARED; 455 xfer->state = XFER_PREPARED;
456 return 0; 456 return 0;
457 457
458} /* prepare_xfer */ 458} /* prepare_xfer */
459 459
460/*====================================================================== 460/*======================================================================
@@ -466,7 +466,7 @@ static int prepare_xfer(partition_t *part, int i)
466 All data blocks are copied to the corresponding blocks in the 466 All data blocks are copied to the corresponding blocks in the
467 target unit, so the virtual block map does not need to be 467 target unit, so the virtual block map does not need to be
468 updated. 468 updated.
469 469
470======================================================================*/ 470======================================================================*/
471 471
472static int copy_erase_unit(partition_t *part, u_int16_t srcunit, 472static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
@@ -486,14 +486,14 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
486 xfer = &part->XferInfo[xferunit]; 486 xfer = &part->XferInfo[xferunit];
487 DEBUG(2, "ftl_cs: copying block 0x%x to 0x%x\n", 487 DEBUG(2, "ftl_cs: copying block 0x%x to 0x%x\n",
488 eun->Offset, xfer->Offset); 488 eun->Offset, xfer->Offset);
489 489
490 490
491 /* Read current BAM */ 491 /* Read current BAM */
492 if (part->bam_index != srcunit) { 492 if (part->bam_index != srcunit) {
493 493
494 offset = eun->Offset + le32_to_cpu(part->header.BAMOffset); 494 offset = eun->Offset + le32_to_cpu(part->header.BAMOffset);
495 495
496 ret = part->mbd.mtd->read(part->mbd.mtd, offset, 496 ret = part->mbd.mtd->read(part->mbd.mtd, offset,
497 part->BlocksPerUnit * sizeof(u_int32_t), 497 part->BlocksPerUnit * sizeof(u_int32_t),
498 &retlen, (u_char *) (part->bam_cache)); 498 &retlen, (u_char *) (part->bam_cache));
499 499
@@ -501,11 +501,11 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
501 part->bam_index = 0xffff; 501 part->bam_index = 0xffff;
502 502
503 if (ret) { 503 if (ret) {
504 printk( KERN_WARNING "ftl: Failed to read BAM cache in copy_erase_unit()!\n"); 504 printk( KERN_WARNING "ftl: Failed to read BAM cache in copy_erase_unit()!\n");
505 return ret; 505 return ret;
506 } 506 }
507 } 507 }
508 508
509 /* Write the LogicalEUN for the transfer unit */ 509 /* Write the LogicalEUN for the transfer unit */
510 xfer->state = XFER_UNKNOWN; 510 xfer->state = XFER_UNKNOWN;
511 offset = xfer->Offset + 20; /* Bad! */ 511 offset = xfer->Offset + 20; /* Bad! */
@@ -513,12 +513,12 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
513 513
514 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int16_t), 514 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int16_t),
515 &retlen, (u_char *) &unit); 515 &retlen, (u_char *) &unit);
516 516
517 if (ret) { 517 if (ret) {
518 printk( KERN_WARNING "ftl: Failed to write back to BAM cache in copy_erase_unit()!\n"); 518 printk( KERN_WARNING "ftl: Failed to write back to BAM cache in copy_erase_unit()!\n");
519 return ret; 519 return ret;
520 } 520 }
521 521
522 /* Copy all data blocks from source unit to transfer unit */ 522 /* Copy all data blocks from source unit to transfer unit */
523 src = eun->Offset; dest = xfer->Offset; 523 src = eun->Offset; dest = xfer->Offset;
524 524
@@ -558,15 +558,15 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
558 } 558 }
559 559
560 /* Write the BAM to the transfer unit */ 560 /* Write the BAM to the transfer unit */
561 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + le32_to_cpu(part->header.BAMOffset), 561 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + le32_to_cpu(part->header.BAMOffset),
562 part->BlocksPerUnit * sizeof(int32_t), &retlen, 562 part->BlocksPerUnit * sizeof(int32_t), &retlen,
563 (u_char *)part->bam_cache); 563 (u_char *)part->bam_cache);
564 if (ret) { 564 if (ret) {
565 printk( KERN_WARNING "ftl: Error writing BAM in copy_erase_unit\n"); 565 printk( KERN_WARNING "ftl: Error writing BAM in copy_erase_unit\n");
566 return ret; 566 return ret;
567 } 567 }
568 568
569 569
570 /* All clear? Then update the LogicalEUN again */ 570 /* All clear? Then update the LogicalEUN again */
571 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(u_int16_t), 571 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(u_int16_t),
572 &retlen, (u_char *)&srcunitswap); 572 &retlen, (u_char *)&srcunitswap);
@@ -574,9 +574,9 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
574 if (ret) { 574 if (ret) {
575 printk(KERN_WARNING "ftl: Error writing new LogicalEUN in copy_erase_unit\n"); 575 printk(KERN_WARNING "ftl: Error writing new LogicalEUN in copy_erase_unit\n");
576 return ret; 576 return ret;
577 } 577 }
578 578
579 579
580 /* Update the maps and usage stats*/ 580 /* Update the maps and usage stats*/
581 i = xfer->EraseCount; 581 i = xfer->EraseCount;
582 xfer->EraseCount = eun->EraseCount; 582 xfer->EraseCount = eun->EraseCount;
@@ -588,10 +588,10 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
588 part->FreeTotal += free; 588 part->FreeTotal += free;
589 eun->Free = free; 589 eun->Free = free;
590 eun->Deleted = 0; 590 eun->Deleted = 0;
591 591
592 /* Now, the cache should be valid for the new block */ 592 /* Now, the cache should be valid for the new block */
593 part->bam_index = srcunit; 593 part->bam_index = srcunit;
594 594
595 return 0; 595 return 0;
596} /* copy_erase_unit */ 596} /* copy_erase_unit */
597 597
@@ -608,7 +608,7 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
608 oldest data unit instead. This means that we generally postpone 608 oldest data unit instead. This means that we generally postpone
609 the next reclaimation as long as possible, but shuffle static 609 the next reclaimation as long as possible, but shuffle static
610 stuff around a bit for wear leveling. 610 stuff around a bit for wear leveling.
611 611
612======================================================================*/ 612======================================================================*/
613 613
614static int reclaim_block(partition_t *part) 614static int reclaim_block(partition_t *part)
@@ -666,7 +666,7 @@ static int reclaim_block(partition_t *part)
666 else 666 else
667 DEBUG(1, "ftl_cs: reclaim failed: no " 667 DEBUG(1, "ftl_cs: reclaim failed: no "
668 "suitable transfer units!\n"); 668 "suitable transfer units!\n");
669 669
670 return -EIO; 670 return -EIO;
671 } 671 }
672 } 672 }
@@ -715,7 +715,7 @@ static int reclaim_block(partition_t *part)
715 returns the block index -- the erase unit is just the currently 715 returns the block index -- the erase unit is just the currently
716 cached unit. If there are no free blocks, it returns 0 -- this 716 cached unit. If there are no free blocks, it returns 0 -- this
717 is never a valid data block because it contains the header. 717 is never a valid data block because it contains the header.
718 718
719======================================================================*/ 719======================================================================*/
720 720
721#ifdef PSYCHO_DEBUG 721#ifdef PSYCHO_DEBUG
@@ -737,7 +737,7 @@ static u_int32_t find_free(partition_t *part)
737 u_int32_t blk; 737 u_int32_t blk;
738 size_t retlen; 738 size_t retlen;
739 int ret; 739 int ret;
740 740
741 /* Find an erase unit with some free space */ 741 /* Find an erase unit with some free space */
742 stop = (part->bam_index == 0xffff) ? 0 : part->bam_index; 742 stop = (part->bam_index == 0xffff) ? 0 : part->bam_index;
743 eun = stop; 743 eun = stop;
@@ -749,17 +749,17 @@ static u_int32_t find_free(partition_t *part)
749 749
750 if (part->EUNInfo[eun].Free == 0) 750 if (part->EUNInfo[eun].Free == 0)
751 return 0; 751 return 0;
752 752
753 /* Is this unit's BAM cached? */ 753 /* Is this unit's BAM cached? */
754 if (eun != part->bam_index) { 754 if (eun != part->bam_index) {
755 /* Invalidate cache */ 755 /* Invalidate cache */
756 part->bam_index = 0xffff; 756 part->bam_index = 0xffff;
757 757
758 ret = part->mbd.mtd->read(part->mbd.mtd, 758 ret = part->mbd.mtd->read(part->mbd.mtd,
759 part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset), 759 part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset),
760 part->BlocksPerUnit * sizeof(u_int32_t), 760 part->BlocksPerUnit * sizeof(u_int32_t),
761 &retlen, (u_char *) (part->bam_cache)); 761 &retlen, (u_char *) (part->bam_cache));
762 762
763 if (ret) { 763 if (ret) {
764 printk(KERN_WARNING"ftl: Error reading BAM in find_free\n"); 764 printk(KERN_WARNING"ftl: Error reading BAM in find_free\n");
765 return 0; 765 return 0;
@@ -781,14 +781,14 @@ static u_int32_t find_free(partition_t *part)
781 } 781 }
782 DEBUG(2, "ftl_cs: found free block at %d in %d\n", blk, eun); 782 DEBUG(2, "ftl_cs: found free block at %d in %d\n", blk, eun);
783 return blk; 783 return blk;
784 784
785} /* find_free */ 785} /* find_free */
786 786
787 787
788/*====================================================================== 788/*======================================================================
789 789
790 Read a series of sectors from an FTL partition. 790 Read a series of sectors from an FTL partition.
791 791
792======================================================================*/ 792======================================================================*/
793 793
794static int ftl_read(partition_t *part, caddr_t buffer, 794static int ftl_read(partition_t *part, caddr_t buffer,
@@ -798,7 +798,7 @@ static int ftl_read(partition_t *part, caddr_t buffer,
798 u_long i; 798 u_long i;
799 int ret; 799 int ret;
800 size_t offset, retlen; 800 size_t offset, retlen;
801 801
802 DEBUG(2, "ftl_cs: ftl_read(0x%p, 0x%lx, %ld)\n", 802 DEBUG(2, "ftl_cs: ftl_read(0x%p, 0x%lx, %ld)\n",
803 part, sector, nblocks); 803 part, sector, nblocks);
804 if (!(part->state & FTL_FORMATTED)) { 804 if (!(part->state & FTL_FORMATTED)) {
@@ -834,7 +834,7 @@ static int ftl_read(partition_t *part, caddr_t buffer,
834/*====================================================================== 834/*======================================================================
835 835
836 Write a series of sectors to an FTL partition 836 Write a series of sectors to an FTL partition
837 837
838======================================================================*/ 838======================================================================*/
839 839
840static int set_bam_entry(partition_t *part, u_int32_t log_addr, 840static int set_bam_entry(partition_t *part, u_int32_t log_addr,
@@ -855,7 +855,7 @@ static int set_bam_entry(partition_t *part, u_int32_t log_addr,
855 blk = (log_addr % bsize) / SECTOR_SIZE; 855 blk = (log_addr % bsize) / SECTOR_SIZE;
856 offset = (part->EUNInfo[eun].Offset + blk * sizeof(u_int32_t) + 856 offset = (part->EUNInfo[eun].Offset + blk * sizeof(u_int32_t) +
857 le32_to_cpu(part->header.BAMOffset)); 857 le32_to_cpu(part->header.BAMOffset));
858 858
859#ifdef PSYCHO_DEBUG 859#ifdef PSYCHO_DEBUG
860 ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(u_int32_t), 860 ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(u_int32_t),
861 &retlen, (u_char *)&old_addr); 861 &retlen, (u_char *)&old_addr);
@@ -925,7 +925,7 @@ static int ftl_write(partition_t *part, caddr_t buffer,
925 if (ret) 925 if (ret)
926 return ret; 926 return ret;
927 } 927 }
928 928
929 bsize = 1 << part->header.EraseUnitSize; 929 bsize = 1 << part->header.EraseUnitSize;
930 930
931 virt_addr = sector * SECTOR_SIZE | BLOCK_DATA; 931 virt_addr = sector * SECTOR_SIZE | BLOCK_DATA;
@@ -949,12 +949,12 @@ static int ftl_write(partition_t *part, caddr_t buffer,
949 log_addr = part->bam_index * bsize + blk * SECTOR_SIZE; 949 log_addr = part->bam_index * bsize + blk * SECTOR_SIZE;
950 part->EUNInfo[part->bam_index].Free--; 950 part->EUNInfo[part->bam_index].Free--;
951 part->FreeTotal--; 951 part->FreeTotal--;
952 if (set_bam_entry(part, log_addr, 0xfffffffe)) 952 if (set_bam_entry(part, log_addr, 0xfffffffe))
953 return -EIO; 953 return -EIO;
954 part->EUNInfo[part->bam_index].Deleted++; 954 part->EUNInfo[part->bam_index].Deleted++;
955 offset = (part->EUNInfo[part->bam_index].Offset + 955 offset = (part->EUNInfo[part->bam_index].Offset +
956 blk * SECTOR_SIZE); 956 blk * SECTOR_SIZE);
957 ret = part->mbd.mtd->write(part->mbd.mtd, offset, SECTOR_SIZE, &retlen, 957 ret = part->mbd.mtd->write(part->mbd.mtd, offset, SECTOR_SIZE, &retlen,
958 buffer); 958 buffer);
959 959
960 if (ret) { 960 if (ret) {
@@ -964,7 +964,7 @@ static int ftl_write(partition_t *part, caddr_t buffer,
964 offset); 964 offset);
965 return -EIO; 965 return -EIO;
966 } 966 }
967 967
968 /* Only delete the old entry when the new entry is ready */ 968 /* Only delete the old entry when the new entry is ready */
969 old_addr = part->VirtualBlockMap[sector+i]; 969 old_addr = part->VirtualBlockMap[sector+i];
970 if (old_addr != 0xffffffff) { 970 if (old_addr != 0xffffffff) {
@@ -979,7 +979,7 @@ static int ftl_write(partition_t *part, caddr_t buffer,
979 return -EIO; 979 return -EIO;
980 part->VirtualBlockMap[sector+i] = log_addr; 980 part->VirtualBlockMap[sector+i] = log_addr;
981 part->EUNInfo[part->bam_index].Deleted--; 981 part->EUNInfo[part->bam_index].Deleted--;
982 982
983 buffer += SECTOR_SIZE; 983 buffer += SECTOR_SIZE;
984 virt_addr += SECTOR_SIZE; 984 virt_addr += SECTOR_SIZE;
985 } 985 }
@@ -1034,20 +1034,20 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
1034 partition_t *partition; 1034 partition_t *partition;
1035 1035
1036 partition = kmalloc(sizeof(partition_t), GFP_KERNEL); 1036 partition = kmalloc(sizeof(partition_t), GFP_KERNEL);
1037 1037
1038 if (!partition) { 1038 if (!partition) {
1039 printk(KERN_WARNING "No memory to scan for FTL on %s\n", 1039 printk(KERN_WARNING "No memory to scan for FTL on %s\n",
1040 mtd->name); 1040 mtd->name);
1041 return; 1041 return;
1042 } 1042 }
1043 1043
1044 memset(partition, 0, sizeof(partition_t)); 1044 memset(partition, 0, sizeof(partition_t));
1045 1045
1046 partition->mbd.mtd = mtd; 1046 partition->mbd.mtd = mtd;
1047 1047
1048 if ((scan_header(partition) == 0) && 1048 if ((scan_header(partition) == 0) &&
1049 (build_maps(partition) == 0)) { 1049 (build_maps(partition) == 0)) {
1050 1050
1051 partition->state = FTL_FORMATTED; 1051 partition->state = FTL_FORMATTED;
1052#ifdef PCMCIA_DEBUG 1052#ifdef PCMCIA_DEBUG
1053 printk(KERN_INFO "ftl_cs: opening %d KiB FTL partition\n", 1053 printk(KERN_INFO "ftl_cs: opening %d KiB FTL partition\n",
@@ -1086,7 +1086,7 @@ struct mtd_blktrans_ops ftl_tr = {
1086 1086
1087int init_ftl(void) 1087int init_ftl(void)
1088{ 1088{
1089 DEBUG(0, "$Id: ftl.c,v 1.55 2005/01/17 13:47:21 hvr Exp $\n"); 1089 DEBUG(0, "$Id: ftl.c,v 1.58 2005/11/07 11:14:19 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/inftlcore.c b/drivers/mtd/inftlcore.c
index 39eb53f6551f..8a544890173d 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * inftlcore.c -- Linux driver for Inverse Flash Translation Layer (INFTL) 2 * inftlcore.c -- Linux driver for Inverse Flash Translation Layer (INFTL)
3 * 3 *
4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) 4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
@@ -7,7 +7,7 @@
7 * (c) 1999 Machine Vision Holdings, Inc. 7 * (c) 1999 Machine Vision Holdings, Inc.
8 * Author: David Woodhouse <dwmw2@infradead.org> 8 * Author: David Woodhouse <dwmw2@infradead.org>
9 * 9 *
10 * $Id: inftlcore.c,v 1.18 2004/11/16 18:28:59 dwmw2 Exp $ 10 * $Id: inftlcore.c,v 1.19 2005/11/07 11:14:20 gleixner Exp $
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
@@ -113,23 +113,21 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
113 113
114 if (inftl->mbd.size != inftl->heads * inftl->cylinders * inftl->sectors) { 114 if (inftl->mbd.size != inftl->heads * inftl->cylinders * inftl->sectors) {
115 /* 115 /*
116 Oh no we don't have 116 Oh no we don't have
117 mbd.size == heads * cylinders * sectors 117 mbd.size == heads * cylinders * sectors
118 */ 118 */
119 printk(KERN_WARNING "INFTL: cannot calculate a geometry to " 119 printk(KERN_WARNING "INFTL: cannot calculate a geometry to "
120 "match size of 0x%lx.\n", inftl->mbd.size); 120 "match size of 0x%lx.\n", inftl->mbd.size);
121 printk(KERN_WARNING "INFTL: using C:%d H:%d S:%d " 121 printk(KERN_WARNING "INFTL: using C:%d H:%d S:%d "
122 "(== 0x%lx sects)\n", 122 "(== 0x%lx sects)\n",
123 inftl->cylinders, inftl->heads , inftl->sectors, 123 inftl->cylinders, inftl->heads , inftl->sectors,
124 (long)inftl->cylinders * (long)inftl->heads * 124 (long)inftl->cylinders * (long)inftl->heads *
125 (long)inftl->sectors ); 125 (long)inftl->sectors );
126 } 126 }
127 127
128 if (add_mtd_blktrans_dev(&inftl->mbd)) { 128 if (add_mtd_blktrans_dev(&inftl->mbd)) {
129 if (inftl->PUtable) 129 kfree(inftl->PUtable);
130 kfree(inftl->PUtable); 130 kfree(inftl->VUtable);
131 if (inftl->VUtable)
132 kfree(inftl->VUtable);
133 kfree(inftl); 131 kfree(inftl);
134 return; 132 return;
135 } 133 }
@@ -147,10 +145,8 @@ static void inftl_remove_dev(struct mtd_blktrans_dev *dev)
147 145
148 del_mtd_blktrans_dev(dev); 146 del_mtd_blktrans_dev(dev);
149 147
150 if (inftl->PUtable) 148 kfree(inftl->PUtable);
151 kfree(inftl->PUtable); 149 kfree(inftl->VUtable);
152 if (inftl->VUtable)
153 kfree(inftl->VUtable);
154 kfree(inftl); 150 kfree(inftl);
155} 151}
156 152
@@ -223,7 +219,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
223 "Virtual Unit Chain %d!\n", thisVUC); 219 "Virtual Unit Chain %d!\n", thisVUC);
224 return BLOCK_NIL; 220 return BLOCK_NIL;
225 } 221 }
226 222
227 /* 223 /*
228 * Scan to find the Erase Unit which holds the actual data for each 224 * Scan to find the Erase Unit which holds the actual data for each
229 * 512-byte block within the Chain. 225 * 512-byte block within the Chain.
@@ -264,7 +260,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
264 "Unit Chain 0x%x\n", thisVUC); 260 "Unit Chain 0x%x\n", thisVUC);
265 return BLOCK_NIL; 261 return BLOCK_NIL;
266 } 262 }
267 263
268 thisEUN = inftl->PUtable[thisEUN]; 264 thisEUN = inftl->PUtable[thisEUN];
269 } 265 }
270 266
@@ -295,15 +291,15 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
295 */ 291 */
296 if (BlockMap[block] == BLOCK_NIL) 292 if (BlockMap[block] == BLOCK_NIL)
297 continue; 293 continue;
298 294
299 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * 295 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize *
300 BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE, 296 BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE,
301 &retlen, movebuf); 297 &retlen, movebuf);
302 if (ret < 0) { 298 if (ret < 0) {
303 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * 299 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize *
304 BlockMap[block]) + (block * SECTORSIZE), 300 BlockMap[block]) + (block * SECTORSIZE),
305 SECTORSIZE, &retlen, movebuf); 301 SECTORSIZE, &retlen, movebuf);
306 if (ret != -EIO) 302 if (ret != -EIO)
307 DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went " 303 DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went "
308 "away on retry?\n"); 304 "away on retry?\n");
309 } 305 }
@@ -355,7 +351,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
355static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock) 351static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock)
356{ 352{
357 /* 353 /*
358 * This is the part that needs some cleverness applied. 354 * This is the part that needs some cleverness applied.
359 * For now, I'm doing the minimum applicable to actually 355 * For now, I'm doing the minimum applicable to actually
360 * get the thing to work. 356 * get the thing to work.
361 * Wear-levelling and other clever stuff needs to be implemented 357 * Wear-levelling and other clever stuff needs to be implemented
@@ -414,7 +410,7 @@ static int nrbits(unsigned int val, int bitcount)
414} 410}
415 411
416/* 412/*
417 * INFTL_findwriteunit: Return the unit number into which we can write 413 * INFTL_findwriteunit: Return the unit number into which we can write
418 * for this block. Make it available if it isn't already. 414 * for this block. Make it available if it isn't already.
419 */ 415 */
420static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) 416static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
@@ -463,10 +459,10 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
463 * Invalid block. Don't use it any more. 459 * Invalid block. Don't use it any more.
464 * Must implement. 460 * Must implement.
465 */ 461 */
466 break; 462 break;
467 } 463 }
468 464
469 if (!silly--) { 465 if (!silly--) {
470 printk(KERN_WARNING "INFTL: infinite loop in " 466 printk(KERN_WARNING "INFTL: infinite loop in "
471 "Virtual Unit Chain 0x%x\n", thisVUC); 467 "Virtual Unit Chain 0x%x\n", thisVUC);
472 return 0xffff; 468 return 0xffff;
@@ -482,7 +478,7 @@ hitused:
482 478
483 479
484 /* 480 /*
485 * OK. We didn't find one in the existing chain, or there 481 * OK. We didn't find one in the existing chain, or there
486 * is no existing chain. Allocate a new one. 482 * is no existing chain. Allocate a new one.
487 */ 483 */
488 writeEUN = INFTL_findfreeblock(inftl, 0); 484 writeEUN = INFTL_findfreeblock(inftl, 0);
@@ -506,8 +502,8 @@ hitused:
506 if (writeEUN == BLOCK_NIL) { 502 if (writeEUN == BLOCK_NIL) {
507 /* 503 /*
508 * Ouch. This should never happen - we should 504 * Ouch. This should never happen - we should
509 * always be able to make some room somehow. 505 * always be able to make some room somehow.
510 * If we get here, we've allocated more storage 506 * If we get here, we've allocated more storage
511 * space than actual media, or our makefreeblock 507 * space than actual media, or our makefreeblock
512 * routine is missing something. 508 * routine is missing something.
513 */ 509 */
@@ -518,7 +514,7 @@ hitused:
518 INFTL_dumpVUchains(inftl); 514 INFTL_dumpVUchains(inftl);
519#endif 515#endif
520 return BLOCK_NIL; 516 return BLOCK_NIL;
521 } 517 }
522 } 518 }
523 519
524 /* 520 /*
@@ -543,7 +539,7 @@ hitused:
543 parity |= (nrbits(prev_block, 16) & 0x1) ? 0x2 : 0; 539 parity |= (nrbits(prev_block, 16) & 0x1) ? 0x2 : 0;
544 parity |= (nrbits(anac, 8) & 0x1) ? 0x4 : 0; 540 parity |= (nrbits(anac, 8) & 0x1) ? 0x4 : 0;
545 parity |= (nrbits(nacs, 8) & 0x1) ? 0x8 : 0; 541 parity |= (nrbits(nacs, 8) & 0x1) ? 0x8 : 0;
546 542
547 oob.u.a.virtualUnitNo = cpu_to_le16(thisVUC); 543 oob.u.a.virtualUnitNo = cpu_to_le16(thisVUC);
548 oob.u.a.prevUnitNo = cpu_to_le16(prev_block); 544 oob.u.a.prevUnitNo = cpu_to_le16(prev_block);
549 oob.u.a.ANAC = anac; 545 oob.u.a.ANAC = anac;
@@ -562,7 +558,7 @@ hitused:
562 oob.u.b.parityPerField = parity; 558 oob.u.b.parityPerField = parity;
563 oob.u.b.discarded = 0xaa; 559 oob.u.b.discarded = 0xaa;
564 560
565 MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize + 561 MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize +
566 SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u); 562 SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u);
567 563
568 inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC]; 564 inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC];
@@ -602,7 +598,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
602 "Virtual Unit Chain %d!\n", thisVUC); 598 "Virtual Unit Chain %d!\n", thisVUC);
603 return; 599 return;
604 } 600 }
605 601
606 /* 602 /*
607 * Scan through the Erase Units to determine whether any data is in 603 * Scan through the Erase Units to determine whether any data is in
608 * each of the 512-byte blocks within the Chain. 604 * each of the 512-byte blocks within the Chain.
@@ -642,7 +638,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
642 "Unit Chain 0x%x\n", thisVUC); 638 "Unit Chain 0x%x\n", thisVUC);
643 return; 639 return;
644 } 640 }
645 641
646 thisEUN = inftl->PUtable[thisEUN]; 642 thisEUN = inftl->PUtable[thisEUN];
647 } 643 }
648 644
@@ -758,7 +754,7 @@ foundit:
758 return 0; 754 return 0;
759} 755}
760 756
761static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block, 757static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block,
762 char *buffer) 758 char *buffer)
763{ 759{
764 struct INFTLrecord *inftl = (void *)mbd; 760 struct INFTLrecord *inftl = (void *)mbd;
@@ -893,7 +889,7 @@ extern char inftlmountrev[];
893 889
894static int __init init_inftl(void) 890static int __init init_inftl(void)
895{ 891{
896 printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.18 $, " 892 printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.19 $, "
897 "inftlmount.c %s\n", inftlmountrev); 893 "inftlmount.c %s\n", inftlmountrev);
898 894
899 return register_mtd_blktrans(&inftl_tr); 895 return register_mtd_blktrans(&inftl_tr);
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index b5dda47395a7..43fdc9433882 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -1,14 +1,14 @@
1/* 1/*
2 * inftlmount.c -- INFTL mount code with extensive checks. 2 * inftlmount.c -- INFTL mount code with extensive checks.
3 * 3 *
4 * Author: Greg Ungerer (gerg@snapgear.com) 4 * Author: Greg Ungerer (gerg@snapgear.com)
5 * (C) Copyright 2002-2003, Greg Ungerer (gerg@snapgear.com) 5 * (C) Copyright 2002-2003, Greg Ungerer (gerg@snapgear.com)
6 * 6 *
7 * Based heavily on the nftlmount.c code which is: 7 * Based heavily on the nftlmount.c code which is:
8 * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 8 * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
9 * Copyright (C) 2000 Netgem S.A. 9 * Copyright (C) 2000 Netgem S.A.
10 * 10 *
11 * $Id: inftlmount.c,v 1.16 2004/11/22 13:50:53 kalev Exp $ 11 * $Id: inftlmount.c,v 1.18 2005/11/07 11:14:20 gleixner Exp $
12 * 12 *
13 * 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
14 * 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
@@ -41,7 +41,7 @@
41#include <linux/mtd/inftl.h> 41#include <linux/mtd/inftl.h>
42#include <linux/mtd/compatmac.h> 42#include <linux/mtd/compatmac.h>
43 43
44char inftlmountrev[]="$Revision: 1.16 $"; 44char inftlmountrev[]="$Revision: 1.18 $";
45 45
46/* 46/*
47 * find_boot_record: Find the INFTL Media Header and its Spare copy which 47 * find_boot_record: Find the INFTL Media Header and its Spare copy which
@@ -273,7 +273,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
273 inftl->nb_boot_blocks); 273 inftl->nb_boot_blocks);
274 return -1; 274 return -1;
275 } 275 }
276 276
277 inftl->mbd.size = inftl->numvunits * 277 inftl->mbd.size = inftl->numvunits *
278 (inftl->EraseSize / SECTORSIZE); 278 (inftl->EraseSize / SECTORSIZE);
279 279
@@ -302,7 +302,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
302 inftl->nb_blocks * sizeof(u16)); 302 inftl->nb_blocks * sizeof(u16));
303 return -ENOMEM; 303 return -ENOMEM;
304 } 304 }
305 305
306 /* Mark the blocks before INFTL MediaHeader as reserved */ 306 /* Mark the blocks before INFTL MediaHeader as reserved */
307 for (i = 0; i < inftl->nb_boot_blocks; i++) 307 for (i = 0; i < inftl->nb_boot_blocks; i++)
308 inftl->PUtable[i] = BLOCK_RESERVED; 308 inftl->PUtable[i] = BLOCK_RESERVED;
@@ -380,7 +380,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
380 * 380 *
381 * Return: 0 when succeed, -1 on error. 381 * Return: 0 when succeed, -1 on error.
382 * 382 *
383 * ToDo: 1. Is it neceressary to check_free_sector after erasing ?? 383 * ToDo: 1. Is it neceressary to check_free_sector after erasing ??
384 */ 384 */
385int INFTL_formatblock(struct INFTLrecord *inftl, int block) 385int INFTL_formatblock(struct INFTLrecord *inftl, int block)
386{ 386{
@@ -563,7 +563,7 @@ int INFTL_mount(struct INFTLrecord *s)
563 /* Search for INFTL MediaHeader and Spare INFTL Media Header */ 563 /* Search for INFTL MediaHeader and Spare INFTL Media Header */
564 if (find_boot_record(s) < 0) { 564 if (find_boot_record(s) < 0) {
565 printk(KERN_WARNING "INFTL: could not find valid boot record?\n"); 565 printk(KERN_WARNING "INFTL: could not find valid boot record?\n");
566 return -1; 566 return -ENXIO;
567 } 567 }
568 568
569 /* Init the logical to physical table */ 569 /* Init the logical to physical table */
@@ -574,6 +574,12 @@ int INFTL_mount(struct INFTLrecord *s)
574 574
575 /* Temporary buffer to store ANAC numbers. */ 575 /* Temporary buffer to store ANAC numbers. */
576 ANACtable = kmalloc(s->nb_blocks * sizeof(u8), GFP_KERNEL); 576 ANACtable = kmalloc(s->nb_blocks * sizeof(u8), GFP_KERNEL);
577 if (!ANACtable) {
578 printk(KERN_WARNING "INFTL: allocation of ANACtable "
579 "failed (%zd bytes)\n",
580 s->nb_blocks * sizeof(u8));
581 return -ENOMEM;
582 }
577 memset(ANACtable, 0, s->nb_blocks); 583 memset(ANACtable, 0, s->nb_blocks);
578 584
579 /* 585 /*
@@ -595,7 +601,7 @@ int INFTL_mount(struct INFTLrecord *s)
595 601
596 for (chain_length = 0; ; chain_length++) { 602 for (chain_length = 0; ; chain_length++) {
597 603
598 if ((chain_length == 0) && 604 if ((chain_length == 0) &&
599 (s->PUtable[block] != BLOCK_NOTEXPLORED)) { 605 (s->PUtable[block] != BLOCK_NOTEXPLORED)) {
600 /* Nothing to do here, onto next block */ 606 /* Nothing to do here, onto next block */
601 break; 607 break;
@@ -742,7 +748,7 @@ int INFTL_mount(struct INFTLrecord *s)
742 "in virtual chain %d\n", 748 "in virtual chain %d\n",
743 s->PUtable[block], logical_block); 749 s->PUtable[block], logical_block);
744 s->PUtable[block] = BLOCK_NIL; 750 s->PUtable[block] = BLOCK_NIL;
745 751
746 } 752 }
747 if (ANACtable[block] != ANAC) { 753 if (ANACtable[block] != ANAC) {
748 /* 754 /*
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 44781a83b2e7..48638c8097a5 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -1,5 +1,5 @@
1# drivers/mtd/maps/Kconfig 1# drivers/mtd/maps/Kconfig
2# $Id: Kconfig,v 1.55 2005/07/02 01:53:24 tpoynor Exp $ 2# $Id: Kconfig,v 1.61 2005/11/07 11:14:26 gleixner Exp $
3 3
4menu "Mapping drivers for chip access" 4menu "Mapping drivers for chip access"
5 depends on MTD!=n 5 depends on MTD!=n
@@ -64,9 +64,9 @@ config 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 (SPARC32 || SPARC64) && 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
69 Sun Microsystems boardsets. This driver will require CFI support 69 Sun Microsystems boardsets. This driver will require CFI support
70 in the kernel, so if you did not enable CFI previously, do that now. 70 in the kernel, so if you did not enable CFI previously, do that now.
71 71
72config MTD_PNC2000 72config MTD_PNC2000
@@ -89,22 +89,22 @@ config MTD_NETSC520
89 depends on X86 && MTD_CFI && MTD_PARTITIONS 89 depends on X86 && MTD_CFI && MTD_PARTITIONS
90 help 90 help
91 This enables access routines for the flash chips on the AMD NetSc520 91 This enables access routines for the flash chips on the AMD NetSc520
92 demonstration board. If you have one of these boards and would like 92 demonstration board. If you have one of these boards and would like
93 to use the flash chips on it, say 'Y'. 93 to use the flash chips on it, say 'Y'.
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 X86 && MTD_JEDECPROBE && MTD_PARTITIONS 97 depends on ELAN
98 select MTD_PARTITIONS
99 select MTD_JEDECPROBE
100 select MTD_CFI_AMDSTD
98 help 101 help
99 This provides a driver for the on-board flash of the Technologic 102 This provides a driver for the on-board flash of the Technologic
100 System's TS-5500 board. The flash is split into 3 partitions 103 System's TS-5500 board. The 2MB flash is split into 3 partitions
101 which are accessed as separate MTD devices. 104 which are accessed as separate MTD devices.
102 105
103 mtd0 and mtd2 are the two BIOS drives. Unfortunately the BIOS 106 mtd0 and mtd2 are the two BIOS drives, which use the resident
104 uses a proprietary flash translation layer from General Software, 107 flash disk (RFD) flash translation layer.
105 which is not supported (the drives cannot be mounted). You can
106 create your own file system (jffs for example), but the BIOS
107 won't be able to boot from it.
108 108
109 mtd1 allows you to reprogram your BIOS. BE VERY CAREFUL. 109 mtd1 allows you to reprogram your BIOS. BE VERY CAREFUL.
110 110
@@ -212,11 +212,18 @@ config MTD_NETtel
212 Support for flash chips on NETtel/SecureEdge/SnapGear boards. 212 Support for flash chips on NETtel/SecureEdge/SnapGear boards.
213 213
214config MTD_ALCHEMY 214config MTD_ALCHEMY
215 tristate ' AMD Alchemy Pb1xxx/Db1xxx/RDK MTD support' 215 tristate ' AMD Alchemy Pb1xxx/Db1xxx/RDK MTD support'
216 depends on MIPS && SOC_AU1X00 216 depends on SOC_AU1X00
217 help 217 help
218 Flash memory access on AMD Alchemy Pb/Db/RDK Reference Boards 218 Flash memory access on AMD Alchemy Pb/Db/RDK Reference Boards
219 219
220config MTD_MTX1
221 tristate "4G Systems MTX-1 Flash device"
222 depends on MIPS && MIPS_MTX1
223 help
224 Flash memory access on 4G Systems MTX-1 Board. If you have one of
225 these boards and would like to use the flash chips on it, say 'Y'.
226
220config MTD_DILNETPC 227config MTD_DILNETPC
221 tristate "CFI Flash device mapped on DIL/Net PC" 228 tristate "CFI Flash device mapped on DIL/Net PC"
222 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT 229 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
@@ -244,14 +251,14 @@ config MTD_L440GX
244 251
245config MTD_SBC8240 252config MTD_SBC8240
246 tristate "Flash device on SBC8240" 253 tristate "Flash device on SBC8240"
247 depends on PPC32 && MTD_JEDECPROBE && 6xx && 8260 254 depends on MTD_JEDECPROBE && 8260
248 help 255 help
249 Flash access on the SBC8240 board from Wind River. See 256 Flash access on the SBC8240 board from Wind River. See
250 <http://www.windriver.com/products/sbc8240/> 257 <http://www.windriver.com/products/sbc8240/>
251 258
252config MTD_TQM8XXL 259config MTD_TQM8XXL
253 tristate "CFI Flash device mapped on TQM8XXL" 260 tristate "CFI Flash device mapped on TQM8XXL"
254 depends on MTD_CFI && PPC32 && 8xx && TQM8xxL 261 depends on MTD_CFI && TQM8xxL
255 help 262 help
256 The TQM8xxL PowerPC board has up to two banks of CFI-compliant 263 The TQM8xxL PowerPC board has up to two banks of CFI-compliant
257 chips, currently uses AMD one. This 'mapping' driver supports 264 chips, currently uses AMD one. This 'mapping' driver supports
@@ -261,7 +268,7 @@ config MTD_TQM8XXL
261 268
262config MTD_RPXLITE 269config MTD_RPXLITE
263 tristate "CFI Flash device mapped on RPX Lite or CLLF" 270 tristate "CFI Flash device mapped on RPX Lite or CLLF"
264 depends on MTD_CFI && PPC32 && 8xx && (RPXCLASSIC || RPXLITE) 271 depends on MTD_CFI && (RPXCLASSIC || RPXLITE)
265 help 272 help
266 The RPXLite PowerPC board has CFI-compliant chips mapped in 273 The RPXLite PowerPC board has CFI-compliant chips mapped in
267 a strange sparse mapping. This 'mapping' driver supports that 274 a strange sparse mapping. This 'mapping' driver supports that
@@ -271,7 +278,7 @@ config MTD_RPXLITE
271 278
272config MTD_MBX860 279config MTD_MBX860
273 tristate "System flash on MBX860 board" 280 tristate "System flash on MBX860 board"
274 depends on MTD_CFI && PPC32 && 8xx && MBX 281 depends on MTD_CFI && MBX
275 help 282 help
276 This enables access routines for the flash chips on the Motorola 283 This enables access routines for the flash chips on the Motorola
277 MBX860 board. If you have one of these boards and would like 284 MBX860 board. If you have one of these boards and would like
@@ -279,7 +286,7 @@ config MTD_MBX860
279 286
280config MTD_DBOX2 287config MTD_DBOX2
281 tristate "CFI Flash device mapped on D-Box2" 288 tristate "CFI Flash device mapped on D-Box2"
282 depends on PPC32 && 8xx && DBOX2 && MTD_CFI_INTELSTD && MTD_CFI_INTELEXT && MTD_CFI_AMDSTD 289 depends on DBOX2 && MTD_CFI_INTELSTD && MTD_CFI_INTELEXT && MTD_CFI_AMDSTD
283 help 290 help
284 This enables access routines for the flash chips on the Nokia/Sagem 291 This enables access routines for the flash chips on the Nokia/Sagem
285 D-Box 2 board. If you have one of these boards and would like to use 292 D-Box 2 board. If you have one of these boards and would like to use
@@ -287,14 +294,14 @@ config MTD_DBOX2
287 294
288config MTD_CFI_FLAGADM 295config MTD_CFI_FLAGADM
289 tristate "CFI Flash device mapping on FlagaDM" 296 tristate "CFI Flash device mapping on FlagaDM"
290 depends on PPC32 && 8xx && MTD_CFI 297 depends on 8xx && MTD_CFI
291 help 298 help
292 Mapping for the Flaga digital module. If you don't have one, ignore 299 Mapping for the Flaga digital module. If you don't have one, ignore
293 this setting. 300 this setting.
294 301
295config MTD_BEECH 302config MTD_BEECH
296 tristate "CFI Flash device mapped on IBM 405LP Beech" 303 tristate "CFI Flash device mapped on IBM 405LP Beech"
297 depends on MTD_CFI && PPC32 && 40x && BEECH 304 depends on MTD_CFI && BEECH
298 help 305 help
299 This enables access routines for the flash chips on the IBM 306 This enables access routines for the flash chips on the IBM
300 405LP Beech board. If you have one of these boards and would like 307 405LP Beech board. If you have one of these boards and would like
@@ -302,7 +309,7 @@ config MTD_BEECH
302 309
303config MTD_ARCTIC 310config MTD_ARCTIC
304 tristate "CFI Flash device mapped on IBM 405LP Arctic" 311 tristate "CFI Flash device mapped on IBM 405LP Arctic"
305 depends on MTD_CFI && PPC32 && 40x && ARCTIC2 312 depends on MTD_CFI && ARCTIC2
306 help 313 help
307 This enables access routines for the flash chips on the IBM 405LP 314 This enables access routines for the flash chips on the IBM 405LP
308 Arctic board. If you have one of these boards and would like to 315 Arctic board. If you have one of these boards and would like to
@@ -310,7 +317,7 @@ config MTD_ARCTIC
310 317
311config MTD_WALNUT 318config MTD_WALNUT
312 tristate "Flash device mapped on IBM 405GP Walnut" 319 tristate "Flash device mapped on IBM 405GP Walnut"
313 depends on MTD_JEDECPROBE && PPC32 && 40x && WALNUT 320 depends on MTD_JEDECPROBE && WALNUT
314 help 321 help
315 This enables access routines for the flash chips on the IBM 405GP 322 This enables access routines for the flash chips on the IBM 405GP
316 Walnut board. If you have one of these boards and would like to 323 Walnut board. If you have one of these boards and would like to
@@ -318,7 +325,7 @@ config MTD_WALNUT
318 325
319config MTD_EBONY 326config MTD_EBONY
320 tristate "Flash devices mapped on IBM 440GP Ebony" 327 tristate "Flash devices mapped on IBM 440GP Ebony"
321 depends on MTD_JEDECPROBE && PPC32 && 44x && EBONY 328 depends on MTD_JEDECPROBE && EBONY
322 help 329 help
323 This enables access routines for the flash chips on the IBM 440GP 330 This enables access routines for the flash chips on the IBM 440GP
324 Ebony board. If you have one of these boards and would like to 331 Ebony board. If you have one of these boards and would like to
@@ -326,7 +333,7 @@ config MTD_EBONY
326 333
327config MTD_OCOTEA 334config MTD_OCOTEA
328 tristate "Flash devices mapped on IBM 440GX Ocotea" 335 tristate "Flash devices mapped on IBM 440GX Ocotea"
329 depends on MTD_CFI && PPC32 && 44x && OCOTEA 336 depends on MTD_CFI && OCOTEA
330 help 337 help
331 This enables access routines for the flash chips on the IBM 440GX 338 This enables access routines for the flash chips on the IBM 440GX
332 Ocotea board. If you have one of these boards and would like to 339 Ocotea board. If you have one of these boards and would like to
@@ -334,12 +341,20 @@ config MTD_OCOTEA
334 341
335config MTD_REDWOOD 342config MTD_REDWOOD
336 tristate "CFI Flash devices mapped on IBM Redwood" 343 tristate "CFI Flash devices mapped on IBM Redwood"
337 depends on MTD_CFI && PPC32 && 4xx && 40x && ( REDWOOD_4 || REDWOOD_5 || REDWOOD_6 ) 344 depends on MTD_CFI && ( REDWOOD_4 || REDWOOD_5 || REDWOOD_6 )
338 help 345 help
339 This enables access routines for the flash chips on the IBM 346 This enables access routines for the flash chips on the IBM
340 Redwood board. If you have one of these boards and would like to 347 Redwood board. If you have one of these boards and would like to
341 use the flash chips on it, say 'Y'. 348 use the flash chips on it, say 'Y'.
342 349
350config MTD_TQM834x
351 tristate "Flash device mapped on TQ Components TQM834x Boards"
352 depends on MTD_CFI && TQM834x
353 help
354 This enables access routines for the flash chips on the
355 TQ Components TQM834x boards. If you have one of these boards
356 and would like to use the flash chips on it, say 'Y'.
357
343config MTD_CSTM_MIPS_IXX 358config MTD_CSTM_MIPS_IXX
344 tristate "Flash chip mapping on ITE QED-4N-S01B, Globespan IVR or custom board" 359 tristate "Flash chip mapping on ITE QED-4N-S01B, Globespan IVR or custom board"
345 depends on MIPS && MTD_CFI && MTD_JEDECPROBE && MTD_PARTITIONS 360 depends on MIPS && MTD_CFI && MTD_JEDECPROBE && MTD_PARTITIONS
@@ -362,8 +377,8 @@ config MTD_CSTM_MIPS_IXX_START
362 default "0x8000000" 377 default "0x8000000"
363 help 378 help
364 This is the physical memory location that the MTD driver will 379 This is the physical memory location that the MTD driver will
365 use for the flash chips on your particular target board. 380 use for the flash chips on your particular target board.
366 Refer to the memory map which should hopefully be in the 381 Refer to the memory map which should hopefully be in the
367 documentation for your board. 382 documentation for your board.
368 383
369config MTD_CSTM_MIPS_IXX_LEN 384config MTD_CSTM_MIPS_IXX_LEN
@@ -371,7 +386,7 @@ config MTD_CSTM_MIPS_IXX_LEN
371 depends on MTD_CSTM_MIPS_IXX 386 depends on MTD_CSTM_MIPS_IXX
372 default "0x4000000" 387 default "0x4000000"
373 help 388 help
374 This is the total length that the MTD driver will use for the 389 This is the total length that the MTD driver will use for the
375 flash chips on your particular board. Refer to the memory 390 flash chips on your particular board. Refer to the memory
376 map which should hopefully be in the documentation for your 391 map which should hopefully be in the documentation for your
377 board. 392 board.
@@ -405,14 +420,14 @@ config MTD_ARM_INTEGRATOR
405 420
406config MTD_CDB89712 421config MTD_CDB89712
407 tristate "Cirrus CDB89712 evaluation board mappings" 422 tristate "Cirrus CDB89712 evaluation board mappings"
408 depends on ARM && MTD_CFI && ARCH_CDB89712 423 depends on MTD_CFI && ARCH_CDB89712
409 help 424 help
410 This enables access to the flash or ROM chips on the CDB89712 board. 425 This enables access to the flash or ROM chips on the CDB89712 board.
411 If you have such a board, say 'Y'. 426 If you have such a board, say 'Y'.
412 427
413config MTD_SA1100 428config MTD_SA1100
414 tristate "CFI Flash device mapped on StrongARM SA11x0" 429 tristate "CFI Flash device mapped on StrongARM SA11x0"
415 depends on ARM && MTD_CFI && ARCH_SA1100 && MTD_PARTITIONS 430 depends on MTD_CFI && ARCH_SA1100 && MTD_PARTITIONS
416 help 431 help
417 This enables access to the flash chips on most platforms based on 432 This enables access to the flash chips on most platforms based on
418 the SA1100 and SA1110, including the Assabet and the Compaq iPAQ. 433 the SA1100 and SA1110, including the Assabet and the Compaq iPAQ.
@@ -420,13 +435,13 @@ config MTD_SA1100
420 435
421config MTD_IPAQ 436config MTD_IPAQ
422 tristate "CFI Flash device mapped on Compaq/HP iPAQ" 437 tristate "CFI Flash device mapped on Compaq/HP iPAQ"
423 depends on ARM && IPAQ_HANDHELD && MTD_CFI 438 depends on IPAQ_HANDHELD && MTD_CFI
424 help 439 help
425 This provides a driver for the on-board flash of the iPAQ. 440 This provides a driver for the on-board flash of the iPAQ.
426 441
427config MTD_DC21285 442config MTD_DC21285
428 tristate "CFI Flash device mapped on DC21285 Footbridge" 443 tristate "CFI Flash device mapped on DC21285 Footbridge"
429 depends on ARM && MTD_CFI && ARCH_FOOTBRIDGE && MTD_COMPLEX_MAPPINGS 444 depends on MTD_CFI && ARCH_FOOTBRIDGE && MTD_COMPLEX_MAPPINGS
430 help 445 help
431 This provides a driver for the flash accessed using Intel's 446 This provides a driver for the flash accessed using Intel's
432 21285 bridge used with Intel's StrongARM processors. More info at 447 21285 bridge used with Intel's StrongARM processors. More info at
@@ -434,33 +449,33 @@ config MTD_DC21285
434 449
435config MTD_IQ80310 450config MTD_IQ80310
436 tristate "CFI Flash device mapped on the XScale IQ80310 board" 451 tristate "CFI Flash device mapped on the XScale IQ80310 board"
437 depends on ARM && MTD_CFI && ARCH_IQ80310 452 depends on MTD_CFI && ARCH_IQ80310
438 help 453 help
439 This enables access routines for the flash chips on the Intel XScale 454 This enables access routines for the flash chips on the Intel XScale
440 IQ80310 evaluation board. If you have one of these boards and would 455 IQ80310 evaluation board. If you have one of these boards and would
441 like to use the flash chips on it, say 'Y'. 456 like to use the flash chips on it, say 'Y'.
442 457
443config MTD_IXP4XX 458config MTD_IXP4XX
444 tristate "CFI Flash device mapped on Intel IXP4xx based systems" 459 tristate "CFI Flash device mapped on Intel IXP4xx based systems"
445 depends on ARM && MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP4XX 460 depends on MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP4XX
446 help 461 help
447 This enables MTD access to flash devices on platforms based 462 This enables MTD access to flash devices on platforms based
448 on Intel's IXP4xx family of network processors such as the 463 on Intel's IXP4xx family of network processors such as the
449 IXDP425 and Coyote. If you have an IXP4xx based board and 464 IXDP425 and Coyote. If you have an IXP4xx based board and
450 would like to use the flash chips on it, say 'Y'. 465 would like to use the flash chips on it, say 'Y'.
451 466
452config MTD_IXP2000 467config MTD_IXP2000
453 tristate "CFI Flash device mapped on Intel IXP2000 based systems" 468 tristate "CFI Flash device mapped on Intel IXP2000 based systems"
454 depends on ARM && MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP2000 469 depends on MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP2000
455 help 470 help
456 This enables MTD access to flash devices on platforms based 471 This enables MTD access to flash devices on platforms based
457 on Intel's IXP2000 family of network processors such as the 472 on Intel's IXP2000 family of network processors such as the
458 IXDP425 and Coyote. If you have an IXP2000 based board and 473 IXDP425 and Coyote. If you have an IXP2000 based board and
459 would like to use the flash chips on it, say 'Y'. 474 would like to use the flash chips on it, say 'Y'.
460 475
461config MTD_EPXA10DB 476config MTD_EPXA10DB
462 tristate "CFI Flash device mapped on Epxa10db" 477 tristate "CFI Flash device mapped on Epxa10db"
463 depends on ARM && MTD_CFI && MTD_PARTITIONS && ARCH_CAMELOT 478 depends on MTD_CFI && MTD_PARTITIONS && ARCH_CAMELOT
464 help 479 help
465 This enables support for the flash devices on the Altera 480 This enables support for the flash devices on the Altera
466 Excalibur XA10 Development Board. If you are building a kernel 481 Excalibur XA10 Development Board. If you are building a kernel
@@ -468,21 +483,21 @@ config MTD_EPXA10DB
468 483
469config MTD_FORTUNET 484config MTD_FORTUNET
470 tristate "CFI Flash device mapped on the FortuNet board" 485 tristate "CFI Flash device mapped on the FortuNet board"
471 depends on ARM && MTD_CFI && MTD_PARTITIONS && SA1100_FORTUNET 486 depends on MTD_CFI && MTD_PARTITIONS && SA1100_FORTUNET
472 help 487 help
473 This enables access to the Flash on the FortuNet board. If you 488 This enables access to the Flash on the FortuNet board. If you
474 have such a board, say 'Y'. 489 have such a board, say 'Y'.
475 490
476config MTD_AUTCPU12 491config MTD_AUTCPU12
477 tristate "NV-RAM mapping AUTCPU12 board" 492 tristate "NV-RAM mapping AUTCPU12 board"
478 depends on ARM && ARCH_AUTCPU12 493 depends on ARCH_AUTCPU12
479 help 494 help
480 This enables access to the NV-RAM on autronix autcpu12 board. 495 This enables access to the NV-RAM on autronix autcpu12 board.
481 If you have such a board, say 'Y'. 496 If you have such a board, say 'Y'.
482 497
483config MTD_EDB7312 498config MTD_EDB7312
484 tristate "CFI Flash device mapped on EDB7312" 499 tristate "CFI Flash device mapped on EDB7312"
485 depends on ARM && MTD_CFI 500 depends on ARCH_EDB7312 && MTD_CFI
486 help 501 help
487 This enables access to the CFI Flash on the Cogent EDB7312 board. 502 This enables access to the CFI Flash on the Cogent EDB7312 board.
488 If you have such a board, say 'Y' here. 503 If you have such a board, say 'Y' here.
@@ -496,7 +511,7 @@ config MTD_IMPA7
496 511
497config MTD_CEIVA 512config MTD_CEIVA
498 tristate "JEDEC Flash device mapped on Ceiva/Polaroid PhotoMax Digital Picture Frame" 513 tristate "JEDEC Flash device mapped on Ceiva/Polaroid PhotoMax Digital Picture Frame"
499 depends on ARM && MTD_JEDECPROBE && ARCH_CEIVA 514 depends on MTD_JEDECPROBE && ARCH_CEIVA
500 help 515 help
501 This enables access to the flash chips on the Ceiva/Polaroid 516 This enables access to the flash chips on the Ceiva/Polaroid
502 PhotoMax Digital Picture Frame. 517 PhotoMax Digital Picture Frame.
@@ -504,25 +519,31 @@ config MTD_CEIVA
504 519
505config MTD_NOR_TOTO 520config MTD_NOR_TOTO
506 tristate "NOR Flash device on TOTO board" 521 tristate "NOR Flash device on TOTO board"
507 depends on ARM && ARCH_OMAP && OMAP_TOTO 522 depends on ARCH_OMAP && OMAP_TOTO
508 help 523 help
509 This enables access to the NOR flash on the Texas Instruments 524 This enables access to the NOR flash on the Texas Instruments
510 TOTO board. 525 TOTO board.
511 526
512config MTD_H720X 527config MTD_H720X
513 tristate "Hynix evaluation board mappings" 528 tristate "Hynix evaluation board mappings"
514 depends on ARM && MTD_CFI && ( ARCH_H7201 || ARCH_H7202 ) 529 depends on MTD_CFI && ( ARCH_H7201 || ARCH_H7202 )
515 help 530 help
516 This enables access to the flash chips on the Hynix evaluation boards. 531 This enables access to the flash chips on the Hynix evaluation boards.
517 If you have such a board, say 'Y'. 532 If you have such a board, say 'Y'.
518 533
519config MTD_MPC1211 534config MTD_MPC1211
520 tristate "CFI Flash device mapped on Interface MPC-1211" 535 tristate "CFI Flash device mapped on Interface MPC-1211"
521 depends on SUPERH && SH_MPC1211 && MTD_CFI 536 depends on SH_MPC1211 && MTD_CFI
522 help 537 help
523 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).
524 If you have such a board, say 'Y'. 539 If you have such a board, say 'Y'.
525 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
526config MTD_OMAP_NOR 547config MTD_OMAP_NOR
527 tristate "TI OMAP board mappings" 548 tristate "TI OMAP board mappings"
528 depends on MTD_CFI && ARCH_OMAP 549 depends on MTD_CFI && ARCH_OMAP
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 7bcbc49e329f..7d9e940a1dcd 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -1,7 +1,7 @@
1# 1#
2# linux/drivers/maps/Makefile 2# linux/drivers/maps/Makefile
3# 3#
4# $Id: Makefile.common,v 1.30 2005/07/02 01:53:24 tpoynor Exp $ 4# $Id: Makefile.common,v 1.34 2005/11/07 11:14:26 gleixner Exp $
5 5
6ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y) 6ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y)
7obj-$(CONFIG_MTD) += map_funcs.o 7obj-$(CONFIG_MTD) += map_funcs.o
@@ -26,7 +26,7 @@ obj-$(CONFIG_MTD_MAINSTONE) += mainstone-flash.o
26obj-$(CONFIG_MTD_MBX860) += mbx860.o 26obj-$(CONFIG_MTD_MBX860) += mbx860.o
27obj-$(CONFIG_MTD_CEIVA) += ceiva.o 27obj-$(CONFIG_MTD_CEIVA) += ceiva.o
28obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o 28obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o
29obj-$(CONFIG_MTD_PHYSMAP) += physmap.o 29obj-$(CONFIG_MTD_PHYSMAP) += physmap.o
30obj-$(CONFIG_MTD_PNC2000) += pnc2000.o 30obj-$(CONFIG_MTD_PNC2000) += pnc2000.o
31obj-$(CONFIG_MTD_PCMCIA) += pcmciamtd.o 31obj-$(CONFIG_MTD_PCMCIA) += pcmciamtd.o
32obj-$(CONFIG_MTD_RPXLITE) += rpxlite.o 32obj-$(CONFIG_MTD_RPXLITE) += rpxlite.o
@@ -70,3 +70,6 @@ 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
75obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
diff --git a/drivers/mtd/maps/alchemy-flash.c b/drivers/mtd/maps/alchemy-flash.c
index 27fd2a3c3b60..a57791a6ce40 100644
--- a/drivers/mtd/maps/alchemy-flash.c
+++ b/drivers/mtd/maps/alchemy-flash.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * Flash memory access on AMD Alchemy evaluation boards 2 * Flash memory access on AMD Alchemy evaluation boards
3 * 3 *
4 * $Id: alchemy-flash.c,v 1.1 2005/02/27 21:50:21 ppopov Exp $ 4 * $Id: alchemy-flash.c,v 1.2 2005/11/07 11:14:26 gleixner Exp $
5 * 5 *
6 * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com> 6 * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com>
7 * 7 *
8 */ 8 */
9 9
10#include <linux/config.h> 10#include <linux/config.h>
@@ -22,7 +22,7 @@
22#ifdef DEBUG_RW 22#ifdef DEBUG_RW
23#define DBG(x...) printk(x) 23#define DBG(x...) printk(x)
24#else 24#else
25#define DBG(x...) 25#define DBG(x...)
26#endif 26#endif
27 27
28#ifdef CONFIG_MIPS_PB1000 28#ifdef CONFIG_MIPS_PB1000
@@ -136,7 +136,7 @@ int __init alchemy_mtd_init(void)
136 int nb_parts = 0; 136 int nb_parts = 0;
137 unsigned long window_addr; 137 unsigned long window_addr;
138 unsigned long window_size; 138 unsigned long window_size;
139 139
140 /* Default flash buswidth */ 140 /* Default flash buswidth */
141 alchemy_map.bankwidth = BOARD_FLASH_WIDTH; 141 alchemy_map.bankwidth = BOARD_FLASH_WIDTH;
142 142
@@ -161,7 +161,7 @@ int __init alchemy_mtd_init(void)
161 * Now let's probe for the actual flash. Do it here since 161 * Now let's probe for the actual flash. Do it here since
162 * specific machine settings might have been set above. 162 * specific machine settings might have been set above.
163 */ 163 */
164 printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n", 164 printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
165 alchemy_map.bankwidth*8); 165 alchemy_map.bankwidth*8);
166 alchemy_map.virt = ioremap(window_addr, window_size); 166 alchemy_map.virt = ioremap(window_addr, window_size);
167 mymtd = do_map_probe("cfi_probe", &alchemy_map); 167 mymtd = do_map_probe("cfi_probe", &alchemy_map);
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
index e8a900a77685..c350878d4592 100644
--- a/drivers/mtd/maps/amd76xrom.c
+++ b/drivers/mtd/maps/amd76xrom.c
@@ -2,7 +2,7 @@
2 * amd76xrom.c 2 * amd76xrom.c
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * $Id: amd76xrom.c,v 1.20 2005/03/18 14:04:35 gleixner Exp $ 5 * $Id: amd76xrom.c,v 1.21 2005/11/07 11:14:26 gleixner Exp $
6 */ 6 */
7 7
8#include <linux/module.h> 8#include <linux/module.h>
@@ -70,7 +70,7 @@ static void amd76xrom_cleanup(struct amd76xrom_window *window)
70 list_del(&map->list); 70 list_del(&map->list);
71 kfree(map); 71 kfree(map);
72 } 72 }
73 if (window->rsrc.parent) 73 if (window->rsrc.parent)
74 release_resource(&window->rsrc); 74 release_resource(&window->rsrc);
75 75
76 if (window->virt) { 76 if (window->virt) {
@@ -107,7 +107,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
107 window->phys = 0xffff0000; /* 64KiB */ 107 window->phys = 0xffff0000; /* 64KiB */
108 } 108 }
109 window->size = 0xffffffffUL - window->phys + 1UL; 109 window->size = 0xffffffffUL - window->phys + 1UL;
110 110
111 /* 111 /*
112 * Try to reserve the window mem region. If this fails then 112 * Try to reserve the window mem region. If this fails then
113 * it is likely due to a fragment of the window being 113 * it is likely due to a fragment of the window being
@@ -138,7 +138,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
138 /* Enable writes through the rom window */ 138 /* Enable writes through the rom window */
139 pci_read_config_byte(pdev, 0x40, &byte); 139 pci_read_config_byte(pdev, 0x40, &byte);
140 pci_write_config_byte(pdev, 0x40, byte | 1); 140 pci_write_config_byte(pdev, 0x40, byte | 1);
141 141
142 /* FIXME handle registers 0x80 - 0x8C the bios region locks */ 142 /* FIXME handle registers 0x80 - 0x8C the bios region locks */
143 143
144 /* For write accesses caches are useless */ 144 /* For write accesses caches are useless */
@@ -186,7 +186,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
186 MOD_NAME, map->map.phys); 186 MOD_NAME, map->map.phys);
187 187
188 /* There is no generic VPP support */ 188 /* There is no generic VPP support */
189 for(map->map.bankwidth = 32; map->map.bankwidth; 189 for(map->map.bankwidth = 32; map->map.bankwidth;
190 map->map.bankwidth >>= 1) 190 map->map.bankwidth >>= 1)
191 { 191 {
192 char **probe_type; 192 char **probe_type;
@@ -239,7 +239,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
239 for(i = 0; i < cfi->numchips; i++) { 239 for(i = 0; i < cfi->numchips; i++) {
240 cfi->chips[i].start += offset; 240 cfi->chips[i].start += offset;
241 } 241 }
242 242
243 /* Now that the mtd devices is complete claim and export it */ 243 /* Now that the mtd devices is complete claim and export it */
244 map->mtd->owner = THIS_MODULE; 244 map->mtd->owner = THIS_MODULE;
245 if (add_mtd_device(map->mtd)) { 245 if (add_mtd_device(map->mtd)) {
@@ -259,9 +259,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
259 259
260 out: 260 out:
261 /* Free any left over map structures */ 261 /* Free any left over map structures */
262 if (map) { 262 kfree(map);
263 kfree(map);
264 }
265 /* See if I have any map structures */ 263 /* See if I have any map structures */
266 if (list_empty(&window->maps)) { 264 if (list_empty(&window->maps)) {
267 amd76xrom_cleanup(window); 265 amd76xrom_cleanup(window);
@@ -279,9 +277,9 @@ static void __devexit amd76xrom_remove_one (struct pci_dev *pdev)
279} 277}
280 278
281static struct pci_device_id amd76xrom_pci_tbl[] = { 279static struct pci_device_id amd76xrom_pci_tbl[] = {
282 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, 280 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410,
283 PCI_ANY_ID, PCI_ANY_ID, }, 281 PCI_ANY_ID, PCI_ANY_ID, },
284 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7440, 282 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7440,
285 PCI_ANY_ID, PCI_ANY_ID, }, 283 PCI_ANY_ID, PCI_ANY_ID, },
286 { PCI_VENDOR_ID_AMD, 0x7468 }, /* amd8111 support */ 284 { PCI_VENDOR_ID_AMD, 0x7468 }, /* amd8111 support */
287 { 0, } 285 { 0, }
diff --git a/drivers/mtd/maps/arctic-mtd.c b/drivers/mtd/maps/arctic-mtd.c
index 777276fd0e15..d95ae582fbe9 100644
--- a/drivers/mtd/maps/arctic-mtd.c
+++ b/drivers/mtd/maps/arctic-mtd.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * $Id: arctic-mtd.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $ 2 * $Id: arctic-mtd.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $
3 * 3 *
4 * drivers/mtd/maps/arctic-mtd.c MTD mappings and partition tables for 4 * drivers/mtd/maps/arctic-mtd.c MTD mappings and partition tables for
5 * IBM 405LP Arctic boards. 5 * IBM 405LP Arctic boards.
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
diff --git a/drivers/mtd/maps/autcpu12-nvram.c b/drivers/mtd/maps/autcpu12-nvram.c
index cf362ccc3c8e..7ed3424dd959 100644
--- a/drivers/mtd/maps/autcpu12-nvram.c
+++ b/drivers/mtd/maps/autcpu12-nvram.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * NV-RAM memory access on autcpu12 2 * NV-RAM memory access on autcpu12
3 * (C) 2002 Thomas Gleixner (gleixner@autronix.de) 3 * (C) 2002 Thomas Gleixner (gleixner@autronix.de)
4 * 4 *
5 * $Id: autcpu12-nvram.c,v 1.8 2004/11/04 13:24:14 gleixner Exp $ 5 * $Id: autcpu12-nvram.c,v 1.9 2005/11/07 11:14:26 gleixner Exp $
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
@@ -55,10 +55,10 @@ static int __init init_autcpu12_sram (void)
55 } 55 }
56 simple_map_init(&autcpu_sram_map); 56 simple_map_init(&autcpu_sram_map);
57 57
58 /* 58 /*
59 * Check for 32K/128K 59 * Check for 32K/128K
60 * read ofs 0 60 * read ofs 0
61 * read ofs 0x10000 61 * read ofs 0x10000
62 * Write complement to ofs 0x100000 62 * Write complement to ofs 0x100000
63 * Read and check result on ofs 0x0 63 * Read and check result on ofs 0x0
64 * Restore contents 64 * Restore contents
@@ -66,7 +66,7 @@ static int __init init_autcpu12_sram (void)
66 save0 = map_read32(&autcpu12_sram_map,0); 66 save0 = map_read32(&autcpu12_sram_map,0);
67 save1 = map_read32(&autcpu12_sram_map,0x10000); 67 save1 = map_read32(&autcpu12_sram_map,0x10000);
68 map_write32(&autcpu12_sram_map,~save0,0x10000); 68 map_write32(&autcpu12_sram_map,~save0,0x10000);
69 /* if we find this pattern on 0x0, we have 32K size 69 /* if we find this pattern on 0x0, we have 32K size
70 * restore contents and exit 70 * restore contents and exit
71 */ 71 */
72 if ( map_read32(&autcpu12_sram_map,0) != save0) { 72 if ( map_read32(&autcpu12_sram_map,0) != save0) {
@@ -89,7 +89,7 @@ map:
89 89
90 sram_mtd->owner = THIS_MODULE; 90 sram_mtd->owner = THIS_MODULE;
91 sram_mtd->erasesize = 16; 91 sram_mtd->erasesize = 16;
92 92
93 if (add_mtd_device(sram_mtd)) { 93 if (add_mtd_device(sram_mtd)) {
94 printk("NV-RAM device addition failed\n"); 94 printk("NV-RAM device addition failed\n");
95 err = -ENOMEM; 95 err = -ENOMEM;
@@ -97,7 +97,7 @@ map:
97 } 97 }
98 98
99 printk("NV-RAM device size %ldKiB registered on AUTCPU12\n",autcpu12_sram_map.size/SZ_1K); 99 printk("NV-RAM device size %ldKiB registered on AUTCPU12\n",autcpu12_sram_map.size/SZ_1K);
100 100
101 return 0; 101 return 0;
102 102
103out_probe: 103out_probe:
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
index bfe994e59265..b7858eb93534 100644
--- a/drivers/mtd/maps/bast-flash.c
+++ b/drivers/mtd/maps/bast-flash.c
@@ -9,7 +9,7 @@
9 * 20-Sep-2004 BJD Initial version 9 * 20-Sep-2004 BJD Initial version
10 * 17-Jan-2005 BJD Add whole device if no partitions found 10 * 17-Jan-2005 BJD Add whole device if no partitions found
11 * 11 *
12 * $Id: bast-flash.c,v 1.2 2005/01/18 11:13:47 bjd Exp $ 12 * $Id: bast-flash.c,v 1.5 2005/11/07 11:14:26 gleixner Exp $
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
@@ -75,7 +75,7 @@ static void bast_flash_setrw(int to)
75 75
76 local_irq_save(flags); 76 local_irq_save(flags);
77 val = __raw_readb(BAST_VA_CTRL3); 77 val = __raw_readb(BAST_VA_CTRL3);
78 78
79 if (to) 79 if (to)
80 val |= BAST_CPLD_CTRL3_ROMWEN; 80 val |= BAST_CPLD_CTRL3_ROMWEN;
81 else 81 else
@@ -93,7 +93,7 @@ static int bast_flash_remove(struct device *dev)
93 93
94 dev_set_drvdata(dev, NULL); 94 dev_set_drvdata(dev, NULL);
95 95
96 if (info == NULL) 96 if (info == NULL)
97 return 0; 97 return 0;
98 98
99 if (info->map.virt != NULL) 99 if (info->map.virt != NULL)
@@ -104,14 +104,13 @@ static int bast_flash_remove(struct device *dev)
104 map_destroy(info->mtd); 104 map_destroy(info->mtd);
105 } 105 }
106 106
107 if (info->partitions) 107 kfree(info->partitions);
108 kfree(info->partitions);
109 108
110 if (info->area) { 109 if (info->area) {
111 release_resource(info->area); 110 release_resource(info->area);
112 kfree(info->area); 111 kfree(info->area);
113 } 112 }
114 113
115 kfree(info); 114 kfree(info);
116 115
117 return 0; 116 return 0;
@@ -138,15 +137,15 @@ static int bast_flash_probe(struct device *dev)
138 137
139 info->map.phys = res->start; 138 info->map.phys = res->start;
140 info->map.size = res->end - res->start + 1; 139 info->map.size = res->end - res->start + 1;
141 info->map.name = dev->bus_id; 140 info->map.name = dev->bus_id;
142 info->map.bankwidth = 2; 141 info->map.bankwidth = 2;
143 142
144 if (info->map.size > AREA_MAXSIZE) 143 if (info->map.size > AREA_MAXSIZE)
145 info->map.size = AREA_MAXSIZE; 144 info->map.size = AREA_MAXSIZE;
146 145
147 pr_debug("%s: area %08lx, size %ld\n", __FUNCTION__, 146 pr_debug("%s: area %08lx, size %ld\n", __FUNCTION__,
148 info->map.phys, info->map.size); 147 info->map.phys, info->map.size);
149 148
150 info->area = request_mem_region(res->start, info->map.size, 149 info->area = request_mem_region(res->start, info->map.size,
151 pdev->name); 150 pdev->name);
152 if (info->area == NULL) { 151 if (info->area == NULL) {
@@ -163,7 +162,7 @@ static int bast_flash_probe(struct device *dev)
163 err = -EIO; 162 err = -EIO;
164 goto exit_error; 163 goto exit_error;
165 } 164 }
166 165
167 simple_map_init(&info->map); 166 simple_map_init(&info->map);
168 167
169 /* enable the write to the flash area */ 168 /* enable the write to the flash area */
@@ -188,7 +187,7 @@ static int bast_flash_probe(struct device *dev)
188 err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0); 187 err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0);
189 if (err > 0) { 188 if (err > 0) {
190 err = add_mtd_partitions(info->mtd, info->partitions, err); 189 err = add_mtd_partitions(info->mtd, info->partitions, err);
191 if (err) 190 if (err)
192 printk(KERN_ERR PFX "cannot add/parse partitions\n"); 191 printk(KERN_ERR PFX "cannot add/parse partitions\n");
193 } else { 192 } else {
194 err = add_mtd_device(info->mtd); 193 err = add_mtd_device(info->mtd);
@@ -206,6 +205,7 @@ static int bast_flash_probe(struct device *dev)
206 205
207static struct device_driver bast_flash_driver = { 206static struct device_driver bast_flash_driver = {
208 .name = "bast-nor", 207 .name = "bast-nor",
208 .owner = THIS_MODULE,
209 .bus = &platform_bus_type, 209 .bus = &platform_bus_type,
210 .probe = bast_flash_probe, 210 .probe = bast_flash_probe,
211 .remove = bast_flash_remove, 211 .remove = bast_flash_remove,
diff --git a/drivers/mtd/maps/beech-mtd.c b/drivers/mtd/maps/beech-mtd.c
index 5e79c9d5da2b..5df7361d1407 100644
--- a/drivers/mtd/maps/beech-mtd.c
+++ b/drivers/mtd/maps/beech-mtd.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * $Id: beech-mtd.c,v 1.10 2004/11/04 13:24:14 gleixner Exp $ 2 * $Id: beech-mtd.c,v 1.11 2005/11/07 11:14:26 gleixner Exp $
3 * 3 *
4 * drivers/mtd/maps/beech-mtd.c MTD mappings and partition tables for 4 * drivers/mtd/maps/beech-mtd.c MTD mappings and partition tables for
5 * IBM 405LP Beech boards. 5 * IBM 405LP Beech boards.
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
diff --git a/drivers/mtd/maps/cdb89712.c b/drivers/mtd/maps/cdb89712.c
index ab15dac2f936..9f17bb6c5a9d 100644
--- a/drivers/mtd/maps/cdb89712.c
+++ b/drivers/mtd/maps/cdb89712.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Flash on Cirrus CDB89712 2 * Flash on Cirrus CDB89712
3 * 3 *
4 * $Id: cdb89712.c,v 1.10 2004/11/04 13:24:14 gleixner Exp $ 4 * $Id: cdb89712.c,v 1.11 2005/11/07 11:14:26 gleixner Exp $
5 */ 5 */
6 6
7#include <linux/module.h> 7#include <linux/module.h>
@@ -37,13 +37,13 @@ struct resource cdb89712_flash_resource = {
37static int __init init_cdb89712_flash (void) 37static int __init init_cdb89712_flash (void)
38{ 38{
39 int err; 39 int err;
40 40
41 if (request_resource (&ioport_resource, &cdb89712_flash_resource)) { 41 if (request_resource (&ioport_resource, &cdb89712_flash_resource)) {
42 printk(KERN_NOTICE "Failed to reserve Cdb89712 FLASH space\n"); 42 printk(KERN_NOTICE "Failed to reserve Cdb89712 FLASH space\n");
43 err = -EBUSY; 43 err = -EBUSY;
44 goto out; 44 goto out;
45 } 45 }
46 46
47 cdb89712_flash_map.virt = ioremap(FLASH_START, FLASH_SIZE); 47 cdb89712_flash_map.virt = ioremap(FLASH_START, FLASH_SIZE);
48 if (!cdb89712_flash_map.virt) { 48 if (!cdb89712_flash_map.virt) {
49 printk(KERN_NOTICE "Failed to ioremap Cdb89712 FLASH space\n"); 49 printk(KERN_NOTICE "Failed to ioremap Cdb89712 FLASH space\n");
@@ -64,13 +64,13 @@ static int __init init_cdb89712_flash (void)
64 } 64 }
65 65
66 flash_mtd->owner = THIS_MODULE; 66 flash_mtd->owner = THIS_MODULE;
67 67
68 if (add_mtd_device(flash_mtd)) { 68 if (add_mtd_device(flash_mtd)) {
69 printk("FLASH device addition failed\n"); 69 printk("FLASH device addition failed\n");
70 err = -ENOMEM; 70 err = -ENOMEM;
71 goto out_probe; 71 goto out_probe;
72 } 72 }
73 73
74 return 0; 74 return 0;
75 75
76out_probe: 76out_probe:
@@ -107,13 +107,13 @@ struct resource cdb89712_sram_resource = {
107static int __init init_cdb89712_sram (void) 107static int __init init_cdb89712_sram (void)
108{ 108{
109 int err; 109 int err;
110 110
111 if (request_resource (&ioport_resource, &cdb89712_sram_resource)) { 111 if (request_resource (&ioport_resource, &cdb89712_sram_resource)) {
112 printk(KERN_NOTICE "Failed to reserve Cdb89712 SRAM space\n"); 112 printk(KERN_NOTICE "Failed to reserve Cdb89712 SRAM space\n");
113 err = -EBUSY; 113 err = -EBUSY;
114 goto out; 114 goto out;
115 } 115 }
116 116
117 cdb89712_sram_map.virt = ioremap(SRAM_START, SRAM_SIZE); 117 cdb89712_sram_map.virt = ioremap(SRAM_START, SRAM_SIZE);
118 if (!cdb89712_sram_map.virt) { 118 if (!cdb89712_sram_map.virt) {
119 printk(KERN_NOTICE "Failed to ioremap Cdb89712 SRAM space\n"); 119 printk(KERN_NOTICE "Failed to ioremap Cdb89712 SRAM space\n");
@@ -130,13 +130,13 @@ static int __init init_cdb89712_sram (void)
130 130
131 sram_mtd->owner = THIS_MODULE; 131 sram_mtd->owner = THIS_MODULE;
132 sram_mtd->erasesize = 16; 132 sram_mtd->erasesize = 16;
133 133
134 if (add_mtd_device(sram_mtd)) { 134 if (add_mtd_device(sram_mtd)) {
135 printk("SRAM device addition failed\n"); 135 printk("SRAM device addition failed\n");
136 err = -ENOMEM; 136 err = -ENOMEM;
137 goto out_probe; 137 goto out_probe;
138 } 138 }
139 139
140 return 0; 140 return 0;
141 141
142out_probe: 142out_probe:
@@ -175,13 +175,13 @@ struct resource cdb89712_bootrom_resource = {
175static int __init init_cdb89712_bootrom (void) 175static int __init init_cdb89712_bootrom (void)
176{ 176{
177 int err; 177 int err;
178 178
179 if (request_resource (&ioport_resource, &cdb89712_bootrom_resource)) { 179 if (request_resource (&ioport_resource, &cdb89712_bootrom_resource)) {
180 printk(KERN_NOTICE "Failed to reserve Cdb89712 BOOTROM space\n"); 180 printk(KERN_NOTICE "Failed to reserve Cdb89712 BOOTROM space\n");
181 err = -EBUSY; 181 err = -EBUSY;
182 goto out; 182 goto out;
183 } 183 }
184 184
185 cdb89712_bootrom_map.virt = ioremap(BOOTROM_START, BOOTROM_SIZE); 185 cdb89712_bootrom_map.virt = ioremap(BOOTROM_START, BOOTROM_SIZE);
186 if (!cdb89712_bootrom_map.virt) { 186 if (!cdb89712_bootrom_map.virt) {
187 printk(KERN_NOTICE "Failed to ioremap Cdb89712 BootROM space\n"); 187 printk(KERN_NOTICE "Failed to ioremap Cdb89712 BootROM space\n");
@@ -198,13 +198,13 @@ static int __init init_cdb89712_bootrom (void)
198 198
199 bootrom_mtd->owner = THIS_MODULE; 199 bootrom_mtd->owner = THIS_MODULE;
200 bootrom_mtd->erasesize = 0x10000; 200 bootrom_mtd->erasesize = 0x10000;
201 201
202 if (add_mtd_device(bootrom_mtd)) { 202 if (add_mtd_device(bootrom_mtd)) {
203 printk("BootROM device addition failed\n"); 203 printk("BootROM device addition failed\n");
204 err = -ENOMEM; 204 err = -ENOMEM;
205 goto out_probe; 205 goto out_probe;
206 } 206 }
207 207
208 return 0; 208 return 0;
209 209
210out_probe: 210out_probe:
@@ -225,16 +225,16 @@ out:
225static int __init init_cdb89712_maps(void) 225static int __init init_cdb89712_maps(void)
226{ 226{
227 227
228 printk(KERN_INFO "Cirrus CDB89712 MTD mappings:\n Flash 0x%x at 0x%x\n SRAM 0x%x at 0x%x\n BootROM 0x%x at 0x%x\n", 228 printk(KERN_INFO "Cirrus CDB89712 MTD mappings:\n Flash 0x%x at 0x%x\n SRAM 0x%x at 0x%x\n BootROM 0x%x at 0x%x\n",
229 FLASH_SIZE, FLASH_START, SRAM_SIZE, SRAM_START, BOOTROM_SIZE, BOOTROM_START); 229 FLASH_SIZE, FLASH_START, SRAM_SIZE, SRAM_START, BOOTROM_SIZE, BOOTROM_START);
230 230
231 init_cdb89712_flash(); 231 init_cdb89712_flash();
232 init_cdb89712_sram(); 232 init_cdb89712_sram();
233 init_cdb89712_bootrom(); 233 init_cdb89712_bootrom();
234 234
235 return 0; 235 return 0;
236} 236}
237 237
238 238
239static void __exit cleanup_cdb89712_maps(void) 239static void __exit cleanup_cdb89712_maps(void)
240{ 240{
@@ -244,7 +244,7 @@ static void __exit cleanup_cdb89712_maps(void)
244 iounmap((void *)cdb89712_sram_map.virt); 244 iounmap((void *)cdb89712_sram_map.virt);
245 release_resource (&cdb89712_sram_resource); 245 release_resource (&cdb89712_sram_resource);
246 } 246 }
247 247
248 if (flash_mtd) { 248 if (flash_mtd) {
249 del_mtd_device(flash_mtd); 249 del_mtd_device(flash_mtd);
250 map_destroy(flash_mtd); 250 map_destroy(flash_mtd);
diff --git a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c
index c68b31dc7e6d..5a95ab370a97 100644
--- a/drivers/mtd/maps/ceiva.c
+++ b/drivers/mtd/maps/ceiva.c
@@ -313,8 +313,7 @@ static void __init clps_locate_partitions(struct mtd_info *mtd)
313 313
314static void __exit clps_destroy_partitions(void) 314static void __exit clps_destroy_partitions(void)
315{ 315{
316 if (parsed_parts) 316 kfree(parsed_parts);
317 kfree(parsed_parts);
318} 317}
319 318
320static struct mtd_info *mymtd; 319static struct mtd_info *mymtd;
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c
index f72e4f894b32..6a8c0415bde8 100644
--- a/drivers/mtd/maps/cfi_flagadm.c
+++ b/drivers/mtd/maps/cfi_flagadm.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Copyright © 2001 Flaga hf. Medical Devices, Kári Davíðsson <kd@flaga.is> 2 * Copyright © 2001 Flaga hf. Medical Devices, Kári Davíðsson <kd@flaga.is>
3 * 3 *
4 * $Id: cfi_flagadm.c,v 1.14 2004/11/04 13:24:14 gleixner Exp $ 4 * $Id: cfi_flagadm.c,v 1.15 2005/11/07 11:14:26 gleixner Exp $
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the 7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your 8 * Free Software Foundation; either version 2 of the License, or (at your
@@ -42,7 +42,7 @@
42 */ 42 */
43 43
44#define FLASH_PHYS_ADDR 0x40000000 44#define FLASH_PHYS_ADDR 0x40000000
45#define FLASH_SIZE 0x400000 45#define FLASH_SIZE 0x400000
46 46
47#define FLASH_PARTITION0_ADDR 0x00000000 47#define FLASH_PARTITION0_ADDR 0x00000000
48#define FLASH_PARTITION0_SIZE 0x00020000 48#define FLASH_PARTITION0_SIZE 0x00020000
@@ -79,7 +79,7 @@ struct mtd_partition flagadm_parts[] = {
79 .offset = FLASH_PARTITION2_ADDR, 79 .offset = FLASH_PARTITION2_ADDR,
80 .size = FLASH_PARTITION2_SIZE 80 .size = FLASH_PARTITION2_SIZE
81 }, 81 },
82 { 82 {
83 .name = "Persistant storage", 83 .name = "Persistant storage",
84 .offset = FLASH_PARTITION3_ADDR, 84 .offset = FLASH_PARTITION3_ADDR,
85 .size = FLASH_PARTITION3_SIZE 85 .size = FLASH_PARTITION3_SIZE
@@ -91,10 +91,10 @@ struct mtd_partition flagadm_parts[] = {
91static struct mtd_info *mymtd; 91static struct mtd_info *mymtd;
92 92
93int __init init_flagadm(void) 93int __init init_flagadm(void)
94{ 94{
95 printk(KERN_NOTICE "FlagaDM flash device: %x at %x\n", 95 printk(KERN_NOTICE "FlagaDM flash device: %x at %x\n",
96 FLASH_SIZE, FLASH_PHYS_ADDR); 96 FLASH_SIZE, FLASH_PHYS_ADDR);
97 97
98 flagadm_map.phys = FLASH_PHYS_ADDR; 98 flagadm_map.phys = FLASH_PHYS_ADDR;
99 flagadm_map.virt = ioremap(FLASH_PHYS_ADDR, 99 flagadm_map.virt = ioremap(FLASH_PHYS_ADDR,
100 FLASH_SIZE); 100 FLASH_SIZE);
diff --git a/drivers/mtd/maps/cstm_mips_ixx.c b/drivers/mtd/maps/cstm_mips_ixx.c
index ae9252fbf176..a370953c1513 100644
--- a/drivers/mtd/maps/cstm_mips_ixx.c
+++ b/drivers/mtd/maps/cstm_mips_ixx.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * $Id: cstm_mips_ixx.c,v 1.12 2004/11/04 13:24:14 gleixner Exp $ 2 * $Id: cstm_mips_ixx.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $
3 * 3 *
4 * Mapping of a custom board with both AMD CFI and JEDEC flash in partitions. 4 * Mapping of a custom board with both AMD CFI and JEDEC flash in partitions.
5 * Config with both CFI and JEDEC device support. 5 * Config with both CFI and JEDEC device support.
6 * 6 *
7 * Basically physmap.c with the addition of partitions and 7 * Basically physmap.c with the addition of partitions and
8 * an array of mapping info to accomodate more than one flash type per board. 8 * an array of mapping info to accomodate more than one flash type per board.
9 * 9 *
10 * Copyright 2000 MontaVista Software Inc. 10 * Copyright 2000 MontaVista Software Inc.
@@ -69,7 +69,7 @@ void cstm_mips_ixx_set_vpp(struct map_info *map,int vpp)
69 __u16 data; 69 __u16 data;
70 __u8 data1; 70 __u8 data1;
71 static u8 first = 1; 71 static u8 first = 1;
72 72
73 // Set GPIO port B pin3 to high 73 // Set GPIO port B pin3 to high
74 data = *(__u16 *)(CC_GPBCR); 74 data = *(__u16 *)(CC_GPBCR);
75 data = (data & 0xff0f) | 0x0040; 75 data = (data & 0xff0f) | 0x0040;
@@ -85,7 +85,7 @@ void cstm_mips_ixx_set_vpp(struct map_info *map,int vpp)
85 } else { 85 } else {
86 if (!--vpp_count) { 86 if (!--vpp_count) {
87 __u16 data; 87 __u16 data;
88 88
89 // Set GPIO port B pin3 to high 89 // Set GPIO port B pin3 to high
90 data = *(__u16 *)(CC_GPBCR); 90 data = *(__u16 *)(CC_GPBCR);
91 data = (data & 0xff3f) | 0x0040; 91 data = (data & 0xff3f) | 0x0040;
@@ -109,8 +109,8 @@ struct cstm_mips_ixx_info {
109}; 109};
110 110
111#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) 111#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR)
112#define PHYSMAP_NUMBER 1 // number of board desc structs needed, one per contiguous flash type 112#define PHYSMAP_NUMBER 1 // number of board desc structs needed, one per contiguous flash type
113const struct cstm_mips_ixx_info cstm_mips_ixx_board_desc[PHYSMAP_NUMBER] = 113const struct cstm_mips_ixx_info cstm_mips_ixx_board_desc[PHYSMAP_NUMBER] =
114{ 114{
115 { // 28F128J3A in 2x16 configuration 115 { // 28F128J3A in 2x16 configuration
116 "big flash", // name 116 "big flash", // name
@@ -131,10 +131,10 @@ static struct mtd_partition cstm_mips_ixx_partitions[PHYSMAP_NUMBER][MAX_PHYSMAP
131}, 131},
132}; 132};
133#else /* defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) */ 133#else /* defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) */
134#define PHYSMAP_NUMBER 1 // number of board desc structs needed, one per contiguous flash type 134#define PHYSMAP_NUMBER 1 // number of board desc structs needed, one per contiguous flash type
135const struct cstm_mips_ixx_info cstm_mips_ixx_board_desc[PHYSMAP_NUMBER] = 135const struct cstm_mips_ixx_info cstm_mips_ixx_board_desc[PHYSMAP_NUMBER] =
136{ 136{
137 { 137 {
138 "MTD flash", // name 138 "MTD flash", // name
139 CONFIG_MTD_CSTM_MIPS_IXX_START, // window_addr 139 CONFIG_MTD_CSTM_MIPS_IXX_START, // window_addr
140 CONFIG_MTD_CSTM_MIPS_IXX_LEN, // window_size 140 CONFIG_MTD_CSTM_MIPS_IXX_LEN, // window_size
@@ -144,7 +144,7 @@ const struct cstm_mips_ixx_info cstm_mips_ixx_board_desc[PHYSMAP_NUMBER] =
144 144
145}; 145};
146static struct mtd_partition cstm_mips_ixx_partitions[PHYSMAP_NUMBER][MAX_PHYSMAP_PARTITIONS] = { 146static struct mtd_partition cstm_mips_ixx_partitions[PHYSMAP_NUMBER][MAX_PHYSMAP_PARTITIONS] = {
147{ 147{
148 { 148 {
149 .name = "main partition", 149 .name = "main partition",
150 .size = CONFIG_MTD_CSTM_MIPS_IXX_LEN, 150 .size = CONFIG_MTD_CSTM_MIPS_IXX_LEN,
@@ -165,7 +165,7 @@ int __init init_cstm_mips_ixx(void)
165 165
166 /* Initialize mapping */ 166 /* Initialize mapping */
167 for (i=0;i<PHYSMAP_NUMBER;i++) { 167 for (i=0;i<PHYSMAP_NUMBER;i++) {
168 printk(KERN_NOTICE "cstm_mips_ixx flash device: 0x%lx at 0x%lx\n", 168 printk(KERN_NOTICE "cstm_mips_ixx flash device: 0x%lx at 0x%lx\n",
169 cstm_mips_ixx_board_desc[i].window_size, cstm_mips_ixx_board_desc[i].window_addr); 169 cstm_mips_ixx_board_desc[i].window_size, cstm_mips_ixx_board_desc[i].window_addr);
170 170
171 171
@@ -235,7 +235,7 @@ void PCISetULongByOffset(__u32 DevNumber, __u32 FuncNumber, __u32 Offset, __u32
235 235
236 offset = ( unsigned long )( 0x80000000 | ( DevNumber << 11 ) + ( FuncNumber << 8 ) + Offset) ; 236 offset = ( unsigned long )( 0x80000000 | ( DevNumber << 11 ) + ( FuncNumber << 8 ) + Offset) ;
237 237
238 *(__u32 *)CC_CONFADDR = offset; 238 *(__u32 *)CC_CONFADDR = offset;
239 *(__u32 *)CC_CONFDATA = data; 239 *(__u32 *)CC_CONFDATA = data;
240} 240}
241void setup_ITE_IVR_flash() 241void setup_ITE_IVR_flash()
diff --git a/drivers/mtd/maps/dbox2-flash.c b/drivers/mtd/maps/dbox2-flash.c
index d850a27a4b59..49d90542fc75 100644
--- a/drivers/mtd/maps/dbox2-flash.c
+++ b/drivers/mtd/maps/dbox2-flash.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: dbox2-flash.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $ 2 * $Id: dbox2-flash.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $
3 * 3 *
4 * D-Box 2 flash driver 4 * D-Box 2 flash driver
5 */ 5 */
@@ -21,38 +21,38 @@
21static struct mtd_partition partition_info[]= { 21static struct mtd_partition partition_info[]= {
22 { 22 {
23 .name = "BR bootloader", 23 .name = "BR bootloader",
24 .size = 128 * 1024, 24 .size = 128 * 1024,
25 .offset = 0, 25 .offset = 0,
26 .mask_flags = MTD_WRITEABLE 26 .mask_flags = MTD_WRITEABLE
27 }, 27 },
28 { 28 {
29 .name = "FLFS (U-Boot)", 29 .name = "FLFS (U-Boot)",
30 .size = 128 * 1024, 30 .size = 128 * 1024,
31 .offset = MTDPART_OFS_APPEND, 31 .offset = MTDPART_OFS_APPEND,
32 .mask_flags = 0 32 .mask_flags = 0
33 }, 33 },
34 { 34 {
35 .name = "Root (SquashFS)", 35 .name = "Root (SquashFS)",
36 .size = 7040 * 1024, 36 .size = 7040 * 1024,
37 .offset = MTDPART_OFS_APPEND, 37 .offset = MTDPART_OFS_APPEND,
38 .mask_flags = 0 38 .mask_flags = 0
39 }, 39 },
40 { 40 {
41 .name = "var (JFFS2)", 41 .name = "var (JFFS2)",
42 .size = 896 * 1024, 42 .size = 896 * 1024,
43 .offset = MTDPART_OFS_APPEND, 43 .offset = MTDPART_OFS_APPEND,
44 .mask_flags = 0 44 .mask_flags = 0
45 }, 45 },
46 { 46 {
47 .name = "Flash without bootloader", 47 .name = "Flash without bootloader",
48 .size = MTDPART_SIZ_FULL, 48 .size = MTDPART_SIZ_FULL,
49 .offset = 128 * 1024, 49 .offset = 128 * 1024,
50 .mask_flags = 0 50 .mask_flags = 0
51 }, 51 },
52 { 52 {
53 .name = "Complete Flash", 53 .name = "Complete Flash",
54 .size = MTDPART_SIZ_FULL, 54 .size = MTDPART_SIZ_FULL,
55 .offset = 0, 55 .offset = 0,
56 .mask_flags = MTD_WRITEABLE 56 .mask_flags = MTD_WRITEABLE
57 } 57 }
58}; 58};
@@ -88,16 +88,16 @@ int __init init_dbox2_flash(void)
88 if (!mymtd) { 88 if (!mymtd) {
89 // Probe for single Intel 28F640 89 // Probe for single Intel 28F640
90 dbox2_flash_map.bankwidth = 2; 90 dbox2_flash_map.bankwidth = 2;
91 91
92 mymtd = do_map_probe("cfi_probe", &dbox2_flash_map); 92 mymtd = do_map_probe("cfi_probe", &dbox2_flash_map);
93 } 93 }
94 94
95 if (mymtd) { 95 if (mymtd) {
96 mymtd->owner = THIS_MODULE; 96 mymtd->owner = THIS_MODULE;
97 97
98 /* Create MTD devices for each partition. */ 98 /* Create MTD devices for each partition. */
99 add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS); 99 add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
100 100
101 return 0; 101 return 0;
102 } 102 }
103 103
diff --git a/drivers/mtd/maps/dc21285.c b/drivers/mtd/maps/dc21285.c
index e5b74169fde6..701620b6baed 100644
--- a/drivers/mtd/maps/dc21285.c
+++ b/drivers/mtd/maps/dc21285.c
@@ -4,8 +4,8 @@
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 * 7 *
8 * $Id: dc21285.c,v 1.22 2004/11/01 13:39:21 rmk Exp $ 8 * $Id: dc21285.c,v 1.24 2005/11/07 11:14:26 gleixner Exp $
9 */ 9 */
10#include <linux/config.h> 10#include <linux/config.h>
11#include <linux/module.h> 11#include <linux/module.h>
@@ -27,9 +27,9 @@
27static struct mtd_info *dc21285_mtd; 27static struct mtd_info *dc21285_mtd;
28 28
29#ifdef CONFIG_ARCH_NETWINDER 29#ifdef CONFIG_ARCH_NETWINDER
30/* 30/*
31 * This is really ugly, but it seams to be the only 31 * This is really ugly, but it seams to be the only
32 * realiable way to do it, as the cpld state machine 32 * realiable way to do it, as the cpld state machine
33 * is unpredictible. So we have a 25us penalty per 33 * is unpredictible. So we have a 25us penalty per
34 * write access. 34 * write access.
35 */ 35 */
@@ -150,7 +150,7 @@ static struct map_info dc21285_map = {
150static struct mtd_partition *dc21285_parts; 150static struct mtd_partition *dc21285_parts;
151static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 151static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
152#endif 152#endif
153 153
154static int __init init_dc21285(void) 154static int __init init_dc21285(void)
155{ 155{
156 156
@@ -160,20 +160,20 @@ static int __init init_dc21285(void)
160 160
161 /* Determine bankwidth */ 161 /* Determine bankwidth */
162 switch (*CSR_SA110_CNTL & (3<<14)) { 162 switch (*CSR_SA110_CNTL & (3<<14)) {
163 case SA110_CNTL_ROMWIDTH_8: 163 case SA110_CNTL_ROMWIDTH_8:
164 dc21285_map.bankwidth = 1; 164 dc21285_map.bankwidth = 1;
165 dc21285_map.read = dc21285_read8; 165 dc21285_map.read = dc21285_read8;
166 dc21285_map.write = dc21285_write8; 166 dc21285_map.write = dc21285_write8;
167 dc21285_map.copy_to = dc21285_copy_to_8; 167 dc21285_map.copy_to = dc21285_copy_to_8;
168 break; 168 break;
169 case SA110_CNTL_ROMWIDTH_16: 169 case SA110_CNTL_ROMWIDTH_16:
170 dc21285_map.bankwidth = 2; 170 dc21285_map.bankwidth = 2;
171 dc21285_map.read = dc21285_read16; 171 dc21285_map.read = dc21285_read16;
172 dc21285_map.write = dc21285_write16; 172 dc21285_map.write = dc21285_write16;
173 dc21285_map.copy_to = dc21285_copy_to_16; 173 dc21285_map.copy_to = dc21285_copy_to_16;
174 break; 174 break;
175 case SA110_CNTL_ROMWIDTH_32: 175 case SA110_CNTL_ROMWIDTH_32:
176 dc21285_map.bankwidth = 4; 176 dc21285_map.bankwidth = 4;
177 dc21285_map.read = dc21285_read32; 177 dc21285_map.read = dc21285_read32;
178 dc21285_map.write = dc21285_write32; 178 dc21285_map.write = dc21285_write32;
179 dc21285_map.copy_to = dc21285_copy_to_32; 179 dc21285_map.copy_to = dc21285_copy_to_32;
@@ -201,20 +201,20 @@ static int __init init_dc21285(void)
201 if (!dc21285_mtd) { 201 if (!dc21285_mtd) {
202 iounmap(dc21285_map.virt); 202 iounmap(dc21285_map.virt);
203 return -ENXIO; 203 return -ENXIO;
204 } 204 }
205 205
206 dc21285_mtd->owner = THIS_MODULE; 206 dc21285_mtd->owner = THIS_MODULE;
207 207
208#ifdef CONFIG_MTD_PARTITIONS 208#ifdef CONFIG_MTD_PARTITIONS
209 nrparts = parse_mtd_partitions(dc21285_mtd, probes, &dc21285_parts, 0); 209 nrparts = parse_mtd_partitions(dc21285_mtd, probes, &dc21285_parts, 0);
210 if (nrparts > 0) 210 if (nrparts > 0)
211 add_mtd_partitions(dc21285_mtd, dc21285_parts, nrparts); 211 add_mtd_partitions(dc21285_mtd, dc21285_parts, nrparts);
212 else 212 else
213#endif 213#endif
214 add_mtd_device(dc21285_mtd); 214 add_mtd_device(dc21285_mtd);
215 215
216 if(machine_is_ebsa285()) { 216 if(machine_is_ebsa285()) {
217 /* 217 /*
218 * Flash timing is determined with bits 19-16 of the 218 * Flash timing is determined with bits 19-16 of the
219 * CSR_SA110_CNTL. The value is the number of wait cycles, or 219 * CSR_SA110_CNTL. The value is the number of wait cycles, or
220 * 0 for 16 cycles (the default). Cycles are 20 ns. 220 * 0 for 16 cycles (the default). Cycles are 20 ns.
@@ -227,7 +227,7 @@ static int __init init_dc21285(void)
227 /* tristate time */ 227 /* tristate time */
228 *CSR_SA110_CNTL = ((*CSR_SA110_CNTL & ~0x0f000000) | (7 << 24)); 228 *CSR_SA110_CNTL = ((*CSR_SA110_CNTL & ~0x0f000000) | (7 << 24));
229 } 229 }
230 230
231 return 0; 231 return 0;
232} 232}
233 233
diff --git a/drivers/mtd/maps/dilnetpc.c b/drivers/mtd/maps/dilnetpc.c
index f99519692cb7..b51c757817d8 100644
--- a/drivers/mtd/maps/dilnetpc.c
+++ b/drivers/mtd/maps/dilnetpc.c
@@ -14,7 +14,7 @@
14 * along with this program; if not, write to the Free Software 14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
16 * 16 *
17 * $Id: dilnetpc.c,v 1.17 2004/11/28 09:40:39 dwmw2 Exp $ 17 * $Id: dilnetpc.c,v 1.20 2005/11/07 11:14:26 gleixner Exp $
18 * 18 *
19 * The DIL/Net PC is a tiny embedded PC board made by SSV Embedded Systems 19 * The DIL/Net PC is a tiny embedded PC board made by SSV Embedded Systems
20 * featuring the AMD Elan SC410 processor. There are two variants of this 20 * featuring the AMD Elan SC410 processor. There are two variants of this
@@ -272,13 +272,13 @@ static struct map_info dnpc_map = {
272 272
273static struct mtd_partition partition_info[]= 273static struct mtd_partition partition_info[]=
274{ 274{
275 { 275 {
276 .name = "ADNP boot", 276 .name = "ADNP boot",
277 .offset = 0, 277 .offset = 0,
278 .size = 0xf0000, 278 .size = 0xf0000,
279 }, 279 },
280 { 280 {
281 .name = "ADNP system BIOS", 281 .name = "ADNP system BIOS",
282 .offset = MTDPART_OFS_NXTBLK, 282 .offset = MTDPART_OFS_NXTBLK,
283 .size = 0x10000, 283 .size = 0x10000,
284#ifdef DNPC_BIOS_BLOCKS_WRITEPROTECTED 284#ifdef DNPC_BIOS_BLOCKS_WRITEPROTECTED
@@ -291,7 +291,7 @@ static struct mtd_partition partition_info[]=
291 .size = 0x2f0000, 291 .size = 0x2f0000,
292 }, 292 },
293 { 293 {
294 .name = "ADNP system BIOS entry", 294 .name = "ADNP system BIOS entry",
295 .offset = MTDPART_OFS_NXTBLK, 295 .offset = MTDPART_OFS_NXTBLK,
296 .size = MTDPART_SIZ_FULL, 296 .size = MTDPART_SIZ_FULL,
297#ifdef DNPC_BIOS_BLOCKS_WRITEPROTECTED 297#ifdef DNPC_BIOS_BLOCKS_WRITEPROTECTED
@@ -325,9 +325,9 @@ static struct mtd_info *merged_mtd;
325 325
326static struct mtd_partition higlvl_partition_info[]= 326static struct mtd_partition higlvl_partition_info[]=
327{ 327{
328 { 328 {
329 .name = "ADNP boot block", 329 .name = "ADNP boot block",
330 .offset = 0, 330 .offset = 0,
331 .size = CONFIG_MTD_DILNETPC_BOOTSIZE, 331 .size = CONFIG_MTD_DILNETPC_BOOTSIZE,
332 }, 332 },
333 { 333 {
@@ -335,8 +335,8 @@ static struct mtd_partition higlvl_partition_info[]=
335 .offset = MTDPART_OFS_NXTBLK, 335 .offset = MTDPART_OFS_NXTBLK,
336 .size = ADNP_WINDOW_SIZE-CONFIG_MTD_DILNETPC_BOOTSIZE-0x20000, 336 .size = ADNP_WINDOW_SIZE-CONFIG_MTD_DILNETPC_BOOTSIZE-0x20000,
337 }, 337 },
338 { 338 {
339 .name = "ADNP system BIOS + BIOS Entry", 339 .name = "ADNP system BIOS + BIOS Entry",
340 .offset = MTDPART_OFS_NXTBLK, 340 .offset = MTDPART_OFS_NXTBLK,
341 .size = MTDPART_SIZ_FULL, 341 .size = MTDPART_SIZ_FULL,
342#ifdef DNPC_BIOS_BLOCKS_WRITEPROTECTED 342#ifdef DNPC_BIOS_BLOCKS_WRITEPROTECTED
@@ -371,7 +371,7 @@ static int __init init_dnpc(void)
371 371
372 /* 372 /*
373 ** determine hardware (DNP/ADNP/invalid) 373 ** determine hardware (DNP/ADNP/invalid)
374 */ 374 */
375 if((is_dnp = dnp_adnp_probe()) < 0) 375 if((is_dnp = dnp_adnp_probe()) < 0)
376 return -ENXIO; 376 return -ENXIO;
377 377
@@ -397,13 +397,13 @@ static int __init init_dnpc(void)
397 ++dnpc_map.name; 397 ++dnpc_map.name;
398 for(i = 0; i < NUM_PARTITIONS; i++) 398 for(i = 0; i < NUM_PARTITIONS; i++)
399 ++partition_info[i].name; 399 ++partition_info[i].name;
400 higlvl_partition_info[1].size = DNP_WINDOW_SIZE - 400 higlvl_partition_info[1].size = DNP_WINDOW_SIZE -
401 CONFIG_MTD_DILNETPC_BOOTSIZE - 0x20000; 401 CONFIG_MTD_DILNETPC_BOOTSIZE - 0x20000;
402 for(i = 0; i < NUM_HIGHLVL_PARTITIONS; i++) 402 for(i = 0; i < NUM_HIGHLVL_PARTITIONS; i++)
403 ++higlvl_partition_info[i].name; 403 ++higlvl_partition_info[i].name;
404 } 404 }
405 405
406 printk(KERN_NOTICE "DIL/Net %s flash: 0x%lx at 0x%lx\n", 406 printk(KERN_NOTICE "DIL/Net %s flash: 0x%lx at 0x%lx\n",
407 is_dnp ? "DNPC" : "ADNP", dnpc_map.size, dnpc_map.phys); 407 is_dnp ? "DNPC" : "ADNP", dnpc_map.size, dnpc_map.phys);
408 408
409 dnpc_map.virt = ioremap_nocache(dnpc_map.phys, dnpc_map.size); 409 dnpc_map.virt = ioremap_nocache(dnpc_map.phys, dnpc_map.size);
@@ -436,7 +436,7 @@ static int __init init_dnpc(void)
436 iounmap(dnpc_map.virt); 436 iounmap(dnpc_map.virt);
437 return -ENXIO; 437 return -ENXIO;
438 } 438 }
439 439
440 mymtd->owner = THIS_MODULE; 440 mymtd->owner = THIS_MODULE;
441 441
442 /* 442 /*
diff --git a/drivers/mtd/maps/dmv182.c b/drivers/mtd/maps/dmv182.c
index b9bc63503e26..b993ac01a9a5 100644
--- a/drivers/mtd/maps/dmv182.c
+++ b/drivers/mtd/maps/dmv182.c
@@ -1,10 +1,10 @@
1 1
2/* 2/*
3 * drivers/mtd/maps/svme182.c 3 * drivers/mtd/maps/svme182.c
4 * 4 *
5 * Flash map driver for the Dy4 SVME182 board 5 * Flash map driver for the Dy4 SVME182 board
6 * 6 *
7 * $Id: dmv182.c,v 1.5 2004/11/04 13:24:14 gleixner Exp $ 7 * $Id: dmv182.c,v 1.6 2005/11/07 11:14:26 gleixner Exp $
8 * 8 *
9 * Copyright 2003-2004, TimeSys Corporation 9 * Copyright 2003-2004, TimeSys Corporation
10 * 10 *
@@ -104,7 +104,7 @@ static int __init init_svme182(void)
104 partitions = svme182_partitions; 104 partitions = svme182_partitions;
105 105
106 svme182_map.virt = ioremap(FLASH_BASE_ADDR, svme182_map.size); 106 svme182_map.virt = ioremap(FLASH_BASE_ADDR, svme182_map.size);
107 107
108 if (svme182_map.virt == 0) { 108 if (svme182_map.virt == 0) {
109 printk("Failed to ioremap FLASH memory area.\n"); 109 printk("Failed to ioremap FLASH memory area.\n");
110 return -EIO; 110 return -EIO;
diff --git a/drivers/mtd/maps/ebony.c b/drivers/mtd/maps/ebony.c
index b9d9cf4854b6..c0daf58357ca 100644
--- a/drivers/mtd/maps/ebony.c
+++ b/drivers/mtd/maps/ebony.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * $Id: ebony.c,v 1.15 2004/12/09 18:39:54 holindho Exp $ 2 * $Id: ebony.c,v 1.16 2005/11/07 11:14:26 gleixner Exp $
3 * 3 *
4 * Mapping for Ebony user flash 4 * Mapping for Ebony user flash
5 * 5 *
6 * Matt Porter <mporter@kernel.crashing.org> 6 * Matt Porter <mporter@kernel.crashing.org>
@@ -85,7 +85,7 @@ int __init init_ebony(void)
85 small_flash_base = EBONY_SMALL_FLASH_LOW2; 85 small_flash_base = EBONY_SMALL_FLASH_LOW2;
86 else 86 else
87 small_flash_base = EBONY_SMALL_FLASH_LOW1; 87 small_flash_base = EBONY_SMALL_FLASH_LOW1;
88 88
89 if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) && 89 if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
90 !EBONY_ONBRD_FLASH_EN(fpga0_reg)) 90 !EBONY_ONBRD_FLASH_EN(fpga0_reg))
91 large_flash_base = EBONY_LARGE_FLASH_LOW; 91 large_flash_base = EBONY_LARGE_FLASH_LOW;
diff --git a/drivers/mtd/maps/edb7312.c b/drivers/mtd/maps/edb7312.c
index 8b0da394f3fa..b48a3473ffc1 100644
--- a/drivers/mtd/maps/edb7312.c
+++ b/drivers/mtd/maps/edb7312.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * $Id: edb7312.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $ 2 * $Id: edb7312.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * Handle mapping of the NOR flash on Cogent EDB7312 boards 4 * Handle mapping of the NOR flash on Cogent EDB7312 boards
5 * 5 *
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH 6 * Copyright 2002 SYSGO Real-Time Solutions GmbH
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
@@ -46,7 +46,7 @@ struct map_info edb7312nor_map = {
46#ifdef CONFIG_MTD_PARTITIONS 46#ifdef CONFIG_MTD_PARTITIONS
47 47
48/* 48/*
49 * MTD partitioning stuff 49 * MTD partitioning stuff
50 */ 50 */
51static struct mtd_partition static_partitions[3] = 51static struct mtd_partition static_partitions[3] =
52{ 52{
@@ -80,7 +80,7 @@ int __init init_edb7312nor(void)
80 const char **type; 80 const char **type;
81 const char *part_type = 0; 81 const char *part_type = 0;
82 82
83 printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n", 83 printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n",
84 WINDOW_SIZE, WINDOW_ADDR); 84 WINDOW_SIZE, WINDOW_ADDR);
85 edb7312nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); 85 edb7312nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
86 86
@@ -88,7 +88,7 @@ int __init init_edb7312nor(void)
88 printk(MSG_PREFIX "failed to ioremap\n"); 88 printk(MSG_PREFIX "failed to ioremap\n");
89 return -EIO; 89 return -EIO;
90 } 90 }
91 91
92 simple_map_init(&edb7312nor_map); 92 simple_map_init(&edb7312nor_map);
93 93
94 mymtd = 0; 94 mymtd = 0;
diff --git a/drivers/mtd/maps/epxa10db-flash.c b/drivers/mtd/maps/epxa10db-flash.c
index 1df6188926b3..265b079fe934 100644
--- a/drivers/mtd/maps/epxa10db-flash.c
+++ b/drivers/mtd/maps/epxa10db-flash.c
@@ -5,7 +5,7 @@
5 * Copyright (C) 2001 Altera Corporation 5 * Copyright (C) 2001 Altera Corporation
6 * Copyright (C) 2001 Red Hat, Inc. 6 * Copyright (C) 2001 Red Hat, Inc.
7 * 7 *
8 * $Id: epxa10db-flash.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $ 8 * $Id: epxa10db-flash.c,v 1.15 2005/11/07 11:14:27 gleixner Exp $
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -62,7 +62,7 @@ static const char *probes[] = { "RedBoot", "afs", NULL };
62static int __init epxa_mtd_init(void) 62static int __init epxa_mtd_init(void)
63{ 63{
64 int i; 64 int i;
65 65
66 printk(KERN_NOTICE "%s flash device: 0x%x at 0x%x\n", BOARD_NAME, FLASH_SIZE, FLASH_START); 66 printk(KERN_NOTICE "%s flash device: 0x%x at 0x%x\n", BOARD_NAME, FLASH_SIZE, FLASH_START);
67 67
68 epxa_map.virt = ioremap(FLASH_START, FLASH_SIZE); 68 epxa_map.virt = ioremap(FLASH_START, FLASH_SIZE);
@@ -126,8 +126,8 @@ static void __exit epxa_mtd_cleanup(void)
126} 126}
127 127
128 128
129/* 129/*
130 * This will do for now, once we decide which bootldr we're finally 130 * This will do for now, once we decide which bootldr we're finally
131 * going to use then we'll remove this function and do it properly 131 * going to use then we'll remove this function and do it properly
132 * 132 *
133 * Partions are currently (as offsets from base of flash): 133 * Partions are currently (as offsets from base of flash):
@@ -140,7 +140,7 @@ static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_pa
140 struct mtd_partition *parts; 140 struct mtd_partition *parts;
141 int ret, i; 141 int ret, i;
142 int npartitions = 0; 142 int npartitions = 0;
143 char *names; 143 char *names;
144 const char *name = "jffs"; 144 const char *name = "jffs";
145 145
146 printk("Using default partitions for %s\n",BOARD_NAME); 146 printk("Using default partitions for %s\n",BOARD_NAME);
@@ -152,7 +152,7 @@ static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_pa
152 goto out; 152 goto out;
153 } 153 }
154 i=0; 154 i=0;
155 names = (char *)&parts[npartitions]; 155 names = (char *)&parts[npartitions];
156 parts[i].name = names; 156 parts[i].name = names;
157 names += strlen(name) + 1; 157 names += strlen(name) + 1;
158 strcpy(parts[i].name, name); 158 strcpy(parts[i].name, name);
diff --git a/drivers/mtd/maps/fortunet.c b/drivers/mtd/maps/fortunet.c
index 00f7bbe5479e..c6bf4e1219ef 100644
--- a/drivers/mtd/maps/fortunet.c
+++ b/drivers/mtd/maps/fortunet.c
@@ -1,6 +1,6 @@
1/* fortunet.c memory map 1/* fortunet.c memory map
2 * 2 *
3 * $Id: fortunet.c,v 1.9 2004/11/04 13:24:14 gleixner Exp $ 3 * $Id: fortunet.c,v 1.11 2005/11/07 11:14:27 gleixner Exp $
4 */ 4 */
5 5
6#include <linux/module.h> 6#include <linux/module.h>
@@ -212,7 +212,7 @@ int __init init_fortunet(void)
212 212
213 map_regions[ix].map_info.phys = map_regions[ix].window_addr_physical, 213 map_regions[ix].map_info.phys = map_regions[ix].window_addr_physical,
214 214
215 map_regions[ix].map_info.virt = 215 map_regions[ix].map_info.virt =
216 ioremap_nocache( 216 ioremap_nocache(
217 map_regions[ix].window_addr_physical, 217 map_regions[ix].window_addr_physical,
218 map_regions[ix].map_info.size); 218 map_regions[ix].map_info.size);
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c
index c73828171d9b..319094821101 100644
--- a/drivers/mtd/maps/h720x-flash.c
+++ b/drivers/mtd/maps/h720x-flash.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * Flash memory access on Hynix GMS30C7201/HMS30C7202 based 2 * Flash memory access on Hynix GMS30C7201/HMS30C7202 based
3 * evaluation boards 3 * evaluation boards
4 * 4 *
5 * $Id: h720x-flash.c,v 1.11 2004/11/04 13:24:14 gleixner Exp $ 5 * $Id: h720x-flash.c,v 1.12 2005/11/07 11:14:27 gleixner Exp $
6 * 6 *
7 * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com> 7 * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com>
8 * 2003 Thomas Gleixner <tglx@linutronix.de> 8 * 2003 Thomas Gleixner <tglx@linutronix.de>
9 */ 9 */
10 10
11#include <linux/config.h> 11#include <linux/config.h>
@@ -72,7 +72,7 @@ int __init h720x_mtd_init(void)
72{ 72{
73 73
74 char *part_type = NULL; 74 char *part_type = NULL;
75 75
76 h720x_map.virt = ioremap(FLASH_PHYS, FLASH_SIZE); 76 h720x_map.virt = ioremap(FLASH_PHYS, FLASH_SIZE);
77 77
78 if (!h720x_map.virt) { 78 if (!h720x_map.virt) {
@@ -91,7 +91,7 @@ int __init h720x_mtd_init(void)
91 h720x_map.bankwidth = 2; 91 h720x_map.bankwidth = 2;
92 mymtd = do_map_probe("cfi_probe", &h720x_map); 92 mymtd = do_map_probe("cfi_probe", &h720x_map);
93 } 93 }
94 94
95 if (mymtd) { 95 if (mymtd) {
96 mymtd->owner = THIS_MODULE; 96 mymtd->owner = THIS_MODULE;
97 97
@@ -124,11 +124,11 @@ static void __exit h720x_mtd_cleanup(void)
124 del_mtd_partitions(mymtd); 124 del_mtd_partitions(mymtd);
125 map_destroy(mymtd); 125 map_destroy(mymtd);
126 } 126 }
127 127
128 /* Free partition info, if commandline partition was used */ 128 /* Free partition info, if commandline partition was used */
129 if (mtd_parts && (mtd_parts != h720x_partitions)) 129 if (mtd_parts && (mtd_parts != h720x_partitions))
130 kfree (mtd_parts); 130 kfree (mtd_parts);
131 131
132 if (h720x_map.virt) { 132 if (h720x_map.virt) {
133 iounmap((void *)h720x_map.virt); 133 iounmap((void *)h720x_map.virt);
134 h720x_map.virt = 0; 134 h720x_map.virt = 0;
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
index e505207cd489..ea5073781b3a 100644
--- a/drivers/mtd/maps/ichxrom.c
+++ b/drivers/mtd/maps/ichxrom.c
@@ -2,7 +2,7 @@
2 * ichxrom.c 2 * ichxrom.c
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * $Id: ichxrom.c,v 1.18 2005/07/07 10:26:20 dwmw2 Exp $ 5 * $Id: ichxrom.c,v 1.19 2005/11/07 11:14:27 gleixner Exp $
6 */ 6 */
7 7
8#include <linux/module.h> 8#include <linux/module.h>
@@ -101,7 +101,7 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
101 * you can only really attach a FWH to an ICHX there 101 * you can only really attach a FWH to an ICHX there
102 * a number of simplifications you can make. 102 * a number of simplifications you can make.
103 * 103 *
104 * Also you can page firmware hubs if an 8MB window isn't enough 104 * Also you can page firmware hubs if an 8MB window isn't enough
105 * but don't currently handle that case either. 105 * but don't currently handle that case either.
106 */ 106 */
107 window->pdev = pdev; 107 window->pdev = pdev;
@@ -144,7 +144,7 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
144 window->phys = 0xfff00000; 144 window->phys = 0xfff00000;
145 } 145 }
146 else if ((byte & 0x80) == 0x80) { 146 else if ((byte & 0x80) == 0x80) {
147 window->phys = 0xfff80000; 147 window->phys = 0xfff80000;
148 } 148 }
149 149
150 if (window->phys == 0) { 150 if (window->phys == 0) {
@@ -233,7 +233,7 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
233 * in a factory setting. So in-place programming 233 * in a factory setting. So in-place programming
234 * needs to use a different method. 234 * needs to use a different method.
235 */ 235 */
236 for(map->map.bankwidth = 32; map->map.bankwidth; 236 for(map->map.bankwidth = 32; map->map.bankwidth;
237 map->map.bankwidth >>= 1) 237 map->map.bankwidth >>= 1)
238 { 238 {
239 char **probe_type; 239 char **probe_type;
@@ -286,7 +286,7 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
286 for(i = 0; i < cfi->numchips; i++) { 286 for(i = 0; i < cfi->numchips; i++) {
287 cfi->chips[i].start += offset; 287 cfi->chips[i].start += offset;
288 } 288 }
289 289
290 /* Now that the mtd devices is complete claim and export it */ 290 /* Now that the mtd devices is complete claim and export it */
291 map->mtd->owner = THIS_MODULE; 291 map->mtd->owner = THIS_MODULE;
292 if (add_mtd_device(map->mtd)) { 292 if (add_mtd_device(map->mtd)) {
@@ -306,9 +306,8 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
306 306
307 out: 307 out:
308 /* Free any left over map structures */ 308 /* Free any left over map structures */
309 if (map) { 309 kfree(map);
310 kfree(map); 310
311 }
312 /* See if I have any map structures */ 311 /* See if I have any map structures */
313 if (list_empty(&window->maps)) { 312 if (list_empty(&window->maps)) {
314 ichxrom_cleanup(window); 313 ichxrom_cleanup(window);
@@ -325,11 +324,11 @@ static void __devexit ichxrom_remove_one (struct pci_dev *pdev)
325} 324}
326 325
327static struct pci_device_id ichxrom_pci_tbl[] __devinitdata = { 326static struct pci_device_id ichxrom_pci_tbl[] __devinitdata = {
328 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, 327 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0,
329 PCI_ANY_ID, PCI_ANY_ID, }, 328 PCI_ANY_ID, PCI_ANY_ID, },
330 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, 329 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0,
331 PCI_ANY_ID, PCI_ANY_ID, }, 330 PCI_ANY_ID, PCI_ANY_ID, },
332 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, 331 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,
333 PCI_ANY_ID, PCI_ANY_ID, }, 332 PCI_ANY_ID, PCI_ANY_ID, },
334 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, 333 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0,
335 PCI_ANY_ID, PCI_ANY_ID, }, 334 PCI_ANY_ID, PCI_ANY_ID, },
diff --git a/drivers/mtd/maps/impa7.c b/drivers/mtd/maps/impa7.c
index cb39172c81d2..ba7f40311a7e 100644
--- a/drivers/mtd/maps/impa7.c
+++ b/drivers/mtd/maps/impa7.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * $Id: impa7.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $ 2 * $Id: impa7.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * Handle mapping of the NOR flash on implementa A7 boards 4 * Handle mapping of the NOR flash on implementa A7 boards
5 * 5 *
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH 6 * Copyright 2002 SYSGO Real-Time Solutions GmbH
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
@@ -55,7 +55,7 @@ static struct map_info impa7_map[NUM_FLASHBANKS] = {
55#ifdef CONFIG_MTD_PARTITIONS 55#ifdef CONFIG_MTD_PARTITIONS
56 56
57/* 57/*
58 * MTD partitioning stuff 58 * MTD partitioning stuff
59 */ 59 */
60static struct mtd_partition static_partitions[] = 60static struct mtd_partition static_partitions[] =
61{ 61{
@@ -108,9 +108,9 @@ int __init init_impa7(void)
108 impa7_mtd[i]->owner = THIS_MODULE; 108 impa7_mtd[i]->owner = THIS_MODULE;
109 devicesfound++; 109 devicesfound++;
110#ifdef CONFIG_MTD_PARTITIONS 110#ifdef CONFIG_MTD_PARTITIONS
111 mtd_parts_nb[i] = parse_mtd_partitions(impa7_mtd[i], 111 mtd_parts_nb[i] = parse_mtd_partitions(impa7_mtd[i],
112 probes, 112 probes,
113 &mtd_parts[i], 113 &mtd_parts[i],
114 0); 114 0);
115 if (mtd_parts_nb[i] > 0) { 115 if (mtd_parts_nb[i] > 0) {
116 part_type = "command line"; 116 part_type = "command line";
@@ -121,16 +121,16 @@ int __init init_impa7(void)
121 } 121 }
122 122
123 printk(KERN_NOTICE MSG_PREFIX 123 printk(KERN_NOTICE MSG_PREFIX
124 "using %s partition definition\n", 124 "using %s partition definition\n",
125 part_type); 125 part_type);
126 add_mtd_partitions(impa7_mtd[i], 126 add_mtd_partitions(impa7_mtd[i],
127 mtd_parts[i], mtd_parts_nb[i]); 127 mtd_parts[i], mtd_parts_nb[i]);
128#else 128#else
129 add_mtd_device(impa7_mtd[i]); 129 add_mtd_device(impa7_mtd[i]);
130 130
131#endif 131#endif
132 } 132 }
133 else 133 else
134 iounmap((void *)impa7_map[i].virt); 134 iounmap((void *)impa7_map[i].virt);
135 } 135 }
136 return devicesfound == 0 ? -ENXIO : 0; 136 return devicesfound == 0 ? -ENXIO : 0;
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
index d14a0185b8f4..fe738fd8d6f8 100644
--- a/drivers/mtd/maps/integrator-flash.c
+++ b/drivers/mtd/maps/integrator-flash.c
@@ -1,28 +1,28 @@
1/*====================================================================== 1/*======================================================================
2 2
3 drivers/mtd/maps/integrator-flash.c: ARM Integrator flash map driver 3 drivers/mtd/maps/integrator-flash.c: ARM Integrator flash map driver
4 4
5 Copyright (C) 2000 ARM Limited 5 Copyright (C) 2000 ARM Limited
6 Copyright (C) 2003 Deep Blue Solutions Ltd. 6 Copyright (C) 2003 Deep Blue Solutions Ltd.
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 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 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 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 21
22 This is access code for flashes using ARM's flash partitioning 22 This is access code for flashes using ARM's flash partitioning
23 standards. 23 standards.
24 24
25 $Id: integrator-flash.c,v 1.18 2004/11/01 13:26:15 rmk Exp $ 25 $Id: integrator-flash.c,v 1.20 2005/11/07 11:14:27 gleixner Exp $
26 26
27======================================================================*/ 27======================================================================*/
28 28
@@ -148,8 +148,7 @@ static int armflash_probe(struct device *_dev)
148 del_mtd_partitions(info->mtd); 148 del_mtd_partitions(info->mtd);
149 map_destroy(info->mtd); 149 map_destroy(info->mtd);
150 } 150 }
151 if (info->parts) 151 kfree(info->parts);
152 kfree(info->parts);
153 152
154 no_device: 153 no_device:
155 iounmap(base); 154 iounmap(base);
@@ -176,8 +175,7 @@ static int armflash_remove(struct device *_dev)
176 del_mtd_partitions(info->mtd); 175 del_mtd_partitions(info->mtd);
177 map_destroy(info->mtd); 176 map_destroy(info->mtd);
178 } 177 }
179 if (info->parts) 178 kfree(info->parts);
180 kfree(info->parts);
181 179
182 iounmap(info->map.virt); 180 iounmap(info->map.virt);
183 release_resource(info->res); 181 release_resource(info->res);
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
index 712401810841..35097c9bbf50 100644
--- a/drivers/mtd/maps/ipaq-flash.c
+++ b/drivers/mtd/maps/ipaq-flash.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * Flash memory access on iPAQ Handhelds (either SA1100 or PXA250 based) 2 * Flash memory access on iPAQ Handhelds (either SA1100 or PXA250 based)
3 * 3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 * (C) 2002 Hewlett-Packard Company <jamey.hicks@hp.com> 5 * (C) 2002 Hewlett-Packard Company <jamey.hicks@hp.com>
6 * (C) 2003 Christian Pellegrin <chri@ascensit.com>, <chri@infis.univ.ts.it>: concatenation of multiple flashes 6 * (C) 2003 Christian Pellegrin <chri@ascensit.com>, <chri@infis.univ.ts.it>: concatenation of multiple flashes
7 * 7 *
8 * $Id: ipaq-flash.c,v 1.3 2004/11/04 13:24:15 gleixner Exp $ 8 * $Id: ipaq-flash.c,v 1.5 2005/11/07 11:14:27 gleixner Exp $
9 */ 9 */
10 10
11#include <linux/config.h> 11#include <linux/config.h>
@@ -107,7 +107,7 @@ static struct mtd_partition h3xxx_partitions[] = {
107#ifndef CONFIG_LAB 107#ifndef CONFIG_LAB
108 mask_flags: MTD_WRITEABLE, /* force read-only */ 108 mask_flags: MTD_WRITEABLE, /* force read-only */
109#endif 109#endif
110 }, 110 },
111 { 111 {
112 name: "H3XXX root jffs2", 112 name: "H3XXX root jffs2",
113#ifndef CONFIG_LAB 113#ifndef CONFIG_LAB
@@ -148,7 +148,7 @@ static DEFINE_SPINLOCK(ipaq_vpp_lock);
148static void h3xxx_set_vpp(struct map_info *map, int vpp) 148static void h3xxx_set_vpp(struct map_info *map, int vpp)
149{ 149{
150 static int nest = 0; 150 static int nest = 0;
151 151
152 spin_lock(&ipaq_vpp_lock); 152 spin_lock(&ipaq_vpp_lock);
153 if (vpp) 153 if (vpp)
154 nest++; 154 nest++;
@@ -191,7 +191,7 @@ static unsigned long cs_phys[] = {
191 SA1100_CS3_PHYS, 191 SA1100_CS3_PHYS,
192 SA1100_CS4_PHYS, 192 SA1100_CS4_PHYS,
193 SA1100_CS5_PHYS, 193 SA1100_CS5_PHYS,
194#else 194#else
195 PXA_CS0_PHYS, 195 PXA_CS0_PHYS,
196 PXA_CS1_PHYS, 196 PXA_CS1_PHYS,
197 PXA_CS2_PHYS, 197 PXA_CS2_PHYS,
@@ -216,7 +216,7 @@ int __init ipaq_mtd_init(void)
216 216
217 /* Default flash bankwidth */ 217 /* Default flash bankwidth */
218 // ipaq_map.bankwidth = (MSC0 & MSC_RBW) ? 2 : 4; 218 // ipaq_map.bankwidth = (MSC0 & MSC_RBW) ? 2 : 4;
219 219
220 if (machine_is_h1900()) 220 if (machine_is_h1900())
221 { 221 {
222 /* For our intents, the h1900 is not a real iPAQ, so we special-case it. */ 222 /* For our intents, the h1900 is not a real iPAQ, so we special-case it. */
@@ -229,7 +229,7 @@ int __init ipaq_mtd_init(void)
229 else 229 else
230 for(i=0; i<MAX_IPAQ_CS; i++) 230 for(i=0; i<MAX_IPAQ_CS; i++)
231 ipaq_map[i].bankwidth = 4; 231 ipaq_map[i].bankwidth = 4;
232 232
233 /* 233 /*
234 * Static partition definition selection 234 * Static partition definition selection
235 */ 235 */
@@ -309,7 +309,7 @@ int __init ipaq_mtd_init(void)
309 return -ENXIO; 309 return -ENXIO;
310 } else 310 } else
311 printk(KERN_NOTICE "iPAQ flash: found %d bytes\n", my_sub_mtd[i]->size); 311 printk(KERN_NOTICE "iPAQ flash: found %d bytes\n", my_sub_mtd[i]->size);
312 312
313 /* do we really need this debugging? --joshua 20030703 */ 313 /* do we really need this debugging? --joshua 20030703 */
314 // printk("my_sub_mtd[%d]=%p\n", i, my_sub_mtd[i]); 314 // printk("my_sub_mtd[%d]=%p\n", i, my_sub_mtd[i]);
315 my_sub_mtd[i]->owner = THIS_MODULE; 315 my_sub_mtd[i]->owner = THIS_MODULE;
@@ -333,11 +333,11 @@ int __init ipaq_mtd_init(void)
333#else 333#else
334 mymtd = my_sub_mtd[0]; 334 mymtd = my_sub_mtd[0];
335 335
336 /* 336 /*
337 *In the very near future, command line partition parsing 337 *In the very near future, command line partition parsing
338 * will use the device name as 'mtd-id' instead of a value 338 * will use the device name as 'mtd-id' instead of a value
339 * passed to the parse_cmdline_partitions() routine. Since 339 * passed to the parse_cmdline_partitions() routine. Since
340 * the bootldr says 'ipaq', make sure it continues to work. 340 * the bootldr says 'ipaq', make sure it continues to work.
341 */ 341 */
342 mymtd->name = "ipaq"; 342 mymtd->name = "ipaq";
343 343
@@ -385,7 +385,7 @@ int __init ipaq_mtd_init(void)
385 */ 385 */
386 386
387 i = parse_mtd_partitions(mymtd, part_probes, &parsed_parts, 0); 387 i = parse_mtd_partitions(mymtd, part_probes, &parsed_parts, 0);
388 388
389 if (i > 0) { 389 if (i > 0) {
390 nb_parts = parsed_nr_parts = i; 390 nb_parts = parsed_nr_parts = i;
391 parts = parsed_parts; 391 parts = parsed_parts;
@@ -423,16 +423,15 @@ static void __exit ipaq_mtd_cleanup(void)
423#endif 423#endif
424 map_destroy(mymtd); 424 map_destroy(mymtd);
425#ifdef CONFIG_MTD_CONCAT 425#ifdef CONFIG_MTD_CONCAT
426 for(i=0; i<MAX_IPAQ_CS; i++) 426 for(i=0; i<MAX_IPAQ_CS; i++)
427#else 427#else
428 for(i=1; i<MAX_IPAQ_CS; i++) 428 for(i=1; i<MAX_IPAQ_CS; i++)
429#endif 429#endif
430 { 430 {
431 if (my_sub_mtd[i]) 431 if (my_sub_mtd[i])
432 map_destroy(my_sub_mtd[i]); 432 map_destroy(my_sub_mtd[i]);
433 } 433 }
434 if (parsed_parts) 434 kfree(parsed_parts);
435 kfree(parsed_parts);
436 } 435 }
437} 436}
438 437
@@ -445,14 +444,14 @@ static int __init h1900_special_case(void)
445 ipaq_map[0].phys = 0x0; 444 ipaq_map[0].phys = 0x0;
446 ipaq_map[0].virt = __ioremap(0x0, 0x04000000, 0, 1); 445 ipaq_map[0].virt = __ioremap(0x0, 0x04000000, 0, 1);
447 ipaq_map[0].bankwidth = 2; 446 ipaq_map[0].bankwidth = 2;
448 447
449 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);
450 mymtd = do_map_probe("jedec_probe", &ipaq_map[0]); 449 mymtd = do_map_probe("jedec_probe", &ipaq_map[0]);
451 if (!mymtd) 450 if (!mymtd)
452 return -ENODEV; 451 return -ENODEV;
453 add_mtd_device(mymtd); 452 add_mtd_device(mymtd);
454 printk(KERN_NOTICE "iPAQ flash: registered h1910 flash\n"); 453 printk(KERN_NOTICE "iPAQ flash: registered h1910 flash\n");
455 454
456 return 0; 455 return 0;
457} 456}
458 457
diff --git a/drivers/mtd/maps/iq80310.c b/drivers/mtd/maps/iq80310.c
index 558d014e7acc..62d9e87d84e2 100644
--- a/drivers/mtd/maps/iq80310.c
+++ b/drivers/mtd/maps/iq80310.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * $Id: iq80310.c,v 1.20 2004/11/04 13:24:15 gleixner Exp $ 2 * $Id: iq80310.c,v 1.21 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * Mapping for the Intel XScale IQ80310 evaluation board 4 * Mapping for the Intel XScale IQ80310 evaluation board
5 * 5 *
6 * Author: Nicolas Pitre 6 * Author: Nicolas Pitre
7 * Copyright: (C) 2001 MontaVista Software Inc. 7 * Copyright: (C) 2001 MontaVista Software Inc.
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 version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
@@ -103,8 +103,7 @@ static void __exit cleanup_iq80310(void)
103 if (mymtd) { 103 if (mymtd) {
104 del_mtd_partitions(mymtd); 104 del_mtd_partitions(mymtd);
105 map_destroy(mymtd); 105 map_destroy(mymtd);
106 if (parsed_parts) 106 kfree(parsed_parts);
107 kfree(parsed_parts);
108 } 107 }
109 if (iq80310_map.virt) 108 if (iq80310_map.virt)
110 iounmap((void *)iq80310_map.virt); 109 iounmap((void *)iq80310_map.virt);
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index 00b9f67580f1..641eb2b55e9f 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ixp2000.c,v 1.6 2005/03/18 14:07:46 gleixner Exp $ 2 * $Id: ixp2000.c,v 1.9 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * drivers/mtd/maps/ixp2000.c 4 * drivers/mtd/maps/ixp2000.c
5 * 5 *
@@ -14,7 +14,7 @@
14 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as 15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation. 16 * published by the Free Software Foundation.
17 * 17 *
18 */ 18 */
19 19
20#include <linux/module.h> 20#include <linux/module.h>
@@ -46,8 +46,8 @@ struct ixp2000_flash_info {
46}; 46};
47 47
48static inline unsigned long flash_bank_setup(struct map_info *map, unsigned long ofs) 48static inline unsigned long flash_bank_setup(struct map_info *map, unsigned long ofs)
49{ 49{
50 unsigned long (*set_bank)(unsigned long) = 50 unsigned long (*set_bank)(unsigned long) =
51 (unsigned long(*)(unsigned long))map->map_priv_2; 51 (unsigned long(*)(unsigned long))map->map_priv_2;
52 52
53 return (set_bank ? set_bank(ofs) : ofs); 53 return (set_bank ? set_bank(ofs) : ofs);
@@ -55,8 +55,8 @@ static inline unsigned long flash_bank_setup(struct map_info *map, unsigned long
55 55
56#ifdef __ARMEB__ 56#ifdef __ARMEB__
57/* 57/*
58 * Rev A0 and A1 of IXP2400 silicon have a broken addressing unit which 58 * Rev A0 and A1 of IXP2400 silicon have a broken addressing unit which
59 * causes the lower address bits to be XORed with 0x11 on 8 bit accesses 59 * causes the lower address bits to be XORed with 0x11 on 8 bit accesses
60 * and XORed with 0x10 on 16 bit accesses. See the spec update, erratum 44. 60 * and XORed with 0x10 on 16 bit accesses. See the spec update, erratum 44.
61 */ 61 */
62static int erratum44_workaround = 0; 62static int erratum44_workaround = 0;
@@ -90,7 +90,7 @@ static void ixp2000_flash_copy_from(struct map_info *map, void *to,
90 unsigned long from, ssize_t len) 90 unsigned long from, ssize_t len)
91{ 91{
92 from = flash_bank_setup(map, from); 92 from = flash_bank_setup(map, from);
93 while(len--) 93 while(len--)
94 *(__u8 *) to++ = *(__u8 *)(map->map_priv_1 + from++); 94 *(__u8 *) to++ = *(__u8 *)(map->map_priv_1 + from++);
95} 95}
96 96
@@ -129,8 +129,7 @@ static int ixp2000_flash_remove(struct device *_dev)
129 if (info->map.map_priv_1) 129 if (info->map.map_priv_1)
130 iounmap((void *) info->map.map_priv_1); 130 iounmap((void *) info->map.map_priv_1);
131 131
132 if (info->partitions) { 132 kfree(info->partitions);
133 kfree(info->partitions); }
134 133
135 if (info->res) { 134 if (info->res) {
136 release_resource(info->res); 135 release_resource(info->res);
@@ -149,11 +148,11 @@ static int ixp2000_flash_probe(struct device *_dev)
149 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 148 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
150 struct platform_device *dev = to_platform_device(_dev); 149 struct platform_device *dev = to_platform_device(_dev);
151 struct ixp2000_flash_data *ixp_data = dev->dev.platform_data; 150 struct ixp2000_flash_data *ixp_data = dev->dev.platform_data;
152 struct flash_platform_data *plat; 151 struct flash_platform_data *plat;
153 struct ixp2000_flash_info *info; 152 struct ixp2000_flash_info *info;
154 unsigned long window_size; 153 unsigned long window_size;
155 int err = -1; 154 int err = -1;
156 155
157 if (!ixp_data) 156 if (!ixp_data)
158 return -ENODEV; 157 return -ENODEV;
159 158
@@ -162,7 +161,7 @@ static int ixp2000_flash_probe(struct device *_dev)
162 return -ENODEV; 161 return -ENODEV;
163 162
164 window_size = dev->resource->end - dev->resource->start + 1; 163 window_size = dev->resource->end - dev->resource->start + 1;
165 dev_info(_dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n", 164 dev_info(_dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n",
166 ixp_data->nr_banks, ((u32)window_size >> 20)); 165 ixp_data->nr_banks, ((u32)window_size >> 20));
167 166
168 if (plat->width != 1) { 167 if (plat->width != 1) {
@@ -175,7 +174,7 @@ static int ixp2000_flash_probe(struct device *_dev)
175 if(!info) { 174 if(!info) {
176 err = -ENOMEM; 175 err = -ENOMEM;
177 goto Error; 176 goto Error;
178 } 177 }
179 memzero(info, sizeof(struct ixp2000_flash_info)); 178 memzero(info, sizeof(struct ixp2000_flash_info));
180 179
181 dev_set_drvdata(&dev->dev, info); 180 dev_set_drvdata(&dev->dev, info);
@@ -185,7 +184,7 @@ static int ixp2000_flash_probe(struct device *_dev)
185 * not attempt to do a direct access on us. 184 * not attempt to do a direct access on us.
186 */ 185 */
187 info->map.phys = NO_XIP; 186 info->map.phys = NO_XIP;
188 187
189 info->nr_banks = ixp_data->nr_banks; 188 info->nr_banks = ixp_data->nr_banks;
190 info->map.size = ixp_data->nr_banks * window_size; 189 info->map.size = ixp_data->nr_banks * window_size;
191 info->map.bankwidth = 1; 190 info->map.bankwidth = 1;
@@ -193,7 +192,7 @@ static int ixp2000_flash_probe(struct device *_dev)
193 /* 192 /*
194 * map_priv_2 is used to store a ptr to to the bank_setup routine 193 * map_priv_2 is used to store a ptr to to the bank_setup routine
195 */ 194 */
196 info->map.map_priv_2 = (void __iomem *) ixp_data->bank_setup; 195 info->map.map_priv_2 = (unsigned long) ixp_data->bank_setup;
197 196
198 info->map.name = dev->dev.bus_id; 197 info->map.name = dev->dev.bus_id;
199 info->map.read = ixp2000_flash_read8; 198 info->map.read = ixp2000_flash_read8;
@@ -201,8 +200,8 @@ static int ixp2000_flash_probe(struct device *_dev)
201 info->map.copy_from = ixp2000_flash_copy_from; 200 info->map.copy_from = ixp2000_flash_copy_from;
202 info->map.copy_to = ixp2000_flash_copy_to; 201 info->map.copy_to = ixp2000_flash_copy_to;
203 202
204 info->res = request_mem_region(dev->resource->start, 203 info->res = request_mem_region(dev->resource->start,
205 dev->resource->end - dev->resource->start + 1, 204 dev->resource->end - dev->resource->start + 1,
206 dev->dev.bus_id); 205 dev->dev.bus_id);
207 if (!info->res) { 206 if (!info->res) {
208 dev_err(_dev, "Could not reserve memory region\n"); 207 dev_err(_dev, "Could not reserve memory region\n");
@@ -210,7 +209,7 @@ static int ixp2000_flash_probe(struct device *_dev)
210 goto Error; 209 goto Error;
211 } 210 }
212 211
213 info->map.map_priv_1 = ioremap(dev->resource->start, 212 info->map.map_priv_1 = (unsigned long) ioremap(dev->resource->start,
214 dev->resource->end - dev->resource->start + 1); 213 dev->resource->end - dev->resource->start + 1);
215 if (!info->map.map_priv_1) { 214 if (!info->map.map_priv_1) {
216 dev_err(_dev, "Failed to ioremap flash region\n"); 215 dev_err(_dev, "Failed to ioremap flash region\n");
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 733a9297a562..56b3a355bf7b 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.7 2004/11/04 13:24:15 gleixner Exp $ 2 * $Id: ixp4xx.c,v 1.12 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * drivers/mtd/maps/ixp4xx.c 4 * drivers/mtd/maps/ixp4xx.c
5 * 5 *
@@ -45,7 +45,7 @@
45static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs) 45static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs)
46{ 46{
47 map_word val; 47 map_word val;
48 val.x[0] = *(__u16 *) (map->map_priv_1 + ofs); 48 val.x[0] = le16_to_cpu(readw(map->virt + ofs));
49 return val; 49 return val;
50} 50}
51 51
@@ -59,35 +59,35 @@ static void ixp4xx_copy_from(struct map_info *map, void *to,
59{ 59{
60 int i; 60 int i;
61 u8 *dest = (u8 *) to; 61 u8 *dest = (u8 *) to;
62 u16 *src = (u16 *) (map->map_priv_1 + from); 62 void __iomem *src = map->virt + from;
63 u16 data; 63 u16 data;
64 64
65 for (i = 0; i < (len / 2); i++) { 65 for (i = 0; i < (len / 2); i++) {
66 data = src[i]; 66 data = le16_to_cpu(readw(src + 2*i));
67 dest[i * 2] = BYTE0(data); 67 dest[i * 2] = BYTE0(data);
68 dest[i * 2 + 1] = BYTE1(data); 68 dest[i * 2 + 1] = BYTE1(data);
69 } 69 }
70 70
71 if (len & 1) 71 if (len & 1)
72 dest[len - 1] = BYTE0(src[i]); 72 dest[len - 1] = BYTE0(le16_to_cpu(readw(src + 2*i)));
73} 73}
74 74
75/* 75/*
76 * Unaligned writes are ignored, causing the 8-bit 76 * Unaligned writes are ignored, causing the 8-bit
77 * probe to fail and proceed to the 16-bit probe (which succeeds). 77 * probe to fail and proceed to the 16-bit probe (which succeeds).
78 */ 78 */
79static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr) 79static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr)
80{ 80{
81 if (!(adr & 1)) 81 if (!(adr & 1))
82 *(__u16 *) (map->map_priv_1 + adr) = d.x[0]; 82 writew(cpu_to_le16(d.x[0]), map->virt + adr);
83} 83}
84 84
85/* 85/*
86 * Fast write16 function without the probing check above 86 * Fast write16 function without the probing check above
87 */ 87 */
88static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr) 88static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
89{ 89{
90 *(__u16 *) (map->map_priv_1 + adr) = d.x[0]; 90 writew(cpu_to_le16(d.x[0]), map->virt + adr);
91} 91}
92 92
93struct ixp4xx_flash_info { 93struct ixp4xx_flash_info {
@@ -104,28 +104,20 @@ static int ixp4xx_flash_remove(struct device *_dev)
104 struct platform_device *dev = to_platform_device(_dev); 104 struct platform_device *dev = to_platform_device(_dev);
105 struct flash_platform_data *plat = dev->dev.platform_data; 105 struct flash_platform_data *plat = dev->dev.platform_data;
106 struct ixp4xx_flash_info *info = dev_get_drvdata(&dev->dev); 106 struct ixp4xx_flash_info *info = dev_get_drvdata(&dev->dev);
107 map_word d;
108 107
109 dev_set_drvdata(&dev->dev, NULL); 108 dev_set_drvdata(&dev->dev, NULL);
110 109
111 if(!info) 110 if(!info)
112 return 0; 111 return 0;
113 112
114 /*
115 * This is required for a soft reboot to work.
116 */
117 d.x[0] = 0xff;
118 ixp4xx_write16(&info->map, d, 0x55 * 0x2);
119
120 if (info->mtd) { 113 if (info->mtd) {
121 del_mtd_partitions(info->mtd); 114 del_mtd_partitions(info->mtd);
122 map_destroy(info->mtd); 115 map_destroy(info->mtd);
123 } 116 }
124 if (info->map.map_priv_1) 117 if (info->map.virt)
125 iounmap((void *) info->map.map_priv_1); 118 iounmap(info->map.virt);
126 119
127 if (info->partitions) 120 kfree(info->partitions);
128 kfree(info->partitions);
129 121
130 if (info->res) { 122 if (info->res) {
131 release_resource(info->res); 123 release_resource(info->res);
@@ -135,9 +127,6 @@ static int ixp4xx_flash_remove(struct device *_dev)
135 if (plat->exit) 127 if (plat->exit)
136 plat->exit(); 128 plat->exit();
137 129
138 /* Disable flash write */
139 *IXP4XX_EXP_CS0 &= ~IXP4XX_FLASH_WRITABLE;
140
141 return 0; 130 return 0;
142} 131}
143 132
@@ -161,17 +150,11 @@ static int ixp4xx_flash_probe(struct device *_dev)
161 if(!info) { 150 if(!info) {
162 err = -ENOMEM; 151 err = -ENOMEM;
163 goto Error; 152 goto Error;
164 } 153 }
165 memzero(info, sizeof(struct ixp4xx_flash_info)); 154 memzero(info, sizeof(struct ixp4xx_flash_info));
166 155
167 dev_set_drvdata(&dev->dev, info); 156 dev_set_drvdata(&dev->dev, info);
168 157
169 /*
170 * Enable flash write
171 * TODO: Move this out to board specific code
172 */
173 *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
174
175 /* 158 /*
176 * Tell the MTD layer we're not 1:1 mapped so that it does 159 * Tell the MTD layer we're not 1:1 mapped so that it does
177 * not attempt to do a direct access on us. 160 * not attempt to do a direct access on us.
@@ -190,8 +173,8 @@ static int ixp4xx_flash_probe(struct device *_dev)
190 info->map.write = ixp4xx_probe_write16, 173 info->map.write = ixp4xx_probe_write16,
191 info->map.copy_from = ixp4xx_copy_from, 174 info->map.copy_from = ixp4xx_copy_from,
192 175
193 info->res = request_mem_region(dev->resource->start, 176 info->res = request_mem_region(dev->resource->start,
194 dev->resource->end - dev->resource->start + 1, 177 dev->resource->end - dev->resource->start + 1,
195 "IXP4XXFlash"); 178 "IXP4XXFlash");
196 if (!info->res) { 179 if (!info->res) {
197 printk(KERN_ERR "IXP4XXFlash: Could not reserve memory region\n"); 180 printk(KERN_ERR "IXP4XXFlash: Could not reserve memory region\n");
@@ -199,9 +182,9 @@ static int ixp4xx_flash_probe(struct device *_dev)
199 goto Error; 182 goto Error;
200 } 183 }
201 184
202 info->map.map_priv_1 = ioremap(dev->resource->start, 185 info->map.virt = ioremap(dev->resource->start,
203 dev->resource->end - dev->resource->start + 1); 186 dev->resource->end - dev->resource->start + 1);
204 if (!info->map.map_priv_1) { 187 if (!info->map.virt) {
205 printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n"); 188 printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n");
206 err = -EIO; 189 err = -EIO;
207 goto Error; 190 goto Error;
@@ -214,7 +197,7 @@ static int ixp4xx_flash_probe(struct device *_dev)
214 goto Error; 197 goto Error;
215 } 198 }
216 info->mtd->owner = THIS_MODULE; 199 info->mtd->owner = THIS_MODULE;
217 200
218 /* Use the fast version */ 201 /* Use the fast version */
219 info->map.write = ixp4xx_write16, 202 info->map.write = ixp4xx_write16,
220 203
@@ -259,4 +242,3 @@ module_exit(ixp4xx_flash_exit);
259MODULE_LICENSE("GPL"); 242MODULE_LICENSE("GPL");
260MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems"); 243MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems");
261MODULE_AUTHOR("Deepak Saxena"); 244MODULE_AUTHOR("Deepak Saxena");
262
diff --git a/drivers/mtd/maps/l440gx.c b/drivers/mtd/maps/l440gx.c
index b08668212ab7..851bf9576052 100644
--- a/drivers/mtd/maps/l440gx.c
+++ b/drivers/mtd/maps/l440gx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: l440gx.c,v 1.17 2004/11/28 09:40:39 dwmw2 Exp $ 2 * $Id: l440gx.c,v 1.18 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * BIOS Flash chip on Intel 440GX board. 4 * BIOS Flash chip on Intel 440GX board.
5 * 5 *
@@ -49,7 +49,7 @@ static struct map_info l440gx_map = {
49 .bankwidth = BUSWIDTH, 49 .bankwidth = BUSWIDTH,
50 .phys = WINDOW_ADDR, 50 .phys = WINDOW_ADDR,
51#if 0 51#if 0
52 /* FIXME verify that this is the 52 /* FIXME verify that this is the
53 * appripriate code for vpp enable/disable 53 * appripriate code for vpp enable/disable
54 */ 54 */
55 .set_vpp = l440gx_set_vpp 55 .set_vpp = l440gx_set_vpp
@@ -62,10 +62,10 @@ static int __init init_l440gx(void)
62 struct resource *pm_iobase; 62 struct resource *pm_iobase;
63 __u16 word; 63 __u16 word;
64 64
65 dev = pci_find_device(PCI_VENDOR_ID_INTEL, 65 dev = pci_find_device(PCI_VENDOR_ID_INTEL,
66 PCI_DEVICE_ID_INTEL_82371AB_0, NULL); 66 PCI_DEVICE_ID_INTEL_82371AB_0, NULL);
67 67
68 pm_dev = pci_find_device(PCI_VENDOR_ID_INTEL, 68 pm_dev = pci_find_device(PCI_VENDOR_ID_INTEL,
69 PCI_DEVICE_ID_INTEL_82371AB_3, NULL); 69 PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
70 70
71 if (!dev || !pm_dev) { 71 if (!dev || !pm_dev) {
@@ -82,10 +82,10 @@ static int __init init_l440gx(void)
82 simple_map_init(&l440gx_map); 82 simple_map_init(&l440gx_map);
83 printk(KERN_NOTICE "window_addr = 0x%08lx\n", (unsigned long)l440gx_map.virt); 83 printk(KERN_NOTICE "window_addr = 0x%08lx\n", (unsigned long)l440gx_map.virt);
84 84
85 /* Setup the pm iobase resource 85 /* Setup the pm iobase resource
86 * This code should move into some kind of generic bridge 86 * This code should move into some kind of generic bridge
87 * driver but for the moment I'm content with getting the 87 * driver but for the moment I'm content with getting the
88 * allocation correct. 88 * allocation correct.
89 */ 89 */
90 pm_iobase = &pm_dev->resource[PIIXE_IOBASE_RESOURCE]; 90 pm_iobase = &pm_dev->resource[PIIXE_IOBASE_RESOURCE];
91 if (!(pm_iobase->flags & IORESOURCE_IO)) { 91 if (!(pm_iobase->flags & IORESOURCE_IO)) {
@@ -110,7 +110,7 @@ static int __init init_l440gx(void)
110 /* Set the iobase */ 110 /* Set the iobase */
111 iobase = pm_iobase->start; 111 iobase = pm_iobase->start;
112 pci_write_config_dword(pm_dev, 0x40, iobase | 1); 112 pci_write_config_dword(pm_dev, 0x40, iobase | 1);
113 113
114 114
115 /* Set XBCS# */ 115 /* Set XBCS# */
116 pci_read_config_word(dev, 0x4e, &word); 116 pci_read_config_word(dev, 0x4e, &word);
@@ -122,7 +122,7 @@ static int __init init_l440gx(void)
122 122
123 /* Enable the gate on the WE line */ 123 /* Enable the gate on the WE line */
124 outb(inb(TRIBUF_PORT) & ~1, TRIBUF_PORT); 124 outb(inb(TRIBUF_PORT) & ~1, TRIBUF_PORT);
125 125
126 printk(KERN_NOTICE "Enabled WE line to L440GX BIOS flash chip.\n"); 126 printk(KERN_NOTICE "Enabled WE line to L440GX BIOS flash chip.\n");
127 127
128 mymtd = do_map_probe("jedec_probe", &l440gx_map); 128 mymtd = do_map_probe("jedec_probe", &l440gx_map);
@@ -145,7 +145,7 @@ static void __exit cleanup_l440gx(void)
145{ 145{
146 del_mtd_device(mymtd); 146 del_mtd_device(mymtd);
147 map_destroy(mymtd); 147 map_destroy(mymtd);
148 148
149 iounmap(l440gx_map.virt); 149 iounmap(l440gx_map.virt);
150} 150}
151 151
diff --git a/drivers/mtd/maps/lubbock-flash.c b/drivers/mtd/maps/lubbock-flash.c
index 2337e0c46750..1aa0447c5e66 100644
--- a/drivers/mtd/maps/lubbock-flash.c
+++ b/drivers/mtd/maps/lubbock-flash.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * $Id: lubbock-flash.c,v 1.19 2004/11/04 13:24:15 gleixner Exp $ 2 * $Id: lubbock-flash.c,v 1.21 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * Map driver for the Lubbock developer platform. 4 * Map driver for the Lubbock developer platform.
5 * 5 *
6 * Author: Nicolas Pitre 6 * Author: Nicolas Pitre
7 * Copyright: (C) 2001 MontaVista Software Inc. 7 * Copyright: (C) 2001 MontaVista Software Inc.
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 version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
@@ -76,7 +76,7 @@ static int __init init_lubbock(void)
76 int flashboot = (LUB_CONF_SWITCHES & 1); 76 int flashboot = (LUB_CONF_SWITCHES & 1);
77 int ret = 0, i; 77 int ret = 0, i;
78 78
79 lubbock_maps[0].bankwidth = lubbock_maps[1].bankwidth = 79 lubbock_maps[0].bankwidth = lubbock_maps[1].bankwidth =
80 (BOOT_DEF & 1) ? 2 : 4; 80 (BOOT_DEF & 1) ? 2 : 4;
81 81
82 /* Compensate for the nROMBT switch which swaps the flash banks */ 82 /* Compensate for the nROMBT switch which swaps the flash banks */
@@ -100,11 +100,11 @@ static int __init init_lubbock(void)
100 simple_map_init(&lubbock_maps[i]); 100 simple_map_init(&lubbock_maps[i]);
101 101
102 printk(KERN_NOTICE "Probing %s at physical address 0x%08lx (%d-bit bankwidth)\n", 102 printk(KERN_NOTICE "Probing %s at physical address 0x%08lx (%d-bit bankwidth)\n",
103 lubbock_maps[i].name, lubbock_maps[i].phys, 103 lubbock_maps[i].name, lubbock_maps[i].phys,
104 lubbock_maps[i].bankwidth * 8); 104 lubbock_maps[i].bankwidth * 8);
105 105
106 mymtds[i] = do_map_probe("cfi_probe", &lubbock_maps[i]); 106 mymtds[i] = do_map_probe("cfi_probe", &lubbock_maps[i]);
107 107
108 if (!mymtds[i]) { 108 if (!mymtds[i]) {
109 iounmap((void *)lubbock_maps[i].virt); 109 iounmap((void *)lubbock_maps[i].virt);
110 if (lubbock_maps[i].cached) 110 if (lubbock_maps[i].cached)
@@ -124,7 +124,7 @@ static int __init init_lubbock(void)
124 124
125 if (!mymtds[0] && !mymtds[1]) 125 if (!mymtds[0] && !mymtds[1])
126 return ret; 126 return ret;
127 127
128 for (i = 0; i < 2; i++) { 128 for (i = 0; i < 2; i++) {
129 if (!mymtds[i]) { 129 if (!mymtds[i]) {
130 printk(KERN_WARNING "%s is absent. Skipping\n", lubbock_maps[i].name); 130 printk(KERN_WARNING "%s is absent. Skipping\n", lubbock_maps[i].name);
@@ -151,15 +151,14 @@ static void __exit cleanup_lubbock(void)
151 if (nr_parsed_parts[i] || !i) 151 if (nr_parsed_parts[i] || !i)
152 del_mtd_partitions(mymtds[i]); 152 del_mtd_partitions(mymtds[i]);
153 else 153 else
154 del_mtd_device(mymtds[i]); 154 del_mtd_device(mymtds[i]);
155 155
156 map_destroy(mymtds[i]); 156 map_destroy(mymtds[i]);
157 iounmap((void *)lubbock_maps[i].virt); 157 iounmap((void *)lubbock_maps[i].virt);
158 if (lubbock_maps[i].cached) 158 if (lubbock_maps[i].cached)
159 iounmap(lubbock_maps[i].cached); 159 iounmap(lubbock_maps[i].cached);
160 160
161 if (parsed_parts[i]) 161 kfree(parsed_parts[i]);
162 kfree(parsed_parts[i]);
163 } 162 }
164} 163}
165 164
diff --git a/drivers/mtd/maps/mainstone-flash.c b/drivers/mtd/maps/mainstone-flash.c
index da0f8a692628..eaa4bbb868a3 100644
--- a/drivers/mtd/maps/mainstone-flash.c
+++ b/drivers/mtd/maps/mainstone-flash.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Author: Nicolas Pitre 6 * Author: Nicolas Pitre
7 * Copyright: (C) 2001 MontaVista Software Inc. 7 * Copyright: (C) 2001 MontaVista Software Inc.
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 version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
@@ -91,27 +91,27 @@ static int __init init_mainstone(void)
91 mainstone_maps[i].virt = ioremap(mainstone_maps[i].phys, 91 mainstone_maps[i].virt = ioremap(mainstone_maps[i].phys,
92 WINDOW_SIZE); 92 WINDOW_SIZE);
93 if (!mainstone_maps[i].virt) { 93 if (!mainstone_maps[i].virt) {
94 printk(KERN_WARNING "Failed to ioremap %s\n", 94 printk(KERN_WARNING "Failed to ioremap %s\n",
95 mainstone_maps[i].name); 95 mainstone_maps[i].name);
96 if (!ret) 96 if (!ret)
97 ret = -ENOMEM; 97 ret = -ENOMEM;
98 continue; 98 continue;
99 } 99 }
100 mainstone_maps[i].cached = 100 mainstone_maps[i].cached =
101 ioremap_cached(mainstone_maps[i].phys, WINDOW_SIZE); 101 ioremap_cached(mainstone_maps[i].phys, WINDOW_SIZE);
102 if (!mainstone_maps[i].cached) 102 if (!mainstone_maps[i].cached)
103 printk(KERN_WARNING "Failed to ioremap cached %s\n", 103 printk(KERN_WARNING "Failed to ioremap cached %s\n",
104 mainstone_maps[i].name); 104 mainstone_maps[i].name);
105 simple_map_init(&mainstone_maps[i]); 105 simple_map_init(&mainstone_maps[i]);
106 106
107 printk(KERN_NOTICE 107 printk(KERN_NOTICE
108 "Probing %s at physical address 0x%08lx" 108 "Probing %s at physical address 0x%08lx"
109 " (%d-bit bankwidth)\n", 109 " (%d-bit bankwidth)\n",
110 mainstone_maps[i].name, mainstone_maps[i].phys, 110 mainstone_maps[i].name, mainstone_maps[i].phys,
111 mainstone_maps[i].bankwidth * 8); 111 mainstone_maps[i].bankwidth * 8);
112 112
113 mymtds[i] = do_map_probe("cfi_probe", &mainstone_maps[i]); 113 mymtds[i] = do_map_probe("cfi_probe", &mainstone_maps[i]);
114 114
115 if (!mymtds[i]) { 115 if (!mymtds[i]) {
116 iounmap((void *)mainstone_maps[i].virt); 116 iounmap((void *)mainstone_maps[i].virt);
117 if (mainstone_maps[i].cached) 117 if (mainstone_maps[i].cached)
@@ -131,21 +131,21 @@ static int __init init_mainstone(void)
131 131
132 if (!mymtds[0] && !mymtds[1]) 132 if (!mymtds[0] && !mymtds[1])
133 return ret; 133 return ret;
134 134
135 for (i = 0; i < 2; i++) { 135 for (i = 0; i < 2; i++) {
136 if (!mymtds[i]) { 136 if (!mymtds[i]) {
137 printk(KERN_WARNING "%s is absent. Skipping\n", 137 printk(KERN_WARNING "%s is absent. Skipping\n",
138 mainstone_maps[i].name); 138 mainstone_maps[i].name);
139 } else if (nr_parsed_parts[i]) { 139 } else if (nr_parsed_parts[i]) {
140 add_mtd_partitions(mymtds[i], parsed_parts[i], 140 add_mtd_partitions(mymtds[i], parsed_parts[i],
141 nr_parsed_parts[i]); 141 nr_parsed_parts[i]);
142 } else if (!i) { 142 } else if (!i) {
143 printk("Using static partitions on %s\n", 143 printk("Using static partitions on %s\n",
144 mainstone_maps[i].name); 144 mainstone_maps[i].name);
145 add_mtd_partitions(mymtds[i], mainstone_partitions, 145 add_mtd_partitions(mymtds[i], mainstone_partitions,
146 ARRAY_SIZE(mainstone_partitions)); 146 ARRAY_SIZE(mainstone_partitions));
147 } else { 147 } else {
148 printk("Registering %s as whole device\n", 148 printk("Registering %s as whole device\n",
149 mainstone_maps[i].name); 149 mainstone_maps[i].name);
150 add_mtd_device(mymtds[i]); 150 add_mtd_device(mymtds[i]);
151 } 151 }
diff --git a/drivers/mtd/maps/mbx860.c b/drivers/mtd/maps/mbx860.c
index c5c6901a4763..06b118727846 100644
--- a/drivers/mtd/maps/mbx860.c
+++ b/drivers/mtd/maps/mbx860.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * $Id: mbx860.c,v 1.8 2004/11/04 13:24:15 gleixner Exp $ 2 * $Id: mbx860.c,v 1.9 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * Handle mapping of the flash on MBX860 boards 4 * Handle mapping of the flash on MBX860 boards
5 * 5 *
6 * Author: Anton Todorov 6 * Author: Anton Todorov
7 * Copyright: (C) 2001 Emness Technology 7 * Copyright: (C) 2001 Emness Technology
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 version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
@@ -46,7 +46,7 @@ static struct mtd_partition partition_info[]={
46 { .name = "MBX flash APPLICATION partition", 46 { .name = "MBX flash APPLICATION partition",
47 .offset = (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 } 47 .offset = (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 }
48}; 48};
49 49
50 50
51static struct mtd_info *mymtd; 51static struct mtd_info *mymtd;
52 52
diff --git a/drivers/mtd/maps/mtx-1_flash.c b/drivers/mtd/maps/mtx-1_flash.c
new file mode 100644
index 000000000000..d1e66e186746
--- /dev/null
+++ b/drivers/mtd/maps/mtx-1_flash.c
@@ -0,0 +1,96 @@
1/*
2 * Flash memory access on 4G Systems MTX-1 boards
3 *
4 * $Id: mtx-1_flash.c,v 1.2 2005/11/07 11:14:27 gleixner Exp $
5 *
6 * (C) 2005 Bruno Randolf <bruno.randolf@4g-systems.biz>
7 * (C) 2005 Jörn Engel <joern@wohnheim.fh-wedel.de>
8 *
9 */
10
11#include <linux/config.h>
12#include <linux/module.h>
13#include <linux/types.h>
14#include <linux/init.h>
15#include <linux/kernel.h>
16
17#include <linux/mtd/mtd.h>
18#include <linux/mtd/map.h>
19#include <linux/mtd/partitions.h>
20
21#include <asm/io.h>
22
23static struct map_info mtx1_map = {
24 .name = "MTX-1 flash",
25 .bankwidth = 4,
26 .size = 0x2000000,
27 .phys = 0x1E000000,
28};
29
30static struct mtd_partition mtx1_partitions[] = {
31 {
32 .name = "filesystem",
33 .size = 0x01C00000,
34 .offset = 0,
35 },{
36 .name = "yamon",
37 .size = 0x00100000,
38 .offset = MTDPART_OFS_APPEND,
39 .mask_flags = MTD_WRITEABLE,
40 },{
41 .name = "kernel",
42 .size = 0x002c0000,
43 .offset = MTDPART_OFS_APPEND,
44 },{
45 .name = "yamon env",
46 .size = 0x00040000,
47 .offset = MTDPART_OFS_APPEND,
48 }
49};
50
51static struct mtd_info *mtx1_mtd;
52
53int __init mtx1_mtd_init(void)
54{
55 int ret = -ENXIO;
56
57 simple_map_init(&mtx1_map);
58
59 mtx1_map.virt = ioremap(mtx1_map.phys, mtx1_map.size);
60 if (!mtx1_map.virt)
61 return -EIO;
62
63 mtx1_mtd = do_map_probe("cfi_probe", &mtx1_map);
64 if (!mtx1_mtd)
65 goto err;
66
67 mtx1_mtd->owner = THIS_MODULE;
68
69 ret = add_mtd_partitions(mtx1_mtd, mtx1_partitions,
70 ARRAY_SIZE(mtx1_partitions));
71 if (ret)
72 goto err;
73
74 return 0;
75
76err:
77 iounmap(mtx1_map.virt);
78 return ret;
79}
80
81static void __exit mtx1_mtd_cleanup(void)
82{
83 if (mtx1_mtd) {
84 del_mtd_partitions(mtx1_mtd);
85 map_destroy(mtx1_mtd);
86 }
87 if (mtx1_map.virt)
88 iounmap(mtx1_map.virt);
89}
90
91module_init(mtx1_mtd_init);
92module_exit(mtx1_mtd_cleanup);
93
94MODULE_AUTHOR("Bruno Randolf <bruno.randolf@4g-systems.biz>");
95MODULE_DESCRIPTION("MTX-1 flash map");
96MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/maps/netsc520.c b/drivers/mtd/maps/netsc520.c
index ab7e6358d281..33060a315722 100644
--- a/drivers/mtd/maps/netsc520.c
+++ b/drivers/mtd/maps/netsc520.c
@@ -3,7 +3,7 @@
3 * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com) 3 * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com)
4 * based on sc520cdp.c by Sysgo Real-Time Solutions GmbH 4 * based on sc520cdp.c by Sysgo Real-Time Solutions GmbH
5 * 5 *
6 * $Id: netsc520.c,v 1.13 2004/11/28 09:40:40 dwmw2 Exp $ 6 * $Id: netsc520.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@
38** The single, 16 megabyte flash bank is divided into four virtual 38** The single, 16 megabyte flash bank is divided into four virtual
39** partitions. The first partition is 768 KiB and is intended to 39** partitions. The first partition is 768 KiB and is intended to
40** store the kernel image loaded by the bootstrap loader. The second 40** store the kernel image loaded by the bootstrap loader. The second
41** partition is 256 KiB and holds the BIOS image. The third 41** partition is 256 KiB and holds the BIOS image. The third
42** partition is 14.5 MiB and is intended for the flash file system 42** partition is 14.5 MiB and is intended for the flash file system
43** image. The last partition is 512 KiB and contains another copy 43** image. The last partition is 512 KiB and contains another copy
44** of the BIOS image and the reset vector. 44** of the BIOS image and the reset vector.
@@ -51,28 +51,28 @@
51** recoverable afterwards. 51** recoverable afterwards.
52*/ 52*/
53 53
54/* partition_info gives details on the logical partitions that the split the 54/* partition_info gives details on the logical partitions that the split the
55 * single flash device into. If the size if zero we use up to the end of the 55 * single flash device into. If the size if zero we use up to the end of the
56 * device. */ 56 * device. */
57static struct mtd_partition partition_info[]={ 57static struct mtd_partition partition_info[]={
58 { 58 {
59 .name = "NetSc520 boot kernel", 59 .name = "NetSc520 boot kernel",
60 .offset = 0, 60 .offset = 0,
61 .size = 0xc0000 61 .size = 0xc0000
62 }, 62 },
63 { 63 {
64 .name = "NetSc520 Low BIOS", 64 .name = "NetSc520 Low BIOS",
65 .offset = 0xc0000, 65 .offset = 0xc0000,
66 .size = 0x40000 66 .size = 0x40000
67 }, 67 },
68 { 68 {
69 .name = "NetSc520 file system", 69 .name = "NetSc520 file system",
70 .offset = 0x100000, 70 .offset = 0x100000,
71 .size = 0xe80000 71 .size = 0xe80000
72 }, 72 },
73 { 73 {
74 .name = "NetSc520 High BIOS", 74 .name = "NetSc520 High BIOS",
75 .offset = 0xf80000, 75 .offset = 0xf80000,
76 .size = 0x80000 76 .size = 0x80000
77 }, 77 },
78}; 78};
@@ -114,7 +114,7 @@ static int __init init_netsc520(void)
114 iounmap(netsc520_map.virt); 114 iounmap(netsc520_map.virt);
115 return -ENXIO; 115 return -ENXIO;
116 } 116 }
117 117
118 mymtd->owner = THIS_MODULE; 118 mymtd->owner = THIS_MODULE;
119 add_mtd_partitions( mymtd, partition_info, NUM_PARTITIONS ); 119 add_mtd_partitions( mymtd, partition_info, NUM_PARTITIONS );
120 return 0; 120 return 0;
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
index 61be5a4148c9..f00ee7e54dba 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.10 2005/01/05 17:11:29 dwmw2 Exp $ 9 * $Id: nettel.c,v 1.11 2005/11/07 11:14:27 gleixner Exp $
10 */ 10 */
11 11
12/****************************************************************************/ 12/****************************************************************************/
@@ -143,7 +143,7 @@ static int nettel_reboot_notifier(struct notifier_block *nb, unsigned long val,
143{ 143{
144 struct cfi_private *cfi = nettel_intel_map.fldrv_priv; 144 struct cfi_private *cfi = nettel_intel_map.fldrv_priv;
145 unsigned long b; 145 unsigned long b;
146 146
147 /* Make sure all FLASH chips are put back into read mode */ 147 /* Make sure all FLASH chips are put back into read mode */
148 for (b = 0; (b < nettel_intel_partitions[3].size); b += 0x100000) { 148 for (b = 0; (b < nettel_intel_partitions[3].size); b += 0x100000) {
149 cfi_send_gen_cmd(0xff, 0x55, b, &nettel_intel_map, cfi, 149 cfi_send_gen_cmd(0xff, 0x55, b, &nettel_intel_map, cfi,
@@ -199,7 +199,7 @@ int nettel_eraseconfig(void)
199 199
200 schedule(); /* Wait for erase to finish. */ 200 schedule(); /* Wait for erase to finish. */
201 remove_wait_queue(&wait_q, &wait); 201 remove_wait_queue(&wait_q, &wait);
202 202
203 put_mtd_device(mtd); 203 put_mtd_device(mtd);
204 } 204 }
205 205
@@ -430,7 +430,7 @@ int __init nettel_init(void)
430 nettel_intel_partitions[1].size = (intel0size + intel1size) - 430 nettel_intel_partitions[1].size = (intel0size + intel1size) -
431 (1024*1024 + intel_mtd->erasesize); 431 (1024*1024 + intel_mtd->erasesize);
432 nettel_intel_partitions[3].size = intel0size + intel1size; 432 nettel_intel_partitions[3].size = intel0size + intel1size;
433 nettel_intel_partitions[4].offset = 433 nettel_intel_partitions[4].offset =
434 (intel0size + intel1size) - intel_mtd->erasesize; 434 (intel0size + intel1size) - intel_mtd->erasesize;
435 nettel_intel_partitions[4].size = intel_mtd->erasesize; 435 nettel_intel_partitions[4].size = intel_mtd->erasesize;
436 nettel_intel_partitions[5].offset = 436 nettel_intel_partitions[5].offset =
diff --git a/drivers/mtd/maps/ocelot.c b/drivers/mtd/maps/ocelot.c
index 82c3070678c5..6977963d7897 100644
--- a/drivers/mtd/maps/ocelot.c
+++ b/drivers/mtd/maps/ocelot.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ocelot.c,v 1.16 2005/01/05 18:05:13 dwmw2 Exp $ 2 * $Id: ocelot.c,v 1.17 2005/11/07 11:14:27 gleixner Exp $
3 * 3 *
4 * Flash on Momenco Ocelot 4 * Flash on Momenco Ocelot
5 */ 5 */
@@ -31,7 +31,7 @@ static void ocelot_ram_write(struct mtd_info *mtd, loff_t to, size_t len, size_t
31 struct map_info *map = mtd->priv; 31 struct map_info *map = mtd->priv;
32 size_t done = 0; 32 size_t done = 0;
33 33
34 /* If we use memcpy, it does word-wide writes. Even though we told the 34 /* If we use memcpy, it does word-wide writes. Even though we told the
35 GT64120A that it's an 8-bit wide region, word-wide writes don't work. 35 GT64120A that it's an 8-bit wide region, word-wide writes don't work.
36 We end up just writing the first byte of the four to all four bytes. 36 We end up just writing the first byte of the four to all four bytes.
37 So we have this loop instead */ 37 So we have this loop instead */
@@ -68,7 +68,7 @@ static int __init init_ocelot_maps(void)
68 int nr_parts; 68 int nr_parts;
69 unsigned char brd_status; 69 unsigned char brd_status;
70 70
71 printk(KERN_INFO "Momenco Ocelot MTD mappings: Flash 0x%x at 0x%x, NVRAM 0x%x at 0x%x\n", 71 printk(KERN_INFO "Momenco Ocelot MTD mappings: Flash 0x%x at 0x%x, NVRAM 0x%x at 0x%x\n",
72 FLASH_WINDOW_SIZE, FLASH_WINDOW_ADDR, NVRAM_WINDOW_SIZE, NVRAM_WINDOW_ADDR); 72 FLASH_WINDOW_SIZE, FLASH_WINDOW_ADDR, NVRAM_WINDOW_SIZE, NVRAM_WINDOW_ADDR);
73 73
74 /* First check whether the flash jumper is present */ 74 /* First check whether the flash jumper is present */
@@ -138,8 +138,8 @@ static int __init init_ocelot_maps(void)
138 add_mtd_device(flash_mtd); 138 add_mtd_device(flash_mtd);
139 139
140 return 0; 140 return 0;
141 141
142 fail3: 142 fail3:
143 iounmap((void *)ocelot_flash_map.virt); 143 iounmap((void *)ocelot_flash_map.virt);
144 if (ocelot_flash_map.cached) 144 if (ocelot_flash_map.cached)
145 iounmap((void *)ocelot_flash_map.cached); 145 iounmap((void *)ocelot_flash_map.cached);
diff --git a/drivers/mtd/maps/octagon-5066.c b/drivers/mtd/maps/octagon-5066.c
index e5ff83de420e..a6642db3d325 100644
--- a/drivers/mtd/maps/octagon-5066.c
+++ b/drivers/mtd/maps/octagon-5066.c
@@ -1,12 +1,12 @@
1// $Id: octagon-5066.c,v 1.26 2004/07/12 22:38:29 dwmw2 Exp $ 1// $Id: octagon-5066.c,v 1.28 2005/11/07 11:14:27 gleixner Exp $
2/* ###################################################################### 2/* ######################################################################
3 3
4 Octagon 5066 MTD Driver. 4 Octagon 5066 MTD Driver.
5 5
6 The Octagon 5066 is a SBC based on AMD's 586-WB running at 133 MHZ. It 6 The Octagon 5066 is a SBC based on AMD's 586-WB running at 133 MHZ. It
7 comes with a builtin AMD 29F016 flash chip and a socketed EEPROM that 7 comes with a builtin AMD 29F016 flash chip and a socketed EEPROM that
8 is replacable by flash. Both units are mapped through a multiplexer 8 is replacable by flash. Both units are mapped through a multiplexer
9 into a 32k memory window at 0xe8000. The control register for the 9 into a 32k memory window at 0xe8000. The control register for the
10 multiplexing unit is located at IO 0x208 with a bit map of 10 multiplexing unit is located at IO 0x208 with a bit map of
11 0-5 Page Selection in 32k increments 11 0-5 Page Selection in 32k increments
12 6-7 Device selection: 12 6-7 Device selection:
@@ -14,14 +14,14 @@
14 01 SSD 0 (Socket) 14 01 SSD 0 (Socket)
15 10 SSD 1 (Flash chip) 15 10 SSD 1 (Flash chip)
16 11 undefined 16 11 undefined
17 17
18 On each SSD, the first 128k is reserved for use by the bios 18 On each SSD, the first 128k is reserved for use by the bios
19 (actually it IS the bios..) This only matters if you are booting off the 19 (actually it IS the bios..) This only matters if you are booting off the
20 flash, you must not put a file system starting there. 20 flash, you must not put a file system starting there.
21 21
22 The driver tries to do a detection algorithm to guess what sort of devices 22 The driver tries to do a detection algorithm to guess what sort of devices
23 are plugged into the sockets. 23 are plugged into the sockets.
24 24
25 ##################################################################### */ 25 ##################################################################### */
26 26
27#include <linux/module.h> 27#include <linux/module.h>
@@ -56,7 +56,7 @@ static void __oct5066_page(struct map_info *map, __u8 byte)
56static inline void oct5066_page(struct map_info *map, unsigned long ofs) 56static inline void oct5066_page(struct map_info *map, unsigned long ofs)
57{ 57{
58 __u8 byte = map->map_priv_1 | (ofs >> WINDOW_SHIFT); 58 __u8 byte = map->map_priv_1 | (ofs >> WINDOW_SHIFT);
59 59
60 if (page_n_dev != byte) 60 if (page_n_dev != byte)
61 __oct5066_page(map, byte); 61 __oct5066_page(map, byte);
62} 62}
@@ -78,7 +78,7 @@ static void oct5066_copy_from(struct map_info *map, void *to, unsigned long from
78 unsigned long thislen = len; 78 unsigned long thislen = len;
79 if (len > (WINDOW_LENGTH - (from & WINDOW_MASK))) 79 if (len > (WINDOW_LENGTH - (from & WINDOW_MASK)))
80 thislen = WINDOW_LENGTH-(from & WINDOW_MASK); 80 thislen = WINDOW_LENGTH-(from & WINDOW_MASK);
81 81
82 spin_lock(&oct5066_spin); 82 spin_lock(&oct5066_spin);
83 oct5066_page(map, from); 83 oct5066_page(map, from);
84 memcpy_fromio(to, iomapadr + from, thislen); 84 memcpy_fromio(to, iomapadr + from, thislen);
@@ -103,7 +103,7 @@ static void oct5066_copy_to(struct map_info *map, unsigned long to, const void *
103 unsigned long thislen = len; 103 unsigned long thislen = len;
104 if (len > (WINDOW_LENGTH - (to & WINDOW_MASK))) 104 if (len > (WINDOW_LENGTH - (to & WINDOW_MASK)))
105 thislen = WINDOW_LENGTH-(to & WINDOW_MASK); 105 thislen = WINDOW_LENGTH-(to & WINDOW_MASK);
106 106
107 spin_lock(&oct5066_spin); 107 spin_lock(&oct5066_spin);
108 oct5066_page(map, to); 108 oct5066_page(map, to);
109 memcpy_toio(iomapadr + to, from, thislen); 109 memcpy_toio(iomapadr + to, from, thislen);
@@ -144,7 +144,7 @@ static struct mtd_info *oct5066_mtd[2] = {NULL, NULL};
144// OctProbe - Sense if this is an octagon card 144// OctProbe - Sense if this is an octagon card
145// --------------------------------------------------------------------- 145// ---------------------------------------------------------------------
146/* Perform a simple validity test, we map the window select SSD0 and 146/* Perform a simple validity test, we map the window select SSD0 and
147 change pages while monitoring the window. A change in the window, 147 change pages while monitoring the window. A change in the window,
148 controlled by the PAGE_IO port is a functioning 5066 board. This will 148 controlled by the PAGE_IO port is a functioning 5066 board. This will
149 fail if the thing in the socket is set to a uniform value. */ 149 fail if the thing in the socket is set to a uniform value. */
150static int __init OctProbe(void) 150static int __init OctProbe(void)
@@ -161,13 +161,13 @@ static int __init OctProbe(void)
161 Values[I%10] = readl(iomapadr); 161 Values[I%10] = readl(iomapadr);
162 if (I > 0 && Values[I%10] == Values[0]) 162 if (I > 0 && Values[I%10] == Values[0])
163 return -EAGAIN; 163 return -EAGAIN;
164 } 164 }
165 else 165 else
166 { 166 {
167 // Make sure we get the same values on the second pass 167 // Make sure we get the same values on the second pass
168 if (Values[I%10] != readl(iomapadr)) 168 if (Values[I%10] != readl(iomapadr))
169 return -EAGAIN; 169 return -EAGAIN;
170 } 170 }
171 } 171 }
172 return 0; 172 return 0;
173} 173}
@@ -207,11 +207,11 @@ int __init init_oct5066(void)
207 ret = -EAGAIN; 207 ret = -EAGAIN;
208 goto out_unmap; 208 goto out_unmap;
209 } 209 }
210 210
211 // Print out our little header.. 211 // Print out our little header..
212 printk("Octagon 5066 SSD IO:0x%x MEM:0x%x-0x%x\n",PAGE_IO,WINDOW_START, 212 printk("Octagon 5066 SSD IO:0x%x MEM:0x%x-0x%x\n",PAGE_IO,WINDOW_START,
213 WINDOW_START+WINDOW_LENGTH); 213 WINDOW_START+WINDOW_LENGTH);
214 214
215 for (i=0; i<2; i++) { 215 for (i=0; i<2; i++) {
216 oct5066_mtd[i] = do_map_probe("cfi_probe", &oct5066_map[i]); 216 oct5066_mtd[i] = do_map_probe("cfi_probe", &oct5066_map[i]);
217 if (!oct5066_mtd[i]) 217 if (!oct5066_mtd[i])
@@ -225,11 +225,11 @@ int __init init_oct5066(void)
225 add_mtd_device(oct5066_mtd[i]); 225 add_mtd_device(oct5066_mtd[i]);
226 } 226 }
227 } 227 }
228 228
229 if (!oct5066_mtd[0] && !oct5066_mtd[1]) { 229 if (!oct5066_mtd[0] && !oct5066_mtd[1]) {
230 cleanup_oct5066(); 230 cleanup_oct5066();
231 return -ENXIO; 231 return -ENXIO;
232 } 232 }
233 233
234 return 0; 234 return 0;
235 235
diff --git a/drivers/mtd/maps/omap-toto-flash.c b/drivers/mtd/maps/omap-toto-flash.c
index da36e8dddd17..dc3765270057 100644
--- a/drivers/mtd/maps/omap-toto-flash.c
+++ b/drivers/mtd/maps/omap-toto-flash.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * (C) 2002 MontVista Software, Inc. 6 * (C) 2002 MontVista Software, Inc.
7 * 7 *
8 * $Id: omap-toto-flash.c,v 1.3 2004/09/16 23:27:13 gleixner Exp $ 8 * $Id: omap-toto-flash.c,v 1.5 2005/11/07 11:14:27 gleixner Exp $
9 */ 9 */
10 10
11#include <linux/config.h> 11#include <linux/config.h>
@@ -38,7 +38,7 @@ static struct map_info omap_toto_map_flash = {
38 .virt = (void __iomem *)OMAP_TOTO_FLASH_BASE, 38 .virt = (void __iomem *)OMAP_TOTO_FLASH_BASE,
39}; 39};
40 40
41 41
42static struct mtd_partition toto_flash_partitions[] = { 42static struct mtd_partition toto_flash_partitions[] = {
43 { 43 {
44 .name = "BootLoader", 44 .name = "BootLoader",
@@ -54,21 +54,21 @@ static struct mtd_partition toto_flash_partitions[] = {
54 .name = "EnvArea", /* bottom 64KiB for env vars */ 54 .name = "EnvArea", /* bottom 64KiB for env vars */
55 .size = MTDPART_SIZ_FULL, 55 .size = MTDPART_SIZ_FULL,
56 .offset = MTDPART_OFS_APPEND, 56 .offset = MTDPART_OFS_APPEND,
57 } 57 }
58}; 58};
59 59
60static struct mtd_partition *parsed_parts; 60static struct mtd_partition *parsed_parts;
61 61
62static struct mtd_info *flash_mtd; 62static struct mtd_info *flash_mtd;
63 63
64static int __init init_flash (void) 64static int __init init_flash (void)
65{ 65{
66 66
67 struct mtd_partition *parts; 67 struct mtd_partition *parts;
68 int nb_parts = 0; 68 int nb_parts = 0;
69 int parsed_nr_parts = 0; 69 int parsed_nr_parts = 0;
70 const char *part_type; 70 const char *part_type;
71 71
72 /* 72 /*
73 * Static partition definition selection 73 * Static partition definition selection
74 */ 74 */
@@ -89,7 +89,7 @@ static int __init init_flash (void)
89 flash_mtd = do_map_probe("jedec_probe", &omap_toto_map_flash); 89 flash_mtd = do_map_probe("jedec_probe", &omap_toto_map_flash);
90 if (!flash_mtd) 90 if (!flash_mtd)
91 return -ENXIO; 91 return -ENXIO;
92 92
93 if (parsed_nr_parts > 0) { 93 if (parsed_nr_parts > 0) {
94 parts = parsed_parts; 94 parts = parsed_parts;
95 nb_parts = parsed_nr_parts; 95 nb_parts = parsed_nr_parts;
@@ -108,8 +108,8 @@ static int __init init_flash (void)
108 } 108 }
109 return 0; 109 return 0;
110} 110}
111 111
112int __init omap_toto_mtd_init(void) 112int __init omap_toto_mtd_init(void)
113{ 113{
114 int status; 114 int status;
115 115
@@ -119,13 +119,12 @@ int __init omap_toto_mtd_init(void)
119 return status; 119 return status;
120} 120}
121 121
122static void __exit omap_toto_mtd_cleanup(void) 122static void __exit omap_toto_mtd_cleanup(void)
123{ 123{
124 if (flash_mtd) { 124 if (flash_mtd) {
125 del_mtd_partitions(flash_mtd); 125 del_mtd_partitions(flash_mtd);
126 map_destroy(flash_mtd); 126 map_destroy(flash_mtd);
127 if (parsed_parts) 127 kfree(parsed_parts);
128 kfree(parsed_parts);
129 } 128 }
130} 129}
131 130
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
index 7f370bb794fe..fd3b4a5fc207 100644
--- a/drivers/mtd/maps/omap_nor.c
+++ b/drivers/mtd/maps/omap_nor.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-2002 MontaVista Software Inc. 4 * Copyright (C) 2001-2002 MontaVista Software Inc.
5 * Copyright (C) 2003-2004 Texas Instruments 5 * Copyright (C) 2003-2004 Texas Instruments
6 * Copyright (C) 2004 Nokia Corporation 6 * Copyright (C) 2004 Nokia Corporation
7 * 7 *
8 * Assembled using driver code copyright the companies above 8 * Assembled using driver code copyright the companies above
9 * and written by David Brownell, Jian Zhang <jzhang@ti.com>, 9 * and written by David Brownell, Jian Zhang <jzhang@ti.com>,
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c
index d9c64e99ee32..8b3570b09095 100644
--- a/drivers/mtd/maps/pci.c
+++ b/drivers/mtd/maps/pci.c
@@ -7,8 +7,8 @@
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.10 2005/03/18 14:04:35 gleixner Exp $ 10 * $Id: pci.c,v 1.13 2005/11/07 11:14:27 gleixner 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.
14 * - Intel EBSA285 (blank rom programming mode). Tested working 27/09/2001 14 * - Intel EBSA285 (blank rom programming mode). Tested working 27/09/2001
@@ -38,7 +38,7 @@ struct map_pci_info {
38 void (*exit)(struct pci_dev *dev, struct map_pci_info *map); 38 void (*exit)(struct pci_dev *dev, struct map_pci_info *map);
39 unsigned long (*translate)(struct map_pci_info *map, unsigned long ofs); 39 unsigned long (*translate)(struct map_pci_info *map, unsigned long ofs);
40 struct pci_dev *dev; 40 struct pci_dev *dev;
41}; 41};
42 42
43static map_word mtd_pci_read8(struct map_info *_map, unsigned long ofs) 43static map_word mtd_pci_read8(struct map_info *_map, unsigned long ofs)
44{ 44{
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index ff7c50d10180..af24216a0626 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: pcmciamtd.c,v 1.51 2004/07/12 22:38:29 dwmw2 Exp $ 2 * $Id: pcmciamtd.c,v 1.55 2005/11/07 11:14:28 gleixner Exp $
3 * 3 *
4 * pcmciamtd.c - MTD driver for PCMCIA flash memory cards 4 * pcmciamtd.c - MTD driver for PCMCIA flash memory cards
5 * 5 *
@@ -48,7 +48,7 @@ static const int debug = 0;
48 48
49 49
50#define DRIVER_DESC "PCMCIA Flash memory card driver" 50#define DRIVER_DESC "PCMCIA Flash memory card driver"
51#define DRIVER_VERSION "$Revision: 1.51 $" 51#define DRIVER_VERSION "$Revision: 1.55 $"
52 52
53/* Size of the PCMCIA address space: 26 bits = 64 MB */ 53/* Size of the PCMCIA address space: 26 bits = 64 MB */
54#define MAX_PCMCIA_ADDR 0x4000000 54#define MAX_PCMCIA_ADDR 0x4000000
@@ -176,7 +176,7 @@ static void pcmcia_copy_from_remap(struct map_info *map, void *to, unsigned long
176 176
177 if(toread > len) 177 if(toread > len)
178 toread = len; 178 toread = len;
179 179
180 addr = remap_window(map, from); 180 addr = remap_window(map, from);
181 if(!addr) 181 if(!addr)
182 return; 182 return;
@@ -386,7 +386,7 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_
386 cs_error(link->handle, ParseTuple, rc); 386 cs_error(link->handle, ParseTuple, rc);
387 break; 387 break;
388 } 388 }
389 389
390 switch(tuple.TupleCode) { 390 switch(tuple.TupleCode) {
391 case CISTPL_FORMAT: { 391 case CISTPL_FORMAT: {
392 cistpl_format_t *t = &parse.format; 392 cistpl_format_t *t = &parse.format;
@@ -394,9 +394,9 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_
394 DEBUG(2, "Format type: %u, Error Detection: %u, offset = %u, length =%u", 394 DEBUG(2, "Format type: %u, Error Detection: %u, offset = %u, length =%u",
395 t->type, t->edc, t->offset, t->length); 395 t->type, t->edc, t->offset, t->length);
396 break; 396 break;
397 397
398 } 398 }
399 399
400 case CISTPL_DEVICE: { 400 case CISTPL_DEVICE: {
401 cistpl_device_t *t = &parse.device; 401 cistpl_device_t *t = &parse.device;
402 int i; 402 int i;
@@ -410,7 +410,7 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_
410 } 410 }
411 break; 411 break;
412 } 412 }
413 413
414 case CISTPL_VERS_1: { 414 case CISTPL_VERS_1: {
415 cistpl_vers_1_t *t = &parse.version_1; 415 cistpl_vers_1_t *t = &parse.version_1;
416 int i; 416 int i;
@@ -425,7 +425,7 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_
425 DEBUG(2, "Found name: %s", dev->mtd_name); 425 DEBUG(2, "Found name: %s", dev->mtd_name);
426 break; 426 break;
427 } 427 }
428 428
429 case CISTPL_JEDEC_C: { 429 case CISTPL_JEDEC_C: {
430 cistpl_jedec_t *t = &parse.jedec; 430 cistpl_jedec_t *t = &parse.jedec;
431 int i; 431 int i;
@@ -434,7 +434,7 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_
434 } 434 }
435 break; 435 break;
436 } 436 }
437 437
438 case CISTPL_DEVICE_GEO: { 438 case CISTPL_DEVICE_GEO: {
439 cistpl_device_geo_t *t = &parse.device_geo; 439 cistpl_device_geo_t *t = &parse.device_geo;
440 int i; 440 int i;
@@ -449,11 +449,11 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_
449 } 449 }
450 break; 450 break;
451 } 451 }
452 452
453 default: 453 default:
454 DEBUG(2, "Unknown tuple code %d", tuple.TupleCode); 454 DEBUG(2, "Unknown tuple code %d", tuple.TupleCode);
455 } 455 }
456 456
457 rc = pcmcia_get_next_tuple(link->handle, &tuple); 457 rc = pcmcia_get_next_tuple(link->handle, &tuple);
458 } 458 }
459 if(!dev->pcmcia_map.size) 459 if(!dev->pcmcia_map.size)
@@ -470,7 +470,7 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_
470 if(bankwidth) { 470 if(bankwidth) {
471 dev->pcmcia_map.bankwidth = bankwidth; 471 dev->pcmcia_map.bankwidth = bankwidth;
472 DEBUG(2, "bankwidth forced to %d", bankwidth); 472 DEBUG(2, "bankwidth forced to %d", bankwidth);
473 } 473 }
474 474
475 dev->pcmcia_map.name = dev->mtd_name; 475 dev->pcmcia_map.name = dev->mtd_name;
476 if(!dev->mtd_name[0]) { 476 if(!dev->mtd_name[0]) {
@@ -568,7 +568,7 @@ static void pcmciamtd_config(dev_link_t *link)
568 return; 568 return;
569 } 569 }
570 DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); 570 DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10);
571 571
572 /* Get write protect status */ 572 /* Get write protect status */
573 CS_CHECK(GetStatus, pcmcia_get_status(link->handle, &status)); 573 CS_CHECK(GetStatus, pcmcia_get_status(link->handle, &status));
574 DEBUG(2, "status value: 0x%x window handle = 0x%8.8lx", 574 DEBUG(2, "status value: 0x%x window handle = 0x%8.8lx",
@@ -624,11 +624,11 @@ static void pcmciamtd_config(dev_link_t *link)
624 mtd = do_map_probe(probes[i], &dev->pcmcia_map); 624 mtd = do_map_probe(probes[i], &dev->pcmcia_map);
625 if(mtd) 625 if(mtd)
626 break; 626 break;
627 627
628 DEBUG(1, "FAILED: %s", probes[i]); 628 DEBUG(1, "FAILED: %s", probes[i]);
629 } 629 }
630 } 630 }
631 631
632 if(!mtd) { 632 if(!mtd) {
633 DEBUG(1, "Cant find an MTD"); 633 DEBUG(1, "Cant find an MTD");
634 pcmciamtd_release(link); 634 pcmciamtd_release(link);
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index b853670bfb81..9ee760f97bc6 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.37 2004/11/28 09:40:40 dwmw2 Exp $ 2 * $Id: physmap.c,v 1.38 2005/11/07 11:14:28 gleixner Exp $
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * 5 *
@@ -69,7 +69,7 @@ static int __init init_physmap(void)
69 mymtd->owner = THIS_MODULE; 69 mymtd->owner = THIS_MODULE;
70 70
71#ifdef CONFIG_MTD_PARTITIONS 71#ifdef CONFIG_MTD_PARTITIONS
72 mtd_parts_nb = parse_mtd_partitions(mymtd, part_probes, 72 mtd_parts_nb = parse_mtd_partitions(mymtd, part_probes,
73 &mtd_parts, 0); 73 &mtd_parts, 0);
74 74
75 if (mtd_parts_nb > 0) 75 if (mtd_parts_nb > 0)
@@ -78,9 +78,9 @@ static int __init init_physmap(void)
78 return 0; 78 return 0;
79 } 79 }
80 80
81 if (num_physmap_partitions != 0) 81 if (num_physmap_partitions != 0)
82 { 82 {
83 printk(KERN_NOTICE 83 printk(KERN_NOTICE
84 "Using physmap partition definition\n"); 84 "Using physmap partition definition\n");
85 add_mtd_partitions (mymtd, physmap_partitions, num_physmap_partitions); 85 add_mtd_partitions (mymtd, physmap_partitions, num_physmap_partitions);
86 return 0; 86 return 0;
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index 104576b5be34..a02eed94a231 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -6,7 +6,7 @@
6 * 6 *
7 * Generic platfrom device based RAM map 7 * Generic platfrom device based RAM map
8 * 8 *
9 * $Id: plat-ram.c,v 1.3 2005/03/19 22:41:27 gleixner Exp $ 9 * $Id: plat-ram.c,v 1.7 2005/11/07 11:14:28 gleixner Exp $
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 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 12 * it under the terms of the GNU General Public License as published by
@@ -91,7 +91,7 @@ static int platram_remove(struct device *dev)
91 91
92 dev_dbg(dev, "removing device\n"); 92 dev_dbg(dev, "removing device\n");
93 93
94 if (info == NULL) 94 if (info == NULL)
95 return 0; 95 return 0;
96 96
97 if (info->mtd) { 97 if (info->mtd) {
@@ -118,7 +118,7 @@ static int platram_remove(struct device *dev)
118 118
119 if (info->map.virt != NULL) 119 if (info->map.virt != NULL)
120 iounmap(info->map.virt); 120 iounmap(info->map.virt);
121 121
122 kfree(info); 122 kfree(info);
123 123
124 return 0; 124 return 0;
@@ -139,7 +139,7 @@ static int platram_probe(struct device *dev)
139 int err = 0; 139 int err = 0;
140 140
141 dev_dbg(dev, "probe entered\n"); 141 dev_dbg(dev, "probe entered\n");
142 142
143 if (dev->platform_data == NULL) { 143 if (dev->platform_data == NULL) {
144 dev_err(dev, "no platform data supplied\n"); 144 dev_err(dev, "no platform data supplied\n");
145 err = -ENOENT; 145 err = -ENOENT;
@@ -177,7 +177,7 @@ static int platram_probe(struct device *dev)
177 177
178 info->map.phys = res->start; 178 info->map.phys = res->start;
179 info->map.size = (res->end - res->start) + 1; 179 info->map.size = (res->end - res->start) + 1;
180 info->map.name = pdata->mapname != NULL ? pdata->mapname : pd->name; 180 info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pd->name;
181 info->map.bankwidth = pdata->bankwidth; 181 info->map.bankwidth = pdata->bankwidth;
182 182
183 /* register our usage of the memory area */ 183 /* register our usage of the memory area */
@@ -240,7 +240,7 @@ static int platram_probe(struct device *dev)
240 dev_err(dev, "add_mtd_device() failed\n"); 240 dev_err(dev, "add_mtd_device() failed\n");
241 err = -ENOMEM; 241 err = -ENOMEM;
242 } 242 }
243 243
244 dev_info(dev, "registered mtd device\n"); 244 dev_info(dev, "registered mtd device\n");
245 return err; 245 return err;
246 246
@@ -254,6 +254,7 @@ static int platram_probe(struct device *dev)
254 254
255static struct device_driver platram_driver = { 255static struct device_driver platram_driver = {
256 .name = "mtd-ram", 256 .name = "mtd-ram",
257 .owner = THIS_MODULE,
257 .bus = &platform_bus_type, 258 .bus = &platform_bus_type,
258 .probe = platram_probe, 259 .probe = platram_probe,
259 .remove = platram_remove, 260 .remove = platram_remove,
diff --git a/drivers/mtd/maps/pnc2000.c b/drivers/mtd/maps/pnc2000.c
index a0f43dad8985..d7e16c2d5c44 100644
--- a/drivers/mtd/maps/pnc2000.c
+++ b/drivers/mtd/maps/pnc2000.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 * 7 *
8 * $Id: pnc2000.c,v 1.17 2004/11/16 18:29:02 dwmw2 Exp $ 8 * $Id: pnc2000.c,v 1.18 2005/11/07 11:14:28 gleixner Exp $
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
@@ -21,7 +21,7 @@
21#define WINDOW_ADDR 0xbf000000 21#define WINDOW_ADDR 0xbf000000
22#define WINDOW_SIZE 0x00400000 22#define WINDOW_SIZE 0x00400000
23 23
24/* 24/*
25 * MAP DRIVER STUFF 25 * MAP DRIVER STUFF
26 */ 26 */
27 27
@@ -36,7 +36,7 @@ static struct map_info pnc_map = {
36 36
37 37
38/* 38/*
39 * MTD 'PARTITIONING' STUFF 39 * MTD 'PARTITIONING' STUFF
40 */ 40 */
41static struct mtd_partition pnc_partitions[3] = { 41static struct mtd_partition pnc_partitions[3] = {
42 { 42 {
@@ -56,7 +56,7 @@ static struct mtd_partition pnc_partitions[3] = {
56 } 56 }
57}; 57};
58 58
59/* 59/*
60 * This is the master MTD device for which all the others are just 60 * This is the master MTD device for which all the others are just
61 * auto-relocating aliases. 61 * auto-relocating aliases.
62 */ 62 */
diff --git a/drivers/mtd/maps/pq2fads.c b/drivers/mtd/maps/pq2fads.c
new file mode 100644
index 000000000000..fb78d87cc130
--- /dev/null
+++ b/drivers/mtd/maps/pq2fads.c
@@ -0,0 +1,88 @@
1/*
2 * drivers/mtd/maps/pq2fads.c
3 *
4 * Mapping for the flash SIMM on 8272ADS and PQ2FADS board
5 *
6 * Author: Vitaly Bordug <vbordug@ru.mvista.com>
7 *
8 * 2005 (c) MontaVista Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
12 */
13
14#include <linux/module.h>
15#include <linux/types.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <asm/io.h>
19#include <asm/ppcboot.h>
20#include <linux/mtd/mtd.h>
21#include <linux/mtd/map.h>
22#include <linux/mtd/partitions.h>
23#include <linux/mtd/physmap.h>
24
25/*
26 NOTE: bank width and interleave relative to the installed flash
27 should have been chosen within MTD_CFI_GEOMETRY options.
28 */
29#define PQ2FADS_BANK_WIDTH 4
30
31static struct mtd_partition pq2fads_partitions[] = {
32 {
33#ifdef CONFIG_ADS8272
34 .name = "HRCW",
35 .size = 0x40000,
36 .offset = 0,
37 .mask_flags = MTD_WRITEABLE, /* force read-only */
38 }, {
39 .name = "User FS",
40 .size = 0x5c0000,
41 .offset = 0x40000,
42#else
43 .name = "User FS",
44 .size = 0x600000,
45 .offset = 0,
46#endif
47 }, {
48 .name = "uImage",
49 .size = 0x100000,
50 .offset = 0x600000,
51 .mask_flags = MTD_WRITEABLE, /* force read-only */
52 }, {
53 .name = "bootloader",
54 .size = 0x40000,
55 .offset = 0x700000,
56 .mask_flags = MTD_WRITEABLE, /* force read-only */
57 }, {
58 .name = "bootloader env",
59 .size = 0x40000,
60 .offset = 0x740000,
61 .mask_flags = MTD_WRITEABLE, /* force read-only */
62 }
63};
64
65
66/* pointer to MPC885ADS board info data */
67extern unsigned char __res[];
68
69static int __init init_pq2fads_mtd(void)
70{
71 bd_t *bd = (bd_t *)__res;
72 physmap_configure(bd->bi_flashstart, bd->bi_flashsize, PQ2FADS_BANK_WIDTH, NULL);
73
74 physmap_set_partitions(pq2fads_partitions,
75 sizeof (pq2fads_partitions) /
76 sizeof (pq2fads_partitions[0]));
77 return 0;
78}
79
80static void __exit cleanup_pq2fads_mtd(void)
81{
82}
83
84module_init(init_pq2fads_mtd);
85module_exit(cleanup_pq2fads_mtd);
86
87MODULE_LICENSE("GPL");
88MODULE_DESCRIPTION("MTD map and partitions for MPC8272ADS boards");
diff --git a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c
index edd01ee4f90b..5b76ed886185 100644
--- a/drivers/mtd/maps/redwood.c
+++ b/drivers/mtd/maps/redwood.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: redwood.c,v 1.10 2004/11/04 13:24:15 gleixner Exp $ 2 * $Id: redwood.c,v 1.11 2005/11/07 11:14:28 gleixner Exp $
3 * 3 *
4 * drivers/mtd/maps/redwood.c 4 * drivers/mtd/maps/redwood.c
5 * 5 *
@@ -79,7 +79,7 @@ static struct mtd_partition redwood_flash_partitions[] = {
79 79
80#define RW_PART0_OF 0 80#define RW_PART0_OF 0
81#define RW_PART0_SZ 0x400000 /* 4 MiB data */ 81#define RW_PART0_SZ 0x400000 /* 4 MiB data */
82#define RW_PART1_OF RW_PART0_OF + RW_PART0_SZ 82#define RW_PART1_OF RW_PART0_OF + RW_PART0_SZ
83#define RW_PART1_SZ 0x10000 /* 64K VPD */ 83#define RW_PART1_SZ 0x10000 /* 64K VPD */
84#define RW_PART2_OF RW_PART1_OF + RW_PART1_SZ 84#define RW_PART2_OF RW_PART1_OF + RW_PART1_SZ
85#define RW_PART2_SZ 0x400000 - (0x10000 + 0x20000) 85#define RW_PART2_SZ 0x400000 - (0x10000 + 0x20000)
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index c8d0da19d897..9e8bb1782be0 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * Flash memory access on SA11x0 based devices 2 * Flash memory access on SA11x0 based devices
3 * 3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 * 5 *
6 * $Id: sa1100-flash.c,v 1.47 2004/11/01 13:44:36 rmk Exp $ 6 * $Id: sa1100-flash.c,v 1.51 2005/11/07 11:14:28 gleixner Exp $
7 */ 7 */
8#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/module.h> 9#include <linux/module.h>
@@ -241,8 +241,7 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla
241#endif 241#endif
242 } 242 }
243 243
244 if (info->parts) 244 kfree(info->parts);
245 kfree(info->parts);
246 245
247 for (i = info->num_subdev - 1; i >= 0; i--) 246 for (i = info->num_subdev - 1; i >= 0; i--)
248 sa1100_destroy_subdev(&info->subdev[i]); 247 sa1100_destroy_subdev(&info->subdev[i]);
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c
index da684d3384e9..225cdd9ba5b2 100644
--- a/drivers/mtd/maps/sbc8240.c
+++ b/drivers/mtd/maps/sbc8240.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * This code is GPLed 6 * This code is GPLed
7 * 7 *
8 * $Id: sbc8240.c,v 1.4 2004/07/12 22:38:29 dwmw2 Exp $ 8 * $Id: sbc8240.c,v 1.5 2005/11/07 11:14:28 gleixner Exp $
9 * 9 *
10 */ 10 */
11 11
@@ -205,7 +205,7 @@ int __init init_sbc8240_mtd (void)
205 } else { 205 } else {
206 printk (KERN_NOTICE MSG_PREFIX 206 printk (KERN_NOTICE MSG_PREFIX
207 "Using %s partition definition\n", sbc8240_part_banks[i].mtd_part->name); 207 "Using %s partition definition\n", sbc8240_part_banks[i].mtd_part->name);
208 add_mtd_partitions (sbc8240_mtd[i], 208 add_mtd_partitions (sbc8240_mtd[i],
209 sbc8240_part_banks[i].mtd_part, 209 sbc8240_part_banks[i].mtd_part,
210 sbc8240_part_banks[i].nums); 210 sbc8240_part_banks[i].nums);
211 } 211 }
diff --git a/drivers/mtd/maps/sbc_gxx.c b/drivers/mtd/maps/sbc_gxx.c
index 65add28bde14..7cc4041d096d 100644
--- a/drivers/mtd/maps/sbc_gxx.c
+++ b/drivers/mtd/maps/sbc_gxx.c
@@ -1,35 +1,35 @@
1/* sbc_gxx.c -- MTD map driver for Arcom Control Systems SBC-MediaGX, 1/* sbc_gxx.c -- MTD map driver for Arcom Control Systems SBC-MediaGX,
2 SBC-GXm and SBC-GX1 series boards. 2 SBC-GXm and SBC-GX1 series boards.
3 3
4 Copyright (C) 2001 Arcom Control System Ltd 4 Copyright (C) 2001 Arcom Control System Ltd
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 19
20 $Id: sbc_gxx.c,v 1.33 2004/11/28 09:40:40 dwmw2 Exp $ 20 $Id: sbc_gxx.c,v 1.35 2005/11/07 11:14:28 gleixner Exp $
21 21
22The SBC-MediaGX / SBC-GXx has up to 16 MiB of 22The SBC-MediaGX / SBC-GXx has up to 16 MiB of
23Intel StrataFlash (28F320/28F640) in x8 mode. 23Intel StrataFlash (28F320/28F640) in x8 mode.
24 24
25This driver uses the CFI probe and Intel Extended Command Set drivers. 25This driver uses the CFI probe and Intel Extended Command Set drivers.
26 26
27The flash is accessed as follows: 27The flash is accessed as follows:
28 28
29 16 KiB memory window at 0xdc000-0xdffff 29 16 KiB memory window at 0xdc000-0xdffff
30 30
31 Two IO address locations for paging 31 Two IO address locations for paging
32 32
33 0x258 33 0x258
34 bit 0-7: address bit 14-21 34 bit 0-7: address bit 14-21
35 0x259 35 0x259
@@ -37,7 +37,7 @@ The flash is accessed as follows:
37 bit 7: 0 - reset/powered down 37 bit 7: 0 - reset/powered down
38 1 - device enabled 38 1 - device enabled
39 39
40The single flash device is divided into 3 partition which appear as 40The single flash device is divided into 3 partition which appear as
41separate MTD devices. 41separate MTD devices.
42 42
4325/04/2001 AJL (Arcom) Modified signon strings and partition sizes 4325/04/2001 AJL (Arcom) Modified signon strings and partition sizes
@@ -87,17 +87,17 @@ static volatile int page_in_window = -1; // Current page in window.
87static void __iomem *iomapadr; 87static void __iomem *iomapadr;
88static DEFINE_SPINLOCK(sbc_gxx_spin); 88static DEFINE_SPINLOCK(sbc_gxx_spin);
89 89
90/* partition_info gives details on the logical partitions that the split the 90/* partition_info gives details on the logical partitions that the split the
91 * single flash device into. If the size if zero we use up to the end of the 91 * single flash device into. If the size if zero we use up to the end of the
92 * device. */ 92 * device. */
93static struct mtd_partition partition_info[]={ 93static struct mtd_partition partition_info[]={
94 { .name = "SBC-GXx flash boot partition", 94 { .name = "SBC-GXx flash boot partition",
95 .offset = 0, 95 .offset = 0,
96 .size = BOOT_PARTITION_SIZE_KiB*1024 }, 96 .size = BOOT_PARTITION_SIZE_KiB*1024 },
97 { .name = "SBC-GXx flash data partition", 97 { .name = "SBC-GXx flash data partition",
98 .offset = BOOT_PARTITION_SIZE_KiB*1024, 98 .offset = BOOT_PARTITION_SIZE_KiB*1024,
99 .size = (DATA_PARTITION_SIZE_KiB)*1024 }, 99 .size = (DATA_PARTITION_SIZE_KiB)*1024 },
100 { .name = "SBC-GXx flash application partition", 100 { .name = "SBC-GXx flash application partition",
101 .offset = (BOOT_PARTITION_SIZE_KiB+DATA_PARTITION_SIZE_KiB)*1024 } 101 .offset = (BOOT_PARTITION_SIZE_KiB+DATA_PARTITION_SIZE_KiB)*1024 }
102}; 102};
103 103
@@ -130,7 +130,7 @@ static void sbc_gxx_copy_from(struct map_info *map, void *to, unsigned long from
130 unsigned long thislen = len; 130 unsigned long thislen = len;
131 if (len > (WINDOW_LENGTH - (from & WINDOW_MASK))) 131 if (len > (WINDOW_LENGTH - (from & WINDOW_MASK)))
132 thislen = WINDOW_LENGTH-(from & WINDOW_MASK); 132 thislen = WINDOW_LENGTH-(from & WINDOW_MASK);
133 133
134 spin_lock(&sbc_gxx_spin); 134 spin_lock(&sbc_gxx_spin);
135 sbc_gxx_page(map, from); 135 sbc_gxx_page(map, from);
136 memcpy_fromio(to, iomapadr + (from & WINDOW_MASK), thislen); 136 memcpy_fromio(to, iomapadr + (from & WINDOW_MASK), thislen);
@@ -150,12 +150,12 @@ static void sbc_gxx_write8(struct map_info *map, map_word d, unsigned long adr)
150} 150}
151 151
152static void sbc_gxx_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) 152static void sbc_gxx_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
153{ 153{
154 while(len) { 154 while(len) {
155 unsigned long thislen = len; 155 unsigned long thislen = len;
156 if (len > (WINDOW_LENGTH - (to & WINDOW_MASK))) 156 if (len > (WINDOW_LENGTH - (to & WINDOW_MASK)))
157 thislen = WINDOW_LENGTH-(to & WINDOW_MASK); 157 thislen = WINDOW_LENGTH-(to & WINDOW_MASK);
158 158
159 spin_lock(&sbc_gxx_spin); 159 spin_lock(&sbc_gxx_spin);
160 sbc_gxx_page(map, to); 160 sbc_gxx_page(map, to);
161 memcpy_toio(iomapadr + (to & WINDOW_MASK), from, thislen); 161 memcpy_toio(iomapadr + (to & WINDOW_MASK), from, thislen);
@@ -201,7 +201,7 @@ static int __init init_sbc_gxx(void)
201 sbc_gxx_map.name ); 201 sbc_gxx_map.name );
202 return -EIO; 202 return -EIO;
203 } 203 }
204 204
205 if (!request_region( PAGE_IO, PAGE_IO_SIZE, "SBC-GXx flash")) { 205 if (!request_region( PAGE_IO, PAGE_IO_SIZE, "SBC-GXx flash")) {
206 printk( KERN_ERR"%s: IO ports 0x%x-0x%x in use\n", 206 printk( KERN_ERR"%s: IO ports 0x%x-0x%x in use\n",
207 sbc_gxx_map.name, 207 sbc_gxx_map.name,
@@ -209,8 +209,8 @@ static int __init init_sbc_gxx(void)
209 iounmap(iomapadr); 209 iounmap(iomapadr);
210 return -EAGAIN; 210 return -EAGAIN;
211 } 211 }
212 212
213 213
214 printk( KERN_INFO"%s: IO:0x%x-0x%x MEM:0x%x-0x%x\n", 214 printk( KERN_INFO"%s: IO:0x%x-0x%x MEM:0x%x-0x%x\n",
215 sbc_gxx_map.name, 215 sbc_gxx_map.name,
216 PAGE_IO, PAGE_IO+PAGE_IO_SIZE-1, 216 PAGE_IO, PAGE_IO+PAGE_IO_SIZE-1,
@@ -222,7 +222,7 @@ static int __init init_sbc_gxx(void)
222 cleanup_sbc_gxx(); 222 cleanup_sbc_gxx();
223 return -ENXIO; 223 return -ENXIO;
224 } 224 }
225 225
226 all_mtd->owner = THIS_MODULE; 226 all_mtd->owner = THIS_MODULE;
227 227
228 /* Create MTD devices for each partition. */ 228 /* Create MTD devices for each partition. */
diff --git a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c
index a06ed21e7ed1..6fb9f3c57aab 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.21 2004/12/13 10:27:08 dedekind Exp $ 19 * $Id: sc520cdp.c,v 1.22 2005/11/07 11:14:28 gleixner 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
@@ -231,7 +231,7 @@ static void sc520cdp_setup_par(void)
231static int __init init_sc520cdp(void) 231static int __init init_sc520cdp(void)
232{ 232{
233 int i, devices_found = 0; 233 int i, devices_found = 0;
234 234
235#ifdef REPROGRAM_PAR 235#ifdef REPROGRAM_PAR
236 /* reprogram PAR registers so flash appears at the desired addresses */ 236 /* reprogram PAR registers so flash appears at the desired addresses */
237 sc520cdp_setup_par(); 237 sc520cdp_setup_par();
@@ -278,7 +278,7 @@ static int __init init_sc520cdp(void)
278static void __exit cleanup_sc520cdp(void) 278static void __exit cleanup_sc520cdp(void)
279{ 279{
280 int i; 280 int i;
281 281
282 if (merged_mtd) { 282 if (merged_mtd) {
283 del_mtd_device(merged_mtd); 283 del_mtd_device(merged_mtd);
284 mtd_concat_destroy(merged_mtd); 284 mtd_concat_destroy(merged_mtd);
diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c
index 0ece3786d6ea..2c91dff8bb60 100644
--- a/drivers/mtd/maps/scx200_docflash.c
+++ b/drivers/mtd/maps/scx200_docflash.c
@@ -1,8 +1,8 @@
1/* linux/drivers/mtd/maps/scx200_docflash.c 1/* linux/drivers/mtd/maps/scx200_docflash.c
2 2
3 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> 3 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
4 4
5 $Id: scx200_docflash.c,v 1.10 2004/11/28 09:40:40 dwmw2 Exp $ 5 $Id: scx200_docflash.c,v 1.12 2005/11/07 11:14:28 gleixner Exp $
6 6
7 National Semiconductor SCx200 flash mapped with DOCCS 7 National Semiconductor SCx200 flash mapped with DOCCS
8*/ 8*/
@@ -49,23 +49,23 @@ static struct mtd_info *mymtd;
49 49
50#ifdef CONFIG_MTD_PARTITIONS 50#ifdef CONFIG_MTD_PARTITIONS
51static struct mtd_partition partition_info[] = { 51static struct mtd_partition partition_info[] = {
52 { 52 {
53 .name = "DOCCS Boot kernel", 53 .name = "DOCCS Boot kernel",
54 .offset = 0, 54 .offset = 0,
55 .size = 0xc0000 55 .size = 0xc0000
56 }, 56 },
57 { 57 {
58 .name = "DOCCS Low BIOS", 58 .name = "DOCCS Low BIOS",
59 .offset = 0xc0000, 59 .offset = 0xc0000,
60 .size = 0x40000 60 .size = 0x40000
61 }, 61 },
62 { 62 {
63 .name = "DOCCS File system", 63 .name = "DOCCS File system",
64 .offset = 0x100000, 64 .offset = 0x100000,
65 .size = ~0 /* calculate from flash size */ 65 .size = ~0 /* calculate from flash size */
66 }, 66 },
67 { 67 {
68 .name = "DOCCS High BIOS", 68 .name = "DOCCS High BIOS",
69 .offset = ~0, /* calculate from flash size */ 69 .offset = ~0, /* calculate from flash size */
70 .size = 0x80000 70 .size = 0x80000
71 }, 71 },
@@ -88,7 +88,7 @@ static int __init init_scx200_docflash(void)
88 88
89 printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n"); 89 printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n");
90 90
91 if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, 91 if ((bridge = pci_find_device(PCI_VENDOR_ID_NS,
92 PCI_DEVICE_ID_NS_SCx200_BRIDGE, 92 PCI_DEVICE_ID_NS_SCx200_BRIDGE,
93 NULL)) == NULL) 93 NULL)) == NULL)
94 return -ENODEV; 94 return -ENODEV;
@@ -134,28 +134,28 @@ static int __init init_scx200_docflash(void)
134 printk(KERN_ERR NAME ": invalid size for flash mapping\n"); 134 printk(KERN_ERR NAME ": invalid size for flash mapping\n");
135 return -EINVAL; 135 return -EINVAL;
136 } 136 }
137 137
138 if (width != 8 && width != 16) { 138 if (width != 8 && width != 16) {
139 printk(KERN_ERR NAME ": invalid bus width for flash mapping\n"); 139 printk(KERN_ERR NAME ": invalid bus width for flash mapping\n");
140 return -EINVAL; 140 return -EINVAL;
141 } 141 }
142 142
143 if (allocate_resource(&iomem_resource, &docmem, 143 if (allocate_resource(&iomem_resource, &docmem,
144 size, 144 size,
145 0xc0000000, 0xffffffff, 145 0xc0000000, 0xffffffff,
146 size, NULL, NULL)) { 146 size, NULL, NULL)) {
147 printk(KERN_ERR NAME ": unable to allocate memory for flash mapping\n"); 147 printk(KERN_ERR NAME ": unable to allocate memory for flash mapping\n");
148 return -ENOMEM; 148 return -ENOMEM;
149 } 149 }
150 150
151 ctrl = 0x07000000 | ((size-1) >> 13); 151 ctrl = 0x07000000 | ((size-1) >> 13);
152 152
153 printk(KERN_INFO "DOCCS BASE=0x%08lx, CTRL=0x%08lx\n", (long)docmem.start, (long)ctrl); 153 printk(KERN_INFO "DOCCS BASE=0x%08lx, CTRL=0x%08lx\n", (long)docmem.start, (long)ctrl);
154 154
155 pci_write_config_dword(bridge, SCx200_DOCCS_BASE, docmem.start); 155 pci_write_config_dword(bridge, SCx200_DOCCS_BASE, docmem.start);
156 pci_write_config_dword(bridge, SCx200_DOCCS_CTRL, ctrl); 156 pci_write_config_dword(bridge, SCx200_DOCCS_CTRL, ctrl);
157 pmr = inl(scx200_cb_base + SCx200_PMR); 157 pmr = inl(scx200_cb_base + SCx200_PMR);
158 158
159 if (width == 8) { 159 if (width == 8) {
160 pmr &= ~(1<<6); 160 pmr &= ~(1<<6);
161 } else { 161 } else {
@@ -163,8 +163,8 @@ static int __init init_scx200_docflash(void)
163 } 163 }
164 outl(pmr, scx200_cb_base + SCx200_PMR); 164 outl(pmr, scx200_cb_base + SCx200_PMR);
165 } 165 }
166 166
167 printk(KERN_INFO NAME ": DOCCS mapped at 0x%lx-0x%lx, width %d\n", 167 printk(KERN_INFO NAME ": DOCCS mapped at 0x%lx-0x%lx, width %d\n",
168 docmem.start, docmem.end, width); 168 docmem.start, docmem.end, width);
169 169
170 scx200_docflash_map.size = size; 170 scx200_docflash_map.size = size;
diff --git a/drivers/mtd/maps/sharpsl-flash.c b/drivers/mtd/maps/sharpsl-flash.c
index b7f093fbf9b0..999f4bb3d845 100644
--- a/drivers/mtd/maps/sharpsl-flash.c
+++ b/drivers/mtd/maps/sharpsl-flash.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * sharpsl-flash.c 2 * sharpsl-flash.c
3 * 3 *
4 * Copyright (C) 2001 Lineo Japan, Inc. 4 * Copyright (C) 2001 Lineo Japan, Inc.
5 * Copyright (C) 2002 SHARP 5 * Copyright (C) 2002 SHARP
6 * 6 *
7 * $Id: sharpsl-flash.c,v 1.5 2005/03/21 08:42:11 rpurdie Exp $ 7 * $Id: sharpsl-flash.c,v 1.7 2005/11/07 11:14:28 gleixner Exp $
8 * 8 *
9 * based on rpxlite.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp 9 * based on rpxlite.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp
10 * Handle mapping of the flash on the RPX Lite and CLLF boards 10 * Handle mapping of the flash on the RPX Lite and CLLF boards
@@ -57,7 +57,7 @@ int __init init_sharpsl(void)
57 int nb_parts = 0; 57 int nb_parts = 0;
58 char *part_type = "static"; 58 char *part_type = "static";
59 59
60 printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n", 60 printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n",
61 WINDOW_SIZE, WINDOW_ADDR); 61 WINDOW_SIZE, WINDOW_ADDR);
62 sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); 62 sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
63 if (!sharpsl_map.virt) { 63 if (!sharpsl_map.virt) {
@@ -75,7 +75,7 @@ int __init init_sharpsl(void)
75 75
76 mymtd->owner = THIS_MODULE; 76 mymtd->owner = THIS_MODULE;
77 77
78 if (machine_is_corgi() || machine_is_shepherd() || machine_is_husky() 78 if (machine_is_corgi() || machine_is_shepherd() || machine_is_husky()
79 || machine_is_poodle()) { 79 || machine_is_poodle()) {
80 sharpsl_partitions[0].size=0x006d0000; 80 sharpsl_partitions[0].size=0x006d0000;
81 sharpsl_partitions[0].offset=0x00120000; 81 sharpsl_partitions[0].offset=0x00120000;
@@ -87,10 +87,10 @@ int __init init_sharpsl(void)
87 sharpsl_partitions[0].offset=0x00140000; 87 sharpsl_partitions[0].offset=0x00140000;
88 } else { 88 } else {
89 map_destroy(mymtd); 89 map_destroy(mymtd);
90 iounmap(sharpsl_map.virt); 90 iounmap(sharpsl_map.virt);
91 return -ENODEV; 91 return -ENODEV;
92 } 92 }
93 93
94 parts = sharpsl_partitions; 94 parts = sharpsl_partitions;
95 nb_parts = NB_OF(sharpsl_partitions); 95 nb_parts = NB_OF(sharpsl_partitions);
96 96
diff --git a/drivers/mtd/maps/solutionengine.c b/drivers/mtd/maps/solutionengine.c
index 8ce5d897645c..c53c2c369c9d 100644
--- a/drivers/mtd/maps/solutionengine.c
+++ b/drivers/mtd/maps/solutionengine.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: solutionengine.c,v 1.14 2004/09/16 23:27:14 gleixner Exp $ 2 * $Id: solutionengine.c,v 1.15 2005/11/07 11:14:28 gleixner Exp $
3 * 3 *
4 * Flash and EPROM on Hitachi Solution Engine and similar boards. 4 * Flash and EPROM on Hitachi Solution Engine and similar boards.
5 * 5 *
@@ -67,7 +67,7 @@ static int __init init_soleng_maps(void)
67 soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000); 67 soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000);
68 simple_map_init(&soleng_eprom_map); 68 simple_map_init(&soleng_eprom_map);
69 simple_map_init(&soleng_flash_map); 69 simple_map_init(&soleng_flash_map);
70 70
71 printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n"); 71 printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
72 flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map); 72 flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
73 if (!flash_mtd) { 73 if (!flash_mtd) {
diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c
index 29091d10030a..0758cb1d0105 100644
--- a/drivers/mtd/maps/sun_uflash.c
+++ b/drivers/mtd/maps/sun_uflash.c
@@ -1,4 +1,4 @@
1/* $Id: sun_uflash.c,v 1.11 2004/11/04 13:24:15 gleixner Exp $ 1/* $Id: sun_uflash.c,v 1.13 2005/11/07 11:14:28 gleixner Exp $
2 * 2 *
3 * sun_uflash - Driver implementation for user-programmable flash 3 * sun_uflash - Driver implementation for user-programmable flash
4 * present on many Sun Microsystems SME boardsets. 4 * present on many Sun Microsystems SME boardsets.
@@ -63,7 +63,7 @@ int uflash_devinit(struct linux_ebus_device* edev)
63 iTmp = prom_getproperty( 63 iTmp = prom_getproperty(
64 edev->prom_node, "reg", (void *)regs, sizeof(regs)); 64 edev->prom_node, "reg", (void *)regs, sizeof(regs));
65 if ((iTmp % sizeof(regs[0])) != 0) { 65 if ((iTmp % sizeof(regs[0])) != 0) {
66 printk("%s: Strange reg property size %d\n", 66 printk("%s: Strange reg property size %d\n",
67 UFLASH_DEVNAME, iTmp); 67 UFLASH_DEVNAME, iTmp);
68 return -ENODEV; 68 return -ENODEV;
69 } 69 }
@@ -75,7 +75,7 @@ int uflash_devinit(struct linux_ebus_device* edev)
75 * can work on supporting it. 75 * can work on supporting it.
76 */ 76 */
77 printk("%s: unsupported device at 0x%lx (%d regs): " \ 77 printk("%s: unsupported device at 0x%lx (%d regs): " \
78 "email ebrower@usa.net\n", 78 "email ebrower@usa.net\n",
79 UFLASH_DEVNAME, edev->resource[0].start, nregs); 79 UFLASH_DEVNAME, edev->resource[0].start, nregs);
80 return -ENODEV; 80 return -ENODEV;
81 } 81 }
@@ -84,7 +84,7 @@ int uflash_devinit(struct linux_ebus_device* edev)
84 printk("%s: unable to kmalloc new device\n", UFLASH_DEVNAME); 84 printk("%s: unable to kmalloc new device\n", UFLASH_DEVNAME);
85 return(-ENOMEM); 85 return(-ENOMEM);
86 } 86 }
87 87
88 /* copy defaults and tweak parameters */ 88 /* copy defaults and tweak parameters */
89 memcpy(&pdev->map, &uflash_map_templ, sizeof(uflash_map_templ)); 89 memcpy(&pdev->map, &uflash_map_templ, sizeof(uflash_map_templ));
90 pdev->map.size = regs[0].reg_size; 90 pdev->map.size = regs[0].reg_size;
@@ -155,7 +155,7 @@ static void __exit uflash_cleanup(void)
155 155
156 list_for_each(udevlist, &device_list) { 156 list_for_each(udevlist, &device_list) {
157 udev = list_entry(udevlist, struct uflash_dev, list); 157 udev = list_entry(udevlist, struct uflash_dev, list);
158 DEBUG(2, "%s: removing device %s\n", 158 DEBUG(2, "%s: removing device %s\n",
159 UFLASH_DEVNAME, udev->name); 159 UFLASH_DEVNAME, udev->name);
160 160
161 if(0 != udev->mtd) { 161 if(0 != udev->mtd) {
@@ -166,11 +166,9 @@ static void __exit uflash_cleanup(void)
166 iounmap(udev->map.virt); 166 iounmap(udev->map.virt);
167 udev->map.virt = NULL; 167 udev->map.virt = NULL;
168 } 168 }
169 if(0 != udev->name) { 169 kfree(udev->name);
170 kfree(udev->name);
171 }
172 kfree(udev); 170 kfree(udev);
173 } 171 }
174} 172}
175 173
176module_init(uflash_init); 174module_init(uflash_init);
diff --git a/drivers/mtd/maps/tqm834x.c b/drivers/mtd/maps/tqm834x.c
new file mode 100644
index 000000000000..c7ae9a515c1a
--- /dev/null
+++ b/drivers/mtd/maps/tqm834x.c
@@ -0,0 +1,291 @@
1/*
2 * drivers/mtd/maps/tqm834x.c
3 *
4 * MTD mapping driver for TQM834x boards
5 *
6 * Copyright 2005 Wolfgang Denk, DENX Software Engineering, <wd@denx.de>.
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 *
12 */
13
14#include <linux/config.h>
15#include <linux/init.h>
16#include <linux/module.h>
17#include <linux/types.h>
18#include <linux/kernel.h>
19#include <linux/slab.h>
20#include <asm/io.h>
21#include <asm/ppcboot.h>
22
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/map.h>
25#include <linux/mtd/partitions.h>
26
27#define FLASH_BANK_MAX 2
28
29extern unsigned char __res[];
30
31/* trivial struct to describe partition information */
32struct mtd_part_def
33{
34 int nums;
35 unsigned char *type;
36 struct mtd_partition* mtd_part;
37};
38
39static struct mtd_info* mtd_banks[FLASH_BANK_MAX];
40static struct map_info* map_banks[FLASH_BANK_MAX];
41static struct mtd_part_def part_banks[FLASH_BANK_MAX];
42
43static unsigned long num_banks;
44static unsigned long start_scan_addr;
45
46#ifdef CONFIG_MTD_PARTITIONS
47/*
48 * The following defines the partition layout of TQM834x boards.
49 *
50 * See include/linux/mtd/partitions.h for definition of the
51 * mtd_partition structure.
52 *
53 * Assume minimal initial size of 4 MiB per bank, will be updated
54 * later in init_tqm834x_mtd() routine.
55 */
56
57/* Partition definition for the first flash bank which is always present. */
58static struct mtd_partition tqm834x_partitions_bank1[] = {
59 {
60 .name = "u-boot", /* u-boot firmware */
61 .offset = 0x00000000,
62 .size = 0x00040000, /* 256 KiB */
63 /*mask_flags: MTD_WRITEABLE, * force read-only */
64 },
65 {
66 .name = "env", /* u-boot environment */
67 .offset = 0x00040000,
68 .size = 0x00020000, /* 128 KiB */
69 /*mask_flags: MTD_WRITEABLE, * force read-only */
70 },
71 {
72 .name = "kernel", /* linux kernel image */
73 .offset = 0x00060000,
74 .size = 0x00100000, /* 1 MiB */
75 /*mask_flags: MTD_WRITEABLE, * force read-only */
76 },
77 {
78 .name = "initrd", /* ramdisk image */
79 .offset = 0x00160000,
80 .size = 0x00200000, /* 2 MiB */
81 },
82 {
83 .name = "user", /* user data */
84 .offset = 0x00360000,
85 .size = 0x000a0000, /* remaining space */
86 /* NOTE: this parttion size is re-calcated in */
87 /* init_tqm834x_mtd() to cover actual remaining space. */
88 },
89};
90
91/* Partition definition for the second flash bank which may be present on some
92 * TQM834x boards.
93 */
94static struct mtd_partition tqm834x_partitions_bank2[] = {
95 {
96 .name = "jffs2", /* jffs2 filesystem */
97 .offset = 0x00000000,
98 .size = 0x00400000, /* whole device */
99 /* NOTE: this parttion size is re-calcated in */
100 /* init_tqm834x_mtd() to cover actual device size. */
101 },
102};
103
104#endif /* CONFIG_MTD_PARTITIONS */
105
106static int __init init_tqm834x_mtd(void)
107{
108 int idx = 0, ret = 0;
109 unsigned long flash_addr, flash_size, mtd_size = 0;
110
111 /* pointer to TQM834x board info data */
112 bd_t *bd = (bd_t *)__res;
113#ifdef CONFIG_MTD_CMDLINE_PARTS
114 int n;
115 char mtdid[4];
116 const char *part_probes[] = { "cmdlinepart", NULL };
117#endif
118
119 flash_addr = bd->bi_flashstart;
120 flash_size = bd->bi_flashsize;
121
122 /* request maximum flash size address space */
123 start_scan_addr = (unsigned long)ioremap(flash_addr, flash_size);
124 if (!start_scan_addr) {
125 printk("%s: Failed to ioremap address: 0x%lx\n",
126 __FUNCTION__, flash_addr);
127 return -EIO;
128 }
129
130 for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) {
131 if (mtd_size >= flash_size)
132 break;
133
134 pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx);
135
136 map_banks[idx] =
137 (struct map_info *)kmalloc(sizeof(struct map_info),
138 GFP_KERNEL);
139 if (map_banks[idx] == NULL) {
140 ret = -ENOMEM;
141 goto error_mem;
142 }
143 memset((void *)map_banks[idx], 0, sizeof(struct map_info));
144 map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL);
145 if (map_banks[idx]->name == NULL) {
146 ret = -ENOMEM;
147 goto error_mem;
148 }
149 memset((void *)map_banks[idx]->name, 0, 16);
150
151 sprintf(map_banks[idx]->name, "TQM834x-%d", idx);
152 map_banks[idx]->size = flash_size;
153 map_banks[idx]->bankwidth = 4;
154
155 simple_map_init(map_banks[idx]);
156
157 map_banks[idx]->virt = (void __iomem *)
158 (start_scan_addr + ((idx > 0) ?
159 (mtd_banks[idx-1] ? mtd_banks[idx-1]->size : 0) : 0));
160 map_banks[idx]->phys =
161 flash_addr + ((idx > 0) ?
162 (mtd_banks[idx-1] ? mtd_banks[idx-1]->size : 0) : 0);
163
164 /* start to probe flash chips */
165 mtd_banks[idx] = do_map_probe("cfi_probe", map_banks[idx]);
166 if (mtd_banks[idx]) {
167 mtd_banks[idx]->owner = THIS_MODULE;
168 mtd_size += mtd_banks[idx]->size;
169 num_banks++;
170 pr_debug("%s: bank %ld, name: %s, size: %d bytes \n",
171 __FUNCTION__, num_banks,
172 mtd_banks[idx]->name, mtd_banks[idx]->size);
173 }
174 }
175
176 /* no supported flash chips found */
177 if (!num_banks) {
178 printk("TQM834x: No supported flash chips found!\n");
179 ret = -ENXIO;
180 goto error_mem;
181 }
182
183#ifdef CONFIG_MTD_PARTITIONS
184 /*
185 * Select static partition definitions
186 */
187 n = ARRAY_SIZE(tqm834x_partitions_bank1);
188 part_banks[0].mtd_part = tqm834x_partitions_bank1;
189 part_banks[0].type = "static image bank1";
190 part_banks[0].nums = n;
191
192 /* update last partition size to cover actual remaining space */
193 tqm834x_partitions_bank1[n - 1].size =
194 mtd_banks[0]->size -
195 tqm834x_partitions_bank1[n - 1].offset;
196
197 /* check if we have second bank? */
198 if (num_banks == 2) {
199 n = ARRAY_SIZE(tqm834x_partitions_bank2);
200 part_banks[1].mtd_part = tqm834x_partitions_bank2;
201 part_banks[1].type = "static image bank2";
202 part_banks[1].nums = n;
203
204 /* update last partition size to cover actual remaining space */
205 tqm834x_partitions_bank2[n - 1].size =
206 mtd_banks[1]->size -
207 tqm834x_partitions_bank2[n - 1].offset;
208 }
209
210 for(idx = 0; idx < num_banks ; idx++) {
211#ifdef CONFIG_MTD_CMDLINE_PARTS
212 sprintf(mtdid, "%d", idx);
213 n = parse_mtd_partitions(mtd_banks[idx],
214 part_probes,
215 &part_banks[idx].mtd_part,
216 0);
217 pr_debug("%s: %d command line partitions on bank %s\n",
218 __FUNCTION__, n, mtdid);
219 if (n > 0) {
220 part_banks[idx].type = "command line";
221 part_banks[idx].nums = n;
222 }
223#endif /* CONFIG_MTD_CMDLINE_PARTS */
224 if (part_banks[idx].nums == 0) {
225 printk(KERN_NOTICE
226 "TQM834x flash bank %d: no partition info "
227 "available, registering whole device\n", idx);
228 add_mtd_device(mtd_banks[idx]);
229 } else {
230 printk(KERN_NOTICE
231 "TQM834x flash bank %d: Using %s partition "
232 "definition\n", idx, part_banks[idx].type);
233 add_mtd_partitions(mtd_banks[idx],
234 part_banks[idx].mtd_part,
235 part_banks[idx].nums);
236 }
237 }
238#else /* ! CONFIG_MTD_PARTITIONS */
239 printk(KERN_NOTICE "TQM834x flash: registering %d flash banks "
240 "at once\n", num_banks);
241
242 for(idx = 0 ; idx < num_banks ; idx++)
243 add_mtd_device(mtd_banks[idx]);
244
245#endif /* CONFIG_MTD_PARTITIONS */
246
247 return 0;
248error_mem:
249 for (idx = 0 ; idx < FLASH_BANK_MAX ; idx++) {
250 if (map_banks[idx] != NULL) {
251 if (map_banks[idx]->name != NULL) {
252 kfree(map_banks[idx]->name);
253 map_banks[idx]->name = NULL;
254 }
255 kfree(map_banks[idx]);
256 map_banks[idx] = NULL;
257 }
258 }
259
260 iounmap((void *)start_scan_addr);
261
262 return ret;
263}
264
265static void __exit cleanup_tqm834x_mtd(void)
266{
267 unsigned int idx = 0;
268 for(idx = 0 ; idx < num_banks ; idx++) {
269 /* destroy mtd_info previously allocated */
270 if (mtd_banks[idx]) {
271 del_mtd_partitions(mtd_banks[idx]);
272 map_destroy(mtd_banks[idx]);
273 }
274
275 /* release map_info not used anymore */
276 kfree(map_banks[idx]->name);
277 kfree(map_banks[idx]);
278 }
279
280 if (start_scan_addr) {
281 iounmap((void *)start_scan_addr);
282 start_scan_addr = 0;
283 }
284}
285
286module_init(init_tqm834x_mtd);
287module_exit(cleanup_tqm834x_mtd);
288
289MODULE_LICENSE("GPL");
290MODULE_AUTHOR("Wolfgang Denk <wd@denx.de>");
291MODULE_DESCRIPTION("MTD map driver for TQM834x boards");
diff --git a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c
index 4e28b977f224..a43517053e7c 100644
--- a/drivers/mtd/maps/tqm8xxl.c
+++ b/drivers/mtd/maps/tqm8xxl.c
@@ -1,15 +1,15 @@
1/* 1/*
2 * Handle mapping of the flash memory access routines 2 * Handle mapping of the flash memory access routines
3 * on TQM8xxL based devices. 3 * on TQM8xxL based devices.
4 * 4 *
5 * $Id: tqm8xxl.c,v 1.13 2004/10/20 22:21:53 dwmw2 Exp $ 5 * $Id: tqm8xxl.c,v 1.15 2005/11/07 11:14:28 gleixner Exp $
6 * 6 *
7 * based on rpxlite.c 7 * based on rpxlite.c
8 * 8 *
9 * Copyright(C) 2001 Kirk Lee <kirk@hpc.ee.ntu.edu.tw> 9 * Copyright(C) 2001 Kirk Lee <kirk@hpc.ee.ntu.edu.tw>
10 * 10 *
11 * This code is GPLed 11 * This code is GPLed
12 * 12 *
13 */ 13 */
14 14
15/* 15/*
@@ -19,7 +19,7 @@
19 * 2MiB 512Kx16 2MiB 0 19 * 2MiB 512Kx16 2MiB 0
20 * 4MiB 1Mx16 4MiB 0 20 * 4MiB 1Mx16 4MiB 0
21 * 8MiB 1Mx16 4MiB 4MiB 21 * 8MiB 1Mx16 4MiB 4MiB
22 * Thus, we choose CONFIG_MTD_CFI_I2 & CONFIG_MTD_CFI_B4 at 22 * Thus, we choose CONFIG_MTD_CFI_I2 & CONFIG_MTD_CFI_B4 at
23 * kernel configuration. 23 * kernel configuration.
24 */ 24 */
25#include <linux/config.h> 25#include <linux/config.h>
@@ -58,9 +58,9 @@ static void __iomem *start_scan_addr;
58 * Here are partition information for all known TQM8xxL series devices. 58 * Here are partition information for all known TQM8xxL series devices.
59 * See include/linux/mtd/partitions.h for definition of the mtd_partition 59 * See include/linux/mtd/partitions.h for definition of the mtd_partition
60 * structure. 60 * structure.
61 * 61 *
62 * The *_max_flash_size is the maximum possible mapped flash size which 62 * The *_max_flash_size is the maximum possible mapped flash size which
63 * is not necessarily the actual flash size. It must correspond to the 63 * is not necessarily the actual flash size. It must correspond to the
64 * value specified in the mapping definition defined by the 64 * value specified in the mapping definition defined by the
65 * "struct map_desc *_io_desc" for the corresponding machine. 65 * "struct map_desc *_io_desc" for the corresponding machine.
66 */ 66 */
@@ -132,9 +132,9 @@ int __init init_tqm_mtd(void)
132 for (idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { 132 for (idx = 0 ; idx < FLASH_BANK_MAX ; idx++) {
133 if(mtd_size >= flash_size) 133 if(mtd_size >= flash_size)
134 break; 134 break;
135 135
136 printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx); 136 printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx);
137 137
138 map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), GFP_KERNEL); 138 map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), GFP_KERNEL);
139 if(map_banks[idx] == NULL) { 139 if(map_banks[idx] == NULL) {
140 ret = -ENOMEM; 140 ret = -ENOMEM;
@@ -180,7 +180,7 @@ int __init init_tqm_mtd(void)
180 mtd_size += mtd_banks[idx]->size; 180 mtd_size += mtd_banks[idx]->size;
181 num_banks++; 181 num_banks++;
182 182
183 printk(KERN_INFO "%s: bank%d, name:%s, size:%dbytes \n", __FUNCTION__, num_banks, 183 printk(KERN_INFO "%s: bank%d, name:%s, size:%dbytes \n", __FUNCTION__, num_banks,
184 mtd_banks[idx]->name, mtd_banks[idx]->size); 184 mtd_banks[idx]->name, mtd_banks[idx]->size);
185 } 185 }
186 } 186 }
@@ -211,7 +211,7 @@ int __init init_tqm_mtd(void)
211 } else { 211 } else {
212 printk(KERN_NOTICE "TQM flash%d: Using %s partition definition\n", 212 printk(KERN_NOTICE "TQM flash%d: Using %s partition definition\n",
213 idx, part_banks[idx].type); 213 idx, part_banks[idx].type);
214 add_mtd_partitions(mtd_banks[idx], part_banks[idx].mtd_part, 214 add_mtd_partitions(mtd_banks[idx], part_banks[idx].mtd_part,
215 part_banks[idx].nums); 215 part_banks[idx].nums);
216 } 216 }
217 } 217 }
@@ -224,10 +224,8 @@ int __init init_tqm_mtd(void)
224error_mem: 224error_mem:
225 for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { 225 for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) {
226 if(map_banks[idx] != NULL) { 226 if(map_banks[idx] != NULL) {
227 if(map_banks[idx]->name != NULL) { 227 kfree(map_banks[idx]->name);
228 kfree(map_banks[idx]->name); 228 map_banks[idx]->name = NULL;
229 map_banks[idx]->name = NULL;
230 }
231 kfree(map_banks[idx]); 229 kfree(map_banks[idx]);
232 map_banks[idx] = NULL; 230 map_banks[idx] = NULL;
233 } 231 }
diff --git a/drivers/mtd/maps/ts5500_flash.c b/drivers/mtd/maps/ts5500_flash.c
index 3ebd90f56503..4b372bcb17f1 100644
--- a/drivers/mtd/maps/ts5500_flash.c
+++ b/drivers/mtd/maps/ts5500_flash.c
@@ -19,26 +19,22 @@
19 * 19 *
20 * Note: 20 * Note:
21 * - In order for detection to work, jumper 3 must be set. 21 * - In order for detection to work, jumper 3 must be set.
22 * - Drive A and B use a proprietary FTL from General Software which isn't 22 * - Drive A and B use the resident flash disk (RFD) flash translation layer.
23 * supported as of yet so standard drives can't be mounted; you can create 23 * - If you have created your own jffs file system and the bios overwrites
24 * your own (e.g. jffs) file system.
25 * - If you have created your own jffs file system and the bios overwrites
26 * it during boot, try disabling Drive A: and B: in the boot order. 24 * it during boot, try disabling Drive A: and B: in the boot order.
27 * 25 *
28 * $Id: ts5500_flash.c,v 1.2 2004/11/28 09:40:40 dwmw2 Exp $ 26 * $Id: ts5500_flash.c,v 1.5 2005/11/07 11:14:28 gleixner Exp $
29 */ 27 */
30 28
31#include <linux/config.h> 29#include <linux/config.h>
30#include <linux/init.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/types.h>
34#include <linux/kernel.h> 32#include <linux/kernel.h>
35#include <linux/init.h>
36#include <linux/mtd/mtd.h>
37#include <linux/mtd/map.h> 33#include <linux/mtd/map.h>
38 34#include <linux/mtd/mtd.h>
39#ifdef CONFIG_MTD_PARTITIONS
40#include <linux/mtd/partitions.h> 35#include <linux/mtd/partitions.h>
41#endif 36#include <linux/types.h>
37
42 38
43#define WINDOW_ADDR 0x09400000 39#define WINDOW_ADDR 0x09400000
44#define WINDOW_SIZE 0x00200000 40#define WINDOW_SIZE 0x00200000
@@ -50,7 +46,6 @@ static struct map_info ts5500_map = {
50 .phys = WINDOW_ADDR 46 .phys = WINDOW_ADDR
51}; 47};
52 48
53#ifdef CONFIG_MTD_PARTITIONS
54static struct mtd_partition ts5500_partitions[] = { 49static struct mtd_partition ts5500_partitions[] = {
55 { 50 {
56 .name = "Drive A", 51 .name = "Drive A",
@@ -71,8 +66,6 @@ static struct mtd_partition ts5500_partitions[] = {
71 66
72#define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition)) 67#define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition))
73 68
74#endif
75
76static struct mtd_info *mymtd; 69static struct mtd_info *mymtd;
77 70
78static int __init init_ts5500_map(void) 71static int __init init_ts5500_map(void)
@@ -81,48 +74,39 @@ static int __init init_ts5500_map(void)
81 74
82 ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size); 75 ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
83 76
84 if(!ts5500_map.virt) { 77 if (!ts5500_map.virt) {
85 printk(KERN_ERR "Failed to ioremap_nocache\n"); 78 printk(KERN_ERR "Failed to ioremap_nocache\n");
86 rc = -EIO; 79 rc = -EIO;
87 goto err_out_ioremap; 80 goto err2;
88 } 81 }
89 82
90 simple_map_init(&ts5500_map); 83 simple_map_init(&ts5500_map);
91 84
92 mymtd = do_map_probe("jedec_probe", &ts5500_map); 85 mymtd = do_map_probe("jedec_probe", &ts5500_map);
93 if(!mymtd) 86 if (!mymtd)
94 mymtd = do_map_probe("map_rom", &ts5500_map); 87 mymtd = do_map_probe("map_rom", &ts5500_map);
95 88
96 if(!mymtd) { 89 if (!mymtd) {
97 rc = -ENXIO; 90 rc = -ENXIO;
98 goto err_out_map; 91 goto err1;
99 } 92 }
100 93
101 mymtd->owner = THIS_MODULE; 94 mymtd->owner = THIS_MODULE;
102#ifdef CONFIG_MTD_PARTITIONS
103 add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS); 95 add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS);
104#else
105 add_mtd_device(mymtd);
106#endif
107 96
108 return 0; 97 return 0;
109 98
110err_out_map: 99err1:
111 map_destroy(mymtd); 100 map_destroy(mymtd);
112err_out_ioremap:
113 iounmap(ts5500_map.virt); 101 iounmap(ts5500_map.virt);
114 102err2:
115 return rc; 103 return rc;
116} 104}
117 105
118static void __exit cleanup_ts5500_map(void) 106static void __exit cleanup_ts5500_map(void)
119{ 107{
120 if (mymtd) { 108 if (mymtd) {
121#ifdef CONFIG_MTD_PARTITIONS
122 del_mtd_partitions(mymtd); 109 del_mtd_partitions(mymtd);
123#else
124 del_mtd_device(mymtd);
125#endif
126 map_destroy(mymtd); 110 map_destroy(mymtd);
127 } 111 }
128 112
diff --git a/drivers/mtd/maps/tsunami_flash.c b/drivers/mtd/maps/tsunami_flash.c
index 170d71239e5e..9e21e6c02f80 100644
--- a/drivers/mtd/maps/tsunami_flash.c
+++ b/drivers/mtd/maps/tsunami_flash.c
@@ -2,7 +2,7 @@
2 * tsunami_flash.c 2 * tsunami_flash.c
3 * 3 *
4 * flash chip on alpha ds10... 4 * flash chip on alpha ds10...
5 * $Id: tsunami_flash.c,v 1.9 2004/07/14 09:52:55 dwmw2 Exp $ 5 * $Id: tsunami_flash.c,v 1.10 2005/11/07 11:14:29 gleixner Exp $
6 */ 6 */
7#include <asm/io.h> 7#include <asm/io.h>
8#include <asm/core_tsunami.h> 8#include <asm/core_tsunami.h>
@@ -41,7 +41,7 @@ static void tsunami_flash_copy_from(
41} 41}
42 42
43static void tsunami_flash_copy_to( 43static void tsunami_flash_copy_to(
44 struct map_info *map, unsigned long offset, 44 struct map_info *map, unsigned long offset,
45 const void *addr, ssize_t len) 45 const void *addr, ssize_t len)
46{ 46{
47 const unsigned char *src; 47 const unsigned char *src;
@@ -90,7 +90,7 @@ static int __init init_tsunami_flash(void)
90 char **type; 90 char **type;
91 91
92 tsunami_tig_writeb(FLASH_ENABLE_BYTE, FLASH_ENABLE_PORT); 92 tsunami_tig_writeb(FLASH_ENABLE_BYTE, FLASH_ENABLE_PORT);
93 93
94 tsunami_flash_mtd = 0; 94 tsunami_flash_mtd = 0;
95 type = rom_probe_types; 95 type = rom_probe_types;
96 for(; !tsunami_flash_mtd && *type; type++) { 96 for(; !tsunami_flash_mtd && *type; type++) {
diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c
index cc372136e852..79d92808b766 100644
--- a/drivers/mtd/maps/uclinux.c
+++ b/drivers/mtd/maps/uclinux.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) 6 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
7 * 7 *
8 * $Id: uclinux.c,v 1.10 2005/01/05 18:05:13 dwmw2 Exp $ 8 * $Id: uclinux.c,v 1.12 2005/11/07 11:14:29 gleixner Exp $
9 */ 9 */
10 10
11/****************************************************************************/ 11/****************************************************************************/
@@ -82,7 +82,7 @@ int __init uclinux_mtd_init(void)
82 iounmap(mapp->virt); 82 iounmap(mapp->virt);
83 return(-ENXIO); 83 return(-ENXIO);
84 } 84 }
85 85
86 mtd->owner = THIS_MODULE; 86 mtd->owner = THIS_MODULE;
87 mtd->point = uclinux_point; 87 mtd->point = uclinux_point;
88 mtd->priv = mapp; 88 mtd->priv = mapp;
diff --git a/drivers/mtd/maps/vmax301.c b/drivers/mtd/maps/vmax301.c
index c8c74110ed1b..e0063941c0df 100644
--- a/drivers/mtd/maps/vmax301.c
+++ b/drivers/mtd/maps/vmax301.c
@@ -1,19 +1,19 @@
1// $Id: vmax301.c,v 1.30 2004/07/12 22:38:29 dwmw2 Exp $ 1// $Id: vmax301.c,v 1.32 2005/11/07 11:14:29 gleixner Exp $
2/* ###################################################################### 2/* ######################################################################
3 3
4 Tempustech VMAX SBC301 MTD Driver. 4 Tempustech VMAX SBC301 MTD Driver.
5 5
6 The VMAx 301 is a SBC based on . It 6 The VMAx 301 is a SBC based on . It
7 comes with three builtin AMD 29F016B flash chips and a socket for SRAM or 7 comes with three builtin AMD 29F016B flash chips and a socket for SRAM or
8 more flash. Each unit has it's own 8k mapping into a settable region 8 more flash. Each unit has it's own 8k mapping into a settable region
9 (0xD8000). There are two 8k mappings for each MTD, the first is always set 9 (0xD8000). There are two 8k mappings for each MTD, the first is always set
10 to the lower 8k of the device the second is paged. Writing a 16 bit page 10 to the lower 8k of the device the second is paged. Writing a 16 bit page
11 value to anywhere in the first 8k will cause the second 8k to page around. 11 value to anywhere in the first 8k will cause the second 8k to page around.
12 12
13 To boot the device a bios extension must be installed into the first 8k 13 To boot the device a bios extension must be installed into the first 8k
14 of flash that is smart enough to copy itself down, page in the rest of 14 of flash that is smart enough to copy itself down, page in the rest of
15 itself and begin executing. 15 itself and begin executing.
16 16
17 ##################################################################### */ 17 ##################################################################### */
18 18
19#include <linux/module.h> 19#include <linux/module.h>
@@ -35,7 +35,7 @@
35/* Actually we could use two spinlocks, but we'd have to have 35/* Actually we could use two spinlocks, but we'd have to have
36 more private space in the struct map_info. We lose a little 36 more private space in the struct map_info. We lose a little
37 performance like this, but we'd probably lose more by having 37 performance like this, but we'd probably lose more by having
38 the extra indirection from having one of the map->map_priv 38 the extra indirection from having one of the map->map_priv
39 fields pointing to yet another private struct. 39 fields pointing to yet another private struct.
40*/ 40*/
41static DEFINE_SPINLOCK(vmax301_spin); 41static DEFINE_SPINLOCK(vmax301_spin);
@@ -98,7 +98,7 @@ static void vmax301_copy_to(struct map_info *map, unsigned long to, const void *
98 spin_lock(&vmax301_spin); 98 spin_lock(&vmax301_spin);
99 vmax301_page(map, to); 99 vmax301_page(map, to);
100 memcpy_toio(map->map_priv_2 + to, from, thislen); 100 memcpy_toio(map->map_priv_2 + to, from, thislen);
101 spin_unlock(&vmax301_spin); 101 spin_unlock(&vmax301_spin);
102 to += thislen; 102 to += thislen;
103 from += thislen; 103 from += thislen;
104 len -= thislen; 104 len -= thislen;
@@ -137,7 +137,7 @@ static struct mtd_info *vmax_mtd[2] = {NULL, NULL};
137static void __exit cleanup_vmax301(void) 137static void __exit cleanup_vmax301(void)
138{ 138{
139 int i; 139 int i;
140 140
141 for (i=0; i<2; i++) { 141 for (i=0; i<2; i++) {
142 if (vmax_mtd[i]) { 142 if (vmax_mtd[i]) {
143 del_mtd_device(vmax_mtd[i]); 143 del_mtd_device(vmax_mtd[i]);
@@ -161,13 +161,13 @@ int __init init_vmax301(void)
161 return -EIO; 161 return -EIO;
162 } 162 }
163 /* Put the address in the map's private data area. 163 /* Put the address in the map's private data area.
164 We store the actual MTD IO address rather than the 164 We store the actual MTD IO address rather than the
165 address of the first half, because it's used more 165 address of the first half, because it's used more
166 often. 166 often.
167 */ 167 */
168 vmax_map[0].map_priv_2 = iomapadr + WINDOW_START; 168 vmax_map[0].map_priv_2 = iomapadr + WINDOW_START;
169 vmax_map[1].map_priv_2 = iomapadr + (3*WINDOW_START); 169 vmax_map[1].map_priv_2 = iomapadr + (3*WINDOW_START);
170 170
171 for (i=0; i<2; i++) { 171 for (i=0; i<2; i++) {
172 vmax_mtd[i] = do_map_probe("cfi_probe", &vmax_map[i]); 172 vmax_mtd[i] = do_map_probe("cfi_probe", &vmax_map[i]);
173 if (!vmax_mtd[i]) 173 if (!vmax_mtd[i])
diff --git a/drivers/mtd/maps/walnut.c b/drivers/mtd/maps/walnut.c
index d6137b1b5670..5c17bca3a37e 100644
--- a/drivers/mtd/maps/walnut.c
+++ b/drivers/mtd/maps/walnut.c
@@ -1,12 +1,12 @@
1/* 1/*
2 * $Id: walnut.c,v 1.2 2004/12/10 12:07:42 holindho Exp $ 2 * $Id: walnut.c,v 1.3 2005/11/07 11:14:29 gleixner Exp $
3 * 3 *
4 * Mapping for Walnut flash 4 * Mapping for Walnut flash
5 * (used ebony.c as a "framework") 5 * (used ebony.c as a "framework")
6 * 6 *
7 * Heikki Lindholm <holindho@infradead.org> 7 * Heikki Lindholm <holindho@infradead.org>
8 * 8 *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your 12 * Free Software Foundation; either version 2 of the License, or (at your
@@ -48,7 +48,7 @@ static struct mtd_partition walnut_partitions[] = {
48 .name = "OpenBIOS", 48 .name = "OpenBIOS",
49 .offset = 0x0, 49 .offset = 0x0,
50 .size = WALNUT_FLASH_SIZE, 50 .size = WALNUT_FLASH_SIZE,
51 /*.mask_flags = MTD_WRITEABLE, */ /* force read-only */ 51 /*.mask_flags = MTD_WRITEABLE, */ /* force read-only */
52 } 52 }
53}; 53};
54 54
@@ -72,11 +72,11 @@ int __init init_walnut(void)
72 printk("The on-board flash is disabled (U79 sw 5)!"); 72 printk("The on-board flash is disabled (U79 sw 5)!");
73 return -EIO; 73 return -EIO;
74 } 74 }
75 if (WALNUT_FLASH_SRAM_SEL(fpga_brds1)) 75 if (WALNUT_FLASH_SRAM_SEL(fpga_brds1))
76 flash_base = WALNUT_FLASH_LOW; 76 flash_base = WALNUT_FLASH_LOW;
77 else 77 else
78 flash_base = WALNUT_FLASH_HIGH; 78 flash_base = WALNUT_FLASH_HIGH;
79 79
80 walnut_map.phys = flash_base; 80 walnut_map.phys = flash_base;
81 walnut_map.virt = 81 walnut_map.virt =
82 (void __iomem *)ioremap(flash_base, walnut_map.size); 82 (void __iomem *)ioremap(flash_base, walnut_map.size);
diff --git a/drivers/mtd/maps/wr_sbc82xx_flash.c b/drivers/mtd/maps/wr_sbc82xx_flash.c
index 82b887b05707..60c197ec455b 100644
--- a/drivers/mtd/maps/wr_sbc82xx_flash.c
+++ b/drivers/mtd/maps/wr_sbc82xx_flash.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: wr_sbc82xx_flash.c,v 1.7 2004/11/04 13:24:15 gleixner Exp $ 2 * $Id: wr_sbc82xx_flash.c,v 1.8 2005/11/07 11:14:29 gleixner Exp $
3 * 3 *
4 * Map for flash chips on Wind River PowerQUICC II SBC82xx board. 4 * Map for flash chips on Wind River PowerQUICC II SBC82xx board.
5 * 5 *
@@ -163,10 +163,10 @@ static void __exit cleanup_sbc82xx_flash(void)
163 del_mtd_partitions(sbcmtd[i]); 163 del_mtd_partitions(sbcmtd[i]);
164 else 164 else
165 del_mtd_device(sbcmtd[i]); 165 del_mtd_device(sbcmtd[i]);
166 166
167 kfree(sbcmtd_parts[i]); 167 kfree(sbcmtd_parts[i]);
168 map_destroy(sbcmtd[i]); 168 map_destroy(sbcmtd[i]);
169 169
170 iounmap((void *)sbc82xx_flash_map[i].virt); 170 iounmap((void *)sbc82xx_flash_map[i].virt);
171 sbc82xx_flash_map[i].virt = 0; 171 sbc82xx_flash_map[i].virt = 0;
172 } 172 }
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index f8d2185819e7..339cb1218eaa 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: mtd_blkdevs.c,v 1.24 2004/11/16 18:28:59 dwmw2 Exp $ 2 * $Id: mtd_blkdevs.c,v 1.27 2005/11/07 11:14:20 gleixner Exp $
3 * 3 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org> 4 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 * 5 *
@@ -21,7 +21,6 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <asm/semaphore.h> 22#include <asm/semaphore.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <linux/devfs_fs_kernel.h>
25 24
26static LIST_HEAD(blktrans_majors); 25static LIST_HEAD(blktrans_majors);
27 26
@@ -86,7 +85,7 @@ static int mtd_blktrans_thread(void *arg)
86 daemonize("%sd", tr->name); 85 daemonize("%sd", tr->name);
87 86
88 /* daemonize() doesn't do this for us since some kernel threads 87 /* daemonize() doesn't do this for us since some kernel threads
89 actually want to deal with signals. We can't just call 88 actually want to deal with signals. We can't just call
90 exit_sighand() since that'll cause an oops when we finally 89 exit_sighand() since that'll cause an oops when we finally
91 do exit. */ 90 do exit. */
92 spin_lock_irq(&current->sighand->siglock); 91 spin_lock_irq(&current->sighand->siglock);
@@ -95,7 +94,7 @@ static int mtd_blktrans_thread(void *arg)
95 spin_unlock_irq(&current->sighand->siglock); 94 spin_unlock_irq(&current->sighand->siglock);
96 95
97 spin_lock_irq(rq->queue_lock); 96 spin_lock_irq(rq->queue_lock);
98 97
99 while (!tr->blkcore_priv->exiting) { 98 while (!tr->blkcore_priv->exiting) {
100 struct request *req; 99 struct request *req;
101 struct mtd_blktrans_dev *dev; 100 struct mtd_blktrans_dev *dev;
@@ -158,7 +157,7 @@ static int blktrans_open(struct inode *i, struct file *f)
158 if (!try_module_get(tr->owner)) 157 if (!try_module_get(tr->owner))
159 goto out_tr; 158 goto out_tr;
160 159
161 /* FIXME: Locking. A hot pluggable device can go away 160 /* FIXME: Locking. A hot pluggable device can go away
162 (del_mtd_device can be called for it) without its module 161 (del_mtd_device can be called for it) without its module
163 being unloaded. */ 162 being unloaded. */
164 dev->mtd->usecount++; 163 dev->mtd->usecount++;
@@ -196,7 +195,7 @@ static int blktrans_release(struct inode *i, struct file *f)
196} 195}
197 196
198 197
199static int blktrans_ioctl(struct inode *inode, struct file *file, 198static int blktrans_ioctl(struct inode *inode, struct file *file,
200 unsigned int cmd, unsigned long arg) 199 unsigned int cmd, unsigned long arg)
201{ 200{
202 struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data; 201 struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data;
@@ -265,7 +264,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
265 /* Required number was free */ 264 /* Required number was free */
266 list_add_tail(&new->list, &d->list); 265 list_add_tail(&new->list, &d->list);
267 goto added; 266 goto added;
268 } 267 }
269 last_devnum = d->devnum; 268 last_devnum = d->devnum;
270 } 269 }
271 if (new->devnum == -1) 270 if (new->devnum == -1)
@@ -289,11 +288,19 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
289 gd->major = tr->major; 288 gd->major = tr->major;
290 gd->first_minor = (new->devnum) << tr->part_bits; 289 gd->first_minor = (new->devnum) << tr->part_bits;
291 gd->fops = &mtd_blktrans_ops; 290 gd->fops = &mtd_blktrans_ops;
292 291
293 snprintf(gd->disk_name, sizeof(gd->disk_name), 292 if (tr->part_bits)
294 "%s%c", tr->name, (tr->part_bits?'a':'0') + new->devnum); 293 if (new->devnum < 26)
295 snprintf(gd->devfs_name, sizeof(gd->devfs_name), 294 snprintf(gd->disk_name, sizeof(gd->disk_name),
296 "%s/%c", tr->name, (tr->part_bits?'a':'0') + new->devnum); 295 "%s%c", tr->name, 'a' + new->devnum);
296 else
297 snprintf(gd->disk_name, sizeof(gd->disk_name),
298 "%s%c%c", tr->name,
299 'a' - 1 + new->devnum / 26,
300 'a' + new->devnum % 26);
301 else
302 snprintf(gd->disk_name, sizeof(gd->disk_name),
303 "%s%d", tr->name, new->devnum);
297 304
298 /* 2.5 has capacity in units of 512 bytes while still 305 /* 2.5 has capacity in units of 512 bytes while still
299 having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */ 306 having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */
@@ -307,7 +314,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
307 set_disk_ro(gd, 1); 314 set_disk_ro(gd, 1);
308 315
309 add_disk(gd); 316 add_disk(gd);
310 317
311 return 0; 318 return 0;
312} 319}
313 320
@@ -322,7 +329,7 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
322 329
323 del_gendisk(old->blkcore_priv); 330 del_gendisk(old->blkcore_priv);
324 put_disk(old->blkcore_priv); 331 put_disk(old->blkcore_priv);
325 332
326 return 0; 333 return 0;
327} 334}
328 335
@@ -361,12 +368,12 @@ static struct mtd_notifier blktrans_notifier = {
361 .add = blktrans_notify_add, 368 .add = blktrans_notify_add,
362 .remove = blktrans_notify_remove, 369 .remove = blktrans_notify_remove,
363}; 370};
364 371
365int register_mtd_blktrans(struct mtd_blktrans_ops *tr) 372int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
366{ 373{
367 int ret, i; 374 int ret, i;
368 375
369 /* Register the notifier if/when the first device type is 376 /* Register the notifier if/when the first device type is
370 registered, to prevent the link/init ordering from fucking 377 registered, to prevent the link/init ordering from fucking
371 us over. */ 378 us over. */
372 if (!blktrans_notifier.list.next) 379 if (!blktrans_notifier.list.next)
@@ -409,9 +416,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
409 kfree(tr->blkcore_priv); 416 kfree(tr->blkcore_priv);
410 up(&mtd_table_mutex); 417 up(&mtd_table_mutex);
411 return ret; 418 return ret;
412 } 419 }
413
414 devfs_mk_dir(tr->name);
415 420
416 INIT_LIST_HEAD(&tr->devs); 421 INIT_LIST_HEAD(&tr->devs);
417 list_add(&tr->list, &blktrans_majors); 422 list_add(&tr->list, &blktrans_majors);
@@ -445,7 +450,6 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
445 tr->remove_dev(dev); 450 tr->remove_dev(dev);
446 } 451 }
447 452
448 devfs_remove(tr->name);
449 blk_cleanup_queue(tr->blkcore_priv->rq); 453 blk_cleanup_queue(tr->blkcore_priv->rq);
450 unregister_blkdev(tr->major, tr->name); 454 unregister_blkdev(tr->major, tr->name);
451 455
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 400dd9c89883..e84756644fd1 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -1,21 +1,22 @@
1/* 1/*
2 * Direct MTD block device access 2 * Direct MTD block device access
3 * 3 *
4 * $Id: mtdblock.c,v 1.66 2004/11/25 13:52:52 joern Exp $ 4 * $Id: mtdblock.c,v 1.68 2005/11/07 11:14:20 gleixner Exp $
5 * 5 *
6 * (C) 2000-2003 Nicolas Pitre <nico@cam.org> 6 * (C) 2000-2003 Nicolas Pitre <nico@cam.org>
7 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> 7 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
8 */ 8 */
9 9
10#include <linux/config.h> 10#include <linux/config.h>
11#include <linux/types.h>
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/fs.h> 11#include <linux/fs.h>
15#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/sched.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/types.h>
17#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
18#include <linux/sched.h> /* TASK_* */ 19
19#include <linux/mtd/mtd.h> 20#include <linux/mtd/mtd.h>
20#include <linux/mtd/blktrans.h> 21#include <linux/mtd/blktrans.h>
21 22
@@ -31,7 +32,7 @@ static struct mtdblk_dev {
31 32
32/* 33/*
33 * Cache stuff... 34 * Cache stuff...
34 * 35 *
35 * Since typical flash erasable sectors are much larger than what Linux's 36 * Since typical flash erasable sectors are much larger than what Linux's
36 * buffer cache can handle, we must implement read-modify-write on flash 37 * buffer cache can handle, we must implement read-modify-write on flash
37 * sectors for each block write requests. To avoid over-erasing flash sectors 38 * sectors for each block write requests. To avoid over-erasing flash sectors
@@ -45,7 +46,7 @@ static void erase_callback(struct erase_info *done)
45 wake_up(wait_q); 46 wake_up(wait_q);
46} 47}
47 48
48static int erase_write (struct mtd_info *mtd, unsigned long pos, 49static int erase_write (struct mtd_info *mtd, unsigned long pos,
49 int len, const char *buf) 50 int len, const char *buf)
50{ 51{
51 struct erase_info erase; 52 struct erase_info erase;
@@ -103,18 +104,18 @@ static int write_cached_data (struct mtdblk_dev *mtdblk)
103 return 0; 104 return 0;
104 105
105 DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: writing cached data for \"%s\" " 106 DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: writing cached data for \"%s\" "
106 "at 0x%lx, size 0x%x\n", mtd->name, 107 "at 0x%lx, size 0x%x\n", mtd->name,
107 mtdblk->cache_offset, mtdblk->cache_size); 108 mtdblk->cache_offset, mtdblk->cache_size);
108 109
109 ret = erase_write (mtd, mtdblk->cache_offset, 110 ret = erase_write (mtd, mtdblk->cache_offset,
110 mtdblk->cache_size, mtdblk->cache_data); 111 mtdblk->cache_size, mtdblk->cache_data);
111 if (ret) 112 if (ret)
112 return ret; 113 return ret;
113 114
114 /* 115 /*
115 * Here we could argubly set the cache state to STATE_CLEAN. 116 * Here we could argubly set the cache state to STATE_CLEAN.
116 * However this could lead to inconsistency since we will not 117 * However this could lead to inconsistency since we will not
117 * be notified if this content is altered on the flash by other 118 * be notified if this content is altered on the flash by other
118 * means. Let's declare it empty and leave buffering tasks to 119 * means. Let's declare it empty and leave buffering tasks to
119 * the buffer cache instead. 120 * the buffer cache instead.
120 */ 121 */
@@ -123,7 +124,7 @@ static int write_cached_data (struct mtdblk_dev *mtdblk)
123} 124}
124 125
125 126
126static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, 127static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
127 int len, const char *buf) 128 int len, const char *buf)
128{ 129{
129 struct mtd_info *mtd = mtdblk->mtd; 130 struct mtd_info *mtd = mtdblk->mtd;
@@ -133,7 +134,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
133 134
134 DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: write on \"%s\" at 0x%lx, size 0x%x\n", 135 DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: write on \"%s\" at 0x%lx, size 0x%x\n",
135 mtd->name, pos, len); 136 mtd->name, pos, len);
136 137
137 if (!sect_size) 138 if (!sect_size)
138 return MTD_WRITE (mtd, pos, len, &retlen, buf); 139 return MTD_WRITE (mtd, pos, len, &retlen, buf);
139 140
@@ -141,11 +142,11 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
141 unsigned long sect_start = (pos/sect_size)*sect_size; 142 unsigned long sect_start = (pos/sect_size)*sect_size;
142 unsigned int offset = pos - sect_start; 143 unsigned int offset = pos - sect_start;
143 unsigned int size = sect_size - offset; 144 unsigned int size = sect_size - offset;
144 if( size > len ) 145 if( size > len )
145 size = len; 146 size = len;
146 147
147 if (size == sect_size) { 148 if (size == sect_size) {
148 /* 149 /*
149 * We are covering a whole sector. Thus there is no 150 * We are covering a whole sector. Thus there is no
150 * need to bother with the cache while it may still be 151 * need to bother with the cache while it may still be
151 * useful for other partial writes. 152 * useful for other partial writes.
@@ -159,7 +160,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
159 if (mtdblk->cache_state == STATE_DIRTY && 160 if (mtdblk->cache_state == STATE_DIRTY &&
160 mtdblk->cache_offset != sect_start) { 161 mtdblk->cache_offset != sect_start) {
161 ret = write_cached_data(mtdblk); 162 ret = write_cached_data(mtdblk);
162 if (ret) 163 if (ret)
163 return ret; 164 return ret;
164 } 165 }
165 166
@@ -192,7 +193,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
192} 193}
193 194
194 195
195static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, 196static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
196 int len, char *buf) 197 int len, char *buf)
197{ 198{
198 struct mtd_info *mtd = mtdblk->mtd; 199 struct mtd_info *mtd = mtdblk->mtd;
@@ -200,9 +201,9 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
200 size_t retlen; 201 size_t retlen;
201 int ret; 202 int ret;
202 203
203 DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n", 204 DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n",
204 mtd->name, pos, len); 205 mtd->name, pos, len);
205 206
206 if (!sect_size) 207 if (!sect_size)
207 return MTD_READ (mtd, pos, len, &retlen, buf); 208 return MTD_READ (mtd, pos, len, &retlen, buf);
208 209
@@ -210,7 +211,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
210 unsigned long sect_start = (pos/sect_size)*sect_size; 211 unsigned long sect_start = (pos/sect_size)*sect_size;
211 unsigned int offset = pos - sect_start; 212 unsigned int offset = pos - sect_start;
212 unsigned int size = sect_size - offset; 213 unsigned int size = sect_size - offset;
213 if (size > len) 214 if (size > len)
214 size = len; 215 size = len;
215 216
216 /* 217 /*
@@ -268,12 +269,12 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
268 int dev = mbd->devnum; 269 int dev = mbd->devnum;
269 270
270 DEBUG(MTD_DEBUG_LEVEL1,"mtdblock_open\n"); 271 DEBUG(MTD_DEBUG_LEVEL1,"mtdblock_open\n");
271 272
272 if (mtdblks[dev]) { 273 if (mtdblks[dev]) {
273 mtdblks[dev]->count++; 274 mtdblks[dev]->count++;
274 return 0; 275 return 0;
275 } 276 }
276 277
277 /* OK, it's not open. Create cache info for it */ 278 /* OK, it's not open. Create cache info for it */
278 mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); 279 mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
279 if (!mtdblk) 280 if (!mtdblk)
@@ -292,7 +293,7 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
292 } 293 }
293 294
294 mtdblks[dev] = mtdblk; 295 mtdblks[dev] = mtdblk;
295 296
296 DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); 297 DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
297 298
298 return 0; 299 return 0;
@@ -320,7 +321,7 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
320 DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); 321 DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
321 322
322 return 0; 323 return 0;
323} 324}
324 325
325static int mtdblock_flush(struct mtd_blktrans_dev *dev) 326static int mtdblock_flush(struct mtd_blktrans_dev *dev)
326{ 327{
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 16df1e4fb0e9..6f044584bdc6 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1,22 +1,23 @@
1/* 1/*
2 * $Id: mtdchar.c,v 1.73 2005/07/04 17:36:41 gleixner Exp $ 2 * $Id: mtdchar.c,v 1.76 2005/11/07 11:14:20 gleixner Exp $
3 * 3 *
4 * Character-device access to raw MTD devices. 4 * Character-device access to raw MTD devices.
5 * 5 *
6 */ 6 */
7 7
8#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/device.h>
10#include <linux/fs.h>
11#include <linux/init.h>
9#include <linux/kernel.h> 12#include <linux/kernel.h>
10#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/slab.h>
15#include <linux/sched.h>
16
11#include <linux/mtd/mtd.h> 17#include <linux/mtd/mtd.h>
12#include <linux/mtd/compatmac.h> 18#include <linux/mtd/compatmac.h>
13#include <linux/slab.h>
14#include <linux/init.h>
15#include <linux/fs.h>
16#include <linux/sched.h> /* TASK_* */
17#include <asm/uaccess.h>
18 19
19#include <linux/device.h> 20#include <asm/uaccess.h>
20 21
21static struct class *mtd_class; 22static struct class *mtd_class;
22 23
@@ -27,7 +28,7 @@ static void mtd_notify_add(struct mtd_info* mtd)
27 28
28 class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), 29 class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
29 NULL, "mtd%d", mtd->index); 30 NULL, "mtd%d", mtd->index);
30 31
31 class_device_create(mtd_class, NULL, 32 class_device_create(mtd_class, NULL,
32 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), 33 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
33 NULL, "mtd%dro", mtd->index); 34 NULL, "mtd%dro", mtd->index);
@@ -70,26 +71,23 @@ static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
70 switch (orig) { 71 switch (orig) {
71 case 0: 72 case 0:
72 /* SEEK_SET */ 73 /* SEEK_SET */
73 file->f_pos = offset;
74 break; 74 break;
75 case 1: 75 case 1:
76 /* SEEK_CUR */ 76 /* SEEK_CUR */
77 file->f_pos += offset; 77 offset += file->f_pos;
78 break; 78 break;
79 case 2: 79 case 2:
80 /* SEEK_END */ 80 /* SEEK_END */
81 file->f_pos =mtd->size + offset; 81 offset += mtd->size;
82 break; 82 break;
83 default: 83 default:
84 return -EINVAL; 84 return -EINVAL;
85 } 85 }
86 86
87 if (file->f_pos < 0) 87 if (offset >= 0 && offset < mtd->size)
88 file->f_pos = 0; 88 return file->f_pos = offset;
89 else if (file->f_pos >= mtd->size)
90 file->f_pos = mtd->size - 1;
91 89
92 return file->f_pos; 90 return -EINVAL;
93} 91}
94 92
95 93
@@ -110,23 +108,23 @@ static int mtd_open(struct inode *inode, struct file *file)
110 return -EACCES; 108 return -EACCES;
111 109
112 mtd = get_mtd_device(NULL, devnum); 110 mtd = get_mtd_device(NULL, devnum);
113 111
114 if (!mtd) 112 if (!mtd)
115 return -ENODEV; 113 return -ENODEV;
116 114
117 if (MTD_ABSENT == mtd->type) { 115 if (MTD_ABSENT == mtd->type) {
118 put_mtd_device(mtd); 116 put_mtd_device(mtd);
119 return -ENODEV; 117 return -ENODEV;
120 } 118 }
121 119
122 file->private_data = mtd; 120 file->private_data = mtd;
123 121
124 /* You can't open it RW if it's not a writeable device */ 122 /* You can't open it RW if it's not a writeable device */
125 if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { 123 if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
126 put_mtd_device(mtd); 124 put_mtd_device(mtd);
127 return -EACCES; 125 return -EACCES;
128 } 126 }
129 127
130 return 0; 128 return 0;
131} /* mtd_open */ 129} /* mtd_open */
132 130
@@ -139,10 +137,10 @@ static int mtd_close(struct inode *inode, struct file *file)
139 DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n"); 137 DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");
140 138
141 mtd = TO_MTD(file); 139 mtd = TO_MTD(file);
142 140
143 if (mtd->sync) 141 if (mtd->sync)
144 mtd->sync(mtd); 142 mtd->sync(mtd);
145 143
146 put_mtd_device(mtd); 144 put_mtd_device(mtd);
147 145
148 return 0; 146 return 0;
@@ -161,7 +159,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
161 int ret=0; 159 int ret=0;
162 int len; 160 int len;
163 char *kbuf; 161 char *kbuf;
164 162
165 DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n"); 163 DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n");
166 164
167 if (*ppos + count > mtd->size) 165 if (*ppos + count > mtd->size)
@@ -169,11 +167,11 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
169 167
170 if (!count) 168 if (!count)
171 return 0; 169 return 0;
172 170
173 /* FIXME: Use kiovec in 2.5 to lock down the user's buffers 171 /* FIXME: Use kiovec in 2.5 to lock down the user's buffers
174 and pass them directly to the MTD functions */ 172 and pass them directly to the MTD functions */
175 while (count) { 173 while (count) {
176 if (count > MAX_KMALLOC_SIZE) 174 if (count > MAX_KMALLOC_SIZE)
177 len = MAX_KMALLOC_SIZE; 175 len = MAX_KMALLOC_SIZE;
178 else 176 else
179 len = count; 177 len = count;
@@ -181,7 +179,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
181 kbuf=kmalloc(len,GFP_KERNEL); 179 kbuf=kmalloc(len,GFP_KERNEL);
182 if (!kbuf) 180 if (!kbuf)
183 return -ENOMEM; 181 return -ENOMEM;
184 182
185 switch (MTD_MODE(file)) { 183 switch (MTD_MODE(file)) {
186 case MTD_MODE_OTP_FACT: 184 case MTD_MODE_OTP_FACT:
187 ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf); 185 ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf);
@@ -194,7 +192,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
194 } 192 }
195 /* Nand returns -EBADMSG on ecc errors, but it returns 193 /* Nand returns -EBADMSG on ecc errors, but it returns
196 * the data. For our userspace tools it is important 194 * the data. For our userspace tools it is important
197 * to dump areas with ecc errors ! 195 * to dump areas with ecc errors !
198 * Userspace software which accesses NAND this way 196 * Userspace software which accesses NAND this way
199 * must be aware of the fact that it deals with NAND 197 * must be aware of the fact that it deals with NAND
200 */ 198 */
@@ -216,7 +214,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
216 kfree(kbuf); 214 kfree(kbuf);
217 return ret; 215 return ret;
218 } 216 }
219 217
220 kfree(kbuf); 218 kfree(kbuf);
221 } 219 }
222 220
@@ -233,10 +231,10 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
233 int len; 231 int len;
234 232
235 DEBUG(MTD_DEBUG_LEVEL0,"MTD_write\n"); 233 DEBUG(MTD_DEBUG_LEVEL0,"MTD_write\n");
236 234
237 if (*ppos == mtd->size) 235 if (*ppos == mtd->size)
238 return -ENOSPC; 236 return -ENOSPC;
239 237
240 if (*ppos + count > mtd->size) 238 if (*ppos + count > mtd->size)
241 count = mtd->size - *ppos; 239 count = mtd->size - *ppos;
242 240
@@ -244,7 +242,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
244 return 0; 242 return 0;
245 243
246 while (count) { 244 while (count) {
247 if (count > MAX_KMALLOC_SIZE) 245 if (count > MAX_KMALLOC_SIZE)
248 len = MAX_KMALLOC_SIZE; 246 len = MAX_KMALLOC_SIZE;
249 else 247 else
250 len = count; 248 len = count;
@@ -259,7 +257,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
259 kfree(kbuf); 257 kfree(kbuf);
260 return -EFAULT; 258 return -EFAULT;
261 } 259 }
262 260
263 switch (MTD_MODE(file)) { 261 switch (MTD_MODE(file)) {
264 case MTD_MODE_OTP_FACT: 262 case MTD_MODE_OTP_FACT:
265 ret = -EROFS; 263 ret = -EROFS;
@@ -284,7 +282,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
284 kfree(kbuf); 282 kfree(kbuf);
285 return ret; 283 return ret;
286 } 284 }
287 285
288 kfree(kbuf); 286 kfree(kbuf);
289 } 287 }
290 288
@@ -308,7 +306,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
308 void __user *argp = (void __user *)arg; 306 void __user *argp = (void __user *)arg;
309 int ret = 0; 307 int ret = 0;
310 u_long size; 308 u_long size;
311 309
312 DEBUG(MTD_DEBUG_LEVEL0, "MTD_ioctl\n"); 310 DEBUG(MTD_DEBUG_LEVEL0, "MTD_ioctl\n");
313 311
314 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; 312 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
@@ -320,7 +318,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
320 if (!access_ok(VERIFY_WRITE, argp, size)) 318 if (!access_ok(VERIFY_WRITE, argp, size))
321 return -EFAULT; 319 return -EFAULT;
322 } 320 }
323 321
324 switch (cmd) { 322 switch (cmd) {
325 case MEMGETREGIONCOUNT: 323 case MEMGETREGIONCOUNT:
326 if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int))) 324 if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int)))
@@ -372,11 +370,11 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
372 erase->mtd = mtd; 370 erase->mtd = mtd;
373 erase->callback = mtdchar_erase_callback; 371 erase->callback = mtdchar_erase_callback;
374 erase->priv = (unsigned long)&waitq; 372 erase->priv = (unsigned long)&waitq;
375 373
376 /* 374 /*
377 FIXME: Allow INTERRUPTIBLE. Which means 375 FIXME: Allow INTERRUPTIBLE. Which means
378 not having the wait_queue head on the stack. 376 not having the wait_queue head on the stack.
379 377
380 If the wq_head is on the stack, and we 378 If the wq_head is on the stack, and we
381 leave because we got interrupted, then the 379 leave because we got interrupted, then the
382 wq_head is no longer there when the 380 wq_head is no longer there when the
@@ -404,13 +402,13 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
404 struct mtd_oob_buf buf; 402 struct mtd_oob_buf buf;
405 void *databuf; 403 void *databuf;
406 ssize_t retlen; 404 ssize_t retlen;
407 405
408 if(!(file->f_mode & 2)) 406 if(!(file->f_mode & 2))
409 return -EPERM; 407 return -EPERM;
410 408
411 if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf))) 409 if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
412 return -EFAULT; 410 return -EFAULT;
413 411
414 if (buf.length > 0x4096) 412 if (buf.length > 0x4096)
415 return -EINVAL; 413 return -EINVAL;
416 414
@@ -426,7 +424,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
426 databuf = kmalloc(buf.length, GFP_KERNEL); 424 databuf = kmalloc(buf.length, GFP_KERNEL);
427 if (!databuf) 425 if (!databuf)
428 return -ENOMEM; 426 return -ENOMEM;
429 427
430 if (copy_from_user(databuf, buf.ptr, buf.length)) { 428 if (copy_from_user(databuf, buf.ptr, buf.length)) {
431 kfree(databuf); 429 kfree(databuf);
432 return -EFAULT; 430 return -EFAULT;
@@ -450,7 +448,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
450 448
451 if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf))) 449 if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
452 return -EFAULT; 450 return -EFAULT;
453 451
454 if (buf.length > 0x4096) 452 if (buf.length > 0x4096)
455 return -EINVAL; 453 return -EINVAL;
456 454
@@ -466,14 +464,14 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
466 databuf = kmalloc(buf.length, GFP_KERNEL); 464 databuf = kmalloc(buf.length, GFP_KERNEL);
467 if (!databuf) 465 if (!databuf)
468 return -ENOMEM; 466 return -ENOMEM;
469 467
470 ret = (mtd->read_oob)(mtd, buf.start, buf.length, &retlen, databuf); 468 ret = (mtd->read_oob)(mtd, buf.start, buf.length, &retlen, databuf);
471 469
472 if (put_user(retlen, (uint32_t __user *)argp)) 470 if (put_user(retlen, (uint32_t __user *)argp))
473 ret = -EFAULT; 471 ret = -EFAULT;
474 else if (retlen && copy_to_user(buf.ptr, databuf, retlen)) 472 else if (retlen && copy_to_user(buf.ptr, databuf, retlen))
475 ret = -EFAULT; 473 ret = -EFAULT;
476 474
477 kfree(databuf); 475 kfree(databuf);
478 break; 476 break;
479 } 477 }
@@ -523,7 +521,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
523 case MEMGETBADBLOCK: 521 case MEMGETBADBLOCK:
524 { 522 {
525 loff_t offs; 523 loff_t offs;
526 524
527 if (copy_from_user(&offs, argp, sizeof(loff_t))) 525 if (copy_from_user(&offs, argp, sizeof(loff_t)))
528 return -EFAULT; 526 return -EFAULT;
529 if (!mtd->block_isbad) 527 if (!mtd->block_isbad)
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index f3e65af33a9c..b1bf8c411de7 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -7,14 +7,15 @@
7 * 7 *
8 * This code is GPL 8 * This code is GPL
9 * 9 *
10 * $Id: mtdconcat.c,v 1.9 2004/06/30 15:17:41 dbrown Exp $ 10 * $Id: mtdconcat.c,v 1.11 2005/11/07 11:14:20 gleixner Exp $
11 */ 11 */
12 12
13#include <linux/module.h>
14#include <linux/types.h>
15#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h>
16#include <linux/slab.h> 15#include <linux/slab.h>
17#include <linux/sched.h> /* TASK_* */ 16#include <linux/sched.h>
17#include <linux/types.h>
18
18#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
19#include <linux/mtd/concat.h> 20#include <linux/mtd/concat.h>
20 21
@@ -43,7 +44,7 @@ struct mtd_concat {
43 */ 44 */
44#define CONCAT(x) ((struct mtd_concat *)(x)) 45#define CONCAT(x) ((struct mtd_concat *)(x))
45 46
46/* 47/*
47 * MTD methods which look up the relevant subdevice, translate the 48 * MTD methods which look up the relevant subdevice, translate the
48 * effective address and pass through to the subdevice. 49 * effective address and pass through to the subdevice.
49 */ 50 */
@@ -877,7 +878,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
877 return &concat->mtd; 878 return &concat->mtd;
878} 879}
879 880
880/* 881/*
881 * This function destroys an MTD object obtained from concat_mtd_devs() 882 * This function destroys an MTD object obtained from concat_mtd_devs()
882 */ 883 */
883 884
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index dc86df18e94b..dade02ab0687 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: mtdcore.c,v 1.45 2005/02/18 14:34:50 dedekind Exp $ 2 * $Id: mtdcore.c,v 1.47 2005/11/07 11:14:20 gleixner Exp $
3 * 3 *
4 * Core registration and callback routines for MTD 4 * Core registration and callback routines for MTD
5 * drivers and users. 5 * drivers and users.
@@ -25,7 +25,7 @@
25 25
26#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
27 27
28/* These are exported solely for the purpose of mtd_blkdevs.c. You 28/* These are exported solely for the purpose of mtd_blkdevs.c. You
29 should not use them for _anything_ else */ 29 should not use them for _anything_ else */
30DECLARE_MUTEX(mtd_table_mutex); 30DECLARE_MUTEX(mtd_table_mutex);
31struct mtd_info *mtd_table[MAX_MTD_DEVICES]; 31struct mtd_info *mtd_table[MAX_MTD_DEVICES];
@@ -66,7 +66,7 @@ int add_mtd_device(struct mtd_info *mtd)
66 struct mtd_notifier *not = list_entry(this, struct mtd_notifier, list); 66 struct mtd_notifier *not = list_entry(this, struct mtd_notifier, list);
67 not->add(mtd); 67 not->add(mtd);
68 } 68 }
69 69
70 up(&mtd_table_mutex); 70 up(&mtd_table_mutex);
71 /* We _know_ we aren't being removed, because 71 /* We _know_ we aren't being removed, because
72 our caller is still holding us here. So none 72 our caller is still holding us here. So none
@@ -75,7 +75,7 @@ int add_mtd_device(struct mtd_info *mtd)
75 __module_get(THIS_MODULE); 75 __module_get(THIS_MODULE);
76 return 0; 76 return 0;
77 } 77 }
78 78
79 up(&mtd_table_mutex); 79 up(&mtd_table_mutex);
80 return 1; 80 return 1;
81} 81}
@@ -93,13 +93,13 @@ int add_mtd_device(struct mtd_info *mtd)
93int del_mtd_device (struct mtd_info *mtd) 93int del_mtd_device (struct mtd_info *mtd)
94{ 94{
95 int ret; 95 int ret;
96 96
97 down(&mtd_table_mutex); 97 down(&mtd_table_mutex);
98 98
99 if (mtd_table[mtd->index] != mtd) { 99 if (mtd_table[mtd->index] != mtd) {
100 ret = -ENODEV; 100 ret = -ENODEV;
101 } else if (mtd->usecount) { 101 } else if (mtd->usecount) {
102 printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n", 102 printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n",
103 mtd->index, mtd->name, mtd->usecount); 103 mtd->index, mtd->name, mtd->usecount);
104 ret = -EBUSY; 104 ret = -EBUSY;
105 } else { 105 } else {
@@ -140,7 +140,7 @@ void register_mtd_user (struct mtd_notifier *new)
140 list_add(&new->list, &mtd_notifiers); 140 list_add(&new->list, &mtd_notifiers);
141 141
142 __module_get(THIS_MODULE); 142 __module_get(THIS_MODULE);
143 143
144 for (i=0; i< MAX_MTD_DEVICES; i++) 144 for (i=0; i< MAX_MTD_DEVICES; i++)
145 if (mtd_table[i]) 145 if (mtd_table[i])
146 new->add(mtd_table[i]); 146 new->add(mtd_table[i]);
@@ -169,7 +169,7 @@ int unregister_mtd_user (struct mtd_notifier *old)
169 for (i=0; i< MAX_MTD_DEVICES; i++) 169 for (i=0; i< MAX_MTD_DEVICES; i++)
170 if (mtd_table[i]) 170 if (mtd_table[i])
171 old->remove(mtd_table[i]); 171 old->remove(mtd_table[i]);
172 172
173 list_del(&old->list); 173 list_del(&old->list);
174 up(&mtd_table_mutex); 174 up(&mtd_table_mutex);
175 return 0; 175 return 0;
@@ -187,7 +187,7 @@ int unregister_mtd_user (struct mtd_notifier *old)
187 * both, return the num'th driver only if its address matches. Return NULL 187 * both, return the num'th driver only if its address matches. Return NULL
188 * if not. 188 * if not.
189 */ 189 */
190 190
191struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) 191struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
192{ 192{
193 struct mtd_info *ret = NULL; 193 struct mtd_info *ret = NULL;
@@ -297,39 +297,6 @@ EXPORT_SYMBOL(default_mtd_writev);
297EXPORT_SYMBOL(default_mtd_readv); 297EXPORT_SYMBOL(default_mtd_readv);
298 298
299/*====================================================================*/ 299/*====================================================================*/
300/* Power management code */
301
302#ifdef CONFIG_PM
303
304#include <linux/pm.h>
305
306static struct pm_dev *mtd_pm_dev = NULL;
307
308static int mtd_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data)
309{
310 int ret = 0, i;
311
312 if (down_trylock(&mtd_table_mutex))
313 return -EAGAIN;
314 if (rqst == PM_SUSPEND) {
315 for (i = 0; ret == 0 && i < MAX_MTD_DEVICES; i++) {
316 if (mtd_table[i] && mtd_table[i]->suspend)
317 ret = mtd_table[i]->suspend(mtd_table[i]);
318 }
319 } else i = MAX_MTD_DEVICES-1;
320
321 if (rqst == PM_RESUME || ret) {
322 for ( ; i >= 0; i--) {
323 if (mtd_table[i] && mtd_table[i]->resume)
324 mtd_table[i]->resume(mtd_table[i]);
325 }
326 }
327 up(&mtd_table_mutex);
328 return ret;
329}
330#endif
331
332/*====================================================================*/
333/* Support for /proc/mtd */ 300/* Support for /proc/mtd */
334 301
335#ifdef CONFIG_PROC_FS 302#ifdef CONFIG_PROC_FS
@@ -388,22 +355,11 @@ static int __init init_mtd(void)
388 if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) 355 if ((proc_mtd = create_proc_entry( "mtd", 0, NULL )))
389 proc_mtd->read_proc = mtd_read_proc; 356 proc_mtd->read_proc = mtd_read_proc;
390#endif 357#endif
391
392#ifdef CONFIG_PM
393 mtd_pm_dev = pm_register(PM_UNKNOWN_DEV, 0, mtd_pm_callback);
394#endif
395 return 0; 358 return 0;
396} 359}
397 360
398static void __exit cleanup_mtd(void) 361static void __exit cleanup_mtd(void)
399{ 362{
400#ifdef CONFIG_PM
401 if (mtd_pm_dev) {
402 pm_unregister(mtd_pm_dev);
403 mtd_pm_dev = NULL;
404 }
405#endif
406
407#ifdef CONFIG_PROC_FS 363#ifdef CONFIG_PROC_FS
408 if (proc_mtd) 364 if (proc_mtd)
409 remove_proc_entry( "mtd", NULL); 365 remove_proc_entry( "mtd", NULL);
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index b92e6bfffaf2..99395911d26f 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -5,11 +5,11 @@
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 * 7 *
8 * $Id: mtdpart.c,v 1.53 2005/02/08 17:11:13 nico Exp $ 8 * $Id: mtdpart.c,v 1.55 2005/11/07 11:14:20 gleixner Exp $
9 * 9 *
10 * 02-21-2002 Thomas Gleixner <gleixner@autronix.de> 10 * 02-21-2002 Thomas Gleixner <gleixner@autronix.de>
11 * added support for read_oob, write_oob 11 * added support for read_oob, write_oob
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/types.h> 15#include <linux/types.h>
@@ -41,13 +41,13 @@ struct mtd_part {
41 */ 41 */
42#define PART(x) ((struct mtd_part *)(x)) 42#define PART(x) ((struct mtd_part *)(x))
43 43
44 44
45/* 45/*
46 * MTD methods which simply translate the effective address and pass through 46 * MTD methods which simply translate the effective address and pass through
47 * to the _real_ device. 47 * to the _real_ device.
48 */ 48 */
49 49
50static int part_read (struct mtd_info *mtd, loff_t from, size_t len, 50static int part_read (struct mtd_info *mtd, loff_t from, size_t len,
51 size_t *retlen, u_char *buf) 51 size_t *retlen, u_char *buf)
52{ 52{
53 struct mtd_part *part = PART(mtd); 53 struct mtd_part *part = PART(mtd);
@@ -55,15 +55,15 @@ static int part_read (struct mtd_info *mtd, loff_t from, size_t len,
55 len = 0; 55 len = 0;
56 else if (from + len > mtd->size) 56 else if (from + len > mtd->size)
57 len = mtd->size - from; 57 len = mtd->size - from;
58 if (part->master->read_ecc == NULL) 58 if (part->master->read_ecc == NULL)
59 return part->master->read (part->master, from + part->offset, 59 return part->master->read (part->master, from + part->offset,
60 len, retlen, buf); 60 len, retlen, buf);
61 else 61 else
62 return part->master->read_ecc (part->master, from + part->offset, 62 return part->master->read_ecc (part->master, from + part->offset,
63 len, retlen, buf, NULL, &mtd->oobinfo); 63 len, retlen, buf, NULL, &mtd->oobinfo);
64} 64}
65 65
66static int part_point (struct mtd_info *mtd, loff_t from, size_t len, 66static int part_point (struct mtd_info *mtd, loff_t from, size_t len,
67 size_t *retlen, u_char **buf) 67 size_t *retlen, u_char **buf)
68{ 68{
69 struct mtd_part *part = PART(mtd); 69 struct mtd_part *part = PART(mtd);
@@ -71,7 +71,7 @@ static int part_point (struct mtd_info *mtd, loff_t from, size_t len,
71 len = 0; 71 len = 0;
72 else if (from + len > mtd->size) 72 else if (from + len > mtd->size)
73 len = mtd->size - from; 73 len = mtd->size - from;
74 return part->master->point (part->master, from + part->offset, 74 return part->master->point (part->master, from + part->offset,
75 len, retlen, buf); 75 len, retlen, buf);
76} 76}
77static void part_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, size_t len) 77static void part_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, size_t len)
@@ -82,7 +82,7 @@ static void part_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, size_
82} 82}
83 83
84 84
85static int part_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, 85static int part_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
86 size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel) 86 size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel)
87{ 87{
88 struct mtd_part *part = PART(mtd); 88 struct mtd_part *part = PART(mtd);
@@ -92,11 +92,11 @@ static int part_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
92 len = 0; 92 len = 0;
93 else if (from + len > mtd->size) 93 else if (from + len > mtd->size)
94 len = mtd->size - from; 94 len = mtd->size - from;
95 return part->master->read_ecc (part->master, from + part->offset, 95 return part->master->read_ecc (part->master, from + part->offset,
96 len, retlen, buf, eccbuf, oobsel); 96 len, retlen, buf, eccbuf, oobsel);
97} 97}
98 98
99static int part_read_oob (struct mtd_info *mtd, loff_t from, size_t len, 99static int part_read_oob (struct mtd_info *mtd, loff_t from, size_t len,
100 size_t *retlen, u_char *buf) 100 size_t *retlen, u_char *buf)
101{ 101{
102 struct mtd_part *part = PART(mtd); 102 struct mtd_part *part = PART(mtd);
@@ -104,15 +104,15 @@ static int part_read_oob (struct mtd_info *mtd, loff_t from, size_t len,
104 len = 0; 104 len = 0;
105 else if (from + len > mtd->size) 105 else if (from + len > mtd->size)
106 len = mtd->size - from; 106 len = mtd->size - from;
107 return part->master->read_oob (part->master, from + part->offset, 107 return part->master->read_oob (part->master, from + part->offset,
108 len, retlen, buf); 108 len, retlen, buf);
109} 109}
110 110
111static int part_read_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, 111static int part_read_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len,
112 size_t *retlen, u_char *buf) 112 size_t *retlen, u_char *buf)
113{ 113{
114 struct mtd_part *part = PART(mtd); 114 struct mtd_part *part = PART(mtd);
115 return part->master->read_user_prot_reg (part->master, from, 115 return part->master->read_user_prot_reg (part->master, from,
116 len, retlen, buf); 116 len, retlen, buf);
117} 117}
118 118
@@ -123,11 +123,11 @@ static int part_get_user_prot_info (struct mtd_info *mtd,
123 return part->master->get_user_prot_info (part->master, buf, len); 123 return part->master->get_user_prot_info (part->master, buf, len);
124} 124}
125 125
126static int part_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, 126static int part_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t len,
127 size_t *retlen, u_char *buf) 127 size_t *retlen, u_char *buf)
128{ 128{
129 struct mtd_part *part = PART(mtd); 129 struct mtd_part *part = PART(mtd);
130 return part->master->read_fact_prot_reg (part->master, from, 130 return part->master->read_fact_prot_reg (part->master, from,
131 len, retlen, buf); 131 len, retlen, buf);
132} 132}
133 133
@@ -148,13 +148,13 @@ static int part_write (struct mtd_info *mtd, loff_t to, size_t len,
148 len = 0; 148 len = 0;
149 else if (to + len > mtd->size) 149 else if (to + len > mtd->size)
150 len = mtd->size - to; 150 len = mtd->size - to;
151 if (part->master->write_ecc == NULL) 151 if (part->master->write_ecc == NULL)
152 return part->master->write (part->master, to + part->offset, 152 return part->master->write (part->master, to + part->offset,
153 len, retlen, buf); 153 len, retlen, buf);
154 else 154 else
155 return part->master->write_ecc (part->master, to + part->offset, 155 return part->master->write_ecc (part->master, to + part->offset,
156 len, retlen, buf, NULL, &mtd->oobinfo); 156 len, retlen, buf, NULL, &mtd->oobinfo);
157 157
158} 158}
159 159
160static int part_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, 160static int part_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
@@ -170,7 +170,7 @@ static int part_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
170 len = 0; 170 len = 0;
171 else if (to + len > mtd->size) 171 else if (to + len > mtd->size)
172 len = mtd->size - to; 172 len = mtd->size - to;
173 return part->master->write_ecc (part->master, to + part->offset, 173 return part->master->write_ecc (part->master, to + part->offset,
174 len, retlen, buf, eccbuf, oobsel); 174 len, retlen, buf, eccbuf, oobsel);
175} 175}
176 176
@@ -184,19 +184,19 @@ static int part_write_oob (struct mtd_info *mtd, loff_t to, size_t len,
184 len = 0; 184 len = 0;
185 else if (to + len > mtd->size) 185 else if (to + len > mtd->size)
186 len = mtd->size - to; 186 len = mtd->size - to;
187 return part->master->write_oob (part->master, to + part->offset, 187 return part->master->write_oob (part->master, to + part->offset,
188 len, retlen, buf); 188 len, retlen, buf);
189} 189}
190 190
191static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, 191static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len,
192 size_t *retlen, u_char *buf) 192 size_t *retlen, u_char *buf)
193{ 193{
194 struct mtd_part *part = PART(mtd); 194 struct mtd_part *part = PART(mtd);
195 return part->master->write_user_prot_reg (part->master, from, 195 return part->master->write_user_prot_reg (part->master, from,
196 len, retlen, buf); 196 len, retlen, buf);
197} 197}
198 198
199static int part_lock_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len) 199static int part_lock_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len)
200{ 200{
201 struct mtd_part *part = PART(mtd); 201 struct mtd_part *part = PART(mtd);
202 return part->master->lock_user_prot_reg (part->master, from, len); 202 return part->master->lock_user_prot_reg (part->master, from, len);
@@ -208,7 +208,7 @@ static int part_writev (struct mtd_info *mtd, const struct kvec *vecs,
208 struct mtd_part *part = PART(mtd); 208 struct mtd_part *part = PART(mtd);
209 if (!(mtd->flags & MTD_WRITEABLE)) 209 if (!(mtd->flags & MTD_WRITEABLE))
210 return -EROFS; 210 return -EROFS;
211 if (part->master->writev_ecc == NULL) 211 if (part->master->writev_ecc == NULL)
212 return part->master->writev (part->master, vecs, count, 212 return part->master->writev (part->master, vecs, count,
213 to + part->offset, retlen); 213 to + part->offset, retlen);
214 else 214 else
@@ -221,12 +221,12 @@ static int part_readv (struct mtd_info *mtd, struct kvec *vecs,
221 unsigned long count, loff_t from, size_t *retlen) 221 unsigned long count, loff_t from, size_t *retlen)
222{ 222{
223 struct mtd_part *part = PART(mtd); 223 struct mtd_part *part = PART(mtd);
224 if (part->master->readv_ecc == NULL) 224 if (part->master->readv_ecc == NULL)
225 return part->master->readv (part->master, vecs, count, 225 return part->master->readv (part->master, vecs, count,
226 from + part->offset, retlen); 226 from + part->offset, retlen);
227 else 227 else
228 return part->master->readv_ecc (part->master, vecs, count, 228 return part->master->readv_ecc (part->master, vecs, count,
229 from + part->offset, retlen, 229 from + part->offset, retlen,
230 NULL, &mtd->oobinfo); 230 NULL, &mtd->oobinfo);
231} 231}
232 232
@@ -252,7 +252,7 @@ static int part_readv_ecc (struct mtd_info *mtd, struct kvec *vecs,
252 if (oobsel == NULL) 252 if (oobsel == NULL)
253 oobsel = &mtd->oobinfo; 253 oobsel = &mtd->oobinfo;
254 return part->master->readv_ecc (part->master, vecs, count, 254 return part->master->readv_ecc (part->master, vecs, count,
255 from + part->offset, retlen, 255 from + part->offset, retlen,
256 eccbuf, oobsel); 256 eccbuf, oobsel);
257} 257}
258 258
@@ -286,7 +286,7 @@ EXPORT_SYMBOL_GPL(mtd_erase_callback);
286static int part_lock (struct mtd_info *mtd, loff_t ofs, size_t len) 286static int part_lock (struct mtd_info *mtd, loff_t ofs, size_t len)
287{ 287{
288 struct mtd_part *part = PART(mtd); 288 struct mtd_part *part = PART(mtd);
289 if ((len + ofs) > mtd->size) 289 if ((len + ofs) > mtd->size)
290 return -EINVAL; 290 return -EINVAL;
291 return part->master->lock(part->master, ofs + part->offset, len); 291 return part->master->lock(part->master, ofs + part->offset, len);
292} 292}
@@ -294,7 +294,7 @@ static int part_lock (struct mtd_info *mtd, loff_t ofs, size_t len)
294static int part_unlock (struct mtd_info *mtd, loff_t ofs, size_t len) 294static int part_unlock (struct mtd_info *mtd, loff_t ofs, size_t len)
295{ 295{
296 struct mtd_part *part = PART(mtd); 296 struct mtd_part *part = PART(mtd);
297 if ((len + ofs) > mtd->size) 297 if ((len + ofs) > mtd->size)
298 return -EINVAL; 298 return -EINVAL;
299 return part->master->unlock(part->master, ofs + part->offset, len); 299 return part->master->unlock(part->master, ofs + part->offset, len);
300} 300}
@@ -337,8 +337,8 @@ static int part_block_markbad (struct mtd_info *mtd, loff_t ofs)
337 return part->master->block_markbad(part->master, ofs); 337 return part->master->block_markbad(part->master, ofs);
338} 338}
339 339
340/* 340/*
341 * This function unregisters and destroy all slave MTD objects which are 341 * This function unregisters and destroy all slave MTD objects which are
342 * attached to the given master MTD object. 342 * attached to the given master MTD object.
343 */ 343 */
344 344
@@ -371,7 +371,7 @@ int del_mtd_partitions(struct mtd_info *master)
371 * (Q: should we register the master MTD object as well?) 371 * (Q: should we register the master MTD object as well?)
372 */ 372 */
373 373
374int add_mtd_partitions(struct mtd_info *master, 374int add_mtd_partitions(struct mtd_info *master,
375 const struct mtd_partition *parts, 375 const struct mtd_partition *parts,
376 int nbparts) 376 int nbparts)
377{ 377{
@@ -414,7 +414,7 @@ int add_mtd_partitions(struct mtd_info *master,
414 slave->mtd.point = part_point; 414 slave->mtd.point = part_point;
415 slave->mtd.unpoint = part_unpoint; 415 slave->mtd.unpoint = part_unpoint;
416 } 416 }
417 417
418 if (master->read_ecc) 418 if (master->read_ecc)
419 slave->mtd.read_ecc = part_read_ecc; 419 slave->mtd.read_ecc = part_read_ecc;
420 if (master->write_ecc) 420 if (master->write_ecc)
@@ -465,9 +465,10 @@ int add_mtd_partitions(struct mtd_info *master,
465 if (slave->offset == MTDPART_OFS_APPEND) 465 if (slave->offset == MTDPART_OFS_APPEND)
466 slave->offset = cur_offset; 466 slave->offset = cur_offset;
467 if (slave->offset == MTDPART_OFS_NXTBLK) { 467 if (slave->offset == MTDPART_OFS_NXTBLK) {
468 u_int32_t emask = master->erasesize-1; 468 slave->offset = cur_offset;
469 slave->offset = (cur_offset + emask) & ~emask; 469 if ((cur_offset % master->erasesize) != 0) {
470 if (slave->offset != cur_offset) { 470 /* Round up to next erasesize */
471 slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize;
471 printk(KERN_NOTICE "Moving partition %d: " 472 printk(KERN_NOTICE "Moving partition %d: "
472 "0x%08x -> 0x%08x\n", i, 473 "0x%08x -> 0x%08x\n", i,
473 cur_offset, slave->offset); 474 cur_offset, slave->offset);
@@ -476,8 +477,8 @@ int add_mtd_partitions(struct mtd_info *master,
476 if (slave->mtd.size == MTDPART_SIZ_FULL) 477 if (slave->mtd.size == MTDPART_SIZ_FULL)
477 slave->mtd.size = master->size - slave->offset; 478 slave->mtd.size = master->size - slave->offset;
478 cur_offset = slave->offset + slave->mtd.size; 479 cur_offset = slave->offset + slave->mtd.size;
479 480
480 printk (KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset, 481 printk (KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset,
481 slave->offset + slave->mtd.size, slave->mtd.name); 482 slave->offset + slave->mtd.size, slave->mtd.name);
482 483
483 /* let's do some sanity checks */ 484 /* let's do some sanity checks */
@@ -497,7 +498,7 @@ int add_mtd_partitions(struct mtd_info *master,
497 /* Deal with variable erase size stuff */ 498 /* Deal with variable erase size stuff */
498 int i; 499 int i;
499 struct mtd_erase_region_info *regions = master->eraseregions; 500 struct mtd_erase_region_info *regions = master->eraseregions;
500 501
501 /* Find the first erase regions which is part of this partition. */ 502 /* Find the first erase regions which is part of this partition. */
502 for (i=0; i < master->numeraseregions && slave->offset >= regions[i].offset; i++) 503 for (i=0; i < master->numeraseregions && slave->offset >= regions[i].offset; i++)
503 ; 504 ;
@@ -512,7 +513,7 @@ int add_mtd_partitions(struct mtd_info *master,
512 slave->mtd.erasesize = master->erasesize; 513 slave->mtd.erasesize = master->erasesize;
513 } 514 }
514 515
515 if ((slave->mtd.flags & MTD_WRITEABLE) && 516 if ((slave->mtd.flags & MTD_WRITEABLE) &&
516 (slave->offset % slave->mtd.erasesize)) { 517 (slave->offset % slave->mtd.erasesize)) {
517 /* Doesn't start on a boundary of major erase size */ 518 /* Doesn't start on a boundary of major erase size */
518 /* FIXME: Let it be writable if it is on a boundary of _minor_ erase size though */ 519 /* FIXME: Let it be writable if it is on a boundary of _minor_ erase size though */
@@ -520,14 +521,14 @@ int add_mtd_partitions(struct mtd_info *master,
520 printk ("mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n", 521 printk ("mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
521 parts[i].name); 522 parts[i].name);
522 } 523 }
523 if ((slave->mtd.flags & MTD_WRITEABLE) && 524 if ((slave->mtd.flags & MTD_WRITEABLE) &&
524 (slave->mtd.size % slave->mtd.erasesize)) { 525 (slave->mtd.size % slave->mtd.erasesize)) {
525 slave->mtd.flags &= ~MTD_WRITEABLE; 526 slave->mtd.flags &= ~MTD_WRITEABLE;
526 printk ("mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n", 527 printk ("mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
527 parts[i].name); 528 parts[i].name);
528 } 529 }
529 530
530 /* copy oobinfo from master */ 531 /* copy oobinfo from master */
531 memcpy(&slave->mtd.oobinfo, &master->oobinfo, sizeof(slave->mtd.oobinfo)); 532 memcpy(&slave->mtd.oobinfo, &master->oobinfo, sizeof(slave->mtd.oobinfo));
532 533
533 if(parts[i].mtdp) 534 if(parts[i].mtdp)
@@ -588,12 +589,12 @@ int deregister_mtd_parser(struct mtd_part_parser *p)
588 return 0; 589 return 0;
589} 590}
590 591
591int parse_mtd_partitions(struct mtd_info *master, const char **types, 592int parse_mtd_partitions(struct mtd_info *master, const char **types,
592 struct mtd_partition **pparts, unsigned long origin) 593 struct mtd_partition **pparts, unsigned long origin)
593{ 594{
594 struct mtd_part_parser *parser; 595 struct mtd_part_parser *parser;
595 int ret = 0; 596 int ret = 0;
596 597
597 for ( ; ret <= 0 && *types; types++) { 598 for ( ; ret <= 0 && *types; types++) {
598 parser = get_partition_parser(*types); 599 parser = get_partition_parser(*types);
599#ifdef CONFIG_KMOD 600#ifdef CONFIG_KMOD
@@ -607,7 +608,7 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types,
607 } 608 }
608 ret = (*parser->parse_fn)(master, pparts, origin); 609 ret = (*parser->parse_fn)(master, pparts, origin);
609 if (ret > 0) { 610 if (ret > 0) {
610 printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n", 611 printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n",
611 ret, parser->name, master->name); 612 ret, parser->name, master->name);
612 } 613 }
613 put_partition_parser(parser); 614 put_partition_parser(parser);
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 36d34e5e5a5a..1fc4c134d939 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -1,5 +1,5 @@
1# drivers/mtd/nand/Kconfig 1# drivers/mtd/nand/Kconfig
2# $Id: Kconfig,v 1.31 2005/06/20 12:03:21 bjd Exp $ 2# $Id: Kconfig,v 1.35 2005/11/07 11:14:30 gleixner Exp $
3 3
4menu "NAND Flash Device Drivers" 4menu "NAND Flash Device Drivers"
5 depends on MTD!=n 5 depends on MTD!=n
@@ -25,33 +25,33 @@ config MTD_NAND_VERIFY_WRITE
25 25
26config MTD_NAND_AUTCPU12 26config MTD_NAND_AUTCPU12
27 tristate "SmartMediaCard on autronix autcpu12 board" 27 tristate "SmartMediaCard on autronix autcpu12 board"
28 depends on ARM && MTD_NAND && ARCH_AUTCPU12 28 depends on MTD_NAND && ARCH_AUTCPU12
29 help 29 help
30 This enables the driver for the autronix autcpu12 board to 30 This enables the driver for the autronix autcpu12 board to
31 access the SmartMediaCard. 31 access the SmartMediaCard.
32 32
33config MTD_NAND_EDB7312 33config MTD_NAND_EDB7312
34 tristate "Support for Cirrus Logic EBD7312 evaluation board" 34 tristate "Support for Cirrus Logic EBD7312 evaluation board"
35 depends on ARM && MTD_NAND && ARCH_EDB7312 35 depends on MTD_NAND && ARCH_EDB7312
36 help 36 help
37 This enables the driver for the Cirrus Logic EBD7312 evaluation 37 This enables the driver for the Cirrus Logic EBD7312 evaluation
38 board to access the onboard NAND Flash. 38 board to access the onboard NAND Flash.
39 39
40config MTD_NAND_H1900 40config MTD_NAND_H1900
41 tristate "iPAQ H1900 flash" 41 tristate "iPAQ H1900 flash"
42 depends on ARM && MTD_NAND && ARCH_PXA && MTD_PARTITIONS 42 depends on MTD_NAND && ARCH_PXA && MTD_PARTITIONS
43 help 43 help
44 This enables the driver for the iPAQ h1900 flash. 44 This enables the driver for the iPAQ h1900 flash.
45 45
46config MTD_NAND_SPIA 46config MTD_NAND_SPIA
47 tristate "NAND Flash device on SPIA board" 47 tristate "NAND Flash device on SPIA board"
48 depends on ARM && ARCH_P720T && MTD_NAND 48 depends on ARCH_P720T && MTD_NAND
49 help 49 help
50 If you had to ask, you don't have one. Say 'N'. 50 If you had to ask, you don't have one. Say 'N'.
51 51
52config MTD_NAND_TOTO 52config MTD_NAND_TOTO
53 tristate "NAND Flash device on TOTO board" 53 tristate "NAND Flash device on TOTO board"
54 depends on ARM && ARCH_OMAP && MTD_NAND 54 depends on ARCH_OMAP && MTD_NAND
55 help 55 help
56 Support for NAND flash on Texas Instruments Toto platform. 56 Support for NAND flash on Texas Instruments Toto platform.
57 57
@@ -59,8 +59,8 @@ config MTD_NAND_IDS
59 tristate 59 tristate
60 60
61config MTD_NAND_AU1550 61config MTD_NAND_AU1550
62 tristate "Au1550 NAND support" 62 tristate "Au1550/1200 NAND support"
63 depends on SOC_AU1550 && MTD_NAND 63 depends on (SOC_AU1200 || SOC_AU1550) && MTD_NAND
64 help 64 help
65 This enables the driver for the NAND flash controller on the 65 This enables the driver for the NAND flash controller on the
66 AMD/Alchemy 1550 SOC. 66 AMD/Alchemy 1550 SOC.
@@ -71,7 +71,7 @@ config MTD_NAND_RTC_FROM4
71 select REED_SOLOMON 71 select REED_SOLOMON
72 select REED_SOLOMON_DEC8 72 select REED_SOLOMON_DEC8
73 help 73 help
74 This enables the driver for the Renesas Technology AG-AND 74 This enables the driver for the Renesas Technology AG-AND
75 flash interface board (FROM_BOARD4) 75 flash interface board (FROM_BOARD4)
76 76
77config MTD_NAND_PPCHAMELEONEVB 77config MTD_NAND_PPCHAMELEONEVB
@@ -88,7 +88,7 @@ config MTD_NAND_S3C2410
88 SoCs 88 SoCs
89 89
90 No board specfic support is done by this driver, each board 90 No board specfic support is done by this driver, each board
91 must advertise a platform_device for the driver to attach. 91 must advertise a platform_device for the driver to attach.
92 92
93config MTD_NAND_S3C2410_DEBUG 93config MTD_NAND_S3C2410_DEBUG
94 bool "S3C2410 NAND driver debug" 94 bool "S3C2410 NAND driver debug"
@@ -181,7 +181,7 @@ config MTD_NAND_DISKONCHIP_BBTWRITE
181 181
182 config MTD_NAND_SHARPSL 182 config MTD_NAND_SHARPSL
183 bool "Support for NAND Flash on Sharp SL Series (C7xx + others)" 183 bool "Support for NAND Flash on Sharp SL Series (C7xx + others)"
184 depends on MTD_NAND && ARCH_PXA 184 depends on MTD_NAND && ARCH_PXA
185 185
186 config MTD_NAND_NANDSIM 186 config MTD_NAND_NANDSIM
187 bool "Support for NAND Flash Simulator" 187 bool "Support for NAND Flash Simulator"
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
index 4c7719ce3f48..3cafcdf28aed 100644
--- a/drivers/mtd/nand/au1550nd.c
+++ b/drivers/mtd/nand/au1550nd.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2004 Embedded Edge, LLC 4 * Copyright (C) 2004 Embedded Edge, LLC
5 * 5 *
6 * $Id: au1550nd.c,v 1.11 2004/11/04 12:53:10 gleixner Exp $ 6 * $Id: au1550nd.c,v 1.13 2005/11/07 11:14:30 gleixner Exp $
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
@@ -21,20 +21,14 @@
21 21
22/* fixme: this is ugly */ 22/* fixme: this is ugly */
23#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0) 23#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0)
24#include <asm/mach-au1x00/au1000.h> 24#include <asm/mach-au1x00/au1xxx.h>
25#ifdef CONFIG_MIPS_PB1550
26#include <asm/mach-pb1x00/pb1550.h>
27#endif
28#ifdef CONFIG_MIPS_DB1550
29#include <asm/mach-db1x00/db1x00.h>
30#endif
31#else 25#else
32#include <asm/au1000.h> 26#include <asm/au1000.h>
33#ifdef CONFIG_MIPS_PB1550 27#ifdef CONFIG_MIPS_PB1550
34#include <asm/pb1550.h> 28#include <asm/pb1550.h>
35#endif 29#endif
36#ifdef CONFIG_MIPS_DB1550 30#ifdef CONFIG_MIPS_DB1550
37#include <asm/db1x00.h> 31#include <asm/db1x00.h>
38#endif 32#endif
39#endif 33#endif
40 34
@@ -45,39 +39,22 @@ static struct mtd_info *au1550_mtd = NULL;
45static void __iomem *p_nand; 39static void __iomem *p_nand;
46static int nand_width = 1; /* default x8*/ 40static int nand_width = 1; /* default x8*/
47 41
48#define NAND_CS 1
49
50/* 42/*
51 * Define partitions for flash device 43 * Define partitions for flash device
52 */ 44 */
53const static struct mtd_partition partition_info[] = { 45const static struct mtd_partition partition_info[] = {
54#ifdef CONFIG_MIPS_PB1550 46 {
55#define NUM_PARTITIONS 2 47 .name = "NAND FS 0",
56 {
57 .name = "Pb1550 NAND FS 0",
58 .offset = 0, 48 .offset = 0,
59 .size = 8*1024*1024 49 .size = 8*1024*1024
60 }, 50 },
61 { 51 {
62 .name = "Pb1550 NAND FS 1", 52 .name = "NAND FS 1",
63 .offset = MTDPART_OFS_APPEND, 53 .offset = MTDPART_OFS_APPEND,
64 .size = MTDPART_SIZ_FULL 54 .size = MTDPART_SIZ_FULL
65 } 55 }
66#endif
67#ifdef CONFIG_MIPS_DB1550
68#define NUM_PARTITIONS 2
69 {
70 .name = "Db1550 NAND FS 0",
71 .offset = 0,
72 .size = 8*1024*1024
73 },
74 {
75 .name = "Db1550 NAND FS 1",
76 .offset = MTDPART_OFS_APPEND,
77 .size = MTDPART_SIZ_FULL
78 }
79#endif
80}; 56};
57#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
81 58
82 59
83/** 60/**
@@ -112,7 +89,7 @@ static void au_write_byte(struct mtd_info *mtd, u_char byte)
112 * au_read_byte16 - read one byte endianess aware from the chip 89 * au_read_byte16 - read one byte endianess aware from the chip
113 * @mtd: MTD device structure 90 * @mtd: MTD device structure
114 * 91 *
115 * read function for 16bit buswith with 92 * read function for 16bit buswith with
116 * endianess conversion 93 * endianess conversion
117 */ 94 */
118static u_char au_read_byte16(struct mtd_info *mtd) 95static u_char au_read_byte16(struct mtd_info *mtd)
@@ -142,7 +119,7 @@ static void au_write_byte16(struct mtd_info *mtd, u_char byte)
142 * au_read_word - read one word from the chip 119 * au_read_word - read one word from the chip
143 * @mtd: MTD device structure 120 * @mtd: MTD device structure
144 * 121 *
145 * read function for 16bit buswith without 122 * read function for 16bit buswith without
146 * endianess conversion 123 * endianess conversion
147 */ 124 */
148static u16 au_read_word(struct mtd_info *mtd) 125static u16 au_read_word(struct mtd_info *mtd)
@@ -158,7 +135,7 @@ static u16 au_read_word(struct mtd_info *mtd)
158 * @mtd: MTD device structure 135 * @mtd: MTD device structure
159 * @word: data word to write 136 * @word: data word to write
160 * 137 *
161 * write function for 16bit buswith without 138 * write function for 16bit buswith without
162 * endianess conversion 139 * endianess conversion
163 */ 140 */
164static void au_write_word(struct mtd_info *mtd, u16 word) 141static void au_write_word(struct mtd_info *mtd, u16 word)
@@ -188,7 +165,7 @@ static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
188} 165}
189 166
190/** 167/**
191 * au_read_buf - read chip data into buffer 168 * au_read_buf - read chip data into buffer
192 * @mtd: MTD device structure 169 * @mtd: MTD device structure
193 * @buf: buffer to store date 170 * @buf: buffer to store date
194 * @len: number of bytes to read 171 * @len: number of bytes to read
@@ -202,12 +179,12 @@ static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len)
202 179
203 for (i=0; i<len; i++) { 180 for (i=0; i<len; i++) {
204 buf[i] = readb(this->IO_ADDR_R); 181 buf[i] = readb(this->IO_ADDR_R);
205 au_sync(); 182 au_sync();
206 } 183 }
207} 184}
208 185
209/** 186/**
210 * au_verify_buf - Verify chip data against buffer 187 * au_verify_buf - Verify chip data against buffer
211 * @mtd: MTD device structure 188 * @mtd: MTD device structure
212 * @buf: buffer containing the data to compare 189 * @buf: buffer containing the data to compare
213 * @len: number of bytes to compare 190 * @len: number of bytes to compare
@@ -242,16 +219,16 @@ static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
242 struct nand_chip *this = mtd->priv; 219 struct nand_chip *this = mtd->priv;
243 u16 *p = (u16 *) buf; 220 u16 *p = (u16 *) buf;
244 len >>= 1; 221 len >>= 1;
245 222
246 for (i=0; i<len; i++) { 223 for (i=0; i<len; i++) {
247 writew(p[i], this->IO_ADDR_W); 224 writew(p[i], this->IO_ADDR_W);
248 au_sync(); 225 au_sync();
249 } 226 }
250 227
251} 228}
252 229
253/** 230/**
254 * au_read_buf16 - read chip data into buffer 231 * au_read_buf16 - read chip data into buffer
255 * @mtd: MTD device structure 232 * @mtd: MTD device structure
256 * @buf: buffer to store date 233 * @buf: buffer to store date
257 * @len: number of bytes to read 234 * @len: number of bytes to read
@@ -272,7 +249,7 @@ static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
272} 249}
273 250
274/** 251/**
275 * au_verify_buf16 - Verify chip data against buffer 252 * au_verify_buf16 - Verify chip data against buffer
276 * @mtd: MTD device structure 253 * @mtd: MTD device structure
277 * @buf: buffer containing the data to compare 254 * @buf: buffer containing the data to compare
278 * @len: number of bytes to compare 255 * @len: number of bytes to compare
@@ -305,26 +282,26 @@ static void au1550_hwcontrol(struct mtd_info *mtd, int cmd)
305 case NAND_CTL_CLRCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; break; 282 case NAND_CTL_CLRCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; break;
306 283
307 case NAND_CTL_SETALE: this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR; break; 284 case NAND_CTL_SETALE: this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR; break;
308 case NAND_CTL_CLRALE: 285 case NAND_CTL_CLRALE:
309 this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; 286 this->IO_ADDR_W = p_nand + MEM_STNAND_DATA;
310 /* FIXME: Nobody knows why this is neccecary, 287 /* FIXME: Nobody knows why this is neccecary,
311 * but it works only that way */ 288 * but it works only that way */
312 udelay(1); 289 udelay(1);
313 break; 290 break;
314 291
315 case NAND_CTL_SETNCE: 292 case NAND_CTL_SETNCE:
316 /* assert (force assert) chip enable */ 293 /* assert (force assert) chip enable */
317 au_writel((1<<(4+NAND_CS)) , MEM_STNDCTL); break; 294 au_writel((1<<(4+NAND_CS)) , MEM_STNDCTL); break;
318 break; 295 break;
319 296
320 case NAND_CTL_CLRNCE: 297 case NAND_CTL_CLRNCE:
321 /* deassert chip enable */ 298 /* deassert chip enable */
322 au_writel(0, MEM_STNDCTL); break; 299 au_writel(0, MEM_STNDCTL); break;
323 break; 300 break;
324 } 301 }
325 302
326 this->IO_ADDR_R = this->IO_ADDR_W; 303 this->IO_ADDR_R = this->IO_ADDR_W;
327 304
328 /* Drain the writebuffer */ 305 /* Drain the writebuffer */
329 au_sync(); 306 au_sync();
330} 307}
@@ -339,14 +316,16 @@ int au1550_device_ready(struct mtd_info *mtd)
339/* 316/*
340 * Main initialization routine 317 * Main initialization routine
341 */ 318 */
342int __init au1550_init (void) 319int __init au1xxx_nand_init (void)
343{ 320{
344 struct nand_chip *this; 321 struct nand_chip *this;
345 u16 boot_swapboot = 0; /* default value */ 322 u16 boot_swapboot = 0; /* default value */
346 int retval; 323 int retval;
324 u32 mem_staddr;
325 u32 nand_phys;
347 326
348 /* Allocate memory for MTD device structure and private data */ 327 /* Allocate memory for MTD device structure and private data */
349 au1550_mtd = kmalloc (sizeof(struct mtd_info) + 328 au1550_mtd = kmalloc (sizeof(struct mtd_info) +
350 sizeof (struct nand_chip), GFP_KERNEL); 329 sizeof (struct nand_chip), GFP_KERNEL);
351 if (!au1550_mtd) { 330 if (!au1550_mtd) {
352 printk ("Unable to allocate NAND MTD dev structure.\n"); 331 printk ("Unable to allocate NAND MTD dev structure.\n");
@@ -364,14 +343,17 @@ int __init au1550_init (void)
364 au1550_mtd->priv = this; 343 au1550_mtd->priv = this;
365 344
366 345
367 /* MEM_STNDCTL: disable ints, disable nand boot */ 346 /* disable interrupts */
368 au_writel(0, MEM_STNDCTL); 347 au_writel(au_readl(MEM_STNDCTL) & ~(1<<8), MEM_STNDCTL);
348
349 /* disable NAND boot */
350 au_writel(au_readl(MEM_STNDCTL) & ~(1<<0), MEM_STNDCTL);
369 351
370#ifdef CONFIG_MIPS_PB1550 352#ifdef CONFIG_MIPS_PB1550
371 /* set gpio206 high */ 353 /* set gpio206 high */
372 au_writel(au_readl(GPIO2_DIR) & ~(1<<6), GPIO2_DIR); 354 au_writel(au_readl(GPIO2_DIR) & ~(1<<6), GPIO2_DIR);
373 355
374 boot_swapboot = (au_readl(MEM_STSTAT) & (0x7<<1)) | 356 boot_swapboot = (au_readl(MEM_STSTAT) & (0x7<<1)) |
375 ((bcsr->status >> 6) & 0x1); 357 ((bcsr->status >> 6) & 0x1);
376 switch (boot_swapboot) { 358 switch (boot_swapboot) {
377 case 0: 359 case 0:
@@ -397,25 +379,66 @@ int __init au1550_init (void)
397 } 379 }
398#endif 380#endif
399 381
400 /* Configure RCE1 - should be done by YAMON */ 382 /* Configure chip-select; normally done by boot code, e.g. YAMON */
401 au_writel(0x5 | (nand_width << 22), 0xB4001010); /* MEM_STCFG1 */ 383#ifdef NAND_STCFG
402 au_writel(NAND_TIMING, 0xB4001014); /* MEM_STTIME1 */ 384 if (NAND_CS == 0) {
403 au_sync(); 385 au_writel(NAND_STCFG, MEM_STCFG0);
386 au_writel(NAND_STTIME, MEM_STTIME0);
387 au_writel(NAND_STADDR, MEM_STADDR0);
388 }
389 if (NAND_CS == 1) {
390 au_writel(NAND_STCFG, MEM_STCFG1);
391 au_writel(NAND_STTIME, MEM_STTIME1);
392 au_writel(NAND_STADDR, MEM_STADDR1);
393 }
394 if (NAND_CS == 2) {
395 au_writel(NAND_STCFG, MEM_STCFG2);
396 au_writel(NAND_STTIME, MEM_STTIME2);
397 au_writel(NAND_STADDR, MEM_STADDR2);
398 }
399 if (NAND_CS == 3) {
400 au_writel(NAND_STCFG, MEM_STCFG3);
401 au_writel(NAND_STTIME, MEM_STTIME3);
402 au_writel(NAND_STADDR, MEM_STADDR3);
403 }
404#endif
404 405
405 /* setup and enable chip select, MEM_STADDR1 */ 406 /* Locate NAND chip-select in order to determine NAND phys address */
406 /* we really need to decode offsets only up till 0x20 */ 407 mem_staddr = 0x00000000;
407 au_writel((1<<28) | (NAND_PHYS_ADDR>>4) | 408 if (((au_readl(MEM_STCFG0) & 0x7) == 0x5) && (NAND_CS == 0))
408 (((NAND_PHYS_ADDR + 0x1000)-1) & (0x3fff<<18)>>18), 409 mem_staddr = au_readl(MEM_STADDR0);
409 MEM_STADDR1); 410 else if (((au_readl(MEM_STCFG1) & 0x7) == 0x5) && (NAND_CS == 1))
410 au_sync(); 411 mem_staddr = au_readl(MEM_STADDR1);
412 else if (((au_readl(MEM_STCFG2) & 0x7) == 0x5) && (NAND_CS == 2))
413 mem_staddr = au_readl(MEM_STADDR2);
414 else if (((au_readl(MEM_STCFG3) & 0x7) == 0x5) && (NAND_CS == 3))
415 mem_staddr = au_readl(MEM_STADDR3);
416
417 if (mem_staddr == 0x00000000) {
418 printk("Au1xxx NAND: ERROR WITH NAND CHIP-SELECT\n");
419 kfree(au1550_mtd);
420 return 1;
421 }
422 nand_phys = (mem_staddr << 4) & 0xFFFC0000;
423
424 p_nand = (void __iomem *)ioremap(nand_phys, 0x1000);
425
426 /* make controller and MTD agree */
427 if (NAND_CS == 0)
428 nand_width = au_readl(MEM_STCFG0) & (1<<22);
429 if (NAND_CS == 1)
430 nand_width = au_readl(MEM_STCFG1) & (1<<22);
431 if (NAND_CS == 2)
432 nand_width = au_readl(MEM_STCFG2) & (1<<22);
433 if (NAND_CS == 3)
434 nand_width = au_readl(MEM_STCFG3) & (1<<22);
411 435
412 p_nand = ioremap(NAND_PHYS_ADDR, 0x1000);
413 436
414 /* Set address of hardware control function */ 437 /* Set address of hardware control function */
415 this->hwcontrol = au1550_hwcontrol; 438 this->hwcontrol = au1550_hwcontrol;
416 this->dev_ready = au1550_device_ready; 439 this->dev_ready = au1550_device_ready;
417 /* 30 us command delay time */ 440 /* 30 us command delay time */
418 this->chip_delay = 30; 441 this->chip_delay = 30;
419 this->eccmode = NAND_ECC_SOFT; 442 this->eccmode = NAND_ECC_SOFT;
420 443
421 this->options = NAND_NO_AUTOINCR; 444 this->options = NAND_NO_AUTOINCR;
@@ -438,19 +461,19 @@ int __init au1550_init (void)
438 } 461 }
439 462
440 /* Register the partitions */ 463 /* Register the partitions */
441 add_mtd_partitions(au1550_mtd, partition_info, NUM_PARTITIONS); 464 add_mtd_partitions(au1550_mtd, partition_info, NB_OF(partition_info));
442 465
443 return 0; 466 return 0;
444 467
445 outio: 468 outio:
446 iounmap ((void *)p_nand); 469 iounmap ((void *)p_nand);
447 470
448 outmem: 471 outmem:
449 kfree (au1550_mtd); 472 kfree (au1550_mtd);
450 return retval; 473 return retval;
451} 474}
452 475
453module_init(au1550_init); 476module_init(au1xxx_nand_init);
454 477
455/* 478/*
456 * Clean up routine 479 * Clean up routine
diff --git a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c
index 4afa8ced05ad..056dfc17a075 100644
--- a/drivers/mtd/nand/autcpu12.c
+++ b/drivers/mtd/nand/autcpu12.c
@@ -5,8 +5,8 @@
5 * 5 *
6 * Derived from drivers/mtd/spia.c 6 * Derived from drivers/mtd/spia.c
7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
8 * 8 *
9 * $Id: autcpu12.c,v 1.22 2004/11/04 12:53:10 gleixner Exp $ 9 * $Id: autcpu12.c,v 1.23 2005/11/07 11:14:30 gleixner Exp $
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -14,7 +14,7 @@
14 * 14 *
15 * Overview: 15 * Overview:
16 * This is a device driver for the NAND flash device found on the 16 * This is a device driver for the NAND flash device found on the
17 * autronix autcpu12 board, which is a SmartMediaCard. It supports 17 * autronix autcpu12 board, which is a SmartMediaCard. It supports
18 * 16MiB, 32MiB and 64MiB cards. 18 * 16MiB, 32MiB and 64MiB cards.
19 * 19 *
20 * 20 *
@@ -93,7 +93,7 @@ static struct mtd_partition partition_info128k[] = {
93#define NUM_PARTITIONS32K 2 93#define NUM_PARTITIONS32K 2
94#define NUM_PARTITIONS64K 2 94#define NUM_PARTITIONS64K 2
95#define NUM_PARTITIONS128K 2 95#define NUM_PARTITIONS128K 2
96/* 96/*
97 * hardware specific access to control-lines 97 * hardware specific access to control-lines
98*/ 98*/
99static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd) 99static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd)
@@ -163,7 +163,7 @@ int __init autcpu12_init (void)
163 this->hwcontrol = autcpu12_hwcontrol; 163 this->hwcontrol = autcpu12_hwcontrol;
164 this->dev_ready = autcpu12_device_ready; 164 this->dev_ready = autcpu12_device_ready;
165 /* 20 us command delay time */ 165 /* 20 us command delay time */
166 this->chip_delay = 20; 166 this->chip_delay = 20;
167 this->eccmode = NAND_ECC_SOFT; 167 this->eccmode = NAND_ECC_SOFT;
168 168
169 /* Enable the following for a flash based bad block table */ 169 /* Enable the following for a flash based bad block table */
@@ -171,21 +171,21 @@ int __init autcpu12_init (void)
171 this->options = NAND_USE_FLASH_BBT; 171 this->options = NAND_USE_FLASH_BBT;
172 */ 172 */
173 this->options = NAND_USE_FLASH_BBT; 173 this->options = NAND_USE_FLASH_BBT;
174 174
175 /* Scan to find existance of the device */ 175 /* Scan to find existance of the device */
176 if (nand_scan (autcpu12_mtd, 1)) { 176 if (nand_scan (autcpu12_mtd, 1)) {
177 err = -ENXIO; 177 err = -ENXIO;
178 goto out_ior; 178 goto out_ior;
179 } 179 }
180 180
181 /* Register the partitions */ 181 /* Register the partitions */
182 switch(autcpu12_mtd->size){ 182 switch(autcpu12_mtd->size){
183 case SZ_16M: add_mtd_partitions(autcpu12_mtd, partition_info16k, NUM_PARTITIONS16K); break; 183 case SZ_16M: add_mtd_partitions(autcpu12_mtd, partition_info16k, NUM_PARTITIONS16K); break;
184 case SZ_32M: add_mtd_partitions(autcpu12_mtd, partition_info32k, NUM_PARTITIONS32K); break; 184 case SZ_32M: add_mtd_partitions(autcpu12_mtd, partition_info32k, NUM_PARTITIONS32K); break;
185 case SZ_64M: add_mtd_partitions(autcpu12_mtd, partition_info64k, NUM_PARTITIONS64K); break; 185 case SZ_64M: add_mtd_partitions(autcpu12_mtd, partition_info64k, NUM_PARTITIONS64K); break;
186 case SZ_128M: add_mtd_partitions(autcpu12_mtd, partition_info128k, NUM_PARTITIONS128K); break; 186 case SZ_128M: add_mtd_partitions(autcpu12_mtd, partition_info128k, NUM_PARTITIONS128K); break;
187 default: { 187 default: {
188 printk ("Unsupported SmartMedia device\n"); 188 printk ("Unsupported SmartMedia device\n");
189 err = -ENXIO; 189 err = -ENXIO;
190 goto out_ior; 190 goto out_ior;
191 } 191 }
@@ -213,7 +213,7 @@ static void __exit autcpu12_cleanup (void)
213 213
214 /* unmap physical adress */ 214 /* unmap physical adress */
215 iounmap((void *)autcpu12_fio_base); 215 iounmap((void *)autcpu12_fio_base);
216 216
217 /* Free the MTD device structure */ 217 /* Free the MTD device structure */
218 kfree (autcpu12_mtd); 218 kfree (autcpu12_mtd);
219} 219}
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index fdb5d4ad3d52..21d4e8f4b7af 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * drivers/mtd/nand/diskonchip.c 2 * drivers/mtd/nand/diskonchip.c
3 * 3 *
4 * (C) 2003 Red Hat, Inc. 4 * (C) 2003 Red Hat, Inc.
@@ -8,15 +8,15 @@
8 * Author: David Woodhouse <dwmw2@infradead.org> 8 * Author: David Woodhouse <dwmw2@infradead.org>
9 * Additional Diskonchip 2000 and Millennium support by Dan Brown <dan_brown@ieee.org> 9 * Additional Diskonchip 2000 and Millennium support by Dan Brown <dan_brown@ieee.org>
10 * Diskonchip Millennium Plus support by Kalev Lember <kalev@smartlink.ee> 10 * Diskonchip Millennium Plus support by Kalev Lember <kalev@smartlink.ee>
11 * 11 *
12 * Error correction code lifted from the old docecc code 12 * Error correction code lifted from the old docecc code
13 * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 13 * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
14 * Copyright (C) 2000 Netgem S.A. 14 * Copyright (C) 2000 Netgem S.A.
15 * converted to the generic Reed-Solomon library by Thomas Gleixner <tglx@linutronix.de> 15 * converted to the generic Reed-Solomon library by Thomas Gleixner <tglx@linutronix.de>
16 * 16 *
17 * Interface to generic NAND code for M-Systems DiskOnChip devices 17 * Interface to generic NAND code for M-Systems DiskOnChip devices
18 * 18 *
19 * $Id: diskonchip.c,v 1.54 2005/04/07 14:22:55 dbrown Exp $ 19 * $Id: diskonchip.c,v 1.55 2005/11/07 11:14:30 gleixner Exp $
20 */ 20 */
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -42,16 +42,16 @@
42static unsigned long __initdata doc_locations[] = { 42static unsigned long __initdata doc_locations[] = {
43#if defined (__alpha__) || defined(__i386__) || defined(__x86_64__) 43#if defined (__alpha__) || defined(__i386__) || defined(__x86_64__)
44#ifdef CONFIG_MTD_NAND_DISKONCHIP_PROBE_HIGH 44#ifdef CONFIG_MTD_NAND_DISKONCHIP_PROBE_HIGH
45 0xfffc8000, 0xfffca000, 0xfffcc000, 0xfffce000, 45 0xfffc8000, 0xfffca000, 0xfffcc000, 0xfffce000,
46 0xfffd0000, 0xfffd2000, 0xfffd4000, 0xfffd6000, 46 0xfffd0000, 0xfffd2000, 0xfffd4000, 0xfffd6000,
47 0xfffd8000, 0xfffda000, 0xfffdc000, 0xfffde000, 47 0xfffd8000, 0xfffda000, 0xfffdc000, 0xfffde000,
48 0xfffe0000, 0xfffe2000, 0xfffe4000, 0xfffe6000, 48 0xfffe0000, 0xfffe2000, 0xfffe4000, 0xfffe6000,
49 0xfffe8000, 0xfffea000, 0xfffec000, 0xfffee000, 49 0xfffe8000, 0xfffea000, 0xfffec000, 0xfffee000,
50#else /* CONFIG_MTD_DOCPROBE_HIGH */ 50#else /* CONFIG_MTD_DOCPROBE_HIGH */
51 0xc8000, 0xca000, 0xcc000, 0xce000, 51 0xc8000, 0xca000, 0xcc000, 0xce000,
52 0xd0000, 0xd2000, 0xd4000, 0xd6000, 52 0xd0000, 0xd2000, 0xd4000, 0xd6000,
53 0xd8000, 0xda000, 0xdc000, 0xde000, 53 0xd8000, 0xda000, 0xdc000, 0xde000,
54 0xe0000, 0xe2000, 0xe4000, 0xe6000, 54 0xe0000, 0xe2000, 0xe4000, 0xe6000,
55 0xe8000, 0xea000, 0xec000, 0xee000, 55 0xe8000, 0xea000, 0xec000, 0xee000,
56#endif /* CONFIG_MTD_DOCPROBE_HIGH */ 56#endif /* CONFIG_MTD_DOCPROBE_HIGH */
57#elif defined(__PPC__) 57#elif defined(__PPC__)
@@ -138,7 +138,7 @@ MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe
138/* the Reed Solomon control structure */ 138/* the Reed Solomon control structure */
139static struct rs_control *rs_decoder; 139static struct rs_control *rs_decoder;
140 140
141/* 141/*
142 * The HW decoder in the DoC ASIC's provides us a error syndrome, 142 * The HW decoder in the DoC ASIC's provides us a error syndrome,
143 * which we must convert to a standard syndrom usable by the generic 143 * which we must convert to a standard syndrom usable by the generic
144 * Reed-Solomon library code. 144 * Reed-Solomon library code.
@@ -163,8 +163,8 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc)
163 /* Initialize the syndrom buffer */ 163 /* Initialize the syndrom buffer */
164 for (i = 0; i < NROOTS; i++) 164 for (i = 0; i < NROOTS; i++)
165 s[i] = ds[0]; 165 s[i] = ds[0];
166 /* 166 /*
167 * Evaluate 167 * Evaluate
168 * s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0] 168 * s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0]
169 * where x = alpha^(FCR + i) 169 * where x = alpha^(FCR + i)
170 */ 170 */
@@ -188,7 +188,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc)
188 if (nerr < 0) 188 if (nerr < 0)
189 return nerr; 189 return nerr;
190 190
191 /* 191 /*
192 * Correct the errors. The bitpositions are a bit of magic, 192 * Correct the errors. The bitpositions are a bit of magic,
193 * but they are given by the design of the de/encoder circuit 193 * but they are given by the design of the de/encoder circuit
194 * in the DoC ASIC's. 194 * in the DoC ASIC's.
@@ -205,7 +205,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc)
205 can be modified since pos is even */ 205 can be modified since pos is even */
206 index = (pos >> 3) ^ 1; 206 index = (pos >> 3) ^ 1;
207 bitpos = pos & 7; 207 bitpos = pos & 7;
208 if ((index >= 0 && index < SECTOR_SIZE) || 208 if ((index >= 0 && index < SECTOR_SIZE) ||
209 index == (SECTOR_SIZE + 1)) { 209 index == (SECTOR_SIZE + 1)) {
210 val = (uint8_t) (errval[i] >> (2 + bitpos)); 210 val = (uint8_t) (errval[i] >> (2 + bitpos));
211 parity ^= val; 211 parity ^= val;
@@ -216,7 +216,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc)
216 bitpos = (bitpos + 10) & 7; 216 bitpos = (bitpos + 10) & 7;
217 if (bitpos == 0) 217 if (bitpos == 0)
218 bitpos = 8; 218 bitpos = 8;
219 if ((index >= 0 && index < SECTOR_SIZE) || 219 if ((index >= 0 && index < SECTOR_SIZE) ||
220 index == (SECTOR_SIZE + 1)) { 220 index == (SECTOR_SIZE + 1)) {
221 val = (uint8_t)(errval[i] << (8 - bitpos)); 221 val = (uint8_t)(errval[i] << (8 - bitpos));
222 parity ^= val; 222 parity ^= val;
@@ -233,7 +233,7 @@ static void DoC_Delay(struct doc_priv *doc, unsigned short cycles)
233{ 233{
234 volatile char dummy; 234 volatile char dummy;
235 int i; 235 int i;
236 236
237 for (i = 0; i < cycles; i++) { 237 for (i = 0; i < cycles; i++) {
238 if (DoC_is_Millennium(doc)) 238 if (DoC_is_Millennium(doc))
239 dummy = ReadDOC(doc->virtadr, NOP); 239 dummy = ReadDOC(doc->virtadr, NOP);
@@ -242,7 +242,7 @@ static void DoC_Delay(struct doc_priv *doc, unsigned short cycles)
242 else 242 else
243 dummy = ReadDOC(doc->virtadr, DOCStatus); 243 dummy = ReadDOC(doc->virtadr, DOCStatus);
244 } 244 }
245 245
246} 246}
247 247
248#define CDSN_CTRL_FR_B_MASK (CDSN_CTRL_FR_B0 | CDSN_CTRL_FR_B1) 248#define CDSN_CTRL_FR_B_MASK (CDSN_CTRL_FR_B0 | CDSN_CTRL_FR_B1)
@@ -327,7 +327,7 @@ static u_char doc2000_read_byte(struct mtd_info *mtd)
327 return ret; 327 return ret;
328} 328}
329 329
330static void doc2000_writebuf(struct mtd_info *mtd, 330static void doc2000_writebuf(struct mtd_info *mtd,
331 const u_char *buf, int len) 331 const u_char *buf, int len)
332{ 332{
333 struct nand_chip *this = mtd->priv; 333 struct nand_chip *this = mtd->priv;
@@ -343,7 +343,7 @@ static void doc2000_writebuf(struct mtd_info *mtd,
343 if (debug) printk("\n"); 343 if (debug) printk("\n");
344} 344}
345 345
346static void doc2000_readbuf(struct mtd_info *mtd, 346static void doc2000_readbuf(struct mtd_info *mtd,
347 u_char *buf, int len) 347 u_char *buf, int len)
348{ 348{
349 struct nand_chip *this = mtd->priv; 349 struct nand_chip *this = mtd->priv;
@@ -358,7 +358,7 @@ static void doc2000_readbuf(struct mtd_info *mtd,
358 } 358 }
359} 359}
360 360
361static void doc2000_readbuf_dword(struct mtd_info *mtd, 361static void doc2000_readbuf_dword(struct mtd_info *mtd,
362 u_char *buf, int len) 362 u_char *buf, int len)
363{ 363{
364 struct nand_chip *this = mtd->priv; 364 struct nand_chip *this = mtd->priv;
@@ -379,7 +379,7 @@ static void doc2000_readbuf_dword(struct mtd_info *mtd,
379 } 379 }
380} 380}
381 381
382static int doc2000_verifybuf(struct mtd_info *mtd, 382static int doc2000_verifybuf(struct mtd_info *mtd,
383 const u_char *buf, int len) 383 const u_char *buf, int len)
384{ 384{
385 struct nand_chip *this = mtd->priv; 385 struct nand_chip *this = mtd->priv;
@@ -406,12 +406,12 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
406 doc200x_hwcontrol(mtd, NAND_CTL_SETALE); 406 doc200x_hwcontrol(mtd, NAND_CTL_SETALE);
407 this->write_byte(mtd, 0); 407 this->write_byte(mtd, 0);
408 doc200x_hwcontrol(mtd, NAND_CTL_CLRALE); 408 doc200x_hwcontrol(mtd, NAND_CTL_CLRALE);
409 409
410 /* We cant' use dev_ready here, but at least we wait for the 410 /* We cant' use dev_ready here, but at least we wait for the
411 * command to complete 411 * command to complete
412 */ 412 */
413 udelay(50); 413 udelay(50);
414 414
415 ret = this->read_byte(mtd) << 8; 415 ret = this->read_byte(mtd) << 8;
416 ret |= this->read_byte(mtd); 416 ret |= this->read_byte(mtd);
417 417
@@ -438,7 +438,7 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
438 this->read_buf = &doc2000_readbuf_dword; 438 this->read_buf = &doc2000_readbuf_dword;
439 } 439 }
440 } 440 }
441 441
442 return ret; 442 return ret;
443} 443}
444 444
@@ -469,7 +469,7 @@ static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
469 struct doc_priv *doc = this->priv; 469 struct doc_priv *doc = this->priv;
470 470
471 int status; 471 int status;
472 472
473 DoC_WaitReady(doc); 473 DoC_WaitReady(doc);
474 this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); 474 this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
475 DoC_WaitReady(doc); 475 DoC_WaitReady(doc);
@@ -503,7 +503,7 @@ static u_char doc2001_read_byte(struct mtd_info *mtd)
503 return ReadDOC(docptr, LastDataRead); 503 return ReadDOC(docptr, LastDataRead);
504} 504}
505 505
506static void doc2001_writebuf(struct mtd_info *mtd, 506static void doc2001_writebuf(struct mtd_info *mtd,
507 const u_char *buf, int len) 507 const u_char *buf, int len)
508{ 508{
509 struct nand_chip *this = mtd->priv; 509 struct nand_chip *this = mtd->priv;
@@ -517,7 +517,7 @@ static void doc2001_writebuf(struct mtd_info *mtd,
517 WriteDOC(0x00, docptr, WritePipeTerm); 517 WriteDOC(0x00, docptr, WritePipeTerm);
518} 518}
519 519
520static void doc2001_readbuf(struct mtd_info *mtd, 520static void doc2001_readbuf(struct mtd_info *mtd,
521 u_char *buf, int len) 521 u_char *buf, int len)
522{ 522{
523 struct nand_chip *this = mtd->priv; 523 struct nand_chip *this = mtd->priv;
@@ -535,7 +535,7 @@ static void doc2001_readbuf(struct mtd_info *mtd,
535 buf[i] = ReadDOC(docptr, LastDataRead); 535 buf[i] = ReadDOC(docptr, LastDataRead);
536} 536}
537 537
538static int doc2001_verifybuf(struct mtd_info *mtd, 538static int doc2001_verifybuf(struct mtd_info *mtd,
539 const u_char *buf, int len) 539 const u_char *buf, int len)
540{ 540{
541 struct nand_chip *this = mtd->priv; 541 struct nand_chip *this = mtd->priv;
@@ -570,7 +570,7 @@ static u_char doc2001plus_read_byte(struct mtd_info *mtd)
570 return ret; 570 return ret;
571} 571}
572 572
573static void doc2001plus_writebuf(struct mtd_info *mtd, 573static void doc2001plus_writebuf(struct mtd_info *mtd,
574 const u_char *buf, int len) 574 const u_char *buf, int len)
575{ 575{
576 struct nand_chip *this = mtd->priv; 576 struct nand_chip *this = mtd->priv;
@@ -587,7 +587,7 @@ static void doc2001plus_writebuf(struct mtd_info *mtd,
587 if (debug) printk("\n"); 587 if (debug) printk("\n");
588} 588}
589 589
590static void doc2001plus_readbuf(struct mtd_info *mtd, 590static void doc2001plus_readbuf(struct mtd_info *mtd,
591 u_char *buf, int len) 591 u_char *buf, int len)
592{ 592{
593 struct nand_chip *this = mtd->priv; 593 struct nand_chip *this = mtd->priv;
@@ -617,7 +617,7 @@ static void doc2001plus_readbuf(struct mtd_info *mtd,
617 if (debug) printk("\n"); 617 if (debug) printk("\n");
618} 618}
619 619
620static int doc2001plus_verifybuf(struct mtd_info *mtd, 620static int doc2001plus_verifybuf(struct mtd_info *mtd,
621 const u_char *buf, int len) 621 const u_char *buf, int len)
622{ 622{
623 struct nand_chip *this = mtd->priv; 623 struct nand_chip *this = mtd->priv;
@@ -797,7 +797,7 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col
797 WriteDOC(0, docptr, Mplus_FlashControl); 797 WriteDOC(0, docptr, Mplus_FlashControl);
798 } 798 }
799 799
800 /* 800 /*
801 * program and erase have their own busy handlers 801 * program and erase have their own busy handlers
802 * status and sequential in needs no delay 802 * status and sequential in needs no delay
803 */ 803 */
@@ -822,7 +822,7 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col
822 822
823 /* This applies to read commands */ 823 /* This applies to read commands */
824 default: 824 default:
825 /* 825 /*
826 * If we don't have access to the busy pin, we apply the given 826 * If we don't have access to the busy pin, we apply the given
827 * command delay 827 * command delay
828 */ 828 */
@@ -945,7 +945,7 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
945 for (i = 0; i < 6; i++) { 945 for (i = 0; i < 6; i++) {
946 if (DoC_is_MillenniumPlus(doc)) 946 if (DoC_is_MillenniumPlus(doc))
947 ecc_code[i] = ReadDOC_(docptr, DoC_Mplus_ECCSyndrome0 + i); 947 ecc_code[i] = ReadDOC_(docptr, DoC_Mplus_ECCSyndrome0 + i);
948 else 948 else
949 ecc_code[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i); 949 ecc_code[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
950 if (ecc_code[i] != empty_write_ecc[i]) 950 if (ecc_code[i] != empty_write_ecc[i])
951 emptymatch = 0; 951 emptymatch = 0;
@@ -982,7 +982,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_
982 void __iomem *docptr = doc->virtadr; 982 void __iomem *docptr = doc->virtadr;
983 volatile u_char dummy; 983 volatile u_char dummy;
984 int emptymatch = 1; 984 int emptymatch = 1;
985 985
986 /* flush the pipeline */ 986 /* flush the pipeline */
987 if (DoC_is_2000(doc)) { 987 if (DoC_is_2000(doc)) {
988 dummy = ReadDOC(docptr, 2k_ECCStatus); 988 dummy = ReadDOC(docptr, 2k_ECCStatus);
@@ -997,7 +997,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_
997 dummy = ReadDOC(docptr, ECCConf); 997 dummy = ReadDOC(docptr, ECCConf);
998 dummy = ReadDOC(docptr, ECCConf); 998 dummy = ReadDOC(docptr, ECCConf);
999 } 999 }
1000 1000
1001 /* Error occured ? */ 1001 /* Error occured ? */
1002 if (dummy & 0x80) { 1002 if (dummy & 0x80) {
1003 for (i = 0; i < 6; i++) { 1003 for (i = 0; i < 6; i++) {
@@ -1035,7 +1035,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_
1035 if (!emptymatch) ret = doc_ecc_decode (rs_decoder, dat, calc_ecc); 1035 if (!emptymatch) ret = doc_ecc_decode (rs_decoder, dat, calc_ecc);
1036 if (ret > 0) 1036 if (ret > 0)
1037 printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret); 1037 printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret);
1038 } 1038 }
1039 if (DoC_is_MillenniumPlus(doc)) 1039 if (DoC_is_MillenniumPlus(doc))
1040 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf); 1040 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf);
1041 else 1041 else
@@ -1046,7 +1046,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_
1046 } 1046 }
1047 return ret; 1047 return ret;
1048} 1048}
1049 1049
1050//u_char mydatabuf[528]; 1050//u_char mydatabuf[528];
1051 1051
1052/* The strange out-of-order .oobfree list below is a (possibly unneeded) 1052/* The strange out-of-order .oobfree list below is a (possibly unneeded)
@@ -1065,7 +1065,7 @@ static struct nand_oobinfo doc200x_oobinfo = {
1065 .eccpos = {0, 1, 2, 3, 4, 5}, 1065 .eccpos = {0, 1, 2, 3, 4, 5},
1066 .oobfree = { {8, 8}, {6, 2} } 1066 .oobfree = { {8, 8}, {6, 2} }
1067}; 1067};
1068 1068
1069/* Find the (I)NFTL Media Header, and optionally also the mirror media header. 1069/* Find the (I)NFTL Media Header, and optionally also the mirror media header.
1070 On sucessful return, buf will contain a copy of the media header for 1070 On sucessful return, buf will contain a copy of the media header for
1071 further processing. id is the string to scan for, and will presumably be 1071 further processing. id is the string to scan for, and will presumably be
@@ -1251,7 +1251,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd,
1251 mh->BlockMultiplierBits = le32_to_cpu(mh->BlockMultiplierBits); 1251 mh->BlockMultiplierBits = le32_to_cpu(mh->BlockMultiplierBits);
1252 mh->FormatFlags = le32_to_cpu(mh->FormatFlags); 1252 mh->FormatFlags = le32_to_cpu(mh->FormatFlags);
1253 mh->PercentUsed = le32_to_cpu(mh->PercentUsed); 1253 mh->PercentUsed = le32_to_cpu(mh->PercentUsed);
1254 1254
1255 printk(KERN_INFO " bootRecordID = %s\n" 1255 printk(KERN_INFO " bootRecordID = %s\n"
1256 " NoOfBootImageBlocks = %d\n" 1256 " NoOfBootImageBlocks = %d\n"
1257 " NoOfBinaryPartitions = %d\n" 1257 " NoOfBinaryPartitions = %d\n"
@@ -1468,7 +1468,7 @@ static inline int __init doc2001_init(struct mtd_info *mtd)
1468 ReadDOC(doc->virtadr, ChipID); 1468 ReadDOC(doc->virtadr, ChipID);
1469 if (ReadDOC(doc->virtadr, ChipID) != DOC_ChipID_DocMil) { 1469 if (ReadDOC(doc->virtadr, ChipID) != DOC_ChipID_DocMil) {
1470 /* It's not a Millennium; it's one of the newer 1470 /* It's not a Millennium; it's one of the newer
1471 DiskOnChip 2000 units with a similar ASIC. 1471 DiskOnChip 2000 units with a similar ASIC.
1472 Treat it like a Millennium, except that it 1472 Treat it like a Millennium, except that it
1473 can have multiple chips. */ 1473 can have multiple chips. */
1474 doc2000_count_chips(mtd); 1474 doc2000_count_chips(mtd);
@@ -1530,20 +1530,20 @@ static inline int __init doc_probe(unsigned long physadr)
1530 * to the DOCControl register. So we store the current contents 1530 * to the DOCControl register. So we store the current contents
1531 * of the DOCControl register's location, in case we later decide 1531 * of the DOCControl register's location, in case we later decide
1532 * that it's not a DiskOnChip, and want to put it back how we 1532 * that it's not a DiskOnChip, and want to put it back how we
1533 * found it. 1533 * found it.
1534 */ 1534 */
1535 save_control = ReadDOC(virtadr, DOCControl); 1535 save_control = ReadDOC(virtadr, DOCControl);
1536 1536
1537 /* Reset the DiskOnChip ASIC */ 1537 /* Reset the DiskOnChip ASIC */
1538 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, 1538 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
1539 virtadr, DOCControl); 1539 virtadr, DOCControl);
1540 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, 1540 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
1541 virtadr, DOCControl); 1541 virtadr, DOCControl);
1542 1542
1543 /* Enable the DiskOnChip ASIC */ 1543 /* Enable the DiskOnChip ASIC */
1544 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, 1544 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL,
1545 virtadr, DOCControl); 1545 virtadr, DOCControl);
1546 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, 1546 WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL,
1547 virtadr, DOCControl); 1547 virtadr, DOCControl);
1548 1548
1549 ChipID = ReadDOC(virtadr, ChipID); 1549 ChipID = ReadDOC(virtadr, ChipID);
@@ -1738,7 +1738,7 @@ static int __init init_nanddoc(void)
1738 int i, ret = 0; 1738 int i, ret = 0;
1739 1739
1740 /* We could create the decoder on demand, if memory is a concern. 1740 /* We could create the decoder on demand, if memory is a concern.
1741 * This way we have it handy, if an error happens 1741 * This way we have it handy, if an error happens
1742 * 1742 *
1743 * Symbolsize is 10 (bits) 1743 * Symbolsize is 10 (bits)
1744 * Primitve polynomial is x^10+x^3+1 1744 * Primitve polynomial is x^10+x^3+1
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
index 5549681ccdce..9b1fd2f387fa 100644
--- a/drivers/mtd/nand/edb7312.c
+++ b/drivers/mtd/nand/edb7312.c
@@ -6,7 +6,7 @@
6 * Derived from drivers/mtd/nand/autcpu12.c 6 * Derived from drivers/mtd/nand/autcpu12.c
7 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) 7 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
8 * 8 *
9 * $Id: edb7312.c,v 1.11 2004/11/04 12:53:10 gleixner Exp $ 9 * $Id: edb7312.c,v 1.12 2005/11/07 11:14:30 gleixner Exp $
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -71,27 +71,27 @@ static struct mtd_partition partition_info[] = {
71#endif 71#endif
72 72
73 73
74/* 74/*
75 * hardware specific access to control-lines 75 * hardware specific access to control-lines
76 */ 76 */
77static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd) 77static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd)
78{ 78{
79 switch(cmd) { 79 switch(cmd) {
80 80
81 case NAND_CTL_SETCLE: 81 case NAND_CTL_SETCLE:
82 clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr); 82 clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr);
83 break; 83 break;
84 case NAND_CTL_CLRCLE: 84 case NAND_CTL_CLRCLE:
85 clps_writeb(clps_readb(ep7312_pxdr) & ~0x10, ep7312_pxdr); 85 clps_writeb(clps_readb(ep7312_pxdr) & ~0x10, ep7312_pxdr);
86 break; 86 break;
87 87
88 case NAND_CTL_SETALE: 88 case NAND_CTL_SETALE:
89 clps_writeb(clps_readb(ep7312_pxdr) | 0x20, ep7312_pxdr); 89 clps_writeb(clps_readb(ep7312_pxdr) | 0x20, ep7312_pxdr);
90 break; 90 break;
91 case NAND_CTL_CLRALE: 91 case NAND_CTL_CLRALE:
92 clps_writeb(clps_readb(ep7312_pxdr) & ~0x20, ep7312_pxdr); 92 clps_writeb(clps_readb(ep7312_pxdr) & ~0x20, ep7312_pxdr);
93 break; 93 break;
94 94
95 case NAND_CTL_SETNCE: 95 case NAND_CTL_SETNCE:
96 clps_writeb((clps_readb(ep7312_pxdr) | 0x80) & ~0x40, ep7312_pxdr); 96 clps_writeb((clps_readb(ep7312_pxdr) | 0x80) & ~0x40, ep7312_pxdr);
97 break; 97 break;
@@ -122,16 +122,16 @@ static int __init ep7312_init (void)
122 int mtd_parts_nb = 0; 122 int mtd_parts_nb = 0;
123 struct mtd_partition *mtd_parts = 0; 123 struct mtd_partition *mtd_parts = 0;
124 void __iomem * ep7312_fio_base; 124 void __iomem * ep7312_fio_base;
125 125
126 /* Allocate memory for MTD device structure and private data */ 126 /* Allocate memory for MTD device structure and private data */
127 ep7312_mtd = kmalloc(sizeof(struct mtd_info) + 127 ep7312_mtd = kmalloc(sizeof(struct mtd_info) +
128 sizeof(struct nand_chip), 128 sizeof(struct nand_chip),
129 GFP_KERNEL); 129 GFP_KERNEL);
130 if (!ep7312_mtd) { 130 if (!ep7312_mtd) {
131 printk("Unable to allocate EDB7312 NAND MTD device structure.\n"); 131 printk("Unable to allocate EDB7312 NAND MTD device structure.\n");
132 return -ENOMEM; 132 return -ENOMEM;
133 } 133 }
134 134
135 /* map physical adress */ 135 /* map physical adress */
136 ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K); 136 ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K);
137 if(!ep7312_fio_base) { 137 if(!ep7312_fio_base) {
@@ -139,23 +139,23 @@ static int __init ep7312_init (void)
139 kfree(ep7312_mtd); 139 kfree(ep7312_mtd);
140 return -EIO; 140 return -EIO;
141 } 141 }
142 142
143 /* Get pointer to private data */ 143 /* Get pointer to private data */
144 this = (struct nand_chip *) (&ep7312_mtd[1]); 144 this = (struct nand_chip *) (&ep7312_mtd[1]);
145 145
146 /* Initialize structures */ 146 /* Initialize structures */
147 memset((char *) ep7312_mtd, 0, sizeof(struct mtd_info)); 147 memset((char *) ep7312_mtd, 0, sizeof(struct mtd_info));
148 memset((char *) this, 0, sizeof(struct nand_chip)); 148 memset((char *) this, 0, sizeof(struct nand_chip));
149 149
150 /* Link the private data with the MTD structure */ 150 /* Link the private data with the MTD structure */
151 ep7312_mtd->priv = this; 151 ep7312_mtd->priv = this;
152 152
153 /* 153 /*
154 * Set GPIO Port B control register so that the pins are configured 154 * Set GPIO Port B control register so that the pins are configured
155 * to be outputs for controlling the NAND flash. 155 * to be outputs for controlling the NAND flash.
156 */ 156 */
157 clps_writeb(0xf0, ep7312_pxddr); 157 clps_writeb(0xf0, ep7312_pxddr);
158 158
159 /* insert callbacks */ 159 /* insert callbacks */
160 this->IO_ADDR_R = ep7312_fio_base; 160 this->IO_ADDR_R = ep7312_fio_base;
161 this->IO_ADDR_W = ep7312_fio_base; 161 this->IO_ADDR_W = ep7312_fio_base;
@@ -163,14 +163,14 @@ static int __init ep7312_init (void)
163 this->dev_ready = ep7312_device_ready; 163 this->dev_ready = ep7312_device_ready;
164 /* 15 us command delay time */ 164 /* 15 us command delay time */
165 this->chip_delay = 15; 165 this->chip_delay = 15;
166 166
167 /* Scan to find existence of the device */ 167 /* Scan to find existence of the device */
168 if (nand_scan (ep7312_mtd, 1)) { 168 if (nand_scan (ep7312_mtd, 1)) {
169 iounmap((void *)ep7312_fio_base); 169 iounmap((void *)ep7312_fio_base);
170 kfree (ep7312_mtd); 170 kfree (ep7312_mtd);
171 return -ENXIO; 171 return -ENXIO;
172 } 172 }
173 173
174#ifdef CONFIG_MTD_PARTITIONS 174#ifdef CONFIG_MTD_PARTITIONS
175 ep7312_mtd->name = "edb7312-nand"; 175 ep7312_mtd->name = "edb7312-nand";
176 mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes, 176 mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes,
@@ -185,11 +185,11 @@ static int __init ep7312_init (void)
185 mtd_parts_nb = NUM_PARTITIONS; 185 mtd_parts_nb = NUM_PARTITIONS;
186 part_type = "static"; 186 part_type = "static";
187 } 187 }
188 188
189 /* Register the partitions */ 189 /* Register the partitions */
190 printk(KERN_NOTICE "Using %s partition definition\n", part_type); 190 printk(KERN_NOTICE "Using %s partition definition\n", part_type);
191 add_mtd_partitions(ep7312_mtd, mtd_parts, mtd_parts_nb); 191 add_mtd_partitions(ep7312_mtd, mtd_parts, mtd_parts_nb);
192 192
193 /* Return happy */ 193 /* Return happy */
194 return 0; 194 return 0;
195} 195}
@@ -201,13 +201,13 @@ module_init(ep7312_init);
201static void __exit ep7312_cleanup (void) 201static void __exit ep7312_cleanup (void)
202{ 202{
203 struct nand_chip *this = (struct nand_chip *) &ep7312_mtd[1]; 203 struct nand_chip *this = (struct nand_chip *) &ep7312_mtd[1];
204 204
205 /* Release resources, unregister device */ 205 /* Release resources, unregister device */
206 nand_release (ap7312_mtd); 206 nand_release (ap7312_mtd);
207 207
208 /* Free internal data buffer */ 208 /* Free internal data buffer */
209 kfree (this->data_buf); 209 kfree (this->data_buf);
210 210
211 /* Free the MTD device structure */ 211 /* Free the MTD device structure */
212 kfree (ep7312_mtd); 212 kfree (ep7312_mtd);
213} 213}
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c
index 3825a7a0900c..041e4b3358fb 100644
--- a/drivers/mtd/nand/h1910.c
+++ b/drivers/mtd/nand/h1910.c
@@ -7,7 +7,7 @@
7 * Copyright (C) 2002 Marius Gröger (mag@sysgo.de) 7 * Copyright (C) 2002 Marius Gröger (mag@sysgo.de)
8 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) 8 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
9 * 9 *
10 * $Id: h1910.c,v 1.5 2004/11/04 12:53:10 gleixner Exp $ 10 * $Id: h1910.c,v 1.6 2005/11/07 11:14:30 gleixner Exp $
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 version 2 as 13 * it under the terms of the GNU General Public License version 2 as
@@ -54,24 +54,24 @@ static struct mtd_partition partition_info[] = {
54#endif 54#endif
55 55
56 56
57/* 57/*
58 * hardware specific access to control-lines 58 * hardware specific access to control-lines
59 */ 59 */
60static void h1910_hwcontrol(struct mtd_info *mtd, int cmd) 60static void h1910_hwcontrol(struct mtd_info *mtd, int cmd)
61{ 61{
62 struct nand_chip* this = (struct nand_chip *) (mtd->priv); 62 struct nand_chip* this = (struct nand_chip *) (mtd->priv);
63 63
64 switch(cmd) { 64 switch(cmd) {
65 65
66 case NAND_CTL_SETCLE: 66 case NAND_CTL_SETCLE:
67 this->IO_ADDR_R |= (1 << 2); 67 this->IO_ADDR_R |= (1 << 2);
68 this->IO_ADDR_W |= (1 << 2); 68 this->IO_ADDR_W |= (1 << 2);
69 break; 69 break;
70 case NAND_CTL_CLRCLE: 70 case NAND_CTL_CLRCLE:
71 this->IO_ADDR_R &= ~(1 << 2); 71 this->IO_ADDR_R &= ~(1 << 2);
72 this->IO_ADDR_W &= ~(1 << 2); 72 this->IO_ADDR_W &= ~(1 << 2);
73 break; 73 break;
74 74
75 case NAND_CTL_SETALE: 75 case NAND_CTL_SETALE:
76 this->IO_ADDR_R |= (1 << 3); 76 this->IO_ADDR_R |= (1 << 3);
77 this->IO_ADDR_W |= (1 << 3); 77 this->IO_ADDR_W |= (1 << 3);
@@ -80,7 +80,7 @@ static void h1910_hwcontrol(struct mtd_info *mtd, int cmd)
80 this->IO_ADDR_R &= ~(1 << 3); 80 this->IO_ADDR_R &= ~(1 << 3);
81 this->IO_ADDR_W &= ~(1 << 3); 81 this->IO_ADDR_W &= ~(1 << 3);
82 break; 82 break;
83 83
84 case NAND_CTL_SETNCE: 84 case NAND_CTL_SETNCE:
85 break; 85 break;
86 case NAND_CTL_CLRNCE: 86 case NAND_CTL_CLRNCE:
@@ -108,18 +108,18 @@ static int __init h1910_init (void)
108 int mtd_parts_nb = 0; 108 int mtd_parts_nb = 0;
109 struct mtd_partition *mtd_parts = 0; 109 struct mtd_partition *mtd_parts = 0;
110 void __iomem *nandaddr; 110 void __iomem *nandaddr;
111 111
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, 0, 1);
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;
119 } 119 }
120 120
121 /* Allocate memory for MTD device structure and private data */ 121 /* Allocate memory for MTD device structure and private data */
122 h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + 122 h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) +
123 sizeof(struct nand_chip), 123 sizeof(struct nand_chip),
124 GFP_KERNEL); 124 GFP_KERNEL);
125 if (!h1910_nand_mtd) { 125 if (!h1910_nand_mtd) {
@@ -127,22 +127,22 @@ static int __init h1910_init (void)
127 iounmap ((void *) nandaddr); 127 iounmap ((void *) nandaddr);
128 return -ENOMEM; 128 return -ENOMEM;
129 } 129 }
130 130
131 /* Get pointer to private data */ 131 /* Get pointer to private data */
132 this = (struct nand_chip *) (&h1910_nand_mtd[1]); 132 this = (struct nand_chip *) (&h1910_nand_mtd[1]);
133 133
134 /* Initialize structures */ 134 /* Initialize structures */
135 memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info)); 135 memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info));
136 memset((char *) this, 0, sizeof(struct nand_chip)); 136 memset((char *) this, 0, sizeof(struct nand_chip));
137 137
138 /* Link the private data with the MTD structure */ 138 /* Link the private data with the MTD structure */
139 h1910_nand_mtd->priv = this; 139 h1910_nand_mtd->priv = this;
140 140
141 /* 141 /*
142 * Enable VPEN 142 * Enable VPEN
143 */ 143 */
144 GPSR(37) = GPIO_bit(37); 144 GPSR(37) = GPIO_bit(37);
145 145
146 /* insert callbacks */ 146 /* insert callbacks */
147 this->IO_ADDR_R = nandaddr; 147 this->IO_ADDR_R = nandaddr;
148 this->IO_ADDR_W = nandaddr; 148 this->IO_ADDR_W = nandaddr;
@@ -152,7 +152,7 @@ static int __init h1910_init (void)
152 this->chip_delay = 50; 152 this->chip_delay = 50;
153 this->eccmode = NAND_ECC_SOFT; 153 this->eccmode = NAND_ECC_SOFT;
154 this->options = NAND_NO_AUTOINCR; 154 this->options = NAND_NO_AUTOINCR;
155 155
156 /* Scan to find existence of the device */ 156 /* Scan to find existence of the device */
157 if (nand_scan (h1910_nand_mtd, 1)) { 157 if (nand_scan (h1910_nand_mtd, 1)) {
158 printk(KERN_NOTICE "No NAND device - returning -ENXIO\n"); 158 printk(KERN_NOTICE "No NAND device - returning -ENXIO\n");
@@ -160,9 +160,9 @@ static int __init h1910_init (void)
160 iounmap ((void *) nandaddr); 160 iounmap ((void *) nandaddr);
161 return -ENXIO; 161 return -ENXIO;
162 } 162 }
163 163
164#ifdef CONFIG_MTD_CMDLINE_PARTS 164#ifdef CONFIG_MTD_CMDLINE_PARTS
165 mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, 165 mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts,
166 "h1910-nand"); 166 "h1910-nand");
167 if (mtd_parts_nb > 0) 167 if (mtd_parts_nb > 0)
168 part_type = "command line"; 168 part_type = "command line";
@@ -175,11 +175,11 @@ static int __init h1910_init (void)
175 mtd_parts_nb = NUM_PARTITIONS; 175 mtd_parts_nb = NUM_PARTITIONS;
176 part_type = "static"; 176 part_type = "static";
177 } 177 }
178 178
179 /* Register the partitions */ 179 /* Register the partitions */
180 printk(KERN_NOTICE "Using %s partition definition\n", part_type); 180 printk(KERN_NOTICE "Using %s partition definition\n", part_type);
181 add_mtd_partitions(h1910_nand_mtd, mtd_parts, mtd_parts_nb); 181 add_mtd_partitions(h1910_nand_mtd, mtd_parts, mtd_parts_nb);
182 182
183 /* Return happy */ 183 /* Return happy */
184 return 0; 184 return 0;
185} 185}
@@ -191,7 +191,7 @@ module_init(h1910_init);
191static void __exit h1910_cleanup (void) 191static void __exit h1910_cleanup (void)
192{ 192{
193 struct nand_chip *this = (struct nand_chip *) &h1910_nand_mtd[1]; 193 struct nand_chip *this = (struct nand_chip *) &h1910_nand_mtd[1];
194 194
195 /* Release resources, unregister device */ 195 /* Release resources, unregister device */
196 nand_release (h1910_nand_mtd); 196 nand_release (h1910_nand_mtd);
197 197
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 04e54318bc6a..5d222460b42a 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -5,14 +5,14 @@
5 * This is the generic MTD driver for NAND flash devices. It should be 5 * This is the generic MTD driver for NAND flash devices. It should be
6 * capable of working with almost all NAND chips currently available. 6 * capable of working with almost all NAND chips currently available.
7 * Basic support for AG-AND chips is provided. 7 * Basic support for AG-AND chips is provided.
8 * 8 *
9 * Additional technical information is available on 9 * Additional technical information is available on
10 * http://www.linux-mtd.infradead.org/tech/nand.html 10 * http://www.linux-mtd.infradead.org/tech/nand.html
11 * 11 *
12 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 12 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
13 * 2002 Thomas Gleixner (tglx@linutronix.de) 13 * 2002 Thomas Gleixner (tglx@linutronix.de)
14 * 14 *
15 * 02-08-2004 tglx: support for strange chips, which cannot auto increment 15 * 02-08-2004 tglx: support for strange chips, which cannot auto increment
16 * pages on read / read_oob 16 * pages on read / read_oob
17 * 17 *
18 * 03-17-2004 tglx: Check ready before auto increment check. Simon Bayes 18 * 03-17-2004 tglx: Check ready before auto increment check. Simon Bayes
@@ -21,7 +21,7 @@
21 * Make reads over block boundaries work too 21 * Make reads over block boundaries work too
22 * 22 *
23 * 04-14-2004 tglx: first working version for 2k page size chips 23 * 04-14-2004 tglx: first working version for 2k page size chips
24 * 24 *
25 * 05-19-2004 tglx: Basic support for Renesas AG-AND chips 25 * 05-19-2004 tglx: Basic support for Renesas AG-AND chips
26 * 26 *
27 * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared 27 * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared
@@ -30,25 +30,27 @@
30 * 30 *
31 * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" issue. 31 * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" issue.
32 * Basically, any block not rewritten may lose data when surrounding blocks 32 * Basically, any block not rewritten may lose data when surrounding blocks
33 * are rewritten many times. JFFS2 ensures this doesn't happen for blocks 33 * are rewritten many times. JFFS2 ensures this doesn't happen for blocks
34 * it uses, but the Bad Block Table(s) may not be rewritten. To ensure they 34 * it uses, but the Bad Block Table(s) may not be rewritten. To ensure they
35 * do not lose data, force them to be rewritten when some of the surrounding 35 * do not lose data, force them to be rewritten when some of the surrounding
36 * blocks are erased. Rather than tracking a specific nearby block (which 36 * blocks are erased. Rather than tracking a specific nearby block (which
37 * could itself go bad), use a page address 'mask' to select several blocks 37 * could itself go bad), use a page address 'mask' to select several blocks
38 * in the same area, and rewrite the BBT when any of them are erased. 38 * in the same area, and rewrite the BBT when any of them are erased.
39 * 39 *
40 * 01-03-2005 dmarlin: added support for the device recovery command sequence for Renesas 40 * 01-03-2005 dmarlin: added support for the device recovery command sequence for Renesas
41 * AG-AND chips. If there was a sudden loss of power during an erase operation, 41 * AG-AND chips. If there was a sudden loss of power during an erase operation,
42 * a "device recovery" operation must be performed when power is restored 42 * a "device recovery" operation must be performed when power is restored
43 * to ensure correct operation. 43 * to ensure correct operation.
44 * 44 *
45 * 01-20-2005 dmarlin: added support for optional hardware specific callback routine to 45 * 01-20-2005 dmarlin: added support for optional hardware specific callback routine to
46 * perform extra error status checks on erase and write failures. This required 46 * perform extra error status checks on erase and write failures. This required
47 * adding a wrapper function for nand_read_ecc. 47 * adding a wrapper function for nand_read_ecc.
48 * 48 *
49 * 08-20-2005 vwool: suspend/resume added
50 *
49 * Credits: 51 * Credits:
50 * David Woodhouse for adding multichip support 52 * David Woodhouse for adding multichip support
51 * 53 *
52 * Aleph One Ltd. and Toby Churchill Ltd. for supporting the 54 * Aleph One Ltd. and Toby Churchill Ltd. for supporting the
53 * rework for 2K page size chips 55 * rework for 2K page size chips
54 * 56 *
@@ -59,7 +61,7 @@
59 * The AG-AND chips have nice features for speed improvement, 61 * The AG-AND chips have nice features for speed improvement,
60 * which are not supported yet. Read / program 4 pages in one go. 62 * which are not supported yet. Read / program 4 pages in one go.
61 * 63 *
62 * $Id: nand_base.c,v 1.147 2005/07/15 07:18:06 gleixner Exp $ 64 * $Id: nand_base.c,v 1.150 2005/09/15 13:58:48 vwool Exp $
63 * 65 *
64 * This program is free software; you can redistribute it and/or modify 66 * This program is free software; you can redistribute it and/or modify
65 * it under the terms of the GNU General Public License version 2 as 67 * it under the terms of the GNU General Public License version 2 as
@@ -103,8 +105,8 @@ static struct nand_oobinfo nand_oob_64 = {
103 .useecc = MTD_NANDECC_AUTOPLACE, 105 .useecc = MTD_NANDECC_AUTOPLACE,
104 .eccbytes = 24, 106 .eccbytes = 24,
105 .eccpos = { 107 .eccpos = {
106 40, 41, 42, 43, 44, 45, 46, 47, 108 40, 41, 42, 43, 44, 45, 46, 47,
107 48, 49, 50, 51, 52, 53, 54, 55, 109 48, 49, 50, 51, 52, 53, 54, 55,
108 56, 57, 58, 59, 60, 61, 62, 63}, 110 56, 57, 58, 59, 60, 61, 62, 63},
109 .oobfree = { {2, 38} } 111 .oobfree = { {2, 38} }
110}; 112};
@@ -147,19 +149,19 @@ static void nand_sync (struct mtd_info *mtd);
147static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, 149static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf,
148 struct nand_oobinfo *oobsel, int mode); 150 struct nand_oobinfo *oobsel, int mode);
149#ifdef CONFIG_MTD_NAND_VERIFY_WRITE 151#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
150static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, 152static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages,
151 u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); 153 u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode);
152#else 154#else
153#define nand_verify_pages(...) (0) 155#define nand_verify_pages(...) (0)
154#endif 156#endif
155 157
156static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state); 158static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state);
157 159
158/** 160/**
159 * nand_release_device - [GENERIC] release chip 161 * nand_release_device - [GENERIC] release chip
160 * @mtd: MTD device structure 162 * @mtd: MTD device structure
161 * 163 *
162 * Deselect, release chip lock and wake up anyone waiting on the device 164 * Deselect, release chip lock and wake up anyone waiting on the device
163 */ 165 */
164static void nand_release_device (struct mtd_info *mtd) 166static void nand_release_device (struct mtd_info *mtd)
165{ 167{
@@ -213,7 +215,7 @@ static void nand_write_byte(struct mtd_info *mtd, u_char byte)
213 * nand_read_byte16 - [DEFAULT] read one byte endianess aware from the chip 215 * nand_read_byte16 - [DEFAULT] read one byte endianess aware from the chip
214 * @mtd: MTD device structure 216 * @mtd: MTD device structure
215 * 217 *
216 * Default read function for 16bit buswith with 218 * Default read function for 16bit buswith with
217 * endianess conversion 219 * endianess conversion
218 */ 220 */
219static u_char nand_read_byte16(struct mtd_info *mtd) 221static u_char nand_read_byte16(struct mtd_info *mtd)
@@ -240,7 +242,7 @@ static void nand_write_byte16(struct mtd_info *mtd, u_char byte)
240 * nand_read_word - [DEFAULT] read one word from the chip 242 * nand_read_word - [DEFAULT] read one word from the chip
241 * @mtd: MTD device structure 243 * @mtd: MTD device structure
242 * 244 *
243 * Default read function for 16bit buswith without 245 * Default read function for 16bit buswith without
244 * endianess conversion 246 * endianess conversion
245 */ 247 */
246static u16 nand_read_word(struct mtd_info *mtd) 248static u16 nand_read_word(struct mtd_info *mtd)
@@ -254,7 +256,7 @@ static u16 nand_read_word(struct mtd_info *mtd)
254 * @mtd: MTD device structure 256 * @mtd: MTD device structure
255 * @word: data word to write 257 * @word: data word to write
256 * 258 *
257 * Default write function for 16bit buswith without 259 * Default write function for 16bit buswith without
258 * endianess conversion 260 * endianess conversion
259 */ 261 */
260static void nand_write_word(struct mtd_info *mtd, u16 word) 262static void nand_write_word(struct mtd_info *mtd, u16 word)
@@ -275,7 +277,7 @@ static void nand_select_chip(struct mtd_info *mtd, int chip)
275 struct nand_chip *this = mtd->priv; 277 struct nand_chip *this = mtd->priv;
276 switch(chip) { 278 switch(chip) {
277 case -1: 279 case -1:
278 this->hwcontrol(mtd, NAND_CTL_CLRNCE); 280 this->hwcontrol(mtd, NAND_CTL_CLRNCE);
279 break; 281 break;
280 case 0: 282 case 0:
281 this->hwcontrol(mtd, NAND_CTL_SETNCE); 283 this->hwcontrol(mtd, NAND_CTL_SETNCE);
@@ -304,7 +306,7 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
304} 306}
305 307
306/** 308/**
307 * nand_read_buf - [DEFAULT] read chip data into buffer 309 * nand_read_buf - [DEFAULT] read chip data into buffer
308 * @mtd: MTD device structure 310 * @mtd: MTD device structure
309 * @buf: buffer to store date 311 * @buf: buffer to store date
310 * @len: number of bytes to read 312 * @len: number of bytes to read
@@ -321,7 +323,7 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
321} 323}
322 324
323/** 325/**
324 * nand_verify_buf - [DEFAULT] Verify chip data against buffer 326 * nand_verify_buf - [DEFAULT] Verify chip data against buffer
325 * @mtd: MTD device structure 327 * @mtd: MTD device structure
326 * @buf: buffer containing the data to compare 328 * @buf: buffer containing the data to compare
327 * @len: number of bytes to compare 329 * @len: number of bytes to compare
@@ -354,14 +356,14 @@ static void nand_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
354 struct nand_chip *this = mtd->priv; 356 struct nand_chip *this = mtd->priv;
355 u16 *p = (u16 *) buf; 357 u16 *p = (u16 *) buf;
356 len >>= 1; 358 len >>= 1;
357 359
358 for (i=0; i<len; i++) 360 for (i=0; i<len; i++)
359 writew(p[i], this->IO_ADDR_W); 361 writew(p[i], this->IO_ADDR_W);
360 362
361} 363}
362 364
363/** 365/**
364 * nand_read_buf16 - [DEFAULT] read chip data into buffer 366 * nand_read_buf16 - [DEFAULT] read chip data into buffer
365 * @mtd: MTD device structure 367 * @mtd: MTD device structure
366 * @buf: buffer to store date 368 * @buf: buffer to store date
367 * @len: number of bytes to read 369 * @len: number of bytes to read
@@ -380,7 +382,7 @@ static void nand_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
380} 382}
381 383
382/** 384/**
383 * nand_verify_buf16 - [DEFAULT] Verify chip data against buffer 385 * nand_verify_buf16 - [DEFAULT] Verify chip data against buffer
384 * @mtd: MTD device structure 386 * @mtd: MTD device structure
385 * @buf: buffer containing the data to compare 387 * @buf: buffer containing the data to compare
386 * @len: number of bytes to compare 388 * @len: number of bytes to compare
@@ -407,7 +409,7 @@ static int nand_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len)
407 * @ofs: offset from device start 409 * @ofs: offset from device start
408 * @getchip: 0, if the chip is already selected 410 * @getchip: 0, if the chip is already selected
409 * 411 *
410 * Check, if the block is bad. 412 * Check, if the block is bad.
411 */ 413 */
412static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) 414static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
413{ 415{
@@ -424,14 +426,14 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
424 426
425 /* Select the NAND device */ 427 /* Select the NAND device */
426 this->select_chip(mtd, chipnr); 428 this->select_chip(mtd, chipnr);
427 } else 429 } else
428 page = (int) ofs; 430 page = (int) ofs;
429 431
430 if (this->options & NAND_BUSWIDTH_16) { 432 if (this->options & NAND_BUSWIDTH_16) {
431 this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); 433 this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask);
432 bad = cpu_to_le16(this->read_word(mtd)); 434 bad = cpu_to_le16(this->read_word(mtd));
433 if (this->badblockpos & 0x1) 435 if (this->badblockpos & 0x1)
434 bad >>= 1; 436 bad >>= 8;
435 if ((bad & 0xFF) != 0xff) 437 if ((bad & 0xFF) != 0xff)
436 res = 1; 438 res = 1;
437 } else { 439 } else {
@@ -439,12 +441,12 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
439 if (this->read_byte(mtd) != 0xff) 441 if (this->read_byte(mtd) != 0xff)
440 res = 1; 442 res = 1;
441 } 443 }
442 444
443 if (getchip) { 445 if (getchip) {
444 /* Deselect and wake up anyone waiting on the device */ 446 /* Deselect and wake up anyone waiting on the device */
445 nand_release_device(mtd); 447 nand_release_device(mtd);
446 } 448 }
447 449
448 return res; 450 return res;
449} 451}
450 452
@@ -462,7 +464,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
462 u_char buf[2] = {0, 0}; 464 u_char buf[2] = {0, 0};
463 size_t retlen; 465 size_t retlen;
464 int block; 466 int block;
465 467
466 /* Get block number */ 468 /* Get block number */
467 block = ((int) ofs) >> this->bbt_erase_shift; 469 block = ((int) ofs) >> this->bbt_erase_shift;
468 if (this->bbt) 470 if (this->bbt)
@@ -471,25 +473,25 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
471 /* Do we have a flash based bad block table ? */ 473 /* Do we have a flash based bad block table ? */
472 if (this->options & NAND_USE_FLASH_BBT) 474 if (this->options & NAND_USE_FLASH_BBT)
473 return nand_update_bbt (mtd, ofs); 475 return nand_update_bbt (mtd, ofs);
474 476
475 /* We write two bytes, so we dont have to mess with 16 bit access */ 477 /* We write two bytes, so we dont have to mess with 16 bit access */
476 ofs += mtd->oobsize + (this->badblockpos & ~0x01); 478 ofs += mtd->oobsize + (this->badblockpos & ~0x01);
477 return nand_write_oob (mtd, ofs , 2, &retlen, buf); 479 return nand_write_oob (mtd, ofs , 2, &retlen, buf);
478} 480}
479 481
480/** 482/**
481 * nand_check_wp - [GENERIC] check if the chip is write protected 483 * nand_check_wp - [GENERIC] check if the chip is write protected
482 * @mtd: MTD device structure 484 * @mtd: MTD device structure
483 * Check, if the device is write protected 485 * Check, if the device is write protected
484 * 486 *
485 * The function expects, that the device is already selected 487 * The function expects, that the device is already selected
486 */ 488 */
487static int nand_check_wp (struct mtd_info *mtd) 489static int nand_check_wp (struct mtd_info *mtd)
488{ 490{
489 struct nand_chip *this = mtd->priv; 491 struct nand_chip *this = mtd->priv;
490 /* Check the WP bit */ 492 /* Check the WP bit */
491 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); 493 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
492 return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; 494 return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1;
493} 495}
494 496
495/** 497/**
@@ -505,15 +507,15 @@ static int nand_check_wp (struct mtd_info *mtd)
505static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) 507static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt)
506{ 508{
507 struct nand_chip *this = mtd->priv; 509 struct nand_chip *this = mtd->priv;
508 510
509 if (!this->bbt) 511 if (!this->bbt)
510 return this->block_bad(mtd, ofs, getchip); 512 return this->block_bad(mtd, ofs, getchip);
511 513
512 /* Return info from the table */ 514 /* Return info from the table */
513 return nand_isbad_bbt (mtd, ofs, allowbbt); 515 return nand_isbad_bbt (mtd, ofs, allowbbt);
514} 516}
515 517
516/* 518/*
517 * Wait for the ready pin, after a command 519 * Wait for the ready pin, after a command
518 * The timeout is catched later. 520 * The timeout is catched later.
519 */ 521 */
@@ -527,7 +529,7 @@ static void nand_wait_ready(struct mtd_info *mtd)
527 if (this->dev_ready(mtd)) 529 if (this->dev_ready(mtd))
528 return; 530 return;
529 touch_softlockup_watchdog(); 531 touch_softlockup_watchdog();
530 } while (time_before(jiffies, timeo)); 532 } while (time_before(jiffies, timeo));
531} 533}
532 534
533/** 535/**
@@ -590,13 +592,13 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in
590 /* Latch in address */ 592 /* Latch in address */
591 this->hwcontrol(mtd, NAND_CTL_CLRALE); 593 this->hwcontrol(mtd, NAND_CTL_CLRALE);
592 } 594 }
593 595
594 /* 596 /*
595 * program and erase have their own busy handlers 597 * program and erase have their own busy handlers
596 * status and sequential in needs no delay 598 * status and sequential in needs no delay
597 */ 599 */
598 switch (command) { 600 switch (command) {
599 601
600 case NAND_CMD_PAGEPROG: 602 case NAND_CMD_PAGEPROG:
601 case NAND_CMD_ERASE1: 603 case NAND_CMD_ERASE1:
602 case NAND_CMD_ERASE2: 604 case NAND_CMD_ERASE2:
@@ -605,7 +607,7 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in
605 return; 607 return;
606 608
607 case NAND_CMD_RESET: 609 case NAND_CMD_RESET:
608 if (this->dev_ready) 610 if (this->dev_ready)
609 break; 611 break;
610 udelay(this->chip_delay); 612 udelay(this->chip_delay);
611 this->hwcontrol(mtd, NAND_CTL_SETCLE); 613 this->hwcontrol(mtd, NAND_CTL_SETCLE);
@@ -614,16 +616,16 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in
614 while ( !(this->read_byte(mtd) & NAND_STATUS_READY)); 616 while ( !(this->read_byte(mtd) & NAND_STATUS_READY));
615 return; 617 return;
616 618
617 /* This applies to read commands */ 619 /* This applies to read commands */
618 default: 620 default:
619 /* 621 /*
620 * If we don't have access to the busy pin, we apply the given 622 * If we don't have access to the busy pin, we apply the given
621 * command delay 623 * command delay
622 */ 624 */
623 if (!this->dev_ready) { 625 if (!this->dev_ready) {
624 udelay (this->chip_delay); 626 udelay (this->chip_delay);
625 return; 627 return;
626 } 628 }
627 } 629 }
628 /* Apply this short delay always to ensure that we do wait tWB in 630 /* Apply this short delay always to ensure that we do wait tWB in
629 * any case on any machine. */ 631 * any case on any machine. */
@@ -653,8 +655,8 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
653 column += mtd->oobblock; 655 column += mtd->oobblock;
654 command = NAND_CMD_READ0; 656 command = NAND_CMD_READ0;
655 } 657 }
656 658
657 659
658 /* Begin command latch cycle */ 660 /* Begin command latch cycle */
659 this->hwcontrol(mtd, NAND_CTL_SETCLE); 661 this->hwcontrol(mtd, NAND_CTL_SETCLE);
660 /* Write out the command to the device. */ 662 /* Write out the command to the device. */
@@ -672,7 +674,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
672 column >>= 1; 674 column >>= 1;
673 this->write_byte(mtd, column & 0xff); 675 this->write_byte(mtd, column & 0xff);
674 this->write_byte(mtd, column >> 8); 676 this->write_byte(mtd, column >> 8);
675 } 677 }
676 if (page_addr != -1) { 678 if (page_addr != -1) {
677 this->write_byte(mtd, (unsigned char) (page_addr & 0xff)); 679 this->write_byte(mtd, (unsigned char) (page_addr & 0xff));
678 this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff)); 680 this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff));
@@ -683,13 +685,13 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
683 /* Latch in address */ 685 /* Latch in address */
684 this->hwcontrol(mtd, NAND_CTL_CLRALE); 686 this->hwcontrol(mtd, NAND_CTL_CLRALE);
685 } 687 }
686 688
687 /* 689 /*
688 * program and erase have their own busy handlers 690 * program and erase have their own busy handlers
689 * status, sequential in, and deplete1 need no delay 691 * status, sequential in, and deplete1 need no delay
690 */ 692 */
691 switch (command) { 693 switch (command) {
692 694
693 case NAND_CMD_CACHEDPROG: 695 case NAND_CMD_CACHEDPROG:
694 case NAND_CMD_PAGEPROG: 696 case NAND_CMD_PAGEPROG:
695 case NAND_CMD_ERASE1: 697 case NAND_CMD_ERASE1:
@@ -699,7 +701,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
699 case NAND_CMD_DEPLETE1: 701 case NAND_CMD_DEPLETE1:
700 return; 702 return;
701 703
702 /* 704 /*
703 * read error status commands require only a short delay 705 * read error status commands require only a short delay
704 */ 706 */
705 case NAND_CMD_STATUS_ERROR: 707 case NAND_CMD_STATUS_ERROR:
@@ -711,7 +713,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
711 return; 713 return;
712 714
713 case NAND_CMD_RESET: 715 case NAND_CMD_RESET:
714 if (this->dev_ready) 716 if (this->dev_ready)
715 break; 717 break;
716 udelay(this->chip_delay); 718 udelay(this->chip_delay);
717 this->hwcontrol(mtd, NAND_CTL_SETCLE); 719 this->hwcontrol(mtd, NAND_CTL_SETCLE);
@@ -728,17 +730,17 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
728 /* End command latch cycle */ 730 /* End command latch cycle */
729 this->hwcontrol(mtd, NAND_CTL_CLRCLE); 731 this->hwcontrol(mtd, NAND_CTL_CLRCLE);
730 /* Fall through into ready check */ 732 /* Fall through into ready check */
731 733
732 /* This applies to read commands */ 734 /* This applies to read commands */
733 default: 735 default:
734 /* 736 /*
735 * If we don't have access to the busy pin, we apply the given 737 * If we don't have access to the busy pin, we apply the given
736 * command delay 738 * command delay
737 */ 739 */
738 if (!this->dev_ready) { 740 if (!this->dev_ready) {
739 udelay (this->chip_delay); 741 udelay (this->chip_delay);
740 return; 742 return;
741 } 743 }
742 } 744 }
743 745
744 /* Apply this short delay always to ensure that we do wait tWB in 746 /* Apply this short delay always to ensure that we do wait tWB in
@@ -752,11 +754,11 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
752 * nand_get_device - [GENERIC] Get chip for selected access 754 * nand_get_device - [GENERIC] Get chip for selected access
753 * @this: the nand chip descriptor 755 * @this: the nand chip descriptor
754 * @mtd: MTD device structure 756 * @mtd: MTD device structure
755 * @new_state: the state which is requested 757 * @new_state: the state which is requested
756 * 758 *
757 * Get the device and lock it for exclusive access 759 * Get the device and lock it for exclusive access
758 */ 760 */
759static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state) 761static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
760{ 762{
761 struct nand_chip *active; 763 struct nand_chip *active;
762 spinlock_t *lock; 764 spinlock_t *lock;
@@ -779,7 +781,11 @@ retry:
779 if (active == this && this->state == FL_READY) { 781 if (active == this && this->state == FL_READY) {
780 this->state = new_state; 782 this->state = new_state;
781 spin_unlock(lock); 783 spin_unlock(lock);
782 return; 784 return 0;
785 }
786 if (new_state == FL_PM_SUSPENDED) {
787 spin_unlock(lock);
788 return (this->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
783 } 789 }
784 set_current_state(TASK_UNINTERRUPTIBLE); 790 set_current_state(TASK_UNINTERRUPTIBLE);
785 add_wait_queue(wq, &wait); 791 add_wait_queue(wq, &wait);
@@ -796,7 +802,7 @@ retry:
796 * @state: state to select the max. timeout value 802 * @state: state to select the max. timeout value
797 * 803 *
798 * Wait for command done. This applies to erase and program only 804 * Wait for command done. This applies to erase and program only
799 * Erase can take up to 400ms and program up to 20ms according to 805 * Erase can take up to 400ms and program up to 20ms according to
800 * general NAND and SmartMedia specs 806 * general NAND and SmartMedia specs
801 * 807 *
802*/ 808*/
@@ -805,7 +811,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
805 811
806 unsigned long timeo = jiffies; 812 unsigned long timeo = jiffies;
807 int status; 813 int status;
808 814
809 if (state == FL_ERASING) 815 if (state == FL_ERASING)
810 timeo += (HZ * 400) / 1000; 816 timeo += (HZ * 400) / 1000;
811 else 817 else
@@ -817,17 +823,17 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
817 823
818 if ((state == FL_ERASING) && (this->options & NAND_IS_AND)) 824 if ((state == FL_ERASING) && (this->options & NAND_IS_AND))
819 this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1); 825 this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1);
820 else 826 else
821 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); 827 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
822 828
823 while (time_before(jiffies, timeo)) { 829 while (time_before(jiffies, timeo)) {
824 /* Check, if we were interrupted */ 830 /* Check, if we were interrupted */
825 if (this->state != state) 831 if (this->state != state)
826 return 0; 832 return 0;
827 833
828 if (this->dev_ready) { 834 if (this->dev_ready) {
829 if (this->dev_ready(mtd)) 835 if (this->dev_ready(mtd))
830 break; 836 break;
831 } else { 837 } else {
832 if (this->read_byte(mtd) & NAND_STATUS_READY) 838 if (this->read_byte(mtd) & NAND_STATUS_READY)
833 break; 839 break;
@@ -853,7 +859,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
853 * 859 *
854 * Cached programming is not supported yet. 860 * Cached programming is not supported yet.
855 */ 861 */
856static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, 862static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page,
857 u_char *oob_buf, struct nand_oobinfo *oobsel, int cached) 863 u_char *oob_buf, struct nand_oobinfo *oobsel, int cached)
858{ 864{
859 int i, status; 865 int i, status;
@@ -862,10 +868,10 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa
862 int *oob_config = oobsel->eccpos; 868 int *oob_config = oobsel->eccpos;
863 int datidx = 0, eccidx = 0, eccsteps = this->eccsteps; 869 int datidx = 0, eccidx = 0, eccsteps = this->eccsteps;
864 int eccbytes = 0; 870 int eccbytes = 0;
865 871
866 /* FIXME: Enable cached programming */ 872 /* FIXME: Enable cached programming */
867 cached = 0; 873 cached = 0;
868 874
869 /* Send command to begin auto page programming */ 875 /* Send command to begin auto page programming */
870 this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page); 876 this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page);
871 877
@@ -876,7 +882,7 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa
876 printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); 882 printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n");
877 this->write_buf(mtd, this->data_poi, mtd->oobblock); 883 this->write_buf(mtd, this->data_poi, mtd->oobblock);
878 break; 884 break;
879 885
880 /* Software ecc 3/256, write all */ 886 /* Software ecc 3/256, write all */
881 case NAND_ECC_SOFT: 887 case NAND_ECC_SOFT:
882 for (; eccsteps; eccsteps--) { 888 for (; eccsteps; eccsteps--) {
@@ -905,11 +911,11 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa
905 } 911 }
906 break; 912 break;
907 } 913 }
908 914
909 /* Write out OOB data */ 915 /* Write out OOB data */
910 if (this->options & NAND_HWECC_SYNDROME) 916 if (this->options & NAND_HWECC_SYNDROME)
911 this->write_buf(mtd, &oob_buf[oobsel->eccbytes], mtd->oobsize - oobsel->eccbytes); 917 this->write_buf(mtd, &oob_buf[oobsel->eccbytes], mtd->oobsize - oobsel->eccbytes);
912 else 918 else
913 this->write_buf(mtd, oob_buf, mtd->oobsize); 919 this->write_buf(mtd, oob_buf, mtd->oobsize);
914 920
915 /* Send command to actually program the data */ 921 /* Send command to actually program the data */
@@ -934,7 +940,7 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa
934 /* wait until cache is ready*/ 940 /* wait until cache is ready*/
935 // status = this->waitfunc (mtd, this, FL_CACHEDRPG); 941 // status = this->waitfunc (mtd, this, FL_CACHEDRPG);
936 } 942 }
937 return 0; 943 return 0;
938} 944}
939 945
940#ifdef CONFIG_MTD_NAND_VERIFY_WRITE 946#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
@@ -950,19 +956,19 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa
950 * @oobmode: 1 = full buffer verify, 0 = ecc only 956 * @oobmode: 1 = full buffer verify, 0 = ecc only
951 * 957 *
952 * The NAND device assumes that it is always writing to a cleanly erased page. 958 * The NAND device assumes that it is always writing to a cleanly erased page.
953 * Hence, it performs its internal write verification only on bits that 959 * Hence, it performs its internal write verification only on bits that
954 * transitioned from 1 to 0. The device does NOT verify the whole page on a 960 * transitioned from 1 to 0. The device does NOT verify the whole page on a
955 * byte by byte basis. It is possible that the page was not completely erased 961 * byte by byte basis. It is possible that the page was not completely erased
956 * or the page is becoming unusable due to wear. The read with ECC would catch 962 * or the page is becoming unusable due to wear. The read with ECC would catch
957 * the error later when the ECC page check fails, but we would rather catch 963 * the error later when the ECC page check fails, but we would rather catch
958 * it early in the page write stage. Better to write no data than invalid data. 964 * it early in the page write stage. Better to write no data than invalid data.
959 */ 965 */
960static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, 966static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages,
961 u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode) 967 u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode)
962{ 968{
963 int i, j, datidx = 0, oobofs = 0, res = -EIO; 969 int i, j, datidx = 0, oobofs = 0, res = -EIO;
964 int eccsteps = this->eccsteps; 970 int eccsteps = this->eccsteps;
965 int hweccbytes; 971 int hweccbytes;
966 u_char oobdata[64]; 972 u_char oobdata[64];
967 973
968 hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0; 974 hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0;
@@ -1002,7 +1008,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
1002 1008
1003 if (oobsel->useecc != MTD_NANDECC_OFF && !hweccbytes) { 1009 if (oobsel->useecc != MTD_NANDECC_OFF && !hweccbytes) {
1004 int ecccnt = oobsel->eccbytes; 1010 int ecccnt = oobsel->eccbytes;
1005 1011
1006 for (i = 0; i < ecccnt; i++) { 1012 for (i = 0; i < ecccnt; i++) {
1007 int idx = oobsel->eccpos[i]; 1013 int idx = oobsel->eccpos[i];
1008 if (oobdata[idx] != oob_buf[oobofs + idx] ) { 1014 if (oobdata[idx] != oob_buf[oobofs + idx] ) {
@@ -1012,20 +1018,20 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
1012 goto out; 1018 goto out;
1013 } 1019 }
1014 } 1020 }
1015 } 1021 }
1016 } 1022 }
1017 oobofs += mtd->oobsize - hweccbytes * eccsteps; 1023 oobofs += mtd->oobsize - hweccbytes * eccsteps;
1018 page++; 1024 page++;
1019 numpages--; 1025 numpages--;
1020 1026
1021 /* Apply delay or wait for ready/busy pin 1027 /* Apply delay or wait for ready/busy pin
1022 * Do this before the AUTOINCR check, so no problems 1028 * Do this before the AUTOINCR check, so no problems
1023 * arise if a chip which does auto increment 1029 * arise if a chip which does auto increment
1024 * is marked as NOAUTOINCR by the board driver. 1030 * is marked as NOAUTOINCR by the board driver.
1025 * Do this also before returning, so the chip is 1031 * Do this also before returning, so the chip is
1026 * ready for the next command. 1032 * ready for the next command.
1027 */ 1033 */
1028 if (!this->dev_ready) 1034 if (!this->dev_ready)
1029 udelay (this->chip_delay); 1035 udelay (this->chip_delay);
1030 else 1036 else
1031 nand_wait_ready(mtd); 1037 nand_wait_ready(mtd);
@@ -1033,17 +1039,17 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
1033 /* All done, return happy */ 1039 /* All done, return happy */
1034 if (!numpages) 1040 if (!numpages)
1035 return 0; 1041 return 0;
1036 1042
1037 1043
1038 /* Check, if the chip supports auto page increment */ 1044 /* Check, if the chip supports auto page increment */
1039 if (!NAND_CANAUTOINCR(this)) 1045 if (!NAND_CANAUTOINCR(this))
1040 this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); 1046 this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page);
1041 } 1047 }
1042 /* 1048 /*
1043 * Terminate the read command. We come here in case of an error 1049 * Terminate the read command. We come here in case of an error
1044 * So we must issue a reset command. 1050 * So we must issue a reset command.
1045 */ 1051 */
1046out: 1052out:
1047 this->cmdfunc (mtd, NAND_CMD_RESET, -1, -1); 1053 this->cmdfunc (mtd, NAND_CMD_RESET, -1, -1);
1048 return res; 1054 return res;
1049} 1055}
@@ -1105,7 +1111,7 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1105 * NAND read with ECC 1111 * NAND read with ECC
1106 */ 1112 */
1107int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, 1113int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1108 size_t * retlen, u_char * buf, u_char * oob_buf, 1114 size_t * retlen, u_char * buf, u_char * oob_buf,
1109 struct nand_oobinfo *oobsel, int flags) 1115 struct nand_oobinfo *oobsel, int flags)
1110{ 1116{
1111 1117
@@ -1139,7 +1145,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1139 /* Autoplace of oob data ? Use the default placement scheme */ 1145 /* Autoplace of oob data ? Use the default placement scheme */
1140 if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) 1146 if (oobsel->useecc == MTD_NANDECC_AUTOPLACE)
1141 oobsel = this->autooob; 1147 oobsel = this->autooob;
1142 1148
1143 eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE; 1149 eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
1144 oob_config = oobsel->eccpos; 1150 oob_config = oobsel->eccpos;
1145 1151
@@ -1157,28 +1163,28 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1157 end = mtd->oobblock; 1163 end = mtd->oobblock;
1158 ecc = this->eccsize; 1164 ecc = this->eccsize;
1159 eccbytes = this->eccbytes; 1165 eccbytes = this->eccbytes;
1160 1166
1161 if ((eccmode == NAND_ECC_NONE) || (this->options & NAND_HWECC_SYNDROME)) 1167 if ((eccmode == NAND_ECC_NONE) || (this->options & NAND_HWECC_SYNDROME))
1162 compareecc = 0; 1168 compareecc = 0;
1163 1169
1164 oobreadlen = mtd->oobsize; 1170 oobreadlen = mtd->oobsize;
1165 if (this->options & NAND_HWECC_SYNDROME) 1171 if (this->options & NAND_HWECC_SYNDROME)
1166 oobreadlen -= oobsel->eccbytes; 1172 oobreadlen -= oobsel->eccbytes;
1167 1173
1168 /* Loop until all data read */ 1174 /* Loop until all data read */
1169 while (read < len) { 1175 while (read < len) {
1170 1176
1171 int aligned = (!col && (len - read) >= end); 1177 int aligned = (!col && (len - read) >= end);
1172 /* 1178 /*
1173 * If the read is not page aligned, we have to read into data buffer 1179 * If the read is not page aligned, we have to read into data buffer
1174 * due to ecc, else we read into return buffer direct 1180 * due to ecc, else we read into return buffer direct
1175 */ 1181 */
1176 if (aligned) 1182 if (aligned)
1177 data_poi = &buf[read]; 1183 data_poi = &buf[read];
1178 else 1184 else
1179 data_poi = this->data_buf; 1185 data_poi = this->data_buf;
1180 1186
1181 /* Check, if we have this page in the buffer 1187 /* Check, if we have this page in the buffer
1182 * 1188 *
1183 * FIXME: Make it work when we must provide oob data too, 1189 * FIXME: Make it work when we must provide oob data too,
1184 * check the usage of data_buf oob field 1190 * check the usage of data_buf oob field
@@ -1194,7 +1200,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1194 if (sndcmd) { 1200 if (sndcmd) {
1195 this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); 1201 this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page);
1196 sndcmd = 0; 1202 sndcmd = 0;
1197 } 1203 }
1198 1204
1199 /* get oob area, if we have no oob buffer from fs-driver */ 1205 /* get oob area, if we have no oob buffer from fs-driver */
1200 if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE || 1206 if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE ||
@@ -1202,7 +1208,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1202 oob_data = &this->data_buf[end]; 1208 oob_data = &this->data_buf[end];
1203 1209
1204 eccsteps = this->eccsteps; 1210 eccsteps = this->eccsteps;
1205 1211
1206 switch (eccmode) { 1212 switch (eccmode) {
1207 case NAND_ECC_NONE: { /* No ECC, Read in a page */ 1213 case NAND_ECC_NONE: { /* No ECC, Read in a page */
1208 static unsigned long lastwhinge = 0; 1214 static unsigned long lastwhinge = 0;
@@ -1213,12 +1219,12 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1213 this->read_buf(mtd, data_poi, end); 1219 this->read_buf(mtd, data_poi, end);
1214 break; 1220 break;
1215 } 1221 }
1216 1222
1217 case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */ 1223 case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */
1218 this->read_buf(mtd, data_poi, end); 1224 this->read_buf(mtd, data_poi, end);
1219 for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=3, datidx += ecc) 1225 for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=3, datidx += ecc)
1220 this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); 1226 this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]);
1221 break; 1227 break;
1222 1228
1223 default: 1229 default:
1224 for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=eccbytes, datidx += ecc) { 1230 for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=eccbytes, datidx += ecc) {
@@ -1237,15 +1243,15 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1237 * does the error correction on the fly */ 1243 * does the error correction on the fly */
1238 ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]); 1244 ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]);
1239 if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { 1245 if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) {
1240 DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " 1246 DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: "
1241 "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr); 1247 "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr);
1242 ecc_failed++; 1248 ecc_failed++;
1243 } 1249 }
1244 } else { 1250 } else {
1245 this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); 1251 this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]);
1246 } 1252 }
1247 } 1253 }
1248 break; 1254 break;
1249 } 1255 }
1250 1256
1251 /* read oobdata */ 1257 /* read oobdata */
@@ -1253,8 +1259,8 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1253 1259
1254 /* Skip ECC check, if not requested (ECC_NONE or HW_ECC with syndromes) */ 1260 /* Skip ECC check, if not requested (ECC_NONE or HW_ECC with syndromes) */
1255 if (!compareecc) 1261 if (!compareecc)
1256 goto readoob; 1262 goto readoob;
1257 1263
1258 /* Pick the ECC bytes out of the oob data */ 1264 /* Pick the ECC bytes out of the oob data */
1259 for (j = 0; j < oobsel->eccbytes; j++) 1265 for (j = 0; j < oobsel->eccbytes; j++)
1260 ecc_code[j] = oob_data[oob_config[j]]; 1266 ecc_code[j] = oob_data[oob_config[j]];
@@ -1262,24 +1268,24 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1262 /* correct data, if neccecary */ 1268 /* correct data, if neccecary */
1263 for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) { 1269 for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) {
1264 ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]); 1270 ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]);
1265 1271
1266 /* Get next chunk of ecc bytes */ 1272 /* Get next chunk of ecc bytes */
1267 j += eccbytes; 1273 j += eccbytes;
1268 1274
1269 /* Check, if we have a fs supplied oob-buffer, 1275 /* Check, if we have a fs supplied oob-buffer,
1270 * This is the legacy mode. Used by YAFFS1 1276 * This is the legacy mode. Used by YAFFS1
1271 * Should go away some day 1277 * Should go away some day
1272 */ 1278 */
1273 if (oob_buf && oobsel->useecc == MTD_NANDECC_PLACE) { 1279 if (oob_buf && oobsel->useecc == MTD_NANDECC_PLACE) {
1274 int *p = (int *)(&oob_data[mtd->oobsize]); 1280 int *p = (int *)(&oob_data[mtd->oobsize]);
1275 p[i] = ecc_status; 1281 p[i] = ecc_status;
1276 } 1282 }
1277 1283
1278 if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { 1284 if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) {
1279 DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page); 1285 DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page);
1280 ecc_failed++; 1286 ecc_failed++;
1281 } 1287 }
1282 } 1288 }
1283 1289
1284 readoob: 1290 readoob:
1285 /* check, if we have a fs supplied oob-buffer */ 1291 /* check, if we have a fs supplied oob-buffer */
@@ -1305,25 +1311,25 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1305 } 1311 }
1306 readdata: 1312 readdata:
1307 /* Partial page read, transfer data into fs buffer */ 1313 /* Partial page read, transfer data into fs buffer */
1308 if (!aligned) { 1314 if (!aligned) {
1309 for (j = col; j < end && read < len; j++) 1315 for (j = col; j < end && read < len; j++)
1310 buf[read++] = data_poi[j]; 1316 buf[read++] = data_poi[j];
1311 this->pagebuf = realpage; 1317 this->pagebuf = realpage;
1312 } else 1318 } else
1313 read += mtd->oobblock; 1319 read += mtd->oobblock;
1314 1320
1315 /* Apply delay or wait for ready/busy pin 1321 /* Apply delay or wait for ready/busy pin
1316 * Do this before the AUTOINCR check, so no problems 1322 * Do this before the AUTOINCR check, so no problems
1317 * arise if a chip which does auto increment 1323 * arise if a chip which does auto increment
1318 * is marked as NOAUTOINCR by the board driver. 1324 * is marked as NOAUTOINCR by the board driver.
1319 */ 1325 */
1320 if (!this->dev_ready) 1326 if (!this->dev_ready)
1321 udelay (this->chip_delay); 1327 udelay (this->chip_delay);
1322 else 1328 else
1323 nand_wait_ready(mtd); 1329 nand_wait_ready(mtd);
1324 1330
1325 if (read == len) 1331 if (read == len)
1326 break; 1332 break;
1327 1333
1328 /* For subsequent reads align to page boundary. */ 1334 /* For subsequent reads align to page boundary. */
1329 col = 0; 1335 col = 0;
@@ -1337,11 +1343,11 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1337 this->select_chip(mtd, -1); 1343 this->select_chip(mtd, -1);
1338 this->select_chip(mtd, chipnr); 1344 this->select_chip(mtd, chipnr);
1339 } 1345 }
1340 /* Check, if the chip supports auto page increment 1346 /* Check, if the chip supports auto page increment
1341 * or if we have hit a block boundary. 1347 * or if we have hit a block boundary.
1342 */ 1348 */
1343 if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) 1349 if (!NAND_CANAUTOINCR(this) || !(page & blockcheck))
1344 sndcmd = 1; 1350 sndcmd = 1;
1345 } 1351 }
1346 1352
1347 /* Deselect and wake up anyone waiting on the device */ 1353 /* Deselect and wake up anyone waiting on the device */
@@ -1378,7 +1384,7 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t
1378 /* Shift to get page */ 1384 /* Shift to get page */
1379 page = (int)(from >> this->page_shift); 1385 page = (int)(from >> this->page_shift);
1380 chipnr = (int)(from >> this->chip_shift); 1386 chipnr = (int)(from >> this->chip_shift);
1381 1387
1382 /* Mask to get column */ 1388 /* Mask to get column */
1383 col = from & (mtd->oobsize - 1); 1389 col = from & (mtd->oobsize - 1);
1384 1390
@@ -1400,7 +1406,7 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t
1400 1406
1401 /* Send the read command */ 1407 /* Send the read command */
1402 this->cmdfunc (mtd, NAND_CMD_READOOB, col, page & this->pagemask); 1408 this->cmdfunc (mtd, NAND_CMD_READOOB, col, page & this->pagemask);
1403 /* 1409 /*
1404 * Read the data, if we read more than one page 1410 * Read the data, if we read more than one page
1405 * oob data, let the device transfer the data ! 1411 * oob data, let the device transfer the data !
1406 */ 1412 */
@@ -1422,20 +1428,20 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t
1422 this->select_chip(mtd, -1); 1428 this->select_chip(mtd, -1);
1423 this->select_chip(mtd, chipnr); 1429 this->select_chip(mtd, chipnr);
1424 } 1430 }
1425 1431
1426 /* Apply delay or wait for ready/busy pin 1432 /* Apply delay or wait for ready/busy pin
1427 * Do this before the AUTOINCR check, so no problems 1433 * Do this before the AUTOINCR check, so no problems
1428 * arise if a chip which does auto increment 1434 * arise if a chip which does auto increment
1429 * is marked as NOAUTOINCR by the board driver. 1435 * is marked as NOAUTOINCR by the board driver.
1430 */ 1436 */
1431 if (!this->dev_ready) 1437 if (!this->dev_ready)
1432 udelay (this->chip_delay); 1438 udelay (this->chip_delay);
1433 else 1439 else
1434 nand_wait_ready(mtd); 1440 nand_wait_ready(mtd);
1435 1441
1436 /* Check, if the chip supports auto page increment 1442 /* Check, if the chip supports auto page increment
1437 * or if we have hit a block boundary. 1443 * or if we have hit a block boundary.
1438 */ 1444 */
1439 if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) { 1445 if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) {
1440 /* For subsequent page reads set offset to 0 */ 1446 /* For subsequent page reads set offset to 0 */
1441 this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask); 1447 this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask);
@@ -1481,27 +1487,27 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len,
1481 nand_get_device (this, mtd , FL_READING); 1487 nand_get_device (this, mtd , FL_READING);
1482 1488
1483 this->select_chip (mtd, chip); 1489 this->select_chip (mtd, chip);
1484 1490
1485 /* Add requested oob length */ 1491 /* Add requested oob length */
1486 len += ooblen; 1492 len += ooblen;
1487 1493
1488 while (len) { 1494 while (len) {
1489 if (sndcmd) 1495 if (sndcmd)
1490 this->cmdfunc (mtd, NAND_CMD_READ0, 0, page & this->pagemask); 1496 this->cmdfunc (mtd, NAND_CMD_READ0, 0, page & this->pagemask);
1491 sndcmd = 0; 1497 sndcmd = 0;
1492 1498
1493 this->read_buf (mtd, &buf[cnt], pagesize); 1499 this->read_buf (mtd, &buf[cnt], pagesize);
1494 1500
1495 len -= pagesize; 1501 len -= pagesize;
1496 cnt += pagesize; 1502 cnt += pagesize;
1497 page++; 1503 page++;
1498 1504
1499 if (!this->dev_ready) 1505 if (!this->dev_ready)
1500 udelay (this->chip_delay); 1506 udelay (this->chip_delay);
1501 else 1507 else
1502 nand_wait_ready(mtd); 1508 nand_wait_ready(mtd);
1503 1509
1504 /* Check, if the chip supports auto page increment */ 1510 /* Check, if the chip supports auto page increment */
1505 if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) 1511 if (!NAND_CANAUTOINCR(this) || !(page & blockcheck))
1506 sndcmd = 1; 1512 sndcmd = 1;
1507 } 1513 }
@@ -1512,8 +1518,8 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len,
1512} 1518}
1513 1519
1514 1520
1515/** 1521/**
1516 * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer 1522 * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer
1517 * @mtd: MTD device structure 1523 * @mtd: MTD device structure
1518 * @fsbuf: buffer given by fs driver 1524 * @fsbuf: buffer given by fs driver
1519 * @oobsel: out of band selection structre 1525 * @oobsel: out of band selection structre
@@ -1542,20 +1548,20 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct
1542 int i, len, ofs; 1548 int i, len, ofs;
1543 1549
1544 /* Zero copy fs supplied buffer */ 1550 /* Zero copy fs supplied buffer */
1545 if (fsbuf && !autoplace) 1551 if (fsbuf && !autoplace)
1546 return fsbuf; 1552 return fsbuf;
1547 1553
1548 /* Check, if the buffer must be filled with ff again */ 1554 /* Check, if the buffer must be filled with ff again */
1549 if (this->oobdirty) { 1555 if (this->oobdirty) {
1550 memset (this->oob_buf, 0xff, 1556 memset (this->oob_buf, 0xff,
1551 mtd->oobsize << (this->phys_erase_shift - this->page_shift)); 1557 mtd->oobsize << (this->phys_erase_shift - this->page_shift));
1552 this->oobdirty = 0; 1558 this->oobdirty = 0;
1553 } 1559 }
1554 1560
1555 /* If we have no autoplacement or no fs buffer use the internal one */ 1561 /* If we have no autoplacement or no fs buffer use the internal one */
1556 if (!autoplace || !fsbuf) 1562 if (!autoplace || !fsbuf)
1557 return this->oob_buf; 1563 return this->oob_buf;
1558 1564
1559 /* Walk through the pages and place the data */ 1565 /* Walk through the pages and place the data */
1560 this->oobdirty = 1; 1566 this->oobdirty = 1;
1561 ofs = 0; 1567 ofs = 0;
@@ -1589,7 +1595,7 @@ static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * ret
1589{ 1595{
1590 return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL)); 1596 return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL));
1591} 1597}
1592 1598
1593/** 1599/**
1594 * nand_write_ecc - [MTD Interface] NAND write with ECC 1600 * nand_write_ecc - [MTD Interface] NAND write with ECC
1595 * @mtd: MTD device structure 1601 * @mtd: MTD device structure
@@ -1622,7 +1628,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
1622 return -EINVAL; 1628 return -EINVAL;
1623 } 1629 }
1624 1630
1625 /* reject writes, which are not page aligned */ 1631 /* reject writes, which are not page aligned */
1626 if (NOTALIGNED (to) || NOTALIGNED(len)) { 1632 if (NOTALIGNED (to) || NOTALIGNED(len)) {
1627 printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); 1633 printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
1628 return -EINVAL; 1634 return -EINVAL;
@@ -1641,14 +1647,14 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
1641 goto out; 1647 goto out;
1642 1648
1643 /* if oobsel is NULL, use chip defaults */ 1649 /* if oobsel is NULL, use chip defaults */
1644 if (oobsel == NULL) 1650 if (oobsel == NULL)
1645 oobsel = &mtd->oobinfo; 1651 oobsel = &mtd->oobinfo;
1646 1652
1647 /* Autoplace of oob data ? Use the default placement scheme */ 1653 /* Autoplace of oob data ? Use the default placement scheme */
1648 if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) { 1654 if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) {
1649 oobsel = this->autooob; 1655 oobsel = this->autooob;
1650 autoplace = 1; 1656 autoplace = 1;
1651 } 1657 }
1652 if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR) 1658 if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
1653 autoplace = 1; 1659 autoplace = 1;
1654 1660
@@ -1656,9 +1662,9 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
1656 totalpages = len >> this->page_shift; 1662 totalpages = len >> this->page_shift;
1657 page = (int) (to >> this->page_shift); 1663 page = (int) (to >> this->page_shift);
1658 /* Invalidate the page cache, if we write to the cached page */ 1664 /* Invalidate the page cache, if we write to the cached page */
1659 if (page <= this->pagebuf && this->pagebuf < (page + totalpages)) 1665 if (page <= this->pagebuf && this->pagebuf < (page + totalpages))
1660 this->pagebuf = -1; 1666 this->pagebuf = -1;
1661 1667
1662 /* Set it relative to chip */ 1668 /* Set it relative to chip */
1663 page &= this->pagemask; 1669 page &= this->pagemask;
1664 startpage = page; 1670 startpage = page;
@@ -1680,14 +1686,14 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
1680 if (ret) { 1686 if (ret) {
1681 DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret); 1687 DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret);
1682 goto out; 1688 goto out;
1683 } 1689 }
1684 /* Next oob page */ 1690 /* Next oob page */
1685 oob += mtd->oobsize; 1691 oob += mtd->oobsize;
1686 /* Update written bytes count */ 1692 /* Update written bytes count */
1687 written += mtd->oobblock; 1693 written += mtd->oobblock;
1688 if (written == len) 1694 if (written == len)
1689 goto cmp; 1695 goto cmp;
1690 1696
1691 /* Increment page address */ 1697 /* Increment page address */
1692 page++; 1698 page++;
1693 1699
@@ -1698,13 +1704,13 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
1698 if (!(page & (ppblock - 1))){ 1704 if (!(page & (ppblock - 1))){
1699 int ofs; 1705 int ofs;
1700 this->data_poi = bufstart; 1706 this->data_poi = bufstart;
1701 ret = nand_verify_pages (mtd, this, startpage, 1707 ret = nand_verify_pages (mtd, this, startpage,
1702 page - startpage, 1708 page - startpage,
1703 oobbuf, oobsel, chipnr, (eccbuf != NULL)); 1709 oobbuf, oobsel, chipnr, (eccbuf != NULL));
1704 if (ret) { 1710 if (ret) {
1705 DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); 1711 DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret);
1706 goto out; 1712 goto out;
1707 } 1713 }
1708 *retlen = written; 1714 *retlen = written;
1709 1715
1710 ofs = autoplace ? mtd->oobavail : mtd->oobsize; 1716 ofs = autoplace ? mtd->oobavail : mtd->oobsize;
@@ -1714,8 +1720,9 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
1714 numpages = min (totalpages, ppblock); 1720 numpages = min (totalpages, ppblock);
1715 page &= this->pagemask; 1721 page &= this->pagemask;
1716 startpage = page; 1722 startpage = page;
1717 oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, 1723 oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel,
1718 autoplace, numpages); 1724 autoplace, numpages);
1725 oob = 0;
1719 /* Check, if we cross a chip boundary */ 1726 /* Check, if we cross a chip boundary */
1720 if (!page) { 1727 if (!page) {
1721 chipnr++; 1728 chipnr++;
@@ -1731,7 +1738,7 @@ cmp:
1731 oobbuf, oobsel, chipnr, (eccbuf != NULL)); 1738 oobbuf, oobsel, chipnr, (eccbuf != NULL));
1732 if (!ret) 1739 if (!ret)
1733 *retlen = written; 1740 *retlen = written;
1734 else 1741 else
1735 DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); 1742 DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret);
1736 1743
1737out: 1744out:
@@ -1791,7 +1798,7 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t *
1791 /* Check, if it is write protected */ 1798 /* Check, if it is write protected */
1792 if (nand_check_wp(mtd)) 1799 if (nand_check_wp(mtd))
1793 goto out; 1800 goto out;
1794 1801
1795 /* Invalidate the page cache, if we write to the cached page */ 1802 /* Invalidate the page cache, if we write to the cached page */
1796 if (page == this->pagebuf) 1803 if (page == this->pagebuf)
1797 this->pagebuf = -1; 1804 this->pagebuf = -1;
@@ -1854,10 +1861,10 @@ out:
1854 * 1861 *
1855 * NAND write with kvec. This just calls the ecc function 1862 * NAND write with kvec. This just calls the ecc function
1856 */ 1863 */
1857static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, 1864static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count,
1858 loff_t to, size_t * retlen) 1865 loff_t to, size_t * retlen)
1859{ 1866{
1860 return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, NULL)); 1867 return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, NULL));
1861} 1868}
1862 1869
1863/** 1870/**
@@ -1872,7 +1879,7 @@ static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned
1872 * 1879 *
1873 * NAND write with iovec with ecc 1880 * NAND write with iovec with ecc
1874 */ 1881 */
1875static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, 1882static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count,
1876 loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel) 1883 loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel)
1877{ 1884{
1878 int i, page, len, total_len, ret = -EIO, written = 0, chipnr; 1885 int i, page, len, total_len, ret = -EIO, written = 0, chipnr;
@@ -1898,7 +1905,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
1898 return -EINVAL; 1905 return -EINVAL;
1899 } 1906 }
1900 1907
1901 /* reject writes, which are not page aligned */ 1908 /* reject writes, which are not page aligned */
1902 if (NOTALIGNED (to) || NOTALIGNED(total_len)) { 1909 if (NOTALIGNED (to) || NOTALIGNED(total_len)) {
1903 printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); 1910 printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
1904 return -EINVAL; 1911 return -EINVAL;
@@ -1917,21 +1924,21 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
1917 goto out; 1924 goto out;
1918 1925
1919 /* if oobsel is NULL, use chip defaults */ 1926 /* if oobsel is NULL, use chip defaults */
1920 if (oobsel == NULL) 1927 if (oobsel == NULL)
1921 oobsel = &mtd->oobinfo; 1928 oobsel = &mtd->oobinfo;
1922 1929
1923 /* Autoplace of oob data ? Use the default placement scheme */ 1930 /* Autoplace of oob data ? Use the default placement scheme */
1924 if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) { 1931 if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) {
1925 oobsel = this->autooob; 1932 oobsel = this->autooob;
1926 autoplace = 1; 1933 autoplace = 1;
1927 } 1934 }
1928 if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR) 1935 if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
1929 autoplace = 1; 1936 autoplace = 1;
1930 1937
1931 /* Setup start page */ 1938 /* Setup start page */
1932 page = (int) (to >> this->page_shift); 1939 page = (int) (to >> this->page_shift);
1933 /* Invalidate the page cache, if we write to the cached page */ 1940 /* Invalidate the page cache, if we write to the cached page */
1934 if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift)) 1941 if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift))
1935 this->pagebuf = -1; 1942 this->pagebuf = -1;
1936 1943
1937 startpage = page & this->pagemask; 1944 startpage = page & this->pagemask;
@@ -1955,10 +1962,10 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
1955 oob = 0; 1962 oob = 0;
1956 for (i = 1; i <= numpages; i++) { 1963 for (i = 1; i <= numpages; i++) {
1957 /* Write one page. If this is the last page to write 1964 /* Write one page. If this is the last page to write
1958 * then use the real pageprogram command, else select 1965 * then use the real pageprogram command, else select
1959 * cached programming if supported by the chip. 1966 * cached programming if supported by the chip.
1960 */ 1967 */
1961 ret = nand_write_page (mtd, this, page & this->pagemask, 1968 ret = nand_write_page (mtd, this, page & this->pagemask,
1962 &oobbuf[oob], oobsel, i != numpages); 1969 &oobbuf[oob], oobsel, i != numpages);
1963 if (ret) 1970 if (ret)
1964 goto out; 1971 goto out;
@@ -1974,12 +1981,12 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
1974 count--; 1981 count--;
1975 } 1982 }
1976 } else { 1983 } else {
1977 /* We must use the internal buffer, read data out of each 1984 /* We must use the internal buffer, read data out of each
1978 * tuple until we have a full page to write 1985 * tuple until we have a full page to write
1979 */ 1986 */
1980 int cnt = 0; 1987 int cnt = 0;
1981 while (cnt < mtd->oobblock) { 1988 while (cnt < mtd->oobblock) {
1982 if (vecs->iov_base != NULL && vecs->iov_len) 1989 if (vecs->iov_base != NULL && vecs->iov_len)
1983 this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; 1990 this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++];
1984 /* Check, if we have to switch to the next tuple */ 1991 /* Check, if we have to switch to the next tuple */
1985 if (len >= (int) vecs->iov_len) { 1992 if (len >= (int) vecs->iov_len) {
@@ -1988,10 +1995,10 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
1988 count--; 1995 count--;
1989 } 1996 }
1990 } 1997 }
1991 this->pagebuf = page; 1998 this->pagebuf = page;
1992 this->data_poi = this->data_buf; 1999 this->data_poi = this->data_buf;
1993 bufstart = this->data_poi; 2000 bufstart = this->data_poi;
1994 numpages = 1; 2001 numpages = 1;
1995 oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages); 2002 oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages);
1996 ret = nand_write_page (mtd, this, page & this->pagemask, 2003 ret = nand_write_page (mtd, this, page & this->pagemask,
1997 oobbuf, oobsel, 0); 2004 oobbuf, oobsel, 0);
@@ -2004,7 +2011,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
2004 ret = nand_verify_pages (mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0); 2011 ret = nand_verify_pages (mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0);
2005 if (ret) 2012 if (ret)
2006 goto out; 2013 goto out;
2007 2014
2008 written += mtd->oobblock * numpages; 2015 written += mtd->oobblock * numpages;
2009 /* All done ? */ 2016 /* All done ? */
2010 if (!count) 2017 if (!count)
@@ -2072,7 +2079,7 @@ static int nand_erase (struct mtd_info *mtd, struct erase_info *instr)
2072{ 2079{
2073 return nand_erase_nand (mtd, instr, 0); 2080 return nand_erase_nand (mtd, instr, 0);
2074} 2081}
2075 2082
2076#define BBT_PAGE_MASK 0xffffff3f 2083#define BBT_PAGE_MASK 0xffffff3f
2077/** 2084/**
2078 * nand_erase_intern - [NAND Interface] erase block(s) 2085 * nand_erase_intern - [NAND Interface] erase block(s)
@@ -2154,14 +2161,14 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
2154 instr->state = MTD_ERASE_FAILED; 2161 instr->state = MTD_ERASE_FAILED;
2155 goto erase_exit; 2162 goto erase_exit;
2156 } 2163 }
2157 2164
2158 /* Invalidate the page cache, if we erase the block which contains 2165 /* Invalidate the page cache, if we erase the block which contains
2159 the current cached page */ 2166 the current cached page */
2160 if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block)) 2167 if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block))
2161 this->pagebuf = -1; 2168 this->pagebuf = -1;
2162 2169
2163 this->erase_cmd (mtd, page & this->pagemask); 2170 this->erase_cmd (mtd, page & this->pagemask);
2164 2171
2165 status = this->waitfunc (mtd, this, FL_ERASING); 2172 status = this->waitfunc (mtd, this, FL_ERASING);
2166 2173
2167 /* See if operation failed and additional status checks are available */ 2174 /* See if operation failed and additional status checks are available */
@@ -2179,12 +2186,12 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
2179 2186
2180 /* if BBT requires refresh, set the BBT rewrite flag to the page being erased */ 2187 /* if BBT requires refresh, set the BBT rewrite flag to the page being erased */
2181 if (this->options & BBT_AUTO_REFRESH) { 2188 if (this->options & BBT_AUTO_REFRESH) {
2182 if (((page & BBT_PAGE_MASK) == bbt_masked_page) && 2189 if (((page & BBT_PAGE_MASK) == bbt_masked_page) &&
2183 (page != this->bbt_td->pages[chipnr])) { 2190 (page != this->bbt_td->pages[chipnr])) {
2184 rewrite_bbt[chipnr] = (page << this->page_shift); 2191 rewrite_bbt[chipnr] = (page << this->page_shift);
2185 } 2192 }
2186 } 2193 }
2187 2194
2188 /* Increment page address and decrement length */ 2195 /* Increment page address and decrement length */
2189 len -= (1 << this->phys_erase_shift); 2196 len -= (1 << this->phys_erase_shift);
2190 page += pages_per_block; 2197 page += pages_per_block;
@@ -2195,7 +2202,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
2195 this->select_chip(mtd, -1); 2202 this->select_chip(mtd, -1);
2196 this->select_chip(mtd, chipnr); 2203 this->select_chip(mtd, chipnr);
2197 2204
2198 /* if BBT requires refresh and BBT-PERCHIP, 2205 /* if BBT requires refresh and BBT-PERCHIP,
2199 * set the BBT page mask to see if this BBT should be rewritten */ 2206 * set the BBT page mask to see if this BBT should be rewritten */
2200 if ((this->options & BBT_AUTO_REFRESH) && (this->bbt_td->options & NAND_BBT_PERCHIP)) { 2207 if ((this->options & BBT_AUTO_REFRESH) && (this->bbt_td->options & NAND_BBT_PERCHIP)) {
2201 bbt_masked_page = this->bbt_td->pages[chipnr] & BBT_PAGE_MASK; 2208 bbt_masked_page = this->bbt_td->pages[chipnr] & BBT_PAGE_MASK;
@@ -2220,7 +2227,7 @@ erase_exit:
2220 for (chipnr = 0; chipnr < this->numchips; chipnr++) { 2227 for (chipnr = 0; chipnr < this->numchips; chipnr++) {
2221 if (rewrite_bbt[chipnr]) { 2228 if (rewrite_bbt[chipnr]) {
2222 /* update the BBT for chip */ 2229 /* update the BBT for chip */
2223 DEBUG (MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n", 2230 DEBUG (MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n",
2224 chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]); 2231 chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]);
2225 nand_update_bbt (mtd, rewrite_bbt[chipnr]); 2232 nand_update_bbt (mtd, rewrite_bbt[chipnr]);
2226 } 2233 }
@@ -2258,9 +2265,9 @@ static void nand_sync (struct mtd_info *mtd)
2258static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs) 2265static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs)
2259{ 2266{
2260 /* Check for invalid offset */ 2267 /* Check for invalid offset */
2261 if (ofs > mtd->size) 2268 if (ofs > mtd->size)
2262 return -EINVAL; 2269 return -EINVAL;
2263 2270
2264 return nand_block_checkbad (mtd, ofs, 1, 0); 2271 return nand_block_checkbad (mtd, ofs, 1, 0);
2265} 2272}
2266 2273
@@ -2285,6 +2292,34 @@ static int nand_block_markbad (struct mtd_info *mtd, loff_t ofs)
2285} 2292}
2286 2293
2287/** 2294/**
2295 * nand_suspend - [MTD Interface] Suspend the NAND flash
2296 * @mtd: MTD device structure
2297 */
2298static int nand_suspend(struct mtd_info *mtd)
2299{
2300 struct nand_chip *this = mtd->priv;
2301
2302 return nand_get_device (this, mtd, FL_PM_SUSPENDED);
2303}
2304
2305/**
2306 * nand_resume - [MTD Interface] Resume the NAND flash
2307 * @mtd: MTD device structure
2308 */
2309static void nand_resume(struct mtd_info *mtd)
2310{
2311 struct nand_chip *this = mtd->priv;
2312
2313 if (this->state == FL_PM_SUSPENDED)
2314 nand_release_device(mtd);
2315 else
2316 printk(KERN_ERR "resume() called for the chip which is not "
2317 "in suspended state\n");
2318
2319}
2320
2321
2322/**
2288 * nand_scan - [NAND Interface] Scan for the NAND device 2323 * nand_scan - [NAND Interface] Scan for the NAND device
2289 * @mtd: MTD device structure 2324 * @mtd: MTD device structure
2290 * @maxchips: Number of chips to scan for 2325 * @maxchips: Number of chips to scan for
@@ -2351,13 +2386,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2351 2386
2352 /* Print and store flash device information */ 2387 /* Print and store flash device information */
2353 for (i = 0; nand_flash_ids[i].name != NULL; i++) { 2388 for (i = 0; nand_flash_ids[i].name != NULL; i++) {
2354 2389
2355 if (nand_dev_id != nand_flash_ids[i].id) 2390 if (nand_dev_id != nand_flash_ids[i].id)
2356 continue; 2391 continue;
2357 2392
2358 if (!mtd->name) mtd->name = nand_flash_ids[i].name; 2393 if (!mtd->name) mtd->name = nand_flash_ids[i].name;
2359 this->chipsize = nand_flash_ids[i].chipsize << 20; 2394 this->chipsize = nand_flash_ids[i].chipsize << 20;
2360 2395
2361 /* New devices have all the information in additional id bytes */ 2396 /* New devices have all the information in additional id bytes */
2362 if (!nand_flash_ids[i].pagesize) { 2397 if (!nand_flash_ids[i].pagesize) {
2363 int extid; 2398 int extid;
@@ -2369,14 +2404,14 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2369 mtd->oobblock = 1024 << (extid & 0x3); 2404 mtd->oobblock = 1024 << (extid & 0x3);
2370 extid >>= 2; 2405 extid >>= 2;
2371 /* Calc oobsize */ 2406 /* Calc oobsize */
2372 mtd->oobsize = (8 << (extid & 0x03)) * (mtd->oobblock / 512); 2407 mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9);
2373 extid >>= 2; 2408 extid >>= 2;
2374 /* Calc blocksize. Blocksize is multiples of 64KiB */ 2409 /* Calc blocksize. Blocksize is multiples of 64KiB */
2375 mtd->erasesize = (64 * 1024) << (extid & 0x03); 2410 mtd->erasesize = (64 * 1024) << (extid & 0x03);
2376 extid >>= 2; 2411 extid >>= 2;
2377 /* Get buswidth information */ 2412 /* Get buswidth information */
2378 busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; 2413 busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0;
2379 2414
2380 } else { 2415 } else {
2381 /* Old devices have this data hardcoded in the 2416 /* Old devices have this data hardcoded in the
2382 * device id table */ 2417 * device id table */
@@ -2396,23 +2431,23 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2396 * this correct ! */ 2431 * this correct ! */
2397 if (busw != (this->options & NAND_BUSWIDTH_16)) { 2432 if (busw != (this->options & NAND_BUSWIDTH_16)) {
2398 printk (KERN_INFO "NAND device: Manufacturer ID:" 2433 printk (KERN_INFO "NAND device: Manufacturer ID:"
2399 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, 2434 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id,
2400 nand_manuf_ids[maf_id].name , mtd->name); 2435 nand_manuf_ids[maf_id].name , mtd->name);
2401 printk (KERN_WARNING 2436 printk (KERN_WARNING
2402 "NAND bus width %d instead %d bit\n", 2437 "NAND bus width %d instead %d bit\n",
2403 (this->options & NAND_BUSWIDTH_16) ? 16 : 8, 2438 (this->options & NAND_BUSWIDTH_16) ? 16 : 8,
2404 busw ? 16 : 8); 2439 busw ? 16 : 8);
2405 this->select_chip(mtd, -1); 2440 this->select_chip(mtd, -1);
2406 return 1; 2441 return 1;
2407 } 2442 }
2408 2443
2409 /* Calculate the address shift from the page size */ 2444 /* Calculate the address shift from the page size */
2410 this->page_shift = ffs(mtd->oobblock) - 1; 2445 this->page_shift = ffs(mtd->oobblock) - 1;
2411 this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1; 2446 this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1;
2412 this->chip_shift = ffs(this->chipsize) - 1; 2447 this->chip_shift = ffs(this->chipsize) - 1;
2413 2448
2414 /* Set the bad block position */ 2449 /* Set the bad block position */
2415 this->badblockpos = mtd->oobblock > 512 ? 2450 this->badblockpos = mtd->oobblock > 512 ?
2416 NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; 2451 NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
2417 2452
2418 /* Get chip options, preserve non chip based options */ 2453 /* Get chip options, preserve non chip based options */
@@ -2422,10 +2457,10 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2422 this->options |= NAND_NO_AUTOINCR; 2457 this->options |= NAND_NO_AUTOINCR;
2423 /* Check if this is a not a samsung device. Do not clear the options 2458 /* Check if this is a not a samsung device. Do not clear the options
2424 * for chips which are not having an extended id. 2459 * for chips which are not having an extended id.
2425 */ 2460 */
2426 if (nand_maf_id != NAND_MFR_SAMSUNG && !nand_flash_ids[i].pagesize) 2461 if (nand_maf_id != NAND_MFR_SAMSUNG && !nand_flash_ids[i].pagesize)
2427 this->options &= ~NAND_SAMSUNG_LP_OPTIONS; 2462 this->options &= ~NAND_SAMSUNG_LP_OPTIONS;
2428 2463
2429 /* Check for AND chips with 4 page planes */ 2464 /* Check for AND chips with 4 page planes */
2430 if (this->options & NAND_4PAGE_ARRAY) 2465 if (this->options & NAND_4PAGE_ARRAY)
2431 this->erase_cmd = multi_erase_cmd; 2466 this->erase_cmd = multi_erase_cmd;
@@ -2435,9 +2470,9 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2435 /* Do not replace user supplied command function ! */ 2470 /* Do not replace user supplied command function ! */
2436 if (mtd->oobblock > 512 && this->cmdfunc == nand_command) 2471 if (mtd->oobblock > 512 && this->cmdfunc == nand_command)
2437 this->cmdfunc = nand_command_lp; 2472 this->cmdfunc = nand_command_lp;
2438 2473
2439 printk (KERN_INFO "NAND device: Manufacturer ID:" 2474 printk (KERN_INFO "NAND device: Manufacturer ID:"
2440 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, 2475 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id,
2441 nand_manuf_ids[maf_id].name , nand_flash_ids[i].name); 2476 nand_manuf_ids[maf_id].name , nand_flash_ids[i].name);
2442 break; 2477 break;
2443 } 2478 }
@@ -2461,7 +2496,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2461 } 2496 }
2462 if (i > 1) 2497 if (i > 1)
2463 printk(KERN_INFO "%d NAND chips detected\n", i); 2498 printk(KERN_INFO "%d NAND chips detected\n", i);
2464 2499
2465 /* Allocate buffers, if neccecary */ 2500 /* Allocate buffers, if neccecary */
2466 if (!this->oob_buf) { 2501 if (!this->oob_buf) {
2467 size_t len; 2502 size_t len;
@@ -2473,7 +2508,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2473 } 2508 }
2474 this->options |= NAND_OOBBUF_ALLOC; 2509 this->options |= NAND_OOBBUF_ALLOC;
2475 } 2510 }
2476 2511
2477 if (!this->data_buf) { 2512 if (!this->data_buf) {
2478 size_t len; 2513 size_t len;
2479 len = mtd->oobblock + mtd->oobsize; 2514 len = mtd->oobblock + mtd->oobsize;
@@ -2500,7 +2535,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2500 if (!this->autooob) { 2535 if (!this->autooob) {
2501 /* Select the appropriate default oob placement scheme for 2536 /* Select the appropriate default oob placement scheme for
2502 * placement agnostic filesystems */ 2537 * placement agnostic filesystems */
2503 switch (mtd->oobsize) { 2538 switch (mtd->oobsize) {
2504 case 8: 2539 case 8:
2505 this->autooob = &nand_oob_8; 2540 this->autooob = &nand_oob_8;
2506 break; 2541 break;
@@ -2516,19 +2551,19 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2516 BUG(); 2551 BUG();
2517 } 2552 }
2518 } 2553 }
2519 2554
2520 /* The number of bytes available for the filesystem to place fs dependend 2555 /* The number of bytes available for the filesystem to place fs dependend
2521 * oob data */ 2556 * oob data */
2522 mtd->oobavail = 0; 2557 mtd->oobavail = 0;
2523 for (i = 0; this->autooob->oobfree[i][1]; i++) 2558 for (i = 0; this->autooob->oobfree[i][1]; i++)
2524 mtd->oobavail += this->autooob->oobfree[i][1]; 2559 mtd->oobavail += this->autooob->oobfree[i][1];
2525 2560
2526 /* 2561 /*
2527 * check ECC mode, default to software 2562 * check ECC mode, default to software
2528 * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize 2563 * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize
2529 * fallback to software ECC 2564 * fallback to software ECC
2530 */ 2565 */
2531 this->eccsize = 256; /* set default eccsize */ 2566 this->eccsize = 256; /* set default eccsize */
2532 this->eccbytes = 3; 2567 this->eccbytes = 3;
2533 2568
2534 switch (this->eccmode) { 2569 switch (this->eccmode) {
@@ -2543,56 +2578,56 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2543 this->eccsize = 2048; 2578 this->eccsize = 2048;
2544 break; 2579 break;
2545 2580
2546 case NAND_ECC_HW3_512: 2581 case NAND_ECC_HW3_512:
2547 case NAND_ECC_HW6_512: 2582 case NAND_ECC_HW6_512:
2548 case NAND_ECC_HW8_512: 2583 case NAND_ECC_HW8_512:
2549 if (mtd->oobblock == 256) { 2584 if (mtd->oobblock == 256) {
2550 printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); 2585 printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n");
2551 this->eccmode = NAND_ECC_SOFT; 2586 this->eccmode = NAND_ECC_SOFT;
2552 this->calculate_ecc = nand_calculate_ecc; 2587 this->calculate_ecc = nand_calculate_ecc;
2553 this->correct_data = nand_correct_data; 2588 this->correct_data = nand_correct_data;
2554 } else 2589 } else
2555 this->eccsize = 512; /* set eccsize to 512 */ 2590 this->eccsize = 512; /* set eccsize to 512 */
2556 break; 2591 break;
2557 2592
2558 case NAND_ECC_HW3_256: 2593 case NAND_ECC_HW3_256:
2559 break; 2594 break;
2560 2595
2561 case NAND_ECC_NONE: 2596 case NAND_ECC_NONE:
2562 printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n"); 2597 printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n");
2563 this->eccmode = NAND_ECC_NONE; 2598 this->eccmode = NAND_ECC_NONE;
2564 break; 2599 break;
2565 2600
2566 case NAND_ECC_SOFT: 2601 case NAND_ECC_SOFT:
2567 this->calculate_ecc = nand_calculate_ecc; 2602 this->calculate_ecc = nand_calculate_ecc;
2568 this->correct_data = nand_correct_data; 2603 this->correct_data = nand_correct_data;
2569 break; 2604 break;
2570 2605
2571 default: 2606 default:
2572 printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); 2607 printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
2573 BUG(); 2608 BUG();
2574 } 2609 }
2575 2610
2576 /* Check hardware ecc function availability and adjust number of ecc bytes per 2611 /* Check hardware ecc function availability and adjust number of ecc bytes per
2577 * calculation step 2612 * calculation step
2578 */ 2613 */
2579 switch (this->eccmode) { 2614 switch (this->eccmode) {
2580 case NAND_ECC_HW12_2048: 2615 case NAND_ECC_HW12_2048:
2581 this->eccbytes += 4; 2616 this->eccbytes += 4;
2582 case NAND_ECC_HW8_512: 2617 case NAND_ECC_HW8_512:
2583 this->eccbytes += 2; 2618 this->eccbytes += 2;
2584 case NAND_ECC_HW6_512: 2619 case NAND_ECC_HW6_512:
2585 this->eccbytes += 3; 2620 this->eccbytes += 3;
2586 case NAND_ECC_HW3_512: 2621 case NAND_ECC_HW3_512:
2587 case NAND_ECC_HW3_256: 2622 case NAND_ECC_HW3_256:
2588 if (this->calculate_ecc && this->correct_data && this->enable_hwecc) 2623 if (this->calculate_ecc && this->correct_data && this->enable_hwecc)
2589 break; 2624 break;
2590 printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n"); 2625 printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n");
2591 BUG(); 2626 BUG();
2592 } 2627 }
2593 2628
2594 mtd->eccsize = this->eccsize; 2629 mtd->eccsize = this->eccsize;
2595 2630
2596 /* Set the number of read / write steps for one page to ensure ECC generation */ 2631 /* Set the number of read / write steps for one page to ensure ECC generation */
2597 switch (this->eccmode) { 2632 switch (this->eccmode) {
2598 case NAND_ECC_HW12_2048: 2633 case NAND_ECC_HW12_2048:
@@ -2604,15 +2639,15 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2604 this->eccsteps = mtd->oobblock / 512; 2639 this->eccsteps = mtd->oobblock / 512;
2605 break; 2640 break;
2606 case NAND_ECC_HW3_256: 2641 case NAND_ECC_HW3_256:
2607 case NAND_ECC_SOFT: 2642 case NAND_ECC_SOFT:
2608 this->eccsteps = mtd->oobblock / 256; 2643 this->eccsteps = mtd->oobblock / 256;
2609 break; 2644 break;
2610 2645
2611 case NAND_ECC_NONE: 2646 case NAND_ECC_NONE:
2612 this->eccsteps = 1; 2647 this->eccsteps = 1;
2613 break; 2648 break;
2614 } 2649 }
2615 2650
2616 /* Initialize state, waitqueue and spinlock */ 2651 /* Initialize state, waitqueue and spinlock */
2617 this->state = FL_READY; 2652 this->state = FL_READY;
2618 init_waitqueue_head (&this->wq); 2653 init_waitqueue_head (&this->wq);
@@ -2643,8 +2678,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2643 mtd->sync = nand_sync; 2678 mtd->sync = nand_sync;
2644 mtd->lock = NULL; 2679 mtd->lock = NULL;
2645 mtd->unlock = NULL; 2680 mtd->unlock = NULL;
2646 mtd->suspend = NULL; 2681 mtd->suspend = nand_suspend;
2647 mtd->resume = NULL; 2682 mtd->resume = nand_resume;
2648 mtd->block_isbad = nand_block_isbad; 2683 mtd->block_isbad = nand_block_isbad;
2649 mtd->block_markbad = nand_block_markbad; 2684 mtd->block_markbad = nand_block_markbad;
2650 2685
@@ -2652,7 +2687,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2652 memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo)); 2687 memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo));
2653 2688
2654 mtd->owner = THIS_MODULE; 2689 mtd->owner = THIS_MODULE;
2655 2690
2656 /* Check, if we should skip the bad block table scan */ 2691 /* Check, if we should skip the bad block table scan */
2657 if (this->options & NAND_SKIP_BBTSCAN) 2692 if (this->options & NAND_SKIP_BBTSCAN)
2658 return 0; 2693 return 0;
@@ -2662,7 +2697,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2662} 2697}
2663 2698
2664/** 2699/**
2665 * nand_release - [NAND Interface] Free resources held by the NAND device 2700 * nand_release - [NAND Interface] Free resources held by the NAND device
2666 * @mtd: MTD device structure 2701 * @mtd: MTD device structure
2667*/ 2702*/
2668void nand_release (struct mtd_info *mtd) 2703void nand_release (struct mtd_info *mtd)
@@ -2676,9 +2711,8 @@ void nand_release (struct mtd_info *mtd)
2676 /* Deregister the device */ 2711 /* Deregister the device */
2677 del_mtd_device (mtd); 2712 del_mtd_device (mtd);
2678 2713
2679 /* Free bad block table memory, if allocated */ 2714 /* Free bad block table memory */
2680 if (this->bbt) 2715 kfree (this->bbt);
2681 kfree (this->bbt);
2682 /* Buffer allocated by nand_scan ? */ 2716 /* Buffer allocated by nand_scan ? */
2683 if (this->options & NAND_OOBBUF_ALLOC) 2717 if (this->options & NAND_OOBBUF_ALLOC)
2684 kfree (this->oob_buf); 2718 kfree (this->oob_buf);
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 7535ef53685e..ca286999fe08 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -3,10 +3,10 @@
3 * 3 *
4 * Overview: 4 * Overview:
5 * Bad block table support for the NAND driver 5 * Bad block table support for the NAND driver
6 * 6 *
7 * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de) 7 * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
8 * 8 *
9 * $Id: nand_bbt.c,v 1.35 2005/07/15 13:53:47 gleixner Exp $ 9 * $Id: nand_bbt.c,v 1.36 2005/11/07 11:14:30 gleixner Exp $
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -14,23 +14,23 @@
14 * 14 *
15 * Description: 15 * Description:
16 * 16 *
17 * When nand_scan_bbt is called, then it tries to find the bad block table 17 * When nand_scan_bbt is called, then it tries to find the bad block table
18 * depending on the options in the bbt descriptor(s). If a bbt is found 18 * depending on the options in the bbt descriptor(s). If a bbt is found
19 * then the contents are read and the memory based bbt is created. If a 19 * then the contents are read and the memory based bbt is created. If a
20 * mirrored bbt is selected then the mirror is searched too and the 20 * mirrored bbt is selected then the mirror is searched too and the
21 * versions are compared. If the mirror has a greater version number 21 * versions are compared. If the mirror has a greater version number
22 * than the mirror bbt is used to build the memory based bbt. 22 * than the mirror bbt is used to build the memory based bbt.
23 * If the tables are not versioned, then we "or" the bad block information. 23 * If the tables are not versioned, then we "or" the bad block information.
24 * If one of the bbt's is out of date or does not exist it is (re)created. 24 * If one of the bbt's is out of date or does not exist it is (re)created.
25 * If no bbt exists at all then the device is scanned for factory marked 25 * If no bbt exists at all then the device is scanned for factory marked
26 * good / bad blocks and the bad block tables are created. 26 * good / bad blocks and the bad block tables are created.
27 * 27 *
28 * For manufacturer created bbts like the one found on M-SYS DOC devices 28 * For manufacturer created bbts like the one found on M-SYS DOC devices
29 * the bbt is searched and read but never created 29 * the bbt is searched and read but never created
30 * 30 *
31 * The autogenerated bad block table is located in the last good blocks 31 * The autogenerated bad block table is located in the last good blocks
32 * of the device. The table is mirrored, so it can be updated eventually. 32 * of the device. The table is mirrored, so it can be updated eventually.
33 * The table is marked in the oob area with an ident pattern and a version 33 * The table is marked in the oob area with an ident pattern and a version
34 * number which indicates which of both tables is more up to date. 34 * number which indicates which of both tables is more up to date.
35 * 35 *
36 * The table uses 2 bits per block 36 * The table uses 2 bits per block
@@ -43,13 +43,13 @@
43 * 01b: block is marked bad due to wear 43 * 01b: block is marked bad due to wear
44 * 10b: block is reserved (to protect the bbt area) 44 * 10b: block is reserved (to protect the bbt area)
45 * 11b: block is factory marked bad 45 * 11b: block is factory marked bad
46 * 46 *
47 * Multichip devices like DOC store the bad block info per floor. 47 * Multichip devices like DOC store the bad block info per floor.
48 * 48 *
49 * Following assumptions are made: 49 * Following assumptions are made:
50 * - bbts start at a page boundary, if autolocated on a block boundary 50 * - bbts start at a page boundary, if autolocated on a block boundary
51 * - the space neccecary for a bbt in FLASH does not exceed a block boundary 51 * - the space neccecary for a bbt in FLASH does not exceed a block boundary
52 * 52 *
53 */ 53 */
54 54
55#include <linux/slab.h> 55#include <linux/slab.h>
@@ -62,7 +62,7 @@
62#include <linux/delay.h> 62#include <linux/delay.h>
63 63
64 64
65/** 65/**
66 * check_pattern - [GENERIC] check if a pattern is in the buffer 66 * check_pattern - [GENERIC] check if a pattern is in the buffer
67 * @buf: the buffer to search 67 * @buf: the buffer to search
68 * @len: the length of buffer to search 68 * @len: the length of buffer to search
@@ -86,9 +86,9 @@ static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_des
86 if (p[i] != 0xff) 86 if (p[i] != 0xff)
87 return -1; 87 return -1;
88 } 88 }
89 } 89 }
90 p += end; 90 p += end;
91 91
92 /* Compare the pattern */ 92 /* Compare the pattern */
93 for (i = 0; i < td->len; i++) { 93 for (i = 0; i < td->len; i++) {
94 if (p[i] != td->pattern[i]) 94 if (p[i] != td->pattern[i])
@@ -106,13 +106,13 @@ static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_des
106 return 0; 106 return 0;
107} 107}
108 108
109/** 109/**
110 * check_short_pattern - [GENERIC] check if a pattern is in the buffer 110 * check_short_pattern - [GENERIC] check if a pattern is in the buffer
111 * @buf: the buffer to search 111 * @buf: the buffer to search
112 * @td: search pattern descriptor 112 * @td: search pattern descriptor
113 * 113 *
114 * Check for a pattern at the given place. Used to search bad block 114 * Check for a pattern at the given place. Used to search bad block
115 * tables and good / bad block identifiers. Same as check_pattern, but 115 * tables and good / bad block identifiers. Same as check_pattern, but
116 * no optional empty check 116 * no optional empty check
117 * 117 *
118*/ 118*/
@@ -142,7 +142,7 @@ static int check_short_pattern (uint8_t *buf, struct nand_bbt_descr *td)
142 * Read the bad block table starting from page. 142 * Read the bad block table starting from page.
143 * 143 *
144 */ 144 */
145static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, 145static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num,
146 int bits, int offs, int reserved_block_code) 146 int bits, int offs, int reserved_block_code)
147{ 147{
148 int res, i, j, act = 0; 148 int res, i, j, act = 0;
@@ -153,7 +153,7 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num,
153 153
154 totlen = (num * bits) >> 3; 154 totlen = (num * bits) >> 3;
155 from = ((loff_t)page) << this->page_shift; 155 from = ((loff_t)page) << this->page_shift;
156 156
157 while (totlen) { 157 while (totlen) {
158 len = min (totlen, (size_t) (1 << this->bbt_erase_shift)); 158 len = min (totlen, (size_t) (1 << this->bbt_erase_shift));
159 res = mtd->read_ecc (mtd, from, len, &retlen, buf, NULL, this->autooob); 159 res = mtd->read_ecc (mtd, from, len, &retlen, buf, NULL, this->autooob);
@@ -163,7 +163,7 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num,
163 return res; 163 return res;
164 } 164 }
165 printk (KERN_WARNING "nand_bbt: ECC error while reading bad block table\n"); 165 printk (KERN_WARNING "nand_bbt: ECC error while reading bad block table\n");
166 } 166 }
167 167
168 /* Analyse data */ 168 /* Analyse data */
169 for (i = 0; i < len; i++) { 169 for (i = 0; i < len; i++) {
@@ -183,12 +183,12 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num,
183 * message to MTD_DEBUG_LEVEL0 */ 183 * message to MTD_DEBUG_LEVEL0 */
184 printk (KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n", 184 printk (KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n",
185 ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); 185 ((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
186 /* Factory marked bad or worn out ? */ 186 /* Factory marked bad or worn out ? */
187 if (tmp == 0) 187 if (tmp == 0)
188 this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); 188 this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06);
189 else 189 else
190 this->bbt[offs + (act >> 3)] |= 0x1 << (act & 0x06); 190 this->bbt[offs + (act >> 3)] |= 0x1 << (act & 0x06);
191 } 191 }
192 } 192 }
193 totlen -= len; 193 totlen -= len;
194 from += len; 194 from += len;
@@ -200,7 +200,7 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num,
200 * read_abs_bbt - [GENERIC] Read the bad block table starting at a given page 200 * read_abs_bbt - [GENERIC] Read the bad block table starting at a given page
201 * @mtd: MTD device structure 201 * @mtd: MTD device structure
202 * @buf: temporary buffer 202 * @buf: temporary buffer
203 * @td: descriptor for the bad block table 203 * @td: descriptor for the bad block table
204 * @chip: read the table for a specific chip, -1 read all chips. 204 * @chip: read the table for a specific chip, -1 read all chips.
205 * Applies only if NAND_BBT_PERCHIP option is set 205 * Applies only if NAND_BBT_PERCHIP option is set
206 * 206 *
@@ -235,7 +235,7 @@ static int read_abs_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des
235 * read_abs_bbts - [GENERIC] Read the bad block table(s) for all chips starting at a given page 235 * read_abs_bbts - [GENERIC] Read the bad block table(s) for all chips starting at a given page
236 * @mtd: MTD device structure 236 * @mtd: MTD device structure
237 * @buf: temporary buffer 237 * @buf: temporary buffer
238 * @td: descriptor for the bad block table 238 * @td: descriptor for the bad block table
239 * @md: descriptor for the bad block table mirror 239 * @md: descriptor for the bad block table mirror
240 * 240 *
241 * Read the bad block table(s) for all chips starting at a given page 241 * Read the bad block table(s) for all chips starting at a given page
@@ -247,16 +247,16 @@ static int read_abs_bbts (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_de
247{ 247{
248 struct nand_chip *this = mtd->priv; 248 struct nand_chip *this = mtd->priv;
249 249
250 /* Read the primary version, if available */ 250 /* Read the primary version, if available */
251 if (td->options & NAND_BBT_VERSION) { 251 if (td->options & NAND_BBT_VERSION) {
252 nand_read_raw (mtd, buf, td->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); 252 nand_read_raw (mtd, buf, td->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize);
253 td->version[0] = buf[mtd->oobblock + td->veroffs]; 253 td->version[0] = buf[mtd->oobblock + td->veroffs];
254 printk (KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]); 254 printk (KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]);
255 } 255 }
256 256
257 /* Read the mirror version, if available */ 257 /* Read the mirror version, if available */
258 if (md && (md->options & NAND_BBT_VERSION)) { 258 if (md && (md->options & NAND_BBT_VERSION)) {
259 nand_read_raw (mtd, buf, md->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); 259 nand_read_raw (mtd, buf, md->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize);
260 md->version[0] = buf[mtd->oobblock + md->veroffs]; 260 md->version[0] = buf[mtd->oobblock + md->veroffs];
261 printk (KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]); 261 printk (KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]);
262 } 262 }
@@ -290,7 +290,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
290 else { 290 else {
291 if (bd->options & NAND_BBT_SCAN2NDPAGE) 291 if (bd->options & NAND_BBT_SCAN2NDPAGE)
292 len = 2; 292 len = 2;
293 else 293 else
294 len = 1; 294 len = 1;
295 } 295 }
296 296
@@ -322,10 +322,10 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
322 numblocks += startblock; 322 numblocks += startblock;
323 from = startblock << (this->bbt_erase_shift - 1); 323 from = startblock << (this->bbt_erase_shift - 1);
324 } 324 }
325 325
326 for (i = startblock; i < numblocks;) { 326 for (i = startblock; i < numblocks;) {
327 int ret; 327 int ret;
328 328
329 if (bd->options & NAND_BBT_SCANEMPTY) 329 if (bd->options & NAND_BBT_SCANEMPTY)
330 if ((ret = nand_read_raw (mtd, buf, from, readlen, ooblen))) 330 if ((ret = nand_read_raw (mtd, buf, from, readlen, ooblen)))
331 return ret; 331 return ret;
@@ -333,8 +333,8 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
333 for (j = 0; j < len; j++) { 333 for (j = 0; j < len; j++) {
334 if (!(bd->options & NAND_BBT_SCANEMPTY)) { 334 if (!(bd->options & NAND_BBT_SCANEMPTY)) {
335 size_t retlen; 335 size_t retlen;
336 336
337 /* Read the full oob until read_oob is fixed to 337 /* Read the full oob until read_oob is fixed to
338 * handle single byte reads for 16 bit buswidth */ 338 * handle single byte reads for 16 bit buswidth */
339 ret = mtd->read_oob(mtd, from + j * mtd->oobblock, 339 ret = mtd->read_oob(mtd, from + j * mtd->oobblock,
340 mtd->oobsize, &retlen, buf); 340 mtd->oobsize, &retlen, buf);
@@ -343,14 +343,14 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
343 343
344 if (check_short_pattern (buf, bd)) { 344 if (check_short_pattern (buf, bd)) {
345 this->bbt[i >> 3] |= 0x03 << (i & 0x6); 345 this->bbt[i >> 3] |= 0x03 << (i & 0x6);
346 printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 346 printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
347 i >> 1, (unsigned int) from); 347 i >> 1, (unsigned int) from);
348 break; 348 break;
349 } 349 }
350 } else { 350 } else {
351 if (check_pattern (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { 351 if (check_pattern (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) {
352 this->bbt[i >> 3] |= 0x03 << (i & 0x6); 352 this->bbt[i >> 3] |= 0x03 << (i & 0x6);
353 printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 353 printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
354 i >> 1, (unsigned int) from); 354 i >> 1, (unsigned int) from);
355 break; 355 break;
356 } 356 }
@@ -369,15 +369,15 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
369 * @td: descriptor for the bad block table 369 * @td: descriptor for the bad block table
370 * 370 *
371 * Read the bad block table by searching for a given ident pattern. 371 * Read the bad block table by searching for a given ident pattern.
372 * Search is preformed either from the beginning up or from the end of 372 * Search is preformed either from the beginning up or from the end of
373 * the device downwards. The search starts always at the start of a 373 * the device downwards. The search starts always at the start of a
374 * block. 374 * block.
375 * If the option NAND_BBT_PERCHIP is given, each chip is searched 375 * If the option NAND_BBT_PERCHIP is given, each chip is searched
376 * for a bbt, which contains the bad block information of this chip. 376 * for a bbt, which contains the bad block information of this chip.
377 * This is neccecary to provide support for certain DOC devices. 377 * This is neccecary to provide support for certain DOC devices.
378 * 378 *
379 * The bbt ident pattern resides in the oob area of the first page 379 * The bbt ident pattern resides in the oob area of the first page
380 * in a block. 380 * in a block.
381 */ 381 */
382static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td) 382static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td)
383{ 383{
@@ -392,10 +392,10 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
392 startblock = (mtd->size >> this->bbt_erase_shift) -1; 392 startblock = (mtd->size >> this->bbt_erase_shift) -1;
393 dir = -1; 393 dir = -1;
394 } else { 394 } else {
395 startblock = 0; 395 startblock = 0;
396 dir = 1; 396 dir = 1;
397 } 397 }
398 398
399 /* Do we have a bbt per chip ? */ 399 /* Do we have a bbt per chip ? */
400 if (td->options & NAND_BBT_PERCHIP) { 400 if (td->options & NAND_BBT_PERCHIP) {
401 chips = this->numchips; 401 chips = this->numchips;
@@ -405,19 +405,19 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
405 chips = 1; 405 chips = 1;
406 bbtblocks = mtd->size >> this->bbt_erase_shift; 406 bbtblocks = mtd->size >> this->bbt_erase_shift;
407 } 407 }
408 408
409 /* Number of bits for each erase block in the bbt */ 409 /* Number of bits for each erase block in the bbt */
410 bits = td->options & NAND_BBT_NRBITS_MSK; 410 bits = td->options & NAND_BBT_NRBITS_MSK;
411 411
412 for (i = 0; i < chips; i++) { 412 for (i = 0; i < chips; i++) {
413 /* Reset version information */ 413 /* Reset version information */
414 td->version[i] = 0; 414 td->version[i] = 0;
415 td->pages[i] = -1; 415 td->pages[i] = -1;
416 /* Scan the maximum number of blocks */ 416 /* Scan the maximum number of blocks */
417 for (block = 0; block < td->maxblocks; block++) { 417 for (block = 0; block < td->maxblocks; block++) {
418 int actblock = startblock + dir * block; 418 int actblock = startblock + dir * block;
419 /* Read first page */ 419 /* Read first page */
420 nand_read_raw (mtd, buf, actblock << this->bbt_erase_shift, mtd->oobblock, mtd->oobsize); 420 nand_read_raw (mtd, buf, actblock << this->bbt_erase_shift, mtd->oobblock, mtd->oobsize);
421 if (!check_pattern(buf, scanlen, mtd->oobblock, td)) { 421 if (!check_pattern(buf, scanlen, mtd->oobblock, td)) {
422 td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift); 422 td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift);
423 if (td->options & NAND_BBT_VERSION) { 423 if (td->options & NAND_BBT_VERSION) {
@@ -435,46 +435,46 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
435 else 435 else
436 printk (KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i], td->version[i]); 436 printk (KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i], td->version[i]);
437 } 437 }
438 return 0; 438 return 0;
439} 439}
440 440
441/** 441/**
442 * search_read_bbts - [GENERIC] scan the device for bad block table(s) 442 * search_read_bbts - [GENERIC] scan the device for bad block table(s)
443 * @mtd: MTD device structure 443 * @mtd: MTD device structure
444 * @buf: temporary buffer 444 * @buf: temporary buffer
445 * @td: descriptor for the bad block table 445 * @td: descriptor for the bad block table
446 * @md: descriptor for the bad block table mirror 446 * @md: descriptor for the bad block table mirror
447 * 447 *
448 * Search and read the bad block table(s) 448 * Search and read the bad block table(s)
449*/ 449*/
450static int search_read_bbts (struct mtd_info *mtd, uint8_t *buf, 450static int search_read_bbts (struct mtd_info *mtd, uint8_t *buf,
451 struct nand_bbt_descr *td, struct nand_bbt_descr *md) 451 struct nand_bbt_descr *td, struct nand_bbt_descr *md)
452{ 452{
453 /* Search the primary table */ 453 /* Search the primary table */
454 search_bbt (mtd, buf, td); 454 search_bbt (mtd, buf, td);
455 455
456 /* Search the mirror table */ 456 /* Search the mirror table */
457 if (md) 457 if (md)
458 search_bbt (mtd, buf, md); 458 search_bbt (mtd, buf, md);
459 459
460 /* Force result check */ 460 /* Force result check */
461 return 1; 461 return 1;
462} 462}
463
464 463
465/** 464
465/**
466 * write_bbt - [GENERIC] (Re)write the bad block table 466 * write_bbt - [GENERIC] (Re)write the bad block table
467 * 467 *
468 * @mtd: MTD device structure 468 * @mtd: MTD device structure
469 * @buf: temporary buffer 469 * @buf: temporary buffer
470 * @td: descriptor for the bad block table 470 * @td: descriptor for the bad block table
471 * @md: descriptor for the bad block table mirror 471 * @md: descriptor for the bad block table mirror
472 * @chipsel: selector for a specific chip, -1 for all 472 * @chipsel: selector for a specific chip, -1 for all
473 * 473 *
474 * (Re)write the bad block table 474 * (Re)write the bad block table
475 * 475 *
476*/ 476*/
477static int write_bbt (struct mtd_info *mtd, uint8_t *buf, 477static int write_bbt (struct mtd_info *mtd, uint8_t *buf,
478 struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel) 478 struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel)
479{ 479{
480 struct nand_chip *this = mtd->priv; 480 struct nand_chip *this = mtd->priv;
@@ -493,7 +493,7 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf,
493 /* Write bad block table per chip rather than per device ? */ 493 /* Write bad block table per chip rather than per device ? */
494 if (td->options & NAND_BBT_PERCHIP) { 494 if (td->options & NAND_BBT_PERCHIP) {
495 numblocks = (int) (this->chipsize >> this->bbt_erase_shift); 495 numblocks = (int) (this->chipsize >> this->bbt_erase_shift);
496 /* Full device write or specific chip ? */ 496 /* Full device write or specific chip ? */
497 if (chipsel == -1) { 497 if (chipsel == -1) {
498 nrchips = this->numchips; 498 nrchips = this->numchips;
499 } else { 499 } else {
@@ -503,19 +503,19 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf,
503 } else { 503 } else {
504 numblocks = (int) (mtd->size >> this->bbt_erase_shift); 504 numblocks = (int) (mtd->size >> this->bbt_erase_shift);
505 nrchips = 1; 505 nrchips = 1;
506 } 506 }
507 507
508 /* Loop through the chips */ 508 /* Loop through the chips */
509 for (; chip < nrchips; chip++) { 509 for (; chip < nrchips; chip++) {
510 510
511 /* There was already a version of the table, reuse the page 511 /* There was already a version of the table, reuse the page
512 * This applies for absolute placement too, as we have the 512 * This applies for absolute placement too, as we have the
513 * page nr. in td->pages. 513 * page nr. in td->pages.
514 */ 514 */
515 if (td->pages[chip] != -1) { 515 if (td->pages[chip] != -1) {
516 page = td->pages[chip]; 516 page = td->pages[chip];
517 goto write; 517 goto write;
518 } 518 }
519 519
520 /* Automatic placement of the bad block table */ 520 /* Automatic placement of the bad block table */
521 /* Search direction top -> down ? */ 521 /* Search direction top -> down ? */
@@ -525,7 +525,7 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf,
525 } else { 525 } else {
526 startblock = chip * numblocks; 526 startblock = chip * numblocks;
527 dir = 1; 527 dir = 1;
528 } 528 }
529 529
530 for (i = 0; i < td->maxblocks; i++) { 530 for (i = 0; i < td->maxblocks; i++) {
531 int block = startblock + dir * i; 531 int block = startblock + dir * i;
@@ -542,7 +542,7 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf,
542 } 542 }
543 printk (KERN_ERR "No space left to write bad block table\n"); 543 printk (KERN_ERR "No space left to write bad block table\n");
544 return -ENOSPC; 544 return -ENOSPC;
545write: 545write:
546 546
547 /* Set up shift count and masks for the flash table */ 547 /* Set up shift count and masks for the flash table */
548 bits = td->options & NAND_BBT_NRBITS_MSK; 548 bits = td->options & NAND_BBT_NRBITS_MSK;
@@ -553,14 +553,14 @@ write:
553 case 8: sft = 0; sftmsk = 0x00; msk[0] = 0x00; msk[1] = 0x0F; msk[2] = ~rcode; msk[3] = 0xff; break; 553 case 8: sft = 0; sftmsk = 0x00; msk[0] = 0x00; msk[1] = 0x0F; msk[2] = ~rcode; msk[3] = 0xff; break;
554 default: return -EINVAL; 554 default: return -EINVAL;
555 } 555 }
556 556
557 bbtoffs = chip * (numblocks >> 2); 557 bbtoffs = chip * (numblocks >> 2);
558 558
559 to = ((loff_t) page) << this->page_shift; 559 to = ((loff_t) page) << this->page_shift;
560 560
561 memcpy (&oobinfo, this->autooob, sizeof(oobinfo)); 561 memcpy (&oobinfo, this->autooob, sizeof(oobinfo));
562 oobinfo.useecc = MTD_NANDECC_PLACEONLY; 562 oobinfo.useecc = MTD_NANDECC_PLACEONLY;
563 563
564 /* Must we save the block contents ? */ 564 /* Must we save the block contents ? */
565 if (td->options & NAND_BBT_SAVECONTENT) { 565 if (td->options & NAND_BBT_SAVECONTENT) {
566 /* Make it block aligned */ 566 /* Make it block aligned */
@@ -599,7 +599,7 @@ write:
599 buf[len + td->veroffs] = td->version[chip]; 599 buf[len + td->veroffs] = td->version[chip];
600 } 600 }
601 } 601 }
602 602
603 /* walk through the memory table */ 603 /* walk through the memory table */
604 for (i = 0; i < numblocks; ) { 604 for (i = 0; i < numblocks; ) {
605 uint8_t dat; 605 uint8_t dat;
@@ -611,7 +611,7 @@ write:
611 dat >>= 2; 611 dat >>= 2;
612 } 612 }
613 } 613 }
614 614
615 memset (&einfo, 0, sizeof (einfo)); 615 memset (&einfo, 0, sizeof (einfo));
616 einfo.mtd = mtd; 616 einfo.mtd = mtd;
617 einfo.addr = (unsigned long) to; 617 einfo.addr = (unsigned long) to;
@@ -621,18 +621,18 @@ write:
621 printk (KERN_WARNING "nand_bbt: Error during block erase: %d\n", res); 621 printk (KERN_WARNING "nand_bbt: Error during block erase: %d\n", res);
622 return res; 622 return res;
623 } 623 }
624 624
625 res = mtd->write_ecc (mtd, to, len, &retlen, buf, &buf[len], &oobinfo); 625 res = mtd->write_ecc (mtd, to, len, &retlen, buf, &buf[len], &oobinfo);
626 if (res < 0) { 626 if (res < 0) {
627 printk (KERN_WARNING "nand_bbt: Error while writing bad block table %d\n", res); 627 printk (KERN_WARNING "nand_bbt: Error while writing bad block table %d\n", res);
628 return res; 628 return res;
629 } 629 }
630 printk (KERN_DEBUG "Bad block table written to 0x%08x, version 0x%02X\n", 630 printk (KERN_DEBUG "Bad block table written to 0x%08x, version 0x%02X\n",
631 (unsigned int) to, td->version[chip]); 631 (unsigned int) to, td->version[chip]);
632 632
633 /* Mark it as used */ 633 /* Mark it as used */
634 td->pages[chip] = page; 634 td->pages[chip] = page;
635 } 635 }
636 return 0; 636 return 0;
637} 637}
638 638
@@ -641,7 +641,7 @@ write:
641 * @mtd: MTD device structure 641 * @mtd: MTD device structure
642 * @bd: descriptor for the good/bad block search pattern 642 * @bd: descriptor for the good/bad block search pattern
643 * 643 *
644 * The function creates a memory based bbt by scanning the device 644 * The function creates a memory based bbt by scanning the device
645 * for manufacturer / software marked good / bad blocks 645 * for manufacturer / software marked good / bad blocks
646*/ 646*/
647static inline int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) 647static inline int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
@@ -673,11 +673,11 @@ static int check_create (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des
673 struct nand_bbt_descr *rd, *rd2; 673 struct nand_bbt_descr *rd, *rd2;
674 674
675 /* Do we have a bbt per chip ? */ 675 /* Do we have a bbt per chip ? */
676 if (td->options & NAND_BBT_PERCHIP) 676 if (td->options & NAND_BBT_PERCHIP)
677 chips = this->numchips; 677 chips = this->numchips;
678 else 678 else
679 chips = 1; 679 chips = 1;
680 680
681 for (i = 0; i < chips; i++) { 681 for (i = 0; i < chips; i++) {
682 writeops = 0; 682 writeops = 0;
683 rd = NULL; 683 rd = NULL;
@@ -692,7 +692,7 @@ static int check_create (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des
692 } 692 }
693 693
694 if (td->pages[i] == -1) { 694 if (td->pages[i] == -1) {
695 rd = md; 695 rd = md;
696 td->version[i] = md->version[i]; 696 td->version[i] = md->version[i];
697 writeops = 1; 697 writeops = 1;
698 goto writecheck; 698 goto writecheck;
@@ -710,7 +710,7 @@ static int check_create (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des
710 if (!(td->options & NAND_BBT_VERSION)) 710 if (!(td->options & NAND_BBT_VERSION))
711 rd2 = md; 711 rd2 = md;
712 goto writecheck; 712 goto writecheck;
713 } 713 }
714 714
715 if (((int8_t) (td->version[i] - md->version[i])) > 0) { 715 if (((int8_t) (td->version[i] - md->version[i])) > 0) {
716 rd = td; 716 rd = td;
@@ -735,15 +735,15 @@ static int check_create (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des
735create: 735create:
736 /* Create the bad block table by scanning the device ? */ 736 /* Create the bad block table by scanning the device ? */
737 if (!(td->options & NAND_BBT_CREATE)) 737 if (!(td->options & NAND_BBT_CREATE))
738 continue; 738 continue;
739 739
740 /* Create the table in memory by scanning the chip(s) */ 740 /* Create the table in memory by scanning the chip(s) */
741 create_bbt (mtd, buf, bd, chipsel); 741 create_bbt (mtd, buf, bd, chipsel);
742 742
743 td->version[i] = 1; 743 td->version[i] = 1;
744 if (md) 744 if (md)
745 md->version[i] = 1; 745 md->version[i] = 1;
746writecheck: 746writecheck:
747 /* read back first ? */ 747 /* read back first ? */
748 if (rd) 748 if (rd)
749 read_abs_bbt (mtd, buf, rd, chipsel); 749 read_abs_bbt (mtd, buf, rd, chipsel);
@@ -757,7 +757,7 @@ writecheck:
757 if (res < 0) 757 if (res < 0)
758 return res; 758 return res;
759 } 759 }
760 760
761 /* Write the mirror bad block table to the device ? */ 761 /* Write the mirror bad block table to the device ? */
762 if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { 762 if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) {
763 res = write_bbt (mtd, buf, md, td, chipsel); 763 res = write_bbt (mtd, buf, md, td, chipsel);
@@ -765,11 +765,11 @@ writecheck:
765 return res; 765 return res;
766 } 766 }
767 } 767 }
768 return 0; 768 return 0;
769} 769}
770 770
771/** 771/**
772 * mark_bbt_regions - [GENERIC] mark the bad block table regions 772 * mark_bbt_regions - [GENERIC] mark the bad block table regions
773 * @mtd: MTD device structure 773 * @mtd: MTD device structure
774 * @td: bad block table descriptor 774 * @td: bad block table descriptor
775 * 775 *
@@ -790,14 +790,14 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td)
790 } else { 790 } else {
791 chips = 1; 791 chips = 1;
792 nrblocks = (int)(mtd->size >> this->bbt_erase_shift); 792 nrblocks = (int)(mtd->size >> this->bbt_erase_shift);
793 } 793 }
794 794
795 for (i = 0; i < chips; i++) { 795 for (i = 0; i < chips; i++) {
796 if ((td->options & NAND_BBT_ABSPAGE) || 796 if ((td->options & NAND_BBT_ABSPAGE) ||
797 !(td->options & NAND_BBT_WRITE)) { 797 !(td->options & NAND_BBT_WRITE)) {
798 if (td->pages[i] == -1) continue; 798 if (td->pages[i] == -1) continue;
799 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); 799 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift);
800 block <<= 1; 800 block <<= 1;
801 oldval = this->bbt[(block >> 3)]; 801 oldval = this->bbt[(block >> 3)];
802 newval = oldval | (0x2 << (block & 0x06)); 802 newval = oldval | (0x2 << (block & 0x06));
803 this->bbt[(block >> 3)] = newval; 803 this->bbt[(block >> 3)] = newval;
@@ -808,16 +808,16 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td)
808 update = 0; 808 update = 0;
809 if (td->options & NAND_BBT_LASTBLOCK) 809 if (td->options & NAND_BBT_LASTBLOCK)
810 block = ((i + 1) * nrblocks) - td->maxblocks; 810 block = ((i + 1) * nrblocks) - td->maxblocks;
811 else 811 else
812 block = i * nrblocks; 812 block = i * nrblocks;
813 block <<= 1; 813 block <<= 1;
814 for (j = 0; j < td->maxblocks; j++) { 814 for (j = 0; j < td->maxblocks; j++) {
815 oldval = this->bbt[(block >> 3)]; 815 oldval = this->bbt[(block >> 3)];
816 newval = oldval | (0x2 << (block & 0x06)); 816 newval = oldval | (0x2 << (block & 0x06));
817 this->bbt[(block >> 3)] = newval; 817 this->bbt[(block >> 3)] = newval;
818 if (oldval != newval) update = 1; 818 if (oldval != newval) update = 1;
819 block += 2; 819 block += 2;
820 } 820 }
821 /* If we want reserved blocks to be recorded to flash, and some 821 /* If we want reserved blocks to be recorded to flash, and some
822 new ones have been marked, then we need to update the stored 822 new ones have been marked, then we need to update the stored
823 bbts. This should only happen once. */ 823 bbts. This should only happen once. */
@@ -831,7 +831,7 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td)
831 * @mtd: MTD device structure 831 * @mtd: MTD device structure
832 * @bd: descriptor for the good/bad block search pattern 832 * @bd: descriptor for the good/bad block search pattern
833 * 833 *
834 * The function checks, if a bad block table(s) is/are already 834 * The function checks, if a bad block table(s) is/are already
835 * available. If not it scans the device for manufacturer 835 * available. If not it scans the device for manufacturer
836 * marked good / bad blocks and writes the bad block table(s) to 836 * marked good / bad blocks and writes the bad block table(s) to
837 * the selected place. 837 * the selected place.
@@ -880,30 +880,30 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
880 this->bbt = NULL; 880 this->bbt = NULL;
881 return -ENOMEM; 881 return -ENOMEM;
882 } 882 }
883 883
884 /* Is the bbt at a given page ? */ 884 /* Is the bbt at a given page ? */
885 if (td->options & NAND_BBT_ABSPAGE) { 885 if (td->options & NAND_BBT_ABSPAGE) {
886 res = read_abs_bbts (mtd, buf, td, md); 886 res = read_abs_bbts (mtd, buf, td, md);
887 } else { 887 } else {
888 /* Search the bad block table using a pattern in oob */ 888 /* Search the bad block table using a pattern in oob */
889 res = search_read_bbts (mtd, buf, td, md); 889 res = search_read_bbts (mtd, buf, td, md);
890 } 890 }
891 891
892 if (res) 892 if (res)
893 res = check_create (mtd, buf, bd); 893 res = check_create (mtd, buf, bd);
894 894
895 /* Prevent the bbt regions from erasing / writing */ 895 /* Prevent the bbt regions from erasing / writing */
896 mark_bbt_region (mtd, td); 896 mark_bbt_region (mtd, td);
897 if (md) 897 if (md)
898 mark_bbt_region (mtd, md); 898 mark_bbt_region (mtd, md);
899 899
900 kfree (buf); 900 kfree (buf);
901 return res; 901 return res;
902} 902}
903 903
904 904
905/** 905/**
906 * nand_update_bbt - [NAND Interface] update bad block table(s) 906 * nand_update_bbt - [NAND Interface] update bad block table(s)
907 * @mtd: MTD device structure 907 * @mtd: MTD device structure
908 * @offs: the offset of the newly marked block 908 * @offs: the offset of the newly marked block
909 * 909 *
@@ -930,7 +930,7 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs)
930 printk (KERN_ERR "nand_update_bbt: Out of memory\n"); 930 printk (KERN_ERR "nand_update_bbt: Out of memory\n");
931 return -ENOMEM; 931 return -ENOMEM;
932 } 932 }
933 933
934 writeops = md != NULL ? 0x03 : 0x01; 934 writeops = md != NULL ? 0x03 : 0x01;
935 935
936 /* Do we have a bbt per chip ? */ 936 /* Do we have a bbt per chip ? */
@@ -944,7 +944,7 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs)
944 944
945 td->version[chip]++; 945 td->version[chip]++;
946 if (md) 946 if (md)
947 md->version[chip]++; 947 md->version[chip]++;
948 948
949 /* Write the bad block table to the device ? */ 949 /* Write the bad block table to the device ? */
950 if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { 950 if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) {
@@ -957,12 +957,12 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs)
957 res = write_bbt (mtd, buf, md, td, chipsel); 957 res = write_bbt (mtd, buf, md, td, chipsel);
958 } 958 }
959 959
960out: 960out:
961 kfree (buf); 961 kfree (buf);
962 return res; 962 return res;
963} 963}
964 964
965/* Define some generic bad / good block scan pattern which are used 965/* Define some generic bad / good block scan pattern which are used
966 * while scanning a device for factory marked good / bad blocks. */ 966 * while scanning a device for factory marked good / bad blocks. */
967static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; 967static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
968 968
@@ -1009,7 +1009,7 @@ static uint8_t bbt_pattern[] = {'B', 'b', 't', '0' };
1009static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' }; 1009static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' };
1010 1010
1011static struct nand_bbt_descr bbt_main_descr = { 1011static struct nand_bbt_descr bbt_main_descr = {
1012 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE 1012 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
1013 | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, 1013 | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
1014 .offs = 8, 1014 .offs = 8,
1015 .len = 4, 1015 .len = 4,
@@ -1019,7 +1019,7 @@ static struct nand_bbt_descr bbt_main_descr = {
1019}; 1019};
1020 1020
1021static struct nand_bbt_descr bbt_mirror_descr = { 1021static struct nand_bbt_descr bbt_mirror_descr = {
1022 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE 1022 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
1023 | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, 1023 | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
1024 .offs = 8, 1024 .offs = 8,
1025 .len = 4, 1025 .len = 4,
@@ -1029,7 +1029,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
1029}; 1029};
1030 1030
1031/** 1031/**
1032 * nand_default_bbt - [NAND Interface] Select a default bad block table for the device 1032 * nand_default_bbt - [NAND Interface] Select a default bad block table for the device
1033 * @mtd: MTD device structure 1033 * @mtd: MTD device structure
1034 * 1034 *
1035 * This function selects the default bad block table 1035 * This function selects the default bad block table
@@ -1039,29 +1039,29 @@ static struct nand_bbt_descr bbt_mirror_descr = {
1039int nand_default_bbt (struct mtd_info *mtd) 1039int nand_default_bbt (struct mtd_info *mtd)
1040{ 1040{
1041 struct nand_chip *this = mtd->priv; 1041 struct nand_chip *this = mtd->priv;
1042 1042
1043 /* Default for AG-AND. We must use a flash based 1043 /* Default for AG-AND. We must use a flash based
1044 * bad block table as the devices have factory marked 1044 * bad block table as the devices have factory marked
1045 * _good_ blocks. Erasing those blocks leads to loss 1045 * _good_ blocks. Erasing those blocks leads to loss
1046 * of the good / bad information, so we _must_ store 1046 * of the good / bad information, so we _must_ store
1047 * this information in a good / bad table during 1047 * this information in a good / bad table during
1048 * startup 1048 * startup
1049 */ 1049 */
1050 if (this->options & NAND_IS_AND) { 1050 if (this->options & NAND_IS_AND) {
1051 /* Use the default pattern descriptors */ 1051 /* Use the default pattern descriptors */
1052 if (!this->bbt_td) { 1052 if (!this->bbt_td) {
1053 this->bbt_td = &bbt_main_descr; 1053 this->bbt_td = &bbt_main_descr;
1054 this->bbt_md = &bbt_mirror_descr; 1054 this->bbt_md = &bbt_mirror_descr;
1055 } 1055 }
1056 this->options |= NAND_USE_FLASH_BBT; 1056 this->options |= NAND_USE_FLASH_BBT;
1057 return nand_scan_bbt (mtd, &agand_flashbased); 1057 return nand_scan_bbt (mtd, &agand_flashbased);
1058 } 1058 }
1059 1059
1060 1060
1061 /* Is a flash based bad block table requested ? */ 1061 /* Is a flash based bad block table requested ? */
1062 if (this->options & NAND_USE_FLASH_BBT) { 1062 if (this->options & NAND_USE_FLASH_BBT) {
1063 /* Use the default pattern descriptors */ 1063 /* Use the default pattern descriptors */
1064 if (!this->bbt_td) { 1064 if (!this->bbt_td) {
1065 this->bbt_td = &bbt_main_descr; 1065 this->bbt_td = &bbt_main_descr;
1066 this->bbt_md = &bbt_mirror_descr; 1066 this->bbt_md = &bbt_mirror_descr;
1067 } 1067 }
@@ -1081,7 +1081,7 @@ int nand_default_bbt (struct mtd_info *mtd)
1081} 1081}
1082 1082
1083/** 1083/**
1084 * nand_isbad_bbt - [NAND Interface] Check if a block is bad 1084 * nand_isbad_bbt - [NAND Interface] Check if a block is bad
1085 * @mtd: MTD device structure 1085 * @mtd: MTD device structure
1086 * @offs: offset in the device 1086 * @offs: offset in the device
1087 * @allowbbt: allow access to bad block table region 1087 * @allowbbt: allow access to bad block table region
@@ -1092,12 +1092,12 @@ int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt)
1092 struct nand_chip *this = mtd->priv; 1092 struct nand_chip *this = mtd->priv;
1093 int block; 1093 int block;
1094 uint8_t res; 1094 uint8_t res;
1095 1095
1096 /* Get block number * 2 */ 1096 /* Get block number * 2 */
1097 block = (int) (offs >> (this->bbt_erase_shift - 1)); 1097 block = (int) (offs >> (this->bbt_erase_shift - 1));
1098 res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03; 1098 res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03;
1099 1099
1100 DEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n", 1100 DEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n",
1101 (unsigned int)offs, block >> 1, res); 1101 (unsigned int)offs, block >> 1, res);
1102 1102
1103 switch ((int)res) { 1103 switch ((int)res) {
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
index 2e341b75437a..40ac909150a3 100644
--- a/drivers/mtd/nand/nand_ecc.c
+++ b/drivers/mtd/nand/nand_ecc.c
@@ -7,22 +7,22 @@
7 * Copyright (C) 2000-2004 Steven J. Hill (sjhill@realitydiluted.com) 7 * Copyright (C) 2000-2004 Steven J. Hill (sjhill@realitydiluted.com)
8 * Toshiba America Electronics Components, Inc. 8 * Toshiba America Electronics Components, Inc.
9 * 9 *
10 * $Id: nand_ecc.c,v 1.14 2004/06/16 15:34:37 gleixner Exp $ 10 * $Id: nand_ecc.c,v 1.15 2005/11/07 11:14:30 gleixner Exp $
11 * 11 *
12 * This file is free software; you can redistribute it and/or modify it 12 * This file 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 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 14 * Free Software Foundation; either version 2 or (at your option) any
15 * later version. 15 * later version.
16 * 16 *
17 * This file is distributed in the hope that it will be useful, but WITHOUT 17 * This file is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details. 20 * for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License along 22 * You should have received a copy of the GNU General Public License along
23 * with this file; if not, write to the Free Software Foundation, Inc., 23 * with this file; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 * 25 *
26 * As a special exception, if other files instantiate templates or use 26 * As a special exception, if other files instantiate templates or use
27 * macros or inline functions from these files, or you compile these 27 * macros or inline functions from these files, or you compile these
28 * files and link them with other works to produce a work based on these 28 * files and link them with other works to produce a work based on these
@@ -30,7 +30,7 @@
30 * covered by the GNU General Public License. However the source code for 30 * covered by the GNU General Public License. However the source code for
31 * these files must still be made available in accordance with section (3) 31 * these files must still be made available in accordance with section (3)
32 * of the GNU General Public License. 32 * of the GNU General Public License.
33 * 33 *
34 * This exception does not invalidate any other reasons why a work based on 34 * This exception does not invalidate any other reasons why a work based on
35 * this file might be covered by the GNU General Public License. 35 * this file might be covered by the GNU General Public License.
36 */ 36 */
@@ -67,7 +67,7 @@ static const u_char nand_ecc_precalc_table[] = {
67 * nand_trans_result - [GENERIC] create non-inverted ECC 67 * nand_trans_result - [GENERIC] create non-inverted ECC
68 * @reg2: line parity reg 2 68 * @reg2: line parity reg 2
69 * @reg3: line parity reg 3 69 * @reg3: line parity reg 3
70 * @ecc_code: ecc 70 * @ecc_code: ecc
71 * 71 *
72 * Creates non-inverted ECC code from line parity 72 * Creates non-inverted ECC code from line parity
73 */ 73 */
@@ -75,11 +75,11 @@ static void nand_trans_result(u_char reg2, u_char reg3,
75 u_char *ecc_code) 75 u_char *ecc_code)
76{ 76{
77 u_char a, b, i, tmp1, tmp2; 77 u_char a, b, i, tmp1, tmp2;
78 78
79 /* Initialize variables */ 79 /* Initialize variables */
80 a = b = 0x80; 80 a = b = 0x80;
81 tmp1 = tmp2 = 0; 81 tmp1 = tmp2 = 0;
82 82
83 /* Calculate first ECC byte */ 83 /* Calculate first ECC byte */
84 for (i = 0; i < 4; i++) { 84 for (i = 0; i < 4; i++) {
85 if (reg3 & a) /* LP15,13,11,9 --> ecc_code[0] */ 85 if (reg3 & a) /* LP15,13,11,9 --> ecc_code[0] */
@@ -90,7 +90,7 @@ static void nand_trans_result(u_char reg2, u_char reg3,
90 b >>= 1; 90 b >>= 1;
91 a >>= 1; 91 a >>= 1;
92 } 92 }
93 93
94 /* Calculate second ECC byte */ 94 /* Calculate second ECC byte */
95 b = 0x80; 95 b = 0x80;
96 for (i = 0; i < 4; i++) { 96 for (i = 0; i < 4; i++) {
@@ -102,7 +102,7 @@ static void nand_trans_result(u_char reg2, u_char reg3,
102 b >>= 1; 102 b >>= 1;
103 a >>= 1; 103 a >>= 1;
104 } 104 }
105 105
106 /* Store two of the ECC bytes */ 106 /* Store two of the ECC bytes */
107 ecc_code[0] = tmp1; 107 ecc_code[0] = tmp1;
108 ecc_code[1] = tmp2; 108 ecc_code[1] = tmp2;
@@ -118,28 +118,28 @@ int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code
118{ 118{
119 u_char idx, reg1, reg2, reg3; 119 u_char idx, reg1, reg2, reg3;
120 int j; 120 int j;
121 121
122 /* Initialize variables */ 122 /* Initialize variables */
123 reg1 = reg2 = reg3 = 0; 123 reg1 = reg2 = reg3 = 0;
124 ecc_code[0] = ecc_code[1] = ecc_code[2] = 0; 124 ecc_code[0] = ecc_code[1] = ecc_code[2] = 0;
125 125
126 /* Build up column parity */ 126 /* Build up column parity */
127 for(j = 0; j < 256; j++) { 127 for(j = 0; j < 256; j++) {
128 128
129 /* Get CP0 - CP5 from table */ 129 /* Get CP0 - CP5 from table */
130 idx = nand_ecc_precalc_table[dat[j]]; 130 idx = nand_ecc_precalc_table[dat[j]];
131 reg1 ^= (idx & 0x3f); 131 reg1 ^= (idx & 0x3f);
132 132
133 /* All bit XOR = 1 ? */ 133 /* All bit XOR = 1 ? */
134 if (idx & 0x40) { 134 if (idx & 0x40) {
135 reg3 ^= (u_char) j; 135 reg3 ^= (u_char) j;
136 reg2 ^= ~((u_char) j); 136 reg2 ^= ~((u_char) j);
137 } 137 }
138 } 138 }
139 139
140 /* Create non-inverted ECC code from line parity */ 140 /* Create non-inverted ECC code from line parity */
141 nand_trans_result(reg2, reg3, ecc_code); 141 nand_trans_result(reg2, reg3, ecc_code);
142 142
143 /* Calculate final ECC code */ 143 /* Calculate final ECC code */
144 ecc_code[0] = ~ecc_code[0]; 144 ecc_code[0] = ~ecc_code[0];
145 ecc_code[1] = ~ecc_code[1]; 145 ecc_code[1] = ~ecc_code[1];
@@ -159,12 +159,12 @@ int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code
159int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc) 159int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc)
160{ 160{
161 u_char a, b, c, d1, d2, d3, add, bit, i; 161 u_char a, b, c, d1, d2, d3, add, bit, i;
162 162
163 /* Do error detection */ 163 /* Do error detection */
164 d1 = calc_ecc[0] ^ read_ecc[0]; 164 d1 = calc_ecc[0] ^ read_ecc[0];
165 d2 = calc_ecc[1] ^ read_ecc[1]; 165 d2 = calc_ecc[1] ^ read_ecc[1];
166 d3 = calc_ecc[2] ^ read_ecc[2]; 166 d3 = calc_ecc[2] ^ read_ecc[2];
167 167
168 if ((d1 | d2 | d3) == 0) { 168 if ((d1 | d2 | d3) == 0) {
169 /* No errors */ 169 /* No errors */
170 return 0; 170 return 0;
@@ -173,7 +173,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha
173 a = (d1 ^ (d1 >> 1)) & 0x55; 173 a = (d1 ^ (d1 >> 1)) & 0x55;
174 b = (d2 ^ (d2 >> 1)) & 0x55; 174 b = (d2 ^ (d2 >> 1)) & 0x55;
175 c = (d3 ^ (d3 >> 1)) & 0x54; 175 c = (d3 ^ (d3 >> 1)) & 0x54;
176 176
177 /* Found and will correct single bit error in the data */ 177 /* Found and will correct single bit error in the data */
178 if ((a == 0x55) && (b == 0x55) && (c == 0x54)) { 178 if ((a == 0x55) && (b == 0x55) && (c == 0x54)) {
179 c = 0x80; 179 c = 0x80;
@@ -237,7 +237,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 /* Should never happen */ 241 /* Should never happen */
242 return -1; 242 return -1;
243} 243}
diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c
index efe246961b69..dbc7e55a4247 100644
--- a/drivers/mtd/nand/nand_ids.c
+++ b/drivers/mtd/nand/nand_ids.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002 Thomas Gleixner (tglx@linutronix.de) 4 * Copyright (C) 2002 Thomas Gleixner (tglx@linutronix.de)
5 * 5 *
6 * $Id: nand_ids.c,v 1.14 2005/06/23 09:38:50 gleixner Exp $ 6 * $Id: nand_ids.c,v 1.16 2005/11/07 11:14:31 gleixner Exp $
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
@@ -14,14 +14,14 @@
14#include <linux/mtd/nand.h> 14#include <linux/mtd/nand.h>
15/* 15/*
16* Chip ID list 16* Chip ID list
17* 17*
18* Name. ID code, pagesize, chipsize in MegaByte, eraseblock size, 18* Name. ID code, pagesize, chipsize in MegaByte, eraseblock size,
19* options 19* options
20* 20*
21* Pagesize; 0, 256, 512 21* Pagesize; 0, 256, 512
22* 0 get this information from the extended chip ID 22* 0 get this information from the extended chip ID
23+ 256 256 Byte page size 23+ 256 256 Byte page size
24* 512 512 Byte page size 24* 512 512 Byte page size
25*/ 25*/
26struct nand_flash_dev nand_flash_ids[] = { 26struct nand_flash_dev nand_flash_ids[] = {
27 {"NAND 1MiB 5V 8-bit", 0x6e, 256, 1, 0x1000, 0}, 27 {"NAND 1MiB 5V 8-bit", 0x6e, 256, 1, 0x1000, 0},
@@ -34,27 +34,27 @@ struct nand_flash_dev nand_flash_ids[] = {
34 {"NAND 4MiB 3,3V 8-bit", 0xe3, 512, 4, 0x2000, 0}, 34 {"NAND 4MiB 3,3V 8-bit", 0xe3, 512, 4, 0x2000, 0},
35 {"NAND 4MiB 3,3V 8-bit", 0xe5, 512, 4, 0x2000, 0}, 35 {"NAND 4MiB 3,3V 8-bit", 0xe5, 512, 4, 0x2000, 0},
36 {"NAND 8MiB 3,3V 8-bit", 0xd6, 512, 8, 0x2000, 0}, 36 {"NAND 8MiB 3,3V 8-bit", 0xd6, 512, 8, 0x2000, 0},
37 37
38 {"NAND 8MiB 1,8V 8-bit", 0x39, 512, 8, 0x2000, 0}, 38 {"NAND 8MiB 1,8V 8-bit", 0x39, 512, 8, 0x2000, 0},
39 {"NAND 8MiB 3,3V 8-bit", 0xe6, 512, 8, 0x2000, 0}, 39 {"NAND 8MiB 3,3V 8-bit", 0xe6, 512, 8, 0x2000, 0},
40 {"NAND 8MiB 1,8V 16-bit", 0x49, 512, 8, 0x2000, NAND_BUSWIDTH_16}, 40 {"NAND 8MiB 1,8V 16-bit", 0x49, 512, 8, 0x2000, NAND_BUSWIDTH_16},
41 {"NAND 8MiB 3,3V 16-bit", 0x59, 512, 8, 0x2000, NAND_BUSWIDTH_16}, 41 {"NAND 8MiB 3,3V 16-bit", 0x59, 512, 8, 0x2000, NAND_BUSWIDTH_16},
42 42
43 {"NAND 16MiB 1,8V 8-bit", 0x33, 512, 16, 0x4000, 0}, 43 {"NAND 16MiB 1,8V 8-bit", 0x33, 512, 16, 0x4000, 0},
44 {"NAND 16MiB 3,3V 8-bit", 0x73, 512, 16, 0x4000, 0}, 44 {"NAND 16MiB 3,3V 8-bit", 0x73, 512, 16, 0x4000, 0},
45 {"NAND 16MiB 1,8V 16-bit", 0x43, 512, 16, 0x4000, NAND_BUSWIDTH_16}, 45 {"NAND 16MiB 1,8V 16-bit", 0x43, 512, 16, 0x4000, NAND_BUSWIDTH_16},
46 {"NAND 16MiB 3,3V 16-bit", 0x53, 512, 16, 0x4000, NAND_BUSWIDTH_16}, 46 {"NAND 16MiB 3,3V 16-bit", 0x53, 512, 16, 0x4000, NAND_BUSWIDTH_16},
47 47
48 {"NAND 32MiB 1,8V 8-bit", 0x35, 512, 32, 0x4000, 0}, 48 {"NAND 32MiB 1,8V 8-bit", 0x35, 512, 32, 0x4000, 0},
49 {"NAND 32MiB 3,3V 8-bit", 0x75, 512, 32, 0x4000, 0}, 49 {"NAND 32MiB 3,3V 8-bit", 0x75, 512, 32, 0x4000, 0},
50 {"NAND 32MiB 1,8V 16-bit", 0x45, 512, 32, 0x4000, NAND_BUSWIDTH_16}, 50 {"NAND 32MiB 1,8V 16-bit", 0x45, 512, 32, 0x4000, NAND_BUSWIDTH_16},
51 {"NAND 32MiB 3,3V 16-bit", 0x55, 512, 32, 0x4000, NAND_BUSWIDTH_16}, 51 {"NAND 32MiB 3,3V 16-bit", 0x55, 512, 32, 0x4000, NAND_BUSWIDTH_16},
52 52
53 {"NAND 64MiB 1,8V 8-bit", 0x36, 512, 64, 0x4000, 0}, 53 {"NAND 64MiB 1,8V 8-bit", 0x36, 512, 64, 0x4000, 0},
54 {"NAND 64MiB 3,3V 8-bit", 0x76, 512, 64, 0x4000, 0}, 54 {"NAND 64MiB 3,3V 8-bit", 0x76, 512, 64, 0x4000, 0},
55 {"NAND 64MiB 1,8V 16-bit", 0x46, 512, 64, 0x4000, NAND_BUSWIDTH_16}, 55 {"NAND 64MiB 1,8V 16-bit", 0x46, 512, 64, 0x4000, NAND_BUSWIDTH_16},
56 {"NAND 64MiB 3,3V 16-bit", 0x56, 512, 64, 0x4000, NAND_BUSWIDTH_16}, 56 {"NAND 64MiB 3,3V 16-bit", 0x56, 512, 64, 0x4000, NAND_BUSWIDTH_16},
57 57
58 {"NAND 128MiB 1,8V 8-bit", 0x78, 512, 128, 0x4000, 0}, 58 {"NAND 128MiB 1,8V 8-bit", 0x78, 512, 128, 0x4000, 0},
59 {"NAND 128MiB 1,8V 8-bit", 0x39, 512, 128, 0x4000, 0}, 59 {"NAND 128MiB 1,8V 8-bit", 0x39, 512, 128, 0x4000, 0},
60 {"NAND 128MiB 3,3V 8-bit", 0x79, 512, 128, 0x4000, 0}, 60 {"NAND 128MiB 3,3V 8-bit", 0x79, 512, 128, 0x4000, 0},
@@ -62,7 +62,7 @@ struct nand_flash_dev nand_flash_ids[] = {
62 {"NAND 128MiB 1,8V 16-bit", 0x49, 512, 128, 0x4000, NAND_BUSWIDTH_16}, 62 {"NAND 128MiB 1,8V 16-bit", 0x49, 512, 128, 0x4000, NAND_BUSWIDTH_16},
63 {"NAND 128MiB 3,3V 16-bit", 0x74, 512, 128, 0x4000, NAND_BUSWIDTH_16}, 63 {"NAND 128MiB 3,3V 16-bit", 0x74, 512, 128, 0x4000, NAND_BUSWIDTH_16},
64 {"NAND 128MiB 3,3V 16-bit", 0x59, 512, 128, 0x4000, NAND_BUSWIDTH_16}, 64 {"NAND 128MiB 3,3V 16-bit", 0x59, 512, 128, 0x4000, NAND_BUSWIDTH_16},
65 65
66 {"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, 0}, 66 {"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, 0},
67 67
68 /* These are the new chips with large page size. The pagesize 68 /* These are the new chips with large page size. The pagesize
@@ -73,7 +73,7 @@ struct nand_flash_dev nand_flash_ids[] = {
73 {"NAND 64MiB 3,3V 8-bit", 0xF2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 73 {"NAND 64MiB 3,3V 8-bit", 0xF2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
74 {"NAND 64MiB 1,8V 16-bit", 0xB2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR}, 74 {"NAND 64MiB 1,8V 16-bit", 0xB2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
75 {"NAND 64MiB 3,3V 16-bit", 0xC2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR}, 75 {"NAND 64MiB 3,3V 16-bit", 0xC2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
76 76
77 /* 1 Gigabit */ 77 /* 1 Gigabit */
78 {"NAND 128MiB 1,8V 8-bit", 0xA1, 0, 128, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 78 {"NAND 128MiB 1,8V 8-bit", 0xA1, 0, 128, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
79 {"NAND 128MiB 3,3V 8-bit", 0xF1, 0, 128, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 79 {"NAND 128MiB 3,3V 8-bit", 0xF1, 0, 128, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
@@ -85,13 +85,13 @@ struct nand_flash_dev nand_flash_ids[] = {
85 {"NAND 256MiB 3,3V 8-bit", 0xDA, 0, 256, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 85 {"NAND 256MiB 3,3V 8-bit", 0xDA, 0, 256, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
86 {"NAND 256MiB 1,8V 16-bit", 0xBA, 0, 256, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR}, 86 {"NAND 256MiB 1,8V 16-bit", 0xBA, 0, 256, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
87 {"NAND 256MiB 3,3V 16-bit", 0xCA, 0, 256, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR}, 87 {"NAND 256MiB 3,3V 16-bit", 0xCA, 0, 256, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
88 88
89 /* 4 Gigabit */ 89 /* 4 Gigabit */
90 {"NAND 512MiB 1,8V 8-bit", 0xAC, 0, 512, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 90 {"NAND 512MiB 1,8V 8-bit", 0xAC, 0, 512, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
91 {"NAND 512MiB 3,3V 8-bit", 0xDC, 0, 512, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 91 {"NAND 512MiB 3,3V 8-bit", 0xDC, 0, 512, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
92 {"NAND 512MiB 1,8V 16-bit", 0xBC, 0, 512, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR}, 92 {"NAND 512MiB 1,8V 16-bit", 0xBC, 0, 512, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
93 {"NAND 512MiB 3,3V 16-bit", 0xCC, 0, 512, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR}, 93 {"NAND 512MiB 3,3V 16-bit", 0xCC, 0, 512, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
94 94
95 /* 8 Gigabit */ 95 /* 8 Gigabit */
96 {"NAND 1GiB 1,8V 8-bit", 0xA3, 0, 1024, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 96 {"NAND 1GiB 1,8V 8-bit", 0xA3, 0, 1024, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
97 {"NAND 1GiB 3,3V 8-bit", 0xD3, 0, 1024, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 97 {"NAND 1GiB 3,3V 8-bit", 0xD3, 0, 1024, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
@@ -104,11 +104,11 @@ struct nand_flash_dev nand_flash_ids[] = {
104 {"NAND 2GiB 1,8V 16-bit", 0xB5, 0, 2048, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR}, 104 {"NAND 2GiB 1,8V 16-bit", 0xB5, 0, 2048, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
105 {"NAND 2GiB 3,3V 16-bit", 0xC5, 0, 2048, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR}, 105 {"NAND 2GiB 3,3V 16-bit", 0xC5, 0, 2048, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
106 106
107 /* Renesas AND 1 Gigabit. Those chips do not support extended id and have a strange page/block layout ! 107 /* Renesas AND 1 Gigabit. Those chips do not support extended id and have a strange page/block layout !
108 * The chosen minimum erasesize is 4 * 2 * 2048 = 16384 Byte, as those chips have an array of 4 page planes 108 * The chosen minimum erasesize is 4 * 2 * 2048 = 16384 Byte, as those chips have an array of 4 page planes
109 * 1 block = 2 pages, but due to plane arrangement the blocks 0-3 consists of page 0 + 4,1 + 5, 2 + 6, 3 + 7 109 * 1 block = 2 pages, but due to plane arrangement the blocks 0-3 consists of page 0 + 4,1 + 5, 2 + 6, 3 + 7
110 * Anyway JFFS2 would increase the eraseblock size so we chose a combined one which can be erased in one go 110 * Anyway JFFS2 would increase the eraseblock size so we chose a combined one which can be erased in one go
111 * There are more speed improvements for reads and writes possible, but not implemented now 111 * There are more speed improvements for reads and writes possible, but not implemented now
112 */ 112 */
113 {"AND 128MiB 3,3V 8-bit", 0x01, 2048, 128, 0x4000, NAND_IS_AND | NAND_NO_AUTOINCR | NAND_4PAGE_ARRAY | BBT_AUTO_REFRESH}, 113 {"AND 128MiB 3,3V 8-bit", 0x01, 2048, 128, 0x4000, NAND_IS_AND | NAND_NO_AUTOINCR | NAND_4PAGE_ARRAY | BBT_AUTO_REFRESH},
114 114
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 754b6ed7ce14..de4500395300 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Author: Artem B. Bityuckiy <dedekind@oktetlabs.ru>, <dedekind@infradead.org> 4 * Author: Artem B. Bityuckiy <dedekind@oktetlabs.ru>, <dedekind@infradead.org>
5 * 5 *
6 * Copyright (C) 2004 Nokia Corporation 6 * Copyright (C) 2004 Nokia Corporation
7 * 7 *
8 * Note: NS means "NAND Simulator". 8 * Note: NS means "NAND Simulator".
9 * Note: Input means input TO flash chip, output means output FROM chip. 9 * Note: Input means input TO flash chip, output means output FROM chip.
@@ -126,7 +126,7 @@ MODULE_PARM_DESC(dbg, "Output debug information if not zero");
126 126
127/* The largest possible page size */ 127/* The largest possible page size */
128#define NS_LARGEST_PAGE_SIZE 2048 128#define NS_LARGEST_PAGE_SIZE 2048
129 129
130/* The prefix for simulator output */ 130/* The prefix for simulator output */
131#define NS_OUTPUT_PREFIX "[nandsim]" 131#define NS_OUTPUT_PREFIX "[nandsim]"
132 132
@@ -145,7 +145,7 @@ MODULE_PARM_DESC(dbg, "Output debug information if not zero");
145 do { if (do_delays) udelay(us); } while(0) 145 do { if (do_delays) udelay(us); } while(0)
146#define NS_MDELAY(us) \ 146#define NS_MDELAY(us) \
147 do { if (do_delays) mdelay(us); } while(0) 147 do { if (do_delays) mdelay(us); } while(0)
148 148
149/* Is the nandsim structure initialized ? */ 149/* Is the nandsim structure initialized ? */
150#define NS_IS_INITIALIZED(ns) ((ns)->geom.totsz != 0) 150#define NS_IS_INITIALIZED(ns) ((ns)->geom.totsz != 0)
151 151
@@ -153,12 +153,12 @@ MODULE_PARM_DESC(dbg, "Output debug information if not zero");
153#define NS_STATUS_OK(ns) (NAND_STATUS_READY | (NAND_STATUS_WP * ((ns)->lines.wp == 0))) 153#define NS_STATUS_OK(ns) (NAND_STATUS_READY | (NAND_STATUS_WP * ((ns)->lines.wp == 0)))
154 154
155/* Operation failed completion status */ 155/* Operation failed completion status */
156#define NS_STATUS_FAILED(ns) (NAND_STATUS_FAIL | NS_STATUS_OK(ns)) 156#define NS_STATUS_FAILED(ns) (NAND_STATUS_FAIL | NS_STATUS_OK(ns))
157 157
158/* Calculate the page offset in flash RAM image by (row, column) address */ 158/* Calculate the page offset in flash RAM image by (row, column) address */
159#define NS_RAW_OFFSET(ns) \ 159#define NS_RAW_OFFSET(ns) \
160 (((ns)->regs.row << (ns)->geom.pgshift) + ((ns)->regs.row * (ns)->geom.oobsz) + (ns)->regs.column) 160 (((ns)->regs.row << (ns)->geom.pgshift) + ((ns)->regs.row * (ns)->geom.oobsz) + (ns)->regs.column)
161 161
162/* Calculate the OOB offset in flash RAM image by (row, column) address */ 162/* Calculate the OOB offset in flash RAM image by (row, column) address */
163#define NS_RAW_OFFSET_OOB(ns) (NS_RAW_OFFSET(ns) + ns->geom.pgsz) 163#define NS_RAW_OFFSET_OOB(ns) (NS_RAW_OFFSET(ns) + ns->geom.pgsz)
164 164
@@ -223,15 +223,15 @@ MODULE_PARM_DESC(dbg, "Output debug information if not zero");
223 223
224/* Remove action bits ftom state */ 224/* Remove action bits ftom state */
225#define NS_STATE(x) ((x) & ~ACTION_MASK) 225#define NS_STATE(x) ((x) & ~ACTION_MASK)
226 226
227/* 227/*
228 * Maximum previous states which need to be saved. Currently saving is 228 * Maximum previous states which need to be saved. Currently saving is
229 * only needed for page programm operation with preceeded read command 229 * only needed for page programm operation with preceeded read command
230 * (which is only valid for 512-byte pages). 230 * (which is only valid for 512-byte pages).
231 */ 231 */
232#define NS_MAX_PREVSTATES 1 232#define NS_MAX_PREVSTATES 1
233 233
234/* 234/*
235 * The structure which describes all the internal simulator data. 235 * The structure which describes all the internal simulator data.
236 */ 236 */
237struct nandsim { 237struct nandsim {
@@ -242,7 +242,7 @@ struct nandsim {
242 uint32_t options; /* chip's characteristic bits */ 242 uint32_t options; /* chip's characteristic bits */
243 uint32_t state; /* current chip state */ 243 uint32_t state; /* current chip state */
244 uint32_t nxstate; /* next expected state */ 244 uint32_t nxstate; /* next expected state */
245 245
246 uint32_t *op; /* current operation, NULL operations isn't known yet */ 246 uint32_t *op; /* current operation, NULL operations isn't known yet */
247 uint32_t pstates[NS_MAX_PREVSTATES]; /* previous states */ 247 uint32_t pstates[NS_MAX_PREVSTATES]; /* previous states */
248 uint16_t npstates; /* number of previous states saved */ 248 uint16_t npstates; /* number of previous states saved */
@@ -413,7 +413,7 @@ init_nandsim(struct mtd_info *mtd)
413 ns->geom.secaddrbytes = 3; 413 ns->geom.secaddrbytes = 3;
414 } 414 }
415 } 415 }
416 416
417 /* Detect how many ID bytes the NAND chip outputs */ 417 /* Detect how many ID bytes the NAND chip outputs */
418 for (i = 0; nand_flash_ids[i].name != NULL; i++) { 418 for (i = 0; nand_flash_ids[i].name != NULL; i++) {
419 if (second_id_byte != nand_flash_ids[i].id) 419 if (second_id_byte != nand_flash_ids[i].id)
@@ -444,7 +444,7 @@ init_nandsim(struct mtd_info *mtd)
444#ifdef CONFIG_NS_ABS_POS 444#ifdef CONFIG_NS_ABS_POS
445 ns->mem.byte = ioremap(CONFIG_NS_ABS_POS, ns->geom.totszoob); 445 ns->mem.byte = ioremap(CONFIG_NS_ABS_POS, ns->geom.totszoob);
446 if (!ns->mem.byte) { 446 if (!ns->mem.byte) {
447 NS_ERR("init_nandsim: failed to map the NAND flash image at address %p\n", 447 NS_ERR("init_nandsim: failed to map the NAND flash image at address %p\n",
448 (void *)CONFIG_NS_ABS_POS); 448 (void *)CONFIG_NS_ABS_POS);
449 return -ENOMEM; 449 return -ENOMEM;
450 } 450 }
@@ -567,7 +567,7 @@ static int
567check_command(int cmd) 567check_command(int cmd)
568{ 568{
569 switch (cmd) { 569 switch (cmd) {
570 570
571 case NAND_CMD_READ0: 571 case NAND_CMD_READ0:
572 case NAND_CMD_READSTART: 572 case NAND_CMD_READSTART:
573 case NAND_CMD_PAGEPROG: 573 case NAND_CMD_PAGEPROG:
@@ -580,7 +580,7 @@ check_command(int cmd)
580 case NAND_CMD_RESET: 580 case NAND_CMD_RESET:
581 case NAND_CMD_READ1: 581 case NAND_CMD_READ1:
582 return 0; 582 return 0;
583 583
584 case NAND_CMD_STATUS_MULTI: 584 case NAND_CMD_STATUS_MULTI:
585 default: 585 default:
586 return 1; 586 return 1;
@@ -631,7 +631,7 @@ static inline void
631accept_addr_byte(struct nandsim *ns, u_char bt) 631accept_addr_byte(struct nandsim *ns, u_char bt)
632{ 632{
633 uint byte = (uint)bt; 633 uint byte = (uint)bt;
634 634
635 if (ns->regs.count < (ns->geom.pgaddrbytes - ns->geom.secaddrbytes)) 635 if (ns->regs.count < (ns->geom.pgaddrbytes - ns->geom.secaddrbytes))
636 ns->regs.column |= (byte << 8 * ns->regs.count); 636 ns->regs.column |= (byte << 8 * ns->regs.count);
637 else { 637 else {
@@ -642,11 +642,11 @@ accept_addr_byte(struct nandsim *ns, u_char bt)
642 642
643 return; 643 return;
644} 644}
645 645
646/* 646/*
647 * Switch to STATE_READY state. 647 * Switch to STATE_READY state.
648 */ 648 */
649static inline void 649static inline void
650switch_to_ready_state(struct nandsim *ns, u_char status) 650switch_to_ready_state(struct nandsim *ns, u_char status)
651{ 651{
652 NS_DBG("switch_to_ready_state: switch to %s state\n", get_state_name(STATE_READY)); 652 NS_DBG("switch_to_ready_state: switch to %s state\n", get_state_name(STATE_READY));
@@ -675,7 +675,7 @@ switch_to_ready_state(struct nandsim *ns, u_char status)
675 * (for example program from the second half and read from the 675 * (for example program from the second half and read from the
676 * second half operations both begin with the READ1 command). In this 676 * second half operations both begin with the READ1 command). In this
677 * case the ns->pstates[] array contains previous states. 677 * case the ns->pstates[] array contains previous states.
678 * 678 *
679 * Thus, the function tries to find operation containing the following 679 * Thus, the function tries to find operation containing the following
680 * states (if the 'flag' parameter is 0): 680 * states (if the 'flag' parameter is 0):
681 * ns->pstates[0], ... ns->pstates[ns->npstates], ns->state 681 * ns->pstates[0], ... ns->pstates[ns->npstates], ns->state
@@ -683,7 +683,7 @@ switch_to_ready_state(struct nandsim *ns, u_char status)
683 * If (one and only one) matching operation is found, it is accepted ( 683 * If (one and only one) matching operation is found, it is accepted (
684 * ns->ops, ns->state, ns->nxstate are initialized, ns->npstate is 684 * ns->ops, ns->state, ns->nxstate are initialized, ns->npstate is
685 * zeroed). 685 * zeroed).
686 * 686 *
687 * If there are several maches, the current state is pushed to the 687 * If there are several maches, the current state is pushed to the
688 * ns->pstates. 688 * ns->pstates.
689 * 689 *
@@ -692,7 +692,7 @@ switch_to_ready_state(struct nandsim *ns, u_char status)
692 * In such situation the function is called with 'flag' != 0, and the 692 * In such situation the function is called with 'flag' != 0, and the
693 * operation is searched using the following pattern: 693 * operation is searched using the following pattern:
694 * ns->pstates[0], ... ns->pstates[ns->npstates], <address input> 694 * ns->pstates[0], ... ns->pstates[ns->npstates], <address input>
695 * 695 *
696 * It is supposed that this pattern must either match one operation on 696 * It is supposed that this pattern must either match one operation on
697 * none. There can't be ambiguity in that case. 697 * none. There can't be ambiguity in that case.
698 * 698 *
@@ -711,15 +711,15 @@ find_operation(struct nandsim *ns, uint32_t flag)
711{ 711{
712 int opsfound = 0; 712 int opsfound = 0;
713 int i, j, idx = 0; 713 int i, j, idx = 0;
714 714
715 for (i = 0; i < NS_OPER_NUM; i++) { 715 for (i = 0; i < NS_OPER_NUM; i++) {
716 716
717 int found = 1; 717 int found = 1;
718 718
719 if (!(ns->options & ops[i].reqopts)) 719 if (!(ns->options & ops[i].reqopts))
720 /* Ignore operations we can't perform */ 720 /* Ignore operations we can't perform */
721 continue; 721 continue;
722 722
723 if (flag) { 723 if (flag) {
724 if (!(ops[i].states[ns->npstates] & STATE_ADDR_MASK)) 724 if (!(ops[i].states[ns->npstates] & STATE_ADDR_MASK))
725 continue; 725 continue;
@@ -728,7 +728,7 @@ find_operation(struct nandsim *ns, uint32_t flag)
728 continue; 728 continue;
729 } 729 }
730 730
731 for (j = 0; j < ns->npstates; j++) 731 for (j = 0; j < ns->npstates; j++)
732 if (NS_STATE(ops[i].states[j]) != NS_STATE(ns->pstates[j]) 732 if (NS_STATE(ops[i].states[j]) != NS_STATE(ns->pstates[j])
733 && (ns->options & ops[idx].reqopts)) { 733 && (ns->options & ops[idx].reqopts)) {
734 found = 0; 734 found = 0;
@@ -745,7 +745,7 @@ find_operation(struct nandsim *ns, uint32_t flag)
745 /* Exact match */ 745 /* Exact match */
746 ns->op = &ops[idx].states[0]; 746 ns->op = &ops[idx].states[0];
747 if (flag) { 747 if (flag) {
748 /* 748 /*
749 * In this case the find_operation function was 749 * In this case the find_operation function was
750 * called when address has just began input. But it isn't 750 * called when address has just began input. But it isn't
751 * yet fully input and the current state must 751 * yet fully input and the current state must
@@ -763,7 +763,7 @@ find_operation(struct nandsim *ns, uint32_t flag)
763 idx, get_state_name(ns->state), get_state_name(ns->nxstate)); 763 idx, get_state_name(ns->state), get_state_name(ns->nxstate));
764 return 0; 764 return 0;
765 } 765 }
766 766
767 if (opsfound == 0) { 767 if (opsfound == 0) {
768 /* Nothing was found. Try to ignore previous commands (if any) and search again */ 768 /* Nothing was found. Try to ignore previous commands (if any) and search again */
769 if (ns->npstates != 0) { 769 if (ns->npstates != 0) {
@@ -777,13 +777,13 @@ find_operation(struct nandsim *ns, uint32_t flag)
777 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); 777 switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
778 return -2; 778 return -2;
779 } 779 }
780 780
781 if (flag) { 781 if (flag) {
782 /* This shouldn't happen */ 782 /* This shouldn't happen */
783 NS_DBG("find_operation: BUG, operation must be known if address is input\n"); 783 NS_DBG("find_operation: BUG, operation must be known if address is input\n");
784 return -2; 784 return -2;
785 } 785 }
786 786
787 NS_DBG("find_operation: there is still ambiguity\n"); 787 NS_DBG("find_operation: there is still ambiguity\n");
788 788
789 ns->pstates[ns->npstates++] = ns->state; 789 ns->pstates[ns->npstates++] = ns->state;
@@ -803,7 +803,7 @@ do_state_action(struct nandsim *ns, uint32_t action)
803 int busdiv = ns->busw == 8 ? 1 : 2; 803 int busdiv = ns->busw == 8 ? 1 : 2;
804 804
805 action &= ACTION_MASK; 805 action &= ACTION_MASK;
806 806
807 /* Check that page address input is correct */ 807 /* Check that page address input is correct */
808 if (action != ACTION_SECERASE && ns->regs.row >= ns->geom.pgnum) { 808 if (action != ACTION_SECERASE && ns->regs.row >= ns->geom.pgnum) {
809 NS_WARN("do_state_action: wrong page number (%#x)\n", ns->regs.row); 809 NS_WARN("do_state_action: wrong page number (%#x)\n", ns->regs.row);
@@ -827,14 +827,14 @@ do_state_action(struct nandsim *ns, uint32_t action)
827 827
828 NS_DBG("do_state_action: (ACTION_CPY:) copy %d bytes to int buf, raw offset %d\n", 828 NS_DBG("do_state_action: (ACTION_CPY:) copy %d bytes to int buf, raw offset %d\n",
829 num, NS_RAW_OFFSET(ns) + ns->regs.off); 829 num, NS_RAW_OFFSET(ns) + ns->regs.off);
830 830
831 if (ns->regs.off == 0) 831 if (ns->regs.off == 0)
832 NS_LOG("read page %d\n", ns->regs.row); 832 NS_LOG("read page %d\n", ns->regs.row);
833 else if (ns->regs.off < ns->geom.pgsz) 833 else if (ns->regs.off < ns->geom.pgsz)
834 NS_LOG("read page %d (second half)\n", ns->regs.row); 834 NS_LOG("read page %d (second half)\n", ns->regs.row);
835 else 835 else
836 NS_LOG("read OOB of page %d\n", ns->regs.row); 836 NS_LOG("read OOB of page %d\n", ns->regs.row);
837 837
838 NS_UDELAY(access_delay); 838 NS_UDELAY(access_delay);
839 NS_UDELAY(input_cycle * ns->geom.pgsz / 1000 / busdiv); 839 NS_UDELAY(input_cycle * ns->geom.pgsz / 1000 / busdiv);
840 840
@@ -844,30 +844,30 @@ do_state_action(struct nandsim *ns, uint32_t action)
844 /* 844 /*
845 * Erase sector. 845 * Erase sector.
846 */ 846 */
847 847
848 if (ns->lines.wp) { 848 if (ns->lines.wp) {
849 NS_ERR("do_state_action: device is write-protected, ignore sector erase\n"); 849 NS_ERR("do_state_action: device is write-protected, ignore sector erase\n");
850 return -1; 850 return -1;
851 } 851 }
852 852
853 if (ns->regs.row >= ns->geom.pgnum - ns->geom.pgsec 853 if (ns->regs.row >= ns->geom.pgnum - ns->geom.pgsec
854 || (ns->regs.row & ~(ns->geom.secsz - 1))) { 854 || (ns->regs.row & ~(ns->geom.secsz - 1))) {
855 NS_ERR("do_state_action: wrong sector address (%#x)\n", ns->regs.row); 855 NS_ERR("do_state_action: wrong sector address (%#x)\n", ns->regs.row);
856 return -1; 856 return -1;
857 } 857 }
858 858
859 ns->regs.row = (ns->regs.row << 859 ns->regs.row = (ns->regs.row <<
860 8 * (ns->geom.pgaddrbytes - ns->geom.secaddrbytes)) | ns->regs.column; 860 8 * (ns->geom.pgaddrbytes - ns->geom.secaddrbytes)) | ns->regs.column;
861 ns->regs.column = 0; 861 ns->regs.column = 0;
862 862
863 NS_DBG("do_state_action: erase sector at address %#x, off = %d\n", 863 NS_DBG("do_state_action: erase sector at address %#x, off = %d\n",
864 ns->regs.row, NS_RAW_OFFSET(ns)); 864 ns->regs.row, NS_RAW_OFFSET(ns));
865 NS_LOG("erase sector %d\n", ns->regs.row >> (ns->geom.secshift - ns->geom.pgshift)); 865 NS_LOG("erase sector %d\n", ns->regs.row >> (ns->geom.secshift - ns->geom.pgshift));
866 866
867 memset(ns->mem.byte + NS_RAW_OFFSET(ns), 0xFF, ns->geom.secszoob); 867 memset(ns->mem.byte + NS_RAW_OFFSET(ns), 0xFF, ns->geom.secszoob);
868 868
869 NS_MDELAY(erase_delay); 869 NS_MDELAY(erase_delay);
870 870
871 break; 871 break;
872 872
873 case ACTION_PRGPAGE: 873 case ACTION_PRGPAGE:
@@ -893,12 +893,12 @@ do_state_action(struct nandsim *ns, uint32_t action)
893 NS_DBG("do_state_action: copy %d bytes from int buf to (%#x, %#x), raw off = %d\n", 893 NS_DBG("do_state_action: copy %d bytes from int buf to (%#x, %#x), raw off = %d\n",
894 num, ns->regs.row, ns->regs.column, NS_RAW_OFFSET(ns) + ns->regs.off); 894 num, ns->regs.row, ns->regs.column, NS_RAW_OFFSET(ns) + ns->regs.off);
895 NS_LOG("programm page %d\n", ns->regs.row); 895 NS_LOG("programm page %d\n", ns->regs.row);
896 896
897 NS_UDELAY(programm_delay); 897 NS_UDELAY(programm_delay);
898 NS_UDELAY(output_cycle * ns->geom.pgsz / 1000 / busdiv); 898 NS_UDELAY(output_cycle * ns->geom.pgsz / 1000 / busdiv);
899 899
900 break; 900 break;
901 901
902 case ACTION_ZEROOFF: 902 case ACTION_ZEROOFF:
903 NS_DBG("do_state_action: set internal offset to 0\n"); 903 NS_DBG("do_state_action: set internal offset to 0\n");
904 ns->regs.off = 0; 904 ns->regs.off = 0;
@@ -918,7 +918,7 @@ do_state_action(struct nandsim *ns, uint32_t action)
918 NS_DBG("do_state_action: set internal offset to %d\n", ns->geom.pgsz); 918 NS_DBG("do_state_action: set internal offset to %d\n", ns->geom.pgsz);
919 ns->regs.off = ns->geom.pgsz; 919 ns->regs.off = ns->geom.pgsz;
920 break; 920 break;
921 921
922 default: 922 default:
923 NS_DBG("do_state_action: BUG! unknown action\n"); 923 NS_DBG("do_state_action: BUG! unknown action\n");
924 } 924 }
@@ -937,7 +937,7 @@ switch_state(struct nandsim *ns)
937 * The current operation have already been identified. 937 * The current operation have already been identified.
938 * Just follow the states chain. 938 * Just follow the states chain.
939 */ 939 */
940 940
941 ns->stateidx += 1; 941 ns->stateidx += 1;
942 ns->state = ns->nxstate; 942 ns->state = ns->nxstate;
943 ns->nxstate = ns->op[ns->stateidx + 1]; 943 ns->nxstate = ns->op[ns->stateidx + 1];
@@ -951,14 +951,14 @@ switch_state(struct nandsim *ns)
951 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); 951 switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
952 return; 952 return;
953 } 953 }
954 954
955 } else { 955 } else {
956 /* 956 /*
957 * We don't yet know which operation we perform. 957 * We don't yet know which operation we perform.
958 * Try to identify it. 958 * Try to identify it.
959 */ 959 */
960 960
961 /* 961 /*
962 * The only event causing the switch_state function to 962 * The only event causing the switch_state function to
963 * be called with yet unknown operation is new command. 963 * be called with yet unknown operation is new command.
964 */ 964 */
@@ -987,7 +987,7 @@ switch_state(struct nandsim *ns)
987 */ 987 */
988 988
989 u_char status = NS_STATUS_OK(ns); 989 u_char status = NS_STATUS_OK(ns);
990 990
991 /* In case of data states, see if all bytes were input/output */ 991 /* In case of data states, see if all bytes were input/output */
992 if ((ns->state & (STATE_DATAIN_MASK | STATE_DATAOUT_MASK)) 992 if ((ns->state & (STATE_DATAIN_MASK | STATE_DATAOUT_MASK))
993 && ns->regs.count != ns->regs.num) { 993 && ns->regs.count != ns->regs.num) {
@@ -995,17 +995,17 @@ switch_state(struct nandsim *ns)
995 ns->regs.num - ns->regs.count); 995 ns->regs.num - ns->regs.count);
996 status = NS_STATUS_FAILED(ns); 996 status = NS_STATUS_FAILED(ns);
997 } 997 }
998 998
999 NS_DBG("switch_state: operation complete, switch to STATE_READY state\n"); 999 NS_DBG("switch_state: operation complete, switch to STATE_READY state\n");
1000 1000
1001 switch_to_ready_state(ns, status); 1001 switch_to_ready_state(ns, status);
1002 1002
1003 return; 1003 return;
1004 } else if (ns->nxstate & (STATE_DATAIN_MASK | STATE_DATAOUT_MASK)) { 1004 } else if (ns->nxstate & (STATE_DATAIN_MASK | STATE_DATAOUT_MASK)) {
1005 /* 1005 /*
1006 * If the next state is data input/output, switch to it now 1006 * If the next state is data input/output, switch to it now
1007 */ 1007 */
1008 1008
1009 ns->state = ns->nxstate; 1009 ns->state = ns->nxstate;
1010 ns->nxstate = ns->op[++ns->stateidx + 1]; 1010 ns->nxstate = ns->op[++ns->stateidx + 1];
1011 ns->regs.num = ns->regs.count = 0; 1011 ns->regs.num = ns->regs.count = 0;
@@ -1023,16 +1023,16 @@ switch_state(struct nandsim *ns)
1023 case STATE_DATAOUT: 1023 case STATE_DATAOUT:
1024 ns->regs.num = ns->geom.pgszoob - ns->regs.off - ns->regs.column; 1024 ns->regs.num = ns->geom.pgszoob - ns->regs.off - ns->regs.column;
1025 break; 1025 break;
1026 1026
1027 case STATE_DATAOUT_ID: 1027 case STATE_DATAOUT_ID:
1028 ns->regs.num = ns->geom.idbytes; 1028 ns->regs.num = ns->geom.idbytes;
1029 break; 1029 break;
1030 1030
1031 case STATE_DATAOUT_STATUS: 1031 case STATE_DATAOUT_STATUS:
1032 case STATE_DATAOUT_STATUS_M: 1032 case STATE_DATAOUT_STATUS_M:
1033 ns->regs.count = ns->regs.num = 0; 1033 ns->regs.count = ns->regs.num = 0;
1034 break; 1034 break;
1035 1035
1036 default: 1036 default:
1037 NS_ERR("switch_state: BUG! unknown data state\n"); 1037 NS_ERR("switch_state: BUG! unknown data state\n");
1038 } 1038 }
@@ -1044,16 +1044,16 @@ switch_state(struct nandsim *ns)
1044 */ 1044 */
1045 1045
1046 ns->regs.count = 0; 1046 ns->regs.count = 0;
1047 1047
1048 switch (NS_STATE(ns->nxstate)) { 1048 switch (NS_STATE(ns->nxstate)) {
1049 case STATE_ADDR_PAGE: 1049 case STATE_ADDR_PAGE:
1050 ns->regs.num = ns->geom.pgaddrbytes; 1050 ns->regs.num = ns->geom.pgaddrbytes;
1051 1051
1052 break; 1052 break;
1053 case STATE_ADDR_SEC: 1053 case STATE_ADDR_SEC:
1054 ns->regs.num = ns->geom.secaddrbytes; 1054 ns->regs.num = ns->geom.secaddrbytes;
1055 break; 1055 break;
1056 1056
1057 case STATE_ADDR_ZERO: 1057 case STATE_ADDR_ZERO:
1058 ns->regs.num = 1; 1058 ns->regs.num = 1;
1059 break; 1059 break;
@@ -1062,7 +1062,7 @@ switch_state(struct nandsim *ns)
1062 NS_ERR("switch_state: BUG! unknown address state\n"); 1062 NS_ERR("switch_state: BUG! unknown address state\n");
1063 } 1063 }
1064 } else { 1064 } else {
1065 /* 1065 /*
1066 * Just reset internal counters. 1066 * Just reset internal counters.
1067 */ 1067 */
1068 1068
@@ -1184,7 +1184,7 @@ ns_nand_read_byte(struct mtd_info *mtd)
1184 default: 1184 default:
1185 BUG(); 1185 BUG();
1186 } 1186 }
1187 1187
1188 if (ns->regs.count == ns->regs.num) { 1188 if (ns->regs.count == ns->regs.num) {
1189 NS_DBG("read_byte: all bytes were read\n"); 1189 NS_DBG("read_byte: all bytes were read\n");
1190 1190
@@ -1201,9 +1201,9 @@ ns_nand_read_byte(struct mtd_info *mtd)
1201 } 1201 }
1202 else if (NS_STATE(ns->nxstate) == STATE_READY) 1202 else if (NS_STATE(ns->nxstate) == STATE_READY)
1203 switch_state(ns); 1203 switch_state(ns);
1204 1204
1205 } 1205 }
1206 1206
1207 return outb; 1207 return outb;
1208} 1208}
1209 1209
@@ -1211,7 +1211,7 @@ static void
1211ns_nand_write_byte(struct mtd_info *mtd, u_char byte) 1211ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1212{ 1212{
1213 struct nandsim *ns = (struct nandsim *)((struct nand_chip *)mtd->priv)->priv; 1213 struct nandsim *ns = (struct nandsim *)((struct nand_chip *)mtd->priv)->priv;
1214 1214
1215 /* Sanity and correctness checks */ 1215 /* Sanity and correctness checks */
1216 if (!ns->lines.ce) { 1216 if (!ns->lines.ce) {
1217 NS_ERR("write_byte: chip is disabled, ignore write\n"); 1217 NS_ERR("write_byte: chip is disabled, ignore write\n");
@@ -1221,7 +1221,7 @@ ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1221 NS_ERR("write_byte: ALE and CLE pins are high simultaneously, ignore write\n"); 1221 NS_ERR("write_byte: ALE and CLE pins are high simultaneously, ignore write\n");
1222 return; 1222 return;
1223 } 1223 }
1224 1224
1225 if (ns->lines.cle == 1) { 1225 if (ns->lines.cle == 1) {
1226 /* 1226 /*
1227 * The byte written is a command. 1227 * The byte written is a command.
@@ -1233,7 +1233,7 @@ ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1233 return; 1233 return;
1234 } 1234 }
1235 1235
1236 /* 1236 /*
1237 * Chip might still be in STATE_DATAOUT 1237 * Chip might still be in STATE_DATAOUT
1238 * (if OPT_AUTOINCR feature is supported), STATE_DATAOUT_STATUS or 1238 * (if OPT_AUTOINCR feature is supported), STATE_DATAOUT_STATUS or
1239 * STATE_DATAOUT_STATUS_M state. If so, switch state. 1239 * STATE_DATAOUT_STATUS_M state. If so, switch state.
@@ -1254,13 +1254,13 @@ ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1254 "ignore previous states\n", (uint)byte, get_state_name(ns->nxstate)); 1254 "ignore previous states\n", (uint)byte, get_state_name(ns->nxstate));
1255 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); 1255 switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
1256 } 1256 }
1257 1257
1258 /* Check that the command byte is correct */ 1258 /* Check that the command byte is correct */
1259 if (check_command(byte)) { 1259 if (check_command(byte)) {
1260 NS_ERR("write_byte: unknown command %#x\n", (uint)byte); 1260 NS_ERR("write_byte: unknown command %#x\n", (uint)byte);
1261 return; 1261 return;
1262 } 1262 }
1263 1263
1264 NS_DBG("command byte corresponding to %s state accepted\n", 1264 NS_DBG("command byte corresponding to %s state accepted\n",
1265 get_state_name(get_state_by_command(byte))); 1265 get_state_name(get_state_by_command(byte)));
1266 ns->regs.command = byte; 1266 ns->regs.command = byte;
@@ -1277,12 +1277,12 @@ ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1277 1277
1278 if (find_operation(ns, 1) < 0) 1278 if (find_operation(ns, 1) < 0)
1279 return; 1279 return;
1280 1280
1281 if ((ns->state & ACTION_MASK) && do_state_action(ns, ns->state) < 0) { 1281 if ((ns->state & ACTION_MASK) && do_state_action(ns, ns->state) < 0) {
1282 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); 1282 switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
1283 return; 1283 return;
1284 } 1284 }
1285 1285
1286 ns->regs.count = 0; 1286 ns->regs.count = 0;
1287 switch (NS_STATE(ns->nxstate)) { 1287 switch (NS_STATE(ns->nxstate)) {
1288 case STATE_ADDR_PAGE: 1288 case STATE_ADDR_PAGE:
@@ -1306,7 +1306,7 @@ ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1306 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); 1306 switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
1307 return; 1307 return;
1308 } 1308 }
1309 1309
1310 /* Check if this is expected byte */ 1310 /* Check if this is expected byte */
1311 if (ns->regs.count == ns->regs.num) { 1311 if (ns->regs.count == ns->regs.num) {
1312 NS_ERR("write_byte: no more address bytes expected\n"); 1312 NS_ERR("write_byte: no more address bytes expected\n");
@@ -1325,12 +1325,12 @@ ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1325 NS_DBG("address (%#x, %#x) is accepted\n", ns->regs.row, ns->regs.column); 1325 NS_DBG("address (%#x, %#x) is accepted\n", ns->regs.row, ns->regs.column);
1326 switch_state(ns); 1326 switch_state(ns);
1327 } 1327 }
1328 1328
1329 } else { 1329 } else {
1330 /* 1330 /*
1331 * The byte written is an input data. 1331 * The byte written is an input data.
1332 */ 1332 */
1333 1333
1334 /* Check that chip is expecting data input */ 1334 /* Check that chip is expecting data input */
1335 if (!(ns->state & STATE_DATAIN_MASK)) { 1335 if (!(ns->state & STATE_DATAIN_MASK)) {
1336 NS_ERR("write_byte: data input (%#x) isn't expected, state is %s, " 1336 NS_ERR("write_byte: data input (%#x) isn't expected, state is %s, "
@@ -1372,7 +1372,7 @@ ns_nand_read_word(struct mtd_info *mtd)
1372 struct nand_chip *chip = (struct nand_chip *)mtd->priv; 1372 struct nand_chip *chip = (struct nand_chip *)mtd->priv;
1373 1373
1374 NS_DBG("read_word\n"); 1374 NS_DBG("read_word\n");
1375 1375
1376 return chip->read_byte(mtd) | (chip->read_byte(mtd) << 8); 1376 return chip->read_byte(mtd) | (chip->read_byte(mtd) << 8);
1377} 1377}
1378 1378
@@ -1380,14 +1380,14 @@ static void
1380ns_nand_write_word(struct mtd_info *mtd, uint16_t word) 1380ns_nand_write_word(struct mtd_info *mtd, uint16_t word)
1381{ 1381{
1382 struct nand_chip *chip = (struct nand_chip *)mtd->priv; 1382 struct nand_chip *chip = (struct nand_chip *)mtd->priv;
1383 1383
1384 NS_DBG("write_word\n"); 1384 NS_DBG("write_word\n");
1385 1385
1386 chip->write_byte(mtd, word & 0xFF); 1386 chip->write_byte(mtd, word & 0xFF);
1387 chip->write_byte(mtd, word >> 8); 1387 chip->write_byte(mtd, word >> 8);
1388} 1388}
1389 1389
1390static void 1390static void
1391ns_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 1391ns_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
1392{ 1392{
1393 struct nandsim *ns = (struct nandsim *)((struct nand_chip *)mtd->priv)->priv; 1393 struct nandsim *ns = (struct nandsim *)((struct nand_chip *)mtd->priv)->priv;
@@ -1409,13 +1409,13 @@ ns_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
1409 1409
1410 memcpy(ns->buf.byte + ns->regs.count, buf, len); 1410 memcpy(ns->buf.byte + ns->regs.count, buf, len);
1411 ns->regs.count += len; 1411 ns->regs.count += len;
1412 1412
1413 if (ns->regs.count == ns->regs.num) { 1413 if (ns->regs.count == ns->regs.num) {
1414 NS_DBG("write_buf: %d bytes were written\n", ns->regs.count); 1414 NS_DBG("write_buf: %d bytes were written\n", ns->regs.count);
1415 } 1415 }
1416} 1416}
1417 1417
1418static void 1418static void
1419ns_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) 1419ns_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
1420{ 1420{
1421 struct nandsim *ns = (struct nandsim *)((struct nand_chip *)mtd->priv)->priv; 1421 struct nandsim *ns = (struct nandsim *)((struct nand_chip *)mtd->priv)->priv;
@@ -1453,7 +1453,7 @@ ns_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
1453 1453
1454 memcpy(buf, ns->buf.byte + ns->regs.count, len); 1454 memcpy(buf, ns->buf.byte + ns->regs.count, len);
1455 ns->regs.count += len; 1455 ns->regs.count += len;
1456 1456
1457 if (ns->regs.count == ns->regs.num) { 1457 if (ns->regs.count == ns->regs.num) {
1458 if ((ns->options & OPT_AUTOINCR) && NS_STATE(ns->state) == STATE_DATAOUT) { 1458 if ((ns->options & OPT_AUTOINCR) && NS_STATE(ns->state) == STATE_DATAOUT) {
1459 ns->regs.count = 0; 1459 ns->regs.count = 0;
@@ -1465,11 +1465,11 @@ ns_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
1465 else if (NS_STATE(ns->nxstate) == STATE_READY) 1465 else if (NS_STATE(ns->nxstate) == STATE_READY)
1466 switch_state(ns); 1466 switch_state(ns);
1467 } 1467 }
1468 1468
1469 return; 1469 return;
1470} 1470}
1471 1471
1472static int 1472static int
1473ns_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) 1473ns_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
1474{ 1474{
1475 ns_nand_read_buf(mtd, (u_char *)&ns_verify_buf[0], len); 1475 ns_nand_read_buf(mtd, (u_char *)&ns_verify_buf[0], len);
@@ -1496,7 +1496,7 @@ int __init ns_init_module(void)
1496 NS_ERR("wrong bus width (%d), use only 8 or 16\n", bus_width); 1496 NS_ERR("wrong bus width (%d), use only 8 or 16\n", bus_width);
1497 return -EINVAL; 1497 return -EINVAL;
1498 } 1498 }
1499 1499
1500 /* Allocate and initialize mtd_info, nand_chip and nandsim structures */ 1500 /* Allocate and initialize mtd_info, nand_chip and nandsim structures */
1501 nsmtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip) 1501 nsmtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip)
1502 + sizeof(struct nandsim), GFP_KERNEL); 1502 + sizeof(struct nandsim), GFP_KERNEL);
@@ -1509,7 +1509,7 @@ int __init ns_init_module(void)
1509 chip = (struct nand_chip *)(nsmtd + 1); 1509 chip = (struct nand_chip *)(nsmtd + 1);
1510 nsmtd->priv = (void *)chip; 1510 nsmtd->priv = (void *)chip;
1511 nand = (struct nandsim *)(chip + 1); 1511 nand = (struct nandsim *)(chip + 1);
1512 chip->priv = (void *)nand; 1512 chip->priv = (void *)nand;
1513 1513
1514 /* 1514 /*
1515 * Register simulator's callbacks. 1515 * Register simulator's callbacks.
@@ -1526,9 +1526,9 @@ int __init ns_init_module(void)
1526 chip->eccmode = NAND_ECC_SOFT; 1526 chip->eccmode = NAND_ECC_SOFT;
1527 chip->options |= NAND_SKIP_BBTSCAN; 1527 chip->options |= NAND_SKIP_BBTSCAN;
1528 1528
1529 /* 1529 /*
1530 * Perform minimum nandsim structure initialization to handle 1530 * Perform minimum nandsim structure initialization to handle
1531 * the initial ID read command correctly 1531 * the initial ID read command correctly
1532 */ 1532 */
1533 if (third_id_byte != 0xFF || fourth_id_byte != 0xFF) 1533 if (third_id_byte != 0xFF || fourth_id_byte != 0xFF)
1534 nand->geom.idbytes = 4; 1534 nand->geom.idbytes = 4;
@@ -1557,7 +1557,7 @@ int __init ns_init_module(void)
1557 NS_ERR("scan_bbt: can't initialize the nandsim structure\n"); 1557 NS_ERR("scan_bbt: can't initialize the nandsim structure\n");
1558 goto error; 1558 goto error;
1559 } 1559 }
1560 1560
1561 if ((retval = nand_default_bbt(nsmtd)) != 0) { 1561 if ((retval = nand_default_bbt(nsmtd)) != 0) {
1562 free_nandsim(nand); 1562 free_nandsim(nand);
1563 goto error; 1563 goto error;
diff --git a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c
index e510a83d7bdb..91a95f34a6ee 100644
--- a/drivers/mtd/nand/ppchameleonevb.c
+++ b/drivers/mtd/nand/ppchameleonevb.c
@@ -6,7 +6,7 @@
6 * Derived from drivers/mtd/nand/edb7312.c 6 * Derived from drivers/mtd/nand/edb7312.c
7 * 7 *
8 * 8 *
9 * $Id: ppchameleonevb.c,v 1.6 2004/11/05 16:07:16 kalev Exp $ 9 * $Id: ppchameleonevb.c,v 1.7 2005/11/07 11:14:31 gleixner Exp $
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -338,7 +338,7 @@ nand_evb_init:
338 out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xFFFFFFF0); 338 out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xFFFFFFF0);
339 out_be32((volatile unsigned*)GPIO0_TSRL, in_be32((volatile unsigned*)GPIO0_TSRL) & 0x3FFFFFFF); 339 out_be32((volatile unsigned*)GPIO0_TSRL, in_be32((volatile unsigned*)GPIO0_TSRL) & 0x3FFFFFFF);
340 /* enable output driver */ 340 /* enable output driver */
341 out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_EVB_nCE_GPIO_PIN | 341 out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_EVB_nCE_GPIO_PIN |
342 NAND_EVB_CLE_GPIO_PIN | NAND_EVB_ALE_GPIO_PIN); 342 NAND_EVB_CLE_GPIO_PIN | NAND_EVB_ALE_GPIO_PIN);
343#ifdef USE_READY_BUSY_PIN 343#ifdef USE_READY_BUSY_PIN
344 /* three-state select */ 344 /* three-state select */
@@ -402,7 +402,7 @@ static void __exit ppchameleonevb_cleanup (void)
402 /* Release resources, unregister device(s) */ 402 /* Release resources, unregister device(s) */
403 nand_release (ppchameleon_mtd); 403 nand_release (ppchameleon_mtd);
404 nand_release (ppchameleonevb_mtd); 404 nand_release (ppchameleonevb_mtd);
405 405
406 /* Release iomaps */ 406 /* Release iomaps */
407 this = (struct nand_chip *) &ppchameleon_mtd[1]; 407 this = (struct nand_chip *) &ppchameleon_mtd[1];
408 iounmap((void *) this->IO_ADDR_R; 408 iounmap((void *) this->IO_ADDR_R;
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
index 031051cbde76..3a5841c9d950 100644
--- a/drivers/mtd/nand/rtc_from4.c
+++ b/drivers/mtd/nand/rtc_from4.c
@@ -2,11 +2,11 @@
2 * drivers/mtd/nand/rtc_from4.c 2 * drivers/mtd/nand/rtc_from4.c
3 * 3 *
4 * Copyright (C) 2004 Red Hat, Inc. 4 * Copyright (C) 2004 Red Hat, Inc.
5 * 5 *
6 * Derived from drivers/mtd/nand/spia.c 6 * Derived from drivers/mtd/nand/spia.c
7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
8 * 8 *
9 * $Id: rtc_from4.c,v 1.9 2005/01/24 20:40:11 dmarlin Exp $ 9 * $Id: rtc_from4.c,v 1.10 2005/11/07 11:14:31 gleixner Exp $
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -14,8 +14,8 @@
14 * 14 *
15 * Overview: 15 * Overview:
16 * This is a device driver for the AG-AND flash device found on the 16 * This is a device driver for the AG-AND flash device found on the
17 * Renesas Technology Corp. Flash ROM 4-slot interface board (FROM_BOARD4), 17 * Renesas Technology Corp. Flash ROM 4-slot interface board (FROM_BOARD4),
18 * which utilizes the Renesas HN29V1G91T-30 part. 18 * which utilizes the Renesas HN29V1G91T-30 part.
19 * This chip is a 1 GBibit (128MiB x 8 bits) AG-AND flash device. 19 * This chip is a 1 GBibit (128MiB x 8 bits) AG-AND flash device.
20 */ 20 */
21 21
@@ -105,9 +105,9 @@ const static struct mtd_partition partition_info[] = {
105}; 105};
106#define NUM_PARTITIONS 1 106#define NUM_PARTITIONS 1
107 107
108/* 108/*
109 * hardware specific flash bbt decriptors 109 * hardware specific flash bbt decriptors
110 * Note: this is to allow debugging by disabling 110 * Note: this is to allow debugging by disabling
111 * NAND_BBT_CREATE and/or NAND_BBT_WRITE 111 * NAND_BBT_CREATE and/or NAND_BBT_WRITE
112 * 112 *
113 */ 113 */
@@ -141,7 +141,7 @@ static struct nand_bbt_descr rtc_from4_bbt_mirror_descr = {
141/* the Reed Solomon control structure */ 141/* the Reed Solomon control structure */
142static struct rs_control *rs_decoder; 142static struct rs_control *rs_decoder;
143 143
144/* 144/*
145 * hardware specific Out Of Band information 145 * hardware specific Out Of Band information
146 */ 146 */
147static struct nand_oobinfo rtc_from4_nand_oobinfo = { 147static struct nand_oobinfo rtc_from4_nand_oobinfo = {
@@ -200,38 +200,38 @@ static uint8_t revbits[256] = {
200 200
201 201
202 202
203/* 203/*
204 * rtc_from4_hwcontrol - hardware specific access to control-lines 204 * rtc_from4_hwcontrol - hardware specific access to control-lines
205 * @mtd: MTD device structure 205 * @mtd: MTD device structure
206 * @cmd: hardware control command 206 * @cmd: hardware control command
207 * 207 *
208 * Address lines (A5 and A4) are used to control Command and Address Latch 208 * Address lines (A5 and A4) are used to control Command and Address Latch
209 * Enable on this board, so set the read/write address appropriately. 209 * Enable on this board, so set the read/write address appropriately.
210 * 210 *
211 * Chip Enable is also controlled by the Chip Select (CS5) and 211 * Chip Enable is also controlled by the Chip Select (CS5) and
212 * Address lines (A24-A22), so no action is required here. 212 * Address lines (A24-A22), so no action is required here.
213 * 213 *
214 */ 214 */
215static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) 215static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd)
216{ 216{
217 struct nand_chip* this = (struct nand_chip *) (mtd->priv); 217 struct nand_chip* this = (struct nand_chip *) (mtd->priv);
218 218
219 switch(cmd) { 219 switch(cmd) {
220 220
221 case NAND_CTL_SETCLE: 221 case NAND_CTL_SETCLE:
222 this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_CLE); 222 this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_CLE);
223 break; 223 break;
224 case NAND_CTL_CLRCLE: 224 case NAND_CTL_CLRCLE:
225 this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_CLE); 225 this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_CLE);
226 break; 226 break;
227 227
228 case NAND_CTL_SETALE: 228 case NAND_CTL_SETALE:
229 this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_ALE); 229 this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_ALE);
230 break; 230 break;
231 case NAND_CTL_CLRALE: 231 case NAND_CTL_CLRALE:
232 this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_ALE); 232 this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_ALE);
233 break; 233 break;
234 234
235 case NAND_CTL_SETNCE: 235 case NAND_CTL_SETNCE:
236 break; 236 break;
237 case NAND_CTL_CLRNCE: 237 case NAND_CTL_CLRNCE:
@@ -296,7 +296,7 @@ static int rtc_from4_nand_device_ready(struct mtd_info *mtd)
296 * @mtd: MTD device structure 296 * @mtd: MTD device structure
297 * @chip: Chip to select (0 == slot 3, 1 == slot 4) 297 * @chip: Chip to select (0 == slot 3, 1 == slot 4)
298 * 298 *
299 * If there was a sudden loss of power during an erase operation, a 299 * If there was a sudden loss of power during an erase operation, a
300 * "device recovery" operation must be performed when power is restored 300 * "device recovery" operation must be performed when power is restored
301 * to ensure correct operation. This routine performs the required steps 301 * to ensure correct operation. This routine performs the required steps
302 * for the requested chip. 302 * for the requested chip.
@@ -312,7 +312,7 @@ static void deplete(struct mtd_info *mtd, int chip)
312 while (!this->dev_ready(mtd)); 312 while (!this->dev_ready(mtd));
313 313
314 this->select_chip(mtd, chip); 314 this->select_chip(mtd, chip);
315 315
316 /* Send the commands for device recovery, phase 1 */ 316 /* Send the commands for device recovery, phase 1 */
317 this->cmdfunc (mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0000); 317 this->cmdfunc (mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0000);
318 this->cmdfunc (mtd, NAND_CMD_DEPLETE2, -1, -1); 318 this->cmdfunc (mtd, NAND_CMD_DEPLETE2, -1, -1);
@@ -330,7 +330,7 @@ static void deplete(struct mtd_info *mtd, int chip)
330 * @mtd: MTD device structure 330 * @mtd: MTD device structure
331 * @mode: I/O mode; read or write 331 * @mode: I/O mode; read or write
332 * 332 *
333 * enable hardware ECC for data read or write 333 * enable hardware ECC for data read or write
334 * 334 *
335 */ 335 */
336static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode) 336static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode)
@@ -340,7 +340,7 @@ static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode)
340 340
341 switch (mode) { 341 switch (mode) {
342 case NAND_ECC_READ : 342 case NAND_ECC_READ :
343 status = RTC_FROM4_RS_ECC_CTL_CLR 343 status = RTC_FROM4_RS_ECC_CTL_CLR
344 | RTC_FROM4_RS_ECC_CTL_FD_E; 344 | RTC_FROM4_RS_ECC_CTL_FD_E;
345 345
346 *rs_ecc_ctl = status; 346 *rs_ecc_ctl = status;
@@ -353,8 +353,8 @@ static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode)
353 break; 353 break;
354 354
355 case NAND_ECC_WRITE : 355 case NAND_ECC_WRITE :
356 status = RTC_FROM4_RS_ECC_CTL_CLR 356 status = RTC_FROM4_RS_ECC_CTL_CLR
357 | RTC_FROM4_RS_ECC_CTL_GEN 357 | RTC_FROM4_RS_ECC_CTL_GEN
358 | RTC_FROM4_RS_ECC_CTL_FD_E; 358 | RTC_FROM4_RS_ECC_CTL_FD_E;
359 359
360 *rs_ecc_ctl = status; 360 *rs_ecc_ctl = status;
@@ -411,7 +411,7 @@ static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_c
411static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_char *ecc1, u_char *ecc2) 411static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_char *ecc1, u_char *ecc2)
412{ 412{
413 int i, j, res; 413 int i, j, res;
414 unsigned short status; 414 unsigned short status;
415 uint16_t par[6], syn[6]; 415 uint16_t par[6], syn[6];
416 uint8_t ecc[8]; 416 uint8_t ecc[8];
417 volatile unsigned short *rs_ecc; 417 volatile unsigned short *rs_ecc;
@@ -430,7 +430,7 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha
430 } 430 }
431 431
432 /* convert into 6 10bit syndrome fields */ 432 /* convert into 6 10bit syndrome fields */
433 par[5] = rs_decoder->index_of[(((uint16_t)ecc[0] >> 0) & 0x0ff) | 433 par[5] = rs_decoder->index_of[(((uint16_t)ecc[0] >> 0) & 0x0ff) |
434 (((uint16_t)ecc[1] << 8) & 0x300)]; 434 (((uint16_t)ecc[1] << 8) & 0x300)];
435 par[4] = rs_decoder->index_of[(((uint16_t)ecc[1] >> 2) & 0x03f) | 435 par[4] = rs_decoder->index_of[(((uint16_t)ecc[1] >> 2) & 0x03f) |
436 (((uint16_t)ecc[2] << 6) & 0x3c0)]; 436 (((uint16_t)ecc[2] << 6) & 0x3c0)];
@@ -456,7 +456,7 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha
456 /* Let the library code do its magic.*/ 456 /* Let the library code do its magic.*/
457 res = decode_rs8(rs_decoder, (uint8_t *)buf, par, 512, syn, 0, NULL, 0xff, NULL); 457 res = decode_rs8(rs_decoder, (uint8_t *)buf, par, 512, syn, 0, NULL, 0xff, NULL);
458 if (res > 0) { 458 if (res > 0) {
459 DEBUG (MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: " 459 DEBUG (MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: "
460 "ECC corrected %d errors on read\n", res); 460 "ECC corrected %d errors on read\n", res);
461 } 461 }
462 return res; 462 return res;
@@ -470,9 +470,9 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha
470 * @state: state or the operation 470 * @state: state or the operation
471 * @status: status code returned from read status 471 * @status: status code returned from read status
472 * @page: startpage inside the chip, must be called with (page & this->pagemask) 472 * @page: startpage inside the chip, must be called with (page & this->pagemask)
473 * 473 *
474 * Perform additional error status checks on erase and write failures 474 * Perform additional error status checks on erase and write failures
475 * to determine if errors are correctable. For this device, correctable 475 * to determine if errors are correctable. For this device, correctable
476 * 1-bit errors on erase and write are considered acceptable. 476 * 1-bit errors on erase and write are considered acceptable.
477 * 477 *
478 * note: see pages 34..37 of data sheet for details. 478 * note: see pages 34..37 of data sheet for details.
@@ -633,7 +633,7 @@ int __init rtc_from4_init (void)
633 633
634#ifdef RTC_FROM4_HWECC 634#ifdef RTC_FROM4_HWECC
635 /* We could create the decoder on demand, if memory is a concern. 635 /* We could create the decoder on demand, if memory is a concern.
636 * This way we have it handy, if an error happens 636 * This way we have it handy, if an error happens
637 * 637 *
638 * Symbolsize is 10 (bits) 638 * Symbolsize is 10 (bits)
639 * Primitve polynomial is x^10+x^3+1 639 * Primitve polynomial is x^10+x^3+1
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 2df5e47d1f5c..97e9b7892d29 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -17,8 +17,9 @@
17 * 02-May-2005 BJD Reduced hwcontrol decode 17 * 02-May-2005 BJD Reduced hwcontrol decode
18 * 20-Jun-2005 BJD Updated s3c2440 support, fixed timing bug 18 * 20-Jun-2005 BJD Updated s3c2440 support, fixed timing bug
19 * 08-Jul-2005 BJD Fix OOPS when no platform data supplied 19 * 08-Jul-2005 BJD Fix OOPS when no platform data supplied
20 * 20-Oct-2005 BJD Fix timing calculation bug
20 * 21 *
21 * $Id: s3c2410.c,v 1.14 2005/07/06 20:05:06 bjd Exp $ 22 * $Id: s3c2410.c,v 1.20 2005/11/07 11:14:31 gleixner Exp $
22 * 23 *
23 * This program is free software; you can redistribute it and/or modify 24 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by 25 * it under the terms of the GNU General Public License as published by
@@ -136,13 +137,13 @@ static struct s3c2410_platform_nand *to_nand_plat(struct device *dev)
136 137
137/* timing calculations */ 138/* timing calculations */
138 139
139#define NS_IN_KHZ 10000000 140#define NS_IN_KHZ 1000000
140 141
141static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max) 142static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
142{ 143{
143 int result; 144 int result;
144 145
145 result = (wanted * NS_IN_KHZ) / clk; 146 result = (wanted * clk) / NS_IN_KHZ;
146 result++; 147 result++;
147 148
148 pr_debug("result %d from %ld, %d\n", result, clk, wanted); 149 pr_debug("result %d from %ld, %d\n", result, clk, wanted);
@@ -159,20 +160,22 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
159 return result; 160 return result;
160} 161}
161 162
162#define to_ns(ticks,clk) (((clk) * (ticks)) / NS_IN_KHZ) 163#define to_ns(ticks,clk) (((ticks) * NS_IN_KHZ) / (unsigned int)(clk))
163 164
164/* controller setup */ 165/* controller setup */
165 166
166static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, 167static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
167 struct device *dev) 168 struct device *dev)
168{ 169{
169 struct s3c2410_platform_nand *plat = to_nand_plat(dev); 170 struct s3c2410_platform_nand *plat = to_nand_plat(dev);
170 unsigned int tacls, twrph0, twrph1;
171 unsigned long clkrate = clk_get_rate(info->clk); 171 unsigned long clkrate = clk_get_rate(info->clk);
172 int tacls, twrph0, twrph1;
172 unsigned long cfg; 173 unsigned long cfg;
173 174
174 /* calculate the timing information for the controller */ 175 /* calculate the timing information for the controller */
175 176
177 clkrate /= 1000; /* turn clock into kHz for ease of use */
178
176 if (plat != NULL) { 179 if (plat != NULL) {
177 tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4); 180 tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4);
178 twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8); 181 twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8);
@@ -183,16 +186,16 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
183 twrph0 = 8; 186 twrph0 = 8;
184 twrph1 = 8; 187 twrph1 = 8;
185 } 188 }
186 189
187 if (tacls < 0 || twrph0 < 0 || twrph1 < 0) { 190 if (tacls < 0 || twrph0 < 0 || twrph1 < 0) {
188 printk(KERN_ERR PFX "cannot get timings suitable for board\n"); 191 printk(KERN_ERR PFX "cannot get timings suitable for board\n");
189 return -EINVAL; 192 return -EINVAL;
190 } 193 }
191 194
192 printk(KERN_INFO PFX "timing: Tacls %ldns, Twrph0 %ldns, Twrph1 %ldns\n", 195 printk(KERN_INFO PFX "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n",
193 to_ns(tacls, clkrate), 196 tacls, to_ns(tacls, clkrate),
194 to_ns(twrph0, clkrate), 197 twrph0, to_ns(twrph0, clkrate),
195 to_ns(twrph1, clkrate)); 198 twrph1, to_ns(twrph1, clkrate));
196 199
197 if (!info->is_s3c2440) { 200 if (!info->is_s3c2440) {
198 cfg = S3C2410_NFCONF_EN; 201 cfg = S3C2410_NFCONF_EN;
@@ -216,7 +219,7 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
216static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip) 219static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
217{ 220{
218 struct s3c2410_nand_info *info; 221 struct s3c2410_nand_info *info;
219 struct s3c2410_nand_mtd *nmtd; 222 struct s3c2410_nand_mtd *nmtd;
220 struct nand_chip *this = mtd->priv; 223 struct nand_chip *this = mtd->priv;
221 void __iomem *reg; 224 void __iomem *reg;
222 unsigned long cur; 225 unsigned long cur;
@@ -249,7 +252,7 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
249 writel(cur, reg); 252 writel(cur, reg);
250} 253}
251 254
252/* command and control functions 255/* command and control functions
253 * 256 *
254 * Note, these all use tglx's method of changing the IO_ADDR_W field 257 * Note, these all use tglx's method of changing the IO_ADDR_W field
255 * to make the code simpler, and use the nand layer's code to issue the 258 * to make the code simpler, and use the nand layer's code to issue the
@@ -321,7 +324,7 @@ static void s3c2440_nand_hwcontrol(struct mtd_info *mtd, int cmd)
321static int s3c2410_nand_devready(struct mtd_info *mtd) 324static int s3c2410_nand_devready(struct mtd_info *mtd)
322{ 325{
323 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 326 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
324 327
325 if (info->is_s3c2440) 328 if (info->is_s3c2440)
326 return readb(info->regs + S3C2440_NFSTAT) & S3C2440_NFSTAT_READY; 329 return readb(info->regs + S3C2440_NFSTAT) & S3C2440_NFSTAT_READY;
327 return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY; 330 return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY;
@@ -342,7 +345,7 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
342 345
343 if (read_ecc[0] == calc_ecc[0] && 346 if (read_ecc[0] == calc_ecc[0] &&
344 read_ecc[1] == calc_ecc[1] && 347 read_ecc[1] == calc_ecc[1] &&
345 read_ecc[2] == calc_ecc[2]) 348 read_ecc[2] == calc_ecc[2])
346 return 0; 349 return 0;
347 350
348 /* we curently have no method for correcting the error */ 351 /* we curently have no method for correcting the error */
@@ -433,14 +436,14 @@ static int s3c2410_nand_remove(struct device *dev)
433 436
434 dev_set_drvdata(dev, NULL); 437 dev_set_drvdata(dev, NULL);
435 438
436 if (info == NULL) 439 if (info == NULL)
437 return 0; 440 return 0;
438 441
439 /* first thing we need to do is release all our mtds 442 /* first thing we need to do is release all our mtds
440 * and their partitions, then go through freeing the 443 * and their partitions, then go through freeing the
441 * resources used 444 * resources used
442 */ 445 */
443 446
444 if (info->mtds != NULL) { 447 if (info->mtds != NULL) {
445 struct s3c2410_nand_mtd *ptr = info->mtds; 448 struct s3c2410_nand_mtd *ptr = info->mtds;
446 int mtdno; 449 int mtdno;
@@ -504,7 +507,7 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
504 507
505/* s3c2410_nand_init_chip 508/* s3c2410_nand_init_chip
506 * 509 *
507 * init a single instance of an chip 510 * init a single instance of an chip
508*/ 511*/
509 512
510static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, 513static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
@@ -576,7 +579,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
576 579
577 info = kmalloc(sizeof(*info), GFP_KERNEL); 580 info = kmalloc(sizeof(*info), GFP_KERNEL);
578 if (info == NULL) { 581 if (info == NULL) {
579 printk(KERN_ERR PFX "no memory for flash info\n"); 582 dev_err(dev, "no memory for flash info\n");
580 err = -ENOMEM; 583 err = -ENOMEM;
581 goto exit_error; 584 goto exit_error;
582 } 585 }
@@ -591,7 +594,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
591 594
592 info->clk = clk_get(dev, "nand"); 595 info->clk = clk_get(dev, "nand");
593 if (IS_ERR(info->clk)) { 596 if (IS_ERR(info->clk)) {
594 printk(KERN_ERR PFX "failed to get clock"); 597 dev_err(dev, "failed to get clock");
595 err = -ENOENT; 598 err = -ENOENT;
596 goto exit_error; 599 goto exit_error;
597 } 600 }
@@ -608,7 +611,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
608 info->area = request_mem_region(res->start, size, pdev->name); 611 info->area = request_mem_region(res->start, size, pdev->name);
609 612
610 if (info->area == NULL) { 613 if (info->area == NULL) {
611 printk(KERN_ERR PFX "cannot reserve register region\n"); 614 dev_err(dev, "cannot reserve register region\n");
612 err = -ENOENT; 615 err = -ENOENT;
613 goto exit_error; 616 goto exit_error;
614 } 617 }
@@ -619,12 +622,12 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
619 info->is_s3c2440 = is_s3c2440; 622 info->is_s3c2440 = is_s3c2440;
620 623
621 if (info->regs == NULL) { 624 if (info->regs == NULL) {
622 printk(KERN_ERR PFX "cannot reserve register region\n"); 625 dev_err(dev, "cannot reserve register region\n");
623 err = -EIO; 626 err = -EIO;
624 goto exit_error; 627 goto exit_error;
625 } 628 }
626 629
627 printk(KERN_INFO PFX "mapped registers at %p\n", info->regs); 630 dev_dbg(dev, "mapped registers at %p\n", info->regs);
628 631
629 /* initialise the hardware */ 632 /* initialise the hardware */
630 633
@@ -642,7 +645,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
642 size = nr_sets * sizeof(*info->mtds); 645 size = nr_sets * sizeof(*info->mtds);
643 info->mtds = kmalloc(size, GFP_KERNEL); 646 info->mtds = kmalloc(size, GFP_KERNEL);
644 if (info->mtds == NULL) { 647 if (info->mtds == NULL) {
645 printk(KERN_ERR PFX "failed to allocate mtd storage\n"); 648 dev_err(dev, "failed to allocate mtd storage\n");
646 err = -ENOMEM; 649 err = -ENOMEM;
647 goto exit_error; 650 goto exit_error;
648 } 651 }
@@ -656,7 +659,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
656 for (setno = 0; setno < nr_sets; setno++, nmtd++) { 659 for (setno = 0; setno < nr_sets; setno++, nmtd++) {
657 pr_debug("initialising set %d (%p, info %p)\n", 660 pr_debug("initialising set %d (%p, info %p)\n",
658 setno, nmtd, info); 661 setno, nmtd, info);
659 662
660 s3c2410_nand_init_chip(info, nmtd, sets); 663 s3c2410_nand_init_chip(info, nmtd, sets);
661 664
662 nmtd->scan_res = nand_scan(&nmtd->mtd, 665 nmtd->scan_res = nand_scan(&nmtd->mtd,
@@ -669,7 +672,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
669 if (sets != NULL) 672 if (sets != NULL)
670 sets++; 673 sets++;
671 } 674 }
672 675
673 pr_debug("initialised ok\n"); 676 pr_debug("initialised ok\n");
674 return 0; 677 return 0;
675 678
@@ -695,6 +698,7 @@ static int s3c2440_nand_probe(struct device *dev)
695 698
696static struct device_driver s3c2410_nand_driver = { 699static struct device_driver s3c2410_nand_driver = {
697 .name = "s3c2410-nand", 700 .name = "s3c2410-nand",
701 .owner = THIS_MODULE,
698 .bus = &platform_bus_type, 702 .bus = &platform_bus_type,
699 .probe = s3c2410_nand_probe, 703 .probe = s3c2410_nand_probe,
700 .remove = s3c2410_nand_remove, 704 .remove = s3c2410_nand_remove,
@@ -702,6 +706,7 @@ static struct device_driver s3c2410_nand_driver = {
702 706
703static struct device_driver s3c2440_nand_driver = { 707static struct device_driver s3c2440_nand_driver = {
704 .name = "s3c2440-nand", 708 .name = "s3c2440-nand",
709 .owner = THIS_MODULE,
705 .bus = &platform_bus_type, 710 .bus = &platform_bus_type,
706 .probe = s3c2440_nand_probe, 711 .probe = s3c2440_nand_probe,
707 .remove = s3c2410_nand_remove, 712 .remove = s3c2410_nand_remove,
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 88b5b5b40b43..1924a4f137c7 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2004 Richard Purdie 4 * Copyright (C) 2004 Richard Purdie
5 * 5 *
6 * $Id: sharpsl.c,v 1.4 2005/01/23 11:09:19 rpurdie Exp $ 6 * $Id: sharpsl.c,v 1.7 2005/11/07 11:14:31 gleixner Exp $
7 * 7 *
8 * Based on Sharp's NAND driver sharp_sl.c 8 * Based on Sharp's NAND driver sharp_sl.c
9 * 9 *
@@ -76,14 +76,14 @@ static struct mtd_partition sharpsl_nand_default_partition_info[] = {
76 }, 76 },
77}; 77};
78 78
79/* 79/*
80 * hardware specific access to control-lines 80 * hardware specific access to control-lines
81 */ 81 */
82static void 82static void
83sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd) 83sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd)
84{ 84{
85 switch (cmd) { 85 switch (cmd) {
86 case NAND_CTL_SETCLE: 86 case NAND_CTL_SETCLE:
87 writeb(readb(FLASHCTL) | FLCLE, FLASHCTL); 87 writeb(readb(FLASHCTL) | FLCLE, FLASHCTL);
88 break; 88 break;
89 case NAND_CTL_CLRCLE: 89 case NAND_CTL_CLRCLE:
@@ -97,10 +97,10 @@ sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd)
97 writeb(readb(FLASHCTL) & ~FLALE, FLASHCTL); 97 writeb(readb(FLASHCTL) & ~FLALE, FLASHCTL);
98 break; 98 break;
99 99
100 case NAND_CTL_SETNCE: 100 case NAND_CTL_SETNCE:
101 writeb(readb(FLASHCTL) & ~(FLCE0|FLCE1), FLASHCTL); 101 writeb(readb(FLASHCTL) & ~(FLCE0|FLCE1), FLASHCTL);
102 break; 102 break;
103 case NAND_CTL_CLRNCE: 103 case NAND_CTL_CLRNCE:
104 writeb(readb(FLASHCTL) | (FLCE0|FLCE1), FLASHCTL); 104 writeb(readb(FLASHCTL) | (FLCE0|FLCE1), FLASHCTL);
105 break; 105 break;
106 } 106 }
@@ -115,6 +115,23 @@ static struct nand_bbt_descr sharpsl_bbt = {
115 .pattern = scan_ff_pattern 115 .pattern = scan_ff_pattern
116}; 116};
117 117
118static struct nand_bbt_descr sharpsl_akita_bbt = {
119 .options = 0,
120 .offs = 4,
121 .len = 1,
122 .pattern = scan_ff_pattern
123};
124
125static struct nand_oobinfo akita_oobinfo = {
126 .useecc = MTD_NANDECC_AUTOPLACE,
127 .eccbytes = 24,
128 .eccpos = {
129 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
130 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
131 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
132 .oobfree = { {0x08, 0x09} }
133};
134
118static int 135static int
119sharpsl_nand_dev_ready(struct mtd_info* mtd) 136sharpsl_nand_dev_ready(struct mtd_info* mtd)
120{ 137{
@@ -160,7 +177,7 @@ sharpsl_nand_init(void)
160 printk ("Unable to allocate SharpSL NAND MTD device structure.\n"); 177 printk ("Unable to allocate SharpSL NAND MTD device structure.\n");
161 return -ENOMEM; 178 return -ENOMEM;
162 } 179 }
163 180
164 /* map physical adress */ 181 /* map physical adress */
165 sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); 182 sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000);
166 if(!sharpsl_io_base){ 183 if(!sharpsl_io_base){
@@ -168,7 +185,7 @@ sharpsl_nand_init(void)
168 kfree(sharpsl_mtd); 185 kfree(sharpsl_mtd);
169 return -EIO; 186 return -EIO;
170 } 187 }
171 188
172 /* Get pointer to private data */ 189 /* Get pointer to private data */
173 this = (struct nand_chip *) (&sharpsl_mtd[1]); 190 this = (struct nand_chip *) (&sharpsl_mtd[1]);
174 191
@@ -194,10 +211,14 @@ sharpsl_nand_init(void)
194 this->chip_delay = 15; 211 this->chip_delay = 15;
195 /* set eccmode using hardware ECC */ 212 /* set eccmode using hardware ECC */
196 this->eccmode = NAND_ECC_HW3_256; 213 this->eccmode = NAND_ECC_HW3_256;
214 this->badblock_pattern = &sharpsl_bbt;
215 if (machine_is_akita() || machine_is_borzoi()) {
216 this->badblock_pattern = &sharpsl_akita_bbt;
217 this->autooob = &akita_oobinfo;
218 }
197 this->enable_hwecc = sharpsl_nand_enable_hwecc; 219 this->enable_hwecc = sharpsl_nand_enable_hwecc;
198 this->calculate_ecc = sharpsl_nand_calculate_ecc; 220 this->calculate_ecc = sharpsl_nand_calculate_ecc;
199 this->correct_data = nand_correct_data; 221 this->correct_data = nand_correct_data;
200 this->badblock_pattern = &sharpsl_bbt;
201 222
202 /* Scan to find existence of the device */ 223 /* Scan to find existence of the device */
203 err=nand_scan(sharpsl_mtd,1); 224 err=nand_scan(sharpsl_mtd,1);
@@ -211,7 +232,7 @@ sharpsl_nand_init(void)
211 sharpsl_mtd->name = "sharpsl-nand"; 232 sharpsl_mtd->name = "sharpsl-nand";
212 nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, 233 nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes,
213 &sharpsl_partition_info, 0); 234 &sharpsl_partition_info, 0);
214 235
215 if (nr_partitions <= 0) { 236 if (nr_partitions <= 0) {
216 nr_partitions = DEFAULT_NUM_PARTITIONS; 237 nr_partitions = DEFAULT_NUM_PARTITIONS;
217 sharpsl_partition_info = sharpsl_nand_default_partition_info; 238 sharpsl_partition_info = sharpsl_nand_default_partition_info;
@@ -230,7 +251,7 @@ sharpsl_nand_init(void)
230 } 251 }
231 } 252 }
232 253
233 if (machine_is_husky() || machine_is_borzoi()) { 254 if (machine_is_husky() || machine_is_borzoi() || machine_is_akita()) {
234 /* Need to use small eraseblock size for backward compatibility */ 255 /* Need to use small eraseblock size for backward compatibility */
235 sharpsl_mtd->flags |= MTD_NO_VIRTBLOCKS; 256 sharpsl_mtd->flags |= MTD_NO_VIRTBLOCKS;
236 } 257 }
diff --git a/drivers/mtd/nand/spia.c b/drivers/mtd/nand/spia.c
index b777c412b758..32541cbb0103 100644
--- a/drivers/mtd/nand/spia.c
+++ b/drivers/mtd/nand/spia.c
@@ -8,7 +8,7 @@
8 * to controllines (due to change in nand.c) 8 * to controllines (due to change in nand.c)
9 * page_cache added 9 * page_cache added
10 * 10 *
11 * $Id: spia.c,v 1.24 2004/11/04 12:53:10 gleixner Exp $ 11 * $Id: spia.c,v 1.25 2005/11/07 11:14:31 gleixner Exp $
12 * 12 *
13 * 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
14 * it under the terms of the GNU General Public License version 2 as 14 * it under the terms of the GNU General Public License version 2 as
@@ -82,7 +82,7 @@ const static struct mtd_partition partition_info[] = {
82#define NUM_PARTITIONS 2 82#define NUM_PARTITIONS 2
83 83
84 84
85/* 85/*
86 * hardware specific access to control-lines 86 * hardware specific access to control-lines
87*/ 87*/
88static void spia_hwcontrol(struct mtd_info *mtd, int cmd){ 88static void spia_hwcontrol(struct mtd_info *mtd, int cmd){
@@ -137,7 +137,7 @@ int __init spia_init (void)
137 /* Set address of hardware control function */ 137 /* Set address of hardware control function */
138 this->hwcontrol = spia_hwcontrol; 138 this->hwcontrol = spia_hwcontrol;
139 /* 15 us command delay time */ 139 /* 15 us command delay time */
140 this->chip_delay = 15; 140 this->chip_delay = 15;
141 141
142 /* Scan to find existence of the device */ 142 /* Scan to find existence of the device */
143 if (nand_scan (spia_mtd, 1)) { 143 if (nand_scan (spia_mtd, 1)) {
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c
index 52c808fb5fa9..7609c43cb3ec 100644
--- a/drivers/mtd/nand/toto.c
+++ b/drivers/mtd/nand/toto.c
@@ -15,7 +15,7 @@
15 * This is a device driver for the NAND flash device found on the 15 * This is a device driver for the NAND flash device found on the
16 * TI fido board. It supports 32MiB and 64MiB cards 16 * TI fido board. It supports 32MiB and 64MiB cards
17 * 17 *
18 * $Id: toto.c,v 1.4 2004/10/05 13:50:20 gleixner Exp $ 18 * $Id: toto.c,v 1.5 2005/11/07 11:14:31 gleixner Exp $
19 */ 19 */
20 20
21#include <linux/slab.h> 21#include <linux/slab.h>
@@ -57,7 +57,7 @@ static unsigned long toto_io_base = OMAP_FLASH_1_BASE;
57#endif 57#endif
58#define T_NAND_CTL_SETNCE(iob) gpiosetout(NAND_NCE, 0) 58#define T_NAND_CTL_SETNCE(iob) gpiosetout(NAND_NCE, 0)
59#define T_NAND_CTL_CLRNCE(iob) gpiosetout(NAND_NCE, NAND_NCE) 59#define T_NAND_CTL_CLRNCE(iob) gpiosetout(NAND_NCE, NAND_NCE)
60 60
61/* 61/*
62 * Define partitions for flash devices 62 * Define partitions for flash devices
63 */ 63 */
@@ -91,7 +91,7 @@ static struct mtd_partition partition_info32M[] = {
91 91
92#define NUM_PARTITIONS32M 3 92#define NUM_PARTITIONS32M 3
93#define NUM_PARTITIONS64M 4 93#define NUM_PARTITIONS64M 4
94/* 94/*
95 * hardware specific access to control-lines 95 * hardware specific access to control-lines
96*/ 96*/
97 97
@@ -146,7 +146,7 @@ int __init toto_init (void)
146 this->hwcontrol = toto_hwcontrol; 146 this->hwcontrol = toto_hwcontrol;
147 this->dev_ready = NULL; 147 this->dev_ready = NULL;
148 /* 25 us command delay time */ 148 /* 25 us command delay time */
149 this->chip_delay = 30; 149 this->chip_delay = 30;
150 this->eccmode = NAND_ECC_SOFT; 150 this->eccmode = NAND_ECC_SOFT;
151 151
152 /* Scan to find existance of the device */ 152 /* Scan to find existance of the device */
@@ -157,10 +157,10 @@ int __init toto_init (void)
157 157
158 /* Register the partitions */ 158 /* Register the partitions */
159 switch(toto_mtd->size){ 159 switch(toto_mtd->size){
160 case SZ_64M: add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); break; 160 case SZ_64M: add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); break;
161 case SZ_32M: add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); break; 161 case SZ_32M: add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); break;
162 default: { 162 default: {
163 printk (KERN_WARNING "Unsupported Nand device\n"); 163 printk (KERN_WARNING "Unsupported Nand device\n");
164 err = -ENXIO; 164 err = -ENXIO;
165 goto out_buf; 165 goto out_buf;
166 } 166 }
@@ -170,9 +170,9 @@ int __init toto_init (void)
170 archflashwp(0,0); /* open up flash for writing */ 170 archflashwp(0,0); /* open up flash for writing */
171 171
172 goto out; 172 goto out;
173 173
174out_buf: 174out_buf:
175 kfree (this->data_buf); 175 kfree (this->data_buf);
176out_mtd: 176out_mtd:
177 kfree (toto_mtd); 177 kfree (toto_mtd);
178out: 178out:
@@ -194,7 +194,7 @@ static void __exit toto_cleanup (void)
194 194
195 /* stop flash writes */ 195 /* stop flash writes */
196 archflashwp(0,1); 196 archflashwp(0,1);
197 197
198 /* release gpios to system */ 198 /* release gpios to system */
199 gpiorelease(NAND_MASK); 199 gpiorelease(NAND_MASK);
200} 200}
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index b2014043634f..d7cd5fa16ba4 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -1,7 +1,7 @@
1/* Linux driver for NAND Flash Translation Layer */ 1/* Linux driver for NAND Flash Translation Layer */
2/* (c) 1999 Machine Vision Holdings, Inc. */ 2/* (c) 1999 Machine Vision Holdings, Inc. */
3/* Author: David Woodhouse <dwmw2@infradead.org> */ 3/* Author: David Woodhouse <dwmw2@infradead.org> */
4/* $Id: nftlcore.c,v 1.97 2004/11/16 18:28:59 dwmw2 Exp $ */ 4/* $Id: nftlcore.c,v 1.98 2005/11/07 11:14:21 gleixner Exp $ */
5 5
6/* 6/*
7 The contents of this file are distributed under the GNU General 7 The contents of this file are distributed under the GNU General
@@ -101,23 +101,21 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
101 101
102 if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) { 102 if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) {
103 /* 103 /*
104 Oh no we don't have 104 Oh no we don't have
105 mbd.size == heads * cylinders * sectors 105 mbd.size == heads * cylinders * sectors
106 */ 106 */
107 printk(KERN_WARNING "NFTL: cannot calculate a geometry to " 107 printk(KERN_WARNING "NFTL: cannot calculate a geometry to "
108 "match size of 0x%lx.\n", nftl->mbd.size); 108 "match size of 0x%lx.\n", nftl->mbd.size);
109 printk(KERN_WARNING "NFTL: using C:%d H:%d S:%d " 109 printk(KERN_WARNING "NFTL: using C:%d H:%d S:%d "
110 "(== 0x%lx sects)\n", 110 "(== 0x%lx sects)\n",
111 nftl->cylinders, nftl->heads , nftl->sectors, 111 nftl->cylinders, nftl->heads , nftl->sectors,
112 (long)nftl->cylinders * (long)nftl->heads * 112 (long)nftl->cylinders * (long)nftl->heads *
113 (long)nftl->sectors ); 113 (long)nftl->sectors );
114 } 114 }
115 115
116 if (add_mtd_blktrans_dev(&nftl->mbd)) { 116 if (add_mtd_blktrans_dev(&nftl->mbd)) {
117 if (nftl->ReplUnitTable) 117 kfree(nftl->ReplUnitTable);
118 kfree(nftl->ReplUnitTable); 118 kfree(nftl->EUNtable);
119 if (nftl->EUNtable)
120 kfree(nftl->EUNtable);
121 kfree(nftl); 119 kfree(nftl);
122 return; 120 return;
123 } 121 }
@@ -133,10 +131,8 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)
133 DEBUG(MTD_DEBUG_LEVEL1, "NFTL: remove_dev (i=%d)\n", dev->devnum); 131 DEBUG(MTD_DEBUG_LEVEL1, "NFTL: remove_dev (i=%d)\n", dev->devnum);
134 132
135 del_mtd_blktrans_dev(dev); 133 del_mtd_blktrans_dev(dev);
136 if (nftl->ReplUnitTable) 134 kfree(nftl->ReplUnitTable);
137 kfree(nftl->ReplUnitTable); 135 kfree(nftl->EUNtable);
138 if (nftl->EUNtable)
139 kfree(nftl->EUNtable);
140 kfree(nftl); 136 kfree(nftl);
141} 137}
142 138
@@ -178,7 +174,7 @@ static u16 NFTL_findfreeblock(struct NFTLrecord *nftl, int desperate )
178 174
179 if (!silly--) { 175 if (!silly--) {
180 printk("Argh! No free blocks found! LastFreeEUN = %d, " 176 printk("Argh! No free blocks found! LastFreeEUN = %d, "
181 "FirstEUN = %d\n", nftl->LastFreeEUN, 177 "FirstEUN = %d\n", nftl->LastFreeEUN,
182 le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)); 178 le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN));
183 return 0xffff; 179 return 0xffff;
184 } 180 }
@@ -210,7 +206,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
210 "Virtual Unit Chain %d!\n", thisVUC); 206 "Virtual Unit Chain %d!\n", thisVUC);
211 return BLOCK_NIL; 207 return BLOCK_NIL;
212 } 208 }
213 209
214 /* Scan to find the Erase Unit which holds the actual data for each 210 /* Scan to find the Erase Unit which holds the actual data for each
215 512-byte block within the Chain. 211 512-byte block within the Chain.
216 */ 212 */
@@ -227,7 +223,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
227 if (block == 2) { 223 if (block == 2) {
228 foldmark = oob.u.c.FoldMark | oob.u.c.FoldMark1; 224 foldmark = oob.u.c.FoldMark | oob.u.c.FoldMark1;
229 if (foldmark == FOLD_MARK_IN_PROGRESS) { 225 if (foldmark == FOLD_MARK_IN_PROGRESS) {
230 DEBUG(MTD_DEBUG_LEVEL1, 226 DEBUG(MTD_DEBUG_LEVEL1,
231 "Write Inhibited on EUN %d\n", thisEUN); 227 "Write Inhibited on EUN %d\n", thisEUN);
232 inplace = 0; 228 inplace = 0;
233 } else { 229 } else {
@@ -249,7 +245,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
249 if (!BlockFreeFound[block]) 245 if (!BlockFreeFound[block])
250 BlockMap[block] = thisEUN; 246 BlockMap[block] = thisEUN;
251 else 247 else
252 printk(KERN_WARNING 248 printk(KERN_WARNING
253 "SECTOR_USED found after SECTOR_FREE " 249 "SECTOR_USED found after SECTOR_FREE "
254 "in Virtual Unit Chain %d for block %d\n", 250 "in Virtual Unit Chain %d for block %d\n",
255 thisVUC, block); 251 thisVUC, block);
@@ -258,7 +254,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
258 if (!BlockFreeFound[block]) 254 if (!BlockFreeFound[block])
259 BlockMap[block] = BLOCK_NIL; 255 BlockMap[block] = BLOCK_NIL;
260 else 256 else
261 printk(KERN_WARNING 257 printk(KERN_WARNING
262 "SECTOR_DELETED found after SECTOR_FREE " 258 "SECTOR_DELETED found after SECTOR_FREE "
263 "in Virtual Unit Chain %d for block %d\n", 259 "in Virtual Unit Chain %d for block %d\n",
264 thisVUC, block); 260 thisVUC, block);
@@ -277,14 +273,14 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
277 thisVUC); 273 thisVUC);
278 return BLOCK_NIL; 274 return BLOCK_NIL;
279 } 275 }
280 276
281 thisEUN = nftl->ReplUnitTable[thisEUN]; 277 thisEUN = nftl->ReplUnitTable[thisEUN];
282 } 278 }
283 279
284 if (inplace) { 280 if (inplace) {
285 /* We're being asked to be a fold-in-place. Check 281 /* We're being asked to be a fold-in-place. Check
286 that all blocks which actually have data associated 282 that all blocks which actually have data associated
287 with them (i.e. BlockMap[block] != BLOCK_NIL) are 283 with them (i.e. BlockMap[block] != BLOCK_NIL) are
288 either already present or SECTOR_FREE in the target 284 either already present or SECTOR_FREE in the target
289 block. If not, we're going to have to fold out-of-place 285 block. If not, we're going to have to fold out-of-place
290 anyway. 286 anyway.
@@ -297,7 +293,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
297 "block %d was %x lastEUN, " 293 "block %d was %x lastEUN, "
298 "and is in EUN %d (%s) %d\n", 294 "and is in EUN %d (%s) %d\n",
299 thisVUC, block, BlockLastState[block], 295 thisVUC, block, BlockLastState[block],
300 BlockMap[block], 296 BlockMap[block],
301 BlockMap[block]== targetEUN ? "==" : "!=", 297 BlockMap[block]== targetEUN ? "==" : "!=",
302 targetEUN); 298 targetEUN);
303 inplace = 0; 299 inplace = 0;
@@ -314,17 +310,17 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
314 inplace = 0; 310 inplace = 0;
315 } 311 }
316 } 312 }
317 313
318 if (!inplace) { 314 if (!inplace) {
319 DEBUG(MTD_DEBUG_LEVEL1, "Cannot fold Virtual Unit Chain %d in place. " 315 DEBUG(MTD_DEBUG_LEVEL1, "Cannot fold Virtual Unit Chain %d in place. "
320 "Trying out-of-place\n", thisVUC); 316 "Trying out-of-place\n", thisVUC);
321 /* We need to find a targetEUN to fold into. */ 317 /* We need to find a targetEUN to fold into. */
322 targetEUN = NFTL_findfreeblock(nftl, 1); 318 targetEUN = NFTL_findfreeblock(nftl, 1);
323 if (targetEUN == BLOCK_NIL) { 319 if (targetEUN == BLOCK_NIL) {
324 /* Ouch. Now we're screwed. We need to do a 320 /* Ouch. Now we're screwed. We need to do a
325 fold-in-place of another chain to make room 321 fold-in-place of another chain to make room
326 for this one. We need a better way of selecting 322 for this one. We need a better way of selecting
327 which chain to fold, because makefreeblock will 323 which chain to fold, because makefreeblock will
328 only ask us to fold the same one again. 324 only ask us to fold the same one again.
329 */ 325 */
330 printk(KERN_WARNING 326 printk(KERN_WARNING
@@ -338,7 +334,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
338 chain by selecting the longer one */ 334 chain by selecting the longer one */
339 oob.u.c.FoldMark = oob.u.c.FoldMark1 = cpu_to_le16(FOLD_MARK_IN_PROGRESS); 335 oob.u.c.FoldMark = oob.u.c.FoldMark1 = cpu_to_le16(FOLD_MARK_IN_PROGRESS);
340 oob.u.c.unused = 0xffffffff; 336 oob.u.c.unused = 0xffffffff;
341 MTD_WRITEOOB(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + 2 * 512 + 8, 337 MTD_WRITEOOB(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + 2 * 512 + 8,
342 8, &retlen, (char *)&oob.u); 338 8, &retlen, (char *)&oob.u);
343 } 339 }
344 340
@@ -361,14 +357,14 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
361 happen in case of media errors or deleted blocks) */ 357 happen in case of media errors or deleted blocks) */
362 if (BlockMap[block] == BLOCK_NIL) 358 if (BlockMap[block] == BLOCK_NIL)
363 continue; 359 continue;
364 360
365 ret = MTD_READ(nftl->mbd.mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512), 361 ret = MTD_READ(nftl->mbd.mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512),
366 512, &retlen, movebuf); 362 512, &retlen, movebuf);
367 if (ret < 0) { 363 if (ret < 0) {
368 ret = MTD_READ(nftl->mbd.mtd, (nftl->EraseSize * BlockMap[block]) 364 ret = MTD_READ(nftl->mbd.mtd, (nftl->EraseSize * BlockMap[block])
369 + (block * 512), 512, &retlen, 365 + (block * 512), 512, &retlen,
370 movebuf); 366 movebuf);
371 if (ret != -EIO) 367 if (ret != -EIO)
372 printk("Error went away on retry.\n"); 368 printk("Error went away on retry.\n");
373 } 369 }
374 memset(&oob, 0xff, sizeof(struct nftl_oob)); 370 memset(&oob, 0xff, sizeof(struct nftl_oob));
@@ -376,18 +372,18 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
376 MTD_WRITEECC(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + (block * 512), 372 MTD_WRITEECC(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + (block * 512),
377 512, &retlen, movebuf, (char *)&oob, &nftl->oobinfo); 373 512, &retlen, movebuf, (char *)&oob, &nftl->oobinfo);
378 } 374 }
379 375
380 /* add the header so that it is now a valid chain */ 376 /* add the header so that it is now a valid chain */
381 oob.u.a.VirtUnitNum = oob.u.a.SpareVirtUnitNum 377 oob.u.a.VirtUnitNum = oob.u.a.SpareVirtUnitNum
382 = cpu_to_le16(thisVUC); 378 = cpu_to_le16(thisVUC);
383 oob.u.a.ReplUnitNum = oob.u.a.SpareReplUnitNum = 0xffff; 379 oob.u.a.ReplUnitNum = oob.u.a.SpareReplUnitNum = 0xffff;
384 380
385 MTD_WRITEOOB(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + 8, 381 MTD_WRITEOOB(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + 8,
386 8, &retlen, (char *)&oob.u); 382 8, &retlen, (char *)&oob.u);
387 383
388 /* OK. We've moved the whole lot into the new block. Now we have to free the original blocks. */ 384 /* OK. We've moved the whole lot into the new block. Now we have to free the original blocks. */
389 385
390 /* At this point, we have two different chains for this Virtual Unit, and no way to tell 386 /* At this point, we have two different chains for this Virtual Unit, and no way to tell
391 them apart. If we crash now, we get confused. However, both contain the same data, so we 387 them apart. If we crash now, we get confused. However, both contain the same data, so we
392 shouldn't actually lose data in this case. It's just that when we load up on a medium which 388 shouldn't actually lose data in this case. It's just that when we load up on a medium which
393 has duplicate chains, we need to free one of the chains because it's not necessary any more. 389 has duplicate chains, we need to free one of the chains because it's not necessary any more.
@@ -395,7 +391,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
395 thisEUN = nftl->EUNtable[thisVUC]; 391 thisEUN = nftl->EUNtable[thisVUC];
396 DEBUG(MTD_DEBUG_LEVEL1,"Want to erase\n"); 392 DEBUG(MTD_DEBUG_LEVEL1,"Want to erase\n");
397 393
398 /* For each block in the old chain (except the targetEUN of course), 394 /* For each block in the old chain (except the targetEUN of course),
399 free it and make it available for future use */ 395 free it and make it available for future use */
400 while (thisEUN <= nftl->lastEUN && thisEUN != targetEUN) { 396 while (thisEUN <= nftl->lastEUN && thisEUN != targetEUN) {
401 unsigned int EUNtmp; 397 unsigned int EUNtmp;
@@ -413,7 +409,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
413 } 409 }
414 thisEUN = EUNtmp; 410 thisEUN = EUNtmp;
415 } 411 }
416 412
417 /* Make this the new start of chain for thisVUC */ 413 /* Make this the new start of chain for thisVUC */
418 nftl->ReplUnitTable[targetEUN] = BLOCK_NIL; 414 nftl->ReplUnitTable[targetEUN] = BLOCK_NIL;
419 nftl->EUNtable[thisVUC] = targetEUN; 415 nftl->EUNtable[thisVUC] = targetEUN;
@@ -423,7 +419,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
423 419
424static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock) 420static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
425{ 421{
426 /* This is the part that needs some cleverness applied. 422 /* This is the part that needs some cleverness applied.
427 For now, I'm doing the minimum applicable to actually 423 For now, I'm doing the minimum applicable to actually
428 get the thing to work. 424 get the thing to work.
429 Wear-levelling and other clever stuff needs to be implemented 425 Wear-levelling and other clever stuff needs to be implemented
@@ -470,7 +466,7 @@ static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
470 return NFTL_foldchain (nftl, LongestChain, pendingblock); 466 return NFTL_foldchain (nftl, LongestChain, pendingblock);
471} 467}
472 468
473/* NFTL_findwriteunit: Return the unit number into which we can write 469/* NFTL_findwriteunit: Return the unit number into which we can write
474 for this block. Make it available if it isn't already 470 for this block. Make it available if it isn't already
475*/ 471*/
476static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block) 472static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
@@ -488,7 +484,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
488 a free space for the block in question. 484 a free space for the block in question.
489 */ 485 */
490 486
491 /* This condition catches the 0x[7f]fff cases, as well as 487 /* This condition catches the 0x[7f]fff cases, as well as
492 being a sanity check for past-end-of-media access 488 being a sanity check for past-end-of-media access
493 */ 489 */
494 lastEUN = BLOCK_NIL; 490 lastEUN = BLOCK_NIL;
@@ -503,7 +499,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
503 499
504 MTD_READOOB(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs, 500 MTD_READOOB(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs,
505 8, &retlen, (char *)&bci); 501 8, &retlen, (char *)&bci);
506 502
507 DEBUG(MTD_DEBUG_LEVEL2, "Status of block %d in EUN %d is %x\n", 503 DEBUG(MTD_DEBUG_LEVEL2, "Status of block %d in EUN %d is %x\n",
508 block , writeEUN, le16_to_cpu(bci.Status)); 504 block , writeEUN, le16_to_cpu(bci.Status));
509 505
@@ -518,10 +514,10 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
518 break; 514 break;
519 default: 515 default:
520 // Invalid block. Don't use it any more. Must implement. 516 // Invalid block. Don't use it any more. Must implement.
521 break; 517 break;
522 } 518 }
523 519
524 if (!silly--) { 520 if (!silly--) {
525 printk(KERN_WARNING 521 printk(KERN_WARNING
526 "Infinite loop in Virtual Unit Chain 0x%x\n", 522 "Infinite loop in Virtual Unit Chain 0x%x\n",
527 thisVUC); 523 thisVUC);
@@ -532,7 +528,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
532 writeEUN = nftl->ReplUnitTable[writeEUN]; 528 writeEUN = nftl->ReplUnitTable[writeEUN];
533 } 529 }
534 530
535 /* OK. We didn't find one in the existing chain, or there 531 /* OK. We didn't find one in the existing chain, or there
536 is no existing chain. */ 532 is no existing chain. */
537 533
538 /* Try to find an already-free block */ 534 /* Try to find an already-free block */
@@ -546,12 +542,12 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
546 542
547 /* First remember the start of this chain */ 543 /* First remember the start of this chain */
548 //u16 startEUN = nftl->EUNtable[thisVUC]; 544 //u16 startEUN = nftl->EUNtable[thisVUC];
549 545
550 //printk("Write to VirtualUnitChain %d, calling makefreeblock()\n", thisVUC); 546 //printk("Write to VirtualUnitChain %d, calling makefreeblock()\n", thisVUC);
551 writeEUN = NFTL_makefreeblock(nftl, 0xffff); 547 writeEUN = NFTL_makefreeblock(nftl, 0xffff);
552 548
553 if (writeEUN == BLOCK_NIL) { 549 if (writeEUN == BLOCK_NIL) {
554 /* OK, we accept that the above comment is 550 /* OK, we accept that the above comment is
555 lying - there may have been free blocks 551 lying - there may have been free blocks
556 last time we called NFTL_findfreeblock(), 552 last time we called NFTL_findfreeblock(),
557 but they are reserved for when we're 553 but they are reserved for when we're
@@ -562,21 +558,21 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
562 } 558 }
563 if (writeEUN == BLOCK_NIL) { 559 if (writeEUN == BLOCK_NIL) {
564 /* Ouch. This should never happen - we should 560 /* Ouch. This should never happen - we should
565 always be able to make some room somehow. 561 always be able to make some room somehow.
566 If we get here, we've allocated more storage 562 If we get here, we've allocated more storage
567 space than actual media, or our makefreeblock 563 space than actual media, or our makefreeblock
568 routine is missing something. 564 routine is missing something.
569 */ 565 */
570 printk(KERN_WARNING "Cannot make free space.\n"); 566 printk(KERN_WARNING "Cannot make free space.\n");
571 return BLOCK_NIL; 567 return BLOCK_NIL;
572 } 568 }
573 //printk("Restarting scan\n"); 569 //printk("Restarting scan\n");
574 lastEUN = BLOCK_NIL; 570 lastEUN = BLOCK_NIL;
575 continue; 571 continue;
576 } 572 }
577 573
578 /* We've found a free block. Insert it into the chain. */ 574 /* We've found a free block. Insert it into the chain. */
579 575
580 if (lastEUN != BLOCK_NIL) { 576 if (lastEUN != BLOCK_NIL) {
581 thisVUC |= 0x8000; /* It's a replacement block */ 577 thisVUC |= 0x8000; /* It's a replacement block */
582 } else { 578 } else {
@@ -749,7 +745,7 @@ extern char nftlmountrev[];
749 745
750static int __init init_nftl(void) 746static int __init init_nftl(void)
751{ 747{
752 printk(KERN_INFO "NFTL driver: nftlcore.c $Revision: 1.97 $, nftlmount.c %s\n", nftlmountrev); 748 printk(KERN_INFO "NFTL driver: nftlcore.c $Revision: 1.98 $, nftlmount.c %s\n", nftlmountrev);
753 749
754 return register_mtd_blktrans(&nftl_tr); 750 return register_mtd_blktrans(&nftl_tr);
755} 751}
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index 84afd9029f53..3b104ebb219a 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * NFTL mount code with extensive checks 2 * NFTL mount code with extensive checks
3 * 3 *
4 * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 4 * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
5 * Copyright (C) 2000 Netgem S.A. 5 * Copyright (C) 2000 Netgem S.A.
6 * 6 *
7 * $Id: nftlmount.c,v 1.40 2004/11/22 14:38:29 kalev Exp $ 7 * $Id: nftlmount.c,v 1.41 2005/11/07 11:14:21 gleixner Exp $
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
@@ -31,7 +31,7 @@
31 31
32#define SECTORSIZE 512 32#define SECTORSIZE 512
33 33
34char nftlmountrev[]="$Revision: 1.40 $"; 34char nftlmountrev[]="$Revision: 1.41 $";
35 35
36/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the 36/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the
37 * various device information of the NFTL partition and Bad Unit Table. Update 37 * various device information of the NFTL partition and Bad Unit Table. Update
@@ -47,7 +47,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
47 struct NFTLMediaHeader *mh = &nftl->MediaHdr; 47 struct NFTLMediaHeader *mh = &nftl->MediaHdr;
48 unsigned int i; 48 unsigned int i;
49 49
50 /* Assume logical EraseSize == physical erasesize for starting the scan. 50 /* Assume logical EraseSize == physical erasesize for starting the scan.
51 We'll sort it out later if we find a MediaHeader which says otherwise */ 51 We'll sort it out later if we find a MediaHeader which says otherwise */
52 /* Actually, we won't. The new DiskOnChip driver has already scanned 52 /* Actually, we won't. The new DiskOnChip driver has already scanned
53 the MediaHeader and adjusted the virtual erasesize it presents in 53 the MediaHeader and adjusted the virtual erasesize it presents in
@@ -83,9 +83,9 @@ static int find_boot_record(struct NFTLrecord *nftl)
83 if (retlen < 6 || memcmp(buf, "ANAND", 6)) { 83 if (retlen < 6 || memcmp(buf, "ANAND", 6)) {
84 /* ANAND\0 not found. Continue */ 84 /* ANAND\0 not found. Continue */
85#if 0 85#if 0
86 printk(KERN_DEBUG "ANAND header not found at 0x%x in mtd%d\n", 86 printk(KERN_DEBUG "ANAND header not found at 0x%x in mtd%d\n",
87 block * nftl->EraseSize, nftl->mbd.mtd->index); 87 block * nftl->EraseSize, nftl->mbd.mtd->index);
88#endif 88#endif
89 continue; 89 continue;
90 } 90 }
91 91
@@ -103,7 +103,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
103 */ 103 */
104 if (le16_to_cpu(h1.EraseMark | h1.EraseMark1) != ERASE_MARK) { 104 if (le16_to_cpu(h1.EraseMark | h1.EraseMark1) != ERASE_MARK) {
105 printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but erase mark not present (0x%04x,0x%04x instead)\n", 105 printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but erase mark not present (0x%04x,0x%04x instead)\n",
106 block * nftl->EraseSize, nftl->mbd.mtd->index, 106 block * nftl->EraseSize, nftl->mbd.mtd->index,
107 le16_to_cpu(h1.EraseMark), le16_to_cpu(h1.EraseMark1)); 107 le16_to_cpu(h1.EraseMark), le16_to_cpu(h1.EraseMark1));
108 continue; 108 continue;
109 } 109 }
@@ -175,7 +175,7 @@ device is already correct.
175 nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN); 175 nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN);
176 if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) { 176 if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) {
177 printk(KERN_NOTICE "NFTL Media Header sanity check failed:\n"); 177 printk(KERN_NOTICE "NFTL Media Header sanity check failed:\n");
178 printk(KERN_NOTICE "nb_boot_blocks (%d) + 2 > nb_blocks (%d)\n", 178 printk(KERN_NOTICE "nb_boot_blocks (%d) + 2 > nb_blocks (%d)\n",
179 nftl->nb_boot_blocks, nftl->nb_blocks); 179 nftl->nb_boot_blocks, nftl->nb_blocks);
180 return -1; 180 return -1;
181 } 181 }
@@ -187,7 +187,7 @@ device is already correct.
187 nftl->numvunits, nftl->nb_blocks, nftl->nb_boot_blocks); 187 nftl->numvunits, nftl->nb_blocks, nftl->nb_boot_blocks);
188 return -1; 188 return -1;
189 } 189 }
190 190
191 nftl->mbd.size = nftl->numvunits * (nftl->EraseSize / SECTORSIZE); 191 nftl->mbd.size = nftl->numvunits * (nftl->EraseSize / SECTORSIZE);
192 192
193 /* If we're not using the last sectors in the device for some reason, 193 /* If we're not using the last sectors in the device for some reason,
@@ -210,12 +210,12 @@ device is already correct.
210 printk(KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n"); 210 printk(KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n");
211 return -ENOMEM; 211 return -ENOMEM;
212 } 212 }
213 213
214 /* mark the bios blocks (blocks before NFTL MediaHeader) as reserved */ 214 /* mark the bios blocks (blocks before NFTL MediaHeader) as reserved */
215 for (i = 0; i < nftl->nb_boot_blocks; i++) 215 for (i = 0; i < nftl->nb_boot_blocks; i++)
216 nftl->ReplUnitTable[i] = BLOCK_RESERVED; 216 nftl->ReplUnitTable[i] = BLOCK_RESERVED;
217 /* mark all remaining blocks as potentially containing data */ 217 /* mark all remaining blocks as potentially containing data */
218 for (; i < nftl->nb_blocks; i++) { 218 for (; i < nftl->nb_blocks; i++) {
219 nftl->ReplUnitTable[i] = BLOCK_NOTEXPLORED; 219 nftl->ReplUnitTable[i] = BLOCK_NOTEXPLORED;
220 } 220 }
221 221
@@ -245,12 +245,12 @@ The new DiskOnChip driver already scanned the bad block table. Just query it.
245 if (nftl->mbd.mtd->block_isbad(nftl->mbd.mtd, i * nftl->EraseSize)) 245 if (nftl->mbd.mtd->block_isbad(nftl->mbd.mtd, i * nftl->EraseSize))
246 nftl->ReplUnitTable[i] = BLOCK_RESERVED; 246 nftl->ReplUnitTable[i] = BLOCK_RESERVED;
247 } 247 }
248 248
249 nftl->MediaUnit = block; 249 nftl->MediaUnit = block;
250 boot_record_count++; 250 boot_record_count++;
251 251
252 } /* foreach (block) */ 252 } /* foreach (block) */
253 253
254 return boot_record_count?0:-1; 254 return boot_record_count?0:-1;
255} 255}
256 256
@@ -265,7 +265,7 @@ static int memcmpb(void *a, int c, int n)
265} 265}
266 266
267/* check_free_sector: check if a free sector is actually FREE, i.e. All 0xff in data and oob area */ 267/* check_free_sector: check if a free sector is actually FREE, i.e. All 0xff in data and oob area */
268static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int len, 268static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int len,
269 int check_oob) 269 int check_oob)
270{ 270{
271 int i; 271 int i;
@@ -293,7 +293,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int
293 * 293 *
294 * Return: 0 when succeed, -1 on error. 294 * Return: 0 when succeed, -1 on error.
295 * 295 *
296 * ToDo: 1. Is it neceressary to check_free_sector after erasing ?? 296 * ToDo: 1. Is it neceressary to check_free_sector after erasing ??
297 */ 297 */
298int NFTL_formatblock(struct NFTLrecord *nftl, int block) 298int NFTL_formatblock(struct NFTLrecord *nftl, int block)
299{ 299{
@@ -385,7 +385,7 @@ static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_b
385 /* verify that the sector is really free. If not, mark 385 /* verify that the sector is really free. If not, mark
386 as ignore */ 386 as ignore */
387 if (memcmpb(&bci, 0xff, 8) != 0 || 387 if (memcmpb(&bci, 0xff, 8) != 0 ||
388 check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE, 388 check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE,
389 SECTORSIZE, 0) != 0) { 389 SECTORSIZE, 0) != 0) {
390 printk("Incorrect free sector %d in block %d: " 390 printk("Incorrect free sector %d in block %d: "
391 "marking it as ignored\n", 391 "marking it as ignored\n",
@@ -486,7 +486,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
486 size_t retlen; 486 size_t retlen;
487 487
488 /* check erase mark. */ 488 /* check erase mark. */
489 if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, 489 if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8,
490 &retlen, (char *)&h1) < 0) 490 &retlen, (char *)&h1) < 0)
491 return -1; 491 return -1;
492 492
@@ -501,7 +501,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
501 h1.EraseMark = cpu_to_le16(ERASE_MARK); 501 h1.EraseMark = cpu_to_le16(ERASE_MARK);
502 h1.EraseMark1 = cpu_to_le16(ERASE_MARK); 502 h1.EraseMark1 = cpu_to_le16(ERASE_MARK);
503 h1.WearInfo = cpu_to_le32(0); 503 h1.WearInfo = cpu_to_le32(0);
504 if (MTD_WRITEOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, 504 if (MTD_WRITEOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8,
505 &retlen, (char *)&h1) < 0) 505 &retlen, (char *)&h1) < 0)
506 return -1; 506 return -1;
507 } else { 507 } else {
@@ -582,9 +582,9 @@ int NFTL_mount(struct NFTLrecord *s)
582 582
583 for (;;) { 583 for (;;) {
584 /* read the block header. If error, we format the chain */ 584 /* read the block header. If error, we format the chain */
585 if (MTD_READOOB(s->mbd.mtd, block * s->EraseSize + 8, 8, 585 if (MTD_READOOB(s->mbd.mtd, block * s->EraseSize + 8, 8,
586 &retlen, (char *)&h0) < 0 || 586 &retlen, (char *)&h0) < 0 ||
587 MTD_READOOB(s->mbd.mtd, block * s->EraseSize + SECTORSIZE + 8, 8, 587 MTD_READOOB(s->mbd.mtd, block * s->EraseSize + SECTORSIZE + 8, 8,
588 &retlen, (char *)&h1) < 0) { 588 &retlen, (char *)&h1) < 0) {
589 s->ReplUnitTable[block] = BLOCK_NIL; 589 s->ReplUnitTable[block] = BLOCK_NIL;
590 do_format_chain = 1; 590 do_format_chain = 1;
@@ -639,7 +639,7 @@ int NFTL_mount(struct NFTLrecord *s)
639 first_logical_block = logical_block; 639 first_logical_block = logical_block;
640 } else { 640 } else {
641 if (logical_block != first_logical_block) { 641 if (logical_block != first_logical_block) {
642 printk("Block %d: incorrect logical block: %d expected: %d\n", 642 printk("Block %d: incorrect logical block: %d expected: %d\n",
643 block, logical_block, first_logical_block); 643 block, logical_block, first_logical_block);
644 /* the chain is incorrect : we must format it, 644 /* the chain is incorrect : we must format it,
645 but we need to read it completly */ 645 but we need to read it completly */
@@ -668,7 +668,7 @@ int NFTL_mount(struct NFTLrecord *s)
668 s->ReplUnitTable[block] = BLOCK_NIL; 668 s->ReplUnitTable[block] = BLOCK_NIL;
669 break; 669 break;
670 } else if (rep_block >= s->nb_blocks) { 670 } else if (rep_block >= s->nb_blocks) {
671 printk("Block %d: referencing invalid block %d\n", 671 printk("Block %d: referencing invalid block %d\n",
672 block, rep_block); 672 block, rep_block);
673 do_format_chain = 1; 673 do_format_chain = 1;
674 s->ReplUnitTable[block] = BLOCK_NIL; 674 s->ReplUnitTable[block] = BLOCK_NIL;
@@ -688,7 +688,7 @@ int NFTL_mount(struct NFTLrecord *s)
688 s->ReplUnitTable[block] = rep_block; 688 s->ReplUnitTable[block] = rep_block;
689 s->EUNtable[first_logical_block] = BLOCK_NIL; 689 s->EUNtable[first_logical_block] = BLOCK_NIL;
690 } else { 690 } else {
691 printk("Block %d: referencing block %d already in another chain\n", 691 printk("Block %d: referencing block %d already in another chain\n",
692 block, rep_block); 692 block, rep_block);
693 /* XXX: should handle correctly fold in progress chains */ 693 /* XXX: should handle correctly fold in progress chains */
694 do_format_chain = 1; 694 do_format_chain = 1;
@@ -710,7 +710,7 @@ int NFTL_mount(struct NFTLrecord *s)
710 } else { 710 } else {
711 unsigned int first_block1, chain_to_format, chain_length1; 711 unsigned int first_block1, chain_to_format, chain_length1;
712 int fold_mark; 712 int fold_mark;
713 713
714 /* valid chain : get foldmark */ 714 /* valid chain : get foldmark */
715 fold_mark = get_fold_mark(s, first_block); 715 fold_mark = get_fold_mark(s, first_block);
716 if (fold_mark == 0) { 716 if (fold_mark == 0) {
@@ -729,9 +729,9 @@ int NFTL_mount(struct NFTLrecord *s)
729 if (first_block1 != BLOCK_NIL) { 729 if (first_block1 != BLOCK_NIL) {
730 /* XXX: what to do if same length ? */ 730 /* XXX: what to do if same length ? */
731 chain_length1 = calc_chain_length(s, first_block1); 731 chain_length1 = calc_chain_length(s, first_block1);
732 printk("Two chains at blocks %d (len=%d) and %d (len=%d)\n", 732 printk("Two chains at blocks %d (len=%d) and %d (len=%d)\n",
733 first_block1, chain_length1, first_block, chain_length); 733 first_block1, chain_length1, first_block, chain_length);
734 734
735 if (chain_length >= chain_length1) { 735 if (chain_length >= chain_length1) {
736 chain_to_format = first_block1; 736 chain_to_format = first_block1;
737 s->EUNtable[first_logical_block] = first_block; 737 s->EUNtable[first_logical_block] = first_block;
diff --git a/drivers/mtd/onenand/Kconfig b/drivers/mtd/onenand/Kconfig
new file mode 100644
index 000000000000..126ff6bf63d5
--- /dev/null
+++ b/drivers/mtd/onenand/Kconfig
@@ -0,0 +1,38 @@
1#
2# linux/drivers/mtd/onenand/Kconfig
3#
4
5menu "OneNAND Flash Device Drivers"
6 depends on MTD != n
7
8config MTD_ONENAND
9 tristate "OneNAND Device Support"
10 depends on MTD
11 help
12 This enables support for accessing all type of OneNAND flash
13 devices. For further information see
14 <http://www.samsung.com/Products/Semiconductor/Flash/OneNAND_TM/index.htm>.
15
16config MTD_ONENAND_VERIFY_WRITE
17 bool "Verify OneNAND page writes"
18 depends on MTD_ONENAND
19 help
20 This adds an extra check when data is written to the flash. The
21 OneNAND flash device internally checks only bits transitioning
22 from 1 to 0. There is a rare possibility that even though the
23 device thinks the write was successful, a bit could have been
24 flipped accidentaly due to device wear or something else.
25
26config MTD_ONENAND_GENERIC
27 tristate "OneNAND Flash device via platform device driver"
28 depends on MTD_ONENAND && ARM
29 help
30 Support for OneNAND flash via platform device driver.
31
32config MTD_ONENAND_SYNC_READ
33 bool "OneNAND Sync. Burst Read Support"
34 depends on ARCH_OMAP
35 help
36 This enables support for Sync. Burst Read.
37
38endmenu
diff --git a/drivers/mtd/onenand/Makefile b/drivers/mtd/onenand/Makefile
new file mode 100644
index 000000000000..269cfe467345
--- /dev/null
+++ b/drivers/mtd/onenand/Makefile
@@ -0,0 +1,11 @@
1#
2# Makefile for the OneNAND MTD
3#
4
5# Core functionality.
6obj-$(CONFIG_MTD_ONENAND) += onenand.o
7
8# Board specific.
9obj-$(CONFIG_MTD_ONENAND_GENERIC) += generic.o
10
11onenand-objs = onenand_base.o onenand_bbt.o
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c
new file mode 100644
index 000000000000..48cce431f89f
--- /dev/null
+++ b/drivers/mtd/onenand/generic.c
@@ -0,0 +1,147 @@
1/*
2 * linux/drivers/mtd/onenand/generic.c
3 *
4 * Copyright (c) 2005 Samsung Electronics
5 * Kyungmin Park <kyungmin.park@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Overview:
12 * This is a device driver for the OneNAND flash for generic boards.
13 */
14
15#include <linux/device.h>
16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/mtd/mtd.h>
19#include <linux/mtd/onenand.h>
20#include <linux/mtd/partitions.h>
21
22#include <asm/io.h>
23#include <asm/mach/flash.h>
24
25#define DRIVER_NAME "onenand"
26
27
28#ifdef CONFIG_MTD_PARTITIONS
29static const char *part_probes[] = { "cmdlinepart", NULL, };
30#endif
31
32struct onenand_info {
33 struct mtd_info mtd;
34 struct mtd_partition *parts;
35 struct onenand_chip onenand;
36};
37
38static int __devinit generic_onenand_probe(struct device *dev)
39{
40 struct onenand_info *info;
41 struct platform_device *pdev = to_platform_device(dev);
42 struct onenand_platform_data *pdata = pdev->dev.platform_data;
43 struct resource *res = pdev->resource;
44 unsigned long size = res->end - res->start + 1;
45 int err;
46
47 info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL);
48 if (!info)
49 return -ENOMEM;
50
51 memset(info, 0, sizeof(struct onenand_info));
52
53 if (!request_mem_region(res->start, size, dev->driver->name)) {
54 err = -EBUSY;
55 goto out_free_info;
56 }
57
58 info->onenand.base = ioremap(res->start, size);
59 if (!info->onenand.base) {
60 err = -ENOMEM;
61 goto out_release_mem_region;
62 }
63
64 info->onenand.mmcontrol = pdata->mmcontrol;
65
66 info->mtd.name = pdev->dev.bus_id;
67 info->mtd.priv = &info->onenand;
68 info->mtd.owner = THIS_MODULE;
69
70 if (onenand_scan(&info->mtd, 1)) {
71 err = -ENXIO;
72 goto out_iounmap;
73 }
74
75#ifdef CONFIG_MTD_PARTITIONS
76 err = parse_mtd_partitions(&info->mtd, part_probes, &info->parts, 0);
77 if (err > 0)
78 add_mtd_partitions(&info->mtd, info->parts, err);
79 else if (err < 0 && pdata->parts)
80 add_mtd_partitions(&info->mtd, pdata->parts, pdata->nr_parts);
81 else
82#endif
83 err = add_mtd_device(&info->mtd);
84
85 dev_set_drvdata(&pdev->dev, info);
86
87 return 0;
88
89out_iounmap:
90 iounmap(info->onenand.base);
91out_release_mem_region:
92 release_mem_region(res->start, size);
93out_free_info:
94 kfree(info);
95
96 return err;
97}
98
99static int __devexit generic_onenand_remove(struct device *dev)
100{
101 struct platform_device *pdev = to_platform_device(dev);
102 struct onenand_info *info = dev_get_drvdata(&pdev->dev);
103 struct resource *res = pdev->resource;
104 unsigned long size = res->end - res->start + 1;
105
106 dev_set_drvdata(&pdev->dev, NULL);
107
108 if (info) {
109 if (info->parts)
110 del_mtd_partitions(&info->mtd);
111 else
112 del_mtd_device(&info->mtd);
113
114 onenand_release(&info->mtd);
115 release_mem_region(res->start, size);
116 iounmap(info->onenand.base);
117 kfree(info);
118 }
119
120 return 0;
121}
122
123static struct device_driver generic_onenand_driver = {
124 .name = DRIVER_NAME,
125 .bus = &platform_bus_type,
126 .probe = generic_onenand_probe,
127 .remove = __devexit_p(generic_onenand_remove),
128};
129
130MODULE_ALIAS(DRIVER_NAME);
131
132static int __init generic_onenand_init(void)
133{
134 return driver_register(&generic_onenand_driver);
135}
136
137static void __exit generic_onenand_exit(void)
138{
139 driver_unregister(&generic_onenand_driver);
140}
141
142module_init(generic_onenand_init);
143module_exit(generic_onenand_exit);
144
145MODULE_LICENSE("GPL");
146MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>");
147MODULE_DESCRIPTION("Glue layer for OneNAND flash on generic boards");
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
new file mode 100644
index 000000000000..cc38fa0d45c6
--- /dev/null
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -0,0 +1,1588 @@
1/*
2 * linux/drivers/mtd/onenand/onenand_base.c
3 *
4 * Copyright (C) 2005 Samsung Electronics
5 * Kyungmin Park <kyungmin.park@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/mtd/mtd.h>
16#include <linux/mtd/onenand.h>
17#include <linux/mtd/partitions.h>
18
19#include <asm/io.h>
20
21/**
22 * onenand_oob_64 - oob info for large (2KB) page
23 */
24static struct nand_oobinfo onenand_oob_64 = {
25 .useecc = MTD_NANDECC_AUTOPLACE,
26 .eccbytes = 20,
27 .eccpos = {
28 8, 9, 10, 11, 12,
29 24, 25, 26, 27, 28,
30 40, 41, 42, 43, 44,
31 56, 57, 58, 59, 60,
32 },
33 .oobfree = {
34 {2, 3}, {14, 2}, {18, 3}, {30, 2},
35 {24, 3}, {46, 2}, {40, 3}, {62, 2} }
36};
37
38/**
39 * onenand_oob_32 - oob info for middle (1KB) page
40 */
41static struct nand_oobinfo onenand_oob_32 = {
42 .useecc = MTD_NANDECC_AUTOPLACE,
43 .eccbytes = 10,
44 .eccpos = {
45 8, 9, 10, 11, 12,
46 24, 25, 26, 27, 28,
47 },
48 .oobfree = { {2, 3}, {14, 2}, {18, 3}, {30, 2} }
49};
50
51static const unsigned char ffchars[] = {
52 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
53 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 16 */
54 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
55 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 32 */
56 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
57 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 48 */
58 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
59 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 64 */
60};
61
62/**
63 * onenand_readw - [OneNAND Interface] Read OneNAND register
64 * @param addr address to read
65 *
66 * Read OneNAND register
67 */
68static unsigned short onenand_readw(void __iomem *addr)
69{
70 return readw(addr);
71}
72
73/**
74 * onenand_writew - [OneNAND Interface] Write OneNAND register with value
75 * @param value value to write
76 * @param addr address to write
77 *
78 * Write OneNAND register with value
79 */
80static void onenand_writew(unsigned short value, void __iomem *addr)
81{
82 writew(value, addr);
83}
84
85/**
86 * onenand_block_address - [DEFAULT] Get block address
87 * @param this onenand chip data structure
88 * @param block the block
89 * @return translated block address if DDP, otherwise same
90 *
91 * Setup Start Address 1 Register (F100h)
92 */
93static int onenand_block_address(struct onenand_chip *this, int block)
94{
95 if (this->device_id & ONENAND_DEVICE_IS_DDP) {
96 /* Device Flash Core select, NAND Flash Block Address */
97 int dfs = 0;
98
99 if (block & this->density_mask)
100 dfs = 1;
101
102 return (dfs << ONENAND_DDP_SHIFT) |
103 (block & (this->density_mask - 1));
104 }
105
106 return block;
107}
108
109/**
110 * onenand_bufferram_address - [DEFAULT] Get bufferram address
111 * @param this onenand chip data structure
112 * @param block the block
113 * @return set DBS value if DDP, otherwise 0
114 *
115 * Setup Start Address 2 Register (F101h) for DDP
116 */
117static int onenand_bufferram_address(struct onenand_chip *this, int block)
118{
119 if (this->device_id & ONENAND_DEVICE_IS_DDP) {
120 /* Device BufferRAM Select */
121 int dbs = 0;
122
123 if (block & this->density_mask)
124 dbs = 1;
125
126 return (dbs << ONENAND_DDP_SHIFT);
127 }
128
129 return 0;
130}
131
132/**
133 * onenand_page_address - [DEFAULT] Get page address
134 * @param page the page address
135 * @param sector the sector address
136 * @return combined page and sector address
137 *
138 * Setup Start Address 8 Register (F107h)
139 */
140static int onenand_page_address(int page, int sector)
141{
142 /* Flash Page Address, Flash Sector Address */
143 int fpa, fsa;
144
145 fpa = page & ONENAND_FPA_MASK;
146 fsa = sector & ONENAND_FSA_MASK;
147
148 return ((fpa << ONENAND_FPA_SHIFT) | fsa);
149}
150
151/**
152 * onenand_buffer_address - [DEFAULT] Get buffer address
153 * @param dataram1 DataRAM index
154 * @param sectors the sector address
155 * @param count the number of sectors
156 * @return the start buffer value
157 *
158 * Setup Start Buffer Register (F200h)
159 */
160static int onenand_buffer_address(int dataram1, int sectors, int count)
161{
162 int bsa, bsc;
163
164 /* BufferRAM Sector Address */
165 bsa = sectors & ONENAND_BSA_MASK;
166
167 if (dataram1)
168 bsa |= ONENAND_BSA_DATARAM1; /* DataRAM1 */
169 else
170 bsa |= ONENAND_BSA_DATARAM0; /* DataRAM0 */
171
172 /* BufferRAM Sector Count */
173 bsc = count & ONENAND_BSC_MASK;
174
175 return ((bsa << ONENAND_BSA_SHIFT) | bsc);
176}
177
178/**
179 * onenand_command - [DEFAULT] Send command to OneNAND device
180 * @param mtd MTD device structure
181 * @param cmd the command to be sent
182 * @param addr offset to read from or write to
183 * @param len number of bytes to read or write
184 *
185 * Send command to OneNAND device. This function is used for middle/large page
186 * devices (1KB/2KB Bytes per page)
187 */
188static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t len)
189{
190 struct onenand_chip *this = mtd->priv;
191 int value, readcmd = 0;
192 int block, page;
193 /* Now we use page size operation */
194 int sectors = 4, count = 4;
195
196 /* Address translation */
197 switch (cmd) {
198 case ONENAND_CMD_UNLOCK:
199 case ONENAND_CMD_LOCK:
200 case ONENAND_CMD_LOCK_TIGHT:
201 block = -1;
202 page = -1;
203 break;
204
205 case ONENAND_CMD_ERASE:
206 case ONENAND_CMD_BUFFERRAM:
207 block = (int) (addr >> this->erase_shift);
208 page = -1;
209 break;
210
211 default:
212 block = (int) (addr >> this->erase_shift);
213 page = (int) (addr >> this->page_shift);
214 page &= this->page_mask;
215 break;
216 }
217
218 /* NOTE: The setting order of the registers is very important! */
219 if (cmd == ONENAND_CMD_BUFFERRAM) {
220 /* Select DataRAM for DDP */
221 value = onenand_bufferram_address(this, block);
222 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
223
224 /* Switch to the next data buffer */
225 ONENAND_SET_NEXT_BUFFERRAM(this);
226
227 return 0;
228 }
229
230 if (block != -1) {
231 /* Write 'DFS, FBA' of Flash */
232 value = onenand_block_address(this, block);
233 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
234 }
235
236 if (page != -1) {
237 int dataram;
238
239 switch (cmd) {
240 case ONENAND_CMD_READ:
241 case ONENAND_CMD_READOOB:
242 dataram = ONENAND_SET_NEXT_BUFFERRAM(this);
243 readcmd = 1;
244 break;
245
246 default:
247 dataram = ONENAND_CURRENT_BUFFERRAM(this);
248 break;
249 }
250
251 /* Write 'FPA, FSA' of Flash */
252 value = onenand_page_address(page, sectors);
253 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS8);
254
255 /* Write 'BSA, BSC' of DataRAM */
256 value = onenand_buffer_address(dataram, sectors, count);
257 this->write_word(value, this->base + ONENAND_REG_START_BUFFER);
258
259 if (readcmd) {
260 /* Select DataRAM for DDP */
261 value = onenand_bufferram_address(this, block);
262 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
263 }
264 }
265
266 /* Interrupt clear */
267 this->write_word(ONENAND_INT_CLEAR, this->base + ONENAND_REG_INTERRUPT);
268
269 /* Write command */
270 this->write_word(cmd, this->base + ONENAND_REG_COMMAND);
271
272 return 0;
273}
274
275/**
276 * onenand_wait - [DEFAULT] wait until the command is done
277 * @param mtd MTD device structure
278 * @param state state to select the max. timeout value
279 *
280 * Wait for command done. This applies to all OneNAND command
281 * Read can take up to 30us, erase up to 2ms and program up to 350us
282 * according to general OneNAND specs
283 */
284static int onenand_wait(struct mtd_info *mtd, int state)
285{
286 struct onenand_chip * this = mtd->priv;
287 unsigned long timeout;
288 unsigned int flags = ONENAND_INT_MASTER;
289 unsigned int interrupt = 0;
290 unsigned int ctrl, ecc;
291
292 /* The 20 msec is enough */
293 timeout = jiffies + msecs_to_jiffies(20);
294 while (time_before(jiffies, timeout)) {
295 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
296
297 if (interrupt & flags)
298 break;
299
300 if (state != FL_READING)
301 cond_resched();
302 }
303 /* To get correct interrupt status in timeout case */
304 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
305
306 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
307
308 if (ctrl & ONENAND_CTRL_ERROR) {
309 /* It maybe occur at initial bad block */
310 DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: controller error = 0x%04x\n", ctrl);
311 /* Clear other interrupt bits for preventing ECC error */
312 interrupt &= ONENAND_INT_MASTER;
313 }
314
315 if (ctrl & ONENAND_CTRL_LOCK) {
316 DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: it's locked error = 0x%04x\n", ctrl);
317 return -EACCES;
318 }
319
320 if (interrupt & ONENAND_INT_READ) {
321 ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);
322 if (ecc & ONENAND_ECC_2BIT_ALL) {
323 DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: ECC error = 0x%04x\n", ecc);
324 return -EBADMSG;
325 }
326 }
327
328 return 0;
329}
330
331/**
332 * onenand_bufferram_offset - [DEFAULT] BufferRAM offset
333 * @param mtd MTD data structure
334 * @param area BufferRAM area
335 * @return offset given area
336 *
337 * Return BufferRAM offset given area
338 */
339static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area)
340{
341 struct onenand_chip *this = mtd->priv;
342
343 if (ONENAND_CURRENT_BUFFERRAM(this)) {
344 if (area == ONENAND_DATARAM)
345 return mtd->oobblock;
346 if (area == ONENAND_SPARERAM)
347 return mtd->oobsize;
348 }
349
350 return 0;
351}
352
353/**
354 * onenand_read_bufferram - [OneNAND Interface] Read the bufferram area
355 * @param mtd MTD data structure
356 * @param area BufferRAM area
357 * @param buffer the databuffer to put/get data
358 * @param offset offset to read from or write to
359 * @param count number of bytes to read/write
360 *
361 * Read the BufferRAM area
362 */
363static int onenand_read_bufferram(struct mtd_info *mtd, int area,
364 unsigned char *buffer, int offset, size_t count)
365{
366 struct onenand_chip *this = mtd->priv;
367 void __iomem *bufferram;
368
369 bufferram = this->base + area;
370
371 bufferram += onenand_bufferram_offset(mtd, area);
372
373 memcpy(buffer, bufferram + offset, count);
374
375 return 0;
376}
377
378/**
379 * onenand_sync_read_bufferram - [OneNAND Interface] Read the bufferram area with Sync. Burst mode
380 * @param mtd MTD data structure
381 * @param area BufferRAM area
382 * @param buffer the databuffer to put/get data
383 * @param offset offset to read from or write to
384 * @param count number of bytes to read/write
385 *
386 * Read the BufferRAM area with Sync. Burst Mode
387 */
388static int onenand_sync_read_bufferram(struct mtd_info *mtd, int area,
389 unsigned char *buffer, int offset, size_t count)
390{
391 struct onenand_chip *this = mtd->priv;
392 void __iomem *bufferram;
393
394 bufferram = this->base + area;
395
396 bufferram += onenand_bufferram_offset(mtd, area);
397
398 this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ);
399
400 memcpy(buffer, bufferram + offset, count);
401
402 this->mmcontrol(mtd, 0);
403
404 return 0;
405}
406
407/**
408 * onenand_write_bufferram - [OneNAND Interface] Write the bufferram area
409 * @param mtd MTD data structure
410 * @param area BufferRAM area
411 * @param buffer the databuffer to put/get data
412 * @param offset offset to read from or write to
413 * @param count number of bytes to read/write
414 *
415 * Write the BufferRAM area
416 */
417static int onenand_write_bufferram(struct mtd_info *mtd, int area,
418 const unsigned char *buffer, int offset, size_t count)
419{
420 struct onenand_chip *this = mtd->priv;
421 void __iomem *bufferram;
422
423 bufferram = this->base + area;
424
425 bufferram += onenand_bufferram_offset(mtd, area);
426
427 memcpy(bufferram + offset, buffer, count);
428
429 return 0;
430}
431
432/**
433 * onenand_check_bufferram - [GENERIC] Check BufferRAM information
434 * @param mtd MTD data structure
435 * @param addr address to check
436 * @return 1 if there are valid data, otherwise 0
437 *
438 * Check bufferram if there is data we required
439 */
440static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr)
441{
442 struct onenand_chip *this = mtd->priv;
443 int block, page;
444 int i;
445
446 block = (int) (addr >> this->erase_shift);
447 page = (int) (addr >> this->page_shift);
448 page &= this->page_mask;
449
450 i = ONENAND_CURRENT_BUFFERRAM(this);
451
452 /* Is there valid data? */
453 if (this->bufferram[i].block == block &&
454 this->bufferram[i].page == page &&
455 this->bufferram[i].valid)
456 return 1;
457
458 return 0;
459}
460
461/**
462 * onenand_update_bufferram - [GENERIC] Update BufferRAM information
463 * @param mtd MTD data structure
464 * @param addr address to update
465 * @param valid valid flag
466 *
467 * Update BufferRAM information
468 */
469static int onenand_update_bufferram(struct mtd_info *mtd, loff_t addr,
470 int valid)
471{
472 struct onenand_chip *this = mtd->priv;
473 int block, page;
474 int i;
475
476 block = (int) (addr >> this->erase_shift);
477 page = (int) (addr >> this->page_shift);
478 page &= this->page_mask;
479
480 /* Invalidate BufferRAM */
481 for (i = 0; i < MAX_BUFFERRAM; i++) {
482 if (this->bufferram[i].block == block &&
483 this->bufferram[i].page == page)
484 this->bufferram[i].valid = 0;
485 }
486
487 /* Update BufferRAM */
488 i = ONENAND_CURRENT_BUFFERRAM(this);
489 this->bufferram[i].block = block;
490 this->bufferram[i].page = page;
491 this->bufferram[i].valid = valid;
492
493 return 0;
494}
495
496/**
497 * onenand_get_device - [GENERIC] Get chip for selected access
498 * @param mtd MTD device structure
499 * @param new_state the state which is requested
500 *
501 * Get the device and lock it for exclusive access
502 */
503static int onenand_get_device(struct mtd_info *mtd, int new_state)
504{
505 struct onenand_chip *this = mtd->priv;
506 DECLARE_WAITQUEUE(wait, current);
507
508 /*
509 * Grab the lock and see if the device is available
510 */
511 while (1) {
512 spin_lock(&this->chip_lock);
513 if (this->state == FL_READY) {
514 this->state = new_state;
515 spin_unlock(&this->chip_lock);
516 break;
517 }
518 if (new_state == FL_PM_SUSPENDED) {
519 spin_unlock(&this->chip_lock);
520 return (this->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
521 }
522 set_current_state(TASK_UNINTERRUPTIBLE);
523 add_wait_queue(&this->wq, &wait);
524 spin_unlock(&this->chip_lock);
525 schedule();
526 remove_wait_queue(&this->wq, &wait);
527 }
528
529 return 0;
530}
531
532/**
533 * onenand_release_device - [GENERIC] release chip
534 * @param mtd MTD device structure
535 *
536 * Deselect, release chip lock and wake up anyone waiting on the device
537 */
538static void onenand_release_device(struct mtd_info *mtd)
539{
540 struct onenand_chip *this = mtd->priv;
541
542 /* Release the chip */
543 spin_lock(&this->chip_lock);
544 this->state = FL_READY;
545 wake_up(&this->wq);
546 spin_unlock(&this->chip_lock);
547}
548
549/**
550 * onenand_read_ecc - [MTD Interface] Read data with ECC
551 * @param mtd MTD device structure
552 * @param from offset to read from
553 * @param len number of bytes to read
554 * @param retlen pointer to variable to store the number of read bytes
555 * @param buf the databuffer to put data
556 * @param oob_buf filesystem supplied oob data buffer
557 * @param oobsel oob selection structure
558 *
559 * OneNAND read with ECC
560 */
561static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
562 size_t *retlen, u_char *buf,
563 u_char *oob_buf, struct nand_oobinfo *oobsel)
564{
565 struct onenand_chip *this = mtd->priv;
566 int read = 0, column;
567 int thislen;
568 int ret = 0;
569
570 DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
571
572 /* Do not allow reads past end of device */
573 if ((from + len) > mtd->size) {
574 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_ecc: Attempt read beyond end of device\n");
575 *retlen = 0;
576 return -EINVAL;
577 }
578
579 /* Grab the lock and see if the device is available */
580 onenand_get_device(mtd, FL_READING);
581
582 /* TODO handling oob */
583
584 while (read < len) {
585 thislen = min_t(int, mtd->oobblock, len - read);
586
587 column = from & (mtd->oobblock - 1);
588 if (column + thislen > mtd->oobblock)
589 thislen = mtd->oobblock - column;
590
591 if (!onenand_check_bufferram(mtd, from)) {
592 this->command(mtd, ONENAND_CMD_READ, from, mtd->oobblock);
593
594 ret = this->wait(mtd, FL_READING);
595 /* First copy data and check return value for ECC handling */
596 onenand_update_bufferram(mtd, from, 1);
597 }
598
599 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
600
601 read += thislen;
602
603 if (read == len)
604 break;
605
606 if (ret) {
607 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_ecc: read failed = %d\n", ret);
608 goto out;
609 }
610
611 from += thislen;
612 buf += thislen;
613 }
614
615out:
616 /* Deselect and wake up anyone waiting on the device */
617 onenand_release_device(mtd);
618
619 /*
620 * Return success, if no ECC failures, else -EBADMSG
621 * fs driver will take care of that, because
622 * retlen == desired len and result == -EBADMSG
623 */
624 *retlen = read;
625 return ret;
626}
627
628/**
629 * onenand_read - [MTD Interface] MTD compability function for onenand_read_ecc
630 * @param mtd MTD device structure
631 * @param from offset to read from
632 * @param len number of bytes to read
633 * @param retlen pointer to variable to store the number of read bytes
634 * @param buf the databuffer to put data
635 *
636 * This function simply calls onenand_read_ecc with oob buffer and oobsel = NULL
637*/
638static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
639 size_t *retlen, u_char *buf)
640{
641 return onenand_read_ecc(mtd, from, len, retlen, buf, NULL, NULL);
642}
643
644/**
645 * onenand_read_oob - [MTD Interface] OneNAND read out-of-band
646 * @param mtd MTD device structure
647 * @param from offset to read from
648 * @param len number of bytes to read
649 * @param retlen pointer to variable to store the number of read bytes
650 * @param buf the databuffer to put data
651 *
652 * OneNAND read out-of-band data from the spare area
653 */
654static int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
655 size_t *retlen, u_char *buf)
656{
657 struct onenand_chip *this = mtd->priv;
658 int read = 0, thislen, column;
659 int ret = 0;
660
661 DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
662
663 /* Initialize return length value */
664 *retlen = 0;
665
666 /* Do not allow reads past end of device */
667 if (unlikely((from + len) > mtd->size)) {
668 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_oob: Attempt read beyond end of device\n");
669 return -EINVAL;
670 }
671
672 /* Grab the lock and see if the device is available */
673 onenand_get_device(mtd, FL_READING);
674
675 column = from & (mtd->oobsize - 1);
676
677 while (read < len) {
678 thislen = mtd->oobsize - column;
679 thislen = min_t(int, thislen, len);
680
681 this->command(mtd, ONENAND_CMD_READOOB, from, mtd->oobsize);
682
683 onenand_update_bufferram(mtd, from, 0);
684
685 ret = this->wait(mtd, FL_READING);
686 /* First copy data and check return value for ECC handling */
687
688 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);
689
690 read += thislen;
691
692 if (read == len)
693 break;
694
695 if (ret) {
696 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_oob: read failed = %d\n", ret);
697 goto out;
698 }
699
700 buf += thislen;
701
702 /* Read more? */
703 if (read < len) {
704 /* Page size */
705 from += mtd->oobblock;
706 column = 0;
707 }
708 }
709
710out:
711 /* Deselect and wake up anyone waiting on the device */
712 onenand_release_device(mtd);
713
714 *retlen = read;
715 return ret;
716}
717
718#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
719/**
720 * onenand_verify_page - [GENERIC] verify the chip contents after a write
721 * @param mtd MTD device structure
722 * @param buf the databuffer to verify
723 *
724 * Check DataRAM area directly
725 */
726static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
727{
728 struct onenand_chip *this = mtd->priv;
729 void __iomem *dataram0, *dataram1;
730 int ret = 0;
731
732 this->command(mtd, ONENAND_CMD_READ, addr, mtd->oobblock);
733
734 ret = this->wait(mtd, FL_READING);
735 if (ret)
736 return ret;
737
738 onenand_update_bufferram(mtd, addr, 1);
739
740 /* Check, if the two dataram areas are same */
741 dataram0 = this->base + ONENAND_DATARAM;
742 dataram1 = dataram0 + mtd->oobblock;
743
744 if (memcmp(dataram0, dataram1, mtd->oobblock))
745 return -EBADMSG;
746
747 return 0;
748}
749#else
750#define onenand_verify_page(...) (0)
751#endif
752
753#define NOTALIGNED(x) ((x & (mtd->oobblock - 1)) != 0)
754
755/**
756 * onenand_write_ecc - [MTD Interface] OneNAND write with ECC
757 * @param mtd MTD device structure
758 * @param to offset to write to
759 * @param len number of bytes to write
760 * @param retlen pointer to variable to store the number of written bytes
761 * @param buf the data to write
762 * @param eccbuf filesystem supplied oob data buffer
763 * @param oobsel oob selection structure
764 *
765 * OneNAND write with ECC
766 */
767static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
768 size_t *retlen, const u_char *buf,
769 u_char *eccbuf, struct nand_oobinfo *oobsel)
770{
771 struct onenand_chip *this = mtd->priv;
772 int written = 0;
773 int ret = 0;
774
775 DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
776
777 /* Initialize retlen, in case of early exit */
778 *retlen = 0;
779
780 /* Do not allow writes past end of device */
781 if (unlikely((to + len) > mtd->size)) {
782 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: Attempt write to past end of device\n");
783 return -EINVAL;
784 }
785
786 /* Reject writes, which are not page aligned */
787 if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(len))) {
788 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: Attempt to write not page aligned data\n");
789 return -EINVAL;
790 }
791
792 /* Grab the lock and see if the device is available */
793 onenand_get_device(mtd, FL_WRITING);
794
795 /* Loop until all data write */
796 while (written < len) {
797 int thislen = min_t(int, mtd->oobblock, len - written);
798
799 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock);
800
801 this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen);
802 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
803
804 this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock);
805
806 onenand_update_bufferram(mtd, to, 1);
807
808 ret = this->wait(mtd, FL_WRITING);
809 if (ret) {
810 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: write filaed %d\n", ret);
811 goto out;
812 }
813
814 written += thislen;
815
816 /* Only check verify write turn on */
817 ret = onenand_verify_page(mtd, (u_char *) buf, to);
818 if (ret) {
819 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: verify failed %d\n", ret);
820 goto out;
821 }
822
823 if (written == len)
824 break;
825
826 to += thislen;
827 buf += thislen;
828 }
829
830out:
831 /* Deselect and wake up anyone waiting on the device */
832 onenand_release_device(mtd);
833
834 *retlen = written;
835
836 return ret;
837}
838
839/**
840 * onenand_write - [MTD Interface] compability function for onenand_write_ecc
841 * @param mtd MTD device structure
842 * @param to offset to write to
843 * @param len number of bytes to write
844 * @param retlen pointer to variable to store the number of written bytes
845 * @param buf the data to write
846 *
847 * This function simply calls onenand_write_ecc
848 * with oob buffer and oobsel = NULL
849 */
850static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
851 size_t *retlen, const u_char *buf)
852{
853 return onenand_write_ecc(mtd, to, len, retlen, buf, NULL, NULL);
854}
855
856/**
857 * onenand_write_oob - [MTD Interface] OneNAND write out-of-band
858 * @param mtd MTD device structure
859 * @param to offset to write to
860 * @param len number of bytes to write
861 * @param retlen pointer to variable to store the number of written bytes
862 * @param buf the data to write
863 *
864 * OneNAND write out-of-band
865 */
866static int onenand_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
867 size_t *retlen, const u_char *buf)
868{
869 struct onenand_chip *this = mtd->priv;
870 int column, status;
871 int written = 0;
872
873 DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
874
875 /* Initialize retlen, in case of early exit */
876 *retlen = 0;
877
878 /* Do not allow writes past end of device */
879 if (unlikely((to + len) > mtd->size)) {
880 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_oob: Attempt write to past end of device\n");
881 return -EINVAL;
882 }
883
884 /* Grab the lock and see if the device is available */
885 onenand_get_device(mtd, FL_WRITING);
886
887 /* Loop until all data write */
888 while (written < len) {
889 int thislen = min_t(int, mtd->oobsize, len - written);
890
891 column = to & (mtd->oobsize - 1);
892
893 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobsize);
894
895 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
896 this->write_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);
897
898 this->command(mtd, ONENAND_CMD_PROGOOB, to, mtd->oobsize);
899
900 onenand_update_bufferram(mtd, to, 0);
901
902 status = this->wait(mtd, FL_WRITING);
903 if (status)
904 goto out;
905
906 written += thislen;
907
908 if (written == len)
909 break;
910
911 to += thislen;
912 buf += thislen;
913 }
914
915out:
916 /* Deselect and wake up anyone waiting on the device */
917 onenand_release_device(mtd);
918
919 *retlen = written;
920
921 return 0;
922}
923
924/**
925 * onenand_writev_ecc - [MTD Interface] write with iovec with ecc
926 * @param mtd MTD device structure
927 * @param vecs the iovectors to write
928 * @param count number of vectors
929 * @param to offset to write to
930 * @param retlen pointer to variable to store the number of written bytes
931 * @param eccbuf filesystem supplied oob data buffer
932 * @param oobsel oob selection structure
933 *
934 * OneNAND write with iovec with ecc
935 */
936static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
937 unsigned long count, loff_t to, size_t *retlen,
938 u_char *eccbuf, struct nand_oobinfo *oobsel)
939{
940 struct onenand_chip *this = mtd->priv;
941 unsigned char buffer[MAX_ONENAND_PAGESIZE], *pbuf;
942 size_t total_len, len;
943 int i, written = 0;
944 int ret = 0;
945
946 /* Preset written len for early exit */
947 *retlen = 0;
948
949 /* Calculate total length of data */
950 total_len = 0;
951 for (i = 0; i < count; i++)
952 total_len += vecs[i].iov_len;
953
954 DEBUG(MTD_DEBUG_LEVEL3, "onenand_writev_ecc: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);
955
956 /* Do not allow write past end of the device */
957 if (unlikely((to + total_len) > mtd->size)) {
958 DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: Attempted write past end of device\n");
959 return -EINVAL;
960 }
961
962 /* Reject writes, which are not page aligned */
963 if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(total_len))) {
964 DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: Attempt to write not page aligned data\n");
965 return -EINVAL;
966 }
967
968 /* Grab the lock and see if the device is available */
969 onenand_get_device(mtd, FL_WRITING);
970
971 /* TODO handling oob */
972
973 /* Loop until all keve's data has been written */
974 len = 0;
975 while (count) {
976 pbuf = buffer;
977 /*
978 * If the given tuple is >= pagesize then
979 * write it out from the iov
980 */
981 if ((vecs->iov_len - len) >= mtd->oobblock) {
982 pbuf = vecs->iov_base + len;
983
984 len += mtd->oobblock;
985
986 /* Check, if we have to switch to the next tuple */
987 if (len >= (int) vecs->iov_len) {
988 vecs++;
989 len = 0;
990 count--;
991 }
992 } else {
993 int cnt = 0, thislen;
994 while (cnt < mtd->oobblock) {
995 thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len);
996 memcpy(buffer + cnt, vecs->iov_base + len, thislen);
997 cnt += thislen;
998 len += thislen;
999
1000 /* Check, if we have to switch to the next tuple */
1001 if (len >= (int) vecs->iov_len) {
1002 vecs++;
1003 len = 0;
1004 count--;
1005 }
1006 }
1007 }
1008
1009 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock);
1010
1011 this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->oobblock);
1012 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
1013
1014 this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock);
1015
1016 onenand_update_bufferram(mtd, to, 1);
1017
1018 ret = this->wait(mtd, FL_WRITING);
1019 if (ret) {
1020 DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: write failed %d\n", ret);
1021 goto out;
1022 }
1023
1024
1025 /* Only check verify write turn on */
1026 ret = onenand_verify_page(mtd, (u_char *) pbuf, to);
1027 if (ret) {
1028 DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: verify failed %d\n", ret);
1029 goto out;
1030 }
1031
1032 written += mtd->oobblock;
1033
1034 to += mtd->oobblock;
1035 }
1036
1037out:
1038 /* Deselect and wakt up anyone waiting on the device */
1039 onenand_release_device(mtd);
1040
1041 *retlen = written;
1042
1043 return 0;
1044}
1045
1046/**
1047 * onenand_writev - [MTD Interface] compabilty function for onenand_writev_ecc
1048 * @param mtd MTD device structure
1049 * @param vecs the iovectors to write
1050 * @param count number of vectors
1051 * @param to offset to write to
1052 * @param retlen pointer to variable to store the number of written bytes
1053 *
1054 * OneNAND write with kvec. This just calls the ecc function
1055 */
1056static int onenand_writev(struct mtd_info *mtd, const struct kvec *vecs,
1057 unsigned long count, loff_t to, size_t *retlen)
1058{
1059 return onenand_writev_ecc(mtd, vecs, count, to, retlen, NULL, NULL);
1060}
1061
1062/**
1063 * onenand_block_checkbad - [GENERIC] Check if a block is marked bad
1064 * @param mtd MTD device structure
1065 * @param ofs offset from device start
1066 * @param getchip 0, if the chip is already selected
1067 * @param allowbbt 1, if its allowed to access the bbt area
1068 *
1069 * Check, if the block is bad. Either by reading the bad block table or
1070 * calling of the scan function.
1071 */
1072static int onenand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt)
1073{
1074 struct onenand_chip *this = mtd->priv;
1075 struct bbm_info *bbm = this->bbm;
1076
1077 /* Return info from the table */
1078 return bbm->isbad_bbt(mtd, ofs, allowbbt);
1079}
1080
1081/**
1082 * onenand_erase - [MTD Interface] erase block(s)
1083 * @param mtd MTD device structure
1084 * @param instr erase instruction
1085 *
1086 * Erase one ore more blocks
1087 */
1088static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
1089{
1090 struct onenand_chip *this = mtd->priv;
1091 unsigned int block_size;
1092 loff_t addr;
1093 int len;
1094 int ret = 0;
1095
1096 DEBUG(MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);
1097
1098 block_size = (1 << this->erase_shift);
1099
1100 /* Start address must align on block boundary */
1101 if (unlikely(instr->addr & (block_size - 1))) {
1102 DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Unaligned address\n");
1103 return -EINVAL;
1104 }
1105
1106 /* Length must align on block boundary */
1107 if (unlikely(instr->len & (block_size - 1))) {
1108 DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Length not block aligned\n");
1109 return -EINVAL;
1110 }
1111
1112 /* Do not allow erase past end of device */
1113 if (unlikely((instr->len + instr->addr) > mtd->size)) {
1114 DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Erase past end of device\n");
1115 return -EINVAL;
1116 }
1117
1118 instr->fail_addr = 0xffffffff;
1119
1120 /* Grab the lock and see if the device is available */
1121 onenand_get_device(mtd, FL_ERASING);
1122
1123 /* Loop throught the pages */
1124 len = instr->len;
1125 addr = instr->addr;
1126
1127 instr->state = MTD_ERASING;
1128
1129 while (len) {
1130
1131 /* Check if we have a bad block, we do not erase bad blocks */
1132 if (onenand_block_checkbad(mtd, addr, 0, 0)) {
1133 printk (KERN_WARNING "onenand_erase: attempt to erase a bad block at addr 0x%08x\n", (unsigned int) addr);
1134 instr->state = MTD_ERASE_FAILED;
1135 goto erase_exit;
1136 }
1137
1138 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
1139
1140 ret = this->wait(mtd, FL_ERASING);
1141 /* Check, if it is write protected */
1142 if (ret) {
1143 if (ret == -EPERM)
1144 DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Device is write protected!!!\n");
1145 else
1146 DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Failed erase, block %d\n", (unsigned) (addr >> this->erase_shift));
1147 instr->state = MTD_ERASE_FAILED;
1148 instr->fail_addr = addr;
1149 goto erase_exit;
1150 }
1151
1152 len -= block_size;
1153 addr += block_size;
1154 }
1155
1156 instr->state = MTD_ERASE_DONE;
1157
1158erase_exit:
1159
1160 ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
1161 /* Do call back function */
1162 if (!ret)
1163 mtd_erase_callback(instr);
1164
1165 /* Deselect and wake up anyone waiting on the device */
1166 onenand_release_device(mtd);
1167
1168 return ret;
1169}
1170
1171/**
1172 * onenand_sync - [MTD Interface] sync
1173 * @param mtd MTD device structure
1174 *
1175 * Sync is actually a wait for chip ready function
1176 */
1177static void onenand_sync(struct mtd_info *mtd)
1178{
1179 DEBUG(MTD_DEBUG_LEVEL3, "onenand_sync: called\n");
1180
1181 /* Grab the lock and see if the device is available */
1182 onenand_get_device(mtd, FL_SYNCING);
1183
1184 /* Release it and go back */
1185 onenand_release_device(mtd);
1186}
1187
1188
1189/**
1190 * onenand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad
1191 * @param mtd MTD device structure
1192 * @param ofs offset relative to mtd start
1193 *
1194 * Check whether the block is bad
1195 */
1196static int onenand_block_isbad(struct mtd_info *mtd, loff_t ofs)
1197{
1198 /* Check for invalid offset */
1199 if (ofs > mtd->size)
1200 return -EINVAL;
1201
1202 return onenand_block_checkbad(mtd, ofs, 1, 0);
1203}
1204
1205/**
1206 * onenand_default_block_markbad - [DEFAULT] mark a block bad
1207 * @param mtd MTD device structure
1208 * @param ofs offset from device start
1209 *
1210 * This is the default implementation, which can be overridden by
1211 * a hardware specific driver.
1212 */
1213static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
1214{
1215 struct onenand_chip *this = mtd->priv;
1216 struct bbm_info *bbm = this->bbm;
1217 u_char buf[2] = {0, 0};
1218 size_t retlen;
1219 int block;
1220
1221 /* Get block number */
1222 block = ((int) ofs) >> bbm->bbt_erase_shift;
1223 if (bbm->bbt)
1224 bbm->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1);
1225
1226 /* We write two bytes, so we dont have to mess with 16 bit access */
1227 ofs += mtd->oobsize + (bbm->badblockpos & ~0x01);
1228 return mtd->write_oob(mtd, ofs , 2, &retlen, buf);
1229}
1230
1231/**
1232 * onenand_block_markbad - [MTD Interface] Mark the block at the given offset as bad
1233 * @param mtd MTD device structure
1234 * @param ofs offset relative to mtd start
1235 *
1236 * Mark the block as bad
1237 */
1238static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs)
1239{
1240 struct onenand_chip *this = mtd->priv;
1241 int ret;
1242
1243 ret = onenand_block_isbad(mtd, ofs);
1244 if (ret) {
1245 /* If it was bad already, return success and do nothing */
1246 if (ret > 0)
1247 return 0;
1248 return ret;
1249 }
1250
1251 return this->block_markbad(mtd, ofs);
1252}
1253
1254/**
1255 * onenand_unlock - [MTD Interface] Unlock block(s)
1256 * @param mtd MTD device structure
1257 * @param ofs offset relative to mtd start
1258 * @param len number of bytes to unlock
1259 *
1260 * Unlock one or more blocks
1261 */
1262static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1263{
1264 struct onenand_chip *this = mtd->priv;
1265 int start, end, block, value, status;
1266
1267 start = ofs >> this->erase_shift;
1268 end = len >> this->erase_shift;
1269
1270 /* Continuous lock scheme */
1271 if (this->options & ONENAND_CONT_LOCK) {
1272 /* Set start block address */
1273 this->write_word(start, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
1274 /* Set end block address */
1275 this->write_word(end - 1, this->base + ONENAND_REG_END_BLOCK_ADDRESS);
1276 /* Write unlock command */
1277 this->command(mtd, ONENAND_CMD_UNLOCK, 0, 0);
1278
1279 /* There's no return value */
1280 this->wait(mtd, FL_UNLOCKING);
1281
1282 /* Sanity check */
1283 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
1284 & ONENAND_CTRL_ONGO)
1285 continue;
1286
1287 /* Check lock status */
1288 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
1289 if (!(status & ONENAND_WP_US))
1290 printk(KERN_ERR "wp status = 0x%x\n", status);
1291
1292 return 0;
1293 }
1294
1295 /* Block lock scheme */
1296 for (block = start; block < end; block++) {
1297 /* Set start block address */
1298 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
1299 /* Write unlock command */
1300 this->command(mtd, ONENAND_CMD_UNLOCK, 0, 0);
1301
1302 /* There's no return value */
1303 this->wait(mtd, FL_UNLOCKING);
1304
1305 /* Sanity check */
1306 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
1307 & ONENAND_CTRL_ONGO)
1308 continue;
1309
1310 /* Set block address for read block status */
1311 value = onenand_block_address(this, block);
1312 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
1313
1314 /* Check lock status */
1315 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
1316 if (!(status & ONENAND_WP_US))
1317 printk(KERN_ERR "block = %d, wp status = 0x%x\n", block, status);
1318 }
1319
1320 return 0;
1321}
1322
1323/**
1324 * onenand_print_device_info - Print device ID
1325 * @param device device ID
1326 *
1327 * Print device ID
1328 */
1329static void onenand_print_device_info(int device)
1330{
1331 int vcc, demuxed, ddp, density;
1332
1333 vcc = device & ONENAND_DEVICE_VCC_MASK;
1334 demuxed = device & ONENAND_DEVICE_IS_DEMUX;
1335 ddp = device & ONENAND_DEVICE_IS_DDP;
1336 density = device >> ONENAND_DEVICE_DENSITY_SHIFT;
1337 printk(KERN_INFO "%sOneNAND%s %dMB %sV 16-bit (0x%02x)\n",
1338 demuxed ? "" : "Muxed ",
1339 ddp ? "(DDP)" : "",
1340 (16 << density),
1341 vcc ? "2.65/3.3" : "1.8",
1342 device);
1343}
1344
1345static const struct onenand_manufacturers onenand_manuf_ids[] = {
1346 {ONENAND_MFR_SAMSUNG, "Samsung"},
1347 {ONENAND_MFR_UNKNOWN, "Unknown"}
1348};
1349
1350/**
1351 * onenand_check_maf - Check manufacturer ID
1352 * @param manuf manufacturer ID
1353 *
1354 * Check manufacturer ID
1355 */
1356static int onenand_check_maf(int manuf)
1357{
1358 int i;
1359
1360 for (i = 0; onenand_manuf_ids[i].id; i++) {
1361 if (manuf == onenand_manuf_ids[i].id)
1362 break;
1363 }
1364
1365 printk(KERN_DEBUG "OneNAND Manufacturer: %s (0x%0x)\n",
1366 onenand_manuf_ids[i].name, manuf);
1367
1368 return (i != ONENAND_MFR_UNKNOWN);
1369}
1370
1371/**
1372 * onenand_probe - [OneNAND Interface] Probe the OneNAND device
1373 * @param mtd MTD device structure
1374 *
1375 * OneNAND detection method:
1376 * Compare the the values from command with ones from register
1377 */
1378static int onenand_probe(struct mtd_info *mtd)
1379{
1380 struct onenand_chip *this = mtd->priv;
1381 int bram_maf_id, bram_dev_id, maf_id, dev_id;
1382 int version_id;
1383 int density;
1384
1385 /* Send the command for reading device ID from BootRAM */
1386 this->write_word(ONENAND_CMD_READID, this->base + ONENAND_BOOTRAM);
1387
1388 /* Read manufacturer and device IDs from BootRAM */
1389 bram_maf_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x0);
1390 bram_dev_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x2);
1391
1392 /* Check manufacturer ID */
1393 if (onenand_check_maf(bram_maf_id))
1394 return -ENXIO;
1395
1396 /* Reset OneNAND to read default register values */
1397 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
1398
1399 /* Read manufacturer and device IDs from Register */
1400 maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);
1401 dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
1402
1403 /* Check OneNAND device */
1404 if (maf_id != bram_maf_id || dev_id != bram_dev_id)
1405 return -ENXIO;
1406
1407 /* Flash device information */
1408 onenand_print_device_info(dev_id);
1409 this->device_id = dev_id;
1410
1411 density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT;
1412 this->chipsize = (16 << density) << 20;
1413 /* Set density mask. it is used for DDP */
1414 this->density_mask = (1 << (density + 6));
1415
1416 /* OneNAND page size & block size */
1417 /* The data buffer size is equal to page size */
1418 mtd->oobblock = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
1419 mtd->oobsize = mtd->oobblock >> 5;
1420 /* Pagers per block is always 64 in OneNAND */
1421 mtd->erasesize = mtd->oobblock << 6;
1422
1423 this->erase_shift = ffs(mtd->erasesize) - 1;
1424 this->page_shift = ffs(mtd->oobblock) - 1;
1425 this->ppb_shift = (this->erase_shift - this->page_shift);
1426 this->page_mask = (mtd->erasesize / mtd->oobblock) - 1;
1427
1428 /* REVIST: Multichip handling */
1429
1430 mtd->size = this->chipsize;
1431
1432 /* Version ID */
1433 version_id = this->read_word(this->base + ONENAND_REG_VERSION_ID);
1434 printk(KERN_DEBUG "OneNAND version = 0x%04x\n", version_id);
1435
1436 /* Lock scheme */
1437 if (density <= ONENAND_DEVICE_DENSITY_512Mb &&
1438 !(version_id >> ONENAND_VERSION_PROCESS_SHIFT)) {
1439 printk(KERN_INFO "Lock scheme is Continues Lock\n");
1440 this->options |= ONENAND_CONT_LOCK;
1441 }
1442
1443 return 0;
1444}
1445
1446/**
1447 * onenand_suspend - [MTD Interface] Suspend the OneNAND flash
1448 * @param mtd MTD device structure
1449 */
1450static int onenand_suspend(struct mtd_info *mtd)
1451{
1452 return onenand_get_device(mtd, FL_PM_SUSPENDED);
1453}
1454
1455/**
1456 * onenand_resume - [MTD Interface] Resume the OneNAND flash
1457 * @param mtd MTD device structure
1458 */
1459static void onenand_resume(struct mtd_info *mtd)
1460{
1461 struct onenand_chip *this = mtd->priv;
1462
1463 if (this->state == FL_PM_SUSPENDED)
1464 onenand_release_device(mtd);
1465 else
1466 printk(KERN_ERR "resume() called for the chip which is not"
1467 "in suspended state\n");
1468}
1469
1470
1471/**
1472 * onenand_scan - [OneNAND Interface] Scan for the OneNAND device
1473 * @param mtd MTD device structure
1474 * @param maxchips Number of chips to scan for
1475 *
1476 * This fills out all the not initialized function pointers
1477 * with the defaults.
1478 * The flash ID is read and the mtd/chip structures are
1479 * filled with the appropriate values.
1480 */
1481int onenand_scan(struct mtd_info *mtd, int maxchips)
1482{
1483 struct onenand_chip *this = mtd->priv;
1484
1485 if (!this->read_word)
1486 this->read_word = onenand_readw;
1487 if (!this->write_word)
1488 this->write_word = onenand_writew;
1489
1490 if (!this->command)
1491 this->command = onenand_command;
1492 if (!this->wait)
1493 this->wait = onenand_wait;
1494
1495 if (!this->read_bufferram)
1496 this->read_bufferram = onenand_read_bufferram;
1497 if (!this->write_bufferram)
1498 this->write_bufferram = onenand_write_bufferram;
1499
1500 if (!this->block_markbad)
1501 this->block_markbad = onenand_default_block_markbad;
1502 if (!this->scan_bbt)
1503 this->scan_bbt = onenand_default_bbt;
1504
1505 if (onenand_probe(mtd))
1506 return -ENXIO;
1507
1508 /* Set Sync. Burst Read after probing */
1509 if (this->mmcontrol) {
1510 printk(KERN_INFO "OneNAND Sync. Burst Read support\n");
1511 this->read_bufferram = onenand_sync_read_bufferram;
1512 }
1513
1514 this->state = FL_READY;
1515 init_waitqueue_head(&this->wq);
1516 spin_lock_init(&this->chip_lock);
1517
1518 switch (mtd->oobsize) {
1519 case 64:
1520 this->autooob = &onenand_oob_64;
1521 break;
1522
1523 case 32:
1524 this->autooob = &onenand_oob_32;
1525 break;
1526
1527 default:
1528 printk(KERN_WARNING "No OOB scheme defined for oobsize %d\n",
1529 mtd->oobsize);
1530 /* To prevent kernel oops */
1531 this->autooob = &onenand_oob_32;
1532 break;
1533 }
1534
1535 memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo));
1536
1537 /* Fill in remaining MTD driver data */
1538 mtd->type = MTD_NANDFLASH;
1539 mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
1540 mtd->ecctype = MTD_ECC_SW;
1541 mtd->erase = onenand_erase;
1542 mtd->point = NULL;
1543 mtd->unpoint = NULL;
1544 mtd->read = onenand_read;
1545 mtd->write = onenand_write;
1546 mtd->read_ecc = onenand_read_ecc;
1547 mtd->write_ecc = onenand_write_ecc;
1548 mtd->read_oob = onenand_read_oob;
1549 mtd->write_oob = onenand_write_oob;
1550 mtd->readv = NULL;
1551 mtd->readv_ecc = NULL;
1552 mtd->writev = onenand_writev;
1553 mtd->writev_ecc = onenand_writev_ecc;
1554 mtd->sync = onenand_sync;
1555 mtd->lock = NULL;
1556 mtd->unlock = onenand_unlock;
1557 mtd->suspend = onenand_suspend;
1558 mtd->resume = onenand_resume;
1559 mtd->block_isbad = onenand_block_isbad;
1560 mtd->block_markbad = onenand_block_markbad;
1561 mtd->owner = THIS_MODULE;
1562
1563 /* Unlock whole block */
1564 mtd->unlock(mtd, 0x0, this->chipsize);
1565
1566 return this->scan_bbt(mtd);
1567}
1568
1569/**
1570 * onenand_release - [OneNAND Interface] Free resources held by the OneNAND device
1571 * @param mtd MTD device structure
1572 */
1573void onenand_release(struct mtd_info *mtd)
1574{
1575#ifdef CONFIG_MTD_PARTITIONS
1576 /* Deregister partitions */
1577 del_mtd_partitions (mtd);
1578#endif
1579 /* Deregister the device */
1580 del_mtd_device (mtd);
1581}
1582
1583EXPORT_SYMBOL_GPL(onenand_scan);
1584EXPORT_SYMBOL_GPL(onenand_release);
1585
1586MODULE_LICENSE("GPL");
1587MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>");
1588MODULE_DESCRIPTION("Generic OneNAND flash driver code");
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c
new file mode 100644
index 000000000000..f40190f499e1
--- /dev/null
+++ b/drivers/mtd/onenand/onenand_bbt.c
@@ -0,0 +1,246 @@
1/*
2 * linux/drivers/mtd/onenand/onenand_bbt.c
3 *
4 * Bad Block Table support for the OneNAND driver
5 *
6 * Copyright(c) 2005 Samsung Electronics
7 * Kyungmin Park <kyungmin.park@samsung.com>
8 *
9 * Derived from nand_bbt.c
10 *
11 * TODO:
12 * Split BBT core and chip specific BBT.
13 */
14
15#include <linux/slab.h>
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/onenand.h>
18#include <linux/mtd/compatmac.h>
19
20/**
21 * check_short_pattern - [GENERIC] check if a pattern is in the buffer
22 * @param buf the buffer to search
23 * @param len the length of buffer to search
24 * @param paglen the pagelength
25 * @param td search pattern descriptor
26 *
27 * Check for a pattern at the given place. Used to search bad block
28 * tables and good / bad block identifiers. Same as check_pattern, but
29 * no optional empty check and the pattern is expected to start
30 * at offset 0.
31 *
32 */
33static int check_short_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
34{
35 int i;
36 uint8_t *p = buf;
37
38 /* Compare the pattern */
39 for (i = 0; i < td->len; i++) {
40 if (p[i] != td->pattern[i])
41 return -1;
42 }
43 return 0;
44}
45
46/**
47 * create_bbt - [GENERIC] Create a bad block table by scanning the device
48 * @param mtd MTD device structure
49 * @param buf temporary buffer
50 * @param bd descriptor for the good/bad block search pattern
51 * @param chip create the table for a specific chip, -1 read all chips.
52 * Applies only if NAND_BBT_PERCHIP option is set
53 *
54 * Create a bad block table by scanning the device
55 * for the given good/bad block identify pattern
56 */
57static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip)
58{
59 struct onenand_chip *this = mtd->priv;
60 struct bbm_info *bbm = this->bbm;
61 int i, j, numblocks, len, scanlen;
62 int startblock;
63 loff_t from;
64 size_t readlen, ooblen;
65
66 printk(KERN_INFO "Scanning device for bad blocks\n");
67
68 len = 1;
69
70 /* We need only read few bytes from the OOB area */
71 scanlen = ooblen = 0;
72 readlen = bd->len;
73
74 /* chip == -1 case only */
75 /* Note that numblocks is 2 * (real numblocks) here;
76 * see i += 2 below as it makses shifting and masking less painful
77 */
78 numblocks = mtd->size >> (bbm->bbt_erase_shift - 1);
79 startblock = 0;
80 from = 0;
81
82 for (i = startblock; i < numblocks; ) {
83 int ret;
84
85 for (j = 0; j < len; j++) {
86 size_t retlen;
87
88 /* No need to read pages fully,
89 * just read required OOB bytes */
90 ret = mtd->read_oob(mtd, from + j * mtd->oobblock + bd->offs,
91 readlen, &retlen, &buf[0]);
92
93 if (ret)
94 return ret;
95
96 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->oobblock, bd)) {
97 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
98 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
99 i >> 1, (unsigned int) from);
100 break;
101 }
102 }
103 i += 2;
104 from += (1 << bbm->bbt_erase_shift);
105 }
106
107 return 0;
108}
109
110
111/**
112 * onenand_memory_bbt - [GENERIC] create a memory based bad block table
113 * @param mtd MTD device structure
114 * @param bd descriptor for the good/bad block search pattern
115 *
116 * The function creates a memory based bbt by scanning the device
117 * for manufacturer / software marked good / bad blocks
118 */
119static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
120{
121 unsigned char data_buf[MAX_ONENAND_PAGESIZE];
122
123 bd->options &= ~NAND_BBT_SCANEMPTY;
124 return create_bbt(mtd, data_buf, bd, -1);
125}
126
127/**
128 * onenand_isbad_bbt - [OneNAND Interface] Check if a block is bad
129 * @param mtd MTD device structure
130 * @param offs offset in the device
131 * @param allowbbt allow access to bad block table region
132 */
133static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
134{
135 struct onenand_chip *this = mtd->priv;
136 struct bbm_info *bbm = this->bbm;
137 int block;
138 uint8_t res;
139
140 /* Get block number * 2 */
141 block = (int) (offs >> (bbm->bbt_erase_shift - 1));
142 res = (bbm->bbt[block >> 3] >> (block & 0x06)) & 0x03;
143
144 DEBUG(MTD_DEBUG_LEVEL2, "onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n",
145 (unsigned int) offs, block >> 1, res);
146
147 switch ((int) res) {
148 case 0x00: return 0;
149 case 0x01: return 1;
150 case 0x02: return allowbbt ? 0 : 1;
151 }
152
153 return 1;
154}
155
156/**
157 * onenand_scan_bbt - [OneNAND Interface] scan, find, read and maybe create bad block table(s)
158 * @param mtd MTD device structure
159 * @param bd descriptor for the good/bad block search pattern
160 *
161 * The function checks, if a bad block table(s) is/are already
162 * available. If not it scans the device for manufacturer
163 * marked good / bad blocks and writes the bad block table(s) to
164 * the selected place.
165 *
166 * The bad block table memory is allocated here. It must be freed
167 * by calling the onenand_free_bbt function.
168 *
169 */
170int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
171{
172 struct onenand_chip *this = mtd->priv;
173 struct bbm_info *bbm = this->bbm;
174 int len, ret = 0;
175
176 len = mtd->size >> (this->erase_shift + 2);
177 /* Allocate memory (2bit per block) */
178 bbm->bbt = kmalloc(len, GFP_KERNEL);
179 if (!bbm->bbt) {
180 printk(KERN_ERR "onenand_scan_bbt: Out of memory\n");
181 return -ENOMEM;
182 }
183 /* Clear the memory bad block table */
184 memset(bbm->bbt, 0x00, len);
185
186 /* Set the bad block position */
187 bbm->badblockpos = ONENAND_BADBLOCK_POS;
188
189 /* Set erase shift */
190 bbm->bbt_erase_shift = this->erase_shift;
191
192 if (!bbm->isbad_bbt)
193 bbm->isbad_bbt = onenand_isbad_bbt;
194
195 /* Scan the device to build a memory based bad block table */
196 if ((ret = onenand_memory_bbt(mtd, bd))) {
197 printk(KERN_ERR "onenand_scan_bbt: Can't scan flash and build the RAM-based BBT\n");
198 kfree(bbm->bbt);
199 bbm->bbt = NULL;
200 }
201
202 return ret;
203}
204
205/*
206 * Define some generic bad / good block scan pattern which are used
207 * while scanning a device for factory marked good / bad blocks.
208 */
209static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
210
211static struct nand_bbt_descr largepage_memorybased = {
212 .options = 0,
213 .offs = 0,
214 .len = 2,
215 .pattern = scan_ff_pattern,
216};
217
218/**
219 * onenand_default_bbt - [OneNAND Interface] Select a default bad block table for the device
220 * @param mtd MTD device structure
221 *
222 * This function selects the default bad block table
223 * support for the device and calls the onenand_scan_bbt function
224 */
225int onenand_default_bbt(struct mtd_info *mtd)
226{
227 struct onenand_chip *this = mtd->priv;
228 struct bbm_info *bbm;
229
230 this->bbm = kmalloc(sizeof(struct bbm_info), GFP_KERNEL);
231 if (!this->bbm)
232 return -ENOMEM;
233
234 bbm = this->bbm;
235
236 memset(bbm, 0, sizeof(struct bbm_info));
237
238 /* 1KB page has same configuration as 2KB page */
239 if (!bbm->badblock_pattern)
240 bbm->badblock_pattern = &largepage_memorybased;
241
242 return onenand_scan_bbt(mtd, bbm->badblock_pattern);
243}
244
245EXPORT_SYMBOL(onenand_scan_bbt);
246EXPORT_SYMBOL(onenand_default_bbt);
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index 13f9e992bef8..7b7ca5ab5ae4 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: redboot.c,v 1.17 2004/11/22 11:33:56 ijc Exp $ 2 * $Id: redboot.c,v 1.18 2005/11/07 11:14:21 gleixner Exp $
3 * 3 *
4 * Parse RedBoot-style Flash Image System (FIS) tables and 4 * Parse RedBoot-style Flash Image System (FIS) tables and
5 * produce a Linux partition array to match. 5 * produce a Linux partition array to match.
@@ -39,7 +39,7 @@ static inline int redboot_checksum(struct fis_image_desc *img)
39 return 1; 39 return 1;
40} 40}
41 41
42static int parse_redboot_partitions(struct mtd_info *master, 42static int parse_redboot_partitions(struct mtd_info *master,
43 struct mtd_partition **pparts, 43 struct mtd_partition **pparts,
44 unsigned long fis_origin) 44 unsigned long fis_origin)
45{ 45{
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
new file mode 100644
index 000000000000..041ee59ea77d
--- /dev/null
+++ b/drivers/mtd/rfd_ftl.c
@@ -0,0 +1,855 @@
1/*
2 * rfd_ftl.c -- resident flash disk (flash translation layer)
3 *
4 * Copyright (C) 2005 Sean Young <sean@mess.org>
5 *
6 * $Id: rfd_ftl.c,v 1.5 2005/11/07 11:14:21 gleixner Exp $
7 *
8 * This type of flash translation layer (FTL) is used by the Embedded BIOS
9 * by General Software. It is known as the Resident Flash Disk (RFD), see:
10 *
11 * http://www.gensw.com/pages/prod/bios/rfd.htm
12 *
13 * based on ftl.c
14 */
15
16#include <linux/hdreg.h>
17#include <linux/init.h>
18#include <linux/mtd/blktrans.h>
19#include <linux/mtd/mtd.h>
20#include <linux/vmalloc.h>
21
22#include <asm/types.h>
23
24#define const_cpu_to_le16 __constant_cpu_to_le16
25
26static int block_size = 0;
27module_param(block_size, int, 0);
28MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit size");
29
30#define PREFIX "rfd_ftl: "
31
32/* Major device # for FTL device */
33
34/* A request for this major has been sent to device@lanana.org */
35#ifndef RFD_FTL_MAJOR
36#define RFD_FTL_MAJOR 95
37#endif
38
39/* Maximum number of partitions in an FTL region */
40#define PART_BITS 4
41
42/* An erase unit should start with this value */
43#define RFD_MAGIC 0x9193
44
45/* the second value is 0xffff or 0xffc8; function unknown */
46
47/* the third value is always 0xffff, ignored */
48
49/* next is an array of mapping for each corresponding sector */
50#define HEADER_MAP_OFFSET 3
51#define SECTOR_DELETED 0x0000
52#define SECTOR_ZERO 0xfffe
53#define SECTOR_FREE 0xffff
54
55#define SECTOR_SIZE 512
56
57#define SECTORS_PER_TRACK 63
58
59struct block {
60 enum {
61 BLOCK_OK,
62 BLOCK_ERASING,
63 BLOCK_ERASED,
64 BLOCK_FAILED
65 } state;
66 int free_sectors;
67 int used_sectors;
68 int erases;
69 u_long offset;
70};
71
72struct partition {
73 struct mtd_blktrans_dev mbd;
74
75 u_int block_size; /* size of erase unit */
76 u_int total_blocks; /* number of erase units */
77 u_int header_sectors_per_block; /* header sectors in erase unit */
78 u_int data_sectors_per_block; /* data sectors in erase unit */
79 u_int sector_count; /* sectors in translated disk */
80 u_int header_size; /* bytes in header sector */
81 int reserved_block; /* block next up for reclaim */
82 int current_block; /* block to write to */
83 u16 *header_cache; /* cached header */
84
85 int is_reclaiming;
86 int cylinders;
87 int errors;
88 u_long *sector_map;
89 struct block *blocks;
90};
91
92static int rfd_ftl_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf);
93
94static int build_block_map(struct partition *part, int block_no)
95{
96 struct block *block = &part->blocks[block_no];
97 int i;
98
99 block->offset = part->block_size * block_no;
100
101 if (le16_to_cpu(part->header_cache[0]) != RFD_MAGIC) {
102 block->state = BLOCK_ERASED; /* assumption */
103 block->free_sectors = part->data_sectors_per_block;
104 part->reserved_block = block_no;
105 return 1;
106 }
107
108 block->state = BLOCK_OK;
109
110 for (i=0; i<part->data_sectors_per_block; i++) {
111 u16 entry;
112
113 entry = le16_to_cpu(part->header_cache[HEADER_MAP_OFFSET + i]);
114
115 if (entry == SECTOR_DELETED)
116 continue;
117
118 if (entry == SECTOR_FREE) {
119 block->free_sectors++;
120 continue;
121 }
122
123 if (entry == SECTOR_ZERO)
124 entry = 0;
125
126 if (entry >= part->sector_count) {
127 printk(KERN_NOTICE PREFIX
128 "'%s': unit #%d: entry %d corrupt, "
129 "sector %d out of range\n",
130 part->mbd.mtd->name, block_no, i, entry);
131 continue;
132 }
133
134 if (part->sector_map[entry] != -1) {
135 printk(KERN_NOTICE PREFIX
136 "'%s': more than one entry for sector %d\n",
137 part->mbd.mtd->name, entry);
138 part->errors = 1;
139 continue;
140 }
141
142 part->sector_map[entry] = block->offset +
143 (i + part->header_sectors_per_block) * SECTOR_SIZE;
144
145 block->used_sectors++;
146 }
147
148 if (block->free_sectors == part->data_sectors_per_block)
149 part->reserved_block = block_no;
150
151 return 0;
152}
153
154static int scan_header(struct partition *part)
155{
156 int sectors_per_block;
157 int i, rc = -ENOMEM;
158 int blocks_found;
159 size_t retlen;
160
161 sectors_per_block = part->block_size / SECTOR_SIZE;
162 part->total_blocks = part->mbd.mtd->size / part->block_size;
163
164 if (part->total_blocks < 2)
165 return -ENOENT;
166
167 /* each erase block has three bytes header, followed by the map */
168 part->header_sectors_per_block =
169 ((HEADER_MAP_OFFSET + sectors_per_block) *
170 sizeof(u16) + SECTOR_SIZE - 1) / SECTOR_SIZE;
171
172 part->data_sectors_per_block = sectors_per_block -
173 part->header_sectors_per_block;
174
175 part->header_size = (HEADER_MAP_OFFSET +
176 part->data_sectors_per_block) * sizeof(u16);
177
178 part->cylinders = (part->data_sectors_per_block *
179 (part->total_blocks - 1) - 1) / SECTORS_PER_TRACK;
180
181 part->sector_count = part->cylinders * SECTORS_PER_TRACK;
182
183 part->current_block = -1;
184 part->reserved_block = -1;
185 part->is_reclaiming = 0;
186
187 part->header_cache = kmalloc(part->header_size, GFP_KERNEL);
188 if (!part->header_cache)
189 goto err;
190
191 part->blocks = kcalloc(part->total_blocks, sizeof(struct block),
192 GFP_KERNEL);
193 if (!part->blocks)
194 goto err;
195
196 part->sector_map = vmalloc(part->sector_count * sizeof(u_long));
197 if (!part->sector_map) {
198 printk(KERN_ERR PREFIX "'%s': unable to allocate memory for "
199 "sector map", part->mbd.mtd->name);
200 goto err;
201 }
202
203 for (i=0; i<part->sector_count; i++)
204 part->sector_map[i] = -1;
205
206 for (i=0, blocks_found=0; i<part->total_blocks; i++) {
207 rc = part->mbd.mtd->read(part->mbd.mtd,
208 i * part->block_size, part->header_size,
209 &retlen, (u_char*)part->header_cache);
210
211 if (!rc && retlen != part->header_size)
212 rc = -EIO;
213
214 if (rc)
215 goto err;
216
217 if (!build_block_map(part, i))
218 blocks_found++;
219 }
220
221 if (blocks_found == 0) {
222 printk(KERN_NOTICE PREFIX "no RFD magic found in '%s'\n",
223 part->mbd.mtd->name);
224 rc = -ENOENT;
225 goto err;
226 }
227
228 if (part->reserved_block == -1) {
229 printk(KERN_NOTICE PREFIX "'%s': no empty erase unit found\n",
230 part->mbd.mtd->name);
231
232 part->errors = 1;
233 }
234
235 return 0;
236
237err:
238 vfree(part->sector_map);
239 kfree(part->header_cache);
240 kfree(part->blocks);
241
242 return rc;
243}
244
245static int rfd_ftl_readsect(struct mtd_blktrans_dev *dev, u_long sector, char *buf)
246{
247 struct partition *part = (struct partition*)dev;
248 u_long addr;
249 size_t retlen;
250 int rc;
251
252 if (sector >= part->sector_count)
253 return -EIO;
254
255 addr = part->sector_map[sector];
256 if (addr != -1) {
257 rc = part->mbd.mtd->read(part->mbd.mtd, addr, SECTOR_SIZE,
258 &retlen, (u_char*)buf);
259 if (!rc && retlen != SECTOR_SIZE)
260 rc = -EIO;
261
262 if (rc) {
263 printk(KERN_WARNING PREFIX "error reading '%s' at "
264 "0x%lx\n", part->mbd.mtd->name, addr);
265 return rc;
266 }
267 } else
268 memset(buf, 0, SECTOR_SIZE);
269
270 return 0;
271}
272
273static void erase_callback(struct erase_info *erase)
274{
275 struct partition *part;
276 u16 magic;
277 int i, rc;
278 size_t retlen;
279
280 part = (struct partition*)erase->priv;
281
282 i = erase->addr / part->block_size;
283 if (i >= part->total_blocks || part->blocks[i].offset != erase->addr) {
284 printk(KERN_ERR PREFIX "erase callback for unknown offset %x "
285 "on '%s'\n", erase->addr, part->mbd.mtd->name);
286 return;
287 }
288
289 if (erase->state != MTD_ERASE_DONE) {
290 printk(KERN_WARNING PREFIX "erase failed at 0x%x on '%s', "
291 "state %d\n", erase->addr,
292 part->mbd.mtd->name, erase->state);
293
294 part->blocks[i].state = BLOCK_FAILED;
295 part->blocks[i].free_sectors = 0;
296 part->blocks[i].used_sectors = 0;
297
298 kfree(erase);
299
300 return;
301 }
302
303 magic = const_cpu_to_le16(RFD_MAGIC);
304
305 part->blocks[i].state = BLOCK_ERASED;
306 part->blocks[i].free_sectors = part->data_sectors_per_block;
307 part->blocks[i].used_sectors = 0;
308 part->blocks[i].erases++;
309
310 rc = part->mbd.mtd->write(part->mbd.mtd,
311 part->blocks[i].offset, sizeof(magic), &retlen,
312 (u_char*)&magic);
313
314 if (!rc && retlen != sizeof(magic))
315 rc = -EIO;
316
317 if (rc) {
318 printk(KERN_NOTICE PREFIX "'%s': unable to write RFD "
319 "header at 0x%lx\n",
320 part->mbd.mtd->name,
321 part->blocks[i].offset);
322 part->blocks[i].state = BLOCK_FAILED;
323 }
324 else
325 part->blocks[i].state = BLOCK_OK;
326
327 kfree(erase);
328}
329
330static int erase_block(struct partition *part, int block)
331{
332 struct erase_info *erase;
333 int rc = -ENOMEM;
334
335 erase = kmalloc(sizeof(struct erase_info), GFP_KERNEL);
336 if (!erase)
337 goto err;
338
339 erase->mtd = part->mbd.mtd;
340 erase->callback = erase_callback;
341 erase->addr = part->blocks[block].offset;
342 erase->len = part->block_size;
343 erase->priv = (u_long)part;
344
345 part->blocks[block].state = BLOCK_ERASING;
346 part->blocks[block].free_sectors = 0;
347
348 rc = part->mbd.mtd->erase(part->mbd.mtd, erase);
349
350 if (rc) {
351 printk(KERN_WARNING PREFIX "erase of region %x,%x on '%s' "
352 "failed\n", erase->addr, erase->len,
353 part->mbd.mtd->name);
354 kfree(erase);
355 }
356
357err:
358 return rc;
359}
360
361static int move_block_contents(struct partition *part, int block_no, u_long *old_sector)
362{
363 void *sector_data;
364 u16 *map;
365 size_t retlen;
366 int i, rc = -ENOMEM;
367
368 part->is_reclaiming = 1;
369
370 sector_data = kmalloc(SECTOR_SIZE, GFP_KERNEL);
371 if (!sector_data)
372 goto err3;
373
374 map = kmalloc(part->header_size, GFP_KERNEL);
375 if (!map)
376 goto err2;
377
378 rc = part->mbd.mtd->read(part->mbd.mtd,
379 part->blocks[block_no].offset, part->header_size,
380 &retlen, (u_char*)map);
381
382 if (!rc && retlen != part->header_size)
383 rc = -EIO;
384
385 if (rc) {
386 printk(KERN_NOTICE PREFIX "error reading '%s' at "
387 "0x%lx\n", part->mbd.mtd->name,
388 part->blocks[block_no].offset);
389
390 goto err;
391 }
392
393 for (i=0; i<part->data_sectors_per_block; i++) {
394 u16 entry = le16_to_cpu(map[HEADER_MAP_OFFSET + i]);
395 u_long addr;
396
397
398 if (entry == SECTOR_FREE || entry == SECTOR_DELETED)
399 continue;
400
401 if (entry == SECTOR_ZERO)
402 entry = 0;
403
404 /* already warned about and ignored in build_block_map() */
405 if (entry >= part->sector_count)
406 continue;
407
408 addr = part->blocks[block_no].offset +
409 (i + part->header_sectors_per_block) * SECTOR_SIZE;
410
411 if (*old_sector == addr) {
412 *old_sector = -1;
413 if (!part->blocks[block_no].used_sectors--) {
414 rc = erase_block(part, block_no);
415 break;
416 }
417 continue;
418 }
419 rc = part->mbd.mtd->read(part->mbd.mtd, addr,
420 SECTOR_SIZE, &retlen, sector_data);
421
422 if (!rc && retlen != SECTOR_SIZE)
423 rc = -EIO;
424
425 if (rc) {
426 printk(KERN_NOTICE PREFIX "'%s': Unable to "
427 "read sector for relocation\n",
428 part->mbd.mtd->name);
429
430 goto err;
431 }
432
433 rc = rfd_ftl_writesect((struct mtd_blktrans_dev*)part,
434 entry, sector_data);
435
436 if (rc)
437 goto err;
438 }
439
440err:
441 kfree(map);
442err2:
443 kfree(sector_data);
444err3:
445 part->is_reclaiming = 0;
446
447 return rc;
448}
449
450static int reclaim_block(struct partition *part, u_long *old_sector)
451{
452 int block, best_block, score, old_sector_block;
453 int rc;
454
455 /* we have a race if sync doesn't exist */
456 if (part->mbd.mtd->sync)
457 part->mbd.mtd->sync(part->mbd.mtd);
458
459 score = 0x7fffffff; /* MAX_INT */
460 best_block = -1;
461 if (*old_sector != -1)
462 old_sector_block = *old_sector / part->block_size;
463 else
464 old_sector_block = -1;
465
466 for (block=0; block<part->total_blocks; block++) {
467 int this_score;
468
469 if (block == part->reserved_block)
470 continue;
471
472 /*
473 * Postpone reclaiming if there is a free sector as
474 * more removed sectors is more efficient (have to move
475 * less).
476 */
477 if (part->blocks[block].free_sectors)
478 return 0;
479
480 this_score = part->blocks[block].used_sectors;
481
482 if (block == old_sector_block)
483 this_score--;
484 else {
485 /* no point in moving a full block */
486 if (part->blocks[block].used_sectors ==
487 part->data_sectors_per_block)
488 continue;
489 }
490
491 this_score += part->blocks[block].erases;
492
493 if (this_score < score) {
494 best_block = block;
495 score = this_score;
496 }
497 }
498
499 if (best_block == -1)
500 return -ENOSPC;
501
502 part->current_block = -1;
503 part->reserved_block = best_block;
504
505 pr_debug("reclaim_block: reclaiming block #%d with %d used "
506 "%d free sectors\n", best_block,
507 part->blocks[best_block].used_sectors,
508 part->blocks[best_block].free_sectors);
509
510 if (part->blocks[best_block].used_sectors)
511 rc = move_block_contents(part, best_block, old_sector);
512 else
513 rc = erase_block(part, best_block);
514
515 return rc;
516}
517
518/*
519 * IMPROVE: It would be best to choose the block with the most deleted sectors,
520 * because if we fill that one up first it'll have the most chance of having
521 * the least live sectors at reclaim.
522 */
523static int find_free_block(const struct partition *part)
524{
525 int block, stop;
526
527 block = part->current_block == -1 ?
528 jiffies % part->total_blocks : part->current_block;
529 stop = block;
530
531 do {
532 if (part->blocks[block].free_sectors &&
533 block != part->reserved_block)
534 return block;
535
536 if (++block >= part->total_blocks)
537 block = 0;
538
539 } while (block != stop);
540
541 return -1;
542}
543
544static int find_writeable_block(struct partition *part, u_long *old_sector)
545{
546 int rc, block;
547 size_t retlen;
548
549 block = find_free_block(part);
550
551 if (block == -1) {
552 if (!part->is_reclaiming) {
553 rc = reclaim_block(part, old_sector);
554 if (rc)
555 goto err;
556
557 block = find_free_block(part);
558 }
559
560 if (block == -1) {
561 rc = -ENOSPC;
562 goto err;
563 }
564 }
565
566 rc = part->mbd.mtd->read(part->mbd.mtd, part->blocks[block].offset,
567 part->header_size, &retlen, (u_char*)part->header_cache);
568
569 if (!rc && retlen != part->header_size)
570 rc = -EIO;
571
572 if (rc) {
573 printk(KERN_NOTICE PREFIX "'%s': unable to read header at "
574 "0x%lx\n", part->mbd.mtd->name,
575 part->blocks[block].offset);
576 goto err;
577 }
578
579 part->current_block = block;
580
581err:
582 return rc;
583}
584
585static int mark_sector_deleted(struct partition *part, u_long old_addr)
586{
587 int block, offset, rc;
588 u_long addr;
589 size_t retlen;
590 u16 del = const_cpu_to_le16(SECTOR_DELETED);
591
592 block = old_addr / part->block_size;
593 offset = (old_addr % part->block_size) / SECTOR_SIZE -
594 part->header_sectors_per_block;
595
596 addr = part->blocks[block].offset +
597 (HEADER_MAP_OFFSET + offset) * sizeof(u16);
598 rc = part->mbd.mtd->write(part->mbd.mtd, addr,
599 sizeof(del), &retlen, (u_char*)&del);
600
601 if (!rc && retlen != sizeof(del))
602 rc = -EIO;
603
604 if (rc) {
605 printk(KERN_WARNING PREFIX "error writing '%s' at "
606 "0x%lx\n", part->mbd.mtd->name, addr);
607 if (rc)
608 goto err;
609 }
610 if (block == part->current_block)
611 part->header_cache[offset + HEADER_MAP_OFFSET] = del;
612
613 part->blocks[block].used_sectors--;
614
615 if (!part->blocks[block].used_sectors &&
616 !part->blocks[block].free_sectors)
617 rc = erase_block(part, block);
618
619err:
620 return rc;
621}
622
623static int find_free_sector(const struct partition *part, const struct block *block)
624{
625 int i, stop;
626
627 i = stop = part->data_sectors_per_block - block->free_sectors;
628
629 do {
630 if (le16_to_cpu(part->header_cache[HEADER_MAP_OFFSET + i])
631 == SECTOR_FREE)
632 return i;
633
634 if (++i == part->data_sectors_per_block)
635 i = 0;
636 }
637 while(i != stop);
638
639 return -1;
640}
641
642static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf, ulong *old_addr)
643{
644 struct partition *part = (struct partition*)dev;
645 struct block *block;
646 u_long addr;
647 int i;
648 int rc;
649 size_t retlen;
650 u16 entry;
651
652 if (part->current_block == -1 ||
653 !part->blocks[part->current_block].free_sectors) {
654
655 rc = find_writeable_block(part, old_addr);
656 if (rc)
657 goto err;
658 }
659
660 block = &part->blocks[part->current_block];
661
662 i = find_free_sector(part, block);
663
664 if (i < 0) {
665 rc = -ENOSPC;
666 goto err;
667 }
668
669 addr = (i + part->header_sectors_per_block) * SECTOR_SIZE +
670 block->offset;
671 rc = part->mbd.mtd->write(part->mbd.mtd,
672 addr, SECTOR_SIZE, &retlen, (u_char*)buf);
673
674 if (!rc && retlen != SECTOR_SIZE)
675 rc = -EIO;
676
677 if (rc) {
678 printk(KERN_WARNING PREFIX "error writing '%s' at 0x%lx\n",
679 part->mbd.mtd->name, addr);
680 if (rc)
681 goto err;
682 }
683
684 part->sector_map[sector] = addr;
685
686 entry = cpu_to_le16(sector == 0 ? SECTOR_ZERO : sector);
687
688 part->header_cache[i + HEADER_MAP_OFFSET] = entry;
689
690 addr = block->offset + (HEADER_MAP_OFFSET + i) * sizeof(u16);
691 rc = part->mbd.mtd->write(part->mbd.mtd, addr,
692 sizeof(entry), &retlen, (u_char*)&entry);
693
694 if (!rc && retlen != sizeof(entry))
695 rc = -EIO;
696
697 if (rc) {
698 printk(KERN_WARNING PREFIX "error writing '%s' at 0x%lx\n",
699 part->mbd.mtd->name, addr);
700 if (rc)
701 goto err;
702 }
703 block->used_sectors++;
704 block->free_sectors--;
705
706err:
707 return rc;
708}
709
710static int rfd_ftl_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf)
711{
712 struct partition *part = (struct partition*)dev;
713 u_long old_addr;
714 int i;
715 int rc = 0;
716
717 pr_debug("rfd_ftl_writesect(sector=0x%lx)\n", sector);
718
719 if (part->reserved_block == -1) {
720 rc = -EACCES;
721 goto err;
722 }
723
724 if (sector >= part->sector_count) {
725 rc = -EIO;
726 goto err;
727 }
728
729 old_addr = part->sector_map[sector];
730
731 for (i=0; i<SECTOR_SIZE; i++) {
732 if (!buf[i])
733 continue;
734
735 rc = do_writesect(dev, sector, buf, &old_addr);
736 if (rc)
737 goto err;
738 break;
739 }
740
741 if (i == SECTOR_SIZE)
742 part->sector_map[sector] = -1;
743
744 if (old_addr != -1)
745 rc = mark_sector_deleted(part, old_addr);
746
747err:
748 return rc;
749}
750
751static int rfd_ftl_getgeo(struct mtd_blktrans_dev *dev, struct hd_geometry *geo)
752{
753 struct partition *part = (struct partition*)dev;
754
755 geo->heads = 1;
756 geo->sectors = SECTORS_PER_TRACK;
757 geo->cylinders = part->cylinders;
758
759 return 0;
760}
761
762static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
763{
764 struct partition *part;
765
766 if (mtd->type != MTD_NORFLASH)
767 return;
768
769 part = kcalloc(1, sizeof(struct partition), GFP_KERNEL);
770 if (!part)
771 return;
772
773 part->mbd.mtd = mtd;
774
775 if (block_size)
776 part->block_size = block_size;
777 else {
778 if (!mtd->erasesize) {
779 printk(KERN_NOTICE PREFIX "please provide block_size");
780 return;
781 }
782 else
783 part->block_size = mtd->erasesize;
784 }
785
786 if (scan_header(part) == 0) {
787 part->mbd.size = part->sector_count;
788 part->mbd.blksize = SECTOR_SIZE;
789 part->mbd.tr = tr;
790 part->mbd.devnum = -1;
791 if (!(mtd->flags & MTD_WRITEABLE))
792 part->mbd.readonly = 1;
793 else if (part->errors) {
794 printk(KERN_NOTICE PREFIX "'%s': errors found, "
795 "setting read-only", mtd->name);
796 part->mbd.readonly = 1;
797 }
798
799 printk(KERN_INFO PREFIX "name: '%s' type: %d flags %x\n",
800 mtd->name, mtd->type, mtd->flags);
801
802 if (!add_mtd_blktrans_dev((void*)part))
803 return;
804 }
805
806 kfree(part);
807}
808
809static void rfd_ftl_remove_dev(struct mtd_blktrans_dev *dev)
810{
811 struct partition *part = (struct partition*)dev;
812 int i;
813
814 for (i=0; i<part->total_blocks; i++) {
815 pr_debug("rfd_ftl_remove_dev:'%s': erase unit #%02d: %d erases\n",
816 part->mbd.mtd->name, i, part->blocks[i].erases);
817 }
818
819 del_mtd_blktrans_dev(dev);
820 vfree(part->sector_map);
821 kfree(part->header_cache);
822 kfree(part->blocks);
823 kfree(part);
824}
825
826struct mtd_blktrans_ops rfd_ftl_tr = {
827 .name = "rfd",
828 .major = RFD_FTL_MAJOR,
829 .part_bits = PART_BITS,
830 .readsect = rfd_ftl_readsect,
831 .writesect = rfd_ftl_writesect,
832 .getgeo = rfd_ftl_getgeo,
833 .add_mtd = rfd_ftl_add_mtd,
834 .remove_dev = rfd_ftl_remove_dev,
835 .owner = THIS_MODULE,
836};
837
838static int __init init_rfd_ftl(void)
839{
840 return register_mtd_blktrans(&rfd_ftl_tr);
841}
842
843static void __exit cleanup_rfd_ftl(void)
844{
845 deregister_mtd_blktrans(&rfd_ftl_tr);
846}
847
848module_init(init_rfd_ftl);
849module_exit(cleanup_rfd_ftl);
850
851MODULE_LICENSE("GPL");
852MODULE_AUTHOR("Sean Young <sean@mess.org>");
853MODULE_DESCRIPTION("Support code for RFD Flash Translation Layer, "
854 "used by General Software's Embedded BIOS");
855
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 455ba915ede7..7488ee7f7caf 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -602,7 +602,7 @@ MODULE_DEVICE_TABLE(pci, vortex_pci_tbl);
602 First the windows. There are eight register windows, with the command 602 First the windows. There are eight register windows, with the command
603 and status registers available in each. 603 and status registers available in each.
604 */ 604 */
605#define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD) 605#define EL3WINDOW(win_num) iowrite16(SelectWindow + (win_num), ioaddr + EL3_CMD)
606#define EL3_CMD 0x0e 606#define EL3_CMD 0x0e
607#define EL3_STATUS 0x0e 607#define EL3_STATUS 0x0e
608 608
@@ -776,7 +776,8 @@ struct vortex_private {
776 776
777 /* PCI configuration space information. */ 777 /* PCI configuration space information. */
778 struct device *gendev; 778 struct device *gendev;
779 char __iomem *cb_fn_base; /* CardBus function status addr space. */ 779 void __iomem *ioaddr; /* IO address space */
780 void __iomem *cb_fn_base; /* CardBus function status addr space. */
780 781
781 /* Some values here only for performance evaluation and path-coverage */ 782 /* Some values here only for performance evaluation and path-coverage */
782 int rx_nocopy, rx_copy, queued_packet, rx_csumhits; 783 int rx_nocopy, rx_copy, queued_packet, rx_csumhits;
@@ -869,12 +870,12 @@ static struct {
869/* number of ETHTOOL_GSTATS u64's */ 870/* number of ETHTOOL_GSTATS u64's */
870#define VORTEX_NUM_STATS 3 871#define VORTEX_NUM_STATS 3
871 872
872static int vortex_probe1(struct device *gendev, long ioaddr, int irq, 873static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
873 int chip_idx, int card_idx); 874 int chip_idx, int card_idx);
874static void vortex_up(struct net_device *dev); 875static void vortex_up(struct net_device *dev);
875static void vortex_down(struct net_device *dev, int final); 876static void vortex_down(struct net_device *dev, int final);
876static int vortex_open(struct net_device *dev); 877static int vortex_open(struct net_device *dev);
877static void mdio_sync(long ioaddr, int bits); 878static void mdio_sync(void __iomem *ioaddr, int bits);
878static int mdio_read(struct net_device *dev, int phy_id, int location); 879static int mdio_read(struct net_device *dev, int phy_id, int location);
879static void mdio_write(struct net_device *vp, int phy_id, int location, int value); 880static void mdio_write(struct net_device *vp, int phy_id, int location, int value);
880static void vortex_timer(unsigned long arg); 881static void vortex_timer(unsigned long arg);
@@ -887,7 +888,7 @@ static irqreturn_t vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
887static irqreturn_t boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs); 888static irqreturn_t boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs);
888static int vortex_close(struct net_device *dev); 889static int vortex_close(struct net_device *dev);
889static void dump_tx_ring(struct net_device *dev); 890static void dump_tx_ring(struct net_device *dev);
890static void update_stats(long ioaddr, struct net_device *dev); 891static void update_stats(void __iomem *ioaddr, struct net_device *dev);
891static struct net_device_stats *vortex_get_stats(struct net_device *dev); 892static struct net_device_stats *vortex_get_stats(struct net_device *dev);
892static void set_rx_mode(struct net_device *dev); 893static void set_rx_mode(struct net_device *dev);
893#ifdef CONFIG_PCI 894#ifdef CONFIG_PCI
@@ -902,14 +903,16 @@ static void set_8021q_mode(struct net_device *dev, int enable);
902/* This driver uses 'options' to pass the media type, full-duplex flag, etc. */ 903/* This driver uses 'options' to pass the media type, full-duplex flag, etc. */
903/* Option count limit only -- unlimited interfaces are supported. */ 904/* Option count limit only -- unlimited interfaces are supported. */
904#define MAX_UNITS 8 905#define MAX_UNITS 8
905static int options[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1,}; 906static int options[MAX_UNITS] = { [0 ... MAX_UNITS-1] = -1 };
906static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 907static int full_duplex[MAX_UNITS] = {[0 ... MAX_UNITS-1] = -1 };
907static int hw_checksums[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 908static int hw_checksums[MAX_UNITS] = {[0 ... MAX_UNITS-1] = -1 };
908static int flow_ctrl[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 909static int flow_ctrl[MAX_UNITS] = {[0 ... MAX_UNITS-1] = -1 };
909static int enable_wol[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 910static int enable_wol[MAX_UNITS] = {[0 ... MAX_UNITS-1] = -1 };
911static int use_mmio[MAX_UNITS] = {[0 ... MAX_UNITS-1] = -1 };
910static int global_options = -1; 912static int global_options = -1;
911static int global_full_duplex = -1; 913static int global_full_duplex = -1;
912static int global_enable_wol = -1; 914static int global_enable_wol = -1;
915static int global_use_mmio = -1;
913 916
914/* #define dev_alloc_skb dev_alloc_skb_debug */ 917/* #define dev_alloc_skb dev_alloc_skb_debug */
915 918
@@ -934,21 +937,25 @@ module_param(compaq_ioaddr, int, 0);
934module_param(compaq_irq, int, 0); 937module_param(compaq_irq, int, 0);
935module_param(compaq_device_id, int, 0); 938module_param(compaq_device_id, int, 0);
936module_param(watchdog, int, 0); 939module_param(watchdog, int, 0);
940module_param(global_use_mmio, int, 0);
941module_param_array(use_mmio, int, NULL, 0);
937MODULE_PARM_DESC(debug, "3c59x debug level (0-6)"); 942MODULE_PARM_DESC(debug, "3c59x debug level (0-6)");
938MODULE_PARM_DESC(options, "3c59x: Bits 0-3: media type, bit 4: bus mastering, bit 9: full duplex"); 943MODULE_PARM_DESC(options, "3c59x: Bits 0-3: media type, bit 4: bus mastering, bit 9: full duplex");
939MODULE_PARM_DESC(global_options, "3c59x: same as options, but applies to all NICs if options is unset"); 944MODULE_PARM_DESC(global_options, "3c59x: same as options, but applies to all NICs if options is unset");
940MODULE_PARM_DESC(full_duplex, "3c59x full duplex setting(s) (1)"); 945MODULE_PARM_DESC(full_duplex, "3c59x full duplex setting(s) (1)");
941MODULE_PARM_DESC(global_full_duplex, "3c59x: same as full_duplex, but applies to all NICs if options is unset"); 946MODULE_PARM_DESC(global_full_duplex, "3c59x: same as full_duplex, but applies to all NICs if full_duplex is unset");
942MODULE_PARM_DESC(hw_checksums, "3c59x Hardware checksum checking by adapter(s) (0-1)"); 947MODULE_PARM_DESC(hw_checksums, "3c59x Hardware checksum checking by adapter(s) (0-1)");
943MODULE_PARM_DESC(flow_ctrl, "3c59x 802.3x flow control usage (PAUSE only) (0-1)"); 948MODULE_PARM_DESC(flow_ctrl, "3c59x 802.3x flow control usage (PAUSE only) (0-1)");
944MODULE_PARM_DESC(enable_wol, "3c59x: Turn on Wake-on-LAN for adapter(s) (0-1)"); 949MODULE_PARM_DESC(enable_wol, "3c59x: Turn on Wake-on-LAN for adapter(s) (0-1)");
945MODULE_PARM_DESC(global_enable_wol, "3c59x: same as enable_wol, but applies to all NICs if options is unset"); 950MODULE_PARM_DESC(global_enable_wol, "3c59x: same as enable_wol, but applies to all NICs if enable_wol is unset");
946MODULE_PARM_DESC(rx_copybreak, "3c59x copy breakpoint for copy-only-tiny-frames"); 951MODULE_PARM_DESC(rx_copybreak, "3c59x copy breakpoint for copy-only-tiny-frames");
947MODULE_PARM_DESC(max_interrupt_work, "3c59x maximum events handled per interrupt"); 952MODULE_PARM_DESC(max_interrupt_work, "3c59x maximum events handled per interrupt");
948MODULE_PARM_DESC(compaq_ioaddr, "3c59x PCI I/O base address (Compaq BIOS problem workaround)"); 953MODULE_PARM_DESC(compaq_ioaddr, "3c59x PCI I/O base address (Compaq BIOS problem workaround)");
949MODULE_PARM_DESC(compaq_irq, "3c59x PCI IRQ number (Compaq BIOS problem workaround)"); 954MODULE_PARM_DESC(compaq_irq, "3c59x PCI IRQ number (Compaq BIOS problem workaround)");
950MODULE_PARM_DESC(compaq_device_id, "3c59x PCI device ID (Compaq BIOS problem workaround)"); 955MODULE_PARM_DESC(compaq_device_id, "3c59x PCI device ID (Compaq BIOS problem workaround)");
951MODULE_PARM_DESC(watchdog, "3c59x transmit timeout in milliseconds"); 956MODULE_PARM_DESC(watchdog, "3c59x transmit timeout in milliseconds");
957MODULE_PARM_DESC(global_use_mmio, "3c59x: same as use_mmio, but applies to all NICs if options is unset");
958MODULE_PARM_DESC(use_mmio, "3c59x: use memory-mapped PCI I/O resource (0-1)");
952 959
953#ifdef CONFIG_NET_POLL_CONTROLLER 960#ifdef CONFIG_NET_POLL_CONTROLLER
954static void poll_vortex(struct net_device *dev) 961static void poll_vortex(struct net_device *dev)
@@ -1029,18 +1036,19 @@ static struct eisa_driver vortex_eisa_driver = {
1029 1036
1030static int vortex_eisa_probe (struct device *device) 1037static int vortex_eisa_probe (struct device *device)
1031{ 1038{
1032 long ioaddr; 1039 void __iomem *ioaddr;
1033 struct eisa_device *edev; 1040 struct eisa_device *edev;
1034 1041
1035 edev = to_eisa_device (device); 1042 edev = to_eisa_device (device);
1036 ioaddr = edev->base_addr;
1037 1043
1038 if (!request_region(ioaddr, VORTEX_TOTAL_SIZE, DRV_NAME)) 1044 if (!request_region(edev->base_addr, VORTEX_TOTAL_SIZE, DRV_NAME))
1039 return -EBUSY; 1045 return -EBUSY;
1040 1046
1041 if (vortex_probe1(device, ioaddr, inw(ioaddr + 0xC88) >> 12, 1047 ioaddr = ioport_map(edev->base_addr, VORTEX_TOTAL_SIZE);
1048
1049 if (vortex_probe1(device, ioaddr, ioread16(ioaddr + 0xC88) >> 12,
1042 edev->id.driver_data, vortex_cards_found)) { 1050 edev->id.driver_data, vortex_cards_found)) {
1043 release_region (ioaddr, VORTEX_TOTAL_SIZE); 1051 release_region (edev->base_addr, VORTEX_TOTAL_SIZE);
1044 return -ENODEV; 1052 return -ENODEV;
1045 } 1053 }
1046 1054
@@ -1054,7 +1062,7 @@ static int vortex_eisa_remove (struct device *device)
1054 struct eisa_device *edev; 1062 struct eisa_device *edev;
1055 struct net_device *dev; 1063 struct net_device *dev;
1056 struct vortex_private *vp; 1064 struct vortex_private *vp;
1057 long ioaddr; 1065 void __iomem *ioaddr;
1058 1066
1059 edev = to_eisa_device (device); 1067 edev = to_eisa_device (device);
1060 dev = eisa_get_drvdata (edev); 1068 dev = eisa_get_drvdata (edev);
@@ -1065,11 +1073,11 @@ static int vortex_eisa_remove (struct device *device)
1065 } 1073 }
1066 1074
1067 vp = netdev_priv(dev); 1075 vp = netdev_priv(dev);
1068 ioaddr = dev->base_addr; 1076 ioaddr = vp->ioaddr;
1069 1077
1070 unregister_netdev (dev); 1078 unregister_netdev (dev);
1071 outw (TotalReset|0x14, ioaddr + EL3_CMD); 1079 iowrite16 (TotalReset|0x14, ioaddr + EL3_CMD);
1072 release_region (ioaddr, VORTEX_TOTAL_SIZE); 1080 release_region (dev->base_addr, VORTEX_TOTAL_SIZE);
1073 1081
1074 free_netdev (dev); 1082 free_netdev (dev);
1075 return 0; 1083 return 0;
@@ -1096,8 +1104,8 @@ static int __init vortex_eisa_init (void)
1096 1104
1097 /* Special code to work-around the Compaq PCI BIOS32 problem. */ 1105 /* Special code to work-around the Compaq PCI BIOS32 problem. */
1098 if (compaq_ioaddr) { 1106 if (compaq_ioaddr) {
1099 vortex_probe1(NULL, compaq_ioaddr, compaq_irq, 1107 vortex_probe1(NULL, ioport_map(compaq_ioaddr, VORTEX_TOTAL_SIZE),
1100 compaq_device_id, vortex_cards_found++); 1108 compaq_irq, compaq_device_id, vortex_cards_found++);
1101 } 1109 }
1102 1110
1103 return vortex_cards_found - orig_cards_found + eisa_found; 1111 return vortex_cards_found - orig_cards_found + eisa_found;
@@ -1107,15 +1115,32 @@ static int __init vortex_eisa_init (void)
1107static int __devinit vortex_init_one (struct pci_dev *pdev, 1115static int __devinit vortex_init_one (struct pci_dev *pdev,
1108 const struct pci_device_id *ent) 1116 const struct pci_device_id *ent)
1109{ 1117{
1110 int rc; 1118 int rc, unit, pci_bar;
1119 struct vortex_chip_info *vci;
1120 void __iomem *ioaddr;
1111 1121
1112 /* wake up and enable device */ 1122 /* wake up and enable device */
1113 rc = pci_enable_device (pdev); 1123 rc = pci_enable_device (pdev);
1114 if (rc < 0) 1124 if (rc < 0)
1115 goto out; 1125 goto out;
1116 1126
1117 rc = vortex_probe1 (&pdev->dev, pci_resource_start (pdev, 0), 1127 unit = vortex_cards_found;
1118 pdev->irq, ent->driver_data, vortex_cards_found); 1128
1129 if (global_use_mmio < 0 && (unit >= MAX_UNITS || use_mmio[unit] < 0)) {
1130 /* Determine the default if the user didn't override us */
1131 vci = &vortex_info_tbl[ent->driver_data];
1132 pci_bar = vci->drv_flags & (IS_CYCLONE | IS_TORNADO) ? 1 : 0;
1133 } else if (unit < MAX_UNITS && use_mmio[unit] >= 0)
1134 pci_bar = use_mmio[unit] ? 1 : 0;
1135 else
1136 pci_bar = global_use_mmio ? 1 : 0;
1137
1138 ioaddr = pci_iomap(pdev, pci_bar, 0);
1139 if (!ioaddr) /* If mapping fails, fall-back to BAR 0... */
1140 ioaddr = pci_iomap(pdev, 0, 0);
1141
1142 rc = vortex_probe1(&pdev->dev, ioaddr, pdev->irq,
1143 ent->driver_data, unit);
1119 if (rc < 0) { 1144 if (rc < 0) {
1120 pci_disable_device (pdev); 1145 pci_disable_device (pdev);
1121 goto out; 1146 goto out;
@@ -1134,7 +1159,7 @@ out:
1134 * NOTE: pdev can be NULL, for the case of a Compaq device 1159 * NOTE: pdev can be NULL, for the case of a Compaq device
1135 */ 1160 */
1136static int __devinit vortex_probe1(struct device *gendev, 1161static int __devinit vortex_probe1(struct device *gendev,
1137 long ioaddr, int irq, 1162 void __iomem *ioaddr, int irq,
1138 int chip_idx, int card_idx) 1163 int chip_idx, int card_idx)
1139{ 1164{
1140 struct vortex_private *vp; 1165 struct vortex_private *vp;
@@ -1202,15 +1227,16 @@ static int __devinit vortex_probe1(struct device *gendev,
1202 if (print_info) 1227 if (print_info)
1203 printk (KERN_INFO "See Documentation/networking/vortex.txt\n"); 1228 printk (KERN_INFO "See Documentation/networking/vortex.txt\n");
1204 1229
1205 printk(KERN_INFO "%s: 3Com %s %s at 0x%lx. Vers " DRV_VERSION "\n", 1230 printk(KERN_INFO "%s: 3Com %s %s at %p. Vers " DRV_VERSION "\n",
1206 print_name, 1231 print_name,
1207 pdev ? "PCI" : "EISA", 1232 pdev ? "PCI" : "EISA",
1208 vci->name, 1233 vci->name,
1209 ioaddr); 1234 ioaddr);
1210 1235
1211 dev->base_addr = ioaddr; 1236 dev->base_addr = (unsigned long)ioaddr;
1212 dev->irq = irq; 1237 dev->irq = irq;
1213 dev->mtu = mtu; 1238 dev->mtu = mtu;
1239 vp->ioaddr = ioaddr;
1214 vp->large_frames = mtu > 1500; 1240 vp->large_frames = mtu > 1500;
1215 vp->drv_flags = vci->drv_flags; 1241 vp->drv_flags = vci->drv_flags;
1216 vp->has_nway = (vci->drv_flags & HAS_NWAY) ? 1 : 0; 1242 vp->has_nway = (vci->drv_flags & HAS_NWAY) ? 1 : 0;
@@ -1226,7 +1252,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1226 if (pdev) { 1252 if (pdev) {
1227 /* EISA resources already marked, so only PCI needs to do this here */ 1253 /* EISA resources already marked, so only PCI needs to do this here */
1228 /* Ignore return value, because Cardbus drivers already allocate for us */ 1254 /* Ignore return value, because Cardbus drivers already allocate for us */
1229 if (request_region(ioaddr, vci->io_size, print_name) != NULL) 1255 if (request_region(dev->base_addr, vci->io_size, print_name) != NULL)
1230 vp->must_free_region = 1; 1256 vp->must_free_region = 1;
1231 1257
1232 /* enable bus-mastering if necessary */ 1258 /* enable bus-mastering if necessary */
@@ -1316,14 +1342,14 @@ static int __devinit vortex_probe1(struct device *gendev,
1316 1342
1317 for (i = 0; i < 0x40; i++) { 1343 for (i = 0; i < 0x40; i++) {
1318 int timer; 1344 int timer;
1319 outw(base + i, ioaddr + Wn0EepromCmd); 1345 iowrite16(base + i, ioaddr + Wn0EepromCmd);
1320 /* Pause for at least 162 us. for the read to take place. */ 1346 /* Pause for at least 162 us. for the read to take place. */
1321 for (timer = 10; timer >= 0; timer--) { 1347 for (timer = 10; timer >= 0; timer--) {
1322 udelay(162); 1348 udelay(162);
1323 if ((inw(ioaddr + Wn0EepromCmd) & 0x8000) == 0) 1349 if ((ioread16(ioaddr + Wn0EepromCmd) & 0x8000) == 0)
1324 break; 1350 break;
1325 } 1351 }
1326 eeprom[i] = inw(ioaddr + Wn0EepromData); 1352 eeprom[i] = ioread16(ioaddr + Wn0EepromData);
1327 } 1353 }
1328 } 1354 }
1329 for (i = 0; i < 0x18; i++) 1355 for (i = 0; i < 0x18; i++)
@@ -1338,6 +1364,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1338 printk(" ***INVALID CHECKSUM %4.4x*** ", checksum); 1364 printk(" ***INVALID CHECKSUM %4.4x*** ", checksum);
1339 for (i = 0; i < 3; i++) 1365 for (i = 0; i < 3; i++)
1340 ((u16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]); 1366 ((u16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]);
1367 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
1341 if (print_info) { 1368 if (print_info) {
1342 for (i = 0; i < 6; i++) 1369 for (i = 0; i < 6; i++)
1343 printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]); 1370 printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
@@ -1351,7 +1378,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1351 } 1378 }
1352 EL3WINDOW(2); 1379 EL3WINDOW(2);
1353 for (i = 0; i < 6; i++) 1380 for (i = 0; i < 6; i++)
1354 outb(dev->dev_addr[i], ioaddr + i); 1381 iowrite8(dev->dev_addr[i], ioaddr + i);
1355 1382
1356#ifdef __sparc__ 1383#ifdef __sparc__
1357 if (print_info) 1384 if (print_info)
@@ -1366,7 +1393,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1366#endif 1393#endif
1367 1394
1368 EL3WINDOW(4); 1395 EL3WINDOW(4);
1369 step = (inb(ioaddr + Wn4_NetDiag) & 0x1e) >> 1; 1396 step = (ioread8(ioaddr + Wn4_NetDiag) & 0x1e) >> 1;
1370 if (print_info) { 1397 if (print_info) {
1371 printk(KERN_INFO " product code %02x%02x rev %02x.%d date %02d-" 1398 printk(KERN_INFO " product code %02x%02x rev %02x.%d date %02d-"
1372 "%02d-%02d\n", eeprom[6]&0xff, eeprom[6]>>8, eeprom[0x14], 1399 "%02d-%02d\n", eeprom[6]&0xff, eeprom[6]>>8, eeprom[0x14],
@@ -1375,31 +1402,30 @@ static int __devinit vortex_probe1(struct device *gendev,
1375 1402
1376 1403
1377 if (pdev && vci->drv_flags & HAS_CB_FNS) { 1404 if (pdev && vci->drv_flags & HAS_CB_FNS) {
1378 unsigned long fn_st_addr; /* Cardbus function status space */
1379 unsigned short n; 1405 unsigned short n;
1380 1406
1381 fn_st_addr = pci_resource_start (pdev, 2); 1407 vp->cb_fn_base = pci_iomap(pdev, 2, 0);
1382 if (fn_st_addr) { 1408 if (!vp->cb_fn_base) {
1383 vp->cb_fn_base = ioremap(fn_st_addr, 128);
1384 retval = -ENOMEM; 1409 retval = -ENOMEM;
1385 if (!vp->cb_fn_base) 1410 goto free_ring;
1386 goto free_ring;
1387 } 1411 }
1412
1388 if (print_info) { 1413 if (print_info) {
1389 printk(KERN_INFO "%s: CardBus functions mapped %8.8lx->%p\n", 1414 printk(KERN_INFO "%s: CardBus functions mapped %8.8lx->%p\n",
1390 print_name, fn_st_addr, vp->cb_fn_base); 1415 print_name, pci_resource_start(pdev, 2),
1416 vp->cb_fn_base);
1391 } 1417 }
1392 EL3WINDOW(2); 1418 EL3WINDOW(2);
1393 1419
1394 n = inw(ioaddr + Wn2_ResetOptions) & ~0x4010; 1420 n = ioread16(ioaddr + Wn2_ResetOptions) & ~0x4010;
1395 if (vp->drv_flags & INVERT_LED_PWR) 1421 if (vp->drv_flags & INVERT_LED_PWR)
1396 n |= 0x10; 1422 n |= 0x10;
1397 if (vp->drv_flags & INVERT_MII_PWR) 1423 if (vp->drv_flags & INVERT_MII_PWR)
1398 n |= 0x4000; 1424 n |= 0x4000;
1399 outw(n, ioaddr + Wn2_ResetOptions); 1425 iowrite16(n, ioaddr + Wn2_ResetOptions);
1400 if (vp->drv_flags & WNO_XCVR_PWR) { 1426 if (vp->drv_flags & WNO_XCVR_PWR) {
1401 EL3WINDOW(0); 1427 EL3WINDOW(0);
1402 outw(0x0800, ioaddr); 1428 iowrite16(0x0800, ioaddr);
1403 } 1429 }
1404 } 1430 }
1405 1431
@@ -1418,13 +1444,13 @@ static int __devinit vortex_probe1(struct device *gendev,
1418 static const char * ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 1444 static const char * ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
1419 unsigned int config; 1445 unsigned int config;
1420 EL3WINDOW(3); 1446 EL3WINDOW(3);
1421 vp->available_media = inw(ioaddr + Wn3_Options); 1447 vp->available_media = ioread16(ioaddr + Wn3_Options);
1422 if ((vp->available_media & 0xff) == 0) /* Broken 3c916 */ 1448 if ((vp->available_media & 0xff) == 0) /* Broken 3c916 */
1423 vp->available_media = 0x40; 1449 vp->available_media = 0x40;
1424 config = inl(ioaddr + Wn3_Config); 1450 config = ioread32(ioaddr + Wn3_Config);
1425 if (print_info) { 1451 if (print_info) {
1426 printk(KERN_DEBUG " Internal config register is %4.4x, " 1452 printk(KERN_DEBUG " Internal config register is %4.4x, "
1427 "transceivers %#x.\n", config, inw(ioaddr + Wn3_Options)); 1453 "transceivers %#x.\n", config, ioread16(ioaddr + Wn3_Options));
1428 printk(KERN_INFO " %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n", 1454 printk(KERN_INFO " %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n",
1429 8 << RAM_SIZE(config), 1455 8 << RAM_SIZE(config),
1430 RAM_WIDTH(config) ? "word" : "byte", 1456 RAM_WIDTH(config) ? "word" : "byte",
@@ -1455,7 +1481,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1455 if (vp->drv_flags & EXTRA_PREAMBLE) 1481 if (vp->drv_flags & EXTRA_PREAMBLE)
1456 mii_preamble_required++; 1482 mii_preamble_required++;
1457 mdio_sync(ioaddr, 32); 1483 mdio_sync(ioaddr, 32);
1458 mdio_read(dev, 24, 1); 1484 mdio_read(dev, 24, MII_BMSR);
1459 for (phy = 0; phy < 32 && phy_idx < 1; phy++) { 1485 for (phy = 0; phy < 32 && phy_idx < 1; phy++) {
1460 int mii_status, phyx; 1486 int mii_status, phyx;
1461 1487
@@ -1469,7 +1495,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1469 phyx = phy - 1; 1495 phyx = phy - 1;
1470 else 1496 else
1471 phyx = phy; 1497 phyx = phy;
1472 mii_status = mdio_read(dev, phyx, 1); 1498 mii_status = mdio_read(dev, phyx, MII_BMSR);
1473 if (mii_status && mii_status != 0xffff) { 1499 if (mii_status && mii_status != 0xffff) {
1474 vp->phys[phy_idx++] = phyx; 1500 vp->phys[phy_idx++] = phyx;
1475 if (print_info) { 1501 if (print_info) {
@@ -1485,7 +1511,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1485 printk(KERN_WARNING" ***WARNING*** No MII transceivers found!\n"); 1511 printk(KERN_WARNING" ***WARNING*** No MII transceivers found!\n");
1486 vp->phys[0] = 24; 1512 vp->phys[0] = 24;
1487 } else { 1513 } else {
1488 vp->advertising = mdio_read(dev, vp->phys[0], 4); 1514 vp->advertising = mdio_read(dev, vp->phys[0], MII_ADVERTISE);
1489 if (vp->full_duplex) { 1515 if (vp->full_duplex) {
1490 /* Only advertise the FD media types. */ 1516 /* Only advertise the FD media types. */
1491 vp->advertising &= ~0x02A0; 1517 vp->advertising &= ~0x02A0;
@@ -1510,10 +1536,10 @@ static int __devinit vortex_probe1(struct device *gendev,
1510 if (vp->full_bus_master_tx) { 1536 if (vp->full_bus_master_tx) {
1511 dev->hard_start_xmit = boomerang_start_xmit; 1537 dev->hard_start_xmit = boomerang_start_xmit;
1512 /* Actually, it still should work with iommu. */ 1538 /* Actually, it still should work with iommu. */
1513 dev->features |= NETIF_F_SG; 1539 if (card_idx < MAX_UNITS &&
1514 if (((hw_checksums[card_idx] == -1) && (vp->drv_flags & HAS_HWCKSM)) || 1540 ((hw_checksums[card_idx] == -1 && (vp->drv_flags & HAS_HWCKSM)) ||
1515 (hw_checksums[card_idx] == 1)) { 1541 hw_checksums[card_idx] == 1)) {
1516 dev->features |= NETIF_F_IP_CSUM; 1542 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
1517 } 1543 }
1518 } else { 1544 } else {
1519 dev->hard_start_xmit = vortex_start_xmit; 1545 dev->hard_start_xmit = vortex_start_xmit;
@@ -1555,7 +1581,7 @@ free_ring:
1555 vp->rx_ring_dma); 1581 vp->rx_ring_dma);
1556free_region: 1582free_region:
1557 if (vp->must_free_region) 1583 if (vp->must_free_region)
1558 release_region(ioaddr, vci->io_size); 1584 release_region(dev->base_addr, vci->io_size);
1559 free_netdev(dev); 1585 free_netdev(dev);
1560 printk(KERN_ERR PFX "vortex_probe1 fails. Returns %d\n", retval); 1586 printk(KERN_ERR PFX "vortex_probe1 fails. Returns %d\n", retval);
1561out: 1587out:
@@ -1565,17 +1591,19 @@ out:
1565static void 1591static void
1566issue_and_wait(struct net_device *dev, int cmd) 1592issue_and_wait(struct net_device *dev, int cmd)
1567{ 1593{
1594 struct vortex_private *vp = netdev_priv(dev);
1595 void __iomem *ioaddr = vp->ioaddr;
1568 int i; 1596 int i;
1569 1597
1570 outw(cmd, dev->base_addr + EL3_CMD); 1598 iowrite16(cmd, ioaddr + EL3_CMD);
1571 for (i = 0; i < 2000; i++) { 1599 for (i = 0; i < 2000; i++) {
1572 if (!(inw(dev->base_addr + EL3_STATUS) & CmdInProgress)) 1600 if (!(ioread16(ioaddr + EL3_STATUS) & CmdInProgress))
1573 return; 1601 return;
1574 } 1602 }
1575 1603
1576 /* OK, that didn't work. Do it the slow way. One second */ 1604 /* OK, that didn't work. Do it the slow way. One second */
1577 for (i = 0; i < 100000; i++) { 1605 for (i = 0; i < 100000; i++) {
1578 if (!(inw(dev->base_addr + EL3_STATUS) & CmdInProgress)) { 1606 if (!(ioread16(ioaddr + EL3_STATUS) & CmdInProgress)) {
1579 if (vortex_debug > 1) 1607 if (vortex_debug > 1)
1580 printk(KERN_INFO "%s: command 0x%04x took %d usecs\n", 1608 printk(KERN_INFO "%s: command 0x%04x took %d usecs\n",
1581 dev->name, cmd, i * 10); 1609 dev->name, cmd, i * 10);
@@ -1584,14 +1612,14 @@ issue_and_wait(struct net_device *dev, int cmd)
1584 udelay(10); 1612 udelay(10);
1585 } 1613 }
1586 printk(KERN_ERR "%s: command 0x%04x did not complete! Status=0x%x\n", 1614 printk(KERN_ERR "%s: command 0x%04x did not complete! Status=0x%x\n",
1587 dev->name, cmd, inw(dev->base_addr + EL3_STATUS)); 1615 dev->name, cmd, ioread16(ioaddr + EL3_STATUS));
1588} 1616}
1589 1617
1590static void 1618static void
1591vortex_up(struct net_device *dev) 1619vortex_up(struct net_device *dev)
1592{ 1620{
1593 long ioaddr = dev->base_addr;
1594 struct vortex_private *vp = netdev_priv(dev); 1621 struct vortex_private *vp = netdev_priv(dev);
1622 void __iomem *ioaddr = vp->ioaddr;
1595 unsigned int config; 1623 unsigned int config;
1596 int i; 1624 int i;
1597 1625
@@ -1604,7 +1632,7 @@ vortex_up(struct net_device *dev)
1604 1632
1605 /* Before initializing select the active media port. */ 1633 /* Before initializing select the active media port. */
1606 EL3WINDOW(3); 1634 EL3WINDOW(3);
1607 config = inl(ioaddr + Wn3_Config); 1635 config = ioread32(ioaddr + Wn3_Config);
1608 1636
1609 if (vp->media_override != 7) { 1637 if (vp->media_override != 7) {
1610 printk(KERN_INFO "%s: Media override to transceiver %d (%s).\n", 1638 printk(KERN_INFO "%s: Media override to transceiver %d (%s).\n",
@@ -1651,14 +1679,14 @@ vortex_up(struct net_device *dev)
1651 config = BFINS(config, dev->if_port, 20, 4); 1679 config = BFINS(config, dev->if_port, 20, 4);
1652 if (vortex_debug > 6) 1680 if (vortex_debug > 6)
1653 printk(KERN_DEBUG "vortex_up(): writing 0x%x to InternalConfig\n", config); 1681 printk(KERN_DEBUG "vortex_up(): writing 0x%x to InternalConfig\n", config);
1654 outl(config, ioaddr + Wn3_Config); 1682 iowrite32(config, ioaddr + Wn3_Config);
1655 1683
1656 if (dev->if_port == XCVR_MII || dev->if_port == XCVR_NWAY) { 1684 if (dev->if_port == XCVR_MII || dev->if_port == XCVR_NWAY) {
1657 int mii_reg1, mii_reg5; 1685 int mii_reg1, mii_reg5;
1658 EL3WINDOW(4); 1686 EL3WINDOW(4);
1659 /* Read BMSR (reg1) only to clear old status. */ 1687 /* Read BMSR (reg1) only to clear old status. */
1660 mii_reg1 = mdio_read(dev, vp->phys[0], 1); 1688 mii_reg1 = mdio_read(dev, vp->phys[0], MII_BMSR);
1661 mii_reg5 = mdio_read(dev, vp->phys[0], 5); 1689 mii_reg5 = mdio_read(dev, vp->phys[0], MII_LPA);
1662 if (mii_reg5 == 0xffff || mii_reg5 == 0x0000) { 1690 if (mii_reg5 == 0xffff || mii_reg5 == 0x0000) {
1663 netif_carrier_off(dev); /* No MII device or no link partner report */ 1691 netif_carrier_off(dev); /* No MII device or no link partner report */
1664 } else { 1692 } else {
@@ -1679,7 +1707,7 @@ vortex_up(struct net_device *dev)
1679 } 1707 }
1680 1708
1681 /* Set the full-duplex bit. */ 1709 /* Set the full-duplex bit. */
1682 outw( ((vp->info1 & 0x8000) || vp->full_duplex ? 0x20 : 0) | 1710 iowrite16( ((vp->info1 & 0x8000) || vp->full_duplex ? 0x20 : 0) |
1683 (vp->large_frames ? 0x40 : 0) | 1711 (vp->large_frames ? 0x40 : 0) |
1684 ((vp->full_duplex && vp->flow_ctrl && vp->partner_flow_ctrl) ? 0x100 : 0), 1712 ((vp->full_duplex && vp->flow_ctrl && vp->partner_flow_ctrl) ? 0x100 : 0),
1685 ioaddr + Wn3_MAC_Ctrl); 1713 ioaddr + Wn3_MAC_Ctrl);
@@ -1695,51 +1723,51 @@ vortex_up(struct net_device *dev)
1695 */ 1723 */
1696 issue_and_wait(dev, RxReset|0x04); 1724 issue_and_wait(dev, RxReset|0x04);
1697 1725
1698 outw(SetStatusEnb | 0x00, ioaddr + EL3_CMD); 1726 iowrite16(SetStatusEnb | 0x00, ioaddr + EL3_CMD);
1699 1727
1700 if (vortex_debug > 1) { 1728 if (vortex_debug > 1) {
1701 EL3WINDOW(4); 1729 EL3WINDOW(4);
1702 printk(KERN_DEBUG "%s: vortex_up() irq %d media status %4.4x.\n", 1730 printk(KERN_DEBUG "%s: vortex_up() irq %d media status %4.4x.\n",
1703 dev->name, dev->irq, inw(ioaddr + Wn4_Media)); 1731 dev->name, dev->irq, ioread16(ioaddr + Wn4_Media));
1704 } 1732 }
1705 1733
1706 /* Set the station address and mask in window 2 each time opened. */ 1734 /* Set the station address and mask in window 2 each time opened. */
1707 EL3WINDOW(2); 1735 EL3WINDOW(2);
1708 for (i = 0; i < 6; i++) 1736 for (i = 0; i < 6; i++)
1709 outb(dev->dev_addr[i], ioaddr + i); 1737 iowrite8(dev->dev_addr[i], ioaddr + i);
1710 for (; i < 12; i+=2) 1738 for (; i < 12; i+=2)
1711 outw(0, ioaddr + i); 1739 iowrite16(0, ioaddr + i);
1712 1740
1713 if (vp->cb_fn_base) { 1741 if (vp->cb_fn_base) {
1714 unsigned short n = inw(ioaddr + Wn2_ResetOptions) & ~0x4010; 1742 unsigned short n = ioread16(ioaddr + Wn2_ResetOptions) & ~0x4010;
1715 if (vp->drv_flags & INVERT_LED_PWR) 1743 if (vp->drv_flags & INVERT_LED_PWR)
1716 n |= 0x10; 1744 n |= 0x10;
1717 if (vp->drv_flags & INVERT_MII_PWR) 1745 if (vp->drv_flags & INVERT_MII_PWR)
1718 n |= 0x4000; 1746 n |= 0x4000;
1719 outw(n, ioaddr + Wn2_ResetOptions); 1747 iowrite16(n, ioaddr + Wn2_ResetOptions);
1720 } 1748 }
1721 1749
1722 if (dev->if_port == XCVR_10base2) 1750 if (dev->if_port == XCVR_10base2)
1723 /* Start the thinnet transceiver. We should really wait 50ms...*/ 1751 /* Start the thinnet transceiver. We should really wait 50ms...*/
1724 outw(StartCoax, ioaddr + EL3_CMD); 1752 iowrite16(StartCoax, ioaddr + EL3_CMD);
1725 if (dev->if_port != XCVR_NWAY) { 1753 if (dev->if_port != XCVR_NWAY) {
1726 EL3WINDOW(4); 1754 EL3WINDOW(4);
1727 outw((inw(ioaddr + Wn4_Media) & ~(Media_10TP|Media_SQE)) | 1755 iowrite16((ioread16(ioaddr + Wn4_Media) & ~(Media_10TP|Media_SQE)) |
1728 media_tbl[dev->if_port].media_bits, ioaddr + Wn4_Media); 1756 media_tbl[dev->if_port].media_bits, ioaddr + Wn4_Media);
1729 } 1757 }
1730 1758
1731 /* Switch to the stats window, and clear all stats by reading. */ 1759 /* Switch to the stats window, and clear all stats by reading. */
1732 outw(StatsDisable, ioaddr + EL3_CMD); 1760 iowrite16(StatsDisable, ioaddr + EL3_CMD);
1733 EL3WINDOW(6); 1761 EL3WINDOW(6);
1734 for (i = 0; i < 10; i++) 1762 for (i = 0; i < 10; i++)
1735 inb(ioaddr + i); 1763 ioread8(ioaddr + i);
1736 inw(ioaddr + 10); 1764 ioread16(ioaddr + 10);
1737 inw(ioaddr + 12); 1765 ioread16(ioaddr + 12);
1738 /* New: On the Vortex we must also clear the BadSSD counter. */ 1766 /* New: On the Vortex we must also clear the BadSSD counter. */
1739 EL3WINDOW(4); 1767 EL3WINDOW(4);
1740 inb(ioaddr + 12); 1768 ioread8(ioaddr + 12);
1741 /* ..and on the Boomerang we enable the extra statistics bits. */ 1769 /* ..and on the Boomerang we enable the extra statistics bits. */
1742 outw(0x0040, ioaddr + Wn4_NetDiag); 1770 iowrite16(0x0040, ioaddr + Wn4_NetDiag);
1743 1771
1744 /* Switch to register set 7 for normal use. */ 1772 /* Switch to register set 7 for normal use. */
1745 EL3WINDOW(7); 1773 EL3WINDOW(7);
@@ -1747,30 +1775,30 @@ vortex_up(struct net_device *dev)
1747 if (vp->full_bus_master_rx) { /* Boomerang bus master. */ 1775 if (vp->full_bus_master_rx) { /* Boomerang bus master. */
1748 vp->cur_rx = vp->dirty_rx = 0; 1776 vp->cur_rx = vp->dirty_rx = 0;
1749 /* Initialize the RxEarly register as recommended. */ 1777 /* Initialize the RxEarly register as recommended. */
1750 outw(SetRxThreshold + (1536>>2), ioaddr + EL3_CMD); 1778 iowrite16(SetRxThreshold + (1536>>2), ioaddr + EL3_CMD);
1751 outl(0x0020, ioaddr + PktStatus); 1779 iowrite32(0x0020, ioaddr + PktStatus);
1752 outl(vp->rx_ring_dma, ioaddr + UpListPtr); 1780 iowrite32(vp->rx_ring_dma, ioaddr + UpListPtr);
1753 } 1781 }
1754 if (vp->full_bus_master_tx) { /* Boomerang bus master Tx. */ 1782 if (vp->full_bus_master_tx) { /* Boomerang bus master Tx. */
1755 vp->cur_tx = vp->dirty_tx = 0; 1783 vp->cur_tx = vp->dirty_tx = 0;
1756 if (vp->drv_flags & IS_BOOMERANG) 1784 if (vp->drv_flags & IS_BOOMERANG)
1757 outb(PKT_BUF_SZ>>8, ioaddr + TxFreeThreshold); /* Room for a packet. */ 1785 iowrite8(PKT_BUF_SZ>>8, ioaddr + TxFreeThreshold); /* Room for a packet. */
1758 /* Clear the Rx, Tx rings. */ 1786 /* Clear the Rx, Tx rings. */
1759 for (i = 0; i < RX_RING_SIZE; i++) /* AKPM: this is done in vortex_open, too */ 1787 for (i = 0; i < RX_RING_SIZE; i++) /* AKPM: this is done in vortex_open, too */
1760 vp->rx_ring[i].status = 0; 1788 vp->rx_ring[i].status = 0;
1761 for (i = 0; i < TX_RING_SIZE; i++) 1789 for (i = 0; i < TX_RING_SIZE; i++)
1762 vp->tx_skbuff[i] = NULL; 1790 vp->tx_skbuff[i] = NULL;
1763 outl(0, ioaddr + DownListPtr); 1791 iowrite32(0, ioaddr + DownListPtr);
1764 } 1792 }
1765 /* Set receiver mode: presumably accept b-case and phys addr only. */ 1793 /* Set receiver mode: presumably accept b-case and phys addr only. */
1766 set_rx_mode(dev); 1794 set_rx_mode(dev);
1767 /* enable 802.1q tagged frames */ 1795 /* enable 802.1q tagged frames */
1768 set_8021q_mode(dev, 1); 1796 set_8021q_mode(dev, 1);
1769 outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */ 1797 iowrite16(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */
1770 1798
1771// issue_and_wait(dev, SetTxStart|0x07ff); 1799// issue_and_wait(dev, SetTxStart|0x07ff);
1772 outw(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */ 1800 iowrite16(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */
1773 outw(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */ 1801 iowrite16(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */
1774 /* Allow status bits to be seen. */ 1802 /* Allow status bits to be seen. */
1775 vp->status_enable = SetStatusEnb | HostError|IntReq|StatsFull|TxComplete| 1803 vp->status_enable = SetStatusEnb | HostError|IntReq|StatsFull|TxComplete|
1776 (vp->full_bus_master_tx ? DownComplete : TxAvailable) | 1804 (vp->full_bus_master_tx ? DownComplete : TxAvailable) |
@@ -1780,13 +1808,13 @@ vortex_up(struct net_device *dev)
1780 (vp->full_bus_master_rx ? 0 : RxComplete) | 1808 (vp->full_bus_master_rx ? 0 : RxComplete) |
1781 StatsFull | HostError | TxComplete | IntReq 1809 StatsFull | HostError | TxComplete | IntReq
1782 | (vp->bus_master ? DMADone : 0) | UpComplete | DownComplete; 1810 | (vp->bus_master ? DMADone : 0) | UpComplete | DownComplete;
1783 outw(vp->status_enable, ioaddr + EL3_CMD); 1811 iowrite16(vp->status_enable, ioaddr + EL3_CMD);
1784 /* Ack all pending events, and set active indicator mask. */ 1812 /* Ack all pending events, and set active indicator mask. */
1785 outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq, 1813 iowrite16(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
1786 ioaddr + EL3_CMD); 1814 ioaddr + EL3_CMD);
1787 outw(vp->intr_enable, ioaddr + EL3_CMD); 1815 iowrite16(vp->intr_enable, ioaddr + EL3_CMD);
1788 if (vp->cb_fn_base) /* The PCMCIA people are idiots. */ 1816 if (vp->cb_fn_base) /* The PCMCIA people are idiots. */
1789 writel(0x8000, vp->cb_fn_base + 4); 1817 iowrite32(0x8000, vp->cb_fn_base + 4);
1790 netif_start_queue (dev); 1818 netif_start_queue (dev);
1791} 1819}
1792 1820
@@ -1852,7 +1880,7 @@ vortex_timer(unsigned long data)
1852{ 1880{
1853 struct net_device *dev = (struct net_device *)data; 1881 struct net_device *dev = (struct net_device *)data;
1854 struct vortex_private *vp = netdev_priv(dev); 1882 struct vortex_private *vp = netdev_priv(dev);
1855 long ioaddr = dev->base_addr; 1883 void __iomem *ioaddr = vp->ioaddr;
1856 int next_tick = 60*HZ; 1884 int next_tick = 60*HZ;
1857 int ok = 0; 1885 int ok = 0;
1858 int media_status, mii_status, old_window; 1886 int media_status, mii_status, old_window;
@@ -1866,9 +1894,9 @@ vortex_timer(unsigned long data)
1866 if (vp->medialock) 1894 if (vp->medialock)
1867 goto leave_media_alone; 1895 goto leave_media_alone;
1868 disable_irq(dev->irq); 1896 disable_irq(dev->irq);
1869 old_window = inw(ioaddr + EL3_CMD) >> 13; 1897 old_window = ioread16(ioaddr + EL3_CMD) >> 13;
1870 EL3WINDOW(4); 1898 EL3WINDOW(4);
1871 media_status = inw(ioaddr + Wn4_Media); 1899 media_status = ioread16(ioaddr + Wn4_Media);
1872 switch (dev->if_port) { 1900 switch (dev->if_port) {
1873 case XCVR_10baseT: case XCVR_100baseTx: case XCVR_100baseFx: 1901 case XCVR_10baseT: case XCVR_100baseTx: case XCVR_100baseFx:
1874 if (media_status & Media_LnkBeat) { 1902 if (media_status & Media_LnkBeat) {
@@ -1888,14 +1916,17 @@ vortex_timer(unsigned long data)
1888 case XCVR_MII: case XCVR_NWAY: 1916 case XCVR_MII: case XCVR_NWAY:
1889 { 1917 {
1890 spin_lock_bh(&vp->lock); 1918 spin_lock_bh(&vp->lock);
1891 mii_status = mdio_read(dev, vp->phys[0], 1); 1919 mii_status = mdio_read(dev, vp->phys[0], MII_BMSR);
1892 mii_status = mdio_read(dev, vp->phys[0], 1); 1920 if (!(mii_status & BMSR_LSTATUS)) {
1921 /* Re-read to get actual link status */
1922 mii_status = mdio_read(dev, vp->phys[0], MII_BMSR);
1923 }
1893 ok = 1; 1924 ok = 1;
1894 if (vortex_debug > 2) 1925 if (vortex_debug > 2)
1895 printk(KERN_DEBUG "%s: MII transceiver has status %4.4x.\n", 1926 printk(KERN_DEBUG "%s: MII transceiver has status %4.4x.\n",
1896 dev->name, mii_status); 1927 dev->name, mii_status);
1897 if (mii_status & BMSR_LSTATUS) { 1928 if (mii_status & BMSR_LSTATUS) {
1898 int mii_reg5 = mdio_read(dev, vp->phys[0], 5); 1929 int mii_reg5 = mdio_read(dev, vp->phys[0], MII_LPA);
1899 if (! vp->force_fd && mii_reg5 != 0xffff) { 1930 if (! vp->force_fd && mii_reg5 != 0xffff) {
1900 int duplex; 1931 int duplex;
1901 1932
@@ -1909,7 +1940,7 @@ vortex_timer(unsigned long data)
1909 vp->phys[0], mii_reg5); 1940 vp->phys[0], mii_reg5);
1910 /* Set the full-duplex bit. */ 1941 /* Set the full-duplex bit. */
1911 EL3WINDOW(3); 1942 EL3WINDOW(3);
1912 outw( (vp->full_duplex ? 0x20 : 0) | 1943 iowrite16( (vp->full_duplex ? 0x20 : 0) |
1913 (vp->large_frames ? 0x40 : 0) | 1944 (vp->large_frames ? 0x40 : 0) |
1914 ((vp->full_duplex && vp->flow_ctrl && vp->partner_flow_ctrl) ? 0x100 : 0), 1945 ((vp->full_duplex && vp->flow_ctrl && vp->partner_flow_ctrl) ? 0x100 : 0),
1915 ioaddr + Wn3_MAC_Ctrl); 1946 ioaddr + Wn3_MAC_Ctrl);
@@ -1950,15 +1981,15 @@ vortex_timer(unsigned long data)
1950 dev->name, media_tbl[dev->if_port].name); 1981 dev->name, media_tbl[dev->if_port].name);
1951 next_tick = media_tbl[dev->if_port].wait; 1982 next_tick = media_tbl[dev->if_port].wait;
1952 } 1983 }
1953 outw((media_status & ~(Media_10TP|Media_SQE)) | 1984 iowrite16((media_status & ~(Media_10TP|Media_SQE)) |
1954 media_tbl[dev->if_port].media_bits, ioaddr + Wn4_Media); 1985 media_tbl[dev->if_port].media_bits, ioaddr + Wn4_Media);
1955 1986
1956 EL3WINDOW(3); 1987 EL3WINDOW(3);
1957 config = inl(ioaddr + Wn3_Config); 1988 config = ioread32(ioaddr + Wn3_Config);
1958 config = BFINS(config, dev->if_port, 20, 4); 1989 config = BFINS(config, dev->if_port, 20, 4);
1959 outl(config, ioaddr + Wn3_Config); 1990 iowrite32(config, ioaddr + Wn3_Config);
1960 1991
1961 outw(dev->if_port == XCVR_10base2 ? StartCoax : StopCoax, 1992 iowrite16(dev->if_port == XCVR_10base2 ? StartCoax : StopCoax,
1962 ioaddr + EL3_CMD); 1993 ioaddr + EL3_CMD);
1963 if (vortex_debug > 1) 1994 if (vortex_debug > 1)
1964 printk(KERN_DEBUG "wrote 0x%08x to Wn3_Config\n", config); 1995 printk(KERN_DEBUG "wrote 0x%08x to Wn3_Config\n", config);
@@ -1974,29 +2005,29 @@ leave_media_alone:
1974 2005
1975 mod_timer(&vp->timer, RUN_AT(next_tick)); 2006 mod_timer(&vp->timer, RUN_AT(next_tick));
1976 if (vp->deferred) 2007 if (vp->deferred)
1977 outw(FakeIntr, ioaddr + EL3_CMD); 2008 iowrite16(FakeIntr, ioaddr + EL3_CMD);
1978 return; 2009 return;
1979} 2010}
1980 2011
1981static void vortex_tx_timeout(struct net_device *dev) 2012static void vortex_tx_timeout(struct net_device *dev)
1982{ 2013{
1983 struct vortex_private *vp = netdev_priv(dev); 2014 struct vortex_private *vp = netdev_priv(dev);
1984 long ioaddr = dev->base_addr; 2015 void __iomem *ioaddr = vp->ioaddr;
1985 2016
1986 printk(KERN_ERR "%s: transmit timed out, tx_status %2.2x status %4.4x.\n", 2017 printk(KERN_ERR "%s: transmit timed out, tx_status %2.2x status %4.4x.\n",
1987 dev->name, inb(ioaddr + TxStatus), 2018 dev->name, ioread8(ioaddr + TxStatus),
1988 inw(ioaddr + EL3_STATUS)); 2019 ioread16(ioaddr + EL3_STATUS));
1989 EL3WINDOW(4); 2020 EL3WINDOW(4);
1990 printk(KERN_ERR " diagnostics: net %04x media %04x dma %08x fifo %04x\n", 2021 printk(KERN_ERR " diagnostics: net %04x media %04x dma %08x fifo %04x\n",
1991 inw(ioaddr + Wn4_NetDiag), 2022 ioread16(ioaddr + Wn4_NetDiag),
1992 inw(ioaddr + Wn4_Media), 2023 ioread16(ioaddr + Wn4_Media),
1993 inl(ioaddr + PktStatus), 2024 ioread32(ioaddr + PktStatus),
1994 inw(ioaddr + Wn4_FIFODiag)); 2025 ioread16(ioaddr + Wn4_FIFODiag));
1995 /* Slight code bloat to be user friendly. */ 2026 /* Slight code bloat to be user friendly. */
1996 if ((inb(ioaddr + TxStatus) & 0x88) == 0x88) 2027 if ((ioread8(ioaddr + TxStatus) & 0x88) == 0x88)
1997 printk(KERN_ERR "%s: Transmitter encountered 16 collisions --" 2028 printk(KERN_ERR "%s: Transmitter encountered 16 collisions --"
1998 " network cable problem?\n", dev->name); 2029 " network cable problem?\n", dev->name);
1999 if (inw(ioaddr + EL3_STATUS) & IntLatch) { 2030 if (ioread16(ioaddr + EL3_STATUS) & IntLatch) {
2000 printk(KERN_ERR "%s: Interrupt posted but not delivered --" 2031 printk(KERN_ERR "%s: Interrupt posted but not delivered --"
2001 " IRQ blocked by another device?\n", dev->name); 2032 " IRQ blocked by another device?\n", dev->name);
2002 /* Bad idea here.. but we might as well handle a few events. */ 2033 /* Bad idea here.. but we might as well handle a few events. */
@@ -2022,21 +2053,21 @@ static void vortex_tx_timeout(struct net_device *dev)
2022 vp->stats.tx_errors++; 2053 vp->stats.tx_errors++;
2023 if (vp->full_bus_master_tx) { 2054 if (vp->full_bus_master_tx) {
2024 printk(KERN_DEBUG "%s: Resetting the Tx ring pointer.\n", dev->name); 2055 printk(KERN_DEBUG "%s: Resetting the Tx ring pointer.\n", dev->name);
2025 if (vp->cur_tx - vp->dirty_tx > 0 && inl(ioaddr + DownListPtr) == 0) 2056 if (vp->cur_tx - vp->dirty_tx > 0 && ioread32(ioaddr + DownListPtr) == 0)
2026 outl(vp->tx_ring_dma + (vp->dirty_tx % TX_RING_SIZE) * sizeof(struct boom_tx_desc), 2057 iowrite32(vp->tx_ring_dma + (vp->dirty_tx % TX_RING_SIZE) * sizeof(struct boom_tx_desc),
2027 ioaddr + DownListPtr); 2058 ioaddr + DownListPtr);
2028 if (vp->cur_tx - vp->dirty_tx < TX_RING_SIZE) 2059 if (vp->cur_tx - vp->dirty_tx < TX_RING_SIZE)
2029 netif_wake_queue (dev); 2060 netif_wake_queue (dev);
2030 if (vp->drv_flags & IS_BOOMERANG) 2061 if (vp->drv_flags & IS_BOOMERANG)
2031 outb(PKT_BUF_SZ>>8, ioaddr + TxFreeThreshold); 2062 iowrite8(PKT_BUF_SZ>>8, ioaddr + TxFreeThreshold);
2032 outw(DownUnstall, ioaddr + EL3_CMD); 2063 iowrite16(DownUnstall, ioaddr + EL3_CMD);
2033 } else { 2064 } else {
2034 vp->stats.tx_dropped++; 2065 vp->stats.tx_dropped++;
2035 netif_wake_queue(dev); 2066 netif_wake_queue(dev);
2036 } 2067 }
2037 2068
2038 /* Issue Tx Enable */ 2069 /* Issue Tx Enable */
2039 outw(TxEnable, ioaddr + EL3_CMD); 2070 iowrite16(TxEnable, ioaddr + EL3_CMD);
2040 dev->trans_start = jiffies; 2071 dev->trans_start = jiffies;
2041 2072
2042 /* Switch to register set 7 for normal use. */ 2073 /* Switch to register set 7 for normal use. */
@@ -2051,7 +2082,7 @@ static void
2051vortex_error(struct net_device *dev, int status) 2082vortex_error(struct net_device *dev, int status)
2052{ 2083{
2053 struct vortex_private *vp = netdev_priv(dev); 2084 struct vortex_private *vp = netdev_priv(dev);
2054 long ioaddr = dev->base_addr; 2085 void __iomem *ioaddr = vp->ioaddr;
2055 int do_tx_reset = 0, reset_mask = 0; 2086 int do_tx_reset = 0, reset_mask = 0;
2056 unsigned char tx_status = 0; 2087 unsigned char tx_status = 0;
2057 2088
@@ -2060,7 +2091,7 @@ vortex_error(struct net_device *dev, int status)
2060 } 2091 }
2061 2092
2062 if (status & TxComplete) { /* Really "TxError" for us. */ 2093 if (status & TxComplete) { /* Really "TxError" for us. */
2063 tx_status = inb(ioaddr + TxStatus); 2094 tx_status = ioread8(ioaddr + TxStatus);
2064 /* Presumably a tx-timeout. We must merely re-enable. */ 2095 /* Presumably a tx-timeout. We must merely re-enable. */
2065 if (vortex_debug > 2 2096 if (vortex_debug > 2
2066 || (tx_status != 0x88 && vortex_debug > 0)) { 2097 || (tx_status != 0x88 && vortex_debug > 0)) {
@@ -2074,20 +2105,20 @@ vortex_error(struct net_device *dev, int status)
2074 } 2105 }
2075 if (tx_status & 0x14) vp->stats.tx_fifo_errors++; 2106 if (tx_status & 0x14) vp->stats.tx_fifo_errors++;
2076 if (tx_status & 0x38) vp->stats.tx_aborted_errors++; 2107 if (tx_status & 0x38) vp->stats.tx_aborted_errors++;
2077 outb(0, ioaddr + TxStatus); 2108 iowrite8(0, ioaddr + TxStatus);
2078 if (tx_status & 0x30) { /* txJabber or txUnderrun */ 2109 if (tx_status & 0x30) { /* txJabber or txUnderrun */
2079 do_tx_reset = 1; 2110 do_tx_reset = 1;
2080 } else if ((tx_status & 0x08) && (vp->drv_flags & MAX_COLLISION_RESET)) { /* maxCollisions */ 2111 } else if ((tx_status & 0x08) && (vp->drv_flags & MAX_COLLISION_RESET)) { /* maxCollisions */
2081 do_tx_reset = 1; 2112 do_tx_reset = 1;
2082 reset_mask = 0x0108; /* Reset interface logic, but not download logic */ 2113 reset_mask = 0x0108; /* Reset interface logic, but not download logic */
2083 } else { /* Merely re-enable the transmitter. */ 2114 } else { /* Merely re-enable the transmitter. */
2084 outw(TxEnable, ioaddr + EL3_CMD); 2115 iowrite16(TxEnable, ioaddr + EL3_CMD);
2085 } 2116 }
2086 } 2117 }
2087 2118
2088 if (status & RxEarly) { /* Rx early is unused. */ 2119 if (status & RxEarly) { /* Rx early is unused. */
2089 vortex_rx(dev); 2120 vortex_rx(dev);
2090 outw(AckIntr | RxEarly, ioaddr + EL3_CMD); 2121 iowrite16(AckIntr | RxEarly, ioaddr + EL3_CMD);
2091 } 2122 }
2092 if (status & StatsFull) { /* Empty statistics. */ 2123 if (status & StatsFull) { /* Empty statistics. */
2093 static int DoneDidThat; 2124 static int DoneDidThat;
@@ -2097,29 +2128,29 @@ vortex_error(struct net_device *dev, int status)
2097 /* HACK: Disable statistics as an interrupt source. */ 2128 /* HACK: Disable statistics as an interrupt source. */
2098 /* This occurs when we have the wrong media type! */ 2129 /* This occurs when we have the wrong media type! */
2099 if (DoneDidThat == 0 && 2130 if (DoneDidThat == 0 &&
2100 inw(ioaddr + EL3_STATUS) & StatsFull) { 2131 ioread16(ioaddr + EL3_STATUS) & StatsFull) {
2101 printk(KERN_WARNING "%s: Updating statistics failed, disabling " 2132 printk(KERN_WARNING "%s: Updating statistics failed, disabling "
2102 "stats as an interrupt source.\n", dev->name); 2133 "stats as an interrupt source.\n", dev->name);
2103 EL3WINDOW(5); 2134 EL3WINDOW(5);
2104 outw(SetIntrEnb | (inw(ioaddr + 10) & ~StatsFull), ioaddr + EL3_CMD); 2135 iowrite16(SetIntrEnb | (ioread16(ioaddr + 10) & ~StatsFull), ioaddr + EL3_CMD);
2105 vp->intr_enable &= ~StatsFull; 2136 vp->intr_enable &= ~StatsFull;
2106 EL3WINDOW(7); 2137 EL3WINDOW(7);
2107 DoneDidThat++; 2138 DoneDidThat++;
2108 } 2139 }
2109 } 2140 }
2110 if (status & IntReq) { /* Restore all interrupt sources. */ 2141 if (status & IntReq) { /* Restore all interrupt sources. */
2111 outw(vp->status_enable, ioaddr + EL3_CMD); 2142 iowrite16(vp->status_enable, ioaddr + EL3_CMD);
2112 outw(vp->intr_enable, ioaddr + EL3_CMD); 2143 iowrite16(vp->intr_enable, ioaddr + EL3_CMD);
2113 } 2144 }
2114 if (status & HostError) { 2145 if (status & HostError) {
2115 u16 fifo_diag; 2146 u16 fifo_diag;
2116 EL3WINDOW(4); 2147 EL3WINDOW(4);
2117 fifo_diag = inw(ioaddr + Wn4_FIFODiag); 2148 fifo_diag = ioread16(ioaddr + Wn4_FIFODiag);
2118 printk(KERN_ERR "%s: Host error, FIFO diagnostic register %4.4x.\n", 2149 printk(KERN_ERR "%s: Host error, FIFO diagnostic register %4.4x.\n",
2119 dev->name, fifo_diag); 2150 dev->name, fifo_diag);
2120 /* Adapter failure requires Tx/Rx reset and reinit. */ 2151 /* Adapter failure requires Tx/Rx reset and reinit. */
2121 if (vp->full_bus_master_tx) { 2152 if (vp->full_bus_master_tx) {
2122 int bus_status = inl(ioaddr + PktStatus); 2153 int bus_status = ioread32(ioaddr + PktStatus);
2123 /* 0x80000000 PCI master abort. */ 2154 /* 0x80000000 PCI master abort. */
2124 /* 0x40000000 PCI target abort. */ 2155 /* 0x40000000 PCI target abort. */
2125 if (vortex_debug) 2156 if (vortex_debug)
@@ -2139,14 +2170,14 @@ vortex_error(struct net_device *dev, int status)
2139 set_rx_mode(dev); 2170 set_rx_mode(dev);
2140 /* enable 802.1q VLAN tagged frames */ 2171 /* enable 802.1q VLAN tagged frames */
2141 set_8021q_mode(dev, 1); 2172 set_8021q_mode(dev, 1);
2142 outw(RxEnable, ioaddr + EL3_CMD); /* Re-enable the receiver. */ 2173 iowrite16(RxEnable, ioaddr + EL3_CMD); /* Re-enable the receiver. */
2143 outw(AckIntr | HostError, ioaddr + EL3_CMD); 2174 iowrite16(AckIntr | HostError, ioaddr + EL3_CMD);
2144 } 2175 }
2145 } 2176 }
2146 2177
2147 if (do_tx_reset) { 2178 if (do_tx_reset) {
2148 issue_and_wait(dev, TxReset|reset_mask); 2179 issue_and_wait(dev, TxReset|reset_mask);
2149 outw(TxEnable, ioaddr + EL3_CMD); 2180 iowrite16(TxEnable, ioaddr + EL3_CMD);
2150 if (!vp->full_bus_master_tx) 2181 if (!vp->full_bus_master_tx)
2151 netif_wake_queue(dev); 2182 netif_wake_queue(dev);
2152 } 2183 }
@@ -2156,29 +2187,29 @@ static int
2156vortex_start_xmit(struct sk_buff *skb, struct net_device *dev) 2187vortex_start_xmit(struct sk_buff *skb, struct net_device *dev)
2157{ 2188{
2158 struct vortex_private *vp = netdev_priv(dev); 2189 struct vortex_private *vp = netdev_priv(dev);
2159 long ioaddr = dev->base_addr; 2190 void __iomem *ioaddr = vp->ioaddr;
2160 2191
2161 /* Put out the doubleword header... */ 2192 /* Put out the doubleword header... */
2162 outl(skb->len, ioaddr + TX_FIFO); 2193 iowrite32(skb->len, ioaddr + TX_FIFO);
2163 if (vp->bus_master) { 2194 if (vp->bus_master) {
2164 /* Set the bus-master controller to transfer the packet. */ 2195 /* Set the bus-master controller to transfer the packet. */
2165 int len = (skb->len + 3) & ~3; 2196 int len = (skb->len + 3) & ~3;
2166 outl( vp->tx_skb_dma = pci_map_single(VORTEX_PCI(vp), skb->data, len, PCI_DMA_TODEVICE), 2197 iowrite32( vp->tx_skb_dma = pci_map_single(VORTEX_PCI(vp), skb->data, len, PCI_DMA_TODEVICE),
2167 ioaddr + Wn7_MasterAddr); 2198 ioaddr + Wn7_MasterAddr);
2168 outw(len, ioaddr + Wn7_MasterLen); 2199 iowrite16(len, ioaddr + Wn7_MasterLen);
2169 vp->tx_skb = skb; 2200 vp->tx_skb = skb;
2170 outw(StartDMADown, ioaddr + EL3_CMD); 2201 iowrite16(StartDMADown, ioaddr + EL3_CMD);
2171 /* netif_wake_queue() will be called at the DMADone interrupt. */ 2202 /* netif_wake_queue() will be called at the DMADone interrupt. */
2172 } else { 2203 } else {
2173 /* ... and the packet rounded to a doubleword. */ 2204 /* ... and the packet rounded to a doubleword. */
2174 outsl(ioaddr + TX_FIFO, skb->data, (skb->len + 3) >> 2); 2205 iowrite32_rep(ioaddr + TX_FIFO, skb->data, (skb->len + 3) >> 2);
2175 dev_kfree_skb (skb); 2206 dev_kfree_skb (skb);
2176 if (inw(ioaddr + TxFree) > 1536) { 2207 if (ioread16(ioaddr + TxFree) > 1536) {
2177 netif_start_queue (dev); /* AKPM: redundant? */ 2208 netif_start_queue (dev); /* AKPM: redundant? */
2178 } else { 2209 } else {
2179 /* Interrupt us when the FIFO has room for max-sized packet. */ 2210 /* Interrupt us when the FIFO has room for max-sized packet. */
2180 netif_stop_queue(dev); 2211 netif_stop_queue(dev);
2181 outw(SetTxThreshold + (1536>>2), ioaddr + EL3_CMD); 2212 iowrite16(SetTxThreshold + (1536>>2), ioaddr + EL3_CMD);
2182 } 2213 }
2183 } 2214 }
2184 2215
@@ -2189,7 +2220,7 @@ vortex_start_xmit(struct sk_buff *skb, struct net_device *dev)
2189 int tx_status; 2220 int tx_status;
2190 int i = 32; 2221 int i = 32;
2191 2222
2192 while (--i > 0 && (tx_status = inb(ioaddr + TxStatus)) > 0) { 2223 while (--i > 0 && (tx_status = ioread8(ioaddr + TxStatus)) > 0) {
2193 if (tx_status & 0x3C) { /* A Tx-disabling error occurred. */ 2224 if (tx_status & 0x3C) { /* A Tx-disabling error occurred. */
2194 if (vortex_debug > 2) 2225 if (vortex_debug > 2)
2195 printk(KERN_DEBUG "%s: Tx error, status %2.2x.\n", 2226 printk(KERN_DEBUG "%s: Tx error, status %2.2x.\n",
@@ -2199,9 +2230,9 @@ vortex_start_xmit(struct sk_buff *skb, struct net_device *dev)
2199 if (tx_status & 0x30) { 2230 if (tx_status & 0x30) {
2200 issue_and_wait(dev, TxReset); 2231 issue_and_wait(dev, TxReset);
2201 } 2232 }
2202 outw(TxEnable, ioaddr + EL3_CMD); 2233 iowrite16(TxEnable, ioaddr + EL3_CMD);
2203 } 2234 }
2204 outb(0x00, ioaddr + TxStatus); /* Pop the status stack. */ 2235 iowrite8(0x00, ioaddr + TxStatus); /* Pop the status stack. */
2205 } 2236 }
2206 } 2237 }
2207 return 0; 2238 return 0;
@@ -2211,7 +2242,7 @@ static int
2211boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev) 2242boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev)
2212{ 2243{
2213 struct vortex_private *vp = netdev_priv(dev); 2244 struct vortex_private *vp = netdev_priv(dev);
2214 long ioaddr = dev->base_addr; 2245 void __iomem *ioaddr = vp->ioaddr;
2215 /* Calculate the next Tx descriptor entry. */ 2246 /* Calculate the next Tx descriptor entry. */
2216 int entry = vp->cur_tx % TX_RING_SIZE; 2247 int entry = vp->cur_tx % TX_RING_SIZE;
2217 struct boom_tx_desc *prev_entry = &vp->tx_ring[(vp->cur_tx-1) % TX_RING_SIZE]; 2248 struct boom_tx_desc *prev_entry = &vp->tx_ring[(vp->cur_tx-1) % TX_RING_SIZE];
@@ -2275,8 +2306,8 @@ boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev)
2275 /* Wait for the stall to complete. */ 2306 /* Wait for the stall to complete. */
2276 issue_and_wait(dev, DownStall); 2307 issue_and_wait(dev, DownStall);
2277 prev_entry->next = cpu_to_le32(vp->tx_ring_dma + entry * sizeof(struct boom_tx_desc)); 2308 prev_entry->next = cpu_to_le32(vp->tx_ring_dma + entry * sizeof(struct boom_tx_desc));
2278 if (inl(ioaddr + DownListPtr) == 0) { 2309 if (ioread32(ioaddr + DownListPtr) == 0) {
2279 outl(vp->tx_ring_dma + entry * sizeof(struct boom_tx_desc), ioaddr + DownListPtr); 2310 iowrite32(vp->tx_ring_dma + entry * sizeof(struct boom_tx_desc), ioaddr + DownListPtr);
2280 vp->queued_packet++; 2311 vp->queued_packet++;
2281 } 2312 }
2282 2313
@@ -2291,7 +2322,7 @@ boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev)
2291 prev_entry->status &= cpu_to_le32(~TxIntrUploaded); 2322 prev_entry->status &= cpu_to_le32(~TxIntrUploaded);
2292#endif 2323#endif
2293 } 2324 }
2294 outw(DownUnstall, ioaddr + EL3_CMD); 2325 iowrite16(DownUnstall, ioaddr + EL3_CMD);
2295 spin_unlock_irqrestore(&vp->lock, flags); 2326 spin_unlock_irqrestore(&vp->lock, flags);
2296 dev->trans_start = jiffies; 2327 dev->trans_start = jiffies;
2297 return 0; 2328 return 0;
@@ -2310,15 +2341,15 @@ vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2310{ 2341{
2311 struct net_device *dev = dev_id; 2342 struct net_device *dev = dev_id;
2312 struct vortex_private *vp = netdev_priv(dev); 2343 struct vortex_private *vp = netdev_priv(dev);
2313 long ioaddr; 2344 void __iomem *ioaddr;
2314 int status; 2345 int status;
2315 int work_done = max_interrupt_work; 2346 int work_done = max_interrupt_work;
2316 int handled = 0; 2347 int handled = 0;
2317 2348
2318 ioaddr = dev->base_addr; 2349 ioaddr = vp->ioaddr;
2319 spin_lock(&vp->lock); 2350 spin_lock(&vp->lock);
2320 2351
2321 status = inw(ioaddr + EL3_STATUS); 2352 status = ioread16(ioaddr + EL3_STATUS);
2322 2353
2323 if (vortex_debug > 6) 2354 if (vortex_debug > 6)
2324 printk("vortex_interrupt(). status=0x%4x\n", status); 2355 printk("vortex_interrupt(). status=0x%4x\n", status);
@@ -2337,7 +2368,7 @@ vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2337 2368
2338 if (vortex_debug > 4) 2369 if (vortex_debug > 4)
2339 printk(KERN_DEBUG "%s: interrupt, status %4.4x, latency %d ticks.\n", 2370 printk(KERN_DEBUG "%s: interrupt, status %4.4x, latency %d ticks.\n",
2340 dev->name, status, inb(ioaddr + Timer)); 2371 dev->name, status, ioread8(ioaddr + Timer));
2341 2372
2342 do { 2373 do {
2343 if (vortex_debug > 5) 2374 if (vortex_debug > 5)
@@ -2350,16 +2381,16 @@ vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2350 if (vortex_debug > 5) 2381 if (vortex_debug > 5)
2351 printk(KERN_DEBUG " TX room bit was handled.\n"); 2382 printk(KERN_DEBUG " TX room bit was handled.\n");
2352 /* There's room in the FIFO for a full-sized packet. */ 2383 /* There's room in the FIFO for a full-sized packet. */
2353 outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); 2384 iowrite16(AckIntr | TxAvailable, ioaddr + EL3_CMD);
2354 netif_wake_queue (dev); 2385 netif_wake_queue (dev);
2355 } 2386 }
2356 2387
2357 if (status & DMADone) { 2388 if (status & DMADone) {
2358 if (inw(ioaddr + Wn7_MasterStatus) & 0x1000) { 2389 if (ioread16(ioaddr + Wn7_MasterStatus) & 0x1000) {
2359 outw(0x1000, ioaddr + Wn7_MasterStatus); /* Ack the event. */ 2390 iowrite16(0x1000, ioaddr + Wn7_MasterStatus); /* Ack the event. */
2360 pci_unmap_single(VORTEX_PCI(vp), vp->tx_skb_dma, (vp->tx_skb->len + 3) & ~3, PCI_DMA_TODEVICE); 2391 pci_unmap_single(VORTEX_PCI(vp), vp->tx_skb_dma, (vp->tx_skb->len + 3) & ~3, PCI_DMA_TODEVICE);
2361 dev_kfree_skb_irq(vp->tx_skb); /* Release the transferred buffer */ 2392 dev_kfree_skb_irq(vp->tx_skb); /* Release the transferred buffer */
2362 if (inw(ioaddr + TxFree) > 1536) { 2393 if (ioread16(ioaddr + TxFree) > 1536) {
2363 /* 2394 /*
2364 * AKPM: FIXME: I don't think we need this. If the queue was stopped due to 2395 * AKPM: FIXME: I don't think we need this. If the queue was stopped due to
2365 * insufficient FIFO room, the TxAvailable test will succeed and call 2396 * insufficient FIFO room, the TxAvailable test will succeed and call
@@ -2367,7 +2398,7 @@ vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2367 */ 2398 */
2368 netif_wake_queue(dev); 2399 netif_wake_queue(dev);
2369 } else { /* Interrupt when FIFO has room for max-sized packet. */ 2400 } else { /* Interrupt when FIFO has room for max-sized packet. */
2370 outw(SetTxThreshold + (1536>>2), ioaddr + EL3_CMD); 2401 iowrite16(SetTxThreshold + (1536>>2), ioaddr + EL3_CMD);
2371 netif_stop_queue(dev); 2402 netif_stop_queue(dev);
2372 } 2403 }
2373 } 2404 }
@@ -2385,17 +2416,17 @@ vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2385 /* Disable all pending interrupts. */ 2416 /* Disable all pending interrupts. */
2386 do { 2417 do {
2387 vp->deferred |= status; 2418 vp->deferred |= status;
2388 outw(SetStatusEnb | (~vp->deferred & vp->status_enable), 2419 iowrite16(SetStatusEnb | (~vp->deferred & vp->status_enable),
2389 ioaddr + EL3_CMD); 2420 ioaddr + EL3_CMD);
2390 outw(AckIntr | (vp->deferred & 0x7ff), ioaddr + EL3_CMD); 2421 iowrite16(AckIntr | (vp->deferred & 0x7ff), ioaddr + EL3_CMD);
2391 } while ((status = inw(ioaddr + EL3_CMD)) & IntLatch); 2422 } while ((status = ioread16(ioaddr + EL3_CMD)) & IntLatch);
2392 /* The timer will reenable interrupts. */ 2423 /* The timer will reenable interrupts. */
2393 mod_timer(&vp->timer, jiffies + 1*HZ); 2424 mod_timer(&vp->timer, jiffies + 1*HZ);
2394 break; 2425 break;
2395 } 2426 }
2396 /* Acknowledge the IRQ. */ 2427 /* Acknowledge the IRQ. */
2397 outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); 2428 iowrite16(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD);
2398 } while ((status = inw(ioaddr + EL3_STATUS)) & (IntLatch | RxComplete)); 2429 } while ((status = ioread16(ioaddr + EL3_STATUS)) & (IntLatch | RxComplete));
2399 2430
2400 if (vortex_debug > 4) 2431 if (vortex_debug > 4)
2401 printk(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n", 2432 printk(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n",
@@ -2415,11 +2446,11 @@ boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2415{ 2446{
2416 struct net_device *dev = dev_id; 2447 struct net_device *dev = dev_id;
2417 struct vortex_private *vp = netdev_priv(dev); 2448 struct vortex_private *vp = netdev_priv(dev);
2418 long ioaddr; 2449 void __iomem *ioaddr;
2419 int status; 2450 int status;
2420 int work_done = max_interrupt_work; 2451 int work_done = max_interrupt_work;
2421 2452
2422 ioaddr = dev->base_addr; 2453 ioaddr = vp->ioaddr;
2423 2454
2424 /* 2455 /*
2425 * It seems dopey to put the spinlock this early, but we could race against vortex_tx_timeout 2456 * It seems dopey to put the spinlock this early, but we could race against vortex_tx_timeout
@@ -2427,7 +2458,7 @@ boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2427 */ 2458 */
2428 spin_lock(&vp->lock); 2459 spin_lock(&vp->lock);
2429 2460
2430 status = inw(ioaddr + EL3_STATUS); 2461 status = ioread16(ioaddr + EL3_STATUS);
2431 2462
2432 if (vortex_debug > 6) 2463 if (vortex_debug > 6)
2433 printk(KERN_DEBUG "boomerang_interrupt. status=0x%4x\n", status); 2464 printk(KERN_DEBUG "boomerang_interrupt. status=0x%4x\n", status);
@@ -2448,13 +2479,13 @@ boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2448 2479
2449 if (vortex_debug > 4) 2480 if (vortex_debug > 4)
2450 printk(KERN_DEBUG "%s: interrupt, status %4.4x, latency %d ticks.\n", 2481 printk(KERN_DEBUG "%s: interrupt, status %4.4x, latency %d ticks.\n",
2451 dev->name, status, inb(ioaddr + Timer)); 2482 dev->name, status, ioread8(ioaddr + Timer));
2452 do { 2483 do {
2453 if (vortex_debug > 5) 2484 if (vortex_debug > 5)
2454 printk(KERN_DEBUG "%s: In interrupt loop, status %4.4x.\n", 2485 printk(KERN_DEBUG "%s: In interrupt loop, status %4.4x.\n",
2455 dev->name, status); 2486 dev->name, status);
2456 if (status & UpComplete) { 2487 if (status & UpComplete) {
2457 outw(AckIntr | UpComplete, ioaddr + EL3_CMD); 2488 iowrite16(AckIntr | UpComplete, ioaddr + EL3_CMD);
2458 if (vortex_debug > 5) 2489 if (vortex_debug > 5)
2459 printk(KERN_DEBUG "boomerang_interrupt->boomerang_rx\n"); 2490 printk(KERN_DEBUG "boomerang_interrupt->boomerang_rx\n");
2460 boomerang_rx(dev); 2491 boomerang_rx(dev);
@@ -2463,11 +2494,11 @@ boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2463 if (status & DownComplete) { 2494 if (status & DownComplete) {
2464 unsigned int dirty_tx = vp->dirty_tx; 2495 unsigned int dirty_tx = vp->dirty_tx;
2465 2496
2466 outw(AckIntr | DownComplete, ioaddr + EL3_CMD); 2497 iowrite16(AckIntr | DownComplete, ioaddr + EL3_CMD);
2467 while (vp->cur_tx - dirty_tx > 0) { 2498 while (vp->cur_tx - dirty_tx > 0) {
2468 int entry = dirty_tx % TX_RING_SIZE; 2499 int entry = dirty_tx % TX_RING_SIZE;
2469#if 1 /* AKPM: the latter is faster, but cyclone-only */ 2500#if 1 /* AKPM: the latter is faster, but cyclone-only */
2470 if (inl(ioaddr + DownListPtr) == 2501 if (ioread32(ioaddr + DownListPtr) ==
2471 vp->tx_ring_dma + entry * sizeof(struct boom_tx_desc)) 2502 vp->tx_ring_dma + entry * sizeof(struct boom_tx_desc))
2472 break; /* It still hasn't been processed. */ 2503 break; /* It still hasn't been processed. */
2473#else 2504#else
@@ -2514,20 +2545,20 @@ boomerang_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2514 /* Disable all pending interrupts. */ 2545 /* Disable all pending interrupts. */
2515 do { 2546 do {
2516 vp->deferred |= status; 2547 vp->deferred |= status;
2517 outw(SetStatusEnb | (~vp->deferred & vp->status_enable), 2548 iowrite16(SetStatusEnb | (~vp->deferred & vp->status_enable),
2518 ioaddr + EL3_CMD); 2549 ioaddr + EL3_CMD);
2519 outw(AckIntr | (vp->deferred & 0x7ff), ioaddr + EL3_CMD); 2550 iowrite16(AckIntr | (vp->deferred & 0x7ff), ioaddr + EL3_CMD);
2520 } while ((status = inw(ioaddr + EL3_CMD)) & IntLatch); 2551 } while ((status = ioread16(ioaddr + EL3_CMD)) & IntLatch);
2521 /* The timer will reenable interrupts. */ 2552 /* The timer will reenable interrupts. */
2522 mod_timer(&vp->timer, jiffies + 1*HZ); 2553 mod_timer(&vp->timer, jiffies + 1*HZ);
2523 break; 2554 break;
2524 } 2555 }
2525 /* Acknowledge the IRQ. */ 2556 /* Acknowledge the IRQ. */
2526 outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); 2557 iowrite16(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD);
2527 if (vp->cb_fn_base) /* The PCMCIA people are idiots. */ 2558 if (vp->cb_fn_base) /* The PCMCIA people are idiots. */
2528 writel(0x8000, vp->cb_fn_base + 4); 2559 iowrite32(0x8000, vp->cb_fn_base + 4);
2529 2560
2530 } while ((status = inw(ioaddr + EL3_STATUS)) & IntLatch); 2561 } while ((status = ioread16(ioaddr + EL3_STATUS)) & IntLatch);
2531 2562
2532 if (vortex_debug > 4) 2563 if (vortex_debug > 4)
2533 printk(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n", 2564 printk(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n",
@@ -2540,16 +2571,16 @@ handler_exit:
2540static int vortex_rx(struct net_device *dev) 2571static int vortex_rx(struct net_device *dev)
2541{ 2572{
2542 struct vortex_private *vp = netdev_priv(dev); 2573 struct vortex_private *vp = netdev_priv(dev);
2543 long ioaddr = dev->base_addr; 2574 void __iomem *ioaddr = vp->ioaddr;
2544 int i; 2575 int i;
2545 short rx_status; 2576 short rx_status;
2546 2577
2547 if (vortex_debug > 5) 2578 if (vortex_debug > 5)
2548 printk(KERN_DEBUG "vortex_rx(): status %4.4x, rx_status %4.4x.\n", 2579 printk(KERN_DEBUG "vortex_rx(): status %4.4x, rx_status %4.4x.\n",
2549 inw(ioaddr+EL3_STATUS), inw(ioaddr+RxStatus)); 2580 ioread16(ioaddr+EL3_STATUS), ioread16(ioaddr+RxStatus));
2550 while ((rx_status = inw(ioaddr + RxStatus)) > 0) { 2581 while ((rx_status = ioread16(ioaddr + RxStatus)) > 0) {
2551 if (rx_status & 0x4000) { /* Error, update stats. */ 2582 if (rx_status & 0x4000) { /* Error, update stats. */
2552 unsigned char rx_error = inb(ioaddr + RxErrors); 2583 unsigned char rx_error = ioread8(ioaddr + RxErrors);
2553 if (vortex_debug > 2) 2584 if (vortex_debug > 2)
2554 printk(KERN_DEBUG " Rx error: status %2.2x.\n", rx_error); 2585 printk(KERN_DEBUG " Rx error: status %2.2x.\n", rx_error);
2555 vp->stats.rx_errors++; 2586 vp->stats.rx_errors++;
@@ -2572,34 +2603,35 @@ static int vortex_rx(struct net_device *dev)
2572 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 2603 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
2573 /* 'skb_put()' points to the start of sk_buff data area. */ 2604 /* 'skb_put()' points to the start of sk_buff data area. */
2574 if (vp->bus_master && 2605 if (vp->bus_master &&
2575 ! (inw(ioaddr + Wn7_MasterStatus) & 0x8000)) { 2606 ! (ioread16(ioaddr + Wn7_MasterStatus) & 0x8000)) {
2576 dma_addr_t dma = pci_map_single(VORTEX_PCI(vp), skb_put(skb, pkt_len), 2607 dma_addr_t dma = pci_map_single(VORTEX_PCI(vp), skb_put(skb, pkt_len),
2577 pkt_len, PCI_DMA_FROMDEVICE); 2608 pkt_len, PCI_DMA_FROMDEVICE);
2578 outl(dma, ioaddr + Wn7_MasterAddr); 2609 iowrite32(dma, ioaddr + Wn7_MasterAddr);
2579 outw((skb->len + 3) & ~3, ioaddr + Wn7_MasterLen); 2610 iowrite16((skb->len + 3) & ~3, ioaddr + Wn7_MasterLen);
2580 outw(StartDMAUp, ioaddr + EL3_CMD); 2611 iowrite16(StartDMAUp, ioaddr + EL3_CMD);
2581 while (inw(ioaddr + Wn7_MasterStatus) & 0x8000) 2612 while (ioread16(ioaddr + Wn7_MasterStatus) & 0x8000)
2582 ; 2613 ;
2583 pci_unmap_single(VORTEX_PCI(vp), dma, pkt_len, PCI_DMA_FROMDEVICE); 2614 pci_unmap_single(VORTEX_PCI(vp), dma, pkt_len, PCI_DMA_FROMDEVICE);
2584 } else { 2615 } else {
2585 insl(ioaddr + RX_FIFO, skb_put(skb, pkt_len), 2616 ioread32_rep(ioaddr + RX_FIFO,
2586 (pkt_len + 3) >> 2); 2617 skb_put(skb, pkt_len),
2618 (pkt_len + 3) >> 2);
2587 } 2619 }
2588 outw(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */ 2620 iowrite16(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */
2589 skb->protocol = eth_type_trans(skb, dev); 2621 skb->protocol = eth_type_trans(skb, dev);
2590 netif_rx(skb); 2622 netif_rx(skb);
2591 dev->last_rx = jiffies; 2623 dev->last_rx = jiffies;
2592 vp->stats.rx_packets++; 2624 vp->stats.rx_packets++;
2593 /* Wait a limited time to go to next packet. */ 2625 /* Wait a limited time to go to next packet. */
2594 for (i = 200; i >= 0; i--) 2626 for (i = 200; i >= 0; i--)
2595 if ( ! (inw(ioaddr + EL3_STATUS) & CmdInProgress)) 2627 if ( ! (ioread16(ioaddr + EL3_STATUS) & CmdInProgress))
2596 break; 2628 break;
2597 continue; 2629 continue;
2598 } else if (vortex_debug > 0) 2630 } else if (vortex_debug > 0)
2599 printk(KERN_NOTICE "%s: No memory to allocate a sk_buff of " 2631 printk(KERN_NOTICE "%s: No memory to allocate a sk_buff of "
2600 "size %d.\n", dev->name, pkt_len); 2632 "size %d.\n", dev->name, pkt_len);
2633 vp->stats.rx_dropped++;
2601 } 2634 }
2602 vp->stats.rx_dropped++;
2603 issue_and_wait(dev, RxDiscard); 2635 issue_and_wait(dev, RxDiscard);
2604 } 2636 }
2605 2637
@@ -2611,12 +2643,12 @@ boomerang_rx(struct net_device *dev)
2611{ 2643{
2612 struct vortex_private *vp = netdev_priv(dev); 2644 struct vortex_private *vp = netdev_priv(dev);
2613 int entry = vp->cur_rx % RX_RING_SIZE; 2645 int entry = vp->cur_rx % RX_RING_SIZE;
2614 long ioaddr = dev->base_addr; 2646 void __iomem *ioaddr = vp->ioaddr;
2615 int rx_status; 2647 int rx_status;
2616 int rx_work_limit = vp->dirty_rx + RX_RING_SIZE - vp->cur_rx; 2648 int rx_work_limit = vp->dirty_rx + RX_RING_SIZE - vp->cur_rx;
2617 2649
2618 if (vortex_debug > 5) 2650 if (vortex_debug > 5)
2619 printk(KERN_DEBUG "boomerang_rx(): status %4.4x\n", inw(ioaddr+EL3_STATUS)); 2651 printk(KERN_DEBUG "boomerang_rx(): status %4.4x\n", ioread16(ioaddr+EL3_STATUS));
2620 2652
2621 while ((rx_status = le32_to_cpu(vp->rx_ring[entry].status)) & RxDComplete){ 2653 while ((rx_status = le32_to_cpu(vp->rx_ring[entry].status)) & RxDComplete){
2622 if (--rx_work_limit < 0) 2654 if (--rx_work_limit < 0)
@@ -2699,7 +2731,7 @@ boomerang_rx(struct net_device *dev)
2699 vp->rx_skbuff[entry] = skb; 2731 vp->rx_skbuff[entry] = skb;
2700 } 2732 }
2701 vp->rx_ring[entry].status = 0; /* Clear complete bit. */ 2733 vp->rx_ring[entry].status = 0; /* Clear complete bit. */
2702 outw(UpUnstall, ioaddr + EL3_CMD); 2734 iowrite16(UpUnstall, ioaddr + EL3_CMD);
2703 } 2735 }
2704 return 0; 2736 return 0;
2705} 2737}
@@ -2728,7 +2760,7 @@ static void
2728vortex_down(struct net_device *dev, int final_down) 2760vortex_down(struct net_device *dev, int final_down)
2729{ 2761{
2730 struct vortex_private *vp = netdev_priv(dev); 2762 struct vortex_private *vp = netdev_priv(dev);
2731 long ioaddr = dev->base_addr; 2763 void __iomem *ioaddr = vp->ioaddr;
2732 2764
2733 netif_stop_queue (dev); 2765 netif_stop_queue (dev);
2734 2766
@@ -2736,26 +2768,26 @@ vortex_down(struct net_device *dev, int final_down)
2736 del_timer_sync(&vp->timer); 2768 del_timer_sync(&vp->timer);
2737 2769
2738 /* Turn off statistics ASAP. We update vp->stats below. */ 2770 /* Turn off statistics ASAP. We update vp->stats below. */
2739 outw(StatsDisable, ioaddr + EL3_CMD); 2771 iowrite16(StatsDisable, ioaddr + EL3_CMD);
2740 2772
2741 /* Disable the receiver and transmitter. */ 2773 /* Disable the receiver and transmitter. */
2742 outw(RxDisable, ioaddr + EL3_CMD); 2774 iowrite16(RxDisable, ioaddr + EL3_CMD);
2743 outw(TxDisable, ioaddr + EL3_CMD); 2775 iowrite16(TxDisable, ioaddr + EL3_CMD);
2744 2776
2745 /* Disable receiving 802.1q tagged frames */ 2777 /* Disable receiving 802.1q tagged frames */
2746 set_8021q_mode(dev, 0); 2778 set_8021q_mode(dev, 0);
2747 2779
2748 if (dev->if_port == XCVR_10base2) 2780 if (dev->if_port == XCVR_10base2)
2749 /* Turn off thinnet power. Green! */ 2781 /* Turn off thinnet power. Green! */
2750 outw(StopCoax, ioaddr + EL3_CMD); 2782 iowrite16(StopCoax, ioaddr + EL3_CMD);
2751 2783
2752 outw(SetIntrEnb | 0x0000, ioaddr + EL3_CMD); 2784 iowrite16(SetIntrEnb | 0x0000, ioaddr + EL3_CMD);
2753 2785
2754 update_stats(ioaddr, dev); 2786 update_stats(ioaddr, dev);
2755 if (vp->full_bus_master_rx) 2787 if (vp->full_bus_master_rx)
2756 outl(0, ioaddr + UpListPtr); 2788 iowrite32(0, ioaddr + UpListPtr);
2757 if (vp->full_bus_master_tx) 2789 if (vp->full_bus_master_tx)
2758 outl(0, ioaddr + DownListPtr); 2790 iowrite32(0, ioaddr + DownListPtr);
2759 2791
2760 if (final_down && VORTEX_PCI(vp)) { 2792 if (final_down && VORTEX_PCI(vp)) {
2761 vp->pm_state_valid = 1; 2793 vp->pm_state_valid = 1;
@@ -2768,7 +2800,7 @@ static int
2768vortex_close(struct net_device *dev) 2800vortex_close(struct net_device *dev)
2769{ 2801{
2770 struct vortex_private *vp = netdev_priv(dev); 2802 struct vortex_private *vp = netdev_priv(dev);
2771 long ioaddr = dev->base_addr; 2803 void __iomem *ioaddr = vp->ioaddr;
2772 int i; 2804 int i;
2773 2805
2774 if (netif_device_present(dev)) 2806 if (netif_device_present(dev))
@@ -2776,17 +2808,18 @@ vortex_close(struct net_device *dev)
2776 2808
2777 if (vortex_debug > 1) { 2809 if (vortex_debug > 1) {
2778 printk(KERN_DEBUG"%s: vortex_close() status %4.4x, Tx status %2.2x.\n", 2810 printk(KERN_DEBUG"%s: vortex_close() status %4.4x, Tx status %2.2x.\n",
2779 dev->name, inw(ioaddr + EL3_STATUS), inb(ioaddr + TxStatus)); 2811 dev->name, ioread16(ioaddr + EL3_STATUS), ioread8(ioaddr + TxStatus));
2780 printk(KERN_DEBUG "%s: vortex close stats: rx_nocopy %d rx_copy %d" 2812 printk(KERN_DEBUG "%s: vortex close stats: rx_nocopy %d rx_copy %d"
2781 " tx_queued %d Rx pre-checksummed %d.\n", 2813 " tx_queued %d Rx pre-checksummed %d.\n",
2782 dev->name, vp->rx_nocopy, vp->rx_copy, vp->queued_packet, vp->rx_csumhits); 2814 dev->name, vp->rx_nocopy, vp->rx_copy, vp->queued_packet, vp->rx_csumhits);
2783 } 2815 }
2784 2816
2785#if DO_ZEROCOPY 2817#if DO_ZEROCOPY
2786 if ( vp->rx_csumhits && 2818 if (vp->rx_csumhits &&
2787 ((vp->drv_flags & HAS_HWCKSM) == 0) && 2819 (vp->drv_flags & HAS_HWCKSM) == 0 &&
2788 (hw_checksums[vp->card_idx] == -1)) { 2820 (vp->card_idx >= MAX_UNITS || hw_checksums[vp->card_idx] == -1)) {
2789 printk(KERN_WARNING "%s supports hardware checksums, and we're not using them!\n", dev->name); 2821 printk(KERN_WARNING "%s supports hardware checksums, and we're "
2822 "not using them!\n", dev->name);
2790 } 2823 }
2791#endif 2824#endif
2792 2825
@@ -2830,18 +2863,18 @@ dump_tx_ring(struct net_device *dev)
2830{ 2863{
2831 if (vortex_debug > 0) { 2864 if (vortex_debug > 0) {
2832 struct vortex_private *vp = netdev_priv(dev); 2865 struct vortex_private *vp = netdev_priv(dev);
2833 long ioaddr = dev->base_addr; 2866 void __iomem *ioaddr = vp->ioaddr;
2834 2867
2835 if (vp->full_bus_master_tx) { 2868 if (vp->full_bus_master_tx) {
2836 int i; 2869 int i;
2837 int stalled = inl(ioaddr + PktStatus) & 0x04; /* Possible racy. But it's only debug stuff */ 2870 int stalled = ioread32(ioaddr + PktStatus) & 0x04; /* Possible racy. But it's only debug stuff */
2838 2871
2839 printk(KERN_ERR " Flags; bus-master %d, dirty %d(%d) current %d(%d)\n", 2872 printk(KERN_ERR " Flags; bus-master %d, dirty %d(%d) current %d(%d)\n",
2840 vp->full_bus_master_tx, 2873 vp->full_bus_master_tx,
2841 vp->dirty_tx, vp->dirty_tx % TX_RING_SIZE, 2874 vp->dirty_tx, vp->dirty_tx % TX_RING_SIZE,
2842 vp->cur_tx, vp->cur_tx % TX_RING_SIZE); 2875 vp->cur_tx, vp->cur_tx % TX_RING_SIZE);
2843 printk(KERN_ERR " Transmit list %8.8x vs. %p.\n", 2876 printk(KERN_ERR " Transmit list %8.8x vs. %p.\n",
2844 inl(ioaddr + DownListPtr), 2877 ioread32(ioaddr + DownListPtr),
2845 &vp->tx_ring[vp->dirty_tx % TX_RING_SIZE]); 2878 &vp->tx_ring[vp->dirty_tx % TX_RING_SIZE]);
2846 issue_and_wait(dev, DownStall); 2879 issue_and_wait(dev, DownStall);
2847 for (i = 0; i < TX_RING_SIZE; i++) { 2880 for (i = 0; i < TX_RING_SIZE; i++) {
@@ -2855,7 +2888,7 @@ dump_tx_ring(struct net_device *dev)
2855 le32_to_cpu(vp->tx_ring[i].status)); 2888 le32_to_cpu(vp->tx_ring[i].status));
2856 } 2889 }
2857 if (!stalled) 2890 if (!stalled)
2858 outw(DownUnstall, ioaddr + EL3_CMD); 2891 iowrite16(DownUnstall, ioaddr + EL3_CMD);
2859 } 2892 }
2860 } 2893 }
2861} 2894}
@@ -2863,11 +2896,12 @@ dump_tx_ring(struct net_device *dev)
2863static struct net_device_stats *vortex_get_stats(struct net_device *dev) 2896static struct net_device_stats *vortex_get_stats(struct net_device *dev)
2864{ 2897{
2865 struct vortex_private *vp = netdev_priv(dev); 2898 struct vortex_private *vp = netdev_priv(dev);
2899 void __iomem *ioaddr = vp->ioaddr;
2866 unsigned long flags; 2900 unsigned long flags;
2867 2901
2868 if (netif_device_present(dev)) { /* AKPM: Used to be netif_running */ 2902 if (netif_device_present(dev)) { /* AKPM: Used to be netif_running */
2869 spin_lock_irqsave (&vp->lock, flags); 2903 spin_lock_irqsave (&vp->lock, flags);
2870 update_stats(dev->base_addr, dev); 2904 update_stats(ioaddr, dev);
2871 spin_unlock_irqrestore (&vp->lock, flags); 2905 spin_unlock_irqrestore (&vp->lock, flags);
2872 } 2906 }
2873 return &vp->stats; 2907 return &vp->stats;
@@ -2880,37 +2914,37 @@ static struct net_device_stats *vortex_get_stats(struct net_device *dev)
2880 table. This is done by checking that the ASM (!) code generated uses 2914 table. This is done by checking that the ASM (!) code generated uses
2881 atomic updates with '+='. 2915 atomic updates with '+='.
2882 */ 2916 */
2883static void update_stats(long ioaddr, struct net_device *dev) 2917static void update_stats(void __iomem *ioaddr, struct net_device *dev)
2884{ 2918{
2885 struct vortex_private *vp = netdev_priv(dev); 2919 struct vortex_private *vp = netdev_priv(dev);
2886 int old_window = inw(ioaddr + EL3_CMD); 2920 int old_window = ioread16(ioaddr + EL3_CMD);
2887 2921
2888 if (old_window == 0xffff) /* Chip suspended or ejected. */ 2922 if (old_window == 0xffff) /* Chip suspended or ejected. */
2889 return; 2923 return;
2890 /* Unlike the 3c5x9 we need not turn off stats updates while reading. */ 2924 /* Unlike the 3c5x9 we need not turn off stats updates while reading. */
2891 /* Switch to the stats window, and read everything. */ 2925 /* Switch to the stats window, and read everything. */
2892 EL3WINDOW(6); 2926 EL3WINDOW(6);
2893 vp->stats.tx_carrier_errors += inb(ioaddr + 0); 2927 vp->stats.tx_carrier_errors += ioread8(ioaddr + 0);
2894 vp->stats.tx_heartbeat_errors += inb(ioaddr + 1); 2928 vp->stats.tx_heartbeat_errors += ioread8(ioaddr + 1);
2895 vp->stats.collisions += inb(ioaddr + 3); 2929 vp->stats.collisions += ioread8(ioaddr + 3);
2896 vp->stats.tx_window_errors += inb(ioaddr + 4); 2930 vp->stats.tx_window_errors += ioread8(ioaddr + 4);
2897 vp->stats.rx_fifo_errors += inb(ioaddr + 5); 2931 vp->stats.rx_fifo_errors += ioread8(ioaddr + 5);
2898 vp->stats.tx_packets += inb(ioaddr + 6); 2932 vp->stats.tx_packets += ioread8(ioaddr + 6);
2899 vp->stats.tx_packets += (inb(ioaddr + 9)&0x30) << 4; 2933 vp->stats.tx_packets += (ioread8(ioaddr + 9)&0x30) << 4;
2900 /* Rx packets */ inb(ioaddr + 7); /* Must read to clear */ 2934 /* Rx packets */ ioread8(ioaddr + 7); /* Must read to clear */
2901 /* Don't bother with register 9, an extension of registers 6&7. 2935 /* Don't bother with register 9, an extension of registers 6&7.
2902 If we do use the 6&7 values the atomic update assumption above 2936 If we do use the 6&7 values the atomic update assumption above
2903 is invalid. */ 2937 is invalid. */
2904 vp->stats.rx_bytes += inw(ioaddr + 10); 2938 vp->stats.rx_bytes += ioread16(ioaddr + 10);
2905 vp->stats.tx_bytes += inw(ioaddr + 12); 2939 vp->stats.tx_bytes += ioread16(ioaddr + 12);
2906 /* Extra stats for get_ethtool_stats() */ 2940 /* Extra stats for get_ethtool_stats() */
2907 vp->xstats.tx_multiple_collisions += inb(ioaddr + 2); 2941 vp->xstats.tx_multiple_collisions += ioread8(ioaddr + 2);
2908 vp->xstats.tx_deferred += inb(ioaddr + 8); 2942 vp->xstats.tx_deferred += ioread8(ioaddr + 8);
2909 EL3WINDOW(4); 2943 EL3WINDOW(4);
2910 vp->xstats.rx_bad_ssd += inb(ioaddr + 12); 2944 vp->xstats.rx_bad_ssd += ioread8(ioaddr + 12);
2911 2945
2912 { 2946 {
2913 u8 up = inb(ioaddr + 13); 2947 u8 up = ioread8(ioaddr + 13);
2914 vp->stats.rx_bytes += (up & 0x0f) << 16; 2948 vp->stats.rx_bytes += (up & 0x0f) << 16;
2915 vp->stats.tx_bytes += (up & 0xf0) << 12; 2949 vp->stats.tx_bytes += (up & 0xf0) << 12;
2916 } 2950 }
@@ -2922,7 +2956,7 @@ static void update_stats(long ioaddr, struct net_device *dev)
2922static int vortex_nway_reset(struct net_device *dev) 2956static int vortex_nway_reset(struct net_device *dev)
2923{ 2957{
2924 struct vortex_private *vp = netdev_priv(dev); 2958 struct vortex_private *vp = netdev_priv(dev);
2925 long ioaddr = dev->base_addr; 2959 void __iomem *ioaddr = vp->ioaddr;
2926 unsigned long flags; 2960 unsigned long flags;
2927 int rc; 2961 int rc;
2928 2962
@@ -2936,7 +2970,7 @@ static int vortex_nway_reset(struct net_device *dev)
2936static u32 vortex_get_link(struct net_device *dev) 2970static u32 vortex_get_link(struct net_device *dev)
2937{ 2971{
2938 struct vortex_private *vp = netdev_priv(dev); 2972 struct vortex_private *vp = netdev_priv(dev);
2939 long ioaddr = dev->base_addr; 2973 void __iomem *ioaddr = vp->ioaddr;
2940 unsigned long flags; 2974 unsigned long flags;
2941 int rc; 2975 int rc;
2942 2976
@@ -2950,7 +2984,7 @@ static u32 vortex_get_link(struct net_device *dev)
2950static int vortex_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2984static int vortex_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2951{ 2985{
2952 struct vortex_private *vp = netdev_priv(dev); 2986 struct vortex_private *vp = netdev_priv(dev);
2953 long ioaddr = dev->base_addr; 2987 void __iomem *ioaddr = vp->ioaddr;
2954 unsigned long flags; 2988 unsigned long flags;
2955 int rc; 2989 int rc;
2956 2990
@@ -2964,7 +2998,7 @@ static int vortex_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2964static int vortex_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2998static int vortex_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2965{ 2999{
2966 struct vortex_private *vp = netdev_priv(dev); 3000 struct vortex_private *vp = netdev_priv(dev);
2967 long ioaddr = dev->base_addr; 3001 void __iomem *ioaddr = vp->ioaddr;
2968 unsigned long flags; 3002 unsigned long flags;
2969 int rc; 3003 int rc;
2970 3004
@@ -2994,10 +3028,11 @@ static void vortex_get_ethtool_stats(struct net_device *dev,
2994 struct ethtool_stats *stats, u64 *data) 3028 struct ethtool_stats *stats, u64 *data)
2995{ 3029{
2996 struct vortex_private *vp = netdev_priv(dev); 3030 struct vortex_private *vp = netdev_priv(dev);
3031 void __iomem *ioaddr = vp->ioaddr;
2997 unsigned long flags; 3032 unsigned long flags;
2998 3033
2999 spin_lock_irqsave(&vp->lock, flags); 3034 spin_lock_irqsave(&vp->lock, flags);
3000 update_stats(dev->base_addr, dev); 3035 update_stats(ioaddr, dev);
3001 spin_unlock_irqrestore(&vp->lock, flags); 3036 spin_unlock_irqrestore(&vp->lock, flags);
3002 3037
3003 data[0] = vp->xstats.tx_deferred; 3038 data[0] = vp->xstats.tx_deferred;
@@ -3047,6 +3082,7 @@ static struct ethtool_ops vortex_ethtool_ops = {
3047 .set_settings = vortex_set_settings, 3082 .set_settings = vortex_set_settings,
3048 .get_link = vortex_get_link, 3083 .get_link = vortex_get_link,
3049 .nway_reset = vortex_nway_reset, 3084 .nway_reset = vortex_nway_reset,
3085 .get_perm_addr = ethtool_op_get_perm_addr,
3050}; 3086};
3051 3087
3052#ifdef CONFIG_PCI 3088#ifdef CONFIG_PCI
@@ -3057,7 +3093,7 @@ static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
3057{ 3093{
3058 int err; 3094 int err;
3059 struct vortex_private *vp = netdev_priv(dev); 3095 struct vortex_private *vp = netdev_priv(dev);
3060 long ioaddr = dev->base_addr; 3096 void __iomem *ioaddr = vp->ioaddr;
3061 unsigned long flags; 3097 unsigned long flags;
3062 int state = 0; 3098 int state = 0;
3063 3099
@@ -3085,7 +3121,8 @@ static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
3085 the chip has a very clean way to set the mode, unlike many others. */ 3121 the chip has a very clean way to set the mode, unlike many others. */
3086static void set_rx_mode(struct net_device *dev) 3122static void set_rx_mode(struct net_device *dev)
3087{ 3123{
3088 long ioaddr = dev->base_addr; 3124 struct vortex_private *vp = netdev_priv(dev);
3125 void __iomem *ioaddr = vp->ioaddr;
3089 int new_mode; 3126 int new_mode;
3090 3127
3091 if (dev->flags & IFF_PROMISC) { 3128 if (dev->flags & IFF_PROMISC) {
@@ -3097,7 +3134,7 @@ static void set_rx_mode(struct net_device *dev)
3097 } else 3134 } else
3098 new_mode = SetRxFilter | RxStation | RxBroadcast; 3135 new_mode = SetRxFilter | RxStation | RxBroadcast;
3099 3136
3100 outw(new_mode, ioaddr + EL3_CMD); 3137 iowrite16(new_mode, ioaddr + EL3_CMD);
3101} 3138}
3102 3139
3103#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 3140#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
@@ -3111,8 +3148,8 @@ static void set_rx_mode(struct net_device *dev)
3111static void set_8021q_mode(struct net_device *dev, int enable) 3148static void set_8021q_mode(struct net_device *dev, int enable)
3112{ 3149{
3113 struct vortex_private *vp = netdev_priv(dev); 3150 struct vortex_private *vp = netdev_priv(dev);
3114 long ioaddr = dev->base_addr; 3151 void __iomem *ioaddr = vp->ioaddr;
3115 int old_window = inw(ioaddr + EL3_CMD); 3152 int old_window = ioread16(ioaddr + EL3_CMD);
3116 int mac_ctrl; 3153 int mac_ctrl;
3117 3154
3118 if ((vp->drv_flags&IS_CYCLONE) || (vp->drv_flags&IS_TORNADO)) { 3155 if ((vp->drv_flags&IS_CYCLONE) || (vp->drv_flags&IS_TORNADO)) {
@@ -3124,24 +3161,24 @@ static void set_8021q_mode(struct net_device *dev, int enable)
3124 max_pkt_size += 4; /* 802.1Q VLAN tag */ 3161 max_pkt_size += 4; /* 802.1Q VLAN tag */
3125 3162
3126 EL3WINDOW(3); 3163 EL3WINDOW(3);
3127 outw(max_pkt_size, ioaddr+Wn3_MaxPktSize); 3164 iowrite16(max_pkt_size, ioaddr+Wn3_MaxPktSize);
3128 3165
3129 /* set VlanEtherType to let the hardware checksumming 3166 /* set VlanEtherType to let the hardware checksumming
3130 treat tagged frames correctly */ 3167 treat tagged frames correctly */
3131 EL3WINDOW(7); 3168 EL3WINDOW(7);
3132 outw(VLAN_ETHER_TYPE, ioaddr+Wn7_VlanEtherType); 3169 iowrite16(VLAN_ETHER_TYPE, ioaddr+Wn7_VlanEtherType);
3133 } else { 3170 } else {
3134 /* on older cards we have to enable large frames */ 3171 /* on older cards we have to enable large frames */
3135 3172
3136 vp->large_frames = dev->mtu > 1500 || enable; 3173 vp->large_frames = dev->mtu > 1500 || enable;
3137 3174
3138 EL3WINDOW(3); 3175 EL3WINDOW(3);
3139 mac_ctrl = inw(ioaddr+Wn3_MAC_Ctrl); 3176 mac_ctrl = ioread16(ioaddr+Wn3_MAC_Ctrl);
3140 if (vp->large_frames) 3177 if (vp->large_frames)
3141 mac_ctrl |= 0x40; 3178 mac_ctrl |= 0x40;
3142 else 3179 else
3143 mac_ctrl &= ~0x40; 3180 mac_ctrl &= ~0x40;
3144 outw(mac_ctrl, ioaddr+Wn3_MAC_Ctrl); 3181 iowrite16(mac_ctrl, ioaddr+Wn3_MAC_Ctrl);
3145 } 3182 }
3146 3183
3147 EL3WINDOW(old_window); 3184 EL3WINDOW(old_window);
@@ -3163,7 +3200,7 @@ static void set_8021q_mode(struct net_device *dev, int enable)
3163/* The maximum data clock rate is 2.5 Mhz. The minimum timing is usually 3200/* The maximum data clock rate is 2.5 Mhz. The minimum timing is usually
3164 met by back-to-back PCI I/O cycles, but we insert a delay to avoid 3201 met by back-to-back PCI I/O cycles, but we insert a delay to avoid
3165 "overclocking" issues. */ 3202 "overclocking" issues. */
3166#define mdio_delay() inl(mdio_addr) 3203#define mdio_delay() ioread32(mdio_addr)
3167 3204
3168#define MDIO_SHIFT_CLK 0x01 3205#define MDIO_SHIFT_CLK 0x01
3169#define MDIO_DIR_WRITE 0x04 3206#define MDIO_DIR_WRITE 0x04
@@ -3174,15 +3211,15 @@ static void set_8021q_mode(struct net_device *dev, int enable)
3174 3211
3175/* Generate the preamble required for initial synchronization and 3212/* Generate the preamble required for initial synchronization and
3176 a few older transceivers. */ 3213 a few older transceivers. */
3177static void mdio_sync(long ioaddr, int bits) 3214static void mdio_sync(void __iomem *ioaddr, int bits)
3178{ 3215{
3179 long mdio_addr = ioaddr + Wn4_PhysicalMgmt; 3216 void __iomem *mdio_addr = ioaddr + Wn4_PhysicalMgmt;
3180 3217
3181 /* Establish sync by sending at least 32 logic ones. */ 3218 /* Establish sync by sending at least 32 logic ones. */
3182 while (-- bits >= 0) { 3219 while (-- bits >= 0) {
3183 outw(MDIO_DATA_WRITE1, mdio_addr); 3220 iowrite16(MDIO_DATA_WRITE1, mdio_addr);
3184 mdio_delay(); 3221 mdio_delay();
3185 outw(MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr); 3222 iowrite16(MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
3186 mdio_delay(); 3223 mdio_delay();
3187 } 3224 }
3188} 3225}
@@ -3190,10 +3227,11 @@ static void mdio_sync(long ioaddr, int bits)
3190static int mdio_read(struct net_device *dev, int phy_id, int location) 3227static int mdio_read(struct net_device *dev, int phy_id, int location)
3191{ 3228{
3192 int i; 3229 int i;
3193 long ioaddr = dev->base_addr; 3230 struct vortex_private *vp = netdev_priv(dev);
3231 void __iomem *ioaddr = vp->ioaddr;
3194 int read_cmd = (0xf6 << 10) | (phy_id << 5) | location; 3232 int read_cmd = (0xf6 << 10) | (phy_id << 5) | location;
3195 unsigned int retval = 0; 3233 unsigned int retval = 0;
3196 long mdio_addr = ioaddr + Wn4_PhysicalMgmt; 3234 void __iomem *mdio_addr = ioaddr + Wn4_PhysicalMgmt;
3197 3235
3198 if (mii_preamble_required) 3236 if (mii_preamble_required)
3199 mdio_sync(ioaddr, 32); 3237 mdio_sync(ioaddr, 32);
@@ -3201,17 +3239,17 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)
3201 /* Shift the read command bits out. */ 3239 /* Shift the read command bits out. */
3202 for (i = 14; i >= 0; i--) { 3240 for (i = 14; i >= 0; i--) {
3203 int dataval = (read_cmd&(1<<i)) ? MDIO_DATA_WRITE1 : MDIO_DATA_WRITE0; 3241 int dataval = (read_cmd&(1<<i)) ? MDIO_DATA_WRITE1 : MDIO_DATA_WRITE0;
3204 outw(dataval, mdio_addr); 3242 iowrite16(dataval, mdio_addr);
3205 mdio_delay(); 3243 mdio_delay();
3206 outw(dataval | MDIO_SHIFT_CLK, mdio_addr); 3244 iowrite16(dataval | MDIO_SHIFT_CLK, mdio_addr);
3207 mdio_delay(); 3245 mdio_delay();
3208 } 3246 }
3209 /* Read the two transition, 16 data, and wire-idle bits. */ 3247 /* Read the two transition, 16 data, and wire-idle bits. */
3210 for (i = 19; i > 0; i--) { 3248 for (i = 19; i > 0; i--) {
3211 outw(MDIO_ENB_IN, mdio_addr); 3249 iowrite16(MDIO_ENB_IN, mdio_addr);
3212 mdio_delay(); 3250 mdio_delay();
3213 retval = (retval << 1) | ((inw(mdio_addr) & MDIO_DATA_READ) ? 1 : 0); 3251 retval = (retval << 1) | ((ioread16(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
3214 outw(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr); 3252 iowrite16(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
3215 mdio_delay(); 3253 mdio_delay();
3216 } 3254 }
3217 return retval & 0x20000 ? 0xffff : retval>>1 & 0xffff; 3255 return retval & 0x20000 ? 0xffff : retval>>1 & 0xffff;
@@ -3219,9 +3257,10 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)
3219 3257
3220static void mdio_write(struct net_device *dev, int phy_id, int location, int value) 3258static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
3221{ 3259{
3222 long ioaddr = dev->base_addr; 3260 struct vortex_private *vp = netdev_priv(dev);
3261 void __iomem *ioaddr = vp->ioaddr;
3223 int write_cmd = 0x50020000 | (phy_id << 23) | (location << 18) | value; 3262 int write_cmd = 0x50020000 | (phy_id << 23) | (location << 18) | value;
3224 long mdio_addr = ioaddr + Wn4_PhysicalMgmt; 3263 void __iomem *mdio_addr = ioaddr + Wn4_PhysicalMgmt;
3225 int i; 3264 int i;
3226 3265
3227 if (mii_preamble_required) 3266 if (mii_preamble_required)
@@ -3230,16 +3269,16 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
3230 /* Shift the command bits out. */ 3269 /* Shift the command bits out. */
3231 for (i = 31; i >= 0; i--) { 3270 for (i = 31; i >= 0; i--) {
3232 int dataval = (write_cmd&(1<<i)) ? MDIO_DATA_WRITE1 : MDIO_DATA_WRITE0; 3271 int dataval = (write_cmd&(1<<i)) ? MDIO_DATA_WRITE1 : MDIO_DATA_WRITE0;
3233 outw(dataval, mdio_addr); 3272 iowrite16(dataval, mdio_addr);
3234 mdio_delay(); 3273 mdio_delay();
3235 outw(dataval | MDIO_SHIFT_CLK, mdio_addr); 3274 iowrite16(dataval | MDIO_SHIFT_CLK, mdio_addr);
3236 mdio_delay(); 3275 mdio_delay();
3237 } 3276 }
3238 /* Leave the interface idle. */ 3277 /* Leave the interface idle. */
3239 for (i = 1; i >= 0; i--) { 3278 for (i = 1; i >= 0; i--) {
3240 outw(MDIO_ENB_IN, mdio_addr); 3279 iowrite16(MDIO_ENB_IN, mdio_addr);
3241 mdio_delay(); 3280 mdio_delay();
3242 outw(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr); 3281 iowrite16(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
3243 mdio_delay(); 3282 mdio_delay();
3244 } 3283 }
3245 return; 3284 return;
@@ -3250,15 +3289,15 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
3250static void acpi_set_WOL(struct net_device *dev) 3289static void acpi_set_WOL(struct net_device *dev)
3251{ 3290{
3252 struct vortex_private *vp = netdev_priv(dev); 3291 struct vortex_private *vp = netdev_priv(dev);
3253 long ioaddr = dev->base_addr; 3292 void __iomem *ioaddr = vp->ioaddr;
3254 3293
3255 if (vp->enable_wol) { 3294 if (vp->enable_wol) {
3256 /* Power up on: 1==Downloaded Filter, 2==Magic Packets, 4==Link Status. */ 3295 /* Power up on: 1==Downloaded Filter, 2==Magic Packets, 4==Link Status. */
3257 EL3WINDOW(7); 3296 EL3WINDOW(7);
3258 outw(2, ioaddr + 0x0c); 3297 iowrite16(2, ioaddr + 0x0c);
3259 /* The RxFilter must accept the WOL frames. */ 3298 /* The RxFilter must accept the WOL frames. */
3260 outw(SetRxFilter|RxStation|RxMulticast|RxBroadcast, ioaddr + EL3_CMD); 3299 iowrite16(SetRxFilter|RxStation|RxMulticast|RxBroadcast, ioaddr + EL3_CMD);
3261 outw(RxEnable, ioaddr + EL3_CMD); 3300 iowrite16(RxEnable, ioaddr + EL3_CMD);
3262 3301
3263 pci_enable_wake(VORTEX_PCI(vp), 0, 1); 3302 pci_enable_wake(VORTEX_PCI(vp), 0, 1);
3264 3303
@@ -3280,10 +3319,9 @@ static void __devexit vortex_remove_one (struct pci_dev *pdev)
3280 3319
3281 vp = netdev_priv(dev); 3320 vp = netdev_priv(dev);
3282 3321
3283 /* AKPM: FIXME: we should have 3322 if (vp->cb_fn_base)
3284 * if (vp->cb_fn_base) iounmap(vp->cb_fn_base); 3323 pci_iounmap(VORTEX_PCI(vp), vp->cb_fn_base);
3285 * here 3324
3286 */
3287 unregister_netdev(dev); 3325 unregister_netdev(dev);
3288 3326
3289 if (VORTEX_PCI(vp)) { 3327 if (VORTEX_PCI(vp)) {
@@ -3293,8 +3331,10 @@ static void __devexit vortex_remove_one (struct pci_dev *pdev)
3293 pci_disable_device(VORTEX_PCI(vp)); 3331 pci_disable_device(VORTEX_PCI(vp));
3294 } 3332 }
3295 /* Should really use issue_and_wait() here */ 3333 /* Should really use issue_and_wait() here */
3296 outw(TotalReset | ((vp->drv_flags & EEPROM_RESET) ? 0x04 : 0x14), 3334 iowrite16(TotalReset | ((vp->drv_flags & EEPROM_RESET) ? 0x04 : 0x14),
3297 dev->base_addr + EL3_CMD); 3335 vp->ioaddr + EL3_CMD);
3336
3337 pci_iounmap(VORTEX_PCI(vp), vp->ioaddr);
3298 3338
3299 pci_free_consistent(pdev, 3339 pci_free_consistent(pdev,
3300 sizeof(struct boom_rx_desc) * RX_RING_SIZE 3340 sizeof(struct boom_rx_desc) * RX_RING_SIZE
@@ -3342,7 +3382,7 @@ static int __init vortex_init (void)
3342static void __exit vortex_eisa_cleanup (void) 3382static void __exit vortex_eisa_cleanup (void)
3343{ 3383{
3344 struct vortex_private *vp; 3384 struct vortex_private *vp;
3345 long ioaddr; 3385 void __iomem *ioaddr;
3346 3386
3347#ifdef CONFIG_EISA 3387#ifdef CONFIG_EISA
3348 /* Take care of the EISA devices */ 3388 /* Take care of the EISA devices */
@@ -3351,11 +3391,13 @@ static void __exit vortex_eisa_cleanup (void)
3351 3391
3352 if (compaq_net_device) { 3392 if (compaq_net_device) {
3353 vp = compaq_net_device->priv; 3393 vp = compaq_net_device->priv;
3354 ioaddr = compaq_net_device->base_addr; 3394 ioaddr = ioport_map(compaq_net_device->base_addr,
3395 VORTEX_TOTAL_SIZE);
3355 3396
3356 unregister_netdev (compaq_net_device); 3397 unregister_netdev (compaq_net_device);
3357 outw (TotalReset, ioaddr + EL3_CMD); 3398 iowrite16 (TotalReset, ioaddr + EL3_CMD);
3358 release_region (ioaddr, VORTEX_TOTAL_SIZE); 3399 release_region(compaq_net_device->base_addr,
3400 VORTEX_TOTAL_SIZE);
3359 3401
3360 free_netdev (compaq_net_device); 3402 free_netdev (compaq_net_device);
3361 } 3403 }
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 11d252318221..8f464271664d 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -14,8 +14,8 @@
14 14
15#define DRV_MODULE_NAME "bnx2" 15#define DRV_MODULE_NAME "bnx2"
16#define PFX DRV_MODULE_NAME ": " 16#define PFX DRV_MODULE_NAME ": "
17#define DRV_MODULE_VERSION "1.2.21" 17#define DRV_MODULE_VERSION "1.4.30"
18#define DRV_MODULE_RELDATE "September 7, 2005" 18#define DRV_MODULE_RELDATE "October 11, 2005"
19 19
20#define RUN_AT(x) (jiffies + (x)) 20#define RUN_AT(x) (jiffies + (x))
21 21
@@ -26,7 +26,7 @@ static char version[] __devinitdata =
26 "Broadcom NetXtreme II Gigabit Ethernet Driver " DRV_MODULE_NAME " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 26 "Broadcom NetXtreme II Gigabit Ethernet Driver " DRV_MODULE_NAME " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
27 27
28MODULE_AUTHOR("Michael Chan <mchan@broadcom.com>"); 28MODULE_AUTHOR("Michael Chan <mchan@broadcom.com>");
29MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706 Driver"); 29MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706/5708 Driver");
30MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
31MODULE_VERSION(DRV_MODULE_VERSION); 31MODULE_VERSION(DRV_MODULE_VERSION);
32 32
@@ -41,6 +41,8 @@ typedef enum {
41 NC370I, 41 NC370I,
42 BCM5706S, 42 BCM5706S,
43 NC370F, 43 NC370F,
44 BCM5708,
45 BCM5708S,
44} board_t; 46} board_t;
45 47
46/* indexed by board_t, above */ 48/* indexed by board_t, above */
@@ -52,6 +54,8 @@ static struct {
52 { "HP NC370i Multifunction Gigabit Server Adapter" }, 54 { "HP NC370i Multifunction Gigabit Server Adapter" },
53 { "Broadcom NetXtreme II BCM5706 1000Base-SX" }, 55 { "Broadcom NetXtreme II BCM5706 1000Base-SX" },
54 { "HP NC370F Multifunction Gigabit Server Adapter" }, 56 { "HP NC370F Multifunction Gigabit Server Adapter" },
57 { "Broadcom NetXtreme II BCM5708 1000Base-T" },
58 { "Broadcom NetXtreme II BCM5708 1000Base-SX" },
55 }; 59 };
56 60
57static struct pci_device_id bnx2_pci_tbl[] = { 61static struct pci_device_id bnx2_pci_tbl[] = {
@@ -61,48 +65,102 @@ static struct pci_device_id bnx2_pci_tbl[] = {
61 PCI_VENDOR_ID_HP, 0x3106, 0, 0, NC370I }, 65 PCI_VENDOR_ID_HP, 0x3106, 0, 0, NC370I },
62 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706, 66 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706,
63 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706 }, 67 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706 },
68 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5708,
69 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708 },
64 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706S, 70 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706S,
65 PCI_VENDOR_ID_HP, 0x3102, 0, 0, NC370F }, 71 PCI_VENDOR_ID_HP, 0x3102, 0, 0, NC370F },
66 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706S, 72 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706S,
67 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706S }, 73 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706S },
74 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5708S,
75 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708S },
68 { 0, } 76 { 0, }
69}; 77};
70 78
71static struct flash_spec flash_table[] = 79static struct flash_spec flash_table[] =
72{ 80{
73 /* Slow EEPROM */ 81 /* Slow EEPROM */
74 {0x00000000, 0x40030380, 0x009f0081, 0xa184a053, 0xaf000400, 82 {0x00000000, 0x40830380, 0x009f0081, 0xa184a053, 0xaf000400,
75 1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE, 83 1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
76 SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE, 84 SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE,
77 "EEPROM - slow"}, 85 "EEPROM - slow"},
78 /* Fast EEPROM */ 86 /* Expansion entry 0001 */
79 {0x02000000, 0x62008380, 0x009f0081, 0xa184a053, 0xaf000400, 87 {0x08000002, 0x4b808201, 0x00050081, 0x03840253, 0xaf020406,
80 1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
81 SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE,
82 "EEPROM - fast"},
83 /* ATMEL AT45DB011B (buffered flash) */
84 {0x02000003, 0x6e008173, 0x00570081, 0x68848353, 0xaf000400,
85 1, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE,
86 BUFFERED_FLASH_BYTE_ADDR_MASK, BUFFERED_FLASH_TOTAL_SIZE,
87 "Buffered flash"},
88 /* Saifun SA25F005 (non-buffered flash) */
89 /* strap, cfg1, & write1 need updates */
90 {0x01000003, 0x5f008081, 0x00050081, 0x03840253, 0xaf020406,
91 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, 88 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
92 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE, 89 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
93 "Non-buffered flash (64kB)"}, 90 "Entry 0001"},
94 /* Saifun SA25F010 (non-buffered flash) */ 91 /* Saifun SA25F010 (non-buffered flash) */
95 /* strap, cfg1, & write1 need updates */ 92 /* strap, cfg1, & write1 need updates */
96 {0x00000001, 0x47008081, 0x00050081, 0x03840253, 0xaf020406, 93 {0x04000001, 0x47808201, 0x00050081, 0x03840253, 0xaf020406,
97 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, 94 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
98 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*2, 95 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*2,
99 "Non-buffered flash (128kB)"}, 96 "Non-buffered flash (128kB)"},
100 /* Saifun SA25F020 (non-buffered flash) */ 97 /* Saifun SA25F020 (non-buffered flash) */
101 /* strap, cfg1, & write1 need updates */ 98 /* strap, cfg1, & write1 need updates */
102 {0x00000003, 0x4f008081, 0x00050081, 0x03840253, 0xaf020406, 99 {0x0c000003, 0x4f808201, 0x00050081, 0x03840253, 0xaf020406,
103 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, 100 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
104 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*4, 101 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*4,
105 "Non-buffered flash (256kB)"}, 102 "Non-buffered flash (256kB)"},
103 /* Expansion entry 0100 */
104 {0x11000000, 0x53808201, 0x00050081, 0x03840253, 0xaf020406,
105 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
106 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
107 "Entry 0100"},
108 /* Entry 0101: ST M45PE10 (non-buffered flash, TetonII B0) */
109 {0x19000002, 0x5b808201, 0x000500db, 0x03840253, 0xaf020406,
110 0, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE,
111 ST_MICRO_FLASH_BYTE_ADDR_MASK, ST_MICRO_FLASH_BASE_TOTAL_SIZE*2,
112 "Entry 0101: ST M45PE10 (128kB non-bufferred)"},
113 /* Entry 0110: ST M45PE20 (non-buffered flash)*/
114 {0x15000001, 0x57808201, 0x000500db, 0x03840253, 0xaf020406,
115 0, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE,
116 ST_MICRO_FLASH_BYTE_ADDR_MASK, ST_MICRO_FLASH_BASE_TOTAL_SIZE*4,
117 "Entry 0110: ST M45PE20 (256kB non-bufferred)"},
118 /* Saifun SA25F005 (non-buffered flash) */
119 /* strap, cfg1, & write1 need updates */
120 {0x1d000003, 0x5f808201, 0x00050081, 0x03840253, 0xaf020406,
121 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
122 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE,
123 "Non-buffered flash (64kB)"},
124 /* Fast EEPROM */
125 {0x22000000, 0x62808380, 0x009f0081, 0xa184a053, 0xaf000400,
126 1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
127 SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE,
128 "EEPROM - fast"},
129 /* Expansion entry 1001 */
130 {0x2a000002, 0x6b808201, 0x00050081, 0x03840253, 0xaf020406,
131 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
132 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
133 "Entry 1001"},
134 /* Expansion entry 1010 */
135 {0x26000001, 0x67808201, 0x00050081, 0x03840253, 0xaf020406,
136 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
137 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
138 "Entry 1010"},
139 /* ATMEL AT45DB011B (buffered flash) */
140 {0x2e000003, 0x6e808273, 0x00570081, 0x68848353, 0xaf000400,
141 1, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE,
142 BUFFERED_FLASH_BYTE_ADDR_MASK, BUFFERED_FLASH_TOTAL_SIZE,
143 "Buffered flash (128kB)"},
144 /* Expansion entry 1100 */
145 {0x33000000, 0x73808201, 0x00050081, 0x03840253, 0xaf020406,
146 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
147 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
148 "Entry 1100"},
149 /* Expansion entry 1101 */
150 {0x3b000002, 0x7b808201, 0x00050081, 0x03840253, 0xaf020406,
151 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
152 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
153 "Entry 1101"},
154 /* Ateml Expansion entry 1110 */
155 {0x37000001, 0x76808273, 0x00570081, 0x68848353, 0xaf000400,
156 1, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE,
157 BUFFERED_FLASH_BYTE_ADDR_MASK, 0,
158 "Entry 1110 (Atmel)"},
159 /* ATMEL AT45DB021B (buffered flash) */
160 {0x3f000003, 0x7e808273, 0x00570081, 0x68848353, 0xaf000400,
161 1, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE,
162 BUFFERED_FLASH_BYTE_ADDR_MASK, BUFFERED_FLASH_TOTAL_SIZE*2,
163 "Buffered flash (256kB)"},
106}; 164};
107 165
108MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl); 166MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl);
@@ -379,6 +437,62 @@ alloc_mem_err:
379} 437}
380 438
381static void 439static void
440bnx2_report_fw_link(struct bnx2 *bp)
441{
442 u32 fw_link_status = 0;
443
444 if (bp->link_up) {
445 u32 bmsr;
446
447 switch (bp->line_speed) {
448 case SPEED_10:
449 if (bp->duplex == DUPLEX_HALF)
450 fw_link_status = BNX2_LINK_STATUS_10HALF;
451 else
452 fw_link_status = BNX2_LINK_STATUS_10FULL;
453 break;
454 case SPEED_100:
455 if (bp->duplex == DUPLEX_HALF)
456 fw_link_status = BNX2_LINK_STATUS_100HALF;
457 else
458 fw_link_status = BNX2_LINK_STATUS_100FULL;
459 break;
460 case SPEED_1000:
461 if (bp->duplex == DUPLEX_HALF)
462 fw_link_status = BNX2_LINK_STATUS_1000HALF;
463 else
464 fw_link_status = BNX2_LINK_STATUS_1000FULL;
465 break;
466 case SPEED_2500:
467 if (bp->duplex == DUPLEX_HALF)
468 fw_link_status = BNX2_LINK_STATUS_2500HALF;
469 else
470 fw_link_status = BNX2_LINK_STATUS_2500FULL;
471 break;
472 }
473
474 fw_link_status |= BNX2_LINK_STATUS_LINK_UP;
475
476 if (bp->autoneg) {
477 fw_link_status |= BNX2_LINK_STATUS_AN_ENABLED;
478
479 bnx2_read_phy(bp, MII_BMSR, &bmsr);
480 bnx2_read_phy(bp, MII_BMSR, &bmsr);
481
482 if (!(bmsr & BMSR_ANEGCOMPLETE) ||
483 bp->phy_flags & PHY_PARALLEL_DETECT_FLAG)
484 fw_link_status |= BNX2_LINK_STATUS_PARALLEL_DET;
485 else
486 fw_link_status |= BNX2_LINK_STATUS_AN_COMPLETE;
487 }
488 }
489 else
490 fw_link_status = BNX2_LINK_STATUS_LINK_DOWN;
491
492 REG_WR_IND(bp, bp->shmem_base + BNX2_LINK_STATUS, fw_link_status);
493}
494
495static void
382bnx2_report_link(struct bnx2 *bp) 496bnx2_report_link(struct bnx2 *bp)
383{ 497{
384 if (bp->link_up) { 498 if (bp->link_up) {
@@ -409,6 +523,8 @@ bnx2_report_link(struct bnx2 *bp)
409 netif_carrier_off(bp->dev); 523 netif_carrier_off(bp->dev);
410 printk(KERN_ERR PFX "%s NIC Link is Down\n", bp->dev->name); 524 printk(KERN_ERR PFX "%s NIC Link is Down\n", bp->dev->name);
411 } 525 }
526
527 bnx2_report_fw_link(bp);
412} 528}
413 529
414static void 530static void
@@ -430,6 +546,18 @@ bnx2_resolve_flow_ctrl(struct bnx2 *bp)
430 return; 546 return;
431 } 547 }
432 548
549 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
550 (CHIP_NUM(bp) == CHIP_NUM_5708)) {
551 u32 val;
552
553 bnx2_read_phy(bp, BCM5708S_1000X_STAT1, &val);
554 if (val & BCM5708S_1000X_STAT1_TX_PAUSE)
555 bp->flow_ctrl |= FLOW_CTRL_TX;
556 if (val & BCM5708S_1000X_STAT1_RX_PAUSE)
557 bp->flow_ctrl |= FLOW_CTRL_RX;
558 return;
559 }
560
433 bnx2_read_phy(bp, MII_ADVERTISE, &local_adv); 561 bnx2_read_phy(bp, MII_ADVERTISE, &local_adv);
434 bnx2_read_phy(bp, MII_LPA, &remote_adv); 562 bnx2_read_phy(bp, MII_LPA, &remote_adv);
435 563
@@ -476,7 +604,36 @@ bnx2_resolve_flow_ctrl(struct bnx2 *bp)
476} 604}
477 605
478static int 606static int
479bnx2_serdes_linkup(struct bnx2 *bp) 607bnx2_5708s_linkup(struct bnx2 *bp)
608{
609 u32 val;
610
611 bp->link_up = 1;
612 bnx2_read_phy(bp, BCM5708S_1000X_STAT1, &val);
613 switch (val & BCM5708S_1000X_STAT1_SPEED_MASK) {
614 case BCM5708S_1000X_STAT1_SPEED_10:
615 bp->line_speed = SPEED_10;
616 break;
617 case BCM5708S_1000X_STAT1_SPEED_100:
618 bp->line_speed = SPEED_100;
619 break;
620 case BCM5708S_1000X_STAT1_SPEED_1G:
621 bp->line_speed = SPEED_1000;
622 break;
623 case BCM5708S_1000X_STAT1_SPEED_2G5:
624 bp->line_speed = SPEED_2500;
625 break;
626 }
627 if (val & BCM5708S_1000X_STAT1_FD)
628 bp->duplex = DUPLEX_FULL;
629 else
630 bp->duplex = DUPLEX_HALF;
631
632 return 0;
633}
634
635static int
636bnx2_5706s_linkup(struct bnx2 *bp)
480{ 637{
481 u32 bmcr, local_adv, remote_adv, common; 638 u32 bmcr, local_adv, remote_adv, common;
482 639
@@ -593,13 +750,27 @@ bnx2_set_mac_link(struct bnx2 *bp)
593 val = REG_RD(bp, BNX2_EMAC_MODE); 750 val = REG_RD(bp, BNX2_EMAC_MODE);
594 751
595 val &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX | 752 val &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX |
596 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK); 753 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK |
754 BNX2_EMAC_MODE_25G);
597 755
598 if (bp->link_up) { 756 if (bp->link_up) {
599 if (bp->line_speed != SPEED_1000) 757 switch (bp->line_speed) {
600 val |= BNX2_EMAC_MODE_PORT_MII; 758 case SPEED_10:
601 else 759 if (CHIP_NUM(bp) == CHIP_NUM_5708) {
602 val |= BNX2_EMAC_MODE_PORT_GMII; 760 val |= BNX2_EMAC_MODE_PORT_MII_10;
761 break;
762 }
763 /* fall through */
764 case SPEED_100:
765 val |= BNX2_EMAC_MODE_PORT_MII;
766 break;
767 case SPEED_2500:
768 val |= BNX2_EMAC_MODE_25G;
769 /* fall through */
770 case SPEED_1000:
771 val |= BNX2_EMAC_MODE_PORT_GMII;
772 break;
773 }
603 } 774 }
604 else { 775 else {
605 val |= BNX2_EMAC_MODE_PORT_GMII; 776 val |= BNX2_EMAC_MODE_PORT_GMII;
@@ -662,7 +833,10 @@ bnx2_set_link(struct bnx2 *bp)
662 bp->link_up = 1; 833 bp->link_up = 1;
663 834
664 if (bp->phy_flags & PHY_SERDES_FLAG) { 835 if (bp->phy_flags & PHY_SERDES_FLAG) {
665 bnx2_serdes_linkup(bp); 836 if (CHIP_NUM(bp) == CHIP_NUM_5706)
837 bnx2_5706s_linkup(bp);
838 else if (CHIP_NUM(bp) == CHIP_NUM_5708)
839 bnx2_5708s_linkup(bp);
666 } 840 }
667 else { 841 else {
668 bnx2_copper_linkup(bp); 842 bnx2_copper_linkup(bp);
@@ -755,39 +929,61 @@ bnx2_phy_get_pause_adv(struct bnx2 *bp)
755static int 929static int
756bnx2_setup_serdes_phy(struct bnx2 *bp) 930bnx2_setup_serdes_phy(struct bnx2 *bp)
757{ 931{
758 u32 adv, bmcr; 932 u32 adv, bmcr, up1;
759 u32 new_adv = 0; 933 u32 new_adv = 0;
760 934
761 if (!(bp->autoneg & AUTONEG_SPEED)) { 935 if (!(bp->autoneg & AUTONEG_SPEED)) {
762 u32 new_bmcr; 936 u32 new_bmcr;
937 int force_link_down = 0;
938
939 if (CHIP_NUM(bp) == CHIP_NUM_5708) {
940 bnx2_read_phy(bp, BCM5708S_UP1, &up1);
941 if (up1 & BCM5708S_UP1_2G5) {
942 up1 &= ~BCM5708S_UP1_2G5;
943 bnx2_write_phy(bp, BCM5708S_UP1, up1);
944 force_link_down = 1;
945 }
946 }
947
948 bnx2_read_phy(bp, MII_ADVERTISE, &adv);
949 adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
763 950
764 bnx2_read_phy(bp, MII_BMCR, &bmcr); 951 bnx2_read_phy(bp, MII_BMCR, &bmcr);
765 new_bmcr = bmcr & ~BMCR_ANENABLE; 952 new_bmcr = bmcr & ~BMCR_ANENABLE;
766 new_bmcr |= BMCR_SPEED1000; 953 new_bmcr |= BMCR_SPEED1000;
767 if (bp->req_duplex == DUPLEX_FULL) { 954 if (bp->req_duplex == DUPLEX_FULL) {
955 adv |= ADVERTISE_1000XFULL;
768 new_bmcr |= BMCR_FULLDPLX; 956 new_bmcr |= BMCR_FULLDPLX;
769 } 957 }
770 else { 958 else {
959 adv |= ADVERTISE_1000XHALF;
771 new_bmcr &= ~BMCR_FULLDPLX; 960 new_bmcr &= ~BMCR_FULLDPLX;
772 } 961 }
773 if (new_bmcr != bmcr) { 962 if ((new_bmcr != bmcr) || (force_link_down)) {
774 /* Force a link down visible on the other side */ 963 /* Force a link down visible on the other side */
775 if (bp->link_up) { 964 if (bp->link_up) {
776 bnx2_read_phy(bp, MII_ADVERTISE, &adv); 965 bnx2_write_phy(bp, MII_ADVERTISE, adv &
777 adv &= ~(ADVERTISE_1000XFULL | 966 ~(ADVERTISE_1000XFULL |
778 ADVERTISE_1000XHALF); 967 ADVERTISE_1000XHALF));
779 bnx2_write_phy(bp, MII_ADVERTISE, adv);
780 bnx2_write_phy(bp, MII_BMCR, bmcr | 968 bnx2_write_phy(bp, MII_BMCR, bmcr |
781 BMCR_ANRESTART | BMCR_ANENABLE); 969 BMCR_ANRESTART | BMCR_ANENABLE);
782 970
783 bp->link_up = 0; 971 bp->link_up = 0;
784 netif_carrier_off(bp->dev); 972 netif_carrier_off(bp->dev);
973 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
785 } 974 }
975 bnx2_write_phy(bp, MII_ADVERTISE, adv);
786 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 976 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
787 } 977 }
788 return 0; 978 return 0;
789 } 979 }
790 980
981 if (bp->phy_flags & PHY_2_5G_CAPABLE_FLAG) {
982 bnx2_read_phy(bp, BCM5708S_UP1, &up1);
983 up1 |= BCM5708S_UP1_2G5;
984 bnx2_write_phy(bp, BCM5708S_UP1, up1);
985 }
986
791 if (bp->advertising & ADVERTISED_1000baseT_Full) 987 if (bp->advertising & ADVERTISED_1000baseT_Full)
792 new_adv |= ADVERTISE_1000XFULL; 988 new_adv |= ADVERTISE_1000XFULL;
793 989
@@ -952,7 +1148,60 @@ bnx2_setup_phy(struct bnx2 *bp)
952} 1148}
953 1149
954static int 1150static int
955bnx2_init_serdes_phy(struct bnx2 *bp) 1151bnx2_init_5708s_phy(struct bnx2 *bp)
1152{
1153 u32 val;
1154
1155 bnx2_write_phy(bp, BCM5708S_BLK_ADDR, BCM5708S_BLK_ADDR_DIG3);
1156 bnx2_write_phy(bp, BCM5708S_DIG_3_0, BCM5708S_DIG_3_0_USE_IEEE);
1157 bnx2_write_phy(bp, BCM5708S_BLK_ADDR, BCM5708S_BLK_ADDR_DIG);
1158
1159 bnx2_read_phy(bp, BCM5708S_1000X_CTL1, &val);
1160 val |= BCM5708S_1000X_CTL1_FIBER_MODE | BCM5708S_1000X_CTL1_AUTODET_EN;
1161 bnx2_write_phy(bp, BCM5708S_1000X_CTL1, val);
1162
1163 bnx2_read_phy(bp, BCM5708S_1000X_CTL2, &val);
1164 val |= BCM5708S_1000X_CTL2_PLLEL_DET_EN;
1165 bnx2_write_phy(bp, BCM5708S_1000X_CTL2, val);
1166
1167 if (bp->phy_flags & PHY_2_5G_CAPABLE_FLAG) {
1168 bnx2_read_phy(bp, BCM5708S_UP1, &val);
1169 val |= BCM5708S_UP1_2G5;
1170 bnx2_write_phy(bp, BCM5708S_UP1, val);
1171 }
1172
1173 if ((CHIP_ID(bp) == CHIP_ID_5708_A0) ||
1174 (CHIP_ID(bp) == CHIP_ID_5708_B0)) {
1175 /* increase tx signal amplitude */
1176 bnx2_write_phy(bp, BCM5708S_BLK_ADDR,
1177 BCM5708S_BLK_ADDR_TX_MISC);
1178 bnx2_read_phy(bp, BCM5708S_TX_ACTL1, &val);
1179 val &= ~BCM5708S_TX_ACTL1_DRIVER_VCM;
1180 bnx2_write_phy(bp, BCM5708S_TX_ACTL1, val);
1181 bnx2_write_phy(bp, BCM5708S_BLK_ADDR, BCM5708S_BLK_ADDR_DIG);
1182 }
1183
1184 val = REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_HW_CFG_CONFIG) &
1185 BNX2_PORT_HW_CFG_CFG_TXCTL3_MASK;
1186
1187 if (val) {
1188 u32 is_backplane;
1189
1190 is_backplane = REG_RD_IND(bp, bp->shmem_base +
1191 BNX2_SHARED_HW_CFG_CONFIG);
1192 if (is_backplane & BNX2_SHARED_HW_CFG_PHY_BACKPLANE) {
1193 bnx2_write_phy(bp, BCM5708S_BLK_ADDR,
1194 BCM5708S_BLK_ADDR_TX_MISC);
1195 bnx2_write_phy(bp, BCM5708S_TX_ACTL3, val);
1196 bnx2_write_phy(bp, BCM5708S_BLK_ADDR,
1197 BCM5708S_BLK_ADDR_DIG);
1198 }
1199 }
1200 return 0;
1201}
1202
1203static int
1204bnx2_init_5706s_phy(struct bnx2 *bp)
956{ 1205{
957 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG; 1206 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
958 1207
@@ -990,6 +1239,8 @@ bnx2_init_serdes_phy(struct bnx2 *bp)
990static int 1239static int
991bnx2_init_copper_phy(struct bnx2 *bp) 1240bnx2_init_copper_phy(struct bnx2 *bp)
992{ 1241{
1242 u32 val;
1243
993 bp->phy_flags |= PHY_CRC_FIX_FLAG; 1244 bp->phy_flags |= PHY_CRC_FIX_FLAG;
994 1245
995 if (bp->phy_flags & PHY_CRC_FIX_FLAG) { 1246 if (bp->phy_flags & PHY_CRC_FIX_FLAG) {
@@ -1004,8 +1255,6 @@ bnx2_init_copper_phy(struct bnx2 *bp)
1004 } 1255 }
1005 1256
1006 if (bp->dev->mtu > 1500) { 1257 if (bp->dev->mtu > 1500) {
1007 u32 val;
1008
1009 /* Set extended packet length bit */ 1258 /* Set extended packet length bit */
1010 bnx2_write_phy(bp, 0x18, 0x7); 1259 bnx2_write_phy(bp, 0x18, 0x7);
1011 bnx2_read_phy(bp, 0x18, &val); 1260 bnx2_read_phy(bp, 0x18, &val);
@@ -1015,8 +1264,6 @@ bnx2_init_copper_phy(struct bnx2 *bp)
1015 bnx2_write_phy(bp, 0x10, val | 0x1); 1264 bnx2_write_phy(bp, 0x10, val | 0x1);
1016 } 1265 }
1017 else { 1266 else {
1018 u32 val;
1019
1020 bnx2_write_phy(bp, 0x18, 0x7); 1267 bnx2_write_phy(bp, 0x18, 0x7);
1021 bnx2_read_phy(bp, 0x18, &val); 1268 bnx2_read_phy(bp, 0x18, &val);
1022 bnx2_write_phy(bp, 0x18, val & ~0x4007); 1269 bnx2_write_phy(bp, 0x18, val & ~0x4007);
@@ -1025,6 +1272,10 @@ bnx2_init_copper_phy(struct bnx2 *bp)
1025 bnx2_write_phy(bp, 0x10, val & ~0x1); 1272 bnx2_write_phy(bp, 0x10, val & ~0x1);
1026 } 1273 }
1027 1274
1275 /* ethernet@wirespeed */
1276 bnx2_write_phy(bp, 0x18, 0x7007);
1277 bnx2_read_phy(bp, 0x18, &val);
1278 bnx2_write_phy(bp, 0x18, val | (1 << 15) | (1 << 4));
1028 return 0; 1279 return 0;
1029} 1280}
1030 1281
@@ -1048,7 +1299,10 @@ bnx2_init_phy(struct bnx2 *bp)
1048 bp->phy_id |= val & 0xffff; 1299 bp->phy_id |= val & 0xffff;
1049 1300
1050 if (bp->phy_flags & PHY_SERDES_FLAG) { 1301 if (bp->phy_flags & PHY_SERDES_FLAG) {
1051 rc = bnx2_init_serdes_phy(bp); 1302 if (CHIP_NUM(bp) == CHIP_NUM_5706)
1303 rc = bnx2_init_5706s_phy(bp);
1304 else if (CHIP_NUM(bp) == CHIP_NUM_5708)
1305 rc = bnx2_init_5708s_phy(bp);
1052 } 1306 }
1053 else { 1307 else {
1054 rc = bnx2_init_copper_phy(bp); 1308 rc = bnx2_init_copper_phy(bp);
@@ -1084,13 +1338,13 @@ bnx2_fw_sync(struct bnx2 *bp, u32 msg_data)
1084 bp->fw_wr_seq++; 1338 bp->fw_wr_seq++;
1085 msg_data |= bp->fw_wr_seq; 1339 msg_data |= bp->fw_wr_seq;
1086 1340
1087 REG_WR_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DRV_MB, msg_data); 1341 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_MB, msg_data);
1088 1342
1089 /* wait for an acknowledgement. */ 1343 /* wait for an acknowledgement. */
1090 for (i = 0; i < (FW_ACK_TIME_OUT_MS * 1000)/5; i++) { 1344 for (i = 0; i < (FW_ACK_TIME_OUT_MS * 1000)/5; i++) {
1091 udelay(5); 1345 udelay(5);
1092 1346
1093 val = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_FW_MB); 1347 val = REG_RD_IND(bp, bp->shmem_base + BNX2_FW_MB);
1094 1348
1095 if ((val & BNX2_FW_MSG_ACK) == (msg_data & BNX2_DRV_MSG_SEQ)) 1349 if ((val & BNX2_FW_MSG_ACK) == (msg_data & BNX2_DRV_MSG_SEQ))
1096 break; 1350 break;
@@ -1103,7 +1357,7 @@ bnx2_fw_sync(struct bnx2 *bp, u32 msg_data)
1103 msg_data &= ~BNX2_DRV_MSG_CODE; 1357 msg_data &= ~BNX2_DRV_MSG_CODE;
1104 msg_data |= BNX2_DRV_MSG_CODE_FW_TIMEOUT; 1358 msg_data |= BNX2_DRV_MSG_CODE_FW_TIMEOUT;
1105 1359
1106 REG_WR_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DRV_MB, msg_data); 1360 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_MB, msg_data);
1107 1361
1108 bp->fw_timed_out = 1; 1362 bp->fw_timed_out = 1;
1109 1363
@@ -1279,10 +1533,11 @@ bnx2_phy_int(struct bnx2 *bp)
1279static void 1533static void
1280bnx2_tx_int(struct bnx2 *bp) 1534bnx2_tx_int(struct bnx2 *bp)
1281{ 1535{
1536 struct status_block *sblk = bp->status_blk;
1282 u16 hw_cons, sw_cons, sw_ring_cons; 1537 u16 hw_cons, sw_cons, sw_ring_cons;
1283 int tx_free_bd = 0; 1538 int tx_free_bd = 0;
1284 1539
1285 hw_cons = bp->status_blk->status_tx_quick_consumer_index0; 1540 hw_cons = bp->hw_tx_cons = sblk->status_tx_quick_consumer_index0;
1286 if ((hw_cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT) { 1541 if ((hw_cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT) {
1287 hw_cons++; 1542 hw_cons++;
1288 } 1543 }
@@ -1337,7 +1592,9 @@ bnx2_tx_int(struct bnx2 *bp)
1337 1592
1338 dev_kfree_skb_irq(skb); 1593 dev_kfree_skb_irq(skb);
1339 1594
1340 hw_cons = bp->status_blk->status_tx_quick_consumer_index0; 1595 hw_cons = bp->hw_tx_cons =
1596 sblk->status_tx_quick_consumer_index0;
1597
1341 if ((hw_cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT) { 1598 if ((hw_cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT) {
1342 hw_cons++; 1599 hw_cons++;
1343 } 1600 }
@@ -1382,11 +1639,12 @@ bnx2_reuse_rx_skb(struct bnx2 *bp, struct sk_buff *skb,
1382static int 1639static int
1383bnx2_rx_int(struct bnx2 *bp, int budget) 1640bnx2_rx_int(struct bnx2 *bp, int budget)
1384{ 1641{
1642 struct status_block *sblk = bp->status_blk;
1385 u16 hw_cons, sw_cons, sw_ring_cons, sw_prod, sw_ring_prod; 1643 u16 hw_cons, sw_cons, sw_ring_cons, sw_prod, sw_ring_prod;
1386 struct l2_fhdr *rx_hdr; 1644 struct l2_fhdr *rx_hdr;
1387 int rx_pkt = 0; 1645 int rx_pkt = 0;
1388 1646
1389 hw_cons = bp->status_blk->status_rx_quick_consumer_index0; 1647 hw_cons = bp->hw_rx_cons = sblk->status_rx_quick_consumer_index0;
1390 if ((hw_cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT) { 1648 if ((hw_cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT) {
1391 hw_cons++; 1649 hw_cons++;
1392 } 1650 }
@@ -1506,6 +1764,15 @@ next_rx:
1506 1764
1507 if ((rx_pkt == budget)) 1765 if ((rx_pkt == budget))
1508 break; 1766 break;
1767
1768 /* Refresh hw_cons to see if there is new work */
1769 if (sw_cons == hw_cons) {
1770 hw_cons = bp->hw_rx_cons =
1771 sblk->status_rx_quick_consumer_index0;
1772 if ((hw_cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT)
1773 hw_cons++;
1774 rmb();
1775 }
1509 } 1776 }
1510 bp->rx_cons = sw_cons; 1777 bp->rx_cons = sw_cons;
1511 bp->rx_prod = sw_prod; 1778 bp->rx_prod = sw_prod;
@@ -1573,15 +1840,27 @@ bnx2_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
1573 return IRQ_HANDLED; 1840 return IRQ_HANDLED;
1574} 1841}
1575 1842
1843static inline int
1844bnx2_has_work(struct bnx2 *bp)
1845{
1846 struct status_block *sblk = bp->status_blk;
1847
1848 if ((sblk->status_rx_quick_consumer_index0 != bp->hw_rx_cons) ||
1849 (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons))
1850 return 1;
1851
1852 if (((sblk->status_attn_bits & STATUS_ATTN_BITS_LINK_STATE) != 0) !=
1853 bp->link_up)
1854 return 1;
1855
1856 return 0;
1857}
1858
1576static int 1859static int
1577bnx2_poll(struct net_device *dev, int *budget) 1860bnx2_poll(struct net_device *dev, int *budget)
1578{ 1861{
1579 struct bnx2 *bp = dev->priv; 1862 struct bnx2 *bp = dev->priv;
1580 int rx_done = 1;
1581 1863
1582 bp->last_status_idx = bp->status_blk->status_idx;
1583
1584 rmb();
1585 if ((bp->status_blk->status_attn_bits & 1864 if ((bp->status_blk->status_attn_bits &
1586 STATUS_ATTN_BITS_LINK_STATE) != 1865 STATUS_ATTN_BITS_LINK_STATE) !=
1587 (bp->status_blk->status_attn_bits_ack & 1866 (bp->status_blk->status_attn_bits_ack &
@@ -1592,11 +1871,10 @@ bnx2_poll(struct net_device *dev, int *budget)
1592 spin_unlock(&bp->phy_lock); 1871 spin_unlock(&bp->phy_lock);
1593 } 1872 }
1594 1873
1595 if (bp->status_blk->status_tx_quick_consumer_index0 != bp->tx_cons) { 1874 if (bp->status_blk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)
1596 bnx2_tx_int(bp); 1875 bnx2_tx_int(bp);
1597 }
1598 1876
1599 if (bp->status_blk->status_rx_quick_consumer_index0 != bp->rx_cons) { 1877 if (bp->status_blk->status_rx_quick_consumer_index0 != bp->hw_rx_cons) {
1600 int orig_budget = *budget; 1878 int orig_budget = *budget;
1601 int work_done; 1879 int work_done;
1602 1880
@@ -1606,13 +1884,12 @@ bnx2_poll(struct net_device *dev, int *budget)
1606 work_done = bnx2_rx_int(bp, orig_budget); 1884 work_done = bnx2_rx_int(bp, orig_budget);
1607 *budget -= work_done; 1885 *budget -= work_done;
1608 dev->quota -= work_done; 1886 dev->quota -= work_done;
1609
1610 if (work_done >= orig_budget) {
1611 rx_done = 0;
1612 }
1613 } 1887 }
1614 1888
1615 if (rx_done) { 1889 bp->last_status_idx = bp->status_blk->status_idx;
1890 rmb();
1891
1892 if (!bnx2_has_work(bp)) {
1616 netif_rx_complete(dev); 1893 netif_rx_complete(dev);
1617 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, 1894 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
1618 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | 1895 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
@@ -2383,21 +2660,27 @@ bnx2_init_nvram(struct bnx2 *bp)
2383 2660
2384 /* Flash interface has been reconfigured */ 2661 /* Flash interface has been reconfigured */
2385 for (j = 0, flash = &flash_table[0]; j < entry_count; 2662 for (j = 0, flash = &flash_table[0]; j < entry_count;
2386 j++, flash++) { 2663 j++, flash++) {
2387 2664 if ((val & FLASH_BACKUP_STRAP_MASK) ==
2388 if (val == flash->config1) { 2665 (flash->config1 & FLASH_BACKUP_STRAP_MASK)) {
2389 bp->flash_info = flash; 2666 bp->flash_info = flash;
2390 break; 2667 break;
2391 } 2668 }
2392 } 2669 }
2393 } 2670 }
2394 else { 2671 else {
2672 u32 mask;
2395 /* Not yet been reconfigured */ 2673 /* Not yet been reconfigured */
2396 2674
2675 if (val & (1 << 23))
2676 mask = FLASH_BACKUP_STRAP_MASK;
2677 else
2678 mask = FLASH_STRAP_MASK;
2679
2397 for (j = 0, flash = &flash_table[0]; j < entry_count; 2680 for (j = 0, flash = &flash_table[0]; j < entry_count;
2398 j++, flash++) { 2681 j++, flash++) {
2399 2682
2400 if ((val & FLASH_STRAP_MASK) == flash->strapping) { 2683 if ((val & mask) == (flash->strapping & mask)) {
2401 bp->flash_info = flash; 2684 bp->flash_info = flash;
2402 2685
2403 /* Request access to the flash interface. */ 2686 /* Request access to the flash interface. */
@@ -2733,7 +3016,7 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
2733 3016
2734 /* Deposit a driver reset signature so the firmware knows that 3017 /* Deposit a driver reset signature so the firmware knows that
2735 * this is a soft reset. */ 3018 * this is a soft reset. */
2736 REG_WR_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DRV_RESET_SIGNATURE, 3019 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_RESET_SIGNATURE,
2737 BNX2_DRV_RESET_SIGNATURE_MAGIC); 3020 BNX2_DRV_RESET_SIGNATURE_MAGIC);
2738 3021
2739 bp->fw_timed_out = 0; 3022 bp->fw_timed_out = 0;
@@ -2962,6 +3245,7 @@ bnx2_init_tx_ring(struct bnx2 *bp)
2962 3245
2963 bp->tx_prod = 0; 3246 bp->tx_prod = 0;
2964 bp->tx_cons = 0; 3247 bp->tx_cons = 0;
3248 bp->hw_tx_cons = 0;
2965 bp->tx_prod_bseq = 0; 3249 bp->tx_prod_bseq = 0;
2966 3250
2967 val = BNX2_L2CTX_TYPE_TYPE_L2; 3251 val = BNX2_L2CTX_TYPE_TYPE_L2;
@@ -2994,6 +3278,7 @@ bnx2_init_rx_ring(struct bnx2 *bp)
2994 3278
2995 ring_prod = prod = bp->rx_prod = 0; 3279 ring_prod = prod = bp->rx_prod = 0;
2996 bp->rx_cons = 0; 3280 bp->rx_cons = 0;
3281 bp->hw_rx_cons = 0;
2997 bp->rx_prod_bseq = 0; 3282 bp->rx_prod_bseq = 0;
2998 3283
2999 rxbd = &bp->rx_desc_ring[0]; 3284 rxbd = &bp->rx_desc_ring[0];
@@ -3079,7 +3364,7 @@ bnx2_free_rx_skbs(struct bnx2 *bp)
3079 struct sw_bd *rx_buf = &bp->rx_buf_ring[i]; 3364 struct sw_bd *rx_buf = &bp->rx_buf_ring[i];
3080 struct sk_buff *skb = rx_buf->skb; 3365 struct sk_buff *skb = rx_buf->skb;
3081 3366
3082 if (skb == 0) 3367 if (skb == NULL)
3083 continue; 3368 continue;
3084 3369
3085 pci_unmap_single(bp->pdev, pci_unmap_addr(rx_buf, mapping), 3370 pci_unmap_single(bp->pdev, pci_unmap_addr(rx_buf, mapping),
@@ -3234,7 +3519,7 @@ bnx2_test_registers(struct bnx2 *bp)
3234 { 0x1408, 0, 0x01c00800, 0x00000000 }, 3519 { 0x1408, 0, 0x01c00800, 0x00000000 },
3235 { 0x149c, 0, 0x8000ffff, 0x00000000 }, 3520 { 0x149c, 0, 0x8000ffff, 0x00000000 },
3236 { 0x14a8, 0, 0x00000000, 0x000001ff }, 3521 { 0x14a8, 0, 0x00000000, 0x000001ff },
3237 { 0x14ac, 0, 0x4fffffff, 0x10000000 }, 3522 { 0x14ac, 0, 0x0fffffff, 0x10000000 },
3238 { 0x14b0, 0, 0x00000002, 0x00000001 }, 3523 { 0x14b0, 0, 0x00000002, 0x00000001 },
3239 { 0x14b8, 0, 0x00000000, 0x00000000 }, 3524 { 0x14b8, 0, 0x00000000, 0x00000000 },
3240 { 0x14c0, 0, 0x00000000, 0x00000009 }, 3525 { 0x14c0, 0, 0x00000000, 0x00000009 },
@@ -3577,7 +3862,7 @@ bnx2_test_memory(struct bnx2 *bp)
3577 u32 len; 3862 u32 len;
3578 } mem_tbl[] = { 3863 } mem_tbl[] = {
3579 { 0x60000, 0x4000 }, 3864 { 0x60000, 0x4000 },
3580 { 0xa0000, 0x4000 }, 3865 { 0xa0000, 0x3000 },
3581 { 0xe0000, 0x4000 }, 3866 { 0xe0000, 0x4000 },
3582 { 0x120000, 0x4000 }, 3867 { 0x120000, 0x4000 },
3583 { 0x1a0000, 0x4000 }, 3868 { 0x1a0000, 0x4000 },
@@ -3810,7 +4095,7 @@ bnx2_timer(unsigned long data)
3810 goto bnx2_restart_timer; 4095 goto bnx2_restart_timer;
3811 4096
3812 msg = (u32) ++bp->fw_drv_pulse_wr_seq; 4097 msg = (u32) ++bp->fw_drv_pulse_wr_seq;
3813 REG_WR_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DRV_PULSE_MB, msg); 4098 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg);
3814 4099
3815 if ((bp->phy_flags & PHY_SERDES_FLAG) && 4100 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
3816 (CHIP_NUM(bp) == CHIP_NUM_5706)) { 4101 (CHIP_NUM(bp) == CHIP_NUM_5706)) {
@@ -4264,7 +4549,8 @@ bnx2_get_stats(struct net_device *dev)
4264 (unsigned long) (stats_blk->stat_Dot3StatsExcessiveCollisions + 4549 (unsigned long) (stats_blk->stat_Dot3StatsExcessiveCollisions +
4265 stats_blk->stat_Dot3StatsLateCollisions); 4550 stats_blk->stat_Dot3StatsLateCollisions);
4266 4551
4267 if (CHIP_NUM(bp) == CHIP_NUM_5706) 4552 if ((CHIP_NUM(bp) == CHIP_NUM_5706) ||
4553 (CHIP_ID(bp) == CHIP_ID_5708_A0))
4268 net_stats->tx_carrier_errors = 0; 4554 net_stats->tx_carrier_errors = 0;
4269 else { 4555 else {
4270 net_stats->tx_carrier_errors = 4556 net_stats->tx_carrier_errors =
@@ -4814,6 +5100,14 @@ static u8 bnx2_5706_stats_len_arr[BNX2_NUM_STATS] = {
4814 4,4,4,4,4, 5100 4,4,4,4,4,
4815}; 5101};
4816 5102
5103static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = {
5104 8,0,8,8,8,8,8,8,8,8,
5105 4,4,4,4,4,4,4,4,4,4,
5106 4,4,4,4,4,4,4,4,4,4,
5107 4,4,4,4,4,4,4,4,4,4,
5108 4,4,4,4,4,
5109};
5110
4817#define BNX2_NUM_TESTS 6 5111#define BNX2_NUM_TESTS 6
4818 5112
4819static struct { 5113static struct {
@@ -4922,8 +5216,13 @@ bnx2_get_ethtool_stats(struct net_device *dev,
4922 return; 5216 return;
4923 } 5217 }
4924 5218
4925 if (CHIP_NUM(bp) == CHIP_NUM_5706) 5219 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
5220 (CHIP_ID(bp) == CHIP_ID_5706_A1) ||
5221 (CHIP_ID(bp) == CHIP_ID_5706_A2) ||
5222 (CHIP_ID(bp) == CHIP_ID_5708_A0))
4926 stats_len_arr = bnx2_5706_stats_len_arr; 5223 stats_len_arr = bnx2_5706_stats_len_arr;
5224 else
5225 stats_len_arr = bnx2_5708_stats_len_arr;
4927 5226
4928 for (i = 0; i < BNX2_NUM_STATS; i++) { 5227 for (i = 0; i < BNX2_NUM_STATS; i++) {
4929 if (stats_len_arr[i] == 0) { 5228 if (stats_len_arr[i] == 0) {
@@ -5205,8 +5504,6 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5205 5504
5206 bp->chip_id = REG_RD(bp, BNX2_MISC_ID); 5505 bp->chip_id = REG_RD(bp, BNX2_MISC_ID);
5207 5506
5208 bp->phy_addr = 1;
5209
5210 /* Get bus information. */ 5507 /* Get bus information. */
5211 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS); 5508 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS);
5212 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) { 5509 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) {
@@ -5269,10 +5566,18 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5269 5566
5270 bnx2_init_nvram(bp); 5567 bnx2_init_nvram(bp);
5271 5568
5569 reg = REG_RD_IND(bp, BNX2_SHM_HDR_SIGNATURE);
5570
5571 if ((reg & BNX2_SHM_HDR_SIGNATURE_SIG_MASK) ==
5572 BNX2_SHM_HDR_SIGNATURE_SIG)
5573 bp->shmem_base = REG_RD_IND(bp, BNX2_SHM_HDR_ADDR_0);
5574 else
5575 bp->shmem_base = HOST_VIEW_SHMEM_BASE;
5576
5272 /* Get the permanent MAC address. First we need to make sure the 5577 /* Get the permanent MAC address. First we need to make sure the
5273 * firmware is actually running. 5578 * firmware is actually running.
5274 */ 5579 */
5275 reg = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DEV_INFO_SIGNATURE); 5580 reg = REG_RD_IND(bp, bp->shmem_base + BNX2_DEV_INFO_SIGNATURE);
5276 5581
5277 if ((reg & BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK) != 5582 if ((reg & BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK) !=
5278 BNX2_DEV_INFO_SIGNATURE_MAGIC) { 5583 BNX2_DEV_INFO_SIGNATURE_MAGIC) {
@@ -5281,14 +5586,13 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5281 goto err_out_unmap; 5586 goto err_out_unmap;
5282 } 5587 }
5283 5588
5284 bp->fw_ver = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + 5589 bp->fw_ver = REG_RD_IND(bp, bp->shmem_base + BNX2_DEV_INFO_BC_REV);
5285 BNX2_DEV_INFO_BC_REV);
5286 5590
5287 reg = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_PORT_HW_CFG_MAC_UPPER); 5591 reg = REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_HW_CFG_MAC_UPPER);
5288 bp->mac_addr[0] = (u8) (reg >> 8); 5592 bp->mac_addr[0] = (u8) (reg >> 8);
5289 bp->mac_addr[1] = (u8) reg; 5593 bp->mac_addr[1] = (u8) reg;
5290 5594
5291 reg = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_PORT_HW_CFG_MAC_LOWER); 5595 reg = REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_HW_CFG_MAC_LOWER);
5292 bp->mac_addr[2] = (u8) (reg >> 24); 5596 bp->mac_addr[2] = (u8) (reg >> 24);
5293 bp->mac_addr[3] = (u8) (reg >> 16); 5597 bp->mac_addr[3] = (u8) (reg >> 16);
5294 bp->mac_addr[4] = (u8) (reg >> 8); 5598 bp->mac_addr[4] = (u8) (reg >> 8);
@@ -5316,10 +5620,19 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5316 bp->timer_interval = HZ; 5620 bp->timer_interval = HZ;
5317 bp->current_interval = HZ; 5621 bp->current_interval = HZ;
5318 5622
5623 bp->phy_addr = 1;
5624
5319 /* Disable WOL support if we are running on a SERDES chip. */ 5625 /* Disable WOL support if we are running on a SERDES chip. */
5320 if (CHIP_BOND_ID(bp) & CHIP_BOND_ID_SERDES_BIT) { 5626 if (CHIP_BOND_ID(bp) & CHIP_BOND_ID_SERDES_BIT) {
5321 bp->phy_flags |= PHY_SERDES_FLAG; 5627 bp->phy_flags |= PHY_SERDES_FLAG;
5322 bp->flags |= NO_WOL_FLAG; 5628 bp->flags |= NO_WOL_FLAG;
5629 if (CHIP_NUM(bp) == CHIP_NUM_5708) {
5630 bp->phy_addr = 2;
5631 reg = REG_RD_IND(bp, bp->shmem_base +
5632 BNX2_SHARED_HW_CFG_CONFIG);
5633 if (reg & BNX2_SHARED_HW_CFG_PHY_2_5G)
5634 bp->phy_flags |= PHY_2_5G_CAPABLE_FLAG;
5635 }
5323 } 5636 }
5324 5637
5325 if (CHIP_ID(bp) == CHIP_ID_5706_A0) { 5638 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
@@ -5339,8 +5652,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5339 if (bp->phy_flags & PHY_SERDES_FLAG) { 5652 if (bp->phy_flags & PHY_SERDES_FLAG) {
5340 bp->advertising = ETHTOOL_ALL_FIBRE_SPEED | ADVERTISED_Autoneg; 5653 bp->advertising = ETHTOOL_ALL_FIBRE_SPEED | ADVERTISED_Autoneg;
5341 5654
5342 reg = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + 5655 reg = REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_HW_CFG_CONFIG);
5343 BNX2_PORT_HW_CFG_CONFIG);
5344 reg &= BNX2_PORT_HW_CFG_CFG_DFLT_LINK_MASK; 5656 reg &= BNX2_PORT_HW_CFG_CFG_DFLT_LINK_MASK;
5345 if (reg == BNX2_PORT_HW_CFG_CFG_DFLT_LINK_1G) { 5657 if (reg == BNX2_PORT_HW_CFG_CFG_DFLT_LINK_1G) {
5346 bp->autoneg = 0; 5658 bp->autoneg = 0;
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 62857b6a6ee4..76bb5f1a250b 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -1449,8 +1449,9 @@ struct l2_fhdr {
1449#define BNX2_EMAC_MODE_PORT_NONE (0L<<2) 1449#define BNX2_EMAC_MODE_PORT_NONE (0L<<2)
1450#define BNX2_EMAC_MODE_PORT_MII (1L<<2) 1450#define BNX2_EMAC_MODE_PORT_MII (1L<<2)
1451#define BNX2_EMAC_MODE_PORT_GMII (2L<<2) 1451#define BNX2_EMAC_MODE_PORT_GMII (2L<<2)
1452#define BNX2_EMAC_MODE_PORT_UNDEF (3L<<2) 1452#define BNX2_EMAC_MODE_PORT_MII_10 (3L<<2)
1453#define BNX2_EMAC_MODE_MAC_LOOP (1L<<4) 1453#define BNX2_EMAC_MODE_MAC_LOOP (1L<<4)
1454#define BNX2_EMAC_MODE_25G (1L<<5)
1454#define BNX2_EMAC_MODE_TAGGED_MAC_CTL (1L<<7) 1455#define BNX2_EMAC_MODE_TAGGED_MAC_CTL (1L<<7)
1455#define BNX2_EMAC_MODE_TX_BURST (1L<<8) 1456#define BNX2_EMAC_MODE_TX_BURST (1L<<8)
1456#define BNX2_EMAC_MODE_MAX_DEFER_DROP_ENA (1L<<9) 1457#define BNX2_EMAC_MODE_MAX_DEFER_DROP_ENA (1L<<9)
@@ -3714,6 +3715,15 @@ struct l2_fhdr {
3714#define BNX2_MCP_ROM 0x00150000 3715#define BNX2_MCP_ROM 0x00150000
3715#define BNX2_MCP_SCRATCH 0x00160000 3716#define BNX2_MCP_SCRATCH 0x00160000
3716 3717
3718#define BNX2_SHM_HDR_SIGNATURE BNX2_MCP_SCRATCH
3719#define BNX2_SHM_HDR_SIGNATURE_SIG_MASK 0xffff0000
3720#define BNX2_SHM_HDR_SIGNATURE_SIG 0x53530000
3721#define BNX2_SHM_HDR_SIGNATURE_VER_MASK 0x000000ff
3722#define BNX2_SHM_HDR_SIGNATURE_VER_ONE 0x00000001
3723
3724#define BNX2_SHM_HDR_ADDR_0 BNX2_MCP_SCRATCH + 4
3725#define BNX2_SHM_HDR_ADDR_1 BNX2_MCP_SCRATCH + 8
3726
3717 3727
3718#define NUM_MC_HASH_REGISTERS 8 3728#define NUM_MC_HASH_REGISTERS 8
3719 3729
@@ -3724,6 +3734,53 @@ struct l2_fhdr {
3724#define PHY_ID(id) ((id) & 0xfffffff0) 3734#define PHY_ID(id) ((id) & 0xfffffff0)
3725#define PHY_REV_ID(id) ((id) & 0xf) 3735#define PHY_REV_ID(id) ((id) & 0xf)
3726 3736
3737/* 5708 Serdes PHY registers */
3738
3739#define BCM5708S_UP1 0xb
3740
3741#define BCM5708S_UP1_2G5 0x1
3742
3743#define BCM5708S_BLK_ADDR 0x1f
3744
3745#define BCM5708S_BLK_ADDR_DIG 0x0000
3746#define BCM5708S_BLK_ADDR_DIG3 0x0002
3747#define BCM5708S_BLK_ADDR_TX_MISC 0x0005
3748
3749/* Digital Block */
3750#define BCM5708S_1000X_CTL1 0x10
3751
3752#define BCM5708S_1000X_CTL1_FIBER_MODE 0x0001
3753#define BCM5708S_1000X_CTL1_AUTODET_EN 0x0010
3754
3755#define BCM5708S_1000X_CTL2 0x11
3756
3757#define BCM5708S_1000X_CTL2_PLLEL_DET_EN 0x0001
3758
3759#define BCM5708S_1000X_STAT1 0x14
3760
3761#define BCM5708S_1000X_STAT1_SGMII 0x0001
3762#define BCM5708S_1000X_STAT1_LINK 0x0002
3763#define BCM5708S_1000X_STAT1_FD 0x0004
3764#define BCM5708S_1000X_STAT1_SPEED_MASK 0x0018
3765#define BCM5708S_1000X_STAT1_SPEED_10 0x0000
3766#define BCM5708S_1000X_STAT1_SPEED_100 0x0008
3767#define BCM5708S_1000X_STAT1_SPEED_1G 0x0010
3768#define BCM5708S_1000X_STAT1_SPEED_2G5 0x0018
3769#define BCM5708S_1000X_STAT1_TX_PAUSE 0x0020
3770#define BCM5708S_1000X_STAT1_RX_PAUSE 0x0040
3771
3772/* Digital3 Block */
3773#define BCM5708S_DIG_3_0 0x10
3774
3775#define BCM5708S_DIG_3_0_USE_IEEE 0x0001
3776
3777/* Tx/Misc Block */
3778#define BCM5708S_TX_ACTL1 0x15
3779
3780#define BCM5708S_TX_ACTL1_DRIVER_VCM 0x30
3781
3782#define BCM5708S_TX_ACTL3 0x17
3783
3727#define MIN_ETHERNET_PACKET_SIZE 60 3784#define MIN_ETHERNET_PACKET_SIZE 60
3728#define MAX_ETHERNET_PACKET_SIZE 1514 3785#define MAX_ETHERNET_PACKET_SIZE 1514
3729#define MAX_ETHERNET_JUMBO_PACKET_SIZE 9014 3786#define MAX_ETHERNET_JUMBO_PACKET_SIZE 9014
@@ -3799,7 +3856,7 @@ struct sw_bd {
3799#define BUFFERED_FLASH_PHY_PAGE_SIZE (1 << BUFFERED_FLASH_PAGE_BITS) 3856#define BUFFERED_FLASH_PHY_PAGE_SIZE (1 << BUFFERED_FLASH_PAGE_BITS)
3800#define BUFFERED_FLASH_BYTE_ADDR_MASK (BUFFERED_FLASH_PHY_PAGE_SIZE-1) 3857#define BUFFERED_FLASH_BYTE_ADDR_MASK (BUFFERED_FLASH_PHY_PAGE_SIZE-1)
3801#define BUFFERED_FLASH_PAGE_SIZE 264 3858#define BUFFERED_FLASH_PAGE_SIZE 264
3802#define BUFFERED_FLASH_TOTAL_SIZE 131072 3859#define BUFFERED_FLASH_TOTAL_SIZE 0x21000
3803 3860
3804#define SAIFUN_FLASH_PAGE_BITS 8 3861#define SAIFUN_FLASH_PAGE_BITS 8
3805#define SAIFUN_FLASH_PHY_PAGE_SIZE (1 << SAIFUN_FLASH_PAGE_BITS) 3862#define SAIFUN_FLASH_PHY_PAGE_SIZE (1 << SAIFUN_FLASH_PAGE_BITS)
@@ -3807,6 +3864,12 @@ struct sw_bd {
3807#define SAIFUN_FLASH_PAGE_SIZE 256 3864#define SAIFUN_FLASH_PAGE_SIZE 256
3808#define SAIFUN_FLASH_BASE_TOTAL_SIZE 65536 3865#define SAIFUN_FLASH_BASE_TOTAL_SIZE 65536
3809 3866
3867#define ST_MICRO_FLASH_PAGE_BITS 8
3868#define ST_MICRO_FLASH_PHY_PAGE_SIZE (1 << ST_MICRO_FLASH_PAGE_BITS)
3869#define ST_MICRO_FLASH_BYTE_ADDR_MASK (ST_MICRO_FLASH_PHY_PAGE_SIZE-1)
3870#define ST_MICRO_FLASH_PAGE_SIZE 256
3871#define ST_MICRO_FLASH_BASE_TOTAL_SIZE 65536
3872
3810#define NVRAM_TIMEOUT_COUNT 30000 3873#define NVRAM_TIMEOUT_COUNT 30000
3811 3874
3812 3875
@@ -3815,6 +3878,8 @@ struct sw_bd {
3815 BNX2_NVM_CFG1_PROTECT_MODE | \ 3878 BNX2_NVM_CFG1_PROTECT_MODE | \
3816 BNX2_NVM_CFG1_FLASH_SIZE) 3879 BNX2_NVM_CFG1_FLASH_SIZE)
3817 3880
3881#define FLASH_BACKUP_STRAP_MASK (0xf << 26)
3882
3818struct flash_spec { 3883struct flash_spec {
3819 u32 strapping; 3884 u32 strapping;
3820 u32 config1; 3885 u32 config1;
@@ -3849,6 +3914,9 @@ struct bnx2 {
3849 u16 tx_cons; 3914 u16 tx_cons;
3850 int tx_ring_size; 3915 int tx_ring_size;
3851 3916
3917 u16 hw_tx_cons;
3918 u16 hw_rx_cons;
3919
3852#ifdef BCM_VLAN 3920#ifdef BCM_VLAN
3853 struct vlan_group *vlgrp; 3921 struct vlan_group *vlgrp;
3854#endif 3922#endif
@@ -3893,6 +3961,7 @@ struct bnx2 {
3893#define PHY_SERDES_FLAG 1 3961#define PHY_SERDES_FLAG 1
3894#define PHY_CRC_FIX_FLAG 2 3962#define PHY_CRC_FIX_FLAG 2
3895#define PHY_PARALLEL_DETECT_FLAG 4 3963#define PHY_PARALLEL_DETECT_FLAG 4
3964#define PHY_2_5G_CAPABLE_FLAG 8
3896#define PHY_INT_MODE_MASK_FLAG 0x300 3965#define PHY_INT_MODE_MASK_FLAG 0x300
3897#define PHY_INT_MODE_AUTO_POLLING_FLAG 0x100 3966#define PHY_INT_MODE_AUTO_POLLING_FLAG 0x100
3898#define PHY_INT_MODE_LINK_READY_FLAG 0x200 3967#define PHY_INT_MODE_LINK_READY_FLAG 0x200
@@ -3901,6 +3970,7 @@ struct bnx2 {
3901 /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */ 3970 /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */
3902#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000) 3971#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000)
3903#define CHIP_NUM_5706 0x57060000 3972#define CHIP_NUM_5706 0x57060000
3973#define CHIP_NUM_5708 0x57080000
3904 3974
3905#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000) 3975#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000)
3906#define CHIP_REV_Ax 0x00000000 3976#define CHIP_REV_Ax 0x00000000
@@ -3913,6 +3983,9 @@ struct bnx2 {
3913#define CHIP_ID(bp) (((bp)->chip_id) & 0xfffffff0) 3983#define CHIP_ID(bp) (((bp)->chip_id) & 0xfffffff0)
3914#define CHIP_ID_5706_A0 0x57060000 3984#define CHIP_ID_5706_A0 0x57060000
3915#define CHIP_ID_5706_A1 0x57060010 3985#define CHIP_ID_5706_A1 0x57060010
3986#define CHIP_ID_5706_A2 0x57060020
3987#define CHIP_ID_5708_A0 0x57080000
3988#define CHIP_ID_5708_B0 0x57081000
3916 3989
3917#define CHIP_BOND_ID(bp) (((bp)->chip_id) & 0xf) 3990#define CHIP_BOND_ID(bp) (((bp)->chip_id) & 0xf)
3918 3991
@@ -3991,6 +4064,8 @@ struct bnx2 {
3991 4064
3992 u8 mac_addr[8]; 4065 u8 mac_addr[8];
3993 4066
4067 u32 shmem_base;
4068
3994 u32 fw_ver; 4069 u32 fw_ver;
3995 4070
3996 int pm_cap; 4071 int pm_cap;
@@ -4130,14 +4205,46 @@ struct fw_info {
4130#define BNX2_FW_MSG_STATUS_FAILURE 0x00ff0000 4205#define BNX2_FW_MSG_STATUS_FAILURE 0x00ff0000
4131 4206
4132#define BNX2_LINK_STATUS 0x0000000c 4207#define BNX2_LINK_STATUS 0x0000000c
4208#define BNX2_LINK_STATUS_INIT_VALUE 0xffffffff
4209#define BNX2_LINK_STATUS_LINK_UP 0x1
4210#define BNX2_LINK_STATUS_LINK_DOWN 0x0
4211#define BNX2_LINK_STATUS_SPEED_MASK 0x1e
4212#define BNX2_LINK_STATUS_AN_INCOMPLETE (0<<1)
4213#define BNX2_LINK_STATUS_10HALF (1<<1)
4214#define BNX2_LINK_STATUS_10FULL (2<<1)
4215#define BNX2_LINK_STATUS_100HALF (3<<1)
4216#define BNX2_LINK_STATUS_100BASE_T4 (4<<1)
4217#define BNX2_LINK_STATUS_100FULL (5<<1)
4218#define BNX2_LINK_STATUS_1000HALF (6<<1)
4219#define BNX2_LINK_STATUS_1000FULL (7<<1)
4220#define BNX2_LINK_STATUS_2500HALF (8<<1)
4221#define BNX2_LINK_STATUS_2500FULL (9<<1)
4222#define BNX2_LINK_STATUS_AN_ENABLED (1<<5)
4223#define BNX2_LINK_STATUS_AN_COMPLETE (1<<6)
4224#define BNX2_LINK_STATUS_PARALLEL_DET (1<<7)
4225#define BNX2_LINK_STATUS_RESERVED (1<<8)
4226#define BNX2_LINK_STATUS_PARTNER_AD_1000FULL (1<<9)
4227#define BNX2_LINK_STATUS_PARTNER_AD_1000HALF (1<<10)
4228#define BNX2_LINK_STATUS_PARTNER_AD_100BT4 (1<<11)
4229#define BNX2_LINK_STATUS_PARTNER_AD_100FULL (1<<12)
4230#define BNX2_LINK_STATUS_PARTNER_AD_100HALF (1<<13)
4231#define BNX2_LINK_STATUS_PARTNER_AD_10FULL (1<<14)
4232#define BNX2_LINK_STATUS_PARTNER_AD_10HALF (1<<15)
4233#define BNX2_LINK_STATUS_TX_FC_ENABLED (1<<16)
4234#define BNX2_LINK_STATUS_RX_FC_ENABLED (1<<17)
4235#define BNX2_LINK_STATUS_PARTNER_SYM_PAUSE_CAP (1<<18)
4236#define BNX2_LINK_STATUS_PARTNER_ASYM_PAUSE_CAP (1<<19)
4237#define BNX2_LINK_STATUS_SERDES_LINK (1<<20)
4238#define BNX2_LINK_STATUS_PARTNER_AD_2500FULL (1<<21)
4239#define BNX2_LINK_STATUS_PARTNER_AD_2500HALF (1<<22)
4133 4240
4134#define BNX2_DRV_PULSE_MB 0x00000010 4241#define BNX2_DRV_PULSE_MB 0x00000010
4135#define BNX2_DRV_PULSE_SEQ_MASK 0x0000ffff 4242#define BNX2_DRV_PULSE_SEQ_MASK 0x00007fff
4136 4243
4137/* Indicate to the firmware not to go into the 4244/* Indicate to the firmware not to go into the
4138 * OS absent when it is not getting driver pulse. 4245 * OS absent when it is not getting driver pulse.
4139 * This is used for debugging. */ 4246 * This is used for debugging. */
4140#define BNX2_DRV_MSG_DATA_PULSE_CODE_ALWAYS_ALIVE 0x00010000 4247#define BNX2_DRV_MSG_DATA_PULSE_CODE_ALWAYS_ALIVE 0x00080000
4141 4248
4142#define BNX2_DEV_INFO_SIGNATURE 0x00000020 4249#define BNX2_DEV_INFO_SIGNATURE 0x00000020
4143#define BNX2_DEV_INFO_SIGNATURE_MAGIC 0x44564900 4250#define BNX2_DEV_INFO_SIGNATURE_MAGIC 0x44564900
@@ -4160,6 +4267,8 @@ struct fw_info {
4160#define BNX2_SHARED_HW_CFG_DESIGN_LOM 0x1 4267#define BNX2_SHARED_HW_CFG_DESIGN_LOM 0x1
4161#define BNX2_SHARED_HW_CFG_PHY_COPPER 0 4268#define BNX2_SHARED_HW_CFG_PHY_COPPER 0
4162#define BNX2_SHARED_HW_CFG_PHY_FIBER 0x2 4269#define BNX2_SHARED_HW_CFG_PHY_FIBER 0x2
4270#define BNX2_SHARED_HW_CFG_PHY_2_5G 0x20
4271#define BNX2_SHARED_HW_CFG_PHY_BACKPLANE 0x40
4163#define BNX2_SHARED_HW_CFG_LED_MODE_SHIFT_BITS 8 4272#define BNX2_SHARED_HW_CFG_LED_MODE_SHIFT_BITS 8
4164#define BNX2_SHARED_HW_CFG_LED_MODE_MASK 0x300 4273#define BNX2_SHARED_HW_CFG_LED_MODE_MASK 0x300
4165#define BNX2_SHARED_HW_CFG_LED_MODE_MAC 0 4274#define BNX2_SHARED_HW_CFG_LED_MODE_MAC 0
@@ -4173,9 +4282,11 @@ struct fw_info {
4173 4282
4174#define BNX2_PORT_HW_CFG_MAC_LOWER 0x00000054 4283#define BNX2_PORT_HW_CFG_MAC_LOWER 0x00000054
4175#define BNX2_PORT_HW_CFG_CONFIG 0x00000058 4284#define BNX2_PORT_HW_CFG_CONFIG 0x00000058
4285#define BNX2_PORT_HW_CFG_CFG_TXCTL3_MASK 0x0000ffff
4176#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_MASK 0x001f0000 4286#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_MASK 0x001f0000
4177#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_AN 0x00000000 4287#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_AN 0x00000000
4178#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_1G 0x00030000 4288#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_1G 0x00030000
4289#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_2_5G 0x00040000
4179 4290
4180#define BNX2_PORT_HW_CFG_IMD_MAC_A_UPPER 0x00000068 4291#define BNX2_PORT_HW_CFG_IMD_MAC_A_UPPER 0x00000068
4181#define BNX2_PORT_HW_CFG_IMD_MAC_A_LOWER 0x0000006c 4292#define BNX2_PORT_HW_CFG_IMD_MAC_A_LOWER 0x0000006c
diff --git a/drivers/net/bnx2_fw.h b/drivers/net/bnx2_fw.h
index 35f3a2ae5ef1..ab07a4900e9a 100644
--- a/drivers/net/bnx2_fw.h
+++ b/drivers/net/bnx2_fw.h
@@ -14,24 +14,23 @@
14 * accompanying it. 14 * accompanying it.
15 */ 15 */
16 16
17 17static int bnx2_COM_b06FwReleaseMajor = 0x1;
18static int bnx2_COM_b06FwReleaseMajor = 0x0;
19static int bnx2_COM_b06FwReleaseMinor = 0x0; 18static int bnx2_COM_b06FwReleaseMinor = 0x0;
20static int bnx2_COM_b06FwReleaseFix = 0x0; 19static int bnx2_COM_b06FwReleaseFix = 0x0;
21static u32 bnx2_COM_b06FwStartAddr = 0x080004a0; 20static u32 bnx2_COM_b06FwStartAddr = 0x080008b4;
22static u32 bnx2_COM_b06FwTextAddr = 0x08000000; 21static u32 bnx2_COM_b06FwTextAddr = 0x08000000;
23static int bnx2_COM_b06FwTextLen = 0x4594; 22static int bnx2_COM_b06FwTextLen = 0x57bc;
24static u32 bnx2_COM_b06FwDataAddr = 0x080045e0; 23static u32 bnx2_COM_b06FwDataAddr = 0x08005840;
25static int bnx2_COM_b06FwDataLen = 0x0; 24static int bnx2_COM_b06FwDataLen = 0x0;
26static u32 bnx2_COM_b06FwRodataAddr = 0x08004598; 25static u32 bnx2_COM_b06FwRodataAddr = 0x080057c0;
27static int bnx2_COM_b06FwRodataLen = 0x18; 26static int bnx2_COM_b06FwRodataLen = 0x58;
28static u32 bnx2_COM_b06FwBssAddr = 0x08004600; 27static u32 bnx2_COM_b06FwBssAddr = 0x08005860;
29static int bnx2_COM_b06FwBssLen = 0x88; 28static int bnx2_COM_b06FwBssLen = 0x88;
30static u32 bnx2_COM_b06FwSbssAddr = 0x080045e0; 29static u32 bnx2_COM_b06FwSbssAddr = 0x08005840;
31static int bnx2_COM_b06FwSbssLen = 0x1c; 30static int bnx2_COM_b06FwSbssLen = 0x1c;
32static u32 bnx2_COM_b06FwText[(0x4594/4) + 1] = { 31static u32 bnx2_COM_b06FwText[(0x57bc/4) + 1] = {
33 0x0a000128, 0x00000000, 0x00000000, 0x0000000d, 0x636f6d20, 0x302e362e, 32 0x0a00022d, 0x00000000, 0x00000000, 0x0000000d, 0x636f6d20, 0x322e352e,
34 0x39000000, 0x00060902, 0x00000000, 0x00000003, 0x00000014, 0x00000032, 33 0x38000000, 0x02050802, 0x00000000, 0x00000003, 0x00000014, 0x00000032,
35 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 34 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
36 0x00000010, 0x000003e8, 0x0000ea60, 0x00000001, 0x00000000, 0x00000000, 35 0x00000010, 0x000003e8, 0x0000ea60, 0x00000001, 0x00000000, 0x00000000,
37 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 36 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -79,70 +78,117 @@ static u32 bnx2_COM_b06FwText[(0x4594/4) + 1] = {
79 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 78 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
80 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 79 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
81 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 80 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
82 0x00000000, 0x00000000, 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 81 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
83 0x0000000d, 0x3c020800, 0x244245e0, 0x3c030800, 0x24634688, 0xac400000, 82 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
84 0x0043202b, 0x1480fffd, 0x24420004, 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 83 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
85 0x3c100800, 0x261004a0, 0x3c1c0800, 0x279c45e0, 0x0e0001f2, 0x00000000, 84 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
86 0x0000000d, 0x27bdffe8, 0x3c1a8000, 0x3c020008, 0x0342d825, 0x3c036010, 85 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
87 0xafbf0010, 0x8c655000, 0x3c020800, 0x24470ac8, 0x3c040800, 0x24864600, 86 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
88 0x2402ff7f, 0x00a22824, 0x34a5380c, 0xac655000, 0x00002821, 0x24020037, 87 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
89 0x24030c80, 0xaf420008, 0xaf430024, 0xacc70000, 0x24a50001, 0x2ca20016, 88 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
90 0x1440fffc, 0x24c60004, 0x24844600, 0x3c020800, 0x24420ad4, 0x3c030800, 89 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
91 0x246309d4, 0xac820004, 0x3c020800, 0x24420618, 0x3c050800, 0x24a50ca0, 90 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
92 0xac82000c, 0x3c020800, 0x24423100, 0xac830008, 0x3c030800, 0x246325c8, 91 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
93 0xac820014, 0x3c020800, 0x24422b0c, 0xac830018, 0xac83001c, 0x3c030800, 92 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
94 0x24630adc, 0xac820024, 0x3c020800, 0x24423040, 0xac83002c, 0x3c030800, 93 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
95 0x24633060, 0xac820030, 0x3c020800, 0x24422f6c, 0xac830034, 0x3c030800, 94 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
96 0x24632c60, 0xac82003c, 0x3c020800, 0x24420b6c, 0xac850010, 0xac850020, 95 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
97 0xac830040, 0x0e000bd6, 0xac820050, 0x8fbf0010, 0x03e00008, 0x27bd0018, 96 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
98 0x27bdffe0, 0xafb00010, 0x27500100, 0xafbf0018, 0xafb10014, 0x9203000b, 97 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
99 0x24020003, 0x1462005b, 0x96110008, 0x32220001, 0x10400009, 0x27430080, 98 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
100 0x8e020000, 0x96040014, 0x000211c2, 0x00021040, 0x00621821, 0xa4640000, 99 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
101 0x0a0001cb, 0x3c020800, 0x3c020800, 0x8c430020, 0x1060002a, 0x3c030800, 100 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
102 0x0e001006, 0x00000000, 0x97420108, 0x8f850018, 0x9743010c, 0x3042003e, 101 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
103 0x00021400, 0x00621825, 0xaca30000, 0x8f840018, 0x8f420100, 0xac820004, 102 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
104 0x97430116, 0x9742010e, 0x8f840018, 0x00031c00, 0x00431025, 0xac820008, 103 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
105 0x97430110, 0x97440112, 0x8f850018, 0x00031c00, 0x00832025, 0xaca4000c, 104 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
106 0x97420114, 0x8f840018, 0x3042ffff, 0xac820010, 0x8f830018, 0xac600014, 105 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
107 0x8f820018, 0x3c030800, 0xac400018, 0x9462466e, 0x8f840018, 0x3c032000, 106 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
108 0x00431025, 0xac82001c, 0x0e001044, 0x24040001, 0x3c030800, 0x8c620040, 107 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
109 0x24420001, 0xac620040, 0x3c020800, 0x8c430044, 0x32240004, 0x24630001, 108 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
110 0x10800017, 0xac430044, 0x8f4202b8, 0x04430007, 0x8e020020, 0x3c040800, 109 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
111 0x8c830060, 0x24020001, 0x24630001, 0x0a0001ed, 0xac830060, 0x3c060800, 110 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
112 0x8cc4005c, 0xaf420280, 0x96030016, 0x00001021, 0xa7430284, 0x8e050004, 111 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
113 0x24840001, 0x3c031000, 0xaf450288, 0xaf4302b8, 0x0a0001ed, 0xacc4005c, 112 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
114 0x32220002, 0x0a0001ed, 0x0002102b, 0x3c026000, 0xac400808, 0x0000000d, 113 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
115 0x00001021, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 114 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
116 0x27bdffc8, 0xafbf0034, 0xafbe0030, 0xafb7002c, 0xafb60028, 0xafb50024, 115 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
117 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014, 0x0e00013f, 0xafb00010, 116 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
118 0x24110020, 0x24150030, 0x2794000c, 0x27930008, 0x3c124000, 0x3c1e0800, 117 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
119 0x3c170800, 0x3c160800, 0x8f820004, 0x3c040800, 0x8c830020, 0x10430004, 118 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
120 0x00000000, 0xaf830004, 0x0e00110b, 0x00000000, 0x8f500000, 0x32020007, 119 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
121 0x1040fff5, 0x32020001, 0x1040002b, 0x32020002, 0x8f420100, 0xaf420020, 120 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
122 0x8f430104, 0xaf4300a8, 0x9342010b, 0x93630000, 0x306300ff, 0x10710005, 121 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
123 0x304400ff, 0x10750006, 0x2c820016, 0x0a000227, 0x00000000, 0xaf940000, 122 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
124 0x0a000228, 0x2c820016, 0xaf930000, 0x0a000228, 0x00000000, 0xaf800000, 123 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
125 0x14400005, 0x00041880, 0x0e0002b2, 0x00000000, 0x0a000234, 0x00000000, 124 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
126 0x3c020800, 0x24424600, 0x00621821, 0x8c620000, 0x0040f809, 0x00000000, 125 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800, 0x24425840,
127 0x10400005, 0x8fc20034, 0x8f420104, 0x3c016020, 0xac220014, 0x8fc20034, 126 0x3c030800, 0x246358e8, 0xac400000, 0x0043202b, 0x1480fffd, 0x24420004,
128 0xaf520138, 0x24420001, 0xafc20034, 0x32020002, 0x10400019, 0x32020004, 127 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 0x3c100800, 0x261008b4, 0x3c1c0800,
129 0x8f420140, 0xaf420020, 0x93630000, 0x306300ff, 0x10710005, 0x00000000, 128 0x279c5840, 0x0e0002f7, 0x00000000, 0x0000000d, 0x27bdffe8, 0x3c1a8000,
130 0x10750006, 0x00000000, 0x0a000250, 0x00000000, 0xaf940000, 0x0a000251, 129 0x3c020008, 0x0342d825, 0x3c036010, 0xafbf0010, 0x8c655000, 0x3c020800,
131 0x00000000, 0xaf930000, 0x0a000251, 0x00000000, 0xaf800000, 0x0e0008b9, 130 0x24470f30, 0x3c040800, 0x24865860, 0x2402ff7f, 0x00a22824, 0x34a5380c,
132 0x00000000, 0x8ee20038, 0xaf520178, 0x24420001, 0xaee20038, 0x32020004, 131 0xac655000, 0x00002821, 0x24020037, 0x24030c80, 0xaf420008, 0xaf430024,
133 0x1040ffad, 0x00000000, 0x8f420180, 0xaf420020, 0x93630000, 0x306300ff, 132 0xacc70000, 0x24a50001, 0x2ca20016, 0x1440fffc, 0x24c60004, 0x24845860,
134 0x10710005, 0x00000000, 0x10750006, 0x00000000, 0x0a00026a, 0x00000000, 133 0x3c020800, 0x24420f3c, 0x3c030800, 0x24630e2c, 0xac820004, 0x3c020800,
135 0xaf940000, 0x0a00026b, 0x00000000, 0xaf930000, 0x0a00026b, 0x00000000, 134 0x24420a2c, 0x3c050800, 0x24a51268, 0xac82000c, 0x3c020800, 0x244243dc,
136 0xaf800000, 0x93620000, 0x14510004, 0x8ec2003c, 0x0e000835, 0x00000000, 135 0xac830008, 0x3c030800, 0x24633698, 0xac820014, 0x3c020800, 0x24423c24,
137 0x8ec2003c, 0xaf5201b8, 0x24420001, 0x0a000206, 0xaec2003c, 0x27bdffe8, 136 0xac830018, 0xac83001c, 0x3c030800, 0x24630f44, 0xac820024, 0x3c020800,
138 0xafbf0010, 0x97420108, 0x24033000, 0x30447000, 0x10830012, 0x28823001, 137 0x244243ac, 0xac83002c, 0x3c030800, 0x246343cc, 0xac820030, 0x3c020800,
139 0x10400007, 0x24024000, 0x1080000b, 0x24022000, 0x1082001a, 0x24020001, 138 0x244242f0, 0xac830034, 0x3c030800, 0x24633d78, 0xac82003c, 0x3c020800,
140 0x0a000299, 0x00000000, 0x1082000c, 0x24025000, 0x1082000e, 0x00000000, 139 0x24420fd4, 0xac850010, 0xac850020, 0xac830040, 0x0e0010b7, 0xac820050,
141 0x0a000299, 0x00000000, 0x0000000d, 0x0a00029b, 0x00001021, 0x0e000300, 140 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe0, 0xafb00010, 0x27500100,
142 0x00000000, 0x0a00029b, 0x00001021, 0x0e00048f, 0x00000000, 0x0a00029b, 141 0xafbf0018, 0xafb10014, 0x9203000b, 0x24020003, 0x1462005b, 0x96110008,
143 0x00001021, 0x0e000fdf, 0x00000000, 0x0a00029b, 0x00001021, 0x0000000d, 142 0x32220001, 0x10400009, 0x27430080, 0x8e020000, 0x96040014, 0x000211c2,
143 0x00021040, 0x00621821, 0xa4640000, 0x0a0002d0, 0x3c020800, 0x3c020800,
144 0x8c430020, 0x1060002a, 0x3c030800, 0x0e00148e, 0x00000000, 0x97420108,
145 0x8f850018, 0x9743010c, 0x3042003e, 0x00021400, 0x00621825, 0xaca30000,
146 0x8f840018, 0x8f420100, 0xac820004, 0x97430116, 0x9742010e, 0x8f840018,
147 0x00031c00, 0x00431025, 0xac820008, 0x97430110, 0x97440112, 0x8f850018,
148 0x00031c00, 0x00832025, 0xaca4000c, 0x97420114, 0x8f840018, 0x3042ffff,
149 0xac820010, 0x8f830018, 0xac600014, 0x8f820018, 0x3c030800, 0xac400018,
150 0x946258ce, 0x8f840018, 0x3c032000, 0x00431025, 0xac82001c, 0x0e0014cc,
151 0x24040001, 0x3c030800, 0x8c620040, 0x24420001, 0xac620040, 0x3c020800,
152 0x8c430044, 0x32240004, 0x24630001, 0x10800017, 0xac430044, 0x8f4202b8,
153 0x04430007, 0x8e020020, 0x3c040800, 0x8c830060, 0x24020001, 0x24630001,
154 0x0a0002f2, 0xac830060, 0x3c060800, 0x8cc4005c, 0xaf420280, 0x96030016,
155 0x00001021, 0xa7430284, 0x8e050004, 0x24840001, 0x3c031000, 0xaf450288,
156 0xaf4302b8, 0x0a0002f2, 0xacc4005c, 0x32220002, 0x0a0002f2, 0x0002102b,
157 0x3c026000, 0xac400808, 0x0000000d, 0x00001021, 0x8fbf0018, 0x8fb10014,
158 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffc8, 0xafbf0034, 0xafbe0030,
159 0xafb7002c, 0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c, 0xafb20018,
160 0xafb10014, 0x0e000244, 0xafb00010, 0x3c170800, 0x3c160800, 0x24110020,
161 0x24150030, 0x2794000c, 0x27930008, 0x3c124000, 0x3c1e0800, 0x8f820004,
162 0x3c040800, 0x8c830020, 0x10430005, 0x8ee200a4, 0xaf830004, 0x0e001593,
163 0x00000000, 0x8ee200a4, 0x8ec300a0, 0x10430004, 0x26c400a0, 0x94820002,
164 0xa742009e, 0xaee300a4, 0x8f500000, 0x32020007, 0x1040ffee, 0x32020001,
165 0x1040002c, 0x32020002, 0x8f420100, 0xaf420020, 0x8f430104, 0xaf4300a8,
166 0x9342010b, 0x93630000, 0x306300ff, 0x10710005, 0x304400ff, 0x10750006,
167 0x2c820016, 0x0a000333, 0x00000000, 0xaf940000, 0x0a000334, 0x2c820016,
168 0xaf930000, 0x0a000334, 0x00000000, 0xaf800000, 0x14400005, 0x00041880,
169 0x0e0003cc, 0x00000000, 0x0a000340, 0x00000000, 0x3c020800, 0x24425860,
170 0x00621821, 0x8c620000, 0x0040f809, 0x00000000, 0x10400005, 0x3c030800,
171 0x8f420104, 0x3c016020, 0xac220014, 0x3c030800, 0x8c620034, 0xaf520138,
172 0x24420001, 0xac620034, 0x32020002, 0x1040001a, 0x32020004, 0x8f420140,
173 0xaf420020, 0x93630000, 0x306300ff, 0x10710005, 0x00000000, 0x10750006,
174 0x00000000, 0x0a00035d, 0x00000000, 0xaf940000, 0x0a00035e, 0x00000000,
175 0xaf930000, 0x0a00035e, 0x00000000, 0xaf800000, 0x0e000c7b, 0x00000000,
176 0x3c040800, 0x8c820038, 0xaf520178, 0x24420001, 0xac820038, 0x32020004,
177 0x1040ffa4, 0x00000000, 0x8f420180, 0xaf420020, 0x93630000, 0x306300ff,
178 0x10710005, 0x00000000, 0x10750006, 0x00000000, 0x0a000378, 0x00000000,
179 0xaf940000, 0x0a000379, 0x00000000, 0xaf930000, 0x0a000379, 0x00000000,
180 0xaf800000, 0x8f430180, 0x24020f00, 0x14620005, 0x00000000, 0x8f420188,
181 0xa742009c, 0x0a000387, 0x8fc2003c, 0x93620000, 0x14510004, 0x8fc2003c,
182 0x0e000bad, 0x00000000, 0x8fc2003c, 0xaf5201b8, 0x24420001, 0x0a00030b,
183 0xafc2003c, 0x27bdffe8, 0xafbf0010, 0x97420108, 0x24033000, 0x30447000,
184 0x10830016, 0x28823001, 0x10400007, 0x24024000, 0x1080000b, 0x24022000,
185 0x1082000c, 0x00000000, 0x0a0003b3, 0x00000000, 0x10820010, 0x24025000,
186 0x10820012, 0x00000000, 0x0a0003b3, 0x00000000, 0x0000000d, 0x0a0003b5,
187 0x00001021, 0x0e000442, 0x00000000, 0x0a0003b6, 0x8fbf0010, 0x0e00041a,
188 0x00000000, 0x0a0003b5, 0x00001021, 0x0e000669, 0x00000000, 0x0a0003b5,
189 0x00001021, 0x0e001467, 0x00000000, 0x0a0003b5, 0x00001021, 0x0000000d,
144 0x00001021, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x93620000, 0x24030020, 190 0x00001021, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x93620000, 0x24030020,
145 0x304400ff, 0x10830005, 0x24020030, 0x10820007, 0x00000000, 0x0a0002af, 191 0x304400ff, 0x10830005, 0x24020030, 0x10820007, 0x00000000, 0x0a0003c9,
146 0x00000000, 0x2782000c, 0xaf820000, 0x03e00008, 0x00000000, 0x27820008, 192 0x00000000, 0x2782000c, 0xaf820000, 0x03e00008, 0x00000000, 0x27820008,
147 0xaf820000, 0x03e00008, 0x00000000, 0xaf800000, 0x03e00008, 0x00000000, 193 0xaf820000, 0x03e00008, 0x00000000, 0xaf800000, 0x03e00008, 0x00000000,
148 0x0000000d, 0x03e00008, 0x00001021, 0x03e00008, 0x00001021, 0x27440100, 194 0x0000000d, 0x03e00008, 0x00001021, 0x03e00008, 0x00001021, 0x27440100,
@@ -159,1000 +205,1716 @@ static u32 bnx2_COM_b06FwText[(0x4594/4) + 1] = {
159 0x3c020006, 0x34420001, 0xaf420030, 0x00000000, 0x00000000, 0x00000000, 205 0x3c020006, 0x34420001, 0xaf420030, 0x00000000, 0x00000000, 0x00000000,
160 0x8f420000, 0x30420010, 0x1040fffd, 0x00001021, 0x03e00008, 0x00000000, 206 0x8f420000, 0x30420010, 0x1040fffd, 0x00001021, 0x03e00008, 0x00000000,
161 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 0x1060001e, 207 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 0x1060001e,
162 0xafbf0014, 0x0e001006, 0x00000000, 0x8f830018, 0x8e020018, 0xac620000, 208 0xafbf0014, 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020018, 0xac620000,
163 0x8f840018, 0x9602000c, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 209 0x8f840018, 0x9602000c, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018,
164 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f840018, 210 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f840018,
165 0x3c026000, 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x9464466e, 211 0x3c026000, 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x946458ce,
166 0x8f850018, 0x00021400, 0x00441025, 0x24040001, 0x0e001044, 0xaca2001c, 212 0x8f850018, 0x00021400, 0x00441025, 0x24040001, 0x0e0014cc, 0xaca2001c,
167 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffc8, 0xafb3001c, 213 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafb00010,
168 0x00009821, 0xafb7002c, 0x0000b821, 0xafbe0030, 0x0000f021, 0xafb50024, 214 0x27500100, 0xafbf0014, 0x92020009, 0x14400003, 0x3c020800, 0x0a00046c,
169 0x27550100, 0xafbf0034, 0xafb60028, 0xafb40020, 0xafb20018, 0xafb10014, 215 0x24020001, 0x8c430020, 0x1060001f, 0x00001021, 0x0e00148e, 0x00000000,
170 0xafb00010, 0x96a20008, 0x8f540100, 0x8eb20018, 0x30420001, 0x10400037, 216 0x8f830018, 0x8e020018, 0xac620000, 0x8f840018, 0x9602000c, 0xac820004,
171 0x02a0b021, 0x8f630054, 0x2642ffff, 0x00431023, 0x18400006, 0x00000000, 217 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
172 0x0000000d, 0x00000000, 0x24000128, 0x0a000372, 0x00002021, 0x8f62004c, 218 0x8f820018, 0xac400014, 0x8f840018, 0x3c026000, 0x8c434448, 0xac830018,
173 0x02421023, 0x18400028, 0x00002021, 0x93650120, 0x93640121, 0x3c030800, 219 0x96020008, 0x3c030800, 0x946458ce, 0x8f850018, 0x00021400, 0x00441025,
174 0x8c62008c, 0x308400ff, 0x24420001, 0x30a500ff, 0x00803821, 0x1485000b, 220 0x24040001, 0x0e0014cc, 0xaca2001c, 0x00001021, 0x8fbf0014, 0x8fb00010,
175 0xac62008c, 0x3c040800, 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 221 0x03e00008, 0x27bd0018, 0x3c0b0800, 0x8d6808b0, 0x3c070800, 0x24e700b0,
176 0x30420001, 0x00021023, 0x30420005, 0x0a000372, 0x34440004, 0x27660100, 222 0x00084900, 0x01271821, 0xac640000, 0x93620005, 0x97660008, 0x00e95021,
177 0x00041080, 0x00c21021, 0x8c430000, 0x02431823, 0x04600004, 0x24820001, 223 0x93630023, 0x9364003f, 0x25080001, 0x00021600, 0x00063400, 0x00461025,
178 0x30440007, 0x1485fff9, 0x00041080, 0x10870007, 0x3c030800, 0xa3640121, 224 0x00031a00, 0x00431025, 0x00822025, 0xad440004, 0x9362007e, 0x9366007f,
179 0x8c620094, 0x24040005, 0x24420001, 0x0a000372, 0xac620094, 0x24040004, 225 0x8f630178, 0x9364007a, 0x00021600, 0x00063400, 0x00461025, 0x00031a00,
180 0x00809821, 0x9362003f, 0x304400ff, 0x38830016, 0x2c630001, 0x38820010, 226 0x00431025, 0x00822025, 0xad440008, 0x93620080, 0x9363007d, 0x3108007f,
181 0x2c420001, 0x00621825, 0x1460000c, 0x24020001, 0x38830008, 0x2c630001, 227 0x01403821, 0xad6808b0, 0x00021600, 0x00031c00, 0x00431025, 0x00451025,
182 0x38820014, 0x2c420001, 0x00621825, 0x14600005, 0x24020001, 0x24020012, 228 0x03e00008, 0xace2000c, 0x27bdffb8, 0xafb3002c, 0x00009821, 0xafbe0040,
183 0x14820002, 0x00001021, 0x24020001, 0x50400007, 0x8eb10020, 0x8ea20020, 229 0x0000f021, 0xafb50034, 0x27550100, 0xafbf0044, 0xafb7003c, 0xafb60038,
184 0x8f630040, 0x00408821, 0x00431023, 0x5c400001, 0x8f710040, 0x9343010b, 230 0xafb40030, 0xafb20028, 0xafb10024, 0xafb00020, 0xafa00010, 0xafa00014,
185 0x24020004, 0x54620005, 0x36730080, 0x96a20008, 0x36730002, 0x24170001, 231 0x96a20008, 0x8f540100, 0x8eb10018, 0x30420001, 0x10400037, 0x02a0b821,
186 0x305e0020, 0x2402fffb, 0x02628024, 0x1200002a, 0x3c030800, 0x8c620030, 232 0x8f630054, 0x2622ffff, 0x00431023, 0x18400006, 0x00000000, 0x0000000d,
187 0x02021024, 0x10400026, 0x3c020800, 0x8c430020, 0x10600024, 0x32620004, 233 0x00000000, 0x2400015c, 0x0a0004e5, 0x00002021, 0x8f62004c, 0x02221023,
188 0x0e001006, 0x00000000, 0x8f830018, 0x8f420100, 0xac620000, 0x8f840018, 234 0x18400028, 0x00002021, 0x93650120, 0x93640121, 0x3c030800, 0x8c62008c,
189 0x02201821, 0x32620002, 0xac900004, 0x8f840018, 0x50400001, 0x8ec30014, 235 0x308400ff, 0x24420001, 0x30a500ff, 0x00803821, 0x1485000b, 0xac62008c,
190 0xac830008, 0x8f830018, 0x8ec20020, 0xac62000c, 0x8f840018, 0x8f620040, 236 0x3c040800, 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 0x30420001,
191 0xac820010, 0x8f830018, 0x8ec20018, 0xac620014, 0x8f840018, 0x3c026000, 237 0x00021023, 0x30420005, 0x0a0004e5, 0x34440004, 0x27660100, 0x00041080,
192 0x8c434448, 0x3c020800, 0xac830018, 0x9443466e, 0x8f840018, 0x3c024010, 238 0x00c21021, 0x8c430000, 0x02231823, 0x04600004, 0x24820001, 0x30440007,
193 0x00621825, 0xac83001c, 0x0e001044, 0x24040001, 0x32620004, 0x10400076, 239 0x1485fff9, 0x00041080, 0x10870007, 0x3c030800, 0xa3640121, 0x8c620094,
194 0x00003821, 0x3c029000, 0x34420001, 0x3c038000, 0x02821025, 0xa360007c, 240 0x24040005, 0x24420001, 0x0a0004e5, 0xac620094, 0x24040004, 0x00809821,
195 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620023, 241 0x9362003f, 0x304400ff, 0x38830016, 0x2c630001, 0x38820010, 0x2c420001,
196 0x30420080, 0x10400011, 0x00000000, 0x8f65005c, 0x8f63004c, 0x9764003c, 242 0x00621825, 0x1460000c, 0x24020001, 0x38830008, 0x2c630001, 0x38820014,
197 0x8f620064, 0x00a32823, 0x00852821, 0x00a2102b, 0x54400006, 0x3c023fff, 243 0x2c420001, 0x00621825, 0x14600005, 0x24020001, 0x24020012, 0x14820002,
198 0x93620023, 0x3042007f, 0xa3620023, 0xaf720064, 0x3c023fff, 0x0a0003f1, 244 0x00001021, 0x24020001, 0x10400009, 0x00000000, 0x8ea20020, 0x8f630040,
199 0x3442ffff, 0x8f62005c, 0x02421023, 0x04400011, 0x00000000, 0x8f65005c, 245 0x0040b021, 0x00431023, 0x5c400010, 0x8f760040, 0x0a000511, 0x00000000,
200 0x8f630064, 0x9764003c, 0x3c023fff, 0x3442ffff, 0xaf720064, 0x00a32823, 246 0x9343010b, 0x24020004, 0x1462000a, 0x8eb60020, 0x8f630040, 0x3c021000,
201 0x00852821, 0x0045102b, 0x10400004, 0x02451021, 0x3c053fff, 0x34a5ffff, 247 0x00761823, 0x0043102a, 0x10400004, 0x00000000, 0x0000000d, 0x00000000,
202 0x02451021, 0xaf62005c, 0x24070001, 0xaf72004c, 0x8f620054, 0x16420005, 248 0x240002fa, 0x9343010b, 0x24020004, 0x5462000b, 0x96a20008, 0x24020001,
249 0xafa20010, 0x96a20008, 0x24030001, 0xafa30018, 0x8eb2001c, 0x36730002,
250 0x30420020, 0x0a000526, 0xafa20014, 0x36730080, 0x30420002, 0x10400003,
251 0xafa00018, 0x0a000526, 0x8eb2001c, 0x8eb20014, 0x2402fffb, 0x02628024,
252 0x1200002a, 0x3c030800, 0x8c620030, 0x02021024, 0x10400026, 0x3c020800,
253 0x8c430020, 0x10600024, 0x32620004, 0x0e00148e, 0x00000000, 0x8f830018,
254 0x8f420100, 0xac620000, 0x8f840018, 0x02401821, 0x32620002, 0xac900004,
255 0x8f840018, 0x54400001, 0x02c01821, 0xac830008, 0x8f830018, 0x8ee20020,
256 0xac62000c, 0x8f840018, 0x8f620040, 0xac820010, 0x8f830018, 0x8ee20018,
257 0xac620014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800,
258 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024010, 0x00621825, 0x0e0014cc,
259 0xaca3001c, 0x32620004, 0x10400063, 0x00003821, 0x3c029000, 0x34420001,
260 0x3c038000, 0x02821025, 0xa360007c, 0xaf420020, 0x8f420020, 0x00431024,
261 0x1440fffd, 0x00000000, 0x93620023, 0x30420080, 0x10400011, 0x00000000,
262 0x8f65005c, 0x8f63004c, 0x9764003c, 0x8f620064, 0x00a32823, 0x00852821,
263 0x00a2102b, 0x54400006, 0x3c023fff, 0x93620023, 0x3042007f, 0xa3620023,
264 0xaf710064, 0x3c023fff, 0x0a000580, 0x3442ffff, 0x8f62005c, 0x02221023,
265 0x04400011, 0x00000000, 0x8f65005c, 0x8f630064, 0x9764003c, 0x3c023fff,
266 0x3442ffff, 0xaf710064, 0x00a32823, 0x00852821, 0x0045102b, 0x10400004,
267 0x02251021, 0x3c053fff, 0x34a5ffff, 0x02251021, 0xaf62005c, 0x24070001,
268 0xaf71004c, 0x8f620054, 0x16220005, 0x00000000, 0x93620023, 0x30420040,
269 0x10400017, 0x24020001, 0x9762006a, 0x00022880, 0x50a00001, 0x24050001,
270 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804,
271 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b,
272 0x54600001, 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021,
273 0xaf62000c, 0x93620082, 0x30420080, 0x50400001, 0xa3600081, 0x3c028000,
274 0x34420001, 0x02821025, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620004,
275 0x00000000, 0x0e0013c4, 0x00000000, 0x00403821, 0x54e00001, 0x241e0001,
276 0x8f700040, 0x8f620040, 0x14520003, 0x00521023, 0x0a0005bf, 0x00001021,
277 0x28420001, 0x10400041, 0x8fa20010, 0x0e000fae, 0x02402021, 0xaf720040,
278 0x9362003e, 0x30420001, 0x1440000b, 0x3c029000, 0x93620022, 0x24420001,
279 0xa3620022, 0x93630022, 0x3c020800, 0x8c440098, 0x0064182b, 0x14600027,
280 0x3c020800, 0x3c029000, 0x34420001, 0x02821025, 0xaf420020, 0x3c038000,
281 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000,
282 0x34420001, 0xa362007d, 0x8f640074, 0x34630001, 0x02831825, 0xaf430020,
283 0x04810006, 0x3c038000, 0x02802021, 0x0e000470, 0x24050273, 0x0a0005f2,
284 0x24050001, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000,
285 0xaf5401c0, 0xa34201c4, 0xaf4301f8, 0x24050001, 0x24020001, 0xa7620012,
286 0xa3600022, 0x0a0005fe, 0x2ca20001, 0x9743007a, 0x9444002a, 0x00002821,
287 0x00641821, 0x3063fffe, 0xa7630012, 0x2ca20001, 0x00021023, 0x03c2f024,
288 0x8fa20010, 0x10400004, 0x8fa30014, 0x0e0013c1, 0x00000000, 0x8fa30014,
289 0x10600003, 0x00000000, 0x0e0010eb, 0x00000000, 0x13c0001f, 0x3c029000,
290 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
291 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074,
292 0x34630001, 0x02831825, 0xaf430020, 0x04810006, 0x3c038000, 0x02802021,
293 0x0e000470, 0x2405036c, 0x0a00062b, 0x8fa20018, 0x8f4201f8, 0x00431024,
294 0x1440fffd, 0x24020002, 0x3c031000, 0xaf5401c0, 0xa34201c4, 0xaf4301f8,
295 0x8fa20018, 0x5040002f, 0x96a20008, 0x8f620048, 0x8f630024, 0x00761821,
296 0xaf630048, 0x9764003c, 0x00501023, 0x0044102b, 0x10400025, 0x3c029000,
297 0x34420001, 0x3c040800, 0x8c830080, 0x8f450100, 0x3c068000, 0x24630001,
298 0x00a21025, 0xac830080, 0xaf420020, 0x8f420020, 0x00461024, 0x1440fffd,
299 0x00000000, 0x9362007d, 0x3c038000, 0x34420004, 0xa362007d, 0x8f640074,
300 0x34630001, 0x00a31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00a02021,
301 0x0e000470, 0x2405038a, 0x0a00065b, 0x96a20008, 0x8f4201f8, 0x00431024,
302 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4501c0, 0xa34201c4, 0xaf4301f8,
303 0x96a20008, 0x8fbf0044, 0x8fbe0040, 0x8fb7003c, 0x8fb60038, 0x8fb50034,
304 0x8fb40030, 0x8fb3002c, 0x8fb20028, 0x8fb10024, 0x8fb00020, 0x00021042,
305 0x30420001, 0x03e00008, 0x27bd0048, 0x27bdffe0, 0xafbf0018, 0x97420108,
306 0x24030019, 0x304400ff, 0x10830065, 0x2882001a, 0x1040001a, 0x2882000a,
307 0x1040000f, 0x28820008, 0x10400040, 0x24020001, 0x1082003a, 0x28820002,
308 0x50400005, 0x24020006, 0x10800032, 0x3c026000, 0x0a0006fb, 0x00000000,
309 0x1082003d, 0x00000000, 0x0a0006fb, 0x00000000, 0x2402000b, 0x10820044,
310 0x2882000b, 0x1440004b, 0x2402000e, 0x10820045, 0x00000000, 0x0a0006fb,
311 0x00000000, 0x24020020, 0x10820062, 0x28820021, 0x1040000e, 0x2402001c,
312 0x1082004c, 0x2882001d, 0x10400005, 0x2402001b, 0x10820043, 0x00000000,
313 0x0a0006fb, 0x00000000, 0x2402001f, 0x10820050, 0x00000000, 0x0a0006fb,
314 0x00000000, 0x240200c1, 0x10820042, 0x288200c2, 0x10400005, 0x24020080,
315 0x10820021, 0x00000000, 0x0a0006fb, 0x00000000, 0x240200c2, 0x1082003d,
316 0x240200c9, 0x50820049, 0xafa00010, 0x0a0006fb, 0x00000000, 0x0e001163,
317 0xac400808, 0x0a0006fd, 0x8fbf0018, 0x3c026000, 0x8c444448, 0x3c030800,
318 0xac640064, 0x0e001163, 0x00000000, 0x3c026000, 0x8c444448, 0x3c030800,
319 0x0a0006fc, 0xac640068, 0x8f440100, 0x0e0006ff, 0x00000000, 0x3c026000,
320 0x8c444448, 0x3c030800, 0x0a0006fc, 0xac64006c, 0x0e001191, 0x00000000,
321 0x0a0006fd, 0x8fbf0018, 0x8f440100, 0x0e0011bb, 0x00000000, 0x0a0006fd,
322 0x8fbf0018, 0x0e001202, 0x00000000, 0x0a0006fd, 0x8fbf0018, 0x0000000d,
323 0x0a0006fd, 0x8fbf0018, 0x0e000826, 0x00000000, 0x0a0006fd, 0x8fbf0018,
324 0x8f440100, 0x0e001264, 0x00000000, 0x0a0006fd, 0x8fbf0018, 0x0e00134e,
325 0x00000000, 0x0a0006fd, 0x8fbf0018, 0x0e00087c, 0x27440100, 0x0a0006fd,
326 0x8fbf0018, 0x8f640040, 0x0e000fae, 0x00000000, 0x0a0006fd, 0x8fbf0018,
327 0x8f440100, 0x0e001059, 0x00000000, 0x0a0006fd, 0x8fbf0018, 0x0e001417,
328 0x00000000, 0x0a0006fd, 0x8fbf0018, 0xafa00014, 0x8f440100, 0x8f450118,
329 0x8f46011c, 0x0e001439, 0x8f470120, 0x0a0006fd, 0x8fbf0018, 0x0000000d,
330 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0010, 0x9742010c,
331 0x1440005e, 0x00803821, 0x3c029000, 0x34420001, 0x00e21025, 0xaf420020,
332 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620023,
333 0x30420010, 0x14400026, 0x3c030800, 0x8f630074, 0x3c027fff, 0x3442ffff,
334 0x00621824, 0xaf630074, 0x93620005, 0x34420001, 0xa3620005, 0x8f63004c,
335 0x8f620054, 0x10620021, 0x24040001, 0x9762006a, 0x00022880, 0x50a00001,
336 0x24050001, 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821,
337 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050,
338 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824,
339 0x00a21021, 0xaf62000c, 0x0a00073d, 0x24040001, 0x8c6200a8, 0x00002021,
340 0x24420001, 0xac6200a8, 0x0000000d, 0x00000000, 0x2400044d, 0x3c028000,
341 0x34420001, 0x00e21025, 0xaf420020, 0x1080001f, 0x3c029000, 0x34420001,
342 0x00e21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
343 0x00000000, 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 0x34630001,
344 0x00e31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00e02021, 0x0e000470,
345 0x24050455, 0x0a000761, 0x00000000, 0x8f4201f8, 0x00431024, 0x1440fffd,
346 0x24020002, 0x3c031000, 0xaf4701c0, 0xa34201c4, 0xaf4301f8, 0x0e001163,
347 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffd8, 0xafbf0024,
348 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x93630005,
349 0x00809821, 0x24020030, 0x30630030, 0x146200ac, 0x00a0a021, 0x3c020800,
350 0x8c430020, 0x106000a6, 0x00000000, 0x0e00148e, 0x00000000, 0x8f830018,
351 0xac730000, 0x936200c4, 0x30420002, 0x10400004, 0x24020001, 0x8f830018,
352 0x0a000784, 0x00000000, 0x8f830018, 0x24020003, 0xac620004, 0x8f6200dc,
353 0x8f630040, 0x00431023, 0x18400004, 0x00000000, 0x0000000d, 0x00000000,
354 0x24000509, 0x8f840018, 0x8f6200dc, 0xac820008, 0x8f830018, 0xac60000c,
355 0x8f820018, 0xac400010, 0x8f830018, 0x8f62004c, 0x3c100800, 0xac620014,
356 0x8f850018, 0x3c026000, 0x8c434448, 0x261258c0, 0x00002021, 0xaca30018,
357 0x9642000e, 0x8f850018, 0x3c034010, 0x00431025, 0x0e0014cc, 0xaca2001c,
358 0x8f830018, 0xac730000, 0x9362003e, 0x9363003f, 0x8f840018, 0x00021200,
359 0x00621825, 0xac830004, 0x93620081, 0x93630082, 0x8f840018, 0x00021600,
360 0x00031c00, 0x00431025, 0xac820008, 0x8f830018, 0x8f620040, 0xac62000c,
361 0x8f840018, 0x8f620048, 0xac820010, 0x8f71004c, 0x8f820018, 0xac510014,
362 0x8f620050, 0x8f850018, 0x00401821, 0x02221023, 0x5c400001, 0x02201821,
363 0x00002021, 0xaca30018, 0x9642000e, 0x8f850018, 0x3c03c00b, 0x00431025,
364 0x0e0014cc, 0xaca2001c, 0x8f620054, 0x8f840018, 0x00401821, 0x02221023,
365 0x5c400001, 0x02201821, 0xac830000, 0x8f840018, 0x8f630058, 0xac830004,
366 0x93620023, 0x30420010, 0x10400004, 0x00000000, 0x8f830018, 0x0a0007dd,
367 0x8f620148, 0x8f830018, 0x8f62005c, 0xac620008, 0x8f830018, 0x8f620060,
368 0xac62000c, 0x8f840018, 0x8f620064, 0xac820010, 0x97630068, 0x9762006a,
369 0x8f840018, 0x00031c00, 0x00431025, 0xac820014, 0x8f850018, 0x00002021,
370 0x2402ffff, 0x260358c0, 0xaca20018, 0x9462000e, 0x8f850018, 0x3c03c00c,
371 0x00431025, 0x0e0014cc, 0xaca2001c, 0x8f840018, 0x8f630018, 0xac830000,
372 0x936200c4, 0x30420002, 0x10400006, 0x00000000, 0x976200c8, 0x8f830018,
373 0x3042ffff, 0x0a000803, 0xac620004, 0x8f820018, 0xac400004, 0x8f830018,
374 0x8f62006c, 0xac620008, 0x8f840018, 0x8f6200dc, 0xac82000c, 0x8f830018,
375 0xac600010, 0x93620005, 0x8f830018, 0x00021600, 0x00541025, 0xac620014,
376 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x260258c0, 0xaca30018,
377 0x9443000e, 0x8f850018, 0x3c02400d, 0x00621825, 0x0e0014cc, 0xaca3001c,
378 0x0e00122e, 0x02602021, 0x8fbf0024, 0x8fb40020, 0x8fb3001c, 0x8fb20018,
379 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0028, 0x27bdffe0, 0xafb00010,
380 0x27500100, 0xafbf0018, 0xafb10014, 0x9603000c, 0x240200c1, 0x54620024,
381 0x8e040000, 0x3c029000, 0x8f450100, 0x34420001, 0x3c038000, 0x00a21025,
382 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d,
383 0x3c038000, 0x34420004, 0xa362007d, 0x8f640074, 0x34630001, 0x00a31825,
384 0xaf430020, 0x04810006, 0x3c038000, 0x00a02021, 0x0e000470, 0x240505b2,
385 0x0a000878, 0x8fbf0018, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002,
386 0x3c031000, 0xaf4501c0, 0xa34201c4, 0xaf4301f8, 0x0a000878, 0x8fbf0018,
387 0x8f65004c, 0x24060001, 0x0e0012a3, 0x240705be, 0x3c020800, 0x8c430020,
388 0x9611000c, 0x1060001d, 0x8e100000, 0x0e00148e, 0x00000000, 0x8f820018,
389 0xac500000, 0x8f840018, 0x00111400, 0xac820004, 0x8f830018, 0xac600008,
390 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f840018, 0x240205c1,
391 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800,
392 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024019, 0x00621825, 0x0e0014cc,
393 0xaca3001c, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
394 0x27bdffb0, 0xafb5003c, 0x0000a821, 0xafbe0048, 0x0000f021, 0xafb70044,
395 0x0000b821, 0xafb30034, 0x00009821, 0xafb60040, 0x0080b021, 0xafbf004c,
396 0xafb40038, 0xafb20030, 0xafb1002c, 0xafb00028, 0xafa00010, 0x8f620040,
397 0x8ec30014, 0x96d1000c, 0x00431023, 0x04410025, 0x8ed40000, 0x32220401,
398 0x1040030c, 0x3c029000, 0x34420001, 0x02821025, 0xaf420020, 0x3c038000,
399 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000,
400 0x34420004, 0xa362007d, 0x8f640074, 0x34630001, 0x02831825, 0xaf430020,
401 0x04810006, 0x3c038000, 0x02802021, 0x0e000470, 0x24050664, 0x0a000ba2,
402 0x8fbf004c, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000,
403 0xaf5401c0, 0xa34201c4, 0xaf4301f8, 0x0a000ba2, 0x8fbf004c, 0x32220010,
404 0x1040006b, 0x00003021, 0x9362003f, 0x92c6000f, 0x304500ff, 0x24c3fff8,
405 0x2c62000f, 0x10400057, 0x3c020800, 0x244257c0, 0x00031880, 0x00621821,
406 0x8c640000, 0x00800008, 0x00000000, 0x38a20012, 0x0a000924, 0x0002a82b,
407 0x2402000e, 0x14a20004, 0x2402000c, 0x24150001, 0x0a000924, 0x24060010,
408 0x10a20049, 0x38a30010, 0x2c630001, 0x38a20016, 0x2c420001, 0x00621825,
409 0x1460004d, 0x0000a821, 0x24020014, 0x10a2004a, 0x00000000, 0x0000000d,
410 0x00000000, 0x2400069c, 0x0a000924, 0x0000a821, 0x24020016, 0x14a20005,
411 0x2402000c, 0x24150001, 0x24060010, 0x0a000924, 0x3231fffd, 0x10a20032,
412 0x38a30010, 0x2c630001, 0x38a2000e, 0x2c420001, 0x00621825, 0x14600036,
413 0x0000a821, 0x24020014, 0x14a20003, 0x24150001, 0x0a000924, 0x24060012,
414 0x0000000d, 0x00000000, 0x240006bc, 0x0a000924, 0x0000a821, 0x2402000e,
415 0x14a20004, 0x24020016, 0x24150001, 0x0a000924, 0x3231fffb, 0x14a20004,
416 0x24020014, 0x24150001, 0x0a000924, 0x3231fffd, 0x54a20013, 0x92c2000e,
417 0x24150001, 0x24060012, 0x0a000924, 0x3231fffd, 0x2402000c, 0x54a2000c,
418 0x92c2000e, 0x92c3000e, 0x2402000a, 0x10620005, 0x24150001, 0x0000000d,
419 0x00000000, 0x240006e8, 0x24150001, 0x0a000924, 0x24060014, 0x92c2000e,
420 0x14a20003, 0x00000000, 0x0a000924, 0x24150001, 0x10a6ffc1, 0x24020012,
421 0x10a20005, 0x0000a821, 0x0000000d, 0x00000000, 0x24000704, 0x0000a821,
422 0x12a00022, 0x32220004, 0x10400002, 0x24020001, 0xafa20010, 0x32230102,
423 0x24020002, 0x1462000f, 0x00000000, 0x92c2000a, 0x30420020, 0x1440000b,
424 0x00000000, 0x8f630048, 0x8f620040, 0x14620004, 0x00000000, 0x8f620048,
425 0x24420001, 0xaf620048, 0x8f620040, 0x24420001, 0xaf620040, 0xa366003f,
426 0x38c30012, 0x2c630001, 0x38c20010, 0x2c420001, 0x00621825, 0x10600005,
427 0x3c030800, 0x8c620074, 0x24420001, 0x0e00140d, 0xac620074, 0x32220040,
428 0x32230020, 0xafa30020, 0x32230080, 0xafa30024, 0x32230001, 0xafa30018,
429 0x32230008, 0xafa3001c, 0x32230100, 0x104000c4, 0xafa30014, 0x8ec60010,
430 0x8f630054, 0x24c2ffff, 0x00431023, 0x18400006, 0x00000000, 0x0000000d,
431 0x00000000, 0x2400015c, 0x0a000989, 0x00009021, 0x8f62004c, 0x00c21023,
432 0x18400028, 0x00009021, 0x93650120, 0x93640121, 0x3c030800, 0x8c62008c,
433 0x308400ff, 0x24420001, 0x30a500ff, 0x00804021, 0x1485000b, 0xac62008c,
434 0x3c040800, 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 0x30420001,
435 0x00021023, 0x30420005, 0x0a000989, 0x34520004, 0x27670100, 0x00041080,
436 0x00e21021, 0x8c430000, 0x00c31823, 0x04600004, 0x24820001, 0x30440007,
437 0x1485fff9, 0x00041080, 0x10880007, 0x3c030800, 0xa3640121, 0x8c620094,
438 0x24120005, 0x24420001, 0x0a000989, 0xac620094, 0x24120004, 0x32420001,
439 0x10400021, 0x3c020800, 0x8c430020, 0x8ed00000, 0x1060001c, 0x8ed30010,
440 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x24020001,
441 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018,
442 0xac600010, 0x8f820018, 0xac530014, 0x8f850018, 0x3c026000, 0x8c434448,
443 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024010,
444 0x00621825, 0x0e0014cc, 0xaca3001c, 0x24130001, 0x32420004, 0x10400068,
445 0x00003821, 0x3c029000, 0x8ec60010, 0x34420001, 0x3c038000, 0x02821025,
446 0xa360007c, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000,
447 0x93620023, 0x30420080, 0x10400011, 0x00000000, 0x8f65005c, 0x8f63004c,
448 0x9764003c, 0x8f620064, 0x00a32823, 0x00852821, 0x00a2102b, 0x54400006,
449 0x3c023fff, 0x93620023, 0x3042007f, 0xa3620023, 0xaf660064, 0x3c023fff,
450 0x0a0009da, 0x3442ffff, 0x8f62005c, 0x00c21023, 0x04400011, 0x00000000,
451 0x8f65005c, 0x8f630064, 0x9764003c, 0x3c023fff, 0x3442ffff, 0xaf660064,
452 0x00a32823, 0x00852821, 0x0045102b, 0x10400004, 0x00c51021, 0x3c053fff,
453 0x34a5ffff, 0x00c51021, 0xaf62005c, 0x24070001, 0xaf66004c, 0x8fa20010,
454 0x10400003, 0x00000000, 0xaf660050, 0xaf660054, 0x8f620054, 0x14c20005,
203 0x00000000, 0x93620023, 0x30420040, 0x10400017, 0x24020001, 0x9762006a, 455 0x00000000, 0x93620023, 0x30420040, 0x10400017, 0x24020001, 0x9762006a,
204 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 0x3c020800, 456 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 0x3c020800,
205 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021, 457 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021,
206 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074, 458 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074,
207 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 0x3c028000, 0x34420001, 459 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 0x93620082, 0x30420080,
208 0x02821025, 0xa3600081, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620004, 460 0x50400001, 0xa3600081, 0x3c028000, 0x34420001, 0x02821025, 0xaf420020,
209 0x00000000, 0x0e000f2a, 0x00000000, 0x00403821, 0x10e00017, 0x3c029000, 461 0x9363007e, 0x9362007a, 0x10620005, 0x00e0b821, 0x0e0013c4, 0x00000000,
462 0x00403821, 0x00e0b821, 0x8fa30020, 0x10600009, 0x8fa20010, 0x8ec20018,
463 0xaf620018, 0x8ec3001c, 0xaf63001c, 0x8ec20020, 0x24170001, 0xaf620058,
464 0x8fa20010, 0x10400057, 0x8fa30024, 0x93620023, 0x30420040, 0x10400053,
465 0x00000000, 0x16600021, 0x3c120800, 0x8e420020, 0x8f70004c, 0x1040001e,
466 0x24130001, 0x0e00148e, 0x00000000, 0x8f820018, 0xac540000, 0x8f840018,
467 0x24020001, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
468 0x8f830018, 0xac600010, 0x8f820018, 0xac500014, 0x8f850018, 0x3c026000,
469 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018,
470 0x3c024010, 0x00621825, 0xaca3001c, 0x0e0014cc, 0x24130001, 0x8e420020,
471 0x1040001c, 0x8ed00000, 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000,
472 0x8f830018, 0xac600004, 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c,
473 0x8f820018, 0xac400010, 0x8f830018, 0x24020798, 0xac620014, 0x8f850018,
474 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce,
475 0x8f850018, 0x3c024019, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x3c029000,
210 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 476 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
211 0x1440fffd, 0x3c028000, 0x9363007d, 0x34420001, 0x3c048000, 0x02821025, 477 0x1440fffd, 0x24020001, 0xaf62000c, 0x93630023, 0x3c028000, 0x34420001,
212 0xa363007d, 0xaf420020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002, 478 0x02821025, 0x306300bf, 0xa3630023, 0xaf420020, 0x8fa30024, 0x10600012,
213 0x3c031000, 0xaf5401c0, 0xa34201c4, 0xaf4301f8, 0x8ea30014, 0x8f620040, 479 0x8fa30018, 0x9362007c, 0x24420001, 0xa362007c, 0x9363007e, 0x9362007a,
214 0x14430003, 0x00431023, 0x0a000443, 0x00001021, 0x28420001, 0x10400034, 480 0x1462000b, 0x8fa30018, 0x9362007c, 0x3c030800, 0x8c640024, 0x0044102b,
215 0x00000000, 0x8f620040, 0xaf630040, 0x9362003e, 0x30420001, 0x1440000b, 481 0x14400005, 0x8fa30018, 0x0e0013c4, 0x00000000, 0x02e2b825, 0x8fa30018,
216 0x3c029000, 0x93620022, 0x24420001, 0xa3620022, 0x93630022, 0x3c020800, 482 0x3062ffff, 0x10400003, 0x32220200, 0x0a000a94, 0x241e0004, 0x10400003,
217 0x8c440098, 0x0064182b, 0x1460001e, 0x3c020800, 0x3c029000, 0x34420001, 483 0x00000000, 0x241e0040, 0x24170001, 0x12a000d0, 0x32220002, 0x104000cf,
484 0x8fa2001c, 0x92c2000a, 0x30420002, 0x5040003b, 0x92c2000a, 0x93620023,
485 0x30420008, 0x54400037, 0x92c2000a, 0x3c020800, 0x8c430020, 0x10600023,
486 0x3c029000, 0x0e00148e, 0x00000000, 0x8f840018, 0x8ec30000, 0xac830000,
487 0x92c2000a, 0x8f830018, 0x00021600, 0xac620004, 0x8f840018, 0x8f620040,
488 0xac820008, 0x8f850018, 0x8f63004c, 0xaca3000c, 0x9362003f, 0x8f840018,
489 0x304200ff, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f850018,
490 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018,
491 0x3c02401a, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x3c029000, 0x34420001,
218 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 492 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
219 0x00000000, 0x3c038000, 0x9362007d, 0x34630001, 0x3c048000, 0x02831825, 493 0x00000000, 0x93630023, 0x3c028000, 0x34420001, 0x02821025, 0x34630008,
220 0x34420001, 0xa362007d, 0xaf430020, 0x8f4201f8, 0x00441024, 0x1440fffd, 494 0xa3630023, 0xaf420020, 0x92c2000a, 0x30420020, 0x1040008e, 0x8fa2001c,
221 0x24020002, 0x3c031000, 0xaf5401c0, 0xa34201c4, 0x24020001, 0xaf4301f8, 495 0x93620023, 0x30420001, 0x14400035, 0x3c020800, 0x8c430020, 0x10600023,
222 0xa7620012, 0x0a000476, 0xa3600022, 0x9743007a, 0x9444002a, 0x00641821, 496 0x3c029000, 0x0e00148e, 0x00000000, 0x8f840018, 0x8ec30000, 0xac830000,
223 0x3063fffe, 0xa7630012, 0x0e000b68, 0x00000000, 0x12e00003, 0x00000000, 497 0x92c2000a, 0x8f830018, 0x00021600, 0xac620004, 0x8f840018, 0x8f620040,
224 0x0e000f27, 0x00000000, 0x53c00004, 0x96a20008, 0x0e000c10, 0x00000000, 498 0xac820008, 0x8f850018, 0x8f63004c, 0xaca3000c, 0x9362003f, 0x8f840018,
225 0x96a20008, 0x8fbf0034, 0x8fbe0030, 0x8fb7002c, 0x8fb60028, 0x8fb50024, 499 0x304200ff, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f850018,
226 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x00021042, 500 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018,
227 0x30420001, 0x03e00008, 0x27bd0038, 0x27bdffe8, 0xafbf0010, 0x97420108, 501 0x3c02401a, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x3c029000, 0x34420001,
228 0x2403000b, 0x304400ff, 0x1083004e, 0x2882000c, 0x10400011, 0x24020006, 502 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
229 0x1082003e, 0x28820007, 0x10400007, 0x28820008, 0x1080002b, 0x24020001, 503 0x00000000, 0x93630023, 0x3c028000, 0x34420001, 0x02821025, 0x34630001,
230 0x1082002e, 0x3c026000, 0x0a000504, 0x00000000, 0x14400061, 0x2882000a, 504 0xa3630023, 0xaf420020, 0x93620023, 0x30420040, 0x10400052, 0x8fa2001c,
231 0x1440002b, 0x00000000, 0x0a0004ec, 0x00000000, 0x2402001c, 0x1082004e, 505 0x16600020, 0x3c120800, 0x8e420020, 0x8f70004c, 0x1040003c, 0x3c029000,
232 0x2882001d, 0x1040000e, 0x24020019, 0x10820041, 0x2882001a, 0x10400005, 506 0x0e00148e, 0x00000000, 0x8f820018, 0xac540000, 0x8f840018, 0x24020001,
233 0x2402000e, 0x10820036, 0x00000000, 0x0a000504, 0x00000000, 0x2402001b, 507 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018,
234 0x1082003c, 0x00000000, 0x0a000504, 0x00000000, 0x240200c1, 0x10820040, 508 0xac600010, 0x8f820018, 0xac500014, 0x8f850018, 0x3c026000, 0x8c434448,
235 0x288200c2, 0x10400005, 0x24020080, 0x1082001f, 0x00000000, 0x0a000504, 509 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024010,
236 0x00000000, 0x240200c2, 0x1082003b, 0x00000000, 0x0a000504, 0x00000000, 510 0x00621825, 0x0e0014cc, 0xaca3001c, 0x8e420020, 0x1040001e, 0x3c029000,
237 0x3c026000, 0x0e000c7d, 0xac400808, 0x0a000506, 0x8fbf0010, 0x8c444448, 511 0x0e00148e, 0x00000000, 0x8f820018, 0xac540000, 0x8f840018, 0x3c02008d,
238 0x3c030800, 0xac640064, 0x0e000c7d, 0x00000000, 0x3c026000, 0x8c444448, 512 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018,
239 0x3c030800, 0x0a000505, 0xac640068, 0x8f440100, 0x0e000508, 0x00000000, 513 0xac600010, 0x8f840018, 0x240207ee, 0xac820014, 0x8f850018, 0x3c026000,
240 0x3c026000, 0x8c444448, 0x3c030800, 0x0a000505, 0xac64006c, 0x0e000cab, 514 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018,
241 0x00000000, 0x0a000506, 0x8fbf0010, 0x8f440100, 0x0e000cd5, 0x00000000, 515 0x3c024019, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x3c029000, 0x34420001,
242 0x0a000506, 0x8fbf0010, 0x0e000d1c, 0x00000000, 0x0a000506, 0x8fbf0010, 516 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
243 0x0000000d, 0x0a000506, 0x8fbf0010, 0x0e0005d7, 0x00000000, 0x0a000506, 517 0x00000000, 0x93630023, 0x3c028000, 0x34420001, 0x02821025, 0x306300bf,
244 0x8fbf0010, 0x8f440100, 0x0e000d7e, 0x00000000, 0x0a000506, 0x8fbf0010, 518 0xa3630023, 0xaf420020, 0x8fa2001c, 0x1040000e, 0x8fa20014, 0x92c2000a,
245 0x0e000e95, 0x00000000, 0x0a000506, 0x8fbf0010, 0x0e000626, 0x00000000, 519 0xa3620082, 0x57c00005, 0x37de0008, 0x8fa30014, 0x10600004, 0x00000000,
246 0x0a000506, 0x8fbf0010, 0x0e000b68, 0x00000000, 0x0a000506, 0x8fbf0010, 520 0x37de0008, 0x0a000b75, 0x24170001, 0x0e0012cf, 0x02802021, 0x8fa20014,
247 0x0000000d, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0x3c029000, 521 0x10400003, 0x00000000, 0x37de0010, 0x24170001, 0x12e00020, 0x3c029000,
248 0x34420001, 0xafb00010, 0x00808021, 0x02021025, 0x3c038000, 0xafbf0014, 522 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
249 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 523 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0x03c21025, 0xa362007d,
250 0x34420001, 0xa3620005, 0x8f63004c, 0x8f620054, 0x10620019, 0x3c028000, 524 0x8f640074, 0x34630001, 0x02831825, 0xaf430020, 0x04810006, 0x3c038000,
251 0x9762006a, 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 525 0x02802021, 0x0e000470, 0x2405082a, 0x0a000b9b, 0x00000000, 0x8f4201f8,
252 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 526 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf5401c0, 0xa34201c4,
253 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 527 0xaf4301f8, 0x9363003f, 0x24020012, 0x14620004, 0x8fbf004c, 0x0e00140d,
254 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 0x3c028000, 528 0x00000000, 0x8fbf004c, 0x8fbe0048, 0x8fb70044, 0x8fb60040, 0x8fb5003c,
255 0x34420001, 0x02021025, 0x0e000c7d, 0xaf420020, 0x3c029000, 0x34420001,
256 0x3c038000, 0x02021025, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd,
257 0x3c028000, 0x9363007d, 0x34420001, 0x3c048000, 0x02021025, 0xa363007d,
258 0xaf420020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x8fbf0014, 0xaf5001c0,
259 0x8fb00010, 0x24020002, 0x3c031000, 0xa34201c4, 0xaf4301f8, 0x03e00008,
260 0x27bd0018, 0x27bdffd8, 0xafbf0020, 0xafb3001c, 0xafb20018, 0xafb10014,
261 0xafb00010, 0x93630005, 0x00809021, 0x24020030, 0x30630030, 0x14620072,
262 0x00a09821, 0x3c020800, 0x8c430020, 0x1060006c, 0x00000000, 0x0e001006,
263 0x00000000, 0x8f820018, 0xac520000, 0x9363003e, 0x9362003f, 0x8f840018,
264 0x00031a00, 0x00431025, 0xac820004, 0x93630081, 0x93620082, 0x8f850018,
265 0x00031e00, 0x00021400, 0x00621825, 0xaca30008, 0x8f840018, 0x8f620040,
266 0xac82000c, 0x8f830018, 0x8f620048, 0xac620010, 0x8f840018, 0x8f62004c,
267 0x3c110800, 0xac820014, 0x8f830018, 0x8f620050, 0x26304660, 0x00002021,
268 0xac620018, 0x9602000e, 0x8f850018, 0x3c03c00b, 0x00431025, 0x0e001044,
269 0xaca2001c, 0x8f830018, 0x8f620054, 0xac620000, 0x8f840018, 0x8f620058,
270 0xac820004, 0x8f830018, 0x8f62005c, 0xac620008, 0x8f840018, 0x8f620060,
271 0xac82000c, 0x8f850018, 0x8f620064, 0xaca20010, 0x97630068, 0x9762006a,
272 0x8f840018, 0x00031c00, 0x00431025, 0xac820014, 0x8f830018, 0x00002021,
273 0xac600018, 0x9602000e, 0x8f850018, 0x3c03c00c, 0x00431025, 0x0e001044,
274 0xaca2001c, 0x8f840018, 0x8f630018, 0xac830000, 0x936200c4, 0x30420002,
275 0x10400006, 0x00000000, 0x976200c8, 0x8f830018, 0x3042ffff, 0x0a0005b5,
276 0xac620004, 0x8f820018, 0xac400004, 0x8f830018, 0x8f62006c, 0xac620008,
277 0x8f840018, 0x8f6200dc, 0xac82000c, 0x8f830018, 0xac600010, 0x93620005,
278 0x8f830018, 0x00021600, 0x00531025, 0xac620014, 0x8f850018, 0x3c026000,
279 0x8c434448, 0x24040001, 0x26224660, 0xaca30018, 0x9443000e, 0x8f850018,
280 0x3c02400d, 0x00621825, 0x0e001044, 0xaca3001c, 0x0e000d48, 0x02402021,
281 0x8fbf0020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008,
282 0x27bd0028, 0x27bdffe0, 0xafb00010, 0x27500100, 0xafbf0018, 0xafb10014,
283 0x9603000c, 0x240200c1, 0x5462001d, 0x8e040000, 0x3c029000, 0x8f440100,
284 0x34420001, 0x3c038000, 0x00821025, 0xaf420020, 0x8f420020, 0x00431024,
285 0x1440fffd, 0x00000000, 0x3c038000, 0x9362007d, 0x34630001, 0x3c058000,
286 0x00831825, 0x34420004, 0xa362007d, 0xaf430020, 0x8f4201f8, 0x00451024,
287 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4401c0, 0xa34201c4, 0xaf4301f8,
288 0x0a000622, 0x8fbf0018, 0x8f65004c, 0x24060001, 0x0e000db5, 0x2407049f,
289 0x3c020800, 0x8c430020, 0x9611000c, 0x1060001d, 0x8e100000, 0x0e001006,
290 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x00111400, 0xac820004,
291 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
292 0x8f840018, 0x240204a2, 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448,
293 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c024019,
294 0x00621825, 0x0e001044, 0xaca3001c, 0x8fbf0018, 0x8fb10014, 0x8fb00010,
295 0x03e00008, 0x27bd0020, 0x27bdffb0, 0xafb1002c, 0x27510100, 0xafbf004c,
296 0xafbe0048, 0xafb70044, 0xafb60040, 0xafb5003c, 0xafb40038, 0xafb30034,
297 0xafb20030, 0xafb00028, 0x8e350000, 0x9634000c, 0x3c026000, 0x8c434448,
298 0x0000f021, 0xaf630170, 0x8f620040, 0x8e230014, 0x0000b821, 0x00431023,
299 0x044001ec, 0x0000b021, 0x32820010, 0x1040002e, 0x3c026000, 0x9363003f,
300 0x9222000e, 0x10430006, 0x2402000c, 0x9223000f, 0x10620003, 0x24020014,
301 0x14620025, 0x3c026000, 0x32820004, 0x10400007, 0x241e0001, 0x8f620050,
302 0x24420001, 0xaf620050, 0x8f630054, 0x24630001, 0xaf630054, 0x32830102,
303 0x24020002, 0x5462000d, 0x9222000f, 0x8f620040, 0x24420001, 0xaf620040,
304 0x8f630048, 0x8f620040, 0x24630001, 0x54620005, 0x9222000f, 0x8f620048,
305 0x24420001, 0xaf620048, 0x9222000f, 0xa362003f, 0x9223000f, 0x24020012,
306 0x14620007, 0x3c026000, 0x3c030800, 0x8c620074, 0x24420001, 0x0e000f6e,
307 0xac620074, 0x3c026000, 0x8c434448, 0x32820040, 0xaf630174, 0x32830020,
308 0xafa30010, 0x32830080, 0xafa30014, 0x32830001, 0xafa3001c, 0x32830008,
309 0xafa30020, 0x32830100, 0x104000bb, 0xafa30018, 0x8e260010, 0x8f630054,
310 0x24c2ffff, 0x00431023, 0x18400006, 0x00000000, 0x0000000d, 0x00000000,
311 0x24000128, 0x0a0006b2, 0x00009021, 0x8f62004c, 0x00c21023, 0x18400028,
312 0x00009021, 0x93650120, 0x93640121, 0x3c030800, 0x8c62008c, 0x308400ff,
313 0x24420001, 0x30a500ff, 0x00804021, 0x1485000b, 0xac62008c, 0x3c040800,
314 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 0x30420001, 0x00021023,
315 0x30420005, 0x0a0006b2, 0x34520004, 0x27670100, 0x00041080, 0x00e21021,
316 0x8c430000, 0x00c31823, 0x04600004, 0x24820001, 0x30440007, 0x1485fff9,
317 0x00041080, 0x10880007, 0x3c030800, 0xa3640121, 0x8c620094, 0x24120005,
318 0x24420001, 0x0a0006b2, 0xac620094, 0x24120004, 0x32420001, 0x10400020,
319 0x3c020800, 0x8c430020, 0x8e300000, 0x1060001c, 0x8e330010, 0x0e001006,
320 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x24020001, 0xac820004,
321 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
322 0x8f820018, 0xac530014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
323 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c024010, 0x00621825,
324 0x0e001044, 0xaca3001c, 0x32420004, 0x10400060, 0x00003821, 0x3c029000,
325 0x8e260010, 0x34420001, 0x3c038000, 0x02a21025, 0xa360007c, 0xaf420020,
326 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620023, 0x30420080,
327 0x10400011, 0x00000000, 0x8f65005c, 0x8f63004c, 0x9764003c, 0x8f620064,
328 0x00a32823, 0x00852821, 0x00a2102b, 0x54400006, 0x3c023fff, 0x93620023,
329 0x3042007f, 0xa3620023, 0xaf660064, 0x3c023fff, 0x0a000702, 0x3442ffff,
330 0x8f62005c, 0x00c21023, 0x04400011, 0x00000000, 0x8f65005c, 0x8f630064,
331 0x9764003c, 0x3c023fff, 0x3442ffff, 0xaf660064, 0x00a32823, 0x00852821,
332 0x0045102b, 0x10400004, 0x00c51021, 0x3c053fff, 0x34a5ffff, 0x00c51021,
333 0xaf62005c, 0x24070001, 0xaf66004c, 0x8f620054, 0x14c20005, 0x00000000,
334 0x93620023, 0x30420040, 0x10400017, 0x24020001, 0x9762006a, 0x00022880,
335 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c,
336 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800,
337 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074, 0x2403fffe,
338 0x00832824, 0x00a21021, 0xaf62000c, 0x3c028000, 0x34420001, 0x02a21025,
339 0xa3600081, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620005, 0x00e0b021,
340 0x0e000f2a, 0x00000000, 0x00403821, 0x00e0b021, 0x8fa20010, 0x10400008,
341 0x00000000, 0x8e220018, 0xaf620018, 0x8e23001c, 0xaf63001c, 0x8e220020,
342 0x24160001, 0xaf620058, 0x13c00036, 0x32820004, 0x10400035, 0x8fa30014,
343 0x93620023, 0x30420040, 0x10400031, 0x3c020800, 0x8c430020, 0x1060001c,
344 0x8e300000, 0x0e001006, 0x00000000, 0x8f820018, 0xac500000, 0x8f830018,
345 0xac600004, 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c, 0x8f820018,
346 0xac400010, 0x8f830018, 0x24020587, 0xac620014, 0x8f850018, 0x3c026000,
347 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018,
348 0x3c024019, 0x00621825, 0x0e001044, 0xaca3001c, 0x3c029000, 0x34420001,
349 0x02a21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
350 0x24020001, 0xaf62000c, 0x93630023, 0x3c028000, 0x34420001, 0x02a21025,
351 0x306300bf, 0xa3630023, 0xaf420020, 0x8fa30014, 0x10600012, 0x8fa3001c,
352 0x9362007c, 0x24420001, 0xa362007c, 0x9363007e, 0x9362007a, 0x1462000b,
353 0x8fa3001c, 0x9362007c, 0x3c030800, 0x8c640024, 0x0044102b, 0x14400005,
354 0x8fa3001c, 0x0e000f2a, 0x00000000, 0x02c2b025, 0x8fa3001c, 0x3062ffff,
355 0x10400003, 0x32820200, 0x0a000793, 0x24170004, 0x10400003, 0x00000000,
356 0x24170040, 0x24160001, 0x13c0005d, 0x32820002, 0x1040005c, 0x8fa20020,
357 0x9222000a, 0x30420020, 0x10400033, 0x3c100800, 0x93620023, 0x30420040,
358 0x1040002f, 0x8e020020, 0x1040001e, 0x3c029000, 0x0e001006, 0x00000000,
359 0x8f820018, 0xac550000, 0x8f840018, 0x3c02008d, 0xac820004, 0x8f830018,
360 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f840018,
361 0x240205bf, 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
362 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c024019, 0x00621825,
363 0x0e001044, 0xaca3001c, 0x3c029000, 0x34420001, 0x02a21025, 0xaf420020,
364 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93630023,
365 0x3c028000, 0x34420001, 0x02a21025, 0x306300bf, 0xa3630023, 0xaf420020,
366 0x8e020020, 0x10400023, 0x8fa20020, 0x0e001006, 0x00000000, 0x8f840018,
367 0x8e230000, 0xac830000, 0x9222000a, 0x8f830018, 0x00021600, 0xac620004,
368 0x8f840018, 0x8f620040, 0xac820008, 0x8f850018, 0x8f63004c, 0xaca3000c,
369 0x9362003f, 0x8f840018, 0x304200ff, 0xac820010, 0x8f830018, 0x3c026000,
370 0xac600014, 0x8f850018, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018,
371 0x9443466e, 0x8f850018, 0x3c02401a, 0x00621825, 0x0e001044, 0xaca3001c,
372 0x8fa20020, 0x1040000e, 0x8fa20018, 0x9222000a, 0xa3620082, 0x56e00005,
373 0x36f70008, 0x8fa30018, 0x10600004, 0x00000000, 0x36f70008, 0x0a000801,
374 0x24160001, 0x0e000de1, 0x02a02021, 0x8fa20018, 0x10400003, 0x00000000,
375 0x36f70010, 0x24160001, 0x12c00019, 0x3c029000, 0x34420001, 0x02a21025,
376 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000,
377 0x3c038000, 0x9362007d, 0x34630001, 0x3c048000, 0x02a31825, 0x02e21025,
378 0xa362007d, 0xaf430020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002,
379 0x3c031000, 0xaf5501c0, 0xa34201c4, 0xaf4301f8, 0x9363003f, 0x24020012,
380 0x14620004, 0x3c026000, 0x0e000f6e, 0x00000000, 0x3c026000, 0x8c434448,
381 0xaf630178, 0x8fbf004c, 0x8fbe0048, 0x8fb70044, 0x8fb60040, 0x8fb5003c,
382 0x8fb40038, 0x8fb30034, 0x8fb20030, 0x8fb1002c, 0x8fb00028, 0x03e00008, 529 0x8fb40038, 0x8fb30034, 0x8fb20030, 0x8fb1002c, 0x8fb00028, 0x03e00008,
383 0x27bd0050, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f500180, 0x97420184, 530 0x27bd0050, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f500180, 0x97420184,
384 0x30420200, 0x14400015, 0x00000000, 0x8f430188, 0x3c02ff00, 0x00621824, 531 0x30420200, 0x14400015, 0x00000000, 0x8f430188, 0x3c02ff00, 0x00621824,
385 0x3c020200, 0x10620031, 0x0043102b, 0x14400007, 0x3c020300, 0x1060000b, 532 0x3c020200, 0x10620031, 0x0043102b, 0x14400007, 0x3c020300, 0x1060000b,
386 0x3c020100, 0x1062000d, 0x00000000, 0x0a0008b4, 0x00000000, 0x10620027, 533 0x3c020100, 0x1062000d, 0x00000000, 0x0a000c2c, 0x00000000, 0x10620027,
387 0x3c020400, 0x1062003e, 0x02002021, 0x0a0008b4, 0x00000000, 0x0e000e1e, 534 0x3c020400, 0x1062003e, 0x02002021, 0x0a000c2c, 0x00000000, 0x0e000c31,
388 0x02002021, 0x0a0008b6, 0x8fbf0014, 0x93620005, 0x30420020, 0x1440005e, 535 0x02002021, 0x0a000c2e, 0x8fbf0014, 0x93620005, 0x30420020, 0x1440005e,
389 0x8fbf0014, 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 0x3c038000, 536 0x8fbf0014, 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 0x3c038000,
390 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 0x3c038000, 537 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 0x3c038000,
391 0x34630001, 0x02031825, 0x34420020, 0xa3620005, 0xaf430020, 0x93620005, 538 0x34630001, 0x02031825, 0x34420020, 0xa3620005, 0xaf430020, 0x93620005,
392 0x30420020, 0x14400003, 0x02002021, 0x0000000d, 0x02002021, 0x0e000553, 539 0x30420020, 0x14400003, 0x02002021, 0x0000000d, 0x02002021, 0x0e000766,
393 0x24055854, 0x0a0008b6, 0x8fbf0014, 0x93620005, 0x30420001, 0x1040003f, 540 0x24055854, 0x0a000c2e, 0x8fbf0014, 0x93620005, 0x30420001, 0x1040003f,
394 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 0x3c038000, 0x8f420020, 541 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 0x3c038000, 0x8f420020,
395 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 0x3c048000, 0x3c030800, 542 0x00431024, 0x1440fffd, 0x00000000, 0x93620023, 0x34420004, 0xa3620023,
396 0x304200fe, 0xa3620005, 0x8c620020, 0x34840001, 0x02042025, 0xaf440020, 543 0x93630005, 0x3c048000, 0x3c020800, 0x306300fe, 0xa3630005, 0x8c430020,
397 0x1040002d, 0x8fbf0014, 0x0a000894, 0x00000000, 0x00002821, 0x00003021, 544 0x34840001, 0x02042025, 0x0a000c0a, 0xaf440020, 0x00002821, 0x00003021,
398 0x0e000f78, 0x240706a4, 0x3c020800, 0x8c430020, 0x10600023, 0x8fbf0014, 545 0x0e000fb1, 0x240708d9, 0x3c020800, 0x8c430020, 0x10600023, 0x8fbf0014,
399 0x0e001006, 0x00000000, 0x8f820018, 0xac500000, 0x93630082, 0x9362003f, 546 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000, 0x93630082, 0x9362003f,
400 0x8f840018, 0x00031a00, 0x00431025, 0xac820004, 0x8f830018, 0xac600008, 547 0x8f840018, 0x00031a00, 0x00431025, 0xac820004, 0x8f830018, 0xac600008,
401 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 548 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac400014,
402 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 549 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018,
403 0x9443466e, 0x8f850018, 0x3c02400a, 0x00621825, 0x0e001044, 0xaca3001c, 550 0x944358ce, 0x8f850018, 0x3c02400a, 0x00621825, 0x0e0014cc, 0xaca3001c,
404 0x0a0008b6, 0x8fbf0014, 0x0000000d, 0x8fbf0014, 0x8fb00010, 0x03e00008, 551 0x0a000c2e, 0x8fbf0014, 0x0000000d, 0x8fbf0014, 0x8fb00010, 0x03e00008,
405 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x93420148, 0x2444ffff, 0x2c830005, 552 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x8f420188, 0x00803021, 0x93640000,
406 0x10600047, 0x3c020800, 0x24424598, 0x00041880, 0x00621821, 0x8c640000, 553 0x24030020, 0x00021402, 0x10830008, 0x304500ff, 0x3c036018, 0x8c625000,
407 0x00800008, 0x00000000, 0x8f430144, 0x8f62000c, 0x14620006, 0x24020001, 554 0x34420400, 0xac625000, 0x0000000d, 0x00000000, 0x24000955, 0x9363003f,
408 0xaf62000c, 0x0e000909, 0x00000000, 0x0a000907, 0x8fbf0010, 0x8f62000c, 555 0x24020012, 0x14620023, 0x3c029000, 0x34420001, 0x3c038000, 0x00c21025,
409 0x0a000900, 0x00000000, 0x97630010, 0x8f420144, 0x14430006, 0x24020001, 556 0xaf650178, 0xa365007a, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd,
410 0xa7620010, 0x0e000eeb, 0x00000000, 0x0a000907, 0x8fbf0010, 0x97620010, 557 0x00000000, 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 0x34630001,
411 0x0a000900, 0x00000000, 0x97630012, 0x8f420144, 0x14430006, 0x24020001, 558 0x00c31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00c02021, 0x0e000470,
412 0xa7620012, 0x0e000f06, 0x00000000, 0x0a000907, 0x8fbf0010, 0x97620012, 559 0x24050963, 0x0a000c79, 0x8fbf0010, 0x8f4201f8, 0x00431024, 0x1440fffd,
413 0x0a000900, 0x00000000, 0x97630014, 0x8f420144, 0x14430006, 0x24020001, 560 0x24020002, 0x3c031000, 0xaf4601c0, 0xa34201c4, 0xaf4301f8, 0x0a000c79,
414 0xa7620014, 0x0e000f21, 0x00000000, 0x0a000907, 0x8fbf0010, 0x97620014, 561 0x8fbf0010, 0x9362007e, 0x1445000e, 0x00000000, 0x8f620178, 0x1045000b,
415 0x0a000900, 0x00000000, 0x97630016, 0x8f420144, 0x14430006, 0x24020001, 562 0x00000000, 0x8f820000, 0xaf650178, 0x8f660178, 0x8f440180, 0x8f65004c,
416 0xa7620016, 0x0e000f24, 0x00000000, 0x0a000907, 0x8fbf0010, 0x97620016, 563 0x8c430000, 0x0060f809, 0x30c600ff, 0x0a000c79, 0x8fbf0010, 0xaf650178,
417 0x14400006, 0x8fbf0010, 0x3c030800, 0x8c620070, 0x24420001, 0xac620070, 564 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x93630000,
418 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x93620081, 565 0x24020020, 0x10620005, 0x00000000, 0x93630000, 0x24020030, 0x1462004d,
419 0x3c030800, 0x8c640048, 0x0044102b, 0x14400028, 0x3c029000, 0x8f460140, 566 0x8fbf0010, 0x93420148, 0x2444ffff, 0x2c830005, 0x10600047, 0x3c020800,
420 0x34420001, 0x3c038000, 0x00c21025, 0xaf420020, 0x8f420020, 0x00431024, 567 0x24425800, 0x00041880, 0x00621821, 0x8c640000, 0x00800008, 0x00000000,
421 0x1440fffd, 0x3c048000, 0x34840001, 0x3c059000, 0x34a50001, 0x3c078000, 568 0x8f430144, 0x8f62000c, 0x14620006, 0x24020001, 0xaf62000c, 0x0e000d59,
422 0x24020012, 0x24030080, 0x00c42025, 0x00c52825, 0xa362003f, 0xa3630082, 569 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x8f62000c, 0x0a000cca, 0x00000000,
423 0xaf440020, 0xaf450020, 0x8f420020, 0x00471024, 0x1440fffd, 0x3c038000, 570 0x97630010, 0x8f420144, 0x14430006, 0x24020001, 0xa7620010, 0x0e00137a,
424 0x9362007d, 0x34630001, 0x3c048000, 0x00c31825, 0x34420020, 0xa362007d, 571 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x97620010, 0x0a000cca, 0x00000000,
425 0xaf430020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000, 572 0x97630012, 0x8f420144, 0x14430006, 0x24020001, 0xa7620012, 0x0e001395,
426 0x0a00096d, 0xaf4601c0, 0x93620081, 0x24420001, 0x0e000f2a, 0xa3620081, 573 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x97620012, 0x0a000cca, 0x00000000,
427 0x9763006a, 0x00032880, 0x14a00002, 0x00403821, 0x24050001, 0x97630068, 574 0x97630014, 0x8f420144, 0x14430006, 0x24020001, 0xa7620014, 0x0e0013bb,
575 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x97620014, 0x0a000cca, 0x00000000,
576 0x97630016, 0x8f420144, 0x14430006, 0x24020001, 0xa7620016, 0x0e0013be,
577 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x97620016, 0x14400006, 0x8fbf0010,
578 0x3c030800, 0x8c620070, 0x24420001, 0xac620070, 0x8fbf0010, 0x03e00008,
579 0x27bd0018, 0x27bdffe0, 0x3c029000, 0xafbf001c, 0xafb20018, 0xafb10014,
580 0xafb00010, 0x8f500140, 0x34420001, 0x3c038000, 0x02021025, 0xaf420020,
581 0x8f420020, 0x00431024, 0x1440fffd, 0x24020012, 0x24030080, 0xa362003f,
582 0xa3630082, 0x93620023, 0x30420040, 0x10400007, 0x00008821, 0x93620023,
583 0x24110001, 0x304200bf, 0xa3620023, 0x0a000cf0, 0x3c028000, 0x3c028000,
584 0x34420001, 0x3c039000, 0x34630001, 0x3c048000, 0x02021025, 0x02031825,
585 0xaf420020, 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd, 0x00000000,
586 0x9362007d, 0x3c038000, 0x34420020, 0xa362007d, 0x8f640074, 0x34630001,
587 0x02031825, 0xaf430020, 0x04810006, 0x3c038000, 0x02002021, 0x0e000470,
588 0x24050a63, 0x0a000d13, 0x00000000, 0x8f4201f8, 0x00431024, 0x1440fffd,
589 0x24020002, 0x3c031000, 0xaf5001c0, 0xa34201c4, 0xaf4301f8, 0x1220003f,
590 0x3c120800, 0x8e420020, 0x8f71004c, 0x1040003c, 0x8fbf001c, 0x0e00148e,
591 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x24020001, 0xac820004,
592 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
593 0x8f820018, 0xac510014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
594 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024010, 0x00621825,
595 0x0e0014cc, 0xaca3001c, 0x8e420020, 0x1040001e, 0x8fbf001c, 0x0e00148e,
596 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x3c02008d, 0xac820004,
597 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
598 0x8f840018, 0x24020a6a, 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448,
599 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024019,
600 0x00621825, 0x0e0014cc, 0xaca3001c, 0x8fbf001c, 0x8fb20018, 0x8fb10014,
601 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0010, 0x93620081,
602 0x3c030800, 0x8c640048, 0x0044102b, 0x14400005, 0x00000000, 0x0e000cd3,
603 0x00000000, 0x0a000da4, 0x8fbf0010, 0x93620081, 0x24420001, 0x0e0013c4,
604 0xa3620081, 0x9763006a, 0x00032880, 0x14a00002, 0x00403821, 0x24050001,
605 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804,
606 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b,
607 0x54600001, 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021,
608 0xaf62000c, 0x10e00021, 0x3c029000, 0x8f450140, 0x34420001, 0x3c038000,
609 0x00a21025, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000,
610 0x9362007d, 0x3c038000, 0x34420004, 0xa362007d, 0x8f640074, 0x34630001,
611 0x00a31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00a02021, 0x0e000470,
612 0x24050a92, 0x0a000da4, 0x8fbf0010, 0x8f4201f8, 0x00431024, 0x1440fffd,
613 0x24020002, 0x3c031000, 0xaf4501c0, 0xa34201c4, 0xaf4301f8, 0x8fbf0010,
614 0x03e00008, 0x27bd0018, 0x27bdffd8, 0xafb3001c, 0x27530100, 0xafbf0024,
615 0xafb40020, 0xafb20018, 0xafb10014, 0xafb00010, 0x96620008, 0x3c140800,
616 0x8f520100, 0x30420001, 0x104000da, 0x00000000, 0x8e700018, 0x8f630054,
617 0x2602ffff, 0x00431023, 0x18400006, 0x00000000, 0x0000000d, 0x00000000,
618 0x2400015c, 0x0a000dea, 0x00008821, 0x8f62004c, 0x02021023, 0x18400028,
619 0x00008821, 0x93650120, 0x93640121, 0x3c030800, 0x8c62008c, 0x308400ff,
620 0x24420001, 0x30a500ff, 0x00803821, 0x1485000b, 0xac62008c, 0x3c040800,
621 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 0x30420001, 0x00021023,
622 0x30420005, 0x0a000dea, 0x34510004, 0x27660100, 0x00041080, 0x00c21021,
623 0x8c430000, 0x02031823, 0x04600004, 0x24820001, 0x30440007, 0x1485fff9,
624 0x00041080, 0x10870007, 0x3c030800, 0xa3640121, 0x8c620094, 0x24110005,
625 0x24420001, 0x0a000dea, 0xac620094, 0x24110004, 0x32220001, 0x1040001e,
626 0x8e820020, 0x1040001d, 0x32220004, 0x0e00148e, 0x00000000, 0x8f820018,
627 0xac520000, 0x8f840018, 0x24020001, 0xac820004, 0x8f830018, 0xac600008,
628 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac500014,
629 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018,
630 0x944358ce, 0x8f850018, 0x3c024010, 0x00621825, 0x0e0014cc, 0xaca3001c,
631 0x32220004, 0x10400081, 0x00003821, 0x3c029000, 0x34420001, 0x3c038000,
632 0x02421025, 0xa360007c, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd,
633 0x00000000, 0x93620023, 0x30420080, 0x10400011, 0x00000000, 0x8f65005c,
634 0x8f63004c, 0x9764003c, 0x8f620064, 0x00a32823, 0x00852821, 0x00a2102b,
635 0x54400006, 0x3c023fff, 0x93620023, 0x3042007f, 0xa3620023, 0xaf700064,
636 0x3c023fff, 0x0a000e37, 0x3442ffff, 0x8f62005c, 0x02021023, 0x04400011,
637 0x00000000, 0x8f65005c, 0x8f630064, 0x9764003c, 0x3c023fff, 0x3442ffff,
638 0xaf700064, 0x00a32823, 0x00852821, 0x0045102b, 0x10400004, 0x02051021,
639 0x3c053fff, 0x34a5ffff, 0x02051021, 0xaf62005c, 0x24070001, 0xaf70004c,
640 0x8f620054, 0x16020005, 0x00000000, 0x93620023, 0x30420040, 0x10400017,
641 0x24020001, 0x9762006a, 0x00022880, 0x50a00001, 0x24050001, 0x97630068,
428 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 642 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b,
429 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 643 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001,
430 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 644 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c,
431 0x10e0001a, 0x3c029000, 0x8f440140, 0x34420001, 0x3c038000, 0x00821025, 645 0x93620082, 0x30420080, 0x50400001, 0xa3600081, 0x3c028000, 0x34420001,
432 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 646 0x02421025, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620004, 0x00000000,
433 0x9362007d, 0x34630001, 0x3c058000, 0x00831825, 0x34420004, 0xa362007d, 647 0x0e0013c4, 0x00000000, 0x00403821, 0x10e0001f, 0x3c029000, 0x34420001,
434 0xaf430020, 0x8f4201f8, 0x00451024, 0x1440fffd, 0x24020002, 0x3c031000, 648 0x02421025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
435 0xaf4401c0, 0xa34201c4, 0xaf4301f8, 0x8fbf0010, 0x03e00008, 0x27bd0018, 649 0x00000000, 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 0x34630001,
436 0x27bdffd8, 0xafb3001c, 0x27530100, 0xafbf0024, 0xafb40020, 0xafb20018, 650 0x02431825, 0xaf430020, 0x04810006, 0x3c038000, 0x02402021, 0x0e000470,
437 0xafb10014, 0xafb00010, 0x96620008, 0x3c140800, 0x8f520100, 0x30420001, 651 0x24050b3d, 0x0a000e8d, 0x00000000, 0x8f4201f8, 0x00431024, 0x1440fffd,
438 0x104000cf, 0x00000000, 0x8e700018, 0x8f630054, 0x2602ffff, 0x00431023, 652 0x24020002, 0x3c031000, 0xaf5201c0, 0xa34201c4, 0xaf4301f8, 0x9342010b,
439 0x18400006, 0x00000000, 0x0000000d, 0x00000000, 0x24000128, 0x0a0009b6, 653 0x9343010b, 0x8e820020, 0x27500100, 0x38630006, 0x10400029, 0x2c710001,
440 0x00008821, 0x8f62004c, 0x02021023, 0x18400028, 0x00008821, 0x93650120, 654 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018,
441 0x93640121, 0x3c030800, 0x8c62008c, 0x308400ff, 0x24420001, 0x30a500ff, 655 0x96020008, 0xac820004, 0x8f830018, 0x8e020014, 0xac620008, 0x8f850018,
442 0x00803821, 0x1485000b, 0xac62008c, 0x3c040800, 0x8c830090, 0x24630001, 656 0x3c026000, 0x8c434448, 0xaca3000c, 0x8f840018, 0x96020012, 0xac820010,
443 0xac830090, 0x93620122, 0x30420001, 0x00021023, 0x30420005, 0x0a0009b6, 657 0x8f850018, 0x8e030020, 0xaca30014, 0x9602000c, 0x9603000e, 0x8f840018,
444 0x34510004, 0x27660100, 0x00041080, 0x00c21021, 0x8c430000, 0x02031823, 658 0x00021400, 0x00431025, 0xac820018, 0x12200005, 0x3c020800, 0x944358ce,
445 0x04600004, 0x24820001, 0x30440007, 0x1485fff9, 0x00041080, 0x10870007, 659 0x8f840018, 0x0a000eb8, 0x3c024013, 0x944358ce, 0x8f840018, 0x3c024014,
446 0x3c030800, 0xa3640121, 0x8c620094, 0x24110005, 0x24420001, 0x0a0009b6, 660 0x00621825, 0xac83001c, 0x0e0014cc, 0x24040001, 0x8e700014, 0x8f620040,
447 0xac620094, 0x24110004, 0x32220001, 0x1040001e, 0x8e820020, 0x1040001d, 661 0x14500003, 0x00501023, 0x0a000ec3, 0x00001021, 0x28420001, 0x1040003a,
448 0x32220004, 0x0e001006, 0x00000000, 0x8f820018, 0xac520000, 0x8f840018, 662 0x00000000, 0x0e000fae, 0x02002021, 0xaf700040, 0x9362003e, 0x30420001,
449 0x24020001, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 663 0x1440000b, 0x3c029000, 0x93620022, 0x24420001, 0xa3620022, 0x93630022,
450 0x8f830018, 0xac600010, 0x8f820018, 0xac500014, 0x8f850018, 0x3c026000, 664 0x3c020800, 0x8c440098, 0x0064182b, 0x14600025, 0x3c020800, 0x3c029000,
451 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018,
452 0x3c024010, 0x00621825, 0x0e001044, 0xaca3001c, 0x32220004, 0x10400076,
453 0x00003821, 0x3c029000, 0x34420001, 0x3c038000, 0x02421025, 0xa360007c,
454 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620023,
455 0x30420080, 0x10400011, 0x00000000, 0x8f65005c, 0x8f63004c, 0x9764003c,
456 0x8f620064, 0x00a32823, 0x00852821, 0x00a2102b, 0x54400006, 0x3c023fff,
457 0x93620023, 0x3042007f, 0xa3620023, 0xaf700064, 0x3c023fff, 0x0a000a03,
458 0x3442ffff, 0x8f62005c, 0x02021023, 0x04400011, 0x00000000, 0x8f65005c,
459 0x8f630064, 0x9764003c, 0x3c023fff, 0x3442ffff, 0xaf700064, 0x00a32823,
460 0x00852821, 0x0045102b, 0x10400004, 0x02051021, 0x3c053fff, 0x34a5ffff,
461 0x02051021, 0xaf62005c, 0x24070001, 0xaf70004c, 0x8f620054, 0x16020005,
462 0x00000000, 0x93620023, 0x30420040, 0x10400017, 0x24020001, 0x9762006a,
463 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 0x3c020800,
464 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021,
465 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074,
466 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 0x3c028000, 0x34420001,
467 0x02421025, 0xa3600081, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620004,
468 0x00000000, 0x0e000f2a, 0x00000000, 0x00403821, 0x10e00017, 0x3c029000,
469 0x34420001, 0x02421025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 665 0x34420001, 0x02421025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
470 0x1440fffd, 0x3c028000, 0x9363007d, 0x34420001, 0x3c048000, 0x02421025, 666 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0x34420001, 0xa362007d,
471 0xa363007d, 0xaf420020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002, 667 0x8f640074, 0x34630001, 0x02431825, 0xaf430020, 0x04810006, 0x3c038000,
472 0x3c031000, 0xaf5201c0, 0xa34201c4, 0xaf4301f8, 0x9342010b, 0x8e830020, 668 0x02402021, 0x0e000470, 0x24050273, 0x0a000ef6, 0x24020001, 0x8f4201f8,
473 0x27500100, 0x38420006, 0x10600029, 0x2c510001, 0x0e001006, 0x00000000, 669 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf5201c0, 0xa34201c4,
474 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018, 0x96020008, 0xac820004, 670 0xaf4301f8, 0x24020001, 0xa7620012, 0x0a000efe, 0xa3600022, 0x9743007a,
475 0x8f830018, 0x8e020014, 0xac620008, 0x8f850018, 0x3c026000, 0x8c434448, 671 0x9444002a, 0x00641821, 0x3063fffe, 0xa7630012, 0x97420108, 0x8fbf0024,
476 0xaca3000c, 0x8f840018, 0x96020012, 0xac820010, 0x8f850018, 0x8e030020, 672 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x00021042,
477 0xaca30014, 0x9602000c, 0x9603000e, 0x8f840018, 0x00021400, 0x00431025, 673 0x30420001, 0x03e00008, 0x27bd0028, 0x27bdffe0, 0xafb20018, 0x3c120800,
478 0xac820018, 0x12200005, 0x3c020800, 0x9443466e, 0x8f840018, 0x0a000a78, 674 0x8e420020, 0xafb00010, 0x27500100, 0xafbf001c, 0x10400046, 0xafb10014,
479 0x3c024013, 0x9443466e, 0x8f840018, 0x3c024014, 0x00621825, 0xac83001c, 675 0x0e00148e, 0x00000000, 0x8f840018, 0x8e020000, 0xac820000, 0x936300b1,
480 0x0e001044, 0x24040001, 0x8e630014, 0x8f620040, 0x14430003, 0x00431023, 676 0x936200c5, 0x8f850018, 0x00031e00, 0x00021400, 0x34420100, 0x00621825,
481 0x0a000a83, 0x00001021, 0x28420001, 0x10400034, 0x00000000, 0x8f620040, 677 0xaca30004, 0x8f840018, 0x8e02001c, 0xac820008, 0x8f830018, 0x8f620048,
482 0xaf630040, 0x9362003e, 0x30420001, 0x1440000b, 0x3c029000, 0x93620022, 678 0xac62000c, 0x8f840018, 0x96020012, 0xac820010, 0x8f830018, 0x8f620040,
483 0x24420001, 0xa3620022, 0x93630022, 0x3c020800, 0x8c440098, 0x0064182b, 679 0x24040001, 0xac620014, 0x8f850018, 0x3c026000, 0x8c434448, 0x3c020800,
484 0x1460001e, 0x3c020800, 0x3c029000, 0x34420001, 0x02421025, 0xaf420020, 680 0x245158c0, 0xaca30018, 0x9623000e, 0x8f850018, 0x3c024016, 0x00621825,
485 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 681 0x0e0014cc, 0xaca3001c, 0x96030008, 0x30630010, 0x1060001c, 0x8e420020,
486 0x9362007d, 0x34630001, 0x3c048000, 0x02431825, 0x34420001, 0xa362007d, 682 0x1040001a, 0x8e100000, 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000,
487 0xaf430020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000,
488 0xaf5201c0, 0xa34201c4, 0x24020001, 0xaf4301f8, 0xa7620012, 0x0a000ab6,
489 0xa3600022, 0x9743007a, 0x9444002a, 0x00641821, 0x3063fffe, 0xa7630012,
490 0x0e000b68, 0x00000000, 0x97420108, 0x8fbf0024, 0x8fb40020, 0x8fb3001c,
491 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x00021042, 0x30420001, 0x03e00008,
492 0x27bd0028, 0x27bdffe0, 0xafb20018, 0x3c120800, 0x8e420020, 0xafb00010,
493 0x27500100, 0xafbf001c, 0x10400046, 0xafb10014, 0x0e001006, 0x00000000,
494 0x8f840018, 0x8e020000, 0xac820000, 0x936300b1, 0x936200c5, 0x8f850018,
495 0x00031e00, 0x00021400, 0x34420100, 0x00621825, 0xaca30004, 0x8f840018,
496 0x8e02001c, 0xac820008, 0x8f830018, 0x8f620048, 0xac62000c, 0x8f840018,
497 0x96020012, 0xac820010, 0x8f830018, 0x8f620040, 0x24040001, 0xac620014,
498 0x8f850018, 0x3c026000, 0x8c434448, 0x3c020800, 0x24514660, 0xaca30018,
499 0x9623000e, 0x8f850018, 0x3c024016, 0x00621825, 0x0e001044, 0xaca3001c,
500 0x96030008, 0x30630010, 0x1060001c, 0x8e420020, 0x1040001a, 0x8e100000,
501 0x0e001006, 0x00000000, 0x8f820018, 0xac500000, 0x8f830018, 0xac600004,
502 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010,
503 0x8f830018, 0xac600014, 0x8f850018, 0x3c036000, 0x8c634448, 0x24040001,
504 0xaca30018, 0x9622000e, 0x8f850018, 0x3c034015, 0x00431025, 0x0e001044,
505 0xaca2001c, 0x00001021, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
506 0x03e00008, 0x27bd0020, 0x27bdffe0, 0xafb20018, 0x3c120800, 0x8e420020,
507 0xafb00010, 0x27500100, 0xafbf001c, 0x10400041, 0xafb10014, 0x0e001006,
508 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018, 0x24020100,
509 0xac820004, 0x8f830018, 0x8e02001c, 0xac620008, 0x8f840018, 0x8e020018,
510 0xac82000c, 0x8f830018, 0x96020012, 0xac620010, 0x8f840018, 0x96020008,
511 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800,
512 0x24514660, 0xaca30018, 0x9623000e, 0x8f850018, 0x3c024017, 0x00621825,
513 0x0e001044, 0xaca3001c, 0x96030008, 0x30630010, 0x1060001c, 0x8e420020,
514 0x1040001a, 0x8e100000, 0x0e001006, 0x00000000, 0x8f820018, 0xac500000,
515 0x8f830018, 0xac600004, 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c, 683 0x8f830018, 0xac600004, 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c,
516 0x8f820018, 0xac400010, 0x8f830018, 0xac600014, 0x8f850018, 0x3c036000, 684 0x8f820018, 0xac400010, 0x8f830018, 0xac600014, 0x8f850018, 0x3c036000,
517 0x8c634448, 0x24040001, 0xaca30018, 0x9622000e, 0x8f850018, 0x3c034015, 685 0x8c634448, 0x24040001, 0xaca30018, 0x9622000e, 0x8f850018, 0x3c034015,
518 0x00431025, 0x0e001044, 0xaca2001c, 0x00001021, 0x8fbf001c, 0x8fb20018, 686 0x00431025, 0x0e0014cc, 0xaca2001c, 0x00001021, 0x8fbf001c, 0x8fb20018,
519 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0010, 687 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe0, 0xafb20018,
520 0x936200c4, 0x30420002, 0x10400019, 0x00000000, 0x936200c5, 0x936300b1, 688 0x3c120800, 0x8e420020, 0xafb00010, 0x27500100, 0xafbf001c, 0x10400041,
521 0x00431023, 0x304400ff, 0x30830080, 0x10600004, 0x00000000, 0x0000000d, 689 0xafb10014, 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000,
522 0x00000000, 0x24000a6a, 0x93620004, 0x00441023, 0x304400ff, 0x30830080, 690 0x8f840018, 0x24020100, 0xac820004, 0x8f830018, 0x8e02001c, 0xac620008,
523 0x10600004, 0x2482ffff, 0x8f650024, 0x0a000b82, 0x00000000, 0x00022b00, 691 0x8f840018, 0x8e020018, 0xac82000c, 0x8f830018, 0x96020012, 0xac620010,
524 0x8f620024, 0x0045102b, 0x10400002, 0x00000000, 0x8f650024, 0x8f620048, 692 0x8f840018, 0x96020008, 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448,
525 0x8f630040, 0x00431823, 0x0065202b, 0x10800004, 0x00000000, 0x8f620040, 693 0x24040001, 0x3c020800, 0x245158c0, 0xaca30018, 0x9623000e, 0x8f850018,
526 0x00451021, 0xaf620048, 0x9762003c, 0x0062102b, 0x10400041, 0x8fbf0010, 694 0x3c024017, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x96030008, 0x30630010,
527 0x10a0003f, 0x3c029000, 0x34420001, 0x3c040800, 0x8c830080, 0x8f450100, 695 0x1060001c, 0x8e420020, 0x1040001a, 0x8e100000, 0x0e00148e, 0x00000000,
528 0x3c068000, 0x24630001, 0x00a21025, 0xac830080, 0xaf420020, 0x8f420020, 696 0x8f820018, 0xac500000, 0x8f830018, 0xac600004, 0x8f820018, 0xac400008,
529 0x00461024, 0x1440fffd, 0x3c038000, 0x9362007d, 0x34630001, 0x3c048000, 697 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010, 0x8f830018, 0xac600014,
530 0x00a31825, 0x34420004, 0xa362007d, 0xaf430020, 0x8f4201f8, 0x00441024, 698 0x8f850018, 0x3c036000, 0x8c634448, 0x24040001, 0xaca30018, 0x9622000e,
531 0x1440fffd, 0x24020002, 0x3c030800, 0xaf4501c0, 0xa34201c4, 0x8c640020, 699 0x8f850018, 0x3c034015, 0x00431025, 0x0e0014cc, 0xaca2001c, 0x00001021,
532 0x3c021000, 0xaf4201f8, 0x1080001f, 0x8fbf0010, 0x0e001006, 0x00000000, 700 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
533 0x8f830018, 0x8f420100, 0xac620000, 0x8f840018, 0x8f620040, 0xac820004, 701 0x27bdfff0, 0x03e00008, 0x27bd0010, 0x27bdffd0, 0xafb10014, 0x00808821,
534 0x8f850018, 0x8f620048, 0xaca20008, 0x8f830018, 0xac60000c, 0x8f820018, 702 0xafb40020, 0x00c0a021, 0xafbf0028, 0xafb50024, 0xafb3001c, 0xafb20018,
535 0xac400010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018, 0x8c434448, 703 0xafb00010, 0x93620023, 0x00e0a821, 0x30420040, 0x1040003e, 0x30b3ffff,
536 0x3c020800, 0xac830018, 0x9443466e, 0x8f840018, 0x3c0240c2, 0x00621825, 704 0x3c120800, 0x8e420020, 0x1040003a, 0x8f70004c, 0x0e00148e, 0x00000000,
537 0xac83001c, 0x0e001044, 0x24040001, 0x8fbf0010, 0x03e00008, 0x27bd0018, 705 0x8f820018, 0xac510000, 0x8f840018, 0x24020001, 0xac820004, 0x8f830018,
538 0x3c020800, 0x24423958, 0xaf82000c, 0x03e00008, 0x00000000, 0x27bdffe8, 706 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018,
539 0xafb00010, 0x27500100, 0xafbf0014, 0x8e02001c, 0x14400003, 0x3c020800, 707 0x24040001, 0xac500014, 0x8f850018, 0x3c026000, 0x8c434448, 0x3c020800,
540 0x0000000d, 0x3c020800, 0x8c430020, 0x10600026, 0x00001021, 0x0e001006, 708 0x245058c0, 0xaca30018, 0x9603000e, 0x8f850018, 0x3c024010, 0x00621825,
541 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018, 0x8e02001c, 709 0x0e0014cc, 0xaca3001c, 0x8e430020, 0x1060001b, 0x00000000, 0x0e00148e,
542 0xac820004, 0x8f830018, 0xac600008, 0x8f840018, 0x8e020018, 0xac82000c, 710 0x00000000, 0x8f820018, 0xac510000, 0x8f840018, 0x3c02008d, 0xac820004,
543 0x8f850018, 0x96020012, 0xaca20010, 0x8f830018, 0x3c106000, 0xac600014, 711 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
544 0x8f840018, 0x8e024448, 0x3c030800, 0xac820018, 0x9462466e, 0x8f840018, 712 0x8f820018, 0xac550014, 0x8f850018, 0x3c036000, 0x8c634448, 0x24040001,
545 0x3c034012, 0x00431025, 0xac82001c, 0x0e001044, 0x24040001, 0x8e036800, 713 0xaca30018, 0x9602000e, 0x8f850018, 0x3c034019, 0x00431025, 0x0e0014cc,
546 0x00001021, 0x3c040001, 0x00641825, 0xae036800, 0x0a000c0d, 0x8fbf0014, 714 0xaca2001c, 0x93620023, 0x30420020, 0x14400003, 0x3c120800, 0x1280003f,
547 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c020800, 0x97430078, 715 0x3c029000, 0x8e420020, 0x8f70004c, 0x1040003b, 0x3c029000, 0x0e00148e,
548 0x9444002e, 0x00001021, 0x00641821, 0x3063fffe, 0x03e00008, 0xa7630010, 716 0x00000000, 0x8f820018, 0xac510000, 0x8f840018, 0x24020001, 0xac820004,
549 0x27450100, 0x8f640048, 0x8ca30018, 0x00641023, 0x18400021, 0x00000000, 717 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
550 0xaf630048, 0x8f620040, 0x9763003c, 0x00821023, 0x0043102a, 0x1040001a, 718 0x8f820018, 0x24040001, 0xac500014, 0x8f850018, 0x3c026000, 0x8c434448,
551 0x3c029000, 0x8ca40000, 0x34420001, 0x3c038000, 0x00821025, 0xaf420020, 719 0x3c020800, 0x245058c0, 0xaca30018, 0x9603000e, 0x8f850018, 0x3c024010,
552 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 0x9362007d, 720 0x00621825, 0x0e0014cc, 0xaca3001c, 0x8e430020, 0x1060001c, 0x3c029000,
553 0x34630001, 0x3c058000, 0x00831825, 0x34420004, 0xa362007d, 0xaf430020, 721 0x0e00148e, 0x00000000, 0x8f820018, 0xac510000, 0x8f840018, 0x00131400,
554 0x8f4201f8, 0x00451024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4401c0, 722 0xac820004, 0x8f830018, 0xac750008, 0x8f820018, 0xac40000c, 0x8f830018,
555 0xa34201c4, 0xaf4301f8, 0x03e00008, 0x00001021, 0x8f420100, 0x34420001, 723 0xac600010, 0x8f820018, 0xac400014, 0x8f850018, 0x3c036000, 0x8c634448,
556 0xaf4200a4, 0x03e00008, 0x00001021, 0x27bdffe0, 0xafbf0018, 0xafb10014, 724 0x24040001, 0xaca30018, 0x9602000e, 0x8f850018, 0x3c03401b, 0x00431025,
557 0xafb00010, 0x9362007e, 0x30d000ff, 0x16020029, 0x00808821, 0x93620080, 725 0x0e0014cc, 0xaca2001c, 0x3c029000, 0x34420001, 0x02221025, 0xaf420020,
558 0x16020026, 0x00000000, 0x9362007f, 0x16020023, 0x00000000, 0x9362007a, 726 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93630023,
559 0x16020004, 0x00000000, 0x0000000d, 0x00000000, 0x24000771, 0x0e000f49, 727 0x3c028000, 0x34420001, 0x02221025, 0x8fbf0028, 0x8fb50024, 0x8fb40020,
560 0x00000000, 0x3c039000, 0x34630001, 0x3c048000, 0x02231825, 0xa370007a, 728 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x3063009f, 0xa3630023,
561 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd, 0x3c028000, 0x9363007d, 729 0xaf420020, 0x03e00008, 0x27bd0030, 0x27bdffe0, 0xafb10014, 0x27510100,
562 0x34420001, 0x3c048000, 0x02221025, 0xa363007d, 0xaf420020, 0x8f4201f8, 730 0x3c029000, 0x34420001, 0xafb00010, 0x00808021, 0x02021025, 0x3c038000,
563 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf5101c0, 0xa34201c4, 731 0xafbf0018, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000,
564 0xaf4301f8, 0x0a000c79, 0x8fbf0018, 0x0000000d, 0x00000000, 0x24000781, 732 0xa7600008, 0x8f63005c, 0x3c028000, 0x34420001, 0xaf630148, 0x8f640050,
565 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3c020800, 733 0x02021025, 0x3c039000, 0xaf64017c, 0xaf420020, 0x8f450100, 0x34630001,
734 0x3c048000, 0x00a31825, 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd,
735 0x00000000, 0x9362007d, 0x3c038000, 0x34420001, 0xa362007d, 0x8f640074,
736 0x34630001, 0x00a31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00a02021,
737 0x0e000470, 0x24050de5, 0x0a001093, 0x3c020800, 0x8f4201f8, 0x00431024,
738 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4501c0, 0xa34201c4, 0xaf4301f8,
739 0x3c020800, 0x8c430020, 0x1060001e, 0x8fbf0018, 0x0e00148e, 0x00000000,
740 0x8f830018, 0xac700000, 0x9622000c, 0x8f840018, 0x00021400, 0xac820004,
741 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
742 0x8f820018, 0xac400014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
743 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c02401f, 0x00621825,
744 0x0e0014cc, 0xaca3001c, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008,
745 0x27bd0020, 0x3c020800, 0x24424c3c, 0xaf82000c, 0x03e00008, 0x00000000,
746 0x27bdffe8, 0xafb00010, 0x27500100, 0xafbf0014, 0x8e02001c, 0x14400003,
747 0x3c020800, 0x0000000d, 0x3c020800, 0x8c430020, 0x10600020, 0x00001021,
748 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018,
749 0x8e02001c, 0xac820004, 0x8f830018, 0xac600008, 0x8f840018, 0x8e020018,
750 0xac82000c, 0x8f850018, 0x96020012, 0xaca20010, 0x8f830018, 0x3c026000,
751 0xac600014, 0x8f840018, 0x8c434448, 0x3c020800, 0xac830018, 0x944358ce,
752 0x8f840018, 0x3c024012, 0x00621825, 0xac83001c, 0x0e0014cc, 0x24040001,
753 0x00001021, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c020800,
754 0x97430078, 0x9444002e, 0x00001021, 0x00641821, 0x3063fffe, 0x03e00008,
755 0xa7630010, 0x27bdfff0, 0x00001021, 0x03e00008, 0x27bd0010, 0x8f420100,
756 0x34420001, 0xaf4200a4, 0x03e00008, 0x00001021, 0x27bdffe0, 0xafbf0018,
757 0xafb10014, 0xafb00010, 0x9362007e, 0x30d000ff, 0x16020031, 0x00808821,
758 0x8f620178, 0x1602002e, 0x00000000, 0x9362007f, 0x1602002b, 0x00000000,
759 0x9362007a, 0x16020004, 0x00000000, 0x0000000d, 0x00000000, 0x240009d2,
760 0x0e0013e6, 0x00000000, 0x3c039000, 0x34630001, 0x3c048000, 0x02231825,
761 0xa370007a, 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd, 0x00000000,
762 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 0x34630001, 0x02231825,
763 0xaf430020, 0x04810006, 0x3c038000, 0x02202021, 0x0e000470, 0x240509dd,
764 0x0a001138, 0x8fbf0018, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002,
765 0x3c031000, 0xaf5101c0, 0xa34201c4, 0xaf4301f8, 0x0a001138, 0x8fbf0018,
766 0x0000000d, 0x00000000, 0x240009e2, 0x8fbf0018, 0x8fb10014, 0x8fb00010,
767 0x03e00008, 0x27bd0020, 0x27bdffe8, 0x30a500ff, 0x3c029000, 0x34420001,
768 0x00803821, 0x00e21025, 0x3c038000, 0xafbf0010, 0xaf420020, 0x8f420020,
769 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0x00a21025,
770 0xa362007d, 0x8f640074, 0x34630001, 0x00e31825, 0xaf430020, 0x04810006,
771 0x3c038000, 0x00e02021, 0x0e000470, 0x00c02821, 0x0a001161, 0x8fbf0010,
772 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4701c0,
773 0xa34201c4, 0xaf4301f8, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x3c020800,
566 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 0x10600024, 0xafbf0014, 774 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 0x10600024, 0xafbf0014,
567 0x0e001006, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018, 775 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018,
568 0x8e020004, 0xac820004, 0x8f830018, 0x8e020018, 0xac620008, 0x8f840018, 776 0x8e020004, 0xac820004, 0x8f830018, 0x8e020018, 0xac620008, 0x8f840018,
569 0x8e03001c, 0xac83000c, 0x9602000c, 0x9203000a, 0x8f840018, 0x00021400, 777 0x8e03001c, 0xac83000c, 0x9602000c, 0x9203000a, 0x8f840018, 0x00021400,
570 0x00431025, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018, 778 0x00431025, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018,
571 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x9464466e, 0x8f850018, 779 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x946458ce, 0x8f850018,
572 0x00021400, 0x00441025, 0x24040001, 0x0e001044, 0xaca2001c, 0x8fbf0014, 780 0x00021400, 0x00441025, 0x24040001, 0x0e0014cc, 0xaca2001c, 0x8fbf0014,
573 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe8, 781 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe8,
574 0xafb00010, 0x27500100, 0x10600020, 0xafbf0014, 0x0e001006, 0x00000000, 782 0xafb00010, 0x27500100, 0x10600020, 0xafbf0014, 0x0e00148e, 0x00000000,
575 0x8f820018, 0xac400000, 0x8f830018, 0xac600004, 0x8f820018, 0xac400008, 783 0x8f820018, 0xac400000, 0x8f830018, 0xac600004, 0x8f820018, 0xac400008,
576 0x8f830018, 0xac60000c, 0x9602000c, 0x9603000e, 0x8f840018, 0x00021400, 784 0x8f830018, 0xac60000c, 0x9602000c, 0x9603000e, 0x8f840018, 0x00021400,
577 0x00431025, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018, 785 0x00431025, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018,
578 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x9464466e, 0x8f850018, 786 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x946458ce, 0x8f850018,
579 0x00021400, 0x00441025, 0x24040001, 0x0e001044, 0xaca2001c, 0x8fbf0014, 787 0x00021400, 0x00441025, 0x24040001, 0x0e0014cc, 0xaca2001c, 0x8fbf0014,
580 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafb00010, 0x27500100, 788 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafb00010, 0x27500100,
581 0xafbf0014, 0x9602000c, 0x10400024, 0x00802821, 0x3c020800, 0x8c430020, 789 0xafbf0014, 0x9602000c, 0x10400024, 0x00802821, 0x3c020800, 0x8c430020,
582 0x1060003a, 0x8fbf0014, 0x0e001006, 0x00000000, 0x8f840018, 0x8e030000, 790 0x1060003a, 0x8fbf0014, 0x0e00148e, 0x00000000, 0x8f840018, 0x8e030000,
583 0xac830000, 0x9602000c, 0x8f840018, 0x00021400, 0xac820004, 0x8f830018, 791 0xac830000, 0x9602000c, 0x8f840018, 0x00021400, 0xac820004, 0x8f830018,
584 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 792 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018,
585 0xac400014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 793 0xac400014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800,
586 0xaca30018, 0x9443466e, 0x8f850018, 0x3c02400b, 0x00621825, 0x0e001044, 794 0xaca30018, 0x944358ce, 0x8f850018, 0x3c02400b, 0x00621825, 0x0e0014cc,
587 0xaca3001c, 0x0a000d19, 0x8fbf0014, 0x93620005, 0x30420010, 0x14400015, 795 0xaca3001c, 0x0a0011ff, 0x8fbf0014, 0x93620005, 0x30420010, 0x14400015,
588 0x3c029000, 0x34420001, 0x00a21025, 0xaf420020, 0x3c038000, 0x8f420020, 796 0x3c029000, 0x34420001, 0x00a21025, 0xaf420020, 0x3c038000, 0x8f420020,
589 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 0x93620005, 0x34630001, 797 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 0x93620005, 0x34630001,
590 0x00a02021, 0x00a31825, 0x24055852, 0x34420010, 0xa3620005, 0x0e000553, 798 0x00a02021, 0x00a31825, 0x24055852, 0x34420010, 0xa3620005, 0x0e000766,
591 0xaf430020, 0x0a000d19, 0x8fbf0014, 0x0000000d, 0x8fbf0014, 0x8fb00010, 799 0xaf430020, 0x0a0011ff, 0x8fbf0014, 0x0000000d, 0x8fbf0014, 0x8fb00010,
592 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010, 800 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010,
593 0x27500100, 0x10600022, 0xafbf0014, 0x0e001006, 0x00000000, 0x8f840018, 801 0x27500100, 0x10600022, 0xafbf0014, 0x0e00148e, 0x00000000, 0x8f840018,
594 0x8e020004, 0xac820000, 0x9603000c, 0x9762002c, 0x8f840018, 0x00031c00, 802 0x8e020004, 0xac820000, 0x9603000c, 0x9762002c, 0x8f840018, 0x00031c00,
595 0x00431025, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 803 0x00431025, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
596 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f850018, 0x3c026000, 804 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f850018, 0x3c026000,
597 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 805 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018,
598 0x3c02400e, 0x00621825, 0x0e001044, 0xaca3001c, 0x0e000d48, 0x8e040000, 806 0x3c02400e, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x0e00122e, 0x8e040000,
599 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c038000, 0x8f420278, 807 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c038000, 0x8f420278,
600 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf440240, 0xa3420244, 808 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf440240, 0xa3420244,
601 0x03e00008, 0xaf430278, 0x3c020800, 0x8c430020, 0x27bdffe0, 0xafb10014, 809 0x03e00008, 0xaf430278, 0x3c020800, 0x8c430020, 0x27bdffe0, 0xafb10014,
602 0x00808821, 0xafb20018, 0x00c09021, 0xafb00010, 0x30b0ffff, 0x1060001c, 810 0x00808821, 0xafb20018, 0x00c09021, 0xafb00010, 0x30b0ffff, 0x1060001c,
603 0xafbf001c, 0x0e001006, 0x00000000, 0x8f820018, 0xac510000, 0x8f840018, 811 0xafbf001c, 0x0e00148e, 0x00000000, 0x8f820018, 0xac510000, 0x8f840018,
604 0x00101400, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 812 0x00101400, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
605 0x8f830018, 0xac600010, 0x8f820018, 0xac520014, 0x8f840018, 0x3c026000, 813 0x8f830018, 0xac600010, 0x8f820018, 0xac520014, 0x8f840018, 0x3c026000,
606 0x8c434448, 0x3c020800, 0xac830018, 0x9443466e, 0x8f840018, 0x3c024019, 814 0x8c434448, 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c024019,
607 0x00621825, 0xac83001c, 0x0e001044, 0x24040001, 0x8fbf001c, 0x8fb20018, 815 0x00621825, 0xac83001c, 0x0e0014cc, 0x24040001, 0x8fbf001c, 0x8fb20018,
608 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0x27450100, 816 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0x27450100,
609 0xafbf0010, 0x94a3000c, 0x240200c1, 0x14620029, 0x00803021, 0x3c029000, 817 0xafbf0010, 0x94a3000c, 0x240200c1, 0x14620031, 0x00803021, 0x3c029000,
610 0x34420001, 0x00c21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 818 0x34420001, 0x00c21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
611 0x1440fffd, 0x3c028000, 0x34420001, 0x3c049000, 0x34840001, 0x3c058000, 819 0x1440fffd, 0x3c028000, 0x34420001, 0x3c049000, 0x34840001, 0x3c058000,
612 0x24030012, 0x00c21025, 0x00c42025, 0xa363003f, 0xaf420020, 0xaf440020, 820 0x24030012, 0x00c21025, 0x00c42025, 0xa363003f, 0xaf420020, 0xaf440020,
613 0x8f420020, 0x00451024, 0x1440fffd, 0x3c038000, 0x9362007d, 0x34630001, 821 0x8f420020, 0x00451024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000,
614 0x3c048000, 0x00c31825, 0x34420020, 0xa362007d, 0xaf430020, 0x8f4201f8, 822 0x34420020, 0xa362007d, 0x8f640074, 0x34630001, 0x00c31825, 0xaf430020,
615 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4601c0, 0xa34201c4, 823 0x04810006, 0x3c038000, 0x00c02021, 0x0e000470, 0x24050906, 0x0a0012a1,
616 0xaf4301f8, 0x0a000db3, 0x8fbf0010, 0x00c02021, 0x94a5000c, 0x24060001, 824 0x8fbf0010, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000,
617 0x0e000f78, 0x240706d8, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x3c020800, 825 0xaf4601c0, 0xa34201c4, 0xaf4301f8, 0x0a0012a1, 0x8fbf0010, 0x00c02021,
618 0x8c430020, 0x27bdffe0, 0xafb00010, 0x00808021, 0xafb20018, 0x00a09021, 826 0x94a5000c, 0x24060001, 0x0e000fb1, 0x2407090e, 0x8fbf0010, 0x03e00008,
619 0xafb10014, 0x30d100ff, 0x1060001c, 0xafbf001c, 0x0e001006, 0x00000000, 827 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe0, 0xafb00010, 0x00808021,
620 0x8f820018, 0xac500000, 0x8f840018, 0x24020001, 0xac820004, 0x8f830018, 828 0xafb20018, 0x00a09021, 0xafb10014, 0x30d100ff, 0x1060001c, 0xafbf001c,
621 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 829 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x24020001,
622 0xac520014, 0x8f840018, 0x3c026000, 0x8c434448, 0x3c020800, 0xac830018, 830 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018,
623 0x9443466e, 0x8f840018, 0x3c024010, 0x00621825, 0xac83001c, 0x0e001044, 831 0xac600010, 0x8f820018, 0xac520014, 0x8f840018, 0x3c026000, 0x8c434448,
624 0x02202021, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 832 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c024010, 0x00621825,
625 0x27bd0020, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x93620005, 0x30420001, 833 0xac83001c, 0x0e0014cc, 0x02202021, 0x8fbf001c, 0x8fb20018, 0x8fb10014,
626 0x10400033, 0x00808021, 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 834 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0014, 0xafb00010,
627 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 835 0x93620005, 0x30420001, 0x10400036, 0x00808021, 0x3c029000, 0x34420001,
628 0x3c048000, 0x3c030800, 0x304200fe, 0xa3620005, 0x8c620020, 0x34840001, 836 0x02021025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
629 0x02042025, 0xaf440020, 0x10400020, 0x8fbf0014, 0x0e001006, 0x00000000, 837 0x00000000, 0x93620023, 0x34420004, 0xa3620023, 0x93630005, 0x3c048000,
630 0x8f820018, 0xac500000, 0x93630082, 0x9362003f, 0x8f840018, 0x00031a00, 838 0x3c020800, 0x306300fe, 0xa3630005, 0x8c430020, 0x34840001, 0x02042025,
631 0x00431025, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 839 0xaf440020, 0x10600020, 0x8fbf0014, 0x0e00148e, 0x00000000, 0x8f820018,
632 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f840018, 0x3c026000, 840 0xac500000, 0x93630082, 0x9362003f, 0x8f840018, 0x00031a00, 0x00431025,
633 0x8c434448, 0x3c020800, 0xac830018, 0x9443466e, 0x8f840018, 0x3c02400a, 841 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018,
634 0x00621825, 0xac83001c, 0x0e001044, 0x24040001, 0x8fbf0014, 0x8fb00010, 842 0xac600010, 0x8f820018, 0xac400014, 0x8f840018, 0x3c026000, 0x8c434448,
635 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x8f420188, 0x00803021, 843 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c02400a, 0x00621825,
636 0x9364003f, 0x24030012, 0x00021402, 0x1483001c, 0x304500ff, 0x3c029000, 844 0xac83001c, 0x0e0014cc, 0x24040001, 0x8fbf0014, 0x8fb00010, 0x03e00008,
637 0x34420001, 0x3c038000, 0x00c21025, 0xa3650080, 0xa365007a, 0xaf420020, 845 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe0, 0xafb10014, 0x00808821,
638 0x8f420020, 0x00431024, 0x1440fffd, 0x3c028000, 0x9363007d, 0x34420001, 846 0xafb20018, 0x00a09021, 0xafb00010, 0x30d000ff, 0x1060002f, 0xafbf001c,
639 0x3c048000, 0x00c21025, 0xa363007d, 0xaf420020, 0x8f4201f8, 0x00441024, 847 0x0e00148e, 0x00000000, 0x8f820018, 0xac510000, 0x8f830018, 0xac700004,
640 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4601c0, 0xa34201c4, 0xaf4301f8, 848 0x8f820018, 0xac520008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010,
641 0x0a000e54, 0x8fbf0010, 0x9362007e, 0x1445000e, 0x00000000, 0x93620080, 849 0x9763006a, 0x00032880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081,
642 0x1045000b, 0x00000000, 0xa3650080, 0x8f820000, 0x93660080, 0x8f440180, 850 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001,
643 0x8f65004c, 0x8c430000, 0x0060f809, 0x00000000, 0x0a000e54, 0x8fbf0010, 851 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021,
644 0xa3650080, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 852 0x8f830018, 0x2402fffe, 0x00822824, 0x3c026000, 0xac650014, 0x8f840018,
645 0x27bdffe0, 0xafb10014, 0x00808821, 0xafb20018, 0x00a09021, 0xafb00010, 853 0x8c434448, 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c024011,
646 0x30d000ff, 0x1060002f, 0xafbf001c, 0x0e001006, 0x00000000, 0x8f820018, 854 0x00621825, 0xac83001c, 0x0e0014cc, 0x24040001, 0x8fbf001c, 0x8fb20018,
647 0xac510000, 0x8f830018, 0xac700004, 0x8f820018, 0xac520008, 0x8f830018, 855 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0014,
648 0xac60000c, 0x8f820018, 0xac400010, 0x9763006a, 0x00032880, 0x50a00001, 856 0xafb00010, 0x8f440100, 0x27500100, 0x8f650050, 0x0e0010fc, 0x9206001b,
649 0x24050001, 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 857 0x3c020800, 0x8c430020, 0x1060001d, 0x8e100018, 0x0e00148e, 0x00000000,
650 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 858 0x8f840018, 0x8f420100, 0xac820000, 0x8f830018, 0xac700004, 0x8f840018,
651 0x00c4182b, 0x54600001, 0x00c02021, 0x8f830018, 0x2402fffe, 0x00822824, 859 0x8f620050, 0xac820008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010,
652 0x3c026000, 0xac650014, 0x8f840018, 0x8c434448, 0x3c020800, 0xac830018, 860 0x8f830018, 0x3c026000, 0xac600014, 0x8f850018, 0x8c434448, 0x24040001,
653 0x9443466e, 0x8f840018, 0x3c024011, 0x00621825, 0xac83001c, 0x0e001044, 861 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c02401c, 0x00621825,
654 0x24040001, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 862 0x0e0014cc, 0xaca3001c, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018,
655 0x27bd0020, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f440100, 0x27500100, 863 0x8f430238, 0x3c020800, 0x04610013, 0x8c44009c, 0x2406fffe, 0x3c050800,
656 0x8f650050, 0x0e000c45, 0x9206001b, 0x3c020800, 0x8c430020, 0x1060001d, 864 0x3c038000, 0x2484ffff, 0x14800009, 0x00000000, 0x97420078, 0x8ca3007c,
657 0x8e100018, 0x0e001006, 0x00000000, 0x8f840018, 0x8f420100, 0xac820000, 865 0x24420001, 0x00461024, 0x24630001, 0xa7620010, 0x03e00008, 0xaca3007c,
658 0x8f830018, 0xac700004, 0x8f840018, 0x8f620050, 0xac820008, 0x8f830018, 866 0x8f420238, 0x00431024, 0x1440fff3, 0x2484ffff, 0x8f420140, 0x3c031000,
659 0xac60000c, 0x8f820018, 0xac400010, 0x8f830018, 0x3c026000, 0xac600014, 867 0xaf420200, 0x03e00008, 0xaf430238, 0x27bdffe8, 0x3c029000, 0xafbf0010,
660 0x8f850018, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 868 0x8f450140, 0x34420001, 0x3c038000, 0x00a21025, 0xaf420020, 0x8f420020,
661 0x8f850018, 0x3c02401c, 0x00621825, 0x0e001044, 0xaca3001c, 0x8fbf0014, 869 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0x34420001,
662 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c029000, 0x8f460140, 0x34420001, 870 0xa362007d, 0x8f640074, 0x34630001, 0x00a31825, 0xaf430020, 0x04810006,
663 0x3c038000, 0x00c21025, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 871 0x3c038000, 0x00a02021, 0x0e000470, 0x24050ac7, 0x0a0013b9, 0x8fbf0010,
664 0x3c048000, 0x34840001, 0x3c059000, 0x34a50001, 0x3c078000, 0x24020012, 872 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4501c0,
665 0x24030080, 0x00c42025, 0x00c52825, 0xa362003f, 0xa3630082, 0xaf440020, 873 0xa34201c4, 0xaf4301f8, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x0000000d,
666 0xaf450020, 0x8f420020, 0x00471024, 0x1440fffd, 0x3c038000, 0x9362007d, 874 0x03e00008, 0x00000000, 0x0000000d, 0x03e00008, 0x00000000, 0x24020001,
667 0x34630001, 0x3c048000, 0x00c31825, 0x34420020, 0xa362007d, 0xaf430020, 875 0x03e00008, 0xa7620010, 0x9362003f, 0x304400ff, 0x3883000e, 0x2c630001,
668 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4601c0, 876 0x38820010, 0x2c420001, 0x00621825, 0x14600003, 0x24020012, 0x14820003,
669 0xa34201c4, 0x03e00008, 0xaf4301f8, 0x8f430238, 0x3c020800, 0x04610013, 877 0x00000000, 0x03e00008, 0x00001021, 0x9363007e, 0x9362007a, 0x14620006,
670 0x8c44009c, 0x2406fffe, 0x3c050800, 0x3c038000, 0x2484ffff, 0x14800009, 878 0x00000000, 0x9363007e, 0x24020001, 0x24630001, 0x03e00008, 0xa363007e,
671 0x00000000, 0x97420078, 0x8ca3007c, 0x24420001, 0x00461024, 0x24630001, 879 0x9362007e, 0x8f630178, 0x304200ff, 0x14430006, 0x00000000, 0x9363000b,
672 0xa7620010, 0x03e00008, 0xaca3007c, 0x8f420238, 0x00431024, 0x1440fff3, 880 0x24020001, 0x24630001, 0x03e00008, 0xa363000b, 0x03e00008, 0x00001021,
673 0x2484ffff, 0x8f420140, 0x3c031000, 0xaf420200, 0x03e00008, 0xaf430238, 881 0x9362000b, 0x10400023, 0x00001021, 0xa360000b, 0x9362003f, 0x304400ff,
674 0x3c029000, 0x8f440140, 0x34420001, 0x3c038000, 0x00821025, 0xaf420020, 882 0x3883000e, 0x2c630001, 0x38820010, 0x2c420001, 0x00621825, 0x14600017,
675 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 0x9362007d, 883 0x00001821, 0x24020012, 0x10820014, 0x00000000, 0x9363007e, 0x9362007a,
676 0x34630001, 0x3c058000, 0x00831825, 0x34420001, 0xa362007d, 0xaf430020, 884 0x14620007, 0x00000000, 0x9362007e, 0x24030001, 0x24420001, 0xa362007e,
677 0x8f4201f8, 0x00451024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4401c0, 885 0x03e00008, 0x00601021, 0x9362007e, 0x8f630178, 0x304200ff, 0x14430005,
678 0xa34201c4, 0x03e00008, 0xaf4301f8, 0x0000000d, 0x03e00008, 0x00000000, 886 0x00001821, 0x9362000b, 0x24030001, 0x24420001, 0xa362000b, 0x03e00008,
679 0x0000000d, 0x03e00008, 0x00000000, 0x24020001, 0x03e00008, 0xa7620010, 887 0x00601021, 0x03e00008, 0x00000000, 0x24040001, 0xaf64000c, 0x8f6300dc,
680 0x9362003f, 0x304400ff, 0x3883000e, 0x2c630001, 0x38820010, 0x2c420001, 888 0x8f6200cc, 0x50620001, 0xa7640010, 0xa7640012, 0xa7640014, 0x03e00008,
681 0x00621825, 0x14600003, 0x24020012, 0x14820003, 0x00000000, 0x03e00008, 889 0xa7640016, 0x3c020800, 0x8c430020, 0x27bdffe8, 0x1060001b, 0xafbf0010,
682 0x00001021, 0x9363007e, 0x9362007a, 0x14620006, 0x00000000, 0x9363007e, 890 0x0e00148e, 0x00000000, 0x8f820018, 0xac400000, 0x8f830018, 0xac600004,
683 0x24020001, 0x24630001, 0x03e00008, 0xa363007e, 0x9363007e, 0x93620080, 891 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010,
684 0x14620004, 0x24020001, 0xa362000b, 0x03e00008, 0x24020001, 0x03e00008, 892 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018, 0x8c434448, 0x3c020800,
685 0x00001021, 0x9362000b, 0x10400021, 0x00001021, 0xa360000b, 0x9362003f, 893 0xac830018, 0x944358ce, 0x8f840018, 0x3c024020, 0x00621825, 0xac83001c,
686 0x304400ff, 0x3883000e, 0x2c630001, 0x38820010, 0x2c420001, 0x00621825, 894 0x0e0014cc, 0x24040001, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x3c020800,
687 0x14600015, 0x00001821, 0x24020012, 0x10820012, 0x00000000, 0x9363007e, 895 0x8c430020, 0x27bdffe0, 0xafb00010, 0x00a08021, 0xafb10014, 0x00c08821,
688 0x9362007a, 0x14620007, 0x00000000, 0x9362007e, 0x24030001, 0x24420001, 896 0xafb20018, 0x00e09021, 0x1060001e, 0xafbf001c, 0x0e00148e, 0x00000000,
689 0xa362007e, 0x03e00008, 0x00601021, 0x9363007e, 0x93620080, 0x14620004, 897 0x8f840018, 0x8f420100, 0xac820000, 0x8f830018, 0xac700004, 0x8f820018,
690 0x00001821, 0x24020001, 0xa362000b, 0x24030001, 0x03e00008, 0x00601021, 898 0xac510008, 0x8f830018, 0xac72000c, 0x8f840018, 0x8fa20030, 0xac820010,
691 0x03e00008, 0x00000000, 0x24040001, 0xaf64000c, 0x8f6300dc, 0x8f6200cc, 899 0x8f830018, 0x8fa20034, 0xac620014, 0x8f840018, 0x3c026000, 0x8c434448,
692 0x50620001, 0xa7640010, 0xa7640012, 0xa7640014, 0x03e00008, 0xa7640016, 900 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c0240c9, 0x00621825,
693 0x27bdffd8, 0xafb00010, 0x00808021, 0xafb3001c, 0x00c09821, 0xafbf0020, 901 0xac83001c, 0x0e0014cc, 0x24040001, 0x8fbf001c, 0x8fb20018, 0x8fb10014,
694 0xafb20018, 0xafb10014, 0x93620023, 0x00e09021, 0x30420040, 0x10400020, 902 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3c020800, 0x8c430020, 0x27bdffe8,
695 0x30b1ffff, 0x3c020800, 0x8c430020, 0x1060001c, 0x00000000, 0x0e001006, 903 0xafb00010, 0x27500100, 0x1060001d, 0xafbf0014, 0x0e00148e, 0x00000000,
696 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x3c02008d, 0xac820004, 904 0x8f830018, 0x8e020004, 0xac620000, 0x8f840018, 0x8e020018, 0xac820004,
697 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 905 0x8f850018, 0x8e020000, 0xaca20008, 0x8f830018, 0xac60000c, 0x8f820018,
698 0x8f820018, 0xac520014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 906 0xac400010, 0x8f830018, 0xac600014, 0x8f820018, 0xac400018, 0x96030008,
699 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c024019, 0x00621825, 907 0x3c020800, 0x944458ce, 0x8f850018, 0x00031c00, 0x00641825, 0x24040001,
700 0x0e001044, 0xaca3001c, 0x93620023, 0x30420020, 0x14400003, 0x3c020800, 908 0x0e0014cc, 0xaca3001c, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018,
701 0x52600020, 0x3c029000, 0x8c430020, 0x1060001d, 0x3c029000, 0x0e001006, 909 0x3c060800, 0x24c558c0, 0x3c02000a, 0x03421821, 0x94640006, 0x94a2000a,
702 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x00111400, 0xac820004, 910 0x00441023, 0x00021400, 0x00021c03, 0x04610006, 0xa4a40006, 0x0000000d,
703 0x8f830018, 0xac720008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 911 0x00000000, 0x2400005a, 0x0a0014a3, 0x24020001, 0x8f820014, 0x0062102b,
704 0x8f820018, 0xac400014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 912 0x14400002, 0x00001021, 0x24020001, 0x304200ff, 0x1040001c, 0x274a0400,
705 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c02401b, 0x00621825, 913 0x3c07000a, 0x3c020800, 0x244558c0, 0x94a9000a, 0x8f880014, 0x03471021,
706 0x0e001044, 0xaca3001c, 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 914 0x94430006, 0x00402021, 0xa4a30006, 0x94820006, 0xa4a20006, 0x01221023,
707 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93630023, 915 0x00021400, 0x00021403, 0x04410006, 0x0048102b, 0x0000000d, 0x00000000,
708 0x3c028000, 0x34420001, 0x02021025, 0x8fbf0020, 0x8fb3001c, 0x8fb20018, 916 0x2400005a, 0x0a0014be, 0x24020001, 0x14400002, 0x00001021, 0x24020001,
709 0x8fb10014, 0x8fb00010, 0x3063009f, 0xa3630023, 0xaf420020, 0x03e00008, 917 0x304200ff, 0x1440ffec, 0x03471021, 0x24c458c0, 0x8c820010, 0xaf420038,
710 0x27bd0028, 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 918 0x8c830014, 0x3c020005, 0xaf43003c, 0xaf420030, 0xaf800010, 0xaf8a0018,
711 0x1060001d, 0xafbf0014, 0x0e001006, 0x00000000, 0x8f830018, 0x8e020004, 919 0x03e00008, 0x00000000, 0x27bdffe0, 0x8f820010, 0x8f850018, 0x3c070800,
712 0xac620000, 0x8f840018, 0x8e020018, 0xac820004, 0x8f850018, 0x8e020000, 920 0x24e858c0, 0xafbf001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x9503000a,
713 0xaca20008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010, 0x8f830018, 921 0x8d060014, 0x00009021, 0x309000ff, 0x00e08821, 0x24420001, 0x24a50020,
714 0xac600014, 0x8f820018, 0xac400018, 0x96030008, 0x3c020800, 0x9444466e, 922 0x24630001, 0xaf820010, 0xaf850018, 0xa503000a, 0x24c30020, 0x3c028000,
715 0x8f850018, 0x00031c00, 0x00641825, 0x24040001, 0x0e001044, 0xaca3001c, 923 0x04c10007, 0xad030014, 0x00621024, 0x14400005, 0x262258c0, 0x8d020010,
716 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c060800, 0x24c54660, 924 0x24420001, 0xad020010, 0x262258c0, 0x9444000a, 0x94450018, 0x0010102b,
717 0x3c02000a, 0x03421821, 0x94640006, 0x94a2000a, 0x00441023, 0x00021400, 925 0x00a41826, 0x2c630001, 0x00621825, 0x1060001c, 0x3c030006, 0x8f820010,
718 0x00021c03, 0x04610006, 0xa4a40006, 0x0000000d, 0x00000000, 0x2400005a, 926 0x24120001, 0x00021140, 0x00431025, 0xaf420030, 0x00000000, 0x00000000,
719 0x0a00101b, 0x24020001, 0x8f820014, 0x0062102b, 0x14400002, 0x00001021, 927 0x00000000, 0x27450400, 0x8f420000, 0x30420010, 0x1040fffd, 0x262258c0,
720 0x24020001, 0x304200ff, 0x1040001c, 0x274a0400, 0x3c07000a, 0x3c020800, 928 0x9444000a, 0x94430018, 0xaf800010, 0xaf850018, 0x14830012, 0x262758c0,
721 0x24454660, 0x94a9000a, 0x8f880014, 0x03471021, 0x94430006, 0x00402021, 929 0x0e00155a, 0x00000000, 0x1600000e, 0x262758c0, 0x0e00148e, 0x00000000,
722 0xa4a30006, 0x94820006, 0xa4a20006, 0x01221023, 0x00021400, 0x00021403, 930 0x0a001517, 0x262758c0, 0x00041c00, 0x00031c03, 0x00051400, 0x00021403,
723 0x04410006, 0x0048102b, 0x0000000d, 0x00000000, 0x2400005a, 0x0a001036, 931 0x00621823, 0x18600002, 0x3c026000, 0xac400808, 0x262758c0, 0x94e2000e,
724 0x24020001, 0x14400002, 0x00001021, 0x24020001, 0x304200ff, 0x1440ffec, 932 0x94e3000c, 0x24420001, 0xa4e2000e, 0x3042ffff, 0x50430001, 0xa4e0000e,
725 0x03471021, 0x24c44660, 0x8c820010, 0xaf420038, 0x8c830014, 0x3c020005, 933 0x12000005, 0x3c02000a, 0x94e2000a, 0xa74200a2, 0x0a001554, 0x02401021,
726 0xaf43003c, 0xaf420030, 0xaf800010, 0xaf8a0018, 0x03e00008, 0x00000000, 934 0x03421821, 0x94640006, 0x94e2000a, 0x00441023, 0x00021400, 0x00021c03,
727 0x27bdffe0, 0x8f820010, 0x8f850018, 0x3c070800, 0x24e84660, 0xafbf001c, 935 0x04610006, 0xa4e40006, 0x0000000d, 0x00000000, 0x2400005a, 0x0a001536,
728 0xafb20018, 0xafb10014, 0xafb00010, 0x9503000a, 0x8d060014, 0x00009021, 936 0x24020001, 0x8f820014, 0x0062102b, 0x14400002, 0x00001021, 0x24020001,
729 0x309000ff, 0x00e08821, 0x24420001, 0x24a50020, 0x24630001, 0xaf820010, 937 0x304200ff, 0x1040001b, 0x3c020800, 0x3c06000a, 0x244558c0, 0x94a8000a,
730 0xaf850018, 0xa503000a, 0x24c30020, 0x3c028000, 0x04c10007, 0xad030014, 938 0x8f870014, 0x03461021, 0x94430006, 0x00402021, 0xa4a30006, 0x94820006,
731 0x00621024, 0x14400005, 0x26224660, 0x8d020010, 0x24420001, 0xad020010, 939 0xa4a20006, 0x01021023, 0x00021400, 0x00021403, 0x04410006, 0x0047102b,
732 0x26224660, 0x9444000a, 0x94450018, 0x0010102b, 0x00a41826, 0x2c630001, 940 0x0000000d, 0x00000000, 0x2400005a, 0x0a001550, 0x24020001, 0x14400002,
733 0x00621825, 0x1060001c, 0x3c030006, 0x8f820010, 0x24120001, 0x00021140, 941 0x00001021, 0x24020001, 0x304200ff, 0x1440ffec, 0x03461021, 0x02401021,
734 0x00431025, 0xaf420030, 0x00000000, 0x00000000, 0x00000000, 0x27450400, 942 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
735 0x8f420000, 0x30420010, 0x1040fffd, 0x26224660, 0x9444000a, 0x94430018, 943 0x3c020800, 0x244558c0, 0x94a3001a, 0x8ca40024, 0x00403021, 0x000318c0,
736 0xaf800010, 0xaf850018, 0x14830012, 0x26274660, 0x0e0010d2, 0x00000000, 944 0x00832021, 0xaf44003c, 0x8ca20020, 0xaf420038, 0x3c020050, 0x34420008,
737 0x1600000e, 0x26274660, 0x0e001006, 0x00000000, 0x0a00108f, 0x26274660, 945 0xaf420030, 0x00000000, 0x00000000, 0x00000000, 0x8f420000, 0x30420020,
738 0x00041c00, 0x00031c03, 0x00051400, 0x00021403, 0x00621823, 0x18600002, 946 0x1040fffd, 0x00000000, 0x8f430400, 0x24c658c0, 0xacc30010, 0x8f420404,
739 0x3c026000, 0xac400808, 0x26274660, 0x94e2000e, 0x94e3000c, 0x24420001, 947 0x3c030020, 0xacc20014, 0xaf430030, 0x94c40018, 0x94c3001c, 0x94c2001a,
740 0xa4e2000e, 0x3042ffff, 0x50430001, 0xa4e0000e, 0x12000005, 0x3c02000a, 948 0x94c5001e, 0x00832021, 0x24420001, 0xa4c2001a, 0x3042ffff, 0x14450002,
741 0x94e2000a, 0xa74200a2, 0x0a0010cc, 0x02401021, 0x03421821, 0x94640006, 949 0xa4c40018, 0xa4c0001a, 0x03e00008, 0x00000000, 0x8f820010, 0x3c030006,
742 0x94e2000a, 0x00441023, 0x00021400, 0x00021c03, 0x04610006, 0xa4e40006, 950 0x00021140, 0x00431025, 0xaf420030, 0x00000000, 0x00000000, 0x00000000,
743 0x0000000d, 0x00000000, 0x2400005a, 0x0a0010ae, 0x24020001, 0x8f820014, 951 0x27430400, 0x8f420000, 0x30420010, 0x1040fffd, 0x00000000, 0xaf800010,
744 0x0062102b, 0x14400002, 0x00001021, 0x24020001, 0x304200ff, 0x1040001b, 952 0xaf830018, 0x03e00008, 0x00000000, 0x27bdffe8, 0xafb00010, 0x3c100800,
745 0x3c020800, 0x3c06000a, 0x24454660, 0x94a8000a, 0x8f870014, 0x03461021, 953 0x261058c0, 0x3c05000a, 0x02002021, 0x03452821, 0xafbf0014, 0x0e0015b0,
746 0x94430006, 0x00402021, 0xa4a30006, 0x94820006, 0xa4a20006, 0x01021023, 954 0x2406000a, 0x96020002, 0x9603001e, 0x3042000f, 0x24420003, 0x00431804,
747 0x00021400, 0x00021403, 0x04410006, 0x0047102b, 0x0000000d, 0x00000000, 955 0x24027fff, 0x0043102b, 0xaf830014, 0x10400004, 0x00000000, 0x0000000d,
748 0x2400005a, 0x0a0010c8, 0x24020001, 0x14400002, 0x00001021, 0x24020001, 956 0x00000000, 0x24000043, 0x0e00155a, 0x00000000, 0x8fbf0014, 0x8fb00010,
749 0x304200ff, 0x1440ffec, 0x03461021, 0x02401021, 0x8fbf001c, 0x8fb20018, 957 0x03e00008, 0x27bd0018, 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff,
750 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3c020800, 0x24454660, 958 0x24a50004, 0xac820000, 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000,
751 0x94a3001a, 0x8ca40024, 0x00403021, 0x000318c0, 0x00832021, 0xaf44003c, 959 0x0a0015c1, 0x00a01021, 0xac860000, 0x00000000, 0x00000000, 0x24840004,
752 0x8ca20020, 0xaf420038, 0x3c020050, 0x34420008, 0xaf420030, 0x00000000, 960 0x00a01021, 0x1440fffa, 0x24a5ffff, 0x03e00008, 0x00000000, 0x3c036000,
753 0x00000000, 0x00000000, 0x8f420000, 0x30420020, 0x1040fffd, 0x00000000, 961 0x8c642b7c, 0x3c036010, 0x8c6553fc, 0x00041582, 0x00042302, 0x308403ff,
754 0x8f430400, 0x24c64660, 0xacc30010, 0x8f420404, 0x3c030020, 0xacc20014, 962 0x00052d82, 0x00441026, 0x0002102b, 0x0005282b, 0x00451025, 0x1440000d,
755 0xaf430030, 0x94c40018, 0x94c3001c, 0x94c2001a, 0x94c5001e, 0x00832021, 963 0x3c020050, 0x34420004, 0xaf400038, 0xaf40003c, 0xaf420030, 0x00000000,
756 0x24420001, 0xa4c2001a, 0x3042ffff, 0x14450002, 0xa4c40018, 0xa4c0001a, 964 0x00000000, 0x8f420000, 0x30420020, 0x1040fffd, 0x3c020020, 0xaf420030,
757 0x03e00008, 0x00000000, 0x8f820010, 0x3c030006, 0x00021140, 0x00431025, 965 0x0000000d, 0x03e00008, 0x00000000, 0x3c020050, 0x34420004, 0xaf440038,
758 0xaf420030, 0x00000000, 0x00000000, 0x00000000, 0x27430400, 0x8f420000, 966 0xaf45003c, 0xaf420030, 0x00000000, 0x00000000, 0x8f420000, 0x30420020,
759 0x30420010, 0x1040fffd, 0x00000000, 0xaf800010, 0xaf830018, 0x03e00008, 967 0x1040fffd, 0x3c020020, 0xaf420030, 0x03e00008, 0x00000000, 0x00000000};
760 0x00000000, 0x27bdffe8, 0xafb00010, 0x3c100800, 0x26104660, 0x3c05000a,
761 0x02002021, 0x03452821, 0xafbf0014, 0x0e001128, 0x2406000a, 0x96020002,
762 0x9603001e, 0x3042000f, 0x24420003, 0x00431804, 0x24027fff, 0x0043102b,
763 0xaf830014, 0x10400004, 0x00000000, 0x0000000d, 0x00000000, 0x24000043,
764 0x0e0010d2, 0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018,
765 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000,
766 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a001137, 0x00a01021,
767 0xac860000, 0x24840004, 0x00a01021, 0x1440fffc, 0x24a5ffff, 0x03e00008,
768 0x00000000, 0x3c036000, 0x8c642b7c, 0x3c036010, 0x8c6553fc, 0x00041582,
769 0x00042302, 0x308403ff, 0x00052d82, 0x00441026, 0x0002102b, 0x0005282b,
770 0x00451025, 0x1440000d, 0x3c020050, 0x34420004, 0xaf400038, 0xaf40003c,
771 0xaf420030, 0x00000000, 0x00000000, 0x8f420000, 0x30420020, 0x1040fffd,
772 0x3c020020, 0xaf420030, 0x0000000d, 0x03e00008, 0x00000000, 0x3c020050,
773 0x34420004, 0xaf440038, 0xaf45003c, 0xaf420030, 0x00000000, 0x00000000,
774 0x8f420000, 0x30420020, 0x1040fffd, 0x3c020020, 0xaf420030, 0x03e00008,
775 0x00000000, 0x00000000 };
776
777static u32 bnx2_COM_b06FwData[(0x0/4) + 1] = { 0x00000000 };
778static u32 bnx2_COM_b06FwRodata[(0x18/4) + 1] = {
779 0x08002318, 0x08002348, 0x08002378, 0x080023a8, 0x080023d8, 0x00000000,
780 0x00000000 };
781 968
782static u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x00000000 }; 969static u32 bnx2_COM_b06FwData[(0x0/4) + 1] = { 0x0 };
783static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x00000000 }; 970static u32 bnx2_COM_b06FwRodata[(0x58/4) + 1] = {
971 0x08002428, 0x0800245c, 0x0800245c, 0x0800245c, 0x0800245c, 0x0800245c,
972 0x08002380, 0x0800245c, 0x080023e4, 0x0800245c, 0x0800231c, 0x0800245c,
973 0x0800245c, 0x0800245c, 0x08002328, 0x00000000, 0x08003240, 0x08003270,
974 0x080032a0, 0x080032d0, 0x08003300, 0x00000000, 0x00000000 };
975static u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x0 };
976static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x0 };
784 977
785static int bnx2_RXP_b06FwReleaseMajor = 0x0; 978static int bnx2_RXP_b06FwReleaseMajor = 0x1;
786static int bnx2_RXP_b06FwReleaseMinor = 0x0; 979static int bnx2_RXP_b06FwReleaseMinor = 0x0;
787static int bnx2_RXP_b06FwReleaseFix = 0x0; 980static int bnx2_RXP_b06FwReleaseFix = 0x0;
788static u32 bnx2_RXP_b06FwStartAddr = 0x08000060; 981static u32 bnx2_RXP_b06FwStartAddr = 0x08003104;
789static u32 bnx2_RXP_b06FwTextAddr = 0x08000000; 982static u32 bnx2_RXP_b06FwTextAddr = 0x08000000;
790static int bnx2_RXP_b06FwTextLen = 0x20b8; 983static int bnx2_RXP_b06FwTextLen = 0x562c;
791static u32 bnx2_RXP_b06FwDataAddr = 0x080020e0; 984static u32 bnx2_RXP_b06FwDataAddr = 0x08005660;
792static int bnx2_RXP_b06FwDataLen = 0x0; 985static int bnx2_RXP_b06FwDataLen = 0x0;
793static u32 bnx2_RXP_b06FwRodataAddr = 0x00000000; 986static u32 bnx2_RXP_b06FwRodataAddr = 0x00000000;
794static int bnx2_RXP_b06FwRodataLen = 0x0; 987static int bnx2_RXP_b06FwRodataLen = 0x0;
795static u32 bnx2_RXP_b06FwBssAddr = 0x08002100; 988static u32 bnx2_RXP_b06FwBssAddr = 0x08005680;
796static int bnx2_RXP_b06FwBssLen = 0x239c; 989static int bnx2_RXP_b06FwBssLen = 0x1394;
797static u32 bnx2_RXP_b06FwSbssAddr = 0x080020e0; 990static u32 bnx2_RXP_b06FwSbssAddr = 0x08005660;
798static int bnx2_RXP_b06FwSbssLen = 0x14; 991static int bnx2_RXP_b06FwSbssLen = 0x18;
799 992static u32 bnx2_RXP_b06FwText[(0x562c/4) + 1] = {
800static u32 bnx2_RXP_b06FwText[(0x20b8/4) + 1] = { 993 0x0a000c41, 0x00000000, 0x00000000, 0x0000000d, 0x72787020, 0x322e352e,
801 0x0a000018, 0x00000000, 0x00000000, 0x0000000d, 0x72787020, 0x302e362e, 994 0x38000000, 0x02050803, 0x00000000, 0x0000000d, 0x00000000, 0x00000000,
802 0x39000000, 0x00060903, 0x00000000, 0x0000000d, 0x00000000, 0x00000000,
803 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 995 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
804 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 996 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
805 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800, 997 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
806 0x244220e0, 0x3c030800, 0x2463449c, 0xac400000, 0x0043202b, 0x1480fffd, 998 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
807 0x24420004, 0x3c1d0800, 0x37bd3ffc, 0x03a0f021, 0x3c100800, 0x26100060, 999 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
808 0x3c1c0800, 0x279c20e0, 0x0e000329, 0x00000000, 0x0000000d, 0x8f870008, 1000 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
809 0x2ce20080, 0x10400018, 0x3c030800, 0x24633490, 0x8f460100, 0x00072140, 1001 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
810 0x00831021, 0xac460000, 0x8f450104, 0x00641021, 0xac450004, 0x8f460108, 1002 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
811 0xac460008, 0x8f45010c, 0xac45000c, 0x8f460114, 0xac460010, 0x8f450118, 1003 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
812 0xac450014, 0x8f460124, 0xac460018, 0x8f450128, 0x00641821, 0x24e20001, 1004 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
813 0xaf820008, 0xac65001c, 0x03e00008, 0x00000000, 0x00804021, 0x8f830000, 1005 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
814 0x24070001, 0x3c020001, 0x00621024, 0x10400037, 0x00603021, 0x9742010e, 1006 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
815 0x3c038000, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 1007 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
816 0xa342018b, 0x8f840004, 0x24020080, 0x24030002, 0xaf420180, 0xa743018c, 1008 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
817 0x10800005, 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000069, 0x00021400, 1009 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
818 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c, 1010 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
819 0x24020003, 0x30838000, 0x1060000d, 0xa7420188, 0x93420116, 0x304200fc, 1011 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
820 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600005, 0x00000000, 1012 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
821 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 1013 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
822 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 1014 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
823 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x30c21000, 1015 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
824 0x1040000f, 0x00000000, 0x9742010c, 0x3042fc00, 0x5440000b, 0x24070005, 1016 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
825 0x3c021000, 0x00c21024, 0x10400007, 0x3c030dff, 0x3463ffff, 0x3c020e00, 1017 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
826 0x00c21024, 0x0062182b, 0x54600001, 0x24070005, 0x8f82000c, 0x30434000, 1018 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
827 0x10600016, 0x00404821, 0x3c020f00, 0x00c21024, 0x14400012, 0x00000000, 1019 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1020 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1021 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1022 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1023 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1024 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1025 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1026 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1027 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1028 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1029 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1030 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1031 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1032 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1033 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1034 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1035 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1036 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1037 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1038 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1039 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1040 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1041 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1042 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1044 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1045 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1046 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1047 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1048 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1049 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1050 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1051 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1052 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1053 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1054 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1055 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1056 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1057 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1058 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1059 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1060 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1061 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1062 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1063 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1064 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1065 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1066 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1067 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1068 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1069 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1070 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1071 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1072 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1073 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1074 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1075 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1076 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1077 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1078 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1079 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1080 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1081 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1082 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1083 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1084 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1085 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1086 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1087 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1088 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1089 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1090 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1091 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1092 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1093 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1094 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1095 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1096 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1097 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1098 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1099 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1100 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1101 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1102 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1103 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1104 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1105 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1106 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1107 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1108 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1109 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1110 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1111 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1112 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1113 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1114 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1115 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1116 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1117 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1118 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1119 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1120 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1121 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1122 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1123 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1124 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1125 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1126 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1127 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1128 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1129 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1130 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1131 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1132 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1133 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1134 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1135 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1136 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1137 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1138 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1139 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1140 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1141 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1142 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1143 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1144 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1145 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1146 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1147 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1148 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1149 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1150 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1151 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1152 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1153 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1154 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1155 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1156 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1157 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1158 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1159 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1160 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1161 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1162 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1163 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1164 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1165 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1166 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1167 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1168 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1169 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1170 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1171 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1172 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1173 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1174 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1175 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1176 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1177 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1178 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1179 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1180 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1181 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1182 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1183 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1184 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1185 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1186 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1187 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1188 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1189 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1190 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1191 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1192 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1193 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1194 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1195 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1196 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1197 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1198 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1199 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1200 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1201 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1202 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1203 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1204 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1205 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1206 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1207 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1208 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1209 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1210 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1211 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1212 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1213 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1214 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1215 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1216 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1217 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1218 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1219 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1220 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1221 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1222 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1223 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1224 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1225 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1226 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1227 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1228 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1229 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1230 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1231 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1232 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1233 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1234 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1235 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1236 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1237 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1238 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1239 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1240 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1241 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1242 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1243 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1244 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1245 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1246 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1247 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1248 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1249 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1250 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1251 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1252 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1253 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1254 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1255 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1256 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1257 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1258 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1259 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1260 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1261 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1262 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1263 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1264 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1265 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1266 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1267 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1268 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1269 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1270 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1271 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1272 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1273 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1274 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1275 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1276 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1277 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1278 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1279 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1280 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1281 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1282 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1283 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1284 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1285 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1286 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1287 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1288 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1289 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1290 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1291 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1292 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1293 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1294 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1295 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1296 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1297 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1298 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1299 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1300 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1301 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1302 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1303 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1304 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1305 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1306 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1307 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1308 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1309 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1310 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1311 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1312 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1313 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1314 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1315 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1316 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1317 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1318 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1319 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1320 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1321 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1322 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1323 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1324 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1325 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1326 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1327 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1328 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1329 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1330 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1331 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1332 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1333 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1334 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1335 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1336 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1337 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1338 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1339 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1340 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1341 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1342 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1343 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1344 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1345 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1346 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1347 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1348 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1349 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1350 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1351 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1352 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1353 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1354 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1355 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1356 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1357 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1358 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1359 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1360 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1361 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1362 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1363 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1364 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1365 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1366 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1367 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1368 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1369 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1370 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1371 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1372 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1373 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1374 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1375 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1376 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1377 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1378 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1379 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1380 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1381 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1382 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1383 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1384 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1385 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1386 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1387 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1388 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1389 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1390 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1391 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1392 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1393 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1394 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1395 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1396 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1397 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1398 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1399 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1400 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1401 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1402 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1403 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1404 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1405 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1406 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1407 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1408 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1409 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1410 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1411 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1412 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1413 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1414 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1415 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1416 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1417 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1418 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1419 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1420 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1421 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1422 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1423 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1424 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1425 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1426 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1427 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1428 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1429 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1430 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1431 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1432 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1433 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1434 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1435 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1436 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1437 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1438 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1439 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1440 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1441 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1442 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1443 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1444 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1445 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1446 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1447 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1448 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1449 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1450 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1451 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1452 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1453 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1454 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1455 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1456 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1457 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1458 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1459 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1460 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1461 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1462 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1463 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1464 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1465 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1466 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1467 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1468 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1469 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1470 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1471 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1472 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1473 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1474 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1475 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1476 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1477 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1478 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1479 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1480 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1481 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1482 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1483 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1484 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1485 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1486 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1487 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1488 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1489 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1490 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1491 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1492 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1493 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1494 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1495 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1496 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1497 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1498 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1499 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1500 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1501 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1502 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1503 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1504 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1505 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1506 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1507 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1508 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1509 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1510 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1511 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1512 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1513 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1514 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1515 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1516 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800, 0x24425660,
1517 0x3c030800, 0x24636a14, 0xac400000, 0x0043202b, 0x1480fffd, 0x24420004,
1518 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 0x3c100800, 0x26103104, 0x3c1c0800,
1519 0x279c5660, 0x0e001035, 0x00000000, 0x0000000d, 0x3c080800, 0x8d023100,
1520 0x2c420080, 0x50400001, 0xad003100, 0x8d073100, 0x3c040800, 0x24840100,
1521 0x8f460100, 0x00071840, 0x00671821, 0x00031940, 0x00641021, 0xac460000,
1522 0x8f450104, 0x00831021, 0xac450004, 0x8f460108, 0xac460008, 0x8f45010c,
1523 0xac45000c, 0x8f460114, 0xac460010, 0x8f450118, 0xac450014, 0x8f460124,
1524 0xac460018, 0x8f450128, 0xac45001c, 0x8f464010, 0xac460020, 0x8f454014,
1525 0xac450024, 0x8f464018, 0xac460028, 0x8f45401c, 0xac45002c, 0x8f464020,
1526 0xac460030, 0x8f454024, 0xac450034, 0x8f464028, 0xac460038, 0x8f45402c,
1527 0xac45003c, 0x8f464030, 0xac460040, 0x8f454034, 0xac450044, 0x8f464038,
1528 0xac460048, 0x8f45403c, 0xac45004c, 0x8f464040, 0xac460050, 0x8f454044,
1529 0xac450054, 0x8f464048, 0xac460058, 0x8f45404c, 0x24e70001, 0x00402021,
1530 0xad073100, 0x03e00008, 0xac85005c, 0x8f820004, 0x9743010c, 0x00804821,
1531 0x00403021, 0x30421000, 0x10400010, 0x306affff, 0x30c20020, 0x1440000e,
1532 0x24070005, 0x3c021000, 0x00c21024, 0x10400009, 0x3c030dff, 0x3463ffff,
1533 0x3c020e00, 0x00c21024, 0x0062182b, 0x50600004, 0x24070001, 0x0a000cb1,
1534 0x3c020800, 0x24070001, 0x3c020800, 0x8c430034, 0x1460001d, 0x00405821,
1535 0x8f820010, 0x30424000, 0x1440001a, 0x3c020001, 0x3c021f01, 0x00c24024,
1536 0x3c031000, 0x15030015, 0x3c020001, 0x31420200, 0x54400012, 0x3c020001,
1537 0x9744010e, 0x24020003, 0xa342018b, 0x97850012, 0x24020002, 0x34e30002,
1538 0xaf400180, 0xa742018c, 0xa7430188, 0x24840004, 0x30a5bfff, 0xa744018e,
1539 0xa74501a6, 0xaf4801b8, 0x03e00008, 0x00001021, 0x3c020001, 0x00c21024,
1540 0x10400039, 0x00000000, 0x9742010e, 0x3c038000, 0x3046ffff, 0x8f4201b8,
1541 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97840006, 0x8f85000c,
1542 0x24020080, 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0x10a00005,
1543 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000cec, 0x00021400, 0x9743011e,
1544 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 0x24020003,
1545 0x30838000, 0x1060000d, 0xa7420188, 0x93420116, 0x304200fc, 0x005a1021,
1546 0x24424004, 0x8c430000, 0x3063ffff, 0x14600005, 0x00000000, 0x3c02ffff,
1547 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104,
1548 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac,
1549 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x8f820010, 0x30434000,
1550 0x10600016, 0x00404021, 0x3c020f00, 0x00c21024, 0x14400012, 0x00000000,
828 0x93420116, 0x34424000, 0x03421821, 0x94650002, 0x2ca21389, 0x1040000b, 1551 0x93420116, 0x34424000, 0x03421821, 0x94650002, 0x2ca21389, 0x1040000b,
829 0x3c020800, 0x24422100, 0x00051942, 0x00031880, 0x00621821, 0x30a5001f, 1552 0x3c020800, 0x24425680, 0x00051942, 0x00031880, 0x00621821, 0x30a5001f,
830 0x8c640000, 0x24020001, 0x00a21004, 0x00822024, 0x01044025, 0x11000037, 1553 0x8c640000, 0x24020001, 0x00a21004, 0x00822024, 0x01244825, 0x11200039,
831 0x3c021000, 0x9742010e, 0x34e60002, 0x3c038000, 0x24420004, 0x3045ffff, 1554 0x3c021000, 0x9742010e, 0x34e70002, 0x3c038000, 0x24420004, 0x3046ffff,
832 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x8f840004, 1555 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97840006,
833 0x24020180, 0x24030002, 0xaf420180, 0xa743018c, 0x10800005, 0xa745018e, 1556 0x8f85000c, 0x24020180, 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e,
834 0x9743011c, 0x9742011e, 0x0a0000cd, 0x00021400, 0x9743011e, 0x9742011c, 1557 0x10a00005, 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000d41, 0x00021400,
835 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c, 0x30828000, 0x1040000c, 1558 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010,
836 0xa7460188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000,
837 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf82000c,
838 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff,
839 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x03e00008,
840 0x00001021, 0x00c21024, 0x104000ba, 0x3c020800, 0x8c430030, 0x1060003e,
841 0x31224000, 0x1040003c, 0x3c030f00, 0x00c31824, 0x3c020100, 0x0043102b,
842 0x14400038, 0x3c030800, 0x9742010e, 0x34e60002, 0x3c038000, 0x24420004,
843 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b,
844 0x8f840004, 0x24020080, 0x24030002, 0xaf420180, 0xa743018c, 0x10800005,
845 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000110, 0x00021400, 0x9743011e,
846 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c, 0x30828000,
847 0x1040000c, 0xa7460188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
848 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024,
849 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
850 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
851 0x03e00008, 0x00001021, 0x3c030800, 0x8c620024, 0x30420008, 0x1040003d,
852 0x34e80002, 0x3c020f00, 0x00c21024, 0x5440003a, 0x3107ffff, 0x9742010c,
853 0x30420200, 0x50400036, 0x3107ffff, 0x9742010e, 0x30e6fffb, 0x3c038000,
854 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
855 0xa342018b, 0x8f840004, 0x24020180, 0x24030002, 0xaf420180, 0xa743018c,
856 0x10800005, 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000153, 0x00021400,
857 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c,
858 0x30828000, 0x1040000c, 0xa7460188, 0x93420116, 0x304200fc, 0x005a1021,
859 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
860 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff,
861 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
862 0xaf4201b8, 0x3107ffff, 0x8f820000, 0x3c068000, 0x9743010e, 0x00021442,
863 0x30440780, 0x24630004, 0x3065ffff, 0x8f4201b8, 0x00461024, 0x1440fffd,
864 0x24020003, 0xa342018b, 0x8f830004, 0x24020002, 0xaf440180, 0xa742018c,
865 0x10600005, 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000189, 0x00021400,
866 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c,
867 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021, 1559 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021,
868 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 1560 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
869 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff, 1561 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff,
870 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 1562 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
871 0xaf4201b8, 0x03e00008, 0x00001021, 0x8f424000, 0x30420100, 0x104000ef, 1563 0xaf4201b8, 0x03e00008, 0x00001021, 0x00c21024, 0x104000e3, 0x3c020800,
872 0x3c020800, 0x8c440024, 0x24030001, 0x14830036, 0x00404021, 0x9742010e, 1564 0x8c430030, 0x10600040, 0x31024000, 0x1040003e, 0x3c030f00, 0x00c31824,
873 0x34e50002, 0x3c038000, 0x24420004, 0x3044ffff, 0x8f4201b8, 0x00431024, 1565 0x3c020100, 0x0043102b, 0x1440003a, 0x3c030800, 0x9742010e, 0x34e70002,
874 0x1440fffd, 0x24020003, 0xa342018b, 0x8f830004, 0x24020002, 0xaf400180, 1566 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
875 0xa742018c, 0x10600005, 0xa744018e, 0x9743011c, 0x9742011e, 0x0a0001c6, 1567 0x24020003, 0xa342018b, 0x97840006, 0x8f85000c, 0x24020080, 0x24030002,
1568 0xaf420180, 0xa743018c, 0xa746018e, 0x10a00005, 0xa7440190, 0x9743011c,
1569 0x9742011e, 0x0a000d86, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400,
1570 0x00621825, 0xaf4301a8, 0x8f840010, 0x30828000, 0x1040000c, 0xa7470188,
1571 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff,
1572 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf820010, 0x97820012,
1573 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825,
1574 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021,
1575 0x3c030800, 0x8c620024, 0x30420008, 0x1040003e, 0x34e80002, 0x3c020f00,
1576 0x00c21024, 0x1440003b, 0x8d620034, 0x31420200, 0x10400038, 0x8d620034,
1577 0x9742010e, 0x30e7fffb, 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8,
1578 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97840006, 0x8f85000c,
1579 0x24020180, 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0x10a00005,
1580 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000dca, 0x00021400, 0x9743011e,
1581 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 0x30828000,
1582 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1583 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024,
1584 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1585 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1586 0x8d620034, 0x8f860004, 0x1040001a, 0x30c20100, 0x10400018, 0x3c020f00,
1587 0x00c21024, 0x3c030200, 0x10430014, 0x00000000, 0x8f82000c, 0x10400004,
1588 0x00000000, 0x9742011c, 0x0a000df8, 0x3044ffff, 0x9742011e, 0x3044ffff,
1589 0x3c030800, 0x8c620038, 0x3c030800, 0x2463003c, 0x2442ffff, 0x00822024,
1590 0x00831821, 0x90620000, 0x24420004, 0x0a000e0d, 0x000229c0, 0x00000000,
1591 0x00061602, 0x3042000f, 0x000229c0, 0x3c04fc00, 0x00441021, 0x3c030300,
1592 0x0062182b, 0x50600001, 0x24050800, 0x9742010e, 0x3107ffff, 0x3c038000,
1593 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
1594 0xa342018b, 0x97830006, 0x8f84000c, 0x24020002, 0xaf450180, 0xa742018c,
1595 0xa746018e, 0x10800005, 0xa7430190, 0x9743011c, 0x9742011e, 0x0a000e26,
876 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 1596 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8,
877 0x8f84000c, 0x30828000, 0x1040000c, 0xa7450188, 0x93420116, 0x304200fc, 1597 0x8f840010, 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc,
878 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 1598 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff,
879 0x34427fff, 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 1599 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104,
880 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 1600 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac,
881 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x30820001, 0x10400035, 1601 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x8f424000, 0x30420100,
882 0x30e90004, 0x9742010e, 0x30e6fffb, 0x3c038000, 0x24420004, 0x3044ffff, 1602 0x104000f9, 0x3c020800, 0x8c440024, 0x24030001, 0x14830038, 0x00404821,
883 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x8f830004, 1603 0x9742010e, 0x34e60002, 0x3c038000, 0x24420004, 0x3045ffff, 0x8f4201b8,
884 0x24020002, 0xaf400180, 0xa742018c, 0x10600005, 0xa744018e, 0x9743011c, 1604 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97830006, 0x8f84000c,
885 0x9742011e, 0x0a0001fe, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 1605 0x24020002, 0xaf400180, 0xa742018c, 0xa745018e, 0x10800005, 0xa7430190,
886 0x00621825, 0xaf4301a8, 0x8f84000c, 0x30828000, 0x1040000c, 0xa7470188, 1606 0x9743011c, 0x9742011e, 0x0a000e65, 0x00021400, 0x9743011e, 0x9742011c,
887 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 1607 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 0x30828000, 0x1040000c,
888 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf82000c, 0x9782000e, 1608 0xa7460188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000,
889 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 1609 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf820010,
890 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x30c7ffff, 0x8d020024, 1610 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff,
891 0x30420004, 0x10400037, 0x8d020024, 0x9742010e, 0x30e6fffb, 0x3c038000, 1611 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x03e00008,
892 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 1612 0x00001021, 0x30820001, 0x10400037, 0x30ea0004, 0x9742010e, 0x30e8fffb,
893 0xa342018b, 0x8f840004, 0x24020100, 0x24030002, 0xaf420180, 0xa743018c, 1613 0x3c038000, 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
894 0x10800005, 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000237, 0x00021400, 1614 0x24020003, 0xa342018b, 0x97830006, 0x8f84000c, 0x24020002, 0xaf400180,
895 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c, 1615 0xa742018c, 0xa745018e, 0x10800005, 0xa7430190, 0x9743011c, 0x9742011e,
896 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021, 1616 0x0a000e9f, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825,
897 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 1617 0xaf4301a8, 0x8f840010, 0x30828000, 0x1040000c, 0xa7470188, 0x93420116,
898 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff,
899 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
900 0xaf4201b8, 0x30c7ffff, 0x8d020024, 0x30420008, 0x10400034, 0x00000000,
901 0x9742010e, 0x3c038000, 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024,
902 0x1440fffd, 0x24020003, 0xa342018b, 0x8f840004, 0x24020180, 0x24030002,
903 0xaf420180, 0xa743018c, 0x10800005, 0xa745018e, 0x9743011c, 0x9742011e,
904 0x0a00026f, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825,
905 0xaf4301a8, 0x8f84000c, 0x30828000, 0x1040000c, 0xa7470188, 0x93420116,
906 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 1618 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004,
907 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 1619 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c,
908 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 1620 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6,
909 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x15200046, 0x00001021, 0x3c038000, 1621 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x3107ffff, 0x8d220024, 0x30420004,
910 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0x24032000, 0xa342018b, 1622 0x10400039, 0x8d220024, 0x9742010e, 0x30e8fffb, 0x3c038000, 0x24420004,
911 0xa7430188, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x3c030800, 1623 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b,
912 0x8c620024, 0x30420001, 0x10400035, 0x00001021, 0x9742010e, 0x34e50002, 1624 0x97840006, 0x8f85000c, 0x24020100, 0x24030002, 0xaf420180, 0xa743018c,
913 0x3c038000, 0x24420004, 0x3044ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 1625 0xa746018e, 0x10a00005, 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000eda,
914 0x24020003, 0xa342018b, 0x8f830004, 0x24020002, 0xaf400180, 0xa742018c, 1626 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8,
915 0x10600005, 0xa744018e, 0x9743011c, 0x9742011e, 0x0a0002b5, 0x00021400, 1627 0x8f840010, 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc,
916 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c, 1628 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff,
917 0x30828000, 0x1040000c, 0xa7450188, 0x93420116, 0x304200fc, 0x005a1021, 1629 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104,
918 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 1630 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac,
919 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff, 1631 0x3c021000, 0xaf4201b8, 0x3107ffff, 0x8d220024, 0x30420008, 0x10400036,
920 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 1632 0x00000000, 0x9742010e, 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8,
921 0xaf4201b8, 0x00001021, 0x03e00008, 0x00000000, 0x27bdffe0, 0xafbf0018, 1633 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97840006, 0x8f85000c,
922 0xafb10014, 0xafb00010, 0x8f420140, 0xaf420020, 0x8f430148, 0x3c027000, 1634 0x24020180, 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0x10a00005,
923 0x00621824, 0x3c024000, 0x1062000c, 0x0043102b, 0x14400006, 0x3c025000, 1635 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000f14, 0x00021400, 0x9743011e,
924 0x3c023000, 0x1062000b, 0x3c024000, 0x0a00031f, 0x00000000, 0x10620034, 1636 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 0x30828000,
925 0x3c024000, 0x0a00031f, 0x00000000, 0x0e00067c, 0x00000000, 0x0a00031f, 1637 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1638 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024,
1639 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1640 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1641 0x1540004a, 0x00001021, 0x27440180, 0x3c038000, 0x8f4201b8, 0x00431024,
1642 0x1440fffd, 0x24022000, 0x24030002, 0xa4820008, 0xa083000b, 0xa4800010,
1643 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x3c030800, 0x8c620024,
1644 0x30420001, 0x10400037, 0x00001021, 0x9742010e, 0x34e60002, 0x3c038000,
1645 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
1646 0xa342018b, 0x97830006, 0x8f84000c, 0x24020002, 0xaf400180, 0xa742018c,
1647 0xa745018e, 0x10800005, 0xa7430190, 0x9743011c, 0x9742011e, 0x0a000f5e,
1648 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8,
1649 0x8f840010, 0x30828000, 0x1040000c, 0xa7460188, 0x93420116, 0x304200fc,
1650 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff,
1651 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104,
1652 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac,
1653 0x3c021000, 0xaf4201b8, 0x00001021, 0x03e00008, 0x00000000, 0x27bdffe8,
1654 0xafbf0010, 0x8f460128, 0x8f84000c, 0xaf460020, 0x8f450104, 0x8f420100,
1655 0x24030800, 0xaf850004, 0xaf820010, 0xaf4301b8, 0x1080000a, 0x3c020800,
1656 0x8c430034, 0x10600007, 0x30a22000, 0x10400005, 0x34a30100, 0x8f820008,
1657 0xaf830004, 0x24420001, 0xaf820008, 0x3c020800, 0x8c4300c0, 0x10600006,
1658 0x3c030800, 0x8c6200c4, 0x24040001, 0x24420001, 0x0a000fc0, 0xac6200c4,
1659 0x8f820004, 0x3c030010, 0x00431024, 0x14400009, 0x3c02001f, 0x3c030800,
1660 0x8c620020, 0x00002021, 0x24420001, 0x0e000c99, 0xac620020, 0x0a000fc0,
1661 0x00402021, 0x3442ff00, 0x14c20009, 0x2403bfff, 0x3c030800, 0x8c620020,
1662 0x24040001, 0x24420001, 0x0e000c99, 0xac620020, 0x0a000fc0, 0x00402021,
1663 0x8f820010, 0x00431024, 0x14400006, 0x00000000, 0xaf400048, 0x0e001144,
1664 0xaf400040, 0x0a000fc0, 0x00402021, 0x0e0014c9, 0x00000000, 0x00402021,
1665 0x10800005, 0x3c024000, 0x8f430124, 0x3c026020, 0xac430014, 0x3c024000,
1666 0xaf420138, 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe0,
1667 0xafbf0018, 0xafb10014, 0xafb00010, 0x8f420140, 0xaf420020, 0x8f430148,
1668 0x3c027000, 0x00621824, 0x3c023000, 0x10620021, 0x0043102b, 0x14400006,
1669 0x3c024000, 0x3c022000, 0x10620009, 0x3c024000, 0x0a00102b, 0x00000000,
1670 0x10620045, 0x3c025000, 0x10620047, 0x3c024000, 0x0a00102b, 0x00000000,
1671 0x27440180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000,
1672 0x8f420148, 0x24030002, 0xa083000b, 0x00021402, 0xa4820008, 0x8f430148,
1673 0xa4830010, 0x8f420144, 0x3c031000, 0xac820024, 0xaf4301b8, 0x0a00102b,
926 0x3c024000, 0x8f420148, 0x24030002, 0x3044ffff, 0x00021402, 0x305000ff, 1674 0x3c024000, 0x8f420148, 0x24030002, 0x3044ffff, 0x00021402, 0x305000ff,
927 0x1203000c, 0x27510180, 0x2a020003, 0x10400005, 0x24020003, 0x0600001d, 1675 0x1203000c, 0x27510180, 0x2a020003, 0x10400005, 0x24020003, 0x0600001d,
928 0x36053000, 0x0a00030a, 0x3c038000, 0x12020007, 0x00000000, 0x0a000317, 1676 0x36053000, 0x0a001012, 0x3c038000, 0x12020007, 0x00000000, 0x0a00101f,
929 0x00000000, 0x0e000423, 0x00000000, 0x0a000308, 0x00402021, 0x0e000435, 1677 0x00000000, 0x0e00111f, 0x00000000, 0x0a001010, 0x00402021, 0x0e001131,
930 0x00000000, 0x00402021, 0x36053000, 0x3c038000, 0x8f4201b8, 0x00431024, 1678 0x00000000, 0x00402021, 0x36053000, 0x3c038000, 0x8f4201b8, 0x00431024,
931 0x1440fffd, 0x24020002, 0xa6250008, 0xa222000b, 0xa6240010, 0x8f420144, 1679 0x1440fffd, 0x24020002, 0xa6250008, 0xa222000b, 0xa6240010, 0x8f420144,
932 0x3c031000, 0xae220024, 0xaf4301b8, 0x0a00031f, 0x3c024000, 0x0000000d, 1680 0x3c031000, 0xae220024, 0xaf4301b8, 0x0a00102b, 0x3c024000, 0x0000000d,
933 0x00000000, 0x240001c3, 0x0a00031f, 0x3c024000, 0x0e0007f7, 0x00000000, 1681 0x00000000, 0x24000295, 0x0a00102b, 0x3c024000, 0x0e0013a7, 0x00000000,
934 0x3c024000, 0xaf420178, 0x00000000, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 1682 0x0a00102b, 0x3c024000, 0x0e001552, 0x00000000, 0x3c024000, 0xaf420178,
935 0x03e00008, 0x27bd0020, 0x24020800, 0x03e00008, 0xaf4201b8, 0x27bdffe8, 1683 0x00000000, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
936 0x3c04600c, 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f, 1684 0x24020800, 0x03e00008, 0xaf4201b8, 0x27bdffe8, 0x3c04600c, 0xafbf0014,
937 0x3c106000, 0x00431024, 0x3442380c, 0x24030003, 0xac825000, 0x3c040008, 1685 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f, 0x3c106000, 0x00431024,
938 0xaf430008, 0x8e020808, 0x3c030800, 0xac600020, 0x3042fff0, 0x2c420001, 1686 0x3442380c, 0x24030003, 0xac825000, 0x3c020008, 0xaf430008, 0x8e040808,
939 0xaf820004, 0x0e000819, 0x0344d825, 0x0e000781, 0x00000000, 0x3c020400, 1687 0x0342d825, 0x8e020808, 0x3c030800, 0xac600020, 0x3084fff0, 0x2c840001,
940 0x3442000c, 0x3c03ffff, 0x34630806, 0xae021948, 0xae03194c, 0x8e021980, 1688 0x3042fff0, 0x38420010, 0x2c420001, 0xaf84000c, 0xaf820000, 0x0e001574,
941 0x34420200, 0xae021980, 0x8f500000, 0x32020003, 0x1040fffd, 0x32020001, 1689 0x00000000, 0x0e0014c7, 0x00000000, 0x3c020400, 0x3442000c, 0x3c03ffff,
942 0x10400004, 0x32020002, 0x0e0003bd, 0x00000000, 0x32020002, 0x1040fff6, 1690 0x34630806, 0xae021948, 0xae03194c, 0x8e021980, 0x34420200, 0xae021980,
943 0x00000000, 0x0e0002d4, 0x00000000, 0x0a00034a, 0x00000000, 0x27bdffe8, 1691 0x8f500000, 0x32020003, 0x1040fffd, 0x32020001, 0x10400004, 0x32020002,
944 0x3c04600c, 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f, 1692 0x0e000f7d, 0x00000000, 0x32020002, 0x1040fff6, 0x00000000, 0x0e000fcb,
945 0x3c106000, 0x00431024, 0x3442380c, 0x24030003, 0xac825000, 0x3c040008, 1693 0x00000000, 0x0a00105c, 0x00000000, 0x27bdffe8, 0x3c04600c, 0xafbf0014,
946 0xaf430008, 0x8e020808, 0x3c030800, 0xac600020, 0x3042fff0, 0x2c420001, 1694 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f, 0x3c106000, 0x00431024,
947 0xaf820004, 0x0e000819, 0x0344d825, 0x0e000781, 0x00000000, 0x3c020400, 1695 0x3442380c, 0x24030003, 0xac825000, 0x3c020008, 0xaf430008, 0x8e040808,
948 0x3442000c, 0x3c03ffff, 0x34630806, 0xae021948, 0xae03194c, 0x8e021980, 1696 0x0342d825, 0x8e020808, 0x3c030800, 0xac600020, 0x3084fff0, 0x2c840001,
949 0x8fbf0014, 0x34420200, 0xae021980, 0x8fb00010, 0x03e00008, 0x27bd0018, 1697 0x3042fff0, 0x38420010, 0x2c420001, 0xaf84000c, 0xaf820000, 0x0e001574,
950 0x30a5ffff, 0x30c6ffff, 0x30e7ffff, 0x3c038000, 0x8f4201b8, 0x00431024, 1698 0x00000000, 0x0e0014c7, 0x00000000, 0x3c020400, 0x3442000c, 0x3c03ffff,
951 0x1440fffd, 0x24020003, 0xa342018b, 0x8f830004, 0xaf440180, 0xa745018c, 1699 0x34630806, 0xae021948, 0xae03194c, 0x8e021980, 0x8fbf0014, 0x34420200,
952 0x10600005, 0xa746018e, 0x9743011c, 0x9742011e, 0x0a000393, 0x00021400, 1700 0xae021980, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x30a5ffff, 0x30c6ffff,
953 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c, 1701 0x30e7ffff, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
1702 0xa342018b, 0x97830006, 0x8f82000c, 0xaf440180, 0xa745018c, 0xa746018e,
1703 0x10400005, 0xa7430190, 0x9743011c, 0x9742011e, 0x0a0010ad, 0x00021400,
1704 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010,
954 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021, 1705 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021,
955 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 1706 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
956 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff, 1707 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff,
957 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 1708 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
958 0xaf4201b8, 0x03e00008, 0x00000000, 0x3c038000, 0x8f4201b8, 0x00431024, 1709 0xaf4201b8, 0x03e00008, 0x00000000, 0x27440180, 0x3c038000, 0x8f4201b8,
959 0x1440fffd, 0x24020002, 0x24032000, 0xa342018b, 0xa7430188, 0x3c021000, 1710 0x00431024, 0x1440fffd, 0x24022000, 0x24030002, 0xa4820008, 0xa083000b,
960 0xaf4201b8, 0x03e00008, 0x00000000, 0x27bdffe8, 0xafbf0010, 0x8f460128, 1711 0xa4800010, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00000000, 0x27440180,
961 0xaf460020, 0x8f420104, 0x8f450100, 0x24030800, 0x3c040010, 0xaf820000, 1712 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420148,
962 0x00441024, 0xaf85000c, 0xaf4301b8, 0x14400005, 0x3c02001f, 0x3c030800, 1713 0x24030002, 0xa083000b, 0x00021402, 0xa4820008, 0x8f430148, 0xa4830010,
963 0x8c620020, 0x0a0003d5, 0x00002021, 0x3442ff00, 0x14c20009, 0x2402bfff, 1714 0x8f420144, 0x3c031000, 0xac820024, 0x03e00008, 0xaf4301b8, 0x27bdffe0,
964 0x3c030800, 0x8c620020, 0x24040001, 0x24420001, 0x0e00004c, 0xac620020,
965 0x0a0003e4, 0x00000000, 0x00a21024, 0x14400006, 0x00000000, 0xaf400048,
966 0x0e000448, 0xaf400040, 0x0a0003e4, 0x00000000, 0x0e000783, 0x00000000,
967 0x10400005, 0x3c024000, 0x8f430124, 0x3c026020, 0xac430014, 0x3c024000,
968 0xaf420138, 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe0,
969 0xafbf0018, 0xafb10014, 0xafb00010, 0x8f420148, 0x24030002, 0x3044ffff, 1715 0xafbf0018, 0xafb10014, 0xafb00010, 0x8f420148, 0x24030002, 0x3044ffff,
970 0x00021402, 0x305000ff, 0x1203000c, 0x27510180, 0x2a020003, 0x10400005, 1716 0x00021402, 0x305000ff, 0x1203000c, 0x27510180, 0x2a020003, 0x10400005,
971 0x24020003, 0x0600001d, 0x36053000, 0x0a00040e, 0x3c038000, 0x12020007, 1717 0x24020003, 0x0600001d, 0x36053000, 0x0a00110a, 0x3c038000, 0x12020007,
972 0x00000000, 0x0a00041b, 0x00000000, 0x0e000423, 0x00000000, 0x0a00040c, 1718 0x00000000, 0x0a001117, 0x00000000, 0x0e00111f, 0x00000000, 0x0a001108,
973 0x00402021, 0x0e000435, 0x00000000, 0x00402021, 0x36053000, 0x3c038000, 1719 0x00402021, 0x0e001131, 0x00000000, 0x00402021, 0x36053000, 0x3c038000,
974 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0xa6250008, 0xa222000b, 1720 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0xa6250008, 0xa222000b,
975 0xa6240010, 0x8f420144, 0x3c031000, 0xae220024, 0xaf4301b8, 0x0a00041f, 1721 0xa6240010, 0x8f420144, 0x3c031000, 0xae220024, 0xaf4301b8, 0x0a00111b,
976 0x8fbf0018, 0x0000000d, 0x00000000, 0x240001c3, 0x8fbf0018, 0x8fb10014, 1722 0x8fbf0018, 0x0000000d, 0x00000000, 0x24000295, 0x8fbf0018, 0x8fb10014,
977 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3084ffff, 0x2c821389, 0x1040000d, 1723 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3084ffff, 0x2c821389, 0x1040000d,
978 0x00001021, 0x3c030800, 0x24632100, 0x00042942, 0x00052880, 0x00a32821, 1724 0x00001021, 0x3c030800, 0x24635680, 0x00042942, 0x00052880, 0x00a32821,
979 0x3086001f, 0x8ca40000, 0x24030001, 0x00c31804, 0x00832025, 0x03e00008, 1725 0x3086001f, 0x8ca40000, 0x24030001, 0x00c31804, 0x00832025, 0x03e00008,
980 0xaca40000, 0x03e00008, 0x24020091, 0x3084ffff, 0x2c821389, 0x1040000e, 1726 0xaca40000, 0x03e00008, 0x24020091, 0x3084ffff, 0x2c821389, 0x1040000e,
981 0x00001021, 0x3c030800, 0x24632100, 0x00042942, 0x00052880, 0x00a32821, 1727 0x00001021, 0x3c030800, 0x24635680, 0x00042942, 0x00052880, 0x00a32821,
982 0x3086001f, 0x24030001, 0x8ca40000, 0x00c31804, 0x00031827, 0x00832024, 1728 0x3086001f, 0x24030001, 0x8ca40000, 0x00c31804, 0x00031827, 0x00832024,
983 0x03e00008, 0xaca40000, 0x03e00008, 0x24020091, 0x27bdffb0, 0x3c026000, 1729 0x03e00008, 0xaca40000, 0x03e00008, 0x24020091, 0x27bdffb0, 0xafbf0048,
984 0xafbf0048, 0x8c434448, 0xaf630140, 0x93620005, 0x30420001, 0x14400005, 1730 0x93620023, 0x30420010, 0x1440025b, 0x24020001, 0x93420116, 0x93630005,
985 0x00000000, 0x0e0007ed, 0x00000000, 0x0a00067a, 0x8fbf0048, 0x93420116, 1731 0x34424000, 0x30630001, 0x14600005, 0x03425821, 0x0e001548, 0x00000000,
986 0x93430112, 0x8f430104, 0x3c040020, 0x34424000, 0x00641824, 0x1060000d, 1732 0x0a0013a5, 0x8fbf0048, 0x93420112, 0x8f430104, 0x3c040020, 0x34424000,
987 0x03426021, 0x8f430128, 0x27420180, 0xac430000, 0x8f650040, 0x24040008, 1733 0x00641824, 0x10600012, 0x03422821, 0x27450180, 0x3c038000, 0x8f4201b8,
988 0x240340c1, 0xa4430008, 0x24030002, 0xa043000b, 0x3c031000, 0x0a000563, 1734 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000, 0x8f640040,
989 0xa044000a, 0x8f420104, 0x3c030040, 0x00431024, 0x10400007, 0x00000000, 1735 0x24030008, 0x240240c1, 0xa4a20008, 0x24020002, 0xa0a2000b, 0x3c021000,
990 0x8f430128, 0x27420180, 0xac430000, 0x8f650040, 0x0a00055c, 0x24040010, 1736 0x0a001181, 0xa0a3000a, 0x8f420104, 0x3c030040, 0x00431024, 0x1040001d,
991 0xaf400048, 0xaf400054, 0xaf400040, 0x8f630048, 0x8f620040, 0x00624823, 1737 0x3c038000, 0x27450180, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000,
992 0x05210004, 0x00000000, 0x0000000d, 0x00000000, 0x24000132, 0x9742011a, 1738 0x8f420128, 0xaca20000, 0x8f640040, 0x24030010, 0x240240c1, 0xa4a20008,
993 0x3046ffff, 0x10c00004, 0x8d880004, 0x01061021, 0x0a000487, 0x2445ffff, 1739 0x24020002, 0xa0a3000a, 0x24030008, 0xa0a2000b, 0x3c021000, 0xa4a30010,
994 0x01002821, 0x918a000d, 0xa7a00020, 0xafa00028, 0x9364003f, 0x3c026000, 1740 0xa0a00012, 0xa0a00013, 0xaca00014, 0xaca00024, 0xaca00028, 0xaca0002c,
995 0x8c434448, 0x308700ff, 0x31420004, 0x10400033, 0xaf630144, 0x24090012, 1741 0xaca40018, 0x0e001548, 0xaf4201b8, 0x0a0013a5, 0x8fbf0048, 0x8f820000,
996 0x14e90006, 0x3c040800, 0x8c830028, 0x24020001, 0x24630001, 0x0a00054e, 1742 0x10400016, 0x00000000, 0x8f420104, 0x3c030001, 0x00431024, 0x10400011,
997 0xac830028, 0x8f620044, 0x15020012, 0x97a20020, 0x27a60010, 0x27450180, 1743 0x00000000, 0x8ca3000c, 0x8f620030, 0x1462020c, 0x24020001, 0x8ca30010,
998 0x3442001a, 0xa7a20020, 0x8f630040, 0x3c048000, 0x24020020, 0xa3a70022, 1744 0x8f62002c, 0x14620208, 0x24020001, 0x9763003a, 0x95620000, 0x14430204,
999 0xa3a90023, 0xa3a2001a, 0xafa30028, 0x8f4201b8, 0x00441024, 0x1440fffd, 1745 0x24020001, 0x97630038, 0x95620002, 0x14430200, 0x24020001, 0xaf400048,
1000 0x00000000, 0x0a000533, 0x00000000, 0x8f620044, 0x01021023, 0x0440009e, 1746 0xaf400054, 0xaf400040, 0x8f690040, 0x8f6a0048, 0x01497023, 0x05c10004,
1001 0x24020001, 0x8f620048, 0x01021023, 0x0441009a, 0x24020001, 0x97a20020, 1747 0x00000000, 0x0000000d, 0x00000000, 0x24000169, 0x9742011a, 0x3046ffff,
1002 0x27a60010, 0x34420001, 0xa7a20020, 0x8f630040, 0x27450180, 0x3c048000, 1748 0x10c00004, 0x8d680004, 0x01061021, 0x0a0011b8, 0x2445ffff, 0x01002821,
1003 0xafa30028, 0x8f4201b8, 0x00441024, 0x1440fffd, 0x00000000, 0x0a000533, 1749 0x916c000d, 0xa7a00020, 0xa3a0001a, 0xafa00028, 0x9362003f, 0x31830004,
1004 0x00000000, 0x3c026000, 0x8c424448, 0xaf620148, 0x8f630040, 0x00685823, 1750 0x1060003a, 0x304700ff, 0x24040012, 0x14e40006, 0x24020001, 0x3c040800,
1005 0x19600013, 0x00cb102a, 0x54400007, 0x314a00fe, 0x5566000c, 0x010b4021, 1751 0x8c830028, 0x24630001, 0x0a00128d, 0xac830028, 0x8f620044, 0x15020010,
1006 0x31420001, 0x54400009, 0x010b4021, 0x314a00fe, 0x24020001, 0xa7a20020, 1752 0x27a60010, 0x27450180, 0x3c038000, 0x2402001a, 0xa7a20020, 0x24020020,
1007 0x8f630040, 0x00c05821, 0x00003021, 0x0a0004dd, 0xafa30028, 0x00cb1023, 1753 0xafa90028, 0xa3a70022, 0xa3a40023, 0xa3a2001a, 0x8f4201b8, 0x00431024,
1008 0x0a0004dd, 0x3046ffff, 0x00005821, 0x8f620048, 0x2442ffff, 0x00a21823, 1754 0x1440fffd, 0x00000000, 0x0a001272, 0x00000000, 0x8f620044, 0x01021023,
1009 0x18600019, 0x0066102a, 0x14400013, 0x24020001, 0xa7a20020, 0x8f630040, 1755 0x0440001a, 0x010a1023, 0x044100ae, 0x24020001, 0x3c020800, 0x8c4300d8,
1010 0xafa30028, 0x8f620040, 0x55020005, 0x27a60010, 0x55200003, 0x27a60010, 1756 0x10600004, 0x24020001, 0xa7a20020, 0x0a0011ee, 0xafa90028, 0x2402001a,
1011 0x0a0004f6, 0x00c01821, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 1757 0xa7a20020, 0x24020020, 0xafa90028, 0xa3a70022, 0xa3a40023, 0xa3a2001a,
1012 0x1440fffd, 0x00000000, 0x0a000533, 0x00000000, 0x8f650048, 0x00c31023, 1758 0x27a60010, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1013 0x3046ffff, 0x314a00f6, 0x3c046000, 0x8c824448, 0x31430002, 0x1060001e, 1759 0x00000000, 0x0a001272, 0x00000000, 0x0a00128d, 0x24020001, 0x01286823,
1014 0xaf62014c, 0x8f620044, 0x1502000e, 0x97a20020, 0x27a60010, 0x34420200, 1760 0x19a00016, 0x00cd102a, 0x54400007, 0x318c00fe, 0x55a6000f, 0x010d4021,
1015 0xa7a20020, 0x8f630040, 0x27450180, 0x3c048000, 0xafa30028, 0x8f4201b8, 1761 0x31820001, 0x5440000c, 0x010d4021, 0x318c00fe, 0x00c06821, 0x3c040800,
1016 0x00441024, 0x1440fffd, 0x00000000, 0x0a000533, 0x00000000, 0x27a60010, 1762 0x8c8300c8, 0x00003021, 0x24020001, 0xa7a20020, 0xafa90028, 0x24630001,
1017 0x34420001, 0xa7a20020, 0x8f630040, 0x27450180, 0x3c048000, 0xafa30028, 1763 0x0a001212, 0xac8300c8, 0x00cd1023, 0x0a001212, 0x3046ffff, 0x00006821,
1018 0x8f4201b8, 0x00441024, 0x1440fffd, 0x00000000, 0x0a000533, 0x00000000, 1764 0x2542ffff, 0x00a21823, 0x1860001e, 0x0066102a, 0x14400018, 0x01402821,
1019 0x3c026000, 0x8c424448, 0x31430010, 0xaf620150, 0x54600003, 0x8d890008, 1765 0x97a20020, 0x3c040800, 0x8c8300cc, 0xafa90028, 0x34420001, 0x24630001,
1020 0x0a00054e, 0x24020001, 0x8f630054, 0x2522ffff, 0x00431023, 0x1840002a, 1766 0xa7a20020, 0x01091026, 0x2c420001, 0xac8300cc, 0x2dc30001, 0x00431024,
1021 0x24020001, 0x27a60010, 0xa7a20020, 0x8f630040, 0x27450180, 0x3c048000, 1767 0x1440000a, 0x00c01821, 0x27a60010, 0x27450180, 0x3c038000, 0x8f4201b8,
1022 0xafa30028, 0x8f4201b8, 0x00441024, 0x1440fffd, 0x00000000, 0x8f420128, 1768 0x00431024, 0x1440fffd, 0x00000000, 0x0a001272, 0x00000000, 0x00c31023,
1023 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 0xaca30018, 0x90c4000a, 1769 0x3046ffff, 0x0a00123d, 0x318c00f6, 0x01091023, 0x18400008, 0x97a20020,
1024 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 0xa4a20010, 0x90c30012, 1770 0x3c040800, 0x8c8300d4, 0xafa80028, 0x34420400, 0x24630001, 0xa7a20020,
1025 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 0xaca30014, 0x8cc20024, 1771 0xac8300d4, 0x31820002, 0x1040001c, 0x31820010, 0x8f620044, 0x1502000d,
1026 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc4002c, 0x24020001, 0x3c031000, 1772 0x27a60010, 0x97a20020, 0x27450180, 0x3c038000, 0xafa90028, 0x34420001,
1027 0xaca4002c, 0xaf4301b8, 0xaf400044, 0xaf400050, 0x0a00067a, 0x8fbf0048, 1773 0xa7a20020, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a001272,
1028 0x3c026000, 0x8c424448, 0x31430020, 0x10600019, 0xaf620154, 0x8f430128, 1774 0x00000000, 0x97a20020, 0x27450180, 0x3c038000, 0xafa90028, 0x34420001,
1029 0x27420180, 0xac430000, 0x8f650040, 0x24040004, 0x240340c1, 0xa4430008, 1775 0xa7a20020, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a001272,
1030 0x24030002, 0xa044000a, 0x24040008, 0xa043000b, 0x3c031000, 0xa4440010, 1776 0x00000000, 0x54400003, 0x8d6a0008, 0x0a00128d, 0x24020001, 0x8f630054,
1031 0xa0400012, 0xa0400013, 0xac400014, 0xac400024, 0xac400028, 0xac40002c, 1777 0x2542ffff, 0x00431023, 0x1840002e, 0x97a20020, 0x27a60010, 0x3c040800,
1032 0xac450018, 0x0e0007ed, 0xaf4301b8, 0x0a00067a, 0x8fbf0048, 0x8f430104, 1778 0x8c8300d0, 0x27450180, 0x3c078000, 0xafa90028, 0x34420001, 0x24630001,
1033 0x8c824448, 0x38e3000a, 0x2c630001, 0xaf620158, 0x38e2000c, 0x2c420001, 1779 0xa7a20020, 0xac8300d0, 0x8f4201b8, 0x00471024, 0x1440fffd, 0x00000000,
1034 0x00621825, 0x14600003, 0x2402000e, 0x14e2002a, 0x00000000, 0x50c00008, 1780 0x8f420128, 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 0xaca30018,
1035 0x9584000e, 0x10c00004, 0xa7a60040, 0x01061021, 0x0a000583, 0x2445ffff, 1781 0x90c4000a, 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 0xa4a20010,
1036 0x01002821, 0x9584000e, 0x93630035, 0x8f62004c, 0x00642004, 0x00892021, 1782 0x90c30012, 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 0xaca30014,
1037 0x00821023, 0x1840001f, 0x3c026000, 0x8f620018, 0x01021023, 0x1c40000f, 1783 0x8cc20024, 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc4002c, 0x24020001,
1038 0x97a20020, 0x8f620018, 0x15020018, 0x3c026000, 0x8f62001c, 0x01221023, 1784 0x3c031000, 0xaca4002c, 0xaf4301b8, 0xaf400044, 0xaf400050, 0x0a0013a5,
1039 0x1c400008, 0x97a20020, 0x8f62001c, 0x15220011, 0x3c026000, 0x8f620058, 1785 0x8fbf0048, 0x31820020, 0x10400011, 0x00000000, 0x95620012, 0x0046102b,
1040 0x00821023, 0x1840000c, 0x97a20020, 0xafa50028, 0xafa80034, 0xafa90038, 1786 0x10400008, 0x97a20020, 0x95660012, 0x10c00003, 0x01061021, 0x0a00129e,
1041 0xafa4003c, 0x34420020, 0x0a0005a8, 0xa7a20020, 0x8f680040, 0x00003021, 1787 0x2445ffff, 0x01002821, 0x97a20020, 0x93a3001a, 0x34420008, 0x34630004,
1042 0x8f640058, 0x01002821, 0x3c026000, 0x8c434448, 0xaf63015c, 0x8f62004c, 1788 0xa7a20020, 0xa3a3001a, 0x8f420104, 0x38e3000a, 0x2c630001, 0x38e2000c,
1043 0x01221023, 0x18400009, 0x00000000, 0x8f620054, 0x01221023, 0x1c400005, 1789 0x2c420001, 0x00621825, 0x14600003, 0x2402000e, 0x54e2002a, 0x00003021,
1044 0x97a20020, 0xafa50028, 0xafa90024, 0x0a0005c3, 0x34420040, 0x9742011a, 1790 0x50c00008, 0x9564000e, 0x10c00004, 0xa7a60040, 0x01061021, 0x0a0012b6,
1045 0x1440000c, 0x24020014, 0x8f620058, 0x14820009, 0x24020014, 0x8f63004c, 1791 0x2445ffff, 0x01002821, 0x9564000e, 0x93630035, 0x8f62004c, 0x00642004,
1046 0x8f620054, 0x10620004, 0x97a20020, 0xafa50028, 0x34420080, 0xa7a20020, 1792 0x008a2021, 0x00821023, 0x1840001d, 0x00000000, 0x8f620018, 0x01021023,
1047 0x24020014, 0x10e2000a, 0x28e20015, 0x10400005, 0x2402000c, 0x10e20006, 1793 0x1c40000f, 0x97a20020, 0x8f620018, 0x15020016, 0x00000000, 0x8f62001c,
1048 0x3c026000, 0x0a000600, 0x00000000, 0x24020016, 0x14e20031, 0x3c026000, 1794 0x01421023, 0x1c400008, 0x97a20020, 0x8f62001c, 0x1542000f, 0x00000000,
1049 0x8f620054, 0x24420001, 0x1522002d, 0x3c026000, 0x24020014, 0x10e2001e, 1795 0x8f620058, 0x00821023, 0x1840000b, 0x97a20020, 0xafa50028, 0xafa80034,
1050 0x28e20015, 0x10400005, 0x2402000c, 0x10e20008, 0x3c026000, 0x0a000600, 1796 0xafaa0038, 0xafa4003c, 0x34420020, 0x0a0012da, 0xa7a20020, 0x01204021,
1051 0x00000000, 0x24020016, 0x10e2000c, 0x97a20020, 0x0a000600, 0x3c026000, 1797 0x01002821, 0x8f640058, 0x8f62004c, 0x01421023, 0x18400009, 0x00000000,
1052 0x97a30020, 0x2402000e, 0xafa50028, 0xa3a70022, 0xa3a20023, 0xafa90024, 1798 0x8f620054, 0x01421023, 0x1c400005, 0x97a20020, 0xafa50028, 0xafaa0024,
1053 0x34630054, 0x0a0005ff, 0xa7a30020, 0x24030010, 0x24040002, 0xafa50028, 1799 0x0a0012f2, 0x34420040, 0x9742011a, 0x1440000c, 0x24020014, 0x8f620058,
1054 0xa3a70022, 0xa3a30023, 0xa3a4001a, 0xafa90024, 0x0a0005fe, 0x3442005d, 1800 0x14820009, 0x24020014, 0x8f63004c, 0x8f620054, 0x10620004, 0x97a20020,
1055 0x97a20020, 0x24030012, 0x24040002, 0xafa50028, 0xa3a70022, 0xa3a30023, 1801 0xafa50028, 0x34420080, 0xa7a20020, 0x24020014, 0x10e2000a, 0x28e20015,
1056 0xa3a4001a, 0xafa90024, 0x3042fffe, 0x3442005c, 0xa7a20020, 0x3c026000, 1802 0x10400005, 0x2402000c, 0x10e20006, 0x31820001, 0x0a001333, 0x00000000,
1057 0x8c434448, 0x31420001, 0xaf630160, 0x1040002c, 0x2402000c, 0x10e20014, 1803 0x24020016, 0x14e20035, 0x31820001, 0x8f620084, 0x24420001, 0x15420031,
1058 0x28e2000d, 0x10400005, 0x2402000a, 0x10e20008, 0x97a20020, 0x0a000631, 1804 0x31820001, 0x24020014, 0x10e20021, 0x28e20015, 0x10400005, 0x2402000c,
1059 0x3c026000, 0x2402000e, 0x10e20018, 0x3c026000, 0x0a000631, 0x00000000, 1805 0x10e20008, 0x31820001, 0x0a001333, 0x00000000, 0x24020016, 0x10e2000c,
1060 0x24030008, 0x24040002, 0xafa50028, 0xa3a70022, 0xa3a30023, 0xa3a4001a, 1806 0x31820001, 0x0a001333, 0x00000000, 0x97a30020, 0x2402000e, 0xafa50028,
1061 0x0a00062f, 0x34420013, 0x97a30020, 0x30620004, 0x1440000b, 0x97a20020, 1807 0xa3a70022, 0xa3a20023, 0xafaa0024, 0x34630054, 0x0a001332, 0xa7a30020,
1062 0x3462001b, 0xa7a20020, 0x24020016, 0x24030002, 0xafa50028, 0xa3a70022, 1808 0x97a20020, 0x93a4001a, 0x24030010, 0xafa50028, 0xa3a70022, 0xa3a30023,
1063 0xa3a20023, 0x0a000630, 0xa3a3001a, 0x97a20020, 0x24030010, 0x24040002, 1809 0xafaa0024, 0x3442005d, 0x34840002, 0xa7a20020, 0x0a001332, 0xa3a4001a,
1064 0xafa50028, 0xa3a70022, 0xa3a30023, 0xa3a4001a, 0x3442001b, 0xa7a20020, 1810 0x97a20020, 0x24030012, 0xa3a30023, 0x93a3001a, 0xafa50028, 0xa3a70022,
1065 0x3c026000, 0x8c434448, 0x31420009, 0x0002102b, 0x00021023, 0x30420007, 1811 0xafaa0024, 0x3042fffe, 0x3442005c, 0x34630002, 0xa7a20020, 0xa3a3001a,
1066 0x34440003, 0xaf630164, 0x10c00016, 0x24030800, 0x8f820010, 0x27450180, 1812 0x31820001, 0x10400030, 0x2402000c, 0x10e20013, 0x28e2000d, 0x10400005,
1067 0x24420001, 0xaf820010, 0x24020004, 0xaf4301b8, 0xa4a40008, 0xa0a2000b, 1813 0x2402000a, 0x10e20008, 0x97a20020, 0x0a001365, 0x31820009, 0x2402000e,
1068 0x93440120, 0x3c031000, 0xa4a6000e, 0xaca90024, 0xaca80028, 0x008b2021, 1814 0x10e2001b, 0x31820009, 0x0a001366, 0x0002102b, 0x93a4001a, 0x24030008,
1069 0xa4a4000c, 0xaf4301b8, 0x97a20020, 0x00003021, 0x3042ffbf, 0x0a000650, 1815 0xafa50028, 0xa3a70022, 0xa3a30023, 0x0a001361, 0x34420013, 0x97a30020,
1070 0xa7a20020, 0x24060001, 0x3c026000, 0x8c434448, 0xaf630168, 0x97a20020, 1816 0x30620004, 0x14400005, 0x93a2001a, 0x3463001b, 0xa7a30020, 0x0a001354,
1071 0x10400020, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 1817 0x24030016, 0x3463001b, 0xa7a30020, 0x24030010, 0xafa50028, 0xa3a70022,
1072 0x00000000, 0x8f420128, 0xaca20000, 0x8fa30028, 0x240240c1, 0xa4a20008, 1818 0xa3a30023, 0x34420002, 0x0a001364, 0xa3a2001a, 0x97a20020, 0x93a4001a,
1073 0xaca30018, 0x93a4001a, 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x97a20020, 1819 0x24030010, 0xafa50028, 0xa3a70022, 0xa3a30023, 0x3442001b, 0x34840002,
1074 0xa4a20010, 0x93a30022, 0xa0a30012, 0x93a20023, 0xa0a20013, 0x8fa30024, 1820 0xa7a20020, 0xa3a4001a, 0x31820009, 0x0002102b, 0x00021023, 0x30420007,
1075 0xaca30014, 0x8fa20034, 0xaca20024, 0x8fa30038, 0xaca30028, 0x8fa2003c, 1821 0x10c00017, 0x34440003, 0x8f820014, 0x24030800, 0x27450180, 0x24420001,
1076 0x3c031000, 0xaca2002c, 0xaf4301b8, 0x3c026000, 0x8c434448, 0x00c01021, 1822 0xaf820014, 0x24020004, 0xaf4301b8, 0xa4a40008, 0xa0a2000b, 0x93440120,
1077 0xaf63016c, 0x8fbf0048, 0x03e00008, 0x27bd0050, 0x8f460140, 0x8f470148, 1823 0x3c031000, 0xa4a6000e, 0xacaa0024, 0xaca80028, 0x008d2021, 0xa4a4000c,
1078 0x3c028000, 0x00e24024, 0x00072c02, 0x30a300ff, 0x2402000b, 0x1062008f, 1824 0xaf4301b8, 0x97a20020, 0x00003021, 0x3042ffbf, 0x0a001381, 0xa7a20020,
1079 0x27440180, 0x2862000c, 0x10400011, 0x24020006, 0x1062005a, 0x28620007, 1825 0x24060001, 0x97a20020, 0x10400020, 0x27450180, 0x3c038000, 0x8f4201b8,
1080 0x10400007, 0x24020008, 0x10600024, 0x24020001, 0x10620037, 0x00000000, 1826 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000, 0x8fa30028,
1081 0x0a00077e, 0x00000000, 0x106200a9, 0x24020009, 0x106200bb, 0x00071c02, 1827 0x240240c1, 0xa4a20008, 0xaca30018, 0x93a4001a, 0x24020002, 0xa0a2000b,
1082 0x0a00077e, 0x00000000, 0x2402001b, 0x106200c7, 0x2862001c, 0x10400007, 1828 0xa0a4000a, 0x97a20020, 0xa4a20010, 0x93a30022, 0xa0a30012, 0x93a20023,
1083 0x2402000e, 0x106200b1, 0x24020019, 0x106200c2, 0x00071c02, 0x0a00077e, 1829 0xa0a20013, 0x8fa30024, 0xaca30014, 0x8fa20034, 0xaca20024, 0x8fa30038,
1084 0x00000000, 0x24020080, 0x10620060, 0x28620081, 0x10400005, 0x2402001c, 1830 0xaca30028, 0x8fa2003c, 0x3c031000, 0xaca2002c, 0xaf4301b8, 0x00c01021,
1085 0x10620094, 0x00071c02, 0x0a00077e, 0x00000000, 0x240200c2, 0x106200c5, 1831 0x8fbf0048, 0x03e00008, 0x27bd0050, 0x8f470140, 0x8f460148, 0x3c028000,
1086 0x00a01821, 0x0a00077e, 0x00000000, 0x00a01821, 0x3c058000, 0x8f4201b8, 1832 0x00c24024, 0x00062c02, 0x30a300ff, 0x24020019, 0x106200e7, 0x27440180,
1087 0x00451024, 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 0xac860000, 1833 0x2862001a, 0x1040001f, 0x24020008, 0x106200be, 0x28620009, 0x1040000d,
1088 0xac800004, 0xa082000a, 0xa083000b, 0xa4870010, 0x8f430144, 0x3c021000, 1834 0x24020001, 0x10620046, 0x28620002, 0x50400005, 0x24020006, 0x1060002e,
1835 0x00a01821, 0x0a0014c4, 0x00000000, 0x1062005b, 0x00a01821, 0x0a0014c4,
1836 0x00000000, 0x2402000b, 0x10620084, 0x2862000c, 0x10400005, 0x24020009,
1837 0x106200bc, 0x00061c02, 0x0a0014c4, 0x00000000, 0x2402000e, 0x106200b7,
1838 0x00061c02, 0x0a0014c4, 0x00000000, 0x28620021, 0x10400009, 0x2862001f,
1839 0x104000c1, 0x2402001b, 0x106200bf, 0x2402001c, 0x1062009a, 0x00061c02,
1840 0x0a0014c4, 0x00000000, 0x240200c2, 0x106200ca, 0x286200c3, 0x10400005,
1841 0x24020080, 0x1062005a, 0x00a01821, 0x0a0014c4, 0x00000000, 0x240200c9,
1842 0x106200cd, 0x30c5ffff, 0x0a0014c4, 0x00000000, 0x3c058000, 0x8f4201b8,
1843 0x00451024, 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 0xac870000,
1844 0xac800004, 0xa082000a, 0xa083000b, 0xa4860010, 0x8f430144, 0x3c021000,
1089 0xac800028, 0xac830024, 0x3c036000, 0xaf4201b8, 0x03e00008, 0xac600808, 1845 0xac800028, 0xac830024, 0x3c036000, 0xaf4201b8, 0x03e00008, 0xac600808,
1090 0x11000009, 0x00a01821, 0x3c020800, 0x24030002, 0xa0434490, 0x24424490, 1846 0x11000009, 0x00a01821, 0x3c020800, 0x24030002, 0xa0436a08, 0x24426a08,
1091 0xac460008, 0x8f430144, 0x03e00008, 0xac430004, 0x3c058000, 0x8f4201b8, 1847 0xac470008, 0x8f430144, 0x03e00008, 0xac430004, 0x3c058000, 0x8f4201b8,
1092 0x00451024, 0x1440fffd, 0x24020002, 0xac800000, 0xac860004, 0xa4830008, 1848 0x00451024, 0x1440fffd, 0x24020002, 0xac800000, 0xac870004, 0xa4830008,
1093 0xa082000a, 0xa082000b, 0xa4870010, 0xac800024, 0x8f420144, 0x3c031000, 1849 0xa082000a, 0xa082000b, 0xa4860010, 0xac800024, 0x8f420144, 0x3c031000,
1094 0xac820028, 0x3c026000, 0xaf4301b8, 0x03e00008, 0xac400808, 0x00a01821, 1850 0xac820028, 0x3c026000, 0xaf4301b8, 0x03e00008, 0xac400808, 0x3c080800,
1095 0x3c080800, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x00000000, 1851 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x00000000, 0xac870000,
1096 0xac860000, 0x91024490, 0x00002821, 0x10400002, 0x25064490, 0x8cc50008, 1852 0x91026a08, 0x00002821, 0x10400002, 0x25076a08, 0x8ce50008, 0xac850004,
1097 0xac850004, 0xa4830008, 0x91034490, 0x24020002, 0xa082000b, 0xa4870010, 1853 0xa4830008, 0x91036a08, 0x24020002, 0xa082000b, 0xa4860010, 0x34630001,
1098 0x34630001, 0xa083000a, 0x8f420144, 0xac820024, 0x91034490, 0x10600002, 1854 0xa083000a, 0x8f420144, 0xac820024, 0x91036a08, 0x10600002, 0x00001021,
1099 0x00001021, 0x8cc20004, 0xac820028, 0x3c021000, 0xaf4201b8, 0x3c026000, 1855 0x8ce20004, 0xac820028, 0x3c021000, 0xaf4201b8, 0x3c026000, 0xa1006a08,
1100 0xa1004490, 0x03e00008, 0xac400808, 0x00a01821, 0x3c058000, 0x8f4201b8, 1856 0x03e00008, 0xac400808, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd,
1101 0x00451024, 0x1440fffd, 0x24020002, 0xa082000b, 0xa4830008, 0xa4870010, 1857 0x24020002, 0xa082000b, 0xa4830008, 0xa4860010, 0x8f420144, 0x3c031000,
1102 0x8f420144, 0x3c031000, 0xa4820012, 0x03e00008, 0xaf4301b8, 0x30e2ffff, 1858 0xa4820012, 0x03e00008, 0xaf4301b8, 0x30c2ffff, 0x14400028, 0x00061c02,
1103 0x14400028, 0x00071c02, 0x93620005, 0x30420004, 0x14400020, 0x3c029000, 1859 0x93620005, 0x30420004, 0x14400020, 0x3c029000, 0x34420001, 0x00e21025,
1104 0x34420001, 0x00c21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 1860 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000,
1105 0x1440fffd, 0x00000000, 0x93620005, 0x3c038000, 0x34630001, 0x00c31825, 1861 0x93620005, 0x3c038000, 0x34630001, 0x00e31825, 0x34420004, 0xa3620005,
1106 0x34420004, 0xa3620005, 0xaf430020, 0x93620005, 0x30420004, 0x14400003, 1862 0xaf430020, 0x93620005, 0x30420004, 0x14400003, 0x3c038000, 0x0000000d,
1107 0x3c038000, 0x0000000d, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 1863 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020005, 0x3c031000,
1108 0x24020005, 0x3c031000, 0xac860000, 0xa082000b, 0xaf4301b8, 0x0a00073d, 1864 0xac870000, 0xa082000b, 0xaf4301b8, 0x0a001473, 0x00061c02, 0x0000000d,
1109 0x00071c02, 0x0000000d, 0x03e00008, 0x00000000, 0x00071c02, 0x3c058000, 1865 0x03e00008, 0x00000000, 0x00061c02, 0x3c058000, 0x8f4201b8, 0x00451024,
1110 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 1866 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 0xac870000, 0xac800004,
1111 0xac860000, 0xac800004, 0xa082000a, 0xa083000b, 0xa4870010, 0x8f430144, 1867 0xa082000a, 0xa083000b, 0xa4860010, 0x8f430144, 0x3c021000, 0xac800028,
1112 0x3c021000, 0xac800028, 0xac830024, 0x03e00008, 0xaf4201b8, 0x00071c02, 1868 0xac830024, 0x03e00008, 0xaf4201b8, 0x3c058000, 0x8f4201b8, 0x00451024,
1113 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002, 0xac800000, 1869 0x1440fffd, 0x24020002, 0xac800000, 0xac870004, 0xa4830008, 0xa082000a,
1114 0xac860004, 0xa4830008, 0xa082000a, 0xa082000b, 0xa4870010, 0xac800024, 1870 0xa082000b, 0xa4860010, 0xac800024, 0x8f420144, 0x3c031000, 0xac820028,
1115 0x8f420144, 0x3c031000, 0xac820028, 0x03e00008, 0xaf4301b8, 0x00071c02, 1871 0x03e00008, 0xaf4301b8, 0x00061c02, 0x3c058000, 0x8f4201b8, 0x00451024,
1116 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020001, 0xa4830008, 1872 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 0xa082000a, 0x3c021000,
1117 0x24030002, 0xa082000a, 0x3c021000, 0xac860000, 0xac800004, 0xa083000b, 1873 0xac870000, 0xac800004, 0xa083000b, 0xa4860010, 0xac800024, 0xac800028,
1118 0xa4870010, 0xac800024, 0xac800028, 0x03e00008, 0xaf4201b8, 0x3c058000, 1874 0x03e00008, 0xaf4201b8, 0x00a01821, 0x3c058000, 0x8f4201b8, 0x00451024,
1119 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002, 0xac860000, 0xac800004, 1875 0x1440fffd, 0x24020002, 0xac870000, 0xac800004, 0xa4830008, 0xa080000a,
1120 0xa4830008, 0xa080000a, 0x0a000748, 0xa082000b, 0x0000000d, 0x03e00008, 1876 0x0a00147e, 0xa082000b, 0x8f440144, 0x3c038000, 0x8f4201b8, 0x00431024,
1121 0x00000000, 0x03e00008, 0x00000000, 0x8f420100, 0x3042003e, 0x14400011, 1877 0x1440fffd, 0x24020002, 0x240340c9, 0xaf470180, 0xa342018b, 0x3c021000,
1122 0x24020001, 0xaf400048, 0x8f420100, 0x304207c0, 0x10400005, 0x00000000, 1878 0xa7430188, 0xaf4401a4, 0xaf4501a8, 0xaf4001ac, 0x03e00008, 0xaf4201b8,
1123 0xaf40004c, 0xaf400050, 0x03e00008, 0x24020001, 0xaf400054, 0xaf400040, 1879 0x0000000d, 0x03e00008, 0x00000000, 0x03e00008, 0x00000000, 0x8f420100,
1124 0x8f420100, 0x30423800, 0x54400001, 0xaf400044, 0x24020001, 0x03e00008, 1880 0x3042003e, 0x14400011, 0x24020001, 0xaf400048, 0x8f420100, 0x304207c0,
1125 0x00000000, 0x3c029000, 0x34420001, 0x00822025, 0xaf440020, 0x3c038000, 1881 0x10400005, 0x00000000, 0xaf40004c, 0xaf400050, 0x03e00008, 0x24020001,
1126 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x03e00008, 0x00000000, 1882 0xaf400054, 0xaf400040, 0x8f420100, 0x30423800, 0x54400001, 0xaf400044,
1127 0x3c028000, 0x34420001, 0x00822025, 0x03e00008, 0xaf440020, 0x8f430128, 1883 0x24020001, 0x03e00008, 0x00000000, 0x3c038000, 0x8f4201b8, 0x00431024,
1128 0x27420180, 0xac430000, 0x8f650040, 0x240340c1, 0xa4430008, 0x24030002, 1884 0x1440fffd, 0x24020002, 0x240340c9, 0xaf440180, 0xa342018b, 0x3c021000,
1129 0xa044000a, 0x24040008, 0xa043000b, 0x3c031000, 0xa4440010, 0xa0400012, 1885 0xa7430188, 0xaf4501a4, 0xaf4601a8, 0xaf4701ac, 0x03e00008, 0xaf4201b8,
1130 0xa0400013, 0xac400014, 0xac400024, 0xac400028, 0xac40002c, 0xac450018, 1886 0x3c029000, 0x34420001, 0x00822025, 0xaf440020, 0x3c038000, 0x8f420020,
1131 0x03e00008, 0xaf4301b8, 0x24020001, 0xacc40000, 0x03e00008, 0xa4e50000, 1887 0x00431024, 0x1440fffd, 0x00000000, 0x03e00008, 0x00000000, 0x3c028000,
1132 0x03e00008, 0x24020001, 0x24020001, 0xaf400044, 0x03e00008, 0xaf400050, 1888 0x34420001, 0x00822025, 0x03e00008, 0xaf440020, 0x308600ff, 0x27450180,
1133 0x00803021, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 1889 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128,
1134 0x00000000, 0x8f420128, 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 1890 0xaca20000, 0x8f640040, 0x24030008, 0x240240c1, 0xa4a20008, 0x24020002,
1135 0xaca30018, 0x90c4000a, 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 1891 0xa0a2000b, 0x3c021000, 0xa0a6000a, 0xa4a30010, 0xa0a00012, 0xa0a00013,
1136 0xa4a20010, 0x90c30012, 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 1892 0xaca00014, 0xaca00024, 0xaca00028, 0xaca0002c, 0xaca40018, 0x03e00008,
1137 0xaca30014, 0x8cc20024, 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc2002c, 1893 0xaf4201b8, 0x24020001, 0xacc40000, 0x03e00008, 0xa4e50000, 0x03e00008,
1138 0x3c031000, 0xaca2002c, 0x24020001, 0xaf4301b8, 0xaf400044, 0x03e00008, 1894 0x24020001, 0x24020001, 0xaf400044, 0x03e00008, 0xaf400050, 0x00803021,
1139 0xaf400050, 0x27bdffe8, 0xafbf0010, 0x0e000326, 0x00000000, 0x00002021, 1895 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000,
1140 0x0e00004c, 0xaf400180, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x8f460148, 1896 0x8f420128, 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 0xaca30018,
1141 0x27450180, 0x3c038000, 0x00061402, 0x304700ff, 0x8f4201b8, 0x00431024, 1897 0x90c4000a, 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 0xa4a20010,
1142 0x1440fffd, 0x00000000, 0x8f440140, 0x00061202, 0x304200ff, 0x00061c02, 1898 0x90c30012, 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 0xaca30014,
1143 0xaca20004, 0x24020002, 0xa4a30008, 0x30c300ff, 0xa0a2000b, 0xaca30024, 1899 0x8cc20024, 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc2002c, 0x3c031000,
1144 0x10e0000a, 0xaca40000, 0x28e20004, 0x14400005, 0x24020001, 0x24020005, 1900 0xaca2002c, 0x24020001, 0xaf4301b8, 0xaf400044, 0x03e00008, 0xaf400050,
1145 0x54e20005, 0xa0a0000a, 0x24020001, 0x0a000816, 0xa0a2000a, 0xa0a0000a, 1901 0x27bdffe8, 0xafbf0010, 0x0e001032, 0x00000000, 0x00002021, 0x0e000c99,
1146 0x3c021000, 0x03e00008, 0xaf4201b8, 0x03e00008, 0x00001021, 0x10c00007, 1902 0xaf400180, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x8f460148, 0x27450180,
1147 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000, 0x14c0fffb, 1903 0x3c038000, 0x00061402, 0x304700ff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1148 0x24840004, 0x03e00008, 0x00000000, 0x0a00082a, 0x00a01021, 0xac860000, 1904 0x00000000, 0x8f440140, 0x00061202, 0x304200ff, 0x00061c02, 0xaca20004,
1149 0x24840004, 0x00a01021, 0x1440fffc, 0x24a5ffff, 0x03e00008, 0x00000000, 1905 0x24020002, 0xa4a30008, 0x30c300ff, 0xa0a2000b, 0xaca30024, 0x10e0000a,
1150 0x00000000 }; 1906 0xaca40000, 0x28e20004, 0x14400005, 0x24020001, 0x24020005, 0x54e20005,
1907 0xa0a0000a, 0x24020001, 0x0a001571, 0xa0a2000a, 0xa0a0000a, 0x3c021000,
1908 0x03e00008, 0xaf4201b8, 0x03e00008, 0x00001021, 0x10c00007, 0x00000000,
1909 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000, 0x14c0fffb, 0x24840004,
1910 0x03e00008, 0x00000000, 0x0a001587, 0x00a01021, 0xac860000, 0x00000000,
1911 0x00000000, 0x24840004, 0x00a01021, 0x1440fffa, 0x24a5ffff, 0x03e00008,
1912 0x00000000, 0x00000000 };
1151 1913
1152static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x00000000 }; 1914static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 };
1153static u32 bnx2_RXP_b06FwRodata[(0x0/4) + 1] = { 0x00000000 }; 1915static u32 bnx2_RXP_b06FwRodata[(0x0/4) + 1] = { 0x0 };
1154static u32 bnx2_RXP_b06FwBss[(0x239c/4) + 1] = { 0x00000000 }; 1916static u32 bnx2_RXP_b06FwBss[(0x1394/4) + 1] = { 0x0 };
1155static u32 bnx2_RXP_b06FwSbss[(0x14/4) + 1] = { 0x00000000 }; 1917static u32 bnx2_RXP_b06FwSbss[(0x18/4) + 1] = { 0x0 };
1156 1918
1157static u32 bnx2_rv2p_proc1[] = { 1919static u32 bnx2_rv2p_proc1[] = {
1158 0x00000008, 0xac000001, 0x0000000c, 0x2f800001, 0x00000010, 0x213f0004, 1920 0x00000008, 0xac000001, 0x0000000c, 0x2f800001, 0x00000010, 0x213f0004,
@@ -1536,249 +2298,346 @@ static u32 bnx2_rv2p_proc2[] = {
1536 0x0000000c, 0x29520000, 0x00000018, 0x80000002, 0x0000000c, 0x29800000, 2298 0x0000000c, 0x29520000, 0x00000018, 0x80000002, 0x0000000c, 0x29800000,
1537 0x00000018, 0x00570000 }; 2299 0x00000018, 0x00570000 };
1538 2300
1539static int bnx2_TPAT_b06FwReleaseMajor = 0x0; 2301static int bnx2_TPAT_b06FwReleaseMajor = 0x1;
1540static int bnx2_TPAT_b06FwReleaseMinor = 0x0; 2302static int bnx2_TPAT_b06FwReleaseMinor = 0x0;
1541static int bnx2_TPAT_b06FwReleaseFix = 0x0; 2303static int bnx2_TPAT_b06FwReleaseFix = 0x0;
1542static u32 bnx2_TPAT_b06FwStartAddr = 0x08000858; 2304static u32 bnx2_TPAT_b06FwStartAddr = 0x08000860;
1543static u32 bnx2_TPAT_b06FwTextAddr = 0x08000800; 2305static u32 bnx2_TPAT_b06FwTextAddr = 0x08000800;
1544static int bnx2_TPAT_b06FwTextLen = 0x1314; 2306static int bnx2_TPAT_b06FwTextLen = 0x122c;
1545static u32 bnx2_TPAT_b06FwDataAddr = 0x08001b40; 2307static u32 bnx2_TPAT_b06FwDataAddr = 0x08001a60;
1546static int bnx2_TPAT_b06FwDataLen = 0x0; 2308static int bnx2_TPAT_b06FwDataLen = 0x0;
1547static u32 bnx2_TPAT_b06FwRodataAddr = 0x00000000; 2309static u32 bnx2_TPAT_b06FwRodataAddr = 0x00000000;
1548static int bnx2_TPAT_b06FwRodataLen = 0x0; 2310static int bnx2_TPAT_b06FwRodataLen = 0x0;
1549static u32 bnx2_TPAT_b06FwBssAddr = 0x08001b90; 2311static u32 bnx2_TPAT_b06FwBssAddr = 0x08001aa0;
1550static int bnx2_TPAT_b06FwBssLen = 0x80; 2312static int bnx2_TPAT_b06FwBssLen = 0x250;
1551static u32 bnx2_TPAT_b06FwSbssAddr = 0x08001b40; 2313static u32 bnx2_TPAT_b06FwSbssAddr = 0x08001a60;
1552static int bnx2_TPAT_b06FwSbssLen = 0x48; 2314static int bnx2_TPAT_b06FwSbssLen = 0x34;
1553 2315static u32 bnx2_TPAT_b06FwText[(0x122c/4) + 1] = {
1554static u32 bnx2_TPAT_b06FwText[(0x1314/4) + 1] = { 2316 0x0a000218, 0x00000000, 0x00000000, 0x0000000d, 0x74706174, 0x20322e35,
1555 0x0a000216, 0x00000000, 0x00000000, 0x0000000d, 0x74706174, 0x20302e36, 2317 0x2e313100, 0x02050b01, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1556 0x2e390000, 0x00060901, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2318 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1557 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2319 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1558 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000003, 2320 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800,
1559 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800, 0x24421b40, 0x3c030800, 2321 0x24421a60, 0x3c030800, 0x24631cf0, 0xac400000, 0x0043202b, 0x1480fffd,
1560 0x24631c10, 0xac400000, 0x0043202b, 0x1480fffd, 0x24420004, 0x3c1d0800, 2322 0x24420004, 0x3c1d0800, 0x37bd2ffc, 0x03a0f021, 0x3c100800, 0x26100860,
1561 0x37bd3ffc, 0x03a0f021, 0x3c100800, 0x26100858, 0x3c1c0800, 0x279c1b40, 2323 0x3c1c0800, 0x279c1a60, 0x0e000546, 0x00000000, 0x0000000d, 0x8f820010,
1562 0x0e00051f, 0x00000000, 0x0000000d, 0x8f820024, 0x27bdffe8, 0xafbf0014,
1563 0x10400004, 0xafb00010, 0x0000000d, 0x00000000, 0x2400015f, 0x8f82001c,
1564 0x8c450008, 0x24030800, 0xaf430178, 0x97430104, 0x3c020008, 0xaf420140, 2324 0x8c450008, 0x24030800, 0xaf430178, 0x97430104, 0x3c020008, 0xaf420140,
1565 0x8f820034, 0x30420001, 0x10400006, 0x3070ffff, 0x24020002, 0x2603fffe, 2325 0x8f820024, 0x30420001, 0x10400007, 0x3069ffff, 0x24020002, 0x2523fffe,
1566 0xa7420146, 0x0a000246, 0xa7430148, 0xa7400146, 0x8f850034, 0x30a20020, 2326 0xa7420146, 0xa7430148, 0x0a000242, 0x3c020800, 0xa7400146, 0x3c020800,
1567 0x0002102b, 0x00021023, 0x30460009, 0x30a30c00, 0x24020400, 0x14620002, 2327 0x8c43083c, 0x1460000e, 0x24020f00, 0x8f820024, 0x30430020, 0x0003182b,
1568 0x34c40001, 0x34c40005, 0xa744014a, 0x3c020800, 0x8c440820, 0x3c030048, 2328 0x00031823, 0x30650009, 0x30420c00, 0x24030400, 0x14430002, 0x34a40001,
1569 0x24020002, 0x00832025, 0x30a30006, 0x1062000d, 0x2c620003, 0x50400005, 2329 0x34a40005, 0xa744014a, 0x0a000264, 0x3c020800, 0x8f830014, 0x14620008,
1570 0x24020004, 0x10600012, 0x3c020001, 0x0a000271, 0x00000000, 0x10620007, 2330 0x00000000, 0x8f820024, 0x30420020, 0x0002102b, 0x00021023, 0x3042000d,
1571 0x24020006, 0x1462000f, 0x3c020111, 0x0a000269, 0x00821025, 0x0a000268, 2331 0x0a000262, 0x34420005, 0x8f820024, 0x30420020, 0x0002102b, 0x00021023,
1572 0x3c020101, 0x3c020011, 0x00821025, 0x24030001, 0xaf421000, 0xaf830030, 2332 0x30420009, 0x34420001, 0xa742014a, 0x3c020800, 0x8c430820, 0x8f840024,
1573 0x0a000271, 0x00000000, 0x00821025, 0xaf421000, 0xaf800030, 0x00000000, 2333 0x3c020048, 0x00621825, 0x30840006, 0x24020002, 0x1082000d, 0x2c820003,
1574 0x00000000, 0x00000000, 0x00000000, 0x8f830030, 0x1060003f, 0x3c048000, 2334 0x50400005, 0x24020004, 0x10800012, 0x3c020001, 0x0a000284, 0x00000000,
1575 0x8f421000, 0x00441024, 0x1040fffd, 0x00000000, 0x10600039, 0x00000000, 2335 0x10820007, 0x24020006, 0x1482000f, 0x3c020111, 0x0a00027c, 0x00621025,
1576 0x8f421000, 0x3c030020, 0x00431024, 0x10400034, 0x00000000, 0x97421014, 2336 0x0a00027b, 0x3c020101, 0x3c020011, 0x00621025, 0x24030001, 0xaf421000,
1577 0x14400031, 0x00000000, 0x97421008, 0x8f84001c, 0x24420006, 0x00024082, 2337 0xaf830020, 0x0a000284, 0x00000000, 0x00621025, 0xaf421000, 0xaf800020,
1578 0x00081880, 0x00643821, 0x8ce50000, 0x30430003, 0x30420001, 0x10400004, 2338 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8f830020, 0x1060003f,
1579 0x00000000, 0x0000000d, 0x0a0002b0, 0x00081080, 0x5460000f, 0x30a5ffff, 2339 0x3c048000, 0x8f421000, 0x00441024, 0x1040fffd, 0x00000000, 0x10600039,
1580 0x3c06ffff, 0x00a62824, 0x0005182b, 0x00a61026, 0x0002102b, 0x00621824, 2340 0x00000000, 0x8f421000, 0x3c030020, 0x00431024, 0x10400034, 0x00000000,
1581 0x10600004, 0x00000000, 0x0000000d, 0x00000000, 0x240001fc, 0x8ce20000, 2341 0x97421014, 0x14400031, 0x00000000, 0x97421008, 0x8f840010, 0x24420006,
1582 0x0a0002af, 0x00462825, 0x0005182b, 0x38a2ffff, 0x0002102b, 0x00621824, 2342 0x00024082, 0x00081880, 0x00643821, 0x8ce50000, 0x30430003, 0x30420001,
1583 0x10600004, 0x00000000, 0x0000000d, 0x00000000, 0x24000206, 0x8ce20000, 2343 0x10400004, 0x00000000, 0x0000000d, 0x0a0002c3, 0x00081080, 0x5460000f,
1584 0x3445ffff, 0x00081080, 0x00441021, 0x3c030800, 0xac450000, 0x8c620840, 2344 0x30a5ffff, 0x3c06ffff, 0x00a62824, 0x0005182b, 0x00a61026, 0x0002102b,
1585 0x24420001, 0xac620840, 0x8f820008, 0x10400003, 0x00000000, 0x0e000660, 2345 0x00621824, 0x10600004, 0x00000000, 0x0000000d, 0x00000000, 0x240001fb,
1586 0x00000000, 0x8f840028, 0x02002821, 0x24820008, 0x30421fff, 0x24434000, 2346 0x8ce20000, 0x0a0002c2, 0x00462825, 0x0005182b, 0x38a2ffff, 0x0002102b,
1587 0x0343d821, 0x30a30007, 0xaf840018, 0xaf820028, 0xaf420084, 0x10600002, 2347 0x00621824, 0x10600004, 0x00000000, 0x0000000d, 0x00000000, 0x24000205,
1588 0x24a20007, 0x3045fff8, 0x8f820044, 0x8f840004, 0x00451821, 0xaf82002c, 2348 0x8ce20000, 0x3445ffff, 0x00081080, 0x00441021, 0x3c030800, 0xac450000,
1589 0x0064102b, 0xaf830044, 0x14400002, 0x00641023, 0xaf820044, 0x8f840044, 2349 0x8c620830, 0x24420001, 0xac620830, 0x8f840018, 0x01202821, 0x24820008,
1590 0x34028000, 0x8fbf0014, 0x8fb00010, 0x00821021, 0x03421821, 0x3c021000, 2350 0x30421fff, 0x24434000, 0x0343d821, 0x30a30007, 0xaf84000c, 0xaf820018,
1591 0xaf83001c, 0xaf440080, 0xaf420178, 0x03e00008, 0x27bd0018, 0x8f820024, 2351 0xaf420084, 0x10600002, 0x24a20007, 0x3045fff8, 0x8f820030, 0x8f840000,
1592 0x27bdffe8, 0xafbf0014, 0x10400004, 0xafb00010, 0x0000000d, 0x00000000, 2352 0x00451821, 0xaf82001c, 0x0064102b, 0xaf830030, 0x14400002, 0x00641023,
1593 0x24000249, 0x8f85001c, 0x24020001, 0xaf820024, 0x8ca70008, 0xa3800023, 2353 0xaf820030, 0x8f840030, 0x34028000, 0x00821021, 0x03421821, 0x3c021000,
1594 0x8f620004, 0x3c100800, 0x26041b90, 0x00021402, 0xa3820010, 0x304600ff, 2354 0xaf830010, 0xaf440080, 0x03e00008, 0xaf420178, 0x8f830024, 0x27bdffe0,
1595 0x24c60005, 0x0e00064a, 0x00063082, 0x8f640004, 0x8f430108, 0x3c021000, 2355 0xafbf0018, 0xafb10014, 0x30620200, 0x14400004, 0xafb00010, 0x0000000d,
1596 0x00621824, 0xa7840020, 0x10600008, 0x00000000, 0x97420104, 0x93830023, 2356 0x00000000, 0x24000242, 0x00031a82, 0x30630003, 0x000310c0, 0x00431021,
1597 0x2442ffec, 0x34630002, 0xa3830023, 0x0a000304, 0x3045ffff, 0x97420104, 2357 0x00021080, 0x00431021, 0x00021080, 0x3c030800, 0x24631aa0, 0x00438821,
1598 0x2442fff0, 0x3045ffff, 0x8f620004, 0x3042ffff, 0x2c420013, 0x14400004, 2358 0x8e240000, 0x10800004, 0x00000000, 0x0000000d, 0x00000000, 0x2400024d,
1599 0x00000000, 0x93820023, 0x34420001, 0xa3820023, 0x93830023, 0x24020001, 2359 0x8f850010, 0x24020001, 0xae220000, 0x8ca70008, 0xa2200007, 0x8f620004,
1600 0x10620009, 0x28620002, 0x14400014, 0x24020002, 0x10620012, 0x24020003, 2360 0x26300014, 0x02002021, 0x00021402, 0xa2220004, 0x304600ff, 0x24c60005,
1601 0x1062000a, 0x00000000, 0x0a000325, 0x00000000, 0x8f82001c, 0x8c43000c, 2361 0x0e000673, 0x00063082, 0x8f620004, 0xa6220008, 0x8f430108, 0x3c021000,
1602 0x3c04ffff, 0x00641824, 0x00651825, 0x0a000325, 0xac43000c, 0x8f82001c, 2362 0x00621824, 0x10600008, 0x00000000, 0x97420104, 0x92230007, 0x2442ffec,
1603 0x8c430010, 0x3c04ffff, 0x00641824, 0x00651825, 0xac430010, 0x8f620004, 2363 0x3045ffff, 0x34630002, 0x0a000321, 0xa2230007, 0x97420104, 0x2442fff0,
1604 0x3042ffff, 0x24420002, 0x00021083, 0xa3820038, 0x304500ff, 0x8f82001c, 2364 0x3045ffff, 0x8f620004, 0x3042ffff, 0x2c420013, 0x54400005, 0x92230007,
1605 0x3c04ffff, 0x00052880, 0x00a22821, 0x8ca70000, 0x97820020, 0x97430104, 2365 0x92220007, 0x34420001, 0xa2220007, 0x92230007, 0x24020001, 0x10620009,
1606 0x00e42024, 0x24420002, 0x00621823, 0x00833825, 0xaca70000, 0x93840038, 2366 0x28620002, 0x14400014, 0x24020002, 0x10620012, 0x24020003, 0x1062000a,
1607 0x26061b90, 0x00041080, 0x00461021, 0x90430000, 0x3063000f, 0x00832021, 2367 0x00000000, 0x0a000342, 0x00000000, 0x8f820010, 0x8c43000c, 0x3c04ffff,
1608 0xa3840022, 0x308200ff, 0x3c04fff6, 0x24420003, 0x00021080, 0x00461021, 2368 0x00641824, 0x00651825, 0x0a000342, 0xac43000c, 0x8f820010, 0x8c430010,
1609 0x8c450000, 0x93830022, 0x8f82001c, 0x3484ffff, 0x00a43824, 0x00031880, 2369 0x3c04ffff, 0x00641824, 0x00651825, 0xac430010, 0x8f620004, 0x3042ffff,
1610 0x00621821, 0xaf850000, 0xac67000c, 0x93820022, 0x93830022, 0x8f84001c, 2370 0x24420002, 0x00021083, 0xa2220005, 0x304500ff, 0x8f820010, 0x3c04ffff,
1611 0x24420003, 0x00021080, 0x00461021, 0x24630004, 0x00031880, 0xac470000, 2371 0x00052880, 0x00a22821, 0x8ca70000, 0x96220008, 0x97430104, 0x00e42024,
1612 0x93820022, 0x00661821, 0x94670002, 0x00021080, 0x00441021, 0xac670000, 2372 0x24420002, 0x00621823, 0x00833825, 0xaca70000, 0x92240005, 0x00041080,
1613 0x24030010, 0xac470010, 0xa7430140, 0x24030002, 0xa7400142, 0xa7400144, 2373 0x02021021, 0x90430000, 0x3c05fff6, 0x34a5ffff, 0x3063000f, 0x00832021,
1614 0xa7430146, 0x97420104, 0x8f840034, 0x24030001, 0x2442fffe, 0x30840006, 2374 0xa2240006, 0x308200ff, 0x24420003, 0x00021080, 0x02021021, 0x8c460000,
1615 0xa7420148, 0x24020002, 0xa743014a, 0x1082000d, 0x2c820003, 0x10400005, 2375 0x308300ff, 0x8f820010, 0x3c04ff3f, 0x00031880, 0x00c53824, 0x00621821,
1616 0x24020004, 0x10800011, 0x3c020009, 0x0a000383, 0x00000000, 0x10820007, 2376 0xae26000c, 0xac67000c, 0x8e22000c, 0x92230006, 0x3484ffff, 0x00441024,
1617 0x24020006, 0x1482000d, 0x3c020119, 0x0a00037d, 0x24030001, 0x0a00037c, 2377 0x24630003, 0x00031880, 0x02031821, 0x00e42024, 0xae22000c, 0xac640000,
1618 0x3c020109, 0x3c020019, 0x24030001, 0xaf421000, 0xaf830030, 0x0a000383, 2378 0x92220006, 0x24420004, 0x00021080, 0x02021021, 0x94470002, 0xac470000,
1619 0x00000000, 0xaf421000, 0xaf800030, 0x00000000, 0x00000000, 0x00000000, 2379 0x92230006, 0x8f820010, 0x00031880, 0x00621821, 0x24020010, 0xac670010,
1620 0x00000000, 0x93820010, 0x24030008, 0x8f840030, 0x24420002, 0x30420007, 2380 0x24030002, 0xa7420140, 0xa7400142, 0xa7400144, 0xa7430146, 0x97420104,
1621 0x00621823, 0x30630007, 0xaf83000c, 0x10800005, 0x3c038000, 0x8f421000, 2381 0x24030001, 0x2442fffe, 0xa7420148, 0xa743014a, 0x8f820024, 0x24030002,
1622 0x00431024, 0x1040fffd, 0x00000000, 0x8f820028, 0xaf820018, 0x24420010, 2382 0x30440006, 0x1083000d, 0x2c820003, 0x10400005, 0x24020004, 0x10800011,
1623 0x30421fff, 0xaf820028, 0xaf420084, 0x97430104, 0x24424000, 0x0342d821, 2383 0x3c020009, 0x0a0003a5, 0x00000000, 0x10820007, 0x24020006, 0x1482000d,
1624 0x3063ffff, 0x30620007, 0x10400002, 0x24620007, 0x3043fff8, 0x8f820044, 2384 0x3c020119, 0x0a00039f, 0x24030001, 0x0a00039e, 0x3c020109, 0x3c020019,
1625 0x8f840004, 0x00431821, 0xaf82002c, 0x0064102b, 0xaf830044, 0x14400002, 2385 0x24030001, 0xaf421000, 0xaf830020, 0x0a0003a5, 0x00000000, 0xaf421000,
1626 0x00641023, 0xaf820044, 0x8f840044, 0x34028000, 0x8fbf0014, 0x8fb00010, 2386 0xaf800020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x92220004,
1627 0x00821021, 0x03421821, 0x3c021000, 0xaf83001c, 0xaf440080, 0xaf420178, 2387 0x24030008, 0x8f840020, 0x24420002, 0x30420007, 0x00621823, 0x30630007,
1628 0x03e00008, 0x27bd0018, 0x8f820024, 0x27bdffe8, 0xafbf0014, 0x14400004, 2388 0x10800006, 0xae230010, 0x3c038000, 0x8f421000, 0x00431024, 0x1040fffd,
1629 0xafb00010, 0x0000000d, 0x00000000, 0x240002db, 0x8f620004, 0x04410009, 2389 0x00000000, 0x8f820018, 0xaf82000c, 0x24420010, 0x30421fff, 0xaf820018,
1630 0x3c050800, 0x93820022, 0x8f830000, 0x24a41b90, 0xaf800024, 0x24420003, 2390 0xaf420084, 0x97430104, 0x24424000, 0x0342d821, 0x3063ffff, 0x30620007,
1631 0x00021080, 0x00441021, 0xac430000, 0x93820038, 0x24a51b90, 0x93860010, 2391 0x10400002, 0x24620007, 0x3043fff8, 0x8f820030, 0x8f840000, 0x00431821,
1632 0x3c040001, 0x27700008, 0x24420001, 0x00021080, 0x00451021, 0x8c430000, 2392 0xaf82001c, 0x0064102b, 0xaf830030, 0x14400002, 0x00641023, 0xaf820030,
1633 0x24c60005, 0x00063082, 0x00641821, 0x02002021, 0x0e00064a, 0xac430000, 2393 0x8f840030, 0x34028000, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x00821021,
1634 0x93840022, 0x3c057fff, 0x8f620004, 0x00042080, 0x00902021, 0x8c830004, 2394 0x03421821, 0x3c021000, 0xaf830010, 0xaf440080, 0xaf420178, 0x03e00008,
1635 0x34a5ffff, 0x00451024, 0x00621821, 0xac830004, 0x93850038, 0x3c07ffff, 2395 0x27bd0020, 0x8f830024, 0x27bdffe0, 0xafbf0018, 0xafb10014, 0x30620200,
1636 0x93840010, 0x00052880, 0x00b02821, 0x8ca30000, 0x97420104, 0x97860020, 2396 0x14400004, 0xafb00010, 0x0000000d, 0x00000000, 0x240002e4, 0x00031a82,
1637 0x00671824, 0x00441021, 0x00461023, 0x3042ffff, 0x00621825, 0xaca30000, 2397 0x30630003, 0x000310c0, 0x00431021, 0x00021080, 0x00431021, 0x00021080,
1638 0x93830023, 0x24020001, 0x10620009, 0x28620002, 0x1440001a, 0x24020002, 2398 0x3c030800, 0x24631aa0, 0x00438021, 0x8e040000, 0x14800004, 0x00000000,
1639 0x10620018, 0x24020003, 0x1062000d, 0x00000000, 0x0a000411, 0x00000000, 2399 0x0000000d, 0x00000000, 0x240002e9, 0x8f620004, 0x04410008, 0x26050014,
1640 0x93820010, 0x97430104, 0x8e04000c, 0x00621821, 0x2463fff2, 0x3063ffff, 2400 0x92020006, 0x8e03000c, 0x24420003, 0x00021080, 0x00a21021, 0xac430000,
1641 0x00872024, 0x00832025, 0x0a000411, 0xae04000c, 0x93820010, 0x97430104, 2401 0xae000000, 0x92020005, 0x24420001, 0x00021080, 0x00a21021, 0x8c430000,
1642 0x8e040010, 0x00621821, 0x2463ffee, 0x3063ffff, 0x00872024, 0x00832025, 2402 0x3c040001, 0x00641821, 0xac430000, 0x92060004, 0x27710008, 0x02202021,
1643 0xae040010, 0x9783000e, 0x8f840034, 0x2402000a, 0xa7420140, 0xa7430142, 2403 0x24c60005, 0x0e000673, 0x00063082, 0x92040006, 0x3c057fff, 0x8f620004,
1644 0x93820010, 0xa7420144, 0xa7400146, 0x97430104, 0x30840006, 0x24020001, 2404 0x00042080, 0x00912021, 0x8c830004, 0x34a5ffff, 0x00451024, 0x00621821,
1645 0xa7430148, 0xa742014a, 0x24020002, 0x1082000d, 0x2c820003, 0x10400005, 2405 0xac830004, 0x92050005, 0x3c07ffff, 0x92040004, 0x00052880, 0x00b12821,
1646 0x24020004, 0x10800011, 0x3c020041, 0x0a000437, 0x00000000, 0x10820007, 2406 0x8ca30000, 0x97420104, 0x96060008, 0x00671824, 0x00441021, 0x00461023,
1647 0x24020006, 0x1482000d, 0x3c020151, 0x0a000431, 0x24030001, 0x0a000430, 2407 0x3042ffff, 0x00621825, 0xaca30000, 0x92030007, 0x24020001, 0x1062000a,
1648 0x3c020141, 0x3c020051, 0x24030001, 0xaf421000, 0xaf830030, 0x0a000437, 2408 0x28620002, 0x1440001d, 0x2402000a, 0x24020002, 0x10620019, 0x24020003,
1649 0x00000000, 0xaf421000, 0xaf800030, 0x00000000, 0x00000000, 0x00000000, 2409 0x1062000e, 0x2402000a, 0x0a000447, 0x00000000, 0x92020004, 0x97430104,
1650 0x00000000, 0x8f820030, 0x93840010, 0x8f850028, 0x10400005, 0x3c038000, 2410 0x8e24000c, 0x00621821, 0x2463fff2, 0x3063ffff, 0x00872024, 0x00832025,
1651 0x8f421000, 0x00431024, 0x1040fffd, 0x00000000, 0x2483000a, 0x30620007, 2411 0xae24000c, 0x0a000447, 0x2402000a, 0x92020004, 0x97430104, 0x8e240010,
1652 0x10400002, 0x24620007, 0x304303f8, 0x00a31021, 0x30421fff, 0xaf850018, 2412 0x00621821, 0x2463ffee, 0x3063ffff, 0x00872024, 0x00832025, 0xae240010,
1653 0xaf820028, 0xaf420084, 0x97430104, 0x24424000, 0x0342d821, 0x3063ffff, 2413 0x2402000a, 0xa7420140, 0x96030012, 0x8f840024, 0xa7430142, 0x92020004,
1654 0x30620007, 0x10400002, 0x24620007, 0x3043fff8, 0x8f820044, 0x8f840004, 2414 0xa7420144, 0xa7400146, 0x97430104, 0x30840006, 0x24020001, 0xa7430148,
1655 0x00431821, 0xaf82002c, 0x0064102b, 0xaf830044, 0x14400002, 0x00641023, 2415 0xa742014a, 0x24020002, 0x1082000d, 0x2c820003, 0x10400005, 0x24020004,
1656 0xaf820044, 0x8f840044, 0x34028000, 0x8fbf0014, 0x8fb00010, 0x00821021, 2416 0x10800011, 0x3c020041, 0x0a00046c, 0x00000000, 0x10820007, 0x24020006,
1657 0x03421821, 0x3c021000, 0xaf83001c, 0xaf440080, 0xaf420178, 0x03e00008, 2417 0x1482000d, 0x3c020151, 0x0a000466, 0x24030001, 0x0a000465, 0x3c020141,
1658 0x27bd0018, 0x3c026000, 0x8c444448, 0x3c030800, 0xac64082c, 0x8f620000, 2418 0x3c020051, 0x24030001, 0xaf421000, 0xaf830020, 0x0a00046c, 0x00000000,
1659 0x97430104, 0x3c048000, 0x3046ffff, 0x3067ffff, 0x8f420178, 0x00441024, 2419 0xaf421000, 0xaf800020, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1660 0x1440fffd, 0x2402000a, 0x30c30007, 0xa7420140, 0x24020008, 0x00431023, 2420 0x8f820020, 0x8f840018, 0x10400006, 0x92030004, 0x3c058000, 0x8f421000,
1661 0x30420007, 0x24c3fffe, 0xa7420142, 0xa7430144, 0xa7400146, 0xa7470148, 2421 0x00451024, 0x1040fffd, 0x00000000, 0x2463000a, 0x30620007, 0x10400002,
1662 0x8f420108, 0x3c036000, 0x8f850034, 0x30420020, 0x0002102b, 0x00021023, 2422 0x24620007, 0x304303f8, 0x00831021, 0x30421fff, 0xaf84000c, 0xaf820018,
1663 0x30420009, 0x34420001, 0xa742014a, 0x8c644448, 0x3c020800, 0x30a50006, 2423 0xaf420084, 0x97430104, 0x24424000, 0x0342d821, 0x3063ffff, 0x30620007,
1664 0xac440830, 0x24020002, 0x10a2000d, 0x2ca20003, 0x10400005, 0x24020004, 2424 0x10400002, 0x24620007, 0x3043fff8, 0x8f820030, 0x8f840000, 0x00431821,
1665 0x10a00011, 0x3c020041, 0x0a0004a8, 0x00000000, 0x10a20007, 0x24020006, 2425 0xaf82001c, 0x0064102b, 0xaf830030, 0x14400002, 0x00641023, 0xaf820030,
1666 0x14a2000d, 0x3c020151, 0x0a0004a2, 0x24030001, 0x0a0004a1, 0x3c020141, 2426 0x8f840030, 0x34028000, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x00821021,
1667 0x3c020051, 0x24030001, 0xaf421000, 0xaf830030, 0x0a0004a8, 0x00000000, 2427 0x03421821, 0x3c021000, 0xaf830010, 0xaf440080, 0xaf420178, 0x03e00008,
1668 0xaf421000, 0xaf800030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2428 0x27bd0020, 0x8f620000, 0x97430104, 0x3c048000, 0x3045ffff, 0x3066ffff,
1669 0x8f820030, 0x24c30008, 0x10400006, 0x30e6ffff, 0x3c048000, 0x8f421000, 2429 0x8f420178, 0x00441024, 0x1440fffd, 0x2402000a, 0x30a30007, 0xa7420140,
1670 0x00441024, 0x1040fffd, 0x00000000, 0x3c026000, 0x8c444448, 0x3065ffff, 2430 0x24020008, 0x00431023, 0x30420007, 0x24a3fffe, 0xa7420142, 0xa7430144,
1671 0x3c020800, 0x30a30007, 0x10600003, 0xac440834, 0x24a20007, 0x3045fff8, 2431 0xa7400146, 0xa7460148, 0x8f420108, 0x8f830024, 0x30420020, 0x0002102b,
1672 0x8f840028, 0x00851021, 0x30421fff, 0x24434000, 0x0343d821, 0x30c30007, 2432 0x00021023, 0x30420009, 0x34420001, 0x30630006, 0xa742014a, 0x24020002,
1673 0xaf840018, 0xaf820028, 0xaf420084, 0x10600002, 0x24c20007, 0x3046fff8, 2433 0x1062000d, 0x2c620003, 0x10400005, 0x24020004, 0x10600011, 0x3c020041,
1674 0x8f820044, 0x8f840004, 0x00461821, 0xaf82002c, 0x0064102b, 0xaf830044, 2434 0x0a0004d6, 0x00000000, 0x10620007, 0x24020006, 0x1462000d, 0x3c020151,
1675 0x14400002, 0x00641023, 0xaf820044, 0x8f840044, 0x34028000, 0x3c030800, 2435 0x0a0004d0, 0x24030001, 0x0a0004cf, 0x3c020141, 0x3c020051, 0x24030001,
1676 0x8c650844, 0x00821021, 0x03421821, 0xaf83001c, 0xaf440080, 0x10a00006, 2436 0xaf421000, 0xaf830020, 0x0a0004d6, 0x00000000, 0xaf421000, 0xaf800020,
1677 0x2402000e, 0x93830043, 0x14620004, 0x3c021000, 0x2402043f, 0xa7420148, 2437 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8f820020, 0x24a30008,
1678 0x3c021000, 0x3c036000, 0xaf420178, 0x8c644448, 0x3c020800, 0x03e00008, 2438 0x8f850018, 0x10400006, 0x30c6ffff, 0x3c048000, 0x8f421000, 0x00441024,
1679 0xac440838, 0x8f820034, 0x30424000, 0x10400005, 0x24020800, 0x0000000d, 2439 0x1040fffd, 0x00000000, 0x3063ffff, 0x30620007, 0x10400002, 0x24620007,
1680 0x00000000, 0x24000405, 0x24020800, 0xaf420178, 0x97440104, 0x3c030008, 2440 0x3043fff8, 0x00a31021, 0x30421fff, 0x24434000, 0x0343d821, 0x00c02021,
1681 0xaf430140, 0x8f820034, 0x30420001, 0x10400006, 0x3085ffff, 0x24020002, 2441 0x30830007, 0xaf85000c, 0xaf820018, 0xaf420084, 0x10600002, 0x24820007,
1682 0x24a3fffe, 0xa7420146, 0x0a0004ff, 0xa7430148, 0xa7400146, 0x8f840028, 2442 0x3044fff8, 0x8f820030, 0x8f850000, 0x00441821, 0xaf82001c, 0x0065102b,
1683 0x2402000d, 0xa742014a, 0x24830008, 0x30631fff, 0x24624000, 0x0342d821, 2443 0xaf830030, 0x14400002, 0x00651023, 0xaf820030, 0x8f840030, 0x34028000,
1684 0x30a20007, 0xaf840018, 0xaf830028, 0xaf430084, 0x10400002, 0x24a20007, 2444 0x3c030800, 0x8c650834, 0x00821021, 0x03421821, 0xaf830010, 0xaf440080,
1685 0x3045fff8, 0x8f820044, 0x8f840004, 0x00451821, 0xaf82002c, 0x0064102b, 2445 0x10a00006, 0x2402000e, 0x9383002f, 0x14620004, 0x3c021000, 0x2402043f,
1686 0xaf830044, 0x14400002, 0x00641023, 0xaf820044, 0x8f840044, 0x34028000, 2446 0xa7420148, 0x3c021000, 0x03e00008, 0xaf420178, 0x8f820024, 0x30424000,
1687 0x00821021, 0x03421821, 0x3c021000, 0xaf83001c, 0xaf440080, 0x03e00008, 2447 0x10400005, 0x24020800, 0x0000000d, 0x00000000, 0x2400040e, 0x24020800,
1688 0xaf420178, 0x27bdffe8, 0x3c046008, 0xafbf0014, 0xafb00010, 0x8c825000, 2448 0xaf420178, 0x97440104, 0x3c030008, 0xaf430140, 0x8f820024, 0x30420001,
1689 0x3c1a8000, 0x2403ff7f, 0x375b4000, 0x00431024, 0x3442380c, 0xac825000, 2449 0x10400006, 0x3085ffff, 0x24020002, 0x24a3fffe, 0xa7420146, 0x0a000526,
1690 0x8f430008, 0x3c100800, 0x37428000, 0x34630001, 0xaf430008, 0xaf82001c, 2450 0xa7430148, 0xa7400146, 0x8f840018, 0x2402000d, 0xa742014a, 0x24830008,
1691 0x3c02601c, 0xaf800028, 0xaf400080, 0xaf400084, 0x8c450008, 0x3c036000, 2451 0x30631fff, 0x24624000, 0x0342d821, 0x30a20007, 0xaf84000c, 0xaf830018,
1692 0x8c620808, 0x3c040800, 0x3c030080, 0xac830820, 0x3042fff0, 0x38420010, 2452 0xaf430084, 0x10400002, 0x24a20007, 0x3045fff8, 0x8f820030, 0x8f840000,
1693 0x2c420001, 0xaf850004, 0xaf820008, 0x0e00062f, 0x00000000, 0x8f420000, 2453 0x00451821, 0xaf82001c, 0x0064102b, 0xaf830030, 0x14400002, 0x00641023,
1694 0x30420001, 0x1040fffb, 0x00000000, 0x8f440108, 0x30822000, 0xaf840034, 2454 0xaf820030, 0x8f840030, 0x34028000, 0x00821021, 0x03421821, 0x3c021000,
1695 0x10400004, 0x8e02083c, 0x24420001, 0x0a00059d, 0xae02083c, 0x30820200, 2455 0xaf830010, 0xaf440080, 0x03e00008, 0xaf420178, 0x27bdffe8, 0x3c046008,
1696 0x10400027, 0x00000000, 0x97420104, 0x1040001c, 0x30824000, 0x14400005, 2456 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f, 0x375b4000,
1697 0x00000000, 0x0e00022d, 0x00000000, 0x0a000592, 0x00000000, 0x8f620008, 2457 0x00431024, 0x3442380c, 0xac825000, 0x8f430008, 0x3c100800, 0x37428000,
1698 0x8f630000, 0x24020030, 0x00031e02, 0x306300f0, 0x10620007, 0x28620031, 2458 0x34630001, 0xaf430008, 0xaf820010, 0x3c02601c, 0xaf800018, 0xaf400080,
1699 0x14400031, 0x24020040, 0x10620007, 0x00000000, 0x0a000592, 0x00000000, 2459 0xaf400084, 0x8c450008, 0x3c036000, 0x8c620808, 0x3c040800, 0x3c030080,
1700 0x0e0002dd, 0x00000000, 0x0a000592, 0x00000000, 0x0e0003b8, 0x00000000, 2460 0xac830820, 0x3042fff0, 0x38420010, 0x2c420001, 0xaf850000, 0xaf820004,
1701 0x0a000592, 0x00000000, 0x30820040, 0x1440002d, 0x00000000, 0x0000000d, 2461 0x0e000658, 0x00000000, 0x8f420000, 0x30420001, 0x1040fffb, 0x00000000,
1702 0x00000000, 0x240004a6, 0x0a00059d, 0x00000000, 0x8f430100, 0x24020d00, 2462 0x8f430108, 0x8f440100, 0x30622000, 0xaf830024, 0xaf840014, 0x10400004,
1703 0x1462000f, 0x30820006, 0x97420104, 0x10400005, 0x30820040, 0x0e0004e9, 2463 0x8e02082c, 0x24420001, 0x0a0005c6, 0xae02082c, 0x30620200, 0x14400003,
1704 0x00000000, 0x0a000592, 0x00000000, 0x1440001b, 0x00000000, 0x0000000d, 2464 0x24020f00, 0x14820027, 0x24020d00, 0x97420104, 0x1040001c, 0x30624000,
1705 0x00000000, 0x240004b8, 0x0a00059d, 0x00000000, 0x1040000e, 0x30821000, 2465 0x14400005, 0x00000000, 0x0e00022f, 0x00000000, 0x0a0005bb, 0x00000000,
1706 0x10400005, 0x00000000, 0x0e00065d, 0x00000000, 0x0a000592, 0x00000000, 2466 0x8f620008, 0x8f630000, 0x24020030, 0x00031e02, 0x306300f0, 0x10620007,
1707 0x0e00046b, 0x00000000, 0x8f820040, 0x24420001, 0xaf820040, 0x0a00059d, 2467 0x28620031, 0x1440002f, 0x24020040, 0x10620007, 0x00000000, 0x0a0005bb,
1708 0x00000000, 0x30820040, 0x14400004, 0x00000000, 0x0000000d, 0x00000000, 2468 0x00000000, 0x0e0002e8, 0x00000000, 0x0a0005bb, 0x00000000, 0x0e0003db,
1709 0x240004cf, 0x8f420138, 0x3c034000, 0x00431025, 0xaf420138, 0x0a00053f, 2469 0x00000000, 0x0a0005bb, 0x00000000, 0x30620040, 0x1440002b, 0x00000000,
1710 0x00000000, 0x3c046008, 0x8c835000, 0x3c1a8000, 0x2402ff7f, 0x375b4000, 2470 0x0000000d, 0x00000000, 0x240004b2, 0x0a0005c6, 0x00000000, 0x1482000f,
1711 0x00621824, 0x3463380c, 0xac835000, 0x8f420008, 0x3c056000, 0x3c03601c, 2471 0x30620006, 0x97420104, 0x10400005, 0x30620040, 0x0e000510, 0x00000000,
1712 0x34420001, 0xaf420008, 0x37428000, 0xaf800028, 0xaf82001c, 0xaf400080, 2472 0x0a0005bb, 0x00000000, 0x1440001b, 0x00000000, 0x0000000d, 0x00000000,
1713 0xaf400084, 0x8c660008, 0x8ca20808, 0x3c040800, 0x3c030080, 0xac830820, 2473 0x240004c4, 0x0a0005c6, 0x00000000, 0x1040000e, 0x30621000, 0x10400005,
1714 0x3042fff0, 0x38420010, 0x2c420001, 0xaf860004, 0xaf820008, 0x03e00008, 2474 0x00000000, 0x0e000688, 0x00000000, 0x0a0005bb, 0x00000000, 0x0e0004a1,
1715 0x00000000, 0x3084ffff, 0x30820007, 0x10400002, 0x24820007, 0x3044fff8, 2475 0x00000000, 0x8f82002c, 0x24420001, 0xaf82002c, 0x0a0005c6, 0x00000000,
1716 0x8f820028, 0x00441821, 0x30631fff, 0x24644000, 0x0344d821, 0xaf820018, 2476 0x30620040, 0x14400004, 0x00000000, 0x0000000d, 0x00000000, 0x240004db,
1717 0xaf830028, 0x03e00008, 0xaf430084, 0x3084ffff, 0x30820007, 0x10400002, 2477 0x8f420138, 0x3c034000, 0x00431025, 0xaf420138, 0x0a000566, 0x00000000,
1718 0x24820007, 0x3044fff8, 0x8f820044, 0x8f830004, 0x00442021, 0xaf82002c, 2478 0x3c046008, 0x8c835000, 0x3c1a8000, 0x2402ff7f, 0x375b4000, 0x00621824,
1719 0x0083102b, 0xaf840044, 0x14400002, 0x00831023, 0xaf820044, 0x8f820044, 2479 0x3463380c, 0xac835000, 0x8f420008, 0x3c056000, 0x3c03601c, 0x34420001,
1720 0x34038000, 0x00431821, 0x03432021, 0xaf84001c, 0x03e00008, 0xaf420080, 2480 0xaf420008, 0x37428000, 0xaf800018, 0xaf820010, 0xaf400080, 0xaf400084,
1721 0x8f830034, 0x24020002, 0x30630006, 0x1062000d, 0x2c620003, 0x50400005, 2481 0x8c660008, 0x8ca20808, 0x3c040800, 0x3c030080, 0xac830820, 0x3042fff0,
1722 0x24020004, 0x10600012, 0x3c020001, 0x0a000601, 0x00000000, 0x10620007, 2482 0x38420010, 0x2c420001, 0xaf860000, 0xaf820004, 0x03e00008, 0x00000000,
1723 0x24020006, 0x1462000f, 0x3c020111, 0x0a0005f9, 0x00821025, 0x0a0005f8, 2483 0x3084ffff, 0x30820007, 0x10400002, 0x24820007, 0x3044fff8, 0x8f820018,
1724 0x3c020101, 0x3c020011, 0x00821025, 0x24030001, 0xaf421000, 0xaf830030, 2484 0x00441821, 0x30631fff, 0x24644000, 0x0344d821, 0xaf82000c, 0xaf830018,
1725 0x0a000601, 0x00000000, 0x00821025, 0xaf421000, 0xaf800030, 0x00000000, 2485 0x03e00008, 0xaf430084, 0x3084ffff, 0x30820007, 0x10400002, 0x24820007,
1726 0x00000000, 0x00000000, 0x03e00008, 0x00000000, 0x8f820030, 0x10400005, 2486 0x3044fff8, 0x8f820030, 0x8f830000, 0x00442021, 0xaf82001c, 0x0083102b,
1727 0x3c038000, 0x8f421000, 0x00431024, 0x1040fffd, 0x00000000, 0x03e00008, 2487 0xaf840030, 0x14400002, 0x00831023, 0xaf820030, 0x8f820030, 0x34038000,
1728 0x00000000, 0x8f820034, 0x27bdffe8, 0x30424000, 0x14400005, 0xafbf0010, 2488 0x00431821, 0x03432021, 0xaf840010, 0x03e00008, 0xaf420080, 0x8f830024,
1729 0x0e00022d, 0x00000000, 0x0a00062d, 0x8fbf0010, 0x8f620008, 0x8f630000, 2489 0x24020002, 0x30630006, 0x1062000d, 0x2c620003, 0x50400005, 0x24020004,
1730 0x24020030, 0x00031e02, 0x306300f0, 0x10620008, 0x28620031, 0x1440000d, 2490 0x10600012, 0x3c020001, 0x0a00062a, 0x00000000, 0x10620007, 0x24020006,
1731 0x8fbf0010, 0x24020040, 0x10620007, 0x00000000, 0x0a00062d, 0x00000000, 2491 0x1462000f, 0x3c020111, 0x0a000622, 0x00821025, 0x0a000621, 0x3c020101,
1732 0x0e0002dd, 0x00000000, 0x0a00062d, 0x8fbf0010, 0x0e0003b8, 0x00000000, 2492 0x3c020011, 0x00821025, 0x24030001, 0xaf421000, 0xaf830020, 0x0a00062a,
1733 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x8f84003c, 0x1080000f, 0x3c026000, 2493 0x00000000, 0x00821025, 0xaf421000, 0xaf800020, 0x00000000, 0x00000000,
1734 0x8c430c3c, 0x30630fff, 0xaf830014, 0x14600011, 0x3082000f, 0x10400005, 2494 0x00000000, 0x03e00008, 0x00000000, 0x8f820020, 0x10400005, 0x3c038000,
1735 0x308200f0, 0x10400003, 0x30820f00, 0x14400006, 0x00000000, 0x0000000d, 2495 0x8f421000, 0x00431024, 0x1040fffd, 0x00000000, 0x03e00008, 0x00000000,
1736 0x00000000, 0x2400050e, 0x03e00008, 0x00000000, 0x0000000d, 0x00000000, 2496 0x8f820024, 0x27bdffe8, 0x30424000, 0x14400005, 0xafbf0010, 0x0e00022f,
1737 0x24000513, 0x03e00008, 0x00000000, 0xaf83003c, 0x03e00008, 0x00000000, 2497 0x00000000, 0x0a000656, 0x8fbf0010, 0x8f620008, 0x8f630000, 0x24020030,
1738 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000, 2498 0x00031e02, 0x306300f0, 0x10620008, 0x28620031, 0x1440000d, 0x8fbf0010,
1739 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a000659, 0x00a01021, 2499 0x24020040, 0x10620007, 0x00000000, 0x0a000656, 0x00000000, 0x0e0002e8,
1740 0xac860000, 0x24840004, 0x00a01021, 0x1440fffc, 0x24a5ffff, 0x03e00008, 2500 0x00000000, 0x0a000656, 0x8fbf0010, 0x0e0003db, 0x00000000, 0x8fbf0010,
1741 0x00000000, 0x0000000d, 0x03e00008, 0x00000000, 0x3c040800, 0x8c82084c, 2501 0x03e00008, 0x27bd0018, 0x8f840028, 0x1080000f, 0x3c026000, 0x8c430c3c,
1742 0x54400007, 0xac80084c, 0x8f820034, 0x24030400, 0x30420c00, 0x1443005b, 2502 0x30630fff, 0xaf830008, 0x14600011, 0x3082000f, 0x10400005, 0x308200f0,
1743 0x00000000, 0xac80084c, 0x0000000d, 0x00000000, 0x2400003c, 0x3c026000, 2503 0x10400003, 0x30820f00, 0x14400006, 0x00000000, 0x0000000d, 0x00000000,
1744 0x8c444448, 0x3c030800, 0xac640850, 0x24000043, 0x97420104, 0x3045ffff, 2504 0x2400051a, 0x03e00008, 0x00000000, 0x0000000d, 0x00000000, 0x2400051f,
1745 0x000530c2, 0x24a2007f, 0x000239c2, 0x2400004e, 0x3c046020, 0x24030020, 2505 0x03e00008, 0x00000000, 0xaf830028, 0x03e00008, 0x00000000, 0x10c00007,
1746 0xac830000, 0x8c820000, 0x30420020, 0x10400005, 0x3c036020, 0x8c620000, 2506 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000, 0x14c0fffb,
1747 0x30420020, 0x1440fffd, 0x00000000, 0x3c026020, 0x8c430010, 0x24040001, 2507 0x24840004, 0x03e00008, 0x00000000, 0x0a000684, 0x00a01021, 0xac860000,
1748 0x0087102b, 0x30ea007f, 0x24abfffe, 0x10400010, 0x00034240, 0x3c056020, 2508 0x00000000, 0x00000000, 0x24840004, 0x00a01021, 0x1440fffa, 0x24a5ffff,
1749 0x24090020, 0xaca90000, 0x8ca20000, 0x30420020, 0x10400006, 0x24840001, 2509 0x03e00008, 0x00000000, 0x0000000d, 0x03e00008, 0x00000000, 0x00000000};
1750 0x3c036020, 0x8c620000, 0x30420020, 0x1440fffd, 0x00000000, 0x0087102b,
1751 0x1440fff4, 0x00000000, 0x8f85001c, 0x3c026020, 0x8c430010, 0x3c046020,
1752 0x34848000, 0x006a1825, 0x01034025, 0x2400006b, 0x10c0000b, 0x00000000,
1753 0x8ca30000, 0x24a50004, 0x8ca20000, 0x24a50004, 0x24c6ffff, 0xac820000,
1754 0x24840004, 0xac830000, 0x14c0fff7, 0x24840004, 0x24000077, 0x3c020007,
1755 0x34427700, 0x3c036000, 0xac6223c8, 0xac6b23cc, 0xac6823e4, 0x24000086,
1756 0x3c046000, 0x3c038000, 0x8c8223f8, 0x00431024, 0x1440fffd, 0x3c021000,
1757 0x3c056000, 0x24030019, 0xaca223f8, 0xa743014a, 0x8ca44448, 0x3c020800,
1758 0xac440854, 0x03e00008, 0x00000000, 0x00000000 };
1759 2510
1760static u32 bnx2_TPAT_b06FwData[(0x0/4) + 1] = { 0x00000000 }; 2511static u32 bnx2_TPAT_b06FwData[(0x0/4) + 1] = { 0x0 };
1761static u32 bnx2_TPAT_b06FwRodata[(0x0/4) + 1] = { 0x00000000 }; 2512static u32 bnx2_TPAT_b06FwRodata[(0x0/4) + 1] = { 0x0 };
1762static u32 bnx2_TPAT_b06FwBss[(0x80/4) + 1] = { 0x00000000 }; 2513static u32 bnx2_TPAT_b06FwBss[(0x250/4) + 1] = { 0x0 };
1763static u32 bnx2_TPAT_b06FwSbss[(0x48/4) + 1] = { 0x00000000 }; 2514static u32 bnx2_TPAT_b06FwSbss[(0x34/4) + 1] = { 0x0 };
1764 2515
1765static int bnx2_TXP_b06FwReleaseMajor = 0x0; 2516static int bnx2_TXP_b06FwReleaseMajor = 0x1;
1766static int bnx2_TXP_b06FwReleaseMinor = 0x0; 2517static int bnx2_TXP_b06FwReleaseMinor = 0x0;
1767static int bnx2_TXP_b06FwReleaseFix = 0x0; 2518static int bnx2_TXP_b06FwReleaseFix = 0x0;
1768static u32 bnx2_TXP_b06FwStartAddr = 0x08002090; 2519static u32 bnx2_TXP_b06FwStartAddr = 0x080034b0;
1769static u32 bnx2_TXP_b06FwTextAddr = 0x08000000; 2520static u32 bnx2_TXP_b06FwTextAddr = 0x08000000;
1770static int bnx2_TXP_b06FwTextLen = 0x3ffc; 2521static int bnx2_TXP_b06FwTextLen = 0x5748;
1771static u32 bnx2_TXP_b06FwDataAddr = 0x08004020; 2522static u32 bnx2_TXP_b06FwDataAddr = 0x08005760;
1772static int bnx2_TXP_b06FwDataLen = 0x0; 2523static int bnx2_TXP_b06FwDataLen = 0x0;
1773static u32 bnx2_TXP_b06FwRodataAddr = 0x00000000; 2524static u32 bnx2_TXP_b06FwRodataAddr = 0x00000000;
1774static int bnx2_TXP_b06FwRodataLen = 0x0; 2525static int bnx2_TXP_b06FwRodataLen = 0x0;
1775static u32 bnx2_TXP_b06FwBssAddr = 0x08004060; 2526static u32 bnx2_TXP_b06FwBssAddr = 0x080057a0;
1776static int bnx2_TXP_b06FwBssLen = 0x194; 2527static int bnx2_TXP_b06FwBssLen = 0x1c4;
1777static u32 bnx2_TXP_b06FwSbssAddr = 0x08004020; 2528static u32 bnx2_TXP_b06FwSbssAddr = 0x08005760;
1778static int bnx2_TXP_b06FwSbssLen = 0x34; 2529static int bnx2_TXP_b06FwSbssLen = 0x38;
1779static u32 bnx2_TXP_b06FwText[(0x3ffc/4) + 1] = { 2530static u32 bnx2_TXP_b06FwText[(0x5748/4) + 1] = {
1780 0x0a000824, 0x00000000, 0x00000000, 0x0000000d, 0x74787020, 0x302e362e, 2531 0x0a000d2c, 0x00000000, 0x00000000, 0x0000000d, 0x74787020, 0x322e352e,
1781 0x39000000, 0x00060900, 0x0000000a, 0x000003e8, 0x0000ea60, 0x00000000, 2532 0x38000000, 0x02050800, 0x0000000a, 0x000003e8, 0x0000ea60, 0x00000000,
2533 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2534 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2535 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2536 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2537 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2538 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2539 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2540 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2541 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2542 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2543 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2544 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2545 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2546 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2547 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2548 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2549 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2550 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2551 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2552 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2553 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2554 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2555 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2556 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2557 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2558 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2559 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2560 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2561 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2562 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2563 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2564 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2565 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2566 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2567 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2568 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2569 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2570 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2571 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2572 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2573 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2574 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2575 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2576 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2577 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2578 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2579 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2580 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2581 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2582 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2583 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2584 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2585 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2586 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2587 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2588 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2589 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2590 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2591 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2592 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2593 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2594 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2595 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2596 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2597 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2598 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2599 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2600 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2601 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2602 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2603 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2604 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2605 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2606 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2607 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2608 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2609 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2610 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2611 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2612 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2613 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2614 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2615 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2616 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2617 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2618 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2619 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2620 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2621 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2622 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2623 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2624 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2625 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2626 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2627 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2628 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2629 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2630 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2631 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2632 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2633 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2634 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2635 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2636 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2637 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2638 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2639 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2640 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1782 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2641 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1783 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2642 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1784 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2643 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -2124,55 +2983,164 @@ static u32 bnx2_TXP_b06FwText[(0x3ffc/4) + 1] = {
2124 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2983 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2125 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2984 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2126 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 2985 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2127 0x00000000, 0x00000000, 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 2986 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2128 0x0000000d, 0x3c020800, 0x24424020, 0x3c030800, 0x246341f4, 0xac400000, 2987 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2129 0x0043202b, 0x1480fffd, 0x24420004, 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 2988 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2130 0x3c100800, 0x26102090, 0x3c1c0800, 0x279c4020, 0x0e000a0e, 0x00000000, 2989 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2131 0x0000000d, 0x8f840014, 0x27bdffe8, 0xafb00010, 0x8f460104, 0x8f830008, 2990 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2132 0x8c8500ac, 0xaf430080, 0x948200a8, 0xa7420e10, 0x948300aa, 0xa7430e12, 2991 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2133 0x8c8200ac, 0xaf420e18, 0x97430e10, 0xa7430e14, 0x97420e12, 0xa7420e16, 2992 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2134 0x8f430e18, 0x00005021, 0x00c53023, 0x10c001a3, 0xaf430e1c, 0x240f0800, 2993 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2135 0x3c0e1000, 0x2419fff8, 0x24100010, 0x3c188100, 0x93620008, 0x10400009, 2994 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2136 0x00000000, 0x97620010, 0x00c2102b, 0x14400005, 0x00000000, 0x97620010, 2995 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2137 0x3042ffff, 0x0a000862, 0xaf420e00, 0xaf460e00, 0x8f420000, 0x30420008, 2996 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2138 0x1040fffd, 0x00000000, 0x97420e08, 0x8f450e04, 0x3044ffff, 0x30820001, 2997 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2139 0x14400005, 0x00000000, 0x14a00005, 0x3083a040, 0x0a0009e6, 0x00000000, 2998 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2140 0x0000000d, 0x3083a040, 0x24020040, 0x14620049, 0x3082a000, 0x8f87000c, 2999 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2141 0x30880036, 0x30890008, 0xaf4f0178, 0x00e01821, 0x9742008a, 0x00431023, 3000 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2142 0x2442ffff, 0x30421fff, 0x2c420008, 0x1440fffa, 0x00000000, 0x8f830018, 3001 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2143 0x00a05021, 0x00c53023, 0x24e24000, 0x03422821, 0x306b00ff, 0x24630001, 3002 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2144 0xaf830018, 0x93840012, 0x000b1400, 0x3c030100, 0x00431025, 0xaca20000, 3003 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2145 0x8f820018, 0x30840007, 0x00042240, 0x34870001, 0x00e83825, 0x1120000f, 3004 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2146 0xaca20004, 0x97430e0a, 0x8f84000c, 0x00ee3825, 0x2402000e, 0x00781825, 3005 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2147 0xaf430160, 0x25430006, 0x24840008, 0x30841fff, 0xa742015a, 0xa7430158, 3006 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2148 0xaf84000c, 0x0a0008a9, 0x00000000, 0x8f83000c, 0x25420002, 0xa7420158, 3007 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2149 0x24630008, 0x30631fff, 0xaf83000c, 0x54c0000c, 0x8f420e14, 0x97420e10, 3008 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2150 0x97430e12, 0x8f840014, 0x00021400, 0x00621825, 0xac8300a8, 0x8f850014, 3009 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2151 0x8f420e18, 0x34e70040, 0xaca200ac, 0x8f420e14, 0x8f430e1c, 0xaf420144, 3010 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2152 0xaf430148, 0xa34b0152, 0xaf470154, 0x0a0009f1, 0xaf4e0178, 0x10400128, 3011 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2153 0x00000000, 0x97620010, 0x00a2102b, 0x10400003, 0x30820040, 0x10400122, 3012 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2154 0x00000000, 0xafa60008, 0xa7840010, 0xaf850004, 0x93620008, 0x1440005e, 3013 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2155 0x27ac0008, 0xaf60000c, 0x97820010, 0x30424000, 0x10400002, 0x2403000e, 3014 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2156 0x24030016, 0xa363000a, 0x24034007, 0xaf630014, 0x93820012, 0x8f630014, 3015 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2157 0x30420007, 0x00021240, 0x00621825, 0xaf630014, 0x97820010, 0x8f630014, 3016 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2158 0x30420010, 0x00621825, 0xaf630014, 0x97820010, 0x30420008, 0x5040000e, 3017 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2159 0x00002821, 0x8f620014, 0x004e1025, 0xaf620014, 0x97430e0a, 0x2402000e, 3018 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2160 0x00781825, 0xaf630004, 0xa3620002, 0x9363000a, 0x3405fffc, 0x24630004, 3019 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2161 0x0a0008f2, 0xa363000a, 0xaf600004, 0xa3600002, 0x97820010, 0x9363000a, 3020 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2162 0x30421f00, 0x00021182, 0x24420028, 0x00621821, 0xa3630009, 0x97420e0c, 3021 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2163 0xa7620010, 0x93630009, 0x24020008, 0x24630002, 0x30630007, 0x00431023, 3022 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2164 0x30420007, 0xa362000b, 0x93640009, 0x97620010, 0x8f890004, 0x97830010, 3023 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2165 0x00441021, 0x00a21021, 0x30630040, 0x10600006, 0x3045ffff, 0x15250005, 3024 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2166 0x0125102b, 0x3c068000, 0x0a000925, 0x00005821, 0x0125102b, 0x144000c8, 3025 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2167 0x00005021, 0x97420e14, 0xa7420e10, 0x97430e16, 0xa7430e12, 0x8f420e1c, 3026 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2168 0xaf420e18, 0xaf450e00, 0x8f420000, 0x30420008, 0x1040fffd, 0x00000000, 3027 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2169 0x97420e08, 0x00a04821, 0xa7820010, 0x8f430e04, 0x00003021, 0x240b0001, 3028 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2170 0xaf830004, 0x97620010, 0x0a000936, 0x304dffff, 0x8f890004, 0x97820010, 3029 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2171 0x30420040, 0x10400004, 0x01206821, 0x3c068000, 0x0a000936, 0x00005821, 3030 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2172 0x97630010, 0x8f820004, 0x144300a7, 0x00005021, 0x00003021, 0x240b0001, 3031 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3032 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3033 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3034 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3035 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3036 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3037 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3038 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3039 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3040 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3041 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3042 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3044 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3045 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3046 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3047 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3048 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3049 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3050 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3051 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3052 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3053 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3054 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3055 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3056 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3057 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3058 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3059 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3060 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3061 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3062 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3063 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3064 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3065 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3066 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3067 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3068 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3069 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3070 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3071 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3072 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3073 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3074 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3075 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3076 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3077 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3078 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3079 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3080 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3081 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3082 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3083 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3084 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3085 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3086 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3087 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3088 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3089 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3090 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3091 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3092 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3093 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800,
3094 0x24425760, 0x3c030800, 0x24635964, 0xac400000, 0x0043202b, 0x1480fffd,
3095 0x24420004, 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 0x3c100800, 0x261034b0,
3096 0x3c1c0800, 0x279c5760, 0x0e000f5b, 0x00000000, 0x0000000d, 0x8f840014,
3097 0x27bdffe8, 0xafb10014, 0xafb00010, 0x8f460104, 0x8f830008, 0x8c8500ac,
3098 0xaf430080, 0x948200a8, 0xa7420e10, 0x948300aa, 0xa7430e12, 0x8c8200ac,
3099 0xaf420e18, 0x97430e10, 0xa7430e14, 0x97420e12, 0x00008021, 0xa7420e16,
3100 0x8f430e18, 0x00006021, 0x00c53023, 0xaf430e1c, 0x10c001a2, 0x2d820001,
3101 0x3c0e1000, 0x2419fff8, 0x24110010, 0x240f0f00, 0x3c188100, 0x93620008,
3102 0x10400009, 0x00000000, 0x97620010, 0x00c2102b, 0x14400005, 0x00000000,
3103 0x97620010, 0x3042ffff, 0x0a000d6d, 0xaf420e00, 0xaf460e00, 0x8f420000,
3104 0x30420008, 0x1040fffd, 0x00000000, 0x97420e08, 0x8f450e04, 0x3044ffff,
3105 0x30820001, 0x14400005, 0x00000000, 0x14a00005, 0x3083a040, 0x0a000f34,
3106 0x00000000, 0x0000000d, 0x3083a040, 0x24020040, 0x1462004f, 0x3082a000,
3107 0x308a0036, 0x8f88000c, 0x30890008, 0x24020800, 0xaf420178, 0x01001821,
3108 0x9742008a, 0x00431023, 0x2442ffff, 0x30421fff, 0x2c420008, 0x1440fffa,
3109 0x00a06021, 0x8f820018, 0x00cc3023, 0x24070001, 0x8f830008, 0x304b00ff,
3110 0x24420001, 0xaf820018, 0x25024000, 0x106f0005, 0x03422021, 0x93820012,
3111 0x30420007, 0x00021240, 0x34470001, 0x000b1400, 0x3c030100, 0x00431025,
3112 0xac820000, 0x8f830018, 0x00ea3825, 0x1120000f, 0xac830004, 0x97430e0a,
3113 0x8f84000c, 0x00ee3825, 0x2402000e, 0x00781825, 0xaf430160, 0x25830006,
3114 0x24840008, 0x30841fff, 0xa742015a, 0xa7430158, 0xaf84000c, 0x0a000db7,
3115 0x00000000, 0x8f83000c, 0x25820002, 0xa7420158, 0x24630008, 0x30631fff,
3116 0xaf83000c, 0x54c0000f, 0x8f420e14, 0x8f820008, 0x504f0002, 0x24100001,
3117 0x34e70040, 0x97420e10, 0x97430e12, 0x8f850014, 0x00021400, 0x00621825,
3118 0xaca300a8, 0x8f840014, 0x8f420e18, 0xac8200ac, 0x8f420e14, 0x8f430e1c,
3119 0xaf420144, 0xaf430148, 0xa34b0152, 0xaf470154, 0x0a000efb, 0xaf4e0178,
3120 0x10400165, 0x00000000, 0x93620008, 0x50400008, 0xafa60008, 0x97620010,
3121 0x00a2102b, 0x10400003, 0x30820040, 0x1040015c, 0x00000000, 0xafa60008,
3122 0xa7840010, 0xaf850004, 0x93620008, 0x1440005f, 0x27ac0008, 0xaf60000c,
3123 0x97820010, 0x30424000, 0x10400002, 0x2403000e, 0x24030016, 0xa363000a,
3124 0x24034007, 0xaf630014, 0x93820012, 0x8f630014, 0x30420007, 0x00021240,
3125 0x00621825, 0xaf630014, 0x97820010, 0x8f630014, 0x30420010, 0x00621825,
3126 0xaf630014, 0x97820010, 0x30420008, 0x5040000e, 0x00002821, 0x8f620014,
3127 0x004e1025, 0xaf620014, 0x97430e0a, 0x2402000e, 0x00781825, 0xaf630004,
3128 0xa3620002, 0x9363000a, 0x3405fffc, 0x24630004, 0x0a000e06, 0xa363000a,
3129 0xaf600004, 0xa3600002, 0x97820010, 0x9363000a, 0x30421f00, 0x00021182,
3130 0x24420028, 0x00621821, 0xa3630009, 0x97420e0c, 0xa7620010, 0x93630009,
3131 0x24020008, 0x24630002, 0x30630007, 0x00431023, 0x30420007, 0xa362000b,
3132 0x93640009, 0x97620010, 0x8f890004, 0x97830010, 0x00441021, 0x00a21021,
3133 0x30630040, 0x10600007, 0x3045ffff, 0x00a9102b, 0x14400005, 0x0125102b,
3134 0x3c068000, 0x0a000e3a, 0x00005821, 0x0125102b, 0x544000c7, 0x00006021,
3135 0x97420e14, 0xa7420e10, 0x97430e16, 0xa7430e12, 0x8f420e1c, 0xaf420e18,
3136 0xaf450e00, 0x8f420000, 0x30420008, 0x1040fffd, 0x00000000, 0x97420e08,
3137 0x00a04821, 0xa7820010, 0x8f430e04, 0x00003021, 0x240b0001, 0xaf830004,
3138 0x97620010, 0x0a000e4c, 0x304dffff, 0x8f890004, 0x97820010, 0x30420040,
3139 0x10400004, 0x01206821, 0x3c068000, 0x0a000e4c, 0x00005821, 0x97630010,
3140 0x8f820004, 0x10430003, 0x00003021, 0x0a000eee, 0x00006021, 0x240b0001,
2173 0x8d820000, 0x00491023, 0x1440000d, 0xad820000, 0x8f620014, 0x34420040, 3141 0x8d820000, 0x00491023, 0x1440000d, 0xad820000, 0x8f620014, 0x34420040,
2174 0xaf620014, 0x97430e10, 0x97420e12, 0x8f840014, 0x00031c00, 0x00431025, 3142 0xaf620014, 0x97430e10, 0x97420e12, 0x8f840014, 0x00031c00, 0x00431025,
2175 0xac8200a8, 0x8f830014, 0x8f420e18, 0xac6200ac, 0x93620008, 0x1440003f, 3143 0xac8200a8, 0x8f830014, 0x8f420e18, 0xac6200ac, 0x93620008, 0x1440003e,
2176 0x00000000, 0x25260002, 0x8f84000c, 0x9743008a, 0x3063ffff, 0xafa30000, 3144 0x00000000, 0x25260002, 0x8f84000c, 0x9743008a, 0x3063ffff, 0xafa30000,
2177 0x8fa20000, 0x00441023, 0x2442ffff, 0x30421fff, 0x2c420010, 0x1440fff7, 3145 0x8fa20000, 0x00441023, 0x2442ffff, 0x30421fff, 0x2c420010, 0x1440fff7,
2178 0x00000000, 0x8f82000c, 0x8f830018, 0x00021082, 0x00021080, 0x24424000, 3146 0x00000000, 0x8f82000c, 0x8f830018, 0x00021082, 0x00021080, 0x24424000,
@@ -2180,289 +3148,320 @@ static u32 bnx2_TXP_b06FwText[(0x3ffc/4) + 1] = {
2180 0x3c033200, 0x00431025, 0xaca20000, 0x93630009, 0x9362000a, 0x00031c00, 3148 0x3c033200, 0x00431025, 0xaca20000, 0x93630009, 0x9362000a, 0x00031c00,
2181 0x00431025, 0xaca20004, 0x8f830018, 0xaca30008, 0x97820010, 0x30420008, 3149 0x00431025, 0xaca20004, 0x8f830018, 0xaca30008, 0x97820010, 0x30420008,
2182 0x10400002, 0x00c04021, 0x25280006, 0x97430e14, 0x93640002, 0x8f450e1c, 3150 0x10400002, 0x00c04021, 0x25280006, 0x97430e14, 0x93640002, 0x8f450e1c,
2183 0x8f660004, 0x8f670014, 0xaf4f0178, 0x3063ffff, 0xa7430144, 0x97420e16, 3151 0x8f660004, 0x8f670014, 0x3063ffff, 0xa7430144, 0x97420e16, 0xa7420146,
2184 0xa7420146, 0xaf450148, 0xa34a0152, 0x8f82000c, 0x308400ff, 0xa744015a, 3152 0xaf450148, 0xa34a0152, 0x8f82000c, 0x308400ff, 0xa744015a, 0xaf460160,
2185 0xaf460160, 0xa7480158, 0xaf470154, 0xaf4e0178, 0x00501021, 0x30421fff, 3153 0xa7480158, 0xaf470154, 0xaf4e0178, 0x00511021, 0x30421fff, 0xaf82000c,
2186 0xaf82000c, 0x0a0009c5, 0x8d820000, 0x93620009, 0x9363000b, 0x8f85000c, 3154 0x0a000ed9, 0x8d820000, 0x93620009, 0x9363000b, 0x8f85000c, 0x2463000a,
2187 0x2463000a, 0x00435021, 0x25440007, 0x00992024, 0x9743008a, 0x3063ffff, 3155 0x00435021, 0x25440007, 0x00992024, 0x9743008a, 0x3063ffff, 0xafa30000,
2188 0xafa30000, 0x8fa20000, 0x00451023, 0x2442ffff, 0x30421fff, 0x0044102b, 3156 0x8fa20000, 0x00451023, 0x2442ffff, 0x30421fff, 0x0044102b, 0x1440fff7,
2189 0x1440fff7, 0x00000000, 0x8f82000c, 0x8f840018, 0x00021082, 0x00021080, 3157 0x00000000, 0x8f82000c, 0x8f840018, 0x00021082, 0x00021080, 0x24424000,
2190 0x24424000, 0x03422821, 0x00804021, 0x24840001, 0xaf840018, 0x93630009, 3158 0x03422821, 0x00804021, 0x24840001, 0xaf840018, 0x93630009, 0x310200ff,
2191 0x310200ff, 0x00022400, 0x3c024100, 0x24630002, 0x00621825, 0x00832025, 3159 0x00022400, 0x3c024100, 0x24630002, 0x00621825, 0x00832025, 0xaca40000,
2192 0xaca40000, 0x8f62000c, 0x00461025, 0xaca20004, 0x97430e14, 0x93640002, 3160 0x8f62000c, 0x00461025, 0xaca20004, 0x97430e14, 0x93640002, 0x8f450e1c,
2193 0x8f450e1c, 0x8f660004, 0x8f670014, 0xaf4f0178, 0x3063ffff, 0xa7430144, 3161 0x8f660004, 0x8f670014, 0x3063ffff, 0xa7430144, 0x97420e16, 0x308400ff,
2194 0x97420e16, 0x308400ff, 0xa7420146, 0xaf450148, 0xa3480152, 0x8f83000c, 3162 0xa7420146, 0xaf450148, 0xa3480152, 0x8f83000c, 0x25420007, 0x00591024,
2195 0x25420007, 0x00591024, 0xa744015a, 0xaf460160, 0xa7490158, 0xaf470154, 3163 0xa744015a, 0xaf460160, 0xa7490158, 0xaf470154, 0xaf4e0178, 0x00621821,
2196 0xaf4e0178, 0x00621821, 0x30631fff, 0xaf83000c, 0x8d820000, 0x14400005, 3164 0x30631fff, 0xaf83000c, 0x8d820000, 0x14400005, 0x00000000, 0x8f620014,
2197 0x00000000, 0x8f620014, 0x2403ffbf, 0x00431024, 0xaf620014, 0x8f62000c, 3165 0x2403ffbf, 0x00431024, 0xaf620014, 0x8f62000c, 0x004d1021, 0xaf62000c,
2198 0x004d1021, 0xaf62000c, 0x93630008, 0x14600008, 0x00000000, 0x11600006, 3166 0x93630008, 0x14600008, 0x00000000, 0x11600006, 0x00000000, 0x8f630014,
2199 0x00000000, 0x8f630014, 0x3c02efff, 0x3442fffe, 0x00621824, 0xaf630014, 3167 0x3c02efff, 0x3442fffe, 0x00621824, 0xaf630014, 0xa36b0008, 0x01206021,
2200 0xa36b0008, 0x01205021, 0x15400016, 0x8fa60008, 0x97420e14, 0x97430e16, 3168 0x1580000c, 0x8fa60008, 0x97420e14, 0x97430e16, 0x8f850014, 0x00021400,
2201 0x8f850014, 0x00021400, 0x00621825, 0xaca300a8, 0x8f840014, 0x8f420e1c, 3169 0x00621825, 0xaca300a8, 0x8f840014, 0x8f420e1c, 0xac8200ac, 0x0a000efd,
2202 0x0a0009f3, 0xac8200ac, 0x97420e14, 0x97430e16, 0x8f840014, 0x00021400, 3170 0x2d820001, 0x14c0fe65, 0x2d820001, 0x00501025, 0x10400058, 0x24020f00,
2203 0x00621825, 0xac8300a8, 0x8f850014, 0x8f420e1c, 0x00005021, 0x0a0009f3, 3171 0x8f830008, 0x14620023, 0x3c048000, 0x11800009, 0x3c038000, 0x97420e08,
2204 0xaca200ac, 0x14c0fe64, 0x00000000, 0x55400018, 0x8fb00010, 0x3c038000, 3172 0x30420040, 0x14400005, 0x00000000, 0x0000000d, 0x00000000, 0x2400032c,
2205 0x8f420178, 0x00431024, 0x1440fffd, 0x00000000, 0x97430e14, 0x8f440e1c, 3173 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x00000000, 0x97420e10,
2206 0x24020800, 0xaf420178, 0x3063ffff, 0xa7430144, 0x97420e16, 0x3c031000, 3174 0x3c030500, 0x00431025, 0xaf42014c, 0x97430e14, 0xa7430144, 0x97420e16,
2207 0xa7420146, 0x24020240, 0xaf440148, 0xa3400152, 0xa740015a, 0xaf400160, 3175 0xa7420146, 0x8f430e1c, 0x24022000, 0xaf430148, 0x3c031000, 0xa3400152,
2208 0xa7400158, 0xaf420154, 0xaf430178, 0x8fb00010, 0x03e00008, 0x27bd0018, 3176 0xa740015a, 0xaf400160, 0xa7400158, 0xaf420154, 0xaf430178, 0x8f830008,
2209 0x27bdffd8, 0x3c1a8000, 0x3c0420ff, 0x3484fffd, 0x3c020008, 0x03421821, 3177 0x3c048000, 0x8f420178, 0x00441024, 0x1440fffd, 0x24020f00, 0x10620016,
2210 0xafbf0020, 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0xaf830014, 3178 0x00000000, 0x97420e14, 0xa7420144, 0x97430e16, 0xa7430146, 0x8f420e1c,
2211 0xaf440e00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 3179 0x3c031000, 0xaf420148, 0x0a000f51, 0x24020240, 0x97420e14, 0x97430e16,
2212 0x3c0200ff, 0x3442fffd, 0x3c046004, 0xaf420e00, 0x8c835000, 0x24130d00, 3180 0x8f840014, 0x00021400, 0x00621825, 0xac8300a8, 0x8f850014, 0x8f420e1c,
2213 0x3c120800, 0x3c114000, 0x2402ff7f, 0x00621824, 0x3463380c, 0x24020009, 3181 0x00006021, 0xaca200ac, 0x0a000efd, 0x2d820001, 0xaf40014c, 0x11800007,
2214 0xac835000, 0xaf420008, 0xaf800018, 0xaf80000c, 0x0e000fa1, 0x00000000, 3182 0x00000000, 0x97420e10, 0xa7420144, 0x97430e12, 0xa7430146, 0x0a000f4e,
2215 0x0e000a96, 0x00000000, 0x3c020800, 0x24504080, 0x8f420000, 0x30420001, 3183 0x8f420e18, 0x97420e14, 0xa7420144, 0x97430e16, 0xa7430146, 0x8f420e1c,
2216 0x1040fffd, 0x00000000, 0x8f440100, 0xaf840008, 0xaf440020, 0x93430108, 3184 0xaf420148, 0x24020040, 0x3c031000, 0xa3400152, 0xa740015a, 0xaf400160,
2217 0xa3830012, 0x93820012, 0x30420001, 0x10400008, 0x00000000, 0x93820012, 3185 0xa7400158, 0xaf420154, 0xaf430178, 0x8fb10014, 0x8fb00010, 0x03e00008,
2218 0x30420006, 0x00021100, 0x0e00083b, 0x0050d821, 0x0a000a52, 0x00000000, 3186 0x27bd0018, 0x27bdffd0, 0x3c1a8000, 0x3c0420ff, 0x3484fffd, 0x3c020008,
2219 0x14930005, 0x00000000, 0x0e00083b, 0x265b4100, 0x0a000a52, 0x00000000, 3187 0x03421821, 0xafbf002c, 0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c,
2220 0x0e000ba3, 0x00000000, 0xaf510138, 0x0a000a36, 0x00000000, 0x27bdfff8, 3188 0xafb20018, 0xafb10014, 0xafb00010, 0xaf830014, 0xaf440e00, 0x00000000,
2221 0x3084ffff, 0x24820007, 0x3044fff8, 0x8f85000c, 0x9743008a, 0x3063ffff, 3189 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3c0200ff, 0x3442fffd,
2222 0xafa30000, 0x8fa20000, 0x00451023, 0x2442ffff, 0x30421fff, 0x0044102b, 3190 0x3c046004, 0xaf420e00, 0x8c835000, 0x24160800, 0x24150d00, 0x3c140800,
2223 0x1440fff7, 0x00000000, 0x8f82000c, 0x00021082, 0x00021080, 0x24424000, 3191 0x24130f00, 0x3c120800, 0x3c114000, 0x2402ff7f, 0x00621824, 0x3463380c,
2224 0x03421021, 0x03e00008, 0x27bd0008, 0x3084ffff, 0x8f82000c, 0x24840007, 3192 0x24020009, 0xac835000, 0xaf420008, 0xaf800018, 0xaf80000c, 0x0e001559,
2225 0x3084fff8, 0x00441021, 0x30421fff, 0xaf82000c, 0x03e00008, 0x00000000, 3193 0x00000000, 0x0e000ff0, 0x00000000, 0x3c020800, 0x245057c0, 0x8f420000,
2226 0x27bdffe8, 0x3c1a8000, 0x3c0420ff, 0x3484fffd, 0x3c020008, 0x03421821, 3194 0x30420001, 0x1040fffd, 0x00000000, 0x8f440100, 0xaf840008, 0xaf440020,
2227 0xafbf0010, 0xaf830014, 0xaf440e00, 0x00000000, 0x00000000, 0x00000000, 3195 0xaf560178, 0x93430108, 0xa3830012, 0x93820012, 0x30420001, 0x10400008,
2228 0x00000000, 0x00000000, 0x3c0200ff, 0x3442fffd, 0x3c046004, 0xaf420e00, 3196 0x00000000, 0x93820012, 0x30420006, 0x00021100, 0x0e000d43, 0x0050d821,
2229 0x8c825000, 0x2403ff7f, 0x00431024, 0x3442380c, 0x24030009, 0xac825000, 3197 0x0a000fac, 0x00000000, 0x14950005, 0x00000000, 0x0e000d43, 0x269b5840,
2230 0xaf430008, 0xaf800018, 0xaf80000c, 0x0e000fa1, 0x00000000, 0x0e000a96, 3198 0x0a000fac, 0x00000000, 0x14930005, 0x00000000, 0x0e000d43, 0x265b5860,
2231 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0x3c02000a, 3199 0x0a000fac, 0x00000000, 0x0e0010ea, 0x00000000, 0xaf510138, 0x0a000f89,
2232 0x03421821, 0x3c040800, 0x24844120, 0x24050018, 0xafbf0010, 0xaf830024, 3200 0x00000000, 0x27bdfff8, 0x3084ffff, 0x24820007, 0x3044fff8, 0x8f85000c,
2233 0x0e000fad, 0x00003021, 0x3c050800, 0x3c020800, 0x24423d60, 0xaca24180, 3201 0x9743008a, 0x3063ffff, 0xafa30000, 0x8fa20000, 0x00451023, 0x2442ffff,
2234 0x24a54180, 0x3c020800, 0x24423e18, 0x3c030800, 0x24633e2c, 0x3c040800, 3202 0x30421fff, 0x0044102b, 0x1440fff7, 0x00000000, 0x8f82000c, 0x00021082,
2235 0xaca20004, 0x3c020800, 0x24423d68, 0xaca30008, 0xac824190, 0x24844190, 3203 0x00021080, 0x24424000, 0x03421021, 0x03e00008, 0x27bd0008, 0x3084ffff,
2236 0x3c020800, 0x24423da4, 0x3c070800, 0x24e73de4, 0x3c060800, 0x24c63e40, 3204 0x8f82000c, 0x24840007, 0x3084fff8, 0x00441021, 0x30421fff, 0xaf82000c,
2237 0x3c050800, 0x24a52b28, 0x3c030800, 0xac820004, 0x3c020800, 0x24423e48, 3205 0x03e00008, 0x00000000, 0x27bdffe8, 0x3c1a8000, 0x3c0420ff, 0x3484fffd,
2238 0xac870008, 0xac86000c, 0xac850010, 0xac6241b0, 0x246341b0, 0x8fbf0010, 3206 0x3c020008, 0x03421821, 0xafbf0010, 0xaf830014, 0xaf440e00, 0x00000000,
2239 0x3c020800, 0x24423e60, 0xac620004, 0xac670008, 0xac66000c, 0xac650010, 3207 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3c0200ff, 0x3442fffd,
2240 0x03e00008, 0x27bd0018, 0x27bdffc8, 0x3c020800, 0x24424120, 0xafbf0030, 3208 0x3c046004, 0xaf420e00, 0x8c825000, 0x2403ff7f, 0x00431024, 0x3442380c,
2241 0xafb3002c, 0xafb20028, 0xafb10024, 0xafb00020, 0x90470021, 0x8c510008, 3209 0x24030009, 0xac825000, 0xaf430008, 0xaf800018, 0xaf80000c, 0x0e001559,
2242 0x8c45001c, 0x8f900020, 0x3c060800, 0x3c038000, 0x8f420178, 0x00431024, 3210 0x00000000, 0x0e000ff0, 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018,
2243 0x1440fffd, 0x8cc2414c, 0x24c3414c, 0x2473ffd4, 0xaf420144, 0x8e620030, 3211 0x27bdffe8, 0x3c02000a, 0x03421821, 0x3c040800, 0x24845880, 0x24050019,
2244 0x30b22000, 0xaf420148, 0x3c021000, 0xaf50014c, 0xa3470152, 0xa7510158, 3212 0xafbf0010, 0xaf830024, 0x0e001565, 0x00003021, 0x3c050800, 0x3c020800,
2245 0xaf450154, 0xaf420178, 0x12400004, 0x3c030800, 0x8c620030, 0x24420001, 3213 0x24425330, 0xaca258e8, 0x24a558e8, 0x3c020800, 0x244254f8, 0x3c030800,
2246 0xac620030, 0x93420109, 0x9344010a, 0x00111c00, 0xafa30018, 0x00071a00, 3214 0x2463550c, 0x3c040800, 0xaca20004, 0x3c020800, 0x24425338, 0xaca30008,
2247 0xafa50014, 0x8cc5414c, 0x00021600, 0x00042400, 0x00441025, 0x00431025, 3215 0xac825900, 0x24845900, 0x3c020800, 0x244253c4, 0x3c070800, 0x24e75404,
2248 0xafa20010, 0x8f440100, 0x8e660030, 0x0e000fe1, 0x02003821, 0x1640000e, 3216 0x3c060800, 0x24c65520, 0x3c050800, 0x24a55438, 0x3c030800, 0xac820004,
2249 0x8fbf0030, 0x8f820000, 0x8e630030, 0x8c44017c, 0x02031823, 0x00711823, 3217 0x3c020800, 0x24425528, 0xac870008, 0xac86000c, 0xac850010, 0xac625920,
2250 0x00641823, 0x2c630002, 0x14600006, 0x8fb3002c, 0x0000000d, 0x00000000, 3218 0x24635920, 0x8fbf0010, 0x3c020800, 0x24425540, 0xac620004, 0x3c020800,
2251 0x240000ca, 0x8fbf0030, 0x8fb3002c, 0x8fb20028, 0x8fb10024, 0x8fb00020, 3219 0xac670008, 0xac66000c, 0xac650010, 0xac400048, 0x03e00008, 0x27bd0018,
2252 0x03e00008, 0x27bd0038, 0x974309da, 0x00804021, 0xad030000, 0x8f4209dc, 3220 0x974309da, 0x00804021, 0xad030000, 0x8f4209dc, 0xad020004, 0x8f4309e0,
2253 0xad020004, 0x8f4309e0, 0xad030008, 0x934409d9, 0x24020001, 0x30840003, 3221 0xad030008, 0x934409d9, 0x24020001, 0x30840003, 0x1082001f, 0x30a900ff,
2254 0x1082001f, 0x30a900ff, 0x28820002, 0x10400005, 0x24020002, 0x10800009, 3222 0x28820002, 0x10400005, 0x24020002, 0x10800009, 0x3c0a0800, 0x0a001078,
2255 0x3c0a0800, 0x0a000b64, 0x93420934, 0x1082000b, 0x24020003, 0x10820026, 3223 0x93420934, 0x1082000b, 0x24020003, 0x10820026, 0x3c0a0800, 0x0a001078,
2256 0x3c0a0800, 0x0a000b64, 0x93420934, 0x974209e4, 0x00021400, 0x34420800, 3224 0x93420934, 0x974209e4, 0x00021400, 0x34420800, 0xad02000c, 0x0a001077,
2257 0xad02000c, 0x0a000b63, 0x25080010, 0x974209e4, 0x00021400, 0x34428100, 3225 0x25080010, 0x974209e4, 0x00021400, 0x34428100, 0xad02000c, 0x974309e8,
2258 0xad02000c, 0x974309e8, 0x3c0a0800, 0x00031c00, 0x34630800, 0xad030010, 3226 0x3c0a0800, 0x00031c00, 0x34630800, 0xad030010, 0x0a001077, 0x25080014,
2259 0x0a000b63, 0x25080014, 0x974409e4, 0x3c050800, 0x24a24120, 0x94430018, 3227 0x974409e4, 0x3c050800, 0x24a25880, 0x9443001c, 0x94460014, 0x94470010,
2260 0x94460010, 0x9447000c, 0x00a05021, 0x24020800, 0xad000010, 0xad020014, 3228 0x00a05021, 0x24020800, 0xad000010, 0xad020014, 0x00042400, 0x00661821,
2261 0x00042400, 0x00661821, 0x00671823, 0x2463fff2, 0x00832025, 0xad04000c, 3229 0x00671823, 0x2463fff2, 0x00832025, 0xad04000c, 0x0a001077, 0x25080018,
2262 0x0a000b63, 0x25080018, 0x974209e4, 0x3c050800, 0x00021400, 0x34428100, 3230 0x974209e4, 0x3c050800, 0x00021400, 0x34428100, 0xad02000c, 0x974409e8,
2263 0xad02000c, 0x974409e8, 0x24a24120, 0x94430018, 0x94460010, 0x9447000c, 3231 0x24a25880, 0x9443001c, 0x94460014, 0x94470010, 0x00a05021, 0x24020800,
2264 0x00a05021, 0x24020800, 0xad000014, 0xad020018, 0x00042400, 0x00661821, 3232 0xad000014, 0xad020018, 0x00042400, 0x00661821, 0x00671823, 0x2463ffee,
2265 0x00671823, 0x2463ffee, 0x00832025, 0xad040010, 0x2508001c, 0x93420934, 3233 0x00832025, 0xad040010, 0x2508001c, 0x93420934, 0x93450921, 0x3c074000,
2266 0x93450921, 0x3c074000, 0x25444120, 0x94830014, 0x94860010, 0x00021082, 3234 0x25445880, 0x94830018, 0x94860014, 0x00021082, 0x00021600, 0x00052c00,
2267 0x00021600, 0x00052c00, 0x00a72825, 0x00451025, 0x00661821, 0x00431025, 3235 0x00a72825, 0x00451025, 0x00661821, 0x00431025, 0xad020000, 0x9783002c,
2268 0xad020000, 0x97830028, 0x974209ea, 0x00621821, 0x00031c00, 0xad030004, 3236 0x974209ea, 0x00621821, 0x00031c00, 0xad030004, 0x9782002c, 0x24420001,
2269 0x97820028, 0x24420001, 0x30427fff, 0xa7820028, 0x93430920, 0x3c020006, 3237 0x30427fff, 0xa782002c, 0x93430920, 0x3c020006, 0x00031e00, 0x00621825,
2270 0x00031e00, 0x00621825, 0xad030008, 0x8f42092c, 0xad02000c, 0x8f430930, 3238 0xad030008, 0x8f42092c, 0xad02000c, 0x8f430930, 0xad030010, 0x8f440938,
2271 0xad030010, 0x8f440938, 0x25080014, 0xad040000, 0x8f820020, 0x11200004, 3239 0x25080014, 0xad040000, 0x8f820020, 0x11200004, 0xad020004, 0x8f420940,
2272 0xad020004, 0x8f420940, 0x0a000b8d, 0x2442ffff, 0x8f420940, 0xad020008, 3240 0x0a0010a1, 0x2442ffff, 0x8f420940, 0xad020008, 0x8f440948, 0x8f420940,
2273 0x8f440948, 0x8f420940, 0x93430936, 0x00822823, 0x00652806, 0x3402ffff, 3241 0x93430936, 0x00823023, 0x00663006, 0x3402ffff, 0x0046102b, 0x54400001,
2274 0x0045102b, 0x54400001, 0x3405ffff, 0x93420937, 0x25444120, 0x90830020, 3242 0x3406ffff, 0x93420937, 0x25445880, 0x90830024, 0xad000010, 0x00021700,
2275 0xad000010, 0x00021700, 0x34630010, 0x00031c00, 0x00431025, 0x00451025, 3243 0x34630010, 0x00031c00, 0x00431025, 0x00461025, 0xad02000c, 0x8c830008,
2276 0xad02000c, 0x03e00008, 0x25020014, 0x27bdffb0, 0x3c020008, 0x03421821, 3244 0x14600031, 0x25080014, 0x3c020800, 0x8c430048, 0x1060002d, 0x00000000,
2277 0xafbf004c, 0xafbe0048, 0xafb70044, 0xafb60040, 0xafb5003c, 0xafb40038, 3245 0x9342010b, 0xad020000, 0x8f830000, 0x8c6200b0, 0xad020004, 0x8f830000,
2278 0xafb30034, 0xafb20030, 0xafb1002c, 0xafb00028, 0xaf830000, 0x24020040, 3246 0x8c6200b4, 0xad020008, 0x8f830000, 0x8c6200c0, 0xad02000c, 0x8f830000,
2279 0xaf420814, 0xaf400810, 0x8f420944, 0x8f430950, 0x8f440954, 0x8f45095c, 3247 0x8c6200c4, 0xad020010, 0x8f830000, 0x8c6200c8, 0xad020014, 0x8f830000,
2280 0xaf820030, 0xaf830020, 0xaf84001c, 0xaf85002c, 0x93430900, 0x24020020, 3248 0x8c6200cc, 0xad020018, 0x8f830000, 0x8c6200e0, 0xad02001c, 0x8f830000,
2281 0x10620005, 0x24020030, 0x10620022, 0x3c030800, 0x0a000bf1, 0x8c62002c, 3249 0x8c6200e8, 0xad020020, 0x8f830000, 0x8c6200f0, 0x3c04600e, 0xad020024,
2282 0x24020088, 0xaf420818, 0x3c020800, 0x24424180, 0xafa20020, 0x93430109, 3250 0x8c8200d0, 0xad020028, 0x8c8300d4, 0xad03002c, 0x8f820028, 0x3c046012,
2283 0x3c020800, 0x10600009, 0x24574190, 0x3c026000, 0x24030100, 0xac43081c, 3251 0xad020030, 0x8c8200a8, 0xad020034, 0x8c8300ac, 0x3c026000, 0xad030038,
2284 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x2400031d, 0x9342010a, 3252 0x8c434448, 0xad03003c, 0x03e00008, 0x01001021, 0x27bdffa8, 0x3c020008,
2285 0x30420080, 0x1440001c, 0x00000000, 0x3c026000, 0x24030100, 0xac43081c, 3253 0x03423021, 0xafbf0054, 0xafbe0050, 0xafb7004c, 0xafb60048, 0xafb50044,
2286 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x24000324, 0x0a000bf4, 3254 0xafb40040, 0xafb3003c, 0xafb20038, 0xafb10034, 0xafb00030, 0xaf860000,
2287 0x00000000, 0x93430109, 0x3063007f, 0x00031140, 0x000318c0, 0x00431021, 3255 0x24020040, 0xaf420814, 0xaf400810, 0x8f420944, 0x8f430950, 0x8f440954,
2288 0x24430088, 0xaf430818, 0x0000000d, 0x3c020800, 0x244241d0, 0x3c030800, 3256 0x8f45095c, 0xaf820034, 0xaf830020, 0xaf84001c, 0xaf850030, 0x90c20000,
2289 0x247741e0, 0x0a000bf4, 0xafa20020, 0x24420001, 0x0a000f4c, 0xac62002c, 3257 0x24030020, 0x304400ff, 0x10830005, 0x24020030, 0x10820022, 0x3c030800,
2290 0x8f840000, 0x8f850020, 0x24020800, 0xaf420178, 0x8f4209a4, 0x8c83017c, 3258 0x0a001139, 0x8c62002c, 0x24020088, 0xaf420818, 0x3c020800, 0x244258e8,
2291 0x00a21023, 0x00431023, 0x2c420002, 0x14400004, 0x00000000, 0x0000000d, 3259 0xafa20020, 0x93430109, 0x3c020800, 0x10600009, 0x24575900, 0x3c026000,
2292 0x00000000, 0x24000349, 0x8f420104, 0x8f430988, 0x00431023, 0x58400005, 3260 0x24030100, 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000,
2293 0x8f4209a0, 0x0000000d, 0x00000000, 0x2400034d, 0x8f4209a0, 0x3c100800, 3261 0x24000376, 0x9342010a, 0x30420080, 0x14400021, 0x24020800, 0x3c026000,
2294 0xae02414c, 0x8f4309a4, 0x2604414c, 0x2491ffd4, 0xae230030, 0x8f420104, 3262 0x24030100, 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000,
2295 0xae250024, 0x00431023, 0xac82ffd4, 0x8fa30020, 0x8c620000, 0x0040f809, 3263 0x2400037d, 0x0a001141, 0x24020800, 0x93430109, 0x3063007f, 0x00031140,
3264 0x000318c0, 0x00431021, 0x24430088, 0xaf430818, 0x0000000d, 0x3c020800,
3265 0x24425940, 0x3c030800, 0x24775950, 0x0a001140, 0xafa20020, 0x24420001,
3266 0xac62002c, 0x0000000d, 0x00000000, 0x24000395, 0x0a0014c1, 0x8fbf0054,
3267 0x24020800, 0xaf420178, 0x8f450104, 0x8f420988, 0x00a21023, 0x58400005,
3268 0x8f4309a0, 0x0000000d, 0x00000000, 0x240003b1, 0x8f4309a0, 0x3c100800,
3269 0xae0358b0, 0x8f4209a4, 0x8f830020, 0x260458b0, 0x2491ffd0, 0xae220034,
3270 0x00a21023, 0xae230028, 0xac82ffd0, 0x8fa30020, 0x8c620000, 0x0040f809,
2296 0x0200b021, 0x00409021, 0x32440010, 0x32420002, 0x10400007, 0xafa40024, 3271 0x0200b021, 0x00409021, 0x32440010, 0x32420002, 0x10400007, 0xafa40024,
2297 0x8e22001c, 0x32500040, 0x2403ffbf, 0x00431024, 0x0a000f13, 0xae22001c, 3272 0x8e220020, 0x32530040, 0x2403ffbf, 0x00431024, 0x0a001493, 0xae220020,
2298 0x32420020, 0x10400002, 0x3c020800, 0x245741b0, 0x32420001, 0x14400007, 3273 0x32420020, 0x10400002, 0x3c020800, 0x24575920, 0x32420001, 0x14400007,
2299 0x00000000, 0x8f820008, 0xaf420080, 0x8ec3414c, 0xaf430e10, 0x8e220030, 3274 0x00000000, 0x8f820008, 0xaf420080, 0x8ec358b0, 0xaf430e10, 0x8e220034,
2300 0xaf420e18, 0x9343010b, 0x93420905, 0x30420008, 0x1040003c, 0x307400ff, 3275 0xaf420e18, 0x9343010b, 0x93420905, 0x30420008, 0x1040003c, 0x307400ff,
2301 0x8f820000, 0x8c430074, 0x0460000a, 0x00000000, 0x3c026000, 0x24030100, 3276 0x8f820000, 0x8c430074, 0x0460000a, 0x00000000, 0x3c026000, 0x24030100,
2302 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x24000384, 3277 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x240003ed,
2303 0x8f820000, 0x9044007b, 0x9343010a, 0x14830027, 0x32500040, 0x24072000, 3278 0x8f820000, 0x9044007b, 0x9343010a, 0x14830027, 0x32530040, 0x00003821,
2304 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec2414c, 3279 0x24052000, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd,
2305 0x26c4414c, 0x2484ffd4, 0xaf420144, 0x8c820030, 0x3c030100, 0xaf420148, 3280 0x8ec258b0, 0x26c458b0, 0x2484ffd0, 0xaf420144, 0x8c820034, 0x3c030100,
2306 0x24020047, 0xaf43014c, 0x00001821, 0xa3420152, 0x3c021000, 0xa7430158, 3281 0xaf420148, 0x24020047, 0xaf43014c, 0xa3420152, 0x8d230030, 0x3c021000,
2307 0xaf470154, 0xaf420178, 0x8ec5414c, 0x8d230030, 0x8c860030, 0x24630001, 3282 0xa7470158, 0xaf450154, 0xaf420178, 0x8c860034, 0x24630001, 0xad230030,
2308 0xad230030, 0x93420109, 0x9343010a, 0xafa70014, 0xafa00018, 0x00021600, 3283 0x9342010a, 0x3c030047, 0xafa50014, 0x00021600, 0x00431025, 0x00471025,
2309 0x00031c00, 0x00431025, 0x34424700, 0xafa20010, 0x8f440100, 0x0e000fe1, 3284 0xafa20010, 0x9343010b, 0xafa30018, 0x8f440100, 0x8f450104, 0x0e00159b,
2310 0x3c070100, 0x3c030800, 0x24624120, 0x0a000d01, 0x8c43001c, 0x32820002, 3285 0x3c070100, 0x3c050800, 0x24a25880, 0x0a001250, 0x8c430020, 0x32820002,
2311 0x10400047, 0x3c039000, 0x34630001, 0x8f820008, 0x32500040, 0x3c048000, 3286 0x10400050, 0x00000000, 0x0e0015b9, 0x32530040, 0x3c039000, 0x34630001,
2312 0x00431025, 0xaf420020, 0x8f420020, 0x00441024, 0x1440fffd, 0x00000000, 3287 0x8f820008, 0x3c048000, 0x00431025, 0xaf420020, 0x8f420020, 0x00441024,
2313 0x8f830000, 0x90620005, 0x3c058000, 0x34420008, 0xa0620005, 0x8f860000, 3288 0x1440fffd, 0x00000000, 0x8f830000, 0x90620005, 0x34420008, 0xa0620005,
2314 0x34a50001, 0x8f840008, 0x8cc20074, 0x3c038000, 0x00852025, 0x00431025, 3289 0x8f840000, 0x8c820074, 0x3c038000, 0x00431025, 0xac820074, 0x90830000,
2315 0xacc20074, 0xaf440020, 0x90c3007b, 0x9342010a, 0x14620028, 0x3c040800, 3290 0x24020020, 0x10620004, 0x00000000, 0x0000000d, 0x00000000, 0x2400040b,
2316 0x24072000, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 3291 0x8f830008, 0x3c028000, 0x34420001, 0x00621825, 0xaf430020, 0x9084007b,
2317 0x8ec2414c, 0x26c4414c, 0x2484ffd4, 0xaf420144, 0x8c820030, 0x3c030100, 3292 0x9342010a, 0x14820028, 0x3c030800, 0x00003821, 0x24052000, 0x3c090800,
2318 0xaf420148, 0x24020046, 0xaf43014c, 0x00001821, 0xa3420152, 0x3c021000, 3293 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec258b0, 0x26c458b0,
2319 0xa7430158, 0xaf470154, 0xaf420178, 0x8ec5414c, 0x8d230030, 0x8c860030, 3294 0x2484ffd0, 0xaf420144, 0x8c820034, 0x3c030100, 0xaf420148, 0x24020046,
2320 0x24630001, 0xad230030, 0x93420109, 0x9343010a, 0xafa70014, 0xafa00018, 3295 0xaf43014c, 0xa3420152, 0x8d230030, 0x3c021000, 0xa7470158, 0xaf450154,
2321 0x00021600, 0x00031c00, 0x00431025, 0x34424600, 0xafa20010, 0x8f440100, 3296 0xaf420178, 0x8c860034, 0x24630001, 0xad230030, 0x9342010a, 0x3c030046,
2322 0x0e000fe1, 0x3c070100, 0x3c040800, 0x24824120, 0x0a000d01, 0x8c43001c, 3297 0xafa50014, 0x00021600, 0x00431025, 0x00471025, 0xafa20010, 0x9343010b,
2323 0x93420108, 0x30420010, 0x50400050, 0x9343093f, 0x8f860000, 0x90c3007f, 3298 0xafa30018, 0x8f440100, 0x8f450104, 0x0e00159b, 0x3c070100, 0x3c030800,
2324 0x90c2007e, 0x90c40080, 0x306800ff, 0x00021600, 0x00081c00, 0x00431025, 3299 0x24625880, 0x0a001250, 0x8c430020, 0x93420108, 0x30420010, 0x50400056,
2325 0x00042200, 0x90c3007a, 0x90c5000a, 0x00441025, 0x11050028, 0x00623825, 3300 0x9343093f, 0x8f860000, 0x90c2007f, 0x8cc30178, 0x304800ff, 0x15030004,
2326 0xa0c8000a, 0x24086000, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 3301 0x00000000, 0x0000000d, 0x00000000, 0x24000425, 0x90c2007e, 0x90c40080,
2327 0x1440fffd, 0x8ec2414c, 0x26c4414c, 0x2484ffd4, 0xaf420144, 0x8c820030, 3302 0x00081c00, 0x00021600, 0x00431025, 0x00042200, 0x90c3007a, 0x90c5000a,
2328 0x00001821, 0xaf420148, 0x24020052, 0xaf47014c, 0xa3420152, 0x3c021000, 3303 0x00441025, 0x11050028, 0x00623825, 0xa0c8000a, 0x00004021, 0x24056000,
2329 0xa7430158, 0xaf480154, 0xaf420178, 0x8ec5414c, 0x8d230030, 0x8c860030, 3304 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec258b0,
2330 0x24630001, 0xad230030, 0x93420109, 0x9343010a, 0xafa80014, 0xafa00018, 3305 0x26c458b0, 0x2484ffd0, 0xaf420144, 0x8c820034, 0xaf420148, 0x24020052,
2331 0x00021600, 0x00031c00, 0x00431025, 0x34425200, 0xafa20010, 0x0e000fe1, 3306 0xaf47014c, 0xa3420152, 0x8d230030, 0x3c021000, 0xa7480158, 0xaf450154,
2332 0x8f440100, 0x0a000cfb, 0x00000000, 0x3c026000, 0x24030100, 0xac43081c, 3307 0xaf420178, 0x8c860034, 0x24630001, 0xad230030, 0x9342010a, 0x3c030052,
2333 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x240003cd, 0x16800009, 3308 0xafa50014, 0x00021600, 0x00431025, 0x00481025, 0xafa20010, 0x9343010b,
2334 0x3c040800, 0x3c030800, 0x24624120, 0x8c43001c, 0x32500040, 0x2404ffbf, 3309 0xafa30018, 0x8f440100, 0x0e00159b, 0x8f450104, 0x0a00124a, 0x00000000,
2335 0x00641824, 0x0a000f13, 0xac43001c, 0x8c824120, 0x10400005, 0x3c030800, 3310 0x3c026000, 0x24030100, 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d,
2336 0x8c620034, 0xac804120, 0x24420001, 0xac620034, 0x9343093f, 0x24020012, 3311 0x00000000, 0x2400043e, 0x16800009, 0x3c050800, 0x3c040800, 0x24825880,
2337 0x1462000f, 0x329e0038, 0x17c0000c, 0x3c030800, 0x8f830000, 0x8c62004c, 3312 0x8c430020, 0x32530040, 0x2404ffbf, 0x00641824, 0x0a001493, 0xac430020,
2338 0xac62005c, 0x3c020800, 0x24444120, 0x8c82001c, 0x32500040, 0x2403ffbf, 3313 0x8ca25880, 0x10400005, 0x3c030800, 0x8c620034, 0xaca05880, 0x24420001,
2339 0x00431024, 0x0a000f13, 0xac82001c, 0xac604120, 0x97420908, 0x000211c0, 3314 0xac620034, 0x9343093f, 0x24020012, 0x5462000e, 0x97420908, 0x32820038,
3315 0x14400009, 0x3c030800, 0x8f830000, 0x8c62004c, 0xac62005c, 0x3c020800,
3316 0x24445880, 0x8c820020, 0x0a001285, 0x32530040, 0xac605880, 0x97420908,
3317 0x5440001c, 0x97420908, 0x3c039000, 0x34630001, 0x8f820008, 0x32530040,
3318 0x3c048000, 0x00431025, 0xaf420020, 0x8f420020, 0x00441024, 0x1440fffd,
3319 0x3c028000, 0x8f840000, 0x8f850008, 0x8c830050, 0x34420001, 0x00a22825,
3320 0xaf830020, 0xac830070, 0xac83005c, 0xaf450020, 0x3c050800, 0x24a45880,
3321 0x8c820020, 0x2403ffbf, 0x00431024, 0x0a001493, 0xac820020, 0x000211c0,
2340 0xaf420024, 0x97420908, 0x3c030080, 0x34630003, 0x000211c0, 0xaf42080c, 3322 0xaf420024, 0x97420908, 0x3c030080, 0x34630003, 0x000211c0, 0xaf42080c,
2341 0xaf43081c, 0x974209ec, 0x8f4309a4, 0xa7820028, 0x3c020800, 0x24444120, 3323 0xaf43081c, 0x974209ec, 0x8f4309a4, 0xa782002c, 0x3c020800, 0x24445880,
2342 0xac830028, 0x93420937, 0x93430934, 0x00021080, 0x00621821, 0xa4830014, 3324 0xac83002c, 0x93420937, 0x93430934, 0x00021080, 0x00621821, 0xa4830018,
2343 0x934209d8, 0x00621821, 0xa4830016, 0x934209d8, 0x93430934, 0x00809821, 3325 0x934209d8, 0x32850038, 0xafa50028, 0x00621821, 0xa483001a, 0x934209d8,
2344 0x00431021, 0x24420010, 0xa4820012, 0x0000a821, 0x24020006, 0x13c00003, 3326 0x93430934, 0x3c1e0800, 0x00809821, 0x00431021, 0x24420010, 0xa4820016,
2345 0xae62001c, 0x0a000d82, 0x24120008, 0x8f420958, 0x8f830020, 0x8f84002c, 3327 0x24020006, 0xae620020, 0x8fa20028, 0x10400003, 0x0000a821, 0x0a0012f0,
2346 0x00431023, 0x00832023, 0x04800003, 0xae620004, 0x04410003, 0x0082102b, 3328 0x24120008, 0x8f420958, 0x8f830020, 0x8f840030, 0x00431023, 0x00832023,
2347 0x0a000d4e, 0xae600004, 0x54400001, 0xae640004, 0x8ee20000, 0x0040f809, 3329 0x04800003, 0xae620004, 0x04410003, 0x0082102b, 0x0a0012bc, 0xae600004,
2348 0x00000000, 0x00409021, 0x32420001, 0x5440001e, 0x8ee20004, 0x8e630008, 3330 0x54400001, 0xae640004, 0x8ee20000, 0x0040f809, 0x00000000, 0x00409021,
2349 0x1060002b, 0x3c02c000, 0x00621025, 0xaf420e00, 0x8f420000, 0x30420008, 3331 0x32420001, 0x5440001e, 0x8ee20004, 0x8e630008, 0x1060002b, 0x3c02c000,
2350 0x1040fffd, 0x00000000, 0x97420e08, 0xa7820010, 0x8f430e04, 0x8e620008, 3332 0x00621025, 0xaf420e00, 0x8f420000, 0x30420008, 0x1040fffd, 0x00000000,
2351 0xaf830004, 0x8f840004, 0x0044102b, 0x1040000b, 0x24150001, 0x24020100, 3333 0x97420e08, 0xa7820010, 0x8f430e04, 0x8e620008, 0xaf830004, 0x8f840004,
2352 0x3c016000, 0xac22081c, 0x3c020001, 0x3c016000, 0xac22081c, 0x0000000d, 3334 0x0044102b, 0x1040000b, 0x24150001, 0x24020100, 0x3c016000, 0xac22081c,
2353 0x00000000, 0x24000449, 0x24150001, 0x8ee20004, 0x0040f809, 0x00000000, 3335 0x3c020001, 0x3c016000, 0xac22081c, 0x0000000d, 0x00000000, 0x240004cd,
2354 0x02429025, 0x32420002, 0x5040001d, 0x8f470940, 0x12a00006, 0x8ec2414c, 3336 0x24150001, 0x8ee20004, 0x0040f809, 0x00000000, 0x02429025, 0x32420002,
2355 0x8f830000, 0xac6200a8, 0x8f840000, 0x8e620030, 0xac8200ac, 0x32420004, 3337 0x5040001d, 0x8f470940, 0x12a00006, 0x8ec258b0, 0x8f830000, 0xac6200a8,
2356 0x50400013, 0x8f470940, 0x3c020800, 0x3283007d, 0x106000fe, 0x245741b0, 3338 0x8f840000, 0x8e620034, 0xac8200ac, 0x32420004, 0x50400013, 0x8f470940,
2357 0x32820001, 0x50400006, 0x36520002, 0x8f830030, 0x8f420940, 0x106200f7, 3339 0x3c020800, 0x3283007d, 0x10600110, 0x24575920, 0x32820001, 0x50400006,
2358 0x00000000, 0x36520002, 0x24020008, 0xa660000c, 0xa662000e, 0xae600008, 3340 0x36520002, 0x8f830034, 0x8f420940, 0x10620109, 0x00000000, 0x36520002,
2359 0xa2600020, 0x8f470940, 0x3c030800, 0x24684120, 0x8d020028, 0x8d050008, 3341 0x24020008, 0xa6600010, 0xa6620012, 0xae600008, 0xa2600024, 0x8f470940,
2360 0x9504000c, 0x9506000a, 0x95030022, 0x00451021, 0x00862021, 0x00641821, 3342 0x3c030800, 0x24685880, 0x8d02002c, 0x8d050008, 0x95040010, 0x9506000a,
2361 0xaf870030, 0xad020028, 0x32820030, 0x10400006, 0xa5030010, 0x91020020, 3343 0x95030026, 0x00451021, 0x00862021, 0x00641821, 0xaf870034, 0xad02002c,
2362 0x32910040, 0x34420004, 0x0a000dd4, 0xa1020020, 0x93420923, 0x30420040, 3344 0x32820030, 0x10400008, 0xa5030014, 0x91020024, 0x32910040, 0x34420004,
3345 0xa1020024, 0xaf400048, 0x0a001345, 0x3c040800, 0x93420923, 0x30420002,
2363 0x10400029, 0x32910040, 0x8f830000, 0x8f840020, 0x8c620084, 0x00441023, 3346 0x10400029, 0x32910040, 0x8f830000, 0x8f840020, 0x8c620084, 0x00441023,
2364 0x0442000a, 0x3c039000, 0x95020010, 0x8c630084, 0x00821021, 0x00621823, 3347 0x0442000a, 0x3c039000, 0x95020014, 0x8c630084, 0x00821021, 0x00621823,
2365 0x1c600004, 0x3c039000, 0x91020020, 0x34420001, 0xa1020020, 0x34630001, 3348 0x1c600004, 0x3c039000, 0x91020024, 0x34420001, 0xa1020024, 0x34630001,
2366 0x8f820008, 0x32910040, 0x3c048000, 0x00431025, 0xaf420020, 0x8f420020, 3349 0x8f820008, 0x32910040, 0x3c048000, 0x00431025, 0xaf420020, 0x8f420020,
2367 0x00441024, 0x1440fffd, 0x00000000, 0x8f840000, 0x9083003f, 0x2402000a, 3350 0x00441024, 0x1440fffd, 0x00000000, 0x8f840000, 0x9083003f, 0x2402000a,
2368 0x10620005, 0x2402000c, 0x9083003f, 0x24020008, 0x14620002, 0x24020014, 3351 0x10620005, 0x2402000c, 0x9083003f, 0x24020008, 0x14620002, 0x24020014,
2369 0xa082003f, 0x8f830008, 0x3c028000, 0x34420001, 0x00621825, 0xaf430020, 3352 0xa082003f, 0x8f830008, 0x3c028000, 0x34420001, 0x00621825, 0xaf430020,
2370 0x3c040800, 0x24904120, 0x9602000c, 0x96030016, 0x9604000e, 0x00431021, 3353 0x3c040800, 0x24865880, 0x94c20010, 0x94c3001a, 0x8cc40008, 0x00432821,
2371 0x00442021, 0x24840002, 0x3084ffff, 0x0e000a55, 0xa6020018, 0x8f850018, 3354 0x14800006, 0xa4c5001c, 0x3c020800, 0x8c430048, 0x10600002, 0x24a20040,
2372 0x00a01821, 0xa2030021, 0x8ee60008, 0x00402021, 0x24a50001, 0xaf850018, 3355 0xa4c2001c, 0x27d05880, 0x9604001c, 0x96020012, 0x00822021, 0x24840002,
2373 0x00c0f809, 0x00000000, 0x00402021, 0x0e000b12, 0x02202821, 0x8ee3000c, 3356 0x0e000faf, 0x3084ffff, 0x8f850018, 0x00a01821, 0xa2030025, 0x8ee60008,
2374 0x0060f809, 0x00402021, 0x96040018, 0x9602000e, 0x00822021, 0x24840002, 3357 0x00402021, 0x24a50001, 0xaf850018, 0x00c0f809, 0x00000000, 0x00402021,
2375 0x0e000a6b, 0x3084ffff, 0x3c030800, 0x8c624120, 0x8e030008, 0x3c040800, 3358 0x0e001026, 0x02202821, 0x8ee3000c, 0x0060f809, 0x00402021, 0x9604001c,
2376 0x00431023, 0x14400012, 0xac824120, 0x54600006, 0x8e02001c, 0x3243004a, 3359 0x96020012, 0x00822021, 0x24840002, 0x0e000fc5, 0x3084ffff, 0x8fc25880,
2377 0x24020002, 0x14620005, 0x00000000, 0x8e02001c, 0x34420040, 0x0a000e0b, 3360 0x8e030008, 0x00431023, 0x14400012, 0xafc25880, 0x54600006, 0x8e020020,
2378 0xae02001c, 0x52a00006, 0x36520002, 0x8e02002c, 0xaf420e10, 0x8e030030, 3361 0x3243004a, 0x24020002, 0x14620005, 0x00000000, 0x8e020020, 0x34420040,
2379 0xaf430e18, 0x36520002, 0x52a00008, 0x96670010, 0x8f830000, 0x8f420e10, 3362 0x0a001382, 0xae020020, 0x52a00006, 0x36520002, 0x8e020030, 0xaf420e10,
2380 0xac6200a8, 0x8f840000, 0x8f420e18, 0xac8200ac, 0x96670010, 0x92680020, 3363 0x8e030034, 0xaf430e18, 0x36520002, 0x52a00008, 0x96670014, 0x8f830000,
2381 0x24020040, 0xaf420814, 0x8f830020, 0x8f82001c, 0x00671821, 0x00621023, 3364 0x8f420e10, 0xac6200a8, 0x8f840000, 0x8f420e18, 0xac8200ac, 0x96670014,
2382 0xaf830020, 0x58400005, 0x8f42095c, 0x8f820000, 0xaf83001c, 0xac430054, 3365 0x92680024, 0x24020040, 0xaf420814, 0x8f830020, 0x8f82001c, 0x00671821,
2383 0x8f42095c, 0x31030008, 0xaf82002c, 0x1060001a, 0x00000000, 0x8f840000, 3366 0x00621023, 0xaf830020, 0x18400008, 0x00000000, 0x8f820000, 0xaf83001c,
2384 0x90820120, 0x90830121, 0x304600ff, 0x00c31823, 0x30630007, 0x24020007, 3367 0xac430054, 0x54e00005, 0xaf400040, 0x0a0013a0, 0x8f42095c, 0x54e00001,
2385 0x1062000e, 0x00000000, 0x90820122, 0x304200fe, 0xa0820122, 0x8f850000, 3368 0xaf400044, 0x8f42095c, 0x31030008, 0xaf820030, 0x1060001a, 0x00000000,
2386 0x00061880, 0x8f840020, 0x24a20100, 0x00431021, 0x24c30001, 0x30630007, 3369 0x8f840000, 0x90820120, 0x90830121, 0x304600ff, 0x00c31823, 0x30630007,
2387 0xac440000, 0x0a000e40, 0xa0a30120, 0x90820122, 0x34420001, 0xa0820122, 3370 0x24020007, 0x1062000e, 0x00000000, 0x90820122, 0x304200fe, 0xa0820122,
2388 0x14e00003, 0x31020001, 0x10400031, 0x32510002, 0x8f820000, 0x8c43000c, 3371 0x8f850000, 0x00061880, 0x8f840020, 0x24a20100, 0x00431021, 0x24c30001,
2389 0x30630001, 0x1060002c, 0x32510002, 0x3c029000, 0x8f830008, 0x34420001, 3372 0x30630007, 0xac440000, 0x0a0013bd, 0xa0a30120, 0x90820122, 0x34420001,
2390 0x3c048000, 0x00621825, 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd, 3373 0xa0820122, 0x14e00003, 0x31020001, 0x10400031, 0x32510002, 0x8f820000,
2391 0x00000000, 0x8f870000, 0x8ce2000c, 0x30420001, 0x10400018, 0x00000000, 3374 0x8c43000c, 0x30630001, 0x1060002c, 0x32510002, 0x3c029000, 0x8f830008,
2392 0x94e2006a, 0x00022880, 0x50a00001, 0x24050001, 0x94e30068, 0x90e40081, 3375 0x34420001, 0x3c048000, 0x00621825, 0xaf430020, 0x8f420020, 0x00441024,
2393 0x3c020800, 0x8c460024, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 3376 0x1440fffd, 0x00000000, 0x8f870000, 0x8ce2000c, 0x30420001, 0x10400018,
2394 0x00a03021, 0x3c020800, 0x8c440028, 0x00c4182b, 0x54600001, 0x00c02021, 3377 0x00000000, 0x94e2006a, 0x00022880, 0x50a00001, 0x24050001, 0x94e30068,
2395 0x8f430074, 0x2402fffe, 0x00822824, 0x00a31821, 0xace3000c, 0x8f830008, 3378 0x90e40081, 0x3c020800, 0x8c460024, 0x00652821, 0x00852804, 0x00c5102b,
2396 0x3c028000, 0x34420001, 0x00621825, 0xaf430020, 0x8f830020, 0x3c020800, 3379 0x54400001, 0x00a03021, 0x3c020800, 0x8c440028, 0x00c4182b, 0x54600001,
2397 0x24504120, 0xae030024, 0x8ee20010, 0x0040f809, 0x00000000, 0x12a00005, 3380 0x00c02021, 0x8f430074, 0x2402fffe, 0x00822824, 0x00a31821, 0xace3000c,
2398 0x00000000, 0x8f420e10, 0xae02002c, 0x8f430e18, 0xae030030, 0x1220feba, 3381 0x8f830008, 0x3c028000, 0x34420001, 0x00621825, 0xaf430020, 0x8f820020,
2399 0x0000a821, 0x8f870024, 0x97860028, 0x8f830000, 0x8f820030, 0x8f840020, 3382 0x3c050800, 0x24b05880, 0xae020028, 0x8ee30010, 0x0060f809, 0x00000000,
2400 0x8f85001c, 0x32500040, 0xa4e6002c, 0xac620044, 0x32420008, 0xac640050, 3383 0x8f820028, 0x24420001, 0xaf820028, 0x12a00005, 0xaf40004c, 0x8f420e10,
2401 0xac650054, 0x1040007a, 0x32820020, 0x10400027, 0x32910010, 0x24072000, 3384 0xae020030, 0x8f430e18, 0xae030034, 0x1220fea7, 0x24020006, 0x8f870024,
2402 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec2414c, 3385 0x9786002c, 0x8f830000, 0x8f820034, 0x8f840020, 0x8f85001c, 0x32530040,
2403 0x26c4414c, 0x2484ffd4, 0xaf420144, 0x8c820030, 0x3c030400, 0xaf420148, 3386 0xa4e6002c, 0xac620044, 0x32420008, 0xac640050, 0xac650054, 0x1040007a,
2404 0x24020041, 0xaf43014c, 0x00001821, 0xa3420152, 0x3c021000, 0xa7430158, 3387 0x32820020, 0x10400027, 0x32910010, 0x00003821, 0x24052000, 0x3c090800,
2405 0xaf470154, 0xaf420178, 0x8ec5414c, 0x8d230030, 0x8c860030, 0x24630001, 3388 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec258b0, 0x26c458b0,
2406 0xad230030, 0x93420109, 0x9343010a, 0xafa70014, 0xafa00018, 0x00021600, 3389 0x2484ffd0, 0xaf420144, 0x8c820034, 0x3c030400, 0xaf420148, 0x24020041,
2407 0x00031c00, 0x00431025, 0x34424100, 0xafa20010, 0x8f440100, 0x0e000fe1, 3390 0xaf43014c, 0xa3420152, 0x8d230030, 0x3c021000, 0xa7470158, 0xaf450154,
2408 0x3c070400, 0x12200028, 0x24072000, 0x3c090800, 0x3c038000, 0x8f420178, 3391 0xaf420178, 0x8c860034, 0x24630001, 0xad230030, 0x9342010a, 0x3c030041,
2409 0x00431024, 0x1440fffd, 0x8ec2414c, 0x26c4414c, 0x2484ffd4, 0xaf420144, 3392 0xafa50014, 0x00021600, 0x00431025, 0x00471025, 0xafa20010, 0x9343010b,
2410 0x8c820030, 0x3c030300, 0xaf420148, 0x2402004e, 0xaf43014c, 0x00001821, 3393 0xafa30018, 0x8f440100, 0x8f450104, 0x0e00159b, 0x3c070400, 0x12200028,
2411 0xa3420152, 0x3c021000, 0xa7430158, 0xaf470154, 0xaf420178, 0x8ec5414c, 3394 0x00003821, 0x24052000, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024,
2412 0x8d230030, 0x8c860030, 0x24630001, 0xad230030, 0x93420109, 0x9343010a, 3395 0x1440fffd, 0x8ec258b0, 0x26c458b0, 0x2484ffd0, 0xaf420144, 0x8c820034,
2413 0xafa70014, 0xafa00018, 0x00021600, 0x00031c00, 0x00431025, 0x34424e00, 3396 0x3c030300, 0xaf420148, 0x2402004e, 0xaf43014c, 0xa3420152, 0x8d230030,
2414 0xafa20010, 0x8f440100, 0x0e000fe1, 0x3c070300, 0x0a000f0b, 0x8fa30024, 3397 0x3c021000, 0xa7470158, 0xaf450154, 0xaf420178, 0x8c860034, 0x24630001,
2415 0x32820008, 0x10400026, 0x3c090800, 0x24072000, 0x3c038000, 0x8f420178, 3398 0xad230030, 0x9342010a, 0x3c03004e, 0xafa50014, 0x00021600, 0x00431025,
2416 0x00431024, 0x1440fffd, 0x8ec2414c, 0x26c4414c, 0x2484ffd4, 0xaf420144, 3399 0x00471025, 0xafa20010, 0x9343010b, 0xafa30018, 0x8f440100, 0x8f450104,
2417 0x8c820030, 0x3c030200, 0xaf420148, 0x2402004b, 0xaf43014c, 0x00001821, 3400 0x0e00159b, 0x3c070300, 0x0a00148b, 0x8fa20024, 0x32820008, 0x10400026,
2418 0xa3420152, 0x3c021000, 0xa7430158, 0xaf470154, 0xaf420178, 0x8ec5414c, 3401 0x24052000, 0x00003821, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024,
2419 0x8d230030, 0x8c860030, 0x24630001, 0xad230030, 0x93420109, 0x9343010a, 3402 0x1440fffd, 0x8ec258b0, 0x26c458b0, 0x2484ffd0, 0xaf420144, 0x8c820034,
2420 0xafa70014, 0xafa00018, 0x00021600, 0x00031c00, 0x00431025, 0x34424b00, 3403 0x3c030200, 0xaf420148, 0x2402004b, 0xaf43014c, 0xa3420152, 0x8d230030,
2421 0xafa20010, 0x8f440100, 0x0e000fe1, 0x3c070200, 0x8fa30024, 0x14600004, 3404 0x3c021000, 0xa7470158, 0xaf450154, 0xaf420178, 0x8c860034, 0x24630001,
2422 0x8fa40020, 0x32420010, 0x10400004, 0x00000000, 0x8c820004, 0x0040f809, 3405 0xad230030, 0x9342010a, 0x3c03004b, 0xafa50014, 0x00021600, 0x00431025,
2423 0x00000000, 0x12000006, 0x8fa30020, 0x8c620008, 0x0040f809, 0x00000000, 3406 0x00471025, 0xafa20010, 0x9343010b, 0xafa30018, 0x8f440100, 0x8f450104,
2424 0x0a000f4d, 0x8fbf004c, 0x3c030800, 0x8c62413c, 0x30420040, 0x1440002f, 3407 0x0e00159b, 0x3c070200, 0x8fa20024, 0x14400004, 0x8fa30020, 0x32420010,
2425 0x8fbf004c, 0x24040040, 0x8f910020, 0x3c038000, 0x8f420178, 0x00431024, 3408 0x10400004, 0x00000000, 0x8c620004, 0x0040f809, 0x00000000, 0x12600006,
2426 0x1440fffd, 0x8ec2414c, 0x26d0414c, 0x2610ffd4, 0xaf420144, 0x8e020030, 3409 0x8fa40020, 0x8c820008, 0x0040f809, 0x00000000, 0x0a0014c1, 0x8fbf0054,
2427 0x00001821, 0xaf420148, 0x24020049, 0xaf51014c, 0xa3420152, 0x3c021000, 3410 0x3c030800, 0x8c6258a0, 0x30420040, 0x14400023, 0x8fbf0054, 0x00002821,
2428 0xa7430158, 0xaf440154, 0xaf420178, 0x8ec5414c, 0x8e060030, 0x93420109, 3411 0x24040040, 0x8f870020, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd,
2429 0x9343010a, 0xafa40014, 0xafa00018, 0x00021600, 0x00031c00, 0x00431025, 3412 0x8ec258b0, 0x26c358b0, 0x2463ffd0, 0xaf420144, 0x8c620034, 0xaf420148,
2430 0x34424900, 0xafa20010, 0x8f440100, 0x0e000fe1, 0x02203821, 0x8f830000, 3413 0x24020049, 0xaf47014c, 0xa3420152, 0x3c021000, 0xa7450158, 0xaf440154,
2431 0x8e020030, 0x8c64017c, 0x02221023, 0x00441023, 0x2c420002, 0x14400005, 3414 0xaf420178, 0x8c660034, 0x9342010a, 0x3c030049, 0xafa40014, 0x00021600,
2432 0x8fbf004c, 0x0000000d, 0x00000000, 0x240000ca, 0x8fbf004c, 0x8fbe0048, 3415 0x00431025, 0x00451025, 0xafa20010, 0x9343010b, 0xafa30018, 0x8f440100,
2433 0x8fb70044, 0x8fb60040, 0x8fb5003c, 0x8fb40038, 0x8fb30034, 0x8fb20030, 3416 0x0e00159b, 0x8f450104, 0x8fbf0054, 0x8fbe0050, 0x8fb7004c, 0x8fb60048,
2434 0x8fb1002c, 0x8fb00028, 0x03e00008, 0x27bd0050, 0x03e00008, 0x00001021, 3417 0x8fb50044, 0x8fb40040, 0x8fb3003c, 0x8fb20038, 0x8fb10034, 0x8fb00030,
2435 0x3c030800, 0x24654120, 0x8ca40004, 0x8c634120, 0x0064102b, 0x54400001, 3418 0x03e00008, 0x27bd0058, 0x03e00008, 0x00001021, 0x3c020800, 0x24435880,
2436 0x00602021, 0x9743093c, 0x0083102b, 0x54400001, 0x00801821, 0x00001021, 3419 0x8c650004, 0x8c445880, 0x0085182b, 0x10600002, 0x00403021, 0x00802821,
2437 0xaca30008, 0x03e00008, 0xa4a00022, 0x8f850004, 0x97840010, 0x3c030800, 3420 0x9744093c, 0x00a4102b, 0x54400001, 0x00a02021, 0x93420923, 0x0004182b,
2438 0x24634120, 0x24020008, 0xa462000e, 0x8f820004, 0xa460000c, 0x000420c2, 3421 0x00021042, 0x30420001, 0x00431024, 0x1040000d, 0x24c25880, 0x8f850000,
3422 0x8f830020, 0x8ca20084, 0x00431023, 0x04420007, 0x24c25880, 0x8ca20084,
3423 0x00641821, 0x00431023, 0x28420001, 0x00822023, 0x24c25880, 0xac440008,
3424 0xa4400026, 0x03e00008, 0x00001021, 0x8f850004, 0x97840010, 0x3c030800,
3425 0x24635880, 0x24020008, 0xa4620012, 0x8f820004, 0xa4600010, 0x000420c2,
2439 0x30840008, 0x2c420001, 0x00021023, 0x30420006, 0xac650008, 0x03e00008, 3426 0x30840008, 0x2c420001, 0x00021023, 0x30420006, 0xac650008, 0x03e00008,
2440 0xa0640020, 0x3c020800, 0x24424120, 0x90450021, 0x94430018, 0x3c021100, 3427 0xa0640024, 0x3c020800, 0x24425880, 0x90450025, 0x9443001c, 0x3c021100,
2441 0xac800004, 0x00052c00, 0x24630002, 0x00621825, 0x00a32825, 0x24820008, 3428 0xac800004, 0x00052c00, 0x24630002, 0x00621825, 0x00a32825, 0x24820008,
2442 0x03e00008, 0xac850000, 0x0000000d, 0x00000000, 0x2400016f, 0x03e00008, 3429 0x03e00008, 0xac850000, 0x27bdffd8, 0x3c020800, 0x24425880, 0xafbf0020,
2443 0x00000000, 0x0000000d, 0x00000000, 0x2400017b, 0x03e00008, 0x00000000, 3430 0x90480025, 0x8c440008, 0x8c460020, 0x8f870020, 0x3c030800, 0x3c058000,
2444 0x03e00008, 0x00000000, 0x3c020800, 0x24424120, 0xac400008, 0xa4400022, 3431 0x8f420178, 0x00451024, 0x1440fffd, 0x8c6258b0, 0x246358b0, 0x2469ffd0,
2445 0x03e00008, 0x24020001, 0x3c020800, 0x24424120, 0x24030008, 0xac400008, 3432 0xaf420144, 0x8d220034, 0x30c32000, 0xaf420148, 0x3c021000, 0xaf47014c,
2446 0xa440000c, 0xa443000e, 0xa0400020, 0x03e00008, 0x24020004, 0x03e00008, 3433 0xa3480152, 0xa7440158, 0xaf460154, 0xaf420178, 0x10600004, 0x3c030800,
3434 0x8c620030, 0x24420001, 0xac620030, 0x9342010a, 0x00081c00, 0x3084ffff,
3435 0xafa60014, 0x00021600, 0x00431025, 0x00441025, 0xafa20010, 0x9343010b,
3436 0xafa30018, 0x8f440100, 0x8f450104, 0x0e00159b, 0x8d260034, 0x8fbf0020,
3437 0x03e00008, 0x27bd0028, 0x0000000d, 0x00000000, 0x2400019d, 0x03e00008,
3438 0x00000000, 0x0000000d, 0x00000000, 0x240001a9, 0x03e00008, 0x00000000,
3439 0x03e00008, 0x00000000, 0x3c020800, 0x24425880, 0xac400008, 0xa4400026,
3440 0x03e00008, 0x24020001, 0x3c020800, 0x24425880, 0x24030008, 0xac400008,
3441 0xa4400010, 0xa4430012, 0xa0400024, 0x03e00008, 0x24020004, 0x03e00008,
2447 0x00001021, 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 3442 0x00001021, 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004,
2448 0xac820000, 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a000fb2, 3443 0xac820000, 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a00156c,
2449 0x00a01021, 0xac860000, 0x24840004, 0x00a01021, 0x1440fffc, 0x24a5ffff, 3444 0x00a01021, 0xac860000, 0x00000000, 0x00000000, 0x24840004, 0x00a01021,
2450 0x03e00008, 0x00000000, 0x3c0a0800, 0x8d490068, 0x3c050800, 0x24a51090, 3445 0x1440fffa, 0x24a5ffff, 0x03e00008, 0x00000000, 0x3c0a0800, 0x8d490068,
2451 0x00093140, 0x00c51021, 0xac440000, 0x8f440e04, 0x00a61021, 0xac440004, 3446 0x3c050800, 0x24a52098, 0x00093140, 0x00c51021, 0xac440000, 0x8f440e04,
2452 0x97430e08, 0x97420e0c, 0x00a62021, 0x00031c00, 0x00431025, 0xac820008, 3447 0x00a61021, 0xac440004, 0x97430e08, 0x97420e0c, 0x00a62021, 0x00031c00,
2453 0x8f430e10, 0x00801021, 0xac43000c, 0x8f440e14, 0xac440010, 0x8f430e18, 3448 0x00431025, 0xac820008, 0x8f430e10, 0x00801021, 0xac43000c, 0x8f440e14,
2454 0x3c0800ff, 0xac430014, 0x8f470e1c, 0x3508ffff, 0x25290001, 0xac470018, 3449 0xac440010, 0x8f430e18, 0x3c0800ff, 0xac430014, 0x8f470e1c, 0x3508ffff,
2455 0x3c070800, 0x8ce3006c, 0x9344010a, 0x3c026000, 0x24630001, 0xace3006c, 3450 0x25290001, 0xac470018, 0x3c070800, 0x8ce3006c, 0x9344010a, 0x3c026000,
2456 0x8c434448, 0x3129007f, 0x00a62821, 0xad490068, 0x00042600, 0x00681824, 3451 0x24630001, 0xace3006c, 0x8c434448, 0x3129007f, 0x00a62821, 0xad490068,
2457 0x00832025, 0x03e00008, 0xaca4001c, 0x8fac0010, 0x8fad0014, 0x8fae0018, 3452 0x00042600, 0x00681824, 0x00832025, 0x03e00008, 0xaca4001c, 0x8fac0010,
2458 0x3c0b0800, 0x8d6a0060, 0x3c080800, 0x25080078, 0x000a4940, 0x01281021, 3453 0x8fad0014, 0x8fae0018, 0x3c0b0800, 0x8d6a0060, 0x3c080800, 0x25080080,
2459 0x01091821, 0xac440000, 0x00601021, 0xac650004, 0xac460008, 0xac67000c, 3454 0x000a4940, 0x01281021, 0x01091821, 0xac440000, 0x00601021, 0xac650004,
2460 0xac4c0010, 0xac6d0014, 0x3c036000, 0xac4e0018, 0x8c654448, 0x3c040800, 3455 0xac460008, 0xac67000c, 0xac4c0010, 0xac6d0014, 0x3c036000, 0xac4e0018,
2461 0x8c820064, 0x254a0001, 0x314a007f, 0x01094021, 0xad6a0060, 0x24420001, 3456 0x8c654448, 0x3c040800, 0x8c820064, 0x254a0001, 0x314a00ff, 0x01094021,
2462 0xac820064, 0x03e00008, 0xad05001c, 0x00000000 }; 3457 0xad6a0060, 0x24420001, 0xac820064, 0x03e00008, 0xad05001c, 0x3c030800,
2463 3458 0x3c090800, 0x8d250070, 0x246330b0, 0x8f460100, 0x00053900, 0x00e31021,
2464static u32 bnx2_TXP_b06FwData[(0x0/4) + 1] = { 0x00000000 }; 3459 0xac460000, 0x8f440104, 0x00671021, 0xac440004, 0x8f460108, 0x8f840014,
2465static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x00000000 }; 3460 0x24a50001, 0xac460008, 0x8c880074, 0x3c060800, 0x8cc20074, 0x30a5003f,
2466static u32 bnx2_TXP_b06FwBss[(0x194/4) + 1] = { 0x00000000 }; 3461 0x00671821, 0xad250070, 0x24420001, 0xacc20074, 0x03e00008, 0xac68000c,
2467static u32 bnx2_TXP_b06FwSbss[(0x34/4) + 1] = { 0x00000000 }; 3462 0x00000000 };
2468 3463
3464static u32 bnx2_TXP_b06FwData[(0x0/4) + 1] = { 0x0 };
3465static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x0 };
3466static u32 bnx2_TXP_b06FwBss[(0x1c4/4) + 1] = { 0x0 };
3467static u32 bnx2_TXP_b06FwSbss[(0x38/4) + 1] = { 0x0 };
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 4d26e5e7d18b..0d33a93df96b 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -1470,15 +1470,6 @@ static int __init depca_mca_probe(struct device *device)
1470** ISA bus I/O device probe 1470** ISA bus I/O device probe
1471*/ 1471*/
1472 1472
1473static void depca_platform_release (struct device *device)
1474{
1475 struct platform_device *pldev;
1476
1477 /* free device */
1478 pldev = to_platform_device (device);
1479 kfree (pldev);
1480}
1481
1482static void __init depca_platform_probe (void) 1473static void __init depca_platform_probe (void)
1483{ 1474{
1484 int i; 1475 int i;
@@ -1491,19 +1482,16 @@ static void __init depca_platform_probe (void)
1491 * line, use it (if valid) */ 1482 * line, use it (if valid) */
1492 if (io && io != depca_io_ports[i].iobase) 1483 if (io && io != depca_io_ports[i].iobase)
1493 continue; 1484 continue;
1494 1485
1495 if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) 1486 pldev = platform_device_alloc(depca_string, i);
1487 if (!pldev)
1496 continue; 1488 continue;
1497 1489
1498 memset (pldev, 0, sizeof (*pldev));
1499 pldev->name = depca_string;
1500 pldev->id = i;
1501 pldev->dev.platform_data = (void *) depca_io_ports[i].iobase; 1490 pldev->dev.platform_data = (void *) depca_io_ports[i].iobase;
1502 pldev->dev.release = depca_platform_release;
1503 depca_io_ports[i].device = pldev; 1491 depca_io_ports[i].device = pldev;
1504 1492
1505 if (platform_device_register (pldev)) { 1493 if (platform_device_add(pldev)) {
1506 kfree (pldev); 1494 platform_device_put(pldev);
1507 depca_io_ports[i].device = NULL; 1495 depca_io_ports[i].device = NULL;
1508 continue; 1496 continue;
1509 } 1497 }
@@ -1515,6 +1503,7 @@ static void __init depca_platform_probe (void)
1515 * allocated structure */ 1503 * allocated structure */
1516 1504
1517 depca_io_ports[i].device = NULL; 1505 depca_io_ports[i].device = NULL;
1506 pldev->dev.platform_data = NULL;
1518 platform_device_unregister (pldev); 1507 platform_device_unregister (pldev);
1519 } 1508 }
1520 } 1509 }
@@ -2112,6 +2101,7 @@ static void __exit depca_module_exit (void)
2112 2101
2113 for (i = 0; depca_io_ports[i].iobase; i++) { 2102 for (i = 0; depca_io_ports[i].iobase; i++) {
2114 if (depca_io_ports[i].device) { 2103 if (depca_io_ports[i].device) {
2104 depca_io_ports[i].device->dev.platform_data = NULL;
2115 platform_device_unregister (depca_io_ports[i].device); 2105 platform_device_unregister (depca_io_ports[i].device);
2116 depca_io_ports[i].device = NULL; 2106 depca_io_ports[i].device = NULL;
2117 } 2107 }
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 9c7feaeaa6a4..8eae8ba27e84 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1739,7 +1739,7 @@ e1000_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
1739 } 1739 }
1740} 1740}
1741 1741
1742struct ethtool_ops e1000_ethtool_ops = { 1742static struct ethtool_ops e1000_ethtool_ops = {
1743 .get_settings = e1000_get_settings, 1743 .get_settings = e1000_get_settings,
1744 .set_settings = e1000_set_settings, 1744 .set_settings = e1000_set_settings,
1745 .get_drvinfo = e1000_get_drvinfo, 1745 .get_drvinfo = e1000_get_drvinfo,
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 8fc876da43b4..a267c5235fc0 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -68,6 +68,38 @@ static int32_t e1000_polarity_reversal_workaround(struct e1000_hw *hw);
68static int32_t e1000_set_phy_mode(struct e1000_hw *hw); 68static int32_t e1000_set_phy_mode(struct e1000_hw *hw);
69static int32_t e1000_host_if_read_cookie(struct e1000_hw *hw, uint8_t *buffer); 69static int32_t e1000_host_if_read_cookie(struct e1000_hw *hw, uint8_t *buffer);
70static uint8_t e1000_calculate_mng_checksum(char *buffer, uint32_t length); 70static uint8_t e1000_calculate_mng_checksum(char *buffer, uint32_t length);
71static uint8_t e1000_arc_subsystem_valid(struct e1000_hw *hw);
72static int32_t e1000_check_downshift(struct e1000_hw *hw);
73static int32_t e1000_check_polarity(struct e1000_hw *hw, uint16_t *polarity);
74static void e1000_clear_hw_cntrs(struct e1000_hw *hw);
75static void e1000_clear_vfta(struct e1000_hw *hw);
76static int32_t e1000_commit_shadow_ram(struct e1000_hw *hw);
77static int32_t e1000_config_dsp_after_link_change(struct e1000_hw *hw,
78 boolean_t link_up);
79static int32_t e1000_config_fc_after_link_up(struct e1000_hw *hw);
80static int32_t e1000_detect_gig_phy(struct e1000_hw *hw);
81static int32_t e1000_get_auto_rd_done(struct e1000_hw *hw);
82static int32_t e1000_get_cable_length(struct e1000_hw *hw,
83 uint16_t *min_length,
84 uint16_t *max_length);
85static int32_t e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw);
86static int32_t e1000_get_phy_cfg_done(struct e1000_hw *hw);
87static int32_t e1000_id_led_init(struct e1000_hw * hw);
88static void e1000_init_rx_addrs(struct e1000_hw *hw);
89static boolean_t e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw);
90static int32_t e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd);
91static void e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw);
92static int32_t e1000_read_eeprom_eerd(struct e1000_hw *hw, uint16_t offset,
93 uint16_t words, uint16_t *data);
94static int32_t e1000_set_d0_lplu_state(struct e1000_hw *hw, boolean_t active);
95static int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
96static int32_t e1000_wait_autoneg(struct e1000_hw *hw);
97
98static void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset,
99 uint32_t value);
100
101#define E1000_WRITE_REG_IO(a, reg, val) \
102 e1000_write_reg_io((a), E1000_##reg, val)
71 103
72/* IGP cable length table */ 104/* IGP cable length table */
73static const 105static const
@@ -2035,7 +2067,7 @@ e1000_force_mac_fc(struct e1000_hw *hw)
2035 * based on the flow control negotiated by the PHY. In TBI mode, the TFCE 2067 * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
2036 * and RFCE bits will be automaticaly set to the negotiated flow control mode. 2068 * and RFCE bits will be automaticaly set to the negotiated flow control mode.
2037 *****************************************************************************/ 2069 *****************************************************************************/
2038int32_t 2070static int32_t
2039e1000_config_fc_after_link_up(struct e1000_hw *hw) 2071e1000_config_fc_after_link_up(struct e1000_hw *hw)
2040{ 2072{
2041 int32_t ret_val; 2073 int32_t ret_val;
@@ -2537,7 +2569,7 @@ e1000_get_speed_and_duplex(struct e1000_hw *hw,
2537* 2569*
2538* hw - Struct containing variables accessed by shared code 2570* hw - Struct containing variables accessed by shared code
2539******************************************************************************/ 2571******************************************************************************/
2540int32_t 2572static int32_t
2541e1000_wait_autoneg(struct e1000_hw *hw) 2573e1000_wait_autoneg(struct e1000_hw *hw)
2542{ 2574{
2543 int32_t ret_val; 2575 int32_t ret_val;
@@ -3021,7 +3053,7 @@ e1000_phy_reset(struct e1000_hw *hw)
3021* 3053*
3022* hw - Struct containing variables accessed by shared code 3054* hw - Struct containing variables accessed by shared code
3023******************************************************************************/ 3055******************************************************************************/
3024int32_t 3056static int32_t
3025e1000_detect_gig_phy(struct e1000_hw *hw) 3057e1000_detect_gig_phy(struct e1000_hw *hw)
3026{ 3058{
3027 int32_t phy_init_status, ret_val; 3059 int32_t phy_init_status, ret_val;
@@ -3121,7 +3153,7 @@ e1000_phy_reset_dsp(struct e1000_hw *hw)
3121* hw - Struct containing variables accessed by shared code 3153* hw - Struct containing variables accessed by shared code
3122* phy_info - PHY information structure 3154* phy_info - PHY information structure
3123******************************************************************************/ 3155******************************************************************************/
3124int32_t 3156static int32_t
3125e1000_phy_igp_get_info(struct e1000_hw *hw, 3157e1000_phy_igp_get_info(struct e1000_hw *hw,
3126 struct e1000_phy_info *phy_info) 3158 struct e1000_phy_info *phy_info)
3127{ 3159{
@@ -3195,7 +3227,7 @@ e1000_phy_igp_get_info(struct e1000_hw *hw,
3195* hw - Struct containing variables accessed by shared code 3227* hw - Struct containing variables accessed by shared code
3196* phy_info - PHY information structure 3228* phy_info - PHY information structure
3197******************************************************************************/ 3229******************************************************************************/
3198int32_t 3230static int32_t
3199e1000_phy_m88_get_info(struct e1000_hw *hw, 3231e1000_phy_m88_get_info(struct e1000_hw *hw,
3200 struct e1000_phy_info *phy_info) 3232 struct e1000_phy_info *phy_info)
3201{ 3233{
@@ -3905,7 +3937,7 @@ e1000_read_eeprom(struct e1000_hw *hw,
3905 * data - word read from the EEPROM 3937 * data - word read from the EEPROM
3906 * words - number of words to read 3938 * words - number of words to read
3907 *****************************************************************************/ 3939 *****************************************************************************/
3908int32_t 3940static int32_t
3909e1000_read_eeprom_eerd(struct e1000_hw *hw, 3941e1000_read_eeprom_eerd(struct e1000_hw *hw,
3910 uint16_t offset, 3942 uint16_t offset,
3911 uint16_t words, 3943 uint16_t words,
@@ -3939,7 +3971,7 @@ e1000_read_eeprom_eerd(struct e1000_hw *hw,
3939 * data - word read from the EEPROM 3971 * data - word read from the EEPROM
3940 * words - number of words to read 3972 * words - number of words to read
3941 *****************************************************************************/ 3973 *****************************************************************************/
3942int32_t 3974static int32_t
3943e1000_write_eeprom_eewr(struct e1000_hw *hw, 3975e1000_write_eeprom_eewr(struct e1000_hw *hw,
3944 uint16_t offset, 3976 uint16_t offset,
3945 uint16_t words, 3977 uint16_t words,
@@ -3976,7 +4008,7 @@ e1000_write_eeprom_eewr(struct e1000_hw *hw,
3976 * 4008 *
3977 * hw - Struct containing variables accessed by shared code 4009 * hw - Struct containing variables accessed by shared code
3978 *****************************************************************************/ 4010 *****************************************************************************/
3979int32_t 4011static int32_t
3980e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd) 4012e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd)
3981{ 4013{
3982 uint32_t attempts = 100000; 4014 uint32_t attempts = 100000;
@@ -4004,7 +4036,7 @@ e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd)
4004* 4036*
4005* hw - Struct containing variables accessed by shared code 4037* hw - Struct containing variables accessed by shared code
4006****************************************************************************/ 4038****************************************************************************/
4007boolean_t 4039static boolean_t
4008e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw) 4040e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw)
4009{ 4041{
4010 uint32_t eecd = 0; 4042 uint32_t eecd = 0;
@@ -4322,7 +4354,7 @@ e1000_write_eeprom_microwire(struct e1000_hw *hw,
4322 * data - word read from the EEPROM 4354 * data - word read from the EEPROM
4323 * words - number of words to read 4355 * words - number of words to read
4324 *****************************************************************************/ 4356 *****************************************************************************/
4325int32_t 4357static int32_t
4326e1000_commit_shadow_ram(struct e1000_hw *hw) 4358e1000_commit_shadow_ram(struct e1000_hw *hw)
4327{ 4359{
4328 uint32_t attempts = 100000; 4360 uint32_t attempts = 100000;
@@ -4453,7 +4485,7 @@ e1000_read_mac_addr(struct e1000_hw * hw)
4453 * of the receive addresss registers. Clears the multicast table. Assumes 4485 * of the receive addresss registers. Clears the multicast table. Assumes
4454 * the receiver is in reset when the routine is called. 4486 * the receiver is in reset when the routine is called.
4455 *****************************************************************************/ 4487 *****************************************************************************/
4456void 4488static void
4457e1000_init_rx_addrs(struct e1000_hw *hw) 4489e1000_init_rx_addrs(struct e1000_hw *hw)
4458{ 4490{
4459 uint32_t i; 4491 uint32_t i;
@@ -4481,6 +4513,7 @@ e1000_init_rx_addrs(struct e1000_hw *hw)
4481 } 4513 }
4482} 4514}
4483 4515
4516#if 0
4484/****************************************************************************** 4517/******************************************************************************
4485 * Updates the MAC's list of multicast addresses. 4518 * Updates the MAC's list of multicast addresses.
4486 * 4519 *
@@ -4564,6 +4597,7 @@ e1000_mc_addr_list_update(struct e1000_hw *hw,
4564 } 4597 }
4565 DEBUGOUT("MC Update Complete\n"); 4598 DEBUGOUT("MC Update Complete\n");
4566} 4599}
4600#endif /* 0 */
4567 4601
4568/****************************************************************************** 4602/******************************************************************************
4569 * Hashes an address to determine its location in the multicast table 4603 * Hashes an address to determine its location in the multicast table
@@ -4705,7 +4739,7 @@ e1000_write_vfta(struct e1000_hw *hw,
4705 * 4739 *
4706 * hw - Struct containing variables accessed by shared code 4740 * hw - Struct containing variables accessed by shared code
4707 *****************************************************************************/ 4741 *****************************************************************************/
4708void 4742static void
4709e1000_clear_vfta(struct e1000_hw *hw) 4743e1000_clear_vfta(struct e1000_hw *hw)
4710{ 4744{
4711 uint32_t offset; 4745 uint32_t offset;
@@ -4735,7 +4769,7 @@ e1000_clear_vfta(struct e1000_hw *hw)
4735 } 4769 }
4736} 4770}
4737 4771
4738int32_t 4772static int32_t
4739e1000_id_led_init(struct e1000_hw * hw) 4773e1000_id_led_init(struct e1000_hw * hw)
4740{ 4774{
4741 uint32_t ledctl; 4775 uint32_t ledctl;
@@ -4997,7 +5031,7 @@ e1000_led_off(struct e1000_hw *hw)
4997 * 5031 *
4998 * hw - Struct containing variables accessed by shared code 5032 * hw - Struct containing variables accessed by shared code
4999 *****************************************************************************/ 5033 *****************************************************************************/
5000void 5034static void
5001e1000_clear_hw_cntrs(struct e1000_hw *hw) 5035e1000_clear_hw_cntrs(struct e1000_hw *hw)
5002{ 5036{
5003 volatile uint32_t temp; 5037 volatile uint32_t temp;
@@ -5283,6 +5317,8 @@ e1000_get_bus_info(struct e1000_hw *hw)
5283 break; 5317 break;
5284 } 5318 }
5285} 5319}
5320
5321#if 0
5286/****************************************************************************** 5322/******************************************************************************
5287 * Reads a value from one of the devices registers using port I/O (as opposed 5323 * Reads a value from one of the devices registers using port I/O (as opposed
5288 * memory mapped I/O). Only 82544 and newer devices support port I/O. 5324 * memory mapped I/O). Only 82544 and newer devices support port I/O.
@@ -5300,6 +5336,7 @@ e1000_read_reg_io(struct e1000_hw *hw,
5300 e1000_io_write(hw, io_addr, offset); 5336 e1000_io_write(hw, io_addr, offset);
5301 return e1000_io_read(hw, io_data); 5337 return e1000_io_read(hw, io_data);
5302} 5338}
5339#endif /* 0 */
5303 5340
5304/****************************************************************************** 5341/******************************************************************************
5305 * Writes a value to one of the devices registers using port I/O (as opposed to 5342 * Writes a value to one of the devices registers using port I/O (as opposed to
@@ -5309,7 +5346,7 @@ e1000_read_reg_io(struct e1000_hw *hw,
5309 * offset - offset to write to 5346 * offset - offset to write to
5310 * value - value to write 5347 * value - value to write
5311 *****************************************************************************/ 5348 *****************************************************************************/
5312void 5349static void
5313e1000_write_reg_io(struct e1000_hw *hw, 5350e1000_write_reg_io(struct e1000_hw *hw,
5314 uint32_t offset, 5351 uint32_t offset,
5315 uint32_t value) 5352 uint32_t value)
@@ -5337,7 +5374,7 @@ e1000_write_reg_io(struct e1000_hw *hw,
5337 * register to the minimum and maximum range. 5374 * register to the minimum and maximum range.
5338 * For IGP phy's, the function calculates the range by the AGC registers. 5375 * For IGP phy's, the function calculates the range by the AGC registers.
5339 *****************************************************************************/ 5376 *****************************************************************************/
5340int32_t 5377static int32_t
5341e1000_get_cable_length(struct e1000_hw *hw, 5378e1000_get_cable_length(struct e1000_hw *hw,
5342 uint16_t *min_length, 5379 uint16_t *min_length,
5343 uint16_t *max_length) 5380 uint16_t *max_length)
@@ -5489,7 +5526,7 @@ e1000_get_cable_length(struct e1000_hw *hw,
5489 * return 0. If the link speed is 1000 Mbps the polarity status is in the 5526 * return 0. If the link speed is 1000 Mbps the polarity status is in the
5490 * IGP01E1000_PHY_PCS_INIT_REG. 5527 * IGP01E1000_PHY_PCS_INIT_REG.
5491 *****************************************************************************/ 5528 *****************************************************************************/
5492int32_t 5529static int32_t
5493e1000_check_polarity(struct e1000_hw *hw, 5530e1000_check_polarity(struct e1000_hw *hw,
5494 uint16_t *polarity) 5531 uint16_t *polarity)
5495{ 5532{
@@ -5551,7 +5588,7 @@ e1000_check_polarity(struct e1000_hw *hw,
5551 * Link Health register. In IGP this bit is latched high, so the driver must 5588 * Link Health register. In IGP this bit is latched high, so the driver must
5552 * read it immediately after link is established. 5589 * read it immediately after link is established.
5553 *****************************************************************************/ 5590 *****************************************************************************/
5554int32_t 5591static int32_t
5555e1000_check_downshift(struct e1000_hw *hw) 5592e1000_check_downshift(struct e1000_hw *hw)
5556{ 5593{
5557 int32_t ret_val; 5594 int32_t ret_val;
@@ -5592,7 +5629,7 @@ e1000_check_downshift(struct e1000_hw *hw)
5592 * 5629 *
5593 ****************************************************************************/ 5630 ****************************************************************************/
5594 5631
5595int32_t 5632static int32_t
5596e1000_config_dsp_after_link_change(struct e1000_hw *hw, 5633e1000_config_dsp_after_link_change(struct e1000_hw *hw,
5597 boolean_t link_up) 5634 boolean_t link_up)
5598{ 5635{
@@ -5823,7 +5860,7 @@ e1000_set_phy_mode(struct e1000_hw *hw)
5823 * 5860 *
5824 ****************************************************************************/ 5861 ****************************************************************************/
5825 5862
5826int32_t 5863static int32_t
5827e1000_set_d3_lplu_state(struct e1000_hw *hw, 5864e1000_set_d3_lplu_state(struct e1000_hw *hw,
5828 boolean_t active) 5865 boolean_t active)
5829{ 5866{
@@ -5936,7 +5973,7 @@ e1000_set_d3_lplu_state(struct e1000_hw *hw,
5936 * 5973 *
5937 ****************************************************************************/ 5974 ****************************************************************************/
5938 5975
5939int32_t 5976static int32_t
5940e1000_set_d0_lplu_state(struct e1000_hw *hw, 5977e1000_set_d0_lplu_state(struct e1000_hw *hw,
5941 boolean_t active) 5978 boolean_t active)
5942{ 5979{
@@ -6103,7 +6140,7 @@ e1000_host_if_read_cookie(struct e1000_hw * hw, uint8_t *buffer)
6103 * timeout 6140 * timeout
6104 * - E1000_SUCCESS for success. 6141 * - E1000_SUCCESS for success.
6105 ****************************************************************************/ 6142 ****************************************************************************/
6106int32_t 6143static int32_t
6107e1000_mng_enable_host_if(struct e1000_hw * hw) 6144e1000_mng_enable_host_if(struct e1000_hw * hw)
6108{ 6145{
6109 uint32_t hicr; 6146 uint32_t hicr;
@@ -6137,7 +6174,7 @@ e1000_mng_enable_host_if(struct e1000_hw * hw)
6137 * 6174 *
6138 * returns - E1000_SUCCESS for success. 6175 * returns - E1000_SUCCESS for success.
6139 ****************************************************************************/ 6176 ****************************************************************************/
6140int32_t 6177static int32_t
6141e1000_mng_host_if_write(struct e1000_hw * hw, uint8_t *buffer, 6178e1000_mng_host_if_write(struct e1000_hw * hw, uint8_t *buffer,
6142 uint16_t length, uint16_t offset, uint8_t *sum) 6179 uint16_t length, uint16_t offset, uint8_t *sum)
6143{ 6180{
@@ -6205,7 +6242,7 @@ e1000_mng_host_if_write(struct e1000_hw * hw, uint8_t *buffer,
6205 * 6242 *
6206 * returns - E1000_SUCCESS for success. 6243 * returns - E1000_SUCCESS for success.
6207 ****************************************************************************/ 6244 ****************************************************************************/
6208int32_t 6245static int32_t
6209e1000_mng_write_cmd_header(struct e1000_hw * hw, 6246e1000_mng_write_cmd_header(struct e1000_hw * hw,
6210 struct e1000_host_mng_command_header * hdr) 6247 struct e1000_host_mng_command_header * hdr)
6211{ 6248{
@@ -6243,7 +6280,7 @@ e1000_mng_write_cmd_header(struct e1000_hw * hw,
6243 * 6280 *
6244 * returns - E1000_SUCCESS for success. 6281 * returns - E1000_SUCCESS for success.
6245 ****************************************************************************/ 6282 ****************************************************************************/
6246int32_t 6283static int32_t
6247e1000_mng_write_commit( 6284e1000_mng_write_commit(
6248 struct e1000_hw * hw) 6285 struct e1000_hw * hw)
6249{ 6286{
@@ -6496,7 +6533,7 @@ e1000_polarity_reversal_workaround(struct e1000_hw *hw)
6496 * returns: - none. 6533 * returns: - none.
6497 * 6534 *
6498 ***************************************************************************/ 6535 ***************************************************************************/
6499void 6536static void
6500e1000_set_pci_express_master_disable(struct e1000_hw *hw) 6537e1000_set_pci_express_master_disable(struct e1000_hw *hw)
6501{ 6538{
6502 uint32_t ctrl; 6539 uint32_t ctrl;
@@ -6511,6 +6548,7 @@ e1000_set_pci_express_master_disable(struct e1000_hw *hw)
6511 E1000_WRITE_REG(hw, CTRL, ctrl); 6548 E1000_WRITE_REG(hw, CTRL, ctrl);
6512} 6549}
6513 6550
6551#if 0
6514/*************************************************************************** 6552/***************************************************************************
6515 * 6553 *
6516 * Enables PCI-Express master access. 6554 * Enables PCI-Express master access.
@@ -6534,6 +6572,7 @@ e1000_enable_pciex_master(struct e1000_hw *hw)
6534 ctrl &= ~E1000_CTRL_GIO_MASTER_DISABLE; 6572 ctrl &= ~E1000_CTRL_GIO_MASTER_DISABLE;
6535 E1000_WRITE_REG(hw, CTRL, ctrl); 6573 E1000_WRITE_REG(hw, CTRL, ctrl);
6536} 6574}
6575#endif /* 0 */
6537 6576
6538/******************************************************************************* 6577/*******************************************************************************
6539 * 6578 *
@@ -6584,7 +6623,7 @@ e1000_disable_pciex_master(struct e1000_hw *hw)
6584 * E1000_SUCCESS at any other case. 6623 * E1000_SUCCESS at any other case.
6585 * 6624 *
6586 ******************************************************************************/ 6625 ******************************************************************************/
6587int32_t 6626static int32_t
6588e1000_get_auto_rd_done(struct e1000_hw *hw) 6627e1000_get_auto_rd_done(struct e1000_hw *hw)
6589{ 6628{
6590 int32_t timeout = AUTO_READ_DONE_TIMEOUT; 6629 int32_t timeout = AUTO_READ_DONE_TIMEOUT;
@@ -6623,7 +6662,7 @@ e1000_get_auto_rd_done(struct e1000_hw *hw)
6623 * E1000_SUCCESS at any other case. 6662 * E1000_SUCCESS at any other case.
6624 * 6663 *
6625 ***************************************************************************/ 6664 ***************************************************************************/
6626int32_t 6665static int32_t
6627e1000_get_phy_cfg_done(struct e1000_hw *hw) 6666e1000_get_phy_cfg_done(struct e1000_hw *hw)
6628{ 6667{
6629 int32_t timeout = PHY_CFG_TIMEOUT; 6668 int32_t timeout = PHY_CFG_TIMEOUT;
@@ -6666,7 +6705,7 @@ e1000_get_phy_cfg_done(struct e1000_hw *hw)
6666 * E1000_SUCCESS at any other case. 6705 * E1000_SUCCESS at any other case.
6667 * 6706 *
6668 ***************************************************************************/ 6707 ***************************************************************************/
6669int32_t 6708static int32_t
6670e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw) 6709e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw)
6671{ 6710{
6672 int32_t timeout; 6711 int32_t timeout;
@@ -6711,7 +6750,7 @@ e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw)
6711 * returns: - None. 6750 * returns: - None.
6712 * 6751 *
6713 ***************************************************************************/ 6752 ***************************************************************************/
6714void 6753static void
6715e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw) 6754e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw)
6716{ 6755{
6717 uint32_t swsm; 6756 uint32_t swsm;
@@ -6747,7 +6786,7 @@ e1000_check_phy_reset_block(struct e1000_hw *hw)
6747 E1000_BLK_PHY_RESET : E1000_SUCCESS; 6786 E1000_BLK_PHY_RESET : E1000_SUCCESS;
6748} 6787}
6749 6788
6750uint8_t 6789static uint8_t
6751e1000_arc_subsystem_valid(struct e1000_hw *hw) 6790e1000_arc_subsystem_valid(struct e1000_hw *hw)
6752{ 6791{
6753 uint32_t fwsm; 6792 uint32_t fwsm;
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 4f2c196dc314..76ce12809a11 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -284,7 +284,6 @@ typedef enum {
284/* Initialization */ 284/* Initialization */
285int32_t e1000_reset_hw(struct e1000_hw *hw); 285int32_t e1000_reset_hw(struct e1000_hw *hw);
286int32_t e1000_init_hw(struct e1000_hw *hw); 286int32_t e1000_init_hw(struct e1000_hw *hw);
287int32_t e1000_id_led_init(struct e1000_hw * hw);
288int32_t e1000_set_mac_type(struct e1000_hw *hw); 287int32_t e1000_set_mac_type(struct e1000_hw *hw);
289void e1000_set_media_type(struct e1000_hw *hw); 288void e1000_set_media_type(struct e1000_hw *hw);
290 289
@@ -292,10 +291,8 @@ void e1000_set_media_type(struct e1000_hw *hw);
292int32_t e1000_setup_link(struct e1000_hw *hw); 291int32_t e1000_setup_link(struct e1000_hw *hw);
293int32_t e1000_phy_setup_autoneg(struct e1000_hw *hw); 292int32_t e1000_phy_setup_autoneg(struct e1000_hw *hw);
294void e1000_config_collision_dist(struct e1000_hw *hw); 293void e1000_config_collision_dist(struct e1000_hw *hw);
295int32_t e1000_config_fc_after_link_up(struct e1000_hw *hw);
296int32_t e1000_check_for_link(struct e1000_hw *hw); 294int32_t e1000_check_for_link(struct e1000_hw *hw);
297int32_t e1000_get_speed_and_duplex(struct e1000_hw *hw, uint16_t * speed, uint16_t * duplex); 295int32_t e1000_get_speed_and_duplex(struct e1000_hw *hw, uint16_t * speed, uint16_t * duplex);
298int32_t e1000_wait_autoneg(struct e1000_hw *hw);
299int32_t e1000_force_mac_fc(struct e1000_hw *hw); 296int32_t e1000_force_mac_fc(struct e1000_hw *hw);
300 297
301/* PHY */ 298/* PHY */
@@ -303,21 +300,11 @@ int32_t e1000_read_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy
303int32_t e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data); 300int32_t e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data);
304int32_t e1000_phy_hw_reset(struct e1000_hw *hw); 301int32_t e1000_phy_hw_reset(struct e1000_hw *hw);
305int32_t e1000_phy_reset(struct e1000_hw *hw); 302int32_t e1000_phy_reset(struct e1000_hw *hw);
306int32_t e1000_detect_gig_phy(struct e1000_hw *hw);
307int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info); 303int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
308int32_t e1000_phy_m88_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
309int32_t e1000_phy_igp_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
310int32_t e1000_get_cable_length(struct e1000_hw *hw, uint16_t *min_length, uint16_t *max_length);
311int32_t e1000_check_polarity(struct e1000_hw *hw, uint16_t *polarity);
312int32_t e1000_check_downshift(struct e1000_hw *hw);
313int32_t e1000_validate_mdi_setting(struct e1000_hw *hw); 304int32_t e1000_validate_mdi_setting(struct e1000_hw *hw);
314 305
315/* EEPROM Functions */ 306/* EEPROM Functions */
316int32_t e1000_init_eeprom_params(struct e1000_hw *hw); 307int32_t e1000_init_eeprom_params(struct e1000_hw *hw);
317boolean_t e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw);
318int32_t e1000_read_eeprom_eerd(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
319int32_t e1000_write_eeprom_eewr(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
320int32_t e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd);
321 308
322/* MNG HOST IF functions */ 309/* MNG HOST IF functions */
323uint32_t e1000_enable_mng_pass_thru(struct e1000_hw *hw); 310uint32_t e1000_enable_mng_pass_thru(struct e1000_hw *hw);
@@ -377,13 +364,6 @@ int32_t e1000_mng_write_dhcp_info(struct e1000_hw *hw, uint8_t *buffer,
377 uint16_t length); 364 uint16_t length);
378boolean_t e1000_check_mng_mode(struct e1000_hw *hw); 365boolean_t e1000_check_mng_mode(struct e1000_hw *hw);
379boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw); 366boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw);
380int32_t e1000_mng_enable_host_if(struct e1000_hw *hw);
381int32_t e1000_mng_host_if_write(struct e1000_hw *hw, uint8_t *buffer,
382 uint16_t length, uint16_t offset, uint8_t *sum);
383int32_t e1000_mng_write_cmd_header(struct e1000_hw* hw,
384 struct e1000_host_mng_command_header* hdr);
385
386int32_t e1000_mng_write_commit(struct e1000_hw *hw);
387 367
388int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data); 368int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data);
389int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw); 369int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw);
@@ -395,13 +375,10 @@ int32_t e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask);
395void e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask); 375void e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask);
396 376
397/* Filters (multicast, vlan, receive) */ 377/* Filters (multicast, vlan, receive) */
398void e1000_init_rx_addrs(struct e1000_hw *hw);
399void e1000_mc_addr_list_update(struct e1000_hw *hw, uint8_t * mc_addr_list, uint32_t mc_addr_count, uint32_t pad, uint32_t rar_used_count);
400uint32_t e1000_hash_mc_addr(struct e1000_hw *hw, uint8_t * mc_addr); 378uint32_t e1000_hash_mc_addr(struct e1000_hw *hw, uint8_t * mc_addr);
401void e1000_mta_set(struct e1000_hw *hw, uint32_t hash_value); 379void e1000_mta_set(struct e1000_hw *hw, uint32_t hash_value);
402void e1000_rar_set(struct e1000_hw *hw, uint8_t * mc_addr, uint32_t rar_index); 380void e1000_rar_set(struct e1000_hw *hw, uint8_t * mc_addr, uint32_t rar_index);
403void e1000_write_vfta(struct e1000_hw *hw, uint32_t offset, uint32_t value); 381void e1000_write_vfta(struct e1000_hw *hw, uint32_t offset, uint32_t value);
404void e1000_clear_vfta(struct e1000_hw *hw);
405 382
406/* LED functions */ 383/* LED functions */
407int32_t e1000_setup_led(struct e1000_hw *hw); 384int32_t e1000_setup_led(struct e1000_hw *hw);
@@ -412,7 +389,6 @@ int32_t e1000_led_off(struct e1000_hw *hw);
412/* Adaptive IFS Functions */ 389/* Adaptive IFS Functions */
413 390
414/* Everything else */ 391/* Everything else */
415void e1000_clear_hw_cntrs(struct e1000_hw *hw);
416void e1000_reset_adaptive(struct e1000_hw *hw); 392void e1000_reset_adaptive(struct e1000_hw *hw);
417void e1000_update_adaptive(struct e1000_hw *hw); 393void e1000_update_adaptive(struct e1000_hw *hw);
418void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct e1000_hw_stats *stats, uint32_t frame_len, uint8_t * mac_addr); 394void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct e1000_hw_stats *stats, uint32_t frame_len, uint8_t * mac_addr);
@@ -423,29 +399,11 @@ void e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
423void e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value); 399void e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
424/* Port I/O is only supported on 82544 and newer */ 400/* Port I/O is only supported on 82544 and newer */
425uint32_t e1000_io_read(struct e1000_hw *hw, unsigned long port); 401uint32_t e1000_io_read(struct e1000_hw *hw, unsigned long port);
426uint32_t e1000_read_reg_io(struct e1000_hw *hw, uint32_t offset);
427void e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value); 402void e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value);
428void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value);
429int32_t e1000_config_dsp_after_link_change(struct e1000_hw *hw, boolean_t link_up);
430int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
431int32_t e1000_set_d0_lplu_state(struct e1000_hw *hw, boolean_t active);
432void e1000_set_pci_express_master_disable(struct e1000_hw *hw);
433void e1000_enable_pciex_master(struct e1000_hw *hw);
434int32_t e1000_disable_pciex_master(struct e1000_hw *hw); 403int32_t e1000_disable_pciex_master(struct e1000_hw *hw);
435int32_t e1000_get_auto_rd_done(struct e1000_hw *hw);
436int32_t e1000_get_phy_cfg_done(struct e1000_hw *hw);
437int32_t e1000_get_software_semaphore(struct e1000_hw *hw); 404int32_t e1000_get_software_semaphore(struct e1000_hw *hw);
438void e1000_release_software_semaphore(struct e1000_hw *hw); 405void e1000_release_software_semaphore(struct e1000_hw *hw);
439int32_t e1000_check_phy_reset_block(struct e1000_hw *hw); 406int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
440int32_t e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw);
441void e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw);
442int32_t e1000_commit_shadow_ram(struct e1000_hw *hw);
443uint8_t e1000_arc_subsystem_valid(struct e1000_hw *hw);
444
445#define E1000_READ_REG_IO(a, reg) \
446 e1000_read_reg_io((a), E1000_##reg)
447#define E1000_WRITE_REG_IO(a, reg, val) \
448 e1000_write_reg_io((a), E1000_##reg, val)
449 407
450/* PCI Device IDs */ 408/* PCI Device IDs */
451#define E1000_DEV_ID_82542 0x1000 409#define E1000_DEV_ID_82542 0x1000
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index efbbda7cbcbf..8b207f0e139e 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39char e1000_driver_name[] = "e1000"; 39char e1000_driver_name[] = "e1000";
40char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; 40static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
41#ifndef CONFIG_E1000_NAPI 41#ifndef CONFIG_E1000_NAPI
42#define DRIVERNAPI 42#define DRIVERNAPI
43#else 43#else
@@ -45,7 +45,7 @@ char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
45#endif 45#endif
46#define DRV_VERSION "6.1.16-k2"DRIVERNAPI 46#define DRV_VERSION "6.1.16-k2"DRIVERNAPI
47char e1000_driver_version[] = DRV_VERSION; 47char e1000_driver_version[] = DRV_VERSION;
48char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation."; 48static char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
49 49
50/* e1000_pci_tbl - PCI Device ID Table 50/* e1000_pci_tbl - PCI Device ID Table
51 * 51 *
@@ -112,14 +112,14 @@ int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
112int e1000_setup_all_rx_resources(struct e1000_adapter *adapter); 112int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
113void e1000_free_all_tx_resources(struct e1000_adapter *adapter); 113void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
114void e1000_free_all_rx_resources(struct e1000_adapter *adapter); 114void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
115int e1000_setup_tx_resources(struct e1000_adapter *adapter, 115static int e1000_setup_tx_resources(struct e1000_adapter *adapter,
116 struct e1000_tx_ring *txdr); 116 struct e1000_tx_ring *txdr);
117int e1000_setup_rx_resources(struct e1000_adapter *adapter, 117static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
118 struct e1000_rx_ring *rxdr); 118 struct e1000_rx_ring *rxdr);
119void e1000_free_tx_resources(struct e1000_adapter *adapter, 119static void e1000_free_tx_resources(struct e1000_adapter *adapter,
120 struct e1000_tx_ring *tx_ring); 120 struct e1000_tx_ring *tx_ring);
121void e1000_free_rx_resources(struct e1000_adapter *adapter, 121static void e1000_free_rx_resources(struct e1000_adapter *adapter,
122 struct e1000_rx_ring *rx_ring); 122 struct e1000_rx_ring *rx_ring);
123void e1000_update_stats(struct e1000_adapter *adapter); 123void e1000_update_stats(struct e1000_adapter *adapter);
124 124
125/* Local Function Prototypes */ 125/* Local Function Prototypes */
@@ -296,7 +296,8 @@ e1000_irq_enable(struct e1000_adapter *adapter)
296 E1000_WRITE_FLUSH(&adapter->hw); 296 E1000_WRITE_FLUSH(&adapter->hw);
297 } 297 }
298} 298}
299void 299
300static void
300e1000_update_mng_vlan(struct e1000_adapter *adapter) 301e1000_update_mng_vlan(struct e1000_adapter *adapter)
301{ 302{
302 struct net_device *netdev = adapter->netdev; 303 struct net_device *netdev = adapter->netdev;
@@ -1141,7 +1142,7 @@ e1000_check_64k_bound(struct e1000_adapter *adapter,
1141 * Return 0 on success, negative on failure 1142 * Return 0 on success, negative on failure
1142 **/ 1143 **/
1143 1144
1144int 1145static int
1145e1000_setup_tx_resources(struct e1000_adapter *adapter, 1146e1000_setup_tx_resources(struct e1000_adapter *adapter,
1146 struct e1000_tx_ring *txdr) 1147 struct e1000_tx_ring *txdr)
1147{ 1148{
@@ -1359,7 +1360,7 @@ e1000_configure_tx(struct e1000_adapter *adapter)
1359 * Returns 0 on success, negative on failure 1360 * Returns 0 on success, negative on failure
1360 **/ 1361 **/
1361 1362
1362int 1363static int
1363e1000_setup_rx_resources(struct e1000_adapter *adapter, 1364e1000_setup_rx_resources(struct e1000_adapter *adapter,
1364 struct e1000_rx_ring *rxdr) 1365 struct e1000_rx_ring *rxdr)
1365{ 1366{
@@ -1747,7 +1748,7 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1747 * Free all transmit software resources 1748 * Free all transmit software resources
1748 **/ 1749 **/
1749 1750
1750void 1751static void
1751e1000_free_tx_resources(struct e1000_adapter *adapter, 1752e1000_free_tx_resources(struct e1000_adapter *adapter,
1752 struct e1000_tx_ring *tx_ring) 1753 struct e1000_tx_ring *tx_ring)
1753{ 1754{
@@ -1858,7 +1859,7 @@ e1000_clean_all_tx_rings(struct e1000_adapter *adapter)
1858 * Free all receive software resources 1859 * Free all receive software resources
1859 **/ 1860 **/
1860 1861
1861void 1862static void
1862e1000_free_rx_resources(struct e1000_adapter *adapter, 1863e1000_free_rx_resources(struct e1000_adapter *adapter,
1863 struct e1000_rx_ring *rx_ring) 1864 struct e1000_rx_ring *rx_ring)
1864{ 1865{
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 85504fb900da..bd6983d1afba 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -18,8 +18,8 @@
18 * Much better multiple PHY support by Magnus Damm. 18 * Much better multiple PHY support by Magnus Damm.
19 * Copyright (c) 2000 Ericsson Radio Systems AB. 19 * Copyright (c) 2000 Ericsson Radio Systems AB.
20 * 20 *
21 * Support for FEC controller of ColdFire/5270/5271/5272/5274/5275/5280/5282. 21 * Support for FEC controller of ColdFire processors.
22 * Copyright (c) 2001-2004 Greg Ungerer (gerg@snapgear.com) 22 * Copyright (c) 2001-2005 Greg Ungerer (gerg@snapgear.com)
23 * 23 *
24 * Bug fixes and cleanup by Philippe De Muyter (phdm@macqel.be) 24 * Bug fixes and cleanup by Philippe De Muyter (phdm@macqel.be)
25 * Copyright (c) 2004-2005 Macq Electronique SA. 25 * Copyright (c) 2004-2005 Macq Electronique SA.
@@ -50,7 +50,8 @@
50#include <asm/pgtable.h> 50#include <asm/pgtable.h>
51 51
52#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \ 52#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
53 defined(CONFIG_M5272) || defined(CONFIG_M528x) 53 defined(CONFIG_M5272) || defined(CONFIG_M528x) || \
54 defined(CONFIG_M520x)
54#include <asm/coldfire.h> 55#include <asm/coldfire.h>
55#include <asm/mcfsim.h> 56#include <asm/mcfsim.h>
56#include "fec.h" 57#include "fec.h"
@@ -77,6 +78,8 @@ static unsigned int fec_hw[] = {
77 (MCF_MBAR + 0x1800), 78 (MCF_MBAR + 0x1800),
78#elif defined(CONFIG_M523x) || defined(CONFIG_M528x) 79#elif defined(CONFIG_M523x) || defined(CONFIG_M528x)
79 (MCF_MBAR + 0x1000), 80 (MCF_MBAR + 0x1000),
81#elif defined(CONFIG_M520x)
82 (MCF_MBAR+0x30000),
80#else 83#else
81 &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec), 84 &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec),
82#endif 85#endif
@@ -139,6 +142,10 @@ typedef struct {
139#define TX_RING_SIZE 16 /* Must be power of two */ 142#define TX_RING_SIZE 16 /* Must be power of two */
140#define TX_RING_MOD_MASK 15 /* for this to work */ 143#define TX_RING_MOD_MASK 15 /* for this to work */
141 144
145#if (((RX_RING_SIZE + TX_RING_SIZE) * 8) > PAGE_SIZE)
146#error "FEC: descriptor ring size contants too large"
147#endif
148
142/* Interrupt events/masks. 149/* Interrupt events/masks.
143*/ 150*/
144#define FEC_ENET_HBERR ((uint)0x80000000) /* Heartbeat error */ 151#define FEC_ENET_HBERR ((uint)0x80000000) /* Heartbeat error */
@@ -164,7 +171,8 @@ typedef struct {
164 * size bits. Other FEC hardware does not, so we need to take that into 171 * size bits. Other FEC hardware does not, so we need to take that into
165 * account when setting it. 172 * account when setting it.
166 */ 173 */
167#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) 174#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
175 defined(CONFIG_M520x)
168#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16) 176#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16)
169#else 177#else
170#define OPT_FRAME_SIZE 0 178#define OPT_FRAME_SIZE 0
@@ -1137,6 +1145,65 @@ static phy_info_t const phy_info_ks8721bl = {
1137}; 1145};
1138 1146
1139/* ------------------------------------------------------------------------- */ 1147/* ------------------------------------------------------------------------- */
1148/* register definitions for the DP83848 */
1149
1150#define MII_DP8384X_PHYSTST 16 /* PHY Status Register */
1151
1152static void mii_parse_dp8384x_sr2(uint mii_reg, struct net_device *dev)
1153{
1154 struct fec_enet_private *fep = dev->priv;
1155 volatile uint *s = &(fep->phy_status);
1156
1157 *s &= ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC);
1158
1159 /* Link up */
1160 if (mii_reg & 0x0001) {
1161 fep->link = 1;
1162 *s |= PHY_STAT_LINK;
1163 } else
1164 fep->link = 0;
1165 /* Status of link */
1166 if (mii_reg & 0x0010) /* Autonegotioation complete */
1167 *s |= PHY_STAT_ANC;
1168 if (mii_reg & 0x0002) { /* 10MBps? */
1169 if (mii_reg & 0x0004) /* Full Duplex? */
1170 *s |= PHY_STAT_10FDX;
1171 else
1172 *s |= PHY_STAT_10HDX;
1173 } else { /* 100 Mbps? */
1174 if (mii_reg & 0x0004) /* Full Duplex? */
1175 *s |= PHY_STAT_100FDX;
1176 else
1177 *s |= PHY_STAT_100HDX;
1178 }
1179 if (mii_reg & 0x0008)
1180 *s |= PHY_STAT_FAULT;
1181}
1182
1183static phy_info_t phy_info_dp83848= {
1184 0x020005c9,
1185 "DP83848",
1186
1187 (const phy_cmd_t []) { /* config */
1188 { mk_mii_read(MII_REG_CR), mii_parse_cr },
1189 { mk_mii_read(MII_REG_ANAR), mii_parse_anar },
1190 { mk_mii_read(MII_DP8384X_PHYSTST), mii_parse_dp8384x_sr2 },
1191 { mk_mii_end, }
1192 },
1193 (const phy_cmd_t []) { /* startup - enable interrupts */
1194 { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
1195 { mk_mii_read(MII_REG_SR), mii_parse_sr },
1196 { mk_mii_end, }
1197 },
1198 (const phy_cmd_t []) { /* ack_int - never happens, no interrupt */
1199 { mk_mii_end, }
1200 },
1201 (const phy_cmd_t []) { /* shutdown */
1202 { mk_mii_end, }
1203 },
1204};
1205
1206/* ------------------------------------------------------------------------- */
1140 1207
1141static phy_info_t const * const phy_info[] = { 1208static phy_info_t const * const phy_info[] = {
1142 &phy_info_lxt970, 1209 &phy_info_lxt970,
@@ -1144,6 +1211,7 @@ static phy_info_t const * const phy_info[] = {
1144 &phy_info_qs6612, 1211 &phy_info_qs6612,
1145 &phy_info_am79c874, 1212 &phy_info_am79c874,
1146 &phy_info_ks8721bl, 1213 &phy_info_ks8721bl,
1214 &phy_info_dp83848,
1147 NULL 1215 NULL
1148}; 1216};
1149 1217
@@ -1422,6 +1490,134 @@ static void __inline__ fec_uncache(unsigned long addr)
1422 1490
1423/* ------------------------------------------------------------------------- */ 1491/* ------------------------------------------------------------------------- */
1424 1492
1493#elif defined(CONFIG_M520x)
1494
1495/*
1496 * Code specific to Coldfire 520x
1497 */
1498static void __inline__ fec_request_intrs(struct net_device *dev)
1499{
1500 struct fec_enet_private *fep;
1501 int b;
1502 static const struct idesc {
1503 char *name;
1504 unsigned short irq;
1505 } *idp, id[] = {
1506 { "fec(TXF)", 23 },
1507 { "fec(TXB)", 24 },
1508 { "fec(TXFIFO)", 25 },
1509 { "fec(TXCR)", 26 },
1510 { "fec(RXF)", 27 },
1511 { "fec(RXB)", 28 },
1512 { "fec(MII)", 29 },
1513 { "fec(LC)", 30 },
1514 { "fec(HBERR)", 31 },
1515 { "fec(GRA)", 32 },
1516 { "fec(EBERR)", 33 },
1517 { "fec(BABT)", 34 },
1518 { "fec(BABR)", 35 },
1519 { NULL },
1520 };
1521
1522 fep = netdev_priv(dev);
1523 b = 64 + 13;
1524
1525 /* Setup interrupt handlers. */
1526 for (idp = id; idp->name; idp++) {
1527 if (request_irq(b+idp->irq,fec_enet_interrupt,0,idp->name,dev)!=0)
1528 printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, b+idp->irq);
1529 }
1530
1531 /* Unmask interrupts at ColdFire interrupt controller */
1532 {
1533 volatile unsigned char *icrp;
1534 volatile unsigned long *imrp;
1535
1536 icrp = (volatile unsigned char *) (MCF_IPSBAR + MCFICM_INTC0 +
1537 MCFINTC_ICR0);
1538 for (b = 36; (b < 49); b++)
1539 icrp[b] = 0x04;
1540 imrp = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 +
1541 MCFINTC_IMRH);
1542 *imrp &= ~0x0001FFF0;
1543 }
1544 *(volatile unsigned char *)(MCF_IPSBAR + MCF_GPIO_PAR_FEC) |= 0xf0;
1545 *(volatile unsigned char *)(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C) |= 0x0f;
1546}
1547
1548static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
1549{
1550 volatile fec_t *fecp;
1551
1552 fecp = fep->hwp;
1553 fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;
1554 fecp->fec_x_cntrl = 0x00;
1555
1556 /*
1557 * Set MII speed to 2.5 MHz
1558 * See 5282 manual section 17.5.4.7: MSCR
1559 */
1560 fep->phy_speed = ((((MCF_CLK / 2) / (2500000 / 10)) + 5) / 10) * 2;
1561 fecp->fec_mii_speed = fep->phy_speed;
1562
1563 fec_restart(dev, 0);
1564}
1565
1566static void __inline__ fec_get_mac(struct net_device *dev)
1567{
1568 struct fec_enet_private *fep = netdev_priv(dev);
1569 volatile fec_t *fecp;
1570 unsigned char *iap, tmpaddr[ETH_ALEN];
1571
1572 fecp = fep->hwp;
1573
1574 if (FEC_FLASHMAC) {
1575 /*
1576 * Get MAC address from FLASH.
1577 * If it is all 1's or 0's, use the default.
1578 */
1579 iap = FEC_FLASHMAC;
1580 if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) &&
1581 (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0))
1582 iap = fec_mac_default;
1583 if ((iap[0] == 0xff) && (iap[1] == 0xff) && (iap[2] == 0xff) &&
1584 (iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff))
1585 iap = fec_mac_default;
1586 } else {
1587 *((unsigned long *) &tmpaddr[0]) = fecp->fec_addr_low;
1588 *((unsigned short *) &tmpaddr[4]) = (fecp->fec_addr_high >> 16);
1589 iap = &tmpaddr[0];
1590 }
1591
1592 memcpy(dev->dev_addr, iap, ETH_ALEN);
1593
1594 /* Adjust MAC if using default MAC address */
1595 if (iap == fec_mac_default)
1596 dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->index;
1597}
1598
1599static void __inline__ fec_enable_phy_intr(void)
1600{
1601}
1602
1603static void __inline__ fec_disable_phy_intr(void)
1604{
1605}
1606
1607static void __inline__ fec_phy_ack_intr(void)
1608{
1609}
1610
1611static void __inline__ fec_localhw_setup(void)
1612{
1613}
1614
1615static void __inline__ fec_uncache(unsigned long addr)
1616{
1617}
1618
1619/* ------------------------------------------------------------------------- */
1620
1425#else 1621#else
1426 1622
1427/* 1623/*
@@ -1952,6 +2148,14 @@ int __init fec_enet_init(struct net_device *dev)
1952 if (index >= FEC_MAX_PORTS) 2148 if (index >= FEC_MAX_PORTS)
1953 return -ENXIO; 2149 return -ENXIO;
1954 2150
2151 /* Allocate memory for buffer descriptors.
2152 */
2153 mem_addr = __get_free_page(GFP_KERNEL);
2154 if (mem_addr == 0) {
2155 printk("FEC: allocate descriptor memory failed?\n");
2156 return -ENOMEM;
2157 }
2158
1955 /* Create an Ethernet device instance. 2159 /* Create an Ethernet device instance.
1956 */ 2160 */
1957 fecp = (volatile fec_t *) fec_hw[index]; 2161 fecp = (volatile fec_t *) fec_hw[index];
@@ -1964,16 +2168,6 @@ int __init fec_enet_init(struct net_device *dev)
1964 fecp->fec_ecntrl = 1; 2168 fecp->fec_ecntrl = 1;
1965 udelay(10); 2169 udelay(10);
1966 2170
1967 /* Clear and enable interrupts */
1968 fecp->fec_ievent = 0xffc00000;
1969 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
1970 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
1971 fecp->fec_hash_table_high = 0;
1972 fecp->fec_hash_table_low = 0;
1973 fecp->fec_r_buff_size = PKT_MAXBLR_SIZE;
1974 fecp->fec_ecntrl = 2;
1975 fecp->fec_r_des_active = 0x01000000;
1976
1977 /* Set the Ethernet address. If using multiple Enets on the 8xx, 2171 /* Set the Ethernet address. If using multiple Enets on the 8xx,
1978 * this needs some work to get unique addresses. 2172 * this needs some work to get unique addresses.
1979 * 2173 *
@@ -1982,14 +2176,6 @@ int __init fec_enet_init(struct net_device *dev)
1982 */ 2176 */
1983 fec_get_mac(dev); 2177 fec_get_mac(dev);
1984 2178
1985 /* Allocate memory for buffer descriptors.
1986 */
1987 if (((RX_RING_SIZE + TX_RING_SIZE) * sizeof(cbd_t)) > PAGE_SIZE) {
1988 printk("FEC init error. Need more space.\n");
1989 printk("FEC initialization failed.\n");
1990 return 1;
1991 }
1992 mem_addr = __get_free_page(GFP_KERNEL);
1993 cbd_base = (cbd_t *)mem_addr; 2179 cbd_base = (cbd_t *)mem_addr;
1994 /* XXX: missing check for allocation failure */ 2180 /* XXX: missing check for allocation failure */
1995 2181
@@ -2067,6 +2253,16 @@ int __init fec_enet_init(struct net_device *dev)
2067 */ 2253 */
2068 fec_request_intrs(dev); 2254 fec_request_intrs(dev);
2069 2255
2256 /* Clear and enable interrupts */
2257 fecp->fec_ievent = 0xffc00000;
2258 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2259 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2260 fecp->fec_hash_table_high = 0;
2261 fecp->fec_hash_table_low = 0;
2262 fecp->fec_r_buff_size = PKT_MAXBLR_SIZE;
2263 fecp->fec_ecntrl = 2;
2264 fecp->fec_r_des_active = 0x01000000;
2265
2070 dev->base_addr = (unsigned long)fecp; 2266 dev->base_addr = (unsigned long)fecp;
2071 2267
2072 /* The FEC Ethernet specific entries in the device structure. */ 2268 /* The FEC Ethernet specific entries in the device structure. */
diff --git a/drivers/net/fec.h b/drivers/net/fec.h
index 045761b8a600..965c5c49fcdc 100644
--- a/drivers/net/fec.h
+++ b/drivers/net/fec.h
@@ -1,11 +1,10 @@
1/****************************************************************************/ 1/****************************************************************************/
2 2
3/* 3/*
4 * fec.h -- Fast Ethernet Controller for Motorola ColdFire 5230, 4 * fec.h -- Fast Ethernet Controller for Motorola ColdFire SoC
5 * 5231, 5232, 5234, 5235, 5270, 5271, 5272, 5274, 5275, 5 * processors.
6 * 5280 and 5282.
7 * 6 *
8 * (C) Copyright 2000-2003, Greg Ungerer (gerg@snapgear.com) 7 * (C) Copyright 2000-2005, Greg Ungerer (gerg@snapgear.com)
9 * (C) Copyright 2000-2001, Lineo (www.lineo.com) 8 * (C) Copyright 2000-2001, Lineo (www.lineo.com)
10 */ 9 */
11 10
@@ -14,7 +13,8 @@
14#define FEC_H 13#define FEC_H
15/****************************************************************************/ 14/****************************************************************************/
16 15
17#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) 16#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
17 defined(CONFIG_M520x)
18/* 18/*
19 * Just figures, Motorola would have to change the offsets for 19 * Just figures, Motorola would have to change the offsets for
20 * registers in the same peripheral device on different models 20 * registers in the same peripheral device on different models
diff --git a/drivers/net/fec_8xx/Kconfig b/drivers/net/fec_8xx/Kconfig
index 4560026ed419..94e7a9af8705 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 3 depends on NET_ETHERNET && FEC
4 select MII 4 select MII
5 5
6config FEC_8XX_GENERIC_PHY 6config FEC_8XX_GENERIC_PHY
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 3be3f916643a..c8dc40214a08 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -311,16 +311,6 @@ static void __exit dmascc_exit(void)
311 } 311 }
312} 312}
313 313
314#ifndef MODULE
315void __init dmascc_setup(char *str, int *ints)
316{
317 int i;
318
319 for (i = 0; i < MAX_NUM_DEVS && i < ints[0]; i++)
320 io[i] = ints[i + 1];
321}
322#endif
323
324static int __init dmascc_init(void) 314static int __init dmascc_init(void)
325{ 315{
326 int h, i, j, n; 316 int h, i, j, n;
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index 04e47189d830..d38ade5f2f4e 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -694,7 +694,7 @@ ixgb_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
694 } 694 }
695} 695}
696 696
697struct ethtool_ops ixgb_ethtool_ops = { 697static struct ethtool_ops ixgb_ethtool_ops = {
698 .get_settings = ixgb_get_settings, 698 .get_settings = ixgb_get_settings,
699 .set_settings = ixgb_set_settings, 699 .set_settings = ixgb_set_settings,
700 .get_drvinfo = ixgb_get_drvinfo, 700 .get_drvinfo = ixgb_get_drvinfo,
diff --git a/drivers/net/ixgb/ixgb_hw.c b/drivers/net/ixgb/ixgb_hw.c
index 69329c73095a..620cad48bdea 100644
--- a/drivers/net/ixgb/ixgb_hw.c
+++ b/drivers/net/ixgb/ixgb_hw.c
@@ -47,9 +47,22 @@ static void ixgb_optics_reset(struct ixgb_hw *hw);
47 47
48static ixgb_phy_type ixgb_identify_phy(struct ixgb_hw *hw); 48static ixgb_phy_type ixgb_identify_phy(struct ixgb_hw *hw);
49 49
50uint32_t ixgb_mac_reset(struct ixgb_hw *hw); 50static void ixgb_clear_hw_cntrs(struct ixgb_hw *hw);
51 51
52uint32_t ixgb_mac_reset(struct ixgb_hw *hw) 52static void ixgb_clear_vfta(struct ixgb_hw *hw);
53
54static void ixgb_init_rx_addrs(struct ixgb_hw *hw);
55
56static uint16_t ixgb_read_phy_reg(struct ixgb_hw *hw,
57 uint32_t reg_address,
58 uint32_t phy_address,
59 uint32_t device_type);
60
61static boolean_t ixgb_setup_fc(struct ixgb_hw *hw);
62
63static boolean_t mac_addr_valid(uint8_t *mac_addr);
64
65static uint32_t ixgb_mac_reset(struct ixgb_hw *hw)
53{ 66{
54 uint32_t ctrl_reg; 67 uint32_t ctrl_reg;
55 68
@@ -335,7 +348,7 @@ ixgb_init_hw(struct ixgb_hw *hw)
335 * of the receive addresss registers. Clears the multicast table. Assumes 348 * of the receive addresss registers. Clears the multicast table. Assumes
336 * the receiver is in reset when the routine is called. 349 * the receiver is in reset when the routine is called.
337 *****************************************************************************/ 350 *****************************************************************************/
338void 351static void
339ixgb_init_rx_addrs(struct ixgb_hw *hw) 352ixgb_init_rx_addrs(struct ixgb_hw *hw)
340{ 353{
341 uint32_t i; 354 uint32_t i;
@@ -604,7 +617,7 @@ ixgb_write_vfta(struct ixgb_hw *hw,
604 * 617 *
605 * hw - Struct containing variables accessed by shared code 618 * hw - Struct containing variables accessed by shared code
606 *****************************************************************************/ 619 *****************************************************************************/
607void 620static void
608ixgb_clear_vfta(struct ixgb_hw *hw) 621ixgb_clear_vfta(struct ixgb_hw *hw)
609{ 622{
610 uint32_t offset; 623 uint32_t offset;
@@ -620,7 +633,7 @@ ixgb_clear_vfta(struct ixgb_hw *hw)
620 * hw - Struct containing variables accessed by shared code 633 * hw - Struct containing variables accessed by shared code
621 *****************************************************************************/ 634 *****************************************************************************/
622 635
623boolean_t 636static boolean_t
624ixgb_setup_fc(struct ixgb_hw *hw) 637ixgb_setup_fc(struct ixgb_hw *hw)
625{ 638{
626 uint32_t ctrl_reg; 639 uint32_t ctrl_reg;
@@ -722,7 +735,7 @@ ixgb_setup_fc(struct ixgb_hw *hw)
722 * This requires that first an address cycle command is sent, followed by a 735 * This requires that first an address cycle command is sent, followed by a
723 * read command. 736 * read command.
724 *****************************************************************************/ 737 *****************************************************************************/
725uint16_t 738static uint16_t
726ixgb_read_phy_reg(struct ixgb_hw *hw, 739ixgb_read_phy_reg(struct ixgb_hw *hw,
727 uint32_t reg_address, 740 uint32_t reg_address,
728 uint32_t phy_address, 741 uint32_t phy_address,
@@ -815,7 +828,7 @@ ixgb_read_phy_reg(struct ixgb_hw *hw,
815 * This requires that first an address cycle command is sent, followed by a 828 * This requires that first an address cycle command is sent, followed by a
816 * write command. 829 * write command.
817 *****************************************************************************/ 830 *****************************************************************************/
818void 831static void
819ixgb_write_phy_reg(struct ixgb_hw *hw, 832ixgb_write_phy_reg(struct ixgb_hw *hw,
820 uint32_t reg_address, 833 uint32_t reg_address,
821 uint32_t phy_address, 834 uint32_t phy_address,
@@ -959,7 +972,7 @@ boolean_t ixgb_check_for_bad_link(struct ixgb_hw *hw)
959 * 972 *
960 * hw - Struct containing variables accessed by shared code 973 * hw - Struct containing variables accessed by shared code
961 *****************************************************************************/ 974 *****************************************************************************/
962void 975static void
963ixgb_clear_hw_cntrs(struct ixgb_hw *hw) 976ixgb_clear_hw_cntrs(struct ixgb_hw *hw)
964{ 977{
965 volatile uint32_t temp_reg; 978 volatile uint32_t temp_reg;
@@ -1114,7 +1127,7 @@ ixgb_get_bus_info(struct ixgb_hw *hw)
1114 * mac_addr - pointer to MAC address. 1127 * mac_addr - pointer to MAC address.
1115 * 1128 *
1116 *****************************************************************************/ 1129 *****************************************************************************/
1117boolean_t 1130static boolean_t
1118mac_addr_valid(uint8_t *mac_addr) 1131mac_addr_valid(uint8_t *mac_addr)
1119{ 1132{
1120 boolean_t is_valid = TRUE; 1133 boolean_t is_valid = TRUE;
diff --git a/drivers/net/ixgb/ixgb_hw.h b/drivers/net/ixgb/ixgb_hw.h
index 8bcf31ed10c2..382c6300ccc2 100644
--- a/drivers/net/ixgb/ixgb_hw.h
+++ b/drivers/net/ixgb/ixgb_hw.h
@@ -784,23 +784,8 @@ struct ixgb_hw_stats {
784extern boolean_t ixgb_adapter_stop(struct ixgb_hw *hw); 784extern boolean_t ixgb_adapter_stop(struct ixgb_hw *hw);
785extern boolean_t ixgb_init_hw(struct ixgb_hw *hw); 785extern boolean_t ixgb_init_hw(struct ixgb_hw *hw);
786extern boolean_t ixgb_adapter_start(struct ixgb_hw *hw); 786extern boolean_t ixgb_adapter_start(struct ixgb_hw *hw);
787extern void ixgb_init_rx_addrs(struct ixgb_hw *hw);
788extern void ixgb_check_for_link(struct ixgb_hw *hw); 787extern void ixgb_check_for_link(struct ixgb_hw *hw);
789extern boolean_t ixgb_check_for_bad_link(struct ixgb_hw *hw); 788extern boolean_t ixgb_check_for_bad_link(struct ixgb_hw *hw);
790extern boolean_t ixgb_setup_fc(struct ixgb_hw *hw);
791extern void ixgb_clear_hw_cntrs(struct ixgb_hw *hw);
792extern boolean_t mac_addr_valid(uint8_t *mac_addr);
793
794extern uint16_t ixgb_read_phy_reg(struct ixgb_hw *hw,
795 uint32_t reg_addr,
796 uint32_t phy_addr,
797 uint32_t device_type);
798
799extern void ixgb_write_phy_reg(struct ixgb_hw *hw,
800 uint32_t reg_addr,
801 uint32_t phy_addr,
802 uint32_t device_type,
803 uint16_t data);
804 789
805extern void ixgb_rar_set(struct ixgb_hw *hw, 790extern void ixgb_rar_set(struct ixgb_hw *hw,
806 uint8_t *addr, 791 uint8_t *addr,
@@ -818,8 +803,6 @@ extern void ixgb_write_vfta(struct ixgb_hw *hw,
818 uint32_t offset, 803 uint32_t offset,
819 uint32_t value); 804 uint32_t value);
820 805
821extern void ixgb_clear_vfta(struct ixgb_hw *hw);
822
823/* Access functions to eeprom data */ 806/* Access functions to eeprom data */
824void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, uint8_t *mac_addr); 807void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, uint8_t *mac_addr);
825uint32_t ixgb_get_ee_pba_number(struct ixgb_hw *hw); 808uint32_t ixgb_get_ee_pba_number(struct ixgb_hw *hw);
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 176680cb153e..f9f77e4f5965 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -45,7 +45,7 @@
45 */ 45 */
46 46
47char ixgb_driver_name[] = "ixgb"; 47char ixgb_driver_name[] = "ixgb";
48char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver"; 48static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
49 49
50#ifndef CONFIG_IXGB_NAPI 50#ifndef CONFIG_IXGB_NAPI
51#define DRIVERNAPI 51#define DRIVERNAPI
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index a74a5cfaf5bc..2fb3101cb33e 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -285,18 +285,8 @@ static struct device_driver jazz_sonic_driver = {
285 .remove = __devexit_p(jazz_sonic_device_remove), 285 .remove = __devexit_p(jazz_sonic_device_remove),
286}; 286};
287 287
288static void jazz_sonic_platform_release (struct device *device)
289{
290 struct platform_device *pldev;
291
292 /* free device */
293 pldev = to_platform_device (device);
294 kfree (pldev);
295}
296
297static int __init jazz_sonic_init_module(void) 288static int __init jazz_sonic_init_module(void)
298{ 289{
299 struct platform_device *pldev;
300 int err; 290 int err;
301 291
302 if ((err = driver_register(&jazz_sonic_driver))) { 292 if ((err = driver_register(&jazz_sonic_driver))) {
@@ -304,27 +294,19 @@ static int __init jazz_sonic_init_module(void)
304 return err; 294 return err;
305 } 295 }
306 296
307 jazz_sonic_device = NULL; 297 jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0);
308 298 if (!jazz_sonnic_device)
309 if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
310 goto out_unregister; 299 goto out_unregister;
311 }
312 300
313 memset(pldev, 0, sizeof (*pldev)); 301 if (platform_device_add(jazz_sonic_device)) {
314 pldev->name = jazz_sonic_string; 302 platform_device_put(jazz_sonic_device);
315 pldev->id = 0;
316 pldev->dev.release = jazz_sonic_platform_release;
317 jazz_sonic_device = pldev;
318
319 if (platform_device_register (pldev)) {
320 kfree(pldev);
321 jazz_sonic_device = NULL; 303 jazz_sonic_device = NULL;
322 } 304 }
323 305
324 return 0; 306 return 0;
325 307
326out_unregister: 308out_unregister:
327 platform_device_unregister(pldev); 309 driver_unregister(&jazz_sonic_driver);
328 310
329 return -ENOMEM; 311 return -ENOMEM;
330} 312}
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index e9c999d7eb39..9ef4592aca03 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -599,18 +599,8 @@ static struct device_driver mac_sonic_driver = {
599 .remove = __devexit_p(mac_sonic_device_remove), 599 .remove = __devexit_p(mac_sonic_device_remove),
600}; 600};
601 601
602static void mac_sonic_platform_release(struct device *device)
603{
604 struct platform_device *pldev;
605
606 /* free device */
607 pldev = to_platform_device (device);
608 kfree (pldev);
609}
610
611static int __init mac_sonic_init_module(void) 602static int __init mac_sonic_init_module(void)
612{ 603{
613 struct platform_device *pldev;
614 int err; 604 int err;
615 605
616 if ((err = driver_register(&mac_sonic_driver))) { 606 if ((err = driver_register(&mac_sonic_driver))) {
@@ -618,27 +608,20 @@ static int __init mac_sonic_init_module(void)
618 return err; 608 return err;
619 } 609 }
620 610
621 mac_sonic_device = NULL; 611 mac_sonic_device = platform_device_alloc(mac_sonic_string, 0);
622 612 if (!mac_sonic_device) {
623 if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
624 goto out_unregister; 613 goto out_unregister;
625 } 614 }
626 615
627 memset(pldev, 0, sizeof (*pldev)); 616 if (platform_device_add(mac_sonic_device)) {
628 pldev->name = mac_sonic_string; 617 platform_device_put(mac_sonic_device);
629 pldev->id = 0;
630 pldev->dev.release = mac_sonic_platform_release;
631 mac_sonic_device = pldev;
632
633 if (platform_device_register (pldev)) {
634 kfree(pldev);
635 mac_sonic_device = NULL; 618 mac_sonic_device = NULL;
636 } 619 }
637 620
638 return 0; 621 return 0;
639 622
640out_unregister: 623out_unregister:
641 platform_device_unregister(pldev); 624 driver_unregister(&mac_sonic_driver);
642 625
643 return -ENOMEM; 626 return -ENOMEM;
644} 627}
diff --git a/drivers/net/phy/cicada.c b/drivers/net/phy/cicada.c
index c47fb2ecd147..7d8d534255c0 100644
--- a/drivers/net/phy/cicada.c
+++ b/drivers/net/phy/cicada.c
@@ -29,7 +29,6 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h> 32#include <linux/mii.h>
34#include <linux/ethtool.h> 33#include <linux/ethtool.h>
35#include <linux/phy.h> 34#include <linux/phy.h>
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index 6caf499fae32..5e9002e444c5 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -29,7 +29,6 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h> 32#include <linux/mii.h>
34#include <linux/ethtool.h> 33#include <linux/ethtool.h>
35#include <linux/phy.h> 34#include <linux/phy.h>
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index 4c840448ec86..bef79e454c33 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -29,7 +29,6 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h> 32#include <linux/mii.h>
34#include <linux/ethtool.h> 33#include <linux/ethtool.h>
35#include <linux/phy.h> 34#include <linux/phy.h>
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 4a72b025006b..a2d6386d13bc 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -29,7 +29,6 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h> 32#include <linux/mii.h>
34#include <linux/ethtool.h> 33#include <linux/ethtool.h>
35#include <linux/phy.h> 34#include <linux/phy.h>
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 5eab9c42a111..02940c0fef68 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -29,7 +29,6 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h> 32#include <linux/mii.h>
34#include <linux/ethtool.h> 33#include <linux/ethtool.h>
35#include <linux/phy.h> 34#include <linux/phy.h>
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 9209da9dde0d..b8686e47f899 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -30,7 +30,6 @@
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/version.h>
34#include <linux/mii.h> 33#include <linux/mii.h>
35#include <linux/ethtool.h> 34#include <linux/ethtool.h>
36#include <linux/phy.h> 35#include <linux/phy.h>
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 6da1aa0706a1..16bebe7a7ce1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -30,7 +30,6 @@
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/version.h>
34#include <linux/mii.h> 33#include <linux/mii.h>
35#include <linux/ethtool.h> 34#include <linux/ethtool.h>
36#include <linux/phy.h> 35#include <linux/phy.h>
diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c
index d461ba457631..65d995b02b25 100644
--- a/drivers/net/phy/qsemi.c
+++ b/drivers/net/phy/qsemi.c
@@ -29,7 +29,6 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h> 32#include <linux/mii.h>
34#include <linux/ethtool.h> 33#include <linux/ethtool.h>
35#include <linux/phy.h> 34#include <linux/phy.h>
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 9c4935407f26..0745dd9d01f3 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -2110,7 +2110,7 @@ int fill_rxd_3buf(nic_t *nic, RxD_t *rxdp, struct sk_buff *skb)
2110{ 2110{
2111 struct net_device *dev = nic->dev; 2111 struct net_device *dev = nic->dev;
2112 struct sk_buff *frag_list; 2112 struct sk_buff *frag_list;
2113 u64 tmp; 2113 void *tmp;
2114 2114
2115 /* Buffer-1 receives L3/L4 headers */ 2115 /* Buffer-1 receives L3/L4 headers */
2116 ((RxD3_t*)rxdp)->Buffer1_ptr = pci_map_single 2116 ((RxD3_t*)rxdp)->Buffer1_ptr = pci_map_single
@@ -2125,11 +2125,9 @@ int fill_rxd_3buf(nic_t *nic, RxD_t *rxdp, struct sk_buff *skb)
2125 } 2125 }
2126 frag_list = skb_shinfo(skb)->frag_list; 2126 frag_list = skb_shinfo(skb)->frag_list;
2127 frag_list->next = NULL; 2127 frag_list->next = NULL;
2128 tmp = (u64) frag_list->data; 2128 tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1);
2129 tmp += ALIGN_SIZE; 2129 frag_list->data = tmp;
2130 tmp &= ~ALIGN_SIZE; 2130 frag_list->tail = tmp;
2131 frag_list->data = (void *) tmp;
2132 frag_list->tail = (void *) tmp;
2133 2131
2134 /* Buffer-2 receives L4 data payload */ 2132 /* Buffer-2 receives L4 data payload */
2135 ((RxD3_t*)rxdp)->Buffer2_ptr = pci_map_single(nic->pdev, 2133 ((RxD3_t*)rxdp)->Buffer2_ptr = pci_map_single(nic->pdev,
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 849ac88bcccc..6afc6e5dee9b 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -47,6 +47,8 @@
47#include <linux/pci.h> 47#include <linux/pci.h>
48#include <asm/uaccess.h> 48#include <asm/uaccess.h>
49 49
50#include "airo.h"
51
50#ifdef CONFIG_PCI 52#ifdef CONFIG_PCI
51static struct pci_device_id card_ids[] = { 53static struct pci_device_id card_ids[] = {
52 { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, }, 54 { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, },
diff --git a/drivers/net/wireless/airo.h b/drivers/net/wireless/airo.h
new file mode 100644
index 000000000000..e480adf86be6
--- /dev/null
+++ b/drivers/net/wireless/airo.h
@@ -0,0 +1,9 @@
1#ifndef _AIRO_H_
2#define _AIRO_H_
3
4struct net_device *init_airo_card(unsigned short irq, int port, int is_pcmcia,
5 struct device *dmdev);
6int reset_airo_card(struct net_device *dev);
7void stop_airo_card(struct net_device *dev, int freeres);
8
9#endif /* _AIRO_H_ */
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 784de9109113..96ed8da8661d 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -42,6 +42,8 @@
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/system.h> 43#include <asm/system.h>
44 44
45#include "airo.h"
46
45/* 47/*
46 All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If 48 All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
47 you do not define PCMCIA_DEBUG at all, all the debug code will be 49 you do not define PCMCIA_DEBUG at all, all the debug code will be
@@ -78,10 +80,6 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
78 event handler. 80 event handler.
79*/ 81*/
80 82
81struct net_device *init_airo_card( int, int, int, struct device * );
82void stop_airo_card( struct net_device *, int );
83int reset_airo_card( struct net_device * );
84
85static void airo_config(dev_link_t *link); 83static void airo_config(dev_link_t *link);
86static void airo_release(dev_link_t *link); 84static void airo_release(dev_link_t *link);
87static int airo_event(event_t event, int priority, 85static int airo_event(event_t event, int priority,
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index 3b49efa37ee5..fc1eb3564832 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -244,7 +244,6 @@ islpci_eth_transmit(struct sk_buff *skb, struct net_device *ndev)
244 priv->statistics.tx_dropped++; 244 priv->statistics.tx_dropped++;
245 spin_unlock_irqrestore(&priv->slock, flags); 245 spin_unlock_irqrestore(&priv->slock, flags);
246 dev_kfree_skb(skb); 246 dev_kfree_skb(skb);
247 skb = NULL;
248 return err; 247 return err;
249} 248}
250 249
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index 6e6f42d01e64..4b48b31ec235 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -78,17 +78,15 @@ static void parse_data(struct parport *port, int device, char *str)
78 u++; 78 u++;
79 } 79 }
80 if (!strcmp(p, "MFG") || !strcmp(p, "MANUFACTURER")) { 80 if (!strcmp(p, "MFG") || !strcmp(p, "MANUFACTURER")) {
81 if (info->mfr) 81 kfree(info->mfr);
82 kfree (info->mfr);
83 info->mfr = kstrdup(sep, GFP_KERNEL); 82 info->mfr = kstrdup(sep, GFP_KERNEL);
84 } else if (!strcmp(p, "MDL") || !strcmp(p, "MODEL")) { 83 } else if (!strcmp(p, "MDL") || !strcmp(p, "MODEL")) {
85 if (info->model) 84 kfree(info->model);
86 kfree (info->model);
87 info->model = kstrdup(sep, GFP_KERNEL); 85 info->model = kstrdup(sep, GFP_KERNEL);
88 } else if (!strcmp(p, "CLS") || !strcmp(p, "CLASS")) { 86 } else if (!strcmp(p, "CLS") || !strcmp(p, "CLASS")) {
89 int i; 87 int i;
90 if (info->class_name) 88
91 kfree (info->class_name); 89 kfree(info->class_name);
92 info->class_name = kstrdup(sep, GFP_KERNEL); 90 info->class_name = kstrdup(sep, GFP_KERNEL);
93 for (u = sep; *u; u++) 91 for (u = sep; *u; u++)
94 *u = toupper(*u); 92 *u = toupper(*u);
@@ -102,21 +100,22 @@ static void parse_data(struct parport *port, int device, char *str)
102 info->class = PARPORT_CLASS_OTHER; 100 info->class = PARPORT_CLASS_OTHER;
103 } else if (!strcmp(p, "CMD") || 101 } else if (!strcmp(p, "CMD") ||
104 !strcmp(p, "COMMAND SET")) { 102 !strcmp(p, "COMMAND SET")) {
105 if (info->cmdset) 103 kfree(info->cmdset);
106 kfree (info->cmdset);
107 info->cmdset = kstrdup(sep, GFP_KERNEL); 104 info->cmdset = kstrdup(sep, GFP_KERNEL);
108 /* if it speaks printer language, it's 105 /* if it speaks printer language, it's
109 probably a printer */ 106 probably a printer */
110 if (strstr(sep, "PJL") || strstr(sep, "PCL")) 107 if (strstr(sep, "PJL") || strstr(sep, "PCL"))
111 guessed_class = PARPORT_CLASS_PRINTER; 108 guessed_class = PARPORT_CLASS_PRINTER;
112 } else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) { 109 } else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) {
113 if (info->description) 110 kfree(info->description);
114 kfree (info->description);
115 info->description = kstrdup(sep, GFP_KERNEL); 111 info->description = kstrdup(sep, GFP_KERNEL);
116 } 112 }
117 } 113 }
118 rock_on: 114 rock_on:
119 if (q) p = q+1; else p=NULL; 115 if (q)
116 p = q + 1;
117 else
118 p = NULL;
120 } 119 }
121 120
122 /* If the device didn't tell us its class, maybe we have managed to 121 /* If the device didn't tell us its class, maybe we have managed to
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index ae7becf7efa5..9cb3ab156b09 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -202,16 +202,11 @@ static void free_port (struct parport *port)
202 list_del(&port->full_list); 202 list_del(&port->full_list);
203 spin_unlock(&full_list_lock); 203 spin_unlock(&full_list_lock);
204 for (d = 0; d < 5; d++) { 204 for (d = 0; d < 5; d++) {
205 if (port->probe_info[d].class_name) 205 kfree(port->probe_info[d].class_name);
206 kfree (port->probe_info[d].class_name); 206 kfree(port->probe_info[d].mfr);
207 if (port->probe_info[d].mfr) 207 kfree(port->probe_info[d].model);
208 kfree (port->probe_info[d].mfr); 208 kfree(port->probe_info[d].cmdset);
209 if (port->probe_info[d].model) 209 kfree(port->probe_info[d].description);
210 kfree (port->probe_info[d].model);
211 if (port->probe_info[d].cmdset)
212 kfree (port->probe_info[d].cmdset);
213 if (port->probe_info[d].description)
214 kfree (port->probe_info[d].description);
215 } 210 }
216 211
217 kfree(port->name); 212 kfree(port->name);
@@ -618,9 +613,9 @@ parport_register_device(struct parport *port, const char *name,
618 return tmp; 613 return tmp;
619 614
620 out_free_all: 615 out_free_all:
621 kfree (tmp->state); 616 kfree(tmp->state);
622 out_free_pardevice: 617 out_free_pardevice:
623 kfree (tmp); 618 kfree(tmp);
624 out: 619 out:
625 parport_put_port (port); 620 parport_put_port (port);
626 module_put(port->ops->owner); 621 module_put(port->ops->owner);
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 93e39c4096a9..00b81a7bdd26 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -259,8 +259,7 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
259 sizeof(struct irq_routing_table)) / sizeof(struct irq_info); 259 sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
260 // Make sure I got at least one entry 260 // Make sure I got at least one entry
261 if (len == 0) { 261 if (len == 0) {
262 if (PCIIRQRoutingInfoLength != NULL) 262 kfree(PCIIRQRoutingInfoLength );
263 kfree(PCIIRQRoutingInfoLength );
264 return -1; 263 return -1;
265 } 264 }
266 265
@@ -275,8 +274,7 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
275 ctrl->pci_bus->number = tbus; 274 ctrl->pci_bus->number = tbus;
276 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work); 275 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work);
277 if (!nobridge || (work == 0xffffffff)) { 276 if (!nobridge || (work == 0xffffffff)) {
278 if (PCIIRQRoutingInfoLength != NULL) 277 kfree(PCIIRQRoutingInfoLength );
279 kfree(PCIIRQRoutingInfoLength );
280 return 0; 278 return 0;
281 } 279 }
282 280
@@ -289,20 +287,17 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
289 dbg("Scan bus for Non Bridge: bus %d\n", tbus); 287 dbg("Scan bus for Non Bridge: bus %d\n", tbus);
290 if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) { 288 if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) {
291 *bus_num = tbus; 289 *bus_num = tbus;
292 if (PCIIRQRoutingInfoLength != NULL) 290 kfree(PCIIRQRoutingInfoLength );
293 kfree(PCIIRQRoutingInfoLength );
294 return 0; 291 return 0;
295 } 292 }
296 } else { 293 } else {
297 if (PCIIRQRoutingInfoLength != NULL) 294 kfree(PCIIRQRoutingInfoLength );
298 kfree(PCIIRQRoutingInfoLength );
299 return 0; 295 return 0;
300 } 296 }
301 297
302 } 298 }
303 } 299 }
304 if (PCIIRQRoutingInfoLength != NULL) 300 kfree(PCIIRQRoutingInfoLength );
305 kfree(PCIIRQRoutingInfoLength );
306 return -1; 301 return -1;
307} 302}
308 303
diff --git a/drivers/pci/hotplug/pciehprm_nonacpi.c b/drivers/pci/hotplug/pciehprm_nonacpi.c
index 33b2c69a0829..76c727c74cc0 100644
--- a/drivers/pci/hotplug/pciehprm_nonacpi.c
+++ b/drivers/pci/hotplug/pciehprm_nonacpi.c
@@ -31,6 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/sched.h>
34#include <linux/pci.h> 35#include <linux/pci.h>
35#include <linux/init.h> 36#include <linux/init.h>
36#include <linux/slab.h> 37#include <linux/slab.h>
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index ae986e590b48..94e68c54d273 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -10,6 +10,7 @@
10#include <linux/mempolicy.h> 10#include <linux/mempolicy.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/sched.h>
13#include "pci.h" 14#include "pci.h"
14 15
15/* 16/*
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 3afb682255a0..2dc3e611a9a3 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -334,10 +334,8 @@ void destroy_cis_cache(struct pcmcia_socket *s)
334 /* 334 /*
335 * If there was a fake CIS, destroy that as well. 335 * If there was a fake CIS, destroy that as well.
336 */ 336 */
337 if (s->fake_cis) { 337 kfree(s->fake_cis);
338 kfree(s->fake_cis); 338 s->fake_cis = NULL;
339 s->fake_cis = NULL;
340 }
341} 339}
342EXPORT_SYMBOL(destroy_cis_cache); 340EXPORT_SYMBOL(destroy_cis_cache);
343 341
@@ -386,10 +384,8 @@ int verify_cis_cache(struct pcmcia_socket *s)
386 384
387int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) 385int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis)
388{ 386{
389 if (s->fake_cis != NULL) { 387 kfree(s->fake_cis);
390 kfree(s->fake_cis); 388 s->fake_cis = NULL;
391 s->fake_cis = NULL;
392 }
393 if (cis->Length > CISTPL_MAX_CIS_SIZE) 389 if (cis->Length > CISTPL_MAX_CIS_SIZE)
394 return CS_BAD_SIZE; 390 return CS_BAD_SIZE;
395 s->fake_cis = kmalloc(cis->Length, GFP_KERNEL); 391 s->fake_cis = kmalloc(cis->Length, GFP_KERNEL);
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index d5e76423a0ee..234cdca6fe13 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -331,10 +331,8 @@ static void shutdown_socket(struct pcmcia_socket *s)
331 cb_free(s); 331 cb_free(s);
332#endif 332#endif
333 s->functions = 0; 333 s->functions = 0;
334 if (s->config) { 334 kfree(s->config);
335 kfree(s->config); 335 s->config = NULL;
336 s->config = NULL;
337 }
338 336
339 { 337 {
340 int status; 338 int status;
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index e95ed67d4f05..bd7c966ea2d7 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -12,7 +12,7 @@
12#include "base.h" 12#include "base.h"
13 13
14LIST_HEAD(pnp_cards); 14LIST_HEAD(pnp_cards);
15LIST_HEAD(pnp_card_drivers); 15static LIST_HEAD(pnp_card_drivers);
16 16
17 17
18static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card) 18static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card)
@@ -374,11 +374,13 @@ void pnp_unregister_card_driver(struct pnp_card_driver * drv)
374 pnp_unregister_driver(&drv->link); 374 pnp_unregister_driver(&drv->link);
375} 375}
376 376
377#if 0
377EXPORT_SYMBOL(pnp_add_card); 378EXPORT_SYMBOL(pnp_add_card);
378EXPORT_SYMBOL(pnp_remove_card); 379EXPORT_SYMBOL(pnp_remove_card);
379EXPORT_SYMBOL(pnp_add_card_device); 380EXPORT_SYMBOL(pnp_add_card_device);
380EXPORT_SYMBOL(pnp_remove_card_device); 381EXPORT_SYMBOL(pnp_remove_card_device);
381EXPORT_SYMBOL(pnp_add_card_id); 382EXPORT_SYMBOL(pnp_add_card_id);
383#endif /* 0 */
382EXPORT_SYMBOL(pnp_request_card_device); 384EXPORT_SYMBOL(pnp_request_card_device);
383EXPORT_SYMBOL(pnp_release_card_device); 385EXPORT_SYMBOL(pnp_release_card_device);
384EXPORT_SYMBOL(pnp_register_card_driver); 386EXPORT_SYMBOL(pnp_register_card_driver);
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index deed92459bc5..aec83ec5ea23 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -158,13 +158,14 @@ void __pnp_remove_device(struct pnp_dev *dev)
158 * 158 *
159 * this function will free all mem used by dev 159 * this function will free all mem used by dev
160 */ 160 */
161 161#if 0
162void pnp_remove_device(struct pnp_dev *dev) 162void pnp_remove_device(struct pnp_dev *dev)
163{ 163{
164 if (!dev || dev->card) 164 if (!dev || dev->card)
165 return; 165 return;
166 __pnp_remove_device(dev); 166 __pnp_remove_device(dev);
167} 167}
168#endif /* 0 */
168 169
169static int __init pnp_init(void) 170static int __init pnp_init(void)
170{ 171{
@@ -174,7 +175,9 @@ static int __init pnp_init(void)
174 175
175subsys_initcall(pnp_init); 176subsys_initcall(pnp_init);
176 177
178#if 0
177EXPORT_SYMBOL(pnp_register_protocol); 179EXPORT_SYMBOL(pnp_register_protocol);
178EXPORT_SYMBOL(pnp_unregister_protocol); 180EXPORT_SYMBOL(pnp_unregister_protocol);
179EXPORT_SYMBOL(pnp_add_device); 181EXPORT_SYMBOL(pnp_add_device);
180EXPORT_SYMBOL(pnp_remove_device); 182EXPORT_SYMBOL(pnp_remove_device);
183#endif /* 0 */
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index 33da25f3213f..d3ccce706ab4 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -214,6 +214,8 @@ int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev)
214 214
215EXPORT_SYMBOL(pnp_register_driver); 215EXPORT_SYMBOL(pnp_register_driver);
216EXPORT_SYMBOL(pnp_unregister_driver); 216EXPORT_SYMBOL(pnp_unregister_driver);
217#if 0
217EXPORT_SYMBOL(pnp_add_id); 218EXPORT_SYMBOL(pnp_add_id);
219#endif
218EXPORT_SYMBOL(pnp_device_attach); 220EXPORT_SYMBOL(pnp_device_attach);
219EXPORT_SYMBOL(pnp_device_detach); 221EXPORT_SYMBOL(pnp_device_detach);
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index beedd86800f4..57fd60314d59 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -941,7 +941,9 @@ EXPORT_SYMBOL(isapnp_protocol);
941EXPORT_SYMBOL(isapnp_present); 941EXPORT_SYMBOL(isapnp_present);
942EXPORT_SYMBOL(isapnp_cfg_begin); 942EXPORT_SYMBOL(isapnp_cfg_begin);
943EXPORT_SYMBOL(isapnp_cfg_end); 943EXPORT_SYMBOL(isapnp_cfg_end);
944#if 0
944EXPORT_SYMBOL(isapnp_read_byte); 945EXPORT_SYMBOL(isapnp_read_byte);
946#endif
945EXPORT_SYMBOL(isapnp_write_byte); 947EXPORT_SYMBOL(isapnp_write_byte);
946 948
947static int isapnp_read_resources(struct pnp_dev *dev, struct pnp_resource_table *res) 949static int isapnp_read_resources(struct pnp_dev *dev, struct pnp_resource_table *res)
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index cbb2749db178..261668618b2d 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -555,7 +555,9 @@ void pnp_resource_change(struct resource *resource, unsigned long start, unsigne
555 555
556 556
557EXPORT_SYMBOL(pnp_manual_config_dev); 557EXPORT_SYMBOL(pnp_manual_config_dev);
558#if 0
558EXPORT_SYMBOL(pnp_auto_config_dev); 559EXPORT_SYMBOL(pnp_auto_config_dev);
560#endif
559EXPORT_SYMBOL(pnp_activate_dev); 561EXPORT_SYMBOL(pnp_activate_dev);
560EXPORT_SYMBOL(pnp_disable_dev); 562EXPORT_SYMBOL(pnp_disable_dev);
561EXPORT_SYMBOL(pnp_resource_change); 563EXPORT_SYMBOL(pnp_resource_change);
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 1a8915e74160..816479ad217b 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -117,7 +117,7 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
117 return ACPI_FAILURE(status) ? -ENODEV : 0; 117 return ACPI_FAILURE(status) ? -ENODEV : 0;
118} 118}
119 119
120struct pnp_protocol pnpacpi_protocol = { 120static struct pnp_protocol pnpacpi_protocol = {
121 .name = "Plug and Play ACPI", 121 .name = "Plug and Play ACPI",
122 .get = pnpacpi_get_resources, 122 .get = pnpacpi_get_resources,
123 .set = pnpacpi_set_resources, 123 .set = pnpacpi_set_resources,
@@ -234,7 +234,7 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
234} 234}
235 235
236int pnpacpi_disabled __initdata; 236int pnpacpi_disabled __initdata;
237int __init pnpacpi_init(void) 237static int __init pnpacpi_init(void)
238{ 238{
239 if (acpi_disabled || pnpacpi_disabled) { 239 if (acpi_disabled || pnpacpi_disabled) {
240 pnp_info("PnP ACPI: disabled"); 240 pnp_info("PnP ACPI: disabled");
@@ -258,4 +258,6 @@ static int __init pnpacpi_setup(char *str)
258} 258}
259__setup("pnpacpi=", pnpacpi_setup); 259__setup("pnpacpi=", pnpacpi_setup);
260 260
261#if 0
261EXPORT_SYMBOL(pnpacpi_protocol); 262EXPORT_SYMBOL(pnpacpi_protocol);
263#endif
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 887ad8939349..6ded527169f4 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -477,12 +477,14 @@ int pnp_check_dma(struct pnp_dev * dev, int idx)
477} 477}
478 478
479 479
480#if 0
480EXPORT_SYMBOL(pnp_register_dependent_option); 481EXPORT_SYMBOL(pnp_register_dependent_option);
481EXPORT_SYMBOL(pnp_register_independent_option); 482EXPORT_SYMBOL(pnp_register_independent_option);
482EXPORT_SYMBOL(pnp_register_irq_resource); 483EXPORT_SYMBOL(pnp_register_irq_resource);
483EXPORT_SYMBOL(pnp_register_dma_resource); 484EXPORT_SYMBOL(pnp_register_dma_resource);
484EXPORT_SYMBOL(pnp_register_port_resource); 485EXPORT_SYMBOL(pnp_register_port_resource);
485EXPORT_SYMBOL(pnp_register_mem_resource); 486EXPORT_SYMBOL(pnp_register_mem_resource);
487#endif /* 0 */
486 488
487 489
488/* format is: pnp_reserve_irq=irq1[,irq2] .... */ 490/* format is: pnp_reserve_irq=irq1[,irq2] .... */
diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
new file mode 100644
index 000000000000..0b2d2c3579a7
--- /dev/null
+++ b/drivers/rapidio/Kconfig
@@ -0,0 +1,18 @@
1#
2# RapidIO configuration
3#
4config RAPIDIO_8_BIT_TRANSPORT
5 bool "8-bit transport addressing"
6 depends on RAPIDIO
7 ---help---
8 By default, the kernel assumes a 16-bit addressed RapidIO
9 network. By selecting this option, the kernel will support
10 an 8-bit addressed network.
11
12config RAPIDIO_DISC_TIMEOUT
13 int "Discovery timeout duration (seconds)"
14 depends on RAPIDIO
15 default "30"
16 ---help---
17 Amount of time a discovery node waits for a host to complete
18 enumeration beforing giving up.
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile
new file mode 100644
index 000000000000..7c0e1818de51
--- /dev/null
+++ b/drivers/rapidio/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for RapidIO interconnect services
3#
4obj-y += rio.o rio-access.o rio-driver.o rio-scan.o rio-sysfs.o
5
6obj-$(CONFIG_RAPIDIO) += switches/
diff --git a/drivers/rapidio/rio-access.c b/drivers/rapidio/rio-access.c
new file mode 100644
index 000000000000..b9fab2ae3a36
--- /dev/null
+++ b/drivers/rapidio/rio-access.c
@@ -0,0 +1,175 @@
1/*
2 * RapidIO configuration space access support
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/rio.h>
14#include <linux/module.h>
15
16/*
17 * These interrupt-safe spinlocks protect all accesses to RIO
18 * configuration space and doorbell access.
19 */
20static spinlock_t rio_config_lock = SPIN_LOCK_UNLOCKED;
21static spinlock_t rio_doorbell_lock = SPIN_LOCK_UNLOCKED;
22
23/*
24 * Wrappers for all RIO configuration access functions. They just check
25 * alignment, do locking and call the low-level functions pointed to
26 * by rio_mport->ops.
27 */
28
29#define RIO_8_BAD 0
30#define RIO_16_BAD (offset & 1)
31#define RIO_32_BAD (offset & 3)
32
33/**
34 * RIO_LOP_READ - Generate rio_local_read_config_* functions
35 * @size: Size of configuration space read (8, 16, 32 bits)
36 * @type: C type of value argument
37 * @len: Length of configuration space read (1, 2, 4 bytes)
38 *
39 * Generates rio_local_read_config_* functions used to access
40 * configuration space registers on the local device.
41 */
42#define RIO_LOP_READ(size,type,len) \
43int __rio_local_read_config_##size \
44 (struct rio_mport *mport, u32 offset, type *value) \
45{ \
46 int res; \
47 unsigned long flags; \
48 u32 data = 0; \
49 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
50 spin_lock_irqsave(&rio_config_lock, flags); \
51 res = mport->ops->lcread(mport->id, offset, len, &data); \
52 *value = (type)data; \
53 spin_unlock_irqrestore(&rio_config_lock, flags); \
54 return res; \
55}
56
57/**
58 * RIO_LOP_WRITE - Generate rio_local_write_config_* functions
59 * @size: Size of configuration space write (8, 16, 32 bits)
60 * @type: C type of value argument
61 * @len: Length of configuration space write (1, 2, 4 bytes)
62 *
63 * Generates rio_local_write_config_* functions used to access
64 * configuration space registers on the local device.
65 */
66#define RIO_LOP_WRITE(size,type,len) \
67int __rio_local_write_config_##size \
68 (struct rio_mport *mport, u32 offset, type value) \
69{ \
70 int res; \
71 unsigned long flags; \
72 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
73 spin_lock_irqsave(&rio_config_lock, flags); \
74 res = mport->ops->lcwrite(mport->id, offset, len, value); \
75 spin_unlock_irqrestore(&rio_config_lock, flags); \
76 return res; \
77}
78
79RIO_LOP_READ(8, u8, 1)
80RIO_LOP_READ(16, u16, 2)
81RIO_LOP_READ(32, u32, 4)
82RIO_LOP_WRITE(8, u8, 1)
83RIO_LOP_WRITE(16, u16, 2)
84RIO_LOP_WRITE(32, u32, 4)
85
86EXPORT_SYMBOL_GPL(__rio_local_read_config_8);
87EXPORT_SYMBOL_GPL(__rio_local_read_config_16);
88EXPORT_SYMBOL_GPL(__rio_local_read_config_32);
89EXPORT_SYMBOL_GPL(__rio_local_write_config_8);
90EXPORT_SYMBOL_GPL(__rio_local_write_config_16);
91EXPORT_SYMBOL_GPL(__rio_local_write_config_32);
92
93/**
94 * RIO_OP_READ - Generate rio_mport_read_config_* functions
95 * @size: Size of configuration space read (8, 16, 32 bits)
96 * @type: C type of value argument
97 * @len: Length of configuration space read (1, 2, 4 bytes)
98 *
99 * Generates rio_mport_read_config_* functions used to access
100 * configuration space registers on the local device.
101 */
102#define RIO_OP_READ(size,type,len) \
103int rio_mport_read_config_##size \
104 (struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type *value) \
105{ \
106 int res; \
107 unsigned long flags; \
108 u32 data = 0; \
109 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
110 spin_lock_irqsave(&rio_config_lock, flags); \
111 res = mport->ops->cread(mport->id, destid, hopcount, offset, len, &data); \
112 *value = (type)data; \
113 spin_unlock_irqrestore(&rio_config_lock, flags); \
114 return res; \
115}
116
117/**
118 * RIO_OP_WRITE - Generate rio_mport_write_config_* functions
119 * @size: Size of configuration space write (8, 16, 32 bits)
120 * @type: C type of value argument
121 * @len: Length of configuration space write (1, 2, 4 bytes)
122 *
123 * Generates rio_mport_write_config_* functions used to access
124 * configuration space registers on the local device.
125 */
126#define RIO_OP_WRITE(size,type,len) \
127int rio_mport_write_config_##size \
128 (struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type value) \
129{ \
130 int res; \
131 unsigned long flags; \
132 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
133 spin_lock_irqsave(&rio_config_lock, flags); \
134 res = mport->ops->cwrite(mport->id, destid, hopcount, offset, len, value); \
135 spin_unlock_irqrestore(&rio_config_lock, flags); \
136 return res; \
137}
138
139RIO_OP_READ(8, u8, 1)
140RIO_OP_READ(16, u16, 2)
141RIO_OP_READ(32, u32, 4)
142RIO_OP_WRITE(8, u8, 1)
143RIO_OP_WRITE(16, u16, 2)
144RIO_OP_WRITE(32, u32, 4)
145
146EXPORT_SYMBOL_GPL(rio_mport_read_config_8);
147EXPORT_SYMBOL_GPL(rio_mport_read_config_16);
148EXPORT_SYMBOL_GPL(rio_mport_read_config_32);
149EXPORT_SYMBOL_GPL(rio_mport_write_config_8);
150EXPORT_SYMBOL_GPL(rio_mport_write_config_16);
151EXPORT_SYMBOL_GPL(rio_mport_write_config_32);
152
153/**
154 * rio_mport_send_doorbell - Send a doorbell message
155 *
156 * @mport: RIO master port
157 * @destid: RIO device destination ID
158 * @data: Doorbell message data
159 *
160 * Send a doorbell message to a RIO device. The doorbell message
161 * has a 16-bit info field provided by the data argument.
162 */
163int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data)
164{
165 int res;
166 unsigned long flags;
167
168 spin_lock_irqsave(&rio_doorbell_lock, flags);
169 res = mport->ops->dsend(mport->id, destid, data);
170 spin_unlock_irqrestore(&rio_doorbell_lock, flags);
171
172 return res;
173}
174
175EXPORT_SYMBOL_GPL(rio_mport_send_doorbell);
diff --git a/drivers/rapidio/rio-driver.c b/drivers/rapidio/rio-driver.c
new file mode 100644
index 000000000000..dc749609699a
--- /dev/null
+++ b/drivers/rapidio/rio-driver.c
@@ -0,0 +1,229 @@
1/*
2 * RapidIO driver support
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/rio.h>
16#include <linux/rio_ids.h>
17
18#include "rio.h"
19
20/**
21 * rio_match_device - Tell if a RIO device has a matching RIO device id structure
22 * @id: the RIO device id structure to match against
23 * @rdev: the RIO device structure to match against
24 *
25 * Used from driver probe and bus matching to check whether a RIO device
26 * matches a device id structure provided by a RIO driver. Returns the
27 * matching &struct rio_device_id or %NULL if there is no match.
28 */
29static const struct rio_device_id *rio_match_device(const struct rio_device_id
30 *id,
31 const struct rio_dev *rdev)
32{
33 while (id->vid || id->asm_vid) {
34 if (((id->vid == RIO_ANY_ID) || (id->vid == rdev->vid)) &&
35 ((id->did == RIO_ANY_ID) || (id->did == rdev->did)) &&
36 ((id->asm_vid == RIO_ANY_ID)
37 || (id->asm_vid == rdev->asm_vid))
38 && ((id->asm_did == RIO_ANY_ID)
39 || (id->asm_did == rdev->asm_did)))
40 return id;
41 id++;
42 }
43 return NULL;
44}
45
46/**
47 * rio_dev_get - Increments the reference count of the RIO device structure
48 *
49 * @rdev: RIO device being referenced
50 *
51 * Each live reference to a device should be refcounted.
52 *
53 * Drivers for RIO devices should normally record such references in
54 * their probe() methods, when they bind to a device, and release
55 * them by calling rio_dev_put(), in their disconnect() methods.
56 */
57struct rio_dev *rio_dev_get(struct rio_dev *rdev)
58{
59 if (rdev)
60 get_device(&rdev->dev);
61
62 return rdev;
63}
64
65/**
66 * rio_dev_put - Release a use of the RIO device structure
67 *
68 * @rdev: RIO device being disconnected
69 *
70 * Must be called when a user of a device is finished with it.
71 * When the last user of the device calls this function, the
72 * memory of the device is freed.
73 */
74void rio_dev_put(struct rio_dev *rdev)
75{
76 if (rdev)
77 put_device(&rdev->dev);
78}
79
80/**
81 * rio_device_probe - Tell if a RIO device structure has a matching RIO
82 * device id structure
83 * @id: the RIO device id structure to match against
84 * @dev: the RIO device structure to match against
85 *
86 * return 0 and set rio_dev->driver when drv claims rio_dev, else error
87 */
88static int rio_device_probe(struct device *dev)
89{
90 struct rio_driver *rdrv = to_rio_driver(dev->driver);
91 struct rio_dev *rdev = to_rio_dev(dev);
92 int error = -ENODEV;
93 const struct rio_device_id *id;
94
95 if (!rdev->driver && rdrv->probe) {
96 if (!rdrv->id_table)
97 return error;
98 id = rio_match_device(rdrv->id_table, rdev);
99 rio_dev_get(rdev);
100 if (id)
101 error = rdrv->probe(rdev, id);
102 if (error >= 0) {
103 rdev->driver = rdrv;
104 error = 0;
105 rio_dev_put(rdev);
106 }
107 }
108 return error;
109}
110
111/**
112 * rio_device_remove - Remove a RIO device from the system
113 *
114 * @dev: the RIO device structure to match against
115 *
116 * Remove a RIO device from the system. If it has an associated
117 * driver, then run the driver remove() method. Then update
118 * the reference count.
119 */
120static int rio_device_remove(struct device *dev)
121{
122 struct rio_dev *rdev = to_rio_dev(dev);
123 struct rio_driver *rdrv = rdev->driver;
124
125 if (rdrv) {
126 if (rdrv->remove)
127 rdrv->remove(rdev);
128 rdev->driver = NULL;
129 }
130
131 rio_dev_put(rdev);
132
133 return 0;
134}
135
136/**
137 * rio_register_driver - register a new RIO driver
138 * @rdrv: the RIO driver structure to register
139 *
140 * Adds a &struct rio_driver to the list of registered drivers
141 * Returns a negative value on error, otherwise 0. If no error
142 * occurred, the driver remains registered even if no device
143 * was claimed during registration.
144 */
145int rio_register_driver(struct rio_driver *rdrv)
146{
147 /* initialize common driver fields */
148 rdrv->driver.name = rdrv->name;
149 rdrv->driver.bus = &rio_bus_type;
150 rdrv->driver.probe = rio_device_probe;
151 rdrv->driver.remove = rio_device_remove;
152
153 /* register with core */
154 return driver_register(&rdrv->driver);
155}
156
157/**
158 * rio_unregister_driver - unregister a RIO driver
159 * @rdrv: the RIO driver structure to unregister
160 *
161 * Deletes the &struct rio_driver from the list of registered RIO
162 * drivers, gives it a chance to clean up by calling its remove()
163 * function for each device it was responsible for, and marks those
164 * devices as driverless.
165 */
166void rio_unregister_driver(struct rio_driver *rdrv)
167{
168 driver_unregister(&rdrv->driver);
169}
170
171/**
172 * rio_match_bus - Tell if a RIO device structure has a matching RIO
173 * driver device id structure
174 * @dev: the standard device structure to match against
175 * @drv: the standard driver structure containing the ids to match against
176 *
177 * Used by a driver to check whether a RIO device present in the
178 * system is in its list of supported devices. Returns 1 if
179 * there is a matching &struct rio_device_id or 0 if there is
180 * no match.
181 */
182static int rio_match_bus(struct device *dev, struct device_driver *drv)
183{
184 struct rio_dev *rdev = to_rio_dev(dev);
185 struct rio_driver *rdrv = to_rio_driver(drv);
186 const struct rio_device_id *id = rdrv->id_table;
187 const struct rio_device_id *found_id;
188
189 if (!id)
190 goto out;
191
192 found_id = rio_match_device(id, rdev);
193
194 if (found_id)
195 return 1;
196
197 out:return 0;
198}
199
200static struct device rio_bus = {
201 .bus_id = "rapidio",
202};
203
204struct bus_type rio_bus_type = {
205 .name = "rapidio",
206 .match = rio_match_bus,
207 .dev_attrs = rio_dev_attrs
208};
209
210/**
211 * rio_bus_init - Register the RapidIO bus with the device model
212 *
213 * Registers the RIO bus device and RIO bus type with the Linux
214 * device model.
215 */
216static int __init rio_bus_init(void)
217{
218 if (device_register(&rio_bus) < 0)
219 printk("RIO: failed to register RIO bus device\n");
220 return bus_register(&rio_bus_type);
221}
222
223postcore_initcall(rio_bus_init);
224
225EXPORT_SYMBOL_GPL(rio_register_driver);
226EXPORT_SYMBOL_GPL(rio_unregister_driver);
227EXPORT_SYMBOL_GPL(rio_bus_type);
228EXPORT_SYMBOL_GPL(rio_dev_get);
229EXPORT_SYMBOL_GPL(rio_dev_put);
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
new file mode 100644
index 000000000000..4f7ed4bd3be9
--- /dev/null
+++ b/drivers/rapidio/rio-scan.c
@@ -0,0 +1,945 @@
1/*
2 * RapidIO enumeration and discovery support
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/config.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16
17#include <linux/delay.h>
18#include <linux/dma-mapping.h>
19#include <linux/init.h>
20#include <linux/rio.h>
21#include <linux/rio_drv.h>
22#include <linux/rio_ids.h>
23#include <linux/rio_regs.h>
24#include <linux/module.h>
25#include <linux/spinlock.h>
26#include <linux/timer.h>
27
28#include "rio.h"
29
30LIST_HEAD(rio_devices);
31static LIST_HEAD(rio_switches);
32
33#define RIO_ENUM_CMPL_MAGIC 0xdeadbeef
34
35static void rio_enum_timeout(unsigned long);
36
37DEFINE_SPINLOCK(rio_global_list_lock);
38
39static int next_destid = 0;
40static int next_switchid = 0;
41static int next_net = 0;
42
43static struct timer_list rio_enum_timer =
44TIMER_INITIALIZER(rio_enum_timeout, 0, 0);
45
46static int rio_mport_phys_table[] = {
47 RIO_EFB_PAR_EP_ID,
48 RIO_EFB_PAR_EP_REC_ID,
49 RIO_EFB_SER_EP_ID,
50 RIO_EFB_SER_EP_REC_ID,
51 -1,
52};
53
54static int rio_sport_phys_table[] = {
55 RIO_EFB_PAR_EP_FREE_ID,
56 RIO_EFB_SER_EP_FREE_ID,
57 -1,
58};
59
60/**
61 * rio_get_device_id - Get the base/extended device id for a device
62 * @port: RIO master port
63 * @destid: Destination ID of device
64 * @hopcount: Hopcount to device
65 *
66 * Reads the base/extended device id from a device. Returns the
67 * 8/16-bit device ID.
68 */
69static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount)
70{
71 u32 result;
72
73 rio_mport_read_config_32(port, destid, hopcount, RIO_DID_CSR, &result);
74
75 return RIO_GET_DID(result);
76}
77
78/**
79 * rio_set_device_id - Set the base/extended device id for a device
80 * @port: RIO master port
81 * @destid: Destination ID of device
82 * @hopcount: Hopcount to device
83 * @did: Device ID value to be written
84 *
85 * Writes the base/extended device id from a device.
86 */
87static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did)
88{
89 rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR,
90 RIO_SET_DID(did));
91}
92
93/**
94 * rio_local_set_device_id - Set the base/extended device id for a port
95 * @port: RIO master port
96 * @did: Device ID value to be written
97 *
98 * Writes the base/extended device id from a device.
99 */
100static void rio_local_set_device_id(struct rio_mport *port, u16 did)
101{
102 rio_local_write_config_32(port, RIO_DID_CSR, RIO_SET_DID(did));
103}
104
105/**
106 * rio_clear_locks- Release all host locks and signal enumeration complete
107 * @port: Master port to issue transaction
108 *
109 * Marks the component tag CSR on each device with the enumeration
110 * complete flag. When complete, it then release the host locks on
111 * each device. Returns 0 on success or %-EINVAL on failure.
112 */
113static int rio_clear_locks(struct rio_mport *port)
114{
115 struct rio_dev *rdev;
116 u32 result;
117 int ret = 0;
118
119 /* Write component tag CSR magic complete value */
120 rio_local_write_config_32(port, RIO_COMPONENT_TAG_CSR,
121 RIO_ENUM_CMPL_MAGIC);
122 list_for_each_entry(rdev, &rio_devices, global_list)
123 rio_write_config_32(rdev, RIO_COMPONENT_TAG_CSR,
124 RIO_ENUM_CMPL_MAGIC);
125
126 /* Release host device id locks */
127 rio_local_write_config_32(port, RIO_HOST_DID_LOCK_CSR,
128 port->host_deviceid);
129 rio_local_read_config_32(port, RIO_HOST_DID_LOCK_CSR, &result);
130 if ((result & 0xffff) != 0xffff) {
131 printk(KERN_INFO
132 "RIO: badness when releasing host lock on master port, result %8.8x\n",
133 result);
134 ret = -EINVAL;
135 }
136 list_for_each_entry(rdev, &rio_devices, global_list) {
137 rio_write_config_32(rdev, RIO_HOST_DID_LOCK_CSR,
138 port->host_deviceid);
139 rio_read_config_32(rdev, RIO_HOST_DID_LOCK_CSR, &result);
140 if ((result & 0xffff) != 0xffff) {
141 printk(KERN_INFO
142 "RIO: badness when releasing host lock on vid %4.4x did %4.4x\n",
143 rdev->vid, rdev->did);
144 ret = -EINVAL;
145 }
146 }
147
148 return ret;
149}
150
151/**
152 * rio_enum_host- Set host lock and initialize host destination ID
153 * @port: Master port to issue transaction
154 *
155 * Sets the local host master port lock and destination ID register
156 * with the host device ID value. The host device ID value is provided
157 * by the platform. Returns %0 on success or %-1 on failure.
158 */
159static int rio_enum_host(struct rio_mport *port)
160{
161 u32 result;
162
163 /* Set master port host device id lock */
164 rio_local_write_config_32(port, RIO_HOST_DID_LOCK_CSR,
165 port->host_deviceid);
166
167 rio_local_read_config_32(port, RIO_HOST_DID_LOCK_CSR, &result);
168 if ((result & 0xffff) != port->host_deviceid)
169 return -1;
170
171 /* Set master port destid and init destid ctr */
172 rio_local_set_device_id(port, port->host_deviceid);
173
174 if (next_destid == port->host_deviceid)
175 next_destid++;
176
177 return 0;
178}
179
180/**
181 * rio_device_has_destid- Test if a device contains a destination ID register
182 * @port: Master port to issue transaction
183 * @src_ops: RIO device source operations
184 * @dst_ops: RIO device destination operations
185 *
186 * Checks the provided @src_ops and @dst_ops for the necessary transaction
187 * capabilities that indicate whether or not a device will implement a
188 * destination ID register. Returns 1 if true or 0 if false.
189 */
190static int rio_device_has_destid(struct rio_mport *port, int src_ops,
191 int dst_ops)
192{
193 u32 mask = RIO_OPS_READ | RIO_OPS_WRITE | RIO_OPS_ATOMIC_TST_SWP | RIO_OPS_ATOMIC_INC | RIO_OPS_ATOMIC_DEC | RIO_OPS_ATOMIC_SET | RIO_OPS_ATOMIC_CLR;
194
195 return !!((src_ops | dst_ops) & mask);
196}
197
198/**
199 * rio_release_dev- Frees a RIO device struct
200 * @dev: LDM device associated with a RIO device struct
201 *
202 * Gets the RIO device struct associated a RIO device struct.
203 * The RIO device struct is freed.
204 */
205static void rio_release_dev(struct device *dev)
206{
207 struct rio_dev *rdev;
208
209 rdev = to_rio_dev(dev);
210 kfree(rdev);
211}
212
213/**
214 * rio_is_switch- Tests if a RIO device has switch capabilities
215 * @rdev: RIO device
216 *
217 * Gets the RIO device Processing Element Features register
218 * contents and tests for switch capabilities. Returns 1 if
219 * the device is a switch or 0 if it is not a switch.
220 * The RIO device struct is freed.
221 */
222static int rio_is_switch(struct rio_dev *rdev)
223{
224 if (rdev->pef & RIO_PEF_SWITCH)
225 return 1;
226 return 0;
227}
228
229/**
230 * rio_route_set_ops- Sets routing operations for a particular vendor switch
231 * @rdev: RIO device
232 *
233 * Searches the RIO route ops table for known switch types. If the vid
234 * and did match a switch table entry, then set the add_entry() and
235 * get_entry() ops to the table entry values.
236 */
237static void rio_route_set_ops(struct rio_dev *rdev)
238{
239 struct rio_route_ops *cur = __start_rio_route_ops;
240 struct rio_route_ops *end = __end_rio_route_ops;
241
242 while (cur < end) {
243 if ((cur->vid == rdev->vid) && (cur->did == rdev->did)) {
244 pr_debug("RIO: adding routing ops for %s\n", rio_name(rdev));
245 rdev->rswitch->add_entry = cur->add_hook;
246 rdev->rswitch->get_entry = cur->get_hook;
247 }
248 cur++;
249 }
250
251 if (!rdev->rswitch->add_entry || !rdev->rswitch->get_entry)
252 printk(KERN_ERR "RIO: missing routing ops for %s\n",
253 rio_name(rdev));
254}
255
256/**
257 * rio_add_device- Adds a RIO device to the device model
258 * @rdev: RIO device
259 *
260 * Adds the RIO device to the global device list and adds the RIO
261 * device to the RIO device list. Creates the generic sysfs nodes
262 * for an RIO device.
263 */
264static void __devinit rio_add_device(struct rio_dev *rdev)
265{
266 device_add(&rdev->dev);
267
268 spin_lock(&rio_global_list_lock);
269 list_add_tail(&rdev->global_list, &rio_devices);
270 spin_unlock(&rio_global_list_lock);
271
272 rio_create_sysfs_dev_files(rdev);
273}
274
275/**
276 * rio_setup_device- Allocates and sets up a RIO device
277 * @net: RIO network
278 * @port: Master port to send transactions
279 * @destid: Current destination ID
280 * @hopcount: Current hopcount
281 * @do_enum: Enumeration/Discovery mode flag
282 *
283 * Allocates a RIO device and configures fields based on configuration
284 * space contents. If device has a destination ID register, a destination
285 * ID is either assigned in enumeration mode or read from configuration
286 * space in discovery mode. If the device has switch capabilities, then
287 * a switch is allocated and configured appropriately. Returns a pointer
288 * to a RIO device on success or NULL on failure.
289 *
290 */
291static struct rio_dev *rio_setup_device(struct rio_net *net,
292 struct rio_mport *port, u16 destid,
293 u8 hopcount, int do_enum)
294{
295 struct rio_dev *rdev;
296 struct rio_switch *rswitch;
297 int result, rdid;
298
299 rdev = kmalloc(sizeof(struct rio_dev), GFP_KERNEL);
300 if (!rdev)
301 goto out;
302
303 memset(rdev, 0, sizeof(struct rio_dev));
304 rdev->net = net;
305 rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR,
306 &result);
307 rdev->did = result >> 16;
308 rdev->vid = result & 0xffff;
309 rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_INFO_CAR,
310 &rdev->device_rev);
311 rio_mport_read_config_32(port, destid, hopcount, RIO_ASM_ID_CAR,
312 &result);
313 rdev->asm_did = result >> 16;
314 rdev->asm_vid = result & 0xffff;
315 rio_mport_read_config_32(port, destid, hopcount, RIO_ASM_INFO_CAR,
316 &result);
317 rdev->asm_rev = result >> 16;
318 rio_mport_read_config_32(port, destid, hopcount, RIO_PEF_CAR,
319 &rdev->pef);
320 if (rdev->pef & RIO_PEF_EXT_FEATURES)
321 rdev->efptr = result & 0xffff;
322
323 rio_mport_read_config_32(port, destid, hopcount, RIO_SRC_OPS_CAR,
324 &rdev->src_ops);
325 rio_mport_read_config_32(port, destid, hopcount, RIO_DST_OPS_CAR,
326 &rdev->dst_ops);
327
328 if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops)
329 && do_enum) {
330 rio_set_device_id(port, destid, hopcount, next_destid);
331 rdev->destid = next_destid++;
332 if (next_destid == port->host_deviceid)
333 next_destid++;
334 } else
335 rdev->destid = rio_get_device_id(port, destid, hopcount);
336
337 /* If a PE has both switch and other functions, show it as a switch */
338 if (rio_is_switch(rdev)) {
339 rio_mport_read_config_32(port, destid, hopcount,
340 RIO_SWP_INFO_CAR, &rdev->swpinfo);
341 rswitch = kmalloc(sizeof(struct rio_switch), GFP_KERNEL);
342 if (!rswitch) {
343 kfree(rdev);
344 rdev = NULL;
345 goto out;
346 }
347 rswitch->switchid = next_switchid;
348 rswitch->hopcount = hopcount;
349 rswitch->destid = 0xffff;
350 /* Initialize switch route table */
351 for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES; rdid++)
352 rswitch->route_table[rdid] = RIO_INVALID_ROUTE;
353 rdev->rswitch = rswitch;
354 sprintf(rio_name(rdev), "%02x:s:%04x", rdev->net->id,
355 rdev->rswitch->switchid);
356 rio_route_set_ops(rdev);
357
358 list_add_tail(&rswitch->node, &rio_switches);
359
360 } else
361 sprintf(rio_name(rdev), "%02x:e:%04x", rdev->net->id,
362 rdev->destid);
363
364 rdev->dev.bus = &rio_bus_type;
365
366 device_initialize(&rdev->dev);
367 rdev->dev.release = rio_release_dev;
368 rio_dev_get(rdev);
369
370 rdev->dma_mask = DMA_32BIT_MASK;
371 rdev->dev.dma_mask = &rdev->dma_mask;
372 rdev->dev.coherent_dma_mask = DMA_32BIT_MASK;
373
374 if ((rdev->pef & RIO_PEF_INB_DOORBELL) &&
375 (rdev->dst_ops & RIO_DST_OPS_DOORBELL))
376 rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE],
377 0, 0xffff);
378
379 rio_add_device(rdev);
380
381 out:
382 return rdev;
383}
384
385/**
386 * rio_sport_is_active- Tests if a switch port has an active connection.
387 * @port: Master port to send transaction
388 * @destid: Associated destination ID for switch
389 * @hopcount: Hopcount to reach switch
390 * @sport: Switch port number
391 *
392 * Reads the port error status CSR for a particular switch port to
393 * determine if the port has an active link. Returns
394 * %PORT_N_ERR_STS_PORT_OK if the port is active or %0 if it is
395 * inactive.
396 */
397static int
398rio_sport_is_active(struct rio_mport *port, u16 destid, u8 hopcount, int sport)
399{
400 u32 result;
401 u32 ext_ftr_ptr;
402
403 int *entry = rio_sport_phys_table;
404
405 do {
406 if ((ext_ftr_ptr =
407 rio_mport_get_feature(port, 0, destid, hopcount, *entry)))
408
409 break;
410 } while (*++entry >= 0);
411
412 if (ext_ftr_ptr)
413 rio_mport_read_config_32(port, destid, hopcount,
414 ext_ftr_ptr +
415 RIO_PORT_N_ERR_STS_CSR(sport),
416 &result);
417
418 return (result & PORT_N_ERR_STS_PORT_OK);
419}
420
421/**
422 * rio_route_add_entry- Add a route entry to a switch routing table
423 * @mport: Master port to send transaction
424 * @rdev: Switch device
425 * @table: Routing table ID
426 * @route_destid: Destination ID to be routed
427 * @route_port: Port number to be routed
428 *
429 * Calls the switch specific add_entry() method to add a route entry
430 * on a switch. The route table can be specified using the @table
431 * argument if a switch has per port routing tables or the normal
432 * use is to specific all tables (or the global table) by passing
433 * %RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL
434 * on failure.
435 */
436static int rio_route_add_entry(struct rio_mport *mport, struct rio_dev *rdev,
437 u16 table, u16 route_destid, u8 route_port)
438{
439 return rdev->rswitch->add_entry(mport, rdev->rswitch->destid,
440 rdev->rswitch->hopcount, table,
441 route_destid, route_port);
442}
443
444/**
445 * rio_route_get_entry- Read a route entry in a switch routing table
446 * @mport: Master port to send transaction
447 * @rdev: Switch device
448 * @table: Routing table ID
449 * @route_destid: Destination ID to be routed
450 * @route_port: Pointer to read port number into
451 *
452 * Calls the switch specific get_entry() method to read a route entry
453 * in a switch. The route table can be specified using the @table
454 * argument if a switch has per port routing tables or the normal
455 * use is to specific all tables (or the global table) by passing
456 * %RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL
457 * on failure.
458 */
459static int
460rio_route_get_entry(struct rio_mport *mport, struct rio_dev *rdev, u16 table,
461 u16 route_destid, u8 * route_port)
462{
463 return rdev->rswitch->get_entry(mport, rdev->rswitch->destid,
464 rdev->rswitch->hopcount, table,
465 route_destid, route_port);
466}
467
468/**
469 * rio_get_host_deviceid_lock- Reads the Host Device ID Lock CSR on a device
470 * @port: Master port to send transaction
471 * @hopcount: Number of hops to the device
472 *
473 * Used during enumeration to read the Host Device ID Lock CSR on a
474 * RIO device. Returns the value of the lock register.
475 */
476static u16 rio_get_host_deviceid_lock(struct rio_mport *port, u8 hopcount)
477{
478 u32 result;
479
480 rio_mport_read_config_32(port, RIO_ANY_DESTID, hopcount,
481 RIO_HOST_DID_LOCK_CSR, &result);
482
483 return (u16) (result & 0xffff);
484}
485
486/**
487 * rio_get_swpinfo_inport- Gets the ingress port number
488 * @mport: Master port to send transaction
489 * @destid: Destination ID associated with the switch
490 * @hopcount: Number of hops to the device
491 *
492 * Returns port number being used to access the switch device.
493 */
494static u8
495rio_get_swpinfo_inport(struct rio_mport *mport, u16 destid, u8 hopcount)
496{
497 u32 result;
498
499 rio_mport_read_config_32(mport, destid, hopcount, RIO_SWP_INFO_CAR,
500 &result);
501
502 return (u8) (result & 0xff);
503}
504
505/**
506 * rio_get_swpinfo_tports- Gets total number of ports on the switch
507 * @mport: Master port to send transaction
508 * @destid: Destination ID associated with the switch
509 * @hopcount: Number of hops to the device
510 *
511 * Returns total numbers of ports implemented by the switch device.
512 */
513static u8 rio_get_swpinfo_tports(struct rio_mport *mport, u16 destid,
514 u8 hopcount)
515{
516 u32 result;
517
518 rio_mport_read_config_32(mport, destid, hopcount, RIO_SWP_INFO_CAR,
519 &result);
520
521 return RIO_GET_TOTAL_PORTS(result);
522}
523
524/**
525 * rio_net_add_mport- Add a master port to a RIO network
526 * @net: RIO network
527 * @port: Master port to add
528 *
529 * Adds a master port to the network list of associated master
530 * ports..
531 */
532static void rio_net_add_mport(struct rio_net *net, struct rio_mport *port)
533{
534 spin_lock(&rio_global_list_lock);
535 list_add_tail(&port->nnode, &net->mports);
536 spin_unlock(&rio_global_list_lock);
537}
538
539/**
540 * rio_enum_peer- Recursively enumerate a RIO network through a master port
541 * @net: RIO network being enumerated
542 * @port: Master port to send transactions
543 * @hopcount: Number of hops into the network
544 *
545 * Recursively enumerates a RIO network. Transactions are sent via the
546 * master port passed in @port.
547 */
548static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
549 u8 hopcount)
550{
551 int port_num;
552 int num_ports;
553 int cur_destid;
554 struct rio_dev *rdev;
555 u16 destid;
556 int tmp;
557
558 if (rio_get_host_deviceid_lock(port, hopcount) == port->host_deviceid) {
559 pr_debug("RIO: PE already discovered by this host\n");
560 /*
561 * Already discovered by this host. Add it as another
562 * master port for the current network.
563 */
564 rio_net_add_mport(net, port);
565 return 0;
566 }
567
568 /* Attempt to acquire device lock */
569 rio_mport_write_config_32(port, RIO_ANY_DESTID, hopcount,
570 RIO_HOST_DID_LOCK_CSR, port->host_deviceid);
571 while ((tmp = rio_get_host_deviceid_lock(port, hopcount))
572 < port->host_deviceid) {
573 /* Delay a bit */
574 mdelay(1);
575 /* Attempt to acquire device lock again */
576 rio_mport_write_config_32(port, RIO_ANY_DESTID, hopcount,
577 RIO_HOST_DID_LOCK_CSR,
578 port->host_deviceid);
579 }
580
581 if (rio_get_host_deviceid_lock(port, hopcount) > port->host_deviceid) {
582 pr_debug(
583 "RIO: PE locked by a higher priority host...retreating\n");
584 return -1;
585 }
586
587 /* Setup new RIO device */
588 if ((rdev = rio_setup_device(net, port, RIO_ANY_DESTID, hopcount, 1))) {
589 /* Add device to the global and bus/net specific list. */
590 list_add_tail(&rdev->net_list, &net->devices);
591 } else
592 return -1;
593
594 if (rio_is_switch(rdev)) {
595 next_switchid++;
596
597 for (destid = 0; destid < next_destid; destid++) {
598 rio_route_add_entry(port, rdev, RIO_GLOBAL_TABLE,
599 destid, rio_get_swpinfo_inport(port,
600 RIO_ANY_DESTID,
601 hopcount));
602 rdev->rswitch->route_table[destid] =
603 rio_get_swpinfo_inport(port, RIO_ANY_DESTID,
604 hopcount);
605 }
606
607 num_ports =
608 rio_get_swpinfo_tports(port, RIO_ANY_DESTID, hopcount);
609 pr_debug(
610 "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n",
611 rio_name(rdev), rdev->vid, rdev->did, num_ports);
612 for (port_num = 0; port_num < num_ports; port_num++) {
613 if (rio_get_swpinfo_inport
614 (port, RIO_ANY_DESTID, hopcount) == port_num)
615 continue;
616
617 cur_destid = next_destid;
618
619 if (rio_sport_is_active
620 (port, RIO_ANY_DESTID, hopcount, port_num)) {
621 pr_debug(
622 "RIO: scanning device on port %d\n",
623 port_num);
624 rio_route_add_entry(port, rdev,
625 RIO_GLOBAL_TABLE,
626 RIO_ANY_DESTID, port_num);
627
628 if (rio_enum_peer(net, port, hopcount + 1) < 0)
629 return -1;
630
631 /* Update routing tables */
632 if (next_destid > cur_destid) {
633 for (destid = cur_destid;
634 destid < next_destid; destid++) {
635 rio_route_add_entry(port, rdev,
636 RIO_GLOBAL_TABLE,
637 destid,
638 port_num);
639 rdev->rswitch->
640 route_table[destid] =
641 port_num;
642 }
643 rdev->rswitch->destid = cur_destid;
644 }
645 }
646 }
647 } else
648 pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n",
649 rio_name(rdev), rdev->vid, rdev->did);
650
651 return 0;
652}
653
654/**
655 * rio_enum_complete- Tests if enumeration of a network is complete
656 * @port: Master port to send transaction
657 *
658 * Tests the Component Tag CSR for presence of the magic enumeration
659 * complete flag. Return %1 if enumeration is complete or %0 if
660 * enumeration is incomplete.
661 */
662static int rio_enum_complete(struct rio_mport *port)
663{
664 u32 tag_csr;
665 int ret = 0;
666
667 rio_local_read_config_32(port, RIO_COMPONENT_TAG_CSR, &tag_csr);
668
669 if (tag_csr == RIO_ENUM_CMPL_MAGIC)
670 ret = 1;
671
672 return ret;
673}
674
675/**
676 * rio_disc_peer- Recursively discovers a RIO network through a master port
677 * @net: RIO network being discovered
678 * @port: Master port to send transactions
679 * @destid: Current destination ID in network
680 * @hopcount: Number of hops into the network
681 *
682 * Recursively discovers a RIO network. Transactions are sent via the
683 * master port passed in @port.
684 */
685static int
686rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
687 u8 hopcount)
688{
689 u8 port_num, route_port;
690 int num_ports;
691 struct rio_dev *rdev;
692 u16 ndestid;
693
694 /* Setup new RIO device */
695 if ((rdev = rio_setup_device(net, port, destid, hopcount, 0))) {
696 /* Add device to the global and bus/net specific list. */
697 list_add_tail(&rdev->net_list, &net->devices);
698 } else
699 return -1;
700
701 if (rio_is_switch(rdev)) {
702 next_switchid++;
703
704 /* Associated destid is how we accessed this switch */
705 rdev->rswitch->destid = destid;
706
707 num_ports = rio_get_swpinfo_tports(port, destid, hopcount);
708 pr_debug(
709 "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n",
710 rio_name(rdev), rdev->vid, rdev->did, num_ports);
711 for (port_num = 0; port_num < num_ports; port_num++) {
712 if (rio_get_swpinfo_inport(port, destid, hopcount) ==
713 port_num)
714 continue;
715
716 if (rio_sport_is_active
717 (port, destid, hopcount, port_num)) {
718 pr_debug(
719 "RIO: scanning device on port %d\n",
720 port_num);
721 for (ndestid = 0; ndestid < RIO_ANY_DESTID;
722 ndestid++) {
723 rio_route_get_entry(port, rdev,
724 RIO_GLOBAL_TABLE,
725 ndestid,
726 &route_port);
727 if (route_port == port_num)
728 break;
729 }
730
731 if (rio_disc_peer
732 (net, port, ndestid, hopcount + 1) < 0)
733 return -1;
734 }
735 }
736 } else
737 pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n",
738 rio_name(rdev), rdev->vid, rdev->did);
739
740 return 0;
741}
742
743/**
744 * rio_mport_is_active- Tests if master port link is active
745 * @port: Master port to test
746 *
747 * Reads the port error status CSR for the master port to
748 * determine if the port has an active link. Returns
749 * %PORT_N_ERR_STS_PORT_OK if the master port is active
750 * or %0 if it is inactive.
751 */
752static int rio_mport_is_active(struct rio_mport *port)
753{
754 u32 result = 0;
755 u32 ext_ftr_ptr;
756 int *entry = rio_mport_phys_table;
757
758 do {
759 if ((ext_ftr_ptr =
760 rio_mport_get_feature(port, 1, 0, 0, *entry)))
761 break;
762 } while (*++entry >= 0);
763
764 if (ext_ftr_ptr)
765 rio_local_read_config_32(port,
766 ext_ftr_ptr +
767 RIO_PORT_N_ERR_STS_CSR(port->index),
768 &result);
769
770 return (result & PORT_N_ERR_STS_PORT_OK);
771}
772
773/**
774 * rio_alloc_net- Allocate and configure a new RIO network
775 * @port: Master port associated with the RIO network
776 *
777 * Allocates a RIO network structure, initializes per-network
778 * list heads, and adds the associated master port to the
779 * network list of associated master ports. Returns a
780 * RIO network pointer on success or %NULL on failure.
781 */
782static struct rio_net __devinit *rio_alloc_net(struct rio_mport *port)
783{
784 struct rio_net *net;
785
786 net = kmalloc(sizeof(struct rio_net), GFP_KERNEL);
787 if (net) {
788 memset(net, 0, sizeof(struct rio_net));
789 INIT_LIST_HEAD(&net->node);
790 INIT_LIST_HEAD(&net->devices);
791 INIT_LIST_HEAD(&net->mports);
792 list_add_tail(&port->nnode, &net->mports);
793 net->hport = port;
794 net->id = next_net++;
795 }
796 return net;
797}
798
799/**
800 * rio_enum_mport- Start enumeration through a master port
801 * @mport: Master port to send transactions
802 *
803 * Starts the enumeration process. If somebody has enumerated our
804 * master port device, then give up. If not and we have an active
805 * link, then start recursive peer enumeration. Returns %0 if
806 * enumeration succeeds or %-EBUSY if enumeration fails.
807 */
808int rio_enum_mport(struct rio_mport *mport)
809{
810 struct rio_net *net = NULL;
811 int rc = 0;
812
813 printk(KERN_INFO "RIO: enumerate master port %d, %s\n", mport->id,
814 mport->name);
815 /* If somebody else enumerated our master port device, bail. */
816 if (rio_enum_host(mport) < 0) {
817 printk(KERN_INFO
818 "RIO: master port %d device has been enumerated by a remote host\n",
819 mport->id);
820 rc = -EBUSY;
821 goto out;
822 }
823
824 /* If master port has an active link, allocate net and enum peers */
825 if (rio_mport_is_active(mport)) {
826 if (!(net = rio_alloc_net(mport))) {
827 printk(KERN_ERR "RIO: failed to allocate new net\n");
828 rc = -ENOMEM;
829 goto out;
830 }
831 if (rio_enum_peer(net, mport, 0) < 0) {
832 /* A higher priority host won enumeration, bail. */
833 printk(KERN_INFO
834 "RIO: master port %d device has lost enumeration to a remote host\n",
835 mport->id);
836 rio_clear_locks(mport);
837 rc = -EBUSY;
838 goto out;
839 }
840 rio_clear_locks(mport);
841 } else {
842 printk(KERN_INFO "RIO: master port %d link inactive\n",
843 mport->id);
844 rc = -EINVAL;
845 }
846
847 out:
848 return rc;
849}
850
851/**
852 * rio_build_route_tables- Generate route tables from switch route entries
853 *
854 * For each switch device, generate a route table by copying existing
855 * route entries from the switch.
856 */
857static void rio_build_route_tables(void)
858{
859 struct rio_dev *rdev;
860 int i;
861 u8 sport;
862
863 list_for_each_entry(rdev, &rio_devices, global_list)
864 if (rio_is_switch(rdev))
865 for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) {
866 if (rio_route_get_entry
867 (rdev->net->hport, rdev, RIO_GLOBAL_TABLE, i,
868 &sport) < 0)
869 continue;
870 rdev->rswitch->route_table[i] = sport;
871 }
872}
873
874/**
875 * rio_enum_timeout- Signal that enumeration timed out
876 * @data: Address of timeout flag.
877 *
878 * When the enumeration complete timer expires, set a flag that
879 * signals to the discovery process that enumeration did not
880 * complete in a sane amount of time.
881 */
882static void rio_enum_timeout(unsigned long data)
883{
884 /* Enumeration timed out, set flag */
885 *(int *)data = 1;
886}
887
888/**
889 * rio_disc_mport- Start discovery through a master port
890 * @mport: Master port to send transactions
891 *
892 * Starts the discovery process. If we have an active link,
893 * then wait for the signal that enumeration is complete.
894 * When enumeration completion is signaled, start recursive
895 * peer discovery. Returns %0 if discovery succeeds or %-EBUSY
896 * on failure.
897 */
898int rio_disc_mport(struct rio_mport *mport)
899{
900 struct rio_net *net = NULL;
901 int enum_timeout_flag = 0;
902
903 printk(KERN_INFO "RIO: discover master port %d, %s\n", mport->id,
904 mport->name);
905
906 /* If master port has an active link, allocate net and discover peers */
907 if (rio_mport_is_active(mport)) {
908 if (!(net = rio_alloc_net(mport))) {
909 printk(KERN_ERR "RIO: Failed to allocate new net\n");
910 goto bail;
911 }
912
913 pr_debug("RIO: wait for enumeration complete...");
914
915 rio_enum_timer.expires =
916 jiffies + CONFIG_RAPIDIO_DISC_TIMEOUT * HZ;
917 rio_enum_timer.data = (unsigned long)&enum_timeout_flag;
918 add_timer(&rio_enum_timer);
919 while (!rio_enum_complete(mport)) {
920 mdelay(1);
921 if (enum_timeout_flag) {
922 del_timer_sync(&rio_enum_timer);
923 goto timeout;
924 }
925 }
926 del_timer_sync(&rio_enum_timer);
927
928 pr_debug("done\n");
929 if (rio_disc_peer(net, mport, RIO_ANY_DESTID, 0) < 0) {
930 printk(KERN_INFO
931 "RIO: master port %d device has failed discovery\n",
932 mport->id);
933 goto bail;
934 }
935
936 rio_build_route_tables();
937 }
938
939 return 0;
940
941 timeout:
942 pr_debug("timeout\n");
943 bail:
944 return -EBUSY;
945}
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
new file mode 100644
index 000000000000..30a11436e241
--- /dev/null
+++ b/drivers/rapidio/rio-sysfs.c
@@ -0,0 +1,230 @@
1/*
2 * RapidIO sysfs attributes and support
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/config.h>
14#include <linux/kernel.h>
15#include <linux/rio.h>
16#include <linux/rio_drv.h>
17#include <linux/stat.h>
18
19#include "rio.h"
20
21/* Sysfs support */
22#define rio_config_attr(field, format_string) \
23static ssize_t \
24field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
25{ \
26 struct rio_dev *rdev = to_rio_dev(dev); \
27 \
28 return sprintf(buf, format_string, rdev->field); \
29} \
30
31rio_config_attr(did, "0x%04x\n");
32rio_config_attr(vid, "0x%04x\n");
33rio_config_attr(device_rev, "0x%08x\n");
34rio_config_attr(asm_did, "0x%04x\n");
35rio_config_attr(asm_vid, "0x%04x\n");
36rio_config_attr(asm_rev, "0x%04x\n");
37
38static ssize_t routes_show(struct device *dev, struct device_attribute *attr, char *buf)
39{
40 struct rio_dev *rdev = to_rio_dev(dev);
41 char *str = buf;
42 int i;
43
44 if (!rdev->rswitch)
45 goto out;
46
47 for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) {
48 if (rdev->rswitch->route_table[i] == RIO_INVALID_ROUTE)
49 continue;
50 str +=
51 sprintf(str, "%04x %02x\n", i,
52 rdev->rswitch->route_table[i]);
53 }
54
55 out:
56 return (str - buf);
57}
58
59struct device_attribute rio_dev_attrs[] = {
60 __ATTR_RO(did),
61 __ATTR_RO(vid),
62 __ATTR_RO(device_rev),
63 __ATTR_RO(asm_did),
64 __ATTR_RO(asm_vid),
65 __ATTR_RO(asm_rev),
66 __ATTR_RO(routes),
67 __ATTR_NULL,
68};
69
70static ssize_t
71rio_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
72{
73 struct rio_dev *dev =
74 to_rio_dev(container_of(kobj, struct device, kobj));
75 unsigned int size = 0x100;
76 loff_t init_off = off;
77 u8 *data = (u8 *) buf;
78
79 /* Several chips lock up trying to read undefined config space */
80 if (capable(CAP_SYS_ADMIN))
81 size = 0x200000;
82
83 if (off > size)
84 return 0;
85 if (off + count > size) {
86 size -= off;
87 count = size;
88 } else {
89 size = count;
90 }
91
92 if ((off & 1) && size) {
93 u8 val;
94 rio_read_config_8(dev, off, &val);
95 data[off - init_off] = val;
96 off++;
97 size--;
98 }
99
100 if ((off & 3) && size > 2) {
101 u16 val;
102 rio_read_config_16(dev, off, &val);
103 data[off - init_off] = (val >> 8) & 0xff;
104 data[off - init_off + 1] = val & 0xff;
105 off += 2;
106 size -= 2;
107 }
108
109 while (size > 3) {
110 u32 val;
111 rio_read_config_32(dev, off, &val);
112 data[off - init_off] = (val >> 24) & 0xff;
113 data[off - init_off + 1] = (val >> 16) & 0xff;
114 data[off - init_off + 2] = (val >> 8) & 0xff;
115 data[off - init_off + 3] = val & 0xff;
116 off += 4;
117 size -= 4;
118 }
119
120 if (size >= 2) {
121 u16 val;
122 rio_read_config_16(dev, off, &val);
123 data[off - init_off] = (val >> 8) & 0xff;
124 data[off - init_off + 1] = val & 0xff;
125 off += 2;
126 size -= 2;
127 }
128
129 if (size > 0) {
130 u8 val;
131 rio_read_config_8(dev, off, &val);
132 data[off - init_off] = val;
133 off++;
134 --size;
135 }
136
137 return count;
138}
139
140static ssize_t
141rio_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
142{
143 struct rio_dev *dev =
144 to_rio_dev(container_of(kobj, struct device, kobj));
145 unsigned int size = count;
146 loff_t init_off = off;
147 u8 *data = (u8 *) buf;
148
149 if (off > 0x200000)
150 return 0;
151 if (off + count > 0x200000) {
152 size = 0x200000 - off;
153 count = size;
154 }
155
156 if ((off & 1) && size) {
157 rio_write_config_8(dev, off, data[off - init_off]);
158 off++;
159 size--;
160 }
161
162 if ((off & 3) && (size > 2)) {
163 u16 val = data[off - init_off + 1];
164 val |= (u16) data[off - init_off] << 8;
165 rio_write_config_16(dev, off, val);
166 off += 2;
167 size -= 2;
168 }
169
170 while (size > 3) {
171 u32 val = data[off - init_off + 3];
172 val |= (u32) data[off - init_off + 2] << 8;
173 val |= (u32) data[off - init_off + 1] << 16;
174 val |= (u32) data[off - init_off] << 24;
175 rio_write_config_32(dev, off, val);
176 off += 4;
177 size -= 4;
178 }
179
180 if (size >= 2) {
181 u16 val = data[off - init_off + 1];
182 val |= (u16) data[off - init_off] << 8;
183 rio_write_config_16(dev, off, val);
184 off += 2;
185 size -= 2;
186 }
187
188 if (size) {
189 rio_write_config_8(dev, off, data[off - init_off]);
190 off++;
191 --size;
192 }
193
194 return count;
195}
196
197static struct bin_attribute rio_config_attr = {
198 .attr = {
199 .name = "config",
200 .mode = S_IRUGO | S_IWUSR,
201 .owner = THIS_MODULE,
202 },
203 .size = 0x200000,
204 .read = rio_read_config,
205 .write = rio_write_config,
206};
207
208/**
209 * rio_create_sysfs_dev_files - create RIO specific sysfs files
210 * @rdev: device whose entries should be created
211 *
212 * Create files when @rdev is added to sysfs.
213 */
214int rio_create_sysfs_dev_files(struct rio_dev *rdev)
215{
216 sysfs_create_bin_file(&rdev->dev.kobj, &rio_config_attr);
217
218 return 0;
219}
220
221/**
222 * rio_remove_sysfs_dev_files - cleanup RIO specific sysfs files
223 * @rdev: device whose entries we should free
224 *
225 * Cleanup when @rdev is removed from sysfs.
226 */
227void rio_remove_sysfs_dev_files(struct rio_dev *rdev)
228{
229 sysfs_remove_bin_file(&rdev->dev.kobj, &rio_config_attr);
230}
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
new file mode 100644
index 000000000000..3ca1011ceaac
--- /dev/null
+++ b/drivers/rapidio/rio.c
@@ -0,0 +1,510 @@
1/*
2 * RapidIO interconnect services
3 * (RapidIO Interconnect Specification, http://www.rapidio.org)
4 *
5 * Copyright 2005 MontaVista Software, Inc.
6 * Matt Porter <mporter@kernel.crashing.org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/config.h>
15#include <linux/types.h>
16#include <linux/kernel.h>
17
18#include <linux/delay.h>
19#include <linux/init.h>
20#include <linux/rio.h>
21#include <linux/rio_drv.h>
22#include <linux/rio_ids.h>
23#include <linux/rio_regs.h>
24#include <linux/module.h>
25#include <linux/spinlock.h>
26
27#include "rio.h"
28
29static LIST_HEAD(rio_mports);
30
31/**
32 * rio_local_get_device_id - Get the base/extended device id for a port
33 * @port: RIO master port from which to get the deviceid
34 *
35 * Reads the base/extended device id from the local device
36 * implementing the master port. Returns the 8/16-bit device
37 * id.
38 */
39u16 rio_local_get_device_id(struct rio_mport *port)
40{
41 u32 result;
42
43 rio_local_read_config_32(port, RIO_DID_CSR, &result);
44
45 return (RIO_GET_DID(result));
46}
47
48/**
49 * rio_request_inb_mbox - request inbound mailbox service
50 * @mport: RIO master port from which to allocate the mailbox resource
51 * @dev_id: Device specific pointer to pass on event
52 * @mbox: Mailbox number to claim
53 * @entries: Number of entries in inbound mailbox queue
54 * @minb: Callback to execute when inbound message is received
55 *
56 * Requests ownership of an inbound mailbox resource and binds
57 * a callback function to the resource. Returns %0 on success.
58 */
59int rio_request_inb_mbox(struct rio_mport *mport,
60 void *dev_id,
61 int mbox,
62 int entries,
63 void (*minb) (struct rio_mport * mport, void *dev_id, int mbox,
64 int slot))
65{
66 int rc = 0;
67
68 struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL);
69
70 if (res) {
71 rio_init_mbox_res(res, mbox, mbox);
72
73 /* Make sure this mailbox isn't in use */
74 if ((rc =
75 request_resource(&mport->riores[RIO_INB_MBOX_RESOURCE],
76 res)) < 0) {
77 kfree(res);
78 goto out;
79 }
80
81 mport->inb_msg[mbox].res = res;
82
83 /* Hook the inbound message callback */
84 mport->inb_msg[mbox].mcback = minb;
85
86 rc = rio_open_inb_mbox(mport, dev_id, mbox, entries);
87 } else
88 rc = -ENOMEM;
89
90 out:
91 return rc;
92}
93
94/**
95 * rio_release_inb_mbox - release inbound mailbox message service
96 * @mport: RIO master port from which to release the mailbox resource
97 * @mbox: Mailbox number to release
98 *
99 * Releases ownership of an inbound mailbox resource. Returns 0
100 * if the request has been satisfied.
101 */
102int rio_release_inb_mbox(struct rio_mport *mport, int mbox)
103{
104 rio_close_inb_mbox(mport, mbox);
105
106 /* Release the mailbox resource */
107 return release_resource(mport->inb_msg[mbox].res);
108}
109
110/**
111 * rio_request_outb_mbox - request outbound mailbox service
112 * @mport: RIO master port from which to allocate the mailbox resource
113 * @dev_id: Device specific pointer to pass on event
114 * @mbox: Mailbox number to claim
115 * @entries: Number of entries in outbound mailbox queue
116 * @moutb: Callback to execute when outbound message is sent
117 *
118 * Requests ownership of an outbound mailbox resource and binds
119 * a callback function to the resource. Returns 0 on success.
120 */
121int rio_request_outb_mbox(struct rio_mport *mport,
122 void *dev_id,
123 int mbox,
124 int entries,
125 void (*moutb) (struct rio_mport * mport, void *dev_id, int mbox, int slot))
126{
127 int rc = 0;
128
129 struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL);
130
131 if (res) {
132 rio_init_mbox_res(res, mbox, mbox);
133
134 /* Make sure this outbound mailbox isn't in use */
135 if ((rc =
136 request_resource(&mport->riores[RIO_OUTB_MBOX_RESOURCE],
137 res)) < 0) {
138 kfree(res);
139 goto out;
140 }
141
142 mport->outb_msg[mbox].res = res;
143
144 /* Hook the inbound message callback */
145 mport->outb_msg[mbox].mcback = moutb;
146
147 rc = rio_open_outb_mbox(mport, dev_id, mbox, entries);
148 } else
149 rc = -ENOMEM;
150
151 out:
152 return rc;
153}
154
155/**
156 * rio_release_outb_mbox - release outbound mailbox message service
157 * @mport: RIO master port from which to release the mailbox resource
158 * @mbox: Mailbox number to release
159 *
160 * Releases ownership of an inbound mailbox resource. Returns 0
161 * if the request has been satisfied.
162 */
163int rio_release_outb_mbox(struct rio_mport *mport, int mbox)
164{
165 rio_close_outb_mbox(mport, mbox);
166
167 /* Release the mailbox resource */
168 return release_resource(mport->outb_msg[mbox].res);
169}
170
171/**
172 * rio_setup_inb_dbell - bind inbound doorbell callback
173 * @mport: RIO master port to bind the doorbell callback
174 * @dev_id: Device specific pointer to pass on event
175 * @res: Doorbell message resource
176 * @dinb: Callback to execute when doorbell is received
177 *
178 * Adds a doorbell resource/callback pair into a port's
179 * doorbell event list. Returns 0 if the request has been
180 * satisfied.
181 */
182static int
183rio_setup_inb_dbell(struct rio_mport *mport, void *dev_id, struct resource *res,
184 void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, u16 dst,
185 u16 info))
186{
187 int rc = 0;
188 struct rio_dbell *dbell;
189
190 if (!(dbell = kmalloc(sizeof(struct rio_dbell), GFP_KERNEL))) {
191 rc = -ENOMEM;
192 goto out;
193 }
194
195 dbell->res = res;
196 dbell->dinb = dinb;
197 dbell->dev_id = dev_id;
198
199 list_add_tail(&dbell->node, &mport->dbells);
200
201 out:
202 return rc;
203}
204
205/**
206 * rio_request_inb_dbell - request inbound doorbell message service
207 * @mport: RIO master port from which to allocate the doorbell resource
208 * @dev_id: Device specific pointer to pass on event
209 * @start: Doorbell info range start
210 * @end: Doorbell info range end
211 * @dinb: Callback to execute when doorbell is received
212 *
213 * Requests ownership of an inbound doorbell resource and binds
214 * a callback function to the resource. Returns 0 if the request
215 * has been satisfied.
216 */
217int rio_request_inb_dbell(struct rio_mport *mport,
218 void *dev_id,
219 u16 start,
220 u16 end,
221 void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src,
222 u16 dst, u16 info))
223{
224 int rc = 0;
225
226 struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL);
227
228 if (res) {
229 rio_init_dbell_res(res, start, end);
230
231 /* Make sure these doorbells aren't in use */
232 if ((rc =
233 request_resource(&mport->riores[RIO_DOORBELL_RESOURCE],
234 res)) < 0) {
235 kfree(res);
236 goto out;
237 }
238
239 /* Hook the doorbell callback */
240 rc = rio_setup_inb_dbell(mport, dev_id, res, dinb);
241 } else
242 rc = -ENOMEM;
243
244 out:
245 return rc;
246}
247
248/**
249 * rio_release_inb_dbell - release inbound doorbell message service
250 * @mport: RIO master port from which to release the doorbell resource
251 * @start: Doorbell info range start
252 * @end: Doorbell info range end
253 *
254 * Releases ownership of an inbound doorbell resource and removes
255 * callback from the doorbell event list. Returns 0 if the request
256 * has been satisfied.
257 */
258int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end)
259{
260 int rc = 0, found = 0;
261 struct rio_dbell *dbell;
262
263 list_for_each_entry(dbell, &mport->dbells, node) {
264 if ((dbell->res->start == start) && (dbell->res->end == end)) {
265 found = 1;
266 break;
267 }
268 }
269
270 /* If we can't find an exact match, fail */
271 if (!found) {
272 rc = -EINVAL;
273 goto out;
274 }
275
276 /* Delete from list */
277 list_del(&dbell->node);
278
279 /* Release the doorbell resource */
280 rc = release_resource(dbell->res);
281
282 /* Free the doorbell event */
283 kfree(dbell);
284
285 out:
286 return rc;
287}
288
289/**
290 * rio_request_outb_dbell - request outbound doorbell message range
291 * @rdev: RIO device from which to allocate the doorbell resource
292 * @start: Doorbell message range start
293 * @end: Doorbell message range end
294 *
295 * Requests ownership of a doorbell message range. Returns a resource
296 * if the request has been satisfied or %NULL on failure.
297 */
298struct resource *rio_request_outb_dbell(struct rio_dev *rdev, u16 start,
299 u16 end)
300{
301 struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL);
302
303 if (res) {
304 rio_init_dbell_res(res, start, end);
305
306 /* Make sure these doorbells aren't in use */
307 if (request_resource(&rdev->riores[RIO_DOORBELL_RESOURCE], res)
308 < 0) {
309 kfree(res);
310 res = NULL;
311 }
312 }
313
314 return res;
315}
316
317/**
318 * rio_release_outb_dbell - release outbound doorbell message range
319 * @rdev: RIO device from which to release the doorbell resource
320 * @res: Doorbell resource to be freed
321 *
322 * Releases ownership of a doorbell message range. Returns 0 if the
323 * request has been satisfied.
324 */
325int rio_release_outb_dbell(struct rio_dev *rdev, struct resource *res)
326{
327 int rc = release_resource(res);
328
329 kfree(res);
330
331 return rc;
332}
333
334/**
335 * rio_mport_get_feature - query for devices' extended features
336 * @port: Master port to issue transaction
337 * @local: Indicate a local master port or remote device access
338 * @destid: Destination ID of the device
339 * @hopcount: Number of switch hops to the device
340 * @ftr: Extended feature code
341 *
342 * Tell if a device supports a given RapidIO capability.
343 * Returns the offset of the requested extended feature
344 * block within the device's RIO configuration space or
345 * 0 in case the device does not support it. Possible
346 * values for @ftr:
347 *
348 * %RIO_EFB_PAR_EP_ID LP/LVDS EP Devices
349 *
350 * %RIO_EFB_PAR_EP_REC_ID LP/LVDS EP Recovery Devices
351 *
352 * %RIO_EFB_PAR_EP_FREE_ID LP/LVDS EP Free Devices
353 *
354 * %RIO_EFB_SER_EP_ID LP/Serial EP Devices
355 *
356 * %RIO_EFB_SER_EP_REC_ID LP/Serial EP Recovery Devices
357 *
358 * %RIO_EFB_SER_EP_FREE_ID LP/Serial EP Free Devices
359 */
360u32
361rio_mport_get_feature(struct rio_mport * port, int local, u16 destid,
362 u8 hopcount, int ftr)
363{
364 u32 asm_info, ext_ftr_ptr, ftr_header;
365
366 if (local)
367 rio_local_read_config_32(port, RIO_ASM_INFO_CAR, &asm_info);
368 else
369 rio_mport_read_config_32(port, destid, hopcount,
370 RIO_ASM_INFO_CAR, &asm_info);
371
372 ext_ftr_ptr = asm_info & RIO_EXT_FTR_PTR_MASK;
373
374 while (ext_ftr_ptr) {
375 if (local)
376 rio_local_read_config_32(port, ext_ftr_ptr,
377 &ftr_header);
378 else
379 rio_mport_read_config_32(port, destid, hopcount,
380 ext_ftr_ptr, &ftr_header);
381 if (RIO_GET_BLOCK_ID(ftr_header) == ftr)
382 return ext_ftr_ptr;
383 if (!(ext_ftr_ptr = RIO_GET_BLOCK_PTR(ftr_header)))
384 break;
385 }
386
387 return 0;
388}
389
390/**
391 * rio_get_asm - Begin or continue searching for a RIO device by vid/did/asm_vid/asm_did
392 * @vid: RIO vid to match or %RIO_ANY_ID to match all vids
393 * @did: RIO did to match or %RIO_ANY_ID to match all dids
394 * @asm_vid: RIO asm_vid to match or %RIO_ANY_ID to match all asm_vids
395 * @asm_did: RIO asm_did to match or %RIO_ANY_ID to match all asm_dids
396 * @from: Previous RIO device found in search, or %NULL for new search
397 *
398 * Iterates through the list of known RIO devices. If a RIO device is
399 * found with a matching @vid, @did, @asm_vid, @asm_did, the reference
400 * count to the device is incrememted and a pointer to its device
401 * structure is returned. Otherwise, %NULL is returned. A new search
402 * is initiated by passing %NULL to the @from argument. Otherwise, if
403 * @from is not %NULL, searches continue from next device on the global
404 * list. The reference count for @from is always decremented if it is
405 * not %NULL.
406 */
407struct rio_dev *rio_get_asm(u16 vid, u16 did,
408 u16 asm_vid, u16 asm_did, struct rio_dev *from)
409{
410 struct list_head *n;
411 struct rio_dev *rdev;
412
413 WARN_ON(in_interrupt());
414 spin_lock(&rio_global_list_lock);
415 n = from ? from->global_list.next : rio_devices.next;
416
417 while (n && (n != &rio_devices)) {
418 rdev = rio_dev_g(n);
419 if ((vid == RIO_ANY_ID || rdev->vid == vid) &&
420 (did == RIO_ANY_ID || rdev->did == did) &&
421 (asm_vid == RIO_ANY_ID || rdev->asm_vid == asm_vid) &&
422 (asm_did == RIO_ANY_ID || rdev->asm_did == asm_did))
423 goto exit;
424 n = n->next;
425 }
426 rdev = NULL;
427 exit:
428 rio_dev_put(from);
429 rdev = rio_dev_get(rdev);
430 spin_unlock(&rio_global_list_lock);
431 return rdev;
432}
433
434/**
435 * rio_get_device - Begin or continue searching for a RIO device by vid/did
436 * @vid: RIO vid to match or %RIO_ANY_ID to match all vids
437 * @did: RIO did to match or %RIO_ANY_ID to match all dids
438 * @from: Previous RIO device found in search, or %NULL for new search
439 *
440 * Iterates through the list of known RIO devices. If a RIO device is
441 * found with a matching @vid and @did, the reference count to the
442 * device is incrememted and a pointer to its device structure is returned.
443 * Otherwise, %NULL is returned. A new search is initiated by passing %NULL
444 * to the @from argument. Otherwise, if @from is not %NULL, searches
445 * continue from next device on the global list. The reference count for
446 * @from is always decremented if it is not %NULL.
447 */
448struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from)
449{
450 return rio_get_asm(vid, did, RIO_ANY_ID, RIO_ANY_ID, from);
451}
452
453static void rio_fixup_device(struct rio_dev *dev)
454{
455}
456
457static int __devinit rio_init(void)
458{
459 struct rio_dev *dev = NULL;
460
461 while ((dev = rio_get_device(RIO_ANY_ID, RIO_ANY_ID, dev)) != NULL) {
462 rio_fixup_device(dev);
463 }
464 return 0;
465}
466
467device_initcall(rio_init);
468
469int rio_init_mports(void)
470{
471 int rc = 0;
472 struct rio_mport *port;
473
474 list_for_each_entry(port, &rio_mports, node) {
475 if (!request_mem_region(port->iores.start,
476 port->iores.end - port->iores.start,
477 port->name)) {
478 printk(KERN_ERR
479 "RIO: Error requesting master port region %8.8lx-%8.8lx\n",
480 port->iores.start, port->iores.end - 1);
481 rc = -ENOMEM;
482 goto out;
483 }
484
485 if (port->host_deviceid >= 0)
486 rio_enum_mport(port);
487 else
488 rio_disc_mport(port);
489 }
490
491 out:
492 return rc;
493}
494
495void rio_register_mport(struct rio_mport *port)
496{
497 list_add_tail(&port->node, &rio_mports);
498}
499
500EXPORT_SYMBOL_GPL(rio_local_get_device_id);
501EXPORT_SYMBOL_GPL(rio_get_device);
502EXPORT_SYMBOL_GPL(rio_get_asm);
503EXPORT_SYMBOL_GPL(rio_request_inb_dbell);
504EXPORT_SYMBOL_GPL(rio_release_inb_dbell);
505EXPORT_SYMBOL_GPL(rio_request_outb_dbell);
506EXPORT_SYMBOL_GPL(rio_release_outb_dbell);
507EXPORT_SYMBOL_GPL(rio_request_inb_mbox);
508EXPORT_SYMBOL_GPL(rio_release_inb_mbox);
509EXPORT_SYMBOL_GPL(rio_request_outb_mbox);
510EXPORT_SYMBOL_GPL(rio_release_outb_mbox);
diff --git a/drivers/rapidio/rio.h b/drivers/rapidio/rio.h
new file mode 100644
index 000000000000..b242cee656e7
--- /dev/null
+++ b/drivers/rapidio/rio.h
@@ -0,0 +1,60 @@
1/*
2 * RapidIO interconnect services
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/device.h>
14#include <linux/list.h>
15#include <linux/rio.h>
16
17/* Functions internal to the RIO core code */
18
19extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
20 u8 hopcount, int ftr);
21extern int rio_create_sysfs_dev_files(struct rio_dev *rdev);
22extern int rio_enum_mport(struct rio_mport *mport);
23extern int rio_disc_mport(struct rio_mport *mport);
24
25/* Structures internal to the RIO core code */
26extern struct device_attribute rio_dev_attrs[];
27extern spinlock_t rio_global_list_lock;
28
29extern struct rio_route_ops __start_rio_route_ops[];
30extern struct rio_route_ops __end_rio_route_ops[];
31
32/* Helpers internal to the RIO core code */
33#define DECLARE_RIO_ROUTE_SECTION(section, vid, did, add_hook, get_hook) \
34 static struct rio_route_ops __rio_route_ops __attribute_used__ \
35 __attribute__((__section__(#section))) = { vid, did, add_hook, get_hook };
36
37/**
38 * DECLARE_RIO_ROUTE_OPS - Registers switch routing operations
39 * @vid: RIO vendor ID
40 * @did: RIO device ID
41 * @add_hook: Callback that adds a route entry
42 * @get_hook: Callback that gets a route entry
43 *
44 * Manipulating switch route tables in RIO is switch specific. This
45 * registers a switch by vendor and device ID with two callbacks for
46 * modifying and retrieving route entries in a switch. A &struct
47 * rio_route_ops is initialized with the ops and placed into a
48 * RIO-specific kernel section.
49 */
50#define DECLARE_RIO_ROUTE_OPS(vid, did, add_hook, get_hook) \
51 DECLARE_RIO_ROUTE_SECTION(.rio_route_ops, \
52 vid, did, add_hook, get_hook)
53
54#ifdef CONFIG_RAPIDIO_8_BIT_TRANSPORT
55#define RIO_GET_DID(x) ((x & 0x00ff0000) >> 16)
56#define RIO_SET_DID(x) ((x & 0x000000ff) << 16)
57#else
58#define RIO_GET_DID(x) (x & 0xffff)
59#define RIO_SET_DID(x) (x & 0xffff)
60#endif
diff --git a/drivers/rapidio/switches/Makefile b/drivers/rapidio/switches/Makefile
new file mode 100644
index 000000000000..b924f8301761
--- /dev/null
+++ b/drivers/rapidio/switches/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for RIO switches
3#
4
5obj-$(CONFIG_RAPIDIO) += tsi500.o
diff --git a/drivers/rapidio/switches/tsi500.c b/drivers/rapidio/switches/tsi500.c
new file mode 100644
index 000000000000..c77c23bd9840
--- /dev/null
+++ b/drivers/rapidio/switches/tsi500.c
@@ -0,0 +1,60 @@
1/*
2 * RapidIO Tsi500 switch support
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/rio.h>
14#include <linux/rio_drv.h>
15#include <linux/rio_ids.h>
16#include "../rio.h"
17
18static int
19tsi500_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 route_port)
20{
21 int i;
22 u32 offset = 0x10000 + 0xa00 + ((route_destid / 2)&~0x3);
23 u32 result;
24
25 if (table == 0xff) {
26 rio_mport_read_config_32(mport, destid, hopcount, offset, &result);
27 result &= ~(0xf << (4*(route_destid & 0x7)));
28 for (i=0;i<4;i++)
29 rio_mport_write_config_32(mport, destid, hopcount, offset + (0x20000*i), result | (route_port << (4*(route_destid & 0x7))));
30 }
31 else {
32 rio_mport_read_config_32(mport, destid, hopcount, offset + (0x20000*table), &result);
33 result &= ~(0xf << (4*(route_destid & 0x7)));
34 rio_mport_write_config_32(mport, destid, hopcount, offset + (0x20000*table), result | (route_port << (4*(route_destid & 0x7))));
35 }
36
37 return 0;
38}
39
40static int
41tsi500_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 *route_port)
42{
43 int ret = 0;
44 u32 offset = 0x10000 + 0xa00 + ((route_destid / 2)&~0x3);
45 u32 result;
46
47 if (table == 0xff)
48 rio_mport_read_config_32(mport, destid, hopcount, offset, &result);
49 else
50 rio_mport_read_config_32(mport, destid, hopcount, offset + (0x20000*table), &result);
51
52 result &= 0xf << (4*(route_destid & 0x7));
53 *route_port = result >> (4*(route_destid & 0x7));
54 if (*route_port > 3)
55 ret = -1;
56
57 return ret;
58}
59
60DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI500, tsi500_route_add_entry, tsi500_route_get_entry);
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 8fc891a9d47f..7008d32433bf 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -115,8 +115,7 @@ dasd_alloc_device(void)
115void 115void
116dasd_free_device(struct dasd_device *device) 116dasd_free_device(struct dasd_device *device)
117{ 117{
118 if (device->private) 118 kfree(device->private);
119 kfree(device->private);
120 free_page((unsigned long) device->erp_mem); 119 free_page((unsigned long) device->erp_mem);
121 free_pages((unsigned long) device->ccw_mem, 1); 120 free_pages((unsigned long) device->ccw_mem, 1);
122 kfree(device); 121 kfree(device);
@@ -539,8 +538,7 @@ dasd_kmalloc_request(char *magic, int cplength, int datasize,
539 if (datasize > 0) { 538 if (datasize > 0) {
540 cqr->data = kmalloc(datasize, GFP_ATOMIC | GFP_DMA); 539 cqr->data = kmalloc(datasize, GFP_ATOMIC | GFP_DMA);
541 if (cqr->data == NULL) { 540 if (cqr->data == NULL) {
542 if (cqr->cpaddr != NULL) 541 kfree(cqr->cpaddr);
543 kfree(cqr->cpaddr);
544 kfree(cqr); 542 kfree(cqr);
545 return ERR_PTR(-ENOMEM); 543 return ERR_PTR(-ENOMEM);
546 } 544 }
@@ -615,10 +613,8 @@ dasd_kfree_request(struct dasd_ccw_req * cqr, struct dasd_device * device)
615 clear_normalized_cda(ccw); 613 clear_normalized_cda(ccw);
616 } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC)); 614 } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC));
617#endif 615#endif
618 if (cqr->cpaddr != NULL) 616 kfree(cqr->cpaddr);
619 kfree(cqr->cpaddr); 617 kfree(cqr->data);
620 if (cqr->data != NULL)
621 kfree(cqr->data);
622 kfree(cqr); 618 kfree(cqr);
623 dasd_put_device(device); 619 dasd_put_device(device);
624} 620}
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index bda896d9d788..caee16a3dc62 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -387,8 +387,7 @@ dasd_add_busid(char *bus_id, int features)
387 new = 0; 387 new = 0;
388 } 388 }
389 spin_unlock(&dasd_devmap_lock); 389 spin_unlock(&dasd_devmap_lock);
390 if (new) 390 kfree(new);
391 kfree(new);
392 return devmap; 391 return devmap;
393} 392}
394 393
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index 7478423b53bb..ab8754e566bc 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -6,7 +6,7 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.49 $ 9 * $Revision: 1.51 $
10 */ 10 */
11 11
12#include <linux/config.h> 12#include <linux/config.h>
@@ -67,9 +67,9 @@ static const u8 DASD_DIAG_CMS1[] = { 0xc3, 0xd4, 0xe2, 0xf1 };/* EBCDIC CMS1 */
67static __inline__ int 67static __inline__ int
68dia250(void *iob, int cmd) 68dia250(void *iob, int cmd)
69{ 69{
70 typedef struct { 70 typedef union {
71 char _[max(sizeof (struct dasd_diag_init_io), 71 struct dasd_diag_init_io init_io;
72 sizeof (struct dasd_diag_rw_io))]; 72 struct dasd_diag_rw_io rw_io;
73 } addr_type; 73 } addr_type;
74 int rc; 74 int rc;
75 75
@@ -190,7 +190,7 @@ dasd_start_diag(struct dasd_ccw_req * cqr)
190 private->iob.flags = DASD_DIAG_RWFLAG_ASYNC; 190 private->iob.flags = DASD_DIAG_RWFLAG_ASYNC;
191 private->iob.block_count = dreq->block_count; 191 private->iob.block_count = dreq->block_count;
192 private->iob.interrupt_params = (addr_t) cqr; 192 private->iob.interrupt_params = (addr_t) cqr;
193 private->iob.bio_list = __pa(dreq->bio); 193 private->iob.bio_list = dreq->bio;
194 private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT; 194 private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;
195 195
196 cqr->startclk = get_clock(); 196 cqr->startclk = get_clock();
@@ -394,47 +394,57 @@ dasd_diag_check_device(struct dasd_device *device)
394 memset(&bio, 0, sizeof (struct dasd_diag_bio)); 394 memset(&bio, 0, sizeof (struct dasd_diag_bio));
395 bio.type = MDSK_READ_REQ; 395 bio.type = MDSK_READ_REQ;
396 bio.block_number = private->pt_block + 1; 396 bio.block_number = private->pt_block + 1;
397 bio.buffer = __pa(label); 397 bio.buffer = label;
398 memset(&private->iob, 0, sizeof (struct dasd_diag_rw_io)); 398 memset(&private->iob, 0, sizeof (struct dasd_diag_rw_io));
399 private->iob.dev_nr = rdc_data->dev_nr; 399 private->iob.dev_nr = rdc_data->dev_nr;
400 private->iob.key = 0; 400 private->iob.key = 0;
401 private->iob.flags = 0; /* do synchronous io */ 401 private->iob.flags = 0; /* do synchronous io */
402 private->iob.block_count = 1; 402 private->iob.block_count = 1;
403 private->iob.interrupt_params = 0; 403 private->iob.interrupt_params = 0;
404 private->iob.bio_list = __pa(&bio); 404 private->iob.bio_list = &bio;
405 private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT; 405 private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;
406 rc = dia250(&private->iob, RW_BIO); 406 rc = dia250(&private->iob, RW_BIO);
407 if (rc == 0 || rc == 3) 407 if (rc == 3) {
408 break; 408 DEV_MESSAGE(KERN_WARNING, device, "%s",
409 "DIAG call failed");
410 rc = -EOPNOTSUPP;
411 goto out;
412 }
409 mdsk_term_io(device); 413 mdsk_term_io(device);
414 if (rc == 0)
415 break;
410 } 416 }
411 if (rc == 3) { 417 if (bsize > PAGE_SIZE) {
412 DEV_MESSAGE(KERN_WARNING, device, "%s", "DIAG call failed");
413 rc = -EOPNOTSUPP;
414 } else if (rc != 0) {
415 DEV_MESSAGE(KERN_WARNING, device, "device access failed " 418 DEV_MESSAGE(KERN_WARNING, device, "device access failed "
416 "(rc=%d)", rc); 419 "(rc=%d)", rc);
417 rc = -EIO; 420 rc = -EIO;
421 goto out;
422 }
423 /* check for label block */
424 if (memcmp(label->label_id, DASD_DIAG_CMS1,
425 sizeof(DASD_DIAG_CMS1)) == 0) {
426 /* get formatted blocksize from label block */
427 bsize = (unsigned int) label->block_size;
428 device->blocks = (unsigned long) label->block_count;
429 } else
430 device->blocks = end_block;
431 device->bp_block = bsize;
432 device->s2b_shift = 0; /* bits to shift 512 to get a block */
433 for (sb = 512; sb < bsize; sb = sb << 1)
434 device->s2b_shift++;
435 rc = mdsk_init_io(device, device->bp_block, 0, NULL);
436 if (rc) {
437 DEV_MESSAGE(KERN_WARNING, device, "DIAG initialization "
438 "failed (rc=%d)", rc);
439 rc = -EIO;
418 } else { 440 } else {
419 if (memcmp(label->label_id, DASD_DIAG_CMS1,
420 sizeof(DASD_DIAG_CMS1)) == 0) {
421 /* get formatted blocksize from label block */
422 bsize = (unsigned int) label->block_size;
423 device->blocks = (unsigned long) label->block_count;
424 } else
425 device->blocks = end_block;
426 device->bp_block = bsize;
427 device->s2b_shift = 0; /* bits to shift 512 to get a block */
428 for (sb = 512; sb < bsize; sb = sb << 1)
429 device->s2b_shift++;
430
431 DEV_MESSAGE(KERN_INFO, device, 441 DEV_MESSAGE(KERN_INFO, device,
432 "(%ld B/blk): %ldkB", 442 "(%ld B/blk): %ldkB",
433 (unsigned long) device->bp_block, 443 (unsigned long) device->bp_block,
434 (unsigned long) (device->blocks << 444 (unsigned long) (device->blocks <<
435 device->s2b_shift) >> 1); 445 device->s2b_shift) >> 1);
436 rc = 0;
437 } 446 }
447out:
438 free_page((long) label); 448 free_page((long) label);
439 return rc; 449 return rc;
440} 450}
@@ -529,7 +539,7 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
529 memset(dbio, 0, sizeof (struct dasd_diag_bio)); 539 memset(dbio, 0, sizeof (struct dasd_diag_bio));
530 dbio->type = rw_cmd; 540 dbio->type = rw_cmd;
531 dbio->block_number = recid + 1; 541 dbio->block_number = recid + 1;
532 dbio->buffer = __pa(dst); 542 dbio->buffer = dst;
533 dbio++; 543 dbio++;
534 dst += blksize; 544 dst += blksize;
535 recid++; 545 recid++;
diff --git a/drivers/s390/block/dasd_diag.h b/drivers/s390/block/dasd_diag.h
index b26eb28df4bf..df31484d73a7 100644
--- a/drivers/s390/block/dasd_diag.h
+++ b/drivers/s390/block/dasd_diag.h
@@ -6,7 +6,7 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.7 $ 9 * $Revision: 1.8 $
10 */ 10 */
11 11
12#define MDSK_WRITE_REQ 0x01 12#define MDSK_WRITE_REQ 0x01
@@ -78,7 +78,7 @@ struct dasd_diag_bio {
78 u8 spare1[2]; 78 u8 spare1[2];
79 u32 alet; 79 u32 alet;
80 blocknum_t block_number; 80 blocknum_t block_number;
81 u64 buffer; 81 void *buffer;
82} __attribute__ ((packed, aligned(8))); 82} __attribute__ ((packed, aligned(8)));
83 83
84struct dasd_diag_init_io { 84struct dasd_diag_init_io {
@@ -104,7 +104,7 @@ struct dasd_diag_rw_io {
104 u32 alet; 104 u32 alet;
105 u8 spare3[4]; 105 u8 spare3[4];
106 u64 interrupt_params; 106 u64 interrupt_params;
107 u64 bio_list; 107 struct dasd_diag_bio *bio_list;
108 u8 spare4[8]; 108 u8 spare4[8];
109} __attribute__ ((packed, aligned(8))); 109} __attribute__ ((packed, aligned(8)));
110#else /* CONFIG_ARCH_S390X */ 110#else /* CONFIG_ARCH_S390X */
@@ -119,7 +119,7 @@ struct dasd_diag_bio {
119 u16 spare1; 119 u16 spare1;
120 blocknum_t block_number; 120 blocknum_t block_number;
121 u32 alet; 121 u32 alet;
122 u32 buffer; 122 void *buffer;
123} __attribute__ ((packed, aligned(8))); 123} __attribute__ ((packed, aligned(8)));
124 124
125struct dasd_diag_init_io { 125struct dasd_diag_init_io {
@@ -142,7 +142,7 @@ struct dasd_diag_rw_io {
142 u8 spare2[2]; 142 u8 spare2[2];
143 u32 block_count; 143 u32 block_count;
144 u32 alet; 144 u32 alet;
145 u32 bio_list; 145 struct dasd_diag_bio *bio_list;
146 u32 interrupt_params; 146 u32 interrupt_params;
147 u8 spare3[20]; 147 u8 spare3[20];
148} __attribute__ ((packed, aligned(8))); 148} __attribute__ ((packed, aligned(8)));
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index f11a67fda40e..75419cf9d353 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -727,8 +727,7 @@ raw3215_remove (struct ccw_device *cdev)
727 raw = cdev->dev.driver_data; 727 raw = cdev->dev.driver_data;
728 if (raw) { 728 if (raw) {
729 cdev->dev.driver_data = NULL; 729 cdev->dev.driver_data = NULL;
730 if (raw->buffer) 730 kfree(raw->buffer);
731 kfree(raw->buffer);
732 kfree(raw); 731 kfree(raw);
733 } 732 }
734} 733}
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index fd43d99b45a3..5bda2340a39d 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -99,13 +99,11 @@ out_fn_handler:
99 kfree(kbd->fn_handler); 99 kfree(kbd->fn_handler);
100out_func: 100out_func:
101 for (i = 0; i < ARRAY_SIZE(func_table); i++) 101 for (i = 0; i < ARRAY_SIZE(func_table); i++)
102 if (kbd->func_table[i]) 102 kfree(kbd->func_table[i]);
103 kfree(kbd->func_table[i]);
104 kfree(kbd->func_table); 103 kfree(kbd->func_table);
105out_maps: 104out_maps:
106 for (i = 0; i < ARRAY_SIZE(key_maps); i++) 105 for (i = 0; i < ARRAY_SIZE(key_maps); i++)
107 if (kbd->key_maps[i]) 106 kfree(kbd->key_maps[i]);
108 kfree(kbd->key_maps[i]);
109 kfree(kbd->key_maps); 107 kfree(kbd->key_maps);
110out_kbd: 108out_kbd:
111 kfree(kbd); 109 kfree(kbd);
@@ -121,12 +119,10 @@ kbd_free(struct kbd_data *kbd)
121 kfree(kbd->accent_table); 119 kfree(kbd->accent_table);
122 kfree(kbd->fn_handler); 120 kfree(kbd->fn_handler);
123 for (i = 0; i < ARRAY_SIZE(func_table); i++) 121 for (i = 0; i < ARRAY_SIZE(func_table); i++)
124 if (kbd->func_table[i]) 122 kfree(kbd->func_table[i]);
125 kfree(kbd->func_table[i]);
126 kfree(kbd->func_table); 123 kfree(kbd->func_table);
127 for (i = 0; i < ARRAY_SIZE(key_maps); i++) 124 for (i = 0; i < ARRAY_SIZE(key_maps); i++)
128 if (kbd->key_maps[i]) 125 kfree(kbd->key_maps[i]);
129 kfree(kbd->key_maps[i]);
130 kfree(kbd->key_maps); 126 kfree(kbd->key_maps);
131 kfree(kbd); 127 kfree(kbd);
132} 128}
@@ -452,8 +448,7 @@ do_kdgkb_ioctl(struct kbd_data *kbd, struct kbsentry __user *u_kbs,
452 return -EFAULT; 448 return -EFAULT;
453 } 449 }
454 p[len] = 0; 450 p[len] = 0;
455 if (kbd->func_table[kb_func]) 451 kfree(kbd->func_table[kb_func]);
456 kfree(kbd->func_table[kb_func]);
457 kbd->func_table[kb_func] = p; 452 kbd->func_table[kb_func] = p;
458 break; 453 break;
459 } 454 }
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index d66946443dfc..f5b7d360fc10 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -183,8 +183,7 @@ raw3270_request_alloc_bootmem(size_t size)
183void 183void
184raw3270_request_free (struct raw3270_request *rq) 184raw3270_request_free (struct raw3270_request *rq)
185{ 185{
186 if (rq->buffer) 186 kfree(rq->buffer);
187 kfree(rq->buffer);
188 kfree(rq); 187 kfree(rq);
189} 188}
190 189
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 6c52e8307dc5..8f486e1a8507 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -682,8 +682,7 @@ tape_alloc_request(int cplength, int datasize)
682 request->cpdata = kmalloc(datasize, GFP_KERNEL | GFP_DMA); 682 request->cpdata = kmalloc(datasize, GFP_KERNEL | GFP_DMA);
683 if (request->cpdata == NULL) { 683 if (request->cpdata == NULL) {
684 DBF_EXCEPTION(1, "cqra nomem\n"); 684 DBF_EXCEPTION(1, "cqra nomem\n");
685 if (request->cpaddr != NULL) 685 kfree(request->cpaddr);
686 kfree(request->cpaddr);
687 kfree(request); 686 kfree(request);
688 return ERR_PTR(-ENOMEM); 687 return ERR_PTR(-ENOMEM);
689 } 688 }
@@ -706,10 +705,8 @@ tape_free_request (struct tape_request * request)
706 if (request->device != NULL) { 705 if (request->device != NULL) {
707 request->device = tape_put_device(request->device); 706 request->device = tape_put_device(request->device);
708 } 707 }
709 if (request->cpdata != NULL) 708 kfree(request->cpdata);
710 kfree(request->cpdata); 709 kfree(request->cpaddr);
711 if (request->cpaddr != NULL)
712 kfree(request->cpaddr);
713 kfree(request); 710 kfree(request);
714} 711}
715 712
diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c
index 8990d8076e7d..19762f3476aa 100644
--- a/drivers/s390/char/vmcp.c
+++ b/drivers/s390/char/vmcp.c
@@ -103,8 +103,10 @@ vmcp_write(struct file *file, const char __user * buff, size_t count,
103 } 103 }
104 cmd[count] = '\0'; 104 cmd[count] = '\0';
105 session = (struct vmcp_session *)file->private_data; 105 session = (struct vmcp_session *)file->private_data;
106 if (down_interruptible(&session->mutex)) 106 if (down_interruptible(&session->mutex)) {
107 kfree(cmd);
107 return -ERESTARTSYS; 108 return -ERESTARTSYS;
109 }
108 if (!session->response) 110 if (!session->response)
109 session->response = (char *)__get_free_pages(GFP_KERNEL 111 session->response = (char *)__get_free_pages(GFP_KERNEL
110 | __GFP_REPEAT | GFP_DMA, 112 | __GFP_REPEAT | GFP_DMA,
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index dbb3eb0e330b..e7bd7f37f080 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/ccwgroup.c 2 * drivers/s390/cio/ccwgroup.c
3 * bus driver for ccwgroup 3 * bus driver for ccwgroup
4 * $Revision: 1.29 $ 4 * $Revision: 1.32 $
5 * 5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -274,7 +274,7 @@ ccwgroup_set_online(struct ccwgroup_device *gdev)
274 goto out; 274 goto out;
275 } 275 }
276 gdrv = to_ccwgroupdrv (gdev->dev.driver); 276 gdrv = to_ccwgroupdrv (gdev->dev.driver);
277 if ((ret = gdrv->set_online(gdev))) 277 if ((ret = gdrv->set_online ? gdrv->set_online(gdev) : 0))
278 goto out; 278 goto out;
279 279
280 gdev->state = CCWGROUP_ONLINE; 280 gdev->state = CCWGROUP_ONLINE;
@@ -300,7 +300,7 @@ ccwgroup_set_offline(struct ccwgroup_device *gdev)
300 goto out; 300 goto out;
301 } 301 }
302 gdrv = to_ccwgroupdrv (gdev->dev.driver); 302 gdrv = to_ccwgroupdrv (gdev->dev.driver);
303 if ((ret = gdrv->set_offline(gdev))) 303 if ((ret = gdrv->set_offline ? gdrv->set_offline(gdev) : 0))
304 goto out; 304 goto out;
305 305
306 gdev->state = CCWGROUP_OFFLINE; 306 gdev->state = CCWGROUP_OFFLINE;
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index c05b069c2996..b978f7fe8327 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -642,8 +642,7 @@ static void
642free_cmbe (struct ccw_device *cdev) 642free_cmbe (struct ccw_device *cdev)
643{ 643{
644 spin_lock_irq(cdev->ccwlock); 644 spin_lock_irq(cdev->ccwlock);
645 if (cdev->private->cmb) 645 kfree(cdev->private->cmb);
646 kfree(cdev->private->cmb);
647 cdev->private->cmb = NULL; 646 cdev->private->cmb = NULL;
648 spin_unlock_irq(cdev->ccwlock); 647 spin_unlock_irq(cdev->ccwlock);
649 648
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index ad3fe5aeb663..85a3026e6900 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -550,10 +550,8 @@ ccw_device_stlck(struct ccw_device *cdev)
550 /* Clear irb. */ 550 /* Clear irb. */
551 memset(&cdev->private->irb, 0, sizeof(struct irb)); 551 memset(&cdev->private->irb, 0, sizeof(struct irb));
552out_unlock: 552out_unlock:
553 if (buf) 553 kfree(buf);
554 kfree(buf); 554 kfree(buf2);
555 if (buf2)
556 kfree(buf2);
557 spin_unlock_irqrestore(&sch->lock, flags); 555 spin_unlock_irqrestore(&sch->lock, flags);
558 return ret; 556 return ret;
559} 557}
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 381f339e3200..eb39218b925e 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -56,7 +56,7 @@
56#include "ioasm.h" 56#include "ioasm.h"
57#include "chsc.h" 57#include "chsc.h"
58 58
59#define VERSION_QDIO_C "$Revision: 1.101 $" 59#define VERSION_QDIO_C "$Revision: 1.108 $"
60 60
61/****************** MODULE PARAMETER VARIABLES ********************/ 61/****************** MODULE PARAMETER VARIABLES ********************/
62MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>"); 62MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
@@ -1338,16 +1338,14 @@ qdio_release_irq_memory(struct qdio_irq *irq_ptr)
1338 if (!irq_ptr->input_qs[i]) 1338 if (!irq_ptr->input_qs[i])
1339 goto next; 1339 goto next;
1340 1340
1341 if (irq_ptr->input_qs[i]->slib) 1341 kfree(irq_ptr->input_qs[i]->slib);
1342 kfree(irq_ptr->input_qs[i]->slib);
1343 kfree(irq_ptr->input_qs[i]); 1342 kfree(irq_ptr->input_qs[i]);
1344 1343
1345next: 1344next:
1346 if (!irq_ptr->output_qs[i]) 1345 if (!irq_ptr->output_qs[i])
1347 continue; 1346 continue;
1348 1347
1349 if (irq_ptr->output_qs[i]->slib) 1348 kfree(irq_ptr->output_qs[i]->slib);
1350 kfree(irq_ptr->output_qs[i]->slib);
1351 kfree(irq_ptr->output_qs[i]); 1349 kfree(irq_ptr->output_qs[i]);
1352 1350
1353 } 1351 }
@@ -2873,10 +2871,10 @@ qdio_establish(struct qdio_initialize *init_data)
2873 return result; 2871 return result;
2874 } 2872 }
2875 2873
2876 wait_event_interruptible_timeout(cdev->private->wait_q, 2874 /* Timeout is cared for already by using ccw_device_start_timeout(). */
2875 wait_event_interruptible(cdev->private->wait_q,
2877 irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED || 2876 irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED ||
2878 irq_ptr->state == QDIO_IRQ_STATE_ERR, 2877 irq_ptr->state == QDIO_IRQ_STATE_ERR);
2879 QDIO_ESTABLISH_TIMEOUT);
2880 2878
2881 if (irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED) 2879 if (irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED)
2882 result = 0; 2880 result = 0;
@@ -3315,8 +3313,7 @@ qdio_get_qdio_memory(void)
3315static void 3313static void
3316qdio_release_qdio_memory(void) 3314qdio_release_qdio_memory(void)
3317{ 3315{
3318 if (indicators) 3316 kfree(indicators);
3319 kfree(indicators);
3320} 3317}
3321 3318
3322static void 3319static void
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index 0cb47eca91f3..04c2ef778ec6 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -3051,8 +3051,7 @@ destroy_crypto_device(int index)
3051 if (dev_ptr) { 3051 if (dev_ptr) {
3052 disabledFlag = dev_ptr->disabled; 3052 disabledFlag = dev_ptr->disabled;
3053 t = dev_ptr->dev_type; 3053 t = dev_ptr->dev_type;
3054 if (dev_ptr->dev_resp_p) 3054 kfree(dev_ptr->dev_resp_p);
3055 kfree(dev_ptr->dev_resp_p);
3056 kfree(dev_ptr); 3055 kfree(dev_ptr);
3057 } else { 3056 } else {
3058 disabledFlag = 0; 3057 disabledFlag = 0;
@@ -3080,11 +3079,11 @@ static void
3080destroy_z90crypt(void) 3079destroy_z90crypt(void)
3081{ 3080{
3082 int i; 3081 int i;
3082
3083 for (i = 0; i < z90crypt.max_count; i++) 3083 for (i = 0; i < z90crypt.max_count; i++)
3084 if (z90crypt.device_p[i]) 3084 if (z90crypt.device_p[i])
3085 destroy_crypto_device(i); 3085 destroy_crypto_device(i);
3086 if (z90crypt.hdware_info) 3086 kfree(z90crypt.hdware_info);
3087 kfree((void *)z90crypt.hdware_info);
3088 memset((void *)&z90crypt, 0, sizeof(z90crypt)); 3087 memset((void *)&z90crypt, 0, sizeof(z90crypt));
3089} 3088}
3090 3089
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 3092473991a7..1a1c3decea72 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -2743,14 +2743,10 @@ probe_error( struct ccwgroup_device *cgdev)
2743#endif 2743#endif
2744 privptr=(struct claw_privbk *)cgdev->dev.driver_data; 2744 privptr=(struct claw_privbk *)cgdev->dev.driver_data;
2745 if (privptr!=NULL) { 2745 if (privptr!=NULL) {
2746 if (privptr->p_env != NULL) { 2746 kfree(privptr->p_env);
2747 kfree(privptr->p_env); 2747 privptr->p_env=NULL;
2748 privptr->p_env=NULL; 2748 kfree(privptr->p_mtc_envelope);
2749 } 2749 privptr->p_mtc_envelope=NULL;
2750 if (privptr->p_mtc_envelope!=NULL) {
2751 kfree(privptr->p_mtc_envelope);
2752 privptr->p_mtc_envelope=NULL;
2753 }
2754 kfree(privptr); 2750 kfree(privptr);
2755 privptr=NULL; 2751 privptr=NULL;
2756 } 2752 }
@@ -4121,22 +4117,14 @@ claw_remove_device(struct ccwgroup_device *cgdev)
4121 if (cgdev->state == CCWGROUP_ONLINE) 4117 if (cgdev->state == CCWGROUP_ONLINE)
4122 claw_shutdown_device(cgdev); 4118 claw_shutdown_device(cgdev);
4123 claw_remove_files(&cgdev->dev); 4119 claw_remove_files(&cgdev->dev);
4124 if (priv->p_mtc_envelope!=NULL) { 4120 kfree(priv->p_mtc_envelope);
4125 kfree(priv->p_mtc_envelope); 4121 priv->p_mtc_envelope=NULL;
4126 priv->p_mtc_envelope=NULL; 4122 kfree(priv->p_env);
4127 } 4123 priv->p_env=NULL;
4128 if (priv->p_env != NULL) { 4124 kfree(priv->channel[0].irb);
4129 kfree(priv->p_env); 4125 priv->channel[0].irb=NULL;
4130 priv->p_env=NULL; 4126 kfree(priv->channel[1].irb);
4131 } 4127 priv->channel[1].irb=NULL;
4132 if (priv->channel[0].irb != NULL) {
4133 kfree(priv->channel[0].irb);
4134 priv->channel[0].irb=NULL;
4135 }
4136 if (priv->channel[1].irb != NULL) {
4137 kfree(priv->channel[1].irb);
4138 priv->channel[1].irb=NULL;
4139 }
4140 kfree(priv); 4128 kfree(priv);
4141 cgdev->dev.driver_data=NULL; 4129 cgdev->dev.driver_data=NULL;
4142 cgdev->cdev[READ]->dev.driver_data = NULL; 4130 cgdev->cdev[READ]->dev.driver_data = NULL;
diff --git a/drivers/s390/net/fsm.c b/drivers/s390/net/fsm.c
index 38f50b7129a2..24029bd9c7d0 100644
--- a/drivers/s390/net/fsm.c
+++ b/drivers/s390/net/fsm.c
@@ -78,8 +78,7 @@ kfree_fsm(fsm_instance *this)
78{ 78{
79 if (this) { 79 if (this) {
80 if (this->f) { 80 if (this->f) {
81 if (this->f->jumpmatrix) 81 kfree(this->f->jumpmatrix);
82 kfree(this->f->jumpmatrix);
83 kfree(this->f); 82 kfree(this->f);
84 } 83 }
85 kfree(this); 84 kfree(this);
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index e08e74e16124..df7647c3c100 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -447,14 +447,10 @@ static void
447iucv_exit(void) 447iucv_exit(void)
448{ 448{
449 iucv_retrieve_buffer(); 449 iucv_retrieve_buffer();
450 if (iucv_external_int_buffer) { 450 kfree(iucv_external_int_buffer);
451 kfree(iucv_external_int_buffer); 451 iucv_external_int_buffer = NULL;
452 iucv_external_int_buffer = NULL; 452 kfree(iucv_param_pool);
453 } 453 iucv_param_pool = NULL;
454 if (iucv_param_pool) {
455 kfree(iucv_param_pool);
456 iucv_param_pool = NULL;
457 }
458 s390_root_dev_unregister(iucv_root); 454 s390_root_dev_unregister(iucv_root);
459 bus_unregister(&iucv_bus); 455 bus_unregister(&iucv_bus);
460 printk(KERN_INFO "IUCV lowlevel driver unloaded\n"); 456 printk(KERN_INFO "IUCV lowlevel driver unloaded\n");
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 46f34ba93ac5..1c8ad2fcad8a 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -145,8 +145,7 @@ lcs_free_channel(struct lcs_channel *channel)
145 145
146 LCS_DBF_TEXT(2, setup, "ichfree"); 146 LCS_DBF_TEXT(2, setup, "ichfree");
147 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) { 147 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
148 if (channel->iob[cnt].data != NULL) 148 kfree(channel->iob[cnt].data);
149 kfree(channel->iob[cnt].data);
150 channel->iob[cnt].data = NULL; 149 channel->iob[cnt].data = NULL;
151 } 150 }
152} 151}
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index f94f1f25eec6..011915d5e243 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -62,8 +62,7 @@ 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 if (ctx->elements != NULL) 65 kfree(ctx->elements);
66 kfree(ctx->elements);
67 kfree(ctx); 66 kfree(ctx);
68} 67}
69 68
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index cab098556b44..c218b5c944a6 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -450,8 +450,7 @@ zfcp_cfdc_dev_ioctl(struct file *file, unsigned int command,
450 kfree(sg_list); 450 kfree(sg_list);
451 } 451 }
452 452
453 if (sense_data != NULL) 453 kfree(sense_data);
454 kfree(sense_data);
455 454
456 return retval; 455 return retval;
457} 456}
diff --git a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c
index c82abeb59d3a..071ae24be892 100644
--- a/drivers/sbus/char/cpwatchdog.c
+++ b/drivers/sbus/char/cpwatchdog.c
@@ -26,6 +26,7 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/smp_lock.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/ebus.h> 31#include <asm/ebus.h>
31#include <asm/oplib.h> 32#include <asm/oplib.h>
@@ -394,6 +395,28 @@ static int wd_ioctl(struct inode *inode, struct file *file,
394 return(0); 395 return(0);
395} 396}
396 397
398static long wd_compat_ioctl(struct file *file, unsigned int cmd,
399 unsigned long arg)
400{
401 int rval = -ENOIOCTLCMD;
402
403 switch (cmd) {
404 /* solaris ioctls are specific to this driver */
405 case WIOCSTART:
406 case WIOCSTOP:
407 case WIOCGSTAT:
408 lock_kernel();
409 rval = wd_ioctl(file->f_dentry->d_inode, file, cmd, arg);
410 lock_kernel();
411 break;
412 /* everything else is handled by the generic compat layer */
413 default:
414 break;
415 }
416
417 return rval;
418}
419
397static ssize_t wd_write(struct file *file, 420static ssize_t wd_write(struct file *file,
398 const char __user *buf, 421 const char __user *buf,
399 size_t count, 422 size_t count,
@@ -441,6 +464,7 @@ static irqreturn_t wd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
441static struct file_operations wd_fops = { 464static struct file_operations wd_fops = {
442 .owner = THIS_MODULE, 465 .owner = THIS_MODULE,
443 .ioctl = wd_ioctl, 466 .ioctl = wd_ioctl,
467 .compat_ioctl = wd_compat_ioctl,
444 .open = wd_open, 468 .open = wd_open,
445 .write = wd_write, 469 .write = wd_write,
446 .read = wd_read, 470 .read = wd_read,
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index 24ed5893b4f0..39f54213a6d5 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/miscdevice.h> 16#include <linux/miscdevice.h>
17#include <linux/ioport.h> /* request_region */ 17#include <linux/ioport.h> /* request_region */
18#include <linux/smp_lock.h>
18#include <asm/atomic.h> 19#include <asm/atomic.h>
19#include <asm/ebus.h> /* EBus device */ 20#include <asm/ebus.h> /* EBus device */
20#include <asm/oplib.h> /* OpenProm Library */ 21#include <asm/oplib.h> /* OpenProm Library */
@@ -114,22 +115,25 @@ static int d7s_release(struct inode *inode, struct file *f)
114 return 0; 115 return 0;
115} 116}
116 117
117static int d7s_ioctl(struct inode *inode, struct file *f, 118static long d7s_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
118 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 123
123 if (D7S_MINOR != iminor(inode)) 124 if (D7S_MINOR != iminor(file->f_dentry->d_inode))
124 return -ENODEV; 125 return -ENODEV;
125 126
127 lock_kernel();
126 switch (cmd) { 128 switch (cmd) {
127 case D7SIOCWR: 129 case D7SIOCWR:
128 /* assign device register values 130 /* assign device register values
129 * we mask-out D7S_FLIP if in sol_compat mode 131 * we mask-out D7S_FLIP if in sol_compat mode
130 */ 132 */
131 if (get_user(ireg, (int __user *) arg)) 133 if (get_user(ireg, (int __user *) arg)) {
132 return -EFAULT; 134 error = -EFAULT;
135 break;
136 }
133 if (0 != sol_compat) { 137 if (0 != sol_compat) {
134 (regs & D7S_FLIP) ? 138 (regs & D7S_FLIP) ?
135 (ireg |= D7S_FLIP) : (ireg &= ~D7S_FLIP); 139 (ireg |= D7S_FLIP) : (ireg &= ~D7S_FLIP);
@@ -144,8 +148,10 @@ static int d7s_ioctl(struct inode *inode, struct file *f,
144 * This driver will not misinform you about the state 148 * This driver will not misinform you about the state
145 * of your hardware while in sol_compat mode 149 * of your hardware while in sol_compat mode
146 */ 150 */
147 if (put_user(regs, (int __user *) arg)) 151 if (put_user(regs, (int __user *) arg)) {
148 return -EFAULT; 152 error = -EFAULT;
153 break;
154 }
149 break; 155 break;
150 156
151 case D7SIOCTM: 157 case D7SIOCTM:
@@ -155,15 +161,17 @@ static int d7s_ioctl(struct inode *inode, struct file *f,
155 writeb(regs, d7s_regs); 161 writeb(regs, d7s_regs);
156 break; 162 break;
157 }; 163 };
164 lock_kernel();
158 165
159 return 0; 166 return error;
160} 167}
161 168
162static struct file_operations d7s_fops = { 169static struct file_operations d7s_fops = {
163 .owner = THIS_MODULE, 170 .owner = THIS_MODULE,
164 .ioctl = d7s_ioctl, 171 .unlocked_ioctl = d7s_ioctl,
165 .open = d7s_open, 172 .compat_ioctl = d7s_ioctl,
166 .release = d7s_release, 173 .open = d7s_open,
174 .release = d7s_release,
167}; 175};
168 176
169static struct miscdevice d7s_miscdev = { D7S_MINOR, D7S_DEVNAME, &d7s_fops }; 177static struct miscdevice d7s_miscdev = { D7S_MINOR, D7S_DEVNAME, &d7s_fops };
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index b0cc3c2588fd..19e8eddf887a 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -654,9 +654,8 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
654/* Function Description: Command what to read. Mapped to user ioctl(). 654/* Function Description: Command what to read. Mapped to user ioctl().
655 * Return: Gives 0 for implemented commands, -EINVAL otherwise. 655 * Return: Gives 0 for implemented commands, -EINVAL otherwise.
656 */ 656 */
657static int 657static long
658envctrl_ioctl(struct inode *inode, struct file *file, 658envctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
659 unsigned int cmd, unsigned long arg)
660{ 659{
661 char __user *infobuf; 660 char __user *infobuf;
662 661
@@ -715,11 +714,14 @@ envctrl_release(struct inode *inode, struct file *file)
715} 714}
716 715
717static struct file_operations envctrl_fops = { 716static struct file_operations envctrl_fops = {
718 .owner = THIS_MODULE, 717 .owner = THIS_MODULE,
719 .read = envctrl_read, 718 .read = envctrl_read,
720 .ioctl = envctrl_ioctl, 719 .unlocked_ioctl = envctrl_ioctl,
721 .open = envctrl_open, 720#ifdef CONFIG_COMPAT
722 .release = envctrl_release, 721 .compat_ioctl = envctrl_ioctl,
722#endif
723 .open = envctrl_open,
724 .release = envctrl_release,
723}; 725};
724 726
725static struct miscdevice envctrl_dev = { 727static struct miscdevice envctrl_dev = {
@@ -1125,10 +1127,9 @@ out_deregister:
1125 misc_deregister(&envctrl_dev); 1127 misc_deregister(&envctrl_dev);
1126out_iounmap: 1128out_iounmap:
1127 iounmap(i2c); 1129 iounmap(i2c);
1128 for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) { 1130 for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++)
1129 if (i2c_childlist[i].tables) 1131 kfree(i2c_childlist[i].tables);
1130 kfree(i2c_childlist[i].tables); 1132
1131 }
1132 return err; 1133 return err;
1133} 1134}
1134 1135
@@ -1141,10 +1142,8 @@ static void __exit envctrl_cleanup(void)
1141 iounmap(i2c); 1142 iounmap(i2c);
1142 misc_deregister(&envctrl_dev); 1143 misc_deregister(&envctrl_dev);
1143 1144
1144 for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) { 1145 for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++)
1145 if (i2c_childlist[i].tables) 1146 kfree(i2c_childlist[i].tables);
1146 kfree(i2c_childlist[i].tables);
1147 }
1148} 1147}
1149 1148
1150module_init(envctrl_init); 1149module_init(envctrl_init);
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index 58ed33749571..5028ac214326 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -39,6 +39,7 @@
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/miscdevice.h> 41#include <linux/miscdevice.h>
42#include <linux/smp_lock.h>
42#include <linux/init.h> 43#include <linux/init.h>
43#include <linux/fs.h> 44#include <linux/fs.h>
44#include <asm/oplib.h> 45#include <asm/oplib.h>
@@ -565,6 +566,38 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
565 } 566 }
566} 567}
567 568
569static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
570 unsigned long arg)
571{
572 long rval = -ENOTTY;
573
574 /*
575 * SunOS/Solaris only, the NetBSD one's have embedded pointers in
576 * the arg which we'd need to clean up...
577 */
578 switch (cmd) {
579 case OPROMGETOPT:
580 case OPROMSETOPT:
581 case OPROMNXTOPT:
582 case OPROMSETOPT2:
583 case OPROMNEXT:
584 case OPROMCHILD:
585 case OPROMGETPROP:
586 case OPROMNXTPROP:
587 case OPROMU2P:
588 case OPROMGETCONS:
589 case OPROMGETFBNAME:
590 case OPROMGETBOOTARGS:
591 case OPROMSETCUR:
592 case OPROMPCI2NODE:
593 case OPROMPATH2NODE:
594 lock_kernel();
595 rval = openprom_ioctl(file->f_dentry->d_inode, file, cmd, arg);
596 lock_kernel();
597 break;
598 }
599}
600
568static int openprom_open(struct inode * inode, struct file * file) 601static int openprom_open(struct inode * inode, struct file * file)
569{ 602{
570 DATA *data; 603 DATA *data;
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index d06ee65d668d..3ff74f472249 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1017,8 +1017,7 @@ static void twa_free_device_extension(TW_Device_Extension *tw_dev)
1017 tw_dev->generic_buffer_virt[0], 1017 tw_dev->generic_buffer_virt[0],
1018 tw_dev->generic_buffer_phys[0]); 1018 tw_dev->generic_buffer_phys[0]);
1019 1019
1020 if (tw_dev->event_queue[0]) 1020 kfree(tw_dev->event_queue[0]);
1021 kfree(tw_dev->event_queue[0]);
1022} /* End twa_free_device_extension() */ 1021} /* End twa_free_device_extension() */
1023 1022
1024/* This function will free a request id */ 1023/* This function will free a request id */
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index cc9ecb35b412..cba9655d0f14 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -606,10 +606,7 @@ static int __init NCR5380_probe_irq(struct Scsi_Host *instance, int possible)
606 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL); 606 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL);
607 607
608 while (probe_irq == SCSI_IRQ_NONE && time_before(jiffies, timeout)) 608 while (probe_irq == SCSI_IRQ_NONE && time_before(jiffies, timeout))
609 { 609 schedule_timeout_uninterruptible(1);
610 set_current_state(TASK_UNINTERRUPTIBLE);
611 schedule_timeout(1);
612 }
613 610
614 NCR5380_write(SELECT_ENABLE_REG, 0); 611 NCR5380_write(SELECT_ENABLE_REG, 0);
615 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 612 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index ee9067255930..723c0cea7c04 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1164,7 +1164,7 @@ int aac_command_thread(struct aac_dev * dev)
1164 kfree(hw_fib_pool); 1164 kfree(hw_fib_pool);
1165 hw_fib_pool = NULL; 1165 hw_fib_pool = NULL;
1166 } 1166 }
1167 } else if (hw_fib_pool) { 1167 } else {
1168 kfree(hw_fib_pool); 1168 kfree(hw_fib_pool);
1169 hw_fib_pool = NULL; 1169 hw_fib_pool = NULL;
1170 } 1170 }
@@ -1247,17 +1247,13 @@ int aac_command_thread(struct aac_dev * dev)
1247 hw_fib_p = hw_fib_pool; 1247 hw_fib_p = hw_fib_pool;
1248 fib_p = fib_pool; 1248 fib_p = fib_pool;
1249 while (hw_fib_p < &hw_fib_pool[num]) { 1249 while (hw_fib_p < &hw_fib_pool[num]) {
1250 if (*hw_fib_p) 1250 kfree(*hw_fib_p);
1251 kfree(*hw_fib_p); 1251 kfree(*fib_p);
1252 if (*fib_p)
1253 kfree(*fib_p);
1254 ++fib_p; 1252 ++fib_p;
1255 ++hw_fib_p; 1253 ++hw_fib_p;
1256 } 1254 }
1257 if (hw_fib_pool) 1255 kfree(hw_fib_pool);
1258 kfree(hw_fib_pool); 1256 kfree(fib_pool);
1259 if (fib_pool)
1260 kfree(fib_pool);
1261 } 1257 }
1262 kfree(fib); 1258 kfree(fib);
1263 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags); 1259 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);
diff --git a/drivers/scsi/aacraid/rkt.c b/drivers/scsi/aacraid/rkt.c
index fc4c73c2a6a9..e9b775d6bec9 100644
--- a/drivers/scsi/aacraid/rkt.c
+++ b/drivers/scsi/aacraid/rkt.c
@@ -183,8 +183,7 @@ static int rkt_sync_cmd(struct aac_dev *dev, u32 command,
183 /* 183 /*
184 * Yield the processor in case we are slow 184 * Yield the processor in case we are slow
185 */ 185 */
186 set_current_state(TASK_UNINTERRUPTIBLE); 186 schedule_timeout_uninterruptible(1);
187 schedule_timeout(1);
188 } 187 }
189 if (ok != 1) { 188 if (ok != 1) {
190 /* 189 /*
@@ -452,8 +451,7 @@ int aac_rkt_init(struct aac_dev *dev)
452 dev->name, instance, status); 451 dev->name, instance, status);
453 goto error_iounmap; 452 goto error_iounmap;
454 } 453 }
455 set_current_state(TASK_UNINTERRUPTIBLE); 454 schedule_timeout_uninterruptible(1);
456 schedule_timeout(1);
457 } 455 }
458 if (request_irq(dev->scsi_host_ptr->irq, aac_rkt_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0) 456 if (request_irq(dev->scsi_host_ptr->irq, aac_rkt_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0)
459 { 457 {
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index da99046e5393..6998bc877dd6 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -183,8 +183,7 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command,
183 /* 183 /*
184 * Yield the processor in case we are slow 184 * Yield the processor in case we are slow
185 */ 185 */
186 set_current_state(TASK_UNINTERRUPTIBLE); 186 schedule_timeout_uninterruptible(1);
187 schedule_timeout(1);
188 } 187 }
189 if (ok != 1) { 188 if (ok != 1) {
190 /* 189 /*
@@ -452,8 +451,7 @@ int aac_rx_init(struct aac_dev *dev)
452 dev->name, instance, status); 451 dev->name, instance, status);
453 goto error_iounmap; 452 goto error_iounmap;
454 } 453 }
455 set_current_state(TASK_UNINTERRUPTIBLE); 454 schedule_timeout_uninterruptible(1);
456 schedule_timeout(1);
457 } 455 }
458 if (request_irq(dev->scsi_host_ptr->irq, aac_rx_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0) 456 if (request_irq(dev->scsi_host_ptr->irq, aac_rx_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0)
459 { 457 {
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
index 8b9596209164..466f05cfbf0c 100644
--- a/drivers/scsi/aacraid/sa.c
+++ b/drivers/scsi/aacraid/sa.c
@@ -189,8 +189,7 @@ static int sa_sync_cmd(struct aac_dev *dev, u32 command,
189 ok = 1; 189 ok = 1;
190 break; 190 break;
191 } 191 }
192 set_current_state(TASK_UNINTERRUPTIBLE); 192 schedule_timeout_uninterruptible(1);
193 schedule_timeout(1);
194 } 193 }
195 194
196 if (ok != 1) 195 if (ok != 1)
@@ -325,8 +324,7 @@ int aac_sa_init(struct aac_dev *dev)
325 name, instance, status); 324 name, instance, status);
326 goto error_iounmap; 325 goto error_iounmap;
327 } 326 }
328 set_current_state(TASK_UNINTERRUPTIBLE); 327 schedule_timeout_uninterruptible(1);
329 schedule_timeout(1);
330 } 328 }
331 329
332 if (request_irq(dev->scsi_host_ptr->irq, aac_sa_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev ) < 0) { 330 if (request_irq(dev->scsi_host_ptr->irq, aac_sa_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev ) < 0) {
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 37ec5411e325..f4cfb8f29620 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -5402,10 +5402,8 @@ advansys_detect(struct scsi_host_template *tpnt)
5402 release_region(shp->io_port, boardp->asc_n_io_port); 5402 release_region(shp->io_port, boardp->asc_n_io_port);
5403 if (ASC_WIDE_BOARD(boardp)) { 5403 if (ASC_WIDE_BOARD(boardp)) {
5404 iounmap(boardp->ioremap_addr); 5404 iounmap(boardp->ioremap_addr);
5405 if (boardp->orig_carrp) { 5405 kfree(boardp->orig_carrp);
5406 kfree(boardp->orig_carrp); 5406 boardp->orig_carrp = NULL;
5407 boardp->orig_carrp = NULL;
5408 }
5409 if (boardp->orig_reqp) { 5407 if (boardp->orig_reqp) {
5410 kfree(boardp->orig_reqp); 5408 kfree(boardp->orig_reqp);
5411 boardp->orig_reqp = boardp->adv_reqp = NULL; 5409 boardp->orig_reqp = boardp->adv_reqp = NULL;
@@ -5457,10 +5455,8 @@ advansys_release(struct Scsi_Host *shp)
5457 adv_sgblk_t *sgp = NULL; 5455 adv_sgblk_t *sgp = NULL;
5458 5456
5459 iounmap(boardp->ioremap_addr); 5457 iounmap(boardp->ioremap_addr);
5460 if (boardp->orig_carrp) { 5458 kfree(boardp->orig_carrp);
5461 kfree(boardp->orig_carrp); 5459 boardp->orig_carrp = NULL;
5462 boardp->orig_carrp = NULL;
5463 }
5464 if (boardp->orig_reqp) { 5460 if (boardp->orig_reqp) {
5465 kfree(boardp->orig_reqp); 5461 kfree(boardp->orig_reqp);
5466 boardp->orig_reqp = boardp->adv_reqp = NULL; 5462 boardp->orig_reqp = boardp->adv_reqp = NULL;
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index adda750412f2..1b1adfb384cb 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -543,10 +543,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id, struct pt
543 return; 543 return;
544 } 544 }
545 my_done = SCtmp->scsi_done; 545 my_done = SCtmp->scsi_done;
546 if (SCtmp->host_scribble) { 546 kfree(SCtmp->host_scribble);
547 kfree(SCtmp->host_scribble); 547 SCtmp->host_scribble = NULL;
548 SCtmp->host_scribble = NULL;
549 }
550 /* Fetch the sense data, and tuck it away, in the required slot. The 548 /* Fetch the sense data, and tuck it away, in the required slot. The
551 Adaptec automatically fetches it, and there is no guarantee that 549 Adaptec automatically fetches it, and there is no guarantee that
552 we will still have it in the cdb when we come back */ 550 we will still have it in the cdb when we come back */
@@ -1432,10 +1430,8 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)
1432 HOSTDATA(SCpnt->host)->SCint[i]->target == SCpnt->target) { 1430 HOSTDATA(SCpnt->host)->SCint[i]->target == SCpnt->target) {
1433 Scsi_Cmnd *SCtmp; 1431 Scsi_Cmnd *SCtmp;
1434 SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; 1432 SCtmp = HOSTDATA(SCpnt->host)->SCint[i];
1435 if (SCtmp->host_scribble) { 1433 kfree(SCtmp->host_scribble);
1436 kfree(SCtmp->host_scribble); 1434 SCtmp->host_scribble = NULL;
1437 SCtmp->host_scribble = NULL;
1438 }
1439 HOSTDATA(SCpnt->host)->SCint[i] = NULL; 1435 HOSTDATA(SCpnt->host)->SCint[i] = NULL;
1440 HOSTDATA(SCpnt->host)->mb[i].status = 0; 1436 HOSTDATA(SCpnt->host)->mb[i].status = 0;
1441 } 1437 }
@@ -1495,10 +1491,8 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)
1495 */ 1491 */
1496 continue; 1492 continue;
1497 } 1493 }
1498 if (SCtmp->host_scribble) { 1494 kfree(SCtmp->host_scribble);
1499 kfree(SCtmp->host_scribble); 1495 SCtmp->host_scribble = NULL;
1500 SCtmp->host_scribble = NULL;
1501 }
1502 HOSTDATA(SCpnt->device->host)->SCint[i] = NULL; 1496 HOSTDATA(SCpnt->device->host)->SCint[i] = NULL;
1503 HOSTDATA(SCpnt->device->host)->mb[i].status = 0; 1497 HOSTDATA(SCpnt->device->host)->mb[i].status = 0;
1504 } 1498 }
@@ -1565,10 +1559,8 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
1565 */ 1559 */
1566 continue; 1560 continue;
1567 } 1561 }
1568 if (SCtmp->host_scribble) { 1562 kfree(SCtmp->host_scribble);
1569 kfree(SCtmp->host_scribble); 1563 SCtmp->host_scribble = NULL;
1570 SCtmp->host_scribble = NULL;
1571 }
1572 HOSTDATA(SCpnt->device->host)->SCint[i] = NULL; 1564 HOSTDATA(SCpnt->device->host)->SCint[i] = NULL;
1573 HOSTDATA(SCpnt->device->host)->mb[i].status = 0; 1565 HOSTDATA(SCpnt->device->host)->mb[i].status = 0;
1574 } 1566 }
@@ -1711,10 +1703,8 @@ static int aha1542_old_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags)
1711 Scsi_Cmnd *SCtmp; 1703 Scsi_Cmnd *SCtmp;
1712 SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; 1704 SCtmp = HOSTDATA(SCpnt->host)->SCint[i];
1713 SCtmp->result = DID_RESET << 16; 1705 SCtmp->result = DID_RESET << 16;
1714 if (SCtmp->host_scribble) { 1706 kfree(SCtmp->host_scribble);
1715 kfree(SCtmp->host_scribble); 1707 SCtmp->host_scribble = NULL;
1716 SCtmp->host_scribble = NULL;
1717 }
1718 printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target); 1708 printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target);
1719 SCtmp->scsi_done(SCpnt); 1709 SCtmp->scsi_done(SCpnt);
1720 1710
@@ -1757,10 +1747,8 @@ fail:
1757 Scsi_Cmnd *SCtmp; 1747 Scsi_Cmnd *SCtmp;
1758 SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; 1748 SCtmp = HOSTDATA(SCpnt->host)->SCint[i];
1759 SCtmp->result = DID_RESET << 16; 1749 SCtmp->result = DID_RESET << 16;
1760 if (SCtmp->host_scribble) { 1750 kfree(SCtmp->host_scribble);
1761 kfree(SCtmp->host_scribble); 1751 SCtmp->host_scribble = NULL;
1762 SCtmp->host_scribble = NULL;
1763 }
1764 printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target); 1752 printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target);
1765 SCtmp->scsi_done(SCpnt); 1753 SCtmp->scsi_done(SCpnt);
1766 1754
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index 52b72d7794f5..880e2d9ffe9b 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -8492,8 +8492,7 @@ aic7xxx_free(struct aic7xxx_host *p)
8492 - scb_dma->dma_offset), 8492 - scb_dma->dma_offset),
8493 scb_dma->dma_address); 8493 scb_dma->dma_address);
8494 } 8494 }
8495 if (p->scb_data->scb_array[i]->kmalloc_ptr != NULL) 8495 kfree(p->scb_data->scb_array[i]->kmalloc_ptr);
8496 kfree(p->scb_data->scb_array[i]->kmalloc_ptr);
8497 p->scb_data->scb_array[i] = NULL; 8496 p->scb_data->scb_array[i] = NULL;
8498 } 8497 }
8499 8498
diff --git a/drivers/scsi/arm/queue.c b/drivers/scsi/arm/queue.c
index e6d159270d29..b10750bb5c09 100644
--- a/drivers/scsi/arm/queue.c
+++ b/drivers/scsi/arm/queue.c
@@ -91,8 +91,7 @@ void queue_free (Queue_t *queue)
91{ 91{
92 if (!list_empty(&queue->head)) 92 if (!list_empty(&queue->head))
93 printk(KERN_WARNING "freeing non-empty queue %p\n", queue); 93 printk(KERN_WARNING "freeing non-empty queue %p\n", queue);
94 if (queue->alloc) 94 kfree(queue->alloc);
95 kfree(queue->alloc);
96} 95}
97 96
98 97
diff --git a/drivers/scsi/atari_dma_emul.c b/drivers/scsi/atari_dma_emul.c
index 7026045527fd..8d5d2a5da961 100644
--- a/drivers/scsi/atari_dma_emul.c
+++ b/drivers/scsi/atari_dma_emul.c
@@ -19,6 +19,8 @@
19 * this code. 19 * this code.
20 */ 20 */
21 21
22#include <linux/compiler.h>
23#include <asm/thread_info.h>
22#include <asm/uaccess.h> 24#include <asm/uaccess.h>
23 25
24#define hades_dma_ctrl (*(unsigned char *) 0xffff8717) 26#define hades_dma_ctrl (*(unsigned char *) 0xffff8717)
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index c44af5795b10..c8a32cf47d73 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -4270,8 +4270,7 @@ static void adapter_sg_tables_free(struct AdapterCtlBlk *acb)
4270 const unsigned srbs_per_page = PAGE_SIZE/SEGMENTX_LEN; 4270 const unsigned srbs_per_page = PAGE_SIZE/SEGMENTX_LEN;
4271 4271
4272 for (i = 0; i < DC395x_MAX_SRB_CNT; i += srbs_per_page) 4272 for (i = 0; i < DC395x_MAX_SRB_CNT; i += srbs_per_page)
4273 if (acb->srb_array[i].segment_x) 4273 kfree(acb->srb_array[i].segment_x);
4274 kfree(acb->srb_array[i].segment_x);
4275} 4274}
4276 4275
4277 4276
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 7235f94f1191..c28e3aea1c3c 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1037,18 +1037,10 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1037 if(pHba->msg_addr_virt != pHba->base_addr_virt){ 1037 if(pHba->msg_addr_virt != pHba->base_addr_virt){
1038 iounmap(pHba->msg_addr_virt); 1038 iounmap(pHba->msg_addr_virt);
1039 } 1039 }
1040 if(pHba->hrt) { 1040 kfree(pHba->hrt);
1041 kfree(pHba->hrt); 1041 kfree(pHba->lct);
1042 } 1042 kfree(pHba->status_block);
1043 if(pHba->lct){ 1043 kfree(pHba->reply_pool);
1044 kfree(pHba->lct);
1045 }
1046 if(pHba->status_block) {
1047 kfree(pHba->status_block);
1048 }
1049 if(pHba->reply_pool){
1050 kfree(pHba->reply_pool);
1051 }
1052 1044
1053 for(d = pHba->devices; d ; d = next){ 1045 for(d = pHba->devices; d ; d = next){
1054 next = d->next; 1046 next = d->next;
@@ -1218,8 +1210,7 @@ static s32 adpt_i2o_post_this(adpt_hba* pHba, u32* data, int len)
1218 printk(KERN_WARNING"dpti%d: Timeout waiting for message frame!\n", pHba->unit); 1210 printk(KERN_WARNING"dpti%d: Timeout waiting for message frame!\n", pHba->unit);
1219 return -ETIMEDOUT; 1211 return -ETIMEDOUT;
1220 } 1212 }
1221 set_current_state(TASK_UNINTERRUPTIBLE); 1213 schedule_timeout_uninterruptible(1);
1222 schedule_timeout(1);
1223 } while(m == EMPTY_QUEUE); 1214 } while(m == EMPTY_QUEUE);
1224 1215
1225 msg = pHba->msg_addr_virt + m; 1216 msg = pHba->msg_addr_virt + m;
@@ -1294,8 +1285,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
1294 printk(KERN_WARNING"Timeout waiting for message!\n"); 1285 printk(KERN_WARNING"Timeout waiting for message!\n");
1295 return -ETIMEDOUT; 1286 return -ETIMEDOUT;
1296 } 1287 }
1297 set_current_state(TASK_UNINTERRUPTIBLE); 1288 schedule_timeout_uninterruptible(1);
1298 schedule_timeout(1);
1299 } while (m == EMPTY_QUEUE); 1289 } while (m == EMPTY_QUEUE);
1300 1290
1301 status = (u8*)kmalloc(4, GFP_KERNEL|ADDR32); 1291 status = (u8*)kmalloc(4, GFP_KERNEL|ADDR32);
@@ -1327,8 +1317,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
1327 return -ETIMEDOUT; 1317 return -ETIMEDOUT;
1328 } 1318 }
1329 rmb(); 1319 rmb();
1330 set_current_state(TASK_UNINTERRUPTIBLE); 1320 schedule_timeout_uninterruptible(1);
1331 schedule_timeout(1);
1332 } 1321 }
1333 1322
1334 if(*status == 0x01 /*I2O_EXEC_IOP_RESET_IN_PROGRESS*/) { 1323 if(*status == 0x01 /*I2O_EXEC_IOP_RESET_IN_PROGRESS*/) {
@@ -1345,8 +1334,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
1345 printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name); 1334 printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name);
1346 return -ETIMEDOUT; 1335 return -ETIMEDOUT;
1347 } 1336 }
1348 set_current_state(TASK_UNINTERRUPTIBLE); 1337 schedule_timeout_uninterruptible(1);
1349 schedule_timeout(1);
1350 } while (m == EMPTY_QUEUE); 1338 } while (m == EMPTY_QUEUE);
1351 // Flush the offset 1339 // Flush the offset
1352 adpt_send_nop(pHba, m); 1340 adpt_send_nop(pHba, m);
@@ -1917,11 +1905,8 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
1917 return -ENXIO; 1905 return -ENXIO;
1918 } 1906 }
1919 1907
1920 while((volatile u32) pHba->state & DPTI_STATE_RESET ) { 1908 while((volatile u32) pHba->state & DPTI_STATE_RESET )
1921 set_task_state(current,TASK_UNINTERRUPTIBLE); 1909 schedule_timeout_uninterruptible(2);
1922 schedule_timeout(2);
1923
1924 }
1925 1910
1926 switch (cmd) { 1911 switch (cmd) {
1927 // TODO: handle 3 cases 1912 // TODO: handle 3 cases
@@ -2635,8 +2620,7 @@ static s32 adpt_send_nop(adpt_hba*pHba,u32 m)
2635 printk(KERN_ERR "%s: Timeout waiting for message frame!\n",pHba->name); 2620 printk(KERN_ERR "%s: Timeout waiting for message frame!\n",pHba->name);
2636 return 2; 2621 return 2;
2637 } 2622 }
2638 set_current_state(TASK_UNINTERRUPTIBLE); 2623 schedule_timeout_uninterruptible(1);
2639 schedule_timeout(1);
2640 } 2624 }
2641 msg = (u32 __iomem *)(pHba->msg_addr_virt + m); 2625 msg = (u32 __iomem *)(pHba->msg_addr_virt + m);
2642 writel( THREE_WORD_MSG_SIZE | SGL_OFFSET_0,&msg[0]); 2626 writel( THREE_WORD_MSG_SIZE | SGL_OFFSET_0,&msg[0]);
@@ -2670,8 +2654,7 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
2670 printk(KERN_WARNING"%s: Timeout waiting for message frame\n",pHba->name); 2654 printk(KERN_WARNING"%s: Timeout waiting for message frame\n",pHba->name);
2671 return -ETIMEDOUT; 2655 return -ETIMEDOUT;
2672 } 2656 }
2673 set_current_state(TASK_UNINTERRUPTIBLE); 2657 schedule_timeout_uninterruptible(1);
2674 schedule_timeout(1);
2675 } while(m == EMPTY_QUEUE); 2658 } while(m == EMPTY_QUEUE);
2676 2659
2677 msg=(u32 __iomem *)(pHba->msg_addr_virt+m); 2660 msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
@@ -2709,21 +2692,18 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
2709 printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name); 2692 printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name);
2710 return -ETIMEDOUT; 2693 return -ETIMEDOUT;
2711 } 2694 }
2712 set_current_state(TASK_UNINTERRUPTIBLE); 2695 schedule_timeout_uninterruptible(1);
2713 schedule_timeout(1);
2714 } while (1); 2696 } while (1);
2715 2697
2716 // If the command was successful, fill the fifo with our reply 2698 // If the command was successful, fill the fifo with our reply
2717 // message packets 2699 // message packets
2718 if(*status != 0x04 /*I2O_EXEC_OUTBOUND_INIT_COMPLETE*/) { 2700 if(*status != 0x04 /*I2O_EXEC_OUTBOUND_INIT_COMPLETE*/) {
2719 kfree((void*)status); 2701 kfree(status);
2720 return -2; 2702 return -2;
2721 } 2703 }
2722 kfree((void*)status); 2704 kfree(status);
2723 2705
2724 if(pHba->reply_pool != NULL){ 2706 kfree(pHba->reply_pool);
2725 kfree(pHba->reply_pool);
2726 }
2727 2707
2728 pHba->reply_pool = (u32*)kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); 2708 pHba->reply_pool = (u32*)kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32);
2729 if(!pHba->reply_pool){ 2709 if(!pHba->reply_pool){
@@ -2788,8 +2768,7 @@ static s32 adpt_i2o_status_get(adpt_hba* pHba)
2788 pHba->name); 2768 pHba->name);
2789 return -ETIMEDOUT; 2769 return -ETIMEDOUT;
2790 } 2770 }
2791 set_current_state(TASK_UNINTERRUPTIBLE); 2771 schedule_timeout_uninterruptible(1);
2792 schedule_timeout(1);
2793 } while(m==EMPTY_QUEUE); 2772 } while(m==EMPTY_QUEUE);
2794 2773
2795 2774
@@ -2816,8 +2795,7 @@ static s32 adpt_i2o_status_get(adpt_hba* pHba)
2816 return -ETIMEDOUT; 2795 return -ETIMEDOUT;
2817 } 2796 }
2818 rmb(); 2797 rmb();
2819 set_current_state(TASK_UNINTERRUPTIBLE); 2798 schedule_timeout_uninterruptible(1);
2820 schedule_timeout(1);
2821 } 2799 }
2822 2800
2823 // Set up our number of outbound and inbound messages 2801 // Set up our number of outbound and inbound messages
@@ -2941,8 +2919,7 @@ static int adpt_i2o_build_sys_table(void)
2941 sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs 2919 sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs
2942 (hba_count) * sizeof(struct i2o_sys_tbl_entry); 2920 (hba_count) * sizeof(struct i2o_sys_tbl_entry);
2943 2921
2944 if(sys_tbl) 2922 kfree(sys_tbl);
2945 kfree(sys_tbl);
2946 2923
2947 sys_tbl = kmalloc(sys_tbl_len, GFP_KERNEL|ADDR32); 2924 sys_tbl = kmalloc(sys_tbl_len, GFP_KERNEL|ADDR32);
2948 if(!sys_tbl) { 2925 if(!sys_tbl) {
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index b45a4c730230..b3f9de8f7595 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -2580,8 +2580,7 @@ static int eata2x_release(struct Scsi_Host *shost)
2580 unsigned int i; 2580 unsigned int i;
2581 2581
2582 for (i = 0; i < shost->can_queue; i++) 2582 for (i = 0; i < shost->can_queue; i++)
2583 if ((&ha->cp[i])->sglist) 2583 kfree((&ha->cp[i])->sglist);
2584 kfree((&ha->cp[i])->sglist);
2585 2584
2586 for (i = 0; i < shost->can_queue; i++) 2585 for (i = 0; i < shost->can_queue; i++)
2587 pci_unmap_single(ha->pdev, ha->cp[i].cp_dma_addr, 2586 pci_unmap_single(ha->pdev, ha->cp[i].cp_dma_addr,
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 50d0cec54777..3553da0e1cd5 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -331,9 +331,9 @@ static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_co
331 rq = kmalloc (sizeof (struct request), GFP_ATOMIC); 331 rq = kmalloc (sizeof (struct request), GFP_ATOMIC);
332 buf = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); 332 buf = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC);
333 if (pc == NULL || rq == NULL || buf == NULL) { 333 if (pc == NULL || rq == NULL || buf == NULL) {
334 if (pc) kfree(pc); 334 kfree(buf);
335 if (rq) kfree(rq); 335 kfree(rq);
336 if (buf) kfree(buf); 336 kfree(pc);
337 return -ENOMEM; 337 return -ENOMEM;
338 } 338 }
339 memset (pc, 0, sizeof (idescsi_pc_t)); 339 memset (pc, 0, sizeof (idescsi_pc_t));
@@ -950,8 +950,8 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
950 spin_lock_irq(host->host_lock); 950 spin_lock_irq(host->host_lock);
951 return 0; 951 return 0;
952abort: 952abort:
953 if (pc) kfree (pc); 953 kfree (pc);
954 if (rq) kfree (rq); 954 kfree (rq);
955 cmd->result = DID_ERROR << 16; 955 cmd->result = DID_ERROR << 16;
956 done(cmd); 956 done(cmd);
957 return 0; 957 return 0;
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index d0c51a2d40ba..cae3262a2957 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -4514,10 +4514,8 @@ ips_free(ips_ha_t * ha)
4514 ha->enq = NULL; 4514 ha->enq = NULL;
4515 } 4515 }
4516 4516
4517 if (ha->conf) { 4517 kfree(ha->conf);
4518 kfree(ha->conf); 4518 ha->conf = NULL;
4519 ha->conf = NULL;
4520 }
4521 4519
4522 if (ha->adapt) { 4520 if (ha->adapt) {
4523 pci_free_consistent(ha->pcidev, 4521 pci_free_consistent(ha->pcidev,
@@ -4535,15 +4533,11 @@ ips_free(ips_ha_t * ha)
4535 ha->logical_drive_info = NULL; 4533 ha->logical_drive_info = NULL;
4536 } 4534 }
4537 4535
4538 if (ha->nvram) { 4536 kfree(ha->nvram);
4539 kfree(ha->nvram); 4537 ha->nvram = NULL;
4540 ha->nvram = NULL;
4541 }
4542 4538
4543 if (ha->subsys) { 4539 kfree(ha->subsys);
4544 kfree(ha->subsys); 4540 ha->subsys = NULL;
4545 ha->subsys = NULL;
4546 }
4547 4541
4548 if (ha->ioctl_data) { 4542 if (ha->ioctl_data) {
4549 pci_free_consistent(ha->pcidev, ha->ioctl_len, 4543 pci_free_consistent(ha->pcidev, ha->ioctl_len,
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 08a0c00cfc30..bcc29ec126dc 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -127,8 +127,7 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba,
127 if (((pcmd = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) || 127 if (((pcmd = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) ||
128 ((pcmd->virt = lpfc_mbuf_alloc(phba, 128 ((pcmd->virt = lpfc_mbuf_alloc(phba,
129 MEM_PRI, &(pcmd->phys))) == 0)) { 129 MEM_PRI, &(pcmd->phys))) == 0)) {
130 if (pcmd) 130 kfree(pcmd);
131 kfree(pcmd);
132 131
133 spin_lock_irq(phba->host->host_lock); 132 spin_lock_irq(phba->host->host_lock);
134 lpfc_sli_release_iocbq(phba, elsiocb); 133 lpfc_sli_release_iocbq(phba, elsiocb);
@@ -145,8 +144,7 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba,
145 prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, 144 prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
146 &prsp->phys); 145 &prsp->phys);
147 if (prsp == 0 || prsp->virt == 0) { 146 if (prsp == 0 || prsp->virt == 0) {
148 if (prsp) 147 kfree(prsp);
149 kfree(prsp);
150 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys); 148 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
151 kfree(pcmd); 149 kfree(pcmd);
152 spin_lock_irq(phba->host->host_lock); 150 spin_lock_irq(phba->host->host_lock);
@@ -172,8 +170,7 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba,
172 lpfc_mbuf_free(phba, prsp->virt, prsp->phys); 170 lpfc_mbuf_free(phba, prsp->virt, prsp->phys);
173 kfree(pcmd); 171 kfree(pcmd);
174 kfree(prsp); 172 kfree(prsp);
175 if (pbuflist) 173 kfree(pbuflist);
176 kfree(pbuflist);
177 return NULL; 174 return NULL;
178 } 175 }
179 176
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 4e04470321a2..c90723860a04 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -894,8 +894,7 @@ lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt,
894 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, 894 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
895 &mp1->phys); 895 &mp1->phys);
896 if (mp1 == 0 || mp1->virt == 0) { 896 if (mp1 == 0 || mp1->virt == 0) {
897 if (mp1) 897 kfree(mp1);
898 kfree(mp1);
899 spin_lock_irq(phba->host->host_lock); 898 spin_lock_irq(phba->host->host_lock);
900 lpfc_sli_release_iocbq(phba, iocb); 899 lpfc_sli_release_iocbq(phba, iocb);
901 spin_unlock_irq(phba->host->host_lock); 900 spin_unlock_irq(phba->host->host_lock);
@@ -911,8 +910,7 @@ lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt,
911 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, 910 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
912 &mp2->phys); 911 &mp2->phys);
913 if (mp2 == 0 || mp2->virt == 0) { 912 if (mp2 == 0 || mp2->virt == 0) {
914 if (mp2) 913 kfree(mp2);
915 kfree(mp2);
916 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); 914 lpfc_mbuf_free(phba, mp1->virt, mp1->phys);
917 kfree(mp1); 915 kfree(mp1);
918 spin_lock_irq(phba->host->host_lock); 916 spin_lock_irq(phba->host->host_lock);
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
index 31c20cc00609..e3bc8d3f7302 100644
--- a/drivers/scsi/lpfc/lpfc_mbox.c
+++ b/drivers/scsi/lpfc/lpfc_mbox.c
@@ -248,8 +248,7 @@ lpfc_read_sparam(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
248 248
249 if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) || 249 if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) ||
250 ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) { 250 ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) {
251 if (mp) 251 kfree(mp);
252 kfree(mp);
253 mb->mbxCommand = MBX_READ_SPARM64; 252 mb->mbxCommand = MBX_READ_SPARM64;
254 /* READ_SPARAM: no buffers */ 253 /* READ_SPARAM: no buffers */
255 lpfc_printf_log(phba, 254 lpfc_printf_log(phba,
@@ -363,9 +362,7 @@ lpfc_reg_login(struct lpfc_hba * phba,
363 /* Get a buffer to hold NPorts Service Parameters */ 362 /* Get a buffer to hold NPorts Service Parameters */
364 if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == NULL) || 363 if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == NULL) ||
365 ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) { 364 ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) {
366 if (mp) 365 kfree(mp);
367 kfree(mp);
368
369 mb->mbxCommand = MBX_REG_LOGIN64; 366 mb->mbxCommand = MBX_REG_LOGIN64;
370 /* REG_LOGIN: no buffers */ 367 /* REG_LOGIN: no buffers */
371 lpfc_printf_log(phba, 368 lpfc_printf_log(phba,
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index c34d3cf4f19c..c63275e66e2e 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -825,8 +825,7 @@ __lpfc_abort_handler(struct scsi_cmnd *cmnd)
825 while (lpfc_cmd->pCmd == cmnd) 825 while (lpfc_cmd->pCmd == cmnd)
826 { 826 {
827 spin_unlock_irq(phba->host->host_lock); 827 spin_unlock_irq(phba->host->host_lock);
828 set_current_state(TASK_UNINTERRUPTIBLE); 828 schedule_timeout_uninterruptible(LPFC_ABORT_WAIT*HZ);
829 schedule_timeout(LPFC_ABORT_WAIT*HZ);
830 spin_lock_irq(phba->host->host_lock); 829 spin_lock_irq(phba->host->host_lock);
831 if (++loop_count 830 if (++loop_count
832 > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT) 831 > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT)
@@ -885,8 +884,7 @@ __lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
885 884
886 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) { 885 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
887 spin_unlock_irq(phba->host->host_lock); 886 spin_unlock_irq(phba->host->host_lock);
888 set_current_state(TASK_UNINTERRUPTIBLE); 887 schedule_timeout_uninterruptible(msecs_to_jiffies(500));
889 schedule_timeout( HZ/2);
890 spin_lock_irq(phba->host->host_lock); 888 spin_lock_irq(phba->host->host_lock);
891 } 889 }
892 if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE)) 890 if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))
@@ -939,8 +937,7 @@ __lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
939 cmnd->device->id, cmnd->device->lun, 937 cmnd->device->id, cmnd->device->lun,
940 LPFC_CTX_LUN))) { 938 LPFC_CTX_LUN))) {
941 spin_unlock_irq(phba->host->host_lock); 939 spin_unlock_irq(phba->host->host_lock);
942 set_current_state(TASK_UNINTERRUPTIBLE); 940 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
943 schedule_timeout(LPFC_RESET_WAIT*HZ);
944 spin_lock_irq(phba->host->host_lock); 941 spin_lock_irq(phba->host->host_lock);
945 942
946 if (++loopcnt 943 if (++loopcnt
@@ -1038,8 +1035,7 @@ __lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
1038 &phba->sli.ring[phba->sli.fcp_ring], 1035 &phba->sli.ring[phba->sli.fcp_ring],
1039 0, 0, LPFC_CTX_HOST))) { 1036 0, 0, LPFC_CTX_HOST))) {
1040 spin_unlock_irq(phba->host->host_lock); 1037 spin_unlock_irq(phba->host->host_lock);
1041 set_current_state(TASK_UNINTERRUPTIBLE); 1038 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
1042 schedule_timeout(LPFC_RESET_WAIT*HZ);
1043 spin_lock_irq(phba->host->host_lock); 1039 spin_lock_irq(phba->host->host_lock);
1044 1040
1045 if (++loopcnt 1041 if (++loopcnt
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 508710001ed6..e2c08c5d83fb 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -2269,11 +2269,8 @@ lpfc_sli_hba_down(struct lpfc_hba * phba)
2269 2269
2270 INIT_LIST_HEAD(&(pring->txq)); 2270 INIT_LIST_HEAD(&(pring->txq));
2271 2271
2272 if (pring->fast_lookup) { 2272 kfree(pring->fast_lookup);
2273 kfree(pring->fast_lookup); 2273 pring->fast_lookup = NULL;
2274 pring->fast_lookup = NULL;
2275 }
2276
2277 } 2274 }
2278 2275
2279 spin_unlock_irqrestore(phba->host->host_lock, flags); 2276 spin_unlock_irqrestore(phba->host->host_lock, flags);
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 670c7a44ab67..4b5d420d2f4d 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -3890,9 +3890,8 @@ megaraid_sysfs_free_resources(adapter_t *adapter)
3890{ 3890{
3891 mraid_device_t *raid_dev = ADAP2RAIDDEV(adapter); 3891 mraid_device_t *raid_dev = ADAP2RAIDDEV(adapter);
3892 3892
3893 if (raid_dev->sysfs_uioc) kfree(raid_dev->sysfs_uioc); 3893 kfree(raid_dev->sysfs_uioc);
3894 3894 kfree(raid_dev->sysfs_mbox64);
3895 if (raid_dev->sysfs_mbox64) kfree(raid_dev->sysfs_mbox64);
3896 3895
3897 if (raid_dev->sysfs_buffer) { 3896 if (raid_dev->sysfs_buffer) {
3898 pci_free_consistent(adapter->pdev, PAGE_SIZE, 3897 pci_free_consistent(adapter->pdev, PAGE_SIZE,
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 37d110e864c4..8f3ce0432295 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -995,17 +995,13 @@ pthru_dma_pool_error:
995 995
996memalloc_error: 996memalloc_error:
997 997
998 if (adapter->kioc_list) 998 kfree(adapter->kioc_list);
999 kfree(adapter->kioc_list); 999 kfree(adapter->mbox_list);
1000
1001 if (adapter->mbox_list)
1002 kfree(adapter->mbox_list);
1003 1000
1004 if (adapter->pthru_dma_pool) 1001 if (adapter->pthru_dma_pool)
1005 pci_pool_destroy(adapter->pthru_dma_pool); 1002 pci_pool_destroy(adapter->pthru_dma_pool);
1006 1003
1007 if (adapter) 1004 kfree(adapter);
1008 kfree(adapter);
1009 1005
1010 return rval; 1006 return rval;
1011} 1007}
@@ -1157,7 +1153,6 @@ mraid_mm_free_adp_resources(mraid_mmadp_t *adp)
1157 } 1153 }
1158 1154
1159 kfree(adp->kioc_list); 1155 kfree(adp->kioc_list);
1160
1161 kfree(adp->mbox_list); 1156 kfree(adp->mbox_list);
1162 1157
1163 pci_pool_destroy(adp->pthru_dma_pool); 1158 pci_pool_destroy(adp->pthru_dma_pool);
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 1cf11c3322fb..d9946bd95492 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -862,8 +862,7 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request *
862 retval = osst_write_error_recovery(STp, aSRpnt, 0); 862 retval = osst_write_error_recovery(STp, aSRpnt, 0);
863 break; 863 break;
864 } 864 }
865 set_current_state(TASK_INTERRUPTIBLE); 865 schedule_timeout_interruptible(HZ / OSST_POLL_PER_SEC);
866 schedule_timeout (HZ / OSST_POLL_PER_SEC);
867 866
868 STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24; 867 STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
869 memset(cmd, 0, MAX_COMMAND_SIZE); 868 memset(cmd, 0, MAX_COMMAND_SIZE);
@@ -1558,8 +1557,7 @@ static int osst_reposition_and_retry(struct osst_tape * STp, struct scsi_request
1558 osst_set_frame_position(STp, aSRpnt, frame + skip, 1); 1557 osst_set_frame_position(STp, aSRpnt, frame + skip, 1);
1559 flag = 0; 1558 flag = 0;
1560 attempts--; 1559 attempts--;
1561 set_current_state(TASK_INTERRUPTIBLE); 1560 schedule_timeout_interruptible(msecs_to_jiffies(100));
1562 schedule_timeout(HZ / 10);
1563 } 1561 }
1564 if (osst_get_frame_position(STp, aSRpnt) < 0) { /* additional write error */ 1562 if (osst_get_frame_position(STp, aSRpnt) < 0) { /* additional write error */
1565#if DEBUG 1563#if DEBUG
@@ -1620,8 +1618,7 @@ static int osst_reposition_and_retry(struct osst_tape * STp, struct scsi_request
1620 debugging = 0; 1618 debugging = 0;
1621 } 1619 }
1622#endif 1620#endif
1623 set_current_state(TASK_INTERRUPTIBLE); 1621 schedule_timeout_interruptible(msecs_to_jiffies(100));
1624 schedule_timeout(HZ / 10);
1625 } 1622 }
1626 printk(KERN_ERR "%s:E: Failed to find valid tape media\n", name); 1623 printk(KERN_ERR "%s:E: Failed to find valid tape media\n", name);
1627#if DEBUG 1624#if DEBUG
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 290a6b92616c..72d9090df3df 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1977,8 +1977,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha)
1977 } 1977 }
1978 1978
1979cleanup_allocation: 1979cleanup_allocation:
1980 if (new_fcport) 1980 kfree(new_fcport);
1981 kfree(new_fcport);
1982 1981
1983 if (rval != QLA_SUCCESS) { 1982 if (rval != QLA_SUCCESS) {
1984 DEBUG2(printk("scsi(%ld): Configure local loop error exit: " 1983 DEBUG2(printk("scsi(%ld): Configure local loop error exit: "
@@ -2348,8 +2347,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2348 /* Allocate temporary fcport for any new fcports discovered. */ 2347 /* Allocate temporary fcport for any new fcports discovered. */
2349 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); 2348 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
2350 if (new_fcport == NULL) { 2349 if (new_fcport == NULL) {
2351 if (swl) 2350 kfree(swl);
2352 kfree(swl);
2353 return (QLA_MEMORY_ALLOC_FAILED); 2351 return (QLA_MEMORY_ALLOC_FAILED);
2354 } 2352 }
2355 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); 2353 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
@@ -2485,19 +2483,15 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2485 nxt_d_id.b24 = new_fcport->d_id.b24; 2483 nxt_d_id.b24 = new_fcport->d_id.b24;
2486 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); 2484 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
2487 if (new_fcport == NULL) { 2485 if (new_fcport == NULL) {
2488 if (swl) 2486 kfree(swl);
2489 kfree(swl);
2490 return (QLA_MEMORY_ALLOC_FAILED); 2487 return (QLA_MEMORY_ALLOC_FAILED);
2491 } 2488 }
2492 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); 2489 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
2493 new_fcport->d_id.b24 = nxt_d_id.b24; 2490 new_fcport->d_id.b24 = nxt_d_id.b24;
2494 } 2491 }
2495 2492
2496 if (swl) 2493 kfree(swl);
2497 kfree(swl); 2494 kfree(new_fcport);
2498
2499 if (new_fcport)
2500 kfree(new_fcport);
2501 2495
2502 if (!list_empty(new_fcports)) 2496 if (!list_empty(new_fcports))
2503 ha->device_flags |= DFLG_FABRIC_DEVICES; 2497 ha->device_flags |= DFLG_FABRIC_DEVICES;
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c
index a9f99c68556f..5b1c12041a4f 100644
--- a/drivers/scsi/raid_class.c
+++ b/drivers/scsi/raid_class.c
@@ -12,6 +12,8 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/slab.h>
16#include <linux/string.h>
15#include <linux/raid_class.h> 17#include <linux/raid_class.h>
16#include <scsi/scsi_device.h> 18#include <scsi/scsi_device.h>
17#include <scsi/scsi_host.h> 19#include <scsi/scsi_host.h>
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 0cc766a9aa65..edabbd05d258 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -26,6 +26,8 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/slab.h>
30#include <linux/string.h>
29 31
30#include <scsi/scsi_device.h> 32#include <scsi/scsi_device.h>
31#include <scsi/scsi_host.h> 33#include <scsi/scsi_host.h>
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 4f30a37db63c..62e3f340cc52 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -476,8 +476,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
476 sg_finish_rem_req(srp); 476 sg_finish_rem_req(srp);
477 retval = count; 477 retval = count;
478free_old_hdr: 478free_old_hdr:
479 if (old_hdr) 479 kfree(old_hdr);
480 kfree(old_hdr);
481 return retval; 480 return retval;
482} 481}
483 482
@@ -1703,10 +1702,8 @@ exit_sg(void)
1703 sg_sysfs_valid = 0; 1702 sg_sysfs_valid = 0;
1704 unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), 1703 unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0),
1705 SG_MAX_DEVS); 1704 SG_MAX_DEVS);
1706 if (sg_dev_arr != NULL) { 1705 kfree((char *)sg_dev_arr);
1707 kfree((char *) sg_dev_arr); 1706 sg_dev_arr = NULL;
1708 sg_dev_arr = NULL;
1709 }
1710 sg_dev_max = 0; 1707 sg_dev_max = 0;
1711} 1708}
1712 1709
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 6b85f84c8397..770c4324f3d5 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4107,8 +4107,7 @@ out_free_tape:
4107 write_unlock(&st_dev_arr_lock); 4107 write_unlock(&st_dev_arr_lock);
4108out_put_disk: 4108out_put_disk:
4109 put_disk(disk); 4109 put_disk(disk);
4110 if (tpnt) 4110 kfree(tpnt);
4111 kfree(tpnt);
4112out_buffer_free: 4111out_buffer_free:
4113 kfree(buffer); 4112 kfree(buffer);
4114out: 4113out:
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index a1a58e1d5ad3..a7420cad4547 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -39,6 +39,7 @@
39 */ 39 */
40 40
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <asm/param.h> /* for timeouts in units of HZ */
42 43
43#include "sym_glue.h" 44#include "sym_glue.h"
44#include "sym_nvram.h" 45#include "sym_nvram.h"
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
index cfab8f197084..1ce29ba683eb 100644
--- a/drivers/scsi/u14-34f.c
+++ b/drivers/scsi/u14-34f.c
@@ -1953,11 +1953,11 @@ static int u14_34f_release(struct Scsi_Host *shpnt) {
1953 1953
1954 for (j = 0; sh[j] != NULL && sh[j] != shpnt; j++); 1954 for (j = 0; sh[j] != NULL && sh[j] != shpnt; j++);
1955 1955
1956 if (sh[j] == NULL) panic("%s: release, invalid Scsi_Host pointer.\n", 1956 if (sh[j] == NULL)
1957 driver_name); 1957 panic("%s: release, invalid Scsi_Host pointer.\n", driver_name);
1958 1958
1959 for (i = 0; i < sh[j]->can_queue; i++) 1959 for (i = 0; i < sh[j]->can_queue; i++)
1960 if ((&HD(j)->cp[i])->sglist) kfree((&HD(j)->cp[i])->sglist); 1960 kfree((&HD(j)->cp[i])->sglist);
1961 1961
1962 for (i = 0; i < sh[j]->can_queue; i++) 1962 for (i = 0; i < sh[j]->can_queue; i++)
1963 pci_unmap_single(HD(j)->pdev, HD(j)->cp[i].cp_dma_addr, 1963 pci_unmap_single(HD(j)->pdev, HD(j)->cp[i].cp_dma_addr,
@@ -1965,7 +1965,8 @@ static int u14_34f_release(struct Scsi_Host *shpnt) {
1965 1965
1966 free_irq(sh[j]->irq, &sha[j]); 1966 free_irq(sh[j]->irq, &sha[j]);
1967 1967
1968 if (sh[j]->dma_channel != NO_DMA) free_dma(sh[j]->dma_channel); 1968 if (sh[j]->dma_channel != NO_DMA)
1969 free_dma(sh[j]->dma_channel);
1969 1970
1970 release_region(sh[j]->io_port, sh[j]->n_io_port); 1971 release_region(sh[j]->io_port, sh[j]->n_io_port);
1971 scsi_unregister(sh[j]); 1972 scsi_unregister(sh[j]);
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index f47d2c454e33..98820603e75f 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -40,6 +40,7 @@
40#include <linux/serial_core.h> 40#include <linux/serial_core.h>
41#include <linux/serial.h> 41#include <linux/serial.h>
42#include <linux/serial_8250.h> 42#include <linux/serial_8250.h>
43#include <linux/nmi.h>
43 44
44#include <asm/io.h> 45#include <asm/io.h>
45#include <asm/irq.h> 46#include <asm/irq.h>
@@ -251,9 +252,53 @@ static const struct serial8250_config uart_config[] = {
251 }, 252 },
252}; 253};
253 254
255#ifdef CONFIG_SERIAL_8250_AU1X00
256
257/* Au1x00 UART hardware has a weird register layout */
258static const u8 au_io_in_map[] = {
259 [UART_RX] = 0,
260 [UART_IER] = 2,
261 [UART_IIR] = 3,
262 [UART_LCR] = 5,
263 [UART_MCR] = 6,
264 [UART_LSR] = 7,
265 [UART_MSR] = 8,
266};
267
268static const u8 au_io_out_map[] = {
269 [UART_TX] = 1,
270 [UART_IER] = 2,
271 [UART_FCR] = 4,
272 [UART_LCR] = 5,
273 [UART_MCR] = 6,
274};
275
276/* sane hardware needs no mapping */
277static inline int map_8250_in_reg(struct uart_8250_port *up, int offset)
278{
279 if (up->port.iotype != UPIO_AU)
280 return offset;
281 return au_io_in_map[offset];
282}
283
284static inline int map_8250_out_reg(struct uart_8250_port *up, int offset)
285{
286 if (up->port.iotype != UPIO_AU)
287 return offset;
288 return au_io_out_map[offset];
289}
290
291#else
292
293/* sane hardware needs no mapping */
294#define map_8250_in_reg(up, offset) (offset)
295#define map_8250_out_reg(up, offset) (offset)
296
297#endif
298
254static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset) 299static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset)
255{ 300{
256 offset <<= up->port.regshift; 301 offset = map_8250_in_reg(up, offset) << up->port.regshift;
257 302
258 switch (up->port.iotype) { 303 switch (up->port.iotype) {
259 case UPIO_HUB6: 304 case UPIO_HUB6:
@@ -266,6 +311,11 @@ static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset)
266 case UPIO_MEM32: 311 case UPIO_MEM32:
267 return readl(up->port.membase + offset); 312 return readl(up->port.membase + offset);
268 313
314#ifdef CONFIG_SERIAL_8250_AU1X00
315 case UPIO_AU:
316 return __raw_readl(up->port.membase + offset);
317#endif
318
269 default: 319 default:
270 return inb(up->port.iobase + offset); 320 return inb(up->port.iobase + offset);
271 } 321 }
@@ -274,7 +324,7 @@ static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset)
274static _INLINE_ void 324static _INLINE_ void
275serial_out(struct uart_8250_port *up, int offset, int value) 325serial_out(struct uart_8250_port *up, int offset, int value)
276{ 326{
277 offset <<= up->port.regshift; 327 offset = map_8250_out_reg(up, offset) << up->port.regshift;
278 328
279 switch (up->port.iotype) { 329 switch (up->port.iotype) {
280 case UPIO_HUB6: 330 case UPIO_HUB6:
@@ -290,6 +340,12 @@ serial_out(struct uart_8250_port *up, int offset, int value)
290 writel(value, up->port.membase + offset); 340 writel(value, up->port.membase + offset);
291 break; 341 break;
292 342
343#ifdef CONFIG_SERIAL_8250_AU1X00
344 case UPIO_AU:
345 __raw_writel(value, up->port.membase + offset);
346 break;
347#endif
348
293 default: 349 default:
294 outb(value, up->port.iobase + offset); 350 outb(value, up->port.iobase + offset);
295 } 351 }
@@ -910,6 +966,13 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
910 } 966 }
911 } 967 }
912#endif 968#endif
969
970#ifdef CONFIG_SERIAL_8250_AU1X00
971 /* if access method is AU, it is a 16550 with a quirk */
972 if (up->port.type == PORT_16550A && up->port.iotype == UPIO_AU)
973 up->bugs |= UART_BUG_NOMSR;
974#endif
975
913 serial_outp(up, UART_LCR, save_lcr); 976 serial_outp(up, UART_LCR, save_lcr);
914 977
915 if (up->capabilities != uart_config[up->port.type].flags) { 978 if (up->capabilities != uart_config[up->port.type].flags) {
@@ -1057,6 +1120,10 @@ static void serial8250_enable_ms(struct uart_port *port)
1057{ 1120{
1058 struct uart_8250_port *up = (struct uart_8250_port *)port; 1121 struct uart_8250_port *up = (struct uart_8250_port *)port;
1059 1122
1123 /* no MSR capabilities */
1124 if (up->bugs & UART_BUG_NOMSR)
1125 return;
1126
1060 up->ier |= UART_IER_MSI; 1127 up->ier |= UART_IER_MSI;
1061 serial_out(up, UART_IER, up->ier); 1128 serial_out(up, UART_IER, up->ier);
1062} 1129}
@@ -1774,7 +1841,8 @@ serial8250_set_termios(struct uart_port *port, struct termios *termios,
1774 * CTS flow control flag and modem status interrupts 1841 * CTS flow control flag and modem status interrupts
1775 */ 1842 */
1776 up->ier &= ~UART_IER_MSI; 1843 up->ier &= ~UART_IER_MSI;
1777 if (UART_ENABLE_MS(&up->port, termios->c_cflag)) 1844 if (!(up->bugs & UART_BUG_NOMSR) &&
1845 UART_ENABLE_MS(&up->port, termios->c_cflag))
1778 up->ier |= UART_IER_MSI; 1846 up->ier |= UART_IER_MSI;
1779 if (up->capabilities & UART_CAP_UUE) 1847 if (up->capabilities & UART_CAP_UUE)
1780 up->ier |= UART_IER_UUE | UART_IER_RTOIE; 1848 up->ier |= UART_IER_UUE | UART_IER_RTOIE;
@@ -2141,6 +2209,8 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2141 unsigned int ier; 2209 unsigned int ier;
2142 int i; 2210 int i;
2143 2211
2212 touch_nmi_watchdog();
2213
2144 /* 2214 /*
2145 * First save the UER then disable the interrupts 2215 * First save the UER then disable the interrupts
2146 */ 2216 */
diff --git a/drivers/serial/8250.h b/drivers/serial/8250.h
index b1b459efda52..a607b98016db 100644
--- a/drivers/serial/8250.h
+++ b/drivers/serial/8250.h
@@ -49,6 +49,7 @@ struct serial8250_config {
49 49
50#define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */ 50#define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
51#define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ 51#define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
52#define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */
52 53
53#if defined(__i386__) && (defined(CONFIG_M386) || defined(CONFIG_M486)) 54#if defined(__i386__) && (defined(CONFIG_M386) || defined(CONFIG_M486))
54#define _INLINE_ inline 55#define _INLINE_ inline
diff --git a/drivers/serial/8250_au1x00.c b/drivers/serial/8250_au1x00.c
new file mode 100644
index 000000000000..06ae8fbcc947
--- /dev/null
+++ b/drivers/serial/8250_au1x00.c
@@ -0,0 +1,102 @@
1/*
2 * Serial Device Initialisation for Au1x00
3 *
4 * (C) Copyright Embedded Alley Solutions, Inc 2005
5 * Author: Pantelis Antoniou <pantelis@embeddedalley.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#include <linux/errno.h>
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <linux/ioport.h>
17#include <linux/module.h>
18#include <linux/serial_core.h>
19#include <linux/signal.h>
20#include <linux/slab.h>
21#include <linux/types.h>
22
23#include <linux/serial_8250.h>
24
25#include <asm/mach-au1x00/au1000.h>
26
27#include "8250.h"
28
29#define PORT(_base, _irq) \
30 { \
31 .iobase = _base, \
32 .membase = (void __iomem *)_base,\
33 .mapbase = _base, \
34 .irq = _irq, \
35 .uartclk = 0, /* filled */ \
36 .regshift = 2, \
37 .iotype = UPIO_AU, \
38 .flags = UPF_SKIP_TEST | \
39 UPF_IOREMAP, \
40 }
41
42static struct plat_serial8250_port au1x00_data[] = {
43#if defined(CONFIG_SOC_AU1000)
44 PORT(UART0_ADDR, AU1000_UART0_INT),
45 PORT(UART1_ADDR, AU1000_UART1_INT),
46 PORT(UART2_ADDR, AU1000_UART2_INT),
47 PORT(UART3_ADDR, AU1000_UART3_INT),
48#elif defined(CONFIG_SOC_AU1500)
49 PORT(UART0_ADDR, AU1500_UART0_INT),
50 PORT(UART3_ADDR, AU1500_UART3_INT),
51#elif defined(CONFIG_SOC_AU1100)
52 PORT(UART0_ADDR, AU1100_UART0_INT),
53 PORT(UART1_ADDR, AU1100_UART1_INT),
54 PORT(UART2_ADDR, AU1100_UART2_INT),
55 PORT(UART3_ADDR, AU1100_UART3_INT),
56#elif defined(CONFIG_SOC_AU1550)
57 PORT(UART0_ADDR, AU1550_UART0_INT),
58 PORT(UART1_ADDR, AU1550_UART1_INT),
59 PORT(UART2_ADDR, AU1550_UART2_INT),
60 PORT(UART3_ADDR, AU1550_UART3_INT),
61#elif defined(CONFIG_SOC_AU1200)
62 PORT(UART0_ADDR, AU1200_UART0_INT),
63 PORT(UART1_ADDR, AU1200_UART1_INT),
64#endif
65 { },
66};
67
68static struct platform_device au1x00_device = {
69 .name = "serial8250",
70 .id = PLAT8250_DEV_AU1X00,
71 .dev = {
72 .platform_data = au1x00_data,
73 },
74};
75
76static int __init au1x00_init(void)
77{
78 int i;
79 unsigned int uartclk;
80
81 /* get uart clock */
82 uartclk = get_au1x00_uart_baud_base() * 16;
83
84 /* fill up uartclk */
85 for (i = 0; au1x00_data[i].flags ; i++)
86 au1x00_data[i].uartclk = uartclk;
87
88 return platform_device_register(&au1x00_device);
89}
90
91/* XXX: Yes, I know this doesn't yet work. */
92static void __exit au1x00_exit(void)
93{
94 platform_device_unregister(&au1x00_device);
95}
96
97module_init(au1x00_init);
98module_exit(au1x00_exit);
99
100MODULE_AUTHOR("Pantelis Antoniou <pantelis@embeddedalley.com>");
101MODULE_DESCRIPTION("8250 serial probe module for Au1x000 cards");
102MODULE_LICENSE("GPL");
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b745a1b9e835..ff36f0c9fdad 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -207,6 +207,14 @@ config SERIAL_8250_ACORN
207 system, say Y to this option. The driver can handle 1, 2, or 3 port 207 system, say Y to this option. The driver can handle 1, 2, or 3 port
208 cards. If unsure, say N. 208 cards. If unsure, say N.
209 209
210config SERIAL_8250_AU1X00
211 bool "AU1X00 serial port support"
212 depends on SERIAL_8250 != n && SOC_AU1X00
213 help
214 If you have an Au1x00 board and want to use the serial port, say Y
215 to this option. The driver can handle 1 or 2 serial ports.
216 If unsure, say N.
217
210comment "Non-8250 serial port support" 218comment "Non-8250 serial port support"
211 219
212config SERIAL_AMBA_PL010 220config SERIAL_AMBA_PL010
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 11c7dc483f93..d7c7c7180e33 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
22obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o 22obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
23obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o 23obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
24obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o 24obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
25obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o
25obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o 26obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
26obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o 27obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
27obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o 28obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 40d3e7139cfe..08c42c000188 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -4416,10 +4416,8 @@ rs_close(struct tty_struct *tty, struct file * filp)
4416 info->event = 0; 4416 info->event = 0;
4417 info->tty = 0; 4417 info->tty = 0;
4418 if (info->blocked_open) { 4418 if (info->blocked_open) {
4419 if (info->close_delay) { 4419 if (info->close_delay)
4420 set_current_state(TASK_INTERRUPTIBLE); 4420 schedule_timeout_interruptible(info->close_delay);
4421 schedule_timeout(info->close_delay);
4422 }
4423 wake_up_interruptible(&info->open_wait); 4421 wake_up_interruptible(&info->open_wait);
4424 } 4422 }
4425 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 4423 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -4469,8 +4467,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
4469 while (info->xmit.head != info->xmit.tail || /* More in send queue */ 4467 while (info->xmit.head != info->xmit.tail || /* More in send queue */
4470 (*info->ostatusadr & 0x007f) || /* more in FIFO */ 4468 (*info->ostatusadr & 0x007f) || /* more in FIFO */
4471 (elapsed_usec < 2*info->char_time_usec)) { 4469 (elapsed_usec < 2*info->char_time_usec)) {
4472 set_current_state(TASK_INTERRUPTIBLE); 4470 schedule_timeout_interruptible(1);
4473 schedule_timeout(1);
4474 if (signal_pending(current)) 4471 if (signal_pending(current))
4475 break; 4472 break;
4476 if (timeout && time_after(jiffies, orig_jiffies + timeout)) 4473 if (timeout && time_after(jiffies, orig_jiffies + timeout))
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index e2ebdcad553c..47f7404cb045 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -57,7 +57,8 @@ struct timer_list mcfrs_timer_struct;
57 * keep going. Perhaps one day the cflag settings for the 57 * keep going. Perhaps one day the cflag settings for the
58 * console can be used instead. 58 * console can be used instead.
59 */ 59 */
60#if defined(CONFIG_ARNEWSH) || defined(CONFIG_MOTOROLA) || defined(CONFIG_senTec) || defined(CONFIG_SNEHA) 60#if defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \
61 defined(CONFIG_senTec) || defined(CONFIG_SNEHA)
61#define CONSOLE_BAUD_RATE 19200 62#define CONSOLE_BAUD_RATE 19200
62#define DEFAULT_CBAUD B19200 63#define DEFAULT_CBAUD B19200
63#endif 64#endif
@@ -67,7 +68,7 @@ struct timer_list mcfrs_timer_struct;
67#define DEFAULT_CBAUD B38400 68#define DEFAULT_CBAUD B38400
68#endif 69#endif
69 70
70#if defined(CONFIG_MOD5272) 71#if defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB)
71#define CONSOLE_BAUD_RATE 115200 72#define CONSOLE_BAUD_RATE 115200
72#define DEFAULT_CBAUD B115200 73#define DEFAULT_CBAUD B115200
73#endif 74#endif
@@ -95,7 +96,8 @@ static struct tty_driver *mcfrs_serial_driver;
95#undef SERIAL_DEBUG_OPEN 96#undef SERIAL_DEBUG_OPEN
96#undef SERIAL_DEBUG_FLOW 97#undef SERIAL_DEBUG_FLOW
97 98
98#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) 99#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
100 defined(CONFIG_M520x)
99#define IRQBASE (MCFINT_VECBASE+MCFINT_UART0) 101#define IRQBASE (MCFINT_VECBASE+MCFINT_UART0)
100#else 102#else
101#define IRQBASE 73 103#define IRQBASE 73
@@ -1528,6 +1530,35 @@ static void mcfrs_irqinit(struct mcf_serial *info)
1528 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 + 1530 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 +
1529 MCFINTC_IMRL); 1531 MCFINTC_IMRL);
1530 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1); 1532 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1);
1533#elif defined(CONFIG_M520x)
1534 volatile unsigned char *icrp, *uartp;
1535 volatile unsigned long *imrp;
1536
1537 uartp = info->addr;
1538
1539 icrp = (volatile unsigned char *) (MCF_MBAR + MCFICM_INTC0 +
1540 MCFINTC_ICR0 + MCFINT_UART0 + info->line);
1541 *icrp = 0x03;
1542
1543 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 +
1544 MCFINTC_IMRL);
1545 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1);
1546 if (info->line < 2) {
1547 unsigned short *uart_par;
1548 uart_par = (unsigned short *)(MCF_IPSBAR + MCF_GPIO_PAR_UART);
1549 if (info->line == 0)
1550 *uart_par |= MCF_GPIO_PAR_UART_PAR_UTXD0
1551 | MCF_GPIO_PAR_UART_PAR_URXD0;
1552 else if (info->line == 1)
1553 *uart_par |= MCF_GPIO_PAR_UART_PAR_UTXD1
1554 | MCF_GPIO_PAR_UART_PAR_URXD1;
1555 } else if (info->line == 2) {
1556 unsigned char *feci2c_par;
1557 feci2c_par = (unsigned char *)(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
1558 *feci2c_par &= ~0x0F;
1559 *feci2c_par |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2
1560 | MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
1561 }
1531#else 1562#else
1532 volatile unsigned char *icrp, *uartp; 1563 volatile unsigned char *icrp, *uartp;
1533 1564
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 0745ce782974..427a23858076 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1959,6 +1959,7 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port)
1959 break; 1959 break;
1960 case UPIO_MEM: 1960 case UPIO_MEM:
1961 case UPIO_MEM32: 1961 case UPIO_MEM32:
1962 case UPIO_AU:
1962 snprintf(address, sizeof(address), 1963 snprintf(address, sizeof(address),
1963 "MMIO 0x%lx", port->mapbase); 1964 "MMIO 0x%lx", port->mapbase);
1964 break; 1965 break;
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 656c0e8d160e..f0738533f39a 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1441,7 +1441,7 @@ static void sunsu_console_write(struct console *co, const char *s,
1441 * - initialize the serial port 1441 * - initialize the serial port
1442 * Return non-zero if we didn't find a serial port. 1442 * Return non-zero if we didn't find a serial port.
1443 */ 1443 */
1444static int __init sunsu_console_setup(struct console *co, char *options) 1444static int sunsu_console_setup(struct console *co, char *options)
1445{ 1445{
1446 struct uart_port *port; 1446 struct uart_port *port;
1447 int baud = 9600; 1447 int baud = 9600;
diff --git a/drivers/sh/superhyway/superhyway-sysfs.c b/drivers/sh/superhyway/superhyway-sysfs.c
index dc119ce68e3e..55434330867b 100644
--- a/drivers/sh/superhyway/superhyway-sysfs.c
+++ b/drivers/sh/superhyway/superhyway-sysfs.c
@@ -30,7 +30,7 @@ superhyway_ro_attr(bot_mb, "0x%02x\n", vcr.bot_mb);
30superhyway_ro_attr(top_mb, "0x%02x\n", vcr.top_mb); 30superhyway_ro_attr(top_mb, "0x%02x\n", vcr.top_mb);
31 31
32/* Misc */ 32/* Misc */
33superhyway_ro_attr(resource, "0x%08lx\n", resource.start); 33superhyway_ro_attr(resource, "0x%08lx\n", resource[0].start);
34 34
35struct device_attribute superhyway_dev_attrs[] = { 35struct device_attribute superhyway_dev_attrs[] = {
36 __ATTR_RO(perr_flags), 36 __ATTR_RO(perr_flags),
diff --git a/drivers/sh/superhyway/superhyway.c b/drivers/sh/superhyway/superhyway.c
index 28757cb9d246..7bdab2a7f59c 100644
--- a/drivers/sh/superhyway/superhyway.c
+++ b/drivers/sh/superhyway/superhyway.c
@@ -27,19 +27,20 @@ static struct device superhyway_bus_device = {
27 27
28static void superhyway_device_release(struct device *dev) 28static void superhyway_device_release(struct device *dev)
29{ 29{
30 kfree(to_superhyway_device(dev)); 30 struct superhyway_device *sdev = to_superhyway_device(dev);
31
32 kfree(sdev->resource);
33 kfree(sdev);
31} 34}
32 35
33/** 36/**
34 * superhyway_add_device - Add a SuperHyway module 37 * superhyway_add_device - Add a SuperHyway module
35 * @mod_id: Module ID (taken from MODULE.VCR.MOD_ID).
36 * @base: Physical address where module is mapped. 38 * @base: Physical address where module is mapped.
37 * @vcr: VCR value. 39 * @sdev: SuperHyway device to add, or NULL to allocate a new one.
40 * @bus: Bus where SuperHyway module resides.
38 * 41 *
39 * This is responsible for adding a new SuperHyway module. This sets up a new 42 * This is responsible for adding a new SuperHyway module. This sets up a new
40 * struct superhyway_device for the module being added. Each one of @mod_id, 43 * struct superhyway_device for the module being added if @sdev == NULL.
41 * @base, and @vcr are registered with the new device for further use
42 * elsewhere.
43 * 44 *
44 * Devices are initially added in the order that they are scanned (from the 45 * Devices are initially added in the order that they are scanned (from the
45 * top-down of the memory map), and are assigned an ID based on the order that 46 * top-down of the memory map), and are assigned an ID based on the order that
@@ -49,28 +50,40 @@ static void superhyway_device_release(struct device *dev)
49 * Further work can and should be done in superhyway_scan_bus(), to be sure 50 * Further work can and should be done in superhyway_scan_bus(), to be sure
50 * that any new modules are properly discovered and subsequently registered. 51 * that any new modules are properly discovered and subsequently registered.
51 */ 52 */
52int superhyway_add_device(unsigned int mod_id, unsigned long base, 53int superhyway_add_device(unsigned long base, struct superhyway_device *sdev,
53 unsigned long long vcr) 54 struct superhyway_bus *bus)
54{ 55{
55 struct superhyway_device *dev; 56 struct superhyway_device *dev = sdev;
57
58 if (!dev) {
59 dev = kmalloc(sizeof(struct superhyway_device), GFP_KERNEL);
60 if (!dev)
61 return -ENOMEM;
56 62
57 dev = kmalloc(sizeof(struct superhyway_device), GFP_KERNEL); 63 memset(dev, 0, sizeof(struct superhyway_device));
58 if (!dev) 64 }
59 return -ENOMEM;
60 65
61 memset(dev, 0, sizeof(struct superhyway_device)); 66 dev->bus = bus;
67 superhyway_read_vcr(dev, base, &dev->vcr);
62 68
63 dev->id.id = mod_id; 69 if (!dev->resource) {
64 sprintf(dev->name, "SuperHyway device %04x", dev->id.id); 70 dev->resource = kmalloc(sizeof(struct resource), GFP_KERNEL);
71 if (!dev->resource) {
72 kfree(dev);
73 return -ENOMEM;
74 }
75
76 dev->resource->name = dev->name;
77 dev->resource->start = base;
78 dev->resource->end = dev->resource->start + 0x01000000;
79 }
65 80
66 dev->vcr = *((struct vcr_info *)(&vcr));
67 dev->resource.name = dev->name;
68 dev->resource.start = base;
69 dev->resource.end = dev->resource.start + 0x01000000;
70 dev->dev.parent = &superhyway_bus_device; 81 dev->dev.parent = &superhyway_bus_device;
71 dev->dev.bus = &superhyway_bus_type; 82 dev->dev.bus = &superhyway_bus_type;
72 dev->dev.release = superhyway_device_release; 83 dev->dev.release = superhyway_device_release;
84 dev->id.id = dev->vcr.mod_id;
73 85
86 sprintf(dev->name, "SuperHyway device %04x", dev->id.id);
74 sprintf(dev->dev.bus_id, "%02x", superhyway_devices); 87 sprintf(dev->dev.bus_id, "%02x", superhyway_devices);
75 88
76 superhyway_devices++; 89 superhyway_devices++;
@@ -78,10 +91,31 @@ int superhyway_add_device(unsigned int mod_id, unsigned long base,
78 return device_register(&dev->dev); 91 return device_register(&dev->dev);
79} 92}
80 93
94int superhyway_add_devices(struct superhyway_bus *bus,
95 struct superhyway_device **devices,
96 int nr_devices)
97{
98 int i, ret = 0;
99
100 for (i = 0; i < nr_devices; i++) {
101 struct superhyway_device *dev = devices[i];
102 ret |= superhyway_add_device(dev->resource[0].start, dev, bus);
103 }
104
105 return ret;
106}
107
81static int __init superhyway_init(void) 108static int __init superhyway_init(void)
82{ 109{
110 struct superhyway_bus *bus;
111 int ret = 0;
112
83 device_register(&superhyway_bus_device); 113 device_register(&superhyway_bus_device);
84 return superhyway_scan_bus(); 114
115 for (bus = superhyway_channels; bus->ops; bus++)
116 ret |= superhyway_scan_bus(bus);
117
118 return ret;
85} 119}
86 120
87postcore_initcall(superhyway_init); 121postcore_initcall(superhyway_init);
@@ -197,6 +231,7 @@ module_exit(superhyway_bus_exit);
197 231
198EXPORT_SYMBOL(superhyway_bus_type); 232EXPORT_SYMBOL(superhyway_bus_type);
199EXPORT_SYMBOL(superhyway_add_device); 233EXPORT_SYMBOL(superhyway_add_device);
234EXPORT_SYMBOL(superhyway_add_devices);
200EXPORT_SYMBOL(superhyway_register_driver); 235EXPORT_SYMBOL(superhyway_register_driver);
201EXPORT_SYMBOL(superhyway_unregister_driver); 236EXPORT_SYMBOL(superhyway_unregister_driver);
202 237
diff --git a/drivers/tc/.gitignore b/drivers/tc/.gitignore
new file mode 100644
index 000000000000..acc0e1e6a650
--- /dev/null
+++ b/drivers/tc/.gitignore
@@ -0,0 +1 @@
lk201-map.c
diff --git a/drivers/video/68328fb.c b/drivers/video/68328fb.c
index 6a3cfbdc6dc9..3b0ddc55236b 100644
--- a/drivers/video/68328fb.c
+++ b/drivers/video/68328fb.c
@@ -113,7 +113,6 @@ static struct fb_ops mc68x328fb_ops = {
113 .fb_fillrect = cfb_fillrect, 113 .fb_fillrect = cfb_fillrect,
114 .fb_copyarea = cfb_copyarea, 114 .fb_copyarea = cfb_copyarea,
115 .fb_imageblit = cfb_imageblit, 115 .fb_imageblit = cfb_imageblit,
116 .fb_cursor = soft_cursor,
117 .fb_mmap = mc68x328fb_mmap, 116 .fb_mmap = mc68x328fb_mmap,
118}; 117};
119 118
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 7192b770bfb6..44b6ca290ce3 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -65,15 +65,6 @@ config FB_CFB_IMAGEBLIT
65 blitting. This is used by drivers that don't provide their own 65 blitting. This is used by drivers that don't provide their own
66 (accelerated) version. 66 (accelerated) version.
67 67
68config FB_SOFT_CURSOR
69 tristate
70 depends on FB
71 default n
72 ---help---
73 Include the soft_cursor function for generic software cursor support.
74 This is used by drivers that don't provide their own (accelerated)
75 version.
76
77config FB_MACMODES 68config FB_MACMODES
78 tristate 69 tristate
79 depends on FB 70 depends on FB
@@ -114,7 +105,6 @@ config FB_CIRRUS
114 select FB_CFB_FILLRECT 105 select FB_CFB_FILLRECT
115 select FB_CFB_COPYAREA 106 select FB_CFB_COPYAREA
116 select FB_CFB_IMAGEBLIT 107 select FB_CFB_IMAGEBLIT
117 select FB_SOFT_CURSOR
118 ---help--- 108 ---help---
119 This enables support for Cirrus Logic GD542x/543x based boards on 109 This enables support for Cirrus Logic GD542x/543x based boards on
120 Amiga: SD64, Piccolo, Picasso II/II+, Picasso IV, or EGS Spectrum. 110 Amiga: SD64, Piccolo, Picasso II/II+, Picasso IV, or EGS Spectrum.
@@ -133,7 +123,6 @@ config FB_PM2
133 select FB_CFB_FILLRECT 123 select FB_CFB_FILLRECT
134 select FB_CFB_COPYAREA 124 select FB_CFB_COPYAREA
135 select FB_CFB_IMAGEBLIT 125 select FB_CFB_IMAGEBLIT
136 select FB_SOFT_CURSOR
137 help 126 help
138 This is the frame buffer device driver for the Permedia2 AGP frame 127 This is the frame buffer device driver for the Permedia2 AGP frame
139 buffer card from ASK, aka `Graphic Blaster Exxtreme'. There is a 128 buffer card from ASK, aka `Graphic Blaster Exxtreme'. There is a
@@ -152,7 +141,6 @@ config FB_ARMCLCD
152 select FB_CFB_FILLRECT 141 select FB_CFB_FILLRECT
153 select FB_CFB_COPYAREA 142 select FB_CFB_COPYAREA
154 select FB_CFB_IMAGEBLIT 143 select FB_CFB_IMAGEBLIT
155 select FB_SOFT_CURSOR
156 help 144 help
157 This framebuffer device driver is for the ARM PrimeCell PL110 145 This framebuffer device driver is for the ARM PrimeCell PL110
158 Colour LCD controller. ARM PrimeCells provide the building 146 Colour LCD controller. ARM PrimeCells provide the building
@@ -169,7 +157,6 @@ config FB_ACORN
169 select FB_CFB_FILLRECT 157 select FB_CFB_FILLRECT
170 select FB_CFB_COPYAREA 158 select FB_CFB_COPYAREA
171 select FB_CFB_IMAGEBLIT 159 select FB_CFB_IMAGEBLIT
172 select FB_SOFT_CURSOR
173 help 160 help
174 This is the frame buffer device driver for the Acorn VIDC graphics 161 This is the frame buffer device driver for the Acorn VIDC graphics
175 hardware found in Acorn RISC PCs and other ARM-based machines. If 162 hardware found in Acorn RISC PCs and other ARM-based machines. If
@@ -181,7 +168,9 @@ config FB_CLPS711X
181 select FB_CFB_FILLRECT 168 select FB_CFB_FILLRECT
182 select FB_CFB_COPYAREA 169 select FB_CFB_COPYAREA
183 select FB_CFB_IMAGEBLIT 170 select FB_CFB_IMAGEBLIT
184 select FB_SOFT_CURSOR 171 help
172 Say Y to enable the Framebuffer driver for the CLPS7111 and
173 EP7212 processors.
185 174
186config FB_SA1100 175config FB_SA1100
187 bool "SA-1100 LCD support" 176 bool "SA-1100 LCD support"
@@ -189,7 +178,6 @@ config FB_SA1100
189 select FB_CFB_FILLRECT 178 select FB_CFB_FILLRECT
190 select FB_CFB_COPYAREA 179 select FB_CFB_COPYAREA
191 select FB_CFB_IMAGEBLIT 180 select FB_CFB_IMAGEBLIT
192 select FB_SOFT_CURSOR
193 help 181 help
194 This is a framebuffer device for the SA-1100 LCD Controller. 182 This is a framebuffer device for the SA-1100 LCD Controller.
195 See <http://www.linux-fbdev.org/> for information on framebuffer 183 See <http://www.linux-fbdev.org/> for information on framebuffer
@@ -204,7 +192,6 @@ config FB_IMX
204 select FB_CFB_FILLRECT 192 select FB_CFB_FILLRECT
205 select FB_CFB_COPYAREA 193 select FB_CFB_COPYAREA
206 select FB_CFB_IMAGEBLIT 194 select FB_CFB_IMAGEBLIT
207 select FB_SOFT_CURSOR
208 195
209config FB_CYBER2000 196config FB_CYBER2000
210 tristate "CyberPro 2000/2010/5000 support" 197 tristate "CyberPro 2000/2010/5000 support"
@@ -212,7 +199,6 @@ config FB_CYBER2000
212 select FB_CFB_FILLRECT 199 select FB_CFB_FILLRECT
213 select FB_CFB_COPYAREA 200 select FB_CFB_COPYAREA
214 select FB_CFB_IMAGEBLIT 201 select FB_CFB_IMAGEBLIT
215 select FB_SOFT_CURSOR
216 help 202 help
217 This enables support for the Integraphics CyberPro 20x0 and 5000 203 This enables support for the Integraphics CyberPro 20x0 and 5000
218 VGA chips used in the Rebel.com Netwinder and other machines. 204 VGA chips used in the Rebel.com Netwinder and other machines.
@@ -225,7 +211,6 @@ config FB_APOLLO
225 default y 211 default y
226 select FB_CFB_FILLRECT 212 select FB_CFB_FILLRECT
227 select FB_CFB_IMAGEBLIT 213 select FB_CFB_IMAGEBLIT
228 select FB_SOFT_CURSOR
229 214
230config FB_Q40 215config FB_Q40
231 bool 216 bool
@@ -234,12 +219,10 @@ config FB_Q40
234 select FB_CFB_FILLRECT 219 select FB_CFB_FILLRECT
235 select FB_CFB_COPYAREA 220 select FB_CFB_COPYAREA
236 select FB_CFB_IMAGEBLIT 221 select FB_CFB_IMAGEBLIT
237 select FB_SOFT_CURSOR
238 222
239config FB_AMIGA 223config FB_AMIGA
240 tristate "Amiga native chipset support" 224 tristate "Amiga native chipset support"
241 depends on FB && AMIGA 225 depends on FB && AMIGA
242 select FB_SOFT_CURSOR
243 help 226 help
244 This is the frame buffer device driver for the builtin graphics 227 This is the frame buffer device driver for the builtin graphics
245 chipset found in Amigas. 228 chipset found in Amigas.
@@ -279,7 +262,6 @@ config FB_CYBER
279 select FB_CFB_FILLRECT 262 select FB_CFB_FILLRECT
280 select FB_CFB_COPYAREA 263 select FB_CFB_COPYAREA
281 select FB_CFB_IMAGEBLIT 264 select FB_CFB_IMAGEBLIT
282 select FB_SOFT_CURSOR
283 help 265 help
284 This enables support for the Cybervision 64 graphics card from 266 This enables support for the Cybervision 64 graphics card from
285 Phase5. Please note that its use is not all that intuitive (i.e. if 267 Phase5. Please note that its use is not all that intuitive (i.e. if
@@ -294,7 +276,6 @@ config FB_VIRGE
294 select FB_CFB_FILLRECT 276 select FB_CFB_FILLRECT
295 select FB_CFB_COPYAREA 277 select FB_CFB_COPYAREA
296 select FB_CFB_IMAGEBLIT 278 select FB_CFB_IMAGEBLIT
297 select FB_SOFT_CURSOR
298 help 279 help
299 This enables support for the Cybervision 64/3D graphics card from 280 This enables support for the Cybervision 64/3D graphics card from
300 Phase5. Please note that its use is not all that intuitive (i.e. if 281 Phase5. Please note that its use is not all that intuitive (i.e. if
@@ -317,7 +298,6 @@ config FB_FM2
317 select FB_CFB_FILLRECT 298 select FB_CFB_FILLRECT
318 select FB_CFB_COPYAREA 299 select FB_CFB_COPYAREA
319 select FB_CFB_IMAGEBLIT 300 select FB_CFB_IMAGEBLIT
320 select FB_SOFT_CURSOR
321 help 301 help
322 This is the frame buffer device driver for the Amiga FrameMaster 302 This is the frame buffer device driver for the Amiga FrameMaster
323 card from BSC (exhibited 1992 but not shipped as a CBM product). 303 card from BSC (exhibited 1992 but not shipped as a CBM product).
@@ -328,7 +308,6 @@ config FB_ARC
328 select FB_CFB_FILLRECT 308 select FB_CFB_FILLRECT
329 select FB_CFB_COPYAREA 309 select FB_CFB_COPYAREA
330 select FB_CFB_IMAGEBLIT 310 select FB_CFB_IMAGEBLIT
331 select FB_SOFT_CURSOR
332 help 311 help
333 This enables support for the Arc Monochrome LCD board. The board 312 This enables support for the Arc Monochrome LCD board. The board
334 is based on the KS-108 lcd controller and is typically a matrix 313 is based on the KS-108 lcd controller and is typically a matrix
@@ -351,7 +330,6 @@ config FB_OF
351 select FB_CFB_FILLRECT 330 select FB_CFB_FILLRECT
352 select FB_CFB_COPYAREA 331 select FB_CFB_COPYAREA
353 select FB_CFB_IMAGEBLIT 332 select FB_CFB_IMAGEBLIT
354 select FB_SOFT_CURSOR
355 select FB_MACMODES 333 select FB_MACMODES
356 help 334 help
357 Say Y if you want support with Open Firmware for your graphics 335 Say Y if you want support with Open Firmware for your graphics
@@ -363,7 +341,6 @@ config FB_CONTROL
363 select FB_CFB_FILLRECT 341 select FB_CFB_FILLRECT
364 select FB_CFB_COPYAREA 342 select FB_CFB_COPYAREA
365 select FB_CFB_IMAGEBLIT 343 select FB_CFB_IMAGEBLIT
366 select FB_SOFT_CURSOR
367 select FB_MACMODES 344 select FB_MACMODES
368 help 345 help
369 This driver supports a frame buffer for the graphics adapter in the 346 This driver supports a frame buffer for the graphics adapter in the
@@ -375,7 +352,6 @@ config FB_PLATINUM
375 select FB_CFB_FILLRECT 352 select FB_CFB_FILLRECT
376 select FB_CFB_COPYAREA 353 select FB_CFB_COPYAREA
377 select FB_CFB_IMAGEBLIT 354 select FB_CFB_IMAGEBLIT
378 select FB_SOFT_CURSOR
379 select FB_MACMODES 355 select FB_MACMODES
380 help 356 help
381 This driver supports a frame buffer for the "platinum" graphics 357 This driver supports a frame buffer for the "platinum" graphics
@@ -387,7 +363,6 @@ config FB_VALKYRIE
387 select FB_CFB_FILLRECT 363 select FB_CFB_FILLRECT
388 select FB_CFB_COPYAREA 364 select FB_CFB_COPYAREA
389 select FB_CFB_IMAGEBLIT 365 select FB_CFB_IMAGEBLIT
390 select FB_SOFT_CURSOR
391 select FB_MACMODES 366 select FB_MACMODES
392 help 367 help
393 This driver supports a frame buffer for the "valkyrie" graphics 368 This driver supports a frame buffer for the "valkyrie" graphics
@@ -399,42 +374,32 @@ config FB_CT65550
399 select FB_CFB_FILLRECT 374 select FB_CFB_FILLRECT
400 select FB_CFB_COPYAREA 375 select FB_CFB_COPYAREA
401 select FB_CFB_IMAGEBLIT 376 select FB_CFB_IMAGEBLIT
402 select FB_SOFT_CURSOR
403 help 377 help
404 This is the frame buffer device driver for the Chips & Technologies 378 This is the frame buffer device driver for the Chips & Technologies
405 65550 graphics chip in PowerBooks. 379 65550 graphics chip in PowerBooks.
406 380
407config FB_ASILIANT 381config FB_ASILIANT
408 bool "Chips 69000 display support" 382 bool "Asiliant (Chips) 69000 display support"
409 depends on (FB = y) && PCI 383 depends on (FB = y) && PCI
410 select FB_CFB_FILLRECT 384 select FB_CFB_FILLRECT
411 select FB_CFB_COPYAREA 385 select FB_CFB_COPYAREA
412 select FB_CFB_IMAGEBLIT 386 select FB_CFB_IMAGEBLIT
413 select FB_SOFT_CURSOR
414 387
415config FB_IMSTT 388config FB_IMSTT
416 bool "IMS Twin Turbo display support" 389 bool "IMS Twin Turbo display support"
417 depends on (FB = y) && PCI 390 depends on (FB = y) && PCI
418 select FB_CFB_IMAGEBLIT 391 select FB_CFB_IMAGEBLIT
419 select FB_SOFT_CURSOR
420 select FB_MACMODES if PPC 392 select FB_MACMODES if PPC
421 help 393 help
422 The IMS Twin Turbo is a PCI-based frame buffer card bundled with 394 The IMS Twin Turbo is a PCI-based frame buffer card bundled with
423 many Macintosh and compatible computers. 395 many Macintosh and compatible computers.
424 396
425config FB_S3TRIO
426 bool "S3 Trio display support"
427 depends on (FB = y) && PPC && BROKEN
428 help
429 If you have a S3 Trio say Y. Say N for S3 Virge.
430
431config FB_VGA16 397config FB_VGA16
432 tristate "VGA 16-color graphics support" 398 tristate "VGA 16-color graphics support"
433 depends on FB && (X86 || PPC) 399 depends on FB && (X86 || PPC)
434 select FB_CFB_FILLRECT 400 select FB_CFB_FILLRECT
435 select FB_CFB_COPYAREA 401 select FB_CFB_COPYAREA
436 select FB_CFB_IMAGEBLIT 402 select FB_CFB_IMAGEBLIT
437 select FB_SOFT_CURSOR
438 help 403 help
439 This is the frame buffer device driver for VGA 16 color graphic 404 This is the frame buffer device driver for VGA 16 color graphic
440 cards. Say Y if you have such a card. 405 cards. Say Y if you have such a card.
@@ -448,7 +413,6 @@ config FB_STI
448 select FB_CFB_FILLRECT 413 select FB_CFB_FILLRECT
449 select FB_CFB_COPYAREA 414 select FB_CFB_COPYAREA
450 select FB_CFB_IMAGEBLIT 415 select FB_CFB_IMAGEBLIT
451 select FB_SOFT_CURSOR
452 default y 416 default y
453 ---help--- 417 ---help---
454 STI refers to the HP "Standard Text Interface" which is a set of 418 STI refers to the HP "Standard Text Interface" which is a set of
@@ -469,7 +433,6 @@ config FB_MAC
469 select FB_CFB_FILLRECT 433 select FB_CFB_FILLRECT
470 select FB_CFB_COPYAREA 434 select FB_CFB_COPYAREA
471 select FB_CFB_IMAGEBLIT 435 select FB_CFB_IMAGEBLIT
472 select FB_SOFT_CURSOR
473 select FB_MACMODES 436 select FB_MACMODES
474 437
475# bool ' Apple DAFB display support' CONFIG_FB_DAFB 438# bool ' Apple DAFB display support' CONFIG_FB_DAFB
@@ -478,7 +441,6 @@ config FB_HP300
478 depends on (FB = y) && HP300 441 depends on (FB = y) && HP300
479 select FB_CFB_FILLRECT 442 select FB_CFB_FILLRECT
480 select FB_CFB_IMAGEBLIT 443 select FB_CFB_IMAGEBLIT
481 select FB_SOFT_CURSOR
482 default y 444 default y
483 445
484config FB_TGA 446config FB_TGA
@@ -487,7 +449,6 @@ config FB_TGA
487 select FB_CFB_FILLRECT 449 select FB_CFB_FILLRECT
488 select FB_CFB_COPYAREA 450 select FB_CFB_COPYAREA
489 select FB_CFB_IMAGEBLIT 451 select FB_CFB_IMAGEBLIT
490 select FB_SOFT_CURSOR
491 help 452 help
492 This is the frame buffer device driver for generic TGA graphic 453 This is the frame buffer device driver for generic TGA graphic
493 cards. Say Y if you have one of those. 454 cards. Say Y if you have one of those.
@@ -498,7 +459,6 @@ config FB_VESA
498 select FB_CFB_FILLRECT 459 select FB_CFB_FILLRECT
499 select FB_CFB_COPYAREA 460 select FB_CFB_COPYAREA
500 select FB_CFB_IMAGEBLIT 461 select FB_CFB_IMAGEBLIT
501 select FB_SOFT_CURSOR
502 help 462 help
503 This is the frame buffer device driver for generic VESA 2.0 463 This is the frame buffer device driver for generic VESA 2.0
504 compliant graphic cards. The older VESA 1.2 cards are not supported. 464 compliant graphic cards. The older VESA 1.2 cards are not supported.
@@ -516,7 +476,6 @@ config FB_HGA
516 select FB_CFB_FILLRECT 476 select FB_CFB_FILLRECT
517 select FB_CFB_COPYAREA 477 select FB_CFB_COPYAREA
518 select FB_CFB_IMAGEBLIT 478 select FB_CFB_IMAGEBLIT
519 select FB_SOFT_CURSOR
520 help 479 help
521 Say Y here if you have a Hercules mono graphics card. 480 Say Y here if you have a Hercules mono graphics card.
522 481
@@ -545,7 +504,6 @@ config FB_SGIVW
545 select FB_CFB_FILLRECT 504 select FB_CFB_FILLRECT
546 select FB_CFB_COPYAREA 505 select FB_CFB_COPYAREA
547 select FB_CFB_IMAGEBLIT 506 select FB_CFB_IMAGEBLIT
548 select FB_SOFT_CURSOR
549 help 507 help
550 SGI Visual Workstation support for framebuffer graphics. 508 SGI Visual Workstation support for framebuffer graphics.
551 509
@@ -555,7 +513,6 @@ config FB_GBE
555 select FB_CFB_FILLRECT 513 select FB_CFB_FILLRECT
556 select FB_CFB_COPYAREA 514 select FB_CFB_COPYAREA
557 select FB_CFB_IMAGEBLIT 515 select FB_CFB_IMAGEBLIT
558 select FB_SOFT_CURSOR
559 help 516 help
560 This is the frame buffer device driver for SGI Graphics Backend. 517 This is the frame buffer device driver for SGI Graphics Backend.
561 This chip is used in SGI O2 and Visual Workstation 320/540. 518 This chip is used in SGI O2 and Visual Workstation 320/540.
@@ -583,7 +540,6 @@ config FB_BW2
583 select FB_CFB_FILLRECT 540 select FB_CFB_FILLRECT
584 select FB_CFB_COPYAREA 541 select FB_CFB_COPYAREA
585 select FB_CFB_IMAGEBLIT 542 select FB_CFB_IMAGEBLIT
586 select FB_SOFT_CURSOR
587 help 543 help
588 This is the frame buffer device driver for the BWtwo frame buffer. 544 This is the frame buffer device driver for the BWtwo frame buffer.
589 545
@@ -592,7 +548,6 @@ config FB_CG3
592 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 548 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
593 select FB_CFB_COPYAREA 549 select FB_CFB_COPYAREA
594 select FB_CFB_IMAGEBLIT 550 select FB_CFB_IMAGEBLIT
595 select FB_SOFT_CURSOR
596 help 551 help
597 This is the frame buffer device driver for the CGthree frame buffer. 552 This is the frame buffer device driver for the CGthree frame buffer.
598 553
@@ -601,7 +556,6 @@ config FB_CG6
601 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 556 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
602 select FB_CFB_COPYAREA 557 select FB_CFB_COPYAREA
603 select FB_CFB_IMAGEBLIT 558 select FB_CFB_IMAGEBLIT
604 select FB_SOFT_CURSOR
605 help 559 help
606 This is the frame buffer device driver for the CGsix (GX, TurboGX) 560 This is the frame buffer device driver for the CGsix (GX, TurboGX)
607 frame buffer. 561 frame buffer.
@@ -612,7 +566,6 @@ config FB_PVR2
612 select FB_CFB_FILLRECT 566 select FB_CFB_FILLRECT
613 select FB_CFB_COPYAREA 567 select FB_CFB_COPYAREA
614 select FB_CFB_IMAGEBLIT 568 select FB_CFB_IMAGEBLIT
615 select FB_SOFT_CURSOR
616 ---help--- 569 ---help---
617 Say Y here if you have a PowerVR 2 card in your box. If you plan to 570 Say Y here if you have a PowerVR 2 card in your box. If you plan to
618 run linux on your Dreamcast, you will have to say Y here. 571 run linux on your Dreamcast, you will have to say Y here.
@@ -634,13 +587,55 @@ config FB_EPSON1355
634 select FB_CFB_FILLRECT 587 select FB_CFB_FILLRECT
635 select FB_CFB_COPYAREA 588 select FB_CFB_COPYAREA
636 select FB_CFB_IMAGEBLIT 589 select FB_CFB_IMAGEBLIT
637 select FB_SOFT_CURSOR
638 help 590 help
639 Build in support for the SED1355 Epson Research Embedded RAMDAC 591 Build in support for the SED1355 Epson Research Embedded RAMDAC
640 LCD/CRT Controller (since redesignated as the S1D13505) as a 592 LCD/CRT Controller (since redesignated as the S1D13505) as a
641 framebuffer. Product specs at 593 framebuffer. Product specs at
642 <http://www.erd.epson.com/vdc/html/products.htm>. 594 <http://www.erd.epson.com/vdc/html/products.htm>.
643 595
596config FB_E1356
597 tristate "Epson SED1356 framebuffer support"
598 depends on FB && EXPERIMENTAL && PCI && MIPS
599
600config PB1000_CRT
601 bool "Use CRT on Pb1000 (J65)"
602 depends on MIPS_PB1000=y && FB_E1356
603
604config PB1000_NTSC
605 bool "Use Compsite NTSC on Pb1000 (J63)"
606 depends on MIPS_PB1000=y && FB_E1356
607
608config PB1000_TFT
609 bool "Use TFT Panel on Pb1000 (J64)"
610 depends on MIPS_PB1000=y && FB_E1356
611
612config PB1500_CRT
613 bool "Use CRT on Pb1500 " if MIPS_PB1500=y
614 depends on FB_E1356
615
616config PB1500_CRT
617 prompt "Use CRT on Pb1100 "
618 depends on FB_E1356 && MIPS_PB1100=y
619
620config PB1500_TFT
621 bool "Use TFT Panel on Pb1500 " if MIPS_PB1500=y
622 depends on FB_E1356
623
624config PB1500_TFT
625 prompt "Use TFT Panel on Pb1100 "
626 depends on FB_E1356 && MIPS_PB1100=y
627
628config FB_S1D13XXX
629 tristate "Epson S1D13XXX framebuffer support"
630 depends on FB
631 select FB_CFB_FILLRECT
632 select FB_CFB_COPYAREA
633 select FB_CFB_IMAGEBLIT
634 help
635 Support for S1D13XXX framebuffer device family (currently only
636 working with S1D13806). Product specs at
637 <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm>
638
644config FB_NVIDIA 639config FB_NVIDIA
645 tristate "nVidia Framebuffer Support" 640 tristate "nVidia Framebuffer Support"
646 depends on FB && PCI 641 depends on FB && PCI
@@ -650,7 +645,6 @@ config FB_NVIDIA
650 select FB_CFB_FILLRECT 645 select FB_CFB_FILLRECT
651 select FB_CFB_COPYAREA 646 select FB_CFB_COPYAREA
652 select FB_CFB_IMAGEBLIT 647 select FB_CFB_IMAGEBLIT
653 select FB_SOFT_CURSOR
654 help 648 help
655 This driver supports graphics boards with the nVidia chips, TNT 649 This driver supports graphics boards with the nVidia chips, TNT
656 and newer. For very old chipsets, such as the RIVA128, then use 650 and newer. For very old chipsets, such as the RIVA128, then use
@@ -662,7 +656,7 @@ config FB_NVIDIA
662 656
663config FB_NVIDIA_I2C 657config FB_NVIDIA_I2C
664 bool "Enable DDC Support" 658 bool "Enable DDC Support"
665 depends on FB_NVIDIA && !PPC_OF 659 depends on FB_NVIDIA
666 help 660 help
667 This enables I2C support for nVidia Chipsets. This is used 661 This enables I2C support for nVidia Chipsets. This is used
668 only for getting EDID information from the attached display 662 only for getting EDID information from the attached display
@@ -768,7 +762,6 @@ config FB_INTEL
768 select FB_CFB_FILLRECT 762 select FB_CFB_FILLRECT
769 select FB_CFB_COPYAREA 763 select FB_CFB_COPYAREA
770 select FB_CFB_IMAGEBLIT 764 select FB_CFB_IMAGEBLIT
771 select FB_SOFT_CURSOR
772 help 765 help
773 This driver supports the on-board graphics built in to the Intel 766 This driver supports the on-board graphics built in to the Intel
774 830M/845G/852GM/855GM/865G chipsets. 767 830M/845G/852GM/855GM/865G chipsets.
@@ -791,7 +784,6 @@ config FB_MATROX
791 select FB_CFB_FILLRECT 784 select FB_CFB_FILLRECT
792 select FB_CFB_COPYAREA 785 select FB_CFB_COPYAREA
793 select FB_CFB_IMAGEBLIT 786 select FB_CFB_IMAGEBLIT
794 select FB_SOFT_CURSOR
795 select FB_TILEBLITTING 787 select FB_TILEBLITTING
796 select FB_MACMODES if PPC_PMAC 788 select FB_MACMODES if PPC_PMAC
797 ---help--- 789 ---help---
@@ -932,7 +924,6 @@ config FB_RADEON_OLD
932 select FB_CFB_FILLRECT 924 select FB_CFB_FILLRECT
933 select FB_CFB_COPYAREA 925 select FB_CFB_COPYAREA
934 select FB_CFB_IMAGEBLIT 926 select FB_CFB_IMAGEBLIT
935 select FB_SOFT_CURSOR
936 select FB_MACMODES if PPC 927 select FB_MACMODES if PPC
937 help 928 help
938 Choose this option if you want to use an ATI Radeon graphics card as 929 Choose this option if you want to use an ATI Radeon graphics card as
@@ -950,7 +941,6 @@ config FB_RADEON
950 select FB_CFB_FILLRECT 941 select FB_CFB_FILLRECT
951 select FB_CFB_COPYAREA 942 select FB_CFB_COPYAREA
952 select FB_CFB_IMAGEBLIT 943 select FB_CFB_IMAGEBLIT
953 select FB_SOFT_CURSOR
954 select FB_MACMODES if PPC_OF 944 select FB_MACMODES if PPC_OF
955 help 945 help
956 Choose this option if you want to use an ATI Radeon graphics card as 946 Choose this option if you want to use an ATI Radeon graphics card as
@@ -988,7 +978,6 @@ config FB_ATY128
988 select FB_CFB_FILLRECT 978 select FB_CFB_FILLRECT
989 select FB_CFB_COPYAREA 979 select FB_CFB_COPYAREA
990 select FB_CFB_IMAGEBLIT 980 select FB_CFB_IMAGEBLIT
991 select FB_SOFT_CURSOR
992 select FB_MACMODES if PPC_PMAC 981 select FB_MACMODES if PPC_PMAC
993 help 982 help
994 This driver supports graphics boards with the ATI Rage128 chips. 983 This driver supports graphics boards with the ATI Rage128 chips.
@@ -1004,7 +993,6 @@ config FB_ATY
1004 select FB_CFB_FILLRECT 993 select FB_CFB_FILLRECT
1005 select FB_CFB_COPYAREA 994 select FB_CFB_COPYAREA
1006 select FB_CFB_IMAGEBLIT 995 select FB_CFB_IMAGEBLIT
1007 select FB_SOFT_CURSOR
1008 select FB_MACMODES if PPC 996 select FB_MACMODES if PPC
1009 help 997 help
1010 This driver supports graphics boards with the ATI Mach64 chips. 998 This driver supports graphics boards with the ATI Mach64 chips.
@@ -1047,6 +1035,12 @@ config FB_ATY_GX
1047 is at 1035 is at
1048 <http://support.ati.com/products/pc/mach64/graphics_xpression.html>. 1036 <http://support.ati.com/products/pc/mach64/graphics_xpression.html>.
1049 1037
1038config FB_S3TRIO
1039 bool "S3 Trio display support"
1040 depends on (FB = y) && PPC && BROKEN
1041 help
1042 If you have a S3 Trio say Y. Say N for S3 Virge.
1043
1050config FB_SAVAGE 1044config FB_SAVAGE
1051 tristate "S3 Savage support" 1045 tristate "S3 Savage support"
1052 depends on FB && PCI && EXPERIMENTAL 1046 depends on FB && PCI && EXPERIMENTAL
@@ -1056,7 +1050,6 @@ config FB_SAVAGE
1056 select FB_CFB_FILLRECT 1050 select FB_CFB_FILLRECT
1057 select FB_CFB_COPYAREA 1051 select FB_CFB_COPYAREA
1058 select FB_CFB_IMAGEBLIT 1052 select FB_CFB_IMAGEBLIT
1059 select FB_SOFT_CURSOR
1060 help 1053 help
1061 This driver supports notebooks and computers with S3 Savage PCI/AGP 1054 This driver supports notebooks and computers with S3 Savage PCI/AGP
1062 chips. 1055 chips.
@@ -1093,7 +1086,6 @@ config FB_SIS
1093 select FB_CFB_FILLRECT 1086 select FB_CFB_FILLRECT
1094 select FB_CFB_COPYAREA 1087 select FB_CFB_COPYAREA
1095 select FB_CFB_IMAGEBLIT 1088 select FB_CFB_IMAGEBLIT
1096 select FB_SOFT_CURSOR
1097 help 1089 help
1098 This is the frame buffer device driver for the SiS 300, 315, 330 1090 This is the frame buffer device driver for the SiS 300, 315, 330
1099 and 340 series as well as XGI V3XT, V5, V8, Z7 graphics chipsets. 1091 and 340 series as well as XGI V3XT, V5, V8, Z7 graphics chipsets.
@@ -1123,7 +1115,6 @@ config FB_NEOMAGIC
1123 select FB_CFB_FILLRECT 1115 select FB_CFB_FILLRECT
1124 select FB_CFB_COPYAREA 1116 select FB_CFB_COPYAREA
1125 select FB_CFB_IMAGEBLIT 1117 select FB_CFB_IMAGEBLIT
1126 select FB_SOFT_CURSOR
1127 help 1118 help
1128 This driver supports notebooks with NeoMagic PCI chips. 1119 This driver supports notebooks with NeoMagic PCI chips.
1129 Say Y if you have such a graphics card. 1120 Say Y if you have such a graphics card.
@@ -1137,7 +1128,6 @@ config FB_KYRO
1137 select FB_CFB_FILLRECT 1128 select FB_CFB_FILLRECT
1138 select FB_CFB_COPYAREA 1129 select FB_CFB_COPYAREA
1139 select FB_CFB_IMAGEBLIT 1130 select FB_CFB_IMAGEBLIT
1140 select FB_SOFT_CURSOR
1141 help 1131 help
1142 Say Y here if you have a STG4000 / Kyro / PowerVR 3 based 1132 Say Y here if you have a STG4000 / Kyro / PowerVR 3 based
1143 graphics board. 1133 graphics board.
@@ -1151,7 +1141,6 @@ config FB_3DFX
1151 select FB_CFB_IMAGEBLIT 1141 select FB_CFB_IMAGEBLIT
1152 select FB_CFB_FILLRECT 1142 select FB_CFB_FILLRECT
1153 select FB_CFB_COPYAREA 1143 select FB_CFB_COPYAREA
1154 select FB_SOFT_CURSOR
1155 help 1144 help
1156 This driver supports graphics boards with the 3Dfx Banshee/Voodoo3 1145 This driver supports graphics boards with the 3Dfx Banshee/Voodoo3
1157 chips. Say Y if you have such a graphics board. 1146 chips. Say Y if you have such a graphics board.
@@ -1173,7 +1162,6 @@ config FB_VOODOO1
1173 select FB_CFB_FILLRECT 1162 select FB_CFB_FILLRECT
1174 select FB_CFB_COPYAREA 1163 select FB_CFB_COPYAREA
1175 select FB_CFB_IMAGEBLIT 1164 select FB_CFB_IMAGEBLIT
1176 select FB_SOFT_CURSOR
1177 ---help--- 1165 ---help---
1178 Say Y here if you have a 3Dfx Voodoo Graphics (Voodoo1/sst1) or 1166 Say Y here if you have a 3Dfx Voodoo Graphics (Voodoo1/sst1) or
1179 Voodoo2 (cvg) based graphics card. 1167 Voodoo2 (cvg) based graphics card.
@@ -1190,7 +1178,6 @@ config FB_CYBLA
1190 tristate "Cyberblade/i1 support" 1178 tristate "Cyberblade/i1 support"
1191 depends on FB && PCI 1179 depends on FB && PCI
1192 select FB_CFB_IMAGEBLIT 1180 select FB_CFB_IMAGEBLIT
1193 select FB_SOFT_CURSOR
1194 select VIDEO_SELECT 1181 select VIDEO_SELECT
1195 ---help--- 1182 ---help---
1196 This driver is supposed to support the Trident Cyberblade/i1 1183 This driver is supposed to support the Trident Cyberblade/i1
@@ -1218,7 +1205,6 @@ config FB_TRIDENT
1218 select FB_CFB_FILLRECT 1205 select FB_CFB_FILLRECT
1219 select FB_CFB_COPYAREA 1206 select FB_CFB_COPYAREA
1220 select FB_CFB_IMAGEBLIT 1207 select FB_CFB_IMAGEBLIT
1221 select FB_SOFT_CURSOR
1222 ---help--- 1208 ---help---
1223 This driver is supposed to support graphics boards with the 1209 This driver is supposed to support graphics boards with the
1224 Trident CyberXXXX/Image/CyberBlade chips mostly found in laptops 1210 Trident CyberXXXX/Image/CyberBlade chips mostly found in laptops
@@ -1250,38 +1236,6 @@ config FB_PM3
1250 similar boards, 3DLabs Permedia3 Create!, Appian Jeronimo 2000 1236 similar boards, 3DLabs Permedia3 Create!, Appian Jeronimo 2000
1251 and maybe other boards. 1237 and maybe other boards.
1252 1238
1253config FB_E1356
1254 tristate "Epson SED1356 framebuffer support"
1255 depends on FB && EXPERIMENTAL && PCI && MIPS
1256
1257config PB1000_CRT
1258 bool "Use CRT on Pb1000 (J65)"
1259 depends on MIPS_PB1000=y && FB_E1356
1260
1261config PB1000_NTSC
1262 bool "Use Compsite NTSC on Pb1000 (J63)"
1263 depends on MIPS_PB1000=y && FB_E1356
1264
1265config PB1000_TFT
1266 bool "Use TFT Panel on Pb1000 (J64)"
1267 depends on MIPS_PB1000=y && FB_E1356
1268
1269config PB1500_CRT
1270 bool "Use CRT on Pb1500 " if MIPS_PB1500=y
1271 depends on FB_E1356
1272
1273config PB1500_CRT
1274 prompt "Use CRT on Pb1100 "
1275 depends on FB_E1356 && MIPS_PB1100=y
1276
1277config PB1500_TFT
1278 bool "Use TFT Panel on Pb1500 " if MIPS_PB1500=y
1279 depends on FB_E1356
1280
1281config PB1500_TFT
1282 prompt "Use TFT Panel on Pb1100 "
1283 depends on FB_E1356 && MIPS_PB1100=y
1284
1285config FB_AU1100 1239config FB_AU1100
1286 bool "Au1100 LCD Driver" 1240 bool "Au1100 LCD Driver"
1287 depends on (FB = y) && EXPERIMENTAL && PCI && MIPS && MIPS_PB1100=y 1241 depends on (FB = y) && EXPERIMENTAL && PCI && MIPS && MIPS_PB1100=y
@@ -1299,7 +1253,6 @@ config FB_FFB
1299 depends on FB_SBUS && SPARC64 1253 depends on FB_SBUS && SPARC64
1300 select FB_CFB_COPYAREA 1254 select FB_CFB_COPYAREA
1301 select FB_CFB_IMAGEBLIT 1255 select FB_CFB_IMAGEBLIT
1302 select FB_SOFT_CURSOR
1303 help 1256 help
1304 This is the frame buffer device driver for the Creator, Creator3D, 1257 This is the frame buffer device driver for the Creator, Creator3D,
1305 and Elite3D graphics boards. 1258 and Elite3D graphics boards.
@@ -1310,7 +1263,6 @@ config FB_TCX
1310 select FB_CFB_FILLRECT 1263 select FB_CFB_FILLRECT
1311 select FB_CFB_COPYAREA 1264 select FB_CFB_COPYAREA
1312 select FB_CFB_IMAGEBLIT 1265 select FB_CFB_IMAGEBLIT
1313 select FB_SOFT_CURSOR
1314 help 1266 help
1315 This is the frame buffer device driver for the TCX 24/8bit frame 1267 This is the frame buffer device driver for the TCX 24/8bit frame
1316 buffer. 1268 buffer.
@@ -1321,7 +1273,6 @@ config FB_CG14
1321 select FB_CFB_FILLRECT 1273 select FB_CFB_FILLRECT
1322 select FB_CFB_COPYAREA 1274 select FB_CFB_COPYAREA
1323 select FB_CFB_IMAGEBLIT 1275 select FB_CFB_IMAGEBLIT
1324 select FB_SOFT_CURSOR
1325 help 1276 help
1326 This is the frame buffer device driver for the CGfourteen frame 1277 This is the frame buffer device driver for the CGfourteen frame
1327 buffer on Desktop SPARCsystems with the SX graphics option. 1278 buffer on Desktop SPARCsystems with the SX graphics option.
@@ -1332,7 +1283,6 @@ config FB_P9100
1332 select FB_CFB_FILLRECT 1283 select FB_CFB_FILLRECT
1333 select FB_CFB_COPYAREA 1284 select FB_CFB_COPYAREA
1334 select FB_CFB_IMAGEBLIT 1285 select FB_CFB_IMAGEBLIT
1335 select FB_SOFT_CURSOR
1336 help 1286 help
1337 This is the frame buffer device driver for the P9100 card 1287 This is the frame buffer device driver for the P9100 card
1338 supported on Sparcbook 3 machines. 1288 supported on Sparcbook 3 machines.
@@ -1343,7 +1293,6 @@ config FB_LEO
1343 select FB_CFB_FILLRECT 1293 select FB_CFB_FILLRECT
1344 select FB_CFB_COPYAREA 1294 select FB_CFB_COPYAREA
1345 select FB_CFB_IMAGEBLIT 1295 select FB_CFB_IMAGEBLIT
1346 select FB_SOFT_CURSOR
1347 help 1296 help
1348 This is the frame buffer device driver for the SBUS-based Sun ZX 1297 This is the frame buffer device driver for the SBUS-based Sun ZX
1349 (leo) frame buffer cards. 1298 (leo) frame buffer cards.
@@ -1358,7 +1307,6 @@ config FB_IGA
1358 select FB_CFB_FILLRECT 1307 select FB_CFB_FILLRECT
1359 select FB_CFB_COPYAREA 1308 select FB_CFB_COPYAREA
1360 select FB_CFB_IMAGEBLIT 1309 select FB_CFB_IMAGEBLIT
1361 select FB_SOFT_CURSOR
1362 help 1310 help
1363 This is the framebuffer device for the INTERGRAPHICS 1680 and 1311 This is the framebuffer device for the INTERGRAPHICS 1680 and
1364 successor frame buffer cards. 1312 successor frame buffer cards.
@@ -1369,7 +1317,6 @@ config FB_HIT
1369 select FB_CFB_FILLRECT 1317 select FB_CFB_FILLRECT
1370 select FB_CFB_COPYAREA 1318 select FB_CFB_COPYAREA
1371 select FB_CFB_IMAGEBLIT 1319 select FB_CFB_IMAGEBLIT
1372 select FB_SOFT_CURSOR
1373 help 1320 help
1374 This is the frame buffer device driver for the Hitachi HD64461 LCD 1321 This is the frame buffer device driver for the Hitachi HD64461 LCD
1375 frame buffer card. 1322 frame buffer card.
@@ -1380,7 +1327,6 @@ config FB_PMAG_AA
1380 select FB_CFB_FILLRECT 1327 select FB_CFB_FILLRECT
1381 select FB_CFB_COPYAREA 1328 select FB_CFB_COPYAREA
1382 select FB_CFB_IMAGEBLIT 1329 select FB_CFB_IMAGEBLIT
1383 select FB_SOFT_CURSOR
1384 help 1330 help
1385 Support for the PMAG-AA TURBOchannel framebuffer card (1280x1024x1) 1331 Support for the PMAG-AA TURBOchannel framebuffer card (1280x1024x1)
1386 used mainly in the MIPS-based DECstation series. 1332 used mainly in the MIPS-based DECstation series.
@@ -1391,7 +1337,6 @@ config FB_PMAG_BA
1391 select FB_CFB_FILLRECT 1337 select FB_CFB_FILLRECT
1392 select FB_CFB_COPYAREA 1338 select FB_CFB_COPYAREA
1393 select FB_CFB_IMAGEBLIT 1339 select FB_CFB_IMAGEBLIT
1394 select FB_SOFT_CURSOR
1395 help 1340 help
1396 Support for the PMAG-BA TURBOchannel framebuffer card (1024x864x8) 1341 Support for the PMAG-BA TURBOchannel framebuffer card (1024x864x8)
1397 used mainly in the MIPS-based DECstation series. 1342 used mainly in the MIPS-based DECstation series.
@@ -1402,7 +1347,6 @@ config FB_PMAGB_B
1402 select FB_CFB_FILLRECT 1347 select FB_CFB_FILLRECT
1403 select FB_CFB_COPYAREA 1348 select FB_CFB_COPYAREA
1404 select FB_CFB_IMAGEBLIT 1349 select FB_CFB_IMAGEBLIT
1405 select FB_SOFT_CURSOR
1406 help 1350 help
1407 Support for the PMAGB-B TURBOchannel framebuffer card used mainly 1351 Support for the PMAGB-B TURBOchannel framebuffer card used mainly
1408 in the MIPS-based DECstation series. The card is currently only 1352 in the MIPS-based DECstation series. The card is currently only
@@ -1414,7 +1358,6 @@ config FB_MAXINE
1414 select FB_CFB_FILLRECT 1358 select FB_CFB_FILLRECT
1415 select FB_CFB_COPYAREA 1359 select FB_CFB_COPYAREA
1416 select FB_CFB_IMAGEBLIT 1360 select FB_CFB_IMAGEBLIT
1417 select FB_SOFT_CURSOR
1418 help 1361 help
1419 Support for the onboard framebuffer (1024x768x8) in the Personal 1362 Support for the onboard framebuffer (1024x768x8) in the Personal
1420 DECstation series (Personal DECstation 5000/20, /25, /33, /50, 1363 DECstation series (Personal DECstation 5000/20, /25, /33, /50,
@@ -1426,7 +1369,6 @@ config FB_TX3912
1426 select FB_CFB_FILLRECT 1369 select FB_CFB_FILLRECT
1427 select FB_CFB_COPYAREA 1370 select FB_CFB_COPYAREA
1428 select FB_CFB_IMAGEBLIT 1371 select FB_CFB_IMAGEBLIT
1429 select FB_SOFT_CURSOR
1430 help 1372 help
1431 The TX3912 is a Toshiba RISC processor based on the MIPS 3900 core 1373 The TX3912 is a Toshiba RISC processor based on the MIPS 3900 core
1432 see <http://www.toshiba.com/taec/components/Generic/risc/tx3912.htm>. 1374 see <http://www.toshiba.com/taec/components/Generic/risc/tx3912.htm>.
@@ -1439,7 +1381,6 @@ config FB_G364
1439 select FB_CFB_FILLRECT 1381 select FB_CFB_FILLRECT
1440 select FB_CFB_COPYAREA 1382 select FB_CFB_COPYAREA
1441 select FB_CFB_IMAGEBLIT 1383 select FB_CFB_IMAGEBLIT
1442 select FB_SOFT_CURSOR
1443 help 1384 help
1444 The G364 driver is the framebuffer used in MIPS Magnum 4000 and 1385 The G364 driver is the framebuffer used in MIPS Magnum 4000 and
1445 Olivetti M700-10 systems. 1386 Olivetti M700-10 systems.
@@ -1450,7 +1391,6 @@ config FB_68328
1450 select FB_CFB_FILLRECT 1391 select FB_CFB_FILLRECT
1451 select FB_CFB_COPYAREA 1392 select FB_CFB_COPYAREA
1452 select FB_CFB_IMAGEBLIT 1393 select FB_CFB_IMAGEBLIT
1453 select FB_SOFT_CURSOR
1454 help 1394 help
1455 Say Y here if you want to support the built-in frame buffer of 1395 Say Y here if you want to support the built-in frame buffer of
1456 the Motorola 68328 CPU family. 1396 the Motorola 68328 CPU family.
@@ -1461,7 +1401,6 @@ config FB_PXA
1461 select FB_CFB_FILLRECT 1401 select FB_CFB_FILLRECT
1462 select FB_CFB_COPYAREA 1402 select FB_CFB_COPYAREA
1463 select FB_CFB_IMAGEBLIT 1403 select FB_CFB_IMAGEBLIT
1464 select FB_SOFT_CURSOR
1465 ---help--- 1404 ---help---
1466 Frame buffer driver for the built-in LCD controller in the Intel 1405 Frame buffer driver for the built-in LCD controller in the Intel
1467 PXA2x0 processor. 1406 PXA2x0 processor.
@@ -1473,23 +1412,6 @@ config FB_PXA
1473 1412
1474 If unsure, say N. 1413 If unsure, say N.
1475 1414
1476config FB_W100
1477 tristate "W100 frame buffer support"
1478 depends on FB && PXA_SHARPSL
1479 select FB_CFB_FILLRECT
1480 select FB_CFB_COPYAREA
1481 select FB_CFB_IMAGEBLIT
1482 select FB_SOFT_CURSOR
1483 ---help---
1484 Frame buffer driver for the w100 as found on the Sharp SL-Cxx series.
1485
1486 This driver is also available as a module ( = code which can be
1487 inserted and removed from the running kernel whenever you want). The
1488 module will be called vfb. If you want to compile it as a module,
1489 say M here and read <file:Documentation/modules.txt>.
1490
1491 If unsure, say N.
1492
1493config FB_PXA_PARAMETERS 1415config FB_PXA_PARAMETERS
1494 bool "PXA LCD command line parameters" 1416 bool "PXA LCD command line parameters"
1495 default n 1417 default n
@@ -1507,17 +1429,21 @@ config FB_PXA_PARAMETERS
1507 1429
1508 <file:Documentation/fb/pxafb.txt> describes the available parameters. 1430 <file:Documentation/fb/pxafb.txt> describes the available parameters.
1509 1431
1510config FB_S1D13XXX 1432config FB_W100
1511 tristate "Epson S1D13XXX framebuffer support" 1433 tristate "W100 frame buffer support"
1512 depends on FB 1434 depends on FB && PXA_SHARPSL
1513 select FB_CFB_FILLRECT 1435 select FB_CFB_FILLRECT
1514 select FB_CFB_COPYAREA 1436 select FB_CFB_COPYAREA
1515 select FB_CFB_IMAGEBLIT 1437 select FB_CFB_IMAGEBLIT
1516 select FB_SOFT_CURSOR 1438 ---help---
1517 help 1439 Frame buffer driver for the w100 as found on the Sharp SL-Cxx series.
1518 Support for S1D13XXX framebuffer device family (currently only 1440
1519 working with S1D13806). Product specs at 1441 This driver is also available as a module ( = code which can be
1520 <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> 1442 inserted and removed from the running kernel whenever you want). The
1443 module will be called vfb. If you want to compile it as a module,
1444 say M here and read <file:Documentation/modules.txt>.
1445
1446 If unsure, say N.
1521 1447
1522config FB_S3C2410 1448config FB_S3C2410
1523 tristate "S3C2410 LCD framebuffer support" 1449 tristate "S3C2410 LCD framebuffer support"
@@ -1525,7 +1451,6 @@ config FB_S3C2410
1525 select FB_CFB_FILLRECT 1451 select FB_CFB_FILLRECT
1526 select FB_CFB_COPYAREA 1452 select FB_CFB_COPYAREA
1527 select FB_CFB_IMAGEBLIT 1453 select FB_CFB_IMAGEBLIT
1528 select FB_SOFT_CURSOR
1529 ---help--- 1454 ---help---
1530 Frame buffer driver for the built-in LCD controller in the Samsung 1455 Frame buffer driver for the built-in LCD controller in the Samsung
1531 S3C2410 processor. 1456 S3C2410 processor.
@@ -1549,7 +1474,6 @@ config FB_VIRTUAL
1549 select FB_CFB_FILLRECT 1474 select FB_CFB_FILLRECT
1550 select FB_CFB_COPYAREA 1475 select FB_CFB_COPYAREA
1551 select FB_CFB_IMAGEBLIT 1476 select FB_CFB_IMAGEBLIT
1552 select FB_SOFT_CURSOR
1553 ---help--- 1477 ---help---
1554 This is a `virtual' frame buffer device. It operates on a chunk of 1478 This is a `virtual' frame buffer device. It operates on a chunk of
1555 unswappable kernel memory instead of on the memory of a graphics 1479 unswappable kernel memory instead of on the memory of a graphics
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 97c5d03ac8d9..aa434e725c0d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -16,7 +16,6 @@ fb-objs := $(fb-y)
16obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o 16obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o
17obj-$(CONFIG_FB_CFB_COPYAREA) += cfbcopyarea.o 17obj-$(CONFIG_FB_CFB_COPYAREA) += cfbcopyarea.o
18obj-$(CONFIG_FB_CFB_IMAGEBLIT) += cfbimgblt.o 18obj-$(CONFIG_FB_CFB_IMAGEBLIT) += cfbimgblt.o
19obj-$(CONFIG_FB_SOFT_CURSOR) += softcursor.o
20obj-$(CONFIG_FB_MACMODES) += macmodes.o 19obj-$(CONFIG_FB_MACMODES) += macmodes.o
21 20
22# Hardware specific drivers go first 21# Hardware specific drivers go first
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c
index 9b6a39348f81..193b482570c7 100644
--- a/drivers/video/acornfb.c
+++ b/drivers/video/acornfb.c
@@ -926,7 +926,6 @@ static struct fb_ops acornfb_ops = {
926 .fb_copyarea = cfb_copyarea, 926 .fb_copyarea = cfb_copyarea,
927 .fb_imageblit = cfb_imageblit, 927 .fb_imageblit = cfb_imageblit,
928 .fb_mmap = acornfb_mmap, 928 .fb_mmap = acornfb_mmap,
929 .fb_cursor = soft_cursor,
930}; 929};
931 930
932/* 931/*
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index 4fc93dc2b4d3..467a1d7ebbde 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -333,7 +333,6 @@ static struct fb_ops clcdfb_ops = {
333 .fb_fillrect = cfb_fillrect, 333 .fb_fillrect = cfb_fillrect,
334 .fb_copyarea = cfb_copyarea, 334 .fb_copyarea = cfb_copyarea,
335 .fb_imageblit = cfb_imageblit, 335 .fb_imageblit = cfb_imageblit,
336 .fb_cursor = soft_cursor,
337 .fb_mmap = clcdfb_mmap, 336 .fb_mmap = clcdfb_mmap,
338}; 337};
339 338
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index cf8bb67462dc..d549e215f3c5 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -1185,7 +1185,6 @@ static struct fb_ops amifb_ops = {
1185 .fb_fillrect = amifb_fillrect, 1185 .fb_fillrect = amifb_fillrect,
1186 .fb_copyarea = amifb_copyarea, 1186 .fb_copyarea = amifb_copyarea,
1187 .fb_imageblit = amifb_imageblit, 1187 .fb_imageblit = amifb_imageblit,
1188 .fb_cursor = soft_cursor,
1189 .fb_ioctl = amifb_ioctl, 1188 .fb_ioctl = amifb_ioctl,
1190}; 1189};
1191 1190
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index 126daff1c848..a1fc8bbb1090 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -502,10 +502,6 @@ static ssize_t arcfb_write(struct file *file, const char *buf, size_t count,
502 return err; 502 return err;
503} 503}
504 504
505static void arcfb_platform_release(struct device *device)
506{
507}
508
509static struct fb_ops arcfb_ops = { 505static struct fb_ops arcfb_ops = {
510 .owner = THIS_MODULE, 506 .owner = THIS_MODULE,
511 .fb_open = arcfb_open, 507 .fb_open = arcfb_open,
@@ -515,7 +511,6 @@ static struct fb_ops arcfb_ops = {
515 .fb_fillrect = arcfb_fillrect, 511 .fb_fillrect = arcfb_fillrect,
516 .fb_copyarea = arcfb_copyarea, 512 .fb_copyarea = arcfb_copyarea,
517 .fb_imageblit = arcfb_imageblit, 513 .fb_imageblit = arcfb_imageblit,
518 .fb_cursor = soft_cursor,
519 .fb_ioctl = arcfb_ioctl, 514 .fb_ioctl = arcfb_ioctl,
520}; 515};
521 516
@@ -624,13 +619,7 @@ static struct device_driver arcfb_driver = {
624 .remove = arcfb_remove, 619 .remove = arcfb_remove,
625}; 620};
626 621
627static struct platform_device arcfb_device = { 622static struct platform_device *arcfb_device;
628 .name = "arcfb",
629 .id = 0,
630 .dev = {
631 .release = arcfb_platform_release,
632 }
633};
634 623
635static int __init arcfb_init(void) 624static int __init arcfb_init(void)
636{ 625{
@@ -641,9 +630,16 @@ static int __init arcfb_init(void)
641 630
642 ret = driver_register(&arcfb_driver); 631 ret = driver_register(&arcfb_driver);
643 if (!ret) { 632 if (!ret) {
644 ret = platform_device_register(&arcfb_device); 633 arcfb_device = platform_device_alloc("arcfb", 0);
645 if (ret) 634 if (arcfb_device) {
635 ret = platform_device_add(arcfb_device);
636 } else {
637 ret = -ENOMEM;
638 }
639 if (ret) {
640 platform_device_put(arcfb_device);
646 driver_unregister(&arcfb_driver); 641 driver_unregister(&arcfb_driver);
642 }
647 } 643 }
648 return ret; 644 return ret;
649 645
@@ -651,7 +647,7 @@ static int __init arcfb_init(void)
651 647
652static void __exit arcfb_exit(void) 648static void __exit arcfb_exit(void)
653{ 649{
654 platform_device_unregister(&arcfb_device); 650 platform_device_unregister(arcfb_device);
655 driver_unregister(&arcfb_driver); 651 driver_unregister(&arcfb_driver);
656} 652}
657 653
diff --git a/drivers/video/asiliantfb.c b/drivers/video/asiliantfb.c
index f4729f4df8ce..c64de59398f4 100644
--- a/drivers/video/asiliantfb.c
+++ b/drivers/video/asiliantfb.c
@@ -106,7 +106,6 @@ static struct fb_ops asiliantfb_ops = {
106 .fb_fillrect = cfb_fillrect, 106 .fb_fillrect = cfb_fillrect,
107 .fb_copyarea = cfb_copyarea, 107 .fb_copyarea = cfb_copyarea,
108 .fb_imageblit = cfb_imageblit, 108 .fb_imageblit = cfb_imageblit,
109 .fb_cursor = soft_cursor,
110}; 109};
111 110
112/* Calculate the ratios for the dot clocks without using a single long long 111/* Calculate the ratios for the dot clocks without using a single long long
diff --git a/drivers/video/aty/ati_ids.h b/drivers/video/aty/ati_ids.h
index 13321c689cf6..39ab483fc250 100644
--- a/drivers/video/aty/ati_ids.h
+++ b/drivers/video/aty/ati_ids.h
@@ -150,6 +150,7 @@
150#define PCI_CHIP_RV200_QX 0x5158 150#define PCI_CHIP_RV200_QX 0x5158
151#define PCI_CHIP_RV100_QY 0x5159 151#define PCI_CHIP_RV100_QY 0x5159
152#define PCI_CHIP_RV100_QZ 0x515A 152#define PCI_CHIP_RV100_QZ 0x515A
153#define PCI_CHIP_RN50 0x515E
153#define PCI_CHIP_RAGE128RE 0x5245 154#define PCI_CHIP_RAGE128RE 0x5245
154#define PCI_CHIP_RAGE128RF 0x5246 155#define PCI_CHIP_RAGE128RF 0x5246
155#define PCI_CHIP_RAGE128RG 0x5247 156#define PCI_CHIP_RAGE128RG 0x5247
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index e380ee8b0247..e686185a076d 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -478,7 +478,6 @@ static struct fb_ops aty128fb_ops = {
478 .fb_fillrect = cfb_fillrect, 478 .fb_fillrect = cfb_fillrect,
479 .fb_copyarea = cfb_copyarea, 479 .fb_copyarea = cfb_copyarea,
480 .fb_imageblit = cfb_imageblit, 480 .fb_imageblit = cfb_imageblit,
481 .fb_cursor = soft_cursor,
482}; 481};
483 482
484#ifdef CONFIG_PMAC_BACKLIGHT 483#ifdef CONFIG_PMAC_BACKLIGHT
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 037fe9d32fe3..08edbfcfca58 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -292,7 +292,6 @@ static struct fb_ops atyfb_ops = {
292 .fb_fillrect = atyfb_fillrect, 292 .fb_fillrect = atyfb_fillrect,
293 .fb_copyarea = atyfb_copyarea, 293 .fb_copyarea = atyfb_copyarea,
294 .fb_imageblit = atyfb_imageblit, 294 .fb_imageblit = atyfb_imageblit,
295 .fb_cursor = soft_cursor,
296#ifdef __sparc__ 295#ifdef __sparc__
297 .fb_mmap = atyfb_mmap, 296 .fb_mmap = atyfb_mmap,
298#endif 297#endif
@@ -2157,11 +2156,38 @@ static void __init aty_calc_mem_refresh(struct atyfb_par *par, int xclk)
2157 2156
2158static struct fb_info *fb_list = NULL; 2157static struct fb_info *fb_list = NULL;
2159 2158
2159#if defined(__i386__) && defined(CONFIG_FB_ATY_GENERIC_LCD)
2160static int __devinit atyfb_get_timings_from_lcd(struct atyfb_par *par,
2161 struct fb_var_screeninfo *var)
2162{
2163 int ret = -EINVAL;
2164
2165 if (par->lcd_table != 0 && (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {
2166 *var = default_var;
2167 var->xres = var->xres_virtual = par->lcd_hdisp;
2168 var->right_margin = par->lcd_right_margin;
2169 var->left_margin = par->lcd_hblank_len -
2170 (par->lcd_right_margin + par->lcd_hsync_dly +
2171 par->lcd_hsync_len);
2172 var->hsync_len = par->lcd_hsync_len + par->lcd_hsync_dly;
2173 var->yres = var->yres_virtual = par->lcd_vdisp;
2174 var->lower_margin = par->lcd_lower_margin;
2175 var->upper_margin = par->lcd_vblank_len -
2176 (par->lcd_lower_margin + par->lcd_vsync_len);
2177 var->vsync_len = par->lcd_vsync_len;
2178 var->pixclock = par->lcd_pixclock;
2179 ret = 0;
2180 }
2181
2182 return ret;
2183}
2184#endif /* defined(__i386__) && defined(CONFIG_FB_ATY_GENERIC_LCD) */
2185
2160static int __init aty_init(struct fb_info *info, const char *name) 2186static int __init aty_init(struct fb_info *info, const char *name)
2161{ 2187{
2162 struct atyfb_par *par = (struct atyfb_par *) info->par; 2188 struct atyfb_par *par = (struct atyfb_par *) info->par;
2163 const char *ramname = NULL, *xtal; 2189 const char *ramname = NULL, *xtal;
2164 int gtb_memsize; 2190 int gtb_memsize, has_var = 0;
2165 struct fb_var_screeninfo var; 2191 struct fb_var_screeninfo var;
2166 u8 pll_ref_div; 2192 u8 pll_ref_div;
2167 u32 i; 2193 u32 i;
@@ -2469,8 +2495,8 @@ static int __init aty_init(struct fb_info *info, const char *name)
2469 * applies to all Mac video cards 2495 * applies to all Mac video cards
2470 */ 2496 */
2471 if (mode) { 2497 if (mode) {
2472 if (!mac_find_mode(&var, info, mode, 8)) 2498 if (mac_find_mode(&var, info, mode, 8))
2473 var = default_var; 2499 has_var = 1;
2474 } else { 2500 } else {
2475 if (default_vmode == VMODE_CHOOSE) { 2501 if (default_vmode == VMODE_CHOOSE) {
2476 if (M64_HAS(G3_PB_1024x768)) 2502 if (M64_HAS(G3_PB_1024x768))
@@ -2492,20 +2518,23 @@ static int __init aty_init(struct fb_info *info, const char *name)
2492 default_vmode = VMODE_640_480_60; 2518 default_vmode = VMODE_640_480_60;
2493 if (default_cmode < CMODE_8 || default_cmode > CMODE_32) 2519 if (default_cmode < CMODE_8 || default_cmode > CMODE_32)
2494 default_cmode = CMODE_8; 2520 default_cmode = CMODE_8;
2495 if (mac_vmode_to_var(default_vmode, default_cmode, &var)) 2521 if (!mac_vmode_to_var(default_vmode, default_cmode,
2496 var = default_var; 2522 &var))
2523 has_var = 1;
2497 } 2524 }
2498 } else 2525 }
2526
2499#endif /* !CONFIG_PPC */ 2527#endif /* !CONFIG_PPC */
2500 if ( 2528
2501#if defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64) 2529#if defined(__i386__) && defined(CONFIG_FB_ATY_GENERIC_LCD)
2502 /* On Sparc, unless the user gave a specific mode 2530 if (!atyfb_get_timings_from_lcd(par, &var))
2503 * specification, use the PROM probed values in 2531 has_var = 1;
2504 * default_var.
2505 */
2506 !mode ||
2507#endif 2532#endif
2508 !fb_find_mode(&var, info, mode, NULL, 0, &defmode, 8)) 2533
2534 if (mode && fb_find_mode(&var, info, mode, NULL, 0, &defmode, 8))
2535 has_var = 1;
2536
2537 if (!has_var)
2509 var = default_var; 2538 var = default_var;
2510 2539
2511 if (noaccel) 2540 if (noaccel)
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 8a24a66d9ba8..4f01ccc02aa4 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -69,7 +69,6 @@
69#include <linux/pci.h> 69#include <linux/pci.h>
70#include <linux/vmalloc.h> 70#include <linux/vmalloc.h>
71#include <linux/device.h> 71#include <linux/device.h>
72#include <linux/i2c.h>
73 72
74#include <asm/io.h> 73#include <asm/io.h>
75#include <asm/uaccess.h> 74#include <asm/uaccess.h>
@@ -113,6 +112,7 @@ static struct pci_device_id radeonfb_pci_table[] = {
113 /* Radeon VE/7000 */ 112 /* Radeon VE/7000 */
114 CHIP_DEF(PCI_CHIP_RV100_QY, RV100, CHIP_HAS_CRTC2), 113 CHIP_DEF(PCI_CHIP_RV100_QY, RV100, CHIP_HAS_CRTC2),
115 CHIP_DEF(PCI_CHIP_RV100_QZ, RV100, CHIP_HAS_CRTC2), 114 CHIP_DEF(PCI_CHIP_RV100_QZ, RV100, CHIP_HAS_CRTC2),
115 CHIP_DEF(PCI_CHIP_RN50, RV100, CHIP_HAS_CRTC2),
116 /* Radeon IGP320M (U1) */ 116 /* Radeon IGP320M (U1) */
117 CHIP_DEF(PCI_CHIP_RS100_4336, RS100, CHIP_HAS_CRTC2 | CHIP_IS_IGP | CHIP_IS_MOBILITY), 117 CHIP_DEF(PCI_CHIP_RS100_4336, RS100, CHIP_HAS_CRTC2 | CHIP_IS_IGP | CHIP_IS_MOBILITY),
118 /* Radeon IGP320 (A3) */ 118 /* Radeon IGP320 (A3) */
@@ -1874,7 +1874,6 @@ static struct fb_ops radeonfb_ops = {
1874 .fb_fillrect = radeonfb_fillrect, 1874 .fb_fillrect = radeonfb_fillrect,
1875 .fb_copyarea = radeonfb_copyarea, 1875 .fb_copyarea = radeonfb_copyarea,
1876 .fb_imageblit = radeonfb_imageblit, 1876 .fb_imageblit = radeonfb_imageblit,
1877 .fb_cursor = soft_cursor,
1878}; 1877};
1879 1878
1880 1879
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
index 01b8b2f78514..217e00ab4a2d 100644
--- a/drivers/video/aty/radeonfb.h
+++ b/drivers/video/aty/radeonfb.h
@@ -10,9 +10,10 @@
10#include <linux/fb.h> 10#include <linux/fb.h>
11 11
12 12
13#ifdef CONFIG_FB_RADEON_I2C
13#include <linux/i2c.h> 14#include <linux/i2c.h>
14#include <linux/i2c-id.h>
15#include <linux/i2c-algo-bit.h> 15#include <linux/i2c-algo-bit.h>
16#endif
16 17
17#include <asm/io.h> 18#include <asm/io.h>
18 19
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index 3d20b2d47d46..f53bf3ba1278 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -51,7 +51,6 @@ 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 .fb_cursor = soft_cursor,
55}; 54};
56 55
57/* OBio addresses for the bwtwo registers */ 56/* OBio addresses for the bwtwo registers */
diff --git a/drivers/video/cfbcopyarea.c b/drivers/video/cfbcopyarea.c
index 67711f7b11b1..cdc71572cf35 100644
--- a/drivers/video/cfbcopyarea.c
+++ b/drivers/video/cfbcopyarea.c
@@ -349,46 +349,10 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
349 unsigned long __iomem *dst = NULL, *src = NULL; 349 unsigned long __iomem *dst = NULL, *src = NULL;
350 int bits = BITS_PER_LONG, bytes = bits >> 3; 350 int bits = BITS_PER_LONG, bytes = bits >> 3;
351 int dst_idx = 0, src_idx = 0, rev_copy = 0; 351 int dst_idx = 0, src_idx = 0, rev_copy = 0;
352 int x2, y2, vxres, vyres;
353 352
354 if (p->state != FBINFO_STATE_RUNNING) 353 if (p->state != FBINFO_STATE_RUNNING)
355 return; 354 return;
356 355
357 /* We want rotation but lack hardware to do it for us. */
358 if (!p->fbops->fb_rotate && p->var.rotate) {
359 }
360
361 vxres = p->var.xres_virtual;
362 vyres = p->var.yres_virtual;
363
364 if (area->dx > vxres || area->sx > vxres ||
365 area->dy > vyres || area->sy > vyres)
366 return;
367
368 /* clip the destination
369 * We could use hardware clipping but on many cards you get around
370 * hardware clipping by writing to framebuffer directly.
371 */
372 x2 = area->dx + area->width;
373 y2 = area->dy + area->height;
374 dx = area->dx > 0 ? area->dx : 0;
375 dy = area->dy > 0 ? area->dy : 0;
376 x2 = x2 < vxres ? x2 : vxres;
377 y2 = y2 < vyres ? y2 : vyres;
378 width = x2 - dx;
379 height = y2 - dy;
380
381 if ((width==0) ||(height==0))
382 return;
383
384 /* update sx1,sy1 */
385 sx += (dx - area->dx);
386 sy += (dy - area->dy);
387
388 /* the source must be completely inside the virtual screen */
389 if (sx < 0 || sy < 0 || (sx + width) > vxres || (sy + height) > vyres)
390 return;
391
392 /* if the beginning of the target area might overlap with the end of 356 /* if the beginning of the target area might overlap with the end of
393 the source area, be have to copy the area reverse. */ 357 the source area, be have to copy the area reverse. */
394 if ((dy == sy && dx > sx) || (dy > sy)) { 358 if ((dy == sy && dx > sx) || (dy > sy)) {
diff --git a/drivers/video/cfbfillrect.c b/drivers/video/cfbfillrect.c
index e4fc42b013eb..167d9314e6eb 100644
--- a/drivers/video/cfbfillrect.c
+++ b/drivers/video/cfbfillrect.c
@@ -344,7 +344,8 @@ bitfill_unaligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat
344 344
345void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect) 345void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
346{ 346{
347 unsigned long x2, y2, vxres, vyres, height, width, pat, fg; 347 unsigned long pat, fg;
348 unsigned long width = rect->width, height = rect->height;
348 int bits = BITS_PER_LONG, bytes = bits >> 3; 349 int bits = BITS_PER_LONG, bytes = bits >> 3;
349 u32 bpp = p->var.bits_per_pixel; 350 u32 bpp = p->var.bits_per_pixel;
350 unsigned long __iomem *dst; 351 unsigned long __iomem *dst;
@@ -353,27 +354,6 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
353 if (p->state != FBINFO_STATE_RUNNING) 354 if (p->state != FBINFO_STATE_RUNNING)
354 return; 355 return;
355 356
356 /* We want rotation but lack hardware to do it for us. */
357 if (!p->fbops->fb_rotate && p->var.rotate) {
358 }
359
360 vxres = p->var.xres_virtual;
361 vyres = p->var.yres_virtual;
362
363 if (!rect->width || !rect->height ||
364 rect->dx > vxres || rect->dy > vyres)
365 return;
366
367 /* We could use hardware clipping but on many cards you get around
368 * hardware clipping by writing to framebuffer directly. */
369
370 x2 = rect->dx + rect->width;
371 y2 = rect->dy + rect->height;
372 x2 = x2 < vxres ? x2 : vxres;
373 y2 = y2 < vyres ? y2 : vyres;
374 width = x2 - rect->dx;
375 height = y2 - rect->dy;
376
377 if (p->fix.visual == FB_VISUAL_TRUECOLOR || 357 if (p->fix.visual == FB_VISUAL_TRUECOLOR ||
378 p->fix.visual == FB_VISUAL_DIRECTCOLOR ) 358 p->fix.visual == FB_VISUAL_DIRECTCOLOR )
379 fg = ((u32 *) (p->pseudo_palette))[rect->color]; 359 fg = ((u32 *) (p->pseudo_palette))[rect->color];
diff --git a/drivers/video/cfbimgblt.c b/drivers/video/cfbimgblt.c
index 4c123abaa843..da664cea7eca 100644
--- a/drivers/video/cfbimgblt.c
+++ b/drivers/video/cfbimgblt.c
@@ -272,33 +272,13 @@ void cfb_imageblit(struct fb_info *p, const struct fb_image *image)
272{ 272{
273 u32 fgcolor, bgcolor, start_index, bitstart, pitch_index = 0; 273 u32 fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
274 u32 bpl = sizeof(u32), bpp = p->var.bits_per_pixel; 274 u32 bpl = sizeof(u32), bpp = p->var.bits_per_pixel;
275 u32 width = image->width, height = image->height; 275 u32 width = image->width;
276 u32 dx = image->dx, dy = image->dy; 276 u32 dx = image->dx, dy = image->dy;
277 int x2, y2, vxres, vyres;
278 u8 __iomem *dst1; 277 u8 __iomem *dst1;
279 278
280 if (p->state != FBINFO_STATE_RUNNING) 279 if (p->state != FBINFO_STATE_RUNNING)
281 return; 280 return;
282 281
283 vxres = p->var.xres_virtual;
284 vyres = p->var.yres_virtual;
285 /*
286 * We could use hardware clipping but on many cards you get around
287 * hardware clipping by writing to framebuffer directly like we are
288 * doing here.
289 */
290 if (image->dx > vxres || image->dy > vyres)
291 return;
292
293 x2 = image->dx + image->width;
294 y2 = image->dy + image->height;
295 dx = image->dx > 0 ? image->dx : 0;
296 dy = image->dy > 0 ? image->dy : 0;
297 x2 = x2 < vxres ? x2 : vxres;
298 y2 = y2 < vyres ? y2 : vyres;
299 width = x2 - dx;
300 height = y2 - dy;
301
302 bitstart = (dy * p->fix.line_length * 8) + (dx * bpp); 282 bitstart = (dy * p->fix.line_length * 8) + (dx * bpp);
303 start_index = bitstart & (32 - 1); 283 start_index = bitstart & (32 - 1);
304 pitch_index = (p->fix.line_length & (bpl - 1)) * 8; 284 pitch_index = (p->fix.line_length & (bpl - 1)) * 8;
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c
index 18e60b941e21..030d4b13b1c2 100644
--- a/drivers/video/cg14.c
+++ b/drivers/video/cg14.c
@@ -49,7 +49,6 @@ 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 .fb_cursor = soft_cursor,
53}; 52};
54 53
55#define CG14_MCR_INTENABLE_SHIFT 7 54#define CG14_MCR_INTENABLE_SHIFT 7
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index 6e7d8d45dc68..b94eee8c42d5 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -50,7 +50,6 @@ 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 .fb_cursor = soft_cursor,
54}; 53};
55 54
56 55
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c
index 49a2545671d9..414c4409e924 100644
--- a/drivers/video/cg6.c
+++ b/drivers/video/cg6.c
@@ -54,7 +54,6 @@ 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 .fb_cursor = soft_cursor,
58}; 57};
59 58
60/* Offset of interesting structures in the OBIO space */ 59/* Offset of interesting structures in the OBIO space */
@@ -654,12 +653,6 @@ static void cg6_chip_init(struct fb_info *info)
654 sbus_writel(0, &fbc->clipminy); 653 sbus_writel(0, &fbc->clipminy);
655 sbus_writel(info->var.xres - 1, &fbc->clipmaxx); 654 sbus_writel(info->var.xres - 1, &fbc->clipmaxx);
656 sbus_writel(info->var.yres - 1, &fbc->clipmaxy); 655 sbus_writel(info->var.yres - 1, &fbc->clipmaxy);
657
658 /* Disable cursor in Brooktree DAC. */
659 sbus_writel(0x06 << 24, &par->bt->addr);
660 tmp = sbus_readl(&par->bt->control);
661 tmp &= ~(0x03 << 24);
662 sbus_writel(tmp, &par->bt->control);
663} 656}
664 657
665struct all_info { 658struct all_info {
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
index 4131243cfdf8..bc061d4ec786 100644
--- a/drivers/video/chipsfb.c
+++ b/drivers/video/chipsfb.c
@@ -91,7 +91,6 @@ static struct fb_ops chipsfb_ops = {
91 .fb_fillrect = cfb_fillrect, 91 .fb_fillrect = cfb_fillrect,
92 .fb_copyarea = cfb_copyarea, 92 .fb_copyarea = cfb_copyarea,
93 .fb_imageblit = cfb_imageblit, 93 .fb_imageblit = cfb_imageblit,
94 .fb_cursor = soft_cursor,
95}; 94};
96 95
97static int chipsfb_check_var(struct fb_var_screeninfo *var, 96static int chipsfb_check_var(struct fb_var_screeninfo *var,
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index 3a26f9cc8585..2858c5c8ba3c 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -548,7 +548,6 @@ static struct fb_ops cirrusfb_ops = {
548 .fb_fillrect = cirrusfb_fillrect, 548 .fb_fillrect = cirrusfb_fillrect,
549 .fb_copyarea = cirrusfb_copyarea, 549 .fb_copyarea = cirrusfb_copyarea,
550 .fb_imageblit = cirrusfb_imageblit, 550 .fb_imageblit = cirrusfb_imageblit,
551 .fb_cursor = soft_cursor,
552}; 551};
553 552
554/*--- Hardware Specific Routines -------------------------------------------*/ 553/*--- Hardware Specific Routines -------------------------------------------*/
diff --git a/drivers/video/clps711xfb.c b/drivers/video/clps711xfb.c
index 8692e002986b..50b78af0fa24 100644
--- a/drivers/video/clps711xfb.c
+++ b/drivers/video/clps711xfb.c
@@ -219,7 +219,6 @@ static struct fb_ops clps7111fb_ops = {
219 .fb_fillrect = cfb_fillrect, 219 .fb_fillrect = cfb_fillrect,
220 .fb_copyarea = cfb_copyarea, 220 .fb_copyarea = cfb_copyarea,
221 .fb_imageblit = cfb_imageblit, 221 .fb_imageblit = cfb_imageblit,
222 .fb_cursor = soft_cursor,
223}; 222};
224 223
225static int 224static int
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 6a9ae2b3d1ab..fadf7c5d216e 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -98,6 +98,8 @@ config FRAMEBUFFER_CONSOLE
98 tristate "Framebuffer Console support" 98 tristate "Framebuffer Console support"
99 depends on FB 99 depends on FB
100 select CRC32 100 select CRC32
101 help
102 Low-level framebuffer-based console driver.
101 103
102config STI_CONSOLE 104config STI_CONSOLE
103 tristate "STI text console" 105 tristate "STI text console"
@@ -203,5 +205,12 @@ config FONT_10x18
203 big letters. It fits between the sun 12x22 and the normal 8x16 font. 205 big letters. It fits between the sun 12x22 and the normal 8x16 font.
204 If other fonts are too big or too small for you, say Y, otherwise say N. 206 If other fonts are too big or too small for you, say Y, otherwise say N.
205 207
208config FONT_RL
209 bool "console Roman Large 8x16 font" if FONTS
210 depends on FRAMEBUFFER_CONSOLE
211 help
212 This is the visually-appealing "RL" console font that is
213 included with the kbd package.
214
206endmenu 215endmenu
207 216
diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
index 42c7b8dcd220..5222628accce 100644
--- a/drivers/video/console/Makefile
+++ b/drivers/video/console/Makefile
@@ -15,6 +15,7 @@ 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
18 19
19font-objs += $(font-objs-y) 20font-objs += $(font-objs-y)
20 21
@@ -26,7 +27,7 @@ obj-$(CONFIG_PROM_CONSOLE) += promcon.o promcon_tbl.o
26obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o font.o 27obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o font.o
27obj-$(CONFIG_VGA_CONSOLE) += vgacon.o 28obj-$(CONFIG_VGA_CONSOLE) += vgacon.o
28obj-$(CONFIG_MDA_CONSOLE) += mdacon.o 29obj-$(CONFIG_MDA_CONSOLE) += mdacon.o
29obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon.o bitblit.o font.o 30obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon.o bitblit.o font.o softcursor.o
30ifeq ($(CONFIG_FB_TILEBLITTING),y) 31ifeq ($(CONFIG_FB_TILEBLITTING),y)
31obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += tileblit.o 32obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += tileblit.o
32endif 33endif
diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
index 9f70e512b88b..67857b3cfc8b 100644
--- a/drivers/video/console/bitblit.c
+++ b/drivers/video/console/bitblit.c
@@ -272,6 +272,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info,
272 int w = (vc->vc_font.width + 7) >> 3, c; 272 int w = (vc->vc_font.width + 7) >> 3, c;
273 int y = real_y(p, vc->vc_y); 273 int y = real_y(p, vc->vc_y);
274 int attribute, use_sw = (vc->vc_cursor_type & 0x10); 274 int attribute, use_sw = (vc->vc_cursor_type & 0x10);
275 int err = 1;
275 char *src; 276 char *src;
276 277
277 cursor.set = 0; 278 cursor.set = 0;
@@ -408,7 +409,11 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info,
408 cursor.image.depth = 1; 409 cursor.image.depth = 1;
409 cursor.rop = ROP_XOR; 410 cursor.rop = ROP_XOR;
410 411
411 info->fbops->fb_cursor(info, &cursor); 412 if (info->fbops->fb_cursor)
413 err = info->fbops->fb_cursor(info, &cursor);
414
415 if (err)
416 soft_cursor(info, &cursor);
412 417
413 ops->cursor_reset = 0; 418 ops->cursor_reset = 0;
414} 419}
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 0fc8bb499c3f..3cf1b61ff1f8 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -281,6 +281,18 @@ static inline int get_color(struct vc_data *vc, struct fb_info *info,
281 return color; 281 return color;
282} 282}
283 283
284static void fbcon_update_softback(struct vc_data *vc)
285{
286 int l = fbcon_softback_size / vc->vc_size_row;
287
288 if (l > 5)
289 softback_end = softback_buf + l * vc->vc_size_row;
290 else
291 /* Smaller scrollback makes no sense, and 0 would screw
292 the operation totally */
293 softback_top = 0;
294}
295
284static void fb_flashcursor(void *private) 296static void fb_flashcursor(void *private)
285{ 297{
286 struct fb_info *info = private; 298 struct fb_info *info = private;
@@ -618,6 +630,15 @@ static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
618 kfree(oldinfo->fbcon_par); 630 kfree(oldinfo->fbcon_par);
619 oldinfo->fbcon_par = NULL; 631 oldinfo->fbcon_par = NULL;
620 module_put(oldinfo->fbops->owner); 632 module_put(oldinfo->fbops->owner);
633 /*
634 If oldinfo and newinfo are driving the same hardware,
635 the fb_release() method of oldinfo may attempt to
636 restore the hardware state. This will leave the
637 newinfo in an undefined state. Thus, a call to
638 fb_set_par() may be needed for the newinfo.
639 */
640 if (newinfo->fbops->fb_set_par)
641 newinfo->fbops->fb_set_par(newinfo);
621 } 642 }
622 643
623 return err; 644 return err;
@@ -1007,16 +1028,8 @@ static void fbcon_init(struct vc_data *vc, int init)
1007 if (logo) 1028 if (logo)
1008 fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows); 1029 fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
1009 1030
1010 if (vc == svc && softback_buf) { 1031 if (vc == svc && softback_buf)
1011 int l = fbcon_softback_size / vc->vc_size_row; 1032 fbcon_update_softback(vc);
1012 if (l > 5)
1013 softback_end = softback_buf + l * vc->vc_size_row;
1014 else {
1015 /* Smaller scrollback makes no sense, and 0 would screw
1016 the operation totally */
1017 softback_top = 0;
1018 }
1019 }
1020} 1033}
1021 1034
1022static void fbcon_deinit(struct vc_data *vc) 1035static void fbcon_deinit(struct vc_data *vc)
@@ -1223,18 +1236,8 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
1223 vc_resize(vc, cols, rows); 1236 vc_resize(vc, cols, rows);
1224 if (CON_IS_VISIBLE(vc)) { 1237 if (CON_IS_VISIBLE(vc)) {
1225 update_screen(vc); 1238 update_screen(vc);
1226 if (softback_buf) { 1239 if (softback_buf)
1227 int l = fbcon_softback_size / vc->vc_size_row; 1240 fbcon_update_softback(vc);
1228
1229 if (l > 5)
1230 softback_end = softback_buf + l *
1231 vc->vc_size_row;
1232 else {
1233 /* Smaller scrollback makes no sense, and 0
1234 would screw the operation totally */
1235 softback_top = 0;
1236 }
1237 }
1238 } 1241 }
1239} 1242}
1240 1243
@@ -1892,24 +1895,11 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
1892 mode = fb_find_best_mode(&var, &info->modelist); 1895 mode = fb_find_best_mode(&var, &info->modelist);
1893 if (mode == NULL) 1896 if (mode == NULL)
1894 return -EINVAL; 1897 return -EINVAL;
1898 display_to_var(&var, p);
1895 fb_videomode_to_var(&var, mode); 1899 fb_videomode_to_var(&var, mode);
1900
1896 if (width > var.xres/fw || height > var.yres/fh) 1901 if (width > var.xres/fw || height > var.yres/fh)
1897 return -EINVAL; 1902 return -EINVAL;
1898 /*
1899 * The following can probably have any value... Do we need to
1900 * set all of them?
1901 */
1902 var.bits_per_pixel = p->bits_per_pixel;
1903 var.xres_virtual = p->xres_virtual;
1904 var.yres_virtual = p->yres_virtual;
1905 var.accel_flags = p->accel_flags;
1906 var.width = p->width;
1907 var.height = p->height;
1908 var.red = p->red;
1909 var.green = p->green;
1910 var.blue = p->blue;
1911 var.transp = p->transp;
1912 var.nonstd = p->nonstd;
1913 1903
1914 DPRINTK("resize now %ix%i\n", var.xres, var.yres); 1904 DPRINTK("resize now %ix%i\n", var.xres, var.yres);
1915 if (CON_IS_VISIBLE(vc)) { 1905 if (CON_IS_VISIBLE(vc)) {
@@ -1933,19 +1923,11 @@ static int fbcon_switch(struct vc_data *vc)
1933 info = registered_fb[con2fb_map[vc->vc_num]]; 1923 info = registered_fb[con2fb_map[vc->vc_num]];
1934 1924
1935 if (softback_top) { 1925 if (softback_top) {
1936 int l = fbcon_softback_size / vc->vc_size_row;
1937 if (softback_lines) 1926 if (softback_lines)
1938 fbcon_set_origin(vc); 1927 fbcon_set_origin(vc);
1939 softback_top = softback_curr = softback_in = softback_buf; 1928 softback_top = softback_curr = softback_in = softback_buf;
1940 softback_lines = 0; 1929 softback_lines = 0;
1941 1930 fbcon_update_softback(vc);
1942 if (l > 5)
1943 softback_end = softback_buf + l * vc->vc_size_row;
1944 else {
1945 /* Smaller scrollback makes no sense, and 0 would screw
1946 the operation totally */
1947 softback_top = 0;
1948 }
1949 } 1931 }
1950 1932
1951 if (logo_shown >= 0) { 1933 if (logo_shown >= 0) {
@@ -2235,17 +2217,8 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2235 /* reset wrap/pan */ 2217 /* reset wrap/pan */
2236 info->var.xoffset = info->var.yoffset = p->yscroll = 0; 2218 info->var.xoffset = info->var.yoffset = p->yscroll = 0;
2237 vc_resize(vc, info->var.xres / w, info->var.yres / h); 2219 vc_resize(vc, info->var.xres / w, info->var.yres / h);
2238 if (CON_IS_VISIBLE(vc) && softback_buf) { 2220 if (CON_IS_VISIBLE(vc) && softback_buf)
2239 int l = fbcon_softback_size / vc->vc_size_row; 2221 fbcon_update_softback(vc);
2240 if (l > 5)
2241 softback_end =
2242 softback_buf + l * vc->vc_size_row;
2243 else {
2244 /* Smaller scrollback makes no sense, and 0 would screw
2245 the operation totally */
2246 softback_top = 0;
2247 }
2248 }
2249 } else if (CON_IS_VISIBLE(vc) 2222 } else if (CON_IS_VISIBLE(vc)
2250 && vc->vc_mode == KD_TEXT) { 2223 && vc->vc_mode == KD_TEXT) {
2251 fbcon_clear_margins(vc, 0); 2224 fbcon_clear_margins(vc, 0);
@@ -2615,16 +2588,8 @@ static void fbcon_modechanged(struct fb_info *info)
2615 update_var(vc->vc_num, info); 2588 update_var(vc->vc_num, info);
2616 fbcon_set_palette(vc, color_table); 2589 fbcon_set_palette(vc, color_table);
2617 update_screen(vc); 2590 update_screen(vc);
2618 if (softback_buf) { 2591 if (softback_buf)
2619 int l = fbcon_softback_size / vc->vc_size_row; 2592 fbcon_update_softback(vc);
2620 if (l > 5)
2621 softback_end = softback_buf + l * vc->vc_size_row;
2622 else {
2623 /* Smaller scrollback makes no sense, and 0
2624 would screw the operation totally */
2625 softback_top = 0;
2626 }
2627 }
2628 } 2593 }
2629} 2594}
2630 2595
@@ -2659,16 +2624,8 @@ static void fbcon_set_all_vcs(struct fb_info *info)
2659 update_var(vc->vc_num, info); 2624 update_var(vc->vc_num, info);
2660 fbcon_set_palette(vc, color_table); 2625 fbcon_set_palette(vc, color_table);
2661 update_screen(vc); 2626 update_screen(vc);
2662 if (softback_buf) { 2627 if (softback_buf)
2663 int l = fbcon_softback_size / vc->vc_size_row; 2628 fbcon_update_softback(vc);
2664 if (l > 5)
2665 softback_end = softback_buf + l * vc->vc_size_row;
2666 else {
2667 /* Smaller scrollback makes no sense, and 0
2668 would screw the operation totally */
2669 softback_top = 0;
2670 }
2671 }
2672 } 2629 }
2673 } 2630 }
2674} 2631}
@@ -2758,7 +2715,8 @@ static void fbcon_new_modelist(struct fb_info *info)
2758 continue; 2715 continue;
2759 vc = vc_cons[i].d; 2716 vc = vc_cons[i].d;
2760 display_to_var(&var, &fb_display[i]); 2717 display_to_var(&var, &fb_display[i]);
2761 mode = fb_find_nearest_mode(&var, &info->modelist); 2718 mode = fb_find_nearest_mode(fb_display[i].mode,
2719 &info->modelist);
2762 fb_videomode_to_var(&var, mode); 2720 fb_videomode_to_var(&var, mode);
2763 2721
2764 if (vc) 2722 if (vc)
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index 0738cd62def2..b68e0e2c2d16 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -167,5 +167,5 @@ extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info,
167 struct display *p, struct fbcon_ops *ops); 167 struct display *p, struct fbcon_ops *ops);
168#endif 168#endif
169extern void fbcon_set_bitops(struct fbcon_ops *ops); 169extern void fbcon_set_bitops(struct fbcon_ops *ops);
170 170extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
171#endif /* _VIDEO_FBCON_H */ 171#endif /* _VIDEO_FBCON_H */
diff --git a/drivers/video/console/font_rl.c b/drivers/video/console/font_rl.c
new file mode 100644
index 000000000000..dfecc27d8ded
--- /dev/null
+++ b/drivers/video/console/font_rl.c
@@ -0,0 +1,4374 @@
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 4fd07d9eca03..9be83bed1959 100644
--- a/drivers/video/console/fonts.c
+++ b/drivers/video/console/fonts.c
@@ -64,6 +64,10 @@ 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
67}; 71};
68 72
69#define num_fonts (sizeof(fonts)/sizeof(*fonts)) 73#define num_fonts (sizeof(fonts)/sizeof(*fonts))
diff --git a/drivers/video/softcursor.c b/drivers/video/console/softcursor.c
index 229c4bc35079..8529bf08db28 100644
--- a/drivers/video/softcursor.c
+++ b/drivers/video/console/softcursor.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/drivers/video/softcursor.c -- Generic software cursor for frame buffer devices 2 * linux/drivers/video/softcursor.c -- Generic software cursor for frame buffer devices
3 * 3 *
4 * Created 14 Nov 2002 by James Simmons 4 * Created 14 Nov 2002 by James Simmons
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive 7 * License. See the file COPYING in the main directory of this archive
@@ -55,9 +55,9 @@ int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
55 src[i] = image->data[i] & cursor->mask[i]; 55 src[i] = image->data[i] & cursor->mask[i];
56 break; 56 break;
57 } 57 }
58 } else 58 } else
59 memcpy(src, image->data, dsize); 59 memcpy(src, image->data, dsize);
60 60
61 fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height); 61 fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height);
62 image->data = dst; 62 image->data = dst;
63 info->fbops->fb_imageblit(info, image); 63 info->fbops->fb_imageblit(info, image);
@@ -66,7 +66,7 @@ int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
66} 66}
67 67
68EXPORT_SYMBOL(soft_cursor); 68EXPORT_SYMBOL(soft_cursor);
69 69
70MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>"); 70MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
71MODULE_DESCRIPTION("Generic software cursor"); 71MODULE_DESCRIPTION("Generic software cursor");
72MODULE_LICENSE("GPL"); 72MODULE_LICENSE("GPL");
diff --git a/drivers/video/controlfb.c b/drivers/video/controlfb.c
index 989e700159e0..403d17377f8d 100644
--- a/drivers/video/controlfb.c
+++ b/drivers/video/controlfb.c
@@ -176,7 +176,6 @@ static struct fb_ops controlfb_ops = {
176 .fb_fillrect = cfb_fillrect, 176 .fb_fillrect = cfb_fillrect,
177 .fb_copyarea = cfb_copyarea, 177 .fb_copyarea = cfb_copyarea,
178 .fb_imageblit = cfb_imageblit, 178 .fb_imageblit = cfb_imageblit,
179 .fb_cursor = soft_cursor,
180}; 179};
181 180
182 181
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index 3894b2a501d6..c589d23e7f91 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -1064,7 +1064,6 @@ static struct fb_ops cyber2000fb_ops = {
1064 .fb_fillrect = cyber2000fb_fillrect, 1064 .fb_fillrect = cyber2000fb_fillrect,
1065 .fb_copyarea = cyber2000fb_copyarea, 1065 .fb_copyarea = cyber2000fb_copyarea,
1066 .fb_imageblit = cyber2000fb_imageblit, 1066 .fb_imageblit = cyber2000fb_imageblit,
1067 .fb_cursor = soft_cursor,
1068 .fb_sync = cyber2000fb_sync, 1067 .fb_sync = cyber2000fb_sync,
1069}; 1068};
1070 1069
diff --git a/drivers/video/cyblafb.c b/drivers/video/cyblafb.c
index 6992100a508c..03fbe83d71a8 100644
--- a/drivers/video/cyblafb.c
+++ b/drivers/video/cyblafb.c
@@ -968,7 +968,6 @@ static struct fb_ops cyblafb_ops __devinitdata = {
968 .fb_fillrect = cyblafb_fillrect, 968 .fb_fillrect = cyblafb_fillrect,
969 .fb_copyarea= cyblafb_copyarea, 969 .fb_copyarea= cyblafb_copyarea,
970 .fb_imageblit = cyblafb_imageblit, 970 .fb_imageblit = cyblafb_imageblit,
971 .fb_cursor = soft_cursor,
972}; 971};
973 972
974//========================================================================== 973//==========================================================================
diff --git a/drivers/video/dnfb.c b/drivers/video/dnfb.c
index 1785686a7f11..957a3ada2b75 100644
--- a/drivers/video/dnfb.c
+++ b/drivers/video/dnfb.c
@@ -116,7 +116,6 @@ static struct fb_ops dn_fb_ops = {
116 .fb_fillrect = cfb_fillrect, 116 .fb_fillrect = cfb_fillrect,
117 .fb_copyarea = dnfb_copyarea, 117 .fb_copyarea = dnfb_copyarea,
118 .fb_imageblit = cfb_imageblit, 118 .fb_imageblit = cfb_imageblit,
119 .fb_cursor = soft_cursor,
120}; 119};
121 120
122struct fb_var_screeninfo dnfb_var __devinitdata = { 121struct fb_var_screeninfo dnfb_var __devinitdata = {
diff --git a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
index 7363d0b25fdf..6a81a1dd8f3d 100644
--- a/drivers/video/epson1355fb.c
+++ b/drivers/video/epson1355fb.c
@@ -484,7 +484,6 @@ static struct fb_ops epson1355fb_fbops = {
484 .fb_imageblit = cfb_imageblit, 484 .fb_imageblit = cfb_imageblit,
485 .fb_read = epson1355fb_read, 485 .fb_read = epson1355fb_read,
486 .fb_write = epson1355fb_write, 486 .fb_write = epson1355fb_write,
487 .fb_cursor = soft_cursor,
488}; 487};
489 488
490/* ------------------------------------------------------------------------- */ 489/* ------------------------------------------------------------------------- */
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 713226cdf3c6..fc7965b66775 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -538,25 +538,12 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize)
538 538
539 *dbsize = 0; 539 *dbsize = 0;
540 540
541 DPRINTK(" Supported VESA Modes\n");
542 block = edid + ESTABLISHED_TIMING_1;
543 num += get_est_timing(block, &mode[num]);
544
545 DPRINTK(" Standard Timings\n");
546 block = edid + STD_TIMING_DESCRIPTIONS_START;
547 for (i = 0; i < STD_TIMING; i++, block += STD_TIMING_DESCRIPTION_SIZE)
548 num += get_std_timing(block, &mode[num]);
549
550 DPRINTK(" Detailed Timings\n"); 541 DPRINTK(" Detailed Timings\n");
551 block = edid + DETAILED_TIMING_DESCRIPTIONS_START; 542 block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
552 for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE) { 543 for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE) {
553 int first = 1; 544 int first = 1;
554 545
555 if (block[0] == 0x00 && block[1] == 0x00) { 546 if (!(block[0] == 0x00 && block[1] == 0x00)) {
556 if (block[3] == 0xfa) {
557 num += get_dst_timing(block + 5, &mode[num]);
558 }
559 } else {
560 get_detailed_timing(block, &mode[num]); 547 get_detailed_timing(block, &mode[num]);
561 if (first) { 548 if (first) {
562 mode[num].flag |= FB_MODE_IS_FIRST; 549 mode[num].flag |= FB_MODE_IS_FIRST;
@@ -565,6 +552,21 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize)
565 num++; 552 num++;
566 } 553 }
567 } 554 }
555
556 DPRINTK(" Supported VESA Modes\n");
557 block = edid + ESTABLISHED_TIMING_1;
558 num += get_est_timing(block, &mode[num]);
559
560 DPRINTK(" Standard Timings\n");
561 block = edid + STD_TIMING_DESCRIPTIONS_START;
562 for (i = 0; i < STD_TIMING; i++, block += STD_TIMING_DESCRIPTION_SIZE)
563 num += get_std_timing(block, &mode[num]);
564
565 block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
566 for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE) {
567 if (block[0] == 0x00 && block[1] == 0x00 && block[3] == 0xfa)
568 num += get_dst_timing(block + 5, &mode[num]);
569 }
568 570
569 /* Yikes, EDID data is totally useless */ 571 /* Yikes, EDID data is totally useless */
570 if (!num) { 572 if (!num) {
@@ -827,7 +829,7 @@ int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var)
827void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs) 829void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
828{ 830{
829 unsigned char *block; 831 unsigned char *block;
830 int i; 832 int i, found = 0;
831 833
832 if (edid == NULL) 834 if (edid == NULL)
833 return; 835 return;
@@ -869,6 +871,22 @@ void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
869 get_monspecs(edid, specs); 871 get_monspecs(edid, specs);
870 872
871 specs->modedb = fb_create_modedb(edid, &specs->modedb_len); 873 specs->modedb = fb_create_modedb(edid, &specs->modedb_len);
874
875 /*
876 * Workaround for buggy EDIDs that sets that the first
877 * detailed timing is preferred but has not detailed
878 * timing specified
879 */
880 for (i = 0; i < specs->modedb_len; i++) {
881 if (specs->modedb[i].flag & FB_MODE_IS_DETAILED) {
882 found = 1;
883 break;
884 }
885 }
886
887 if (!found)
888 specs->misc &= ~FB_MISC_1ST_DETAIL;
889
872 DPRINTK("========================================\n"); 890 DPRINTK("========================================\n");
873} 891}
874 892
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 10cd05059fe9..04417dc16c2e 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -57,9 +57,6 @@ 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
61 /* XXX Use FFB hw cursor once fb cursor API is better understood... */
62 .fb_cursor = soft_cursor,
63}; 60};
64 61
65/* Register layout and definitions */ 62/* Register layout and definitions */
diff --git a/drivers/video/fm2fb.c b/drivers/video/fm2fb.c
index a0763283d776..998374cfae6d 100644
--- a/drivers/video/fm2fb.c
+++ b/drivers/video/fm2fb.c
@@ -172,7 +172,6 @@ static struct fb_ops fm2fb_ops = {
172 .fb_fillrect = cfb_fillrect, 172 .fb_fillrect = cfb_fillrect,
173 .fb_copyarea = cfb_copyarea, 173 .fb_copyarea = cfb_copyarea,
174 .fb_imageblit = cfb_imageblit, 174 .fb_imageblit = cfb_imageblit,
175 .fb_cursor = soft_cursor,
176}; 175};
177 176
178 /* 177 /*
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index 316bfe994811..9d5e4f342110 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -1038,7 +1038,6 @@ static struct fb_ops gbefb_ops = {
1038 .fb_fillrect = cfb_fillrect, 1038 .fb_fillrect = cfb_fillrect,
1039 .fb_copyarea = cfb_copyarea, 1039 .fb_copyarea = cfb_copyarea,
1040 .fb_imageblit = cfb_imageblit, 1040 .fb_imageblit = cfb_imageblit,
1041 .fb_cursor = soft_cursor,
1042}; 1041};
1043 1042
1044/* 1043/*
@@ -1260,24 +1259,30 @@ static struct device_driver gbefb_driver = {
1260 .remove = __devexit_p(gbefb_remove), 1259 .remove = __devexit_p(gbefb_remove),
1261}; 1260};
1262 1261
1263static struct platform_device gbefb_device = { 1262static struct platform_device *gbefb_device;
1264 .name = "gbefb",
1265};
1266 1263
1267int __init gbefb_init(void) 1264int __init gbefb_init(void)
1268{ 1265{
1269 int ret = driver_register(&gbefb_driver); 1266 int ret = driver_register(&gbefb_driver);
1270 if (!ret) { 1267 if (!ret) {
1271 ret = platform_device_register(&gbefb_device); 1268 gbefb_device = platform_device_alloc("gbefb", 0);
1272 if (ret) 1269 if (gbefb_device) {
1270 ret = platform_device_add(gbefb_device);
1271 } else {
1272 ret = -ENOMEM;
1273 }
1274 if (ret) {
1275 platform_device_put(gbefb_device);
1273 driver_unregister(&gbefb_driver); 1276 driver_unregister(&gbefb_driver);
1277 }
1274 } 1278 }
1275 return ret; 1279 return ret;
1276} 1280}
1277 1281
1278void __exit gbefb_exit(void) 1282void __exit gbefb_exit(void)
1279{ 1283{
1280 driver_unregister(&gbefb_driver); 1284 platform_device_unregister(gbefb_device);
1285 driver_unregister(&gbefb_driver);
1281} 1286}
1282 1287
1283module_init(gbefb_init); 1288module_init(gbefb_init);
diff --git a/drivers/video/geode/Kconfig b/drivers/video/geode/Kconfig
index 5a9b89c3831b..42fb9a89a792 100644
--- a/drivers/video/geode/Kconfig
+++ b/drivers/video/geode/Kconfig
@@ -14,7 +14,6 @@ config FB_GEODE_GX1
14 select FB_CFB_FILLRECT 14 select FB_CFB_FILLRECT
15 select FB_CFB_COPYAREA 15 select FB_CFB_COPYAREA
16 select FB_CFB_IMAGEBLIT 16 select FB_CFB_IMAGEBLIT
17 select FB_SOFT_CURSOR
18 ---help--- 17 ---help---
19 Framebuffer driver for the display controller integrated into the 18 Framebuffer driver for the display controller integrated into the
20 AMD Geode GX1 processor. 19 AMD Geode GX1 processor.
diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c
index 74a5fca86b8a..8e8da7433994 100644
--- a/drivers/video/geode/gx1fb_core.c
+++ b/drivers/video/geode/gx1fb_core.c
@@ -275,7 +275,6 @@ static struct fb_ops gx1fb_ops = {
275 .fb_fillrect = cfb_fillrect, 275 .fb_fillrect = cfb_fillrect,
276 .fb_copyarea = cfb_copyarea, 276 .fb_copyarea = cfb_copyarea,
277 .fb_imageblit = cfb_imageblit, 277 .fb_imageblit = cfb_imageblit,
278 .fb_cursor = soft_cursor,
279}; 278};
280 279
281static struct fb_info * __init gx1fb_init_fbinfo(struct device *dev) 280static struct fb_info * __init gx1fb_init_fbinfo(struct device *dev)
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 0d376ba54814..f04ca721f94c 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -262,7 +262,6 @@ static struct fb_ops hitfb_ops = {
262 .fb_fillrect = hitfb_fillrect, 262 .fb_fillrect = hitfb_fillrect,
263 .fb_copyarea = hitfb_copyarea, 263 .fb_copyarea = hitfb_copyarea,
264 .fb_imageblit = cfb_imageblit, 264 .fb_imageblit = cfb_imageblit,
265 .fb_cursor = soft_cursor,
266}; 265};
267 266
268int __init hitfb_init(void) 267int __init hitfb_init(void)
diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c
index e97fe8481d59..bebdac59d231 100644
--- a/drivers/video/hpfb.c
+++ b/drivers/video/hpfb.c
@@ -193,7 +193,6 @@ static struct fb_ops hpfb_ops = {
193 .fb_fillrect = hpfb_fillrect, 193 .fb_fillrect = hpfb_fillrect,
194 .fb_copyarea = hpfb_copyarea, 194 .fb_copyarea = hpfb_copyarea,
195 .fb_imageblit = cfb_imageblit, 195 .fb_imageblit = cfb_imageblit,
196 .fb_cursor = soft_cursor,
197 .fb_sync = hpfb_sync, 196 .fb_sync = hpfb_sync,
198}; 197};
199 198
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c
index 689d2586366d..c61bad0da20f 100644
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -46,92 +46,45 @@ static void i810i2c_setscl(void *data, int state)
46 struct i810fb_par *par = chan->par; 46 struct i810fb_par *par = chan->par;
47 u8 __iomem *mmio = par->mmio_start_virtual; 47 u8 __iomem *mmio = par->mmio_start_virtual;
48 48
49 i810_writel(mmio, GPIOB, (state ? SCL_VAL_OUT : 0) | SCL_DIR | 49 i810_writel(mmio, chan->ddc_base, (state ? SCL_VAL_OUT : 0) | SCL_DIR |
50 SCL_DIR_MASK | SCL_VAL_MASK); 50 SCL_DIR_MASK | SCL_VAL_MASK);
51 i810_readl(mmio, GPIOB); /* flush posted write */ 51 i810_readl(mmio, chan->ddc_base); /* flush posted write */
52} 52}
53 53
54static void i810i2c_setsda(void *data, int state) 54static void i810i2c_setsda(void *data, int state)
55{ 55{
56 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 56 struct i810fb_i2c_chan *chan = data;
57 struct i810fb_par *par = chan->par; 57 struct i810fb_par *par = chan->par;
58 u8 __iomem *mmio = par->mmio_start_virtual; 58 u8 __iomem *mmio = par->mmio_start_virtual;
59 59
60 i810_writel(mmio, GPIOB, (state ? SDA_VAL_OUT : 0) | SDA_DIR | 60 i810_writel(mmio, chan->ddc_base, (state ? SDA_VAL_OUT : 0) | SDA_DIR |
61 SDA_DIR_MASK | SDA_VAL_MASK); 61 SDA_DIR_MASK | SDA_VAL_MASK);
62 i810_readl(mmio, GPIOB); /* flush posted write */ 62 i810_readl(mmio, chan->ddc_base); /* flush posted write */
63} 63}
64 64
65static int i810i2c_getscl(void *data) 65static int i810i2c_getscl(void *data)
66{ 66{
67 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 67 struct i810fb_i2c_chan *chan = data;
68 struct i810fb_par *par = chan->par; 68 struct i810fb_par *par = chan->par;
69 u8 __iomem *mmio = par->mmio_start_virtual; 69 u8 __iomem *mmio = par->mmio_start_virtual;
70 70
71 i810_writel(mmio, GPIOB, SCL_DIR_MASK); 71 i810_writel(mmio, chan->ddc_base, SCL_DIR_MASK);
72 i810_writel(mmio, GPIOB, 0); 72 i810_writel(mmio, chan->ddc_base, 0);
73 return (0 != (i810_readl(mmio, GPIOB) & SCL_VAL_IN)); 73 return ((i810_readl(mmio, chan->ddc_base) & SCL_VAL_IN) != 0);
74} 74}
75 75
76static int i810i2c_getsda(void *data) 76static int i810i2c_getsda(void *data)
77{ 77{
78 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 78 struct i810fb_i2c_chan *chan = data;
79 struct i810fb_par *par = chan->par; 79 struct i810fb_par *par = chan->par;
80 u8 __iomem *mmio = par->mmio_start_virtual; 80 u8 __iomem *mmio = par->mmio_start_virtual;
81 81
82 i810_writel(mmio, GPIOB, SDA_DIR_MASK); 82 i810_writel(mmio, chan->ddc_base, SDA_DIR_MASK);
83 i810_writel(mmio, GPIOB, 0); 83 i810_writel(mmio, chan->ddc_base, 0);
84 return (0 != (i810_readl(mmio, GPIOB) & SDA_VAL_IN)); 84 return ((i810_readl(mmio, chan->ddc_base) & SDA_VAL_IN) != 0);
85}
86
87static void i810ddc_setscl(void *data, int state)
88{
89 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
90 struct i810fb_par *par = chan->par;
91 u8 __iomem *mmio = par->mmio_start_virtual;
92
93 i810_writel(mmio, GPIOA, (state ? SCL_VAL_OUT : 0) | SCL_DIR |
94 SCL_DIR_MASK | SCL_VAL_MASK);
95 i810_readl(mmio, GPIOA); /* flush posted write */
96}
97
98static void i810ddc_setsda(void *data, int state)
99{
100 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
101 struct i810fb_par *par = chan->par;
102 u8 __iomem *mmio = par->mmio_start_virtual;
103
104 i810_writel(mmio, GPIOA, (state ? SDA_VAL_OUT : 0) | SDA_DIR |
105 SDA_DIR_MASK | SDA_VAL_MASK);
106 i810_readl(mmio, GPIOA); /* flush posted write */
107}
108
109static int i810ddc_getscl(void *data)
110{
111 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
112 struct i810fb_par *par = chan->par;
113 u8 __iomem *mmio = par->mmio_start_virtual;
114
115 i810_writel(mmio, GPIOA, SCL_DIR_MASK);
116 i810_writel(mmio, GPIOA, 0);
117 return (0 != (i810_readl(mmio, GPIOA) & SCL_VAL_IN));
118}
119
120static int i810ddc_getsda(void *data)
121{
122 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
123 struct i810fb_par *par = chan->par;
124 u8 __iomem *mmio = par->mmio_start_virtual;
125
126 i810_writel(mmio, GPIOA, SDA_DIR_MASK);
127 i810_writel(mmio, GPIOA, 0);
128 return (0 != (i810_readl(mmio, GPIOA) & SDA_VAL_IN));
129} 85}
130 86
131#define I2C_ALGO_DDC_I810 0x0e0000 87static int i810_setup_i2c_bus(struct i810fb_i2c_chan *chan, const char *name)
132#define I2C_ALGO_I2C_I810 0x0f0000
133static int i810_setup_i2c_bus(struct i810fb_i2c_chan *chan, const char *name,
134 int conn)
135{ 88{
136 int rc; 89 int rc;
137 90
@@ -139,22 +92,11 @@ static int i810_setup_i2c_bus(struct i810fb_i2c_chan *chan, const char *name,
139 chan->adapter.owner = THIS_MODULE; 92 chan->adapter.owner = THIS_MODULE;
140 chan->adapter.algo_data = &chan->algo; 93 chan->adapter.algo_data = &chan->algo;
141 chan->adapter.dev.parent = &chan->par->dev->dev; 94 chan->adapter.dev.parent = &chan->par->dev->dev;
142 switch (conn) { 95 chan->adapter.id = I2C_HW_B_I810;
143 case 1: 96 chan->algo.setsda = i810i2c_setsda;
144 chan->adapter.id = I2C_ALGO_DDC_I810; 97 chan->algo.setscl = i810i2c_setscl;
145 chan->algo.setsda = i810ddc_setsda; 98 chan->algo.getsda = i810i2c_getsda;
146 chan->algo.setscl = i810ddc_setscl; 99 chan->algo.getscl = i810i2c_getscl;
147 chan->algo.getsda = i810ddc_getsda;
148 chan->algo.getscl = i810ddc_getscl;
149 break;
150 case 2:
151 chan->adapter.id = I2C_ALGO_I2C_I810;
152 chan->algo.setsda = i810i2c_setsda;
153 chan->algo.setscl = i810i2c_setscl;
154 chan->algo.getsda = i810i2c_getsda;
155 chan->algo.getscl = i810i2c_getscl;
156 break;
157 }
158 chan->algo.udelay = 10; 100 chan->algo.udelay = 10;
159 chan->algo.mdelay = 10; 101 chan->algo.mdelay = 10;
160 chan->algo.timeout = (HZ/2); 102 chan->algo.timeout = (HZ/2);
@@ -168,11 +110,15 @@ static int i810_setup_i2c_bus(struct i810fb_i2c_chan *chan, const char *name,
168 udelay(20); 110 udelay(20);
169 111
170 rc = i2c_bit_add_bus(&chan->adapter); 112 rc = i2c_bit_add_bus(&chan->adapter);
113
171 if (rc == 0) 114 if (rc == 0)
172 dev_dbg(&chan->par->dev->dev, "I2C bus %s registered.\n",name); 115 dev_dbg(&chan->par->dev->dev, "I2C bus %s registered.\n",name);
173 else 116 else {
174 dev_warn(&chan->par->dev->dev, "Failed to register I2C bus " 117 dev_warn(&chan->par->dev->dev, "Failed to register I2C bus "
175 "%s.\n", name); 118 "%s.\n", name);
119 chan->par = NULL;
120 }
121
176 return rc; 122 return rc;
177} 123}
178 124
@@ -180,8 +126,14 @@ void i810_create_i2c_busses(struct i810fb_par *par)
180{ 126{
181 par->chan[0].par = par; 127 par->chan[0].par = par;
182 par->chan[1].par = par; 128 par->chan[1].par = par;
183 i810_setup_i2c_bus(&par->chan[0], "I810-DDC", 1); 129 par->chan[2].par = par;
184 i810_setup_i2c_bus(&par->chan[1], "I810-I2C", 2); 130
131 par->chan[0].ddc_base = GPIOA;
132 i810_setup_i2c_bus(&par->chan[0], "I810-DDC");
133 par->chan[1].ddc_base = GPIOB;
134 i810_setup_i2c_bus(&par->chan[1], "I810-I2C");
135 par->chan[2].ddc_base = GPIOC;
136 i810_setup_i2c_bus(&par->chan[2], "I810-GPIOC");
185} 137}
186 138
187void i810_delete_i2c_busses(struct i810fb_par *par) 139void i810_delete_i2c_busses(struct i810fb_par *par)
@@ -189,9 +141,14 @@ void i810_delete_i2c_busses(struct i810fb_par *par)
189 if (par->chan[0].par) 141 if (par->chan[0].par)
190 i2c_bit_del_bus(&par->chan[0].adapter); 142 i2c_bit_del_bus(&par->chan[0].adapter);
191 par->chan[0].par = NULL; 143 par->chan[0].par = NULL;
144
192 if (par->chan[1].par) 145 if (par->chan[1].par)
193 i2c_bit_del_bus(&par->chan[1].adapter); 146 i2c_bit_del_bus(&par->chan[1].adapter);
194 par->chan[1].par = NULL; 147 par->chan[1].par = NULL;
148
149 if (par->chan[2].par)
150 i2c_bit_del_bus(&par->chan[2].adapter);
151 par->chan[2].par = NULL;
195} 152}
196 153
197static u8 *i810_do_probe_i2c_edid(struct i810fb_i2c_chan *chan) 154static u8 *i810_do_probe_i2c_edid(struct i810fb_i2c_chan *chan)
@@ -221,6 +178,7 @@ static u8 *i810_do_probe_i2c_edid(struct i810fb_i2c_chan *chan)
221 DPRINTK("i810-i2c: I2C Transfer successful\n"); 178 DPRINTK("i810-i2c: I2C Transfer successful\n");
222 return buf; 179 return buf;
223 } 180 }
181
224 DPRINTK("i810-i2c: Unable to read EDID block.\n"); 182 DPRINTK("i810-i2c: Unable to read EDID block.\n");
225 kfree(buf); 183 kfree(buf);
226 return NULL; 184 return NULL;
@@ -233,7 +191,7 @@ int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, int conn)
233 int i; 191 int i;
234 192
235 DPRINTK("i810-i2c: Probe DDC%i Bus\n", conn); 193 DPRINTK("i810-i2c: Probe DDC%i Bus\n", conn);
236 if (conn < 3) { 194 if (conn < 4) {
237 for (i = 0; i < 3; i++) { 195 for (i = 0; i < 3; i++) {
238 /* Do the real work */ 196 /* Do the real work */
239 edid = i810_do_probe_i2c_edid(&par->chan[conn-1]); 197 edid = i810_do_probe_i2c_edid(&par->chan[conn-1]);
@@ -241,11 +199,14 @@ int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, int conn)
241 break; 199 break;
242 } 200 }
243 } else { 201 } else {
244 DPRINTK("i810-i2c: Getting EDID from BIOS\n"); 202 const u8 *e = fb_firmware_edid(info->device);
245 edid = kmalloc(EDID_LENGTH, GFP_KERNEL); 203
246 if (edid) 204 if (e != NULL) {
247 memcpy(edid, fb_firmware_edid(info->device), 205 DPRINTK("i810-i2c: Getting EDID from BIOS\n");
248 EDID_LENGTH); 206 edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
207 if (edid)
208 memcpy(edid, e, EDID_LENGTH);
209 }
249 } 210 }
250 211
251 if (out_edid) 212 if (out_edid)
@@ -253,5 +214,3 @@ int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, int conn)
253 214
254 return (edid) ? 0 : 1; 215 return (edid) ? 0 : 1;
255} 216}
256
257
diff --git a/drivers/video/i810/i810.h b/drivers/video/i810/i810.h
index d48949ceaacc..6c187d5fe951 100644
--- a/drivers/video/i810/i810.h
+++ b/drivers/video/i810/i810.h
@@ -249,6 +249,7 @@ struct i810fb_i2c_chan {
249 struct i810fb_par *par; 249 struct i810fb_par *par;
250 struct i2c_adapter adapter; 250 struct i2c_adapter adapter;
251 struct i2c_algo_bit_data algo; 251 struct i2c_algo_bit_data algo;
252 unsigned long ddc_base;
252}; 253};
253 254
254struct i810fb_par { 255struct i810fb_par {
@@ -262,7 +263,7 @@ struct i810fb_par {
262 struct heap_data iring; 263 struct heap_data iring;
263 struct heap_data cursor_heap; 264 struct heap_data cursor_heap;
264 struct vgastate state; 265 struct vgastate state;
265 struct i810fb_i2c_chan chan[2]; 266 struct i810fb_i2c_chan chan[3];
266 atomic_t use_count; 267 atomic_t use_count;
267 u32 pseudo_palette[17]; 268 u32 pseudo_palette[17];
268 unsigned long mmio_start_phys; 269 unsigned long mmio_start_phys;
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 0dbc9ddb6766..c0c974b1afaa 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1854,7 +1854,7 @@ static void __devinit i810fb_find_init_mode(struct fb_info *info)
1854#ifdef CONFIG_FB_I810_I2C 1854#ifdef CONFIG_FB_I810_I2C
1855 i810_create_i2c_busses(par); 1855 i810_create_i2c_busses(par);
1856 1856
1857 for (i = 0; i < 3; i++) { 1857 for (i = 0; i < 4; i++) {
1858 err = i810_probe_i2c_connector(info, &par->edid, i+1); 1858 err = i810_probe_i2c_connector(info, &par->edid, i+1);
1859 if (!err) 1859 if (!err)
1860 break; 1860 break;
@@ -1871,27 +1871,18 @@ static void __devinit i810fb_find_init_mode(struct fb_info *info)
1871 fb_videomode_to_modelist(specs->modedb, specs->modedb_len, 1871 fb_videomode_to_modelist(specs->modedb, specs->modedb_len,
1872 &info->modelist); 1872 &info->modelist);
1873 if (specs->modedb != NULL) { 1873 if (specs->modedb != NULL) {
1874 if (xres && yres) { 1874 struct fb_videomode *m;
1875 struct fb_videomode *m;
1876 1875
1876 if (xres && yres) {
1877 if ((m = fb_find_best_mode(&var, &info->modelist))) { 1877 if ((m = fb_find_best_mode(&var, &info->modelist))) {
1878 mode = *m; 1878 mode = *m;
1879 found = 1; 1879 found = 1;
1880 } 1880 }
1881 } 1881 }
1882 1882
1883 if (!found && specs->misc & FB_MISC_1ST_DETAIL) {
1884 for (i = 0; i < specs->modedb_len; i++) {
1885 if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
1886 mode = specs->modedb[i];
1887 found = 1;
1888 break;
1889 }
1890 }
1891 }
1892
1893 if (!found) { 1883 if (!found) {
1894 mode = specs->modedb[0]; 1884 m = fb_find_best_display(&info->monspecs, &info->modelist);
1885 mode = *m;
1895 found = 1; 1886 found = 1;
1896 } 1887 }
1897 1888
@@ -2066,8 +2057,7 @@ static void i810fb_release_resource(struct fb_info *info,
2066 iounmap(par->mmio_start_virtual); 2057 iounmap(par->mmio_start_virtual);
2067 if (par->aperture.virtual) 2058 if (par->aperture.virtual)
2068 iounmap(par->aperture.virtual); 2059 iounmap(par->aperture.virtual);
2069 if (par->edid) 2060 kfree(par->edid);
2070 kfree(par->edid);
2071 if (par->res_flags & FRAMEBUFFER_REQ) 2061 if (par->res_flags & FRAMEBUFFER_REQ)
2072 release_mem_region(par->aperture.physical, 2062 release_mem_region(par->aperture.physical,
2073 par->aperture.size); 2063 par->aperture.size);
diff --git a/drivers/video/i810/i810_regs.h b/drivers/video/i810/i810_regs.h
index 6e4b9afa4d98..91c6bd9d0d0d 100644
--- a/drivers/video/i810/i810_regs.h
+++ b/drivers/video/i810/i810_regs.h
@@ -70,6 +70,7 @@
70#define HVSYNC 0x05000 70#define HVSYNC 0x05000
71#define GPIOA 0x05010 71#define GPIOA 0x05010
72#define GPIOB 0x05014 72#define GPIOB 0x05014
73#define GPIOC 0x0501C
73 74
74/* Clock Control and Power Management Registers (06000h 06FFFh) */ 75/* Clock Control and Power Management Registers (06000h 06FFFh) */
75#define DCLK_0D 0x06000 76#define DCLK_0D 0x06000
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index 7b9bf45ab6fe..7fbe24206b19 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -1344,7 +1344,6 @@ static struct fb_ops imsttfb_ops = {
1344 .fb_fillrect = imsttfb_fillrect, 1344 .fb_fillrect = imsttfb_fillrect,
1345 .fb_copyarea = imsttfb_copyarea, 1345 .fb_copyarea = imsttfb_copyarea,
1346 .fb_imageblit = cfb_imageblit, 1346 .fb_imageblit = cfb_imageblit,
1347 .fb_cursor = soft_cursor,
1348 .fb_ioctl = imsttfb_ioctl, 1347 .fb_ioctl = imsttfb_ioctl,
1349}; 1348};
1350 1349
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 64d9bcc38da3..e20b9f3a255f 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -298,7 +298,6 @@ static struct fb_ops imxfb_ops = {
298 .fb_copyarea = cfb_copyarea, 298 .fb_copyarea = cfb_copyarea,
299 .fb_imageblit = cfb_imageblit, 299 .fb_imageblit = cfb_imageblit,
300 .fb_blank = imxfb_blank, 300 .fb_blank = imxfb_blank,
301 .fb_cursor = soft_cursor, /* FIXME: i.MX can do hardware cursor */
302}; 301};
303 302
304/* 303/*
diff --git a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h
index 011e11626558..f077ca34faba 100644
--- a/drivers/video/intelfb/intelfb.h
+++ b/drivers/video/intelfb/intelfb.h
@@ -10,7 +10,7 @@
10/*** Version/name ***/ 10/*** Version/name ***/
11#define INTELFB_VERSION "0.9.2" 11#define INTELFB_VERSION "0.9.2"
12#define INTELFB_MODULE_NAME "intelfb" 12#define INTELFB_MODULE_NAME "intelfb"
13#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G" 13#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM"
14 14
15 15
16/*** Debug/feature defines ***/ 16/*** Debug/feature defines ***/
@@ -47,6 +47,7 @@
47#define PCI_DEVICE_ID_INTEL_85XGM 0x3582 47#define PCI_DEVICE_ID_INTEL_85XGM 0x3582
48#define PCI_DEVICE_ID_INTEL_865G 0x2572 48#define PCI_DEVICE_ID_INTEL_865G 0x2572
49#define PCI_DEVICE_ID_INTEL_915G 0x2582 49#define PCI_DEVICE_ID_INTEL_915G 0x2582
50#define PCI_DEVICE_ID_INTEL_915GM 0x2592
50 51
51/* Size of MMIO region */ 52/* Size of MMIO region */
52#define INTEL_REG_SIZE 0x80000 53#define INTEL_REG_SIZE 0x80000
@@ -119,7 +120,8 @@ enum intel_chips {
119 INTEL_855GM, 120 INTEL_855GM,
120 INTEL_855GME, 121 INTEL_855GME,
121 INTEL_865G, 122 INTEL_865G,
122 INTEL_915G 123 INTEL_915G,
124 INTEL_915GM
123}; 125};
124 126
125struct intelfb_hwstate { 127struct intelfb_hwstate {
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 80a09344f1aa..0799b999b314 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * intelfb 2 * intelfb
3 * 3 *
4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G 4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM
5 * integrated graphics chips. 5 * integrated graphics chips.
6 * 6 *
7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org> 7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
@@ -186,6 +186,7 @@ static struct pci_device_id intelfb_pci_table[] __devinitdata = {
186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_85XGM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_85XGM }, 186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_85XGM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_85XGM },
187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_865G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_865G }, 187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_865G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_865G },
188 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915G }, 188 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915G },
189 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM },
189 { 0, } 190 { 0, }
190}; 191};
191 192
@@ -549,10 +550,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
549 } 550 }
550 551
551 /* Set base addresses. */ 552 /* Set base addresses. */
552 if (ent->device == PCI_DEVICE_ID_INTEL_915G) { 553 if ((ent->device == PCI_DEVICE_ID_INTEL_915G) ||
554 (ent->device == PCI_DEVICE_ID_INTEL_915GM)) {
553 aperture_bar = 2; 555 aperture_bar = 2;
554 mmio_bar = 0; 556 mmio_bar = 0;
555 /* Disable HW cursor on 915G (not implemented yet) */ 557 /* Disable HW cursor on 915G/M (not implemented yet) */
556 hwcursor = 0; 558 hwcursor = 0;
557 } 559 }
558 dinfo->aperture.physical = pci_resource_start(pdev, aperture_bar); 560 dinfo->aperture.physical = pci_resource_start(pdev, aperture_bar);
@@ -1483,7 +1485,7 @@ intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1483#endif 1485#endif
1484 1486
1485 if (!dinfo->hwcursor) 1487 if (!dinfo->hwcursor)
1486 return soft_cursor(info, cursor); 1488 return -ENODEV;
1487 1489
1488 intelfbhw_cursor_hide(dinfo); 1490 intelfbhw_cursor_hide(dinfo);
1489 1491
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index 5bafc3c54db7..ac94c2e5ff85 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -99,6 +99,11 @@ intelfbhw_get_chipset(struct pci_dev *pdev, const char **name, int *chipset,
99 *chipset = INTEL_915G; 99 *chipset = INTEL_915G;
100 *mobile = 0; 100 *mobile = 0;
101 return 0; 101 return 0;
102 case PCI_DEVICE_ID_INTEL_915GM:
103 *name = "Intel(R) 915GM";
104 *chipset = INTEL_915GM;
105 *mobile = 1;
106 return 0;
102 default: 107 default:
103 return 1; 108 return 1;
104 } 109 }
diff --git a/drivers/video/kyro/fbdev.c b/drivers/video/kyro/fbdev.c
index d8bac9e97842..5eb4d5c177bd 100644
--- a/drivers/video/kyro/fbdev.c
+++ b/drivers/video/kyro/fbdev.c
@@ -669,7 +669,6 @@ static struct fb_ops kyrofb_ops = {
669 .fb_fillrect = cfb_fillrect, 669 .fb_fillrect = cfb_fillrect,
670 .fb_copyarea = cfb_copyarea, 670 .fb_copyarea = cfb_copyarea,
671 .fb_imageblit = cfb_imageblit, 671 .fb_imageblit = cfb_imageblit,
672 .fb_cursor = soft_cursor,
673}; 672};
674 673
675static int __devinit kyrofb_probe(struct pci_dev *pdev, 674static int __devinit kyrofb_probe(struct pci_dev *pdev,
diff --git a/drivers/video/leo.c b/drivers/video/leo.c
index 7e1e7fb168bd..84a7fe435bb8 100644
--- a/drivers/video/leo.c
+++ b/drivers/video/leo.c
@@ -51,7 +51,6 @@ 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 .fb_cursor = soft_cursor,
55}; 54};
56 55
57#define LEO_OFF_LC_SS0_KRN 0x00200000UL 56#define LEO_OFF_LC_SS0_KRN 0x00200000UL
diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 3e9ccf370ab2..8cb7fb4db441 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -7,6 +7,8 @@ menu "Logo configuration"
7config LOGO 7config LOGO
8 bool "Bootup logo" 8 bool "Bootup logo"
9 depends on FB || SGI_NEWPORT_CONSOLE 9 depends on FB || SGI_NEWPORT_CONSOLE
10 help
11 Enable and select frame buffer bootup logos.
10 12
11config LOGO_LINUX_MONO 13config LOGO_LINUX_MONO
12 bool "Standard black and white Linux logo" 14 bool "Standard black and white Linux logo"
diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c
index 4945a4c02209..cfc748e94272 100644
--- a/drivers/video/macfb.c
+++ b/drivers/video/macfb.c
@@ -589,7 +589,6 @@ static struct fb_ops macfb_ops = {
589 .fb_fillrect = cfb_fillrect, 589 .fb_fillrect = cfb_fillrect,
590 .fb_copyarea = cfb_copyarea, 590 .fb_copyarea = cfb_copyarea,
591 .fb_imageblit = cfb_imageblit, 591 .fb_imageblit = cfb_imageblit,
592 .fb_cursor = soft_cursor,
593}; 592};
594 593
595void __init macfb_setup(char *options) 594void __init macfb_setup(char *options)
diff --git a/drivers/video/matrox/matroxfb_DAC1064.c b/drivers/video/matrox/matroxfb_DAC1064.c
index 149680f8bcf0..0fbd9b5149f1 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.c
+++ b/drivers/video/matrox/matroxfb_DAC1064.c
@@ -657,7 +657,6 @@ static int MGA1064_preinit(WPMINFO2) {
657 /* ACCESS_FBINFO(capable.cfb4) = 0; ... preinitialized by 0 */ 657 /* ACCESS_FBINFO(capable.cfb4) = 0; ... preinitialized by 0 */
658 ACCESS_FBINFO(capable.text) = 1; 658 ACCESS_FBINFO(capable.text) = 1;
659 ACCESS_FBINFO(capable.vxres) = vxres_mystique; 659 ACCESS_FBINFO(capable.vxres) = vxres_mystique;
660 ACCESS_FBINFO(features.accel.has_cacheflush) = 1;
661 660
662 ACCESS_FBINFO(outputs[0]).output = &m1064; 661 ACCESS_FBINFO(outputs[0]).output = &m1064;
663 ACCESS_FBINFO(outputs[0]).src = ACCESS_FBINFO(outputs[0]).default_src; 662 ACCESS_FBINFO(outputs[0]).src = ACCESS_FBINFO(outputs[0]).default_src;
@@ -842,7 +841,6 @@ static int MGAG100_preinit(WPMINFO2) {
842 /* ACCESS_FBINFO(capable.cfb4) = 0; ... preinitialized by 0 */ 841 /* ACCESS_FBINFO(capable.cfb4) = 0; ... preinitialized by 0 */
843 ACCESS_FBINFO(capable.text) = 1; 842 ACCESS_FBINFO(capable.text) = 1;
844 ACCESS_FBINFO(capable.vxres) = vxres_g100; 843 ACCESS_FBINFO(capable.vxres) = vxres_g100;
845 ACCESS_FBINFO(features.accel.has_cacheflush) = 1;
846 ACCESS_FBINFO(capable.plnwt) = ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG100 844 ACCESS_FBINFO(capable.plnwt) = ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGAG100
847 ? ACCESS_FBINFO(devflags.sgram) : 1; 845 ? ACCESS_FBINFO(devflags.sgram) : 1;
848 846
@@ -980,7 +978,7 @@ static void MGAG100_reset(WPMINFO2) {
980 hw->MXoptionReg |= 0x40; /* FIXME... */ 978 hw->MXoptionReg |= 0x40; /* FIXME... */
981 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg); 979 pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
982 } 980 }
983 mga_setr(M_EXTVGA_INDEX, 0x06, 0x50); 981 mga_setr(M_EXTVGA_INDEX, 0x06, 0x00);
984 } 982 }
985 } 983 }
986 if (ACCESS_FBINFO(devflags.g450dac)) { 984 if (ACCESS_FBINFO(devflags.g450dac)) {
diff --git a/drivers/video/matrox/matroxfb_accel.c b/drivers/video/matrox/matroxfb_accel.c
index c7f3e1321224..a5c825d99466 100644
--- a/drivers/video/matrox/matroxfb_accel.c
+++ b/drivers/video/matrox/matroxfb_accel.c
@@ -122,7 +122,7 @@ void matrox_cfbX_init(WPMINFO2) {
122 ACCESS_FBINFO(fbops).fb_copyarea = cfb_copyarea; 122 ACCESS_FBINFO(fbops).fb_copyarea = cfb_copyarea;
123 ACCESS_FBINFO(fbops).fb_fillrect = cfb_fillrect; 123 ACCESS_FBINFO(fbops).fb_fillrect = cfb_fillrect;
124 ACCESS_FBINFO(fbops).fb_imageblit = cfb_imageblit; 124 ACCESS_FBINFO(fbops).fb_imageblit = cfb_imageblit;
125 ACCESS_FBINFO(fbops).fb_cursor = soft_cursor; 125 ACCESS_FBINFO(fbops).fb_cursor = NULL;
126 126
127 accel = (ACCESS_FBINFO(fbcon).var.accel_flags & FB_ACCELF_TEXT) == FB_ACCELF_TEXT; 127 accel = (ACCESS_FBINFO(fbcon).var.accel_flags & FB_ACCELF_TEXT) == FB_ACCELF_TEXT;
128 128
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index e02da41f1b26..1e74f4cca53b 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -264,7 +264,6 @@ static void matroxfb_disable_irq(WPMINFO2) {
264} 264}
265 265
266int matroxfb_wait_for_sync(WPMINFO u_int32_t crtc) { 266int matroxfb_wait_for_sync(WPMINFO u_int32_t crtc) {
267 wait_queue_t __wait;
268 struct matrox_vsync *vs; 267 struct matrox_vsync *vs;
269 unsigned int cnt; 268 unsigned int cnt;
270 int ret; 269 int ret;
@@ -286,7 +285,6 @@ int matroxfb_wait_for_sync(WPMINFO u_int32_t crtc) {
286 if (ret) { 285 if (ret) {
287 return ret; 286 return ret;
288 } 287 }
289 init_waitqueue_entry(&__wait, current);
290 288
291 cnt = vs->cnt; 289 cnt = vs->cnt;
292 ret = wait_event_interruptible_timeout(vs->wait, cnt != vs->cnt, HZ/10); 290 ret = wait_event_interruptible_timeout(vs->wait, cnt != vs->cnt, HZ/10);
@@ -500,10 +498,6 @@ static int matroxfb_pitch_adjust(CPMINFO int xres, int bpp) {
500 } else { 498 } else {
501 xres_new = matroxfb_test_and_set_rounding(PMINFO xres, bpp); 499 xres_new = matroxfb_test_and_set_rounding(PMINFO xres, bpp);
502 } 500 }
503 if (!xres_new) return 0;
504 if (xres != xres_new) {
505 printk(KERN_INFO "matroxfb: cannot set xres to %d, rounded up to %d\n", xres, xres_new);
506 }
507 return xres_new; 501 return xres_new;
508} 502}
509 503
@@ -1285,7 +1279,7 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1285 vaddr_t vm; 1279 vaddr_t vm;
1286 unsigned int offs; 1280 unsigned int offs;
1287 unsigned int offs2; 1281 unsigned int offs2;
1288 unsigned char store, orig; 1282 unsigned char orig;
1289 unsigned char bytes[32]; 1283 unsigned char bytes[32];
1290 unsigned char* tmp; 1284 unsigned char* tmp;
1291 1285
@@ -1301,16 +1295,12 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1301 orig = mga_inb(M_EXTVGA_DATA); 1295 orig = mga_inb(M_EXTVGA_DATA);
1302 mga_outb(M_EXTVGA_DATA, orig | 0x80); 1296 mga_outb(M_EXTVGA_DATA, orig | 0x80);
1303 1297
1304 store = mga_readb(vm, 0x1234);
1305 tmp = bytes; 1298 tmp = bytes;
1306 for (offs = 0x100000; offs < maxSize; offs += 0x200000) 1299 for (offs = 0x100000; offs < maxSize; offs += 0x200000)
1307 *tmp++ = mga_readb(vm, offs); 1300 *tmp++ = mga_readb(vm, offs);
1308 for (offs = 0x100000; offs < maxSize; offs += 0x200000) 1301 for (offs = 0x100000; offs < maxSize; offs += 0x200000)
1309 mga_writeb(vm, offs, 0x02); 1302 mga_writeb(vm, offs, 0x02);
1310 if (ACCESS_FBINFO(features.accel.has_cacheflush)) 1303 mga_outb(M_CACHEFLUSH, 0x00);
1311 mga_outb(M_CACHEFLUSH, 0x00);
1312 else
1313 mga_writeb(vm, 0x1234, 0x99);
1314 for (offs = 0x100000; offs < maxSize; offs += 0x200000) { 1304 for (offs = 0x100000; offs < maxSize; offs += 0x200000) {
1315 if (mga_readb(vm, offs) != 0x02) 1305 if (mga_readb(vm, offs) != 0x02)
1316 break; 1306 break;
@@ -1321,7 +1311,6 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1321 tmp = bytes; 1311 tmp = bytes;
1322 for (offs2 = 0x100000; offs2 < maxSize; offs2 += 0x200000) 1312 for (offs2 = 0x100000; offs2 < maxSize; offs2 += 0x200000)
1323 mga_writeb(vm, offs2, *tmp++); 1313 mga_writeb(vm, offs2, *tmp++);
1324 mga_writeb(vm, 0x1234, store);
1325 1314
1326 mga_outb(M_EXTVGA_INDEX, 0x03); 1315 mga_outb(M_EXTVGA_INDEX, 0x03);
1327 mga_outb(M_EXTVGA_DATA, orig); 1316 mga_outb(M_EXTVGA_DATA, orig);
@@ -1430,6 +1419,20 @@ static struct board {
1430 MGA_1164, 1419 MGA_1164,
1431 &vbMystique, 1420 &vbMystique,
1432 "Mystique 220 (PCI)"}, 1421 "Mystique 220 (PCI)"},
1422 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MYS_AGP, 0x02,
1423 0, 0,
1424 DEVF_VIDEO64BIT | DEVF_CROSS4MB,
1425 180000,
1426 MGA_1064,
1427 &vbMystique,
1428 "Mystique (AGP)"},
1429 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MYS_AGP, 0xFF,
1430 0, 0,
1431 DEVF_VIDEO64BIT | DEVF_SWAPS | DEVF_CROSS4MB,
1432 220000,
1433 MGA_1164,
1434 &vbMystique,
1435 "Mystique 220 (AGP)"},
1433#endif 1436#endif
1434#ifdef CONFIG_FB_MATROX_G 1437#ifdef CONFIG_FB_MATROX_G
1435 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_MM, 0xFF, 1438 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_MM, 0xFF,
diff --git a/drivers/video/matrox/matroxfb_base.h b/drivers/video/matrox/matroxfb_base.h
index 85a0b2558452..a8c47ad2cdb6 100644
--- a/drivers/video/matrox/matroxfb_base.h
+++ b/drivers/video/matrox/matroxfb_base.h
@@ -272,10 +272,6 @@ struct matrox_DAC1064_features {
272 u_int8_t xmiscctrl; 272 u_int8_t xmiscctrl;
273}; 273};
274 274
275struct matrox_accel_features {
276 int has_cacheflush;
277};
278
279/* current hardware status */ 275/* current hardware status */
280struct mavenregs { 276struct mavenregs {
281 u_int8_t regs[256]; 277 u_int8_t regs[256];
@@ -440,7 +436,6 @@ struct matrox_fb_info {
440 struct { 436 struct {
441 struct matrox_pll_features pll; 437 struct matrox_pll_features pll;
442 struct matrox_DAC1064_features DAC1064; 438 struct matrox_DAC1064_features DAC1064;
443 struct matrox_accel_features accel;
444 } features; 439 } features;
445 struct { 440 struct {
446 spinlock_t DAC; 441 spinlock_t DAC;
diff --git a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c
index 429047ac615a..d52d7d825c41 100644
--- a/drivers/video/matrox/matroxfb_crtc2.c
+++ b/drivers/video/matrox/matroxfb_crtc2.c
@@ -576,7 +576,6 @@ static struct fb_ops matroxfb_dh_ops = {
576 .fb_fillrect = cfb_fillrect, 576 .fb_fillrect = cfb_fillrect,
577 .fb_copyarea = cfb_copyarea, 577 .fb_copyarea = cfb_copyarea,
578 .fb_imageblit = cfb_imageblit, 578 .fb_imageblit = cfb_imageblit,
579 .fb_cursor = soft_cursor,
580}; 579};
581 580
582static struct fb_var_screeninfo matroxfb_dh_defined = { 581static struct fb_var_screeninfo matroxfb_dh_defined = {
diff --git a/drivers/video/maxinefb.c b/drivers/video/maxinefb.c
index f192d995d030..743e7ad26acc 100644
--- a/drivers/video/maxinefb.c
+++ b/drivers/video/maxinefb.c
@@ -113,7 +113,6 @@ static struct fb_ops maxinefb_ops = {
113 .fb_fillrect = cfb_fillrect, 113 .fb_fillrect = cfb_fillrect,
114 .fb_copyarea = cfb_copyarea, 114 .fb_copyarea = cfb_copyarea,
115 .fb_imageblit = cfb_imageblit, 115 .fb_imageblit = cfb_imageblit,
116 .fb_cursor = soft_cursor,
117}; 116};
118 117
119int __init maxinefb_init(void) 118int __init maxinefb_init(void)
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c
index 47516c44a390..1789a52d776a 100644
--- a/drivers/video/modedb.c
+++ b/drivers/video/modedb.c
@@ -676,6 +676,8 @@ void fb_var_to_videomode(struct fb_videomode *mode,
676 mode->sync = var->sync; 676 mode->sync = var->sync;
677 mode->vmode = var->vmode & FB_VMODE_MASK; 677 mode->vmode = var->vmode & FB_VMODE_MASK;
678 mode->flag = FB_MODE_IS_FROM_VAR; 678 mode->flag = FB_MODE_IS_FROM_VAR;
679 mode->refresh = 0;
680
679 if (!var->pixclock) 681 if (!var->pixclock)
680 return; 682 return;
681 683
@@ -785,39 +787,39 @@ struct fb_videomode *fb_find_best_mode(struct fb_var_screeninfo *var,
785} 787}
786 788
787/** 789/**
788 * fb_find_nearest_mode - find mode closest video mode 790 * fb_find_nearest_mode - find closest videomode
789 * 791 *
790 * @var: pointer to struct fb_var_screeninfo 792 * @mode: pointer to struct fb_videomode
791 * @head: pointer to modelist 793 * @head: pointer to modelist
792 * 794 *
793 * Finds best matching videomode, smaller or greater in dimension. 795 * Finds best matching videomode, smaller or greater in dimension.
794 * If more than 1 videomode is found, will return the videomode with 796 * If more than 1 videomode is found, will return the videomode with
795 * the closest refresh rate 797 * the closest refresh rate.
796 */ 798 */
797struct fb_videomode *fb_find_nearest_mode(struct fb_var_screeninfo *var, 799struct fb_videomode *fb_find_nearest_mode(struct fb_videomode *mode,
798 struct list_head *head) 800 struct list_head *head)
799{ 801{
800 struct list_head *pos; 802 struct list_head *pos;
801 struct fb_modelist *modelist; 803 struct fb_modelist *modelist;
802 struct fb_videomode *mode, *best = NULL; 804 struct fb_videomode *cmode, *best = NULL;
803 u32 diff = -1, diff_refresh = -1; 805 u32 diff = -1, diff_refresh = -1;
804 806
805 list_for_each(pos, head) { 807 list_for_each(pos, head) {
806 u32 d; 808 u32 d;
807 809
808 modelist = list_entry(pos, struct fb_modelist, list); 810 modelist = list_entry(pos, struct fb_modelist, list);
809 mode = &modelist->mode; 811 cmode = &modelist->mode;
810 812
811 d = abs(mode->xres - var->xres) + 813 d = abs(cmode->xres - mode->xres) +
812 abs(mode->yres - var->yres); 814 abs(cmode->yres - mode->yres);
813 if (diff > d) { 815 if (diff > d) {
814 diff = d; 816 diff = d;
815 best = mode; 817 best = cmode;
816 } else if (diff == d) { 818 } else if (diff == d) {
817 d = abs(mode->refresh - best->refresh); 819 d = abs(cmode->refresh - mode->refresh);
818 if (diff_refresh > d) { 820 if (diff_refresh > d) {
819 diff_refresh = d; 821 diff_refresh = d;
820 best = mode; 822 best = cmode;
821 } 823 }
822 } 824 }
823 } 825 }
@@ -942,6 +944,66 @@ void fb_videomode_to_modelist(struct fb_videomode *modedb, int num,
942 } 944 }
943} 945}
944 946
947struct fb_videomode *fb_find_best_display(struct fb_monspecs *specs,
948 struct list_head *head)
949{
950 struct list_head *pos;
951 struct fb_modelist *modelist;
952 struct fb_videomode *m, *m1 = NULL, *md = NULL, *best = NULL;
953 int first = 0;
954
955 if (!head->prev || !head->next || list_empty(head))
956 goto finished;
957
958 /* get the first detailed mode and the very first mode */
959 list_for_each(pos, head) {
960 modelist = list_entry(pos, struct fb_modelist, list);
961 m = &modelist->mode;
962
963 if (!first) {
964 m1 = m;
965 first = 1;
966 }
967
968 if (m->flag & FB_MODE_IS_FIRST) {
969 md = m;
970 break;
971 }
972 }
973
974 /* first detailed timing is preferred */
975 if (specs->misc & FB_MISC_1ST_DETAIL) {
976 best = md;
977 goto finished;
978 }
979
980 /* find best mode based on display width and height */
981 if (specs->max_x && specs->max_y) {
982 struct fb_var_screeninfo var;
983
984 memset(&var, 0, sizeof(struct fb_var_screeninfo));
985 var.xres = (specs->max_x * 7200)/254;
986 var.yres = (specs->max_y * 7200)/254;
987 m = fb_find_best_mode(&var, head);
988 if (m) {
989 best = m;
990 goto finished;
991 }
992 }
993
994 /* use first detailed mode */
995 if (md) {
996 best = md;
997 goto finished;
998 }
999
1000 /* last resort, use the very first mode */
1001 best = m1;
1002finished:
1003 return best;
1004}
1005EXPORT_SYMBOL(fb_find_best_display);
1006
945EXPORT_SYMBOL(fb_videomode_to_var); 1007EXPORT_SYMBOL(fb_videomode_to_var);
946EXPORT_SYMBOL(fb_var_to_videomode); 1008EXPORT_SYMBOL(fb_var_to_videomode);
947EXPORT_SYMBOL(fb_mode_is_equal); 1009EXPORT_SYMBOL(fb_mode_is_equal);
diff --git a/drivers/video/neofb.c b/drivers/video/neofb.c
index 5d424a30270a..8486e77872dc 100644
--- a/drivers/video/neofb.c
+++ b/drivers/video/neofb.c
@@ -1665,7 +1665,6 @@ static struct fb_ops neofb_ops = {
1665 .fb_fillrect = neofb_fillrect, 1665 .fb_fillrect = neofb_fillrect,
1666 .fb_copyarea = neofb_copyarea, 1666 .fb_copyarea = neofb_copyarea,
1667 .fb_imageblit = neofb_imageblit, 1667 .fb_imageblit = neofb_imageblit,
1668 .fb_cursor = soft_cursor,
1669}; 1668};
1670 1669
1671/* --------------------------------------------------------------------- */ 1670/* --------------------------------------------------------------------- */
diff --git a/drivers/video/nvidia/nv_local.h b/drivers/video/nvidia/nv_local.h
index afee284fc73c..4243d7fae972 100644
--- a/drivers/video/nvidia/nv_local.h
+++ b/drivers/video/nvidia/nv_local.h
@@ -105,7 +105,7 @@ do { \
105 *a = byte_rev[*a]; \ 105 *a = byte_rev[*a]; \
106} while(0) 106} while(0)
107#else 107#else
108#define reverse_order(l) 108#define reverse_order(l) do { } while(0)
109#endif /* __LITTLE_ENDIAN */ 109#endif /* __LITTLE_ENDIAN */
110 110
111#endif /* __NV_LOCAL_H__ */ 111#endif /* __NV_LOCAL_H__ */
diff --git a/drivers/video/nvidia/nv_of.c b/drivers/video/nvidia/nv_of.c
index 4fa2cf9a8af2..7a03d040b1a3 100644
--- a/drivers/video/nvidia/nv_of.c
+++ b/drivers/video/nvidia/nv_of.c
@@ -27,34 +27,60 @@
27#include "nv_local.h" 27#include "nv_local.h"
28#include "nv_proto.h" 28#include "nv_proto.h"
29 29
30void nvidia_create_i2c_busses(struct nvidia_par *par) {} 30#include "../edid.h"
31void nvidia_delete_i2c_busses(struct nvidia_par *par) {}
32 31
33int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid) 32int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid)
34{ 33{
35 struct nvidia_par *par = info->par; 34 struct nvidia_par *par = info->par;
36 struct device_node *dp; 35 struct device_node *parent, *dp;
37 unsigned char *pedid = NULL; 36 unsigned char *pedid = NULL;
38 unsigned char *disptype = NULL;
39 static char *propnames[] = { 37 static char *propnames[] = {
40 "DFP,EDID", "LCD,EDID", "EDID", "EDID1", "EDID,B", "EDID,A", NULL }; 38 "DFP,EDID", "LCD,EDID", "EDID", "EDID1",
39 "EDID,B", "EDID,A", NULL };
41 int i; 40 int i;
42 41
43 dp = pci_device_to_OF_node(par->pci_dev); 42 parent = pci_device_to_OF_node(par->pci_dev);
44 for (; dp != NULL; dp = dp->child) { 43 if (parent == NULL)
45 disptype = (unsigned char *)get_property(dp, "display-type", NULL); 44 return -1;
46 if (disptype == NULL) 45 if (par->twoHeads) {
47 continue; 46 char *pname;
48 if (strncmp(disptype, "LCD", 3) != 0) 47 int len;
49 continue; 48
49 for (dp = NULL;
50 (dp = of_get_next_child(parent, dp)) != NULL;) {
51 pname = (char *)get_property(dp, "name", NULL);
52 if (!pname)
53 continue;
54 len = strlen(pname);
55 if ((pname[len-1] == 'A' && conn == 1) ||
56 (pname[len-1] == 'B' && conn == 2)) {
57 for (i = 0; propnames[i] != NULL; ++i) {
58 pedid = (unsigned char *)
59 get_property(dp, propnames[i],
60 NULL);
61 if (pedid != NULL)
62 break;
63 }
64 of_node_put(dp);
65 break;
66 }
67 }
68 }
69 if (pedid == NULL) {
50 for (i = 0; propnames[i] != NULL; ++i) { 70 for (i = 0; propnames[i] != NULL; ++i) {
51 pedid = (unsigned char *) 71 pedid = (unsigned char *)
52 get_property(dp, propnames[i], NULL); 72 get_property(parent, propnames[i], NULL);
53 if (pedid != NULL) { 73 if (pedid != NULL)
54 *out_edid = pedid; 74 break;
55 return 0;
56 }
57 } 75 }
58 } 76 }
59 return 1; 77 if (pedid) {
78 *out_edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
79 if (*out_edid == NULL)
80 return -1;
81 memcpy(*out_edid, pedid, EDID_LENGTH);
82 printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn);
83 return 0;
84 }
85 return -1;
60} 86}
diff --git a/drivers/video/nvidia/nv_proto.h b/drivers/video/nvidia/nv_proto.h
index cac44fc7f587..f60b1f432270 100644
--- a/drivers/video/nvidia/nv_proto.h
+++ b/drivers/video/nvidia/nv_proto.h
@@ -31,7 +31,7 @@ int NVShowHideCursor(struct nvidia_par *par, int);
31void NVLockUnlock(struct nvidia_par *par, int); 31void NVLockUnlock(struct nvidia_par *par, int);
32 32
33/* in nvidia-i2c.c */ 33/* in nvidia-i2c.c */
34#if defined(CONFIG_FB_NVIDIA_I2C) || defined (CONFIG_PPC_OF) 34#ifdef CONFIG_FB_NVIDIA_I2C
35void nvidia_create_i2c_busses(struct nvidia_par *par); 35void nvidia_create_i2c_busses(struct nvidia_par *par);
36void nvidia_delete_i2c_busses(struct nvidia_par *par); 36void nvidia_delete_i2c_busses(struct nvidia_par *par);
37int nvidia_probe_i2c_connector(struct fb_info *info, int conn, 37int nvidia_probe_i2c_connector(struct fb_info *info, int conn,
@@ -39,10 +39,18 @@ int nvidia_probe_i2c_connector(struct fb_info *info, int conn,
39#else 39#else
40#define nvidia_create_i2c_busses(...) 40#define nvidia_create_i2c_busses(...)
41#define nvidia_delete_i2c_busses(...) 41#define nvidia_delete_i2c_busses(...)
42#define nvidia_probe_i2c_connector(p, c, edid) \ 42#define nvidia_probe_i2c_connector(p, c, edid) (-1)
43do { \ 43#endif
44 *(edid) = NULL; \ 44
45} while(0) 45#ifdef CONFIG_FB_OF
46int nvidia_probe_of_connector(struct fb_info *info, int conn,
47 u8 ** out_edid);
48#else
49static inline int nvidia_probe_of_connector(struct fb_info *info, int conn,
50 u8 ** out_edid)
51{
52 return -1;
53}
46#endif 54#endif
47 55
48/* in nv_accel.c */ 56/* in nv_accel.c */
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c
index 11c84178f420..1f06a9f1bd0f 100644
--- a/drivers/video/nvidia/nv_setup.c
+++ b/drivers/video/nvidia/nv_setup.c
@@ -190,9 +190,9 @@ static int NVIsConnected(struct nvidia_par *par, int output)
190 present = (NV_RD32(PRAMDAC, 0x0608) & (1 << 28)) ? 1 : 0; 190 present = (NV_RD32(PRAMDAC, 0x0608) & (1 << 28)) ? 1 : 0;
191 191
192 if (present) 192 if (present)
193 printk("nvidiafb: CRTC%i found\n", output); 193 printk("nvidiafb: CRTC%i analog found\n", output);
194 else 194 else
195 printk("nvidiafb: CRTC%i not found\n", output); 195 printk("nvidiafb: CRTC%i analog not found\n", output);
196 196
197 NV_WR32(par->PRAMDAC0, 0x0608, NV_RD32(par->PRAMDAC0, 0x0608) & 197 NV_WR32(par->PRAMDAC0, 0x0608, NV_RD32(par->PRAMDAC0, 0x0608) &
198 0x0000EFFF); 198 0x0000EFFF);
@@ -305,6 +305,9 @@ void NVCommonSetup(struct fb_info *info)
305 int FlatPanel = -1; /* really means the CRTC is slaved */ 305 int FlatPanel = -1; /* really means the CRTC is slaved */
306 int Television = 0; 306 int Television = 0;
307 307
308 memset(&monitorA, 0, sizeof(struct fb_monspecs));
309 memset(&monitorB, 0, sizeof(struct fb_monspecs));
310
308 par->PRAMIN = par->REGS + (0x00710000 / 4); 311 par->PRAMIN = par->REGS + (0x00710000 / 4);
309 par->PCRTC0 = par->REGS + (0x00600000 / 4); 312 par->PCRTC0 = par->REGS + (0x00600000 / 4);
310 par->PRAMDAC0 = par->REGS + (0x00680000 / 4); 313 par->PRAMDAC0 = par->REGS + (0x00680000 / 4);
@@ -401,7 +404,8 @@ void NVCommonSetup(struct fb_info *info)
401 nvidia_create_i2c_busses(par); 404 nvidia_create_i2c_busses(par);
402 if (!par->twoHeads) { 405 if (!par->twoHeads) {
403 par->CRTCnumber = 0; 406 par->CRTCnumber = 0;
404 nvidia_probe_i2c_connector(info, 1, &edidA); 407 if (nvidia_probe_i2c_connector(info, 1, &edidA))
408 nvidia_probe_of_connector(info, 1, &edidA);
405 if (edidA && !fb_parse_edid(edidA, &var)) { 409 if (edidA && !fb_parse_edid(edidA, &var)) {
406 printk("nvidiafb: EDID found from BUS1\n"); 410 printk("nvidiafb: EDID found from BUS1\n");
407 monA = &monitorA; 411 monA = &monitorA;
@@ -488,14 +492,16 @@ void NVCommonSetup(struct fb_info *info)
488 oldhead = NV_RD32(par->PCRTC0, 0x00000860); 492 oldhead = NV_RD32(par->PCRTC0, 0x00000860);
489 NV_WR32(par->PCRTC0, 0x00000860, oldhead | 0x00000010); 493 NV_WR32(par->PCRTC0, 0x00000860, oldhead | 0x00000010);
490 494
491 nvidia_probe_i2c_connector(info, 1, &edidA); 495 if (nvidia_probe_i2c_connector(info, 1, &edidA))
496 nvidia_probe_of_connector(info, 1, &edidA);
492 if (edidA && !fb_parse_edid(edidA, &var)) { 497 if (edidA && !fb_parse_edid(edidA, &var)) {
493 printk("nvidiafb: EDID found from BUS1\n"); 498 printk("nvidiafb: EDID found from BUS1\n");
494 monA = &monitorA; 499 monA = &monitorA;
495 fb_edid_to_monspecs(edidA, monA); 500 fb_edid_to_monspecs(edidA, monA);
496 } 501 }
497 502
498 nvidia_probe_i2c_connector(info, 2, &edidB); 503 if (nvidia_probe_i2c_connector(info, 2, &edidB))
504 nvidia_probe_of_connector(info, 2, &edidB);
499 if (edidB && !fb_parse_edid(edidB, &var)) { 505 if (edidB && !fb_parse_edid(edidB, &var)) {
500 printk("nvidiafb: EDID found from BUS2\n"); 506 printk("nvidiafb: EDID found from BUS2\n");
501 monB = &monitorB; 507 monB = &monitorB;
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index 308defc389a2..0b40a2a721c1 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -411,6 +411,7 @@ MODULE_DEVICE_TABLE(pci, nvidiafb_pci_tbl);
411 411
412/* command line data, set in nvidiafb_setup() */ 412/* command line data, set in nvidiafb_setup() */
413static int flatpanel __devinitdata = -1; /* Autodetect later */ 413static int flatpanel __devinitdata = -1; /* Autodetect later */
414static int fpdither __devinitdata = -1;
414static int forceCRTC __devinitdata = -1; 415static int forceCRTC __devinitdata = -1;
415static int hwcur __devinitdata = 0; 416static int hwcur __devinitdata = 0;
416static int noaccel __devinitdata = 0; 417static int noaccel __devinitdata = 0;
@@ -627,41 +628,85 @@ static void nvidia_save_vga(struct nvidia_par *par,
627 NVTRACE_LEAVE(); 628 NVTRACE_LEAVE();
628} 629}
629 630
631#undef DUMP_REG
632
630static void nvidia_write_regs(struct nvidia_par *par) 633static void nvidia_write_regs(struct nvidia_par *par)
631{ 634{
632 struct _riva_hw_state *state = &par->ModeReg; 635 struct _riva_hw_state *state = &par->ModeReg;
633 int i; 636 int i;
634 637
635 NVTRACE_ENTER(); 638 NVTRACE_ENTER();
636 NVWriteCrtc(par, 0x11, 0x00);
637
638 NVLockUnlock(par, 0);
639 639
640 NVLoadStateExt(par, state); 640 NVLoadStateExt(par, state);
641 641
642 NVWriteMiscOut(par, state->misc_output); 642 NVWriteMiscOut(par, state->misc_output);
643 643
644 for (i = 1; i < NUM_SEQ_REGS; i++) {
645#ifdef DUMP_REG
646 printk(" SEQ[%02x] = %08x\n", i, state->seq[i]);
647#endif
648 NVWriteSeq(par, i, state->seq[i]);
649 }
650
651 /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */
652 NVWriteCrtc(par, 0x11, state->crtc[0x11] & ~0x80);
653
644 for (i = 0; i < NUM_CRT_REGS; i++) { 654 for (i = 0; i < NUM_CRT_REGS; i++) {
645 switch (i) { 655 switch (i) {
646 case 0x19: 656 case 0x19:
647 case 0x20 ... 0x40: 657 case 0x20 ... 0x40:
648 break; 658 break;
649 default: 659 default:
660#ifdef DUMP_REG
661 printk("CRTC[%02x] = %08x\n", i, state->crtc[i]);
662#endif
650 NVWriteCrtc(par, i, state->crtc[i]); 663 NVWriteCrtc(par, i, state->crtc[i]);
651 } 664 }
652 } 665 }
653 666
654 for (i = 0; i < NUM_ATC_REGS; i++) 667 for (i = 0; i < NUM_GRC_REGS; i++) {
655 NVWriteAttr(par, i, state->attr[i]); 668#ifdef DUMP_REG
656 669 printk(" GRA[%02x] = %08x\n", i, state->gra[i]);
657 for (i = 0; i < NUM_GRC_REGS; i++) 670#endif
658 NVWriteGr(par, i, state->gra[i]); 671 NVWriteGr(par, i, state->gra[i]);
672 }
673
674 for (i = 0; i < NUM_ATC_REGS; i++) {
675#ifdef DUMP_REG
676 printk("ATTR[%02x] = %08x\n", i, state->attr[i]);
677#endif
678 NVWriteAttr(par, i, state->attr[i]);
679 }
659 680
660 for (i = 0; i < NUM_SEQ_REGS; i++)
661 NVWriteSeq(par, i, state->seq[i]);
662 NVTRACE_LEAVE(); 681 NVTRACE_LEAVE();
663} 682}
664 683
684static void nvidia_vga_protect(struct nvidia_par *par, int on)
685{
686 unsigned char tmp;
687
688 if (on) {
689 /*
690 * Turn off screen and disable sequencer.
691 */
692 tmp = NVReadSeq(par, 0x01);
693
694 NVWriteSeq(par, 0x00, 0x01); /* Synchronous Reset */
695 NVWriteSeq(par, 0x01, tmp | 0x20); /* disable the display */
696 } else {
697 /*
698 * Reenable sequencer, then turn on screen.
699 */
700
701 tmp = NVReadSeq(par, 0x01);
702
703 NVWriteSeq(par, 0x01, tmp & ~0x20); /* reenable display */
704 NVWriteSeq(par, 0x00, 0x03); /* End Reset */
705 }
706}
707
708
709
665static int nvidia_calc_regs(struct fb_info *info) 710static int nvidia_calc_regs(struct fb_info *info)
666{ 711{
667 struct nvidia_par *par = info->par; 712 struct nvidia_par *par = info->par;
@@ -868,7 +913,7 @@ static void nvidia_init_vga(struct fb_info *info)
868 for (i = 0; i < 0x10; i++) 913 for (i = 0; i < 0x10; i++)
869 state->attr[i] = i; 914 state->attr[i] = i;
870 state->attr[0x10] = 0x41; 915 state->attr[0x10] = 0x41;
871 state->attr[0x11] = 0x01; 916 state->attr[0x11] = 0xff;
872 state->attr[0x12] = 0x0f; 917 state->attr[0x12] = 0x0f;
873 state->attr[0x13] = 0x00; 918 state->attr[0x13] = 0x00;
874 state->attr[0x14] = 0x00; 919 state->attr[0x14] = 0x00;
@@ -982,16 +1027,24 @@ static int nvidiafb_set_par(struct fb_info *info)
982 NVTRACE_ENTER(); 1027 NVTRACE_ENTER();
983 1028
984 NVLockUnlock(par, 1); 1029 NVLockUnlock(par, 1);
985 if (!par->FlatPanel || (info->var.bits_per_pixel != 24) || 1030 if (!par->FlatPanel || !par->twoHeads)
986 !par->twoHeads)
987 par->FPDither = 0; 1031 par->FPDither = 0;
988 1032
1033 if (par->FPDither < 0) {
1034 if ((par->Chipset & 0x0ff0) == 0x0110)
1035 par->FPDither = !!(NV_RD32(par->PRAMDAC, 0x0528)
1036 & 0x00010000);
1037 else
1038 par->FPDither = !!(NV_RD32(par->PRAMDAC, 0x083C) & 1);
1039 printk(KERN_INFO PFX "Flat panel dithering %s\n",
1040 par->FPDither ? "enabled" : "disabled");
1041 }
1042
989 info->fix.visual = (info->var.bits_per_pixel == 8) ? 1043 info->fix.visual = (info->var.bits_per_pixel == 8) ?
990 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; 1044 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
991 1045
992 nvidia_init_vga(info); 1046 nvidia_init_vga(info);
993 nvidia_calc_regs(info); 1047 nvidia_calc_regs(info);
994 nvidia_write_regs(par);
995 1048
996 NVLockUnlock(par, 0); 1049 NVLockUnlock(par, 0);
997 if (par->twoHeads) { 1050 if (par->twoHeads) {
@@ -1000,7 +1053,22 @@ static int nvidiafb_set_par(struct fb_info *info)
1000 NVLockUnlock(par, 0); 1053 NVLockUnlock(par, 0);
1001 } 1054 }
1002 1055
1003 NVWriteCrtc(par, 0x11, 0x00); 1056 nvidia_vga_protect(par, 1);
1057
1058 nvidia_write_regs(par);
1059
1060#if defined (__BIG_ENDIAN)
1061 /* turn on LFB swapping */
1062 {
1063 unsigned char tmp;
1064
1065 VGA_WR08(par->PCIO, 0x3d4, 0x46);
1066 tmp = VGA_RD08(par->PCIO, 0x3d5);
1067 tmp |= (1 << 7);
1068 VGA_WR08(par->PCIO, 0x3d5, tmp);
1069 }
1070#endif
1071
1004 info->fix.line_length = (info->var.xres_virtual * 1072 info->fix.line_length = (info->var.xres_virtual *
1005 info->var.bits_per_pixel) >> 3; 1073 info->var.bits_per_pixel) >> 3;
1006 if (info->var.accel_flags) { 1074 if (info->var.accel_flags) {
@@ -1022,7 +1090,7 @@ static int nvidiafb_set_par(struct fb_info *info)
1022 1090
1023 par->cursor_reset = 1; 1091 par->cursor_reset = 1;
1024 1092
1025 NVWriteCrtc(par, 0x11, 0xff); 1093 nvidia_vga_protect(par, 0);
1026 1094
1027 NVTRACE_LEAVE(); 1095 NVTRACE_LEAVE();
1028 return 0; 1096 return 0;
@@ -1315,22 +1383,10 @@ static int __devinit nvidia_set_fbinfo(struct fb_info *info)
1315 fb_var_to_videomode(&modedb, &nvidiafb_default_var); 1383 fb_var_to_videomode(&modedb, &nvidiafb_default_var);
1316 1384
1317 if (specs->modedb != NULL) { 1385 if (specs->modedb != NULL) {
1318 /* get preferred timing */ 1386 struct fb_videomode *modedb;
1319 if (specs->misc & FB_MISC_1ST_DETAIL) {
1320 int i;
1321
1322 for (i = 0; i < specs->modedb_len; i++) {
1323 if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
1324 modedb = specs->modedb[i];
1325 break;
1326 }
1327 }
1328 } else {
1329 /* otherwise, get first mode in database */
1330 modedb = specs->modedb[0];
1331 }
1332 1387
1333 fb_videomode_to_var(&nvidiafb_default_var, &modedb); 1388 modedb = fb_find_best_display(specs, &info->modelist);
1389 fb_videomode_to_var(&nvidiafb_default_var, modedb);
1334 nvidiafb_default_var.bits_per_pixel = 8; 1390 nvidiafb_default_var.bits_per_pixel = 8;
1335 } else if (par->fpWidth && par->fpHeight) { 1391 } else if (par->fpWidth && par->fpHeight) {
1336 char buf[16]; 1392 char buf[16];
@@ -1365,7 +1421,7 @@ static int __devinit nvidia_set_fbinfo(struct fb_info *info)
1365 info->pixmap.flags = FB_PIXMAP_SYSTEM; 1421 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1366 1422
1367 if (!hwcur) 1423 if (!hwcur)
1368 info->fbops->fb_cursor = soft_cursor; 1424 info->fbops->fb_cursor = NULL;
1369 1425
1370 info->var.accel_flags = (!noaccel); 1426 info->var.accel_flags = (!noaccel);
1371 1427
@@ -1490,9 +1546,9 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd,
1490 sprintf(nvidiafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4); 1546 sprintf(nvidiafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4);
1491 1547
1492 par->FlatPanel = flatpanel; 1548 par->FlatPanel = flatpanel;
1493
1494 if (flatpanel == 1) 1549 if (flatpanel == 1)
1495 printk(KERN_INFO PFX "flatpanel support enabled\n"); 1550 printk(KERN_INFO PFX "flatpanel support enabled\n");
1551 par->FPDither = fpdither;
1496 1552
1497 par->CRTCnumber = forceCRTC; 1553 par->CRTCnumber = forceCRTC;
1498 par->FpScale = (!noscale); 1554 par->FpScale = (!noscale);
@@ -1671,6 +1727,8 @@ static int __devinit nvidiafb_setup(char *options)
1671 } else if (!strncmp(this_opt, "nomtrr", 6)) { 1727 } else if (!strncmp(this_opt, "nomtrr", 6)) {
1672 nomtrr = 1; 1728 nomtrr = 1;
1673#endif 1729#endif
1730 } else if (!strncmp(this_opt, "fpdither:", 9)) {
1731 fpdither = simple_strtol(this_opt+9, NULL, 0);
1674 } else 1732 } else
1675 mode_option = this_opt; 1733 mode_option = this_opt;
1676 } 1734 }
@@ -1717,7 +1775,11 @@ module_exit(nvidiafb_exit);
1717module_param(flatpanel, int, 0); 1775module_param(flatpanel, int, 0);
1718MODULE_PARM_DESC(flatpanel, 1776MODULE_PARM_DESC(flatpanel,
1719 "Enables experimental flat panel support for some chipsets. " 1777 "Enables experimental flat panel support for some chipsets. "
1720 "(0 or 1=enabled) (default=0)"); 1778 "(0=disabled, 1=enabled, -1=autodetect) (default=-1)");
1779module_param(fpdither, int, 0);
1780MODULE_PARM_DESC(fpdither,
1781 "Enables dithering of flat panel for 6 bits panels. "
1782 "(0=disabled, 1=enabled, -1=autodetect) (default=-1)");
1721module_param(hwcur, int, 0); 1783module_param(hwcur, int, 0);
1722MODULE_PARM_DESC(hwcur, 1784MODULE_PARM_DESC(hwcur,
1723 "Enables hardware cursor implementation. (0 or 1=enabled) " 1785 "Enables hardware cursor implementation. (0 or 1=enabled) "
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 611922c0b22f..2c856838694e 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -85,7 +85,6 @@ static struct fb_ops offb_ops = {
85 .fb_fillrect = cfb_fillrect, 85 .fb_fillrect = cfb_fillrect,
86 .fb_copyarea = cfb_copyarea, 86 .fb_copyarea = cfb_copyarea,
87 .fb_imageblit = cfb_imageblit, 87 .fb_imageblit = cfb_imageblit,
88 .fb_cursor = soft_cursor,
89}; 88};
90 89
91 /* 90 /*
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index b76a5a9a125b..9aaf65fb623a 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -48,7 +48,6 @@ 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 .fb_cursor = soft_cursor,
52}; 51};
53 52
54/* P9100 control registers */ 53/* P9100 control registers */
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index b00887e9851c..ca4082ae5a18 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -109,7 +109,6 @@ static struct fb_ops platinumfb_ops = {
109 .fb_fillrect = cfb_fillrect, 109 .fb_fillrect = cfb_fillrect,
110 .fb_copyarea = cfb_copyarea, 110 .fb_copyarea = cfb_copyarea,
111 .fb_imageblit = cfb_imageblit, 111 .fb_imageblit = cfb_imageblit,
112 .fb_cursor = soft_cursor,
113}; 112};
114 113
115/* 114/*
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c
index 42c17efa9fb0..0277ce031e5e 100644
--- a/drivers/video/pm2fb.c
+++ b/drivers/video/pm2fb.c
@@ -1034,7 +1034,6 @@ static struct fb_ops pm2fb_ops = {
1034 .fb_fillrect = cfb_fillrect, 1034 .fb_fillrect = cfb_fillrect,
1035 .fb_copyarea = cfb_copyarea, 1035 .fb_copyarea = cfb_copyarea,
1036 .fb_imageblit = cfb_imageblit, 1036 .fb_imageblit = cfb_imageblit,
1037 .fb_cursor = soft_cursor,
1038}; 1037};
1039 1038
1040/* 1039/*
@@ -1121,6 +1120,22 @@ static int __devinit pm2fb_probe(struct pci_dev *pdev,
1121 default_par->mem_control, default_par->boot_address, 1120 default_par->mem_control, default_par->boot_address,
1122 default_par->mem_config); 1121 default_par->mem_config);
1123 1122
1123 if(default_par->mem_control == 0 &&
1124 default_par->boot_address == 0x31 &&
1125 default_par->mem_config == 0x259fffff &&
1126 pdev->subsystem_vendor == 0x1048 &&
1127 pdev->subsystem_device == 0x0a31) {
1128 DPRINTK("subsystem_vendor: %04x, subsystem_device: %04x\n",
1129 pdev->subsystem_vendor, pdev->subsystem_device);
1130 DPRINTK("We have not been initialized by VGA BIOS "
1131 "and are running on an Elsa Winner 2000 Office\n");
1132 DPRINTK("Initializing card timings manually...\n");
1133 default_par->mem_control=0;
1134 default_par->boot_address=0x20;
1135 default_par->mem_config=0xe6002021;
1136 default_par->memclock=100000;
1137 }
1138
1124 /* Now work out how big lfb is going to be. */ 1139 /* Now work out how big lfb is going to be. */
1125 switch(default_par->mem_config & PM2F_MEM_CONFIG_RAM_MASK) { 1140 switch(default_par->mem_config & PM2F_MEM_CONFIG_RAM_MASK) {
1126 case PM2F_MEM_BANKS_1: 1141 case PM2F_MEM_BANKS_1:
diff --git a/drivers/video/pmag-ba-fb.c b/drivers/video/pmag-ba-fb.c
index c98f1c8d7dc2..f3927b6cda9d 100644
--- a/drivers/video/pmag-ba-fb.c
+++ b/drivers/video/pmag-ba-fb.c
@@ -128,7 +128,6 @@ static struct fb_ops pmagbafb_ops = {
128 .fb_fillrect = cfb_fillrect, 128 .fb_fillrect = cfb_fillrect,
129 .fb_copyarea = cfb_copyarea, 129 .fb_copyarea = cfb_copyarea,
130 .fb_imageblit = cfb_imageblit, 130 .fb_imageblit = cfb_imageblit,
131 .fb_cursor = soft_cursor,
132}; 131};
133 132
134 133
diff --git a/drivers/video/pmagb-b-fb.c b/drivers/video/pmagb-b-fb.c
index a483b13e117b..25148de5fe67 100644
--- a/drivers/video/pmagb-b-fb.c
+++ b/drivers/video/pmagb-b-fb.c
@@ -132,7 +132,6 @@ static struct fb_ops pmagbbfb_ops = {
132 .fb_fillrect = cfb_fillrect, 132 .fb_fillrect = cfb_fillrect,
133 .fb_copyarea = cfb_copyarea, 133 .fb_copyarea = cfb_copyarea,
134 .fb_imageblit = cfb_imageblit, 134 .fb_imageblit = cfb_imageblit,
135 .fb_cursor = soft_cursor,
136}; 135};
137 136
138 137
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 31c547fd383b..ec4bacf9dd2e 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -230,7 +230,6 @@ static struct fb_ops pvr2fb_ops = {
230 .fb_fillrect = cfb_fillrect, 230 .fb_fillrect = cfb_fillrect,
231 .fb_copyarea = cfb_copyarea, 231 .fb_copyarea = cfb_copyarea,
232 .fb_imageblit = cfb_imageblit, 232 .fb_imageblit = cfb_imageblit,
233 .fb_cursor = soft_cursor,
234}; 233};
235 234
236static struct fb_videomode pvr2_modedb[] __initdata = { 235static struct fb_videomode pvr2_modedb[] __initdata = {
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index efd9333b05c2..f305a5b77b23 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -418,7 +418,6 @@ static struct fb_ops pxafb_ops = {
418 .fb_copyarea = cfb_copyarea, 418 .fb_copyarea = cfb_copyarea,
419 .fb_imageblit = cfb_imageblit, 419 .fb_imageblit = cfb_imageblit,
420 .fb_blank = pxafb_blank, 420 .fb_blank = pxafb_blank,
421 .fb_cursor = soft_cursor,
422 .fb_mmap = pxafb_mmap, 421 .fb_mmap = pxafb_mmap,
423}; 422};
424 423
diff --git a/drivers/video/q40fb.c b/drivers/video/q40fb.c
index 8416b2e2b501..bfc41f2c902a 100644
--- a/drivers/video/q40fb.c
+++ b/drivers/video/q40fb.c
@@ -84,7 +84,6 @@ static struct fb_ops q40fb_ops = {
84 .fb_fillrect = cfb_fillrect, 84 .fb_fillrect = cfb_fillrect,
85 .fb_copyarea = cfb_copyarea, 85 .fb_copyarea = cfb_copyarea,
86 .fb_imageblit = cfb_imageblit, 86 .fb_imageblit = cfb_imageblit,
87 .fb_cursor = soft_cursor,
88}; 87};
89 88
90static int __init q40fb_probe(struct device *device) 89static int __init q40fb_probe(struct device *device)
diff --git a/drivers/video/radeonfb.c b/drivers/video/radeonfb.c
index a78b9bd8f897..600318f708f2 100644
--- a/drivers/video/radeonfb.c
+++ b/drivers/video/radeonfb.c
@@ -2218,7 +2218,6 @@ static struct fb_ops radeonfb_ops = {
2218 .fb_copyarea = cfb_copyarea, 2218 .fb_copyarea = cfb_copyarea,
2219 .fb_imageblit = cfb_imageblit, 2219 .fb_imageblit = cfb_imageblit,
2220#endif 2220#endif
2221 .fb_cursor = soft_cursor,
2222}; 2221};
2223 2222
2224 2223
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index f4437430dc5f..3edbd14c5c46 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -388,7 +388,6 @@ static struct fb_ops s1d13xxxfb_fbops = {
388 .fb_fillrect = cfb_fillrect, 388 .fb_fillrect = cfb_fillrect,
389 .fb_copyarea = cfb_copyarea, 389 .fb_copyarea = cfb_copyarea,
390 .fb_imageblit = cfb_imageblit, 390 .fb_imageblit = cfb_imageblit,
391 .fb_cursor = soft_cursor
392}; 391};
393 392
394static int s1d13xxxfb_width_tab[2][4] __devinitdata = { 393static int s1d13xxxfb_width_tab[2][4] __devinitdata = {
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index 3cef90456a4b..855a6778b9eb 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -495,7 +495,6 @@ static struct fb_ops s3c2410fb_ops = {
495 .fb_fillrect = cfb_fillrect, 495 .fb_fillrect = cfb_fillrect,
496 .fb_copyarea = cfb_copyarea, 496 .fb_copyarea = cfb_copyarea,
497 .fb_imageblit = cfb_imageblit, 497 .fb_imageblit = cfb_imageblit,
498 .fb_cursor = soft_cursor,
499}; 498};
500 499
501 500
@@ -885,6 +884,7 @@ static int s3c2410fb_resume(struct device *dev)
885 884
886static struct device_driver s3c2410fb_driver = { 885static struct device_driver s3c2410fb_driver = {
887 .name = "s3c2410-lcd", 886 .name = "s3c2410-lcd",
887 .owner = THIS_MODULE,
888 .bus = &platform_bus_type, 888 .bus = &platform_bus_type,
889 .probe = s3c2410fb_probe, 889 .probe = s3c2410fb_probe,
890 .suspend = s3c2410fb_suspend, 890 .suspend = s3c2410fb_suspend,
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
index 3d35b28aaac7..a5184575cfae 100644
--- a/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -853,7 +853,6 @@ static struct fb_ops sa1100fb_ops = {
853 .fb_copyarea = cfb_copyarea, 853 .fb_copyarea = cfb_copyarea,
854 .fb_imageblit = cfb_imageblit, 854 .fb_imageblit = cfb_imageblit,
855 .fb_blank = sa1100fb_blank, 855 .fb_blank = sa1100fb_blank,
856 .fb_cursor = soft_cursor,
857 .fb_mmap = sa1100fb_mmap, 856 .fb_mmap = sa1100fb_mmap,
858}; 857};
859 858
diff --git a/drivers/video/savage/savagefb.h b/drivers/video/savage/savagefb.h
index ea17f7e0482c..58cfdfb41833 100644
--- a/drivers/video/savage/savagefb.h
+++ b/drivers/video/savage/savagefb.h
@@ -169,6 +169,7 @@ struct savagefb_par {
169 struct savagefb_i2c_chan chan; 169 struct savagefb_i2c_chan chan;
170 unsigned char *edid; 170 unsigned char *edid;
171 u32 pseudo_palette[16]; 171 u32 pseudo_palette[16];
172 int paletteEnabled;
172 int pm_state; 173 int pm_state;
173 int display_type; 174 int display_type;
174 int dvi; 175 int dvi;
@@ -244,105 +245,150 @@ struct savagefb_par {
244 245
245 246
246/* IO functions */ 247/* IO functions */
248static inline u8 savage_in8(u32 addr, struct savagefb_par *par)
249{
250 return readb(par->mmio.vbase + addr);
251}
252
253static inline u16 savage_in16(u32 addr, struct savagefb_par *par)
254{
255 return readw(par->mmio.vbase + addr);
256}
257
258static inline u32 savage_in32(u32 addr, struct savagefb_par *par)
259{
260 return readl(par->mmio.vbase + addr);
261}
262
263static inline void savage_out8(u32 addr, u8 val, struct savagefb_par *par)
264{
265 writeb(val, par->mmio.vbase + addr);
266}
267
268static inline void savage_out16(u32 addr, u16 val, struct savagefb_par *par)
269{
270 writew(val, par->mmio.vbase + addr);
271}
272
273static inline void savage_out32(u32 addr, u32 val, struct savagefb_par *par)
274{
275 writel(val, par->mmio.vbase + addr);
276}
277
278static inline u8 vga_in8(int addr, struct savagefb_par *par)
279{
280 return savage_in8(0x8000 + addr, par);
281}
282
283static inline u16 vga_in16(int addr, struct savagefb_par *par)
284{
285 return savage_in16(0x8000 + addr, par);
286}
287
288static inline u8 vga_in32(int addr, struct savagefb_par *par)
289{
290 return savage_in32(0x8000 + addr, par);
291}
292
293static inline void vga_out8(int addr, u8 val, struct savagefb_par *par)
294{
295 savage_out8(0x8000 + addr, val, par);
296}
297
298static inline void vga_out16(int addr, u16 val, struct savagefb_par *par)
299{
300 savage_out16(0x8000 + addr, val, par);
301}
302
303static inline void vga_out32(int addr, u32 val, struct savagefb_par *par)
304{
305 savage_out32(0x8000 + addr, val, par);
306}
247 307
248#define vga_in8(addr) (inb (addr)) 308static inline u8 VGArCR (u8 index, struct savagefb_par *par)
249#define vga_in16(addr) (inw (addr)) 309{
250#define vga_in32(addr) (inl (addr)) 310 vga_out8(0x3d4, index, par);
311 return vga_in8(0x3d5, par);
312}
313
314static inline u8 VGArGR (u8 index, struct savagefb_par *par)
315{
316 vga_out8(0x3ce, index, par);
317 return vga_in8(0x3cf, par);
318}
319
320static inline u8 VGArSEQ (u8 index, struct savagefb_par *par)
321{
322 vga_out8(0x3c4, index, par);
323 return vga_in8(0x3c5, par);
324}
251 325
252#define vga_out8(addr,val) (outb ((val), (addr))) 326static inline void VGAwCR(u8 index, u8 val, struct savagefb_par *par)
253#define vga_out16(addr,val) (outw ((val), (addr))) 327{
254#define vga_out32(addr,val) (outl ((val), (addr))) 328 vga_out8(0x3d4, index, par);
329 vga_out8(0x3d5, val, par);
330}
255 331
256#define savage_in16(addr) readw(par->mmio.vbase + (addr)) 332static inline void VGAwGR(u8 index, u8 val, struct savagefb_par *par)
257#define savage_in32(addr) readl(par->mmio.vbase + (addr)) 333{
334 vga_out8(0x3ce, index, par);
335 vga_out8(0x3cf, val, par);
336}
258 337
259#define savage_out16(addr,val) writew((val), par->mmio.vbase + (addr)) 338static inline void VGAwSEQ(u8 index, u8 val, struct savagefb_par *par)
260#define savage_out32(addr,val) writel((val), par->mmio.vbase + (addr)) 339{
340 vga_out8(0x3c4, index, par);
341 vga_out8 (0x3c5, val, par);
342}
261 343
262static inline u8 VGArCR (u8 index) 344static inline void VGAenablePalette(struct savagefb_par *par)
263{ 345{
264 outb (index, 0x3d4); 346 u8 tmp;
265 return inb (0x3d5); 347
348 tmp = vga_in8(0x3da, par);
349 vga_out8(0x3c0, 0x00, par);
350 par->paletteEnabled = 1;
266} 351}
267 352
268static inline u8 VGArGR (u8 index) 353static inline void VGAdisablePalette(struct savagefb_par *par)
269{ 354{
270 outb (index, 0x3ce); 355 u8 tmp;
271 return inb (0x3cf); 356
357 tmp = vga_in8(0x3da, par);
358 vga_out8(0x3c0, 0x20, par);
359 par->paletteEnabled = 0;
272} 360}
273 361
274static inline u8 VGArSEQ (u8 index) 362static inline void VGAwATTR(u8 index, u8 value, struct savagefb_par *par)
275{ 363{
276 outb (index, 0x3c4); 364 u8 tmp;
277 return inb (0x3c5); 365
366 if (par->paletteEnabled)
367 index &= ~0x20;
368 else
369 index |= 0x20;
370
371 tmp = vga_in8(0x3da, par);
372 vga_out8(0x3c0, index, par);
373 vga_out8 (0x3c0, value, par);
278} 374}
279 375
280#define VGAwCR(index, val) \ 376static inline void VGAwMISC(u8 value, struct savagefb_par *par)
281do { \ 377{
282 vga_out8 (0x3d4, index); \ 378 vga_out8(0x3c2, value, par);
283 vga_out8 (0x3d5, val); \ 379}
284} while (0)
285
286#define VGAwGR(index, val) \
287do { \
288 vga_out8 (0x3ce, index); \
289 vga_out8 (0x3cf, val); \
290} while (0)
291
292#define VGAwSEQ(index, val) \
293do { \
294 vga_out8 (0x3c4, index); \
295 vga_out8 (0x3c5, val); \
296} while (0)
297
298#define VGAenablePalette() \
299do { \
300 u8 tmp; \
301 \
302 tmp = vga_in8 (0x3da); \
303 vga_out8 (0x3c0, 0x00); \
304 paletteEnabled = 1; \
305} while (0)
306
307#define VGAdisablePalette() \
308do { \
309 u8 tmp; \
310 \
311 tmp = vga_in8 (0x3da); \
312 vga_out8 (0x3c0, 0x20); \
313 paletteEnabled = 0; \
314} while (0)
315
316#define VGAwATTR(index, value) \
317do { \
318 u8 tmp; \
319 \
320 if (paletteEnabled) \
321 index &= ~0x20; \
322 else \
323 index |= 0x20; \
324 \
325 tmp = vga_in8 (0x3da); \
326 vga_out8 (0x3c0, index); \
327 vga_out8 (0x3c0, value); \
328} while (0)
329
330#define VGAwMISC(value) \
331do { \
332 vga_out8 (0x3c2, value); \
333} while (0)
334 380
335#ifndef CONFIG_FB_SAVAGE_ACCEL 381#ifndef CONFIG_FB_SAVAGE_ACCEL
336#define savagefb_set_clip(x) 382#define savagefb_set_clip(x)
337#endif 383#endif
338 384
339#define VerticalRetraceWait() \ 385static inline void VerticalRetraceWait(struct savagefb_par *par)
340{ \ 386{
341 vga_out8 (0x3d4, 0x17); \ 387 vga_out8(0x3d4, 0x17, par);
342 if (vga_in8 (0x3d5) & 0x80) { \ 388 if (vga_in8(0x3d5, par) & 0x80) {
343 while ((vga_in8(0x3da) & 0x08) == 0x08) ; \ 389 while ((vga_in8(0x3da, par) & 0x08) == 0x08);
344 while ((vga_in8(0x3da) & 0x08) == 0x00) ; \ 390 while ((vga_in8(0x3da, par) & 0x08) == 0x00);
345 } \ 391 }
346} 392}
347 393
348extern int savagefb_probe_i2c_connector(struct fb_info *info, 394extern int savagefb_probe_i2c_connector(struct fb_info *info,
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 7c285455c924..f0dfb35e3191 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -74,7 +74,6 @@
74 74
75 75
76static char *mode_option __initdata = NULL; 76static char *mode_option __initdata = NULL;
77static int paletteEnabled = 0;
78 77
79#ifdef MODULE 78#ifdef MODULE
80 79
@@ -90,9 +89,9 @@ MODULE_DESCRIPTION("FBDev driver for S3 Savage PCI/AGP Chips");
90static void vgaHWSeqReset (struct savagefb_par *par, int start) 89static void vgaHWSeqReset (struct savagefb_par *par, int start)
91{ 90{
92 if (start) 91 if (start)
93 VGAwSEQ (0x00, 0x01); /* Synchronous Reset */ 92 VGAwSEQ (0x00, 0x01, par); /* Synchronous Reset */
94 else 93 else
95 VGAwSEQ (0x00, 0x03); /* End Reset */ 94 VGAwSEQ (0x00, 0x03, par); /* End Reset */
96} 95}
97 96
98static void vgaHWProtect (struct savagefb_par *par, int on) 97static void vgaHWProtect (struct savagefb_par *par, int on)
@@ -103,23 +102,23 @@ static void vgaHWProtect (struct savagefb_par *par, int on)
103 /* 102 /*
104 * Turn off screen and disable sequencer. 103 * Turn off screen and disable sequencer.
105 */ 104 */
106 tmp = VGArSEQ (0x01); 105 tmp = VGArSEQ (0x01, par);
107 106
108 vgaHWSeqReset (par, 1); /* start synchronous reset */ 107 vgaHWSeqReset (par, 1); /* start synchronous reset */
109 VGAwSEQ (0x01, tmp | 0x20); /* disable the display */ 108 VGAwSEQ (0x01, tmp | 0x20, par);/* disable the display */
110 109
111 VGAenablePalette(); 110 VGAenablePalette(par);
112 } else { 111 } else {
113 /* 112 /*
114 * Reenable sequencer, then turn on screen. 113 * Reenable sequencer, then turn on screen.
115 */ 114 */
116 115
117 tmp = VGArSEQ (0x01); 116 tmp = VGArSEQ (0x01, par);
118 117
119 VGAwSEQ (0x01, tmp & ~0x20); /* reenable display */ 118 VGAwSEQ (0x01, tmp & ~0x20, par);/* reenable display */
120 vgaHWSeqReset (par, 0); /* clear synchronous reset */ 119 vgaHWSeqReset (par, 0); /* clear synchronous reset */
121 120
122 VGAdisablePalette(); 121 VGAdisablePalette(par);
123 } 122 }
124} 123}
125 124
@@ -127,27 +126,27 @@ static void vgaHWRestore (struct savagefb_par *par)
127{ 126{
128 int i; 127 int i;
129 128
130 VGAwMISC (par->MiscOutReg); 129 VGAwMISC (par->MiscOutReg, par);
131 130
132 for (i = 1; i < 5; i++) 131 for (i = 1; i < 5; i++)
133 VGAwSEQ (i, par->Sequencer[i]); 132 VGAwSEQ (i, par->Sequencer[i], par);
134 133
135 /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or 134 /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or
136 CRTC[17] */ 135 CRTC[17] */
137 VGAwCR (17, par->CRTC[17] & ~0x80); 136 VGAwCR (17, par->CRTC[17] & ~0x80, par);
138 137
139 for (i = 0; i < 25; i++) 138 for (i = 0; i < 25; i++)
140 VGAwCR (i, par->CRTC[i]); 139 VGAwCR (i, par->CRTC[i], par);
141 140
142 for (i = 0; i < 9; i++) 141 for (i = 0; i < 9; i++)
143 VGAwGR (i, par->Graphics[i]); 142 VGAwGR (i, par->Graphics[i], par);
144 143
145 VGAenablePalette(); 144 VGAenablePalette(par);
146 145
147 for (i = 0; i < 21; i++) 146 for (i = 0; i < 21; i++)
148 VGAwATTR (i, par->Attribute[i]); 147 VGAwATTR (i, par->Attribute[i], par);
149 148
150 VGAdisablePalette(); 149 VGAdisablePalette(par);
151} 150}
152 151
153static void vgaHWInit (struct fb_var_screeninfo *var, 152static void vgaHWInit (struct fb_var_screeninfo *var,
@@ -267,7 +266,7 @@ savage3D_waitfifo(struct savagefb_par *par, int space)
267{ 266{
268 int slots = MAXFIFO - space; 267 int slots = MAXFIFO - space;
269 268
270 while ((savage_in32(0x48C00) & 0x0000ffff) > slots); 269 while ((savage_in32(0x48C00, par) & 0x0000ffff) > slots);
271} 270}
272 271
273static void 272static void
@@ -275,7 +274,7 @@ savage4_waitfifo(struct savagefb_par *par, int space)
275{ 274{
276 int slots = MAXFIFO - space; 275 int slots = MAXFIFO - space;
277 276
278 while ((savage_in32(0x48C60) & 0x001fffff) > slots); 277 while ((savage_in32(0x48C60, par) & 0x001fffff) > slots);
279} 278}
280 279
281static void 280static void
@@ -283,26 +282,26 @@ savage2000_waitfifo(struct savagefb_par *par, int space)
283{ 282{
284 int slots = MAXFIFO - space; 283 int slots = MAXFIFO - space;
285 284
286 while ((savage_in32(0x48C60) & 0x0000ffff) > slots); 285 while ((savage_in32(0x48C60, par) & 0x0000ffff) > slots);
287} 286}
288 287
289/* Wait for idle accelerator */ 288/* Wait for idle accelerator */
290static void 289static void
291savage3D_waitidle(struct savagefb_par *par) 290savage3D_waitidle(struct savagefb_par *par)
292{ 291{
293 while ((savage_in32(0x48C00) & 0x0008ffff) != 0x80000); 292 while ((savage_in32(0x48C00, par) & 0x0008ffff) != 0x80000);
294} 293}
295 294
296static void 295static void
297savage4_waitidle(struct savagefb_par *par) 296savage4_waitidle(struct savagefb_par *par)
298{ 297{
299 while ((savage_in32(0x48C60) & 0x00a00000) != 0x00a00000); 298 while ((savage_in32(0x48C60, par) & 0x00a00000) != 0x00a00000);
300} 299}
301 300
302static void 301static void
303savage2000_waitidle(struct savagefb_par *par) 302savage2000_waitidle(struct savagefb_par *par)
304{ 303{
305 while ((savage_in32(0x48C60) & 0x009fffff)); 304 while ((savage_in32(0x48C60, par) & 0x009fffff));
306} 305}
307 306
308 307
@@ -319,59 +318,64 @@ SavageSetup2DEngine (struct savagefb_par *par)
319 case S3_SAVAGE3D: 318 case S3_SAVAGE3D:
320 case S3_SAVAGE_MX: 319 case S3_SAVAGE_MX:
321 /* Disable BCI */ 320 /* Disable BCI */
322 savage_out32(0x48C18, savage_in32(0x48C18) & 0x3FF0); 321 savage_out32(0x48C18, savage_in32(0x48C18, par) & 0x3FF0, par);
323 /* Setup BCI command overflow buffer */ 322 /* Setup BCI command overflow buffer */
324 savage_out32(0x48C14, (par->cob_offset >> 11) | (par->cob_index << 29)); 323 savage_out32(0x48C14,
324 (par->cob_offset >> 11) | (par->cob_index << 29),
325 par);
325 /* Program shadow status update. */ 326 /* Program shadow status update. */
326 savage_out32(0x48C10, 0x78207220); 327 savage_out32(0x48C10, 0x78207220, par);
327 savage_out32(0x48C0C, 0); 328 savage_out32(0x48C0C, 0, par);
328 /* Enable BCI and command overflow buffer */ 329 /* Enable BCI and command overflow buffer */
329 savage_out32(0x48C18, savage_in32(0x48C18) | 0x0C); 330 savage_out32(0x48C18, savage_in32(0x48C18, par) | 0x0C, par);
330 break; 331 break;
331 case S3_SAVAGE4: 332 case S3_SAVAGE4:
332 case S3_PROSAVAGE: 333 case S3_PROSAVAGE:
333 case S3_SUPERSAVAGE: 334 case S3_SUPERSAVAGE:
334 /* Disable BCI */ 335 /* Disable BCI */
335 savage_out32(0x48C18, savage_in32(0x48C18) & 0x3FF0); 336 savage_out32(0x48C18, savage_in32(0x48C18, par) & 0x3FF0, par);
336 /* Program shadow status update */ 337 /* Program shadow status update */
337 savage_out32(0x48C10, 0x00700040); 338 savage_out32(0x48C10, 0x00700040, par);
338 savage_out32(0x48C0C, 0); 339 savage_out32(0x48C0C, 0, par);
339 /* Enable BCI without the COB */ 340 /* Enable BCI without the COB */
340 savage_out32(0x48C18, savage_in32(0x48C18) | 0x08); 341 savage_out32(0x48C18, savage_in32(0x48C18, par) | 0x08, par);
341 break; 342 break;
342 case S3_SAVAGE2000: 343 case S3_SAVAGE2000:
343 /* Disable BCI */ 344 /* Disable BCI */
344 savage_out32(0x48C18, 0); 345 savage_out32(0x48C18, 0, par);
345 /* Setup BCI command overflow buffer */ 346 /* Setup BCI command overflow buffer */
346 savage_out32(0x48C18, (par->cob_offset >> 7) | (par->cob_index)); 347 savage_out32(0x48C18,
348 (par->cob_offset >> 7) | (par->cob_index),
349 par);
347 /* Disable shadow status update */ 350 /* Disable shadow status update */
348 savage_out32(0x48A30, 0); 351 savage_out32(0x48A30, 0, par);
349 /* Enable BCI and command overflow buffer */ 352 /* Enable BCI and command overflow buffer */
350 savage_out32(0x48C18, savage_in32(0x48C18) | 0x00280000 ); 353 savage_out32(0x48C18, savage_in32(0x48C18, par) | 0x00280000,
354 par);
351 break; 355 break;
352 default: 356 default:
353 break; 357 break;
354 } 358 }
355 /* Turn on 16-bit register access. */ 359 /* Turn on 16-bit register access. */
356 vga_out8(0x3d4, 0x31); 360 vga_out8(0x3d4, 0x31, par);
357 vga_out8(0x3d5, 0x0c); 361 vga_out8(0x3d5, 0x0c, par);
358 362
359 /* Set stride to use GBD. */ 363 /* Set stride to use GBD. */
360 vga_out8 (0x3d4, 0x50); 364 vga_out8 (0x3d4, 0x50, par);
361 vga_out8 (0x3d5, vga_in8 (0x3d5 ) | 0xC1); 365 vga_out8 (0x3d5, vga_in8(0x3d5, par) | 0xC1, par);
362 366
363 /* Enable 2D engine. */ 367 /* Enable 2D engine. */
364 vga_out8 (0x3d4, 0x40 ); 368 vga_out8 (0x3d4, 0x40, par);
365 vga_out8 (0x3d5, 0x01 ); 369 vga_out8 (0x3d5, 0x01, par);
366 370
367 savage_out32 (MONO_PAT_0, ~0); 371 savage_out32 (MONO_PAT_0, ~0, par);
368 savage_out32 (MONO_PAT_1, ~0); 372 savage_out32 (MONO_PAT_1, ~0, par);
369 373
370 /* Setup plane masks */ 374 /* Setup plane masks */
371 savage_out32 (0x8128, ~0 ); /* enable all write planes */ 375 savage_out32 (0x8128, ~0, par); /* enable all write planes */
372 savage_out32 (0x812C, ~0 ); /* enable all read planes */ 376 savage_out32 (0x812C, ~0, par); /* enable all read planes */
373 savage_out16 (0x8134, 0x27 ); 377 savage_out16 (0x8134, 0x27, par);
374 savage_out16 (0x8136, 0x07 ); 378 savage_out16 (0x8136, 0x07, par);
375 379
376 /* Now set the GBD */ 380 /* Now set the GBD */
377 par->bci_ptr = 0; 381 par->bci_ptr = 0;
@@ -489,8 +493,8 @@ static void SavagePrintRegs(void)
489 for( i = 0; i < 0x70; i++ ) { 493 for( i = 0; i < 0x70; i++ ) {
490 if( !(i % 16) ) 494 if( !(i % 16) )
491 printk(KERN_DEBUG "\nSR%xx ", i >> 4 ); 495 printk(KERN_DEBUG "\nSR%xx ", i >> 4 );
492 vga_out8( 0x3c4, i ); 496 vga_out8( 0x3c4, i, par);
493 printk(KERN_DEBUG " %02x", vga_in8(0x3c5) ); 497 printk(KERN_DEBUG " %02x", vga_in8(0x3c5, par) );
494 } 498 }
495 499
496 printk(KERN_DEBUG "\n\nCR x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC " 500 printk(KERN_DEBUG "\n\nCR x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC "
@@ -499,8 +503,8 @@ static void SavagePrintRegs(void)
499 for( i = 0; i < 0xB7; i++ ) { 503 for( i = 0; i < 0xB7; i++ ) {
500 if( !(i % 16) ) 504 if( !(i % 16) )
501 printk(KERN_DEBUG "\nCR%xx ", i >> 4 ); 505 printk(KERN_DEBUG "\nCR%xx ", i >> 4 );
502 vga_out8( vgaCRIndex, i ); 506 vga_out8( vgaCRIndex, i, par);
503 printk(KERN_DEBUG " %02x", vga_in8(vgaCRReg) ); 507 printk(KERN_DEBUG " %02x", vga_in8(vgaCRReg, par) );
504 } 508 }
505 509
506 printk(KERN_DEBUG "\n\n"); 510 printk(KERN_DEBUG "\n\n");
@@ -513,152 +517,152 @@ static void savage_get_default_par(struct savagefb_par *par)
513{ 517{
514 unsigned char cr3a, cr53, cr66; 518 unsigned char cr3a, cr53, cr66;
515 519
516 vga_out16 (0x3d4, 0x4838); 520 vga_out16 (0x3d4, 0x4838, par);
517 vga_out16 (0x3d4, 0xa039); 521 vga_out16 (0x3d4, 0xa039, par);
518 vga_out16 (0x3c4, 0x0608); 522 vga_out16 (0x3c4, 0x0608, par);
519 523
520 vga_out8 (0x3d4, 0x66); 524 vga_out8 (0x3d4, 0x66, par);
521 cr66 = vga_in8 (0x3d5); 525 cr66 = vga_in8 (0x3d5, par);
522 vga_out8 (0x3d5, cr66 | 0x80); 526 vga_out8 (0x3d5, cr66 | 0x80, par);
523 vga_out8 (0x3d4, 0x3a); 527 vga_out8 (0x3d4, 0x3a, par);
524 cr3a = vga_in8 (0x3d5); 528 cr3a = vga_in8 (0x3d5, par);
525 vga_out8 (0x3d5, cr3a | 0x80); 529 vga_out8 (0x3d5, cr3a | 0x80, par);
526 vga_out8 (0x3d4, 0x53); 530 vga_out8 (0x3d4, 0x53, par);
527 cr53 = vga_in8 (0x3d5); 531 cr53 = vga_in8 (0x3d5, par);
528 vga_out8 (0x3d5, cr53 & 0x7f); 532 vga_out8 (0x3d5, cr53 & 0x7f, par);
529 533
530 vga_out8 (0x3d4, 0x66); 534 vga_out8 (0x3d4, 0x66, par);
531 vga_out8 (0x3d5, cr66); 535 vga_out8 (0x3d5, cr66, par);
532 vga_out8 (0x3d4, 0x3a); 536 vga_out8 (0x3d4, 0x3a, par);
533 vga_out8 (0x3d5, cr3a); 537 vga_out8 (0x3d5, cr3a, par);
534 538
535 vga_out8 (0x3d4, 0x66); 539 vga_out8 (0x3d4, 0x66, par);
536 vga_out8 (0x3d5, cr66); 540 vga_out8 (0x3d5, cr66, par);
537 vga_out8 (0x3d4, 0x3a); 541 vga_out8 (0x3d4, 0x3a, par);
538 vga_out8 (0x3d5, cr3a); 542 vga_out8 (0x3d5, cr3a, par);
539 543
540 /* unlock extended seq regs */ 544 /* unlock extended seq regs */
541 vga_out8 (0x3c4, 0x08); 545 vga_out8 (0x3c4, 0x08, par);
542 par->SR08 = vga_in8 (0x3c5); 546 par->SR08 = vga_in8 (0x3c5, par);
543 vga_out8 (0x3c5, 0x06); 547 vga_out8 (0x3c5, 0x06, par);
544 548
545 /* now save all the extended regs we need */ 549 /* now save all the extended regs we need */
546 vga_out8 (0x3d4, 0x31); 550 vga_out8 (0x3d4, 0x31, par);
547 par->CR31 = vga_in8 (0x3d5); 551 par->CR31 = vga_in8 (0x3d5, par);
548 vga_out8 (0x3d4, 0x32); 552 vga_out8 (0x3d4, 0x32, par);
549 par->CR32 = vga_in8 (0x3d5); 553 par->CR32 = vga_in8 (0x3d5, par);
550 vga_out8 (0x3d4, 0x34); 554 vga_out8 (0x3d4, 0x34, par);
551 par->CR34 = vga_in8 (0x3d5); 555 par->CR34 = vga_in8 (0x3d5, par);
552 vga_out8 (0x3d4, 0x36); 556 vga_out8 (0x3d4, 0x36, par);
553 par->CR36 = vga_in8 (0x3d5); 557 par->CR36 = vga_in8 (0x3d5, par);
554 vga_out8 (0x3d4, 0x3a); 558 vga_out8 (0x3d4, 0x3a, par);
555 par->CR3A = vga_in8 (0x3d5); 559 par->CR3A = vga_in8 (0x3d5, par);
556 vga_out8 (0x3d4, 0x40); 560 vga_out8 (0x3d4, 0x40, par);
557 par->CR40 = vga_in8 (0x3d5); 561 par->CR40 = vga_in8 (0x3d5, par);
558 vga_out8 (0x3d4, 0x42); 562 vga_out8 (0x3d4, 0x42, par);
559 par->CR42 = vga_in8 (0x3d5); 563 par->CR42 = vga_in8 (0x3d5, par);
560 vga_out8 (0x3d4, 0x45); 564 vga_out8 (0x3d4, 0x45, par);
561 par->CR45 = vga_in8 (0x3d5); 565 par->CR45 = vga_in8 (0x3d5, par);
562 vga_out8 (0x3d4, 0x50); 566 vga_out8 (0x3d4, 0x50, par);
563 par->CR50 = vga_in8 (0x3d5); 567 par->CR50 = vga_in8 (0x3d5, par);
564 vga_out8 (0x3d4, 0x51); 568 vga_out8 (0x3d4, 0x51, par);
565 par->CR51 = vga_in8 (0x3d5); 569 par->CR51 = vga_in8 (0x3d5, par);
566 vga_out8 (0x3d4, 0x53); 570 vga_out8 (0x3d4, 0x53, par);
567 par->CR53 = vga_in8 (0x3d5); 571 par->CR53 = vga_in8 (0x3d5, par);
568 vga_out8 (0x3d4, 0x58); 572 vga_out8 (0x3d4, 0x58, par);
569 par->CR58 = vga_in8 (0x3d5); 573 par->CR58 = vga_in8 (0x3d5, par);
570 vga_out8 (0x3d4, 0x60); 574 vga_out8 (0x3d4, 0x60, par);
571 par->CR60 = vga_in8 (0x3d5); 575 par->CR60 = vga_in8 (0x3d5, par);
572 vga_out8 (0x3d4, 0x66); 576 vga_out8 (0x3d4, 0x66, par);
573 par->CR66 = vga_in8 (0x3d5); 577 par->CR66 = vga_in8 (0x3d5, par);
574 vga_out8 (0x3d4, 0x67); 578 vga_out8 (0x3d4, 0x67, par);
575 par->CR67 = vga_in8 (0x3d5); 579 par->CR67 = vga_in8 (0x3d5, par);
576 vga_out8 (0x3d4, 0x68); 580 vga_out8 (0x3d4, 0x68, par);
577 par->CR68 = vga_in8 (0x3d5); 581 par->CR68 = vga_in8 (0x3d5, par);
578 vga_out8 (0x3d4, 0x69); 582 vga_out8 (0x3d4, 0x69, par);
579 par->CR69 = vga_in8 (0x3d5); 583 par->CR69 = vga_in8 (0x3d5, par);
580 vga_out8 (0x3d4, 0x6f); 584 vga_out8 (0x3d4, 0x6f, par);
581 par->CR6F = vga_in8 (0x3d5); 585 par->CR6F = vga_in8 (0x3d5, par);
582 586
583 vga_out8 (0x3d4, 0x33); 587 vga_out8 (0x3d4, 0x33, par);
584 par->CR33 = vga_in8 (0x3d5); 588 par->CR33 = vga_in8 (0x3d5, par);
585 vga_out8 (0x3d4, 0x86); 589 vga_out8 (0x3d4, 0x86, par);
586 par->CR86 = vga_in8 (0x3d5); 590 par->CR86 = vga_in8 (0x3d5, par);
587 vga_out8 (0x3d4, 0x88); 591 vga_out8 (0x3d4, 0x88, par);
588 par->CR88 = vga_in8 (0x3d5); 592 par->CR88 = vga_in8 (0x3d5, par);
589 vga_out8 (0x3d4, 0x90); 593 vga_out8 (0x3d4, 0x90, par);
590 par->CR90 = vga_in8 (0x3d5); 594 par->CR90 = vga_in8 (0x3d5, par);
591 vga_out8 (0x3d4, 0x91); 595 vga_out8 (0x3d4, 0x91, par);
592 par->CR91 = vga_in8 (0x3d5); 596 par->CR91 = vga_in8 (0x3d5, par);
593 vga_out8 (0x3d4, 0xb0); 597 vga_out8 (0x3d4, 0xb0, par);
594 par->CRB0 = vga_in8 (0x3d5) | 0x80; 598 par->CRB0 = vga_in8 (0x3d5, par) | 0x80;
595 599
596 /* extended mode timing regs */ 600 /* extended mode timing regs */
597 vga_out8 (0x3d4, 0x3b); 601 vga_out8 (0x3d4, 0x3b, par);
598 par->CR3B = vga_in8 (0x3d5); 602 par->CR3B = vga_in8 (0x3d5, par);
599 vga_out8 (0x3d4, 0x3c); 603 vga_out8 (0x3d4, 0x3c, par);
600 par->CR3C = vga_in8 (0x3d5); 604 par->CR3C = vga_in8 (0x3d5, par);
601 vga_out8 (0x3d4, 0x43); 605 vga_out8 (0x3d4, 0x43, par);
602 par->CR43 = vga_in8 (0x3d5); 606 par->CR43 = vga_in8 (0x3d5, par);
603 vga_out8 (0x3d4, 0x5d); 607 vga_out8 (0x3d4, 0x5d, par);
604 par->CR5D = vga_in8 (0x3d5); 608 par->CR5D = vga_in8 (0x3d5, par);
605 vga_out8 (0x3d4, 0x5e); 609 vga_out8 (0x3d4, 0x5e, par);
606 par->CR5E = vga_in8 (0x3d5); 610 par->CR5E = vga_in8 (0x3d5, par);
607 vga_out8 (0x3d4, 0x65); 611 vga_out8 (0x3d4, 0x65, par);
608 par->CR65 = vga_in8 (0x3d5); 612 par->CR65 = vga_in8 (0x3d5, par);
609 613
610 /* save seq extended regs for DCLK PLL programming */ 614 /* save seq extended regs for DCLK PLL programming */
611 vga_out8 (0x3c4, 0x0e); 615 vga_out8 (0x3c4, 0x0e, par);
612 par->SR0E = vga_in8 (0x3c5); 616 par->SR0E = vga_in8 (0x3c5, par);
613 vga_out8 (0x3c4, 0x0f); 617 vga_out8 (0x3c4, 0x0f, par);
614 par->SR0F = vga_in8 (0x3c5); 618 par->SR0F = vga_in8 (0x3c5, par);
615 vga_out8 (0x3c4, 0x10); 619 vga_out8 (0x3c4, 0x10, par);
616 par->SR10 = vga_in8 (0x3c5); 620 par->SR10 = vga_in8 (0x3c5, par);
617 vga_out8 (0x3c4, 0x11); 621 vga_out8 (0x3c4, 0x11, par);
618 par->SR11 = vga_in8 (0x3c5); 622 par->SR11 = vga_in8 (0x3c5, par);
619 vga_out8 (0x3c4, 0x12); 623 vga_out8 (0x3c4, 0x12, par);
620 par->SR12 = vga_in8 (0x3c5); 624 par->SR12 = vga_in8 (0x3c5, par);
621 vga_out8 (0x3c4, 0x13); 625 vga_out8 (0x3c4, 0x13, par);
622 par->SR13 = vga_in8 (0x3c5); 626 par->SR13 = vga_in8 (0x3c5, par);
623 vga_out8 (0x3c4, 0x29); 627 vga_out8 (0x3c4, 0x29, par);
624 par->SR29 = vga_in8 (0x3c5); 628 par->SR29 = vga_in8 (0x3c5, par);
625 629
626 vga_out8 (0x3c4, 0x15); 630 vga_out8 (0x3c4, 0x15, par);
627 par->SR15 = vga_in8 (0x3c5); 631 par->SR15 = vga_in8 (0x3c5, par);
628 vga_out8 (0x3c4, 0x30); 632 vga_out8 (0x3c4, 0x30, par);
629 par->SR30 = vga_in8 (0x3c5); 633 par->SR30 = vga_in8 (0x3c5, par);
630 vga_out8 (0x3c4, 0x18); 634 vga_out8 (0x3c4, 0x18, par);
631 par->SR18 = vga_in8 (0x3c5); 635 par->SR18 = vga_in8 (0x3c5, par);
632 636
633 /* Save flat panel expansion regsters. */ 637 /* Save flat panel expansion regsters. */
634 if (par->chip == S3_SAVAGE_MX) { 638 if (par->chip == S3_SAVAGE_MX) {
635 int i; 639 int i;
636 640
637 for (i = 0; i < 8; i++) { 641 for (i = 0; i < 8; i++) {
638 vga_out8 (0x3c4, 0x54+i); 642 vga_out8 (0x3c4, 0x54+i, par);
639 par->SR54[i] = vga_in8 (0x3c5); 643 par->SR54[i] = vga_in8 (0x3c5, par);
640 } 644 }
641 } 645 }
642 646
643 vga_out8 (0x3d4, 0x66); 647 vga_out8 (0x3d4, 0x66, par);
644 cr66 = vga_in8 (0x3d5); 648 cr66 = vga_in8 (0x3d5, par);
645 vga_out8 (0x3d5, cr66 | 0x80); 649 vga_out8 (0x3d5, cr66 | 0x80, par);
646 vga_out8 (0x3d4, 0x3a); 650 vga_out8 (0x3d4, 0x3a, par);
647 cr3a = vga_in8 (0x3d5); 651 cr3a = vga_in8 (0x3d5, par);
648 vga_out8 (0x3d5, cr3a | 0x80); 652 vga_out8 (0x3d5, cr3a | 0x80, par);
649 653
650 /* now save MIU regs */ 654 /* now save MIU regs */
651 if (par->chip != S3_SAVAGE_MX) { 655 if (par->chip != S3_SAVAGE_MX) {
652 par->MMPR0 = savage_in32(FIFO_CONTROL_REG); 656 par->MMPR0 = savage_in32(FIFO_CONTROL_REG, par);
653 par->MMPR1 = savage_in32(MIU_CONTROL_REG); 657 par->MMPR1 = savage_in32(MIU_CONTROL_REG, par);
654 par->MMPR2 = savage_in32(STREAMS_TIMEOUT_REG); 658 par->MMPR2 = savage_in32(STREAMS_TIMEOUT_REG, par);
655 par->MMPR3 = savage_in32(MISC_TIMEOUT_REG); 659 par->MMPR3 = savage_in32(MISC_TIMEOUT_REG, par);
656 } 660 }
657 661
658 vga_out8 (0x3d4, 0x3a); 662 vga_out8 (0x3d4, 0x3a, par);
659 vga_out8 (0x3d5, cr3a); 663 vga_out8 (0x3d5, cr3a, par);
660 vga_out8 (0x3d4, 0x66); 664 vga_out8 (0x3d4, 0x66, par);
661 vga_out8 (0x3d5, cr66); 665 vga_out8 (0x3d5, cr66, par);
662} 666}
663 667
664static void savage_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb) 668static void savage_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb)
@@ -868,8 +872,8 @@ static int savagefb_decode_var (struct fb_var_screeninfo *var,
868 * match. Fall back to traditional register-crunching. 872 * match. Fall back to traditional register-crunching.
869 */ 873 */
870 874
871 vga_out8 (0x3d4, 0x3a); 875 vga_out8 (0x3d4, 0x3a, par);
872 tmp = vga_in8 (0x3d5); 876 tmp = vga_in8 (0x3d5, par);
873 if (1 /*FIXME:psav->pci_burst*/) 877 if (1 /*FIXME:psav->pci_burst*/)
874 par->CR3A = (tmp & 0x7f) | 0x15; 878 par->CR3A = (tmp & 0x7f) | 0x15;
875 else 879 else
@@ -879,16 +883,16 @@ static int savagefb_decode_var (struct fb_var_screeninfo *var,
879 par->CR31 = 0x8c; 883 par->CR31 = 0x8c;
880 par->CR66 = 0x89; 884 par->CR66 = 0x89;
881 885
882 vga_out8 (0x3d4, 0x58); 886 vga_out8 (0x3d4, 0x58, par);
883 par->CR58 = vga_in8 (0x3d5) & 0x80; 887 par->CR58 = vga_in8 (0x3d5, par) & 0x80;
884 par->CR58 |= 0x13; 888 par->CR58 |= 0x13;
885 889
886 par->SR15 = 0x03 | 0x80; 890 par->SR15 = 0x03 | 0x80;
887 par->SR18 = 0x00; 891 par->SR18 = 0x00;
888 par->CR43 = par->CR45 = par->CR65 = 0x00; 892 par->CR43 = par->CR45 = par->CR65 = 0x00;
889 893
890 vga_out8 (0x3d4, 0x40); 894 vga_out8 (0x3d4, 0x40, par);
891 par->CR40 = vga_in8 (0x3d5) & ~0x01; 895 par->CR40 = vga_in8 (0x3d5, par) & ~0x01;
892 896
893 par->MMPR0 = 0x010400; 897 par->MMPR0 = 0x010400;
894 par->MMPR1 = 0x00; 898 par->MMPR1 = 0x00;
@@ -992,19 +996,19 @@ static int savagefb_decode_var (struct fb_var_screeninfo *var,
992 996
993 par->CR67 |= 1; 997 par->CR67 |= 1;
994 998
995 vga_out8(0x3d4, 0x36); 999 vga_out8(0x3d4, 0x36, par);
996 par->CR36 = vga_in8 (0x3d5); 1000 par->CR36 = vga_in8 (0x3d5, par);
997 vga_out8 (0x3d4, 0x68); 1001 vga_out8 (0x3d4, 0x68, par);
998 par->CR68 = vga_in8 (0x3d5); 1002 par->CR68 = vga_in8 (0x3d5, par);
999 par->CR69 = 0; 1003 par->CR69 = 0;
1000 vga_out8 (0x3d4, 0x6f); 1004 vga_out8 (0x3d4, 0x6f, par);
1001 par->CR6F = vga_in8 (0x3d5); 1005 par->CR6F = vga_in8 (0x3d5, par);
1002 vga_out8 (0x3d4, 0x86); 1006 vga_out8 (0x3d4, 0x86, par);
1003 par->CR86 = vga_in8 (0x3d5); 1007 par->CR86 = vga_in8 (0x3d5, par);
1004 vga_out8 (0x3d4, 0x88); 1008 vga_out8 (0x3d4, 0x88, par);
1005 par->CR88 = vga_in8 (0x3d5) | 0x08; 1009 par->CR88 = vga_in8 (0x3d5, par) | 0x08;
1006 vga_out8 (0x3d4, 0xb0); 1010 vga_out8 (0x3d4, 0xb0, par);
1007 par->CRB0 = vga_in8 (0x3d5) | 0x80; 1011 par->CRB0 = vga_in8 (0x3d5, par) | 0x80;
1008 1012
1009 return 0; 1013 return 0;
1010} 1014}
@@ -1033,11 +1037,11 @@ static int savagefb_setcolreg(unsigned regno,
1033 1037
1034 switch (info->var.bits_per_pixel) { 1038 switch (info->var.bits_per_pixel) {
1035 case 8: 1039 case 8:
1036 vga_out8 (0x3c8, regno); 1040 vga_out8 (0x3c8, regno, par);
1037 1041
1038 vga_out8 (0x3c9, red >> 10); 1042 vga_out8 (0x3c9, red >> 10, par);
1039 vga_out8 (0x3c9, green >> 10); 1043 vga_out8 (0x3c9, green >> 10, par);
1040 vga_out8 (0x3c9, blue >> 10); 1044 vga_out8 (0x3c9, blue >> 10, par);
1041 break; 1045 break;
1042 1046
1043 case 16: 1047 case 16:
@@ -1079,11 +1083,11 @@ static void savagefb_set_par_int (struct savagefb_par *par)
1079 1083
1080 par->SavageWaitIdle (par); 1084 par->SavageWaitIdle (par);
1081 1085
1082 vga_out8 (0x3c2, 0x23); 1086 vga_out8 (0x3c2, 0x23, par);
1083 1087
1084 vga_out16 (0x3d4, 0x4838); 1088 vga_out16 (0x3d4, 0x4838, par);
1085 vga_out16 (0x3d4, 0xa539); 1089 vga_out16 (0x3d4, 0xa539, par);
1086 vga_out16 (0x3c4, 0x0608); 1090 vga_out16 (0x3c4, 0x0608, par);
1087 1091
1088 vgaHWProtect (par, 1); 1092 vgaHWProtect (par, 1);
1089 1093
@@ -1094,197 +1098,197 @@ static void savagefb_set_par_int (struct savagefb_par *par)
1094 * switch to mode 3 here seems to eliminate the issue. 1098 * switch to mode 3 here seems to eliminate the issue.
1095 */ 1099 */
1096 1100
1097 VerticalRetraceWait(); 1101 VerticalRetraceWait(par);
1098 vga_out8 (0x3d4, 0x67); 1102 vga_out8 (0x3d4, 0x67, par);
1099 cr67 = vga_in8 (0x3d5); 1103 cr67 = vga_in8 (0x3d5, par);
1100 vga_out8 (0x3d5, cr67/*par->CR67*/ & ~0x0c); /* no STREAMS yet */ 1104 vga_out8 (0x3d5, cr67/*par->CR67*/ & ~0x0c, par); /* no STREAMS yet */
1101 1105
1102 vga_out8 (0x3d4, 0x23); 1106 vga_out8 (0x3d4, 0x23, par);
1103 vga_out8 (0x3d5, 0x00); 1107 vga_out8 (0x3d5, 0x00, par);
1104 vga_out8 (0x3d4, 0x26); 1108 vga_out8 (0x3d4, 0x26, par);
1105 vga_out8 (0x3d5, 0x00); 1109 vga_out8 (0x3d5, 0x00, par);
1106 1110
1107 /* restore extended regs */ 1111 /* restore extended regs */
1108 vga_out8 (0x3d4, 0x66); 1112 vga_out8 (0x3d4, 0x66, par);
1109 vga_out8 (0x3d5, par->CR66); 1113 vga_out8 (0x3d5, par->CR66, par);
1110 vga_out8 (0x3d4, 0x3a); 1114 vga_out8 (0x3d4, 0x3a, par);
1111 vga_out8 (0x3d5, par->CR3A); 1115 vga_out8 (0x3d5, par->CR3A, par);
1112 vga_out8 (0x3d4, 0x31); 1116 vga_out8 (0x3d4, 0x31, par);
1113 vga_out8 (0x3d5, par->CR31); 1117 vga_out8 (0x3d5, par->CR31, par);
1114 vga_out8 (0x3d4, 0x32); 1118 vga_out8 (0x3d4, 0x32, par);
1115 vga_out8 (0x3d5, par->CR32); 1119 vga_out8 (0x3d5, par->CR32, par);
1116 vga_out8 (0x3d4, 0x58); 1120 vga_out8 (0x3d4, 0x58, par);
1117 vga_out8 (0x3d5, par->CR58); 1121 vga_out8 (0x3d5, par->CR58, par);
1118 vga_out8 (0x3d4, 0x53); 1122 vga_out8 (0x3d4, 0x53, par);
1119 vga_out8 (0x3d5, par->CR53 & 0x7f); 1123 vga_out8 (0x3d5, par->CR53 & 0x7f, par);
1120 1124
1121 vga_out16 (0x3c4, 0x0608); 1125 vga_out16 (0x3c4, 0x0608, par);
1122 1126
1123 /* Restore DCLK registers. */ 1127 /* Restore DCLK registers. */
1124 1128
1125 vga_out8 (0x3c4, 0x0e); 1129 vga_out8 (0x3c4, 0x0e, par);
1126 vga_out8 (0x3c5, par->SR0E); 1130 vga_out8 (0x3c5, par->SR0E, par);
1127 vga_out8 (0x3c4, 0x0f); 1131 vga_out8 (0x3c4, 0x0f, par);
1128 vga_out8 (0x3c5, par->SR0F); 1132 vga_out8 (0x3c5, par->SR0F, par);
1129 vga_out8 (0x3c4, 0x29); 1133 vga_out8 (0x3c4, 0x29, par);
1130 vga_out8 (0x3c5, par->SR29); 1134 vga_out8 (0x3c5, par->SR29, par);
1131 vga_out8 (0x3c4, 0x15); 1135 vga_out8 (0x3c4, 0x15, par);
1132 vga_out8 (0x3c5, par->SR15); 1136 vga_out8 (0x3c5, par->SR15, par);
1133 1137
1134 /* Restore flat panel expansion regsters. */ 1138 /* Restore flat panel expansion regsters. */
1135 if( par->chip == S3_SAVAGE_MX ) { 1139 if( par->chip == S3_SAVAGE_MX ) {
1136 int i; 1140 int i;
1137 1141
1138 for( i = 0; i < 8; i++ ) { 1142 for( i = 0; i < 8; i++ ) {
1139 vga_out8 (0x3c4, 0x54+i); 1143 vga_out8 (0x3c4, 0x54+i, par);
1140 vga_out8 (0x3c5, par->SR54[i]); 1144 vga_out8 (0x3c5, par->SR54[i], par);
1141 } 1145 }
1142 } 1146 }
1143 1147
1144 vgaHWRestore (par); 1148 vgaHWRestore (par);
1145 1149
1146 /* extended mode timing registers */ 1150 /* extended mode timing registers */
1147 vga_out8 (0x3d4, 0x53); 1151 vga_out8 (0x3d4, 0x53, par);
1148 vga_out8 (0x3d5, par->CR53); 1152 vga_out8 (0x3d5, par->CR53, par);
1149 vga_out8 (0x3d4, 0x5d); 1153 vga_out8 (0x3d4, 0x5d, par);
1150 vga_out8 (0x3d5, par->CR5D); 1154 vga_out8 (0x3d5, par->CR5D, par);
1151 vga_out8 (0x3d4, 0x5e); 1155 vga_out8 (0x3d4, 0x5e, par);
1152 vga_out8 (0x3d5, par->CR5E); 1156 vga_out8 (0x3d5, par->CR5E, par);
1153 vga_out8 (0x3d4, 0x3b); 1157 vga_out8 (0x3d4, 0x3b, par);
1154 vga_out8 (0x3d5, par->CR3B); 1158 vga_out8 (0x3d5, par->CR3B, par);
1155 vga_out8 (0x3d4, 0x3c); 1159 vga_out8 (0x3d4, 0x3c, par);
1156 vga_out8 (0x3d5, par->CR3C); 1160 vga_out8 (0x3d5, par->CR3C, par);
1157 vga_out8 (0x3d4, 0x43); 1161 vga_out8 (0x3d4, 0x43, par);
1158 vga_out8 (0x3d5, par->CR43); 1162 vga_out8 (0x3d5, par->CR43, par);
1159 vga_out8 (0x3d4, 0x65); 1163 vga_out8 (0x3d4, 0x65, par);
1160 vga_out8 (0x3d5, par->CR65); 1164 vga_out8 (0x3d5, par->CR65, par);
1161 1165
1162 /* restore the desired video mode with cr67 */ 1166 /* restore the desired video mode with cr67 */
1163 vga_out8 (0x3d4, 0x67); 1167 vga_out8 (0x3d4, 0x67, par);
1164 /* following part not present in X11 driver */ 1168 /* following part not present in X11 driver */
1165 cr67 = vga_in8 (0x3d5) & 0xf; 1169 cr67 = vga_in8 (0x3d5, par) & 0xf;
1166 vga_out8 (0x3d5, 0x50 | cr67); 1170 vga_out8 (0x3d5, 0x50 | cr67, par);
1167 udelay (10000); 1171 udelay (10000);
1168 vga_out8 (0x3d4, 0x67); 1172 vga_out8 (0x3d4, 0x67, par);
1169 /* end of part */ 1173 /* end of part */
1170 vga_out8 (0x3d5, par->CR67 & ~0x0c); 1174 vga_out8 (0x3d5, par->CR67 & ~0x0c, par);
1171 1175
1172 /* other mode timing and extended regs */ 1176 /* other mode timing and extended regs */
1173 vga_out8 (0x3d4, 0x34); 1177 vga_out8 (0x3d4, 0x34, par);
1174 vga_out8 (0x3d5, par->CR34); 1178 vga_out8 (0x3d5, par->CR34, par);
1175 vga_out8 (0x3d4, 0x40); 1179 vga_out8 (0x3d4, 0x40, par);
1176 vga_out8 (0x3d5, par->CR40); 1180 vga_out8 (0x3d5, par->CR40, par);
1177 vga_out8 (0x3d4, 0x42); 1181 vga_out8 (0x3d4, 0x42, par);
1178 vga_out8 (0x3d5, par->CR42); 1182 vga_out8 (0x3d5, par->CR42, par);
1179 vga_out8 (0x3d4, 0x45); 1183 vga_out8 (0x3d4, 0x45, par);
1180 vga_out8 (0x3d5, par->CR45); 1184 vga_out8 (0x3d5, par->CR45, par);
1181 vga_out8 (0x3d4, 0x50); 1185 vga_out8 (0x3d4, 0x50, par);
1182 vga_out8 (0x3d5, par->CR50); 1186 vga_out8 (0x3d5, par->CR50, par);
1183 vga_out8 (0x3d4, 0x51); 1187 vga_out8 (0x3d4, 0x51, par);
1184 vga_out8 (0x3d5, par->CR51); 1188 vga_out8 (0x3d5, par->CR51, par);
1185 1189
1186 /* memory timings */ 1190 /* memory timings */
1187 vga_out8 (0x3d4, 0x36); 1191 vga_out8 (0x3d4, 0x36, par);
1188 vga_out8 (0x3d5, par->CR36); 1192 vga_out8 (0x3d5, par->CR36, par);
1189 vga_out8 (0x3d4, 0x60); 1193 vga_out8 (0x3d4, 0x60, par);
1190 vga_out8 (0x3d5, par->CR60); 1194 vga_out8 (0x3d5, par->CR60, par);
1191 vga_out8 (0x3d4, 0x68); 1195 vga_out8 (0x3d4, 0x68, par);
1192 vga_out8 (0x3d5, par->CR68); 1196 vga_out8 (0x3d5, par->CR68, par);
1193 vga_out8 (0x3d4, 0x69); 1197 vga_out8 (0x3d4, 0x69, par);
1194 vga_out8 (0x3d5, par->CR69); 1198 vga_out8 (0x3d5, par->CR69, par);
1195 vga_out8 (0x3d4, 0x6f); 1199 vga_out8 (0x3d4, 0x6f, par);
1196 vga_out8 (0x3d5, par->CR6F); 1200 vga_out8 (0x3d5, par->CR6F, par);
1197 1201
1198 vga_out8 (0x3d4, 0x33); 1202 vga_out8 (0x3d4, 0x33, par);
1199 vga_out8 (0x3d5, par->CR33); 1203 vga_out8 (0x3d5, par->CR33, par);
1200 vga_out8 (0x3d4, 0x86); 1204 vga_out8 (0x3d4, 0x86, par);
1201 vga_out8 (0x3d5, par->CR86); 1205 vga_out8 (0x3d5, par->CR86, par);
1202 vga_out8 (0x3d4, 0x88); 1206 vga_out8 (0x3d4, 0x88, par);
1203 vga_out8 (0x3d5, par->CR88); 1207 vga_out8 (0x3d5, par->CR88, par);
1204 vga_out8 (0x3d4, 0x90); 1208 vga_out8 (0x3d4, 0x90, par);
1205 vga_out8 (0x3d5, par->CR90); 1209 vga_out8 (0x3d5, par->CR90, par);
1206 vga_out8 (0x3d4, 0x91); 1210 vga_out8 (0x3d4, 0x91, par);
1207 vga_out8 (0x3d5, par->CR91); 1211 vga_out8 (0x3d5, par->CR91, par);
1208 1212
1209 if (par->chip == S3_SAVAGE4) { 1213 if (par->chip == S3_SAVAGE4) {
1210 vga_out8 (0x3d4, 0xb0); 1214 vga_out8 (0x3d4, 0xb0, par);
1211 vga_out8 (0x3d5, par->CRB0); 1215 vga_out8 (0x3d5, par->CRB0, par);
1212 } 1216 }
1213 1217
1214 vga_out8 (0x3d4, 0x32); 1218 vga_out8 (0x3d4, 0x32, par);
1215 vga_out8 (0x3d5, par->CR32); 1219 vga_out8 (0x3d5, par->CR32, par);
1216 1220
1217 /* unlock extended seq regs */ 1221 /* unlock extended seq regs */
1218 vga_out8 (0x3c4, 0x08); 1222 vga_out8 (0x3c4, 0x08, par);
1219 vga_out8 (0x3c5, 0x06); 1223 vga_out8 (0x3c5, 0x06, par);
1220 1224
1221 /* Restore extended sequencer regs for MCLK. SR10 == 255 indicates 1225 /* Restore extended sequencer regs for MCLK. SR10 == 255 indicates
1222 * that we should leave the default SR10 and SR11 values there. 1226 * that we should leave the default SR10 and SR11 values there.
1223 */ 1227 */
1224 if (par->SR10 != 255) { 1228 if (par->SR10 != 255) {
1225 vga_out8 (0x3c4, 0x10); 1229 vga_out8 (0x3c4, 0x10, par);
1226 vga_out8 (0x3c5, par->SR10); 1230 vga_out8 (0x3c5, par->SR10, par);
1227 vga_out8 (0x3c4, 0x11); 1231 vga_out8 (0x3c4, 0x11, par);
1228 vga_out8 (0x3c5, par->SR11); 1232 vga_out8 (0x3c5, par->SR11, par);
1229 } 1233 }
1230 1234
1231 /* restore extended seq regs for dclk */ 1235 /* restore extended seq regs for dclk */
1232 vga_out8 (0x3c4, 0x0e); 1236 vga_out8 (0x3c4, 0x0e, par);
1233 vga_out8 (0x3c5, par->SR0E); 1237 vga_out8 (0x3c5, par->SR0E, par);
1234 vga_out8 (0x3c4, 0x0f); 1238 vga_out8 (0x3c4, 0x0f, par);
1235 vga_out8 (0x3c5, par->SR0F); 1239 vga_out8 (0x3c5, par->SR0F, par);
1236 vga_out8 (0x3c4, 0x12); 1240 vga_out8 (0x3c4, 0x12, par);
1237 vga_out8 (0x3c5, par->SR12); 1241 vga_out8 (0x3c5, par->SR12, par);
1238 vga_out8 (0x3c4, 0x13); 1242 vga_out8 (0x3c4, 0x13, par);
1239 vga_out8 (0x3c5, par->SR13); 1243 vga_out8 (0x3c5, par->SR13, par);
1240 vga_out8 (0x3c4, 0x29); 1244 vga_out8 (0x3c4, 0x29, par);
1241 vga_out8 (0x3c5, par->SR29); 1245 vga_out8 (0x3c5, par->SR29, par);
1242 1246
1243 vga_out8 (0x3c4, 0x18); 1247 vga_out8 (0x3c4, 0x18, par);
1244 vga_out8 (0x3c5, par->SR18); 1248 vga_out8 (0x3c5, par->SR18, par);
1245 1249
1246 /* load new m, n pll values for dclk & mclk */ 1250 /* load new m, n pll values for dclk & mclk */
1247 vga_out8 (0x3c4, 0x15); 1251 vga_out8 (0x3c4, 0x15, par);
1248 tmp = vga_in8 (0x3c5) & ~0x21; 1252 tmp = vga_in8 (0x3c5, par) & ~0x21;
1249 1253
1250 vga_out8 (0x3c5, tmp | 0x03); 1254 vga_out8 (0x3c5, tmp | 0x03, par);
1251 vga_out8 (0x3c5, tmp | 0x23); 1255 vga_out8 (0x3c5, tmp | 0x23, par);
1252 vga_out8 (0x3c5, tmp | 0x03); 1256 vga_out8 (0x3c5, tmp | 0x03, par);
1253 vga_out8 (0x3c5, par->SR15); 1257 vga_out8 (0x3c5, par->SR15, par);
1254 udelay (100); 1258 udelay (100);
1255 1259
1256 vga_out8 (0x3c4, 0x30); 1260 vga_out8 (0x3c4, 0x30, par);
1257 vga_out8 (0x3c5, par->SR30); 1261 vga_out8 (0x3c5, par->SR30, par);
1258 vga_out8 (0x3c4, 0x08); 1262 vga_out8 (0x3c4, 0x08, par);
1259 vga_out8 (0x3c5, par->SR08); 1263 vga_out8 (0x3c5, par->SR08, par);
1260 1264
1261 /* now write out cr67 in full, possibly starting STREAMS */ 1265 /* now write out cr67 in full, possibly starting STREAMS */
1262 VerticalRetraceWait(); 1266 VerticalRetraceWait(par);
1263 vga_out8 (0x3d4, 0x67); 1267 vga_out8 (0x3d4, 0x67, par);
1264 vga_out8 (0x3d5, par->CR67); 1268 vga_out8 (0x3d5, par->CR67, par);
1265 1269
1266 vga_out8 (0x3d4, 0x66); 1270 vga_out8 (0x3d4, 0x66, par);
1267 cr66 = vga_in8 (0x3d5); 1271 cr66 = vga_in8 (0x3d5, par);
1268 vga_out8 (0x3d5, cr66 | 0x80); 1272 vga_out8 (0x3d5, cr66 | 0x80, par);
1269 vga_out8 (0x3d4, 0x3a); 1273 vga_out8 (0x3d4, 0x3a, par);
1270 cr3a = vga_in8 (0x3d5); 1274 cr3a = vga_in8 (0x3d5, par);
1271 vga_out8 (0x3d5, cr3a | 0x80); 1275 vga_out8 (0x3d5, cr3a | 0x80, par);
1272 1276
1273 if (par->chip != S3_SAVAGE_MX) { 1277 if (par->chip != S3_SAVAGE_MX) {
1274 VerticalRetraceWait(); 1278 VerticalRetraceWait(par);
1275 savage_out32 (FIFO_CONTROL_REG, par->MMPR0); 1279 savage_out32 (FIFO_CONTROL_REG, par->MMPR0, par);
1276 par->SavageWaitIdle (par); 1280 par->SavageWaitIdle (par);
1277 savage_out32 (MIU_CONTROL_REG, par->MMPR1); 1281 savage_out32 (MIU_CONTROL_REG, par->MMPR1, par);
1278 par->SavageWaitIdle (par); 1282 par->SavageWaitIdle (par);
1279 savage_out32 (STREAMS_TIMEOUT_REG, par->MMPR2); 1283 savage_out32 (STREAMS_TIMEOUT_REG, par->MMPR2, par);
1280 par->SavageWaitIdle (par); 1284 par->SavageWaitIdle (par);
1281 savage_out32 (MISC_TIMEOUT_REG, par->MMPR3); 1285 savage_out32 (MISC_TIMEOUT_REG, par->MMPR3, par);
1282 } 1286 }
1283 1287
1284 vga_out8 (0x3d4, 0x66); 1288 vga_out8 (0x3d4, 0x66, par);
1285 vga_out8 (0x3d5, cr66); 1289 vga_out8 (0x3d5, cr66, par);
1286 vga_out8 (0x3d4, 0x3a); 1290 vga_out8 (0x3d4, 0x3a, par);
1287 vga_out8 (0x3d5, cr3a); 1291 vga_out8 (0x3d5, cr3a, par);
1288 1292
1289 SavageSetup2DEngine (par); 1293 SavageSetup2DEngine (par);
1290 vgaHWProtect (par, 0); 1294 vgaHWProtect (par, 0);
@@ -1299,10 +1303,10 @@ static void savagefb_update_start (struct savagefb_par *par,
1299 * ((var->bits_per_pixel+7) / 8)) >> 2; 1303 * ((var->bits_per_pixel+7) / 8)) >> 2;
1300 1304
1301 /* now program the start address registers */ 1305 /* now program the start address registers */
1302 vga_out16(0x3d4, (base & 0x00ff00) | 0x0c); 1306 vga_out16(0x3d4, (base & 0x00ff00) | 0x0c, par);
1303 vga_out16(0x3d4, ((base & 0x00ff) << 8) | 0x0d); 1307 vga_out16(0x3d4, ((base & 0x00ff) << 8) | 0x0d, par);
1304 vga_out8 (0x3d4, 0x69); 1308 vga_out8 (0x3d4, 0x69, par);
1305 vga_out8 (0x3d5, (base & 0x7f0000) >> 16); 1309 vga_out8 (0x3d5, (base & 0x7f0000) >> 16, par);
1306} 1310}
1307 1311
1308 1312
@@ -1406,12 +1410,12 @@ static int savagefb_blank(int blank, struct fb_info *info)
1406 u8 sr8 = 0, srd = 0; 1410 u8 sr8 = 0, srd = 0;
1407 1411
1408 if (par->display_type == DISP_CRT) { 1412 if (par->display_type == DISP_CRT) {
1409 vga_out8(0x3c4, 0x08); 1413 vga_out8(0x3c4, 0x08, par);
1410 sr8 = vga_in8(0x3c5); 1414 sr8 = vga_in8(0x3c5, par);
1411 sr8 |= 0x06; 1415 sr8 |= 0x06;
1412 vga_out8(0x3c5, sr8); 1416 vga_out8(0x3c5, sr8, par);
1413 vga_out8(0x3c4, 0x0d); 1417 vga_out8(0x3c4, 0x0d, par);
1414 srd = vga_in8(0x3c5); 1418 srd = vga_in8(0x3c5, par);
1415 srd &= 0x03; 1419 srd &= 0x03;
1416 1420
1417 switch (blank) { 1421 switch (blank) {
@@ -1429,8 +1433,8 @@ static int savagefb_blank(int blank, struct fb_info *info)
1429 break; 1433 break;
1430 } 1434 }
1431 1435
1432 vga_out8(0x3c4, 0x0d); 1436 vga_out8(0x3c4, 0x0d, par);
1433 vga_out8(0x3c5, srd); 1437 vga_out8(0x3c5, srd, par);
1434 } 1438 }
1435 1439
1436 if (par->display_type == DISP_LCD || 1440 if (par->display_type == DISP_LCD ||
@@ -1438,14 +1442,14 @@ static int savagefb_blank(int blank, struct fb_info *info)
1438 switch(blank) { 1442 switch(blank) {
1439 case FB_BLANK_UNBLANK: 1443 case FB_BLANK_UNBLANK:
1440 case FB_BLANK_NORMAL: 1444 case FB_BLANK_NORMAL:
1441 vga_out8(0x3c4, 0x31); /* SR31 bit 4 - FP enable */ 1445 vga_out8(0x3c4, 0x31, par); /* SR31 bit 4 - FP enable */
1442 vga_out8(0x3c5, vga_in8(0x3c5) | 0x10); 1446 vga_out8(0x3c5, vga_in8(0x3c5, par) | 0x10, par);
1443 break; 1447 break;
1444 case FB_BLANK_VSYNC_SUSPEND: 1448 case FB_BLANK_VSYNC_SUSPEND:
1445 case FB_BLANK_HSYNC_SUSPEND: 1449 case FB_BLANK_HSYNC_SUSPEND:
1446 case FB_BLANK_POWERDOWN: 1450 case FB_BLANK_POWERDOWN:
1447 vga_out8(0x3c4, 0x31); /* SR31 bit 4 - FP enable */ 1451 vga_out8(0x3c4, 0x31, par); /* SR31 bit 4 - FP enable */
1448 vga_out8(0x3c5, vga_in8(0x3c5) & ~0x10); 1452 vga_out8(0x3c5, vga_in8(0x3c5, par) & ~0x10, par);
1449 break; 1453 break;
1450 } 1454 }
1451 } 1455 }
@@ -1470,7 +1474,6 @@ static struct fb_ops savagefb_ops = {
1470 .fb_copyarea = cfb_copyarea, 1474 .fb_copyarea = cfb_copyarea,
1471 .fb_imageblit = cfb_imageblit, 1475 .fb_imageblit = cfb_imageblit,
1472#endif 1476#endif
1473 .fb_cursor = soft_cursor,
1474}; 1477};
1475 1478
1476/* --------------------------------------------------------------------- */ 1479/* --------------------------------------------------------------------- */
@@ -1499,15 +1502,15 @@ static void savage_enable_mmio (struct savagefb_par *par)
1499 1502
1500 DBG ("savage_enable_mmio\n"); 1503 DBG ("savage_enable_mmio\n");
1501 1504
1502 val = vga_in8 (0x3c3); 1505 val = vga_in8 (0x3c3, par);
1503 vga_out8 (0x3c3, val | 0x01); 1506 vga_out8 (0x3c3, val | 0x01, par);
1504 val = vga_in8 (0x3cc); 1507 val = vga_in8 (0x3cc, par);
1505 vga_out8 (0x3c2, val | 0x01); 1508 vga_out8 (0x3c2, val | 0x01, par);
1506 1509
1507 if (par->chip >= S3_SAVAGE4) { 1510 if (par->chip >= S3_SAVAGE4) {
1508 vga_out8 (0x3d4, 0x40); 1511 vga_out8 (0x3d4, 0x40, par);
1509 val = vga_in8 (0x3d5); 1512 val = vga_in8 (0x3d5, par);
1510 vga_out8 (0x3d5, val | 1); 1513 vga_out8 (0x3d5, val | 1, par);
1511 } 1514 }
1512} 1515}
1513 1516
@@ -1519,9 +1522,9 @@ static void savage_disable_mmio (struct savagefb_par *par)
1519 DBG ("savage_disable_mmio\n"); 1522 DBG ("savage_disable_mmio\n");
1520 1523
1521 if(par->chip >= S3_SAVAGE4 ) { 1524 if(par->chip >= S3_SAVAGE4 ) {
1522 vga_out8 (0x3d4, 0x40); 1525 vga_out8 (0x3d4, 0x40, par);
1523 val = vga_in8 (0x3d5); 1526 val = vga_in8 (0x3d5, par);
1524 vga_out8 (0x3d5, val | 1); 1527 vga_out8 (0x3d5, val | 1, par);
1525 } 1528 }
1526} 1529}
1527 1530
@@ -1641,30 +1644,30 @@ static int __devinit savage_init_hw (struct savagefb_par *par)
1641 DBG("savage_init_hw"); 1644 DBG("savage_init_hw");
1642 1645
1643 /* unprotect CRTC[0-7] */ 1646 /* unprotect CRTC[0-7] */
1644 vga_out8(0x3d4, 0x11); 1647 vga_out8(0x3d4, 0x11, par);
1645 tmp = vga_in8(0x3d5); 1648 tmp = vga_in8(0x3d5, par);
1646 vga_out8(0x3d5, tmp & 0x7f); 1649 vga_out8(0x3d5, tmp & 0x7f, par);
1647 1650
1648 /* unlock extended regs */ 1651 /* unlock extended regs */
1649 vga_out16(0x3d4, 0x4838); 1652 vga_out16(0x3d4, 0x4838, par);
1650 vga_out16(0x3d4, 0xa039); 1653 vga_out16(0x3d4, 0xa039, par);
1651 vga_out16(0x3c4, 0x0608); 1654 vga_out16(0x3c4, 0x0608, par);
1652 1655
1653 vga_out8(0x3d4, 0x40); 1656 vga_out8(0x3d4, 0x40, par);
1654 tmp = vga_in8(0x3d5); 1657 tmp = vga_in8(0x3d5, par);
1655 vga_out8(0x3d5, tmp & ~0x01); 1658 vga_out8(0x3d5, tmp & ~0x01, par);
1656 1659
1657 /* unlock sys regs */ 1660 /* unlock sys regs */
1658 vga_out8(0x3d4, 0x38); 1661 vga_out8(0x3d4, 0x38, par);
1659 vga_out8(0x3d5, 0x48); 1662 vga_out8(0x3d5, 0x48, par);
1660 1663
1661 /* Unlock system registers. */ 1664 /* Unlock system registers. */
1662 vga_out16(0x3d4, 0x4838); 1665 vga_out16(0x3d4, 0x4838, par);
1663 1666
1664 /* Next go on to detect amount of installed ram */ 1667 /* Next go on to detect amount of installed ram */
1665 1668
1666 vga_out8(0x3d4, 0x36); /* for register CR36 (CONFG_REG1), */ 1669 vga_out8(0x3d4, 0x36, par); /* for register CR36 (CONFG_REG1), */
1667 config1 = vga_in8(0x3d5); /* get amount of vram installed */ 1670 config1 = vga_in8(0x3d5, par); /* get amount of vram installed */
1668 1671
1669 /* Compute the amount of video memory and offscreen memory. */ 1672 /* Compute the amount of video memory and offscreen memory. */
1670 1673
@@ -1680,8 +1683,8 @@ static int __devinit savage_init_hw (struct savagefb_par *par)
1680 * when it really means 8MB. Why do it the same when you 1683 * when it really means 8MB. Why do it the same when you
1681 * can do it different... 1684 * can do it different...
1682 */ 1685 */
1683 vga_out8(0x3d4, 0x68); /* memory control 1 */ 1686 vga_out8(0x3d4, 0x68, par); /* memory control 1 */
1684 if( (vga_in8(0x3d5) & 0xC0) == (0x01 << 6) ) 1687 if( (vga_in8(0x3d5, par) & 0xC0) == (0x01 << 6) )
1685 RamSavage4[1] = 8; 1688 RamSavage4[1] = 8;
1686 1689
1687 /*FALLTHROUGH*/ 1690 /*FALLTHROUGH*/
@@ -1710,13 +1713,13 @@ static int __devinit savage_init_hw (struct savagefb_par *par)
1710 printk (KERN_INFO "savagefb: probed videoram: %dk\n", videoRam); 1713 printk (KERN_INFO "savagefb: probed videoram: %dk\n", videoRam);
1711 1714
1712 /* reset graphics engine to avoid memory corruption */ 1715 /* reset graphics engine to avoid memory corruption */
1713 vga_out8 (0x3d4, 0x66); 1716 vga_out8 (0x3d4, 0x66, par);
1714 cr66 = vga_in8 (0x3d5); 1717 cr66 = vga_in8 (0x3d5, par);
1715 vga_out8 (0x3d5, cr66 | 0x02); 1718 vga_out8 (0x3d5, cr66 | 0x02, par);
1716 udelay (10000); 1719 udelay (10000);
1717 1720
1718 vga_out8 (0x3d4, 0x66); 1721 vga_out8 (0x3d4, 0x66, par);
1719 vga_out8 (0x3d5, cr66 & ~0x02); /* clear reset flag */ 1722 vga_out8 (0x3d5, cr66 & ~0x02, par); /* clear reset flag */
1720 udelay (10000); 1723 udelay (10000);
1721 1724
1722 1725
@@ -1724,13 +1727,13 @@ static int __devinit savage_init_hw (struct savagefb_par *par)
1724 * reset memory interface, 3D engine, AGP master, PCI master, 1727 * reset memory interface, 3D engine, AGP master, PCI master,
1725 * master engine unit, motion compensation/LPB 1728 * master engine unit, motion compensation/LPB
1726 */ 1729 */
1727 vga_out8 (0x3d4, 0x3f); 1730 vga_out8 (0x3d4, 0x3f, par);
1728 cr3f = vga_in8 (0x3d5); 1731 cr3f = vga_in8 (0x3d5, par);
1729 vga_out8 (0x3d5, cr3f | 0x08); 1732 vga_out8 (0x3d5, cr3f | 0x08, par);
1730 udelay (10000); 1733 udelay (10000);
1731 1734
1732 vga_out8 (0x3d4, 0x3f); 1735 vga_out8 (0x3d4, 0x3f, par);
1733 vga_out8 (0x3d5, cr3f & ~0x08); /* clear reset flags */ 1736 vga_out8 (0x3d5, cr3f & ~0x08, par); /* clear reset flags */
1734 udelay (10000); 1737 udelay (10000);
1735 1738
1736 /* Savage ramdac speeds */ 1739 /* Savage ramdac speeds */
@@ -1741,15 +1744,15 @@ static int __devinit savage_init_hw (struct savagefb_par *par)
1741 par->clock[3] = 220000; 1744 par->clock[3] = 220000;
1742 1745
1743 /* detect current mclk */ 1746 /* detect current mclk */
1744 vga_out8(0x3c4, 0x08); 1747 vga_out8(0x3c4, 0x08, par);
1745 sr8 = vga_in8(0x3c5); 1748 sr8 = vga_in8(0x3c5, par);
1746 vga_out8(0x3c5, 0x06); 1749 vga_out8(0x3c5, 0x06, par);
1747 vga_out8(0x3c4, 0x10); 1750 vga_out8(0x3c4, 0x10, par);
1748 n = vga_in8(0x3c5); 1751 n = vga_in8(0x3c5, par);
1749 vga_out8(0x3c4, 0x11); 1752 vga_out8(0x3c4, 0x11, par);
1750 m = vga_in8(0x3c5); 1753 m = vga_in8(0x3c5, par);
1751 vga_out8(0x3c4, 0x08); 1754 vga_out8(0x3c4, 0x08, par);
1752 vga_out8(0x3c5, sr8); 1755 vga_out8(0x3c5, sr8, par);
1753 m &= 0x7f; 1756 m &= 0x7f;
1754 n1 = n & 0x1f; 1757 n1 = n & 0x1f;
1755 n2 = (n >> 5) & 0x03; 1758 n2 = (n >> 5) & 0x03;
@@ -1763,10 +1766,10 @@ static int __devinit savage_init_hw (struct savagefb_par *par)
1763 if (par->chip == S3_SAVAGE4) { 1766 if (par->chip == S3_SAVAGE4) {
1764 unsigned char sr30 = 0x00; 1767 unsigned char sr30 = 0x00;
1765 1768
1766 vga_out8(0x3c4, 0x30); 1769 vga_out8(0x3c4, 0x30, par);
1767 /* clear bit 1 */ 1770 /* clear bit 1 */
1768 vga_out8(0x3c5, vga_in8(0x3c5) & ~0x02); 1771 vga_out8(0x3c5, vga_in8(0x3c5, par) & ~0x02, par);
1769 sr30 = vga_in8(0x3c5); 1772 sr30 = vga_in8(0x3c5, par);
1770 if (sr30 & 0x02 /*0x04 */) { 1773 if (sr30 & 0x02 /*0x04 */) {
1771 dvi = 1; 1774 dvi = 1;
1772 printk("savagefb: Digital Flat Panel Detected\n"); 1775 printk("savagefb: Digital Flat Panel Detected\n");
@@ -1783,12 +1786,12 @@ static int __devinit savage_init_hw (struct savagefb_par *par)
1783 /* Check LCD panel parrmation */ 1786 /* Check LCD panel parrmation */
1784 1787
1785 if (par->display_type == DISP_LCD) { 1788 if (par->display_type == DISP_LCD) {
1786 unsigned char cr6b = VGArCR( 0x6b ); 1789 unsigned char cr6b = VGArCR( 0x6b, par);
1787 1790
1788 int panelX = (VGArSEQ (0x61) + 1791 int panelX = (VGArSEQ (0x61, par) +
1789 ((VGArSEQ (0x66) & 0x02) << 7) + 1) * 8; 1792 ((VGArSEQ (0x66, par) & 0x02) << 7) + 1) * 8;
1790 int panelY = (VGArSEQ (0x69) + 1793 int panelY = (VGArSEQ (0x69, par) +
1791 ((VGArSEQ (0x6e) & 0x70) << 4) + 1); 1794 ((VGArSEQ (0x6e, par) & 0x70) << 4) + 1);
1792 1795
1793 char * sTechnology = "Unknown"; 1796 char * sTechnology = "Unknown";
1794 1797
@@ -1810,9 +1813,9 @@ static int __devinit savage_init_hw (struct savagefb_par *par)
1810 ActiveDUO = 0x80 1813 ActiveDUO = 0x80
1811 }; 1814 };
1812 1815
1813 if ((VGArSEQ (0x39) & 0x03) == 0) { 1816 if ((VGArSEQ (0x39, par) & 0x03) == 0) {
1814 sTechnology = "TFT"; 1817 sTechnology = "TFT";
1815 } else if ((VGArSEQ (0x30) & 0x01) == 0) { 1818 } else if ((VGArSEQ (0x30, par) & 0x01) == 0) {
1816 sTechnology = "DSTN"; 1819 sTechnology = "DSTN";
1817 } else { 1820 } else {
1818 sTechnology = "STN"; 1821 sTechnology = "STN";
@@ -2049,24 +2052,11 @@ static int __devinit savagefb_probe (struct pci_dev* dev,
2049 info->monspecs.modedb, info->monspecs.modedb_len, 2052 info->monspecs.modedb, info->monspecs.modedb_len,
2050 NULL, 8); 2053 NULL, 8);
2051 } else if (info->monspecs.modedb != NULL) { 2054 } else if (info->monspecs.modedb != NULL) {
2052 struct fb_monspecs *specs = &info->monspecs; 2055 struct fb_videomode *modedb;
2053 struct fb_videomode modedb;
2054 2056
2055 if (info->monspecs.misc & FB_MISC_1ST_DETAIL) { 2057 modedb = fb_find_best_display(&info->monspecs,
2056 int i; 2058 &info->modelist);
2057 2059 savage_update_var(&info->var, modedb);
2058 for (i = 0; i < specs->modedb_len; i++) {
2059 if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
2060 modedb = specs->modedb[i];
2061 break;
2062 }
2063 }
2064 } else {
2065 /* otherwise, get first mode in database */
2066 modedb = specs->modedb[0];
2067 }
2068
2069 savage_update_var(&info->var, &modedb);
2070 } 2060 }
2071 2061
2072 /* maximize virtual vertical length */ 2062 /* maximize virtual vertical length */
diff --git a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
index cf5106eab2d5..2e8769dd345a 100644
--- a/drivers/video/sgivwfb.c
+++ b/drivers/video/sgivwfb.c
@@ -126,7 +126,6 @@ static struct fb_ops sgivwfb_ops = {
126 .fb_fillrect = cfb_fillrect, 126 .fb_fillrect = cfb_fillrect,
127 .fb_copyarea = cfb_copyarea, 127 .fb_copyarea = cfb_copyarea,
128 .fb_imageblit = cfb_imageblit, 128 .fb_imageblit = cfb_imageblit,
129 .fb_cursor = soft_cursor,
130 .fb_mmap = sgivwfb_mmap, 129 .fb_mmap = sgivwfb_mmap,
131}; 130};
132 131
@@ -751,10 +750,6 @@ int __init sgivwfb_setup(char *options)
751/* 750/*
752 * Initialisation 751 * Initialisation
753 */ 752 */
754static void sgivwfb_release(struct device *device)
755{
756}
757
758static int __init sgivwfb_probe(struct device *device) 753static int __init sgivwfb_probe(struct device *device)
759{ 754{
760 struct platform_device *dev = to_platform_device(device); 755 struct platform_device *dev = to_platform_device(device);
@@ -859,13 +854,7 @@ static struct device_driver sgivwfb_driver = {
859 .remove = sgivwfb_remove, 854 .remove = sgivwfb_remove,
860}; 855};
861 856
862static struct platform_device sgivwfb_device = { 857static struct platform_device *sgivwfb_device;
863 .name = "sgivwfb",
864 .id = 0,
865 .dev = {
866 .release = sgivwfb_release,
867 }
868};
869 858
870int __init sgivwfb_init(void) 859int __init sgivwfb_init(void)
871{ 860{
@@ -880,9 +869,15 @@ int __init sgivwfb_init(void)
880#endif 869#endif
881 ret = driver_register(&sgivwfb_driver); 870 ret = driver_register(&sgivwfb_driver);
882 if (!ret) { 871 if (!ret) {
883 ret = platform_device_register(&sgivwfb_device); 872 sgivwfb_device = platform_device_alloc("sgivwfb", 0);
884 if (ret) 873 if (sgivwfb_device) {
874 ret = platform_device_add(sgivwfb_device);
875 } else
876 ret = -ENOMEM;
877 if (ret) {
885 driver_unregister(&sgivwfb_driver); 878 driver_unregister(&sgivwfb_driver);
879 platform_device_put(sgivwfb_device);
880 }
886 } 881 }
887 return ret; 882 return ret;
888} 883}
@@ -894,7 +889,7 @@ MODULE_LICENSE("GPL");
894 889
895static void __exit sgivwfb_exit(void) 890static void __exit sgivwfb_exit(void)
896{ 891{
897 platform_device_unregister(&sgivwfb_device); 892 platform_device_unregister(sgivwfb_device);
898 driver_unregister(&sgivwfb_driver); 893 driver_unregister(&sgivwfb_driver);
899} 894}
900 895
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index 42c54b69726e..dea1a46c67c4 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -2002,7 +2002,9 @@ static struct fb_ops sisfb_ops = {
2002 .fb_fillrect = fbcon_sis_fillrect, 2002 .fb_fillrect = fbcon_sis_fillrect,
2003 .fb_copyarea = fbcon_sis_copyarea, 2003 .fb_copyarea = fbcon_sis_copyarea,
2004 .fb_imageblit = cfb_imageblit, 2004 .fb_imageblit = cfb_imageblit,
2005#ifdef CONFIG_FB_SOFT_CURSOR
2005 .fb_cursor = soft_cursor, 2006 .fb_cursor = soft_cursor,
2007#endif
2006 .fb_sync = fbcon_sis_sync, 2008 .fb_sync = fbcon_sis_sync,
2007#ifdef SIS_NEW_CONFIG_COMPAT 2009#ifdef SIS_NEW_CONFIG_COMPAT
2008 .fb_compat_ioctl= sisfb_compat_ioctl, 2010 .fb_compat_ioctl= sisfb_compat_ioctl,
diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
index 7b43716ab665..a01e7ecc15ed 100644
--- a/drivers/video/skeletonfb.c
+++ b/drivers/video/skeletonfb.c
@@ -457,11 +457,8 @@ void xxxfb_imageblit(struct fb_info *p, const struct fb_image *image)
457} 457}
458 458
459/** 459/**
460 * xxxfb_cursor - REQUIRED function. If your hardware lacks support 460 * xxxfb_cursor - OPTIONAL. If your hardware lacks support
461 * for a cursor you can use the default cursor whose 461 * for a cursor, leave this field NULL.
462 * function is called soft_cursor. It will always
463 * work since it uses xxxfb_imageblit function which
464 * is required.
465 * 462 *
466 * @info: frame buffer structure that represents a single frame buffer 463 * @info: frame buffer structure that represents a single frame buffer
467 * @cursor: structure defining the cursor to draw. 464 * @cursor: structure defining the cursor to draw.
@@ -663,7 +660,7 @@ static struct fb_ops xxxfb_ops = {
663 .fb_fillrect = xxxfb_fillrect, /* Needed !!! */ 660 .fb_fillrect = xxxfb_fillrect, /* Needed !!! */
664 .fb_copyarea = xxxfb_copyarea, /* Needed !!! */ 661 .fb_copyarea = xxxfb_copyarea, /* Needed !!! */
665 .fb_imageblit = xxxfb_imageblit, /* Needed !!! */ 662 .fb_imageblit = xxxfb_imageblit, /* Needed !!! */
666 .fb_cursor = xxxfb_cursor, /* Needed !!! */ 663 .fb_cursor = xxxfb_cursor, /* Optional !!! */
667 .fb_rotate = xxxfb_rotate, 664 .fb_rotate = xxxfb_rotate,
668 .fb_poll = xxxfb_poll, 665 .fb_poll = xxxfb_poll,
669 .fb_sync = xxxfb_sync, 666 .fb_sync = xxxfb_sync,
diff --git a/drivers/video/sstfb.c b/drivers/video/sstfb.c
index 663d53657fa4..e0f14df840d9 100644
--- a/drivers/video/sstfb.c
+++ b/drivers/video/sstfb.c
@@ -1382,7 +1382,6 @@ static struct fb_ops sstfb_ops = {
1382 .fb_fillrect = cfb_fillrect, /* sstfb_fillrect */ 1382 .fb_fillrect = cfb_fillrect, /* sstfb_fillrect */
1383 .fb_copyarea = cfb_copyarea, /* sstfb_copyarea */ 1383 .fb_copyarea = cfb_copyarea, /* sstfb_copyarea */
1384 .fb_imageblit = cfb_imageblit, 1384 .fb_imageblit = cfb_imageblit,
1385 .fb_cursor = soft_cursor,
1386 .fb_ioctl = sstfb_ioctl, 1385 .fb_ioctl = sstfb_ioctl,
1387}; 1386};
1388 1387
diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c
index 9e52794768e6..fbb17332afd7 100644
--- a/drivers/video/stifb.c
+++ b/drivers/video/stifb.c
@@ -1147,7 +1147,6 @@ static struct fb_ops stifb_ops = {
1147 .fb_fillrect = cfb_fillrect, 1147 .fb_fillrect = cfb_fillrect,
1148 .fb_copyarea = cfb_copyarea, 1148 .fb_copyarea = cfb_copyarea,
1149 .fb_imageblit = cfb_imageblit, 1149 .fb_imageblit = cfb_imageblit,
1150 .fb_cursor = soft_cursor,
1151}; 1150};
1152 1151
1153 1152
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index 1986a8b3833c..59fff29bc02e 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -52,7 +52,6 @@ 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 .fb_cursor = soft_cursor,
56}; 55};
57 56
58/* THC definitions */ 57/* THC definitions */
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index 7044226c5d4c..9d53387e6a66 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -184,7 +184,6 @@ static struct fb_ops tdfxfb_ops = {
184 .fb_copyarea = cfb_copyarea, 184 .fb_copyarea = cfb_copyarea,
185 .fb_imageblit = cfb_imageblit, 185 .fb_imageblit = cfb_imageblit,
186#endif 186#endif
187 .fb_cursor = soft_cursor,
188}; 187};
189 188
190/* 189/*
diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
index 9d9d2009ad8c..7398bd48ba6c 100644
--- a/drivers/video/tgafb.c
+++ b/drivers/video/tgafb.c
@@ -63,7 +63,6 @@ static struct fb_ops tgafb_ops = {
63 .fb_fillrect = tgafb_fillrect, 63 .fb_fillrect = tgafb_fillrect,
64 .fb_copyarea = tgafb_copyarea, 64 .fb_copyarea = tgafb_copyarea,
65 .fb_imageblit = tgafb_imageblit, 65 .fb_imageblit = tgafb_imageblit,
66 .fb_cursor = soft_cursor,
67}; 66};
68 67
69 68
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
index 81a6d9f188cf..9ac2d3171187 100644
--- a/drivers/video/tridentfb.c
+++ b/drivers/video/tridentfb.c
@@ -1293,7 +1293,6 @@ static struct fb_ops tridentfb_ops = {
1293 .fb_fillrect = tridentfb_fillrect, 1293 .fb_fillrect = tridentfb_fillrect,
1294 .fb_copyarea= tridentfb_copyarea, 1294 .fb_copyarea= tridentfb_copyarea,
1295 .fb_imageblit = cfb_imageblit, 1295 .fb_imageblit = cfb_imageblit,
1296 .fb_cursor = soft_cursor,
1297}; 1296};
1298 1297
1299module_init(tridentfb_init); 1298module_init(tridentfb_init);
diff --git a/drivers/video/tx3912fb.c b/drivers/video/tx3912fb.c
index 39d9ca71856b..d904da44e1aa 100644
--- a/drivers/video/tx3912fb.c
+++ b/drivers/video/tx3912fb.c
@@ -89,7 +89,6 @@ static struct fb_ops tx3912fb_ops = {
89 .fb_fillrect = cfb_fillrect, 89 .fb_fillrect = cfb_fillrect,
90 .fb_copyarea = cfb_copyarea, 90 .fb_copyarea = cfb_copyarea,
91 .fb_imageblit = cfb_imageblit, 91 .fb_imageblit = cfb_imageblit,
92 .fb_cursor = soft_cursor,
93}; 92};
94 93
95static int tx3912fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 94static int tx3912fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
index 31a2bbc53974..ce97ec8eae97 100644
--- a/drivers/video/valkyriefb.c
+++ b/drivers/video/valkyriefb.c
@@ -135,7 +135,6 @@ static struct fb_ops valkyriefb_ops = {
135 .fb_fillrect = cfb_fillrect, 135 .fb_fillrect = cfb_fillrect,
136 .fb_copyarea = cfb_copyarea, 136 .fb_copyarea = cfb_copyarea,
137 .fb_imageblit = cfb_imageblit, 137 .fb_imageblit = cfb_imageblit,
138 .fb_cursor = soft_cursor,
139}; 138};
140 139
141/* Sets the video mode according to info->var */ 140/* Sets the video mode according to info->var */
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 3cc23106641d..e25eae1a78c1 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -48,7 +48,7 @@ static struct fb_fix_screeninfo vesafb_fix __initdata = {
48}; 48};
49 49
50static int inverse = 0; 50static int inverse = 0;
51static int mtrr = 3; /* default to write-combining */ 51static int mtrr = 0; /* disable mtrr */
52static int vram_remap __initdata = 0; /* Set amount of memory to be used */ 52static int vram_remap __initdata = 0; /* Set amount of memory to be used */
53static int vram_total __initdata = 0; /* Set total amount of memory */ 53static int vram_total __initdata = 0; /* Set total amount of memory */
54static int pmi_setpal = 0; /* pmi for palette changes ??? */ 54static int pmi_setpal = 0; /* pmi for palette changes ??? */
@@ -166,45 +166,39 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
166 if (regno >= info->cmap.len) 166 if (regno >= info->cmap.len)
167 return 1; 167 return 1;
168 168
169 switch (info->var.bits_per_pixel) { 169 if (info->var.bits_per_pixel == 8)
170 case 8:
171 vesa_setpalette(regno,red,green,blue); 170 vesa_setpalette(regno,red,green,blue);
172 break; 171 else if (regno < 16) {
173 case 16: 172 switch (info->var.bits_per_pixel) {
174 if (info->var.red.offset == 10) { 173 case 16:
175 /* 1:5:5:5 */ 174 if (info->var.red.offset == 10) {
176 ((u32*) (info->pseudo_palette))[regno] = 175 /* 1:5:5:5 */
176 ((u32*) (info->pseudo_palette))[regno] =
177 ((red & 0xf800) >> 1) | 177 ((red & 0xf800) >> 1) |
178 ((green & 0xf800) >> 6) | 178 ((green & 0xf800) >> 6) |
179 ((blue & 0xf800) >> 11); 179 ((blue & 0xf800) >> 11);
180 } else { 180 } else {
181 /* 0:5:6:5 */ 181 /* 0:5:6:5 */
182 ((u32*) (info->pseudo_palette))[regno] = 182 ((u32*) (info->pseudo_palette))[regno] =
183 ((red & 0xf800) ) | 183 ((red & 0xf800) ) |
184 ((green & 0xfc00) >> 5) | 184 ((green & 0xfc00) >> 5) |
185 ((blue & 0xf800) >> 11); 185 ((blue & 0xf800) >> 11);
186 }
187 break;
188 case 24:
189 case 32:
190 red >>= 8;
191 green >>= 8;
192 blue >>= 8;
193 ((u32 *)(info->pseudo_palette))[regno] =
194 (red << info->var.red.offset) |
195 (green << info->var.green.offset) |
196 (blue << info->var.blue.offset);
197 break;
186 } 198 }
187 break; 199 }
188 case 24: 200
189 red >>= 8; 201 return 0;
190 green >>= 8;
191 blue >>= 8;
192 ((u32 *)(info->pseudo_palette))[regno] =
193 (red << info->var.red.offset) |
194 (green << info->var.green.offset) |
195 (blue << info->var.blue.offset);
196 break;
197 case 32:
198 red >>= 8;
199 green >>= 8;
200 blue >>= 8;
201 ((u32 *)(info->pseudo_palette))[regno] =
202 (red << info->var.red.offset) |
203 (green << info->var.green.offset) |
204 (blue << info->var.blue.offset);
205 break;
206 }
207 return 0;
208} 202}
209 203
210static struct fb_ops vesafb_ops = { 204static struct fb_ops vesafb_ops = {
@@ -215,7 +209,6 @@ static struct fb_ops vesafb_ops = {
215 .fb_fillrect = cfb_fillrect, 209 .fb_fillrect = cfb_fillrect,
216 .fb_copyarea = cfb_copyarea, 210 .fb_copyarea = cfb_copyarea,
217 .fb_imageblit = cfb_imageblit, 211 .fb_imageblit = cfb_imageblit,
218 .fb_cursor = soft_cursor,
219}; 212};
220 213
221static int __init vesafb_setup(char *options) 214static int __init vesafb_setup(char *options)
diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c
index 92d46555dd86..8794dc5d2466 100644
--- a/drivers/video/vfb.c
+++ b/drivers/video/vfb.c
@@ -92,7 +92,6 @@ static struct fb_ops vfb_ops = {
92 .fb_fillrect = cfb_fillrect, 92 .fb_fillrect = cfb_fillrect,
93 .fb_copyarea = cfb_copyarea, 93 .fb_copyarea = cfb_copyarea,
94 .fb_imageblit = cfb_imageblit, 94 .fb_imageblit = cfb_imageblit,
95 .fb_cursor = soft_cursor,
96 .fb_mmap = vfb_mmap, 95 .fb_mmap = vfb_mmap,
97}; 96};
98 97
diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
index b46454c55c91..690bb6fe8281 100644
--- a/drivers/video/vga16fb.c
+++ b/drivers/video/vga16fb.c
@@ -1326,7 +1326,6 @@ static struct fb_ops vga16fb_ops = {
1326 .fb_fillrect = vga16fb_fillrect, 1326 .fb_fillrect = vga16fb_fillrect,
1327 .fb_copyarea = vga16fb_copyarea, 1327 .fb_copyarea = vga16fb_copyarea,
1328 .fb_imageblit = vga16fb_imageblit, 1328 .fb_imageblit = vga16fb_imageblit,
1329 .fb_cursor = soft_cursor,
1330}; 1329};
1331 1330
1332#ifndef MODULE 1331#ifndef MODULE
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index cf8cdb108fd9..48e70f153c4b 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -397,7 +397,6 @@ static struct fb_ops w100fb_ops = {
397 .fb_fillrect = cfb_fillrect, 397 .fb_fillrect = cfb_fillrect,
398 .fb_copyarea = cfb_copyarea, 398 .fb_copyarea = cfb_copyarea,
399 .fb_imageblit = cfb_imageblit, 399 .fb_imageblit = cfb_imageblit,
400 .fb_cursor = soft_cursor,
401}; 400};
402 401
403#ifdef CONFIG_PM 402#ifdef CONFIG_PM
diff --git a/drivers/w1/w1_ds2433.c b/drivers/w1/w1_ds2433.c
index 279e0e0363d6..1e3d98aac12d 100644
--- a/drivers/w1/w1_ds2433.c
+++ b/drivers/w1/w1_ds2433.c
@@ -299,10 +299,8 @@ static int w1_f23_add_slave(struct w1_slave *sl)
299static void w1_f23_remove_slave(struct w1_slave *sl) 299static void w1_f23_remove_slave(struct w1_slave *sl)
300{ 300{
301#ifdef CONFIG_W1_F23_CRC 301#ifdef CONFIG_W1_F23_CRC
302 if (sl->family_data) { 302 kfree(sl->family_data);
303 kfree(sl->family_data); 303 sl->family_data = NULL;
304 sl->family_data = NULL;
305 }
306#endif /* CONFIG_W1_F23_CRC */ 304#endif /* CONFIG_W1_F23_CRC */
307 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 305 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
308} 306}