aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-12-01 04:56:43 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2006-12-01 04:56:43 -0500
commitbd3c97a7c718bfb9f1e4f31c16c383a5c6f815eb (patch)
tree3f56594e813c6f35cbacbdb3e137ba5bfd0b3069 /drivers
parent6c33cafc794d07c9254c160789120a0e98c088c9 (diff)
parent0215ffb08ce99e2bb59eca114a99499a4d06e704 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/osl.c34
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/ata/ahci.c24
-rw-r--r--drivers/ata/ata_piix.c41
-rw-r--r--drivers/ata/libata-core.c3
-rw-r--r--drivers/ata/libata-scsi.c23
-rw-r--r--drivers/ata/libata-sff.c9
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_amd.c2
-rw-r--r--drivers/ata/pata_artop.c2
-rw-r--r--drivers/ata/pata_hpt37x.c19
-rw-r--r--drivers/ata/sata_nv.c12
-rw-r--r--drivers/ata/sata_sis.c21
-rw-r--r--drivers/ata/sata_via.c2
-rw-r--r--drivers/atm/ambassador.c4
-rw-r--r--drivers/atm/firestream.c4
-rw-r--r--drivers/atm/horizon.c6
-rw-r--r--drivers/atm/nicstar.c4
-rw-r--r--drivers/base/Kconfig4
-rw-r--r--drivers/base/core.c4
-rw-r--r--drivers/base/dd.c30
-rw-r--r--drivers/block/aoe/aoeblk.c1
-rw-r--r--drivers/block/cciss.c36
-rw-r--r--drivers/block/cpqarray.c15
-rw-r--r--drivers/bluetooth/bluecard_cs.c2
-rw-r--r--drivers/char/Kconfig8
-rw-r--r--drivers/char/agp/generic.c2
-rw-r--r--drivers/char/agp/intel-agp.c33
-rw-r--r--drivers/char/agp/uninorth-agp.c54
-rw-r--r--drivers/char/drm/drm_bufs.c4
-rw-r--r--drivers/char/drm/drm_sysfs.c43
-rw-r--r--drivers/char/drm/mga_drv.c1
-rw-r--r--drivers/char/drm/r300_cmdbuf.c33
-rw-r--r--drivers/char/drm/radeon_state.c109
-rw-r--r--drivers/char/drm/savage_bci.c1
-rw-r--r--drivers/char/drm/savage_state.c2
-rw-r--r--drivers/char/ftape/zftape/zftape-buffers.c4
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c22
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c10
-rw-r--r--drivers/char/isicom.c3
-rw-r--r--drivers/char/moxa.c9
-rw-r--r--drivers/char/mspec.c8
-rw-r--r--drivers/char/rio/host.h1
-rw-r--r--drivers/char/rio/rio_linux.c9
-rw-r--r--drivers/char/tlclk.c5
-rw-r--r--drivers/char/watchdog/Kconfig65
-rw-r--r--drivers/char/watchdog/Makefile4
-rw-r--r--drivers/char/watchdog/at91rm9200_wdt.c (renamed from drivers/char/watchdog/at91_wdt.c)0
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c21
-rw-r--r--drivers/char/watchdog/s3c2410_wdt.c5
-rw-r--r--drivers/char/watchdog/sc1200wdt.c9
-rw-r--r--drivers/char/watchdog/smsc37b787_wdt.c627
-rw-r--r--drivers/char/watchdog/w83627hf_wdt.c8
-rw-r--r--drivers/char/watchdog/w83697hf_wdt.c450
-rw-r--r--drivers/clocksource/acpi_pm.c6
-rw-r--r--drivers/cpufreq/Kconfig1
-rw-r--r--drivers/cpufreq/cpufreq.c2
-rw-r--r--drivers/edac/edac_mc.c45
-rw-r--r--drivers/fc4/fc.c28
-rw-r--r--drivers/fc4/fcp_impl.h15
-rw-r--r--drivers/firmware/dell_rbu.c9
-rw-r--r--drivers/firmware/dmi_scan.c20
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c3
-rw-r--r--drivers/i2c/busses/i2c-pxa.c8
-rw-r--r--drivers/i2c/busses/scx200_acb.c7
-rw-r--r--drivers/ide/ide-cd.c2
-rw-r--r--drivers/ide/legacy/hd.c2
-rw-r--r--drivers/ide/pci/amd74xx.c7
-rw-r--r--drivers/ide/pci/generic.c19
-rw-r--r--drivers/ide/pci/sgiioc4.c7
-rw-r--r--drivers/ieee1394/eth1394.c20
-rw-r--r--drivers/ieee1394/ohci1394.c19
-rw-r--r--drivers/infiniband/core/addr.c28
-rw-r--r--drivers/infiniband/core/cma.c31
-rw-r--r--drivers/infiniband/core/mad.c2
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2.c3
-rw-r--r--drivers/infiniband/hw/amso1100/c2_alloc.c13
-rw-r--r--drivers/infiniband/hw/amso1100/c2_cq.c18
-rw-r--r--drivers/infiniband/hw/amso1100/c2_provider.c39
-rw-r--r--drivers/infiniband/hw/amso1100/c2_rnic.c60
-rw-r--r--drivers/infiniband/hw/ehca/Kconfig1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_av.c5
-rw-r--r--drivers/infiniband/hw/ehca/ehca_hca.c17
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c17
-rw-r--r--drivers/infiniband/hw/ehca/ehca_iverbs.h8
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c56
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c8
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c10
-rw-r--r--drivers/infiniband/hw/ehca/ehca_tools.h1
-rw-r--r--drivers/infiniband/hw/ehca/hipz_hw.h2
-rw-r--r--drivers/infiniband/hw/ipath/Kconfig2
-rw-r--r--drivers/infiniband/hw/ipath/Makefile5
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c21
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6110.c117
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6120.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_intr.c10
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h4
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c14
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c15
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.c4
-rw-r--r--drivers/input/keyboard/lkkbd.c5
-rw-r--r--drivers/input/touchscreen/hp680_ts_input.c2
-rw-r--r--drivers/isdn/gigaset/common.c2
-rw-r--r--drivers/isdn/hisax/Kconfig2
-rw-r--r--drivers/isdn/hysdn/hysdn_sched.c19
-rw-r--r--drivers/macintosh/windfarm_pm112.c11
-rw-r--r--drivers/macintosh/windfarm_pm81.c1
-rw-r--r--drivers/macintosh/windfarm_pm91.c1
-rw-r--r--drivers/md/bitmap.c10
-rw-r--r--drivers/md/dm-crypt.c11
-rw-r--r--drivers/md/dm-ioctl.c9
-rw-r--r--drivers/md/dm-raid1.c22
-rw-r--r--drivers/md/dm-round-robin.c2
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/md/md.c24
-rw-r--r--drivers/md/multipath.c4
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c2
-rw-r--r--drivers/media/common/saa7146_i2c.c10
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c2
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig12
-rw-r--r--drivers/media/dvb/frontends/Kconfig2
-rw-r--r--drivers/media/dvb/frontends/bcm3510.h2
-rw-r--r--drivers/media/dvb/frontends/cx22700.h2
-rw-r--r--drivers/media/dvb/frontends/cx22702.h2
-rw-r--r--drivers/media/dvb/frontends/cx24110.h2
-rw-r--r--drivers/media/dvb/frontends/cx24123.h2
-rw-r--r--drivers/media/dvb/frontends/dib3000.h2
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.h2
-rw-r--r--drivers/media/dvb/frontends/isl6421.h2
-rw-r--r--drivers/media/dvb/frontends/l64781.h2
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.h2
-rw-r--r--drivers/media/dvb/frontends/lnbp21.h2
-rw-r--r--drivers/media/dvb/frontends/mt2060.h8
-rw-r--r--drivers/media/dvb/frontends/mt312.h2
-rw-r--r--drivers/media/dvb/frontends/mt352.h2
-rw-r--r--drivers/media/dvb/frontends/nxt200x.h2
-rw-r--r--drivers/media/dvb/frontends/nxt6000.h2
-rw-r--r--drivers/media/dvb/frontends/or51132.h2
-rw-r--r--drivers/media/dvb/frontends/or51211.h2
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h2
-rw-r--r--drivers/media/dvb/frontends/sp8870.h2
-rw-r--r--drivers/media/dvb/frontends/sp887x.h2
-rw-r--r--drivers/media/dvb/frontends/stv0297.h2
-rw-r--r--drivers/media/dvb/frontends/stv0299.h2
-rw-r--r--drivers/media/dvb/frontends/tda10021.h2
-rw-r--r--drivers/media/dvb/frontends/tda1004x.h2
-rw-r--r--drivers/media/dvb/frontends/tda10086.c4
-rw-r--r--drivers/media/dvb/frontends/tda10086.h2
-rw-r--r--drivers/media/dvb/frontends/tda8083.h2
-rw-r--r--drivers/media/dvb/frontends/tda826x.c2
-rw-r--r--drivers/media/dvb/frontends/tda826x.h2
-rw-r--r--drivers/media/dvb/frontends/tua6100.h2
-rw-r--r--drivers/media/dvb/frontends/ves1820.h2
-rw-r--r--drivers/media/dvb/frontends/ves1x93.h2
-rw-r--r--drivers/media/dvb/frontends/zl10353.h2
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c10
-rw-r--r--drivers/media/dvb/ttpci/budget.c9
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c2
-rw-r--r--drivers/media/video/cx88/cx88-input.c10
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c6
-rw-r--r--drivers/media/video/saa6588.c4
-rw-r--r--drivers/media/video/saa7115.c9
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c5
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c11
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c3
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/message/fusion/mptbase.h4
-rw-r--r--drivers/message/fusion/mptfc.c89
-rw-r--r--drivers/message/i2o/exec-osm.c4
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/misc/ioc4.c5
-rw-r--r--drivers/misc/lkdtm.c32
-rw-r--r--drivers/mmc/mmc.c19
-rw-r--r--drivers/mmc/tifm_sd.c1
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c2
-rw-r--r--drivers/mtd/nand/nand_base.c1
-rw-r--r--drivers/net/Kconfig21
-rw-r--r--drivers/net/arcnet/com20020.c7
-rw-r--r--drivers/net/arm/ep93xx_eth.c40
-rw-r--r--drivers/net/au1000_eth.c2
-rw-r--r--drivers/net/b44.c5
-rw-r--r--drivers/net/bonding/bond_main.c5
-rw-r--r--drivers/net/cris/eth_v10.c2
-rw-r--r--drivers/net/e100.c10
-rw-r--r--drivers/net/e1000/e1000_ethtool.c4
-rw-r--r--drivers/net/e1000/e1000_hw.h6
-rw-r--r--drivers/net/e1000/e1000_main.c52
-rw-r--r--drivers/net/ehea/ehea.h5
-rw-r--r--drivers/net/ehea/ehea_ethtool.c2
-rw-r--r--drivers/net/ehea/ehea_main.c31
-rw-r--r--drivers/net/ehea/ehea_phyp.c2
-rw-r--r--drivers/net/ehea/ehea_phyp.h6
-rw-r--r--drivers/net/ehea/ehea_qmr.c17
-rw-r--r--drivers/net/hamradio/6pack.c2
-rw-r--r--drivers/net/ibmveth.c10
-rw-r--r--drivers/net/ioc3-eth.c4
-rw-r--r--drivers/net/irda/stir4200.c3
-rw-r--r--drivers/net/myri10ge/myri10ge.c1
-rw-r--r--drivers/net/r8169.c49
-rw-r--r--drivers/net/s2io.c11
-rw-r--r--drivers/net/sb1250-mac.c2
-rw-r--r--drivers/net/skge.c3
-rw-r--r--drivers/net/sky2.c42
-rw-r--r--drivers/net/smc91x.h18
-rw-r--r--drivers/net/tg3.c52
-rw-r--r--drivers/net/tokenring/proteon.c9
-rw-r--r--drivers/net/tokenring/skisa.c9
-rw-r--r--drivers/net/ucc_geth.c633
-rw-r--r--drivers/net/ucc_geth.h248
-rw-r--r--drivers/net/ucc_geth_phy.c26
-rw-r--r--drivers/net/ucc_geth_phy.h2
-rw-r--r--drivers/net/wan/Kconfig2
-rw-r--r--drivers/net/wan/n2.c6
-rw-r--r--drivers/net/wan/pc300_drv.c24
-rw-r--r--drivers/net/wireless/airo.c105
-rw-r--r--drivers/net/wireless/atmel.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_dma.c28
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_dma.h18
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.c9
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.h6
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c72
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c7
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c4
-rw-r--r--drivers/net/wireless/orinoco.c16
-rw-r--r--drivers/net/wireless/ray_cs.c1
-rw-r--r--drivers/net/wireless/zd1201.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c2
-rw-r--r--drivers/parport/parport_ip32.c2
-rw-r--r--drivers/pci/Kconfig2
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c6
-rw-r--r--drivers/pci/htirq.c101
-rw-r--r--drivers/pci/pci-driver.c13
-rw-r--r--drivers/pci/pci-sysfs.c3
-rw-r--r--drivers/pci/quirks.c100
-rw-r--r--drivers/pci/rom.c5
-rw-r--r--drivers/pcmcia/at91_cf.c28
-rw-r--r--drivers/pcmcia/au1000_generic.c25
-rw-r--r--drivers/pcmcia/ds.c34
-rw-r--r--drivers/pcmcia/i82092.c9
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c12
-rw-r--r--drivers/pcmcia/omap_cf.c3
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c11
-rw-r--r--drivers/pcmcia/pcmcia_resource.c2
-rw-r--r--drivers/pcmcia/pd6729.c4
-rw-r--r--drivers/pcmcia/pxa2xx_base.c41
-rw-r--r--drivers/pcmcia/pxa2xx_base.h2
-rw-r--r--drivers/pcmcia/pxa2xx_lubbock.c2
-rw-r--r--drivers/pcmcia/soc_common.c1
-rw-r--r--drivers/pcmcia/yenta_socket.c22
-rw-r--r--drivers/rtc/interface.c16
-rw-r--r--drivers/rtc/rtc-at91.c3
-rw-r--r--drivers/rtc/rtc-dev.c25
-rw-r--r--drivers/rtc/rtc-ds1553.c3
-rw-r--r--drivers/rtc/rtc-rs5c372.c6
-rw-r--r--drivers/rtc/rtc-test.c2
-rw-r--r--drivers/s390/cio/css.c7
-rw-r--r--drivers/s390/cio/device.c3
-rw-r--r--drivers/s390/cio/device.h1
-rw-r--r--drivers/s390/crypto/ap_bus.c7
-rw-r--r--drivers/s390/scsi/zfcp_def.h4
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c1
-rw-r--r--drivers/sbus/sbus.c4
-rw-r--r--drivers/scsi/3w-9xxx.c141
-rw-r--r--drivers/scsi/3w-9xxx.h14
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.h66
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_core.c350
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_inline.h30
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c45
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h5
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm_pci.c2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.c7
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_proc.c2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx.h11
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_core.c40
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c72
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h13
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm_pci.c2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_pci.c4
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_proc.c10
-rw-r--r--drivers/scsi/aic7xxx_old.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c18
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.h13
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sas.h1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c72
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sds.c4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.c5
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.h2
-rw-r--r--drivers/scsi/dpt/dpti_i2o.h2
-rw-r--r--drivers/scsi/fdomain.c30
-rw-r--r--drivers/scsi/gdth.c4
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c2
-rw-r--r--drivers/scsi/imm.c2
-rw-r--r--drivers/scsi/iscsi_tcp.c22
-rw-r--r--drivers/scsi/libiscsi.c78
-rw-r--r--drivers/scsi/libsas/sas_expander.c84
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c4
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c42
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h46
-rw-r--r--drivers/scsi/pcmcia/nsp_debug.c4
-rw-r--r--drivers/scsi/pcmcia/nsp_message.c4
-rw-r--r--drivers/scsi/ppa.c2
-rw-r--r--drivers/scsi/psi240i.c33
-rw-r--r--drivers/scsi/psi240i.h6
-rw-r--r--drivers/scsi/qla1280.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c51
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.h14
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c23
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c91
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c35
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/qla4xxx/Kconfig2
-rw-r--r--drivers/scsi/qla4xxx/ql4_dbg.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_glbl.h2
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c2
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c10
-rw-r--r--drivers/scsi/qlogicfas408.c18
-rw-r--r--drivers/scsi/qlogicfas408.h29
-rw-r--r--drivers/scsi/scsi_debug.c141
-rw-r--r--drivers/scsi/scsi_lib.c3
-rw-r--r--drivers/scsi/scsi_scan.c18
-rw-r--r--drivers/scsi/scsi_sysfs.c2
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c248
-rw-r--r--drivers/scsi/sg.c25
-rw-r--r--drivers/scsi/st.c5
-rw-r--r--drivers/scsi/sun3_NCR5380.c109
-rw-r--r--drivers/scsi/sun3_scsi.c7
-rw-r--r--drivers/scsi/sun3_scsi.h7
-rw-r--r--drivers/scsi/sun3_scsi_vme.c7
-rw-r--r--drivers/scsi/tmscsim.c1
-rw-r--r--drivers/serial/cpm_uart/cpm_uart.h2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c16
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c2
-rw-r--r--drivers/serial/ioc4_serial.c4
-rw-r--r--drivers/spi/spi.c1
-rw-r--r--drivers/telephony/ixj.h2
-rw-r--r--drivers/usb/class/usblp.c3
-rw-r--r--drivers/usb/core/hub.c3
-rw-r--r--drivers/usb/core/message.c5
-rw-r--r--drivers/usb/host/ohci-hcd.c25
-rw-r--r--drivers/usb/host/ohci-hub.c6
-rw-r--r--drivers/usb/input/ati_remote.c10
-rw-r--r--drivers/usb/input/hid-core.c68
-rw-r--r--drivers/usb/input/hid-input.c17
-rw-r--r--drivers/usb/input/hid.h1
-rw-r--r--drivers/usb/input/usbtouchscreen.c2
-rw-r--r--drivers/usb/input/xpad.c41
-rw-r--r--drivers/usb/misc/auerswald.c2
-rw-r--r--drivers/usb/net/Kconfig8
-rw-r--r--drivers/usb/net/usbnet.c60
-rw-r--r--drivers/usb/serial/Kconfig4
-rw-r--r--drivers/usb/serial/cp2101.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.h11
-rw-r--r--drivers/usb/serial/ipaq.c1
-rw-r--r--drivers/usb/serial/sierra.c3
-rw-r--r--drivers/usb/storage/unusual_devs.h13
-rw-r--r--drivers/video/aty/atyfb_base.c2
-rw-r--r--drivers/video/aty/radeon_i2c.c8
-rw-r--r--drivers/video/backlight/corgi_bl.c4
-rw-r--r--drivers/video/backlight/hp680_bl.c2
-rw-r--r--drivers/video/fb_ddc.c6
-rw-r--r--drivers/video/hitfb.c1
-rw-r--r--drivers/video/intelfb/intelfbhw.c6
-rw-r--r--drivers/video/nvidia/nv_hw.c12
-rw-r--r--drivers/video/nvidia/nv_setup.c20
-rw-r--r--drivers/video/nvidia/nv_type.h1
-rw-r--r--drivers/video/nvidia/nvidia.c24
-rw-r--r--drivers/video/offb.c36
-rw-r--r--drivers/video/pnx4008/pnxrgbfb.c5
-rw-r--r--drivers/video/pnx4008/sdum.c2
-rw-r--r--drivers/w1/masters/matrox_w1.c2
387 files changed, 5104 insertions, 2764 deletions
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index c84286cbbe25..068fe4f100b0 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -73,7 +73,6 @@ static unsigned int acpi_irq_irq;
73static acpi_osd_handler acpi_irq_handler; 73static acpi_osd_handler acpi_irq_handler;
74static void *acpi_irq_context; 74static void *acpi_irq_context;
75static struct workqueue_struct *kacpid_wq; 75static struct workqueue_struct *kacpid_wq;
76static struct workqueue_struct *kacpi_notify_wq;
77 76
78acpi_status acpi_os_initialize(void) 77acpi_status acpi_os_initialize(void)
79{ 78{
@@ -92,9 +91,8 @@ acpi_status acpi_os_initialize1(void)
92 return AE_NULL_ENTRY; 91 return AE_NULL_ENTRY;
93 } 92 }
94 kacpid_wq = create_singlethread_workqueue("kacpid"); 93 kacpid_wq = create_singlethread_workqueue("kacpid");
95 kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
96 BUG_ON(!kacpid_wq); 94 BUG_ON(!kacpid_wq);
97 BUG_ON(!kacpi_notify_wq); 95
98 return AE_OK; 96 return AE_OK;
99} 97}
100 98
@@ -106,7 +104,6 @@ acpi_status acpi_os_terminate(void)
106 } 104 }
107 105
108 destroy_workqueue(kacpid_wq); 106 destroy_workqueue(kacpid_wq);
109 destroy_workqueue(kacpi_notify_wq);
110 107
111 return AE_OK; 108 return AE_OK;
112} 109}
@@ -569,7 +566,10 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
569 566
570static void acpi_os_execute_deferred(void *context) 567static void acpi_os_execute_deferred(void *context)
571{ 568{
572 struct acpi_os_dpc *dpc = (struct acpi_os_dpc *)context; 569 struct acpi_os_dpc *dpc = NULL;
570
571
572 dpc = (struct acpi_os_dpc *)context;
573 if (!dpc) { 573 if (!dpc) {
574 printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); 574 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
575 return; 575 return;
@@ -604,12 +604,14 @@ acpi_status acpi_os_execute(acpi_execute_type type,
604 struct acpi_os_dpc *dpc; 604 struct acpi_os_dpc *dpc;
605 struct work_struct *task; 605 struct work_struct *task;
606 606
607 ACPI_FUNCTION_TRACE("os_queue_for_execution");
608
607 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 609 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
608 "Scheduling function [%p(%p)] for deferred execution.\n", 610 "Scheduling function [%p(%p)] for deferred execution.\n",
609 function, context)); 611 function, context));
610 612
611 if (!function) 613 if (!function)
612 return AE_BAD_PARAMETER; 614 return_ACPI_STATUS(AE_BAD_PARAMETER);
613 615
614 /* 616 /*
615 * Allocate/initialize DPC structure. Note that this memory will be 617 * Allocate/initialize DPC structure. Note that this memory will be
@@ -622,20 +624,26 @@ acpi_status acpi_os_execute(acpi_execute_type type,
622 * from the same memory. 624 * from the same memory.
623 */ 625 */
624 626
625 dpc = kmalloc(sizeof(struct acpi_os_dpc) + 627 dpc =
626 sizeof(struct work_struct), GFP_ATOMIC); 628 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
629 GFP_ATOMIC);
627 if (!dpc) 630 if (!dpc)
628 return AE_NO_MEMORY; 631 return_ACPI_STATUS(AE_NO_MEMORY);
632
629 dpc->function = function; 633 dpc->function = function;
630 dpc->context = context; 634 dpc->context = context;
635
631 task = (void *)(dpc + 1); 636 task = (void *)(dpc + 1);
632 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); 637 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
633 if (!queue_work((type == OSL_NOTIFY_HANDLER)? 638
634 kacpi_notify_wq : kacpid_wq, task)) { 639 if (!queue_work(kacpid_wq, task)) {
635 status = AE_ERROR; 640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
641 "Call to queue_work() failed.\n"));
636 kfree(dpc); 642 kfree(dpc);
643 status = AE_ERROR;
637 } 644 }
638 return status; 645
646 return_ACPI_STATUS(status);
639} 647}
640 648
641EXPORT_SYMBOL(acpi_os_execute); 649EXPORT_SYMBOL(acpi_os_execute);
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 7ba5e49ab302..6fd174a37149 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -83,10 +83,8 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
83 goto out; 83 goto out;
84 84
85 ppc = (unsigned int)pr->performance_platform_limit; 85 ppc = (unsigned int)pr->performance_platform_limit;
86 if (!ppc)
87 goto out;
88 86
89 if (ppc > pr->performance->state_count) 87 if (ppc >= pr->performance->state_count)
90 goto out; 88 goto out;
91 89
92 cpufreq_verify_within_limits(policy, 0, 90 cpufreq_verify_within_limits(policy, 0,
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 3f4aa0c99ee4..03f6338acc8f 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -6,6 +6,7 @@ menu "Serial ATA (prod) and Parallel ATA (experimental) drivers"
6 6
7config ATA 7config ATA
8 tristate "ATA device support" 8 tristate "ATA device support"
9 depends on BLOCK
9 depends on !(M32R || M68K) || BROKEN 10 depends on !(M32R || M68K) || BROKEN
10 depends on !SUN4 || BROKEN 11 depends on !SUN4 || BROKEN
11 select SCSI 12 select SCSI
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 25929123ffff..f510e1196dc6 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -314,6 +314,17 @@ static const struct pci_device_id ahci_pci_tbl[] = {
314 { PCI_VDEVICE(INTEL, 0x2824), board_ahci }, /* ICH8 */ 314 { PCI_VDEVICE(INTEL, 0x2824), board_ahci }, /* ICH8 */
315 { PCI_VDEVICE(INTEL, 0x2829), board_ahci }, /* ICH8M */ 315 { PCI_VDEVICE(INTEL, 0x2829), board_ahci }, /* ICH8M */
316 { PCI_VDEVICE(INTEL, 0x282a), board_ahci }, /* ICH8M */ 316 { PCI_VDEVICE(INTEL, 0x282a), board_ahci }, /* ICH8M */
317 { PCI_VDEVICE(INTEL, 0x2922), board_ahci }, /* ICH9 */
318 { PCI_VDEVICE(INTEL, 0x2923), board_ahci }, /* ICH9 */
319 { PCI_VDEVICE(INTEL, 0x2924), board_ahci }, /* ICH9 */
320 { PCI_VDEVICE(INTEL, 0x2925), board_ahci }, /* ICH9 */
321 { PCI_VDEVICE(INTEL, 0x2927), board_ahci }, /* ICH9 */
322 { PCI_VDEVICE(INTEL, 0x2929), board_ahci }, /* ICH9M */
323 { PCI_VDEVICE(INTEL, 0x292a), board_ahci }, /* ICH9M */
324 { PCI_VDEVICE(INTEL, 0x292b), board_ahci }, /* ICH9M */
325 { PCI_VDEVICE(INTEL, 0x292f), board_ahci }, /* ICH9M */
326 { PCI_VDEVICE(INTEL, 0x294d), board_ahci }, /* ICH9 */
327 { PCI_VDEVICE(INTEL, 0x294e), board_ahci }, /* ICH9M */
317 328
318 /* JMicron */ 329 /* JMicron */
319 { PCI_VDEVICE(JMICRON, 0x2360), board_ahci }, /* JMicron JMB360 */ 330 { PCI_VDEVICE(JMICRON, 0x2360), board_ahci }, /* JMicron JMB360 */
@@ -334,6 +345,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
334 { PCI_VDEVICE(NVIDIA, 0x044d), board_ahci }, /* MCP65 */ 345 { PCI_VDEVICE(NVIDIA, 0x044d), board_ahci }, /* MCP65 */
335 { PCI_VDEVICE(NVIDIA, 0x044e), board_ahci }, /* MCP65 */ 346 { PCI_VDEVICE(NVIDIA, 0x044e), board_ahci }, /* MCP65 */
336 { PCI_VDEVICE(NVIDIA, 0x044f), board_ahci }, /* MCP65 */ 347 { PCI_VDEVICE(NVIDIA, 0x044f), board_ahci }, /* MCP65 */
348 { PCI_VDEVICE(NVIDIA, 0x0554), board_ahci }, /* MCP67 */
349 { PCI_VDEVICE(NVIDIA, 0x0555), board_ahci }, /* MCP67 */
350 { PCI_VDEVICE(NVIDIA, 0x0556), board_ahci }, /* MCP67 */
351 { PCI_VDEVICE(NVIDIA, 0x0557), board_ahci }, /* MCP67 */
352 { PCI_VDEVICE(NVIDIA, 0x0558), board_ahci }, /* MCP67 */
353 { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */
354 { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */
355 { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */
337 356
338 /* SiS */ 357 /* SiS */
339 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ 358 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
@@ -736,8 +755,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
736 } 755 }
737 756
738 /* check BUSY/DRQ, perform Command List Override if necessary */ 757 /* check BUSY/DRQ, perform Command List Override if necessary */
739 ahci_tf_read(ap, &tf); 758 if (ahci_check_status(ap) & (ATA_BUSY | ATA_DRQ)) {
740 if (tf.command & (ATA_BUSY | ATA_DRQ)) {
741 rc = ahci_clo(ap); 759 rc = ahci_clo(ap);
742 760
743 if (rc == -EOPNOTSUPP) { 761 if (rc == -EOPNOTSUPP) {
@@ -1041,7 +1059,7 @@ static void ahci_host_intr(struct ata_port *ap)
1041 /* hmmm... a spurious interupt */ 1059 /* hmmm... a spurious interupt */
1042 1060
1043 /* some devices send D2H reg with I bit set during NCQ command phase */ 1061 /* some devices send D2H reg with I bit set during NCQ command phase */
1044 if (ap->sactive && status & PORT_IRQ_D2H_REG_FIS) 1062 if (ap->sactive && (status & PORT_IRQ_D2H_REG_FIS))
1045 return; 1063 return;
1046 1064
1047 /* ignore interim PIO setup fis interrupts */ 1065 /* ignore interim PIO setup fis interrupts */
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 5719704eb0ee..720174d628fa 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -126,8 +126,7 @@ enum {
126 ich6_sata = 7, 126 ich6_sata = 7,
127 ich6_sata_ahci = 8, 127 ich6_sata_ahci = 8,
128 ich6m_sata_ahci = 9, 128 ich6m_sata_ahci = 9,
129 ich7m_sata_ahci = 10, 129 ich8_sata_ahci = 10,
130 ich8_sata_ahci = 11,
131 130
132 /* constants for mapping table */ 131 /* constants for mapping table */
133 P0 = 0, /* port 0 */ 132 P0 = 0, /* port 0 */
@@ -227,7 +226,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
227 /* 82801GB/GR/GH (ICH7, identical to ICH6) */ 226 /* 82801GB/GR/GH (ICH7, identical to ICH6) */
228 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 227 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
229 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */ 228 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */
230 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7m_sata_ahci }, 229 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci },
231 /* Enterprise Southbridge 2 (where's the datasheet?) */ 230 /* Enterprise Southbridge 2 (where's the datasheet?) */
232 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 231 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
233 /* SATA Controller 1 IDE (ICH8, no datasheet yet) */ 232 /* SATA Controller 1 IDE (ICH8, no datasheet yet) */
@@ -399,23 +398,10 @@ static const struct piix_map_db ich6m_map_db = {
399 .mask = 0x3, 398 .mask = 0x3,
400 .port_enable = 0x5, 399 .port_enable = 0x5,
401 .present_shift = 4, 400 .present_shift = 4,
402 .map = {
403 /* PM PS SM SS MAP */
404 { P0, P2, RV, RV }, /* 00b */
405 { RV, RV, RV, RV },
406 { P0, P2, IDE, IDE }, /* 10b */
407 { RV, RV, RV, RV },
408 },
409};
410
411static const struct piix_map_db ich7m_map_db = {
412 .mask = 0x3,
413 .port_enable = 0x5,
414 .present_shift = 4,
415 401
416 /* Map 01b isn't specified in the doc but some notebooks use 402 /* Map 01b isn't specified in the doc but some notebooks use
417 * it anyway. ATM, the only case spotted carries subsystem ID 403 * it anyway. MAP 01b have been spotted on both ICH6M and
418 * 1025:0107. This is the only difference from ich6m. 404 * ICH7M.
419 */ 405 */
420 .map = { 406 .map = {
421 /* PM PS SM SS MAP */ 407 /* PM PS SM SS MAP */
@@ -432,9 +418,9 @@ static const struct piix_map_db ich8_map_db = {
432 .present_shift = 8, 418 .present_shift = 8,
433 .map = { 419 .map = {
434 /* PM PS SM SS MAP */ 420 /* PM PS SM SS MAP */
435 { P0, NA, P1, NA }, /* 00b (hardwired) */ 421 { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */
436 { RV, RV, RV, RV }, 422 { RV, RV, RV, RV },
437 { RV, RV, RV, RV }, /* 10b (never) */ 423 { IDE, IDE, NA, NA }, /* 10b (IDE mode) */
438 { RV, RV, RV, RV }, 424 { RV, RV, RV, RV },
439 }, 425 },
440}; 426};
@@ -445,7 +431,6 @@ static const struct piix_map_db *piix_map_db_table[] = {
445 [ich6_sata] = &ich6_map_db, 431 [ich6_sata] = &ich6_map_db,
446 [ich6_sata_ahci] = &ich6_map_db, 432 [ich6_sata_ahci] = &ich6_map_db,
447 [ich6m_sata_ahci] = &ich6m_map_db, 433 [ich6m_sata_ahci] = &ich6m_map_db,
448 [ich7m_sata_ahci] = &ich7m_map_db,
449 [ich8_sata_ahci] = &ich8_map_db, 434 [ich8_sata_ahci] = &ich8_map_db,
450}; 435};
451 436
@@ -556,19 +541,7 @@ static struct ata_port_info piix_port_info[] = {
556 .port_ops = &piix_sata_ops, 541 .port_ops = &piix_sata_ops,
557 }, 542 },
558 543
559 /* ich7m_sata_ahci: 10 */ 544 /* ich8_sata_ahci: 10 */
560 {
561 .sht = &piix_sht,
562 .flags = ATA_FLAG_SATA |
563 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
564 PIIX_FLAG_AHCI,
565 .pio_mask = 0x1f, /* pio0-4 */
566 .mwdma_mask = 0x07, /* mwdma0-2 */
567 .udma_mask = 0x7f, /* udma0-6 */
568 .port_ops = &piix_sata_ops,
569 },
570
571 /* ich8_sata_ahci: 11 */
572 { 545 {
573 .sht = &piix_sht, 546 .sht = &piix_sht,
574 .flags = ATA_FLAG_SATA | 547 .flags = ATA_FLAG_SATA |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 83728a9457ad..915a55a6cc14 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5957,7 +5957,7 @@ static void __exit ata_exit(void)
5957 destroy_workqueue(ata_aux_wq); 5957 destroy_workqueue(ata_aux_wq);
5958} 5958}
5959 5959
5960module_init(ata_init); 5960subsys_initcall(ata_init);
5961module_exit(ata_exit); 5961module_exit(ata_exit);
5962 5962
5963static unsigned long ratelimit_time; 5963static unsigned long ratelimit_time;
@@ -6122,7 +6122,6 @@ EXPORT_SYMBOL_GPL(ata_std_prereset);
6122EXPORT_SYMBOL_GPL(ata_std_softreset); 6122EXPORT_SYMBOL_GPL(ata_std_softreset);
6123EXPORT_SYMBOL_GPL(sata_std_hardreset); 6123EXPORT_SYMBOL_GPL(sata_std_hardreset);
6124EXPORT_SYMBOL_GPL(ata_std_postreset); 6124EXPORT_SYMBOL_GPL(ata_std_postreset);
6125EXPORT_SYMBOL_GPL(ata_dev_revalidate);
6126EXPORT_SYMBOL_GPL(ata_dev_classify); 6125EXPORT_SYMBOL_GPL(ata_dev_classify);
6127EXPORT_SYMBOL_GPL(ata_dev_pair); 6126EXPORT_SYMBOL_GPL(ata_dev_pair);
6128EXPORT_SYMBOL_GPL(ata_port_disable); 6127EXPORT_SYMBOL_GPL(ata_port_disable);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 7af2a4ba4990..47ea111d5ace 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1451,6 +1451,7 @@ nothing_to_do:
1451 1451
1452static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) 1452static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1453{ 1453{
1454 struct ata_port *ap = qc->ap;
1454 struct scsi_cmnd *cmd = qc->scsicmd; 1455 struct scsi_cmnd *cmd = qc->scsicmd;
1455 u8 *cdb = cmd->cmnd; 1456 u8 *cdb = cmd->cmnd;
1456 int need_sense = (qc->err_mask != 0); 1457 int need_sense = (qc->err_mask != 0);
@@ -1459,11 +1460,12 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1459 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE 1460 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE
1460 * cache 1461 * cache
1461 */ 1462 */
1462 if (!need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) && 1463 if (ap->ops->error_handler &&
1464 !need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) &&
1463 ((qc->tf.feature == SETFEATURES_WC_ON) || 1465 ((qc->tf.feature == SETFEATURES_WC_ON) ||
1464 (qc->tf.feature == SETFEATURES_WC_OFF))) { 1466 (qc->tf.feature == SETFEATURES_WC_OFF))) {
1465 qc->ap->eh_info.action |= ATA_EH_REVALIDATE; 1467 ap->eh_info.action |= ATA_EH_REVALIDATE;
1466 ata_port_schedule_eh(qc->ap); 1468 ata_port_schedule_eh(ap);
1467 } 1469 }
1468 1470
1469 /* For ATA pass thru (SAT) commands, generate a sense block if 1471 /* For ATA pass thru (SAT) commands, generate a sense block if
@@ -1490,8 +1492,8 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1490 } 1492 }
1491 } 1493 }
1492 1494
1493 if (need_sense && !qc->ap->ops->error_handler) 1495 if (need_sense && !ap->ops->error_handler)
1494 ata_dump_status(qc->ap->id, &qc->result_tf); 1496 ata_dump_status(ap->id, &qc->result_tf);
1495 1497
1496 qc->scsidone(cmd); 1498 qc->scsidone(cmd);
1497 1499
@@ -1612,9 +1614,9 @@ early_finish:
1612 1614
1613err_did: 1615err_did:
1614 ata_qc_free(qc); 1616 ata_qc_free(qc);
1615err_mem:
1616 cmd->result = (DID_ERROR << 16); 1617 cmd->result = (DID_ERROR << 16);
1617 done(cmd); 1618 done(cmd);
1619err_mem:
1618 DPRINTK("EXIT - internal\n"); 1620 DPRINTK("EXIT - internal\n");
1619 return 0; 1621 return 0;
1620 1622
@@ -3345,20 +3347,23 @@ EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
3345 * @ap: ATA port to which the command is being sent 3347 * @ap: ATA port to which the command is being sent
3346 * 3348 *
3347 * RETURNS: 3349 * RETURNS:
3348 * Zero. 3350 * Return value from __ata_scsi_queuecmd() if @cmd can be queued,
3351 * 0 otherwise.
3349 */ 3352 */
3350 3353
3351int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), 3354int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
3352 struct ata_port *ap) 3355 struct ata_port *ap)
3353{ 3356{
3357 int rc = 0;
3358
3354 ata_scsi_dump_cdb(ap, cmd); 3359 ata_scsi_dump_cdb(ap, cmd);
3355 3360
3356 if (likely(ata_scsi_dev_enabled(ap->device))) 3361 if (likely(ata_scsi_dev_enabled(ap->device)))
3357 __ata_scsi_queuecmd(cmd, done, ap->device); 3362 rc = __ata_scsi_queuecmd(cmd, done, ap->device);
3358 else { 3363 else {
3359 cmd->result = (DID_BAD_TARGET << 16); 3364 cmd->result = (DID_BAD_TARGET << 16);
3360 done(cmd); 3365 done(cmd);
3361 } 3366 }
3362 return 0; 3367 return rc;
3363} 3368}
3364EXPORT_SYMBOL_GPL(ata_sas_queuecmd); 3369EXPORT_SYMBOL_GPL(ata_sas_queuecmd);
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 06daaa3736a2..7645f2b30ccf 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -981,6 +981,15 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
981 mask = (1 << 2) | (1 << 0); 981 mask = (1 << 2) | (1 << 0);
982 if ((tmp8 & mask) != mask) 982 if ((tmp8 & mask) != mask)
983 legacy_mode = (1 << 3); 983 legacy_mode = (1 << 3);
984#if defined(CONFIG_NO_ATA_LEGACY)
985 /* Some platforms with PCI limits cannot address compat
986 port space. In that case we punt if their firmware has
987 left a device in compatibility mode */
988 if (legacy_mode) {
989 printk(KERN_ERR "ata: Compatibility mode ATA is not supported on this platform, skipping.\n");
990 return -EOPNOTSUPP;
991 }
992#endif
984 } 993 }
985 994
986 rc = pci_request_regions(pdev, DRV_NAME); 995 rc = pci_request_regions(pdev, DRV_NAME);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index a5ecb71390a9..0ed263be652a 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -53,6 +53,7 @@ extern unsigned ata_exec_internal(struct ata_device *dev,
53extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); 53extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
54extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 54extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
55 int post_reset, u16 *id); 55 int post_reset, u16 *id);
56extern int ata_dev_revalidate(struct ata_device *dev, int post_reset);
56extern int ata_dev_configure(struct ata_device *dev, int print_info); 57extern int ata_dev_configure(struct ata_device *dev, int print_info);
57extern int sata_down_spd_limit(struct ata_port *ap); 58extern int sata_down_spd_limit(struct ata_port *ap);
58extern int sata_set_spd_needed(struct ata_port *ap); 59extern int sata_set_spd_needed(struct ata_port *ap);
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 29234c897118..5c47a9e0e0ca 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -677,6 +677,8 @@ static const struct pci_device_id amd[] = {
677 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 8 }, 677 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 8 },
678 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 8 }, 678 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 8 },
679 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 8 }, 679 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 8 },
680 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 8 },
681 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 8 },
680 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 9 }, 682 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 9 },
681 683
682 { }, 684 { },
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 690828eb5226..96a098020a8f 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -92,7 +92,7 @@ static int artop6260_pre_reset(struct ata_port *ap)
92 return -ENOENT; 92 return -ENOENT;
93 93
94 pci_read_config_byte(pdev, 0x49, &tmp); 94 pci_read_config_byte(pdev, 0x49, &tmp);
95 if (tmp & (1 >> ap->port_no)) 95 if (tmp & (1 << ap->port_no))
96 ap->cbl = ATA_CBL_PATA40; 96 ap->cbl = ATA_CBL_PATA40;
97 else 97 else
98 ap->cbl = ATA_CBL_PATA80; 98 ap->cbl = ATA_CBL_PATA80;
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 7350443948c1..fce3fcdc7e79 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt37x" 27#define DRV_NAME "pata_hpt37x"
28#define DRV_VERSION "0.5" 28#define DRV_VERSION "0.5.1"
29 29
30struct hpt_clock { 30struct hpt_clock {
31 u8 xfer_speed; 31 u8 xfer_speed;
@@ -453,7 +453,13 @@ static int hpt37x_pre_reset(struct ata_port *ap)
453{ 453{
454 u8 scr2, ata66; 454 u8 scr2, ata66;
455 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 455 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
456 456 static const struct pci_bits hpt37x_enable_bits[] = {
457 { 0x50, 1, 0x04, 0x04 },
458 { 0x54, 1, 0x04, 0x04 }
459 };
460 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
461 return -ENOENT;
462
457 pci_read_config_byte(pdev, 0x5B, &scr2); 463 pci_read_config_byte(pdev, 0x5B, &scr2);
458 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01); 464 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01);
459 /* Cable register now active */ 465 /* Cable register now active */
@@ -488,10 +494,17 @@ static void hpt37x_error_handler(struct ata_port *ap)
488 494
489static int hpt374_pre_reset(struct ata_port *ap) 495static int hpt374_pre_reset(struct ata_port *ap)
490{ 496{
497 static const struct pci_bits hpt37x_enable_bits[] = {
498 { 0x50, 1, 0x04, 0x04 },
499 { 0x54, 1, 0x04, 0x04 }
500 };
491 u16 mcr3, mcr6; 501 u16 mcr3, mcr6;
492 u8 ata66; 502 u8 ata66;
493
494 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 503 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
504
505 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
506 return -ENOENT;
507
495 /* Do the extra channel work */ 508 /* Do the extra channel work */
496 pci_read_config_word(pdev, 0x52, &mcr3); 509 pci_read_config_word(pdev, 0x52, &mcr3);
497 pci_read_config_word(pdev, 0x56, &mcr6); 510 pci_read_config_word(pdev, 0x56, &mcr6);
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 323b60710806..d65ebfd7c7b2 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -117,10 +117,14 @@ static const struct pci_device_id nv_pci_tbl[] = {
117 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, 117 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC },
118 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, 118 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC },
119 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, 119 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC },
120 { PCI_VDEVICE(NVIDIA, 0x045c), GENERIC }, 120 { PCI_VDEVICE(NVIDIA, 0x045c), GENERIC }, /* MCP65 */
121 { PCI_VDEVICE(NVIDIA, 0x045d), GENERIC }, 121 { PCI_VDEVICE(NVIDIA, 0x045d), GENERIC }, /* MCP65 */
122 { PCI_VDEVICE(NVIDIA, 0x045e), GENERIC }, 122 { PCI_VDEVICE(NVIDIA, 0x045e), GENERIC }, /* MCP65 */
123 { PCI_VDEVICE(NVIDIA, 0x045f), GENERIC }, 123 { PCI_VDEVICE(NVIDIA, 0x045f), GENERIC }, /* MCP65 */
124 { PCI_VDEVICE(NVIDIA, 0x0550), GENERIC }, /* MCP67 */
125 { PCI_VDEVICE(NVIDIA, 0x0551), GENERIC }, /* MCP67 */
126 { PCI_VDEVICE(NVIDIA, 0x0552), GENERIC }, /* MCP67 */
127 { PCI_VDEVICE(NVIDIA, 0x0553), GENERIC }, /* MCP67 */
124 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 128 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
125 PCI_ANY_ID, PCI_ANY_ID, 129 PCI_ANY_ID, PCI_ANY_ID,
126 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC }, 130 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index 0738f52463a9..9d1235ba06b1 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -240,7 +240,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
240 struct ata_probe_ent *probe_ent = NULL; 240 struct ata_probe_ent *probe_ent = NULL;
241 int rc; 241 int rc;
242 u32 genctl; 242 u32 genctl;
243 struct ata_port_info *ppi[2]; 243 struct ata_port_info pi = sis_port_info, *ppi[2] = { &pi, &pi };
244 int pci_dev_busy = 0; 244 int pci_dev_busy = 0;
245 u8 pmr; 245 u8 pmr;
246 u8 port2_start; 246 u8 port2_start;
@@ -265,27 +265,20 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
265 if (rc) 265 if (rc)
266 goto err_out_regions; 266 goto err_out_regions;
267 267
268 ppi[0] = ppi[1] = &sis_port_info;
269 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
270 if (!probe_ent) {
271 rc = -ENOMEM;
272 goto err_out_regions;
273 }
274
275 /* check and see if the SCRs are in IO space or PCI cfg space */ 268 /* check and see if the SCRs are in IO space or PCI cfg space */
276 pci_read_config_dword(pdev, SIS_GENCTL, &genctl); 269 pci_read_config_dword(pdev, SIS_GENCTL, &genctl);
277 if ((genctl & GENCTL_IOMAPPED_SCR) == 0) 270 if ((genctl & GENCTL_IOMAPPED_SCR) == 0)
278 probe_ent->port_flags |= SIS_FLAG_CFGSCR; 271 pi.flags |= SIS_FLAG_CFGSCR;
279 272
280 /* if hardware thinks SCRs are in IO space, but there are 273 /* if hardware thinks SCRs are in IO space, but there are
281 * no IO resources assigned, change to PCI cfg space. 274 * no IO resources assigned, change to PCI cfg space.
282 */ 275 */
283 if ((!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) && 276 if ((!(pi.flags & SIS_FLAG_CFGSCR)) &&
284 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) || 277 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) ||
285 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) { 278 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) {
286 genctl &= ~GENCTL_IOMAPPED_SCR; 279 genctl &= ~GENCTL_IOMAPPED_SCR;
287 pci_write_config_dword(pdev, SIS_GENCTL, genctl); 280 pci_write_config_dword(pdev, SIS_GENCTL, genctl);
288 probe_ent->port_flags |= SIS_FLAG_CFGSCR; 281 pi.flags |= SIS_FLAG_CFGSCR;
289 } 282 }
290 283
291 pci_read_config_byte(pdev, SIS_PMR, &pmr); 284 pci_read_config_byte(pdev, SIS_PMR, &pmr);
@@ -306,6 +299,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
306 port2_start = 0x20; 299 port2_start = 0x20;
307 } 300 }
308 301
302 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
303 if (!probe_ent) {
304 rc = -ENOMEM;
305 goto err_out_regions;
306 }
307
309 if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) { 308 if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) {
310 probe_ent->port[0].scr_addr = 309 probe_ent->port[0].scr_addr =
311 pci_resource_start(pdev, SIS_SCR_PCI_BAR); 310 pci_resource_start(pdev, SIS_SCR_PCI_BAR);
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index f4455a1efe2d..1c7f19aecc25 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -230,7 +230,7 @@ static int vt6420_prereset(struct ata_port *ap)
230 int online; 230 int online;
231 231
232 /* don't do any SCR stuff if we're not loading */ 232 /* don't do any SCR stuff if we're not loading */
233 if (!ATA_PFLAG_LOADING) 233 if (!(ap->pflags & ATA_PFLAG_LOADING))
234 goto skip_scr; 234 goto skip_scr;
235 235
236 /* Resume phy. This is the old resume sequence from 236 /* Resume phy. This is the old resume sequence from
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 323592de047b..9fffa7af6db1 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -2452,8 +2452,8 @@ static int __init amb_module_init (void)
2452static void __exit amb_module_exit (void) 2452static void __exit amb_module_exit (void)
2453{ 2453{
2454 PRINTD (DBG_FLOW|DBG_INIT, "cleanup_module"); 2454 PRINTD (DBG_FLOW|DBG_INIT, "cleanup_module");
2455 2455
2456 return pci_unregister_driver(&amb_driver); 2456 pci_unregister_driver(&amb_driver);
2457} 2457}
2458 2458
2459module_init(amb_module_init); 2459module_init(amb_module_init);
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 40ab9b65fae9..697ad82f6634 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1002,6 +1002,10 @@ static int fs_open(struct atm_vcc *atm_vcc)
1002 r = ROUND_UP; 1002 r = ROUND_UP;
1003 } 1003 }
1004 error = make_rate (pcr, r, &tmc0, NULL); 1004 error = make_rate (pcr, r, &tmc0, NULL);
1005 if (error) {
1006 kfree(tc);
1007 return error;
1008 }
1005 } 1009 }
1006 fs_dprintk (FS_DEBUG_OPEN, "pcr = %d.\n", pcr); 1010 fs_dprintk (FS_DEBUG_OPEN, "pcr = %d.\n", pcr);
1007 } 1011 }
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index f59349206dd2..4dc10105d610 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -1789,7 +1789,7 @@ static inline void CLOCK_IT (const hrz_dev *dev, u32 ctrl)
1789 WRITE_IT_WAIT(dev, ctrl | SEEPROM_SK); 1789 WRITE_IT_WAIT(dev, ctrl | SEEPROM_SK);
1790} 1790}
1791 1791
1792static u16 __init read_bia (const hrz_dev * dev, u16 addr) 1792static u16 __devinit read_bia (const hrz_dev * dev, u16 addr)
1793{ 1793{
1794 u32 ctrl = rd_regl (dev, CONTROL_0_REG); 1794 u32 ctrl = rd_regl (dev, CONTROL_0_REG);
1795 1795
@@ -2932,8 +2932,8 @@ static int __init hrz_module_init (void) {
2932 2932
2933static void __exit hrz_module_exit (void) { 2933static void __exit hrz_module_exit (void) {
2934 PRINTD (DBG_FLOW, "cleanup_module"); 2934 PRINTD (DBG_FLOW, "cleanup_module");
2935 2935
2936 return pci_unregister_driver(&hrz_driver); 2936 pci_unregister_driver(&hrz_driver);
2937} 2937}
2938 2938
2939module_init(hrz_module_init); 2939module_init(hrz_module_init);
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 632ede552761..bd0904594805 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -2759,7 +2759,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2759{ 2759{
2760 ns_dev *card; 2760 ns_dev *card;
2761 pool_levels pl; 2761 pool_levels pl;
2762 int btype; 2762 long btype;
2763 unsigned long flags; 2763 unsigned long flags;
2764 2764
2765 card = dev->dev_data; 2765 card = dev->dev_data;
@@ -2859,7 +2859,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2859 case NS_ADJBUFLEV: 2859 case NS_ADJBUFLEV:
2860 if (!capable(CAP_NET_ADMIN)) 2860 if (!capable(CAP_NET_ADMIN))
2861 return -EPERM; 2861 return -EPERM;
2862 btype = (int) arg; /* an int is the same size as a pointer */ 2862 btype = (long) arg; /* a long is the same size as a pointer or bigger */
2863 switch (btype) 2863 switch (btype)
2864 { 2864 {
2865 case NS_BUFTYPE_SMALL: 2865 case NS_BUFTYPE_SMALL:
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 0b4e22436935..1429f3a2629e 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -37,8 +37,8 @@ config DEBUG_DRIVER
37 37
38 If you are unsure about this, say N here. 38 If you are unsure about this, say N here.
39 39
40endmenu
41
42config SYS_HYPERVISOR 40config SYS_HYPERVISOR
43 bool 41 bool
44 default n 42 default n
43
44endmenu
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 68ad11af22b4..002fde46d38d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -591,8 +591,10 @@ void device_del(struct device * dev)
591 591
592 if (parent) 592 if (parent)
593 klist_del(&dev->knode_parent); 593 klist_del(&dev->knode_parent);
594 if (dev->devt_attr) 594 if (dev->devt_attr) {
595 device_remove_file(dev, dev->devt_attr); 595 device_remove_file(dev, dev->devt_attr);
596 kfree(dev->devt_attr);
597 }
596 if (dev->class) { 598 if (dev->class) {
597 sysfs_remove_link(&dev->kobj, "subsystem"); 599 sysfs_remove_link(&dev->kobj, "subsystem");
598 sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); 600 sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index db01b95a47a5..c5d6bb4290ad 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -18,6 +18,7 @@
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kthread.h> 20#include <linux/kthread.h>
21#include <linux/wait.h>
21 22
22#include "base.h" 23#include "base.h"
23#include "power/power.h" 24#include "power/power.h"
@@ -70,6 +71,8 @@ struct stupid_thread_structure {
70}; 71};
71 72
72static atomic_t probe_count = ATOMIC_INIT(0); 73static atomic_t probe_count = ATOMIC_INIT(0);
74static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue);
75
73static int really_probe(void *void_data) 76static int really_probe(void *void_data)
74{ 77{
75 struct stupid_thread_structure *data = void_data; 78 struct stupid_thread_structure *data = void_data;
@@ -121,6 +124,7 @@ probe_failed:
121done: 124done:
122 kfree(data); 125 kfree(data);
123 atomic_dec(&probe_count); 126 atomic_dec(&probe_count);
127 wake_up(&probe_waitqueue);
124 return ret; 128 return ret;
125} 129}
126 130
@@ -337,6 +341,32 @@ void driver_detach(struct device_driver * drv)
337 } 341 }
338} 342}
339 343
344#ifdef CONFIG_PCI_MULTITHREAD_PROBE
345static int __init wait_for_probes(void)
346{
347 DEFINE_WAIT(wait);
348
349 printk(KERN_INFO "%s: waiting for %d threads\n", __FUNCTION__,
350 atomic_read(&probe_count));
351 if (!atomic_read(&probe_count))
352 return 0;
353 while (atomic_read(&probe_count)) {
354 prepare_to_wait(&probe_waitqueue, &wait, TASK_UNINTERRUPTIBLE);
355 if (atomic_read(&probe_count))
356 schedule();
357 }
358 finish_wait(&probe_waitqueue, &wait);
359 return 0;
360}
361
362core_initcall_sync(wait_for_probes);
363postcore_initcall_sync(wait_for_probes);
364arch_initcall_sync(wait_for_probes);
365subsys_initcall_sync(wait_for_probes);
366fs_initcall_sync(wait_for_probes);
367device_initcall_sync(wait_for_probes);
368late_initcall_sync(wait_for_probes);
369#endif
340 370
341EXPORT_SYMBOL_GPL(device_bind_driver); 371EXPORT_SYMBOL_GPL(device_bind_driver);
342EXPORT_SYMBOL_GPL(device_release_driver); 372EXPORT_SYMBOL_GPL(device_release_driver);
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index d433f27e0ce2..aa25f8b09fe3 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -68,6 +68,7 @@ static struct attribute *aoe_attrs[] = {
68 &disk_attr_mac.attr, 68 &disk_attr_mac.attr,
69 &disk_attr_netif.attr, 69 &disk_attr_netif.attr,
70 &disk_attr_fwver.attr, 70 &disk_attr_fwver.attr,
71 NULL
71}; 72};
72 73
73static const struct attribute_group attr_group = { 74static const struct attribute_group attr_group = {
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index dcccaf2782f3..4105c3bf3476 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1300,6 +1300,12 @@ static void cciss_softirq_done(struct request *rq)
1300 1300
1301 complete_buffers(rq->bio, rq->errors); 1301 complete_buffers(rq->bio, rq->errors);
1302 1302
1303 if (blk_fs_request(rq)) {
1304 const int rw = rq_data_dir(rq);
1305
1306 disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
1307 }
1308
1303#ifdef CCISS_DEBUG 1309#ifdef CCISS_DEBUG
1304 printk("Done with %p\n", rq); 1310 printk("Done with %p\n", rq);
1305#endif /* CCISS_DEBUG */ 1311#endif /* CCISS_DEBUG */
@@ -1923,7 +1929,6 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
1923{ 1929{
1924 int return_code; 1930 int return_code;
1925 unsigned long t; 1931 unsigned long t;
1926 unsigned long rem;
1927 1932
1928 memset(inq_buff, 0, sizeof(InquiryData_struct)); 1933 memset(inq_buff, 0, sizeof(InquiryData_struct));
1929 if (withirq) 1934 if (withirq)
@@ -1939,26 +1944,23 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
1939 printk(KERN_WARNING 1944 printk(KERN_WARNING
1940 "cciss: reading geometry failed, volume " 1945 "cciss: reading geometry failed, volume "
1941 "does not support reading geometry\n"); 1946 "does not support reading geometry\n");
1942 drv->block_size = block_size;
1943 drv->nr_blocks = total_size;
1944 drv->heads = 255; 1947 drv->heads = 255;
1945 drv->sectors = 32; // Sectors per track 1948 drv->sectors = 32; // Sectors per track
1946 t = drv->heads * drv->sectors;
1947 drv->cylinders = total_size;
1948 rem = do_div(drv->cylinders, t);
1949 } else { 1949 } else {
1950 drv->block_size = block_size;
1951 drv->nr_blocks = total_size;
1952 drv->heads = inq_buff->data_byte[6]; 1950 drv->heads = inq_buff->data_byte[6];
1953 drv->sectors = inq_buff->data_byte[7]; 1951 drv->sectors = inq_buff->data_byte[7];
1954 drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8; 1952 drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8;
1955 drv->cylinders += inq_buff->data_byte[5]; 1953 drv->cylinders += inq_buff->data_byte[5];
1956 drv->raid_level = inq_buff->data_byte[8]; 1954 drv->raid_level = inq_buff->data_byte[8];
1957 t = drv->heads * drv->sectors; 1955 }
1958 if (t > 1) { 1956 drv->block_size = block_size;
1959 drv->cylinders = total_size; 1957 drv->nr_blocks = total_size;
1960 rem = do_div(drv->cylinders, t); 1958 t = drv->heads * drv->sectors;
1961 } 1959 if (t > 1) {
1960 unsigned rem = sector_div(total_size, t);
1961 if (rem)
1962 total_size++;
1963 drv->cylinders = total_size;
1962 } 1964 }
1963 } else { /* Get geometry failed */ 1965 } else { /* Get geometry failed */
1964 printk(KERN_WARNING "cciss: reading geometry failed\n"); 1966 printk(KERN_WARNING "cciss: reading geometry failed\n");
@@ -1996,8 +1998,8 @@ cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size,
1996 *block_size = BLOCK_SIZE; 1998 *block_size = BLOCK_SIZE;
1997 } 1999 }
1998 if (*total_size != (__u32) 0) 2000 if (*total_size != (__u32) 0)
1999 printk(KERN_INFO " blocks= %lld block_size= %d\n", 2001 printk(KERN_INFO " blocks= %llu block_size= %d\n",
2000 *total_size, *block_size); 2002 (unsigned long long)*total_size, *block_size);
2001 kfree(buf); 2003 kfree(buf);
2002 return; 2004 return;
2003} 2005}
@@ -2031,8 +2033,8 @@ cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size,
2031 *total_size = 0; 2033 *total_size = 0;
2032 *block_size = BLOCK_SIZE; 2034 *block_size = BLOCK_SIZE;
2033 } 2035 }
2034 printk(KERN_INFO " blocks= %lld block_size= %d\n", 2036 printk(KERN_INFO " blocks= %llu block_size= %d\n",
2035 *total_size, *block_size); 2037 (unsigned long long)*total_size, *block_size);
2036 kfree(buf); 2038 kfree(buf);
2037 return; 2039 return;
2038} 2040}
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 570d2f049323..d5f519ebbc08 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -998,6 +998,7 @@ static inline void complete_buffers(struct bio *bio, int ok)
998 */ 998 */
999static inline void complete_command(cmdlist_t *cmd, int timeout) 999static inline void complete_command(cmdlist_t *cmd, int timeout)
1000{ 1000{
1001 struct request *rq = cmd->rq;
1001 int ok=1; 1002 int ok=1;
1002 int i, ddir; 1003 int i, ddir;
1003 1004
@@ -1029,12 +1030,18 @@ static inline void complete_command(cmdlist_t *cmd, int timeout)
1029 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr, 1030 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr,
1030 cmd->req.sg[i].size, ddir); 1031 cmd->req.sg[i].size, ddir);
1031 1032
1032 complete_buffers(cmd->rq->bio, ok); 1033 complete_buffers(rq->bio, ok);
1033 1034
1034 add_disk_randomness(cmd->rq->rq_disk); 1035 if (blk_fs_request(rq)) {
1036 const int rw = rq_data_dir(rq);
1035 1037
1036 DBGPX(printk("Done with %p\n", cmd->rq);); 1038 disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
1037 end_that_request_last(cmd->rq, ok ? 1 : -EIO); 1039 }
1040
1041 add_disk_randomness(rq->rq_disk);
1042
1043 DBGPX(printk("Done with %p\n", rq););
1044 end_that_request_last(rq, ok ? 1 : -EIO);
1038} 1045}
1039 1046
1040/* 1047/*
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 845b8680032a..cbc07250b898 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -282,7 +282,7 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
282 clear_bit(ready_bit, &(info->tx_state)); 282 clear_bit(ready_bit, &(info->tx_state));
283 283
284 if (bt_cb(skb)->pkt_type & 0x80) { 284 if (bt_cb(skb)->pkt_type & 0x80) {
285 DECLARE_WAIT_QUEUE_HEAD(wq); 285 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
286 DEFINE_WAIT(wait); 286 DEFINE_WAIT(wait);
287 287
288 unsigned char baud_reg; 288 unsigned char baud_reg;
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 39a9f8cc6412..2af12fc45115 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -409,14 +409,6 @@ config SGI_MBCS
409 If you have an SGI Altix with an attached SABrick 409 If you have an SGI Altix with an attached SABrick
410 say Y or M here, otherwise say N. 410 say Y or M here, otherwise say N.
411 411
412config MSPEC
413 tristate "Memory special operations driver"
414 depends on IA64
415 help
416 If you have an ia64 and you want to enable memory special
417 operations support (formerly known as fetchop), say Y here,
418 otherwise say N.
419
420source "drivers/serial/Kconfig" 412source "drivers/serial/Kconfig"
421 413
422config UNIX98_PTYS 414config UNIX98_PTYS
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index c39200161688..5ff457b41efb 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1054,7 +1054,7 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
1054{ 1054{
1055 struct page * page; 1055 struct page * page;
1056 1056
1057 page = alloc_page(GFP_KERNEL); 1057 page = alloc_page(GFP_KERNEL | GFP_DMA32);
1058 if (page == NULL) 1058 if (page == NULL)
1059 return NULL; 1059 return NULL;
1060 1060
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index d1ede7db5a12..555b3a8ab49c 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -169,7 +169,7 @@ static void *i8xx_alloc_pages(void)
169{ 169{
170 struct page * page; 170 struct page * page;
171 171
172 page = alloc_pages(GFP_KERNEL, 2); 172 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
173 if (page == NULL) 173 if (page == NULL)
174 return NULL; 174 return NULL;
175 175
@@ -387,11 +387,7 @@ static void intel_i830_init_gtt_entries(void)
387 /* We obtain the size of the GTT, which is also stored (for some 387 /* We obtain the size of the GTT, which is also stored (for some
388 * reason) at the top of stolen memory. Then we add 4KB to that 388 * reason) at the top of stolen memory. Then we add 4KB to that
389 * for the video BIOS popup, which is also stored in there. */ 389 * for the video BIOS popup, which is also stored in there. */
390 390 size = agp_bridge->driver->fetch_size() + 4;
391 if (IS_I965)
392 size = 512 + 4;
393 else
394 size = agp_bridge->driver->fetch_size() + 4;
395 391
396 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB || 392 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
397 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { 393 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
@@ -805,6 +801,26 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
805 801
806 return 0; 802 return 0;
807} 803}
804
805/*
806 * The i965 supports 36-bit physical addresses, but to keep
807 * the format of the GTT the same, the bits that don't fit
808 * in a 32-bit word are shifted down to bits 4..7.
809 *
810 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
811 * is always zero on 32-bit architectures, so no need to make
812 * this conditional.
813 */
814static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
815 unsigned long addr, int type)
816{
817 /* Shift high bits down */
818 addr |= (addr >> 28) & 0xf0;
819
820 /* Type checking must be done elsewhere */
821 return addr | bridge->driver->masks[type].mask;
822}
823
808static int intel_i965_fetch_size(void) 824static int intel_i965_fetch_size(void)
809{ 825{
810 struct aper_size_info_fixed *values; 826 struct aper_size_info_fixed *values;
@@ -832,7 +848,8 @@ static int intel_i965_fetch_size(void)
832 848
833 agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset); 849 agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset);
834 850
835 return values[offset].size; 851 /* The i965 GTT is always sized as if it had a 512kB aperture size */
852 return 512;
836} 853}
837 854
838/* The intel i965 automatically initializes the agp aperture during POST. 855/* The intel i965 automatically initializes the agp aperture during POST.
@@ -1584,7 +1601,7 @@ static struct agp_bridge_driver intel_i965_driver = {
1584 .fetch_size = intel_i965_fetch_size, 1601 .fetch_size = intel_i965_fetch_size,
1585 .cleanup = intel_i915_cleanup, 1602 .cleanup = intel_i915_cleanup,
1586 .tlb_flush = intel_i810_tlbflush, 1603 .tlb_flush = intel_i810_tlbflush,
1587 .mask_memory = intel_i810_mask_memory, 1604 .mask_memory = intel_i965_mask_memory,
1588 .masks = intel_i810_masks, 1605 .masks = intel_i810_masks,
1589 .agp_enable = intel_i810_agp_enable, 1606 .agp_enable = intel_i810_agp_enable,
1590 .cache_flush = global_cache_flush, 1607 .cache_flush = global_cache_flush,
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 91b71e750ee1..dffc19382f7e 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -27,32 +27,42 @@
27static int uninorth_rev; 27static int uninorth_rev;
28static int is_u3; 28static int is_u3;
29 29
30static char __devinitdata *aperture = NULL;
30 31
31static int uninorth_fetch_size(void) 32static int uninorth_fetch_size(void)
32{ 33{
33 int i; 34 int i, size = 0;
34 u32 temp; 35 struct aper_size_info_32 *values =
35 struct aper_size_info_32 *values; 36 A_SIZE_32(agp_bridge->driver->aperture_sizes);
36 37
37 pci_read_config_dword(agp_bridge->dev, UNI_N_CFG_GART_BASE, &temp); 38 if (aperture) {
38 temp &= ~(0xfffff000); 39 char *save = aperture;
39 values = A_SIZE_32(agp_bridge->driver->aperture_sizes); 40
40 41 size = memparse(aperture, &aperture) >> 20;
41 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { 42 aperture = save;
42 if (temp == values[i].size_value) { 43
43 agp_bridge->previous_size = 44 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++)
44 agp_bridge->current_size = (void *) (values + i); 45 if (size == values[i].size)
45 agp_bridge->aperture_size_idx = i; 46 break;
46 return values[i].size; 47
48 if (i == agp_bridge->driver->num_aperture_sizes) {
49 printk(KERN_ERR PFX "Invalid aperture size, using"
50 " default\n");
51 size = 0;
52 aperture = NULL;
47 } 53 }
48 } 54 }
49 55
50 agp_bridge->previous_size = 56 if (!size) {
51 agp_bridge->current_size = (void *) (values + 1); 57 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++)
52 agp_bridge->aperture_size_idx = 1; 58 if (values[i].size == 32)
53 return values[1].size; 59 break;
60 }
54 61
55 return 0; 62 agp_bridge->previous_size =
63 agp_bridge->current_size = (void *)(values + i);
64 agp_bridge->aperture_size_idx = i;
65 return values[i].size;
56} 66}
57 67
58static void uninorth_tlbflush(struct agp_memory *mem) 68static void uninorth_tlbflush(struct agp_memory *mem)
@@ -683,5 +693,11 @@ static void __exit agp_uninorth_cleanup(void)
683module_init(agp_uninorth_init); 693module_init(agp_uninorth_init);
684module_exit(agp_uninorth_cleanup); 694module_exit(agp_uninorth_cleanup);
685 695
696module_param(aperture, charp, 0);
697MODULE_PARM_DESC(aperture,
698 "Aperture size, must be power of two between 4MB and an\n"
699 "\t\tupper limit specific to the UniNorth revision.\n"
700 "\t\tDefault: 32M");
701
686MODULE_AUTHOR("Ben Herrenschmidt & Paul Mackerras"); 702MODULE_AUTHOR("Ben Herrenschmidt & Paul Mackerras");
687MODULE_LICENSE("GPL"); 703MODULE_LICENSE("GPL");
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 029baea33b62..6eafff13dab6 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -237,6 +237,8 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
237 237
238 list = drm_alloc(sizeof(*list), DRM_MEM_MAPS); 238 list = drm_alloc(sizeof(*list), DRM_MEM_MAPS);
239 if (!list) { 239 if (!list) {
240 if (map->type == _DRM_REGISTERS)
241 drm_ioremapfree(map->handle, map->size, dev);
240 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 242 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
241 return -EINVAL; 243 return -EINVAL;
242 } 244 }
@@ -252,6 +254,8 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
252 map->offset; 254 map->offset;
253 ret = drm_map_handle(dev, &list->hash, user_token, 0); 255 ret = drm_map_handle(dev, &list->hash, user_token, 0);
254 if (ret) { 256 if (ret) {
257 if (map->type == _DRM_REGISTERS)
258 drm_ioremapfree(map->handle, map->size, dev);
255 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 259 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
256 drm_free(list, sizeof(*list), DRM_MEM_MAPS); 260 drm_free(list, sizeof(*list), DRM_MEM_MAPS);
257 mutex_unlock(&dev->struct_mutex); 261 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/char/drm/drm_sysfs.c b/drivers/char/drm/drm_sysfs.c
index 51ad98c685c3..ba4b8de83cf0 100644
--- a/drivers/char/drm/drm_sysfs.c
+++ b/drivers/char/drm/drm_sysfs.c
@@ -42,13 +42,24 @@ static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
42struct class *drm_sysfs_create(struct module *owner, char *name) 42struct class *drm_sysfs_create(struct module *owner, char *name)
43{ 43{
44 struct class *class; 44 struct class *class;
45 int err;
45 46
46 class = class_create(owner, name); 47 class = class_create(owner, name);
47 if (!class) 48 if (!class) {
48 return class; 49 err = -ENOMEM;
50 goto err_out;
51 }
52
53 err = class_create_file(class, &class_attr_version);
54 if (err)
55 goto err_out_class;
49 56
50 class_create_file(class, &class_attr_version);
51 return class; 57 return class;
58
59err_out_class:
60 class_destroy(class);
61err_out:
62 return ERR_PTR(err);
52} 63}
53 64
54/** 65/**
@@ -96,20 +107,36 @@ static struct class_device_attribute class_device_attrs[] = {
96struct class_device *drm_sysfs_device_add(struct class *cs, drm_head_t *head) 107struct class_device *drm_sysfs_device_add(struct class *cs, drm_head_t *head)
97{ 108{
98 struct class_device *class_dev; 109 struct class_device *class_dev;
99 int i; 110 int i, j, err;
100 111
101 class_dev = class_device_create(cs, NULL, 112 class_dev = class_device_create(cs, NULL,
102 MKDEV(DRM_MAJOR, head->minor), 113 MKDEV(DRM_MAJOR, head->minor),
103 &(head->dev->pdev)->dev, 114 &(head->dev->pdev)->dev,
104 "card%d", head->minor); 115 "card%d", head->minor);
105 if (!class_dev) 116 if (!class_dev) {
106 return NULL; 117 err = -ENOMEM;
118 goto err_out;
119 }
107 120
108 class_set_devdata(class_dev, head); 121 class_set_devdata(class_dev, head);
109 122
110 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 123 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
111 class_device_create_file(class_dev, &class_device_attrs[i]); 124 err = class_device_create_file(class_dev,
125 &class_device_attrs[i]);
126 if (err)
127 goto err_out_files;
128 }
129
112 return class_dev; 130 return class_dev;
131
132err_out_files:
133 if (i > 0)
134 for (j = 0; j < i; j++)
135 class_device_remove_file(class_dev,
136 &class_device_attrs[i]);
137 class_device_unregister(class_dev);
138err_out:
139 return ERR_PTR(err);
113} 140}
114 141
115/** 142/**
diff --git a/drivers/char/drm/mga_drv.c b/drivers/char/drm/mga_drv.c
index e30f556b79f1..be49dbb9ec3f 100644
--- a/drivers/char/drm/mga_drv.c
+++ b/drivers/char/drm/mga_drv.c
@@ -47,6 +47,7 @@ static struct drm_driver driver = {
47 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | 47 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
48 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | 48 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
49 DRIVER_IRQ_VBL, 49 DRIVER_IRQ_VBL,
50 .dev_priv_size = sizeof(drm_mga_buf_priv_t),
50 .load = mga_driver_load, 51 .load = mga_driver_load,
51 .unload = mga_driver_unload, 52 .unload = mga_driver_unload,
52 .lastclose = mga_driver_lastclose, 53 .lastclose = mga_driver_lastclose,
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c
index 26bdf2ca59d7..d14477ba3679 100644
--- a/drivers/char/drm/r300_cmdbuf.c
+++ b/drivers/char/drm/r300_cmdbuf.c
@@ -538,6 +538,36 @@ static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv,
538 return 0; 538 return 0;
539} 539}
540 540
541static __inline__ int r300_emit_indx_buffer(drm_radeon_private_t *dev_priv,
542 drm_radeon_kcmd_buffer_t *cmdbuf)
543{
544 u32 *cmd = (u32 *) cmdbuf->buf;
545 int count, ret;
546 RING_LOCALS;
547
548 count=(cmd[0]>>16) & 0x3fff;
549
550 if ((cmd[1] & 0x8000ffff) != 0x80000810) {
551 DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]);
552 return DRM_ERR(EINVAL);
553 }
554 ret = r300_check_offset(dev_priv, cmd[2]);
555 if (ret) {
556 DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]);
557 return DRM_ERR(EINVAL);
558 }
559
560 BEGIN_RING(count+2);
561 OUT_RING(cmd[0]);
562 OUT_RING_TABLE((int *)(cmdbuf->buf + 4), count + 1);
563 ADVANCE_RING();
564
565 cmdbuf->buf += (count+2)*4;
566 cmdbuf->bufsz -= (count+2)*4;
567
568 return 0;
569}
570
541static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv, 571static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
542 drm_radeon_kcmd_buffer_t *cmdbuf) 572 drm_radeon_kcmd_buffer_t *cmdbuf)
543{ 573{
@@ -578,10 +608,11 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
578 case RADEON_CNTL_BITBLT_MULTI: 608 case RADEON_CNTL_BITBLT_MULTI:
579 return r300_emit_bitblt_multi(dev_priv, cmdbuf); 609 return r300_emit_bitblt_multi(dev_priv, cmdbuf);
580 610
611 case RADEON_CP_INDX_BUFFER: /* DRAW_INDX_2 without INDX_BUFFER seems to lock up the gpu */
612 return r300_emit_indx_buffer(dev_priv, cmdbuf);
581 case RADEON_CP_3D_DRAW_IMMD_2: /* triggers drawing using in-packet vertex data */ 613 case RADEON_CP_3D_DRAW_IMMD_2: /* triggers drawing using in-packet vertex data */
582 case RADEON_CP_3D_DRAW_VBUF_2: /* triggers drawing of vertex buffers setup elsewhere */ 614 case RADEON_CP_3D_DRAW_VBUF_2: /* triggers drawing of vertex buffers setup elsewhere */
583 case RADEON_CP_3D_DRAW_INDX_2: /* triggers drawing using indices to vertex buffer */ 615 case RADEON_CP_3D_DRAW_INDX_2: /* triggers drawing using indices to vertex buffer */
584 case RADEON_CP_INDX_BUFFER: /* DRAW_INDX_2 without INDX_BUFFER seems to lock up the gpu */
585 case RADEON_WAIT_FOR_IDLE: 616 case RADEON_WAIT_FOR_IDLE:
586 case RADEON_CP_NOP: 617 case RADEON_CP_NOP:
587 /* these packets are safe */ 618 /* these packets are safe */
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
index feac5f005d47..6e04fdd732ac 100644
--- a/drivers/char/drm/radeon_state.c
+++ b/drivers/char/drm/radeon_state.c
@@ -275,6 +275,8 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
275 unsigned int *cmdsz) 275 unsigned int *cmdsz)
276{ 276{
277 u32 *cmd = (u32 *) cmdbuf->buf; 277 u32 *cmd = (u32 *) cmdbuf->buf;
278 u32 offset, narrays;
279 int count, i, k;
278 280
279 *cmdsz = 2 + ((cmd[0] & RADEON_CP_PACKET_COUNT_MASK) >> 16); 281 *cmdsz = 2 + ((cmd[0] & RADEON_CP_PACKET_COUNT_MASK) >> 16);
280 282
@@ -288,10 +290,106 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
288 return DRM_ERR(EINVAL); 290 return DRM_ERR(EINVAL);
289 } 291 }
290 292
291 /* Check client state and fix it up if necessary */ 293 switch(cmd[0] & 0xff00) {
292 if (cmd[0] & 0x8000) { /* MSB of opcode: next DWORD GUI_CNTL */ 294 /* XXX Are there old drivers needing other packets? */
293 u32 offset;
294 295
296 case RADEON_3D_DRAW_IMMD:
297 case RADEON_3D_DRAW_VBUF:
298 case RADEON_3D_DRAW_INDX:
299 case RADEON_WAIT_FOR_IDLE:
300 case RADEON_CP_NOP:
301 case RADEON_3D_CLEAR_ZMASK:
302/* case RADEON_CP_NEXT_CHAR:
303 case RADEON_CP_PLY_NEXTSCAN:
304 case RADEON_CP_SET_SCISSORS: */ /* probably safe but will never need them? */
305 /* these packets are safe */
306 break;
307
308 case RADEON_CP_3D_DRAW_IMMD_2:
309 case RADEON_CP_3D_DRAW_VBUF_2:
310 case RADEON_CP_3D_DRAW_INDX_2:
311 case RADEON_3D_CLEAR_HIZ:
312 /* safe but r200 only */
313 if (dev_priv->microcode_version != UCODE_R200) {
314 DRM_ERROR("Invalid 3d packet for r100-class chip\n");
315 return DRM_ERR(EINVAL);
316 }
317 break;
318
319 case RADEON_3D_LOAD_VBPNTR:
320 count = (cmd[0] >> 16) & 0x3fff;
321
322 if (count > 18) { /* 12 arrays max */
323 DRM_ERROR("Too large payload in 3D_LOAD_VBPNTR (count=%d)\n",
324 count);
325 return DRM_ERR(EINVAL);
326 }
327
328 /* carefully check packet contents */
329 narrays = cmd[1] & ~0xc000;
330 k = 0;
331 i = 2;
332 while ((k < narrays) && (i < (count + 2))) {
333 i++; /* skip attribute field */
334 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[i])) {
335 DRM_ERROR
336 ("Invalid offset (k=%d i=%d) in 3D_LOAD_VBPNTR packet.\n",
337 k, i);
338 return DRM_ERR(EINVAL);
339 }
340 k++;
341 i++;
342 if (k == narrays)
343 break;
344 /* have one more to process, they come in pairs */
345 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[i])) {
346 DRM_ERROR
347 ("Invalid offset (k=%d i=%d) in 3D_LOAD_VBPNTR packet.\n",
348 k, i);
349 return DRM_ERR(EINVAL);
350 }
351 k++;
352 i++;
353 }
354 /* do the counts match what we expect ? */
355 if ((k != narrays) || (i != (count + 2))) {
356 DRM_ERROR
357 ("Malformed 3D_LOAD_VBPNTR packet (k=%d i=%d narrays=%d count+1=%d).\n",
358 k, i, narrays, count + 1);
359 return DRM_ERR(EINVAL);
360 }
361 break;
362
363 case RADEON_3D_RNDR_GEN_INDX_PRIM:
364 if (dev_priv->microcode_version != UCODE_R100) {
365 DRM_ERROR("Invalid 3d packet for r200-class chip\n");
366 return DRM_ERR(EINVAL);
367 }
368 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[1])) {
369 DRM_ERROR("Invalid rndr_gen_indx offset\n");
370 return DRM_ERR(EINVAL);
371 }
372 break;
373
374 case RADEON_CP_INDX_BUFFER:
375 if (dev_priv->microcode_version != UCODE_R200) {
376 DRM_ERROR("Invalid 3d packet for r100-class chip\n");
377 return DRM_ERR(EINVAL);
378 }
379 if ((cmd[1] & 0x8000ffff) != 0x80000810) {
380 DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]);
381 return DRM_ERR(EINVAL);
382 }
383 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[2])) {
384 DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]);
385 return DRM_ERR(EINVAL);
386 }
387 break;
388
389 case RADEON_CNTL_HOSTDATA_BLT:
390 case RADEON_CNTL_PAINT_MULTI:
391 case RADEON_CNTL_BITBLT_MULTI:
392 /* MSB of opcode: next DWORD GUI_CNTL */
295 if (cmd[1] & (RADEON_GMC_SRC_PITCH_OFFSET_CNTL 393 if (cmd[1] & (RADEON_GMC_SRC_PITCH_OFFSET_CNTL
296 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) { 394 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) {
297 offset = cmd[2] << 10; 395 offset = cmd[2] << 10;
@@ -313,6 +411,11 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
313 } 411 }
314 cmd[3] = (cmd[3] & 0xffc00000) | offset >> 10; 412 cmd[3] = (cmd[3] & 0xffc00000) | offset >> 10;
315 } 413 }
414 break;
415
416 default:
417 DRM_ERROR("Invalid packet type %x\n", cmd[0] & 0xff00);
418 return DRM_ERR(EINVAL);
316 } 419 }
317 420
318 return 0; 421 return 0;
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c
index 59c7520bf9a2..a9a84f88df5e 100644
--- a/drivers/char/drm/savage_bci.c
+++ b/drivers/char/drm/savage_bci.c
@@ -728,6 +728,7 @@ static int savage_do_init_bci(drm_device_t * dev, drm_savage_init_t * init)
728 dev_priv->status = NULL; 728 dev_priv->status = NULL;
729 } 729 }
730 if (dev_priv->dma_type == SAVAGE_DMA_AGP && init->buffers_offset) { 730 if (dev_priv->dma_type == SAVAGE_DMA_AGP && init->buffers_offset) {
731 dev->agp_buffer_token = init->buffers_offset;
731 dev->agp_buffer_map = drm_core_findmap(dev, 732 dev->agp_buffer_map = drm_core_findmap(dev,
732 init->buffers_offset); 733 init->buffers_offset);
733 if (!dev->agp_buffer_map) { 734 if (!dev->agp_buffer_map) {
diff --git a/drivers/char/drm/savage_state.c b/drivers/char/drm/savage_state.c
index ef2581d16146..1ca1e9cb5a33 100644
--- a/drivers/char/drm/savage_state.c
+++ b/drivers/char/drm/savage_state.c
@@ -994,7 +994,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
994 if (cmdbuf.size) { 994 if (cmdbuf.size) {
995 kcmd_addr = drm_alloc(cmdbuf.size * 8, DRM_MEM_DRIVER); 995 kcmd_addr = drm_alloc(cmdbuf.size * 8, DRM_MEM_DRIVER);
996 if (kcmd_addr == NULL) 996 if (kcmd_addr == NULL)
997 return ENOMEM; 997 return DRM_ERR(ENOMEM);
998 998
999 if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf.cmd_addr, 999 if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf.cmd_addr,
1000 cmdbuf.size * 8)) 1000 cmdbuf.size * 8))
diff --git a/drivers/char/ftape/zftape/zftape-buffers.c b/drivers/char/ftape/zftape/zftape-buffers.c
index da06f138334e..7ebce2ec7897 100644
--- a/drivers/char/ftape/zftape/zftape-buffers.c
+++ b/drivers/char/ftape/zftape/zftape-buffers.c
@@ -85,7 +85,7 @@ int zft_vmalloc_once(void *new, size_t size)
85 peak_memory = used_memory; 85 peak_memory = used_memory;
86 } 86 }
87 TRACE_ABORT(0, ft_t_noise, 87 TRACE_ABORT(0, ft_t_noise,
88 "allocated buffer @ %p, %d bytes", *(void **)new, size); 88 "allocated buffer @ %p, %zd bytes", *(void **)new, size);
89} 89}
90int zft_vmalloc_always(void *new, size_t size) 90int zft_vmalloc_always(void *new, size_t size)
91{ 91{
@@ -101,7 +101,7 @@ void zft_vfree(void *old, size_t size)
101 if (*(void **)old) { 101 if (*(void **)old) {
102 vfree(*(void **)old); 102 vfree(*(void **)old);
103 used_memory -= size; 103 used_memory -= size;
104 TRACE(ft_t_noise, "released buffer @ %p, %d bytes", 104 TRACE(ft_t_noise, "released buffer @ %p, %zd bytes",
105 *(void **)old, size); 105 *(void **)old, size);
106 *(void **)old = NULL; 106 *(void **)old = NULL;
107 } 107 }
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 34a4fd13fa81..c47add8e47df 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -376,13 +376,23 @@ static void free_recv_msg_list(struct list_head *q)
376 } 376 }
377} 377}
378 378
379static void free_smi_msg_list(struct list_head *q)
380{
381 struct ipmi_smi_msg *msg, *msg2;
382
383 list_for_each_entry_safe(msg, msg2, q, link) {
384 list_del(&msg->link);
385 ipmi_free_smi_msg(msg);
386 }
387}
388
379static void clean_up_interface_data(ipmi_smi_t intf) 389static void clean_up_interface_data(ipmi_smi_t intf)
380{ 390{
381 int i; 391 int i;
382 struct cmd_rcvr *rcvr, *rcvr2; 392 struct cmd_rcvr *rcvr, *rcvr2;
383 struct list_head list; 393 struct list_head list;
384 394
385 free_recv_msg_list(&intf->waiting_msgs); 395 free_smi_msg_list(&intf->waiting_msgs);
386 free_recv_msg_list(&intf->waiting_events); 396 free_recv_msg_list(&intf->waiting_events);
387 397
388 /* Wholesale remove all the entries from the list in the 398 /* Wholesale remove all the entries from the list in the
@@ -1844,7 +1854,7 @@ static ssize_t provides_dev_sdrs_show(struct device *dev,
1844 struct bmc_device *bmc = dev_get_drvdata(dev); 1854 struct bmc_device *bmc = dev_get_drvdata(dev);
1845 1855
1846 return snprintf(buf, 10, "%u\n", 1856 return snprintf(buf, 10, "%u\n",
1847 bmc->id.device_revision && 0x80 >> 7); 1857 (bmc->id.device_revision & 0x80) >> 7);
1848} 1858}
1849 1859
1850static ssize_t revision_show(struct device *dev, struct device_attribute *attr, 1860static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
@@ -1853,7 +1863,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
1853 struct bmc_device *bmc = dev_get_drvdata(dev); 1863 struct bmc_device *bmc = dev_get_drvdata(dev);
1854 1864
1855 return snprintf(buf, 20, "%u\n", 1865 return snprintf(buf, 20, "%u\n",
1856 bmc->id.device_revision && 0x0F); 1866 bmc->id.device_revision & 0x0F);
1857} 1867}
1858 1868
1859static ssize_t firmware_rev_show(struct device *dev, 1869static ssize_t firmware_rev_show(struct device *dev,
@@ -2108,7 +2118,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2108 dev_set_drvdata(&bmc->dev->dev, bmc); 2118 dev_set_drvdata(&bmc->dev->dev, bmc);
2109 kref_init(&bmc->refcount); 2119 kref_init(&bmc->refcount);
2110 2120
2111 rv = platform_device_register(bmc->dev); 2121 rv = platform_device_add(bmc->dev);
2112 mutex_unlock(&ipmidriver_mutex); 2122 mutex_unlock(&ipmidriver_mutex);
2113 if (rv) { 2123 if (rv) {
2114 printk(KERN_ERR 2124 printk(KERN_ERR
@@ -3232,7 +3242,9 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
3232 report the error immediately. */ 3242 report the error immediately. */
3233 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0) 3243 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0)
3234 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR) 3244 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR)
3235 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR)) 3245 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR)
3246 && (msg->rsp[2] != IPMI_BUS_ERR)
3247 && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR))
3236 { 3248 {
3237 int chan = msg->rsp[3] & 0xf; 3249 int chan = msg->rsp[3] & 0xf;
3238 3250
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index e5cfb1fa47d1..bb1fac104fda 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1211,7 +1211,7 @@ static void intf_mem_outb(struct si_sm_io *io, unsigned int offset,
1211static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset) 1211static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset)
1212{ 1212{
1213 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift) 1213 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift)
1214 && 0xff; 1214 & 0xff;
1215} 1215}
1216 1216
1217static void intf_mem_outw(struct si_sm_io *io, unsigned int offset, 1217static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
@@ -1223,7 +1223,7 @@ static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
1223static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset) 1223static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset)
1224{ 1224{
1225 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift) 1225 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift)
1226 && 0xff; 1226 & 0xff;
1227} 1227}
1228 1228
1229static void intf_mem_outl(struct si_sm_io *io, unsigned int offset, 1229static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
@@ -1236,7 +1236,7 @@ static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
1236static unsigned char mem_inq(struct si_sm_io *io, unsigned int offset) 1236static unsigned char mem_inq(struct si_sm_io *io, unsigned int offset)
1237{ 1237{
1238 return (readq((io->addr)+(offset * io->regspacing)) >> io->regshift) 1238 return (readq((io->addr)+(offset * io->regspacing)) >> io->regshift)
1239 && 0xff; 1239 & 0xff;
1240} 1240}
1241 1241
1242static void mem_outq(struct si_sm_io *io, unsigned int offset, 1242static void mem_outq(struct si_sm_io *io, unsigned int offset,
@@ -1867,7 +1867,7 @@ static int ipmi_pci_resume(struct pci_dev *pdev)
1867 1867
1868static struct pci_device_id ipmi_pci_devices[] = { 1868static struct pci_device_id ipmi_pci_devices[] = {
1869 { PCI_DEVICE(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID) }, 1869 { PCI_DEVICE(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID) },
1870 { PCI_DEVICE_CLASS(PCI_ERMC_CLASSCODE, PCI_ERMC_CLASSCODE) } 1870 { PCI_DEVICE_CLASS(PCI_ERMC_CLASSCODE, PCI_ERMC_CLASSCODE_MASK) }
1871}; 1871};
1872MODULE_DEVICE_TABLE(pci, ipmi_pci_devices); 1872MODULE_DEVICE_TABLE(pci, ipmi_pci_devices);
1873 1873
@@ -2346,7 +2346,7 @@ static int try_smi_init(struct smi_info *new_smi)
2346 new_smi->dev = &new_smi->pdev->dev; 2346 new_smi->dev = &new_smi->pdev->dev;
2347 new_smi->dev->driver = &ipmi_driver; 2347 new_smi->dev->driver = &ipmi_driver;
2348 2348
2349 rv = platform_device_register(new_smi->pdev); 2349 rv = platform_device_add(new_smi->pdev);
2350 if (rv) { 2350 if (rv) {
2351 printk(KERN_ERR 2351 printk(KERN_ERR
2352 "ipmi_si_intf:" 2352 "ipmi_si_intf:"
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index e9e9bf31c369..58c955e390b3 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -1062,11 +1062,12 @@ static void isicom_shutdown_port(struct isi_port *port)
1062static void isicom_close(struct tty_struct *tty, struct file *filp) 1062static void isicom_close(struct tty_struct *tty, struct file *filp)
1063{ 1063{
1064 struct isi_port *port = tty->driver_data; 1064 struct isi_port *port = tty->driver_data;
1065 struct isi_board *card = port->card; 1065 struct isi_board *card;
1066 unsigned long flags; 1066 unsigned long flags;
1067 1067
1068 if (!port) 1068 if (!port)
1069 return; 1069 return;
1070 card = port->card;
1070 if (isicom_paranoia_check(port, tty->name, "isicom_close")) 1071 if (isicom_paranoia_check(port, tty->name, "isicom_close"))
1071 return; 1072 return;
1072 1073
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index b401383808c2..96cb1f07332b 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -130,6 +130,7 @@ static moxa_isa_board_conf moxa_isa_boards[] =
130typedef struct _moxa_pci_devinfo { 130typedef struct _moxa_pci_devinfo {
131 ushort busNum; 131 ushort busNum;
132 ushort devNum; 132 ushort devNum;
133 struct pci_dev *pdev;
133} moxa_pci_devinfo; 134} moxa_pci_devinfo;
134 135
135typedef struct _moxa_board_conf { 136typedef struct _moxa_board_conf {
@@ -324,6 +325,9 @@ static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf
324 board->busType = MOXA_BUS_TYPE_PCI; 325 board->busType = MOXA_BUS_TYPE_PCI;
325 board->pciInfo.busNum = p->bus->number; 326 board->pciInfo.busNum = p->bus->number;
326 board->pciInfo.devNum = p->devfn >> 3; 327 board->pciInfo.devNum = p->devfn >> 3;
328 board->pciInfo.pdev = p;
329 /* don't lose the reference in the next pci_get_device iteration */
330 pci_dev_get(p);
327 331
328 return (0); 332 return (0);
329} 333}
@@ -493,6 +497,11 @@ static void __exit moxa_exit(void)
493 if (tty_unregister_driver(moxaDriver)) 497 if (tty_unregister_driver(moxaDriver))
494 printk("Couldn't unregister MOXA Intellio family serial driver\n"); 498 printk("Couldn't unregister MOXA Intellio family serial driver\n");
495 put_tty_driver(moxaDriver); 499 put_tty_driver(moxaDriver);
500
501 for (i = 0; i < MAX_BOARDS; i++)
502 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI)
503 pci_dev_put(moxa_boards[i].pciInfo.pdev);
504
496 if (verbose) 505 if (verbose)
497 printk("Done\n"); 506 printk("Done\n");
498} 507}
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index 5c0dec39cf6c..235e89226112 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -72,7 +72,11 @@ enum {
72 MSPEC_UNCACHED 72 MSPEC_UNCACHED
73}; 73};
74 74
75#ifdef CONFIG_SGI_SN
75static int is_sn2; 76static int is_sn2;
77#else
78#define is_sn2 0
79#endif
76 80
77/* 81/*
78 * One of these structures is allocated when an mspec region is mmaped. The 82 * One of these structures is allocated when an mspec region is mmaped. The
@@ -211,7 +215,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
211 if (vdata->type == MSPEC_FETCHOP) 215 if (vdata->type == MSPEC_FETCHOP)
212 paddr = TO_AMO(maddr); 216 paddr = TO_AMO(maddr);
213 else 217 else
214 paddr = __pa(TO_CAC(maddr)); 218 paddr = maddr & ~__IA64_UNCACHED_OFFSET;
215 219
216 pfn = paddr >> PAGE_SHIFT; 220 pfn = paddr >> PAGE_SHIFT;
217 221
@@ -335,6 +339,7 @@ mspec_init(void)
335 * The fetchop device only works on SN2 hardware, uncached and cached 339 * The fetchop device only works on SN2 hardware, uncached and cached
336 * memory drivers should both be valid on all ia64 hardware 340 * memory drivers should both be valid on all ia64 hardware
337 */ 341 */
342#ifdef CONFIG_SGI_SN
338 if (ia64_platform_is("sn2")) { 343 if (ia64_platform_is("sn2")) {
339 is_sn2 = 1; 344 is_sn2 = 1;
340 if (is_shub2()) { 345 if (is_shub2()) {
@@ -363,6 +368,7 @@ mspec_init(void)
363 goto free_scratch_pages; 368 goto free_scratch_pages;
364 } 369 }
365 } 370 }
371#endif
366 ret = misc_register(&cached_miscdev); 372 ret = misc_register(&cached_miscdev);
367 if (ret) { 373 if (ret) {
368 printk(KERN_ERR "%s: failed to register device %i\n", 374 printk(KERN_ERR "%s: failed to register device %i\n",
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h
index ee2ddea7a63a..23d0681fe491 100644
--- a/drivers/char/rio/host.h
+++ b/drivers/char/rio/host.h
@@ -44,6 +44,7 @@
44** the host. 44** the host.
45*/ 45*/
46struct Host { 46struct Host {
47 struct pci_dev *pdev;
47 unsigned char Type; /* RIO_EISA, RIO_MCA, ... */ 48 unsigned char Type; /* RIO_EISA, RIO_MCA, ... */
48 unsigned char Ivec; /* POLLED or ivec number */ 49 unsigned char Ivec; /* POLLED or ivec number */
49 unsigned char Mode; /* Control stuff */ 50 unsigned char Mode; /* Control stuff */
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index c382df0f82f6..7ac68cb3bedd 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -1017,6 +1017,10 @@ static int __init rio_init(void)
1017 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1017 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1018 1018
1019 fix_rio_pci(pdev); 1019 fix_rio_pci(pdev);
1020
1021 p->RIOHosts[p->RIONumHosts].pdev = pdev;
1022 pci_dev_get(pdev);
1023
1020 p->RIOLastPCISearch = 0; 1024 p->RIOLastPCISearch = 0;
1021 p->RIONumHosts++; 1025 p->RIONumHosts++;
1022 found++; 1026 found++;
@@ -1066,6 +1070,9 @@ static int __init rio_init(void)
1066 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); 1070 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
1067 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1071 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1068 1072
1073 p->RIOHosts[p->RIONumHosts].pdev = pdev;
1074 pci_dev_get(pdev);
1075
1069 p->RIOLastPCISearch = 0; 1076 p->RIOLastPCISearch = 0;
1070 p->RIONumHosts++; 1077 p->RIONumHosts++;
1071 found++; 1078 found++;
@@ -1181,6 +1188,8 @@ static void __exit rio_exit(void)
1181 } 1188 }
1182 /* It is safe/allowed to del_timer a non-active timer */ 1189 /* It is safe/allowed to del_timer a non-active timer */
1183 del_timer(&hp->timer); 1190 del_timer(&hp->timer);
1191 if (hp->Type == RIO_PCI)
1192 pci_dev_put(hp->pdev);
1184 } 1193 }
1185 1194
1186 if (misc_deregister(&rio_fw_device) < 0) { 1195 if (misc_deregister(&rio_fw_device) < 0) {
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 2444a0e24b31..244d30a03fef 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -792,15 +792,14 @@ static int __init tlclk_init(void)
792 ret = misc_register(&tlclk_miscdev); 792 ret = misc_register(&tlclk_miscdev);
793 if (ret < 0) { 793 if (ret < 0) {
794 printk(KERN_ERR "tlclk: misc_register returns %d.\n", ret); 794 printk(KERN_ERR "tlclk: misc_register returns %d.\n", ret);
795 ret = -EBUSY;
796 goto out3; 795 goto out3;
797 } 796 }
798 797
799 tlclk_device = platform_device_register_simple("telco_clock", 798 tlclk_device = platform_device_register_simple("telco_clock",
800 -1, NULL, 0); 799 -1, NULL, 0);
801 if (!tlclk_device) { 800 if (IS_ERR(tlclk_device)) {
802 printk(KERN_ERR "tlclk: platform_device_register failed.\n"); 801 printk(KERN_ERR "tlclk: platform_device_register failed.\n");
803 ret = -EBUSY; 802 ret = PTR_ERR(tlclk_device);
804 goto out4; 803 goto out4;
805 } 804 }
806 805
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 89e46d6dfc4e..0187b1185323 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -13,7 +13,7 @@ config WATCHDOG
13 subsequently opening the file and then failing to write to it for 13 subsequently opening the file and then failing to write to it for
14 longer than 1 minute will result in rebooting the machine. This 14 longer than 1 minute will result in rebooting the machine. This
15 could be useful for a networked machine that needs to come back 15 could be useful for a networked machine that needs to come back
16 online as fast as possible after a lock-up. There's both a watchdog 16 on-line as fast as possible after a lock-up. There's both a watchdog
17 implementation entirely in software (which can sometimes fail to 17 implementation entirely in software (which can sometimes fail to
18 reboot the machine) and a driver for hardware watchdog boards, which 18 reboot the machine) and a driver for hardware watchdog boards, which
19 are more robust and can also keep track of the temperature inside 19 are more robust and can also keep track of the temperature inside
@@ -60,7 +60,7 @@ config SOFT_WATCHDOG
60 60
61# ARM Architecture 61# ARM Architecture
62 62
63config AT91_WATCHDOG 63config AT91RM9200_WATCHDOG
64 tristate "AT91RM9200 watchdog" 64 tristate "AT91RM9200 watchdog"
65 depends on WATCHDOG && ARCH_AT91RM9200 65 depends on WATCHDOG && ARCH_AT91RM9200
66 help 66 help
@@ -71,7 +71,7 @@ config 21285_WATCHDOG
71 tristate "DC21285 watchdog" 71 tristate "DC21285 watchdog"
72 depends on WATCHDOG && FOOTBRIDGE 72 depends on WATCHDOG && FOOTBRIDGE
73 help 73 help
74 The Intel Footbridge chip contains a builtin watchdog circuit. Say Y 74 The Intel Footbridge chip contains a built-in watchdog circuit. Say Y
75 here if you wish to use this. Alternatively say M to compile the 75 here if you wish to use this. Alternatively say M to compile the
76 driver as a module, which will be called wdt285. 76 driver as a module, which will be called wdt285.
77 77
@@ -269,11 +269,11 @@ config IB700_WDT
269 Most people will say N. 269 Most people will say N.
270 270
271config IBMASR 271config IBMASR
272 tristate "IBM Automatic Server Restart" 272 tristate "IBM Automatic Server Restart"
273 depends on WATCHDOG && X86 273 depends on WATCHDOG && X86
274 help 274 help
275 This is the driver for the IBM Automatic Server Restart watchdog 275 This is the driver for the IBM Automatic Server Restart watchdog
276 timer builtin into some eServer xSeries machines. 276 timer built-in into some eServer xSeries machines.
277 277
278 To compile this driver as a module, choose M here: the 278 To compile this driver as a module, choose M here: the
279 module will be called ibmasr. 279 module will be called ibmasr.
@@ -316,13 +316,16 @@ config I8XX_TCO
316 To compile this driver as a module, choose M here: the 316 To compile this driver as a module, choose M here: the
317 module will be called i8xx_tco. 317 module will be called i8xx_tco.
318 318
319 Note: This driver will be removed in the near future. Please
320 use the Intel TCO Timer/Watchdog driver.
321
319config ITCO_WDT 322config ITCO_WDT
320 tristate "Intel TCO Timer/Watchdog (EXPERIMENTAL)" 323 tristate "Intel TCO Timer/Watchdog"
321 depends on WATCHDOG && (X86 || IA64) && PCI && EXPERIMENTAL 324 depends on WATCHDOG && (X86 || IA64) && PCI
322 ---help--- 325 ---help---
323 Hardware driver for the intel TCO timer based watchdog devices. 326 Hardware driver for the intel TCO timer based watchdog devices.
324 These drivers are included in the Intel 82801 I/O Controller 327 These drivers are included in the Intel 82801 I/O Controller
325 Hub family 'from ICH0 up to ICH7) and in the Intel 6300ESB 328 Hub family (from ICH0 up to ICH8) and in the Intel 6300ESB
326 controller hub. 329 controller hub.
327 330
328 The TCO (Total Cost of Ownership) timer is a watchdog timer 331 The TCO (Total Cost of Ownership) timer is a watchdog timer
@@ -395,6 +398,26 @@ config CPU5_WDT
395 To compile this driver as a module, choose M here: the 398 To compile this driver as a module, choose M here: the
396 module will be called cpu5wdt. 399 module will be called cpu5wdt.
397 400
401config SMSC37B787_WDT
402 tristate "Winbond SMsC37B787 Watchdog Timer"
403 depends on WATCHDOG && X86
404 ---help---
405 This is the driver for the hardware watchdog component on the
406 Winbond SMsC37B787 chipset as used on the NetRunner Mainboard
407 from Vision Systems and maybe others.
408
409 This watchdog simply watches your kernel to make sure it doesn't
410 freeze, and if it does, it reboots your computer after a certain
411 amount of time.
412
413 Usually a userspace daemon will notify the kernel WDT driver that
414 userspace is still alive, at regular intervals.
415
416 To compile this driver as a module, choose M here: the
417 module will be called smsc37b787_wdt.
418
419 Most people will say N.
420
398config W83627HF_WDT 421config W83627HF_WDT
399 tristate "W83627HF Watchdog Timer" 422 tristate "W83627HF Watchdog Timer"
400 depends on WATCHDOG && X86 423 depends on WATCHDOG && X86
@@ -410,6 +433,21 @@ config W83627HF_WDT
410 433
411 Most people will say N. 434 Most people will say N.
412 435
436config W83697HF_WDT
437 tristate "W83697HF/W83697HG Watchdog Timer"
438 depends on WATCHDOG && X86
439 ---help---
440 This is the driver for the hardware watchdog on the W83697HF/HG
441 chipset as used in Dedibox/VIA motherboards (and likely others).
442 This watchdog simply watches your kernel to make sure it doesn't
443 freeze, and if it does, it reboots your computer after a certain
444 amount of time.
445
446 To compile this driver as a module, choose M here: the
447 module will be called w83697hf_wdt.
448
449 Most people will say N.
450
413config W83877F_WDT 451config W83877F_WDT
414 tristate "W83877F (EMACS) Watchdog Timer" 452 tristate "W83877F (EMACS) Watchdog Timer"
415 depends on WATCHDOG && X86 453 depends on WATCHDOG && X86
@@ -443,7 +481,7 @@ config MACHZ_WDT
443 depends on WATCHDOG && X86 481 depends on WATCHDOG && X86
444 ---help--- 482 ---help---
445 If you are using a ZF Micro MachZ processor, say Y here, otherwise 483 If you are using a ZF Micro MachZ processor, say Y here, otherwise
446 N. This is the driver for the watchdog timer builtin on that 484 N. This is the driver for the watchdog timer built-in on that
447 processor using ZF-Logic interface. This watchdog simply watches 485 processor using ZF-Logic interface. This watchdog simply watches
448 your kernel to make sure it doesn't freeze, and if it does, it 486 your kernel to make sure it doesn't freeze, and if it does, it
449 reboots your computer after a certain amount of time. 487 reboots your computer after a certain amount of time.
@@ -472,7 +510,6 @@ config SBC_EPX_C3_WATCHDOG
472 To compile this driver as a module, choose M here: the 510 To compile this driver as a module, choose M here: the
473 module will be called sbc_epx_c3. 511 module will be called sbc_epx_c3.
474 512
475
476# PowerPC Architecture 513# PowerPC Architecture
477 514
478config 8xx_WDT 515config 8xx_WDT
@@ -502,7 +539,7 @@ config WATCHDOG_RTAS
502 help 539 help
503 This driver adds watchdog support for the RTAS watchdog. 540 This driver adds watchdog support for the RTAS watchdog.
504 541
505 To compile this driver as a module, choose M here. The module 542 To compile this driver as a module, choose M here. The module
506 will be called wdrtas. 543 will be called wdrtas.
507 544
508# MIPS Architecture 545# MIPS Architecture
@@ -556,7 +593,7 @@ config SH_WDT_MMAP
556 help 593 help
557 If you say Y here, user applications will be able to mmap the 594 If you say Y here, user applications will be able to mmap the
558 WDT/CPG registers. 595 WDT/CPG registers.
559# 596
560# SPARC64 Architecture 597# SPARC64 Architecture
561 598
562config WATCHDOG_CP1XXX 599config WATCHDOG_CP1XXX
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 7f70abad465a..36440497047c 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -23,7 +23,7 @@ obj-$(CONFIG_WDTPCI) += wdt_pci.o
23obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o 23obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
24 24
25# ARM Architecture 25# ARM Architecture
26obj-$(CONFIG_AT91_WATCHDOG) += at91_wdt.o 26obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o
27obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o 27obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
28obj-$(CONFIG_21285_WATCHDOG) += wdt285.o 28obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
29obj-$(CONFIG_977_WATCHDOG) += wdt977.o 29obj-$(CONFIG_977_WATCHDOG) += wdt977.o
@@ -53,7 +53,9 @@ obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
53obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o 53obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
54obj-$(CONFIG_SBC8360_WDT) += sbc8360.o 54obj-$(CONFIG_SBC8360_WDT) += sbc8360.o
55obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o 55obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
56obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o
56obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o 57obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
58obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o
57obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o 59obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
58obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o 60obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o
59obj-$(CONFIG_MACHZ_WDT) += machzwd.o 61obj-$(CONFIG_MACHZ_WDT) += machzwd.o
diff --git a/drivers/char/watchdog/at91_wdt.c b/drivers/char/watchdog/at91rm9200_wdt.c
index 4e7a1145e78f..4e7a1145e78f 100644
--- a/drivers/char/watchdog/at91_wdt.c
+++ b/drivers/char/watchdog/at91rm9200_wdt.c
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index aaac94db0d8b..b6f29cb8bd39 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -35,6 +35,10 @@
35 * 82801GDH (ICH7DH) : document number 307013-002, 307014-009, 35 * 82801GDH (ICH7DH) : document number 307013-002, 307014-009,
36 * 82801GBM (ICH7-M) : document number 307013-002, 307014-009, 36 * 82801GBM (ICH7-M) : document number 307013-002, 307014-009,
37 * 82801GHM (ICH7-M DH) : document number 307013-002, 307014-009, 37 * 82801GHM (ICH7-M DH) : document number 307013-002, 307014-009,
38 * 82801HB (ICH8) : document number 313056-002, 313057-004,
39 * 82801HR (ICH8R) : document number 313056-002, 313057-004,
40 * 82801HH (ICH8DH) : document number 313056-002, 313057-004,
41 * 82801HO (ICH8DO) : document number 313056-002, 313057-004,
38 * 6300ESB (6300ESB) : document number 300641-003 42 * 6300ESB (6300ESB) : document number 300641-003
39 */ 43 */
40 44
@@ -45,7 +49,7 @@
45/* Module and version information */ 49/* Module and version information */
46#define DRV_NAME "iTCO_wdt" 50#define DRV_NAME "iTCO_wdt"
47#define DRV_VERSION "1.00" 51#define DRV_VERSION "1.00"
48#define DRV_RELDATE "30-Jul-2006" 52#define DRV_RELDATE "08-Oct-2006"
49#define PFX DRV_NAME ": " 53#define PFX DRV_NAME ": "
50 54
51/* Includes */ 55/* Includes */
@@ -85,6 +89,9 @@ enum iTCO_chipsets {
85 TCO_ICH7, /* ICH7 & ICH7R */ 89 TCO_ICH7, /* ICH7 & ICH7R */
86 TCO_ICH7M, /* ICH7-M */ 90 TCO_ICH7M, /* ICH7-M */
87 TCO_ICH7MDH, /* ICH7-M DH */ 91 TCO_ICH7MDH, /* ICH7-M DH */
92 TCO_ICH8, /* ICH8 & ICH8R */
93 TCO_ICH8DH, /* ICH8DH */
94 TCO_ICH8DO, /* ICH8DO */
88}; 95};
89 96
90static struct { 97static struct {
@@ -108,6 +115,9 @@ static struct {
108 {"ICH7 or ICH7R", 2}, 115 {"ICH7 or ICH7R", 2},
109 {"ICH7-M", 2}, 116 {"ICH7-M", 2},
110 {"ICH7-M DH", 2}, 117 {"ICH7-M DH", 2},
118 {"ICH8 or ICH8R", 2},
119 {"ICH8DH", 2},
120 {"ICH8DO", 2},
111 {NULL,0} 121 {NULL,0}
112}; 122};
113 123
@@ -135,6 +145,9 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = {
135 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7 }, 145 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7 },
136 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7M }, 146 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7M },
137 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7MDH }, 147 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7MDH },
148 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8 },
149 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8DH },
150 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8DO },
138 { 0, }, /* End of list */ 151 { 0, }, /* End of list */
139}; 152};
140MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl); 153MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl);
@@ -355,7 +368,8 @@ static int iTCO_wdt_get_timeleft (int *time_left)
355 spin_unlock(&iTCO_wdt_private.io_lock); 368 spin_unlock(&iTCO_wdt_private.io_lock);
356 369
357 *time_left = (val8 * 6) / 10; 370 *time_left = (val8 * 6) / 10;
358 } 371 } else
372 return -EINVAL;
359 return 0; 373 return 0;
360} 374}
361 375
@@ -426,7 +440,6 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file,
426{ 440{
427 int new_options, retval = -EINVAL; 441 int new_options, retval = -EINVAL;
428 int new_heartbeat; 442 int new_heartbeat;
429 int time_left;
430 void __user *argp = (void __user *)arg; 443 void __user *argp = (void __user *)arg;
431 int __user *p = argp; 444 int __user *p = argp;
432 static struct watchdog_info ident = { 445 static struct watchdog_info ident = {
@@ -486,6 +499,8 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file,
486 499
487 case WDIOC_GETTIMELEFT: 500 case WDIOC_GETTIMELEFT:
488 { 501 {
502 int time_left;
503
489 if (iTCO_wdt_get_timeleft(&time_left)) 504 if (iTCO_wdt_get_timeleft(&time_left))
490 return -EINVAL; 505 return -EINVAL;
491 506
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
index 68b1ca976d53..18cb050c3862 100644
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -380,18 +380,21 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
380 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 380 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
381 if (res == NULL) { 381 if (res == NULL) {
382 printk(KERN_INFO PFX "failed to get irq resource\n"); 382 printk(KERN_INFO PFX "failed to get irq resource\n");
383 iounmap(wdt_base);
383 return -ENOENT; 384 return -ENOENT;
384 } 385 }
385 386
386 ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev); 387 ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev);
387 if (ret != 0) { 388 if (ret != 0) {
388 printk(KERN_INFO PFX "failed to install irq (%d)\n", ret); 389 printk(KERN_INFO PFX "failed to install irq (%d)\n", ret);
390 iounmap(wdt_base);
389 return ret; 391 return ret;
390 } 392 }
391 393
392 wdt_clock = clk_get(&pdev->dev, "watchdog"); 394 wdt_clock = clk_get(&pdev->dev, "watchdog");
393 if (wdt_clock == NULL) { 395 if (wdt_clock == NULL) {
394 printk(KERN_INFO PFX "failed to find watchdog clock source\n"); 396 printk(KERN_INFO PFX "failed to find watchdog clock source\n");
397 iounmap(wdt_base);
395 return -ENOENT; 398 return -ENOENT;
396 } 399 }
397 400
@@ -415,6 +418,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
415 if (ret) { 418 if (ret) {
416 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n", 419 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n",
417 WATCHDOG_MINOR, ret); 420 WATCHDOG_MINOR, ret);
421 iounmap(wdt_base);
418 return ret; 422 return ret;
419 } 423 }
420 424
@@ -451,6 +455,7 @@ static int s3c2410wdt_remove(struct platform_device *dev)
451 wdt_clock = NULL; 455 wdt_clock = NULL;
452 } 456 }
453 457
458 iounmap(wdt_base);
454 misc_deregister(&s3c2410wdt_miscdev); 459 misc_deregister(&s3c2410wdt_miscdev);
455 return 0; 460 return 0;
456} 461}
diff --git a/drivers/char/watchdog/sc1200wdt.c b/drivers/char/watchdog/sc1200wdt.c
index d8d0f28e0acf..e3239833e4b0 100644
--- a/drivers/char/watchdog/sc1200wdt.c
+++ b/drivers/char/watchdog/sc1200wdt.c
@@ -392,7 +392,7 @@ static int __init sc1200wdt_init(void)
392 if (io == -1) { 392 if (io == -1) {
393 printk(KERN_ERR PFX "io parameter must be specified\n"); 393 printk(KERN_ERR PFX "io parameter must be specified\n");
394 ret = -EINVAL; 394 ret = -EINVAL;
395 goto out_clean; 395 goto out_pnp;
396 } 396 }
397 397
398#if defined CONFIG_PNP 398#if defined CONFIG_PNP
@@ -405,7 +405,7 @@ static int __init sc1200wdt_init(void)
405 if (!request_region(io, io_len, SC1200_MODULE_NAME)) { 405 if (!request_region(io, io_len, SC1200_MODULE_NAME)) {
406 printk(KERN_ERR PFX "Unable to register IO port %#x\n", io); 406 printk(KERN_ERR PFX "Unable to register IO port %#x\n", io);
407 ret = -EBUSY; 407 ret = -EBUSY;
408 goto out_clean; 408 goto out_pnp;
409 } 409 }
410 410
411 ret = sc1200wdt_probe(); 411 ret = sc1200wdt_probe();
@@ -435,6 +435,11 @@ out_rbt:
435out_io: 435out_io:
436 release_region(io, io_len); 436 release_region(io, io_len);
437 437
438out_pnp:
439#if defined CONFIG_PNP
440 if (isapnp)
441 pnp_unregister_driver(&scl200wdt_pnp_driver);
442#endif
438 goto out_clean; 443 goto out_clean;
439} 444}
440 445
diff --git a/drivers/char/watchdog/smsc37b787_wdt.c b/drivers/char/watchdog/smsc37b787_wdt.c
new file mode 100644
index 000000000000..9f56913b484f
--- /dev/null
+++ b/drivers/char/watchdog/smsc37b787_wdt.c
@@ -0,0 +1,627 @@
1/*
2 * SMsC 37B787 Watchdog Timer driver for Linux 2.6.x.x
3 *
4 * Based on acquirewdt.c by Alan Cox <alan@redhat.com>
5 * and some other existing drivers
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * The authors do NOT admit liability nor provide warranty for
13 * any of this software. This material is provided "AS-IS" in
14 * the hope that it may be useful for others.
15 *
16 * (C) Copyright 2003-2006 Sven Anders <anders@anduras.de>
17 *
18 * History:
19 * 2003 - Created version 1.0 for Linux 2.4.x.
20 * 2006 - Ported to Linux 2.6, added nowayout and MAGICCLOSE
21 * features. Released version 1.1
22 *
23 * Theory of operation:
24 *
25 * A Watchdog Timer (WDT) is a hardware circuit that can
26 * reset the computer system in case of a software fault.
27 * You probably knew that already.
28 *
29 * Usually a userspace daemon will notify the kernel WDT driver
30 * via the /dev/watchdog special device file that userspace is
31 * still alive, at regular intervals. When such a notification
32 * occurs, the driver will usually tell the hardware watchdog
33 * that everything is in order, and that the watchdog should wait
34 * for yet another little while to reset the system.
35 * If userspace fails (RAM error, kernel bug, whatever), the
36 * notifications cease to occur, and the hardware watchdog will
37 * reset the system (causing a reboot) after the timeout occurs.
38 *
39 * Create device with:
40 * mknod /dev/watchdog c 10 130
41 *
42 * For an example userspace keep-alive daemon, see:
43 * Documentation/watchdog/watchdog.txt
44 */
45
46#include <linux/module.h>
47#include <linux/moduleparam.h>
48#include <linux/types.h>
49#include <linux/miscdevice.h>
50#include <linux/watchdog.h>
51#include <linux/delay.h>
52#include <linux/fs.h>
53#include <linux/ioport.h>
54#include <linux/notifier.h>
55#include <linux/reboot.h>
56#include <linux/init.h>
57#include <linux/spinlock.h>
58
59#include <asm/io.h>
60#include <asm/uaccess.h>
61#include <asm/system.h>
62
63/* enable support for minutes as units? */
64/* (does not always work correctly, so disabled by default!) */
65#define SMSC_SUPPORT_MINUTES
66#undef SMSC_SUPPORT_MINUTES
67
68#define MAX_TIMEOUT 255
69
70#define UNIT_SECOND 0
71#define UNIT_MINUTE 1
72
73#define MODNAME "smsc37b787_wdt: "
74#define VERSION "1.1"
75
76#define IOPORT 0x3F0
77#define IOPORT_SIZE 2
78#define IODEV_NO 8
79
80static int unit = UNIT_SECOND; /* timer's unit */
81static int timeout = 60; /* timeout value: default is 60 "units" */
82static unsigned long timer_enabled = 0; /* is the timer enabled? */
83
84static char expect_close; /* is the close expected? */
85
86static spinlock_t io_lock; /* to guard the watchdog from io races */
87
88static int nowayout = WATCHDOG_NOWAYOUT;
89
90/* -- Low level function ----------------------------------------*/
91
92/* unlock the IO chip */
93
94static inline void open_io_config(void)
95{
96 outb(0x55, IOPORT);
97 mdelay(1);
98 outb(0x55, IOPORT);
99}
100
101/* lock the IO chip */
102static inline void close_io_config(void)
103{
104 outb(0xAA, IOPORT);
105}
106
107/* select the IO device */
108static inline void select_io_device(unsigned char devno)
109{
110 outb(0x07, IOPORT);
111 outb(devno, IOPORT+1);
112}
113
114/* write to the control register */
115static inline void write_io_cr(unsigned char reg, unsigned char data)
116{
117 outb(reg, IOPORT);
118 outb(data, IOPORT+1);
119}
120
121/* read from the control register */
122static inline char read_io_cr(unsigned char reg)
123{
124 outb(reg, IOPORT);
125 return inb(IOPORT+1);
126}
127
128/* -- Medium level functions ------------------------------------*/
129
130static inline void gpio_bit12(unsigned char reg)
131{
132 // -- General Purpose I/O Bit 1.2 --
133 // Bit 0, In/Out: 0 = Output, 1 = Input
134 // Bit 1, Polarity: 0 = No Invert, 1 = Invert
135 // Bit 2, Group Enable Intr.: 0 = Disable, 1 = Enable
136 // Bit 3/4, Function select: 00 = GPI/O, 01 = WDT, 10 = P17,
137 // 11 = Either Edge Triggered Intr. 2
138 // Bit 5/6 (Reserved)
139 // Bit 7, Output Type: 0 = Push Pull Bit, 1 = Open Drain
140 write_io_cr(0xE2, reg);
141}
142
143static inline void gpio_bit13(unsigned char reg)
144{
145 // -- General Purpose I/O Bit 1.3 --
146 // Bit 0, In/Out: 0 = Output, 1 = Input
147 // Bit 1, Polarity: 0 = No Invert, 1 = Invert
148 // Bit 2, Group Enable Intr.: 0 = Disable, 1 = Enable
149 // Bit 3, Function select: 0 = GPI/O, 1 = LED
150 // Bit 4-6 (Reserved)
151 // Bit 7, Output Type: 0 = Push Pull Bit, 1 = Open Drain
152 write_io_cr(0xE3, reg);
153}
154
155static inline void wdt_timer_units(unsigned char new_units)
156{
157 // -- Watchdog timer units --
158 // Bit 0-6 (Reserved)
159 // Bit 7, WDT Time-out Value Units Select
160 // (0 = Minutes, 1 = Seconds)
161 write_io_cr(0xF1, new_units);
162}
163
164static inline void wdt_timeout_value(unsigned char new_timeout)
165{
166 // -- Watchdog Timer Time-out Value --
167 // Bit 0-7 Binary coded units (0=Disabled, 1..255)
168 write_io_cr(0xF2, new_timeout);
169}
170
171static inline void wdt_timer_conf(unsigned char conf)
172{
173 // -- Watchdog timer configuration --
174 // Bit 0 Joystick enable: 0* = No Reset, 1 = Reset WDT upon Gameport I/O
175 // Bit 1 Keyboard enable: 0* = No Reset, 1 = Reset WDT upon KBD Intr.
176 // Bit 2 Mouse enable: 0* = No Reset, 1 = Reset WDT upon Mouse Intr.
177 // Bit 3 Reset the timer
178 // (Wrong in SMsC documentation? Given as: PowerLED Timout Enabled)
179 // Bit 4-7 WDT Interrupt Mapping: (0000* = Disabled,
180 // 0001=IRQ1, 0010=(Invalid), 0011=IRQ3 to 1111=IRQ15)
181 write_io_cr(0xF3, conf);
182}
183
184static inline void wdt_timer_ctrl(unsigned char reg)
185{
186 // -- Watchdog timer control --
187 // Bit 0 Status Bit: 0 = Timer counting, 1 = Timeout occured
188 // Bit 1 Power LED Toggle: 0 = Disable Toggle, 1 = Toggle at 1 Hz
189 // Bit 2 Force Timeout: 1 = Forces WD timeout event (self-cleaning)
190 // Bit 3 P20 Force Timeout enabled:
191 // 0 = P20 activity does not generate the WD timeout event
192 // 1 = P20 Allows rising edge of P20, from the keyboard
193 // controller, to force the WD timeout event.
194 // Bit 4 (Reserved)
195 // -- Soft power management --
196 // Bit 5 Stop Counter: 1 = Stop software power down counter
197 // set via register 0xB8, (self-cleaning)
198 // (Upon read: 0 = Counter running, 1 = Counter stopped)
199 // Bit 6 Restart Counter: 1 = Restart software power down counter
200 // set via register 0xB8, (self-cleaning)
201 // Bit 7 SPOFF: 1 = Force software power down (self-cleaning)
202
203 write_io_cr(0xF4, reg);
204}
205
206/* -- Higher level functions ------------------------------------*/
207
208/* initialize watchdog */
209
210static void wb_smsc_wdt_initialize(void)
211{
212 unsigned char old;
213
214 spin_lock(&io_lock);
215 open_io_config();
216 select_io_device(IODEV_NO);
217
218 // enable the watchdog
219 gpio_bit13(0x08); // Select pin 80 = LED not GPIO
220 gpio_bit12(0x0A); // Set pin 79 = WDT not GPIO/Output/Polarity=Invert
221
222 // disable the timeout
223 wdt_timeout_value(0);
224
225 // reset control register
226 wdt_timer_ctrl(0x00);
227
228 // reset configuration register
229 wdt_timer_conf(0x00);
230
231 // read old (timer units) register
232 old = read_io_cr(0xF1) & 0x7F;
233 if (unit == UNIT_SECOND) old |= 0x80; // set to seconds
234
235 // set the watchdog timer units
236 wdt_timer_units(old);
237
238 close_io_config();
239 spin_unlock(&io_lock);
240}
241
242/* shutdown the watchdog */
243
244static void wb_smsc_wdt_shutdown(void)
245{
246 spin_lock(&io_lock);
247 open_io_config();
248 select_io_device(IODEV_NO);
249
250 // disable the watchdog
251 gpio_bit13(0x09);
252 gpio_bit12(0x09);
253
254 // reset watchdog config register
255 wdt_timer_conf(0x00);
256
257 // reset watchdog control register
258 wdt_timer_ctrl(0x00);
259
260 // disable timeout
261 wdt_timeout_value(0x00);
262
263 close_io_config();
264 spin_unlock(&io_lock);
265}
266
267/* set timeout => enable watchdog */
268
269static void wb_smsc_wdt_set_timeout(unsigned char new_timeout)
270{
271 spin_lock(&io_lock);
272 open_io_config();
273 select_io_device(IODEV_NO);
274
275 // set Power LED to blink, if we enable the timeout
276 wdt_timer_ctrl((new_timeout == 0) ? 0x00 : 0x02);
277
278 // set timeout value
279 wdt_timeout_value(new_timeout);
280
281 close_io_config();
282 spin_unlock(&io_lock);
283}
284
285/* get timeout */
286
287static unsigned char wb_smsc_wdt_get_timeout(void)
288{
289 unsigned char set_timeout;
290
291 spin_lock(&io_lock);
292 open_io_config();
293 select_io_device(IODEV_NO);
294 set_timeout = read_io_cr(0xF2);
295 close_io_config();
296 spin_unlock(&io_lock);
297
298 return set_timeout;
299}
300
301/* disable watchdog */
302
303static void wb_smsc_wdt_disable(void)
304{
305 // set the timeout to 0 to disable the watchdog
306 wb_smsc_wdt_set_timeout(0);
307}
308
309/* enable watchdog by setting the current timeout */
310
311static void wb_smsc_wdt_enable(void)
312{
313 // set the current timeout...
314 wb_smsc_wdt_set_timeout(timeout);
315}
316
317/* reset the timer */
318
319static void wb_smsc_wdt_reset_timer(void)
320{
321 spin_lock(&io_lock);
322 open_io_config();
323 select_io_device(IODEV_NO);
324
325 // reset the timer
326 wdt_timeout_value(timeout);
327 wdt_timer_conf(0x08);
328
329 close_io_config();
330 spin_unlock(&io_lock);
331}
332
333/* return, if the watchdog is enabled (timeout is set...) */
334
335static int wb_smsc_wdt_status(void)
336{
337 return (wb_smsc_wdt_get_timeout() == 0) ? 0 : WDIOF_KEEPALIVEPING;
338}
339
340
341/* -- File operations -------------------------------------------*/
342
343/* open => enable watchdog and set initial timeout */
344
345static int wb_smsc_wdt_open(struct inode *inode, struct file *file)
346{
347 /* /dev/watchdog can only be opened once */
348
349 if (test_and_set_bit(0, &timer_enabled))
350 return -EBUSY;
351
352 if (nowayout)
353 __module_get(THIS_MODULE);
354
355 /* Reload and activate timer */
356 wb_smsc_wdt_enable();
357
358 printk(KERN_INFO MODNAME "Watchdog enabled. Timeout set to %d %s.\n", timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)");
359
360 return nonseekable_open(inode, file);
361}
362
363/* close => shut off the timer */
364
365static int wb_smsc_wdt_release(struct inode *inode, struct file *file)
366{
367 /* Shut off the timer. */
368
369 if (expect_close == 42) {
370 wb_smsc_wdt_disable();
371 printk(KERN_INFO MODNAME "Watchdog disabled, sleeping again...\n");
372 } else {
373 printk(KERN_CRIT MODNAME "Unexpected close, not stopping watchdog!\n");
374 wb_smsc_wdt_reset_timer();
375 }
376
377 clear_bit(0, &timer_enabled);
378 expect_close = 0;
379 return 0;
380}
381
382/* write => update the timer to keep the machine alive */
383
384static ssize_t wb_smsc_wdt_write(struct file *file, const char __user *data,
385 size_t len, loff_t *ppos)
386{
387 /* See if we got the magic character 'V' and reload the timer */
388 if (len) {
389 if (!nowayout) {
390 size_t i;
391
392 /* reset expect flag */
393 expect_close = 0;
394
395 /* scan to see whether or not we got the magic character */
396 for (i = 0; i != len; i++) {
397 char c;
398 if (get_user(c, data+i))
399 return -EFAULT;
400 if (c == 'V')
401 expect_close = 42;
402 }
403 }
404
405 /* someone wrote to us, we should reload the timer */
406 wb_smsc_wdt_reset_timer();
407 }
408 return len;
409}
410
411/* ioctl => control interface */
412
413static int wb_smsc_wdt_ioctl(struct inode *inode, struct file *file,
414 unsigned int cmd, unsigned long arg)
415{
416 int new_timeout;
417
418 union {
419 struct watchdog_info __user *ident;
420 int __user *i;
421 } uarg;
422
423 static struct watchdog_info ident = {
424 .options = WDIOF_KEEPALIVEPING |
425 WDIOF_SETTIMEOUT |
426 WDIOF_MAGICCLOSE,
427 .firmware_version = 0,
428 .identity = "SMsC 37B787 Watchdog"
429 };
430
431 uarg.i = (int __user *)arg;
432
433 switch (cmd) {
434 default:
435 return -ENOTTY;
436
437 case WDIOC_GETSUPPORT:
438 return copy_to_user(uarg.ident, &ident,
439 sizeof(ident)) ? -EFAULT : 0;
440
441 case WDIOC_GETSTATUS:
442 return put_user(wb_smsc_wdt_status(), uarg.i);
443
444 case WDIOC_GETBOOTSTATUS:
445 return put_user(0, uarg.i);
446
447 case WDIOC_KEEPALIVE:
448 wb_smsc_wdt_reset_timer();
449 return 0;
450
451 case WDIOC_SETTIMEOUT:
452 if (get_user(new_timeout, uarg.i))
453 return -EFAULT;
454
455 // the API states this is given in secs
456 if (unit == UNIT_MINUTE)
457 new_timeout /= 60;
458
459 if (new_timeout < 0 || new_timeout > MAX_TIMEOUT)
460 return -EINVAL;
461
462 timeout = new_timeout;
463 wb_smsc_wdt_set_timeout(timeout);
464
465 // fall through and return the new timeout...
466
467 case WDIOC_GETTIMEOUT:
468
469 new_timeout = timeout;
470
471 if (unit == UNIT_MINUTE)
472 new_timeout *= 60;
473
474 return put_user(new_timeout, uarg.i);
475
476 case WDIOC_SETOPTIONS:
477 {
478 int options, retval = -EINVAL;
479
480 if (get_user(options, uarg.i))
481 return -EFAULT;
482
483 if (options & WDIOS_DISABLECARD) {
484 wb_smsc_wdt_disable();
485 retval = 0;
486 }
487
488 if (options & WDIOS_ENABLECARD) {
489 wb_smsc_wdt_enable();
490 retval = 0;
491 }
492
493 return retval;
494 }
495 }
496}
497
498/* -- Notifier funtions -----------------------------------------*/
499
500static int wb_smsc_wdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused)
501{
502 if (code == SYS_DOWN || code == SYS_HALT)
503 {
504 // set timeout to 0, to avoid possible race-condition
505 timeout = 0;
506 wb_smsc_wdt_disable();
507 }
508 return NOTIFY_DONE;
509}
510
511/* -- Module's structures ---------------------------------------*/
512
513static struct file_operations wb_smsc_wdt_fops =
514{
515 .owner = THIS_MODULE,
516 .llseek = no_llseek,
517 .write = wb_smsc_wdt_write,
518 .ioctl = wb_smsc_wdt_ioctl,
519 .open = wb_smsc_wdt_open,
520 .release = wb_smsc_wdt_release,
521};
522
523static struct notifier_block wb_smsc_wdt_notifier =
524{
525 .notifier_call = wb_smsc_wdt_notify_sys,
526};
527
528static struct miscdevice wb_smsc_wdt_miscdev =
529{
530 .minor = WATCHDOG_MINOR,
531 .name = "watchdog",
532 .fops = &wb_smsc_wdt_fops,
533};
534
535/* -- Module init functions -------------------------------------*/
536
537/* module's "constructor" */
538
539static int __init wb_smsc_wdt_init(void)
540{
541 int ret;
542
543 spin_lock_init(&io_lock);
544
545 printk("SMsC 37B787 watchdog component driver " VERSION " initialising...\n");
546
547 if (!request_region(IOPORT, IOPORT_SIZE, "SMsC 37B787 watchdog")) {
548 printk(KERN_ERR MODNAME "Unable to register IO port %#x\n", IOPORT);
549 ret = -EBUSY;
550 goto out_pnp;
551 }
552
553 // set new maximum, if it's too big
554 if (timeout > MAX_TIMEOUT)
555 timeout = MAX_TIMEOUT;
556
557 // init the watchdog timer
558 wb_smsc_wdt_initialize();
559
560 ret = register_reboot_notifier(&wb_smsc_wdt_notifier);
561 if (ret) {
562 printk(KERN_ERR MODNAME "Unable to register reboot notifier err = %d\n", ret);
563 goto out_io;
564 }
565
566 ret = misc_register(&wb_smsc_wdt_miscdev);
567 if (ret) {
568 printk(KERN_ERR MODNAME "Unable to register miscdev on minor %d\n", WATCHDOG_MINOR);
569 goto out_rbt;
570 }
571
572 // output info
573 printk(KERN_INFO MODNAME "Timeout set to %d %s.\n", timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)");
574 printk(KERN_INFO MODNAME "Watchdog initialized and sleeping (nowayout=%d)...\n", nowayout);
575
576 // ret = 0
577
578out_clean:
579 return ret;
580
581out_rbt:
582 unregister_reboot_notifier(&wb_smsc_wdt_notifier);
583
584out_io:
585 release_region(IOPORT, IOPORT_SIZE);
586
587out_pnp:
588 goto out_clean;
589}
590
591/* module's "destructor" */
592
593static void __exit wb_smsc_wdt_exit(void)
594{
595 /* Stop the timer before we leave */
596 if (!nowayout)
597 {
598 wb_smsc_wdt_shutdown();
599 printk(KERN_INFO MODNAME "Watchdog disabled.\n");
600 }
601
602 misc_deregister(&wb_smsc_wdt_miscdev);
603 unregister_reboot_notifier(&wb_smsc_wdt_notifier);
604 release_region(IOPORT, IOPORT_SIZE);
605
606 printk("SMsC 37B787 watchdog component driver removed.\n");
607}
608
609module_init(wb_smsc_wdt_init);
610module_exit(wb_smsc_wdt_exit);
611
612MODULE_AUTHOR("Sven Anders <anders@anduras.de>");
613MODULE_DESCRIPTION("Driver for SMsC 37B787 watchdog component (Version " VERSION ")");
614MODULE_LICENSE("GPL");
615
616MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
617
618#ifdef SMSC_SUPPORT_MINUTES
619module_param(unit, int, 0);
620MODULE_PARM_DESC(unit, "set unit to use, 0=seconds or 1=minutes, default is 0");
621#endif
622
623module_param(timeout, int, 0);
624MODULE_PARM_DESC(timeout, "range is 1-255 units, default is 60");
625
626module_param(nowayout, int, 0);
627MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
diff --git a/drivers/char/watchdog/w83627hf_wdt.c b/drivers/char/watchdog/w83627hf_wdt.c
index b4adc527e687..07d4bff27226 100644
--- a/drivers/char/watchdog/w83627hf_wdt.c
+++ b/drivers/char/watchdog/w83627hf_wdt.c
@@ -33,6 +33,7 @@
33#include <linux/notifier.h> 33#include <linux/notifier.h>
34#include <linux/reboot.h> 34#include <linux/reboot.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/spinlock.h>
36 37
37#include <asm/io.h> 38#include <asm/io.h>
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
@@ -44,6 +45,7 @@
44 45
45static unsigned long wdt_is_open; 46static unsigned long wdt_is_open;
46static char expect_close; 47static char expect_close;
48static spinlock_t io_lock;
47 49
48/* You must set this - there is no sane way to probe for this board. */ 50/* You must set this - there is no sane way to probe for this board. */
49static int wdt_io = 0x2E; 51static int wdt_io = 0x2E;
@@ -110,12 +112,16 @@ w83627hf_init(void)
110static void 112static void
111wdt_ctrl(int timeout) 113wdt_ctrl(int timeout)
112{ 114{
115 spin_lock(&io_lock);
116
113 w83627hf_select_wd_register(); 117 w83627hf_select_wd_register();
114 118
115 outb_p(0xF6, WDT_EFER); /* Select CRF6 */ 119 outb_p(0xF6, WDT_EFER); /* Select CRF6 */
116 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF6 */ 120 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF6 */
117 121
118 w83627hf_unselect_wd_register(); 122 w83627hf_unselect_wd_register();
123
124 spin_unlock(&io_lock);
119} 125}
120 126
121static int 127static int
@@ -303,6 +309,8 @@ wdt_init(void)
303{ 309{
304 int ret; 310 int ret;
305 311
312 spin_lock_init(&io_lock);
313
306 printk(KERN_INFO "WDT driver for the Winbond(TM) W83627HF Super I/O chip initialising.\n"); 314 printk(KERN_INFO "WDT driver for the Winbond(TM) W83627HF Super I/O chip initialising.\n");
307 315
308 if (wdt_set_heartbeat(timeout)) { 316 if (wdt_set_heartbeat(timeout)) {
diff --git a/drivers/char/watchdog/w83697hf_wdt.c b/drivers/char/watchdog/w83697hf_wdt.c
new file mode 100644
index 000000000000..7768b55487c8
--- /dev/null
+++ b/drivers/char/watchdog/w83697hf_wdt.c
@@ -0,0 +1,450 @@
1/*
2 * w83697hf/hg WDT driver
3 *
4 * (c) Copyright 2006 Samuel Tardieu <sam@rfc1149.net>
5 * (c) Copyright 2006 Marcus Junker <junker@anduras.de>
6 *
7 * Based on w83627hf_wdt.c which is based on advantechwdt.c
8 * which is based on wdt.c.
9 * Original copyright messages:
10 *
11 * (c) Copyright 2003 Pádraig Brady <P@draigBrady.com>
12 *
13 * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl>
14 *
15 * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved.
16 * http://www.redhat.com
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
22 *
23 * Neither Marcus Junker nor ANDURAS AG admit liability nor provide
24 * warranty for any of this software. This material is provided
25 * "AS-IS" and at no charge.
26 */
27
28#include <linux/module.h>
29#include <linux/moduleparam.h>
30#include <linux/types.h>
31#include <linux/miscdevice.h>
32#include <linux/watchdog.h>
33#include <linux/fs.h>
34#include <linux/ioport.h>
35#include <linux/notifier.h>
36#include <linux/reboot.h>
37#include <linux/init.h>
38#include <linux/spinlock.h>
39
40#include <asm/io.h>
41#include <asm/uaccess.h>
42#include <asm/system.h>
43
44#define WATCHDOG_NAME "w83697hf/hg WDT"
45#define PFX WATCHDOG_NAME ": "
46#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
47
48static unsigned long wdt_is_open;
49static char expect_close;
50static spinlock_t io_lock;
51
52/* You must set this - there is no sane way to probe for this board. */
53static int wdt_io = 0x2e;
54module_param(wdt_io, int, 0);
55MODULE_PARM_DESC(wdt_io, "w83697hf/hg WDT io port (default 0x2e, 0 = autodetect)");
56
57static int timeout = WATCHDOG_TIMEOUT; /* in seconds */
58module_param(timeout, int, 0);
59MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
60
61static int nowayout = WATCHDOG_NOWAYOUT;
62module_param(nowayout, int, 0);
63MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
64
65/*
66 * Kernel methods.
67 */
68
69#define W83697HF_EFER (wdt_io+0) /* Extended Function Enable Register */
70#define W83697HF_EFIR (wdt_io+0) /* Extended Function Index Register (same as EFER) */
71#define W83697HF_EFDR (wdt_io+1) /* Extended Function Data Register */
72
73static inline void
74w83697hf_unlock(void)
75{
76 outb_p(0x87, W83697HF_EFER); /* Enter extended function mode */
77 outb_p(0x87, W83697HF_EFER); /* Again according to manual */
78}
79
80static inline void
81w83697hf_lock(void)
82{
83 outb_p(0xAA, W83697HF_EFER); /* Leave extended function mode */
84}
85
86/*
87 * The three functions w83697hf_get_reg(), w83697hf_set_reg() and
88 * w83697hf_write_timeout() must be called with the device unlocked.
89 */
90
91static unsigned char
92w83697hf_get_reg(unsigned char reg)
93{
94 outb_p(reg, W83697HF_EFIR);
95 return inb_p(W83697HF_EFDR);
96}
97
98static void
99w83697hf_set_reg(unsigned char reg, unsigned char data)
100{
101 outb_p(reg, W83697HF_EFIR);
102 outb_p(data, W83697HF_EFDR);
103}
104
105static void
106w83697hf_write_timeout(int timeout)
107{
108 w83697hf_set_reg(0xF4, timeout); /* Write Timeout counter to CRF4 */
109}
110
111static void
112w83697hf_select_wdt(void)
113{
114 w83697hf_unlock();
115 w83697hf_set_reg(0x07, 0x08); /* Switch to logic device 8 (GPIO2) */
116}
117
118static inline void
119w83697hf_deselect_wdt(void)
120{
121 w83697hf_lock();
122}
123
124static void
125w83697hf_init(void)
126{
127 unsigned char bbuf;
128
129 w83697hf_select_wdt();
130
131 bbuf = w83697hf_get_reg(0x29);
132 bbuf &= ~0x60;
133 bbuf |= 0x20;
134 w83697hf_set_reg(0x29, bbuf); /* Set pin 119 to WDTO# mode (= CR29, WDT0) */
135
136 bbuf = w83697hf_get_reg(0xF3);
137 bbuf &= ~0x04;
138 w83697hf_set_reg(0xF3, bbuf); /* Count mode is seconds */
139
140 w83697hf_deselect_wdt();
141}
142
143static int
144wdt_ping(void)
145{
146 spin_lock(&io_lock);
147 w83697hf_select_wdt();
148
149 w83697hf_write_timeout(timeout);
150
151 w83697hf_deselect_wdt();
152 spin_unlock(&io_lock);
153 return 0;
154}
155
156static int
157wdt_enable(void)
158{
159 spin_lock(&io_lock);
160 w83697hf_select_wdt();
161
162 w83697hf_write_timeout(timeout);
163 w83697hf_set_reg(0x30, 1); /* Enable timer */
164
165 w83697hf_deselect_wdt();
166 spin_unlock(&io_lock);
167 return 0;
168}
169
170static int
171wdt_disable(void)
172{
173 spin_lock(&io_lock);
174 w83697hf_select_wdt();
175
176 w83697hf_set_reg(0x30, 0); /* Disable timer */
177 w83697hf_write_timeout(0);
178
179 w83697hf_deselect_wdt();
180 spin_unlock(&io_lock);
181 return 0;
182}
183
184static int
185wdt_set_heartbeat(int t)
186{
187 if ((t < 1) || (t > 255))
188 return -EINVAL;
189
190 timeout = t;
191 return 0;
192}
193
194static ssize_t
195wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
196{
197 if (count) {
198 if (!nowayout) {
199 size_t i;
200
201 expect_close = 0;
202
203 for (i = 0; i != count; i++) {
204 char c;
205 if (get_user(c, buf+i))
206 return -EFAULT;
207 if (c == 'V')
208 expect_close = 42;
209 }
210 }
211 wdt_ping();
212 }
213 return count;
214}
215
216static int
217wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
218 unsigned long arg)
219{
220 void __user *argp = (void __user *)arg;
221 int __user *p = argp;
222 int new_timeout;
223 static struct watchdog_info ident = {
224 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
225 .firmware_version = 1,
226 .identity = "W83697HF WDT",
227 };
228
229 switch (cmd) {
230 case WDIOC_GETSUPPORT:
231 if (copy_to_user(argp, &ident, sizeof(ident)))
232 return -EFAULT;
233 break;
234
235 case WDIOC_GETSTATUS:
236 case WDIOC_GETBOOTSTATUS:
237 return put_user(0, p);
238
239 case WDIOC_KEEPALIVE:
240 wdt_ping();
241 break;
242
243 case WDIOC_SETTIMEOUT:
244 if (get_user(new_timeout, p))
245 return -EFAULT;
246 if (wdt_set_heartbeat(new_timeout))
247 return -EINVAL;
248 wdt_ping();
249 /* Fall */
250
251 case WDIOC_GETTIMEOUT:
252 return put_user(timeout, p);
253
254 case WDIOC_SETOPTIONS:
255 {
256 int options, retval = -EINVAL;
257
258 if (get_user(options, p))
259 return -EFAULT;
260
261 if (options & WDIOS_DISABLECARD) {
262 wdt_disable();
263 retval = 0;
264 }
265
266 if (options & WDIOS_ENABLECARD) {
267 wdt_enable();
268 retval = 0;
269 }
270
271 return retval;
272 }
273
274 default:
275 return -ENOTTY;
276 }
277 return 0;
278}
279
280static int
281wdt_open(struct inode *inode, struct file *file)
282{
283 if (test_and_set_bit(0, &wdt_is_open))
284 return -EBUSY;
285 /*
286 * Activate
287 */
288
289 wdt_enable();
290 return nonseekable_open(inode, file);
291}
292
293static int
294wdt_close(struct inode *inode, struct file *file)
295{
296 if (expect_close == 42) {
297 wdt_disable();
298 } else {
299 printk (KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
300 wdt_ping();
301 }
302 expect_close = 0;
303 clear_bit(0, &wdt_is_open);
304 return 0;
305}
306
307/*
308 * Notifier for system down
309 */
310
311static int
312wdt_notify_sys(struct notifier_block *this, unsigned long code,
313 void *unused)
314{
315 if (code == SYS_DOWN || code == SYS_HALT) {
316 /* Turn the WDT off */
317 wdt_disable();
318 }
319 return NOTIFY_DONE;
320}
321
322/*
323 * Kernel Interfaces
324 */
325
326static struct file_operations wdt_fops = {
327 .owner = THIS_MODULE,
328 .llseek = no_llseek,
329 .write = wdt_write,
330 .ioctl = wdt_ioctl,
331 .open = wdt_open,
332 .release = wdt_close,
333};
334
335static struct miscdevice wdt_miscdev = {
336 .minor = WATCHDOG_MINOR,
337 .name = "watchdog",
338 .fops = &wdt_fops,
339};
340
341/*
342 * The WDT needs to learn about soft shutdowns in order to
343 * turn the timebomb registers off.
344 */
345
346static struct notifier_block wdt_notifier = {
347 .notifier_call = wdt_notify_sys,
348};
349
350static int
351w83697hf_check_wdt(void)
352{
353 if (!request_region(wdt_io, 2, WATCHDOG_NAME)) {
354 printk (KERN_ERR PFX "I/O address 0x%x already in use\n", wdt_io);
355 return -EIO;
356 }
357
358 printk (KERN_DEBUG PFX "Looking for watchdog at address 0x%x\n", wdt_io);
359 w83697hf_unlock();
360 if (w83697hf_get_reg(0x20) == 0x60) {
361 printk (KERN_INFO PFX "watchdog found at address 0x%x\n", wdt_io);
362 w83697hf_lock();
363 return 0;
364 }
365 w83697hf_lock(); /* Reprotect in case it was a compatible device */
366
367 printk (KERN_INFO PFX "watchdog not found at address 0x%x\n", wdt_io);
368 release_region(wdt_io, 2);
369 return -EIO;
370}
371
372static int w83697hf_ioports[] = { 0x2e, 0x4e, 0x00 };
373
374static int __init
375wdt_init(void)
376{
377 int ret, i, found = 0;
378
379 spin_lock_init(&io_lock);
380
381 printk (KERN_INFO PFX "WDT driver for W83697HF/HG initializing\n");
382
383 if (wdt_io == 0) {
384 /* we will autodetect the W83697HF/HG watchdog */
385 for (i = 0; ((!found) && (w83697hf_ioports[i] != 0)); i++) {
386 wdt_io = w83697hf_ioports[i];
387 if (!w83697hf_check_wdt())
388 found++;
389 }
390 } else {
391 if (!w83697hf_check_wdt())
392 found++;
393 }
394
395 if (!found) {
396 printk (KERN_ERR PFX "No W83697HF/HG could be found\n");
397 ret = -EIO;
398 goto out;
399 }
400
401 w83697hf_init();
402 wdt_disable(); /* Disable watchdog until first use */
403
404 if (wdt_set_heartbeat(timeout)) {
405 wdt_set_heartbeat(WATCHDOG_TIMEOUT);
406 printk (KERN_INFO PFX "timeout value must be 1<=timeout<=255, using %d\n",
407 WATCHDOG_TIMEOUT);
408 }
409
410 ret = register_reboot_notifier(&wdt_notifier);
411 if (ret != 0) {
412 printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
413 ret);
414 goto unreg_regions;
415 }
416
417 ret = misc_register(&wdt_miscdev);
418 if (ret != 0) {
419 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
420 WATCHDOG_MINOR, ret);
421 goto unreg_reboot;
422 }
423
424 printk (KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
425 timeout, nowayout);
426
427out:
428 return ret;
429unreg_reboot:
430 unregister_reboot_notifier(&wdt_notifier);
431unreg_regions:
432 release_region(wdt_io, 2);
433 goto out;
434}
435
436static void __exit
437wdt_exit(void)
438{
439 misc_deregister(&wdt_miscdev);
440 unregister_reboot_notifier(&wdt_notifier);
441 release_region(wdt_io, 2);
442}
443
444module_init(wdt_init);
445module_exit(wdt_exit);
446
447MODULE_LICENSE("GPL");
448MODULE_AUTHOR("Marcus Junker <junker@anduras.de>, Samuel Tardieu <sam@rfc1149.net>");
449MODULE_DESCRIPTION("w83697hf/hg WDT driver");
450MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index 7ad3be8c0f49..7fcb77a9d011 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -54,8 +54,8 @@ static cycle_t acpi_pm_read_verified(void)
54 v1 = read_pmtmr(); 54 v1 = read_pmtmr();
55 v2 = read_pmtmr(); 55 v2 = read_pmtmr();
56 v3 = read_pmtmr(); 56 v3 = read_pmtmr();
57 } while ((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) 57 } while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
58 || (v3 > v1 && v3 < v2)); 58 || (v3 > v1 && v3 < v2)));
59 59
60 return (cycle_t)v2; 60 return (cycle_t)v2;
61} 61}
@@ -138,6 +138,8 @@ static void __devinit acpi_pm_check_graylist(struct pci_dev *dev)
138} 138}
139DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, 139DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,
140 acpi_pm_check_graylist); 140 acpi_pm_check_graylist);
141DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
142 acpi_pm_check_graylist);
141#endif 143#endif
142 144
143 145
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 2cc71b66231e..491779af8d55 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -107,6 +107,7 @@ config CPU_FREQ_GOV_USERSPACE
107 107
108config CPU_FREQ_GOV_ONDEMAND 108config CPU_FREQ_GOV_ONDEMAND
109 tristate "'ondemand' cpufreq policy governor" 109 tristate "'ondemand' cpufreq policy governor"
110 select CPU_FREQ_TABLE
110 help 111 help
111 'ondemand' - This driver adds a dynamic cpufreq policy governor. 112 'ondemand' - This driver adds a dynamic cpufreq policy governor.
112 The governor does a periodic polling and 113 The governor does a periodic polling and
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 86e69b7f9122..dd0c2623e27b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -59,7 +59,7 @@ static int __init init_cpufreq_transition_notifier_list(void)
59 srcu_init_notifier_head(&cpufreq_transition_notifier_list); 59 srcu_init_notifier_head(&cpufreq_transition_notifier_list);
60 return 0; 60 return 0;
61} 61}
62core_initcall(init_cpufreq_transition_notifier_list); 62pure_initcall(init_cpufreq_transition_notifier_list);
63 63
64static LIST_HEAD(cpufreq_governor_list); 64static LIST_HEAD(cpufreq_governor_list);
65static DEFINE_MUTEX (cpufreq_governor_mutex); 65static DEFINE_MUTEX (cpufreq_governor_mutex);
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 4bde30bb3be7..75e9e38330ff 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -230,34 +230,43 @@ static struct kobj_type ktype_memctrl = {
230 */ 230 */
231static int edac_sysfs_memctrl_setup(void) 231static int edac_sysfs_memctrl_setup(void)
232{ 232{
233 int err=0; 233 int err = 0;
234 234
235 debugf1("%s()\n", __func__); 235 debugf1("%s()\n", __func__);
236 236
237 /* create the /sys/devices/system/edac directory */ 237 /* create the /sys/devices/system/edac directory */
238 err = sysdev_class_register(&edac_class); 238 err = sysdev_class_register(&edac_class);
239 239
240 if (!err) { 240 if (err) {
241 /* Init the MC's kobject */ 241 debugf1("%s() error=%d\n", __func__, err);
242 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj)); 242 return err;
243 edac_memctrl_kobj.parent = &edac_class.kset.kobj; 243 }
244 edac_memctrl_kobj.ktype = &ktype_memctrl;
245 244
246 /* generate sysfs "..../edac/mc" */ 245 /* Init the MC's kobject */
247 err = kobject_set_name(&edac_memctrl_kobj,"mc"); 246 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
247 edac_memctrl_kobj.parent = &edac_class.kset.kobj;
248 edac_memctrl_kobj.ktype = &ktype_memctrl;
248 249
249 if (!err) { 250 /* generate sysfs "..../edac/mc" */
250 /* FIXME: maybe new sysdev_create_subdir() */ 251 err = kobject_set_name(&edac_memctrl_kobj,"mc");
251 err = kobject_register(&edac_memctrl_kobj);
252 252
253 if (err) 253 if (err)
254 debugf1("Failed to register '.../edac/mc'\n"); 254 goto fail;
255 else 255
256 debugf1("Registered '.../edac/mc' kobject\n"); 256 /* FIXME: maybe new sysdev_create_subdir() */
257 } 257 err = kobject_register(&edac_memctrl_kobj);
258 } else 258
259 debugf1("%s() error=%d\n", __func__, err); 259 if (err) {
260 debugf1("Failed to register '.../edac/mc'\n");
261 goto fail;
262 }
260 263
264 debugf1("Registered '.../edac/mc' kobject\n");
265
266 return 0;
267
268fail:
269 sysdev_class_unregister(&edac_class);
261 return err; 270 return err;
262} 271}
263 272
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c
index 22d17474755f..ca4e67a022d0 100644
--- a/drivers/fc4/fc.c
+++ b/drivers/fc4/fc.c
@@ -70,9 +70,9 @@
70 70
71#define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp)) 71#define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp))
72#define FC_SCMND(SCpnt) ((fc_channel *)(SCpnt->device->host->hostdata[0])) 72#define FC_SCMND(SCpnt) ((fc_channel *)(SCpnt->device->host->hostdata[0]))
73#define SC_FCMND(fcmnd) ((Scsi_Cmnd *)((long)fcmnd - (long)&(((Scsi_Cmnd *)0)->SCp))) 73#define SC_FCMND(fcmnd) ((struct scsi_cmnd *)((long)fcmnd - (long)&(((struct scsi_cmnd *)0)->SCp)))
74 74
75static int fcp_scsi_queue_it(fc_channel *, Scsi_Cmnd *, fcp_cmnd *, int); 75static int fcp_scsi_queue_it(fc_channel *, struct scsi_cmnd *, fcp_cmnd *, int);
76void fcp_queue_empty(fc_channel *); 76void fcp_queue_empty(fc_channel *);
77 77
78static void fcp_scsi_insert_queue (fc_channel *fc, fcp_cmnd *fcmd) 78static void fcp_scsi_insert_queue (fc_channel *fc, fcp_cmnd *fcmd)
@@ -378,14 +378,14 @@ void fcp_register(fc_channel *fc, u8 type, int unregister)
378 printk ("FC: %segistering unknown type %02x\n", unregister ? "Unr" : "R", type); 378 printk ("FC: %segistering unknown type %02x\n", unregister ? "Unr" : "R", type);
379} 379}
380 380
381static void fcp_scsi_done(Scsi_Cmnd *SCpnt); 381static void fcp_scsi_done(struct scsi_cmnd *SCpnt);
382 382
383static inline void fcp_scsi_receive(fc_channel *fc, int token, int status, fc_hdr *fch) 383static inline void fcp_scsi_receive(fc_channel *fc, int token, int status, fc_hdr *fch)
384{ 384{
385 fcp_cmnd *fcmd; 385 fcp_cmnd *fcmd;
386 fcp_rsp *rsp; 386 fcp_rsp *rsp;
387 int host_status; 387 int host_status;
388 Scsi_Cmnd *SCpnt; 388 struct scsi_cmnd *SCpnt;
389 int sense_len; 389 int sense_len;
390 int rsp_status; 390 int rsp_status;
391 391
@@ -757,13 +757,14 @@ void fcp_release(fc_channel *fcchain, int count) /* count must > 0 */
757} 757}
758 758
759 759
760static void fcp_scsi_done (Scsi_Cmnd *SCpnt) 760static void fcp_scsi_done(struct scsi_cmnd *SCpnt)
761{ 761{
762 if (FCP_CMND(SCpnt)->done) 762 if (FCP_CMND(SCpnt)->done)
763 FCP_CMND(SCpnt)->done(SCpnt); 763 FCP_CMND(SCpnt)->done(SCpnt);
764} 764}
765 765
766static int fcp_scsi_queue_it(fc_channel *fc, Scsi_Cmnd *SCpnt, fcp_cmnd *fcmd, int prepare) 766static int fcp_scsi_queue_it(fc_channel *fc, struct scsi_cmnd *SCpnt,
767 fcp_cmnd *fcmd, int prepare)
767{ 768{
768 long i; 769 long i;
769 fcp_cmd *cmd; 770 fcp_cmd *cmd;
@@ -837,7 +838,8 @@ static int fcp_scsi_queue_it(fc_channel *fc, Scsi_Cmnd *SCpnt, fcp_cmnd *fcmd, i
837 return 0; 838 return 0;
838} 839}
839 840
840int fcp_scsi_queuecommand(Scsi_Cmnd *SCpnt, void (* done)(Scsi_Cmnd *)) 841int fcp_scsi_queuecommand(struct scsi_cmnd *SCpnt,
842 void (* done)(struct scsi_cmnd *))
841{ 843{
842 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 844 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
843 fc_channel *fc = FC_SCMND(SCpnt); 845 fc_channel *fc = FC_SCMND(SCpnt);
@@ -873,7 +875,7 @@ void fcp_queue_empty(fc_channel *fc)
873 } 875 }
874} 876}
875 877
876int fcp_scsi_abort(Scsi_Cmnd *SCpnt) 878int fcp_scsi_abort(struct scsi_cmnd *SCpnt)
877{ 879{
878 /* Internal bookkeeping only. Lose 1 cmd_slots slot. */ 880 /* Internal bookkeeping only. Lose 1 cmd_slots slot. */
879 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 881 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
@@ -910,7 +912,7 @@ int fcp_scsi_abort(Scsi_Cmnd *SCpnt)
910} 912}
911 913
912#if 0 914#if 0
913void fcp_scsi_reset_done(Scsi_Cmnd *SCpnt) 915void fcp_scsi_reset_done(struct scsi_cmnd *SCpnt)
914{ 916{
915 fc_channel *fc = FC_SCMND(SCpnt); 917 fc_channel *fc = FC_SCMND(SCpnt);
916 918
@@ -921,7 +923,7 @@ void fcp_scsi_reset_done(Scsi_Cmnd *SCpnt)
921 923
922#define FCP_RESET_TIMEOUT (2*HZ) 924#define FCP_RESET_TIMEOUT (2*HZ)
923 925
924int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt) 926int fcp_scsi_dev_reset(struct scsi_cmnd *SCpnt)
925{ 927{
926#if 0 /* broken junk, but if davem wants to compile this driver, let him.. */ 928#if 0 /* broken junk, but if davem wants to compile this driver, let him.. */
927 unsigned long flags; 929 unsigned long flags;
@@ -931,7 +933,7 @@ int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
931 DECLARE_MUTEX_LOCKED(sem); 933 DECLARE_MUTEX_LOCKED(sem);
932 934
933 if (!fc->rst_pkt) { 935 if (!fc->rst_pkt) {
934 fc->rst_pkt = (Scsi_Cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL); 936 fc->rst_pkt = (struct scsi_cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL);
935 if (!fc->rst_pkt) return FAILED; 937 if (!fc->rst_pkt) return FAILED;
936 938
937 fcmd = FCP_CMND(fc->rst_pkt); 939 fcmd = FCP_CMND(fc->rst_pkt);
@@ -999,7 +1001,7 @@ int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
999 return SUCCESS; 1001 return SUCCESS;
1000} 1002}
1001 1003
1002static int __fcp_scsi_host_reset(Scsi_Cmnd *SCpnt) 1004static int __fcp_scsi_host_reset(struct scsi_cmnd *SCpnt)
1003{ 1005{
1004 fc_channel *fc = FC_SCMND(SCpnt); 1006 fc_channel *fc = FC_SCMND(SCpnt);
1005 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 1007 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
@@ -1020,7 +1022,7 @@ static int __fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
1020 else return FAILED; 1022 else return FAILED;
1021} 1023}
1022 1024
1023int fcp_scsi_host_reset(Scsi_Cmnd *SCpnt) 1025int fcp_scsi_host_reset(struct scsi_cmnd *SCpnt)
1024{ 1026{
1025 unsigned long flags; 1027 unsigned long flags;
1026 int rc; 1028 int rc;
diff --git a/drivers/fc4/fcp_impl.h b/drivers/fc4/fcp_impl.h
index c397c84bef63..1ac61330592e 100644
--- a/drivers/fc4/fcp_impl.h
+++ b/drivers/fc4/fcp_impl.h
@@ -39,7 +39,7 @@ struct _fc_channel;
39typedef struct fcp_cmnd { 39typedef struct fcp_cmnd {
40 struct fcp_cmnd *next; 40 struct fcp_cmnd *next;
41 struct fcp_cmnd *prev; 41 struct fcp_cmnd *prev;
42 void (*done)(Scsi_Cmnd *); 42 void (*done)(struct scsi_cmnd *);
43 unsigned short proto; 43 unsigned short proto;
44 unsigned short token; 44 unsigned short token;
45 unsigned int did; 45 unsigned int did;
@@ -94,14 +94,14 @@ typedef struct _fc_channel {
94 long *scsi_bitmap; 94 long *scsi_bitmap;
95 long scsi_bitmap_end; 95 long scsi_bitmap_end;
96 int scsi_free; 96 int scsi_free;
97 int (*encode_addr)(Scsi_Cmnd *, u16 *, struct _fc_channel *, fcp_cmnd *); 97 int (*encode_addr)(struct scsi_cmnd *, u16 *, struct _fc_channel *, fcp_cmnd *);
98 fcp_cmnd *scsi_que; 98 fcp_cmnd *scsi_que;
99 char scsi_name[4]; 99 char scsi_name[4];
100 fcp_cmnd **cmd_slots; 100 fcp_cmnd **cmd_slots;
101 int channels; 101 int channels;
102 int targets; 102 int targets;
103 long *ages; 103 long *ages;
104 Scsi_Cmnd *rst_pkt; 104 struct scsi_cmnd *rst_pkt;
105 fcp_posmap *posmap; 105 fcp_posmap *posmap;
106 /* LOGIN stuff */ 106 /* LOGIN stuff */
107 fcp_cmnd *login; 107 fcp_cmnd *login;
@@ -155,9 +155,10 @@ int fc_do_prli(fc_channel *, unsigned char);
155 for_each_fc_channel(fc) \ 155 for_each_fc_channel(fc) \
156 if (fc->state == FC_STATE_ONLINE) 156 if (fc->state == FC_STATE_ONLINE)
157 157
158int fcp_scsi_queuecommand(Scsi_Cmnd *, void (* done)(Scsi_Cmnd *)); 158int fcp_scsi_queuecommand(struct scsi_cmnd *,
159int fcp_scsi_abort(Scsi_Cmnd *); 159 void (* done) (struct scsi_cmnd *));
160int fcp_scsi_dev_reset(Scsi_Cmnd *); 160int fcp_scsi_abort(struct scsi_cmnd *);
161int fcp_scsi_host_reset(Scsi_Cmnd *); 161int fcp_scsi_dev_reset(struct scsi_cmnd *);
162int fcp_scsi_host_reset(struct scsi_cmnd *);
162 163
163#endif /* !(_FCP_SCSI_H) */ 164#endif /* !(_FCP_SCSI_H) */
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 08b161798443..fc702e40bd43 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -705,17 +705,16 @@ static struct bin_attribute rbu_packet_size_attr = {
705 705
706static int __init dcdrbu_init(void) 706static int __init dcdrbu_init(void)
707{ 707{
708 int rc = 0; 708 int rc;
709 spin_lock_init(&rbu_data.lock); 709 spin_lock_init(&rbu_data.lock);
710 710
711 init_packet_head(); 711 init_packet_head();
712 rbu_device = 712 rbu_device = platform_device_register_simple("dell_rbu", -1, NULL, 0);
713 platform_device_register_simple("dell_rbu", -1, NULL, 0); 713 if (IS_ERR(rbu_device)) {
714 if (!rbu_device) {
715 printk(KERN_ERR 714 printk(KERN_ERR
716 "dell_rbu:%s:platform_device_register_simple " 715 "dell_rbu:%s:platform_device_register_simple "
717 "failed\n", __FUNCTION__); 716 "failed\n", __FUNCTION__);
718 return -EIO; 717 return PTR_ERR(rbu_device);
719 } 718 }
720 719
721 rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr); 720 rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index b8b596d5778d..37deee6c0c1c 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -326,6 +326,26 @@ char *dmi_get_system_info(int field)
326} 326}
327EXPORT_SYMBOL(dmi_get_system_info); 327EXPORT_SYMBOL(dmi_get_system_info);
328 328
329
330/**
331 * dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information.
332 * @str: Case sensitive Name
333 */
334int dmi_name_in_vendors(char *str)
335{
336 static int fields[] = { DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_SYS_VENDOR,
337 DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR,
338 DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_NONE };
339 int i;
340 for (i = 0; fields[i] != DMI_NONE; i++) {
341 int f = fields[i];
342 if (dmi_ident[f] && strstr(dmi_ident[f], str))
343 return 1;
344 }
345 return 0;
346}
347EXPORT_SYMBOL(dmi_name_in_vendors);
348
329/** 349/**
330 * dmi_find_device - find onboard device by type/name 350 * dmi_find_device - find onboard device by type/name
331 * @type: device type or %DMI_DEV_TYPE_ANY to match all device types 351 * @type: device type or %DMI_DEV_TYPE_ANY to match all device types
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index 1ce01fb0ac09..68fe863f9d54 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -137,7 +137,8 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
137 gpio_line_set(gpio->scl_pin, 0); 137 gpio_line_set(gpio->scl_pin, 0);
138 gpio_line_set(gpio->sda_pin, 0); 138 gpio_line_set(gpio->sda_pin, 0);
139 139
140 if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) { 140 err = i2c_bit_add_bus(&drv_data->adapter);
141 if (err) {
141 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id); 142 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id);
142 143
143 kfree(drv_data); 144 kfree(drv_data);
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 81050d3c9b21..c95a6c154165 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -272,7 +272,8 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c)
272 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", 272 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n",
273 __func__, (long)jiffies, ISR, ICR, IBMR); 273 __func__, (long)jiffies, ISR, ICR, IBMR);
274 274
275 if ((ISR & (ISR_UB|ISR_IBB|ISR_SAD)) == ISR_SAD || 275 if ((ISR & (ISR_UB|ISR_IBB)) == 0 ||
276 (ISR & ISR_SAD) != 0 ||
276 (ICR & ICR_SCLE) == 0) { 277 (ICR & ICR_SCLE) == 0) {
277 if (i2c_debug > 1) 278 if (i2c_debug > 1)
278 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__); 279 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
@@ -492,7 +493,10 @@ static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr)
492 if (isr & ISR_BED) { 493 if (isr & ISR_BED) {
493 /* what should we do here? */ 494 /* what should we do here? */
494 } else { 495 } else {
495 int ret = i2c->slave->read(i2c->slave->data); 496 int ret = 0;
497
498 if (i2c->slave != NULL)
499 ret = i2c->slave->read(i2c->slave->data);
496 500
497 IDBR = ret; 501 IDBR = ret;
498 ICR |= ICR_TB; /* allow next byte */ 502 ICR |= ICR_TB; /* allow next byte */
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 32aab0d34ee9..714bae780953 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -494,11 +494,12 @@ static __init int scx200_create_pci(const char *text, struct pci_dev *pdev,
494 iface->pdev = pdev; 494 iface->pdev = pdev;
495 iface->bar = bar; 495 iface->bar = bar;
496 496
497 pci_enable_device_bars(iface->pdev, 1 << iface->bar); 497 rc = pci_enable_device_bars(iface->pdev, 1 << iface->bar);
498 if (rc)
499 goto errout_free;
498 500
499 rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name); 501 rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name);
500 502 if (rc) {
501 if (rc != 0) {
502 printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n", 503 printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n",
503 iface->bar); 504 iface->bar);
504 goto errout_free; 505 goto errout_free;
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index bddfebdf91d8..88214943d00a 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -724,7 +724,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
724 * if we have an error, pass back CHECK_CONDITION as the 724 * if we have an error, pass back CHECK_CONDITION as the
725 * scsi status byte 725 * scsi status byte
726 */ 726 */
727 if (!rq->errors) 727 if (blk_pc_request(rq) && !rq->errors)
728 rq->errors = SAM_STAT_CHECK_CONDITION; 728 rq->errors = SAM_STAT_CHECK_CONDITION;
729 729
730 /* Check for tray open. */ 730 /* Check for tray open. */
diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c
index b1d5291531b7..45ed03591cd8 100644
--- a/drivers/ide/legacy/hd.c
+++ b/drivers/ide/legacy/hd.c
@@ -459,7 +459,7 @@ ok_to_read:
459#ifdef DEBUG 459#ifdef DEBUG
460 printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n", 460 printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
461 req->rq_disk->disk_name, req->sector, req->nr_sectors, 461 req->rq_disk->disk_name, req->sector, req->nr_sectors,
462 req->buffer+512)); 462 req->buffer+512);
463#endif 463#endif
464 if (req->current_nr_sectors <= 0) 464 if (req->current_nr_sectors <= 0)
465 end_request(req, 1); 465 end_request(req, 1);
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 2b0ea8b6608d..753fe0e21456 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -75,6 +75,7 @@ static struct amd_ide_chip {
75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, AMD_UDMA_133 }, 75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, AMD_UDMA_133 },
76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 }, 76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 },
77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 }, 77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 }, 79 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 },
79 { 0 } 80 { 0 }
80}; 81};
@@ -491,7 +492,8 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
491 /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"), 492 /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"),
492 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"), 493 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"),
493 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"), 494 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"),
494 /* 19 */ DECLARE_AMD_DEV("AMD5536"), 495 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"),
496 /* 20 */ DECLARE_AMD_DEV("AMD5536"),
495}; 497};
496 498
497static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 499static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -530,7 +532,8 @@ static struct pci_device_id amd74xx_pci_tbl[] = {
530 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 }, 532 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 },
531 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 }, 533 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 },
532 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 }, 534 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 },
533 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 }, 535 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 },
536 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 },
534 { 0, }, 537 { 0, },
535}; 538};
536MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 539MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index 5b77a5bcbf0c..9f306880491a 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -40,6 +40,19 @@
40 40
41static int ide_generic_all; /* Set to claim all devices */ 41static int ide_generic_all; /* Set to claim all devices */
42 42
43/*
44 * the module_param_named() was added for the modular case
45 * the __setup() is left as compatibility for existing setups
46 */
47#ifndef MODULE
48static int __init ide_generic_all_on(char *unused)
49{
50 ide_generic_all = 1;
51 printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n");
52 return 1;
53}
54__setup("all-generic-ide", ide_generic_all_on);
55#endif
43module_param_named(all_generic_ide, ide_generic_all, bool, 0444); 56module_param_named(all_generic_ide, ide_generic_all, bool, 0444);
44MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); 57MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers.");
45 58
@@ -234,8 +247,10 @@ static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_devi
234 (!(PCI_FUNC(dev->devfn) & 1))) 247 (!(PCI_FUNC(dev->devfn) & 1)))
235 goto out; 248 goto out;
236 249
237 if (dev->vendor == PCI_VENDOR_ID_JMICRON && PCI_FUNC(dev->devfn) != 1) 250 if (dev->vendor == PCI_VENDOR_ID_JMICRON) {
238 goto out; 251 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 && PCI_FUNC(dev->devfn) != 1)
252 goto out;
253 }
239 254
240 if (dev->vendor != PCI_VENDOR_ID_JMICRON) { 255 if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
241 pci_read_config_word(dev, PCI_COMMAND, &command); 256 pci_read_config_word(dev, PCI_COMMAND, &command);
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 244f7eb7006d..cfad09accf52 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -768,14 +768,7 @@ ioc4_ide_init(void)
768 return ioc4_register_submodule(&ioc4_ide_submodule); 768 return ioc4_register_submodule(&ioc4_ide_submodule);
769} 769}
770 770
771static void __devexit
772ioc4_ide_exit(void)
773{
774 ioc4_unregister_submodule(&ioc4_ide_submodule);
775}
776
777late_initcall(ioc4_ide_init); /* Call only after IDE init is done */ 771late_initcall(ioc4_ide_init); /* Call only after IDE init is done */
778module_exit(ioc4_ide_exit);
779 772
780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon"); 773MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
781MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card"); 774MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card");
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 8a7b8fab6238..31e5cc49d61a 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -64,6 +64,7 @@
64#include <linux/ethtool.h> 64#include <linux/ethtool.h>
65#include <asm/uaccess.h> 65#include <asm/uaccess.h>
66#include <asm/delay.h> 66#include <asm/delay.h>
67#include <asm/unaligned.h>
67#include <net/arp.h> 68#include <net/arp.h>
68 69
69#include "config_roms.h" 70#include "config_roms.h"
@@ -491,7 +492,7 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
491 int i; 492 int i;
492 struct eth1394_priv *priv = netdev_priv(dev); 493 struct eth1394_priv *priv = netdev_priv(dev);
493 struct hpsb_host *host = priv->host; 494 struct hpsb_host *host = priv->host;
494 u64 guid = *((u64*)&(host->csr.rom->bus_info_data[3])); 495 u64 guid = get_unaligned((u64*)&(host->csr.rom->bus_info_data[3]));
495 u16 maxpayload = 1 << (host->csr.max_rec + 1); 496 u16 maxpayload = 1 << (host->csr.max_rec + 1);
496 int max_speed = IEEE1394_SPEED_MAX; 497 int max_speed = IEEE1394_SPEED_MAX;
497 498
@@ -514,8 +515,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
514 ETHER1394_GASP_OVERHEAD))); 515 ETHER1394_GASP_OVERHEAD)));
515 516
516 /* Set our hardware address while we're at it */ 517 /* Set our hardware address while we're at it */
517 *(u64*)dev->dev_addr = guid; 518 memcpy(dev->dev_addr, &guid, sizeof(u64));
518 *(u64*)dev->broadcast = ~0x0ULL; 519 memset(dev->broadcast, 0xff, sizeof(u64));
519 } 520 }
520 521
521 spin_unlock_irqrestore (&priv->lock, flags); 522 spin_unlock_irqrestore (&priv->lock, flags);
@@ -894,6 +895,7 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
894 u16 maxpayload; 895 u16 maxpayload;
895 struct eth1394_node_ref *node; 896 struct eth1394_node_ref *node;
896 struct eth1394_node_info *node_info; 897 struct eth1394_node_info *node_info;
898 __be64 guid;
897 899
898 /* Sanity check. MacOSX seems to be sending us 131 in this 900 /* Sanity check. MacOSX seems to be sending us 131 in this
899 * field (atleast on my Panther G5). Not sure why. */ 901 * field (atleast on my Panther G5). Not sure why. */
@@ -902,8 +904,9 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
902 904
903 maxpayload = min(eth1394_speedto_maxpayload[sspd], (u16)(1 << (max_rec + 1))); 905 maxpayload = min(eth1394_speedto_maxpayload[sspd], (u16)(1 << (max_rec + 1)));
904 906
907 guid = get_unaligned(&arp1394->s_uniq_id);
905 node = eth1394_find_node_guid(&priv->ip_node_list, 908 node = eth1394_find_node_guid(&priv->ip_node_list,
906 be64_to_cpu(arp1394->s_uniq_id)); 909 be64_to_cpu(guid));
907 if (!node) { 910 if (!node) {
908 return 0; 911 return 0;
909 } 912 }
@@ -931,10 +934,9 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
931 arp_ptr += arp->ar_pln; /* skip over sender IP addr */ 934 arp_ptr += arp->ar_pln; /* skip over sender IP addr */
932 935
933 if (arp->ar_op == htons(ARPOP_REQUEST)) 936 if (arp->ar_op == htons(ARPOP_REQUEST))
934 /* just set ARP req target unique ID to 0 */ 937 memset(arp_ptr, 0, sizeof(u64));
935 *((u64*)arp_ptr) = 0;
936 else 938 else
937 *((u64*)arp_ptr) = *((u64*)dev->dev_addr); 939 memcpy(arp_ptr, dev->dev_addr, sizeof(u64));
938 } 940 }
939 941
940 /* Now add the ethernet header. */ 942 /* Now add the ethernet header. */
@@ -1675,8 +1677,10 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1675 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF]) 1677 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
1676 priv->bc_dgl++; 1678 priv->bc_dgl++;
1677 } else { 1679 } else {
1680 __be64 guid = get_unaligned((u64 *)eth->h_dest);
1681
1678 node = eth1394_find_node_guid(&priv->ip_node_list, 1682 node = eth1394_find_node_guid(&priv->ip_node_list,
1679 be64_to_cpu(*(u64*)eth->h_dest)); 1683 be64_to_cpu(guid));
1680 if (!node) { 1684 if (!node) {
1681 ret = -EAGAIN; 1685 ret = -EAGAIN;
1682 goto fail; 1686 goto fail;
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index dea13525df88..6e8ea9110c46 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -3552,12 +3552,21 @@ static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
3552{ 3552{
3553 int err; 3553 int err;
3554 3554
3555 printk(KERN_INFO "%s does not fully support suspend and resume yet\n",
3556 OHCI1394_DRIVER_NAME);
3557
3555 err = pci_save_state(pdev); 3558 err = pci_save_state(pdev);
3556 if (err) 3559 if (err) {
3557 goto out; 3560 printk(KERN_ERR "%s: pci_save_state failed with %d\n",
3561 OHCI1394_DRIVER_NAME, err);
3562 return err;
3563 }
3558 err = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3564 err = pci_set_power_state(pdev, pci_choose_state(pdev, state));
3565#ifdef OHCI1394_DEBUG
3559 if (err) 3566 if (err)
3560 goto out; 3567 printk(KERN_DEBUG "%s: pci_set_power_state failed with %d\n",
3568 OHCI1394_DRIVER_NAME, err);
3569#endif /* OHCI1394_DEBUG */
3561 3570
3562/* PowerMac suspend code comes last */ 3571/* PowerMac suspend code comes last */
3563#ifdef CONFIG_PPC_PMAC 3572#ifdef CONFIG_PPC_PMAC
@@ -3570,8 +3579,8 @@ static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
3570 pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0); 3579 pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0);
3571 } 3580 }
3572#endif /* CONFIG_PPC_PMAC */ 3581#endif /* CONFIG_PPC_PMAC */
3573out: 3582
3574 return err; 3583 return 0;
3575} 3584}
3576#endif /* CONFIG_PM */ 3585#endif /* CONFIG_PM */
3577 3586
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 60d3fbdd216c..e11187ecc931 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -47,6 +47,7 @@ struct addr_req {
47 struct sockaddr src_addr; 47 struct sockaddr src_addr;
48 struct sockaddr dst_addr; 48 struct sockaddr dst_addr;
49 struct rdma_dev_addr *addr; 49 struct rdma_dev_addr *addr;
50 struct rdma_addr_client *client;
50 void *context; 51 void *context;
51 void (*callback)(int status, struct sockaddr *src_addr, 52 void (*callback)(int status, struct sockaddr *src_addr,
52 struct rdma_dev_addr *addr, void *context); 53 struct rdma_dev_addr *addr, void *context);
@@ -61,6 +62,26 @@ static LIST_HEAD(req_list);
61static DECLARE_WORK(work, process_req, NULL); 62static DECLARE_WORK(work, process_req, NULL);
62static struct workqueue_struct *addr_wq; 63static struct workqueue_struct *addr_wq;
63 64
65void rdma_addr_register_client(struct rdma_addr_client *client)
66{
67 atomic_set(&client->refcount, 1);
68 init_completion(&client->comp);
69}
70EXPORT_SYMBOL(rdma_addr_register_client);
71
72static inline void put_client(struct rdma_addr_client *client)
73{
74 if (atomic_dec_and_test(&client->refcount))
75 complete(&client->comp);
76}
77
78void rdma_addr_unregister_client(struct rdma_addr_client *client)
79{
80 put_client(client);
81 wait_for_completion(&client->comp);
82}
83EXPORT_SYMBOL(rdma_addr_unregister_client);
84
64int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev, 85int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
65 const unsigned char *dst_dev_addr) 86 const unsigned char *dst_dev_addr)
66{ 87{
@@ -229,6 +250,7 @@ static void process_req(void *data)
229 list_del(&req->list); 250 list_del(&req->list);
230 req->callback(req->status, &req->src_addr, req->addr, 251 req->callback(req->status, &req->src_addr, req->addr,
231 req->context); 252 req->context);
253 put_client(req->client);
232 kfree(req); 254 kfree(req);
233 } 255 }
234} 256}
@@ -264,7 +286,8 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
264 return ret; 286 return ret;
265} 287}
266 288
267int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr, 289int rdma_resolve_ip(struct rdma_addr_client *client,
290 struct sockaddr *src_addr, struct sockaddr *dst_addr,
268 struct rdma_dev_addr *addr, int timeout_ms, 291 struct rdma_dev_addr *addr, int timeout_ms,
269 void (*callback)(int status, struct sockaddr *src_addr, 292 void (*callback)(int status, struct sockaddr *src_addr,
270 struct rdma_dev_addr *addr, void *context), 293 struct rdma_dev_addr *addr, void *context),
@@ -285,6 +308,8 @@ int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr,
285 req->addr = addr; 308 req->addr = addr;
286 req->callback = callback; 309 req->callback = callback;
287 req->context = context; 310 req->context = context;
311 req->client = client;
312 atomic_inc(&client->refcount);
288 313
289 src_in = (struct sockaddr_in *) &req->src_addr; 314 src_in = (struct sockaddr_in *) &req->src_addr;
290 dst_in = (struct sockaddr_in *) &req->dst_addr; 315 dst_in = (struct sockaddr_in *) &req->dst_addr;
@@ -305,6 +330,7 @@ int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr,
305 break; 330 break;
306 default: 331 default:
307 ret = req->status; 332 ret = req->status;
333 atomic_dec(&client->refcount);
308 kfree(req); 334 kfree(req);
309 break; 335 break;
310 } 336 }
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 9ae4f3a67c70..845090b0859c 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -63,6 +63,7 @@ static struct ib_client cma_client = {
63}; 63};
64 64
65static struct ib_sa_client sa_client; 65static struct ib_sa_client sa_client;
66static struct rdma_addr_client addr_client;
66static LIST_HEAD(dev_list); 67static LIST_HEAD(dev_list);
67static LIST_HEAD(listen_any_list); 68static LIST_HEAD(listen_any_list);
68static DEFINE_MUTEX(lock); 69static DEFINE_MUTEX(lock);
@@ -1625,8 +1626,8 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
1625 if (cma_any_addr(dst_addr)) 1626 if (cma_any_addr(dst_addr))
1626 ret = cma_resolve_loopback(id_priv); 1627 ret = cma_resolve_loopback(id_priv);
1627 else 1628 else
1628 ret = rdma_resolve_ip(&id->route.addr.src_addr, dst_addr, 1629 ret = rdma_resolve_ip(&addr_client, &id->route.addr.src_addr,
1629 &id->route.addr.dev_addr, 1630 dst_addr, &id->route.addr.dev_addr,
1630 timeout_ms, addr_handler, id_priv); 1631 timeout_ms, addr_handler, id_priv);
1631 if (ret) 1632 if (ret)
1632 goto err; 1633 goto err;
@@ -1762,22 +1763,29 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
1762 1763
1763 if (!cma_any_addr(addr)) { 1764 if (!cma_any_addr(addr)) {
1764 ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); 1765 ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
1765 if (!ret) {
1766 mutex_lock(&lock);
1767 ret = cma_acquire_dev(id_priv);
1768 mutex_unlock(&lock);
1769 }
1770 if (ret) 1766 if (ret)
1771 goto err; 1767 goto err1;
1768
1769 mutex_lock(&lock);
1770 ret = cma_acquire_dev(id_priv);
1771 mutex_unlock(&lock);
1772 if (ret)
1773 goto err1;
1772 } 1774 }
1773 1775
1774 memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr)); 1776 memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr));
1775 ret = cma_get_port(id_priv); 1777 ret = cma_get_port(id_priv);
1776 if (ret) 1778 if (ret)
1777 goto err; 1779 goto err2;
1778 1780
1779 return 0; 1781 return 0;
1780err: 1782err2:
1783 if (!cma_any_addr(addr)) {
1784 mutex_lock(&lock);
1785 cma_detach_from_dev(id_priv);
1786 mutex_unlock(&lock);
1787 }
1788err1:
1781 cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_IDLE); 1789 cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_IDLE);
1782 return ret; 1790 return ret;
1783} 1791}
@@ -2210,6 +2218,7 @@ static int cma_init(void)
2210 return -ENOMEM; 2218 return -ENOMEM;
2211 2219
2212 ib_sa_register_client(&sa_client); 2220 ib_sa_register_client(&sa_client);
2221 rdma_addr_register_client(&addr_client);
2213 2222
2214 ret = ib_register_client(&cma_client); 2223 ret = ib_register_client(&cma_client);
2215 if (ret) 2224 if (ret)
@@ -2217,6 +2226,7 @@ static int cma_init(void)
2217 return 0; 2226 return 0;
2218 2227
2219err: 2228err:
2229 rdma_addr_unregister_client(&addr_client);
2220 ib_sa_unregister_client(&sa_client); 2230 ib_sa_unregister_client(&sa_client);
2221 destroy_workqueue(cma_wq); 2231 destroy_workqueue(cma_wq);
2222 return ret; 2232 return ret;
@@ -2225,6 +2235,7 @@ err:
2225static void cma_cleanup(void) 2235static void cma_cleanup(void)
2226{ 2236{
2227 ib_unregister_client(&cma_client); 2237 ib_unregister_client(&cma_client);
2238 rdma_addr_unregister_client(&addr_client);
2228 ib_sa_unregister_client(&sa_client); 2239 ib_sa_unregister_client(&sa_client);
2229 destroy_workqueue(cma_wq); 2240 destroy_workqueue(cma_wq);
2230 idr_destroy(&sdp_ps); 2241 idr_destroy(&sdp_ps);
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 493f4c65c7a2..a72bcea46ff6 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -1750,7 +1750,7 @@ ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
1750 */ 1750 */
1751 (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) || 1751 (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) ||
1752 rcv_has_same_gid(mad_agent_priv, wr, wc))) 1752 rcv_has_same_gid(mad_agent_priv, wr, wc)))
1753 return wr; 1753 return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
1754 } 1754 }
1755 1755
1756 /* 1756 /*
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index b72c7f69ca90..743247ec065e 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1214,7 +1214,7 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
1214 resp.qp_access_flags = attr->qp_access_flags; 1214 resp.qp_access_flags = attr->qp_access_flags;
1215 resp.pkey_index = attr->pkey_index; 1215 resp.pkey_index = attr->pkey_index;
1216 resp.alt_pkey_index = attr->alt_pkey_index; 1216 resp.alt_pkey_index = attr->alt_pkey_index;
1217 resp.en_sqd_async_notify = attr->en_sqd_async_notify; 1217 resp.sq_draining = attr->sq_draining;
1218 resp.max_rd_atomic = attr->max_rd_atomic; 1218 resp.max_rd_atomic = attr->max_rd_atomic;
1219 resp.max_dest_rd_atomic = attr->max_dest_rd_atomic; 1219 resp.max_dest_rd_atomic = attr->max_dest_rd_atomic;
1220 resp.min_rnr_timer = attr->min_rnr_timer; 1220 resp.min_rnr_timer = attr->min_rnr_timer;
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c
index 9e7bd94b958a..27fe242ed435 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -1155,7 +1155,8 @@ static int __devinit c2_probe(struct pci_dev *pcidev,
1155 goto bail10; 1155 goto bail10;
1156 } 1156 }
1157 1157
1158 c2_register_device(c2dev); 1158 if (c2_register_device(c2dev))
1159 goto bail10;
1159 1160
1160 return 0; 1161 return 0;
1161 1162
diff --git a/drivers/infiniband/hw/amso1100/c2_alloc.c b/drivers/infiniband/hw/amso1100/c2_alloc.c
index 028a60bbfca9..0315f99e4191 100644
--- a/drivers/infiniband/hw/amso1100/c2_alloc.c
+++ b/drivers/infiniband/hw/amso1100/c2_alloc.c
@@ -42,13 +42,14 @@ static int c2_alloc_mqsp_chunk(struct c2_dev *c2dev, gfp_t gfp_mask,
42{ 42{
43 int i; 43 int i;
44 struct sp_chunk *new_head; 44 struct sp_chunk *new_head;
45 dma_addr_t dma_addr;
45 46
46 new_head = (struct sp_chunk *) __get_free_page(gfp_mask); 47 new_head = dma_alloc_coherent(&c2dev->pcidev->dev, PAGE_SIZE,
48 &dma_addr, gfp_mask);
47 if (new_head == NULL) 49 if (new_head == NULL)
48 return -ENOMEM; 50 return -ENOMEM;
49 51
50 new_head->dma_addr = dma_map_single(c2dev->ibdev.dma_device, new_head, 52 new_head->dma_addr = dma_addr;
51 PAGE_SIZE, DMA_FROM_DEVICE);
52 pci_unmap_addr_set(new_head, mapping, new_head->dma_addr); 53 pci_unmap_addr_set(new_head, mapping, new_head->dma_addr);
53 54
54 new_head->next = NULL; 55 new_head->next = NULL;
@@ -80,10 +81,8 @@ void c2_free_mqsp_pool(struct c2_dev *c2dev, struct sp_chunk *root)
80 81
81 while (root) { 82 while (root) {
82 next = root->next; 83 next = root->next;
83 dma_unmap_single(c2dev->ibdev.dma_device, 84 dma_free_coherent(&c2dev->pcidev->dev, PAGE_SIZE, root,
84 pci_unmap_addr(root, mapping), PAGE_SIZE, 85 pci_unmap_addr(root, mapping));
85 DMA_FROM_DEVICE);
86 __free_page((struct page *) root);
87 root = next; 86 root = next;
88 } 87 }
89} 88}
diff --git a/drivers/infiniband/hw/amso1100/c2_cq.c b/drivers/infiniband/hw/amso1100/c2_cq.c
index 9d7bcc5ade93..05c9154d46f4 100644
--- a/drivers/infiniband/hw/amso1100/c2_cq.c
+++ b/drivers/infiniband/hw/amso1100/c2_cq.c
@@ -246,20 +246,17 @@ int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify)
246 246
247static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq) 247static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq)
248{ 248{
249 249 dma_free_coherent(&c2dev->pcidev->dev, mq->q_size * mq->msg_size,
250 dma_unmap_single(c2dev->ibdev.dma_device, pci_unmap_addr(mq, mapping), 250 mq->msg_pool.host, pci_unmap_addr(mq, mapping));
251 mq->q_size * mq->msg_size, DMA_FROM_DEVICE);
252 free_pages((unsigned long) mq->msg_pool.host,
253 get_order(mq->q_size * mq->msg_size));
254} 251}
255 252
256static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size, 253static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
257 int msg_size) 254 int msg_size)
258{ 255{
259 unsigned long pool_start; 256 u8 *pool_start;
260 257
261 pool_start = __get_free_pages(GFP_KERNEL, 258 pool_start = dma_alloc_coherent(&c2dev->pcidev->dev, q_size * msg_size,
262 get_order(q_size * msg_size)); 259 &mq->host_dma, GFP_KERNEL);
263 if (!pool_start) 260 if (!pool_start)
264 return -ENOMEM; 261 return -ENOMEM;
265 262
@@ -267,13 +264,10 @@ static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
267 0, /* index (currently unknown) */ 264 0, /* index (currently unknown) */
268 q_size, 265 q_size,
269 msg_size, 266 msg_size,
270 (u8 *) pool_start, 267 pool_start,
271 NULL, /* peer (currently unknown) */ 268 NULL, /* peer (currently unknown) */
272 C2_MQ_HOST_TARGET); 269 C2_MQ_HOST_TARGET);
273 270
274 mq->host_dma = dma_map_single(c2dev->ibdev.dma_device,
275 (void *)pool_start,
276 q_size * msg_size, DMA_FROM_DEVICE);
277 pci_unmap_addr_set(mq, mapping, mq->host_dma); 271 pci_unmap_addr_set(mq, mapping, mq->host_dma);
278 272
279 return 0; 273 return 0;
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
index da98d9f71429..fef972752912 100644
--- a/drivers/infiniband/hw/amso1100/c2_provider.c
+++ b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -757,20 +757,17 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
757 757
758int c2_register_device(struct c2_dev *dev) 758int c2_register_device(struct c2_dev *dev)
759{ 759{
760 int ret; 760 int ret = -ENOMEM;
761 int i; 761 int i;
762 762
763 /* Register pseudo network device */ 763 /* Register pseudo network device */
764 dev->pseudo_netdev = c2_pseudo_netdev_init(dev); 764 dev->pseudo_netdev = c2_pseudo_netdev_init(dev);
765 if (dev->pseudo_netdev) { 765 if (!dev->pseudo_netdev)
766 ret = register_netdev(dev->pseudo_netdev); 766 goto out3;
767 if (ret) { 767
768 printk(KERN_ERR PFX 768 ret = register_netdev(dev->pseudo_netdev);
769 "Unable to register netdev, ret = %d\n", ret); 769 if (ret)
770 free_netdev(dev->pseudo_netdev); 770 goto out2;
771 return ret;
772 }
773 }
774 771
775 pr_debug("%s:%u\n", __FUNCTION__, __LINE__); 772 pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
776 strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX); 773 strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX);
@@ -848,21 +845,25 @@ int c2_register_device(struct c2_dev *dev)
848 845
849 ret = ib_register_device(&dev->ibdev); 846 ret = ib_register_device(&dev->ibdev);
850 if (ret) 847 if (ret)
851 return ret; 848 goto out1;
852 849
853 for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) { 850 for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) {
854 ret = class_device_create_file(&dev->ibdev.class_dev, 851 ret = class_device_create_file(&dev->ibdev.class_dev,
855 c2_class_attributes[i]); 852 c2_class_attributes[i]);
856 if (ret) { 853 if (ret)
857 unregister_netdev(dev->pseudo_netdev); 854 goto out0;
858 free_netdev(dev->pseudo_netdev);
859 ib_unregister_device(&dev->ibdev);
860 return ret;
861 }
862 } 855 }
856 goto out3;
863 857
864 pr_debug("%s:%u\n", __FUNCTION__, __LINE__); 858out0:
865 return 0; 859 ib_unregister_device(&dev->ibdev);
860out1:
861 unregister_netdev(dev->pseudo_netdev);
862out2:
863 free_netdev(dev->pseudo_netdev);
864out3:
865 pr_debug("%s:%u ret=%d\n", __FUNCTION__, __LINE__, ret);
866 return ret;
866} 867}
867 868
868void c2_unregister_device(struct c2_dev *dev) 869void c2_unregister_device(struct c2_dev *dev)
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index 30409e179606..623dc95f91df 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -157,8 +157,8 @@ static int c2_rnic_query(struct c2_dev *c2dev, struct ib_device_attr *props)
157 157
158 props->fw_ver = 158 props->fw_ver =
159 ((u64)be32_to_cpu(reply->fw_ver_major) << 32) | 159 ((u64)be32_to_cpu(reply->fw_ver_major) << 32) |
160 ((be32_to_cpu(reply->fw_ver_minor) && 0xFFFF) << 16) | 160 ((be32_to_cpu(reply->fw_ver_minor) & 0xFFFF) << 16) |
161 (be32_to_cpu(reply->fw_ver_patch) && 0xFFFF); 161 (be32_to_cpu(reply->fw_ver_patch) & 0xFFFF);
162 memcpy(&props->sys_image_guid, c2dev->netdev->dev_addr, 6); 162 memcpy(&props->sys_image_guid, c2dev->netdev->dev_addr, 6);
163 props->max_mr_size = 0xFFFFFFFF; 163 props->max_mr_size = 0xFFFFFFFF;
164 props->page_size_cap = ~(C2_MIN_PAGESIZE-1); 164 props->page_size_cap = ~(C2_MIN_PAGESIZE-1);
@@ -517,14 +517,12 @@ int c2_rnic_init(struct c2_dev *c2dev)
517 /* Initialize the Verbs Reply Queue */ 517 /* Initialize the Verbs Reply Queue */
518 qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_QSIZE)); 518 qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_QSIZE));
519 msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_MSGSIZE)); 519 msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_MSGSIZE));
520 q1_pages = kmalloc(qsize * msgsize, GFP_KERNEL); 520 q1_pages = dma_alloc_coherent(&c2dev->pcidev->dev, qsize * msgsize,
521 &c2dev->rep_vq.host_dma, GFP_KERNEL);
521 if (!q1_pages) { 522 if (!q1_pages) {
522 err = -ENOMEM; 523 err = -ENOMEM;
523 goto bail1; 524 goto bail1;
524 } 525 }
525 c2dev->rep_vq.host_dma = dma_map_single(c2dev->ibdev.dma_device,
526 (void *)q1_pages, qsize * msgsize,
527 DMA_FROM_DEVICE);
528 pci_unmap_addr_set(&c2dev->rep_vq, mapping, c2dev->rep_vq.host_dma); 526 pci_unmap_addr_set(&c2dev->rep_vq, mapping, c2dev->rep_vq.host_dma);
529 pr_debug("%s rep_vq va %p dma %llx\n", __FUNCTION__, q1_pages, 527 pr_debug("%s rep_vq va %p dma %llx\n", __FUNCTION__, q1_pages,
530 (unsigned long long) c2dev->rep_vq.host_dma); 528 (unsigned long long) c2dev->rep_vq.host_dma);
@@ -540,17 +538,15 @@ int c2_rnic_init(struct c2_dev *c2dev)
540 /* Initialize the Asynchronus Event Queue */ 538 /* Initialize the Asynchronus Event Queue */
541 qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_QSIZE)); 539 qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_QSIZE));
542 msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_MSGSIZE)); 540 msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_MSGSIZE));
543 q2_pages = kmalloc(qsize * msgsize, GFP_KERNEL); 541 q2_pages = dma_alloc_coherent(&c2dev->pcidev->dev, qsize * msgsize,
542 &c2dev->aeq.host_dma, GFP_KERNEL);
544 if (!q2_pages) { 543 if (!q2_pages) {
545 err = -ENOMEM; 544 err = -ENOMEM;
546 goto bail2; 545 goto bail2;
547 } 546 }
548 c2dev->aeq.host_dma = dma_map_single(c2dev->ibdev.dma_device,
549 (void *)q2_pages, qsize * msgsize,
550 DMA_FROM_DEVICE);
551 pci_unmap_addr_set(&c2dev->aeq, mapping, c2dev->aeq.host_dma); 547 pci_unmap_addr_set(&c2dev->aeq, mapping, c2dev->aeq.host_dma);
552 pr_debug("%s aeq va %p dma %llx\n", __FUNCTION__, q1_pages, 548 pr_debug("%s aeq va %p dma %llx\n", __FUNCTION__, q2_pages,
553 (unsigned long long) c2dev->rep_vq.host_dma); 549 (unsigned long long) c2dev->aeq.host_dma);
554 c2_mq_rep_init(&c2dev->aeq, 550 c2_mq_rep_init(&c2dev->aeq,
555 2, 551 2,
556 qsize, 552 qsize,
@@ -597,17 +593,13 @@ int c2_rnic_init(struct c2_dev *c2dev)
597 bail4: 593 bail4:
598 vq_term(c2dev); 594 vq_term(c2dev);
599 bail3: 595 bail3:
600 dma_unmap_single(c2dev->ibdev.dma_device, 596 dma_free_coherent(&c2dev->pcidev->dev,
601 pci_unmap_addr(&c2dev->aeq, mapping), 597 c2dev->aeq.q_size * c2dev->aeq.msg_size,
602 c2dev->aeq.q_size * c2dev->aeq.msg_size, 598 q2_pages, pci_unmap_addr(&c2dev->aeq, mapping));
603 DMA_FROM_DEVICE);
604 kfree(q2_pages);
605 bail2: 599 bail2:
606 dma_unmap_single(c2dev->ibdev.dma_device, 600 dma_free_coherent(&c2dev->pcidev->dev,
607 pci_unmap_addr(&c2dev->rep_vq, mapping), 601 c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size,
608 c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size, 602 q1_pages, pci_unmap_addr(&c2dev->rep_vq, mapping));
609 DMA_FROM_DEVICE);
610 kfree(q1_pages);
611 bail1: 603 bail1:
612 c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool); 604 c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool);
613 bail0: 605 bail0:
@@ -640,19 +632,17 @@ void c2_rnic_term(struct c2_dev *c2dev)
640 /* Free the verbs request allocator */ 632 /* Free the verbs request allocator */
641 vq_term(c2dev); 633 vq_term(c2dev);
642 634
643 /* Unmap and free the asynchronus event queue */ 635 /* Free the asynchronus event queue */
644 dma_unmap_single(c2dev->ibdev.dma_device, 636 dma_free_coherent(&c2dev->pcidev->dev,
645 pci_unmap_addr(&c2dev->aeq, mapping), 637 c2dev->aeq.q_size * c2dev->aeq.msg_size,
646 c2dev->aeq.q_size * c2dev->aeq.msg_size, 638 c2dev->aeq.msg_pool.host,
647 DMA_FROM_DEVICE); 639 pci_unmap_addr(&c2dev->aeq, mapping));
648 kfree(c2dev->aeq.msg_pool.host); 640
649 641 /* Free the verbs reply queue */
650 /* Unmap and free the verbs reply queue */ 642 dma_free_coherent(&c2dev->pcidev->dev,
651 dma_unmap_single(c2dev->ibdev.dma_device, 643 c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size,
652 pci_unmap_addr(&c2dev->rep_vq, mapping), 644 c2dev->rep_vq.msg_pool.host,
653 c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size, 645 pci_unmap_addr(&c2dev->rep_vq, mapping));
654 DMA_FROM_DEVICE);
655 kfree(c2dev->rep_vq.msg_pool.host);
656 646
657 /* Free the MQ shared pointer pool */ 647 /* Free the MQ shared pointer pool */
658 c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool); 648 c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool);
diff --git a/drivers/infiniband/hw/ehca/Kconfig b/drivers/infiniband/hw/ehca/Kconfig
index 922389b64394..727b10d89686 100644
--- a/drivers/infiniband/hw/ehca/Kconfig
+++ b/drivers/infiniband/hw/ehca/Kconfig
@@ -10,6 +10,7 @@ config INFINIBAND_EHCA
10config INFINIBAND_EHCA_SCALING 10config INFINIBAND_EHCA_SCALING
11 bool "Scaling support (EXPERIMENTAL)" 11 bool "Scaling support (EXPERIMENTAL)"
12 depends on IBMEBUS && INFINIBAND_EHCA && HOTPLUG_CPU && EXPERIMENTAL 12 depends on IBMEBUS && INFINIBAND_EHCA && HOTPLUG_CPU && EXPERIMENTAL
13 default y
13 ---help--- 14 ---help---
14 eHCA scaling support schedules the CQ callbacks to different CPUs. 15 eHCA scaling support schedules the CQ callbacks to different CPUs.
15 16
diff --git a/drivers/infiniband/hw/ehca/ehca_av.c b/drivers/infiniband/hw/ehca/ehca_av.c
index 3bac197f9014..214e2fdddeef 100644
--- a/drivers/infiniband/hw/ehca/ehca_av.c
+++ b/drivers/infiniband/hw/ehca/ehca_av.c
@@ -118,8 +118,7 @@ struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
118 } 118 }
119 memcpy(&av->av.grh.word_1, &gid, sizeof(gid)); 119 memcpy(&av->av.grh.word_1, &gid, sizeof(gid));
120 } 120 }
121 /* for the time being we use a hard coded PMTU of 2048 Bytes */ 121 av->av.pmtu = EHCA_MAX_MTU;
122 av->av.pmtu = 4;
123 122
124 /* dgid comes in grh.word_3 */ 123 /* dgid comes in grh.word_3 */
125 memcpy(&av->av.grh.word_3, &ah_attr->grh.dgid, 124 memcpy(&av->av.grh.word_3, &ah_attr->grh.dgid,
@@ -193,7 +192,7 @@ int ehca_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
193 memcpy(&new_ehca_av.grh.word_1, &gid, sizeof(gid)); 192 memcpy(&new_ehca_av.grh.word_1, &gid, sizeof(gid));
194 } 193 }
195 194
196 new_ehca_av.pmtu = 4; /* see also comment in create_ah() */ 195 new_ehca_av.pmtu = EHCA_MAX_MTU;
197 196
198 memcpy(&new_ehca_av.grh.word_3, &ah_attr->grh.dgid, 197 memcpy(&new_ehca_av.grh.word_3, &ah_attr->grh.dgid,
199 sizeof(ah_attr->grh.dgid)); 198 sizeof(ah_attr->grh.dgid));
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c
index 5eae6ac48425..e1b618c5f685 100644
--- a/drivers/infiniband/hw/ehca/ehca_hca.c
+++ b/drivers/infiniband/hw/ehca/ehca_hca.c
@@ -40,6 +40,7 @@
40 */ 40 */
41 41
42#include "ehca_tools.h" 42#include "ehca_tools.h"
43#include "ehca_iverbs.h"
43#include "hcp_if.h" 44#include "hcp_if.h"
44 45
45int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) 46int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
@@ -49,7 +50,7 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
49 ib_device); 50 ib_device);
50 struct hipz_query_hca *rblock; 51 struct hipz_query_hca *rblock;
51 52
52 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 53 rblock = ehca_alloc_fw_ctrlblock();
53 if (!rblock) { 54 if (!rblock) {
54 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 55 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
55 return -ENOMEM; 56 return -ENOMEM;
@@ -96,7 +97,7 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
96 = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX); 97 = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX);
97 98
98query_device1: 99query_device1:
99 kfree(rblock); 100 ehca_free_fw_ctrlblock(rblock);
100 101
101 return ret; 102 return ret;
102} 103}
@@ -109,7 +110,7 @@ int ehca_query_port(struct ib_device *ibdev,
109 ib_device); 110 ib_device);
110 struct hipz_query_port *rblock; 111 struct hipz_query_port *rblock;
111 112
112 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 113 rblock = ehca_alloc_fw_ctrlblock();
113 if (!rblock) { 114 if (!rblock) {
114 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 115 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
115 return -ENOMEM; 116 return -ENOMEM;
@@ -162,7 +163,7 @@ int ehca_query_port(struct ib_device *ibdev,
162 props->active_speed = 0x1; 163 props->active_speed = 0x1;
163 164
164query_port1: 165query_port1:
165 kfree(rblock); 166 ehca_free_fw_ctrlblock(rblock);
166 167
167 return ret; 168 return ret;
168} 169}
@@ -178,7 +179,7 @@ int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
178 return -EINVAL; 179 return -EINVAL;
179 } 180 }
180 181
181 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 182 rblock = ehca_alloc_fw_ctrlblock();
182 if (!rblock) { 183 if (!rblock) {
183 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 184 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
184 return -ENOMEM; 185 return -ENOMEM;
@@ -193,7 +194,7 @@ int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
193 memcpy(pkey, &rblock->pkey_entries + index, sizeof(u16)); 194 memcpy(pkey, &rblock->pkey_entries + index, sizeof(u16));
194 195
195query_pkey1: 196query_pkey1:
196 kfree(rblock); 197 ehca_free_fw_ctrlblock(rblock);
197 198
198 return ret; 199 return ret;
199} 200}
@@ -211,7 +212,7 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port,
211 return -EINVAL; 212 return -EINVAL;
212 } 213 }
213 214
214 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 215 rblock = ehca_alloc_fw_ctrlblock();
215 if (!rblock) { 216 if (!rblock) {
216 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 217 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
217 return -ENOMEM; 218 return -ENOMEM;
@@ -227,7 +228,7 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port,
227 memcpy(&gid->raw[8], &rblock->guid_entries[index], sizeof(u64)); 228 memcpy(&gid->raw[8], &rblock->guid_entries[index], sizeof(u64));
228 229
229query_gid1: 230query_gid1:
230 kfree(rblock); 231 ehca_free_fw_ctrlblock(rblock);
231 232
232 return ret; 233 return ret;
233} 234}
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index 048cc443d1e7..c3ea746e9045 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -45,6 +45,7 @@
45#include "ehca_tools.h" 45#include "ehca_tools.h"
46#include "hcp_if.h" 46#include "hcp_if.h"
47#include "hipz_fns.h" 47#include "hipz_fns.h"
48#include "ipz_pt_fn.h"
48 49
49#define EQE_COMPLETION_EVENT EHCA_BMASK_IBM(1,1) 50#define EQE_COMPLETION_EVENT EHCA_BMASK_IBM(1,1)
50#define EQE_CQ_QP_NUMBER EHCA_BMASK_IBM(8,31) 51#define EQE_CQ_QP_NUMBER EHCA_BMASK_IBM(8,31)
@@ -137,38 +138,36 @@ int ehca_error_data(struct ehca_shca *shca, void *data,
137 u64 *rblock; 138 u64 *rblock;
138 unsigned long block_count; 139 unsigned long block_count;
139 140
140 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 141 rblock = ehca_alloc_fw_ctrlblock();
141 if (!rblock) { 142 if (!rblock) {
142 ehca_err(&shca->ib_device, "Cannot allocate rblock memory."); 143 ehca_err(&shca->ib_device, "Cannot allocate rblock memory.");
143 ret = -ENOMEM; 144 ret = -ENOMEM;
144 goto error_data1; 145 goto error_data1;
145 } 146 }
146 147
148 /* rblock must be 4K aligned and should be 4K large */
147 ret = hipz_h_error_data(shca->ipz_hca_handle, 149 ret = hipz_h_error_data(shca->ipz_hca_handle,
148 resource, 150 resource,
149 rblock, 151 rblock,
150 &block_count); 152 &block_count);
151 153
152 if (ret == H_R_STATE) { 154 if (ret == H_R_STATE)
153 ehca_err(&shca->ib_device, 155 ehca_err(&shca->ib_device,
154 "No error data is available: %lx.", resource); 156 "No error data is available: %lx.", resource);
155 }
156 else if (ret == H_SUCCESS) { 157 else if (ret == H_SUCCESS) {
157 int length; 158 int length;
158 159
159 length = EHCA_BMASK_GET(ERROR_DATA_LENGTH, rblock[0]); 160 length = EHCA_BMASK_GET(ERROR_DATA_LENGTH, rblock[0]);
160 161
161 if (length > PAGE_SIZE) 162 if (length > EHCA_PAGESIZE)
162 length = PAGE_SIZE; 163 length = EHCA_PAGESIZE;
163 164
164 print_error_data(shca, data, rblock, length); 165 print_error_data(shca, data, rblock, length);
165 } 166 } else
166 else {
167 ehca_err(&shca->ib_device, 167 ehca_err(&shca->ib_device,
168 "Error data could not be fetched: %lx", resource); 168 "Error data could not be fetched: %lx", resource);
169 }
170 169
171 kfree(rblock); 170 ehca_free_fw_ctrlblock(rblock);
172 171
173error_data1: 172error_data1:
174 return ret; 173 return ret;
diff --git a/drivers/infiniband/hw/ehca/ehca_iverbs.h b/drivers/infiniband/hw/ehca/ehca_iverbs.h
index 319c39d47f3a..3720e3032cce 100644
--- a/drivers/infiniband/hw/ehca/ehca_iverbs.h
+++ b/drivers/infiniband/hw/ehca/ehca_iverbs.h
@@ -179,4 +179,12 @@ int ehca_mmap_register(u64 physical,void **mapped,
179 179
180int ehca_munmap(unsigned long addr, size_t len); 180int ehca_munmap(unsigned long addr, size_t len);
181 181
182#ifdef CONFIG_PPC_64K_PAGES
183void *ehca_alloc_fw_ctrlblock(void);
184void ehca_free_fw_ctrlblock(void *ptr);
185#else
186#define ehca_alloc_fw_ctrlblock() ((void *) get_zeroed_page(GFP_KERNEL))
187#define ehca_free_fw_ctrlblock(ptr) free_page((unsigned long)(ptr))
188#endif
189
182#endif 190#endif
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 024d511c4b58..01f5aa9cb56d 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -40,6 +40,9 @@
40 * POSSIBILITY OF SUCH DAMAGE. 40 * POSSIBILITY OF SUCH DAMAGE.
41 */ 41 */
42 42
43#ifdef CONFIG_PPC_64K_PAGES
44#include <linux/slab.h>
45#endif
43#include "ehca_classes.h" 46#include "ehca_classes.h"
44#include "ehca_iverbs.h" 47#include "ehca_iverbs.h"
45#include "ehca_mrmw.h" 48#include "ehca_mrmw.h"
@@ -49,7 +52,7 @@
49MODULE_LICENSE("Dual BSD/GPL"); 52MODULE_LICENSE("Dual BSD/GPL");
50MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); 53MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>");
51MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver"); 54MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver");
52MODULE_VERSION("SVNEHCA_0017"); 55MODULE_VERSION("SVNEHCA_0018");
53 56
54int ehca_open_aqp1 = 0; 57int ehca_open_aqp1 = 0;
55int ehca_debug_level = 0; 58int ehca_debug_level = 0;
@@ -94,11 +97,31 @@ spinlock_t ehca_cq_idr_lock;
94DEFINE_IDR(ehca_qp_idr); 97DEFINE_IDR(ehca_qp_idr);
95DEFINE_IDR(ehca_cq_idr); 98DEFINE_IDR(ehca_cq_idr);
96 99
100
97static struct list_head shca_list; /* list of all registered ehcas */ 101static struct list_head shca_list; /* list of all registered ehcas */
98static spinlock_t shca_list_lock; 102static spinlock_t shca_list_lock;
99 103
100static struct timer_list poll_eqs_timer; 104static struct timer_list poll_eqs_timer;
101 105
106#ifdef CONFIG_PPC_64K_PAGES
107static struct kmem_cache *ctblk_cache = NULL;
108
109void *ehca_alloc_fw_ctrlblock(void)
110{
111 void *ret = kmem_cache_zalloc(ctblk_cache, SLAB_KERNEL);
112 if (!ret)
113 ehca_gen_err("Out of memory for ctblk");
114 return ret;
115}
116
117void ehca_free_fw_ctrlblock(void *ptr)
118{
119 if (ptr)
120 kmem_cache_free(ctblk_cache, ptr);
121
122}
123#endif
124
102static int ehca_create_slab_caches(void) 125static int ehca_create_slab_caches(void)
103{ 126{
104 int ret; 127 int ret;
@@ -133,6 +156,17 @@ static int ehca_create_slab_caches(void)
133 goto create_slab_caches5; 156 goto create_slab_caches5;
134 } 157 }
135 158
159#ifdef CONFIG_PPC_64K_PAGES
160 ctblk_cache = kmem_cache_create("ehca_cache_ctblk",
161 EHCA_PAGESIZE, H_CB_ALIGNMENT,
162 SLAB_HWCACHE_ALIGN,
163 NULL, NULL);
164 if (!ctblk_cache) {
165 ehca_gen_err("Cannot create ctblk SLAB cache.");
166 ehca_cleanup_mrmw_cache();
167 goto create_slab_caches5;
168 }
169#endif
136 return 0; 170 return 0;
137 171
138create_slab_caches5: 172create_slab_caches5:
@@ -157,6 +191,10 @@ static void ehca_destroy_slab_caches(void)
157 ehca_cleanup_qp_cache(); 191 ehca_cleanup_qp_cache();
158 ehca_cleanup_cq_cache(); 192 ehca_cleanup_cq_cache();
159 ehca_cleanup_pd_cache(); 193 ehca_cleanup_pd_cache();
194#ifdef CONFIG_PPC_64K_PAGES
195 if (ctblk_cache)
196 kmem_cache_destroy(ctblk_cache);
197#endif
160} 198}
161 199
162#define EHCA_HCAAVER EHCA_BMASK_IBM(32,39) 200#define EHCA_HCAAVER EHCA_BMASK_IBM(32,39)
@@ -168,7 +206,7 @@ int ehca_sense_attributes(struct ehca_shca *shca)
168 u64 h_ret; 206 u64 h_ret;
169 struct hipz_query_hca *rblock; 207 struct hipz_query_hca *rblock;
170 208
171 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 209 rblock = ehca_alloc_fw_ctrlblock();
172 if (!rblock) { 210 if (!rblock) {
173 ehca_gen_err("Cannot allocate rblock memory."); 211 ehca_gen_err("Cannot allocate rblock memory.");
174 return -ENOMEM; 212 return -ENOMEM;
@@ -211,7 +249,7 @@ int ehca_sense_attributes(struct ehca_shca *shca)
211 shca->sport[1].rate = IB_RATE_30_GBPS; 249 shca->sport[1].rate = IB_RATE_30_GBPS;
212 250
213num_ports1: 251num_ports1:
214 kfree(rblock); 252 ehca_free_fw_ctrlblock(rblock);
215 return ret; 253 return ret;
216} 254}
217 255
@@ -220,7 +258,7 @@ static int init_node_guid(struct ehca_shca *shca)
220 int ret = 0; 258 int ret = 0;
221 struct hipz_query_hca *rblock; 259 struct hipz_query_hca *rblock;
222 260
223 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 261 rblock = ehca_alloc_fw_ctrlblock();
224 if (!rblock) { 262 if (!rblock) {
225 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 263 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
226 return -ENOMEM; 264 return -ENOMEM;
@@ -235,7 +273,7 @@ static int init_node_guid(struct ehca_shca *shca)
235 memcpy(&shca->ib_device.node_guid, &rblock->node_guid, sizeof(u64)); 273 memcpy(&shca->ib_device.node_guid, &rblock->node_guid, sizeof(u64));
236 274
237init_node_guid1: 275init_node_guid1:
238 kfree(rblock); 276 ehca_free_fw_ctrlblock(rblock);
239 return ret; 277 return ret;
240} 278}
241 279
@@ -431,7 +469,7 @@ static ssize_t ehca_show_##name(struct device *dev, \
431 \ 469 \
432 shca = dev->driver_data; \ 470 shca = dev->driver_data; \
433 \ 471 \
434 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); \ 472 rblock = ehca_alloc_fw_ctrlblock(); \
435 if (!rblock) { \ 473 if (!rblock) { \
436 dev_err(dev, "Can't allocate rblock memory."); \ 474 dev_err(dev, "Can't allocate rblock memory."); \
437 return 0; \ 475 return 0; \
@@ -439,12 +477,12 @@ static ssize_t ehca_show_##name(struct device *dev, \
439 \ 477 \
440 if (hipz_h_query_hca(shca->ipz_hca_handle, rblock) != H_SUCCESS) { \ 478 if (hipz_h_query_hca(shca->ipz_hca_handle, rblock) != H_SUCCESS) { \
441 dev_err(dev, "Can't query device properties"); \ 479 dev_err(dev, "Can't query device properties"); \
442 kfree(rblock); \ 480 ehca_free_fw_ctrlblock(rblock); \
443 return 0; \ 481 return 0; \
444 } \ 482 } \
445 \ 483 \
446 data = rblock->name; \ 484 data = rblock->name; \
447 kfree(rblock); \ 485 ehca_free_fw_ctrlblock(rblock); \
448 \ 486 \
449 if ((strcmp(#name, "num_ports") == 0) && (ehca_nr_ports == 1)) \ 487 if ((strcmp(#name, "num_ports") == 0) && (ehca_nr_ports == 1)) \
450 return snprintf(buf, 256, "1\n"); \ 488 return snprintf(buf, 256, "1\n"); \
@@ -752,7 +790,7 @@ int __init ehca_module_init(void)
752 int ret; 790 int ret;
753 791
754 printk(KERN_INFO "eHCA Infiniband Device Driver " 792 printk(KERN_INFO "eHCA Infiniband Device Driver "
755 "(Rel.: SVNEHCA_0017)\n"); 793 "(Rel.: SVNEHCA_0018)\n");
756 idr_init(&ehca_qp_idr); 794 idr_init(&ehca_qp_idr);
757 idr_init(&ehca_cq_idr); 795 idr_init(&ehca_cq_idr);
758 spin_lock_init(&ehca_qp_idr_lock); 796 spin_lock_init(&ehca_qp_idr_lock);
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index 5ca65441e1da..abce676c0ae0 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -1013,7 +1013,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1013 u32 i; 1013 u32 i;
1014 u64 *kpage; 1014 u64 *kpage;
1015 1015
1016 kpage = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1016 kpage = ehca_alloc_fw_ctrlblock();
1017 if (!kpage) { 1017 if (!kpage) {
1018 ehca_err(&shca->ib_device, "kpage alloc failed"); 1018 ehca_err(&shca->ib_device, "kpage alloc failed");
1019 ret = -ENOMEM; 1019 ret = -ENOMEM;
@@ -1092,7 +1092,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1092 1092
1093 1093
1094ehca_reg_mr_rpages_exit1: 1094ehca_reg_mr_rpages_exit1:
1095 kfree(kpage); 1095 ehca_free_fw_ctrlblock(kpage);
1096ehca_reg_mr_rpages_exit0: 1096ehca_reg_mr_rpages_exit0:
1097 if (ret) 1097 if (ret)
1098 ehca_err(&shca->ib_device, "ret=%x shca=%p e_mr=%p pginfo=%p " 1098 ehca_err(&shca->ib_device, "ret=%x shca=%p e_mr=%p pginfo=%p "
@@ -1124,7 +1124,7 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca,
1124 ehca_mrmw_map_acl(acl, &hipz_acl); 1124 ehca_mrmw_map_acl(acl, &hipz_acl);
1125 ehca_mrmw_set_pgsize_hipz_acl(&hipz_acl); 1125 ehca_mrmw_set_pgsize_hipz_acl(&hipz_acl);
1126 1126
1127 kpage = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1127 kpage = ehca_alloc_fw_ctrlblock();
1128 if (!kpage) { 1128 if (!kpage) {
1129 ehca_err(&shca->ib_device, "kpage alloc failed"); 1129 ehca_err(&shca->ib_device, "kpage alloc failed");
1130 ret = -ENOMEM; 1130 ret = -ENOMEM;
@@ -1181,7 +1181,7 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca,
1181 } 1181 }
1182 1182
1183ehca_rereg_mr_rereg1_exit1: 1183ehca_rereg_mr_rereg1_exit1:
1184 kfree(kpage); 1184 ehca_free_fw_ctrlblock(kpage);
1185ehca_rereg_mr_rereg1_exit0: 1185ehca_rereg_mr_rereg1_exit0:
1186 if ( ret && (ret != -EAGAIN) ) 1186 if ( ret && (ret != -EAGAIN) )
1187 ehca_err(&shca->ib_device, "ret=%x lkey=%x rkey=%x " 1187 ehca_err(&shca->ib_device, "ret=%x lkey=%x rkey=%x "
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 4394123cdbd7..cf3e50ee2d06 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -811,8 +811,8 @@ static int internal_modify_qp(struct ib_qp *ibqp,
811 unsigned long spl_flags = 0; 811 unsigned long spl_flags = 0;
812 812
813 /* do query_qp to obtain current attr values */ 813 /* do query_qp to obtain current attr values */
814 mqpcb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 814 mqpcb = ehca_alloc_fw_ctrlblock();
815 if (mqpcb == NULL) { 815 if (!mqpcb) {
816 ehca_err(ibqp->device, "Could not get zeroed page for mqpcb " 816 ehca_err(ibqp->device, "Could not get zeroed page for mqpcb "
817 "ehca_qp=%p qp_num=%x ", my_qp, ibqp->qp_num); 817 "ehca_qp=%p qp_num=%x ", my_qp, ibqp->qp_num);
818 return -ENOMEM; 818 return -ENOMEM;
@@ -1225,7 +1225,7 @@ modify_qp_exit2:
1225 } 1225 }
1226 1226
1227modify_qp_exit1: 1227modify_qp_exit1:
1228 kfree(mqpcb); 1228 ehca_free_fw_ctrlblock(mqpcb);
1229 1229
1230 return ret; 1230 return ret;
1231} 1231}
@@ -1277,7 +1277,7 @@ int ehca_query_qp(struct ib_qp *qp,
1277 return -EINVAL; 1277 return -EINVAL;
1278 } 1278 }
1279 1279
1280 qpcb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL ); 1280 qpcb = ehca_alloc_fw_ctrlblock();
1281 if (!qpcb) { 1281 if (!qpcb) {
1282 ehca_err(qp->device,"Out of memory for qpcb " 1282 ehca_err(qp->device,"Out of memory for qpcb "
1283 "ehca_qp=%p qp_num=%x", my_qp, qp->qp_num); 1283 "ehca_qp=%p qp_num=%x", my_qp, qp->qp_num);
@@ -1401,7 +1401,7 @@ int ehca_query_qp(struct ib_qp *qp,
1401 ehca_dmp(qpcb, 4*70, "qp_num=%x", qp->qp_num); 1401 ehca_dmp(qpcb, 4*70, "qp_num=%x", qp->qp_num);
1402 1402
1403query_qp_exit1: 1403query_qp_exit1:
1404 kfree(qpcb); 1404 ehca_free_fw_ctrlblock(qpcb);
1405 1405
1406 return ret; 1406 return ret;
1407} 1407}
diff --git a/drivers/infiniband/hw/ehca/ehca_tools.h b/drivers/infiniband/hw/ehca/ehca_tools.h
index 809da3ef706b..973c4b591545 100644
--- a/drivers/infiniband/hw/ehca/ehca_tools.h
+++ b/drivers/infiniband/hw/ehca/ehca_tools.h
@@ -63,6 +63,7 @@
63#include <asm/ibmebus.h> 63#include <asm/ibmebus.h>
64#include <asm/io.h> 64#include <asm/io.h>
65#include <asm/pgtable.h> 65#include <asm/pgtable.h>
66#include <asm/hvcall.h>
66 67
67extern int ehca_debug_level; 68extern int ehca_debug_level;
68 69
diff --git a/drivers/infiniband/hw/ehca/hipz_hw.h b/drivers/infiniband/hw/ehca/hipz_hw.h
index 3fc92b031c50..fad91368dc5a 100644
--- a/drivers/infiniband/hw/ehca/hipz_hw.h
+++ b/drivers/infiniband/hw/ehca/hipz_hw.h
@@ -45,6 +45,8 @@
45 45
46#include "ehca_tools.h" 46#include "ehca_tools.h"
47 47
48#define EHCA_MAX_MTU 4
49
48/* QP Table Entry Memory Map */ 50/* QP Table Entry Memory Map */
49struct hipz_qptemm { 51struct hipz_qptemm {
50 u64 qpx_hcr; 52 u64 qpx_hcr;
diff --git a/drivers/infiniband/hw/ipath/Kconfig b/drivers/infiniband/hw/ipath/Kconfig
index 574a678e7fdd..90c14543677d 100644
--- a/drivers/infiniband/hw/ipath/Kconfig
+++ b/drivers/infiniband/hw/ipath/Kconfig
@@ -1,6 +1,6 @@
1config INFINIBAND_IPATH 1config INFINIBAND_IPATH
2 tristate "QLogic InfiniPath Driver" 2 tristate "QLogic InfiniPath Driver"
3 depends on PCI_MSI && 64BIT && INFINIBAND 3 depends on (PCI_MSI || HT_IRQ) && 64BIT && INFINIBAND && NET
4 ---help--- 4 ---help---
5 This is a driver for QLogic InfiniPath host channel adapters, 5 This is a driver for QLogic InfiniPath host channel adapters,
6 including InfiniBand verbs support. This driver allows these 6 including InfiniBand verbs support. This driver allows these
diff --git a/drivers/infiniband/hw/ipath/Makefile b/drivers/infiniband/hw/ipath/Makefile
index 5e29cb0095e5..7dc10551cf18 100644
--- a/drivers/infiniband/hw/ipath/Makefile
+++ b/drivers/infiniband/hw/ipath/Makefile
@@ -10,8 +10,6 @@ ib_ipath-y := \
10 ipath_eeprom.o \ 10 ipath_eeprom.o \
11 ipath_file_ops.o \ 11 ipath_file_ops.o \
12 ipath_fs.o \ 12 ipath_fs.o \
13 ipath_iba6110.o \
14 ipath_iba6120.o \
15 ipath_init_chip.o \ 13 ipath_init_chip.o \
16 ipath_intr.o \ 14 ipath_intr.o \
17 ipath_keys.o \ 15 ipath_keys.o \
@@ -31,5 +29,8 @@ ib_ipath-y := \
31 ipath_verbs_mcast.o \ 29 ipath_verbs_mcast.o \
32 ipath_verbs.o 30 ipath_verbs.o
33 31
32ib_ipath-$(CONFIG_HT_IRQ) += ipath_iba6110.o
33ib_ipath-$(CONFIG_PCI_MSI) += ipath_iba6120.o
34
34ib_ipath-$(CONFIG_X86_64) += ipath_wc_x86_64.o 35ib_ipath-$(CONFIG_X86_64) += ipath_wc_x86_64.o
35ib_ipath-$(CONFIG_PPC64) += ipath_wc_ppc64.o 36ib_ipath-$(CONFIG_PPC64) += ipath_wc_ppc64.o
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index b4ffaa7bcbb7..1aeddb48e355 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -304,7 +304,7 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
304 } 304 }
305 addr = pci_resource_start(pdev, 0); 305 addr = pci_resource_start(pdev, 0);
306 len = pci_resource_len(pdev, 0); 306 len = pci_resource_len(pdev, 0);
307 ipath_cdbg(VERBOSE, "regbase (0) %llx len %d irq %x, vend %x/%x " 307 ipath_cdbg(VERBOSE, "regbase (0) %llx len %d pdev->irq %d, vend %x/%x "
308 "driver_data %lx\n", addr, len, pdev->irq, ent->vendor, 308 "driver_data %lx\n", addr, len, pdev->irq, ent->vendor,
309 ent->device, ent->driver_data); 309 ent->device, ent->driver_data);
310 310
@@ -390,12 +390,16 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
390 390
391 /* setup the chip-specific functions, as early as possible. */ 391 /* setup the chip-specific functions, as early as possible. */
392 switch (ent->device) { 392 switch (ent->device) {
393#ifdef CONFIG_HT_IRQ
393 case PCI_DEVICE_ID_INFINIPATH_HT: 394 case PCI_DEVICE_ID_INFINIPATH_HT:
394 ipath_init_iba6110_funcs(dd); 395 ipath_init_iba6110_funcs(dd);
395 break; 396 break;
397#endif
398#ifdef CONFIG_PCI_MSI
396 case PCI_DEVICE_ID_INFINIPATH_PE800: 399 case PCI_DEVICE_ID_INFINIPATH_PE800:
397 ipath_init_iba6120_funcs(dd); 400 ipath_init_iba6120_funcs(dd);
398 break; 401 break;
402#endif
399 default: 403 default:
400 ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, " 404 ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, "
401 "failing\n", ent->device); 405 "failing\n", ent->device);
@@ -467,15 +471,15 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
467 * check 0 irq after we return from chip-specific bus setup, since 471 * check 0 irq after we return from chip-specific bus setup, since
468 * that can affect this due to setup 472 * that can affect this due to setup
469 */ 473 */
470 if (!pdev->irq) 474 if (!dd->ipath_irq)
471 ipath_dev_err(dd, "irq is 0, BIOS error? Interrupts won't " 475 ipath_dev_err(dd, "irq is 0, BIOS error? Interrupts won't "
472 "work\n"); 476 "work\n");
473 else { 477 else {
474 ret = request_irq(pdev->irq, ipath_intr, IRQF_SHARED, 478 ret = request_irq(dd->ipath_irq, ipath_intr, IRQF_SHARED,
475 IPATH_DRV_NAME, dd); 479 IPATH_DRV_NAME, dd);
476 if (ret) { 480 if (ret) {
477 ipath_dev_err(dd, "Couldn't setup irq handler, " 481 ipath_dev_err(dd, "Couldn't setup irq handler, "
478 "irq=%u: %d\n", pdev->irq, ret); 482 "irq=%d: %d\n", dd->ipath_irq, ret);
479 goto bail_iounmap; 483 goto bail_iounmap;
480 } 484 }
481 } 485 }
@@ -637,11 +641,10 @@ static void __devexit ipath_remove_one(struct pci_dev *pdev)
637 * free up port 0 (kernel) rcvhdr, egr bufs, and eventually tid bufs 641 * free up port 0 (kernel) rcvhdr, egr bufs, and eventually tid bufs
638 * for all versions of the driver, if they were allocated 642 * for all versions of the driver, if they were allocated
639 */ 643 */
640 if (pdev->irq) { 644 if (dd->ipath_irq) {
641 ipath_cdbg(VERBOSE, 645 ipath_cdbg(VERBOSE, "unit %u free irq %d\n",
642 "unit %u free_irq of irq %x\n", 646 dd->ipath_unit, dd->ipath_irq);
643 dd->ipath_unit, pdev->irq); 647 dd->ipath_f_free_irq(dd);
644 free_irq(pdev->irq, dd);
645 } else 648 } else
646 ipath_dbg("irq is 0, not doing free_irq " 649 ipath_dbg("irq is 0, not doing free_irq "
647 "for unit %u\n", dd->ipath_unit); 650 "for unit %u\n", dd->ipath_unit);
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6110.c b/drivers/infiniband/hw/ipath/ipath_iba6110.c
index 9e4e8d4c6e20..e57c7a351cb5 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6110.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6110.c
@@ -38,6 +38,7 @@
38 38
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/htirq.h>
41 42
42#include "ipath_kernel.h" 43#include "ipath_kernel.h"
43#include "ipath_registers.h" 44#include "ipath_registers.h"
@@ -913,49 +914,40 @@ static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev,
913 } 914 }
914} 915}
915 916
916static int set_int_handler(struct ipath_devdata *dd, struct pci_dev *pdev, 917static int ipath_ht_intconfig(struct ipath_devdata *dd)
917 int pos)
918{ 918{
919 u32 int_handler_addr_lower; 919 int ret;
920 u32 int_handler_addr_upper;
921 u64 ihandler;
922 u32 intvec;
923 920
924 /* use indirection register to get the intr handler */ 921 if (dd->ipath_intconfig) {
925 pci_write_config_byte(pdev, pos + HT_INTR_REG_INDEX, 0x10); 922 ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,
926 pci_read_config_dword(pdev, pos + 4, &int_handler_addr_lower); 923 dd->ipath_intconfig); /* interrupt address */
927 pci_write_config_byte(pdev, pos + HT_INTR_REG_INDEX, 0x11); 924 ret = 0;
928 pci_read_config_dword(pdev, pos + 4, &int_handler_addr_upper); 925 } else {
926 ipath_dev_err(dd, "No interrupts enabled, couldn't setup "
927 "interrupt address\n");
928 ret = -EINVAL;
929 }
929 930
930 ihandler = (u64) int_handler_addr_lower | 931 return ret;
931 ((u64) int_handler_addr_upper << 32); 932}
933
934static void ipath_ht_irq_update(struct pci_dev *dev, int irq,
935 struct ht_irq_msg *msg)
936{
937 struct ipath_devdata *dd = pci_get_drvdata(dev);
938 u64 prev_intconfig = dd->ipath_intconfig;
939
940 dd->ipath_intconfig = msg->address_lo;
941 dd->ipath_intconfig |= ((u64) msg->address_hi) << 32;
932 942
933 /* 943 /*
934 * kernels with CONFIG_PCI_MSI set the vector in the irq field of 944 * If the previous value of dd->ipath_intconfig is zero, we're
935 * struct pci_device, so we use that to program the internal 945 * getting configured for the first time, and must not program the
936 * interrupt register (not config space) with that value. The BIOS 946 * intconfig register here (it will be programmed later, when the
937 * must still have done the basic MSI setup. 947 * hardware is ready). Otherwise, we should.
938 */
939 intvec = pdev->irq;
940 /*
941 * clear any vector bits there; normally not set but we'll overload
942 * this for some debug purposes (setting the HTC debug register
943 * value from software, rather than GPIOs), so it might be set on a
944 * driver reload.
945 */ 948 */
946 ihandler &= ~0xff0000; 949 if (prev_intconfig)
947 /* x86 vector goes in intrinfo[23:16] */ 950 ipath_ht_intconfig(dd);
948 ihandler |= intvec << 16;
949 ipath_cdbg(VERBOSE, "ihandler lower %x, upper %x, intvec %x, "
950 "interruptconfig %llx\n", int_handler_addr_lower,
951 int_handler_addr_upper, intvec,
952 (unsigned long long) ihandler);
953
954 /* can't program yet, so save for interrupt setup */
955 dd->ipath_intconfig = ihandler;
956 /* keep going, so we find link control stuff also */
957
958 return ihandler != 0;
959} 951}
960 952
961/** 953/**
@@ -971,12 +963,19 @@ static int set_int_handler(struct ipath_devdata *dd, struct pci_dev *pdev,
971static int ipath_setup_ht_config(struct ipath_devdata *dd, 963static int ipath_setup_ht_config(struct ipath_devdata *dd,
972 struct pci_dev *pdev) 964 struct pci_dev *pdev)
973{ 965{
974 int pos, ret = 0; 966 int pos, ret;
975 int ihandler = 0; 967
968 ret = __ht_create_irq(pdev, 0, ipath_ht_irq_update);
969 if (ret < 0) {
970 ipath_dev_err(dd, "Couldn't create interrupt handler: "
971 "err %d\n", ret);
972 goto bail;
973 }
974 dd->ipath_irq = ret;
975 ret = 0;
976 976
977 /* 977 /*
978 * Read the capability info to find the interrupt info, and also 978 * Handle clearing CRC errors in linkctrl register if necessary. We
979 * handle clearing CRC errors in linkctrl register if necessary. We
980 * do this early, before we ever enable errors or hardware errors, 979 * do this early, before we ever enable errors or hardware errors,
981 * mostly to avoid causing the chip to enter freeze mode. 980 * mostly to avoid causing the chip to enter freeze mode.
982 */ 981 */
@@ -1000,17 +999,9 @@ static int ipath_setup_ht_config(struct ipath_devdata *dd,
1000 } 999 }
1001 if (!(cap_type & 0xE0)) 1000 if (!(cap_type & 0xE0))
1002 slave_or_pri_blk(dd, pdev, pos, cap_type); 1001 slave_or_pri_blk(dd, pdev, pos, cap_type);
1003 else if (cap_type == HT_INTR_DISC_CONFIG)
1004 ihandler = set_int_handler(dd, pdev, pos);
1005 } while ((pos = pci_find_next_capability(pdev, pos, 1002 } while ((pos = pci_find_next_capability(pdev, pos,
1006 PCI_CAP_ID_HT))); 1003 PCI_CAP_ID_HT)));
1007 1004
1008 if (!ihandler) {
1009 ipath_dev_err(dd, "Couldn't find interrupt handler in "
1010 "config space\n");
1011 ret = -ENODEV;
1012 }
1013
1014bail: 1005bail:
1015 return ret; 1006 return ret;
1016} 1007}
@@ -1360,25 +1351,6 @@ static void ipath_ht_quiet_serdes(struct ipath_devdata *dd)
1360 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val); 1351 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
1361} 1352}
1362 1353
1363static int ipath_ht_intconfig(struct ipath_devdata *dd)
1364{
1365 int ret;
1366
1367 if (!dd->ipath_intconfig) {
1368 ipath_dev_err(dd, "No interrupts enabled, couldn't setup "
1369 "interrupt address\n");
1370 ret = 1;
1371 goto bail;
1372 }
1373
1374 ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,
1375 dd->ipath_intconfig); /* interrupt address */
1376 ret = 0;
1377
1378bail:
1379 return ret;
1380}
1381
1382/** 1354/**
1383 * ipath_pe_put_tid - write a TID in chip 1355 * ipath_pe_put_tid - write a TID in chip
1384 * @dd: the infinipath device 1356 * @dd: the infinipath device
@@ -1575,6 +1547,14 @@ static int ipath_ht_get_base_info(struct ipath_portdata *pd, void *kbase)
1575 return 0; 1547 return 0;
1576} 1548}
1577 1549
1550static void ipath_ht_free_irq(struct ipath_devdata *dd)
1551{
1552 free_irq(dd->ipath_irq, dd);
1553 ht_destroy_irq(dd->ipath_irq);
1554 dd->ipath_irq = 0;
1555 dd->ipath_intconfig = 0;
1556}
1557
1578/** 1558/**
1579 * ipath_init_iba6110_funcs - set up the chip-specific function pointers 1559 * ipath_init_iba6110_funcs - set up the chip-specific function pointers
1580 * @dd: the infinipath device 1560 * @dd: the infinipath device
@@ -1598,6 +1578,7 @@ void ipath_init_iba6110_funcs(struct ipath_devdata *dd)
1598 dd->ipath_f_cleanup = ipath_setup_ht_cleanup; 1578 dd->ipath_f_cleanup = ipath_setup_ht_cleanup;
1599 dd->ipath_f_setextled = ipath_setup_ht_setextled; 1579 dd->ipath_f_setextled = ipath_setup_ht_setextled;
1600 dd->ipath_f_get_base_info = ipath_ht_get_base_info; 1580 dd->ipath_f_get_base_info = ipath_ht_get_base_info;
1581 dd->ipath_f_free_irq = ipath_ht_free_irq;
1601 1582
1602 /* 1583 /*
1603 * initialize chip-specific variables 1584 * initialize chip-specific variables
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6120.c b/drivers/infiniband/hw/ipath/ipath_iba6120.c
index a72ab9de386a..6af89683f710 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6120.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6120.c
@@ -851,6 +851,7 @@ static int ipath_setup_pe_config(struct ipath_devdata *dd,
851 int pos, ret; 851 int pos, ret;
852 852
853 dd->ipath_msi_lo = 0; /* used as a flag during reset processing */ 853 dd->ipath_msi_lo = 0; /* used as a flag during reset processing */
854 dd->ipath_irq = pdev->irq;
854 ret = pci_enable_msi(dd->pcidev); 855 ret = pci_enable_msi(dd->pcidev);
855 if (ret) 856 if (ret)
856 ipath_dev_err(dd, "pci_enable_msi failed: %d, " 857 ipath_dev_err(dd, "pci_enable_msi failed: %d, "
@@ -1323,6 +1324,12 @@ done:
1323 return 0; 1324 return 0;
1324} 1325}
1325 1326
1327static void ipath_pe_free_irq(struct ipath_devdata *dd)
1328{
1329 free_irq(dd->ipath_irq, dd);
1330 dd->ipath_irq = 0;
1331}
1332
1326/** 1333/**
1327 * ipath_init_iba6120_funcs - set up the chip-specific function pointers 1334 * ipath_init_iba6120_funcs - set up the chip-specific function pointers
1328 * @dd: the infinipath device 1335 * @dd: the infinipath device
@@ -1349,6 +1356,7 @@ void ipath_init_iba6120_funcs(struct ipath_devdata *dd)
1349 dd->ipath_f_cleanup = ipath_setup_pe_cleanup; 1356 dd->ipath_f_cleanup = ipath_setup_pe_cleanup;
1350 dd->ipath_f_setextled = ipath_setup_pe_setextled; 1357 dd->ipath_f_setextled = ipath_setup_pe_setextled;
1351 dd->ipath_f_get_base_info = ipath_pe_get_base_info; 1358 dd->ipath_f_get_base_info = ipath_pe_get_base_info;
1359 dd->ipath_f_free_irq = ipath_pe_free_irq;
1352 1360
1353 /* initialize chip-specific variables */ 1361 /* initialize chip-specific variables */
1354 dd->ipath_f_tidtemplate = ipath_pe_tidtemplate; 1362 dd->ipath_f_tidtemplate = ipath_pe_tidtemplate;
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index d9079ee12030..5652a550d442 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -710,14 +710,14 @@ static void ipath_bad_intr(struct ipath_devdata *dd, u32 * unexpectp)
710 * linuxbios development work, and it may happen in 710 * linuxbios development work, and it may happen in
711 * the future again. 711 * the future again.
712 */ 712 */
713 if (dd->pcidev && dd->pcidev->irq) { 713 if (dd->pcidev && dd->ipath_irq) {
714 ipath_dev_err(dd, "Now %u unexpected " 714 ipath_dev_err(dd, "Now %u unexpected "
715 "interrupts, unregistering " 715 "interrupts, unregistering "
716 "interrupt handler\n", 716 "interrupt handler\n",
717 *unexpectp); 717 *unexpectp);
718 ipath_dbg("free_irq of irq %x\n", 718 ipath_dbg("free_irq of irq %d\n",
719 dd->pcidev->irq); 719 dd->ipath_irq);
720 free_irq(dd->pcidev->irq, dd); 720 dd->ipath_f_free_irq(dd);
721 } 721 }
722 } 722 }
723 if (ipath_read_kreg32(dd, dd->ipath_kregs->kr_intmask)) { 723 if (ipath_read_kreg32(dd, dd->ipath_kregs->kr_intmask)) {
@@ -753,7 +753,7 @@ static void ipath_bad_regread(struct ipath_devdata *dd)
753 if (allbits == 2) { 753 if (allbits == 2) {
754 ipath_dev_err(dd, "Still bad interrupt status, " 754 ipath_dev_err(dd, "Still bad interrupt status, "
755 "unregistering interrupt\n"); 755 "unregistering interrupt\n");
756 free_irq(dd->pcidev->irq, dd); 756 dd->ipath_f_free_irq(dd);
757 } else if (allbits > 2) { 757 } else if (allbits > 2) {
758 if ((allbits % 10000) == 0) 758 if ((allbits % 10000) == 0)
759 printk("."); 759 printk(".");
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 06d5020a2f60..986b2125b8f5 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -213,6 +213,8 @@ struct ipath_devdata {
213 void (*ipath_f_setextled)(struct ipath_devdata *, u64, u64); 213 void (*ipath_f_setextled)(struct ipath_devdata *, u64, u64);
214 /* fill out chip-specific fields */ 214 /* fill out chip-specific fields */
215 int (*ipath_f_get_base_info)(struct ipath_portdata *, void *); 215 int (*ipath_f_get_base_info)(struct ipath_portdata *, void *);
216 /* free irq */
217 void (*ipath_f_free_irq)(struct ipath_devdata *);
216 struct ipath_ibdev *verbs_dev; 218 struct ipath_ibdev *verbs_dev;
217 struct timer_list verbs_timer; 219 struct timer_list verbs_timer;
218 /* total dwords sent (summed from counter) */ 220 /* total dwords sent (summed from counter) */
@@ -328,6 +330,8 @@ struct ipath_devdata {
328 /* so we can rewrite it after a chip reset */ 330 /* so we can rewrite it after a chip reset */
329 u32 ipath_pcibar1; 331 u32 ipath_pcibar1;
330 332
333 /* interrupt number */
334 int ipath_irq;
331 /* HT/PCI Vendor ID (here for NodeInfo) */ 335 /* HT/PCI Vendor ID (here for NodeInfo) */
332 u16 ipath_vendorid; 336 u16 ipath_vendorid;
333 /* HT/PCI Device ID (here for NodeInfo) */ 337 /* HT/PCI Device ID (here for NodeInfo) */
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 99a94d710935..768df7265b81 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -1820,11 +1820,11 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
1820 1820
1821#define MAD_IFC_BOX_SIZE 0x400 1821#define MAD_IFC_BOX_SIZE 0x400
1822#define MAD_IFC_MY_QPN_OFFSET 0x100 1822#define MAD_IFC_MY_QPN_OFFSET 0x100
1823#define MAD_IFC_RQPN_OFFSET 0x104 1823#define MAD_IFC_RQPN_OFFSET 0x108
1824#define MAD_IFC_SL_OFFSET 0x108 1824#define MAD_IFC_SL_OFFSET 0x10c
1825#define MAD_IFC_G_PATH_OFFSET 0x109 1825#define MAD_IFC_G_PATH_OFFSET 0x10d
1826#define MAD_IFC_RLID_OFFSET 0x10a 1826#define MAD_IFC_RLID_OFFSET 0x10e
1827#define MAD_IFC_PKEY_OFFSET 0x10e 1827#define MAD_IFC_PKEY_OFFSET 0x112
1828#define MAD_IFC_GRH_OFFSET 0x140 1828#define MAD_IFC_GRH_OFFSET 0x140
1829 1829
1830 inmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); 1830 inmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
@@ -1862,7 +1862,7 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
1862 1862
1863 val = in_wc->dlid_path_bits | 1863 val = in_wc->dlid_path_bits |
1864 (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0); 1864 (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0);
1865 MTHCA_PUT(inbox, val, MAD_IFC_GRH_OFFSET); 1865 MTHCA_PUT(inbox, val, MAD_IFC_G_PATH_OFFSET);
1866 1866
1867 MTHCA_PUT(inbox, in_wc->slid, MAD_IFC_RLID_OFFSET); 1867 MTHCA_PUT(inbox, in_wc->slid, MAD_IFC_RLID_OFFSET);
1868 MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET); 1868 MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
@@ -1870,7 +1870,7 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
1870 if (in_grh) 1870 if (in_grh)
1871 memcpy(inbox + MAD_IFC_GRH_OFFSET, in_grh, 40); 1871 memcpy(inbox + MAD_IFC_GRH_OFFSET, in_grh, 40);
1872 1872
1873 op_modifier |= 0x10; 1873 op_modifier |= 0x4;
1874 1874
1875 in_modifier |= in_wc->slid << 16; 1875 in_modifier |= in_wc->slid << 16;
1876 } 1876 }
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 1eaf00e9862c..85522daeb946 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -49,6 +49,8 @@
49 49
50#include <net/dst.h> 50#include <net/dst.h>
51 51
52#define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
53
52MODULE_AUTHOR("Roland Dreier"); 54MODULE_AUTHOR("Roland Dreier");
53MODULE_DESCRIPTION("IP-over-InfiniBand net driver"); 55MODULE_DESCRIPTION("IP-over-InfiniBand net driver");
54MODULE_LICENSE("Dual BSD/GPL"); 56MODULE_LICENSE("Dual BSD/GPL");
@@ -520,8 +522,7 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
520 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, 522 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
521 sizeof(union ib_gid)); 523 sizeof(union ib_gid));
522 524
523 ipoib_send(dev, skb, path->ah, 525 ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha));
524 be32_to_cpup((__be32 *) skb->dst->neighbour->ha));
525 } else { 526 } else {
526 neigh->ah = NULL; 527 neigh->ah = NULL;
527 __skb_queue_tail(&neigh->queue, skb); 528 __skb_queue_tail(&neigh->queue, skb);
@@ -599,8 +600,7 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
599 ipoib_dbg(priv, "Send unicast ARP to %04x\n", 600 ipoib_dbg(priv, "Send unicast ARP to %04x\n",
600 be16_to_cpu(path->pathrec.dlid)); 601 be16_to_cpu(path->pathrec.dlid));
601 602
602 ipoib_send(dev, skb, path->ah, 603 ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr));
603 be32_to_cpup((__be32 *) phdr->hwaddr));
604 } else if ((path->query || !path_rec_start(dev, path)) && 604 } else if ((path->query || !path_rec_start(dev, path)) &&
605 skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { 605 skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
606 /* put pseudoheader back on for next time */ 606 /* put pseudoheader back on for next time */
@@ -661,8 +661,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
661 goto out; 661 goto out;
662 } 662 }
663 663
664 ipoib_send(dev, skb, neigh->ah, 664 ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(skb->dst->neighbour->ha));
665 be32_to_cpup((__be32 *) skb->dst->neighbour->ha));
666 goto out; 665 goto out;
667 } 666 }
668 667
@@ -694,7 +693,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
694 IPOIB_GID_FMT "\n", 693 IPOIB_GID_FMT "\n",
695 skb->dst ? "neigh" : "dst", 694 skb->dst ? "neigh" : "dst",
696 be16_to_cpup((__be16 *) skb->data), 695 be16_to_cpup((__be16 *) skb->data),
697 be32_to_cpup((__be32 *) phdr->hwaddr), 696 IPOIB_QPN(phdr->hwaddr),
698 IPOIB_GID_RAW_ARG(phdr->hwaddr + 4)); 697 IPOIB_GID_RAW_ARG(phdr->hwaddr + 4));
699 dev_kfree_skb_any(skb); 698 dev_kfree_skb_any(skb);
700 ++priv->stats.tx_dropped; 699 ++priv->stats.tx_dropped;
@@ -777,7 +776,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
777 776
778 ipoib_dbg(priv, 777 ipoib_dbg(priv,
779 "neigh_destructor for %06x " IPOIB_GID_FMT "\n", 778 "neigh_destructor for %06x " IPOIB_GID_FMT "\n",
780 be32_to_cpup((__be32 *) n->ha), 779 IPOIB_QPN(n->ha),
781 IPOIB_GID_RAW_ARG(n->ha + 4)); 780 IPOIB_GID_RAW_ARG(n->ha + 4));
782 781
783 spin_lock_irqsave(&priv->lock, flags); 782 spin_lock_irqsave(&priv->lock, flags);
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index eb6f98d82289..9b2041e25d59 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -363,11 +363,11 @@ iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)
363 struct iscsi_conn *conn = cls_conn->dd_data; 363 struct iscsi_conn *conn = cls_conn->dd_data;
364 int err; 364 int err;
365 365
366 err = iscsi_conn_start(cls_conn); 366 err = iser_conn_set_full_featured_mode(conn);
367 if (err) 367 if (err)
368 return err; 368 return err;
369 369
370 return iser_conn_set_full_featured_mode(conn); 370 return iscsi_conn_start(cls_conn);
371} 371}
372 372
373static struct iscsi_transport iscsi_iser_transport; 373static struct iscsi_transport iscsi_iser_transport;
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 708d5a1bc3d2..979b93e33da7 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -59,11 +59,6 @@
59 * You should have received a copy of the GNU General Public License 59 * You should have received a copy of the GNU General Public License
60 * along with this program; if not, write to the Free Software 60 * along with this program; if not, write to the Free Software
61 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 61 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
62 *
63 * Should you need to contact me, the author, you can do so either by
64 * email or by paper mail:
65 * Jan-Benedict Glaw, Lilienstraße 16, 33790 Hörste (near Halle/Westf.),
66 * Germany.
67 */ 62 */
68 63
69#include <linux/delay.h> 64#include <linux/delay.h>
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c
index e31c6c55b2e2..58fca316786c 100644
--- a/drivers/input/touchscreen/hp680_ts_input.c
+++ b/drivers/input/touchscreen/hp680_ts_input.c
@@ -6,7 +6,7 @@
6#include <asm/io.h> 6#include <asm/io.h>
7#include <asm/delay.h> 7#include <asm/delay.h>
8#include <asm/adc.h> 8#include <asm/adc.h>
9#include <asm/hp6xx/hp6xx.h> 9#include <asm/hp6xx.h>
10 10
11#define MODNAME "hp680_ts_input" 11#define MODNAME "hp680_ts_input"
12 12
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index aca165d43aa0..5800beeebb85 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -616,7 +616,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
616 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 616 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
617 skb_reserve(bcs->skb, HW_HDR_LEN); 617 skb_reserve(bcs->skb, HW_HDR_LEN);
618 else { 618 else {
619 dev_warn(cs->dev, "could not allocate skb\n"); 619 warn("could not allocate skb\n");
620 bcs->inputstate |= INS_skip_frame; 620 bcs->inputstate |= INS_skip_frame;
621 } 621 }
622 622
diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index eb57a988e048..cfd2718a490d 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -344,7 +344,7 @@ config HISAX_HFC_SX
344 344
345config HISAX_ENTERNOW_PCI 345config HISAX_ENTERNOW_PCI
346 bool "Formula-n enter:now PCI card" 346 bool "Formula-n enter:now PCI card"
347 depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || FRV)) 347 depends on HISAX_NETJET && PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || FRV))
348 help 348 help
349 This enables HiSax support for the Formula-n enter:now PCI 349 This enables HiSax support for the Formula-n enter:now PCI
350 ISDN card. 350 ISDN card.
diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c
index 1fadf0133e9b..18758772b744 100644
--- a/drivers/isdn/hysdn/hysdn_sched.c
+++ b/drivers/isdn/hysdn/hysdn_sched.c
@@ -155,21 +155,17 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
155 if (card->debug_flags & LOG_SCHED_ASYN) 155 if (card->debug_flags & LOG_SCHED_ASYN)
156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); 156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
157 157
158 spin_lock_irqsave(&card->hysdn_lock, flags);
159 while (card->async_busy) { 158 while (card->async_busy) {
160 sti();
161 159
162 if (card->debug_flags & LOG_SCHED_ASYN) 160 if (card->debug_flags & LOG_SCHED_ASYN)
163 hysdn_addlog(card, "async tx-cfg delayed"); 161 hysdn_addlog(card, "async tx-cfg delayed");
164 162
165 msleep_interruptible(20); /* Timeout 20ms */ 163 msleep_interruptible(20); /* Timeout 20ms */
166 if (!--cnt) { 164 if (!--cnt)
167 spin_unlock_irqrestore(&card->hysdn_lock, flags);
168 return (-ERR_ASYNC_TIME); /* timed out */ 165 return (-ERR_ASYNC_TIME); /* timed out */
169 }
170 cli();
171 } /* wait for buffer to become free */ 166 } /* wait for buffer to become free */
172 167
168 spin_lock_irqsave(&card->hysdn_lock, flags);
173 strcpy(card->async_data, line); 169 strcpy(card->async_data, line);
174 card->async_len = strlen(line) + 1; 170 card->async_len = strlen(line) + 1;
175 card->async_channel = chan; 171 card->async_channel = chan;
@@ -177,30 +173,23 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
177 173
178 /* now queue the task */ 174 /* now queue the task */
179 schedule_work(&card->irq_queue); 175 schedule_work(&card->irq_queue);
180 sti(); 176 spin_unlock_irqrestore(&card->hysdn_lock, flags);
181 177
182 if (card->debug_flags & LOG_SCHED_ASYN) 178 if (card->debug_flags & LOG_SCHED_ASYN)
183 hysdn_addlog(card, "async tx-cfg data queued"); 179 hysdn_addlog(card, "async tx-cfg data queued");
184 180
185 cnt++; /* short delay */ 181 cnt++; /* short delay */
186 cli();
187 182
188 while (card->async_busy) { 183 while (card->async_busy) {
189 sti();
190 184
191 if (card->debug_flags & LOG_SCHED_ASYN) 185 if (card->debug_flags & LOG_SCHED_ASYN)
192 hysdn_addlog(card, "async tx-cfg waiting for tx-ready"); 186 hysdn_addlog(card, "async tx-cfg waiting for tx-ready");
193 187
194 msleep_interruptible(20); /* Timeout 20ms */ 188 msleep_interruptible(20); /* Timeout 20ms */
195 if (!--cnt) { 189 if (!--cnt)
196 spin_unlock_irqrestore(&card->hysdn_lock, flags);
197 return (-ERR_ASYNC_TIME); /* timed out */ 190 return (-ERR_ASYNC_TIME); /* timed out */
198 }
199 cli();
200 } /* wait for buffer to become free again */ 191 } /* wait for buffer to become free again */
201 192
202 spin_unlock_irqrestore(&card->hysdn_lock, flags);
203
204 if (card->debug_flags & LOG_SCHED_ASYN) 193 if (card->debug_flags & LOG_SCHED_ASYN)
205 hysdn_addlog(card, "async tx-cfg data send"); 194 hysdn_addlog(card, "async tx-cfg data send");
206 195
diff --git a/drivers/macintosh/windfarm_pm112.c b/drivers/macintosh/windfarm_pm112.c
index fa4b13f89369..b3fbb45bc90a 100644
--- a/drivers/macintosh/windfarm_pm112.c
+++ b/drivers/macintosh/windfarm_pm112.c
@@ -685,6 +685,17 @@ static int __init wf_pm112_init(void)
685 ++nr_cores; 685 ++nr_cores;
686 686
687 printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n"); 687 printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n");
688
689#ifdef MODULE
690 request_module("windfarm_smu_controls");
691 request_module("windfarm_smu_sensors");
692 request_module("windfarm_smu_sat");
693 request_module("windfarm_lm75_sensor");
694 request_module("windfarm_max6690_sensor");
695 request_module("windfarm_cpufreq_clamp");
696
697#endif /* MODULE */
698
688 platform_driver_register(&wf_pm112_driver); 699 platform_driver_register(&wf_pm112_driver);
689 return 0; 700 return 0;
690} 701}
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c
index 2a944851b8e1..f24fa734046a 100644
--- a/drivers/macintosh/windfarm_pm81.c
+++ b/drivers/macintosh/windfarm_pm81.c
@@ -788,6 +788,7 @@ static int __init wf_smu_init(void)
788 request_module("windfarm_smu_controls"); 788 request_module("windfarm_smu_controls");
789 request_module("windfarm_smu_sensors"); 789 request_module("windfarm_smu_sensors");
790 request_module("windfarm_lm75_sensor"); 790 request_module("windfarm_lm75_sensor");
791 request_module("windfarm_cpufreq_clamp");
791 792
792#endif /* MODULE */ 793#endif /* MODULE */
793 platform_driver_register(&wf_smu_driver); 794 platform_driver_register(&wf_smu_driver);
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c
index 9961a67b4f85..26eee69ebe6d 100644
--- a/drivers/macintosh/windfarm_pm91.c
+++ b/drivers/macintosh/windfarm_pm91.c
@@ -719,6 +719,7 @@ static int __init wf_smu_init(void)
719 request_module("windfarm_smu_controls"); 719 request_module("windfarm_smu_controls");
720 request_module("windfarm_smu_sensors"); 720 request_module("windfarm_smu_sensors");
721 request_module("windfarm_lm75_sensor"); 721 request_module("windfarm_lm75_sensor");
722 request_module("windfarm_cpufreq_clamp");
722 723
723#endif /* MODULE */ 724#endif /* MODULE */
724 platform_driver_register(&wf_smu_driver); 725 platform_driver_register(&wf_smu_driver);
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index d47d38ac71b1..d6f614738bbd 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -536,7 +536,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
536 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) " 536 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) "
537 "-- forcing full recovery\n", bmname(bitmap), events, 537 "-- forcing full recovery\n", bmname(bitmap), events,
538 (unsigned long long) bitmap->mddev->events); 538 (unsigned long long) bitmap->mddev->events);
539 sb->state |= BITMAP_STALE; 539 sb->state |= cpu_to_le32(BITMAP_STALE);
540 } 540 }
541success: 541success:
542 /* assign fields using values from superblock */ 542 /* assign fields using values from superblock */
@@ -544,11 +544,11 @@ success:
544 bitmap->daemon_sleep = daemon_sleep; 544 bitmap->daemon_sleep = daemon_sleep;
545 bitmap->daemon_lastrun = jiffies; 545 bitmap->daemon_lastrun = jiffies;
546 bitmap->max_write_behind = write_behind; 546 bitmap->max_write_behind = write_behind;
547 bitmap->flags |= sb->state; 547 bitmap->flags |= le32_to_cpu(sb->state);
548 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) 548 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
549 bitmap->flags |= BITMAP_HOSTENDIAN; 549 bitmap->flags |= BITMAP_HOSTENDIAN;
550 bitmap->events_cleared = le64_to_cpu(sb->events_cleared); 550 bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
551 if (sb->state & BITMAP_STALE) 551 if (sb->state & cpu_to_le32(BITMAP_STALE))
552 bitmap->events_cleared = bitmap->mddev->events; 552 bitmap->events_cleared = bitmap->mddev->events;
553 err = 0; 553 err = 0;
554out: 554out:
@@ -578,9 +578,9 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
578 spin_unlock_irqrestore(&bitmap->lock, flags); 578 spin_unlock_irqrestore(&bitmap->lock, flags);
579 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); 579 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
580 switch (op) { 580 switch (op) {
581 case MASK_SET: sb->state |= bits; 581 case MASK_SET: sb->state |= cpu_to_le32(bits);
582 break; 582 break;
583 case MASK_UNSET: sb->state &= ~bits; 583 case MASK_UNSET: sb->state &= cpu_to_le32(~bits);
584 break; 584 break;
585 default: BUG(); 585 default: BUG();
586 } 586 }
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index a625576fdeeb..08a40f4e4f60 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -915,8 +915,6 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
915 char *result, unsigned int maxlen) 915 char *result, unsigned int maxlen)
916{ 916{
917 struct crypt_config *cc = (struct crypt_config *) ti->private; 917 struct crypt_config *cc = (struct crypt_config *) ti->private;
918 const char *cipher;
919 const char *chainmode = NULL;
920 unsigned int sz = 0; 918 unsigned int sz = 0;
921 919
922 switch (type) { 920 switch (type) {
@@ -925,14 +923,11 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
925 break; 923 break;
926 924
927 case STATUSTYPE_TABLE: 925 case STATUSTYPE_TABLE:
928 cipher = crypto_blkcipher_name(cc->tfm);
929
930 chainmode = cc->chainmode;
931
932 if (cc->iv_mode) 926 if (cc->iv_mode)
933 DMEMIT("%s-%s-%s ", cipher, chainmode, cc->iv_mode); 927 DMEMIT("%s-%s-%s ", cc->cipher, cc->chainmode,
928 cc->iv_mode);
934 else 929 else
935 DMEMIT("%s-%s ", cipher, chainmode); 930 DMEMIT("%s-%s ", cc->cipher, cc->chainmode);
936 931
937 if (cc->key_size > 0) { 932 if (cc->key_size > 0) {
938 if ((maxlen - sz) < ((cc->key_size << 1) + 1)) 933 if ((maxlen - sz) < ((cc->key_size << 1) + 1))
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index d13bb15a8a02..4510ad8f971c 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -606,9 +606,14 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
606 return __get_name_cell(param->name); 606 return __get_name_cell(param->name);
607 607
608 md = dm_get_md(huge_decode_dev(param->dev)); 608 md = dm_get_md(huge_decode_dev(param->dev));
609 if (md) 609 if (!md)
610 mdptr = dm_get_mdptr(md); 610 goto out;
611 611
612 mdptr = dm_get_mdptr(md);
613 if (!mdptr)
614 dm_put(md);
615
616out:
612 return mdptr; 617 return mdptr;
613} 618}
614 619
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 659224cb7c53..48a653b3f518 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -24,6 +24,7 @@
24 24
25static struct workqueue_struct *_kmirrord_wq; 25static struct workqueue_struct *_kmirrord_wq;
26static struct work_struct _kmirrord_work; 26static struct work_struct _kmirrord_work;
27static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped);
27 28
28static inline void wake(void) 29static inline void wake(void)
29{ 30{
@@ -83,6 +84,7 @@ struct region_hash {
83 struct list_head *buckets; 84 struct list_head *buckets;
84 85
85 spinlock_t region_lock; 86 spinlock_t region_lock;
87 atomic_t recovery_in_flight;
86 struct semaphore recovery_count; 88 struct semaphore recovery_count;
87 struct list_head clean_regions; 89 struct list_head clean_regions;
88 struct list_head quiesced_regions; 90 struct list_head quiesced_regions;
@@ -191,6 +193,7 @@ static int rh_init(struct region_hash *rh, struct mirror_set *ms,
191 193
192 spin_lock_init(&rh->region_lock); 194 spin_lock_init(&rh->region_lock);
193 sema_init(&rh->recovery_count, 0); 195 sema_init(&rh->recovery_count, 0);
196 atomic_set(&rh->recovery_in_flight, 0);
194 INIT_LIST_HEAD(&rh->clean_regions); 197 INIT_LIST_HEAD(&rh->clean_regions);
195 INIT_LIST_HEAD(&rh->quiesced_regions); 198 INIT_LIST_HEAD(&rh->quiesced_regions);
196 INIT_LIST_HEAD(&rh->recovered_regions); 199 INIT_LIST_HEAD(&rh->recovered_regions);
@@ -382,6 +385,8 @@ static void rh_update_states(struct region_hash *rh)
382 rh->log->type->clear_region(rh->log, reg->key); 385 rh->log->type->clear_region(rh->log, reg->key);
383 rh->log->type->complete_resync_work(rh->log, reg->key, 1); 386 rh->log->type->complete_resync_work(rh->log, reg->key, 1);
384 dispatch_bios(rh->ms, &reg->delayed_bios); 387 dispatch_bios(rh->ms, &reg->delayed_bios);
388 if (atomic_dec_and_test(&rh->recovery_in_flight))
389 wake_up_all(&_kmirrord_recovery_stopped);
385 up(&rh->recovery_count); 390 up(&rh->recovery_count);
386 mempool_free(reg, rh->region_pool); 391 mempool_free(reg, rh->region_pool);
387 } 392 }
@@ -502,11 +507,21 @@ static int __rh_recovery_prepare(struct region_hash *rh)
502 507
503static void rh_recovery_prepare(struct region_hash *rh) 508static void rh_recovery_prepare(struct region_hash *rh)
504{ 509{
505 while (!down_trylock(&rh->recovery_count)) 510 /* Extra reference to avoid race with rh_stop_recovery */
511 atomic_inc(&rh->recovery_in_flight);
512
513 while (!down_trylock(&rh->recovery_count)) {
514 atomic_inc(&rh->recovery_in_flight);
506 if (__rh_recovery_prepare(rh) <= 0) { 515 if (__rh_recovery_prepare(rh) <= 0) {
516 atomic_dec(&rh->recovery_in_flight);
507 up(&rh->recovery_count); 517 up(&rh->recovery_count);
508 break; 518 break;
509 } 519 }
520 }
521
522 /* Drop the extra reference */
523 if (atomic_dec_and_test(&rh->recovery_in_flight))
524 wake_up_all(&_kmirrord_recovery_stopped);
510} 525}
511 526
512/* 527/*
@@ -1177,6 +1192,11 @@ static void mirror_postsuspend(struct dm_target *ti)
1177 struct dirty_log *log = ms->rh.log; 1192 struct dirty_log *log = ms->rh.log;
1178 1193
1179 rh_stop_recovery(&ms->rh); 1194 rh_stop_recovery(&ms->rh);
1195
1196 /* Wait for all I/O we generated to complete */
1197 wait_event(_kmirrord_recovery_stopped,
1198 !atomic_read(&ms->rh.recovery_in_flight));
1199
1180 if (log->type->suspend && log->type->suspend(log)) 1200 if (log->type->suspend && log->type->suspend(log))
1181 /* FIXME: need better error handling */ 1201 /* FIXME: need better error handling */
1182 DMWARN("log suspend failed"); 1202 DMWARN("log suspend failed");
diff --git a/drivers/md/dm-round-robin.c b/drivers/md/dm-round-robin.c
index c5a16c550122..6f9fcd4db9b5 100644
--- a/drivers/md/dm-round-robin.c
+++ b/drivers/md/dm-round-robin.c
@@ -136,7 +136,7 @@ static int rr_add_path(struct path_selector *ps, struct path *path,
136 136
137 path->pscontext = pi; 137 path->pscontext = pi;
138 138
139 list_add(&pi->list, &s->valid_paths); 139 list_add_tail(&pi->list, &s->valid_paths);
140 140
141 return 0; 141 return 0;
142} 142}
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b5764a86c8b5..fc4f743f3b53 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1285,7 +1285,7 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
1285 down(&md->suspend_lock); 1285 down(&md->suspend_lock);
1286 1286
1287 if (dm_suspended(md)) 1287 if (dm_suspended(md))
1288 goto out; 1288 goto out_unlock;
1289 1289
1290 map = dm_get_table(md); 1290 map = dm_get_table(md);
1291 1291
@@ -1361,6 +1361,8 @@ out:
1361 } 1361 }
1362 1362
1363 dm_table_put(map); 1363 dm_table_put(map);
1364
1365out_unlock:
1364 up(&md->suspend_lock); 1366 up(&md->suspend_lock);
1365 return r; 1367 return r;
1366} 1368}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f7f19088f3be..8cbf9c9df1c3 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -974,12 +974,13 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
974 * version 1 superblock 974 * version 1 superblock
975 */ 975 */
976 976
977static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb) 977static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
978{ 978{
979 unsigned int disk_csum, csum; 979 __le32 disk_csum;
980 u32 csum;
980 unsigned long long newcsum; 981 unsigned long long newcsum;
981 int size = 256 + le32_to_cpu(sb->max_dev)*2; 982 int size = 256 + le32_to_cpu(sb->max_dev)*2;
982 unsigned int *isuper = (unsigned int*)sb; 983 __le32 *isuper = (__le32*)sb;
983 int i; 984 int i;
984 985
985 disk_csum = sb->sb_csum; 986 disk_csum = sb->sb_csum;
@@ -989,7 +990,7 @@ static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
989 newcsum += le32_to_cpu(*isuper++); 990 newcsum += le32_to_cpu(*isuper++);
990 991
991 if (size == 2) 992 if (size == 2)
992 newcsum += le16_to_cpu(*(unsigned short*) isuper); 993 newcsum += le16_to_cpu(*(__le16*) isuper);
993 994
994 csum = (newcsum & 0xffffffff) + (newcsum >> 32); 995 csum = (newcsum & 0xffffffff) + (newcsum >> 32);
995 sb->sb_csum = disk_csum; 996 sb->sb_csum = disk_csum;
@@ -1106,7 +1107,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1106 if (le32_to_cpu(sb->chunksize)) 1107 if (le32_to_cpu(sb->chunksize))
1107 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1); 1108 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1);
1108 1109
1109 if (le32_to_cpu(sb->size) > rdev->size*2) 1110 if (le64_to_cpu(sb->size) > rdev->size*2)
1110 return -EINVAL; 1111 return -EINVAL;
1111 return ret; 1112 return ret;
1112} 1113}
@@ -1228,7 +1229,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1228 else 1229 else
1229 sb->resync_offset = cpu_to_le64(0); 1230 sb->resync_offset = cpu_to_le64(0);
1230 1231
1231 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors); 1232 sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
1232 1233
1233 sb->raid_disks = cpu_to_le32(mddev->raid_disks); 1234 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
1234 sb->size = cpu_to_le64(mddev->size<<1); 1235 sb->size = cpu_to_le64(mddev->size<<1);
@@ -2002,6 +2003,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
2002 kobject_init(&rdev->kobj); 2003 kobject_init(&rdev->kobj);
2003 2004
2004 rdev->desc_nr = -1; 2005 rdev->desc_nr = -1;
2006 rdev->saved_raid_disk = -1;
2005 rdev->flags = 0; 2007 rdev->flags = 0;
2006 rdev->data_offset = 0; 2008 rdev->data_offset = 0;
2007 rdev->sb_events = 0; 2009 rdev->sb_events = 0;
@@ -3198,6 +3200,7 @@ static int do_md_run(mddev_t * mddev)
3198 3200
3199 mddev->changed = 1; 3201 mddev->changed = 1;
3200 md_new_event(mddev); 3202 md_new_event(mddev);
3203 kobject_uevent(&mddev->gendisk->kobj, KOBJ_CHANGE);
3201 return 0; 3204 return 0;
3202} 3205}
3203 3206
@@ -4043,11 +4046,8 @@ static int update_size(mddev_t *mddev, unsigned long size)
4043 return -EBUSY; 4046 return -EBUSY;
4044 ITERATE_RDEV(mddev,rdev,tmp) { 4047 ITERATE_RDEV(mddev,rdev,tmp) {
4045 sector_t avail; 4048 sector_t avail;
4046 if (rdev->sb_offset > rdev->data_offset) 4049 avail = rdev->size * 2;
4047 avail = (rdev->sb_offset*2) - rdev->data_offset; 4050
4048 else
4049 avail = get_capacity(rdev->bdev->bd_disk)
4050 - rdev->data_offset;
4051 if (fit && (size == 0 || size > avail/2)) 4051 if (fit && (size == 0 || size > avail/2))
4052 size = avail/2; 4052 size = avail/2;
4053 if (avail < ((sector_t)size << 1)) 4053 if (avail < ((sector_t)size << 1))
@@ -4486,6 +4486,7 @@ static int md_thread(void * arg)
4486 * many dirty RAID5 blocks. 4486 * many dirty RAID5 blocks.
4487 */ 4487 */
4488 4488
4489 current->flags |= PF_NOFREEZE;
4489 allow_signal(SIGKILL); 4490 allow_signal(SIGKILL);
4490 while (!kthread_should_stop()) { 4491 while (!kthread_should_stop()) {
4491 4492
@@ -4502,7 +4503,6 @@ static int md_thread(void * arg)
4502 test_bit(THREAD_WAKEUP, &thread->flags) 4503 test_bit(THREAD_WAKEUP, &thread->flags)
4503 || kthread_should_stop(), 4504 || kthread_should_stop(),
4504 thread->timeout); 4505 thread->timeout);
4505 try_to_freeze();
4506 4506
4507 clear_bit(THREAD_WAKEUP, &thread->flags); 4507 clear_bit(THREAD_WAKEUP, &thread->flags);
4508 4508
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 171ff41b52b0..14da37fee37b 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -277,6 +277,7 @@ static void multipath_error (mddev_t *mddev, mdk_rdev_t *rdev)
277 set_bit(Faulty, &rdev->flags); 277 set_bit(Faulty, &rdev->flags);
278 set_bit(MD_CHANGE_DEVS, &mddev->flags); 278 set_bit(MD_CHANGE_DEVS, &mddev->flags);
279 conf->working_disks--; 279 conf->working_disks--;
280 mddev->degraded++;
280 printk(KERN_ALERT "multipath: IO failure on %s," 281 printk(KERN_ALERT "multipath: IO failure on %s,"
281 " disabling IO path. \n Operation continuing" 282 " disabling IO path. \n Operation continuing"
282 " on %d IO paths.\n", 283 " on %d IO paths.\n",
@@ -336,6 +337,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
336 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 337 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
337 338
338 conf->working_disks++; 339 conf->working_disks++;
340 mddev->degraded--;
339 rdev->raid_disk = path; 341 rdev->raid_disk = path;
340 set_bit(In_sync, &rdev->flags); 342 set_bit(In_sync, &rdev->flags);
341 rcu_assign_pointer(p->rdev, rdev); 343 rcu_assign_pointer(p->rdev, rdev);
@@ -501,7 +503,7 @@ static int multipath_run (mddev_t *mddev)
501 mdname(mddev)); 503 mdname(mddev));
502 goto out_free_conf; 504 goto out_free_conf;
503 } 505 }
504 mddev->degraded = conf->raid_disks = conf->working_disks; 506 mddev->degraded = conf->raid_disks - conf->working_disks;
505 507
506 conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS, 508 conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS,
507 sizeof(struct multipath_bh)); 509 sizeof(struct multipath_bh));
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index dc9d2def0270..656fae912fe3 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1474,8 +1474,8 @@ static void fix_read_error(conf_t *conf, int read_disk,
1474 "raid1:%s: read error corrected " 1474 "raid1:%s: read error corrected "
1475 "(%d sectors at %llu on %s)\n", 1475 "(%d sectors at %llu on %s)\n",
1476 mdname(mddev), s, 1476 mdname(mddev), s,
1477 (unsigned long long)sect + 1477 (unsigned long long)(sect +
1478 rdev->data_offset, 1478 rdev->data_offset),
1479 bdevname(rdev->bdev, b)); 1479 bdevname(rdev->bdev, b));
1480 } 1480 }
1481 } 1481 }
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 1250f0eab4af..7492d6033ac6 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1470,8 +1470,8 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1470 "raid10:%s: read error corrected" 1470 "raid10:%s: read error corrected"
1471 " (%d sectors at %llu on %s)\n", 1471 " (%d sectors at %llu on %s)\n",
1472 mdname(mddev), s, 1472 mdname(mddev), s,
1473 (unsigned long long)sect+ 1473 (unsigned long long)(sect+
1474 rdev->data_offset, 1474 rdev->data_offset),
1475 bdevname(rdev->bdev, b)); 1475 bdevname(rdev->bdev, b));
1476 1476
1477 rdev_dec_pending(rdev, mddev); 1477 rdev_dec_pending(rdev, mddev);
@@ -2079,7 +2079,7 @@ static int run(mddev_t *mddev)
2079 disk = conf->mirrors + i; 2079 disk = conf->mirrors + i;
2080 2080
2081 if (!disk->rdev || 2081 if (!disk->rdev ||
2082 !test_bit(In_sync, &rdev->flags)) { 2082 !test_bit(In_sync, &disk->rdev->flags)) {
2083 disk->head_position = 0; 2083 disk->head_position = 0;
2084 mddev->degraded++; 2084 mddev->degraded++;
2085 } 2085 }
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e14f45780720..69c3e201fa3b 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3659,7 +3659,7 @@ static void end_reshape(raid5_conf_t *conf)
3659 bdev = bdget_disk(conf->mddev->gendisk, 0); 3659 bdev = bdget_disk(conf->mddev->gendisk, 0);
3660 if (bdev) { 3660 if (bdev) {
3661 mutex_lock(&bdev->bd_inode->i_mutex); 3661 mutex_lock(&bdev->bd_inode->i_mutex);
3662 i_size_write(bdev->bd_inode, conf->mddev->array_size << 10); 3662 i_size_write(bdev->bd_inode, (loff_t)conf->mddev->array_size << 10);
3663 mutex_unlock(&bdev->bd_inode->i_mutex); 3663 mutex_unlock(&bdev->bd_inode->i_mutex);
3664 bdput(bdev); 3664 bdput(bdev);
3665 } 3665 }
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c
index d9953f7a8b6b..5297a365c928 100644
--- a/drivers/media/common/saa7146_i2c.c
+++ b/drivers/media/common/saa7146_i2c.c
@@ -217,11 +217,9 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
217 } 217 }
218 /* wait until we get a transfer done or error */ 218 /* wait until we get a transfer done or error */
219 timeout = jiffies + HZ/100 + 1; /* 10ms */ 219 timeout = jiffies + HZ/100 + 1; /* 10ms */
220 /* first read usually delivers bogus results... */
221 saa7146_i2c_status(dev);
220 while(1) { 222 while(1) {
221 /**
222 * first read usually delivers bogus results...
223 */
224 saa7146_i2c_status(dev);
225 status = saa7146_i2c_status(dev); 223 status = saa7146_i2c_status(dev);
226 if ((status & 0x3) != 1) 224 if ((status & 0x3) != 1)
227 break; 225 break;
@@ -232,10 +230,10 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
232 DEB_I2C(("saa7146_i2c_writeout: timed out waiting for end of xfer\n")); 230 DEB_I2C(("saa7146_i2c_writeout: timed out waiting for end of xfer\n"));
233 return -EIO; 231 return -EIO;
234 } 232 }
235 if ((++trial < 20) && short_delay) 233 if (++trial < 50 && short_delay)
236 udelay(10); 234 udelay(10);
237 else 235 else
238 msleep(1); 236 msleep(1);
239 } 237 }
240 } 238 }
241 239
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
index 2853ea1bdaf1..87fb75f0d1cf 100644
--- a/drivers/media/dvb/b2c2/flexcop-usb.c
+++ b/drivers/media/dvb/b2c2/flexcop-usb.c
@@ -246,7 +246,7 @@ static int flexcop_usb_i2c_req(struct flexcop_usb *fc_usb,
246 wIndex = (chipaddr << 8 ) | addr; 246 wIndex = (chipaddr << 8 ) | addr;
247 247
248 deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req, 248 deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req,
249 ((wValue && 0xff) << 8),wValue >> 8,((wIndex && 0xff) << 8),wIndex >> 8); 249 wValue & 0xff, wValue >> 8, wIndex & 0xff, wIndex >> 8);
250 250
251 len = usb_control_msg(fc_usb->udev,pipe, 251 len = usb_control_msg(fc_usb->udev,pipe,
252 req, 252 req,
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 53304e6991ac..a2ab2eebfc68 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -348,7 +348,7 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
348 348
349static void dvb_frontend_swzigzag(struct dvb_frontend *fe) 349static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
350{ 350{
351 fe_status_t s; 351 fe_status_t s = 0;
352 struct dvb_frontend_private *fepriv = fe->frontend_priv; 352 struct dvb_frontend_private *fepriv = fe->frontend_priv;
353 353
354 /* if we've got no parameters, just keep idling */ 354 /* if we've got no parameters, just keep idling */
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 2cc5caa26a0a..a263b3f3c21d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -26,7 +26,7 @@ config DVB_USB_A800
26 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)" 26 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)"
27 depends on DVB_USB 27 depends on DVB_USB
28 select DVB_DIB3000MC 28 select DVB_DIB3000MC
29 select DVB_TUNER_MT2060 29 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
30 help 30 help
31 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver. 31 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver.
32 32
@@ -34,7 +34,7 @@ config DVB_USB_DIBUSB_MB
34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)" 34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)"
35 depends on DVB_USB 35 depends on DVB_USB
36 select DVB_DIB3000MB 36 select DVB_DIB3000MB
37 select DVB_TUNER_MT2060 37 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
38 help 38 help
39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by 39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by
40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. 40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.
@@ -55,7 +55,7 @@ config DVB_USB_DIBUSB_MC
55 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)" 55 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)"
56 depends on DVB_USB 56 depends on DVB_USB
57 select DVB_DIB3000MC 57 select DVB_DIB3000MC
58 select DVB_TUNER_MT2060 58 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
59 help 59 help
60 Support for USB2.0 DVB-T receivers based on reference designs made by 60 Support for USB2.0 DVB-T receivers based on reference designs made by
61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. 61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.
@@ -70,7 +70,7 @@ config DVB_USB_DIB0700
70 tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)" 70 tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
71 depends on DVB_USB 71 depends on DVB_USB
72 select DVB_DIB3000MC 72 select DVB_DIB3000MC
73 select DVB_TUNER_MT2060 73 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
74 help 74 help
75 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The 75 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The
76 USB bridge is also present in devices having the DiB7700 DVB-T-USB 76 USB bridge is also present in devices having the DiB7700 DVB-T-USB
@@ -87,7 +87,7 @@ config DVB_USB_UMT_010
87 tristate "HanfTek UMT-010 DVB-T USB2.0 support" 87 tristate "HanfTek UMT-010 DVB-T USB2.0 support"
88 depends on DVB_USB 88 depends on DVB_USB
89 select DVB_DIB3000MC 89 select DVB_DIB3000MC
90 select DVB_TUNER_MT2060 90 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
91 help 91 help
92 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver. 92 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver.
93 93
@@ -153,7 +153,7 @@ config DVB_USB_NOVA_T_USB2
153 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" 153 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support"
154 depends on DVB_USB 154 depends on DVB_USB
155 select DVB_DIB3000MC 155 select DVB_DIB3000MC
156 select DVB_TUNER_MT2060 156 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
157 help 157 help
158 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver. 158 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver.
159 159
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 080fa257a0bc..aebb8d6f26f8 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -276,6 +276,8 @@ config DVB_TDA826X
276 276
277config DVB_TUNER_MT2060 277config DVB_TUNER_MT2060
278 tristate "Microtune MT2060 silicon IF tuner" 278 tristate "Microtune MT2060 silicon IF tuner"
279 depends on I2C
280 default m if DVB_FE_CUSTOMISE
279 help 281 help
280 A driver for the silicon IF tuner MT2060 from Microtune. 282 A driver for the silicon IF tuner MT2060 from Microtune.
281 283
diff --git a/drivers/media/dvb/frontends/bcm3510.h b/drivers/media/dvb/frontends/bcm3510.h
index 6dfa839a7022..7e4f95e1734b 100644
--- a/drivers/media/dvb/frontends/bcm3510.h
+++ b/drivers/media/dvb/frontends/bcm3510.h
@@ -34,7 +34,7 @@ struct bcm3510_config
34 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 34 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
35}; 35};
36 36
37#if defined(CONFIG_DVB_BCM3510) || defined(CONFIG_DVB_BCM3510_MODULE) 37#if defined(CONFIG_DVB_BCM3510) || (defined(CONFIG_DVB_BCM3510_MODULE) && defined(MODULE))
38extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config, 38extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/cx22700.h b/drivers/media/dvb/frontends/cx22700.h
index 10286cc29fb4..7ac33690cdcc 100644
--- a/drivers/media/dvb/frontends/cx22700.h
+++ b/drivers/media/dvb/frontends/cx22700.h
@@ -31,7 +31,7 @@ struct cx22700_config
31 u8 demod_address; 31 u8 demod_address;
32}; 32};
33 33
34#if defined(CONFIG_DVB_CX22700) || defined(CONFIG_DVB_CX22700_MODULE) 34#if defined(CONFIG_DVB_CX22700) || (defined(CONFIG_DVB_CX22700_MODULE) && defined(MODULE))
35extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, 35extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
36 struct i2c_adapter* i2c); 36 struct i2c_adapter* i2c);
37#else 37#else
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index bc217ddf02c0..9cd64da6ee40 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -41,7 +41,7 @@ struct cx22702_config
41 u8 output_mode; 41 u8 output_mode;
42}; 42};
43 43
44#if defined(CONFIG_DVB_CX22702) || defined(CONFIG_DVB_CX22702_MODULE) 44#if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) && defined(MODULE))
45extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 45extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
46 struct i2c_adapter* i2c); 46 struct i2c_adapter* i2c);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h
index c9d5ae250ebb..0ca3af4db513 100644
--- a/drivers/media/dvb/frontends/cx24110.h
+++ b/drivers/media/dvb/frontends/cx24110.h
@@ -41,7 +41,7 @@ static inline int cx24110_pll_write(struct dvb_frontend *fe, u32 val) {
41 return r; 41 return r;
42} 42}
43 43
44#if defined(CONFIG_DVB_CX24110) || defined(CONFIG_DVB_CX24110_MODULE) 44#if defined(CONFIG_DVB_CX24110) || (defined(CONFIG_DVB_CX24110_MODULE) && defined(MODULE))
45extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, 45extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
46 struct i2c_adapter* i2c); 46 struct i2c_adapter* i2c);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h
index 57a1dae1dc40..84f9e4f5c15e 100644
--- a/drivers/media/dvb/frontends/cx24123.h
+++ b/drivers/media/dvb/frontends/cx24123.h
@@ -35,7 +35,7 @@ struct cx24123_config
35 int lnb_polarity; 35 int lnb_polarity;
36}; 36};
37 37
38#if defined(CONFIG_DVB_CX24123) || defined(CONFIG_DVB_CX24123_MODULE) 38#if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE))
39extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 39extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h
index 0caac3f0f279..a6d3854a67bc 100644
--- a/drivers/media/dvb/frontends/dib3000.h
+++ b/drivers/media/dvb/frontends/dib3000.h
@@ -41,7 +41,7 @@ struct dib_fe_xfer_ops
41 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl); 41 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42}; 42};
43 43
44#if defined(CONFIG_DVB_DIB3000MB) || defined(CONFIG_DVB_DIB3000MB_MODULE) 44#if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
45extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, 45extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
46 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops); 46 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/dib3000mc.h b/drivers/media/dvb/frontends/dib3000mc.h
index 0d6fdef77538..72d4757601d8 100644
--- a/drivers/media/dvb/frontends/dib3000mc.h
+++ b/drivers/media/dvb/frontends/dib3000mc.h
@@ -39,7 +39,7 @@ struct dib3000mc_config {
39#define DEFAULT_DIB3000MC_I2C_ADDRESS 16 39#define DEFAULT_DIB3000MC_I2C_ADDRESS 16
40#define DEFAULT_DIB3000P_I2C_ADDRESS 24 40#define DEFAULT_DIB3000P_I2C_ADDRESS 24
41 41
42#if defined(CONFIG_DVB_DIB3000MC) || defined(CONFIG_DVB_DIB3000MC_MODULE) 42#if defined(CONFIG_DVB_DIB3000MC) || (defined(CONFIG_DVB_DIB3000MC_MODULE) && defined(MODULE))
43extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg); 43extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg);
44#else 44#else
45static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg) 45static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg)
diff --git a/drivers/media/dvb/frontends/isl6421.h b/drivers/media/dvb/frontends/isl6421.h
index 1916e3eb2df3..ea7f78a7d3cd 100644
--- a/drivers/media/dvb/frontends/isl6421.h
+++ b/drivers/media/dvb/frontends/isl6421.h
@@ -39,7 +39,7 @@
39#define ISL6421_ISEL1 0x20 39#define ISL6421_ISEL1 0x20
40#define ISL6421_DCL 0x40 40#define ISL6421_DCL 0x40
41 41
42#if defined(CONFIG_DVB_ISL6421) || defined(CONFIG_DVB_ISL6421_MODULE) 42#if defined(CONFIG_DVB_ISL6421) || (defined(CONFIG_DVB_ISL6421_MODULE) && defined(MODULE))
43/* override_set and override_clear control which system register bits (above) to always set & clear */ 43/* override_set and override_clear control which system register bits (above) to always set & clear */
44extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, 44extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
45 u8 override_set, u8 override_clear); 45 u8 override_set, u8 override_clear);
diff --git a/drivers/media/dvb/frontends/l64781.h b/drivers/media/dvb/frontends/l64781.h
index 21ba4a230760..cd15f76ff28d 100644
--- a/drivers/media/dvb/frontends/l64781.h
+++ b/drivers/media/dvb/frontends/l64781.h
@@ -31,7 +31,7 @@ struct l64781_config
31 u8 demod_address; 31 u8 demod_address;
32}; 32};
33 33
34#if defined(CONFIG_DVB_L64781) || defined(CONFIG_DVB_L64781_MODULE) 34#if defined(CONFIG_DVB_L64781) || (defined(CONFIG_DVB_L64781_MODULE) && defined(MODULE))
35extern struct dvb_frontend* l64781_attach(const struct l64781_config* config, 35extern struct dvb_frontend* l64781_attach(const struct l64781_config* config,
36 struct i2c_adapter* i2c); 36 struct i2c_adapter* i2c);
37#else 37#else
diff --git a/drivers/media/dvb/frontends/lgdt330x.h b/drivers/media/dvb/frontends/lgdt330x.h
index 3f96b485584c..995059004b10 100644
--- a/drivers/media/dvb/frontends/lgdt330x.h
+++ b/drivers/media/dvb/frontends/lgdt330x.h
@@ -52,7 +52,7 @@ struct lgdt330x_config
52 int clock_polarity_flip; 52 int clock_polarity_flip;
53}; 53};
54 54
55#if defined(CONFIG_DVB_LGDT330X) || defined(CONFIG_DVB_LGDT330X_MODULE) 55#if defined(CONFIG_DVB_LGDT330X) || (defined(CONFIG_DVB_LGDT330X_MODULE) && defined(MODULE))
56extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config, 56extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
57 struct i2c_adapter* i2c); 57 struct i2c_adapter* i2c);
58#else 58#else
diff --git a/drivers/media/dvb/frontends/lnbp21.h b/drivers/media/dvb/frontends/lnbp21.h
index 1fe1dd179312..68906acf7d63 100644
--- a/drivers/media/dvb/frontends/lnbp21.h
+++ b/drivers/media/dvb/frontends/lnbp21.h
@@ -39,7 +39,7 @@
39 39
40#include <linux/dvb/frontend.h> 40#include <linux/dvb/frontend.h>
41 41
42#if defined(CONFIG_DVB_LNBP21) || defined(CONFIG_DVB_LNBP21_MODULE) 42#if defined(CONFIG_DVB_LNBP21) || (defined(CONFIG_DVB_LNBP21_MODULE) && defined(MODULE))
43/* override_set and override_clear control which system register bits (above) to always set & clear */ 43/* override_set and override_clear control which system register bits (above) to always set & clear */
44extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear); 44extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear);
45#else 45#else
diff --git a/drivers/media/dvb/frontends/mt2060.h b/drivers/media/dvb/frontends/mt2060.h
index 34a37c2b556f..0a86eab3a954 100644
--- a/drivers/media/dvb/frontends/mt2060.h
+++ b/drivers/media/dvb/frontends/mt2060.h
@@ -30,6 +30,14 @@ struct mt2060_config {
30 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */ 30 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */
31}; 31};
32 32
33#if defined(CONFIG_DVB_TUNER_MT2060) || (defined(CONFIG_DVB_TUNER_MT2060_MODULE) && defined(MODULE))
33extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1); 34extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1);
35#else
36static inline struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1)
37{
38 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
39 return NULL;
40}
41#endif // CONFIG_DVB_TUNER_MT2060
34 42
35#endif 43#endif
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
index 7112fb4d58ac..cf9a1505ad4b 100644
--- a/drivers/media/dvb/frontends/mt312.h
+++ b/drivers/media/dvb/frontends/mt312.h
@@ -34,7 +34,7 @@ struct mt312_config
34 u8 demod_address; 34 u8 demod_address;
35}; 35};
36 36
37#if defined(CONFIG_DVB_MT312) || defined(CONFIG_DVB_MT312_MODULE) 37#if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE))
38struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, 38struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h
index 0035c2e2d7c2..e9964081fd84 100644
--- a/drivers/media/dvb/frontends/mt352.h
+++ b/drivers/media/dvb/frontends/mt352.h
@@ -51,7 +51,7 @@ struct mt352_config
51 int (*demod_init)(struct dvb_frontend* fe); 51 int (*demod_init)(struct dvb_frontend* fe);
52}; 52};
53 53
54#if defined(CONFIG_DVB_MT352) || defined(CONFIG_DVB_MT352_MODULE) 54#if defined(CONFIG_DVB_MT352) || (defined(CONFIG_DVB_MT352_MODULE) && defined(MODULE))
55extern struct dvb_frontend* mt352_attach(const struct mt352_config* config, 55extern struct dvb_frontend* mt352_attach(const struct mt352_config* config,
56 struct i2c_adapter* i2c); 56 struct i2c_adapter* i2c);
57#else 57#else
diff --git a/drivers/media/dvb/frontends/nxt200x.h b/drivers/media/dvb/frontends/nxt200x.h
index 2eb220e98062..28bc5591b319 100644
--- a/drivers/media/dvb/frontends/nxt200x.h
+++ b/drivers/media/dvb/frontends/nxt200x.h
@@ -45,7 +45,7 @@ struct nxt200x_config
45 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 45 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
46}; 46};
47 47
48#if defined(CONFIG_DVB_NXT200X) || defined(CONFIG_DVB_NXT200X_MODULE) 48#if defined(CONFIG_DVB_NXT200X) || (defined(CONFIG_DVB_NXT200X_MODULE) && defined(MODULE))
49extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config, 49extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
50 struct i2c_adapter* i2c); 50 struct i2c_adapter* i2c);
51#else 51#else
diff --git a/drivers/media/dvb/frontends/nxt6000.h b/drivers/media/dvb/frontends/nxt6000.h
index 9397393a6bd1..13d22518356e 100644
--- a/drivers/media/dvb/frontends/nxt6000.h
+++ b/drivers/media/dvb/frontends/nxt6000.h
@@ -33,7 +33,7 @@ struct nxt6000_config
33 u8 clock_inversion:1; 33 u8 clock_inversion:1;
34}; 34};
35 35
36#if defined(CONFIG_DVB_NXT6000) || defined(CONFIG_DVB_NXT6000_MODULE) 36#if defined(CONFIG_DVB_NXT6000) || (defined(CONFIG_DVB_NXT6000_MODULE) && defined(MODULE))
37extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, 37extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
38 struct i2c_adapter* i2c); 38 struct i2c_adapter* i2c);
39#else 39#else
diff --git a/drivers/media/dvb/frontends/or51132.h b/drivers/media/dvb/frontends/or51132.h
index 9718be4fb835..add24f0a743b 100644
--- a/drivers/media/dvb/frontends/or51132.h
+++ b/drivers/media/dvb/frontends/or51132.h
@@ -34,7 +34,7 @@ struct or51132_config
34 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 34 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
35}; 35};
36 36
37#if defined(CONFIG_DVB_OR51132) || defined(CONFIG_DVB_OR51132_MODULE) 37#if defined(CONFIG_DVB_OR51132) || (defined(CONFIG_DVB_OR51132_MODULE) && defined(MODULE))
38extern struct dvb_frontend* or51132_attach(const struct or51132_config* config, 38extern struct dvb_frontend* or51132_attach(const struct or51132_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/or51211.h b/drivers/media/dvb/frontends/or51211.h
index 10a5419f9e00..8aad8402d615 100644
--- a/drivers/media/dvb/frontends/or51211.h
+++ b/drivers/media/dvb/frontends/or51211.h
@@ -37,7 +37,7 @@ struct or51211_config
37 void (*sleep)(struct dvb_frontend * fe); 37 void (*sleep)(struct dvb_frontend * fe);
38}; 38};
39 39
40#if defined(CONFIG_DVB_OR51211) || defined(CONFIG_DVB_OR51211_MODULE) 40#if defined(CONFIG_DVB_OR51211) || (defined(CONFIG_DVB_OR51211_MODULE) && defined(MODULE))
41extern struct dvb_frontend* or51211_attach(const struct or51211_config* config, 41extern struct dvb_frontend* or51211_attach(const struct or51211_config* config,
42 struct i2c_adapter* i2c); 42 struct i2c_adapter* i2c);
43#else 43#else
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
index efc54d7f3c55..1555870f7226 100644
--- a/drivers/media/dvb/frontends/s5h1420.h
+++ b/drivers/media/dvb/frontends/s5h1420.h
@@ -34,7 +34,7 @@ struct s5h1420_config
34 u8 invert:1; 34 u8 invert:1;
35}; 35};
36 36
37#if defined(CONFIG_DVB_S5H1420) || defined(CONFIG_DVB_S5H1420_MODULE) 37#if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE))
38extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, 38extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/sp8870.h b/drivers/media/dvb/frontends/sp8870.h
index 4cf27d3b10f2..909cefe7139e 100644
--- a/drivers/media/dvb/frontends/sp8870.h
+++ b/drivers/media/dvb/frontends/sp8870.h
@@ -35,7 +35,7 @@ struct sp8870_config
35 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 35 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
36}; 36};
37 37
38#if defined(CONFIG_DVB_SP8870) || defined(CONFIG_DVB_SP8870_MODULE) 38#if defined(CONFIG_DVB_SP8870) || (defined(CONFIG_DVB_SP8870_MODULE) && defined(MODULE))
39extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, 39extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/sp887x.h b/drivers/media/dvb/frontends/sp887x.h
index cab7ea644dfa..7ee78d7d916d 100644
--- a/drivers/media/dvb/frontends/sp887x.h
+++ b/drivers/media/dvb/frontends/sp887x.h
@@ -17,7 +17,7 @@ struct sp887x_config
17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
18}; 18};
19 19
20#if defined(CONFIG_DVB_SP887X) || defined(CONFIG_DVB_SP887X_MODULE) 20#if defined(CONFIG_DVB_SP887X) || (defined(CONFIG_DVB_SP887X_MODULE) && defined(MODULE))
21extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, 21extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
22 struct i2c_adapter* i2c); 22 struct i2c_adapter* i2c);
23#else 23#else
diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h
index 760b80db43a5..69f4515df2b9 100644
--- a/drivers/media/dvb/frontends/stv0297.h
+++ b/drivers/media/dvb/frontends/stv0297.h
@@ -42,7 +42,7 @@ struct stv0297_config
42 u8 stop_during_read:1; 42 u8 stop_during_read:1;
43}; 43};
44 44
45#if defined(CONFIG_DVB_STV0297) || defined(CONFIG_DVB_STV0297_MODULE) 45#if defined(CONFIG_DVB_STV0297) || (defined(CONFIG_DVB_STV0297_MODULE) && defined(MODULE))
46extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, 46extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
47 struct i2c_adapter* i2c); 47 struct i2c_adapter* i2c);
48#else 48#else
diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h
index 7ef25207081d..33df9495908f 100644
--- a/drivers/media/dvb/frontends/stv0299.h
+++ b/drivers/media/dvb/frontends/stv0299.h
@@ -89,7 +89,7 @@ struct stv0299_config
89 int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); 89 int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio);
90}; 90};
91 91
92#if defined(CONFIG_DVB_STV0299) || defined(CONFIG_DVB_STV0299_MODULE) 92#if defined(CONFIG_DVB_STV0299) || (defined(CONFIG_DVB_STV0299_MODULE) && defined(MODULE))
93extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, 93extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
94 struct i2c_adapter* i2c); 94 struct i2c_adapter* i2c);
95#else 95#else
diff --git a/drivers/media/dvb/frontends/tda10021.h b/drivers/media/dvb/frontends/tda10021.h
index d68ae20c8412..e3da780108f6 100644
--- a/drivers/media/dvb/frontends/tda10021.h
+++ b/drivers/media/dvb/frontends/tda10021.h
@@ -32,7 +32,7 @@ struct tda10021_config
32 u8 demod_address; 32 u8 demod_address;
33}; 33};
34 34
35#if defined(CONFIG_DVB_TDA10021) || defined(CONFIG_DVB_TDA10021_MODULE) 35#if defined(CONFIG_DVB_TDA10021) || (defined(CONFIG_DVB_TDA10021_MODULE) && defined(MODULE))
36extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config, 36extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
37 struct i2c_adapter* i2c, u8 pwm); 37 struct i2c_adapter* i2c, u8 pwm);
38#else 38#else
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
index e28fca05734c..605ad2dfc09d 100644
--- a/drivers/media/dvb/frontends/tda1004x.h
+++ b/drivers/media/dvb/frontends/tda1004x.h
@@ -71,7 +71,7 @@ struct tda1004x_config
71 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 71 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
72}; 72};
73 73
74#if defined(CONFIG_DVB_TDA1004X) || defined(CONFIG_DVB_TDA1004X_MODULE) 74#if defined(CONFIG_DVB_TDA1004X) || (defined(CONFIG_DVB_TDA1004X_MODULE) && defined(MODULE))
75extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, 75extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
76 struct i2c_adapter* i2c); 76 struct i2c_adapter* i2c);
77 77
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c
index 7456b0b9976b..4c27a2d90a38 100644
--- a/drivers/media/dvb/frontends/tda10086.c
+++ b/drivers/media/dvb/frontends/tda10086.c
@@ -441,6 +441,10 @@ static int tda10086_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa
441 441
442 dprintk ("%s\n", __FUNCTION__); 442 dprintk ("%s\n", __FUNCTION__);
443 443
444 // check for invalid symbol rate
445 if (fe_params->u.qpsk.symbol_rate < 500000)
446 return -EINVAL;
447
444 // calculate the updated frequency (note: we convert from Hz->kHz) 448 // calculate the updated frequency (note: we convert from Hz->kHz)
445 tmp64 = tda10086_read_byte(state, 0x52); 449 tmp64 = tda10086_read_byte(state, 0x52);
446 tmp64 |= (tda10086_read_byte(state, 0x51) << 8); 450 tmp64 |= (tda10086_read_byte(state, 0x51) << 8);
diff --git a/drivers/media/dvb/frontends/tda10086.h b/drivers/media/dvb/frontends/tda10086.h
index 18457adee30b..ed584a8f4a89 100644
--- a/drivers/media/dvb/frontends/tda10086.h
+++ b/drivers/media/dvb/frontends/tda10086.h
@@ -35,7 +35,7 @@ struct tda10086_config
35 u8 invert; 35 u8 invert;
36}; 36};
37 37
38#if defined(CONFIG_DVB_TDA10086) || defined(CONFIG_DVB_TDA10086_MODULE) 38#if defined(CONFIG_DVB_TDA10086) || (defined(CONFIG_DVB_TDA10086_MODULE) && defined(MODULE))
39extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config, 39extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/tda8083.h b/drivers/media/dvb/frontends/tda8083.h
index aae15bdce6eb..2d3307999f21 100644
--- a/drivers/media/dvb/frontends/tda8083.h
+++ b/drivers/media/dvb/frontends/tda8083.h
@@ -35,7 +35,7 @@ struct tda8083_config
35 u8 demod_address; 35 u8 demod_address;
36}; 36};
37 37
38#if defined(CONFIG_DVB_TDA8083) || defined(CONFIG_DVB_TDA8083_MODULE) 38#if defined(CONFIG_DVB_TDA8083) || (defined(CONFIG_DVB_TDA8083_MODULE) && defined(MODULE))
39extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, 39extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c
index eeab26bd36ed..34815b0b97e4 100644
--- a/drivers/media/dvb/frontends/tda826x.c
+++ b/drivers/media/dvb/frontends/tda826x.c
@@ -121,7 +121,7 @@ static struct dvb_tuner_ops tda826x_tuner_ops = {
121 .info = { 121 .info = {
122 .name = "Philips TDA826X", 122 .name = "Philips TDA826X",
123 .frequency_min = 950000, 123 .frequency_min = 950000,
124 .frequency_min = 2175000 124 .frequency_max = 2175000
125 }, 125 },
126 .release = tda826x_release, 126 .release = tda826x_release,
127 .sleep = tda826x_sleep, 127 .sleep = tda826x_sleep,
diff --git a/drivers/media/dvb/frontends/tda826x.h b/drivers/media/dvb/frontends/tda826x.h
index 83998c001196..ad9981195961 100644
--- a/drivers/media/dvb/frontends/tda826x.h
+++ b/drivers/media/dvb/frontends/tda826x.h
@@ -35,7 +35,7 @@
35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector. 35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector.
36 * @return FE pointer on success, NULL on failure. 36 * @return FE pointer on success, NULL on failure.
37 */ 37 */
38#if defined(CONFIG_DVB_TDA826X) || defined(CONFIG_DVB_TDA826X_MODULE) 38#if defined(CONFIG_DVB_TDA826X) || (defined(CONFIG_DVB_TDA826X_MODULE) && defined(MODULE))
39extern struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe, int addr, 39extern struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe, int addr,
40 struct i2c_adapter *i2c, 40 struct i2c_adapter *i2c,
41 int has_loopthrough); 41 int has_loopthrough);
diff --git a/drivers/media/dvb/frontends/tua6100.h b/drivers/media/dvb/frontends/tua6100.h
index 8f98033ffa7b..03a665e7df6d 100644
--- a/drivers/media/dvb/frontends/tua6100.h
+++ b/drivers/media/dvb/frontends/tua6100.h
@@ -34,7 +34,7 @@
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include "dvb_frontend.h" 35#include "dvb_frontend.h"
36 36
37#if defined(CONFIG_DVB_TUA6100) || defined(CONFIG_DVB_TUA6100_MODULE) 37#if defined(CONFIG_DVB_TUA6100) || (defined(CONFIG_DVB_TUA6100_MODULE) && defined(MODULE))
38extern struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c); 38extern struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c);
39#else 39#else
40static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c) 40static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c)
diff --git a/drivers/media/dvb/frontends/ves1820.h b/drivers/media/dvb/frontends/ves1820.h
index f0c9dded39d7..e4a2a324046a 100644
--- a/drivers/media/dvb/frontends/ves1820.h
+++ b/drivers/media/dvb/frontends/ves1820.h
@@ -41,7 +41,7 @@ struct ves1820_config
41 u8 selagc:1; 41 u8 selagc:1;
42}; 42};
43 43
44#if defined(CONFIG_DVB_VES1820) || defined(CONFIG_DVB_VES1820_MODULE) 44#if defined(CONFIG_DVB_VES1820) || (defined(CONFIG_DVB_VES1820_MODULE) && defined(MODULE))
45extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, 45extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
46 struct i2c_adapter* i2c, u8 pwm); 46 struct i2c_adapter* i2c, u8 pwm);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/ves1x93.h b/drivers/media/dvb/frontends/ves1x93.h
index 395fed39b286..d507f8966f81 100644
--- a/drivers/media/dvb/frontends/ves1x93.h
+++ b/drivers/media/dvb/frontends/ves1x93.h
@@ -40,7 +40,7 @@ struct ves1x93_config
40 u8 invert_pwm:1; 40 u8 invert_pwm:1;
41}; 41};
42 42
43#if defined(CONFIG_DVB_VES1X93) || defined(CONFIG_DVB_VES1X93_MODULE) 43#if defined(CONFIG_DVB_VES1X93) || (defined(CONFIG_DVB_VES1X93_MODULE) && defined(MODULE))
44extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, 44extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
45 struct i2c_adapter* i2c); 45 struct i2c_adapter* i2c);
46#else 46#else
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h
index 79a947215c4d..0bc0109737f1 100644
--- a/drivers/media/dvb/frontends/zl10353.h
+++ b/drivers/media/dvb/frontends/zl10353.h
@@ -36,7 +36,7 @@ struct zl10353_config
36 int parallel_ts; 36 int parallel_ts;
37}; 37};
38 38
39#if defined(CONFIG_DVB_ZL10353) || defined(CONFIG_DVB_ZL10353_MODULE) 39#if defined(CONFIG_DVB_ZL10353) || (defined(CONFIG_DVB_ZL10353_MODULE) && defined(MODULE))
40extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config, 40extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config,
41 struct i2c_adapter *i2c); 41 struct i2c_adapter *i2c);
42#else 42#else
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 2a2e9b400613..cd5ec489af1c 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -46,7 +46,14 @@
46#include "bsbe1.h" 46#include "bsbe1.h"
47#include "bsru6.h" 47#include "bsru6.h"
48 48
49#define DEBIADDR_IR 0x1234 49/*
50 * Regarding DEBIADDR_IR:
51 * Some CI modules hang if random addresses are read.
52 * Using address 0x4000 for the IR read means that we
53 * use the same address as for CI version, which should
54 * be a safe default.
55 */
56#define DEBIADDR_IR 0x4000
50#define DEBIADDR_CICONTROL 0x0000 57#define DEBIADDR_CICONTROL 0x0000
51#define DEBIADDR_CIVERSION 0x4000 58#define DEBIADDR_CIVERSION 0x4000
52#define DEBIADDR_IO 0x1000 59#define DEBIADDR_IO 0x1000
@@ -1028,6 +1035,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1028 1035
1029 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) 1036 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
1030 budget_ci->tuner_pll_address = 0x60; 1037 budget_ci->tuner_pll_address = 0x60;
1038 philips_tdm1316l_config.invert = 1;
1031 budget_ci->budget.dvb_frontend = 1039 budget_ci->budget.dvb_frontend =
1032 dvb_attach(tda10046_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1040 dvb_attach(tda10046_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1033 if (budget_ci->budget.dvb_frontend) { 1041 if (budget_ci->budget.dvb_frontend) {
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index e58f0391e9d1..56f1c80defc6 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -46,6 +46,10 @@
46#include "lnbp21.h" 46#include "lnbp21.h"
47#include "bsru6.h" 47#include "bsru6.h"
48 48
49static int diseqc_method;
50module_param(diseqc_method, int, 0444);
51MODULE_PARM_DESC(diseqc_method, "Select DiSEqC method for subsystem id 13c2:1003, 0: default, 1: more reliable (for newer revisions only)");
52
49static void Set22K (struct budget *budget, int state) 53static void Set22K (struct budget *budget, int state)
50{ 54{
51 struct saa7146_dev *dev=budget->dev; 55 struct saa7146_dev *dev=budget->dev;
@@ -382,6 +386,11 @@ static void frontend_init(struct budget *budget)
382 if (budget->dvb_frontend) { 386 if (budget->dvb_frontend) {
383 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 387 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
384 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 388 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
389 if (budget->dev->pci->subsystem_device == 0x1003 && diseqc_method == 0) {
390 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
391 budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
392 budget->dvb_frontend->ops.set_tone = budget_set_tone;
393 }
385 break; 394 break;
386 } 395 }
387 break; 396 break;
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index fbe5b6168cc2..bf267552941f 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -186,7 +186,7 @@ config VIDEO_KS0127
186 186
187config VIDEO_SAA7110 187config VIDEO_SAA7110
188 tristate "Philips SAA7110 video decoder" 188 tristate "Philips SAA7110 video decoder"
189 depends on VIDEO_V4L1 189 depends on VIDEO_V4L1 && I2C
190 ---help--- 190 ---help---
191 Support for the Philips SAA7110 video decoders. 191 Support for the Philips SAA7110 video decoders.
192 192
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index a84903e0d810..21ebe8f13815 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -4001,7 +4001,7 @@ static void __devinit init_PXC200(struct bttv *btv)
4001 * - sleep 1ms 4001 * - sleep 1ms
4002 * - write 0x0E 4002 * - write 0x0E
4003 * read from GPIO_DATA into buf (uint_32) 4003 * read from GPIO_DATA into buf (uint_32)
4004 * - if ( buf>>18 & 0x01 ) || ( buf>>19 && 0x01 != 0 ) 4004 * - if ( buf>>18 & 0x01 ) || ( buf>>19 & 0x01 != 0 )
4005 * error. ERROR_CPLD_Check_Failed. 4005 * error. ERROR_CPLD_Check_Failed.
4006 */ 4006 */
4007/* ----------------------------------------------------------------------- */ 4007/* ----------------------------------------------------------------------- */
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index ee48995a4ab5..57e1c024a547 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -202,13 +202,19 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
202 ir->sampling = 1; 202 ir->sampling = 1;
203 break; 203 break;
204 case CX88_BOARD_WINFAST_DTV2000H: 204 case CX88_BOARD_WINFAST_DTV2000H:
205 case CX88_BOARD_WINFAST2000XP_EXPERT:
206 ir_codes = ir_codes_winfast; 205 ir_codes = ir_codes_winfast;
207 ir->gpio_addr = MO_GP0_IO; 206 ir->gpio_addr = MO_GP0_IO;
208 ir->mask_keycode = 0x8f8; 207 ir->mask_keycode = 0x8f8;
209 ir->mask_keyup = 0x100; 208 ir->mask_keyup = 0x100;
210 ir->polling = 50; /* ms */ 209 ir->polling = 50; /* ms */
211 break; 210 break;
211 case CX88_BOARD_WINFAST2000XP_EXPERT:
212 ir_codes = ir_codes_winfast;
213 ir->gpio_addr = MO_GP0_IO;
214 ir->mask_keycode = 0x8f8;
215 ir->mask_keyup = 0x100;
216 ir->polling = 1; /* ms */
217 break;
212 case CX88_BOARD_IODATA_GVBCTV7E: 218 case CX88_BOARD_IODATA_GVBCTV7E:
213 ir_codes = ir_codes_iodata_bctv7e; 219 ir_codes = ir_codes_iodata_bctv7e;
214 ir->gpio_addr = MO_GP0_IO; 220 ir->gpio_addr = MO_GP0_IO;
@@ -216,7 +222,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
216 ir->mask_keydown = 0x02; 222 ir->mask_keydown = 0x02;
217 ir->polling = 5; /* ms */ 223 ir->polling = 5; /* ms */
218 break; 224 break;
219 case CX88_BOARD_PROLINK_PLAYTVPVR: 225 case CX88_BOARD_PROLINK_PLAYTVPVR:
220 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO: 226 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
221 ir_codes = ir_codes_pixelview; 227 ir_codes = ir_codes_pixelview;
222 ir->gpio_addr = MO_GP1_IO; 228 ir->gpio_addr = MO_GP1_IO;
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index f786ab11d2cd..86e353b26b53 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -1182,8 +1182,6 @@ static void et61x251_release_resources(struct et61x251_device* cam)
1182 video_set_drvdata(cam->v4ldev, NULL); 1182 video_set_drvdata(cam->v4ldev, NULL);
1183 video_unregister_device(cam->v4ldev); 1183 video_unregister_device(cam->v4ldev);
1184 1184
1185 usb_put_dev(cam->usbdev);
1186
1187 mutex_unlock(&et61x251_sysfs_lock); 1185 mutex_unlock(&et61x251_sysfs_lock);
1188 1186
1189 kfree(cam->control_buffer); 1187 kfree(cam->control_buffer);
@@ -1275,6 +1273,7 @@ static int et61x251_release(struct inode* inode, struct file* filp)
1275 1273
1276 if (cam->state & DEV_DISCONNECTED) { 1274 if (cam->state & DEV_DISCONNECTED) {
1277 et61x251_release_resources(cam); 1275 et61x251_release_resources(cam);
1276 usb_put_dev(cam->usbdev);
1278 mutex_unlock(&cam->dev_mutex); 1277 mutex_unlock(&cam->dev_mutex);
1279 kfree(cam); 1278 kfree(cam);
1280 return 0; 1279 return 0;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
index df8feac16aee..c80c26be6e4d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -221,7 +221,7 @@ static unsigned int decoder_describe(struct pvr2_v4l_cx2584x *ctxt,
221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt) 221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt)
222{ 222{
223 int ret; 223 int ret;
224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,0); 224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,NULL);
225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret); 225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret);
226} 226}
227 227
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 97e974d9b9c3..bb40e9085977 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -711,8 +711,8 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
711 dip->devbase.minor,pvr2_config_get_name(dip->config)); 711 dip->devbase.minor,pvr2_config_get_name(dip->config));
712 712
713 /* Paranoia */ 713 /* Paranoia */
714 dip->v4lp = 0; 714 dip->v4lp = NULL;
715 dip->stream = 0; 715 dip->stream = NULL;
716 716
717 /* Actual deallocation happens later when all internal references 717 /* Actual deallocation happens later when all internal references
718 are gone. */ 718 are gone. */
@@ -1076,7 +1076,7 @@ struct pvr2_v4l2 *pvr2_v4l2_create(struct pvr2_context *mnp)
1076 vp->vdev = kmalloc(sizeof(*vp->vdev),GFP_KERNEL); 1076 vp->vdev = kmalloc(sizeof(*vp->vdev),GFP_KERNEL);
1077 if (!vp->vdev) { 1077 if (!vp->vdev) {
1078 kfree(vp); 1078 kfree(vp);
1079 return 0; 1079 return NULL;
1080 } 1080 }
1081 memset(vp->vdev,0,sizeof(*vp->vdev)); 1081 memset(vp->vdev,0,sizeof(*vp->vdev));
1082 pvr2_channel_init(&vp->channel,mnp); 1082 pvr2_channel_init(&vp->channel,mnp);
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index a81285ca7d5b..7b9859c33018 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -212,8 +212,10 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a)
212 if (rd_blocks > s->block_count) 212 if (rd_blocks > s->block_count)
213 rd_blocks = s->block_count; 213 rd_blocks = s->block_count;
214 214
215 if (!rd_blocks) 215 if (!rd_blocks) {
216 spin_unlock_irqrestore(&s->lock, flags);
216 return; 217 return;
218 }
217 219
218 for (i = 0; i < rd_blocks; i++) { 220 for (i = 0; i < rd_blocks; i++) {
219 if (block_to_user_buf(s, buf_ptr)) { 221 if (block_to_user_buf(s, buf_ptr)) {
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index c5719f7bd1ac..f28398dd9d93 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1464,8 +1464,6 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
1464 client->driver = &i2c_driver_saa711x; 1464 client->driver = &i2c_driver_saa711x;
1465 snprintf(client->name, sizeof(client->name) - 1, "saa7115"); 1465 snprintf(client->name, sizeof(client->name) - 1, "saa7115");
1466 1466
1467 v4l_dbg(1, debug, client, "detecting saa7115 client on address 0x%x\n", address << 1);
1468
1469 for (i=0;i<0x0f;i++) { 1467 for (i=0;i<0x0f;i++) {
1470 saa711x_write(client, 0, i); 1468 saa711x_write(client, 0, i);
1471 name[i] = (saa711x_read(client, 0) &0x0f) +'0'; 1469 name[i] = (saa711x_read(client, 0) &0x0f) +'0';
@@ -1477,6 +1475,13 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
1477 saa711x_write(client, 0, 5); 1475 saa711x_write(client, 0, 5);
1478 chip_id = saa711x_read(client, 0) & 0x0f; 1476 chip_id = saa711x_read(client, 0) & 0x0f;
1479 1477
1478 /* Check whether this chip is part of the saa711x series */
1479 if (memcmp(name, "1f711", 5)) {
1480 v4l_dbg(1, debug, client, "chip found @ 0x%x (ID %s) does not match a known saa711x chip.\n",
1481 address << 1, name);
1482 return 0;
1483 }
1484
1480 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id); 1485 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id);
1481 v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, address << 1, adapter->name); 1486 v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, address << 1, adapter->name);
1482 1487
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index c9d8e3b9cc37..51f0cfdcb680 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -2969,7 +2969,7 @@ struct saa7134_board saa7134_boards[] = {
2969 /* Petr Baudis <pasky@ucw.cz> */ 2969 /* Petr Baudis <pasky@ucw.cz> */
2970 .name = "AVerMedia TV Hybrid A16AR", 2970 .name = "AVerMedia TV Hybrid A16AR",
2971 .audio_clock = 0x187de7, 2971 .audio_clock = 0x187de7,
2972 .tuner_type = TUNER_PHILIPS_TDA8290, /* untested */ 2972 .tuner_type = TUNER_PHILIPS_TD1316, /* untested */
2973 .radio_type = TUNER_TEA5767, /* untested */ 2973 .radio_type = TUNER_TEA5767, /* untested */
2974 .tuner_addr = ADDR_UNSET, 2974 .tuner_addr = ADDR_UNSET,
2975 .radio_addr = ADDR_UNSET, 2975 .radio_addr = ADDR_UNSET,
@@ -3718,6 +3718,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3718 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 3718 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
3719 case SAA7134_BOARD_AVERMEDIA_307: 3719 case SAA7134_BOARD_AVERMEDIA_307:
3720 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 3720 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
3721 case SAA7134_BOARD_AVERMEDIA_777:
3721/* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */ 3722/* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */
3722 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 3723 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
3723 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: 3724 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
@@ -3734,6 +3735,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3734 case SAA7134_BOARD_FLYDVBT_LR301: 3735 case SAA7134_BOARD_FLYDVBT_LR301:
3735 case SAA7134_BOARD_FLYDVBTDUO: 3736 case SAA7134_BOARD_FLYDVBTDUO:
3736 case SAA7134_BOARD_PROTEUS_2309: 3737 case SAA7134_BOARD_PROTEUS_2309:
3738 case SAA7134_BOARD_AVERMEDIA_A16AR:
3737 dev->has_remote = SAA7134_REMOTE_GPIO; 3739 dev->has_remote = SAA7134_REMOTE_GPIO;
3738 break; 3740 break;
3739 case SAA7134_BOARD_FLYDVBS_LR300: 3741 case SAA7134_BOARD_FLYDVBS_LR300:
@@ -3772,7 +3774,6 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3772 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08); 3774 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08);
3773 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00); 3775 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00);
3774 break; 3776 break;
3775 case SAA7134_BOARD_AVERMEDIA_A16AR:
3776 case SAA7134_BOARD_AVERMEDIA_CARDBUS: 3777 case SAA7134_BOARD_AVERMEDIA_CARDBUS:
3777 /* power-up tuner chip */ 3778 /* power-up tuner chip */
3778 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff); 3779 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 1ba53b525ad2..6b61d9b2fcb5 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1147,6 +1147,8 @@ static int dvb_init(struct saa7134_dev *dev)
1147 &philips_europa_config, 1147 &philips_europa_config,
1148 &dev->i2c_adap); 1148 &dev->i2c_adap);
1149 if (dev->dvb.frontend) { 1149 if (dev->dvb.frontend) {
1150 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1151 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1150 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; 1152 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1151 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; 1153 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1152 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1154 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index ff5991136f4e..dee83552e681 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -185,7 +185,6 @@ int saa7134_input_init1(struct saa7134_dev *dev)
185 case SAA7134_BOARD_AVERMEDIA_STUDIO_305: 185 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
186 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 186 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
187 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 187 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
188 case SAA7134_BOARD_AVERMEDIA_A16AR:
189 ir_codes = ir_codes_avermedia; 188 ir_codes = ir_codes_avermedia;
190 mask_keycode = 0x0007C8; 189 mask_keycode = 0x0007C8;
191 mask_keydown = 0x000010; 190 mask_keydown = 0x000010;
@@ -194,6 +193,16 @@ int saa7134_input_init1(struct saa7134_dev *dev)
194 saa_setb(SAA7134_GPIO_GPMODE0, 0x4); 193 saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
195 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); 194 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
196 break; 195 break;
196 case SAA7134_BOARD_AVERMEDIA_777:
197 case SAA7134_BOARD_AVERMEDIA_A16AR:
198 ir_codes = ir_codes_avermedia;
199 mask_keycode = 0x02F200;
200 mask_keydown = 0x000400;
201 polling = 50; // ms
202 /* Without this we won't receive key up events */
203 saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
204 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
205 break;
197 case SAA7134_BOARD_KWORLD_TERMINATOR: 206 case SAA7134_BOARD_KWORLD_TERMINATOR:
198 ir_codes = ir_codes_pixelview; 207 ir_codes = ir_codes_pixelview;
199 mask_keycode = 0x00001f; 208 mask_keycode = 0x00001f;
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index a4702d3c2aca..42fb60d985b9 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -1462,8 +1462,6 @@ static void sn9c102_release_resources(struct sn9c102_device* cam)
1462 video_set_drvdata(cam->v4ldev, NULL); 1462 video_set_drvdata(cam->v4ldev, NULL);
1463 video_unregister_device(cam->v4ldev); 1463 video_unregister_device(cam->v4ldev);
1464 1464
1465 usb_put_dev(cam->usbdev);
1466
1467 mutex_unlock(&sn9c102_sysfs_lock); 1465 mutex_unlock(&sn9c102_sysfs_lock);
1468 1466
1469 kfree(cam->control_buffer); 1467 kfree(cam->control_buffer);
@@ -1555,6 +1553,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp)
1555 1553
1556 if (cam->state & DEV_DISCONNECTED) { 1554 if (cam->state & DEV_DISCONNECTED) {
1557 sn9c102_release_resources(cam); 1555 sn9c102_release_resources(cam);
1556 usb_put_dev(cam->usbdev);
1558 mutex_unlock(&cam->dev_mutex); 1557 mutex_unlock(&cam->dev_mutex);
1559 kfree(cam); 1558 kfree(cam);
1560 return 0; 1559 return 0;
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index e6baaee038bf..6b9ef731b83a 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -468,7 +468,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
468 (eeprom_data[i+6] << 8) + 468 (eeprom_data[i+6] << 8) +
469 (eeprom_data[i+7] << 16); 469 (eeprom_data[i+7] << 16);
470 470
471 if ( (eeprom_data[i + 8] && 0xf0) && 471 if ( (eeprom_data[i + 8] & 0xf0) &&
472 (tvee->serial_number < 0xffffff) ) { 472 (tvee->serial_number < 0xffffff) ) {
473 tvee->MAC_address[0] = 0x00; 473 tvee->MAC_address[0] = 0x00;
474 tvee->MAC_address[1] = 0x0D; 474 tvee->MAC_address[1] = 0x0D;
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index c537d71c18e4..a4afad4ecab2 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -75,8 +75,8 @@
75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
76#endif 76#endif
77 77
78#define MPT_LINUX_VERSION_COMMON "3.04.01" 78#define MPT_LINUX_VERSION_COMMON "3.04.02"
79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.01" 79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.02"
80#define WHAT_MAGIC_STRING "@" "(" "#" ")" 80#define WHAT_MAGIC_STRING "@" "(" "#" ")"
81 81
82#define show_mptmod_ver(s,ver) \ 82#define show_mptmod_ver(s,ver) \
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index e57bb035a021..1dd491773150 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -96,6 +96,10 @@ static int mptfc_qcmd(struct scsi_cmnd *SCpnt,
96static void mptfc_target_destroy(struct scsi_target *starget); 96static void mptfc_target_destroy(struct scsi_target *starget);
97static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout); 97static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
98static void __devexit mptfc_remove(struct pci_dev *pdev); 98static void __devexit mptfc_remove(struct pci_dev *pdev);
99static int mptfc_abort(struct scsi_cmnd *SCpnt);
100static int mptfc_dev_reset(struct scsi_cmnd *SCpnt);
101static int mptfc_bus_reset(struct scsi_cmnd *SCpnt);
102static int mptfc_host_reset(struct scsi_cmnd *SCpnt);
99 103
100static struct scsi_host_template mptfc_driver_template = { 104static struct scsi_host_template mptfc_driver_template = {
101 .module = THIS_MODULE, 105 .module = THIS_MODULE,
@@ -110,10 +114,10 @@ static struct scsi_host_template mptfc_driver_template = {
110 .target_destroy = mptfc_target_destroy, 114 .target_destroy = mptfc_target_destroy,
111 .slave_destroy = mptscsih_slave_destroy, 115 .slave_destroy = mptscsih_slave_destroy,
112 .change_queue_depth = mptscsih_change_queue_depth, 116 .change_queue_depth = mptscsih_change_queue_depth,
113 .eh_abort_handler = mptscsih_abort, 117 .eh_abort_handler = mptfc_abort,
114 .eh_device_reset_handler = mptscsih_dev_reset, 118 .eh_device_reset_handler = mptfc_dev_reset,
115 .eh_bus_reset_handler = mptscsih_bus_reset, 119 .eh_bus_reset_handler = mptfc_bus_reset,
116 .eh_host_reset_handler = mptscsih_host_reset, 120 .eh_host_reset_handler = mptfc_host_reset,
117 .bios_param = mptscsih_bios_param, 121 .bios_param = mptscsih_bios_param,
118 .can_queue = MPT_FC_CAN_QUEUE, 122 .can_queue = MPT_FC_CAN_QUEUE,
119 .this_id = -1, 123 .this_id = -1,
@@ -171,6 +175,77 @@ static struct fc_function_template mptfc_transport_functions = {
171 .show_host_symbolic_name = 1, 175 .show_host_symbolic_name = 1,
172}; 176};
173 177
178static int
179mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
180 int (*func)(struct scsi_cmnd *SCpnt),
181 const char *caller)
182{
183 struct scsi_device *sdev = SCpnt->device;
184 struct Scsi_Host *shost = sdev->host;
185 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
186 unsigned long flags;
187 int ready;
188
189 spin_lock_irqsave(shost->host_lock, flags);
190 while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) {
191 spin_unlock_irqrestore(shost->host_lock, flags);
192 dfcprintk ((MYIOC_s_INFO_FMT
193 "mptfc_block_error_handler.%d: %d:%d, port status is "
194 "DID_IMM_RETRY, deferring %s recovery.\n",
195 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
196 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
197 SCpnt->device->id,SCpnt->device->lun,caller));
198 msleep(1000);
199 spin_lock_irqsave(shost->host_lock, flags);
200 }
201 spin_unlock_irqrestore(shost->host_lock, flags);
202
203 if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) {
204 dfcprintk ((MYIOC_s_INFO_FMT
205 "%s.%d: %d:%d, failing recovery, "
206 "port state %d, vdev %p.\n", caller,
207 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
208 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
209 SCpnt->device->id,SCpnt->device->lun,ready,
210 SCpnt->device->hostdata));
211 return FAILED;
212 }
213 dfcprintk ((MYIOC_s_INFO_FMT
214 "%s.%d: %d:%d, executing recovery.\n", caller,
215 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
216 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
217 SCpnt->device->id,SCpnt->device->lun));
218 return (*func)(SCpnt);
219}
220
221static int
222mptfc_abort(struct scsi_cmnd *SCpnt)
223{
224 return
225 mptfc_block_error_handler(SCpnt, mptscsih_abort, __FUNCTION__);
226}
227
228static int
229mptfc_dev_reset(struct scsi_cmnd *SCpnt)
230{
231 return
232 mptfc_block_error_handler(SCpnt, mptscsih_dev_reset, __FUNCTION__);
233}
234
235static int
236mptfc_bus_reset(struct scsi_cmnd *SCpnt)
237{
238 return
239 mptfc_block_error_handler(SCpnt, mptscsih_bus_reset, __FUNCTION__);
240}
241
242static int
243mptfc_host_reset(struct scsi_cmnd *SCpnt)
244{
245 return
246 mptfc_block_error_handler(SCpnt, mptscsih_host_reset, __FUNCTION__);
247}
248
174static void 249static void
175mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) 250mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
176{ 251{
@@ -562,6 +637,12 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
562 return 0; 637 return 0;
563 } 638 }
564 639
640 if (!SCpnt->device->hostdata) { /* vdev */
641 SCpnt->result = DID_NO_CONNECT << 16;
642 done(SCpnt);
643 return 0;
644 }
645
565 /* dd_data is null until finished adding target */ 646 /* dd_data is null until finished adding target */
566 ri = *((struct mptfc_rport_info **)rport->dd_data); 647 ri = *((struct mptfc_rport_info **)rport->dd_data);
567 if (unlikely(!ri)) { 648 if (unlikely(!ri)) {
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 91f95d172ca5..a2350640384b 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -124,10 +124,10 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
124int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg, 124int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
125 unsigned long timeout, struct i2o_dma *dma) 125 unsigned long timeout, struct i2o_dma *dma)
126{ 126{
127 DECLARE_WAIT_QUEUE_HEAD(wq); 127 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
128 struct i2o_exec_wait *wait; 128 struct i2o_exec_wait *wait;
129 static u32 tcntxt = 0x80000000; 129 static u32 tcntxt = 0x80000000;
130 long flags; 130 unsigned long flags;
131 int rc = 0; 131 int rc = 0;
132 132
133 wait = i2o_exec_wait_alloc(); 133 wait = i2o_exec_wait_alloc();
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b6c045dc97b4..00db31c314e0 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -30,6 +30,7 @@ config IBM_ASM
30 30
31config SGI_IOC4 31config SGI_IOC4
32 tristate "SGI IOC4 Base IO support" 32 tristate "SGI IOC4 Base IO support"
33 depends on PCI
33 ---help--- 34 ---help---
34 This option enables basic support for the IOC4 chip on certain 35 This option enables basic support for the IOC4 chip on certain
35 SGI IO controller cards (IO9, IO10, and PCI-RT). This option 36 SGI IO controller cards (IO9, IO10, and PCI-RT). This option
diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 1c3c14a3839c..b995a15b7526 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -32,6 +32,7 @@
32#include <linux/ktime.h> 32#include <linux/ktime.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/time.h> 34#include <linux/time.h>
35#include <asm/io.h>
35 36
36/*************** 37/***************
37 * Definitions * 38 * Definitions *
@@ -209,8 +210,8 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
209 210
210 do_div(ns, IOC4_EXTINT_COUNT_DIVISOR); 211 do_div(ns, IOC4_EXTINT_COUNT_DIVISOR);
211 printk(KERN_DEBUG 212 printk(KERN_DEBUG
212 "IOC4 %s: PCI clock is %lld ns.\n", 213 "IOC4 %s: PCI clock is %llu ns.\n",
213 pci_name(idd->idd_pdev), ns); 214 pci_name(idd->idd_pdev), (unsigned long long)ns);
214 } 215 }
215 216
216 /* Remember results. We store the extint clock period rather 217 /* Remember results. We store the extint clock period rather
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index bbdba7b37e11..db9d7df75ae0 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -44,12 +44,14 @@
44 */ 44 */
45 45
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/fs.h>
47#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/buffer_head.h>
48#include <linux/kprobes.h> 50#include <linux/kprobes.h>
49#include <linux/kallsyms.h> 51#include <linux/list.h>
50#include <linux/init.h> 52#include <linux/init.h>
51#include <linux/irq.h>
52#include <linux/interrupt.h> 53#include <linux/interrupt.h>
54#include <linux/hrtimer.h>
53#include <scsi/scsi_cmnd.h> 55#include <scsi/scsi_cmnd.h>
54 56
55#ifdef CONFIG_IDE 57#ifdef CONFIG_IDE
@@ -116,16 +118,16 @@ static enum ctype cptype = NONE;
116static int count = DEFAULT_COUNT; 118static int count = DEFAULT_COUNT;
117 119
118module_param(recur_count, int, 0644); 120module_param(recur_count, int, 0644);
119MODULE_PARM_DESC(recur_count, "Recurcion level for the stack overflow test,\ 121MODULE_PARM_DESC(recur_count, " Recursion level for the stack overflow test, "\
120 default is 10"); 122 "default is 10");
121module_param(cpoint_name, charp, 0644); 123module_param(cpoint_name, charp, 0644);
122MODULE_PARM_DESC(cpoint_name, "Crash Point, where kernel is to be crashed"); 124MODULE_PARM_DESC(cpoint_name, " Crash Point, where kernel is to be crashed");
123module_param(cpoint_type, charp, 06444); 125module_param(cpoint_type, charp, 0644);
124MODULE_PARM_DESC(cpoint_type, "Crash Point Type, action to be taken on\ 126MODULE_PARM_DESC(cpoint_type, " Crash Point Type, action to be taken on "\
125 hitting the crash point"); 127 "hitting the crash point");
126module_param(cpoint_count, int, 06444); 128module_param(cpoint_count, int, 0644);
127MODULE_PARM_DESC(cpoint_count, "Crash Point Count, number of times the \ 129MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\
128 crash point is to be hit to trigger action"); 130 "crash point is to be hit to trigger action");
129 131
130unsigned int jp_do_irq(unsigned int irq) 132unsigned int jp_do_irq(unsigned int irq)
131{ 133{
@@ -155,8 +157,8 @@ void jp_ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
155 157
156struct scan_control; 158struct scan_control;
157 159
158unsigned long jp_shrink_page_list(struct list_head *page_list, 160unsigned long jp_shrink_inactive_list(unsigned long max_scan,
159 struct scan_control *sc) 161 struct zone *zone, struct scan_control *sc)
160{ 162{
161 lkdtm_handler(); 163 lkdtm_handler();
162 jprobe_return(); 164 jprobe_return();
@@ -295,8 +297,8 @@ int lkdtm_module_init(void)
295 lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block; 297 lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block;
296 break; 298 break;
297 case MEM_SWAPOUT: 299 case MEM_SWAPOUT:
298 lkdtm.kp.symbol_name = "shrink_page_list"; 300 lkdtm.kp.symbol_name = "shrink_inactive_list";
299 lkdtm.entry = (kprobe_opcode_t*) jp_shrink_page_list; 301 lkdtm.entry = (kprobe_opcode_t*) jp_shrink_inactive_list;
300 break; 302 break;
301 case TIMERADD: 303 case TIMERADD:
302 lkdtm.kp.symbol_name = "hrtimer_start"; 304 lkdtm.kp.symbol_name = "hrtimer_start";
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ee8863c123e3..766bc54406e5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -475,7 +475,7 @@ static u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
475 if (bit) { 475 if (bit) {
476 bit -= 1; 476 bit -= 1;
477 477
478 ocr = 3 << bit; 478 ocr &= 3 << bit;
479 479
480 host->ios.vdd = bit; 480 host->ios.vdd = bit;
481 mmc_set_ios(host); 481 mmc_set_ios(host);
@@ -1178,14 +1178,29 @@ static void mmc_rescan(void *data)
1178{ 1178{
1179 struct mmc_host *host = data; 1179 struct mmc_host *host = data;
1180 struct list_head *l, *n; 1180 struct list_head *l, *n;
1181 unsigned char power_mode;
1181 1182
1182 mmc_claim_host(host); 1183 mmc_claim_host(host);
1183 1184
1184 if (host->ios.power_mode == MMC_POWER_ON) 1185 /*
1186 * Check for removed cards and newly inserted ones. We check for
1187 * removed cards first so we can intelligently re-select the VDD.
1188 */
1189 power_mode = host->ios.power_mode;
1190 if (power_mode == MMC_POWER_ON)
1185 mmc_check_cards(host); 1191 mmc_check_cards(host);
1186 1192
1187 mmc_setup(host); 1193 mmc_setup(host);
1188 1194
1195 /*
1196 * Some broken cards process CMD1 even in stand-by state. There is
1197 * no reply, but an ILLEGAL_COMMAND error is cached and returned
1198 * after next command. We poll for card status here to clear any
1199 * possibly pending error.
1200 */
1201 if (power_mode == MMC_POWER_ON)
1202 mmc_check_cards(host);
1203
1189 if (!list_empty(&host->cards)) { 1204 if (!list_empty(&host->cards)) {
1190 /* 1205 /*
1191 * (Re-)calculate the fastest clock rate which the 1206 * (Re-)calculate the fastest clock rate which the
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c
index 2bacff60913d..0fdc55b08a6d 100644
--- a/drivers/mmc/tifm_sd.c
+++ b/drivers/mmc/tifm_sd.c
@@ -14,6 +14,7 @@
14#include <linux/mmc/protocol.h> 14#include <linux/mmc/protocol.h>
15#include <linux/mmc/host.h> 15#include <linux/mmc/host.h>
16#include <linux/highmem.h> 16#include <linux/highmem.h>
17#include <asm/io.h>
17 18
18#define DRIVER_NAME "tifm_sd" 19#define DRIVER_NAME "tifm_sd"
19#define DRIVER_VERSION "0.6" 20#define DRIVER_VERSION "0.6"
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 11de54535526..f69184a92eb2 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -1086,7 +1086,7 @@ static int inval_cache_and_wait_for_operation(
1086 } 1086 }
1087 spin_lock(chip->mutex); 1087 spin_lock(chip->mutex);
1088 1088
1089 if (chip->state != chip_state) { 1089 while (chip->state != chip_state) {
1090 /* Someone's suspended the operation: sleep */ 1090 /* Someone's suspended the operation: sleep */
1091 DECLARE_WAITQUEUE(wait, current); 1091 DECLARE_WAITQUEUE(wait, current);
1092 set_current_state(TASK_UNINTERRUPTIBLE); 1092 set_current_state(TASK_UNINTERRUPTIBLE);
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index eed3271b99cc..dfe56e03e48b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1493,6 +1493,7 @@ static void nand_write_page_syndrome(struct mtd_info *mtd,
1493 * @buf: the data to write 1493 * @buf: the data to write
1494 * @page: page number to write 1494 * @page: page number to write
1495 * @cached: cached programming 1495 * @cached: cached programming
1496 * @raw: use _raw version of write_page
1496 */ 1497 */
1497static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, 1498static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
1498 const uint8_t *buf, int page, int cached, int raw) 1499 const uint8_t *buf, int page, int cached, int raw)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ab92cc794c64..6e863aa9894c 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -486,7 +486,7 @@ config SGI_IOC3_ETH_HW_TX_CSUM
486 486
487config MIPS_SIM_NET 487config MIPS_SIM_NET
488 tristate "MIPS simulator Network device (EXPERIMENTAL)" 488 tristate "MIPS simulator Network device (EXPERIMENTAL)"
489 depends on NETDEVICES && MIPS_SIM && EXPERIMENTAL 489 depends on MIPS_SIM && EXPERIMENTAL
490 help 490 help
491 The MIPSNET device is a simple Ethernet network device which is 491 The MIPSNET device is a simple Ethernet network device which is
492 emulated by the MIPS Simulator. 492 emulated by the MIPS Simulator.
@@ -2112,7 +2112,7 @@ config SKGE
2112 2112
2113config SKY2 2113config SKY2
2114 tristate "SysKonnect Yukon2 support (EXPERIMENTAL)" 2114 tristate "SysKonnect Yukon2 support (EXPERIMENTAL)"
2115 depends on PCI && EXPERIMENTAL 2115 depends on PCI
2116 select CRC32 2116 select CRC32
2117 ---help--- 2117 ---help---
2118 This driver supports Gigabit Ethernet adapters based on the 2118 This driver supports Gigabit Ethernet adapters based on the
@@ -2120,8 +2120,8 @@ config SKY2
2120 Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/ 2120 Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/
2121 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21 2121 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21
2122 2122
2123 This driver does not support the original Yukon chipset: a seperate 2123 There is companion driver for the older Marvell Yukon and
2124 driver, skge, is provided for Yukon-based adapters. 2124 Genesis based adapters: skge.
2125 2125
2126 To compile this driver as a module, choose M here: the module 2126 To compile this driver as a module, choose M here: the module
2127 will be called sky2. This is recommended. 2127 will be called sky2. This is recommended.
@@ -2288,7 +2288,7 @@ config UGETH_TX_ON_DEMOND
2288 2288
2289config UGETH_HAS_GIGA 2289config UGETH_HAS_GIGA
2290 bool 2290 bool
2291 depends on UCC_GETH && MPC836x 2291 depends on UCC_GETH && PPC_MPC836x
2292 2292
2293config MV643XX_ETH 2293config MV643XX_ETH
2294 tristate "MV-643XX Ethernet support" 2294 tristate "MV-643XX Ethernet support"
@@ -2467,7 +2467,7 @@ config ISERIES_VETH
2467 2467
2468config RIONET 2468config RIONET
2469 tristate "RapidIO Ethernet over messaging driver support" 2469 tristate "RapidIO Ethernet over messaging driver support"
2470 depends on NETDEVICES && RAPIDIO 2470 depends on RAPIDIO
2471 2471
2472config RIONET_TX_SIZE 2472config RIONET_TX_SIZE
2473 int "Number of outbound queue entries" 2473 int "Number of outbound queue entries"
@@ -2717,6 +2717,7 @@ config PPP_MPPE
2717 select CRYPTO 2717 select CRYPTO
2718 select CRYPTO_SHA1 2718 select CRYPTO_SHA1
2719 select CRYPTO_ARC4 2719 select CRYPTO_ARC4
2720 select CRYPTO_ECB
2720 ---help--- 2721 ---help---
2721 Support for the MPPE Encryption protocol, as employed by the 2722 Support for the MPPE Encryption protocol, as employed by the
2722 Microsoft Point-to-Point Tunneling Protocol. 2723 Microsoft Point-to-Point Tunneling Protocol.
@@ -2832,7 +2833,7 @@ config NET_FC
2832 "SCSI generic support". 2833 "SCSI generic support".
2833 2834
2834config SHAPER 2835config SHAPER
2835 tristate "Traffic Shaper (EXPERIMENTAL)" 2836 tristate "Traffic Shaper (OBSOLETE)"
2836 depends on EXPERIMENTAL 2837 depends on EXPERIMENTAL
2837 ---help--- 2838 ---help---
2838 The traffic shaper is a virtual network device that allows you to 2839 The traffic shaper is a virtual network device that allows you to
@@ -2841,9 +2842,9 @@ config SHAPER
2841 these virtual devices. See 2842 these virtual devices. See
2842 <file:Documentation/networking/shaper.txt> for more information. 2843 <file:Documentation/networking/shaper.txt> for more information.
2843 2844
2844 An alternative to this traffic shaper is the experimental 2845 An alternative to this traffic shaper are traffic schedulers which
2845 Class-Based Queuing (CBQ) scheduling support which you get if you 2846 you'll get if you say Y to "QoS and/or fair queuing" in
2846 say Y to "QoS and/or fair queuing" above. 2847 "Networking options".
2847 2848
2848 To compile this driver as a module, choose M here: the module 2849 To compile this driver as a module, choose M here: the module
2849 will be called shaper. If unsure, say N. 2850 will be called shaper. If unsure, say N.
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 0dc70c7b7940..aa9dd8f11269 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -337,13 +337,16 @@ static void com20020_set_mc_list(struct net_device *dev)
337 } 337 }
338} 338}
339 339
340#ifdef MODULE 340#if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
341 341 defined(CONFIG_ARCNET_COM20020_ISA_MODULE)
342EXPORT_SYMBOL(com20020_check); 342EXPORT_SYMBOL(com20020_check);
343EXPORT_SYMBOL(com20020_found); 343EXPORT_SYMBOL(com20020_found);
344#endif
344 345
345MODULE_LICENSE("GPL"); 346MODULE_LICENSE("GPL");
346 347
348#ifdef MODULE
349
347int init_module(void) 350int init_module(void)
348{ 351{
349 BUGLVL(D_NORMAL) printk(VERSION); 352 BUGLVL(D_NORMAL) printk(VERSION);
diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index 127561c782fd..8ebd68e2af98 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -193,12 +193,9 @@ static struct net_device_stats *ep93xx_get_stats(struct net_device *dev)
193static int ep93xx_rx(struct net_device *dev, int *budget) 193static int ep93xx_rx(struct net_device *dev, int *budget)
194{ 194{
195 struct ep93xx_priv *ep = netdev_priv(dev); 195 struct ep93xx_priv *ep = netdev_priv(dev);
196 int tail_offset;
197 int rx_done; 196 int rx_done;
198 int processed; 197 int processed;
199 198
200 tail_offset = rdl(ep, REG_RXSTSQCURADD) - ep->descs_dma_addr;
201
202 rx_done = 0; 199 rx_done = 0;
203 processed = 0; 200 processed = 0;
204 while (*budget > 0) { 201 while (*budget > 0) {
@@ -211,36 +208,28 @@ static int ep93xx_rx(struct net_device *dev, int *budget)
211 208
212 entry = ep->rx_pointer; 209 entry = ep->rx_pointer;
213 rstat = ep->descs->rstat + entry; 210 rstat = ep->descs->rstat + entry;
214 if ((void *)rstat - (void *)ep->descs == tail_offset) { 211
212 rstat0 = rstat->rstat0;
213 rstat1 = rstat->rstat1;
214 if (!(rstat0 & RSTAT0_RFP) || !(rstat1 & RSTAT1_RFP)) {
215 rx_done = 1; 215 rx_done = 1;
216 break; 216 break;
217 } 217 }
218 218
219 rstat0 = rstat->rstat0;
220 rstat1 = rstat->rstat1;
221 rstat->rstat0 = 0; 219 rstat->rstat0 = 0;
222 rstat->rstat1 = 0; 220 rstat->rstat1 = 0;
223 221
224 if (!(rstat0 & RSTAT0_RFP))
225 printk(KERN_CRIT "ep93xx_rx: buffer not done "
226 " %.8x %.8x\n", rstat0, rstat1);
227 if (!(rstat0 & RSTAT0_EOF)) 222 if (!(rstat0 & RSTAT0_EOF))
228 printk(KERN_CRIT "ep93xx_rx: not end-of-frame " 223 printk(KERN_CRIT "ep93xx_rx: not end-of-frame "
229 " %.8x %.8x\n", rstat0, rstat1); 224 " %.8x %.8x\n", rstat0, rstat1);
230 if (!(rstat0 & RSTAT0_EOB)) 225 if (!(rstat0 & RSTAT0_EOB))
231 printk(KERN_CRIT "ep93xx_rx: not end-of-buffer " 226 printk(KERN_CRIT "ep93xx_rx: not end-of-buffer "
232 " %.8x %.8x\n", rstat0, rstat1); 227 " %.8x %.8x\n", rstat0, rstat1);
233 if (!(rstat1 & RSTAT1_RFP))
234 printk(KERN_CRIT "ep93xx_rx: buffer1 not done "
235 " %.8x %.8x\n", rstat0, rstat1);
236 if ((rstat1 & RSTAT1_BUFFER_INDEX) >> 16 != entry) 228 if ((rstat1 & RSTAT1_BUFFER_INDEX) >> 16 != entry)
237 printk(KERN_CRIT "ep93xx_rx: entry mismatch " 229 printk(KERN_CRIT "ep93xx_rx: entry mismatch "
238 " %.8x %.8x\n", rstat0, rstat1); 230 " %.8x %.8x\n", rstat0, rstat1);
239 231
240 if (!(rstat0 & RSTAT0_RWE)) { 232 if (!(rstat0 & RSTAT0_RWE)) {
241 printk(KERN_NOTICE "ep93xx_rx: receive error "
242 " %.8x %.8x\n", rstat0, rstat1);
243
244 ep->stats.rx_errors++; 233 ep->stats.rx_errors++;
245 if (rstat0 & RSTAT0_OE) 234 if (rstat0 & RSTAT0_OE)
246 ep->stats.rx_fifo_errors++; 235 ep->stats.rx_fifo_errors++;
@@ -301,13 +290,8 @@ err:
301 290
302static int ep93xx_have_more_rx(struct ep93xx_priv *ep) 291static int ep93xx_have_more_rx(struct ep93xx_priv *ep)
303{ 292{
304 struct ep93xx_rstat *rstat; 293 struct ep93xx_rstat *rstat = ep->descs->rstat + ep->rx_pointer;
305 int tail_offset; 294 return !!((rstat->rstat0 & RSTAT0_RFP) && (rstat->rstat1 & RSTAT1_RFP));
306
307 rstat = ep->descs->rstat + ep->rx_pointer;
308 tail_offset = rdl(ep, REG_RXSTSQCURADD) - ep->descs_dma_addr;
309
310 return !((void *)rstat - (void *)ep->descs == tail_offset);
311} 295}
312 296
313static int ep93xx_poll(struct net_device *dev, int *budget) 297static int ep93xx_poll(struct net_device *dev, int *budget)
@@ -347,7 +331,7 @@ static int ep93xx_xmit(struct sk_buff *skb, struct net_device *dev)
347 struct ep93xx_priv *ep = netdev_priv(dev); 331 struct ep93xx_priv *ep = netdev_priv(dev);
348 int entry; 332 int entry;
349 333
350 if (unlikely(skb->len) > MAX_PKT_SIZE) { 334 if (unlikely(skb->len > MAX_PKT_SIZE)) {
351 ep->stats.tx_dropped++; 335 ep->stats.tx_dropped++;
352 dev_kfree_skb(skb); 336 dev_kfree_skb(skb);
353 return NETDEV_TX_OK; 337 return NETDEV_TX_OK;
@@ -379,10 +363,8 @@ static int ep93xx_xmit(struct sk_buff *skb, struct net_device *dev)
379static void ep93xx_tx_complete(struct net_device *dev) 363static void ep93xx_tx_complete(struct net_device *dev)
380{ 364{
381 struct ep93xx_priv *ep = netdev_priv(dev); 365 struct ep93xx_priv *ep = netdev_priv(dev);
382 int tail_offset;
383 int wake; 366 int wake;
384 367
385 tail_offset = rdl(ep, REG_TXSTSQCURADD) - ep->descs_dma_addr;
386 wake = 0; 368 wake = 0;
387 369
388 spin_lock(&ep->tx_pending_lock); 370 spin_lock(&ep->tx_pending_lock);
@@ -393,15 +375,13 @@ static void ep93xx_tx_complete(struct net_device *dev)
393 375
394 entry = ep->tx_clean_pointer; 376 entry = ep->tx_clean_pointer;
395 tstat = ep->descs->tstat + entry; 377 tstat = ep->descs->tstat + entry;
396 if ((void *)tstat - (void *)ep->descs == tail_offset)
397 break;
398 378
399 tstat0 = tstat->tstat0; 379 tstat0 = tstat->tstat0;
380 if (!(tstat0 & TSTAT0_TXFP))
381 break;
382
400 tstat->tstat0 = 0; 383 tstat->tstat0 = 0;
401 384
402 if (!(tstat0 & TSTAT0_TXFP))
403 printk(KERN_CRIT "ep93xx_tx_complete: buffer not done "
404 " %.8x\n", tstat0);
405 if (tstat0 & TSTAT0_FA) 385 if (tstat0 & TSTAT0_FA)
406 printk(KERN_CRIT "ep93xx_tx_complete: frame aborted " 386 printk(KERN_CRIT "ep93xx_tx_complete: frame aborted "
407 " %.8x\n", tstat0); 387 " %.8x\n", tstat0);
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 4873dc610d22..7db3c8af0894 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -102,7 +102,7 @@ static void enable_mac(struct net_device *, int);
102// externs 102// externs
103extern int get_ethernet_addr(char *ethernet_addr); 103extern int get_ethernet_addr(char *ethernet_addr);
104extern void str2eaddr(unsigned char *ea, unsigned char *str); 104extern void str2eaddr(unsigned char *ea, unsigned char *str);
105extern char * __init prom_getcmdline(void); 105extern char * prom_getcmdline(void);
106 106
107/* 107/*
108 * Theory of operation 108 * Theory of operation
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 1ec217433b4c..474a4e3438db 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -908,8 +908,9 @@ static irqreturn_t b44_interrupt(int irq, void *dev_id)
908 istat = br32(bp, B44_ISTAT); 908 istat = br32(bp, B44_ISTAT);
909 imask = br32(bp, B44_IMASK); 909 imask = br32(bp, B44_IMASK);
910 910
911 /* ??? What the fuck is the purpose of the interrupt mask 911 /* The interrupt mask register controls which interrupt bits
912 * ??? register if we have to mask it out by hand anyways? 912 * will actually raise an interrupt to the CPU when set by hw/firmware,
913 * but doesn't mask off the bits.
913 */ 914 */
914 istat &= imask; 915 istat &= imask;
915 if (istat) { 916 if (istat) {
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c0bbddae4ec4..17a461152d39 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4692,6 +4692,8 @@ static int bond_check_params(struct bond_params *params)
4692 return 0; 4692 return 0;
4693} 4693}
4694 4694
4695static struct lock_class_key bonding_netdev_xmit_lock_key;
4696
4695/* Create a new bond based on the specified name and bonding parameters. 4697/* Create a new bond based on the specified name and bonding parameters.
4696 * Caller must NOT hold rtnl_lock; we need to release it here before we 4698 * Caller must NOT hold rtnl_lock; we need to release it here before we
4697 * set up our sysfs entries. 4699 * set up our sysfs entries.
@@ -4727,6 +4729,9 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
4727 if (res < 0) { 4729 if (res < 0) {
4728 goto out_bond; 4730 goto out_bond;
4729 } 4731 }
4732
4733 lockdep_set_class(&bond_dev->_xmit_lock, &bonding_netdev_xmit_lock_key);
4734
4730 if (newbond) 4735 if (newbond)
4731 *newbond = bond_dev->priv; 4736 *newbond = bond_dev->priv;
4732 4737
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index 966b563e42bb..a03d781f6d0a 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -509,6 +509,8 @@ etrax_ethernet_init(void)
509 * does not share cacheline with any other data (to avoid cache bug) 509 * does not share cacheline with any other data (to avoid cache bug)
510 */ 510 */
511 RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES); 511 RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
512 if (!RxDescList[i].skb)
513 return -ENOMEM;
512 RxDescList[i].descr.ctrl = 0; 514 RxDescList[i].descr.ctrl = 0;
513 RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE; 515 RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE;
514 RxDescList[i].descr.next = virt_to_phys(&RxDescList[i + 1]); 516 RxDescList[i].descr.next = virt_to_phys(&RxDescList[i + 1]);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index a3a08a5dd185..19ab3441269c 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2719,7 +2719,10 @@ static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
2719 struct net_device *netdev = pci_get_drvdata(pdev); 2719 struct net_device *netdev = pci_get_drvdata(pdev);
2720 struct nic *nic = netdev_priv(netdev); 2720 struct nic *nic = netdev_priv(netdev);
2721 2721
2722 netif_poll_disable(nic->netdev); 2722#ifdef CONFIG_E100_NAPI
2723 if (netif_running(netdev))
2724 netif_poll_disable(nic->netdev);
2725#endif
2723 del_timer_sync(&nic->watchdog); 2726 del_timer_sync(&nic->watchdog);
2724 netif_carrier_off(nic->netdev); 2727 netif_carrier_off(nic->netdev);
2725 2728
@@ -2763,7 +2766,10 @@ static void e100_shutdown(struct pci_dev *pdev)
2763 struct net_device *netdev = pci_get_drvdata(pdev); 2766 struct net_device *netdev = pci_get_drvdata(pdev);
2764 struct nic *nic = netdev_priv(netdev); 2767 struct nic *nic = netdev_priv(netdev);
2765 2768
2766 netif_poll_disable(nic->netdev); 2769#ifdef CONFIG_E100_NAPI
2770 if (netif_running(netdev))
2771 netif_poll_disable(nic->netdev);
2772#endif
2767 del_timer_sync(&nic->watchdog); 2773 del_timer_sync(&nic->watchdog);
2768 netif_carrier_off(nic->netdev); 2774 netif_carrier_off(nic->netdev);
2769 2775
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 773821e4cf57..c564adbd669b 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -461,7 +461,8 @@ e1000_get_regs(struct net_device *netdev,
461 regs_buff[24] = (uint32_t)phy_data; /* phy local receiver status */ 461 regs_buff[24] = (uint32_t)phy_data; /* phy local receiver status */
462 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */ 462 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
463 if (hw->mac_type >= e1000_82540 && 463 if (hw->mac_type >= e1000_82540 &&
464 hw->media_type == e1000_media_type_copper) { 464 hw->mac_type < e1000_82571 &&
465 hw->media_type == e1000_media_type_copper) {
465 regs_buff[26] = E1000_READ_REG(hw, MANC); 466 regs_buff[26] = E1000_READ_REG(hw, MANC);
466 } 467 }
467} 468}
@@ -1690,6 +1691,7 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wol
1690 int retval = 1; /* fail by default */ 1691 int retval = 1; /* fail by default */
1691 1692
1692 switch (hw->device_id) { 1693 switch (hw->device_id) {
1694 case E1000_DEV_ID_82542:
1693 case E1000_DEV_ID_82543GC_FIBER: 1695 case E1000_DEV_ID_82543GC_FIBER:
1694 case E1000_DEV_ID_82543GC_COPPER: 1696 case E1000_DEV_ID_82543GC_COPPER:
1695 case E1000_DEV_ID_82544EI_FIBER: 1697 case E1000_DEV_ID_82544EI_FIBER:
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 112447fd8bf2..449a60303e07 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -1961,9 +1961,9 @@ struct e1000_hw {
1961#define E1000_RXDCTL_GRAN 0x01000000 /* RXDCTL Granularity */ 1961#define E1000_RXDCTL_GRAN 0x01000000 /* RXDCTL Granularity */
1962 1962
1963/* Transmit Descriptor Control */ 1963/* Transmit Descriptor Control */
1964#define E1000_TXDCTL_PTHRESH 0x000000FF /* TXDCTL Prefetch Threshold */ 1964#define E1000_TXDCTL_PTHRESH 0x0000003F /* TXDCTL Prefetch Threshold */
1965#define E1000_TXDCTL_HTHRESH 0x0000FF00 /* TXDCTL Host Threshold */ 1965#define E1000_TXDCTL_HTHRESH 0x00003F00 /* TXDCTL Host Threshold */
1966#define E1000_TXDCTL_WTHRESH 0x00FF0000 /* TXDCTL Writeback Threshold */ 1966#define E1000_TXDCTL_WTHRESH 0x003F0000 /* TXDCTL Writeback Threshold */
1967#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */ 1967#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */
1968#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */ 1968#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */
1969#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */ 1969#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index ce0d35fe3947..726ec5e88ab2 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -35,7 +35,7 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
35#else 35#else
36#define DRIVERNAPI "-NAPI" 36#define DRIVERNAPI "-NAPI"
37#endif 37#endif
38#define DRV_VERSION "7.2.9-k2"DRIVERNAPI 38#define DRV_VERSION "7.2.9-k4"DRIVERNAPI
39char e1000_driver_version[] = DRV_VERSION; 39char e1000_driver_version[] = DRV_VERSION;
40static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 40static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
41 41
@@ -699,7 +699,10 @@ e1000_reset(struct e1000_adapter *adapter)
699 phy_data); 699 phy_data);
700 } 700 }
701 701
702 if ((adapter->en_mng_pt) && (adapter->hw.mac_type < e1000_82571)) { 702 if ((adapter->en_mng_pt) &&
703 (adapter->hw.mac_type >= e1000_82540) &&
704 (adapter->hw.mac_type < e1000_82571) &&
705 (adapter->hw.media_type == e1000_media_type_copper)) {
703 manc = E1000_READ_REG(&adapter->hw, MANC); 706 manc = E1000_READ_REG(&adapter->hw, MANC);
704 manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST); 707 manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
705 E1000_WRITE_REG(&adapter->hw, MANC, manc); 708 E1000_WRITE_REG(&adapter->hw, MANC, manc);
@@ -1076,8 +1079,9 @@ e1000_remove(struct pci_dev *pdev)
1076 1079
1077 flush_scheduled_work(); 1080 flush_scheduled_work();
1078 1081
1079 if (adapter->hw.mac_type < e1000_82571 && 1082 if (adapter->hw.mac_type >= e1000_82540 &&
1080 adapter->hw.media_type == e1000_media_type_copper) { 1083 adapter->hw.mac_type < e1000_82571 &&
1084 adapter->hw.media_type == e1000_media_type_copper) {
1081 manc = E1000_READ_REG(&adapter->hw, MANC); 1085 manc = E1000_READ_REG(&adapter->hw, MANC);
1082 if (manc & E1000_MANC_SMBUS_EN) { 1086 if (manc & E1000_MANC_SMBUS_EN) {
1083 manc |= E1000_MANC_ARP_EN; 1087 manc |= E1000_MANC_ARP_EN;
@@ -1804,9 +1808,11 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1804 * followed by the page buffers. Therefore, skb->data is 1808 * followed by the page buffers. Therefore, skb->data is
1805 * sized to hold the largest protocol header. 1809 * sized to hold the largest protocol header.
1806 */ 1810 */
1811 /* allocations using alloc_page take too long for regular MTU
1812 * so only enable packet split for jumbo frames */
1807 pages = PAGE_USE_COUNT(adapter->netdev->mtu); 1813 pages = PAGE_USE_COUNT(adapter->netdev->mtu);
1808 if ((adapter->hw.mac_type > e1000_82547_rev_2) && (pages <= 3) && 1814 if ((adapter->hw.mac_type >= e1000_82571) && (pages <= 3) &&
1809 PAGE_SIZE <= 16384) 1815 PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
1810 adapter->rx_ps_pages = pages; 1816 adapter->rx_ps_pages = pages;
1811 else 1817 else
1812 adapter->rx_ps_pages = 0; 1818 adapter->rx_ps_pages = 0;
@@ -2986,6 +2992,11 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2986 return NETDEV_TX_OK; 2992 return NETDEV_TX_OK;
2987 } 2993 }
2988 2994
2995 /* 82571 and newer doesn't need the workaround that limited descriptor
2996 * length to 4kB */
2997 if (adapter->hw.mac_type >= e1000_82571)
2998 max_per_txd = 8192;
2999
2989#ifdef NETIF_F_TSO 3000#ifdef NETIF_F_TSO
2990 mss = skb_shinfo(skb)->gso_size; 3001 mss = skb_shinfo(skb)->gso_size;
2991 /* The controller does a simple calculation to 3002 /* The controller does a simple calculation to
@@ -3775,9 +3786,6 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3775 3786
3776 length = le16_to_cpu(rx_desc->length); 3787 length = le16_to_cpu(rx_desc->length);
3777 3788
3778 /* adjust length to remove Ethernet CRC */
3779 length -= 4;
3780
3781 if (unlikely(!(status & E1000_RXD_STAT_EOP))) { 3789 if (unlikely(!(status & E1000_RXD_STAT_EOP))) {
3782 /* All receives must fit into a single buffer */ 3790 /* All receives must fit into a single buffer */
3783 E1000_DBG("%s: Receive packet consumed multiple" 3791 E1000_DBG("%s: Receive packet consumed multiple"
@@ -3805,6 +3813,10 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3805 } 3813 }
3806 } 3814 }
3807 3815
3816 /* adjust length to remove Ethernet CRC, this must be
3817 * done after the TBI_ACCEPT workaround above */
3818 length -= 4;
3819
3808 /* code added for copybreak, this should improve 3820 /* code added for copybreak, this should improve
3809 * performance for small packets with large amounts 3821 * performance for small packets with large amounts
3810 * of reassembly being done in the stack */ 3822 * of reassembly being done in the stack */
@@ -4773,8 +4785,9 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4773 pci_enable_wake(pdev, PCI_D3cold, 0); 4785 pci_enable_wake(pdev, PCI_D3cold, 0);
4774 } 4786 }
4775 4787
4776 if (adapter->hw.mac_type < e1000_82571 && 4788 if (adapter->hw.mac_type >= e1000_82540 &&
4777 adapter->hw.media_type == e1000_media_type_copper) { 4789 adapter->hw.mac_type < e1000_82571 &&
4790 adapter->hw.media_type == e1000_media_type_copper) {
4778 manc = E1000_READ_REG(&adapter->hw, MANC); 4791 manc = E1000_READ_REG(&adapter->hw, MANC);
4779 if (manc & E1000_MANC_SMBUS_EN) { 4792 if (manc & E1000_MANC_SMBUS_EN) {
4780 manc |= E1000_MANC_ARP_EN; 4793 manc |= E1000_MANC_ARP_EN;
@@ -4787,6 +4800,9 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4787 if (adapter->hw.phy_type == e1000_phy_igp_3) 4800 if (adapter->hw.phy_type == e1000_phy_igp_3)
4788 e1000_phy_powerdown_workaround(&adapter->hw); 4801 e1000_phy_powerdown_workaround(&adapter->hw);
4789 4802
4803 if (netif_running(netdev))
4804 e1000_free_irq(adapter);
4805
4790 /* Release control of h/w to f/w. If f/w is AMT enabled, this 4806 /* Release control of h/w to f/w. If f/w is AMT enabled, this
4791 * would have already happened in close and is redundant. */ 4807 * would have already happened in close and is redundant. */
4792 e1000_release_hw_control(adapter); 4808 e1000_release_hw_control(adapter);
@@ -4817,6 +4833,10 @@ e1000_resume(struct pci_dev *pdev)
4817 pci_enable_wake(pdev, PCI_D3hot, 0); 4833 pci_enable_wake(pdev, PCI_D3hot, 0);
4818 pci_enable_wake(pdev, PCI_D3cold, 0); 4834 pci_enable_wake(pdev, PCI_D3cold, 0);
4819 4835
4836 if (netif_running(netdev) && (err = e1000_request_irq(adapter)))
4837 return err;
4838
4839 e1000_power_up_phy(adapter);
4820 e1000_reset(adapter); 4840 e1000_reset(adapter);
4821 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 4841 E1000_WRITE_REG(&adapter->hw, WUS, ~0);
4822 4842
@@ -4825,8 +4845,9 @@ e1000_resume(struct pci_dev *pdev)
4825 4845
4826 netif_device_attach(netdev); 4846 netif_device_attach(netdev);
4827 4847
4828 if (adapter->hw.mac_type < e1000_82571 && 4848 if (adapter->hw.mac_type >= e1000_82540 &&
4829 adapter->hw.media_type == e1000_media_type_copper) { 4849 adapter->hw.mac_type < e1000_82571 &&
4850 adapter->hw.media_type == e1000_media_type_copper) {
4830 manc = E1000_READ_REG(&adapter->hw, MANC); 4851 manc = E1000_READ_REG(&adapter->hw, MANC);
4831 manc &= ~(E1000_MANC_ARP_EN); 4852 manc &= ~(E1000_MANC_ARP_EN);
4832 E1000_WRITE_REG(&adapter->hw, MANC, manc); 4853 E1000_WRITE_REG(&adapter->hw, MANC, manc);
@@ -4914,10 +4935,6 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4914 pci_enable_wake(pdev, PCI_D3hot, 0); 4935 pci_enable_wake(pdev, PCI_D3hot, 0);
4915 pci_enable_wake(pdev, PCI_D3cold, 0); 4936 pci_enable_wake(pdev, PCI_D3cold, 0);
4916 4937
4917 /* Perform card reset only on one instance of the card */
4918 if (PCI_FUNC (pdev->devfn) != 0)
4919 return PCI_ERS_RESULT_RECOVERED;
4920
4921 e1000_reset(adapter); 4938 e1000_reset(adapter);
4922 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 4939 E1000_WRITE_REG(&adapter->hw, WUS, ~0);
4923 4940
@@ -4948,6 +4965,7 @@ static void e1000_io_resume(struct pci_dev *pdev)
4948 netif_device_attach(netdev); 4965 netif_device_attach(netdev);
4949 4966
4950 if (adapter->hw.mac_type >= e1000_82540 && 4967 if (adapter->hw.mac_type >= e1000_82540 &&
4968 adapter->hw.mac_type < e1000_82571 &&
4951 adapter->hw.media_type == e1000_media_type_copper) { 4969 adapter->hw.media_type == e1000_media_type_copper) {
4952 manc = E1000_READ_REG(&adapter->hw, MANC); 4970 manc = E1000_READ_REG(&adapter->hw, MANC);
4953 manc &= ~(E1000_MANC_ARP_EN); 4971 manc &= ~(E1000_MANC_ARP_EN);
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index b40724fc6b74..39ad9f73d1ec 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -39,7 +39,7 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#define DRV_NAME "ehea" 41#define DRV_NAME "ehea"
42#define DRV_VERSION "EHEA_0034" 42#define DRV_VERSION "EHEA_0043"
43 43
44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ 44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \
45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) 45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
@@ -105,9 +105,6 @@
105#define EHEA_BCMC_VLANID_ALL 0x01 105#define EHEA_BCMC_VLANID_ALL 0x01
106#define EHEA_BCMC_VLANID_SINGLE 0x00 106#define EHEA_BCMC_VLANID_SINGLE 0x00
107 107
108/* Use this define to kmallocate pHYP control blocks */
109#define H_CB_ALIGNMENT 4096
110
111#define EHEA_CACHE_LINE 128 108#define EHEA_CACHE_LINE 128
112 109
113/* Memory Regions */ 110/* Memory Regions */
diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
index 82eb2fb8c75e..9f57c2e78ced 100644
--- a/drivers/net/ehea/ehea_ethtool.c
+++ b/drivers/net/ehea/ehea_ethtool.c
@@ -238,7 +238,7 @@ static void ehea_get_ethtool_stats(struct net_device *dev,
238 data[i++] = port->port_res[0].swqe_refill_th; 238 data[i++] = port->port_res[0].swqe_refill_th;
239 data[i++] = port->resets; 239 data[i++] = port->resets;
240 240
241 cb6 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 241 cb6 = kzalloc(PAGE_SIZE, GFP_KERNEL);
242 if (!cb6) { 242 if (!cb6) {
243 ehea_error("no mem for cb6"); 243 ehea_error("no mem for cb6");
244 return; 244 return;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index eb7d44de59ff..6ad696101418 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -92,7 +92,7 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev)
92 92
93 memset(stats, 0, sizeof(*stats)); 93 memset(stats, 0, sizeof(*stats));
94 94
95 cb2 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 95 cb2 = kzalloc(PAGE_SIZE, GFP_KERNEL);
96 if (!cb2) { 96 if (!cb2) {
97 ehea_error("no mem for cb2"); 97 ehea_error("no mem for cb2");
98 goto out; 98 goto out;
@@ -586,8 +586,8 @@ int ehea_sense_port_attr(struct ehea_port *port)
586 u64 hret; 586 u64 hret;
587 struct hcp_ehea_port_cb0 *cb0; 587 struct hcp_ehea_port_cb0 *cb0;
588 588
589 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 589 cb0 = kzalloc(PAGE_SIZE, GFP_ATOMIC); /* May be called via */
590 if (!cb0) { 590 if (!cb0) { /* ehea_neq_tasklet() */
591 ehea_error("no mem for cb0"); 591 ehea_error("no mem for cb0");
592 ret = -ENOMEM; 592 ret = -ENOMEM;
593 goto out; 593 goto out;
@@ -670,7 +670,7 @@ int ehea_set_portspeed(struct ehea_port *port, u32 port_speed)
670 u64 hret; 670 u64 hret;
671 int ret = 0; 671 int ret = 0;
672 672
673 cb4 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 673 cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL);
674 if (!cb4) { 674 if (!cb4) {
675 ehea_error("no mem for cb4"); 675 ehea_error("no mem for cb4");
676 ret = -ENOMEM; 676 ret = -ENOMEM;
@@ -765,8 +765,7 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
765 765
766 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) { 766 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) {
767 if (!netif_carrier_ok(port->netdev)) { 767 if (!netif_carrier_ok(port->netdev)) {
768 ret = ehea_sense_port_attr( 768 ret = ehea_sense_port_attr(port);
769 port);
770 if (ret) { 769 if (ret) {
771 ehea_error("failed resensing port " 770 ehea_error("failed resensing port "
772 "attributes"); 771 "attributes");
@@ -986,7 +985,7 @@ static int ehea_configure_port(struct ehea_port *port)
986 struct hcp_ehea_port_cb0 *cb0; 985 struct hcp_ehea_port_cb0 *cb0;
987 986
988 ret = -ENOMEM; 987 ret = -ENOMEM;
989 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 988 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
990 if (!cb0) 989 if (!cb0)
991 goto out; 990 goto out;
992 991
@@ -1444,7 +1443,7 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
1444 goto out; 1443 goto out;
1445 } 1444 }
1446 1445
1447 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1446 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1448 if (!cb0) { 1447 if (!cb0) {
1449 ehea_error("no mem for cb0"); 1448 ehea_error("no mem for cb0");
1450 ret = -ENOMEM; 1449 ret = -ENOMEM;
@@ -1502,7 +1501,7 @@ static void ehea_promiscuous(struct net_device *dev, int enable)
1502 if ((enable && port->promisc) || (!enable && !port->promisc)) 1501 if ((enable && port->promisc) || (!enable && !port->promisc))
1503 return; 1502 return;
1504 1503
1505 cb7 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1504 cb7 = kzalloc(PAGE_SIZE, GFP_ATOMIC);
1506 if (!cb7) { 1505 if (!cb7) {
1507 ehea_error("no mem for cb7"); 1506 ehea_error("no mem for cb7");
1508 goto out; 1507 goto out;
@@ -1606,7 +1605,7 @@ static void ehea_add_multicast_entry(struct ehea_port* port, u8* mc_mac_addr)
1606 struct ehea_mc_list *ehea_mcl_entry; 1605 struct ehea_mc_list *ehea_mcl_entry;
1607 u64 hret; 1606 u64 hret;
1608 1607
1609 ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_KERNEL); 1608 ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_ATOMIC);
1610 if (!ehea_mcl_entry) { 1609 if (!ehea_mcl_entry) {
1611 ehea_error("no mem for mcl_entry"); 1610 ehea_error("no mem for mcl_entry");
1612 return; 1611 return;
@@ -1871,7 +1870,7 @@ static void ehea_vlan_rx_register(struct net_device *dev,
1871 1870
1872 port->vgrp = grp; 1871 port->vgrp = grp;
1873 1872
1874 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1873 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1875 if (!cb1) { 1874 if (!cb1) {
1876 ehea_error("no mem for cb1"); 1875 ehea_error("no mem for cb1");
1877 goto out; 1876 goto out;
@@ -1900,7 +1899,7 @@ static void ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
1900 int index; 1899 int index;
1901 u64 hret; 1900 u64 hret;
1902 1901
1903 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1902 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1904 if (!cb1) { 1903 if (!cb1) {
1905 ehea_error("no mem for cb1"); 1904 ehea_error("no mem for cb1");
1906 goto out; 1905 goto out;
@@ -1936,7 +1935,7 @@ static void ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
1936 if (port->vgrp) 1935 if (port->vgrp)
1937 port->vgrp->vlan_devices[vid] = NULL; 1936 port->vgrp->vlan_devices[vid] = NULL;
1938 1937
1939 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1938 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1940 if (!cb1) { 1939 if (!cb1) {
1941 ehea_error("no mem for cb1"); 1940 ehea_error("no mem for cb1");
1942 goto out; 1941 goto out;
@@ -1969,7 +1968,7 @@ int ehea_activate_qp(struct ehea_adapter *adapter, struct ehea_qp *qp)
1969 u64 dummy64 = 0; 1968 u64 dummy64 = 0;
1970 struct hcp_modify_qp_cb0* cb0; 1969 struct hcp_modify_qp_cb0* cb0;
1971 1970
1972 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1971 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1973 if (!cb0) { 1972 if (!cb0) {
1974 ret = -ENOMEM; 1973 ret = -ENOMEM;
1975 goto out; 1974 goto out;
@@ -2270,7 +2269,7 @@ int ehea_sense_adapter_attr(struct ehea_adapter *adapter)
2270 u64 hret; 2269 u64 hret;
2271 int ret; 2270 int ret;
2272 2271
2273 cb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 2272 cb = kzalloc(PAGE_SIZE, GFP_KERNEL);
2274 if (!cb) { 2273 if (!cb) {
2275 ret = -ENOMEM; 2274 ret = -ENOMEM;
2276 goto out; 2275 goto out;
@@ -2341,7 +2340,7 @@ static int ehea_setup_single_port(struct ehea_port *port,
2341 goto out; 2340 goto out;
2342 2341
2343 /* Enable Jumbo frames */ 2342 /* Enable Jumbo frames */
2344 cb4 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 2343 cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL);
2345 if (!cb4) { 2344 if (!cb4) {
2346 ehea_error("no mem for cb4"); 2345 ehea_error("no mem for cb4");
2347 } else { 2346 } else {
diff --git a/drivers/net/ehea/ehea_phyp.c b/drivers/net/ehea/ehea_phyp.c
index 0b51a8cea077..0cfc2bc1a27b 100644
--- a/drivers/net/ehea/ehea_phyp.c
+++ b/drivers/net/ehea/ehea_phyp.c
@@ -506,7 +506,7 @@ u64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
506 const u8 pagesize, const u8 queue_type, 506 const u8 pagesize, const u8 queue_type,
507 const u64 log_pageaddr, const u64 count) 507 const u64 log_pageaddr, const u64 count)
508{ 508{
509 if ((count > 1) && (log_pageaddr & 0xfff)) { 509 if ((count > 1) && (log_pageaddr & ~PAGE_MASK)) {
510 ehea_error("not on pageboundary"); 510 ehea_error("not on pageboundary");
511 return H_PARAMETER; 511 return H_PARAMETER;
512 } 512 }
diff --git a/drivers/net/ehea/ehea_phyp.h b/drivers/net/ehea/ehea_phyp.h
index fa51e3b5bb05..919f94b75933 100644
--- a/drivers/net/ehea/ehea_phyp.h
+++ b/drivers/net/ehea/ehea_phyp.h
@@ -81,14 +81,16 @@ static inline u32 get_longbusy_msecs(int long_busy_ret_code)
81static inline void hcp_epas_ctor(struct h_epas *epas, u64 paddr_kernel, 81static inline void hcp_epas_ctor(struct h_epas *epas, u64 paddr_kernel,
82 u64 paddr_user) 82 u64 paddr_user)
83{ 83{
84 epas->kernel.addr = ioremap(paddr_kernel, PAGE_SIZE); 84 /* To support 64k pages we must round to 64k page boundary */
85 epas->kernel.addr = ioremap((paddr_kernel & PAGE_MASK), PAGE_SIZE) +
86 (paddr_kernel & ~PAGE_MASK);
85 epas->user.addr = paddr_user; 87 epas->user.addr = paddr_user;
86} 88}
87 89
88static inline void hcp_epas_dtor(struct h_epas *epas) 90static inline void hcp_epas_dtor(struct h_epas *epas)
89{ 91{
90 if (epas->kernel.addr) 92 if (epas->kernel.addr)
91 iounmap(epas->kernel.addr); 93 iounmap((void __iomem*)((u64)epas->kernel.addr & PAGE_MASK));
92 94
93 epas->user.addr = 0; 95 epas->user.addr = 0;
94 epas->kernel.addr = 0; 96 epas->kernel.addr = 0;
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index 3e1862326c88..72ef7bde3346 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -209,11 +209,11 @@ int ehea_destroy_cq(struct ehea_cq *cq)
209{ 209{
210 u64 adapter_handle, hret; 210 u64 adapter_handle, hret;
211 211
212 adapter_handle = cq->adapter->handle;
213
214 if (!cq) 212 if (!cq)
215 return 0; 213 return 0;
216 214
215 adapter_handle = cq->adapter->handle;
216
217 /* deregister all previous registered pages */ 217 /* deregister all previous registered pages */
218 hret = ehea_h_free_resource(adapter_handle, cq->fw_handle); 218 hret = ehea_h_free_resource(adapter_handle, cq->fw_handle);
219 if (hret != H_SUCCESS) { 219 if (hret != H_SUCCESS) {
@@ -512,7 +512,7 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
512 512
513 start = KERNELBASE; 513 start = KERNELBASE;
514 end = (u64)high_memory; 514 end = (u64)high_memory;
515 nr_pages = (end - start) / PAGE_SIZE; 515 nr_pages = (end - start) / EHEA_PAGESIZE;
516 516
517 pt = kzalloc(PAGE_SIZE, GFP_KERNEL); 517 pt = kzalloc(PAGE_SIZE, GFP_KERNEL);
518 if (!pt) { 518 if (!pt) {
@@ -538,9 +538,9 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
538 if (nr_pages > 1) { 538 if (nr_pages > 1) {
539 u64 num_pages = min(nr_pages, (u64)512); 539 u64 num_pages = min(nr_pages, (u64)512);
540 for (i = 0; i < num_pages; i++) 540 for (i = 0; i < num_pages; i++)
541 pt[i] = virt_to_abs((void*)(((u64)start) 541 pt[i] = virt_to_abs((void*)(((u64)start) +
542 + ((k++) * 542 ((k++) *
543 PAGE_SIZE))); 543 EHEA_PAGESIZE)));
544 544
545 hret = ehea_h_register_rpage_mr(adapter->handle, 545 hret = ehea_h_register_rpage_mr(adapter->handle,
546 adapter->mr.handle, 0, 546 adapter->mr.handle, 0,
@@ -548,8 +548,9 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
548 num_pages); 548 num_pages);
549 nr_pages -= num_pages; 549 nr_pages -= num_pages;
550 } else { 550 } else {
551 u64 abs_adr = virt_to_abs((void*)(((u64)start) 551 u64 abs_adr = virt_to_abs((void*)(((u64)start) +
552 + (k * PAGE_SIZE))); 552 (k * EHEA_PAGESIZE)));
553
553 hret = ehea_h_register_rpage_mr(adapter->handle, 554 hret = ehea_h_register_rpage_mr(adapter->handle,
554 adapter->mr.handle, 0, 555 adapter->mr.handle, 0,
555 0, abs_adr,1); 556 0, abs_adr,1);
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 86b3bb9bec2d..92420f007b97 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -914,7 +914,7 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd)
914 printk(KERN_DEBUG "6pack: protocol violation\n"); 914 printk(KERN_DEBUG "6pack: protocol violation\n");
915 else 915 else
916 sp->status = 0; 916 sp->status = 0;
917 cmd &= !SIXP_RX_DCD_MASK; 917 cmd &= ~SIXP_RX_DCD_MASK;
918 } 918 }
919 sp->status = cmd & SIXP_PRIO_DATA_MASK; 919 sp->status = cmd & SIXP_PRIO_DATA_MASK;
920 } else { /* output watchdog char if idle */ 920 } else { /* output watchdog char if idle */
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 2802db23d3cb..44c9f993dcc4 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -212,8 +212,8 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
212 break; 212 break;
213 } 213 }
214 214
215 free_index = pool->consumer_index++ % pool->size; 215 free_index = pool->consumer_index;
216 pool->consumer_index = free_index; 216 pool->consumer_index = (pool->consumer_index + 1) % pool->size;
217 index = pool->free_map[free_index]; 217 index = pool->free_map[free_index];
218 218
219 ibmveth_assert(index != IBM_VETH_INVALID_MAP); 219 ibmveth_assert(index != IBM_VETH_INVALID_MAP);
@@ -329,8 +329,10 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64
329 adapter->rx_buff_pool[pool].buff_size, 329 adapter->rx_buff_pool[pool].buff_size,
330 DMA_FROM_DEVICE); 330 DMA_FROM_DEVICE);
331 331
332 free_index = adapter->rx_buff_pool[pool].producer_index++ % adapter->rx_buff_pool[pool].size; 332 free_index = adapter->rx_buff_pool[pool].producer_index;
333 adapter->rx_buff_pool[pool].producer_index = free_index; 333 adapter->rx_buff_pool[pool].producer_index
334 = (adapter->rx_buff_pool[pool].producer_index + 1)
335 % adapter->rx_buff_pool[pool].size;
334 adapter->rx_buff_pool[pool].free_map[free_index] = index; 336 adapter->rx_buff_pool[pool].free_map[free_index] = index;
335 337
336 mb(); 338 mb();
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index e963dbf816be..f56b00ee385e 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -1017,7 +1017,7 @@ static void ioc3_init(struct net_device *dev)
1017 struct ioc3_private *ip = netdev_priv(dev); 1017 struct ioc3_private *ip = netdev_priv(dev);
1018 struct ioc3 *ioc3 = ip->regs; 1018 struct ioc3 *ioc3 = ip->regs;
1019 1019
1020 del_timer(&ip->ioc3_timer); /* Kill if running */ 1020 del_timer_sync(&ip->ioc3_timer); /* Kill if running */
1021 1021
1022 ioc3_w_emcr(EMCR_RST); /* Reset */ 1022 ioc3_w_emcr(EMCR_RST); /* Reset */
1023 (void) ioc3_r_emcr(); /* Flush WB */ 1023 (void) ioc3_r_emcr(); /* Flush WB */
@@ -1081,7 +1081,7 @@ static int ioc3_close(struct net_device *dev)
1081{ 1081{
1082 struct ioc3_private *ip = netdev_priv(dev); 1082 struct ioc3_private *ip = netdev_priv(dev);
1083 1083
1084 del_timer(&ip->ioc3_timer); 1084 del_timer_sync(&ip->ioc3_timer);
1085 1085
1086 netif_stop_queue(dev); 1086 netif_stop_queue(dev);
1087 1087
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index be8a66e702b0..3b4c47875935 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -15,8 +15,7 @@
15* 15*
16* This program is free software; you can redistribute it and/or modify 16* This program is free software; you can redistribute it and/or modify
17* it under the terms of the GNU General Public License as published by 17* it under the terms of the GNU General Public License as published by
18* the Free Software Foundation; either version 2 of the License, or 18* the Free Software Foundation; either version 2 of the License.
19* (at your option) any later version.
20* 19*
21* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
22* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index fdbb0d7213b0..806081b59733 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -2416,7 +2416,6 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2416 * firmware image, and set tx.boundary to 4KB. 2416 * firmware image, and set tx.boundary to 4KB.
2417 */ 2417 */
2418 2418
2419#define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE 0x0132
2420#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7 2419#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7
2421#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa 2420#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa
2422 2421
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index f1c75751cab7..b977ed85ff39 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -214,6 +214,7 @@ static struct pci_device_id rtl8169_pci_tbl[] = {
214 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 }, 214 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 },
215 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, 215 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
216 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 }, 216 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 },
217 { PCI_DEVICE(0x1259, 0xc107), 0, 0, RTL_CFG_0 },
217 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 }, 218 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 },
218 { PCI_VENDOR_ID_LINKSYS, 0x1032, 219 { PCI_VENDOR_ID_LINKSYS, 0x1032,
219 PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 }, 220 PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 },
@@ -1396,41 +1397,6 @@ static void rtl8169_netpoll(struct net_device *dev)
1396} 1397}
1397#endif 1398#endif
1398 1399
1399static void __rtl8169_set_mac_addr(struct net_device *dev, void __iomem *ioaddr)
1400{
1401 unsigned int i, j;
1402
1403 RTL_W8(Cfg9346, Cfg9346_Unlock);
1404 for (i = 0; i < 2; i++) {
1405 __le32 l = 0;
1406
1407 for (j = 0; j < 4; j++) {
1408 l <<= 8;
1409 l |= dev->dev_addr[4*i + j];
1410 }
1411 RTL_W32(MAC0 + 4*i, cpu_to_be32(l));
1412 }
1413 RTL_W8(Cfg9346, Cfg9346_Lock);
1414}
1415
1416static int rtl8169_set_mac_addr(struct net_device *dev, void *p)
1417{
1418 struct rtl8169_private *tp = netdev_priv(dev);
1419 struct sockaddr *addr = p;
1420
1421 if (!is_valid_ether_addr(addr->sa_data))
1422 return -EINVAL;
1423
1424 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
1425
1426 if (netif_running(dev)) {
1427 spin_lock_irq(&tp->lock);
1428 __rtl8169_set_mac_addr(dev, tp->mmio_addr);
1429 spin_unlock_irq(&tp->lock);
1430 }
1431 return 0;
1432}
1433
1434static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, 1400static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
1435 void __iomem *ioaddr) 1401 void __iomem *ioaddr)
1436{ 1402{
@@ -1507,8 +1473,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1507 struct rtl8169_private *tp; 1473 struct rtl8169_private *tp;
1508 struct net_device *dev; 1474 struct net_device *dev;
1509 void __iomem *ioaddr; 1475 void __iomem *ioaddr;
1510 unsigned int i, pm_cap; 1476 unsigned int pm_cap;
1511 int rc; 1477 int i, rc;
1512 1478
1513 if (netif_msg_drv(&debug)) { 1479 if (netif_msg_drv(&debug)) {
1514 printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", 1480 printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n",
@@ -1680,7 +1646,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1680 dev->stop = rtl8169_close; 1646 dev->stop = rtl8169_close;
1681 dev->tx_timeout = rtl8169_tx_timeout; 1647 dev->tx_timeout = rtl8169_tx_timeout;
1682 dev->set_multicast_list = rtl8169_set_rx_mode; 1648 dev->set_multicast_list = rtl8169_set_rx_mode;
1683 dev->set_mac_address = rtl8169_set_mac_addr;
1684 dev->watchdog_timeo = RTL8169_TX_TIMEOUT; 1649 dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
1685 dev->irq = pdev->irq; 1650 dev->irq = pdev->irq;
1686 dev->base_addr = (unsigned long) ioaddr; 1651 dev->base_addr = (unsigned long) ioaddr;
@@ -1928,8 +1893,6 @@ rtl8169_hw_start(struct net_device *dev)
1928 /* Enable all known interrupts by setting the interrupt mask. */ 1893 /* Enable all known interrupts by setting the interrupt mask. */
1929 RTL_W16(IntrMask, rtl8169_intr_mask); 1894 RTL_W16(IntrMask, rtl8169_intr_mask);
1930 1895
1931 __rtl8169_set_mac_addr(dev, ioaddr);
1932
1933 netif_start_queue(dev); 1896 netif_start_queue(dev);
1934} 1897}
1935 1898
@@ -2700,6 +2663,7 @@ static void rtl8169_down(struct net_device *dev)
2700 struct rtl8169_private *tp = netdev_priv(dev); 2663 struct rtl8169_private *tp = netdev_priv(dev);
2701 void __iomem *ioaddr = tp->mmio_addr; 2664 void __iomem *ioaddr = tp->mmio_addr;
2702 unsigned int poll_locked = 0; 2665 unsigned int poll_locked = 0;
2666 unsigned int intrmask;
2703 2667
2704 rtl8169_delete_timer(dev); 2668 rtl8169_delete_timer(dev);
2705 2669
@@ -2738,8 +2702,11 @@ core_down:
2738 * 2) dev->change_mtu 2702 * 2) dev->change_mtu
2739 * -> rtl8169_poll can not be issued again and re-enable the 2703 * -> rtl8169_poll can not be issued again and re-enable the
2740 * interruptions. Let's simply issue the IRQ down sequence again. 2704 * interruptions. Let's simply issue the IRQ down sequence again.
2705 *
2706 * No loop if hotpluged or major error (0xffff).
2741 */ 2707 */
2742 if (RTL_R16(IntrMask)) 2708 intrmask = RTL_R16(IntrMask);
2709 if (intrmask && (intrmask != 0xffff))
2743 goto core_down; 2710 goto core_down;
2744 2711
2745 rtl8169_tx_clear(tp); 2712 rtl8169_tx_clear(tp);
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index a231ab7d28dd..33569ec9dbfc 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -5985,6 +5985,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
5985 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1; 5985 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1;
5986 } else { 5986 } else {
5987 *skb = dev_alloc_skb(size); 5987 *skb = dev_alloc_skb(size);
5988 if (!(*skb)) {
5989 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb failed\n",
5990 dev->name);
5991 return -ENOMEM;
5992 }
5988 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 = 5993 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 =
5989 pci_map_single(sp->pdev, (*skb)->data, 5994 pci_map_single(sp->pdev, (*skb)->data,
5990 dev->mtu + 4, 5995 dev->mtu + 4,
@@ -6007,7 +6012,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
6007 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2; 6012 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2;
6008 } else { 6013 } else {
6009 *skb = dev_alloc_skb(size); 6014 *skb = dev_alloc_skb(size);
6010 6015 if (!(*skb)) {
6016 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb failed\n",
6017 dev->name);
6018 return -ENOMEM;
6019 }
6011 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 = 6020 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 =
6012 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, 6021 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
6013 PCI_DMA_FROMDEVICE); 6022 PCI_DMA_FROMDEVICE);
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index db2324939b69..1eae16b72b4b 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2903,7 +2903,7 @@ sbmac_init_module(void)
2903 2903
2904 dev = alloc_etherdev(sizeof(struct sbmac_softc)); 2904 dev = alloc_etherdev(sizeof(struct sbmac_softc));
2905 if (!dev) 2905 if (!dev)
2906 return -ENOMEM; /* return ENOMEM */ 2906 return -ENOMEM;
2907 2907
2908 printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port); 2908 printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port);
2909 2909
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index e7e414928f89..b2949035f66a 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -11,8 +11,7 @@
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
14 * the Free Software Foundation; either version 2 of the License, or 14 * the Free Software Foundation; either version 2 of the License.
15 * (at your option) any later version.
16 * 15 *
17 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 67ecd66f26d6..16616f5440d0 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -10,8 +10,7 @@
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
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License.
14 * (at your option) any later version.
15 * 14 *
16 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -699,16 +698,10 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
699 698
700} 699}
701 700
702/* Assign Ram Buffer allocation. 701/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */
703 * start and end are in units of 4k bytes 702static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
704 * ram registers are in units of 64bit words
705 */
706static void sky2_ramset(struct sky2_hw *hw, u16 q, u8 startk, u8 endk)
707{ 703{
708 u32 start, end; 704 pr_debug(PFX "q %d %#x %#x\n", q, start, end);
709
710 start = startk * 4096/8;
711 end = (endk * 4096/8) - 1;
712 705
713 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); 706 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
714 sky2_write32(hw, RB_ADDR(q, RB_START), start); 707 sky2_write32(hw, RB_ADDR(q, RB_START), start);
@@ -717,7 +710,7 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u8 startk, u8 endk)
717 sky2_write32(hw, RB_ADDR(q, RB_RP), start); 710 sky2_write32(hw, RB_ADDR(q, RB_RP), start);
718 711
719 if (q == Q_R1 || q == Q_R2) { 712 if (q == Q_R1 || q == Q_R2) {
720 u32 space = (endk - startk) * 4096/8; 713 u32 space = end - start + 1;
721 u32 tp = space - space/4; 714 u32 tp = space - space/4;
722 715
723 /* On receive queue's set the thresholds 716 /* On receive queue's set the thresholds
@@ -1199,19 +1192,16 @@ static int sky2_up(struct net_device *dev)
1199 1192
1200 sky2_mac_init(hw, port); 1193 sky2_mac_init(hw, port);
1201 1194
1202 /* Determine available ram buffer space (in 4K blocks). 1195 /* Determine available ram buffer space in qwords. */
1203 * Note: not sure about the FE setting below yet 1196 ramsize = sky2_read8(hw, B2_E_0) * 4096/8;
1204 */
1205 if (hw->chip_id == CHIP_ID_YUKON_FE)
1206 ramsize = 4;
1207 else
1208 ramsize = sky2_read8(hw, B2_E_0);
1209 1197
1210 /* Give transmitter one third (rounded up) */ 1198 if (ramsize > 6*1024/8)
1211 rxspace = ramsize - (ramsize + 2) / 3; 1199 rxspace = ramsize - (ramsize + 2) / 3;
1200 else
1201 rxspace = ramsize / 2;
1212 1202
1213 sky2_ramset(hw, rxqaddr[port], 0, rxspace); 1203 sky2_ramset(hw, rxqaddr[port], 0, rxspace-1);
1214 sky2_ramset(hw, txqaddr[port], rxspace, ramsize); 1204 sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1);
1215 1205
1216 /* Make sure SyncQ is disabled */ 1206 /* Make sure SyncQ is disabled */
1217 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), 1207 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
@@ -3248,7 +3238,11 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3248 dev->poll = sky2_poll; 3238 dev->poll = sky2_poll;
3249 dev->weight = NAPI_WEIGHT; 3239 dev->weight = NAPI_WEIGHT;
3250#ifdef CONFIG_NET_POLL_CONTROLLER 3240#ifdef CONFIG_NET_POLL_CONTROLLER
3251 dev->poll_controller = sky2_netpoll; 3241 /* Network console (only works on port 0)
3242 * because netpoll makes assumptions about NAPI
3243 */
3244 if (port == 0)
3245 dev->poll_controller = sky2_netpoll;
3252#endif 3246#endif
3253 3247
3254 sky2 = netdev_priv(dev); 3248 sky2 = netdev_priv(dev);
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 0c9f1e7dab2e..a8640169fc77 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -416,6 +416,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
416 416
417#define SMC_IRQ_FLAGS (0) 417#define SMC_IRQ_FLAGS (0)
418 418
419#elif defined(CONFIG_ARCH_VERSATILE)
420
421#define SMC_CAN_USE_8BIT 1
422#define SMC_CAN_USE_16BIT 1
423#define SMC_CAN_USE_32BIT 1
424#define SMC_NOWAIT 1
425
426#define SMC_inb(a, r) readb((a) + (r))
427#define SMC_inw(a, r) readw((a) + (r))
428#define SMC_inl(a, r) readl((a) + (r))
429#define SMC_outb(v, a, r) writeb(v, (a) + (r))
430#define SMC_outw(v, a, r) writew(v, (a) + (r))
431#define SMC_outl(v, a, r) writel(v, (a) + (r))
432#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
433#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
434
435#define SMC_IRQ_FLAGS (0)
436
419#else 437#else
420 438
421#define SMC_CAN_USE_8BIT 1 439#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 8e398499c045..c20bb998e0e5 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.67" 71#define DRV_MODULE_VERSION "3.69"
72#define DRV_MODULE_RELDATE "October 18, 2006" 72#define DRV_MODULE_RELDATE "November 15, 2006"
73 73
74#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -4728,10 +4728,11 @@ static int tg3_poll_fw(struct tg3 *tp)
4728 u32 val; 4728 u32 val;
4729 4729
4730 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 4730 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
4731 for (i = 0; i < 400; i++) { 4731 /* Wait up to 20ms for init done. */
4732 for (i = 0; i < 200; i++) {
4732 if (tr32(VCPU_STATUS) & VCPU_STATUS_INIT_DONE) 4733 if (tr32(VCPU_STATUS) & VCPU_STATUS_INIT_DONE)
4733 return 0; 4734 return 0;
4734 udelay(10); 4735 udelay(100);
4735 } 4736 }
4736 return -ENODEV; 4737 return -ENODEV;
4737 } 4738 }
@@ -6014,7 +6015,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6014 tg3_abort_hw(tp, 1); 6015 tg3_abort_hw(tp, 1);
6015 } 6016 }
6016 6017
6017 if ((tp->tg3_flags2 & TG3_FLG2_MII_SERDES) && reset_phy) 6018 if (reset_phy)
6018 tg3_phy_reset(tp); 6019 tg3_phy_reset(tp);
6019 6020
6020 err = tg3_chip_reset(tp); 6021 err = tg3_chip_reset(tp);
@@ -6574,7 +6575,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6574 tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 6575 tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
6575 } 6576 }
6576 6577
6577 err = tg3_setup_phy(tp, reset_phy); 6578 err = tg3_setup_phy(tp, 0);
6578 if (err) 6579 if (err)
6579 return err; 6580 return err;
6580 6581
@@ -6978,8 +6979,10 @@ static int tg3_open(struct net_device *dev)
6978 tg3_full_lock(tp, 0); 6979 tg3_full_lock(tp, 0);
6979 6980
6980 err = tg3_set_power_state(tp, PCI_D0); 6981 err = tg3_set_power_state(tp, PCI_D0);
6981 if (err) 6982 if (err) {
6983 tg3_full_unlock(tp);
6982 return err; 6984 return err;
6985 }
6983 6986
6984 tg3_disable_ints(tp); 6987 tg3_disable_ints(tp);
6985 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; 6988 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
@@ -10212,7 +10215,7 @@ skip_phy_reset:
10212static void __devinit tg3_read_partno(struct tg3 *tp) 10215static void __devinit tg3_read_partno(struct tg3 *tp)
10213{ 10216{
10214 unsigned char vpd_data[256]; 10217 unsigned char vpd_data[256];
10215 int i; 10218 unsigned int i;
10216 u32 magic; 10219 u32 magic;
10217 10220
10218 if (tg3_nvram_read_swab(tp, 0x0, &magic)) 10221 if (tg3_nvram_read_swab(tp, 0x0, &magic))
@@ -10258,9 +10261,9 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
10258 } 10261 }
10259 10262
10260 /* Now parse and find the part number. */ 10263 /* Now parse and find the part number. */
10261 for (i = 0; i < 256; ) { 10264 for (i = 0; i < 254; ) {
10262 unsigned char val = vpd_data[i]; 10265 unsigned char val = vpd_data[i];
10263 int block_end; 10266 unsigned int block_end;
10264 10267
10265 if (val == 0x82 || val == 0x91) { 10268 if (val == 0x82 || val == 0x91) {
10266 i = (i + 3 + 10269 i = (i + 3 +
@@ -10276,21 +10279,26 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
10276 (vpd_data[i + 1] + 10279 (vpd_data[i + 1] +
10277 (vpd_data[i + 2] << 8))); 10280 (vpd_data[i + 2] << 8)));
10278 i += 3; 10281 i += 3;
10279 while (i < block_end) { 10282
10283 if (block_end > 256)
10284 goto out_not_found;
10285
10286 while (i < (block_end - 2)) {
10280 if (vpd_data[i + 0] == 'P' && 10287 if (vpd_data[i + 0] == 'P' &&
10281 vpd_data[i + 1] == 'N') { 10288 vpd_data[i + 1] == 'N') {
10282 int partno_len = vpd_data[i + 2]; 10289 int partno_len = vpd_data[i + 2];
10283 10290
10284 if (partno_len > 24) 10291 i += 3;
10292 if (partno_len > 24 || (partno_len + i) > 256)
10285 goto out_not_found; 10293 goto out_not_found;
10286 10294
10287 memcpy(tp->board_part_number, 10295 memcpy(tp->board_part_number,
10288 &vpd_data[i + 3], 10296 &vpd_data[i], partno_len);
10289 partno_len);
10290 10297
10291 /* Success. */ 10298 /* Success. */
10292 return; 10299 return;
10293 } 10300 }
10301 i += 3 + vpd_data[i + 2];
10294 } 10302 }
10295 10303
10296 /* Part number not found. */ 10304 /* Part number not found. */
@@ -10360,7 +10368,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10360 u32 pci_state_reg, grc_misc_cfg; 10368 u32 pci_state_reg, grc_misc_cfg;
10361 u32 val; 10369 u32 val;
10362 u16 pci_cmd; 10370 u16 pci_cmd;
10363 int err; 10371 int err, pcie_cap;
10364 10372
10365 /* Force memory write invalidate off. If we leave it on, 10373 /* Force memory write invalidate off. If we leave it on,
10366 * then on 5700_BX chips we have to enable a workaround. 10374 * then on 5700_BX chips we have to enable a workaround.
@@ -10535,8 +10543,19 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10535 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5906) 10543 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5906)
10536 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; 10544 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE;
10537 10545
10538 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) 10546 pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP);
10547 if (pcie_cap != 0) {
10539 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 10548 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
10549 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
10550 u16 lnkctl;
10551
10552 pci_read_config_word(tp->pdev,
10553 pcie_cap + PCI_EXP_LNKCTL,
10554 &lnkctl);
10555 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN)
10556 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_2;
10557 }
10558 }
10540 10559
10541 /* If we have an AMD 762 or VIA K8T800 chipset, write 10560 /* If we have an AMD 762 or VIA K8T800 chipset, write
10542 * reordering to the mailbox registers done by the host 10561 * reordering to the mailbox registers done by the host
@@ -11803,6 +11822,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11803 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 11822 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
11804 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 || 11823 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
11805 tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 || 11824 tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 ||
11825 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906 ||
11806 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) { 11826 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) {
11807 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE; 11827 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE;
11808 } else { 11828 } else {
diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
index 4f756960db2a..cb7dbb63c9d9 100644
--- a/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -370,6 +370,10 @@ static int __init proteon_init(void)
370 dev->dma = dma[i]; 370 dev->dma = dma[i];
371 pdev = platform_device_register_simple("proteon", 371 pdev = platform_device_register_simple("proteon",
372 i, NULL, 0); 372 i, NULL, 0);
373 if (IS_ERR(pdev)) {
374 free_netdev(dev);
375 continue;
376 }
373 err = setup_card(dev, &pdev->dev); 377 err = setup_card(dev, &pdev->dev);
374 if (!err) { 378 if (!err) {
375 proteon_dev[i] = pdev; 379 proteon_dev[i] = pdev;
@@ -385,9 +389,10 @@ static int __init proteon_init(void)
385 /* Probe for cards. */ 389 /* Probe for cards. */
386 if (num == 0) { 390 if (num == 0) {
387 printk(KERN_NOTICE "proteon.c: No cards found.\n"); 391 printk(KERN_NOTICE "proteon.c: No cards found.\n");
388 return (-ENODEV); 392 platform_driver_unregister(&proteon_driver);
393 return -ENODEV;
389 } 394 }
390 return (0); 395 return 0;
391} 396}
392 397
393static void __exit proteon_cleanup(void) 398static void __exit proteon_cleanup(void)
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
index d6ba41cf3110..33afea31d87b 100644
--- a/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -380,6 +380,10 @@ static int __init sk_isa_init(void)
380 dev->dma = dma[i]; 380 dev->dma = dma[i];
381 pdev = platform_device_register_simple("skisa", 381 pdev = platform_device_register_simple("skisa",
382 i, NULL, 0); 382 i, NULL, 0);
383 if (IS_ERR(pdev)) {
384 free_netdev(dev);
385 continue;
386 }
383 err = setup_card(dev, &pdev->dev); 387 err = setup_card(dev, &pdev->dev);
384 if (!err) { 388 if (!err) {
385 sk_isa_dev[i] = pdev; 389 sk_isa_dev[i] = pdev;
@@ -395,9 +399,10 @@ static int __init sk_isa_init(void)
395 /* Probe for cards. */ 399 /* Probe for cards. */
396 if (num == 0) { 400 if (num == 0) {
397 printk(KERN_NOTICE "skisa.c: No cards found.\n"); 401 printk(KERN_NOTICE "skisa.c: No cards found.\n");
398 return (-ENODEV); 402 platform_driver_unregister(&sk_isa_driver);
403 return -ENODEV;
399 } 404 }
400 return (0); 405 return 0;
401} 406}
402 407
403static void __exit sk_isa_cleanup(void) 408static void __exit sk_isa_cleanup(void)
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 12cd7b561f35..b37888011067 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -2,14 +2,11 @@
2 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved. 2 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
3 * 3 *
4 * Author: Shlomi Gridish <gridish@freescale.com> 4 * Author: Shlomi Gridish <gridish@freescale.com>
5 * Li Yang <leoli@freescale.com>
5 * 6 *
6 * Description: 7 * Description:
7 * QE UCC Gigabit Ethernet Driver 8 * QE UCC Gigabit Ethernet Driver
8 * 9 *
9 * Changelog:
10 * Jul 6, 2006 Li Yang <LeoLi@freescale.com>
11 * - Rearrange code and style fixes
12 *
13 * 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
14 * 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
15 * 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
@@ -31,9 +28,9 @@
31#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
32#include <linux/fsl_devices.h> 29#include <linux/fsl_devices.h>
33#include <linux/ethtool.h> 30#include <linux/ethtool.h>
34#include <linux/platform_device.h>
35#include <linux/mii.h> 31#include <linux/mii.h>
36 32
33#include <asm/of_device.h>
37#include <asm/uaccess.h> 34#include <asm/uaccess.h>
38#include <asm/irq.h> 35#include <asm/irq.h>
39#include <asm/io.h> 36#include <asm/io.h>
@@ -70,7 +67,7 @@
70 67
71static DEFINE_SPINLOCK(ugeth_lock); 68static DEFINE_SPINLOCK(ugeth_lock);
72 69
73static ucc_geth_info_t ugeth_primary_info = { 70static struct ucc_geth_info ugeth_primary_info = {
74 .uf_info = { 71 .uf_info = {
75 .bd_mem_part = MEM_PART_SYSTEM, 72 .bd_mem_part = MEM_PART_SYSTEM,
76 .rtsm = UCC_FAST_SEND_IDLES_BETWEEN_FRAMES, 73 .rtsm = UCC_FAST_SEND_IDLES_BETWEEN_FRAMES,
@@ -163,7 +160,7 @@ static ucc_geth_info_t ugeth_primary_info = {
163 .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, 160 .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2,
164}; 161};
165 162
166static ucc_geth_info_t ugeth_info[8]; 163static struct ucc_geth_info ugeth_info[8];
167 164
168#ifdef DEBUG 165#ifdef DEBUG
169static void mem_disp(u8 *addr, int size) 166static void mem_disp(u8 *addr, int size)
@@ -219,8 +216,8 @@ static struct list_head *dequeue(struct list_head *lh)
219 } 216 }
220} 217}
221 218
222static int get_interface_details(enet_interface_e enet_interface, 219static int get_interface_details(enum enet_interface enet_interface,
223 enet_speed_e *speed, 220 enum enet_speed *speed,
224 int *r10m, 221 int *r10m,
225 int *rmm, 222 int *rmm,
226 int *rpm, 223 int *rpm,
@@ -283,7 +280,7 @@ static int get_interface_details(enet_interface_e enet_interface,
283 return 0; 280 return 0;
284} 281}
285 282
286static struct sk_buff *get_new_skb(ucc_geth_private_t *ugeth, u8 *bd) 283static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth, u8 *bd)
287{ 284{
288 struct sk_buff *skb = NULL; 285 struct sk_buff *skb = NULL;
289 286
@@ -303,21 +300,19 @@ static struct sk_buff *get_new_skb(ucc_geth_private_t *ugeth, u8 *bd)
303 300
304 skb->dev = ugeth->dev; 301 skb->dev = ugeth->dev;
305 302
306 BD_BUFFER_SET(bd, 303 out_be32(&((struct qe_bd *)bd)->buf,
307 dma_map_single(NULL, 304 dma_map_single(NULL,
308 skb->data, 305 skb->data,
309 ugeth->ug_info->uf_info.max_rx_buf_length + 306 ugeth->ug_info->uf_info.max_rx_buf_length +
310 UCC_GETH_RX_DATA_BUF_ALIGNMENT, 307 UCC_GETH_RX_DATA_BUF_ALIGNMENT,
311 DMA_FROM_DEVICE)); 308 DMA_FROM_DEVICE));
312 309
313 BD_STATUS_AND_LENGTH_SET(bd, 310 out_be32((u32 *)bd, (R_E | R_I | (in_be32((u32 *)bd) & R_W)));
314 (R_E | R_I |
315 (BD_STATUS_AND_LENGTH(bd) & R_W)));
316 311
317 return skb; 312 return skb;
318} 313}
319 314
320static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ) 315static int rx_bd_buffer_set(struct ucc_geth_private *ugeth, u8 rxQ)
321{ 316{
322 u8 *bd; 317 u8 *bd;
323 u32 bd_status; 318 u32 bd_status;
@@ -328,7 +323,7 @@ static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ)
328 i = 0; 323 i = 0;
329 324
330 do { 325 do {
331 bd_status = BD_STATUS_AND_LENGTH(bd); 326 bd_status = in_be32((u32*)bd);
332 skb = get_new_skb(ugeth, bd); 327 skb = get_new_skb(ugeth, bd);
333 328
334 if (!skb) /* If can not allocate data buffer, 329 if (!skb) /* If can not allocate data buffer,
@@ -338,19 +333,19 @@ static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ)
338 ugeth->rx_skbuff[rxQ][i] = skb; 333 ugeth->rx_skbuff[rxQ][i] = skb;
339 334
340 /* advance the BD pointer */ 335 /* advance the BD pointer */
341 bd += UCC_GETH_SIZE_OF_BD; 336 bd += sizeof(struct qe_bd);
342 i++; 337 i++;
343 } while (!(bd_status & R_W)); 338 } while (!(bd_status & R_W));
344 339
345 return 0; 340 return 0;
346} 341}
347 342
348static int fill_init_enet_entries(ucc_geth_private_t *ugeth, 343static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
349 volatile u32 *p_start, 344 volatile u32 *p_start,
350 u8 num_entries, 345 u8 num_entries,
351 u32 thread_size, 346 u32 thread_size,
352 u32 thread_alignment, 347 u32 thread_alignment,
353 qe_risc_allocation_e risc, 348 enum qe_risc_allocation risc,
354 int skip_page_for_first_entry) 349 int skip_page_for_first_entry)
355{ 350{
356 u32 init_enet_offset; 351 u32 init_enet_offset;
@@ -383,10 +378,10 @@ static int fill_init_enet_entries(ucc_geth_private_t *ugeth,
383 return 0; 378 return 0;
384} 379}
385 380
386static int return_init_enet_entries(ucc_geth_private_t *ugeth, 381static int return_init_enet_entries(struct ucc_geth_private *ugeth,
387 volatile u32 *p_start, 382 volatile u32 *p_start,
388 u8 num_entries, 383 u8 num_entries,
389 qe_risc_allocation_e risc, 384 enum qe_risc_allocation risc,
390 int skip_page_for_first_entry) 385 int skip_page_for_first_entry)
391{ 386{
392 u32 init_enet_offset; 387 u32 init_enet_offset;
@@ -416,11 +411,11 @@ static int return_init_enet_entries(ucc_geth_private_t *ugeth,
416} 411}
417 412
418#ifdef DEBUG 413#ifdef DEBUG
419static int dump_init_enet_entries(ucc_geth_private_t *ugeth, 414static int dump_init_enet_entries(struct ucc_geth_private *ugeth,
420 volatile u32 *p_start, 415 volatile u32 *p_start,
421 u8 num_entries, 416 u8 num_entries,
422 u32 thread_size, 417 u32 thread_size,
423 qe_risc_allocation_e risc, 418 enum qe_risc_allocation risc,
424 int skip_page_for_first_entry) 419 int skip_page_for_first_entry)
425{ 420{
426 u32 init_enet_offset; 421 u32 init_enet_offset;
@@ -456,14 +451,14 @@ static int dump_init_enet_entries(ucc_geth_private_t *ugeth,
456#endif 451#endif
457 452
458#ifdef CONFIG_UGETH_FILTERING 453#ifdef CONFIG_UGETH_FILTERING
459static enet_addr_container_t *get_enet_addr_container(void) 454static struct enet_addr_container *get_enet_addr_container(void)
460{ 455{
461 enet_addr_container_t *enet_addr_cont; 456 struct enet_addr_container *enet_addr_cont;
462 457
463 /* allocate memory */ 458 /* allocate memory */
464 enet_addr_cont = kmalloc(sizeof(enet_addr_container_t), GFP_KERNEL); 459 enet_addr_cont = kmalloc(sizeof(struct enet_addr_container), GFP_KERNEL);
465 if (!enet_addr_cont) { 460 if (!enet_addr_cont) {
466 ugeth_err("%s: No memory for enet_addr_container_t object.", 461 ugeth_err("%s: No memory for enet_addr_container object.",
467 __FUNCTION__); 462 __FUNCTION__);
468 return NULL; 463 return NULL;
469 } 464 }
@@ -472,45 +467,43 @@ static enet_addr_container_t *get_enet_addr_container(void)
472} 467}
473#endif /* CONFIG_UGETH_FILTERING */ 468#endif /* CONFIG_UGETH_FILTERING */
474 469
475static void put_enet_addr_container(enet_addr_container_t *enet_addr_cont) 470static void put_enet_addr_container(struct enet_addr_container *enet_addr_cont)
476{ 471{
477 kfree(enet_addr_cont); 472 kfree(enet_addr_cont);
478} 473}
479 474
475static int set_mac_addr(__be16 __iomem *reg, u8 *mac)
476{
477 out_be16(&reg[0], ((u16)mac[5] << 8) | mac[4]);
478 out_be16(&reg[1], ((u16)mac[3] << 8) | mac[2]);
479 out_be16(&reg[2], ((u16)mac[1] << 8) | mac[0]);
480}
481
480#ifdef CONFIG_UGETH_FILTERING 482#ifdef CONFIG_UGETH_FILTERING
481static int hw_add_addr_in_paddr(ucc_geth_private_t *ugeth, 483static int hw_add_addr_in_paddr(struct ucc_geth_private *ugeth,
482 enet_addr_t *p_enet_addr, u8 paddr_num) 484 u8 *p_enet_addr, u8 paddr_num)
483{ 485{
484 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 486 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
485 487
486 if (!(paddr_num < NUM_OF_PADDRS)) { 488 if (!(paddr_num < NUM_OF_PADDRS)) {
487 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__); 489 ugeth_warn("%s: Illegal paddr_num.", __FUNCTION__);
488 return -EINVAL; 490 return -EINVAL;
489 } 491 }
490 492
491 p_82xx_addr_filt = 493 p_82xx_addr_filt =
492 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 494 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
493 addressfiltering; 495 addressfiltering;
494 496
495 /* Ethernet frames are defined in Little Endian mode, */ 497 /* Ethernet frames are defined in Little Endian mode, */
496 /* therefore to insert the address we reverse the bytes. */ 498 /* therefore to insert the address we reverse the bytes. */
497 out_be16(&p_82xx_addr_filt->paddr[paddr_num].h, 499 set_mac_addr(&p_82xx_addr_filt->paddr[paddr_num].h, p_enet_addr);
498 (u16) (((u16) (((u16) ((*p_enet_addr)[5])) << 8)) |
499 (u16) (*p_enet_addr)[4]));
500 out_be16(&p_82xx_addr_filt->paddr[paddr_num].m,
501 (u16) (((u16) (((u16) ((*p_enet_addr)[3])) << 8)) |
502 (u16) (*p_enet_addr)[2]));
503 out_be16(&p_82xx_addr_filt->paddr[paddr_num].l,
504 (u16) (((u16) (((u16) ((*p_enet_addr)[1])) << 8)) |
505 (u16) (*p_enet_addr)[0]));
506
507 return 0; 500 return 0;
508} 501}
509#endif /* CONFIG_UGETH_FILTERING */ 502#endif /* CONFIG_UGETH_FILTERING */
510 503
511static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num) 504static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num)
512{ 505{
513 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 506 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
514 507
515 if (!(paddr_num < NUM_OF_PADDRS)) { 508 if (!(paddr_num < NUM_OF_PADDRS)) {
516 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__); 509 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__);
@@ -518,7 +511,7 @@ static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num)
518 } 511 }
519 512
520 p_82xx_addr_filt = 513 p_82xx_addr_filt =
521 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 514 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
522 addressfiltering; 515 addressfiltering;
523 516
524 /* Writing address ff.ff.ff.ff.ff.ff disables address 517 /* Writing address ff.ff.ff.ff.ff.ff disables address
@@ -530,14 +523,14 @@ static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num)
530 return 0; 523 return 0;
531} 524}
532 525
533static void hw_add_addr_in_hash(ucc_geth_private_t *ugeth, 526static void hw_add_addr_in_hash(struct ucc_geth_private *ugeth,
534 enet_addr_t *p_enet_addr) 527 u8 *p_enet_addr)
535{ 528{
536 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 529 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
537 u32 cecr_subblock; 530 u32 cecr_subblock;
538 531
539 p_82xx_addr_filt = 532 p_82xx_addr_filt =
540 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 533 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
541 addressfiltering; 534 addressfiltering;
542 535
543 cecr_subblock = 536 cecr_subblock =
@@ -546,25 +539,18 @@ static void hw_add_addr_in_hash(ucc_geth_private_t *ugeth,
546 /* Ethernet frames are defined in Little Endian mode, 539 /* Ethernet frames are defined in Little Endian mode,
547 therefor to insert */ 540 therefor to insert */
548 /* the address to the hash (Big Endian mode), we reverse the bytes.*/ 541 /* the address to the hash (Big Endian mode), we reverse the bytes.*/
549 out_be16(&p_82xx_addr_filt->taddr.h, 542
550 (u16) (((u16) (((u16) ((*p_enet_addr)[5])) << 8)) | 543 set_mac_addr(&p_82xx_addr_filt->taddr.h, p_enet_addr);
551 (u16) (*p_enet_addr)[4]));
552 out_be16(&p_82xx_addr_filt->taddr.m,
553 (u16) (((u16) (((u16) ((*p_enet_addr)[3])) << 8)) |
554 (u16) (*p_enet_addr)[2]));
555 out_be16(&p_82xx_addr_filt->taddr.l,
556 (u16) (((u16) (((u16) ((*p_enet_addr)[1])) << 8)) |
557 (u16) (*p_enet_addr)[0]));
558 544
559 qe_issue_cmd(QE_SET_GROUP_ADDRESS, cecr_subblock, 545 qe_issue_cmd(QE_SET_GROUP_ADDRESS, cecr_subblock,
560 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 546 QE_CR_PROTOCOL_ETHERNET, 0);
561} 547}
562 548
563#ifdef CONFIG_UGETH_MAGIC_PACKET 549#ifdef CONFIG_UGETH_MAGIC_PACKET
564static void magic_packet_detection_enable(ucc_geth_private_t *ugeth) 550static void magic_packet_detection_enable(struct ucc_geth_private *ugeth)
565{ 551{
566 ucc_fast_private_t *uccf; 552 struct ucc_fast_private *uccf;
567 ucc_geth_t *ug_regs; 553 struct ucc_geth *ug_regs;
568 u32 maccfg2, uccm; 554 u32 maccfg2, uccm;
569 555
570 uccf = ugeth->uccf; 556 uccf = ugeth->uccf;
@@ -581,10 +567,10 @@ static void magic_packet_detection_enable(ucc_geth_private_t *ugeth)
581 out_be32(&ug_regs->maccfg2, maccfg2); 567 out_be32(&ug_regs->maccfg2, maccfg2);
582} 568}
583 569
584static void magic_packet_detection_disable(ucc_geth_private_t *ugeth) 570static void magic_packet_detection_disable(struct ucc_geth_private *ugeth)
585{ 571{
586 ucc_fast_private_t *uccf; 572 struct ucc_fast_private *uccf;
587 ucc_geth_t *ug_regs; 573 struct ucc_geth *ug_regs;
588 u32 maccfg2, uccm; 574 u32 maccfg2, uccm;
589 575
590 uccf = ugeth->uccf; 576 uccf = ugeth->uccf;
@@ -602,26 +588,26 @@ static void magic_packet_detection_disable(ucc_geth_private_t *ugeth)
602} 588}
603#endif /* MAGIC_PACKET */ 589#endif /* MAGIC_PACKET */
604 590
605static inline int compare_addr(enet_addr_t *addr1, enet_addr_t *addr2) 591static inline int compare_addr(u8 **addr1, u8 **addr2)
606{ 592{
607 return memcmp(addr1, addr2, ENET_NUM_OCTETS_PER_ADDRESS); 593 return memcmp(addr1, addr2, ENET_NUM_OCTETS_PER_ADDRESS);
608} 594}
609 595
610#ifdef DEBUG 596#ifdef DEBUG
611static void get_statistics(ucc_geth_private_t *ugeth, 597static void get_statistics(struct ucc_geth_private *ugeth,
612 ucc_geth_tx_firmware_statistics_t * 598 struct ucc_geth_tx_firmware_statistics *
613 tx_firmware_statistics, 599 tx_firmware_statistics,
614 ucc_geth_rx_firmware_statistics_t * 600 struct ucc_geth_rx_firmware_statistics *
615 rx_firmware_statistics, 601 rx_firmware_statistics,
616 ucc_geth_hardware_statistics_t *hardware_statistics) 602 struct ucc_geth_hardware_statistics *hardware_statistics)
617{ 603{
618 ucc_fast_t *uf_regs; 604 struct ucc_fast *uf_regs;
619 ucc_geth_t *ug_regs; 605 struct ucc_geth *ug_regs;
620 ucc_geth_tx_firmware_statistics_pram_t *p_tx_fw_statistics_pram; 606 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram;
621 ucc_geth_rx_firmware_statistics_pram_t *p_rx_fw_statistics_pram; 607 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram;
622 608
623 ug_regs = ugeth->ug_regs; 609 ug_regs = ugeth->ug_regs;
624 uf_regs = (ucc_fast_t *) ug_regs; 610 uf_regs = (struct ucc_fast *) ug_regs;
625 p_tx_fw_statistics_pram = ugeth->p_tx_fw_statistics_pram; 611 p_tx_fw_statistics_pram = ugeth->p_tx_fw_statistics_pram;
626 p_rx_fw_statistics_pram = ugeth->p_rx_fw_statistics_pram; 612 p_rx_fw_statistics_pram = ugeth->p_rx_fw_statistics_pram;
627 613
@@ -727,7 +713,7 @@ static void get_statistics(ucc_geth_private_t *ugeth,
727 } 713 }
728} 714}
729 715
730static void dump_bds(ucc_geth_private_t *ugeth) 716static void dump_bds(struct ucc_geth_private *ugeth)
731{ 717{
732 int i; 718 int i;
733 int length; 719 int length;
@@ -736,7 +722,7 @@ static void dump_bds(ucc_geth_private_t *ugeth)
736 if (ugeth->p_tx_bd_ring[i]) { 722 if (ugeth->p_tx_bd_ring[i]) {
737 length = 723 length =
738 (ugeth->ug_info->bdRingLenTx[i] * 724 (ugeth->ug_info->bdRingLenTx[i] *
739 UCC_GETH_SIZE_OF_BD); 725 sizeof(struct qe_bd));
740 ugeth_info("TX BDs[%d]", i); 726 ugeth_info("TX BDs[%d]", i);
741 mem_disp(ugeth->p_tx_bd_ring[i], length); 727 mem_disp(ugeth->p_tx_bd_ring[i], length);
742 } 728 }
@@ -745,14 +731,14 @@ static void dump_bds(ucc_geth_private_t *ugeth)
745 if (ugeth->p_rx_bd_ring[i]) { 731 if (ugeth->p_rx_bd_ring[i]) {
746 length = 732 length =
747 (ugeth->ug_info->bdRingLenRx[i] * 733 (ugeth->ug_info->bdRingLenRx[i] *
748 UCC_GETH_SIZE_OF_BD); 734 sizeof(struct qe_bd));
749 ugeth_info("RX BDs[%d]", i); 735 ugeth_info("RX BDs[%d]", i);
750 mem_disp(ugeth->p_rx_bd_ring[i], length); 736 mem_disp(ugeth->p_rx_bd_ring[i], length);
751 } 737 }
752 } 738 }
753} 739}
754 740
755static void dump_regs(ucc_geth_private_t *ugeth) 741static void dump_regs(struct ucc_geth_private *ugeth)
756{ 742{
757 int i; 743 int i;
758 744
@@ -893,7 +879,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
893 ugeth_info("Base address: 0x%08x", 879 ugeth_info("Base address: 0x%08x",
894 (u32) & ugeth->p_thread_data_tx[i]); 880 (u32) & ugeth->p_thread_data_tx[i]);
895 mem_disp((u8 *) & ugeth->p_thread_data_tx[i], 881 mem_disp((u8 *) & ugeth->p_thread_data_tx[i],
896 sizeof(ucc_geth_thread_data_tx_t)); 882 sizeof(struct ucc_geth_thread_data_tx));
897 } 883 }
898 } 884 }
899 if (ugeth->p_thread_data_rx) { 885 if (ugeth->p_thread_data_rx) {
@@ -927,7 +913,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
927 ugeth_info("Base address: 0x%08x", 913 ugeth_info("Base address: 0x%08x",
928 (u32) & ugeth->p_thread_data_rx[i]); 914 (u32) & ugeth->p_thread_data_rx[i]);
929 mem_disp((u8 *) & ugeth->p_thread_data_rx[i], 915 mem_disp((u8 *) & ugeth->p_thread_data_rx[i],
930 sizeof(ucc_geth_thread_data_rx_t)); 916 sizeof(struct ucc_geth_thread_data_rx));
931 } 917 }
932 } 918 }
933 if (ugeth->p_exf_glbl_param) { 919 if (ugeth->p_exf_glbl_param) {
@@ -1105,7 +1091,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1105 ugeth_info("Base address: 0x%08x", 1091 ugeth_info("Base address: 0x%08x",
1106 (u32) & ugeth->p_send_q_mem_reg->sqqd[i]); 1092 (u32) & ugeth->p_send_q_mem_reg->sqqd[i]);
1107 mem_disp((u8 *) & ugeth->p_send_q_mem_reg->sqqd[i], 1093 mem_disp((u8 *) & ugeth->p_send_q_mem_reg->sqqd[i],
1108 sizeof(ucc_geth_send_queue_qd_t)); 1094 sizeof(struct ucc_geth_send_queue_qd));
1109 } 1095 }
1110 } 1096 }
1111 if (ugeth->p_scheduler) { 1097 if (ugeth->p_scheduler) {
@@ -1187,7 +1173,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1187 qe_muram_addr(in_be32 1173 qe_muram_addr(in_be32
1188 (&ugeth->p_rx_bd_qs_tbl[i]. 1174 (&ugeth->p_rx_bd_qs_tbl[i].
1189 bdbaseptr)), 1175 bdbaseptr)),
1190 sizeof(ucc_geth_rx_prefetched_bds_t)); 1176 sizeof(struct ucc_geth_rx_prefetched_bds));
1191 } 1177 }
1192 } 1178 }
1193 if (ugeth->p_init_enet_param_shadow) { 1179 if (ugeth->p_init_enet_param_shadow) {
@@ -1198,7 +1184,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1198 mem_disp((u8 *) ugeth->p_init_enet_param_shadow, 1184 mem_disp((u8 *) ugeth->p_init_enet_param_shadow,
1199 sizeof(*ugeth->p_init_enet_param_shadow)); 1185 sizeof(*ugeth->p_init_enet_param_shadow));
1200 1186
1201 size = sizeof(ucc_geth_thread_rx_pram_t); 1187 size = sizeof(struct ucc_geth_thread_rx_pram);
1202 if (ugeth->ug_info->rxExtendedFiltering) { 1188 if (ugeth->ug_info->rxExtendedFiltering) {
1203 size += 1189 size +=
1204 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; 1190 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING;
@@ -1216,7 +1202,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1216 &(ugeth->p_init_enet_param_shadow-> 1202 &(ugeth->p_init_enet_param_shadow->
1217 txthread[0]), 1203 txthread[0]),
1218 ENET_INIT_PARAM_MAX_ENTRIES_TX, 1204 ENET_INIT_PARAM_MAX_ENTRIES_TX,
1219 sizeof(ucc_geth_thread_tx_pram_t), 1205 sizeof(struct ucc_geth_thread_tx_pram),
1220 ugeth->ug_info->riscTx, 0); 1206 ugeth->ug_info->riscTx, 0);
1221 dump_init_enet_entries(ugeth, 1207 dump_init_enet_entries(ugeth,
1222 &(ugeth->p_init_enet_param_shadow-> 1208 &(ugeth->p_init_enet_param_shadow->
@@ -1578,12 +1564,12 @@ static int init_min_frame_len(u16 min_frame_length,
1578 return 0; 1564 return 0;
1579} 1565}
1580 1566
1581static int adjust_enet_interface(ucc_geth_private_t *ugeth) 1567static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1582{ 1568{
1583 ucc_geth_info_t *ug_info; 1569 struct ucc_geth_info *ug_info;
1584 ucc_geth_t *ug_regs; 1570 struct ucc_geth *ug_regs;
1585 ucc_fast_t *uf_regs; 1571 struct ucc_fast *uf_regs;
1586 enet_speed_e speed; 1572 enum enet_speed speed;
1587 int ret_val, rpm = 0, tbi = 0, r10m = 0, rmm = 1573 int ret_val, rpm = 0, tbi = 0, r10m = 0, rmm =
1588 0, limited_to_full_duplex = 0; 1574 0, limited_to_full_duplex = 0;
1589 u32 upsmr, maccfg2, utbipar, tbiBaseAddress; 1575 u32 upsmr, maccfg2, utbipar, tbiBaseAddress;
@@ -1691,8 +1677,8 @@ static int adjust_enet_interface(ucc_geth_private_t *ugeth)
1691 */ 1677 */
1692static void adjust_link(struct net_device *dev) 1678static void adjust_link(struct net_device *dev)
1693{ 1679{
1694 ucc_geth_private_t *ugeth = netdev_priv(dev); 1680 struct ucc_geth_private *ugeth = netdev_priv(dev);
1695 ucc_geth_t *ug_regs; 1681 struct ucc_geth *ug_regs;
1696 u32 tempval; 1682 u32 tempval;
1697 struct ugeth_mii_info *mii_info = ugeth->mii_info; 1683 struct ugeth_mii_info *mii_info = ugeth->mii_info;
1698 1684
@@ -1722,7 +1708,7 @@ static void adjust_link(struct net_device *dev)
1722 if (mii_info->speed != ugeth->oldspeed) { 1708 if (mii_info->speed != ugeth->oldspeed) {
1723 switch (mii_info->speed) { 1709 switch (mii_info->speed) {
1724 case 1000: 1710 case 1000:
1725#ifdef CONFIG_MPC836x 1711#ifdef CONFIG_PPC_MPC836x
1726/* FIXME: This code is for 100Mbs BUG fixing, 1712/* FIXME: This code is for 100Mbs BUG fixing,
1727remove this when it is fixed!!! */ 1713remove this when it is fixed!!! */
1728 if (ugeth->ug_info->enet_interface == 1714 if (ugeth->ug_info->enet_interface ==
@@ -1768,7 +1754,7 @@ remove this when it is fixed!!! */
1768 break; 1754 break;
1769 case 100: 1755 case 100:
1770 case 10: 1756 case 10:
1771#ifdef CONFIG_MPC836x 1757#ifdef CONFIG_PPC_MPC836x
1772/* FIXME: This code is for 100Mbs BUG fixing, 1758/* FIXME: This code is for 100Mbs BUG fixing,
1773remove this lines when it will be fixed!!! */ 1759remove this lines when it will be fixed!!! */
1774 ugeth->ug_info->enet_interface = ENET_100_RGMII; 1760 ugeth->ug_info->enet_interface = ENET_100_RGMII;
@@ -1827,9 +1813,9 @@ remove this lines when it will be fixed!!! */
1827 */ 1813 */
1828static int init_phy(struct net_device *dev) 1814static int init_phy(struct net_device *dev)
1829{ 1815{
1830 ucc_geth_private_t *ugeth = netdev_priv(dev); 1816 struct ucc_geth_private *ugeth = netdev_priv(dev);
1831 struct phy_info *curphy; 1817 struct phy_info *curphy;
1832 ucc_mii_mng_t *mii_regs; 1818 struct ucc_mii_mng *mii_regs;
1833 struct ugeth_mii_info *mii_info; 1819 struct ugeth_mii_info *mii_info;
1834 int err; 1820 int err;
1835 1821
@@ -1914,17 +1900,17 @@ static int init_phy(struct net_device *dev)
1914} 1900}
1915 1901
1916#ifdef CONFIG_UGETH_TX_ON_DEMOND 1902#ifdef CONFIG_UGETH_TX_ON_DEMOND
1917static int ugeth_transmit_on_demand(ucc_geth_private_t *ugeth) 1903static int ugeth_transmit_on_demand(struct ucc_geth_private *ugeth)
1918{ 1904{
1919 ucc_fast_transmit_on_demand(ugeth->uccf); 1905 struct ucc_fastransmit_on_demand(ugeth->uccf);
1920 1906
1921 return 0; 1907 return 0;
1922} 1908}
1923#endif 1909#endif
1924 1910
1925static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth) 1911static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1926{ 1912{
1927 ucc_fast_private_t *uccf; 1913 struct ucc_fast_private *uccf;
1928 u32 cecr_subblock; 1914 u32 cecr_subblock;
1929 u32 temp; 1915 u32 temp;
1930 1916
@@ -1940,7 +1926,7 @@ static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth)
1940 cecr_subblock = 1926 cecr_subblock =
1941 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1927 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
1942 qe_issue_cmd(QE_GRACEFUL_STOP_TX, cecr_subblock, 1928 qe_issue_cmd(QE_GRACEFUL_STOP_TX, cecr_subblock,
1943 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 1929 QE_CR_PROTOCOL_ETHERNET, 0);
1944 1930
1945 /* Wait for command to complete */ 1931 /* Wait for command to complete */
1946 do { 1932 do {
@@ -1952,9 +1938,9 @@ static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth)
1952 return 0; 1938 return 0;
1953} 1939}
1954 1940
1955static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth) 1941static int ugeth_graceful_stop_rx(struct ucc_geth_private * ugeth)
1956{ 1942{
1957 ucc_fast_private_t *uccf; 1943 struct ucc_fast_private *uccf;
1958 u32 cecr_subblock; 1944 u32 cecr_subblock;
1959 u8 temp; 1945 u8 temp;
1960 1946
@@ -1973,7 +1959,7 @@ static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth)
1973 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info. 1959 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.
1974 ucc_num); 1960 ucc_num);
1975 qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock, 1961 qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock,
1976 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 1962 QE_CR_PROTOCOL_ETHERNET, 0);
1977 1963
1978 temp = ugeth->p_rx_glbl_pram->rxgstpack; 1964 temp = ugeth->p_rx_glbl_pram->rxgstpack;
1979 } while (!(temp & GRACEFUL_STOP_ACKNOWLEDGE_RX)); 1965 } while (!(temp & GRACEFUL_STOP_ACKNOWLEDGE_RX));
@@ -1983,41 +1969,40 @@ static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth)
1983 return 0; 1969 return 0;
1984} 1970}
1985 1971
1986static int ugeth_restart_tx(ucc_geth_private_t *ugeth) 1972static int ugeth_restart_tx(struct ucc_geth_private *ugeth)
1987{ 1973{
1988 ucc_fast_private_t *uccf; 1974 struct ucc_fast_private *uccf;
1989 u32 cecr_subblock; 1975 u32 cecr_subblock;
1990 1976
1991 uccf = ugeth->uccf; 1977 uccf = ugeth->uccf;
1992 1978
1993 cecr_subblock = 1979 cecr_subblock =
1994 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1980 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
1995 qe_issue_cmd(QE_RESTART_TX, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 1981 qe_issue_cmd(QE_RESTART_TX, cecr_subblock, QE_CR_PROTOCOL_ETHERNET, 0);
1996 0);
1997 uccf->stopped_tx = 0; 1982 uccf->stopped_tx = 0;
1998 1983
1999 return 0; 1984 return 0;
2000} 1985}
2001 1986
2002static int ugeth_restart_rx(ucc_geth_private_t *ugeth) 1987static int ugeth_restart_rx(struct ucc_geth_private *ugeth)
2003{ 1988{
2004 ucc_fast_private_t *uccf; 1989 struct ucc_fast_private *uccf;
2005 u32 cecr_subblock; 1990 u32 cecr_subblock;
2006 1991
2007 uccf = ugeth->uccf; 1992 uccf = ugeth->uccf;
2008 1993
2009 cecr_subblock = 1994 cecr_subblock =
2010 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1995 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
2011 qe_issue_cmd(QE_RESTART_RX, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 1996 qe_issue_cmd(QE_RESTART_RX, cecr_subblock, QE_CR_PROTOCOL_ETHERNET,
2012 0); 1997 0);
2013 uccf->stopped_rx = 0; 1998 uccf->stopped_rx = 0;
2014 1999
2015 return 0; 2000 return 0;
2016} 2001}
2017 2002
2018static int ugeth_enable(ucc_geth_private_t *ugeth, comm_dir_e mode) 2003static int ugeth_enable(struct ucc_geth_private *ugeth, enum comm_dir mode)
2019{ 2004{
2020 ucc_fast_private_t *uccf; 2005 struct ucc_fast_private *uccf;
2021 int enabled_tx, enabled_rx; 2006 int enabled_tx, enabled_rx;
2022 2007
2023 uccf = ugeth->uccf; 2008 uccf = ugeth->uccf;
@@ -2044,9 +2029,9 @@ static int ugeth_enable(ucc_geth_private_t *ugeth, comm_dir_e mode)
2044 2029
2045} 2030}
2046 2031
2047static int ugeth_disable(ucc_geth_private_t * ugeth, comm_dir_e mode) 2032static int ugeth_disable(struct ucc_geth_private * ugeth, enum comm_dir mode)
2048{ 2033{
2049 ucc_fast_private_t *uccf; 2034 struct ucc_fast_private *uccf;
2050 2035
2051 uccf = ugeth->uccf; 2036 uccf = ugeth->uccf;
2052 2037
@@ -2069,7 +2054,7 @@ static int ugeth_disable(ucc_geth_private_t * ugeth, comm_dir_e mode)
2069 return 0; 2054 return 0;
2070} 2055}
2071 2056
2072static void ugeth_dump_regs(ucc_geth_private_t *ugeth) 2057static void ugeth_dump_regs(struct ucc_geth_private *ugeth)
2073{ 2058{
2074#ifdef DEBUG 2059#ifdef DEBUG
2075 ucc_fast_dump_regs(ugeth->uccf); 2060 ucc_fast_dump_regs(ugeth->uccf);
@@ -2079,9 +2064,9 @@ static void ugeth_dump_regs(ucc_geth_private_t *ugeth)
2079} 2064}
2080 2065
2081#ifdef CONFIG_UGETH_FILTERING 2066#ifdef CONFIG_UGETH_FILTERING
2082static int ugeth_ext_filtering_serialize_tad(ucc_geth_tad_params_t * 2067static int ugeth_ext_filtering_serialize_tad(struct ucc_geth_tad_params *
2083 p_UccGethTadParams, 2068 p_UccGethTadParams,
2084 qe_fltr_tad_t *qe_fltr_tad) 2069 struct qe_fltr_tad *qe_fltr_tad)
2085{ 2070{
2086 u16 temp; 2071 u16 temp;
2087 2072
@@ -2119,11 +2104,11 @@ static int ugeth_ext_filtering_serialize_tad(ucc_geth_tad_params_t *
2119 return 0; 2104 return 0;
2120} 2105}
2121 2106
2122static enet_addr_container_t 2107static struct enet_addr_container_t
2123 *ugeth_82xx_filtering_get_match_addr_in_hash(ucc_geth_private_t *ugeth, 2108 *ugeth_82xx_filtering_get_match_addr_in_hash(struct ucc_geth_private *ugeth,
2124 enet_addr_t *p_enet_addr) 2109 struct enet_addr *p_enet_addr)
2125{ 2110{
2126 enet_addr_container_t *enet_addr_cont; 2111 struct enet_addr_container *enet_addr_cont;
2127 struct list_head *p_lh; 2112 struct list_head *p_lh;
2128 u16 i, num; 2113 u16 i, num;
2129 int32_t j; 2114 int32_t j;
@@ -2144,7 +2129,7 @@ static enet_addr_container_t
2144 2129
2145 for (i = 0; i < num; i++) { 2130 for (i = 0; i < num; i++) {
2146 enet_addr_cont = 2131 enet_addr_cont =
2147 (enet_addr_container_t *) 2132 (struct enet_addr_container *)
2148 ENET_ADDR_CONT_ENTRY(dequeue(p_lh)); 2133 ENET_ADDR_CONT_ENTRY(dequeue(p_lh));
2149 for (j = ENET_NUM_OCTETS_PER_ADDRESS - 1; j >= 0; j--) { 2134 for (j = ENET_NUM_OCTETS_PER_ADDRESS - 1; j >= 0; j--) {
2150 if ((*p_enet_addr)[j] != (enet_addr_cont->address)[j]) 2135 if ((*p_enet_addr)[j] != (enet_addr_cont->address)[j])
@@ -2157,11 +2142,11 @@ static enet_addr_container_t
2157 return NULL; 2142 return NULL;
2158} 2143}
2159 2144
2160static int ugeth_82xx_filtering_add_addr_in_hash(ucc_geth_private_t *ugeth, 2145static int ugeth_82xx_filtering_add_addr_in_hash(struct ucc_geth_private *ugeth,
2161 enet_addr_t *p_enet_addr) 2146 struct enet_addr *p_enet_addr)
2162{ 2147{
2163 ucc_geth_enet_address_recognition_location_e location; 2148 enum ucc_geth_enet_address_recognition_location location;
2164 enet_addr_container_t *enet_addr_cont; 2149 struct enet_addr_container *enet_addr_cont;
2165 struct list_head *p_lh; 2150 struct list_head *p_lh;
2166 u8 i; 2151 u8 i;
2167 u32 limit; 2152 u32 limit;
@@ -2196,18 +2181,17 @@ static int ugeth_82xx_filtering_add_addr_in_hash(ucc_geth_private_t *ugeth,
2196 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ 2181 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */
2197 ++(*p_counter); 2182 ++(*p_counter);
2198 2183
2199 hw_add_addr_in_hash(ugeth, &(enet_addr_cont->address)); 2184 hw_add_addr_in_hash(ugeth, enet_addr_cont->address);
2200
2201 return 0; 2185 return 0;
2202} 2186}
2203 2187
2204static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth, 2188static int ugeth_82xx_filtering_clear_addr_in_hash(struct ucc_geth_private *ugeth,
2205 enet_addr_t *p_enet_addr) 2189 struct enet_addr *p_enet_addr)
2206{ 2190{
2207 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2191 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2208 enet_addr_container_t *enet_addr_cont; 2192 struct enet_addr_container *enet_addr_cont;
2209 ucc_fast_private_t *uccf; 2193 struct ucc_fast_private *uccf;
2210 comm_dir_e comm_dir; 2194 enum comm_dir comm_dir;
2211 u16 i, num; 2195 u16 i, num;
2212 struct list_head *p_lh; 2196 struct list_head *p_lh;
2213 u32 *addr_h, *addr_l; 2197 u32 *addr_h, *addr_l;
@@ -2216,7 +2200,7 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2216 uccf = ugeth->uccf; 2200 uccf = ugeth->uccf;
2217 2201
2218 p_82xx_addr_filt = 2202 p_82xx_addr_filt =
2219 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 2203 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
2220 addressfiltering; 2204 addressfiltering;
2221 2205
2222 if (! 2206 if (!
@@ -2256,9 +2240,9 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2256 num = --(*p_counter); 2240 num = --(*p_counter);
2257 for (i = 0; i < num; i++) { 2241 for (i = 0; i < num; i++) {
2258 enet_addr_cont = 2242 enet_addr_cont =
2259 (enet_addr_container_t *) 2243 (struct enet_addr_container *)
2260 ENET_ADDR_CONT_ENTRY(dequeue(p_lh)); 2244 ENET_ADDR_CONT_ENTRY(dequeue(p_lh));
2261 hw_add_addr_in_hash(ugeth, &(enet_addr_cont->address)); 2245 hw_add_addr_in_hash(ugeth, enet_addr_cont->address);
2262 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ 2246 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */
2263 } 2247 }
2264 2248
@@ -2269,14 +2253,14 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2269} 2253}
2270#endif /* CONFIG_UGETH_FILTERING */ 2254#endif /* CONFIG_UGETH_FILTERING */
2271 2255
2272static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t * 2256static int ugeth_82xx_filtering_clear_all_addr_in_hash(struct ucc_geth_private *
2273 ugeth, 2257 ugeth,
2274 enet_addr_type_e 2258 enum enet_addr_type
2275 enet_addr_type) 2259 enet_addr_type)
2276{ 2260{
2277 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2261 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2278 ucc_fast_private_t *uccf; 2262 struct ucc_fast_private *uccf;
2279 comm_dir_e comm_dir; 2263 enum comm_dir comm_dir;
2280 struct list_head *p_lh; 2264 struct list_head *p_lh;
2281 u16 i, num; 2265 u16 i, num;
2282 u32 *addr_h, *addr_l; 2266 u32 *addr_h, *addr_l;
@@ -2285,7 +2269,7 @@ static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t *
2285 uccf = ugeth->uccf; 2269 uccf = ugeth->uccf;
2286 2270
2287 p_82xx_addr_filt = 2271 p_82xx_addr_filt =
2288 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 2272 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
2289 addressfiltering; 2273 addressfiltering;
2290 2274
2291 if (enet_addr_type == ENET_ADDR_TYPE_GROUP) { 2275 if (enet_addr_type == ENET_ADDR_TYPE_GROUP) {
@@ -2331,8 +2315,8 @@ static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t *
2331} 2315}
2332 2316
2333#ifdef CONFIG_UGETH_FILTERING 2317#ifdef CONFIG_UGETH_FILTERING
2334static int ugeth_82xx_filtering_add_addr_in_paddr(ucc_geth_private_t *ugeth, 2318static int ugeth_82xx_filtering_add_addr_in_paddr(struct ucc_geth_private *ugeth,
2335 enet_addr_t *p_enet_addr, 2319 struct enet_addr *p_enet_addr,
2336 u8 paddr_num) 2320 u8 paddr_num)
2337{ 2321{
2338 int i; 2322 int i;
@@ -2352,14 +2336,14 @@ static int ugeth_82xx_filtering_add_addr_in_paddr(ucc_geth_private_t *ugeth,
2352} 2336}
2353#endif /* CONFIG_UGETH_FILTERING */ 2337#endif /* CONFIG_UGETH_FILTERING */
2354 2338
2355static int ugeth_82xx_filtering_clear_addr_in_paddr(ucc_geth_private_t *ugeth, 2339static int ugeth_82xx_filtering_clear_addr_in_paddr(struct ucc_geth_private *ugeth,
2356 u8 paddr_num) 2340 u8 paddr_num)
2357{ 2341{
2358 ugeth->indAddrRegUsed[paddr_num] = 0; /* mark this paddr as not used */ 2342 ugeth->indAddrRegUsed[paddr_num] = 0; /* mark this paddr as not used */
2359 return hw_clear_addr_in_paddr(ugeth, paddr_num);/* clear in hardware */ 2343 return hw_clear_addr_in_paddr(ugeth, paddr_num);/* clear in hardware */
2360} 2344}
2361 2345
2362static void ucc_geth_memclean(ucc_geth_private_t *ugeth) 2346static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
2363{ 2347{
2364 u16 i, j; 2348 u16 i, j;
2365 u8 *bd; 2349 u8 *bd;
@@ -2433,8 +2417,8 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2433 for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) { 2417 for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) {
2434 if (ugeth->tx_skbuff[i][j]) { 2418 if (ugeth->tx_skbuff[i][j]) {
2435 dma_unmap_single(NULL, 2419 dma_unmap_single(NULL,
2436 BD_BUFFER_ARG(bd), 2420 ((qe_bd_t *)bd)->buf,
2437 (BD_STATUS_AND_LENGTH(bd) & 2421 (in_be32((u32 *)bd) &
2438 BD_LENGTH_MASK), 2422 BD_LENGTH_MASK),
2439 DMA_TO_DEVICE); 2423 DMA_TO_DEVICE);
2440 dev_kfree_skb_any(ugeth->tx_skbuff[i][j]); 2424 dev_kfree_skb_any(ugeth->tx_skbuff[i][j]);
@@ -2460,18 +2444,17 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2460 bd = ugeth->p_rx_bd_ring[i]; 2444 bd = ugeth->p_rx_bd_ring[i];
2461 for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) { 2445 for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) {
2462 if (ugeth->rx_skbuff[i][j]) { 2446 if (ugeth->rx_skbuff[i][j]) {
2463 dma_unmap_single(NULL, BD_BUFFER(bd), 2447 dma_unmap_single(NULL,
2464 ugeth->ug_info-> 2448 ((struct qe_bd *)bd)->buf,
2465 uf_info. 2449 ugeth->ug_info->
2466 max_rx_buf_length + 2450 uf_info.max_rx_buf_length +
2467 UCC_GETH_RX_DATA_BUF_ALIGNMENT, 2451 UCC_GETH_RX_DATA_BUF_ALIGNMENT,
2468 DMA_FROM_DEVICE); 2452 DMA_FROM_DEVICE);
2469 2453 dev_kfree_skb_any(
2470 dev_kfree_skb_any(ugeth-> 2454 ugeth->rx_skbuff[i][j]);
2471 rx_skbuff[i][j]);
2472 ugeth->rx_skbuff[i][j] = NULL; 2455 ugeth->rx_skbuff[i][j] = NULL;
2473 } 2456 }
2474 bd += UCC_GETH_SIZE_OF_BD; 2457 bd += sizeof(struct qe_bd);
2475 } 2458 }
2476 2459
2477 kfree(ugeth->rx_skbuff[i]); 2460 kfree(ugeth->rx_skbuff[i]);
@@ -2496,11 +2479,11 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2496 2479
2497static void ucc_geth_set_multi(struct net_device *dev) 2480static void ucc_geth_set_multi(struct net_device *dev)
2498{ 2481{
2499 ucc_geth_private_t *ugeth; 2482 struct ucc_geth_private *ugeth;
2500 struct dev_mc_list *dmi; 2483 struct dev_mc_list *dmi;
2501 ucc_fast_t *uf_regs; 2484 struct ucc_fast *uf_regs;
2502 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2485 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2503 enet_addr_t tempaddr; 2486 u8 tempaddr[6];
2504 u8 *mcptr, *tdptr; 2487 u8 *mcptr, *tdptr;
2505 int i, j; 2488 int i, j;
2506 2489
@@ -2517,7 +2500,7 @@ static void ucc_geth_set_multi(struct net_device *dev)
2517 uf_regs->upsmr &= ~UPSMR_PRO; 2500 uf_regs->upsmr &= ~UPSMR_PRO;
2518 2501
2519 p_82xx_addr_filt = 2502 p_82xx_addr_filt =
2520 (ucc_geth_82xx_address_filtering_pram_t *) ugeth-> 2503 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->
2521 p_rx_glbl_pram->addressfiltering; 2504 p_rx_glbl_pram->addressfiltering;
2522 2505
2523 if (dev->flags & IFF_ALLMULTI) { 2506 if (dev->flags & IFF_ALLMULTI) {
@@ -2546,23 +2529,22 @@ static void ucc_geth_set_multi(struct net_device *dev)
2546 * copy bytes MSB first from dmi_addr. 2529 * copy bytes MSB first from dmi_addr.
2547 */ 2530 */
2548 mcptr = (u8 *) dmi->dmi_addr + 5; 2531 mcptr = (u8 *) dmi->dmi_addr + 5;
2549 tdptr = (u8 *) & tempaddr; 2532 tdptr = (u8 *) tempaddr;
2550 for (j = 0; j < 6; j++) 2533 for (j = 0; j < 6; j++)
2551 *tdptr++ = *mcptr--; 2534 *tdptr++ = *mcptr--;
2552 2535
2553 /* Ask CPM to run CRC and set bit in 2536 /* Ask CPM to run CRC and set bit in
2554 * filter mask. 2537 * filter mask.
2555 */ 2538 */
2556 hw_add_addr_in_hash(ugeth, &tempaddr); 2539 hw_add_addr_in_hash(ugeth, tempaddr);
2557
2558 } 2540 }
2559 } 2541 }
2560 } 2542 }
2561} 2543}
2562 2544
2563static void ucc_geth_stop(ucc_geth_private_t *ugeth) 2545static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2564{ 2546{
2565 ucc_geth_t *ug_regs = ugeth->ug_regs; 2547 struct ucc_geth *ug_regs = ugeth->ug_regs;
2566 u32 tempval; 2548 u32 tempval;
2567 2549
2568 ugeth_vdbg("%s: IN", __FUNCTION__); 2550 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -2605,15 +2587,15 @@ static void ucc_geth_stop(ucc_geth_private_t *ugeth)
2605 ucc_geth_memclean(ugeth); 2587 ucc_geth_memclean(ugeth);
2606} 2588}
2607 2589
2608static int ucc_geth_startup(ucc_geth_private_t *ugeth) 2590static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2609{ 2591{
2610 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2592 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2611 ucc_geth_init_pram_t *p_init_enet_pram; 2593 struct ucc_geth_init_pram *p_init_enet_pram;
2612 ucc_fast_private_t *uccf; 2594 struct ucc_fast_private *uccf;
2613 ucc_geth_info_t *ug_info; 2595 struct ucc_geth_info *ug_info;
2614 ucc_fast_info_t *uf_info; 2596 struct ucc_fast_info *uf_info;
2615 ucc_fast_t *uf_regs; 2597 struct ucc_fast *uf_regs;
2616 ucc_geth_t *ug_regs; 2598 struct ucc_geth *ug_regs;
2617 int ret_val = -EINVAL; 2599 int ret_val = -EINVAL;
2618 u32 remoder = UCC_GETH_REMODER_INIT; 2600 u32 remoder = UCC_GETH_REMODER_INIT;
2619 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1; 2601 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1;
@@ -2788,7 +2770,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2788 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP); 2770 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP);
2789 2771
2790 uf_regs = uccf->uf_regs; 2772 uf_regs = uccf->uf_regs;
2791 ug_regs = (ucc_geth_t *) (uccf->uf_regs); 2773 ug_regs = (struct ucc_geth *) (uccf->uf_regs);
2792 ugeth->ug_regs = ug_regs; 2774 ugeth->ug_regs = ug_regs;
2793 2775
2794 init_default_reg_vals(&uf_regs->upsmr, 2776 init_default_reg_vals(&uf_regs->upsmr,
@@ -2869,10 +2851,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2869 /* Allocate in multiple of 2851 /* Allocate in multiple of
2870 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT, 2852 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT,
2871 according to spec */ 2853 according to spec */
2872 length = ((ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD) 2854 length = ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd))
2873 / UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) 2855 / UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT)
2874 * UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; 2856 * UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT;
2875 if ((ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD) % 2857 if ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)) %
2876 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) 2858 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT)
2877 length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; 2859 length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT;
2878 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { 2860 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {
@@ -2904,13 +2886,13 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2904 } 2886 }
2905 /* Zero unused end of bd ring, according to spec */ 2887 /* Zero unused end of bd ring, according to spec */
2906 memset(ugeth->p_tx_bd_ring[j] + 2888 memset(ugeth->p_tx_bd_ring[j] +
2907 ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD, 0, 2889 ug_info->bdRingLenTx[j] * sizeof(struct qe_bd), 0,
2908 length - ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD); 2890 length - ug_info->bdRingLenTx[j] * sizeof(struct qe_bd));
2909 } 2891 }
2910 2892
2911 /* Allocate Rx bds */ 2893 /* Allocate Rx bds */
2912 for (j = 0; j < ug_info->numQueuesRx; j++) { 2894 for (j = 0; j < ug_info->numQueuesRx; j++) {
2913 length = ug_info->bdRingLenRx[j] * UCC_GETH_SIZE_OF_BD; 2895 length = ug_info->bdRingLenRx[j] * sizeof(struct qe_bd);
2914 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { 2896 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {
2915 u32 align = 4; 2897 u32 align = 4;
2916 if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4) 2898 if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)
@@ -2960,12 +2942,15 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2960 ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0; 2942 ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0;
2961 bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j]; 2943 bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j];
2962 for (i = 0; i < ug_info->bdRingLenTx[j]; i++) { 2944 for (i = 0; i < ug_info->bdRingLenTx[j]; i++) {
2963 BD_BUFFER_CLEAR(bd); 2945 /* clear bd buffer */
2964 BD_STATUS_AND_LENGTH_SET(bd, 0); 2946 out_be32(&((struct qe_bd *)bd)->buf, 0);
2965 bd += UCC_GETH_SIZE_OF_BD; 2947 /* set bd status and length */
2948 out_be32((u32 *)bd, 0);
2949 bd += sizeof(struct qe_bd);
2966 } 2950 }
2967 bd -= UCC_GETH_SIZE_OF_BD; 2951 bd -= sizeof(struct qe_bd);
2968 BD_STATUS_AND_LENGTH_SET(bd, T_W);/* for last BD set Wrap bit */ 2952 /* set bd status and length */
2953 out_be32((u32 *)bd, T_W); /* for last BD set Wrap bit */
2969 } 2954 }
2970 2955
2971 /* Init Rx bds */ 2956 /* Init Rx bds */
@@ -2989,12 +2974,15 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2989 ugeth->skb_currx[j] = 0; 2974 ugeth->skb_currx[j] = 0;
2990 bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j]; 2975 bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j];
2991 for (i = 0; i < ug_info->bdRingLenRx[j]; i++) { 2976 for (i = 0; i < ug_info->bdRingLenRx[j]; i++) {
2992 BD_STATUS_AND_LENGTH_SET(bd, R_I); 2977 /* set bd status and length */
2993 BD_BUFFER_CLEAR(bd); 2978 out_be32((u32 *)bd, R_I);
2994 bd += UCC_GETH_SIZE_OF_BD; 2979 /* clear bd buffer */
2980 out_be32(&((struct qe_bd *)bd)->buf, 0);
2981 bd += sizeof(struct qe_bd);
2995 } 2982 }
2996 bd -= UCC_GETH_SIZE_OF_BD; 2983 bd -= sizeof(struct qe_bd);
2997 BD_STATUS_AND_LENGTH_SET(bd, R_W);/* for last BD set Wrap bit */ 2984 /* set bd status and length */
2985 out_be32((u32 *)bd, R_W); /* for last BD set Wrap bit */
2998 } 2986 }
2999 2987
3000 /* 2988 /*
@@ -3003,7 +2991,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3003 /* Tx global PRAM */ 2991 /* Tx global PRAM */
3004 /* Allocate global tx parameter RAM page */ 2992 /* Allocate global tx parameter RAM page */
3005 ugeth->tx_glbl_pram_offset = 2993 ugeth->tx_glbl_pram_offset =
3006 qe_muram_alloc(sizeof(ucc_geth_tx_global_pram_t), 2994 qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram),
3007 UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT); 2995 UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT);
3008 if (IS_MURAM_ERR(ugeth->tx_glbl_pram_offset)) { 2996 if (IS_MURAM_ERR(ugeth->tx_glbl_pram_offset)) {
3009 ugeth_err 2997 ugeth_err
@@ -3013,10 +3001,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3013 return -ENOMEM; 3001 return -ENOMEM;
3014 } 3002 }
3015 ugeth->p_tx_glbl_pram = 3003 ugeth->p_tx_glbl_pram =
3016 (ucc_geth_tx_global_pram_t *) qe_muram_addr(ugeth-> 3004 (struct ucc_geth_tx_global_pram *) qe_muram_addr(ugeth->
3017 tx_glbl_pram_offset); 3005 tx_glbl_pram_offset);
3018 /* Zero out p_tx_glbl_pram */ 3006 /* Zero out p_tx_glbl_pram */
3019 memset(ugeth->p_tx_glbl_pram, 0, sizeof(ucc_geth_tx_global_pram_t)); 3007 memset(ugeth->p_tx_glbl_pram, 0, sizeof(struct ucc_geth_tx_global_pram));
3020 3008
3021 /* Fill global PRAM */ 3009 /* Fill global PRAM */
3022 3010
@@ -3024,7 +3012,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3024 /* Size varies with number of Tx threads */ 3012 /* Size varies with number of Tx threads */
3025 ugeth->thread_dat_tx_offset = 3013 ugeth->thread_dat_tx_offset =
3026 qe_muram_alloc(numThreadsTxNumerical * 3014 qe_muram_alloc(numThreadsTxNumerical *
3027 sizeof(ucc_geth_thread_data_tx_t) + 3015 sizeof(struct ucc_geth_thread_data_tx) +
3028 32 * (numThreadsTxNumerical == 1), 3016 32 * (numThreadsTxNumerical == 1),
3029 UCC_GETH_THREAD_DATA_ALIGNMENT); 3017 UCC_GETH_THREAD_DATA_ALIGNMENT);
3030 if (IS_MURAM_ERR(ugeth->thread_dat_tx_offset)) { 3018 if (IS_MURAM_ERR(ugeth->thread_dat_tx_offset)) {
@@ -3036,7 +3024,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3036 } 3024 }
3037 3025
3038 ugeth->p_thread_data_tx = 3026 ugeth->p_thread_data_tx =
3039 (ucc_geth_thread_data_tx_t *) qe_muram_addr(ugeth-> 3027 (struct ucc_geth_thread_data_tx *) qe_muram_addr(ugeth->
3040 thread_dat_tx_offset); 3028 thread_dat_tx_offset);
3041 out_be32(&ugeth->p_tx_glbl_pram->tqptr, ugeth->thread_dat_tx_offset); 3029 out_be32(&ugeth->p_tx_glbl_pram->tqptr, ugeth->thread_dat_tx_offset);
3042 3030
@@ -3053,7 +3041,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3053 /* Size varies with number of Tx queues */ 3041 /* Size varies with number of Tx queues */
3054 ugeth->send_q_mem_reg_offset = 3042 ugeth->send_q_mem_reg_offset =
3055 qe_muram_alloc(ug_info->numQueuesTx * 3043 qe_muram_alloc(ug_info->numQueuesTx *
3056 sizeof(ucc_geth_send_queue_qd_t), 3044 sizeof(struct ucc_geth_send_queue_qd),
3057 UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT); 3045 UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT);
3058 if (IS_MURAM_ERR(ugeth->send_q_mem_reg_offset)) { 3046 if (IS_MURAM_ERR(ugeth->send_q_mem_reg_offset)) {
3059 ugeth_err 3047 ugeth_err
@@ -3064,7 +3052,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3064 } 3052 }
3065 3053
3066 ugeth->p_send_q_mem_reg = 3054 ugeth->p_send_q_mem_reg =
3067 (ucc_geth_send_queue_mem_region_t *) qe_muram_addr(ugeth-> 3055 (struct ucc_geth_send_queue_mem_region *) qe_muram_addr(ugeth->
3068 send_q_mem_reg_offset); 3056 send_q_mem_reg_offset);
3069 out_be32(&ugeth->p_tx_glbl_pram->sqptr, ugeth->send_q_mem_reg_offset); 3057 out_be32(&ugeth->p_tx_glbl_pram->sqptr, ugeth->send_q_mem_reg_offset);
3070 3058
@@ -3073,7 +3061,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3073 for (i = 0; i < ug_info->numQueuesTx; i++) { 3061 for (i = 0; i < ug_info->numQueuesTx; i++) {
3074 endOfRing = 3062 endOfRing =
3075 ugeth->p_tx_bd_ring[i] + (ug_info->bdRingLenTx[i] - 3063 ugeth->p_tx_bd_ring[i] + (ug_info->bdRingLenTx[i] -
3076 1) * UCC_GETH_SIZE_OF_BD; 3064 1) * sizeof(struct qe_bd);
3077 if (ugeth->ug_info->uf_info.bd_mem_part == MEM_PART_SYSTEM) { 3065 if (ugeth->ug_info->uf_info.bd_mem_part == MEM_PART_SYSTEM) {
3078 out_be32(&ugeth->p_send_q_mem_reg->sqqd[i].bd_ring_base, 3066 out_be32(&ugeth->p_send_q_mem_reg->sqqd[i].bd_ring_base,
3079 (u32) virt_to_phys(ugeth->p_tx_bd_ring[i])); 3067 (u32) virt_to_phys(ugeth->p_tx_bd_ring[i]));
@@ -3096,7 +3084,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3096 if (ug_info->numQueuesTx > 1) { 3084 if (ug_info->numQueuesTx > 1) {
3097 /* scheduler exists only if more than 1 tx queue */ 3085 /* scheduler exists only if more than 1 tx queue */
3098 ugeth->scheduler_offset = 3086 ugeth->scheduler_offset =
3099 qe_muram_alloc(sizeof(ucc_geth_scheduler_t), 3087 qe_muram_alloc(sizeof(struct ucc_geth_scheduler),
3100 UCC_GETH_SCHEDULER_ALIGNMENT); 3088 UCC_GETH_SCHEDULER_ALIGNMENT);
3101 if (IS_MURAM_ERR(ugeth->scheduler_offset)) { 3089 if (IS_MURAM_ERR(ugeth->scheduler_offset)) {
3102 ugeth_err 3090 ugeth_err
@@ -3107,12 +3095,12 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3107 } 3095 }
3108 3096
3109 ugeth->p_scheduler = 3097 ugeth->p_scheduler =
3110 (ucc_geth_scheduler_t *) qe_muram_addr(ugeth-> 3098 (struct ucc_geth_scheduler *) qe_muram_addr(ugeth->
3111 scheduler_offset); 3099 scheduler_offset);
3112 out_be32(&ugeth->p_tx_glbl_pram->schedulerbasepointer, 3100 out_be32(&ugeth->p_tx_glbl_pram->schedulerbasepointer,
3113 ugeth->scheduler_offset); 3101 ugeth->scheduler_offset);
3114 /* Zero out p_scheduler */ 3102 /* Zero out p_scheduler */
3115 memset(ugeth->p_scheduler, 0, sizeof(ucc_geth_scheduler_t)); 3103 memset(ugeth->p_scheduler, 0, sizeof(struct ucc_geth_scheduler));
3116 3104
3117 /* Set values in scheduler */ 3105 /* Set values in scheduler */
3118 out_be32(&ugeth->p_scheduler->mblinterval, 3106 out_be32(&ugeth->p_scheduler->mblinterval,
@@ -3144,7 +3132,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3144 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) { 3132 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) {
3145 ugeth->tx_fw_statistics_pram_offset = 3133 ugeth->tx_fw_statistics_pram_offset =
3146 qe_muram_alloc(sizeof 3134 qe_muram_alloc(sizeof
3147 (ucc_geth_tx_firmware_statistics_pram_t), 3135 (struct ucc_geth_tx_firmware_statistics_pram),
3148 UCC_GETH_TX_STATISTICS_ALIGNMENT); 3136 UCC_GETH_TX_STATISTICS_ALIGNMENT);
3149 if (IS_MURAM_ERR(ugeth->tx_fw_statistics_pram_offset)) { 3137 if (IS_MURAM_ERR(ugeth->tx_fw_statistics_pram_offset)) {
3150 ugeth_err 3138 ugeth_err
@@ -3154,11 +3142,11 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3154 return -ENOMEM; 3142 return -ENOMEM;
3155 } 3143 }
3156 ugeth->p_tx_fw_statistics_pram = 3144 ugeth->p_tx_fw_statistics_pram =
3157 (ucc_geth_tx_firmware_statistics_pram_t *) 3145 (struct ucc_geth_tx_firmware_statistics_pram *)
3158 qe_muram_addr(ugeth->tx_fw_statistics_pram_offset); 3146 qe_muram_addr(ugeth->tx_fw_statistics_pram_offset);
3159 /* Zero out p_tx_fw_statistics_pram */ 3147 /* Zero out p_tx_fw_statistics_pram */
3160 memset(ugeth->p_tx_fw_statistics_pram, 3148 memset(ugeth->p_tx_fw_statistics_pram,
3161 0, sizeof(ucc_geth_tx_firmware_statistics_pram_t)); 3149 0, sizeof(struct ucc_geth_tx_firmware_statistics_pram));
3162 } 3150 }
3163 3151
3164 /* temoder */ 3152 /* temoder */
@@ -3183,7 +3171,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3183 /* Rx global PRAM */ 3171 /* Rx global PRAM */
3184 /* Allocate global rx parameter RAM page */ 3172 /* Allocate global rx parameter RAM page */
3185 ugeth->rx_glbl_pram_offset = 3173 ugeth->rx_glbl_pram_offset =
3186 qe_muram_alloc(sizeof(ucc_geth_rx_global_pram_t), 3174 qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram),
3187 UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT); 3175 UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT);
3188 if (IS_MURAM_ERR(ugeth->rx_glbl_pram_offset)) { 3176 if (IS_MURAM_ERR(ugeth->rx_glbl_pram_offset)) {
3189 ugeth_err 3177 ugeth_err
@@ -3193,10 +3181,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3193 return -ENOMEM; 3181 return -ENOMEM;
3194 } 3182 }
3195 ugeth->p_rx_glbl_pram = 3183 ugeth->p_rx_glbl_pram =
3196 (ucc_geth_rx_global_pram_t *) qe_muram_addr(ugeth-> 3184 (struct ucc_geth_rx_global_pram *) qe_muram_addr(ugeth->
3197 rx_glbl_pram_offset); 3185 rx_glbl_pram_offset);
3198 /* Zero out p_rx_glbl_pram */ 3186 /* Zero out p_rx_glbl_pram */
3199 memset(ugeth->p_rx_glbl_pram, 0, sizeof(ucc_geth_rx_global_pram_t)); 3187 memset(ugeth->p_rx_glbl_pram, 0, sizeof(struct ucc_geth_rx_global_pram));
3200 3188
3201 /* Fill global PRAM */ 3189 /* Fill global PRAM */
3202 3190
@@ -3204,7 +3192,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3204 /* Size varies with number of Rx threads */ 3192 /* Size varies with number of Rx threads */
3205 ugeth->thread_dat_rx_offset = 3193 ugeth->thread_dat_rx_offset =
3206 qe_muram_alloc(numThreadsRxNumerical * 3194 qe_muram_alloc(numThreadsRxNumerical *
3207 sizeof(ucc_geth_thread_data_rx_t), 3195 sizeof(struct ucc_geth_thread_data_rx),
3208 UCC_GETH_THREAD_DATA_ALIGNMENT); 3196 UCC_GETH_THREAD_DATA_ALIGNMENT);
3209 if (IS_MURAM_ERR(ugeth->thread_dat_rx_offset)) { 3197 if (IS_MURAM_ERR(ugeth->thread_dat_rx_offset)) {
3210 ugeth_err 3198 ugeth_err
@@ -3215,7 +3203,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3215 } 3203 }
3216 3204
3217 ugeth->p_thread_data_rx = 3205 ugeth->p_thread_data_rx =
3218 (ucc_geth_thread_data_rx_t *) qe_muram_addr(ugeth-> 3206 (struct ucc_geth_thread_data_rx *) qe_muram_addr(ugeth->
3219 thread_dat_rx_offset); 3207 thread_dat_rx_offset);
3220 out_be32(&ugeth->p_rx_glbl_pram->rqptr, ugeth->thread_dat_rx_offset); 3208 out_be32(&ugeth->p_rx_glbl_pram->rqptr, ugeth->thread_dat_rx_offset);
3221 3209
@@ -3227,7 +3215,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3227 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) { 3215 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) {
3228 ugeth->rx_fw_statistics_pram_offset = 3216 ugeth->rx_fw_statistics_pram_offset =
3229 qe_muram_alloc(sizeof 3217 qe_muram_alloc(sizeof
3230 (ucc_geth_rx_firmware_statistics_pram_t), 3218 (struct ucc_geth_rx_firmware_statistics_pram),
3231 UCC_GETH_RX_STATISTICS_ALIGNMENT); 3219 UCC_GETH_RX_STATISTICS_ALIGNMENT);
3232 if (IS_MURAM_ERR(ugeth->rx_fw_statistics_pram_offset)) { 3220 if (IS_MURAM_ERR(ugeth->rx_fw_statistics_pram_offset)) {
3233 ugeth_err 3221 ugeth_err
@@ -3237,11 +3225,11 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3237 return -ENOMEM; 3225 return -ENOMEM;
3238 } 3226 }
3239 ugeth->p_rx_fw_statistics_pram = 3227 ugeth->p_rx_fw_statistics_pram =
3240 (ucc_geth_rx_firmware_statistics_pram_t *) 3228 (struct ucc_geth_rx_firmware_statistics_pram *)
3241 qe_muram_addr(ugeth->rx_fw_statistics_pram_offset); 3229 qe_muram_addr(ugeth->rx_fw_statistics_pram_offset);
3242 /* Zero out p_rx_fw_statistics_pram */ 3230 /* Zero out p_rx_fw_statistics_pram */
3243 memset(ugeth->p_rx_fw_statistics_pram, 0, 3231 memset(ugeth->p_rx_fw_statistics_pram, 0,
3244 sizeof(ucc_geth_rx_firmware_statistics_pram_t)); 3232 sizeof(struct ucc_geth_rx_firmware_statistics_pram));
3245 } 3233 }
3246 3234
3247 /* intCoalescingPtr */ 3235 /* intCoalescingPtr */
@@ -3249,7 +3237,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3249 /* Size varies with number of Rx queues */ 3237 /* Size varies with number of Rx queues */
3250 ugeth->rx_irq_coalescing_tbl_offset = 3238 ugeth->rx_irq_coalescing_tbl_offset =
3251 qe_muram_alloc(ug_info->numQueuesRx * 3239 qe_muram_alloc(ug_info->numQueuesRx *
3252 sizeof(ucc_geth_rx_interrupt_coalescing_entry_t), 3240 sizeof(struct ucc_geth_rx_interrupt_coalescing_entry),
3253 UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT); 3241 UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT);
3254 if (IS_MURAM_ERR(ugeth->rx_irq_coalescing_tbl_offset)) { 3242 if (IS_MURAM_ERR(ugeth->rx_irq_coalescing_tbl_offset)) {
3255 ugeth_err 3243 ugeth_err
@@ -3260,7 +3248,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3260 } 3248 }
3261 3249
3262 ugeth->p_rx_irq_coalescing_tbl = 3250 ugeth->p_rx_irq_coalescing_tbl =
3263 (ucc_geth_rx_interrupt_coalescing_table_t *) 3251 (struct ucc_geth_rx_interrupt_coalescing_table *)
3264 qe_muram_addr(ugeth->rx_irq_coalescing_tbl_offset); 3252 qe_muram_addr(ugeth->rx_irq_coalescing_tbl_offset);
3265 out_be32(&ugeth->p_rx_glbl_pram->intcoalescingptr, 3253 out_be32(&ugeth->p_rx_glbl_pram->intcoalescingptr,
3266 ugeth->rx_irq_coalescing_tbl_offset); 3254 ugeth->rx_irq_coalescing_tbl_offset);
@@ -3300,7 +3288,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3300 l3qt = 0; 3288 l3qt = 0;
3301 for (i = 0; i < 8; i++) 3289 for (i = 0; i < 8; i++)
3302 l3qt |= (ug_info->l3qt[j + i] << (28 - 4 * i)); 3290 l3qt |= (ug_info->l3qt[j + i] << (28 - 4 * i));
3303 out_be32(&ugeth->p_rx_glbl_pram->l3qt[j], l3qt); 3291 out_be32(&ugeth->p_rx_glbl_pram->l3qt[j/8], l3qt);
3304 } 3292 }
3305 3293
3306 /* vlantype */ 3294 /* vlantype */
@@ -3316,8 +3304,8 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3316 /* Size varies with number of Rx queues */ 3304 /* Size varies with number of Rx queues */
3317 ugeth->rx_bd_qs_tbl_offset = 3305 ugeth->rx_bd_qs_tbl_offset =
3318 qe_muram_alloc(ug_info->numQueuesRx * 3306 qe_muram_alloc(ug_info->numQueuesRx *
3319 (sizeof(ucc_geth_rx_bd_queues_entry_t) + 3307 (sizeof(struct ucc_geth_rx_bd_queues_entry) +
3320 sizeof(ucc_geth_rx_prefetched_bds_t)), 3308 sizeof(struct ucc_geth_rx_prefetched_bds)),
3321 UCC_GETH_RX_BD_QUEUES_ALIGNMENT); 3309 UCC_GETH_RX_BD_QUEUES_ALIGNMENT);
3322 if (IS_MURAM_ERR(ugeth->rx_bd_qs_tbl_offset)) { 3310 if (IS_MURAM_ERR(ugeth->rx_bd_qs_tbl_offset)) {
3323 ugeth_err 3311 ugeth_err
@@ -3328,14 +3316,14 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3328 } 3316 }
3329 3317
3330 ugeth->p_rx_bd_qs_tbl = 3318 ugeth->p_rx_bd_qs_tbl =
3331 (ucc_geth_rx_bd_queues_entry_t *) qe_muram_addr(ugeth-> 3319 (struct ucc_geth_rx_bd_queues_entry *) qe_muram_addr(ugeth->
3332 rx_bd_qs_tbl_offset); 3320 rx_bd_qs_tbl_offset);
3333 out_be32(&ugeth->p_rx_glbl_pram->rbdqptr, ugeth->rx_bd_qs_tbl_offset); 3321 out_be32(&ugeth->p_rx_glbl_pram->rbdqptr, ugeth->rx_bd_qs_tbl_offset);
3334 /* Zero out p_rx_bd_qs_tbl */ 3322 /* Zero out p_rx_bd_qs_tbl */
3335 memset(ugeth->p_rx_bd_qs_tbl, 3323 memset(ugeth->p_rx_bd_qs_tbl,
3336 0, 3324 0,
3337 ug_info->numQueuesRx * (sizeof(ucc_geth_rx_bd_queues_entry_t) + 3325 ug_info->numQueuesRx * (sizeof(struct ucc_geth_rx_bd_queues_entry) +
3338 sizeof(ucc_geth_rx_prefetched_bds_t))); 3326 sizeof(struct ucc_geth_rx_prefetched_bds)));
3339 3327
3340 /* Setup the table */ 3328 /* Setup the table */
3341 /* Assume BD rings are already established */ 3329 /* Assume BD rings are already established */
@@ -3406,7 +3394,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3406 /* Allocate memory for extended filtering Mode Global 3394 /* Allocate memory for extended filtering Mode Global
3407 Parameters */ 3395 Parameters */
3408 ugeth->exf_glbl_param_offset = 3396 ugeth->exf_glbl_param_offset =
3409 qe_muram_alloc(sizeof(ucc_geth_exf_global_pram_t), 3397 qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram),
3410 UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT); 3398 UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT);
3411 if (IS_MURAM_ERR(ugeth->exf_glbl_param_offset)) { 3399 if (IS_MURAM_ERR(ugeth->exf_glbl_param_offset)) {
3412 ugeth_err 3400 ugeth_err
@@ -3417,7 +3405,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3417 } 3405 }
3418 3406
3419 ugeth->p_exf_glbl_param = 3407 ugeth->p_exf_glbl_param =
3420 (ucc_geth_exf_global_pram_t *) qe_muram_addr(ugeth-> 3408 (struct ucc_geth_exf_global_pram *) qe_muram_addr(ugeth->
3421 exf_glbl_param_offset); 3409 exf_glbl_param_offset);
3422 out_be32(&ugeth->p_rx_glbl_pram->exfGlobalParam, 3410 out_be32(&ugeth->p_rx_glbl_pram->exfGlobalParam,
3423 ugeth->exf_glbl_param_offset); 3411 ugeth->exf_glbl_param_offset);
@@ -3439,7 +3427,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3439 INIT_LIST_HEAD(&ugeth->ind_hash_q); 3427 INIT_LIST_HEAD(&ugeth->ind_hash_q);
3440 } 3428 }
3441 p_82xx_addr_filt = 3429 p_82xx_addr_filt =
3442 (ucc_geth_82xx_address_filtering_pram_t *) ugeth-> 3430 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->
3443 p_rx_glbl_pram->addressfiltering; 3431 p_rx_glbl_pram->addressfiltering;
3444 3432
3445 ugeth_82xx_filtering_clear_all_addr_in_hash(ugeth, 3433 ugeth_82xx_filtering_clear_all_addr_in_hash(ugeth,
@@ -3462,7 +3450,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3462 * allocated resources can be released when the channel is freed. 3450 * allocated resources can be released when the channel is freed.
3463 */ 3451 */
3464 if (!(ugeth->p_init_enet_param_shadow = 3452 if (!(ugeth->p_init_enet_param_shadow =
3465 (ucc_geth_init_pram_t *) kmalloc(sizeof(ucc_geth_init_pram_t), 3453 (struct ucc_geth_init_pram *) kmalloc(sizeof(struct ucc_geth_init_pram),
3466 GFP_KERNEL))) { 3454 GFP_KERNEL))) {
3467 ugeth_err 3455 ugeth_err
3468 ("%s: Can not allocate memory for" 3456 ("%s: Can not allocate memory for"
@@ -3472,7 +3460,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3472 } 3460 }
3473 /* Zero out *p_init_enet_param_shadow */ 3461 /* Zero out *p_init_enet_param_shadow */
3474 memset((char *)ugeth->p_init_enet_param_shadow, 3462 memset((char *)ugeth->p_init_enet_param_shadow,
3475 0, sizeof(ucc_geth_init_pram_t)); 3463 0, sizeof(struct ucc_geth_init_pram));
3476 3464
3477 /* Fill shadow InitEnet command parameter structure */ 3465 /* Fill shadow InitEnet command parameter structure */
3478 3466
@@ -3506,7 +3494,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3506 } 3494 }
3507 ugeth->p_init_enet_param_shadow->largestexternallookupkeysize = 3495 ugeth->p_init_enet_param_shadow->largestexternallookupkeysize =
3508 ug_info->largestexternallookupkeysize; 3496 ug_info->largestexternallookupkeysize;
3509 size = sizeof(ucc_geth_thread_rx_pram_t); 3497 size = sizeof(struct ucc_geth_thread_rx_pram);
3510 if (ug_info->rxExtendedFiltering) { 3498 if (ug_info->rxExtendedFiltering) {
3511 size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; 3499 size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING;
3512 if (ug_info->largestexternallookupkeysize == 3500 if (ug_info->largestexternallookupkeysize ==
@@ -3537,7 +3525,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3537 fill_init_enet_entries(ugeth, 3525 fill_init_enet_entries(ugeth,
3538 &(ugeth->p_init_enet_param_shadow-> 3526 &(ugeth->p_init_enet_param_shadow->
3539 txthread[0]), numThreadsTxNumerical, 3527 txthread[0]), numThreadsTxNumerical,
3540 sizeof(ucc_geth_thread_tx_pram_t), 3528 sizeof(struct ucc_geth_thread_tx_pram),
3541 UCC_GETH_THREAD_TX_PRAM_ALIGNMENT, 3529 UCC_GETH_THREAD_TX_PRAM_ALIGNMENT,
3542 ug_info->riscTx, 0)) != 0) { 3530 ug_info->riscTx, 0)) != 0) {
3543 ugeth_err("%s: Can not fill p_init_enet_param_shadow.", 3531 ugeth_err("%s: Can not fill p_init_enet_param_shadow.",
@@ -3557,7 +3545,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3557 } 3545 }
3558 3546
3559 /* Allocate InitEnet command parameter structure */ 3547 /* Allocate InitEnet command parameter structure */
3560 init_enet_pram_offset = qe_muram_alloc(sizeof(ucc_geth_init_pram_t), 4); 3548 init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4);
3561 if (IS_MURAM_ERR(init_enet_pram_offset)) { 3549 if (IS_MURAM_ERR(init_enet_pram_offset)) {
3562 ugeth_err 3550 ugeth_err
3563 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.", 3551 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.",
@@ -3566,7 +3554,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3566 return -ENOMEM; 3554 return -ENOMEM;
3567 } 3555 }
3568 p_init_enet_pram = 3556 p_init_enet_pram =
3569 (ucc_geth_init_pram_t *) qe_muram_addr(init_enet_pram_offset); 3557 (struct ucc_geth_init_pram *) qe_muram_addr(init_enet_pram_offset);
3570 3558
3571 /* Copy shadow InitEnet command parameter structure into PRAM */ 3559 /* Copy shadow InitEnet command parameter structure into PRAM */
3572 p_init_enet_pram->resinit1 = ugeth->p_init_enet_param_shadow->resinit1; 3560 p_init_enet_pram->resinit1 = ugeth->p_init_enet_param_shadow->resinit1;
@@ -3591,7 +3579,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3591 /* Issue QE command */ 3579 /* Issue QE command */
3592 cecr_subblock = 3580 cecr_subblock =
3593 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 3581 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
3594 qe_issue_cmd(command, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 3582 qe_issue_cmd(command, cecr_subblock, QE_CR_PROTOCOL_ETHERNET,
3595 init_enet_pram_offset); 3583 init_enet_pram_offset);
3596 3584
3597 /* Free InitEnet command parameter */ 3585 /* Free InitEnet command parameter */
@@ -3603,7 +3591,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3603/* returns a net_device_stats structure pointer */ 3591/* returns a net_device_stats structure pointer */
3604static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev) 3592static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev)
3605{ 3593{
3606 ucc_geth_private_t *ugeth = netdev_priv(dev); 3594 struct ucc_geth_private *ugeth = netdev_priv(dev);
3607 3595
3608 return &(ugeth->stats); 3596 return &(ugeth->stats);
3609} 3597}
@@ -3614,7 +3602,7 @@ static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev)
3614 * starting over will fix the problem. */ 3602 * starting over will fix the problem. */
3615static void ucc_geth_timeout(struct net_device *dev) 3603static void ucc_geth_timeout(struct net_device *dev)
3616{ 3604{
3617 ucc_geth_private_t *ugeth = netdev_priv(dev); 3605 struct ucc_geth_private *ugeth = netdev_priv(dev);
3618 3606
3619 ugeth_vdbg("%s: IN", __FUNCTION__); 3607 ugeth_vdbg("%s: IN", __FUNCTION__);
3620 3608
@@ -3634,7 +3622,7 @@ static void ucc_geth_timeout(struct net_device *dev)
3634/* It is pointed to by the dev->hard_start_xmit function pointer */ 3622/* It is pointed to by the dev->hard_start_xmit function pointer */
3635static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev) 3623static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3636{ 3624{
3637 ucc_geth_private_t *ugeth = netdev_priv(dev); 3625 struct ucc_geth_private *ugeth = netdev_priv(dev);
3638 u8 *bd; /* BD pointer */ 3626 u8 *bd; /* BD pointer */
3639 u32 bd_status; 3627 u32 bd_status;
3640 u8 txQ = 0; 3628 u8 txQ = 0;
@@ -3647,7 +3635,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3647 3635
3648 /* Start from the next BD that should be filled */ 3636 /* Start from the next BD that should be filled */
3649 bd = ugeth->txBd[txQ]; 3637 bd = ugeth->txBd[txQ];
3650 bd_status = BD_STATUS_AND_LENGTH(bd); 3638 bd_status = in_be32((u32 *)bd);
3651 /* Save the skb pointer so we can free it later */ 3639 /* Save the skb pointer so we can free it later */
3652 ugeth->tx_skbuff[txQ][ugeth->skb_curtx[txQ]] = skb; 3640 ugeth->tx_skbuff[txQ][ugeth->skb_curtx[txQ]] = skb;
3653 3641
@@ -3657,20 +3645,21 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3657 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]); 3645 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]);
3658 3646
3659 /* set up the buffer descriptor */ 3647 /* set up the buffer descriptor */
3660 BD_BUFFER_SET(bd, 3648 out_be32(&((struct qe_bd *)bd)->buf,
3661 dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE)); 3649 dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE));
3662 3650
3663 //printk(KERN_DEBUG"skb->data is 0x%x\n",skb->data); 3651 /* printk(KERN_DEBUG"skb->data is 0x%x\n",skb->data); */
3664 3652
3665 bd_status = (bd_status & T_W) | T_R | T_I | T_L | skb->len; 3653 bd_status = (bd_status & T_W) | T_R | T_I | T_L | skb->len;
3666 3654
3667 BD_STATUS_AND_LENGTH_SET(bd, bd_status); 3655 /* set bd status and length */
3656 out_be32((u32 *)bd, bd_status);
3668 3657
3669 dev->trans_start = jiffies; 3658 dev->trans_start = jiffies;
3670 3659
3671 /* Move to next BD in the ring */ 3660 /* Move to next BD in the ring */
3672 if (!(bd_status & T_W)) 3661 if (!(bd_status & T_W))
3673 ugeth->txBd[txQ] = bd + UCC_GETH_SIZE_OF_BD; 3662 ugeth->txBd[txQ] = bd + sizeof(struct qe_bd);
3674 else 3663 else
3675 ugeth->txBd[txQ] = ugeth->p_tx_bd_ring[txQ]; 3664 ugeth->txBd[txQ] = ugeth->p_tx_bd_ring[txQ];
3676 3665
@@ -3695,7 +3684,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3695 return 0; 3684 return 0;
3696} 3685}
3697 3686
3698static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit) 3687static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit)
3699{ 3688{
3700 struct sk_buff *skb; 3689 struct sk_buff *skb;
3701 u8 *bd; 3690 u8 *bd;
@@ -3709,11 +3698,11 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3709 /* collect received buffers */ 3698 /* collect received buffers */
3710 bd = ugeth->rxBd[rxQ]; 3699 bd = ugeth->rxBd[rxQ];
3711 3700
3712 bd_status = BD_STATUS_AND_LENGTH(bd); 3701 bd_status = in_be32((u32 *)bd);
3713 3702
3714 /* while there are received buffers and BD is full (~R_E) */ 3703 /* while there are received buffers and BD is full (~R_E) */
3715 while (!((bd_status & (R_E)) || (--rx_work_limit < 0))) { 3704 while (!((bd_status & (R_E)) || (--rx_work_limit < 0))) {
3716 bdBuffer = (u8 *) BD_BUFFER(bd); 3705 bdBuffer = (u8 *) in_be32(&((struct qe_bd *)bd)->buf);
3717 length = (u16) ((bd_status & BD_LENGTH_MASK) - 4); 3706 length = (u16) ((bd_status & BD_LENGTH_MASK) - 4);
3718 skb = ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]]; 3707 skb = ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]];
3719 3708
@@ -3768,9 +3757,9 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3768 if (bd_status & R_W) 3757 if (bd_status & R_W)
3769 bd = ugeth->p_rx_bd_ring[rxQ]; 3758 bd = ugeth->p_rx_bd_ring[rxQ];
3770 else 3759 else
3771 bd += UCC_GETH_SIZE_OF_BD; 3760 bd += sizeof(struct qe_bd);
3772 3761
3773 bd_status = BD_STATUS_AND_LENGTH(bd); 3762 bd_status = in_be32((u32 *)bd);
3774 } 3763 }
3775 3764
3776 ugeth->rxBd[rxQ] = bd; 3765 ugeth->rxBd[rxQ] = bd;
@@ -3781,12 +3770,12 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3781static int ucc_geth_tx(struct net_device *dev, u8 txQ) 3770static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3782{ 3771{
3783 /* Start from the next BD that should be filled */ 3772 /* Start from the next BD that should be filled */
3784 ucc_geth_private_t *ugeth = netdev_priv(dev); 3773 struct ucc_geth_private *ugeth = netdev_priv(dev);
3785 u8 *bd; /* BD pointer */ 3774 u8 *bd; /* BD pointer */
3786 u32 bd_status; 3775 u32 bd_status;
3787 3776
3788 bd = ugeth->confBd[txQ]; 3777 bd = ugeth->confBd[txQ];
3789 bd_status = BD_STATUS_AND_LENGTH(bd); 3778 bd_status = in_be32((u32 *)bd);
3790 3779
3791 /* Normal processing. */ 3780 /* Normal processing. */
3792 while ((bd_status & T_R) == 0) { 3781 while ((bd_status & T_R) == 0) {
@@ -3813,7 +3802,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3813 3802
3814 /* Advance the confirmation BD pointer */ 3803 /* Advance the confirmation BD pointer */
3815 if (!(bd_status & T_W)) 3804 if (!(bd_status & T_W))
3816 ugeth->confBd[txQ] += UCC_GETH_SIZE_OF_BD; 3805 ugeth->confBd[txQ] += sizeof(struct qe_bd);
3817 else 3806 else
3818 ugeth->confBd[txQ] = ugeth->p_tx_bd_ring[txQ]; 3807 ugeth->confBd[txQ] = ugeth->p_tx_bd_ring[txQ];
3819 } 3808 }
@@ -3823,7 +3812,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3823#ifdef CONFIG_UGETH_NAPI 3812#ifdef CONFIG_UGETH_NAPI
3824static int ucc_geth_poll(struct net_device *dev, int *budget) 3813static int ucc_geth_poll(struct net_device *dev, int *budget)
3825{ 3814{
3826 ucc_geth_private_t *ugeth = netdev_priv(dev); 3815 struct ucc_geth_private *ugeth = netdev_priv(dev);
3827 int howmany; 3816 int howmany;
3828 int rx_work_limit = *budget; 3817 int rx_work_limit = *budget;
3829 u8 rxQ = 0; 3818 u8 rxQ = 0;
@@ -3847,9 +3836,9 @@ static int ucc_geth_poll(struct net_device *dev, int *budget)
3847static irqreturn_t ucc_geth_irq_handler(int irq, void *info) 3836static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3848{ 3837{
3849 struct net_device *dev = (struct net_device *)info; 3838 struct net_device *dev = (struct net_device *)info;
3850 ucc_geth_private_t *ugeth = netdev_priv(dev); 3839 struct ucc_geth_private *ugeth = netdev_priv(dev);
3851 ucc_fast_private_t *uccf; 3840 struct ucc_fast_private *uccf;
3852 ucc_geth_info_t *ug_info; 3841 struct ucc_geth_info *ug_info;
3853 register u32 ucce = 0; 3842 register u32 ucce = 0;
3854 register u32 bit_mask = UCCE_RXBF_SINGLE_MASK; 3843 register u32 bit_mask = UCCE_RXBF_SINGLE_MASK;
3855 register u32 tx_mask = UCCE_TXBF_SINGLE_MASK; 3844 register u32 tx_mask = UCCE_TXBF_SINGLE_MASK;
@@ -3912,7 +3901,7 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3912static irqreturn_t phy_interrupt(int irq, void *dev_id) 3901static irqreturn_t phy_interrupt(int irq, void *dev_id)
3913{ 3902{
3914 struct net_device *dev = (struct net_device *)dev_id; 3903 struct net_device *dev = (struct net_device *)dev_id;
3915 ucc_geth_private_t *ugeth = netdev_priv(dev); 3904 struct ucc_geth_private *ugeth = netdev_priv(dev);
3916 3905
3917 ugeth_vdbg("%s: IN", __FUNCTION__); 3906 ugeth_vdbg("%s: IN", __FUNCTION__);
3918 3907
@@ -3932,8 +3921,8 @@ static irqreturn_t phy_interrupt(int irq, void *dev_id)
3932static void ugeth_phy_change(void *data) 3921static void ugeth_phy_change(void *data)
3933{ 3922{
3934 struct net_device *dev = (struct net_device *)data; 3923 struct net_device *dev = (struct net_device *)data;
3935 ucc_geth_private_t *ugeth = netdev_priv(dev); 3924 struct ucc_geth_private *ugeth = netdev_priv(dev);
3936 ucc_geth_t *ug_regs; 3925 struct ucc_geth *ug_regs;
3937 int result = 0; 3926 int result = 0;
3938 3927
3939 ugeth_vdbg("%s: IN", __FUNCTION__); 3928 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -3963,7 +3952,7 @@ static void ugeth_phy_change(void *data)
3963static void ugeth_phy_timer(unsigned long data) 3952static void ugeth_phy_timer(unsigned long data)
3964{ 3953{
3965 struct net_device *dev = (struct net_device *)data; 3954 struct net_device *dev = (struct net_device *)data;
3966 ucc_geth_private_t *ugeth = netdev_priv(dev); 3955 struct ucc_geth_private *ugeth = netdev_priv(dev);
3967 3956
3968 schedule_work(&ugeth->tq); 3957 schedule_work(&ugeth->tq);
3969 3958
@@ -3979,7 +3968,7 @@ static void ugeth_phy_timer(unsigned long data)
3979static void ugeth_phy_startup_timer(unsigned long data) 3968static void ugeth_phy_startup_timer(unsigned long data)
3980{ 3969{
3981 struct ugeth_mii_info *mii_info = (struct ugeth_mii_info *)data; 3970 struct ugeth_mii_info *mii_info = (struct ugeth_mii_info *)data;
3982 ucc_geth_private_t *ugeth = netdev_priv(mii_info->dev); 3971 struct ucc_geth_private *ugeth = netdev_priv(mii_info->dev);
3983 static int secondary = UGETH_AN_TIMEOUT; 3972 static int secondary = UGETH_AN_TIMEOUT;
3984 int result; 3973 int result;
3985 3974
@@ -4034,7 +4023,7 @@ static void ugeth_phy_startup_timer(unsigned long data)
4034/* Returns 0 for success. */ 4023/* Returns 0 for success. */
4035static int ucc_geth_open(struct net_device *dev) 4024static int ucc_geth_open(struct net_device *dev)
4036{ 4025{
4037 ucc_geth_private_t *ugeth = netdev_priv(dev); 4026 struct ucc_geth_private *ugeth = netdev_priv(dev);
4038 int err; 4027 int err;
4039 4028
4040 ugeth_vdbg("%s: IN", __FUNCTION__); 4029 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -4111,7 +4100,7 @@ static int ucc_geth_open(struct net_device *dev)
4111/* Stops the kernel queue, and halts the controller */ 4100/* Stops the kernel queue, and halts the controller */
4112static int ucc_geth_close(struct net_device *dev) 4101static int ucc_geth_close(struct net_device *dev)
4113{ 4102{
4114 ucc_geth_private_t *ugeth = netdev_priv(dev); 4103 struct ucc_geth_private *ugeth = netdev_priv(dev);
4115 4104
4116 ugeth_vdbg("%s: IN", __FUNCTION__); 4105 ugeth_vdbg("%s: IN", __FUNCTION__);
4117 4106
@@ -4130,30 +4119,53 @@ static int ucc_geth_close(struct net_device *dev)
4130 4119
4131const struct ethtool_ops ucc_geth_ethtool_ops = { }; 4120const struct ethtool_ops ucc_geth_ethtool_ops = { };
4132 4121
4133static int ucc_geth_probe(struct device *device) 4122static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *match)
4134{ 4123{
4135 struct platform_device *pdev = to_platform_device(device); 4124 struct device *device = &ofdev->dev;
4136 struct ucc_geth_platform_data *ugeth_pdata; 4125 struct device_node *np = ofdev->node;
4137 struct net_device *dev = NULL; 4126 struct net_device *dev = NULL;
4138 struct ucc_geth_private *ugeth = NULL; 4127 struct ucc_geth_private *ugeth = NULL;
4139 struct ucc_geth_info *ug_info; 4128 struct ucc_geth_info *ug_info;
4140 int err; 4129 struct resource res;
4130 struct device_node *phy;
4131 int err, ucc_num, phy_interface;
4141 static int mii_mng_configured = 0; 4132 static int mii_mng_configured = 0;
4133 const phandle *ph;
4134 const unsigned int *prop;
4142 4135
4143 ugeth_vdbg("%s: IN", __FUNCTION__); 4136 ugeth_vdbg("%s: IN", __FUNCTION__);
4144 4137
4145 ugeth_pdata = (struct ucc_geth_platform_data *)pdev->dev.platform_data; 4138 prop = get_property(np, "device-id", NULL);
4139 ucc_num = *prop - 1;
4140 if ((ucc_num < 0) || (ucc_num > 7))
4141 return -ENODEV;
4142
4143 ug_info = &ugeth_info[ucc_num];
4144 ug_info->uf_info.ucc_num = ucc_num;
4145 prop = get_property(np, "rx-clock", NULL);
4146 ug_info->uf_info.rx_clock = *prop;
4147 prop = get_property(np, "tx-clock", NULL);
4148 ug_info->uf_info.tx_clock = *prop;
4149 err = of_address_to_resource(np, 0, &res);
4150 if (err)
4151 return -EINVAL;
4152
4153 ug_info->uf_info.regs = res.start;
4154 ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
4155
4156 ph = get_property(np, "phy-handle", NULL);
4157 phy = of_find_node_by_phandle(*ph);
4146 4158
4147 ug_info = &ugeth_info[pdev->id]; 4159 if (phy == NULL)
4148 ug_info->uf_info.ucc_num = pdev->id; 4160 return -ENODEV;
4149 ug_info->uf_info.rx_clock = ugeth_pdata->rx_clock; 4161
4150 ug_info->uf_info.tx_clock = ugeth_pdata->tx_clock; 4162 prop = get_property(phy, "reg", NULL);
4151 ug_info->uf_info.regs = ugeth_pdata->phy_reg_addr; 4163 ug_info->phy_address = *prop;
4152 ug_info->uf_info.irq = platform_get_irq(pdev, 0); 4164 prop = get_property(phy, "interface", NULL);
4153 ug_info->phy_address = ugeth_pdata->phy_id; 4165 ug_info->enet_interface = *prop;
4154 ug_info->enet_interface = ugeth_pdata->phy_interface; 4166 ug_info->phy_interrupt = irq_of_parse_and_map(phy, 0);
4155 ug_info->board_flags = ugeth_pdata->board_flags; 4167 ug_info->board_flags = (ug_info->phy_interrupt == NO_IRQ)?
4156 ug_info->phy_interrupt = ugeth_pdata->phy_interrupt; 4168 0:FSL_UGETH_BRD_HAS_PHY_INTR;
4157 4169
4158 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n", 4170 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n",
4159 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs, 4171 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs,
@@ -4161,12 +4173,44 @@ static int ucc_geth_probe(struct device *device)
4161 4173
4162 if (ug_info == NULL) { 4174 if (ug_info == NULL) {
4163 ugeth_err("%s: [%d] Missing additional data!", __FUNCTION__, 4175 ugeth_err("%s: [%d] Missing additional data!", __FUNCTION__,
4164 pdev->id); 4176 ucc_num);
4165 return -ENODEV; 4177 return -ENODEV;
4166 } 4178 }
4167 4179
4180 /* FIXME: Work around for early chip rev. */
4181 /* There's a bug in initial chip rev(s) in the RGMII ac */
4182 /* timing. */
4183 /* The following compensates by writing to the reserved */
4184 /* QE Port Output Hold Registers (CPOH1?). */
4185 prop = get_property(phy, "interface", NULL);
4186 phy_interface = *prop;
4187 if ((phy_interface == ENET_1000_RGMII) ||
4188 (phy_interface == ENET_100_RGMII) ||
4189 (phy_interface == ENET_10_RGMII)) {
4190 struct device_node *soc;
4191 phys_addr_t immrbase = -1;
4192 u32 *tmp_reg;
4193 u32 tmp_val;
4194
4195 soc = of_find_node_by_type(NULL, "soc");
4196 if (soc) {
4197 unsigned int size;
4198 const void *prop = get_property(soc, "reg", &size);
4199 immrbase = of_translate_address(soc, prop);
4200 of_node_put(soc);
4201 };
4202
4203 tmp_reg = (u32 *) ioremap(immrbase + 0x14A8, 0x4);
4204 tmp_val = in_be32(tmp_reg);
4205 if (ucc_num == 1)
4206 out_be32(tmp_reg, tmp_val | 0x00003000);
4207 else if (ucc_num == 2)
4208 out_be32(tmp_reg, tmp_val | 0x0c000000);
4209 iounmap(tmp_reg);
4210 }
4211
4168 if (!mii_mng_configured) { 4212 if (!mii_mng_configured) {
4169 ucc_set_qe_mux_mii_mng(ug_info->uf_info.ucc_num); 4213 ucc_set_qe_mux_mii_mng(ucc_num);
4170 mii_mng_configured = 1; 4214 mii_mng_configured = 1;
4171 } 4215 }
4172 4216
@@ -4213,13 +4257,14 @@ static int ucc_geth_probe(struct device *device)
4213 4257
4214 ugeth->ug_info = ug_info; 4258 ugeth->ug_info = ug_info;
4215 ugeth->dev = dev; 4259 ugeth->dev = dev;
4216 memcpy(dev->dev_addr, ugeth_pdata->mac_addr, 6); 4260 memcpy(dev->dev_addr, get_property(np, "mac-address", NULL), 6);
4217 4261
4218 return 0; 4262 return 0;
4219} 4263}
4220 4264
4221static int ucc_geth_remove(struct device *device) 4265static int ucc_geth_remove(struct of_device* ofdev)
4222{ 4266{
4267 struct device *device = &ofdev->dev;
4223 struct net_device *dev = dev_get_drvdata(device); 4268 struct net_device *dev = dev_get_drvdata(device);
4224 struct ucc_geth_private *ugeth = netdev_priv(dev); 4269 struct ucc_geth_private *ugeth = netdev_priv(dev);
4225 4270
@@ -4230,28 +4275,38 @@ static int ucc_geth_remove(struct device *device)
4230 return 0; 4275 return 0;
4231} 4276}
4232 4277
4233/* Structure for a device driver */ 4278static struct of_device_id ucc_geth_match[] = {
4234static struct device_driver ucc_geth_driver = { 4279 {
4235 .name = DRV_NAME, 4280 .type = "network",
4236 .bus = &platform_bus_type, 4281 .compatible = "ucc_geth",
4237 .probe = ucc_geth_probe, 4282 },
4238 .remove = ucc_geth_remove, 4283 {},
4284};
4285
4286MODULE_DEVICE_TABLE(of, ucc_geth_match);
4287
4288static struct of_platform_driver ucc_geth_driver = {
4289 .name = DRV_NAME,
4290 .match_table = ucc_geth_match,
4291 .probe = ucc_geth_probe,
4292 .remove = ucc_geth_remove,
4239}; 4293};
4240 4294
4241static int __init ucc_geth_init(void) 4295static int __init ucc_geth_init(void)
4242{ 4296{
4243 int i; 4297 int i;
4298
4244 printk(KERN_INFO "ucc_geth: " DRV_DESC "\n"); 4299 printk(KERN_INFO "ucc_geth: " DRV_DESC "\n");
4245 for (i = 0; i < 8; i++) 4300 for (i = 0; i < 8; i++)
4246 memcpy(&(ugeth_info[i]), &ugeth_primary_info, 4301 memcpy(&(ugeth_info[i]), &ugeth_primary_info,
4247 sizeof(ugeth_primary_info)); 4302 sizeof(ugeth_primary_info));
4248 4303
4249 return driver_register(&ucc_geth_driver); 4304 return of_register_driver(&ucc_geth_driver);
4250} 4305}
4251 4306
4252static void __exit ucc_geth_exit(void) 4307static void __exit ucc_geth_exit(void)
4253{ 4308{
4254 driver_unregister(&ucc_geth_driver); 4309 of_unregister_driver(&ucc_geth_driver);
4255} 4310}
4256 4311
4257module_init(ucc_geth_init); 4312module_init(ucc_geth_init);
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index 005965f5dd9b..a66561253593 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -36,24 +36,24 @@
36#define ENET_INIT_PARAM_MAX_ENTRIES_RX 9 36#define ENET_INIT_PARAM_MAX_ENTRIES_RX 9
37#define ENET_INIT_PARAM_MAX_ENTRIES_TX 8 37#define ENET_INIT_PARAM_MAX_ENTRIES_TX 8
38 38
39typedef struct ucc_mii_mng { 39struct ucc_mii_mng {
40 u32 miimcfg; /* MII management configuration reg */ 40 u32 miimcfg; /* MII management configuration reg */
41 u32 miimcom; /* MII management command reg */ 41 u32 miimcom; /* MII management command reg */
42 u32 miimadd; /* MII management address reg */ 42 u32 miimadd; /* MII management address reg */
43 u32 miimcon; /* MII management control reg */ 43 u32 miimcon; /* MII management control reg */
44 u32 miimstat; /* MII management status reg */ 44 u32 miimstat; /* MII management status reg */
45 u32 miimind; /* MII management indication reg */ 45 u32 miimind; /* MII management indication reg */
46} __attribute__ ((packed)) ucc_mii_mng_t; 46} __attribute__ ((packed));
47 47
48typedef struct ucc_geth { 48struct ucc_geth {
49 ucc_fast_t uccf; 49 struct ucc_fast uccf;
50 50
51 u32 maccfg1; /* mac configuration reg. 1 */ 51 u32 maccfg1; /* mac configuration reg. 1 */
52 u32 maccfg2; /* mac configuration reg. 2 */ 52 u32 maccfg2; /* mac configuration reg. 2 */
53 u32 ipgifg; /* interframe gap reg. */ 53 u32 ipgifg; /* interframe gap reg. */
54 u32 hafdup; /* half-duplex reg. */ 54 u32 hafdup; /* half-duplex reg. */
55 u8 res1[0x10]; 55 u8 res1[0x10];
56 ucc_mii_mng_t miimng; /* MII management structure */ 56 struct ucc_mii_mng miimng; /* MII management structure */
57 u32 ifctl; /* interface control reg */ 57 u32 ifctl; /* interface control reg */
58 u32 ifstat; /* interface statux reg */ 58 u32 ifstat; /* interface statux reg */
59 u32 macstnaddr1; /* mac station address part 1 reg */ 59 u32 macstnaddr1; /* mac station address part 1 reg */
@@ -111,7 +111,7 @@ typedef struct ucc_geth {
111 u32 scar; /* Statistics carry register */ 111 u32 scar; /* Statistics carry register */
112 u32 scam; /* Statistics caryy mask register */ 112 u32 scam; /* Statistics caryy mask register */
113 u8 res5[0x200 - 0x1c4]; 113 u8 res5[0x200 - 0x1c4];
114} __attribute__ ((packed)) ucc_geth_t; 114} __attribute__ ((packed));
115 115
116/* UCC GETH TEMODR Register */ 116/* UCC GETH TEMODR Register */
117#define TEMODER_TX_RMON_STATISTICS_ENABLE 0x0100 /* enable Tx statistics 117#define TEMODER_TX_RMON_STATISTICS_ENABLE 0x0100 /* enable Tx statistics
@@ -508,39 +508,39 @@ typedef struct ucc_geth {
508/* UCC GETH UDSR (Data Synchronization Register) */ 508/* UCC GETH UDSR (Data Synchronization Register) */
509#define UDSR_MAGIC 0x067E 509#define UDSR_MAGIC 0x067E
510 510
511typedef struct ucc_geth_thread_data_tx { 511struct ucc_geth_thread_data_tx {
512 u8 res0[104]; 512 u8 res0[104];
513} __attribute__ ((packed)) ucc_geth_thread_data_tx_t; 513} __attribute__ ((packed));
514 514
515typedef struct ucc_geth_thread_data_rx { 515struct ucc_geth_thread_data_rx {
516 u8 res0[40]; 516 u8 res0[40];
517} __attribute__ ((packed)) ucc_geth_thread_data_rx_t; 517} __attribute__ ((packed));
518 518
519/* Send Queue Queue-Descriptor */ 519/* Send Queue Queue-Descriptor */
520typedef struct ucc_geth_send_queue_qd { 520struct ucc_geth_send_queue_qd {
521 u32 bd_ring_base; /* pointer to BD ring base address */ 521 u32 bd_ring_base; /* pointer to BD ring base address */
522 u8 res0[0x8]; 522 u8 res0[0x8];
523 u32 last_bd_completed_address;/* initialize to last entry in BD ring */ 523 u32 last_bd_completed_address;/* initialize to last entry in BD ring */
524 u8 res1[0x30]; 524 u8 res1[0x30];
525} __attribute__ ((packed)) ucc_geth_send_queue_qd_t; 525} __attribute__ ((packed));
526 526
527typedef struct ucc_geth_send_queue_mem_region { 527struct ucc_geth_send_queue_mem_region {
528 ucc_geth_send_queue_qd_t sqqd[NUM_TX_QUEUES]; 528 struct ucc_geth_send_queue_qd sqqd[NUM_TX_QUEUES];
529} __attribute__ ((packed)) ucc_geth_send_queue_mem_region_t; 529} __attribute__ ((packed));
530 530
531typedef struct ucc_geth_thread_tx_pram { 531struct ucc_geth_thread_tx_pram {
532 u8 res0[64]; 532 u8 res0[64];
533} __attribute__ ((packed)) ucc_geth_thread_tx_pram_t; 533} __attribute__ ((packed));
534 534
535typedef struct ucc_geth_thread_rx_pram { 535struct ucc_geth_thread_rx_pram {
536 u8 res0[128]; 536 u8 res0[128];
537} __attribute__ ((packed)) ucc_geth_thread_rx_pram_t; 537} __attribute__ ((packed));
538 538
539#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING 64 539#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING 64
540#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8 64 540#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8 64
541#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16 96 541#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16 96
542 542
543typedef struct ucc_geth_scheduler { 543struct ucc_geth_scheduler {
544 u16 cpucount0; /* CPU packet counter */ 544 u16 cpucount0; /* CPU packet counter */
545 u16 cpucount1; /* CPU packet counter */ 545 u16 cpucount1; /* CPU packet counter */
546 u16 cecount0; /* QE packet counter */ 546 u16 cecount0; /* QE packet counter */
@@ -574,9 +574,9 @@ typedef struct ucc_geth_scheduler {
574 /**< weight factor for queues */ 574 /**< weight factor for queues */
575 u32 minw; /* temporary variable handled by QE */ 575 u32 minw; /* temporary variable handled by QE */
576 u8 res1[0x70 - 0x64]; 576 u8 res1[0x70 - 0x64];
577} __attribute__ ((packed)) ucc_geth_scheduler_t; 577} __attribute__ ((packed));
578 578
579typedef struct ucc_geth_tx_firmware_statistics_pram { 579struct ucc_geth_tx_firmware_statistics_pram {
580 u32 sicoltx; /* single collision */ 580 u32 sicoltx; /* single collision */
581 u32 mulcoltx; /* multiple collision */ 581 u32 mulcoltx; /* multiple collision */
582 u32 latecoltxfr; /* late collision */ 582 u32 latecoltxfr; /* late collision */
@@ -596,9 +596,9 @@ typedef struct ucc_geth_tx_firmware_statistics_pram {
596 and 1518 octets */ 596 and 1518 octets */
597 u32 txpktsjumbo; /* total packets (including bad) between 1024 597 u32 txpktsjumbo; /* total packets (including bad) between 1024
598 and MAXLength octets */ 598 and MAXLength octets */
599} __attribute__ ((packed)) ucc_geth_tx_firmware_statistics_pram_t; 599} __attribute__ ((packed));
600 600
601typedef struct ucc_geth_rx_firmware_statistics_pram { 601struct ucc_geth_rx_firmware_statistics_pram {
602 u32 frrxfcser; /* frames with crc error */ 602 u32 frrxfcser; /* frames with crc error */
603 u32 fraligner; /* frames with alignment error */ 603 u32 fraligner; /* frames with alignment error */
604 u32 inrangelenrxer; /* in range length error */ 604 u32 inrangelenrxer; /* in range length error */
@@ -630,33 +630,33 @@ typedef struct ucc_geth_rx_firmware_statistics_pram {
630 replaced */ 630 replaced */
631 u32 insertvlan; /* total frames that had their VLAN tag 631 u32 insertvlan; /* total frames that had their VLAN tag
632 inserted */ 632 inserted */
633} __attribute__ ((packed)) ucc_geth_rx_firmware_statistics_pram_t; 633} __attribute__ ((packed));
634 634
635typedef struct ucc_geth_rx_interrupt_coalescing_entry { 635struct ucc_geth_rx_interrupt_coalescing_entry {
636 u32 interruptcoalescingmaxvalue; /* interrupt coalescing max 636 u32 interruptcoalescingmaxvalue; /* interrupt coalescing max
637 value */ 637 value */
638 u32 interruptcoalescingcounter; /* interrupt coalescing counter, 638 u32 interruptcoalescingcounter; /* interrupt coalescing counter,
639 initialize to 639 initialize to
640 interruptcoalescingmaxvalue */ 640 interruptcoalescingmaxvalue */
641} __attribute__ ((packed)) ucc_geth_rx_interrupt_coalescing_entry_t; 641} __attribute__ ((packed));
642 642
643typedef struct ucc_geth_rx_interrupt_coalescing_table { 643struct ucc_geth_rx_interrupt_coalescing_table {
644 ucc_geth_rx_interrupt_coalescing_entry_t coalescingentry[NUM_RX_QUEUES]; 644 struct ucc_geth_rx_interrupt_coalescing_entry coalescingentry[NUM_RX_QUEUES];
645 /**< interrupt coalescing entry */ 645 /**< interrupt coalescing entry */
646} __attribute__ ((packed)) ucc_geth_rx_interrupt_coalescing_table_t; 646} __attribute__ ((packed));
647 647
648typedef struct ucc_geth_rx_prefetched_bds { 648struct ucc_geth_rx_prefetched_bds {
649 qe_bd_t bd[NUM_BDS_IN_PREFETCHED_BDS]; /* prefetched bd */ 649 struct qe_bd bd[NUM_BDS_IN_PREFETCHED_BDS]; /* prefetched bd */
650} __attribute__ ((packed)) ucc_geth_rx_prefetched_bds_t; 650} __attribute__ ((packed));
651 651
652typedef struct ucc_geth_rx_bd_queues_entry { 652struct ucc_geth_rx_bd_queues_entry {
653 u32 bdbaseptr; /* BD base pointer */ 653 u32 bdbaseptr; /* BD base pointer */
654 u32 bdptr; /* BD pointer */ 654 u32 bdptr; /* BD pointer */
655 u32 externalbdbaseptr; /* external BD base pointer */ 655 u32 externalbdbaseptr; /* external BD base pointer */
656 u32 externalbdptr; /* external BD pointer */ 656 u32 externalbdptr; /* external BD pointer */
657} __attribute__ ((packed)) ucc_geth_rx_bd_queues_entry_t; 657} __attribute__ ((packed));
658 658
659typedef struct ucc_geth_tx_global_pram { 659struct ucc_geth_tx_global_pram {
660 u16 temoder; 660 u16 temoder;
661 u8 res0[0x38 - 0x02]; 661 u8 res0[0x38 - 0x02];
662 u32 sqptr; /* a base pointer to send queue memory region */ 662 u32 sqptr; /* a base pointer to send queue memory region */
@@ -670,15 +670,15 @@ typedef struct ucc_geth_tx_global_pram {
670 u32 tqptr; /* a base pointer to the Tx Queues Memory 670 u32 tqptr; /* a base pointer to the Tx Queues Memory
671 Region */ 671 Region */
672 u8 res2[0x80 - 0x74]; 672 u8 res2[0x80 - 0x74];
673} __attribute__ ((packed)) ucc_geth_tx_global_pram_t; 673} __attribute__ ((packed));
674 674
675/* structure representing Extended Filtering Global Parameters in PRAM */ 675/* structure representing Extended Filtering Global Parameters in PRAM */
676typedef struct ucc_geth_exf_global_pram { 676struct ucc_geth_exf_global_pram {
677 u32 l2pcdptr; /* individual address filter, high */ 677 u32 l2pcdptr; /* individual address filter, high */
678 u8 res0[0x10 - 0x04]; 678 u8 res0[0x10 - 0x04];
679} __attribute__ ((packed)) ucc_geth_exf_global_pram_t; 679} __attribute__ ((packed));
680 680
681typedef struct ucc_geth_rx_global_pram { 681struct ucc_geth_rx_global_pram {
682 u32 remoder; /* ethernet mode reg. */ 682 u32 remoder; /* ethernet mode reg. */
683 u32 rqptr; /* base pointer to the Rx Queues Memory Region*/ 683 u32 rqptr; /* base pointer to the Rx Queues Memory Region*/
684 u32 res0[0x1]; 684 u32 res0[0x1];
@@ -710,12 +710,12 @@ typedef struct ucc_geth_rx_global_pram {
710 u32 exfGlobalParam; /* base address for extended filtering global 710 u32 exfGlobalParam; /* base address for extended filtering global
711 parameters */ 711 parameters */
712 u8 res6[0x100 - 0xC4]; /* Initialize to zero */ 712 u8 res6[0x100 - 0xC4]; /* Initialize to zero */
713} __attribute__ ((packed)) ucc_geth_rx_global_pram_t; 713} __attribute__ ((packed));
714 714
715#define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01 715#define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01
716 716
717/* structure representing InitEnet command */ 717/* structure representing InitEnet command */
718typedef struct ucc_geth_init_pram { 718struct ucc_geth_init_pram {
719 u8 resinit1; 719 u8 resinit1;
720 u8 resinit2; 720 u8 resinit2;
721 u8 resinit3; 721 u8 resinit3;
@@ -729,7 +729,7 @@ typedef struct ucc_geth_init_pram {
729 u32 txglobal; /* tx global */ 729 u32 txglobal; /* tx global */
730 u32 txthread[ENET_INIT_PARAM_MAX_ENTRIES_TX]; /* tx threads */ 730 u32 txthread[ENET_INIT_PARAM_MAX_ENTRIES_TX]; /* tx threads */
731 u8 res3[0x1]; 731 u8 res3[0x1];
732} __attribute__ ((packed)) ucc_geth_init_pram_t; 732} __attribute__ ((packed));
733 733
734#define ENET_INIT_PARAM_RGF_SHIFT (32 - 4) 734#define ENET_INIT_PARAM_RGF_SHIFT (32 - 4)
735#define ENET_INIT_PARAM_TGF_SHIFT (32 - 8) 735#define ENET_INIT_PARAM_TGF_SHIFT (32 - 8)
@@ -746,27 +746,27 @@ typedef struct ucc_geth_init_pram {
746#define ENET_INIT_PARAM_MAGIC_RES_INIT5 0x0400 746#define ENET_INIT_PARAM_MAGIC_RES_INIT5 0x0400
747 747
748/* structure representing 82xx Address Filtering Enet Address in PRAM */ 748/* structure representing 82xx Address Filtering Enet Address in PRAM */
749typedef struct ucc_geth_82xx_enet_address { 749struct ucc_geth_82xx_enet_address {
750 u8 res1[0x2]; 750 u8 res1[0x2];
751 u16 h; /* address (MSB) */ 751 u16 h; /* address (MSB) */
752 u16 m; /* address */ 752 u16 m; /* address */
753 u16 l; /* address (LSB) */ 753 u16 l; /* address (LSB) */
754} __attribute__ ((packed)) ucc_geth_82xx_enet_address_t; 754} __attribute__ ((packed));
755 755
756/* structure representing 82xx Address Filtering PRAM */ 756/* structure representing 82xx Address Filtering PRAM */
757typedef struct ucc_geth_82xx_address_filtering_pram { 757struct ucc_geth_82xx_address_filtering_pram {
758 u32 iaddr_h; /* individual address filter, high */ 758 u32 iaddr_h; /* individual address filter, high */
759 u32 iaddr_l; /* individual address filter, low */ 759 u32 iaddr_l; /* individual address filter, low */
760 u32 gaddr_h; /* group address filter, high */ 760 u32 gaddr_h; /* group address filter, high */
761 u32 gaddr_l; /* group address filter, low */ 761 u32 gaddr_l; /* group address filter, low */
762 ucc_geth_82xx_enet_address_t taddr; 762 struct ucc_geth_82xx_enet_address taddr;
763 ucc_geth_82xx_enet_address_t paddr[NUM_OF_PADDRS]; 763 struct ucc_geth_82xx_enet_address paddr[NUM_OF_PADDRS];
764 u8 res0[0x40 - 0x38]; 764 u8 res0[0x40 - 0x38];
765} __attribute__ ((packed)) ucc_geth_82xx_address_filtering_pram_t; 765} __attribute__ ((packed));
766 766
767/* GETH Tx firmware statistics structure, used when calling 767/* GETH Tx firmware statistics structure, used when calling
768 UCC_GETH_GetStatistics. */ 768 UCC_GETH_GetStatistics. */
769typedef struct ucc_geth_tx_firmware_statistics { 769struct ucc_geth_tx_firmware_statistics {
770 u32 sicoltx; /* single collision */ 770 u32 sicoltx; /* single collision */
771 u32 mulcoltx; /* multiple collision */ 771 u32 mulcoltx; /* multiple collision */
772 u32 latecoltxfr; /* late collision */ 772 u32 latecoltxfr; /* late collision */
@@ -786,11 +786,11 @@ typedef struct ucc_geth_tx_firmware_statistics {
786 and 1518 octets */ 786 and 1518 octets */
787 u32 txpktsjumbo; /* total packets (including bad) between 1024 787 u32 txpktsjumbo; /* total packets (including bad) between 1024
788 and MAXLength octets */ 788 and MAXLength octets */
789} __attribute__ ((packed)) ucc_geth_tx_firmware_statistics_t; 789} __attribute__ ((packed));
790 790
791/* GETH Rx firmware statistics structure, used when calling 791/* GETH Rx firmware statistics structure, used when calling
792 UCC_GETH_GetStatistics. */ 792 UCC_GETH_GetStatistics. */
793typedef struct ucc_geth_rx_firmware_statistics { 793struct ucc_geth_rx_firmware_statistics {
794 u32 frrxfcser; /* frames with crc error */ 794 u32 frrxfcser; /* frames with crc error */
795 u32 fraligner; /* frames with alignment error */ 795 u32 fraligner; /* frames with alignment error */
796 u32 inrangelenrxer; /* in range length error */ 796 u32 inrangelenrxer; /* in range length error */
@@ -822,11 +822,11 @@ typedef struct ucc_geth_rx_firmware_statistics {
822 replaced */ 822 replaced */
823 u32 insertvlan; /* total frames that had their VLAN tag 823 u32 insertvlan; /* total frames that had their VLAN tag
824 inserted */ 824 inserted */
825} __attribute__ ((packed)) ucc_geth_rx_firmware_statistics_t; 825} __attribute__ ((packed));
826 826
827/* GETH hardware statistics structure, used when calling 827/* GETH hardware statistics structure, used when calling
828 UCC_GETH_GetStatistics. */ 828 UCC_GETH_GetStatistics. */
829typedef struct ucc_geth_hardware_statistics { 829struct ucc_geth_hardware_statistics {
830 u32 tx64; /* Total number of frames (including bad 830 u32 tx64; /* Total number of frames (including bad
831 frames) transmitted that were exactly of the 831 frames) transmitted that were exactly of the
832 minimal length (64 for un tagged, 68 for 832 minimal length (64 for un tagged, 68 for
@@ -871,7 +871,7 @@ typedef struct ucc_geth_hardware_statistics {
871 u32 rbca; /* Total number of frames received succesfully 871 u32 rbca; /* Total number of frames received succesfully
872 that had destination address equal to the 872 that had destination address equal to the
873 broadcast address */ 873 broadcast address */
874} __attribute__ ((packed)) ucc_geth_hardware_statistics_t; 874} __attribute__ ((packed));
875 875
876/* UCC GETH Tx errors returned via TxConf callback */ 876/* UCC GETH Tx errors returned via TxConf callback */
877#define TX_ERRORS_DEF 0x0200 877#define TX_ERRORS_DEF 0x0200
@@ -1013,21 +1013,21 @@ typedef struct ucc_geth_hardware_statistics {
1013 (MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_112) 1013 (MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_112)
1014 1014
1015/* Ethernet speed */ 1015/* Ethernet speed */
1016typedef enum enet_speed { 1016enum enet_speed {
1017 ENET_SPEED_10BT, /* 10 Base T */ 1017 ENET_SPEED_10BT, /* 10 Base T */
1018 ENET_SPEED_100BT, /* 100 Base T */ 1018 ENET_SPEED_100BT, /* 100 Base T */
1019 ENET_SPEED_1000BT /* 1000 Base T */ 1019 ENET_SPEED_1000BT /* 1000 Base T */
1020} enet_speed_e; 1020};
1021 1021
1022/* Ethernet Address Type. */ 1022/* Ethernet Address Type. */
1023typedef enum enet_addr_type { 1023enum enet_addr_type {
1024 ENET_ADDR_TYPE_INDIVIDUAL, 1024 ENET_ADDR_TYPE_INDIVIDUAL,
1025 ENET_ADDR_TYPE_GROUP, 1025 ENET_ADDR_TYPE_GROUP,
1026 ENET_ADDR_TYPE_BROADCAST 1026 ENET_ADDR_TYPE_BROADCAST
1027} enet_addr_type_e; 1027};
1028 1028
1029/* TBI / MII Set Register */ 1029/* TBI / MII Set Register */
1030typedef enum enet_tbi_mii_reg { 1030enum enet_tbi_mii_reg {
1031 ENET_TBI_MII_CR = 0x00, /* Control (CR ) */ 1031 ENET_TBI_MII_CR = 0x00, /* Control (CR ) */
1032 ENET_TBI_MII_SR = 0x01, /* Status (SR ) */ 1032 ENET_TBI_MII_SR = 0x01, /* Status (SR ) */
1033 ENET_TBI_MII_ANA = 0x04, /* AN advertisement (ANA ) */ 1033 ENET_TBI_MII_ANA = 0x04, /* AN advertisement (ANA ) */
@@ -1040,10 +1040,10 @@ typedef enum enet_tbi_mii_reg {
1040 ENET_TBI_MII_EXST = 0x0F, /* Extended status (EXST ) */ 1040 ENET_TBI_MII_EXST = 0x0F, /* Extended status (EXST ) */
1041 ENET_TBI_MII_JD = 0x10, /* Jitter diagnostics (JD ) */ 1041 ENET_TBI_MII_JD = 0x10, /* Jitter diagnostics (JD ) */
1042 ENET_TBI_MII_TBICON = 0x11 /* TBI control (TBICON ) */ 1042 ENET_TBI_MII_TBICON = 0x11 /* TBI control (TBICON ) */
1043} enet_tbi_mii_reg_e; 1043};
1044 1044
1045/* UCC GETH 82xx Ethernet Address Recognition Location */ 1045/* UCC GETH 82xx Ethernet Address Recognition Location */
1046typedef enum ucc_geth_enet_address_recognition_location { 1046enum ucc_geth_enet_address_recognition_location {
1047 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_STATION_ADDRESS,/* station 1047 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_STATION_ADDRESS,/* station
1048 address */ 1048 address */
1049 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_FIRST, /* additional 1049 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_FIRST, /* additional
@@ -1065,10 +1065,10 @@ typedef enum ucc_geth_enet_address_recognition_location {
1065 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH, /* group hash */ 1065 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH, /* group hash */
1066 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH /* individual 1066 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH /* individual
1067 hash */ 1067 hash */
1068} ucc_geth_enet_address_recognition_location_e; 1068};
1069 1069
1070/* UCC GETH vlan operation tagged */ 1070/* UCC GETH vlan operation tagged */
1071typedef enum ucc_geth_vlan_operation_tagged { 1071enum ucc_geth_vlan_operation_tagged {
1072 UCC_GETH_VLAN_OPERATION_TAGGED_NOP = 0x0, /* Tagged - nop */ 1072 UCC_GETH_VLAN_OPERATION_TAGGED_NOP = 0x0, /* Tagged - nop */
1073 UCC_GETH_VLAN_OPERATION_TAGGED_REPLACE_VID_PORTION_OF_Q_TAG 1073 UCC_GETH_VLAN_OPERATION_TAGGED_REPLACE_VID_PORTION_OF_Q_TAG
1074 = 0x1, /* Tagged - replace vid portion of q tag */ 1074 = 0x1, /* Tagged - replace vid portion of q tag */
@@ -1076,18 +1076,18 @@ typedef enum ucc_geth_vlan_operation_tagged {
1076 = 0x2, /* Tagged - if vid0 replace vid with default value */ 1076 = 0x2, /* Tagged - if vid0 replace vid with default value */
1077 UCC_GETH_VLAN_OPERATION_TAGGED_EXTRACT_Q_TAG_FROM_FRAME 1077 UCC_GETH_VLAN_OPERATION_TAGGED_EXTRACT_Q_TAG_FROM_FRAME
1078 = 0x3 /* Tagged - extract q tag from frame */ 1078 = 0x3 /* Tagged - extract q tag from frame */
1079} ucc_geth_vlan_operation_tagged_e; 1079};
1080 1080
1081/* UCC GETH vlan operation non-tagged */ 1081/* UCC GETH vlan operation non-tagged */
1082typedef enum ucc_geth_vlan_operation_non_tagged { 1082enum ucc_geth_vlan_operation_non_tagged {
1083 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP = 0x0, /* Non tagged - nop */ 1083 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP = 0x0, /* Non tagged - nop */
1084 UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT = 0x1 /* Non tagged - 1084 UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT = 0x1 /* Non tagged -
1085 q tag insert 1085 q tag insert
1086 */ 1086 */
1087} ucc_geth_vlan_operation_non_tagged_e; 1087};
1088 1088
1089/* UCC GETH Rx Quality of Service Mode */ 1089/* UCC GETH Rx Quality of Service Mode */
1090typedef enum ucc_geth_qos_mode { 1090enum ucc_geth_qos_mode {
1091 UCC_GETH_QOS_MODE_DEFAULT = 0x0, /* default queue */ 1091 UCC_GETH_QOS_MODE_DEFAULT = 0x0, /* default queue */
1092 UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L2_CRITERIA = 0x1, /* queue 1092 UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L2_CRITERIA = 0x1, /* queue
1093 determined 1093 determined
@@ -1097,11 +1097,11 @@ typedef enum ucc_geth_qos_mode {
1097 determined 1097 determined
1098 by L3 1098 by L3
1099 criteria */ 1099 criteria */
1100} ucc_geth_qos_mode_e; 1100};
1101 1101
1102/* UCC GETH Statistics Gathering Mode - These are bit flags, 'or' them together 1102/* UCC GETH Statistics Gathering Mode - These are bit flags, 'or' them together
1103 for combined functionality */ 1103 for combined functionality */
1104typedef enum ucc_geth_statistics_gathering_mode { 1104enum ucc_geth_statistics_gathering_mode {
1105 UCC_GETH_STATISTICS_GATHERING_MODE_NONE = 0x00000000, /* No 1105 UCC_GETH_STATISTICS_GATHERING_MODE_NONE = 0x00000000, /* No
1106 statistics 1106 statistics
1107 gathering */ 1107 gathering */
@@ -1122,10 +1122,10 @@ typedef enum ucc_geth_statistics_gathering_mode {
1122 statistics 1122 statistics
1123 gathering 1123 gathering
1124 */ 1124 */
1125} ucc_geth_statistics_gathering_mode_e; 1125};
1126 1126
1127/* UCC GETH Pad and CRC Mode - Note, Padding without CRC is not possible */ 1127/* UCC GETH Pad and CRC Mode - Note, Padding without CRC is not possible */
1128typedef enum ucc_geth_maccfg2_pad_and_crc_mode { 1128enum ucc_geth_maccfg2_pad_and_crc_mode {
1129 UCC_GETH_PAD_AND_CRC_MODE_NONE 1129 UCC_GETH_PAD_AND_CRC_MODE_NONE
1130 = MACCFG2_PAD_AND_CRC_MODE_NONE, /* Neither Padding 1130 = MACCFG2_PAD_AND_CRC_MODE_NONE, /* Neither Padding
1131 short frames 1131 short frames
@@ -1135,61 +1135,59 @@ typedef enum ucc_geth_maccfg2_pad_and_crc_mode {
1135 CRC only */ 1135 CRC only */
1136 UCC_GETH_PAD_AND_CRC_MODE_PAD_AND_CRC = 1136 UCC_GETH_PAD_AND_CRC_MODE_PAD_AND_CRC =
1137 MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC 1137 MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC
1138} ucc_geth_maccfg2_pad_and_crc_mode_e; 1138};
1139 1139
1140/* UCC GETH upsmr Flow Control Mode */ 1140/* UCC GETH upsmr Flow Control Mode */
1141typedef enum ucc_geth_flow_control_mode { 1141enum ucc_geth_flow_control_mode {
1142 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_NONE = 0x00000000, /* No automatic 1142 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_NONE = 0x00000000, /* No automatic
1143 flow control 1143 flow control
1144 */ 1144 */
1145 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_PAUSE_WHEN_EMERGENCY 1145 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_PAUSE_WHEN_EMERGENCY
1146 = 0x00004000 /* Send pause frame when RxFIFO reaches its 1146 = 0x00004000 /* Send pause frame when RxFIFO reaches its
1147 emergency threshold */ 1147 emergency threshold */
1148} ucc_geth_flow_control_mode_e; 1148};
1149 1149
1150/* UCC GETH number of threads */ 1150/* UCC GETH number of threads */
1151typedef enum ucc_geth_num_of_threads { 1151enum ucc_geth_num_of_threads {
1152 UCC_GETH_NUM_OF_THREADS_1 = 0x1, /* 1 */ 1152 UCC_GETH_NUM_OF_THREADS_1 = 0x1, /* 1 */
1153 UCC_GETH_NUM_OF_THREADS_2 = 0x2, /* 2 */ 1153 UCC_GETH_NUM_OF_THREADS_2 = 0x2, /* 2 */
1154 UCC_GETH_NUM_OF_THREADS_4 = 0x0, /* 4 */ 1154 UCC_GETH_NUM_OF_THREADS_4 = 0x0, /* 4 */
1155 UCC_GETH_NUM_OF_THREADS_6 = 0x3, /* 6 */ 1155 UCC_GETH_NUM_OF_THREADS_6 = 0x3, /* 6 */
1156 UCC_GETH_NUM_OF_THREADS_8 = 0x4 /* 8 */ 1156 UCC_GETH_NUM_OF_THREADS_8 = 0x4 /* 8 */
1157} ucc_geth_num_of_threads_e; 1157};
1158 1158
1159/* UCC GETH number of station addresses */ 1159/* UCC GETH number of station addresses */
1160typedef enum ucc_geth_num_of_station_addresses { 1160enum ucc_geth_num_of_station_addresses {
1161 UCC_GETH_NUM_OF_STATION_ADDRESSES_1, /* 1 */ 1161 UCC_GETH_NUM_OF_STATION_ADDRESSES_1, /* 1 */
1162 UCC_GETH_NUM_OF_STATION_ADDRESSES_5 /* 5 */ 1162 UCC_GETH_NUM_OF_STATION_ADDRESSES_5 /* 5 */
1163} ucc_geth_num_of_station_addresses_e; 1163};
1164
1165typedef u8 enet_addr_t[ENET_NUM_OCTETS_PER_ADDRESS];
1166 1164
1167/* UCC GETH 82xx Ethernet Address Container */ 1165/* UCC GETH 82xx Ethernet Address Container */
1168typedef struct enet_addr_container { 1166struct enet_addr_container {
1169 enet_addr_t address; /* ethernet address */ 1167 u8 address[ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */
1170 ucc_geth_enet_address_recognition_location_e location; /* location in 1168 enum ucc_geth_enet_address_recognition_location location; /* location in
1171 82xx address 1169 82xx address
1172 recognition 1170 recognition
1173 hardware */ 1171 hardware */
1174 struct list_head node; 1172 struct list_head node;
1175} enet_addr_container_t; 1173};
1176 1174
1177#define ENET_ADDR_CONT_ENTRY(ptr) list_entry(ptr, enet_addr_container_t, node) 1175#define ENET_ADDR_CONT_ENTRY(ptr) list_entry(ptr, struct enet_addr_container, node)
1178 1176
1179/* UCC GETH Termination Action Descriptor (TAD) structure. */ 1177/* UCC GETH Termination Action Descriptor (TAD) structure. */
1180typedef struct ucc_geth_tad_params { 1178struct ucc_geth_tad_params {
1181 int rx_non_dynamic_extended_features_mode; 1179 int rx_non_dynamic_extended_features_mode;
1182 int reject_frame; 1180 int reject_frame;
1183 ucc_geth_vlan_operation_tagged_e vtag_op; 1181 enum ucc_geth_vlan_operation_tagged vtag_op;
1184 ucc_geth_vlan_operation_non_tagged_e vnontag_op; 1182 enum ucc_geth_vlan_operation_non_tagged vnontag_op;
1185 ucc_geth_qos_mode_e rqos; 1183 enum ucc_geth_qos_mode rqos;
1186 u8 vpri; 1184 u8 vpri;
1187 u16 vid; 1185 u16 vid;
1188} ucc_geth_tad_params_t; 1186};
1189 1187
1190/* GETH protocol initialization structure */ 1188/* GETH protocol initialization structure */
1191typedef struct ucc_geth_info { 1189struct ucc_geth_info {
1192 ucc_fast_info_t uf_info; 1190 struct ucc_fast_info uf_info;
1193 u8 numQueuesTx; 1191 u8 numQueuesTx;
1194 u8 numQueuesRx; 1192 u8 numQueuesRx;
1195 int ipCheckSumCheck; 1193 int ipCheckSumCheck;
@@ -1251,51 +1249,51 @@ typedef struct ucc_geth_info {
1251 u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX]; 1249 u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX];
1252 u16 bdRingLenTx[NUM_TX_QUEUES]; 1250 u16 bdRingLenTx[NUM_TX_QUEUES];
1253 u16 bdRingLenRx[NUM_RX_QUEUES]; 1251 u16 bdRingLenRx[NUM_RX_QUEUES];
1254 enet_interface_e enet_interface; 1252 enum enet_interface enet_interface;
1255 ucc_geth_num_of_station_addresses_e numStationAddresses; 1253 enum ucc_geth_num_of_station_addresses numStationAddresses;
1256 qe_fltr_largest_external_tbl_lookup_key_size_e 1254 enum qe_fltr_largest_external_tbl_lookup_key_size
1257 largestexternallookupkeysize; 1255 largestexternallookupkeysize;
1258 ucc_geth_statistics_gathering_mode_e statisticsMode; 1256 enum ucc_geth_statistics_gathering_mode statisticsMode;
1259 ucc_geth_vlan_operation_tagged_e vlanOperationTagged; 1257 enum ucc_geth_vlan_operation_tagged vlanOperationTagged;
1260 ucc_geth_vlan_operation_non_tagged_e vlanOperationNonTagged; 1258 enum ucc_geth_vlan_operation_non_tagged vlanOperationNonTagged;
1261 ucc_geth_qos_mode_e rxQoSMode; 1259 enum ucc_geth_qos_mode rxQoSMode;
1262 ucc_geth_flow_control_mode_e aufc; 1260 enum ucc_geth_flow_control_mode aufc;
1263 ucc_geth_maccfg2_pad_and_crc_mode_e padAndCrc; 1261 enum ucc_geth_maccfg2_pad_and_crc_mode padAndCrc;
1264 ucc_geth_num_of_threads_e numThreadsTx; 1262 enum ucc_geth_num_of_threads numThreadsTx;
1265 ucc_geth_num_of_threads_e numThreadsRx; 1263 enum ucc_geth_num_of_threads numThreadsRx;
1266 qe_risc_allocation_e riscTx; 1264 enum qe_risc_allocation riscTx;
1267 qe_risc_allocation_e riscRx; 1265 enum qe_risc_allocation riscRx;
1268} ucc_geth_info_t; 1266};
1269 1267
1270/* structure representing UCC GETH */ 1268/* structure representing UCC GETH */
1271typedef struct ucc_geth_private { 1269struct ucc_geth_private {
1272 ucc_geth_info_t *ug_info; 1270 struct ucc_geth_info *ug_info;
1273 ucc_fast_private_t *uccf; 1271 struct ucc_fast_private *uccf;
1274 struct net_device *dev; 1272 struct net_device *dev;
1275 struct net_device_stats stats; /* linux network statistics */ 1273 struct net_device_stats stats; /* linux network statistics */
1276 ucc_geth_t *ug_regs; 1274 struct ucc_geth *ug_regs;
1277 ucc_geth_init_pram_t *p_init_enet_param_shadow; 1275 struct ucc_geth_init_pram *p_init_enet_param_shadow;
1278 ucc_geth_exf_global_pram_t *p_exf_glbl_param; 1276 struct ucc_geth_exf_global_pram *p_exf_glbl_param;
1279 u32 exf_glbl_param_offset; 1277 u32 exf_glbl_param_offset;
1280 ucc_geth_rx_global_pram_t *p_rx_glbl_pram; 1278 struct ucc_geth_rx_global_pram *p_rx_glbl_pram;
1281 u32 rx_glbl_pram_offset; 1279 u32 rx_glbl_pram_offset;
1282 ucc_geth_tx_global_pram_t *p_tx_glbl_pram; 1280 struct ucc_geth_tx_global_pram *p_tx_glbl_pram;
1283 u32 tx_glbl_pram_offset; 1281 u32 tx_glbl_pram_offset;
1284 ucc_geth_send_queue_mem_region_t *p_send_q_mem_reg; 1282 struct ucc_geth_send_queue_mem_region *p_send_q_mem_reg;
1285 u32 send_q_mem_reg_offset; 1283 u32 send_q_mem_reg_offset;
1286 ucc_geth_thread_data_tx_t *p_thread_data_tx; 1284 struct ucc_geth_thread_data_tx *p_thread_data_tx;
1287 u32 thread_dat_tx_offset; 1285 u32 thread_dat_tx_offset;
1288 ucc_geth_thread_data_rx_t *p_thread_data_rx; 1286 struct ucc_geth_thread_data_rx *p_thread_data_rx;
1289 u32 thread_dat_rx_offset; 1287 u32 thread_dat_rx_offset;
1290 ucc_geth_scheduler_t *p_scheduler; 1288 struct ucc_geth_scheduler *p_scheduler;
1291 u32 scheduler_offset; 1289 u32 scheduler_offset;
1292 ucc_geth_tx_firmware_statistics_pram_t *p_tx_fw_statistics_pram; 1290 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram;
1293 u32 tx_fw_statistics_pram_offset; 1291 u32 tx_fw_statistics_pram_offset;
1294 ucc_geth_rx_firmware_statistics_pram_t *p_rx_fw_statistics_pram; 1292 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram;
1295 u32 rx_fw_statistics_pram_offset; 1293 u32 rx_fw_statistics_pram_offset;
1296 ucc_geth_rx_interrupt_coalescing_table_t *p_rx_irq_coalescing_tbl; 1294 struct ucc_geth_rx_interrupt_coalescing_table *p_rx_irq_coalescing_tbl;
1297 u32 rx_irq_coalescing_tbl_offset; 1295 u32 rx_irq_coalescing_tbl_offset;
1298 ucc_geth_rx_bd_queues_entry_t *p_rx_bd_qs_tbl; 1296 struct ucc_geth_rx_bd_queues_entry *p_rx_bd_qs_tbl;
1299 u32 rx_bd_qs_tbl_offset; 1297 u32 rx_bd_qs_tbl_offset;
1300 u8 *p_tx_bd_ring[NUM_TX_QUEUES]; 1298 u8 *p_tx_bd_ring[NUM_TX_QUEUES];
1301 u32 tx_bd_ring_offset[NUM_TX_QUEUES]; 1299 u32 tx_bd_ring_offset[NUM_TX_QUEUES];
@@ -1308,7 +1306,7 @@ typedef struct ucc_geth_private {
1308 u16 cpucount[NUM_TX_QUEUES]; 1306 u16 cpucount[NUM_TX_QUEUES];
1309 volatile u16 *p_cpucount[NUM_TX_QUEUES]; 1307 volatile u16 *p_cpucount[NUM_TX_QUEUES];
1310 int indAddrRegUsed[NUM_OF_PADDRS]; 1308 int indAddrRegUsed[NUM_OF_PADDRS];
1311 enet_addr_t paddr[NUM_OF_PADDRS]; 1309 u8 paddr[NUM_OF_PADDRS][ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */
1312 u8 numGroupAddrInHash; 1310 u8 numGroupAddrInHash;
1313 u8 numIndAddrInHash; 1311 u8 numIndAddrInHash;
1314 u8 numIndAddrInReg; 1312 u8 numIndAddrInReg;
@@ -1334,6 +1332,6 @@ typedef struct ucc_geth_private {
1334 int oldspeed; 1332 int oldspeed;
1335 int oldduplex; 1333 int oldduplex;
1336 int oldlink; 1334 int oldlink;
1337} ucc_geth_private_t; 1335};
1338 1336
1339#endif /* __UCC_GETH_H__ */ 1337#endif /* __UCC_GETH_H__ */
diff --git a/drivers/net/ucc_geth_phy.c b/drivers/net/ucc_geth_phy.c
index 67260eb3188a..5360ec05eaa3 100644
--- a/drivers/net/ucc_geth_phy.c
+++ b/drivers/net/ucc_geth_phy.c
@@ -42,7 +42,6 @@
42 42
43#include "ucc_geth.h" 43#include "ucc_geth.h"
44#include "ucc_geth_phy.h" 44#include "ucc_geth_phy.h"
45#include <platforms/83xx/mpc8360e_pb.h>
46 45
47#define ugphy_printk(level, format, arg...) \ 46#define ugphy_printk(level, format, arg...) \
48 printk(level format "\n", ## arg) 47 printk(level format "\n", ## arg)
@@ -72,16 +71,14 @@ static int genmii_read_status(struct ugeth_mii_info *mii_info);
72u16 phy_read(struct ugeth_mii_info *mii_info, u16 regnum); 71u16 phy_read(struct ugeth_mii_info *mii_info, u16 regnum);
73void phy_write(struct ugeth_mii_info *mii_info, u16 regnum, u16 val); 72void phy_write(struct ugeth_mii_info *mii_info, u16 regnum, u16 val);
74 73
75static u8 *bcsr_regs = NULL;
76
77/* Write value to the PHY for this device to the register at regnum, */ 74/* Write value to the PHY for this device to the register at regnum, */
78/* waiting until the write is done before it returns. All PHY */ 75/* waiting until the write is done before it returns. All PHY */
79/* configuration has to be done through the TSEC1 MIIM regs */ 76/* configuration has to be done through the TSEC1 MIIM regs */
80void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value) 77void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value)
81{ 78{
82 ucc_geth_private_t *ugeth = netdev_priv(dev); 79 struct ucc_geth_private *ugeth = netdev_priv(dev);
83 ucc_mii_mng_t *mii_regs; 80 struct ucc_mii_mng *mii_regs;
84 enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum; 81 enum enet_tbi_mii_reg mii_reg = (enum enet_tbi_mii_reg) regnum;
85 u32 tmp_reg; 82 u32 tmp_reg;
86 83
87 ugphy_vdbg("%s: IN", __FUNCTION__); 84 ugphy_vdbg("%s: IN", __FUNCTION__);
@@ -116,9 +113,9 @@ void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value)
116/* configuration has to be done through the TSEC1 MIIM regs */ 113/* configuration has to be done through the TSEC1 MIIM regs */
117int read_phy_reg(struct net_device *dev, int mii_id, int regnum) 114int read_phy_reg(struct net_device *dev, int mii_id, int regnum)
118{ 115{
119 ucc_geth_private_t *ugeth = netdev_priv(dev); 116 struct ucc_geth_private *ugeth = netdev_priv(dev);
120 ucc_mii_mng_t *mii_regs; 117 struct ucc_mii_mng *mii_regs;
121 enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum; 118 enum enet_tbi_mii_reg mii_reg = (enum enet_tbi_mii_reg) regnum;
122 u32 tmp_reg; 119 u32 tmp_reg;
123 u16 value; 120 u16 value;
124 121
@@ -634,11 +631,6 @@ static void dm9161_close(struct ugeth_mii_info *mii_info)
634 631
635static int dm9161_ack_interrupt(struct ugeth_mii_info *mii_info) 632static int dm9161_ack_interrupt(struct ugeth_mii_info *mii_info)
636{ 633{
637/* FIXME: This lines are for BUG fixing in the mpc8325.
638Remove this from here when it's fixed */
639 if (bcsr_regs == NULL)
640 bcsr_regs = (u8 *) ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
641 bcsr_regs[14] |= 0x40;
642 ugphy_vdbg("%s: IN", __FUNCTION__); 634 ugphy_vdbg("%s: IN", __FUNCTION__);
643 635
644 /* Clear the interrupts by reading the reg */ 636 /* Clear the interrupts by reading the reg */
@@ -650,12 +642,6 @@ Remove this from here when it's fixed */
650 642
651static int dm9161_config_intr(struct ugeth_mii_info *mii_info) 643static int dm9161_config_intr(struct ugeth_mii_info *mii_info)
652{ 644{
653/* FIXME: This lines are for BUG fixing in the mpc8325.
654Remove this from here when it's fixed */
655 if (bcsr_regs == NULL) {
656 bcsr_regs = (u8 *) ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
657 bcsr_regs[14] &= ~0x40;
658 }
659 ugphy_vdbg("%s: IN", __FUNCTION__); 645 ugphy_vdbg("%s: IN", __FUNCTION__);
660 646
661 if (mii_info->interrupts == MII_INTERRUPT_ENABLED) 647 if (mii_info->interrupts == MII_INTERRUPT_ENABLED)
diff --git a/drivers/net/ucc_geth_phy.h b/drivers/net/ucc_geth_phy.h
index 2f98b8f1bb0a..f5740783670f 100644
--- a/drivers/net/ucc_geth_phy.h
+++ b/drivers/net/ucc_geth_phy.h
@@ -126,7 +126,7 @@ struct ugeth_mii_info {
126 /* And management functions */ 126 /* And management functions */
127 struct phy_info *phyinfo; 127 struct phy_info *phyinfo;
128 128
129 ucc_mii_mng_t *mii_regs; 129 struct ucc_mii_mng *mii_regs;
130 130
131 /* forced speed & duplex (no autoneg) 131 /* forced speed & duplex (no autoneg)
132 * partner speed & duplex & pause (autoneg) 132 * partner speed & duplex & pause (autoneg)
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 58b7efbb0750..b5d0d7fb647a 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -127,7 +127,7 @@ config LANMEDIA
127# There is no way to detect a Sealevel board. Force it modular 127# There is no way to detect a Sealevel board. Force it modular
128config SEALEVEL_4021 128config SEALEVEL_4021
129 tristate "Sealevel Systems 4021 support" 129 tristate "Sealevel Systems 4021 support"
130 depends on WAN && ISA && m && ISA_DMA_API 130 depends on WAN && ISA && m && ISA_DMA_API && INET
131 help 131 help
132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. 132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
133 133
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
index dcf46add3adf..5c322dfb79f6 100644
--- a/drivers/net/wan/n2.c
+++ b/drivers/net/wan/n2.c
@@ -500,7 +500,7 @@ static int __init n2_init(void)
500#ifdef MODULE 500#ifdef MODULE
501 printk(KERN_INFO "n2: no card initialized\n"); 501 printk(KERN_INFO "n2: no card initialized\n");
502#endif 502#endif
503 return -ENOSYS; /* no parameters specified, abort */ 503 return -EINVAL; /* no parameters specified, abort */
504 } 504 }
505 505
506 printk(KERN_INFO "%s\n", version); 506 printk(KERN_INFO "%s\n", version);
@@ -538,11 +538,11 @@ static int __init n2_init(void)
538 n2_run(io, irq, ram, valid[0], valid[1]); 538 n2_run(io, irq, ram, valid[0], valid[1]);
539 539
540 if (*hw == '\x0') 540 if (*hw == '\x0')
541 return first_card ? 0 : -ENOSYS; 541 return first_card ? 0 : -EINVAL;
542 }while(*hw++ == ':'); 542 }while(*hw++ == ':');
543 543
544 printk(KERN_ERR "n2: invalid hardware parameters\n"); 544 printk(KERN_ERR "n2: invalid hardware parameters\n");
545 return first_card ? 0 : -ENOSYS; 545 return first_card ? 0 : -EINVAL;
546} 546}
547 547
548 548
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 5823e3bca178..36d1c3ff7078 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -2867,7 +2867,6 @@ static int ch_config(pc300dev_t * d)
2867 uclong clktype = chan->conf.phys_settings.clock_type; 2867 uclong clktype = chan->conf.phys_settings.clock_type;
2868 ucshort encoding = chan->conf.proto_settings.encoding; 2868 ucshort encoding = chan->conf.proto_settings.encoding;
2869 ucshort parity = chan->conf.proto_settings.parity; 2869 ucshort parity = chan->conf.proto_settings.parity;
2870 int tmc, br;
2871 ucchar md0, md2; 2870 ucchar md0, md2;
2872 2871
2873 /* Reset the channel */ 2872 /* Reset the channel */
@@ -2940,8 +2939,12 @@ static int ch_config(pc300dev_t * d)
2940 case PC300_RSV: 2939 case PC300_RSV:
2941 case PC300_X21: 2940 case PC300_X21:
2942 if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) { 2941 if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) {
2942 int tmc, br;
2943
2943 /* Calculate the clkrate parameters */ 2944 /* Calculate the clkrate parameters */
2944 tmc = clock_rate_calc(clkrate, card->hw.clock, &br); 2945 tmc = clock_rate_calc(clkrate, card->hw.clock, &br);
2946 if (tmc < 0)
2947 return -EIO;
2945 cpc_writeb(scabase + M_REG(TMCT, ch), tmc); 2948 cpc_writeb(scabase + M_REG(TMCT, ch), tmc);
2946 cpc_writeb(scabase + M_REG(TXS, ch), 2949 cpc_writeb(scabase + M_REG(TXS, ch),
2947 (TXS_DTRXC | TXS_IBRG | br)); 2950 (TXS_DTRXC | TXS_IBRG | br));
@@ -3097,14 +3100,16 @@ static int cpc_attach(struct net_device *dev, unsigned short encoding,
3097 return 0; 3100 return 0;
3098} 3101}
3099 3102
3100static void cpc_opench(pc300dev_t * d) 3103static int cpc_opench(pc300dev_t * d)
3101{ 3104{
3102 pc300ch_t *chan = (pc300ch_t *) d->chan; 3105 pc300ch_t *chan = (pc300ch_t *) d->chan;
3103 pc300_t *card = (pc300_t *) chan->card; 3106 pc300_t *card = (pc300_t *) chan->card;
3104 int ch = chan->channel; 3107 int ch = chan->channel, rc;
3105 void __iomem *scabase = card->hw.scabase; 3108 void __iomem *scabase = card->hw.scabase;
3106 3109
3107 ch_config(d); 3110 rc = ch_config(d);
3111 if (rc)
3112 return rc;
3108 3113
3109 rx_config(d); 3114 rx_config(d);
3110 3115
@@ -3113,6 +3118,8 @@ static void cpc_opench(pc300dev_t * d)
3113 /* Assert RTS and DTR */ 3118 /* Assert RTS and DTR */
3114 cpc_writeb(scabase + M_REG(CTL, ch), 3119 cpc_writeb(scabase + M_REG(CTL, ch),
3115 cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR)); 3120 cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR));
3121
3122 return 0;
3116} 3123}
3117 3124
3118static void cpc_closech(pc300dev_t * d) 3125static void cpc_closech(pc300dev_t * d)
@@ -3168,9 +3175,16 @@ int cpc_open(struct net_device *dev)
3168 } 3175 }
3169 3176
3170 sprintf(ifr.ifr_name, "%s", dev->name); 3177 sprintf(ifr.ifr_name, "%s", dev->name);
3171 cpc_opench(d); 3178 result = cpc_opench(d);
3179 if (result)
3180 goto err_out;
3181
3172 netif_start_queue(dev); 3182 netif_start_queue(dev);
3173 return 0; 3183 return 0;
3184
3185err_out:
3186 hdlc_close(dev);
3187 return result;
3174} 3188}
3175 3189
3176static int cpc_close(struct net_device *dev) 3190static int cpc_close(struct net_device *dev)
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 0a33c8a56e13..efcdaf1c5f73 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2897,6 +2897,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2897 goto err_out_map; 2897 goto err_out_map;
2898 } 2898 }
2899 ai->wifidev = init_wifidev(ai, dev); 2899 ai->wifidev = init_wifidev(ai, dev);
2900 if (!ai->wifidev)
2901 goto err_out_reg;
2900 2902
2901 set_bit(FLAG_REGISTERED,&ai->flags); 2903 set_bit(FLAG_REGISTERED,&ai->flags);
2902 airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x", 2904 airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x",
@@ -2908,11 +2910,18 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2908 for( i = 0; i < MAX_FIDS; i++ ) 2910 for( i = 0; i < MAX_FIDS; i++ )
2909 ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2); 2911 ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
2910 2912
2911 setup_proc_entry( dev, dev->priv ); /* XXX check for failure */ 2913 if (setup_proc_entry(dev, dev->priv) < 0)
2914 goto err_out_wifi;
2915
2912 netif_start_queue(dev); 2916 netif_start_queue(dev);
2913 SET_MODULE_OWNER(dev); 2917 SET_MODULE_OWNER(dev);
2914 return dev; 2918 return dev;
2915 2919
2920err_out_wifi:
2921 unregister_netdev(ai->wifidev);
2922 free_netdev(ai->wifidev);
2923err_out_reg:
2924 unregister_netdev(dev);
2916err_out_map: 2925err_out_map:
2917 if (test_bit(FLAG_MPI,&ai->flags) && pci) { 2926 if (test_bit(FLAG_MPI,&ai->flags) && pci) {
2918 pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma); 2927 pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma);
@@ -3089,7 +3098,8 @@ static int airo_thread(void *data) {
3089 set_bit(JOB_AUTOWEP, &ai->jobs); 3098 set_bit(JOB_AUTOWEP, &ai->jobs);
3090 break; 3099 break;
3091 } 3100 }
3092 if (!kthread_should_stop()) { 3101 if (!kthread_should_stop() &&
3102 !freezing(current)) {
3093 unsigned long wake_at; 3103 unsigned long wake_at;
3094 if (!ai->expires || !ai->scan_timeout) { 3104 if (!ai->expires || !ai->scan_timeout) {
3095 wake_at = max(ai->expires, 3105 wake_at = max(ai->expires,
@@ -3101,7 +3111,8 @@ static int airo_thread(void *data) {
3101 schedule_timeout(wake_at - jiffies); 3111 schedule_timeout(wake_at - jiffies);
3102 continue; 3112 continue;
3103 } 3113 }
3104 } else if (!kthread_should_stop()) { 3114 } else if (!kthread_should_stop() &&
3115 !freezing(current)) {
3105 schedule(); 3116 schedule();
3106 continue; 3117 continue;
3107 } 3118 }
@@ -4495,91 +4506,128 @@ static int setup_proc_entry( struct net_device *dev,
4495 apriv->proc_entry = create_proc_entry(apriv->proc_name, 4506 apriv->proc_entry = create_proc_entry(apriv->proc_name,
4496 S_IFDIR|airo_perm, 4507 S_IFDIR|airo_perm,
4497 airo_entry); 4508 airo_entry);
4498 apriv->proc_entry->uid = proc_uid; 4509 if (!apriv->proc_entry)
4499 apriv->proc_entry->gid = proc_gid; 4510 goto fail;
4500 apriv->proc_entry->owner = THIS_MODULE; 4511 apriv->proc_entry->uid = proc_uid;
4512 apriv->proc_entry->gid = proc_gid;
4513 apriv->proc_entry->owner = THIS_MODULE;
4501 4514
4502 /* Setup the StatsDelta */ 4515 /* Setup the StatsDelta */
4503 entry = create_proc_entry("StatsDelta", 4516 entry = create_proc_entry("StatsDelta",
4504 S_IFREG | (S_IRUGO&proc_perm), 4517 S_IFREG | (S_IRUGO&proc_perm),
4505 apriv->proc_entry); 4518 apriv->proc_entry);
4506 entry->uid = proc_uid; 4519 if (!entry)
4507 entry->gid = proc_gid; 4520 goto fail_stats_delta;
4521 entry->uid = proc_uid;
4522 entry->gid = proc_gid;
4508 entry->data = dev; 4523 entry->data = dev;
4509 entry->owner = THIS_MODULE; 4524 entry->owner = THIS_MODULE;
4510 SETPROC_OPS(entry, proc_statsdelta_ops); 4525 SETPROC_OPS(entry, proc_statsdelta_ops);
4511 4526
4512 /* Setup the Stats */ 4527 /* Setup the Stats */
4513 entry = create_proc_entry("Stats", 4528 entry = create_proc_entry("Stats",
4514 S_IFREG | (S_IRUGO&proc_perm), 4529 S_IFREG | (S_IRUGO&proc_perm),
4515 apriv->proc_entry); 4530 apriv->proc_entry);
4516 entry->uid = proc_uid; 4531 if (!entry)
4517 entry->gid = proc_gid; 4532 goto fail_stats;
4533 entry->uid = proc_uid;
4534 entry->gid = proc_gid;
4518 entry->data = dev; 4535 entry->data = dev;
4519 entry->owner = THIS_MODULE; 4536 entry->owner = THIS_MODULE;
4520 SETPROC_OPS(entry, proc_stats_ops); 4537 SETPROC_OPS(entry, proc_stats_ops);
4521 4538
4522 /* Setup the Status */ 4539 /* Setup the Status */
4523 entry = create_proc_entry("Status", 4540 entry = create_proc_entry("Status",
4524 S_IFREG | (S_IRUGO&proc_perm), 4541 S_IFREG | (S_IRUGO&proc_perm),
4525 apriv->proc_entry); 4542 apriv->proc_entry);
4526 entry->uid = proc_uid; 4543 if (!entry)
4527 entry->gid = proc_gid; 4544 goto fail_status;
4545 entry->uid = proc_uid;
4546 entry->gid = proc_gid;
4528 entry->data = dev; 4547 entry->data = dev;
4529 entry->owner = THIS_MODULE; 4548 entry->owner = THIS_MODULE;
4530 SETPROC_OPS(entry, proc_status_ops); 4549 SETPROC_OPS(entry, proc_status_ops);
4531 4550
4532 /* Setup the Config */ 4551 /* Setup the Config */
4533 entry = create_proc_entry("Config", 4552 entry = create_proc_entry("Config",
4534 S_IFREG | proc_perm, 4553 S_IFREG | proc_perm,
4535 apriv->proc_entry); 4554 apriv->proc_entry);
4536 entry->uid = proc_uid; 4555 if (!entry)
4537 entry->gid = proc_gid; 4556 goto fail_config;
4557 entry->uid = proc_uid;
4558 entry->gid = proc_gid;
4538 entry->data = dev; 4559 entry->data = dev;
4539 entry->owner = THIS_MODULE; 4560 entry->owner = THIS_MODULE;
4540 SETPROC_OPS(entry, proc_config_ops); 4561 SETPROC_OPS(entry, proc_config_ops);
4541 4562
4542 /* Setup the SSID */ 4563 /* Setup the SSID */
4543 entry = create_proc_entry("SSID", 4564 entry = create_proc_entry("SSID",
4544 S_IFREG | proc_perm, 4565 S_IFREG | proc_perm,
4545 apriv->proc_entry); 4566 apriv->proc_entry);
4546 entry->uid = proc_uid; 4567 if (!entry)
4547 entry->gid = proc_gid; 4568 goto fail_ssid;
4569 entry->uid = proc_uid;
4570 entry->gid = proc_gid;
4548 entry->data = dev; 4571 entry->data = dev;
4549 entry->owner = THIS_MODULE; 4572 entry->owner = THIS_MODULE;
4550 SETPROC_OPS(entry, proc_SSID_ops); 4573 SETPROC_OPS(entry, proc_SSID_ops);
4551 4574
4552 /* Setup the APList */ 4575 /* Setup the APList */
4553 entry = create_proc_entry("APList", 4576 entry = create_proc_entry("APList",
4554 S_IFREG | proc_perm, 4577 S_IFREG | proc_perm,
4555 apriv->proc_entry); 4578 apriv->proc_entry);
4556 entry->uid = proc_uid; 4579 if (!entry)
4557 entry->gid = proc_gid; 4580 goto fail_aplist;
4581 entry->uid = proc_uid;
4582 entry->gid = proc_gid;
4558 entry->data = dev; 4583 entry->data = dev;
4559 entry->owner = THIS_MODULE; 4584 entry->owner = THIS_MODULE;
4560 SETPROC_OPS(entry, proc_APList_ops); 4585 SETPROC_OPS(entry, proc_APList_ops);
4561 4586
4562 /* Setup the BSSList */ 4587 /* Setup the BSSList */
4563 entry = create_proc_entry("BSSList", 4588 entry = create_proc_entry("BSSList",
4564 S_IFREG | proc_perm, 4589 S_IFREG | proc_perm,
4565 apriv->proc_entry); 4590 apriv->proc_entry);
4591 if (!entry)
4592 goto fail_bsslist;
4566 entry->uid = proc_uid; 4593 entry->uid = proc_uid;
4567 entry->gid = proc_gid; 4594 entry->gid = proc_gid;
4568 entry->data = dev; 4595 entry->data = dev;
4569 entry->owner = THIS_MODULE; 4596 entry->owner = THIS_MODULE;
4570 SETPROC_OPS(entry, proc_BSSList_ops); 4597 SETPROC_OPS(entry, proc_BSSList_ops);
4571 4598
4572 /* Setup the WepKey */ 4599 /* Setup the WepKey */
4573 entry = create_proc_entry("WepKey", 4600 entry = create_proc_entry("WepKey",
4574 S_IFREG | proc_perm, 4601 S_IFREG | proc_perm,
4575 apriv->proc_entry); 4602 apriv->proc_entry);
4576 entry->uid = proc_uid; 4603 if (!entry)
4577 entry->gid = proc_gid; 4604 goto fail_wepkey;
4605 entry->uid = proc_uid;
4606 entry->gid = proc_gid;
4578 entry->data = dev; 4607 entry->data = dev;
4579 entry->owner = THIS_MODULE; 4608 entry->owner = THIS_MODULE;
4580 SETPROC_OPS(entry, proc_wepkey_ops); 4609 SETPROC_OPS(entry, proc_wepkey_ops);
4581 4610
4582 return 0; 4611 return 0;
4612
4613fail_wepkey:
4614 remove_proc_entry("BSSList", apriv->proc_entry);
4615fail_bsslist:
4616 remove_proc_entry("APList", apriv->proc_entry);
4617fail_aplist:
4618 remove_proc_entry("SSID", apriv->proc_entry);
4619fail_ssid:
4620 remove_proc_entry("Config", apriv->proc_entry);
4621fail_config:
4622 remove_proc_entry("Status", apriv->proc_entry);
4623fail_status:
4624 remove_proc_entry("Stats", apriv->proc_entry);
4625fail_stats:
4626 remove_proc_entry("StatsDelta", apriv->proc_entry);
4627fail_stats_delta:
4628 remove_proc_entry(apriv->proc_name, airo_entry);
4629fail:
4630 return -ENOMEM;
4583} 4631}
4584 4632
4585static int takedown_proc_entry( struct net_device *dev, 4633static int takedown_proc_entry( struct net_device *dev,
@@ -5924,7 +5972,6 @@ static int airo_get_essid(struct net_device *dev,
5924 5972
5925 /* Get the current SSID */ 5973 /* Get the current SSID */
5926 memcpy(extra, status_rid.SSID, status_rid.SSIDlen); 5974 memcpy(extra, status_rid.SSID, status_rid.SSIDlen);
5927 extra[status_rid.SSIDlen] = '\0';
5928 /* If none, we may want to get the one that was set */ 5975 /* If none, we may want to get the one that was set */
5929 5976
5930 /* Push it out ! */ 5977 /* Push it out ! */
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 31eed85de60f..0c07b8b7250d 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1678,11 +1678,9 @@ static int atmel_get_essid(struct net_device *dev,
1678 /* Get the current SSID */ 1678 /* Get the current SSID */
1679 if (priv->new_SSID_size != 0) { 1679 if (priv->new_SSID_size != 0) {
1680 memcpy(extra, priv->new_SSID, priv->new_SSID_size); 1680 memcpy(extra, priv->new_SSID, priv->new_SSID_size);
1681 extra[priv->new_SSID_size] = '\0';
1682 dwrq->length = priv->new_SSID_size; 1681 dwrq->length = priv->new_SSID_size;
1683 } else { 1682 } else {
1684 memcpy(extra, priv->SSID, priv->SSID_size); 1683 memcpy(extra, priv->SSID, priv->SSID_size);
1685 extra[priv->SSID_size] = '\0';
1686 dwrq->length = priv->SSID_size; 1684 dwrq->length = priv->SSID_size;
1687 } 1685 }
1688 1686
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
index 76e3aed4b471..978ed099e285 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
@@ -705,11 +705,30 @@ int bcm43xx_dma_init(struct bcm43xx_private *bcm)
705 struct bcm43xx_dmaring *ring; 705 struct bcm43xx_dmaring *ring;
706 int err = -ENOMEM; 706 int err = -ENOMEM;
707 int dma64 = 0; 707 int dma64 = 0;
708 u32 sbtmstatehi; 708 u64 mask = bcm43xx_get_supported_dma_mask(bcm);
709 int nobits;
709 710
710 sbtmstatehi = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH); 711 if (mask == DMA_64BIT_MASK) {
711 if (sbtmstatehi & BCM43xx_SBTMSTATEHIGH_DMA64BIT)
712 dma64 = 1; 712 dma64 = 1;
713 nobits = 64;
714 } else if (mask == DMA_32BIT_MASK)
715 nobits = 32;
716 else
717 nobits = 30;
718 err = pci_set_dma_mask(bcm->pci_dev, mask);
719 err |= pci_set_consistent_dma_mask(bcm->pci_dev, mask);
720 if (err) {
721#ifdef CONFIG_BCM43XX_PIO
722 printk(KERN_WARNING PFX "DMA not supported on this device."
723 " Falling back to PIO.\n");
724 bcm->__using_pio = 1;
725 return -ENOSYS;
726#else
727 printk(KERN_ERR PFX "FATAL: DMA not supported and PIO not configured. "
728 "Please recompile the driver with PIO support.\n");
729 return -ENODEV;
730#endif /* CONFIG_BCM43XX_PIO */
731 }
713 732
714 /* setup TX DMA channels. */ 733 /* setup TX DMA channels. */
715 ring = bcm43xx_setup_dmaring(bcm, 0, 1, dma64); 734 ring = bcm43xx_setup_dmaring(bcm, 0, 1, dma64);
@@ -755,8 +774,7 @@ int bcm43xx_dma_init(struct bcm43xx_private *bcm)
755 dma->rx_ring3 = ring; 774 dma->rx_ring3 = ring;
756 } 775 }
757 776
758 dprintk(KERN_INFO PFX "%s DMA initialized\n", 777 dprintk(KERN_INFO PFX "%d-bit DMA initialized\n", nobits);
759 dma64 ? "64-bit" : "32-bit");
760 err = 0; 778 err = 0;
761out: 779out:
762 return err; 780 return err;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
index e04bcaddd1d0..d1105e569a41 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
@@ -4,6 +4,7 @@
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/spinlock.h> 5#include <linux/spinlock.h>
6#include <linux/workqueue.h> 6#include <linux/workqueue.h>
7#include <linux/dma-mapping.h>
7#include <linux/linkage.h> 8#include <linux/linkage.h>
8#include <asm/atomic.h> 9#include <asm/atomic.h>
9 10
@@ -314,6 +315,23 @@ int bcm43xx_dma_tx(struct bcm43xx_private *bcm,
314 struct ieee80211_txb *txb); 315 struct ieee80211_txb *txb);
315void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring); 316void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring);
316 317
318/* Helper function that returns the dma mask for this device. */
319static inline
320u64 bcm43xx_get_supported_dma_mask(struct bcm43xx_private *bcm)
321{
322 int dma64 = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH) &
323 BCM43xx_SBTMSTATEHIGH_DMA64BIT;
324 u16 mmio_base = bcm43xx_dmacontroller_base(dma64, 0);
325 u32 mask = BCM43xx_DMA32_TXADDREXT_MASK;
326
327 if (dma64)
328 return DMA_64BIT_MASK;
329 bcm43xx_write32(bcm, mmio_base + BCM43xx_DMA32_TXCTL, mask);
330 if (bcm43xx_read32(bcm, mmio_base + BCM43xx_DMA32_TXCTL) & mask)
331 return DMA_32BIT_MASK;
332 return DMA_30BIT_MASK;
333}
334
317#else /* CONFIG_BCM43XX_DMA */ 335#else /* CONFIG_BCM43XX_DMA */
318 336
319 337
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
index c3f90c8563d9..7d383a27b927 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
@@ -189,20 +189,24 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
189 case BCM43xx_LED_INACTIVE: 189 case BCM43xx_LED_INACTIVE:
190 continue; 190 continue;
191 case BCM43xx_LED_OFF: 191 case BCM43xx_LED_OFF:
192 case BCM43xx_LED_BCM4303_3:
192 break; 193 break;
193 case BCM43xx_LED_ON: 194 case BCM43xx_LED_ON:
194 turn_on = 1; 195 turn_on = 1;
195 break; 196 break;
196 case BCM43xx_LED_ACTIVITY: 197 case BCM43xx_LED_ACTIVITY:
198 case BCM43xx_LED_BCM4303_0:
197 turn_on = activity; 199 turn_on = activity;
198 break; 200 break;
199 case BCM43xx_LED_RADIO_ALL: 201 case BCM43xx_LED_RADIO_ALL:
200 turn_on = radio->enabled; 202 turn_on = radio->enabled;
201 break; 203 break;
202 case BCM43xx_LED_RADIO_A: 204 case BCM43xx_LED_RADIO_A:
205 case BCM43xx_LED_BCM4303_2:
203 turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A); 206 turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A);
204 break; 207 break;
205 case BCM43xx_LED_RADIO_B: 208 case BCM43xx_LED_RADIO_B:
209 case BCM43xx_LED_BCM4303_1:
206 turn_on = (radio->enabled && 210 turn_on = (radio->enabled &&
207 (phy->type == BCM43xx_PHYTYPE_B || 211 (phy->type == BCM43xx_PHYTYPE_B ||
208 phy->type == BCM43xx_PHYTYPE_G)); 212 phy->type == BCM43xx_PHYTYPE_G));
@@ -242,7 +246,7 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
242 //TODO 246 //TODO
243 break; 247 break;
244 case BCM43xx_LED_ASSOC: 248 case BCM43xx_LED_ASSOC:
245 if (bcm->softmac->associated) 249 if (bcm->softmac->associnfo.associated)
246 turn_on = 1; 250 turn_on = 1;
247 break; 251 break;
248#ifdef CONFIG_BCM43XX_DEBUG 252#ifdef CONFIG_BCM43XX_DEBUG
@@ -257,7 +261,8 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
257 continue; 261 continue;
258#endif /* CONFIG_BCM43XX_DEBUG */ 262#endif /* CONFIG_BCM43XX_DEBUG */
259 default: 263 default:
260 assert(0); 264 dprintkl(KERN_INFO PFX "Bad value in leds_update,"
265 " led->behaviour: 0x%x\n", led->behaviour);
261 }; 266 };
262 267
263 if (led->activelow) 268 if (led->activelow)
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.h b/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
index d3716cf3aebc..811e14a81198 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
@@ -46,6 +46,12 @@ enum { /* LED behaviour values */
46 BCM43xx_LED_TEST_BLINKSLOW, 46 BCM43xx_LED_TEST_BLINKSLOW,
47 BCM43xx_LED_TEST_BLINKMEDIUM, 47 BCM43xx_LED_TEST_BLINKMEDIUM,
48 BCM43xx_LED_TEST_BLINKFAST, 48 BCM43xx_LED_TEST_BLINKFAST,
49
50 /* Misc values for BCM4303 */
51 BCM43xx_LED_BCM4303_0 = 0x2B,
52 BCM43xx_LED_BCM4303_1 = 0x78,
53 BCM43xx_LED_BCM4303_2 = 0x2E,
54 BCM43xx_LED_BCM4303_3 = 0x19,
49}; 55};
50 56
51int bcm43xx_leds_init(struct bcm43xx_private *bcm); 57int bcm43xx_leds_init(struct bcm43xx_private *bcm);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index bad3452ea893..a1b783813d8e 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -746,7 +746,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom)
746 if (err) 746 if (err)
747 goto err_ctlreg; 747 goto err_ctlreg;
748 spromctl |= 0x10; /* SPROM WRITE enable. */ 748 spromctl |= 0x10; /* SPROM WRITE enable. */
749 bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); 749 err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl);
750 if (err) 750 if (err)
751 goto err_ctlreg; 751 goto err_ctlreg;
752 /* We must burn lots of CPU cycles here, but that does not 752 /* We must burn lots of CPU cycles here, but that does not
@@ -768,7 +768,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom)
768 mdelay(20); 768 mdelay(20);
769 } 769 }
770 spromctl &= ~0x10; /* SPROM WRITE enable. */ 770 spromctl &= ~0x10; /* SPROM WRITE enable. */
771 bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); 771 err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl);
772 if (err) 772 if (err)
773 goto err_ctlreg; 773 goto err_ctlreg;
774 mdelay(500); 774 mdelay(500);
@@ -1463,6 +1463,23 @@ static void handle_irq_transmit_status(struct bcm43xx_private *bcm)
1463 } 1463 }
1464} 1464}
1465 1465
1466static void drain_txstatus_queue(struct bcm43xx_private *bcm)
1467{
1468 u32 dummy;
1469
1470 if (bcm->current_core->rev < 5)
1471 return;
1472 /* Read all entries from the microcode TXstatus FIFO
1473 * and throw them away.
1474 */
1475 while (1) {
1476 dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_0);
1477 if (!dummy)
1478 break;
1479 dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_1);
1480 }
1481}
1482
1466static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm) 1483static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm)
1467{ 1484{
1468 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F); 1485 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F);
@@ -2925,10 +2942,13 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm,
2925 bcm43xx_write16(bcm, 0x043C, 0x000C); 2942 bcm43xx_write16(bcm, 0x043C, 0x000C);
2926 2943
2927 if (active_wlcore) { 2944 if (active_wlcore) {
2928 if (bcm43xx_using_pio(bcm)) 2945 if (bcm43xx_using_pio(bcm)) {
2929 err = bcm43xx_pio_init(bcm); 2946 err = bcm43xx_pio_init(bcm);
2930 else 2947 } else {
2931 err = bcm43xx_dma_init(bcm); 2948 err = bcm43xx_dma_init(bcm);
2949 if (err == -ENOSYS)
2950 err = bcm43xx_pio_init(bcm);
2951 }
2932 if (err) 2952 if (err)
2933 goto err_chip_cleanup; 2953 goto err_chip_cleanup;
2934 } 2954 }
@@ -3160,17 +3180,30 @@ static int estimate_periodic_work_badness(unsigned int state)
3160static void bcm43xx_periodic_work_handler(void *d) 3180static void bcm43xx_periodic_work_handler(void *d)
3161{ 3181{
3162 struct bcm43xx_private *bcm = d; 3182 struct bcm43xx_private *bcm = d;
3183 struct net_device *net_dev = bcm->net_dev;
3163 unsigned long flags; 3184 unsigned long flags;
3164 u32 savedirqs = 0; 3185 u32 savedirqs = 0;
3165 int badness; 3186 int badness;
3187 unsigned long orig_trans_start = 0;
3166 3188
3189 mutex_lock(&bcm->mutex);
3167 badness = estimate_periodic_work_badness(bcm->periodic_state); 3190 badness = estimate_periodic_work_badness(bcm->periodic_state);
3168 if (badness > BADNESS_LIMIT) { 3191 if (badness > BADNESS_LIMIT) {
3169 /* Periodic work will take a long time, so we want it to 3192 /* Periodic work will take a long time, so we want it to
3170 * be preemtible. 3193 * be preemtible.
3171 */ 3194 */
3172 mutex_lock(&bcm->mutex); 3195
3173 netif_tx_disable(bcm->net_dev); 3196 netif_tx_lock_bh(net_dev);
3197 /* We must fake a started transmission here, as we are going to
3198 * disable TX. If we wouldn't fake a TX, it would be possible to
3199 * trigger the netdev watchdog, if the last real TX is already
3200 * some time on the past (slightly less than 5secs)
3201 */
3202 orig_trans_start = net_dev->trans_start;
3203 net_dev->trans_start = jiffies;
3204 netif_stop_queue(net_dev);
3205 netif_tx_unlock_bh(net_dev);
3206
3174 spin_lock_irqsave(&bcm->irq_lock, flags); 3207 spin_lock_irqsave(&bcm->irq_lock, flags);
3175 bcm43xx_mac_suspend(bcm); 3208 bcm43xx_mac_suspend(bcm);
3176 if (bcm43xx_using_pio(bcm)) 3209 if (bcm43xx_using_pio(bcm))
@@ -3182,7 +3215,6 @@ static void bcm43xx_periodic_work_handler(void *d)
3182 /* Periodic work should take short time, so we want low 3215 /* Periodic work should take short time, so we want low
3183 * locking overhead. 3216 * locking overhead.
3184 */ 3217 */
3185 mutex_lock(&bcm->mutex);
3186 spin_lock_irqsave(&bcm->irq_lock, flags); 3218 spin_lock_irqsave(&bcm->irq_lock, flags);
3187 } 3219 }
3188 3220
@@ -3196,6 +3228,7 @@ static void bcm43xx_periodic_work_handler(void *d)
3196 bcm43xx_pio_thaw_txqueues(bcm); 3228 bcm43xx_pio_thaw_txqueues(bcm);
3197 bcm43xx_mac_enable(bcm); 3229 bcm43xx_mac_enable(bcm);
3198 netif_wake_queue(bcm->net_dev); 3230 netif_wake_queue(bcm->net_dev);
3231 net_dev->trans_start = orig_trans_start;
3199 } 3232 }
3200 mmiowb(); 3233 mmiowb();
3201 spin_unlock_irqrestore(&bcm->irq_lock, flags); 3234 spin_unlock_irqrestore(&bcm->irq_lock, flags);
@@ -3516,6 +3549,7 @@ int bcm43xx_select_wireless_core(struct bcm43xx_private *bcm,
3516 bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC); 3549 bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC);
3517 bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr)); 3550 bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr));
3518 bcm43xx_security_init(bcm); 3551 bcm43xx_security_init(bcm);
3552 drain_txstatus_queue(bcm);
3519 ieee80211softmac_start(bcm->net_dev); 3553 ieee80211softmac_start(bcm->net_dev);
3520 3554
3521 /* Let's go! Be careful after enabling the IRQs. 3555 /* Let's go! Be careful after enabling the IRQs.
@@ -3993,8 +4027,6 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
3993 struct net_device *net_dev, 4027 struct net_device *net_dev,
3994 struct pci_dev *pci_dev) 4028 struct pci_dev *pci_dev)
3995{ 4029{
3996 int err;
3997
3998 bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT); 4030 bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT);
3999 bcm->ieee = netdev_priv(net_dev); 4031 bcm->ieee = netdev_priv(net_dev);
4000 bcm->softmac = ieee80211_priv(net_dev); 4032 bcm->softmac = ieee80211_priv(net_dev);
@@ -4012,22 +4044,8 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
4012 (void (*)(unsigned long))bcm43xx_interrupt_tasklet, 4044 (void (*)(unsigned long))bcm43xx_interrupt_tasklet,
4013 (unsigned long)bcm); 4045 (unsigned long)bcm);
4014 tasklet_disable_nosync(&bcm->isr_tasklet); 4046 tasklet_disable_nosync(&bcm->isr_tasklet);
4015 if (modparam_pio) { 4047 if (modparam_pio)
4016 bcm->__using_pio = 1; 4048 bcm->__using_pio = 1;
4017 } else {
4018 err = pci_set_dma_mask(pci_dev, DMA_30BIT_MASK);
4019 err |= pci_set_consistent_dma_mask(pci_dev, DMA_30BIT_MASK);
4020 if (err) {
4021#ifdef CONFIG_BCM43XX_PIO
4022 printk(KERN_WARNING PFX "DMA not supported. Falling back to PIO.\n");
4023 bcm->__using_pio = 1;
4024#else
4025 printk(KERN_ERR PFX "FATAL: DMA not supported and PIO not configured. "
4026 "Recompile the driver with PIO support, please.\n");
4027 return -ENODEV;
4028#endif /* CONFIG_BCM43XX_PIO */
4029 }
4030 }
4031 bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD; 4049 bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD;
4032 4050
4033 /* default to sw encryption for now */ 4051 /* default to sw encryption for now */
@@ -4208,7 +4226,11 @@ static int bcm43xx_resume(struct pci_dev *pdev)
4208 dprintk(KERN_INFO PFX "Resuming...\n"); 4226 dprintk(KERN_INFO PFX "Resuming...\n");
4209 4227
4210 pci_set_power_state(pdev, 0); 4228 pci_set_power_state(pdev, 0);
4211 pci_enable_device(pdev); 4229 err = pci_enable_device(pdev);
4230 if (err) {
4231 printk(KERN_ERR PFX "Failure with pci_enable_device!\n");
4232 return err;
4233 }
4212 pci_restore_state(pdev); 4234 pci_restore_state(pdev);
4213 4235
4214 bcm43xx_chipset_attach(bcm); 4236 bcm43xx_chipset_attach(bcm);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index 9b7b15cf6561..d27016f8c736 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -847,7 +847,7 @@ static struct iw_statistics *bcm43xx_get_wireless_stats(struct net_device *net_d
847 unsigned long flags; 847 unsigned long flags;
848 848
849 wstats = &bcm->stats.wstats; 849 wstats = &bcm->stats.wstats;
850 if (!mac->associated) { 850 if (!mac->associnfo.associated) {
851 wstats->miss.beacon = 0; 851 wstats->miss.beacon = 0;
852// bcm->ieee->ieee_stats.tx_retry_limit_exceeded = 0; // FIXME: should this be cleared here? 852// bcm->ieee->ieee_stats.tx_retry_limit_exceeded = 0; // FIXME: should this be cleared here?
853 wstats->discard.retries = 0; 853 wstats->discard.retries = 0;
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 686d895116de..f63909e4bc32 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -887,6 +887,13 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
887 PCMCIA_DEVICE_PROD_ID123( 887 PCMCIA_DEVICE_PROD_ID123(
888 "U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02", 888 "U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02",
889 0xc7b8df9d, 0x1700d087, 0x4b74baa0), 889 0xc7b8df9d, 0x1700d087, 0x4b74baa0),
890 PCMCIA_DEVICE_PROD_ID123(
891 "Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio",
892 "Ver. 1.00",
893 0x5cd01705, 0x4271660f, 0x9d08ee12),
894 PCMCIA_DEVICE_PROD_ID123(
895 "corega", "WL PCCL-11", "ISL37300P",
896 0xa21501a, 0x59868926, 0xc9049a39),
890 PCMCIA_DEVICE_NULL 897 PCMCIA_DEVICE_NULL
891}; 898};
892MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids); 899MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index 6dfa041be66d..bc81b13a5a2a 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -364,7 +364,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
364 364
365 pos = 0; 365 pos = 0;
366 while (pos < CIS_MAX_LEN - 1 && cis[pos] != CISTPL_END) { 366 while (pos < CIS_MAX_LEN - 1 && cis[pos] != CISTPL_END) {
367 if (pos + cis[pos + 1] >= CIS_MAX_LEN) 367 if (pos + 2 + cis[pos + 1] > CIS_MAX_LEN)
368 goto cis_error; 368 goto cis_error;
369 369
370 switch (cis[pos]) { 370 switch (cis[pos]) {
@@ -391,7 +391,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
391 break; 391 break;
392 392
393 case CISTPL_MANFID: 393 case CISTPL_MANFID:
394 if (cis[pos + 1] < 5) 394 if (cis[pos + 1] < 4)
395 goto cis_error; 395 goto cis_error;
396 manfid1 = cis[pos + 2] + (cis[pos + 3] << 8); 396 manfid1 = cis[pos + 2] + (cis[pos + 3] << 8);
397 manfid2 = cis[pos + 4] + (cis[pos + 5] << 8); 397 manfid2 = cis[pos + 4] + (cis[pos + 5] << 8);
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index b779c7dcc1a8..336cabac13b3 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -2457,6 +2457,7 @@ void free_orinocodev(struct net_device *dev)
2457/* Wireless extensions */ 2457/* Wireless extensions */
2458/********************************************************************/ 2458/********************************************************************/
2459 2459
2460/* Return : < 0 -> error code ; >= 0 -> length */
2460static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, 2461static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
2461 char buf[IW_ESSID_MAX_SIZE+1]) 2462 char buf[IW_ESSID_MAX_SIZE+1])
2462{ 2463{
@@ -2501,9 +2502,9 @@ static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
2501 len = le16_to_cpu(essidbuf.len); 2502 len = le16_to_cpu(essidbuf.len);
2502 BUG_ON(len > IW_ESSID_MAX_SIZE); 2503 BUG_ON(len > IW_ESSID_MAX_SIZE);
2503 2504
2504 memset(buf, 0, IW_ESSID_MAX_SIZE+1); 2505 memset(buf, 0, IW_ESSID_MAX_SIZE);
2505 memcpy(buf, p, len); 2506 memcpy(buf, p, len);
2506 buf[len] = '\0'; 2507 err = len;
2507 2508
2508 fail_unlock: 2509 fail_unlock:
2509 orinoco_unlock(priv, &flags); 2510 orinoco_unlock(priv, &flags);
@@ -3027,17 +3028,18 @@ static int orinoco_ioctl_getessid(struct net_device *dev,
3027 3028
3028 if (netif_running(dev)) { 3029 if (netif_running(dev)) {
3029 err = orinoco_hw_get_essid(priv, &active, essidbuf); 3030 err = orinoco_hw_get_essid(priv, &active, essidbuf);
3030 if (err) 3031 if (err < 0)
3031 return err; 3032 return err;
3033 erq->length = err;
3032 } else { 3034 } else {
3033 if (orinoco_lock(priv, &flags) != 0) 3035 if (orinoco_lock(priv, &flags) != 0)
3034 return -EBUSY; 3036 return -EBUSY;
3035 memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE + 1); 3037 memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE);
3038 erq->length = strlen(priv->desired_essid);
3036 orinoco_unlock(priv, &flags); 3039 orinoco_unlock(priv, &flags);
3037 } 3040 }
3038 3041
3039 erq->flags = 1; 3042 erq->flags = 1;
3040 erq->length = strlen(essidbuf);
3041 3043
3042 return 0; 3044 return 0;
3043} 3045}
@@ -3075,10 +3077,10 @@ static int orinoco_ioctl_getnick(struct net_device *dev,
3075 if (orinoco_lock(priv, &flags) != 0) 3077 if (orinoco_lock(priv, &flags) != 0)
3076 return -EBUSY; 3078 return -EBUSY;
3077 3079
3078 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE+1); 3080 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE);
3079 orinoco_unlock(priv, &flags); 3081 orinoco_unlock(priv, &flags);
3080 3082
3081 nrq->length = strlen(nickbuf); 3083 nrq->length = strlen(priv->nick);
3082 3084
3083 return 0; 3085 return 0;
3084} 3086}
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 0b381d77015c..7fbfc9e41d07 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -1198,7 +1198,6 @@ static int ray_get_essid(struct net_device *dev,
1198 1198
1199 /* Get the essid that was set */ 1199 /* Get the essid that was set */
1200 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE); 1200 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
1201 extra[IW_ESSID_MAX_SIZE] = '\0';
1202 1201
1203 /* Push it out ! */ 1202 /* Push it out ! */
1204 dwrq->length = strlen(extra); 1203 dwrq->length = strlen(extra);
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 30057a335a7b..36b29ff05814 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -193,10 +193,8 @@ static void zd1201_usbrx(struct urb *urb)
193 struct sk_buff *skb; 193 struct sk_buff *skb;
194 unsigned char type; 194 unsigned char type;
195 195
196 if (!zd) { 196 if (!zd)
197 free = 1; 197 return;
198 goto exit;
199 }
200 198
201 switch(urb->status) { 199 switch(urb->status) {
202 case -EILSEQ: 200 case -EILSEQ:
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 2d12837052b0..a7d29bddb298 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -1099,7 +1099,7 @@ static void link_led_handler(void *p)
1099 int r; 1099 int r;
1100 1100
1101 spin_lock_irq(&mac->lock); 1101 spin_lock_irq(&mac->lock);
1102 is_associated = sm->associated != 0; 1102 is_associated = sm->associnfo.associated != 0;
1103 spin_unlock_irq(&mac->lock); 1103 spin_unlock_irq(&mac->lock);
1104 1104
1105 r = zd_chip_control_leds(chip, 1105 r = zd_chip_control_leds(chip,
diff --git a/drivers/parport/parport_ip32.c b/drivers/parport/parport_ip32.c
index e3e19277030a..ec44efdbb84e 100644
--- a/drivers/parport/parport_ip32.c
+++ b/drivers/parport/parport_ip32.c
@@ -780,7 +780,7 @@ static irqreturn_t parport_ip32_interrupt(int irq, void *dev_id)
780 enum parport_ip32_irq_mode irq_mode = priv->irq_mode; 780 enum parport_ip32_irq_mode irq_mode = priv->irq_mode;
781 switch (irq_mode) { 781 switch (irq_mode) {
782 case PARPORT_IP32_IRQ_FWD: 782 case PARPORT_IP32_IRQ_FWD:
783 parport_generic_irq(irq, p, regs); 783 parport_generic_irq(irq, p);
784 break; 784 break;
785 case PARPORT_IP32_IRQ_HERE: 785 case PARPORT_IP32_IRQ_HERE:
786 parport_ip32_wakeup(p); 786 parport_ip32_wakeup(p);
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index ecc50db8585a..5f1b9f58070e 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -19,7 +19,7 @@ config PCI_MSI
19 19
20config PCI_MULTITHREAD_PROBE 20config PCI_MULTITHREAD_PROBE
21 bool "PCI Multi-threaded probe (EXPERIMENTAL)" 21 bool "PCI Multi-threaded probe (EXPERIMENTAL)"
22 depends on PCI && EXPERIMENTAL 22 depends on PCI && EXPERIMENTAL && BROKEN
23 help 23 help
24 Say Y here if you want the PCI core to spawn a new thread for 24 Say Y here if you want the PCI core to spawn a new thread for
25 every PCI device that is probed. This can cause a huge 25 every PCI device that is probed. This can cause a huge
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index c44311ac2fd3..16167b016266 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1807,8 +1807,8 @@ u8 acpiphp_get_power_status(struct acpiphp_slot *slot)
1807 1807
1808 1808
1809/* 1809/*
1810 * latch closed: 1 1810 * latch open: 1
1811 * latch open: 0 1811 * latch closed: 0
1812 */ 1812 */
1813u8 acpiphp_get_latch_status(struct acpiphp_slot *slot) 1813u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)
1814{ 1814{
@@ -1816,7 +1816,7 @@ u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)
1816 1816
1817 sta = get_slot_status(slot); 1817 sta = get_slot_status(slot);
1818 1818
1819 return (sta & ACPI_STA_SHOW_IN_UI) ? 1 : 0; 1819 return (sta & ACPI_STA_SHOW_IN_UI) ? 0 : 1;
1820} 1820}
1821 1821
1822 1822
diff --git a/drivers/pci/htirq.c b/drivers/pci/htirq.c
index 0e27f2404a83..0a8d1cce9fa0 100644
--- a/drivers/pci/htirq.c
+++ b/drivers/pci/htirq.c
@@ -25,97 +25,72 @@ static DEFINE_SPINLOCK(ht_irq_lock);
25 25
26struct ht_irq_cfg { 26struct ht_irq_cfg {
27 struct pci_dev *dev; 27 struct pci_dev *dev;
28 /* Update callback used to cope with buggy hardware */
29 ht_irq_update_t *update;
28 unsigned pos; 30 unsigned pos;
29 unsigned idx; 31 unsigned idx;
32 struct ht_irq_msg msg;
30}; 33};
31 34
32void write_ht_irq_low(unsigned int irq, u32 data)
33{
34 struct ht_irq_cfg *cfg = get_irq_data(irq);
35 unsigned long flags;
36 spin_lock_irqsave(&ht_irq_lock, flags);
37 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
38 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
39 spin_unlock_irqrestore(&ht_irq_lock, flags);
40}
41 35
42void write_ht_irq_high(unsigned int irq, u32 data) 36void write_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg)
43{ 37{
44 struct ht_irq_cfg *cfg = get_irq_data(irq); 38 struct ht_irq_cfg *cfg = get_irq_data(irq);
45 unsigned long flags; 39 unsigned long flags;
46 spin_lock_irqsave(&ht_irq_lock, flags); 40 spin_lock_irqsave(&ht_irq_lock, flags);
47 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1); 41 if (cfg->msg.address_lo != msg->address_lo) {
48 pci_write_config_dword(cfg->dev, cfg->pos + 4, data); 42 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
49 spin_unlock_irqrestore(&ht_irq_lock, flags); 43 pci_write_config_dword(cfg->dev, cfg->pos + 4, msg->address_lo);
50} 44 }
51 45 if (cfg->msg.address_hi != msg->address_hi) {
52u32 read_ht_irq_low(unsigned int irq) 46 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1);
53{ 47 pci_write_config_dword(cfg->dev, cfg->pos + 4, msg->address_hi);
54 struct ht_irq_cfg *cfg = get_irq_data(irq); 48 }
55 unsigned long flags; 49 if (cfg->update)
56 u32 data; 50 cfg->update(cfg->dev, irq, msg);
57 spin_lock_irqsave(&ht_irq_lock, flags);
58 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
59 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data);
60 spin_unlock_irqrestore(&ht_irq_lock, flags); 51 spin_unlock_irqrestore(&ht_irq_lock, flags);
61 return data; 52 cfg->msg = *msg;
62} 53}
63 54
64u32 read_ht_irq_high(unsigned int irq) 55void fetch_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg)
65{ 56{
66 struct ht_irq_cfg *cfg = get_irq_data(irq); 57 struct ht_irq_cfg *cfg = get_irq_data(irq);
67 unsigned long flags; 58 *msg = cfg->msg;
68 u32 data;
69 spin_lock_irqsave(&ht_irq_lock, flags);
70 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1);
71 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data);
72 spin_unlock_irqrestore(&ht_irq_lock, flags);
73 return data;
74} 59}
75 60
76void mask_ht_irq(unsigned int irq) 61void mask_ht_irq(unsigned int irq)
77{ 62{
78 struct ht_irq_cfg *cfg; 63 struct ht_irq_cfg *cfg;
79 unsigned long flags; 64 struct ht_irq_msg msg;
80 u32 data;
81 65
82 cfg = get_irq_data(irq); 66 cfg = get_irq_data(irq);
83 67
84 spin_lock_irqsave(&ht_irq_lock, flags); 68 msg = cfg->msg;
85 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx); 69 msg.address_lo |= 1;
86 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data); 70 write_ht_irq_msg(irq, &msg);
87 data |= 1;
88 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
89 spin_unlock_irqrestore(&ht_irq_lock, flags);
90} 71}
91 72
92void unmask_ht_irq(unsigned int irq) 73void unmask_ht_irq(unsigned int irq)
93{ 74{
94 struct ht_irq_cfg *cfg; 75 struct ht_irq_cfg *cfg;
95 unsigned long flags; 76 struct ht_irq_msg msg;
96 u32 data;
97 77
98 cfg = get_irq_data(irq); 78 cfg = get_irq_data(irq);
99 79
100 spin_lock_irqsave(&ht_irq_lock, flags); 80 msg = cfg->msg;
101 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx); 81 msg.address_lo &= ~1;
102 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data); 82 write_ht_irq_msg(irq, &msg);
103 data &= ~1;
104 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
105 spin_unlock_irqrestore(&ht_irq_lock, flags);
106} 83}
107 84
108/** 85/**
109 * ht_create_irq - create an irq and attach it to a device. 86 * __ht_create_irq - create an irq and attach it to a device.
110 * @dev: The hypertransport device to find the irq capability on. 87 * @dev: The hypertransport device to find the irq capability on.
111 * @idx: Which of the possible irqs to attach to. 88 * @idx: Which of the possible irqs to attach to.
112 * 89 * @update: Function to be called when changing the htirq message
113 * ht_create_irq is needs to be called for all hypertransport devices
114 * that generate irqs.
115 * 90 *
116 * The irq number of the new irq or a negative error value is returned. 91 * The irq number of the new irq or a negative error value is returned.
117 */ 92 */
118int ht_create_irq(struct pci_dev *dev, int idx) 93int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
119{ 94{
120 struct ht_irq_cfg *cfg; 95 struct ht_irq_cfg *cfg;
121 unsigned long flags; 96 unsigned long flags;
@@ -150,8 +125,12 @@ int ht_create_irq(struct pci_dev *dev, int idx)
150 return -ENOMEM; 125 return -ENOMEM;
151 126
152 cfg->dev = dev; 127 cfg->dev = dev;
128 cfg->update = update;
153 cfg->pos = pos; 129 cfg->pos = pos;
154 cfg->idx = 0x10 + (idx * 2); 130 cfg->idx = 0x10 + (idx * 2);
131 /* Initialize msg to a value that will never match the first write. */
132 cfg->msg.address_lo = 0xffffffff;
133 cfg->msg.address_hi = 0xffffffff;
155 134
156 irq = create_irq(); 135 irq = create_irq();
157 if (irq < 0) { 136 if (irq < 0) {
@@ -169,6 +148,21 @@ int ht_create_irq(struct pci_dev *dev, int idx)
169} 148}
170 149
171/** 150/**
151 * ht_create_irq - create an irq and attach it to a device.
152 * @dev: The hypertransport device to find the irq capability on.
153 * @idx: Which of the possible irqs to attach to.
154 *
155 * ht_create_irq needs to be called for all hypertransport devices
156 * that generate irqs.
157 *
158 * The irq number of the new irq or a negative error value is returned.
159 */
160int ht_create_irq(struct pci_dev *dev, int idx)
161{
162 return __ht_create_irq(dev, idx, NULL);
163}
164
165/**
172 * ht_destroy_irq - destroy an irq created with ht_create_irq 166 * ht_destroy_irq - destroy an irq created with ht_create_irq
173 * 167 *
174 * This reverses ht_create_irq removing the specified irq from 168 * This reverses ht_create_irq removing the specified irq from
@@ -186,5 +180,6 @@ void ht_destroy_irq(unsigned int irq)
186 kfree(cfg); 180 kfree(cfg);
187} 181}
188 182
183EXPORT_SYMBOL(__ht_create_irq);
189EXPORT_SYMBOL(ht_create_irq); 184EXPORT_SYMBOL(ht_create_irq);
190EXPORT_SYMBOL(ht_destroy_irq); 185EXPORT_SYMBOL(ht_destroy_irq);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index b1c0c707d96c..194f1d21d3d7 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -265,6 +265,13 @@ static int pci_device_remove(struct device * dev)
265 } 265 }
266 266
267 /* 267 /*
268 * If the device is still on, set the power state as "unknown",
269 * since it might change by the next time we load the driver.
270 */
271 if (pci_dev->current_state == PCI_D0)
272 pci_dev->current_state = PCI_UNKNOWN;
273
274 /*
268 * We would love to complain here if pci_dev->is_enabled is set, that 275 * We would love to complain here if pci_dev->is_enabled is set, that
269 * the driver should have called pci_disable_device(), but the 276 * the driver should have called pci_disable_device(), but the
270 * unfortunate fact is there are too many odd BIOS and bridge setups 277 * unfortunate fact is there are too many odd BIOS and bridge setups
@@ -288,6 +295,12 @@ static int pci_device_suspend(struct device * dev, pm_message_t state)
288 suspend_report_result(drv->suspend, i); 295 suspend_report_result(drv->suspend, i);
289 } else { 296 } else {
290 pci_save_state(pci_dev); 297 pci_save_state(pci_dev);
298 /*
299 * mark its power state as "unknown", since we don't know if
300 * e.g. the BIOS will change its device state when we suspend.
301 */
302 if (pci_dev->current_state == PCI_D0)
303 pci_dev->current_state = PCI_UNKNOWN;
291 } 304 }
292 return i; 305 return i;
293} 306}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index a1d2e979b17f..f952bfea48a6 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -642,6 +642,9 @@ err:
642 */ 642 */
643void pci_remove_sysfs_dev_files(struct pci_dev *pdev) 643void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
644{ 644{
645 if (!sysfs_initialized)
646 return;
647
645 if (pdev->cfg_size < 4096) 648 if (pdev->cfg_size < 4096)
646 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); 649 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
647 else 650 else
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index e8a7f1b1b2bc..5b4483811691 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -714,33 +714,6 @@ static void __devinit quirk_vt82c598_id(struct pci_dev *dev)
714} 714}
715DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C597_0, quirk_vt82c598_id ); 715DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C597_0, quirk_vt82c598_id );
716 716
717#ifdef CONFIG_ACPI_SLEEP
718
719/*
720 * Some VIA systems boot with the abnormal status flag set. This can cause
721 * the BIOS to re-POST the system on resume rather than passing control
722 * back to the OS. Clear the flag on boot
723 */
724static void __devinit quirk_via_abnormal_poweroff(struct pci_dev *dev)
725{
726 u32 reg;
727
728 acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
729 &reg);
730
731 if (reg & 0x800) {
732 printk("Clearing abnormal poweroff flag\n");
733 acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
734 ACPI_REGISTER_PM1_STATUS,
735 (u16)0x800);
736 }
737}
738
739DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_via_abnormal_poweroff);
740DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_abnormal_poweroff);
741
742#endif
743
744/* 717/*
745 * CardBus controllers have a legacy base address that enables them 718 * CardBus controllers have a legacy base address that enables them
746 * to respond as i82365 pcmcia controllers. We don't want them to 719 * to respond as i82365 pcmcia controllers. We don't want them to
@@ -1487,33 +1460,6 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2609, quirk_intel_pcie_pm);
1487DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm); 1460DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm);
1488DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm); 1461DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm);
1489 1462
1490/*
1491 * Fixup the cardbus bridges on the IBM Dock II docking station
1492 */
1493static void __devinit quirk_ibm_dock2_cardbus(struct pci_dev *dev)
1494{
1495 u32 val;
1496
1497 /*
1498 * tie the 2 interrupt pins to INTA, and configure the
1499 * multifunction routing register to handle this.
1500 */
1501 if ((dev->subsystem_vendor == PCI_VENDOR_ID_IBM) &&
1502 (dev->subsystem_device == 0x0148)) {
1503 printk(KERN_INFO "PCI: Found IBM Dock II Cardbus Bridge "
1504 "applying quirk\n");
1505 pci_read_config_dword(dev, 0x8c, &val);
1506 val = ((val & 0xffffff00) | 0x1002);
1507 pci_write_config_dword(dev, 0x8c, val);
1508 pci_read_config_dword(dev, 0x80, &val);
1509 val = ((val & 0x00ffff00) | 0x2864c077);
1510 pci_write_config_dword(dev, 0x80, val);
1511 }
1512}
1513
1514DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420,
1515 quirk_ibm_dock2_cardbus);
1516
1517static void __devinit quirk_netmos(struct pci_dev *dev) 1463static void __devinit quirk_netmos(struct pci_dev *dev)
1518{ 1464{
1519 unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; 1465 unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4;
@@ -1619,52 +1565,6 @@ static void __devinit fixup_rev1_53c810(struct pci_dev* dev)
1619} 1565}
1620DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); 1566DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810);
1621 1567
1622/*
1623 * Fixup to mark boot BIOS video selected by BIOS before it changes
1624 *
1625 * From information provided by "Jon Smirl" <jonsmirl@gmail.com>
1626 *
1627 * The standard boot ROM sequence for an x86 machine uses the BIOS
1628 * to select an initial video card for boot display. This boot video
1629 * card will have it's BIOS copied to C0000 in system RAM.
1630 * IORESOURCE_ROM_SHADOW is used to associate the boot video
1631 * card with this copy. On laptops this copy has to be used since
1632 * the main ROM may be compressed or combined with another image.
1633 * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW
1634 * is marked here since the boot video device will be the only enabled
1635 * video device at this point.
1636 */
1637
1638static void __devinit fixup_video(struct pci_dev *pdev)
1639{
1640 struct pci_dev *bridge;
1641 struct pci_bus *bus;
1642 u16 config;
1643
1644 if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
1645 return;
1646
1647 /* Is VGA routed to us? */
1648 bus = pdev->bus;
1649 while (bus) {
1650 bridge = bus->self;
1651 if (bridge) {
1652 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
1653 &config);
1654 if (!(config & PCI_BRIDGE_CTL_VGA))
1655 return;
1656 }
1657 bus = bus->parent;
1658 }
1659 pci_read_config_word(pdev, PCI_COMMAND, &config);
1660 if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
1661 pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
1662 printk(KERN_DEBUG "Boot video device is %s\n", pci_name(pdev));
1663 }
1664}
1665DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, fixup_video);
1666
1667
1668static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end) 1568static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end)
1669{ 1569{
1670 while (f < end) { 1570 while (f < end) {
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 43e4a49f2cc4..e1dcefc69bb4 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -72,8 +72,9 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
72 int last_image; 72 int last_image;
73 73
74 /* 74 /*
75 * IORESOURCE_ROM_SHADOW set if the VGA enable bit of the Bridge Control 75 * IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy
76 * register is set for embedded VGA. 76 * memory map if the VGA enable bit of the Bridge Control register is
77 * set for embedded VGA.
77 */ 78 */
78 if (res->flags & IORESOURCE_ROM_SHADOW) { 79 if (res->flags & IORESOURCE_ROM_SHADOW) {
79 /* primary video rom always starts here */ 80 /* primary video rom always starts here */
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 7f5df9a9f393..3bcb7dc32995 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -241,12 +241,6 @@ static int __init at91_cf_probe(struct platform_device *pdev)
241 csa = at91_sys_read(AT91_EBI_CSA); 241 csa = at91_sys_read(AT91_EBI_CSA);
242 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH); 242 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
243 243
244 /* force poweron defaults for these pins ... */
245 (void) at91_set_A_periph(AT91_PIN_PC9, 0); /* A25/CFRNW */
246 (void) at91_set_A_periph(AT91_PIN_PC10, 0); /* NCS4/CFCS */
247 (void) at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */
248 (void) at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */
249
250 /* nWAIT is _not_ a default setting */ 244 /* nWAIT is _not_ a default setting */
251 (void) at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */ 245 (void) at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */
252 246
@@ -316,12 +310,14 @@ static int __init at91_cf_probe(struct platform_device *pdev)
316 return 0; 310 return 0;
317 311
318fail2: 312fail2:
319 iounmap((void __iomem *) cf->socket.io_offset);
320 release_mem_region(io->start, io->end + 1 - io->start); 313 release_mem_region(io->start, io->end + 1 - io->start);
321fail1: 314fail1:
315 if (cf->socket.io_offset)
316 iounmap((void __iomem *) cf->socket.io_offset);
322 if (board->irq_pin) 317 if (board->irq_pin)
323 free_irq(board->irq_pin, cf); 318 free_irq(board->irq_pin, cf);
324fail0a: 319fail0a:
320 device_init_wakeup(&pdev->dev, 0);
325 free_irq(board->det_pin, cf); 321 free_irq(board->det_pin, cf);
326 device_init_wakeup(&pdev->dev, 0); 322 device_init_wakeup(&pdev->dev, 0);
327fail0: 323fail0:
@@ -360,26 +356,20 @@ static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
360 struct at91_cf_data *board = cf->board; 356 struct at91_cf_data *board = cf->board;
361 357
362 pcmcia_socket_dev_suspend(&pdev->dev, mesg); 358 pcmcia_socket_dev_suspend(&pdev->dev, mesg);
363 if (device_may_wakeup(&pdev->dev)) 359 if (device_may_wakeup(&pdev->dev)) {
364 enable_irq_wake(board->det_pin); 360 enable_irq_wake(board->det_pin);
365 else { 361 if (board->irq_pin)
362 enable_irq_wake(board->irq_pin);
363 } else {
366 disable_irq_wake(board->det_pin); 364 disable_irq_wake(board->det_pin);
367 disable_irq(board->det_pin); 365 if (board->irq_pin)
366 disable_irq_wake(board->irq_pin);
368 } 367 }
369 if (board->irq_pin)
370 disable_irq(board->irq_pin);
371 return 0; 368 return 0;
372} 369}
373 370
374static int at91_cf_resume(struct platform_device *pdev) 371static int at91_cf_resume(struct platform_device *pdev)
375{ 372{
376 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
377 struct at91_cf_data *board = cf->board;
378
379 if (board->irq_pin)
380 enable_irq(board->irq_pin);
381 if (!device_may_wakeup(&pdev->dev))
382 enable_irq(board->det_pin);
383 pcmcia_socket_dev_resume(&pdev->dev); 373 pcmcia_socket_dev_resume(&pdev->dev);
384 return 0; 374 return 0;
385} 375}
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index d5dd0ce65536..551bde5d9430 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -351,6 +351,7 @@ struct skt_dev_info {
351int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) 351int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
352{ 352{
353 struct skt_dev_info *sinfo; 353 struct skt_dev_info *sinfo;
354 struct au1000_pcmcia_socket *skt;
354 int ret, i; 355 int ret, i;
355 356
356 sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL); 357 sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL);
@@ -365,7 +366,7 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
365 * Initialise the per-socket structure. 366 * Initialise the per-socket structure.
366 */ 367 */
367 for (i = 0; i < nr; i++) { 368 for (i = 0; i < nr; i++) {
368 struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); 369 skt = PCMCIA_SOCKET(i);
369 memset(skt, 0, sizeof(*skt)); 370 memset(skt, 0, sizeof(*skt));
370 371
371 skt->socket.resource_ops = &pccard_static_ops; 372 skt->socket.resource_ops = &pccard_static_ops;
@@ -438,17 +439,29 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
438 dev_set_drvdata(dev, sinfo); 439 dev_set_drvdata(dev, sinfo);
439 return 0; 440 return 0;
440 441
441 do { 442
442 struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); 443out_err:
444 flush_scheduled_work();
445 ops->hw_shutdown(skt);
446 while (i-- > 0) {
447 skt = PCMCIA_SOCKET(i);
443 448
444 del_timer_sync(&skt->poll_timer); 449 del_timer_sync(&skt->poll_timer);
445 pcmcia_unregister_socket(&skt->socket); 450 pcmcia_unregister_socket(&skt->socket);
446out_err:
447 flush_scheduled_work(); 451 flush_scheduled_work();
452 if (i == 0) {
453 iounmap(skt->virt_io + (u32)mips_io_port_base);
454 skt->virt_io = NULL;
455 }
456#ifndef CONFIG_MIPS_XXS1500
457 else {
458 iounmap(skt->virt_io + (u32)mips_io_port_base);
459 skt->virt_io = NULL;
460 }
461#endif
448 ops->hw_shutdown(skt); 462 ops->hw_shutdown(skt);
449 463
450 i--; 464 }
451 } while (i > 0);
452 kfree(sinfo); 465 kfree(sinfo);
453out: 466out:
454 return ret; 467 return ret;
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 74b3124e8247..21d83a895b21 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -717,6 +717,7 @@ static int pcmcia_requery(struct device *dev, void * _data)
717static void pcmcia_bus_rescan(struct pcmcia_socket *skt) 717static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
718{ 718{
719 int no_devices=0; 719 int no_devices=0;
720 int ret = 0;
720 unsigned long flags; 721 unsigned long flags;
721 722
722 /* must be called with skt_mutex held */ 723 /* must be called with skt_mutex held */
@@ -729,7 +730,7 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
729 * missing resource information or other trouble, we need to 730 * missing resource information or other trouble, we need to
730 * do this now. */ 731 * do this now. */
731 if (no_devices) { 732 if (no_devices) {
732 int ret = pcmcia_card_add(skt); 733 ret = pcmcia_card_add(skt);
733 if (ret) 734 if (ret)
734 return; 735 return;
735 } 736 }
@@ -741,7 +742,9 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
741 742
742 /* we re-scan all devices, not just the ones connected to this 743 /* we re-scan all devices, not just the ones connected to this
743 * socket. This does not matter, though. */ 744 * socket. This does not matter, though. */
744 bus_rescan_devices(&pcmcia_bus_type); 745 ret = bus_rescan_devices(&pcmcia_bus_type);
746 if (ret)
747 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n");
745} 748}
746 749
747static inline int pcmcia_devmatch(struct pcmcia_device *dev, 750static inline int pcmcia_devmatch(struct pcmcia_device *dev,
@@ -1001,6 +1004,7 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev,
1001 struct device_attribute *attr, const char *buf, size_t count) 1004 struct device_attribute *attr, const char *buf, size_t count)
1002{ 1005{
1003 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1006 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1007 int ret;
1004 1008
1005 if (!count) 1009 if (!count)
1006 return -EINVAL; 1010 return -EINVAL;
@@ -1009,7 +1013,10 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev,
1009 p_dev->allow_func_id_match = 1; 1013 p_dev->allow_func_id_match = 1;
1010 mutex_unlock(&p_dev->socket->skt_mutex); 1014 mutex_unlock(&p_dev->socket->skt_mutex);
1011 1015
1012 bus_rescan_devices(&pcmcia_bus_type); 1016 ret = bus_rescan_devices(&pcmcia_bus_type);
1017 if (ret)
1018 printk(KERN_INFO "pcmcia: bus_rescan_devices failed after "
1019 "allowing func_id matches\n");
1013 1020
1014 return count; 1021 return count;
1015} 1022}
@@ -1264,6 +1271,11 @@ static void pcmcia_bus_remove_socket(struct class_device *class_dev,
1264 socket->pcmcia_state.dead = 1; 1271 socket->pcmcia_state.dead = 1;
1265 pccard_register_pcmcia(socket, NULL); 1272 pccard_register_pcmcia(socket, NULL);
1266 1273
1274 /* unregister any unbound devices */
1275 mutex_lock(&socket->skt_mutex);
1276 pcmcia_card_remove(socket, NULL);
1277 mutex_unlock(&socket->skt_mutex);
1278
1267 pcmcia_put_socket(socket); 1279 pcmcia_put_socket(socket);
1268 1280
1269 return; 1281 return;
@@ -1292,10 +1304,22 @@ struct bus_type pcmcia_bus_type = {
1292 1304
1293static int __init init_pcmcia_bus(void) 1305static int __init init_pcmcia_bus(void)
1294{ 1306{
1307 int ret;
1308
1295 spin_lock_init(&pcmcia_dev_list_lock); 1309 spin_lock_init(&pcmcia_dev_list_lock);
1296 1310
1297 bus_register(&pcmcia_bus_type); 1311 ret = bus_register(&pcmcia_bus_type);
1298 class_interface_register(&pcmcia_bus_interface); 1312 if (ret < 0) {
1313 printk(KERN_WARNING "pcmcia: bus_register error: %d\n", ret);
1314 return ret;
1315 }
1316 ret = class_interface_register(&pcmcia_bus_interface);
1317 if (ret < 0) {
1318 printk(KERN_WARNING
1319 "pcmcia: class_interface_register error: %d\n", ret);
1320 bus_unregister(&pcmcia_bus_type);
1321 return ret;
1322 }
1299 1323
1300 pcmcia_setup_ioctl(); 1324 pcmcia_setup_ioctl();
1301 1325
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index 82715f448957..c2ea07aa7a12 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -41,6 +41,7 @@ static struct pci_device_id i82092aa_pci_ids[] = {
41}; 41};
42MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids); 42MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids);
43 43
44#ifdef CONFIG_PM
44static int i82092aa_socket_suspend (struct pci_dev *dev, pm_message_t state) 45static int i82092aa_socket_suspend (struct pci_dev *dev, pm_message_t state)
45{ 46{
46 return pcmcia_socket_dev_suspend(&dev->dev, state); 47 return pcmcia_socket_dev_suspend(&dev->dev, state);
@@ -50,14 +51,17 @@ static int i82092aa_socket_resume (struct pci_dev *dev)
50{ 51{
51 return pcmcia_socket_dev_resume(&dev->dev); 52 return pcmcia_socket_dev_resume(&dev->dev);
52} 53}
54#endif
53 55
54static struct pci_driver i82092aa_pci_drv = { 56static struct pci_driver i82092aa_pci_drv = {
55 .name = "i82092aa", 57 .name = "i82092aa",
56 .id_table = i82092aa_pci_ids, 58 .id_table = i82092aa_pci_ids,
57 .probe = i82092aa_pci_probe, 59 .probe = i82092aa_pci_probe,
58 .remove = __devexit_p(i82092aa_pci_remove), 60 .remove = __devexit_p(i82092aa_pci_remove),
61#ifdef CONFIG_PM
59 .suspend = i82092aa_socket_suspend, 62 .suspend = i82092aa_socket_suspend,
60 .resume = i82092aa_socket_resume, 63 .resume = i82092aa_socket_resume,
64#endif
61}; 65};
62 66
63 67
@@ -705,10 +709,7 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
705 709
706static int i82092aa_module_init(void) 710static int i82092aa_module_init(void)
707{ 711{
708 enter("i82092aa_module_init"); 712 return pci_register_driver(&i82092aa_pci_drv);
709 pci_register_driver(&i82092aa_pci_drv);
710 leave("i82092aa_module_init");
711 return 0;
712} 713}
713 714
714static void i82092aa_module_exit(void) 715static void i82092aa_module_exit(void)
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index e070a2896769..3b72be880401 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -427,7 +427,7 @@ static int voltage_set(int slot, int vcc, int vpp)
427 reg |= BCSR1_PCCVCC1; 427 reg |= BCSR1_PCCVCC1;
428 break; 428 break;
429 default: 429 default:
430 return 1; 430 goto out_unmap;
431 } 431 }
432 432
433 switch(vpp) { 433 switch(vpp) {
@@ -438,15 +438,15 @@ static int voltage_set(int slot, int vcc, int vpp)
438 if(vcc == vpp) 438 if(vcc == vpp)
439 reg |= BCSR1_PCCVPP1; 439 reg |= BCSR1_PCCVPP1;
440 else 440 else
441 return 1; 441 goto out_unmap;
442 break; 442 break;
443 case 120: 443 case 120:
444 if ((vcc == 33) || (vcc == 50)) 444 if ((vcc == 33) || (vcc == 50))
445 reg |= BCSR1_PCCVPP0; 445 reg |= BCSR1_PCCVPP0;
446 else 446 else
447 return 1; 447 goto out_unmap;
448 default: 448 default:
449 return 1; 449 goto out_unmap;
450 } 450 }
451 451
452 /* first, turn off all power */ 452 /* first, turn off all power */
@@ -457,6 +457,10 @@ static int voltage_set(int slot, int vcc, int vpp)
457 457
458 iounmap(bcsr_io); 458 iounmap(bcsr_io);
459 return 0; 459 return 0;
460
461out_unmap:
462 iounmap(bcsr_io);
463 return 1;
460} 464}
461 465
462#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V 466#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index c8e838c69766..06bf7f48836e 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -309,9 +309,10 @@ static int __devinit omap_cf_probe(struct device *dev)
309 return 0; 309 return 0;
310 310
311fail2: 311fail2:
312 iounmap((void __iomem *) cf->socket.io_offset);
313 release_mem_region(cf->phys_cf, SZ_8K); 312 release_mem_region(cf->phys_cf, SZ_8K);
314fail1: 313fail1:
314 if (cf->socket.io_offset)
315 iounmap((void __iomem *) cf->socket.io_offset);
315 free_irq(irq, cf); 316 free_irq(irq, cf);
316fail0: 317fail0:
317 kfree(cf); 318 kfree(cf);
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 9ad18e62658d..310ede575caa 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -128,9 +128,12 @@ static int proc_read_drivers(char *buf, char **start, off_t pos,
128 int count, int *eof, void *data) 128 int count, int *eof, void *data)
129{ 129{
130 char *p = buf; 130 char *p = buf;
131 int rc;
131 132
132 bus_for_each_drv(&pcmcia_bus_type, NULL, 133 rc = bus_for_each_drv(&pcmcia_bus_type, NULL,
133 (void *) &p, proc_read_drivers_callback); 134 (void *) &p, proc_read_drivers_callback);
135 if (rc < 0)
136 return rc;
134 137
135 return (p - buf); 138 return (p - buf);
136} 139}
@@ -269,8 +272,10 @@ rescan:
269 * Prevent this racing with a card insertion. 272 * Prevent this racing with a card insertion.
270 */ 273 */
271 mutex_lock(&s->skt_mutex); 274 mutex_lock(&s->skt_mutex);
272 bus_rescan_devices(&pcmcia_bus_type); 275 ret = bus_rescan_devices(&pcmcia_bus_type);
273 mutex_unlock(&s->skt_mutex); 276 mutex_unlock(&s->skt_mutex);
277 if (ret)
278 goto err_put_module;
274 279
275 /* check whether the driver indeed matched. I don't care if this 280 /* check whether the driver indeed matched. I don't care if this
276 * is racy or not, because it can only happen on cardmgr access 281 * is racy or not, because it can only happen on cardmgr access
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 74cebd424032..b9201c2ec38b 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -95,7 +95,7 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base,
95 * potential conflicts, just the most obvious ones. 95 * potential conflicts, just the most obvious ones.
96 */ 96 */
97 for (i = 0; i < MAX_IO_WIN; i++) 97 for (i = 0; i < MAX_IO_WIN; i++)
98 if ((s->io[i].res) && 98 if ((s->io[i].res) && *base &&
99 ((s->io[i].res->start & (align-1)) == *base)) 99 ((s->io[i].res->start & (align-1)) == *base))
100 return 1; 100 return 1;
101 for (i = 0; i < MAX_IO_WIN; i++) { 101 for (i = 0; i < MAX_IO_WIN; i++) {
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index c83a0a6b158f..a70f97fdbbdd 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -755,6 +755,7 @@ static void __devexit pd6729_pci_remove(struct pci_dev *dev)
755 kfree(socket); 755 kfree(socket);
756} 756}
757 757
758#ifdef CONFIG_PM
758static int pd6729_socket_suspend(struct pci_dev *dev, pm_message_t state) 759static int pd6729_socket_suspend(struct pci_dev *dev, pm_message_t state)
759{ 760{
760 return pcmcia_socket_dev_suspend(&dev->dev, state); 761 return pcmcia_socket_dev_suspend(&dev->dev, state);
@@ -764,6 +765,7 @@ static int pd6729_socket_resume(struct pci_dev *dev)
764{ 765{
765 return pcmcia_socket_dev_resume(&dev->dev); 766 return pcmcia_socket_dev_resume(&dev->dev);
766} 767}
768#endif
767 769
768static struct pci_device_id pd6729_pci_ids[] = { 770static struct pci_device_id pd6729_pci_ids[] = {
769 { 771 {
@@ -781,8 +783,10 @@ static struct pci_driver pd6729_pci_drv = {
781 .id_table = pd6729_pci_ids, 783 .id_table = pd6729_pci_ids,
782 .probe = pd6729_pci_probe, 784 .probe = pd6729_pci_probe,
783 .remove = __devexit_p(pd6729_pci_remove), 785 .remove = __devexit_p(pd6729_pci_remove),
786#ifdef CONFIG_PM
784 .suspend = pd6729_socket_suspend, 787 .suspend = pd6729_socket_suspend,
785 .resume = pd6729_socket_resume, 788 .resume = pd6729_socket_resume,
789#endif
786}; 790};
787 791
788static int pd6729_module_init(void) 792static int pd6729_module_init(void)
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index b3518131ea0d..dca9f8549b32 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -166,7 +166,7 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
166} 166}
167#endif 167#endif
168 168
169int pxa2xx_drv_pcmcia_probe(struct device *dev) 169int __pxa2xx_drv_pcmcia_probe(struct device *dev)
170{ 170{
171 int ret; 171 int ret;
172 struct pcmcia_low_level *ops; 172 struct pcmcia_low_level *ops;
@@ -203,35 +203,52 @@ int pxa2xx_drv_pcmcia_probe(struct device *dev)
203 203
204 return ret; 204 return ret;
205} 205}
206EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe); 206EXPORT_SYMBOL(__pxa2xx_drv_pcmcia_probe);
207 207
208static int pxa2xx_drv_pcmcia_resume(struct device *dev) 208
209static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
210{
211 return __pxa2xx_drv_pcmcia_probe(&dev->dev);
212}
213
214static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
215{
216 return soc_common_drv_pcmcia_remove(&dev->dev);
217}
218
219static int pxa2xx_drv_pcmcia_suspend(struct platform_device *dev, pm_message_t state)
220{
221 return pcmcia_socket_dev_suspend(&dev->dev, state);
222}
223
224static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev)
209{ 225{
210 struct pcmcia_low_level *ops = dev->platform_data; 226 struct pcmcia_low_level *ops = dev->dev.platform_data;
211 int nr = ops ? ops->nr : 0; 227 int nr = ops ? ops->nr : 0;
212 228
213 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0); 229 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
214 230
215 return pcmcia_socket_dev_resume(dev); 231 return pcmcia_socket_dev_resume(&dev->dev);
216} 232}
217 233
218static struct device_driver pxa2xx_pcmcia_driver = { 234static struct platform_driver pxa2xx_pcmcia_driver = {
219 .probe = pxa2xx_drv_pcmcia_probe, 235 .probe = pxa2xx_drv_pcmcia_probe,
220 .remove = soc_common_drv_pcmcia_remove, 236 .remove = pxa2xx_drv_pcmcia_remove,
221 .suspend = pcmcia_socket_dev_suspend, 237 .suspend = pxa2xx_drv_pcmcia_suspend,
222 .resume = pxa2xx_drv_pcmcia_resume, 238 .resume = pxa2xx_drv_pcmcia_resume,
223 .name = "pxa2xx-pcmcia", 239 .driver = {
224 .bus = &platform_bus_type, 240 .name = "pxa2xx-pcmcia",
241 },
225}; 242};
226 243
227static int __init pxa2xx_pcmcia_init(void) 244static int __init pxa2xx_pcmcia_init(void)
228{ 245{
229 return driver_register(&pxa2xx_pcmcia_driver); 246 return platform_driver_register(&pxa2xx_pcmcia_driver);
230} 247}
231 248
232static void __exit pxa2xx_pcmcia_exit(void) 249static void __exit pxa2xx_pcmcia_exit(void)
233{ 250{
234 driver_unregister(&pxa2xx_pcmcia_driver); 251 platform_driver_unregister(&pxa2xx_pcmcia_driver);
235} 252}
236 253
237fs_initcall(pxa2xx_pcmcia_init); 254fs_initcall(pxa2xx_pcmcia_init);
diff --git a/drivers/pcmcia/pxa2xx_base.h b/drivers/pcmcia/pxa2xx_base.h
index e46cff345d47..235d681652c3 100644
--- a/drivers/pcmcia/pxa2xx_base.h
+++ b/drivers/pcmcia/pxa2xx_base.h
@@ -1,3 +1,3 @@
1/* temporary measure */ 1/* temporary measure */
2extern int pxa2xx_drv_pcmcia_probe(struct device *); 2extern int __pxa2xx_drv_pcmcia_probe(struct device *);
3 3
diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c
index fd1f691c7c2c..a92f11143c43 100644
--- a/drivers/pcmcia/pxa2xx_lubbock.c
+++ b/drivers/pcmcia/pxa2xx_lubbock.c
@@ -260,7 +260,7 @@ int __init pcmcia_lubbock_init(struct sa1111_dev *sadev)
260 lubbock_set_misc_wr((1 << 15) | (1 << 14), 0); 260 lubbock_set_misc_wr((1 << 15) | (1 << 14), 0);
261 261
262 sadev->dev.platform_data = &lubbock_pcmcia_ops; 262 sadev->dev.platform_data = &lubbock_pcmcia_ops;
263 ret = pxa2xx_drv_pcmcia_probe(&sadev->dev); 263 ret = __pxa2xx_drv_pcmcia_probe(&sadev->dev);
264 } 264 }
265 265
266 return ret; 266 return ret;
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 3627e52e0c27..e433704e026a 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -824,3 +824,4 @@ int soc_common_drv_pcmcia_remove(struct device *dev)
824 824
825 return 0; 825 return 0;
826} 826}
827EXPORT_SYMBOL(soc_common_drv_pcmcia_remove);
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 26229d9da762..da471bddc972 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -1197,8 +1197,12 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1197 ret = pcmcia_register_socket(&socket->socket); 1197 ret = pcmcia_register_socket(&socket->socket);
1198 if (ret == 0) { 1198 if (ret == 0) {
1199 /* Add the yenta register attributes */ 1199 /* Add the yenta register attributes */
1200 device_create_file(&dev->dev, &dev_attr_yenta_registers); 1200 ret = device_create_file(&dev->dev, &dev_attr_yenta_registers);
1201 goto out; 1201 if (ret == 0)
1202 goto out;
1203
1204 /* error path... */
1205 pcmcia_unregister_socket(&socket->socket);
1202 } 1206 }
1203 1207
1204 unmap: 1208 unmap:
@@ -1213,7 +1217,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1213 return ret; 1217 return ret;
1214} 1218}
1215 1219
1216 1220#ifdef CONFIG_PM
1217static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state) 1221static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
1218{ 1222{
1219 struct yenta_socket *socket = pci_get_drvdata(dev); 1223 struct yenta_socket *socket = pci_get_drvdata(dev);
@@ -1248,12 +1252,18 @@ static int yenta_dev_resume (struct pci_dev *dev)
1248 struct yenta_socket *socket = pci_get_drvdata(dev); 1252 struct yenta_socket *socket = pci_get_drvdata(dev);
1249 1253
1250 if (socket) { 1254 if (socket) {
1255 int rc;
1256
1251 pci_set_power_state(dev, 0); 1257 pci_set_power_state(dev, 0);
1252 /* FIXME: pci_restore_state needs to have a better interface */ 1258 /* FIXME: pci_restore_state needs to have a better interface */
1253 pci_restore_state(dev); 1259 pci_restore_state(dev);
1254 pci_write_config_dword(dev, 16*4, socket->saved_state[0]); 1260 pci_write_config_dword(dev, 16*4, socket->saved_state[0]);
1255 pci_write_config_dword(dev, 17*4, socket->saved_state[1]); 1261 pci_write_config_dword(dev, 17*4, socket->saved_state[1]);
1256 pci_enable_device(dev); 1262
1263 rc = pci_enable_device(dev);
1264 if (rc)
1265 return rc;
1266
1257 pci_set_master(dev); 1267 pci_set_master(dev);
1258 1268
1259 if (socket->type && socket->type->restore_state) 1269 if (socket->type && socket->type->restore_state)
@@ -1262,7 +1272,7 @@ static int yenta_dev_resume (struct pci_dev *dev)
1262 1272
1263 return pcmcia_socket_dev_resume(&dev->dev); 1273 return pcmcia_socket_dev_resume(&dev->dev);
1264} 1274}
1265 1275#endif
1266 1276
1267#define CB_ID(vend,dev,type) \ 1277#define CB_ID(vend,dev,type) \
1268 { \ 1278 { \
@@ -1359,8 +1369,10 @@ static struct pci_driver yenta_cardbus_driver = {
1359 .id_table = yenta_table, 1369 .id_table = yenta_table,
1360 .probe = yenta_probe, 1370 .probe = yenta_probe,
1361 .remove = __devexit_p(yenta_close), 1371 .remove = __devexit_p(yenta_close),
1372#ifdef CONFIG_PM
1362 .suspend = yenta_dev_suspend, 1373 .suspend = yenta_dev_suspend,
1363 .resume = yenta_dev_resume, 1374 .resume = yenta_dev_resume,
1375#endif
1364}; 1376};
1365 1377
1366 1378
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 579cd667b16f..6f11f6dfdd9d 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -145,6 +145,13 @@ int rtc_set_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm)
145} 145}
146EXPORT_SYMBOL_GPL(rtc_set_alarm); 146EXPORT_SYMBOL_GPL(rtc_set_alarm);
147 147
148/**
149 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs
150 * @class_dev: the rtc's class device
151 * @num: how many irqs are being reported (usually one)
152 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF
153 * Context: in_interrupt(), irqs blocked
154 */
148void rtc_update_irq(struct class_device *class_dev, 155void rtc_update_irq(struct class_device *class_dev,
149 unsigned long num, unsigned long events) 156 unsigned long num, unsigned long events)
150{ 157{
@@ -201,12 +208,12 @@ int rtc_irq_register(struct class_device *class_dev, struct rtc_task *task)
201 if (task == NULL || task->func == NULL) 208 if (task == NULL || task->func == NULL)
202 return -EINVAL; 209 return -EINVAL;
203 210
204 spin_lock(&rtc->irq_task_lock); 211 spin_lock_irq(&rtc->irq_task_lock);
205 if (rtc->irq_task == NULL) { 212 if (rtc->irq_task == NULL) {
206 rtc->irq_task = task; 213 rtc->irq_task = task;
207 retval = 0; 214 retval = 0;
208 } 215 }
209 spin_unlock(&rtc->irq_task_lock); 216 spin_unlock_irq(&rtc->irq_task_lock);
210 217
211 return retval; 218 return retval;
212} 219}
@@ -216,10 +223,10 @@ void rtc_irq_unregister(struct class_device *class_dev, struct rtc_task *task)
216{ 223{
217 struct rtc_device *rtc = to_rtc_device(class_dev); 224 struct rtc_device *rtc = to_rtc_device(class_dev);
218 225
219 spin_lock(&rtc->irq_task_lock); 226 spin_lock_irq(&rtc->irq_task_lock);
220 if (rtc->irq_task == task) 227 if (rtc->irq_task == task)
221 rtc->irq_task = NULL; 228 rtc->irq_task = NULL;
222 spin_unlock(&rtc->irq_task_lock); 229 spin_unlock_irq(&rtc->irq_task_lock);
223} 230}
224EXPORT_SYMBOL_GPL(rtc_irq_unregister); 231EXPORT_SYMBOL_GPL(rtc_irq_unregister);
225 232
@@ -265,3 +272,4 @@ int rtc_irq_set_freq(struct class_device *class_dev, struct rtc_task *task, int
265 } 272 }
266 return err; 273 return err;
267} 274}
275EXPORT_SYMBOL_GPL(rtc_irq_set_freq);
diff --git a/drivers/rtc/rtc-at91.c b/drivers/rtc/rtc-at91.c
index bd61e99540a3..5c8addcaf1fb 100644
--- a/drivers/rtc/rtc-at91.c
+++ b/drivers/rtc/rtc-at91.c
@@ -292,7 +292,8 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
292 AT91_RTC_CALEV); 292 AT91_RTC_CALEV);
293 293
294 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, 294 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,
295 IRQF_SHARED, "at91_rtc", pdev); 295 IRQF_DISABLED | IRQF_SHARED,
296 "at91_rtc", pdev);
296 if (ret) { 297 if (ret) {
297 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n", 298 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n",
298 AT91_ID_SYS); 299 AT91_ID_SYS);
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 583789c66cdb..814b9e1873f5 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -61,7 +61,9 @@ static void rtc_uie_task(void *data)
61 int err; 61 int err;
62 62
63 err = rtc_read_time(&rtc->class_dev, &tm); 63 err = rtc_read_time(&rtc->class_dev, &tm);
64 spin_lock_irq(&rtc->irq_lock); 64
65 local_irq_disable();
66 spin_lock(&rtc->irq_lock);
65 if (rtc->stop_uie_polling || err) { 67 if (rtc->stop_uie_polling || err) {
66 rtc->uie_task_active = 0; 68 rtc->uie_task_active = 0;
67 } else if (rtc->oldsecs != tm.tm_sec) { 69 } else if (rtc->oldsecs != tm.tm_sec) {
@@ -74,11 +76,11 @@ static void rtc_uie_task(void *data)
74 } else if (schedule_work(&rtc->uie_task) == 0) { 76 } else if (schedule_work(&rtc->uie_task) == 0) {
75 rtc->uie_task_active = 0; 77 rtc->uie_task_active = 0;
76 } 78 }
77 spin_unlock_irq(&rtc->irq_lock); 79 spin_unlock(&rtc->irq_lock);
78 if (num) 80 if (num)
79 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF); 81 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF);
82 local_irq_enable();
80} 83}
81
82static void rtc_uie_timer(unsigned long data) 84static void rtc_uie_timer(unsigned long data)
83{ 85{
84 struct rtc_device *rtc = (struct rtc_device *)data; 86 struct rtc_device *rtc = (struct rtc_device *)data;
@@ -214,7 +216,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
214 struct rtc_wkalrm alarm; 216 struct rtc_wkalrm alarm;
215 void __user *uarg = (void __user *) arg; 217 void __user *uarg = (void __user *) arg;
216 218
217 /* check that the calles has appropriate permissions 219 /* check that the calling task has appropriate permissions
218 * for certain ioctls. doing this check here is useful 220 * for certain ioctls. doing this check here is useful
219 * to avoid duplicate code in each driver. 221 * to avoid duplicate code in each driver.
220 */ 222 */
@@ -238,10 +240,10 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
238 240
239 /* avoid conflicting IRQ users */ 241 /* avoid conflicting IRQ users */
240 if (cmd == RTC_PIE_ON || cmd == RTC_PIE_OFF || cmd == RTC_IRQP_SET) { 242 if (cmd == RTC_PIE_ON || cmd == RTC_PIE_OFF || cmd == RTC_IRQP_SET) {
241 spin_lock(&rtc->irq_task_lock); 243 spin_lock_irq(&rtc->irq_task_lock);
242 if (rtc->irq_task) 244 if (rtc->irq_task)
243 err = -EBUSY; 245 err = -EBUSY;
244 spin_unlock(&rtc->irq_task_lock); 246 spin_unlock_irq(&rtc->irq_task_lock);
245 247
246 if (err < 0) 248 if (err < 0)
247 return err; 249 return err;
@@ -299,6 +301,17 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
299 301
300 err = rtc_set_time(class_dev, &tm); 302 err = rtc_set_time(class_dev, &tm);
301 break; 303 break;
304
305 case RTC_IRQP_READ:
306 if (ops->irq_set_freq)
307 err = put_user(rtc->irq_freq, (unsigned long *) arg);
308 break;
309
310 case RTC_IRQP_SET:
311 if (ops->irq_set_freq)
312 err = rtc_irq_set_freq(class_dev, rtc->irq_task, arg);
313 break;
314
302#if 0 315#if 0
303 case RTC_EPOCH_SET: 316 case RTC_EPOCH_SET:
304#ifndef rtc_epoch 317#ifndef rtc_epoch
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index 78552e6e76aa..001eb1123a65 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -340,7 +340,8 @@ static int __init ds1553_rtc_probe(struct platform_device *pdev)
340 340
341 if (pdata->irq >= 0) { 341 if (pdata->irq >= 0) {
342 writeb(0, ioaddr + RTC_INTERRUPTS); 342 writeb(0, ioaddr + RTC_INTERRUPTS);
343 if (request_irq(pdata->irq, ds1553_rtc_interrupt, IRQF_SHARED, 343 if (request_irq(pdata->irq, ds1553_rtc_interrupt,
344 IRQF_DISABLED | IRQF_SHARED,
344 pdev->name, pdev) < 0) { 345 pdev->name, pdev) < 0) {
345 dev_warn(&pdev->dev, "interrupt not available.\n"); 346 dev_warn(&pdev->dev, "interrupt not available.\n");
346 pdata->irq = -1; 347 pdata->irq = -1;
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 2a86632580f1..a44fe4efa216 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -126,13 +126,13 @@ static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
126 return -EIO; 126 return -EIO;
127 } 127 }
128 128
129 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
130
131 if (osc) 129 if (osc)
132 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768; 130 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768;
133 131
134 if (trim) 132 if (trim) {
135 *trim = buf & RS5C372_TRIM_MASK; 133 *trim = buf & RS5C372_TRIM_MASK;
134 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
135 }
136 136
137 return 0; 137 return 0;
138} 138}
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index bc4bd24508a2..6ef9c62d5032 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -99,6 +99,7 @@ static ssize_t test_irq_store(struct device *dev,
99 struct rtc_device *rtc = platform_get_drvdata(plat_dev); 99 struct rtc_device *rtc = platform_get_drvdata(plat_dev);
100 100
101 retval = count; 101 retval = count;
102 local_irq_disable();
102 if (strncmp(buf, "tick", 4) == 0) 103 if (strncmp(buf, "tick", 4) == 0)
103 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF); 104 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF);
104 else if (strncmp(buf, "alarm", 5) == 0) 105 else if (strncmp(buf, "alarm", 5) == 0)
@@ -107,6 +108,7 @@ static ssize_t test_irq_store(struct device *dev,
107 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF); 108 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF);
108 else 109 else
109 retval = -EINVAL; 110 retval = -EINVAL;
111 local_irq_enable();
110 112
111 return retval; 113 return retval;
112} 114}
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index a2dee5bf5a17..ad7f7e1c0163 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -271,10 +271,6 @@ static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
271 /* Reset intparm to zeroes. */ 271 /* Reset intparm to zeroes. */
272 sch->schib.pmcw.intparm = 0; 272 sch->schib.pmcw.intparm = 0;
273 cio_modify(sch); 273 cio_modify(sch);
274
275 /* Probe if necessary. */
276 if (action == UNREGISTER_PROBE)
277 ret = css_probe_device(sch->schid);
278 break; 274 break;
279 case REPROBE: 275 case REPROBE:
280 device_trigger_reprobe(sch); 276 device_trigger_reprobe(sch);
@@ -283,6 +279,9 @@ static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
283 break; 279 break;
284 } 280 }
285 spin_unlock_irqrestore(&sch->lock, flags); 281 spin_unlock_irqrestore(&sch->lock, flags);
282 /* Probe if necessary. */
283 if (action == UNREGISTER_PROBE)
284 ret = css_probe_device(sch->schid);
286 285
287 return ret; 286 return ret;
288} 287}
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 94bdd4d8a4c9..39c98f940507 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -532,8 +532,7 @@ device_remove_files(struct device *dev)
532 532
533/* this is a simple abstraction for device_register that sets the 533/* this is a simple abstraction for device_register that sets the
534 * correct bus type and adds the bus specific files */ 534 * correct bus type and adds the bus specific files */
535int 535static int ccw_device_register(struct ccw_device *cdev)
536ccw_device_register(struct ccw_device *cdev)
537{ 536{
538 struct device *dev = &cdev->dev; 537 struct device *dev = &cdev->dev;
539 int ret; 538 int ret;
diff --git a/drivers/s390/cio/device.h b/drivers/s390/cio/device.h
index c6140cc97a80..9233b5c0bcc8 100644
--- a/drivers/s390/cio/device.h
+++ b/drivers/s390/cio/device.h
@@ -78,7 +78,6 @@ void io_subchannel_recog_done(struct ccw_device *cdev);
78 78
79int ccw_device_cancel_halt_clear(struct ccw_device *); 79int ccw_device_cancel_halt_clear(struct ccw_device *);
80 80
81int ccw_device_register(struct ccw_device *);
82void ccw_device_do_unreg_rereg(void *); 81void ccw_device_do_unreg_rereg(void *);
83void ccw_device_call_sch_unregister(void *); 82void ccw_device_call_sch_unregister(void *);
84 83
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index c5ccd20b110c..79d89c368919 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -739,11 +739,16 @@ static void ap_scan_bus(void *data)
739 dev = bus_find_device(&ap_bus_type, NULL, 739 dev = bus_find_device(&ap_bus_type, NULL,
740 (void *)(unsigned long)qid, 740 (void *)(unsigned long)qid,
741 __ap_scan_bus); 741 __ap_scan_bus);
742 rc = ap_query_queue(qid, &queue_depth, &device_type);
743 if (dev && rc) {
744 put_device(dev);
745 device_unregister(dev);
746 continue;
747 }
742 if (dev) { 748 if (dev) {
743 put_device(dev); 749 put_device(dev);
744 continue; 750 continue;
745 } 751 }
746 rc = ap_query_queue(qid, &queue_depth, &device_type);
747 if (rc) 752 if (rc)
748 continue; 753 continue;
749 rc = ap_init_queue(qid); 754 rc = ap_init_queue(qid);
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 8f882690994d..74c0eac083e4 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -107,6 +107,10 @@ zfcp_address_to_sg(void *address, struct scatterlist *list)
107 (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) 107 (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
108 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ 108 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
109 109
110#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
111 /* max. number of (data buffer) SBALEs in largest SBAL chain
112 multiplied with number of sectors per 4k block */
113
110/* FIXME(tune): free space should be one max. SBAL chain plus what? */ 114/* FIXME(tune): free space should be one max. SBAL chain plus what? */
111#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \ 115#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \
112 - (ZFCP_MAX_SBALS_PER_REQ + 4)) 116 - (ZFCP_MAX_SBALS_PER_REQ + 4))
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 4d2bc7981324..452d96f92a14 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -58,6 +58,7 @@ struct zfcp_data zfcp_data = {
58 .cmd_per_lun = 1, 58 .cmd_per_lun = 1,
59 .use_clustering = 1, 59 .use_clustering = 1,
60 .sdev_attrs = zfcp_sysfs_sdev_attrs, 60 .sdev_attrs = zfcp_sysfs_sdev_attrs,
61 .max_sectors = ZFCP_MAX_SECTORS,
61 }, 62 },
62 .driver_version = ZFCP_VERSION, 63 .driver_version = ZFCP_VERSION,
63}; 64};
diff --git a/drivers/sbus/sbus.c b/drivers/sbus/sbus.c
index 935952ef88f1..98fcbb3d5560 100644
--- a/drivers/sbus/sbus.c
+++ b/drivers/sbus/sbus.c
@@ -61,11 +61,11 @@ static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sde
61 else 61 else
62 sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev; 62 sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev;
63 sdev->ofdev.dev.bus = &sbus_bus_type; 63 sdev->ofdev.dev.bus = &sbus_bus_type;
64 strcpy(sdev->ofdev.dev.bus_id, dp->path_component_name); 64 sprintf(sdev->ofdev.dev.bus_id, "sbus[%08x]", dp->node);
65 65
66 if (of_device_register(&sdev->ofdev) != 0) 66 if (of_device_register(&sdev->ofdev) != 0)
67 printk(KERN_DEBUG "sbus: device registration error for %s!\n", 67 printk(KERN_DEBUG "sbus: device registration error for %s!\n",
68 sdev->ofdev.dev.bus_id); 68 dp->path_component_name);
69} 69}
70 70
71static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus) 71static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus)
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 5f8c26cd66ca..b091a0fc4eb0 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -66,6 +66,9 @@
66 2.26.02.006 - Fix 9550SX pchip reset timeout. 66 2.26.02.006 - Fix 9550SX pchip reset timeout.
67 Add big endian support. 67 Add big endian support.
68 2.26.02.007 - Disable local interrupts during kmap/unmap_atomic(). 68 2.26.02.007 - Disable local interrupts during kmap/unmap_atomic().
69 2.26.02.008 - Free irq handler in __twa_shutdown().
70 Serialize reset code.
71 Add support for 9650SE controllers.
69*/ 72*/
70 73
71#include <linux/module.h> 74#include <linux/module.h>
@@ -89,7 +92,7 @@
89#include "3w-9xxx.h" 92#include "3w-9xxx.h"
90 93
91/* Globals */ 94/* Globals */
92#define TW_DRIVER_VERSION "2.26.02.007" 95#define TW_DRIVER_VERSION "2.26.02.008"
93static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 96static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
94static unsigned int twa_device_extension_count; 97static unsigned int twa_device_extension_count;
95static int twa_major = -1; 98static int twa_major = -1;
@@ -566,9 +569,9 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed)
566 goto out; 569 goto out;
567 } 570 }
568 571
569 tw_dev->working_srl = fw_on_ctlr_srl; 572 tw_dev->tw_compat_info.working_srl = fw_on_ctlr_srl;
570 tw_dev->working_branch = fw_on_ctlr_branch; 573 tw_dev->tw_compat_info.working_branch = fw_on_ctlr_branch;
571 tw_dev->working_build = fw_on_ctlr_build; 574 tw_dev->tw_compat_info.working_build = fw_on_ctlr_build;
572 575
573 /* Try base mode compatibility */ 576 /* Try base mode compatibility */
574 if (!(init_connect_result & TW_CTLR_FW_COMPATIBLE)) { 577 if (!(init_connect_result & TW_CTLR_FW_COMPATIBLE)) {
@@ -590,10 +593,23 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed)
590 } 593 }
591 goto out; 594 goto out;
592 } 595 }
593 tw_dev->working_srl = TW_BASE_FW_SRL; 596 tw_dev->tw_compat_info.working_srl = TW_BASE_FW_SRL;
594 tw_dev->working_branch = TW_BASE_FW_BRANCH; 597 tw_dev->tw_compat_info.working_branch = TW_BASE_FW_BRANCH;
595 tw_dev->working_build = TW_BASE_FW_BUILD; 598 tw_dev->tw_compat_info.working_build = TW_BASE_FW_BUILD;
596 } 599 }
600
601 /* Load rest of compatibility struct */
602 strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION));
603 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
604 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
605 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
606 tw_dev->tw_compat_info.driver_srl_low = TW_BASE_FW_SRL;
607 tw_dev->tw_compat_info.driver_branch_low = TW_BASE_FW_BRANCH;
608 tw_dev->tw_compat_info.driver_build_low = TW_BASE_FW_BUILD;
609 tw_dev->tw_compat_info.fw_on_ctlr_srl = fw_on_ctlr_srl;
610 tw_dev->tw_compat_info.fw_on_ctlr_branch = fw_on_ctlr_branch;
611 tw_dev->tw_compat_info.fw_on_ctlr_build = fw_on_ctlr_build;
612
597 retval = 0; 613 retval = 0;
598out: 614out:
599 return retval; 615 return retval;
@@ -631,7 +647,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
631 goto out2; 647 goto out2;
632 648
633 /* Check data buffer size */ 649 /* Check data buffer size */
634 if (driver_command.buffer_length > TW_MAX_SECTORS * 512) { 650 if (driver_command.buffer_length > TW_MAX_SECTORS * 2048) {
635 retval = TW_IOCTL_ERROR_OS_EINVAL; 651 retval = TW_IOCTL_ERROR_OS_EINVAL;
636 goto out2; 652 goto out2;
637 } 653 }
@@ -680,13 +696,6 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
680 /* Now wait for command to complete */ 696 /* Now wait for command to complete */
681 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout); 697 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
682 698
683 /* See if we reset while waiting for the ioctl to complete */
684 if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
685 clear_bit(TW_IN_RESET, &tw_dev->flags);
686 retval = TW_IOCTL_ERROR_OS_ERESTARTSYS;
687 goto out3;
688 }
689
690 /* We timed out, and didn't get an interrupt */ 699 /* We timed out, and didn't get an interrupt */
691 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) { 700 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) {
692 /* Now we need to reset the board */ 701 /* Now we need to reset the board */
@@ -694,11 +703,6 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
694 tw_dev->host->host_no, TW_DRIVER, 0xc, 703 tw_dev->host->host_no, TW_DRIVER, 0xc,
695 cmd); 704 cmd);
696 retval = TW_IOCTL_ERROR_OS_EIO; 705 retval = TW_IOCTL_ERROR_OS_EIO;
697 spin_lock_irqsave(tw_dev->host->host_lock, flags);
698 tw_dev->state[request_id] = TW_S_COMPLETED;
699 twa_free_request_id(tw_dev, request_id);
700 tw_dev->posted_request_count--;
701 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
702 twa_reset_device_extension(tw_dev, 1); 706 twa_reset_device_extension(tw_dev, 1);
703 goto out3; 707 goto out3;
704 } 708 }
@@ -717,16 +721,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
717 tw_ioctl->driver_command.status = 0; 721 tw_ioctl->driver_command.status = 0;
718 /* Copy compatiblity struct into ioctl data buffer */ 722 /* Copy compatiblity struct into ioctl data buffer */
719 tw_compat_info = (TW_Compatibility_Info *)tw_ioctl->data_buffer; 723 tw_compat_info = (TW_Compatibility_Info *)tw_ioctl->data_buffer;
720 strncpy(tw_compat_info->driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION)); 724 memcpy(tw_compat_info, &tw_dev->tw_compat_info, sizeof(TW_Compatibility_Info));
721 tw_compat_info->working_srl = tw_dev->working_srl;
722 tw_compat_info->working_branch = tw_dev->working_branch;
723 tw_compat_info->working_build = tw_dev->working_build;
724 tw_compat_info->driver_srl_high = TW_CURRENT_DRIVER_SRL;
725 tw_compat_info->driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
726 tw_compat_info->driver_build_high = TW_CURRENT_DRIVER_BUILD;
727 tw_compat_info->driver_srl_low = TW_BASE_FW_SRL;
728 tw_compat_info->driver_branch_low = TW_BASE_FW_BRANCH;
729 tw_compat_info->driver_build_low = TW_BASE_FW_BUILD;
730 break; 725 break;
731 case TW_IOCTL_GET_LAST_EVENT: 726 case TW_IOCTL_GET_LAST_EVENT:
732 if (tw_dev->event_queue_wrapped) { 727 if (tw_dev->event_queue_wrapped) {
@@ -895,7 +890,8 @@ static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value)
895 } 890 }
896 891
897 if (status_reg_value & TW_STATUS_QUEUE_ERROR) { 892 if (status_reg_value & TW_STATUS_QUEUE_ERROR) {
898 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing"); 893 if ((tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9650SE) || (!test_bit(TW_IN_RESET, &tw_dev->flags)))
894 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing");
899 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); 895 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
900 } 896 }
901 897
@@ -939,10 +935,12 @@ static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev)
939 unsigned long before; 935 unsigned long before;
940 int retval = 1; 936 int retval = 1;
941 937
942 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) { 938 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) ||
939 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE)) {
943 before = jiffies; 940 before = jiffies;
944 while ((response_que_value & TW_9550SX_DRAIN_COMPLETED) != TW_9550SX_DRAIN_COMPLETED) { 941 while ((response_que_value & TW_9550SX_DRAIN_COMPLETED) != TW_9550SX_DRAIN_COMPLETED) {
945 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev)); 942 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev));
943 msleep(1);
946 if (time_after(jiffies, before + HZ * 30)) 944 if (time_after(jiffies, before + HZ * 30))
947 goto out; 945 goto out;
948 } 946 }
@@ -1214,6 +1212,10 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1214 1212
1215 handled = 1; 1213 handled = 1;
1216 1214
1215 /* If we are resetting, bail */
1216 if (test_bit(TW_IN_RESET, &tw_dev->flags))
1217 goto twa_interrupt_bail;
1218
1217 /* Check controller for errors */ 1219 /* Check controller for errors */
1218 if (twa_check_bits(status_reg_value)) { 1220 if (twa_check_bits(status_reg_value)) {
1219 if (twa_decode_bits(tw_dev, status_reg_value)) { 1221 if (twa_decode_bits(tw_dev, status_reg_value)) {
@@ -1355,8 +1357,8 @@ static void twa_load_sgl(TW_Command_Full *full_command_packet, int request_id, d
1355 1357
1356 if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) { 1358 if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) {
1357 newcommand = &full_command_packet->command.newcommand; 1359 newcommand = &full_command_packet->command.newcommand;
1358 newcommand->request_id__lunl = 1360 newcommand->request_id__lunl =
1359 TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->request_id__lunl), request_id); 1361 cpu_to_le16(TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->request_id__lunl), request_id));
1360 newcommand->sg_list[0].address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1); 1362 newcommand->sg_list[0].address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1);
1361 newcommand->sg_list[0].length = cpu_to_le32(length); 1363 newcommand->sg_list[0].length = cpu_to_le32(length);
1362 newcommand->sgl_entries__lunh = 1364 newcommand->sgl_entries__lunh =
@@ -1531,6 +1533,13 @@ static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id,
1531 int retval = 1; 1533 int retval = 1;
1532 1534
1533 command_que_value = tw_dev->command_packet_phys[request_id]; 1535 command_que_value = tw_dev->command_packet_phys[request_id];
1536
1537 /* For 9650SE write low 4 bytes first */
1538 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) {
1539 command_que_value += TW_COMMAND_OFFSET;
1540 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev));
1541 }
1542
1534 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); 1543 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
1535 1544
1536 if (twa_check_bits(status_reg_value)) 1545 if (twa_check_bits(status_reg_value))
@@ -1557,13 +1566,17 @@ static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id,
1557 TW_UNMASK_COMMAND_INTERRUPT(tw_dev); 1566 TW_UNMASK_COMMAND_INTERRUPT(tw_dev);
1558 goto out; 1567 goto out;
1559 } else { 1568 } else {
1560 /* We successfully posted the command packet */ 1569 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) {
1561 if (sizeof(dma_addr_t) > 4) { 1570 /* Now write upper 4 bytes */
1562 command_que_value += TW_COMMAND_OFFSET; 1571 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev) + 0x4);
1563 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1564 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR(tw_dev) + 0x4);
1565 } else { 1572 } else {
1566 writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); 1573 if (sizeof(dma_addr_t) > 4) {
1574 command_que_value += TW_COMMAND_OFFSET;
1575 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1576 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR(tw_dev) + 0x4);
1577 } else {
1578 writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1579 }
1567 } 1580 }
1568 tw_dev->state[request_id] = TW_S_POSTED; 1581 tw_dev->state[request_id] = TW_S_POSTED;
1569 tw_dev->posted_request_count++; 1582 tw_dev->posted_request_count++;
@@ -1620,14 +1633,9 @@ static int twa_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res
1620 goto out; 1633 goto out;
1621 1634
1622 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); 1635 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
1636 clear_bit(TW_IN_RESET, &tw_dev->flags);
1637 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1623 1638
1624 /* Wake up any ioctl that was pending before the reset */
1625 if ((tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE) || (ioctl_reset)) {
1626 clear_bit(TW_IN_RESET, &tw_dev->flags);
1627 } else {
1628 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1629 wake_up(&tw_dev->ioctl_wqueue);
1630 }
1631 retval = 0; 1639 retval = 0;
1632out: 1640out:
1633 return retval; 1641 return retval;
@@ -1736,6 +1744,9 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
1736 "WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n", 1744 "WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n",
1737 TW_DRIVER, 0x2c, SCpnt->cmnd[0]); 1745 TW_DRIVER, 0x2c, SCpnt->cmnd[0]);
1738 1746
1747 /* Make sure we are not issuing an ioctl or resetting from ioctl */
1748 mutex_lock(&tw_dev->ioctl_lock);
1749
1739 /* Now reset the card and some of the device extension data */ 1750 /* Now reset the card and some of the device extension data */
1740 if (twa_reset_device_extension(tw_dev, 0)) { 1751 if (twa_reset_device_extension(tw_dev, 0)) {
1741 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset"); 1752 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset");
@@ -1744,6 +1755,7 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
1744 1755
1745 retval = SUCCESS; 1756 retval = SUCCESS;
1746out: 1757out:
1758 mutex_unlock(&tw_dev->ioctl_lock);
1747 return retval; 1759 return retval;
1748} /* End twa_scsi_eh_reset() */ 1760} /* End twa_scsi_eh_reset() */
1749 1761
@@ -1753,8 +1765,14 @@ static int twa_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd
1753 int request_id, retval; 1765 int request_id, retval;
1754 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; 1766 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
1755 1767
1768 /* If we are resetting due to timed out ioctl, report as busy */
1769 if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
1770 retval = SCSI_MLQUEUE_HOST_BUSY;
1771 goto out;
1772 }
1773
1756 /* Check if this FW supports luns */ 1774 /* Check if this FW supports luns */
1757 if ((SCpnt->device->lun != 0) && (tw_dev->working_srl < TW_FW_SRL_LUNS_SUPPORTED)) { 1775 if ((SCpnt->device->lun != 0) && (tw_dev->tw_compat_info.working_srl < TW_FW_SRL_LUNS_SUPPORTED)) {
1758 SCpnt->result = (DID_BAD_TARGET << 16); 1776 SCpnt->result = (DID_BAD_TARGET << 16);
1759 done(SCpnt); 1777 done(SCpnt);
1760 retval = 0; 1778 retval = 0;
@@ -1960,6 +1978,9 @@ static void __twa_shutdown(TW_Device_Extension *tw_dev)
1960 /* Disable interrupts */ 1978 /* Disable interrupts */
1961 TW_DISABLE_INTERRUPTS(tw_dev); 1979 TW_DISABLE_INTERRUPTS(tw_dev);
1962 1980
1981 /* Free up the IRQ */
1982 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
1983
1963 printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no); 1984 printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no);
1964 1985
1965 /* Tell the card we are shutting down */ 1986 /* Tell the card we are shutting down */
@@ -2091,21 +2112,25 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2091 2112
2092 /* Initialize the card */ 2113 /* Initialize the card */
2093 if (twa_reset_sequence(tw_dev, 0)) 2114 if (twa_reset_sequence(tw_dev, 0))
2094 goto out_release_mem_region; 2115 goto out_iounmap;
2095 2116
2096 /* Set host specific parameters */ 2117 /* Set host specific parameters */
2097 host->max_id = TW_MAX_UNITS; 2118 if (pdev->device == PCI_DEVICE_ID_3WARE_9650SE)
2119 host->max_id = TW_MAX_UNITS_9650SE;
2120 else
2121 host->max_id = TW_MAX_UNITS;
2122
2098 host->max_cmd_len = TW_MAX_CDB_LEN; 2123 host->max_cmd_len = TW_MAX_CDB_LEN;
2099 2124
2100 /* Channels aren't supported by adapter */ 2125 /* Channels aren't supported by adapter */
2101 host->max_lun = TW_MAX_LUNS(tw_dev->working_srl); 2126 host->max_lun = TW_MAX_LUNS(tw_dev->tw_compat_info.working_srl);
2102 host->max_channel = 0; 2127 host->max_channel = 0;
2103 2128
2104 /* Register the card with the kernel SCSI layer */ 2129 /* Register the card with the kernel SCSI layer */
2105 retval = scsi_add_host(host, &pdev->dev); 2130 retval = scsi_add_host(host, &pdev->dev);
2106 if (retval) { 2131 if (retval) {
2107 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed"); 2132 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed");
2108 goto out_release_mem_region; 2133 goto out_iounmap;
2109 } 2134 }
2110 2135
2111 pci_set_drvdata(pdev, host); 2136 pci_set_drvdata(pdev, host);
@@ -2145,6 +2170,8 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2145 2170
2146out_remove_host: 2171out_remove_host:
2147 scsi_remove_host(host); 2172 scsi_remove_host(host);
2173out_iounmap:
2174 iounmap(tw_dev->base_addr);
2148out_release_mem_region: 2175out_release_mem_region:
2149 pci_release_regions(pdev); 2176 pci_release_regions(pdev);
2150out_free_device_extension: 2177out_free_device_extension:
@@ -2170,12 +2197,12 @@ static void twa_remove(struct pci_dev *pdev)
2170 twa_major = -1; 2197 twa_major = -1;
2171 } 2198 }
2172 2199
2173 /* Free up the IRQ */
2174 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
2175
2176 /* Shutdown the card */ 2200 /* Shutdown the card */
2177 __twa_shutdown(tw_dev); 2201 __twa_shutdown(tw_dev);
2178 2202
2203 /* Free IO remapping */
2204 iounmap(tw_dev->base_addr);
2205
2179 /* Free up the mem region */ 2206 /* Free up the mem region */
2180 pci_release_regions(pdev); 2207 pci_release_regions(pdev);
2181 2208
@@ -2193,6 +2220,8 @@ static struct pci_device_id twa_pci_tbl[] __devinitdata = {
2193 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2220 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2194 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX, 2221 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX,
2195 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2222 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2223 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9650SE,
2224 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2196 { } 2225 { }
2197}; 2226};
2198MODULE_DEVICE_TABLE(pci, twa_pci_tbl); 2227MODULE_DEVICE_TABLE(pci, twa_pci_tbl);
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index e5685be96f45..7901517d4513 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -289,7 +289,6 @@ static twa_message_type twa_error_table[] = {
289#define TW_STATUS_VALID_INTERRUPT 0x00DF0000 289#define TW_STATUS_VALID_INTERRUPT 0x00DF0000
290 290
291/* PCI related defines */ 291/* PCI related defines */
292#define TW_NUMDEVICES 1
293#define TW_PCI_CLEAR_PARITY_ERRORS 0xc100 292#define TW_PCI_CLEAR_PARITY_ERRORS 0xc100
294#define TW_PCI_CLEAR_PCI_ABORT 0x2000 293#define TW_PCI_CLEAR_PCI_ABORT 0x2000
295 294
@@ -335,6 +334,7 @@ static twa_message_type twa_error_table[] = {
335#define TW_ALIGNMENT_9000 4 /* 4 bytes */ 334#define TW_ALIGNMENT_9000 4 /* 4 bytes */
336#define TW_ALIGNMENT_9000_SGL 0x3 335#define TW_ALIGNMENT_9000_SGL 0x3
337#define TW_MAX_UNITS 16 336#define TW_MAX_UNITS 16
337#define TW_MAX_UNITS_9650SE 32
338#define TW_INIT_MESSAGE_CREDITS 0x100 338#define TW_INIT_MESSAGE_CREDITS 0x100
339#define TW_INIT_COMMAND_PACKET_SIZE 0x3 339#define TW_INIT_COMMAND_PACKET_SIZE 0x3
340#define TW_INIT_COMMAND_PACKET_SIZE_EXTENDED 0x6 340#define TW_INIT_COMMAND_PACKET_SIZE_EXTENDED 0x6
@@ -354,7 +354,6 @@ static twa_message_type twa_error_table[] = {
354#define TW_MAX_RESPONSE_DRAIN 256 354#define TW_MAX_RESPONSE_DRAIN 256
355#define TW_MAX_AEN_DRAIN 40 355#define TW_MAX_AEN_DRAIN 40
356#define TW_IN_RESET 2 356#define TW_IN_RESET 2
357#define TW_IN_CHRDEV_IOCTL 3
358#define TW_IN_ATTENTION_LOOP 4 357#define TW_IN_ATTENTION_LOOP 4
359#define TW_MAX_SECTORS 256 358#define TW_MAX_SECTORS 256
360#define TW_AEN_WAIT_TIME 1000 359#define TW_AEN_WAIT_TIME 1000
@@ -417,6 +416,9 @@ static twa_message_type twa_error_table[] = {
417#ifndef PCI_DEVICE_ID_3WARE_9550SX 416#ifndef PCI_DEVICE_ID_3WARE_9550SX
418#define PCI_DEVICE_ID_3WARE_9550SX 0x1003 417#define PCI_DEVICE_ID_3WARE_9550SX 0x1003
419#endif 418#endif
419#ifndef PCI_DEVICE_ID_3WARE_9650SE
420#define PCI_DEVICE_ID_3WARE_9650SE 0x1004
421#endif
420 422
421/* Bitmask macros to eliminate bitfields */ 423/* Bitmask macros to eliminate bitfields */
422 424
@@ -442,6 +444,7 @@ static twa_message_type twa_error_table[] = {
442#define TW_CONTROL_REG_ADDR(x) (x->base_addr) 444#define TW_CONTROL_REG_ADDR(x) (x->base_addr)
443#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4) 445#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4)
444#define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8)) 446#define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8))
447#define TW_COMMAND_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x20)
445#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC) 448#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC)
446#define TW_RESPONSE_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x30) 449#define TW_RESPONSE_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x30)
447#define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 450#define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
@@ -626,6 +629,9 @@ typedef struct TAG_TW_Compatibility_Info
626 unsigned short driver_srl_low; 629 unsigned short driver_srl_low;
627 unsigned short driver_branch_low; 630 unsigned short driver_branch_low;
628 unsigned short driver_build_low; 631 unsigned short driver_build_low;
632 unsigned short fw_on_ctlr_srl;
633 unsigned short fw_on_ctlr_branch;
634 unsigned short fw_on_ctlr_build;
629} TW_Compatibility_Info; 635} TW_Compatibility_Info;
630 636
631#pragma pack() 637#pragma pack()
@@ -668,9 +674,7 @@ typedef struct TAG_TW_Device_Extension {
668 wait_queue_head_t ioctl_wqueue; 674 wait_queue_head_t ioctl_wqueue;
669 struct mutex ioctl_lock; 675 struct mutex ioctl_lock;
670 char aen_clobber; 676 char aen_clobber;
671 unsigned short working_srl; 677 TW_Compatibility_Info tw_compat_info;
672 unsigned short working_branch;
673 unsigned short working_build;
674} TW_Device_Extension; 678} TW_Device_Extension;
675 679
676#endif /* _3W_9XXX_H */ 680#endif /* _3W_9XXX_H */
diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h
index df3346b5caf8..170a4344cbb2 100644
--- a/drivers/scsi/aic7xxx/aic79xx.h
+++ b/drivers/scsi/aic7xxx/aic79xx.h
@@ -53,14 +53,6 @@ struct ahd_platform_data;
53struct scb_platform_data; 53struct scb_platform_data;
54 54
55/****************************** Useful Macros *********************************/ 55/****************************** Useful Macros *********************************/
56#ifndef MAX
57#define MAX(a,b) (((a) > (b)) ? (a) : (b))
58#endif
59
60#ifndef MIN
61#define MIN(a,b) (((a) < (b)) ? (a) : (b))
62#endif
63
64#ifndef TRUE 56#ifndef TRUE
65#define TRUE 1 57#define TRUE 1
66#endif 58#endif
@@ -972,8 +964,6 @@ int ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
972 964
973int ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf, 965int ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
974 u_int start_addr, u_int count); 966 u_int start_addr, u_int count);
975int ahd_wait_seeprom(struct ahd_softc *ahd);
976int ahd_verify_vpd_cksum(struct vpd_config *vpd);
977int ahd_verify_cksum(struct seeprom_config *sc); 967int ahd_verify_cksum(struct seeprom_config *sc);
978int ahd_acquire_seeprom(struct ahd_softc *ahd); 968int ahd_acquire_seeprom(struct ahd_softc *ahd);
979void ahd_release_seeprom(struct ahd_softc *ahd); 969void ahd_release_seeprom(struct ahd_softc *ahd);
@@ -1320,8 +1310,6 @@ struct ahd_pci_identity {
1320 char *name; 1310 char *name;
1321 ahd_device_setup_t *setup; 1311 ahd_device_setup_t *setup;
1322}; 1312};
1323extern struct ahd_pci_identity ahd_pci_ident_table [];
1324extern const u_int ahd_num_pci_devs;
1325 1313
1326/***************************** VL/EISA Declarations ***************************/ 1314/***************************** VL/EISA Declarations ***************************/
1327struct aic7770_identity { 1315struct aic7770_identity {
@@ -1339,15 +1327,6 @@ extern const int ahd_num_aic7770_devs;
1339/*************************** Function Declarations ****************************/ 1327/*************************** Function Declarations ****************************/
1340/******************************************************************************/ 1328/******************************************************************************/
1341void ahd_reset_cmds_pending(struct ahd_softc *ahd); 1329void ahd_reset_cmds_pending(struct ahd_softc *ahd);
1342u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
1343void ahd_busy_tcl(struct ahd_softc *ahd,
1344 u_int tcl, u_int busyid);
1345static __inline void ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl);
1346static __inline void
1347ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
1348{
1349 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
1350}
1351 1330
1352/***************************** PCI Front End *********************************/ 1331/***************************** PCI Front End *********************************/
1353struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t); 1332struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);
@@ -1356,7 +1335,6 @@ int ahd_pci_config(struct ahd_softc *,
1356int ahd_pci_test_register_access(struct ahd_softc *); 1335int ahd_pci_test_register_access(struct ahd_softc *);
1357 1336
1358/************************** SCB and SCB queue management **********************/ 1337/************************** SCB and SCB queue management **********************/
1359int ahd_probe_scbs(struct ahd_softc *);
1360void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, 1338void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd,
1361 struct scb *scb); 1339 struct scb *scb);
1362int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, 1340int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
@@ -1374,33 +1352,20 @@ int ahd_parse_vpddata(struct ahd_softc *ahd,
1374int ahd_parse_cfgdata(struct ahd_softc *ahd, 1352int ahd_parse_cfgdata(struct ahd_softc *ahd,
1375 struct seeprom_config *sc); 1353 struct seeprom_config *sc);
1376void ahd_intr_enable(struct ahd_softc *ahd, int enable); 1354void ahd_intr_enable(struct ahd_softc *ahd, int enable);
1377void ahd_update_coalescing_values(struct ahd_softc *ahd,
1378 u_int timer,
1379 u_int maxcmds,
1380 u_int mincmds);
1381void ahd_enable_coalescing(struct ahd_softc *ahd,
1382 int enable);
1383void ahd_pause_and_flushwork(struct ahd_softc *ahd); 1355void ahd_pause_and_flushwork(struct ahd_softc *ahd);
1384int ahd_suspend(struct ahd_softc *ahd); 1356int ahd_suspend(struct ahd_softc *ahd);
1385int ahd_resume(struct ahd_softc *ahd);
1386void ahd_set_unit(struct ahd_softc *, int); 1357void ahd_set_unit(struct ahd_softc *, int);
1387void ahd_set_name(struct ahd_softc *, char *); 1358void ahd_set_name(struct ahd_softc *, char *);
1388struct scb *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx); 1359struct scb *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx);
1389void ahd_free_scb(struct ahd_softc *ahd, struct scb *scb); 1360void ahd_free_scb(struct ahd_softc *ahd, struct scb *scb);
1390void ahd_alloc_scbs(struct ahd_softc *ahd);
1391void ahd_free(struct ahd_softc *ahd); 1361void ahd_free(struct ahd_softc *ahd);
1392int ahd_reset(struct ahd_softc *ahd, int reinit); 1362int ahd_reset(struct ahd_softc *ahd, int reinit);
1393void ahd_shutdown(void *arg);
1394int ahd_write_flexport(struct ahd_softc *ahd, 1363int ahd_write_flexport(struct ahd_softc *ahd,
1395 u_int addr, u_int value); 1364 u_int addr, u_int value);
1396int ahd_read_flexport(struct ahd_softc *ahd, u_int addr, 1365int ahd_read_flexport(struct ahd_softc *ahd, u_int addr,
1397 uint8_t *value); 1366 uint8_t *value);
1398int ahd_wait_flexport(struct ahd_softc *ahd);
1399 1367
1400/*************************** Interrupt Services *******************************/ 1368/*************************** Interrupt Services *******************************/
1401void ahd_pci_intr(struct ahd_softc *ahd);
1402void ahd_clear_intstat(struct ahd_softc *ahd);
1403void ahd_flush_qoutfifo(struct ahd_softc *ahd);
1404void ahd_run_qoutfifo(struct ahd_softc *ahd); 1369void ahd_run_qoutfifo(struct ahd_softc *ahd);
1405#ifdef AHD_TARGET_MODE 1370#ifdef AHD_TARGET_MODE
1406void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused); 1371void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
@@ -1409,7 +1374,6 @@ void ahd_handle_hwerrint(struct ahd_softc *ahd);
1409void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat); 1374void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
1410void ahd_handle_scsiint(struct ahd_softc *ahd, 1375void ahd_handle_scsiint(struct ahd_softc *ahd,
1411 u_int intstat); 1376 u_int intstat);
1412void ahd_clear_critical_section(struct ahd_softc *ahd);
1413 1377
1414/***************************** Error Recovery *********************************/ 1378/***************************** Error Recovery *********************************/
1415typedef enum { 1379typedef enum {
@@ -1426,23 +1390,9 @@ int ahd_search_disc_list(struct ahd_softc *ahd, int target,
1426 char channel, int lun, u_int tag, 1390 char channel, int lun, u_int tag,
1427 int stop_on_first, int remove, 1391 int stop_on_first, int remove,
1428 int save_state); 1392 int save_state);
1429void ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
1430int ahd_reset_channel(struct ahd_softc *ahd, char channel, 1393int ahd_reset_channel(struct ahd_softc *ahd, char channel,
1431 int initiate_reset); 1394 int initiate_reset);
1432int ahd_abort_scbs(struct ahd_softc *ahd, int target,
1433 char channel, int lun, u_int tag,
1434 role_t role, uint32_t status);
1435void ahd_restart(struct ahd_softc *ahd);
1436void ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo);
1437void ahd_handle_scb_status(struct ahd_softc *ahd,
1438 struct scb *scb);
1439void ahd_handle_scsi_status(struct ahd_softc *ahd,
1440 struct scb *scb);
1441void ahd_calc_residual(struct ahd_softc *ahd,
1442 struct scb *scb);
1443/*************************** Utility Functions ********************************/ 1395/*************************** Utility Functions ********************************/
1444struct ahd_phase_table_entry*
1445 ahd_lookup_phase_entry(int phase);
1446void ahd_compile_devinfo(struct ahd_devinfo *devinfo, 1396void ahd_compile_devinfo(struct ahd_devinfo *devinfo,
1447 u_int our_id, u_int target, 1397 u_int our_id, u_int target,
1448 u_int lun, char channel, 1398 u_int lun, char channel,
@@ -1450,14 +1400,6 @@ void ahd_compile_devinfo(struct ahd_devinfo *devinfo,
1450/************************** Transfer Negotiation ******************************/ 1400/************************** Transfer Negotiation ******************************/
1451void ahd_find_syncrate(struct ahd_softc *ahd, u_int *period, 1401void ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
1452 u_int *ppr_options, u_int maxsync); 1402 u_int *ppr_options, u_int maxsync);
1453void ahd_validate_offset(struct ahd_softc *ahd,
1454 struct ahd_initiator_tinfo *tinfo,
1455 u_int period, u_int *offset,
1456 int wide, role_t role);
1457void ahd_validate_width(struct ahd_softc *ahd,
1458 struct ahd_initiator_tinfo *tinfo,
1459 u_int *bus_width,
1460 role_t role);
1461/* 1403/*
1462 * Negotiation types. These are used to qualify if we should renegotiate 1404 * Negotiation types. These are used to qualify if we should renegotiate
1463 * even if our goal and current transport parameters are identical. 1405 * even if our goal and current transport parameters are identical.
@@ -1486,11 +1428,6 @@ typedef enum {
1486 AHD_QUEUE_TAGGED 1428 AHD_QUEUE_TAGGED
1487} ahd_queue_alg; 1429} ahd_queue_alg;
1488 1430
1489void ahd_set_tags(struct ahd_softc *ahd,
1490 struct scsi_cmnd *cmd,
1491 struct ahd_devinfo *devinfo,
1492 ahd_queue_alg alg);
1493
1494/**************************** Target Mode *************************************/ 1431/**************************** Target Mode *************************************/
1495#ifdef AHD_TARGET_MODE 1432#ifdef AHD_TARGET_MODE
1496void ahd_send_lstate_events(struct ahd_softc *, 1433void ahd_send_lstate_events(struct ahd_softc *,
@@ -1528,10 +1465,8 @@ extern uint32_t ahd_debug;
1528#define AHD_SHOW_INT_COALESCING 0x10000 1465#define AHD_SHOW_INT_COALESCING 0x10000
1529#define AHD_DEBUG_SEQUENCER 0x20000 1466#define AHD_DEBUG_SEQUENCER 0x20000
1530#endif 1467#endif
1531void ahd_print_scb(struct scb *scb);
1532void ahd_print_devinfo(struct ahd_softc *ahd, 1468void ahd_print_devinfo(struct ahd_softc *ahd,
1533 struct ahd_devinfo *devinfo); 1469 struct ahd_devinfo *devinfo);
1534void ahd_dump_sglist(struct scb *scb);
1535void ahd_dump_card_state(struct ahd_softc *ahd); 1470void ahd_dump_card_state(struct ahd_softc *ahd);
1536int ahd_print_register(ahd_reg_parse_entry_t *table, 1471int ahd_print_register(ahd_reg_parse_entry_t *table,
1537 u_int num_entries, 1472 u_int num_entries,
@@ -1540,5 +1475,4 @@ int ahd_print_register(ahd_reg_parse_entry_t *table,
1540 u_int value, 1475 u_int value,
1541 u_int *cur_column, 1476 u_int *cur_column,
1542 u_int wrap_point); 1477 u_int wrap_point);
1543void ahd_dump_scbs(struct ahd_softc *ahd);
1544#endif /* _AIC79XX_H_ */ 1478#endif /* _AIC79XX_H_ */
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 653818d2f802..07a86a30f676 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -52,7 +52,7 @@
52 52
53 53
54/***************************** Lookup Tables **********************************/ 54/***************************** Lookup Tables **********************************/
55char *ahd_chip_names[] = 55static char *ahd_chip_names[] =
56{ 56{
57 "NONE", 57 "NONE",
58 "aic7901", 58 "aic7901",
@@ -237,10 +237,33 @@ static int ahd_handle_target_cmd(struct ahd_softc *ahd,
237 struct target_cmd *cmd); 237 struct target_cmd *cmd);
238#endif 238#endif
239 239
240static int ahd_abort_scbs(struct ahd_softc *ahd, int target,
241 char channel, int lun, u_int tag,
242 role_t role, uint32_t status);
243static void ahd_alloc_scbs(struct ahd_softc *ahd);
244static void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
245 u_int scbid);
246static void ahd_calc_residual(struct ahd_softc *ahd,
247 struct scb *scb);
248static void ahd_clear_critical_section(struct ahd_softc *ahd);
249static void ahd_clear_intstat(struct ahd_softc *ahd);
250static void ahd_enable_coalescing(struct ahd_softc *ahd,
251 int enable);
252static u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
253static void ahd_freeze_devq(struct ahd_softc *ahd,
254 struct scb *scb);
255static void ahd_handle_scb_status(struct ahd_softc *ahd,
256 struct scb *scb);
257static struct ahd_phase_table_entry* ahd_lookup_phase_entry(int phase);
258static void ahd_shutdown(void *arg);
259static void ahd_update_coalescing_values(struct ahd_softc *ahd,
260 u_int timer,
261 u_int maxcmds,
262 u_int mincmds);
263static int ahd_verify_vpd_cksum(struct vpd_config *vpd);
264static int ahd_wait_seeprom(struct ahd_softc *ahd);
265
240/******************************** Private Inlines *****************************/ 266/******************************** Private Inlines *****************************/
241static __inline void ahd_assert_atn(struct ahd_softc *ahd);
242static __inline int ahd_currently_packetized(struct ahd_softc *ahd);
243static __inline int ahd_set_active_fifo(struct ahd_softc *ahd);
244 267
245static __inline void 268static __inline void
246ahd_assert_atn(struct ahd_softc *ahd) 269ahd_assert_atn(struct ahd_softc *ahd)
@@ -294,11 +317,44 @@ ahd_set_active_fifo(struct ahd_softc *ahd)
294 } 317 }
295} 318}
296 319
320static __inline void
321ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
322{
323 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
324}
325
326/*
327 * Determine whether the sequencer reported a residual
328 * for this SCB/transaction.
329 */
330static __inline void
331ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
332{
333 uint32_t sgptr;
334
335 sgptr = ahd_le32toh(scb->hscb->sgptr);
336 if ((sgptr & SG_STATUS_VALID) != 0)
337 ahd_calc_residual(ahd, scb);
338}
339
340static __inline void
341ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
342{
343 uint32_t sgptr;
344
345 sgptr = ahd_le32toh(scb->hscb->sgptr);
346 if ((sgptr & SG_STATUS_VALID) != 0)
347 ahd_handle_scb_status(ahd, scb);
348 else
349 ahd_done(ahd, scb);
350}
351
352
297/************************* Sequencer Execution Control ************************/ 353/************************* Sequencer Execution Control ************************/
298/* 354/*
299 * Restart the sequencer program from address zero 355 * Restart the sequencer program from address zero
300 */ 356 */
301void 357static void
302ahd_restart(struct ahd_softc *ahd) 358ahd_restart(struct ahd_softc *ahd)
303{ 359{
304 360
@@ -342,7 +398,7 @@ ahd_restart(struct ahd_softc *ahd)
342 ahd_unpause(ahd); 398 ahd_unpause(ahd);
343} 399}
344 400
345void 401static void
346ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo) 402ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
347{ 403{
348 ahd_mode_state saved_modes; 404 ahd_mode_state saved_modes;
@@ -366,7 +422,7 @@ ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
366 * Flush and completed commands that are sitting in the command 422 * Flush and completed commands that are sitting in the command
367 * complete queues down on the chip but have yet to be dma'ed back up. 423 * complete queues down on the chip but have yet to be dma'ed back up.
368 */ 424 */
369void 425static void
370ahd_flush_qoutfifo(struct ahd_softc *ahd) 426ahd_flush_qoutfifo(struct ahd_softc *ahd)
371{ 427{
372 struct scb *scb; 428 struct scb *scb;
@@ -905,6 +961,51 @@ ahd_handle_hwerrint(struct ahd_softc *ahd)
905 ahd_free(ahd); 961 ahd_free(ahd);
906} 962}
907 963
964#ifdef AHD_DEBUG
965static void
966ahd_dump_sglist(struct scb *scb)
967{
968 int i;
969
970 if (scb->sg_count > 0) {
971 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
972 struct ahd_dma64_seg *sg_list;
973
974 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
975 for (i = 0; i < scb->sg_count; i++) {
976 uint64_t addr;
977 uint32_t len;
978
979 addr = ahd_le64toh(sg_list[i].addr);
980 len = ahd_le32toh(sg_list[i].len);
981 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
982 i,
983 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
984 (uint32_t)(addr & 0xFFFFFFFF),
985 sg_list[i].len & AHD_SG_LEN_MASK,
986 (sg_list[i].len & AHD_DMA_LAST_SEG)
987 ? " Last" : "");
988 }
989 } else {
990 struct ahd_dma_seg *sg_list;
991
992 sg_list = (struct ahd_dma_seg*)scb->sg_list;
993 for (i = 0; i < scb->sg_count; i++) {
994 uint32_t len;
995
996 len = ahd_le32toh(sg_list[i].len);
997 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
998 i,
999 (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
1000 ahd_le32toh(sg_list[i].addr),
1001 len & AHD_SG_LEN_MASK,
1002 len & AHD_DMA_LAST_SEG ? " Last" : "");
1003 }
1004 }
1005 }
1006}
1007#endif /* AHD_DEBUG */
1008
908void 1009void
909ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat) 1010ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
910{ 1011{
@@ -1053,10 +1154,12 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
1053 * If a target takes us into the command phase 1154 * If a target takes us into the command phase
1054 * assume that it has been externally reset and 1155 * assume that it has been externally reset and
1055 * has thus lost our previous packetized negotiation 1156 * has thus lost our previous packetized negotiation
1056 * agreement. 1157 * agreement. Since we have not sent an identify
1057 * Revert to async/narrow transfers until we 1158 * message and may not have fully qualified the
1058 * can renegotiate with the device and notify 1159 * connection, we change our command to TUR, assert
1059 * the OSM about the reset. 1160 * ATN and ABORT the task when we go to message in
1161 * phase. The OSM will see the REQUEUE_REQUEST
1162 * status and retry the command.
1060 */ 1163 */
1061 scbid = ahd_get_scbptr(ahd); 1164 scbid = ahd_get_scbptr(ahd);
1062 scb = ahd_lookup_scb(ahd, scbid); 1165 scb = ahd_lookup_scb(ahd, scbid);
@@ -1083,7 +1186,28 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
1083 ahd_set_syncrate(ahd, &devinfo, /*period*/0, 1186 ahd_set_syncrate(ahd, &devinfo, /*period*/0,
1084 /*offset*/0, /*ppr_options*/0, 1187 /*offset*/0, /*ppr_options*/0,
1085 AHD_TRANS_ACTIVE, /*paused*/TRUE); 1188 AHD_TRANS_ACTIVE, /*paused*/TRUE);
1086 scb->flags |= SCB_EXTERNAL_RESET; 1189 /* Hand-craft TUR command */
1190 ahd_outb(ahd, SCB_CDB_STORE, 0);
1191 ahd_outb(ahd, SCB_CDB_STORE+1, 0);
1192 ahd_outb(ahd, SCB_CDB_STORE+2, 0);
1193 ahd_outb(ahd, SCB_CDB_STORE+3, 0);
1194 ahd_outb(ahd, SCB_CDB_STORE+4, 0);
1195 ahd_outb(ahd, SCB_CDB_STORE+5, 0);
1196 ahd_outb(ahd, SCB_CDB_LEN, 6);
1197 scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE);
1198 scb->hscb->control |= MK_MESSAGE;
1199 ahd_outb(ahd, SCB_CONTROL, scb->hscb->control);
1200 ahd_outb(ahd, MSG_OUT, HOST_MSG);
1201 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
1202 /*
1203 * The lun is 0, regardless of the SCB's lun
1204 * as we have not sent an identify message.
1205 */
1206 ahd_outb(ahd, SAVED_LUN, 0);
1207 ahd_outb(ahd, SEQ_FLAGS, 0);
1208 ahd_assert_atn(ahd);
1209 scb->flags &= ~SCB_PACKETIZED;
1210 scb->flags |= SCB_ABORT|SCB_EXTERNAL_RESET;
1087 ahd_freeze_devq(ahd, scb); 1211 ahd_freeze_devq(ahd, scb);
1088 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); 1212 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
1089 ahd_freeze_scb(scb); 1213 ahd_freeze_scb(scb);
@@ -1519,8 +1643,10 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1519 /* 1643 /*
1520 * Ignore external resets after a bus reset. 1644 * Ignore external resets after a bus reset.
1521 */ 1645 */
1522 if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) 1646 if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) {
1647 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
1523 return; 1648 return;
1649 }
1524 1650
1525 /* 1651 /*
1526 * Clear bus reset flag 1652 * Clear bus reset flag
@@ -2200,6 +2326,22 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2200 if (sent_msg == MSG_ABORT_TAG) 2326 if (sent_msg == MSG_ABORT_TAG)
2201 tag = SCB_GET_TAG(scb); 2327 tag = SCB_GET_TAG(scb);
2202 2328
2329 if ((scb->flags & SCB_EXTERNAL_RESET) != 0) {
2330 /*
2331 * This abort is in response to an
2332 * unexpected switch to command phase
2333 * for a packetized connection. Since
2334 * the identify message was never sent,
2335 * "saved lun" is 0. We really want to
2336 * abort only the SCB that encountered
2337 * this error, which could have a different
2338 * lun. The SCB will be retried so the OS
2339 * will see the UA after renegotiating to
2340 * packetized.
2341 */
2342 tag = SCB_GET_TAG(scb);
2343 saved_lun = scb->hscb->lun;
2344 }
2203 found = ahd_abort_scbs(ahd, target, 'A', saved_lun, 2345 found = ahd_abort_scbs(ahd, target, 'A', saved_lun,
2204 tag, ROLE_INITIATOR, 2346 tag, ROLE_INITIATOR,
2205 CAM_REQ_ABORTED); 2347 CAM_REQ_ABORTED);
@@ -2523,7 +2665,7 @@ ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
2523} 2665}
2524 2666
2525#define AHD_MAX_STEPS 2000 2667#define AHD_MAX_STEPS 2000
2526void 2668static void
2527ahd_clear_critical_section(struct ahd_softc *ahd) 2669ahd_clear_critical_section(struct ahd_softc *ahd)
2528{ 2670{
2529 ahd_mode_state saved_modes; 2671 ahd_mode_state saved_modes;
@@ -2646,7 +2788,7 @@ ahd_clear_critical_section(struct ahd_softc *ahd)
2646/* 2788/*
2647 * Clear any pending interrupt status. 2789 * Clear any pending interrupt status.
2648 */ 2790 */
2649void 2791static void
2650ahd_clear_intstat(struct ahd_softc *ahd) 2792ahd_clear_intstat(struct ahd_softc *ahd)
2651{ 2793{
2652 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), 2794 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
@@ -2677,6 +2819,8 @@ ahd_clear_intstat(struct ahd_softc *ahd)
2677#ifdef AHD_DEBUG 2819#ifdef AHD_DEBUG
2678uint32_t ahd_debug = AHD_DEBUG_OPTS; 2820uint32_t ahd_debug = AHD_DEBUG_OPTS;
2679#endif 2821#endif
2822
2823#if 0
2680void 2824void
2681ahd_print_scb(struct scb *scb) 2825ahd_print_scb(struct scb *scb)
2682{ 2826{
@@ -2701,49 +2845,7 @@ ahd_print_scb(struct scb *scb)
2701 SCB_GET_TAG(scb)); 2845 SCB_GET_TAG(scb));
2702 ahd_dump_sglist(scb); 2846 ahd_dump_sglist(scb);
2703} 2847}
2704 2848#endif /* 0 */
2705void
2706ahd_dump_sglist(struct scb *scb)
2707{
2708 int i;
2709
2710 if (scb->sg_count > 0) {
2711 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
2712 struct ahd_dma64_seg *sg_list;
2713
2714 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
2715 for (i = 0; i < scb->sg_count; i++) {
2716 uint64_t addr;
2717 uint32_t len;
2718
2719 addr = ahd_le64toh(sg_list[i].addr);
2720 len = ahd_le32toh(sg_list[i].len);
2721 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
2722 i,
2723 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
2724 (uint32_t)(addr & 0xFFFFFFFF),
2725 sg_list[i].len & AHD_SG_LEN_MASK,
2726 (sg_list[i].len & AHD_DMA_LAST_SEG)
2727 ? " Last" : "");
2728 }
2729 } else {
2730 struct ahd_dma_seg *sg_list;
2731
2732 sg_list = (struct ahd_dma_seg*)scb->sg_list;
2733 for (i = 0; i < scb->sg_count; i++) {
2734 uint32_t len;
2735
2736 len = ahd_le32toh(sg_list[i].len);
2737 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
2738 i,
2739 (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
2740 ahd_le32toh(sg_list[i].addr),
2741 len & AHD_SG_LEN_MASK,
2742 len & AHD_DMA_LAST_SEG ? " Last" : "");
2743 }
2744 }
2745 }
2746}
2747 2849
2748/************************* Transfer Negotiation *******************************/ 2850/************************* Transfer Negotiation *******************************/
2749/* 2851/*
@@ -2850,14 +2952,14 @@ ahd_devlimited_syncrate(struct ahd_softc *ahd,
2850 transinfo = &tinfo->goal; 2952 transinfo = &tinfo->goal;
2851 *ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN); 2953 *ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN);
2852 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) { 2954 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
2853 maxsync = MAX(maxsync, AHD_SYNCRATE_ULTRA2); 2955 maxsync = max(maxsync, (u_int)AHD_SYNCRATE_ULTRA2);
2854 *ppr_options &= ~MSG_EXT_PPR_DT_REQ; 2956 *ppr_options &= ~MSG_EXT_PPR_DT_REQ;
2855 } 2957 }
2856 if (transinfo->period == 0) { 2958 if (transinfo->period == 0) {
2857 *period = 0; 2959 *period = 0;
2858 *ppr_options = 0; 2960 *ppr_options = 0;
2859 } else { 2961 } else {
2860 *period = MAX(*period, transinfo->period); 2962 *period = max(*period, (u_int)transinfo->period);
2861 ahd_find_syncrate(ahd, period, ppr_options, maxsync); 2963 ahd_find_syncrate(ahd, period, ppr_options, maxsync);
2862 } 2964 }
2863} 2965}
@@ -2906,7 +3008,7 @@ ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
2906 * Truncate the given synchronous offset to a value the 3008 * Truncate the given synchronous offset to a value the
2907 * current adapter type and syncrate are capable of. 3009 * current adapter type and syncrate are capable of.
2908 */ 3010 */
2909void 3011static void
2910ahd_validate_offset(struct ahd_softc *ahd, 3012ahd_validate_offset(struct ahd_softc *ahd,
2911 struct ahd_initiator_tinfo *tinfo, 3013 struct ahd_initiator_tinfo *tinfo,
2912 u_int period, u_int *offset, int wide, 3014 u_int period, u_int *offset, int wide,
@@ -2924,12 +3026,12 @@ ahd_validate_offset(struct ahd_softc *ahd,
2924 maxoffset = MAX_OFFSET_PACED; 3026 maxoffset = MAX_OFFSET_PACED;
2925 } else 3027 } else
2926 maxoffset = MAX_OFFSET_NON_PACED; 3028 maxoffset = MAX_OFFSET_NON_PACED;
2927 *offset = MIN(*offset, maxoffset); 3029 *offset = min(*offset, maxoffset);
2928 if (tinfo != NULL) { 3030 if (tinfo != NULL) {
2929 if (role == ROLE_TARGET) 3031 if (role == ROLE_TARGET)
2930 *offset = MIN(*offset, tinfo->user.offset); 3032 *offset = min(*offset, (u_int)tinfo->user.offset);
2931 else 3033 else
2932 *offset = MIN(*offset, tinfo->goal.offset); 3034 *offset = min(*offset, (u_int)tinfo->goal.offset);
2933 } 3035 }
2934} 3036}
2935 3037
@@ -2937,7 +3039,7 @@ ahd_validate_offset(struct ahd_softc *ahd,
2937 * Truncate the given transfer width parameter to a value the 3039 * Truncate the given transfer width parameter to a value the
2938 * current adapter type is capable of. 3040 * current adapter type is capable of.
2939 */ 3041 */
2940void 3042static void
2941ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, 3043ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
2942 u_int *bus_width, role_t role) 3044 u_int *bus_width, role_t role)
2943{ 3045{
@@ -2955,9 +3057,9 @@ ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
2955 } 3057 }
2956 if (tinfo != NULL) { 3058 if (tinfo != NULL) {
2957 if (role == ROLE_TARGET) 3059 if (role == ROLE_TARGET)
2958 *bus_width = MIN(tinfo->user.width, *bus_width); 3060 *bus_width = min((u_int)tinfo->user.width, *bus_width);
2959 else 3061 else
2960 *bus_width = MIN(tinfo->goal.width, *bus_width); 3062 *bus_width = min((u_int)tinfo->goal.width, *bus_width);
2961 } 3063 }
2962} 3064}
2963 3065
@@ -3210,7 +3312,7 @@ ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
3210/* 3312/*
3211 * Update the current state of tagged queuing for a given target. 3313 * Update the current state of tagged queuing for a given target.
3212 */ 3314 */
3213void 3315static void
3214ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd, 3316ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
3215 struct ahd_devinfo *devinfo, ahd_queue_alg alg) 3317 struct ahd_devinfo *devinfo, ahd_queue_alg alg)
3216{ 3318{
@@ -3466,7 +3568,7 @@ ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
3466 devinfo->target, devinfo->lun); 3568 devinfo->target, devinfo->lun);
3467} 3569}
3468 3570
3469struct ahd_phase_table_entry* 3571static struct ahd_phase_table_entry*
3470ahd_lookup_phase_entry(int phase) 3572ahd_lookup_phase_entry(int phase)
3471{ 3573{
3472 struct ahd_phase_table_entry *entry; 3574 struct ahd_phase_table_entry *entry;
@@ -5351,7 +5453,7 @@ ahd_free(struct ahd_softc *ahd)
5351 return; 5453 return;
5352} 5454}
5353 5455
5354void 5456static void
5355ahd_shutdown(void *arg) 5457ahd_shutdown(void *arg)
5356{ 5458{
5357 struct ahd_softc *ahd; 5459 struct ahd_softc *ahd;
@@ -5480,7 +5582,7 @@ ahd_reset(struct ahd_softc *ahd, int reinit)
5480/* 5582/*
5481 * Determine the number of SCBs available on the controller 5583 * Determine the number of SCBs available on the controller
5482 */ 5584 */
5483int 5585static int
5484ahd_probe_scbs(struct ahd_softc *ahd) { 5586ahd_probe_scbs(struct ahd_softc *ahd) {
5485 int i; 5587 int i;
5486 5588
@@ -5929,7 +6031,7 @@ ahd_free_scb(struct ahd_softc *ahd, struct scb *scb)
5929 ahd_platform_scb_free(ahd, scb); 6031 ahd_platform_scb_free(ahd, scb);
5930} 6032}
5931 6033
5932void 6034static void
5933ahd_alloc_scbs(struct ahd_softc *ahd) 6035ahd_alloc_scbs(struct ahd_softc *ahd)
5934{ 6036{
5935 struct scb_data *scb_data; 6037 struct scb_data *scb_data;
@@ -6057,9 +6159,9 @@ ahd_alloc_scbs(struct ahd_softc *ahd)
6057#endif 6159#endif
6058 } 6160 }
6059 6161
6060 newcount = MIN(scb_data->sense_left, scb_data->scbs_left); 6162 newcount = min(scb_data->sense_left, scb_data->scbs_left);
6061 newcount = MIN(newcount, scb_data->sgs_left); 6163 newcount = min(newcount, scb_data->sgs_left);
6062 newcount = MIN(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs)); 6164 newcount = min(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
6063 for (i = 0; i < newcount; i++) { 6165 for (i = 0; i < newcount; i++) {
6064 struct scb_platform_data *pdata; 6166 struct scb_platform_data *pdata;
6065 u_int col_tag; 6167 u_int col_tag;
@@ -6982,7 +7084,7 @@ ahd_intr_enable(struct ahd_softc *ahd, int enable)
6982 ahd_outb(ahd, HCNTRL, hcntrl); 7084 ahd_outb(ahd, HCNTRL, hcntrl);
6983} 7085}
6984 7086
6985void 7087static void
6986ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds, 7088ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
6987 u_int mincmds) 7089 u_int mincmds)
6988{ 7090{
@@ -7000,7 +7102,7 @@ ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
7000 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds); 7102 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds);
7001} 7103}
7002 7104
7003void 7105static void
7004ahd_enable_coalescing(struct ahd_softc *ahd, int enable) 7106ahd_enable_coalescing(struct ahd_softc *ahd, int enable)
7005{ 7107{
7006 7108
@@ -7070,6 +7172,7 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd)
7070 ahd->flags &= ~AHD_ALL_INTERRUPTS; 7172 ahd->flags &= ~AHD_ALL_INTERRUPTS;
7071} 7173}
7072 7174
7175#if 0
7073int 7176int
7074ahd_suspend(struct ahd_softc *ahd) 7177ahd_suspend(struct ahd_softc *ahd)
7075{ 7178{
@@ -7083,7 +7186,9 @@ ahd_suspend(struct ahd_softc *ahd)
7083 ahd_shutdown(ahd); 7186 ahd_shutdown(ahd);
7084 return (0); 7187 return (0);
7085} 7188}
7189#endif /* 0 */
7086 7190
7191#if 0
7087int 7192int
7088ahd_resume(struct ahd_softc *ahd) 7193ahd_resume(struct ahd_softc *ahd)
7089{ 7194{
@@ -7093,6 +7198,7 @@ ahd_resume(struct ahd_softc *ahd)
7093 ahd_restart(ahd); 7198 ahd_restart(ahd);
7094 return (0); 7199 return (0);
7095} 7200}
7201#endif /* 0 */
7096 7202
7097/************************** Busy Target Table *********************************/ 7203/************************** Busy Target Table *********************************/
7098/* 7204/*
@@ -7125,7 +7231,7 @@ ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
7125/* 7231/*
7126 * Return the untagged transaction id for a given target/channel lun. 7232 * Return the untagged transaction id for a given target/channel lun.
7127 */ 7233 */
7128u_int 7234static u_int
7129ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl) 7235ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
7130{ 7236{
7131 u_int scbid; 7237 u_int scbid;
@@ -7138,7 +7244,7 @@ ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
7138 return (scbid); 7244 return (scbid);
7139} 7245}
7140 7246
7141void 7247static void
7142ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid) 7248ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
7143{ 7249{
7144 u_int scb_offset; 7250 u_int scb_offset;
@@ -7186,7 +7292,7 @@ ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
7186 return match; 7292 return match;
7187} 7293}
7188 7294
7189void 7295static void
7190ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb) 7296ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
7191{ 7297{
7192 int target; 7298 int target;
@@ -7690,7 +7796,7 @@ ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid)
7690 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer 7796 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer
7691 * is paused before it is called. 7797 * is paused before it is called.
7692 */ 7798 */
7693int 7799static int
7694ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel, 7800ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
7695 int lun, u_int tag, role_t role, uint32_t status) 7801 int lun, u_int tag, role_t role, uint32_t status)
7696{ 7802{
@@ -7920,6 +8026,11 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7920 ahd_clear_fifo(ahd, 1); 8026 ahd_clear_fifo(ahd, 1);
7921 8027
7922 /* 8028 /*
8029 * Clear SCSI interrupt status
8030 */
8031 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
8032
8033 /*
7923 * Reenable selections 8034 * Reenable selections
7924 */ 8035 */
7925 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST); 8036 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST);
@@ -7952,10 +8063,6 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7952 } 8063 }
7953 } 8064 }
7954#endif 8065#endif
7955 /* Notify the XPT that a bus reset occurred */
7956 ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
7957 CAM_LUN_WILDCARD, AC_BUS_RESET);
7958
7959 /* 8066 /*
7960 * Revert to async/narrow transfers until we renegotiate. 8067 * Revert to async/narrow transfers until we renegotiate.
7961 */ 8068 */
@@ -7977,6 +8084,10 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7977 } 8084 }
7978 } 8085 }
7979 8086
8087 /* Notify the XPT that a bus reset occurred */
8088 ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
8089 CAM_LUN_WILDCARD, AC_BUS_RESET);
8090
7980 ahd_restart(ahd); 8091 ahd_restart(ahd);
7981 8092
7982 return (found); 8093 return (found);
@@ -8019,18 +8130,8 @@ ahd_stat_timer(void *arg)
8019} 8130}
8020 8131
8021/****************************** Status Processing *****************************/ 8132/****************************** Status Processing *****************************/
8022void
8023ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
8024{
8025 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
8026 ahd_handle_scsi_status(ahd, scb);
8027 } else {
8028 ahd_calc_residual(ahd, scb);
8029 ahd_done(ahd, scb);
8030 }
8031}
8032 8133
8033void 8134static void
8034ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb) 8135ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8035{ 8136{
8036 struct hardware_scb *hscb; 8137 struct hardware_scb *hscb;
@@ -8238,10 +8339,21 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8238 } 8339 }
8239} 8340}
8240 8341
8342static void
8343ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
8344{
8345 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
8346 ahd_handle_scsi_status(ahd, scb);
8347 } else {
8348 ahd_calc_residual(ahd, scb);
8349 ahd_done(ahd, scb);
8350 }
8351}
8352
8241/* 8353/*
8242 * Calculate the residual for a just completed SCB. 8354 * Calculate the residual for a just completed SCB.
8243 */ 8355 */
8244void 8356static void
8245ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb) 8357ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
8246{ 8358{
8247 struct hardware_scb *hscb; 8359 struct hardware_scb *hscb;
@@ -8668,7 +8780,7 @@ ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address)
8668 if (skip_addr > i) { 8780 if (skip_addr > i) {
8669 int end_addr; 8781 int end_addr;
8670 8782
8671 end_addr = MIN(address, skip_addr); 8783 end_addr = min(address, skip_addr);
8672 address_offset += end_addr - i; 8784 address_offset += end_addr - i;
8673 i = skip_addr; 8785 i = skip_addr;
8674 } else { 8786 } else {
@@ -9092,6 +9204,7 @@ ahd_dump_card_state(struct ahd_softc *ahd)
9092 ahd_unpause(ahd); 9204 ahd_unpause(ahd);
9093} 9205}
9094 9206
9207#if 0
9095void 9208void
9096ahd_dump_scbs(struct ahd_softc *ahd) 9209ahd_dump_scbs(struct ahd_softc *ahd)
9097{ 9210{
@@ -9117,6 +9230,7 @@ ahd_dump_scbs(struct ahd_softc *ahd)
9117 ahd_set_scbptr(ahd, saved_scb_index); 9230 ahd_set_scbptr(ahd, saved_scb_index);
9118 ahd_restore_modes(ahd, saved_modes); 9231 ahd_restore_modes(ahd, saved_modes);
9119} 9232}
9233#endif /* 0 */
9120 9234
9121/**************************** Flexport Logic **********************************/ 9235/**************************** Flexport Logic **********************************/
9122/* 9236/*
@@ -9219,7 +9333,7 @@ ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
9219/* 9333/*
9220 * Wait ~100us for the serial eeprom to satisfy our request. 9334 * Wait ~100us for the serial eeprom to satisfy our request.
9221 */ 9335 */
9222int 9336static int
9223ahd_wait_seeprom(struct ahd_softc *ahd) 9337ahd_wait_seeprom(struct ahd_softc *ahd)
9224{ 9338{
9225 int cnt; 9339 int cnt;
@@ -9237,7 +9351,7 @@ ahd_wait_seeprom(struct ahd_softc *ahd)
9237 * Validate the two checksums in the per_channel 9351 * Validate the two checksums in the per_channel
9238 * vital product data struct. 9352 * vital product data struct.
9239 */ 9353 */
9240int 9354static int
9241ahd_verify_vpd_cksum(struct vpd_config *vpd) 9355ahd_verify_vpd_cksum(struct vpd_config *vpd)
9242{ 9356{
9243 int i; 9357 int i;
@@ -9316,6 +9430,24 @@ ahd_release_seeprom(struct ahd_softc *ahd)
9316 /* Currently a no-op */ 9430 /* Currently a no-op */
9317} 9431}
9318 9432
9433/*
9434 * Wait at most 2 seconds for flexport arbitration to succeed.
9435 */
9436static int
9437ahd_wait_flexport(struct ahd_softc *ahd)
9438{
9439 int cnt;
9440
9441 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
9442 cnt = 1000000 * 2 / 5;
9443 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
9444 ahd_delay(5);
9445
9446 if (cnt == 0)
9447 return (ETIMEDOUT);
9448 return (0);
9449}
9450
9319int 9451int
9320ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value) 9452ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
9321{ 9453{
@@ -9357,24 +9489,6 @@ ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value)
9357 return (0); 9489 return (0);
9358} 9490}
9359 9491
9360/*
9361 * Wait at most 2 seconds for flexport arbitration to succeed.
9362 */
9363int
9364ahd_wait_flexport(struct ahd_softc *ahd)
9365{
9366 int cnt;
9367
9368 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
9369 cnt = 1000000 * 2 / 5;
9370 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
9371 ahd_delay(5);
9372
9373 if (cnt == 0)
9374 return (ETIMEDOUT);
9375 return (0);
9376}
9377
9378/************************* Target Mode ****************************************/ 9492/************************* Target Mode ****************************************/
9379#ifdef AHD_TARGET_MODE 9493#ifdef AHD_TARGET_MODE
9380cam_status 9494cam_status
diff --git a/drivers/scsi/aic7xxx/aic79xx_inline.h b/drivers/scsi/aic7xxx/aic79xx_inline.h
index a3266e066c00..2ceb67f4af2a 100644
--- a/drivers/scsi/aic7xxx/aic79xx_inline.h
+++ b/drivers/scsi/aic7xxx/aic79xx_inline.h
@@ -418,10 +418,6 @@ ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index)
418} 418}
419 419
420/*********************** Miscelaneous Support Functions ***********************/ 420/*********************** Miscelaneous Support Functions ***********************/
421static __inline void ahd_complete_scb(struct ahd_softc *ahd,
422 struct scb *scb);
423static __inline void ahd_update_residual(struct ahd_softc *ahd,
424 struct scb *scb);
425static __inline struct ahd_initiator_tinfo * 421static __inline struct ahd_initiator_tinfo *
426 ahd_fetch_transinfo(struct ahd_softc *ahd, 422 ahd_fetch_transinfo(struct ahd_softc *ahd,
427 char channel, u_int our_id, 423 char channel, u_int our_id,
@@ -467,32 +463,6 @@ static __inline uint32_t
467 ahd_get_sense_bufaddr(struct ahd_softc *ahd, 463 ahd_get_sense_bufaddr(struct ahd_softc *ahd,
468 struct scb *scb); 464 struct scb *scb);
469 465
470static __inline void
471ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
472{
473 uint32_t sgptr;
474
475 sgptr = ahd_le32toh(scb->hscb->sgptr);
476 if ((sgptr & SG_STATUS_VALID) != 0)
477 ahd_handle_scb_status(ahd, scb);
478 else
479 ahd_done(ahd, scb);
480}
481
482/*
483 * Determine whether the sequencer reported a residual
484 * for this SCB/transaction.
485 */
486static __inline void
487ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
488{
489 uint32_t sgptr;
490
491 sgptr = ahd_le32toh(scb->hscb->sgptr);
492 if ((sgptr & SG_STATUS_VALID) != 0)
493 ahd_calc_residual(ahd, scb);
494}
495
496/* 466/*
497 * Return pointers to the transfer negotiation information 467 * Return pointers to the transfer negotiation information
498 * for the specified our_id/remote_id pair. 468 * for the specified our_id/remote_id pair.
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index f8e60486167d..9bfcca5ede08 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -293,7 +293,7 @@ static uint32_t aic79xx_seltime;
293 * force all outstanding transactions to be serviced prior to a new 293 * force all outstanding transactions to be serviced prior to a new
294 * transaction. 294 * transaction.
295 */ 295 */
296uint32_t aic79xx_periodic_otag; 296static uint32_t aic79xx_periodic_otag;
297 297
298/* Some storage boxes are using an LSI chip which has a bug making it 298/* Some storage boxes are using an LSI chip which has a bug making it
299 * impossible to use aic79xx Rev B chip in 320 speeds. The following 299 * impossible to use aic79xx Rev B chip in 320 speeds. The following
@@ -773,6 +773,7 @@ struct scsi_host_template aic79xx_driver_template = {
773#endif 773#endif
774 .can_queue = AHD_MAX_QUEUE, 774 .can_queue = AHD_MAX_QUEUE,
775 .this_id = -1, 775 .this_id = -1,
776 .max_sectors = 8192,
776 .cmd_per_lun = 2, 777 .cmd_per_lun = 2,
777 .use_clustering = ENABLE_CLUSTERING, 778 .use_clustering = ENABLE_CLUSTERING,
778 .slave_alloc = ahd_linux_slave_alloc, 779 .slave_alloc = ahd_linux_slave_alloc,
@@ -1813,9 +1814,9 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
1813 u_int sense_offset; 1814 u_int sense_offset;
1814 1815
1815 if (scb->flags & SCB_SENSE) { 1816 if (scb->flags & SCB_SENSE) {
1816 sense_size = MIN(sizeof(struct scsi_sense_data) 1817 sense_size = min(sizeof(struct scsi_sense_data)
1817 - ahd_get_sense_residual(scb), 1818 - ahd_get_sense_residual(scb),
1818 sizeof(cmd->sense_buffer)); 1819 (u_long)sizeof(cmd->sense_buffer));
1819 sense_offset = 0; 1820 sense_offset = 0;
1820 } else { 1821 } else {
1821 /* 1822 /*
@@ -1824,7 +1825,8 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
1824 */ 1825 */
1825 siu = (struct scsi_status_iu_header *) 1826 siu = (struct scsi_status_iu_header *)
1826 scb->sense_data; 1827 scb->sense_data;
1827 sense_size = MIN(scsi_4btoul(siu->sense_length), 1828 sense_size = min_t(size_t,
1829 scsi_4btoul(siu->sense_length),
1828 sizeof(cmd->sense_buffer)); 1830 sizeof(cmd->sense_buffer));
1829 sense_offset = SIU_SENSE_OFFSET(siu); 1831 sense_offset = SIU_SENSE_OFFSET(siu);
1830 } 1832 }
@@ -2634,8 +2636,22 @@ static void ahd_linux_set_pcomp_en(struct scsi_target *starget, int pcomp)
2634 pcomp ? "Enable" : "Disable"); 2636 pcomp ? "Enable" : "Disable");
2635#endif 2637#endif
2636 2638
2637 if (pcomp) 2639 if (pcomp) {
2640 uint8_t precomp;
2641
2642 if (ahd->unit < ARRAY_SIZE(aic79xx_iocell_info)) {
2643 struct ahd_linux_iocell_opts *iocell_opts;
2644
2645 iocell_opts = &aic79xx_iocell_info[ahd->unit];
2646 precomp = iocell_opts->precomp;
2647 } else {
2648 precomp = AIC79XX_DEFAULT_PRECOMP;
2649 }
2638 ppr_options |= MSG_EXT_PPR_PCOMP_EN; 2650 ppr_options |= MSG_EXT_PPR_PCOMP_EN;
2651 AHD_SET_PRECOMP(ahd, precomp);
2652 } else {
2653 AHD_SET_PRECOMP(ahd, 0);
2654 }
2639 2655
2640 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2656 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
2641 starget->channel + 'A', ROLE_INITIATOR); 2657 starget->channel + 'A', ROLE_INITIATOR);
@@ -2678,7 +2694,25 @@ static void ahd_linux_set_hold_mcs(struct scsi_target *starget, int hold)
2678 ahd_unlock(ahd, &flags); 2694 ahd_unlock(ahd, &flags);
2679} 2695}
2680 2696
2697static void ahd_linux_get_signalling(struct Scsi_Host *shost)
2698{
2699 struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
2700 unsigned long flags;
2701 u8 mode;
2702
2703 ahd_lock(ahd, &flags);
2704 ahd_pause(ahd);
2705 mode = ahd_inb(ahd, SBLKCTL);
2706 ahd_unpause(ahd);
2707 ahd_unlock(ahd, &flags);
2681 2708
2709 if (mode & ENAB40)
2710 spi_signalling(shost) = SPI_SIGNAL_LVD;
2711 else if (mode & ENAB20)
2712 spi_signalling(shost) = SPI_SIGNAL_SE;
2713 else
2714 spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
2715}
2682 2716
2683static struct spi_function_template ahd_linux_transport_functions = { 2717static struct spi_function_template ahd_linux_transport_functions = {
2684 .set_offset = ahd_linux_set_offset, 2718 .set_offset = ahd_linux_set_offset,
@@ -2703,6 +2737,7 @@ static struct spi_function_template ahd_linux_transport_functions = {
2703 .show_pcomp_en = 1, 2737 .show_pcomp_en = 1,
2704 .set_hold_mcs = ahd_linux_set_hold_mcs, 2738 .set_hold_mcs = ahd_linux_set_hold_mcs,
2705 .show_hold_mcs = 1, 2739 .show_hold_mcs = 1,
2740 .get_signalling = ahd_linux_get_signalling,
2706}; 2741};
2707 2742
2708static int __init 2743static int __init
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index fb3d4dd54413..3a67fc578d78 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -506,9 +506,6 @@ struct info_str {
506 int pos; 506 int pos;
507}; 507};
508 508
509void ahd_format_transinfo(struct info_str *info,
510 struct ahd_transinfo *tinfo);
511
512/******************************** Locking *************************************/ 509/******************************** Locking *************************************/
513static __inline void 510static __inline void
514ahd_lockinit(struct ahd_softc *ahd) 511ahd_lockinit(struct ahd_softc *ahd)
@@ -582,8 +579,6 @@ ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
582#define PCIXM_STATUS_MAXCRDS 0x1C00 /* Maximum Cumulative Read Size */ 579#define PCIXM_STATUS_MAXCRDS 0x1C00 /* Maximum Cumulative Read Size */
583#define PCIXM_STATUS_RCVDSCEM 0x2000 /* Received a Split Comp w/Error msg */ 580#define PCIXM_STATUS_RCVDSCEM 0x2000 /* Received a Split Comp w/Error msg */
584 581
585extern struct pci_driver aic79xx_pci_driver;
586
587typedef enum 582typedef enum
588{ 583{
589 AHD_POWER_STATE_D0, 584 AHD_POWER_STATE_D0,
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
index 4b5354201807..2001fe890e71 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -82,7 +82,7 @@ static struct pci_device_id ahd_linux_pci_id_table[] = {
82 82
83MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table); 83MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table);
84 84
85struct pci_driver aic79xx_pci_driver = { 85static struct pci_driver aic79xx_pci_driver = {
86 .name = "aic79xx", 86 .name = "aic79xx",
87 .probe = ahd_linux_pci_dev_probe, 87 .probe = ahd_linux_pci_dev_probe,
88 .remove = ahd_linux_pci_dev_remove, 88 .remove = ahd_linux_pci_dev_remove,
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index 14850f31aafa..c07735819cd1 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -97,7 +97,7 @@ static ahd_device_setup_t ahd_aic7901A_setup;
97static ahd_device_setup_t ahd_aic7902_setup; 97static ahd_device_setup_t ahd_aic7902_setup;
98static ahd_device_setup_t ahd_aic790X_setup; 98static ahd_device_setup_t ahd_aic790X_setup;
99 99
100struct ahd_pci_identity ahd_pci_ident_table [] = 100static struct ahd_pci_identity ahd_pci_ident_table [] =
101{ 101{
102 /* aic7901 based controllers */ 102 /* aic7901 based controllers */
103 { 103 {
@@ -201,7 +201,7 @@ struct ahd_pci_identity ahd_pci_ident_table [] =
201 } 201 }
202}; 202};
203 203
204const u_int ahd_num_pci_devs = ARRAY_SIZE(ahd_pci_ident_table); 204static const u_int ahd_num_pci_devs = ARRAY_SIZE(ahd_pci_ident_table);
205 205
206#define DEVCONFIG 0x40 206#define DEVCONFIG 0x40
207#define PCIXINITPAT 0x0000E000ul 207#define PCIXINITPAT 0x0000E000ul
@@ -245,6 +245,7 @@ static int ahd_check_extport(struct ahd_softc *ahd);
245static void ahd_configure_termination(struct ahd_softc *ahd, 245static void ahd_configure_termination(struct ahd_softc *ahd,
246 u_int adapter_control); 246 u_int adapter_control);
247static void ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat); 247static void ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat);
248static void ahd_pci_intr(struct ahd_softc *ahd);
248 249
249struct ahd_pci_identity * 250struct ahd_pci_identity *
250ahd_find_pci_device(ahd_dev_softc_t pci) 251ahd_find_pci_device(ahd_dev_softc_t pci)
@@ -757,7 +758,7 @@ static const char *pci_status_strings[] =
757 "%s: Address or Write Phase Parity Error Detected in %s.\n" 758 "%s: Address or Write Phase Parity Error Detected in %s.\n"
758}; 759};
759 760
760void 761static void
761ahd_pci_intr(struct ahd_softc *ahd) 762ahd_pci_intr(struct ahd_softc *ahd)
762{ 763{
763 uint8_t pci_status[8]; 764 uint8_t pci_status[8];
diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c
index c5f0ee591509..6b28bebcbca0 100644
--- a/drivers/scsi/aic7xxx/aic79xx_proc.c
+++ b/drivers/scsi/aic7xxx/aic79xx_proc.c
@@ -136,7 +136,7 @@ copy_info(struct info_str *info, char *fmt, ...)
136 return (len); 136 return (len);
137} 137}
138 138
139void 139static void
140ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo) 140ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
141{ 141{
142 u_int speed; 142 u_int speed;
diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h
index 62ff8c3dc2bb..954c7c24501d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx.h
+++ b/drivers/scsi/aic7xxx/aic7xxx.h
@@ -54,14 +54,6 @@ struct scb_platform_data;
54struct seeprom_descriptor; 54struct seeprom_descriptor;
55 55
56/****************************** Useful Macros *********************************/ 56/****************************** Useful Macros *********************************/
57#ifndef MAX
58#define MAX(a,b) (((a) > (b)) ? (a) : (b))
59#endif
60
61#ifndef MIN
62#define MIN(a,b) (((a) < (b)) ? (a) : (b))
63#endif
64
65#ifndef TRUE 57#ifndef TRUE
66#define TRUE 1 58#define TRUE 1
67#endif 59#endif
@@ -1135,8 +1127,6 @@ struct ahc_pci_identity {
1135 char *name; 1127 char *name;
1136 ahc_device_setup_t *setup; 1128 ahc_device_setup_t *setup;
1137}; 1129};
1138extern struct ahc_pci_identity ahc_pci_ident_table[];
1139extern const u_int ahc_num_pci_devs;
1140 1130
1141/***************************** VL/EISA Declarations ***************************/ 1131/***************************** VL/EISA Declarations ***************************/
1142struct aic7770_identity { 1132struct aic7770_identity {
@@ -1289,6 +1279,7 @@ typedef enum {
1289} ahc_queue_alg; 1279} ahc_queue_alg;
1290 1280
1291void ahc_set_tags(struct ahc_softc *ahc, 1281void ahc_set_tags(struct ahc_softc *ahc,
1282 struct scsi_cmnd *cmd,
1292 struct ahc_devinfo *devinfo, 1283 struct ahc_devinfo *devinfo,
1293 ahc_queue_alg alg); 1284 ahc_queue_alg alg);
1294 1285
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 93e4e40944b6..50ef785224de 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -1671,7 +1671,7 @@ ahc_devlimited_syncrate(struct ahc_softc *ahc,
1671 transinfo = &tinfo->goal; 1671 transinfo = &tinfo->goal;
1672 *ppr_options &= transinfo->ppr_options; 1672 *ppr_options &= transinfo->ppr_options;
1673 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) { 1673 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
1674 maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2); 1674 maxsync = max(maxsync, (u_int)AHC_SYNCRATE_ULTRA2);
1675 *ppr_options &= ~MSG_EXT_PPR_DT_REQ; 1675 *ppr_options &= ~MSG_EXT_PPR_DT_REQ;
1676 } 1676 }
1677 if (transinfo->period == 0) { 1677 if (transinfo->period == 0) {
@@ -1679,7 +1679,7 @@ ahc_devlimited_syncrate(struct ahc_softc *ahc,
1679 *ppr_options = 0; 1679 *ppr_options = 0;
1680 return (NULL); 1680 return (NULL);
1681 } 1681 }
1682 *period = MAX(*period, transinfo->period); 1682 *period = max(*period, (u_int)transinfo->period);
1683 return (ahc_find_syncrate(ahc, period, ppr_options, maxsync)); 1683 return (ahc_find_syncrate(ahc, period, ppr_options, maxsync));
1684} 1684}
1685 1685
@@ -1804,12 +1804,12 @@ ahc_validate_offset(struct ahc_softc *ahc,
1804 else 1804 else
1805 maxoffset = MAX_OFFSET_8BIT; 1805 maxoffset = MAX_OFFSET_8BIT;
1806 } 1806 }
1807 *offset = MIN(*offset, maxoffset); 1807 *offset = min(*offset, maxoffset);
1808 if (tinfo != NULL) { 1808 if (tinfo != NULL) {
1809 if (role == ROLE_TARGET) 1809 if (role == ROLE_TARGET)
1810 *offset = MIN(*offset, tinfo->user.offset); 1810 *offset = min(*offset, (u_int)tinfo->user.offset);
1811 else 1811 else
1812 *offset = MIN(*offset, tinfo->goal.offset); 1812 *offset = min(*offset, (u_int)tinfo->goal.offset);
1813 } 1813 }
1814} 1814}
1815 1815
@@ -1835,9 +1835,9 @@ ahc_validate_width(struct ahc_softc *ahc, struct ahc_initiator_tinfo *tinfo,
1835 } 1835 }
1836 if (tinfo != NULL) { 1836 if (tinfo != NULL) {
1837 if (role == ROLE_TARGET) 1837 if (role == ROLE_TARGET)
1838 *bus_width = MIN(tinfo->user.width, *bus_width); 1838 *bus_width = min((u_int)tinfo->user.width, *bus_width);
1839 else 1839 else
1840 *bus_width = MIN(tinfo->goal.width, *bus_width); 1840 *bus_width = min((u_int)tinfo->goal.width, *bus_width);
1841 } 1841 }
1842} 1842}
1843 1843
@@ -1986,7 +1986,7 @@ ahc_set_syncrate(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1986 tinfo->curr.ppr_options = ppr_options; 1986 tinfo->curr.ppr_options = ppr_options;
1987 1987
1988 ahc_send_async(ahc, devinfo->channel, devinfo->target, 1988 ahc_send_async(ahc, devinfo->channel, devinfo->target,
1989 CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL); 1989 CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
1990 if (bootverbose) { 1990 if (bootverbose) {
1991 if (offset != 0) { 1991 if (offset != 0) {
1992 printf("%s: target %d synchronous at %sMHz%s, " 1992 printf("%s: target %d synchronous at %sMHz%s, "
@@ -2056,7 +2056,7 @@ ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2056 tinfo->curr.width = width; 2056 tinfo->curr.width = width;
2057 2057
2058 ahc_send_async(ahc, devinfo->channel, devinfo->target, 2058 ahc_send_async(ahc, devinfo->channel, devinfo->target,
2059 CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL); 2059 CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
2060 if (bootverbose) { 2060 if (bootverbose) {
2061 printf("%s: target %d using %dbit transfers\n", 2061 printf("%s: target %d using %dbit transfers\n",
2062 ahc_name(ahc), devinfo->target, 2062 ahc_name(ahc), devinfo->target,
@@ -2074,12 +2074,14 @@ ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2074 * Update the current state of tagged queuing for a given target. 2074 * Update the current state of tagged queuing for a given target.
2075 */ 2075 */
2076void 2076void
2077ahc_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 2077ahc_set_tags(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
2078 ahc_queue_alg alg) 2078 struct ahc_devinfo *devinfo, ahc_queue_alg alg)
2079{ 2079{
2080 ahc_platform_set_tags(ahc, devinfo, alg); 2080 struct scsi_device *sdev = cmd->device;
2081
2082 ahc_platform_set_tags(ahc, sdev, devinfo, alg);
2081 ahc_send_async(ahc, devinfo->channel, devinfo->target, 2083 ahc_send_async(ahc, devinfo->channel, devinfo->target,
2082 devinfo->lun, AC_TRANSFER_NEG, &alg); 2084 devinfo->lun, AC_TRANSFER_NEG);
2083} 2085}
2084 2086
2085/* 2087/*
@@ -3489,7 +3491,7 @@ ahc_handle_msg_reject(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
3489 printf("(%s:%c:%d:%d): refuses tagged commands. " 3491 printf("(%s:%c:%d:%d): refuses tagged commands. "
3490 "Performing non-tagged I/O\n", ahc_name(ahc), 3492 "Performing non-tagged I/O\n", ahc_name(ahc),
3491 devinfo->channel, devinfo->target, devinfo->lun); 3493 devinfo->channel, devinfo->target, devinfo->lun);
3492 ahc_set_tags(ahc, devinfo, AHC_QUEUE_NONE); 3494 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_NONE);
3493 mask = ~0x23; 3495 mask = ~0x23;
3494 } else { 3496 } else {
3495 printf("(%s:%c:%d:%d): refuses %s tagged commands. " 3497 printf("(%s:%c:%d:%d): refuses %s tagged commands. "
@@ -3497,7 +3499,7 @@ ahc_handle_msg_reject(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
3497 ahc_name(ahc), devinfo->channel, devinfo->target, 3499 ahc_name(ahc), devinfo->channel, devinfo->target,
3498 devinfo->lun, tag_type == MSG_ORDERED_TASK 3500 devinfo->lun, tag_type == MSG_ORDERED_TASK
3499 ? "ordered" : "head of queue"); 3501 ? "ordered" : "head of queue");
3500 ahc_set_tags(ahc, devinfo, AHC_QUEUE_BASIC); 3502 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_BASIC);
3501 mask = ~0x03; 3503 mask = ~0x03;
3502 } 3504 }
3503 3505
@@ -3763,7 +3765,7 @@ ahc_handle_devreset(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
3763 3765
3764 if (status != CAM_SEL_TIMEOUT) 3766 if (status != CAM_SEL_TIMEOUT)
3765 ahc_send_async(ahc, devinfo->channel, devinfo->target, 3767 ahc_send_async(ahc, devinfo->channel, devinfo->target,
3766 CAM_LUN_WILDCARD, AC_SENT_BDR, NULL); 3768 CAM_LUN_WILDCARD, AC_SENT_BDR);
3767 3769
3768 if (message != NULL 3770 if (message != NULL
3769 && (verbose_level <= bootverbose)) 3771 && (verbose_level <= bootverbose))
@@ -4406,7 +4408,7 @@ ahc_alloc_scbs(struct ahc_softc *ahc)
4406 physaddr = sg_map->sg_physaddr; 4408 physaddr = sg_map->sg_physaddr;
4407 4409
4408 newcount = (PAGE_SIZE / (AHC_NSEG * sizeof(struct ahc_dma_seg))); 4410 newcount = (PAGE_SIZE / (AHC_NSEG * sizeof(struct ahc_dma_seg)));
4409 newcount = MIN(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs)); 4411 newcount = min(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs));
4410 for (i = 0; i < newcount; i++) { 4412 for (i = 0; i < newcount; i++) {
4411 struct scb_platform_data *pdata; 4413 struct scb_platform_data *pdata;
4412#ifndef __linux__ 4414#ifndef __linux__
@@ -6018,7 +6020,7 @@ ahc_reset_channel(struct ahc_softc *ahc, char channel, int initiate_reset)
6018#endif 6020#endif
6019 /* Notify the XPT that a bus reset occurred */ 6021 /* Notify the XPT that a bus reset occurred */
6020 ahc_send_async(ahc, devinfo.channel, CAM_TARGET_WILDCARD, 6022 ahc_send_async(ahc, devinfo.channel, CAM_TARGET_WILDCARD,
6021 CAM_LUN_WILDCARD, AC_BUS_RESET, NULL); 6023 CAM_LUN_WILDCARD, AC_BUS_RESET);
6022 6024
6023 /* 6025 /*
6024 * Revert to async/narrow transfers until we renegotiate. 6026 * Revert to async/narrow transfers until we renegotiate.
@@ -6442,7 +6444,7 @@ ahc_download_instr(struct ahc_softc *ahc, u_int instrptr, uint8_t *dconsts)
6442 if (skip_addr > i) { 6444 if (skip_addr > i) {
6443 int end_addr; 6445 int end_addr;
6444 6446
6445 end_addr = MIN(address, skip_addr); 6447 end_addr = min(address, skip_addr);
6446 address_offset += end_addr - i; 6448 address_offset += end_addr - i;
6447 i = skip_addr; 6449 i = skip_addr;
6448 } else { 6450 } else {
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 43ab753d2739..660f26e23a38 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -328,7 +328,7 @@ static uint32_t aic7xxx_seltime;
328 * force all outstanding transactions to be serviced prior to a new 328 * force all outstanding transactions to be serviced prior to a new
329 * transaction. 329 * transaction.
330 */ 330 */
331uint32_t aic7xxx_periodic_otag; 331static uint32_t aic7xxx_periodic_otag;
332 332
333/* 333/*
334 * Module information and settable options. 334 * Module information and settable options.
@@ -512,7 +512,6 @@ ahc_linux_target_alloc(struct scsi_target *starget)
512 struct seeprom_config *sc = ahc->seep_config; 512 struct seeprom_config *sc = ahc->seep_config;
513 unsigned long flags; 513 unsigned long flags;
514 struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget); 514 struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget);
515 struct ahc_linux_target *targ = scsi_transport_target_data(starget);
516 unsigned short scsirate; 515 unsigned short scsirate;
517 struct ahc_devinfo devinfo; 516 struct ahc_devinfo devinfo;
518 struct ahc_initiator_tinfo *tinfo; 517 struct ahc_initiator_tinfo *tinfo;
@@ -533,7 +532,6 @@ ahc_linux_target_alloc(struct scsi_target *starget)
533 BUG_ON(*ahc_targp != NULL); 532 BUG_ON(*ahc_targp != NULL);
534 533
535 *ahc_targp = starget; 534 *ahc_targp = starget;
536 memset(targ, 0, sizeof(*targ));
537 535
538 if (sc) { 536 if (sc) {
539 int maxsync = AHC_SYNCRATE_DT; 537 int maxsync = AHC_SYNCRATE_DT;
@@ -594,14 +592,11 @@ ahc_linux_slave_alloc(struct scsi_device *sdev)
594 struct ahc_softc *ahc = 592 struct ahc_softc *ahc =
595 *((struct ahc_softc **)sdev->host->hostdata); 593 *((struct ahc_softc **)sdev->host->hostdata);
596 struct scsi_target *starget = sdev->sdev_target; 594 struct scsi_target *starget = sdev->sdev_target;
597 struct ahc_linux_target *targ = scsi_transport_target_data(starget);
598 struct ahc_linux_device *dev; 595 struct ahc_linux_device *dev;
599 596
600 if (bootverbose) 597 if (bootverbose)
601 printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id); 598 printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id);
602 599
603 BUG_ON(targ->sdev[sdev->lun] != NULL);
604
605 dev = scsi_transport_device_data(sdev); 600 dev = scsi_transport_device_data(sdev);
606 memset(dev, 0, sizeof(*dev)); 601 memset(dev, 0, sizeof(*dev));
607 602
@@ -618,8 +613,6 @@ ahc_linux_slave_alloc(struct scsi_device *sdev)
618 */ 613 */
619 dev->maxtags = 0; 614 dev->maxtags = 0;
620 615
621 targ->sdev[sdev->lun] = sdev;
622
623 spi_period(starget) = 0; 616 spi_period(starget) = 0;
624 617
625 return 0; 618 return 0;
@@ -644,22 +637,6 @@ ahc_linux_slave_configure(struct scsi_device *sdev)
644 return 0; 637 return 0;
645} 638}
646 639
647static void
648ahc_linux_slave_destroy(struct scsi_device *sdev)
649{
650 struct ahc_softc *ahc;
651 struct ahc_linux_device *dev = scsi_transport_device_data(sdev);
652 struct ahc_linux_target *targ = scsi_transport_target_data(sdev->sdev_target);
653
654 ahc = *((struct ahc_softc **)sdev->host->hostdata);
655 if (bootverbose)
656 printf("%s: Slave Destroy %d\n", ahc_name(ahc), sdev->id);
657
658 BUG_ON(dev->active);
659
660 targ->sdev[sdev->lun] = NULL;
661}
662
663#if defined(__i386__) 640#if defined(__i386__)
664/* 641/*
665 * Return the disk geometry for the given SCSI device. 642 * Return the disk geometry for the given SCSI device.
@@ -777,11 +754,11 @@ struct scsi_host_template aic7xxx_driver_template = {
777#endif 754#endif
778 .can_queue = AHC_MAX_QUEUE, 755 .can_queue = AHC_MAX_QUEUE,
779 .this_id = -1, 756 .this_id = -1,
757 .max_sectors = 8192,
780 .cmd_per_lun = 2, 758 .cmd_per_lun = 2,
781 .use_clustering = ENABLE_CLUSTERING, 759 .use_clustering = ENABLE_CLUSTERING,
782 .slave_alloc = ahc_linux_slave_alloc, 760 .slave_alloc = ahc_linux_slave_alloc,
783 .slave_configure = ahc_linux_slave_configure, 761 .slave_configure = ahc_linux_slave_configure,
784 .slave_destroy = ahc_linux_slave_destroy,
785 .target_alloc = ahc_linux_target_alloc, 762 .target_alloc = ahc_linux_target_alloc,
786 .target_destroy = ahc_linux_target_destroy, 763 .target_destroy = ahc_linux_target_destroy,
787}; 764};
@@ -1203,21 +1180,13 @@ void
1203ahc_platform_free(struct ahc_softc *ahc) 1180ahc_platform_free(struct ahc_softc *ahc)
1204{ 1181{
1205 struct scsi_target *starget; 1182 struct scsi_target *starget;
1206 int i, j; 1183 int i;
1207 1184
1208 if (ahc->platform_data != NULL) { 1185 if (ahc->platform_data != NULL) {
1209 /* destroy all of the device and target objects */ 1186 /* destroy all of the device and target objects */
1210 for (i = 0; i < AHC_NUM_TARGETS; i++) { 1187 for (i = 0; i < AHC_NUM_TARGETS; i++) {
1211 starget = ahc->platform_data->starget[i]; 1188 starget = ahc->platform_data->starget[i];
1212 if (starget != NULL) { 1189 if (starget != NULL) {
1213 for (j = 0; j < AHC_NUM_LUNS; j++) {
1214 struct ahc_linux_target *targ =
1215 scsi_transport_target_data(starget);
1216
1217 if (targ->sdev[j] == NULL)
1218 continue;
1219 targ->sdev[j] = NULL;
1220 }
1221 ahc->platform_data->starget[i] = NULL; 1190 ahc->platform_data->starget[i] = NULL;
1222 } 1191 }
1223 } 1192 }
@@ -1251,24 +1220,13 @@ ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
1251} 1220}
1252 1221
1253void 1222void
1254ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 1223ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
1255 ahc_queue_alg alg) 1224 struct ahc_devinfo *devinfo, ahc_queue_alg alg)
1256{ 1225{
1257 struct scsi_target *starget;
1258 struct ahc_linux_target *targ;
1259 struct ahc_linux_device *dev; 1226 struct ahc_linux_device *dev;
1260 struct scsi_device *sdev;
1261 u_int target_offset;
1262 int was_queuing; 1227 int was_queuing;
1263 int now_queuing; 1228 int now_queuing;
1264 1229
1265 target_offset = devinfo->target;
1266 if (devinfo->channel != 'A')
1267 target_offset += 8;
1268 starget = ahc->platform_data->starget[target_offset];
1269 targ = scsi_transport_target_data(starget);
1270 BUG_ON(targ == NULL);
1271 sdev = targ->sdev[devinfo->lun];
1272 if (sdev == NULL) 1230 if (sdev == NULL)
1273 return; 1231 return;
1274 dev = scsi_transport_device_data(sdev); 1232 dev = scsi_transport_device_data(sdev);
@@ -1401,11 +1359,15 @@ ahc_linux_device_queue_depth(struct scsi_device *sdev)
1401 tags = ahc_linux_user_tagdepth(ahc, &devinfo); 1359 tags = ahc_linux_user_tagdepth(ahc, &devinfo);
1402 if (tags != 0 && sdev->tagged_supported != 0) { 1360 if (tags != 0 && sdev->tagged_supported != 0) {
1403 1361
1404 ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED); 1362 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_TAGGED);
1363 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1364 devinfo.lun, AC_TRANSFER_NEG);
1405 ahc_print_devinfo(ahc, &devinfo); 1365 ahc_print_devinfo(ahc, &devinfo);
1406 printf("Tagged Queuing enabled. Depth %d\n", tags); 1366 printf("Tagged Queuing enabled. Depth %d\n", tags);
1407 } else { 1367 } else {
1408 ahc_set_tags(ahc, &devinfo, AHC_QUEUE_NONE); 1368 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_NONE);
1369 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1370 devinfo.lun, AC_TRANSFER_NEG);
1409 } 1371 }
1410} 1372}
1411 1373
@@ -1629,7 +1591,7 @@ ahc_platform_flushwork(struct ahc_softc *ahc)
1629 1591
1630void 1592void
1631ahc_send_async(struct ahc_softc *ahc, char channel, 1593ahc_send_async(struct ahc_softc *ahc, char channel,
1632 u_int target, u_int lun, ac_code code, void *arg) 1594 u_int target, u_int lun, ac_code code)
1633{ 1595{
1634 switch (code) { 1596 switch (code) {
1635 case AC_TRANSFER_NEG: 1597 case AC_TRANSFER_NEG:
@@ -1875,9 +1837,9 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1875 if (scb->flags & SCB_SENSE) { 1837 if (scb->flags & SCB_SENSE) {
1876 u_int sense_size; 1838 u_int sense_size;
1877 1839
1878 sense_size = MIN(sizeof(struct scsi_sense_data) 1840 sense_size = min(sizeof(struct scsi_sense_data)
1879 - ahc_get_sense_residual(scb), 1841 - ahc_get_sense_residual(scb),
1880 sizeof(cmd->sense_buffer)); 1842 (u_long)sizeof(cmd->sense_buffer));
1881 memcpy(cmd->sense_buffer, 1843 memcpy(cmd->sense_buffer,
1882 ahc_get_sense_buf(ahc, scb), sense_size); 1844 ahc_get_sense_buf(ahc, scb), sense_size);
1883 if (sense_size < sizeof(cmd->sense_buffer)) 1845 if (sense_size < sizeof(cmd->sense_buffer))
@@ -1946,7 +1908,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1946 } 1908 }
1947 ahc_set_transaction_status(scb, CAM_REQUEUE_REQ); 1909 ahc_set_transaction_status(scb, CAM_REQUEUE_REQ);
1948 ahc_set_scsi_status(scb, SCSI_STATUS_OK); 1910 ahc_set_scsi_status(scb, SCSI_STATUS_OK);
1949 ahc_platform_set_tags(ahc, &devinfo, 1911 ahc_platform_set_tags(ahc, sdev, &devinfo,
1950 (dev->flags & AHC_DEV_Q_BASIC) 1912 (dev->flags & AHC_DEV_Q_BASIC)
1951 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 1913 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
1952 break; 1914 break;
@@ -1957,7 +1919,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1957 */ 1919 */
1958 dev->openings = 1; 1920 dev->openings = 1;
1959 ahc_set_scsi_status(scb, SCSI_STATUS_BUSY); 1921 ahc_set_scsi_status(scb, SCSI_STATUS_BUSY);
1960 ahc_platform_set_tags(ahc, &devinfo, 1922 ahc_platform_set_tags(ahc, sdev, &devinfo,
1961 (dev->flags & AHC_DEV_Q_BASIC) 1923 (dev->flags & AHC_DEV_Q_BASIC)
1962 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 1924 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
1963 break; 1925 break;
@@ -2599,8 +2561,6 @@ ahc_linux_init(void)
2599 if (!ahc_linux_transport_template) 2561 if (!ahc_linux_transport_template)
2600 return -ENODEV; 2562 return -ENODEV;
2601 2563
2602 scsi_transport_reserve_target(ahc_linux_transport_template,
2603 sizeof(struct ahc_linux_target));
2604 scsi_transport_reserve_device(ahc_linux_transport_template, 2564 scsi_transport_reserve_device(ahc_linux_transport_template,
2605 sizeof(struct ahc_linux_device)); 2565 sizeof(struct ahc_linux_device));
2606 2566
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index a87a4ce090df..85ae5d836fa4 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -256,7 +256,6 @@ typedef enum {
256 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 256 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */
257} ahc_linux_dev_flags; 257} ahc_linux_dev_flags;
258 258
259struct ahc_linux_target;
260struct ahc_linux_device { 259struct ahc_linux_device {
261 /* 260 /*
262 * The number of transactions currently 261 * The number of transactions currently
@@ -329,12 +328,6 @@ struct ahc_linux_device {
329#define AHC_OTAG_THRESH 500 328#define AHC_OTAG_THRESH 500
330}; 329};
331 330
332struct ahc_linux_target {
333 struct scsi_device *sdev[AHC_NUM_LUNS];
334 struct ahc_transinfo last_tinfo;
335 struct ahc_softc *ahc;
336};
337
338/********************* Definitions Required by the Core ***********************/ 331/********************* Definitions Required by the Core ***********************/
339/* 332/*
340 * Number of SG segments we require. So long as the S/G segments for 333 * Number of SG segments we require. So long as the S/G segments for
@@ -533,8 +526,6 @@ ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
533#define PCIR_SUBVEND_0 0x2c 526#define PCIR_SUBVEND_0 0x2c
534#define PCIR_SUBDEV_0 0x2e 527#define PCIR_SUBDEV_0 0x2e
535 528
536extern struct pci_driver aic7xxx_pci_driver;
537
538typedef enum 529typedef enum
539{ 530{
540 AHC_POWER_STATE_D0, 531 AHC_POWER_STATE_D0,
@@ -824,7 +815,7 @@ ahc_freeze_scb(struct scb *scb)
824 } 815 }
825} 816}
826 817
827void ahc_platform_set_tags(struct ahc_softc *ahc, 818void ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
828 struct ahc_devinfo *devinfo, ahc_queue_alg); 819 struct ahc_devinfo *devinfo, ahc_queue_alg);
829int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, 820int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
830 char channel, int lun, u_int tag, 821 char channel, int lun, u_int tag,
@@ -834,7 +825,7 @@ irqreturn_t
834void ahc_platform_flushwork(struct ahc_softc *ahc); 825void ahc_platform_flushwork(struct ahc_softc *ahc);
835void ahc_done(struct ahc_softc*, struct scb*); 826void ahc_done(struct ahc_softc*, struct scb*);
836void ahc_send_async(struct ahc_softc *, char channel, 827void ahc_send_async(struct ahc_softc *, char channel,
837 u_int target, u_int lun, ac_code, void *); 828 u_int target, u_int lun, ac_code);
838void ahc_print_path(struct ahc_softc *, struct scb *); 829void ahc_print_path(struct ahc_softc *, struct scb *);
839void ahc_platform_dump_card_state(struct ahc_softc *ahc); 830void ahc_platform_dump_card_state(struct ahc_softc *ahc);
840 831
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
index d20ca514e9f3..ea5687df732d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -130,7 +130,7 @@ static struct pci_device_id ahc_linux_pci_id_table[] = {
130 130
131MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table); 131MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table);
132 132
133struct pci_driver aic7xxx_pci_driver = { 133static struct pci_driver aic7xxx_pci_driver = {
134 .name = "aic7xxx", 134 .name = "aic7xxx",
135 .probe = ahc_linux_pci_dev_probe, 135 .probe = ahc_linux_pci_dev_probe,
136 .remove = ahc_linux_pci_dev_remove, 136 .remove = ahc_linux_pci_dev_remove,
diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c
index 63cab2d74552..09c8172c9e5e 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c
@@ -168,7 +168,7 @@ static ahc_device_setup_t ahc_aha394XX_setup;
168static ahc_device_setup_t ahc_aha494XX_setup; 168static ahc_device_setup_t ahc_aha494XX_setup;
169static ahc_device_setup_t ahc_aha398XX_setup; 169static ahc_device_setup_t ahc_aha398XX_setup;
170 170
171struct ahc_pci_identity ahc_pci_ident_table [] = 171static struct ahc_pci_identity ahc_pci_ident_table [] =
172{ 172{
173 /* aic7850 based controllers */ 173 /* aic7850 based controllers */
174 { 174 {
@@ -559,7 +559,7 @@ struct ahc_pci_identity ahc_pci_ident_table [] =
559 } 559 }
560}; 560};
561 561
562const u_int ahc_num_pci_devs = ARRAY_SIZE(ahc_pci_ident_table); 562static const u_int ahc_num_pci_devs = ARRAY_SIZE(ahc_pci_ident_table);
563 563
564#define AHC_394X_SLOT_CHANNEL_A 4 564#define AHC_394X_SLOT_CHANNEL_A 4
565#define AHC_394X_SLOT_CHANNEL_B 5 565#define AHC_394X_SLOT_CHANNEL_B 5
diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c
index 5914b4aa4a8f..99e5443e7535 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c
@@ -182,7 +182,6 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
182 u_int our_id, char channel, u_int target_id, 182 u_int our_id, char channel, u_int target_id,
183 u_int target_offset) 183 u_int target_offset)
184{ 184{
185 struct ahc_linux_target *targ;
186 struct scsi_target *starget; 185 struct scsi_target *starget;
187 struct ahc_initiator_tinfo *tinfo; 186 struct ahc_initiator_tinfo *tinfo;
188 struct ahc_tmode_tstate *tstate; 187 struct ahc_tmode_tstate *tstate;
@@ -198,7 +197,6 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
198 starget = ahc->platform_data->starget[target_offset]; 197 starget = ahc->platform_data->starget[target_offset];
199 if (!starget) 198 if (!starget)
200 return; 199 return;
201 targ = scsi_transport_target_data(starget);
202 200
203 copy_info(info, "\tGoal: "); 201 copy_info(info, "\tGoal: ");
204 ahc_format_transinfo(info, &tinfo->goal); 202 ahc_format_transinfo(info, &tinfo->goal);
@@ -208,7 +206,7 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
208 for (lun = 0; lun < AHC_NUM_LUNS; lun++) { 206 for (lun = 0; lun < AHC_NUM_LUNS; lun++) {
209 struct scsi_device *sdev; 207 struct scsi_device *sdev;
210 208
211 sdev = targ->sdev[lun]; 209 sdev = scsi_device_lookup_by_target(starget, lun);
212 210
213 if (sdev == NULL) 211 if (sdev == NULL)
214 continue; 212 continue;
@@ -383,11 +381,11 @@ ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
383 } 381 }
384 copy_info(&info, "\n"); 382 copy_info(&info, "\n");
385 383
386 max_targ = 15; 384 max_targ = 16;
387 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0) 385 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
388 max_targ = 7; 386 max_targ = 8;
389 387
390 for (i = 0; i <= max_targ; i++) { 388 for (i = 0; i < max_targ; i++) {
391 u_int our_id; 389 u_int our_id;
392 u_int target_id; 390 u_int target_id;
393 char channel; 391 char channel;
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index bcd7fffab907..46eed10b25d9 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -2646,7 +2646,7 @@ static void aic7xxx_done_cmds_complete(struct aic7xxx_host *p)
2646 2646
2647 while (p->completeq.head != NULL) { 2647 while (p->completeq.head != NULL) {
2648 cmd = p->completeq.head; 2648 cmd = p->completeq.head;
2649 p->completeq.head = (struct scsi_Cmnd *) cmd->host_scribble; 2649 p->completeq.head = (struct scsi_cmnd *) cmd->host_scribble;
2650 cmd->host_scribble = NULL; 2650 cmd->host_scribble = NULL;
2651 cmd->scsi_done(cmd); 2651 cmd->scsi_done(cmd);
2652 } 2652 }
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index 3c2d7a379931..af7e01134364 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -112,6 +112,21 @@ static int asd_init_phy(struct asd_phy *phy)
112 return 0; 112 return 0;
113} 113}
114 114
115static void asd_init_ports(struct asd_ha_struct *asd_ha)
116{
117 int i;
118
119 spin_lock_init(&asd_ha->asd_ports_lock);
120 for (i = 0; i < ASD_MAX_PHYS; i++) {
121 struct asd_port *asd_port = &asd_ha->asd_ports[i];
122
123 memset(asd_port->sas_addr, 0, SAS_ADDR_SIZE);
124 memset(asd_port->attached_sas_addr, 0, SAS_ADDR_SIZE);
125 asd_port->phy_mask = 0;
126 asd_port->num_phys = 0;
127 }
128}
129
115static int asd_init_phys(struct asd_ha_struct *asd_ha) 130static int asd_init_phys(struct asd_ha_struct *asd_ha)
116{ 131{
117 u8 i; 132 u8 i;
@@ -121,6 +136,7 @@ static int asd_init_phys(struct asd_ha_struct *asd_ha)
121 struct asd_phy *phy = &asd_ha->phys[i]; 136 struct asd_phy *phy = &asd_ha->phys[i];
122 137
123 phy->phy_desc = &asd_ha->hw_prof.phy_desc[i]; 138 phy->phy_desc = &asd_ha->hw_prof.phy_desc[i];
139 phy->asd_port = NULL;
124 140
125 phy->sas_phy.enabled = 0; 141 phy->sas_phy.enabled = 0;
126 phy->sas_phy.id = i; 142 phy->sas_phy.id = i;
@@ -658,6 +674,8 @@ int asd_init_hw(struct asd_ha_struct *asd_ha)
658 goto Out; 674 goto Out;
659 } 675 }
660 676
677 asd_init_ports(asd_ha);
678
661 err = asd_init_scbs(asd_ha); 679 err = asd_init_scbs(asd_ha);
662 if (err) { 680 if (err) {
663 asd_printk("couldn't initialize scbs for %s\n", 681 asd_printk("couldn't initialize scbs for %s\n",
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.h b/drivers/scsi/aic94xx/aic94xx_hwi.h
index 14319d1d6804..c6c3d18222fa 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.h
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.h
@@ -46,6 +46,7 @@
46#define PCI_DEVICE_ID_ADAPTEC2_RAZOR10 0x410 46#define PCI_DEVICE_ID_ADAPTEC2_RAZOR10 0x410
47#define PCI_DEVICE_ID_ADAPTEC2_RAZOR12 0x412 47#define PCI_DEVICE_ID_ADAPTEC2_RAZOR12 0x412
48#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1E 0x41E 48#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1E 0x41E
49#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1F 0x41F
49#define PCI_DEVICE_ID_ADAPTEC2_RAZOR30 0x430 50#define PCI_DEVICE_ID_ADAPTEC2_RAZOR30 0x430
50#define PCI_DEVICE_ID_ADAPTEC2_RAZOR32 0x432 51#define PCI_DEVICE_ID_ADAPTEC2_RAZOR32 0x432
51#define PCI_DEVICE_ID_ADAPTEC2_RAZOR3E 0x43E 52#define PCI_DEVICE_ID_ADAPTEC2_RAZOR3E 0x43E
@@ -192,6 +193,16 @@ struct asd_seq_data {
192 struct asd_ascb **escb_arr; /* array of pointers to escbs */ 193 struct asd_ascb **escb_arr; /* array of pointers to escbs */
193}; 194};
194 195
196/* This is an internal port structure. These are used to get accurate
197 * phy_mask for updating DDB 0.
198 */
199struct asd_port {
200 u8 sas_addr[SAS_ADDR_SIZE];
201 u8 attached_sas_addr[SAS_ADDR_SIZE];
202 u32 phy_mask;
203 int num_phys;
204};
205
195/* This is the Host Adapter structure. It describes the hardware 206/* This is the Host Adapter structure. It describes the hardware
196 * SAS adapter. 207 * SAS adapter.
197 */ 208 */
@@ -210,6 +221,8 @@ struct asd_ha_struct {
210 struct hw_profile hw_prof; 221 struct hw_profile hw_prof;
211 222
212 struct asd_phy phys[ASD_MAX_PHYS]; 223 struct asd_phy phys[ASD_MAX_PHYS];
224 spinlock_t asd_ports_lock;
225 struct asd_port asd_ports[ASD_MAX_PHYS];
213 struct asd_sas_port ports[ASD_MAX_PHYS]; 226 struct asd_sas_port ports[ASD_MAX_PHYS];
214 227
215 struct dma_pool *scb_pool; 228 struct dma_pool *scb_pool;
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 99743ca29ca1..57c5ba4043f2 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -786,8 +786,6 @@ static void asd_remove_driver_attrs(struct device_driver *driver)
786} 786}
787 787
788static struct sas_domain_function_template aic94xx_transport_functions = { 788static struct sas_domain_function_template aic94xx_transport_functions = {
789 .lldd_port_formed = asd_update_port_links,
790
791 .lldd_dev_found = asd_dev_found, 789 .lldd_dev_found = asd_dev_found,
792 .lldd_dev_gone = asd_dev_gone, 790 .lldd_dev_gone = asd_dev_gone,
793 791
@@ -814,6 +812,8 @@ static const struct pci_device_id aic94xx_pci_table[] __devinitdata = {
814 0, 0, 1}, 812 0, 0, 1},
815 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1E), 813 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1E),
816 0, 0, 1}, 814 0, 0, 1},
815 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1F),
816 0, 0, 1},
817 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR30), 817 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR30),
818 0, 0, 2}, 818 0, 0, 2},
819 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR32), 819 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR32),
diff --git a/drivers/scsi/aic94xx/aic94xx_sas.h b/drivers/scsi/aic94xx/aic94xx_sas.h
index 64d231712345..9050e93bfd5e 100644
--- a/drivers/scsi/aic94xx/aic94xx_sas.h
+++ b/drivers/scsi/aic94xx/aic94xx_sas.h
@@ -733,6 +733,7 @@ struct asd_phy {
733 733
734 struct sas_identify_frame *identify_frame; 734 struct sas_identify_frame *identify_frame;
735 struct asd_dma_tok *id_frm_tok; 735 struct asd_dma_tok *id_frm_tok;
736 struct asd_port *asd_port;
736 737
737 u8 frame_rcvd[ASD_EDB_SIZE]; 738 u8 frame_rcvd[ASD_EDB_SIZE];
738}; 739};
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index 7ee49b51b724..b15caf1c8fa2 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -168,6 +168,70 @@ static inline void asd_get_attached_sas_addr(struct asd_phy *phy, u8 *sas_addr)
168 } 168 }
169} 169}
170 170
171static void asd_form_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
172{
173 int i;
174 struct asd_port *free_port = NULL;
175 struct asd_port *port;
176 struct asd_sas_phy *sas_phy = &phy->sas_phy;
177 unsigned long flags;
178
179 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags);
180 if (!phy->asd_port) {
181 for (i = 0; i < ASD_MAX_PHYS; i++) {
182 port = &asd_ha->asd_ports[i];
183
184 /* Check for wide port */
185 if (port->num_phys > 0 &&
186 memcmp(port->sas_addr, sas_phy->sas_addr,
187 SAS_ADDR_SIZE) == 0 &&
188 memcmp(port->attached_sas_addr,
189 sas_phy->attached_sas_addr,
190 SAS_ADDR_SIZE) == 0) {
191 break;
192 }
193
194 /* Find a free port */
195 if (port->num_phys == 0 && free_port == NULL) {
196 free_port = port;
197 }
198 }
199
200 /* Use a free port if this doesn't form a wide port */
201 if (i >= ASD_MAX_PHYS) {
202 port = free_port;
203 BUG_ON(!port);
204 memcpy(port->sas_addr, sas_phy->sas_addr,
205 SAS_ADDR_SIZE);
206 memcpy(port->attached_sas_addr,
207 sas_phy->attached_sas_addr,
208 SAS_ADDR_SIZE);
209 }
210 port->num_phys++;
211 port->phy_mask |= (1U << sas_phy->id);
212 phy->asd_port = port;
213 }
214 ASD_DPRINTK("%s: updating phy_mask 0x%x for phy%d\n",
215 __FUNCTION__, phy->asd_port->phy_mask, sas_phy->id);
216 asd_update_port_links(asd_ha, phy);
217 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
218}
219
220static void asd_deform_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
221{
222 struct asd_port *port = phy->asd_port;
223 struct asd_sas_phy *sas_phy = &phy->sas_phy;
224 unsigned long flags;
225
226 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags);
227 if (port) {
228 port->num_phys--;
229 port->phy_mask &= ~(1U << sas_phy->id);
230 phy->asd_port = NULL;
231 }
232 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
233}
234
171static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb, 235static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
172 struct done_list_struct *dl, 236 struct done_list_struct *dl,
173 int edb_id, int phy_id) 237 int edb_id, int phy_id)
@@ -187,6 +251,7 @@ static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
187 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); 251 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr);
188 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); 252 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags);
189 asd_dump_frame_rcvd(phy, dl); 253 asd_dump_frame_rcvd(phy, dl);
254 asd_form_port(ascb->ha, phy);
190 sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED); 255 sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED);
191} 256}
192 257
@@ -197,6 +262,7 @@ static inline void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
197 struct asd_ha_struct *asd_ha = ascb->ha; 262 struct asd_ha_struct *asd_ha = ascb->ha;
198 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; 263 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha;
199 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 264 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
265 struct asd_phy *phy = &asd_ha->phys[phy_id];
200 u8 lr_error = dl->status_block[1]; 266 u8 lr_error = dl->status_block[1];
201 u8 retries_left = dl->status_block[2]; 267 u8 retries_left = dl->status_block[2];
202 268
@@ -221,6 +287,7 @@ static inline void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
221 287
222 asd_turn_led(asd_ha, phy_id, 0); 288 asd_turn_led(asd_ha, phy_id, 0);
223 sas_phy_disconnected(sas_phy); 289 sas_phy_disconnected(sas_phy);
290 asd_deform_port(asd_ha, phy);
224 sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 291 sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR);
225 292
226 if (retries_left == 0) { 293 if (retries_left == 0) {
@@ -248,6 +315,8 @@ static inline void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
248 unsigned long flags; 315 unsigned long flags;
249 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha; 316 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha;
250 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 317 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
318 struct asd_ha_struct *asd_ha = ascb->ha;
319 struct asd_phy *phy = &asd_ha->phys[phy_id];
251 u8 reg = dl->status_block[1]; 320 u8 reg = dl->status_block[1];
252 u32 cont = dl->status_block[2] << ((reg & 3)*8); 321 u32 cont = dl->status_block[2] << ((reg & 3)*8);
253 322
@@ -284,6 +353,7 @@ static inline void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
284 phy_id); 353 phy_id);
285 /* The sequencer disables all phys on that port. 354 /* The sequencer disables all phys on that port.
286 * We have to re-enable the phys ourselves. */ 355 * We have to re-enable the phys ourselves. */
356 asd_deform_port(asd_ha, phy);
287 sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET); 357 sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET);
288 break; 358 break;
289 359
@@ -351,6 +421,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
351 u8 sb_opcode = dl->status_block[0]; 421 u8 sb_opcode = dl->status_block[0];
352 int phy_id = sb_opcode & DL_PHY_MASK; 422 int phy_id = sb_opcode & DL_PHY_MASK;
353 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 423 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
424 struct asd_phy *phy = &asd_ha->phys[phy_id];
354 425
355 if (edb > 6 || edb < 0) { 426 if (edb > 6 || edb < 0) {
356 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", 427 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n",
@@ -395,6 +466,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
395 asd_turn_led(asd_ha, phy_id, 0); 466 asd_turn_led(asd_ha, phy_id, 0);
396 /* the device is gone */ 467 /* the device is gone */
397 sas_phy_disconnected(sas_phy); 468 sas_phy_disconnected(sas_phy);
469 asd_deform_port(asd_ha, phy);
398 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT); 470 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT);
399 break; 471 break;
400 case REQ_TASK_ABORT: 472 case REQ_TASK_ABORT:
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c
index 83574b5b4e69..de7c04d4254d 100644
--- a/drivers/scsi/aic94xx/aic94xx_sds.c
+++ b/drivers/scsi/aic94xx/aic94xx_sds.c
@@ -630,10 +630,6 @@ static int asd_flash_getid(struct asd_ha_struct *asd_ha)
630 630
631 reg = asd_read_reg_dword(asd_ha, EXSICNFGR); 631 reg = asd_read_reg_dword(asd_ha, EXSICNFGR);
632 632
633 if (!(reg & FLASHEX)) {
634 ASD_DPRINTK("flash doesn't exist\n");
635 return -ENOENT;
636 }
637 if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR, 633 if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR,
638 &asd_ha->hw_prof.flash.bar)) { 634 &asd_ha->hw_prof.flash.bar)) {
639 asd_printk("couldn't read PCI_CONF_FLSH_BAR of %s\n", 635 asd_printk("couldn't read PCI_CONF_FLSH_BAR of %s\n",
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
index 56e4b3ba6a08..845112539d05 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.c
+++ b/drivers/scsi/aic94xx/aic94xx_seq.c
@@ -1369,10 +1369,9 @@ int asd_start_seqs(struct asd_ha_struct *asd_ha)
1369 * port_map_by_links is also used as the conn_mask byte in the 1369 * port_map_by_links is also used as the conn_mask byte in the
1370 * initiator/target port DDB. 1370 * initiator/target port DDB.
1371 */ 1371 */
1372void asd_update_port_links(struct asd_sas_phy *sas_phy) 1372void asd_update_port_links(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
1373{ 1373{
1374 struct asd_ha_struct *asd_ha = sas_phy->ha->lldd_ha; 1374 const u8 phy_mask = (u8) phy->asd_port->phy_mask;
1375 const u8 phy_mask = (u8) sas_phy->port->phy_mask;
1376 u8 phy_is_up; 1375 u8 phy_is_up;
1377 u8 mask; 1376 u8 mask;
1378 int i, err; 1377 int i, err;
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.h b/drivers/scsi/aic94xx/aic94xx_seq.h
index 42281c36153b..9e715e5496af 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.h
+++ b/drivers/scsi/aic94xx/aic94xx_seq.h
@@ -64,7 +64,7 @@ int asd_unpause_lseq(struct asd_ha_struct *asd_ha, u8 lseq_mask);
64int asd_init_seqs(struct asd_ha_struct *asd_ha); 64int asd_init_seqs(struct asd_ha_struct *asd_ha);
65int asd_start_seqs(struct asd_ha_struct *asd_ha); 65int asd_start_seqs(struct asd_ha_struct *asd_ha);
66 66
67void asd_update_port_links(struct asd_sas_phy *phy); 67void asd_update_port_links(struct asd_ha_struct *asd_ha, struct asd_phy *phy);
68#endif 68#endif
69 69
70#endif 70#endif
diff --git a/drivers/scsi/dpt/dpti_i2o.h b/drivers/scsi/dpt/dpti_i2o.h
index b3fa7ed71faf..5a49216fe4cf 100644
--- a/drivers/scsi/dpt/dpti_i2o.h
+++ b/drivers/scsi/dpt/dpti_i2o.h
@@ -49,7 +49,7 @@
49 49
50#include <linux/wait.h> 50#include <linux/wait.h>
51typedef wait_queue_head_t adpt_wait_queue_head_t; 51typedef wait_queue_head_t adpt_wait_queue_head_t;
52#define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) DECLARE_WAIT_QUEUE_HEAD(wait) 52#define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait)
53typedef wait_queue_t adpt_wait_queue_t; 53typedef wait_queue_t adpt_wait_queue_t;
54 54
55/* 55/*
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 65e6e7b7ba07..5d4ea6f77953 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -387,6 +387,7 @@ static void __iomem * bios_mem;
387static int bios_major; 387static int bios_major;
388static int bios_minor; 388static int bios_minor;
389static int PCI_bus; 389static int PCI_bus;
390static struct pci_dev *PCI_dev;
390static int Quantum; /* Quantum board variant */ 391static int Quantum; /* Quantum board variant */
391static int interrupt_level; 392static int interrupt_level;
392static volatile int in_command; 393static volatile int in_command;
@@ -812,9 +813,10 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
812 PCI_DEVICE_ID_FD_36C70 ); 813 PCI_DEVICE_ID_FD_36C70 );
813#endif 814#endif
814 815
815 if ((pdev = pci_find_device(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, pdev)) == NULL) 816 if ((pdev = pci_get_device(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, pdev)) == NULL)
816 return 0; 817 return 0;
817 if (pci_enable_device(pdev)) return 0; 818 if (pci_enable_device(pdev))
819 goto fail;
818 820
819#if DEBUG_DETECT 821#if DEBUG_DETECT
820 printk( "scsi: <fdomain> TMC-3260 detect:" 822 printk( "scsi: <fdomain> TMC-3260 detect:"
@@ -831,7 +833,7 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
831 pci_irq = pdev->irq; 833 pci_irq = pdev->irq;
832 834
833 if (!request_region( pci_base, 0x10, "fdomain" )) 835 if (!request_region( pci_base, 0x10, "fdomain" ))
834 return 0; 836 goto fail;
835 837
836 /* Now we have the I/O base address and interrupt from the PCI 838 /* Now we have the I/O base address and interrupt from the PCI
837 configuration registers. */ 839 configuration registers. */
@@ -848,17 +850,22 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
848 if (!fdomain_is_valid_port(pci_base)) { 850 if (!fdomain_is_valid_port(pci_base)) {
849 printk(KERN_ERR "scsi: <fdomain> PCI card detected, but driver not loaded (invalid port)\n" ); 851 printk(KERN_ERR "scsi: <fdomain> PCI card detected, but driver not loaded (invalid port)\n" );
850 release_region(pci_base, 0x10); 852 release_region(pci_base, 0x10);
851 return 0; 853 goto fail;
852 } 854 }
853 855
854 /* Fill in a few global variables. Ugh. */ 856 /* Fill in a few global variables. Ugh. */
855 bios_major = bios_minor = -1; 857 bios_major = bios_minor = -1;
856 PCI_bus = 1; 858 PCI_bus = 1;
859 PCI_dev = pdev;
857 Quantum = 0; 860 Quantum = 0;
858 bios_base = 0; 861 bios_base = 0;
859 862
860 return 1; 863 return 1;
864fail:
865 pci_dev_put(pdev);
866 return 0;
861} 867}
868
862#endif 869#endif
863 870
864struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt ) 871struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
@@ -909,8 +916,7 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
909 if (setup_called) { 916 if (setup_called) {
910 printk(KERN_ERR "scsi: <fdomain> Bad LILO/INSMOD parameters?\n"); 917 printk(KERN_ERR "scsi: <fdomain> Bad LILO/INSMOD parameters?\n");
911 } 918 }
912 release_region(port_base, 0x10); 919 goto fail;
913 return NULL;
914 } 920 }
915 921
916 if (this_id) { 922 if (this_id) {
@@ -942,8 +948,7 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
942 /* Log IRQ with kernel */ 948 /* Log IRQ with kernel */
943 if (!interrupt_level) { 949 if (!interrupt_level) {
944 printk(KERN_ERR "scsi: <fdomain> Card Detected, but driver not loaded (no IRQ)\n" ); 950 printk(KERN_ERR "scsi: <fdomain> Card Detected, but driver not loaded (no IRQ)\n" );
945 release_region(port_base, 0x10); 951 goto fail;
946 return NULL;
947 } else { 952 } else {
948 /* Register the IRQ with the kernel */ 953 /* Register the IRQ with the kernel */
949 954
@@ -964,11 +969,14 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
964 printk(KERN_ERR " Send mail to faith@acm.org\n" ); 969 printk(KERN_ERR " Send mail to faith@acm.org\n" );
965 } 970 }
966 printk(KERN_ERR "scsi: <fdomain> Detected, but driver not loaded (IRQ)\n" ); 971 printk(KERN_ERR "scsi: <fdomain> Detected, but driver not loaded (IRQ)\n" );
967 release_region(port_base, 0x10); 972 goto fail;
968 return NULL;
969 } 973 }
970 } 974 }
971 return shpnt; 975 return shpnt;
976fail:
977 pci_dev_put(pdev);
978 release_region(port_base, 0x10);
979 return NULL;
972} 980}
973 981
974static int fdomain_16x0_detect(struct scsi_host_template *tpnt) 982static int fdomain_16x0_detect(struct scsi_host_template *tpnt)
@@ -1714,6 +1722,8 @@ static int fdomain_16x0_release(struct Scsi_Host *shpnt)
1714 free_irq(shpnt->irq, shpnt); 1722 free_irq(shpnt->irq, shpnt);
1715 if (shpnt->io_port && shpnt->n_io_port) 1723 if (shpnt->io_port && shpnt->n_io_port)
1716 release_region(shpnt->io_port, shpnt->n_io_port); 1724 release_region(shpnt->io_port, shpnt->n_io_port);
1725 if (PCI_bus)
1726 pci_dev_put(PCI_dev);
1717 return 0; 1727 return 0;
1718} 1728}
1719 1729
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 4bc14ad92e22..4c698a71f66f 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3531,7 +3531,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
3531 IStatus &= ~0x80; 3531 IStatus &= ~0x80;
3532#ifdef INT_COAL 3532#ifdef INT_COAL
3533 if (coalesced) 3533 if (coalesced)
3534 ha->status = pcs->ext_status && 0xffff; 3534 ha->status = pcs->ext_status & 0xffff;
3535 else 3535 else
3536#endif 3536#endif
3537 ha->status = gdth_readw(&dp6m_ptr->i960r.status); 3537 ha->status = gdth_readw(&dp6m_ptr->i960r.status);
@@ -3543,7 +3543,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
3543 if (coalesced) { 3543 if (coalesced) {
3544 ha->info = pcs->info0; 3544 ha->info = pcs->info0;
3545 ha->info2 = pcs->info1; 3545 ha->info2 = pcs->info1;
3546 ha->service = (pcs->ext_status >> 16) && 0xffff; 3546 ha->service = (pcs->ext_status >> 16) & 0xffff;
3547 } else 3547 } else
3548#endif 3548#endif
3549 { 3549 {
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 669ea4fff166..fbc1d5c3b0a7 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1213,7 +1213,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
1213 "ibmvscsi: Re-enabling adapter!\n"); 1213 "ibmvscsi: Re-enabling adapter!\n");
1214 purge_requests(hostdata, DID_REQUEUE); 1214 purge_requests(hostdata, DID_REQUEUE);
1215 if ((ibmvscsi_reenable_crq_queue(&hostdata->queue, 1215 if ((ibmvscsi_reenable_crq_queue(&hostdata->queue,
1216 hostdata) == 0) || 1216 hostdata)) ||
1217 (ibmvscsi_send_crq(hostdata, 1217 (ibmvscsi_send_crq(hostdata,
1218 0xC001000000000000LL, 0))) { 1218 0xC001000000000000LL, 0))) {
1219 atomic_set(&hostdata->request_limit, 1219 atomic_set(&hostdata->request_limit,
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 2d95ac9c32c1..e31f6122106f 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -1153,7 +1153,7 @@ static int __imm_attach(struct parport *pb)
1153{ 1153{
1154 struct Scsi_Host *host; 1154 struct Scsi_Host *host;
1155 imm_struct *dev; 1155 imm_struct *dev;
1156 DECLARE_WAIT_QUEUE_HEAD(waiting); 1156 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
1157 DEFINE_WAIT(wait); 1157 DEFINE_WAIT(wait);
1158 int ports; 1158 int ports;
1159 int modes, ppb; 1159 int modes, ppb;
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 0a9dbc59663f..d0b139cccbbc 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -415,8 +415,8 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
415 iscsi_solicit_data_init(conn, ctask, r2t); 415 iscsi_solicit_data_init(conn, ctask, r2t);
416 416
417 tcp_ctask->exp_r2tsn = r2tsn + 1; 417 tcp_ctask->exp_r2tsn = r2tsn + 1;
418 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;
419 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*)); 418 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));
419 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;
420 list_move_tail(&ctask->running, &conn->xmitqueue); 420 list_move_tail(&ctask->running, &conn->xmitqueue);
421 421
422 scsi_queue_work(session->host, &conn->xmitwork); 422 scsi_queue_work(session->host, &conn->xmitwork);
@@ -1627,9 +1627,12 @@ static int iscsi_send_sol_pdu(struct iscsi_conn *conn,
1627 if (tcp_ctask->xmstate & XMSTATE_SOL_HDR) { 1627 if (tcp_ctask->xmstate & XMSTATE_SOL_HDR) {
1628 tcp_ctask->xmstate &= ~XMSTATE_SOL_HDR; 1628 tcp_ctask->xmstate &= ~XMSTATE_SOL_HDR;
1629 tcp_ctask->xmstate |= XMSTATE_SOL_DATA; 1629 tcp_ctask->xmstate |= XMSTATE_SOL_DATA;
1630 if (!tcp_ctask->r2t) 1630 if (!tcp_ctask->r2t) {
1631 spin_lock_bh(&session->lock);
1631 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t, 1632 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t,
1632 sizeof(void*)); 1633 sizeof(void*));
1634 spin_unlock_bh(&session->lock);
1635 }
1633send_hdr: 1636send_hdr:
1634 r2t = tcp_ctask->r2t; 1637 r2t = tcp_ctask->r2t;
1635 dtask = &r2t->dtask; 1638 dtask = &r2t->dtask;
@@ -1816,21 +1819,14 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_conn *cls_conn)
1816{ 1819{
1817 struct iscsi_conn *conn = cls_conn->dd_data; 1820 struct iscsi_conn *conn = cls_conn->dd_data;
1818 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 1821 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1819 int digest = 0;
1820
1821 if (conn->hdrdgst_en || conn->datadgst_en)
1822 digest = 1;
1823 1822
1824 iscsi_tcp_release_conn(conn); 1823 iscsi_tcp_release_conn(conn);
1825 iscsi_conn_teardown(cls_conn); 1824 iscsi_conn_teardown(cls_conn);
1826 1825
1827 /* now free tcp_conn */ 1826 if (tcp_conn->tx_hash.tfm)
1828 if (digest) { 1827 crypto_free_hash(tcp_conn->tx_hash.tfm);
1829 if (tcp_conn->tx_hash.tfm) 1828 if (tcp_conn->rx_hash.tfm)
1830 crypto_free_hash(tcp_conn->tx_hash.tfm); 1829 crypto_free_hash(tcp_conn->rx_hash.tfm);
1831 if (tcp_conn->rx_hash.tfm)
1832 crypto_free_hash(tcp_conn->rx_hash.tfm);
1833 }
1834 1830
1835 kfree(tcp_conn); 1831 kfree(tcp_conn);
1836} 1832}
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c542d0e95e68..5d8862189485 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -481,8 +481,8 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
481 break; 481 break;
482 case ISCSI_OP_ASYNC_EVENT: 482 case ISCSI_OP_ASYNC_EVENT:
483 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; 483 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
484 /* we need sth like iscsi_async_event_rsp() */ 484 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
485 rc = ISCSI_ERR_BAD_OPCODE; 485 rc = ISCSI_ERR_CONN_FAILED;
486 break; 486 break;
487 default: 487 default:
488 rc = ISCSI_ERR_BAD_OPCODE; 488 rc = ISCSI_ERR_BAD_OPCODE;
@@ -578,6 +578,27 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err)
578} 578}
579EXPORT_SYMBOL_GPL(iscsi_conn_failure); 579EXPORT_SYMBOL_GPL(iscsi_conn_failure);
580 580
581static int iscsi_xmit_imm_task(struct iscsi_conn *conn)
582{
583 struct iscsi_hdr *hdr = conn->mtask->hdr;
584 int rc, was_logout = 0;
585
586 if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) {
587 conn->session->state = ISCSI_STATE_IN_RECOVERY;
588 iscsi_block_session(session_to_cls(conn->session));
589 was_logout = 1;
590 }
591 rc = conn->session->tt->xmit_mgmt_task(conn, conn->mtask);
592 if (rc)
593 return rc;
594
595 if (was_logout) {
596 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
597 return -ENODATA;
598 }
599 return 0;
600}
601
581/** 602/**
582 * iscsi_data_xmit - xmit any command into the scheduled connection 603 * iscsi_data_xmit - xmit any command into the scheduled connection
583 * @conn: iscsi connection 604 * @conn: iscsi connection
@@ -623,7 +644,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
623 conn->ctask = NULL; 644 conn->ctask = NULL;
624 } 645 }
625 if (conn->mtask) { 646 if (conn->mtask) {
626 rc = tt->xmit_mgmt_task(conn, conn->mtask); 647 rc = iscsi_xmit_imm_task(conn);
627 if (rc) 648 if (rc)
628 goto again; 649 goto again;
629 /* done with this in-progress mtask */ 650 /* done with this in-progress mtask */
@@ -638,7 +659,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
638 list_add_tail(&conn->mtask->running, 659 list_add_tail(&conn->mtask->running,
639 &conn->mgmt_run_list); 660 &conn->mgmt_run_list);
640 spin_unlock_bh(&conn->session->lock); 661 spin_unlock_bh(&conn->session->lock);
641 rc = tt->xmit_mgmt_task(conn, conn->mtask); 662 rc = iscsi_xmit_imm_task(conn);
642 if (rc) 663 if (rc)
643 goto again; 664 goto again;
644 } 665 }
@@ -661,8 +682,6 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
661 spin_unlock_bh(&conn->session->lock); 682 spin_unlock_bh(&conn->session->lock);
662 683
663 rc = tt->xmit_cmd_task(conn, conn->ctask); 684 rc = tt->xmit_cmd_task(conn, conn->ctask);
664 if (rc)
665 goto again;
666 685
667 spin_lock_bh(&conn->session->lock); 686 spin_lock_bh(&conn->session->lock);
668 __iscsi_put_ctask(conn->ctask); 687 __iscsi_put_ctask(conn->ctask);
@@ -778,6 +797,10 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
778 } 797 }
779 798
780 conn = session->leadconn; 799 conn = session->leadconn;
800 if (!conn) {
801 reason = FAILURE_SESSION_FREED;
802 goto fault;
803 }
781 804
782 if (!__kfifo_get(session->cmdpool.queue, (void*)&ctask, 805 if (!__kfifo_get(session->cmdpool.queue, (void*)&ctask,
783 sizeof(void*))) { 806 sizeof(void*))) {
@@ -952,13 +975,13 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc)
952 if (session->state == ISCSI_STATE_TERMINATE) { 975 if (session->state == ISCSI_STATE_TERMINATE) {
953failed: 976failed:
954 debug_scsi("failing host reset: session terminated " 977 debug_scsi("failing host reset: session terminated "
955 "[CID %d age %d]", conn->id, session->age); 978 "[CID %d age %d]\n", conn->id, session->age);
956 spin_unlock_bh(&session->lock); 979 spin_unlock_bh(&session->lock);
957 return FAILED; 980 return FAILED;
958 } 981 }
959 982
960 if (sc->SCp.phase == session->age) { 983 if (sc->SCp.phase == session->age) {
961 debug_scsi("failing connection CID %d due to SCSI host reset", 984 debug_scsi("failing connection CID %d due to SCSI host reset\n",
962 conn->id); 985 conn->id);
963 fail_session = 1; 986 fail_session = 1;
964 } 987 }
@@ -1031,7 +1054,8 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
1031 NULL, 0); 1054 NULL, 0);
1032 if (rc) { 1055 if (rc) {
1033 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 1056 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1034 debug_scsi("abort sent failure [itt 0x%x] %d", ctask->itt, rc); 1057 debug_scsi("abort sent failure [itt 0x%x] %d\n", ctask->itt,
1058 rc);
1035 return rc; 1059 return rc;
1036 } 1060 }
1037 1061
@@ -1048,7 +1072,7 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
1048 conn->tmabort_timer.function = iscsi_tmabort_timedout; 1072 conn->tmabort_timer.function = iscsi_tmabort_timedout;
1049 conn->tmabort_timer.data = (unsigned long)ctask; 1073 conn->tmabort_timer.data = (unsigned long)ctask;
1050 add_timer(&conn->tmabort_timer); 1074 add_timer(&conn->tmabort_timer);
1051 debug_scsi("abort set timeout [itt 0x%x]", ctask->itt); 1075 debug_scsi("abort set timeout [itt 0x%x]\n", ctask->itt);
1052 } 1076 }
1053 spin_unlock_bh(&session->lock); 1077 spin_unlock_bh(&session->lock);
1054 mutex_unlock(&conn->xmitmutex); 1078 mutex_unlock(&conn->xmitmutex);
@@ -1377,7 +1401,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1377 } 1401 }
1378 1402
1379 spin_lock_init(&session->lock); 1403 spin_lock_init(&session->lock);
1380 INIT_LIST_HEAD(&session->connections);
1381 1404
1382 /* initialize immediate command pool */ 1405 /* initialize immediate command pool */
1383 if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max, 1406 if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max,
@@ -1580,16 +1603,11 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
1580 kfree(conn->persistent_address); 1603 kfree(conn->persistent_address);
1581 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask, 1604 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
1582 sizeof(void*)); 1605 sizeof(void*));
1583 list_del(&conn->item); 1606 if (session->leadconn == conn) {
1584 if (list_empty(&session->connections))
1585 session->leadconn = NULL; 1607 session->leadconn = NULL;
1586 if (session->leadconn && session->leadconn == conn)
1587 session->leadconn = container_of(session->connections.next,
1588 struct iscsi_conn, item);
1589
1590 if (session->leadconn == NULL)
1591 /* no connections exits.. reset sequencing */ 1608 /* no connections exits.. reset sequencing */
1592 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1; 1609 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1;
1610 }
1593 spin_unlock_bh(&session->lock); 1611 spin_unlock_bh(&session->lock);
1594 1612
1595 kfifo_free(conn->immqueue); 1613 kfifo_free(conn->immqueue);
@@ -1777,32 +1795,12 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
1777 struct iscsi_cls_conn *cls_conn, int is_leading) 1795 struct iscsi_cls_conn *cls_conn, int is_leading)
1778{ 1796{
1779 struct iscsi_session *session = class_to_transport_session(cls_session); 1797 struct iscsi_session *session = class_to_transport_session(cls_session);
1780 struct iscsi_conn *tmp = ERR_PTR(-EEXIST), *conn = cls_conn->dd_data; 1798 struct iscsi_conn *conn = cls_conn->dd_data;
1781 1799
1782 /* lookup for existing connection */
1783 spin_lock_bh(&session->lock); 1800 spin_lock_bh(&session->lock);
1784 list_for_each_entry(tmp, &session->connections, item) {
1785 if (tmp == conn) {
1786 if (conn->c_stage != ISCSI_CONN_STOPPED ||
1787 conn->stop_stage == STOP_CONN_TERM) {
1788 printk(KERN_ERR "iscsi: can't bind "
1789 "non-stopped connection (%d:%d)\n",
1790 conn->c_stage, conn->stop_stage);
1791 spin_unlock_bh(&session->lock);
1792 return -EIO;
1793 }
1794 break;
1795 }
1796 }
1797 if (tmp != conn) {
1798 /* bind new iSCSI connection to session */
1799 conn->session = session;
1800 list_add(&conn->item, &session->connections);
1801 }
1802 spin_unlock_bh(&session->lock);
1803
1804 if (is_leading) 1801 if (is_leading)
1805 session->leadconn = conn; 1802 session->leadconn = conn;
1803 spin_unlock_bh(&session->lock);
1806 1804
1807 /* 1805 /*
1808 * Unblock xmitworker(), Login Phase will pass through. 1806 * Unblock xmitworker(), Login Phase will pass through.
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 30b8014bcc7a..e34a93435497 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -71,55 +71,65 @@ static void smp_task_done(struct sas_task *task)
71static int smp_execute_task(struct domain_device *dev, void *req, int req_size, 71static int smp_execute_task(struct domain_device *dev, void *req, int req_size,
72 void *resp, int resp_size) 72 void *resp, int resp_size)
73{ 73{
74 int res; 74 int res, retry;
75 struct sas_task *task = sas_alloc_task(GFP_KERNEL); 75 struct sas_task *task = NULL;
76 struct sas_internal *i = 76 struct sas_internal *i =
77 to_sas_internal(dev->port->ha->core.shost->transportt); 77 to_sas_internal(dev->port->ha->core.shost->transportt);
78 78
79 if (!task) 79 for (retry = 0; retry < 3; retry++) {
80 return -ENOMEM; 80 task = sas_alloc_task(GFP_KERNEL);
81 81 if (!task)
82 task->dev = dev; 82 return -ENOMEM;
83 task->task_proto = dev->tproto;
84 sg_init_one(&task->smp_task.smp_req, req, req_size);
85 sg_init_one(&task->smp_task.smp_resp, resp, resp_size);
86 83
87 task->task_done = smp_task_done; 84 task->dev = dev;
85 task->task_proto = dev->tproto;
86 sg_init_one(&task->smp_task.smp_req, req, req_size);
87 sg_init_one(&task->smp_task.smp_resp, resp, resp_size);
88 88
89 task->timer.data = (unsigned long) task; 89 task->task_done = smp_task_done;
90 task->timer.function = smp_task_timedout;
91 task->timer.expires = jiffies + SMP_TIMEOUT*HZ;
92 add_timer(&task->timer);
93 90
94 res = i->dft->lldd_execute_task(task, 1, GFP_KERNEL); 91 task->timer.data = (unsigned long) task;
92 task->timer.function = smp_task_timedout;
93 task->timer.expires = jiffies + SMP_TIMEOUT*HZ;
94 add_timer(&task->timer);
95 95
96 if (res) { 96 res = i->dft->lldd_execute_task(task, 1, GFP_KERNEL);
97 del_timer(&task->timer);
98 SAS_DPRINTK("executing SMP task failed:%d\n", res);
99 goto ex_err;
100 }
101 97
102 wait_for_completion(&task->completion); 98 if (res) {
103 res = -ETASK; 99 del_timer(&task->timer);
104 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { 100 SAS_DPRINTK("executing SMP task failed:%d\n", res);
105 SAS_DPRINTK("smp task timed out or aborted\n");
106 i->dft->lldd_abort_task(task);
107 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
108 SAS_DPRINTK("SMP task aborted and not done\n");
109 goto ex_err; 101 goto ex_err;
110 } 102 }
103
104 wait_for_completion(&task->completion);
105 res = -ETASK;
106 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
107 SAS_DPRINTK("smp task timed out or aborted\n");
108 i->dft->lldd_abort_task(task);
109 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
110 SAS_DPRINTK("SMP task aborted and not done\n");
111 goto ex_err;
112 }
113 }
114 if (task->task_status.resp == SAS_TASK_COMPLETE &&
115 task->task_status.stat == SAM_GOOD) {
116 res = 0;
117 break;
118 } else {
119 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
120 "status 0x%x\n", __FUNCTION__,
121 SAS_ADDR(dev->sas_addr),
122 task->task_status.resp,
123 task->task_status.stat);
124 sas_free_task(task);
125 task = NULL;
126 }
111 } 127 }
112 if (task->task_status.resp == SAS_TASK_COMPLETE &&
113 task->task_status.stat == SAM_GOOD)
114 res = 0;
115 else
116 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
117 "status 0x%x\n", __FUNCTION__,
118 SAS_ADDR(dev->sas_addr),
119 task->task_status.resp,
120 task->task_status.stat);
121ex_err: 128ex_err:
122 sas_free_task(task); 129 BUG_ON(retry == 3 && task != NULL);
130 if (task != NULL) {
131 sas_free_task(task);
132 }
123 return res; 133 return res;
124} 134}
125 135
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 9496e87c135e..2a4e02e7a392 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -594,7 +594,8 @@ lpfc_soft_wwpn_show(struct class_device *cdev, char *buf)
594{ 594{
595 struct Scsi_Host *host = class_to_shost(cdev); 595 struct Scsi_Host *host = class_to_shost(cdev);
596 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 596 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
597 return snprintf(buf, PAGE_SIZE, "0x%llx\n", phba->cfg_soft_wwpn); 597 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
598 (unsigned long long)phba->cfg_soft_wwpn);
598} 599}
599 600
600 601
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 1b53afb1cb57..3add7c237859 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -188,7 +188,8 @@ lpfc_alloc_ct_rsp(struct lpfc_hba * phba, int cmdcode, struct ulp_bde64 * bpl,
188 188
189 if (!mp->virt) { 189 if (!mp->virt) {
190 kfree(mp); 190 kfree(mp);
191 lpfc_free_ct_rsp(phba, mlist); 191 if (mlist)
192 lpfc_free_ct_rsp(phba, mlist);
192 return NULL; 193 return NULL;
193 } 194 }
194 195
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index d586c3d3b0d0..19c79a0549a7 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -305,7 +305,7 @@ lpfc_do_work(void *p)
305{ 305{
306 struct lpfc_hba *phba = p; 306 struct lpfc_hba *phba = p;
307 int rc; 307 int rc;
308 DECLARE_WAIT_QUEUE_HEAD(work_waitq); 308 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(work_waitq);
309 309
310 set_user_nice(current, -20); 310 set_user_nice(current, -20);
311 phba->work_wait = &work_waitq; 311 phba->work_wait = &work_waitq;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 24a1779b9af4..582f5ea4e84e 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -2983,7 +2983,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
2983 struct lpfc_iocbq * prspiocbq, 2983 struct lpfc_iocbq * prspiocbq,
2984 uint32_t timeout) 2984 uint32_t timeout)
2985{ 2985{
2986 DECLARE_WAIT_QUEUE_HEAD(done_q); 2986 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q);
2987 long timeleft, timeout_req = 0; 2987 long timeleft, timeout_req = 0;
2988 int retval = IOCB_SUCCESS; 2988 int retval = IOCB_SUCCESS;
2989 uint32_t creg_val; 2989 uint32_t creg_val;
@@ -3061,7 +3061,7 @@ int
3061lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, 3061lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
3062 uint32_t timeout) 3062 uint32_t timeout)
3063{ 3063{
3064 DECLARE_WAIT_QUEUE_HEAD(done_q); 3064 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q);
3065 DECLARE_WAITQUEUE(wq_entry, current); 3065 DECLARE_WAITQUEUE(wq_entry, current);
3066 uint32_t timeleft = 0; 3066 uint32_t timeleft = 0;
3067 int retval; 3067 int retval;
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index b1d346049525..f2d79c3f0b8e 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -183,7 +183,7 @@ static void nsp_cs_dmessage(const char *func, int line, int mask, char *fmt, ...
183 * Clenaup parameters and call done() functions. 183 * Clenaup parameters and call done() functions.
184 * You must be set SCpnt->result before call this function. 184 * You must be set SCpnt->result before call this function.
185 */ 185 */
186static void nsp_scsi_done(Scsi_Cmnd *SCpnt) 186static void nsp_scsi_done(struct scsi_cmnd *SCpnt)
187{ 187{
188 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 188 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
189 189
@@ -192,7 +192,8 @@ static void nsp_scsi_done(Scsi_Cmnd *SCpnt)
192 SCpnt->scsi_done(SCpnt); 192 SCpnt->scsi_done(SCpnt);
193} 193}
194 194
195static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 195static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
196 void (*done)(struct scsi_cmnd *))
196{ 197{
197#ifdef NSP_DEBUG 198#ifdef NSP_DEBUG
198 /*unsigned int host_id = SCpnt->device->host->this_id;*/ 199 /*unsigned int host_id = SCpnt->device->host->this_id;*/
@@ -365,7 +366,7 @@ static int nsphw_init(nsp_hw_data *data)
365/* 366/*
366 * Start selection phase 367 * Start selection phase
367 */ 368 */
368static int nsphw_start_selection(Scsi_Cmnd *SCpnt) 369static int nsphw_start_selection(struct scsi_cmnd *SCpnt)
369{ 370{
370 unsigned int host_id = SCpnt->device->host->this_id; 371 unsigned int host_id = SCpnt->device->host->this_id;
371 unsigned int base = SCpnt->device->host->io_port; 372 unsigned int base = SCpnt->device->host->io_port;
@@ -446,7 +447,7 @@ static struct nsp_sync_table nsp_sync_table_20M[] = {
446/* 447/*
447 * setup synchronous data transfer mode 448 * setup synchronous data transfer mode
448 */ 449 */
449static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt) 450static int nsp_analyze_sdtr(struct scsi_cmnd *SCpnt)
450{ 451{
451 unsigned char target = scmd_id(SCpnt); 452 unsigned char target = scmd_id(SCpnt);
452// unsigned char lun = SCpnt->device->lun; 453// unsigned char lun = SCpnt->device->lun;
@@ -504,7 +505,7 @@ static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt)
504/* 505/*
505 * start ninja hardware timer 506 * start ninja hardware timer
506 */ 507 */
507static void nsp_start_timer(Scsi_Cmnd *SCpnt, int time) 508static void nsp_start_timer(struct scsi_cmnd *SCpnt, int time)
508{ 509{
509 unsigned int base = SCpnt->device->host->io_port; 510 unsigned int base = SCpnt->device->host->io_port;
510 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 511 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -517,7 +518,8 @@ static void nsp_start_timer(Scsi_Cmnd *SCpnt, int time)
517/* 518/*
518 * wait for bus phase change 519 * wait for bus phase change
519 */ 520 */
520static int nsp_negate_signal(Scsi_Cmnd *SCpnt, unsigned char mask, char *str) 521static int nsp_negate_signal(struct scsi_cmnd *SCpnt, unsigned char mask,
522 char *str)
521{ 523{
522 unsigned int base = SCpnt->device->host->io_port; 524 unsigned int base = SCpnt->device->host->io_port;
523 unsigned char reg; 525 unsigned char reg;
@@ -544,9 +546,9 @@ static int nsp_negate_signal(Scsi_Cmnd *SCpnt, unsigned char mask, char *str)
544/* 546/*
545 * expect Ninja Irq 547 * expect Ninja Irq
546 */ 548 */
547static int nsp_expect_signal(Scsi_Cmnd *SCpnt, 549static int nsp_expect_signal(struct scsi_cmnd *SCpnt,
548 unsigned char current_phase, 550 unsigned char current_phase,
549 unsigned char mask) 551 unsigned char mask)
550{ 552{
551 unsigned int base = SCpnt->device->host->io_port; 553 unsigned int base = SCpnt->device->host->io_port;
552 int time_out; 554 int time_out;
@@ -579,7 +581,7 @@ static int nsp_expect_signal(Scsi_Cmnd *SCpnt,
579/* 581/*
580 * transfer SCSI message 582 * transfer SCSI message
581 */ 583 */
582static int nsp_xfer(Scsi_Cmnd *SCpnt, int phase) 584static int nsp_xfer(struct scsi_cmnd *SCpnt, int phase)
583{ 585{
584 unsigned int base = SCpnt->device->host->io_port; 586 unsigned int base = SCpnt->device->host->io_port;
585 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 587 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -619,7 +621,7 @@ static int nsp_xfer(Scsi_Cmnd *SCpnt, int phase)
619/* 621/*
620 * get extra SCSI data from fifo 622 * get extra SCSI data from fifo
621 */ 623 */
622static int nsp_dataphase_bypass(Scsi_Cmnd *SCpnt) 624static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt)
623{ 625{
624 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 626 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
625 unsigned int count; 627 unsigned int count;
@@ -651,7 +653,7 @@ static int nsp_dataphase_bypass(Scsi_Cmnd *SCpnt)
651/* 653/*
652 * accept reselection 654 * accept reselection
653 */ 655 */
654static int nsp_reselected(Scsi_Cmnd *SCpnt) 656static int nsp_reselected(struct scsi_cmnd *SCpnt)
655{ 657{
656 unsigned int base = SCpnt->device->host->io_port; 658 unsigned int base = SCpnt->device->host->io_port;
657 unsigned int host_id = SCpnt->device->host->this_id; 659 unsigned int host_id = SCpnt->device->host->this_id;
@@ -690,7 +692,7 @@ static int nsp_reselected(Scsi_Cmnd *SCpnt)
690/* 692/*
691 * count how many data transferd 693 * count how many data transferd
692 */ 694 */
693static int nsp_fifo_count(Scsi_Cmnd *SCpnt) 695static int nsp_fifo_count(struct scsi_cmnd *SCpnt)
694{ 696{
695 unsigned int base = SCpnt->device->host->io_port; 697 unsigned int base = SCpnt->device->host->io_port;
696 unsigned int count; 698 unsigned int count;
@@ -717,7 +719,7 @@ static int nsp_fifo_count(Scsi_Cmnd *SCpnt)
717/* 719/*
718 * read data in DATA IN phase 720 * read data in DATA IN phase
719 */ 721 */
720static void nsp_pio_read(Scsi_Cmnd *SCpnt) 722static void nsp_pio_read(struct scsi_cmnd *SCpnt)
721{ 723{
722 unsigned int base = SCpnt->device->host->io_port; 724 unsigned int base = SCpnt->device->host->io_port;
723 unsigned long mmio_base = SCpnt->device->host->base; 725 unsigned long mmio_base = SCpnt->device->host->base;
@@ -812,7 +814,7 @@ static void nsp_pio_read(Scsi_Cmnd *SCpnt)
812/* 814/*
813 * write data in DATA OUT phase 815 * write data in DATA OUT phase
814 */ 816 */
815static void nsp_pio_write(Scsi_Cmnd *SCpnt) 817static void nsp_pio_write(struct scsi_cmnd *SCpnt)
816{ 818{
817 unsigned int base = SCpnt->device->host->io_port; 819 unsigned int base = SCpnt->device->host->io_port;
818 unsigned long mmio_base = SCpnt->device->host->base; 820 unsigned long mmio_base = SCpnt->device->host->base;
@@ -905,7 +907,7 @@ static void nsp_pio_write(Scsi_Cmnd *SCpnt)
905/* 907/*
906 * setup synchronous/asynchronous data transfer mode 908 * setup synchronous/asynchronous data transfer mode
907 */ 909 */
908static int nsp_nexus(Scsi_Cmnd *SCpnt) 910static int nsp_nexus(struct scsi_cmnd *SCpnt)
909{ 911{
910 unsigned int base = SCpnt->device->host->io_port; 912 unsigned int base = SCpnt->device->host->io_port;
911 unsigned char target = scmd_id(SCpnt); 913 unsigned char target = scmd_id(SCpnt);
@@ -952,7 +954,7 @@ static irqreturn_t nspintr(int irq, void *dev_id)
952{ 954{
953 unsigned int base; 955 unsigned int base;
954 unsigned char irq_status, irq_phase, phase; 956 unsigned char irq_status, irq_phase, phase;
955 Scsi_Cmnd *tmpSC; 957 struct scsi_cmnd *tmpSC;
956 unsigned char target, lun; 958 unsigned char target, lun;
957 unsigned int *sync_neg; 959 unsigned int *sync_neg;
958 int i, tmp; 960 int i, tmp;
@@ -1530,7 +1532,7 @@ nsp_proc_info(
1530/*---------------------------------------------------------------*/ 1532/*---------------------------------------------------------------*/
1531 1533
1532/* 1534/*
1533static int nsp_eh_abort(Scsi_Cmnd *SCpnt) 1535static int nsp_eh_abort(struct scsi_cmnd *SCpnt)
1534{ 1536{
1535 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt); 1537 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
1536 1538
@@ -1558,7 +1560,7 @@ static int nsp_bus_reset(nsp_hw_data *data)
1558 return SUCCESS; 1560 return SUCCESS;
1559} 1561}
1560 1562
1561static int nsp_eh_bus_reset(Scsi_Cmnd *SCpnt) 1563static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
1562{ 1564{
1563 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 1565 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
1564 1566
@@ -1567,7 +1569,7 @@ static int nsp_eh_bus_reset(Scsi_Cmnd *SCpnt)
1567 return nsp_bus_reset(data); 1569 return nsp_bus_reset(data);
1568} 1570}
1569 1571
1570static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt) 1572static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt)
1571{ 1573{
1572 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 1574 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
1573 1575
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index a88714f4c05b..625ca97da52d 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -266,7 +266,7 @@ typedef struct _nsp_hw_data {
266 266
267 int TimerCount; 267 int TimerCount;
268 int SelectionTimeOut; 268 int SelectionTimeOut;
269 Scsi_Cmnd *CurrentSC; 269 struct scsi_cmnd *CurrentSC;
270 //int CurrnetTarget; 270 //int CurrnetTarget;
271 271
272 int FifoCount; 272 int FifoCount;
@@ -319,30 +319,34 @@ static int nsp_proc_info (
319 int hostno, 319 int hostno,
320#endif 320#endif
321 int inout); 321 int inout);
322static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (* done)(Scsi_Cmnd *SCpnt)); 322static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
323 void (* done)(struct scsi_cmnd *SCpnt));
323 324
324/* Error handler */ 325/* Error handler */
325/*static int nsp_eh_abort (Scsi_Cmnd *SCpnt);*/ 326/*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/
326/*static int nsp_eh_device_reset(Scsi_Cmnd *SCpnt);*/ 327/*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
327static int nsp_eh_bus_reset (Scsi_Cmnd *SCpnt); 328static int nsp_eh_bus_reset (struct scsi_cmnd *SCpnt);
328static int nsp_eh_host_reset (Scsi_Cmnd *SCpnt); 329static int nsp_eh_host_reset (struct scsi_cmnd *SCpnt);
329static int nsp_bus_reset (nsp_hw_data *data); 330static int nsp_bus_reset (nsp_hw_data *data);
330 331
331/* */ 332/* */
332static int nsphw_init (nsp_hw_data *data); 333static int nsphw_init (nsp_hw_data *data);
333static int nsphw_start_selection(Scsi_Cmnd *SCpnt); 334static int nsphw_start_selection(struct scsi_cmnd *SCpnt);
334static void nsp_start_timer (Scsi_Cmnd *SCpnt, int time); 335static void nsp_start_timer (struct scsi_cmnd *SCpnt, int time);
335static int nsp_fifo_count (Scsi_Cmnd *SCpnt); 336static int nsp_fifo_count (struct scsi_cmnd *SCpnt);
336static void nsp_pio_read (Scsi_Cmnd *SCpnt); 337static void nsp_pio_read (struct scsi_cmnd *SCpnt);
337static void nsp_pio_write (Scsi_Cmnd *SCpnt); 338static void nsp_pio_write (struct scsi_cmnd *SCpnt);
338static int nsp_nexus (Scsi_Cmnd *SCpnt); 339static int nsp_nexus (struct scsi_cmnd *SCpnt);
339static void nsp_scsi_done (Scsi_Cmnd *SCpnt); 340static void nsp_scsi_done (struct scsi_cmnd *SCpnt);
340static int nsp_analyze_sdtr (Scsi_Cmnd *SCpnt); 341static int nsp_analyze_sdtr (struct scsi_cmnd *SCpnt);
341static int nsp_negate_signal (Scsi_Cmnd *SCpnt, unsigned char mask, char *str); 342static int nsp_negate_signal (struct scsi_cmnd *SCpnt,
342static int nsp_expect_signal (Scsi_Cmnd *SCpnt, unsigned char current_phase, unsigned char mask); 343 unsigned char mask, char *str);
343static int nsp_xfer (Scsi_Cmnd *SCpnt, int phase); 344static int nsp_expect_signal (struct scsi_cmnd *SCpnt,
344static int nsp_dataphase_bypass (Scsi_Cmnd *SCpnt); 345 unsigned char current_phase,
345static int nsp_reselected (Scsi_Cmnd *SCpnt); 346 unsigned char mask);
347static int nsp_xfer (struct scsi_cmnd *SCpnt, int phase);
348static int nsp_dataphase_bypass (struct scsi_cmnd *SCpnt);
349static int nsp_reselected (struct scsi_cmnd *SCpnt);
346static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht); 350static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht);
347 351
348/* Interrupt handler */ 352/* Interrupt handler */
@@ -355,8 +359,8 @@ static void __exit nsp_cs_exit(void);
355 359
356/* Debug */ 360/* Debug */
357#ifdef NSP_DEBUG 361#ifdef NSP_DEBUG
358static void show_command (Scsi_Cmnd *SCpnt); 362static void show_command (struct scsi_cmnd *SCpnt);
359static void show_phase (Scsi_Cmnd *SCpnt); 363static void show_phase (struct scsi_cmnd *SCpnt);
360static void show_busphase(unsigned char stat); 364static void show_busphase(unsigned char stat);
361static void show_message (nsp_hw_data *data); 365static void show_message (nsp_hw_data *data);
362#else 366#else
diff --git a/drivers/scsi/pcmcia/nsp_debug.c b/drivers/scsi/pcmcia/nsp_debug.c
index 62e5c60067fd..2f75fe6e35a7 100644
--- a/drivers/scsi/pcmcia/nsp_debug.c
+++ b/drivers/scsi/pcmcia/nsp_debug.c
@@ -138,12 +138,12 @@ static void print_commandk (unsigned char *command)
138 printk("\n"); 138 printk("\n");
139} 139}
140 140
141static void show_command(Scsi_Cmnd *SCpnt) 141static void show_command(struct scsi_cmnd *SCpnt)
142{ 142{
143 print_commandk(SCpnt->cmnd); 143 print_commandk(SCpnt->cmnd);
144} 144}
145 145
146static void show_phase(Scsi_Cmnd *SCpnt) 146static void show_phase(struct scsi_cmnd *SCpnt)
147{ 147{
148 int i = SCpnt->SCp.phase; 148 int i = SCpnt->SCp.phase;
149 149
diff --git a/drivers/scsi/pcmcia/nsp_message.c b/drivers/scsi/pcmcia/nsp_message.c
index d7057737ff34..ef593b70d0f0 100644
--- a/drivers/scsi/pcmcia/nsp_message.c
+++ b/drivers/scsi/pcmcia/nsp_message.c
@@ -8,7 +8,7 @@
8 8
9/* $Id: nsp_message.c,v 1.6 2003/07/26 14:21:09 elca Exp $ */ 9/* $Id: nsp_message.c,v 1.6 2003/07/26 14:21:09 elca Exp $ */
10 10
11static void nsp_message_in(Scsi_Cmnd *SCpnt) 11static void nsp_message_in(struct scsi_cmnd *SCpnt)
12{ 12{
13 unsigned int base = SCpnt->device->host->io_port; 13 unsigned int base = SCpnt->device->host->io_port;
14 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 14 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -50,7 +50,7 @@ static void nsp_message_in(Scsi_Cmnd *SCpnt)
50 50
51} 51}
52 52
53static void nsp_message_out(Scsi_Cmnd *SCpnt) 53static void nsp_message_out(struct scsi_cmnd *SCpnt)
54{ 54{
55 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 55 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
56 int ret = 1; 56 int ret = 1;
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index b0eba39f208a..89a2a9f11e41 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -1012,7 +1012,7 @@ static LIST_HEAD(ppa_hosts);
1012static int __ppa_attach(struct parport *pb) 1012static int __ppa_attach(struct parport *pb)
1013{ 1013{
1014 struct Scsi_Host *host; 1014 struct Scsi_Host *host;
1015 DECLARE_WAIT_QUEUE_HEAD(waiting); 1015 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
1016 DEFINE_WAIT(wait); 1016 DEFINE_WAIT(wait);
1017 ppa_struct *dev; 1017 ppa_struct *dev;
1018 int ports; 1018 int ports;
diff --git a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c
index a720c9265e66..899e89d6fe67 100644
--- a/drivers/scsi/psi240i.c
+++ b/drivers/scsi/psi240i.c
@@ -87,11 +87,11 @@ typedef struct
87 { 87 {
88 USHORT ports[13]; 88 USHORT ports[13];
89 OUR_DEVICE device[8]; 89 OUR_DEVICE device[8];
90 Scsi_Cmnd *pSCmnd; 90 struct scsi_cmnd *pSCmnd;
91 IDE_STRUCT ide; 91 IDE_STRUCT ide;
92 ULONG startSector; 92 ULONG startSector;
93 USHORT sectorCount; 93 USHORT sectorCount;
94 Scsi_Cmnd *SCpnt; 94 struct scsi_cmnd *SCpnt;
95 VOID *buffer; 95 VOID *buffer;
96 USHORT expectingIRQ; 96 USHORT expectingIRQ;
97 } ADAPTER240I, *PADAPTER240I; 97 } ADAPTER240I, *PADAPTER240I;
@@ -253,12 +253,12 @@ static ULONG DecodeError (struct Scsi_Host *pshost, UCHAR status)
253 ****************************************************************/ 253 ****************************************************************/
254static void Irq_Handler (int irq, void *dev_id) 254static void Irq_Handler (int irq, void *dev_id)
255 { 255 {
256 struct Scsi_Host *shost; // Pointer to host data block 256 struct Scsi_Host *shost; // Pointer to host data block
257 PADAPTER240I padapter; // Pointer to adapter control structure 257 PADAPTER240I padapter; // Pointer to adapter control structure
258 USHORT *pports; // I/O port array 258 USHORT *pports; // I/O port array
259 Scsi_Cmnd *SCpnt; 259 struct scsi_cmnd *SCpnt;
260 UCHAR status; 260 UCHAR status;
261 int z; 261 int z;
262 262
263 DEB(printk ("\npsi240i received interrupt\n")); 263 DEB(printk ("\npsi240i received interrupt\n"));
264 264
@@ -328,7 +328,7 @@ static void Irq_Handler (int irq, void *dev_id)
328 pinquiryData->AdditionalLength = 35 - 4; 328 pinquiryData->AdditionalLength = 35 - 4;
329 329
330 // Fill in vendor identification fields. 330 // Fill in vendor identification fields.
331 for ( z = 0; z < 20; z += 2 ) 331 for ( z = 0; z < 8; z += 2 )
332 { 332 {
333 pinquiryData->VendorId[z] = ((UCHAR *)identifyData.ModelNumber)[z + 1]; 333 pinquiryData->VendorId[z] = ((UCHAR *)identifyData.ModelNumber)[z + 1];
334 pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z]; 334 pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z];
@@ -389,12 +389,17 @@ static irqreturn_t do_Irq_Handler (int irq, void *dev_id)
389 * Returns: Status code. 389 * Returns: Status code.
390 * 390 *
391 ****************************************************************/ 391 ****************************************************************/
392static int Psi240i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 392static int Psi240i_QueueCommand(struct scsi_cmnd *SCpnt,
393 void (*done)(struct scsi_cmnd *))
393 { 394 {
394 UCHAR *cdb = (UCHAR *)SCpnt->cmnd; // Pointer to SCSI CDB 395 UCHAR *cdb = (UCHAR *)SCpnt->cmnd;
395 PADAPTER240I padapter = HOSTDATA (SCpnt->device->host); // Pointer to adapter control structure 396 // Pointer to SCSI CDB
396 POUR_DEVICE pdev = &padapter->device [SCpnt->device->id];// Pointer to device information 397 PADAPTER240I padapter = HOSTDATA (SCpnt->device->host);
397 UCHAR rc; // command return code 398 // Pointer to adapter control structure
399 POUR_DEVICE pdev = &padapter->device [SCpnt->device->id];
400 // Pointer to device information
401 UCHAR rc;
402 // command return code
398 403
399 SCpnt->scsi_done = done; 404 SCpnt->scsi_done = done;
400 padapter->ide.ide.ides.spigot = pdev->spigot; 405 padapter->ide.ide.ides.spigot = pdev->spigot;
diff --git a/drivers/scsi/psi240i.h b/drivers/scsi/psi240i.h
index 6a598766df51..21ebb9214004 100644
--- a/drivers/scsi/psi240i.h
+++ b/drivers/scsi/psi240i.h
@@ -309,7 +309,7 @@ typedef struct _IDENTIFY_DATA2 {
309#endif // PSI_EIDE_SCSIOP 309#endif // PSI_EIDE_SCSIOP
310 310
311// function prototypes 311// function prototypes
312int Psi240i_Command (Scsi_Cmnd *SCpnt); 312int Psi240i_Command(struct scsi_cmnd *SCpnt);
313int Psi240i_Abort (Scsi_Cmnd *SCpnt); 313int Psi240i_Abort(struct scsi_cmnd *SCpnt);
314int Psi240i_Reset (Scsi_Cmnd *SCpnt, unsigned int flags); 314int Psi240i_Reset(struct scsi_cmnd *SCpnt, unsigned int flags);
315#endif 315#endif
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 2521d548dd59..16af5b79e587 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -931,11 +931,10 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
931 931
932 case BUS_RESET: 932 case BUS_RESET:
933 if (qla1280_verbose) 933 if (qla1280_verbose)
934 printk(KERN_INFO "qla1280(%ld:%d): Issuing BUS " 934 printk(KERN_INFO "qla1280(%ld:%d): Issued bus "
935 "DEVICE RESET\n", ha->host_no, bus); 935 "reset.\n", ha->host_no, bus);
936 if (qla1280_bus_reset(ha, bus == 0)) 936 if (qla1280_bus_reset(ha, bus) == 0)
937 result = SUCCESS; 937 result = SUCCESS;
938
939 break; 938 break;
940 939
941 case ADAPTER_RESET: 940 case ADAPTER_RESET:
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index ee75a71f3c66..285c8e8ff1a0 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -379,21 +379,37 @@ static struct bin_attribute sysfs_sfp_attr = {
379 .read = qla2x00_sysfs_read_sfp, 379 .read = qla2x00_sysfs_read_sfp,
380}; 380};
381 381
382static struct sysfs_entry {
383 char *name;
384 struct bin_attribute *attr;
385 int is4GBp_only;
386} bin_file_entries[] = {
387 { "fw_dump", &sysfs_fw_dump_attr, },
388 { "nvram", &sysfs_nvram_attr, },
389 { "optrom", &sysfs_optrom_attr, },
390 { "optrom_ctl", &sysfs_optrom_ctl_attr, },
391 { "vpd", &sysfs_vpd_attr, 1 },
392 { "sfp", &sysfs_sfp_attr, 1 },
393 { 0 },
394};
395
382void 396void
383qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) 397qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
384{ 398{
385 struct Scsi_Host *host = ha->host; 399 struct Scsi_Host *host = ha->host;
400 struct sysfs_entry *iter;
401 int ret;
386 402
387 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); 403 for (iter = bin_file_entries; iter->name; iter++) {
388 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); 404 if (iter->is4GBp_only && (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)))
389 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); 405 continue;
390 sysfs_create_bin_file(&host->shost_gendev.kobj, 406
391 &sysfs_optrom_ctl_attr); 407 ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
392 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 408 iter->attr);
393 sysfs_create_bin_file(&host->shost_gendev.kobj, 409 if (ret)
394 &sysfs_vpd_attr); 410 qla_printk(KERN_INFO, ha,
395 sysfs_create_bin_file(&host->shost_gendev.kobj, 411 "Unable to create sysfs %s binary attribute "
396 &sysfs_sfp_attr); 412 "(%d).\n", iter->name, ret);
397 } 413 }
398} 414}
399 415
@@ -401,17 +417,14 @@ void
401qla2x00_free_sysfs_attr(scsi_qla_host_t *ha) 417qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
402{ 418{
403 struct Scsi_Host *host = ha->host; 419 struct Scsi_Host *host = ha->host;
420 struct sysfs_entry *iter;
421
422 for (iter = bin_file_entries; iter->name; iter++) {
423 if (iter->is4GBp_only && (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)))
424 continue;
404 425
405 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr);
406 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr);
407 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr);
408 sysfs_remove_bin_file(&host->shost_gendev.kobj,
409 &sysfs_optrom_ctl_attr);
410 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
411 sysfs_remove_bin_file(&host->shost_gendev.kobj,
412 &sysfs_vpd_attr);
413 sysfs_remove_bin_file(&host->shost_gendev.kobj, 426 sysfs_remove_bin_file(&host->shost_gendev.kobj,
414 &sysfs_sfp_attr); 427 iter->attr);
415 } 428 }
416 429
417 if (ha->beacon_blink_led == 1) 430 if (ha->beacon_blink_led == 1)
diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h
index 90dad7e88985..5b12278968e0 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.h
+++ b/drivers/scsi/qla2xxx/qla_dbg.h
@@ -38,7 +38,7 @@
38* Macros use for debugging the driver. 38* Macros use for debugging the driver.
39*/ 39*/
40 40
41#define DEBUG(x) do { if (qla2_extended_error_logging) { x; } } while (0) 41#define DEBUG(x) do { if (ql2xextended_error_logging) { x; } } while (0)
42 42
43#if defined(QL_DEBUG_LEVEL_1) 43#if defined(QL_DEBUG_LEVEL_1)
44#define DEBUG1(x) do {x;} while (0) 44#define DEBUG1(x) do {x;} while (0)
@@ -46,12 +46,12 @@
46#define DEBUG1(x) do {} while (0) 46#define DEBUG1(x) do {} while (0)
47#endif 47#endif
48 48
49#define DEBUG2(x) do { if (qla2_extended_error_logging) { x; } } while (0) 49#define DEBUG2(x) do { if (ql2xextended_error_logging) { x; } } while (0)
50#define DEBUG2_3(x) do { if (qla2_extended_error_logging) { x; } } while (0) 50#define DEBUG2_3(x) do { if (ql2xextended_error_logging) { x; } } while (0)
51#define DEBUG2_3_11(x) do { if (qla2_extended_error_logging) { x; } } while (0) 51#define DEBUG2_3_11(x) do { if (ql2xextended_error_logging) { x; } } while (0)
52#define DEBUG2_9_10(x) do { if (qla2_extended_error_logging) { x; } } while (0) 52#define DEBUG2_9_10(x) do { if (ql2xextended_error_logging) { x; } } while (0)
53#define DEBUG2_11(x) do { if (qla2_extended_error_logging) { x; } } while (0) 53#define DEBUG2_11(x) do { if (ql2xextended_error_logging) { x; } } while (0)
54#define DEBUG2_13(x) do { if (qla2_extended_error_logging) { x; } } while (0) 54#define DEBUG2_13(x) do { if (ql2xextended_error_logging) { x; } } while (0)
55 55
56#if defined(QL_DEBUG_LEVEL_3) 56#if defined(QL_DEBUG_LEVEL_3)
57#define DEBUG3(x) do {x;} while (0) 57#define DEBUG3(x) do {x;} while (0)
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index bab33f6d0bdb..c4fc40f8e8ca 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1545,6 +1545,9 @@ typedef struct fc_port {
1545 spinlock_t rport_lock; 1545 spinlock_t rport_lock;
1546 struct fc_rport *rport, *drport; 1546 struct fc_rport *rport, *drport;
1547 u32 supported_classes; 1547 u32 supported_classes;
1548
1549 unsigned long last_queue_full;
1550 unsigned long last_ramp_up;
1548} fc_port_t; 1551} fc_port_t;
1549 1552
1550/* 1553/*
@@ -2255,6 +2258,7 @@ typedef struct scsi_qla_host {
2255 uint16_t mgmt_svr_loop_id; 2258 uint16_t mgmt_svr_loop_id;
2256 2259
2257 uint32_t login_retry_count; 2260 uint32_t login_retry_count;
2261 int max_q_depth;
2258 2262
2259 /* Fibre Channel Device List. */ 2263 /* Fibre Channel Device List. */
2260 struct list_head fcports; 2264 struct list_head fcports;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 7da69832d74c..32ebeec45ff0 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -48,6 +48,7 @@ extern void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
48extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *); 48extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *);
49 49
50extern void qla2x00_alloc_fw_dump(scsi_qla_host_t *); 50extern void qla2x00_alloc_fw_dump(scsi_qla_host_t *);
51extern void qla2x00_try_to_stop_firmware(scsi_qla_host_t *);
51 52
52/* 53/*
53 * Global Data in qla_os.c source file. 54 * Global Data in qla_os.c source file.
@@ -60,7 +61,8 @@ extern int ql2xplogiabsentdevice;
60extern int ql2xloginretrycount; 61extern int ql2xloginretrycount;
61extern int ql2xfdmienable; 62extern int ql2xfdmienable;
62extern int ql2xallocfwdump; 63extern int ql2xallocfwdump;
63extern int qla2_extended_error_logging; 64extern int ql2xextended_error_logging;
65extern int ql2xqfullrampup;
64 66
65extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *); 67extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *);
66 68
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 833b93085fd3..08cb5e3fb553 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1644,7 +1644,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1644 * Set host adapter parameters. 1644 * Set host adapter parameters.
1645 */ 1645 */
1646 if (nv->host_p[0] & BIT_7) 1646 if (nv->host_p[0] & BIT_7)
1647 qla2_extended_error_logging = 1; 1647 ql2xextended_error_logging = 1;
1648 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); 1648 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0);
1649 /* Always load RISC code on non ISP2[12]00 chips. */ 1649 /* Always load RISC code on non ISP2[12]00 chips. */
1650 if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) 1650 if (!IS_QLA2100(ha) && !IS_QLA2200(ha))
@@ -3948,3 +3948,24 @@ qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3948fail_fw_integrity: 3948fail_fw_integrity:
3949 return QLA_FUNCTION_FAILED; 3949 return QLA_FUNCTION_FAILED;
3950} 3950}
3951
3952void
3953qla2x00_try_to_stop_firmware(scsi_qla_host_t *ha)
3954{
3955 int ret, retries;
3956
3957 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
3958 return;
3959
3960 ret = qla2x00_stop_firmware(ha);
3961 for (retries = 5; ret != QLA_SUCCESS && retries ; retries--) {
3962 qla2x00_reset_chip(ha);
3963 if (qla2x00_chip_diag(ha) != QLA_SUCCESS)
3964 continue;
3965 if (qla2x00_setup_chip(ha) != QLA_SUCCESS)
3966 continue;
3967 qla_printk(KERN_INFO, ha,
3968 "Attempting retry of stop-firmware command...\n");
3969 ret = qla2x00_stop_firmware(ha);
3970 }
3971}
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 626c7178a434..d3b6df4d55c8 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -6,6 +6,8 @@
6 */ 6 */
7#include "qla_def.h" 7#include "qla_def.h"
8 8
9#include <scsi/scsi_tcq.h>
10
9static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); 11static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
10static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *); 12static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *);
11static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t); 13static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t);
@@ -593,6 +595,67 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
593 } 595 }
594} 596}
595 597
598static void
599qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, void *data)
600{
601 fc_port_t *fcport = data;
602
603 if (fcport->ha->max_q_depth <= sdev->queue_depth)
604 return;
605
606 if (sdev->ordered_tags)
607 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
608 sdev->queue_depth + 1);
609 else
610 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG,
611 sdev->queue_depth + 1);
612
613 fcport->last_ramp_up = jiffies;
614
615 DEBUG2(qla_printk(KERN_INFO, fcport->ha,
616 "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
617 fcport->ha->host_no, sdev->channel, sdev->id, sdev->lun,
618 sdev->queue_depth));
619}
620
621static void
622qla2x00_adjust_sdev_qdepth_down(struct scsi_device *sdev, void *data)
623{
624 fc_port_t *fcport = data;
625
626 if (!scsi_track_queue_full(sdev, sdev->queue_depth - 1))
627 return;
628
629 DEBUG2(qla_printk(KERN_INFO, fcport->ha,
630 "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
631 fcport->ha->host_no, sdev->channel, sdev->id, sdev->lun,
632 sdev->queue_depth));
633}
634
635static inline void
636qla2x00_ramp_up_queue_depth(scsi_qla_host_t *ha, srb_t *sp)
637{
638 fc_port_t *fcport;
639 struct scsi_device *sdev;
640
641 sdev = sp->cmd->device;
642 if (sdev->queue_depth >= ha->max_q_depth)
643 return;
644
645 fcport = sp->fcport;
646 if (time_before(jiffies,
647 fcport->last_ramp_up + ql2xqfullrampup * HZ))
648 return;
649 if (time_before(jiffies,
650 fcport->last_queue_full + ql2xqfullrampup * HZ))
651 return;
652
653 spin_unlock_irq(&ha->hardware_lock);
654 starget_for_each_device(sdev->sdev_target, fcport,
655 qla2x00_adjust_sdev_qdepth_up);
656 spin_lock_irq(&ha->hardware_lock);
657}
658
596/** 659/**
597 * qla2x00_process_completed_request() - Process a Fast Post response. 660 * qla2x00_process_completed_request() - Process a Fast Post response.
598 * @ha: SCSI driver HA context 661 * @ha: SCSI driver HA context
@@ -624,6 +687,8 @@ qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index)
624 687
625 /* Save ISP completion status */ 688 /* Save ISP completion status */
626 sp->cmd->result = DID_OK << 16; 689 sp->cmd->result = DID_OK << 16;
690
691 qla2x00_ramp_up_queue_depth(ha, sp);
627 qla2x00_sp_compl(ha, sp); 692 qla2x00_sp_compl(ha, sp);
628 } else { 693 } else {
629 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n", 694 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
@@ -823,6 +888,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
823 */ 888 */
824 switch (comp_status) { 889 switch (comp_status) {
825 case CS_COMPLETE: 890 case CS_COMPLETE:
891 case CS_QUEUE_FULL:
826 if (scsi_status == 0) { 892 if (scsi_status == 0) {
827 cp->result = DID_OK << 16; 893 cp->result = DID_OK << 16;
828 break; 894 break;
@@ -849,6 +915,20 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
849 } 915 }
850 cp->result = DID_OK << 16 | lscsi_status; 916 cp->result = DID_OK << 16 | lscsi_status;
851 917
918 if (lscsi_status == SAM_STAT_TASK_SET_FULL) {
919 DEBUG2(printk(KERN_INFO
920 "scsi(%ld): QUEUE FULL status detected "
921 "0x%x-0x%x.\n", ha->host_no, comp_status,
922 scsi_status));
923
924 /* Adjust queue depth for all luns on the port. */
925 fcport->last_queue_full = jiffies;
926 spin_unlock_irq(&ha->hardware_lock);
927 starget_for_each_device(cp->device->sdev_target,
928 fcport, qla2x00_adjust_sdev_qdepth_down);
929 spin_lock_irq(&ha->hardware_lock);
930 break;
931 }
852 if (lscsi_status != SS_CHECK_CONDITION) 932 if (lscsi_status != SS_CHECK_CONDITION)
853 break; 933 break;
854 934
@@ -1066,17 +1146,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1066 qla2x00_mark_device_lost(ha, fcport, 1, 1); 1146 qla2x00_mark_device_lost(ha, fcport, 1, 1);
1067 break; 1147 break;
1068 1148
1069 case CS_QUEUE_FULL:
1070 DEBUG2(printk(KERN_INFO
1071 "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n",
1072 ha->host_no, comp_status, scsi_status));
1073
1074 /* SCSI Mid-Layer handles device queue full */
1075
1076 cp->result = DID_OK << 16 | lscsi_status;
1077
1078 break;
1079
1080 default: 1149 default:
1081 DEBUG3(printk("scsi(%ld): Error detected (unknown status) " 1150 DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
1082 "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status)); 1151 "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status));
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 3f20d765563e..208607be78c7 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -61,9 +61,9 @@ MODULE_PARM_DESC(ql2xallocfwdump,
61 "during HBA initialization. Memory allocation requirements " 61 "during HBA initialization. Memory allocation requirements "
62 "vary by ISP type. Default is 1 - allocate memory."); 62 "vary by ISP type. Default is 1 - allocate memory.");
63 63
64int qla2_extended_error_logging; 64int ql2xextended_error_logging;
65module_param(qla2_extended_error_logging, int, S_IRUGO|S_IRUSR); 65module_param(ql2xextended_error_logging, int, S_IRUGO|S_IRUSR);
66MODULE_PARM_DESC(qla2_extended_error_logging, 66MODULE_PARM_DESC(ql2xextended_error_logging,
67 "Option to enable extended error logging, " 67 "Option to enable extended error logging, "
68 "Default is 0 - no logging. 1 - log errors."); 68 "Default is 0 - no logging. 1 - log errors.");
69 69
@@ -77,6 +77,19 @@ MODULE_PARM_DESC(ql2xfdmienable,
77 "Enables FDMI registratons " 77 "Enables FDMI registratons "
78 "Default is 0 - no FDMI. 1 - perfom FDMI."); 78 "Default is 0 - no FDMI. 1 - perfom FDMI.");
79 79
80#define MAX_Q_DEPTH 32
81static int ql2xmaxqdepth = MAX_Q_DEPTH;
82module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
83MODULE_PARM_DESC(ql2xmaxqdepth,
84 "Maximum queue depth to report for target devices.");
85
86int ql2xqfullrampup = 120;
87module_param(ql2xqfullrampup, int, S_IRUGO|S_IWUSR);
88MODULE_PARM_DESC(ql2xqfullrampup,
89 "Number of seconds to wait to begin to ramp-up the queue "
90 "depth for a device after a queue-full condition has been "
91 "detected. Default is 120 seconds.");
92
80/* 93/*
81 * SCSI host template entry points 94 * SCSI host template entry points
82 */ 95 */
@@ -1104,9 +1117,9 @@ qla2xxx_slave_configure(struct scsi_device *sdev)
1104 struct fc_rport *rport = starget_to_rport(sdev->sdev_target); 1117 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
1105 1118
1106 if (sdev->tagged_supported) 1119 if (sdev->tagged_supported)
1107 scsi_activate_tcq(sdev, 32); 1120 scsi_activate_tcq(sdev, ha->max_q_depth);
1108 else 1121 else
1109 scsi_deactivate_tcq(sdev, 32); 1122 scsi_deactivate_tcq(sdev, ha->max_q_depth);
1110 1123
1111 rport->dev_loss_tmo = ha->port_down_retry_count + 5; 1124 rport->dev_loss_tmo = ha->port_down_retry_count + 5;
1112 1125
@@ -1413,6 +1426,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1413 ha->link_data_rate = PORT_SPEED_UNKNOWN; 1426 ha->link_data_rate = PORT_SPEED_UNKNOWN;
1414 ha->optrom_size = OPTROM_SIZE_2300; 1427 ha->optrom_size = OPTROM_SIZE_2300;
1415 1428
1429 ha->max_q_depth = MAX_Q_DEPTH;
1430 if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU)
1431 ha->max_q_depth = ql2xmaxqdepth;
1432
1416 /* Assign ISP specific operations. */ 1433 /* Assign ISP specific operations. */
1417 ha->isp_ops.pci_config = qla2100_pci_config; 1434 ha->isp_ops.pci_config = qla2100_pci_config;
1418 ha->isp_ops.reset_chip = qla2x00_reset_chip; 1435 ha->isp_ops.reset_chip = qla2x00_reset_chip;
@@ -1712,8 +1729,10 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1712 if (ha->eft) 1729 if (ha->eft)
1713 qla2x00_trace_control(ha, TC_DISABLE, 0, 0); 1730 qla2x00_trace_control(ha, TC_DISABLE, 0, 0);
1714 1731
1732 ha->flags.online = 0;
1733
1715 /* Stop currently executing firmware. */ 1734 /* Stop currently executing firmware. */
1716 qla2x00_stop_firmware(ha); 1735 qla2x00_try_to_stop_firmware(ha);
1717 1736
1718 /* turn-off interrupts on the card */ 1737 /* turn-off interrupts on the card */
1719 if (ha->interrupts_on) 1738 if (ha->interrupts_on)
@@ -1721,8 +1740,6 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1721 1740
1722 qla2x00_mem_free(ha); 1741 qla2x00_mem_free(ha);
1723 1742
1724 ha->flags.online = 0;
1725
1726 /* Detach interrupts */ 1743 /* Detach interrupts */
1727 if (ha->host->irq) 1744 if (ha->host->irq)
1728 free_irq(ha->host->irq, ha); 1745 free_irq(ha->host->irq, ha);
@@ -2697,7 +2714,7 @@ qla2x00_module_init(void)
2697 2714
2698 /* Derive version string. */ 2715 /* Derive version string. */
2699 strcpy(qla2x00_version_str, QLA2XXX_VERSION); 2716 strcpy(qla2x00_version_str, QLA2XXX_VERSION);
2700 if (qla2_extended_error_logging) 2717 if (ql2xextended_error_logging)
2701 strcat(qla2x00_version_str, "-debug"); 2718 strcat(qla2x00_version_str, "-debug");
2702 2719
2703 qla2xxx_transport_template = 2720 qla2xxx_transport_template =
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index e57bf45a3393..1fa0bce6b24e 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.01.07-k2" 10#define QLA2XXX_VERSION "8.01.07-k3"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 1 13#define QLA_DRIVER_MINOR_VER 1
diff --git a/drivers/scsi/qla4xxx/Kconfig b/drivers/scsi/qla4xxx/Kconfig
index 08a07f0b8d94..69cbff3f57cf 100644
--- a/drivers/scsi/qla4xxx/Kconfig
+++ b/drivers/scsi/qla4xxx/Kconfig
@@ -1,6 +1,6 @@
1config SCSI_QLA_ISCSI 1config SCSI_QLA_ISCSI
2 tristate "QLogic ISP4XXX host adapter family support" 2 tristate "QLogic ISP4XXX host adapter family support"
3 depends on PCI && SCSI 3 depends on PCI && SCSI && NET
4 select SCSI_ISCSI_ATTRS 4 select SCSI_ISCSI_ATTRS
5 ---help--- 5 ---help---
6 This driver supports the QLogic 40xx (ISP4XXX) iSCSI host 6 This driver supports the QLogic 40xx (ISP4XXX) iSCSI host
diff --git a/drivers/scsi/qla4xxx/ql4_dbg.h b/drivers/scsi/qla4xxx/ql4_dbg.h
index 3e99dcfd5a9f..d861c3b411c8 100644
--- a/drivers/scsi/qla4xxx/ql4_dbg.h
+++ b/drivers/scsi/qla4xxx/ql4_dbg.h
@@ -22,14 +22,14 @@
22#endif 22#endif
23 23
24#if defined(QL_DEBUG_LEVEL_2) 24#if defined(QL_DEBUG_LEVEL_2)
25#define DEBUG2(x) do {if(qla4_extended_error_logging == 2) x;} while (0); 25#define DEBUG2(x) do {if(ql4xextended_error_logging == 2) x;} while (0);
26#define DEBUG2_3(x) do {x;} while (0); 26#define DEBUG2_3(x) do {x;} while (0);
27#else /* */ 27#else /* */
28#define DEBUG2(x) do {} while (0); 28#define DEBUG2(x) do {} while (0);
29#endif /* */ 29#endif /* */
30 30
31#if defined(QL_DEBUG_LEVEL_3) 31#if defined(QL_DEBUG_LEVEL_3)
32#define DEBUG3(x) do {if(qla4_extended_error_logging == 3) x;} while (0); 32#define DEBUG3(x) do {if(ql4xextended_error_logging == 3) x;} while (0);
33#else /* */ 33#else /* */
34#define DEBUG3(x) do {} while (0); 34#define DEBUG3(x) do {} while (0);
35#if !defined(QL_DEBUG_LEVEL_2) 35#if !defined(QL_DEBUG_LEVEL_2)
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 2c803edf2de8..1b221ff0f6f7 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -72,7 +72,7 @@ int qla4xxx_reinitialize_ddb_list(struct scsi_qla_host * ha);
72int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha, 72int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha,
73 uint32_t fw_ddb_index, uint32_t state); 73 uint32_t fw_ddb_index, uint32_t state);
74 74
75extern int qla4_extended_error_logging; 75extern int ql4xextended_error_logging;
76extern int ql4xdiscoverywait; 76extern int ql4xdiscoverywait;
77extern int ql4xdontresethba; 77extern int ql4xdontresethba;
78#endif /* _QLA4x_GBL_H */ 78#endif /* _QLA4x_GBL_H */
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index ef82399c0858..b721dc5dd711 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -701,7 +701,7 @@ void qla4xxx_get_conn_event_log(struct scsi_qla_host * ha)
701 DEBUG3(printk("scsi%ld: Connection Event Log Dump (%d entries):\n", 701 DEBUG3(printk("scsi%ld: Connection Event Log Dump (%d entries):\n",
702 ha->host_no, num_valid_entries)); 702 ha->host_no, num_valid_entries));
703 703
704 if (qla4_extended_error_logging == 3) { 704 if (ql4xextended_error_logging == 3) {
705 if (oldest_entry == 0) { 705 if (oldest_entry == 0) {
706 /* Circular Buffer has not wrapped around */ 706 /* Circular Buffer has not wrapped around */
707 for (i=0; i < num_valid_entries; i++) { 707 for (i=0; i < num_valid_entries; i++) {
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 178fcddcfd81..5b8db6109536 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -34,9 +34,9 @@ MODULE_PARM_DESC(ql4xdontresethba,
34 " default it will reset hba :0" 34 " default it will reset hba :0"
35 " set to 1 to avoid resetting HBA"); 35 " set to 1 to avoid resetting HBA");
36 36
37int qla4_extended_error_logging = 0; /* 0 = off, 1 = log errors */ 37int ql4xextended_error_logging = 0; /* 0 = off, 1 = log errors */
38module_param(qla4_extended_error_logging, int, S_IRUGO | S_IRUSR); 38module_param(ql4xextended_error_logging, int, S_IRUGO | S_IRUSR);
39MODULE_PARM_DESC(qla4_extended_error_logging, 39MODULE_PARM_DESC(ql4xextended_error_logging,
40 "Option to enable extended error logging, " 40 "Option to enable extended error logging, "
41 "Default is 0 - no logging, 1 - debug logging"); 41 "Default is 0 - no logging, 1 - debug logging");
42 42
@@ -1714,7 +1714,7 @@ static int __init qla4xxx_module_init(void)
1714 1714
1715 /* Derive version string. */ 1715 /* Derive version string. */
1716 strcpy(qla4xxx_version_str, QLA4XXX_DRIVER_VERSION); 1716 strcpy(qla4xxx_version_str, QLA4XXX_DRIVER_VERSION);
1717 if (qla4_extended_error_logging) 1717 if (ql4xextended_error_logging)
1718 strcat(qla4xxx_version_str, "-debug"); 1718 strcat(qla4xxx_version_str, "-debug");
1719 1719
1720 qla4xxx_scsi_transport = 1720 qla4xxx_scsi_transport =
@@ -1724,13 +1724,13 @@ static int __init qla4xxx_module_init(void)
1724 goto release_srb_cache; 1724 goto release_srb_cache;
1725 } 1725 }
1726 1726
1727 printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
1728 ret = pci_register_driver(&qla4xxx_pci_driver); 1727 ret = pci_register_driver(&qla4xxx_pci_driver);
1729 if (ret) 1728 if (ret)
1730 goto unregister_transport; 1729 goto unregister_transport;
1731 1730
1732 printk(KERN_INFO "QLogic iSCSI HBA Driver\n"); 1731 printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
1733 return 0; 1732 return 0;
1733
1734unregister_transport: 1734unregister_transport:
1735 iscsi_unregister_transport(&qla4xxx_iscsi_transport); 1735 iscsi_unregister_transport(&qla4xxx_iscsi_transport);
1736release_srb_cache: 1736release_srb_cache:
diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index e0725353c99c..2e7db18f5aef 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -209,7 +209,7 @@ static int ql_wai(struct qlogicfas408_priv *priv)
209 * caller must hold host lock 209 * caller must hold host lock
210 */ 210 */
211 211
212static void ql_icmd(Scsi_Cmnd * cmd) 212static void ql_icmd(struct scsi_cmnd *cmd)
213{ 213{
214 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 214 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
215 int qbase = priv->qbase; 215 int qbase = priv->qbase;
@@ -256,7 +256,7 @@ static void ql_icmd(Scsi_Cmnd * cmd)
256 * Process scsi command - usually after interrupt 256 * Process scsi command - usually after interrupt
257 */ 257 */
258 258
259static unsigned int ql_pcmd(Scsi_Cmnd * cmd) 259static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
260{ 260{
261 unsigned int i, j; 261 unsigned int i, j;
262 unsigned long k; 262 unsigned long k;
@@ -407,7 +407,7 @@ static unsigned int ql_pcmd(Scsi_Cmnd * cmd)
407 407
408static void ql_ihandl(void *dev_id) 408static void ql_ihandl(void *dev_id)
409{ 409{
410 Scsi_Cmnd *icmd; 410 struct scsi_cmnd *icmd;
411 struct Scsi_Host *host = dev_id; 411 struct Scsi_Host *host = dev_id;
412 struct qlogicfas408_priv *priv = get_priv_by_host(host); 412 struct qlogicfas408_priv *priv = get_priv_by_host(host);
413 int qbase = priv->qbase; 413 int qbase = priv->qbase;
@@ -447,7 +447,8 @@ irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id)
447 * Queued command 447 * Queued command
448 */ 448 */
449 449
450int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) 450int qlogicfas408_queuecommand(struct scsi_cmnd *cmd,
451 void (*done) (struct scsi_cmnd *))
451{ 452{
452 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 453 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
453 if (scmd_id(cmd) == priv->qinitid) { 454 if (scmd_id(cmd) == priv->qinitid) {
@@ -470,9 +471,8 @@ int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
470 * Return bios parameters 471 * Return bios parameters
471 */ 472 */
472 473
473int qlogicfas408_biosparam(struct scsi_device * disk, 474int qlogicfas408_biosparam(struct scsi_device *disk, struct block_device *dev,
474 struct block_device *dev, 475 sector_t capacity, int ip[])
475 sector_t capacity, int ip[])
476{ 476{
477/* This should mimic the DOS Qlogic driver's behavior exactly */ 477/* This should mimic the DOS Qlogic driver's behavior exactly */
478 ip[0] = 0x40; 478 ip[0] = 0x40;
@@ -494,7 +494,7 @@ int qlogicfas408_biosparam(struct scsi_device * disk,
494 * Abort a command in progress 494 * Abort a command in progress
495 */ 495 */
496 496
497int qlogicfas408_abort(Scsi_Cmnd * cmd) 497int qlogicfas408_abort(struct scsi_cmnd *cmd)
498{ 498{
499 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 499 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
500 priv->qabort = 1; 500 priv->qabort = 1;
@@ -508,7 +508,7 @@ int qlogicfas408_abort(Scsi_Cmnd * cmd)
508 * the PCMCIA qlogic_stub code. This wants fixing 508 * the PCMCIA qlogic_stub code. This wants fixing
509 */ 509 */
510 510
511int qlogicfas408_bus_reset(Scsi_Cmnd * cmd) 511int qlogicfas408_bus_reset(struct scsi_cmnd *cmd)
512{ 512{
513 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 513 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
514 unsigned long flags; 514 unsigned long flags;
diff --git a/drivers/scsi/qlogicfas408.h b/drivers/scsi/qlogicfas408.h
index 8fd5555c75b1..260626427a32 100644
--- a/drivers/scsi/qlogicfas408.h
+++ b/drivers/scsi/qlogicfas408.h
@@ -75,15 +75,15 @@
75/*----------------------------------------------------------------*/ 75/*----------------------------------------------------------------*/
76 76
77struct qlogicfas408_priv { 77struct qlogicfas408_priv {
78 int qbase; /* Port */ 78 int qbase; /* Port */
79 int qinitid; /* initiator ID */ 79 int qinitid; /* initiator ID */
80 int qabort; /* Flag to cause an abort */ 80 int qabort; /* Flag to cause an abort */
81 int qlirq; /* IRQ being used */ 81 int qlirq; /* IRQ being used */
82 int int_type; /* type of irq, 2 for ISA board, 0 for PCMCIA */ 82 int int_type; /* type of irq, 2 for ISA board, 0 for PCMCIA */
83 char qinfo[80]; /* description */ 83 char qinfo[80]; /* description */
84 Scsi_Cmnd *qlcmd; /* current command being processed */ 84 struct scsi_cmnd *qlcmd; /* current command being processed */
85 struct Scsi_Host *shost; /* pointer back to host */ 85 struct Scsi_Host *shost; /* pointer back to host */
86 struct qlogicfas408_priv *next; /* next private struct */ 86 struct qlogicfas408_priv *next; /* next private struct */
87}; 87};
88 88
89/* The qlogic card uses two register maps - These macros select which one */ 89/* The qlogic card uses two register maps - These macros select which one */
@@ -103,12 +103,13 @@ struct qlogicfas408_priv {
103#define get_priv_by_host(x) (struct qlogicfas408_priv *)&((x)->hostdata[0]) 103#define get_priv_by_host(x) (struct qlogicfas408_priv *)&((x)->hostdata[0])
104 104
105irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id); 105irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id);
106int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)); 106int qlogicfas408_queuecommand(struct scsi_cmnd * cmd,
107 void (*done) (struct scsi_cmnd *));
107int qlogicfas408_biosparam(struct scsi_device * disk, 108int qlogicfas408_biosparam(struct scsi_device * disk,
108 struct block_device *dev, 109 struct block_device *dev,
109 sector_t capacity, int ip[]); 110 sector_t capacity, int ip[]);
110int qlogicfas408_abort(Scsi_Cmnd * cmd); 111int qlogicfas408_abort(struct scsi_cmnd * cmd);
111int qlogicfas408_bus_reset(Scsi_Cmnd * cmd); 112int qlogicfas408_bus_reset(struct scsi_cmnd * cmd);
112const char *qlogicfas408_info(struct Scsi_Host *host); 113const char *qlogicfas408_info(struct Scsi_Host *host);
113int qlogicfas408_get_chip_type(int qbase, int int_type); 114int qlogicfas408_get_chip_type(int qbase, int int_type);
114void qlogicfas408_setup(int qbase, int id, int int_type); 115void qlogicfas408_setup(int qbase, int id, int int_type);
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 9c0f35820e3e..30ee3d72c021 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -52,7 +52,7 @@
52#include "scsi_debug.h" 52#include "scsi_debug.h"
53 53
54#define SCSI_DEBUG_VERSION "1.80" 54#define SCSI_DEBUG_VERSION "1.80"
55static const char * scsi_debug_version_date = "20060914"; 55static const char * scsi_debug_version_date = "20061018";
56 56
57/* Additional Sense Code (ASC) used */ 57/* Additional Sense Code (ASC) used */
58#define NO_ADDITIONAL_SENSE 0x0 58#define NO_ADDITIONAL_SENSE 0x0
@@ -254,6 +254,8 @@ static int resp_requests(struct scsi_cmnd * SCpnt,
254 struct sdebug_dev_info * devip); 254 struct sdebug_dev_info * devip);
255static int resp_start_stop(struct scsi_cmnd * scp, 255static int resp_start_stop(struct scsi_cmnd * scp,
256 struct sdebug_dev_info * devip); 256 struct sdebug_dev_info * devip);
257static int resp_report_tgtpgs(struct scsi_cmnd * scp,
258 struct sdebug_dev_info * devip);
257static int resp_readcap(struct scsi_cmnd * SCpnt, 259static int resp_readcap(struct scsi_cmnd * SCpnt,
258 struct sdebug_dev_info * devip); 260 struct sdebug_dev_info * devip);
259static int resp_readcap16(struct scsi_cmnd * SCpnt, 261static int resp_readcap16(struct scsi_cmnd * SCpnt,
@@ -287,9 +289,9 @@ static void __init sdebug_build_parts(unsigned char * ramp);
287static void __init init_all_queued(void); 289static void __init init_all_queued(void);
288static void stop_all_queued(void); 290static void stop_all_queued(void);
289static int stop_queued_cmnd(struct scsi_cmnd * cmnd); 291static int stop_queued_cmnd(struct scsi_cmnd * cmnd);
290static int inquiry_evpd_83(unsigned char * arr, int target_dev_id, 292static int inquiry_evpd_83(unsigned char * arr, int port_group_id,
291 int dev_id_num, const char * dev_id_str, 293 int target_dev_id, int dev_id_num,
292 int dev_id_str_len); 294 const char * dev_id_str, int dev_id_str_len);
293static int inquiry_evpd_88(unsigned char * arr, int target_dev_id); 295static int inquiry_evpd_88(unsigned char * arr, int target_dev_id);
294static int do_create_driverfs_files(void); 296static int do_create_driverfs_files(void);
295static void do_remove_driverfs_files(void); 297static void do_remove_driverfs_files(void);
@@ -422,6 +424,15 @@ int scsi_debug_queuecommand(struct scsi_cmnd * SCpnt, done_funct_t done)
422 } 424 }
423 errsts = resp_readcap16(SCpnt, devip); 425 errsts = resp_readcap16(SCpnt, devip);
424 break; 426 break;
427 case MAINTENANCE_IN:
428 if (MI_REPORT_TARGET_PGS != cmd[1]) {
429 mk_sense_buffer(devip, ILLEGAL_REQUEST,
430 INVALID_OPCODE, 0);
431 errsts = check_condition_result;
432 break;
433 }
434 errsts = resp_report_tgtpgs(SCpnt, devip);
435 break;
425 case READ_16: 436 case READ_16:
426 case READ_12: 437 case READ_12:
427 case READ_10: 438 case READ_10:
@@ -665,8 +676,9 @@ static const char * inq_vendor_id = "Linux ";
665static const char * inq_product_id = "scsi_debug "; 676static const char * inq_product_id = "scsi_debug ";
666static const char * inq_product_rev = "0004"; 677static const char * inq_product_rev = "0004";
667 678
668static int inquiry_evpd_83(unsigned char * arr, int target_dev_id, 679static int inquiry_evpd_83(unsigned char * arr, int port_group_id,
669 int dev_id_num, const char * dev_id_str, 680 int target_dev_id, int dev_id_num,
681 const char * dev_id_str,
670 int dev_id_str_len) 682 int dev_id_str_len)
671{ 683{
672 int num, port_a; 684 int num, port_a;
@@ -720,6 +732,15 @@ static int inquiry_evpd_83(unsigned char * arr, int target_dev_id,
720 arr[num++] = (port_a >> 16) & 0xff; 732 arr[num++] = (port_a >> 16) & 0xff;
721 arr[num++] = (port_a >> 8) & 0xff; 733 arr[num++] = (port_a >> 8) & 0xff;
722 arr[num++] = port_a & 0xff; 734 arr[num++] = port_a & 0xff;
735 /* NAA-5, Target port group identifier */
736 arr[num++] = 0x61; /* proto=sas, binary */
737 arr[num++] = 0x95; /* piv=1, target port group id */
738 arr[num++] = 0x0;
739 arr[num++] = 0x4;
740 arr[num++] = 0;
741 arr[num++] = 0;
742 arr[num++] = (port_group_id >> 8) & 0xff;
743 arr[num++] = port_group_id & 0xff;
723 /* NAA-5, Target device identifier */ 744 /* NAA-5, Target device identifier */
724 arr[num++] = 0x61; /* proto=sas, binary */ 745 arr[num++] = 0x61; /* proto=sas, binary */
725 arr[num++] = 0xa3; /* piv=1, target device, naa */ 746 arr[num++] = 0xa3; /* piv=1, target device, naa */
@@ -928,12 +949,12 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
928 struct sdebug_dev_info * devip) 949 struct sdebug_dev_info * devip)
929{ 950{
930 unsigned char pq_pdt; 951 unsigned char pq_pdt;
931 unsigned char arr[SDEBUG_MAX_INQ_ARR_SZ]; 952 unsigned char * arr;
932 unsigned char *cmd = (unsigned char *)scp->cmnd; 953 unsigned char *cmd = (unsigned char *)scp->cmnd;
933 int alloc_len, n; 954 int alloc_len, n, ret;
934 955
935 alloc_len = (cmd[3] << 8) + cmd[4]; 956 alloc_len = (cmd[3] << 8) + cmd[4];
936 memset(arr, 0, SDEBUG_MAX_INQ_ARR_SZ); 957 arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_KERNEL);
937 if (devip->wlun) 958 if (devip->wlun)
938 pq_pdt = 0x1e; /* present, wlun */ 959 pq_pdt = 0x1e; /* present, wlun */
939 else if (scsi_debug_no_lun_0 && (0 == devip->lun)) 960 else if (scsi_debug_no_lun_0 && (0 == devip->lun))
@@ -944,12 +965,15 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
944 if (0x2 & cmd[1]) { /* CMDDT bit set */ 965 if (0x2 & cmd[1]) { /* CMDDT bit set */
945 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 966 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB,
946 0); 967 0);
968 kfree(arr);
947 return check_condition_result; 969 return check_condition_result;
948 } else if (0x1 & cmd[1]) { /* EVPD bit set */ 970 } else if (0x1 & cmd[1]) { /* EVPD bit set */
949 int lu_id_num, target_dev_id, len; 971 int lu_id_num, port_group_id, target_dev_id, len;
950 char lu_id_str[6]; 972 char lu_id_str[6];
951 int host_no = devip->sdbg_host->shost->host_no; 973 int host_no = devip->sdbg_host->shost->host_no;
952 974
975 port_group_id = (((host_no + 1) & 0x7f) << 8) +
976 (devip->channel & 0x7f);
953 if (0 == scsi_debug_vpd_use_hostno) 977 if (0 == scsi_debug_vpd_use_hostno)
954 host_no = 0; 978 host_no = 0;
955 lu_id_num = devip->wlun ? -1 : (((host_no + 1) * 2000) + 979 lu_id_num = devip->wlun ? -1 : (((host_no + 1) * 2000) +
@@ -977,8 +1001,9 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
977 memcpy(&arr[4], lu_id_str, len); 1001 memcpy(&arr[4], lu_id_str, len);
978 } else if (0x83 == cmd[2]) { /* device identification */ 1002 } else if (0x83 == cmd[2]) { /* device identification */
979 arr[1] = cmd[2]; /*sanity */ 1003 arr[1] = cmd[2]; /*sanity */
980 arr[3] = inquiry_evpd_83(&arr[4], target_dev_id, 1004 arr[3] = inquiry_evpd_83(&arr[4], port_group_id,
981 lu_id_num, lu_id_str, len); 1005 target_dev_id, lu_id_num,
1006 lu_id_str, len);
982 } else if (0x84 == cmd[2]) { /* Software interface ident. */ 1007 } else if (0x84 == cmd[2]) { /* Software interface ident. */
983 arr[1] = cmd[2]; /*sanity */ 1008 arr[1] = cmd[2]; /*sanity */
984 arr[3] = inquiry_evpd_84(&arr[4]); 1009 arr[3] = inquiry_evpd_84(&arr[4]);
@@ -1012,17 +1037,22 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
1012 /* Illegal request, invalid field in cdb */ 1037 /* Illegal request, invalid field in cdb */
1013 mk_sense_buffer(devip, ILLEGAL_REQUEST, 1038 mk_sense_buffer(devip, ILLEGAL_REQUEST,
1014 INVALID_FIELD_IN_CDB, 0); 1039 INVALID_FIELD_IN_CDB, 0);
1040 kfree(arr);
1015 return check_condition_result; 1041 return check_condition_result;
1016 } 1042 }
1017 len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len); 1043 len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len);
1018 return fill_from_dev_buffer(scp, arr, 1044 ret = fill_from_dev_buffer(scp, arr,
1019 min(len, SDEBUG_MAX_INQ_ARR_SZ)); 1045 min(len, SDEBUG_MAX_INQ_ARR_SZ));
1046 kfree(arr);
1047 return ret;
1020 } 1048 }
1021 /* drops through here for a standard inquiry */ 1049 /* drops through here for a standard inquiry */
1022 arr[1] = DEV_REMOVEABLE(target) ? 0x80 : 0; /* Removable disk */ 1050 arr[1] = DEV_REMOVEABLE(target) ? 0x80 : 0; /* Removable disk */
1023 arr[2] = scsi_debug_scsi_level; 1051 arr[2] = scsi_debug_scsi_level;
1024 arr[3] = 2; /* response_data_format==2 */ 1052 arr[3] = 2; /* response_data_format==2 */
1025 arr[4] = SDEBUG_LONG_INQ_SZ - 5; 1053 arr[4] = SDEBUG_LONG_INQ_SZ - 5;
1054 if (0 == scsi_debug_vpd_use_hostno)
1055 arr[5] = 0x10; /* claim: implicit TGPS */
1026 arr[6] = 0x10; /* claim: MultiP */ 1056 arr[6] = 0x10; /* claim: MultiP */
1027 /* arr[6] |= 0x40; ... claim: EncServ (enclosure services) */ 1057 /* arr[6] |= 0x40; ... claim: EncServ (enclosure services) */
1028 arr[7] = 0xa; /* claim: LINKED + CMDQUE */ 1058 arr[7] = 0xa; /* claim: LINKED + CMDQUE */
@@ -1039,8 +1069,10 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
1039 arr[n++] = 0x3; arr[n++] = 0x60; /* SSC-2 no version */ 1069 arr[n++] = 0x3; arr[n++] = 0x60; /* SSC-2 no version */
1040 } 1070 }
1041 arr[n++] = 0xc; arr[n++] = 0xf; /* SAS-1.1 rev 10 */ 1071 arr[n++] = 0xc; arr[n++] = 0xf; /* SAS-1.1 rev 10 */
1042 return fill_from_dev_buffer(scp, arr, 1072 ret = fill_from_dev_buffer(scp, arr,
1043 min(alloc_len, SDEBUG_LONG_INQ_SZ)); 1073 min(alloc_len, SDEBUG_LONG_INQ_SZ));
1074 kfree(arr);
1075 return ret;
1044} 1076}
1045 1077
1046static int resp_requests(struct scsi_cmnd * scp, 1078static int resp_requests(struct scsi_cmnd * scp,
@@ -1171,6 +1203,87 @@ static int resp_readcap16(struct scsi_cmnd * scp,
1171 min(alloc_len, SDEBUG_READCAP16_ARR_SZ)); 1203 min(alloc_len, SDEBUG_READCAP16_ARR_SZ));
1172} 1204}
1173 1205
1206#define SDEBUG_MAX_TGTPGS_ARR_SZ 1412
1207
1208static int resp_report_tgtpgs(struct scsi_cmnd * scp,
1209 struct sdebug_dev_info * devip)
1210{
1211 unsigned char *cmd = (unsigned char *)scp->cmnd;
1212 unsigned char * arr;
1213 int host_no = devip->sdbg_host->shost->host_no;
1214 int n, ret, alen, rlen;
1215 int port_group_a, port_group_b, port_a, port_b;
1216
1217 alen = ((cmd[6] << 24) + (cmd[7] << 16) + (cmd[8] << 8)
1218 + cmd[9]);
1219
1220 arr = kzalloc(SDEBUG_MAX_TGTPGS_ARR_SZ, GFP_KERNEL);
1221 /*
1222 * EVPD page 0x88 states we have two ports, one
1223 * real and a fake port with no device connected.
1224 * So we create two port groups with one port each
1225 * and set the group with port B to unavailable.
1226 */
1227 port_a = 0x1; /* relative port A */
1228 port_b = 0x2; /* relative port B */
1229 port_group_a = (((host_no + 1) & 0x7f) << 8) +
1230 (devip->channel & 0x7f);
1231 port_group_b = (((host_no + 1) & 0x7f) << 8) +
1232 (devip->channel & 0x7f) + 0x80;
1233
1234 /*
1235 * The asymmetric access state is cycled according to the host_id.
1236 */
1237 n = 4;
1238 if (0 == scsi_debug_vpd_use_hostno) {
1239 arr[n++] = host_no % 3; /* Asymm access state */
1240 arr[n++] = 0x0F; /* claim: all states are supported */
1241 } else {
1242 arr[n++] = 0x0; /* Active/Optimized path */
1243 arr[n++] = 0x01; /* claim: only support active/optimized paths */
1244 }
1245 arr[n++] = (port_group_a >> 8) & 0xff;
1246 arr[n++] = port_group_a & 0xff;
1247 arr[n++] = 0; /* Reserved */
1248 arr[n++] = 0; /* Status code */
1249 arr[n++] = 0; /* Vendor unique */
1250 arr[n++] = 0x1; /* One port per group */
1251 arr[n++] = 0; /* Reserved */
1252 arr[n++] = 0; /* Reserved */
1253 arr[n++] = (port_a >> 8) & 0xff;
1254 arr[n++] = port_a & 0xff;
1255 arr[n++] = 3; /* Port unavailable */
1256 arr[n++] = 0x08; /* claim: only unavailalbe paths are supported */
1257 arr[n++] = (port_group_b >> 8) & 0xff;
1258 arr[n++] = port_group_b & 0xff;
1259 arr[n++] = 0; /* Reserved */
1260 arr[n++] = 0; /* Status code */
1261 arr[n++] = 0; /* Vendor unique */
1262 arr[n++] = 0x1; /* One port per group */
1263 arr[n++] = 0; /* Reserved */
1264 arr[n++] = 0; /* Reserved */
1265 arr[n++] = (port_b >> 8) & 0xff;
1266 arr[n++] = port_b & 0xff;
1267
1268 rlen = n - 4;
1269 arr[0] = (rlen >> 24) & 0xff;
1270 arr[1] = (rlen >> 16) & 0xff;
1271 arr[2] = (rlen >> 8) & 0xff;
1272 arr[3] = rlen & 0xff;
1273
1274 /*
1275 * Return the smallest value of either
1276 * - The allocated length
1277 * - The constructed command length
1278 * - The maximum array size
1279 */
1280 rlen = min(alen,n);
1281 ret = fill_from_dev_buffer(scp, arr,
1282 min(rlen, SDEBUG_MAX_TGTPGS_ARR_SZ));
1283 kfree(arr);
1284 return ret;
1285}
1286
1174/* <<Following mode page info copied from ST318451LW>> */ 1287/* <<Following mode page info copied from ST318451LW>> */
1175 1288
1176static int resp_err_recov_pg(unsigned char * p, int pcontrol, int target) 1289static int resp_err_recov_pg(unsigned char * p, int pcontrol, int target)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 743f67ed7640..3ac4890ce086 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -410,6 +410,7 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
410 goto free_req; 410 goto free_req;
411 411
412 req->cmd_len = cmd_len; 412 req->cmd_len = cmd_len;
413 memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
413 memcpy(req->cmd, cmd, req->cmd_len); 414 memcpy(req->cmd, cmd, req->cmd_len);
414 req->sense = sioc->sense; 415 req->sense = sioc->sense;
415 req->sense_len = 0; 416 req->sense_len = 0;
@@ -1084,7 +1085,7 @@ static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
1084{ 1085{
1085 struct request *req = cmd->request; 1086 struct request *req = cmd->request;
1086 1087
1087 BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); 1088 BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
1088 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1089 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
1089 cmd->cmd_len = req->cmd_len; 1090 cmd->cmd_len = req->cmd_len;
1090 if (!req->data_len) 1091 if (!req->data_len)
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index fd9e281c3bfe..94a274645f6f 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -631,12 +631,22 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
631 * scanning run at their own risk, or supply a user level program 631 * scanning run at their own risk, or supply a user level program
632 * that can correctly scan. 632 * that can correctly scan.
633 */ 633 */
634 sdev->inquiry = kmalloc(sdev->inquiry_len, GFP_ATOMIC); 634
635 if (sdev->inquiry == NULL) { 635 /*
636 * Copy at least 36 bytes of INQUIRY data, so that we don't
637 * dereference unallocated memory when accessing the Vendor,
638 * Product, and Revision strings. Badly behaved devices may set
639 * the INQUIRY Additional Length byte to a small value, indicating
640 * these strings are invalid, but often they contain plausible data
641 * nonetheless. It doesn't matter if the device sent < 36 bytes
642 * total, since scsi_probe_lun() initializes inq_result with 0s.
643 */
644 sdev->inquiry = kmemdup(inq_result,
645 max_t(size_t, sdev->inquiry_len, 36),
646 GFP_ATOMIC);
647 if (sdev->inquiry == NULL)
636 return SCSI_SCAN_NO_RESPONSE; 648 return SCSI_SCAN_NO_RESPONSE;
637 }
638 649
639 memcpy(sdev->inquiry, inq_result, sdev->inquiry_len);
640 sdev->vendor = (char *) (sdev->inquiry + 8); 650 sdev->vendor = (char *) (sdev->inquiry + 8);
641 sdev->model = (char *) (sdev->inquiry + 16); 651 sdev->model = (char *) (sdev->inquiry + 16);
642 sdev->rev = (char *) (sdev->inquiry + 32); 652 sdev->rev = (char *) (sdev->inquiry + 32);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e7fe565b96de..e1a91665d1c2 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -192,6 +192,7 @@ static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost
192shost_rd_attr(unique_id, "%u\n"); 192shost_rd_attr(unique_id, "%u\n");
193shost_rd_attr(host_busy, "%hu\n"); 193shost_rd_attr(host_busy, "%hu\n");
194shost_rd_attr(cmd_per_lun, "%hd\n"); 194shost_rd_attr(cmd_per_lun, "%hd\n");
195shost_rd_attr(can_queue, "%hd\n");
195shost_rd_attr(sg_tablesize, "%hu\n"); 196shost_rd_attr(sg_tablesize, "%hu\n");
196shost_rd_attr(unchecked_isa_dma, "%d\n"); 197shost_rd_attr(unchecked_isa_dma, "%d\n");
197shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); 198shost_rd_attr2(proc_name, hostt->proc_name, "%s\n");
@@ -200,6 +201,7 @@ static struct class_device_attribute *scsi_sysfs_shost_attrs[] = {
200 &class_device_attr_unique_id, 201 &class_device_attr_unique_id,
201 &class_device_attr_host_busy, 202 &class_device_attr_host_busy,
202 &class_device_attr_cmd_per_lun, 203 &class_device_attr_cmd_per_lun,
204 &class_device_attr_can_queue,
203 &class_device_attr_sg_tablesize, 205 &class_device_attr_sg_tablesize,
204 &class_device_attr_unchecked_isa_dma, 206 &class_device_attr_unchecked_isa_dma,
205 &class_device_attr_proc_name, 207 &class_device_attr_proc_name,
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 7b0019cccce3..9b25124a989e 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -21,7 +21,6 @@
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */ 22 */
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/mempool.h>
25#include <linux/mutex.h> 24#include <linux/mutex.h>
26#include <net/tcp.h> 25#include <net/tcp.h>
27#include <scsi/scsi.h> 26#include <scsi/scsi.h>
@@ -34,7 +33,7 @@
34#define ISCSI_SESSION_ATTRS 11 33#define ISCSI_SESSION_ATTRS 11
35#define ISCSI_CONN_ATTRS 11 34#define ISCSI_CONN_ATTRS 11
36#define ISCSI_HOST_ATTRS 0 35#define ISCSI_HOST_ATTRS 0
37#define ISCSI_TRANSPORT_VERSION "2.0-685" 36#define ISCSI_TRANSPORT_VERSION "2.0-724"
38 37
39struct iscsi_internal { 38struct iscsi_internal {
40 int daemon_pid; 39 int daemon_pid;
@@ -149,30 +148,6 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
149static struct sock *nls; 148static struct sock *nls;
150static DEFINE_MUTEX(rx_queue_mutex); 149static DEFINE_MUTEX(rx_queue_mutex);
151 150
152struct mempool_zone {
153 mempool_t *pool;
154 atomic_t allocated;
155 int size;
156 int hiwat;
157 struct list_head freequeue;
158 spinlock_t freelock;
159};
160
161static struct mempool_zone *z_reply;
162
163/*
164 * Z_MAX_* - actual mempool size allocated at the mempool_zone_init() time
165 * Z_HIWAT_* - zone's high watermark when if_error bit will be set to -ENOMEM
166 * so daemon will notice OOM on NETLINK tranposrt level and will
167 * be able to predict or change operational behavior
168 */
169#define Z_MAX_REPLY 8
170#define Z_HIWAT_REPLY 6
171#define Z_MAX_PDU 8
172#define Z_HIWAT_PDU 6
173#define Z_MAX_ERROR 16
174#define Z_HIWAT_ERROR 12
175
176static LIST_HEAD(sesslist); 151static LIST_HEAD(sesslist);
177static DEFINE_SPINLOCK(sesslock); 152static DEFINE_SPINLOCK(sesslock);
178static LIST_HEAD(connlist); 153static LIST_HEAD(connlist);
@@ -414,59 +389,11 @@ int iscsi_destroy_session(struct iscsi_cls_session *session)
414} 389}
415EXPORT_SYMBOL_GPL(iscsi_destroy_session); 390EXPORT_SYMBOL_GPL(iscsi_destroy_session);
416 391
417static void mempool_zone_destroy(struct mempool_zone *zp)
418{
419 mempool_destroy(zp->pool);
420 kfree(zp);
421}
422
423static void*
424mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data)
425{
426 struct mempool_zone *zone = pool_data;
427
428 return alloc_skb(zone->size, gfp_mask);
429}
430
431static void
432mempool_zone_free_skb(void *element, void *pool_data)
433{
434 kfree_skb(element);
435}
436
437static struct mempool_zone *
438mempool_zone_init(unsigned max, unsigned size, unsigned hiwat)
439{
440 struct mempool_zone *zp;
441
442 zp = kzalloc(sizeof(*zp), GFP_KERNEL);
443 if (!zp)
444 return NULL;
445
446 zp->size = size;
447 zp->hiwat = hiwat;
448 INIT_LIST_HEAD(&zp->freequeue);
449 spin_lock_init(&zp->freelock);
450 atomic_set(&zp->allocated, 0);
451
452 zp->pool = mempool_create(max, mempool_zone_alloc_skb,
453 mempool_zone_free_skb, zp);
454 if (!zp->pool) {
455 kfree(zp);
456 return NULL;
457 }
458
459 return zp;
460}
461
462static void iscsi_conn_release(struct device *dev) 392static void iscsi_conn_release(struct device *dev)
463{ 393{
464 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev); 394 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev);
465 struct device *parent = conn->dev.parent; 395 struct device *parent = conn->dev.parent;
466 396
467 mempool_zone_destroy(conn->z_pdu);
468 mempool_zone_destroy(conn->z_error);
469
470 kfree(conn); 397 kfree(conn);
471 put_device(parent); 398 put_device(parent);
472} 399}
@@ -476,31 +403,6 @@ static int iscsi_is_conn_dev(const struct device *dev)
476 return dev->release == iscsi_conn_release; 403 return dev->release == iscsi_conn_release;
477} 404}
478 405
479static int iscsi_create_event_pools(struct iscsi_cls_conn *conn)
480{
481 conn->z_pdu = mempool_zone_init(Z_MAX_PDU,
482 NLMSG_SPACE(sizeof(struct iscsi_uevent) +
483 sizeof(struct iscsi_hdr) +
484 DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH),
485 Z_HIWAT_PDU);
486 if (!conn->z_pdu) {
487 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "
488 "pdu zone for new conn\n");
489 return -ENOMEM;
490 }
491
492 conn->z_error = mempool_zone_init(Z_MAX_ERROR,
493 NLMSG_SPACE(sizeof(struct iscsi_uevent)),
494 Z_HIWAT_ERROR);
495 if (!conn->z_error) {
496 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "
497 "error zone for new conn\n");
498 mempool_zone_destroy(conn->z_pdu);
499 return -ENOMEM;
500 }
501 return 0;
502}
503
504/** 406/**
505 * iscsi_create_conn - create iscsi class connection 407 * iscsi_create_conn - create iscsi class connection
506 * @session: iscsi cls session 408 * @session: iscsi cls session
@@ -533,12 +435,9 @@ iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
533 conn->transport = transport; 435 conn->transport = transport;
534 conn->cid = cid; 436 conn->cid = cid;
535 437
536 if (iscsi_create_event_pools(conn))
537 goto free_conn;
538
539 /* this is released in the dev's release function */ 438 /* this is released in the dev's release function */
540 if (!get_device(&session->dev)) 439 if (!get_device(&session->dev))
541 goto free_conn_pools; 440 goto free_conn;
542 441
543 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u", 442 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u",
544 session->sid, cid); 443 session->sid, cid);
@@ -555,8 +454,6 @@ iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
555 454
556release_parent_ref: 455release_parent_ref:
557 put_device(&session->dev); 456 put_device(&session->dev);
558free_conn_pools:
559
560free_conn: 457free_conn:
561 kfree(conn); 458 kfree(conn);
562 return NULL; 459 return NULL;
@@ -599,81 +496,31 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
599 return NULL; 496 return NULL;
600} 497}
601 498
602static inline struct list_head *skb_to_lh(struct sk_buff *skb)
603{
604 return (struct list_head *)&skb->cb;
605}
606
607static void
608mempool_zone_complete(struct mempool_zone *zone)
609{
610 unsigned long flags;
611 struct list_head *lh, *n;
612
613 spin_lock_irqsave(&zone->freelock, flags);
614 list_for_each_safe(lh, n, &zone->freequeue) {
615 struct sk_buff *skb = (struct sk_buff *)((char *)lh -
616 offsetof(struct sk_buff, cb));
617 if (!skb_shared(skb)) {
618 list_del(skb_to_lh(skb));
619 mempool_free(skb, zone->pool);
620 atomic_dec(&zone->allocated);
621 }
622 }
623 spin_unlock_irqrestore(&zone->freelock, flags);
624}
625
626static struct sk_buff*
627mempool_zone_get_skb(struct mempool_zone *zone)
628{
629 struct sk_buff *skb;
630
631 skb = mempool_alloc(zone->pool, GFP_ATOMIC);
632 if (skb)
633 atomic_inc(&zone->allocated);
634 return skb;
635}
636
637static int 499static int
638iscsi_broadcast_skb(struct mempool_zone *zone, struct sk_buff *skb, gfp_t gfp) 500iscsi_broadcast_skb(struct sk_buff *skb, gfp_t gfp)
639{ 501{
640 unsigned long flags;
641 int rc; 502 int rc;
642 503
643 skb_get(skb);
644 rc = netlink_broadcast(nls, skb, 0, 1, gfp); 504 rc = netlink_broadcast(nls, skb, 0, 1, gfp);
645 if (rc < 0) { 505 if (rc < 0) {
646 mempool_free(skb, zone->pool);
647 printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc); 506 printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc);
648 return rc; 507 return rc;
649 } 508 }
650 509
651 spin_lock_irqsave(&zone->freelock, flags);
652 INIT_LIST_HEAD(skb_to_lh(skb));
653 list_add(skb_to_lh(skb), &zone->freequeue);
654 spin_unlock_irqrestore(&zone->freelock, flags);
655 return 0; 510 return 0;
656} 511}
657 512
658static int 513static int
659iscsi_unicast_skb(struct mempool_zone *zone, struct sk_buff *skb, int pid) 514iscsi_unicast_skb(struct sk_buff *skb, int pid)
660{ 515{
661 unsigned long flags;
662 int rc; 516 int rc;
663 517
664 skb_get(skb);
665 rc = netlink_unicast(nls, skb, pid, MSG_DONTWAIT); 518 rc = netlink_unicast(nls, skb, pid, MSG_DONTWAIT);
666 if (rc < 0) { 519 if (rc < 0) {
667 mempool_free(skb, zone->pool);
668 printk(KERN_ERR "iscsi: can not unicast skb (%d)\n", rc); 520 printk(KERN_ERR "iscsi: can not unicast skb (%d)\n", rc);
669 return rc; 521 return rc;
670 } 522 }
671 523
672 spin_lock_irqsave(&zone->freelock, flags);
673 INIT_LIST_HEAD(skb_to_lh(skb));
674 list_add(skb_to_lh(skb), &zone->freequeue);
675 spin_unlock_irqrestore(&zone->freelock, flags);
676
677 return 0; 524 return 0;
678} 525}
679 526
@@ -692,9 +539,7 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
692 if (!priv) 539 if (!priv)
693 return -EINVAL; 540 return -EINVAL;
694 541
695 mempool_zone_complete(conn->z_pdu); 542 skb = alloc_skb(len, GFP_ATOMIC);
696
697 skb = mempool_zone_get_skb(conn->z_pdu);
698 if (!skb) { 543 if (!skb) {
699 iscsi_conn_error(conn, ISCSI_ERR_CONN_FAILED); 544 iscsi_conn_error(conn, ISCSI_ERR_CONN_FAILED);
700 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not deliver " 545 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not deliver "
@@ -707,15 +552,13 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
707 memset(ev, 0, sizeof(*ev)); 552 memset(ev, 0, sizeof(*ev));
708 ev->transport_handle = iscsi_handle(conn->transport); 553 ev->transport_handle = iscsi_handle(conn->transport);
709 ev->type = ISCSI_KEVENT_RECV_PDU; 554 ev->type = ISCSI_KEVENT_RECV_PDU;
710 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
711 ev->iferror = -ENOMEM;
712 ev->r.recv_req.cid = conn->cid; 555 ev->r.recv_req.cid = conn->cid;
713 ev->r.recv_req.sid = iscsi_conn_get_sid(conn); 556 ev->r.recv_req.sid = iscsi_conn_get_sid(conn);
714 pdu = (char*)ev + sizeof(*ev); 557 pdu = (char*)ev + sizeof(*ev);
715 memcpy(pdu, hdr, sizeof(struct iscsi_hdr)); 558 memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
716 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size); 559 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
717 560
718 return iscsi_unicast_skb(conn->z_pdu, skb, priv->daemon_pid); 561 return iscsi_unicast_skb(skb, priv->daemon_pid);
719} 562}
720EXPORT_SYMBOL_GPL(iscsi_recv_pdu); 563EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
721 564
@@ -731,9 +574,7 @@ void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error)
731 if (!priv) 574 if (!priv)
732 return; 575 return;
733 576
734 mempool_zone_complete(conn->z_error); 577 skb = alloc_skb(len, GFP_ATOMIC);
735
736 skb = mempool_zone_get_skb(conn->z_error);
737 if (!skb) { 578 if (!skb) {
738 dev_printk(KERN_ERR, &conn->dev, "iscsi: gracefully ignored " 579 dev_printk(KERN_ERR, &conn->dev, "iscsi: gracefully ignored "
739 "conn error (%d)\n", error); 580 "conn error (%d)\n", error);
@@ -744,13 +585,11 @@ void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error)
744 ev = NLMSG_DATA(nlh); 585 ev = NLMSG_DATA(nlh);
745 ev->transport_handle = iscsi_handle(conn->transport); 586 ev->transport_handle = iscsi_handle(conn->transport);
746 ev->type = ISCSI_KEVENT_CONN_ERROR; 587 ev->type = ISCSI_KEVENT_CONN_ERROR;
747 if (atomic_read(&conn->z_error->allocated) >= conn->z_error->hiwat)
748 ev->iferror = -ENOMEM;
749 ev->r.connerror.error = error; 588 ev->r.connerror.error = error;
750 ev->r.connerror.cid = conn->cid; 589 ev->r.connerror.cid = conn->cid;
751 ev->r.connerror.sid = iscsi_conn_get_sid(conn); 590 ev->r.connerror.sid = iscsi_conn_get_sid(conn);
752 591
753 iscsi_broadcast_skb(conn->z_error, skb, GFP_ATOMIC); 592 iscsi_broadcast_skb(skb, GFP_ATOMIC);
754 593
755 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n", 594 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n",
756 error); 595 error);
@@ -767,9 +606,7 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
767 int flags = multi ? NLM_F_MULTI : 0; 606 int flags = multi ? NLM_F_MULTI : 0;
768 int t = done ? NLMSG_DONE : type; 607 int t = done ? NLMSG_DONE : type;
769 608
770 mempool_zone_complete(z_reply); 609 skb = alloc_skb(len, GFP_ATOMIC);
771
772 skb = mempool_zone_get_skb(z_reply);
773 /* 610 /*
774 * FIXME: 611 * FIXME:
775 * user is supposed to react on iferror == -ENOMEM; 612 * user is supposed to react on iferror == -ENOMEM;
@@ -780,7 +617,7 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
780 nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0); 617 nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0);
781 nlh->nlmsg_flags = flags; 618 nlh->nlmsg_flags = flags;
782 memcpy(NLMSG_DATA(nlh), payload, size); 619 memcpy(NLMSG_DATA(nlh), payload, size);
783 return iscsi_unicast_skb(z_reply, skb, pid); 620 return iscsi_unicast_skb(skb, pid);
784} 621}
785 622
786static int 623static int
@@ -810,9 +647,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
810 do { 647 do {
811 int actual_size; 648 int actual_size;
812 649
813 mempool_zone_complete(conn->z_pdu); 650 skbstat = alloc_skb(len, GFP_ATOMIC);
814
815 skbstat = mempool_zone_get_skb(conn->z_pdu);
816 if (!skbstat) { 651 if (!skbstat) {
817 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not " 652 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not "
818 "deliver stats: OOM\n"); 653 "deliver stats: OOM\n");
@@ -825,8 +660,6 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
825 memset(evstat, 0, sizeof(*evstat)); 660 memset(evstat, 0, sizeof(*evstat));
826 evstat->transport_handle = iscsi_handle(conn->transport); 661 evstat->transport_handle = iscsi_handle(conn->transport);
827 evstat->type = nlh->nlmsg_type; 662 evstat->type = nlh->nlmsg_type;
828 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
829 evstat->iferror = -ENOMEM;
830 evstat->u.get_stats.cid = 663 evstat->u.get_stats.cid =
831 ev->u.get_stats.cid; 664 ev->u.get_stats.cid;
832 evstat->u.get_stats.sid = 665 evstat->u.get_stats.sid =
@@ -845,7 +678,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
845 skb_trim(skbstat, NLMSG_ALIGN(actual_size)); 678 skb_trim(skbstat, NLMSG_ALIGN(actual_size));
846 nlhstat->nlmsg_len = actual_size; 679 nlhstat->nlmsg_len = actual_size;
847 680
848 err = iscsi_unicast_skb(conn->z_pdu, skbstat, priv->daemon_pid); 681 err = iscsi_unicast_skb(skbstat, priv->daemon_pid);
849 } while (err < 0 && err != -ECONNREFUSED); 682 } while (err < 0 && err != -ECONNREFUSED);
850 683
851 return err; 684 return err;
@@ -876,9 +709,7 @@ int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn)
876 session = iscsi_dev_to_session(conn->dev.parent); 709 session = iscsi_dev_to_session(conn->dev.parent);
877 shost = iscsi_session_to_shost(session); 710 shost = iscsi_session_to_shost(session);
878 711
879 mempool_zone_complete(conn->z_pdu); 712 skb = alloc_skb(len, GFP_KERNEL);
880
881 skb = mempool_zone_get_skb(conn->z_pdu);
882 if (!skb) { 713 if (!skb) {
883 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 714 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
884 "session creation event\n"); 715 "session creation event\n");
@@ -896,7 +727,7 @@ int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn)
896 * this will occur if the daemon is not up, so we just warn 727 * this will occur if the daemon is not up, so we just warn
897 * the user and when the daemon is restarted it will handle it 728 * the user and when the daemon is restarted it will handle it
898 */ 729 */
899 rc = iscsi_broadcast_skb(conn->z_pdu, skb, GFP_KERNEL); 730 rc = iscsi_broadcast_skb(skb, GFP_KERNEL);
900 if (rc < 0) 731 if (rc < 0)
901 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 732 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
902 "session destruction event. Check iscsi daemon\n"); 733 "session destruction event. Check iscsi daemon\n");
@@ -939,9 +770,7 @@ int iscsi_if_create_session_done(struct iscsi_cls_conn *conn)
939 session = iscsi_dev_to_session(conn->dev.parent); 770 session = iscsi_dev_to_session(conn->dev.parent);
940 shost = iscsi_session_to_shost(session); 771 shost = iscsi_session_to_shost(session);
941 772
942 mempool_zone_complete(conn->z_pdu); 773 skb = alloc_skb(len, GFP_KERNEL);
943
944 skb = mempool_zone_get_skb(conn->z_pdu);
945 if (!skb) { 774 if (!skb) {
946 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 775 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
947 "session creation event\n"); 776 "session creation event\n");
@@ -959,7 +788,7 @@ int iscsi_if_create_session_done(struct iscsi_cls_conn *conn)
959 * this will occur if the daemon is not up, so we just warn 788 * this will occur if the daemon is not up, so we just warn
960 * the user and when the daemon is restarted it will handle it 789 * the user and when the daemon is restarted it will handle it
961 */ 790 */
962 rc = iscsi_broadcast_skb(conn->z_pdu, skb, GFP_KERNEL); 791 rc = iscsi_broadcast_skb(skb, GFP_KERNEL);
963 if (rc < 0) 792 if (rc < 0)
964 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 793 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
965 "session creation event. Check iscsi daemon\n"); 794 "session creation event. Check iscsi daemon\n");
@@ -1278,9 +1107,6 @@ iscsi_if_rx(struct sock *sk, int len)
1278 err = iscsi_if_send_reply( 1107 err = iscsi_if_send_reply(
1279 NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq, 1108 NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq,
1280 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev)); 1109 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
1281 if (atomic_read(&z_reply->allocated) >=
1282 z_reply->hiwat)
1283 ev->iferror = -ENOMEM;
1284 } while (err < 0 && err != -ECONNREFUSED); 1110 } while (err < 0 && err != -ECONNREFUSED);
1285 skb_pull(skb, rlen); 1111 skb_pull(skb, rlen);
1286 } 1112 }
@@ -1584,32 +1410,6 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
1584} 1410}
1585EXPORT_SYMBOL_GPL(iscsi_unregister_transport); 1411EXPORT_SYMBOL_GPL(iscsi_unregister_transport);
1586 1412
1587static int
1588iscsi_rcv_nl_event(struct notifier_block *this, unsigned long event, void *ptr)
1589{
1590 struct netlink_notify *n = ptr;
1591
1592 if (event == NETLINK_URELEASE &&
1593 n->protocol == NETLINK_ISCSI && n->pid) {
1594 struct iscsi_cls_conn *conn;
1595 unsigned long flags;
1596
1597 mempool_zone_complete(z_reply);
1598 spin_lock_irqsave(&connlock, flags);
1599 list_for_each_entry(conn, &connlist, conn_list) {
1600 mempool_zone_complete(conn->z_error);
1601 mempool_zone_complete(conn->z_pdu);
1602 }
1603 spin_unlock_irqrestore(&connlock, flags);
1604 }
1605
1606 return NOTIFY_DONE;
1607}
1608
1609static struct notifier_block iscsi_nl_notifier = {
1610 .notifier_call = iscsi_rcv_nl_event,
1611};
1612
1613static __init int iscsi_transport_init(void) 1413static __init int iscsi_transport_init(void)
1614{ 1414{
1615 int err; 1415 int err;
@@ -1633,25 +1433,15 @@ static __init int iscsi_transport_init(void)
1633 if (err) 1433 if (err)
1634 goto unregister_conn_class; 1434 goto unregister_conn_class;
1635 1435
1636 err = netlink_register_notifier(&iscsi_nl_notifier);
1637 if (err)
1638 goto unregister_session_class;
1639
1640 nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx, 1436 nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx,
1641 THIS_MODULE); 1437 THIS_MODULE);
1642 if (!nls) { 1438 if (!nls) {
1643 err = -ENOBUFS; 1439 err = -ENOBUFS;
1644 goto unregister_notifier; 1440 goto unregister_session_class;
1645 } 1441 }
1646 1442
1647 z_reply = mempool_zone_init(Z_MAX_REPLY, 1443 return 0;
1648 NLMSG_SPACE(sizeof(struct iscsi_uevent)), Z_HIWAT_REPLY);
1649 if (z_reply)
1650 return 0;
1651 1444
1652 sock_release(nls->sk_socket);
1653unregister_notifier:
1654 netlink_unregister_notifier(&iscsi_nl_notifier);
1655unregister_session_class: 1445unregister_session_class:
1656 transport_class_unregister(&iscsi_session_class); 1446 transport_class_unregister(&iscsi_session_class);
1657unregister_conn_class: 1447unregister_conn_class:
@@ -1665,9 +1455,7 @@ unregister_transport_class:
1665 1455
1666static void __exit iscsi_transport_exit(void) 1456static void __exit iscsi_transport_exit(void)
1667{ 1457{
1668 mempool_zone_destroy(z_reply);
1669 sock_release(nls->sk_socket); 1458 sock_release(nls->sk_socket);
1670 netlink_unregister_notifier(&iscsi_nl_notifier);
1671 transport_class_unregister(&iscsi_connection_class); 1459 transport_class_unregister(&iscsi_connection_class);
1672 transport_class_unregister(&iscsi_session_class); 1460 transport_class_unregister(&iscsi_session_class);
1673 transport_class_unregister(&iscsi_host_class); 1461 transport_class_unregister(&iscsi_host_class);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 3f8b93188567..81e3bc7b02a1 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -60,7 +60,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */
60 60
61#ifdef CONFIG_SCSI_PROC_FS 61#ifdef CONFIG_SCSI_PROC_FS
62#include <linux/proc_fs.h> 62#include <linux/proc_fs.h>
63static char *sg_version_date = "20060920"; 63static char *sg_version_date = "20061027";
64 64
65static int sg_proc_init(void); 65static int sg_proc_init(void);
66static void sg_proc_cleanup(void); 66static void sg_proc_cleanup(void);
@@ -710,12 +710,12 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
710 (int) cmnd[0], (int) hp->cmd_len)); 710 (int) cmnd[0], (int) hp->cmd_len));
711 711
712 if ((k = sg_start_req(srp))) { 712 if ((k = sg_start_req(srp))) {
713 SCSI_LOG_TIMEOUT(1, printk("sg_write: start_req err=%d\n", k)); 713 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: start_req err=%d\n", k));
714 sg_finish_rem_req(srp); 714 sg_finish_rem_req(srp);
715 return k; /* probably out of space --> ENOMEM */ 715 return k; /* probably out of space --> ENOMEM */
716 } 716 }
717 if ((k = sg_write_xfer(srp))) { 717 if ((k = sg_write_xfer(srp))) {
718 SCSI_LOG_TIMEOUT(1, printk("sg_write: write_xfer, bad address\n")); 718 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: write_xfer, bad address\n"));
719 sg_finish_rem_req(srp); 719 sg_finish_rem_req(srp);
720 return k; 720 return k;
721 } 721 }
@@ -746,7 +746,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
746 hp->dxfer_len, srp->data.k_use_sg, timeout, 746 hp->dxfer_len, srp->data.k_use_sg, timeout,
747 SG_DEFAULT_RETRIES, srp, sg_cmd_done, 747 SG_DEFAULT_RETRIES, srp, sg_cmd_done,
748 GFP_ATOMIC)) { 748 GFP_ATOMIC)) {
749 SCSI_LOG_TIMEOUT(1, printk("sg_write: scsi_execute_async failed\n")); 749 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: scsi_execute_async failed\n"));
750 /* 750 /*
751 * most likely out of mem, but could also be a bad map 751 * most likely out of mem, but could also be a bad map
752 */ 752 */
@@ -1283,7 +1283,7 @@ sg_cmd_done(void *data, char *sense, int result, int resid)
1283 sg_finish_rem_req(srp); 1283 sg_finish_rem_req(srp);
1284 srp = NULL; 1284 srp = NULL;
1285 if (NULL == sfp->headrp) { 1285 if (NULL == sfp->headrp) {
1286 SCSI_LOG_TIMEOUT(1, printk("sg...bh: already closed, final cleanup\n")); 1286 SCSI_LOG_TIMEOUT(1, printk("sg_cmd_done: already closed, final cleanup\n"));
1287 if (0 == sg_remove_sfp(sdp, sfp)) { /* device still present */ 1287 if (0 == sg_remove_sfp(sdp, sfp)) { /* device still present */
1288 scsi_device_put(sdp->device); 1288 scsi_device_put(sdp->device);
1289 } 1289 }
@@ -1512,12 +1512,12 @@ sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
1512 POLL_HUP); 1512 POLL_HUP);
1513 } 1513 }
1514 } 1514 }
1515 SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d, dirty\n", k)); 1515 SCSI_LOG_TIMEOUT(3, printk("sg_remove: dev=%d, dirty\n", k));
1516 if (NULL == sdp->headfp) { 1516 if (NULL == sdp->headfp) {
1517 sg_dev_arr[k] = NULL; 1517 sg_dev_arr[k] = NULL;
1518 } 1518 }
1519 } else { /* nothing active, simple case */ 1519 } else { /* nothing active, simple case */
1520 SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d\n", k)); 1520 SCSI_LOG_TIMEOUT(3, printk("sg_remove: dev=%d\n", k));
1521 sg_dev_arr[k] = NULL; 1521 sg_dev_arr[k] = NULL;
1522 } 1522 }
1523 sg_nr_dev--; 1523 sg_nr_dev--;
@@ -1876,14 +1876,15 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1876 } 1876 }
1877 } 1877 }
1878 sg->page = p; 1878 sg->page = p;
1879 sg->length = ret_sz; 1879 sg->length = (ret_sz > num) ? num : ret_sz;
1880 1880
1881 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", 1881 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, "
1882 k, p, ret_sz)); 1882 "ret_sz=%d\n", k, num, ret_sz));
1883 } /* end of for loop */ 1883 } /* end of for loop */
1884 1884
1885 schp->k_use_sg = k; 1885 schp->k_use_sg = k;
1886 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, rem_sz=%d\n", k, rem_sz)); 1886 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, "
1887 "rem_sz=%d\n", k, rem_sz));
1887 1888
1888 schp->bufflen = blk_size; 1889 schp->bufflen = blk_size;
1889 if (rem_sz > 0) /* must have failed */ 1890 if (rem_sz > 0) /* must have failed */
@@ -2014,7 +2015,7 @@ sg_remove_scat(Sg_scatter_hold * schp)
2014 for (k = 0; (k < schp->k_use_sg) && sg->page; 2015 for (k = 0; (k < schp->k_use_sg) && sg->page;
2015 ++k, ++sg) { 2016 ++k, ++sg) {
2016 SCSI_LOG_TIMEOUT(5, printk( 2017 SCSI_LOG_TIMEOUT(5, printk(
2017 "sg_remove_scat: k=%d, a=0x%p, len=%d\n", 2018 "sg_remove_scat: k=%d, pg=0x%p, len=%d\n",
2018 k, sg->page, sg->length)); 2019 k, sg->page, sg->length));
2019 sg_page_free(sg->page, sg->length); 2020 sg_page_free(sg->page, sg->length);
2020 } 2021 }
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 3babdc76b3fb..e1a52c525ed4 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -1177,7 +1177,10 @@ static int st_open(struct inode *inode, struct file *filp)
1177 goto err_out; 1177 goto err_out;
1178 if ((filp->f_flags & O_NONBLOCK) == 0 && 1178 if ((filp->f_flags & O_NONBLOCK) == 0 &&
1179 retval != CHKRES_READY) { 1179 retval != CHKRES_READY) {
1180 retval = (-EIO); 1180 if (STp->ready == NO_TAPE)
1181 retval = (-ENOMEDIUM);
1182 else
1183 retval = (-EIO);
1181 goto err_out; 1184 goto err_out;
1182 } 1185 }
1183 return 0; 1186 return 0;
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 5ec5af8e3379..3b3f3050a877 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -266,8 +266,8 @@ static struct scsi_host_template *the_template = NULL;
266 (struct NCR5380_hostdata *)(in)->hostdata 266 (struct NCR5380_hostdata *)(in)->hostdata
267#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) 267#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata)
268 268
269#define NEXT(cmd) ((Scsi_Cmnd *)((cmd)->host_scribble)) 269#define NEXT(cmd) ((struct scsi_cmnd *)((cmd)->host_scribble))
270#define NEXTADDR(cmd) ((Scsi_Cmnd **)&((cmd)->host_scribble)) 270#define NEXTADDR(cmd) ((struct scsi_cmnd **)&((cmd)->host_scribble))
271 271
272#define HOSTNO instance->host_no 272#define HOSTNO instance->host_no
273#define H_NO(cmd) (cmd)->device->host->host_no 273#define H_NO(cmd) (cmd)->device->host->host_no
@@ -360,7 +360,7 @@ static void __init init_tags( void )
360 * conditions. 360 * conditions.
361 */ 361 */
362 362
363static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged ) 363static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged)
364{ 364{
365 SETUP_HOSTDATA(cmd->device->host); 365 SETUP_HOSTDATA(cmd->device->host);
366 366
@@ -384,7 +384,7 @@ static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged )
384 * untagged. 384 * untagged.
385 */ 385 */
386 386
387static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged ) 387static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)
388{ 388{
389 SETUP_HOSTDATA(cmd->device->host); 389 SETUP_HOSTDATA(cmd->device->host);
390 390
@@ -416,7 +416,7 @@ static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged )
416 * unlock the LUN. 416 * unlock the LUN.
417 */ 417 */
418 418
419static void cmd_free_tag( Scsi_Cmnd *cmd ) 419static void cmd_free_tag(struct scsi_cmnd *cmd)
420{ 420{
421 SETUP_HOSTDATA(cmd->device->host); 421 SETUP_HOSTDATA(cmd->device->host);
422 422
@@ -460,18 +460,18 @@ static void free_all_tags( void )
460 460
461 461
462/* 462/*
463 * Function: void merge_contiguous_buffers( Scsi_Cmnd *cmd ) 463 * Function: void merge_contiguous_buffers(struct scsi_cmnd *cmd)
464 * 464 *
465 * Purpose: Try to merge several scatter-gather requests into one DMA 465 * Purpose: Try to merge several scatter-gather requests into one DMA
466 * transfer. This is possible if the scatter buffers lie on 466 * transfer. This is possible if the scatter buffers lie on
467 * physical contiguous addresses. 467 * physical contiguous addresses.
468 * 468 *
469 * Parameters: Scsi_Cmnd *cmd 469 * Parameters: struct scsi_cmnd *cmd
470 * The command to work on. The first scatter buffer's data are 470 * The command to work on. The first scatter buffer's data are
471 * assumed to be already transfered into ptr/this_residual. 471 * assumed to be already transfered into ptr/this_residual.
472 */ 472 */
473 473
474static void merge_contiguous_buffers( Scsi_Cmnd *cmd ) 474static void merge_contiguous_buffers(struct scsi_cmnd *cmd)
475{ 475{
476 unsigned long endaddr; 476 unsigned long endaddr;
477#if (NDEBUG & NDEBUG_MERGING) 477#if (NDEBUG & NDEBUG_MERGING)
@@ -501,15 +501,15 @@ static void merge_contiguous_buffers( Scsi_Cmnd *cmd )
501} 501}
502 502
503/* 503/*
504 * Function : void initialize_SCp(Scsi_Cmnd *cmd) 504 * Function : void initialize_SCp(struct scsi_cmnd *cmd)
505 * 505 *
506 * Purpose : initialize the saved data pointers for cmd to point to the 506 * Purpose : initialize the saved data pointers for cmd to point to the
507 * start of the buffer. 507 * start of the buffer.
508 * 508 *
509 * Inputs : cmd - Scsi_Cmnd structure to have pointers reset. 509 * Inputs : cmd - struct scsi_cmnd structure to have pointers reset.
510 */ 510 */
511 511
512static __inline__ void initialize_SCp(Scsi_Cmnd *cmd) 512static __inline__ void initialize_SCp(struct scsi_cmnd *cmd)
513{ 513{
514 /* 514 /*
515 * Initialize the Scsi Pointer field so that all of the commands in the 515 * Initialize the Scsi Pointer field so that all of the commands in the
@@ -753,14 +753,15 @@ static void NCR5380_print_status (struct Scsi_Host *instance)
753 do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \ 753 do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \
754 pos += sprintf(pos, fmt , ## args); } while(0) 754 pos += sprintf(pos, fmt , ## args); } while(0)
755static 755static
756char *lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length); 756char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer,
757 int length);
757 758
758static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **start, 759static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer,
759 off_t offset, int length, int inout) 760 char **start, off_t offset, int length, int inout)
760{ 761{
761 char *pos = buffer; 762 char *pos = buffer;
762 struct NCR5380_hostdata *hostdata; 763 struct NCR5380_hostdata *hostdata;
763 Scsi_Cmnd *ptr; 764 struct scsi_cmnd *ptr;
764 unsigned long flags; 765 unsigned long flags;
765 off_t begin = 0; 766 off_t begin = 0;
766#define check_offset() \ 767#define check_offset() \
@@ -784,18 +785,19 @@ static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **s
784 if (!hostdata->connected) 785 if (!hostdata->connected)
785 SPRINTF("scsi%d: no currently connected command\n", HOSTNO); 786 SPRINTF("scsi%d: no currently connected command\n", HOSTNO);
786 else 787 else
787 pos = lprint_Scsi_Cmnd ((Scsi_Cmnd *) hostdata->connected, 788 pos = lprint_Scsi_Cmnd ((struct scsi_cmnd *) hostdata->connected,
788 pos, buffer, length); 789 pos, buffer, length);
789 SPRINTF("scsi%d: issue_queue\n", HOSTNO); 790 SPRINTF("scsi%d: issue_queue\n", HOSTNO);
790 check_offset(); 791 check_offset();
791 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr)) { 792 for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr))
793 {
792 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); 794 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
793 check_offset(); 795 check_offset();
794 } 796 }
795 797
796 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); 798 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO);
797 check_offset(); 799 check_offset();
798 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; 800 for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr;
799 ptr = NEXT(ptr)) { 801 ptr = NEXT(ptr)) {
800 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); 802 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
801 check_offset(); 803 check_offset();
@@ -810,8 +812,8 @@ static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **s
810 return length; 812 return length;
811} 813}
812 814
813static char * 815static char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer,
814lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length) 816 int length)
815{ 817{
816 int i, s; 818 int i, s;
817 unsigned char *command; 819 unsigned char *command;
@@ -888,8 +890,8 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)
888} 890}
889 891
890/* 892/*
891 * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd, 893 * Function : int NCR5380_queue_command (struct scsi_cmnd *cmd,
892 * void (*done)(Scsi_Cmnd *)) 894 * void (*done)(struct scsi_cmnd *))
893 * 895 *
894 * Purpose : enqueues a SCSI command 896 * Purpose : enqueues a SCSI command
895 * 897 *
@@ -906,10 +908,11 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)
906 */ 908 */
907 909
908/* Only make static if a wrapper function is used */ 910/* Only make static if a wrapper function is used */
909static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) 911static int NCR5380_queue_command(struct scsi_cmnd *cmd,
912 void (*done)(struct scsi_cmnd *))
910{ 913{
911 SETUP_HOSTDATA(cmd->device->host); 914 SETUP_HOSTDATA(cmd->device->host);
912 Scsi_Cmnd *tmp; 915 struct scsi_cmnd *tmp;
913 unsigned long flags; 916 unsigned long flags;
914 917
915#if (NDEBUG & NDEBUG_NO_WRITE) 918#if (NDEBUG & NDEBUG_NO_WRITE)
@@ -990,7 +993,7 @@ static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
990 NEXT(cmd) = hostdata->issue_queue; 993 NEXT(cmd) = hostdata->issue_queue;
991 hostdata->issue_queue = cmd; 994 hostdata->issue_queue = cmd;
992 } else { 995 } else {
993 for (tmp = (Scsi_Cmnd *)hostdata->issue_queue; 996 for (tmp = (struct scsi_cmnd *)hostdata->issue_queue;
994 NEXT(tmp); tmp = NEXT(tmp)) 997 NEXT(tmp); tmp = NEXT(tmp))
995 ; 998 ;
996 LIST(cmd, tmp); 999 LIST(cmd, tmp);
@@ -1030,7 +1033,7 @@ static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
1030 1033
1031static void NCR5380_main (void *bl) 1034static void NCR5380_main (void *bl)
1032{ 1035{
1033 Scsi_Cmnd *tmp, *prev; 1036 struct scsi_cmnd *tmp, *prev;
1034 struct Scsi_Host *instance = first_instance; 1037 struct Scsi_Host *instance = first_instance;
1035 struct NCR5380_hostdata *hostdata = HOSTDATA(instance); 1038 struct NCR5380_hostdata *hostdata = HOSTDATA(instance);
1036 int done; 1039 int done;
@@ -1073,12 +1076,12 @@ static void NCR5380_main (void *bl)
1073 * for a target that's not busy. 1076 * for a target that's not busy.
1074 */ 1077 */
1075#if (NDEBUG & NDEBUG_LISTS) 1078#if (NDEBUG & NDEBUG_LISTS)
1076 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; 1079 for (tmp = (struct scsi_cmnd *) hostdata->issue_queue, prev = NULL;
1077 tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp)) 1080 tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp))
1078 ; 1081 ;
1079 if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/ 1082 if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/
1080#endif 1083#endif
1081 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, 1084 for (tmp = (struct scsi_cmnd *) hostdata->issue_queue,
1082 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) { 1085 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) {
1083 1086
1084#if (NDEBUG & NDEBUG_LISTS) 1087#if (NDEBUG & NDEBUG_LISTS)
@@ -1339,7 +1342,8 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)
1339} 1342}
1340 1343
1341#ifdef NCR5380_STATS 1344#ifdef NCR5380_STATS
1342static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd) 1345static void collect_stats(struct NCR5380_hostdata *hostdata,
1346 struct scsi_cmnd *cmd)
1343{ 1347{
1344# ifdef NCR5380_STAT_LIMIT 1348# ifdef NCR5380_STAT_LIMIT
1345 if (cmd->request_bufflen > NCR5380_STAT_LIMIT) 1349 if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
@@ -1365,8 +1369,8 @@ static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd)
1365#endif 1369#endif
1366 1370
1367/* 1371/*
1368 * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, 1372 * Function : int NCR5380_select(struct Scsi_Host *instance,
1369 * int tag); 1373 * struct scsi_cmnd *cmd, int tag);
1370 * 1374 *
1371 * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, 1375 * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
1372 * including ARBITRATION, SELECTION, and initial message out for 1376 * including ARBITRATION, SELECTION, and initial message out for
@@ -1395,7 +1399,8 @@ static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd)
1395 * cmd->result host byte set to DID_BAD_TARGET. 1399 * cmd->result host byte set to DID_BAD_TARGET.
1396 */ 1400 */
1397 1401
1398static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag) 1402static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,
1403 int tag)
1399{ 1404{
1400 SETUP_HOSTDATA(instance); 1405 SETUP_HOSTDATA(instance);
1401 unsigned char tmp[3], phase; 1406 unsigned char tmp[3], phase;
@@ -1985,7 +1990,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
1985#endif 1990#endif
1986 unsigned char *data; 1991 unsigned char *data;
1987 unsigned char phase, tmp, extended_msg[10], old_phase=0xff; 1992 unsigned char phase, tmp, extended_msg[10], old_phase=0xff;
1988 Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; 1993 struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected;
1989 1994
1990#ifdef SUN3_SCSI_VME 1995#ifdef SUN3_SCSI_VME
1991 dregs->csr |= CSR_INTR; 1996 dregs->csr |= CSR_INTR;
@@ -2272,7 +2277,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2272 local_irq_save(flags); 2277 local_irq_save(flags);
2273 LIST(cmd,hostdata->issue_queue); 2278 LIST(cmd,hostdata->issue_queue);
2274 NEXT(cmd) = hostdata->issue_queue; 2279 NEXT(cmd) = hostdata->issue_queue;
2275 hostdata->issue_queue = (Scsi_Cmnd *) cmd; 2280 hostdata->issue_queue = (struct scsi_cmnd *) cmd;
2276 local_irq_restore(flags); 2281 local_irq_restore(flags);
2277 QU_PRINTK("scsi%d: REQUEST SENSE added to head of " 2282 QU_PRINTK("scsi%d: REQUEST SENSE added to head of "
2278 "issue queue\n", H_NO(cmd)); 2283 "issue queue\n", H_NO(cmd));
@@ -2502,7 +2507,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2502 * Function : void NCR5380_reselect (struct Scsi_Host *instance) 2507 * Function : void NCR5380_reselect (struct Scsi_Host *instance)
2503 * 2508 *
2504 * Purpose : does reselection, initializing the instance->connected 2509 * Purpose : does reselection, initializing the instance->connected
2505 * field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q 2510 * field to point to the struct scsi_cmnd for which the I_T_L or I_T_L_Q
2506 * nexus has been reestablished, 2511 * nexus has been reestablished,
2507 * 2512 *
2508 * Inputs : instance - this instance of the NCR5380. 2513 * Inputs : instance - this instance of the NCR5380.
@@ -2521,7 +2526,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2521 unsigned char tag; 2526 unsigned char tag;
2522#endif 2527#endif
2523 unsigned char msg[3]; 2528 unsigned char msg[3];
2524 Scsi_Cmnd *tmp = NULL, *prev; 2529 struct scsi_cmnd *tmp = NULL, *prev;
2525/* unsigned long flags; */ 2530/* unsigned long flags; */
2526 2531
2527 /* 2532 /*
@@ -2577,7 +2582,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2577 * just reestablished, and remove it from the disconnected queue. 2582 * just reestablished, and remove it from the disconnected queue.
2578 */ 2583 */
2579 2584
2580 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; 2585 for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue, prev = NULL;
2581 tmp; prev = tmp, tmp = NEXT(tmp) ) { 2586 tmp; prev = tmp, tmp = NEXT(tmp) ) {
2582 if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun) 2587 if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun)
2583#ifdef SUPPORT_TAGS 2588#ifdef SUPPORT_TAGS
@@ -2668,11 +2673,11 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2668 2673
2669 2674
2670/* 2675/*
2671 * Function : int NCR5380_abort (Scsi_Cmnd *cmd) 2676 * Function : int NCR5380_abort(struct scsi_cmnd *cmd)
2672 * 2677 *
2673 * Purpose : abort a command 2678 * Purpose : abort a command
2674 * 2679 *
2675 * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the 2680 * Inputs : cmd - the struct scsi_cmnd to abort, code - code to set the
2676 * host byte of the result field to, if zero DID_ABORTED is 2681 * host byte of the result field to, if zero DID_ABORTED is
2677 * used. 2682 * used.
2678 * 2683 *
@@ -2684,11 +2689,11 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2684 * called where the loop started in NCR5380_main(). 2689 * called where the loop started in NCR5380_main().
2685 */ 2690 */
2686 2691
2687static int NCR5380_abort (Scsi_Cmnd *cmd) 2692static int NCR5380_abort(struct scsi_cmnd *cmd)
2688{ 2693{
2689 struct Scsi_Host *instance = cmd->device->host; 2694 struct Scsi_Host *instance = cmd->device->host;
2690 SETUP_HOSTDATA(instance); 2695 SETUP_HOSTDATA(instance);
2691 Scsi_Cmnd *tmp, **prev; 2696 struct scsi_cmnd *tmp, **prev;
2692 unsigned long flags; 2697 unsigned long flags;
2693 2698
2694 printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO); 2699 printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO);
@@ -2753,9 +2758,9 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2753 * Case 2 : If the command hasn't been issued yet, we simply remove it 2758 * Case 2 : If the command hasn't been issued yet, we simply remove it
2754 * from the issue queue. 2759 * from the issue queue.
2755 */ 2760 */
2756 for (prev = (Scsi_Cmnd **) &(hostdata->issue_queue), 2761 for (prev = (struct scsi_cmnd **) &(hostdata->issue_queue),
2757 tmp = (Scsi_Cmnd *) hostdata->issue_queue; 2762 tmp = (struct scsi_cmnd *) hostdata->issue_queue;
2758 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) ) 2763 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp))
2759 if (cmd == tmp) { 2764 if (cmd == tmp) {
2760 REMOVE(5, *prev, tmp, NEXT(tmp)); 2765 REMOVE(5, *prev, tmp, NEXT(tmp));
2761 (*prev) = NEXT(tmp); 2766 (*prev) = NEXT(tmp);
@@ -2812,7 +2817,7 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2812 * it from the disconnected queue. 2817 * it from the disconnected queue.
2813 */ 2818 */
2814 2819
2815 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; 2820 for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp;
2816 tmp = NEXT(tmp)) 2821 tmp = NEXT(tmp))
2817 if (cmd == tmp) { 2822 if (cmd == tmp) {
2818 local_irq_restore(flags); 2823 local_irq_restore(flags);
@@ -2826,8 +2831,8 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2826 do_abort (instance); 2831 do_abort (instance);
2827 2832
2828 local_irq_save(flags); 2833 local_irq_save(flags);
2829 for (prev = (Scsi_Cmnd **) &(hostdata->disconnected_queue), 2834 for (prev = (struct scsi_cmnd **) &(hostdata->disconnected_queue),
2830 tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; 2835 tmp = (struct scsi_cmnd *) hostdata->disconnected_queue;
2831 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) ) 2836 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) )
2832 if (cmd == tmp) { 2837 if (cmd == tmp) {
2833 REMOVE(5, *prev, tmp, NEXT(tmp)); 2838 REMOVE(5, *prev, tmp, NEXT(tmp));
@@ -2868,7 +2873,7 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2868 2873
2869 2874
2870/* 2875/*
2871 * Function : int NCR5380_bus_reset (Scsi_Cmnd *cmd) 2876 * Function : int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2872 * 2877 *
2873 * Purpose : reset the SCSI bus. 2878 * Purpose : reset the SCSI bus.
2874 * 2879 *
@@ -2876,13 +2881,13 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2876 * 2881 *
2877 */ 2882 */
2878 2883
2879static int NCR5380_bus_reset( Scsi_Cmnd *cmd) 2884static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2880{ 2885{
2881 SETUP_HOSTDATA(cmd->device->host); 2886 SETUP_HOSTDATA(cmd->device->host);
2882 int i; 2887 int i;
2883 unsigned long flags; 2888 unsigned long flags;
2884#if 1 2889#if 1
2885 Scsi_Cmnd *connected, *disconnected_queue; 2890 struct scsi_cmnd *connected, *disconnected_queue;
2886#endif 2891#endif
2887 2892
2888 2893
@@ -2914,9 +2919,9 @@ static int NCR5380_bus_reset( Scsi_Cmnd *cmd)
2914 * remembered in local variables first. 2919 * remembered in local variables first.
2915 */ 2920 */
2916 local_irq_save(flags); 2921 local_irq_save(flags);
2917 connected = (Scsi_Cmnd *)hostdata->connected; 2922 connected = (struct scsi_cmnd *)hostdata->connected;
2918 hostdata->connected = NULL; 2923 hostdata->connected = NULL;
2919 disconnected_queue = (Scsi_Cmnd *)hostdata->disconnected_queue; 2924 disconnected_queue = (struct scsi_cmnd *)hostdata->disconnected_queue;
2920 hostdata->disconnected_queue = NULL; 2925 hostdata->disconnected_queue = NULL;
2921#ifdef SUPPORT_TAGS 2926#ifdef SUPPORT_TAGS
2922 free_all_tags(); 2927 free_all_tags();
diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c
index e625b4c5833a..d56d85dd9ba0 100644
--- a/drivers/scsi/sun3_scsi.c
+++ b/drivers/scsi/sun3_scsi.c
@@ -119,7 +119,7 @@ module_param(setup_use_tagged_queuing, int, 0);
119static int setup_hostid = -1; 119static int setup_hostid = -1;
120module_param(setup_hostid, int, 0); 120module_param(setup_hostid, int, 0);
121 121
122static Scsi_Cmnd *sun3_dma_setup_done = NULL; 122static struct scsi_cmnd *sun3_dma_setup_done = NULL;
123 123
124#define AFTER_RESET_DELAY (HZ/2) 124#define AFTER_RESET_DELAY (HZ/2)
125 125
@@ -521,8 +521,9 @@ static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance)
521 return last_residual; 521 return last_residual;
522} 522}
523 523
524static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd, 524static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted,
525 int write_flag) 525 struct scsi_cmnd *cmd,
526 int write_flag)
526{ 527{
527 if(blk_fs_request(cmd->request)) 528 if(blk_fs_request(cmd->request))
528 return wanted; 529 return wanted;
diff --git a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h
index 834dab428019..a1103b3e2034 100644
--- a/drivers/scsi/sun3_scsi.h
+++ b/drivers/scsi/sun3_scsi.h
@@ -47,11 +47,12 @@
47 47
48#define IOBASE_SUN3_VMESCSI 0xff200000 48#define IOBASE_SUN3_VMESCSI 0xff200000
49 49
50static int sun3scsi_abort (Scsi_Cmnd *); 50static int sun3scsi_abort(struct scsi_cmnd *);
51static int sun3scsi_detect (struct scsi_host_template *); 51static int sun3scsi_detect (struct scsi_host_template *);
52static const char *sun3scsi_info (struct Scsi_Host *); 52static const char *sun3scsi_info (struct Scsi_Host *);
53static int sun3scsi_bus_reset(Scsi_Cmnd *); 53static int sun3scsi_bus_reset(struct scsi_cmnd *);
54static int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 54static int sun3scsi_queue_command(struct scsi_cmnd *,
55 void (*done)(struct scsi_cmnd *));
55static int sun3scsi_release (struct Scsi_Host *); 56static int sun3scsi_release (struct Scsi_Host *);
56 57
57#ifndef CMD_PER_LUN 58#ifndef CMD_PER_LUN
diff --git a/drivers/scsi/sun3_scsi_vme.c b/drivers/scsi/sun3_scsi_vme.c
index e8faab16567b..92def310a84c 100644
--- a/drivers/scsi/sun3_scsi_vme.c
+++ b/drivers/scsi/sun3_scsi_vme.c
@@ -84,7 +84,7 @@ module_param(setup_use_tagged_queuing, int, 0);
84static int setup_hostid = -1; 84static int setup_hostid = -1;
85module_param(setup_hostid, int, 0); 85module_param(setup_hostid, int, 0);
86 86
87static Scsi_Cmnd *sun3_dma_setup_done = NULL; 87static struct scsi_cmnd *sun3_dma_setup_done = NULL;
88 88
89#define AFTER_RESET_DELAY (HZ/2) 89#define AFTER_RESET_DELAY (HZ/2)
90 90
@@ -455,8 +455,9 @@ static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance)
455 return last_residual; 455 return last_residual;
456} 456}
457 457
458static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd, 458static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted,
459 int write_flag) 459 struct scsi_cmnd *cmd,
460 int write_flag)
460{ 461{
461 if(blk_fs_request(cmd->request)) 462 if(blk_fs_request(cmd->request))
462 return wanted; 463 return wanted;
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index d03aa6ce8fe8..fa5382e354be 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -2304,6 +2304,7 @@ static struct scsi_host_template driver_template = {
2304 .sg_tablesize = SG_ALL, 2304 .sg_tablesize = SG_ALL,
2305 .cmd_per_lun = 1, 2305 .cmd_per_lun = 1,
2306 .use_clustering = ENABLE_CLUSTERING, 2306 .use_clustering = ENABLE_CLUSTERING,
2307 .max_sectors = 0x4000, /* 8MiB = 16 * 1024 * 512 */
2307}; 2308};
2308 2309
2309/*********************************************************************** 2310/***********************************************************************
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index a8f894c78194..69715e556506 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -88,7 +88,7 @@ extern struct uart_cpm_port cpm_uart_ports[UART_NR];
88 88
89/* these are located in their respective files */ 89/* these are located in their respective files */
90void cpm_line_cr_cmd(int line, int cmd); 90void cpm_line_cr_cmd(int line, int cmd);
91int cpm_uart_init_portdesc(void); 91int __init cpm_uart_init_portdesc(void);
92int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con); 92int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
93void cpm_uart_freebuf(struct uart_cpm_port *pinfo); 93void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
94 94
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 0abb544ae63d..7a3b97fdf8d1 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -195,10 +195,8 @@ static void cpm_uart_start_tx(struct uart_port *port)
195 if (cpm_uart_tx_pump(port) != 0) { 195 if (cpm_uart_tx_pump(port) != 0) {
196 if (IS_SMC(pinfo)) { 196 if (IS_SMC(pinfo)) {
197 smcp->smc_smcm |= SMCM_TX; 197 smcp->smc_smcm |= SMCM_TX;
198 smcp->smc_smcmr |= SMCMR_TEN;
199 } else { 198 } else {
200 sccp->scc_sccm |= UART_SCCM_TX; 199 sccp->scc_sccm |= UART_SCCM_TX;
201 pinfo->sccp->scc_gsmrl |= SCC_GSMRL_ENT;
202 } 200 }
203 } 201 }
204} 202}
@@ -421,9 +419,10 @@ static int cpm_uart_startup(struct uart_port *port)
421 /* Startup rx-int */ 419 /* Startup rx-int */
422 if (IS_SMC(pinfo)) { 420 if (IS_SMC(pinfo)) {
423 pinfo->smcp->smc_smcm |= SMCM_RX; 421 pinfo->smcp->smc_smcm |= SMCM_RX;
424 pinfo->smcp->smc_smcmr |= SMCMR_REN; 422 pinfo->smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
425 } else { 423 } else {
426 pinfo->sccp->scc_sccm |= UART_SCCM_RX; 424 pinfo->sccp->scc_sccm |= UART_SCCM_RX;
425 pinfo->sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
427 } 426 }
428 427
429 if (!(pinfo->flags & FLAG_CONSOLE)) 428 if (!(pinfo->flags & FLAG_CONSOLE))
@@ -1350,11 +1349,10 @@ static int cpm_uart_init(void) {
1350 pr_info("cpm_uart: WARNING: no UART devices found on platform bus!\n"); 1349 pr_info("cpm_uart: WARNING: no UART devices found on platform bus!\n");
1351 pr_info( 1350 pr_info(
1352 "cpm_uart: the driver will guess configuration, but this mode is no longer supported.\n"); 1351 "cpm_uart: the driver will guess configuration, but this mode is no longer supported.\n");
1353#ifndef CONFIG_SERIAL_CPM_CONSOLE 1352
1354 ret = cpm_uart_init_portdesc(); 1353 /* Don't run this again, if the console driver did it already */
1355 if (ret) 1354 if (cpm_uart_nr == 0)
1356 return ret; 1355 cpm_uart_init_portdesc();
1357#endif
1358 1356
1359 cpm_reg.nr = cpm_uart_nr; 1357 cpm_reg.nr = cpm_uart_nr;
1360 ret = uart_register_driver(&cpm_reg); 1358 ret = uart_register_driver(&cpm_reg);
@@ -1366,6 +1364,8 @@ static int cpm_uart_init(void) {
1366 int con = cpm_uart_port_map[i]; 1364 int con = cpm_uart_port_map[i];
1367 cpm_uart_ports[con].port.line = i; 1365 cpm_uart_ports[con].port.line = i;
1368 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF; 1366 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF;
1367 if (cpm_uart_ports[con].set_lineif)
1368 cpm_uart_ports[con].set_lineif(&cpm_uart_ports[con]);
1369 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port); 1369 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port);
1370 } 1370 }
1371 1371
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
index 95afc37297a8..08e55fdc882a 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
@@ -184,7 +184,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
184} 184}
185 185
186/* Setup any dynamic params in the uart desc */ 186/* Setup any dynamic params in the uart desc */
187int cpm_uart_init_portdesc(void) 187int __init cpm_uart_init_portdesc(void)
188{ 188{
189 pr_debug("CPM uart[-]:init portdesc\n"); 189 pr_debug("CPM uart[-]:init portdesc\n");
190 190
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index ff4fa25f9fd1..711bd1511439 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -921,7 +921,7 @@ static void handle_dma_error_intr(void *arg, uint32_t other_ir)
921{ 921{
922 struct ioc4_port *port = (struct ioc4_port *)arg; 922 struct ioc4_port *port = (struct ioc4_port *)arg;
923 struct hooks *hooks = port->ip_hooks; 923 struct hooks *hooks = port->ip_hooks;
924 unsigned int flags; 924 unsigned long flags;
925 925
926 spin_lock_irqsave(&port->ip_lock, flags); 926 spin_lock_irqsave(&port->ip_lock, flags);
927 927
@@ -1834,7 +1834,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1834 struct ioc4_port *port = (struct ioc4_port *)arg; 1834 struct ioc4_port *port = (struct ioc4_port *)arg;
1835 struct hooks *hooks = port->ip_hooks; 1835 struct hooks *hooks = port->ip_hooks;
1836 unsigned int rx_high_rd_aborted = 0; 1836 unsigned int rx_high_rd_aborted = 0;
1837 unsigned int flags; 1837 unsigned long flags;
1838 struct uart_port *the_port; 1838 struct uart_port *the_port;
1839 int loop_counter; 1839 int loop_counter;
1840 1840
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 146298ad7371..c3c0626f550b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -281,7 +281,6 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
281 up(&board_lock); 281 up(&board_lock);
282 return 0; 282 return 0;
283} 283}
284EXPORT_SYMBOL_GPL(spi_register_board_info);
285 284
286/* FIXME someone should add support for a __setup("spi", ...) that 285/* FIXME someone should add support for a __setup("spi", ...) that
287 * creates board info from kernel command lines 286 * creates board info from kernel command lines
diff --git a/drivers/telephony/ixj.h b/drivers/telephony/ixj.h
index fbea4541c234..8d69bcdc29c9 100644
--- a/drivers/telephony/ixj.h
+++ b/drivers/telephony/ixj.h
@@ -1295,7 +1295,7 @@ typedef struct {
1295 Proc_Info_Type Info_write; 1295 Proc_Info_Type Info_write;
1296 unsigned short frame_count; 1296 unsigned short frame_count;
1297 unsigned int filter_hist[4]; 1297 unsigned int filter_hist[4];
1298 unsigned char filter_en[4]; 1298 unsigned char filter_en[6];
1299 unsigned short proc_load; 1299 unsigned short proc_load;
1300 unsigned long framesread; 1300 unsigned long framesread;
1301 unsigned long frameswritten; 1301 unsigned long frameswritten;
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 809d465eb257..6303970e93c1 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -722,6 +722,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
722 usblp->wcomplete = 0; 722 usblp->wcomplete = 0;
723 err = usb_submit_urb(usblp->writeurb, GFP_KERNEL); 723 err = usb_submit_urb(usblp->writeurb, GFP_KERNEL);
724 if (err) { 724 if (err) {
725 usblp->wcomplete = 1;
725 if (err != -ENOMEM) 726 if (err != -ENOMEM)
726 count = -EIO; 727 count = -EIO;
727 else 728 else
@@ -1202,8 +1203,6 @@ static int usblp_suspend (struct usb_interface *intf, pm_message_t message)
1202 down (&usblp->sem); 1203 down (&usblp->sem);
1203 /* we take no more IO */ 1204 /* we take no more IO */
1204 usblp->sleeping = 1; 1205 usblp->sleeping = 1;
1205 /* we wait for anything printing */
1206 wait_event (usblp->wait, usblp->wcomplete || !usblp->present);
1207 usblp_unlink_urbs(usblp); 1206 usblp_unlink_urbs(usblp);
1208 up (&usblp->sem); 1207 up (&usblp->sem);
1209 mutex_unlock (&usblp_mutex); 1208 mutex_unlock (&usblp_mutex);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 66bff184a30c..ba165aff9ea4 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1188,6 +1188,7 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1188 1188
1189#ifdef CONFIG_USB_OTG 1189#ifdef CONFIG_USB_OTG
1190#include "otg_whitelist.h" 1190#include "otg_whitelist.h"
1191static int __usb_port_suspend(struct usb_device *, int port1);
1191#endif 1192#endif
1192 1193
1193/** 1194/**
@@ -1289,8 +1290,6 @@ int usb_new_device(struct usb_device *udev)
1289 * (Includes HNP test device.) 1290 * (Includes HNP test device.)
1290 */ 1291 */
1291 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 1292 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1292 static int __usb_port_suspend(struct usb_device *,
1293 int port1);
1294 err = __usb_port_suspend(udev, udev->bus->otg_port); 1293 err = __usb_port_suspend(udev, udev->bus->otg_port);
1295 if (err < 0) 1294 if (err < 0)
1296 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 1295 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index fccd1952bad3..7729c0744886 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -828,10 +828,7 @@ char *usb_cache_string(struct usb_device *udev, int index)
828 * Context: !in_interrupt () 828 * Context: !in_interrupt ()
829 * 829 *
830 * Updates the copy of the device descriptor stored in the device structure, 830 * Updates the copy of the device descriptor stored in the device structure,
831 * which dedicates space for this purpose. Note that several fields are 831 * which dedicates space for this purpose.
832 * converted to the host CPU's byte order: the USB version (bcdUSB), and
833 * vendors product and version fields (idVendor, idProduct, and bcdDevice).
834 * That lets device drivers compare against non-byteswapped constants.
835 * 832 *
836 * Not exported, only for use by the core. If drivers really want to read 833 * Not exported, only for use by the core. If drivers really want to read
837 * the device descriptor directly, they can call usb_get_descriptor() with 834 * the device descriptor directly, they can call usb_get_descriptor() with
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 9be6b303e784..ea4714e557e4 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -715,13 +715,6 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
715 return IRQ_NOTMINE; 715 return IRQ_NOTMINE;
716 } 716 }
717 717
718 if (ints & OHCI_INTR_RHSC) {
719 ohci_vdbg (ohci, "rhsc\n");
720 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
721 ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrstatus);
722 usb_hcd_poll_rh_status(hcd);
723 }
724
725 if (ints & OHCI_INTR_UE) { 718 if (ints & OHCI_INTR_UE) {
726 disable (ohci); 719 disable (ohci);
727 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); 720 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
@@ -731,9 +724,21 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
731 ohci_usb_reset (ohci); 724 ohci_usb_reset (ohci);
732 } 725 }
733 726
734 if (ints & OHCI_INTR_RD) { 727 if (ints & OHCI_INTR_RHSC) {
735 ohci_vdbg (ohci, "resume detect\n"); 728 ohci_vdbg(ohci, "rhsc\n");
736 ohci_writel (ohci, OHCI_INTR_RD, &regs->intrstatus); 729 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
730 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
731 &regs->intrstatus);
732 usb_hcd_poll_rh_status(hcd);
733 }
734
735 /* For connect and disconnect events, we expect the controller
736 * to turn on RHSC along with RD. But for remote wakeup events
737 * this might not happen.
738 */
739 else if (ints & OHCI_INTR_RD) {
740 ohci_vdbg(ohci, "resume detect\n");
741 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
737 hcd->poll_rh = 1; 742 hcd->poll_rh = 1;
738 if (ohci->autostop) { 743 if (ohci->autostop) {
739 spin_lock (&ohci->lock); 744 spin_lock (&ohci->lock);
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 6f113596af66..6995ea36f2e8 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -169,7 +169,8 @@ __acquires(ohci->lock)
169 break; 169 break;
170 case OHCI_USB_RESUME: 170 case OHCI_USB_RESUME:
171 /* HCFS changes sometime after INTR_RD */ 171 /* HCFS changes sometime after INTR_RD */
172 ohci_info (ohci, "wakeup\n"); 172 ohci_info(ohci, "%swakeup\n",
173 autostopped ? "auto-" : "");
173 break; 174 break;
174 case OHCI_USB_OPER: 175 case OHCI_USB_OPER:
175 /* this can happen after resuming a swsusp snapshot */ 176 /* this can happen after resuming a swsusp snapshot */
@@ -422,7 +423,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
422 ohci->autostop = 0; 423 ohci->autostop = 0;
423 ohci->next_statechange = jiffies + 424 ohci->next_statechange = jiffies +
424 STATECHANGE_DELAY; 425 STATECHANGE_DELAY;
425 } else if (time_after_eq (jiffies, 426 } else if (device_may_wakeup(&hcd->self.root_hub->dev)
427 && time_after_eq(jiffies,
426 ohci->next_statechange) 428 ohci->next_statechange)
427 && !ohci->ed_rm_list 429 && !ohci->ed_rm_list
428 && !(ohci->hc_control & 430 && !(ohci->hc_control &
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index f659f3028ad2..787b847d38cc 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -636,13 +636,11 @@ static void ati_remote_free_buffers(struct ati_remote *ati_remote)
636 if (ati_remote->out_urb) 636 if (ati_remote->out_urb)
637 usb_free_urb(ati_remote->out_urb); 637 usb_free_urb(ati_remote->out_urb);
638 638
639 if (ati_remote->inbuf) 639 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
640 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 640 ati_remote->inbuf, ati_remote->inbuf_dma);
641 ati_remote->inbuf, ati_remote->inbuf_dma);
642 641
643 if (ati_remote->outbuf) 642 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
644 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 643 ati_remote->outbuf, ati_remote->outbuf_dma);
645 ati_remote->inbuf, ati_remote->outbuf_dma);
646} 644}
647 645
648static void ati_remote_input_init(struct ati_remote *ati_remote) 646static void ati_remote_input_init(struct ati_remote *ati_remote)
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 45f44fe33bfe..6d08a3bcc952 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -270,7 +270,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
270 * Read data value from item. 270 * Read data value from item.
271 */ 271 */
272 272
273static __inline__ __u32 item_udata(struct hid_item *item) 273static u32 item_udata(struct hid_item *item)
274{ 274{
275 switch (item->size) { 275 switch (item->size) {
276 case 1: return item->data.u8; 276 case 1: return item->data.u8;
@@ -280,7 +280,7 @@ static __inline__ __u32 item_udata(struct hid_item *item)
280 return 0; 280 return 0;
281} 281}
282 282
283static __inline__ __s32 item_sdata(struct hid_item *item) 283static s32 item_sdata(struct hid_item *item)
284{ 284{
285 switch (item->size) { 285 switch (item->size) {
286 case 1: return item->data.s8; 286 case 1: return item->data.s8;
@@ -727,7 +727,7 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
727 * done by hand. 727 * done by hand.
728 */ 728 */
729 729
730static __inline__ __s32 snto32(__u32 value, unsigned n) 730static s32 snto32(__u32 value, unsigned n)
731{ 731{
732 switch (n) { 732 switch (n) {
733 case 8: return ((__s8)value); 733 case 8: return ((__s8)value);
@@ -741,9 +741,9 @@ static __inline__ __s32 snto32(__u32 value, unsigned n)
741 * Convert a signed 32-bit integer to a signed n-bit integer. 741 * Convert a signed 32-bit integer to a signed n-bit integer.
742 */ 742 */
743 743
744static __inline__ __u32 s32ton(__s32 value, unsigned n) 744static u32 s32ton(__s32 value, unsigned n)
745{ 745{
746 __s32 a = value >> (n - 1); 746 s32 a = value >> (n - 1);
747 if (a && a != -1) 747 if (a && a != -1)
748 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 748 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
749 return value & ((1 << n) - 1); 749 return value & ((1 << n) - 1);
@@ -751,30 +751,55 @@ static __inline__ __u32 s32ton(__s32 value, unsigned n)
751 751
752/* 752/*
753 * Extract/implement a data field from/to a little endian report (bit array). 753 * Extract/implement a data field from/to a little endian report (bit array).
754 *
755 * Code sort-of follows HID spec:
756 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf
757 *
758 * While the USB HID spec allows unlimited length bit fields in "report
759 * descriptors", most devices never use more than 16 bits.
760 * One model of UPS is claimed to report "LINEV" as a 32-bit field.
761 * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
754 */ 762 */
755 763
756static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) 764static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
757{ 765{
758 u32 x; 766 u64 x;
767
768 WARN_ON(n > 32);
759 769
760 report += offset >> 3; /* adjust byte index */ 770 report += offset >> 3; /* adjust byte index */
761 offset &= 8 - 1; 771 offset &= 7; /* now only need bit offset into one byte */
762 x = get_unaligned((u32 *) report); 772 x = get_unaligned((u64 *) report);
763 x = le32_to_cpu(x); 773 x = le64_to_cpu(x);
764 x = (x >> offset) & ((1 << n) - 1); 774 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
765 return x; 775 return (u32) x;
766} 776}
767 777
778/*
779 * "implement" : set bits in a little endian bit stream.
780 * Same concepts as "extract" (see comments above).
781 * The data mangled in the bit stream remains in little endian
782 * order the whole time. It make more sense to talk about
783 * endianness of register values by considering a register
784 * a "cached" copy of the little endiad bit stream.
785 */
768static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) 786static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
769{ 787{
770 u32 x; 788 u64 x;
789 u64 m = (1ULL << n) - 1;
790
791 WARN_ON(n > 32);
792
793 WARN_ON(value > m);
794 value &= m;
771 795
772 report += offset >> 3; 796 report += offset >> 3;
773 offset &= 8 - 1; 797 offset &= 7;
774 x = get_unaligned((u32 *)report); 798
775 x &= cpu_to_le32(~((((__u32) 1 << n) - 1) << offset)); 799 x = get_unaligned((u64 *)report);
776 x |= cpu_to_le32(value << offset); 800 x &= cpu_to_le64(~(m << offset));
777 put_unaligned(x,(u32 *)report); 801 x |= cpu_to_le64(((u64) value) << offset);
802 put_unaligned(x, (u64 *) report);
778} 803}
779 804
780/* 805/*
@@ -1615,6 +1640,9 @@ void hid_init_reports(struct hid_device *hid)
1615#define USB_VENDOR_ID_SUN 0x0430 1640#define USB_VENDOR_ID_SUN 0x0430
1616#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab 1641#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
1617 1642
1643#define USB_VENDOR_ID_AIRCABLE 0x16CA
1644#define USB_DEVICE_ID_AIRCABLE1 0x1502
1645
1618/* 1646/*
1619 * Alphabetically sorted blacklist by quirk type. 1647 * Alphabetically sorted blacklist by quirk type.
1620 */ 1648 */
@@ -1632,6 +1660,7 @@ static const struct hid_blacklist {
1632 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE }, 1660 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE },
1633 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE }, 1661 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE },
1634 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE }, 1662 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE },
1663 { USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1, HID_QUIRK_IGNORE },
1635 { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE }, 1664 { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE },
1636 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE }, 1665 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE },
1637 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE }, 1666 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE },
@@ -1768,11 +1797,12 @@ static const struct hid_blacklist {
1768 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN }, 1797 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN },
1769 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN }, 1798 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN },
1770 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN }, 1799 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN },
1771 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN }, 1800 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1772 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN }, 1801 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN },
1773 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN }, 1802 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN },
1774 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN }, 1803 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1775 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN }, 1804 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN },
1805 { USB_VENDOR_ID_APPLE, 0x021B, HID_QUIRK_POWERBOOK_HAS_FN },
1776 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN }, 1806 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN },
1777 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN }, 1807 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN },
1778 1808
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 9a808a3b4d37..68e7ebb978a9 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -121,6 +121,12 @@ static struct hidinput_key_translation powerbook_numlock_keys[] = {
121 { } 121 { }
122}; 122};
123 123
124static struct hidinput_key_translation powerbook_iso_keyboard[] = {
125 { KEY_GRAVE, KEY_102ND },
126 { KEY_102ND, KEY_GRAVE },
127 { }
128};
129
124static int usbhid_pb_fnmode = 1; 130static int usbhid_pb_fnmode = 1;
125module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644); 131module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
126MODULE_PARM_DESC(pb_fnmode, 132MODULE_PARM_DESC(pb_fnmode,
@@ -195,6 +201,14 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
195 } 201 }
196 } 202 }
197 203
204 if (hid->quirks & HID_QUIRK_POWERBOOK_ISO_KEYBOARD) {
205 trans = find_translation(powerbook_iso_keyboard, usage->code);
206 if (trans) {
207 input_event(input, usage->type, trans->to, value);
208 return 1;
209 }
210 }
211
198 return 0; 212 return 0;
199} 213}
200 214
@@ -210,6 +224,9 @@ static void hidinput_pb_setup(struct input_dev *input)
210 224
211 for (trans = powerbook_numlock_keys; trans->from; trans++) 225 for (trans = powerbook_numlock_keys; trans->from; trans++)
212 set_bit(trans->to, input->keybit); 226 set_bit(trans->to, input->keybit);
227
228 for (trans = powerbook_iso_keyboard; trans->from; trans++)
229 set_bit(trans->to, input->keybit);
213} 230}
214#else 231#else
215static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, 232static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index 9b50effef758..0e76e6dcac37 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -260,6 +260,7 @@ struct hid_item {
260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000 260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000 261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
262#define HID_QUIRK_INVERT_HWHEEL 0x00004000 262#define HID_QUIRK_INVERT_HWHEEL 0x00004000
263#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00008000
263 264
264/* 265/*
265 * This is the global environment of the parser. This information is 266 * This is the global environment of the parser. This information is
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 2902742895ad..933ceddf3dee 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -640,7 +640,7 @@ static int usbtouch_probe(struct usb_interface *intf,
640 type->max_press, 0, 0); 640 type->max_press, 0, 0);
641 641
642 usb_fill_int_urb(usbtouch->irq, usbtouch->udev, 642 usb_fill_int_urb(usbtouch->irq, usbtouch->udev,
643 usb_rcvintpipe(usbtouch->udev, 0x81), 643 usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress),
644 usbtouch->data, type->rept_size, 644 usbtouch->data, type->rept_size,
645 usbtouch_irq, usbtouch, endpoint->bInterval); 645 usbtouch_irq, usbtouch, endpoint->bInterval);
646 646
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index 6a12a943b938..df97e5c803f9 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -2,6 +2,10 @@
2 * X-Box gamepad - v0.0.6 2 * X-Box gamepad - v0.0.6
3 * 3 *
4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de> 4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
5 * 2004 Oliver Schwartz <Oliver.Schwartz@gmx.de>,
6 * Steven Toth <steve@toth.demon.co.uk>,
7 * Franz Lehner <franz@caos.at>,
8 * Ivan Hawkes <blackhawk@ivanhawkes.com>
5 * 2005 Dominic Cerquetti <binary1230@yahoo.com> 9 * 2005 Dominic Cerquetti <binary1230@yahoo.com>
6 * 2006 Adam Buchbinder <adam.buchbinder@gmail.com> 10 * 2006 Adam Buchbinder <adam.buchbinder@gmail.com>
7 * 11 *
@@ -29,6 +33,7 @@
29 * - ITO Takayuki for providing essential xpad information on his website 33 * - ITO Takayuki for providing essential xpad information on his website
30 * - Vojtech Pavlik - iforce driver / input subsystem 34 * - Vojtech Pavlik - iforce driver / input subsystem
31 * - Greg Kroah-Hartman - usb-skeleton driver 35 * - Greg Kroah-Hartman - usb-skeleton driver
36 * - XBOX Linux project - extra USB id's
32 * 37 *
33 * TODO: 38 * TODO:
34 * - fine tune axes (especially trigger axes) 39 * - fine tune axes (especially trigger axes)
@@ -54,6 +59,13 @@
54 * - fixed d-pad to axes mapping 59 * - fixed d-pad to axes mapping
55 * 60 *
56 * 2002-07-17 - 0.0.5 : simplified d-pad handling 61 * 2002-07-17 - 0.0.5 : simplified d-pad handling
62 *
63 * 2004-10-02 - 0.0.6 : DDR pad support
64 * - borrowed from the XBOX linux kernel
65 * - USB id's for commonly used dance pads are present
66 * - dance pads will map D-PAD to buttons, not axes
67 * - pass the module paramater 'dpad_to_buttons' to force
68 * the D-PAD to map to buttons if your pad is not detected
57 */ 69 */
58 70
59#include <linux/kernel.h> 71#include <linux/kernel.h>
@@ -90,8 +102,35 @@ static const struct xpad_device {
90 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES }, 102 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES },
91 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES }, 103 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES },
92 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES }, 104 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES },
93 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES }, 105 { 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES },
94 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS }, 106 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS },
107 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES },
108 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES },
109 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES },
110 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES },
111 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES },
112 { 0x0738, 0x4516, "Mad Catz Control Pad", MAP_DPAD_TO_AXES },
113 { 0x0738, 0x4522, "Mad Catz LumiCON", MAP_DPAD_TO_AXES },
114 { 0x0738, 0x4526, "Mad Catz Control Pad Pro", MAP_DPAD_TO_AXES },
115 { 0x0738, 0x4536, "Mad Catz MicroCON", MAP_DPAD_TO_AXES },
116 { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS },
117 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", MAP_DPAD_TO_AXES },
118 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS },
119 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES },
120 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES },
121 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES },
122 { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES },
123 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", MAP_DPAD_TO_AXES},
124 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", MAP_DPAD_TO_AXES },
125 { 0x0e6f, 0x0005, "Eclipse wireless Controller", MAP_DPAD_TO_AXES },
126 { 0x0e6f, 0x0006, "Edge wireless Controller", MAP_DPAD_TO_AXES },
127 { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", MAP_DPAD_TO_AXES },
128 { 0x0f30, 0x0202, "Joytech Advanced Controller", MAP_DPAD_TO_AXES },
129 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES },
130 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES },
131 { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS },
132 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS },
133 { 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES },
95 { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN } 134 { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN }
96}; 135};
97 136
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 0be9d62d62ae..e4971d6aaafb 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -780,7 +780,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
780 780
781bl_fail:/* not enough memory. Free allocated elements */ 781bl_fail:/* not enough memory. Free allocated elements */
782 dbg ("auerbuf_setup: no more memory"); 782 dbg ("auerbuf_setup: no more memory");
783 kfree(bep); 783 auerbuf_free(bep);
784 auerbuf_free_buffers (bcp); 784 auerbuf_free_buffers (bcp);
785 return -ENOMEM; 785 return -ENOMEM;
786} 786}
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
index 454a186b64ad..e081836014ac 100644
--- a/drivers/usb/net/Kconfig
+++ b/drivers/usb/net/Kconfig
@@ -92,8 +92,13 @@ config USB_RTL8150
92 To compile this driver as a module, choose M here: the 92 To compile this driver as a module, choose M here: the
93 module will be called rtl8150. 93 module will be called rtl8150.
94 94
95config USB_USBNET_MII
96 tristate
97 default n
98
95config USB_USBNET 99config USB_USBNET
96 tristate "Multi-purpose USB Networking Framework" 100 tristate "Multi-purpose USB Networking Framework"
101 select MII if USBNET_MII != n
97 ---help--- 102 ---help---
98 This driver supports several kinds of network links over USB, 103 This driver supports several kinds of network links over USB,
99 with "minidrivers" built around a common network driver core 104 with "minidrivers" built around a common network driver core
@@ -129,7 +134,7 @@ config USB_NET_AX8817X
129 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" 134 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters"
130 depends on USB_USBNET && NET_ETHERNET 135 depends on USB_USBNET && NET_ETHERNET
131 select CRC32 136 select CRC32
132 select MII 137 select USB_USBNET_MII
133 default y 138 default y
134 help 139 help
135 This option adds support for ASIX AX88xxx based USB 2.0 140 This option adds support for ASIX AX88xxx based USB 2.0
@@ -210,6 +215,7 @@ config USB_NET_PLUSB
210config USB_NET_MCS7830 215config USB_NET_MCS7830
211 tristate "MosChip MCS7830 based Ethernet adapters" 216 tristate "MosChip MCS7830 based Ethernet adapters"
212 depends on USB_USBNET 217 depends on USB_USBNET
218 select USB_USBNET_MII
213 help 219 help
214 Choose this option if you're using a 10/100 Ethernet USB2 220 Choose this option if you're using a 10/100 Ethernet USB2
215 adapter based on the MosChip 7830 controller. This includes 221 adapter based on the MosChip 7830 controller. This includes
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index cf3d20eb781c..760b5327b81b 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -554,7 +554,7 @@ static int usbnet_stop (struct net_device *net)
554{ 554{
555 struct usbnet *dev = netdev_priv(net); 555 struct usbnet *dev = netdev_priv(net);
556 int temp; 556 int temp;
557 DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); 557 DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
558 DECLARE_WAITQUEUE (wait, current); 558 DECLARE_WAITQUEUE (wait, current);
559 559
560 netif_stop_queue (net); 560 netif_stop_queue (net);
@@ -669,6 +669,9 @@ done:
669 * they'll probably want to use this base set. 669 * they'll probably want to use this base set.
670 */ 670 */
671 671
672#if defined(CONFIG_MII) || defined(CONFIG_MII_MODULE)
673#define HAVE_MII
674
672int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd) 675int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
673{ 676{
674 struct usbnet *dev = netdev_priv(net); 677 struct usbnet *dev = netdev_priv(net);
@@ -699,20 +702,6 @@ int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
699} 702}
700EXPORT_SYMBOL_GPL(usbnet_set_settings); 703EXPORT_SYMBOL_GPL(usbnet_set_settings);
701 704
702
703void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
704{
705 struct usbnet *dev = netdev_priv(net);
706
707 /* REVISIT don't always return "usbnet" */
708 strncpy (info->driver, driver_name, sizeof info->driver);
709 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
710 strncpy (info->fw_version, dev->driver_info->description,
711 sizeof info->fw_version);
712 usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
713}
714EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
715
716u32 usbnet_get_link (struct net_device *net) 705u32 usbnet_get_link (struct net_device *net)
717{ 706{
718 struct usbnet *dev = netdev_priv(net); 707 struct usbnet *dev = netdev_priv(net);
@@ -730,40 +719,57 @@ u32 usbnet_get_link (struct net_device *net)
730} 719}
731EXPORT_SYMBOL_GPL(usbnet_get_link); 720EXPORT_SYMBOL_GPL(usbnet_get_link);
732 721
733u32 usbnet_get_msglevel (struct net_device *net) 722int usbnet_nway_reset(struct net_device *net)
734{ 723{
735 struct usbnet *dev = netdev_priv(net); 724 struct usbnet *dev = netdev_priv(net);
736 725
737 return dev->msg_enable; 726 if (!dev->mii.mdio_write)
727 return -EOPNOTSUPP;
728
729 return mii_nway_restart(&dev->mii);
738} 730}
739EXPORT_SYMBOL_GPL(usbnet_get_msglevel); 731EXPORT_SYMBOL_GPL(usbnet_nway_reset);
740 732
741void usbnet_set_msglevel (struct net_device *net, u32 level) 733#endif /* HAVE_MII */
734
735void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
742{ 736{
743 struct usbnet *dev = netdev_priv(net); 737 struct usbnet *dev = netdev_priv(net);
744 738
745 dev->msg_enable = level; 739 /* REVISIT don't always return "usbnet" */
740 strncpy (info->driver, driver_name, sizeof info->driver);
741 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
742 strncpy (info->fw_version, dev->driver_info->description,
743 sizeof info->fw_version);
744 usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
746} 745}
747EXPORT_SYMBOL_GPL(usbnet_set_msglevel); 746EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
748 747
749int usbnet_nway_reset(struct net_device *net) 748u32 usbnet_get_msglevel (struct net_device *net)
750{ 749{
751 struct usbnet *dev = netdev_priv(net); 750 struct usbnet *dev = netdev_priv(net);
752 751
753 if (!dev->mii.mdio_write) 752 return dev->msg_enable;
754 return -EOPNOTSUPP; 753}
754EXPORT_SYMBOL_GPL(usbnet_get_msglevel);
755 755
756 return mii_nway_restart(&dev->mii); 756void usbnet_set_msglevel (struct net_device *net, u32 level)
757{
758 struct usbnet *dev = netdev_priv(net);
759
760 dev->msg_enable = level;
757} 761}
758EXPORT_SYMBOL_GPL(usbnet_nway_reset); 762EXPORT_SYMBOL_GPL(usbnet_set_msglevel);
759 763
760/* drivers may override default ethtool_ops in their bind() routine */ 764/* drivers may override default ethtool_ops in their bind() routine */
761static struct ethtool_ops usbnet_ethtool_ops = { 765static struct ethtool_ops usbnet_ethtool_ops = {
766#ifdef HAVE_MII
762 .get_settings = usbnet_get_settings, 767 .get_settings = usbnet_get_settings,
763 .set_settings = usbnet_set_settings, 768 .set_settings = usbnet_set_settings,
764 .get_drvinfo = usbnet_get_drvinfo,
765 .get_link = usbnet_get_link, 769 .get_link = usbnet_get_link,
766 .nway_reset = usbnet_nway_reset, 770 .nway_reset = usbnet_nway_reset,
771#endif
772 .get_drvinfo = usbnet_get_drvinfo,
767 .get_msglevel = usbnet_get_msglevel, 773 .get_msglevel = usbnet_get_msglevel,
768 .set_msglevel = usbnet_set_msglevel, 774 .set_msglevel = usbnet_set_msglevel,
769}; 775};
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 9a6ec1b5e3d5..2a8dd4cc943d 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -54,10 +54,10 @@ config USB_SERIAL_GENERIC
54 properly. 54 properly.
55 55
56config USB_SERIAL_AIRCABLE 56config USB_SERIAL_AIRCABLE
57 tristate "AIRcable USB Bluetooth Dongle Driver (EXPERIMENTAL)" 57 tristate "USB AIRcable Bluetooth Dongle Driver (EXPERIMENTAL)"
58 depends on USB_SERIAL && EXPERIMENTAL 58 depends on USB_SERIAL && EXPERIMENTAL
59 help 59 help
60 Say Y here if you want to use AIRcable USB Bluetoot Dongle. 60 Say Y here if you want to use USB AIRcable Bluetooth Dongle.
61 61
62 To compile this driver as a module, choose M here: the module 62 To compile this driver as a module, choose M here: the module
63 will be called aircable. 63 will be called aircable.
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index bbf6532c26e5..f95d42c0d16a 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -64,6 +64,9 @@ static struct usb_device_id id_table [] = {
64 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ 64 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ 65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
66 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 66 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
67 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
68 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
69 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
67 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 70 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
68 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 71 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
69 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 72 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index bd76b4c11fcc..c186b4e73c72 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -311,6 +311,7 @@ static struct usb_device_id id_table_combined [] = {
311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, 311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) },
312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, 312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, 313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) },
314 { USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) },
314 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 315 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
315 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 317 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
@@ -511,6 +512,7 @@ static struct usb_device_id id_table_combined [] = {
511 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, 512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, 513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 514 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
515 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
514 { }, /* Optional parameter entry */ 516 { }, /* Optional parameter entry */
515 { } /* Terminating entry */ 517 { } /* Terminating entry */
516}; 518};
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index f0edb87d2dd5..bae117d359af 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -55,6 +55,9 @@
55/* iPlus device */ 55/* iPlus device */
56#define FTDI_IPLUS_PID 0xD070 /* Product Id */ 56#define FTDI_IPLUS_PID 0xD070 /* Product Id */
57 57
58/* DMX4ALL DMX Interfaces */
59#define FTDI_DMX4ALL 0xC850
60
58/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ 61/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
59/* they use the ftdi chipset for the USB interface and the vendor id is the same */ 62/* they use the ftdi chipset for the USB interface and the vendor id is the same */
60#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 63#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
@@ -175,9 +178,15 @@
175#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ 178#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */
176 179
177/* 180/*
181 * FTDI USB UART chips used in construction projects from the
182 * Elektor Electronics magazine (http://elektor-electronics.co.uk)
183 */
184#define ELEKTOR_VID 0x0C7D
185#define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */
186
187/*
178 * DSS-20 Sync Station for Sony Ericsson P800 188 * DSS-20 Sync Station for Sony Ericsson P800
179 */ 189 */
180
181#define FTDI_DSS20_PID 0xFC82 190#define FTDI_DSS20_PID 0xFC82
182 191
183/* 192/*
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 6238aff1e772..d72cf8bc7f76 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -320,6 +320,7 @@ static struct usb_device_id ipaq_id_table [] = {
320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */ 320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */
321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */ 321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */
322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */ 322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */
323 { USB_DEVICE(0x0BB4, 0x00CF) }, /* HTC USB Modem */
323 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */ 324 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */
324 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */ 325 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */
325 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */ 326 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index ea16572d19f8..4b5097fa48d7 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -35,6 +35,7 @@ static struct usb_device_id id_table [] = {
35 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 35 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
36 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 36 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
38 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
38 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 39 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
39 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 40 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
40 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */ 41 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
@@ -58,8 +59,10 @@ static struct usb_device_id id_table_3port [] = {
58 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 59 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
59 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 60 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
60 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 61 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
62 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
61 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 63 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
62 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 64 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
65 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
63 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */ 66 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
64 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 67 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
65 { } 68 { }
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 37ed8e0f2dc8..efb047f431e8 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1236,7 +1236,7 @@ UNUSUAL_DEV( 0x0e21, 0x0520, 0x0100, 0x0100,
1236 "Cowon Systems", 1236 "Cowon Systems",
1237 "iAUDIO M5", 1237 "iAUDIO M5",
1238 US_SC_DEVICE, US_PR_BULK, NULL, 1238 US_SC_DEVICE, US_PR_BULK, NULL,
1239 0 ), 1239 US_FL_NEED_OVERRIDE ),
1240 1240
1241/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */ 1241/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */
1242UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300, 1242UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
@@ -1306,18 +1306,13 @@ UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1306 US_SC_DEVICE, US_PR_DEVICE, NULL, 1306 US_SC_DEVICE, US_PR_DEVICE, NULL,
1307 US_FL_FIX_CAPACITY ), 1307 US_FL_FIX_CAPACITY ),
1308 1308
1309/* Reported by Jan Mate <mate@fiit.stuba.sk> */
1310UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1311 "Sony Ericsson",
1312 "P990i",
1313 US_SC_DEVICE, US_PR_DEVICE, NULL,
1314 US_FL_FIX_CAPACITY ),
1315
1316/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1309/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
1317 * Tested on hardware version 1.10. 1310 * Tested on hardware version 1.10.
1318 * Entry is needed only for the initializer function override. 1311 * Entry is needed only for the initializer function override.
1312 * Devices with bcd > 110 seem to not need it while those
1313 * with bcd < 110 appear to need it.
1319 */ 1314 */
1320UNUSUAL_DEV( 0x1019, 0x0c55, 0x0110, 0x0110, 1315UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
1321 "Desknote", 1316 "Desknote",
1322 "UCR-61S2B", 1317 "UCR-61S2B",
1323 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1318 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index b77b30923928..e815b354c09d 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -406,7 +406,7 @@ static struct {
406 { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 135, ATI_CHIP_264LTPRO }, 406 { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 135, ATI_CHIP_264LTPRO },
407 { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 407 { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
408 { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 }, 408 { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 },
409 { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 409 { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1024x768 },
410 { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 410 { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
411 411
412 { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL }, 412 { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL },
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 676754520099..869725a13c21 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -139,7 +139,13 @@ void radeon_delete_i2c_busses(struct radeonfb_info *rinfo)
139int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn, 139int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn,
140 u8 **out_edid) 140 u8 **out_edid)
141{ 141{
142 u8 *edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter); 142 u32 reg = rinfo->i2c[conn-1].ddc_reg;
143 u8 *edid;
144
145 OUTREG(reg, INREG(reg) &
146 ~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
147
148 edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter);
143 149
144 if (out_edid) 150 if (out_edid)
145 *out_edid = edid; 151 *out_edid = edid;
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index 2ebbfd95145f..d07ecb53c68b 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -111,7 +111,7 @@ static struct backlight_properties corgibl_data = {
111 .update_status = corgibl_set_intensity, 111 .update_status = corgibl_set_intensity,
112}; 112};
113 113
114static int __init corgibl_probe(struct platform_device *pdev) 114static int corgibl_probe(struct platform_device *pdev)
115{ 115{
116 struct corgibl_machinfo *machinfo = pdev->dev.platform_data; 116 struct corgibl_machinfo *machinfo = pdev->dev.platform_data;
117 117
@@ -166,4 +166,4 @@ module_exit(corgibl_exit);
166 166
167MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); 167MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
168MODULE_DESCRIPTION("Corgi Backlight Driver"); 168MODULE_DESCRIPTION("Corgi Backlight Driver");
169MODULE_LICENSE("GPLv2"); 169MODULE_LICENSE("GPL");
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index fe1488374f62..e3993213d10e 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -19,7 +19,7 @@
19#include <linux/backlight.h> 19#include <linux/backlight.h>
20 20
21#include <asm/cpu/dac.h> 21#include <asm/cpu/dac.h>
22#include <asm/hp6xx/hp6xx.h> 22#include <asm/hp6xx.h>
23#include <asm/hd64461.h> 23#include <asm/hd64461.h>
24 24
25#define HP680_MAX_INTENSITY 255 25#define HP680_MAX_INTENSITY 255
diff --git a/drivers/video/fb_ddc.c b/drivers/video/fb_ddc.c
index 3aa6ebf68f17..f836137a0eda 100644
--- a/drivers/video/fb_ddc.c
+++ b/drivers/video/fb_ddc.c
@@ -20,26 +20,26 @@
20static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter *adapter) 20static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter *adapter)
21{ 21{
22 unsigned char start = 0x0; 22 unsigned char start = 0x0;
23 unsigned char *buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
23 struct i2c_msg msgs[] = { 24 struct i2c_msg msgs[] = {
24 { 25 {
25 .addr = DDC_ADDR, 26 .addr = DDC_ADDR,
27 .flags = 0,
26 .len = 1, 28 .len = 1,
27 .buf = &start, 29 .buf = &start,
28 }, { 30 }, {
29 .addr = DDC_ADDR, 31 .addr = DDC_ADDR,
30 .flags = I2C_M_RD, 32 .flags = I2C_M_RD,
31 .len = EDID_LENGTH, 33 .len = EDID_LENGTH,
34 .buf = buf,
32 } 35 }
33 }; 36 };
34 unsigned char *buf;
35 37
36 buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
37 if (!buf) { 38 if (!buf) {
38 dev_warn(&adapter->dev, "unable to allocate memory for EDID " 39 dev_warn(&adapter->dev, "unable to allocate memory for EDID "
39 "block.\n"); 40 "block.\n");
40 return NULL; 41 return NULL;
41 } 42 }
42 msgs[1].buf = buf;
43 43
44 if (i2c_transfer(adapter, msgs, 2) == 2) 44 if (i2c_transfer(adapter, msgs, 2) == 2)
45 return buf; 45 return buf;
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 3afb472763c0..3dc49424dc75 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -29,7 +29,6 @@
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/hd64461.h> 30#include <asm/hd64461.h>
31#include <asm/cpu/dac.h> 31#include <asm/cpu/dac.h>
32#include <asm/hp6xx/hp6xx.h>
33 32
34#define WIDTH 640 33#define WIDTH 640
35 34
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index eeeeff9a09eb..a95836839e1e 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -161,7 +161,7 @@ intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
161 return 1; 161 return 1;
162 162
163 /* Find the bridge device. It is always 0:0.0 */ 163 /* Find the bridge device. It is always 0:0.0 */
164 if (!(bridge_dev = pci_find_slot(0, PCI_DEVFN(0, 0)))) { 164 if (!(bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)))) {
165 ERR_MSG("cannot find bridge device\n"); 165 ERR_MSG("cannot find bridge device\n");
166 return 1; 166 return 1;
167 } 167 }
@@ -169,6 +169,8 @@ intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
169 /* Get the fb aperture size and "stolen" memory amount. */ 169 /* Get the fb aperture size and "stolen" memory amount. */
170 tmp = 0; 170 tmp = 0;
171 pci_read_config_word(bridge_dev, INTEL_GMCH_CTRL, &tmp); 171 pci_read_config_word(bridge_dev, INTEL_GMCH_CTRL, &tmp);
172 pci_dev_put(bridge_dev);
173
172 switch (pdev->device) { 174 switch (pdev->device) {
173 case PCI_DEVICE_ID_INTEL_915G: 175 case PCI_DEVICE_ID_INTEL_915G:
174 case PCI_DEVICE_ID_INTEL_915GM: 176 case PCI_DEVICE_ID_INTEL_915GM:
@@ -662,7 +664,7 @@ intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw)
662 int index = dinfo->pll_index; 664 int index = dinfo->pll_index;
663 DBG_MSG("intelfbhw_print_hw_state\n"); 665 DBG_MSG("intelfbhw_print_hw_state\n");
664 666
665 if (!hw || !dinfo) 667 if (!hw)
666 return; 668 return;
667 /* Read in as much of the HW state as possible. */ 669 /* Read in as much of the HW state as possible. */
668 printk("hw state dump start\n"); 670 printk("hw state dump start\n");
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c
index 9ed640d35728..ea426115c6f9 100644
--- a/drivers/video/nvidia/nv_hw.c
+++ b/drivers/video/nvidia/nv_hw.c
@@ -145,12 +145,18 @@ static void nvGetClocks(struct nvidia_par *par, unsigned int *MClk,
145 145
146 if (par->Architecture >= NV_ARCH_40) { 146 if (par->Architecture >= NV_ARCH_40) {
147 pll = NV_RD32(par->PMC, 0x4020); 147 pll = NV_RD32(par->PMC, 0x4020);
148 P = (pll >> 16) & 0x03; 148 P = (pll >> 16) & 0x07;
149 pll = NV_RD32(par->PMC, 0x4024); 149 pll = NV_RD32(par->PMC, 0x4024);
150 M = pll & 0xFF; 150 M = pll & 0xFF;
151 N = (pll >> 8) & 0xFF; 151 N = (pll >> 8) & 0xFF;
152 MB = (pll >> 16) & 0xFF; 152 if (((par->Chipset & 0xfff0) == 0x0290) ||
153 NB = (pll >> 24) & 0xFF; 153 ((par->Chipset & 0xfff0) == 0x0390)) {
154 MB = 1;
155 NB = 1;
156 } else {
157 MB = (pll >> 16) & 0xFF;
158 NB = (pll >> 24) & 0xFF;
159 }
154 *MClk = ((N * NB * par->CrystalFreqKHz) / (M * MB)) >> P; 160 *MClk = ((N * NB * par->CrystalFreqKHz) / (M * MB)) >> P;
155 161
156 pll = NV_RD32(par->PMC, 0x4000); 162 pll = NV_RD32(par->PMC, 0x4000);
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c
index a18a9aebf05f..eab3e282a4de 100644
--- a/drivers/video/nvidia/nv_setup.c
+++ b/drivers/video/nvidia/nv_setup.c
@@ -262,7 +262,7 @@ static void nv10GetConfig(struct nvidia_par *par)
262#endif 262#endif
263 263
264 dev = pci_find_slot(0, 1); 264 dev = pci_find_slot(0, 1);
265 if ((par->Chipset && 0xffff) == 0x01a0) { 265 if ((par->Chipset & 0xffff) == 0x01a0) {
266 int amt = 0; 266 int amt = 0;
267 267
268 pci_read_config_dword(dev, 0x7c, &amt); 268 pci_read_config_dword(dev, 0x7c, &amt);
@@ -359,6 +359,7 @@ int NVCommonSetup(struct fb_info *info)
359 case 0x0186: 359 case 0x0186:
360 case 0x0187: 360 case 0x0187:
361 case 0x018D: 361 case 0x018D:
362 case 0x0228:
362 case 0x0286: 363 case 0x0286:
363 case 0x028C: 364 case 0x028C:
364 case 0x0316: 365 case 0x0316:
@@ -382,6 +383,10 @@ int NVCommonSetup(struct fb_info *info)
382 case 0x034C: 383 case 0x034C:
383 case 0x0160: 384 case 0x0160:
384 case 0x0166: 385 case 0x0166:
386 case 0x0169:
387 case 0x016B:
388 case 0x016C:
389 case 0x016D:
385 case 0x00C8: 390 case 0x00C8:
386 case 0x00CC: 391 case 0x00CC:
387 case 0x0144: 392 case 0x0144:
@@ -639,12 +644,23 @@ int NVCommonSetup(struct fb_info *info)
639 par->fpHeight = NV_RD32(par->PRAMDAC, 0x0800) + 1; 644 par->fpHeight = NV_RD32(par->PRAMDAC, 0x0800) + 1;
640 par->fpSyncs = NV_RD32(par->PRAMDAC, 0x0848) & 0x30000033; 645 par->fpSyncs = NV_RD32(par->PRAMDAC, 0x0848) & 0x30000033;
641 646
642 printk("Panel size is %i x %i\n", par->fpWidth, par->fpHeight); 647 printk("nvidiafb: Panel size is %i x %i\n", par->fpWidth, par->fpHeight);
643 } 648 }
644 649
645 if (monA) 650 if (monA)
646 info->monspecs = *monA; 651 info->monspecs = *monA;
647 652
653 if (!par->FlatPanel || !par->twoHeads)
654 par->FPDither = 0;
655
656 par->LVDS = 0;
657 if (par->FlatPanel && par->twoHeads) {
658 NV_WR32(par->PRAMDAC0, 0x08B0, 0x00010004);
659 if (par->PRAMDAC0[0x08b4] & 1)
660 par->LVDS = 1;
661 printk("nvidiafb: Panel is %s\n", par->LVDS ? "LVDS" : "TMDS");
662 }
663
648 kfree(edidA); 664 kfree(edidA);
649 kfree(edidB); 665 kfree(edidB);
650done: 666done:
diff --git a/drivers/video/nvidia/nv_type.h b/drivers/video/nvidia/nv_type.h
index acdc26693402..86e65dea60d3 100644
--- a/drivers/video/nvidia/nv_type.h
+++ b/drivers/video/nvidia/nv_type.h
@@ -129,6 +129,7 @@ struct nvidia_par {
129 int fpHeight; 129 int fpHeight;
130 int PanelTweak; 130 int PanelTweak;
131 int paneltweak; 131 int paneltweak;
132 int LVDS;
132 int pm_state; 133 int pm_state;
133 u32 crtcSync_read; 134 u32 crtcSync_read;
134 u32 fpSyncs; 135 u32 fpSyncs;
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index eb24107bcc81..538e947610e1 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -1160,20 +1160,20 @@ static u32 __devinit nvidia_get_arch(struct fb_info *info)
1160 case 0x0340: /* GeForceFX 5700 */ 1160 case 0x0340: /* GeForceFX 5700 */
1161 arch = NV_ARCH_30; 1161 arch = NV_ARCH_30;
1162 break; 1162 break;
1163 case 0x0040: 1163 case 0x0040: /* GeForce 6800 */
1164 case 0x00C0: 1164 case 0x00C0: /* GeForce 6800 */
1165 case 0x0120: 1165 case 0x0120: /* GeForce 6800 */
1166 case 0x0130: 1166 case 0x0130:
1167 case 0x0140: 1167 case 0x0140: /* GeForce 6600 */
1168 case 0x0160: 1168 case 0x0160: /* GeForce 6200 */
1169 case 0x01D0: 1169 case 0x01D0: /* GeForce 7200, 7300, 7400 */
1170 case 0x0090: 1170 case 0x0090: /* GeForce 7800 */
1171 case 0x0210: 1171 case 0x0210: /* GeForce 6800 */
1172 case 0x0220: 1172 case 0x0220: /* GeForce 6200 */
1173 case 0x0230: 1173 case 0x0230:
1174 case 0x0240: 1174 case 0x0240: /* GeForce 6100 */
1175 case 0x0290: 1175 case 0x0290: /* GeForce 7900 */
1176 case 0x0390: 1176 case 0x0390: /* GeForce 7600 */
1177 arch = NV_ARCH_40; 1177 arch = NV_ARCH_40;
1178 break; 1178 break;
1179 case 0x0020: /* TNT, TNT2 */ 1179 case 0x0020: /* TNT, TNT2 */
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index bad0e98fb3b6..9a40bbecf76b 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -157,7 +157,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
157 out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue)); 157 out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue));
158 break; 158 break;
159 case cmap_gxt2000: 159 case cmap_gxt2000:
160 out_le32((unsigned __iomem *) par->cmap_adr + regno, 160 out_le32(((unsigned __iomem *) par->cmap_adr) + regno,
161 (red << 16 | green << 8 | blue)); 161 (red << 16 | green << 8 | blue));
162 break; 162 break;
163 } 163 }
@@ -213,7 +213,7 @@ static int offb_blank(int blank, struct fb_info *info)
213 out_le32(par->cmap_adr + 0xb4, 0); 213 out_le32(par->cmap_adr + 0xb4, 0);
214 break; 214 break;
215 case cmap_gxt2000: 215 case cmap_gxt2000:
216 out_le32((unsigned __iomem *) par->cmap_adr + i, 216 out_le32(((unsigned __iomem *) par->cmap_adr) + i,
217 0); 217 0);
218 break; 218 break;
219 } 219 }
@@ -226,13 +226,23 @@ static int offb_blank(int blank, struct fb_info *info)
226static void __iomem *offb_map_reg(struct device_node *np, int index, 226static void __iomem *offb_map_reg(struct device_node *np, int index,
227 unsigned long offset, unsigned long size) 227 unsigned long offset, unsigned long size)
228{ 228{
229 struct resource r; 229 const u32 *addrp;
230 230 u64 asize, taddr;
231 if (of_address_to_resource(np, index, &r)) 231 unsigned int flags;
232 return 0; 232
233 if ((r.start + offset + size) > r.end) 233 addrp = of_get_pci_address(np, index, &asize, &flags);
234 return 0; 234 if (addrp == NULL)
235 return ioremap(r.start + offset, size); 235 addrp = of_get_address(np, index, &asize, &flags);
236 if (addrp == NULL)
237 return NULL;
238 if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
239 return NULL;
240 if ((offset + size) > asize)
241 return NULL;
242 taddr = of_translate_address(np, addrp);
243 if (taddr == OF_BAD_ADDR)
244 return NULL;
245 return ioremap(taddr + offset, size);
236} 246}
237 247
238static void __init offb_init_fb(const char *name, const char *full_name, 248static void __init offb_init_fb(const char *name, const char *full_name,
@@ -289,7 +299,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
289 299
290 par->cmap_type = cmap_unknown; 300 par->cmap_type = cmap_unknown;
291 if (depth == 8) { 301 if (depth == 8) {
292 /* Palette hacks disabled for now */
293 if (dp && !strncmp(name, "ATY,Rage128", 11)) { 302 if (dp && !strncmp(name, "ATY,Rage128", 11)) {
294 par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); 303 par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
295 if (par->cmap_adr) 304 if (par->cmap_adr)
@@ -313,7 +322,8 @@ static void __init offb_init_fb(const char *name, const char *full_name,
313 ioremap(base + 0x7ff000, 0x1000) + 0xcc0; 322 ioremap(base + 0x7ff000, 0x1000) + 0xcc0;
314 par->cmap_data = par->cmap_adr + 1; 323 par->cmap_data = par->cmap_adr + 1;
315 par->cmap_type = cmap_m64; 324 par->cmap_type = cmap_m64;
316 } else if (dp && device_is_compatible(dp, "pci1014,b7")) { 325 } else if (dp && (device_is_compatible(dp, "pci1014,b7") ||
326 device_is_compatible(dp, "pci1014,21c"))) {
317 par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000); 327 par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000);
318 if (par->cmap_adr) 328 if (par->cmap_adr)
319 par->cmap_type = cmap_gxt2000; 329 par->cmap_type = cmap_gxt2000;
@@ -433,7 +443,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
433 pp = get_property(dp, "linux,bootx-linebytes", &len); 443 pp = get_property(dp, "linux,bootx-linebytes", &len);
434 if (pp == NULL) 444 if (pp == NULL)
435 pp = get_property(dp, "linebytes", &len); 445 pp = get_property(dp, "linebytes", &len);
436 if (pp && len == sizeof(u32)) 446 if (pp && len == sizeof(u32) && (*pp != 0xffffffffu))
437 pitch = *pp; 447 pitch = *pp;
438 else 448 else
439 pitch = width * ((depth + 7) / 8); 449 pitch = width * ((depth + 7) / 8);
@@ -496,7 +506,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
496 offb_init_fb(no_real_node ? "bootx" : dp->name, 506 offb_init_fb(no_real_node ? "bootx" : dp->name,
497 no_real_node ? "display" : dp->full_name, 507 no_real_node ? "display" : dp->full_name,
498 width, height, depth, pitch, address, 508 width, height, depth, pitch, address,
499 no_real_node ? dp : NULL); 509 no_real_node ? NULL : dp);
500 } 510 }
501} 511}
502 512
diff --git a/drivers/video/pnx4008/pnxrgbfb.c b/drivers/video/pnx4008/pnxrgbfb.c
index 7d9453c91a42..f29e66e2d774 100644
--- a/drivers/video/pnx4008/pnxrgbfb.c
+++ b/drivers/video/pnx4008/pnxrgbfb.c
@@ -154,7 +154,8 @@ static int __devinit rgbfb_probe(struct platform_device *pdev)
154 goto err1; 154 goto err1;
155 } 155 }
156 156
157 if (!fb_get_options("pnxrgbfb", &option) && !strcmp(option, "nocursor")) 157 if (!fb_get_options("pnxrgbfb", &option) && option &&
158 !strcmp(option, "nocursor"))
158 rgbfb_ops.fb_cursor = no_cursor; 159 rgbfb_ops.fb_cursor = no_cursor;
159 160
160 info->node = -1; 161 info->node = -1;
@@ -191,7 +192,7 @@ err:
191 192
192static struct platform_driver rgbfb_driver = { 193static struct platform_driver rgbfb_driver = {
193 .driver = { 194 .driver = {
194 .name = "rgbfb", 195 .name = "pnx4008-rgbfb",
195 }, 196 },
196 .probe = rgbfb_probe, 197 .probe = rgbfb_probe,
197 .remove = rgbfb_remove, 198 .remove = rgbfb_remove,
diff --git a/drivers/video/pnx4008/sdum.c b/drivers/video/pnx4008/sdum.c
index 51f0ecc2a511..d23bf0d659b6 100644
--- a/drivers/video/pnx4008/sdum.c
+++ b/drivers/video/pnx4008/sdum.c
@@ -848,7 +848,7 @@ static int sdum_remove(struct platform_device *pdev)
848 848
849static struct platform_driver sdum_driver = { 849static struct platform_driver sdum_driver = {
850 .driver = { 850 .driver = {
851 .name = "sdum", 851 .name = "pnx4008-sdum",
852 }, 852 },
853 .probe = sdum_probe, 853 .probe = sdum_probe,
854 .remove = sdum_remove, 854 .remove = sdum_remove,
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index 2788b8ca9bb1..6f9d880ab2e9 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -215,6 +215,8 @@ static int __devinit matrox_w1_probe(struct pci_dev *pdev, const struct pci_devi
215 return 0; 215 return 0;
216 216
217err_out_free_device: 217err_out_free_device:
218 if (dev->virt_addr)
219 iounmap(dev->virt_addr);
218 kfree(dev); 220 kfree(dev);
219 221
220 return err; 222 return err;