aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-04-19 12:17:29 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-04-19 12:17:29 -0400
commitadf6d34e460387ee3e8f1e1875d52bff51212c7d (patch)
tree88ef100143e6184103a608f82dfd232bf6376eaf /drivers
parentd1964dab60ce7c104dd21590e987a8787db18051 (diff)
parent3760d31f11bfbd0ead9eaeb8573e0602437a9d7c (diff)
Merge branch 'omap2-upstream' into devel
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/processor_core.c2
-rw-r--r--drivers/acpi/processor_idle.c7
-rw-r--r--drivers/acpi/sbshc.c1
-rw-r--r--drivers/acpi/scan.c18
-rw-r--r--drivers/acpi/sleep/main.c71
-rw-r--r--drivers/acpi/thermal.c2
-rw-r--r--drivers/acpi/video.c2
-rw-r--r--drivers/ata/libata-core.c43
-rw-r--r--drivers/ata/libata-eh.c2
-rw-r--r--drivers/ata/pata_ali.c40
-rw-r--r--drivers/ata/pata_sil680.c6
-rw-r--r--drivers/ata/sata_fsl.c8
-rw-r--r--drivers/atm/firestream.c1
-rw-r--r--drivers/atm/he.c3
-rw-r--r--drivers/atm/idt77252.c6
-rw-r--r--drivers/atm/iphase.c2
-rw-r--r--drivers/base/driver.c5
-rw-r--r--drivers/block/cciss.c1
-rw-r--r--drivers/block/nbd.c6
-rw-r--r--drivers/block/ub.c38
-rw-r--r--drivers/char/drm/ati_pcigart.c11
-rw-r--r--drivers/char/drm/drm_scatter.c11
-rw-r--r--drivers/char/drm/drm_vm.c20
-rw-r--r--drivers/char/drm/i915_dma.c3
-rw-r--r--drivers/char/drm/i915_drv.h4
-rw-r--r--drivers/char/drm/r300_cmdbuf.c54
-rw-r--r--drivers/char/drm/radeon_drm.h12
-rw-r--r--drivers/char/drm/radeon_mem.c8
-rw-r--r--drivers/char/hpet.c51
-rw-r--r--drivers/char/ip2/i2lib.c12
-rw-r--r--drivers/char/n_tty.c2
-rw-r--r--drivers/char/nozomi.c20
-rw-r--r--drivers/char/rio/riotable.c4
-rw-r--r--drivers/char/rio/riotty.c4
-rw-r--r--drivers/cpuidle/cpuidle.c4
-rw-r--r--drivers/cpuidle/sysfs.c10
-rw-r--r--drivers/crypto/hifn_795x.c28
-rw-r--r--drivers/dma/fsldma.c8
-rw-r--r--drivers/dma/fsldma.h47
-rw-r--r--drivers/dma/ioat_dca.c4
-rw-r--r--drivers/firewire/fw-ohci.c9
-rw-r--r--drivers/firmware/dmi_scan.c2
-rw-r--r--drivers/hwmon/w83781d.c21
-rw-r--r--drivers/i2c/busses/i2c-davinci.c17
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c2
-rw-r--r--drivers/i2c/busses/i2c-tiny-usb.c12
-rw-r--r--drivers/i2c/chips/Kconfig1
-rw-r--r--drivers/i2c/chips/tps65010.c101
-rw-r--r--drivers/ide/arm/ide_arm.c2
-rw-r--r--drivers/ide/cris/ide-cris.c2
-rw-r--r--drivers/ide/h8300/ide-h8300.c3
-rw-r--r--drivers/ide/ide-iops.c3
-rw-r--r--drivers/ide/ide-pnp.c2
-rw-r--r--drivers/ide/ide-probe.c5
-rw-r--r--drivers/ide/legacy/buddha.c2
-rw-r--r--drivers/ide/legacy/falconide.c2
-rw-r--r--drivers/ide/legacy/gayle.c2
-rw-r--r--drivers/ide/legacy/macide.c2
-rw-r--r--drivers/ide/legacy/q40ide.c2
-rw-r--r--drivers/ide/pci/cmd640.c2
-rw-r--r--drivers/ide/pci/siimage.c2
-rw-r--r--drivers/ide/ppc/mpc8xx.c2
-rw-r--r--drivers/ide/ppc/pmac.c2
-rw-r--r--drivers/infiniband/core/addr.c8
-rw-r--r--drivers/infiniband/core/cm.c2
-rw-r--r--drivers/infiniband/core/cma.c24
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c2
-rw-r--r--drivers/input/apm-power.c7
-rw-r--r--drivers/input/evdev.c3
-rw-r--r--drivers/input/joydev.c3
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c6
-rw-r--r--drivers/input/misc/ixp4xx-beeper.c1
-rw-r--r--drivers/input/mouse/appletouch.c13
-rw-r--r--drivers/input/mousedev.c3
-rw-r--r--drivers/input/touchscreen/ads7846.c40
-rw-r--r--drivers/leds/leds-gpio.c20
-rw-r--r--drivers/lguest/Makefile8
-rw-r--r--drivers/lguest/core.c18
-rw-r--r--drivers/lguest/hypercalls.c11
-rw-r--r--drivers/lguest/interrupts_and_traps.c7
-rw-r--r--drivers/lguest/lguest_device.c11
-rw-r--r--drivers/lguest/lguest_user.c32
-rw-r--r--drivers/lguest/page_tables.c32
-rw-r--r--drivers/lguest/x86/core.c33
-rw-r--r--drivers/lguest/x86/switcher_32.S8
-rw-r--r--drivers/md/dm-crypt.c58
-rw-r--r--drivers/md/dm-io.c2
-rw-r--r--drivers/md/dm-raid1.c4
-rw-r--r--drivers/md/dm-snap.c2
-rw-r--r--drivers/md/kcopyd.c10
-rw-r--r--drivers/md/kcopyd.h4
-rw-r--r--drivers/md/raid5.c51
-rw-r--r--drivers/media/Makefile3
-rw-r--r--drivers/media/common/saa7146_core.c13
-rw-r--r--drivers/media/common/saa7146_fops.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c4
-rw-r--r--drivers/media/dvb/frontends/s5h1409.c2
-rw-r--r--drivers/media/radio/radio-cadet.c6
-rw-r--r--drivers/media/video/adv7170.c2
-rw-r--r--drivers/media/video/adv7175.c2
-rw-r--r--drivers/media/video/bt819.c2
-rw-r--r--drivers/media/video/bt856.c2
-rw-r--r--drivers/media/video/bt8xx/bt832.c12
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c31
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c6
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c134
-rw-r--r--drivers/media/video/dpc7146.c2
-rw-r--r--drivers/media/video/mt20xx.c2
-rw-r--r--drivers/media/video/mxb.c5
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-devattr.c39
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ioread.c2
-rw-r--r--drivers/media/video/pwc/pwc-if.c7
-rw-r--r--drivers/media/video/saa7110.c4
-rw-r--r--drivers/media/video/saa7111.c2
-rw-r--r--drivers/media/video/saa7114.c2
-rw-r--r--drivers/media/video/saa7185.c2
-rw-r--r--drivers/media/video/tda9840.c2
-rw-r--r--drivers/media/video/tea6415c.c2
-rw-r--r--drivers/media/video/tea6420.c2
-rw-r--r--drivers/media/video/tvp5150.c4
-rw-r--r--drivers/media/video/v4l2-int-device.c2
-rw-r--r--drivers/media/video/zoran_driver.c2
-rw-r--r--drivers/media/video/zr364xx.c2
-rw-r--r--drivers/memstick/host/tifm_ms.c4
-rw-r--r--drivers/mfd/asic3.c4
-rw-r--r--drivers/misc/fujitsu-laptop.c2
-rw-r--r--drivers/misc/ibmasm/module.c2
-rw-r--r--drivers/misc/lkdtm.c2
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c10
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c1
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c1
-rw-r--r--drivers/mtd/maps/physmap.c15
-rw-r--r--drivers/mtd/nand/rtc_from4.c2
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/b44.c5
-rw-r--r--drivers/net/bfin_mac.c2
-rw-r--r--drivers/net/bnx2x.c6
-rw-r--r--drivers/net/bonding/bond_3ad.c4
-rw-r--r--drivers/net/bonding/bond_alb.c6
-rw-r--r--drivers/net/bonding/bond_main.c5
-rw-r--r--drivers/net/bonding/bond_sysfs.c1
-rw-r--r--drivers/net/bonding/bonding.h4
-rw-r--r--drivers/net/cxgb3/sge.c18
-rw-r--r--drivers/net/dm9000.c12
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c2
-rw-r--r--drivers/net/fec_mpc52xx.c1
-rw-r--r--drivers/net/fec_mpc52xx_phy.c1
-rw-r--r--drivers/net/forcedeth.c23
-rw-r--r--drivers/net/ibm_newemac/core.c4
-rw-r--r--drivers/net/igb/e1000_82575.h42
-rw-r--r--drivers/net/igb/e1000_hw.h82
-rw-r--r--drivers/net/igb/igb_main.c21
-rw-r--r--drivers/net/ixgb/ixgb_main.c2
-rw-r--r--drivers/net/netxen/netxen_nic.h27
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c8
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h12
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c2
-rw-r--r--drivers/net/netxen/netxen_nic_init.c201
-rw-r--r--drivers/net/netxen/netxen_nic_isr.c19
-rw-r--r--drivers/net/netxen/netxen_nic_main.c265
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h3
-rw-r--r--drivers/net/phy/marvell.c131
-rw-r--r--drivers/net/plip.c7
-rw-r--r--drivers/net/s2io.c5
-rw-r--r--drivers/net/skge.c6
-rw-r--r--drivers/net/sky2.c6
-rw-r--r--drivers/net/starfire.c11
-rw-r--r--drivers/net/tg3.c154
-rw-r--r--drivers/net/tg3.h79
-rw-r--r--drivers/net/tokenring/olympic.c21
-rw-r--r--drivers/net/tokenring/smctr.c2
-rw-r--r--drivers/net/tulip/eeprom.c6
-rw-r--r--drivers/net/tulip/tulip_core.c7
-rw-r--r--drivers/net/usb/Kconfig2
-rw-r--r--drivers/net/usb/dm9601.c8
-rw-r--r--drivers/net/usb/pegasus.c4
-rw-r--r--drivers/net/usb/rndis_host.c9
-rw-r--r--drivers/net/virtio_net.c6
-rw-r--r--drivers/net/wan/lapbether.c2
-rw-r--r--drivers/net/wireless/arlan-proc.c8
-rw-r--r--drivers/net/wireless/b43/debugfs.c4
-rw-r--r--drivers/net/wireless/b43/dma.c37
-rw-r--r--drivers/net/wireless/b43/main.c2
-rw-r--r--drivers/net/wireless/b43/pcmcia.c6
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_rx.c39
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_tx.c7
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c203
-rw-r--r--drivers/net/wireless/ipw2200.c8
-rw-r--r--drivers/net/wireless/iwlwifi/Kconfig5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c4
-rw-r--r--drivers/net/wireless/libertas/assoc.c2
-rw-r--r--drivers/net/wireless/libertas/if_cs.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c13
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c2
-rw-r--r--drivers/net/wireless/wavelan_cs.h2
-rw-r--r--drivers/parport/parport_pc.c3
-rw-r--r--drivers/pci/quirks.c11
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c8
-rw-r--r--drivers/rtc/Kconfig1
-rw-r--r--drivers/rtc/rtc-at32ap700x.c2
-rw-r--r--drivers/rtc/rtc-at91rm9200.c1
-rw-r--r--drivers/rtc/rtc-bfin.c1
-rw-r--r--drivers/rtc/rtc-cmos.c3
-rw-r--r--drivers/rtc/rtc-ds1216.c1
-rw-r--r--drivers/rtc/rtc-ds1511.c3
-rw-r--r--drivers/rtc/rtc-ds1553.c3
-rw-r--r--drivers/rtc/rtc-ds1742.c1
-rw-r--r--drivers/rtc/rtc-ep93xx.c3
-rw-r--r--drivers/rtc/rtc-m48t59.c3
-rw-r--r--drivers/rtc/rtc-m48t86.c1
-rw-r--r--drivers/rtc/rtc-omap.c2
-rw-r--r--drivers/rtc/rtc-rs5c313.c1
-rw-r--r--drivers/rtc/rtc-s3c.c1
-rw-r--r--drivers/rtc/rtc-sa1100.c1
-rw-r--r--drivers/rtc/rtc-sh.c1
-rw-r--r--drivers/rtc/rtc-stk17ta8.c3
-rw-r--r--drivers/rtc/rtc-v3020.c1
-rw-r--r--drivers/rtc/rtc-vr41xx.c3
-rw-r--r--drivers/scsi/hosts.c16
-rw-r--r--drivers/scsi/libsas/sas_discover.c5
-rw-r--r--drivers/scsi/mvsas.c711
-rw-r--r--drivers/scsi/scsi.c22
-rw-r--r--drivers/scsi/scsi_sysfs.c2
-rw-r--r--drivers/serial/8250_pci.c7
-rw-r--r--drivers/serial/atmel_serial.c30
-rw-r--r--drivers/spi/atmel_spi.c1
-rw-r--r--drivers/spi/au1550_spi.c3
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c3
-rw-r--r--drivers/spi/omap2_mcspi.c3
-rw-r--r--drivers/spi/omap_uwire.c4
-rw-r--r--drivers/spi/pxa2xx_spi.c2
-rw-r--r--drivers/spi/spi_bfin5xx.c19
-rw-r--r--drivers/spi/spi_imx.c4
-rw-r--r--drivers/spi/spi_mpc83xx.c5
-rw-r--r--drivers/spi/spi_s3c24xx.c2
-rw-r--r--drivers/spi/spi_s3c24xx_gpio.c2
-rw-r--r--drivers/spi/spi_sh_sci.c1
-rw-r--r--drivers/spi/spi_txx9.c3
-rw-r--r--drivers/spi/xilinx_spi.c3
-rw-r--r--drivers/ssb/driver_mipscore.c13
-rw-r--r--drivers/ssb/driver_pcicore.c2
-rw-r--r--drivers/ssb/main.c6
-rw-r--r--drivers/usb/gadget/at91_udc.c1
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c2
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c1
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c1
-rw-r--r--drivers/usb/gadget/m66592-udc.c2
-rw-r--r--drivers/usb/gadget/omap_udc.c2
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c2
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c2
-rw-r--r--drivers/usb/host/ehci-hub.c5
-rw-r--r--drivers/usb/host/isp116x-hcd.c8
-rw-r--r--drivers/usb/host/ohci-at91.c3
-rw-r--r--drivers/usb/host/ohci-au1xxx.c1
-rw-r--r--drivers/usb/host/ohci-ep93xx.c2
-rw-r--r--drivers/usb/host/ohci-hcd.c2
-rw-r--r--drivers/usb/host/ohci-lh7a404.c1
-rw-r--r--drivers/usb/host/ohci-omap.c1
-rw-r--r--drivers/usb/host/ohci-pnx4008.c4
-rw-r--r--drivers/usb/host/ohci-pnx8550.c5
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c1
-rw-r--r--drivers/usb/host/ohci-pxa27x.c3
-rw-r--r--drivers/usb/host/ohci-q.c2
-rw-r--r--drivers/usb/host/ohci-s3c2410.c1
-rw-r--r--drivers/usb/host/ohci-sh.c1
-rw-r--r--drivers/usb/host/ohci-sm501.c1
-rw-r--r--drivers/usb/host/r8a66597-hcd.c2
-rw-r--r--drivers/usb/host/sl811-hcd.c1
-rw-r--r--drivers/usb/host/u132-hcd.c1
-rw-r--r--drivers/usb/misc/usbtest.c3
-rw-r--r--drivers/usb/serial/cp2101.c1
-rw-r--r--drivers/usb/serial/keyspan.h4
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c4
-rw-r--r--drivers/usb/serial/visor.c2
-rw-r--r--drivers/video/bf54x-lq043fb.c2
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c38
-rw-r--r--drivers/virtio/virtio_pci.c7
-rw-r--r--drivers/virtio/virtio_ring.c3
-rw-r--r--drivers/watchdog/at32ap700x_wdt.c3
-rw-r--r--drivers/watchdog/at91rm9200_wdt.c1
-rw-r--r--drivers/watchdog/davinci_wdt.c2
-rw-r--r--drivers/watchdog/it8712f_wdt.c16
-rw-r--r--drivers/watchdog/ks8695_wdt.c1
-rw-r--r--drivers/watchdog/mpc83xx_wdt.c2
-rw-r--r--drivers/watchdog/mpcore_wdt.c3
-rw-r--r--drivers/watchdog/mtx-1_wdt.c2
-rw-r--r--drivers/watchdog/mv64x60_wdt.c1
-rw-r--r--drivers/watchdog/omap_wdt.c1
-rw-r--r--drivers/watchdog/pnx4008_wdt.c2
-rw-r--r--drivers/watchdog/s3c2410_wdt.c1
-rw-r--r--drivers/watchdog/txx9wdt.c1
-rw-r--r--drivers/xen/grant-table.c16
300 files changed, 2524 insertions, 1744 deletions
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 36a68fa114e3..a825b431b64f 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -822,7 +822,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
822 } 822 }
823 823
824 processors[pr->id] = NULL; 824 processors[pr->id] = NULL;
825 825 processor_device_array[pr->id] = NULL;
826 kfree(pr); 826 kfree(pr);
827 827
828 return 0; 828 return 0;
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index e8e2d8869236..788da9781f80 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -1487,7 +1487,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1487 return 0; 1487 return 0;
1488 } 1488 }
1489 1489
1490 acpi_unlazy_tlb(smp_processor_id());
1491 /* 1490 /*
1492 * Must be done before busmaster disable as we might need to 1491 * Must be done before busmaster disable as we might need to
1493 * access HPET ! 1492 * access HPET !
@@ -1577,6 +1576,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1577 return 0; 1576 return 0;
1578 } 1577 }
1579 1578
1579 acpi_unlazy_tlb(smp_processor_id());
1580
1580 /* Tell the scheduler that we are going deep-idle: */ 1581 /* Tell the scheduler that we are going deep-idle: */
1581 sched_clock_idle_sleep_event(); 1582 sched_clock_idle_sleep_event();
1582 /* 1583 /*
@@ -1692,7 +1693,9 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
1692 switch (cx->type) { 1693 switch (cx->type) {
1693 case ACPI_STATE_C1: 1694 case ACPI_STATE_C1:
1694 state->flags |= CPUIDLE_FLAG_SHALLOW; 1695 state->flags |= CPUIDLE_FLAG_SHALLOW;
1695 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1696 if (cx->entry_method == ACPI_CSTATE_FFH)
1697 state->flags |= CPUIDLE_FLAG_TIME_VALID;
1698
1696 state->enter = acpi_idle_enter_c1; 1699 state->enter = acpi_idle_enter_c1;
1697 dev->safe_state = state; 1700 dev->safe_state = state;
1698 break; 1701 break;
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index a2cf3008ce6c..bcf2c70fca87 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -130,7 +130,6 @@ static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol,
130 goto end; 130 goto end;
131 } 131 }
132 smb_hc_write(hc, ACPI_SMB_COMMAND, command); 132 smb_hc_write(hc, ACPI_SMB_COMMAND, command);
133 smb_hc_write(hc, ACPI_SMB_COMMAND, command);
134 if (!(protocol & 0x01)) { 133 if (!(protocol & 0x01)) {
135 smb_hc_write(hc, ACPI_SMB_BLOCK_COUNT, length); 134 smb_hc_write(hc, ACPI_SMB_BLOCK_COUNT, length);
136 for (i = 0; i < length; ++i) 135 for (i = 0; i < length; ++i)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 57570ac47803..e6ce262b5d44 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -39,20 +39,26 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
39 int size) 39 int size)
40{ 40{
41 int len; 41 int len;
42 int count;
42 43
43 if (!acpi_dev->flags.hardware_id) 44 if (!acpi_dev->flags.hardware_id && !acpi_dev->flags.compatible_ids)
44 return -ENODEV; 45 return -ENODEV;
45 46
46 len = snprintf(modalias, size, "acpi:%s:", 47 len = snprintf(modalias, size, "acpi:");
47 acpi_dev->pnp.hardware_id);
48 if (len < 0 || len >= size)
49 return -EINVAL;
50 size -= len; 48 size -= len;
51 49
50 if (acpi_dev->flags.hardware_id) {
51 count = snprintf(&modalias[len], size, "%s:",
52 acpi_dev->pnp.hardware_id);
53 if (count < 0 || count >= size)
54 return -EINVAL;
55 len += count;
56 size -= count;
57 }
58
52 if (acpi_dev->flags.compatible_ids) { 59 if (acpi_dev->flags.compatible_ids) {
53 struct acpi_compatible_id_list *cid_list; 60 struct acpi_compatible_id_list *cid_list;
54 int i; 61 int i;
55 int count;
56 62
57 cid_list = acpi_dev->pnp.cid_list; 63 cid_list = acpi_dev->pnp.cid_list;
58 for (i = 0; i < cid_list->count; i++) { 64 for (i = 0; i < cid_list->count; i++) {
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index d2f71a54726c..71183eea7906 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -26,21 +26,6 @@ u8 sleep_states[ACPI_S_STATE_COUNT];
26 26
27#ifdef CONFIG_PM_SLEEP 27#ifdef CONFIG_PM_SLEEP
28static u32 acpi_target_sleep_state = ACPI_STATE_S0; 28static u32 acpi_target_sleep_state = ACPI_STATE_S0;
29static bool acpi_sleep_finish_wake_up;
30
31/*
32 * ACPI 2.0 and later want us to execute _PTS after suspending devices, so we
33 * allow the user to request that behavior by using the 'acpi_new_pts_ordering'
34 * kernel command line option that causes the following variable to be set.
35 */
36static bool new_pts_ordering;
37
38static int __init acpi_new_pts_ordering(char *str)
39{
40 new_pts_ordering = true;
41 return 1;
42}
43__setup("acpi_new_pts_ordering", acpi_new_pts_ordering);
44#endif 29#endif
45 30
46static int acpi_sleep_prepare(u32 acpi_state) 31static int acpi_sleep_prepare(u32 acpi_state)
@@ -91,14 +76,6 @@ static int acpi_pm_begin(suspend_state_t pm_state)
91 76
92 if (sleep_states[acpi_state]) { 77 if (sleep_states[acpi_state]) {
93 acpi_target_sleep_state = acpi_state; 78 acpi_target_sleep_state = acpi_state;
94 if (new_pts_ordering)
95 return 0;
96
97 error = acpi_sleep_prepare(acpi_state);
98 if (error)
99 acpi_target_sleep_state = ACPI_STATE_S0;
100 else
101 acpi_sleep_finish_wake_up = true;
102 } else { 79 } else {
103 printk(KERN_ERR "ACPI does not support this state: %d\n", 80 printk(KERN_ERR "ACPI does not support this state: %d\n",
104 pm_state); 81 pm_state);
@@ -116,14 +93,11 @@ static int acpi_pm_begin(suspend_state_t pm_state)
116 93
117static int acpi_pm_prepare(void) 94static int acpi_pm_prepare(void)
118{ 95{
119 if (new_pts_ordering) { 96 int error = acpi_sleep_prepare(acpi_target_sleep_state);
120 int error = acpi_sleep_prepare(acpi_target_sleep_state);
121 97
122 if (error) { 98 if (error) {
123 acpi_target_sleep_state = ACPI_STATE_S0; 99 acpi_target_sleep_state = ACPI_STATE_S0;
124 return error; 100 return error;
125 }
126 acpi_sleep_finish_wake_up = true;
127 } 101 }
128 102
129 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; 103 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT;
@@ -212,7 +186,6 @@ static void acpi_pm_finish(void)
212 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 186 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
213 187
214 acpi_target_sleep_state = ACPI_STATE_S0; 188 acpi_target_sleep_state = ACPI_STATE_S0;
215 acpi_sleep_finish_wake_up = false;
216 189
217#ifdef CONFIG_X86 190#ifdef CONFIG_X86
218 if (init_8259A_after_S1) { 191 if (init_8259A_after_S1) {
@@ -229,11 +202,10 @@ static void acpi_pm_finish(void)
229static void acpi_pm_end(void) 202static void acpi_pm_end(void)
230{ 203{
231 /* 204 /*
232 * This is necessary in case acpi_pm_finish() is not called directly 205 * This is necessary in case acpi_pm_finish() is not called during a
233 * during a failing transition to a sleep state. 206 * failing transition to a sleep state.
234 */ 207 */
235 if (acpi_sleep_finish_wake_up) 208 acpi_target_sleep_state = ACPI_STATE_S0;
236 acpi_pm_finish();
237} 209}
238 210
239static int acpi_pm_state_valid(suspend_state_t pm_state) 211static int acpi_pm_state_valid(suspend_state_t pm_state)
@@ -285,31 +257,18 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
285#ifdef CONFIG_HIBERNATION 257#ifdef CONFIG_HIBERNATION
286static int acpi_hibernation_begin(void) 258static int acpi_hibernation_begin(void)
287{ 259{
288 int error;
289
290 acpi_target_sleep_state = ACPI_STATE_S4; 260 acpi_target_sleep_state = ACPI_STATE_S4;
291 if (new_pts_ordering)
292 return 0;
293 261
294 error = acpi_sleep_prepare(ACPI_STATE_S4); 262 return 0;
295 if (error)
296 acpi_target_sleep_state = ACPI_STATE_S0;
297 else
298 acpi_sleep_finish_wake_up = true;
299
300 return error;
301} 263}
302 264
303static int acpi_hibernation_prepare(void) 265static int acpi_hibernation_prepare(void)
304{ 266{
305 if (new_pts_ordering) { 267 int error = acpi_sleep_prepare(ACPI_STATE_S4);
306 int error = acpi_sleep_prepare(ACPI_STATE_S4);
307 268
308 if (error) { 269 if (error) {
309 acpi_target_sleep_state = ACPI_STATE_S0; 270 acpi_target_sleep_state = ACPI_STATE_S0;
310 return error; 271 return error;
311 }
312 acpi_sleep_finish_wake_up = true;
313 } 272 }
314 273
315 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; 274 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT;
@@ -353,17 +312,15 @@ static void acpi_hibernation_finish(void)
353 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 312 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
354 313
355 acpi_target_sleep_state = ACPI_STATE_S0; 314 acpi_target_sleep_state = ACPI_STATE_S0;
356 acpi_sleep_finish_wake_up = false;
357} 315}
358 316
359static void acpi_hibernation_end(void) 317static void acpi_hibernation_end(void)
360{ 318{
361 /* 319 /*
362 * This is necessary in case acpi_hibernation_finish() is not called 320 * This is necessary in case acpi_hibernation_finish() is not called
363 * directly during a failing transition to the sleep state. 321 * during a failing transition to the sleep state.
364 */ 322 */
365 if (acpi_sleep_finish_wake_up) 323 acpi_target_sleep_state = ACPI_STATE_S0;
366 acpi_hibernation_finish();
367} 324}
368 325
369static int acpi_hibernation_pre_restore(void) 326static int acpi_hibernation_pre_restore(void)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index c4e00ac8ea85..1bcecc7dd2ca 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -1125,7 +1125,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
1125 tz->trips.active[i].flags.valid; i++, trips++); 1125 tz->trips.active[i].flags.valid; i++, trips++);
1126 tz->thermal_zone = thermal_zone_device_register("ACPI thermal zone", 1126 tz->thermal_zone = thermal_zone_device_register("ACPI thermal zone",
1127 trips, tz, &acpi_thermal_zone_ops); 1127 trips, tz, &acpi_thermal_zone_ops);
1128 if (!tz->thermal_zone) 1128 if (IS_ERR(tz->thermal_zone))
1129 return -ENODEV; 1129 return -ENODEV;
1130 1130
1131 result = sysfs_create_link(&tz->device->dev.kobj, 1131 result = sysfs_create_link(&tz->device->dev.kobj,
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 12fb44f16766..980a74188781 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -713,7 +713,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
713 713
714 kfree(obj); 714 kfree(obj);
715 715
716 if (device->cap._BCL && device->cap._BCM && max_level > 0) { 716 if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){
717 int result; 717 int result;
718 static int count = 0; 718 static int count = 0;
719 char *name; 719 char *name;
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c4248b37ff64..be95fdb69726 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -326,6 +326,44 @@ static void ata_force_horkage(struct ata_device *dev)
326} 326}
327 327
328/** 328/**
329 * atapi_cmd_type - Determine ATAPI command type from SCSI opcode
330 * @opcode: SCSI opcode
331 *
332 * Determine ATAPI command type from @opcode.
333 *
334 * LOCKING:
335 * None.
336 *
337 * RETURNS:
338 * ATAPI_{READ|WRITE|READ_CD|PASS_THRU|MISC}
339 */
340int atapi_cmd_type(u8 opcode)
341{
342 switch (opcode) {
343 case GPCMD_READ_10:
344 case GPCMD_READ_12:
345 return ATAPI_READ;
346
347 case GPCMD_WRITE_10:
348 case GPCMD_WRITE_12:
349 case GPCMD_WRITE_AND_VERIFY_10:
350 return ATAPI_WRITE;
351
352 case GPCMD_READ_CD:
353 case GPCMD_READ_CD_MSF:
354 return ATAPI_READ_CD;
355
356 case ATA_16:
357 case ATA_12:
358 if (atapi_passthru16)
359 return ATAPI_PASS_THRU;
360 /* fall thru */
361 default:
362 return ATAPI_MISC;
363 }
364}
365
366/**
329 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure 367 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
330 * @tf: Taskfile to convert 368 * @tf: Taskfile to convert
331 * @pmp: Port multiplier port 369 * @pmp: Port multiplier port
@@ -972,7 +1010,7 @@ static void ata_dev_disable_pm(struct ata_device *dev)
972void ata_lpm_schedule(struct ata_port *ap, enum link_pm policy) 1010void ata_lpm_schedule(struct ata_port *ap, enum link_pm policy)
973{ 1011{
974 ap->pm_policy = policy; 1012 ap->pm_policy = policy;
975 ap->link.eh_info.action |= ATA_EHI_LPM; 1013 ap->link.eh_info.action |= ATA_EH_LPM;
976 ap->link.eh_info.flags |= ATA_EHI_NO_AUTOPSY; 1014 ap->link.eh_info.flags |= ATA_EHI_NO_AUTOPSY;
977 ata_port_schedule_eh(ap); 1015 ata_port_schedule_eh(ap);
978} 1016}
@@ -2660,7 +2698,7 @@ int ata_bus_probe(struct ata_port *ap)
2660 specific sequence bass-ackwards so that PDIAG- is released by 2698 specific sequence bass-ackwards so that PDIAG- is released by
2661 the slave device */ 2699 the slave device */
2662 2700
2663 ata_link_for_each_dev(dev, &ap->link) { 2701 ata_link_for_each_dev_reverse(dev, &ap->link) {
2664 if (tries[dev->devno]) 2702 if (tries[dev->devno])
2665 dev->class = classes[dev->devno]; 2703 dev->class = classes[dev->devno];
2666 2704
@@ -7774,6 +7812,7 @@ EXPORT_SYMBOL_GPL(ata_tf_read);
7774EXPORT_SYMBOL_GPL(ata_noop_dev_select); 7812EXPORT_SYMBOL_GPL(ata_noop_dev_select);
7775EXPORT_SYMBOL_GPL(ata_std_dev_select); 7813EXPORT_SYMBOL_GPL(ata_std_dev_select);
7776EXPORT_SYMBOL_GPL(sata_print_link_status); 7814EXPORT_SYMBOL_GPL(sata_print_link_status);
7815EXPORT_SYMBOL_GPL(atapi_cmd_type);
7777EXPORT_SYMBOL_GPL(ata_tf_to_fis); 7816EXPORT_SYMBOL_GPL(ata_tf_to_fis);
7778EXPORT_SYMBOL_GPL(ata_tf_from_fis); 7817EXPORT_SYMBOL_GPL(ata_tf_from_fis);
7779EXPORT_SYMBOL_GPL(ata_pack_xfermask); 7818EXPORT_SYMBOL_GPL(ata_pack_xfermask);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 681252fd8143..a5830329eda4 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2748,7 +2748,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2748 ehc->i.flags &= ~ATA_EHI_SETMODE; 2748 ehc->i.flags &= ~ATA_EHI_SETMODE;
2749 } 2749 }
2750 2750
2751 if (ehc->i.action & ATA_EHI_LPM) 2751 if (ehc->i.action & ATA_EH_LPM)
2752 ata_link_for_each_dev(dev, link) 2752 ata_link_for_each_dev(dev, link)
2753 ata_dev_enable_pm(dev, ap->pm_policy); 2753 ata_dev_enable_pm(dev, ap->pm_policy);
2754 2754
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 8786455c901d..ce830fe3a362 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -36,6 +36,10 @@
36#define DRV_NAME "pata_ali" 36#define DRV_NAME "pata_ali"
37#define DRV_VERSION "0.7.5" 37#define DRV_VERSION "0.7.5"
38 38
39int ali_atapi_dma = 0;
40module_param_named(atapi_dma, ali_atapi_dma, int, 0644);
41MODULE_PARM_DESC(atapi_dma, "Enable ATAPI DMA (0=disable, 1=enable)");
42
39/* 43/*
40 * Cable special cases 44 * Cable special cases
41 */ 45 */
@@ -270,6 +274,27 @@ static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev)
270} 274}
271 275
272/** 276/**
277 * ali_warn_atapi_dma - Warn about ATAPI DMA disablement
278 * @adev: Device
279 *
280 * Whine about ATAPI DMA disablement if @adev is an ATAPI device.
281 * Can be used as ->dev_config.
282 */
283
284static void ali_warn_atapi_dma(struct ata_device *adev)
285{
286 struct ata_eh_context *ehc = &adev->link->eh_context;
287 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
288
289 if (print_info && adev->class == ATA_DEV_ATAPI && !ali_atapi_dma) {
290 ata_dev_printk(adev, KERN_WARNING,
291 "WARNING: ATAPI DMA disabled for reliablity issues. It can be enabled\n");
292 ata_dev_printk(adev, KERN_WARNING,
293 "WARNING: via pata_ali.atapi_dma modparam or corresponding sysfs node.\n");
294 }
295}
296
297/**
273 * ali_lock_sectors - Keep older devices to 255 sector mode 298 * ali_lock_sectors - Keep older devices to 255 sector mode
274 * @adev: Device 299 * @adev: Device
275 * 300 *
@@ -283,6 +308,7 @@ static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev)
283static void ali_lock_sectors(struct ata_device *adev) 308static void ali_lock_sectors(struct ata_device *adev)
284{ 309{
285 adev->max_sectors = 255; 310 adev->max_sectors = 255;
311 ali_warn_atapi_dma(adev);
286} 312}
287 313
288/** 314/**
@@ -294,6 +320,18 @@ static void ali_lock_sectors(struct ata_device *adev)
294 320
295static int ali_check_atapi_dma(struct ata_queued_cmd *qc) 321static int ali_check_atapi_dma(struct ata_queued_cmd *qc)
296{ 322{
323 if (!ali_atapi_dma) {
324 /* FIXME: pata_ali can't do ATAPI DMA reliably but the
325 * IDE alim15x3 driver can. I tried lots of things
326 * but couldn't find what the actual difference was.
327 * If you got an idea, please write it to
328 * linux-ide@vger.kernel.org and cc htejun@gmail.com.
329 *
330 * Disable ATAPI DMA for now.
331 */
332 return -EOPNOTSUPP;
333 }
334
297 /* If its not a media command, its not worth it */ 335 /* If its not a media command, its not worth it */
298 if (atapi_cmd_type(qc->cdb[0]) == ATAPI_MISC) 336 if (atapi_cmd_type(qc->cdb[0]) == ATAPI_MISC)
299 return -EOPNOTSUPP; 337 return -EOPNOTSUPP;
@@ -359,6 +397,7 @@ static struct ata_port_operations ali_20_port_ops = {
359 397
360 .tf_load = ata_tf_load, 398 .tf_load = ata_tf_load,
361 .tf_read = ata_tf_read, 399 .tf_read = ata_tf_read,
400 .check_atapi_dma = ali_check_atapi_dma,
362 .check_status = ata_check_status, 401 .check_status = ata_check_status,
363 .exec_command = ata_exec_command, 402 .exec_command = ata_exec_command,
364 .dev_select = ata_std_dev_select, 403 .dev_select = ata_std_dev_select,
@@ -438,6 +477,7 @@ static struct ata_port_operations ali_c5_port_ops = {
438 .check_status = ata_check_status, 477 .check_status = ata_check_status,
439 .exec_command = ata_exec_command, 478 .exec_command = ata_exec_command,
440 .dev_select = ata_std_dev_select, 479 .dev_select = ata_std_dev_select,
480 .dev_config = ali_warn_atapi_dma,
441 481
442 .freeze = ata_bmdma_freeze, 482 .freeze = ata_bmdma_freeze,
443 .thaw = ata_bmdma_thaw, 483 .thaw = ata_bmdma_thaw,
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 503245a1eafa..7c5b2dd9a1a1 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -269,7 +269,11 @@ static u8 sil680_init_chip(struct pci_dev *pdev, int *try_mmio)
269 dev_dbg(&pdev->dev, "sil680: BA5_EN = %d clock = %02X\n", 269 dev_dbg(&pdev->dev, "sil680: BA5_EN = %d clock = %02X\n",
270 tmpbyte & 1, tmpbyte & 0x30); 270 tmpbyte & 1, tmpbyte & 0x30);
271 271
272 *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5); 272 *try_mmio = 0;
273#ifdef CONFIG_PPC_MERGE
274 if (machine_is(cell))
275 *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5);
276#endif
273 277
274 switch(tmpbyte & 0x30) { 278 switch(tmpbyte & 0x30) {
275 case 0x00: 279 case 0x00:
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 07791a7a48a5..9d1e3cad4aa9 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1256,7 +1256,6 @@ static int sata_fsl_probe(struct of_device *ofdev,
1256 void __iomem *ssr_base = NULL; 1256 void __iomem *ssr_base = NULL;
1257 void __iomem *csr_base = NULL; 1257 void __iomem *csr_base = NULL;
1258 struct sata_fsl_host_priv *host_priv = NULL; 1258 struct sata_fsl_host_priv *host_priv = NULL;
1259 struct resource *r;
1260 int irq; 1259 int irq;
1261 struct ata_host *host; 1260 struct ata_host *host;
1262 1261
@@ -1266,8 +1265,6 @@ static int sata_fsl_probe(struct of_device *ofdev,
1266 dev_printk(KERN_INFO, &ofdev->dev, 1265 dev_printk(KERN_INFO, &ofdev->dev,
1267 "Sata FSL Platform/CSB Driver init\n"); 1266 "Sata FSL Platform/CSB Driver init\n");
1268 1267
1269 r = kmalloc(sizeof(struct resource), GFP_KERNEL);
1270
1271 hcr_base = of_iomap(ofdev->node, 0); 1268 hcr_base = of_iomap(ofdev->node, 0);
1272 if (!hcr_base) 1269 if (!hcr_base)
1273 goto error_exit_with_cleanup; 1270 goto error_exit_with_cleanup;
@@ -1348,10 +1345,7 @@ static int sata_fsl_remove(struct of_device *ofdev)
1348 1345
1349static struct of_device_id fsl_sata_match[] = { 1346static struct of_device_id fsl_sata_match[] = {
1350 { 1347 {
1351 .compatible = "fsl,mpc8315-sata", 1348 .compatible = "fsl,pq-sata",
1352 },
1353 {
1354 .compatible = "fsl,mpc8379-sata",
1355 }, 1349 },
1356 {}, 1350 {},
1357}; 1351};
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 47c57a4294b7..98099f526d82 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -978,6 +978,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
978 /* Docs are vague about this atm_hdr field. By the way, the FS 978 /* Docs are vague about this atm_hdr field. By the way, the FS
979 * chip makes odd errors if lower bits are set.... -- REW */ 979 * chip makes odd errors if lower bits are set.... -- REW */
980 tc->atm_hdr = (vpi << 20) | (vci << 4); 980 tc->atm_hdr = (vpi << 20) | (vci << 4);
981 tmc0 = 0;
981 { 982 {
982 int pcr = atm_pcr_goal (txtp); 983 int pcr = atm_pcr_goal (txtp);
983 984
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 2e3395b7e8c1..ffc4a5a41946 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -3000,8 +3000,7 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
3000 3000
3001/* eeprom routines -- see 4.7 */ 3001/* eeprom routines -- see 4.7 */
3002 3002
3003u8 3003static u8 read_prom_byte(struct he_dev *he_dev, int addr)
3004read_prom_byte(struct he_dev *he_dev, int addr)
3005{ 3004{
3006 u32 val = 0, tmp_read = 0; 3005 u32 val = 0, tmp_read = 0;
3007 int i, j = 0; 3006 int i, j = 0;
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index b967919fb7e2..28d77b5195de 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -2016,8 +2016,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
2016 return 0; 2016 return 0;
2017} 2017}
2018 2018
2019int 2019static int idt77252_send(struct atm_vcc *vcc, struct sk_buff *skb)
2020idt77252_send(struct atm_vcc *vcc, struct sk_buff *skb)
2021{ 2020{
2022 return idt77252_send_skb(vcc, skb, 0); 2021 return idt77252_send_skb(vcc, skb, 0);
2023} 2022}
@@ -3072,8 +3071,7 @@ idt77252_dev_open(struct idt77252_dev *card)
3072 return 0; 3071 return 0;
3073} 3072}
3074 3073
3075void 3074static void idt77252_dev_close(struct atm_dev *dev)
3076idt77252_dev_close(struct atm_dev *dev)
3077{ 3075{
3078 struct idt77252_dev *card = dev->dev_data; 3076 struct idt77252_dev *card = dev->dev_data;
3079 u32 conf; 3077 u32 conf;
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index ef52452640e0..670c093ed25f 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -958,6 +958,7 @@ static void ia_suni_pm7345_init (IADEV *iadev)
958 958
959/***************************** IA_LIB END *****************************/ 959/***************************** IA_LIB END *****************************/
960 960
961#ifdef CONFIG_ATM_IA_DEBUG
961static int tcnter = 0; 962static int tcnter = 0;
962static void xdump( u_char* cp, int length, char* prefix ) 963static void xdump( u_char* cp, int length, char* prefix )
963{ 964{
@@ -992,6 +993,7 @@ static void xdump( u_char* cp, int length, char* prefix )
992 } 993 }
993 994
994} /* close xdump(... */ 995} /* close xdump(... */
996#endif /* CONFIG_ATM_IA_DEBUG */
995 997
996 998
997static struct atm_dev *ia_boards = NULL; 999static struct atm_dev *ia_boards = NULL;
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index bf31a0170a48..9a6537f14401 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -133,6 +133,7 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
133{ 133{
134 va_list args; 134 va_list args;
135 char *name; 135 char *name;
136 int ret;
136 137
137 va_start(args, fmt); 138 va_start(args, fmt);
138 name = kvasprintf(GFP_KERNEL, fmt, args); 139 name = kvasprintf(GFP_KERNEL, fmt, args);
@@ -141,7 +142,9 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
141 if (!name) 142 if (!name)
142 return -ENOMEM; 143 return -ENOMEM;
143 144
144 return kobject_add(kobj, &drv->p->kobj, "%s", name); 145 ret = kobject_add(kobj, &drv->p->kobj, "%s", name);
146 kfree(name);
147 return ret;
145} 148}
146EXPORT_SYMBOL_GPL(driver_add_kobj); 149EXPORT_SYMBOL_GPL(driver_add_kobj);
147 150
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 55bd35c0f082..9c9627e8e334 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -50,6 +50,7 @@
50#include <scsi/sg.h> 50#include <scsi/sg.h>
51#include <scsi/scsi_ioctl.h> 51#include <scsi/scsi_ioctl.h>
52#include <linux/cdrom.h> 52#include <linux/cdrom.h>
53#include <linux/scatterlist.h>
53 54
54#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) 55#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
55#define DRIVER_NAME "HP CISS Driver (v 3.6.14)" 56#define DRIVER_NAME "HP CISS Driver (v 3.6.14)"
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b53fdb0a282c..60cc54368b66 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -153,6 +153,12 @@ static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size,
153 struct kvec iov; 153 struct kvec iov;
154 sigset_t blocked, oldset; 154 sigset_t blocked, oldset;
155 155
156 if (unlikely(!sock)) {
157 printk(KERN_ERR "%s: Attempted %s on closed socket in sock_xmit\n",
158 lo->disk->disk_name, (send ? "send" : "recv"));
159 return -EINVAL;
160 }
161
156 /* Allow interception of SIGKILL only 162 /* Allow interception of SIGKILL only
157 * Don't allow other signals to interrupt the transmission */ 163 * Don't allow other signals to interrupt the transmission */
158 siginitsetinv(&blocked, sigmask(SIGKILL)); 164 siginitsetinv(&blocked, sigmask(SIGKILL));
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index c452e2d355ee..27bfe72aab59 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -8,6 +8,7 @@
8 * and is not licensed separately. See file COPYING for details. 8 * and is not licensed separately. See file COPYING for details.
9 * 9 *
10 * TODO (sorted by decreasing priority) 10 * TODO (sorted by decreasing priority)
11 * -- Return sense now that rq allows it (we always auto-sense anyway).
11 * -- set readonly flag for CDs, set removable flag for CF readers 12 * -- set readonly flag for CDs, set removable flag for CF readers
12 * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) 13 * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch)
13 * -- verify the 13 conditions and do bulk resets 14 * -- verify the 13 conditions and do bulk resets
@@ -359,7 +360,8 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
359static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, 360static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
360 struct ub_scsi_cmd *cmd, struct ub_request *urq); 361 struct ub_scsi_cmd *cmd, struct ub_request *urq);
361static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); 362static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
362static void ub_end_rq(struct request *rq, unsigned int status); 363static void ub_end_rq(struct request *rq, unsigned int status,
364 unsigned int cmd_len);
363static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, 365static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
364 struct ub_request *urq, struct ub_scsi_cmd *cmd); 366 struct ub_request *urq, struct ub_scsi_cmd *cmd);
365static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd); 367static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
@@ -642,13 +644,13 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
642 644
643 if (atomic_read(&sc->poison)) { 645 if (atomic_read(&sc->poison)) {
644 blkdev_dequeue_request(rq); 646 blkdev_dequeue_request(rq);
645 ub_end_rq(rq, DID_NO_CONNECT << 16); 647 ub_end_rq(rq, DID_NO_CONNECT << 16, blk_rq_bytes(rq));
646 return 0; 648 return 0;
647 } 649 }
648 650
649 if (lun->changed && !blk_pc_request(rq)) { 651 if (lun->changed && !blk_pc_request(rq)) {
650 blkdev_dequeue_request(rq); 652 blkdev_dequeue_request(rq);
651 ub_end_rq(rq, SAM_STAT_CHECK_CONDITION); 653 ub_end_rq(rq, SAM_STAT_CHECK_CONDITION, blk_rq_bytes(rq));
652 return 0; 654 return 0;
653 } 655 }
654 656
@@ -701,7 +703,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
701 703
702drop: 704drop:
703 ub_put_cmd(lun, cmd); 705 ub_put_cmd(lun, cmd);
704 ub_end_rq(rq, DID_ERROR << 16); 706 ub_end_rq(rq, DID_ERROR << 16, blk_rq_bytes(rq));
705 return 0; 707 return 0;
706} 708}
707 709
@@ -770,6 +772,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
770 struct ub_request *urq = cmd->back; 772 struct ub_request *urq = cmd->back;
771 struct request *rq; 773 struct request *rq;
772 unsigned int scsi_status; 774 unsigned int scsi_status;
775 unsigned int cmd_len;
773 776
774 rq = urq->rq; 777 rq = urq->rq;
775 778
@@ -779,8 +782,18 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
779 rq->data_len = 0; 782 rq->data_len = 0;
780 else 783 else
781 rq->data_len -= cmd->act_len; 784 rq->data_len -= cmd->act_len;
785 scsi_status = 0;
786 } else {
787 if (cmd->act_len != cmd->len) {
788 if ((cmd->key == MEDIUM_ERROR ||
789 cmd->key == UNIT_ATTENTION) &&
790 ub_rw_cmd_retry(sc, lun, urq, cmd) == 0)
791 return;
792 scsi_status = SAM_STAT_CHECK_CONDITION;
793 } else {
794 scsi_status = 0;
795 }
782 } 796 }
783 scsi_status = 0;
784 } else { 797 } else {
785 if (blk_pc_request(rq)) { 798 if (blk_pc_request(rq)) {
786 /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ 799 /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */
@@ -801,14 +814,17 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
801 814
802 urq->rq = NULL; 815 urq->rq = NULL;
803 816
817 cmd_len = cmd->len;
804 ub_put_cmd(lun, cmd); 818 ub_put_cmd(lun, cmd);
805 ub_end_rq(rq, scsi_status); 819 ub_end_rq(rq, scsi_status, cmd_len);
806 blk_start_queue(lun->disk->queue); 820 blk_start_queue(lun->disk->queue);
807} 821}
808 822
809static void ub_end_rq(struct request *rq, unsigned int scsi_status) 823static void ub_end_rq(struct request *rq, unsigned int scsi_status,
824 unsigned int cmd_len)
810{ 825{
811 int error; 826 int error;
827 long rqlen;
812 828
813 if (scsi_status == 0) { 829 if (scsi_status == 0) {
814 error = 0; 830 error = 0;
@@ -816,8 +832,12 @@ static void ub_end_rq(struct request *rq, unsigned int scsi_status)
816 error = -EIO; 832 error = -EIO;
817 rq->errors = scsi_status; 833 rq->errors = scsi_status;
818 } 834 }
819 if (__blk_end_request(rq, error, blk_rq_bytes(rq))) 835 rqlen = blk_rq_bytes(rq); /* Oddly enough, this is the residue. */
820 BUG(); 836 if (__blk_end_request(rq, error, cmd_len)) {
837 printk(KERN_WARNING DRV_NAME
838 ": __blk_end_request blew, %s-cmd total %u rqlen %ld\n",
839 blk_pc_request(rq)? "pc": "fs", cmd_len, rqlen);
840 }
821} 841}
822 842
823static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, 843static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index e5a0e97cfdda..141f4dfa0a11 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -122,8 +122,9 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
122 } else { 122 } else {
123 address = gart_info->addr; 123 address = gart_info->addr;
124 bus_address = gart_info->bus_addr; 124 bus_address = gart_info->bus_addr;
125 DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", 125 DRM_DEBUG("PCI: Gart Table: VRAM %08LX mapped at %08lX\n",
126 bus_address, (unsigned long)address); 126 (unsigned long long)bus_address,
127 (unsigned long)address);
127 } 128 }
128 129
129 pci_gart = (u32 *) address; 130 pci_gart = (u32 *) address;
@@ -167,6 +168,12 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
167 } 168 }
168 } 169 }
169 170
171 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN)
172 dma_sync_single_for_device(&dev->pdev->dev,
173 bus_address,
174 max_pages * sizeof(u32),
175 PCI_DMA_TODEVICE);
176
170 ret = 1; 177 ret = 1;
171 178
172#if defined(__i386__) || defined(__x86_64__) 179#if defined(__i386__) || defined(__x86_64__)
diff --git a/drivers/char/drm/drm_scatter.c b/drivers/char/drm/drm_scatter.c
index 26d8f675ed5d..b2b0f3d41714 100644
--- a/drivers/char/drm/drm_scatter.c
+++ b/drivers/char/drm/drm_scatter.c
@@ -36,6 +36,15 @@
36 36
37#define DEBUG_SCATTER 0 37#define DEBUG_SCATTER 0
38 38
39static inline void *drm_vmalloc_dma(unsigned long size)
40{
41#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
42 return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL | _PAGE_NO_CACHE);
43#else
44 return vmalloc_32(size);
45#endif
46}
47
39void drm_sg_cleanup(struct drm_sg_mem * entry) 48void drm_sg_cleanup(struct drm_sg_mem * entry)
40{ 49{
41 struct page *page; 50 struct page *page;
@@ -104,7 +113,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
104 } 113 }
105 memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr)); 114 memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr));
106 115
107 entry->virtual = vmalloc_32(pages << PAGE_SHIFT); 116 entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT);
108 if (!entry->virtual) { 117 if (!entry->virtual) {
109 drm_free(entry->busaddr, 118 drm_free(entry->busaddr,
110 entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES); 119 entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES);
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 3d65c4dcd0c6..945df72a51a9 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -54,13 +54,24 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma)
54 pgprot_val(tmp) |= _PAGE_NO_CACHE; 54 pgprot_val(tmp) |= _PAGE_NO_CACHE;
55 if (map_type == _DRM_REGISTERS) 55 if (map_type == _DRM_REGISTERS)
56 pgprot_val(tmp) |= _PAGE_GUARDED; 56 pgprot_val(tmp) |= _PAGE_GUARDED;
57#endif 57#elif defined(__ia64__)
58#if defined(__ia64__)
59 if (efi_range_is_wc(vma->vm_start, vma->vm_end - 58 if (efi_range_is_wc(vma->vm_start, vma->vm_end -
60 vma->vm_start)) 59 vma->vm_start))
61 tmp = pgprot_writecombine(tmp); 60 tmp = pgprot_writecombine(tmp);
62 else 61 else
63 tmp = pgprot_noncached(tmp); 62 tmp = pgprot_noncached(tmp);
63#elif defined(__sparc__)
64 tmp = pgprot_noncached(tmp);
65#endif
66 return tmp;
67}
68
69static pgprot_t drm_dma_prot(uint32_t map_type, struct vm_area_struct *vma)
70{
71 pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
72
73#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
74 tmp |= _PAGE_NO_CACHE;
64#endif 75#endif
65 return tmp; 76 return tmp;
66} 77}
@@ -603,9 +614,6 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
603 offset = dev->driver->get_reg_ofs(dev); 614 offset = dev->driver->get_reg_ofs(dev);
604 vma->vm_flags |= VM_IO; /* not in core dump */ 615 vma->vm_flags |= VM_IO; /* not in core dump */
605 vma->vm_page_prot = drm_io_prot(map->type, vma); 616 vma->vm_page_prot = drm_io_prot(map->type, vma);
606#ifdef __sparc__
607 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
608#endif
609 if (io_remap_pfn_range(vma, vma->vm_start, 617 if (io_remap_pfn_range(vma, vma->vm_start,
610 (map->offset + offset) >> PAGE_SHIFT, 618 (map->offset + offset) >> PAGE_SHIFT,
611 vma->vm_end - vma->vm_start, 619 vma->vm_end - vma->vm_start,
@@ -624,6 +632,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
624 page_to_pfn(virt_to_page(map->handle)), 632 page_to_pfn(virt_to_page(map->handle)),
625 vma->vm_end - vma->vm_start, vma->vm_page_prot)) 633 vma->vm_end - vma->vm_start, vma->vm_page_prot))
626 return -EAGAIN; 634 return -EAGAIN;
635 vma->vm_page_prot = drm_dma_prot(map->type, vma);
627 /* fall through to _DRM_SHM */ 636 /* fall through to _DRM_SHM */
628 case _DRM_SHM: 637 case _DRM_SHM:
629 vma->vm_ops = &drm_vm_shm_ops; 638 vma->vm_ops = &drm_vm_shm_ops;
@@ -631,6 +640,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
631 /* Don't let this area swap. Change when 640 /* Don't let this area swap. Change when
632 DRM_KERNEL advisory is supported. */ 641 DRM_KERNEL advisory is supported. */
633 vma->vm_flags |= VM_RESERVED; 642 vma->vm_flags |= VM_RESERVED;
643 vma->vm_page_prot = drm_dma_prot(map->type, vma);
634 break; 644 break;
635 case _DRM_SCATTER_GATHER: 645 case _DRM_SCATTER_GATHER:
636 vma->vm_ops = &drm_vm_sg_ops; 646 vma->vm_ops = &drm_vm_sg_ops;
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index e9d6663bec73..a043bb12301a 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -804,6 +804,9 @@ void i915_driver_lastclose(struct drm_device * dev)
804{ 804{
805 drm_i915_private_t *dev_priv = dev->dev_private; 805 drm_i915_private_t *dev_priv = dev->dev_private;
806 806
807 if (!dev_priv)
808 return;
809
807 if (dev_priv->agp_heap) 810 if (dev_priv->agp_heap)
808 i915_mem_takedown(&(dev_priv->agp_heap)); 811 i915_mem_takedown(&(dev_priv->agp_heap));
809 812
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index c10d128e34db..675d88bda066 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -1092,8 +1092,8 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
1092#define IS_I915G(dev) ((dev)->pci_device == 0x2582 || (dev)->pci_device == 0x258a) 1092#define IS_I915G(dev) ((dev)->pci_device == 0x2582 || (dev)->pci_device == 0x258a)
1093#define IS_I915GM(dev) ((dev)->pci_device == 0x2592) 1093#define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
1094#define IS_I945G(dev) ((dev)->pci_device == 0x2772) 1094#define IS_I945G(dev) ((dev)->pci_device == 0x2772)
1095#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2) 1095#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2 ||\
1096 1096 (dev)->pci_device == 0x27AE)
1097#define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \ 1097#define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \
1098 (dev)->pci_device == 0x2982 || \ 1098 (dev)->pci_device == 0x2982 || \
1099 (dev)->pci_device == 0x2992 || \ 1099 (dev)->pci_device == 0x2992 || \
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c
index 0f4afc44245c..f535812e4057 100644
--- a/drivers/char/drm/r300_cmdbuf.c
+++ b/drivers/char/drm/r300_cmdbuf.c
@@ -729,6 +729,47 @@ static void r300_discard_buffer(struct drm_device * dev, struct drm_buf * buf)
729 buf->used = 0; 729 buf->used = 0;
730} 730}
731 731
732static void r300_cmd_wait(drm_radeon_private_t * dev_priv,
733 drm_r300_cmd_header_t header)
734{
735 u32 wait_until;
736 RING_LOCALS;
737
738 if (!header.wait.flags)
739 return;
740
741 wait_until = 0;
742
743 switch(header.wait.flags) {
744 case R300_WAIT_2D:
745 wait_until = RADEON_WAIT_2D_IDLE;
746 break;
747 case R300_WAIT_3D:
748 wait_until = RADEON_WAIT_3D_IDLE;
749 break;
750 case R300_NEW_WAIT_2D_3D:
751 wait_until = RADEON_WAIT_2D_IDLE|RADEON_WAIT_3D_IDLE;
752 break;
753 case R300_NEW_WAIT_2D_2D_CLEAN:
754 wait_until = RADEON_WAIT_2D_IDLE|RADEON_WAIT_2D_IDLECLEAN;
755 break;
756 case R300_NEW_WAIT_3D_3D_CLEAN:
757 wait_until = RADEON_WAIT_3D_IDLE|RADEON_WAIT_3D_IDLECLEAN;
758 break;
759 case R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN:
760 wait_until = RADEON_WAIT_2D_IDLE|RADEON_WAIT_2D_IDLECLEAN;
761 wait_until |= RADEON_WAIT_3D_IDLE|RADEON_WAIT_3D_IDLECLEAN;
762 break;
763 default:
764 return;
765 }
766
767 BEGIN_RING(2);
768 OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0));
769 OUT_RING(wait_until);
770 ADVANCE_RING();
771}
772
732static int r300_scratch(drm_radeon_private_t *dev_priv, 773static int r300_scratch(drm_radeon_private_t *dev_priv,
733 drm_radeon_kcmd_buffer_t *cmdbuf, 774 drm_radeon_kcmd_buffer_t *cmdbuf,
734 drm_r300_cmd_header_t header) 775 drm_r300_cmd_header_t header)
@@ -909,19 +950,8 @@ int r300_do_cp_cmdbuf(struct drm_device *dev,
909 break; 950 break;
910 951
911 case R300_CMD_WAIT: 952 case R300_CMD_WAIT:
912 /* simple enough, we can do it here */
913 DRM_DEBUG("R300_CMD_WAIT\n"); 953 DRM_DEBUG("R300_CMD_WAIT\n");
914 if (header.wait.flags == 0) 954 r300_cmd_wait(dev_priv, header);
915 break; /* nothing to do */
916
917 {
918 RING_LOCALS;
919
920 BEGIN_RING(2);
921 OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0));
922 OUT_RING((header.wait.flags & 0xf) << 14);
923 ADVANCE_RING();
924 }
925 break; 955 break;
926 956
927 case R300_CMD_SCRATCH: 957 case R300_CMD_SCRATCH:
diff --git a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h
index 71e5b21fad2c..aab82e121e07 100644
--- a/drivers/char/drm/radeon_drm.h
+++ b/drivers/char/drm/radeon_drm.h
@@ -225,8 +225,20 @@ typedef union {
225#define R300_CMD_WAIT 7 225#define R300_CMD_WAIT 7
226# define R300_WAIT_2D 0x1 226# define R300_WAIT_2D 0x1
227# define R300_WAIT_3D 0x2 227# define R300_WAIT_3D 0x2
228/* these two defines are DOING IT WRONG - however
229 * we have userspace which relies on using these.
230 * The wait interface is backwards compat new
231 * code should use the NEW_WAIT defines below
232 * THESE ARE NOT BIT FIELDS
233 */
228# define R300_WAIT_2D_CLEAN 0x3 234# define R300_WAIT_2D_CLEAN 0x3
229# define R300_WAIT_3D_CLEAN 0x4 235# define R300_WAIT_3D_CLEAN 0x4
236
237# define R300_NEW_WAIT_2D_3D 0x3
238# define R300_NEW_WAIT_2D_2D_CLEAN 0x4
239# define R300_NEW_WAIT_3D_3D_CLEAN 0x6
240# define R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN 0x8
241
230#define R300_CMD_SCRATCH 8 242#define R300_CMD_SCRATCH 8
231 243
232typedef union { 244typedef union {
diff --git a/drivers/char/drm/radeon_mem.c b/drivers/char/drm/radeon_mem.c
index 78b34fa7c89a..4af5286a36fb 100644
--- a/drivers/char/drm/radeon_mem.c
+++ b/drivers/char/drm/radeon_mem.c
@@ -88,7 +88,7 @@ static struct mem_block *alloc_block(struct mem_block *heap, int size,
88 88
89 list_for_each(p, heap) { 89 list_for_each(p, heap) {
90 int start = (p->start + mask) & ~mask; 90 int start = (p->start + mask) & ~mask;
91 if (p->file_priv == 0 && start + size <= p->start + p->size) 91 if (p->file_priv == NULL && start + size <= p->start + p->size)
92 return split_block(p, start, size, file_priv); 92 return split_block(p, start, size, file_priv);
93 } 93 }
94 94
@@ -113,7 +113,7 @@ static void free_block(struct mem_block *p)
113 /* Assumes a single contiguous range. Needs a special file_priv in 113 /* Assumes a single contiguous range. Needs a special file_priv in
114 * 'heap' to stop it being subsumed. 114 * 'heap' to stop it being subsumed.
115 */ 115 */
116 if (p->next->file_priv == 0) { 116 if (p->next->file_priv == NULL) {
117 struct mem_block *q = p->next; 117 struct mem_block *q = p->next;
118 p->size += q->size; 118 p->size += q->size;
119 p->next = q->next; 119 p->next = q->next;
@@ -121,7 +121,7 @@ static void free_block(struct mem_block *p)
121 drm_free(q, sizeof(*q), DRM_MEM_BUFS); 121 drm_free(q, sizeof(*q), DRM_MEM_BUFS);
122 } 122 }
123 123
124 if (p->prev->file_priv == 0) { 124 if (p->prev->file_priv == NULL) {
125 struct mem_block *q = p->prev; 125 struct mem_block *q = p->prev;
126 q->size += p->size; 126 q->size += p->size;
127 q->next = p->next; 127 q->next = p->next;
@@ -174,7 +174,7 @@ void radeon_mem_release(struct drm_file *file_priv, struct mem_block *heap)
174 * 'heap' to stop it being subsumed. 174 * 'heap' to stop it being subsumed.
175 */ 175 */
176 list_for_each(p, heap) { 176 list_for_each(p, heap) {
177 while (p->file_priv == 0 && p->next->file_priv == 0) { 177 while (p->file_priv == NULL && p->next->file_priv == NULL) {
178 struct mem_block *q = p->next; 178 struct mem_block *q = p->next;
179 p->size += q->size; 179 p->size += q->size;
180 p->next = q->next; 180 p->next = q->next;
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 465ad35ed38f..1399971be689 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -731,14 +731,14 @@ static unsigned long hpet_calibrate(struct hpets *hpetp)
731 731
732int hpet_alloc(struct hpet_data *hdp) 732int hpet_alloc(struct hpet_data *hdp)
733{ 733{
734 u64 cap, mcfg, hpet_config; 734 u64 cap, mcfg;
735 struct hpet_dev *devp; 735 struct hpet_dev *devp;
736 u32 i, ntimer, irq; 736 u32 i, ntimer;
737 struct hpets *hpetp; 737 struct hpets *hpetp;
738 size_t siz; 738 size_t siz;
739 struct hpet __iomem *hpet; 739 struct hpet __iomem *hpet;
740 static struct hpets *last = NULL; 740 static struct hpets *last = NULL;
741 unsigned long period, irq_bitmap; 741 unsigned long period;
742 unsigned long long temp; 742 unsigned long long temp;
743 743
744 /* 744 /*
@@ -765,47 +765,11 @@ int hpet_alloc(struct hpet_data *hdp)
765 hpetp->hp_hpet_phys = hdp->hd_phys_address; 765 hpetp->hp_hpet_phys = hdp->hd_phys_address;
766 766
767 hpetp->hp_ntimer = hdp->hd_nirqs; 767 hpetp->hp_ntimer = hdp->hd_nirqs;
768 hpet = hpetp->hp_hpet;
769
770 /* Assign IRQs statically for legacy devices */
771 hpetp->hp_dev[0].hd_hdwirq = hdp->hd_irq[0];
772 hpetp->hp_dev[1].hd_hdwirq = hdp->hd_irq[1];
773
774 /* Assign IRQs dynamically for the others */
775 for (i = 2, devp = &hpetp->hp_dev[2]; i < hdp->hd_nirqs; i++, devp++) {
776 struct hpet_timer __iomem *timer;
777 768
778 timer = &hpet->hpet_timers[devp - hpetp->hp_dev]; 769 for (i = 0; i < hdp->hd_nirqs; i++)
770 hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i];
779 771
780 /* Check if there's already an IRQ assigned to the timer */ 772 hpet = hpetp->hp_hpet;
781 if (hdp->hd_irq[i]) {
782 hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i];
783 continue;
784 }
785
786 hpet_config = readq(&timer->hpet_config);
787 irq_bitmap = (hpet_config & Tn_INT_ROUTE_CAP_MASK)
788 >> Tn_INT_ROUTE_CAP_SHIFT;
789 if (!irq_bitmap)
790 irq = 0; /* No valid IRQ Assignable */
791 else {
792 irq = find_first_bit(&irq_bitmap, 32);
793 do {
794 hpet_config |= irq << Tn_INT_ROUTE_CNF_SHIFT;
795 writeq(hpet_config, &timer->hpet_config);
796
797 /*
798 * Verify whether we have written a valid
799 * IRQ number by reading it back again
800 */
801 hpet_config = readq(&timer->hpet_config);
802 if (irq == (hpet_config & Tn_INT_ROUTE_CNF_MASK)
803 >> Tn_INT_ROUTE_CNF_SHIFT)
804 break; /* Success */
805 } while ((irq = (find_next_bit(&irq_bitmap, 32, irq))));
806 }
807 hpetp->hp_dev[i].hd_hdwirq = irq;
808 }
809 773
810 cap = readq(&hpet->hpet_cap); 774 cap = readq(&hpet->hpet_cap);
811 775
@@ -836,8 +800,7 @@ int hpet_alloc(struct hpet_data *hdp)
836 hpetp->hp_which, hdp->hd_phys_address, 800 hpetp->hp_which, hdp->hd_phys_address,
837 hpetp->hp_ntimer > 1 ? "s" : ""); 801 hpetp->hp_ntimer > 1 ? "s" : "");
838 for (i = 0; i < hpetp->hp_ntimer; i++) 802 for (i = 0; i < hpetp->hp_ntimer; i++)
839 printk("%s %d", i > 0 ? "," : "", 803 printk("%s %d", i > 0 ? "," : "", hdp->hd_irq[i]);
840 hpetp->hp_dev[i].hd_hdwirq);
841 printk("\n"); 804 printk("\n");
842 805
843 printk(KERN_INFO "hpet%u: %u %d-bit timers, %Lu Hz\n", 806 printk(KERN_INFO "hpet%u: %u %d-bit timers, %Lu Hz\n",
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index d6567b32fb5c..9c25320121ef 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -644,12 +644,12 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands,
644 // Normal Expected path - We still hold LOCK 644 // Normal Expected path - We still hold LOCK
645 break; /* from for()- Enough room: goto proceed */ 645 break; /* from for()- Enough room: goto proceed */
646 } 646 }
647 } 647 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize);
648 648 WRITE_UNLOCK_IRQRESTORE(lock_var_p, flags);
649 ip2trace (CHANN, ITRC_QUEUE, 3, 1, totalsize ); 649 } else
650 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize);
650 651
651 // Prepare to wait for buffers to empty 652 /* Prepare to wait for buffers to empty */
652 WRITE_UNLOCK_IRQRESTORE(lock_var_p,flags);
653 serviceOutgoingFifo(pB); // Dump what we got 653 serviceOutgoingFifo(pB); // Dump what we got
654 654
655 if (timeout == 0) { 655 if (timeout == 0) {
@@ -1830,6 +1830,8 @@ i2StripFifo(i2eBordStrPtr pB)
1830 default: // Neither packet? should be impossible 1830 default: // Neither packet? should be impossible
1831 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 5, 1, 1831 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 5, 1,
1832 PTYPE_OF(pB->i2eLeadoffWord) ); 1832 PTYPE_OF(pB->i2eLeadoffWord) );
1833 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,
1834 bflags);
1833 1835
1834 break; 1836 break;
1835 } // End of switch on type of packets 1837 } // End of switch on type of packets
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 46b2a1cc8b54..0c09409fa45d 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1183,7 +1183,7 @@ static int copy_from_read_buf(struct tty_struct *tty,
1183 return retval; 1183 return retval;
1184} 1184}
1185 1185
1186extern ssize_t redirected_tty_write(struct file *, const char *, 1186extern ssize_t redirected_tty_write(struct file *, const char __user *,
1187 size_t, loff_t *); 1187 size_t, loff_t *);
1188 1188
1189/** 1189/**
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 6d0dc5f9b6bb..6a6843a0a674 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -438,7 +438,7 @@ static void read_mem32(u32 *buf, const void __iomem *mem_addr_start,
438 u32 size_bytes) 438 u32 size_bytes)
439{ 439{
440 u32 i = 0; 440 u32 i = 0;
441 const u32 *ptr = (__force u32 *) mem_addr_start; 441 const u32 __iomem *ptr = mem_addr_start;
442 u16 *buf16; 442 u16 *buf16;
443 443
444 if (unlikely(!ptr || !buf)) 444 if (unlikely(!ptr || !buf))
@@ -448,11 +448,11 @@ static void read_mem32(u32 *buf, const void __iomem *mem_addr_start,
448 switch (size_bytes) { 448 switch (size_bytes) {
449 case 2: /* 2 bytes */ 449 case 2: /* 2 bytes */
450 buf16 = (u16 *) buf; 450 buf16 = (u16 *) buf;
451 *buf16 = __le16_to_cpu(readw((void __iomem *)ptr)); 451 *buf16 = __le16_to_cpu(readw(ptr));
452 goto out; 452 goto out;
453 break; 453 break;
454 case 4: /* 4 bytes */ 454 case 4: /* 4 bytes */
455 *(buf) = __le32_to_cpu(readl((void __iomem *)ptr)); 455 *(buf) = __le32_to_cpu(readl(ptr));
456 goto out; 456 goto out;
457 break; 457 break;
458 } 458 }
@@ -461,11 +461,11 @@ static void read_mem32(u32 *buf, const void __iomem *mem_addr_start,
461 if (size_bytes - i == 2) { 461 if (size_bytes - i == 2) {
462 /* Handle 2 bytes in the end */ 462 /* Handle 2 bytes in the end */
463 buf16 = (u16 *) buf; 463 buf16 = (u16 *) buf;
464 *(buf16) = __le16_to_cpu(readw((void __iomem *)ptr)); 464 *(buf16) = __le16_to_cpu(readw(ptr));
465 i += 2; 465 i += 2;
466 } else { 466 } else {
467 /* Read 4 bytes */ 467 /* Read 4 bytes */
468 *(buf) = __le32_to_cpu(readl((void __iomem *)ptr)); 468 *(buf) = __le32_to_cpu(readl(ptr));
469 i += 4; 469 i += 4;
470 } 470 }
471 buf++; 471 buf++;
@@ -484,7 +484,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
484 u32 size_bytes) 484 u32 size_bytes)
485{ 485{
486 u32 i = 0; 486 u32 i = 0;
487 u32 *ptr = (__force u32 *) mem_addr_start; 487 u32 __iomem *ptr = mem_addr_start;
488 const u16 *buf16; 488 const u16 *buf16;
489 489
490 if (unlikely(!ptr || !buf)) 490 if (unlikely(!ptr || !buf))
@@ -494,7 +494,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
494 switch (size_bytes) { 494 switch (size_bytes) {
495 case 2: /* 2 bytes */ 495 case 2: /* 2 bytes */
496 buf16 = (const u16 *)buf; 496 buf16 = (const u16 *)buf;
497 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr); 497 writew(__cpu_to_le16(*buf16), ptr);
498 return 2; 498 return 2;
499 break; 499 break;
500 case 1: /* 500 case 1: /*
@@ -502,7 +502,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
502 * so falling through.. 502 * so falling through..
503 */ 503 */
504 case 4: /* 4 bytes */ 504 case 4: /* 4 bytes */
505 writel(__cpu_to_le32(*buf), (void __iomem *)ptr); 505 writel(__cpu_to_le32(*buf), ptr);
506 return 4; 506 return 4;
507 break; 507 break;
508 } 508 }
@@ -511,11 +511,11 @@ static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
511 if (size_bytes - i == 2) { 511 if (size_bytes - i == 2) {
512 /* 2 bytes */ 512 /* 2 bytes */
513 buf16 = (const u16 *)buf; 513 buf16 = (const u16 *)buf;
514 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr); 514 writew(__cpu_to_le16(*buf16), ptr);
515 i += 2; 515 i += 2;
516 } else { 516 } else {
517 /* 4 bytes */ 517 /* 4 bytes */
518 writel(__cpu_to_le32(*buf), (void __iomem *)ptr); 518 writel(__cpu_to_le32(*buf), ptr);
519 i += 4; 519 i += 4;
520 } 520 }
521 buf++; 521 buf++;
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index 991119c9f473..9b52892a501f 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -425,8 +425,10 @@ int RIOApel(struct rio_info *p)
425 425
426 MapP = &p->RIOConnectTable[Next++]; 426 MapP = &p->RIOConnectTable[Next++];
427 MapP->HostUniqueNum = HostP->UniqueNum; 427 MapP->HostUniqueNum = HostP->UniqueNum;
428 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) 428 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
429 rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
429 continue; 430 continue;
431 }
430 MapP->RtaUniqueNum = 0; 432 MapP->RtaUniqueNum = 0;
431 MapP->ID = 0; 433 MapP->ID = 0;
432 MapP->Flags = SLOT_IN_USE; 434 MapP->Flags = SLOT_IN_USE;
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index a4f0b1e3e7fa..cfa54361473f 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -319,6 +319,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
319 PortP->State |= RIO_WOPEN; 319 PortP->State |= RIO_WOPEN;
320 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 320 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
321 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 321 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
322 rio_spin_lock_irqsave(&PortP->portSem, flags);
322 /* 323 /*
323 ** ACTION: verify that this is a good thing 324 ** ACTION: verify that this is a good thing
324 ** to do here. -- ??? 325 ** to do here. -- ???
@@ -334,6 +335,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
334 func_exit(); 335 func_exit();
335 return -EINTR; 336 return -EINTR;
336 } 337 }
338 rio_spin_lock_irqsave(&PortP->portSem, flags);
337 } 339 }
338 PortP->State &= ~RIO_WOPEN; 340 PortP->State &= ~RIO_WOPEN;
339 } 341 }
@@ -493,6 +495,7 @@ int riotclose(void *ptr)
493 495
494 if (RIOShortCommand(p, PortP, CLOSE, 1, 0) == RIO_FAIL) { 496 if (RIOShortCommand(p, PortP, CLOSE, 1, 0) == RIO_FAIL) {
495 RIOPreemptiveCmd(p, PortP, FCLOSE); 497 RIOPreemptiveCmd(p, PortP, FCLOSE);
498 rio_spin_lock_irqsave(&PortP->portSem, flags);
496 goto close_end; 499 goto close_end;
497 } 500 }
498 501
@@ -508,6 +511,7 @@ int riotclose(void *ptr)
508 511
509 if (p->RIOHalted) { 512 if (p->RIOHalted) {
510 RIOClearUp(PortP); 513 RIOClearUp(PortP);
514 rio_spin_lock_irqsave(&PortP->portSem, flags);
511 goto close_end; 515 goto close_end;
512 } 516 }
513 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 517 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index d73663a52324..fc555a90bb21 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -67,7 +67,7 @@ static void cpuidle_idle_call(void)
67 /* enter the state and update stats */ 67 /* enter the state and update stats */
68 dev->last_residency = target_state->enter(dev, target_state); 68 dev->last_residency = target_state->enter(dev, target_state);
69 dev->last_state = target_state; 69 dev->last_state = target_state;
70 target_state->time += dev->last_residency; 70 target_state->time += (unsigned long long)dev->last_residency;
71 target_state->usage++; 71 target_state->usage++;
72 72
73 /* give the governor an opportunity to reflect on the outcome */ 73 /* give the governor an opportunity to reflect on the outcome */
@@ -224,7 +224,7 @@ static void poll_idle_init(struct cpuidle_device *dev)
224 state->exit_latency = 0; 224 state->exit_latency = 0;
225 state->target_residency = 0; 225 state->target_residency = 0;
226 state->power_usage = -1; 226 state->power_usage = -1;
227 state->flags = CPUIDLE_FLAG_POLL | CPUIDLE_FLAG_TIME_VALID; 227 state->flags = CPUIDLE_FLAG_POLL;
228 state->enter = poll_idle; 228 state->enter = poll_idle;
229} 229}
230#else 230#else
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 69102ca05685..e949618b9be0 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -218,6 +218,12 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
218 return sprintf(buf, "%u\n", state->_name);\ 218 return sprintf(buf, "%u\n", state->_name);\
219} 219}
220 220
221#define define_show_state_ull_function(_name) \
222static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
223{ \
224 return sprintf(buf, "%llu\n", state->_name);\
225}
226
221#define define_show_state_str_function(_name) \ 227#define define_show_state_str_function(_name) \
222static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ 228static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
223{ \ 229{ \
@@ -228,8 +234,8 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
228 234
229define_show_state_function(exit_latency) 235define_show_state_function(exit_latency)
230define_show_state_function(power_usage) 236define_show_state_function(power_usage)
231define_show_state_function(usage) 237define_show_state_ull_function(usage)
232define_show_state_function(time) 238define_show_state_ull_function(time)
233define_show_state_str_function(name) 239define_show_state_str_function(name)
234define_show_state_str_function(desc) 240define_show_state_str_function(desc)
235 241
diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index 3110bf7014f7..81f3f950cd7d 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -392,8 +392,8 @@ static atomic_t hifn_dev_number;
392 392
393struct hifn_desc 393struct hifn_desc
394{ 394{
395 volatile u32 l; 395 volatile __le32 l;
396 volatile u32 p; 396 volatile __le32 p;
397}; 397};
398 398
399struct hifn_dma { 399struct hifn_dma {
@@ -481,10 +481,10 @@ struct hifn_device
481 481
482struct hifn_base_command 482struct hifn_base_command
483{ 483{
484 volatile u16 masks; 484 volatile __le16 masks;
485 volatile u16 session_num; 485 volatile __le16 session_num;
486 volatile u16 total_source_count; 486 volatile __le16 total_source_count;
487 volatile u16 total_dest_count; 487 volatile __le16 total_dest_count;
488}; 488};
489 489
490#define HIFN_BASE_CMD_COMP 0x0100 /* enable compression engine */ 490#define HIFN_BASE_CMD_COMP 0x0100 /* enable compression engine */
@@ -504,10 +504,10 @@ struct hifn_base_command
504 */ 504 */
505struct hifn_crypt_command 505struct hifn_crypt_command
506{ 506{
507 volatile u16 masks; 507 volatile __le16 masks;
508 volatile u16 header_skip; 508 volatile __le16 header_skip;
509 volatile u16 source_count; 509 volatile __le16 source_count;
510 volatile u16 reserved; 510 volatile __le16 reserved;
511}; 511};
512 512
513#define HIFN_CRYPT_CMD_ALG_MASK 0x0003 /* algorithm: */ 513#define HIFN_CRYPT_CMD_ALG_MASK 0x0003 /* algorithm: */
@@ -670,7 +670,7 @@ static inline u32 hifn_read_0(struct hifn_device *dev, u32 reg)
670{ 670{
671 u32 ret; 671 u32 ret;
672 672
673 ret = readl((char *)(dev->bar[0]) + reg); 673 ret = readl(dev->bar[0] + reg);
674 674
675 return ret; 675 return ret;
676} 676}
@@ -679,19 +679,19 @@ static inline u32 hifn_read_1(struct hifn_device *dev, u32 reg)
679{ 679{
680 u32 ret; 680 u32 ret;
681 681
682 ret = readl((char *)(dev->bar[1]) + reg); 682 ret = readl(dev->bar[1] + reg);
683 683
684 return ret; 684 return ret;
685} 685}
686 686
687static inline void hifn_write_0(struct hifn_device *dev, u32 reg, u32 val) 687static inline void hifn_write_0(struct hifn_device *dev, u32 reg, u32 val)
688{ 688{
689 writel(val, (char *)(dev->bar[0]) + reg); 689 writel(val, dev->bar[0] + reg);
690} 690}
691 691
692static inline void hifn_write_1(struct hifn_device *dev, u32 reg, u32 val) 692static inline void hifn_write_1(struct hifn_device *dev, u32 reg, u32 val)
693{ 693{
694 writel(val, (char *)(dev->bar[1]) + reg); 694 writel(val, dev->bar[1] + reg);
695} 695}
696 696
697static void hifn_wait_puc(struct hifn_device *dev) 697static void hifn_wait_puc(struct hifn_device *dev)
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 72692309398a..df163687c91a 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -1021,11 +1021,11 @@ const u32 mpc8349_dma_ip_feature = FSL_DMA_IP_83XX | FSL_DMA_LITTLE_ENDIAN;
1021 1021
1022static struct of_device_id of_fsl_dma_chan_ids[] = { 1022static struct of_device_id of_fsl_dma_chan_ids[] = {
1023 { 1023 {
1024 .compatible = "fsl,mpc8540-dma-channel", 1024 .compatible = "fsl,eloplus-dma-channel",
1025 .data = (void *)&mpc8540_dma_ip_feature, 1025 .data = (void *)&mpc8540_dma_ip_feature,
1026 }, 1026 },
1027 { 1027 {
1028 .compatible = "fsl,mpc8349-dma-channel", 1028 .compatible = "fsl,elo-dma-channel",
1029 .data = (void *)&mpc8349_dma_ip_feature, 1029 .data = (void *)&mpc8349_dma_ip_feature,
1030 }, 1030 },
1031 {} 1031 {}
@@ -1107,8 +1107,8 @@ err:
1107} 1107}
1108 1108
1109static struct of_device_id of_fsl_dma_ids[] = { 1109static struct of_device_id of_fsl_dma_ids[] = {
1110 { .compatible = "fsl,mpc8540-dma", }, 1110 { .compatible = "fsl,eloplus-dma", },
1111 { .compatible = "fsl,mpc8349-dma", }, 1111 { .compatible = "fsl,elo-dma", },
1112 {} 1112 {}
1113}; 1113};
1114 1114
diff --git a/drivers/dma/fsldma.h b/drivers/dma/fsldma.h
index fddd6aee2a63..6faf07ba0d0e 100644
--- a/drivers/dma/fsldma.h
+++ b/drivers/dma/fsldma.h
@@ -75,12 +75,15 @@
75#define FSL_DMA_DGSR_EOSI 0x02 75#define FSL_DMA_DGSR_EOSI 0x02
76#define FSL_DMA_DGSR_EOLSI 0x01 76#define FSL_DMA_DGSR_EOLSI 0x01
77 77
78typedef u64 __bitwise v64;
79typedef u32 __bitwise v32;
80
78struct fsl_dma_ld_hw { 81struct fsl_dma_ld_hw {
79 u64 __bitwise src_addr; 82 v64 src_addr;
80 u64 __bitwise dst_addr; 83 v64 dst_addr;
81 u64 __bitwise next_ln_addr; 84 v64 next_ln_addr;
82 u32 __bitwise count; 85 v32 count;
83 u32 __bitwise reserve; 86 v32 reserve;
84} __attribute__((aligned(32))); 87} __attribute__((aligned(32)));
85 88
86struct fsl_desc_sw { 89struct fsl_desc_sw {
@@ -92,13 +95,13 @@ struct fsl_desc_sw {
92} __attribute__((aligned(32))); 95} __attribute__((aligned(32)));
93 96
94struct fsl_dma_chan_regs { 97struct fsl_dma_chan_regs {
95 u32 __bitwise mr; /* 0x00 - Mode Register */ 98 u32 mr; /* 0x00 - Mode Register */
96 u32 __bitwise sr; /* 0x04 - Status Register */ 99 u32 sr; /* 0x04 - Status Register */
97 u64 __bitwise cdar; /* 0x08 - Current descriptor address register */ 100 u64 cdar; /* 0x08 - Current descriptor address register */
98 u64 __bitwise sar; /* 0x10 - Source Address Register */ 101 u64 sar; /* 0x10 - Source Address Register */
99 u64 __bitwise dar; /* 0x18 - Destination Address Register */ 102 u64 dar; /* 0x18 - Destination Address Register */
100 u32 __bitwise bcr; /* 0x20 - Byte Count Register */ 103 u32 bcr; /* 0x20 - Byte Count Register */
101 u64 __bitwise ndar; /* 0x24 - Next Descriptor Address Register */ 104 u64 ndar; /* 0x24 - Next Descriptor Address Register */
102}; 105};
103 106
104struct fsl_dma_chan; 107struct fsl_dma_chan;
@@ -151,25 +154,27 @@ struct fsl_dma_chan {
151#ifndef __powerpc64__ 154#ifndef __powerpc64__
152static u64 in_be64(const u64 __iomem *addr) 155static u64 in_be64(const u64 __iomem *addr)
153{ 156{
154 return ((u64)in_be32((u32 *)addr) << 32) | (in_be32((u32 *)addr + 1)); 157 return ((u64)in_be32((u32 __iomem *)addr) << 32) |
158 (in_be32((u32 __iomem *)addr + 1));
155} 159}
156 160
157static void out_be64(u64 __iomem *addr, u64 val) 161static void out_be64(u64 __iomem *addr, u64 val)
158{ 162{
159 out_be32((u32 *)addr, val >> 32); 163 out_be32((u32 __iomem *)addr, val >> 32);
160 out_be32((u32 *)addr + 1, (u32)val); 164 out_be32((u32 __iomem *)addr + 1, (u32)val);
161} 165}
162 166
163/* There is no asm instructions for 64 bits reverse loads and stores */ 167/* There is no asm instructions for 64 bits reverse loads and stores */
164static u64 in_le64(const u64 __iomem *addr) 168static u64 in_le64(const u64 __iomem *addr)
165{ 169{
166 return ((u64)in_le32((u32 *)addr + 1) << 32) | (in_le32((u32 *)addr)); 170 return ((u64)in_le32((u32 __iomem *)addr + 1) << 32) |
171 (in_le32((u32 __iomem *)addr));
167} 172}
168 173
169static void out_le64(u64 __iomem *addr, u64 val) 174static void out_le64(u64 __iomem *addr, u64 val)
170{ 175{
171 out_le32((u32 *)addr + 1, val >> 32); 176 out_le32((u32 __iomem *)addr + 1, val >> 32);
172 out_le32((u32 *)addr, (u32)val); 177 out_le32((u32 __iomem *)addr, (u32)val);
173} 178}
174#endif 179#endif
175 180
@@ -182,9 +187,11 @@ static void out_le64(u64 __iomem *addr, u64 val)
182 187
183#define DMA_TO_CPU(fsl_chan, d, width) \ 188#define DMA_TO_CPU(fsl_chan, d, width) \
184 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \ 189 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \
185 be##width##_to_cpu(d) : le##width##_to_cpu(d)) 190 be##width##_to_cpu((__force __be##width)(v##width)d) : \
191 le##width##_to_cpu((__force __le##width)(v##width)d))
186#define CPU_TO_DMA(fsl_chan, c, width) \ 192#define CPU_TO_DMA(fsl_chan, c, width) \
187 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \ 193 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \
188 cpu_to_be##width(c) : cpu_to_le##width(c)) 194 (__force v##width)cpu_to_be##width(c) : \
195 (__force v##width)cpu_to_le##width(c))
189 196
190#endif /* __DMA_FSLDMA_H */ 197#endif /* __DMA_FSLDMA_H */
diff --git a/drivers/dma/ioat_dca.c b/drivers/dma/ioat_dca.c
index 0fa8a98051a8..9e922760b7ff 100644
--- a/drivers/dma/ioat_dca.c
+++ b/drivers/dma/ioat_dca.c
@@ -98,7 +98,7 @@ struct ioat_dca_slot {
98 98
99struct ioat_dca_priv { 99struct ioat_dca_priv {
100 void __iomem *iobase; 100 void __iomem *iobase;
101 void *dca_base; 101 void __iomem *dca_base;
102 int max_requesters; 102 int max_requesters;
103 int requester_count; 103 int requester_count;
104 u8 tag_map[IOAT_TAG_MAP_LEN]; 104 u8 tag_map[IOAT_TAG_MAP_LEN];
@@ -338,7 +338,7 @@ static struct dca_ops ioat2_dca_ops = {
338 .get_tag = ioat2_dca_get_tag, 338 .get_tag = ioat2_dca_get_tag,
339}; 339};
340 340
341static int ioat2_dca_count_dca_slots(void *iobase, u16 dca_offset) 341static int ioat2_dca_count_dca_slots(void __iomem *iobase, u16 dca_offset)
342{ 342{
343 int slots = 0; 343 int slots = 0;
344 u32 req; 344 u32 req;
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 996d61f0d460..ca6d51efd8bb 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -401,7 +401,8 @@ static void ar_context_tasklet(unsigned long data)
401 401
402 if (d->res_count == 0) { 402 if (d->res_count == 0) {
403 size_t size, rest, offset; 403 size_t size, rest, offset;
404 dma_addr_t buffer_bus; 404 dma_addr_t start_bus;
405 void *start;
405 406
406 /* 407 /*
407 * This descriptor is finished and we may have a 408 * This descriptor is finished and we may have a
@@ -410,9 +411,9 @@ static void ar_context_tasklet(unsigned long data)
410 */ 411 */
411 412
412 offset = offsetof(struct ar_buffer, data); 413 offset = offsetof(struct ar_buffer, data);
413 buffer_bus = le32_to_cpu(ab->descriptor.data_address) - offset; 414 start = buffer = ab;
415 start_bus = le32_to_cpu(ab->descriptor.data_address) - offset;
414 416
415 buffer = ab;
416 ab = ab->next; 417 ab = ab->next;
417 d = &ab->descriptor; 418 d = &ab->descriptor;
418 size = buffer + PAGE_SIZE - ctx->pointer; 419 size = buffer + PAGE_SIZE - ctx->pointer;
@@ -427,7 +428,7 @@ static void ar_context_tasklet(unsigned long data)
427 buffer = handle_ar_packet(ctx, buffer); 428 buffer = handle_ar_packet(ctx, buffer);
428 429
429 dma_free_coherent(ohci->card.device, PAGE_SIZE, 430 dma_free_coherent(ohci->card.device, PAGE_SIZE,
430 buffer, buffer_bus); 431 start, start_bus);
431 ar_context_add_page(ctx); 432 ar_context_add_page(ctx);
432 } else { 433 } else {
433 buffer = ctx->pointer; 434 buffer = ctx->pointer;
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 4072449ad1cd..c5e3ed7e903b 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -266,7 +266,7 @@ static void __init dmi_save_ipmi_device(const struct dmi_header *dm)
266 dev->name = "IPMI controller"; 266 dev->name = "IPMI controller";
267 dev->device_data = data; 267 dev->device_data = data;
268 268
269 list_add(&dev->list, &dmi_devices); 269 list_add_tail(&dev->list, &dmi_devices);
270} 270}
271 271
272static void __init dmi_save_extended_devices(const struct dmi_header *dm) 272static void __init dmi_save_extended_devices(const struct dmi_header *dm)
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 5c85670e2d16..f942ecdd47c8 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1367,7 +1367,8 @@ w83781d_isa_probe(struct platform_device *pdev)
1367 1367
1368 /* Reserve the ISA region */ 1368 /* Reserve the ISA region */
1369 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1369 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1370 if (!request_region(res->start, W83781D_EXTENT, "w83781d")) { 1370 if (!request_region(res->start + W83781D_ADDR_REG_OFFSET, 2,
1371 "w83781d")) {
1371 err = -EBUSY; 1372 err = -EBUSY;
1372 goto exit; 1373 goto exit;
1373 } 1374 }
@@ -1415,7 +1416,7 @@ w83781d_isa_probe(struct platform_device *pdev)
1415 device_remove_file(&pdev->dev, &dev_attr_name); 1416 device_remove_file(&pdev->dev, &dev_attr_name);
1416 kfree(data); 1417 kfree(data);
1417 exit_release_region: 1418 exit_release_region:
1418 release_region(res->start, W83781D_EXTENT); 1419 release_region(res->start + W83781D_ADDR_REG_OFFSET, 2);
1419 exit: 1420 exit:
1420 return err; 1421 return err;
1421} 1422}
@@ -1429,7 +1430,7 @@ w83781d_isa_remove(struct platform_device *pdev)
1429 sysfs_remove_group(&pdev->dev.kobj, &w83781d_group); 1430 sysfs_remove_group(&pdev->dev.kobj, &w83781d_group);
1430 sysfs_remove_group(&pdev->dev.kobj, &w83781d_group_opt); 1431 sysfs_remove_group(&pdev->dev.kobj, &w83781d_group_opt);
1431 device_remove_file(&pdev->dev, &dev_attr_name); 1432 device_remove_file(&pdev->dev, &dev_attr_name);
1432 release_region(data->client.addr, W83781D_EXTENT); 1433 release_region(data->client.addr + W83781D_ADDR_REG_OFFSET, 2);
1433 kfree(data); 1434 kfree(data);
1434 1435
1435 return 0; 1436 return 0;
@@ -1797,8 +1798,17 @@ w83781d_isa_found(unsigned short address)
1797{ 1798{
1798 int val, save, found = 0; 1799 int val, save, found = 0;
1799 1800
1800 if (!request_region(address, W83781D_EXTENT, "w83781d")) 1801 /* We have to request the region in two parts because some
1802 boards declare base+4 to base+7 as a PNP device */
1803 if (!request_region(address, 4, "w83781d")) {
1804 pr_debug("w83781d: Failed to request low part of region\n");
1801 return 0; 1805 return 0;
1806 }
1807 if (!request_region(address + 4, 4, "w83781d")) {
1808 pr_debug("w83781d: Failed to request high part of region\n");
1809 release_region(address, 4);
1810 return 0;
1811 }
1802 1812
1803#define REALLY_SLOW_IO 1813#define REALLY_SLOW_IO
1804 /* We need the timeouts for at least some W83781D-like 1814 /* We need the timeouts for at least some W83781D-like
@@ -1871,7 +1881,8 @@ w83781d_isa_found(unsigned short address)
1871 val == 0x30 ? "W83782D" : "W83781D", (int)address); 1881 val == 0x30 ? "W83782D" : "W83781D", (int)address);
1872 1882
1873 release: 1883 release:
1874 release_region(address, W83781D_EXTENT); 1884 release_region(address + 4, 4);
1885 release_region(address, 4);
1875 return found; 1886 return found;
1876} 1887}
1877 1888
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index cce5a614758d..fde26345a379 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -382,9 +382,8 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
382 break; 382 break;
383 383
384 case DAVINCI_I2C_IVR_ARDY: 384 case DAVINCI_I2C_IVR_ARDY:
385 w = davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG); 385 davinci_i2c_write_reg(dev,
386 MOD_REG_BIT(w, DAVINCI_I2C_STR_ARDY, 1); 386 DAVINCI_I2C_STR_REG, DAVINCI_I2C_STR_ARDY);
387 davinci_i2c_write_reg(dev, DAVINCI_I2C_STR_REG, w);
388 complete(&dev->cmd_complete); 387 complete(&dev->cmd_complete);
389 break; 388 break;
390 389
@@ -397,12 +396,9 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
397 if (dev->buf_len) 396 if (dev->buf_len)
398 continue; 397 continue;
399 398
400 w = davinci_i2c_read_reg(dev,
401 DAVINCI_I2C_STR_REG);
402 MOD_REG_BIT(w, DAVINCI_I2C_IMR_RRDY, 0);
403 davinci_i2c_write_reg(dev, 399 davinci_i2c_write_reg(dev,
404 DAVINCI_I2C_STR_REG, 400 DAVINCI_I2C_STR_REG,
405 w); 401 DAVINCI_I2C_IMR_RRDY);
406 } else 402 } else
407 dev_err(dev->dev, "RDR IRQ while no " 403 dev_err(dev->dev, "RDR IRQ while no "
408 "data requested\n"); 404 "data requested\n");
@@ -428,9 +424,8 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
428 break; 424 break;
429 425
430 case DAVINCI_I2C_IVR_SCD: 426 case DAVINCI_I2C_IVR_SCD:
431 w = davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG); 427 davinci_i2c_write_reg(dev,
432 MOD_REG_BIT(w, DAVINCI_I2C_STR_SCD, 1); 428 DAVINCI_I2C_STR_REG, DAVINCI_I2C_STR_SCD);
433 davinci_i2c_write_reg(dev, DAVINCI_I2C_STR_REG, w);
434 complete(&dev->cmd_complete); 429 complete(&dev->cmd_complete);
435 break; 430 break;
436 431
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 7c7eb0cfeceb..22bb247d0e60 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(iic_force_poll, "Force polling mode");
55 55
56static int iic_force_fast; 56static int iic_force_fast;
57module_param(iic_force_fast, bool, 0); 57module_param(iic_force_fast, bool, 0);
58MODULE_PARM_DESC(iic_fast_poll, "Force fast mode (400 kHz)"); 58MODULE_PARM_DESC(iic_force_fast, "Force fast mode (400 kHz)");
59 59
60#define DBG_LEVEL 0 60#define DBG_LEVEL 0
61 61
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index cb9abe7565a7..b1c050ff311d 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -131,11 +131,15 @@ static const struct i2c_algorithm usb_algorithm = {
131 131
132/* ----- begin of usb layer ---------------------------------------------- */ 132/* ----- begin of usb layer ---------------------------------------------- */
133 133
134/* The usb i2c interface uses a vid/pid pair donated by */ 134/*
135/* Future Technology Devices International Ltd. */ 135 * Initially the usb i2c interface uses a vid/pid pair donated by
136 * Future Technology Devices International Ltd., later a pair was
137 * bought from EZPrototypes
138 */
136static struct usb_device_id i2c_tiny_usb_table [] = { 139static struct usb_device_id i2c_tiny_usb_table [] = {
137 { USB_DEVICE(0x0403, 0xc631) }, 140 { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */
138 { } /* Terminating entry */ 141 { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */
142 { } /* Terminating entry */
139}; 143};
140 144
141MODULE_DEVICE_TABLE(usb, i2c_tiny_usb_table); 145MODULE_DEVICE_TABLE(usb, i2c_tiny_usb_table);
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index b21593f93586..2da2edfa68ec 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -93,6 +93,7 @@ config ISP1301_OMAP
93 93
94config TPS65010 94config TPS65010
95 tristate "TPS6501x Power Management chips" 95 tristate "TPS6501x Power Management chips"
96 depends on HAVE_GPIO_LIB
96 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK 97 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK
97 help 98 help
98 If you say yes here you get support for the TPS6501x series of 99 If you say yes here you get support for the TPS6501x series of
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 4154a9108859..b67f69c2e7f3 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -30,9 +30,13 @@
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/platform_device.h>
33 34
34#include <linux/i2c/tps65010.h> 35#include <linux/i2c/tps65010.h>
35 36
37#include <asm/gpio.h>
38
39
36/*-------------------------------------------------------------------------*/ 40/*-------------------------------------------------------------------------*/
37 41
38#define DRIVER_VERSION "2 May 2005" 42#define DRIVER_VERSION "2 May 2005"
@@ -84,7 +88,9 @@ struct tps65010 {
84 u8 chgstatus, regstatus, chgconf; 88 u8 chgstatus, regstatus, chgconf;
85 u8 nmask1, nmask2; 89 u8 nmask1, nmask2;
86 90
87 /* not currently tracking GPIO state */ 91 u8 outmask;
92 struct gpio_chip chip;
93 struct platform_device *leds;
88}; 94};
89 95
90#define POWER_POLL_DELAY msecs_to_jiffies(5000) 96#define POWER_POLL_DELAY msecs_to_jiffies(5000)
@@ -449,12 +455,72 @@ static irqreturn_t tps65010_irq(int irq, void *_tps)
449 455
450/*-------------------------------------------------------------------------*/ 456/*-------------------------------------------------------------------------*/
451 457
458/* offsets 0..3 == GPIO1..GPIO4
459 * offsets 4..5 == LED1/nPG, LED2 (we set one of the non-BLINK modes)
460 */
461static void
462tps65010_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
463{
464 if (offset < 4)
465 tps65010_set_gpio_out_value(offset + 1, value);
466 else
467 tps65010_set_led(offset - 3, value ? ON : OFF);
468}
469
470static int
471tps65010_output(struct gpio_chip *chip, unsigned offset, int value)
472{
473 /* GPIOs may be input-only */
474 if (offset < 4) {
475 struct tps65010 *tps;
476
477 tps = container_of(chip, struct tps65010, chip);
478 if (!(tps->outmask & (1 << offset)))
479 return -EINVAL;
480 tps65010_set_gpio_out_value(offset + 1, value);
481 } else
482 tps65010_set_led(offset - 3, value ? ON : OFF);
483
484 return 0;
485}
486
487static int tps65010_gpio_get(struct gpio_chip *chip, unsigned offset)
488{
489 int value;
490 struct tps65010 *tps;
491
492 tps = container_of(chip, struct tps65010, chip);
493
494 if (offset < 4) {
495 value = i2c_smbus_read_byte_data(tps->client, TPS_DEFGPIO);
496 if (value < 0)
497 return 0;
498 if (value & (1 << (offset + 4))) /* output */
499 return !(value & (1 << offset));
500 else /* input */
501 return (value & (1 << offset));
502 }
503
504 /* REVISIT we *could* report LED1/nPG and LED2 state ... */
505 return 0;
506}
507
508
509/*-------------------------------------------------------------------------*/
510
452static struct tps65010 *the_tps; 511static struct tps65010 *the_tps;
453 512
454static int __exit tps65010_remove(struct i2c_client *client) 513static int __exit tps65010_remove(struct i2c_client *client)
455{ 514{
456 struct tps65010 *tps = i2c_get_clientdata(client); 515 struct tps65010 *tps = i2c_get_clientdata(client);
516 struct tps65010_board *board = client->dev.platform_data;
457 517
518 if (board && board->teardown) {
519 int status = board->teardown(client, board->context);
520 if (status < 0)
521 dev_dbg(&client->dev, "board %s %s err %d\n",
522 "teardown", client->name, status);
523 }
458 if (client->irq > 0) 524 if (client->irq > 0)
459 free_irq(client->irq, tps); 525 free_irq(client->irq, tps);
460 cancel_delayed_work(&tps->work); 526 cancel_delayed_work(&tps->work);
@@ -469,6 +535,7 @@ static int tps65010_probe(struct i2c_client *client)
469{ 535{
470 struct tps65010 *tps; 536 struct tps65010 *tps;
471 int status; 537 int status;
538 struct tps65010_board *board = client->dev.platform_data;
472 539
473 if (the_tps) { 540 if (the_tps) {
474 dev_dbg(&client->dev, "only one tps6501x chip allowed\n"); 541 dev_dbg(&client->dev, "only one tps6501x chip allowed\n");
@@ -577,6 +644,38 @@ static int tps65010_probe(struct i2c_client *client)
577 644
578 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, 645 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,
579 tps, DEBUG_FOPS); 646 tps, DEBUG_FOPS);
647
648 /* optionally register GPIOs */
649 if (board && board->base > 0) {
650 tps->outmask = board->outmask;
651
652 tps->chip.label = client->name;
653
654 tps->chip.set = tps65010_gpio_set;
655 tps->chip.direction_output = tps65010_output;
656
657 /* NOTE: only partial support for inputs; nyet IRQs */
658 tps->chip.get = tps65010_gpio_get;
659
660 tps->chip.base = board->base;
661 tps->chip.ngpio = 6;
662 tps->chip.can_sleep = 1;
663
664 status = gpiochip_add(&tps->chip);
665 if (status < 0)
666 dev_err(&client->dev, "can't add gpiochip, err %d\n",
667 status);
668 else if (board->setup) {
669 status = board->setup(client, board->context);
670 if (status < 0) {
671 dev_dbg(&client->dev,
672 "board %s %s err %d\n",
673 "setup", client->name, status);
674 status = 0;
675 }
676 }
677 }
678
580 return 0; 679 return 0;
581fail1: 680fail1:
582 kfree(tps); 681 kfree(tps);
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c
index 43a70e91363e..be9ff7334c52 100644
--- a/drivers/ide/arm/ide_arm.c
+++ b/drivers/ide/arm/ide_arm.c
@@ -46,3 +46,5 @@ static int __init ide_arm_init(void)
46} 46}
47 47
48module_init(ide_arm_init); 48module_init(ide_arm_init);
49
50MODULE_LICENSE("GPL");
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index e79bf8f9b7db..c8ffbaf29a88 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -1067,3 +1067,5 @@ static void cris_dma_start(ide_drive_t *drive)
1067} 1067}
1068 1068
1069module_init(init_e100_ide); 1069module_init(init_e100_ide);
1070
1071MODULE_LICENSE("GPL");
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c
index 520aec075700..4108ec4ffa7f 100644
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -110,6 +110,7 @@ static int __init h8300_ide_init(void)
110 ide_init_port_data(hwif, index); 110 ide_init_port_data(hwif, index);
111 ide_init_port_hw(hwif, &hw); 111 ide_init_port_hw(hwif, &hw);
112 hwif_setup(hwif); 112 hwif_setup(hwif);
113 hwif->host_flags = IDE_HFLAG_NO_IO_32BIT;
113 printk(KERN_INFO "ide%d: H8/300 generic IDE interface\n", index); 114 printk(KERN_INFO "ide%d: H8/300 generic IDE interface\n", index);
114 115
115 idx[0] = index; 116 idx[0] = index;
@@ -125,3 +126,5 @@ out_busy:
125} 126}
126 127
127module_init(h8300_ide_init); 128module_init(h8300_ide_init);
129
130MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index c419266234a7..e77cee0e5d65 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -595,6 +595,7 @@ u8 eighty_ninty_three (ide_drive_t *drive)
595 595
596 /* 596 /*
597 * FIXME: 597 * FIXME:
598 * - change master/slave IDENTIFY order
598 * - force bit13 (80c cable present) check also for !ivb devices 599 * - force bit13 (80c cable present) check also for !ivb devices
599 * (unless the slave device is pre-ATA3) 600 * (unless the slave device is pre-ATA3)
600 */ 601 */
@@ -657,7 +658,7 @@ int ide_driveid_update(ide_drive_t *drive)
657 local_irq_restore(flags); 658 local_irq_restore(flags);
658 return 0; 659 return 0;
659 } 660 }
660 ata_input_data(drive, id, SECTOR_WORDS); 661 hwif->ata_input_data(drive, id, SECTOR_WORDS);
661 (void)ide_read_status(drive); /* clear drive IRQ */ 662 (void)ide_read_status(drive); /* clear drive IRQ */
662 local_irq_enable(); 663 local_irq_enable();
663 local_irq_restore(flags); 664 local_irq_restore(flags);
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index b163b2e52212..c14bb5380c25 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -86,3 +86,5 @@ static void __exit pnpide_exit(void)
86 86
87module_init(pnpide_init); 87module_init(pnpide_init);
88module_exit(pnpide_exit); 88module_exit(pnpide_exit);
89
90MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 194ecb0049eb..47a114927c31 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -774,9 +774,10 @@ static int ide_probe_port(ide_hwif_t *hwif)
774 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); 774 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name);
775 775
776 /* 776 /*
777 * Need to probe slave device first to make it release PDIAG-. 777 * Second drive should only exist if first drive was found,
778 * but a lot of cdrom drives are configured as single slaves.
778 */ 779 */
779 for (unit = MAX_DRIVES - 1; unit >= 0; unit--) { 780 for (unit = 0; unit < MAX_DRIVES; ++unit) {
780 ide_drive_t *drive = &hwif->drives[unit]; 781 ide_drive_t *drive = &hwif->drives[unit];
781 drive->dn = (hwif->channel ? 2 : 0) + unit; 782 drive->dn = (hwif->channel ? 2 : 0) + unit;
782 (void) probe_for_drive(drive); 783 (void) probe_for_drive(drive);
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c
index 50ffa871d5e9..fdd3791e465f 100644
--- a/drivers/ide/legacy/buddha.c
+++ b/drivers/ide/legacy/buddha.c
@@ -241,3 +241,5 @@ fail_base2:
241} 241}
242 242
243module_init(buddha_init); 243module_init(buddha_init);
244
245MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c
index 8949ce71bddc..e950afa5939c 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/legacy/falconide.c
@@ -93,3 +93,5 @@ static int __init falconide_init(void)
93} 93}
94 94
95module_init(falconide_init); 95module_init(falconide_init);
96
97MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c
index b7d81090d5da..e3b4638cc883 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/legacy/gayle.c
@@ -195,3 +195,5 @@ found:
195} 195}
196 196
197module_init(gayle_init); 197module_init(gayle_init);
198
199MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
index 9a79098d9eb4..eaf5dbe58bc2 100644
--- a/drivers/ide/legacy/macide.c
+++ b/drivers/ide/legacy/macide.c
@@ -137,3 +137,5 @@ static int __init macide_init(void)
137} 137}
138 138
139module_init(macide_init); 139module_init(macide_init);
140
141MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c
index 1381b91bc316..2da28759686e 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/legacy/q40ide.c
@@ -153,3 +153,5 @@ static int __init q40ide_init(void)
153} 153}
154 154
155module_init(q40ide_init); 155module_init(q40ide_init);
156
157MODULE_LICENSE("GPL");
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index ec667982809c..29fbc5ead03b 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -881,3 +881,5 @@ module_param_named(probe_vlb, cmd640_vlb, bool, 0);
881MODULE_PARM_DESC(probe_vlb, "probe for VLB version of CMD640 chipset"); 881MODULE_PARM_DESC(probe_vlb, "probe for VLB version of CMD640 chipset");
882 882
883module_init(cmd640x_init); 883module_init(cmd640x_init);
884
885MODULE_LICENSE("GPL");
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index cc4be9621bc0..8d624afe8529 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -492,7 +492,7 @@ static void proc_reports_siimage (struct pci_dev *dev, u8 clocking, const char *
492 492
493static unsigned int setup_mmio_siimage (struct pci_dev *dev, const char *name) 493static unsigned int setup_mmio_siimage (struct pci_dev *dev, const char *name)
494{ 494{
495 unsigned long bar5 = pci_resource_start(dev, 5); 495 resource_size_t bar5 = pci_resource_start(dev, 5);
496 unsigned long barsize = pci_resource_len(dev, 5); 496 unsigned long barsize = pci_resource_len(dev, 5);
497 u8 tmpbyte = 0; 497 u8 tmpbyte = 0;
498 void __iomem *ioaddr; 498 void __iomem *ioaddr;
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c
index 38fbfb8d5445..ebaba01c7551 100644
--- a/drivers/ide/ppc/mpc8xx.c
+++ b/drivers/ide/ppc/mpc8xx.c
@@ -853,3 +853,5 @@ static int __init mpc8xx_ide_probe(void)
853} 853}
854 854
855module_init(mpc8xx_ide_probe); 855module_init(mpc8xx_ide_probe);
856
857MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 78c9eeb85634..d9ca52e6cdab 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1771,3 +1771,5 @@ static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1771#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 1771#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
1772 1772
1773module_init(pmac_ide_probe); 1773module_init(pmac_ide_probe);
1774
1775MODULE_LICENSE("GPL");
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index a58ad8a470f9..781ea5950373 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -154,7 +154,7 @@ static void addr_send_arp(struct sockaddr_in *dst_in)
154{ 154{
155 struct rtable *rt; 155 struct rtable *rt;
156 struct flowi fl; 156 struct flowi fl;
157 u32 dst_ip = dst_in->sin_addr.s_addr; 157 __be32 dst_ip = dst_in->sin_addr.s_addr;
158 158
159 memset(&fl, 0, sizeof fl); 159 memset(&fl, 0, sizeof fl);
160 fl.nl_u.ip4_u.daddr = dst_ip; 160 fl.nl_u.ip4_u.daddr = dst_ip;
@@ -169,8 +169,8 @@ static int addr_resolve_remote(struct sockaddr_in *src_in,
169 struct sockaddr_in *dst_in, 169 struct sockaddr_in *dst_in,
170 struct rdma_dev_addr *addr) 170 struct rdma_dev_addr *addr)
171{ 171{
172 u32 src_ip = src_in->sin_addr.s_addr; 172 __be32 src_ip = src_in->sin_addr.s_addr;
173 u32 dst_ip = dst_in->sin_addr.s_addr; 173 __be32 dst_ip = dst_in->sin_addr.s_addr;
174 struct flowi fl; 174 struct flowi fl;
175 struct rtable *rt; 175 struct rtable *rt;
176 struct neighbour *neigh; 176 struct neighbour *neigh;
@@ -257,7 +257,7 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
257 struct rdma_dev_addr *addr) 257 struct rdma_dev_addr *addr)
258{ 258{
259 struct net_device *dev; 259 struct net_device *dev;
260 u32 src_ip = src_in->sin_addr.s_addr; 260 __be32 src_ip = src_in->sin_addr.s_addr;
261 __be32 dst_ip = dst_in->sin_addr.s_addr; 261 __be32 dst_ip = dst_in->sin_addr.s_addr;
262 int ret; 262 int ret;
263 263
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 4df405157086..faa7ce318a6d 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -393,7 +393,7 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
393 spin_unlock_irqrestore(&cm.lock, flags); 393 spin_unlock_irqrestore(&cm.lock, flags);
394 } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) ); 394 } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
395 395
396 cm_id_priv->id.local_id = (__force __be32) (id ^ cm.random_id_operand); 396 cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;
397 return ret; 397 return ret;
398} 398}
399 399
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 34507daaf9b6..d81c156a22b4 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -168,15 +168,15 @@ struct cma_work {
168union cma_ip_addr { 168union cma_ip_addr {
169 struct in6_addr ip6; 169 struct in6_addr ip6;
170 struct { 170 struct {
171 __u32 pad[3]; 171 __be32 pad[3];
172 __u32 addr; 172 __be32 addr;
173 } ip4; 173 } ip4;
174}; 174};
175 175
176struct cma_hdr { 176struct cma_hdr {
177 u8 cma_version; 177 u8 cma_version;
178 u8 ip_version; /* IP version: 7:4 */ 178 u8 ip_version; /* IP version: 7:4 */
179 __u16 port; 179 __be16 port;
180 union cma_ip_addr src_addr; 180 union cma_ip_addr src_addr;
181 union cma_ip_addr dst_addr; 181 union cma_ip_addr dst_addr;
182}; 182};
@@ -186,8 +186,8 @@ struct sdp_hh {
186 u8 sdp_version; /* Major version: 7:4 */ 186 u8 sdp_version; /* Major version: 7:4 */
187 u8 ip_version; /* IP version: 7:4 */ 187 u8 ip_version; /* IP version: 7:4 */
188 u8 sdp_specific1[10]; 188 u8 sdp_specific1[10];
189 __u16 port; 189 __be16 port;
190 __u16 sdp_specific2; 190 __be16 sdp_specific2;
191 union cma_ip_addr src_addr; 191 union cma_ip_addr src_addr;
192 union cma_ip_addr dst_addr; 192 union cma_ip_addr dst_addr;
193}; 193};
@@ -663,7 +663,7 @@ static inline int cma_any_port(struct sockaddr *addr)
663} 663}
664 664
665static int cma_get_net_info(void *hdr, enum rdma_port_space ps, 665static int cma_get_net_info(void *hdr, enum rdma_port_space ps,
666 u8 *ip_ver, __u16 *port, 666 u8 *ip_ver, __be16 *port,
667 union cma_ip_addr **src, union cma_ip_addr **dst) 667 union cma_ip_addr **src, union cma_ip_addr **dst)
668{ 668{
669 switch (ps) { 669 switch (ps) {
@@ -695,7 +695,7 @@ static int cma_get_net_info(void *hdr, enum rdma_port_space ps,
695 695
696static void cma_save_net_info(struct rdma_addr *addr, 696static void cma_save_net_info(struct rdma_addr *addr,
697 struct rdma_addr *listen_addr, 697 struct rdma_addr *listen_addr,
698 u8 ip_ver, __u16 port, 698 u8 ip_ver, __be16 port,
699 union cma_ip_addr *src, union cma_ip_addr *dst) 699 union cma_ip_addr *src, union cma_ip_addr *dst)
700{ 700{
701 struct sockaddr_in *listen4, *ip4; 701 struct sockaddr_in *listen4, *ip4;
@@ -996,7 +996,7 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
996 struct rdma_cm_id *id; 996 struct rdma_cm_id *id;
997 struct rdma_route *rt; 997 struct rdma_route *rt;
998 union cma_ip_addr *src, *dst; 998 union cma_ip_addr *src, *dst;
999 __u16 port; 999 __be16 port;
1000 u8 ip_ver; 1000 u8 ip_ver;
1001 1001
1002 if (cma_get_net_info(ib_event->private_data, listen_id->ps, 1002 if (cma_get_net_info(ib_event->private_data, listen_id->ps,
@@ -1043,7 +1043,7 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
1043 struct rdma_id_private *id_priv; 1043 struct rdma_id_private *id_priv;
1044 struct rdma_cm_id *id; 1044 struct rdma_cm_id *id;
1045 union cma_ip_addr *src, *dst; 1045 union cma_ip_addr *src, *dst;
1046 __u16 port; 1046 __be16 port;
1047 u8 ip_ver; 1047 u8 ip_ver;
1048 int ret; 1048 int ret;
1049 1049
@@ -1165,7 +1165,7 @@ static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
1165{ 1165{
1166 struct cma_hdr *cma_data, *cma_mask; 1166 struct cma_hdr *cma_data, *cma_mask;
1167 struct sdp_hh *sdp_data, *sdp_mask; 1167 struct sdp_hh *sdp_data, *sdp_mask;
1168 __u32 ip4_addr; 1168 __be32 ip4_addr;
1169 struct in6_addr ip6_addr; 1169 struct in6_addr ip6_addr;
1170 1170
1171 memset(compare, 0, sizeof *compare); 1171 memset(compare, 0, sizeof *compare);
@@ -1181,12 +1181,12 @@ static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
1181 sdp_set_ip_ver(sdp_data, 4); 1181 sdp_set_ip_ver(sdp_data, 4);
1182 sdp_set_ip_ver(sdp_mask, 0xF); 1182 sdp_set_ip_ver(sdp_mask, 0xF);
1183 sdp_data->dst_addr.ip4.addr = ip4_addr; 1183 sdp_data->dst_addr.ip4.addr = ip4_addr;
1184 sdp_mask->dst_addr.ip4.addr = ~0; 1184 sdp_mask->dst_addr.ip4.addr = htonl(~0);
1185 } else { 1185 } else {
1186 cma_set_ip_ver(cma_data, 4); 1186 cma_set_ip_ver(cma_data, 4);
1187 cma_set_ip_ver(cma_mask, 0xF); 1187 cma_set_ip_ver(cma_mask, 0xF);
1188 cma_data->dst_addr.ip4.addr = ip4_addr; 1188 cma_data->dst_addr.ip4.addr = ip4_addr;
1189 cma_mask->dst_addr.ip4.addr = ~0; 1189 cma_mask->dst_addr.ip4.addr = htonl(~0);
1190 } 1190 }
1191 break; 1191 break;
1192 case AF_INET6: 1192 case AF_INET6:
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index 320f2b6ddee6..99f2f2a46bf7 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -1745,7 +1745,7 @@ int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1745 1745
1746 /* bind QP to EP and move to RTS */ 1746 /* bind QP to EP and move to RTS */
1747 attrs.mpa_attr = ep->mpa_attr; 1747 attrs.mpa_attr = ep->mpa_attr;
1748 attrs.max_ird = ep->ord; 1748 attrs.max_ird = ep->ird;
1749 attrs.max_ord = ep->ord; 1749 attrs.max_ord = ep->ord;
1750 attrs.llp_stream_handle = ep; 1750 attrs.llp_stream_handle = ep;
1751 attrs.next_state = IWCH_QP_STATE_RTS; 1751 attrs.next_state = IWCH_QP_STATE_RTS;
diff --git a/drivers/input/apm-power.c b/drivers/input/apm-power.c
index c36d110b349a..7d61a9660806 100644
--- a/drivers/input/apm-power.c
+++ b/drivers/input/apm-power.c
@@ -63,8 +63,6 @@ static int apmpower_connect(struct input_handler *handler,
63 handle->handler = handler; 63 handle->handler = handler;
64 handle->name = "apm-power"; 64 handle->name = "apm-power";
65 65
66 handler->private = handle;
67
68 error = input_register_handle(handle); 66 error = input_register_handle(handle);
69 if (error) { 67 if (error) {
70 printk(KERN_ERR 68 printk(KERN_ERR
@@ -87,11 +85,10 @@ static int apmpower_connect(struct input_handler *handler,
87 return 0; 85 return 0;
88} 86}
89 87
90static void apmpower_disconnect(struct input_handle *handler) 88static void apmpower_disconnect(struct input_handle *handle)
91{ 89{
92 struct input_handle *handle = handler->private;
93
94 input_close_device(handle); 90 input_close_device(handle);
91 input_unregister_handle(handle);
95 kfree(handle); 92 kfree(handle);
96} 93}
97 94
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 0727b0a12557..b32984bc516f 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -124,6 +124,7 @@ static void evdev_free(struct device *dev)
124{ 124{
125 struct evdev *evdev = container_of(dev, struct evdev, dev); 125 struct evdev *evdev = container_of(dev, struct evdev, dev);
126 126
127 input_put_device(evdev->handle.dev);
127 kfree(evdev); 128 kfree(evdev);
128} 129}
129 130
@@ -893,7 +894,7 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
893 evdev->exist = 1; 894 evdev->exist = 1;
894 evdev->minor = minor; 895 evdev->minor = minor;
895 896
896 evdev->handle.dev = dev; 897 evdev->handle.dev = input_get_device(dev);
897 evdev->handle.name = evdev->name; 898 evdev->handle.name = evdev->name;
898 evdev->handle.handler = handler; 899 evdev->handle.handler = handler;
899 evdev->handle.private = evdev; 900 evdev->handle.private = evdev;
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 22b2789ef58a..65d7077a75a1 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -171,6 +171,7 @@ static void joydev_free(struct device *dev)
171{ 171{
172 struct joydev *joydev = container_of(dev, struct joydev, dev); 172 struct joydev *joydev = container_of(dev, struct joydev, dev);
173 173
174 input_put_device(joydev->handle.dev);
174 kfree(joydev); 175 kfree(joydev);
175} 176}
176 177
@@ -750,7 +751,7 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
750 joydev->minor = minor; 751 joydev->minor = minor;
751 752
752 joydev->exist = 1; 753 joydev->exist = 1;
753 joydev->handle.dev = dev; 754 joydev->handle.dev = input_get_device(dev);
754 joydev->handle.name = joydev->name; 755 joydev->handle.name = joydev->name;
755 joydev->handle.handler = handler; 756 joydev->handle.handler = handler;
756 joydev->handle.private = joydev; 757 joydev->handle.private = joydev;
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 6224c2fb3b65..4e651c11c1da 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -50,9 +50,9 @@
50#define KPKDI 0x0048 50#define KPKDI 0x0048
51 51
52/* bit definitions */ 52/* bit definitions */
53#define KPC_MKRN(n) ((((n) & 0x7) - 1) << 26) /* matrix key row number */ 53#define KPC_MKRN(n) ((((n) - 1) & 0x7) << 26) /* matrix key row number */
54#define KPC_MKCN(n) ((((n) & 0x7) - 1) << 23) /* matrix key column number */ 54#define KPC_MKCN(n) ((((n) - 1) & 0x7) << 23) /* matrix key column number */
55#define KPC_DKN(n) ((((n) & 0x7) - 1) << 6) /* direct key number */ 55#define KPC_DKN(n) ((((n) - 1) & 0x7) << 6) /* direct key number */
56 56
57#define KPC_AS (0x1 << 30) /* Automatic Scan bit */ 57#define KPC_AS (0x1 << 30) /* Automatic Scan bit */
58#define KPC_ASACT (0x1 << 29) /* Automatic Scan on Activity */ 58#define KPC_ASACT (0x1 << 29) /* Automatic Scan on Activity */
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c
index d2ade7443b7d..798d84c44d03 100644
--- a/drivers/input/misc/ixp4xx-beeper.c
+++ b/drivers/input/misc/ixp4xx-beeper.c
@@ -25,6 +25,7 @@
25MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 25MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
26MODULE_DESCRIPTION("ixp4xx beeper driver"); 26MODULE_DESCRIPTION("ixp4xx beeper driver");
27MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
28MODULE_ALIAS("platform:ixp4xx-beeper");
28 29
29static DEFINE_SPINLOCK(beep_lock); 30static DEFINE_SPINLOCK(beep_lock);
30 31
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index b4423a471f02..8dd3942f3022 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -62,6 +62,10 @@
62#define GEYSER4_ISO_PRODUCT_ID 0x021B 62#define GEYSER4_ISO_PRODUCT_ID 0x021B
63#define GEYSER4_JIS_PRODUCT_ID 0x021C 63#define GEYSER4_JIS_PRODUCT_ID 0x021C
64 64
65#define GEYSER4_HF_ANSI_PRODUCT_ID 0x0229
66#define GEYSER4_HF_ISO_PRODUCT_ID 0x022A
67#define GEYSER4_HF_JIS_PRODUCT_ID 0x022B
68
65#define ATP_DEVICE(prod) \ 69#define ATP_DEVICE(prod) \
66 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ 70 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
67 USB_DEVICE_ID_MATCH_INT_CLASS | \ 71 USB_DEVICE_ID_MATCH_INT_CLASS | \
@@ -93,6 +97,10 @@ static struct usb_device_id atp_table [] = {
93 { ATP_DEVICE(GEYSER4_ISO_PRODUCT_ID) }, 97 { ATP_DEVICE(GEYSER4_ISO_PRODUCT_ID) },
94 { ATP_DEVICE(GEYSER4_JIS_PRODUCT_ID) }, 98 { ATP_DEVICE(GEYSER4_JIS_PRODUCT_ID) },
95 99
100 { ATP_DEVICE(GEYSER4_HF_ANSI_PRODUCT_ID) },
101 { ATP_DEVICE(GEYSER4_HF_ISO_PRODUCT_ID) },
102 { ATP_DEVICE(GEYSER4_HF_JIS_PRODUCT_ID) },
103
96 /* Terminating entry */ 104 /* Terminating entry */
97 { } 105 { }
98}; 106};
@@ -217,7 +225,10 @@ static inline int atp_is_geyser_3(struct atp *dev)
217 (productId == GEYSER3_JIS_PRODUCT_ID) || 225 (productId == GEYSER3_JIS_PRODUCT_ID) ||
218 (productId == GEYSER4_ANSI_PRODUCT_ID) || 226 (productId == GEYSER4_ANSI_PRODUCT_ID) ||
219 (productId == GEYSER4_ISO_PRODUCT_ID) || 227 (productId == GEYSER4_ISO_PRODUCT_ID) ||
220 (productId == GEYSER4_JIS_PRODUCT_ID); 228 (productId == GEYSER4_JIS_PRODUCT_ID) ||
229 (productId == GEYSER4_HF_ANSI_PRODUCT_ID) ||
230 (productId == GEYSER4_HF_ISO_PRODUCT_ID) ||
231 (productId == GEYSER4_HF_JIS_PRODUCT_ID);
221} 232}
222 233
223/* 234/*
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index bbbe5e81adc1..b989748598ae 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -414,6 +414,7 @@ static void mousedev_free(struct device *dev)
414{ 414{
415 struct mousedev *mousedev = container_of(dev, struct mousedev, dev); 415 struct mousedev *mousedev = container_of(dev, struct mousedev, dev);
416 416
417 input_put_device(mousedev->handle.dev);
417 kfree(mousedev); 418 kfree(mousedev);
418} 419}
419 420
@@ -865,7 +866,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
865 866
866 mousedev->minor = minor; 867 mousedev->minor = minor;
867 mousedev->exist = 1; 868 mousedev->exist = 1;
868 mousedev->handle.dev = dev; 869 mousedev->handle.dev = input_get_device(dev);
869 mousedev->handle.name = mousedev->name; 870 mousedev->handle.name = mousedev->name;
870 mousedev->handle.handler = handler; 871 mousedev->handle.handler = handler;
871 mousedev->handle.private = mousedev; 872 mousedev->handle.private = mousedev;
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 57a1c28bf122..39573b91c8de 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -28,13 +28,6 @@
28#include <linux/spi/ads7846.h> 28#include <linux/spi/ads7846.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#ifdef CONFIG_ARM
32#include <asm/mach-types.h>
33#ifdef CONFIG_ARCH_OMAP
34#include <asm/arch/gpio.h>
35#endif
36#endif
37
38 31
39/* 32/*
40 * This code has been heavily tested on a Nokia 770, and lightly 33 * This code has been heavily tested on a Nokia 770, and lightly
@@ -1174,31 +1167,6 @@ static struct spi_driver ads7846_driver = {
1174 1167
1175static int __init ads7846_init(void) 1168static int __init ads7846_init(void)
1176{ 1169{
1177 /* grr, board-specific init should stay out of drivers!! */
1178
1179#ifdef CONFIG_ARCH_OMAP
1180 if (machine_is_omap_osk()) {
1181 /* GPIO4 = PENIRQ; GPIO6 = BUSY */
1182 omap_request_gpio(4);
1183 omap_set_gpio_direction(4, 1);
1184 omap_request_gpio(6);
1185 omap_set_gpio_direction(6, 1);
1186 }
1187 // also TI 1510 Innovator, bitbanging through FPGA
1188 // also Nokia 770
1189 // also Palm Tungsten T2
1190#endif
1191
1192 // PXA:
1193 // also Dell Axim X50
1194 // also HP iPaq H191x/H192x/H415x/H435x
1195 // also Intel Lubbock (additional to UCB1400; as temperature sensor)
1196 // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
1197
1198 // Atmel at91sam9261-EK uses ads7843
1199
1200 // also various AMD Au1x00 devel boards
1201
1202 return spi_register_driver(&ads7846_driver); 1170 return spi_register_driver(&ads7846_driver);
1203} 1171}
1204module_init(ads7846_init); 1172module_init(ads7846_init);
@@ -1206,14 +1174,6 @@ module_init(ads7846_init);
1206static void __exit ads7846_exit(void) 1174static void __exit ads7846_exit(void)
1207{ 1175{
1208 spi_unregister_driver(&ads7846_driver); 1176 spi_unregister_driver(&ads7846_driver);
1209
1210#ifdef CONFIG_ARCH_OMAP
1211 if (machine_is_omap_osk()) {
1212 omap_free_gpio(4);
1213 omap_free_gpio(6);
1214 }
1215#endif
1216
1217} 1177}
1218module_exit(ads7846_exit); 1178module_exit(ads7846_exit);
1219 1179
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 6c0a9c4761ee..4c0b05852cb6 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -49,13 +49,13 @@ static void gpio_led_set(struct led_classdev *led_cdev,
49 if (led_dat->active_low) 49 if (led_dat->active_low)
50 level = !level; 50 level = !level;
51 51
52 /* setting GPIOs with I2C/etc requires a preemptible task context */ 52 /* Setting GPIOs with I2C/etc requires a task context, and we don't
53 * seem to have a reliable way to know if we're already in one; so
54 * let's just assume the worst.
55 */
53 if (led_dat->can_sleep) { 56 if (led_dat->can_sleep) {
54 if (preempt_count()) { 57 led_dat->new_level = level;
55 led_dat->new_level = level; 58 schedule_work(&led_dat->work);
56 schedule_work(&led_dat->work);
57 } else
58 gpio_set_value_cansleep(led_dat->gpio, level);
59 } else 59 } else
60 gpio_set_value(led_dat->gpio, level); 60 gpio_set_value(led_dat->gpio, level);
61} 61}
@@ -79,6 +79,10 @@ static int gpio_led_probe(struct platform_device *pdev)
79 cur_led = &pdata->leds[i]; 79 cur_led = &pdata->leds[i];
80 led_dat = &leds_data[i]; 80 led_dat = &leds_data[i];
81 81
82 ret = gpio_request(cur_led->gpio, cur_led->name);
83 if (ret < 0)
84 goto err;
85
82 led_dat->cdev.name = cur_led->name; 86 led_dat->cdev.name = cur_led->name;
83 led_dat->cdev.default_trigger = cur_led->default_trigger; 87 led_dat->cdev.default_trigger = cur_led->default_trigger;
84 led_dat->gpio = cur_led->gpio; 88 led_dat->gpio = cur_led->gpio;
@@ -87,10 +91,6 @@ static int gpio_led_probe(struct platform_device *pdev)
87 led_dat->cdev.brightness_set = gpio_led_set; 91 led_dat->cdev.brightness_set = gpio_led_set;
88 led_dat->cdev.brightness = LED_OFF; 92 led_dat->cdev.brightness = LED_OFF;
89 93
90 ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
91 if (ret < 0)
92 goto err;
93
94 gpio_direction_output(led_dat->gpio, led_dat->active_low); 94 gpio_direction_output(led_dat->gpio, led_dat->active_low);
95 95
96 INIT_WORK(&led_dat->work, gpio_led_work); 96 INIT_WORK(&led_dat->work, gpio_led_work);
diff --git a/drivers/lguest/Makefile b/drivers/lguest/Makefile
index 5e8272d296d8..7d463c26124f 100644
--- a/drivers/lguest/Makefile
+++ b/drivers/lguest/Makefile
@@ -19,3 +19,11 @@ Beer:
19 @for f in Preparation Guest Drivers Launcher Host Switcher Mastery; do echo "{==- $$f -==}"; make -s $$f; done; echo "{==-==}" 19 @for f in Preparation Guest Drivers Launcher Host Switcher Mastery; do echo "{==- $$f -==}"; make -s $$f; done; echo "{==-==}"
20Preparation Preparation! Guest Drivers Launcher Host Switcher Mastery: 20Preparation Preparation! Guest Drivers Launcher Host Switcher Mastery:
21 @sh ../../Documentation/lguest/extract $(PREFIX) `find ../../* -name '*.[chS]' -wholename '*lguest*'` 21 @sh ../../Documentation/lguest/extract $(PREFIX) `find ../../* -name '*.[chS]' -wholename '*lguest*'`
22Puppy:
23 @clear
24 @printf " __ \n (___()'\`;\n /, /\`\n \\\\\\\"--\\\\\\ \n"
25 @sleep 2; clear; printf "\n\n Sit!\n\n"; sleep 1; clear
26 @printf " __ \n ()'\`; \n /\\|\` \n / | \n(/_)_|_ \n"
27 @sleep 2; clear; printf "\n\n Stand!\n\n"; sleep 1; clear
28 @printf " __ \n ()'\`; \n /\\|\` \n /._.= \n /| / \n(_\_)_ \n"
29 @sleep 2; clear; printf "\n\n Good puppy!\n\n"; sleep 1; clear
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index c632c08cbbdc..5eea4356d703 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -1,8 +1,6 @@
1/*P:400 This contains run_guest() which actually calls into the Host<->Guest 1/*P:400 This contains run_guest() which actually calls into the Host<->Guest
2 * Switcher and analyzes the return, such as determining if the Guest wants the 2 * Switcher and analyzes the return, such as determining if the Guest wants the
3 * Host to do something. This file also contains useful helper routines, and a 3 * Host to do something. This file also contains useful helper routines. :*/
4 * couple of non-obvious setup and teardown pieces which were implemented after
5 * days of debugging pain. :*/
6#include <linux/module.h> 4#include <linux/module.h>
7#include <linux/stringify.h> 5#include <linux/stringify.h>
8#include <linux/stddef.h> 6#include <linux/stddef.h>
@@ -49,8 +47,8 @@ static __init int map_switcher(void)
49 * easy. 47 * easy.
50 */ 48 */
51 49
52 /* We allocate an array of "struct page"s. map_vm_area() wants the 50 /* We allocate an array of struct page pointers. map_vm_area() wants
53 * pages in this form, rather than just an array of pointers. */ 51 * this, rather than just an array of pages. */
54 switcher_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES, 52 switcher_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES,
55 GFP_KERNEL); 53 GFP_KERNEL);
56 if (!switcher_page) { 54 if (!switcher_page) {
@@ -172,7 +170,7 @@ void __lgread(struct lg_cpu *cpu, void *b, unsigned long addr, unsigned bytes)
172 } 170 }
173} 171}
174 172
175/* This is the write (copy into guest) version. */ 173/* This is the write (copy into Guest) version. */
176void __lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b, 174void __lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b,
177 unsigned bytes) 175 unsigned bytes)
178{ 176{
@@ -209,9 +207,9 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
209 if (cpu->break_out) 207 if (cpu->break_out)
210 return -EAGAIN; 208 return -EAGAIN;
211 209
212 /* Check if there are any interrupts which can be delivered 210 /* Check if there are any interrupts which can be delivered now:
213 * now: if so, this sets up the hander to be executed when we 211 * if so, this sets up the hander to be executed when we next
214 * next run the Guest. */ 212 * run the Guest. */
215 maybe_do_interrupt(cpu); 213 maybe_do_interrupt(cpu);
216 214
217 /* All long-lived kernel loops need to check with this horrible 215 /* All long-lived kernel loops need to check with this horrible
@@ -246,8 +244,10 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
246 lguest_arch_handle_trap(cpu); 244 lguest_arch_handle_trap(cpu);
247 } 245 }
248 246
247 /* Special case: Guest is 'dead' but wants a reboot. */
249 if (cpu->lg->dead == ERR_PTR(-ERESTART)) 248 if (cpu->lg->dead == ERR_PTR(-ERESTART))
250 return -ERESTART; 249 return -ERESTART;
250
251 /* The Guest is dead => "No such file or directory" */ 251 /* The Guest is dead => "No such file or directory" */
252 return -ENOENT; 252 return -ENOENT;
253} 253}
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c
index 0f2cb4fd7c69..54d66f05fefa 100644
--- a/drivers/lguest/hypercalls.c
+++ b/drivers/lguest/hypercalls.c
@@ -29,7 +29,7 @@
29#include "lg.h" 29#include "lg.h"
30 30
31/*H:120 This is the core hypercall routine: where the Guest gets what it wants. 31/*H:120 This is the core hypercall routine: where the Guest gets what it wants.
32 * Or gets killed. Or, in the case of LHCALL_CRASH, both. */ 32 * Or gets killed. Or, in the case of LHCALL_SHUTDOWN, both. */
33static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) 33static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args)
34{ 34{
35 switch (args->arg0) { 35 switch (args->arg0) {
@@ -190,6 +190,13 @@ static void initialize(struct lg_cpu *cpu)
190 * pagetable. */ 190 * pagetable. */
191 guest_pagetable_clear_all(cpu); 191 guest_pagetable_clear_all(cpu);
192} 192}
193/*:*/
194
195/*M:013 If a Guest reads from a page (so creates a mapping) that it has never
196 * written to, and then the Launcher writes to it (ie. the output of a virtual
197 * device), the Guest will still see the old page. In practice, this never
198 * happens: why would the Guest read a page which it has never written to? But
199 * a similar scenario might one day bite us, so it's worth mentioning. :*/
193 200
194/*H:100 201/*H:100
195 * Hypercalls 202 * Hypercalls
@@ -227,7 +234,7 @@ void do_hypercalls(struct lg_cpu *cpu)
227 * However, if we are signalled or the Guest sends I/O to the 234 * However, if we are signalled or the Guest sends I/O to the
228 * Launcher, the run_guest() loop will exit without running the 235 * Launcher, the run_guest() loop will exit without running the
229 * Guest. When it comes back it would try to re-run the 236 * Guest. When it comes back it would try to re-run the
230 * hypercall. */ 237 * hypercall. Finding that bug sucked. */
231 cpu->hcall = NULL; 238 cpu->hcall = NULL;
232 } 239 }
233} 240}
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 32e97c1858e5..0414ddf87587 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -144,7 +144,6 @@ void maybe_do_interrupt(struct lg_cpu *cpu)
144 if (copy_from_user(&blk, cpu->lg->lguest_data->blocked_interrupts, 144 if (copy_from_user(&blk, cpu->lg->lguest_data->blocked_interrupts,
145 sizeof(blk))) 145 sizeof(blk)))
146 return; 146 return;
147
148 bitmap_andnot(blk, cpu->irqs_pending, blk, LGUEST_IRQS); 147 bitmap_andnot(blk, cpu->irqs_pending, blk, LGUEST_IRQS);
149 148
150 /* Find the first interrupt. */ 149 /* Find the first interrupt. */
@@ -237,9 +236,9 @@ void free_interrupts(void)
237 clear_bit(syscall_vector, used_vectors); 236 clear_bit(syscall_vector, used_vectors);
238} 237}
239 238
240/*H:220 Now we've got the routines to deliver interrupts, delivering traps 239/*H:220 Now we've got the routines to deliver interrupts, delivering traps like
241 * like page fault is easy. The only trick is that Intel decided that some 240 * page fault is easy. The only trick is that Intel decided that some traps
242 * traps should have error codes: */ 241 * should have error codes: */
243static int has_err(unsigned int trap) 242static int has_err(unsigned int trap)
244{ 243{
245 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17); 244 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17);
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 1b2ec0bf5eb1..2bc9bf7e88e5 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -1,10 +1,10 @@
1/*P:050 Lguest guests use a very simple method to describe devices. It's a 1/*P:050 Lguest guests use a very simple method to describe devices. It's a
2 * series of device descriptors contained just above the top of normal 2 * series of device descriptors contained just above the top of normal Guest
3 * memory. 3 * memory.
4 * 4 *
5 * We use the standard "virtio" device infrastructure, which provides us with a 5 * We use the standard "virtio" device infrastructure, which provides us with a
6 * console, a network and a block driver. Each one expects some configuration 6 * console, a network and a block driver. Each one expects some configuration
7 * information and a "virtqueue" mechanism to send and receive data. :*/ 7 * information and a "virtqueue" or two to send and receive data. :*/
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/lguest_launcher.h> 10#include <linux/lguest_launcher.h>
@@ -53,7 +53,7 @@ struct lguest_device {
53 * Device configurations 53 * Device configurations
54 * 54 *
55 * The configuration information for a device consists of one or more 55 * The configuration information for a device consists of one or more
56 * virtqueues, a feature bitmaks, and some configuration bytes. The 56 * virtqueues, a feature bitmap, and some configuration bytes. The
57 * configuration bytes don't really matter to us: the Launcher sets them up, and 57 * configuration bytes don't really matter to us: the Launcher sets them up, and
58 * the driver will look at them during setup. 58 * the driver will look at them during setup.
59 * 59 *
@@ -179,7 +179,7 @@ struct lguest_vq_info
179}; 179};
180 180
181/* When the virtio_ring code wants to prod the Host, it calls us here and we 181/* When the virtio_ring code wants to prod the Host, it calls us here and we
182 * make a hypercall. We hand the page number of the virtqueue so the Host 182 * make a hypercall. We hand the physical address of the virtqueue so the Host
183 * knows which virtqueue we're talking about. */ 183 * knows which virtqueue we're talking about. */
184static void lg_notify(struct virtqueue *vq) 184static void lg_notify(struct virtqueue *vq)
185{ 185{
@@ -199,7 +199,8 @@ static void lg_notify(struct virtqueue *vq)
199 * allocate its own pages and tell the Host where they are, but for lguest it's 199 * allocate its own pages and tell the Host where they are, but for lguest it's
200 * simpler for the Host to simply tell us where the pages are. 200 * simpler for the Host to simply tell us where the pages are.
201 * 201 *
202 * So we provide devices with a "find virtqueue and set it up" function. */ 202 * So we provide drivers with a "find the Nth virtqueue and set it up"
203 * function. */
203static struct virtqueue *lg_find_vq(struct virtio_device *vdev, 204static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
204 unsigned index, 205 unsigned index,
205 void (*callback)(struct virtqueue *vq)) 206 void (*callback)(struct virtqueue *vq))
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 2221485b0773..645e6e040bfb 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -73,7 +73,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
73 if (current != cpu->tsk) 73 if (current != cpu->tsk)
74 return -EPERM; 74 return -EPERM;
75 75
76 /* If the guest is already dead, we indicate why */ 76 /* If the Guest is already dead, we indicate why */
77 if (lg->dead) { 77 if (lg->dead) {
78 size_t len; 78 size_t len;
79 79
@@ -88,7 +88,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
88 return len; 88 return len;
89 } 89 }
90 90
91 /* If we returned from read() last time because the Guest notified, 91 /* If we returned from read() last time because the Guest sent I/O,
92 * clear the flag. */ 92 * clear the flag. */
93 if (cpu->pending_notify) 93 if (cpu->pending_notify)
94 cpu->pending_notify = 0; 94 cpu->pending_notify = 0;
@@ -97,14 +97,20 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
97 return run_guest(cpu, (unsigned long __user *)user); 97 return run_guest(cpu, (unsigned long __user *)user);
98} 98}
99 99
100/*L:025 This actually initializes a CPU. For the moment, a Guest is only
101 * uniprocessor, so "id" is always 0. */
100static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip) 102static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
101{ 103{
104 /* We have a limited number the number of CPUs in the lguest struct. */
102 if (id >= NR_CPUS) 105 if (id >= NR_CPUS)
103 return -EINVAL; 106 return -EINVAL;
104 107
108 /* Set up this CPU's id, and pointer back to the lguest struct. */
105 cpu->id = id; 109 cpu->id = id;
106 cpu->lg = container_of((cpu - id), struct lguest, cpus[0]); 110 cpu->lg = container_of((cpu - id), struct lguest, cpus[0]);
107 cpu->lg->nr_cpus++; 111 cpu->lg->nr_cpus++;
112
113 /* Each CPU has a timer it can set. */
108 init_clockdev(cpu); 114 init_clockdev(cpu);
109 115
110 /* We need a complete page for the Guest registers: they are accessible 116 /* We need a complete page for the Guest registers: they are accessible
@@ -120,11 +126,11 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
120 * address. */ 126 * address. */
121 lguest_arch_setup_regs(cpu, start_ip); 127 lguest_arch_setup_regs(cpu, start_ip);
122 128
123 /* Initialize the queue for the waker to wait on */ 129 /* Initialize the queue for the Waker to wait on */
124 init_waitqueue_head(&cpu->break_wq); 130 init_waitqueue_head(&cpu->break_wq);
125 131
126 /* We keep a pointer to the Launcher task (ie. current task) for when 132 /* We keep a pointer to the Launcher task (ie. current task) for when
127 * other Guests want to wake this one (inter-Guest I/O). */ 133 * other Guests want to wake this one (eg. console input). */
128 cpu->tsk = current; 134 cpu->tsk = current;
129 135
130 /* We need to keep a pointer to the Launcher's memory map, because if 136 /* We need to keep a pointer to the Launcher's memory map, because if
@@ -136,6 +142,7 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
136 * when the same Guest runs on the same CPU twice. */ 142 * when the same Guest runs on the same CPU twice. */
137 cpu->last_pages = NULL; 143 cpu->last_pages = NULL;
138 144
145 /* No error == success. */
139 return 0; 146 return 0;
140} 147}
141 148
@@ -182,17 +189,16 @@ static int initialize(struct file *file, const unsigned long __user *input)
182 } 189 }
183 190
184 /* Populate the easy fields of our "struct lguest" */ 191 /* Populate the easy fields of our "struct lguest" */
185 lg->mem_base = (void __user *)(long)args[0]; 192 lg->mem_base = (void __user *)args[0];
186 lg->pfn_limit = args[1]; 193 lg->pfn_limit = args[1];
187 194
188 /* This is the first cpu */ 195 /* This is the first cpu (cpu 0) and it will start booting at args[3] */
189 err = lg_cpu_start(&lg->cpus[0], 0, args[3]); 196 err = lg_cpu_start(&lg->cpus[0], 0, args[3]);
190 if (err) 197 if (err)
191 goto release_guest; 198 goto release_guest;
192 199
193 /* Initialize the Guest's shadow page tables, using the toplevel 200 /* Initialize the Guest's shadow page tables, using the toplevel
194 * address the Launcher gave us. This allocates memory, so can 201 * address the Launcher gave us. This allocates memory, so can fail. */
195 * fail. */
196 err = init_guest_pagetable(lg, args[2]); 202 err = init_guest_pagetable(lg, args[2]);
197 if (err) 203 if (err)
198 goto free_regs; 204 goto free_regs;
@@ -218,11 +224,16 @@ unlock:
218/*L:010 The first operation the Launcher does must be a write. All writes 224/*L:010 The first operation the Launcher does must be a write. All writes
219 * start with an unsigned long number: for the first write this must be 225 * start with an unsigned long number: for the first write this must be
220 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use 226 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use
221 * writes of other values to send interrupts. */ 227 * writes of other values to send interrupts.
228 *
229 * Note that we overload the "offset" in the /dev/lguest file to indicate what
230 * CPU number we're dealing with. Currently this is always 0, since we only
231 * support uniprocessor Guests, but you can see the beginnings of SMP support
232 * here. */
222static ssize_t write(struct file *file, const char __user *in, 233static ssize_t write(struct file *file, const char __user *in,
223 size_t size, loff_t *off) 234 size_t size, loff_t *off)
224{ 235{
225 /* Once the guest is initialized, we hold the "struct lguest" in the 236 /* Once the Guest is initialized, we hold the "struct lguest" in the
226 * file private data. */ 237 * file private data. */
227 struct lguest *lg = file->private_data; 238 struct lguest *lg = file->private_data;
228 const unsigned long __user *input = (const unsigned long __user *)in; 239 const unsigned long __user *input = (const unsigned long __user *)in;
@@ -230,6 +241,7 @@ static ssize_t write(struct file *file, const char __user *in,
230 struct lg_cpu *uninitialized_var(cpu); 241 struct lg_cpu *uninitialized_var(cpu);
231 unsigned int cpu_id = *off; 242 unsigned int cpu_id = *off;
232 243
244 /* The first value tells us what this request is. */
233 if (get_user(req, input) != 0) 245 if (get_user(req, input) != 0)
234 return -EFAULT; 246 return -EFAULT;
235 input++; 247 input++;
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
index a7f64a9d67e0..d93500f24fbb 100644
--- a/drivers/lguest/page_tables.c
+++ b/drivers/lguest/page_tables.c
@@ -2,8 +2,8 @@
2 * previous encounters. It's functional, and as neat as it can be in the 2 * previous encounters. It's functional, and as neat as it can be in the
3 * circumstances, but be wary, for these things are subtle and break easily. 3 * circumstances, but be wary, for these things are subtle and break easily.
4 * The Guest provides a virtual to physical mapping, but we can neither trust 4 * The Guest provides a virtual to physical mapping, but we can neither trust
5 * it nor use it: we verify and convert it here to point the hardware to the 5 * it nor use it: we verify and convert it here then point the CPU to the
6 * actual Guest pages when running the Guest. :*/ 6 * converted Guest pages when running the Guest. :*/
7 7
8/* Copyright (C) Rusty Russell IBM Corporation 2006. 8/* Copyright (C) Rusty Russell IBM Corporation 2006.
9 * GPL v2 and any later version */ 9 * GPL v2 and any later version */
@@ -106,6 +106,11 @@ static unsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr)
106 BUG_ON(!(pgd_flags(gpgd) & _PAGE_PRESENT)); 106 BUG_ON(!(pgd_flags(gpgd) & _PAGE_PRESENT));
107 return gpage + ((vaddr>>PAGE_SHIFT) % PTRS_PER_PTE) * sizeof(pte_t); 107 return gpage + ((vaddr>>PAGE_SHIFT) % PTRS_PER_PTE) * sizeof(pte_t);
108} 108}
109/*:*/
110
111/*M:014 get_pfn is slow; it takes the mmap sem and calls get_user_pages. We
112 * could probably try to grab batches of pages here as an optimization
113 * (ie. pre-faulting). :*/
109 114
110/*H:350 This routine takes a page number given by the Guest and converts it to 115/*H:350 This routine takes a page number given by the Guest and converts it to
111 * an actual, physical page number. It can fail for several reasons: the 116 * an actual, physical page number. It can fail for several reasons: the
@@ -113,8 +118,8 @@ static unsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr)
113 * and the page is read-only, or the write flag was set and the page was 118 * and the page is read-only, or the write flag was set and the page was
114 * shared so had to be copied, but we ran out of memory. 119 * shared so had to be copied, but we ran out of memory.
115 * 120 *
116 * This holds a reference to the page, so release_pte() is careful to 121 * This holds a reference to the page, so release_pte() is careful to put that
117 * put that back. */ 122 * back. */
118static unsigned long get_pfn(unsigned long virtpfn, int write) 123static unsigned long get_pfn(unsigned long virtpfn, int write)
119{ 124{
120 struct page *page; 125 struct page *page;
@@ -532,13 +537,13 @@ static void do_set_pte(struct lg_cpu *cpu, int idx,
532 * all processes. So when the page table above that address changes, we update 537 * all processes. So when the page table above that address changes, we update
533 * all the page tables, not just the current one. This is rare. 538 * all the page tables, not just the current one. This is rare.
534 * 539 *
535 * The benefit is that when we have to track a new page table, we can copy keep 540 * The benefit is that when we have to track a new page table, we can keep all
536 * all the kernel mappings. This speeds up context switch immensely. */ 541 * the kernel mappings. This speeds up context switch immensely. */
537void guest_set_pte(struct lg_cpu *cpu, 542void guest_set_pte(struct lg_cpu *cpu,
538 unsigned long gpgdir, unsigned long vaddr, pte_t gpte) 543 unsigned long gpgdir, unsigned long vaddr, pte_t gpte)
539{ 544{
540 /* Kernel mappings must be changed on all top levels. Slow, but 545 /* Kernel mappings must be changed on all top levels. Slow, but doesn't
541 * doesn't happen often. */ 546 * happen often. */
542 if (vaddr >= cpu->lg->kernel_address) { 547 if (vaddr >= cpu->lg->kernel_address) {
543 unsigned int i; 548 unsigned int i;
544 for (i = 0; i < ARRAY_SIZE(cpu->lg->pgdirs); i++) 549 for (i = 0; i < ARRAY_SIZE(cpu->lg->pgdirs); i++)
@@ -704,12 +709,11 @@ static __init void populate_switcher_pte_page(unsigned int cpu,
704/* We've made it through the page table code. Perhaps our tired brains are 709/* We've made it through the page table code. Perhaps our tired brains are
705 * still processing the details, or perhaps we're simply glad it's over. 710 * still processing the details, or perhaps we're simply glad it's over.
706 * 711 *
707 * If nothing else, note that all this complexity in juggling shadow page 712 * If nothing else, note that all this complexity in juggling shadow page tables
708 * tables in sync with the Guest's page tables is for one reason: for most 713 * in sync with the Guest's page tables is for one reason: for most Guests this
709 * Guests this page table dance determines how bad performance will be. This 714 * page table dance determines how bad performance will be. This is why Xen
710 * is why Xen uses exotic direct Guest pagetable manipulation, and why both 715 * uses exotic direct Guest pagetable manipulation, and why both Intel and AMD
711 * Intel and AMD have implemented shadow page table support directly into 716 * have implemented shadow page table support directly into hardware.
712 * hardware.
713 * 717 *
714 * There is just one file remaining in the Host. */ 718 * There is just one file remaining in the Host. */
715 719
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 635187812d52..5126d5d9ea0e 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -17,6 +17,13 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20/*P:450 This file contains the x86-specific lguest code. It used to be all
21 * mixed in with drivers/lguest/core.c but several foolhardy code slashers
22 * wrestled most of the dependencies out to here in preparation for porting
23 * lguest to other architectures (see what I mean by foolhardy?).
24 *
25 * This also contains a couple of non-obvious setup and teardown pieces which
26 * were implemented after days of debugging pain. :*/
20#include <linux/kernel.h> 27#include <linux/kernel.h>
21#include <linux/start_kernel.h> 28#include <linux/start_kernel.h>
22#include <linux/string.h> 29#include <linux/string.h>
@@ -157,6 +164,8 @@ static void run_guest_once(struct lg_cpu *cpu, struct lguest_pages *pages)
157 * also simplify copy_in_guest_info(). Note that we'd still need to restore 164 * also simplify copy_in_guest_info(). Note that we'd still need to restore
158 * things when we exit to Launcher userspace, but that's fairly easy. 165 * things when we exit to Launcher userspace, but that's fairly easy.
159 * 166 *
167 * We could also try using this hooks for PGE, but that might be too expensive.
168 *
160 * The hooks were designed for KVM, but we can also put them to good use. :*/ 169 * The hooks were designed for KVM, but we can also put them to good use. :*/
161 170
162/*H:040 This is the i386-specific code to setup and run the Guest. Interrupts 171/*H:040 This is the i386-specific code to setup and run the Guest. Interrupts
@@ -182,7 +191,7 @@ void lguest_arch_run_guest(struct lg_cpu *cpu)
182 * was doing. */ 191 * was doing. */
183 run_guest_once(cpu, lguest_pages(raw_smp_processor_id())); 192 run_guest_once(cpu, lguest_pages(raw_smp_processor_id()));
184 193
185 /* Note that the "regs" pointer contains two extra entries which are 194 /* Note that the "regs" structure contains two extra entries which are
186 * not really registers: a trap number which says what interrupt or 195 * not really registers: a trap number which says what interrupt or
187 * trap made the switcher code come back, and an error code which some 196 * trap made the switcher code come back, and an error code which some
188 * traps set. */ 197 * traps set. */
@@ -293,11 +302,10 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
293 break; 302 break;
294 case 14: /* We've intercepted a Page Fault. */ 303 case 14: /* We've intercepted a Page Fault. */
295 /* The Guest accessed a virtual address that wasn't mapped. 304 /* The Guest accessed a virtual address that wasn't mapped.
296 * This happens a lot: we don't actually set up most of the 305 * This happens a lot: we don't actually set up most of the page
297 * page tables for the Guest at all when we start: as it runs 306 * tables for the Guest at all when we start: as it runs it asks
298 * it asks for more and more, and we set them up as 307 * for more and more, and we set them up as required. In this
299 * required. In this case, we don't even tell the Guest that 308 * case, we don't even tell the Guest that the fault happened.
300 * the fault happened.
301 * 309 *
302 * The errcode tells whether this was a read or a write, and 310 * The errcode tells whether this was a read or a write, and
303 * whether kernel or userspace code. */ 311 * whether kernel or userspace code. */
@@ -342,7 +350,7 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
342 if (!deliver_trap(cpu, cpu->regs->trapnum)) 350 if (!deliver_trap(cpu, cpu->regs->trapnum))
343 /* If the Guest doesn't have a handler (either it hasn't 351 /* If the Guest doesn't have a handler (either it hasn't
344 * registered any yet, or it's one of the faults we don't let 352 * registered any yet, or it's one of the faults we don't let
345 * it handle), it dies with a cryptic error message. */ 353 * it handle), it dies with this cryptic error message. */
346 kill_guest(cpu, "unhandled trap %li at %#lx (%#lx)", 354 kill_guest(cpu, "unhandled trap %li at %#lx (%#lx)",
347 cpu->regs->trapnum, cpu->regs->eip, 355 cpu->regs->trapnum, cpu->regs->eip,
348 cpu->regs->trapnum == 14 ? cpu->arch.last_pagefault 356 cpu->regs->trapnum == 14 ? cpu->arch.last_pagefault
@@ -375,8 +383,8 @@ void __init lguest_arch_host_init(void)
375 * The only exception is the interrupt handlers in switcher.S: their 383 * The only exception is the interrupt handlers in switcher.S: their
376 * addresses are placed in a table (default_idt_entries), so we need to 384 * addresses are placed in a table (default_idt_entries), so we need to
377 * update the table with the new addresses. switcher_offset() is a 385 * update the table with the new addresses. switcher_offset() is a
378 * convenience function which returns the distance between the builtin 386 * convenience function which returns the distance between the
379 * switcher code and the high-mapped copy we just made. */ 387 * compiled-in switcher code and the high-mapped copy we just made. */
380 for (i = 0; i < IDT_ENTRIES; i++) 388 for (i = 0; i < IDT_ENTRIES; i++)
381 default_idt_entries[i] += switcher_offset(); 389 default_idt_entries[i] += switcher_offset();
382 390
@@ -416,7 +424,7 @@ void __init lguest_arch_host_init(void)
416 state->guest_gdt_desc.address = (long)&state->guest_gdt; 424 state->guest_gdt_desc.address = (long)&state->guest_gdt;
417 425
418 /* We know where we want the stack to be when the Guest enters 426 /* We know where we want the stack to be when the Guest enters
419 * the switcher: in pages->regs. The stack grows upwards, so 427 * the Switcher: in pages->regs. The stack grows upwards, so
420 * we start it at the end of that structure. */ 428 * we start it at the end of that structure. */
421 state->guest_tss.sp0 = (long)(&pages->regs + 1); 429 state->guest_tss.sp0 = (long)(&pages->regs + 1);
422 /* And this is the GDT entry to use for the stack: we keep a 430 /* And this is the GDT entry to use for the stack: we keep a
@@ -513,8 +521,8 @@ int lguest_arch_init_hypercalls(struct lg_cpu *cpu)
513{ 521{
514 u32 tsc_speed; 522 u32 tsc_speed;
515 523
516 /* The pointer to the Guest's "struct lguest_data" is the only 524 /* The pointer to the Guest's "struct lguest_data" is the only argument.
517 * argument. We check that address now. */ 525 * We check that address now. */
518 if (!lguest_address_ok(cpu->lg, cpu->hcall->arg1, 526 if (!lguest_address_ok(cpu->lg, cpu->hcall->arg1,
519 sizeof(*cpu->lg->lguest_data))) 527 sizeof(*cpu->lg->lguest_data)))
520 return -EFAULT; 528 return -EFAULT;
@@ -546,6 +554,7 @@ int lguest_arch_init_hypercalls(struct lg_cpu *cpu)
546 554
547 return 0; 555 return 0;
548} 556}
557/*:*/
549 558
550/*L:030 lguest_arch_setup_regs() 559/*L:030 lguest_arch_setup_regs()
551 * 560 *
diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
index 0af8baaa0d4a..3fc15318a80f 100644
--- a/drivers/lguest/x86/switcher_32.S
+++ b/drivers/lguest/x86/switcher_32.S
@@ -1,6 +1,6 @@
1/*P:900 This is the Switcher: code which sits at 0xFFC00000 to do the low-level 1/*P:900 This is the Switcher: code which sits at 0xFFC00000 astride both the
2 * Guest<->Host switch. It is as simple as it can be made, but it's naturally 2 * Host and Guest to do the low-level Guest<->Host switch. It is as simple as
3 * very specific to x86. 3 * it can be made, but it's naturally very specific to x86.
4 * 4 *
5 * You have now completed Preparation. If this has whet your appetite; if you 5 * You have now completed Preparation. If this has whet your appetite; if you
6 * are feeling invigorated and refreshed then the next, more challenging stage 6 * are feeling invigorated and refreshed then the next, more challenging stage
@@ -189,7 +189,7 @@ ENTRY(switch_to_guest)
189 // Interrupts are turned back on: we are Guest. 189 // Interrupts are turned back on: we are Guest.
190 iret 190 iret
191 191
192// We treat two paths to switch back to the Host 192// We tread two paths to switch back to the Host
193// Yet both must save Guest state and restore Host 193// Yet both must save Guest state and restore Host
194// So we put the routine in a macro. 194// So we put the routine in a macro.
195#define SWITCH_TO_HOST \ 195#define SWITCH_TO_HOST \
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index b04f98df94ea..835def11419d 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 Christophe Saout <christophe@saout.de> 2 * Copyright (C) 2003 Christophe Saout <christophe@saout.de>
3 * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org> 3 * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
4 * Copyright (C) 2006-2007 Red Hat, Inc. All rights reserved. 4 * Copyright (C) 2006-2008 Red Hat, Inc. All rights reserved.
5 * 5 *
6 * This file is released under the GPL. 6 * This file is released under the GPL.
7 */ 7 */
@@ -93,6 +93,8 @@ struct crypt_config {
93 93
94 struct workqueue_struct *io_queue; 94 struct workqueue_struct *io_queue;
95 struct workqueue_struct *crypt_queue; 95 struct workqueue_struct *crypt_queue;
96 wait_queue_head_t writeq;
97
96 /* 98 /*
97 * crypto related data 99 * crypto related data
98 */ 100 */
@@ -331,14 +333,7 @@ static void crypt_convert_init(struct crypt_config *cc,
331 ctx->idx_out = bio_out ? bio_out->bi_idx : 0; 333 ctx->idx_out = bio_out ? bio_out->bi_idx : 0;
332 ctx->sector = sector + cc->iv_offset; 334 ctx->sector = sector + cc->iv_offset;
333 init_completion(&ctx->restart); 335 init_completion(&ctx->restart);
334 /* 336 atomic_set(&ctx->pending, 1);
335 * Crypto operation can be asynchronous,
336 * ctx->pending is increased after request submission.
337 * We need to ensure that we don't call the crypt finish
338 * operation before pending got incremented
339 * (dependent on crypt submission return code).
340 */
341 atomic_set(&ctx->pending, 2);
342} 337}
343 338
344static int crypt_convert_block(struct crypt_config *cc, 339static int crypt_convert_block(struct crypt_config *cc,
@@ -411,43 +406,42 @@ static void crypt_alloc_req(struct crypt_config *cc,
411static int crypt_convert(struct crypt_config *cc, 406static int crypt_convert(struct crypt_config *cc,
412 struct convert_context *ctx) 407 struct convert_context *ctx)
413{ 408{
414 int r = 0; 409 int r;
415 410
416 while(ctx->idx_in < ctx->bio_in->bi_vcnt && 411 while(ctx->idx_in < ctx->bio_in->bi_vcnt &&
417 ctx->idx_out < ctx->bio_out->bi_vcnt) { 412 ctx->idx_out < ctx->bio_out->bi_vcnt) {
418 413
419 crypt_alloc_req(cc, ctx); 414 crypt_alloc_req(cc, ctx);
420 415
416 atomic_inc(&ctx->pending);
417
421 r = crypt_convert_block(cc, ctx, cc->req); 418 r = crypt_convert_block(cc, ctx, cc->req);
422 419
423 switch (r) { 420 switch (r) {
421 /* async */
424 case -EBUSY: 422 case -EBUSY:
425 wait_for_completion(&ctx->restart); 423 wait_for_completion(&ctx->restart);
426 INIT_COMPLETION(ctx->restart); 424 INIT_COMPLETION(ctx->restart);
427 /* fall through*/ 425 /* fall through*/
428 case -EINPROGRESS: 426 case -EINPROGRESS:
429 atomic_inc(&ctx->pending);
430 cc->req = NULL; 427 cc->req = NULL;
431 r = 0; 428 ctx->sector++;
432 /* fall through*/ 429 continue;
430
431 /* sync */
433 case 0: 432 case 0:
433 atomic_dec(&ctx->pending);
434 ctx->sector++; 434 ctx->sector++;
435 continue; 435 continue;
436 }
437 436
438 break; 437 /* error */
438 default:
439 atomic_dec(&ctx->pending);
440 return r;
441 }
439 } 442 }
440 443
441 /* 444 return 0;
442 * If there are pending crypto operation run async
443 * code. Otherwise process return code synchronously.
444 * The step of 2 ensures that async finish doesn't
445 * call crypto finish too early.
446 */
447 if (atomic_sub_return(2, &ctx->pending))
448 return -EINPROGRESS;
449
450 return r;
451} 445}
452 446
453static void dm_crypt_bio_destructor(struct bio *bio) 447static void dm_crypt_bio_destructor(struct bio *bio)
@@ -624,8 +618,10 @@ static void kcryptd_io_read(struct dm_crypt_io *io)
624static void kcryptd_io_write(struct dm_crypt_io *io) 618static void kcryptd_io_write(struct dm_crypt_io *io)
625{ 619{
626 struct bio *clone = io->ctx.bio_out; 620 struct bio *clone = io->ctx.bio_out;
621 struct crypt_config *cc = io->target->private;
627 622
628 generic_make_request(clone); 623 generic_make_request(clone);
624 wake_up(&cc->writeq);
629} 625}
630 626
631static void kcryptd_io(struct work_struct *work) 627static void kcryptd_io(struct work_struct *work)
@@ -698,7 +694,8 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
698 694
699 r = crypt_convert(cc, &io->ctx); 695 r = crypt_convert(cc, &io->ctx);
700 696
701 if (r != -EINPROGRESS) { 697 if (atomic_dec_and_test(&io->ctx.pending)) {
698 /* processed, no running async crypto */
702 kcryptd_crypt_write_io_submit(io, r, 0); 699 kcryptd_crypt_write_io_submit(io, r, 0);
703 if (unlikely(r < 0)) 700 if (unlikely(r < 0))
704 return; 701 return;
@@ -706,8 +703,12 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
706 atomic_inc(&io->pending); 703 atomic_inc(&io->pending);
707 704
708 /* out of memory -> run queues */ 705 /* out of memory -> run queues */
709 if (unlikely(remaining)) 706 if (unlikely(remaining)) {
707 /* wait for async crypto then reinitialize pending */
708 wait_event(cc->writeq, !atomic_read(&io->ctx.pending));
709 atomic_set(&io->ctx.pending, 1);
710 congestion_wait(WRITE, HZ/100); 710 congestion_wait(WRITE, HZ/100);
711 }
711 } 712 }
712} 713}
713 714
@@ -746,7 +747,7 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
746 747
747 r = crypt_convert(cc, &io->ctx); 748 r = crypt_convert(cc, &io->ctx);
748 749
749 if (r != -EINPROGRESS) 750 if (atomic_dec_and_test(&io->ctx.pending))
750 kcryptd_crypt_read_done(io, r); 751 kcryptd_crypt_read_done(io, r);
751 752
752 crypt_dec_pending(io); 753 crypt_dec_pending(io);
@@ -1047,6 +1048,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1047 goto bad_crypt_queue; 1048 goto bad_crypt_queue;
1048 } 1049 }
1049 1050
1051 init_waitqueue_head(&cc->writeq);
1050 ti->private = cc; 1052 ti->private = cc;
1051 return 0; 1053 return 0;
1052 1054
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index b8e342fe7586..8f25f628ef16 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -114,7 +114,7 @@ static void dec_count(struct io *io, unsigned int region, int error)
114 wake_up_process(io->sleeper); 114 wake_up_process(io->sleeper);
115 115
116 else { 116 else {
117 int r = io->error; 117 unsigned long r = io->error;
118 io_notify_fn fn = io->callback; 118 io_notify_fn fn = io->callback;
119 void *context = io->context; 119 void *context = io->context;
120 120
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 51605870f898..762cb086bb7f 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -753,7 +753,7 @@ out:
753 * are in the no-sync state. We have to recover these by 753 * are in the no-sync state. We have to recover these by
754 * recopying from the default mirror to all the others. 754 * recopying from the default mirror to all the others.
755 *---------------------------------------------------------------*/ 755 *---------------------------------------------------------------*/
756static void recovery_complete(int read_err, unsigned int write_err, 756static void recovery_complete(int read_err, unsigned long write_err,
757 void *context) 757 void *context)
758{ 758{
759 struct region *reg = (struct region *)context; 759 struct region *reg = (struct region *)context;
@@ -767,7 +767,7 @@ static void recovery_complete(int read_err, unsigned int write_err,
767 } 767 }
768 768
769 if (write_err) { 769 if (write_err) {
770 DMERR_LIMIT("Write error during recovery (error = 0x%x)", 770 DMERR_LIMIT("Write error during recovery (error = 0x%lx)",
771 write_err); 771 write_err);
772 /* 772 /*
773 * Bits correspond to devices (excluding default mirror). 773 * Bits correspond to devices (excluding default mirror).
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index ae24eab8cd81..4dc8a43c034b 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -804,7 +804,7 @@ static void commit_callback(void *context, int success)
804 * Called when the copy I/O has finished. kcopyd actually runs 804 * Called when the copy I/O has finished. kcopyd actually runs
805 * this code so don't block. 805 * this code so don't block.
806 */ 806 */
807static void copy_callback(int read_err, unsigned int write_err, void *context) 807static void copy_callback(int read_err, unsigned long write_err, void *context)
808{ 808{
809 struct dm_snap_pending_exception *pe = context; 809 struct dm_snap_pending_exception *pe = context;
810 struct dm_snapshot *s = pe->snap; 810 struct dm_snapshot *s = pe->snap;
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index f3831f31223e..e76b52ade690 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -169,7 +169,7 @@ struct kcopyd_job {
169 * Error state of the job. 169 * Error state of the job.
170 */ 170 */
171 int read_err; 171 int read_err;
172 unsigned int write_err; 172 unsigned long write_err;
173 173
174 /* 174 /*
175 * Either READ or WRITE 175 * Either READ or WRITE
@@ -293,7 +293,7 @@ static int run_complete_job(struct kcopyd_job *job)
293{ 293{
294 void *context = job->context; 294 void *context = job->context;
295 int read_err = job->read_err; 295 int read_err = job->read_err;
296 unsigned int write_err = job->write_err; 296 unsigned long write_err = job->write_err;
297 kcopyd_notify_fn fn = job->fn; 297 kcopyd_notify_fn fn = job->fn;
298 struct kcopyd_client *kc = job->kc; 298 struct kcopyd_client *kc = job->kc;
299 299
@@ -396,7 +396,7 @@ static int process_jobs(struct list_head *jobs, int (*fn) (struct kcopyd_job *))
396 if (r < 0) { 396 if (r < 0) {
397 /* error this rogue job */ 397 /* error this rogue job */
398 if (job->rw == WRITE) 398 if (job->rw == WRITE)
399 job->write_err = (unsigned int) -1; 399 job->write_err = (unsigned long) -1L;
400 else 400 else
401 job->read_err = 1; 401 job->read_err = 1;
402 push(&_complete_jobs, job); 402 push(&_complete_jobs, job);
@@ -448,8 +448,8 @@ static void dispatch_job(struct kcopyd_job *job)
448} 448}
449 449
450#define SUB_JOB_SIZE 128 450#define SUB_JOB_SIZE 128
451static void segment_complete(int read_err, 451static void segment_complete(int read_err, unsigned long write_err,
452 unsigned int write_err, void *context) 452 void *context)
453{ 453{
454 /* FIXME: tidy this function */ 454 /* FIXME: tidy this function */
455 sector_t progress = 0; 455 sector_t progress = 0;
diff --git a/drivers/md/kcopyd.h b/drivers/md/kcopyd.h
index 4621ea055c0e..4845f2a0c676 100644
--- a/drivers/md/kcopyd.h
+++ b/drivers/md/kcopyd.h
@@ -32,8 +32,8 @@ void kcopyd_client_destroy(struct kcopyd_client *kc);
32 * read_err is a boolean, 32 * read_err is a boolean,
33 * write_err is a bitset, with 1 bit for each destination region 33 * write_err is a bitset, with 1 bit for each destination region
34 */ 34 */
35typedef void (*kcopyd_notify_fn)(int read_err, 35typedef void (*kcopyd_notify_fn)(int read_err, unsigned long write_err,
36 unsigned int write_err, void *context); 36 void *context);
37 37
38int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from, 38int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from,
39 unsigned int num_dests, struct io_region *dests, 39 unsigned int num_dests, struct io_region *dests,
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index c574cf5efb5c..b162b839a662 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2348,25 +2348,15 @@ static void handle_issuing_new_write_requests6(raid5_conf_t *conf,
2348static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh, 2348static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2349 struct stripe_head_state *s, int disks) 2349 struct stripe_head_state *s, int disks)
2350{ 2350{
2351 int canceled_check = 0;
2352
2351 set_bit(STRIPE_HANDLE, &sh->state); 2353 set_bit(STRIPE_HANDLE, &sh->state);
2352 /* Take one of the following actions:
2353 * 1/ start a check parity operation if (uptodate == disks)
2354 * 2/ finish a check parity operation and act on the result
2355 * 3/ skip to the writeback section if we previously
2356 * initiated a recovery operation
2357 */
2358 if (s->failed == 0 &&
2359 !test_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending)) {
2360 if (!test_and_set_bit(STRIPE_OP_CHECK, &sh->ops.pending)) {
2361 BUG_ON(s->uptodate != disks);
2362 clear_bit(R5_UPTODATE, &sh->dev[sh->pd_idx].flags);
2363 sh->ops.count++;
2364 s->uptodate--;
2365 } else if (
2366 test_and_clear_bit(STRIPE_OP_CHECK, &sh->ops.complete)) {
2367 clear_bit(STRIPE_OP_CHECK, &sh->ops.ack);
2368 clear_bit(STRIPE_OP_CHECK, &sh->ops.pending);
2369 2354
2355 /* complete a check operation */
2356 if (test_and_clear_bit(STRIPE_OP_CHECK, &sh->ops.complete)) {
2357 clear_bit(STRIPE_OP_CHECK, &sh->ops.ack);
2358 clear_bit(STRIPE_OP_CHECK, &sh->ops.pending);
2359 if (s->failed == 0) {
2370 if (sh->ops.zero_sum_result == 0) 2360 if (sh->ops.zero_sum_result == 0)
2371 /* parity is correct (on disc, 2361 /* parity is correct (on disc,
2372 * not in buffer any more) 2362 * not in buffer any more)
@@ -2391,7 +2381,8 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2391 s->uptodate++; 2381 s->uptodate++;
2392 } 2382 }
2393 } 2383 }
2394 } 2384 } else
2385 canceled_check = 1; /* STRIPE_INSYNC is not set */
2395 } 2386 }
2396 2387
2397 /* check if we can clear a parity disk reconstruct */ 2388 /* check if we can clear a parity disk reconstruct */
@@ -2404,12 +2395,28 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2404 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending); 2395 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending);
2405 } 2396 }
2406 2397
2398 /* start a new check operation if there are no failures, the stripe is
2399 * not insync, and a repair is not in flight
2400 */
2401 if (s->failed == 0 &&
2402 !test_bit(STRIPE_INSYNC, &sh->state) &&
2403 !test_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending)) {
2404 if (!test_and_set_bit(STRIPE_OP_CHECK, &sh->ops.pending)) {
2405 BUG_ON(s->uptodate != disks);
2406 clear_bit(R5_UPTODATE, &sh->dev[sh->pd_idx].flags);
2407 sh->ops.count++;
2408 s->uptodate--;
2409 }
2410 }
2411
2407 /* Wait for check parity and compute block operations to complete 2412 /* Wait for check parity and compute block operations to complete
2408 * before write-back 2413 * before write-back. If a failure occurred while the check operation
2414 * was in flight we need to cycle this stripe through handle_stripe
2415 * since the parity block may not be uptodate
2409 */ 2416 */
2410 if (!test_bit(STRIPE_INSYNC, &sh->state) && 2417 if (!canceled_check && !test_bit(STRIPE_INSYNC, &sh->state) &&
2411 !test_bit(STRIPE_OP_CHECK, &sh->ops.pending) && 2418 !test_bit(STRIPE_OP_CHECK, &sh->ops.pending) &&
2412 !test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending)) { 2419 !test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending)) {
2413 struct r5dev *dev; 2420 struct r5dev *dev;
2414 /* either failed parity check, or recovery is happening */ 2421 /* either failed parity check, or recovery is happening */
2415 if (s->failed == 0) 2422 if (s->failed == 0)
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index 8cf91353b56a..7b8bb6949f5e 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -6,3 +6,6 @@ obj-y := common/
6obj-y += video/ 6obj-y += video/
7obj-$(CONFIG_VIDEO_DEV) += radio/ 7obj-$(CONFIG_VIDEO_DEV) += radio/
8obj-$(CONFIG_DVB_CORE) += dvb/ 8obj-$(CONFIG_DVB_CORE) += dvb/
9ifeq ($(CONFIG_DVB_CORE),)
10 obj-$(CONFIG_VIDEO_TUNER) += dvb/frontends/
11endif
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 168a8d3a5e55..7707b8c7394b 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -306,25 +306,22 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id)
306 return IRQ_NONE; 306 return IRQ_NONE;
307 } 307 }
308 308
309 if( 0 != (dev->ext)) { 309 if (dev->ext) {
310 if( 0 != (dev->ext->irq_mask & isr )) { 310 if (dev->ext->irq_mask & isr) {
311 if( 0 != dev->ext->irq_func ) { 311 if (dev->ext->irq_func)
312 dev->ext->irq_func(dev, &isr); 312 dev->ext->irq_func(dev, &isr);
313 }
314 isr &= ~dev->ext->irq_mask; 313 isr &= ~dev->ext->irq_mask;
315 } 314 }
316 } 315 }
317 if (0 != (isr & (MASK_27))) { 316 if (0 != (isr & (MASK_27))) {
318 DEB_INT(("irq: RPS0 (0x%08x).\n",isr)); 317 DEB_INT(("irq: RPS0 (0x%08x).\n",isr));
319 if( 0 != dev->vv_data && 0 != dev->vv_callback) { 318 if (dev->vv_data && dev->vv_callback)
320 dev->vv_callback(dev,isr); 319 dev->vv_callback(dev,isr);
321 }
322 isr &= ~MASK_27; 320 isr &= ~MASK_27;
323 } 321 }
324 if (0 != (isr & (MASK_28))) { 322 if (0 != (isr & (MASK_28))) {
325 if( 0 != dev->vv_data && 0 != dev->vv_callback) { 323 if (dev->vv_data && dev->vv_callback)
326 dev->vv_callback(dev,isr); 324 dev->vv_callback(dev,isr);
327 }
328 isr &= ~MASK_28; 325 isr &= ~MASK_28;
329 } 326 }
330 if (0 != (isr & (MASK_16|MASK_17))) { 327 if (0 != (isr & (MASK_16|MASK_17))) {
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index f0703d8bc3e8..171afe7da6b6 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -272,7 +272,7 @@ static int fops_open(struct inode *inode, struct file *file)
272 272
273 result = 0; 273 result = 0;
274out: 274out:
275 if( fh != 0 && result != 0 ) { 275 if (fh && result != 0) {
276 kfree(fh); 276 kfree(fh);
277 file->private_data = NULL; 277 file->private_data = NULL;
278 } 278 }
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index ed3f8268ed11..4c8b62e2c035 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -784,8 +784,8 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
784{ 784{
785 struct net_device *dev = feed->priv; 785 struct net_device *dev = feed->priv;
786 786
787 if (buffer2 != 0) 787 if (buffer2)
788 printk(KERN_WARNING "buffer2 not 0: %p.\n", buffer2); 788 printk(KERN_WARNING "buffer2 not NULL: %p.\n", buffer2);
789 if (buffer1_len > 32768) 789 if (buffer1_len > 32768)
790 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len); 790 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len);
791 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n", 791 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n",
diff --git a/drivers/media/dvb/frontends/s5h1409.c b/drivers/media/dvb/frontends/s5h1409.c
index 819433485d3b..1a4d8319773c 100644
--- a/drivers/media/dvb/frontends/s5h1409.c
+++ b/drivers/media/dvb/frontends/s5h1409.c
@@ -445,7 +445,7 @@ static int s5h1409_set_gpio(struct dvb_frontend* fe, int enable)
445 s5h1409_readreg(state, 0xe3) | 0x1100); 445 s5h1409_readreg(state, 0xe3) | 0x1100);
446 else 446 else
447 return s5h1409_writereg(state, 0xe3, 447 return s5h1409_writereg(state, 0xe3,
448 s5h1409_readreg(state, 0xe3) & 0xeeff); 448 s5h1409_readreg(state, 0xe3) & 0xfeff);
449} 449}
450 450
451static int s5h1409_sleep(struct dvb_frontend* fe, int enable) 451static int s5h1409_sleep(struct dvb_frontend* fe, int enable)
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 34e317ced5a3..57b9e3adc8f0 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -587,6 +587,8 @@ static struct video_device cadet_radio=
587 .vidioc_s_input = vidioc_s_input, 587 .vidioc_s_input = vidioc_s_input,
588}; 588};
589 589
590#ifdef CONFIG_PNP
591
590static struct pnp_device_id cadet_pnp_devices[] = { 592static struct pnp_device_id cadet_pnp_devices[] = {
591 /* ADS Cadet AM/FM Radio Card */ 593 /* ADS Cadet AM/FM Radio Card */
592 {.id = "MSM0c24", .driver_data = 0}, 594 {.id = "MSM0c24", .driver_data = 0},
@@ -621,6 +623,10 @@ static struct pnp_driver cadet_pnp_driver = {
621 .remove = NULL, 623 .remove = NULL,
622}; 624};
623 625
626#else
627static struct pnp_driver cadet_pnp_driver;
628#endif
629
624static int cadet_probe(void) 630static int cadet_probe(void)
625{ 631{
626 static int iovals[8]={0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e}; 632 static int iovals[8]={0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e};
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index cbab53fc6243..fea2e723e34b 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -408,7 +408,7 @@ adv7170_detect_client (struct i2c_adapter *adapter,
408 return 0; 408 return 0;
409 409
410 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 410 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
411 if (client == 0) 411 if (!client)
412 return -ENOMEM; 412 return -ENOMEM;
413 client->addr = address; 413 client->addr = address;
414 client->adapter = adapter; 414 client->adapter = adapter;
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 0d0c554bfdf7..10d4d89623f1 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -426,7 +426,7 @@ adv7175_detect_client (struct i2c_adapter *adapter,
426 return 0; 426 return 0;
427 427
428 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 428 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
429 if (client == 0) 429 if (!client)
430 return -ENOMEM; 430 return -ENOMEM;
431 client->addr = address; 431 client->addr = address;
432 client->adapter = adapter; 432 client->adapter = adapter;
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 12d1b9248be5..e663cc045c41 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -524,7 +524,7 @@ bt819_detect_client (struct i2c_adapter *adapter,
524 return 0; 524 return 0;
525 525
526 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 526 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
527 if (client == 0) 527 if (!client)
528 return -ENOMEM; 528 return -ENOMEM;
529 client->addr = address; 529 client->addr = address;
530 client->adapter = adapter; 530 client->adapter = adapter;
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index e1028a76c042..7dee2e3235ad 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -311,7 +311,7 @@ bt856_detect_client (struct i2c_adapter *adapter,
311 return 0; 311 return 0;
312 312
313 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 313 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
314 if (client == 0) 314 if (!client)
315 return -ENOMEM; 315 return -ENOMEM;
316 client->addr = address; 316 client->addr = address;
317 client->adapter = adapter; 317 client->adapter = adapter;
diff --git a/drivers/media/video/bt8xx/bt832.c b/drivers/media/video/bt8xx/bt832.c
index a51876137880..f92f06dec0d0 100644
--- a/drivers/media/video/bt8xx/bt832.c
+++ b/drivers/media/video/bt8xx/bt832.c
@@ -97,6 +97,11 @@ int bt832_init(struct i2c_client *i2c_client_s)
97 int rc; 97 int rc;
98 98
99 buf=kmalloc(65,GFP_KERNEL); 99 buf=kmalloc(65,GFP_KERNEL);
100 if (!buf) {
101 v4l_err(&t->client,
102 "Unable to allocate memory. Detaching.\n");
103 return 0;
104 }
100 bt832_hexdump(i2c_client_s,buf); 105 bt832_hexdump(i2c_client_s,buf);
101 106
102 if(buf[0x40] != 0x31) { 107 if(buf[0x40] != 0x31) {
@@ -211,7 +216,12 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
211 switch (cmd) { 216 switch (cmd) {
212 case BT832_HEXDUMP: { 217 case BT832_HEXDUMP: {
213 unsigned char *buf; 218 unsigned char *buf;
214 buf=kmalloc(65,GFP_KERNEL); 219 buf = kmalloc(65, GFP_KERNEL);
220 if (!buf) {
221 v4l_err(&t->client,
222 "Unable to allocate memory\n");
223 break;
224 }
215 bt832_hexdump(&t->client,buf); 225 bt832_hexdump(&t->client,buf);
216 kfree(buf); 226 kfree(buf);
217 } 227 }
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index a080c149cc6c..fcf8f2d208a8 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -1990,7 +1990,7 @@ static int bttv_g_frequency(struct file *file, void *priv,
1990 if (0 != err) 1990 if (0 != err)
1991 return err; 1991 return err;
1992 1992
1993 f->type = V4L2_TUNER_ANALOG_TV; 1993 f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1994 f->frequency = btv->freq; 1994 f->frequency = btv->freq;
1995 1995
1996 return 0; 1996 return 0;
@@ -2009,7 +2009,8 @@ static int bttv_s_frequency(struct file *file, void *priv,
2009 2009
2010 if (unlikely(f->tuner != 0)) 2010 if (unlikely(f->tuner != 0))
2011 return -EINVAL; 2011 return -EINVAL;
2012 if (unlikely(f->type != V4L2_TUNER_ANALOG_TV)) 2012 if (unlikely(f->type != (btv->radio_user
2013 ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV)))
2013 return -EINVAL; 2014 return -EINVAL;
2014 mutex_lock(&btv->lock); 2015 mutex_lock(&btv->lock);
2015 btv->freq = f->frequency; 2016 btv->freq = f->frequency;
@@ -3415,6 +3416,7 @@ static int radio_open(struct inode *inode, struct file *file)
3415{ 3416{
3416 int minor = iminor(inode); 3417 int minor = iminor(inode);
3417 struct bttv *btv = NULL; 3418 struct bttv *btv = NULL;
3419 struct bttv_fh *fh;
3418 unsigned int i; 3420 unsigned int i;
3419 3421
3420 dprintk("bttv: open minor=%d\n",minor); 3422 dprintk("bttv: open minor=%d\n",minor);
@@ -3429,12 +3431,19 @@ static int radio_open(struct inode *inode, struct file *file)
3429 return -ENODEV; 3431 return -ENODEV;
3430 3432
3431 dprintk("bttv%d: open called (radio)\n",btv->c.nr); 3433 dprintk("bttv%d: open called (radio)\n",btv->c.nr);
3434
3435 /* allocate per filehandle data */
3436 fh = kmalloc(sizeof(*fh), GFP_KERNEL);
3437 if (NULL == fh)
3438 return -ENOMEM;
3439 file->private_data = fh;
3440 *fh = btv->init;
3441 v4l2_prio_open(&btv->prio, &fh->prio);
3442
3432 mutex_lock(&btv->lock); 3443 mutex_lock(&btv->lock);
3433 3444
3434 btv->radio_user++; 3445 btv->radio_user++;
3435 3446
3436 file->private_data = btv;
3437
3438 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL); 3447 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL);
3439 audio_input(btv,TVAUDIO_INPUT_RADIO); 3448 audio_input(btv,TVAUDIO_INPUT_RADIO);
3440 3449
@@ -3444,7 +3453,8 @@ static int radio_open(struct inode *inode, struct file *file)
3444 3453
3445static int radio_release(struct inode *inode, struct file *file) 3454static int radio_release(struct inode *inode, struct file *file)
3446{ 3455{
3447 struct bttv *btv = file->private_data; 3456 struct bttv_fh *fh = file->private_data;
3457 struct bttv *btv = fh->btv;
3448 struct rds_command cmd; 3458 struct rds_command cmd;
3449 3459
3450 btv->radio_user--; 3460 btv->radio_user--;
@@ -3508,8 +3518,12 @@ static int radio_enum_input(struct file *file, void *priv,
3508static int radio_g_audio(struct file *file, void *priv, 3518static int radio_g_audio(struct file *file, void *priv,
3509 struct v4l2_audio *a) 3519 struct v4l2_audio *a)
3510{ 3520{
3521 if (a->index != 0)
3522 return -EINVAL;
3523
3511 memset(a, 0, sizeof(*a)); 3524 memset(a, 0, sizeof(*a));
3512 strcpy(a->name, "Radio"); 3525 strcpy(a->name, "Radio");
3526
3513 return 0; 3527 return 0;
3514} 3528}
3515 3529
@@ -3569,7 +3583,8 @@ static int radio_g_input(struct file *filp, void *priv, unsigned int *i)
3569static ssize_t radio_read(struct file *file, char __user *data, 3583static ssize_t radio_read(struct file *file, char __user *data,
3570 size_t count, loff_t *ppos) 3584 size_t count, loff_t *ppos)
3571{ 3585{
3572 struct bttv *btv = file->private_data; 3586 struct bttv_fh *fh = file->private_data;
3587 struct bttv *btv = fh->btv;
3573 struct rds_command cmd; 3588 struct rds_command cmd;
3574 cmd.block_count = count/3; 3589 cmd.block_count = count/3;
3575 cmd.buffer = data; 3590 cmd.buffer = data;
@@ -3583,7 +3598,8 @@ static ssize_t radio_read(struct file *file, char __user *data,
3583 3598
3584static unsigned int radio_poll(struct file *file, poll_table *wait) 3599static unsigned int radio_poll(struct file *file, poll_table *wait)
3585{ 3600{
3586 struct bttv *btv = file->private_data; 3601 struct bttv_fh *fh = file->private_data;
3602 struct bttv *btv = fh->btv;
3587 struct rds_command cmd; 3603 struct rds_command cmd;
3588 cmd.instance = file; 3604 cmd.instance = file;
3589 cmd.event_list = wait; 3605 cmd.event_list = wait;
@@ -3599,6 +3615,7 @@ static const struct file_operations radio_fops =
3599 .open = radio_open, 3615 .open = radio_open,
3600 .read = radio_read, 3616 .read = radio_read,
3601 .release = radio_release, 3617 .release = radio_release,
3618 .compat_ioctl = v4l_compat_ioctl32,
3602 .ioctl = video_ioctl2, 3619 .ioctl = video_ioctl2,
3603 .llseek = no_llseek, 3620 .llseek = no_llseek,
3604 .poll = radio_poll, 3621 .poll = radio_poll,
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index 2d414dad5c31..dfa269838e01 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -232,6 +232,7 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
232 case 78631: /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */ 232 case 78631: /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */
233 case 79001: /* WinTV-HVR1250 (PCIe, Retail, IR, full height, ATSC and Basic analog */ 233 case 79001: /* WinTV-HVR1250 (PCIe, Retail, IR, full height, ATSC and Basic analog */
234 case 79101: /* WinTV-HVR1250 (PCIe, Retail, IR, half height, ATSC and Basic analog */ 234 case 79101: /* WinTV-HVR1250 (PCIe, Retail, IR, half height, ATSC and Basic analog */
235 case 79561: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */
235 case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */ 236 case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */
236 case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ 237 case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */
237 break; 238 break;
@@ -347,10 +348,13 @@ void cx23885_card_setup(struct cx23885_dev *dev)
347 case CX23885_BOARD_HAUPPAUGE_HVR1250: 348 case CX23885_BOARD_HAUPPAUGE_HVR1250:
348 case CX23885_BOARD_HAUPPAUGE_HVR1500: 349 case CX23885_BOARD_HAUPPAUGE_HVR1500:
349 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 350 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
351 if (dev->i2c_bus[0].i2c_rc == 0)
352 hauppauge_eeprom(dev, eeprom+0x80);
353 break;
350 case CX23885_BOARD_HAUPPAUGE_HVR1800: 354 case CX23885_BOARD_HAUPPAUGE_HVR1800:
351 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 355 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
352 if (dev->i2c_bus[0].i2c_rc == 0) 356 if (dev->i2c_bus[0].i2c_rc == 0)
353 hauppauge_eeprom(dev, eeprom+0x80); 357 hauppauge_eeprom(dev, eeprom+0xc0);
354 break; 358 break;
355 } 359 }
356 360
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index 8e40c7bcc06d..7f10b273598f 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -56,137 +56,6 @@ LIST_HEAD(cx23885_devlist);
56 56
57#define NO_SYNC_LINE (-1U) 57#define NO_SYNC_LINE (-1U)
58 58
59/*
60 * CX23885 Assumptions
61 * 1 line = 16 bytes of CDT
62 * cmds size = 80
63 * cdt size = 16 * linesize
64 * iqsize = 64
65 * maxlines = 6
66 *
67 * Address Space:
68 * 0x00000000 0x00008fff FIFO clusters
69 * 0x00010000 0x000104af Channel Management Data Structures
70 * 0x000104b0 0x000104ff Free
71 * 0x00010500 0x000108bf 15 channels * iqsize
72 * 0x000108c0 0x000108ff Free
73 * 0x00010900 0x00010e9f IQ's + Cluster Descriptor Tables
74 * 15 channels * (iqsize + (maxlines * linesize))
75 * 0x00010ea0 0x00010xxx Free
76 */
77
78static struct sram_channel cx23885_sram_channels[] = {
79 [SRAM_CH01] = {
80 .name = "VID A",
81 .cmds_start = 0x10000,
82 .ctrl_start = 0x105b0,
83 .cdt = 0x107b0,
84 .fifo_start = 0x40,
85 .fifo_size = 0x2800,
86 .ptr1_reg = DMA1_PTR1,
87 .ptr2_reg = DMA1_PTR2,
88 .cnt1_reg = DMA1_CNT1,
89 .cnt2_reg = DMA1_CNT2,
90 .jumponly = 1,
91 },
92 [SRAM_CH02] = {
93 .name = "ch2",
94 .cmds_start = 0x0,
95 .ctrl_start = 0x0,
96 .cdt = 0x0,
97 .fifo_start = 0x0,
98 .fifo_size = 0x0,
99 .ptr1_reg = DMA2_PTR1,
100 .ptr2_reg = DMA2_PTR2,
101 .cnt1_reg = DMA2_CNT1,
102 .cnt2_reg = DMA2_CNT2,
103 },
104 [SRAM_CH03] = {
105 .name = "TS1 B",
106 .cmds_start = 0x100A0,
107 .ctrl_start = 0x10630,
108 .cdt = 0x10870,
109 .fifo_start = 0x5000,
110 .fifo_size = 0x1000,
111 .ptr1_reg = DMA3_PTR1,
112 .ptr2_reg = DMA3_PTR2,
113 .cnt1_reg = DMA3_CNT1,
114 .cnt2_reg = DMA3_CNT2,
115 },
116 [SRAM_CH04] = {
117 .name = "ch4",
118 .cmds_start = 0x0,
119 .ctrl_start = 0x0,
120 .cdt = 0x0,
121 .fifo_start = 0x0,
122 .fifo_size = 0x0,
123 .ptr1_reg = DMA4_PTR1,
124 .ptr2_reg = DMA4_PTR2,
125 .cnt1_reg = DMA4_CNT1,
126 .cnt2_reg = DMA4_CNT2,
127 },
128 [SRAM_CH05] = {
129 .name = "ch5",
130 .cmds_start = 0x0,
131 .ctrl_start = 0x0,
132 .cdt = 0x0,
133 .fifo_start = 0x0,
134 .fifo_size = 0x0,
135 .ptr1_reg = DMA5_PTR1,
136 .ptr2_reg = DMA5_PTR2,
137 .cnt1_reg = DMA5_CNT1,
138 .cnt2_reg = DMA5_CNT2,
139 },
140 [SRAM_CH06] = {
141 .name = "TS2 C",
142 .cmds_start = 0x10140,
143 .ctrl_start = 0x10680,
144 .cdt = 0x108d0,
145 .fifo_start = 0x6000,
146 .fifo_size = 0x1000,
147 .ptr1_reg = DMA5_PTR1,
148 .ptr2_reg = DMA5_PTR2,
149 .cnt1_reg = DMA5_CNT1,
150 .cnt2_reg = DMA5_CNT2,
151 },
152 [SRAM_CH07] = {
153 .name = "ch7",
154 .cmds_start = 0x0,
155 .ctrl_start = 0x0,
156 .cdt = 0x0,
157 .fifo_start = 0x0,
158 .fifo_size = 0x0,
159 .ptr1_reg = DMA6_PTR1,
160 .ptr2_reg = DMA6_PTR2,
161 .cnt1_reg = DMA6_CNT1,
162 .cnt2_reg = DMA6_CNT2,
163 },
164 [SRAM_CH08] = {
165 .name = "ch8",
166 .cmds_start = 0x0,
167 .ctrl_start = 0x0,
168 .cdt = 0x0,
169 .fifo_start = 0x0,
170 .fifo_size = 0x0,
171 .ptr1_reg = DMA7_PTR1,
172 .ptr2_reg = DMA7_PTR2,
173 .cnt1_reg = DMA7_CNT1,
174 .cnt2_reg = DMA7_CNT2,
175 },
176 [SRAM_CH09] = {
177 .name = "ch9",
178 .cmds_start = 0x0,
179 .ctrl_start = 0x0,
180 .cdt = 0x0,
181 .fifo_start = 0x0,
182 .fifo_size = 0x0,
183 .ptr1_reg = DMA8_PTR1,
184 .ptr2_reg = DMA8_PTR2,
185 .cnt1_reg = DMA8_CNT1,
186 .cnt2_reg = DMA8_CNT2,
187 },
188};
189
190/* FIXME, these allocations will change when 59/* FIXME, these allocations will change when
191 * analog arrives. The be reviewed. 60 * analog arrives. The be reviewed.
192 * CX23887 Assumptions 61 * CX23887 Assumptions
@@ -754,6 +623,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
754 atomic_inc(&dev->refcount); 623 atomic_inc(&dev->refcount);
755 624
756 dev->nr = cx23885_devcount++; 625 dev->nr = cx23885_devcount++;
626 dev->sram_channels = cx23887_sram_channels;
757 sprintf(dev->name, "cx23885[%d]", dev->nr); 627 sprintf(dev->name, "cx23885[%d]", dev->nr);
758 628
759 mutex_lock(&devlist); 629 mutex_lock(&devlist);
@@ -763,13 +633,11 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
763 /* Configure the internal memory */ 633 /* Configure the internal memory */
764 if(dev->pci->device == 0x8880) { 634 if(dev->pci->device == 0x8880) {
765 dev->bridge = CX23885_BRIDGE_887; 635 dev->bridge = CX23885_BRIDGE_887;
766 dev->sram_channels = cx23887_sram_channels;
767 /* Apply a sensible clock frequency for the PCIe bridge */ 636 /* Apply a sensible clock frequency for the PCIe bridge */
768 dev->clk_freq = 25000000; 637 dev->clk_freq = 25000000;
769 } else 638 } else
770 if(dev->pci->device == 0x8852) { 639 if(dev->pci->device == 0x8852) {
771 dev->bridge = CX23885_BRIDGE_885; 640 dev->bridge = CX23885_BRIDGE_885;
772 dev->sram_channels = cx23885_sram_channels;
773 /* Apply a sensible clock frequency for the PCIe bridge */ 641 /* Apply a sensible clock frequency for the PCIe bridge */
774 dev->clk_freq = 28000000; 642 dev->clk_freq = 28000000;
775 } else 643 } else
diff --git a/drivers/media/video/dpc7146.c b/drivers/media/video/dpc7146.c
index 566e479e2629..9ceb6b2f3949 100644
--- a/drivers/media/video/dpc7146.c
+++ b/drivers/media/video/dpc7146.c
@@ -131,7 +131,7 @@ static int dpc_probe(struct saa7146_dev* dev)
131 device_for_each_child(&dpc->i2c_adapter.dev, dpc, dpc_check_clients); 131 device_for_each_child(&dpc->i2c_adapter.dev, dpc, dpc_check_clients);
132 132
133 /* check if all devices are present */ 133 /* check if all devices are present */
134 if( 0 == dpc->saa7111a ) { 134 if (!dpc->saa7111a) {
135 DEB_D(("dpc_v4l2.o: dpc_attach failed for this device.\n")); 135 DEB_D(("dpc_v4l2.o: dpc_attach failed for this device.\n"));
136 i2c_del_adapter(&dpc->i2c_adapter); 136 i2c_del_adapter(&dpc->i2c_adapter);
137 kfree(dpc); 137 kfree(dpc);
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c
index 58bab653330f..74fd6a01d4c4 100644
--- a/drivers/media/video/mt20xx.c
+++ b/drivers/media/video/mt20xx.c
@@ -647,7 +647,7 @@ struct dvb_frontend *microtune_attach(struct dvb_frontend *fe,
647 default: 647 default:
648 tuner_info("microtune %s found, not (yet?) supported, sorry :-/\n", 648 tuner_info("microtune %s found, not (yet?) supported, sorry :-/\n",
649 name); 649 name);
650 return 0; 650 return NULL;
651 } 651 }
652 652
653 strlcpy(fe->ops.tuner_ops.info.name, name, 653 strlcpy(fe->ops.tuner_ops.info.name, name,
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index add6d0d680be..cb5a510f9251 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -221,9 +221,8 @@ static int mxb_probe(struct saa7146_dev* dev)
221 device_for_each_child(&mxb->i2c_adapter.dev, mxb, mxb_check_clients); 221 device_for_each_child(&mxb->i2c_adapter.dev, mxb, mxb_check_clients);
222 222
223 /* check if all devices are present */ 223 /* check if all devices are present */
224 if( 0 == mxb->tea6420_1 || 0 == mxb->tea6420_2 || 0 == mxb->tea6415c 224 if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c ||
225 || 0 == mxb->tda9840 || 0 == mxb->saa7111a || 0 == mxb->tuner ) { 225 !mxb->tda9840 || !mxb->saa7111a || !mxb->tuner) {
226
227 printk("mxb: did not find all i2c devices. aborting\n"); 226 printk("mxb: did not find all i2c devices. aborting\n");
228 i2c_del_adapter(&mxb->i2c_adapter); 227 i2c_del_adapter(&mxb->i2c_adapter);
229 kfree(mxb); 228 kfree(mxb);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index 46f156fb108c..5a3e8d21a38a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -60,7 +60,7 @@ int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val)
60 int ret = 0; 60 int ret = 0;
61 if (!cptr) return -EINVAL; 61 if (!cptr) return -EINVAL;
62 LOCK_TAKE(cptr->hdw->big_lock); do { 62 LOCK_TAKE(cptr->hdw->big_lock); do {
63 if (cptr->info->set_value != 0) { 63 if (cptr->info->set_value) {
64 if (cptr->info->type == pvr2_ctl_bitmask) { 64 if (cptr->info->type == pvr2_ctl_bitmask) {
65 mask &= cptr->info->def.type_bitmask.valid_bits; 65 mask &= cptr->info->def.type_bitmask.valid_bits;
66 } else if (cptr->info->type == pvr2_ctl_int) { 66 } else if (cptr->info->type == pvr2_ctl_int) {
@@ -265,7 +265,7 @@ unsigned int pvr2_ctrl_get_v4lflags(struct pvr2_ctrl *cptr)
265int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr) 265int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr)
266{ 266{
267 if (!cptr) return 0; 267 if (!cptr) return 0;
268 return cptr->info->set_value != 0; 268 return cptr->info->set_value != NULL;
269} 269}
270 270
271 271
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
index 4df6d6d936fc..fe9991c10cf4 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-devattr.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
@@ -155,6 +155,41 @@ static const struct pvr2_device_desc pvr2_device_onair_usb2 = {
155 155
156 156
157/*------------------------------------------------------------------------*/ 157/*------------------------------------------------------------------------*/
158/* Hauppauge PVR-USB2 Model 73xxx */
159
160static const char *pvr2_client_73xxx[] = {
161 "cx25840",
162 "tuner",
163};
164
165static const char *pvr2_fw1_names_73xxx[] = {
166 "v4l-pvrusb2-73xxx-01.fw",
167};
168
169static const struct pvr2_device_desc pvr2_device_73xxx = {
170 .description = "WinTV PVR USB2 Model Category 73xxxx",
171 .shortname = "73xxx",
172 .client_modules.lst = pvr2_client_73xxx,
173 .client_modules.cnt = ARRAY_SIZE(pvr2_client_73xxx),
174 .fx2_firmware.lst = pvr2_fw1_names_73xxx,
175 .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_73xxx),
176 .flag_has_cx25840 = !0,
177 .flag_has_hauppauge_rom = !0,
178#if 0
179 .flag_has_analogtuner = !0,
180 .flag_has_composite = !0,
181 .flag_has_svideo = !0,
182 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
183 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
184 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
185#else
186 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
187#endif
188};
189
190
191
192/*------------------------------------------------------------------------*/
158/* Hauppauge PVR-USB2 Model 75xxx */ 193/* Hauppauge PVR-USB2 Model 75xxx */
159 194
160static const char *pvr2_client_75xxx[] = { 195static const char *pvr2_client_75xxx[] = {
@@ -198,8 +233,12 @@ struct usb_device_id pvr2_device_table[] = {
198 { USB_DEVICE(0x11ba, 0x1001), 233 { USB_DEVICE(0x11ba, 0x1001),
199 .driver_info = (kernel_ulong_t)&pvr2_device_onair_usb2}, 234 .driver_info = (kernel_ulong_t)&pvr2_device_onair_usb2},
200#endif 235#endif
236 { USB_DEVICE(0x2040, 0x7300),
237 .driver_info = (kernel_ulong_t)&pvr2_device_73xxx},
201 { USB_DEVICE(0x2040, 0x7500), 238 { USB_DEVICE(0x2040, 0x7500),
202 .driver_info = (kernel_ulong_t)&pvr2_device_75xxx}, 239 .driver_info = (kernel_ulong_t)&pvr2_device_75xxx},
240 { USB_DEVICE(0x2040, 0x7501),
241 .driver_info = (kernel_ulong_t)&pvr2_device_75xxx},
203 { } 242 { }
204}; 243};
205 244
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 41ae980405ed..d6955fa39598 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -2291,7 +2291,7 @@ static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw)
2291 2291
2292 for (idx = 0; idx < hdw->control_cnt; idx++) { 2292 for (idx = 0; idx < hdw->control_cnt; idx++) {
2293 cptr = hdw->controls + idx; 2293 cptr = hdw->controls + idx;
2294 if (cptr->info->is_dirty == 0) continue; 2294 if (!cptr->info->is_dirty) continue;
2295 if (!cptr->info->is_dirty(cptr)) continue; 2295 if (!cptr->info->is_dirty(cptr)) continue;
2296 commit_flag = !0; 2296 commit_flag = !0;
2297 2297
@@ -2646,7 +2646,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw,
2646 u16 address; 2646 u16 address;
2647 unsigned int pipe; 2647 unsigned int pipe;
2648 LOCK_TAKE(hdw->big_lock); do { 2648 LOCK_TAKE(hdw->big_lock); do {
2649 if ((hdw->fw_buffer == 0) == !enable_flag) break; 2649 if ((hdw->fw_buffer == NULL) == !enable_flag) break;
2650 2650
2651 if (!enable_flag) { 2651 if (!enable_flag) {
2652 pvr2_trace(PVR2_TRACE_FIRMWARE, 2652 pvr2_trace(PVR2_TRACE_FIRMWARE,
@@ -2715,7 +2715,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw,
2715/* Return true if we're in a mode for retrieval CPU firmware */ 2715/* Return true if we're in a mode for retrieval CPU firmware */
2716int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw) 2716int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw)
2717{ 2717{
2718 return hdw->fw_buffer != 0; 2718 return hdw->fw_buffer != NULL;
2719} 2719}
2720 2720
2721 2721
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
index ce3c8982ffe0..a9889ff96ecc 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -563,7 +563,7 @@ void pvr2_stream_kill(struct pvr2_stream *sp)
563 struct pvr2_buffer *bp; 563 struct pvr2_buffer *bp;
564 mutex_lock(&sp->mutex); do { 564 mutex_lock(&sp->mutex); do {
565 pvr2_stream_internal_flush(sp); 565 pvr2_stream_internal_flush(sp);
566 while ((bp = pvr2_stream_get_ready_buffer(sp)) != 0) { 566 while ((bp = pvr2_stream_get_ready_buffer(sp)) != NULL) {
567 pvr2_buffer_set_idle(bp); 567 pvr2_buffer_set_idle(bp);
568 } 568 }
569 if (sp->buffer_total_count != sp->buffer_target_count) { 569 if (sp->buffer_total_count != sp->buffer_target_count) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.c b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
index f782418afa45..c572212c9f15 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ioread.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
@@ -165,7 +165,7 @@ static int pvr2_ioread_start(struct pvr2_ioread *cp)
165 if (!(cp->stream)) return 0; 165 if (!(cp->stream)) return 0;
166 pvr2_trace(PVR2_TRACE_START_STOP, 166 pvr2_trace(PVR2_TRACE_START_STOP,
167 "/*---TRACE_READ---*/ pvr2_ioread_start id=%p",cp); 167 "/*---TRACE_READ---*/ pvr2_ioread_start id=%p",cp);
168 while ((bp = pvr2_stream_get_idle_buffer(cp->stream)) != 0) { 168 while ((bp = pvr2_stream_get_idle_buffer(cp->stream)) != NULL) {
169 stat = pvr2_buffer_queue(bp); 169 stat = pvr2_buffer_queue(bp);
170 if (stat < 0) { 170 if (stat < 0) {
171 pvr2_trace(PVR2_TRACE_DATA_FLOW, 171 pvr2_trace(PVR2_TRACE_DATA_FLOW,
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index f991d72fe108..e0a453a6543d 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -915,7 +915,7 @@ static void pwc_iso_stop(struct pwc_device *pdev)
915 struct urb *urb; 915 struct urb *urb;
916 916
917 urb = pdev->sbuf[i].urb; 917 urb = pdev->sbuf[i].urb;
918 if (urb != 0) { 918 if (urb) {
919 PWC_DEBUG_MEMORY("Unlinking URB %p\n", urb); 919 PWC_DEBUG_MEMORY("Unlinking URB %p\n", urb);
920 usb_kill_urb(urb); 920 usb_kill_urb(urb);
921 } 921 }
@@ -931,7 +931,7 @@ static void pwc_iso_free(struct pwc_device *pdev)
931 struct urb *urb; 931 struct urb *urb;
932 932
933 urb = pdev->sbuf[i].urb; 933 urb = pdev->sbuf[i].urb;
934 if (urb != 0) { 934 if (urb) {
935 PWC_DEBUG_MEMORY("Freeing URB\n"); 935 PWC_DEBUG_MEMORY("Freeing URB\n");
936 usb_free_urb(urb); 936 usb_free_urb(urb);
937 pdev->sbuf[i].urb = NULL; 937 pdev->sbuf[i].urb = NULL;
@@ -1759,8 +1759,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1759 1759
1760 /* Allocate video_device structure */ 1760 /* Allocate video_device structure */
1761 pdev->vdev = video_device_alloc(); 1761 pdev->vdev = video_device_alloc();
1762 if (pdev->vdev == 0) 1762 if (!pdev->vdev) {
1763 {
1764 PWC_ERROR("Err, cannot allocate video_device struture. Failing probe."); 1763 PWC_ERROR("Err, cannot allocate video_device struture. Failing probe.");
1765 kfree(pdev); 1764 kfree(pdev);
1766 return -ENOMEM; 1765 return -ENOMEM;
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 061134a7ba9f..1df2602cd184 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -488,7 +488,7 @@ saa7110_detect_client (struct i2c_adapter *adapter,
488 return 0; 488 return 0;
489 489
490 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 490 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
491 if (client == 0) 491 if (!client)
492 return -ENOMEM; 492 return -ENOMEM;
493 client->addr = address; 493 client->addr = address;
494 client->adapter = adapter; 494 client->adapter = adapter;
@@ -496,7 +496,7 @@ saa7110_detect_client (struct i2c_adapter *adapter,
496 strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client))); 496 strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client)));
497 497
498 decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); 498 decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL);
499 if (decoder == 0) { 499 if (!decoder) {
500 kfree(client); 500 kfree(client);
501 return -ENOMEM; 501 return -ENOMEM;
502 } 502 }
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index 7ae2d646d000..a0772c53bb1f 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -502,7 +502,7 @@ saa7111_detect_client (struct i2c_adapter *adapter,
502 return 0; 502 return 0;
503 503
504 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 504 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
505 if (client == 0) 505 if (!client)
506 return -ENOMEM; 506 return -ENOMEM;
507 client->addr = address; 507 client->addr = address;
508 client->adapter = adapter; 508 client->adapter = adapter;
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index 677df51de1a9..bf91a4faa706 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -841,7 +841,7 @@ saa7114_detect_client (struct i2c_adapter *adapter,
841 return 0; 841 return 0;
842 842
843 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 843 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
844 if (client == 0) 844 if (!client)
845 return -ENOMEM; 845 return -ENOMEM;
846 client->addr = address; 846 client->addr = address;
847 client->adapter = adapter; 847 client->adapter = adapter;
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 66cc92c0ea66..41f70440fd3b 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -403,7 +403,7 @@ saa7185_detect_client (struct i2c_adapter *adapter,
403 return 0; 403 return 0;
404 404
405 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 405 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
406 if (client == 0) 406 if (!client)
407 return -ENOMEM; 407 return -ENOMEM;
408 client->addr = address; 408 client->addr = address;
409 client->adapter = adapter; 409 client->adapter = adapter;
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index ef494febb5e4..bdca5d278978 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -172,7 +172,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
172 172
173 /* allocate memory for client structure */ 173 /* allocate memory for client structure */
174 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 174 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
175 if (0 == client) { 175 if (!client) {
176 printk("not enough kernel memory\n"); 176 printk("not enough kernel memory\n");
177 return -ENOMEM; 177 return -ENOMEM;
178 } 178 }
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 523df0b8cc63..df2fad9f391e 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -64,7 +64,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
64 64
65 /* allocate memory for client structure */ 65 /* allocate memory for client structure */
66 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 66 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
67 if (0 == client) { 67 if (!client) {
68 return -ENOMEM; 68 return -ENOMEM;
69 } 69 }
70 70
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index ca05cd655087..4ff6c63f7237 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -101,7 +101,7 @@ static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
101 101
102 /* allocate memory for client structure */ 102 /* allocate memory for client structure */
103 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 103 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
104 if (0 == client) { 104 if (!client) {
105 return -ENOMEM; 105 return -ENOMEM;
106 } 106 }
107 107
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index d28318cb2b8d..b6e24e714a23 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -1072,12 +1072,12 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
1072 return 0; 1072 return 0;
1073 1073
1074 c = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 1074 c = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
1075 if (c == 0) 1075 if (!c)
1076 return -ENOMEM; 1076 return -ENOMEM;
1077 memcpy(c, &client_template, sizeof(struct i2c_client)); 1077 memcpy(c, &client_template, sizeof(struct i2c_client));
1078 1078
1079 core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL); 1079 core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL);
1080 if (core == 0) { 1080 if (!core) {
1081 kfree(c); 1081 kfree(c);
1082 return -ENOMEM; 1082 return -ENOMEM;
1083 } 1083 }
diff --git a/drivers/media/video/v4l2-int-device.c b/drivers/media/video/v4l2-int-device.c
index a545dcaf857f..0e4549922f26 100644
--- a/drivers/media/video/v4l2-int-device.c
+++ b/drivers/media/video/v4l2-int-device.c
@@ -156,3 +156,5 @@ int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg)
156 find_ioctl(d->u.slave, cmd, 156 find_ioctl(d->u.slave, cmd,
157 (v4l2_int_ioctl_func *)no_such_ioctl_1))(d, arg); 157 (v4l2_int_ioctl_func *)no_such_ioctl_1))(d, arg);
158} 158}
159
160MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index dd3d7d2c8b0e..fea4946ee713 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -339,7 +339,7 @@ v4l_fbuffer_alloc (struct file *file)
339 /* Use kmalloc */ 339 /* Use kmalloc */
340 340
341 mem = kmalloc(fh->v4l_buffers.buffer_size, GFP_KERNEL); 341 mem = kmalloc(fh->v4l_buffers.buffer_size, GFP_KERNEL);
342 if (mem == 0) { 342 if (!mem) {
343 dprintk(1, 343 dprintk(1,
344 KERN_ERR 344 KERN_ERR
345 "%s: v4l_fbuffer_alloc() - kmalloc for V4L buf %d failed\n", 345 "%s: v4l_fbuffer_alloc() - kmalloc for V4L buf %d failed\n",
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 1b44784d0efb..04949c823654 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -390,7 +390,7 @@ static int read_frame(struct zr364xx_camera *cam, int framenum)
390} 390}
391 391
392 392
393static ssize_t zr364xx_read(struct file *file, char *buf, size_t cnt, 393static ssize_t zr364xx_read(struct file *file, char __user *buf, size_t cnt,
394 loff_t * ppos) 394 loff_t * ppos)
395{ 395{
396 unsigned long count = cnt; 396 unsigned long count = cnt;
diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
index eb150dfb637f..8577de4ebb0e 100644
--- a/drivers/memstick/host/tifm_ms.c
+++ b/drivers/memstick/host/tifm_ms.c
@@ -182,7 +182,7 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
182 struct tifm_dev *sock = host->dev; 182 struct tifm_dev *sock = host->dev;
183 unsigned int length; 183 unsigned int length;
184 unsigned int off; 184 unsigned int off;
185 unsigned int t_size, p_off, p_cnt; 185 unsigned int t_size, p_cnt;
186 unsigned char *buf; 186 unsigned char *buf;
187 struct page *pg; 187 struct page *pg;
188 unsigned long flags = 0; 188 unsigned long flags = 0;
@@ -198,6 +198,8 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
198 host->block_pos); 198 host->block_pos);
199 199
200 while (length) { 200 while (length) {
201 unsigned int uninitialized_var(p_off);
202
201 if (host->req->long_data) { 203 if (host->req->long_data) {
202 pg = nth_page(sg_page(&host->req->sg), 204 pg = nth_page(sg_page(&host->req->sg),
203 off >> PAGE_SHIFT); 205 off >> PAGE_SHIFT);
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 63fb1ff3ad10..f6f2d960cadb 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -28,14 +28,14 @@
28static inline void asic3_write_register(struct asic3 *asic, 28static inline void asic3_write_register(struct asic3 *asic,
29 unsigned int reg, u32 value) 29 unsigned int reg, u32 value)
30{ 30{
31 iowrite16(value, (unsigned long)asic->mapping + 31 iowrite16(value, asic->mapping +
32 (reg >> asic->bus_shift)); 32 (reg >> asic->bus_shift));
33} 33}
34 34
35static inline u32 asic3_read_register(struct asic3 *asic, 35static inline u32 asic3_read_register(struct asic3 *asic,
36 unsigned int reg) 36 unsigned int reg)
37{ 37{
38 return ioread16((unsigned long)asic->mapping + 38 return ioread16(asic->mapping +
39 (reg >> asic->bus_shift)); 39 (reg >> asic->bus_shift));
40} 40}
41 41
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c
index 1cfd7f3f1294..e2e7c05a147b 100644
--- a/drivers/misc/fujitsu-laptop.c
+++ b/drivers/misc/fujitsu-laptop.c
@@ -231,7 +231,7 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type)
231 231
232 if (!device || !acpi_driver_data(device)) 232 if (!device || !acpi_driver_data(device))
233 return -EINVAL; 233 return -EINVAL;
234 fujitsu->acpi_handle = 0; 234 fujitsu->acpi_handle = NULL;
235 235
236 return 0; 236 return 0;
237} 237}
diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index 4f9d4a9da983..b5f6add34b0b 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -106,7 +106,7 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi
106 sp->irq = pdev->irq; 106 sp->irq = pdev->irq;
107 sp->base_address = ioremap(pci_resource_start(pdev, 0), 107 sp->base_address = ioremap(pci_resource_start(pdev, 0),
108 pci_resource_len(pdev, 0)); 108 pci_resource_len(pdev, 0));
109 if (sp->base_address == 0) { 109 if (!sp->base_address) {
110 dev_err(sp->dev, "Failed to ioremap pci memory\n"); 110 dev_err(sp->dev, "Failed to ioremap pci memory\n");
111 result = -ENODEV; 111 result = -ENODEV;
112 goto error_ioremap; 112 goto error_ioremap;
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index c884730c5eaf..1bfe5d16963b 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -197,7 +197,7 @@ static int lkdtm_parse_commandline(void)
197{ 197{
198 int i; 198 int i;
199 199
200 if (cpoint_name == INVALID || cpoint_type == NONE || 200 if (cpoint_name == NULL || cpoint_type == NULL ||
201 cpoint_count < 1 || recur_count < 1) 201 cpoint_count < 1 || recur_count < 1)
202 return -EINVAL; 202 return -EINVAL;
203 203
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 47794d23a42e..0080452531d6 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -718,7 +718,7 @@ static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long
718 /* Someone else might have been playing with it. */ 718 /* Someone else might have been playing with it. */
719 return -EAGAIN; 719 return -EAGAIN;
720 } 720 }
721 721 /* Fall through */
722 case FL_READY: 722 case FL_READY:
723 case FL_CFI_QUERY: 723 case FL_CFI_QUERY:
724 case FL_JEDEC_QUERY: 724 case FL_JEDEC_QUERY:
@@ -778,14 +778,14 @@ static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long
778 chip->state = FL_READY; 778 chip->state = FL_READY;
779 return 0; 779 return 0;
780 780
781 case FL_SHUTDOWN:
782 /* The machine is rebooting now,so no one can get chip anymore */
783 return -EIO;
781 case FL_POINT: 784 case FL_POINT:
782 /* Only if there's no operation suspended... */ 785 /* Only if there's no operation suspended... */
783 if (mode == FL_READY && chip->oldstate == FL_READY) 786 if (mode == FL_READY && chip->oldstate == FL_READY)
784 return 0; 787 return 0;
785 788 /* Fall through */
786 case FL_SHUTDOWN:
787 /* The machine is rebooting now,so no one can get chip anymore */
788 return -EIO;
789 default: 789 default:
790 sleep: 790 sleep:
791 set_current_state(TASK_UNINTERRUPTIBLE); 791 set_current_state(TASK_UNINTERRUPTIBLE);
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index d072e87ce4e2..458d477614d6 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -1763,6 +1763,7 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1763 1763
1764 default: 1764 default:
1765 /* Not an idle state */ 1765 /* Not an idle state */
1766 set_current_state(TASK_UNINTERRUPTIBLE);
1766 add_wait_queue(&chip->wq, &wait); 1767 add_wait_queue(&chip->wq, &wait);
1767 1768
1768 spin_unlock(chip->mutex); 1769 spin_unlock(chip->mutex);
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index b344ff858b2d..492e2ab27420 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -1015,6 +1015,7 @@ static void cfi_staa_sync (struct mtd_info *mtd)
1015 1015
1016 default: 1016 default:
1017 /* Not an idle state */ 1017 /* Not an idle state */
1018 set_current_state(TASK_UNINTERRUPTIBLE);
1018 add_wait_queue(&chip->wq, &wait); 1019 add_wait_queue(&chip->wq, &wait);
1019 1020
1020 spin_unlock_bh(chip->mutex); 1021 spin_unlock_bh(chip->mutex);
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index f00e04efbe28..bc4649a17b9d 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -202,9 +202,8 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
202 int ret = 0; 202 int ret = 0;
203 int i; 203 int i;
204 204
205 if (info) 205 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
206 for (i = 0; i < MAX_RESOURCES; i++) 206 ret |= info->mtd[i]->suspend(info->mtd[i]);
207 ret |= info->mtd[i]->suspend(info->mtd[i]);
208 207
209 return ret; 208 return ret;
210} 209}
@@ -214,9 +213,9 @@ static int physmap_flash_resume(struct platform_device *dev)
214 struct physmap_flash_info *info = platform_get_drvdata(dev); 213 struct physmap_flash_info *info = platform_get_drvdata(dev);
215 int i; 214 int i;
216 215
217 if (info) 216 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
218 for (i = 0; i < MAX_RESOURCES; i++) 217 info->mtd[i]->resume(info->mtd[i]);
219 info->mtd[i]->resume(info->mtd[i]); 218
220 return 0; 219 return 0;
221} 220}
222 221
@@ -225,8 +224,8 @@ static void physmap_flash_shutdown(struct platform_device *dev)
225 struct physmap_flash_info *info = platform_get_drvdata(dev); 224 struct physmap_flash_info *info = platform_get_drvdata(dev);
226 int i; 225 int i;
227 226
228 for (i = 0; i < MAX_RESOURCES; i++) 227 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
229 if (info && info->mtd[i]->suspend(info->mtd[i]) == 0) 228 if (info->mtd[i]->suspend(info->mtd[i]) == 0)
230 info->mtd[i]->resume(info->mtd[i]); 229 info->mtd[i]->resume(info->mtd[i]);
231} 230}
232#else 231#else
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
index 9189ec8f243e..0f6ac250f434 100644
--- a/drivers/mtd/nand/rtc_from4.c
+++ b/drivers/mtd/nand/rtc_from4.c
@@ -460,7 +460,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this,
460 er_stat |= 1 << 1; 460 er_stat |= 1 << 1;
461 kfree(buf); 461 kfree(buf);
462 } 462 }
463 463out:
464 rtn = status; 464 rtn = status;
465 if (er_stat == 0) { /* if ECC is available */ 465 if (er_stat == 0) { /* if ECC is available */
466 rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */ 466 rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 124d29f5fa0c..0b44daa36f91 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2635,7 +2635,7 @@ config NIU
2635 2635
2636config PASEMI_MAC 2636config PASEMI_MAC
2637 tristate "PA Semi 1/10Gbit MAC" 2637 tristate "PA Semi 1/10Gbit MAC"
2638 depends on PPC64 && PCI 2638 depends on PPC_PASEMI && PCI
2639 select PHYLIB 2639 select PHYLIB
2640 select INET_LRO 2640 select INET_LRO
2641 help 2641 help
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index ea2a2b548e3c..25f1337cd02c 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -2082,6 +2082,11 @@ static int __devinit b44_get_invariants(struct b44 *bp)
2082 addr = sdev->bus->sprom.et0mac; 2082 addr = sdev->bus->sprom.et0mac;
2083 bp->phy_addr = sdev->bus->sprom.et0phyaddr; 2083 bp->phy_addr = sdev->bus->sprom.et0phyaddr;
2084 } 2084 }
2085 /* Some ROMs have buggy PHY addresses with the high
2086 * bits set (sign extension?). Truncate them to a
2087 * valid PHY address. */
2088 bp->phy_addr &= 0x1F;
2089
2085 memcpy(bp->dev->dev_addr, addr, 6); 2090 memcpy(bp->dev->dev_addr, addr, 6);
2086 2091
2087 if (!is_valid_ether_addr(&bp->dev->dev_addr[0])){ 2092 if (!is_valid_ether_addr(&bp->dev->dev_addr[0])){
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index c993a32b3f50..26b2dd5016cd 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -575,7 +575,6 @@ adjust_head:
575static int bf537mac_hard_start_xmit(struct sk_buff *skb, 575static int bf537mac_hard_start_xmit(struct sk_buff *skb,
576 struct net_device *dev) 576 struct net_device *dev)
577{ 577{
578 struct bf537mac_local *lp = netdev_priv(dev);
579 unsigned int data; 578 unsigned int data;
580 579
581 current_tx_ptr->skb = skb; 580 current_tx_ptr->skb = skb;
@@ -634,7 +633,6 @@ out:
634static void bf537mac_rx(struct net_device *dev) 633static void bf537mac_rx(struct net_device *dev)
635{ 634{
636 struct sk_buff *skb, *new_skb; 635 struct sk_buff *skb, *new_skb;
637 struct bf537mac_local *lp = netdev_priv(dev);
638 unsigned short len; 636 unsigned short len;
639 637
640 /* allocate a new skb for next time receive */ 638 /* allocate a new skb for next time receive */
diff --git a/drivers/net/bnx2x.c b/drivers/net/bnx2x.c
index de32b3fba322..7bdb5af35951 100644
--- a/drivers/net/bnx2x.c
+++ b/drivers/net/bnx2x.c
@@ -63,8 +63,8 @@
63#include "bnx2x.h" 63#include "bnx2x.h"
64#include "bnx2x_init.h" 64#include "bnx2x_init.h"
65 65
66#define DRV_MODULE_VERSION "1.42.3" 66#define DRV_MODULE_VERSION "1.42.4"
67#define DRV_MODULE_RELDATE "2008/3/9" 67#define DRV_MODULE_RELDATE "2008/4/9"
68#define BNX2X_BC_VER 0x040200 68#define BNX2X_BC_VER 0x040200
69 69
70/* Time in jiffies before concluding the transmitter is hung. */ 70/* Time in jiffies before concluding the transmitter is hung. */
@@ -6153,7 +6153,7 @@ static int bnx2x_function_init(struct bnx2x *bp, int mode)
6153 func, mode); 6153 func, mode);
6154 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 6154 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET,
6155 0xffffffff); 6155 0xffffffff);
6156 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 6156 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET,
6157 0xfffc); 6157 0xfffc);
6158 bnx2x_init_block(bp, MISC_COMMON_START, MISC_COMMON_END); 6158 bnx2x_init_block(bp, MISC_COMMON_START, MISC_COMMON_END);
6159 6159
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index cb3c6faa7888..d16e0e1d2b30 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -310,7 +310,7 @@ static inline int __check_agg_selection_timer(struct port *port)
310 */ 310 */
311static inline void __get_rx_machine_lock(struct port *port) 311static inline void __get_rx_machine_lock(struct port *port)
312{ 312{
313 spin_lock(&(SLAVE_AD_INFO(port->slave).rx_machine_lock)); 313 spin_lock_bh(&(SLAVE_AD_INFO(port->slave).rx_machine_lock));
314} 314}
315 315
316/** 316/**
@@ -320,7 +320,7 @@ static inline void __get_rx_machine_lock(struct port *port)
320 */ 320 */
321static inline void __release_rx_machine_lock(struct port *port) 321static inline void __release_rx_machine_lock(struct port *port)
322{ 322{
323 spin_unlock(&(SLAVE_AD_INFO(port->slave).rx_machine_lock)); 323 spin_unlock_bh(&(SLAVE_AD_INFO(port->slave).rx_machine_lock));
324} 324}
325 325
326/** 326/**
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index b57bc9467dbe..3f58c3d0b710 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -678,12 +678,8 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon
678 } 678 }
679 679
680 if (!list_empty(&bond->vlan_list)) { 680 if (!list_empty(&bond->vlan_list)) {
681 unsigned short vlan_id; 681 if (!vlan_get_tag(skb, &client_info->vlan_id))
682 int res = vlan_get_tag(skb, &vlan_id);
683 if (!res) {
684 client_info->tag = 1; 682 client_info->tag = 1;
685 client_info->vlan_id = vlan_id;
686 }
687 } 683 }
688 684
689 if (!client_info->assigned) { 685 if (!client_info->assigned) {
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 0942d82f7cbf..0f0675319e9c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -383,7 +383,7 @@ struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr)
383 */ 383 */
384int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev) 384int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev)
385{ 385{
386 unsigned short vlan_id; 386 unsigned short uninitialized_var(vlan_id);
387 387
388 if (!list_empty(&bond->vlan_list) && 388 if (!list_empty(&bond->vlan_list) &&
389 !(slave_dev->features & NETIF_F_HW_VLAN_TX) && 389 !(slave_dev->features & NETIF_F_HW_VLAN_TX) &&
@@ -4528,8 +4528,7 @@ static void bond_free_all(void)
4528 netif_tx_unlock_bh(bond_dev); 4528 netif_tx_unlock_bh(bond_dev);
4529 /* Release the bonded slaves */ 4529 /* Release the bonded slaves */
4530 bond_release_all(bond_dev); 4530 bond_release_all(bond_dev);
4531 bond_deinit(bond_dev); 4531 bond_destroy(bond);
4532 unregister_netdevice(bond_dev);
4533 } 4532 }
4534 4533
4535#ifdef CONFIG_PROC_FS 4534#ifdef CONFIG_PROC_FS
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 90a1f31e8e63..979c2d05ff9c 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -341,6 +341,7 @@ static ssize_t bonding_store_slaves(struct device *d,
341 341
342 if (command[0] == '-') { 342 if (command[0] == '-') {
343 dev = NULL; 343 dev = NULL;
344 original_mtu = 0;
344 bond_for_each_slave(bond, slave, i) 345 bond_for_each_slave(bond, slave, i)
345 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { 346 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
346 dev = slave->dev; 347 dev = slave->dev;
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 67ccad69d445..a3c74e20aa53 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -22,8 +22,8 @@
22#include "bond_3ad.h" 22#include "bond_3ad.h"
23#include "bond_alb.h" 23#include "bond_alb.h"
24 24
25#define DRV_VERSION "3.2.4" 25#define DRV_VERSION "3.2.5"
26#define DRV_RELDATE "January 28, 2008" 26#define DRV_RELDATE "March 21, 2008"
27#define DRV_NAME "bonding" 27#define DRV_NAME "bonding"
28#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" 28#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
29 29
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index db586870c5f4..98a6bbd11d4c 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -557,9 +557,9 @@ static void t3_free_qset(struct adapter *adapter, struct sge_qset *q)
557 557
558 for (i = 0; i < SGE_RXQ_PER_SET; ++i) 558 for (i = 0; i < SGE_RXQ_PER_SET; ++i)
559 if (q->fl[i].desc) { 559 if (q->fl[i].desc) {
560 spin_lock(&adapter->sge.reg_lock); 560 spin_lock_irq(&adapter->sge.reg_lock);
561 t3_sge_disable_fl(adapter, q->fl[i].cntxt_id); 561 t3_sge_disable_fl(adapter, q->fl[i].cntxt_id);
562 spin_unlock(&adapter->sge.reg_lock); 562 spin_unlock_irq(&adapter->sge.reg_lock);
563 free_rx_bufs(pdev, &q->fl[i]); 563 free_rx_bufs(pdev, &q->fl[i]);
564 kfree(q->fl[i].sdesc); 564 kfree(q->fl[i].sdesc);
565 dma_free_coherent(&pdev->dev, 565 dma_free_coherent(&pdev->dev,
@@ -570,9 +570,9 @@ static void t3_free_qset(struct adapter *adapter, struct sge_qset *q)
570 570
571 for (i = 0; i < SGE_TXQ_PER_SET; ++i) 571 for (i = 0; i < SGE_TXQ_PER_SET; ++i)
572 if (q->txq[i].desc) { 572 if (q->txq[i].desc) {
573 spin_lock(&adapter->sge.reg_lock); 573 spin_lock_irq(&adapter->sge.reg_lock);
574 t3_sge_enable_ecntxt(adapter, q->txq[i].cntxt_id, 0); 574 t3_sge_enable_ecntxt(adapter, q->txq[i].cntxt_id, 0);
575 spin_unlock(&adapter->sge.reg_lock); 575 spin_unlock_irq(&adapter->sge.reg_lock);
576 if (q->txq[i].sdesc) { 576 if (q->txq[i].sdesc) {
577 free_tx_desc(adapter, &q->txq[i], 577 free_tx_desc(adapter, &q->txq[i],
578 q->txq[i].in_use); 578 q->txq[i].in_use);
@@ -586,9 +586,9 @@ static void t3_free_qset(struct adapter *adapter, struct sge_qset *q)
586 } 586 }
587 587
588 if (q->rspq.desc) { 588 if (q->rspq.desc) {
589 spin_lock(&adapter->sge.reg_lock); 589 spin_lock_irq(&adapter->sge.reg_lock);
590 t3_sge_disable_rspcntxt(adapter, q->rspq.cntxt_id); 590 t3_sge_disable_rspcntxt(adapter, q->rspq.cntxt_id);
591 spin_unlock(&adapter->sge.reg_lock); 591 spin_unlock_irq(&adapter->sge.reg_lock);
592 dma_free_coherent(&pdev->dev, 592 dma_free_coherent(&pdev->dev,
593 q->rspq.size * sizeof(struct rsp_desc), 593 q->rspq.size * sizeof(struct rsp_desc),
594 q->rspq.desc, q->rspq.phys_addr); 594 q->rspq.desc, q->rspq.phys_addr);
@@ -2667,7 +2667,7 @@ int t3_sge_alloc_qset(struct adapter *adapter, unsigned int id, int nports,
2667 (16 * 1024) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) : 2667 (16 * 1024) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) :
2668 MAX_FRAME_SIZE + 2 + sizeof(struct cpl_rx_pkt); 2668 MAX_FRAME_SIZE + 2 + sizeof(struct cpl_rx_pkt);
2669 2669
2670 spin_lock(&adapter->sge.reg_lock); 2670 spin_lock_irq(&adapter->sge.reg_lock);
2671 2671
2672 /* FL threshold comparison uses < */ 2672 /* FL threshold comparison uses < */
2673 ret = t3_sge_init_rspcntxt(adapter, q->rspq.cntxt_id, irq_vec_idx, 2673 ret = t3_sge_init_rspcntxt(adapter, q->rspq.cntxt_id, irq_vec_idx,
@@ -2711,7 +2711,7 @@ int t3_sge_alloc_qset(struct adapter *adapter, unsigned int id, int nports,
2711 goto err_unlock; 2711 goto err_unlock;
2712 } 2712 }
2713 2713
2714 spin_unlock(&adapter->sge.reg_lock); 2714 spin_unlock_irq(&adapter->sge.reg_lock);
2715 2715
2716 q->adap = adapter; 2716 q->adap = adapter;
2717 q->netdev = dev; 2717 q->netdev = dev;
@@ -2728,7 +2728,7 @@ int t3_sge_alloc_qset(struct adapter *adapter, unsigned int id, int nports,
2728 return 0; 2728 return 0;
2729 2729
2730 err_unlock: 2730 err_unlock:
2731 spin_unlock(&adapter->sge.reg_lock); 2731 spin_unlock_irq(&adapter->sge.reg_lock);
2732 err: 2732 err:
2733 t3_free_qset(adapter, q); 2733 t3_free_qset(adapter, q);
2734 return ret; 2734 return ret;
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 1fe305ca2cf0..d63cc93f055d 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -798,8 +798,6 @@ dm9000_init_dm9000(struct net_device *dev)
798 /* Set address filter table */ 798 /* Set address filter table */
799 dm9000_hash_table(dev); 799 dm9000_hash_table(dev);
800 800
801 /* Activate DM9000 */
802 iow(db, DM9000_RCR, RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN);
803 /* Enable TX/RX interrupt mask */ 801 /* Enable TX/RX interrupt mask */
804 iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM); 802 iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
805 803
@@ -970,7 +968,7 @@ dm9000_interrupt(int irq, void *dev_id)
970struct dm9000_rxhdr { 968struct dm9000_rxhdr {
971 u8 RxPktReady; 969 u8 RxPktReady;
972 u8 RxStatus; 970 u8 RxStatus;
973 u16 RxLen; 971 __le16 RxLen;
974} __attribute__((__packed__)); 972} __attribute__((__packed__));
975 973
976/* 974/*
@@ -1197,6 +1195,7 @@ dm9000_hash_table(struct net_device *dev)
1197 int i, oft; 1195 int i, oft;
1198 u32 hash_val; 1196 u32 hash_val;
1199 u16 hash_table[4]; 1197 u16 hash_table[4];
1198 u8 rcr = RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN;
1200 unsigned long flags; 1199 unsigned long flags;
1201 1200
1202 dm9000_dbg(db, 1, "entering %s\n", __func__); 1201 dm9000_dbg(db, 1, "entering %s\n", __func__);
@@ -1213,6 +1212,12 @@ dm9000_hash_table(struct net_device *dev)
1213 /* broadcast address */ 1212 /* broadcast address */
1214 hash_table[3] = 0x8000; 1213 hash_table[3] = 0x8000;
1215 1214
1215 if (dev->flags & IFF_PROMISC)
1216 rcr |= RCR_PRMSC;
1217
1218 if (dev->flags & IFF_ALLMULTI)
1219 rcr |= RCR_ALL;
1220
1216 /* the multicast address in Hash Table : 64 bits */ 1221 /* the multicast address in Hash Table : 64 bits */
1217 for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) { 1222 for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
1218 hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f; 1223 hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
@@ -1225,6 +1230,7 @@ dm9000_hash_table(struct net_device *dev)
1225 iow(db, oft++, hash_table[i] >> 8); 1230 iow(db, oft++, hash_table[i] >> 8);
1226 } 1231 }
1227 1232
1233 iow(db, DM9000_RCR, rcr);
1228 spin_unlock_irqrestore(&db->lock, flags); 1234 spin_unlock_irqrestore(&db->lock, flags);
1229} 1235}
1230 1236
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index cdf3090a1885..2d139ec79777 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -960,7 +960,7 @@ static void e100_get_defaults(struct nic *nic)
960 960
961 /* Template for a freshly allocated RFD */ 961 /* Template for a freshly allocated RFD */
962 nic->blank_rfd.command = 0; 962 nic->blank_rfd.command = 0;
963 nic->blank_rfd.rbd = 0xFFFFFFFF; 963 nic->blank_rfd.rbd = cpu_to_le32(0xFFFFFFFF);
964 nic->blank_rfd.size = cpu_to_le16(VLAN_ETH_FRAME_LEN); 964 nic->blank_rfd.size = cpu_to_le16(VLAN_ETH_FRAME_LEN);
965 965
966 /* MII setup */ 966 /* MII setup */
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 7c4ead35cfa2..93b7fb246960 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -40,7 +40,7 @@
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42#define DRV_NAME "ehea" 42#define DRV_NAME "ehea"
43#define DRV_VERSION "EHEA_0087" 43#define DRV_VERSION "EHEA_0089"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 21af674b764e..07c742dd3f09 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -3108,7 +3108,7 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
3108 dev->vlan_rx_add_vid = ehea_vlan_rx_add_vid; 3108 dev->vlan_rx_add_vid = ehea_vlan_rx_add_vid;
3109 dev->vlan_rx_kill_vid = ehea_vlan_rx_kill_vid; 3109 dev->vlan_rx_kill_vid = ehea_vlan_rx_kill_vid;
3110 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO 3110 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO
3111 | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_TX 3111 | NETIF_F_HIGHDMA | NETIF_F_IP_CSUM | NETIF_F_HW_VLAN_TX
3112 | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER 3112 | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER
3113 | NETIF_F_LLTX; 3113 | NETIF_F_LLTX;
3114 dev->tx_timeout = &ehea_tx_watchdog; 3114 dev->tx_timeout = &ehea_tx_watchdog;
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 58b71e60204e..fe59c27c09e3 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -1057,6 +1057,7 @@ static int mpc52xx_fec_of_resume(struct of_device *op)
1057#endif 1057#endif
1058 1058
1059static struct of_device_id mpc52xx_fec_match[] = { 1059static struct of_device_id mpc52xx_fec_match[] = {
1060 { .type = "network", .compatible = "fsl,mpc5200b-fec", },
1060 { .type = "network", .compatible = "fsl,mpc5200-fec", }, 1061 { .type = "network", .compatible = "fsl,mpc5200-fec", },
1061 { .type = "network", .compatible = "mpc5200-fec", }, 1062 { .type = "network", .compatible = "mpc5200-fec", },
1062 { } 1063 { }
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c
index 6a3ac4ea97e9..1d0cd1dd955e 100644
--- a/drivers/net/fec_mpc52xx_phy.c
+++ b/drivers/net/fec_mpc52xx_phy.c
@@ -179,6 +179,7 @@ static int mpc52xx_fec_mdio_remove(struct of_device *of)
179 179
180static struct of_device_id mpc52xx_fec_mdio_match[] = { 180static struct of_device_id mpc52xx_fec_mdio_match[] = {
181 { .compatible = "fsl,mpc5200b-mdio", }, 181 { .compatible = "fsl,mpc5200b-mdio", },
182 { .compatible = "fsl,mpc5200-mdio", },
182 { .compatible = "mpc5200b-fec-phy", }, 183 { .compatible = "mpc5200b-fec-phy", },
183 {} 184 {}
184}; 185};
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 6f7e3fde9e7c..419f533006ab 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -1854,6 +1854,7 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1854 struct ring_desc* start_tx; 1854 struct ring_desc* start_tx;
1855 struct ring_desc* prev_tx; 1855 struct ring_desc* prev_tx;
1856 struct nv_skb_map* prev_tx_ctx; 1856 struct nv_skb_map* prev_tx_ctx;
1857 unsigned long flags;
1857 1858
1858 /* add fragments to entries count */ 1859 /* add fragments to entries count */
1859 for (i = 0; i < fragments; i++) { 1860 for (i = 0; i < fragments; i++) {
@@ -1863,10 +1864,10 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1863 1864
1864 empty_slots = nv_get_empty_tx_slots(np); 1865 empty_slots = nv_get_empty_tx_slots(np);
1865 if (unlikely(empty_slots <= entries)) { 1866 if (unlikely(empty_slots <= entries)) {
1866 spin_lock_irq(&np->lock); 1867 spin_lock_irqsave(&np->lock, flags);
1867 netif_stop_queue(dev); 1868 netif_stop_queue(dev);
1868 np->tx_stop = 1; 1869 np->tx_stop = 1;
1869 spin_unlock_irq(&np->lock); 1870 spin_unlock_irqrestore(&np->lock, flags);
1870 return NETDEV_TX_BUSY; 1871 return NETDEV_TX_BUSY;
1871 } 1872 }
1872 1873
@@ -1929,13 +1930,13 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1929 tx_flags_extra = skb->ip_summed == CHECKSUM_PARTIAL ? 1930 tx_flags_extra = skb->ip_summed == CHECKSUM_PARTIAL ?
1930 NV_TX2_CHECKSUM_L3 | NV_TX2_CHECKSUM_L4 : 0; 1931 NV_TX2_CHECKSUM_L3 | NV_TX2_CHECKSUM_L4 : 0;
1931 1932
1932 spin_lock_irq(&np->lock); 1933 spin_lock_irqsave(&np->lock, flags);
1933 1934
1934 /* set tx flags */ 1935 /* set tx flags */
1935 start_tx->flaglen |= cpu_to_le32(tx_flags | tx_flags_extra); 1936 start_tx->flaglen |= cpu_to_le32(tx_flags | tx_flags_extra);
1936 np->put_tx.orig = put_tx; 1937 np->put_tx.orig = put_tx;
1937 1938
1938 spin_unlock_irq(&np->lock); 1939 spin_unlock_irqrestore(&np->lock, flags);
1939 1940
1940 dprintk(KERN_DEBUG "%s: nv_start_xmit: entries %d queued for transmission. tx_flags_extra: %x\n", 1941 dprintk(KERN_DEBUG "%s: nv_start_xmit: entries %d queued for transmission. tx_flags_extra: %x\n",
1941 dev->name, entries, tx_flags_extra); 1942 dev->name, entries, tx_flags_extra);
@@ -1971,6 +1972,7 @@ static int nv_start_xmit_optimized(struct sk_buff *skb, struct net_device *dev)
1971 struct ring_desc_ex* prev_tx; 1972 struct ring_desc_ex* prev_tx;
1972 struct nv_skb_map* prev_tx_ctx; 1973 struct nv_skb_map* prev_tx_ctx;
1973 struct nv_skb_map* start_tx_ctx; 1974 struct nv_skb_map* start_tx_ctx;
1975 unsigned long flags;
1974 1976
1975 /* add fragments to entries count */ 1977 /* add fragments to entries count */
1976 for (i = 0; i < fragments; i++) { 1978 for (i = 0; i < fragments; i++) {
@@ -1980,10 +1982,10 @@ static int nv_start_xmit_optimized(struct sk_buff *skb, struct net_device *dev)
1980 1982
1981 empty_slots = nv_get_empty_tx_slots(np); 1983 empty_slots = nv_get_empty_tx_slots(np);
1982 if (unlikely(empty_slots <= entries)) { 1984 if (unlikely(empty_slots <= entries)) {
1983 spin_lock_irq(&np->lock); 1985 spin_lock_irqsave(&np->lock, flags);
1984 netif_stop_queue(dev); 1986 netif_stop_queue(dev);
1985 np->tx_stop = 1; 1987 np->tx_stop = 1;
1986 spin_unlock_irq(&np->lock); 1988 spin_unlock_irqrestore(&np->lock, flags);
1987 return NETDEV_TX_BUSY; 1989 return NETDEV_TX_BUSY;
1988 } 1990 }
1989 1991
@@ -2059,7 +2061,7 @@ static int nv_start_xmit_optimized(struct sk_buff *skb, struct net_device *dev)
2059 start_tx->txvlan = 0; 2061 start_tx->txvlan = 0;
2060 } 2062 }
2061 2063
2062 spin_lock_irq(&np->lock); 2064 spin_lock_irqsave(&np->lock, flags);
2063 2065
2064 if (np->tx_limit) { 2066 if (np->tx_limit) {
2065 /* Limit the number of outstanding tx. Setup all fragments, but 2067 /* Limit the number of outstanding tx. Setup all fragments, but
@@ -2085,7 +2087,7 @@ static int nv_start_xmit_optimized(struct sk_buff *skb, struct net_device *dev)
2085 start_tx->flaglen |= cpu_to_le32(tx_flags | tx_flags_extra); 2087 start_tx->flaglen |= cpu_to_le32(tx_flags | tx_flags_extra);
2086 np->put_tx.ex = put_tx; 2088 np->put_tx.ex = put_tx;
2087 2089
2088 spin_unlock_irq(&np->lock); 2090 spin_unlock_irqrestore(&np->lock, flags);
2089 2091
2090 dprintk(KERN_DEBUG "%s: nv_start_xmit_optimized: entries %d queued for transmission. tx_flags_extra: %x\n", 2092 dprintk(KERN_DEBUG "%s: nv_start_xmit_optimized: entries %d queued for transmission. tx_flags_extra: %x\n",
2091 dev->name, entries, tx_flags_extra); 2093 dev->name, entries, tx_flags_extra);
@@ -2110,9 +2112,8 @@ static inline void nv_tx_flip_ownership(struct net_device *dev)
2110 2112
2111 np->tx_pkts_in_progress--; 2113 np->tx_pkts_in_progress--;
2112 if (np->tx_change_owner) { 2114 if (np->tx_change_owner) {
2113 __le32 flaglen = le32_to_cpu(np->tx_change_owner->first_tx_desc->flaglen); 2115 np->tx_change_owner->first_tx_desc->flaglen |=
2114 flaglen |= NV_TX2_VALID; 2116 cpu_to_le32(NV_TX2_VALID);
2115 np->tx_change_owner->first_tx_desc->flaglen = cpu_to_le32(flaglen);
2116 np->tx_pkts_in_progress++; 2117 np->tx_pkts_in_progress++;
2117 2118
2118 np->tx_change_owner = np->tx_change_owner->next_tx_ctx; 2119 np->tx_change_owner = np->tx_change_owner->next_tx_ctx;
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index 0789802d59ed..378a23963495 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -1242,8 +1242,8 @@ static int emac_close(struct net_device *ndev)
1242static inline u16 emac_tx_csum(struct emac_instance *dev, 1242static inline u16 emac_tx_csum(struct emac_instance *dev,
1243 struct sk_buff *skb) 1243 struct sk_buff *skb)
1244{ 1244{
1245 if (emac_has_feature(dev, EMAC_FTR_HAS_TAH && 1245 if (emac_has_feature(dev, EMAC_FTR_HAS_TAH) &&
1246 skb->ip_summed == CHECKSUM_PARTIAL)) { 1246 (skb->ip_summed == CHECKSUM_PARTIAL)) {
1247 ++dev->stats.tx_packets_csum; 1247 ++dev->stats.tx_packets_csum;
1248 return EMAC_TX_CTRL_TAH_CSUM; 1248 return EMAC_TX_CTRL_TAH_CSUM;
1249 } 1249 }
diff --git a/drivers/net/igb/e1000_82575.h b/drivers/net/igb/e1000_82575.h
index 6604d96bd567..76ea846663db 100644
--- a/drivers/net/igb/e1000_82575.h
+++ b/drivers/net/igb/e1000_82575.h
@@ -61,28 +61,28 @@
61/* Receive Descriptor - Advanced */ 61/* Receive Descriptor - Advanced */
62union e1000_adv_rx_desc { 62union e1000_adv_rx_desc {
63 struct { 63 struct {
64 u64 pkt_addr; /* Packet buffer address */ 64 __le64 pkt_addr; /* Packet buffer address */
65 u64 hdr_addr; /* Header buffer address */ 65 __le64 hdr_addr; /* Header buffer address */
66 } read; 66 } read;
67 struct { 67 struct {
68 struct { 68 struct {
69 struct { 69 struct {
70 u16 pkt_info; /* RSS type, Packet type */ 70 __le16 pkt_info; /* RSS type, Packet type */
71 u16 hdr_info; /* Split Header, 71 __le16 hdr_info; /* Split Header,
72 * header buffer length */ 72 * header buffer length */
73 } lo_dword; 73 } lo_dword;
74 union { 74 union {
75 u32 rss; /* RSS Hash */ 75 __le32 rss; /* RSS Hash */
76 struct { 76 struct {
77 u16 ip_id; /* IP id */ 77 __le16 ip_id; /* IP id */
78 u16 csum; /* Packet Checksum */ 78 __le16 csum; /* Packet Checksum */
79 } csum_ip; 79 } csum_ip;
80 } hi_dword; 80 } hi_dword;
81 } lower; 81 } lower;
82 struct { 82 struct {
83 u32 status_error; /* ext status/error */ 83 __le32 status_error; /* ext status/error */
84 u16 length; /* Packet length */ 84 __le16 length; /* Packet length */
85 u16 vlan; /* VLAN tag */ 85 __le16 vlan; /* VLAN tag */
86 } upper; 86 } upper;
87 } wb; /* writeback */ 87 } wb; /* writeback */
88}; 88};
@@ -97,14 +97,14 @@ union e1000_adv_rx_desc {
97/* Transmit Descriptor - Advanced */ 97/* Transmit Descriptor - Advanced */
98union e1000_adv_tx_desc { 98union e1000_adv_tx_desc {
99 struct { 99 struct {
100 u64 buffer_addr; /* Address of descriptor's data buf */ 100 __le64 buffer_addr; /* Address of descriptor's data buf */
101 u32 cmd_type_len; 101 __le32 cmd_type_len;
102 u32 olinfo_status; 102 __le32 olinfo_status;
103 } read; 103 } read;
104 struct { 104 struct {
105 u64 rsvd; /* Reserved */ 105 __le64 rsvd; /* Reserved */
106 u32 nxtseq_seed; 106 __le32 nxtseq_seed;
107 u32 status; 107 __le32 status;
108 } wb; 108 } wb;
109}; 109};
110 110
@@ -119,10 +119,10 @@ union e1000_adv_tx_desc {
119 119
120/* Context descriptors */ 120/* Context descriptors */
121struct e1000_adv_tx_context_desc { 121struct e1000_adv_tx_context_desc {
122 u32 vlan_macip_lens; 122 __le32 vlan_macip_lens;
123 u32 seqnum_seed; 123 __le32 seqnum_seed;
124 u32 type_tucmd_mlhl; 124 __le32 type_tucmd_mlhl;
125 u32 mss_l4len_idx; 125 __le32 mss_l4len_idx;
126}; 126};
127 127
128#define E1000_ADVTXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */ 128#define E1000_ADVTXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 161fb68764af..7b2c70a3b8cc 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -143,35 +143,35 @@ enum e1000_fc_type {
143 143
144/* Receive Descriptor */ 144/* Receive Descriptor */
145struct e1000_rx_desc { 145struct e1000_rx_desc {
146 u64 buffer_addr; /* Address of the descriptor's data buffer */ 146 __le64 buffer_addr; /* Address of the descriptor's data buffer */
147 u16 length; /* Length of data DMAed into data buffer */ 147 __le16 length; /* Length of data DMAed into data buffer */
148 u16 csum; /* Packet checksum */ 148 __le16 csum; /* Packet checksum */
149 u8 status; /* Descriptor status */ 149 u8 status; /* Descriptor status */
150 u8 errors; /* Descriptor Errors */ 150 u8 errors; /* Descriptor Errors */
151 u16 special; 151 __le16 special;
152}; 152};
153 153
154/* Receive Descriptor - Extended */ 154/* Receive Descriptor - Extended */
155union e1000_rx_desc_extended { 155union e1000_rx_desc_extended {
156 struct { 156 struct {
157 u64 buffer_addr; 157 __le64 buffer_addr;
158 u64 reserved; 158 __le64 reserved;
159 } read; 159 } read;
160 struct { 160 struct {
161 struct { 161 struct {
162 u32 mrq; /* Multiple Rx Queues */ 162 __le32 mrq; /* Multiple Rx Queues */
163 union { 163 union {
164 u32 rss; /* RSS Hash */ 164 __le32 rss; /* RSS Hash */
165 struct { 165 struct {
166 u16 ip_id; /* IP id */ 166 __le16 ip_id; /* IP id */
167 u16 csum; /* Packet Checksum */ 167 __le16 csum; /* Packet Checksum */
168 } csum_ip; 168 } csum_ip;
169 } hi_dword; 169 } hi_dword;
170 } lower; 170 } lower;
171 struct { 171 struct {
172 u32 status_error; /* ext status/error */ 172 __le32 status_error; /* ext status/error */
173 u16 length; 173 __le16 length;
174 u16 vlan; /* VLAN tag */ 174 __le16 vlan; /* VLAN tag */
175 } upper; 175 } upper;
176 } wb; /* writeback */ 176 } wb; /* writeback */
177}; 177};
@@ -181,49 +181,49 @@ union e1000_rx_desc_extended {
181union e1000_rx_desc_packet_split { 181union e1000_rx_desc_packet_split {
182 struct { 182 struct {
183 /* one buffer for protocol header(s), three data buffers */ 183 /* one buffer for protocol header(s), three data buffers */
184 u64 buffer_addr[MAX_PS_BUFFERS]; 184 __le64 buffer_addr[MAX_PS_BUFFERS];
185 } read; 185 } read;
186 struct { 186 struct {
187 struct { 187 struct {
188 u32 mrq; /* Multiple Rx Queues */ 188 __le32 mrq; /* Multiple Rx Queues */
189 union { 189 union {
190 u32 rss; /* RSS Hash */ 190 __le32 rss; /* RSS Hash */
191 struct { 191 struct {
192 u16 ip_id; /* IP id */ 192 __le16 ip_id; /* IP id */
193 u16 csum; /* Packet Checksum */ 193 __le16 csum; /* Packet Checksum */
194 } csum_ip; 194 } csum_ip;
195 } hi_dword; 195 } hi_dword;
196 } lower; 196 } lower;
197 struct { 197 struct {
198 u32 status_error; /* ext status/error */ 198 __le32 status_error; /* ext status/error */
199 u16 length0; /* length of buffer 0 */ 199 __le16 length0; /* length of buffer 0 */
200 u16 vlan; /* VLAN tag */ 200 __le16 vlan; /* VLAN tag */
201 } middle; 201 } middle;
202 struct { 202 struct {
203 u16 header_status; 203 __le16 header_status;
204 u16 length[3]; /* length of buffers 1-3 */ 204 __le16 length[3]; /* length of buffers 1-3 */
205 } upper; 205 } upper;
206 u64 reserved; 206 __le64 reserved;
207 } wb; /* writeback */ 207 } wb; /* writeback */
208}; 208};
209 209
210/* Transmit Descriptor */ 210/* Transmit Descriptor */
211struct e1000_tx_desc { 211struct e1000_tx_desc {
212 u64 buffer_addr; /* Address of the descriptor's data buffer */ 212 __le64 buffer_addr; /* Address of the descriptor's data buffer */
213 union { 213 union {
214 u32 data; 214 __le32 data;
215 struct { 215 struct {
216 u16 length; /* Data buffer length */ 216 __le16 length; /* Data buffer length */
217 u8 cso; /* Checksum offset */ 217 u8 cso; /* Checksum offset */
218 u8 cmd; /* Descriptor control */ 218 u8 cmd; /* Descriptor control */
219 } flags; 219 } flags;
220 } lower; 220 } lower;
221 union { 221 union {
222 u32 data; 222 __le32 data;
223 struct { 223 struct {
224 u8 status; /* Descriptor status */ 224 u8 status; /* Descriptor status */
225 u8 css; /* Checksum start */ 225 u8 css; /* Checksum start */
226 u16 special; 226 __le16 special;
227 } fields; 227 } fields;
228 } upper; 228 } upper;
229}; 229};
@@ -231,49 +231,49 @@ struct e1000_tx_desc {
231/* Offload Context Descriptor */ 231/* Offload Context Descriptor */
232struct e1000_context_desc { 232struct e1000_context_desc {
233 union { 233 union {
234 u32 ip_config; 234 __le32 ip_config;
235 struct { 235 struct {
236 u8 ipcss; /* IP checksum start */ 236 u8 ipcss; /* IP checksum start */
237 u8 ipcso; /* IP checksum offset */ 237 u8 ipcso; /* IP checksum offset */
238 u16 ipcse; /* IP checksum end */ 238 __le16 ipcse; /* IP checksum end */
239 } ip_fields; 239 } ip_fields;
240 } lower_setup; 240 } lower_setup;
241 union { 241 union {
242 u32 tcp_config; 242 __le32 tcp_config;
243 struct { 243 struct {
244 u8 tucss; /* TCP checksum start */ 244 u8 tucss; /* TCP checksum start */
245 u8 tucso; /* TCP checksum offset */ 245 u8 tucso; /* TCP checksum offset */
246 u16 tucse; /* TCP checksum end */ 246 __le16 tucse; /* TCP checksum end */
247 } tcp_fields; 247 } tcp_fields;
248 } upper_setup; 248 } upper_setup;
249 u32 cmd_and_length; 249 __le32 cmd_and_length;
250 union { 250 union {
251 u32 data; 251 __le32 data;
252 struct { 252 struct {
253 u8 status; /* Descriptor status */ 253 u8 status; /* Descriptor status */
254 u8 hdr_len; /* Header length */ 254 u8 hdr_len; /* Header length */
255 u16 mss; /* Maximum segment size */ 255 __le16 mss; /* Maximum segment size */
256 } fields; 256 } fields;
257 } tcp_seg_setup; 257 } tcp_seg_setup;
258}; 258};
259 259
260/* Offload data descriptor */ 260/* Offload data descriptor */
261struct e1000_data_desc { 261struct e1000_data_desc {
262 u64 buffer_addr; /* Address of the descriptor's buffer address */ 262 __le64 buffer_addr; /* Address of the descriptor's buffer address */
263 union { 263 union {
264 u32 data; 264 __le32 data;
265 struct { 265 struct {
266 u16 length; /* Data buffer length */ 266 __le16 length; /* Data buffer length */
267 u8 typ_len_ext; 267 u8 typ_len_ext;
268 u8 cmd; 268 u8 cmd;
269 } flags; 269 } flags;
270 } lower; 270 } lower;
271 union { 271 union {
272 u32 data; 272 __le32 data;
273 struct { 273 struct {
274 u8 status; /* Descriptor status */ 274 u8 status; /* Descriptor status */
275 u8 popts; /* Packet Options */ 275 u8 popts; /* Packet Options */
276 u16 special; 276 __le16 special;
277 } fields; 277 } fields;
278 } upper; 278 } upper;
279}; 279};
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 928ce8287e69..aaee02e9e3f0 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -3254,6 +3254,13 @@ quit_polling:
3254 3254
3255 return 1; 3255 return 1;
3256} 3256}
3257
3258static inline u32 get_head(struct igb_ring *tx_ring)
3259{
3260 void *end = (struct e1000_tx_desc *)tx_ring->desc + tx_ring->count;
3261 return le32_to_cpu(*(volatile __le32 *)end);
3262}
3263
3257/** 3264/**
3258 * igb_clean_tx_irq - Reclaim resources after transmit completes 3265 * igb_clean_tx_irq - Reclaim resources after transmit completes
3259 * @adapter: board private structure 3266 * @adapter: board private structure
@@ -3275,9 +3282,7 @@ static bool igb_clean_tx_irq(struct igb_adapter *adapter,
3275 unsigned int total_bytes = 0, total_packets = 0; 3282 unsigned int total_bytes = 0, total_packets = 0;
3276 3283
3277 rmb(); 3284 rmb();
3278 head = *(volatile u32 *)((struct e1000_tx_desc *)tx_ring->desc 3285 head = get_head(tx_ring);
3279 + tx_ring->count);
3280 head = le32_to_cpu(head);
3281 i = tx_ring->next_to_clean; 3286 i = tx_ring->next_to_clean;
3282 while (1) { 3287 while (1) {
3283 while (i != head) { 3288 while (i != head) {
@@ -3312,9 +3317,7 @@ static bool igb_clean_tx_irq(struct igb_adapter *adapter,
3312 } 3317 }
3313 oldhead = head; 3318 oldhead = head;
3314 rmb(); 3319 rmb();
3315 head = *(volatile u32 *)((struct e1000_tx_desc *)tx_ring->desc 3320 head = get_head(tx_ring);
3316 + tx_ring->count);
3317 head = le32_to_cpu(head);
3318 if (head == oldhead) 3321 if (head == oldhead)
3319 goto done_cleaning; 3322 goto done_cleaning;
3320 } /* while (1) */ 3323 } /* while (1) */
@@ -3388,7 +3391,7 @@ done_cleaning:
3388 * @vlan: descriptor vlan field as written by hardware (no le/be conversion) 3391 * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
3389 * @skb: pointer to sk_buff to be indicated to stack 3392 * @skb: pointer to sk_buff to be indicated to stack
3390 **/ 3393 **/
3391static void igb_receive_skb(struct igb_adapter *adapter, u8 status, u16 vlan, 3394static void igb_receive_skb(struct igb_adapter *adapter, u8 status, __le16 vlan,
3392 struct sk_buff *skb) 3395 struct sk_buff *skb)
3393{ 3396{
3394 if (adapter->vlgrp && (status & E1000_RXD_STAT_VP)) 3397 if (adapter->vlgrp && (status & E1000_RXD_STAT_VP))
@@ -3452,8 +3455,8 @@ static bool igb_clean_rx_irq_adv(struct igb_adapter *adapter,
3452 * that case, it fills the header buffer and spills the rest 3455 * that case, it fills the header buffer and spills the rest
3453 * into the page. 3456 * into the page.
3454 */ 3457 */
3455 hlen = le16_to_cpu((rx_desc->wb.lower.lo_dword.hdr_info & 3458 hlen = (le16_to_cpu(rx_desc->wb.lower.lo_dword.hdr_info) &
3456 E1000_RXDADV_HDRBUFLEN_MASK) >> E1000_RXDADV_HDRBUFLEN_SHIFT); 3459 E1000_RXDADV_HDRBUFLEN_MASK) >> E1000_RXDADV_HDRBUFLEN_SHIFT;
3457 if (hlen > adapter->rx_ps_hdr_size) 3460 if (hlen > adapter->rx_ps_hdr_size)
3458 hlen = adapter->rx_ps_hdr_size; 3461 hlen = adapter->rx_ps_hdr_size;
3459 3462
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 269e6f805f47..6738b4d097fe 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -2088,14 +2088,12 @@ ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
2088 struct ixgb_buffer *buffer_info; 2088 struct ixgb_buffer *buffer_info;
2089 struct sk_buff *skb; 2089 struct sk_buff *skb;
2090 unsigned int i; 2090 unsigned int i;
2091 int num_group_tail_writes;
2092 long cleancount; 2091 long cleancount;
2093 2092
2094 i = rx_ring->next_to_use; 2093 i = rx_ring->next_to_use;
2095 buffer_info = &rx_ring->buffer_info[i]; 2094 buffer_info = &rx_ring->buffer_info[i];
2096 cleancount = IXGB_DESC_UNUSED(rx_ring); 2095 cleancount = IXGB_DESC_UNUSED(rx_ring);
2097 2096
2098 num_group_tail_writes = IXGB_RX_BUFFER_WRITE;
2099 2097
2100 /* leave three descriptors unused */ 2098 /* leave three descriptors unused */
2101 while(--cleancount > 2) { 2099 while(--cleancount > 2) {
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 2bc5eaae141f..7f20a03623a0 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -85,7 +85,7 @@
85 (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) 85 (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
86#define RCV_BUFFSIZE \ 86#define RCV_BUFFSIZE \
87 (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) 87 (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
88#define find_diff_among(a,b,range) ((a)<=(b)?((b)-(a)):((b)+(range)-(a))) 88#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
89 89
90#define NETXEN_NETDEV_STATUS 0x1 90#define NETXEN_NETDEV_STATUS 0x1
91#define NETXEN_RCV_PRODUCER_OFFSET 0 91#define NETXEN_RCV_PRODUCER_OFFSET 0
@@ -204,7 +204,7 @@ enum {
204 ? RCV_DESC_LRO : \ 204 ? RCV_DESC_LRO : \
205 (RCV_DESC_NORMAL))) 205 (RCV_DESC_NORMAL)))
206 206
207#define MAX_CMD_DESCRIPTORS 1024 207#define MAX_CMD_DESCRIPTORS 4096
208#define MAX_RCV_DESCRIPTORS 16384 208#define MAX_RCV_DESCRIPTORS 16384
209#define MAX_CMD_DESCRIPTORS_HOST (MAX_CMD_DESCRIPTORS / 4) 209#define MAX_CMD_DESCRIPTORS_HOST (MAX_CMD_DESCRIPTORS / 4)
210#define MAX_RCV_DESCRIPTORS_1G (MAX_RCV_DESCRIPTORS / 4) 210#define MAX_RCV_DESCRIPTORS_1G (MAX_RCV_DESCRIPTORS / 4)
@@ -818,15 +818,8 @@ struct netxen_adapter_stats {
818 u64 badskblen; 818 u64 badskblen;
819 u64 nocmddescriptor; 819 u64 nocmddescriptor;
820 u64 polled; 820 u64 polled;
821 u64 uphappy; 821 u64 rxdropped;
822 u64 updropped;
823 u64 uplcong;
824 u64 uphcong;
825 u64 upmcong;
826 u64 updunno;
827 u64 skbfreed;
828 u64 txdropped; 822 u64 txdropped;
829 u64 txnullskb;
830 u64 csummed; 823 u64 csummed;
831 u64 no_rcv; 824 u64 no_rcv;
832 u64 rxbytes; 825 u64 rxbytes;
@@ -842,7 +835,6 @@ struct netxen_rcv_desc_ctx {
842 u32 flags; 835 u32 flags;
843 u32 producer; 836 u32 producer;
844 u32 rcv_pending; /* Num of bufs posted in phantom */ 837 u32 rcv_pending; /* Num of bufs posted in phantom */
845 u32 rcv_free; /* Num of bufs in free list */
846 dma_addr_t phys_addr; 838 dma_addr_t phys_addr;
847 struct pci_dev *phys_pdev; 839 struct pci_dev *phys_pdev;
848 struct rcv_desc *desc_head; /* address of rx ring in Phantom */ 840 struct rcv_desc *desc_head; /* address of rx ring in Phantom */
@@ -889,8 +881,6 @@ struct netxen_adapter {
889 int mtu; 881 int mtu;
890 int portnum; 882 int portnum;
891 883
892 spinlock_t tx_lock;
893 spinlock_t lock;
894 struct work_struct watchdog_task; 884 struct work_struct watchdog_task;
895 struct timer_list watchdog_timer; 885 struct timer_list watchdog_timer;
896 struct work_struct tx_timeout_task; 886 struct work_struct tx_timeout_task;
@@ -899,16 +889,12 @@ struct netxen_adapter {
899 889
900 u32 cmd_producer; 890 u32 cmd_producer;
901 __le32 *cmd_consumer; 891 __le32 *cmd_consumer;
902
903 u32 last_cmd_consumer; 892 u32 last_cmd_consumer;
893
904 u32 max_tx_desc_count; 894 u32 max_tx_desc_count;
905 u32 max_rx_desc_count; 895 u32 max_rx_desc_count;
906 u32 max_jumbo_rx_desc_count; 896 u32 max_jumbo_rx_desc_count;
907 u32 max_lro_rx_desc_count; 897 u32 max_lro_rx_desc_count;
908 /* Num of instances active on cmd buffer ring */
909 u32 proc_cmd_buf_counter;
910
911 u32 num_threads, total_threads; /*Use to keep track of xmit threads */
912 898
913 u32 flags; 899 u32 flags;
914 u32 irq; 900 u32 irq;
@@ -942,6 +928,7 @@ struct netxen_adapter {
942 struct pci_dev *ctx_desc_pdev; 928 struct pci_dev *ctx_desc_pdev;
943 dma_addr_t ctx_desc_phys_addr; 929 dma_addr_t ctx_desc_phys_addr;
944 int intr_scheme; 930 int intr_scheme;
931 int msi_mode;
945 int (*enable_phy_interrupts) (struct netxen_adapter *); 932 int (*enable_phy_interrupts) (struct netxen_adapter *);
946 int (*disable_phy_interrupts) (struct netxen_adapter *); 933 int (*disable_phy_interrupts) (struct netxen_adapter *);
947 void (*handle_phy_intr) (struct netxen_adapter *); 934 void (*handle_phy_intr) (struct netxen_adapter *);
@@ -1075,12 +1062,10 @@ void netxen_tso_check(struct netxen_adapter *adapter,
1075 struct cmd_desc_type0 *desc, struct sk_buff *skb); 1062 struct cmd_desc_type0 *desc, struct sk_buff *skb);
1076int netxen_nic_hw_resources(struct netxen_adapter *adapter); 1063int netxen_nic_hw_resources(struct netxen_adapter *adapter);
1077void netxen_nic_clear_stats(struct netxen_adapter *adapter); 1064void netxen_nic_clear_stats(struct netxen_adapter *adapter);
1078int netxen_nic_rx_has_work(struct netxen_adapter *adapter);
1079int netxen_nic_tx_has_work(struct netxen_adapter *adapter);
1080void netxen_watchdog_task(struct work_struct *work); 1065void netxen_watchdog_task(struct work_struct *work);
1081void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, 1066void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
1082 u32 ringid); 1067 u32 ringid);
1083int netxen_process_cmd_ring(unsigned long data); 1068int netxen_process_cmd_ring(struct netxen_adapter *adapter);
1084u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); 1069u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
1085void netxen_nic_set_multi(struct net_device *netdev); 1070void netxen_nic_set_multi(struct net_device *netdev);
1086int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); 1071int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index 7a876f4b8db2..6e98d830eefb 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -64,15 +64,7 @@ static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = {
64 {"bad_skb_len", NETXEN_NIC_STAT(stats.badskblen)}, 64 {"bad_skb_len", NETXEN_NIC_STAT(stats.badskblen)},
65 {"no_cmd_desc", NETXEN_NIC_STAT(stats.nocmddescriptor)}, 65 {"no_cmd_desc", NETXEN_NIC_STAT(stats.nocmddescriptor)},
66 {"polled", NETXEN_NIC_STAT(stats.polled)}, 66 {"polled", NETXEN_NIC_STAT(stats.polled)},
67 {"uphappy", NETXEN_NIC_STAT(stats.uphappy)},
68 {"updropped", NETXEN_NIC_STAT(stats.updropped)},
69 {"uplcong", NETXEN_NIC_STAT(stats.uplcong)},
70 {"uphcong", NETXEN_NIC_STAT(stats.uphcong)},
71 {"upmcong", NETXEN_NIC_STAT(stats.upmcong)},
72 {"updunno", NETXEN_NIC_STAT(stats.updunno)},
73 {"skb_freed", NETXEN_NIC_STAT(stats.skbfreed)},
74 {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)}, 67 {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)},
75 {"tx_null_skb", NETXEN_NIC_STAT(stats.txnullskb)},
76 {"csummed", NETXEN_NIC_STAT(stats.csummed)}, 68 {"csummed", NETXEN_NIC_STAT(stats.csummed)},
77 {"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)}, 69 {"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)},
78 {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)}, 70 {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)},
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index d72f8f8fcb50..160f605e58db 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -456,6 +456,12 @@ enum {
456#define ISR_INT_MASK_SLOW (NETXEN_PCIX_PS_REG(PCIX_INT_MASK)) 456#define ISR_INT_MASK_SLOW (NETXEN_PCIX_PS_REG(PCIX_INT_MASK))
457#define ISR_INT_TARGET_STATUS (NETXEN_PCIX_PS_REG(PCIX_TARGET_STATUS)) 457#define ISR_INT_TARGET_STATUS (NETXEN_PCIX_PS_REG(PCIX_TARGET_STATUS))
458#define ISR_INT_TARGET_MASK (NETXEN_PCIX_PS_REG(PCIX_TARGET_MASK)) 458#define ISR_INT_TARGET_MASK (NETXEN_PCIX_PS_REG(PCIX_TARGET_MASK))
459#define ISR_INT_TARGET_STATUS_F1 (NETXEN_PCIX_PS_REG(PCIX_TARGET_STATUS_F1))
460#define ISR_INT_TARGET_MASK_F1 (NETXEN_PCIX_PS_REG(PCIX_TARGET_MASK_F1))
461#define ISR_INT_TARGET_STATUS_F2 (NETXEN_PCIX_PS_REG(PCIX_TARGET_STATUS_F2))
462#define ISR_INT_TARGET_MASK_F2 (NETXEN_PCIX_PS_REG(PCIX_TARGET_MASK_F2))
463#define ISR_INT_TARGET_STATUS_F3 (NETXEN_PCIX_PS_REG(PCIX_TARGET_STATUS_F3))
464#define ISR_INT_TARGET_MASK_F3 (NETXEN_PCIX_PS_REG(PCIX_TARGET_MASK_F3))
459 465
460#define NETXEN_PCI_MAPSIZE 128 466#define NETXEN_PCI_MAPSIZE 128
461#define NETXEN_PCI_DDR_NET (0x00000000UL) 467#define NETXEN_PCI_DDR_NET (0x00000000UL)
@@ -662,6 +668,12 @@ enum {
662 668
663#define PCIX_TARGET_STATUS (0x10118) 669#define PCIX_TARGET_STATUS (0x10118)
664#define PCIX_TARGET_MASK (0x10128) 670#define PCIX_TARGET_MASK (0x10128)
671#define PCIX_TARGET_STATUS_F1 (0x10160)
672#define PCIX_TARGET_MASK_F1 (0x10170)
673#define PCIX_TARGET_STATUS_F2 (0x10164)
674#define PCIX_TARGET_MASK_F2 (0x10174)
675#define PCIX_TARGET_STATUS_F3 (0x10168)
676#define PCIX_TARGET_MASK_F3 (0x10178)
665 677
666#define PCIX_MSI_F0 (0x13000) 678#define PCIX_MSI_F0 (0x13000)
667#define PCIX_MSI_F1 (0x13004) 679#define PCIX_MSI_F1 (0x13004)
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 01355701bf8e..05748ca6f216 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -398,6 +398,8 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
398 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_CAPABILITIES_FW)); 398 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_CAPABILITIES_FW));
399 printk(KERN_NOTICE "%s: FW capabilities:0x%x\n", netxen_nic_driver_name, 399 printk(KERN_NOTICE "%s: FW capabilities:0x%x\n", netxen_nic_driver_name,
400 adapter->intr_scheme); 400 adapter->intr_scheme);
401 adapter->msi_mode = readl(
402 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_MSI_MODE_FW));
401 DPRINTK(INFO, "Receive Peg ready too. starting stuff\n"); 403 DPRINTK(INFO, "Receive Peg ready too. starting stuff\n");
402 404
403 addr = netxen_alloc(adapter->ahw.pdev, 405 addr = netxen_alloc(adapter->ahw.pdev,
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 9e38bcb3fba9..45fa33e0cb90 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -145,6 +145,8 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
145 /* Window 1 call */ 145 /* Window 1 call */
146 writel(INTR_SCHEME_PERPORT, 146 writel(INTR_SCHEME_PERPORT,
147 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_CAPABILITIES_HOST)); 147 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_CAPABILITIES_HOST));
148 writel(MSI_MODE_MULTIFUNC,
149 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_MSI_MODE_HOST));
148 writel(MPORT_MULTI_FUNCTION_MODE, 150 writel(MPORT_MULTI_FUNCTION_MODE,
149 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE)); 151 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE));
150 writel(PHAN_INITIALIZE_ACK, 152 writel(PHAN_INITIALIZE_ACK,
@@ -183,7 +185,6 @@ void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
183 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 185 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
184 struct netxen_rx_buffer *rx_buf; 186 struct netxen_rx_buffer *rx_buf;
185 rcv_desc = &adapter->recv_ctx[ctxid].rcv_desc[ring]; 187 rcv_desc = &adapter->recv_ctx[ctxid].rcv_desc[ring];
186 rcv_desc->rcv_free = rcv_desc->max_rx_desc_count;
187 rcv_desc->begin_alloc = 0; 188 rcv_desc->begin_alloc = 0;
188 rx_buf = rcv_desc->rx_buf_arr; 189 rx_buf = rcv_desc->rx_buf_arr;
189 num_rx_bufs = rcv_desc->max_rx_desc_count; 190 num_rx_bufs = rcv_desc->max_rx_desc_count;
@@ -974,28 +975,6 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
974 return 0; 975 return 0;
975} 976}
976 977
977int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
978{
979 int ctx;
980
981 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
982 struct netxen_recv_context *recv_ctx =
983 &(adapter->recv_ctx[ctx]);
984 u32 consumer;
985 struct status_desc *desc_head;
986 struct status_desc *desc;
987
988 consumer = recv_ctx->status_rx_consumer;
989 desc_head = recv_ctx->rcv_status_desc_head;
990 desc = &desc_head[consumer];
991
992 if (netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)
993 return 1;
994 }
995
996 return 0;
997}
998
999static int netxen_nic_check_temp(struct netxen_adapter *adapter) 978static int netxen_nic_check_temp(struct netxen_adapter *adapter)
1000{ 979{
1001 struct net_device *netdev = adapter->netdev; 980 struct net_device *netdev = adapter->netdev;
@@ -1038,7 +1017,6 @@ static int netxen_nic_check_temp(struct netxen_adapter *adapter)
1038 1017
1039void netxen_watchdog_task(struct work_struct *work) 1018void netxen_watchdog_task(struct work_struct *work)
1040{ 1019{
1041 struct net_device *netdev;
1042 struct netxen_adapter *adapter = 1020 struct netxen_adapter *adapter =
1043 container_of(work, struct netxen_adapter, watchdog_task); 1021 container_of(work, struct netxen_adapter, watchdog_task);
1044 1022
@@ -1048,20 +1026,6 @@ void netxen_watchdog_task(struct work_struct *work)
1048 if (adapter->handle_phy_intr) 1026 if (adapter->handle_phy_intr)
1049 adapter->handle_phy_intr(adapter); 1027 adapter->handle_phy_intr(adapter);
1050 1028
1051 netdev = adapter->netdev;
1052 if ((netif_running(netdev)) && !netif_carrier_ok(netdev) &&
1053 netxen_nic_link_ok(adapter) ) {
1054 printk(KERN_INFO "%s %s (port %d), Link is up\n",
1055 netxen_nic_driver_name, netdev->name, adapter->portnum);
1056 netif_carrier_on(netdev);
1057 netif_wake_queue(netdev);
1058 } else if(!(netif_running(netdev)) && netif_carrier_ok(netdev)) {
1059 printk(KERN_ERR "%s %s Link is Down\n",
1060 netxen_nic_driver_name, netdev->name);
1061 netif_carrier_off(netdev);
1062 netif_stop_queue(netdev);
1063 }
1064
1065 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 1029 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
1066} 1030}
1067 1031
@@ -1125,7 +1089,7 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1125 skb = (struct sk_buff *)buffer->skb; 1089 skb = (struct sk_buff *)buffer->skb;
1126 1090
1127 if (likely(adapter->rx_csum && 1091 if (likely(adapter->rx_csum &&
1128 netxen_get_sts_status(sts_data) == STATUS_CKSUM_OK)) { 1092 netxen_get_sts_status(sts_data) == STATUS_CKSUM_OK)) {
1129 adapter->stats.csummed++; 1093 adapter->stats.csummed++;
1130 skb->ip_summed = CHECKSUM_UNNECESSARY; 1094 skb->ip_summed = CHECKSUM_UNNECESSARY;
1131 } else 1095 } else
@@ -1142,40 +1106,8 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1142 skb->protocol = eth_type_trans(skb, netdev); 1106 skb->protocol = eth_type_trans(skb, netdev);
1143 1107
1144 ret = netif_receive_skb(skb); 1108 ret = netif_receive_skb(skb);
1145
1146 /*
1147 * RH: Do we need these stats on a regular basis. Can we get it from
1148 * Linux stats.
1149 */
1150 switch (ret) {
1151 case NET_RX_SUCCESS:
1152 adapter->stats.uphappy++;
1153 break;
1154
1155 case NET_RX_CN_LOW:
1156 adapter->stats.uplcong++;
1157 break;
1158
1159 case NET_RX_CN_MOD:
1160 adapter->stats.upmcong++;
1161 break;
1162
1163 case NET_RX_CN_HIGH:
1164 adapter->stats.uphcong++;
1165 break;
1166
1167 case NET_RX_DROP:
1168 adapter->stats.updropped++;
1169 break;
1170
1171 default:
1172 adapter->stats.updunno++;
1173 break;
1174 }
1175
1176 netdev->last_rx = jiffies; 1109 netdev->last_rx = jiffies;
1177 1110
1178 rcv_desc->rcv_free++;
1179 rcv_desc->rcv_pending--; 1111 rcv_desc->rcv_pending--;
1180 1112
1181 /* 1113 /*
@@ -1200,13 +1132,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1200 u32 producer = 0; 1132 u32 producer = 0;
1201 int count = 0, ring; 1133 int count = 0, ring;
1202 1134
1203 DPRINTK(INFO, "procesing receive\n");
1204 /*
1205 * we assume in this case that there is only one port and that is
1206 * port #1...changes need to be done in firmware to indicate port
1207 * number as part of the descriptor. This way we will be able to get
1208 * the netdev which is associated with that device.
1209 */
1210 while (count < max) { 1135 while (count < max) {
1211 desc = &desc_head[consumer]; 1136 desc = &desc_head[consumer];
1212 if (!(netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)) { 1137 if (!(netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)) {
@@ -1219,11 +1144,8 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1219 consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1); 1144 consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1);
1220 count++; 1145 count++;
1221 } 1146 }
1222 if (count) { 1147 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
1223 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 1148 netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
1224 netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
1225 }
1226 }
1227 1149
1228 /* update the consumer index in phantom */ 1150 /* update the consumer index in phantom */
1229 if (count) { 1151 if (count) {
@@ -1233,108 +1155,60 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1233 /* Window = 1 */ 1155 /* Window = 1 */
1234 writel(consumer, 1156 writel(consumer,
1235 NETXEN_CRB_NORMALIZE(adapter, 1157 NETXEN_CRB_NORMALIZE(adapter,
1236 recv_crb_registers[adapter->portnum]. 1158 recv_crb_registers[adapter->portnum].
1237 crb_rcv_status_consumer)); 1159 crb_rcv_status_consumer));
1238 wmb();
1239 } 1160 }
1240 1161
1241 return count; 1162 return count;
1242} 1163}
1243 1164
1244/* Process Command status ring */ 1165/* Process Command status ring */
1245int netxen_process_cmd_ring(unsigned long data) 1166int netxen_process_cmd_ring(struct netxen_adapter *adapter)
1246{ 1167{
1247 u32 last_consumer; 1168 u32 last_consumer, consumer;
1248 u32 consumer; 1169 int count = 0, i;
1249 struct netxen_adapter *adapter = (struct netxen_adapter *)data;
1250 int count1 = 0;
1251 int count2 = 0;
1252 struct netxen_cmd_buffer *buffer; 1170 struct netxen_cmd_buffer *buffer;
1253 struct pci_dev *pdev; 1171 struct pci_dev *pdev = adapter->pdev;
1172 struct net_device *netdev = adapter->netdev;
1254 struct netxen_skb_frag *frag; 1173 struct netxen_skb_frag *frag;
1255 u32 i; 1174 int done = 0;
1256 int done;
1257 1175
1258 spin_lock(&adapter->tx_lock);
1259 last_consumer = adapter->last_cmd_consumer; 1176 last_consumer = adapter->last_cmd_consumer;
1260 DPRINTK(INFO, "procesing xmit complete\n");
1261 /* we assume in this case that there is only one port and that is
1262 * port #1...changes need to be done in firmware to indicate port
1263 * number as part of the descriptor. This way we will be able to get
1264 * the netdev which is associated with that device.
1265 */
1266
1267 consumer = le32_to_cpu(*(adapter->cmd_consumer)); 1177 consumer = le32_to_cpu(*(adapter->cmd_consumer));
1268 if (last_consumer == consumer) { /* Ring is empty */
1269 DPRINTK(INFO, "last_consumer %d == consumer %d\n",
1270 last_consumer, consumer);
1271 spin_unlock(&adapter->tx_lock);
1272 return 1;
1273 }
1274
1275 adapter->proc_cmd_buf_counter++;
1276 /*
1277 * Not needed - does not seem to be used anywhere.
1278 * adapter->cmd_consumer = consumer;
1279 */
1280 spin_unlock(&adapter->tx_lock);
1281 1178
1282 while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) { 1179 while (last_consumer != consumer) {
1283 buffer = &adapter->cmd_buf_arr[last_consumer]; 1180 buffer = &adapter->cmd_buf_arr[last_consumer];
1284 pdev = adapter->pdev;
1285 if (buffer->skb) { 1181 if (buffer->skb) {
1286 frag = &buffer->frag_array[0]; 1182 frag = &buffer->frag_array[0];
1287 pci_unmap_single(pdev, frag->dma, frag->length, 1183 pci_unmap_single(pdev, frag->dma, frag->length,
1288 PCI_DMA_TODEVICE); 1184 PCI_DMA_TODEVICE);
1289 frag->dma = 0ULL; 1185 frag->dma = 0ULL;
1290 for (i = 1; i < buffer->frag_count; i++) { 1186 for (i = 1; i < buffer->frag_count; i++) {
1291 DPRINTK(INFO, "getting fragment no %d\n", i);
1292 frag++; /* Get the next frag */ 1187 frag++; /* Get the next frag */
1293 pci_unmap_page(pdev, frag->dma, frag->length, 1188 pci_unmap_page(pdev, frag->dma, frag->length,
1294 PCI_DMA_TODEVICE); 1189 PCI_DMA_TODEVICE);
1295 frag->dma = 0ULL; 1190 frag->dma = 0ULL;
1296 } 1191 }
1297 1192
1298 adapter->stats.skbfreed++; 1193 adapter->stats.xmitfinished++;
1299 dev_kfree_skb_any(buffer->skb); 1194 dev_kfree_skb_any(buffer->skb);
1300 buffer->skb = NULL; 1195 buffer->skb = NULL;
1301 } else if (adapter->proc_cmd_buf_counter == 1) {
1302 adapter->stats.txnullskb++;
1303 }
1304 if (unlikely(netif_queue_stopped(adapter->netdev)
1305 && netif_carrier_ok(adapter->netdev))
1306 && ((jiffies - adapter->netdev->trans_start) >
1307 adapter->netdev->watchdog_timeo)) {
1308 SCHEDULE_WORK(&adapter->tx_timeout_task);
1309 } 1196 }
1310 1197
1311 last_consumer = get_next_index(last_consumer, 1198 last_consumer = get_next_index(last_consumer,
1312 adapter->max_tx_desc_count); 1199 adapter->max_tx_desc_count);
1313 count1++; 1200 if (++count >= MAX_STATUS_HANDLE)
1201 break;
1314 } 1202 }
1315 1203
1316 count2 = 0; 1204 if (count) {
1317 spin_lock(&adapter->tx_lock);
1318 if ((--adapter->proc_cmd_buf_counter) == 0) {
1319 adapter->last_cmd_consumer = last_consumer; 1205 adapter->last_cmd_consumer = last_consumer;
1320 while ((adapter->last_cmd_consumer != consumer) 1206 smp_mb();
1321 && (count2 < MAX_STATUS_HANDLE)) { 1207 if (netif_queue_stopped(netdev) && netif_running(netdev)) {
1322 buffer = 1208 netif_tx_lock(netdev);
1323 &adapter->cmd_buf_arr[adapter->last_cmd_consumer]; 1209 netif_wake_queue(netdev);
1324 count2++; 1210 smp_mb();
1325 if (buffer->skb) 1211 netif_tx_unlock(netdev);
1326 break;
1327 else
1328 adapter->last_cmd_consumer =
1329 get_next_index(adapter->last_cmd_consumer,
1330 adapter->max_tx_desc_count);
1331 }
1332 }
1333 if (count1 || count2) {
1334 if (netif_queue_stopped(adapter->netdev)
1335 && (adapter->flags & NETXEN_NETDEV_STATUS)) {
1336 netif_wake_queue(adapter->netdev);
1337 adapter->flags &= ~NETXEN_NETDEV_STATUS;
1338 } 1212 }
1339 } 1213 }
1340 /* 1214 /*
@@ -1350,16 +1224,9 @@ int netxen_process_cmd_ring(unsigned long data)
1350 * There is still a possible race condition and the host could miss an 1224 * There is still a possible race condition and the host could miss an
1351 * interrupt. The card has to take care of this. 1225 * interrupt. The card has to take care of this.
1352 */ 1226 */
1353 if (adapter->last_cmd_consumer == consumer && 1227 consumer = le32_to_cpu(*(adapter->cmd_consumer));
1354 (((adapter->cmd_producer + 1) % 1228 done = (last_consumer == consumer);
1355 adapter->max_tx_desc_count) == adapter->last_cmd_consumer)) {
1356 consumer = le32_to_cpu(*(adapter->cmd_consumer));
1357 }
1358 done = (adapter->last_cmd_consumer == consumer);
1359 1229
1360 spin_unlock(&adapter->tx_lock);
1361 DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer,
1362 __FUNCTION__);
1363 return (done); 1230 return (done);
1364} 1231}
1365 1232
@@ -1433,8 +1300,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1433 rcv_desc->begin_alloc = index; 1300 rcv_desc->begin_alloc = index;
1434 rcv_desc->rcv_pending += count; 1301 rcv_desc->rcv_pending += count;
1435 rcv_desc->producer = producer; 1302 rcv_desc->producer = producer;
1436 if (rcv_desc->rcv_free >= 32) {
1437 rcv_desc->rcv_free = 0;
1438 /* Window = 1 */ 1303 /* Window = 1 */
1439 writel((producer - 1) & 1304 writel((producer - 1) &
1440 (rcv_desc->max_rx_desc_count - 1), 1305 (rcv_desc->max_rx_desc_count - 1),
@@ -1458,8 +1323,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1458 writel(msg, 1323 writel(msg,
1459 DB_NORMALIZE(adapter, 1324 DB_NORMALIZE(adapter,
1460 NETXEN_RCV_PRODUCER_OFFSET)); 1325 NETXEN_RCV_PRODUCER_OFFSET));
1461 wmb();
1462 }
1463 } 1326 }
1464} 1327}
1465 1328
@@ -1523,8 +1386,6 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1523 rcv_desc->begin_alloc = index; 1386 rcv_desc->begin_alloc = index;
1524 rcv_desc->rcv_pending += count; 1387 rcv_desc->rcv_pending += count;
1525 rcv_desc->producer = producer; 1388 rcv_desc->producer = producer;
1526 if (rcv_desc->rcv_free >= 32) {
1527 rcv_desc->rcv_free = 0;
1528 /* Window = 1 */ 1389 /* Window = 1 */
1529 writel((producer - 1) & 1390 writel((producer - 1) &
1530 (rcv_desc->max_rx_desc_count - 1), 1391 (rcv_desc->max_rx_desc_count - 1),
@@ -1534,21 +1395,9 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1534 rcv_desc_crb[ringid]. 1395 rcv_desc_crb[ringid].
1535 crb_rcv_producer_offset)); 1396 crb_rcv_producer_offset));
1536 wmb(); 1397 wmb();
1537 }
1538 } 1398 }
1539} 1399}
1540 1400
1541int netxen_nic_tx_has_work(struct netxen_adapter *adapter)
1542{
1543 if (find_diff_among(adapter->last_cmd_consumer,
1544 adapter->cmd_producer,
1545 adapter->max_tx_desc_count) > 0)
1546 return 1;
1547
1548 return 0;
1549}
1550
1551
1552void netxen_nic_clear_stats(struct netxen_adapter *adapter) 1401void netxen_nic_clear_stats(struct netxen_adapter *adapter)
1553{ 1402{
1554 memset(&adapter->stats, 0, sizeof(adapter->stats)); 1403 memset(&adapter->stats, 0, sizeof(adapter->stats));
diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c
index 48a404aa66ce..c81313b717bd 100644
--- a/drivers/net/netxen/netxen_nic_isr.c
+++ b/drivers/net/netxen/netxen_nic_isr.c
@@ -59,7 +59,7 @@ struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
59 /* packet transmit problems */ 59 /* packet transmit problems */
60 stats->tx_errors = adapter->stats.nocmddescriptor; 60 stats->tx_errors = adapter->stats.nocmddescriptor;
61 /* no space in linux buffers */ 61 /* no space in linux buffers */
62 stats->rx_dropped = adapter->stats.updropped; 62 stats->rx_dropped = adapter->stats.rxdropped;
63 /* no space available in linux */ 63 /* no space available in linux */
64 stats->tx_dropped = adapter->stats.txdropped; 64 stats->tx_dropped = adapter->stats.txdropped;
65 65
@@ -193,14 +193,14 @@ int netxen_nic_link_ok(struct netxen_adapter *adapter)
193void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter) 193void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter)
194{ 194{
195 struct net_device *netdev = adapter->netdev; 195 struct net_device *netdev = adapter->netdev;
196 u32 val, val1; 196 u32 val;
197 197
198 /* WINDOW = 1 */ 198 /* WINDOW = 1 */
199 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE)); 199 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
200 val >>= (physical_port[adapter->portnum] * 8); 200 val >>= (physical_port[adapter->portnum] * 8);
201 val1 = val & 0xff; 201 val &= 0xff;
202 202
203 if (adapter->ahw.xg_linkup == 1 && val1 != XG_LINK_UP) { 203 if (adapter->ahw.xg_linkup == 1 && val != XG_LINK_UP) {
204 printk(KERN_INFO "%s: %s NIC Link is down\n", 204 printk(KERN_INFO "%s: %s NIC Link is down\n",
205 netxen_nic_driver_name, netdev->name); 205 netxen_nic_driver_name, netdev->name);
206 adapter->ahw.xg_linkup = 0; 206 adapter->ahw.xg_linkup = 0;
@@ -208,16 +208,7 @@ void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter)
208 netif_carrier_off(netdev); 208 netif_carrier_off(netdev);
209 netif_stop_queue(netdev); 209 netif_stop_queue(netdev);
210 } 210 }
211 /* read twice to clear sticky bits */ 211 } else if (adapter->ahw.xg_linkup == 0 && val == XG_LINK_UP) {
212 /* WINDOW = 0 */
213 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val1);
214 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val1);
215
216 if ((val & 0xffb) != 0xffb) {
217 printk(KERN_INFO "%s ISR: Sync/Align BAD: 0x%08x\n",
218 netxen_nic_driver_name, val1);
219 }
220 } else if (adapter->ahw.xg_linkup == 0 && val1 == XG_LINK_UP) {
221 printk(KERN_INFO "%s: %s NIC Link is up\n", 212 printk(KERN_INFO "%s: %s NIC Link is up\n",
222 netxen_nic_driver_name, netdev->name); 213 netxen_nic_driver_name, netdev->name);
223 adapter->ahw.xg_linkup = 1; 214 adapter->ahw.xg_linkup = 1;
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 9737eae5ef11..a8fb439a4d03 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -63,12 +63,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *);
63static void netxen_tx_timeout(struct net_device *netdev); 63static void netxen_tx_timeout(struct net_device *netdev);
64static void netxen_tx_timeout_task(struct work_struct *work); 64static void netxen_tx_timeout_task(struct work_struct *work);
65static void netxen_watchdog(unsigned long); 65static void netxen_watchdog(unsigned long);
66static int netxen_handle_int(struct netxen_adapter *, struct net_device *);
67static int netxen_nic_poll(struct napi_struct *napi, int budget); 66static int netxen_nic_poll(struct napi_struct *napi, int budget);
68#ifdef CONFIG_NET_POLL_CONTROLLER 67#ifdef CONFIG_NET_POLL_CONTROLLER
69static void netxen_nic_poll_controller(struct net_device *netdev); 68static void netxen_nic_poll_controller(struct net_device *netdev);
70#endif 69#endif
71static irqreturn_t netxen_intr(int irq, void *data); 70static irqreturn_t netxen_intr(int irq, void *data);
71static irqreturn_t netxen_msi_intr(int irq, void *data);
72 72
73int physical_port[] = {0, 1, 2, 3}; 73int physical_port[] = {0, 1, 2, 3};
74 74
@@ -149,33 +149,30 @@ static void netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter,
149 149
150#define ADAPTER_LIST_SIZE 12 150#define ADAPTER_LIST_SIZE 12
151 151
152static uint32_t msi_tgt_status[4] = {
153 ISR_INT_TARGET_STATUS, ISR_INT_TARGET_STATUS_F1,
154 ISR_INT_TARGET_STATUS_F2, ISR_INT_TARGET_STATUS_F3
155};
156
157static uint32_t sw_int_mask[4] = {
158 CRB_SW_INT_MASK_0, CRB_SW_INT_MASK_1,
159 CRB_SW_INT_MASK_2, CRB_SW_INT_MASK_3
160};
161
152static void netxen_nic_disable_int(struct netxen_adapter *adapter) 162static void netxen_nic_disable_int(struct netxen_adapter *adapter)
153{ 163{
154 uint32_t mask = 0x7ff; 164 u32 mask = 0x7ff;
155 int retries = 32; 165 int retries = 32;
166 int port = adapter->portnum;
167 int pci_fn = adapter->ahw.pci_func;
156 168
157 DPRINTK(1, INFO, "Entered ISR Disable \n"); 169 if (adapter->msi_mode != MSI_MODE_MULTIFUNC)
158 170 writel(0x0, NETXEN_CRB_NORMALIZE(adapter, sw_int_mask[port]));
159 switch (adapter->portnum) {
160 case 0:
161 writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
162 break;
163 case 1:
164 writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
165 break;
166 case 2:
167 writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
168 break;
169 case 3:
170 writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
171 break;
172 }
173 171
174 if (adapter->intr_scheme != -1 && 172 if (adapter->intr_scheme != -1 &&
175 adapter->intr_scheme != INTR_SCHEME_PERPORT) 173 adapter->intr_scheme != INTR_SCHEME_PERPORT)
176 writel(mask,PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)); 174 writel(mask,PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
177 175
178 /* Window = 0 or 1 */
179 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 176 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
180 do { 177 do {
181 writel(0xffffffff, 178 writel(0xffffffff,
@@ -190,14 +187,18 @@ static void netxen_nic_disable_int(struct netxen_adapter *adapter)
190 printk(KERN_NOTICE "%s: Failed to disable interrupt completely\n", 187 printk(KERN_NOTICE "%s: Failed to disable interrupt completely\n",
191 netxen_nic_driver_name); 188 netxen_nic_driver_name);
192 } 189 }
190 } else {
191 if (adapter->msi_mode == MSI_MODE_MULTIFUNC) {
192 writel(0xffffffff, PCI_OFFSET_SECOND_RANGE(adapter,
193 msi_tgt_status[pci_fn]));
194 }
193 } 195 }
194
195 DPRINTK(1, INFO, "Done with Disable Int\n");
196} 196}
197 197
198static void netxen_nic_enable_int(struct netxen_adapter *adapter) 198static void netxen_nic_enable_int(struct netxen_adapter *adapter)
199{ 199{
200 u32 mask; 200 u32 mask;
201 int port = adapter->portnum;
201 202
202 DPRINTK(1, INFO, "Entered ISR Enable \n"); 203 DPRINTK(1, INFO, "Entered ISR Enable \n");
203 204
@@ -218,20 +219,7 @@ static void netxen_nic_enable_int(struct netxen_adapter *adapter)
218 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)); 219 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
219 } 220 }
220 221
221 switch (adapter->portnum) { 222 writel(0x1, NETXEN_CRB_NORMALIZE(adapter, sw_int_mask[port]));
222 case 0:
223 writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
224 break;
225 case 1:
226 writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
227 break;
228 case 2:
229 writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
230 break;
231 case 3:
232 writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
233 break;
234 }
235 223
236 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 224 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
237 mask = 0xbff; 225 mask = 0xbff;
@@ -328,7 +316,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
328 316
329 adapter->ahw.pdev = pdev; 317 adapter->ahw.pdev = pdev;
330 adapter->ahw.pci_func = pci_func_id; 318 adapter->ahw.pci_func = pci_func_id;
331 spin_lock_init(&adapter->tx_lock);
332 319
333 /* remap phys address */ 320 /* remap phys address */
334 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ 321 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
@@ -401,6 +388,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
401 388
402 /* this will be read from FW later */ 389 /* this will be read from FW later */
403 adapter->intr_scheme = -1; 390 adapter->intr_scheme = -1;
391 adapter->msi_mode = -1;
404 392
405 /* This will be reset for mezz cards */ 393 /* This will be reset for mezz cards */
406 adapter->portnum = pci_func_id; 394 adapter->portnum = pci_func_id;
@@ -415,7 +403,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
415 netdev->set_mac_address = netxen_nic_set_mac; 403 netdev->set_mac_address = netxen_nic_set_mac;
416 netdev->change_mtu = netxen_nic_change_mtu; 404 netdev->change_mtu = netxen_nic_change_mtu;
417 netdev->tx_timeout = netxen_tx_timeout; 405 netdev->tx_timeout = netxen_tx_timeout;
418 netdev->watchdog_timeo = HZ; 406 netdev->watchdog_timeo = 2*HZ;
419 407
420 netxen_nic_change_mtu(netdev, netdev->mtu); 408 netxen_nic_change_mtu(netdev, netdev->mtu);
421 409
@@ -543,7 +531,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
543 adapter->watchdog_timer.data = (unsigned long)adapter; 531 adapter->watchdog_timer.data = (unsigned long)adapter;
544 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); 532 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
545 adapter->ahw.pdev = pdev; 533 adapter->ahw.pdev = pdev;
546 adapter->proc_cmd_buf_counter = 0;
547 adapter->ahw.revision_id = pdev->revision; 534 adapter->ahw.revision_id = pdev->revision;
548 535
549 /* make sure Window == 1 */ 536 /* make sure Window == 1 */
@@ -833,6 +820,8 @@ static int netxen_nic_open(struct net_device *netdev)
833 struct netxen_adapter *adapter = (struct netxen_adapter *)netdev->priv; 820 struct netxen_adapter *adapter = (struct netxen_adapter *)netdev->priv;
834 int err = 0; 821 int err = 0;
835 int ctx, ring; 822 int ctx, ring;
823 irq_handler_t handler;
824 unsigned long flags = IRQF_SAMPLE_RANDOM;
836 825
837 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) { 826 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) {
838 err = netxen_init_firmware(adapter); 827 err = netxen_init_firmware(adapter);
@@ -856,9 +845,14 @@ static int netxen_nic_open(struct net_device *netdev)
856 netxen_post_rx_buffers(adapter, ctx, ring); 845 netxen_post_rx_buffers(adapter, ctx, ring);
857 } 846 }
858 adapter->irq = adapter->ahw.pdev->irq; 847 adapter->irq = adapter->ahw.pdev->irq;
859 err = request_irq(adapter->ahw.pdev->irq, netxen_intr, 848 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
860 IRQF_SHARED|IRQF_SAMPLE_RANDOM, netdev->name, 849 handler = netxen_msi_intr;
861 adapter); 850 else {
851 flags |= IRQF_SHARED;
852 handler = netxen_intr;
853 }
854 err = request_irq(adapter->irq, handler,
855 flags, netdev->name, adapter);
862 if (err) { 856 if (err) {
863 printk(KERN_ERR "request_irq failed with: %d\n", err); 857 printk(KERN_ERR "request_irq failed with: %d\n", err);
864 netxen_free_hw_resources(adapter); 858 netxen_free_hw_resources(adapter);
@@ -867,21 +861,12 @@ static int netxen_nic_open(struct net_device *netdev)
867 861
868 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; 862 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
869 } 863 }
870 if (!adapter->driver_mismatch)
871 mod_timer(&adapter->watchdog_timer, jiffies);
872
873 napi_enable(&adapter->napi);
874
875 netxen_nic_enable_int(adapter);
876
877 /* Done here again so that even if phantom sw overwrote it, 864 /* Done here again so that even if phantom sw overwrote it,
878 * we set it */ 865 * we set it */
879 if (adapter->init_port 866 if (adapter->init_port
880 && adapter->init_port(adapter, adapter->portnum) != 0) { 867 && adapter->init_port(adapter, adapter->portnum) != 0) {
881 del_timer_sync(&adapter->watchdog_timer);
882 printk(KERN_ERR "%s: Failed to initialize port %d\n", 868 printk(KERN_ERR "%s: Failed to initialize port %d\n",
883 netxen_nic_driver_name, adapter->portnum); 869 netxen_nic_driver_name, adapter->portnum);
884 napi_disable(&adapter->napi);
885 return -EIO; 870 return -EIO;
886 } 871 }
887 if (adapter->macaddr_set) 872 if (adapter->macaddr_set)
@@ -894,6 +879,12 @@ static int netxen_nic_open(struct net_device *netdev)
894 adapter->set_mtu(adapter, netdev->mtu); 879 adapter->set_mtu(adapter, netdev->mtu);
895 880
896 if (!adapter->driver_mismatch) 881 if (!adapter->driver_mismatch)
882 mod_timer(&adapter->watchdog_timer, jiffies);
883
884 napi_enable(&adapter->napi);
885 netxen_nic_enable_int(adapter);
886
887 if (!adapter->driver_mismatch)
897 netif_start_queue(netdev); 888 netif_start_queue(netdev);
898 889
899 return 0; 890 return 0;
@@ -958,41 +949,17 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
958 struct netxen_skb_frag *buffrag; 949 struct netxen_skb_frag *buffrag;
959 unsigned int i; 950 unsigned int i;
960 951
961 u32 producer = 0; 952 u32 producer, consumer;
962 u32 saved_producer = 0; 953 u32 saved_producer = 0;
963 struct cmd_desc_type0 *hwdesc; 954 struct cmd_desc_type0 *hwdesc;
964 int k; 955 int k;
965 struct netxen_cmd_buffer *pbuf = NULL; 956 struct netxen_cmd_buffer *pbuf = NULL;
966 static int dropped_packet = 0;
967 int frag_count; 957 int frag_count;
968 u32 local_producer = 0;
969 u32 max_tx_desc_count = 0;
970 u32 last_cmd_consumer = 0;
971 int no_of_desc; 958 int no_of_desc;
959 u32 num_txd = adapter->max_tx_desc_count;
972 960
973 adapter->stats.xmitcalled++;
974 frag_count = skb_shinfo(skb)->nr_frags + 1; 961 frag_count = skb_shinfo(skb)->nr_frags + 1;
975 962
976 if (unlikely(skb->len <= 0)) {
977 dev_kfree_skb_any(skb);
978 adapter->stats.badskblen++;
979 return NETDEV_TX_OK;
980 }
981
982 if (frag_count > MAX_BUFFERS_PER_CMD) {
983 printk("%s: %s netxen_nic_xmit_frame: frag_count (%d) "
984 "too large, can handle only %d frags\n",
985 netxen_nic_driver_name, netdev->name,
986 frag_count, MAX_BUFFERS_PER_CMD);
987 adapter->stats.txdropped++;
988 if ((++dropped_packet & 0xff) == 0xff)
989 printk("%s: %s droppped packets = %d\n",
990 netxen_nic_driver_name, netdev->name,
991 dropped_packet);
992
993 return NETDEV_TX_OK;
994 }
995
996 /* There 4 fragments per descriptor */ 963 /* There 4 fragments per descriptor */
997 no_of_desc = (frag_count + 3) >> 2; 964 no_of_desc = (frag_count + 3) >> 2;
998 if (netdev->features & NETIF_F_TSO) { 965 if (netdev->features & NETIF_F_TSO) {
@@ -1007,27 +974,16 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1007 } 974 }
1008 } 975 }
1009 976
1010 spin_lock_bh(&adapter->tx_lock); 977 producer = adapter->cmd_producer;
1011 if (adapter->total_threads >= MAX_XMIT_PRODUCERS) { 978 smp_mb();
1012 goto out_requeue; 979 consumer = adapter->last_cmd_consumer;
1013 } 980 if ((no_of_desc+2) > find_diff_among(producer, consumer, num_txd)) {
1014 local_producer = adapter->cmd_producer; 981 netif_stop_queue(netdev);
1015 k = adapter->cmd_producer; 982 smp_mb();
1016 max_tx_desc_count = adapter->max_tx_desc_count; 983 return NETDEV_TX_BUSY;
1017 last_cmd_consumer = adapter->last_cmd_consumer;
1018 if ((k + no_of_desc) >=
1019 ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count :
1020 last_cmd_consumer)) {
1021 goto out_requeue;
1022 } 984 }
1023 k = get_index_range(k, max_tx_desc_count, no_of_desc);
1024 adapter->cmd_producer = k;
1025 adapter->total_threads++;
1026 adapter->num_threads++;
1027 985
1028 spin_unlock_bh(&adapter->tx_lock);
1029 /* Copy the descriptors into the hardware */ 986 /* Copy the descriptors into the hardware */
1030 producer = local_producer;
1031 saved_producer = producer; 987 saved_producer = producer;
1032 hwdesc = &hw->cmd_desc_head[producer]; 988 hwdesc = &hw->cmd_desc_head[producer];
1033 memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); 989 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
@@ -1067,8 +1023,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1067 /* move to next desc. if there is a need */ 1023 /* move to next desc. if there is a need */
1068 if ((i & 0x3) == 0) { 1024 if ((i & 0x3) == 0) {
1069 k = 0; 1025 k = 0;
1070 producer = get_next_index(producer, 1026 producer = get_next_index(producer, num_txd);
1071 adapter->max_tx_desc_count);
1072 hwdesc = &hw->cmd_desc_head[producer]; 1027 hwdesc = &hw->cmd_desc_head[producer];
1073 memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); 1028 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
1074 pbuf = &adapter->cmd_buf_arr[producer]; 1029 pbuf = &adapter->cmd_buf_arr[producer];
@@ -1086,7 +1041,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1086 buffrag->dma = temp_dma; 1041 buffrag->dma = temp_dma;
1087 buffrag->length = temp_len; 1042 buffrag->length = temp_len;
1088 1043
1089 DPRINTK(INFO, "for loop. i=%d k=%d\n", i, k);
1090 switch (k) { 1044 switch (k) {
1091 case 0: 1045 case 0:
1092 hwdesc->buffer1_length = cpu_to_le16(temp_len); 1046 hwdesc->buffer1_length = cpu_to_le16(temp_len);
@@ -1107,7 +1061,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1107 } 1061 }
1108 frag++; 1062 frag++;
1109 } 1063 }
1110 producer = get_next_index(producer, adapter->max_tx_desc_count); 1064 producer = get_next_index(producer, num_txd);
1111 1065
1112 /* might change opcode to TX_TCP_LSO */ 1066 /* might change opcode to TX_TCP_LSO */
1113 netxen_tso_check(adapter, &hw->cmd_desc_head[saved_producer], skb); 1067 netxen_tso_check(adapter, &hw->cmd_desc_head[saved_producer], skb);
@@ -1134,7 +1088,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1134 /* copy the first 64 bytes */ 1088 /* copy the first 64 bytes */
1135 memcpy(((void *)hwdesc) + 2, 1089 memcpy(((void *)hwdesc) + 2,
1136 (void *)(skb->data), first_hdr_len); 1090 (void *)(skb->data), first_hdr_len);
1137 producer = get_next_index(producer, max_tx_desc_count); 1091 producer = get_next_index(producer, num_txd);
1138 1092
1139 if (more_hdr) { 1093 if (more_hdr) {
1140 hwdesc = &hw->cmd_desc_head[producer]; 1094 hwdesc = &hw->cmd_desc_head[producer];
@@ -1147,35 +1101,19 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1147 hwdesc, 1101 hwdesc,
1148 (hdr_len - 1102 (hdr_len -
1149 first_hdr_len)); 1103 first_hdr_len));
1150 producer = get_next_index(producer, max_tx_desc_count); 1104 producer = get_next_index(producer, num_txd);
1151 } 1105 }
1152 } 1106 }
1153 1107
1154 spin_lock_bh(&adapter->tx_lock); 1108 adapter->cmd_producer = producer;
1155 adapter->stats.txbytes += skb->len; 1109 adapter->stats.txbytes += skb->len;
1156 1110
1157 /* Code to update the adapter considering how many producer threads 1111 netxen_nic_update_cmd_producer(adapter, adapter->cmd_producer);
1158 are currently working */
1159 if ((--adapter->num_threads) == 0) {
1160 /* This is the last thread */
1161 u32 crb_producer = adapter->cmd_producer;
1162 netxen_nic_update_cmd_producer(adapter, crb_producer);
1163 wmb();
1164 adapter->total_threads = 0;
1165 }
1166 1112
1167 adapter->stats.xmitfinished++; 1113 adapter->stats.xmitcalled++;
1168 netdev->trans_start = jiffies; 1114 netdev->trans_start = jiffies;
1169 1115
1170 spin_unlock_bh(&adapter->tx_lock);
1171 return NETDEV_TX_OK; 1116 return NETDEV_TX_OK;
1172
1173out_requeue:
1174 netif_stop_queue(netdev);
1175 adapter->flags |= NETXEN_NETDEV_STATUS;
1176
1177 spin_unlock_bh(&adapter->tx_lock);
1178 return NETDEV_TX_BUSY;
1179} 1117}
1180 1118
1181static void netxen_watchdog(unsigned long v) 1119static void netxen_watchdog(unsigned long v)
@@ -1200,87 +1138,60 @@ static void netxen_tx_timeout_task(struct work_struct *work)
1200 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", 1138 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
1201 netxen_nic_driver_name, adapter->netdev->name); 1139 netxen_nic_driver_name, adapter->netdev->name);
1202 1140
1203 netxen_nic_close(adapter->netdev); 1141 netxen_nic_disable_int(adapter);
1204 netxen_nic_open(adapter->netdev); 1142 napi_disable(&adapter->napi);
1143
1205 adapter->netdev->trans_start = jiffies; 1144 adapter->netdev->trans_start = jiffies;
1145
1146 napi_enable(&adapter->napi);
1147 netxen_nic_enable_int(adapter);
1206 netif_wake_queue(adapter->netdev); 1148 netif_wake_queue(adapter->netdev);
1207} 1149}
1208 1150
1209static int 1151static inline void
1210netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) 1152netxen_handle_int(struct netxen_adapter *adapter)
1211{ 1153{
1212 u32 ret = 0;
1213
1214 DPRINTK(INFO, "Entered handle ISR\n");
1215 adapter->stats.ints++;
1216
1217 netxen_nic_disable_int(adapter); 1154 netxen_nic_disable_int(adapter);
1218 1155 napi_schedule(&adapter->napi);
1219 if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) {
1220 if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
1221 /*
1222 * Interrupts are already disabled.
1223 */
1224 __netif_rx_schedule(netdev, &adapter->napi);
1225 } else {
1226 static unsigned int intcount = 0;
1227 if ((++intcount & 0xfff) == 0xfff)
1228 DPRINTK(KERN_ERR
1229 "%s: %s interrupt %d while in poll\n",
1230 netxen_nic_driver_name, netdev->name,
1231 intcount);
1232 }
1233 ret = 1;
1234 }
1235
1236 if (ret == 0) {
1237 netxen_nic_enable_int(adapter);
1238 }
1239
1240 return ret;
1241} 1156}
1242 1157
1243/*
1244 * netxen_intr - Interrupt Handler
1245 * @irq: interrupt number
1246 * data points to adapter stucture (which may be handling more than 1 port
1247 */
1248irqreturn_t netxen_intr(int irq, void *data) 1158irqreturn_t netxen_intr(int irq, void *data)
1249{ 1159{
1250 struct netxen_adapter *adapter = data; 1160 struct netxen_adapter *adapter = data;
1251 struct net_device *netdev = adapter->netdev;
1252 u32 our_int = 0; 1161 u32 our_int = 0;
1253 1162
1254 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 1163 our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
1255 our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); 1164 /* not our interrupt */
1256 /* not our interrupt */ 1165 if ((our_int & (0x80 << adapter->portnum)) == 0)
1257 if ((our_int & (0x80 << adapter->portnum)) == 0) 1166 return IRQ_NONE;
1258 return IRQ_NONE;
1259 }
1260 1167
1261 if (adapter->intr_scheme == INTR_SCHEME_PERPORT) { 1168 if (adapter->intr_scheme == INTR_SCHEME_PERPORT) {
1262 /* claim interrupt */ 1169 /* claim interrupt */
1263 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 1170 writel(our_int & ~((u32)(0x80 << adapter->portnum)),
1264 writel(our_int & ~((u32)(0x80 << adapter->portnum)),
1265 NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); 1171 NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
1266 }
1267 } 1172 }
1268 1173
1269 if (netif_running(netdev)) 1174 netxen_handle_int(adapter);
1270 netxen_handle_int(adapter, netdev);
1271 1175
1272 return IRQ_HANDLED; 1176 return IRQ_HANDLED;
1273} 1177}
1274 1178
1179irqreturn_t netxen_msi_intr(int irq, void *data)
1180{
1181 struct netxen_adapter *adapter = data;
1182
1183 netxen_handle_int(adapter);
1184 return IRQ_HANDLED;
1185}
1186
1275static int netxen_nic_poll(struct napi_struct *napi, int budget) 1187static int netxen_nic_poll(struct napi_struct *napi, int budget)
1276{ 1188{
1277 struct netxen_adapter *adapter = container_of(napi, struct netxen_adapter, napi); 1189 struct netxen_adapter *adapter = container_of(napi, struct netxen_adapter, napi);
1278 struct net_device *netdev = adapter->netdev; 1190 int tx_complete;
1279 int done = 1;
1280 int ctx; 1191 int ctx;
1281 int work_done; 1192 int work_done;
1282 1193
1283 DPRINTK(INFO, "polling for %d descriptors\n", *budget); 1194 tx_complete = netxen_process_cmd_ring(adapter);
1284 1195
1285 work_done = 0; 1196 work_done = 0;
1286 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { 1197 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
@@ -1300,16 +1211,8 @@ static int netxen_nic_poll(struct napi_struct *napi, int budget)
1300 budget / MAX_RCV_CTX); 1211 budget / MAX_RCV_CTX);
1301 } 1212 }
1302 1213
1303 if (work_done >= budget) 1214 if ((work_done < budget) && tx_complete) {
1304 done = 0; 1215 netif_rx_complete(adapter->netdev, &adapter->napi);
1305
1306 if (netxen_process_cmd_ring((unsigned long)adapter) == 0)
1307 done = 0;
1308
1309 DPRINTK(INFO, "new work_done: %d work_to_do: %d\n",
1310 work_done, work_to_do);
1311 if (done) {
1312 netif_rx_complete(netdev, napi);
1313 netxen_nic_enable_int(adapter); 1216 netxen_nic_enable_int(adapter);
1314 } 1217 }
1315 1218
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
index ffa3b7215ce8..a566b50f36f5 100644
--- a/drivers/net/netxen/netxen_nic_phan_reg.h
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -126,8 +126,11 @@
126 */ 126 */
127#define CRB_NIC_CAPABILITIES_HOST NETXEN_NIC_REG(0x1a8) 127#define CRB_NIC_CAPABILITIES_HOST NETXEN_NIC_REG(0x1a8)
128#define CRB_NIC_CAPABILITIES_FW NETXEN_NIC_REG(0x1dc) 128#define CRB_NIC_CAPABILITIES_FW NETXEN_NIC_REG(0x1dc)
129#define CRB_NIC_MSI_MODE_HOST NETXEN_NIC_REG(0x270)
130#define CRB_NIC_MSI_MODE_FW NETXEN_NIC_REG(0x274)
129 131
130#define INTR_SCHEME_PERPORT 0x1 132#define INTR_SCHEME_PERPORT 0x1
133#define MSI_MODE_MULTIFUNC 0x1
131 134
132/* used for ethtool tests */ 135/* used for ethtool tests */
133#define CRB_SCRATCHPAD_TEST NETXEN_NIC_REG(0x280) 136#define CRB_SCRATCHPAD_TEST NETXEN_NIC_REG(0x280)
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index f0574073a2a3..32a8503a7acd 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -58,9 +58,25 @@
58#define MII_M1111_RX_DELAY 0x80 58#define MII_M1111_RX_DELAY 0x80
59#define MII_M1111_TX_DELAY 0x2 59#define MII_M1111_TX_DELAY 0x2
60#define MII_M1111_PHY_EXT_SR 0x1b 60#define MII_M1111_PHY_EXT_SR 0x1b
61#define MII_M1111_HWCFG_MODE_MASK 0xf 61
62#define MII_M1111_HWCFG_MODE_RGMII 0xb 62#define MII_M1111_HWCFG_MODE_MASK 0xf
63#define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
64#define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
63#define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4 65#define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
66#define MII_M1111_HWCFG_FIBER_COPPER_AUTO 0x8000
67#define MII_M1111_HWCFG_FIBER_COPPER_RES 0x2000
68
69#define MII_M1111_COPPER 0
70#define MII_M1111_FIBER 1
71
72#define MII_M1011_PHY_STATUS 0x11
73#define MII_M1011_PHY_STATUS_1000 0x8000
74#define MII_M1011_PHY_STATUS_100 0x4000
75#define MII_M1011_PHY_STATUS_SPD_MASK 0xc000
76#define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000
77#define MII_M1011_PHY_STATUS_RESOLVED 0x0800
78#define MII_M1011_PHY_STATUS_LINK 0x0400
79
64 80
65MODULE_DESCRIPTION("Marvell PHY driver"); 81MODULE_DESCRIPTION("Marvell PHY driver");
66MODULE_AUTHOR("Andy Fleming"); 82MODULE_AUTHOR("Andy Fleming");
@@ -141,12 +157,22 @@ static int marvell_config_aneg(struct phy_device *phydev)
141static int m88e1111_config_init(struct phy_device *phydev) 157static int m88e1111_config_init(struct phy_device *phydev)
142{ 158{
143 int err; 159 int err;
160 int temp;
161 int mode;
162
163 /* Enable Fiber/Copper auto selection */
164 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
165 temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;
166 phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
167
168 temp = phy_read(phydev, MII_BMCR);
169 temp |= BMCR_RESET;
170 phy_write(phydev, MII_BMCR, temp);
144 171
145 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) || 172 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
146 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) || 173 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
147 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) || 174 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
148 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) { 175 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
149 int temp;
150 176
151 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR); 177 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
152 if (temp < 0) 178 if (temp < 0)
@@ -171,7 +197,13 @@ static int m88e1111_config_init(struct phy_device *phydev)
171 return temp; 197 return temp;
172 198
173 temp &= ~(MII_M1111_HWCFG_MODE_MASK); 199 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
174 temp |= MII_M1111_HWCFG_MODE_RGMII; 200
201 mode = phy_read(phydev, MII_M1111_PHY_EXT_CR);
202
203 if (mode & MII_M1111_HWCFG_FIBER_COPPER_RES)
204 temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
205 else
206 temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;
175 207
176 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); 208 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
177 if (err < 0) 209 if (err < 0)
@@ -179,8 +211,6 @@ static int m88e1111_config_init(struct phy_device *phydev)
179 } 211 }
180 212
181 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { 213 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
182 int temp;
183
184 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); 214 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
185 if (temp < 0) 215 if (temp < 0)
186 return temp; 216 return temp;
@@ -262,6 +292,93 @@ static int m88e1145_config_init(struct phy_device *phydev)
262 return 0; 292 return 0;
263} 293}
264 294
295/* marvell_read_status
296 *
297 * Generic status code does not detect Fiber correctly!
298 * Description:
299 * Check the link, then figure out the current state
300 * by comparing what we advertise with what the link partner
301 * advertises. Start by checking the gigabit possibilities,
302 * then move on to 10/100.
303 */
304static int marvell_read_status(struct phy_device *phydev)
305{
306 int adv;
307 int err;
308 int lpa;
309 int status = 0;
310
311 /* Update the link, but return if there
312 * was an error */
313 err = genphy_update_link(phydev);
314 if (err)
315 return err;
316
317 if (AUTONEG_ENABLE == phydev->autoneg) {
318 status = phy_read(phydev, MII_M1011_PHY_STATUS);
319 if (status < 0)
320 return status;
321
322 lpa = phy_read(phydev, MII_LPA);
323 if (lpa < 0)
324 return lpa;
325
326 adv = phy_read(phydev, MII_ADVERTISE);
327 if (adv < 0)
328 return adv;
329
330 lpa &= adv;
331
332 if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
333 phydev->duplex = DUPLEX_FULL;
334 else
335 phydev->duplex = DUPLEX_HALF;
336
337 status = status & MII_M1011_PHY_STATUS_SPD_MASK;
338 phydev->pause = phydev->asym_pause = 0;
339
340 switch (status) {
341 case MII_M1011_PHY_STATUS_1000:
342 phydev->speed = SPEED_1000;
343 break;
344
345 case MII_M1011_PHY_STATUS_100:
346 phydev->speed = SPEED_100;
347 break;
348
349 default:
350 phydev->speed = SPEED_10;
351 break;
352 }
353
354 if (phydev->duplex == DUPLEX_FULL) {
355 phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
356 phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
357 }
358 } else {
359 int bmcr = phy_read(phydev, MII_BMCR);
360
361 if (bmcr < 0)
362 return bmcr;
363
364 if (bmcr & BMCR_FULLDPLX)
365 phydev->duplex = DUPLEX_FULL;
366 else
367 phydev->duplex = DUPLEX_HALF;
368
369 if (bmcr & BMCR_SPEED1000)
370 phydev->speed = SPEED_1000;
371 else if (bmcr & BMCR_SPEED100)
372 phydev->speed = SPEED_100;
373 else
374 phydev->speed = SPEED_10;
375
376 phydev->pause = phydev->asym_pause = 0;
377 }
378
379 return 0;
380}
381
265static struct phy_driver marvell_drivers[] = { 382static struct phy_driver marvell_drivers[] = {
266 { 383 {
267 .phy_id = 0x01410c60, 384 .phy_id = 0x01410c60,
@@ -296,7 +413,7 @@ static struct phy_driver marvell_drivers[] = {
296 .flags = PHY_HAS_INTERRUPT, 413 .flags = PHY_HAS_INTERRUPT,
297 .config_init = &m88e1111_config_init, 414 .config_init = &m88e1111_config_init,
298 .config_aneg = &marvell_config_aneg, 415 .config_aneg = &marvell_config_aneg,
299 .read_status = &genphy_read_status, 416 .read_status = &marvell_read_status,
300 .ack_interrupt = &marvell_ack_interrupt, 417 .ack_interrupt = &marvell_ack_interrupt,
301 .config_intr = &marvell_config_intr, 418 .config_intr = &marvell_config_intr,
302 .driver = { .owner = THIS_MODULE }, 419 .driver = { .owner = THIS_MODULE },
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index fee3d7b1feba..1e965427b0e9 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -903,17 +903,18 @@ plip_interrupt(void *dev_id)
903 struct net_local *nl; 903 struct net_local *nl;
904 struct plip_local *rcv; 904 struct plip_local *rcv;
905 unsigned char c0; 905 unsigned char c0;
906 unsigned long flags;
906 907
907 nl = netdev_priv(dev); 908 nl = netdev_priv(dev);
908 rcv = &nl->rcv_data; 909 rcv = &nl->rcv_data;
909 910
910 spin_lock_irq (&nl->lock); 911 spin_lock_irqsave (&nl->lock, flags);
911 912
912 c0 = read_status(dev); 913 c0 = read_status(dev);
913 if ((c0 & 0xf8) != 0xc0) { 914 if ((c0 & 0xf8) != 0xc0) {
914 if ((dev->irq != -1) && (net_debug > 1)) 915 if ((dev->irq != -1) && (net_debug > 1))
915 printk(KERN_DEBUG "%s: spurious interrupt\n", dev->name); 916 printk(KERN_DEBUG "%s: spurious interrupt\n", dev->name);
916 spin_unlock_irq (&nl->lock); 917 spin_unlock_irqrestore (&nl->lock, flags);
917 return; 918 return;
918 } 919 }
919 920
@@ -942,7 +943,7 @@ plip_interrupt(void *dev_id)
942 break; 943 break;
943 } 944 }
944 945
945 spin_unlock_irq(&nl->lock); 946 spin_unlock_irqrestore(&nl->lock, flags);
946} 947}
947 948
948static int 949static int
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index c72787adeba3..c082cf0b1ac6 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -84,7 +84,7 @@
84#include "s2io.h" 84#include "s2io.h"
85#include "s2io-regs.h" 85#include "s2io-regs.h"
86 86
87#define DRV_VERSION "2.0.26.15-2" 87#define DRV_VERSION "2.0.26.20"
88 88
89/* S2io Driver name & version. */ 89/* S2io Driver name & version. */
90static char s2io_driver_name[] = "Neterion"; 90static char s2io_driver_name[] = "Neterion";
@@ -4172,6 +4172,9 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4172 dev->trans_start = jiffies; 4172 dev->trans_start = jiffies;
4173 spin_unlock_irqrestore(&fifo->tx_lock, flags); 4173 spin_unlock_irqrestore(&fifo->tx_lock, flags);
4174 4174
4175 if (sp->config.intr_type == MSI_X)
4176 tx_intr_handler(fifo);
4177
4175 return 0; 4178 return 0;
4176pci_map_failed: 4179pci_map_failed:
4177 stats->pci_map_fail_cnt++; 4180 stats->pci_map_fail_cnt++;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 186eb8ebfda6..2e26dced13a1 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -3199,12 +3199,14 @@ static int skge_poll(struct napi_struct *napi, int to_do)
3199 skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_START); 3199 skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_START);
3200 3200
3201 if (work_done < to_do) { 3201 if (work_done < to_do) {
3202 spin_lock_irq(&hw->hw_lock); 3202 unsigned long flags;
3203
3204 spin_lock_irqsave(&hw->hw_lock, flags);
3203 __netif_rx_complete(dev, napi); 3205 __netif_rx_complete(dev, napi);
3204 hw->intr_mask |= napimask[skge->port]; 3206 hw->intr_mask |= napimask[skge->port];
3205 skge_write32(hw, B0_IMSK, hw->intr_mask); 3207 skge_write32(hw, B0_IMSK, hw->intr_mask);
3206 skge_read32(hw, B0_IMSK); 3208 skge_read32(hw, B0_IMSK);
3207 spin_unlock_irq(&hw->hw_lock); 3209 spin_unlock_irqrestore(&hw->hw_lock, flags);
3208 } 3210 }
3209 3211
3210 return work_done; 3212 return work_done;
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 54c662690f65..853bce0ac478 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -4329,10 +4329,14 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
4329 if (!hw) 4329 if (!hw)
4330 return 0; 4330 return 0;
4331 4331
4332 del_timer_sync(&hw->watchdog_timer);
4333 cancel_work_sync(&hw->restart_work);
4334
4332 for (i = 0; i < hw->ports; i++) { 4335 for (i = 0; i < hw->ports; i++) {
4333 struct net_device *dev = hw->dev[i]; 4336 struct net_device *dev = hw->dev[i];
4334 struct sky2_port *sky2 = netdev_priv(dev); 4337 struct sky2_port *sky2 = netdev_priv(dev);
4335 4338
4339 netif_device_detach(dev);
4336 if (netif_running(dev)) 4340 if (netif_running(dev))
4337 sky2_down(dev); 4341 sky2_down(dev);
4338 4342
@@ -4383,6 +4387,8 @@ static int sky2_resume(struct pci_dev *pdev)
4383 4387
4384 for (i = 0; i < hw->ports; i++) { 4388 for (i = 0; i < hw->ports; i++) {
4385 struct net_device *dev = hw->dev[i]; 4389 struct net_device *dev = hw->dev[i];
4390
4391 netif_device_attach(dev);
4386 if (netif_running(dev)) { 4392 if (netif_running(dev)) {
4387 err = sky2_up(dev); 4393 err = sky2_up(dev);
4388 if (err) { 4394 if (err) {
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index c49214feae91..7b7b1717b0d1 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -1472,13 +1472,12 @@ static int __netdev_rx(struct net_device *dev, int *quota)
1472#ifndef final_version /* Remove after testing. */ 1472#ifndef final_version /* Remove after testing. */
1473 /* You will want this info for the initial debug. */ 1473 /* You will want this info for the initial debug. */
1474 if (debug > 5) { 1474 if (debug > 5) {
1475 DECLARE_MAC_BUF(mac); 1475 printk(KERN_DEBUG " Rx data " MAC_FMT " " MAC_FMT
1476 DECLARE_MAC_BUF(mac2);
1477
1478 printk(KERN_DEBUG " Rx data %s %s"
1479 " %2.2x%2.2x.\n", 1476 " %2.2x%2.2x.\n",
1480 print_mac(mac, &skb->data[0]), 1477 skb->data[0], skb->data[1], skb->data[2],
1481 print_mac(mac2, &skb->data[6]), 1478 skb->data[3], skb->data[4], skb->data[5],
1479 skb->data[6], skb->data[7], skb->data[8],
1480 skb->data[9], skb->data[10], skb->data[11],
1482 skb->data[12], skb->data[13]); 1481 skb->data[12], skb->data[13]);
1483 } 1482 }
1484#endif 1483#endif
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index f9ef8bd8b11e..d4655b2d1f3f 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -64,8 +64,8 @@
64 64
65#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
66#define PFX DRV_MODULE_NAME ": " 66#define PFX DRV_MODULE_NAME ": "
67#define DRV_MODULE_VERSION "3.88" 67#define DRV_MODULE_VERSION "3.89"
68#define DRV_MODULE_RELDATE "March 20, 2008" 68#define DRV_MODULE_RELDATE "April 03, 2008"
69 69
70#define TG3_DEF_MAC_MODE 0 70#define TG3_DEF_MAC_MODE 0
71#define TG3_DEF_RX_MODE 0 71#define TG3_DEF_RX_MODE 0
@@ -804,6 +804,12 @@ static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
804 return ret; 804 return ret;
805} 805}
806 806
807static void tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val)
808{
809 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, reg);
810 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, val);
811}
812
807static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable) 813static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable)
808{ 814{
809 u32 phy; 815 u32 phy;
@@ -886,6 +892,49 @@ static int tg3_bmcr_reset(struct tg3 *tp)
886 return 0; 892 return 0;
887} 893}
888 894
895static void tg3_phy_apply_otp(struct tg3 *tp)
896{
897 u32 otp, phy;
898
899 if (!tp->phy_otp)
900 return;
901
902 otp = tp->phy_otp;
903
904 /* Enable SM_DSP clock and tx 6dB coding. */
905 phy = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
906 MII_TG3_AUXCTL_ACTL_SMDSP_ENA |
907 MII_TG3_AUXCTL_ACTL_TX_6DB;
908 tg3_writephy(tp, MII_TG3_AUX_CTRL, phy);
909
910 phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT);
911 phy |= MII_TG3_DSP_TAP1_AGCTGT_DFLT;
912 tg3_phydsp_write(tp, MII_TG3_DSP_TAP1, phy);
913
914 phy = ((otp & TG3_OTP_HPFFLTR_MASK) >> TG3_OTP_HPFFLTR_SHIFT) |
915 ((otp & TG3_OTP_HPFOVER_MASK) >> TG3_OTP_HPFOVER_SHIFT);
916 tg3_phydsp_write(tp, MII_TG3_DSP_AADJ1CH0, phy);
917
918 phy = ((otp & TG3_OTP_LPFDIS_MASK) >> TG3_OTP_LPFDIS_SHIFT);
919 phy |= MII_TG3_DSP_AADJ1CH3_ADCCKADJ;
920 tg3_phydsp_write(tp, MII_TG3_DSP_AADJ1CH3, phy);
921
922 phy = ((otp & TG3_OTP_VDAC_MASK) >> TG3_OTP_VDAC_SHIFT);
923 tg3_phydsp_write(tp, MII_TG3_DSP_EXP75, phy);
924
925 phy = ((otp & TG3_OTP_10BTAMP_MASK) >> TG3_OTP_10BTAMP_SHIFT);
926 tg3_phydsp_write(tp, MII_TG3_DSP_EXP96, phy);
927
928 phy = ((otp & TG3_OTP_ROFF_MASK) >> TG3_OTP_ROFF_SHIFT) |
929 ((otp & TG3_OTP_RCOFF_MASK) >> TG3_OTP_RCOFF_SHIFT);
930 tg3_phydsp_write(tp, MII_TG3_DSP_EXP97, phy);
931
932 /* Turn off SM_DSP clock. */
933 phy = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
934 MII_TG3_AUXCTL_ACTL_TX_6DB;
935 tg3_writephy(tp, MII_TG3_AUX_CTRL, phy);
936}
937
889static int tg3_wait_macro_done(struct tg3 *tp) 938static int tg3_wait_macro_done(struct tg3 *tp)
890{ 939{
891 int limit = 100; 940 int limit = 100;
@@ -1073,6 +1122,7 @@ static void tg3_link_report(struct tg3 *);
1073 */ 1122 */
1074static int tg3_phy_reset(struct tg3 *tp) 1123static int tg3_phy_reset(struct tg3 *tp)
1075{ 1124{
1125 u32 cpmuctrl;
1076 u32 phy_status; 1126 u32 phy_status;
1077 int err; 1127 int err;
1078 1128
@@ -1102,10 +1152,28 @@ static int tg3_phy_reset(struct tg3 *tp)
1102 goto out; 1152 goto out;
1103 } 1153 }
1104 1154
1155 cpmuctrl = 0;
1156 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 &&
1157 GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5784_AX) {
1158 cpmuctrl = tr32(TG3_CPMU_CTRL);
1159 if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY)
1160 tw32(TG3_CPMU_CTRL,
1161 cpmuctrl & ~CPMU_CTRL_GPHY_10MB_RXONLY);
1162 }
1163
1105 err = tg3_bmcr_reset(tp); 1164 err = tg3_bmcr_reset(tp);
1106 if (err) 1165 if (err)
1107 return err; 1166 return err;
1108 1167
1168 if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY) {
1169 u32 phy;
1170
1171 phy = MII_TG3_DSP_EXP8_AEDW | MII_TG3_DSP_EXP8_REJ2MHz;
1172 tg3_phydsp_write(tp, MII_TG3_DSP_EXP8, phy);
1173
1174 tw32(TG3_CPMU_CTRL, cpmuctrl);
1175 }
1176
1109 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { 1177 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) {
1110 u32 val; 1178 u32 val;
1111 1179
@@ -1124,6 +1192,8 @@ static int tg3_phy_reset(struct tg3 *tp)
1124 MII_TG3_MISC_SHDW_APD_WKTM_84MS); 1192 MII_TG3_MISC_SHDW_APD_WKTM_84MS);
1125 } 1193 }
1126 1194
1195 tg3_phy_apply_otp(tp);
1196
1127out: 1197out:
1128 if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) { 1198 if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) {
1129 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); 1199 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
@@ -9464,7 +9534,8 @@ static int tg3_test_loopback(struct tg3 *tp)
9464 if (err) 9534 if (err)
9465 return TG3_LOOPBACK_FAILED; 9535 return TG3_LOOPBACK_FAILED;
9466 9536
9467 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { 9537 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 ||
9538 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) {
9468 int i; 9539 int i;
9469 u32 status; 9540 u32 status;
9470 9541
@@ -9481,17 +9552,23 @@ static int tg3_test_loopback(struct tg3 *tp)
9481 if (status != CPMU_MUTEX_GNT_DRIVER) 9552 if (status != CPMU_MUTEX_GNT_DRIVER)
9482 return TG3_LOOPBACK_FAILED; 9553 return TG3_LOOPBACK_FAILED;
9483 9554
9484 /* Turn off power management based on link speed. */ 9555 /* Turn off link-based power management. */
9485 cpmuctrl = tr32(TG3_CPMU_CTRL); 9556 cpmuctrl = tr32(TG3_CPMU_CTRL);
9486 tw32(TG3_CPMU_CTRL, 9557 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 ||
9487 cpmuctrl & ~(CPMU_CTRL_LINK_SPEED_MODE | 9558 GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5761_AX)
9488 CPMU_CTRL_LINK_AWARE_MODE)); 9559 tw32(TG3_CPMU_CTRL,
9560 cpmuctrl & ~(CPMU_CTRL_LINK_SPEED_MODE |
9561 CPMU_CTRL_LINK_AWARE_MODE));
9562 else
9563 tw32(TG3_CPMU_CTRL,
9564 cpmuctrl & ~CPMU_CTRL_LINK_AWARE_MODE);
9489 } 9565 }
9490 9566
9491 if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) 9567 if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK))
9492 err |= TG3_MAC_LOOPBACK_FAILED; 9568 err |= TG3_MAC_LOOPBACK_FAILED;
9493 9569
9494 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { 9570 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 ||
9571 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) {
9495 tw32(TG3_CPMU_CTRL, cpmuctrl); 9572 tw32(TG3_CPMU_CTRL, cpmuctrl);
9496 9573
9497 /* Release the mutex */ 9574 /* Release the mutex */
@@ -10724,9 +10801,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
10724 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) 10801 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL)
10725 tp->led_ctrl = LED_CTRL_MODE_PHY_2; 10802 tp->led_ctrl = LED_CTRL_MODE_PHY_2;
10726 10803
10727 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || 10804 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX)
10728 tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) 10805 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
10729 tp->led_ctrl = LED_CTRL_MODE_MAC;
10730 10806
10731 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) { 10807 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) {
10732 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 10808 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
@@ -10773,6 +10849,55 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
10773 } 10849 }
10774} 10850}
10775 10851
10852static int __devinit tg3_issue_otp_command(struct tg3 *tp, u32 cmd)
10853{
10854 int i;
10855 u32 val;
10856
10857 tw32(OTP_CTRL, cmd | OTP_CTRL_OTP_CMD_START);
10858 tw32(OTP_CTRL, cmd);
10859
10860 /* Wait for up to 1 ms for command to execute. */
10861 for (i = 0; i < 100; i++) {
10862 val = tr32(OTP_STATUS);
10863 if (val & OTP_STATUS_CMD_DONE)
10864 break;
10865 udelay(10);
10866 }
10867
10868 return (val & OTP_STATUS_CMD_DONE) ? 0 : -EBUSY;
10869}
10870
10871/* Read the gphy configuration from the OTP region of the chip. The gphy
10872 * configuration is a 32-bit value that straddles the alignment boundary.
10873 * We do two 32-bit reads and then shift and merge the results.
10874 */
10875static u32 __devinit tg3_read_otp_phycfg(struct tg3 *tp)
10876{
10877 u32 bhalf_otp, thalf_otp;
10878
10879 tw32(OTP_MODE, OTP_MODE_OTP_THRU_GRC);
10880
10881 if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_INIT))
10882 return 0;
10883
10884 tw32(OTP_ADDRESS, OTP_ADDRESS_MAGIC1);
10885
10886 if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_READ))
10887 return 0;
10888
10889 thalf_otp = tr32(OTP_READ_DATA);
10890
10891 tw32(OTP_ADDRESS, OTP_ADDRESS_MAGIC2);
10892
10893 if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_READ))
10894 return 0;
10895
10896 bhalf_otp = tr32(OTP_READ_DATA);
10897
10898 return ((thalf_otp & 0x0000ffff) << 16) | (bhalf_otp >> 16);
10899}
10900
10776static int __devinit tg3_phy_probe(struct tg3 *tp) 10901static int __devinit tg3_phy_probe(struct tg3 *tp)
10777{ 10902{
10778 u32 hw_phy_id_1, hw_phy_id_2; 10903 u32 hw_phy_id_1, hw_phy_id_2;
@@ -11586,6 +11711,13 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
11586 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; 11711 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG;
11587 } 11712 }
11588 11713
11714 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 &&
11715 GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5784_AX) {
11716 tp->phy_otp = tg3_read_otp_phycfg(tp);
11717 if (tp->phy_otp == 0)
11718 tp->phy_otp = TG3_OTP_DEFAULT;
11719 }
11720
11589 tp->coalesce_mode = 0; 11721 tp->coalesce_mode = 0;
11590 if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX && 11722 if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX &&
11591 GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_BX) 11723 GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_BX)
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 3938eb35ce8c..c1075a73d66c 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -138,6 +138,8 @@
138#define CHIPREV_5704_BX 0x21 138#define CHIPREV_5704_BX 0x21
139#define CHIPREV_5750_AX 0x40 139#define CHIPREV_5750_AX 0x40
140#define CHIPREV_5750_BX 0x41 140#define CHIPREV_5750_BX 0x41
141#define CHIPREV_5784_AX 0x57840
142#define CHIPREV_5761_AX 0x57610
141#define GET_METAL_REV(CHIP_REV_ID) ((CHIP_REV_ID) & 0xff) 143#define GET_METAL_REV(CHIP_REV_ID) ((CHIP_REV_ID) & 0xff)
142#define METAL_REV_A0 0x00 144#define METAL_REV_A0 0x00
143#define METAL_REV_A1 0x01 145#define METAL_REV_A1 0x01
@@ -866,6 +868,7 @@
866#define CPMU_CTRL_LINK_IDLE_MODE 0x00000200 868#define CPMU_CTRL_LINK_IDLE_MODE 0x00000200
867#define CPMU_CTRL_LINK_AWARE_MODE 0x00000400 869#define CPMU_CTRL_LINK_AWARE_MODE 0x00000400
868#define CPMU_CTRL_LINK_SPEED_MODE 0x00004000 870#define CPMU_CTRL_LINK_SPEED_MODE 0x00004000
871#define CPMU_CTRL_GPHY_10MB_RXONLY 0x00010000
869#define TG3_CPMU_LSPD_10MB_CLK 0x00003604 872#define TG3_CPMU_LSPD_10MB_CLK 0x00003604
870#define CPMU_LSPD_10MB_MACCLK_MASK 0x001f0000 873#define CPMU_LSPD_10MB_MACCLK_MASK 0x001f0000
871#define CPMU_LSPD_10MB_MACCLK_6_25 0x00130000 874#define CPMU_LSPD_10MB_MACCLK_6_25 0x00130000
@@ -1559,7 +1562,24 @@
1559/* 0x702c unused */ 1562/* 0x702c unused */
1560 1563
1561#define NVRAM_ADDR_LOCKOUT 0x00007030 1564#define NVRAM_ADDR_LOCKOUT 0x00007030
1562/* 0x7034 --> 0x7c00 unused */ 1565/* 0x7034 --> 0x7500 unused */
1566
1567#define OTP_MODE 0x00007500
1568#define OTP_MODE_OTP_THRU_GRC 0x00000001
1569#define OTP_CTRL 0x00007504
1570#define OTP_CTRL_OTP_PROG_ENABLE 0x00200000
1571#define OTP_CTRL_OTP_CMD_READ 0x00000000
1572#define OTP_CTRL_OTP_CMD_INIT 0x00000008
1573#define OTP_CTRL_OTP_CMD_START 0x00000001
1574#define OTP_STATUS 0x00007508
1575#define OTP_STATUS_CMD_DONE 0x00000001
1576#define OTP_ADDRESS 0x0000750c
1577#define OTP_ADDRESS_MAGIC1 0x000000a0
1578#define OTP_ADDRESS_MAGIC2 0x00000080
1579/* 0x7510 unused */
1580
1581#define OTP_READ_DATA 0x00007514
1582/* 0x7518 --> 0x7c04 unused */
1563 1583
1564#define PCIE_TRANSACTION_CFG 0x00007c04 1584#define PCIE_TRANSACTION_CFG 0x00007c04
1565#define PCIE_TRANS_CFG_1SHOT_MSI 0x20000000 1585#define PCIE_TRANS_CFG_1SHOT_MSI 0x20000000
@@ -1568,6 +1588,28 @@
1568#define PCIE_PWR_MGMT_THRESH 0x00007d28 1588#define PCIE_PWR_MGMT_THRESH 0x00007d28
1569#define PCIE_PWR_MGMT_L1_THRESH_MSK 0x0000ff00 1589#define PCIE_PWR_MGMT_L1_THRESH_MSK 0x0000ff00
1570 1590
1591
1592/* OTP bit definitions */
1593#define TG3_OTP_AGCTGT_MASK 0x000000e0
1594#define TG3_OTP_AGCTGT_SHIFT 1
1595#define TG3_OTP_HPFFLTR_MASK 0x00000300
1596#define TG3_OTP_HPFFLTR_SHIFT 1
1597#define TG3_OTP_HPFOVER_MASK 0x00000400
1598#define TG3_OTP_HPFOVER_SHIFT 1
1599#define TG3_OTP_LPFDIS_MASK 0x00000800
1600#define TG3_OTP_LPFDIS_SHIFT 11
1601#define TG3_OTP_VDAC_MASK 0xff000000
1602#define TG3_OTP_VDAC_SHIFT 24
1603#define TG3_OTP_10BTAMP_MASK 0x0000f000
1604#define TG3_OTP_10BTAMP_SHIFT 8
1605#define TG3_OTP_ROFF_MASK 0x00e00000
1606#define TG3_OTP_ROFF_SHIFT 11
1607#define TG3_OTP_RCOFF_MASK 0x001c0000
1608#define TG3_OTP_RCOFF_SHIFT 16
1609
1610#define TG3_OTP_DEFAULT 0x286c1640
1611
1612
1571#define TG3_EEPROM_MAGIC 0x669955aa 1613#define TG3_EEPROM_MAGIC 0x669955aa
1572#define TG3_EEPROM_MAGIC_FW 0xa5000000 1614#define TG3_EEPROM_MAGIC_FW 0xa5000000
1573#define TG3_EEPROM_MAGIC_FW_MSK 0xff000000 1615#define TG3_EEPROM_MAGIC_FW_MSK 0xff000000
@@ -1705,15 +1747,31 @@
1705 1747
1706#define MII_TG3_DSP_RW_PORT 0x15 /* DSP coefficient read/write port */ 1748#define MII_TG3_DSP_RW_PORT 0x15 /* DSP coefficient read/write port */
1707 1749
1708#define MII_TG3_DSP_ADDRESS 0x17 /* DSP address register */
1709#define MII_TG3_EPHY_PTEST 0x17 /* 5906 PHY register */ 1750#define MII_TG3_EPHY_PTEST 0x17 /* 5906 PHY register */
1751#define MII_TG3_DSP_ADDRESS 0x17 /* DSP address register */
1752
1753#define MII_TG3_DSP_TAP1 0x0001
1754#define MII_TG3_DSP_TAP1_AGCTGT_DFLT 0x0007
1755#define MII_TG3_DSP_AADJ1CH0 0x001f
1756#define MII_TG3_DSP_AADJ1CH3 0x601f
1757#define MII_TG3_DSP_AADJ1CH3_ADCCKADJ 0x0002
1758#define MII_TG3_DSP_EXP8 0x0708
1759#define MII_TG3_DSP_EXP8_REJ2MHz 0x0001
1760#define MII_TG3_DSP_EXP8_AEDW 0x0200
1761#define MII_TG3_DSP_EXP75 0x0f75
1762#define MII_TG3_DSP_EXP96 0x0f96
1763#define MII_TG3_DSP_EXP97 0x0f97
1710 1764
1711#define MII_TG3_AUX_CTRL 0x18 /* auxilliary control register */ 1765#define MII_TG3_AUX_CTRL 0x18 /* auxilliary control register */
1712 1766
1713#define MII_TG3_AUXCTL_MISC_WREN 0x8000 1767#define MII_TG3_AUXCTL_MISC_WREN 0x8000
1714#define MII_TG3_AUXCTL_MISC_FORCE_AMDIX 0x0200 1768#define MII_TG3_AUXCTL_MISC_FORCE_AMDIX 0x0200
1715#define MII_TG3_AUXCTL_MISC_RDSEL_MISC 0x7000 1769#define MII_TG3_AUXCTL_MISC_RDSEL_MISC 0x7000
1716#define MII_TG3_AUXCTL_SHDWSEL_MISC 0x0007 1770#define MII_TG3_AUXCTL_SHDWSEL_MISC 0x0007
1771
1772#define MII_TG3_AUXCTL_ACTL_SMDSP_ENA 0x0800
1773#define MII_TG3_AUXCTL_ACTL_TX_6DB 0x0400
1774#define MII_TG3_AUXCTL_SHDWSEL_AUXCTL 0x0000
1717 1775
1718#define MII_TG3_AUX_STAT 0x19 /* auxilliary status register */ 1776#define MII_TG3_AUX_STAT 0x19 /* auxilliary status register */
1719#define MII_TG3_AUX_STAT_LPASS 0x0004 1777#define MII_TG3_AUX_STAT_LPASS 0x0004
@@ -1743,6 +1801,20 @@
1743#define MII_TG3_INT_DUPLEXCHG 0x0008 1801#define MII_TG3_INT_DUPLEXCHG 0x0008
1744#define MII_TG3_INT_ANEG_PAGE_RX 0x0400 1802#define MII_TG3_INT_ANEG_PAGE_RX 0x0400
1745 1803
1804#define MII_TG3_MISC_SHDW 0x1c
1805#define MII_TG3_MISC_SHDW_WREN 0x8000
1806#define MII_TG3_MISC_SHDW_SCR5_SEL 0x1400
1807#define MII_TG3_MISC_SHDW_APD_SEL 0x2800
1808
1809#define MII_TG3_MISC_SHDW_SCR5_C125OE 0x0001
1810#define MII_TG3_MISC_SHDW_SCR5_DLLAPD 0x0002
1811#define MII_TG3_MISC_SHDW_SCR5_SDTL 0x0004
1812#define MII_TG3_MISC_SHDW_SCR5_DLPTLM 0x0008
1813#define MII_TG3_MISC_SHDW_SCR5_LPED 0x0010
1814
1815#define MII_TG3_MISC_SHDW_APD_WKTM_84MS 0x0001
1816#define MII_TG3_MISC_SHDW_APD_ENABLE 0x0020
1817
1746#define MII_TG3_EPHY_TEST 0x1f /* 5906 PHY register */ 1818#define MII_TG3_EPHY_TEST 0x1f /* 5906 PHY register */
1747#define MII_TG3_EPHY_SHADOW_EN 0x80 1819#define MII_TG3_EPHY_SHADOW_EN 0x80
1748 1820
@@ -2473,6 +2545,7 @@ struct tg3 {
2473#define PHY_REV_BCM5411_X0 0x1 /* Found on Netgear GA302T */ 2545#define PHY_REV_BCM5411_X0 0x1 /* Found on Netgear GA302T */
2474 2546
2475 u32 led_ctrl; 2547 u32 led_ctrl;
2548 u32 phy_otp;
2476 u16 pci_cmd; 2549 u16 pci_cmd;
2477 2550
2478 char board_part_number[24]; 2551 char board_part_number[24];
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index 433c994ea9d8..0ab51a0f35fc 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -117,7 +117,7 @@
117 * Official releases will only have an a.b.c version number format. 117 * Official releases will only have an a.b.c version number format.
118 */ 118 */
119 119
120static char version[] __devinitdata = 120static char version[] =
121"Olympic.c v1.0.5 6/04/02 - Peter De Schrijver & Mike Phillips" ; 121"Olympic.c v1.0.5 6/04/02 - Peter De Schrijver & Mike Phillips" ;
122 122
123static char *open_maj_error[] = {"No error", "Lobe Media Test", "Physical Insertion", 123static char *open_maj_error[] = {"No error", "Lobe Media Test", "Physical Insertion",
@@ -290,7 +290,7 @@ op_disable_dev:
290 return i; 290 return i;
291} 291}
292 292
293static int __devinit olympic_init(struct net_device *dev) 293static int olympic_init(struct net_device *dev)
294{ 294{
295 struct olympic_private *olympic_priv; 295 struct olympic_private *olympic_priv;
296 u8 __iomem *olympic_mmio, *init_srb,*adapter_addr; 296 u8 __iomem *olympic_mmio, *init_srb,*adapter_addr;
@@ -434,7 +434,7 @@ static int __devinit olympic_init(struct net_device *dev)
434 434
435} 435}
436 436
437static int __devinit olympic_open(struct net_device *dev) 437static int olympic_open(struct net_device *dev)
438{ 438{
439 struct olympic_private *olympic_priv=netdev_priv(dev); 439 struct olympic_private *olympic_priv=netdev_priv(dev);
440 u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio,*init_srb; 440 u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio,*init_srb;
@@ -1438,13 +1438,18 @@ static void olympic_arb_cmd(struct net_device *dev)
1438 1438
1439 if (olympic_priv->olympic_network_monitor) { 1439 if (olympic_priv->olympic_network_monitor) {
1440 struct trh_hdr *mac_hdr; 1440 struct trh_hdr *mac_hdr;
1441 DECLARE_MAC_BUF(mac);
1442 printk(KERN_WARNING "%s: Received MAC Frame, details: \n",dev->name); 1441 printk(KERN_WARNING "%s: Received MAC Frame, details: \n",dev->name);
1443 mac_hdr = tr_hdr(mac_frame); 1442 mac_hdr = tr_hdr(mac_frame);
1444 printk(KERN_WARNING "%s: MAC Frame Dest. Addr: %s\n", 1443 printk(KERN_WARNING "%s: MAC Frame Dest. Addr: "
1445 dev->name, print_mac(mac, mac_hdr->daddr)); 1444 MAC_FMT " \n", dev->name,
1446 printk(KERN_WARNING "%s: MAC Frame Srce. Addr: %s\n", 1445 mac_hdr->daddr[0], mac_hdr->daddr[1],
1447 dev->name, print_mac(mac, mac_hdr->saddr)); 1446 mac_hdr->daddr[2], mac_hdr->daddr[3],
1447 mac_hdr->daddr[4], mac_hdr->daddr[5]);
1448 printk(KERN_WARNING "%s: MAC Frame Srce. Addr: "
1449 MAC_FMT " \n", dev->name,
1450 mac_hdr->saddr[0], mac_hdr->saddr[1],
1451 mac_hdr->saddr[2], mac_hdr->saddr[3],
1452 mac_hdr->saddr[4], mac_hdr->saddr[5]);
1448 } 1453 }
1449 netif_rx(mac_frame); 1454 netif_rx(mac_frame);
1450 dev->last_rx = jiffies; 1455 dev->last_rx = jiffies;
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index 8909050b8ea7..5f1c5072b96f 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -3413,7 +3413,7 @@ static int smctr_make_tx_status_code(struct net_device *dev,
3413 tsv->svi = TRANSMIT_STATUS_CODE; 3413 tsv->svi = TRANSMIT_STATUS_CODE;
3414 tsv->svl = S_TRANSMIT_STATUS_CODE; 3414 tsv->svl = S_TRANSMIT_STATUS_CODE;
3415 3415
3416 tsv->svv[0] = ((tx_fstatus & 0x0100 >> 6) || IBM_PASS_SOURCE_ADDR); 3416 tsv->svv[0] = ((tx_fstatus & 0x0100 >> 6) | IBM_PASS_SOURCE_ADDR);
3417 3417
3418 /* Stripped frame status of Transmitted Frame */ 3418 /* Stripped frame status of Transmitted Frame */
3419 tsv->svv[1] = tx_fstatus & 0xff; 3419 tsv->svv[1] = tx_fstatus & 0xff;
diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
index 206918bad539..da2206f6021d 100644
--- a/drivers/net/tulip/eeprom.c
+++ b/drivers/net/tulip/eeprom.c
@@ -343,6 +343,12 @@ int __devinit tulip_read_eeprom(struct net_device *dev, int location, int addr_l
343 void __iomem *ee_addr = tp->base_addr + CSR9; 343 void __iomem *ee_addr = tp->base_addr + CSR9;
344 int read_cmd = location | (EE_READ_CMD << addr_len); 344 int read_cmd = location | (EE_READ_CMD << addr_len);
345 345
346 /* If location is past the end of what we can address, don't
347 * read some other location (ie truncate). Just return zero.
348 */
349 if (location > (1 << addr_len) - 1)
350 return 0;
351
346 iowrite32(EE_ENB & ~EE_CS, ee_addr); 352 iowrite32(EE_ENB & ~EE_CS, ee_addr);
347 iowrite32(EE_ENB, ee_addr); 353 iowrite32(EE_ENB, ee_addr);
348 354
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index ed600bf56e78..82f404b76d81 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1437,6 +1437,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1437 EEPROM. 1437 EEPROM.
1438 */ 1438 */
1439 ee_data = tp->eeprom; 1439 ee_data = tp->eeprom;
1440 memset(ee_data, 0, sizeof(tp->eeprom));
1440 sum = 0; 1441 sum = 0;
1441 if (chip_idx == LC82C168) { 1442 if (chip_idx == LC82C168) {
1442 for (i = 0; i < 3; i++) { 1443 for (i = 0; i < 3; i++) {
@@ -1458,8 +1459,12 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1458 /* A serial EEPROM interface, we read now and sort it out later. */ 1459 /* A serial EEPROM interface, we read now and sort it out later. */
1459 int sa_offset = 0; 1460 int sa_offset = 0;
1460 int ee_addr_size = tulip_read_eeprom(dev, 0xff, 8) & 0x40000 ? 8 : 6; 1461 int ee_addr_size = tulip_read_eeprom(dev, 0xff, 8) & 0x40000 ? 8 : 6;
1462 int ee_max_addr = ((1 << ee_addr_size) - 1) * sizeof(u16);
1461 1463
1462 for (i = 0; i < sizeof(tp->eeprom); i+=2) { 1464 if (ee_max_addr > sizeof(tp->eeprom))
1465 ee_max_addr = sizeof(tp->eeprom);
1466
1467 for (i = 0; i < ee_max_addr ; i += sizeof(u16)) {
1463 u16 data = tulip_read_eeprom(dev, i/2, ee_addr_size); 1468 u16 data = tulip_read_eeprom(dev, i/2, ee_addr_size);
1464 ee_data[i] = data & 0xff; 1469 ee_data[i] = data & 0xff;
1465 ee_data[i + 1] = data >> 8; 1470 ee_data[i + 1] = data >> 8;
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index a12c9c41b217..0604f3faf043 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -129,7 +129,7 @@ config USB_USBNET
129 129
130config USB_NET_AX8817X 130config USB_NET_AX8817X
131 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" 131 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters"
132 depends on USB_USBNET && NET_ETHERNET 132 depends on USB_USBNET
133 select CRC32 133 select CRC32
134 default y 134 default y
135 help 135 help
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 4b131a6c6b70..01660f68943a 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -341,7 +341,7 @@ static void dm9601_set_multicast(struct net_device *net)
341 /* We use the 20 byte dev->data for our 8 byte filter buffer 341 /* We use the 20 byte dev->data for our 8 byte filter buffer
342 * to avoid allocating memory that is tricky to free later */ 342 * to avoid allocating memory that is tricky to free later */
343 u8 *hashes = (u8 *) & dev->data; 343 u8 *hashes = (u8 *) & dev->data;
344 u8 rx_ctl = 0x01; 344 u8 rx_ctl = 0x31;
345 345
346 memset(hashes, 0x00, DM_MCAST_SIZE); 346 memset(hashes, 0x00, DM_MCAST_SIZE);
347 hashes[DM_MCAST_SIZE - 1] |= 0x80; /* broadcast address */ 347 hashes[DM_MCAST_SIZE - 1] |= 0x80; /* broadcast address */
@@ -354,7 +354,7 @@ static void dm9601_set_multicast(struct net_device *net)
354 struct dev_mc_list *mc_list = net->mc_list; 354 struct dev_mc_list *mc_list = net->mc_list;
355 int i; 355 int i;
356 356
357 for (i = 0; i < net->mc_count; i++) { 357 for (i = 0; i < net->mc_count; i++, mc_list = mc_list->next) {
358 u32 crc = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26; 358 u32 crc = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26;
359 hashes[crc >> 3] |= 1 << (crc & 0x7); 359 hashes[crc >> 3] |= 1 << (crc & 0x7);
360 } 360 }
@@ -562,6 +562,10 @@ static const struct usb_device_id products[] = {
562 USB_DEVICE(0x0a46, 0x8515), /* ADMtek ADM8515 USB NIC */ 562 USB_DEVICE(0x0a46, 0x8515), /* ADMtek ADM8515 USB NIC */
563 .driver_info = (unsigned long)&dm9601_info, 563 .driver_info = (unsigned long)&dm9601_info,
564 }, 564 },
565 {
566 USB_DEVICE(0x0a47, 0x9601), /* Hirose USB-100 */
567 .driver_info = (unsigned long)&dm9601_info,
568 },
565 {}, // END 569 {}, // END
566}; 570};
567 571
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index d1ed68a11e70..b588c890ea70 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -1128,12 +1128,8 @@ pegasus_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1128{ 1128{
1129 pegasus_t *pegasus; 1129 pegasus_t *pegasus;
1130 1130
1131 if (in_atomic())
1132 return 0;
1133
1134 pegasus = netdev_priv(dev); 1131 pegasus = netdev_priv(dev);
1135 mii_ethtool_gset(&pegasus->mii, ecmd); 1132 mii_ethtool_gset(&pegasus->mii, ecmd);
1136
1137 return 0; 1133 return 0;
1138} 1134}
1139 1135
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 727547a28992..369c731114b3 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -283,7 +283,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
283 struct rndis_set_c *set_c; 283 struct rndis_set_c *set_c;
284 struct rndis_halt *halt; 284 struct rndis_halt *halt;
285 } u; 285 } u;
286 u32 tmp, *phym; 286 u32 tmp, phym_unspec, *phym;
287 int reply_len; 287 int reply_len;
288 unsigned char *bp; 288 unsigned char *bp;
289 289
@@ -363,12 +363,15 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
363 goto halt_fail_and_release; 363 goto halt_fail_and_release;
364 364
365 /* Check physical medium */ 365 /* Check physical medium */
366 phym = NULL;
366 reply_len = sizeof *phym; 367 reply_len = sizeof *phym;
367 retval = rndis_query(dev, intf, u.buf, OID_GEN_PHYSICAL_MEDIUM, 368 retval = rndis_query(dev, intf, u.buf, OID_GEN_PHYSICAL_MEDIUM,
368 0, (void **) &phym, &reply_len); 369 0, (void **) &phym, &reply_len);
369 if (retval != 0) 370 if (retval != 0 || !phym) {
370 /* OID is optional so don't fail here. */ 371 /* OID is optional so don't fail here. */
371 *phym = RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED; 372 phym_unspec = RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED;
373 phym = &phym_unspec;
374 }
372 if ((flags & FLAG_RNDIS_PHYM_WIRELESS) && 375 if ((flags & FLAG_RNDIS_PHYM_WIRELESS) &&
373 *phym != RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) { 376 *phym != RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) {
374 if (netif_msg_probe(dev)) 377 if (netif_msg_probe(dev))
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b58472cf76f8..555b70c8b863 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -234,11 +234,12 @@ static int start_xmit(struct sk_buff *skb, struct net_device *dev)
234 struct scatterlist sg[1+MAX_SKB_FRAGS]; 234 struct scatterlist sg[1+MAX_SKB_FRAGS];
235 struct virtio_net_hdr *hdr; 235 struct virtio_net_hdr *hdr;
236 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest; 236 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
237 DECLARE_MAC_BUF(mac);
238 237
239 sg_init_table(sg, 1+MAX_SKB_FRAGS); 238 sg_init_table(sg, 1+MAX_SKB_FRAGS);
240 239
241 pr_debug("%s: xmit %p %s\n", dev->name, skb, print_mac(mac, dest)); 240 pr_debug("%s: xmit %p " MAC_FMT "\n", dev->name, skb,
241 dest[0], dest[1], dest[2],
242 dest[3], dest[4], dest[5]);
242 243
243 /* Encode metadata header at front. */ 244 /* Encode metadata header at front. */
244 hdr = skb_vnet_hdr(skb); 245 hdr = skb_vnet_hdr(skb);
@@ -284,7 +285,6 @@ again:
284 /* Activate callback for using skbs: if this returns false it 285 /* Activate callback for using skbs: if this returns false it
285 * means some were used in the meantime. */ 286 * means some were used in the meantime. */
286 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { 287 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) {
287 printk("Unlikely: restart svq race\n");
288 vi->svq->vq_ops->disable_cb(vi->svq); 288 vi->svq->vq_ops->disable_cb(vi->svq);
289 netif_start_queue(dev); 289 netif_start_queue(dev);
290 goto again; 290 goto again;
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index fb37b8095231..824df3b5ea49 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -58,7 +58,7 @@ struct lapbethdev {
58 struct net_device_stats stats; /* some statistics */ 58 struct net_device_stats stats; /* some statistics */
59}; 59};
60 60
61static struct list_head lapbeth_devices = LIST_HEAD_INIT(lapbeth_devices); 61static LIST_HEAD(lapbeth_devices);
62 62
63/* ------------------------------------------------------------------------ */ 63/* ------------------------------------------------------------------------ */
64 64
diff --git a/drivers/net/wireless/arlan-proc.c b/drivers/net/wireless/arlan-proc.c
index c6e70dbc5de8..2ab1d59870f4 100644
--- a/drivers/net/wireless/arlan-proc.c
+++ b/drivers/net/wireless/arlan-proc.c
@@ -1202,13 +1202,6 @@ static ctl_table arlan_table[MAX_ARLANS + 1] =
1202 { .ctl_name = 0 } 1202 { .ctl_name = 0 }
1203}; 1203};
1204#endif 1204#endif
1205#else
1206
1207static ctl_table arlan_table[MAX_ARLANS + 1] =
1208{
1209 { .ctl_name = 0 }
1210};
1211#endif
1212 1205
1213 1206
1214// static int mmtu = 1234; 1207// static int mmtu = 1234;
@@ -1233,7 +1226,6 @@ static ctl_table arlan_root_table[] =
1233//}; 1226//};
1234 1227
1235 1228
1236#ifdef CONFIG_PROC_FS
1237static struct ctl_table_header *arlan_device_sysctl_header; 1229static struct ctl_table_header *arlan_device_sysctl_header;
1238 1230
1239int __init init_arlan_proc(void) 1231int __init init_arlan_proc(void)
diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index e38ed0fe72e9..7fca2ebc747f 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -618,6 +618,7 @@ void b43_debugfs_remove_device(struct b43_wldev *dev)
618 kfree(e); 618 kfree(e);
619} 619}
620 620
621/* Called with IRQs disabled. */
621void b43_debugfs_log_txstat(struct b43_wldev *dev, 622void b43_debugfs_log_txstat(struct b43_wldev *dev,
622 const struct b43_txstatus *status) 623 const struct b43_txstatus *status)
623{ 624{
@@ -629,8 +630,7 @@ void b43_debugfs_log_txstat(struct b43_wldev *dev,
629 if (!e) 630 if (!e)
630 return; 631 return;
631 log = &e->txstatlog; 632 log = &e->txstatlog;
632 B43_WARN_ON(!irqs_disabled()); 633 spin_lock(&log->lock); /* IRQs are already disabled. */
633 spin_lock(&log->lock);
634 i = log->end + 1; 634 i = log->end + 1;
635 if (i == B43_NR_LOGGED_TXSTATUS) 635 if (i == B43_NR_LOGGED_TXSTATUS)
636 i = 0; 636 i = 0;
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index 3dfb28a34be9..948eb1fe916b 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -560,7 +560,7 @@ static int b43_dmacontroller_tx_reset(struct b43_wldev *dev, u16 mmio_base,
560/* Check if a DMA mapping address is invalid. */ 560/* Check if a DMA mapping address is invalid. */
561static bool b43_dma_mapping_error(struct b43_dmaring *ring, 561static bool b43_dma_mapping_error(struct b43_dmaring *ring,
562 dma_addr_t addr, 562 dma_addr_t addr,
563 size_t buffersize) 563 size_t buffersize, bool dma_to_device)
564{ 564{
565 if (unlikely(dma_mapping_error(addr))) 565 if (unlikely(dma_mapping_error(addr)))
566 return 1; 566 return 1;
@@ -568,11 +568,11 @@ static bool b43_dma_mapping_error(struct b43_dmaring *ring,
568 switch (ring->type) { 568 switch (ring->type) {
569 case B43_DMA_30BIT: 569 case B43_DMA_30BIT:
570 if ((u64)addr + buffersize > (1ULL << 30)) 570 if ((u64)addr + buffersize > (1ULL << 30))
571 return 1; 571 goto address_error;
572 break; 572 break;
573 case B43_DMA_32BIT: 573 case B43_DMA_32BIT:
574 if ((u64)addr + buffersize > (1ULL << 32)) 574 if ((u64)addr + buffersize > (1ULL << 32))
575 return 1; 575 goto address_error;
576 break; 576 break;
577 case B43_DMA_64BIT: 577 case B43_DMA_64BIT:
578 /* Currently we can't have addresses beyond 578 /* Currently we can't have addresses beyond
@@ -582,6 +582,12 @@ static bool b43_dma_mapping_error(struct b43_dmaring *ring,
582 582
583 /* The address is OK. */ 583 /* The address is OK. */
584 return 0; 584 return 0;
585
586address_error:
587 /* We can't support this address. Unmap it again. */
588 unmap_descbuffer(ring, addr, buffersize, dma_to_device);
589
590 return 1;
585} 591}
586 592
587static int setup_rx_descbuffer(struct b43_dmaring *ring, 593static int setup_rx_descbuffer(struct b43_dmaring *ring,
@@ -599,7 +605,7 @@ static int setup_rx_descbuffer(struct b43_dmaring *ring,
599 if (unlikely(!skb)) 605 if (unlikely(!skb))
600 return -ENOMEM; 606 return -ENOMEM;
601 dmaaddr = map_descbuffer(ring, skb->data, ring->rx_buffersize, 0); 607 dmaaddr = map_descbuffer(ring, skb->data, ring->rx_buffersize, 0);
602 if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize)) { 608 if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize, 0)) {
603 /* ugh. try to realloc in zone_dma */ 609 /* ugh. try to realloc in zone_dma */
604 gfp_flags |= GFP_DMA; 610 gfp_flags |= GFP_DMA;
605 611
@@ -612,7 +618,8 @@ static int setup_rx_descbuffer(struct b43_dmaring *ring,
612 ring->rx_buffersize, 0); 618 ring->rx_buffersize, 0);
613 } 619 }
614 620
615 if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize)) { 621 if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize, 0)) {
622 b43err(ring->dev->wl, "RX DMA buffer allocation failed\n");
616 dev_kfree_skb_any(skb); 623 dev_kfree_skb_any(skb);
617 return -EIO; 624 return -EIO;
618 } 625 }
@@ -852,7 +859,8 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
852 b43_txhdr_size(dev), 859 b43_txhdr_size(dev),
853 DMA_TO_DEVICE); 860 DMA_TO_DEVICE);
854 861
855 if (b43_dma_mapping_error(ring, dma_test, b43_txhdr_size(dev))) { 862 if (b43_dma_mapping_error(ring, dma_test,
863 b43_txhdr_size(dev), 1)) {
856 /* ugh realloc */ 864 /* ugh realloc */
857 kfree(ring->txhdr_cache); 865 kfree(ring->txhdr_cache);
858 ring->txhdr_cache = kcalloc(nr_slots, 866 ring->txhdr_cache = kcalloc(nr_slots,
@@ -867,8 +875,12 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
867 DMA_TO_DEVICE); 875 DMA_TO_DEVICE);
868 876
869 if (b43_dma_mapping_error(ring, dma_test, 877 if (b43_dma_mapping_error(ring, dma_test,
870 b43_txhdr_size(dev))) 878 b43_txhdr_size(dev), 1)) {
879
880 b43err(dev->wl,
881 "TXHDR DMA allocation failed\n");
871 goto err_kfree_txhdr_cache; 882 goto err_kfree_txhdr_cache;
883 }
872 } 884 }
873 885
874 dma_unmap_single(dev->dev->dev, 886 dma_unmap_single(dev->dev->dev,
@@ -1189,7 +1201,7 @@ static int dma_tx_fragment(struct b43_dmaring *ring,
1189 1201
1190 meta_hdr->dmaaddr = map_descbuffer(ring, (unsigned char *)header, 1202 meta_hdr->dmaaddr = map_descbuffer(ring, (unsigned char *)header,
1191 hdrsize, 1); 1203 hdrsize, 1);
1192 if (b43_dma_mapping_error(ring, meta_hdr->dmaaddr, hdrsize)) { 1204 if (b43_dma_mapping_error(ring, meta_hdr->dmaaddr, hdrsize, 1)) {
1193 ring->current_slot = old_top_slot; 1205 ring->current_slot = old_top_slot;
1194 ring->used_slots = old_used_slots; 1206 ring->used_slots = old_used_slots;
1195 return -EIO; 1207 return -EIO;
@@ -1208,7 +1220,7 @@ static int dma_tx_fragment(struct b43_dmaring *ring,
1208 1220
1209 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1); 1221 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
1210 /* create a bounce buffer in zone_dma on mapping failure. */ 1222 /* create a bounce buffer in zone_dma on mapping failure. */
1211 if (b43_dma_mapping_error(ring, meta->dmaaddr, skb->len)) { 1223 if (b43_dma_mapping_error(ring, meta->dmaaddr, skb->len, 1)) {
1212 bounce_skb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA); 1224 bounce_skb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA);
1213 if (!bounce_skb) { 1225 if (!bounce_skb) {
1214 ring->current_slot = old_top_slot; 1226 ring->current_slot = old_top_slot;
@@ -1222,7 +1234,7 @@ static int dma_tx_fragment(struct b43_dmaring *ring,
1222 skb = bounce_skb; 1234 skb = bounce_skb;
1223 meta->skb = skb; 1235 meta->skb = skb;
1224 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1); 1236 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
1225 if (b43_dma_mapping_error(ring, meta->dmaaddr, skb->len)) { 1237 if (b43_dma_mapping_error(ring, meta->dmaaddr, skb->len, 1)) {
1226 ring->current_slot = old_top_slot; 1238 ring->current_slot = old_top_slot;
1227 ring->used_slots = old_used_slots; 1239 ring->used_slots = old_used_slots;
1228 err = -EIO; 1240 err = -EIO;
@@ -1337,6 +1349,7 @@ out_unlock:
1337 return err; 1349 return err;
1338} 1350}
1339 1351
1352/* Called with IRQs disabled. */
1340void b43_dma_handle_txstatus(struct b43_wldev *dev, 1353void b43_dma_handle_txstatus(struct b43_wldev *dev,
1341 const struct b43_txstatus *status) 1354 const struct b43_txstatus *status)
1342{ 1355{
@@ -1349,8 +1362,8 @@ void b43_dma_handle_txstatus(struct b43_wldev *dev,
1349 ring = parse_cookie(dev, status->cookie, &slot); 1362 ring = parse_cookie(dev, status->cookie, &slot);
1350 if (unlikely(!ring)) 1363 if (unlikely(!ring))
1351 return; 1364 return;
1352 B43_WARN_ON(!irqs_disabled()); 1365
1353 spin_lock(&ring->lock); 1366 spin_lock(&ring->lock); /* IRQs are already disabled. */
1354 1367
1355 B43_WARN_ON(!ring->tx); 1368 B43_WARN_ON(!ring->tx);
1356 ops = ring->ops; 1369 ops = ring->ops;
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 51dfce16178a..c73a75b24cd6 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -2049,7 +2049,6 @@ void b43_mac_enable(struct b43_wldev *dev)
2049{ 2049{
2050 dev->mac_suspended--; 2050 dev->mac_suspended--;
2051 B43_WARN_ON(dev->mac_suspended < 0); 2051 B43_WARN_ON(dev->mac_suspended < 0);
2052 B43_WARN_ON(irqs_disabled());
2053 if (dev->mac_suspended == 0) { 2052 if (dev->mac_suspended == 0) {
2054 b43_write32(dev, B43_MMIO_MACCTL, 2053 b43_write32(dev, B43_MMIO_MACCTL,
2055 b43_read32(dev, B43_MMIO_MACCTL) 2054 b43_read32(dev, B43_MMIO_MACCTL)
@@ -2075,7 +2074,6 @@ void b43_mac_suspend(struct b43_wldev *dev)
2075 u32 tmp; 2074 u32 tmp;
2076 2075
2077 might_sleep(); 2076 might_sleep();
2078 B43_WARN_ON(irqs_disabled());
2079 B43_WARN_ON(dev->mac_suspended < 0); 2077 B43_WARN_ON(dev->mac_suspended < 0);
2080 2078
2081 if (dev->mac_suspended == 0) { 2079 if (dev->mac_suspended == 0) {
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c
index b79a6bd5396d..371e4a119511 100644
--- a/drivers/net/wireless/b43/pcmcia.c
+++ b/drivers/net/wireless/b43/pcmcia.c
@@ -91,6 +91,8 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
91 91
92 dev->conf.ConfigBase = parse.config.base; 92 dev->conf.ConfigBase = parse.config.base;
93 dev->conf.Present = parse.config.rmask[0]; 93 dev->conf.Present = parse.config.rmask[0];
94 dev->conf.Attributes = CONF_ENABLE_IRQ;
95 dev->conf.IntType = INT_MEMORY_AND_IO;
94 96
95 dev->io.BasePort2 = 0; 97 dev->io.BasePort2 = 0;
96 dev->io.NumPorts2 = 0; 98 dev->io.NumPorts2 = 0;
@@ -112,8 +114,8 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
112 if (res != CS_SUCCESS) 114 if (res != CS_SUCCESS)
113 goto err_disable; 115 goto err_disable;
114 116
115 dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_FIRST_SHARED; 117 dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
116 dev->irq.IRQInfo1 = IRQ_LEVEL_ID | IRQ_SHARE_ID; 118 dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
117 dev->irq.Handler = NULL; /* The handler is registered later. */ 119 dev->irq.Handler = NULL; /* The handler is registered later. */
118 dev->irq.Instance = NULL; 120 dev->irq.Instance = NULL;
119 res = pcmcia_request_irq(dev, &dev->irq); 121 res = pcmcia_request_irq(dev, &dev->irq);
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
index 49978bdb4324..4fd73809602e 100644
--- a/drivers/net/wireless/hostap/hostap_80211_rx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_rx.c
@@ -635,7 +635,6 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
635{ 635{
636 struct ieee80211_hdr_4addr *hdr; 636 struct ieee80211_hdr_4addr *hdr;
637 int res, hdrlen; 637 int res, hdrlen;
638 DECLARE_MAC_BUF(mac);
639 638
640 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) 639 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
641 return 0; 640 return 0;
@@ -647,8 +646,10 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
647 strcmp(crypt->ops->name, "TKIP") == 0) { 646 strcmp(crypt->ops->name, "TKIP") == 0) {
648 if (net_ratelimit()) { 647 if (net_ratelimit()) {
649 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " 648 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
650 "received packet from %s\n", 649 "received packet from " MAC_FMT "\n",
651 local->dev->name, print_mac(mac, hdr->addr2)); 650 local->dev->name,
651 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
652 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
652 } 653 }
653 return -1; 654 return -1;
654 } 655 }
@@ -657,9 +658,12 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
657 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); 658 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
658 atomic_dec(&crypt->refcnt); 659 atomic_dec(&crypt->refcnt);
659 if (res < 0) { 660 if (res < 0) {
660 printk(KERN_DEBUG "%s: decryption failed (SA=%s" 661 printk(KERN_DEBUG "%s: decryption failed (SA=" MAC_FMT
661 ") res=%d\n", 662 ") res=%d\n",
662 local->dev->name, print_mac(mac, hdr->addr2), res); 663 local->dev->name,
664 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
665 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
666 res);
663 local->comm_tallies.rx_discards_wep_undecryptable++; 667 local->comm_tallies.rx_discards_wep_undecryptable++;
664 return -1; 668 return -1;
665 } 669 }
@@ -721,7 +725,6 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
721 struct ieee80211_crypt_data *crypt = NULL; 725 struct ieee80211_crypt_data *crypt = NULL;
722 void *sta = NULL; 726 void *sta = NULL;
723 int keyidx = 0; 727 int keyidx = 0;
724 DECLARE_MAC_BUF(mac);
725 728
726 iface = netdev_priv(dev); 729 iface = netdev_priv(dev);
727 local = iface->local; 730 local = iface->local;
@@ -798,8 +801,10 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
798 * frames silently instead of filling system log with 801 * frames silently instead of filling system log with
799 * these reports. */ 802 * these reports. */
800 printk(KERN_DEBUG "%s: WEP decryption failed (not set)" 803 printk(KERN_DEBUG "%s: WEP decryption failed (not set)"
801 " (SA=%s)\n", 804 " (SA=" MAC_FMT ")\n",
802 local->dev->name, print_mac(mac, hdr->addr2)); 805 local->dev->name,
806 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
807 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
803#endif 808#endif
804 local->comm_tallies.rx_discards_wep_undecryptable++; 809 local->comm_tallies.rx_discards_wep_undecryptable++;
805 goto rx_dropped; 810 goto rx_dropped;
@@ -813,8 +818,9 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
813 (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0) 818 (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0)
814 { 819 {
815 printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth " 820 printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
816 "from %s\n", dev->name, 821 "from " MAC_FMT "\n", dev->name,
817 print_mac(mac, hdr->addr2)); 822 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
823 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
818 /* TODO: could inform hostapd about this so that it 824 /* TODO: could inform hostapd about this so that it
819 * could send auth failure report */ 825 * could send auth failure report */
820 goto rx_dropped; 826 goto rx_dropped;
@@ -982,8 +988,10 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
982 "unencrypted EAPOL frame\n", local->dev->name); 988 "unencrypted EAPOL frame\n", local->dev->name);
983 } else { 989 } else {
984 printk(KERN_DEBUG "%s: encryption configured, but RX " 990 printk(KERN_DEBUG "%s: encryption configured, but RX "
985 "frame not encrypted (SA=%s)\n", 991 "frame not encrypted (SA=" MAC_FMT ")\n",
986 local->dev->name, print_mac(mac, hdr->addr2)); 992 local->dev->name,
993 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
994 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
987 goto rx_dropped; 995 goto rx_dropped;
988 } 996 }
989 } 997 }
@@ -992,9 +1000,10 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
992 !hostap_is_eapol_frame(local, skb)) { 1000 !hostap_is_eapol_frame(local, skb)) {
993 if (net_ratelimit()) { 1001 if (net_ratelimit()) {
994 printk(KERN_DEBUG "%s: dropped unencrypted RX data " 1002 printk(KERN_DEBUG "%s: dropped unencrypted RX data "
995 "frame from %s" 1003 "frame from " MAC_FMT " (drop_unencrypted=1)\n",
996 " (drop_unencrypted=1)\n", 1004 dev->name,
997 dev->name, print_mac(mac, hdr->addr2)); 1005 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1006 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
998 } 1007 }
999 goto rx_dropped; 1008 goto rx_dropped;
1000 } 1009 }
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
index e7afc3ec3e6d..921c984416f8 100644
--- a/drivers/net/wireless/hostap/hostap_80211_tx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_tx.c
@@ -314,7 +314,6 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
314 struct ieee80211_hdr_4addr *hdr; 314 struct ieee80211_hdr_4addr *hdr;
315 u16 fc; 315 u16 fc;
316 int prefix_len, postfix_len, hdr_len, res; 316 int prefix_len, postfix_len, hdr_len, res;
317 DECLARE_MAC_BUF(mac);
318 317
319 iface = netdev_priv(skb->dev); 318 iface = netdev_priv(skb->dev);
320 local = iface->local; 319 local = iface->local;
@@ -329,8 +328,10 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
329 hdr = (struct ieee80211_hdr_4addr *) skb->data; 328 hdr = (struct ieee80211_hdr_4addr *) skb->data;
330 if (net_ratelimit()) { 329 if (net_ratelimit()) {
331 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " 330 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
332 "TX packet to %s\n", 331 "TX packet to " MAC_FMT "\n",
333 local->dev->name, print_mac(mac, hdr->addr1)); 332 local->dev->name,
333 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
334 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
334 } 335 }
335 kfree_skb(skb); 336 kfree_skb(skb);
336 return NULL; 337 return NULL;
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index ad040a3bb8a7..0acd9589c48c 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -632,7 +632,6 @@ static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)
632 __le16 *pos; 632 __le16 *pos;
633 struct sta_info *sta = NULL; 633 struct sta_info *sta = NULL;
634 char *txt = NULL; 634 char *txt = NULL;
635 DECLARE_MAC_BUF(mac);
636 635
637 if (ap->local->hostapd) { 636 if (ap->local->hostapd) {
638 dev_kfree_skb(skb); 637 dev_kfree_skb(skb);
@@ -684,10 +683,12 @@ static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)
684 if (sta) 683 if (sta)
685 atomic_dec(&sta->users); 684 atomic_dec(&sta->users);
686 if (txt) { 685 if (txt) {
687 PDEBUG(DEBUG_AP, "%s: %s auth_cb - alg=%d " 686 PDEBUG(DEBUG_AP, "%s: " MAC_FMT " auth_cb - alg=%d "
688 "trans#=%d status=%d - %s\n", 687 "trans#=%d status=%d - %s\n",
689 dev->name, print_mac(mac, hdr->addr1), auth_alg, 688 dev->name,
690 auth_transaction, status, txt); 689 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
690 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5],
691 auth_alg, auth_transaction, status, txt);
691 } 692 }
692 dev_kfree_skb(skb); 693 dev_kfree_skb(skb);
693} 694}
@@ -703,7 +704,6 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
703 __le16 *pos; 704 __le16 *pos;
704 struct sta_info *sta = NULL; 705 struct sta_info *sta = NULL;
705 char *txt = NULL; 706 char *txt = NULL;
706 DECLARE_MAC_BUF(mac);
707 707
708 if (ap->local->hostapd) { 708 if (ap->local->hostapd) {
709 dev_kfree_skb(skb); 709 dev_kfree_skb(skb);
@@ -754,8 +754,11 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
754 if (sta) 754 if (sta)
755 atomic_dec(&sta->users); 755 atomic_dec(&sta->users);
756 if (txt) { 756 if (txt) {
757 PDEBUG(DEBUG_AP, "%s: %s assoc_cb - %s\n", 757 PDEBUG(DEBUG_AP, "%s: " MAC_FMT " assoc_cb - %s\n",
758 dev->name, print_mac(mac, hdr->addr1), txt); 758 dev->name,
759 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
760 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5],
761 txt);
759 } 762 }
760 dev_kfree_skb(skb); 763 dev_kfree_skb(skb);
761} 764}
@@ -767,7 +770,6 @@ static void hostap_ap_tx_cb_poll(struct sk_buff *skb, int ok, void *data)
767 struct ap_data *ap = data; 770 struct ap_data *ap = data;
768 struct ieee80211_hdr_4addr *hdr; 771 struct ieee80211_hdr_4addr *hdr;
769 struct sta_info *sta; 772 struct sta_info *sta;
770 DECLARE_MAC_BUF(mac);
771 773
772 if (skb->len < 24) 774 if (skb->len < 24)
773 goto fail; 775 goto fail;
@@ -779,9 +781,11 @@ static void hostap_ap_tx_cb_poll(struct sk_buff *skb, int ok, void *data)
779 sta->flags &= ~WLAN_STA_PENDING_POLL; 781 sta->flags &= ~WLAN_STA_PENDING_POLL;
780 spin_unlock(&ap->sta_table_lock); 782 spin_unlock(&ap->sta_table_lock);
781 } else { 783 } else {
782 PDEBUG(DEBUG_AP, "%s: STA %s" 784 PDEBUG(DEBUG_AP, "%s: STA " MAC_FMT
783 " did not ACK activity poll frame\n", 785 " did not ACK activity poll frame\n",
784 ap->local->dev->name, print_mac(mac, hdr->addr1)); 786 ap->local->dev->name,
787 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
788 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
785 } 789 }
786 790
787 fail: 791 fail:
@@ -1306,7 +1310,6 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1306 struct sta_info *sta = NULL; 1310 struct sta_info *sta = NULL;
1307 struct ieee80211_crypt_data *crypt; 1311 struct ieee80211_crypt_data *crypt;
1308 char *txt = ""; 1312 char *txt = "";
1309 DECLARE_MAC_BUF(mac);
1310 1313
1311 len = skb->len - IEEE80211_MGMT_HDR_LEN; 1314 len = skb->len - IEEE80211_MGMT_HDR_LEN;
1312 1315
@@ -1315,8 +1318,9 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1315 1318
1316 if (len < 6) { 1319 if (len < 6) {
1317 PDEBUG(DEBUG_AP, "%s: handle_authen - too short payload " 1320 PDEBUG(DEBUG_AP, "%s: handle_authen - too short payload "
1318 "(len=%d) from %s\n", dev->name, len, 1321 "(len=%d) from " MAC_FMT "\n", dev->name, len,
1319 print_mac(mac, hdr->addr2)); 1322 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1323 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
1320 return; 1324 return;
1321 } 1325 }
1322 1326
@@ -1381,8 +1385,10 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1381 if (time_after(jiffies, sta->u.ap.last_beacon + 1385 if (time_after(jiffies, sta->u.ap.last_beacon +
1382 (10 * sta->listen_interval * HZ) / 1024)) { 1386 (10 * sta->listen_interval * HZ) / 1024)) {
1383 PDEBUG(DEBUG_AP, "%s: no beacons received for a while," 1387 PDEBUG(DEBUG_AP, "%s: no beacons received for a while,"
1384 " assuming AP %s is now STA\n", 1388 " assuming AP " MAC_FMT " is now STA\n",
1385 dev->name, print_mac(mac, sta->addr)); 1389 dev->name,
1390 sta->addr[0], sta->addr[1], sta->addr[2],
1391 sta->addr[3], sta->addr[4], sta->addr[5]);
1386 sta->ap = 0; 1392 sta->ap = 0;
1387 sta->flags = 0; 1393 sta->flags = 0;
1388 sta->u.sta.challenge = NULL; 1394 sta->u.sta.challenge = NULL;
@@ -1497,10 +1503,13 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1497 } 1503 }
1498 1504
1499 if (resp) { 1505 if (resp) {
1500 PDEBUG(DEBUG_AP, "%s: %s auth (alg=%d " 1506 PDEBUG(DEBUG_AP, "%s: " MAC_FMT " auth (alg=%d "
1501 "trans#=%d stat=%d len=%d fc=%04x) ==> %d (%s)\n", 1507 "trans#=%d stat=%d len=%d fc=%04x) ==> %d (%s)\n",
1502 dev->name, print_mac(mac, hdr->addr2), auth_alg, 1508 dev->name,
1503 auth_transaction, status_code, len, fc, resp, txt); 1509 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1510 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1511 auth_alg, auth_transaction, status_code, len,
1512 fc, resp, txt);
1504 } 1513 }
1505} 1514}
1506 1515
@@ -1519,14 +1528,15 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
1519 int send_deauth = 0; 1528 int send_deauth = 0;
1520 char *txt = ""; 1529 char *txt = "";
1521 u8 prev_ap[ETH_ALEN]; 1530 u8 prev_ap[ETH_ALEN];
1522 DECLARE_MAC_BUF(mac);
1523 1531
1524 left = len = skb->len - IEEE80211_MGMT_HDR_LEN; 1532 left = len = skb->len - IEEE80211_MGMT_HDR_LEN;
1525 1533
1526 if (len < (reassoc ? 10 : 4)) { 1534 if (len < (reassoc ? 10 : 4)) {
1527 PDEBUG(DEBUG_AP, "%s: handle_assoc - too short payload " 1535 PDEBUG(DEBUG_AP, "%s: handle_assoc - too short payload "
1528 "(len=%d, reassoc=%d) from %s\n", 1536 "(len=%d, reassoc=%d) from " MAC_FMT "\n",
1529 dev->name, len, reassoc, print_mac(mac, hdr->addr2)); 1537 dev->name, len, reassoc,
1538 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1539 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
1530 return; 1540 return;
1531 } 1541 }
1532 1542
@@ -1603,9 +1613,12 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
1603 } 1613 }
1604 1614
1605 if (left > 0) { 1615 if (left > 0) {
1606 PDEBUG(DEBUG_AP, "%s: assoc from %s" 1616 PDEBUG(DEBUG_AP, "%s: assoc from " MAC_FMT
1607 " with extra data (%d bytes) [", 1617 " with extra data (%d bytes) [",
1608 dev->name, print_mac(mac, hdr->addr2), left); 1618 dev->name,
1619 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1620 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1621 left);
1609 while (left > 0) { 1622 while (left > 0) {
1610 PDEBUG2(DEBUG_AP, "<%02x>", *u); 1623 PDEBUG2(DEBUG_AP, "<%02x>", *u);
1611 u++; left--; 1624 u++; left--;
@@ -1704,10 +1717,15 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
1704 } 1717 }
1705 1718
1706#if 0 1719#if 0
1707 PDEBUG(DEBUG_AP, "%s: %s %sassoc (len=%d " 1720 PDEBUG(DEBUG_AP, "%s: " MAC_FMT" %sassoc (len=%d "
1708 "prev_ap=%s) => %d(%d) (%s)\n", 1721 "prev_ap=" MAC_FMT") => %d(%d) (%s)\n",
1709 dev->name, print_mac(mac, hdr->addr2), reassoc ? "re" : "", len, 1722 dev->name,
1710 print_mac(mac, prev_ap), resp, send_deauth, txt); 1723 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1724 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1725 reassoc ? "re" : "", len,
1726 prev_ap[0], prev_ap[1], prev_ap[2],
1727 prev_ap[3], prev_ap[4], prev_ap[5],
1728 resp, send_deauth, txt);
1711#endif 1729#endif
1712} 1730}
1713 1731
@@ -1735,9 +1753,11 @@ static void handle_deauth(local_info_t *local, struct sk_buff *skb,
1735 pos = (__le16 *) body; 1753 pos = (__le16 *) body;
1736 reason_code = le16_to_cpu(*pos); 1754 reason_code = le16_to_cpu(*pos);
1737 1755
1738 PDEBUG(DEBUG_AP, "%s: deauthentication: %s len=%d, " 1756 PDEBUG(DEBUG_AP, "%s: deauthentication: " MAC_FMT " len=%d, "
1739 "reason_code=%d\n", dev->name, print_mac(mac, hdr->addr2), len, 1757 "reason_code=%d\n", dev->name,
1740 reason_code); 1758 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1759 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1760 len, reason_code);
1741 1761
1742 spin_lock_bh(&local->ap->sta_table_lock); 1762 spin_lock_bh(&local->ap->sta_table_lock);
1743 sta = ap_get_sta(local->ap, hdr->addr2); 1763 sta = ap_get_sta(local->ap, hdr->addr2);
@@ -1748,9 +1768,11 @@ static void handle_deauth(local_info_t *local, struct sk_buff *skb,
1748 } 1768 }
1749 spin_unlock_bh(&local->ap->sta_table_lock); 1769 spin_unlock_bh(&local->ap->sta_table_lock);
1750 if (sta == NULL) { 1770 if (sta == NULL) {
1751 printk("%s: deauthentication from %s, " 1771 printk("%s: deauthentication from " MAC_FMT ", "
1752 "reason_code=%d, but STA not authenticated\n", dev->name, 1772 "reason_code=%d, but STA not authenticated\n", dev->name,
1753 print_mac(mac, hdr->addr2), reason_code); 1773 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1774 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1775 reason_code);
1754 } 1776 }
1755} 1777}
1756 1778
@@ -1766,7 +1788,6 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
1766 u16 reason_code; 1788 u16 reason_code;
1767 __le16 *pos; 1789 __le16 *pos;
1768 struct sta_info *sta = NULL; 1790 struct sta_info *sta = NULL;
1769 DECLARE_MAC_BUF(mac);
1770 1791
1771 len = skb->len - IEEE80211_MGMT_HDR_LEN; 1792 len = skb->len - IEEE80211_MGMT_HDR_LEN;
1772 1793
@@ -1778,9 +1799,11 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
1778 pos = (__le16 *) body; 1799 pos = (__le16 *) body;
1779 reason_code = le16_to_cpu(*pos); 1800 reason_code = le16_to_cpu(*pos);
1780 1801
1781 PDEBUG(DEBUG_AP, "%s: disassociation: %s len=%d, " 1802 PDEBUG(DEBUG_AP, "%s: disassociation: " MAC_FMT " len=%d, "
1782 "reason_code=%d\n", dev->name, print_mac(mac, hdr->addr2), len, 1803 "reason_code=%d\n", dev->name,
1783 reason_code); 1804 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1805 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1806 len, reason_code);
1784 1807
1785 spin_lock_bh(&local->ap->sta_table_lock); 1808 spin_lock_bh(&local->ap->sta_table_lock);
1786 sta = ap_get_sta(local->ap, hdr->addr2); 1809 sta = ap_get_sta(local->ap, hdr->addr2);
@@ -1791,9 +1814,12 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
1791 } 1814 }
1792 spin_unlock_bh(&local->ap->sta_table_lock); 1815 spin_unlock_bh(&local->ap->sta_table_lock);
1793 if (sta == NULL) { 1816 if (sta == NULL) {
1794 printk("%s: disassociation from %s, " 1817 printk("%s: disassociation from " MAC_FMT ", "
1795 "reason_code=%d, but STA not authenticated\n", 1818 "reason_code=%d, but STA not authenticated\n",
1796 dev->name, print_mac(mac, hdr->addr2), reason_code); 1819 dev->name,
1820 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1821 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1822 reason_code);
1797 } 1823 }
1798} 1824}
1799 1825
@@ -1882,16 +1908,20 @@ static void handle_pspoll(local_info_t *local,
1882 struct sta_info *sta; 1908 struct sta_info *sta;
1883 u16 aid; 1909 u16 aid;
1884 struct sk_buff *skb; 1910 struct sk_buff *skb;
1885 DECLARE_MAC_BUF(mac);
1886 1911
1887 PDEBUG(DEBUG_PS2, "handle_pspoll: BSSID=%s" 1912 PDEBUG(DEBUG_PS2, "handle_pspoll: BSSID=" MAC_FMT
1888 ", TA=%s PWRMGT=%d\n", 1913 ", TA=" MAC_FMT " PWRMGT=%d\n",
1889 print_mac(mac, hdr->addr1), print_mac(mac, hdr->addr2), 1914 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
1915 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5],
1916 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1917 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1890 !!(le16_to_cpu(hdr->frame_ctl) & IEEE80211_FCTL_PM)); 1918 !!(le16_to_cpu(hdr->frame_ctl) & IEEE80211_FCTL_PM));
1891 1919
1892 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 1920 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
1893 PDEBUG(DEBUG_AP, "handle_pspoll - addr1(BSSID)=%s" 1921 PDEBUG(DEBUG_AP, "handle_pspoll - addr1(BSSID)=" MAC_FMT
1894 " not own MAC\n", print_mac(mac, hdr->addr1)); 1922 " not own MAC\n",
1923 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
1924 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
1895 return; 1925 return;
1896 } 1926 }
1897 1927
@@ -1969,7 +1999,6 @@ static void handle_wds_oper_queue(struct work_struct *work)
1969 wds_oper_queue); 1999 wds_oper_queue);
1970 local_info_t *local = ap->local; 2000 local_info_t *local = ap->local;
1971 struct wds_oper_data *entry, *prev; 2001 struct wds_oper_data *entry, *prev;
1972 DECLARE_MAC_BUF(mac);
1973 2002
1974 spin_lock_bh(&local->lock); 2003 spin_lock_bh(&local->lock);
1975 entry = local->ap->wds_oper_entries; 2004 entry = local->ap->wds_oper_entries;
@@ -1978,10 +2007,11 @@ static void handle_wds_oper_queue(struct work_struct *work)
1978 2007
1979 while (entry) { 2008 while (entry) {
1980 PDEBUG(DEBUG_AP, "%s: %s automatic WDS connection " 2009 PDEBUG(DEBUG_AP, "%s: %s automatic WDS connection "
1981 "to AP %s\n", 2010 "to AP " MAC_FMT "\n",
1982 local->dev->name, 2011 local->dev->name,
1983 entry->type == WDS_ADD ? "adding" : "removing", 2012 entry->type == WDS_ADD ? "adding" : "removing",
1984 print_mac(mac, entry->addr)); 2013 entry->addr[0], entry->addr[1], entry->addr[2],
2014 entry->addr[3], entry->addr[4], entry->addr[5]);
1985 if (entry->type == WDS_ADD) 2015 if (entry->type == WDS_ADD)
1986 prism2_wds_add(local, entry->addr, 0); 2016 prism2_wds_add(local, entry->addr, 0);
1987 else if (entry->type == WDS_DEL) 2017 else if (entry->type == WDS_DEL)
@@ -2158,7 +2188,6 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
2158#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 2188#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2159 u16 fc, type, stype; 2189 u16 fc, type, stype;
2160 struct ieee80211_hdr_4addr *hdr; 2190 struct ieee80211_hdr_4addr *hdr;
2161 DECLARE_MAC_BUF(mac);
2162 2191
2163 /* FIX: should give skb->len to handler functions and check that the 2192 /* FIX: should give skb->len to handler functions and check that the
2164 * buffer is long enough */ 2193 * buffer is long enough */
@@ -2187,8 +2216,9 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
2187 2216
2188 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 2217 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
2189 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(BSSID)=" 2218 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(BSSID)="
2190 "%s not own MAC\n", 2219 MAC_FMT " not own MAC\n",
2191 print_mac(mac, hdr->addr1)); 2220 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
2221 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
2192 goto done; 2222 goto done;
2193 } 2223 }
2194 2224
@@ -2224,14 +2254,18 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
2224 } 2254 }
2225 2255
2226 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 2256 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
2227 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(DA)=%s" 2257 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(DA)=" MAC_FMT
2228 " not own MAC\n", print_mac(mac, hdr->addr1)); 2258 " not own MAC\n",
2259 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
2260 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
2229 goto done; 2261 goto done;
2230 } 2262 }
2231 2263
2232 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN)) { 2264 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN)) {
2233 PDEBUG(DEBUG_AP, "handle_ap_item - addr3(BSSID)=%s" 2265 PDEBUG(DEBUG_AP, "handle_ap_item - addr3(BSSID)=" MAC_FMT
2234 " not own MAC\n", print_mac(mac, hdr->addr3)); 2266 " not own MAC\n",
2267 hdr->addr3[0], hdr->addr3[1], hdr->addr3[2],
2268 hdr->addr3[3], hdr->addr3[4], hdr->addr3[5]);
2235 goto done; 2269 goto done;
2236 } 2270 }
2237 2271
@@ -2312,7 +2346,6 @@ static void schedule_packet_send(local_info_t *local, struct sta_info *sta)
2312 struct sk_buff *skb; 2346 struct sk_buff *skb;
2313 struct ieee80211_hdr_4addr *hdr; 2347 struct ieee80211_hdr_4addr *hdr;
2314 struct hostap_80211_rx_status rx_stats; 2348 struct hostap_80211_rx_status rx_stats;
2315 DECLARE_MAC_BUF(mac);
2316 2349
2317 if (skb_queue_empty(&sta->tx_buf)) 2350 if (skb_queue_empty(&sta->tx_buf))
2318 return; 2351 return;
@@ -2334,7 +2367,9 @@ static void schedule_packet_send(local_info_t *local, struct sta_info *sta)
2334 hdr->duration_id = cpu_to_le16(sta->aid | BIT(15) | BIT(14)); 2367 hdr->duration_id = cpu_to_le16(sta->aid | BIT(15) | BIT(14));
2335 2368
2336 PDEBUG(DEBUG_PS2, "%s: Scheduling buffered packet delivery for STA " 2369 PDEBUG(DEBUG_PS2, "%s: Scheduling buffered packet delivery for STA "
2337 "%s\n", local->dev->name, print_mac(mac, sta->addr)); 2370 MAC_FMT "\n", local->dev->name,
2371 sta->addr[0], sta->addr[1], sta->addr[2],
2372 sta->addr[3], sta->addr[4], sta->addr[5]);
2338 2373
2339 skb->dev = local->dev; 2374 skb->dev = local->dev;
2340 2375
@@ -2661,7 +2696,6 @@ static int ap_update_sta_tx_rate(struct sta_info *sta, struct net_device *dev)
2661 int ret = sta->tx_rate; 2696 int ret = sta->tx_rate;
2662 struct hostap_interface *iface; 2697 struct hostap_interface *iface;
2663 local_info_t *local; 2698 local_info_t *local;
2664 DECLARE_MAC_BUF(mac);
2665 2699
2666 iface = netdev_priv(dev); 2700 iface = netdev_priv(dev);
2667 local = iface->local; 2701 local = iface->local;
@@ -2689,9 +2723,12 @@ static int ap_update_sta_tx_rate(struct sta_info *sta, struct net_device *dev)
2689 case 3: sta->tx_rate = 110; break; 2723 case 3: sta->tx_rate = 110; break;
2690 default: sta->tx_rate = 0; break; 2724 default: sta->tx_rate = 0; break;
2691 } 2725 }
2692 PDEBUG(DEBUG_AP, "%s: STA %s" 2726 PDEBUG(DEBUG_AP, "%s: STA " MAC_FMT
2693 " TX rate raised to %d\n", 2727 " TX rate raised to %d\n",
2694 dev->name, print_mac(mac, sta->addr), sta->tx_rate); 2728 dev->name,
2729 sta->addr[0], sta->addr[1], sta->addr[2],
2730 sta->addr[3], sta->addr[4], sta->addr[5],
2731 sta->tx_rate);
2695 } 2732 }
2696 sta->tx_since_last_failure = 0; 2733 sta->tx_since_last_failure = 0;
2697 } 2734 }
@@ -2709,7 +2746,6 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
2709 int set_tim, ret; 2746 int set_tim, ret;
2710 struct ieee80211_hdr_4addr *hdr; 2747 struct ieee80211_hdr_4addr *hdr;
2711 struct hostap_skb_tx_data *meta; 2748 struct hostap_skb_tx_data *meta;
2712 DECLARE_MAC_BUF(mac);
2713 2749
2714 meta = (struct hostap_skb_tx_data *) skb->cb; 2750 meta = (struct hostap_skb_tx_data *) skb->cb;
2715 ret = AP_TX_CONTINUE; 2751 ret = AP_TX_CONTINUE;
@@ -2745,8 +2781,9 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
2745 * print out any errors here. */ 2781 * print out any errors here. */
2746 if (net_ratelimit()) { 2782 if (net_ratelimit()) {
2747 printk(KERN_DEBUG "AP: drop packet to non-associated " 2783 printk(KERN_DEBUG "AP: drop packet to non-associated "
2748 "STA %s\n", 2784 "STA " MAC_FMT "\n",
2749 print_mac(mac, hdr->addr1)); 2785 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
2786 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
2750 } 2787 }
2751#endif 2788#endif
2752 local->ap->tx_drop_nonassoc++; 2789 local->ap->tx_drop_nonassoc++;
@@ -2784,9 +2821,11 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
2784 } 2821 }
2785 2822
2786 if (skb_queue_len(&sta->tx_buf) >= STA_MAX_TX_BUFFER) { 2823 if (skb_queue_len(&sta->tx_buf) >= STA_MAX_TX_BUFFER) {
2787 PDEBUG(DEBUG_PS, "%s: No more space in STA (%s" 2824 PDEBUG(DEBUG_PS, "%s: No more space in STA (" MAC_FMT
2788 ")'s PS mode buffer\n", 2825 ")'s PS mode buffer\n",
2789 local->dev->name, print_mac(mac, sta->addr)); 2826 local->dev->name,
2827 sta->addr[0], sta->addr[1], sta->addr[2],
2828 sta->addr[3], sta->addr[4], sta->addr[5]);
2790 /* Make sure that TIM is set for the station (it might not be 2829 /* Make sure that TIM is set for the station (it might not be
2791 * after AP wlan hw reset). */ 2830 * after AP wlan hw reset). */
2792 /* FIX: should fix hw reset to restore bits based on STA 2831 /* FIX: should fix hw reset to restore bits based on STA
@@ -2850,7 +2889,6 @@ void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb)
2850 struct sta_info *sta; 2889 struct sta_info *sta;
2851 struct ieee80211_hdr_4addr *hdr; 2890 struct ieee80211_hdr_4addr *hdr;
2852 struct hostap_skb_tx_data *meta; 2891 struct hostap_skb_tx_data *meta;
2853 DECLARE_MAC_BUF(mac);
2854 2892
2855 hdr = (struct ieee80211_hdr_4addr *) skb->data; 2893 hdr = (struct ieee80211_hdr_4addr *) skb->data;
2856 meta = (struct hostap_skb_tx_data *) skb->cb; 2894 meta = (struct hostap_skb_tx_data *) skb->cb;
@@ -2859,9 +2897,12 @@ void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb)
2859 sta = ap_get_sta(local->ap, hdr->addr1); 2897 sta = ap_get_sta(local->ap, hdr->addr1);
2860 if (!sta) { 2898 if (!sta) {
2861 spin_unlock(&local->ap->sta_table_lock); 2899 spin_unlock(&local->ap->sta_table_lock);
2862 PDEBUG(DEBUG_AP, "%s: Could not find STA %s" 2900 PDEBUG(DEBUG_AP, "%s: Could not find STA " MAC_FMT
2863 " for this TX error (@%lu)\n", 2901 " for this TX error (@%lu)\n",
2864 local->dev->name, print_mac(mac, hdr->addr1), jiffies); 2902 local->dev->name,
2903 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
2904 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5],
2905 jiffies);
2865 return; 2906 return;
2866 } 2907 }
2867 2908
@@ -2888,9 +2929,11 @@ void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb)
2888 case 3: sta->tx_rate = 110; break; 2929 case 3: sta->tx_rate = 110; break;
2889 default: sta->tx_rate = 0; break; 2930 default: sta->tx_rate = 0; break;
2890 } 2931 }
2891 PDEBUG(DEBUG_AP, "%s: STA %s" 2932 PDEBUG(DEBUG_AP, "%s: STA " MAC_FMT
2892 " TX rate lowered to %d\n", 2933 " TX rate lowered to %d\n",
2893 local->dev->name, print_mac(mac, sta->addr), 2934 local->dev->name,
2935 sta->addr[0], sta->addr[1], sta->addr[2],
2936 sta->addr[3], sta->addr[4], sta->addr[5],
2894 sta->tx_rate); 2937 sta->tx_rate);
2895 } 2938 }
2896 sta->tx_consecutive_exc = 0; 2939 sta->tx_consecutive_exc = 0;
@@ -2956,7 +2999,6 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
2956 struct sta_info *sta; 2999 struct sta_info *sta;
2957 u16 fc, type, stype; 3000 u16 fc, type, stype;
2958 struct ieee80211_hdr_4addr *hdr; 3001 struct ieee80211_hdr_4addr *hdr;
2959 DECLARE_MAC_BUF(mac);
2960 3002
2961 if (local->ap == NULL) 3003 if (local->ap == NULL)
2962 return AP_RX_CONTINUE; 3004 return AP_RX_CONTINUE;
@@ -2988,9 +3030,12 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
2988 } else { 3030 } else {
2989 printk(KERN_DEBUG "%s: dropped received packet" 3031 printk(KERN_DEBUG "%s: dropped received packet"
2990 " from non-associated STA " 3032 " from non-associated STA "
2991 "%s" 3033 MAC_FMT
2992 " (type=0x%02x, subtype=0x%02x)\n", 3034 " (type=0x%02x, subtype=0x%02x)\n",
2993 dev->name, print_mac(mac, hdr->addr2), 3035 dev->name,
3036 hdr->addr2[0], hdr->addr2[1],
3037 hdr->addr2[2], hdr->addr2[3],
3038 hdr->addr2[4], hdr->addr2[5],
2994 type >> 2, stype >> 4); 3039 type >> 2, stype >> 4);
2995 hostap_rx(dev, skb, rx_stats); 3040 hostap_rx(dev, skb, rx_stats);
2996#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 3041#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
@@ -3025,8 +3070,11 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3025 * being associated. */ 3070 * being associated. */
3026 printk(KERN_DEBUG "%s: rejected received nullfunc " 3071 printk(KERN_DEBUG "%s: rejected received nullfunc "
3027 "frame without ToDS from not associated STA " 3072 "frame without ToDS from not associated STA "
3028 "%s\n", 3073 MAC_FMT "\n",
3029 dev->name, print_mac(mac, hdr->addr2)); 3074 dev->name,
3075 hdr->addr2[0], hdr->addr2[1],
3076 hdr->addr2[2], hdr->addr2[3],
3077 hdr->addr2[4], hdr->addr2[5]);
3030 hostap_rx(dev, skb, rx_stats); 3078 hostap_rx(dev, skb, rx_stats);
3031#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 3079#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3032 } 3080 }
@@ -3043,9 +3091,12 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3043 * If BSSID is own, report the dropping of this frame. */ 3091 * If BSSID is own, report the dropping of this frame. */
3044 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) { 3092 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
3045 printk(KERN_DEBUG "%s: dropped received packet from " 3093 printk(KERN_DEBUG "%s: dropped received packet from "
3046 "%s with no ToDS flag " 3094 MAC_FMT " with no ToDS flag "
3047 "(type=0x%02x, subtype=0x%02x)\n", dev->name, 3095 "(type=0x%02x, subtype=0x%02x)\n", dev->name,
3048 print_mac(mac, hdr->addr2), type >> 2, stype >> 4); 3096 hdr->addr2[0], hdr->addr2[1],
3097 hdr->addr2[2], hdr->addr2[3],
3098 hdr->addr2[4], hdr->addr2[5],
3099 type >> 2, stype >> 4);
3049 hostap_dump_rx_80211(dev->name, skb, rx_stats); 3100 hostap_dump_rx_80211(dev->name, skb, rx_stats);
3050 } 3101 }
3051 ret = AP_RX_DROP; 3102 ret = AP_RX_DROP;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index a56d9fc6354f..98d6ff69d375 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -10192,7 +10192,6 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
10192 u8 id, hdr_len, unicast; 10192 u8 id, hdr_len, unicast;
10193 u16 remaining_bytes; 10193 u16 remaining_bytes;
10194 int fc; 10194 int fc;
10195 DECLARE_MAC_BUF(mac);
10196 10195
10197 hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 10196 hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
10198 switch (priv->ieee->iw_mode) { 10197 switch (priv->ieee->iw_mode) {
@@ -10203,8 +10202,10 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
10203 id = ipw_add_station(priv, hdr->addr1); 10202 id = ipw_add_station(priv, hdr->addr1);
10204 if (id == IPW_INVALID_STATION) { 10203 if (id == IPW_INVALID_STATION) {
10205 IPW_WARNING("Attempt to send data to " 10204 IPW_WARNING("Attempt to send data to "
10206 "invalid cell: %s\n", 10205 "invalid cell: " MAC_FMT "\n",
10207 print_mac(mac, hdr->addr1)); 10206 hdr->addr1[0], hdr->addr1[1],
10207 hdr->addr1[2], hdr->addr1[3],
10208 hdr->addr1[4], hdr->addr1[5]);
10208 goto drop; 10209 goto drop;
10209 } 10210 }
10210 } 10211 }
@@ -11576,6 +11577,7 @@ static int ipw_prom_alloc(struct ipw_priv *priv)
11576 priv->prom_priv->priv = priv; 11577 priv->prom_priv->priv = priv;
11577 11578
11578 strcpy(priv->prom_net_dev->name, "rtap%d"); 11579 strcpy(priv->prom_net_dev->name, "rtap%d");
11580 memcpy(priv->prom_net_dev->dev_addr, priv->mac_addr, ETH_ALEN);
11579 11581
11580 priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP; 11582 priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
11581 priv->prom_net_dev->open = ipw_prom_open; 11583 priv->prom_net_dev->open = ipw_prom_open;
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index d1af938b9aa6..b54ff712e703 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -20,7 +20,7 @@ config IWL4965
20 runs. 20 runs.
21 21
22 If you want to compile the driver as a module ( = code which can be 22 If you want to compile the driver as a module ( = code which can be
23 inserted in and remvoed from the running kernel whenever you want), 23 inserted in and removed from the running kernel whenever you want),
24 say M here and read <file:Documentation/kbuild/modules.txt>. The 24 say M here and read <file:Documentation/kbuild/modules.txt>. The
25 module will be called iwl4965.ko. 25 module will be called iwl4965.ko.
26 26
@@ -35,7 +35,6 @@ config IWL4965_HT
35 bool "Enable 802.11n HT features in iwl4965 driver" 35 bool "Enable 802.11n HT features in iwl4965 driver"
36 depends on EXPERIMENTAL 36 depends on EXPERIMENTAL
37 depends on IWL4965 && IWL4965_QOS 37 depends on IWL4965 && IWL4965_QOS
38 depends on n
39 ---help--- 38 ---help---
40 This option enables IEEE 802.11n High Throughput features 39 This option enables IEEE 802.11n High Throughput features
41 for the iwl4965 driver. 40 for the iwl4965 driver.
@@ -101,7 +100,7 @@ config IWL3945
101 runs. 100 runs.
102 101
103 If you want to compile the driver as a module ( = code which can be 102 If you want to compile the driver as a module ( = code which can be
104 inserted in and remvoed from the running kernel whenever you want), 103 inserted in and removed from the running kernel whenever you want),
105 say M here and read <file:Documentation/kbuild/modules.txt>. The 104 say M here and read <file:Documentation/kbuild/modules.txt>. The
106 module will be called iwl3945.ko. 105 module will be called iwl3945.ko.
107 106
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index d727de8b96fe..65767570be68 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -4589,7 +4589,7 @@ static u8 iwl4965_is_fat_tx_allowed(struct iwl4965_priv *priv,
4589 4589
4590 if (sta_ht_inf) { 4590 if (sta_ht_inf) {
4591 if ((!sta_ht_inf->ht_supported) || 4591 if ((!sta_ht_inf->ht_supported) ||
4592 (!sta_ht_inf->cap & IEEE80211_HT_CAP_SUP_WIDTH)) 4592 (!(sta_ht_inf->cap & IEEE80211_HT_CAP_SUP_WIDTH)))
4593 return 0; 4593 return 0;
4594 } 4594 }
4595 4595
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 40b71bc2c4a4..cbaeaf186494 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -6206,11 +6206,11 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
6206 6206
6207 /* At this point, the NIC is initialized and operational */ 6207 /* At this point, the NIC is initialized and operational */
6208 priv->notif_missed_beacons = 0; 6208 priv->notif_missed_beacons = 0;
6209 set_bit(STATUS_READY, &priv->status);
6210 6209
6211 iwl3945_reg_txpower_periodic(priv); 6210 iwl3945_reg_txpower_periodic(priv);
6212 6211
6213 IWL_DEBUG_INFO("ALIVE processing complete.\n"); 6212 IWL_DEBUG_INFO("ALIVE processing complete.\n");
6213 set_bit(STATUS_READY, &priv->status);
6214 wake_up_interruptible(&priv->wait_command_queue); 6214 wake_up_interruptible(&priv->wait_command_queue);
6215 6215
6216 if (priv->error_recovering) 6216 if (priv->error_recovering)
@@ -8706,7 +8706,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8706 return err; 8706 return err;
8707} 8707}
8708 8708
8709static void iwl3945_pci_remove(struct pci_dev *pdev) 8709static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
8710{ 8710{
8711 struct iwl3945_priv *priv = pci_get_drvdata(pdev); 8711 struct iwl3945_priv *priv = pci_get_drvdata(pdev);
8712 struct list_head *p, *q; 8712 struct list_head *p, *q;
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index a23d4798653b..60ec29eab85a 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -6628,11 +6628,11 @@ static void iwl4965_alive_start(struct iwl4965_priv *priv)
6628 6628
6629 /* At this point, the NIC is initialized and operational */ 6629 /* At this point, the NIC is initialized and operational */
6630 priv->notif_missed_beacons = 0; 6630 priv->notif_missed_beacons = 0;
6631 set_bit(STATUS_READY, &priv->status);
6632 6631
6633 iwl4965_rf_kill_ct_config(priv); 6632 iwl4965_rf_kill_ct_config(priv);
6634 6633
6635 IWL_DEBUG_INFO("ALIVE processing complete.\n"); 6634 IWL_DEBUG_INFO("ALIVE processing complete.\n");
6635 set_bit(STATUS_READY, &priv->status);
6636 wake_up_interruptible(&priv->wait_command_queue); 6636 wake_up_interruptible(&priv->wait_command_queue);
6637 6637
6638 if (priv->error_recovering) 6638 if (priv->error_recovering)
@@ -9282,7 +9282,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9282 return err; 9282 return err;
9283} 9283}
9284 9284
9285static void iwl4965_pci_remove(struct pci_dev *pdev) 9285static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
9286{ 9286{
9287 struct iwl4965_priv *priv = pci_get_drvdata(pdev); 9287 struct iwl4965_priv *priv = pci_get_drvdata(pdev);
9288 struct list_head *p, *q; 9288 struct list_head *p, *q;
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 87e145ffe8f1..6a24ed6067e0 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -541,7 +541,7 @@ void lbs_association_worker(struct work_struct *work)
541 } 541 }
542 542
543 if (find_any_ssid) { 543 if (find_any_ssid) {
544 u8 new_mode; 544 u8 new_mode = assoc_req->mode;
545 545
546 ret = lbs_find_best_network_ssid(priv, assoc_req->ssid, 546 ret = lbs_find_best_network_ssid(priv, assoc_req->ssid,
547 &assoc_req->ssid_len, assoc_req->mode, &new_mode); 547 &assoc_req->ssid_len, assoc_req->mode, &new_mode);
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 5a9cadb97503..038c66a98f15 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -677,9 +677,7 @@ sbi_get_int_status_exit:
677 677
678 /* Card has a command result for us */ 678 /* Card has a command result for us */
679 if (*ireg & IF_CS_C_S_CMD_UPLD_RDY) { 679 if (*ireg & IF_CS_C_S_CMD_UPLD_RDY) {
680 spin_lock(&priv->driver_lock);
681 ret = if_cs_receive_cmdres(priv, priv->upld_buf, &priv->upld_len); 680 ret = if_cs_receive_cmdres(priv, priv->upld_buf, &priv->upld_len);
682 spin_unlock(&priv->driver_lock);
683 if (ret < 0) 681 if (ret < 0)
684 lbs_pr_err("could not receive cmd from card\n"); 682 lbs_pr_err("could not receive cmd from card\n");
685 } 683 }
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index bd305f7f3efd..e873a39fcce3 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1393,11 +1393,20 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1393 1393
1394exit: 1394exit:
1395 /* 1395 /*
1396 * Set device mode to sleep for power management. 1396 * Set device mode to sleep for power management,
1397 * on some hardware this call seems to consistently fail.
1398 * From the specifications it is hard to tell why it fails,
1399 * and if this is a "bad thing".
1400 * Overall it is safe to just ignore the failure and
1401 * continue suspending. The only downside is that the
1402 * device will not be in optimal power save mode, but with
1403 * the radio and the other components already disabled the
1404 * device is as good as disabled.
1397 */ 1405 */
1398 retval = rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP); 1406 retval = rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP);
1399 if (retval) 1407 if (retval)
1400 return retval; 1408 WARNING(rt2x00dev, "Device failed to enter sleep state, "
1409 "continue suspending.\n");
1401 1410
1402 return 0; 1411 return 0;
1403} 1412}
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 93ea212fedd5..ad2e7d53b3da 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -2399,10 +2399,8 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2399 * beacon frame. 2399 * beacon frame.
2400 */ 2400 */
2401 if (skb_headroom(skb) < TXD_DESC_SIZE) { 2401 if (skb_headroom(skb) < TXD_DESC_SIZE) {
2402 if (pskb_expand_head(skb, TXD_DESC_SIZE, 0, GFP_ATOMIC)) { 2402 if (pskb_expand_head(skb, TXD_DESC_SIZE, 0, GFP_ATOMIC))
2403 dev_kfree_skb(skb);
2404 return -ENOMEM; 2403 return -ENOMEM;
2405 }
2406 } 2404 }
2407 2405
2408 /* 2406 /*
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 8103d41a1543..3909cf42f472 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2095,6 +2095,8 @@ static struct usb_device_id rt73usb_device_table[] = {
2095 { USB_DEVICE(0x1371, 0x9032), USB_DEVICE_DATA(&rt73usb_ops) }, 2095 { USB_DEVICE(0x1371, 0x9032), USB_DEVICE_DATA(&rt73usb_ops) },
2096 /* Conceptronic */ 2096 /* Conceptronic */
2097 { USB_DEVICE(0x14b2, 0x3c22), USB_DEVICE_DATA(&rt73usb_ops) }, 2097 { USB_DEVICE(0x14b2, 0x3c22), USB_DEVICE_DATA(&rt73usb_ops) },
2098 /* Corega */
2099 { USB_DEVICE(0x07aa, 0x002e), USB_DEVICE_DATA(&rt73usb_ops) },
2098 /* D-Link */ 2100 /* D-Link */
2099 { USB_DEVICE(0x07d1, 0x3c03), USB_DEVICE_DATA(&rt73usb_ops) }, 2101 { USB_DEVICE(0x07d1, 0x3c03), USB_DEVICE_DATA(&rt73usb_ops) },
2100 { USB_DEVICE(0x07d1, 0x3c04), USB_DEVICE_DATA(&rt73usb_ops) }, 2102 { USB_DEVICE(0x07d1, 0x3c04), USB_DEVICE_DATA(&rt73usb_ops) },
diff --git a/drivers/net/wireless/wavelan_cs.h b/drivers/net/wireless/wavelan_cs.h
index fabc63ee153c..2e4bfe4147c6 100644
--- a/drivers/net/wireless/wavelan_cs.h
+++ b/drivers/net/wireless/wavelan_cs.h
@@ -309,7 +309,7 @@ struct mmw_t
309#define MMW_EXT_ANT_INTERNAL 0x00 /* Internal antenna */ 309#define MMW_EXT_ANT_INTERNAL 0x00 /* Internal antenna */
310#define MMW_EXT_ANT_EXTERNAL 0x03 /* External antenna */ 310#define MMW_EXT_ANT_EXTERNAL 0x03 /* External antenna */
311#define MMW_EXT_ANT_IQ_TEST 0x1C /* IQ test pattern (set to 0) */ 311#define MMW_EXT_ANT_IQ_TEST 0x1C /* IQ test pattern (set to 0) */
312}; 312} __attribute__((packed));
313 313
314/* Size for structure checking (if padding is correct) */ 314/* Size for structure checking (if padding is correct) */
315#define MMW_SIZE 37 315#define MMW_SIZE 37
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index d76d37bcb9cc..a85808938205 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1568,9 +1568,8 @@ static void __devinit detect_and_report_it87(void)
1568 outb(r | 8, 0x2F); 1568 outb(r | 8, 0x2F);
1569 outb(0x02, 0x2E); /* Lock */ 1569 outb(0x02, 0x2E); /* Lock */
1570 outb(0x02, 0x2F); 1570 outb(0x02, 0x2F);
1571
1572 release_region(0x2e, 1);
1573 } 1571 }
1572 release_region(0x2e, 1);
1574} 1573}
1575#endif /* CONFIG_PARPORT_PC_SUPERIO */ 1574#endif /* CONFIG_PARPORT_PC_SUPERIO */
1576 1575
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index e9a333d98552..e887aa45c9cd 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -951,6 +951,12 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82375, quirk_e
951 * accesses to the SMBus registers, with potentially bad effects. Thus you 951 * accesses to the SMBus registers, with potentially bad effects. Thus you
952 * should be very careful when adding new entries: if SMM is accessing the 952 * should be very careful when adding new entries: if SMM is accessing the
953 * Intel SMBus, this is a very good reason to leave it hidden. 953 * Intel SMBus, this is a very good reason to leave it hidden.
954 *
955 * Likewise, many recent laptops use ACPI for thermal management. If the
956 * ACPI DSDT code accesses the SMBus, then Linux should not access it
957 * natively, and keeping the SMBus hidden is the right thing to do. If you
958 * are about to add an entry in the table below, please first disassemble
959 * the DSDT and double-check that there is no code accessing the SMBus.
954 */ 960 */
955static int asus_hides_smbus; 961static int asus_hides_smbus;
956 962
@@ -1028,11 +1034,6 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
1028 case 0x12bf: /* HP xw4100 */ 1034 case 0x12bf: /* HP xw4100 */
1029 asus_hides_smbus = 1; 1035 asus_hides_smbus = 1;
1030 } 1036 }
1031 else if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB)
1032 switch (dev->subsystem_device) {
1033 case 0x099c: /* HP Compaq nx6110 */
1034 asus_hides_smbus = 1;
1035 }
1036 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) { 1037 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) {
1037 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 1038 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB)
1038 switch(dev->subsystem_device) { 1039 switch(dev->subsystem_device) {
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 6aa231ef642d..2dcd1960aca8 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -85,7 +85,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
85 i < PNP_MAX_IRQ) 85 i < PNP_MAX_IRQ)
86 i++; 86 i++;
87 if (i >= PNP_MAX_IRQ && !warned) { 87 if (i >= PNP_MAX_IRQ && !warned) {
88 printk(KERN_ERR "pnpacpi: exceeded the max number of IRQ " 88 printk(KERN_WARNING "pnpacpi: exceeded the max number of IRQ "
89 "resources: %d \n", PNP_MAX_IRQ); 89 "resources: %d \n", PNP_MAX_IRQ);
90 warned = 1; 90 warned = 1;
91 return; 91 return;
@@ -187,7 +187,7 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res,
187 res->dma_resource[i].start = dma; 187 res->dma_resource[i].start = dma;
188 res->dma_resource[i].end = dma; 188 res->dma_resource[i].end = dma;
189 } else if (!warned) { 189 } else if (!warned) {
190 printk(KERN_ERR "pnpacpi: exceeded the max number of DMA " 190 printk(KERN_WARNING "pnpacpi: exceeded the max number of DMA "
191 "resources: %d \n", PNP_MAX_DMA); 191 "resources: %d \n", PNP_MAX_DMA);
192 warned = 1; 192 warned = 1;
193 } 193 }
@@ -213,7 +213,7 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
213 res->port_resource[i].start = io; 213 res->port_resource[i].start = io;
214 res->port_resource[i].end = io + len - 1; 214 res->port_resource[i].end = io + len - 1;
215 } else if (!warned) { 215 } else if (!warned) {
216 printk(KERN_ERR "pnpacpi: exceeded the max number of IO " 216 printk(KERN_WARNING "pnpacpi: exceeded the max number of IO "
217 "resources: %d \n", PNP_MAX_PORT); 217 "resources: %d \n", PNP_MAX_PORT);
218 warned = 1; 218 warned = 1;
219 } 219 }
@@ -241,7 +241,7 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
241 res->mem_resource[i].start = mem; 241 res->mem_resource[i].start = mem;
242 res->mem_resource[i].end = mem + len - 1; 242 res->mem_resource[i].end = mem + len - 1;
243 } else if (!warned) { 243 } else if (!warned) {
244 printk(KERN_ERR "pnpacpi: exceeded the max number of mem " 244 printk(KERN_WARNING "pnpacpi: exceeded the max number of mem "
245 "resources: %d\n", PNP_MAX_MEM); 245 "resources: %d\n", PNP_MAX_MEM);
246 warned = 1; 246 warned = 1;
247 } 247 }
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 9e7de63b26ef..02a4c8cf2b2d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -252,6 +252,7 @@ config RTC_DRV_TWL92330
252 252
253config RTC_DRV_S35390A 253config RTC_DRV_S35390A
254 tristate "Seiko Instruments S-35390A" 254 tristate "Seiko Instruments S-35390A"
255 select BITREVERSE
255 help 256 help
256 If you say yes here you will get support for the Seiko 257 If you say yes here you will get support for the Seiko
257 Instruments S-35390A. 258 Instruments S-35390A.
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c
index d3b9b14267ab..42244f14b41c 100644
--- a/drivers/rtc/rtc-at32ap700x.c
+++ b/drivers/rtc/rtc-at32ap700x.c
@@ -290,7 +290,7 @@ static int __exit at32_rtc_remove(struct platform_device *pdev)
290 return 0; 290 return 0;
291} 291}
292 292
293MODULE_ALIAS("at32ap700x_rtc"); 293MODULE_ALIAS("platform:at32ap700x_rtc");
294 294
295static struct platform_driver at32_rtc_driver = { 295static struct platform_driver at32_rtc_driver = {
296 .remove = __exit_p(at32_rtc_remove), 296 .remove = __exit_p(at32_rtc_remove),
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index 33795e5a5595..52abffc86bcd 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -407,3 +407,4 @@ module_exit(at91_rtc_exit);
407MODULE_AUTHOR("Rick Bronson"); 407MODULE_AUTHOR("Rick Bronson");
408MODULE_DESCRIPTION("RTC driver for Atmel AT91RM9200"); 408MODULE_DESCRIPTION("RTC driver for Atmel AT91RM9200");
409MODULE_LICENSE("GPL"); 409MODULE_LICENSE("GPL");
410MODULE_ALIAS("platform:at91_rtc");
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index d90ba860d216..4f28045d9ef2 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -470,3 +470,4 @@ module_exit(bfin_rtc_exit);
470MODULE_DESCRIPTION("Blackfin On-Chip Real Time Clock Driver"); 470MODULE_DESCRIPTION("Blackfin On-Chip Real Time Clock Driver");
471MODULE_AUTHOR("Mike Frysinger <vapier@gentoo.org>"); 471MODULE_AUTHOR("Mike Frysinger <vapier@gentoo.org>");
472MODULE_LICENSE("GPL"); 472MODULE_LICENSE("GPL");
473MODULE_ALIAS("platform:rtc-bfin");
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index f3ee2ad566b4..b48517021ee6 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -943,6 +943,9 @@ static void cmos_platform_shutdown(struct platform_device *pdev)
943 cmos_do_shutdown(); 943 cmos_do_shutdown();
944} 944}
945 945
946/* work with hotplug and coldplug */
947MODULE_ALIAS("platform:rtc_cmos");
948
946static struct platform_driver cmos_platform_driver = { 949static struct platform_driver cmos_platform_driver = {
947 .remove = __exit_p(cmos_platform_remove), 950 .remove = __exit_p(cmos_platform_remove),
948 .shutdown = cmos_platform_shutdown, 951 .shutdown = cmos_platform_shutdown,
diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c
index 83efb88f8f23..0b17770b032b 100644
--- a/drivers/rtc/rtc-ds1216.c
+++ b/drivers/rtc/rtc-ds1216.c
@@ -221,6 +221,7 @@ MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>");
221MODULE_DESCRIPTION("DS1216 RTC driver"); 221MODULE_DESCRIPTION("DS1216 RTC driver");
222MODULE_LICENSE("GPL"); 222MODULE_LICENSE("GPL");
223MODULE_VERSION(DRV_VERSION); 223MODULE_VERSION(DRV_VERSION);
224MODULE_ALIAS("platform:rtc-ds1216");
224 225
225module_init(ds1216_rtc_init); 226module_init(ds1216_rtc_init);
226module_exit(ds1216_rtc_exit); 227module_exit(ds1216_rtc_exit);
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index d74b8086fa31..d08912f18ddd 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -626,6 +626,9 @@ ds1511_rtc_remove(struct platform_device *pdev)
626 return 0; 626 return 0;
627} 627}
628 628
629/* work with hotplug and coldplug */
630MODULE_ALIAS("platform:ds1511");
631
629static struct platform_driver ds1511_rtc_driver = { 632static struct platform_driver ds1511_rtc_driver = {
630 .probe = ds1511_rtc_probe, 633 .probe = ds1511_rtc_probe,
631 .remove = __devexit_p(ds1511_rtc_remove), 634 .remove = __devexit_p(ds1511_rtc_remove),
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index d9e848dcd450..a19f11415540 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -391,6 +391,9 @@ static int __devexit ds1553_rtc_remove(struct platform_device *pdev)
391 return 0; 391 return 0;
392} 392}
393 393
394/* work with hotplug and coldplug */
395MODULE_ALIAS("platform:rtc-ds1553");
396
394static struct platform_driver ds1553_rtc_driver = { 397static struct platform_driver ds1553_rtc_driver = {
395 .probe = ds1553_rtc_probe, 398 .probe = ds1553_rtc_probe,
396 .remove = __devexit_p(ds1553_rtc_remove), 399 .remove = __devexit_p(ds1553_rtc_remove),
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index 2e73f0b183b2..24d35ede2dbf 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -276,3 +276,4 @@ MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
276MODULE_DESCRIPTION("Dallas DS1742 RTC driver"); 276MODULE_DESCRIPTION("Dallas DS1742 RTC driver");
277MODULE_LICENSE("GPL"); 277MODULE_LICENSE("GPL");
278MODULE_VERSION(DRV_VERSION); 278MODULE_VERSION(DRV_VERSION);
279MODULE_ALIAS("platform:rtc-ds1742");
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index ef4f147f3c0c..1e99325270df 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -132,6 +132,9 @@ static int __devexit ep93xx_rtc_remove(struct platform_device *dev)
132 return 0; 132 return 0;
133} 133}
134 134
135/* work with hotplug and coldplug */
136MODULE_ALIAS("platform:ep93xx-rtc");
137
135static struct platform_driver ep93xx_rtc_platform_driver = { 138static struct platform_driver ep93xx_rtc_platform_driver = {
136 .driver = { 139 .driver = {
137 .name = "ep93xx-rtc", 140 .name = "ep93xx-rtc",
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index cd0bbc0e8038..013e6c103b9c 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -465,6 +465,9 @@ static int __devexit m48t59_rtc_remove(struct platform_device *pdev)
465 return 0; 465 return 0;
466} 466}
467 467
468/* work with hotplug and coldplug */
469MODULE_ALIAS("platform:rtc-m48t59");
470
468static struct platform_driver m48t59_rtc_driver = { 471static struct platform_driver m48t59_rtc_driver = {
469 .driver = { 472 .driver = {
470 .name = "rtc-m48t59", 473 .name = "rtc-m48t59",
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c
index 8ff4a1221f59..3f7f99a5d96a 100644
--- a/drivers/rtc/rtc-m48t86.c
+++ b/drivers/rtc/rtc-m48t86.c
@@ -199,6 +199,7 @@ MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
199MODULE_DESCRIPTION("M48T86 RTC driver"); 199MODULE_DESCRIPTION("M48T86 RTC driver");
200MODULE_LICENSE("GPL"); 200MODULE_LICENSE("GPL");
201MODULE_VERSION(DRV_VERSION); 201MODULE_VERSION(DRV_VERSION);
202MODULE_ALIAS("platform:rtc-m48t86");
202 203
203module_init(m48t86_rtc_init); 204module_init(m48t86_rtc_init);
204module_exit(m48t86_rtc_exit); 205module_exit(m48t86_rtc_exit);
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index a2f84f169588..58f81c774943 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -497,7 +497,7 @@ static void omap_rtc_shutdown(struct platform_device *pdev)
497 rtc_write(0, OMAP_RTC_INTERRUPTS_REG); 497 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
498} 498}
499 499
500MODULE_ALIAS("omap_rtc"); 500MODULE_ALIAS("platform:omap_rtc");
501static struct platform_driver omap_rtc_driver = { 501static struct platform_driver omap_rtc_driver = {
502 .probe = omap_rtc_probe, 502 .probe = omap_rtc_probe,
503 .remove = __devexit_p(omap_rtc_remove), 503 .remove = __devexit_p(omap_rtc_remove),
diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c
index 66eb133bf5fd..664e89a817ed 100644
--- a/drivers/rtc/rtc-rs5c313.c
+++ b/drivers/rtc/rtc-rs5c313.c
@@ -421,3 +421,4 @@ MODULE_VERSION(DRV_VERSION);
421MODULE_AUTHOR("kogiidena , Nobuhiro Iwamatsu <iwamatsu@nigauri.org>"); 421MODULE_AUTHOR("kogiidena , Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
422MODULE_DESCRIPTION("Ricoh RS5C313 RTC device driver"); 422MODULE_DESCRIPTION("Ricoh RS5C313 RTC device driver");
423MODULE_LICENSE("GPL"); 423MODULE_LICENSE("GPL");
424MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 86766f1f2496..9f4d5129a496 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -592,3 +592,4 @@ module_exit(s3c_rtc_exit);
592MODULE_DESCRIPTION("Samsung S3C RTC Driver"); 592MODULE_DESCRIPTION("Samsung S3C RTC Driver");
593MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); 593MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
594MODULE_LICENSE("GPL"); 594MODULE_LICENSE("GPL");
595MODULE_ALIAS("platform:s3c2410-rtc");
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index ee253cc45de1..82f62d25f921 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -399,3 +399,4 @@ module_exit(sa1100_rtc_exit);
399MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); 399MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
400MODULE_DESCRIPTION("SA11x0/PXA2xx Realtime Clock Driver (RTC)"); 400MODULE_DESCRIPTION("SA11x0/PXA2xx Realtime Clock Driver (RTC)");
401MODULE_LICENSE("GPL"); 401MODULE_LICENSE("GPL");
402MODULE_ALIAS("platform:sa1100-rtc");
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index c1d6a1880ccf..9e9caa5d7f5f 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -664,3 +664,4 @@ MODULE_DESCRIPTION("SuperH on-chip RTC driver");
664MODULE_VERSION(DRV_VERSION); 664MODULE_VERSION(DRV_VERSION);
665MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, Jamie Lenehan <lenehan@twibble.org>"); 665MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, Jamie Lenehan <lenehan@twibble.org>");
666MODULE_LICENSE("GPL"); 666MODULE_LICENSE("GPL");
667MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index a265da7c6ff8..31d3c8c28588 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -394,6 +394,9 @@ static int __devexit stk17ta8_rtc_remove(struct platform_device *pdev)
394 return 0; 394 return 0;
395} 395}
396 396
397/* work with hotplug and coldplug */
398MODULE_ALIAS("platform:stk17ta8");
399
397static struct platform_driver stk17ta8_rtc_driver = { 400static struct platform_driver stk17ta8_rtc_driver = {
398 .probe = stk17ta8_rtc_probe, 401 .probe = stk17ta8_rtc_probe,
399 .remove = __devexit_p(stk17ta8_rtc_remove), 402 .remove = __devexit_p(stk17ta8_rtc_remove),
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index a6b572978dc0..24203a06051a 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -264,3 +264,4 @@ module_exit(v3020_exit);
264MODULE_DESCRIPTION("V3020 RTC"); 264MODULE_DESCRIPTION("V3020 RTC");
265MODULE_AUTHOR("Raphael Assenat"); 265MODULE_AUTHOR("Raphael Assenat");
266MODULE_LICENSE("GPL"); 266MODULE_LICENSE("GPL");
267MODULE_ALIAS("platform:v3020");
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index ce2f78de7a80..be9c70d0b193 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -422,6 +422,9 @@ static int __devexit rtc_remove(struct platform_device *pdev)
422 return 0; 422 return 0;
423} 423}
424 424
425/* work with hotplug and coldplug */
426MODULE_ALIAS("platform:RTC");
427
425static struct platform_driver rtc_platform_driver = { 428static struct platform_driver rtc_platform_driver = {
426 .probe = rtc_probe, 429 .probe = rtc_probe,
427 .remove = __devexit_p(rtc_remove), 430 .remove = __devexit_p(rtc_remove),
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 880c78bff0e1..ed7e0a1fc34d 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -218,18 +218,24 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
218 218
219 get_device(&shost->shost_gendev); 219 get_device(&shost->shost_gendev);
220 220
221 if (shost->transportt->host_size && 221 if (shost->transportt->host_size) {
222 (shost->shost_data = kzalloc(shost->transportt->host_size, 222 shost->shost_data = kzalloc(shost->transportt->host_size,
223 GFP_KERNEL)) == NULL) 223 GFP_KERNEL);
224 goto out_del_classdev; 224 if (shost->shost_data == NULL) {
225 error = -ENOMEM;
226 goto out_del_classdev;
227 }
228 }
225 229
226 if (shost->transportt->create_work_queue) { 230 if (shost->transportt->create_work_queue) {
227 snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d", 231 snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d",
228 shost->host_no); 232 shost->host_no);
229 shost->work_q = create_singlethread_workqueue( 233 shost->work_q = create_singlethread_workqueue(
230 shost->work_q_name); 234 shost->work_q_name);
231 if (!shost->work_q) 235 if (!shost->work_q) {
236 error = -EINVAL;
232 goto out_free_shost_data; 237 goto out_free_shost_data;
238 }
233 } 239 }
234 240
235 error = scsi_sysfs_add_host(shost); 241 error = scsi_sysfs_add_host(shost);
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index 31b9af224243..709a6f75ca9d 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -295,11 +295,14 @@ static void sas_discover_domain(struct work_struct *work)
295 case FANOUT_DEV: 295 case FANOUT_DEV:
296 error = sas_discover_root_expander(dev); 296 error = sas_discover_root_expander(dev);
297 break; 297 break;
298#ifdef CONFIG_SCSI_SAS_ATA
299 case SATA_DEV: 298 case SATA_DEV:
300 case SATA_PM: 299 case SATA_PM:
300#ifdef CONFIG_SCSI_SAS_ATA
301 error = sas_discover_sata(dev); 301 error = sas_discover_sata(dev);
302 break; 302 break;
303#else
304 SAS_DPRINTK("ATA device seen but CONFIG_SCSI_SAS_ATA=N so cannot attach\n");
305 /* Fall through */
303#endif 306#endif
304 default: 307 default:
305 error = -ENXIO; 308 error = -ENXIO;
diff --git a/drivers/scsi/mvsas.c b/drivers/scsi/mvsas.c
index 5ec0665b3a3d..e55b9037adb2 100644
--- a/drivers/scsi/mvsas.c
+++ b/drivers/scsi/mvsas.c
@@ -37,11 +37,13 @@
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/ctype.h> 38#include <linux/ctype.h>
39#include <scsi/libsas.h> 39#include <scsi/libsas.h>
40#include <scsi/scsi_tcq.h>
41#include <scsi/sas_ata.h>
40#include <asm/io.h> 42#include <asm/io.h>
41 43
42#define DRV_NAME "mvsas" 44#define DRV_NAME "mvsas"
43#define DRV_VERSION "0.5.1" 45#define DRV_VERSION "0.5.2"
44#define _MV_DUMP 0 46#define _MV_DUMP 0
45#define MVS_DISABLE_NVRAM 47#define MVS_DISABLE_NVRAM
46#define MVS_DISABLE_MSI 48#define MVS_DISABLE_MSI
47 49
@@ -52,7 +54,7 @@
52 readl(regs + MVS_##reg); \ 54 readl(regs + MVS_##reg); \
53 } while (0) 55 } while (0)
54 56
55#define MVS_ID_NOT_MAPPED 0xff 57#define MVS_ID_NOT_MAPPED 0x7f
56#define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width) 58#define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width)
57 59
58/* offset for D2H FIS in the Received FIS List Structure */ 60/* offset for D2H FIS in the Received FIS List Structure */
@@ -84,6 +86,7 @@ enum driver_configuration {
84 MVS_RX_FIS_COUNT = 17, /* Optional rx'd FISs (max 17) */ 86 MVS_RX_FIS_COUNT = 17, /* Optional rx'd FISs (max 17) */
85 87
86 MVS_QUEUE_SIZE = 30, /* Support Queue depth */ 88 MVS_QUEUE_SIZE = 30, /* Support Queue depth */
89 MVS_CAN_QUEUE = MVS_SLOTS - 1, /* SCSI Queue depth */
87}; 90};
88 91
89/* unchangeable hardware details */ 92/* unchangeable hardware details */
@@ -358,7 +361,20 @@ enum hw_register_bits {
358 361
359 /* VSR */ 362 /* VSR */
360 /* PHYMODE 6 (CDB) */ 363 /* PHYMODE 6 (CDB) */
361 PHY_MODE6_DTL_SPEED = (1U << 27), 364 PHY_MODE6_LATECLK = (1U << 29), /* Lock Clock */
365 PHY_MODE6_DTL_SPEED = (1U << 27), /* Digital Loop Speed */
366 PHY_MODE6_FC_ORDER = (1U << 26), /* Fibre Channel Mode Order*/
367 PHY_MODE6_MUCNT_EN = (1U << 24), /* u Count Enable */
368 PHY_MODE6_SEL_MUCNT_LEN = (1U << 22), /* Training Length Select */
369 PHY_MODE6_SELMUPI = (1U << 20), /* Phase Multi Select (init) */
370 PHY_MODE6_SELMUPF = (1U << 18), /* Phase Multi Select (final) */
371 PHY_MODE6_SELMUFF = (1U << 16), /* Freq Loop Multi Sel(final) */
372 PHY_MODE6_SELMUFI = (1U << 14), /* Freq Loop Multi Sel(init) */
373 PHY_MODE6_FREEZE_LOOP = (1U << 12), /* Freeze Rx CDR Loop */
374 PHY_MODE6_INT_RXFOFFS = (1U << 3), /* Rx CDR Freq Loop Enable */
375 PHY_MODE6_FRC_RXFOFFS = (1U << 2), /* Initial Rx CDR Offset */
376 PHY_MODE6_STAU_0D8 = (1U << 1), /* Rx CDR Freq Loop Saturate */
377 PHY_MODE6_RXSAT_DIS = (1U << 0), /* Saturate Ctl */
362}; 378};
363 379
364enum mvs_info_flags { 380enum mvs_info_flags {
@@ -511,7 +527,43 @@ enum status_buffer {
511}; 527};
512 528
513enum error_info_rec { 529enum error_info_rec {
514 CMD_ISS_STPD = (1U << 31), /* Cmd Issue Stopped */ 530 CMD_ISS_STPD = (1U << 31), /* Cmd Issue Stopped */
531 CMD_PI_ERR = (1U << 30), /* Protection info error. see flags2 */
532 RSP_OVER = (1U << 29), /* rsp buffer overflow */
533 RETRY_LIM = (1U << 28), /* FIS/frame retry limit exceeded */
534 UNK_FIS = (1U << 27), /* unknown FIS */
535 DMA_TERM = (1U << 26), /* DMA terminate primitive rx'd */
536 SYNC_ERR = (1U << 25), /* SYNC rx'd during frame xmit */
537 TFILE_ERR = (1U << 24), /* SATA taskfile Error bit set */
538 R_ERR = (1U << 23), /* SATA returned R_ERR prim */
539 RD_OFS = (1U << 20), /* Read DATA frame invalid offset */
540 XFER_RDY_OFS = (1U << 19), /* XFER_RDY offset error */
541 UNEXP_XFER_RDY = (1U << 18), /* unexpected XFER_RDY error */
542 DATA_OVER_UNDER = (1U << 16), /* data overflow/underflow */
543 INTERLOCK = (1U << 15), /* interlock error */
544 NAK = (1U << 14), /* NAK rx'd */
545 ACK_NAK_TO = (1U << 13), /* ACK/NAK timeout */
546 CXN_CLOSED = (1U << 12), /* cxn closed w/out ack/nak */
547 OPEN_TO = (1U << 11), /* I_T nexus lost, open cxn timeout */
548 PATH_BLOCKED = (1U << 10), /* I_T nexus lost, pathway blocked */
549 NO_DEST = (1U << 9), /* I_T nexus lost, no destination */
550 STP_RES_BSY = (1U << 8), /* STP resources busy */
551 BREAK = (1U << 7), /* break received */
552 BAD_DEST = (1U << 6), /* bad destination */
553 BAD_PROTO = (1U << 5), /* protocol not supported */
554 BAD_RATE = (1U << 4), /* cxn rate not supported */
555 WRONG_DEST = (1U << 3), /* wrong destination error */
556 CREDIT_TO = (1U << 2), /* credit timeout */
557 WDOG_TO = (1U << 1), /* watchdog timeout */
558 BUF_PAR = (1U << 0), /* buffer parity error */
559};
560
561enum error_info_rec_2 {
562 SLOT_BSY_ERR = (1U << 31), /* Slot Busy Error */
563 GRD_CHK_ERR = (1U << 14), /* Guard Check Error */
564 APP_CHK_ERR = (1U << 13), /* Application Check error */
565 REF_CHK_ERR = (1U << 12), /* Reference Check Error */
566 USR_BLK_NM = (1U << 0), /* User Block Number */
515}; 567};
516 568
517struct mvs_chip_info { 569struct mvs_chip_info {
@@ -543,28 +595,12 @@ struct mvs_cmd_hdr {
543 __le32 reserved[4]; 595 __le32 reserved[4];
544}; 596};
545 597
546struct mvs_slot_info {
547 struct sas_task *task;
548 u32 n_elem;
549 u32 tx;
550
551 /* DMA buffer for storing cmd tbl, open addr frame, status buffer,
552 * and PRD table
553 */
554 void *buf;
555 dma_addr_t buf_dma;
556#if _MV_DUMP
557 u32 cmd_size;
558#endif
559
560 void *response;
561};
562
563struct mvs_port { 598struct mvs_port {
564 struct asd_sas_port sas_port; 599 struct asd_sas_port sas_port;
565 u8 port_attached; 600 u8 port_attached;
566 u8 taskfileset; 601 u8 taskfileset;
567 u8 wide_port_phymap; 602 u8 wide_port_phymap;
603 struct list_head list;
568}; 604};
569 605
570struct mvs_phy { 606struct mvs_phy {
@@ -582,6 +618,27 @@ struct mvs_phy {
582 u32 frame_rcvd_size; 618 u32 frame_rcvd_size;
583 u8 frame_rcvd[32]; 619 u8 frame_rcvd[32];
584 u8 phy_attached; 620 u8 phy_attached;
621 enum sas_linkrate minimum_linkrate;
622 enum sas_linkrate maximum_linkrate;
623};
624
625struct mvs_slot_info {
626 struct list_head list;
627 struct sas_task *task;
628 u32 n_elem;
629 u32 tx;
630
631 /* DMA buffer for storing cmd tbl, open addr frame, status buffer,
632 * and PRD table
633 */
634 void *buf;
635 dma_addr_t buf_dma;
636#if _MV_DUMP
637 u32 cmd_size;
638#endif
639
640 void *response;
641 struct mvs_port *port;
585}; 642};
586 643
587struct mvs_info { 644struct mvs_info {
@@ -612,21 +669,14 @@ struct mvs_info {
612 669
613 const struct mvs_chip_info *chip; 670 const struct mvs_chip_info *chip;
614 671
615 unsigned long tags[MVS_SLOTS]; 672 u8 tags[MVS_SLOTS];
616 struct mvs_slot_info slot_info[MVS_SLOTS]; 673 struct mvs_slot_info slot_info[MVS_SLOTS];
617 /* further per-slot information */ 674 /* further per-slot information */
618 struct mvs_phy phy[MVS_MAX_PHYS]; 675 struct mvs_phy phy[MVS_MAX_PHYS];
619 struct mvs_port port[MVS_MAX_PHYS]; 676 struct mvs_port port[MVS_MAX_PHYS];
620 677#ifdef MVS_USE_TASKLET
621 u32 can_queue; /* per adapter */ 678 struct tasklet_struct tasklet;
622 u32 tag_out; /*Get*/ 679#endif
623 u32 tag_in; /*Give*/
624};
625
626struct mvs_queue_task {
627 struct list_head list;
628
629 void *uldd_task;
630}; 680};
631 681
632static int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, 682static int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
@@ -641,10 +691,11 @@ static u32 mvs_read_port_irq_mask(struct mvs_info *mvi, u32 port);
641static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i); 691static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i);
642static void mvs_detect_porttype(struct mvs_info *mvi, int i); 692static void mvs_detect_porttype(struct mvs_info *mvi, int i);
643static void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st); 693static void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st);
694static void mvs_release_task(struct mvs_info *mvi, int phy_no);
644 695
645static int mvs_scan_finished(struct Scsi_Host *, unsigned long); 696static int mvs_scan_finished(struct Scsi_Host *, unsigned long);
646static void mvs_scan_start(struct Scsi_Host *); 697static void mvs_scan_start(struct Scsi_Host *);
647static int mvs_sas_slave_alloc(struct scsi_device *scsi_dev); 698static int mvs_slave_configure(struct scsi_device *sdev);
648 699
649static struct scsi_transport_template *mvs_stt; 700static struct scsi_transport_template *mvs_stt;
650 701
@@ -659,7 +710,7 @@ static struct scsi_host_template mvs_sht = {
659 .name = DRV_NAME, 710 .name = DRV_NAME,
660 .queuecommand = sas_queuecommand, 711 .queuecommand = sas_queuecommand,
661 .target_alloc = sas_target_alloc, 712 .target_alloc = sas_target_alloc,
662 .slave_configure = sas_slave_configure, 713 .slave_configure = mvs_slave_configure,
663 .slave_destroy = sas_slave_destroy, 714 .slave_destroy = sas_slave_destroy,
664 .scan_finished = mvs_scan_finished, 715 .scan_finished = mvs_scan_finished,
665 .scan_start = mvs_scan_start, 716 .scan_start = mvs_scan_start,
@@ -674,7 +725,7 @@ static struct scsi_host_template mvs_sht = {
674 .use_clustering = ENABLE_CLUSTERING, 725 .use_clustering = ENABLE_CLUSTERING,
675 .eh_device_reset_handler = sas_eh_device_reset_handler, 726 .eh_device_reset_handler = sas_eh_device_reset_handler,
676 .eh_bus_reset_handler = sas_eh_bus_reset_handler, 727 .eh_bus_reset_handler = sas_eh_bus_reset_handler,
677 .slave_alloc = mvs_sas_slave_alloc, 728 .slave_alloc = sas_slave_alloc,
678 .target_destroy = sas_target_destroy, 729 .target_destroy = sas_target_destroy,
679 .ioctl = sas_ioctl, 730 .ioctl = sas_ioctl,
680}; 731};
@@ -709,10 +760,10 @@ static void mvs_hexdump(u32 size, u8 *data, u32 baseaddr)
709 printk("\n"); 760 printk("\n");
710} 761}
711 762
763#if _MV_DUMP
712static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag, 764static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag,
713 enum sas_protocol proto) 765 enum sas_protocol proto)
714{ 766{
715#if _MV_DUMP
716 u32 offset; 767 u32 offset;
717 struct pci_dev *pdev = mvi->pdev; 768 struct pci_dev *pdev = mvi->pdev;
718 struct mvs_slot_info *slot = &mvi->slot_info[tag]; 769 struct mvs_slot_info *slot = &mvi->slot_info[tag];
@@ -723,14 +774,14 @@ static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag,
723 tag); 774 tag);
724 mvs_hexdump(32, (u8 *) slot->response, 775 mvs_hexdump(32, (u8 *) slot->response,
725 (u32) slot->buf_dma + offset); 776 (u32) slot->buf_dma + offset);
726#endif
727} 777}
778#endif
728 779
729static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag, 780static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
730 enum sas_protocol proto) 781 enum sas_protocol proto)
731{ 782{
732#if _MV_DUMP 783#if _MV_DUMP
733 u32 sz, w_ptr, r_ptr; 784 u32 sz, w_ptr;
734 u64 addr; 785 u64 addr;
735 void __iomem *regs = mvi->regs; 786 void __iomem *regs = mvi->regs;
736 struct pci_dev *pdev = mvi->pdev; 787 struct pci_dev *pdev = mvi->pdev;
@@ -738,12 +789,10 @@ static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
738 789
739 /*Delivery Queue */ 790 /*Delivery Queue */
740 sz = mr32(TX_CFG) & TX_RING_SZ_MASK; 791 sz = mr32(TX_CFG) & TX_RING_SZ_MASK;
741 w_ptr = mr32(TX_PROD_IDX) & TX_RING_SZ_MASK; 792 w_ptr = slot->tx;
742 r_ptr = mr32(TX_CONS_IDX) & TX_RING_SZ_MASK;
743 addr = mr32(TX_HI) << 16 << 16 | mr32(TX_LO); 793 addr = mr32(TX_HI) << 16 << 16 | mr32(TX_LO);
744 dev_printk(KERN_DEBUG, &pdev->dev, 794 dev_printk(KERN_DEBUG, &pdev->dev,
745 "Delivery Queue Size=%04d , WRT_PTR=%04X , RD_PTR=%04X\n", 795 "Delivery Queue Size=%04d , WRT_PTR=%04X\n", sz, w_ptr);
746 sz, w_ptr, r_ptr);
747 dev_printk(KERN_DEBUG, &pdev->dev, 796 dev_printk(KERN_DEBUG, &pdev->dev,
748 "Delivery Queue Base Address=0x%llX (PA)" 797 "Delivery Queue Base Address=0x%llX (PA)"
749 "(tx_dma=0x%llX), Entry=%04d\n", 798 "(tx_dma=0x%llX), Entry=%04d\n",
@@ -751,11 +800,11 @@ static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
751 mvs_hexdump(sizeof(u32), (u8 *)(&mvi->tx[mvi->tx_prod]), 800 mvs_hexdump(sizeof(u32), (u8 *)(&mvi->tx[mvi->tx_prod]),
752 (u32) mvi->tx_dma + sizeof(u32) * w_ptr); 801 (u32) mvi->tx_dma + sizeof(u32) * w_ptr);
753 /*Command List */ 802 /*Command List */
754 addr = mr32(CMD_LIST_HI) << 16 << 16 | mr32(CMD_LIST_LO); 803 addr = mvi->slot_dma;
755 dev_printk(KERN_DEBUG, &pdev->dev, 804 dev_printk(KERN_DEBUG, &pdev->dev,
756 "Command List Base Address=0x%llX (PA)" 805 "Command List Base Address=0x%llX (PA)"
757 "(slot_dma=0x%llX), Header=%03d\n", 806 "(slot_dma=0x%llX), Header=%03d\n",
758 addr, mvi->slot_dma, tag); 807 addr, slot->buf_dma, tag);
759 dev_printk(KERN_DEBUG, &pdev->dev, "Command Header[%03d]:\n", tag); 808 dev_printk(KERN_DEBUG, &pdev->dev, "Command Header[%03d]:\n", tag);
760 /*mvs_cmd_hdr */ 809 /*mvs_cmd_hdr */
761 mvs_hexdump(sizeof(struct mvs_cmd_hdr), (u8 *)(&mvi->slot[tag]), 810 mvs_hexdump(sizeof(struct mvs_cmd_hdr), (u8 *)(&mvi->slot[tag]),
@@ -779,7 +828,7 @@ static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
779 828
780static void mvs_hba_cq_dump(struct mvs_info *mvi) 829static void mvs_hba_cq_dump(struct mvs_info *mvi)
781{ 830{
782#if _MV_DUMP 831#if (_MV_DUMP > 2)
783 u64 addr; 832 u64 addr;
784 void __iomem *regs = mvi->regs; 833 void __iomem *regs = mvi->regs;
785 struct pci_dev *pdev = mvi->pdev; 834 struct pci_dev *pdev = mvi->pdev;
@@ -788,8 +837,8 @@ static void mvs_hba_cq_dump(struct mvs_info *mvi)
788 837
789 /*Completion Queue */ 838 /*Completion Queue */
790 addr = mr32(RX_HI) << 16 << 16 | mr32(RX_LO); 839 addr = mr32(RX_HI) << 16 << 16 | mr32(RX_LO);
791 dev_printk(KERN_DEBUG, &pdev->dev, "Completion Task = 0x%08X\n", 840 dev_printk(KERN_DEBUG, &pdev->dev, "Completion Task = 0x%p\n",
792 (u32) mvi->slot_info[rx_desc & RXQ_SLOT_MASK].task); 841 mvi->slot_info[rx_desc & RXQ_SLOT_MASK].task);
793 dev_printk(KERN_DEBUG, &pdev->dev, 842 dev_printk(KERN_DEBUG, &pdev->dev,
794 "Completion List Base Address=0x%llX (PA), " 843 "Completion List Base Address=0x%llX (PA), "
795 "CQ_Entry=%04d, CQ_WP=0x%08X\n", 844 "CQ_Entry=%04d, CQ_WP=0x%08X\n",
@@ -854,34 +903,53 @@ static int pci_go_64(struct pci_dev *pdev)
854 return rc; 903 return rc;
855} 904}
856 905
906static int mvs_find_tag(struct mvs_info *mvi, struct sas_task *task, u32 *tag)
907{
908 if (task->lldd_task) {
909 struct mvs_slot_info *slot;
910 slot = (struct mvs_slot_info *) task->lldd_task;
911 *tag = slot - mvi->slot_info;
912 return 1;
913 }
914 return 0;
915}
916
857static void mvs_tag_clear(struct mvs_info *mvi, u32 tag) 917static void mvs_tag_clear(struct mvs_info *mvi, u32 tag)
858{ 918{
859 mvi->tag_in = (mvi->tag_in + 1) & (MVS_SLOTS - 1); 919 void *bitmap = (void *) &mvi->tags;
860 mvi->tags[mvi->tag_in] = tag; 920 clear_bit(tag, bitmap);
861} 921}
862 922
863static void mvs_tag_free(struct mvs_info *mvi, u32 tag) 923static void mvs_tag_free(struct mvs_info *mvi, u32 tag)
864{ 924{
865 mvi->tag_out = (mvi->tag_out - 1) & (MVS_SLOTS - 1); 925 mvs_tag_clear(mvi, tag);
926}
927
928static void mvs_tag_set(struct mvs_info *mvi, unsigned int tag)
929{
930 void *bitmap = (void *) &mvi->tags;
931 set_bit(tag, bitmap);
866} 932}
867 933
868static int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out) 934static int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out)
869{ 935{
870 if (mvi->tag_out != mvi->tag_in) { 936 unsigned int index, tag;
871 *tag_out = mvi->tags[mvi->tag_out]; 937 void *bitmap = (void *) &mvi->tags;
872 mvi->tag_out = (mvi->tag_out + 1) & (MVS_SLOTS - 1); 938
873 return 0; 939 index = find_first_zero_bit(bitmap, MVS_SLOTS);
874 } 940 tag = index;
875 return -EBUSY; 941 if (tag >= MVS_SLOTS)
942 return -SAS_QUEUE_FULL;
943 mvs_tag_set(mvi, tag);
944 *tag_out = tag;
945 return 0;
876} 946}
877 947
878static void mvs_tag_init(struct mvs_info *mvi) 948static void mvs_tag_init(struct mvs_info *mvi)
879{ 949{
880 int i; 950 int i;
881 for (i = 0; i < MVS_SLOTS; ++i) 951 for (i = 0; i < MVS_SLOTS; ++i)
882 mvi->tags[i] = i; 952 mvs_tag_clear(mvi, i);
883 mvi->tag_out = 0;
884 mvi->tag_in = MVS_SLOTS - 1;
885} 953}
886 954
887#ifndef MVS_DISABLE_NVRAM 955#ifndef MVS_DISABLE_NVRAM
@@ -1013,10 +1081,21 @@ err_out:
1013static void mvs_bytes_dmaed(struct mvs_info *mvi, int i) 1081static void mvs_bytes_dmaed(struct mvs_info *mvi, int i)
1014{ 1082{
1015 struct mvs_phy *phy = &mvi->phy[i]; 1083 struct mvs_phy *phy = &mvi->phy[i];
1084 struct asd_sas_phy *sas_phy = mvi->sas.sas_phy[i];
1016 1085
1017 if (!phy->phy_attached) 1086 if (!phy->phy_attached)
1018 return; 1087 return;
1019 1088
1089 if (sas_phy->phy) {
1090 struct sas_phy *sphy = sas_phy->phy;
1091
1092 sphy->negotiated_linkrate = sas_phy->linkrate;
1093 sphy->minimum_linkrate = phy->minimum_linkrate;
1094 sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
1095 sphy->maximum_linkrate = phy->maximum_linkrate;
1096 sphy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
1097 }
1098
1020 if (phy->phy_type & PORT_TYPE_SAS) { 1099 if (phy->phy_type & PORT_TYPE_SAS) {
1021 struct sas_identify_frame *id; 1100 struct sas_identify_frame *id;
1022 1101
@@ -1053,80 +1132,149 @@ static void mvs_scan_start(struct Scsi_Host *shost)
1053 } 1132 }
1054} 1133}
1055 1134
1056static int mvs_sas_slave_alloc(struct scsi_device *scsi_dev) 1135static int mvs_slave_configure(struct scsi_device *sdev)
1057{ 1136{
1058 int rc; 1137 struct domain_device *dev = sdev_to_domain_dev(sdev);
1138 int ret = sas_slave_configure(sdev);
1059 1139
1060 rc = sas_slave_alloc(scsi_dev); 1140 if (ret)
1141 return ret;
1061 1142
1062 return rc; 1143 if (dev_is_sata(dev)) {
1144 /* struct ata_port *ap = dev->sata_dev.ap; */
1145 /* struct ata_device *adev = ap->link.device; */
1146
1147 /* clamp at no NCQ for the time being */
1148 /* adev->flags |= ATA_DFLAG_NCQ_OFF; */
1149 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 1);
1150 }
1151 return 0;
1063} 1152}
1064 1153
1065static void mvs_int_port(struct mvs_info *mvi, int port_no, u32 events) 1154static void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events)
1066{ 1155{
1067 struct pci_dev *pdev = mvi->pdev; 1156 struct pci_dev *pdev = mvi->pdev;
1068 struct sas_ha_struct *sas_ha = &mvi->sas; 1157 struct sas_ha_struct *sas_ha = &mvi->sas;
1069 struct mvs_phy *phy = &mvi->phy[port_no]; 1158 struct mvs_phy *phy = &mvi->phy[phy_no];
1070 struct asd_sas_phy *sas_phy = &phy->sas_phy; 1159 struct asd_sas_phy *sas_phy = &phy->sas_phy;
1071 1160
1072 phy->irq_status = mvs_read_port_irq_stat(mvi, port_no); 1161 phy->irq_status = mvs_read_port_irq_stat(mvi, phy_no);
1073 /* 1162 /*
1074 * events is port event now , 1163 * events is port event now ,
1075 * we need check the interrupt status which belongs to per port. 1164 * we need check the interrupt status which belongs to per port.
1076 */ 1165 */
1077 dev_printk(KERN_DEBUG, &pdev->dev, 1166 dev_printk(KERN_DEBUG, &pdev->dev,
1078 "Port %d Event = %X\n", 1167 "Port %d Event = %X\n",
1079 port_no, phy->irq_status); 1168 phy_no, phy->irq_status);
1080 1169
1081 if (phy->irq_status & (PHYEV_POOF | PHYEV_DEC_ERR)) { 1170 if (phy->irq_status & (PHYEV_POOF | PHYEV_DEC_ERR)) {
1082 if (!mvs_is_phy_ready(mvi, port_no)) { 1171 mvs_release_task(mvi, phy_no);
1172 if (!mvs_is_phy_ready(mvi, phy_no)) {
1083 sas_phy_disconnected(sas_phy); 1173 sas_phy_disconnected(sas_phy);
1084 sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL); 1174 sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL);
1175 dev_printk(KERN_INFO, &pdev->dev,
1176 "Port %d Unplug Notice\n", phy_no);
1177
1085 } else 1178 } else
1086 mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, NULL); 1179 mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, NULL);
1087 } 1180 }
1088 if (!(phy->irq_status & PHYEV_DEC_ERR)) { 1181 if (!(phy->irq_status & PHYEV_DEC_ERR)) {
1089 if (phy->irq_status & PHYEV_COMWAKE) { 1182 if (phy->irq_status & PHYEV_COMWAKE) {
1090 u32 tmp = mvs_read_port_irq_mask(mvi, port_no); 1183 u32 tmp = mvs_read_port_irq_mask(mvi, phy_no);
1091 mvs_write_port_irq_mask(mvi, port_no, 1184 mvs_write_port_irq_mask(mvi, phy_no,
1092 tmp | PHYEV_SIG_FIS); 1185 tmp | PHYEV_SIG_FIS);
1093 } 1186 }
1094 if (phy->irq_status & (PHYEV_SIG_FIS | PHYEV_ID_DONE)) { 1187 if (phy->irq_status & (PHYEV_SIG_FIS | PHYEV_ID_DONE)) {
1095 phy->phy_status = mvs_is_phy_ready(mvi, port_no); 1188 phy->phy_status = mvs_is_phy_ready(mvi, phy_no);
1096 if (phy->phy_status) { 1189 if (phy->phy_status) {
1097 mvs_detect_porttype(mvi, port_no); 1190 mvs_detect_porttype(mvi, phy_no);
1098 1191
1099 if (phy->phy_type & PORT_TYPE_SATA) { 1192 if (phy->phy_type & PORT_TYPE_SATA) {
1100 u32 tmp = mvs_read_port_irq_mask(mvi, 1193 u32 tmp = mvs_read_port_irq_mask(mvi,
1101 port_no); 1194 phy_no);
1102 tmp &= ~PHYEV_SIG_FIS; 1195 tmp &= ~PHYEV_SIG_FIS;
1103 mvs_write_port_irq_mask(mvi, 1196 mvs_write_port_irq_mask(mvi,
1104 port_no, tmp); 1197 phy_no, tmp);
1105 } 1198 }
1106 1199
1107 mvs_update_phyinfo(mvi, port_no, 0); 1200 mvs_update_phyinfo(mvi, phy_no, 0);
1108 sas_ha->notify_phy_event(sas_phy, 1201 sas_ha->notify_phy_event(sas_phy,
1109 PHYE_OOB_DONE); 1202 PHYE_OOB_DONE);
1110 mvs_bytes_dmaed(mvi, port_no); 1203 mvs_bytes_dmaed(mvi, phy_no);
1111 } else { 1204 } else {
1112 dev_printk(KERN_DEBUG, &pdev->dev, 1205 dev_printk(KERN_DEBUG, &pdev->dev,
1113 "plugin interrupt but phy is gone\n"); 1206 "plugin interrupt but phy is gone\n");
1114 mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, 1207 mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET,
1115 NULL); 1208 NULL);
1116 } 1209 }
1117 } else if (phy->irq_status & PHYEV_BROAD_CH) 1210 } else if (phy->irq_status & PHYEV_BROAD_CH) {
1211 mvs_release_task(mvi, phy_no);
1118 sas_ha->notify_port_event(sas_phy, 1212 sas_ha->notify_port_event(sas_phy,
1119 PORTE_BROADCAST_RCVD); 1213 PORTE_BROADCAST_RCVD);
1214 }
1120 } 1215 }
1121 mvs_write_port_irq_stat(mvi, port_no, phy->irq_status); 1216 mvs_write_port_irq_stat(mvi, phy_no, phy->irq_status);
1122} 1217}
1123 1218
1124static void mvs_int_sata(struct mvs_info *mvi) 1219static void mvs_int_sata(struct mvs_info *mvi)
1125{ 1220{
1126 /* FIXME */ 1221 u32 tmp;
1222 void __iomem *regs = mvi->regs;
1223 tmp = mr32(INT_STAT_SRS);
1224 mw32(INT_STAT_SRS, tmp & 0xFFFF);
1225}
1226
1227static void mvs_slot_reset(struct mvs_info *mvi, struct sas_task *task,
1228 u32 slot_idx)
1229{
1230 void __iomem *regs = mvi->regs;
1231 struct domain_device *dev = task->dev;
1232 struct asd_sas_port *sas_port = dev->port;
1233 struct mvs_port *port = mvi->slot_info[slot_idx].port;
1234 u32 reg_set, phy_mask;
1235
1236 if (!sas_protocol_ata(task->task_proto)) {
1237 reg_set = 0;
1238 phy_mask = (port->wide_port_phymap) ? port->wide_port_phymap :
1239 sas_port->phy_mask;
1240 } else {
1241 reg_set = port->taskfileset;
1242 phy_mask = sas_port->phy_mask;
1243 }
1244 mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | slot_idx |
1245 (TXQ_CMD_SLOT_RESET << TXQ_CMD_SHIFT) |
1246 (phy_mask << TXQ_PHY_SHIFT) |
1247 (reg_set << TXQ_SRS_SHIFT));
1248
1249 mw32(TX_PROD_IDX, mvi->tx_prod);
1250 mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1);
1251}
1252
1253static int mvs_sata_done(struct mvs_info *mvi, struct sas_task *task,
1254 u32 slot_idx, int err)
1255{
1256 struct mvs_port *port = mvi->slot_info[slot_idx].port;
1257 struct task_status_struct *tstat = &task->task_status;
1258 struct ata_task_resp *resp = (struct ata_task_resp *)tstat->buf;
1259 int stat = SAM_GOOD;
1260
1261 resp->frame_len = sizeof(struct dev_to_host_fis);
1262 memcpy(&resp->ending_fis[0],
1263 SATA_RECEIVED_D2H_FIS(port->taskfileset),
1264 sizeof(struct dev_to_host_fis));
1265 tstat->buf_valid_size = sizeof(*resp);
1266 if (unlikely(err))
1267 stat = SAS_PROTO_RESPONSE;
1268 return stat;
1127} 1269}
1128 1270
1129static void mvs_slot_free(struct mvs_info *mvi, struct sas_task *task, 1271static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc)
1272{
1273 u32 slot_idx = rx_desc & RXQ_SLOT_MASK;
1274 mvs_tag_clear(mvi, slot_idx);
1275}
1276
1277static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,
1130 struct mvs_slot_info *slot, u32 slot_idx) 1278 struct mvs_slot_info *slot, u32 slot_idx)
1131{ 1279{
1132 if (!sas_protocol_ata(task->task_proto)) 1280 if (!sas_protocol_ata(task->task_proto))
@@ -1149,38 +1297,58 @@ static void mvs_slot_free(struct mvs_info *mvi, struct sas_task *task,
1149 /* do nothing */ 1297 /* do nothing */
1150 break; 1298 break;
1151 } 1299 }
1152 1300 list_del(&slot->list);
1301 task->lldd_task = NULL;
1153 slot->task = NULL; 1302 slot->task = NULL;
1154 mvs_tag_clear(mvi, slot_idx); 1303 slot->port = NULL;
1155} 1304}
1156 1305
1157static void mvs_slot_err(struct mvs_info *mvi, struct sas_task *task, 1306static int mvs_slot_err(struct mvs_info *mvi, struct sas_task *task,
1158 u32 slot_idx) 1307 u32 slot_idx)
1159{ 1308{
1160 struct mvs_slot_info *slot = &mvi->slot_info[slot_idx]; 1309 struct mvs_slot_info *slot = &mvi->slot_info[slot_idx];
1161 u64 err_dw0 = *(u32 *) slot->response; 1310 u32 err_dw0 = le32_to_cpu(*(u32 *) (slot->response));
1162 void __iomem *regs = mvi->regs; 1311 u32 err_dw1 = le32_to_cpu(*(u32 *) (slot->response + 4));
1163 u32 tmp; 1312 int stat = SAM_CHECK_COND;
1164 1313
1165 if (err_dw0 & CMD_ISS_STPD) 1314 if (err_dw1 & SLOT_BSY_ERR) {
1166 if (sas_protocol_ata(task->task_proto)) { 1315 stat = SAS_QUEUE_FULL;
1167 tmp = mr32(INT_STAT_SRS); 1316 mvs_slot_reset(mvi, task, slot_idx);
1168 mw32(INT_STAT_SRS, tmp & 0xFFFF); 1317 }
1169 } 1318 switch (task->task_proto) {
1319 case SAS_PROTOCOL_SSP:
1320 break;
1321 case SAS_PROTOCOL_SMP:
1322 break;
1323 case SAS_PROTOCOL_SATA:
1324 case SAS_PROTOCOL_STP:
1325 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
1326 if (err_dw0 & TFILE_ERR)
1327 stat = mvs_sata_done(mvi, task, slot_idx, 1);
1328 break;
1329 default:
1330 break;
1331 }
1170 1332
1171 mvs_hba_sb_dump(mvi, slot_idx, task->task_proto); 1333 mvs_hexdump(16, (u8 *) slot->response, 0);
1334 return stat;
1172} 1335}
1173 1336
1174static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc) 1337static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
1175{ 1338{
1176 u32 slot_idx = rx_desc & RXQ_SLOT_MASK; 1339 u32 slot_idx = rx_desc & RXQ_SLOT_MASK;
1177 struct mvs_slot_info *slot = &mvi->slot_info[slot_idx]; 1340 struct mvs_slot_info *slot = &mvi->slot_info[slot_idx];
1178 struct sas_task *task = slot->task; 1341 struct sas_task *task = slot->task;
1179 struct task_status_struct *tstat = &task->task_status; 1342 struct task_status_struct *tstat;
1180 struct mvs_port *port = &mvi->port[task->dev->port->id]; 1343 struct mvs_port *port;
1181 bool aborted; 1344 bool aborted;
1182 void *to; 1345 void *to;
1183 1346
1347 if (unlikely(!task || !task->lldd_task))
1348 return -1;
1349
1350 mvs_hba_cq_dump(mvi);
1351
1184 spin_lock(&task->task_state_lock); 1352 spin_lock(&task->task_state_lock);
1185 aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED; 1353 aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED;
1186 if (!aborted) { 1354 if (!aborted) {
@@ -1190,22 +1358,27 @@ static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc)
1190 } 1358 }
1191 spin_unlock(&task->task_state_lock); 1359 spin_unlock(&task->task_state_lock);
1192 1360
1193 if (aborted) 1361 if (aborted) {
1362 mvs_slot_task_free(mvi, task, slot, slot_idx);
1363 mvs_slot_free(mvi, rx_desc);
1194 return -1; 1364 return -1;
1365 }
1195 1366
1367 port = slot->port;
1368 tstat = &task->task_status;
1196 memset(tstat, 0, sizeof(*tstat)); 1369 memset(tstat, 0, sizeof(*tstat));
1197 tstat->resp = SAS_TASK_COMPLETE; 1370 tstat->resp = SAS_TASK_COMPLETE;
1198 1371
1199 1372 if (unlikely(!port->port_attached || flags)) {
1200 if (unlikely(!port->port_attached)) { 1373 mvs_slot_err(mvi, task, slot_idx);
1201 tstat->stat = SAS_PHY_DOWN; 1374 if (!sas_protocol_ata(task->task_proto))
1375 tstat->stat = SAS_PHY_DOWN;
1202 goto out; 1376 goto out;
1203 } 1377 }
1204 1378
1205 /* error info record present */ 1379 /* error info record present */
1206 if ((rx_desc & RXQ_ERR) && (*(u64 *) slot->response)) { 1380 if (unlikely((rx_desc & RXQ_ERR) && (*(u64 *) slot->response))) {
1207 tstat->stat = SAM_CHECK_COND; 1381 tstat->stat = mvs_slot_err(mvi, task, slot_idx);
1208 mvs_slot_err(mvi, task, slot_idx);
1209 goto out; 1382 goto out;
1210 } 1383 }
1211 1384
@@ -1242,21 +1415,7 @@ static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc)
1242 case SAS_PROTOCOL_SATA: 1415 case SAS_PROTOCOL_SATA:
1243 case SAS_PROTOCOL_STP: 1416 case SAS_PROTOCOL_STP:
1244 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: { 1417 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: {
1245 struct ata_task_resp *resp = 1418 tstat->stat = mvs_sata_done(mvi, task, slot_idx, 0);
1246 (struct ata_task_resp *)tstat->buf;
1247
1248 if ((rx_desc & (RXQ_DONE | RXQ_ERR | RXQ_ATTN)) ==
1249 RXQ_DONE)
1250 tstat->stat = SAM_GOOD;
1251 else
1252 tstat->stat = SAM_CHECK_COND;
1253
1254 resp->frame_len = sizeof(struct dev_to_host_fis);
1255 memcpy(&resp->ending_fis[0],
1256 SATA_RECEIVED_D2H_FIS(port->taskfileset),
1257 sizeof(struct dev_to_host_fis));
1258 if (resp->ending_fis[2] & ATA_ERR)
1259 mvs_hexdump(16, resp->ending_fis, 0);
1260 break; 1419 break;
1261 } 1420 }
1262 1421
@@ -1266,11 +1425,34 @@ static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc)
1266 } 1425 }
1267 1426
1268out: 1427out:
1269 mvs_slot_free(mvi, task, slot, slot_idx); 1428 mvs_slot_task_free(mvi, task, slot, slot_idx);
1429 if (unlikely(tstat->stat != SAS_QUEUE_FULL))
1430 mvs_slot_free(mvi, rx_desc);
1431
1432 spin_unlock(&mvi->lock);
1270 task->task_done(task); 1433 task->task_done(task);
1434 spin_lock(&mvi->lock);
1271 return tstat->stat; 1435 return tstat->stat;
1272} 1436}
1273 1437
1438static void mvs_release_task(struct mvs_info *mvi, int phy_no)
1439{
1440 struct list_head *pos, *n;
1441 struct mvs_slot_info *slot;
1442 struct mvs_phy *phy = &mvi->phy[phy_no];
1443 struct mvs_port *port = phy->port;
1444 u32 rx_desc;
1445
1446 if (!port)
1447 return;
1448
1449 list_for_each_safe(pos, n, &port->list) {
1450 slot = container_of(pos, struct mvs_slot_info, list);
1451 rx_desc = (u32) (slot - mvi->slot_info);
1452 mvs_slot_complete(mvi, rx_desc, 1);
1453 }
1454}
1455
1274static void mvs_int_full(struct mvs_info *mvi) 1456static void mvs_int_full(struct mvs_info *mvi)
1275{ 1457{
1276 void __iomem *regs = mvi->regs; 1458 void __iomem *regs = mvi->regs;
@@ -1305,40 +1487,43 @@ static int mvs_int_rx(struct mvs_info *mvi, bool self_clear)
1305 * we don't have to stall the CPU reading that register. 1487 * we don't have to stall the CPU reading that register.
1306 * The actual RX ring is offset by one dword, due to this. 1488 * The actual RX ring is offset by one dword, due to this.
1307 */ 1489 */
1308 rx_prod_idx = mr32(RX_CONS_IDX) & RX_RING_SZ_MASK; 1490 rx_prod_idx = mvi->rx_cons;
1309 if (rx_prod_idx == 0xfff) { /* h/w hasn't touched RX ring yet */ 1491 mvi->rx_cons = le32_to_cpu(mvi->rx[0]);
1310 mvi->rx_cons = 0xfff; 1492 if (mvi->rx_cons == 0xfff) /* h/w hasn't touched RX ring yet */
1311 return 0; 1493 return 0;
1312 }
1313 1494
1314 /* The CMPL_Q may come late, read from register and try again 1495 /* The CMPL_Q may come late, read from register and try again
1315 * note: if coalescing is enabled, 1496 * note: if coalescing is enabled,
1316 * it will need to read from register every time for sure 1497 * it will need to read from register every time for sure
1317 */ 1498 */
1318 if (mvi->rx_cons == rx_prod_idx) 1499 if (mvi->rx_cons == rx_prod_idx)
1319 return 0; 1500 mvi->rx_cons = mr32(RX_CONS_IDX) & RX_RING_SZ_MASK;
1320 1501
1321 if (mvi->rx_cons == 0xfff) 1502 if (mvi->rx_cons == rx_prod_idx)
1322 mvi->rx_cons = MVS_RX_RING_SZ - 1; 1503 return 0;
1323 1504
1324 while (mvi->rx_cons != rx_prod_idx) { 1505 while (mvi->rx_cons != rx_prod_idx) {
1325 1506
1326 /* increment our internal RX consumer pointer */ 1507 /* increment our internal RX consumer pointer */
1327 mvi->rx_cons = (mvi->rx_cons + 1) & (MVS_RX_RING_SZ - 1); 1508 rx_prod_idx = (rx_prod_idx + 1) & (MVS_RX_RING_SZ - 1);
1328 1509
1329 rx_desc = le32_to_cpu(mvi->rx[mvi->rx_cons + 1]); 1510 rx_desc = le32_to_cpu(mvi->rx[rx_prod_idx + 1]);
1330
1331 mvs_hba_cq_dump(mvi);
1332 1511
1333 if (likely(rx_desc & RXQ_DONE)) 1512 if (likely(rx_desc & RXQ_DONE))
1334 mvs_slot_complete(mvi, rx_desc); 1513 mvs_slot_complete(mvi, rx_desc, 0);
1335 if (rx_desc & RXQ_ATTN) { 1514 if (rx_desc & RXQ_ATTN) {
1336 attn = true; 1515 attn = true;
1337 dev_printk(KERN_DEBUG, &pdev->dev, "ATTN %X\n", 1516 dev_printk(KERN_DEBUG, &pdev->dev, "ATTN %X\n",
1338 rx_desc); 1517 rx_desc);
1339 } else if (rx_desc & RXQ_ERR) { 1518 } else if (rx_desc & RXQ_ERR) {
1519 if (!(rx_desc & RXQ_DONE))
1520 mvs_slot_complete(mvi, rx_desc, 0);
1340 dev_printk(KERN_DEBUG, &pdev->dev, "RXQ_ERR %X\n", 1521 dev_printk(KERN_DEBUG, &pdev->dev, "RXQ_ERR %X\n",
1341 rx_desc); 1522 rx_desc);
1523 } else if (rx_desc & RXQ_SLOT_RESET) {
1524 dev_printk(KERN_DEBUG, &pdev->dev, "Slot reset[%X]\n",
1525 rx_desc);
1526 mvs_slot_free(mvi, rx_desc);
1342 } 1527 }
1343 } 1528 }
1344 1529
@@ -1348,6 +1533,23 @@ static int mvs_int_rx(struct mvs_info *mvi, bool self_clear)
1348 return 0; 1533 return 0;
1349} 1534}
1350 1535
1536#ifdef MVS_USE_TASKLET
1537static void mvs_tasklet(unsigned long data)
1538{
1539 struct mvs_info *mvi = (struct mvs_info *) data;
1540 unsigned long flags;
1541
1542 spin_lock_irqsave(&mvi->lock, flags);
1543
1544#ifdef MVS_DISABLE_MSI
1545 mvs_int_full(mvi);
1546#else
1547 mvs_int_rx(mvi, true);
1548#endif
1549 spin_unlock_irqrestore(&mvi->lock, flags);
1550}
1551#endif
1552
1351static irqreturn_t mvs_interrupt(int irq, void *opaque) 1553static irqreturn_t mvs_interrupt(int irq, void *opaque)
1352{ 1554{
1353 struct mvs_info *mvi = opaque; 1555 struct mvs_info *mvi = opaque;
@@ -1356,18 +1558,21 @@ static irqreturn_t mvs_interrupt(int irq, void *opaque)
1356 1558
1357 stat = mr32(GBL_INT_STAT); 1559 stat = mr32(GBL_INT_STAT);
1358 1560
1359 /* clear CMD_CMPLT ASAP */
1360 mw32_f(INT_STAT, CINT_DONE);
1361
1362 if (stat == 0 || stat == 0xffffffff) 1561 if (stat == 0 || stat == 0xffffffff)
1363 return IRQ_NONE; 1562 return IRQ_NONE;
1364 1563
1564 /* clear CMD_CMPLT ASAP */
1565 mw32_f(INT_STAT, CINT_DONE);
1566
1567#ifndef MVS_USE_TASKLET
1365 spin_lock(&mvi->lock); 1568 spin_lock(&mvi->lock);
1366 1569
1367 mvs_int_full(mvi); 1570 mvs_int_full(mvi);
1368 1571
1369 spin_unlock(&mvi->lock); 1572 spin_unlock(&mvi->lock);
1370 1573#else
1574 tasklet_schedule(&mvi->tasklet);
1575#endif
1371 return IRQ_HANDLED; 1576 return IRQ_HANDLED;
1372} 1577}
1373 1578
@@ -1376,12 +1581,15 @@ static irqreturn_t mvs_msi_interrupt(int irq, void *opaque)
1376{ 1581{
1377 struct mvs_info *mvi = opaque; 1582 struct mvs_info *mvi = opaque;
1378 1583
1584#ifndef MVS_USE_TASKLET
1379 spin_lock(&mvi->lock); 1585 spin_lock(&mvi->lock);
1380 1586
1381 mvs_int_rx(mvi, true); 1587 mvs_int_rx(mvi, true);
1382 1588
1383 spin_unlock(&mvi->lock); 1589 spin_unlock(&mvi->lock);
1384 1590#else
1591 tasklet_schedule(&mvi->tasklet);
1592#endif
1385 return IRQ_HANDLED; 1593 return IRQ_HANDLED;
1386} 1594}
1387#endif 1595#endif
@@ -1576,15 +1784,19 @@ static u8 mvs_assign_reg_set(struct mvs_info *mvi, struct mvs_port *port)
1576 return MVS_ID_NOT_MAPPED; 1784 return MVS_ID_NOT_MAPPED;
1577} 1785}
1578 1786
1579static u32 mvs_get_ncq_tag(struct sas_task *task) 1787static u32 mvs_get_ncq_tag(struct sas_task *task, u32 *tag)
1580{ 1788{
1581 u32 tag = 0;
1582 struct ata_queued_cmd *qc = task->uldd_task; 1789 struct ata_queued_cmd *qc = task->uldd_task;
1583 1790
1584 if (qc) 1791 if (qc) {
1585 tag = qc->tag; 1792 if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
1793 qc->tf.command == ATA_CMD_FPDMA_READ) {
1794 *tag = qc->tag;
1795 return 1;
1796 }
1797 }
1586 1798
1587 return tag; 1799 return 0;
1588} 1800}
1589 1801
1590static int mvs_task_prep_ata(struct mvs_info *mvi, 1802static int mvs_task_prep_ata(struct mvs_info *mvi,
@@ -1628,11 +1840,9 @@ static int mvs_task_prep_ata(struct mvs_info *mvi,
1628 hdr->flags = cpu_to_le32(flags); 1840 hdr->flags = cpu_to_le32(flags);
1629 1841
1630 /* FIXME: the low order order 5 bits for the TAG if enable NCQ */ 1842 /* FIXME: the low order order 5 bits for the TAG if enable NCQ */
1631 if (task->ata_task.use_ncq) { 1843 if (task->ata_task.use_ncq && mvs_get_ncq_tag(task, &hdr->tags))
1632 hdr->tags = cpu_to_le32(mvs_get_ncq_tag(task)); 1844 task->ata_task.fis.sector_count |= hdr->tags << 3;
1633 /*Fill in task file */ 1845 else
1634 task->ata_task.fis.sector_count = hdr->tags << 3;
1635 } else
1636 hdr->tags = cpu_to_le32(tag); 1846 hdr->tags = cpu_to_le32(tag);
1637 hdr->data_len = cpu_to_le32(task->total_xfer_len); 1847 hdr->data_len = cpu_to_le32(task->total_xfer_len);
1638 1848
@@ -1725,13 +1935,16 @@ static int mvs_task_prep_ssp(struct mvs_info *mvi,
1725 u32 flags; 1935 u32 flags;
1726 u32 resp_len, req_len, i, tag = tei->tag; 1936 u32 resp_len, req_len, i, tag = tei->tag;
1727 const u32 max_resp_len = SB_RFB_MAX; 1937 const u32 max_resp_len = SB_RFB_MAX;
1938 u8 phy_mask;
1728 1939
1729 slot = &mvi->slot_info[tag]; 1940 slot = &mvi->slot_info[tag];
1730 1941
1942 phy_mask = (port->wide_port_phymap) ? port->wide_port_phymap :
1943 task->dev->port->phy_mask;
1731 slot->tx = mvi->tx_prod; 1944 slot->tx = mvi->tx_prod;
1732 mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag | 1945 mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag |
1733 (TXQ_CMD_SSP << TXQ_CMD_SHIFT) | 1946 (TXQ_CMD_SSP << TXQ_CMD_SHIFT) |
1734 (port->wide_port_phymap << TXQ_PHY_SHIFT)); 1947 (phy_mask << TXQ_PHY_SHIFT));
1735 1948
1736 flags = MCH_RETRY; 1949 flags = MCH_RETRY;
1737 if (task->ssp_task.enable_first_burst) { 1950 if (task->ssp_task.enable_first_burst) {
@@ -1832,22 +2045,32 @@ static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags)
1832 void __iomem *regs = mvi->regs; 2045 void __iomem *regs = mvi->regs;
1833 struct mvs_task_exec_info tei; 2046 struct mvs_task_exec_info tei;
1834 struct sas_task *t = task; 2047 struct sas_task *t = task;
2048 struct mvs_slot_info *slot;
1835 u32 tag = 0xdeadbeef, rc, n_elem = 0; 2049 u32 tag = 0xdeadbeef, rc, n_elem = 0;
1836 unsigned long flags; 2050 unsigned long flags;
1837 u32 n = num, pass = 0; 2051 u32 n = num, pass = 0;
1838 2052
1839 spin_lock_irqsave(&mvi->lock, flags); 2053 spin_lock_irqsave(&mvi->lock, flags);
1840
1841 do { 2054 do {
2055 dev = t->dev;
1842 tei.port = &mvi->port[dev->port->id]; 2056 tei.port = &mvi->port[dev->port->id];
1843 2057
1844 if (!tei.port->port_attached) { 2058 if (!tei.port->port_attached) {
1845 struct task_status_struct *ts = &t->task_status; 2059 if (sas_protocol_ata(t->task_proto)) {
1846 ts->stat = SAS_PHY_DOWN; 2060 rc = SAS_PHY_DOWN;
1847 t->task_done(t); 2061 goto out_done;
1848 rc = 0; 2062 } else {
1849 goto exec_exit; 2063 struct task_status_struct *ts = &t->task_status;
2064 ts->resp = SAS_TASK_UNDELIVERED;
2065 ts->stat = SAS_PHY_DOWN;
2066 t->task_done(t);
2067 if (n > 1)
2068 t = list_entry(t->list.next,
2069 struct sas_task, list);
2070 continue;
2071 }
1850 } 2072 }
2073
1851 if (!sas_protocol_ata(t->task_proto)) { 2074 if (!sas_protocol_ata(t->task_proto)) {
1852 if (t->num_scatter) { 2075 if (t->num_scatter) {
1853 n_elem = pci_map_sg(mvi->pdev, t->scatter, 2076 n_elem = pci_map_sg(mvi->pdev, t->scatter,
@@ -1866,9 +2089,10 @@ static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags)
1866 if (rc) 2089 if (rc)
1867 goto err_out; 2090 goto err_out;
1868 2091
1869 mvi->slot_info[tag].task = t; 2092 slot = &mvi->slot_info[tag];
1870 mvi->slot_info[tag].n_elem = n_elem; 2093 t->lldd_task = NULL;
1871 memset(mvi->slot_info[tag].buf, 0, MVS_SLOT_BUF_SZ); 2094 slot->n_elem = n_elem;
2095 memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
1872 tei.task = t; 2096 tei.task = t;
1873 tei.hdr = &mvi->slot[tag]; 2097 tei.hdr = &mvi->slot[tag];
1874 tei.tag = tag; 2098 tei.tag = tag;
@@ -1897,28 +2121,26 @@ static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags)
1897 if (rc) 2121 if (rc)
1898 goto err_out_tag; 2122 goto err_out_tag;
1899 2123
2124 slot->task = t;
2125 slot->port = tei.port;
2126 t->lldd_task = (void *) slot;
2127 list_add_tail(&slot->list, &slot->port->list);
1900 /* TODO: select normal or high priority */ 2128 /* TODO: select normal or high priority */
1901 2129
1902 spin_lock(&t->task_state_lock); 2130 spin_lock(&t->task_state_lock);
1903 t->task_state_flags |= SAS_TASK_AT_INITIATOR; 2131 t->task_state_flags |= SAS_TASK_AT_INITIATOR;
1904 spin_unlock(&t->task_state_lock); 2132 spin_unlock(&t->task_state_lock);
1905 2133
1906 if (n == 1) {
1907 spin_unlock_irqrestore(&mvi->lock, flags);
1908 mw32(TX_PROD_IDX, mvi->tx_prod);
1909 }
1910 mvs_hba_memory_dump(mvi, tag, t->task_proto); 2134 mvs_hba_memory_dump(mvi, tag, t->task_proto);
1911 2135
1912 ++pass; 2136 ++pass;
1913 mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1); 2137 mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1);
1914 2138 if (n > 1)
1915 if (n == 1) 2139 t = list_entry(t->list.next, struct sas_task, list);
1916 break;
1917
1918 t = list_entry(t->list.next, struct sas_task, list);
1919 } while (--n); 2140 } while (--n);
1920 2141
1921 return 0; 2142 rc = 0;
2143 goto out_done;
1922 2144
1923err_out_tag: 2145err_out_tag:
1924 mvs_tag_free(mvi, tag); 2146 mvs_tag_free(mvi, tag);
@@ -1928,7 +2150,7 @@ err_out:
1928 if (n_elem) 2150 if (n_elem)
1929 pci_unmap_sg(mvi->pdev, t->scatter, n_elem, 2151 pci_unmap_sg(mvi->pdev, t->scatter, n_elem,
1930 t->data_dir); 2152 t->data_dir);
1931exec_exit: 2153out_done:
1932 if (pass) 2154 if (pass)
1933 mw32(TX_PROD_IDX, (mvi->tx_prod - 1) & (MVS_CHIP_SLOT_SZ - 1)); 2155 mw32(TX_PROD_IDX, (mvi->tx_prod - 1) & (MVS_CHIP_SLOT_SZ - 1));
1934 spin_unlock_irqrestore(&mvi->lock, flags); 2156 spin_unlock_irqrestore(&mvi->lock, flags);
@@ -1937,42 +2159,59 @@ exec_exit:
1937 2159
1938static int mvs_task_abort(struct sas_task *task) 2160static int mvs_task_abort(struct sas_task *task)
1939{ 2161{
1940 int rc = 1; 2162 int rc;
1941 unsigned long flags; 2163 unsigned long flags;
1942 struct mvs_info *mvi = task->dev->port->ha->lldd_ha; 2164 struct mvs_info *mvi = task->dev->port->ha->lldd_ha;
1943 struct pci_dev *pdev = mvi->pdev; 2165 struct pci_dev *pdev = mvi->pdev;
2166 int tag;
1944 2167
1945 spin_lock_irqsave(&task->task_state_lock, flags); 2168 spin_lock_irqsave(&task->task_state_lock, flags);
1946 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 2169 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
1947 rc = TMF_RESP_FUNC_COMPLETE; 2170 rc = TMF_RESP_FUNC_COMPLETE;
2171 spin_unlock_irqrestore(&task->task_state_lock, flags);
1948 goto out_done; 2172 goto out_done;
1949 } 2173 }
1950 spin_unlock_irqrestore(&task->task_state_lock, flags); 2174 spin_unlock_irqrestore(&task->task_state_lock, flags);
1951 2175
1952 /*FIXME*/
1953 rc = TMF_RESP_FUNC_COMPLETE;
1954
1955 switch (task->task_proto) { 2176 switch (task->task_proto) {
1956 case SAS_PROTOCOL_SMP: 2177 case SAS_PROTOCOL_SMP:
1957 dev_printk(KERN_DEBUG, &pdev->dev, "SMP Abort! "); 2178 dev_printk(KERN_DEBUG, &pdev->dev, "SMP Abort! \n");
1958 break; 2179 break;
1959 case SAS_PROTOCOL_SSP: 2180 case SAS_PROTOCOL_SSP:
1960 dev_printk(KERN_DEBUG, &pdev->dev, "SSP Abort! "); 2181 dev_printk(KERN_DEBUG, &pdev->dev, "SSP Abort! \n");
1961 break; 2182 break;
1962 case SAS_PROTOCOL_SATA: 2183 case SAS_PROTOCOL_SATA:
1963 case SAS_PROTOCOL_STP: 2184 case SAS_PROTOCOL_STP:
1964 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:{ 2185 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:{
1965 dev_printk(KERN_DEBUG, &pdev->dev, "STP Abort! " 2186 dev_printk(KERN_DEBUG, &pdev->dev, "STP Abort! \n");
1966 "Dump D2H FIS: \n"); 2187#if _MV_DUMP
2188 dev_printk(KERN_DEBUG, &pdev->dev, "Dump D2H FIS: \n");
1967 mvs_hexdump(sizeof(struct host_to_dev_fis), 2189 mvs_hexdump(sizeof(struct host_to_dev_fis),
1968 (void *)&task->ata_task.fis, 0); 2190 (void *)&task->ata_task.fis, 0);
1969 dev_printk(KERN_DEBUG, &pdev->dev, "Dump ATAPI Cmd : \n"); 2191 dev_printk(KERN_DEBUG, &pdev->dev, "Dump ATAPI Cmd : \n");
1970 mvs_hexdump(16, task->ata_task.atapi_packet, 0); 2192 mvs_hexdump(16, task->ata_task.atapi_packet, 0);
2193#endif
2194 spin_lock_irqsave(&task->task_state_lock, flags);
2195 if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET) {
2196 /* TODO */
2197 ;
2198 }
2199 spin_unlock_irqrestore(&task->task_state_lock, flags);
1971 break; 2200 break;
1972 } 2201 }
1973 default: 2202 default:
1974 break; 2203 break;
1975 } 2204 }
2205
2206 if (mvs_find_tag(mvi, task, &tag)) {
2207 spin_lock_irqsave(&mvi->lock, flags);
2208 mvs_slot_task_free(mvi, task, &mvi->slot_info[tag], tag);
2209 spin_unlock_irqrestore(&mvi->lock, flags);
2210 }
2211 if (!mvs_task_exec(task, 1, GFP_ATOMIC))
2212 rc = TMF_RESP_FUNC_COMPLETE;
2213 else
2214 rc = TMF_RESP_FUNC_FAILED;
1976out_done: 2215out_done:
1977 return rc; 2216 return rc;
1978} 2217}
@@ -2001,7 +2240,7 @@ static void mvs_free(struct mvs_info *mvi)
2001 mvi->rx_fis, mvi->rx_fis_dma); 2240 mvi->rx_fis, mvi->rx_fis_dma);
2002 if (mvi->rx) 2241 if (mvi->rx)
2003 dma_free_coherent(&mvi->pdev->dev, 2242 dma_free_coherent(&mvi->pdev->dev,
2004 sizeof(*mvi->rx) * MVS_RX_RING_SZ, 2243 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
2005 mvi->rx, mvi->rx_dma); 2244 mvi->rx, mvi->rx_dma);
2006 if (mvi->slot) 2245 if (mvi->slot)
2007 dma_free_coherent(&mvi->pdev->dev, 2246 dma_free_coherent(&mvi->pdev->dev,
@@ -2109,6 +2348,9 @@ static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
2109 return NULL; 2348 return NULL;
2110 2349
2111 spin_lock_init(&mvi->lock); 2350 spin_lock_init(&mvi->lock);
2351#ifdef MVS_USE_TASKLET
2352 tasklet_init(&mvi->tasklet, mvs_tasklet, (unsigned long)mvi);
2353#endif
2112 mvi->pdev = pdev; 2354 mvi->pdev = pdev;
2113 mvi->chip = chip; 2355 mvi->chip = chip;
2114 2356
@@ -2132,6 +2374,10 @@ static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
2132 mvs_phy_init(mvi, i); 2374 mvs_phy_init(mvi, i);
2133 arr_phy[i] = &mvi->phy[i].sas_phy; 2375 arr_phy[i] = &mvi->phy[i].sas_phy;
2134 arr_port[i] = &mvi->port[i].sas_port; 2376 arr_port[i] = &mvi->port[i].sas_port;
2377 mvi->port[i].taskfileset = MVS_ID_NOT_MAPPED;
2378 mvi->port[i].wide_port_phymap = 0;
2379 mvi->port[i].port_attached = 0;
2380 INIT_LIST_HEAD(&mvi->port[i].list);
2135 } 2381 }
2136 2382
2137 SHOST_TO_SAS_HA(mvi->shost) = &mvi->sas; 2383 SHOST_TO_SAS_HA(mvi->shost) = &mvi->sas;
@@ -2148,9 +2394,10 @@ static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
2148 mvi->sas.sas_phy = arr_phy; 2394 mvi->sas.sas_phy = arr_phy;
2149 mvi->sas.sas_port = arr_port; 2395 mvi->sas.sas_port = arr_port;
2150 mvi->sas.num_phys = chip->n_phy; 2396 mvi->sas.num_phys = chip->n_phy;
2151 mvi->sas.lldd_max_execute_num = MVS_CHIP_SLOT_SZ - 1; 2397 mvi->sas.lldd_max_execute_num = 1;
2152 mvi->sas.lldd_queue_size = MVS_QUEUE_SIZE; 2398 mvi->sas.lldd_queue_size = MVS_QUEUE_SIZE;
2153 mvi->can_queue = (MVS_CHIP_SLOT_SZ >> 1) - 1; 2399 mvi->shost->can_queue = MVS_CAN_QUEUE;
2400 mvi->shost->cmd_per_lun = MVS_SLOTS / mvi->sas.num_phys;
2154 mvi->sas.lldd_ha = mvi; 2401 mvi->sas.lldd_ha = mvi;
2155 mvi->sas.core.shost = mvi->shost; 2402 mvi->sas.core.shost = mvi->shost;
2156 2403
@@ -2203,11 +2450,11 @@ static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
2203 memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ); 2450 memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ);
2204 2451
2205 mvi->rx = dma_alloc_coherent(&pdev->dev, 2452 mvi->rx = dma_alloc_coherent(&pdev->dev,
2206 sizeof(*mvi->rx) * MVS_RX_RING_SZ, 2453 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
2207 &mvi->rx_dma, GFP_KERNEL); 2454 &mvi->rx_dma, GFP_KERNEL);
2208 if (!mvi->rx) 2455 if (!mvi->rx)
2209 goto err_out; 2456 goto err_out;
2210 memset(mvi->rx, 0, sizeof(*mvi->rx) * MVS_RX_RING_SZ); 2457 memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1));
2211 2458
2212 mvi->rx[0] = cpu_to_le32(0xfff); 2459 mvi->rx[0] = cpu_to_le32(0xfff);
2213 mvi->rx_cons = 0xfff; 2460 mvi->rx_cons = 0xfff;
@@ -2357,7 +2604,7 @@ static void __devinit mvs_phy_hacks(struct mvs_info *mvi)
2357 mvs_cw32(regs, CMD_SAS_CTL0, tmp); 2604 mvs_cw32(regs, CMD_SAS_CTL0, tmp);
2358 2605
2359 /* workaround for WDTIMEOUT , set to 550 ms */ 2606 /* workaround for WDTIMEOUT , set to 550 ms */
2360 mvs_cw32(regs, CMD_WD_TIMER, 0xffffff); 2607 mvs_cw32(regs, CMD_WD_TIMER, 0x86470);
2361 2608
2362 /* not to halt for different port op during wideport link change */ 2609 /* not to halt for different port op during wideport link change */
2363 mvs_cw32(regs, CMD_APP_ERR_CONFIG, 0xffefbf7d); 2610 mvs_cw32(regs, CMD_APP_ERR_CONFIG, 0xffefbf7d);
@@ -2465,17 +2712,16 @@ static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i)
2465{ 2712{
2466 u32 tmp; 2713 u32 tmp;
2467 struct mvs_phy *phy = &mvi->phy[i]; 2714 struct mvs_phy *phy = &mvi->phy[i];
2468 struct mvs_port *port; 2715 struct mvs_port *port = phy->port;;
2469 2716
2470 tmp = mvs_read_phy_ctl(mvi, i); 2717 tmp = mvs_read_phy_ctl(mvi, i);
2471 2718
2472 if ((tmp & PHY_READY_MASK) && !(phy->irq_status & PHYEV_POOF)) { 2719 if ((tmp & PHY_READY_MASK) && !(phy->irq_status & PHYEV_POOF)) {
2473 if (!phy->port) 2720 if (!port)
2474 phy->phy_attached = 1; 2721 phy->phy_attached = 1;
2475 return tmp; 2722 return tmp;
2476 } 2723 }
2477 2724
2478 port = phy->port;
2479 if (port) { 2725 if (port) {
2480 if (phy->phy_type & PORT_TYPE_SAS) { 2726 if (phy->phy_type & PORT_TYPE_SAS) {
2481 port->wide_port_phymap &= ~(1U << i); 2727 port->wide_port_phymap &= ~(1U << i);
@@ -2497,7 +2743,7 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2497{ 2743{
2498 struct mvs_phy *phy = &mvi->phy[i]; 2744 struct mvs_phy *phy = &mvi->phy[i];
2499 struct pci_dev *pdev = mvi->pdev; 2745 struct pci_dev *pdev = mvi->pdev;
2500 u32 tmp, j; 2746 u32 tmp;
2501 u64 tmp64; 2747 u64 tmp64;
2502 2748
2503 mvs_write_port_cfg_addr(mvi, i, PHYR_IDENTIFY); 2749 mvs_write_port_cfg_addr(mvi, i, PHYR_IDENTIFY);
@@ -2524,46 +2770,20 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2524 sas_phy->linkrate = 2770 sas_phy->linkrate =
2525 (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >> 2771 (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
2526 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET; 2772 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET;
2527 2773 phy->minimum_linkrate =
2528 /* Updated attached_sas_addr */ 2774 (phy->phy_status &
2529 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_HI); 2775 PHY_MIN_SPP_PHYS_LINK_RATE_MASK) >> 8;
2530 phy->att_dev_sas_addr = 2776 phy->maximum_linkrate =
2531 (u64) mvs_read_port_cfg_data(mvi, i) << 32; 2777 (phy->phy_status &
2532 2778 PHY_MAX_SPP_PHYS_LINK_RATE_MASK) >> 12;
2533 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_LO);
2534 phy->att_dev_sas_addr |= mvs_read_port_cfg_data(mvi, i);
2535
2536 dev_printk(KERN_DEBUG, &pdev->dev,
2537 "phy[%d] Get Attached Address 0x%llX ,"
2538 " SAS Address 0x%llX\n",
2539 i, phy->att_dev_sas_addr, phy->dev_sas_addr);
2540 dev_printk(KERN_DEBUG, &pdev->dev,
2541 "Rate = %x , type = %d\n",
2542 sas_phy->linkrate, phy->phy_type);
2543
2544#if 1
2545 /*
2546 * If the device is capable of supporting a wide port
2547 * on its phys, it may configure the phys as a wide port.
2548 */
2549 if (phy->phy_type & PORT_TYPE_SAS)
2550 for (j = 0; j < mvi->chip->n_phy && j != i; ++j) {
2551 if ((mvi->phy[j].phy_attached) &&
2552 (mvi->phy[j].phy_type & PORT_TYPE_SAS))
2553 if (phy->att_dev_sas_addr ==
2554 mvi->phy[j].att_dev_sas_addr - 1) {
2555 phy->att_dev_sas_addr =
2556 mvi->phy[j].att_dev_sas_addr;
2557 break;
2558 }
2559 }
2560
2561#endif
2562
2563 tmp64 = cpu_to_be64(phy->att_dev_sas_addr);
2564 memcpy(sas_phy->attached_sas_addr, &tmp64, SAS_ADDR_SIZE);
2565 2779
2566 if (phy->phy_type & PORT_TYPE_SAS) { 2780 if (phy->phy_type & PORT_TYPE_SAS) {
2781 /* Updated attached_sas_addr */
2782 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_HI);
2783 phy->att_dev_sas_addr =
2784 (u64) mvs_read_port_cfg_data(mvi, i) << 32;
2785 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_LO);
2786 phy->att_dev_sas_addr |= mvs_read_port_cfg_data(mvi, i);
2567 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_DEV_INFO); 2787 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_DEV_INFO);
2568 phy->att_dev_info = mvs_read_port_cfg_data(mvi, i); 2788 phy->att_dev_info = mvs_read_port_cfg_data(mvi, i);
2569 phy->identify.device_type = 2789 phy->identify.device_type =
@@ -2582,6 +2802,7 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2582 } else if (phy->phy_type & PORT_TYPE_SATA) { 2802 } else if (phy->phy_type & PORT_TYPE_SATA) {
2583 phy->identify.target_port_protocols = SAS_PROTOCOL_STP; 2803 phy->identify.target_port_protocols = SAS_PROTOCOL_STP;
2584 if (mvs_is_sig_fis_received(phy->irq_status)) { 2804 if (mvs_is_sig_fis_received(phy->irq_status)) {
2805 phy->att_dev_sas_addr = i; /* temp */
2585 if (phy_st & PHY_OOB_DTCTD) 2806 if (phy_st & PHY_OOB_DTCTD)
2586 sas_phy->oob_mode = SATA_OOB_MODE; 2807 sas_phy->oob_mode = SATA_OOB_MODE;
2587 phy->frame_rcvd_size = 2808 phy->frame_rcvd_size =
@@ -2591,20 +2812,34 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2591 } else { 2812 } else {
2592 dev_printk(KERN_DEBUG, &pdev->dev, 2813 dev_printk(KERN_DEBUG, &pdev->dev,
2593 "No sig fis\n"); 2814 "No sig fis\n");
2815 phy->phy_type &= ~(PORT_TYPE_SATA);
2816 goto out_done;
2594 } 2817 }
2595 } 2818 }
2819 tmp64 = cpu_to_be64(phy->att_dev_sas_addr);
2820 memcpy(sas_phy->attached_sas_addr, &tmp64, SAS_ADDR_SIZE);
2821
2822 dev_printk(KERN_DEBUG, &pdev->dev,
2823 "phy[%d] Get Attached Address 0x%llX ,"
2824 " SAS Address 0x%llX\n",
2825 i, phy->att_dev_sas_addr, phy->dev_sas_addr);
2826 dev_printk(KERN_DEBUG, &pdev->dev,
2827 "Rate = %x , type = %d\n",
2828 sas_phy->linkrate, phy->phy_type);
2829
2596 /* workaround for HW phy decoding error on 1.5g disk drive */ 2830 /* workaround for HW phy decoding error on 1.5g disk drive */
2597 mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE6); 2831 mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE6);
2598 tmp = mvs_read_port_vsr_data(mvi, i); 2832 tmp = mvs_read_port_vsr_data(mvi, i);
2599 if (((phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >> 2833 if (((phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
2600 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET) == 2834 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET) ==
2601 SAS_LINK_RATE_1_5_GBPS) 2835 SAS_LINK_RATE_1_5_GBPS)
2602 tmp &= ~PHY_MODE6_DTL_SPEED; 2836 tmp &= ~PHY_MODE6_LATECLK;
2603 else 2837 else
2604 tmp |= PHY_MODE6_DTL_SPEED; 2838 tmp |= PHY_MODE6_LATECLK;
2605 mvs_write_port_vsr_data(mvi, i, tmp); 2839 mvs_write_port_vsr_data(mvi, i, tmp);
2606 2840
2607 } 2841 }
2842out_done:
2608 if (get_st) 2843 if (get_st)
2609 mvs_write_port_irq_stat(mvi, i, phy->irq_status); 2844 mvs_write_port_irq_stat(mvi, i, phy->irq_status);
2610} 2845}
@@ -2629,6 +2864,11 @@ static void mvs_port_formed(struct asd_sas_phy *sas_phy)
2629 spin_unlock_irqrestore(&mvi->lock, flags); 2864 spin_unlock_irqrestore(&mvi->lock, flags);
2630} 2865}
2631 2866
2867static int mvs_I_T_nexus_reset(struct domain_device *dev)
2868{
2869 return TMF_RESP_FUNC_FAILED;
2870}
2871
2632static int __devinit mvs_hw_init(struct mvs_info *mvi) 2872static int __devinit mvs_hw_init(struct mvs_info *mvi)
2633{ 2873{
2634 void __iomem *regs = mvi->regs; 2874 void __iomem *regs = mvi->regs;
@@ -2790,13 +3030,12 @@ static int __devinit mvs_hw_init(struct mvs_info *mvi)
2790 /* enable CMD/CMPL_Q/RESP mode */ 3030 /* enable CMD/CMPL_Q/RESP mode */
2791 mw32(PCS, PCS_SATA_RETRY | PCS_FIS_RX_EN | PCS_CMD_EN); 3031 mw32(PCS, PCS_SATA_RETRY | PCS_FIS_RX_EN | PCS_CMD_EN);
2792 3032
2793 /* re-enable interrupts globally */
2794 mvs_hba_interrupt_enable(mvi);
2795
2796 /* enable completion queue interrupt */ 3033 /* enable completion queue interrupt */
2797 tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM); 3034 tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM | CINT_SRS);
2798 mw32(INT_MASK, tmp); 3035 mw32(INT_MASK, tmp);
2799 3036
3037 /* Enable SRS interrupt */
3038 mw32(INT_MASK_SRS, 0xFF);
2800 return 0; 3039 return 0;
2801} 3040}
2802 3041
@@ -2870,6 +3109,8 @@ static int __devinit mvs_pci_init(struct pci_dev *pdev,
2870 3109
2871 mvs_print_info(mvi); 3110 mvs_print_info(mvi);
2872 3111
3112 mvs_hba_interrupt_enable(mvi);
3113
2873 scsi_scan_host(mvi->shost); 3114 scsi_scan_host(mvi->shost);
2874 3115
2875 return 0; 3116 return 0;
@@ -2915,12 +3156,22 @@ static struct sas_domain_function_template mvs_transport_ops = {
2915 .lldd_execute_task = mvs_task_exec, 3156 .lldd_execute_task = mvs_task_exec,
2916 .lldd_control_phy = mvs_phy_control, 3157 .lldd_control_phy = mvs_phy_control,
2917 .lldd_abort_task = mvs_task_abort, 3158 .lldd_abort_task = mvs_task_abort,
2918 .lldd_port_formed = mvs_port_formed 3159 .lldd_port_formed = mvs_port_formed,
3160 .lldd_I_T_nexus_reset = mvs_I_T_nexus_reset,
2919}; 3161};
2920 3162
2921static struct pci_device_id __devinitdata mvs_pci_table[] = { 3163static struct pci_device_id __devinitdata mvs_pci_table[] = {
2922 { PCI_VDEVICE(MARVELL, 0x6320), chip_6320 }, 3164 { PCI_VDEVICE(MARVELL, 0x6320), chip_6320 },
2923 { PCI_VDEVICE(MARVELL, 0x6340), chip_6440 }, 3165 { PCI_VDEVICE(MARVELL, 0x6340), chip_6440 },
3166 {
3167 .vendor = PCI_VENDOR_ID_MARVELL,
3168 .device = 0x6440,
3169 .subvendor = PCI_ANY_ID,
3170 .subdevice = 0x6480,
3171 .class = 0,
3172 .class_mask = 0,
3173 .driver_data = chip_6480,
3174 },
2924 { PCI_VDEVICE(MARVELL, 0x6440), chip_6440 }, 3175 { PCI_VDEVICE(MARVELL, 0x6440), chip_6440 },
2925 { PCI_VDEVICE(MARVELL, 0x6480), chip_6480 }, 3176 { PCI_VDEVICE(MARVELL, 0x6480), chip_6480 },
2926 3177
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index e5c6f6af8765..c78b836f59dd 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -181,6 +181,18 @@ struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
181 cmd = kmem_cache_alloc(shost->cmd_pool->cmd_slab, 181 cmd = kmem_cache_alloc(shost->cmd_pool->cmd_slab,
182 gfp_mask | shost->cmd_pool->gfp_mask); 182 gfp_mask | shost->cmd_pool->gfp_mask);
183 183
184 if (likely(cmd)) {
185 buf = kmem_cache_alloc(shost->cmd_pool->sense_slab,
186 gfp_mask | shost->cmd_pool->gfp_mask);
187 if (likely(buf)) {
188 memset(cmd, 0, sizeof(*cmd));
189 cmd->sense_buffer = buf;
190 } else {
191 kmem_cache_free(shost->cmd_pool->cmd_slab, cmd);
192 cmd = NULL;
193 }
194 }
195
184 if (unlikely(!cmd)) { 196 if (unlikely(!cmd)) {
185 unsigned long flags; 197 unsigned long flags;
186 198
@@ -197,16 +209,6 @@ struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
197 memset(cmd, 0, sizeof(*cmd)); 209 memset(cmd, 0, sizeof(*cmd));
198 cmd->sense_buffer = buf; 210 cmd->sense_buffer = buf;
199 } 211 }
200 } else {
201 buf = kmem_cache_alloc(shost->cmd_pool->sense_slab,
202 gfp_mask | shost->cmd_pool->gfp_mask);
203 if (likely(buf)) {
204 memset(cmd, 0, sizeof(*cmd));
205 cmd->sense_buffer = buf;
206 } else {
207 kmem_cache_free(shost->cmd_pool->cmd_slab, cmd);
208 cmd = NULL;
209 }
210 } 212 }
211 213
212 return cmd; 214 return cmd;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b9b09a704584..ed83cdb6e67d 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -294,7 +294,6 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
294 } 294 }
295 295
296 if (sdev->request_queue) { 296 if (sdev->request_queue) {
297 bsg_unregister_queue(sdev->request_queue);
298 sdev->request_queue->queuedata = NULL; 297 sdev->request_queue->queuedata = NULL;
299 /* user context needed to free queue */ 298 /* user context needed to free queue */
300 scsi_free_queue(sdev->request_queue); 299 scsi_free_queue(sdev->request_queue);
@@ -858,6 +857,7 @@ void __scsi_remove_device(struct scsi_device *sdev)
858 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) 857 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
859 return; 858 return;
860 859
860 bsg_unregister_queue(sdev->request_queue);
861 class_device_unregister(&sdev->sdev_classdev); 861 class_device_unregister(&sdev->sdev_classdev);
862 transport_remove_device(dev); 862 transport_remove_device(dev);
863 device_del(dev); 863 device_del(dev);
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index a8bec498cad6..f97224ce59da 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -1214,13 +1214,6 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1214 .base_baud = 115200, 1214 .base_baud = 115200,
1215 .uart_offset = 8, 1215 .uart_offset = 8,
1216 }, 1216 },
1217 [pbn_b0_8_115200] = {
1218 .flags = FL_BASE0,
1219 .num_ports = 8,
1220 .base_baud = 115200,
1221 .uart_offset = 8,
1222 },
1223
1224 [pbn_b0_1_921600] = { 1217 [pbn_b0_1_921600] = {
1225 .flags = FL_BASE0, 1218 .flags = FL_BASE0,
1226 .num_ports = 1, 1219 .num_ports = 1,
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index d57bf3e708d8..430997e33fc4 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -96,6 +96,7 @@
96 96
97 /* PDC registers */ 97 /* PDC registers */
98#define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR) 98#define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR)
99#define UART_GET_TCR(port) __raw_readl((port)->membase + ATMEL_PDC_TCR)
99#define UART_GET_PTSR(port) __raw_readl((port)->membase + ATMEL_PDC_PTSR) 100#define UART_GET_PTSR(port) __raw_readl((port)->membase + ATMEL_PDC_PTSR)
100 101
101#define UART_PUT_RPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RPR) 102#define UART_PUT_RPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RPR)
@@ -106,6 +107,7 @@
106 107
107#define UART_PUT_TPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TPR) 108#define UART_PUT_TPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TPR)
108#define UART_PUT_TCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TCR) 109#define UART_PUT_TCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TCR)
110#define UART_GET_TCR(port) __raw_readl((port)->membase + ATMEL_PDC_TCR)
109 111
110static int (*atmel_open_hook)(struct uart_port *); 112static int (*atmel_open_hook)(struct uart_port *);
111static void (*atmel_close_hook)(struct uart_port *); 113static void (*atmel_close_hook)(struct uart_port *);
@@ -562,17 +564,22 @@ static void atmel_tx_dma(struct uart_port *port)
562 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; 564 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx;
563 int count; 565 int count;
564 566
567 /* nothing left to transmit? */
568 if (UART_GET_TCR(port))
569 return;
570
565 xmit->tail += pdc->ofs; 571 xmit->tail += pdc->ofs;
566 xmit->tail &= UART_XMIT_SIZE - 1; 572 xmit->tail &= UART_XMIT_SIZE - 1;
567 573
568 port->icount.tx += pdc->ofs; 574 port->icount.tx += pdc->ofs;
569 pdc->ofs = 0; 575 pdc->ofs = 0;
570 576
571 if (!uart_circ_empty(xmit)) { 577 /* more to transmit - setup next transfer */
572 /* more to transmit - setup next transfer */
573 578
574 /* disable PDC transmit */ 579 /* disable PDC transmit */
575 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS); 580 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
581
582 if (!uart_circ_empty(xmit)) {
576 dma_sync_single_for_device(port->dev, 583 dma_sync_single_for_device(port->dev,
577 pdc->dma_addr, 584 pdc->dma_addr,
578 pdc->dma_size, 585 pdc->dma_size,
@@ -586,11 +593,6 @@ static void atmel_tx_dma(struct uart_port *port)
586 /* re-enable PDC transmit and interrupts */ 593 /* re-enable PDC transmit and interrupts */
587 UART_PUT_PTCR(port, ATMEL_PDC_TXTEN); 594 UART_PUT_PTCR(port, ATMEL_PDC_TXTEN);
588 UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE); 595 UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE);
589 } else {
590 /* nothing left to transmit - disable the transmitter */
591
592 /* disable PDC transmit */
593 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
594 } 596 }
595 597
596 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 598 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
@@ -1274,6 +1276,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
1274{ 1276{
1275 struct uart_port *port = &atmel_ports[co->index].uart; 1277 struct uart_port *port = &atmel_ports[co->index].uart;
1276 unsigned int status, imr; 1278 unsigned int status, imr;
1279 unsigned int pdc_tx;
1277 1280
1278 /* 1281 /*
1279 * First, save IMR and then disable interrupts 1282 * First, save IMR and then disable interrupts
@@ -1281,6 +1284,10 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
1281 imr = UART_GET_IMR(port); 1284 imr = UART_GET_IMR(port);
1282 UART_PUT_IDR(port, ATMEL_US_RXRDY | ATMEL_US_TXRDY); 1285 UART_PUT_IDR(port, ATMEL_US_RXRDY | ATMEL_US_TXRDY);
1283 1286
1287 /* Store PDC transmit status and disable it */
1288 pdc_tx = UART_GET_PTSR(port) & ATMEL_PDC_TXTEN;
1289 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
1290
1284 uart_console_write(port, s, count, atmel_console_putchar); 1291 uart_console_write(port, s, count, atmel_console_putchar);
1285 1292
1286 /* 1293 /*
@@ -1290,6 +1297,11 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
1290 do { 1297 do {
1291 status = UART_GET_CSR(port); 1298 status = UART_GET_CSR(port);
1292 } while (!(status & ATMEL_US_TXRDY)); 1299 } while (!(status & ATMEL_US_TXRDY));
1300
1301 /* Restore PDC transmit status */
1302 if (pdc_tx)
1303 UART_PUT_PTCR(port, ATMEL_PDC_TXTEN);
1304
1293 /* set interrupts back the way they were */ 1305 /* set interrupts back the way they were */
1294 UART_PUT_IER(port, imr); 1306 UART_PUT_IER(port, imr);
1295} 1307}
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 85687aaf9cab..1749a27be066 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -863,3 +863,4 @@ module_exit(atmel_spi_exit);
863MODULE_DESCRIPTION("Atmel AT32/AT91 SPI Controller driver"); 863MODULE_DESCRIPTION("Atmel AT32/AT91 SPI Controller driver");
864MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>"); 864MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
865MODULE_LICENSE("GPL"); 865MODULE_LICENSE("GPL");
866MODULE_ALIAS("platform:atmel_spi");
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c
index 41a3d00c4515..072c4a595334 100644
--- a/drivers/spi/au1550_spi.c
+++ b/drivers/spi/au1550_spi.c
@@ -958,6 +958,9 @@ static int __exit au1550_spi_remove(struct platform_device *pdev)
958 return 0; 958 return 0;
959} 959}
960 960
961/* work with hotplug and coldplug */
962MODULE_ALIAS("platform:au1550-spi");
963
961static struct platform_driver au1550_spi_drv = { 964static struct platform_driver au1550_spi_drv = {
962 .remove = __exit_p(au1550_spi_remove), 965 .remove = __exit_p(au1550_spi_remove),
963 .driver = { 966 .driver = {
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index a86315a0c5b8..90729469d481 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -500,6 +500,9 @@ static int __exit mpc52xx_psc_spi_remove(struct platform_device *dev)
500 return mpc52xx_psc_spi_do_remove(&dev->dev); 500 return mpc52xx_psc_spi_do_remove(&dev->dev);
501} 501}
502 502
503/* work with hotplug and coldplug */
504MODULE_ALIAS("platform:mpc52xx-psc-spi");
505
503static struct platform_driver mpc52xx_psc_spi_platform_driver = { 506static struct platform_driver mpc52xx_psc_spi_platform_driver = {
504 .remove = __exit_p(mpc52xx_psc_spi_remove), 507 .remove = __exit_p(mpc52xx_psc_spi_remove),
505 .driver = { 508 .driver = {
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index a6ba11afb03f..b1cc148036c1 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -1084,6 +1084,9 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
1084 return 0; 1084 return 0;
1085} 1085}
1086 1086
1087/* work with hotplug and coldplug */
1088MODULE_ALIAS("platform:omap2_mcspi");
1089
1087static struct platform_driver omap2_mcspi_driver = { 1090static struct platform_driver omap2_mcspi_driver = {
1088 .driver = { 1091 .driver = {
1089 .name = "omap2_mcspi", 1092 .name = "omap2_mcspi",
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c
index 8245b5153f30..5f00bd6500ef 100644
--- a/drivers/spi/omap_uwire.c
+++ b/drivers/spi/omap_uwire.c
@@ -537,10 +537,12 @@ static int __exit uwire_remove(struct platform_device *pdev)
537 return status; 537 return status;
538} 538}
539 539
540/* work with hotplug and coldplug */
541MODULE_ALIAS("platform:omap_uwire");
542
540static struct platform_driver uwire_driver = { 543static struct platform_driver uwire_driver = {
541 .driver = { 544 .driver = {
542 .name = "omap_uwire", 545 .name = "omap_uwire",
543 .bus = &platform_bus_type,
544 .owner = THIS_MODULE, 546 .owner = THIS_MODULE,
545 }, 547 },
546 .remove = __exit_p(uwire_remove), 548 .remove = __exit_p(uwire_remove),
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 59deed79e0ab..147e26a78d64 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -44,6 +44,7 @@
44MODULE_AUTHOR("Stephen Street"); 44MODULE_AUTHOR("Stephen Street");
45MODULE_DESCRIPTION("PXA2xx SSP SPI Controller"); 45MODULE_DESCRIPTION("PXA2xx SSP SPI Controller");
46MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
47MODULE_ALIAS("platform:pxa2xx-spi");
47 48
48#define MAX_BUSES 3 49#define MAX_BUSES 3
49 50
@@ -1581,7 +1582,6 @@ static int pxa2xx_spi_resume(struct platform_device *pdev)
1581static struct platform_driver driver = { 1582static struct platform_driver driver = {
1582 .driver = { 1583 .driver = {
1583 .name = "pxa2xx-spi", 1584 .name = "pxa2xx-spi",
1584 .bus = &platform_bus_type,
1585 .owner = THIS_MODULE, 1585 .owner = THIS_MODULE,
1586 }, 1586 },
1587 .remove = pxa2xx_spi_remove, 1587 .remove = pxa2xx_spi_remove,
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index d853fceb6bf0..a9ac1fdb3094 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -713,8 +713,8 @@ static void pump_transfers(unsigned long data)
713 } else { 713 } else {
714 drv_data->len = transfer->len; 714 drv_data->len = transfer->len;
715 } 715 }
716 dev_dbg(&drv_data->pdev->dev, "transfer: ", 716 dev_dbg(&drv_data->pdev->dev,
717 "drv_data->write is %p, chip->write is %p, null_wr is %p\n", 717 "transfer: drv_data->write is %p, chip->write is %p, null_wr is %p\n",
718 drv_data->write, chip->write, null_writer); 718 drv_data->write, chip->write, null_writer);
719 719
720 /* speed and width has been set on per message */ 720 /* speed and width has been set on per message */
@@ -1294,6 +1294,12 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev)
1294 goto out_error_queue_alloc; 1294 goto out_error_queue_alloc;
1295 } 1295 }
1296 1296
1297 status = peripheral_request_list(drv_data->pin_req, DRV_NAME);
1298 if (status != 0) {
1299 dev_err(&pdev->dev, ": Requesting Peripherals failed\n");
1300 goto out_error_queue_alloc;
1301 }
1302
1297 /* Register with the SPI framework */ 1303 /* Register with the SPI framework */
1298 platform_set_drvdata(pdev, drv_data); 1304 platform_set_drvdata(pdev, drv_data);
1299 status = spi_register_master(master); 1305 status = spi_register_master(master);
@@ -1302,12 +1308,6 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev)
1302 goto out_error_queue_alloc; 1308 goto out_error_queue_alloc;
1303 } 1309 }
1304 1310
1305 status = peripheral_request_list(drv_data->pin_req, DRV_NAME);
1306 if (status != 0) {
1307 dev_err(&pdev->dev, ": Requesting Peripherals failed\n");
1308 goto out_error;
1309 }
1310
1311 dev_info(dev, "%s, Version %s, regs_base@%p, dma channel@%d\n", 1311 dev_info(dev, "%s, Version %s, regs_base@%p, dma channel@%d\n",
1312 DRV_DESC, DRV_VERSION, drv_data->regs_base, 1312 DRV_DESC, DRV_VERSION, drv_data->regs_base,
1313 drv_data->dma_channel); 1313 drv_data->dma_channel);
@@ -1319,7 +1319,6 @@ out_error_no_dma_ch:
1319 iounmap((void *) drv_data->regs_base); 1319 iounmap((void *) drv_data->regs_base);
1320out_error_ioremap: 1320out_error_ioremap:
1321out_error_get_res: 1321out_error_get_res:
1322out_error:
1323 spi_master_put(master); 1322 spi_master_put(master);
1324 1323
1325 return status; 1324 return status;
@@ -1397,7 +1396,7 @@ static int bfin5xx_spi_resume(struct platform_device *pdev)
1397#define bfin5xx_spi_resume NULL 1396#define bfin5xx_spi_resume NULL
1398#endif /* CONFIG_PM */ 1397#endif /* CONFIG_PM */
1399 1398
1400MODULE_ALIAS("bfin-spi-master"); /* for platform bus hotplug */ 1399MODULE_ALIAS("platform:bfin-spi");
1401static struct platform_driver bfin5xx_spi_driver = { 1400static struct platform_driver bfin5xx_spi_driver = {
1402 .driver = { 1401 .driver = {
1403 .name = DRV_NAME, 1402 .name = DRV_NAME,
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 1b0647124933..d4ba640366b6 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -1722,10 +1722,12 @@ static int spi_imx_resume(struct platform_device *pdev)
1722#define spi_imx_resume NULL 1722#define spi_imx_resume NULL
1723#endif /* CONFIG_PM */ 1723#endif /* CONFIG_PM */
1724 1724
1725/* work with hotplug and coldplug */
1726MODULE_ALIAS("platform:spi_imx");
1727
1725static struct platform_driver driver = { 1728static struct platform_driver driver = {
1726 .driver = { 1729 .driver = {
1727 .name = "spi_imx", 1730 .name = "spi_imx",
1728 .bus = &platform_bus_type,
1729 .owner = THIS_MODULE, 1731 .owner = THIS_MODULE,
1730 }, 1732 },
1731 .remove = __exit_p(spi_imx_remove), 1733 .remove = __exit_p(spi_imx_remove),
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index 04f7cd9fc261..be15a6213205 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -523,11 +523,12 @@ static int __exit mpc83xx_spi_remove(struct platform_device *dev)
523 return 0; 523 return 0;
524} 524}
525 525
526MODULE_ALIAS("mpc83xx_spi"); /* for platform bus hotplug */ 526MODULE_ALIAS("platform:mpc83xx_spi");
527static struct platform_driver mpc83xx_spi_driver = { 527static struct platform_driver mpc83xx_spi_driver = {
528 .remove = __exit_p(mpc83xx_spi_remove), 528 .remove = __exit_p(mpc83xx_spi_remove),
529 .driver = { 529 .driver = {
530 .name = "mpc83xx_spi", 530 .name = "mpc83xx_spi",
531 .owner = THIS_MODULE,
531 }, 532 },
532}; 533};
533 534
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 6e834b8b9d27..e75103aac790 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -415,7 +415,7 @@ static int s3c24xx_spi_resume(struct platform_device *pdev)
415#define s3c24xx_spi_resume NULL 415#define s3c24xx_spi_resume NULL
416#endif 416#endif
417 417
418MODULE_ALIAS("s3c2410_spi"); /* for platform bus hotplug */ 418MODULE_ALIAS("platform:s3c2410-spi");
419static struct platform_driver s3c24xx_spidrv = { 419static struct platform_driver s3c24xx_spidrv = {
420 .remove = __exit_p(s3c24xx_spi_remove), 420 .remove = __exit_p(s3c24xx_spi_remove),
421 .suspend = s3c24xx_spi_suspend, 421 .suspend = s3c24xx_spi_suspend,
diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c
index 82ae7d7eca38..e33f6145c560 100644
--- a/drivers/spi/spi_s3c24xx_gpio.c
+++ b/drivers/spi/spi_s3c24xx_gpio.c
@@ -168,6 +168,8 @@ static int s3c2410_spigpio_remove(struct platform_device *dev)
168#define s3c2410_spigpio_suspend NULL 168#define s3c2410_spigpio_suspend NULL
169#define s3c2410_spigpio_resume NULL 169#define s3c2410_spigpio_resume NULL
170 170
171/* work with hotplug and coldplug */
172MODULE_ALIAS("platform:spi_s3c24xx_gpio");
171 173
172static struct platform_driver s3c2410_spigpio_drv = { 174static struct platform_driver s3c2410_spigpio_drv = {
173 .probe = s3c2410_spigpio_probe, 175 .probe = s3c2410_spigpio_probe,
diff --git a/drivers/spi/spi_sh_sci.c b/drivers/spi/spi_sh_sci.c
index 3dbe71b16d60..7d36720eb982 100644
--- a/drivers/spi/spi_sh_sci.c
+++ b/drivers/spi/spi_sh_sci.c
@@ -203,3 +203,4 @@ module_exit(sh_sci_spi_exit);
203MODULE_DESCRIPTION("SH SCI SPI Driver"); 203MODULE_DESCRIPTION("SH SCI SPI Driver");
204MODULE_AUTHOR("Magnus Damm <damm@opensource.se>"); 204MODULE_AUTHOR("Magnus Damm <damm@opensource.se>");
205MODULE_LICENSE("GPL"); 205MODULE_LICENSE("GPL");
206MODULE_ALIAS("platform:spi_sh_sci");
diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c
index 363ac8e68821..2296f37ea3c6 100644
--- a/drivers/spi/spi_txx9.c
+++ b/drivers/spi/spi_txx9.c
@@ -450,6 +450,9 @@ static int __exit txx9spi_remove(struct platform_device *dev)
450 return 0; 450 return 0;
451} 451}
452 452
453/* work with hotplug and coldplug */
454MODULE_ALIAS("platform:spi_txx9");
455
453static struct platform_driver txx9spi_driver = { 456static struct platform_driver txx9spi_driver = {
454 .remove = __exit_p(txx9spi_remove), 457 .remove = __exit_p(txx9spi_remove),
455 .driver = { 458 .driver = {
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index 5d04f520c123..cf6aef34fe25 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -408,6 +408,9 @@ static int __devexit xilinx_spi_remove(struct platform_device *dev)
408 return 0; 408 return 0;
409} 409}
410 410
411/* work with hotplug and coldplug */
412MODULE_ALIAS("platform:" XILINX_SPI_NAME);
413
411static struct platform_driver xilinx_spi_driver = { 414static struct platform_driver xilinx_spi_driver = {
412 .probe = xilinx_spi_probe, 415 .probe = xilinx_spi_probe,
413 .remove = __devexit_p(xilinx_spi_remove), 416 .remove = __devexit_p(xilinx_spi_remove),
diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c
index 3d3dd32bf3ab..a9e7eb45b2e7 100644
--- a/drivers/ssb/driver_mipscore.c
+++ b/drivers/ssb/driver_mipscore.c
@@ -109,12 +109,13 @@ static void set_irq(struct ssb_device *dev, unsigned int irq)
109 clear_irq(bus, oldirq); 109 clear_irq(bus, oldirq);
110 110
111 /* assign the new one */ 111 /* assign the new one */
112 if (irq == 0) 112 if (irq == 0) {
113 ssb_write32(mdev, SSB_INTVEC, ((1 << irqflag) & ssb_read32(mdev, SSB_INTVEC))); 113 ssb_write32(mdev, SSB_INTVEC, ((1 << irqflag) | ssb_read32(mdev, SSB_INTVEC)));
114 114 } else {
115 irqflag <<= ipsflag_irq_shift[irq]; 115 irqflag <<= ipsflag_irq_shift[irq];
116 irqflag |= (ssb_read32(mdev, SSB_IPSFLAG) & ~ipsflag_irq_mask[irq]); 116 irqflag |= (ssb_read32(mdev, SSB_IPSFLAG) & ~ipsflag_irq_mask[irq]);
117 ssb_write32(mdev, SSB_IPSFLAG, irqflag); 117 ssb_write32(mdev, SSB_IPSFLAG, irqflag);
118 }
118} 119}
119 120
120static void ssb_mips_serial_init(struct ssb_mipscore *mcore) 121static void ssb_mips_serial_init(struct ssb_mipscore *mcore)
diff --git a/drivers/ssb/driver_pcicore.c b/drivers/ssb/driver_pcicore.c
index 74b9a8aea52b..5d777f211699 100644
--- a/drivers/ssb/driver_pcicore.c
+++ b/drivers/ssb/driver_pcicore.c
@@ -551,7 +551,7 @@ int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
551 } else { 551 } else {
552 tmp = ssb_read32(dev, SSB_TPSFLAG); 552 tmp = ssb_read32(dev, SSB_TPSFLAG);
553 tmp &= SSB_TPSFLAG_BPFLAG; 553 tmp &= SSB_TPSFLAG_BPFLAG;
554 intvec |= tmp; 554 intvec |= (1 << tmp);
555 } 555 }
556 ssb_write32(pdev, SSB_INTVEC, intvec); 556 ssb_write32(pdev, SSB_INTVEC, intvec);
557 } 557 }
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index bedb2b4ee9d2..72017bf2e577 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -1044,6 +1044,12 @@ int ssb_bus_may_powerdown(struct ssb_bus *bus)
1044 goto out; 1044 goto out;
1045 1045
1046 cc = &bus->chipco; 1046 cc = &bus->chipco;
1047
1048 if (!cc->dev)
1049 goto out;
1050 if (cc->dev->id.revision < 5)
1051 goto out;
1052
1047 ssb_chipco_set_clockmode(cc, SSB_CLKMODE_SLOW); 1053 ssb_chipco_set_clockmode(cc, SSB_CLKMODE_SLOW);
1048 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 0); 1054 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 0);
1049 if (err) 1055 if (err)
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index a83e8b798ec9..fd15ced899d8 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1884,3 +1884,4 @@ module_exit(udc_exit_module);
1884MODULE_DESCRIPTION("AT91 udc driver"); 1884MODULE_DESCRIPTION("AT91 udc driver");
1885MODULE_AUTHOR("Thomas Rathbone, David Brownell"); 1885MODULE_AUTHOR("Thomas Rathbone, David Brownell");
1886MODULE_LICENSE("GPL"); 1886MODULE_LICENSE("GPL");
1887MODULE_ALIAS("platform:at91_udc");
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index af8b2a3a2d4a..b0db4c31d018 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -2054,6 +2054,7 @@ static struct platform_driver udc_driver = {
2054 .remove = __exit_p(usba_udc_remove), 2054 .remove = __exit_p(usba_udc_remove),
2055 .driver = { 2055 .driver = {
2056 .name = "atmel_usba_udc", 2056 .name = "atmel_usba_udc",
2057 .owner = THIS_MODULE,
2057 }, 2058 },
2058}; 2059};
2059 2060
@@ -2072,3 +2073,4 @@ module_exit(udc_exit);
2072MODULE_DESCRIPTION("Atmel USBA UDC driver"); 2073MODULE_DESCRIPTION("Atmel USBA UDC driver");
2073MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>"); 2074MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
2074MODULE_LICENSE("GPL"); 2075MODULE_LICENSE("GPL");
2076MODULE_ALIAS("platform:atmel_usba_udc");
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 63e8fa3a69e1..254012ad2b91 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -2475,3 +2475,4 @@ module_exit(udc_exit);
2475MODULE_DESCRIPTION(DRIVER_DESC); 2475MODULE_DESCRIPTION(DRIVER_DESC);
2476MODULE_AUTHOR(DRIVER_AUTHOR); 2476MODULE_AUTHOR(DRIVER_AUTHOR);
2477MODULE_LICENSE("GPL"); 2477MODULE_LICENSE("GPL");
2478MODULE_ALIAS("platform:fsl-usb2-udc");
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 37243ef7104e..078f72467671 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -2146,3 +2146,4 @@ module_exit(udc_exit);
2146MODULE_DESCRIPTION(DRIVER_DESC); 2146MODULE_DESCRIPTION(DRIVER_DESC);
2147MODULE_AUTHOR("Mikko Lahteenmaki, Bo Henriksen"); 2147MODULE_AUTHOR("Mikko Lahteenmaki, Bo Henriksen");
2148MODULE_LICENSE("GPL"); 2148MODULE_LICENSE("GPL");
2149MODULE_ALIAS("platform:lh7a40x_udc");
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 835948f0715a..ee6b35fa870f 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -35,6 +35,7 @@
35MODULE_DESCRIPTION("M66592 USB gadget driver"); 35MODULE_DESCRIPTION("M66592 USB gadget driver");
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37MODULE_AUTHOR("Yoshihiro Shimoda"); 37MODULE_AUTHOR("Yoshihiro Shimoda");
38MODULE_ALIAS("platform:m66592_udc");
38 39
39#define DRIVER_VERSION "18 Oct 2007" 40#define DRIVER_VERSION "18 Oct 2007"
40 41
@@ -1671,6 +1672,7 @@ static struct platform_driver m66592_driver = {
1671 .remove = __exit_p(m66592_remove), 1672 .remove = __exit_p(m66592_remove),
1672 .driver = { 1673 .driver = {
1673 .name = (char *) udc_name, 1674 .name = (char *) udc_name,
1675 .owner = THIS_MODULE,
1674 }, 1676 },
1675}; 1677};
1676 1678
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index e6d68bda428a..ee1e9a314cd1 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -3109,4 +3109,4 @@ module_exit(udc_exit);
3109 3109
3110MODULE_DESCRIPTION(DRIVER_DESC); 3110MODULE_DESCRIPTION(DRIVER_DESC);
3111MODULE_LICENSE("GPL"); 3111MODULE_LICENSE("GPL");
3112 3112MODULE_ALIAS("platform:omap_udc");
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 096c41cc40d1..c00cd8b9d3d1 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -2380,4 +2380,4 @@ module_exit(udc_exit);
2380MODULE_DESCRIPTION(DRIVER_DESC); 2380MODULE_DESCRIPTION(DRIVER_DESC);
2381MODULE_AUTHOR("Frank Becker, Robert Schwebel, David Brownell"); 2381MODULE_AUTHOR("Frank Becker, Robert Schwebel, David Brownell");
2382MODULE_LICENSE("GPL"); 2382MODULE_LICENSE("GPL");
2383 2383MODULE_ALIAS("platform:pxa2xx-udc");
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index aadc4204d6f9..6b1ef488043b 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -2047,3 +2047,5 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
2047MODULE_DESCRIPTION(DRIVER_DESC); 2047MODULE_DESCRIPTION(DRIVER_DESC);
2048MODULE_VERSION(DRIVER_VERSION); 2048MODULE_VERSION(DRIVER_VERSION);
2049MODULE_LICENSE("GPL"); 2049MODULE_LICENSE("GPL");
2050MODULE_ALIAS("platform:s3c2410-usbgadget");
2051MODULE_ALIAS("platform:s3c2440-usbgadget");
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 40e8240b7851..4e065e556e4b 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -135,8 +135,6 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
135 hcd->state = HC_STATE_QUIESCING; 135 hcd->state = HC_STATE_QUIESCING;
136 } 136 }
137 ehci->command = ehci_readl(ehci, &ehci->regs->command); 137 ehci->command = ehci_readl(ehci, &ehci->regs->command);
138 if (ehci->reclaim)
139 end_unlink_async(ehci);
140 ehci_work(ehci); 138 ehci_work(ehci);
141 139
142 /* Unlike other USB host controller types, EHCI doesn't have 140 /* Unlike other USB host controller types, EHCI doesn't have
@@ -180,6 +178,9 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
180 ehci_halt (ehci); 178 ehci_halt (ehci);
181 hcd->state = HC_STATE_SUSPENDED; 179 hcd->state = HC_STATE_SUSPENDED;
182 180
181 if (ehci->reclaim)
182 end_unlink_async(ehci);
183
183 /* allow remote wakeup */ 184 /* allow remote wakeup */
184 mask = INTR_MASK; 185 mask = INTR_MASK;
185 if (!device_may_wakeup(&hcd->self.root_hub->dev)) 186 if (!device_may_wakeup(&hcd->self.root_hub->dev))
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index d7071c855758..203a3359a648 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1684,14 +1684,18 @@ static int isp116x_resume(struct platform_device *dev)
1684 1684
1685#endif 1685#endif
1686 1686
1687/* work with hotplug and coldplug */
1688MODULE_ALIAS("platform:isp116x-hcd");
1689
1687static struct platform_driver isp116x_driver = { 1690static struct platform_driver isp116x_driver = {
1688 .probe = isp116x_probe, 1691 .probe = isp116x_probe,
1689 .remove = isp116x_remove, 1692 .remove = isp116x_remove,
1690 .suspend = isp116x_suspend, 1693 .suspend = isp116x_suspend,
1691 .resume = isp116x_resume, 1694 .resume = isp116x_resume,
1692 .driver = { 1695 .driver = {
1693 .name = (char *)hcd_name, 1696 .name = (char *)hcd_name,
1694 }, 1697 .owner = THIS_MODULE,
1698 },
1695}; 1699};
1696 1700
1697/*-----------------------------------------------------------------*/ 1701/*-----------------------------------------------------------------*/
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 126fcbdd6408..d72dc07dda01 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -355,7 +355,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
355#define ohci_hcd_at91_drv_resume NULL 355#define ohci_hcd_at91_drv_resume NULL
356#endif 356#endif
357 357
358MODULE_ALIAS("at91_ohci"); 358MODULE_ALIAS("platform:at91_ohci");
359 359
360static struct platform_driver ohci_hcd_at91_driver = { 360static struct platform_driver ohci_hcd_at91_driver = {
361 .probe = ohci_hcd_at91_drv_probe, 361 .probe = ohci_hcd_at91_drv_probe,
@@ -368,4 +368,3 @@ static struct platform_driver ohci_hcd_at91_driver = {
368 .owner = THIS_MODULE, 368 .owner = THIS_MODULE,
369 }, 369 },
370}; 370};
371
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index 663a0600b6e7..f90fe0c7373f 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -345,3 +345,4 @@ static struct platform_driver ohci_hcd_au1xxx_driver = {
345 }, 345 },
346}; 346};
347 347
348MODULE_ALIAS("platform:au1xxx-ohci");
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index a68ce9d3c525..156e93a9d0df 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -211,6 +211,8 @@ static struct platform_driver ohci_hcd_ep93xx_driver = {
211#endif 211#endif
212 .driver = { 212 .driver = {
213 .name = "ep93xx-ohci", 213 .name = "ep93xx-ohci",
214 .owner = THIS_MODULE,
214 }, 215 },
215}; 216};
216 217
218MODULE_ALIAS("platform:ep93xx-ohci");
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index dd4798ee028e..33f1c1c32edf 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -467,7 +467,7 @@ static void unlink_watchdog_func(unsigned long _ohci)
467out: 467out:
468 kfree(seen); 468 kfree(seen);
469 if (ohci->eds_scheduled) 469 if (ohci->eds_scheduled)
470 mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ)); 470 mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
471done: 471done:
472 spin_unlock_irqrestore(&ohci->lock, flags); 472 spin_unlock_irqrestore(&ohci->lock, flags);
473} 473}
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
index 4a043abd85ea..13c12ed22252 100644
--- a/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -251,3 +251,4 @@ static struct platform_driver ohci_hcd_lh7a404_driver = {
251 }, 251 },
252}; 252};
253 253
254MODULE_ALIAS("platform:lh7a404-ohci");
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 74e1f4be10bb..7bfca1ed1b58 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -544,3 +544,4 @@ static struct platform_driver ohci_hcd_omap_driver = {
544 }, 544 },
545}; 545};
546 546
547MODULE_ALIAS("platform:ohci");
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 6c52c66b659f..28b458f20cc3 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -456,9 +456,13 @@ static int usb_hcd_pnx4008_remove(struct platform_device *pdev)
456 return 0; 456 return 0;
457} 457}
458 458
459/* work with hotplug and coldplug */
460MODULE_ALIAS("platform:usb-ohci");
461
459static struct platform_driver usb_hcd_pnx4008_driver = { 462static struct platform_driver usb_hcd_pnx4008_driver = {
460 .driver = { 463 .driver = {
461 .name = "usb-ohci", 464 .name = "usb-ohci",
465 .owner = THIS_MODULE,
462 }, 466 },
463 .probe = usb_hcd_pnx4008_probe, 467 .probe = usb_hcd_pnx4008_probe,
464 .remove = usb_hcd_pnx4008_remove, 468 .remove = usb_hcd_pnx4008_remove,
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c
index 85fdfd2a7ad0..605d59cba28e 100644
--- a/drivers/usb/host/ohci-pnx8550.c
+++ b/drivers/usb/host/ohci-pnx8550.c
@@ -230,11 +230,12 @@ static int ohci_hcd_pnx8550_drv_remove(struct platform_device *pdev)
230 return 0; 230 return 0;
231} 231}
232 232
233MODULE_ALIAS("pnx8550-ohci"); 233MODULE_ALIAS("platform:pnx8550-ohci");
234 234
235static struct platform_driver ohci_hcd_pnx8550_driver = { 235static struct platform_driver ohci_hcd_pnx8550_driver = {
236 .driver = { 236 .driver = {
237 .name = "pnx8550-ohci", 237 .name = "pnx8550-ohci",
238 .owner = THIS_MODULE,
238 }, 239 },
239 .probe = ohci_hcd_pnx8550_drv_probe, 240 .probe = ohci_hcd_pnx8550_drv_probe,
240 .remove = ohci_hcd_pnx8550_drv_remove, 241 .remove = ohci_hcd_pnx8550_drv_remove,
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
index f95be1896b0d..523c30125577 100644
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ b/drivers/usb/host/ohci-ppc-soc.c
@@ -213,3 +213,4 @@ static struct platform_driver ohci_hcd_ppc_soc_driver = {
213 }, 213 },
214}; 214};
215 215
216MODULE_ALIAS("platform:ppc-soc-ohci");
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index ff9a79843471..8ad9b3b604b5 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -364,6 +364,8 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
364} 364}
365#endif 365#endif
366 366
367/* work with hotplug and coldplug */
368MODULE_ALIAS("platform:pxa27x-ohci");
367 369
368static struct platform_driver ohci_hcd_pxa27x_driver = { 370static struct platform_driver ohci_hcd_pxa27x_driver = {
369 .probe = ohci_hcd_pxa27x_drv_probe, 371 .probe = ohci_hcd_pxa27x_drv_probe,
@@ -375,6 +377,7 @@ static struct platform_driver ohci_hcd_pxa27x_driver = {
375#endif 377#endif
376 .driver = { 378 .driver = {
377 .name = "pxa27x-ohci", 379 .name = "pxa27x-ohci",
380 .owner = THIS_MODULE,
378 }, 381 },
379}; 382};
380 383
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 51817322232b..9c9f3b59186f 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -169,7 +169,7 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
169 if (quirk_zfmicro(ohci) 169 if (quirk_zfmicro(ohci)
170 && (ed->type == PIPE_INTERRUPT) 170 && (ed->type == PIPE_INTERRUPT)
171 && !(ohci->eds_scheduled++)) 171 && !(ohci->eds_scheduled++))
172 mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ)); 172 mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
173 wmb (); 173 wmb ();
174 174
175 /* we care about rm_list when setting CLE/BLE in case the HC was at 175 /* we care about rm_list when setting CLE/BLE in case the HC was at
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 44b79e8a6e25..ead4772f0f27 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -501,3 +501,4 @@ static struct platform_driver ohci_hcd_s3c2410_driver = {
501 }, 501 },
502}; 502};
503 503
504MODULE_ALIAS("platform:s3c2410-ohci");
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c
index 5309ac039e15..e7ee607278fe 100644
--- a/drivers/usb/host/ohci-sh.c
+++ b/drivers/usb/host/ohci-sh.c
@@ -141,3 +141,4 @@ static struct platform_driver ohci_hcd_sh_driver = {
141 }, 141 },
142}; 142};
143 143
144MODULE_ALIAS("platform:sh_ohci");
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index a97070142869..4ea92762fb28 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -262,3 +262,4 @@ static struct platform_driver ohci_hcd_sm501_driver = {
262 .name = "sm501-usb", 262 .name = "sm501-usb",
263 }, 263 },
264}; 264};
265MODULE_ALIAS("platform:sm501-usb");
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 0ce2fc5e396b..9f80e5285575 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -44,6 +44,7 @@
44MODULE_DESCRIPTION("R8A66597 USB Host Controller Driver"); 44MODULE_DESCRIPTION("R8A66597 USB Host Controller Driver");
45MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
46MODULE_AUTHOR("Yoshihiro Shimoda"); 46MODULE_AUTHOR("Yoshihiro Shimoda");
47MODULE_ALIAS("platform:r8a66597_hcd");
47 48
48#define DRIVER_VERSION "29 May 2007" 49#define DRIVER_VERSION "29 May 2007"
49 50
@@ -2219,6 +2220,7 @@ static struct platform_driver r8a66597_driver = {
2219 .resume = r8a66597_resume, 2220 .resume = r8a66597_resume,
2220 .driver = { 2221 .driver = {
2221 .name = (char *) hcd_name, 2222 .name = (char *) hcd_name,
2223 .owner = THIS_MODULE,
2222 }, 2224 },
2223}; 2225};
2224 2226
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 59be276ccd9d..629bca0ebe8f 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -58,6 +58,7 @@
58 58
59MODULE_DESCRIPTION("SL811HS USB Host Controller Driver"); 59MODULE_DESCRIPTION("SL811HS USB Host Controller Driver");
60MODULE_LICENSE("GPL"); 60MODULE_LICENSE("GPL");
61MODULE_ALIAS("platform:sl811-hcd");
61 62
62#define DRIVER_VERSION "19 May 2005" 63#define DRIVER_VERSION "19 May 2005"
63 64
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 3033d6945202..8e117a795e93 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -3316,3 +3316,4 @@ static void __exit u132_hcd_exit(void)
3316 3316
3317module_exit(u132_hcd_exit); 3317module_exit(u132_hcd_exit);
3318MODULE_LICENSE("GPL"); 3318MODULE_LICENSE("GPL");
3319MODULE_ALIAS("platform:u132_hcd");
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index da922dfc0dcc..b6b5b2affad1 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -378,6 +378,7 @@ alloc_sglist (int nents, int max, int vary)
378 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL); 378 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
379 if (!sg) 379 if (!sg)
380 return NULL; 380 return NULL;
381 sg_init_table(sg, nents);
381 382
382 for (i = 0; i < nents; i++) { 383 for (i = 0; i < nents; i++) {
383 char *buf; 384 char *buf;
@@ -390,7 +391,7 @@ alloc_sglist (int nents, int max, int vary)
390 } 391 }
391 392
392 /* kmalloc pages are always physically contiguous! */ 393 /* kmalloc pages are always physically contiguous! */
393 sg_init_one(&sg[i], buf, size); 394 sg_set_buf(&sg[i], buf, size);
394 395
395 switch (pattern) { 396 switch (pattern) {
396 case 0: 397 case 0:
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index f3ca66017a03..324bb61d68ff 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -75,6 +75,7 @@ static struct usb_device_id id_table [] = {
75 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ 75 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
76 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 76 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
77 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 77 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
78 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
78 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 79 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
79 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 80 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
80 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 81 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 8a0d17401529..74ce8bca3e66 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -637,6 +637,7 @@ static struct usb_serial_driver keyspan_pre_device = {
637 .description = "Keyspan - (without firmware)", 637 .description = "Keyspan - (without firmware)",
638 .id_table = keyspan_pre_ids, 638 .id_table = keyspan_pre_ids,
639 .num_interrupt_in = NUM_DONT_CARE, 639 .num_interrupt_in = NUM_DONT_CARE,
640 .num_interrupt_out = NUM_DONT_CARE,
640 .num_bulk_in = NUM_DONT_CARE, 641 .num_bulk_in = NUM_DONT_CARE,
641 .num_bulk_out = NUM_DONT_CARE, 642 .num_bulk_out = NUM_DONT_CARE,
642 .num_ports = 1, 643 .num_ports = 1,
@@ -651,6 +652,7 @@ static struct usb_serial_driver keyspan_1port_device = {
651 .description = "Keyspan 1 port adapter", 652 .description = "Keyspan 1 port adapter",
652 .id_table = keyspan_1port_ids, 653 .id_table = keyspan_1port_ids,
653 .num_interrupt_in = NUM_DONT_CARE, 654 .num_interrupt_in = NUM_DONT_CARE,
655 .num_interrupt_out = NUM_DONT_CARE,
654 .num_bulk_in = NUM_DONT_CARE, 656 .num_bulk_in = NUM_DONT_CARE,
655 .num_bulk_out = NUM_DONT_CARE, 657 .num_bulk_out = NUM_DONT_CARE,
656 .num_ports = 1, 658 .num_ports = 1,
@@ -678,6 +680,7 @@ static struct usb_serial_driver keyspan_2port_device = {
678 .description = "Keyspan 2 port adapter", 680 .description = "Keyspan 2 port adapter",
679 .id_table = keyspan_2port_ids, 681 .id_table = keyspan_2port_ids,
680 .num_interrupt_in = NUM_DONT_CARE, 682 .num_interrupt_in = NUM_DONT_CARE,
683 .num_interrupt_out = NUM_DONT_CARE,
681 .num_bulk_in = NUM_DONT_CARE, 684 .num_bulk_in = NUM_DONT_CARE,
682 .num_bulk_out = NUM_DONT_CARE, 685 .num_bulk_out = NUM_DONT_CARE,
683 .num_ports = 2, 686 .num_ports = 2,
@@ -705,6 +708,7 @@ static struct usb_serial_driver keyspan_4port_device = {
705 .description = "Keyspan 4 port adapter", 708 .description = "Keyspan 4 port adapter",
706 .id_table = keyspan_4port_ids, 709 .id_table = keyspan_4port_ids,
707 .num_interrupt_in = NUM_DONT_CARE, 710 .num_interrupt_in = NUM_DONT_CARE,
711 .num_interrupt_out = NUM_DONT_CARE,
708 .num_bulk_in = NUM_DONT_CARE, 712 .num_bulk_in = NUM_DONT_CARE,
709 .num_bulk_out = NUM_DONT_CARE, 713 .num_bulk_out = NUM_DONT_CARE,
710 .num_ports = 4, 714 .num_ports = 4,
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index b517f93352ec..e3d241f67afc 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -265,8 +265,8 @@ static struct usb_serial_driver ti_1port_device = {
265 .description = "TI USB 3410 1 port adapter", 265 .description = "TI USB 3410 1 port adapter",
266 .usb_driver = &ti_usb_driver, 266 .usb_driver = &ti_usb_driver,
267 .id_table = ti_id_table_3410, 267 .id_table = ti_id_table_3410,
268 .num_interrupt_in = 1, 268 .num_interrupt_in = NUM_DONT_CARE,
269 .num_bulk_in = 1, 269 .num_bulk_in = NUM_DONT_CARE,
270 .num_bulk_out = 1, 270 .num_bulk_out = 1,
271 .num_ports = 1, 271 .num_ports = 1,
272 .attach = ti_startup, 272 .attach = ti_startup,
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 22b3f78a388c..c2b01f7c3197 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -191,7 +191,7 @@ static struct usb_serial_driver handspring_device = {
191 .id_table = id_table, 191 .id_table = id_table,
192 .num_interrupt_in = NUM_DONT_CARE, 192 .num_interrupt_in = NUM_DONT_CARE,
193 .num_bulk_in = 2, 193 .num_bulk_in = 2,
194 .num_bulk_out = 2, 194 .num_bulk_out = NUM_DONT_CARE,
195 .num_ports = 2, 195 .num_ports = 2,
196 .open = visor_open, 196 .open = visor_open,
197 .close = visor_close, 197 .close = visor_close,
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index 986a550c0439..eefba3d0e4b9 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -384,7 +384,7 @@ static int bfin_bf54x_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
384 * Other flags can be set, and are documented in 384 * Other flags can be set, and are documented in
385 * include/linux/mm.h 385 * include/linux/mm.h
386 */ 386 */
387 vma->vm_flags |= VM_MAYSHARE; 387 vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
388 388
389 return 0; 389 return 0;
390} 390}
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index a2bb2de9e020..135d6dd7e672 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -91,6 +91,7 @@ struct bfin_t350mcqbfb_info {
91 int lq043_open_cnt; 91 int lq043_open_cnt;
92 int irq; 92 int irq;
93 spinlock_t lock; /* lock */ 93 spinlock_t lock; /* lock */
94 u32 pseudo_pal[16];
94}; 95};
95 96
96static int nocursor; 97static int nocursor;
@@ -182,13 +183,13 @@ static void bfin_t350mcqb_config_dma(struct bfin_t350mcqbfb_info *fbi)
182 183
183} 184}
184 185
185static int bfin_t350mcqb_request_ports(int action) 186static u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
186{
187 u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
188 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, 187 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2,
189 P_PPI0_D3, P_PPI0_D4, P_PPI0_D5, 188 P_PPI0_D3, P_PPI0_D4, P_PPI0_D5,
190 P_PPI0_D6, P_PPI0_D7, 0}; 189 P_PPI0_D6, P_PPI0_D7, 0};
191 190
191static int bfin_t350mcqb_request_ports(int action)
192{
192 if (action) { 193 if (action) {
193 if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) { 194 if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) {
194 printk(KERN_ERR "Requesting Peripherals faild\n"); 195 printk(KERN_ERR "Requesting Peripherals faild\n");
@@ -301,7 +302,7 @@ static int bfin_t350mcqb_fb_mmap(struct fb_info *info, struct vm_area_struct *vm
301 * Other flags can be set, and are documented in 302 * Other flags can be set, and are documented in
302 * include/linux/mm.h 303 * include/linux/mm.h
303 */ 304 */
304 vma->vm_flags |= VM_MAYSHARE; 305 vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
305 306
306 return 0; 307 return 0;
307} 308}
@@ -520,16 +521,7 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
520 521
521 fbinfo->fbops = &bfin_t350mcqb_fb_ops; 522 fbinfo->fbops = &bfin_t350mcqb_fb_ops;
522 523
523 fbinfo->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); 524 fbinfo->pseudo_palette = &info->pseudo_pal;
524 if (!fbinfo->pseudo_palette) {
525 printk(KERN_ERR DRIVER_NAME
526 "Fail to allocate pseudo_palette\n");
527
528 ret = -ENOMEM;
529 goto out4;
530 }
531
532 memset(fbinfo->pseudo_palette, 0, sizeof(u32) * 16);
533 525
534 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) 526 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0)
535 < 0) { 527 < 0) {
@@ -537,7 +529,7 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
537 "Fail to allocate colormap (%d entries)\n", 529 "Fail to allocate colormap (%d entries)\n",
538 BFIN_LCD_NBR_PALETTE_ENTRIES); 530 BFIN_LCD_NBR_PALETTE_ENTRIES);
539 ret = -EFAULT; 531 ret = -EFAULT;
540 goto out5; 532 goto out4;
541 } 533 }
542 534
543 if (bfin_t350mcqb_request_ports(1)) { 535 if (bfin_t350mcqb_request_ports(1)) {
@@ -552,11 +544,11 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
552 goto out7; 544 goto out7;
553 } 545 }
554 546
555 if (request_irq(info->irq, (void *)bfin_t350mcqb_irq_error, IRQF_DISABLED, 547 ret = request_irq(info->irq, bfin_t350mcqb_irq_error, IRQF_DISABLED,
556 "PPI ERROR", info) < 0) { 548 "PPI ERROR", info);
549 if (ret < 0) {
557 printk(KERN_ERR DRIVER_NAME 550 printk(KERN_ERR DRIVER_NAME
558 ": unable to request PPI ERROR IRQ\n"); 551 ": unable to request PPI ERROR IRQ\n");
559 ret = -EFAULT;
560 goto out7; 552 goto out7;
561 } 553 }
562 554
@@ -584,8 +576,6 @@ out7:
584 bfin_t350mcqb_request_ports(0); 576 bfin_t350mcqb_request_ports(0);
585out6: 577out6:
586 fb_dealloc_cmap(&fbinfo->cmap); 578 fb_dealloc_cmap(&fbinfo->cmap);
587out5:
588 kfree(fbinfo->pseudo_palette);
589out4: 579out4:
590 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer, 580 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
591 info->dma_handle); 581 info->dma_handle);
@@ -605,6 +595,8 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
605 struct fb_info *fbinfo = platform_get_drvdata(pdev); 595 struct fb_info *fbinfo = platform_get_drvdata(pdev);
606 struct bfin_t350mcqbfb_info *info = fbinfo->par; 596 struct bfin_t350mcqbfb_info *info = fbinfo->par;
607 597
598 unregister_framebuffer(fbinfo);
599
608 free_dma(CH_PPI); 600 free_dma(CH_PPI);
609 free_irq(info->irq, info); 601 free_irq(info->irq, info);
610 602
@@ -612,7 +604,6 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
612 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer, 604 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
613 info->dma_handle); 605 info->dma_handle);
614 606
615 kfree(fbinfo->pseudo_palette);
616 fb_dealloc_cmap(&fbinfo->cmap); 607 fb_dealloc_cmap(&fbinfo->cmap);
617 608
618#ifndef NO_BL_SUPPORT 609#ifndef NO_BL_SUPPORT
@@ -620,10 +611,11 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
620 backlight_device_unregister(bl_dev); 611 backlight_device_unregister(bl_dev);
621#endif 612#endif
622 613
623 unregister_framebuffer(fbinfo);
624
625 bfin_t350mcqb_request_ports(0); 614 bfin_t350mcqb_request_ports(0);
626 615
616 platform_set_drvdata(pdev, NULL);
617 framebuffer_release(fbinfo);
618
627 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n"); 619 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n");
628 620
629 return 0; 621 return 0;
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 59a8f73dec73..c0df924766a7 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -37,7 +37,7 @@ struct virtio_pci_device
37 struct pci_dev *pci_dev; 37 struct pci_dev *pci_dev;
38 38
39 /* the IO mapping for the PCI config space */ 39 /* the IO mapping for the PCI config space */
40 void *ioaddr; 40 void __iomem *ioaddr;
41 41
42 /* a list of queues so we can dispatch IRQs */ 42 /* a list of queues so we can dispatch IRQs */
43 spinlock_t lock; 43 spinlock_t lock;
@@ -111,7 +111,7 @@ static void vp_get(struct virtio_device *vdev, unsigned offset,
111 void *buf, unsigned len) 111 void *buf, unsigned len)
112{ 112{
113 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 113 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
114 void *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset; 114 void __iomem *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset;
115 u8 *ptr = buf; 115 u8 *ptr = buf;
116 int i; 116 int i;
117 117
@@ -125,7 +125,7 @@ static void vp_set(struct virtio_device *vdev, unsigned offset,
125 const void *buf, unsigned len) 125 const void *buf, unsigned len)
126{ 126{
127 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 127 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
128 void *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset; 128 void __iomem *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset;
129 const u8 *ptr = buf; 129 const u8 *ptr = buf;
130 int i; 130 int i;
131 131
@@ -388,6 +388,7 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev)
388{ 388{
389 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 389 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
390 390
391 unregister_virtio_device(&vp_dev->vdev);
391 free_irq(pci_dev->irq, vp_dev); 392 free_irq(pci_dev->irq, vp_dev);
392 pci_set_drvdata(pci_dev, NULL); 393 pci_set_drvdata(pci_dev, NULL);
393 pci_iounmap(pci_dev, vp_dev->ioaddr); 394 pci_iounmap(pci_dev, vp_dev->ioaddr);
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index aa714028641e..c2fa5c630813 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -214,10 +214,7 @@ static void vring_disable_cb(struct virtqueue *_vq)
214{ 214{
215 struct vring_virtqueue *vq = to_vvq(_vq); 215 struct vring_virtqueue *vq = to_vvq(_vq);
216 216
217 START_USE(vq);
218 BUG_ON(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT);
219 vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; 217 vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
220 END_USE(vq);
221} 218}
222 219
223static bool vring_enable_cb(struct virtqueue *_vq) 220static bool vring_enable_cb(struct virtqueue *_vq)
diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c
index fb5ed6478f78..ae0fca5e8749 100644
--- a/drivers/watchdog/at32ap700x_wdt.c
+++ b/drivers/watchdog/at32ap700x_wdt.c
@@ -418,6 +418,9 @@ static int at32_wdt_resume(struct platform_device *pdev)
418#define at32_wdt_resume NULL 418#define at32_wdt_resume NULL
419#endif 419#endif
420 420
421/* work with hotplug and coldplug */
422MODULE_ALIAS("platform:at32_wdt");
423
421static struct platform_driver at32_wdt_driver = { 424static struct platform_driver at32_wdt_driver = {
422 .remove = __exit_p(at32_wdt_remove), 425 .remove = __exit_p(at32_wdt_remove),
423 .suspend = at32_wdt_suspend, 426 .suspend = at32_wdt_suspend,
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
index a684b1e87372..9ff9a9565320 100644
--- a/drivers/watchdog/at91rm9200_wdt.c
+++ b/drivers/watchdog/at91rm9200_wdt.c
@@ -286,3 +286,4 @@ MODULE_AUTHOR("Andrew Victor");
286MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200"); 286MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200");
287MODULE_LICENSE("GPL"); 287MODULE_LICENSE("GPL");
288MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 288MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
289MODULE_ALIAS("platform:at91_wdt");
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index a61cbd48dc07..1782c79eff06 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -248,6 +248,7 @@ static int davinci_wdt_remove(struct platform_device *pdev)
248static struct platform_driver platform_wdt_driver = { 248static struct platform_driver platform_wdt_driver = {
249 .driver = { 249 .driver = {
250 .name = "watchdog", 250 .name = "watchdog",
251 .owner = THIS_MODULE,
251 }, 252 },
252 .probe = davinci_wdt_probe, 253 .probe = davinci_wdt_probe,
253 .remove = davinci_wdt_remove, 254 .remove = davinci_wdt_remove,
@@ -277,3 +278,4 @@ MODULE_PARM_DESC(heartbeat,
277 278
278MODULE_LICENSE("GPL"); 279MODULE_LICENSE("GPL");
279MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 280MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
281MODULE_ALIAS("platform:watchdog");
diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c
index 1efcad3b6fca..445b7e812112 100644
--- a/drivers/watchdog/it8712f_wdt.c
+++ b/drivers/watchdog/it8712f_wdt.c
@@ -111,15 +111,6 @@ superio_inw(int reg)
111 return val; 111 return val;
112} 112}
113 113
114static void
115superio_outw(int val, int reg)
116{
117 outb(reg++, REG);
118 outb((val >> 8) & 0xff, VAL);
119 outb(reg, REG);
120 outb(val & 0xff, VAL);
121}
122
123static inline void 114static inline void
124superio_select(int ldn) 115superio_select(int ldn)
125{ 116{
@@ -170,9 +161,8 @@ it8712f_wdt_update_margin(void)
170 superio_outb(config, WDT_CONFIG); 161 superio_outb(config, WDT_CONFIG);
171 162
172 if (revision >= 0x08) 163 if (revision >= 0x08)
173 superio_outw(units, WDT_TIMEOUT); 164 superio_outb(units >> 8, WDT_TIMEOUT + 1);
174 else 165 superio_outb(units, WDT_TIMEOUT);
175 superio_outb(units, WDT_TIMEOUT);
176} 166}
177 167
178static int 168static int
@@ -210,6 +200,8 @@ it8712f_wdt_disable(void)
210 200
211 superio_outb(0, WDT_CONFIG); 201 superio_outb(0, WDT_CONFIG);
212 superio_outb(0, WDT_CONTROL); 202 superio_outb(0, WDT_CONTROL);
203 if (revision >= 0x08)
204 superio_outb(0, WDT_TIMEOUT + 1);
213 superio_outb(0, WDT_TIMEOUT); 205 superio_outb(0, WDT_TIMEOUT);
214 206
215 superio_exit(); 207 superio_exit();
diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c
index e3a29c302309..df5a6b811ccd 100644
--- a/drivers/watchdog/ks8695_wdt.c
+++ b/drivers/watchdog/ks8695_wdt.c
@@ -306,3 +306,4 @@ MODULE_AUTHOR("Andrew Victor");
306MODULE_DESCRIPTION("Watchdog driver for KS8695"); 306MODULE_DESCRIPTION("Watchdog driver for KS8695");
307MODULE_LICENSE("GPL"); 307MODULE_LICENSE("GPL");
308MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 308MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
309MODULE_ALIAS("platform:ks8695_wdt");
diff --git a/drivers/watchdog/mpc83xx_wdt.c b/drivers/watchdog/mpc83xx_wdt.c
index 6369f569517f..b16c5cd972eb 100644
--- a/drivers/watchdog/mpc83xx_wdt.c
+++ b/drivers/watchdog/mpc83xx_wdt.c
@@ -206,6 +206,7 @@ static struct platform_driver mpc83xx_wdt_driver = {
206 .remove = __devexit_p(mpc83xx_wdt_remove), 206 .remove = __devexit_p(mpc83xx_wdt_remove),
207 .driver = { 207 .driver = {
208 .name = "mpc83xx_wdt", 208 .name = "mpc83xx_wdt",
209 .owner = THIS_MODULE,
209 }, 210 },
210}; 211};
211 212
@@ -226,3 +227,4 @@ MODULE_AUTHOR("Dave Updegraff, Kumar Gala");
226MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor"); 227MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor");
227MODULE_LICENSE("GPL"); 228MODULE_LICENSE("GPL");
228MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 229MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
230MODULE_ALIAS("platform:mpc83xx_wdt");
diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c
index 0d2b27735419..009573b81496 100644
--- a/drivers/watchdog/mpcore_wdt.c
+++ b/drivers/watchdog/mpcore_wdt.c
@@ -392,6 +392,9 @@ static int __devexit mpcore_wdt_remove(struct platform_device *dev)
392 return 0; 392 return 0;
393} 393}
394 394
395/* work with hotplug and coldplug */
396MODULE_ALIAS("platform:mpcore_wdt");
397
395static struct platform_driver mpcore_wdt_driver = { 398static struct platform_driver mpcore_wdt_driver = {
396 .probe = mpcore_wdt_probe, 399 .probe = mpcore_wdt_probe,
397 .remove = __devexit_p(mpcore_wdt_remove), 400 .remove = __devexit_p(mpcore_wdt_remove),
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index 10b89f2703bd..a8e67383784e 100644
--- a/drivers/watchdog/mtx-1_wdt.c
+++ b/drivers/watchdog/mtx-1_wdt.c
@@ -243,6 +243,7 @@ static struct platform_driver mtx1_wdt = {
243 .probe = mtx1_wdt_probe, 243 .probe = mtx1_wdt_probe,
244 .remove = mtx1_wdt_remove, 244 .remove = mtx1_wdt_remove,
245 .driver.name = "mtx1-wdt", 245 .driver.name = "mtx1-wdt",
246 .driver.owner = THIS_MODULE,
246}; 247};
247 248
248static int __init mtx1_wdt_init(void) 249static int __init mtx1_wdt_init(void)
@@ -262,3 +263,4 @@ MODULE_AUTHOR("Michael Stickel, Florian Fainelli");
262MODULE_DESCRIPTION("Driver for the MTX-1 watchdog"); 263MODULE_DESCRIPTION("Driver for the MTX-1 watchdog");
263MODULE_LICENSE("GPL"); 264MODULE_LICENSE("GPL");
264MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 265MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
266MODULE_ALIAS("platform:mtx1-wdt");
diff --git a/drivers/watchdog/mv64x60_wdt.c b/drivers/watchdog/mv64x60_wdt.c
index 0365c317f7e1..b59ca3273967 100644
--- a/drivers/watchdog/mv64x60_wdt.c
+++ b/drivers/watchdog/mv64x60_wdt.c
@@ -324,3 +324,4 @@ MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");
324MODULE_DESCRIPTION("MV64x60 watchdog driver"); 324MODULE_DESCRIPTION("MV64x60 watchdog driver");
325MODULE_LICENSE("GPL"); 325MODULE_LICENSE("GPL");
326MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 326MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
327MODULE_ALIAS("platform:" MV64x60_WDT_NAME);
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 635ca454f56b..74bc39aa1ce8 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -387,3 +387,4 @@ module_exit(omap_wdt_exit);
387MODULE_AUTHOR("George G. Davis"); 387MODULE_AUTHOR("George G. Davis");
388MODULE_LICENSE("GPL"); 388MODULE_LICENSE("GPL");
389MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 389MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
390MODULE_ALIAS("platform:omap_wdt");
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index b04aa096a10a..6b8483d3c783 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -321,6 +321,7 @@ static int pnx4008_wdt_remove(struct platform_device *pdev)
321static struct platform_driver platform_wdt_driver = { 321static struct platform_driver platform_wdt_driver = {
322 .driver = { 322 .driver = {
323 .name = "watchdog", 323 .name = "watchdog",
324 .owner = THIS_MODULE,
324 }, 325 },
325 .probe = pnx4008_wdt_probe, 326 .probe = pnx4008_wdt_probe,
326 .remove = pnx4008_wdt_remove, 327 .remove = pnx4008_wdt_remove,
@@ -354,3 +355,4 @@ MODULE_PARM_DESC(nowayout,
354 355
355MODULE_LICENSE("GPL"); 356MODULE_LICENSE("GPL");
356MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 357MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
358MODULE_ALIAS("platform:watchdog");
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 7645e8812156..98532c0e0689 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -561,3 +561,4 @@ MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>, "
561MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver"); 561MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver");
562MODULE_LICENSE("GPL"); 562MODULE_LICENSE("GPL");
563MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 563MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
564MODULE_ALIAS("platform:s3c2410-wdt");
diff --git a/drivers/watchdog/txx9wdt.c b/drivers/watchdog/txx9wdt.c
index 328b3c7211ef..57cefef27ce3 100644
--- a/drivers/watchdog/txx9wdt.c
+++ b/drivers/watchdog/txx9wdt.c
@@ -274,3 +274,4 @@ module_exit(watchdog_exit);
274MODULE_DESCRIPTION("TXx9 Watchdog Driver"); 274MODULE_DESCRIPTION("TXx9 Watchdog Driver");
275MODULE_LICENSE("GPL"); 275MODULE_LICENSE("GPL");
276MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 276MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
277MODULE_ALIAS("platform:txx9wdt");
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index ea94dbabf9a9..d85dc6d41c2a 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -381,11 +381,15 @@ EXPORT_SYMBOL_GPL(gnttab_cancel_free_callback);
381static int grow_gnttab_list(unsigned int more_frames) 381static int grow_gnttab_list(unsigned int more_frames)
382{ 382{
383 unsigned int new_nr_grant_frames, extra_entries, i; 383 unsigned int new_nr_grant_frames, extra_entries, i;
384 unsigned int nr_glist_frames, new_nr_glist_frames;
384 385
385 new_nr_grant_frames = nr_grant_frames + more_frames; 386 new_nr_grant_frames = nr_grant_frames + more_frames;
386 extra_entries = more_frames * GREFS_PER_GRANT_FRAME; 387 extra_entries = more_frames * GREFS_PER_GRANT_FRAME;
387 388
388 for (i = nr_grant_frames; i < new_nr_grant_frames; i++) { 389 nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
390 new_nr_glist_frames =
391 (new_nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
392 for (i = nr_glist_frames; i < new_nr_glist_frames; i++) {
389 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_ATOMIC); 393 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_ATOMIC);
390 if (!gnttab_list[i]) 394 if (!gnttab_list[i])
391 goto grow_nomem; 395 goto grow_nomem;
@@ -407,7 +411,7 @@ static int grow_gnttab_list(unsigned int more_frames)
407 return 0; 411 return 0;
408 412
409grow_nomem: 413grow_nomem:
410 for ( ; i >= nr_grant_frames; i--) 414 for ( ; i >= nr_glist_frames; i--)
411 free_page((unsigned long) gnttab_list[i]); 415 free_page((unsigned long) gnttab_list[i]);
412 return -ENOMEM; 416 return -ENOMEM;
413} 417}
@@ -530,7 +534,7 @@ static int gnttab_expand(unsigned int req_entries)
530static int __devinit gnttab_init(void) 534static int __devinit gnttab_init(void)
531{ 535{
532 int i; 536 int i;
533 unsigned int max_nr_glist_frames; 537 unsigned int max_nr_glist_frames, nr_glist_frames;
534 unsigned int nr_init_grefs; 538 unsigned int nr_init_grefs;
535 539
536 if (!is_running_on_xen()) 540 if (!is_running_on_xen())
@@ -543,15 +547,15 @@ static int __devinit gnttab_init(void)
543 * grant reference free list on the current hypervisor. 547 * grant reference free list on the current hypervisor.
544 */ 548 */
545 max_nr_glist_frames = (boot_max_nr_grant_frames * 549 max_nr_glist_frames = (boot_max_nr_grant_frames *
546 GREFS_PER_GRANT_FRAME / 550 GREFS_PER_GRANT_FRAME / RPP);
547 (PAGE_SIZE / sizeof(grant_ref_t)));
548 551
549 gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *), 552 gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *),
550 GFP_KERNEL); 553 GFP_KERNEL);
551 if (gnttab_list == NULL) 554 if (gnttab_list == NULL)
552 return -ENOMEM; 555 return -ENOMEM;
553 556
554 for (i = 0; i < nr_grant_frames; i++) { 557 nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
558 for (i = 0; i < nr_glist_frames; i++) {
555 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL); 559 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL);
556 if (gnttab_list[i] == NULL) 560 if (gnttab_list[i] == NULL)
557 goto ini_nomem; 561 goto ini_nomem;