aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/blacklist.c401
-rw-r--r--drivers/acpi/bus.c8
-rw-r--r--drivers/acpi/ec.c3
-rw-r--r--drivers/acpi/osl.c104
-rw-r--r--drivers/acpi/scan.c10
-rw-r--r--drivers/acpi/sleep/main.c40
-rw-r--r--drivers/acpi/toshiba_acpi.c56
-rw-r--r--drivers/acpi/utilities/utglobal.c2
-rw-r--r--drivers/acpi/utils.c16
-rw-r--r--drivers/ata/Kconfig44
-rw-r--r--drivers/ata/ata_piix.c22
-rw-r--r--drivers/ata/libata-core.c74
-rw-r--r--drivers/ata/pata_hpt366.c16
-rw-r--r--drivers/ata/pata_ninja32.c9
-rw-r--r--drivers/ata/pata_rb532_cf.c15
-rw-r--r--drivers/ata/pata_sis.c1
-rw-r--r--drivers/atm/horizon.c2
-rw-r--r--drivers/block/cciss.c5
-rw-r--r--drivers/block/pktcdvd.c6
-rw-r--r--drivers/block/xsysace.c23
-rw-r--r--drivers/cdrom/cdrom.c16
-rw-r--r--drivers/char/agp/uninorth-agp.c2
-rw-r--r--drivers/char/cp437.uni12
-rw-r--r--drivers/char/hpet.c2
-rw-r--r--drivers/char/istallion.c4
-rw-r--r--drivers/char/serial167.c2
-rw-r--r--drivers/char/tty_io.c15
-rw-r--r--drivers/char/vt.c2
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.c3
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.h3
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.c3
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.h3
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c12
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.h3
-rw-r--r--drivers/clocksource/acpi_pm.c10
-rw-r--r--drivers/crypto/talitos.c4
-rw-r--r--drivers/dma/dmaengine.c3
-rw-r--r--drivers/dma/ioat_dma.c5
-rw-r--r--drivers/dma/iop-adma.c16
-rw-r--r--drivers/dma/mv_xor.c15
-rw-r--r--drivers/edac/edac_device.c12
-rw-r--r--drivers/edac/i82875p_edac.c14
-rw-r--r--drivers/firewire/fw-ohci.c11
-rw-r--r--drivers/firewire/fw-sbp2.c5
-rw-r--r--drivers/firewire/fw-transaction.c3
-rw-r--r--drivers/firewire/fw-transaction.h2
-rw-r--r--drivers/gpu/drm/drm_drv.c2
-rw-r--r--drivers/gpu/drm/drm_irq.c4
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c22
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h28
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c722
-rw-r--r--drivers/gpu/drm/i915/i915_gem_proc.c5
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c7
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c293
-rw-r--r--drivers/gpu/drm/i915/i915_opregion.c18
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c6
-rw-r--r--drivers/gpu/drm/mga/mga_dma.c8
-rw-r--r--drivers/gpu/drm/mga/mga_irq.c5
-rw-r--r--drivers/gpu/drm/r128/r128_drv.c6
-rw-r--r--drivers/gpu/drm/r128/r128_drv.h1
-rw-r--r--drivers/gpu/drm/r128/r128_irq.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq.c13
-rw-r--r--drivers/gpu/drm/via/via_irq.c1
-rw-r--r--drivers/gpu/drm/via/via_map.c11
-rw-r--r--drivers/hid/hid-apple.c6
-rw-r--r--drivers/hid/hid-core.c14
-rw-r--r--drivers/hid/hid-ids.h1
-rw-r--r--drivers/hid/hid-pl.c2
-rw-r--r--drivers/hid/usbhid/hid-core.c18
-rw-r--r--drivers/hid/usbhid/usbhid.h1
-rw-r--r--drivers/hwmon/applesmc.c1
-rw-r--r--drivers/i2c/busses/i2c-cpm.c1
-rw-r--r--drivers/i2c/busses/i2c-highlander.c4
-rw-r--r--drivers/i2c/busses/i2c-parport.c4
-rw-r--r--drivers/i2c/busses/i2c-pmcmsp.c2
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c18
-rw-r--r--drivers/i2c/chips/isp1301_omap.c65
-rw-r--r--drivers/i2c/i2c-core.c2
-rw-r--r--drivers/ide/Kconfig14
-rw-r--r--drivers/ide/alim15x3.c2
-rw-r--r--drivers/ide/amd74xx.c11
-rw-r--r--drivers/ide/cs5530.c3
-rw-r--r--drivers/ide/icside.c4
-rw-r--r--drivers/ide/ide-io.c24
-rw-r--r--drivers/ide/ide-iops.c9
-rw-r--r--drivers/ide/ide-probe.c3
-rw-r--r--drivers/ide/pmac.c30
-rw-r--r--drivers/ide/sc1200.c3
-rw-r--r--drivers/ide/sgiioc4.c6
-rw-r--r--drivers/ieee1394/highlevel.c25
-rw-r--r--drivers/ieee1394/hosts.h4
-rw-r--r--drivers/ieee1394/nodemgr.c8
-rw-r--r--drivers/ieee1394/sbp2.c14
-rw-r--r--drivers/infiniband/hw/ehca/ehca_classes.h4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c3
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c26
-rw-r--r--drivers/infiniband/hw/ehca/ehca_reqs.c51
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c5
-rw-r--r--drivers/input/ff-memless.c5
-rw-r--r--drivers/input/keyboard/atkbd.c27
-rw-r--r--drivers/input/misc/cm109.c37
-rw-r--r--drivers/input/mouse/hgpk.c2
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h14
-rw-r--r--drivers/input/tablet/wacom.h13
-rw-r--r--drivers/input/tablet/wacom_sys.c228
-rw-r--r--drivers/input/tablet/wacom_wac.c160
-rw-r--r--drivers/input/tablet/wacom_wac.h4
-rw-r--r--drivers/input/touchscreen/elo.c2
-rw-r--r--drivers/input/xen-kbdfront.c6
-rw-r--r--drivers/isdn/hardware/avm/b1isa.c6
-rw-r--r--drivers/isdn/hisax/config.c16
-rw-r--r--drivers/isdn/hysdn/hysdn_net.c4
-rw-r--r--drivers/macintosh/rack-meter.c10
-rw-r--r--drivers/md/bitmap.c22
-rw-r--r--drivers/md/dm-table.c2
-rw-r--r--drivers/media/dvb/b2c2/Kconfig2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c6
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig2
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c5
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig46
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c8
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700.h5
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c16
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c143
-rw-r--r--drivers/media/dvb/dvb-usb/usb-urb.c19
-rw-r--r--drivers/media/dvb/siano/sms-cards.c2
-rw-r--r--drivers/media/dvb/ttpci/Kconfig2
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c15
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c7
-rw-r--r--drivers/media/video/compat_ioctl32.c2
-rw-r--r--drivers/media/video/cx18/Kconfig2
-rw-r--r--drivers/media/video/cx23885/Kconfig4
-rw-r--r--drivers/media/video/cx88/Kconfig2
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c33
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c58
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c10
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c143
-rw-r--r--drivers/media/video/em28xx/em28xx.h6
-rw-r--r--drivers/media/video/gspca/conex.c3
-rw-r--r--drivers/media/video/gspca/finepix.c8
-rw-r--r--drivers/media/video/gspca/gspca.c60
-rw-r--r--drivers/media/video/gspca/gspca.h6
-rw-r--r--drivers/media/video/gspca/pac7311.c3
-rw-r--r--drivers/media/video/gspca/spca501.c3
-rw-r--r--drivers/media/video/gspca/spca505.c4
-rw-r--r--drivers/media/video/gspca/spca561.c3
-rw-r--r--drivers/media/video/gspca/vc032x.c3
-rw-r--r--drivers/media/video/gspca/zc3xx.c3
-rw-r--r--drivers/media/video/pvrusb2/Kconfig2
-rw-r--r--drivers/media/video/s2255drv.c2
-rw-r--r--drivers/media/video/saa7134/Kconfig4
-rw-r--r--drivers/message/fusion/mptscsih.c3
-rw-r--r--drivers/message/i2o/i2o_block.c2
-rw-r--r--drivers/message/i2o/iop.c1
-rw-r--r--drivers/misc/sgi-gru/grufault.c4
-rw-r--r--drivers/misc/sgi-gru/grufile.c2
-rw-r--r--drivers/misc/sony-laptop.c4
-rw-r--r--drivers/misc/thinkpad_acpi.c57
-rw-r--r--drivers/mtd/devices/m25p80.c28
-rw-r--r--drivers/mtd/maps/physmap.c26
-rw-r--r--drivers/mtd/nand/fsl_upm.c8
-rw-r--r--drivers/mtd/nand/pasemi_nand.c1
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c1
-rw-r--r--drivers/mtd/onenand/omap2.c17
-rw-r--r--drivers/mtd/ubi/eba.c2
-rw-r--r--drivers/mtd/ubi/scan.c2
-rw-r--r--drivers/mtd/ubi/wl.c3
-rw-r--r--drivers/net/Kconfig3
-rw-r--r--drivers/net/Makefile2
-rw-r--r--drivers/net/bnx2.c41
-rw-r--r--drivers/net/bnx2.h6
-rw-r--r--drivers/net/chelsio/sge.c4
-rw-r--r--drivers/net/e1000e/ich8lan.c9
-rw-r--r--drivers/net/e1000e/netdev.c1
-rw-r--r--drivers/net/enc28j60.c18
-rw-r--r--drivers/net/hp-plus.c2
-rw-r--r--drivers/net/igb/igb_main.c4
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c10
-rw-r--r--drivers/net/jme.h2
-rw-r--r--drivers/net/macvlan.c3
-rw-r--r--drivers/net/mlx4/main.c8
-rw-r--r--drivers/net/mlx4/mlx4.h1
-rw-r--r--drivers/net/mlx4/port.c39
-rw-r--r--drivers/net/netx-eth.c2
-rw-r--r--drivers/net/pcmcia/axnet_cs.c2
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c2
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c1
-rw-r--r--drivers/net/phy/mdio_bus.c5
-rw-r--r--drivers/net/phy/phy_device.c13
-rw-r--r--drivers/net/phy/vitesse.c64
-rw-r--r--drivers/net/ppp_generic.c28
-rw-r--r--drivers/net/pppol2tp.c1
-rw-r--r--drivers/net/sis900.c1
-rw-r--r--drivers/net/smc911x.c10
-rw-r--r--drivers/net/smc91x.c10
-rw-r--r--drivers/net/spider_net.c4
-rw-r--r--drivers/net/starfire.c5
-rw-r--r--drivers/net/sungem.c144
-rw-r--r--drivers/net/tlan.c23
-rw-r--r--drivers/net/wireless/ath5k/base.c35
-rw-r--r--drivers/net/wireless/ath5k/base.h1
-rw-r--r--drivers/net/wireless/ath5k/debug.c10
-rw-r--r--drivers/net/wireless/ath9k/beacon.c10
-rw-r--r--drivers/net/wireless/ath9k/recv.c19
-rw-r--r--drivers/net/wireless/ipw2200.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c24
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c2
-rw-r--r--drivers/net/xen-netfront.c6
-rw-r--r--drivers/parport/parport_serial.c2
-rw-r--r--drivers/pci/hotplug/acpiphp.h2
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c2
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c4
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c5
-rw-r--r--drivers/pci/hotplug/pciehp_core.c23
-rw-r--r--drivers/pci/pci.c2
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c2
-rw-r--r--drivers/pci/pcie/aspm.c29
-rw-r--r--drivers/pci/quirks.c17
-rw-r--r--drivers/pci/slot.c1
-rw-r--r--drivers/pcmcia/bfin_cf_pcmcia.c2
-rw-r--r--drivers/rapidio/rio-scan.c4
-rw-r--r--drivers/rapidio/rio.c2
-rw-r--r--drivers/rtc/rtc-ds1672.c6
-rw-r--r--drivers/rtc/rtc-isl1208.c7
-rw-r--r--drivers/rtc/rtc-max6900.c6
-rw-r--r--drivers/rtc/rtc-starfire.c66
-rw-r--r--drivers/rtc/rtc-twl4030.c2
-rw-r--r--drivers/s390/scsi/zfcp_erp.c7
-rw-r--r--drivers/s390/scsi/zfcp_fc.c7
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c20
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c2
-rw-r--r--drivers/scsi/aacraid/linit.c8
-rw-r--r--drivers/scsi/advansys.c4
-rw-r--r--drivers/scsi/device_handler/scsi_dh_hp_sw.c12
-rw-r--r--drivers/scsi/gdth.c12
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c2
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c16
-rw-r--r--drivers/scsi/libiscsi.c11
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c3
-rw-r--r--drivers/scsi/scsi_error.c3
-rw-r--r--drivers/scsi/scsi_lib.c25
-rw-r--r--drivers/scsi/sd.c2
-rw-r--r--drivers/scsi/sr.c2
-rw-r--r--drivers/scsi/stex.c2
-rw-r--r--drivers/serial/ioc3_serial.c6
-rw-r--r--drivers/serial/mpc52xx_uart.c4
-rw-r--r--drivers/serial/s3c2440.c2
-rw-r--r--drivers/serial/uartlite.c4
-rw-r--r--drivers/sh/maple/maple.c2
-rw-r--r--drivers/spi/au1550_spi.c26
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c5
-rw-r--r--drivers/spi/spi_imx.c25
-rw-r--r--drivers/spi/spi_s3c24xx_gpio.c3
-rw-r--r--drivers/spi/spidev.c4
-rw-r--r--drivers/staging/Kconfig3
-rw-r--r--drivers/usb/class/usbtmc.c1
-rw-r--r--drivers/usb/core/driver.c4
-rw-r--r--drivers/usb/gadget/f_rndis.c4
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c3
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c3
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c14
-rw-r--r--drivers/usb/host/ehci-pci.c9
-rw-r--r--drivers/usb/host/ehci.h12
-rw-r--r--drivers/usb/serial/console.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.h6
-rw-r--r--drivers/usb/serial/option.c35
-rw-r--r--drivers/usb/serial/pl2303.c2
-rw-r--r--drivers/usb/serial/pl2303.h8
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c55
-rw-r--r--drivers/usb/storage/unusual_devs.h35
-rw-r--r--drivers/video/aty/radeon_accel.c291
-rw-r--r--drivers/video/aty/radeon_backlight.c2
-rw-r--r--drivers/video/aty/radeon_base.c22
-rw-r--r--drivers/video/aty/radeon_pm.c6
-rw-r--r--drivers/video/aty/radeonfb.h38
-rw-r--r--drivers/video/console/fbcon.c15
-rw-r--r--drivers/video/macfb.c74
-rw-r--r--drivers/video/mb862xx/mb862xxfb.c4
-rw-r--r--drivers/video/omap/Makefile1
-rw-r--r--drivers/video/omap/lcd_sx1.c327
-rw-r--r--drivers/video/omap/omapfb_main.c2
-rw-r--r--drivers/video/xen-fbfront.c6
-rw-r--r--drivers/video/xilinxfb.c5
-rw-r--r--drivers/w1/masters/Kconfig2
-rw-r--r--drivers/w1/w1_io.c4
-rw-r--r--drivers/watchdog/hpwdt.c5
-rw-r--r--drivers/watchdog/iTCO_vendor_support.c31
-rw-r--r--drivers/watchdog/iTCO_wdt.c164
-rw-r--r--drivers/watchdog/mtx-1_wdt.c4
297 files changed, 3418 insertions, 2731 deletions
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index ea92bac42c53..09c69806c1fc 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -176,16 +176,6 @@ static int __init dmi_enable_osi_linux(const struct dmi_system_id *d)
176 acpi_dmi_osi_linux(1, d); /* enable */ 176 acpi_dmi_osi_linux(1, d); /* enable */
177 return 0; 177 return 0;
178} 178}
179static int __init dmi_disable_osi_linux(const struct dmi_system_id *d)
180{
181 acpi_dmi_osi_linux(0, d); /* disable */
182 return 0;
183}
184static int __init dmi_unknown_osi_linux(const struct dmi_system_id *d)
185{
186 acpi_dmi_osi_linux(-1, d); /* unknown */
187 return 0;
188}
189static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) 179static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
190{ 180{
191 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); 181 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
@@ -193,295 +183,21 @@ static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
193 return 0; 183 return 0;
194} 184}
195 185
196/*
197 * Most BIOS that invoke OSI(Linux) do nothing with it.
198 * But some cause Linux to break.
199 * Only a couple use it to make Linux run better.
200 *
201 * Thus, Linux should continue to disable OSI(Linux) by default,
202 * should continue to discourage BIOS writers from using it, and
203 * should whitelist the few existing systems that require it.
204 *
205 * If it appears clear a vendor isn't using OSI(Linux)
206 * for anything constructive, blacklist them by name to disable
207 * unnecessary dmesg warnings on all of their products.
208 */
209
210static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { 186static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
211 /*
212 * Disable OSI(Linux) warnings on all "Acer, inc."
213 *
214 * _OSI(Linux) disables the latest Windows BIOS code:
215 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3100"),
216 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5050"),
217 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"),
218 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5580"),
219 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 3010"),
220 * _OSI(Linux) effect unknown:
221 * DMI_MATCH(DMI_PRODUCT_NAME, "Ferrari 5000"),
222 */
223 /*
224 * note that dmi_check_system() uses strstr()
225 * to match sub-strings rather than !strcmp(),
226 * so "Acer" below matches "Acer, inc." above.
227 */
228 /*
229 * Disable OSI(Linux) warnings on all "Acer"
230 *
231 * _OSI(Linux) effect unknown:
232 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
233 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720Z"),
234 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"),
235 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"),
236 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"),
237 *
238 * _OSI(Linux) is a NOP:
239 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"),
240 * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"),
241 */
242 {
243 .callback = dmi_disable_osi_linux,
244 .ident = "Acer",
245 .matches = {
246 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
247 },
248 },
249 /*
250 * Disable OSI(Linux) warnings on all "Apple Computer, Inc."
251 * Disable OSI(Linux) warnings on all "Apple Inc."
252 *
253 * _OSI(Linux) confirmed to be a NOP:
254 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"),
255 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBook2,1"),
256 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2"),
257 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"),
258 * _OSI(Linux) effect unknown:
259 * DMI_MATCH(DMI_PRODUCT_NAME, "MacPro2,1"),
260 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro1,1"),
261 */
262 {
263 .callback = dmi_disable_osi_linux,
264 .ident = "Apple",
265 .matches = {
266 DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
267 },
268 },
269 /*
270 * Disable OSI(Linux) warnings on all "BenQ"
271 *
272 * _OSI(Linux) confirmed to be a NOP:
273 * DMI_MATCH(DMI_PRODUCT_NAME, "Joybook S31"),
274 */
275 {
276 .callback = dmi_disable_osi_linux,
277 .ident = "BenQ",
278 .matches = {
279 DMI_MATCH(DMI_SYS_VENDOR, "BenQ"),
280 },
281 },
282 /*
283 * Disable OSI(Linux) warnings on all "Clevo Co."
284 *
285 * _OSI(Linux) confirmed to be a NOP:
286 * DMI_MATCH(DMI_PRODUCT_NAME, "M570RU"),
287 */
288 {
289 .callback = dmi_disable_osi_linux,
290 .ident = "Clevo",
291 .matches = {
292 DMI_MATCH(DMI_SYS_VENDOR, "Clevo Co."),
293 },
294 },
295 /*
296 * Disable OSI(Linux) warnings on all "COMPAL"
297 *
298 * _OSI(Linux) confirmed to be a NOP:
299 * DMI_MATCH(DMI_BOARD_NAME, "HEL8X"),
300 * _OSI(Linux) unknown effect:
301 * DMI_MATCH(DMI_BOARD_NAME, "IFL91"),
302 */
303 {
304 .callback = dmi_disable_osi_linux,
305 .ident = "Compal",
306 .matches = {
307 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
308 },
309 },
310 { /* OSI(Linux) touches USB, unknown side-effect */
311 .callback = dmi_disable_osi_linux,
312 .ident = "Dell Dimension 5150",
313 .matches = {
314 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
315 DMI_MATCH(DMI_PRODUCT_NAME, "Dell DM051"),
316 },
317 },
318 { /* OSI(Linux) is a NOP */
319 .callback = dmi_disable_osi_linux,
320 .ident = "Dell i1501",
321 .matches = {
322 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
323 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1501"),
324 },
325 },
326 { /* OSI(Linux) effect unknown */
327 .callback = dmi_unknown_osi_linux,
328 .ident = "Dell Latitude D830",
329 .matches = {
330 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
331 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude D830"),
332 },
333 },
334 { /* OSI(Linux) effect unknown */
335 .callback = dmi_unknown_osi_linux,
336 .ident = "Dell OptiPlex GX620",
337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
339 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"),
340 },
341 },
342 { /* OSI(Linux) causes some USB initialization to not run */
343 .callback = dmi_unknown_osi_linux,
344 .ident = "Dell OptiPlex 755",
345 .matches = {
346 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
347 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 755"),
348 },
349 },
350 { /* OSI(Linux) effect unknown */
351 .callback = dmi_unknown_osi_linux,
352 .ident = "Dell PE 1900",
353 .matches = {
354 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
355 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1900"),
356 },
357 },
358 { /* OSI(Linux) is a NOP */
359 .callback = dmi_unknown_osi_linux,
360 .ident = "Dell PE 1950",
361 .matches = {
362 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
363 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
364 },
365 },
366 { /* OSI(Linux) is a NOP */
367 .callback = dmi_disable_osi_linux,
368 .ident = "Dell PE R200",
369 .matches = {
370 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
371 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R200"),
372 },
373 },
374 { /* OSI(Linux) touches USB */
375 .callback = dmi_disable_osi_linux,
376 .ident = "Dell PR 390",
377 .matches = {
378 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
379 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"),
380 },
381 },
382 { /* OSI(Linux) touches USB */
383 .callback = dmi_unknown_osi_linux,
384 .ident = "Dell PR 390",
385 .matches = {
386 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
387 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 690"),
388 },
389 },
390 { /* OSI(Linux) unknown - ASL looks benign, but may effect dock/SMM */
391 .callback = dmi_unknown_osi_linux,
392 .ident = "Dell PR M4300",
393 .matches = {
394 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
395 DMI_MATCH(DMI_PRODUCT_NAME, "Precision M4300"),
396 },
397 },
398 { /* OSI(Linux) is a NOP */
399 .callback = dmi_disable_osi_linux,
400 .ident = "Dell Vostro 1000",
401 .matches = {
402 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
403 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1000"),
404 },
405 },
406 { /* OSI(Linux) effect unknown */
407 .callback = dmi_unknown_osi_linux,
408 .ident = "Dell PE SC440",
409 .matches = {
410 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
411 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge SC440"),
412 },
413 },
414 { /* OSI(Linux) effect unknown */
415 .callback = dmi_unknown_osi_linux,
416 .ident = "Dialogue Flybook V5",
417 .matches = {
418 DMI_MATCH(DMI_SYS_VENDOR, "Dialogue Technology Corporation"),
419 DMI_MATCH(DMI_PRODUCT_NAME, "Flybook V5"),
420 },
421 },
422 /*
423 * Disable OSI(Linux) warnings on all "FUJITSU SIEMENS"
424 *
425 * _OSI(Linux) disables latest Windows BIOS code:
426 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pa 2510"),
427 * _OSI(Linux) confirmed to be a NOP:
428 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"),
429 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"),
430 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"),
431 * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
432 * _OSI(Linux) unknown effect:
433 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"),
434 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"),
435 */
436 {
437 .callback = dmi_disable_osi_linux,
438 .ident = "Fujitsu Siemens",
439 .matches = {
440 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
441 },
442 },
443 { 187 {
444 .callback = dmi_disable_osi_vista, 188 .callback = dmi_disable_osi_vista,
445 .ident = "Fujitsu Siemens", 189 .ident = "Fujitsu Siemens",
446 .matches = { 190 .matches = {
447 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 191 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
448 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), 192 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
449 }, 193 },
450 }, 194 },
195
451 /* 196 /*
452 * Disable OSI(Linux) warnings on all "Hewlett-Packard" 197 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
453 * 198 * Linux ignores it, except for the machines enumerated below.
454 * _OSI(Linux) confirmed to be a NOP:
455 * .ident = "HP Pavilion tx 1000"
456 * DMI_MATCH(DMI_BOARD_NAME, "30BF"),
457 * .ident = "HP Pavilion dv2000"
458 * DMI_MATCH(DMI_BOARD_NAME, "30B5"),
459 * .ident = "HP Pavilion dv5000",
460 * DMI_MATCH(DMI_BOARD_NAME, "30A7"),
461 * .ident = "HP Pavilion dv6300 30BC",
462 * DMI_MATCH(DMI_BOARD_NAME, "30BC"),
463 * .ident = "HP Pavilion dv6000",
464 * DMI_MATCH(DMI_BOARD_NAME, "30B7"),
465 * DMI_MATCH(DMI_BOARD_NAME, "30B8"),
466 * .ident = "HP Pavilion dv9000",
467 * DMI_MATCH(DMI_BOARD_NAME, "30B9"),
468 * .ident = "HP Pavilion dv9500",
469 * DMI_MATCH(DMI_BOARD_NAME, "30CB"),
470 * .ident = "HP/Compaq Presario C500",
471 * DMI_MATCH(DMI_BOARD_NAME, "30C6"),
472 * .ident = "HP/Compaq Presario F500",
473 * DMI_MATCH(DMI_BOARD_NAME, "30D3"),
474 * _OSI(Linux) unknown effect:
475 * .ident = "HP Pavilion dv6500",
476 * DMI_MATCH(DMI_BOARD_NAME, "30D0"),
477 */ 199 */
478 { 200
479 .callback = dmi_disable_osi_linux,
480 .ident = "Hewlett-Packard",
481 .matches = {
482 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
483 },
484 },
485 /* 201 /*
486 * Lenovo has a mix of systems OSI(Linux) situations 202 * Lenovo has a mix of systems OSI(Linux) situations
487 * and thus we can not wildcard the vendor. 203 * and thus we can not wildcard the vendor.
@@ -519,113 +235,6 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
519 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"), 235 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"),
520 }, 236 },
521 }, 237 },
522 {
523 .callback = dmi_disable_osi_linux,
524 .ident = "Lenovo 3000 V100",
525 .matches = {
526 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
527 DMI_MATCH(DMI_PRODUCT_VERSION, "LENOVO3000 V100"),
528 },
529 },
530 {
531 .callback = dmi_disable_osi_linux,
532 .ident = "Lenovo 3000 N100",
533 .matches = {
534 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
535 DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
536 },
537 },
538 /*
539 * Disable OSI(Linux) warnings on all "LG Electronics"
540 *
541 * _OSI(Linux) confirmed to be a NOP:
542 * DMI_MATCH(DMI_PRODUCT_NAME, "P1-J150B"),
543 * with DMI_MATCH(DMI_BOARD_NAME, "ROCKY"),
544 *
545 * unknown:
546 * DMI_MATCH(DMI_PRODUCT_NAME, "S1-MDGDG"),
547 * with DMI_MATCH(DMI_BOARD_NAME, "ROCKY"),
548 */
549 {
550 .callback = dmi_disable_osi_linux,
551 .ident = "LG",
552 .matches = {
553 DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
554 },
555 },
556 /* NEC - OSI(Linux) effect unknown */
557 {
558 .callback = dmi_unknown_osi_linux,
559 .ident = "NEC VERSA M360",
560 .matches = {
561 DMI_MATCH(DMI_SYS_VENDOR, "NEC Computers SAS"),
562 DMI_MATCH(DMI_PRODUCT_NAME, "NEC VERSA M360"),
563 },
564 },
565 /* Panasonic */
566 {
567 .callback = dmi_unknown_osi_linux,
568 .ident = "Panasonic",
569 .matches = {
570 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
571 /* Toughbook CF-52 */
572 DMI_MATCH(DMI_PRODUCT_NAME, "CF-52CCABVBG"),
573 },
574 },
575 /*
576 * Disable OSI(Linux) warnings on all "Samsung Electronics"
577 *
578 * OSI(Linux) disables PNP0C32 and other BIOS code for Windows:
579 * DMI_MATCH(DMI_PRODUCT_NAME, "R40P/R41P"),
580 * DMI_MATCH(DMI_PRODUCT_NAME, "R59P/R60P/R61P"),
581 */
582 {
583 .callback = dmi_disable_osi_linux,
584 .ident = "Samsung",
585 .matches = {
586 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
587 },
588 },
589 /*
590 * Disable OSI(Linux) warnings on all "Sony Corporation"
591 *
592 * _OSI(Linux) is a NOP:
593 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NR11S_S"),
594 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"),
595 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"),
596 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"),
597 * _OSI(Linux) unknown effect:
598 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"),
599 */
600 {
601 .callback = dmi_disable_osi_linux,
602 .ident = "Sony",
603 .matches = {
604 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
605 },
606 },
607 /*
608 * Disable OSI(Linux) warnings on all "TOSHIBA"
609 *
610 * _OSI(Linux) breaks sound (bugzilla 7787):
611 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P100"),
612 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P105"),
613 * _OSI(Linux) is a NOP:
614 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A100"),
615 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A210"),
616 * _OSI(Linux) unknown effect:
617 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A135"),
618 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A200"),
619 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P205"),
620 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite U305"),
621 */
622 {
623 .callback = dmi_disable_osi_linux,
624 .ident = "Toshiba",
625 .matches = {
626 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
627 },
628 },
629 {} 238 {}
630}; 239};
631 240
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 7edf6d913c13..765fd1c56cd6 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -688,14 +688,6 @@ void __init acpi_early_init(void)
688 if (acpi_disabled) 688 if (acpi_disabled)
689 return; 689 return;
690 690
691 /*
692 * ACPI CA initializes acpi_dbg_level to non-zero, which means
693 * we get debug output merely by turning on CONFIG_ACPI_DEBUG.
694 * Turn it off so we don't get output unless the user specifies
695 * acpi.debug_level.
696 */
697 acpi_dbg_level = 0;
698
699 printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); 691 printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
700 692
701 /* enable workarounds, unless strict ACPI spec. compliance */ 693 /* enable workarounds, unless strict ACPI spec. compliance */
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index cf41f9fc24a7..30f3ef236ecb 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -219,7 +219,8 @@ static void gpe_transaction(struct acpi_ec *ec, u8 status)
219 goto unlock; 219 goto unlock;
220err: 220err:
221 /* false interrupt, state didn't change */ 221 /* false interrupt, state didn't change */
222 ++ec->curr->irq_count; 222 if (in_interrupt())
223 ++ec->curr->irq_count;
223unlock: 224unlock:
224 spin_unlock_irqrestore(&ec->curr_lock, flags); 225 spin_unlock_irqrestore(&ec->curr_lock, flags);
225} 226}
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 4be252145cb4..c8111424dcb8 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -35,7 +35,6 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/kmod.h> 36#include <linux/kmod.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/dmi.h>
39#include <linux/workqueue.h> 38#include <linux/workqueue.h>
40#include <linux/nmi.h> 39#include <linux/nmi.h>
41#include <linux/acpi.h> 40#include <linux/acpi.h>
@@ -97,54 +96,44 @@ static DEFINE_SPINLOCK(acpi_res_lock);
97static char osi_additional_string[OSI_STRING_LENGTH_MAX]; 96static char osi_additional_string[OSI_STRING_LENGTH_MAX];
98 97
99/* 98/*
100 * "Ode to _OSI(Linux)" 99 * The story of _OSI(Linux)
101 * 100 *
102 * osi_linux -- Control response to BIOS _OSI(Linux) query. 101 * From pre-history through Linux-2.6.22,
102 * Linux responded TRUE upon a BIOS OSI(Linux) query.
103 * 103 *
104 * As Linux evolves, the features that it supports change. 104 * Unfortunately, reference BIOS writers got wind of this
105 * So an OSI string such as "Linux" is not specific enough 105 * and put OSI(Linux) in their example code, quickly exposing
106 * to be useful across multiple versions of Linux. It 106 * this string as ill-conceived and opening the door to
107 * doesn't identify any particular feature, interface, 107 * an un-bounded number of BIOS incompatibilities.
108 * or even any particular version of Linux...
109 * 108 *
110 * Unfortunately, Linux-2.6.22 and earlier responded "yes" 109 * For example, OSI(Linux) was used on resume to re-POST a
111 * to a BIOS _OSI(Linux) query. When 110 * video card on one system, because Linux at that time
112 * a reference mobile BIOS started using it, its use 111 * could not do a speedy restore in its native driver.
113 * started to spread to many vendor platforms. 112 * But then upon gaining quick native restore capability,
114 * As it is not supportable, we need to halt that spread. 113 * Linux has no way to tell the BIOS to skip the time-consuming
114 * POST -- putting Linux at a permanent performance disadvantage.
115 * On another system, the BIOS writer used OSI(Linux)
116 * to infer native OS support for IPMI! On other systems,
117 * OSI(Linux) simply got in the way of Linux claiming to
118 * be compatible with other operating systems, exposing
119 * BIOS issues such as skipped device initialization.
115 * 120 *
116 * Today, most BIOS references to _OSI(Linux) are noise -- 121 * So "Linux" turned out to be a really poor chose of
117 * they have no functional effect and are just dead code 122 * OSI string, and from Linux-2.6.23 onward we respond FALSE.
118 * carried over from the reference BIOS.
119 *
120 * The next most common case is that _OSI(Linux) harms Linux,
121 * usually by causing the BIOS to follow paths that are
122 * not tested during Windows validation.
123 *
124 * Finally, there is a short list of platforms
125 * where OSI(Linux) benefits Linux.
126 *
127 * In Linux-2.6.23, OSI(Linux) is first disabled by default.
128 * DMI is used to disable the dmesg warning about OSI(Linux)
129 * on platforms where it is known to have no effect.
130 * But a dmesg warning remains for systems where
131 * we do not know if OSI(Linux) is good or bad for the system.
132 * DMI is also used to enable OSI(Linux) for the machines
133 * that are known to need it.
134 * 123 *
135 * BIOS writers should NOT query _OSI(Linux) on future systems. 124 * BIOS writers should NOT query _OSI(Linux) on future systems.
136 * It will be ignored by default, and to get Linux to 125 * Linux will complain on the console when it sees it, and return FALSE.
137 * not ignore it will require a kernel source update to 126 * To get Linux to return TRUE for your system will require
138 * add a DMI entry, or a boot-time "acpi_osi=Linux" invocation. 127 * a kernel source update to add a DMI entry,
128 * or boot with "acpi_osi=Linux"
139 */ 129 */
140#define OSI_LINUX_ENABLE 0
141 130
142static struct osi_linux { 131static struct osi_linux {
143 unsigned int enable:1; 132 unsigned int enable:1;
144 unsigned int dmi:1; 133 unsigned int dmi:1;
145 unsigned int cmdline:1; 134 unsigned int cmdline:1;
146 unsigned int known:1; 135 unsigned int known:1;
147} osi_linux = { OSI_LINUX_ENABLE, 0, 0, 0}; 136} osi_linux = { 0, 0, 0, 0};
148 137
149static void __init acpi_request_region (struct acpi_generic_address *addr, 138static void __init acpi_request_region (struct acpi_generic_address *addr,
150 unsigned int length, char *desc) 139 unsigned int length, char *desc)
@@ -1296,34 +1285,6 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1296 return (AE_OK); 1285 return (AE_OK);
1297} 1286}
1298 1287
1299/**
1300 * acpi_dmi_dump - dump DMI slots needed for blacklist entry
1301 *
1302 * Returns 0 on success
1303 */
1304static int acpi_dmi_dump(void)
1305{
1306
1307 if (!dmi_available)
1308 return -1;
1309
1310 printk(KERN_NOTICE PREFIX "DMI System Vendor: %s\n",
1311 dmi_get_system_info(DMI_SYS_VENDOR));
1312 printk(KERN_NOTICE PREFIX "DMI Product Name: %s\n",
1313 dmi_get_system_info(DMI_PRODUCT_NAME));
1314 printk(KERN_NOTICE PREFIX "DMI Product Version: %s\n",
1315 dmi_get_system_info(DMI_PRODUCT_VERSION));
1316 printk(KERN_NOTICE PREFIX "DMI Board Name: %s\n",
1317 dmi_get_system_info(DMI_BOARD_NAME));
1318 printk(KERN_NOTICE PREFIX "DMI BIOS Vendor: %s\n",
1319 dmi_get_system_info(DMI_BIOS_VENDOR));
1320 printk(KERN_NOTICE PREFIX "DMI BIOS Date: %s\n",
1321 dmi_get_system_info(DMI_BIOS_DATE));
1322
1323 return 0;
1324}
1325
1326
1327/****************************************************************************** 1288/******************************************************************************
1328 * 1289 *
1329 * FUNCTION: acpi_os_validate_interface 1290 * FUNCTION: acpi_os_validate_interface
@@ -1350,21 +1311,6 @@ acpi_os_validate_interface (char *interface)
1350 osi_linux.cmdline ? " via cmdline" : 1311 osi_linux.cmdline ? " via cmdline" :
1351 osi_linux.dmi ? " via DMI" : ""); 1312 osi_linux.dmi ? " via DMI" : "");
1352 1313
1353 if (!osi_linux.dmi) {
1354 if (acpi_dmi_dump())
1355 printk(KERN_NOTICE PREFIX
1356 "[please extract dmidecode output]\n");
1357 printk(KERN_NOTICE PREFIX
1358 "Please send DMI info above to "
1359 "linux-acpi@vger.kernel.org\n");
1360 }
1361 if (!osi_linux.known && !osi_linux.cmdline) {
1362 printk(KERN_NOTICE PREFIX
1363 "If \"acpi_osi=%sLinux\" works better, "
1364 "please notify linux-acpi@vger.kernel.org\n",
1365 osi_linux.enable ? "!" : "");
1366 }
1367
1368 if (osi_linux.enable) 1314 if (osi_linux.enable)
1369 return AE_OK; 1315 return AE_OK;
1370 } 1316 }
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index bd5253ee5c85..39b7233c3485 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -751,16 +751,6 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
751 if (!acpi_match_device_ids(device, button_device_ids)) 751 if (!acpi_match_device_ids(device, button_device_ids))
752 device->wakeup.flags.run_wake = 1; 752 device->wakeup.flags.run_wake = 1;
753 753
754 /*
755 * Don't set Power button GPE as run_wake
756 * if Fixed Power button is used
757 */
758 if (!strcmp(device->pnp.hardware_id, "PNP0C0C") &&
759 !(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) {
760 device->wakeup.flags.run_wake = 0;
761 device->wakeup.flags.valid = 0;
762 }
763
764 end: 754 end:
765 if (ACPI_FAILURE(status)) 755 if (ACPI_FAILURE(status))
766 device->flags.wake_capable = 0; 756 device->flags.wake_capable = 0;
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 80c0868d0480..28a691cc625e 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -90,6 +90,18 @@ void __init acpi_old_suspend_ordering(void)
90 old_suspend_ordering = true; 90 old_suspend_ordering = true;
91} 91}
92 92
93/*
94 * According to the ACPI specification the BIOS should make sure that ACPI is
95 * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
96 * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
97 * on such systems during resume. Unfortunately that doesn't help in
98 * particularly pathological cases in which SCI_EN has to be set directly on
99 * resume, although the specification states very clearly that this flag is
100 * owned by the hardware. The set_sci_en_on_resume variable will be set in such
101 * cases.
102 */
103static bool set_sci_en_on_resume;
104
93/** 105/**
94 * acpi_pm_disable_gpes - Disable the GPEs. 106 * acpi_pm_disable_gpes - Disable the GPEs.
95 */ 107 */
@@ -235,7 +247,11 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
235 } 247 }
236 248
237 /* If ACPI is not enabled by the BIOS, we need to enable it here. */ 249 /* If ACPI is not enabled by the BIOS, we need to enable it here. */
238 acpi_enable(); 250 if (set_sci_en_on_resume)
251 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1);
252 else
253 acpi_enable();
254
239 /* Reprogram control registers and execute _BFS */ 255 /* Reprogram control registers and execute _BFS */
240 acpi_leave_sleep_state_prep(acpi_state); 256 acpi_leave_sleep_state_prep(acpi_state);
241 257
@@ -323,6 +339,12 @@ static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
323 return 0; 339 return 0;
324} 340}
325 341
342static int __init init_set_sci_en_on_resume(const struct dmi_system_id *d)
343{
344 set_sci_en_on_resume = true;
345 return 0;
346}
347
326static struct dmi_system_id __initdata acpisleep_dmi_table[] = { 348static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
327 { 349 {
328 .callback = init_old_suspend_ordering, 350 .callback = init_old_suspend_ordering,
@@ -340,6 +362,22 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
340 DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"), 362 DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"),
341 }, 363 },
342 }, 364 },
365 {
366 .callback = init_set_sci_en_on_resume,
367 .ident = "Apple MacBook 1,1",
368 .matches = {
369 DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
370 DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"),
371 },
372 },
373 {
374 .callback = init_set_sci_en_on_resume,
375 .ident = "Apple MacMini 1,1",
376 .matches = {
377 DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
378 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
379 },
380 },
343 {}, 381 {},
344}; 382};
345#endif /* CONFIG_SUSPEND */ 383#endif /* CONFIG_SUSPEND */
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
index 66aac06f2ac5..40e60fc2e596 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/acpi/toshiba_acpi.c
@@ -824,34 +824,36 @@ static int __init toshiba_acpi_init(void)
824 toshiba_acpi_exit(); 824 toshiba_acpi_exit();
825 return -ENOMEM; 825 return -ENOMEM;
826 } 826 }
827 }
828 827
829 /* Register input device for kill switch */ 828 /* Register input device for kill switch */
830 toshiba_acpi.poll_dev = input_allocate_polled_device(); 829 toshiba_acpi.poll_dev = input_allocate_polled_device();
831 if (!toshiba_acpi.poll_dev) { 830 if (!toshiba_acpi.poll_dev) {
832 printk(MY_ERR "unable to allocate kill-switch input device\n"); 831 printk(MY_ERR
833 toshiba_acpi_exit(); 832 "unable to allocate kill-switch input device\n");
834 return -ENOMEM; 833 toshiba_acpi_exit();
835 } 834 return -ENOMEM;
836 toshiba_acpi.poll_dev->private = &toshiba_acpi; 835 }
837 toshiba_acpi.poll_dev->poll = bt_poll_rfkill; 836 toshiba_acpi.poll_dev->private = &toshiba_acpi;
838 toshiba_acpi.poll_dev->poll_interval = 1000; /* msecs */ 837 toshiba_acpi.poll_dev->poll = bt_poll_rfkill;
839 838 toshiba_acpi.poll_dev->poll_interval = 1000; /* msecs */
840 toshiba_acpi.poll_dev->input->name = toshiba_acpi.rfk_name; 839
841 toshiba_acpi.poll_dev->input->id.bustype = BUS_HOST; 840 toshiba_acpi.poll_dev->input->name = toshiba_acpi.rfk_name;
842 toshiba_acpi.poll_dev->input->id.vendor = 0x0930; /* Toshiba USB ID */ 841 toshiba_acpi.poll_dev->input->id.bustype = BUS_HOST;
843 set_bit(EV_SW, toshiba_acpi.poll_dev->input->evbit); 842 /* Toshiba USB ID */
844 set_bit(SW_RFKILL_ALL, toshiba_acpi.poll_dev->input->swbit); 843 toshiba_acpi.poll_dev->input->id.vendor = 0x0930;
845 input_report_switch(toshiba_acpi.poll_dev->input, SW_RFKILL_ALL, TRUE); 844 set_bit(EV_SW, toshiba_acpi.poll_dev->input->evbit);
846 input_sync(toshiba_acpi.poll_dev->input); 845 set_bit(SW_RFKILL_ALL, toshiba_acpi.poll_dev->input->swbit);
847 846 input_report_switch(toshiba_acpi.poll_dev->input,
848 ret = input_register_polled_device(toshiba_acpi.poll_dev); 847 SW_RFKILL_ALL, TRUE);
849 if (ret) { 848 input_sync(toshiba_acpi.poll_dev->input);
850 printk(MY_ERR "unable to register kill-switch input device\n"); 849
851 rfkill_free(toshiba_acpi.rfk_dev); 850 ret = input_register_polled_device(toshiba_acpi.poll_dev);
852 toshiba_acpi.rfk_dev = NULL; 851 if (ret) {
853 toshiba_acpi_exit(); 852 printk(MY_ERR
854 return ret; 853 "unable to register kill-switch input device\n");
854 toshiba_acpi_exit();
855 return ret;
856 }
855 } 857 }
856 858
857 return 0; 859 return 0;
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 670551b95e56..17ed5ac840f7 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -64,7 +64,7 @@ u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
64 64
65/* Debug switch - layer (component) mask */ 65/* Debug switch - layer (component) mask */
66 66
67u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; 67u32 acpi_dbg_layer = 0;
68u32 acpi_gbl_nesting_level = 0; 68u32 acpi_gbl_nesting_level = 0;
69 69
70/* Debugger globals */ 70/* Debugger globals */
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index e827be36ee8d..f844941089bb 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -259,34 +259,26 @@ acpi_evaluate_integer(acpi_handle handle,
259 struct acpi_object_list *arguments, unsigned long long *data) 259 struct acpi_object_list *arguments, unsigned long long *data)
260{ 260{
261 acpi_status status = AE_OK; 261 acpi_status status = AE_OK;
262 union acpi_object *element; 262 union acpi_object element;
263 struct acpi_buffer buffer = { 0, NULL }; 263 struct acpi_buffer buffer = { 0, NULL };
264 264
265
266 if (!data) 265 if (!data)
267 return AE_BAD_PARAMETER; 266 return AE_BAD_PARAMETER;
268 267
269 element = kzalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
270 if (!element)
271 return AE_NO_MEMORY;
272
273 buffer.length = sizeof(union acpi_object); 268 buffer.length = sizeof(union acpi_object);
274 buffer.pointer = element; 269 buffer.pointer = &element;
275 status = acpi_evaluate_object(handle, pathname, arguments, &buffer); 270 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
276 if (ACPI_FAILURE(status)) { 271 if (ACPI_FAILURE(status)) {
277 acpi_util_eval_error(handle, pathname, status); 272 acpi_util_eval_error(handle, pathname, status);
278 kfree(element);
279 return status; 273 return status;
280 } 274 }
281 275
282 if (element->type != ACPI_TYPE_INTEGER) { 276 if (element.type != ACPI_TYPE_INTEGER) {
283 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 277 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
284 kfree(element);
285 return AE_BAD_DATA; 278 return AE_BAD_DATA;
286 } 279 }
287 280
288 *data = element->integer.value; 281 *data = element.integer.value;
289 kfree(element);
290 282
291 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%llu]\n", *data)); 283 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%llu]\n", *data));
292 284
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 78fbec8ceda0..421b7c71e72d 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -153,7 +153,7 @@ config SATA_PROMISE
153 If unsure, say N. 153 If unsure, say N.
154 154
155config SATA_SX4 155config SATA_SX4
156 tristate "Promise SATA SX4 support" 156 tristate "Promise SATA SX4 support (Experimental)"
157 depends on PCI && EXPERIMENTAL 157 depends on PCI && EXPERIMENTAL
158 help 158 help
159 This option enables support for Promise Serial ATA SX4. 159 This option enables support for Promise Serial ATA SX4.
@@ -219,8 +219,8 @@ config PATA_ACPI
219 otherwise unsupported hardware. 219 otherwise unsupported hardware.
220 220
221config PATA_ALI 221config PATA_ALI
222 tristate "ALi PATA support (Experimental)" 222 tristate "ALi PATA support"
223 depends on PCI && EXPERIMENTAL 223 depends on PCI
224 help 224 help
225 This option enables support for the ALi ATA interfaces 225 This option enables support for the ALi ATA interfaces
226 found on the many ALi chipsets. 226 found on the many ALi chipsets.
@@ -263,7 +263,7 @@ config PATA_ATIIXP
263 If unsure, say N. 263 If unsure, say N.
264 264
265config PATA_CMD640_PCI 265config PATA_CMD640_PCI
266 tristate "CMD640 PCI PATA support (Very Experimental)" 266 tristate "CMD640 PCI PATA support (Experimental)"
267 depends on PCI && EXPERIMENTAL 267 depends on PCI && EXPERIMENTAL
268 help 268 help
269 This option enables support for the CMD640 PCI IDE 269 This option enables support for the CMD640 PCI IDE
@@ -291,8 +291,8 @@ config PATA_CS5520
291 If unsure, say N. 291 If unsure, say N.
292 292
293config PATA_CS5530 293config PATA_CS5530
294 tristate "CS5530 PATA support (Experimental)" 294 tristate "CS5530 PATA support"
295 depends on PCI && EXPERIMENTAL 295 depends on PCI
296 help 296 help
297 This option enables support for the Cyrix/NatSemi/AMD CS5530 297 This option enables support for the Cyrix/NatSemi/AMD CS5530
298 companion chip used with the MediaGX/Geode processor family. 298 companion chip used with the MediaGX/Geode processor family.
@@ -309,8 +309,8 @@ config PATA_CS5535
309 If unsure, say N. 309 If unsure, say N.
310 310
311config PATA_CS5536 311config PATA_CS5536
312 tristate "CS5536 PATA support (Experimental)" 312 tristate "CS5536 PATA support"
313 depends on PCI && X86 && !X86_64 && EXPERIMENTAL 313 depends on PCI && X86 && !X86_64
314 help 314 help
315 This option enables support for the AMD CS5536 315 This option enables support for the AMD CS5536
316 companion chip used with the Geode LX processor family. 316 companion chip used with the Geode LX processor family.
@@ -363,7 +363,7 @@ config PATA_HPT37X
363 If unsure, say N. 363 If unsure, say N.
364 364
365config PATA_HPT3X2N 365config PATA_HPT3X2N
366 tristate "HPT 372N/302N PATA support (Very Experimental)" 366 tristate "HPT 372N/302N PATA support (Experimental)"
367 depends on PCI && EXPERIMENTAL 367 depends on PCI && EXPERIMENTAL
368 help 368 help
369 This option enables support for the N variant HPT PATA 369 This option enables support for the N variant HPT PATA
@@ -389,8 +389,8 @@ config PATA_HPT3X3_DMA
389 problems with DMA on this chipset. 389 problems with DMA on this chipset.
390 390
391config PATA_ISAPNP 391config PATA_ISAPNP
392 tristate "ISA Plug and Play PATA support (Experimental)" 392 tristate "ISA Plug and Play PATA support"
393 depends on EXPERIMENTAL && ISAPNP 393 depends on ISAPNP
394 help 394 help
395 This option enables support for ISA plug & play ATA 395 This option enables support for ISA plug & play ATA
396 controllers such as those found on old soundcards. 396 controllers such as those found on old soundcards.
@@ -498,8 +498,8 @@ config PATA_NINJA32
498 If unsure, say N. 498 If unsure, say N.
499 499
500config PATA_NS87410 500config PATA_NS87410
501 tristate "Nat Semi NS87410 PATA support (Experimental)" 501 tristate "Nat Semi NS87410 PATA support"
502 depends on PCI && EXPERIMENTAL 502 depends on PCI
503 help 503 help
504 This option enables support for the National Semiconductor 504 This option enables support for the National Semiconductor
505 NS87410 PCI-IDE controller. 505 NS87410 PCI-IDE controller.
@@ -507,8 +507,8 @@ config PATA_NS87410
507 If unsure, say N. 507 If unsure, say N.
508 508
509config PATA_NS87415 509config PATA_NS87415
510 tristate "Nat Semi NS87415 PATA support (Experimental)" 510 tristate "Nat Semi NS87415 PATA support"
511 depends on PCI && EXPERIMENTAL 511 depends on PCI
512 help 512 help
513 This option enables support for the National Semiconductor 513 This option enables support for the National Semiconductor
514 NS87415 PCI-IDE controller. 514 NS87415 PCI-IDE controller.
@@ -544,8 +544,8 @@ config PATA_PCMCIA
544 If unsure, say N. 544 If unsure, say N.
545 545
546config PATA_PDC_OLD 546config PATA_PDC_OLD
547 tristate "Older Promise PATA controller support (Experimental)" 547 tristate "Older Promise PATA controller support"
548 depends on PCI && EXPERIMENTAL 548 depends on PCI
549 help 549 help
550 This option enables support for the Promise 20246, 20262, 20263, 550 This option enables support for the Promise 20246, 20262, 20263,
551 20265 and 20267 adapters. 551 20265 and 20267 adapters.
@@ -559,7 +559,7 @@ config PATA_QDI
559 Support for QDI 6500 and 6580 PATA controllers on VESA local bus. 559 Support for QDI 6500 and 6580 PATA controllers on VESA local bus.
560 560
561config PATA_RADISYS 561config PATA_RADISYS
562 tristate "RADISYS 82600 PATA support (Very Experimental)" 562 tristate "RADISYS 82600 PATA support (Experimental)"
563 depends on PCI && EXPERIMENTAL 563 depends on PCI && EXPERIMENTAL
564 help 564 help
565 This option enables support for the RADISYS 82600 565 This option enables support for the RADISYS 82600
@@ -586,8 +586,8 @@ config PATA_RZ1000
586 If unsure, say N. 586 If unsure, say N.
587 587
588config PATA_SC1200 588config PATA_SC1200
589 tristate "SC1200 PATA support (Very Experimental)" 589 tristate "SC1200 PATA support"
590 depends on PCI && EXPERIMENTAL 590 depends on PCI
591 help 591 help
592 This option enables support for the NatSemi/AMD SC1200 SoC 592 This option enables support for the NatSemi/AMD SC1200 SoC
593 companion chip used with the Geode processor family. 593 companion chip used with the Geode processor family.
@@ -620,8 +620,8 @@ config PATA_SIL680
620 If unsure, say N. 620 If unsure, say N.
621 621
622config PATA_SIS 622config PATA_SIS
623 tristate "SiS PATA support (Experimental)" 623 tristate "SiS PATA support"
624 depends on PCI && EXPERIMENTAL 624 depends on PCI
625 help 625 help
626 This option enables support for SiS PATA controllers 626 This option enables support for SiS PATA controllers
627 627
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 8e37be19bbf5..c11936e13dd3 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1066,6 +1066,28 @@ static int piix_broken_suspend(void)
1066 if (dmi_find_device(DMI_DEV_TYPE_OEM_STRING, oemstrs[i], NULL)) 1066 if (dmi_find_device(DMI_DEV_TYPE_OEM_STRING, oemstrs[i], NULL))
1067 return 1; 1067 return 1;
1068 1068
1069 /* TECRA M4 sometimes forgets its identify and reports bogus
1070 * DMI information. As the bogus information is a bit
1071 * generic, match as many entries as possible. This manual
1072 * matching is necessary because dmi_system_id.matches is
1073 * limited to four entries.
1074 */
1075 if (dmi_get_system_info(DMI_SYS_VENDOR) &&
1076 dmi_get_system_info(DMI_PRODUCT_NAME) &&
1077 dmi_get_system_info(DMI_PRODUCT_VERSION) &&
1078 dmi_get_system_info(DMI_PRODUCT_SERIAL) &&
1079 dmi_get_system_info(DMI_BOARD_VENDOR) &&
1080 dmi_get_system_info(DMI_BOARD_NAME) &&
1081 dmi_get_system_info(DMI_BOARD_VERSION) &&
1082 !strcmp(dmi_get_system_info(DMI_SYS_VENDOR), "TOSHIBA") &&
1083 !strcmp(dmi_get_system_info(DMI_PRODUCT_NAME), "000000") &&
1084 !strcmp(dmi_get_system_info(DMI_PRODUCT_VERSION), "000000") &&
1085 !strcmp(dmi_get_system_info(DMI_PRODUCT_SERIAL), "000000") &&
1086 !strcmp(dmi_get_system_info(DMI_BOARD_VENDOR), "TOSHIBA") &&
1087 !strcmp(dmi_get_system_info(DMI_BOARD_NAME), "Portable PC") &&
1088 !strcmp(dmi_get_system_info(DMI_BOARD_VERSION), "Version A0"))
1089 return 1;
1090
1069 return 0; 1091 return 0;
1070} 1092}
1071 1093
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4214bfb13bbd..bc6695e3c848 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2492,6 +2492,13 @@ int ata_dev_configure(struct ata_device *dev)
2492 } 2492 }
2493 } 2493 }
2494 2494
2495 if ((dev->horkage & ATA_HORKAGE_FIRMWARE_WARN) && print_info) {
2496 ata_dev_printk(dev, KERN_WARNING, "WARNING: device requires "
2497 "firmware update to be fully functional.\n");
2498 ata_dev_printk(dev, KERN_WARNING, " contact the vendor "
2499 "or visit http://ata.wiki.kernel.org.\n");
2500 }
2501
2495 return 0; 2502 return 0;
2496 2503
2497err_out_nosup: 2504err_out_nosup:
@@ -4042,6 +4049,73 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4042 { "ST380817AS", "3.42", ATA_HORKAGE_NONCQ }, 4049 { "ST380817AS", "3.42", ATA_HORKAGE_NONCQ },
4043 { "ST3160023AS", "3.42", ATA_HORKAGE_NONCQ }, 4050 { "ST3160023AS", "3.42", ATA_HORKAGE_NONCQ },
4044 4051
4052 /* Seagate NCQ + FLUSH CACHE firmware bug */
4053 { "ST31500341AS", "SD15", ATA_HORKAGE_NONCQ |
4054 ATA_HORKAGE_FIRMWARE_WARN },
4055 { "ST31500341AS", "SD16", ATA_HORKAGE_NONCQ |
4056 ATA_HORKAGE_FIRMWARE_WARN },
4057 { "ST31500341AS", "SD17", ATA_HORKAGE_NONCQ |
4058 ATA_HORKAGE_FIRMWARE_WARN },
4059 { "ST31500341AS", "SD18", ATA_HORKAGE_NONCQ |
4060 ATA_HORKAGE_FIRMWARE_WARN },
4061 { "ST31500341AS", "SD19", ATA_HORKAGE_NONCQ |
4062 ATA_HORKAGE_FIRMWARE_WARN },
4063
4064 { "ST31000333AS", "SD15", ATA_HORKAGE_NONCQ |
4065 ATA_HORKAGE_FIRMWARE_WARN },
4066 { "ST31000333AS", "SD16", ATA_HORKAGE_NONCQ |
4067 ATA_HORKAGE_FIRMWARE_WARN },
4068 { "ST31000333AS", "SD17", ATA_HORKAGE_NONCQ |
4069 ATA_HORKAGE_FIRMWARE_WARN },
4070 { "ST31000333AS", "SD18", ATA_HORKAGE_NONCQ |
4071 ATA_HORKAGE_FIRMWARE_WARN },
4072 { "ST31000333AS", "SD19", ATA_HORKAGE_NONCQ |
4073 ATA_HORKAGE_FIRMWARE_WARN },
4074
4075 { "ST3640623AS", "SD15", ATA_HORKAGE_NONCQ |
4076 ATA_HORKAGE_FIRMWARE_WARN },
4077 { "ST3640623AS", "SD16", ATA_HORKAGE_NONCQ |
4078 ATA_HORKAGE_FIRMWARE_WARN },
4079 { "ST3640623AS", "SD17", ATA_HORKAGE_NONCQ |
4080 ATA_HORKAGE_FIRMWARE_WARN },
4081 { "ST3640623AS", "SD18", ATA_HORKAGE_NONCQ |
4082 ATA_HORKAGE_FIRMWARE_WARN },
4083 { "ST3640623AS", "SD19", ATA_HORKAGE_NONCQ |
4084 ATA_HORKAGE_FIRMWARE_WARN },
4085
4086 { "ST3640323AS", "SD15", ATA_HORKAGE_NONCQ |
4087 ATA_HORKAGE_FIRMWARE_WARN },
4088 { "ST3640323AS", "SD16", ATA_HORKAGE_NONCQ |
4089 ATA_HORKAGE_FIRMWARE_WARN },
4090 { "ST3640323AS", "SD17", ATA_HORKAGE_NONCQ |
4091 ATA_HORKAGE_FIRMWARE_WARN },
4092 { "ST3640323AS", "SD18", ATA_HORKAGE_NONCQ |
4093 ATA_HORKAGE_FIRMWARE_WARN },
4094 { "ST3640323AS", "SD19", ATA_HORKAGE_NONCQ |
4095 ATA_HORKAGE_FIRMWARE_WARN },
4096
4097 { "ST3320813AS", "SD15", ATA_HORKAGE_NONCQ |
4098 ATA_HORKAGE_FIRMWARE_WARN },
4099 { "ST3320813AS", "SD16", ATA_HORKAGE_NONCQ |
4100 ATA_HORKAGE_FIRMWARE_WARN },
4101 { "ST3320813AS", "SD17", ATA_HORKAGE_NONCQ |
4102 ATA_HORKAGE_FIRMWARE_WARN },
4103 { "ST3320813AS", "SD18", ATA_HORKAGE_NONCQ |
4104 ATA_HORKAGE_FIRMWARE_WARN },
4105 { "ST3320813AS", "SD19", ATA_HORKAGE_NONCQ |
4106 ATA_HORKAGE_FIRMWARE_WARN },
4107
4108 { "ST3320613AS", "SD15", ATA_HORKAGE_NONCQ |
4109 ATA_HORKAGE_FIRMWARE_WARN },
4110 { "ST3320613AS", "SD16", ATA_HORKAGE_NONCQ |
4111 ATA_HORKAGE_FIRMWARE_WARN },
4112 { "ST3320613AS", "SD17", ATA_HORKAGE_NONCQ |
4113 ATA_HORKAGE_FIRMWARE_WARN },
4114 { "ST3320613AS", "SD18", ATA_HORKAGE_NONCQ |
4115 ATA_HORKAGE_FIRMWARE_WARN },
4116 { "ST3320613AS", "SD19", ATA_HORKAGE_NONCQ |
4117 ATA_HORKAGE_FIRMWARE_WARN },
4118
4045 /* Blacklist entries taken from Silicon Image 3124/3132 4119 /* Blacklist entries taken from Silicon Image 3124/3132
4046 Windows driver .inf file - also several Linux problem reports */ 4120 Windows driver .inf file - also several Linux problem reports */
4047 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, 4121 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, },
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index f2b83eabc7c7..e0c4f05d7d57 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -183,7 +183,9 @@ static unsigned long hpt366_filter(struct ata_device *adev, unsigned long mask)
183 mask &= ~(0xF8 << ATA_SHIFT_UDMA); 183 mask &= ~(0xF8 << ATA_SHIFT_UDMA);
184 if (hpt_dma_blacklisted(adev, "UDMA4", bad_ata66_4)) 184 if (hpt_dma_blacklisted(adev, "UDMA4", bad_ata66_4))
185 mask &= ~(0xF0 << ATA_SHIFT_UDMA); 185 mask &= ~(0xF0 << ATA_SHIFT_UDMA);
186 } 186 } else if (adev->class == ATA_DEV_ATAPI)
187 mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
188
187 return ata_bmdma_mode_filter(adev, mask); 189 return ata_bmdma_mode_filter(adev, mask);
188} 190}
189 191
@@ -211,11 +213,15 @@ static u32 hpt36x_find_mode(struct ata_port *ap, int speed)
211 213
212static int hpt36x_cable_detect(struct ata_port *ap) 214static int hpt36x_cable_detect(struct ata_port *ap)
213{ 215{
214 u8 ata66;
215 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 216 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
217 u8 ata66;
216 218
219 /*
220 * Each channel of pata_hpt366 occupies separate PCI function
221 * as the primary channel and bit1 indicates the cable type.
222 */
217 pci_read_config_byte(pdev, 0x5A, &ata66); 223 pci_read_config_byte(pdev, 0x5A, &ata66);
218 if (ata66 & (1 << ap->port_no)) 224 if (ata66 & 2)
219 return ATA_CBL_PATA40; 225 return ATA_CBL_PATA40;
220 return ATA_CBL_PATA80; 226 return ATA_CBL_PATA80;
221} 227}
@@ -382,10 +388,10 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
382 /* PCI clocking determines the ATA timing values to use */ 388 /* PCI clocking determines the ATA timing values to use */
383 /* info_hpt366 is safe against re-entry so we can scribble on it */ 389 /* info_hpt366 is safe against re-entry so we can scribble on it */
384 switch((reg1 & 0x700) >> 8) { 390 switch((reg1 & 0x700) >> 8) {
385 case 5: 391 case 9:
386 hpriv = &hpt366_40; 392 hpriv = &hpt366_40;
387 break; 393 break;
388 case 9: 394 case 5:
389 hpriv = &hpt366_25; 395 hpriv = &hpt366_25;
390 break; 396 break;
391 default: 397 default:
diff --git a/drivers/ata/pata_ninja32.c b/drivers/ata/pata_ninja32.c
index 4e466eae8b46..4dd9a3b031e4 100644
--- a/drivers/ata/pata_ninja32.c
+++ b/drivers/ata/pata_ninja32.c
@@ -44,7 +44,7 @@
44#include <linux/libata.h> 44#include <linux/libata.h>
45 45
46#define DRV_NAME "pata_ninja32" 46#define DRV_NAME "pata_ninja32"
47#define DRV_VERSION "0.1.1" 47#define DRV_VERSION "0.1.3"
48 48
49 49
50/** 50/**
@@ -130,7 +130,8 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)
130 return rc; 130 return rc;
131 pci_set_master(dev); 131 pci_set_master(dev);
132 132
133 /* Set up the register mappings */ 133 /* Set up the register mappings. We use the I/O mapping as only the
134 older chips also have MMIO on BAR 1 */
134 base = host->iomap[0]; 135 base = host->iomap[0];
135 if (!base) 136 if (!base)
136 return -ENOMEM; 137 return -ENOMEM;
@@ -167,8 +168,12 @@ static int ninja32_reinit_one(struct pci_dev *pdev)
167#endif 168#endif
168 169
169static const struct pci_device_id ninja32[] = { 170static const struct pci_device_id ninja32[] = {
171 { 0x10FC, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
172 { 0x1145, 0x8008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
173 { 0x1145, 0xf008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
170 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 174 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
171 { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 175 { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
176 { 0x1145, 0xf02C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
172 { }, 177 { },
173}; 178};
174 179
diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index f8b3ffc8ae9e..c2e6fb9f2ef9 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -39,9 +39,11 @@
39#define RB500_CF_MAXPORTS 1 39#define RB500_CF_MAXPORTS 1
40#define RB500_CF_IO_DELAY 400 40#define RB500_CF_IO_DELAY 400
41 41
42#define RB500_CF_REG_CMD 0x0800 42#define RB500_CF_REG_BASE 0x0800
43#define RB500_CF_REG_ERR 0x080D
43#define RB500_CF_REG_CTRL 0x080E 44#define RB500_CF_REG_CTRL 0x080E
44#define RB500_CF_REG_DATA 0x0C00 45/* 32bit buffered data register offset */
46#define RB500_CF_REG_DBUF32 0x0C00
45 47
46struct rb532_cf_info { 48struct rb532_cf_info {
47 void __iomem *iobase; 49 void __iomem *iobase;
@@ -72,11 +74,12 @@ static void rb532_pata_exec_command(struct ata_port *ap,
72 rb532_pata_finish_io(ap); 74 rb532_pata_finish_io(ap);
73} 75}
74 76
75static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf, 77static unsigned int rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
76 unsigned int buflen, int write_data) 78 unsigned int buflen, int write_data)
77{ 79{
78 struct ata_port *ap = adev->link->ap; 80 struct ata_port *ap = adev->link->ap;
79 void __iomem *ioaddr = ap->ioaddr.data_addr; 81 void __iomem *ioaddr = ap->ioaddr.data_addr;
82 int retlen = buflen;
80 83
81 if (write_data) { 84 if (write_data) {
82 for (; buflen > 0; buflen--, buf++) 85 for (; buflen > 0; buflen--, buf++)
@@ -87,6 +90,7 @@ static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
87 } 90 }
88 91
89 rb532_pata_finish_io(adev->link->ap); 92 rb532_pata_finish_io(adev->link->ap);
93 return retlen;
90} 94}
91 95
92static void rb532_pata_freeze(struct ata_port *ap) 96static void rb532_pata_freeze(struct ata_port *ap)
@@ -146,13 +150,14 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
146 ap->pio_mask = 0x1f; /* PIO4 */ 150 ap->pio_mask = 0x1f; /* PIO4 */
147 ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO; 151 ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO;
148 152
149 ap->ioaddr.cmd_addr = info->iobase + RB500_CF_REG_CMD; 153 ap->ioaddr.cmd_addr = info->iobase + RB500_CF_REG_BASE;
150 ap->ioaddr.ctl_addr = info->iobase + RB500_CF_REG_CTRL; 154 ap->ioaddr.ctl_addr = info->iobase + RB500_CF_REG_CTRL;
151 ap->ioaddr.altstatus_addr = info->iobase + RB500_CF_REG_CTRL; 155 ap->ioaddr.altstatus_addr = info->iobase + RB500_CF_REG_CTRL;
152 156
153 ata_sff_std_ports(&ap->ioaddr); 157 ata_sff_std_ports(&ap->ioaddr);
154 158
155 ap->ioaddr.data_addr = info->iobase + RB500_CF_REG_DATA; 159 ap->ioaddr.data_addr = info->iobase + RB500_CF_REG_DBUF32;
160 ap->ioaddr.error_addr = info->iobase + RB500_CF_REG_ERR;
156} 161}
157 162
158static __devinit int rb532_pata_driver_probe(struct platform_device *pdev) 163static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index d34236611752..e4be55e047f6 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -56,7 +56,6 @@ static const struct sis_laptop sis_laptop[] = {
56 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ 56 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */
57 { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */ 57 { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */
58 { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */ 58 { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */
59 { 0x5513, 0x1039, 0x5513 }, /* Targa Visionary 1000 */
60 /* end marker */ 59 /* end marker */
61 { 0, } 60 { 0, }
62}; 61};
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index 615412364e99..6b969f8c684f 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2705,7 +2705,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
2705 2705
2706 /* XXX DEV_LABEL is a guess */ 2706 /* XXX DEV_LABEL is a guess */
2707 if (!request_region(iobase, HRZ_IO_EXTENT, DEV_LABEL)) { 2707 if (!request_region(iobase, HRZ_IO_EXTENT, DEV_LABEL)) {
2708 return -EINVAL; 2708 err = -EINVAL;
2709 goto out_disable; 2709 goto out_disable;
2710 } 2710 }
2711 2711
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 9364dc554257..9f7c543cc04b 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1693,6 +1693,11 @@ static int rebuild_lun_table(ctlr_info_t *h, int first_time)
1693 for (i = 0; i <= h->highest_lun; i++) { 1693 for (i = 0; i <= h->highest_lun; i++) {
1694 int j; 1694 int j;
1695 drv_found = 0; 1695 drv_found = 0;
1696
1697 /* skip holes in the array from already deleted drives */
1698 if (h->drv[i].raid_level == -1)
1699 continue;
1700
1696 for (j = 0; j < num_luns; j++) { 1701 for (j = 0; j < num_luns; j++) {
1697 memcpy(&lunid, &ld_buff->LUN[j][0], 4); 1702 memcpy(&lunid, &ld_buff->LUN[j][0], 4);
1698 lunid = le32_to_cpu(lunid); 1703 lunid = le32_to_cpu(lunid);
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index f20bf359b84f..dc7a8c352da2 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -302,7 +302,7 @@ static struct kobj_type kobj_pkt_type_wqueue = {
302static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) 302static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
303{ 303{
304 if (class_pktcdvd) { 304 if (class_pktcdvd) {
305 pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, NULL, 305 pd->dev = device_create(class_pktcdvd, NULL, MKDEV(0, 0), NULL,
306 "%s", pd->name); 306 "%s", pd->name);
307 if (IS_ERR(pd->dev)) 307 if (IS_ERR(pd->dev))
308 pd->dev = NULL; 308 pd->dev = NULL;
@@ -2790,7 +2790,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2790 return 0; 2790 return 0;
2791 2791
2792out_mem: 2792out_mem:
2793 blkdev_put(bdev, FMODE_READ|FMODE_WRITE); 2793 blkdev_put(bdev, FMODE_READ | FMODE_NDELAY);
2794 /* This is safe: open() is still holding a reference. */ 2794 /* This is safe: open() is still holding a reference. */
2795 module_put(THIS_MODULE); 2795 module_put(THIS_MODULE);
2796 return ret; 2796 return ret;
@@ -2975,7 +2975,7 @@ static int pkt_remove_dev(dev_t pkt_dev)
2975 pkt_debugfs_dev_remove(pd); 2975 pkt_debugfs_dev_remove(pd);
2976 pkt_sysfs_dev_remove(pd); 2976 pkt_sysfs_dev_remove(pd);
2977 2977
2978 blkdev_put(pd->bdev, FMODE_READ|FMODE_WRITE); 2978 blkdev_put(pd->bdev, FMODE_READ | FMODE_NDELAY);
2979 2979
2980 remove_proc_entry(pd->name, pkt_proc); 2980 remove_proc_entry(pd->name, pkt_proc);
2981 DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name); 2981 DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name);
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index ecab9e67d47a..29e1dfafb7c6 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -194,7 +194,7 @@ struct ace_device {
194 int in_irq; 194 int in_irq;
195 195
196 /* Details of hardware device */ 196 /* Details of hardware device */
197 unsigned long physaddr; 197 resource_size_t physaddr;
198 void __iomem *baseaddr; 198 void __iomem *baseaddr;
199 int irq; 199 int irq;
200 int bus_width; /* 0 := 8 bit; 1 := 16 bit */ 200 int bus_width; /* 0 := 8 bit; 1 := 16 bit */
@@ -628,8 +628,8 @@ static void ace_fsm_dostate(struct ace_device *ace)
628 628
629 /* Okay, it's a data request, set it up for transfer */ 629 /* Okay, it's a data request, set it up for transfer */
630 dev_dbg(ace->dev, 630 dev_dbg(ace->dev,
631 "request: sec=%lx hcnt=%lx, ccnt=%x, dir=%i\n", 631 "request: sec=%llx hcnt=%lx, ccnt=%x, dir=%i\n",
632 req->sector, req->hard_nr_sectors, 632 (unsigned long long) req->sector, req->hard_nr_sectors,
633 req->current_nr_sectors, rq_data_dir(req)); 633 req->current_nr_sectors, rq_data_dir(req));
634 634
635 ace->req = req; 635 ace->req = req;
@@ -935,7 +935,8 @@ static int __devinit ace_setup(struct ace_device *ace)
935 int rc; 935 int rc;
936 936
937 dev_dbg(ace->dev, "ace_setup(ace=0x%p)\n", ace); 937 dev_dbg(ace->dev, "ace_setup(ace=0x%p)\n", ace);
938 dev_dbg(ace->dev, "physaddr=0x%lx irq=%i\n", ace->physaddr, ace->irq); 938 dev_dbg(ace->dev, "physaddr=0x%llx irq=%i\n",
939 (unsigned long long)ace->physaddr, ace->irq);
939 940
940 spin_lock_init(&ace->lock); 941 spin_lock_init(&ace->lock);
941 init_completion(&ace->id_completion); 942 init_completion(&ace->id_completion);
@@ -1017,8 +1018,8 @@ static int __devinit ace_setup(struct ace_device *ace)
1017 /* Print the identification */ 1018 /* Print the identification */
1018 dev_info(ace->dev, "Xilinx SystemACE revision %i.%i.%i\n", 1019 dev_info(ace->dev, "Xilinx SystemACE revision %i.%i.%i\n",
1019 (version >> 12) & 0xf, (version >> 8) & 0x0f, version & 0xff); 1020 (version >> 12) & 0xf, (version >> 8) & 0x0f, version & 0xff);
1020 dev_dbg(ace->dev, "physaddr 0x%lx, mapped to 0x%p, irq=%i\n", 1021 dev_dbg(ace->dev, "physaddr 0x%llx, mapped to 0x%p, irq=%i\n",
1021 ace->physaddr, ace->baseaddr, ace->irq); 1022 (unsigned long long) ace->physaddr, ace->baseaddr, ace->irq);
1022 1023
1023 ace->media_change = 1; 1024 ace->media_change = 1;
1024 ace_revalidate_disk(ace->gd); 1025 ace_revalidate_disk(ace->gd);
@@ -1035,8 +1036,8 @@ err_alloc_disk:
1035err_blk_initq: 1036err_blk_initq:
1036 iounmap(ace->baseaddr); 1037 iounmap(ace->baseaddr);
1037err_ioremap: 1038err_ioremap:
1038 dev_info(ace->dev, "xsysace: error initializing device at 0x%lx\n", 1039 dev_info(ace->dev, "xsysace: error initializing device at 0x%llx\n",
1039 ace->physaddr); 1040 (unsigned long long) ace->physaddr);
1040 return -ENOMEM; 1041 return -ENOMEM;
1041} 1042}
1042 1043
@@ -1059,7 +1060,7 @@ static void __devexit ace_teardown(struct ace_device *ace)
1059} 1060}
1060 1061
1061static int __devinit 1062static int __devinit
1062ace_alloc(struct device *dev, int id, unsigned long physaddr, 1063ace_alloc(struct device *dev, int id, resource_size_t physaddr,
1063 int irq, int bus_width) 1064 int irq, int bus_width)
1064{ 1065{
1065 struct ace_device *ace; 1066 struct ace_device *ace;
@@ -1119,7 +1120,7 @@ static void __devexit ace_free(struct device *dev)
1119 1120
1120static int __devinit ace_probe(struct platform_device *dev) 1121static int __devinit ace_probe(struct platform_device *dev)
1121{ 1122{
1122 unsigned long physaddr = 0; 1123 resource_size_t physaddr = 0;
1123 int bus_width = ACE_BUS_WIDTH_16; /* FIXME: should not be hard coded */ 1124 int bus_width = ACE_BUS_WIDTH_16; /* FIXME: should not be hard coded */
1124 int id = dev->id; 1125 int id = dev->id;
1125 int irq = NO_IRQ; 1126 int irq = NO_IRQ;
@@ -1165,7 +1166,7 @@ static int __devinit
1165ace_of_probe(struct of_device *op, const struct of_device_id *match) 1166ace_of_probe(struct of_device *op, const struct of_device_id *match)
1166{ 1167{
1167 struct resource res; 1168 struct resource res;
1168 unsigned long physaddr; 1169 resource_size_t physaddr;
1169 const u32 *id; 1170 const u32 *id;
1170 int irq, bus_width, rc; 1171 int irq, bus_width, rc;
1171 1172
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index d16b02423d61..7d2e91cccb13 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2081,10 +2081,6 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
2081 if (!q) 2081 if (!q)
2082 return -ENXIO; 2082 return -ENXIO;
2083 2083
2084 rq = blk_get_request(q, READ, GFP_KERNEL);
2085 if (!rq)
2086 return -ENOMEM;
2087
2088 cdi->last_sense = 0; 2084 cdi->last_sense = 0;
2089 2085
2090 while (nframes) { 2086 while (nframes) {
@@ -2096,9 +2092,17 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
2096 2092
2097 len = nr * CD_FRAMESIZE_RAW; 2093 len = nr * CD_FRAMESIZE_RAW;
2098 2094
2095 rq = blk_get_request(q, READ, GFP_KERNEL);
2096 if (!rq) {
2097 ret = -ENOMEM;
2098 break;
2099 }
2100
2099 ret = blk_rq_map_user(q, rq, NULL, ubuf, len, GFP_KERNEL); 2101 ret = blk_rq_map_user(q, rq, NULL, ubuf, len, GFP_KERNEL);
2100 if (ret) 2102 if (ret) {
2103 blk_put_request(rq);
2101 break; 2104 break;
2105 }
2102 2106
2103 rq->cmd[0] = GPCMD_READ_CD; 2107 rq->cmd[0] = GPCMD_READ_CD;
2104 rq->cmd[1] = 1 << 2; 2108 rq->cmd[1] = 1 << 2;
@@ -2124,6 +2128,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
2124 2128
2125 if (blk_rq_unmap_user(bio)) 2129 if (blk_rq_unmap_user(bio))
2126 ret = -EFAULT; 2130 ret = -EFAULT;
2131 blk_put_request(rq);
2127 2132
2128 if (ret) 2133 if (ret)
2129 break; 2134 break;
@@ -2133,7 +2138,6 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
2133 ubuf += len; 2138 ubuf += len;
2134 } 2139 }
2135 2140
2136 blk_put_request(rq);
2137 return ret; 2141 return ret;
2138} 2142}
2139 2143
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 0f004b65ec03..03f95ec08f59 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -27,7 +27,7 @@
27static int uninorth_rev; 27static int uninorth_rev;
28static int is_u3; 28static int is_u3;
29 29
30static char __devinitdata *aperture = NULL; 30static char *aperture = NULL;
31 31
32static int uninorth_fetch_size(void) 32static int uninorth_fetch_size(void)
33{ 33{
diff --git a/drivers/char/cp437.uni b/drivers/char/cp437.uni
index 1f06889a96b9..bc6163484f62 100644
--- a/drivers/char/cp437.uni
+++ b/drivers/char/cp437.uni
@@ -27,7 +27,7 @@
270x0c U+2640 270x0c U+2640
280x0d U+266a 280x0d U+266a
290x0e U+266b 290x0e U+266b
300x0f U+263c 300x0f U+263c U+00a4
310x10 U+25b6 U+25ba 310x10 U+25b6 U+25ba
320x11 U+25c0 U+25c4 320x11 U+25c0 U+25c4
330x12 U+2195 330x12 U+2195
@@ -55,7 +55,7 @@
550x24 U+0024 550x24 U+0024
560x25 U+0025 560x25 U+0025
570x26 U+0026 570x26 U+0026
580x27 U+0027 580x27 U+0027 U+00b4
590x28 U+0028 590x28 U+0028
600x29 U+0029 600x29 U+0029
610x2a U+002a 610x2a U+002a
@@ -84,7 +84,7 @@
840x41 U+0041 U+00c0 U+00c1 U+00c2 U+00c3 840x41 U+0041 U+00c0 U+00c1 U+00c2 U+00c3
850x42 U+0042 850x42 U+0042
860x43 U+0043 U+00a9 860x43 U+0043 U+00a9
870x44 U+0044 870x44 U+0044 U+00d0
880x45 U+0045 U+00c8 U+00ca U+00cb 880x45 U+0045 U+00c8 U+00ca U+00cb
890x46 U+0046 890x46 U+0046
900x47 U+0047 900x47 U+0047
@@ -140,7 +140,7 @@
1400x79 U+0079 U+00fd 1400x79 U+0079 U+00fd
1410x7a U+007a 1410x7a U+007a
1420x7b U+007b 1420x7b U+007b
1430x7c U+007c U+00a5 1430x7c U+007c U+00a6
1440x7d U+007d 1440x7d U+007d
1450x7e U+007e 1450x7e U+007e
146# 146#
@@ -263,10 +263,10 @@
2630xe8 U+03a6 U+00d8 2630xe8 U+03a6 U+00d8
2640xe9 U+0398 2640xe9 U+0398
2650xea U+03a9 U+2126 2650xea U+03a9 U+2126
2660xeb U+03b4 2660xeb U+03b4 U+00f0
2670xec U+221e 2670xec U+221e
2680xed U+03c6 U+00f8 2680xed U+03c6 U+00f8
2690xee U+03b5 2690xee U+03b5 U+2208
2700xef U+2229 2700xef U+2229
2710xf0 U+2261 2710xf0 U+2261
2720xf1 U+00b1 2720xf1 U+00b1
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 53fdc7ff3870..32b8bbf5003e 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -46,7 +46,7 @@
46/* 46/*
47 * The High Precision Event Timer driver. 47 * The High Precision Event Timer driver.
48 * This driver is closely modelled after the rtc.c driver. 48 * This driver is closely modelled after the rtc.c driver.
49 * http://www.intel.com/hardwaredesign/hpetspec.htm 49 * http://www.intel.com/hardwaredesign/hpetspec_1.pdf
50 */ 50 */
51#define HPET_USER_FREQ (64) 51#define HPET_USER_FREQ (64)
52#define HPET_DRIFT (500) 52#define HPET_DRIFT (500)
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 44e5d60f517e..4b10770fa937 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -3739,7 +3739,7 @@ static int stli_getbrdnr(void)
3739 * do is go probing around in the usual places hoping we can find it. 3739 * do is go probing around in the usual places hoping we can find it.
3740 */ 3740 */
3741 3741
3742static int stli_findeisabrds(void) 3742static int __init stli_findeisabrds(void)
3743{ 3743{
3744 struct stlibrd *brdp; 3744 struct stlibrd *brdp;
3745 unsigned int iobase, eid, i; 3745 unsigned int iobase, eid, i;
@@ -3935,7 +3935,7 @@ static struct stlibrd *stli_allocbrd(void)
3935 * can find. 3935 * can find.
3936 */ 3936 */
3937 3937
3938static int stli_initbrds(void) 3938static int __init stli_initbrds(void)
3939{ 3939{
3940 struct stlibrd *brdp, *nxtbrdp; 3940 struct stlibrd *brdp, *nxtbrdp;
3941 struct stlconf conf; 3941 struct stlconf conf;
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 3b23270eaa65..a8f15e6be594 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -418,7 +418,7 @@ static irqreturn_t cd2401_rxerr_interrupt(int irq, void *dev_id)
418 TTY_OVERRUN); 418 TTY_OVERRUN);
419 /* 419 /*
420 If the flip buffer itself is 420 If the flip buffer itself is
421 overflowing, we still loose 421 overflowing, we still lose
422 the next incoming character. 422 the next incoming character.
423 */ 423 */
424 if (tty_buffer_request_room(tty, 1) != 424 if (tty_buffer_request_room(tty, 1) !=
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 59f472143f08..1412a8d1e58d 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1795,12 +1795,15 @@ retry_open:
1795 } 1795 }
1796#endif 1796#endif
1797 if (device == MKDEV(TTYAUX_MAJOR, 1)) { 1797 if (device == MKDEV(TTYAUX_MAJOR, 1)) {
1798 driver = tty_driver_kref_get(console_device(&index)); 1798 struct tty_driver *console_driver = console_device(&index);
1799 if (driver) { 1799 if (console_driver) {
1800 /* Don't let /dev/console block */ 1800 driver = tty_driver_kref_get(console_driver);
1801 filp->f_flags |= O_NONBLOCK; 1801 if (driver) {
1802 noctty = 1; 1802 /* Don't let /dev/console block */
1803 goto got_driver; 1803 filp->f_flags |= O_NONBLOCK;
1804 noctty = 1;
1805 goto got_driver;
1806 }
1804 } 1807 }
1805 mutex_unlock(&tty_mutex); 1808 mutex_unlock(&tty_mutex);
1806 return -ENODEV; 1809 return -ENODEV;
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index a5af6072e2b3..008176edbd64 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2274,7 +2274,7 @@ rescan_last_byte:
2274 continue; /* nothing to display */ 2274 continue; /* nothing to display */
2275 } 2275 }
2276 /* Glyph not found */ 2276 /* Glyph not found */
2277 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) || c < 128) && !(c & ~charmask)) { 2277 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) && c < 128) && !(c & ~charmask)) {
2278 /* In legacy mode use the glyph we get by a 1:1 mapping. 2278 /* In legacy mode use the glyph we get by a 1:1 mapping.
2279 This would make absolutely no sense with Unicode in mind, 2279 This would make absolutely no sense with Unicode in mind,
2280 but do this for ASCII characters since a font may lack 2280 but do this for ASCII characters since a font may lack
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.c b/drivers/char/xilinx_hwicap/buffer_icap.c
index aa7f7962a9a0..05d897764f02 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.c
+++ b/drivers/char/xilinx_hwicap/buffer_icap.c
@@ -21,9 +21,6 @@
21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE. 22 * FOR A PARTICULAR PURPOSE.
23 * 23 *
24 * Xilinx products are not intended for use in life support appliances,
25 * devices, or systems. Use in such applications is expressly prohibited.
26 *
27 * (c) Copyright 2003-2008 Xilinx Inc. 24 * (c) Copyright 2003-2008 Xilinx Inc.
28 * All rights reserved. 25 * All rights reserved.
29 * 26 *
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.h b/drivers/char/xilinx_hwicap/buffer_icap.h
index 8b0252bf06e2..d4f419ee87ab 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.h
+++ b/drivers/char/xilinx_hwicap/buffer_icap.h
@@ -21,9 +21,6 @@
21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE. 22 * FOR A PARTICULAR PURPOSE.
23 * 23 *
24 * Xilinx products are not intended for use in life support appliances,
25 * devices, or systems. Use in such applications is expressly prohibited.
26 *
27 * (c) Copyright 2003-2008 Xilinx Inc. 24 * (c) Copyright 2003-2008 Xilinx Inc.
28 * All rights reserved. 25 * All rights reserved.
29 * 26 *
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.c b/drivers/char/xilinx_hwicap/fifo_icap.c
index 776b50528478..02225eb19cf6 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.c
+++ b/drivers/char/xilinx_hwicap/fifo_icap.c
@@ -21,9 +21,6 @@
21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE. 22 * FOR A PARTICULAR PURPOSE.
23 * 23 *
24 * Xilinx products are not intended for use in life support appliances,
25 * devices, or systems. Use in such applications is expressly prohibited.
26 *
27 * (c) Copyright 2007-2008 Xilinx Inc. 24 * (c) Copyright 2007-2008 Xilinx Inc.
28 * All rights reserved. 25 * All rights reserved.
29 * 26 *
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.h b/drivers/char/xilinx_hwicap/fifo_icap.h
index 62bda453c90b..4c9dd9a3b62a 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.h
+++ b/drivers/char/xilinx_hwicap/fifo_icap.h
@@ -21,9 +21,6 @@
21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE. 22 * FOR A PARTICULAR PURPOSE.
23 * 23 *
24 * Xilinx products are not intended for use in life support appliances,
25 * devices, or systems. Use in such applications is expressly prohibited.
26 *
27 * (c) Copyright 2007-2008 Xilinx Inc. 24 * (c) Copyright 2007-2008 Xilinx Inc.
28 * All rights reserved. 25 * All rights reserved.
29 * 26 *
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index ed132fe55d3d..f40ab699860f 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -21,9 +21,6 @@
21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE. 22 * FOR A PARTICULAR PURPOSE.
23 * 23 *
24 * Xilinx products are not intended for use in life support appliances,
25 * devices, or systems. Use in such applications is expressly prohibited.
26 *
27 * (c) Copyright 2002 Xilinx Inc., Systems Engineering Group 24 * (c) Copyright 2002 Xilinx Inc., Systems Engineering Group
28 * (c) Copyright 2004 Xilinx Inc., Systems Engineering Group 25 * (c) Copyright 2004 Xilinx Inc., Systems Engineering Group
29 * (c) Copyright 2007-2008 Xilinx Inc. 26 * (c) Copyright 2007-2008 Xilinx Inc.
@@ -626,7 +623,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
626 if (!request_mem_region(drvdata->mem_start, 623 if (!request_mem_region(drvdata->mem_start,
627 drvdata->mem_size, DRIVER_NAME)) { 624 drvdata->mem_size, DRIVER_NAME)) {
628 dev_err(dev, "Couldn't lock memory region at %Lx\n", 625 dev_err(dev, "Couldn't lock memory region at %Lx\n",
629 regs_res->start); 626 (unsigned long long) regs_res->start);
630 retval = -EBUSY; 627 retval = -EBUSY;
631 goto failed1; 628 goto failed1;
632 } 629 }
@@ -645,9 +642,10 @@ static int __devinit hwicap_setup(struct device *dev, int id,
645 mutex_init(&drvdata->sem); 642 mutex_init(&drvdata->sem);
646 drvdata->is_open = 0; 643 drvdata->is_open = 0;
647 644
648 dev_info(dev, "ioremap %lx to %p with size %Lx\n", 645 dev_info(dev, "ioremap %llx to %p with size %llx\n",
649 (unsigned long int)drvdata->mem_start, 646 (unsigned long long) drvdata->mem_start,
650 drvdata->base_address, drvdata->mem_size); 647 drvdata->base_address,
648 (unsigned long long) drvdata->mem_size);
651 649
652 cdev_init(&drvdata->cdev, &hwicap_fops); 650 cdev_init(&drvdata->cdev, &hwicap_fops);
653 drvdata->cdev.owner = THIS_MODULE; 651 drvdata->cdev.owner = THIS_MODULE;
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
index 24d0d9b938fb..8cca11981c5f 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
@@ -21,9 +21,6 @@
21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE. 22 * FOR A PARTICULAR PURPOSE.
23 * 23 *
24 * Xilinx products are not intended for use in life support appliances,
25 * devices, or systems. Use in such applications is expressly prohibited.
26 *
27 * (c) Copyright 2003-2007 Xilinx Inc. 24 * (c) Copyright 2003-2007 Xilinx Inc.
28 * All rights reserved. 25 * All rights reserved.
29 * 26 *
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index c20171078d1d..e1129fad96dd 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -57,11 +57,6 @@ u32 acpi_pm_read_verified(void)
57 return v2; 57 return v2;
58} 58}
59 59
60static cycle_t acpi_pm_read_slow(void)
61{
62 return (cycle_t)acpi_pm_read_verified();
63}
64
65static cycle_t acpi_pm_read(void) 60static cycle_t acpi_pm_read(void)
66{ 61{
67 return (cycle_t)read_pmtmr(); 62 return (cycle_t)read_pmtmr();
@@ -88,6 +83,11 @@ static int __init acpi_pm_good_setup(char *__str)
88} 83}
89__setup("acpi_pm_good", acpi_pm_good_setup); 84__setup("acpi_pm_good", acpi_pm_good_setup);
90 85
86static cycle_t acpi_pm_read_slow(void)
87{
88 return (cycle_t)acpi_pm_read_verified();
89}
90
91static inline void acpi_pm_need_workaround(void) 91static inline void acpi_pm_need_workaround(void)
92{ 92{
93 clocksource_acpi_pm.read = acpi_pm_read_slow; 93 clocksource_acpi_pm.read = acpi_pm_read_slow;
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index b6ad3ac5916e..24607669a52b 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -1357,7 +1357,7 @@ static int hw_supports(struct device *dev, __be32 desc_hdr_template)
1357 return ret; 1357 return ret;
1358} 1358}
1359 1359
1360static int __devexit talitos_remove(struct of_device *ofdev) 1360static int talitos_remove(struct of_device *ofdev)
1361{ 1361{
1362 struct device *dev = &ofdev->dev; 1362 struct device *dev = &ofdev->dev;
1363 struct talitos_private *priv = dev_get_drvdata(dev); 1363 struct talitos_private *priv = dev_get_drvdata(dev);
@@ -1622,7 +1622,7 @@ static struct of_platform_driver talitos_driver = {
1622 .name = "talitos", 1622 .name = "talitos",
1623 .match_table = talitos_match, 1623 .match_table = talitos_match,
1624 .probe = talitos_probe, 1624 .probe = talitos_probe,
1625 .remove = __devexit_p(talitos_remove), 1625 .remove = talitos_remove,
1626}; 1626};
1627 1627
1628static int __init talitos_init(void) 1628static int __init talitos_init(void)
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 5317e08221ec..657996517374 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -388,7 +388,10 @@ int dma_async_device_register(struct dma_device *device)
388 388
389 init_completion(&device->done); 389 init_completion(&device->done);
390 kref_init(&device->refcount); 390 kref_init(&device->refcount);
391
392 mutex_lock(&dma_list_mutex);
391 device->dev_id = id++; 393 device->dev_id = id++;
394 mutex_unlock(&dma_list_mutex);
392 395
393 /* represent channels in sysfs. Probably want devs too */ 396 /* represent channels in sysfs. Probably want devs too */
394 list_for_each_entry(chan, &device->channels, device_node) { 397 list_for_each_entry(chan, &device->channels, device_node) {
diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c
index ecd743f7cc61..6607fdd00b1c 100644
--- a/drivers/dma/ioat_dma.c
+++ b/drivers/dma/ioat_dma.c
@@ -1341,10 +1341,12 @@ static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan)
1341 */ 1341 */
1342#define IOAT_TEST_SIZE 2000 1342#define IOAT_TEST_SIZE 2000
1343 1343
1344DECLARE_COMPLETION(test_completion);
1344static void ioat_dma_test_callback(void *dma_async_param) 1345static void ioat_dma_test_callback(void *dma_async_param)
1345{ 1346{
1346 printk(KERN_ERR "ioatdma: ioat_dma_test_callback(%p)\n", 1347 printk(KERN_ERR "ioatdma: ioat_dma_test_callback(%p)\n",
1347 dma_async_param); 1348 dma_async_param);
1349 complete(&test_completion);
1348} 1350}
1349 1351
1350/** 1352/**
@@ -1410,7 +1412,8 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1410 goto free_resources; 1412 goto free_resources;
1411 } 1413 }
1412 device->common.device_issue_pending(dma_chan); 1414 device->common.device_issue_pending(dma_chan);
1413 msleep(1); 1415
1416 wait_for_completion_timeout(&test_completion, msecs_to_jiffies(3000));
1414 1417
1415 if (device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL) 1418 if (device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL)
1416 != DMA_SUCCESS) { 1419 != DMA_SUCCESS) {
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c
index c7a9306d951d..6be317262200 100644
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -85,18 +85,28 @@ iop_adma_run_tx_complete_actions(struct iop_adma_desc_slot *desc,
85 enum dma_ctrl_flags flags = desc->async_tx.flags; 85 enum dma_ctrl_flags flags = desc->async_tx.flags;
86 u32 src_cnt; 86 u32 src_cnt;
87 dma_addr_t addr; 87 dma_addr_t addr;
88 dma_addr_t dest;
88 89
90 src_cnt = unmap->unmap_src_cnt;
91 dest = iop_desc_get_dest_addr(unmap, iop_chan);
89 if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) { 92 if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
90 addr = iop_desc_get_dest_addr(unmap, iop_chan); 93 enum dma_data_direction dir;
91 dma_unmap_page(dev, addr, len, DMA_FROM_DEVICE); 94
95 if (src_cnt > 1) /* is xor? */
96 dir = DMA_BIDIRECTIONAL;
97 else
98 dir = DMA_FROM_DEVICE;
99
100 dma_unmap_page(dev, dest, len, dir);
92 } 101 }
93 102
94 if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) { 103 if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
95 src_cnt = unmap->unmap_src_cnt;
96 while (src_cnt--) { 104 while (src_cnt--) {
97 addr = iop_desc_get_src_addr(unmap, 105 addr = iop_desc_get_src_addr(unmap,
98 iop_chan, 106 iop_chan,
99 src_cnt); 107 src_cnt);
108 if (addr == dest)
109 continue;
100 dma_unmap_page(dev, addr, len, 110 dma_unmap_page(dev, addr, len,
101 DMA_TO_DEVICE); 111 DMA_TO_DEVICE);
102 } 112 }
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 0328da020a10..bcda17426411 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -311,17 +311,26 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc,
311 enum dma_ctrl_flags flags = desc->async_tx.flags; 311 enum dma_ctrl_flags flags = desc->async_tx.flags;
312 u32 src_cnt; 312 u32 src_cnt;
313 dma_addr_t addr; 313 dma_addr_t addr;
314 dma_addr_t dest;
314 315
316 src_cnt = unmap->unmap_src_cnt;
317 dest = mv_desc_get_dest_addr(unmap);
315 if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) { 318 if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
316 addr = mv_desc_get_dest_addr(unmap); 319 enum dma_data_direction dir;
317 dma_unmap_page(dev, addr, len, DMA_FROM_DEVICE); 320
321 if (src_cnt > 1) /* is xor ? */
322 dir = DMA_BIDIRECTIONAL;
323 else
324 dir = DMA_FROM_DEVICE;
325 dma_unmap_page(dev, dest, len, dir);
318 } 326 }
319 327
320 if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) { 328 if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
321 src_cnt = unmap->unmap_src_cnt;
322 while (src_cnt--) { 329 while (src_cnt--) {
323 addr = mv_desc_get_src_addr(unmap, 330 addr = mv_desc_get_src_addr(unmap,
324 src_cnt); 331 src_cnt);
332 if (addr == dest)
333 continue;
325 dma_unmap_page(dev, addr, len, 334 dma_unmap_page(dev, addr, len,
326 DMA_TO_DEVICE); 335 DMA_TO_DEVICE);
327 } 336 }
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
index 5fcd3d89c75d..4041e9143283 100644
--- a/drivers/edac/edac_device.c
+++ b/drivers/edac/edac_device.c
@@ -394,6 +394,12 @@ static void edac_device_workq_function(struct work_struct *work_req)
394 394
395 mutex_lock(&device_ctls_mutex); 395 mutex_lock(&device_ctls_mutex);
396 396
397 /* If we are being removed, bail out immediately */
398 if (edac_dev->op_state == OP_OFFLINE) {
399 mutex_unlock(&device_ctls_mutex);
400 return;
401 }
402
397 /* Only poll controllers that are running polled and have a check */ 403 /* Only poll controllers that are running polled and have a check */
398 if ((edac_dev->op_state == OP_RUNNING_POLL) && 404 if ((edac_dev->op_state == OP_RUNNING_POLL) &&
399 (edac_dev->edac_check != NULL)) { 405 (edac_dev->edac_check != NULL)) {
@@ -585,14 +591,14 @@ struct edac_device_ctl_info *edac_device_del_device(struct device *dev)
585 /* mark this instance as OFFLINE */ 591 /* mark this instance as OFFLINE */
586 edac_dev->op_state = OP_OFFLINE; 592 edac_dev->op_state = OP_OFFLINE;
587 593
588 /* clear workq processing on this instance */
589 edac_device_workq_teardown(edac_dev);
590
591 /* deregister from global list */ 594 /* deregister from global list */
592 del_edac_device_from_global_list(edac_dev); 595 del_edac_device_from_global_list(edac_dev);
593 596
594 mutex_unlock(&device_ctls_mutex); 597 mutex_unlock(&device_ctls_mutex);
595 598
599 /* clear workq processing on this instance */
600 edac_device_workq_teardown(edac_dev);
601
596 /* Tear down the sysfs entries for this instance */ 602 /* Tear down the sysfs entries for this instance */
597 edac_device_remove_sysfs(edac_dev); 603 edac_device_remove_sysfs(edac_dev);
598 604
diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
index e43bdc43a1bf..ebb037b78758 100644
--- a/drivers/edac/i82875p_edac.c
+++ b/drivers/edac/i82875p_edac.c
@@ -182,8 +182,6 @@ static struct pci_dev *mci_pdev; /* init dev: in case that AGP code has
182 * already registered driver 182 * already registered driver
183 */ 183 */
184 184
185static int i82875p_registered = 1;
186
187static struct edac_pci_ctl_info *i82875p_pci; 185static struct edac_pci_ctl_info *i82875p_pci;
188 186
189static void i82875p_get_error_info(struct mem_ctl_info *mci, 187static void i82875p_get_error_info(struct mem_ctl_info *mci,
@@ -295,6 +293,7 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
295 "%s(): pci_bus_add_device() Failed\n", 293 "%s(): pci_bus_add_device() Failed\n",
296 __func__); 294 __func__);
297 } 295 }
296 pci_bus_assign_resources(dev->bus);
298 } 297 }
299 298
300 *ovrfl_pdev = dev; 299 *ovrfl_pdev = dev;
@@ -409,6 +408,9 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
409 goto fail0; 408 goto fail0;
410 } 409 }
411 410
411 /* Keeps mci available after edac_mc_del_mc() till edac_mc_free() */
412 kobject_get(&mci->edac_mci_kobj);
413
412 debugf3("%s(): init mci\n", __func__); 414 debugf3("%s(): init mci\n", __func__);
413 mci->dev = &pdev->dev; 415 mci->dev = &pdev->dev;
414 mci->mtype_cap = MEM_FLAG_DDR; 416 mci->mtype_cap = MEM_FLAG_DDR;
@@ -451,6 +453,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
451 return 0; 453 return 0;
452 454
453fail1: 455fail1:
456 kobject_put(&mci->edac_mci_kobj);
454 edac_mc_free(mci); 457 edac_mc_free(mci);
455 458
456fail0: 459fail0:
@@ -578,12 +581,11 @@ static void __exit i82875p_exit(void)
578{ 581{
579 debugf3("%s()\n", __func__); 582 debugf3("%s()\n", __func__);
580 583
584 i82875p_remove_one(mci_pdev);
585 pci_dev_put(mci_pdev);
586
581 pci_unregister_driver(&i82875p_driver); 587 pci_unregister_driver(&i82875p_driver);
582 588
583 if (!i82875p_registered) {
584 i82875p_remove_one(mci_pdev);
585 pci_dev_put(mci_pdev);
586 }
587} 589}
588 590
589module_init(i82875p_init); 591module_init(i82875p_init);
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 46610b090415..ab9c01e462ef 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -974,6 +974,7 @@ at_context_queue_packet(struct context *ctx, struct fw_packet *packet)
974 packet->ack = RCODE_SEND_ERROR; 974 packet->ack = RCODE_SEND_ERROR;
975 return -1; 975 return -1;
976 } 976 }
977 packet->payload_bus = payload_bus;
977 978
978 d[2].req_count = cpu_to_le16(packet->payload_length); 979 d[2].req_count = cpu_to_le16(packet->payload_length);
979 d[2].data_address = cpu_to_le32(payload_bus); 980 d[2].data_address = cpu_to_le32(payload_bus);
@@ -1025,7 +1026,6 @@ static int handle_at_packet(struct context *context,
1025 struct driver_data *driver_data; 1026 struct driver_data *driver_data;
1026 struct fw_packet *packet; 1027 struct fw_packet *packet;
1027 struct fw_ohci *ohci = context->ohci; 1028 struct fw_ohci *ohci = context->ohci;
1028 dma_addr_t payload_bus;
1029 int evt; 1029 int evt;
1030 1030
1031 if (last->transfer_status == 0) 1031 if (last->transfer_status == 0)
@@ -1038,9 +1038,8 @@ static int handle_at_packet(struct context *context,
1038 /* This packet was cancelled, just continue. */ 1038 /* This packet was cancelled, just continue. */
1039 return 1; 1039 return 1;
1040 1040
1041 payload_bus = le32_to_cpu(last->data_address); 1041 if (packet->payload_bus)
1042 if (payload_bus != 0) 1042 dma_unmap_single(ohci->card.device, packet->payload_bus,
1043 dma_unmap_single(ohci->card.device, payload_bus,
1044 packet->payload_length, DMA_TO_DEVICE); 1043 packet->payload_length, DMA_TO_DEVICE);
1045 1044
1046 evt = le16_to_cpu(last->transfer_status) & 0x1f; 1045 evt = le16_to_cpu(last->transfer_status) & 0x1f;
@@ -1697,6 +1696,10 @@ static int ohci_cancel_packet(struct fw_card *card, struct fw_packet *packet)
1697 if (packet->ack != 0) 1696 if (packet->ack != 0)
1698 goto out; 1697 goto out;
1699 1698
1699 if (packet->payload_bus)
1700 dma_unmap_single(ohci->card.device, packet->payload_bus,
1701 packet->payload_length, DMA_TO_DEVICE);
1702
1700 log_ar_at_event('T', packet->speed, packet->header, 0x20); 1703 log_ar_at_event('T', packet->speed, packet->header, 0x20);
1701 driver_data->packet = NULL; 1704 driver_data->packet = NULL;
1702 packet->ack = RCODE_CANCELLED; 1705 packet->ack = RCODE_CANCELLED;
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 97df6dac3a82..e54403ee59e7 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -372,6 +372,11 @@ static const struct {
372 }, 372 },
373 /* iPod mini */ { 373 /* iPod mini */ {
374 .firmware_revision = 0x0a2700, 374 .firmware_revision = 0x0a2700,
375 .model = 0x000022,
376 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
377 },
378 /* iPod mini */ {
379 .firmware_revision = 0x0a2700,
375 .model = 0x000023, 380 .model = 0x000023,
376 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 381 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
377 }, 382 },
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 022ac4fabb67..2884f876397b 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -207,6 +207,7 @@ fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
207 packet->speed = speed; 207 packet->speed = speed;
208 packet->generation = generation; 208 packet->generation = generation;
209 packet->ack = 0; 209 packet->ack = 0;
210 packet->payload_bus = 0;
210} 211}
211 212
212/** 213/**
@@ -581,6 +582,8 @@ fw_fill_response(struct fw_packet *response, u32 *request_header,
581 BUG(); 582 BUG();
582 return; 583 return;
583 } 584 }
585
586 response->payload_bus = 0;
584} 587}
585EXPORT_SYMBOL(fw_fill_response); 588EXPORT_SYMBOL(fw_fill_response);
586 589
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index aed7dbb17cda..839466f0a795 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -27,6 +27,7 @@
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/spinlock_types.h> 28#include <linux/spinlock_types.h>
29#include <linux/timer.h> 29#include <linux/timer.h>
30#include <linux/types.h>
30#include <linux/workqueue.h> 31#include <linux/workqueue.h>
31 32
32#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) 33#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4)
@@ -153,6 +154,7 @@ struct fw_packet {
153 size_t header_length; 154 size_t header_length;
154 void *payload; 155 void *payload;
155 size_t payload_length; 156 size_t payload_length;
157 dma_addr_t payload_bus;
156 u32 timestamp; 158 u32 timestamp;
157 159
158 /* 160 /*
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3ab1e9cc4692..996097acb5e7 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -305,6 +305,8 @@ static void drm_cleanup(struct drm_device * dev)
305 return; 305 return;
306 } 306 }
307 307
308 drm_vblank_cleanup(dev);
309
308 drm_lastclose(dev); 310 drm_lastclose(dev);
309 311
310 if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && 312 if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 15c8dabc3e97..1e787f894b3c 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -94,7 +94,7 @@ static void vblank_disable_fn(unsigned long arg)
94 } 94 }
95} 95}
96 96
97static void drm_vblank_cleanup(struct drm_device *dev) 97void drm_vblank_cleanup(struct drm_device *dev)
98{ 98{
99 /* Bail if the driver didn't call drm_vblank_init() */ 99 /* Bail if the driver didn't call drm_vblank_init() */
100 if (dev->num_crtcs == 0) 100 if (dev->num_crtcs == 0)
@@ -278,8 +278,6 @@ int drm_irq_uninstall(struct drm_device * dev)
278 278
279 free_irq(dev->pdev->irq, dev); 279 free_irq(dev->pdev->irq, dev);
280 280
281 drm_vblank_cleanup(dev);
282
283 return 0; 281 return 0;
284} 282}
285EXPORT_SYMBOL(drm_irq_uninstall); 283EXPORT_SYMBOL(drm_irq_uninstall);
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 0d215e38606a..afa8a12cd009 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -717,7 +717,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
717 value = dev->pci_device; 717 value = dev->pci_device;
718 break; 718 break;
719 case I915_PARAM_HAS_GEM: 719 case I915_PARAM_HAS_GEM:
720 value = 1; 720 value = dev_priv->has_gem;
721 break; 721 break;
722 default: 722 default:
723 DRM_ERROR("Unknown parameter %d\n", param->param); 723 DRM_ERROR("Unknown parameter %d\n", param->param);
@@ -830,6 +830,14 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
830 830
831 dev_priv->regs = ioremap(base, size); 831 dev_priv->regs = ioremap(base, size);
832 832
833#ifdef CONFIG_HIGHMEM64G
834 /* don't enable GEM on PAE - needs agp + set_memory_* interface fixes */
835 dev_priv->has_gem = 0;
836#else
837 /* enable GEM by default */
838 dev_priv->has_gem = 1;
839#endif
840
833 i915_gem_load(dev); 841 i915_gem_load(dev);
834 842
835 /* Init HWS */ 843 /* Init HWS */
@@ -847,15 +855,23 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
847 * and the registers being closely associated. 855 * and the registers being closely associated.
848 * 856 *
849 * According to chipset errata, on the 965GM, MSI interrupts may 857 * According to chipset errata, on the 965GM, MSI interrupts may
850 * be lost or delayed 858 * be lost or delayed, but we use them anyways to avoid
859 * stuck interrupts on some machines.
851 */ 860 */
852 if (!IS_I945G(dev) && !IS_I945GM(dev) && !IS_I965GM(dev)) 861 if (!IS_I945G(dev) && !IS_I945GM(dev))
853 pci_enable_msi(dev->pdev); 862 pci_enable_msi(dev->pdev);
854 863
855 intel_opregion_init(dev); 864 intel_opregion_init(dev);
856 865
857 spin_lock_init(&dev_priv->user_irq_lock); 866 spin_lock_init(&dev_priv->user_irq_lock);
858 867
868 ret = drm_vblank_init(dev, I915_NUM_PIPE);
869
870 if (ret) {
871 (void) i915_driver_unload(dev);
872 return ret;
873 }
874
859 return ret; 875 return ret;
860} 876}
861 877
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ef1c0b8f8d07..b3cc4731aa7c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -47,6 +47,8 @@ enum pipe {
47 PIPE_B, 47 PIPE_B,
48}; 48};
49 49
50#define I915_NUM_PIPE 2
51
50/* Interface history: 52/* Interface history:
51 * 53 *
52 * 1.1: Original. 54 * 1.1: Original.
@@ -104,6 +106,8 @@ struct intel_opregion {
104typedef struct drm_i915_private { 106typedef struct drm_i915_private {
105 struct drm_device *dev; 107 struct drm_device *dev;
106 108
109 int has_gem;
110
107 void __iomem *regs; 111 void __iomem *regs;
108 drm_local_map_t *sarea; 112 drm_local_map_t *sarea;
109 113
@@ -132,6 +136,7 @@ typedef struct drm_i915_private {
132 int user_irq_refcount; 136 int user_irq_refcount;
133 /** Cached value of IMR to avoid reads in updating the bitfield */ 137 /** Cached value of IMR to avoid reads in updating the bitfield */
134 u32 irq_mask_reg; 138 u32 irq_mask_reg;
139 u32 pipestat[2];
135 140
136 int tex_lru_log_granularity; 141 int tex_lru_log_granularity;
137 int allow_batchbuffer; 142 int allow_batchbuffer;
@@ -147,6 +152,7 @@ typedef struct drm_i915_private {
147 u32 saveDSPBCNTR; 152 u32 saveDSPBCNTR;
148 u32 saveDSPARB; 153 u32 saveDSPARB;
149 u32 saveRENDERSTANDBY; 154 u32 saveRENDERSTANDBY;
155 u32 saveHWS;
150 u32 savePIPEACONF; 156 u32 savePIPEACONF;
151 u32 savePIPEBCONF; 157 u32 savePIPEBCONF;
152 u32 savePIPEASRC; 158 u32 savePIPEASRC;
@@ -240,6 +246,10 @@ typedef struct drm_i915_private {
240 * List of objects currently involved in rendering from the 246 * List of objects currently involved in rendering from the
241 * ringbuffer. 247 * ringbuffer.
242 * 248 *
249 * Includes buffers having the contents of their GPU caches
250 * flushed, not necessarily primitives. last_rendering_seqno
251 * represents when the rendering involved will be completed.
252 *
243 * A reference is held on the buffer while on this list. 253 * A reference is held on the buffer while on this list.
244 */ 254 */
245 struct list_head active_list; 255 struct list_head active_list;
@@ -249,6 +259,8 @@ typedef struct drm_i915_private {
249 * still have a write_domain which needs to be flushed before 259 * still have a write_domain which needs to be flushed before
250 * unbinding. 260 * unbinding.
251 * 261 *
262 * last_rendering_seqno is 0 while an object is in this list.
263 *
252 * A reference is held on the buffer while on this list. 264 * A reference is held on the buffer while on this list.
253 */ 265 */
254 struct list_head flushing_list; 266 struct list_head flushing_list;
@@ -257,6 +269,8 @@ typedef struct drm_i915_private {
257 * LRU list of objects which are not in the ringbuffer and 269 * LRU list of objects which are not in the ringbuffer and
258 * are ready to unbind, but are still in the GTT. 270 * are ready to unbind, but are still in the GTT.
259 * 271 *
272 * last_rendering_seqno is 0 while an object is in this list.
273 *
260 * A reference is not held on the buffer while on this list, 274 * A reference is not held on the buffer while on this list,
261 * as merely being GTT-bound shouldn't prevent its being 275 * as merely being GTT-bound shouldn't prevent its being
262 * freed, and we'll pull it off the list in the free path. 276 * freed, and we'll pull it off the list in the free path.
@@ -367,8 +381,8 @@ struct drm_i915_gem_object {
367 uint32_t agp_type; 381 uint32_t agp_type;
368 382
369 /** 383 /**
370 * Flagging of which individual pages are valid in GEM_DOMAIN_CPU when 384 * If present, while GEM_DOMAIN_CPU is in the read domain this array
371 * GEM_DOMAIN_CPU is not in the object's read domain. 385 * flags which individual pages are valid.
372 */ 386 */
373 uint8_t *page_cpu_valid; 387 uint8_t *page_cpu_valid;
374}; 388};
@@ -390,9 +404,6 @@ struct drm_i915_gem_request {
390 /** Time at which this request was emitted, in jiffies. */ 404 /** Time at which this request was emitted, in jiffies. */
391 unsigned long emitted_jiffies; 405 unsigned long emitted_jiffies;
392 406
393 /** Cache domains that were flushed at the start of the request. */
394 uint32_t flush_domains;
395
396 struct list_head list; 407 struct list_head list;
397}; 408};
398 409
@@ -446,6 +457,13 @@ extern int i915_vblank_swap(struct drm_device *dev, void *data,
446 struct drm_file *file_priv); 457 struct drm_file *file_priv);
447extern void i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask); 458extern void i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask);
448 459
460void
461i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask);
462
463void
464i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask);
465
466
449/* i915_mem.c */ 467/* i915_mem.c */
450extern int i915_mem_alloc(struct drm_device *dev, void *data, 468extern int i915_mem_alloc(struct drm_device *dev, void *data,
451 struct drm_file *file_priv); 469 struct drm_file *file_priv);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 6b4a2bd20640..24fe8c10b4b2 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -31,21 +31,23 @@
31#include "i915_drv.h" 31#include "i915_drv.h"
32#include <linux/swap.h> 32#include <linux/swap.h>
33 33
34static int 34#define I915_GEM_GPU_DOMAINS (~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
35i915_gem_object_set_domain(struct drm_gem_object *obj, 35
36 uint32_t read_domains, 36static void
37 uint32_t write_domain); 37i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj,
38static int 38 uint32_t read_domains,
39i915_gem_object_set_domain_range(struct drm_gem_object *obj, 39 uint32_t write_domain);
40 uint64_t offset, 40static void i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj);
41 uint64_t size, 41static void i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj);
42 uint32_t read_domains, 42static void i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj);
43 uint32_t write_domain); 43static int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj,
44static int 44 int write);
45i915_gem_set_domain(struct drm_gem_object *obj, 45static int i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj,
46 struct drm_file *file_priv, 46 int write);
47 uint32_t read_domains, 47static int i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
48 uint32_t write_domain); 48 uint64_t offset,
49 uint64_t size);
50static void i915_gem_object_set_to_full_cpu_read_domain(struct drm_gem_object *obj);
49static int i915_gem_object_get_page_list(struct drm_gem_object *obj); 51static int i915_gem_object_get_page_list(struct drm_gem_object *obj);
50static void i915_gem_object_free_page_list(struct drm_gem_object *obj); 52static void i915_gem_object_free_page_list(struct drm_gem_object *obj);
51static int i915_gem_object_wait_rendering(struct drm_gem_object *obj); 53static int i915_gem_object_wait_rendering(struct drm_gem_object *obj);
@@ -83,20 +85,14 @@ int
83i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, 85i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
84 struct drm_file *file_priv) 86 struct drm_file *file_priv)
85{ 87{
86 drm_i915_private_t *dev_priv = dev->dev_private;
87 struct drm_i915_gem_get_aperture *args = data; 88 struct drm_i915_gem_get_aperture *args = data;
88 struct drm_i915_gem_object *obj_priv;
89 89
90 if (!(dev->driver->driver_features & DRIVER_GEM)) 90 if (!(dev->driver->driver_features & DRIVER_GEM))
91 return -ENODEV; 91 return -ENODEV;
92 92
93 args->aper_size = dev->gtt_total; 93 args->aper_size = dev->gtt_total;
94 args->aper_available_size = args->aper_size; 94 args->aper_available_size = (args->aper_size -
95 95 atomic_read(&dev->pin_memory));
96 list_for_each_entry(obj_priv, &dev_priv->mm.active_list, list) {
97 if (obj_priv->pin_count > 0)
98 args->aper_available_size -= obj_priv->obj->size;
99 }
100 96
101 return 0; 97 return 0;
102} 98}
@@ -166,8 +162,8 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
166 162
167 mutex_lock(&dev->struct_mutex); 163 mutex_lock(&dev->struct_mutex);
168 164
169 ret = i915_gem_object_set_domain_range(obj, args->offset, args->size, 165 ret = i915_gem_object_set_cpu_read_domain_range(obj, args->offset,
170 I915_GEM_DOMAIN_CPU, 0); 166 args->size);
171 if (ret != 0) { 167 if (ret != 0) {
172 drm_gem_object_unreference(obj); 168 drm_gem_object_unreference(obj);
173 mutex_unlock(&dev->struct_mutex); 169 mutex_unlock(&dev->struct_mutex);
@@ -264,8 +260,7 @@ i915_gem_gtt_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
264 mutex_unlock(&dev->struct_mutex); 260 mutex_unlock(&dev->struct_mutex);
265 return ret; 261 return ret;
266 } 262 }
267 ret = i915_gem_set_domain(obj, file_priv, 263 ret = i915_gem_object_set_to_gtt_domain(obj, 1);
268 I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
269 if (ret) 264 if (ret)
270 goto fail; 265 goto fail;
271 266
@@ -324,8 +319,7 @@ i915_gem_shmem_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
324 319
325 mutex_lock(&dev->struct_mutex); 320 mutex_lock(&dev->struct_mutex);
326 321
327 ret = i915_gem_set_domain(obj, file_priv, 322 ret = i915_gem_object_set_to_cpu_domain(obj, 1);
328 I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
329 if (ret) { 323 if (ret) {
330 mutex_unlock(&dev->struct_mutex); 324 mutex_unlock(&dev->struct_mutex);
331 return ret; 325 return ret;
@@ -401,7 +395,8 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
401} 395}
402 396
403/** 397/**
404 * Called when user space prepares to use an object 398 * Called when user space prepares to use an object with the CPU, either
399 * through the mmap ioctl's mapping or a GTT mapping.
405 */ 400 */
406int 401int
407i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, 402i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
@@ -409,11 +404,26 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
409{ 404{
410 struct drm_i915_gem_set_domain *args = data; 405 struct drm_i915_gem_set_domain *args = data;
411 struct drm_gem_object *obj; 406 struct drm_gem_object *obj;
407 uint32_t read_domains = args->read_domains;
408 uint32_t write_domain = args->write_domain;
412 int ret; 409 int ret;
413 410
414 if (!(dev->driver->driver_features & DRIVER_GEM)) 411 if (!(dev->driver->driver_features & DRIVER_GEM))
415 return -ENODEV; 412 return -ENODEV;
416 413
414 /* Only handle setting domains to types used by the CPU. */
415 if (write_domain & ~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
416 return -EINVAL;
417
418 if (read_domains & ~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
419 return -EINVAL;
420
421 /* Having something in the write domain implies it's in the read
422 * domain, and only that read domain. Enforce that in the request.
423 */
424 if (write_domain != 0 && read_domains != write_domain)
425 return -EINVAL;
426
417 obj = drm_gem_object_lookup(dev, file_priv, args->handle); 427 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
418 if (obj == NULL) 428 if (obj == NULL)
419 return -EBADF; 429 return -EBADF;
@@ -421,10 +431,21 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
421 mutex_lock(&dev->struct_mutex); 431 mutex_lock(&dev->struct_mutex);
422#if WATCH_BUF 432#if WATCH_BUF
423 DRM_INFO("set_domain_ioctl %p(%d), %08x %08x\n", 433 DRM_INFO("set_domain_ioctl %p(%d), %08x %08x\n",
424 obj, obj->size, args->read_domains, args->write_domain); 434 obj, obj->size, read_domains, write_domain);
425#endif 435#endif
426 ret = i915_gem_set_domain(obj, file_priv, 436 if (read_domains & I915_GEM_DOMAIN_GTT) {
427 args->read_domains, args->write_domain); 437 ret = i915_gem_object_set_to_gtt_domain(obj, write_domain != 0);
438
439 /* Silently promote "you're not bound, there was nothing to do"
440 * to success, since the client was just asking us to
441 * make sure everything was done.
442 */
443 if (ret == -EINVAL)
444 ret = 0;
445 } else {
446 ret = i915_gem_object_set_to_cpu_domain(obj, write_domain != 0);
447 }
448
428 drm_gem_object_unreference(obj); 449 drm_gem_object_unreference(obj);
429 mutex_unlock(&dev->struct_mutex); 450 mutex_unlock(&dev->struct_mutex);
430 return ret; 451 return ret;
@@ -459,10 +480,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
459 obj_priv = obj->driver_private; 480 obj_priv = obj->driver_private;
460 481
461 /* Pinned buffers may be scanout, so flush the cache */ 482 /* Pinned buffers may be scanout, so flush the cache */
462 if ((obj->write_domain & I915_GEM_DOMAIN_CPU) && obj_priv->pin_count) { 483 if (obj_priv->pin_count)
463 i915_gem_clflush_object(obj); 484 i915_gem_object_flush_cpu_write_domain(obj);
464 drm_agp_chipset_flush(dev); 485
465 }
466 drm_gem_object_unreference(obj); 486 drm_gem_object_unreference(obj);
467 mutex_unlock(&dev->struct_mutex); 487 mutex_unlock(&dev->struct_mutex);
468 return ret; 488 return ret;
@@ -536,7 +556,7 @@ i915_gem_object_free_page_list(struct drm_gem_object *obj)
536} 556}
537 557
538static void 558static void
539i915_gem_object_move_to_active(struct drm_gem_object *obj) 559i915_gem_object_move_to_active(struct drm_gem_object *obj, uint32_t seqno)
540{ 560{
541 struct drm_device *dev = obj->dev; 561 struct drm_device *dev = obj->dev;
542 drm_i915_private_t *dev_priv = dev->dev_private; 562 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -550,8 +570,20 @@ i915_gem_object_move_to_active(struct drm_gem_object *obj)
550 /* Move from whatever list we were on to the tail of execution. */ 570 /* Move from whatever list we were on to the tail of execution. */
551 list_move_tail(&obj_priv->list, 571 list_move_tail(&obj_priv->list,
552 &dev_priv->mm.active_list); 572 &dev_priv->mm.active_list);
573 obj_priv->last_rendering_seqno = seqno;
553} 574}
554 575
576static void
577i915_gem_object_move_to_flushing(struct drm_gem_object *obj)
578{
579 struct drm_device *dev = obj->dev;
580 drm_i915_private_t *dev_priv = dev->dev_private;
581 struct drm_i915_gem_object *obj_priv = obj->driver_private;
582
583 BUG_ON(!obj_priv->active);
584 list_move_tail(&obj_priv->list, &dev_priv->mm.flushing_list);
585 obj_priv->last_rendering_seqno = 0;
586}
555 587
556static void 588static void
557i915_gem_object_move_to_inactive(struct drm_gem_object *obj) 589i915_gem_object_move_to_inactive(struct drm_gem_object *obj)
@@ -566,6 +598,7 @@ i915_gem_object_move_to_inactive(struct drm_gem_object *obj)
566 else 598 else
567 list_move_tail(&obj_priv->list, &dev_priv->mm.inactive_list); 599 list_move_tail(&obj_priv->list, &dev_priv->mm.inactive_list);
568 600
601 obj_priv->last_rendering_seqno = 0;
569 if (obj_priv->active) { 602 if (obj_priv->active) {
570 obj_priv->active = 0; 603 obj_priv->active = 0;
571 drm_gem_object_unreference(obj); 604 drm_gem_object_unreference(obj);
@@ -614,10 +647,28 @@ i915_add_request(struct drm_device *dev, uint32_t flush_domains)
614 647
615 request->seqno = seqno; 648 request->seqno = seqno;
616 request->emitted_jiffies = jiffies; 649 request->emitted_jiffies = jiffies;
617 request->flush_domains = flush_domains;
618 was_empty = list_empty(&dev_priv->mm.request_list); 650 was_empty = list_empty(&dev_priv->mm.request_list);
619 list_add_tail(&request->list, &dev_priv->mm.request_list); 651 list_add_tail(&request->list, &dev_priv->mm.request_list);
620 652
653 /* Associate any objects on the flushing list matching the write
654 * domain we're flushing with our flush.
655 */
656 if (flush_domains != 0) {
657 struct drm_i915_gem_object *obj_priv, *next;
658
659 list_for_each_entry_safe(obj_priv, next,
660 &dev_priv->mm.flushing_list, list) {
661 struct drm_gem_object *obj = obj_priv->obj;
662
663 if ((obj->write_domain & flush_domains) ==
664 obj->write_domain) {
665 obj->write_domain = 0;
666 i915_gem_object_move_to_active(obj, seqno);
667 }
668 }
669
670 }
671
621 if (was_empty && !dev_priv->mm.suspended) 672 if (was_empty && !dev_priv->mm.suspended)
622 schedule_delayed_work(&dev_priv->mm.retire_work, HZ); 673 schedule_delayed_work(&dev_priv->mm.retire_work, HZ);
623 return seqno; 674 return seqno;
@@ -680,30 +731,10 @@ i915_gem_retire_request(struct drm_device *dev,
680 __func__, request->seqno, obj); 731 __func__, request->seqno, obj);
681#endif 732#endif
682 733
683 if (obj->write_domain != 0) { 734 if (obj->write_domain != 0)
684 list_move_tail(&obj_priv->list, 735 i915_gem_object_move_to_flushing(obj);
685 &dev_priv->mm.flushing_list); 736 else
686 } else {
687 i915_gem_object_move_to_inactive(obj); 737 i915_gem_object_move_to_inactive(obj);
688 }
689 }
690
691 if (request->flush_domains != 0) {
692 struct drm_i915_gem_object *obj_priv, *next;
693
694 /* Clear the write domain and activity from any buffers
695 * that are just waiting for a flush matching the one retired.
696 */
697 list_for_each_entry_safe(obj_priv, next,
698 &dev_priv->mm.flushing_list, list) {
699 struct drm_gem_object *obj = obj_priv->obj;
700
701 if (obj->write_domain & request->flush_domains) {
702 obj->write_domain = 0;
703 i915_gem_object_move_to_inactive(obj);
704 }
705 }
706
707 } 738 }
708} 739}
709 740
@@ -896,25 +927,10 @@ i915_gem_object_wait_rendering(struct drm_gem_object *obj)
896 struct drm_i915_gem_object *obj_priv = obj->driver_private; 927 struct drm_i915_gem_object *obj_priv = obj->driver_private;
897 int ret; 928 int ret;
898 929
899 /* If there are writes queued to the buffer, flush and 930 /* This function only exists to support waiting for existing rendering,
900 * create a new seqno to wait for. 931 * not for emitting required flushes.
901 */ 932 */
902 if (obj->write_domain & ~(I915_GEM_DOMAIN_CPU|I915_GEM_DOMAIN_GTT)) { 933 BUG_ON((obj->write_domain & I915_GEM_GPU_DOMAINS) != 0);
903 uint32_t write_domain = obj->write_domain;
904#if WATCH_BUF
905 DRM_INFO("%s: flushing object %p from write domain %08x\n",
906 __func__, obj, write_domain);
907#endif
908 i915_gem_flush(dev, 0, write_domain);
909
910 i915_gem_object_move_to_active(obj);
911 obj_priv->last_rendering_seqno = i915_add_request(dev,
912 write_domain);
913 BUG_ON(obj_priv->last_rendering_seqno == 0);
914#if WATCH_LRU
915 DRM_INFO("%s: flush moves to exec list %p\n", __func__, obj);
916#endif
917 }
918 934
919 /* If there is rendering queued on the buffer being evicted, wait for 935 /* If there is rendering queued on the buffer being evicted, wait for
920 * it. 936 * it.
@@ -954,24 +970,16 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
954 return -EINVAL; 970 return -EINVAL;
955 } 971 }
956 972
957 /* Wait for any rendering to complete
958 */
959 ret = i915_gem_object_wait_rendering(obj);
960 if (ret) {
961 DRM_ERROR("wait_rendering failed: %d\n", ret);
962 return ret;
963 }
964
965 /* Move the object to the CPU domain to ensure that 973 /* Move the object to the CPU domain to ensure that
966 * any possible CPU writes while it's not in the GTT 974 * any possible CPU writes while it's not in the GTT
967 * are flushed when we go to remap it. This will 975 * are flushed when we go to remap it. This will
968 * also ensure that all pending GPU writes are finished 976 * also ensure that all pending GPU writes are finished
969 * before we unbind. 977 * before we unbind.
970 */ 978 */
971 ret = i915_gem_object_set_domain(obj, I915_GEM_DOMAIN_CPU, 979 ret = i915_gem_object_set_to_cpu_domain(obj, 1);
972 I915_GEM_DOMAIN_CPU);
973 if (ret) { 980 if (ret) {
974 DRM_ERROR("set_domain failed: %d\n", ret); 981 if (ret != -ERESTARTSYS)
982 DRM_ERROR("set_domain failed: %d\n", ret);
975 return ret; 983 return ret;
976 } 984 }
977 985
@@ -1087,6 +1095,21 @@ i915_gem_evict_something(struct drm_device *dev)
1087} 1095}
1088 1096
1089static int 1097static int
1098i915_gem_evict_everything(struct drm_device *dev)
1099{
1100 int ret;
1101
1102 for (;;) {
1103 ret = i915_gem_evict_something(dev);
1104 if (ret != 0)
1105 break;
1106 }
1107 if (ret == -ENOMEM)
1108 return 0;
1109 return ret;
1110}
1111
1112static int
1090i915_gem_object_get_page_list(struct drm_gem_object *obj) 1113i915_gem_object_get_page_list(struct drm_gem_object *obj)
1091{ 1114{
1092 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1115 struct drm_i915_gem_object *obj_priv = obj->driver_private;
@@ -1172,7 +1195,8 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
1172 1195
1173 ret = i915_gem_evict_something(dev); 1196 ret = i915_gem_evict_something(dev);
1174 if (ret != 0) { 1197 if (ret != 0) {
1175 DRM_ERROR("Failed to evict a buffer %d\n", ret); 1198 if (ret != -ERESTARTSYS)
1199 DRM_ERROR("Failed to evict a buffer %d\n", ret);
1176 return ret; 1200 return ret;
1177 } 1201 }
1178 goto search_free; 1202 goto search_free;
@@ -1232,6 +1256,143 @@ i915_gem_clflush_object(struct drm_gem_object *obj)
1232 drm_clflush_pages(obj_priv->page_list, obj->size / PAGE_SIZE); 1256 drm_clflush_pages(obj_priv->page_list, obj->size / PAGE_SIZE);
1233} 1257}
1234 1258
1259/** Flushes any GPU write domain for the object if it's dirty. */
1260static void
1261i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj)
1262{
1263 struct drm_device *dev = obj->dev;
1264 uint32_t seqno;
1265
1266 if ((obj->write_domain & I915_GEM_GPU_DOMAINS) == 0)
1267 return;
1268
1269 /* Queue the GPU write cache flushing we need. */
1270 i915_gem_flush(dev, 0, obj->write_domain);
1271 seqno = i915_add_request(dev, obj->write_domain);
1272 obj->write_domain = 0;
1273 i915_gem_object_move_to_active(obj, seqno);
1274}
1275
1276/** Flushes the GTT write domain for the object if it's dirty. */
1277static void
1278i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj)
1279{
1280 if (obj->write_domain != I915_GEM_DOMAIN_GTT)
1281 return;
1282
1283 /* No actual flushing is required for the GTT write domain. Writes
1284 * to it immediately go to main memory as far as we know, so there's
1285 * no chipset flush. It also doesn't land in render cache.
1286 */
1287 obj->write_domain = 0;
1288}
1289
1290/** Flushes the CPU write domain for the object if it's dirty. */
1291static void
1292i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj)
1293{
1294 struct drm_device *dev = obj->dev;
1295
1296 if (obj->write_domain != I915_GEM_DOMAIN_CPU)
1297 return;
1298
1299 i915_gem_clflush_object(obj);
1300 drm_agp_chipset_flush(dev);
1301 obj->write_domain = 0;
1302}
1303
1304/**
1305 * Moves a single object to the GTT read, and possibly write domain.
1306 *
1307 * This function returns when the move is complete, including waiting on
1308 * flushes to occur.
1309 */
1310static int
1311i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int write)
1312{
1313 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1314 int ret;
1315
1316 /* Not valid to be called on unbound objects. */
1317 if (obj_priv->gtt_space == NULL)
1318 return -EINVAL;
1319
1320 i915_gem_object_flush_gpu_write_domain(obj);
1321 /* Wait on any GPU rendering and flushing to occur. */
1322 ret = i915_gem_object_wait_rendering(obj);
1323 if (ret != 0)
1324 return ret;
1325
1326 /* If we're writing through the GTT domain, then CPU and GPU caches
1327 * will need to be invalidated at next use.
1328 */
1329 if (write)
1330 obj->read_domains &= I915_GEM_DOMAIN_GTT;
1331
1332 i915_gem_object_flush_cpu_write_domain(obj);
1333
1334 /* It should now be out of any other write domains, and we can update
1335 * the domain values for our changes.
1336 */
1337 BUG_ON((obj->write_domain & ~I915_GEM_DOMAIN_GTT) != 0);
1338 obj->read_domains |= I915_GEM_DOMAIN_GTT;
1339 if (write) {
1340 obj->write_domain = I915_GEM_DOMAIN_GTT;
1341 obj_priv->dirty = 1;
1342 }
1343
1344 return 0;
1345}
1346
1347/**
1348 * Moves a single object to the CPU read, and possibly write domain.
1349 *
1350 * This function returns when the move is complete, including waiting on
1351 * flushes to occur.
1352 */
1353static int
1354i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write)
1355{
1356 struct drm_device *dev = obj->dev;
1357 int ret;
1358
1359 i915_gem_object_flush_gpu_write_domain(obj);
1360 /* Wait on any GPU rendering and flushing to occur. */
1361 ret = i915_gem_object_wait_rendering(obj);
1362 if (ret != 0)
1363 return ret;
1364
1365 i915_gem_object_flush_gtt_write_domain(obj);
1366
1367 /* If we have a partially-valid cache of the object in the CPU,
1368 * finish invalidating it and free the per-page flags.
1369 */
1370 i915_gem_object_set_to_full_cpu_read_domain(obj);
1371
1372 /* Flush the CPU cache if it's still invalid. */
1373 if ((obj->read_domains & I915_GEM_DOMAIN_CPU) == 0) {
1374 i915_gem_clflush_object(obj);
1375 drm_agp_chipset_flush(dev);
1376
1377 obj->read_domains |= I915_GEM_DOMAIN_CPU;
1378 }
1379
1380 /* It should now be out of any other write domains, and we can update
1381 * the domain values for our changes.
1382 */
1383 BUG_ON((obj->write_domain & ~I915_GEM_DOMAIN_CPU) != 0);
1384
1385 /* If we're writing through the CPU, then the GPU read domains will
1386 * need to be invalidated at next use.
1387 */
1388 if (write) {
1389 obj->read_domains &= I915_GEM_DOMAIN_CPU;
1390 obj->write_domain = I915_GEM_DOMAIN_CPU;
1391 }
1392
1393 return 0;
1394}
1395
1235/* 1396/*
1236 * Set the next domain for the specified object. This 1397 * Set the next domain for the specified object. This
1237 * may not actually perform the necessary flushing/invaliding though, 1398 * may not actually perform the necessary flushing/invaliding though,
@@ -1343,16 +1504,18 @@ i915_gem_clflush_object(struct drm_gem_object *obj)
1343 * MI_FLUSH 1504 * MI_FLUSH
1344 * drm_agp_chipset_flush 1505 * drm_agp_chipset_flush
1345 */ 1506 */
1346static int 1507static void
1347i915_gem_object_set_domain(struct drm_gem_object *obj, 1508i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj,
1348 uint32_t read_domains, 1509 uint32_t read_domains,
1349 uint32_t write_domain) 1510 uint32_t write_domain)
1350{ 1511{
1351 struct drm_device *dev = obj->dev; 1512 struct drm_device *dev = obj->dev;
1352 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1513 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1353 uint32_t invalidate_domains = 0; 1514 uint32_t invalidate_domains = 0;
1354 uint32_t flush_domains = 0; 1515 uint32_t flush_domains = 0;
1355 int ret; 1516
1517 BUG_ON(read_domains & I915_GEM_DOMAIN_CPU);
1518 BUG_ON(write_domain == I915_GEM_DOMAIN_CPU);
1356 1519
1357#if WATCH_BUF 1520#if WATCH_BUF
1358 DRM_INFO("%s: object %p read %08x -> %08x write %08x -> %08x\n", 1521 DRM_INFO("%s: object %p read %08x -> %08x write %08x -> %08x\n",
@@ -1389,34 +1552,11 @@ i915_gem_object_set_domain(struct drm_gem_object *obj,
1389 DRM_INFO("%s: CPU domain flush %08x invalidate %08x\n", 1552 DRM_INFO("%s: CPU domain flush %08x invalidate %08x\n",
1390 __func__, flush_domains, invalidate_domains); 1553 __func__, flush_domains, invalidate_domains);
1391#endif 1554#endif
1392 /*
1393 * If we're invaliding the CPU cache and flushing a GPU cache,
1394 * then pause for rendering so that the GPU caches will be
1395 * flushed before the cpu cache is invalidated
1396 */
1397 if ((invalidate_domains & I915_GEM_DOMAIN_CPU) &&
1398 (flush_domains & ~(I915_GEM_DOMAIN_CPU |
1399 I915_GEM_DOMAIN_GTT))) {
1400 ret = i915_gem_object_wait_rendering(obj);
1401 if (ret)
1402 return ret;
1403 }
1404 i915_gem_clflush_object(obj); 1555 i915_gem_clflush_object(obj);
1405 } 1556 }
1406 1557
1407 if ((write_domain | flush_domains) != 0) 1558 if ((write_domain | flush_domains) != 0)
1408 obj->write_domain = write_domain; 1559 obj->write_domain = write_domain;
1409
1410 /* If we're invalidating the CPU domain, clear the per-page CPU
1411 * domain list as well.
1412 */
1413 if (obj_priv->page_cpu_valid != NULL &&
1414 (write_domain != 0 ||
1415 read_domains & I915_GEM_DOMAIN_CPU)) {
1416 drm_free(obj_priv->page_cpu_valid, obj->size / PAGE_SIZE,
1417 DRM_MEM_DRIVER);
1418 obj_priv->page_cpu_valid = NULL;
1419 }
1420 obj->read_domains = read_domains; 1560 obj->read_domains = read_domains;
1421 1561
1422 dev->invalidate_domains |= invalidate_domains; 1562 dev->invalidate_domains |= invalidate_domains;
@@ -1427,47 +1567,94 @@ i915_gem_object_set_domain(struct drm_gem_object *obj,
1427 obj->read_domains, obj->write_domain, 1567 obj->read_domains, obj->write_domain,
1428 dev->invalidate_domains, dev->flush_domains); 1568 dev->invalidate_domains, dev->flush_domains);
1429#endif 1569#endif
1430 return 0;
1431} 1570}
1432 1571
1433/** 1572/**
1434 * Set the read/write domain on a range of the object. 1573 * Moves the object from a partially CPU read to a full one.
1435 * 1574 *
1436 * Currently only implemented for CPU reads, otherwise drops to normal 1575 * Note that this only resolves i915_gem_object_set_cpu_read_domain_range(),
1437 * i915_gem_object_set_domain(). 1576 * and doesn't handle transitioning from !(read_domains & I915_GEM_DOMAIN_CPU).
1438 */ 1577 */
1439static int 1578static void
1440i915_gem_object_set_domain_range(struct drm_gem_object *obj, 1579i915_gem_object_set_to_full_cpu_read_domain(struct drm_gem_object *obj)
1441 uint64_t offset,
1442 uint64_t size,
1443 uint32_t read_domains,
1444 uint32_t write_domain)
1445{ 1580{
1581 struct drm_device *dev = obj->dev;
1446 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1582 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1447 int ret, i;
1448 1583
1449 if (obj->read_domains & I915_GEM_DOMAIN_CPU) 1584 if (!obj_priv->page_cpu_valid)
1450 return 0; 1585 return;
1451 1586
1452 if (read_domains != I915_GEM_DOMAIN_CPU || 1587 /* If we're partially in the CPU read domain, finish moving it in.
1453 write_domain != 0) 1588 */
1454 return i915_gem_object_set_domain(obj, 1589 if (obj->read_domains & I915_GEM_DOMAIN_CPU) {
1455 read_domains, write_domain); 1590 int i;
1456 1591
1457 /* Wait on any GPU rendering to the object to be flushed. */ 1592 for (i = 0; i <= (obj->size - 1) / PAGE_SIZE; i++) {
1593 if (obj_priv->page_cpu_valid[i])
1594 continue;
1595 drm_clflush_pages(obj_priv->page_list + i, 1);
1596 }
1597 drm_agp_chipset_flush(dev);
1598 }
1599
1600 /* Free the page_cpu_valid mappings which are now stale, whether
1601 * or not we've got I915_GEM_DOMAIN_CPU.
1602 */
1603 drm_free(obj_priv->page_cpu_valid, obj->size / PAGE_SIZE,
1604 DRM_MEM_DRIVER);
1605 obj_priv->page_cpu_valid = NULL;
1606}
1607
1608/**
1609 * Set the CPU read domain on a range of the object.
1610 *
1611 * The object ends up with I915_GEM_DOMAIN_CPU in its read flags although it's
1612 * not entirely valid. The page_cpu_valid member of the object flags which
1613 * pages have been flushed, and will be respected by
1614 * i915_gem_object_set_to_cpu_domain() if it's called on to get a valid mapping
1615 * of the whole object.
1616 *
1617 * This function returns when the move is complete, including waiting on
1618 * flushes to occur.
1619 */
1620static int
1621i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
1622 uint64_t offset, uint64_t size)
1623{
1624 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1625 int i, ret;
1626
1627 if (offset == 0 && size == obj->size)
1628 return i915_gem_object_set_to_cpu_domain(obj, 0);
1629
1630 i915_gem_object_flush_gpu_write_domain(obj);
1631 /* Wait on any GPU rendering and flushing to occur. */
1458 ret = i915_gem_object_wait_rendering(obj); 1632 ret = i915_gem_object_wait_rendering(obj);
1459 if (ret) 1633 if (ret != 0)
1460 return ret; 1634 return ret;
1635 i915_gem_object_flush_gtt_write_domain(obj);
1461 1636
1637 /* If we're already fully in the CPU read domain, we're done. */
1638 if (obj_priv->page_cpu_valid == NULL &&
1639 (obj->read_domains & I915_GEM_DOMAIN_CPU) != 0)
1640 return 0;
1641
1642 /* Otherwise, create/clear the per-page CPU read domain flag if we're
1643 * newly adding I915_GEM_DOMAIN_CPU
1644 */
1462 if (obj_priv->page_cpu_valid == NULL) { 1645 if (obj_priv->page_cpu_valid == NULL) {
1463 obj_priv->page_cpu_valid = drm_calloc(1, obj->size / PAGE_SIZE, 1646 obj_priv->page_cpu_valid = drm_calloc(1, obj->size / PAGE_SIZE,
1464 DRM_MEM_DRIVER); 1647 DRM_MEM_DRIVER);
1465 } 1648 if (obj_priv->page_cpu_valid == NULL)
1649 return -ENOMEM;
1650 } else if ((obj->read_domains & I915_GEM_DOMAIN_CPU) == 0)
1651 memset(obj_priv->page_cpu_valid, 0, obj->size / PAGE_SIZE);
1466 1652
1467 /* Flush the cache on any pages that are still invalid from the CPU's 1653 /* Flush the cache on any pages that are still invalid from the CPU's
1468 * perspective. 1654 * perspective.
1469 */ 1655 */
1470 for (i = offset / PAGE_SIZE; i <= (offset + size - 1) / PAGE_SIZE; i++) { 1656 for (i = offset / PAGE_SIZE; i <= (offset + size - 1) / PAGE_SIZE;
1657 i++) {
1471 if (obj_priv->page_cpu_valid[i]) 1658 if (obj_priv->page_cpu_valid[i])
1472 continue; 1659 continue;
1473 1660
@@ -1476,39 +1663,14 @@ i915_gem_object_set_domain_range(struct drm_gem_object *obj,
1476 obj_priv->page_cpu_valid[i] = 1; 1663 obj_priv->page_cpu_valid[i] = 1;
1477 } 1664 }
1478 1665
1479 return 0; 1666 /* It should now be out of any other write domains, and we can update
1480} 1667 * the domain values for our changes.
1481
1482/**
1483 * Once all of the objects have been set in the proper domain,
1484 * perform the necessary flush and invalidate operations.
1485 *
1486 * Returns the write domains flushed, for use in flush tracking.
1487 */
1488static uint32_t
1489i915_gem_dev_set_domain(struct drm_device *dev)
1490{
1491 uint32_t flush_domains = dev->flush_domains;
1492
1493 /*
1494 * Now that all the buffers are synced to the proper domains,
1495 * flush and invalidate the collected domains
1496 */ 1668 */
1497 if (dev->invalidate_domains | dev->flush_domains) { 1669 BUG_ON((obj->write_domain & ~I915_GEM_DOMAIN_CPU) != 0);
1498#if WATCH_EXEC
1499 DRM_INFO("%s: invalidate_domains %08x flush_domains %08x\n",
1500 __func__,
1501 dev->invalidate_domains,
1502 dev->flush_domains);
1503#endif
1504 i915_gem_flush(dev,
1505 dev->invalidate_domains,
1506 dev->flush_domains);
1507 dev->invalidate_domains = 0;
1508 dev->flush_domains = 0;
1509 }
1510 1670
1511 return flush_domains; 1671 obj->read_domains |= I915_GEM_DOMAIN_CPU;
1672
1673 return 0;
1512} 1674}
1513 1675
1514/** 1676/**
@@ -1589,6 +1751,18 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
1589 return -EINVAL; 1751 return -EINVAL;
1590 } 1752 }
1591 1753
1754 if (reloc.write_domain & I915_GEM_DOMAIN_CPU ||
1755 reloc.read_domains & I915_GEM_DOMAIN_CPU) {
1756 DRM_ERROR("reloc with read/write CPU domains: "
1757 "obj %p target %d offset %d "
1758 "read %08x write %08x",
1759 obj, reloc.target_handle,
1760 (int) reloc.offset,
1761 reloc.read_domains,
1762 reloc.write_domain);
1763 return -EINVAL;
1764 }
1765
1592 if (reloc.write_domain && target_obj->pending_write_domain && 1766 if (reloc.write_domain && target_obj->pending_write_domain &&
1593 reloc.write_domain != target_obj->pending_write_domain) { 1767 reloc.write_domain != target_obj->pending_write_domain) {
1594 DRM_ERROR("Write domain conflict: " 1768 DRM_ERROR("Write domain conflict: "
@@ -1629,19 +1803,11 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
1629 continue; 1803 continue;
1630 } 1804 }
1631 1805
1632 /* Now that we're going to actually write some data in, 1806 ret = i915_gem_object_set_to_gtt_domain(obj, 1);
1633 * make sure that any rendering using this buffer's contents 1807 if (ret != 0) {
1634 * is completed. 1808 drm_gem_object_unreference(target_obj);
1635 */ 1809 i915_gem_object_unpin(obj);
1636 i915_gem_object_wait_rendering(obj); 1810 return -EINVAL;
1637
1638 /* As we're writing through the gtt, flush
1639 * any CPU writes before we write the relocations
1640 */
1641 if (obj->write_domain & I915_GEM_DOMAIN_CPU) {
1642 i915_gem_clflush_object(obj);
1643 drm_agp_chipset_flush(dev);
1644 obj->write_domain = 0;
1645 } 1811 }
1646 1812
1647 /* Map the page containing the relocation we're going to 1813 /* Map the page containing the relocation we're going to
@@ -1783,6 +1949,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
1783 int ret, i, pinned = 0; 1949 int ret, i, pinned = 0;
1784 uint64_t exec_offset; 1950 uint64_t exec_offset;
1785 uint32_t seqno, flush_domains; 1951 uint32_t seqno, flush_domains;
1952 int pin_tries;
1786 1953
1787#if WATCH_EXEC 1954#if WATCH_EXEC
1788 DRM_INFO("buffers_ptr %d buffer_count %d len %08x\n", 1955 DRM_INFO("buffers_ptr %d buffer_count %d len %08x\n",
@@ -1831,14 +1998,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
1831 return -EBUSY; 1998 return -EBUSY;
1832 } 1999 }
1833 2000
1834 /* Zero the gloabl flush/invalidate flags. These 2001 /* Look up object handles */
1835 * will be modified as each object is bound to the
1836 * gtt
1837 */
1838 dev->invalidate_domains = 0;
1839 dev->flush_domains = 0;
1840
1841 /* Look up object handles and perform the relocations */
1842 for (i = 0; i < args->buffer_count; i++) { 2002 for (i = 0; i < args->buffer_count; i++) {
1843 object_list[i] = drm_gem_object_lookup(dev, file_priv, 2003 object_list[i] = drm_gem_object_lookup(dev, file_priv,
1844 exec_list[i].handle); 2004 exec_list[i].handle);
@@ -1848,17 +2008,39 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
1848 ret = -EBADF; 2008 ret = -EBADF;
1849 goto err; 2009 goto err;
1850 } 2010 }
2011 }
1851 2012
1852 object_list[i]->pending_read_domains = 0; 2013 /* Pin and relocate */
1853 object_list[i]->pending_write_domain = 0; 2014 for (pin_tries = 0; ; pin_tries++) {
1854 ret = i915_gem_object_pin_and_relocate(object_list[i], 2015 ret = 0;
1855 file_priv, 2016 for (i = 0; i < args->buffer_count; i++) {
1856 &exec_list[i]); 2017 object_list[i]->pending_read_domains = 0;
1857 if (ret) { 2018 object_list[i]->pending_write_domain = 0;
1858 DRM_ERROR("object bind and relocate failed %d\n", ret); 2019 ret = i915_gem_object_pin_and_relocate(object_list[i],
2020 file_priv,
2021 &exec_list[i]);
2022 if (ret)
2023 break;
2024 pinned = i + 1;
2025 }
2026 /* success */
2027 if (ret == 0)
2028 break;
2029
2030 /* error other than GTT full, or we've already tried again */
2031 if (ret != -ENOMEM || pin_tries >= 1) {
2032 DRM_ERROR("Failed to pin buffers %d\n", ret);
1859 goto err; 2033 goto err;
1860 } 2034 }
1861 pinned = i + 1; 2035
2036 /* unpin all of our buffers */
2037 for (i = 0; i < pinned; i++)
2038 i915_gem_object_unpin(object_list[i]);
2039
2040 /* evict everyone we can from the aperture */
2041 ret = i915_gem_evict_everything(dev);
2042 if (ret)
2043 goto err;
1862 } 2044 }
1863 2045
1864 /* Set the pending read domains for the batch buffer to COMMAND */ 2046 /* Set the pending read domains for the batch buffer to COMMAND */
@@ -1868,32 +2050,37 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
1868 2050
1869 i915_verify_inactive(dev, __FILE__, __LINE__); 2051 i915_verify_inactive(dev, __FILE__, __LINE__);
1870 2052
2053 /* Zero the global flush/invalidate flags. These
2054 * will be modified as new domains are computed
2055 * for each object
2056 */
2057 dev->invalidate_domains = 0;
2058 dev->flush_domains = 0;
2059
1871 for (i = 0; i < args->buffer_count; i++) { 2060 for (i = 0; i < args->buffer_count; i++) {
1872 struct drm_gem_object *obj = object_list[i]; 2061 struct drm_gem_object *obj = object_list[i];
1873 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1874 2062
1875 if (obj_priv->gtt_space == NULL) { 2063 /* Compute new gpu domains and update invalidate/flush */
1876 /* We evicted the buffer in the process of validating 2064 i915_gem_object_set_to_gpu_domain(obj,
1877 * our set of buffers in. We could try to recover by 2065 obj->pending_read_domains,
1878 * kicking them everything out and trying again from 2066 obj->pending_write_domain);
1879 * the start.
1880 */
1881 ret = -ENOMEM;
1882 goto err;
1883 }
1884
1885 /* make sure all previous memory operations have passed */
1886 ret = i915_gem_object_set_domain(obj,
1887 obj->pending_read_domains,
1888 obj->pending_write_domain);
1889 if (ret)
1890 goto err;
1891 } 2067 }
1892 2068
1893 i915_verify_inactive(dev, __FILE__, __LINE__); 2069 i915_verify_inactive(dev, __FILE__, __LINE__);
1894 2070
1895 /* Flush/invalidate caches and chipset buffer */ 2071 if (dev->invalidate_domains | dev->flush_domains) {
1896 flush_domains = i915_gem_dev_set_domain(dev); 2072#if WATCH_EXEC
2073 DRM_INFO("%s: invalidate_domains %08x flush_domains %08x\n",
2074 __func__,
2075 dev->invalidate_domains,
2076 dev->flush_domains);
2077#endif
2078 i915_gem_flush(dev,
2079 dev->invalidate_domains,
2080 dev->flush_domains);
2081 if (dev->flush_domains)
2082 (void)i915_add_request(dev, dev->flush_domains);
2083 }
1897 2084
1898 i915_verify_inactive(dev, __FILE__, __LINE__); 2085 i915_verify_inactive(dev, __FILE__, __LINE__);
1899 2086
@@ -1913,8 +2100,6 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
1913 ~0); 2100 ~0);
1914#endif 2101#endif
1915 2102
1916 (void)i915_add_request(dev, flush_domains);
1917
1918 /* Exec the batchbuffer */ 2103 /* Exec the batchbuffer */
1919 ret = i915_dispatch_gem_execbuffer(dev, args, exec_offset); 2104 ret = i915_dispatch_gem_execbuffer(dev, args, exec_offset);
1920 if (ret) { 2105 if (ret) {
@@ -1942,10 +2127,8 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
1942 i915_file_priv->mm.last_gem_seqno = seqno; 2127 i915_file_priv->mm.last_gem_seqno = seqno;
1943 for (i = 0; i < args->buffer_count; i++) { 2128 for (i = 0; i < args->buffer_count; i++) {
1944 struct drm_gem_object *obj = object_list[i]; 2129 struct drm_gem_object *obj = object_list[i];
1945 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1946 2130
1947 i915_gem_object_move_to_active(obj); 2131 i915_gem_object_move_to_active(obj, seqno);
1948 obj_priv->last_rendering_seqno = seqno;
1949#if WATCH_LRU 2132#if WATCH_LRU
1950 DRM_INFO("%s: move to exec list %p\n", __func__, obj); 2133 DRM_INFO("%s: move to exec list %p\n", __func__, obj);
1951#endif 2134#endif
@@ -2076,11 +2259,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
2076 /* XXX - flush the CPU caches for pinned objects 2259 /* XXX - flush the CPU caches for pinned objects
2077 * as the X server doesn't manage domains yet 2260 * as the X server doesn't manage domains yet
2078 */ 2261 */
2079 if (obj->write_domain & I915_GEM_DOMAIN_CPU) { 2262 i915_gem_object_flush_cpu_write_domain(obj);
2080 i915_gem_clflush_object(obj);
2081 drm_agp_chipset_flush(dev);
2082 obj->write_domain = 0;
2083 }
2084 args->offset = obj_priv->gtt_offset; 2263 args->offset = obj_priv->gtt_offset;
2085 drm_gem_object_unreference(obj); 2264 drm_gem_object_unreference(obj);
2086 mutex_unlock(&dev->struct_mutex); 2265 mutex_unlock(&dev->struct_mutex);
@@ -2130,7 +2309,14 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
2130 } 2309 }
2131 2310
2132 obj_priv = obj->driver_private; 2311 obj_priv = obj->driver_private;
2133 args->busy = obj_priv->active; 2312 /* Don't count being on the flushing list against the object being
2313 * done. Otherwise, a buffer left on the flushing list but not getting
2314 * flushed (because nobody's flushing that domain) won't ever return
2315 * unbusy and get reused by libdrm's bo cache. The other expected
2316 * consumer of this interface, OpenGL's occlusion queries, also specs
2317 * that the objects get unbusy "eventually" without any interference.
2318 */
2319 args->busy = obj_priv->active && obj_priv->last_rendering_seqno != 0;
2134 2320
2135 drm_gem_object_unreference(obj); 2321 drm_gem_object_unreference(obj);
2136 mutex_unlock(&dev->struct_mutex); 2322 mutex_unlock(&dev->struct_mutex);
@@ -2182,29 +2368,6 @@ void i915_gem_free_object(struct drm_gem_object *obj)
2182 drm_free(obj->driver_private, 1, DRM_MEM_DRIVER); 2368 drm_free(obj->driver_private, 1, DRM_MEM_DRIVER);
2183} 2369}
2184 2370
2185static int
2186i915_gem_set_domain(struct drm_gem_object *obj,
2187 struct drm_file *file_priv,
2188 uint32_t read_domains,
2189 uint32_t write_domain)
2190{
2191 struct drm_device *dev = obj->dev;
2192 int ret;
2193 uint32_t flush_domains;
2194
2195 BUG_ON(!mutex_is_locked(&dev->struct_mutex));
2196
2197 ret = i915_gem_object_set_domain(obj, read_domains, write_domain);
2198 if (ret)
2199 return ret;
2200 flush_domains = i915_gem_dev_set_domain(obj->dev);
2201
2202 if (flush_domains & ~(I915_GEM_DOMAIN_CPU|I915_GEM_DOMAIN_GTT))
2203 (void) i915_add_request(dev, flush_domains);
2204
2205 return 0;
2206}
2207
2208/** Unbinds all objects that are on the given buffer list. */ 2371/** Unbinds all objects that are on the given buffer list. */
2209static int 2372static int
2210i915_gem_evict_from_list(struct drm_device *dev, struct list_head *head) 2373i915_gem_evict_from_list(struct drm_device *dev, struct list_head *head)
@@ -2299,29 +2462,52 @@ i915_gem_idle(struct drm_device *dev)
2299 2462
2300 i915_gem_retire_requests(dev); 2463 i915_gem_retire_requests(dev);
2301 2464
2302 /* Active and flushing should now be empty as we've 2465 if (!dev_priv->mm.wedged) {
2303 * waited for a sequence higher than any pending execbuffer 2466 /* Active and flushing should now be empty as we've
2304 */ 2467 * waited for a sequence higher than any pending execbuffer
2305 BUG_ON(!list_empty(&dev_priv->mm.active_list)); 2468 */
2306 BUG_ON(!list_empty(&dev_priv->mm.flushing_list)); 2469 WARN_ON(!list_empty(&dev_priv->mm.active_list));
2470 WARN_ON(!list_empty(&dev_priv->mm.flushing_list));
2471 /* Request should now be empty as we've also waited
2472 * for the last request in the list
2473 */
2474 WARN_ON(!list_empty(&dev_priv->mm.request_list));
2475 }
2307 2476
2308 /* Request should now be empty as we've also waited 2477 /* Empty the active and flushing lists to inactive. If there's
2309 * for the last request in the list 2478 * anything left at this point, it means that we're wedged and
2479 * nothing good's going to happen by leaving them there. So strip
2480 * the GPU domains and just stuff them onto inactive.
2310 */ 2481 */
2311 BUG_ON(!list_empty(&dev_priv->mm.request_list)); 2482 while (!list_empty(&dev_priv->mm.active_list)) {
2483 struct drm_i915_gem_object *obj_priv;
2484
2485 obj_priv = list_first_entry(&dev_priv->mm.active_list,
2486 struct drm_i915_gem_object,
2487 list);
2488 obj_priv->obj->write_domain &= ~I915_GEM_GPU_DOMAINS;
2489 i915_gem_object_move_to_inactive(obj_priv->obj);
2490 }
2491
2492 while (!list_empty(&dev_priv->mm.flushing_list)) {
2493 struct drm_i915_gem_object *obj_priv;
2312 2494
2313 /* Move all buffers out of the GTT. */ 2495 obj_priv = list_first_entry(&dev_priv->mm.flushing_list,
2496 struct drm_i915_gem_object,
2497 list);
2498 obj_priv->obj->write_domain &= ~I915_GEM_GPU_DOMAINS;
2499 i915_gem_object_move_to_inactive(obj_priv->obj);
2500 }
2501
2502
2503 /* Move all inactive buffers out of the GTT. */
2314 ret = i915_gem_evict_from_list(dev, &dev_priv->mm.inactive_list); 2504 ret = i915_gem_evict_from_list(dev, &dev_priv->mm.inactive_list);
2505 WARN_ON(!list_empty(&dev_priv->mm.inactive_list));
2315 if (ret) { 2506 if (ret) {
2316 mutex_unlock(&dev->struct_mutex); 2507 mutex_unlock(&dev->struct_mutex);
2317 return ret; 2508 return ret;
2318 } 2509 }
2319 2510
2320 BUG_ON(!list_empty(&dev_priv->mm.active_list));
2321 BUG_ON(!list_empty(&dev_priv->mm.flushing_list));
2322 BUG_ON(!list_empty(&dev_priv->mm.inactive_list));
2323 BUG_ON(!list_empty(&dev_priv->mm.request_list));
2324
2325 i915_gem_cleanup_ringbuffer(dev); 2511 i915_gem_cleanup_ringbuffer(dev);
2326 mutex_unlock(&dev->struct_mutex); 2512 mutex_unlock(&dev->struct_mutex);
2327 2513
diff --git a/drivers/gpu/drm/i915/i915_gem_proc.c b/drivers/gpu/drm/i915/i915_gem_proc.c
index 93de15b4c9a7..e8d5abe1250e 100644
--- a/drivers/gpu/drm/i915/i915_gem_proc.c
+++ b/drivers/gpu/drm/i915/i915_gem_proc.c
@@ -166,10 +166,9 @@ static int i915_gem_request_info(char *buf, char **start, off_t offset,
166 list_for_each_entry(gem_request, &dev_priv->mm.request_list, 166 list_for_each_entry(gem_request, &dev_priv->mm.request_list,
167 list) 167 list)
168 { 168 {
169 DRM_PROC_PRINT(" %d @ %d %08x\n", 169 DRM_PROC_PRINT(" %d @ %d\n",
170 gem_request->seqno, 170 gem_request->seqno,
171 (int) (jiffies - gem_request->emitted_jiffies), 171 (int) (jiffies - gem_request->emitted_jiffies));
172 gem_request->flush_domains);
173 } 172 }
174 if (len > request + offset) 173 if (len > request + offset)
175 return request; 174 return request;
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index e8b85ac4ca04..a8cb69469c64 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -119,9 +119,10 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev)
119 dcc & DCC_CHANNEL_XOR_DISABLE) { 119 dcc & DCC_CHANNEL_XOR_DISABLE) {
120 swizzle_x = I915_BIT_6_SWIZZLE_9_10; 120 swizzle_x = I915_BIT_6_SWIZZLE_9_10;
121 swizzle_y = I915_BIT_6_SWIZZLE_9; 121 swizzle_y = I915_BIT_6_SWIZZLE_9;
122 } else if (IS_I965GM(dev) || IS_GM45(dev)) { 122 } else if ((IS_I965GM(dev) || IS_GM45(dev)) &&
123 /* GM965 only does bit 11-based channel 123 (dcc & DCC_CHANNEL_XOR_BIT_17) == 0) {
124 * randomization 124 /* GM965/GM45 does either bit 11 or bit 17
125 * swizzling.
125 */ 126 */
126 swizzle_x = I915_BIT_6_SWIZZLE_9_10_11; 127 swizzle_x = I915_BIT_6_SWIZZLE_9_10_11;
127 swizzle_y = I915_BIT_6_SWIZZLE_9_11; 128 swizzle_y = I915_BIT_6_SWIZZLE_9_11;
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 82752d6177a4..69b9a42da95e 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -33,11 +33,23 @@
33 33
34#define MAX_NOPID ((u32)~0) 34#define MAX_NOPID ((u32)~0)
35 35
36/** These are the interrupts used by the driver */ 36/**
37#define I915_INTERRUPT_ENABLE_MASK (I915_USER_INTERRUPT | \ 37 * Interrupts that are always left unmasked.
38 I915_ASLE_INTERRUPT | \ 38 *
39 I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \ 39 * Since pipe events are edge-triggered from the PIPESTAT register to IIR,
40 I915_DISPLAY_PIPE_B_EVENT_INTERRUPT) 40 * we leave them always unmasked in IMR and then control enabling them through
41 * PIPESTAT alone.
42 */
43#define I915_INTERRUPT_ENABLE_FIX (I915_ASLE_INTERRUPT | \
44 I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \
45 I915_DISPLAY_PIPE_B_EVENT_INTERRUPT)
46
47/** Interrupts that we mask and unmask at runtime. */
48#define I915_INTERRUPT_ENABLE_VAR (I915_USER_INTERRUPT)
49
50/** These are all of the interrupts used by the driver */
51#define I915_INTERRUPT_ENABLE_MASK (I915_INTERRUPT_ENABLE_FIX | \
52 I915_INTERRUPT_ENABLE_VAR)
41 53
42void 54void
43i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask) 55i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask)
@@ -59,6 +71,41 @@ i915_disable_irq(drm_i915_private_t *dev_priv, u32 mask)
59 } 71 }
60} 72}
61 73
74static inline u32
75i915_pipestat(int pipe)
76{
77 if (pipe == 0)
78 return PIPEASTAT;
79 if (pipe == 1)
80 return PIPEBSTAT;
81 BUG();
82}
83
84void
85i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
86{
87 if ((dev_priv->pipestat[pipe] & mask) != mask) {
88 u32 reg = i915_pipestat(pipe);
89
90 dev_priv->pipestat[pipe] |= mask;
91 /* Enable the interrupt, clear any pending status */
92 I915_WRITE(reg, dev_priv->pipestat[pipe] | (mask >> 16));
93 (void) I915_READ(reg);
94 }
95}
96
97void
98i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
99{
100 if ((dev_priv->pipestat[pipe] & mask) != 0) {
101 u32 reg = i915_pipestat(pipe);
102
103 dev_priv->pipestat[pipe] &= ~mask;
104 I915_WRITE(reg, dev_priv->pipestat[pipe]);
105 (void) I915_READ(reg);
106 }
107}
108
62/** 109/**
63 * i915_pipe_enabled - check if a pipe is enabled 110 * i915_pipe_enabled - check if a pipe is enabled
64 * @dev: DRM device 111 * @dev: DRM device
@@ -121,80 +168,102 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
121{ 168{
122 struct drm_device *dev = (struct drm_device *) arg; 169 struct drm_device *dev = (struct drm_device *) arg;
123 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 170 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
124 u32 iir; 171 u32 iir, new_iir;
125 u32 pipea_stats, pipeb_stats; 172 u32 pipea_stats, pipeb_stats;
173 u32 vblank_status;
174 u32 vblank_enable;
126 int vblank = 0; 175 int vblank = 0;
176 unsigned long irqflags;
177 int irq_received;
178 int ret = IRQ_NONE;
127 179
128 atomic_inc(&dev_priv->irq_received); 180 atomic_inc(&dev_priv->irq_received);
129 181
130 if (dev->pdev->msi_enabled)
131 I915_WRITE(IMR, ~0);
132 iir = I915_READ(IIR); 182 iir = I915_READ(IIR);
133 183
134 if (iir == 0) { 184 if (IS_I965G(dev)) {
135 if (dev->pdev->msi_enabled) { 185 vblank_status = I915_START_VBLANK_INTERRUPT_STATUS;
136 I915_WRITE(IMR, dev_priv->irq_mask_reg); 186 vblank_enable = PIPE_START_VBLANK_INTERRUPT_ENABLE;
137 (void) I915_READ(IMR); 187 } else {
138 } 188 vblank_status = I915_VBLANK_INTERRUPT_STATUS;
139 return IRQ_NONE; 189 vblank_enable = I915_VBLANK_INTERRUPT_ENABLE;
140 } 190 }
141 191
142 /* 192 for (;;) {
143 * Clear the PIPE(A|B)STAT regs before the IIR otherwise 193 irq_received = iir != 0;
144 * we may get extra interrupts. 194
145 */ 195 /* Can't rely on pipestat interrupt bit in iir as it might
146 if (iir & I915_DISPLAY_PIPE_A_EVENT_INTERRUPT) { 196 * have been cleared after the pipestat interrupt was received.
197 * It doesn't set the bit in iir again, but it still produces
198 * interrupts (for non-MSI).
199 */
200 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
147 pipea_stats = I915_READ(PIPEASTAT); 201 pipea_stats = I915_READ(PIPEASTAT);
148 if (!(dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_A)) 202 pipeb_stats = I915_READ(PIPEBSTAT);
149 pipea_stats &= ~(PIPE_START_VBLANK_INTERRUPT_ENABLE | 203 /*
150 PIPE_VBLANK_INTERRUPT_ENABLE); 204 * Clear the PIPE(A|B)STAT regs before the IIR
151 else if (pipea_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS| 205 */
152 PIPE_VBLANK_INTERRUPT_STATUS)) { 206 if (pipea_stats & 0x8000ffff) {
207 I915_WRITE(PIPEASTAT, pipea_stats);
208 irq_received = 1;
209 }
210
211 if (pipeb_stats & 0x8000ffff) {
212 I915_WRITE(PIPEBSTAT, pipeb_stats);
213 irq_received = 1;
214 }
215 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
216
217 if (!irq_received)
218 break;
219
220 ret = IRQ_HANDLED;
221
222 I915_WRITE(IIR, iir);
223 new_iir = I915_READ(IIR); /* Flush posted writes */
224
225 if (dev_priv->sarea_priv)
226 dev_priv->sarea_priv->last_dispatch =
227 READ_BREADCRUMB(dev_priv);
228
229 if (iir & I915_USER_INTERRUPT) {
230 dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev);
231 DRM_WAKEUP(&dev_priv->irq_queue);
232 }
233
234 if (pipea_stats & vblank_status) {
153 vblank++; 235 vblank++;
154 drm_handle_vblank(dev, 0); 236 drm_handle_vblank(dev, 0);
155 } 237 }
156 238
157 I915_WRITE(PIPEASTAT, pipea_stats); 239 if (pipeb_stats & vblank_status) {
158 }
159 if (iir & I915_DISPLAY_PIPE_B_EVENT_INTERRUPT) {
160 pipeb_stats = I915_READ(PIPEBSTAT);
161 /* Ack the event */
162 I915_WRITE(PIPEBSTAT, pipeb_stats);
163
164 /* The vblank interrupt gets enabled even if we didn't ask for
165 it, so make sure it's shut down again */
166 if (!(dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_B))
167 pipeb_stats &= ~(PIPE_START_VBLANK_INTERRUPT_ENABLE |
168 PIPE_VBLANK_INTERRUPT_ENABLE);
169 else if (pipeb_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS|
170 PIPE_VBLANK_INTERRUPT_STATUS)) {
171 vblank++; 240 vblank++;
172 drm_handle_vblank(dev, 1); 241 drm_handle_vblank(dev, 1);
173 } 242 }
174 243
175 if (pipeb_stats & I915_LEGACY_BLC_EVENT_STATUS) 244 if ((pipeb_stats & I915_LEGACY_BLC_EVENT_STATUS) ||
245 (iir & I915_ASLE_INTERRUPT))
176 opregion_asle_intr(dev); 246 opregion_asle_intr(dev);
177 I915_WRITE(PIPEBSTAT, pipeb_stats);
178 }
179
180 I915_WRITE(IIR, iir);
181 if (dev->pdev->msi_enabled)
182 I915_WRITE(IMR, dev_priv->irq_mask_reg);
183 (void) I915_READ(IIR); /* Flush posted writes */
184
185 if (dev_priv->sarea_priv)
186 dev_priv->sarea_priv->last_dispatch =
187 READ_BREADCRUMB(dev_priv);
188 247
189 if (iir & I915_USER_INTERRUPT) { 248 /* With MSI, interrupts are only generated when iir
190 dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev); 249 * transitions from zero to nonzero. If another bit got
191 DRM_WAKEUP(&dev_priv->irq_queue); 250 * set while we were handling the existing iir bits, then
251 * we would never get another interrupt.
252 *
253 * This is fine on non-MSI as well, as if we hit this path
254 * we avoid exiting the interrupt handler only to generate
255 * another one.
256 *
257 * Note that for MSI this could cause a stray interrupt report
258 * if an interrupt landed in the time between writing IIR and
259 * the posting read. This should be rare enough to never
260 * trigger the 99% of 100,000 interrupts test for disabling
261 * stray interrupts.
262 */
263 iir = new_iir;
192 } 264 }
193 265
194 if (iir & I915_ASLE_INTERRUPT) 266 return ret;
195 opregion_asle_intr(dev);
196
197 return IRQ_HANDLED;
198} 267}
199 268
200static int i915_emit_irq(struct drm_device * dev) 269static int i915_emit_irq(struct drm_device * dev)
@@ -330,48 +399,16 @@ int i915_irq_wait(struct drm_device *dev, void *data,
330int i915_enable_vblank(struct drm_device *dev, int pipe) 399int i915_enable_vblank(struct drm_device *dev, int pipe)
331{ 400{
332 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 401 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
333 u32 pipestat_reg = 0;
334 u32 pipestat;
335 u32 interrupt = 0;
336 unsigned long irqflags; 402 unsigned long irqflags;
337 403
338 switch (pipe) {
339 case 0:
340 pipestat_reg = PIPEASTAT;
341 interrupt = I915_DISPLAY_PIPE_A_EVENT_INTERRUPT;
342 break;
343 case 1:
344 pipestat_reg = PIPEBSTAT;
345 interrupt = I915_DISPLAY_PIPE_B_EVENT_INTERRUPT;
346 break;
347 default:
348 DRM_ERROR("tried to enable vblank on non-existent pipe %d\n",
349 pipe);
350 return 0;
351 }
352
353 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); 404 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
354 /* Enabling vblank events in IMR comes before PIPESTAT write, or
355 * there's a race where the PIPESTAT vblank bit gets set to 1, so
356 * the OR of enabled PIPESTAT bits goes to 1, so the PIPExEVENT in
357 * ISR flashes to 1, but the IIR bit doesn't get set to 1 because
358 * IMR masks it. It doesn't ever get set after we clear the masking
359 * in IMR because the ISR bit is edge, not level-triggered, on the
360 * OR of PIPESTAT bits.
361 */
362 i915_enable_irq(dev_priv, interrupt);
363 pipestat = I915_READ(pipestat_reg);
364 if (IS_I965G(dev)) 405 if (IS_I965G(dev))
365 pipestat |= PIPE_START_VBLANK_INTERRUPT_ENABLE; 406 i915_enable_pipestat(dev_priv, pipe,
407 PIPE_START_VBLANK_INTERRUPT_ENABLE);
366 else 408 else
367 pipestat |= PIPE_VBLANK_INTERRUPT_ENABLE; 409 i915_enable_pipestat(dev_priv, pipe,
368 /* Clear any stale interrupt status */ 410 PIPE_VBLANK_INTERRUPT_ENABLE);
369 pipestat |= (PIPE_START_VBLANK_INTERRUPT_STATUS |
370 PIPE_VBLANK_INTERRUPT_STATUS);
371 I915_WRITE(pipestat_reg, pipestat);
372 (void) I915_READ(pipestat_reg); /* Posting read */
373 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); 411 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
374
375 return 0; 412 return 0;
376} 413}
377 414
@@ -381,37 +418,12 @@ int i915_enable_vblank(struct drm_device *dev, int pipe)
381void i915_disable_vblank(struct drm_device *dev, int pipe) 418void i915_disable_vblank(struct drm_device *dev, int pipe)
382{ 419{
383 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 420 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
384 u32 pipestat_reg = 0;
385 u32 pipestat;
386 u32 interrupt = 0;
387 unsigned long irqflags; 421 unsigned long irqflags;
388 422
389 switch (pipe) {
390 case 0:
391 pipestat_reg = PIPEASTAT;
392 interrupt = I915_DISPLAY_PIPE_A_EVENT_INTERRUPT;
393 break;
394 case 1:
395 pipestat_reg = PIPEBSTAT;
396 interrupt = I915_DISPLAY_PIPE_B_EVENT_INTERRUPT;
397 break;
398 default:
399 DRM_ERROR("tried to disable vblank on non-existent pipe %d\n",
400 pipe);
401 return;
402 break;
403 }
404
405 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); 423 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
406 i915_disable_irq(dev_priv, interrupt); 424 i915_disable_pipestat(dev_priv, pipe,
407 pipestat = I915_READ(pipestat_reg); 425 PIPE_VBLANK_INTERRUPT_ENABLE |
408 pipestat &= ~(PIPE_START_VBLANK_INTERRUPT_ENABLE | 426 PIPE_START_VBLANK_INTERRUPT_ENABLE);
409 PIPE_VBLANK_INTERRUPT_ENABLE);
410 /* Clear any stale interrupt status */
411 pipestat |= (PIPE_START_VBLANK_INTERRUPT_STATUS |
412 PIPE_VBLANK_INTERRUPT_STATUS);
413 I915_WRITE(pipestat_reg, pipestat);
414 (void) I915_READ(pipestat_reg); /* Posting read */
415 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags); 427 spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
416} 428}
417 429
@@ -476,32 +488,35 @@ void i915_driver_irq_preinstall(struct drm_device * dev)
476 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 488 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
477 489
478 I915_WRITE(HWSTAM, 0xeffe); 490 I915_WRITE(HWSTAM, 0xeffe);
491 I915_WRITE(PIPEASTAT, 0);
492 I915_WRITE(PIPEBSTAT, 0);
479 I915_WRITE(IMR, 0xffffffff); 493 I915_WRITE(IMR, 0xffffffff);
480 I915_WRITE(IER, 0x0); 494 I915_WRITE(IER, 0x0);
495 (void) I915_READ(IER);
481} 496}
482 497
483int i915_driver_irq_postinstall(struct drm_device *dev) 498int i915_driver_irq_postinstall(struct drm_device *dev)
484{ 499{
485 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 500 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
486 int ret, num_pipes = 2;
487
488 /* Set initial unmasked IRQs to just the selected vblank pipes. */
489 dev_priv->irq_mask_reg = ~0;
490
491 ret = drm_vblank_init(dev, num_pipes);
492 if (ret)
493 return ret;
494 501
495 dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; 502 dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
496 dev_priv->irq_mask_reg &= ~I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT;
497 dev_priv->irq_mask_reg &= ~I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT;
498 503
499 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */ 504 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
500 505
501 dev_priv->irq_mask_reg &= I915_INTERRUPT_ENABLE_MASK; 506 /* Unmask the interrupts that we always want on. */
507 dev_priv->irq_mask_reg = ~I915_INTERRUPT_ENABLE_FIX;
508
509 dev_priv->pipestat[0] = 0;
510 dev_priv->pipestat[1] = 0;
511
512 /* Disable pipe interrupt enables, clear pending pipe status */
513 I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff);
514 I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff);
515 /* Clear pending interrupt status */
516 I915_WRITE(IIR, I915_READ(IIR));
502 517
503 I915_WRITE(IMR, dev_priv->irq_mask_reg);
504 I915_WRITE(IER, I915_INTERRUPT_ENABLE_MASK); 518 I915_WRITE(IER, I915_INTERRUPT_ENABLE_MASK);
519 I915_WRITE(IMR, dev_priv->irq_mask_reg);
505 (void) I915_READ(IER); 520 (void) I915_READ(IER);
506 521
507 opregion_enable_asle(dev); 522 opregion_enable_asle(dev);
@@ -513,7 +528,6 @@ int i915_driver_irq_postinstall(struct drm_device *dev)
513void i915_driver_irq_uninstall(struct drm_device * dev) 528void i915_driver_irq_uninstall(struct drm_device * dev)
514{ 529{
515 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 530 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
516 u32 temp;
517 531
518 if (!dev_priv) 532 if (!dev_priv)
519 return; 533 return;
@@ -521,13 +535,12 @@ void i915_driver_irq_uninstall(struct drm_device * dev)
521 dev_priv->vblank_pipe = 0; 535 dev_priv->vblank_pipe = 0;
522 536
523 I915_WRITE(HWSTAM, 0xffffffff); 537 I915_WRITE(HWSTAM, 0xffffffff);
538 I915_WRITE(PIPEASTAT, 0);
539 I915_WRITE(PIPEBSTAT, 0);
524 I915_WRITE(IMR, 0xffffffff); 540 I915_WRITE(IMR, 0xffffffff);
525 I915_WRITE(IER, 0x0); 541 I915_WRITE(IER, 0x0);
526 542
527 temp = I915_READ(PIPEASTAT); 543 I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff);
528 I915_WRITE(PIPEASTAT, temp); 544 I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff);
529 temp = I915_READ(PIPEBSTAT); 545 I915_WRITE(IIR, I915_READ(IIR));
530 I915_WRITE(PIPEBSTAT, temp);
531 temp = I915_READ(IIR);
532 I915_WRITE(IIR, temp);
533} 546}
diff --git a/drivers/gpu/drm/i915/i915_opregion.c b/drivers/gpu/drm/i915/i915_opregion.c
index 1787a0c7e3ab..13ae731a33db 100644
--- a/drivers/gpu/drm/i915/i915_opregion.c
+++ b/drivers/gpu/drm/i915/i915_opregion.c
@@ -235,17 +235,15 @@ void opregion_enable_asle(struct drm_device *dev)
235 struct opregion_asle *asle = dev_priv->opregion.asle; 235 struct opregion_asle *asle = dev_priv->opregion.asle;
236 236
237 if (asle) { 237 if (asle) {
238 u32 pipeb_stats = I915_READ(PIPEBSTAT);
239 if (IS_MOBILE(dev)) { 238 if (IS_MOBILE(dev)) {
240 /* Many devices trigger events with a write to the 239 unsigned long irqflags;
241 legacy backlight controller, so we need to ensure 240
242 that it's able to generate interrupts */ 241 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
243 I915_WRITE(PIPEBSTAT, pipeb_stats |= 242 i915_enable_pipestat(dev_priv, 1,
244 I915_LEGACY_BLC_EVENT_ENABLE); 243 I915_LEGACY_BLC_EVENT_ENABLE);
245 i915_enable_irq(dev_priv, I915_ASLE_INTERRUPT | 244 spin_unlock_irqrestore(&dev_priv->user_irq_lock,
246 I915_DISPLAY_PIPE_B_EVENT_INTERRUPT); 245 irqflags);
247 } else 246 }
248 i915_enable_irq(dev_priv, I915_ASLE_INTERRUPT);
249 247
250 asle->tche = ASLE_ALS_EN | ASLE_BLC_EN | ASLE_PFIT_EN | 248 asle->tche = ASLE_ALS_EN | ASLE_BLC_EN | ASLE_PFIT_EN |
251 ASLE_PFMB_EN; 249 ASLE_PFMB_EN;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 0e476eba36e6..9d24aaeb8a45 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -522,6 +522,7 @@
522#define DCC_ADDRESSING_MODE_DUAL_CHANNEL_INTERLEAVED (2 << 0) 522#define DCC_ADDRESSING_MODE_DUAL_CHANNEL_INTERLEAVED (2 << 0)
523#define DCC_ADDRESSING_MODE_MASK (3 << 0) 523#define DCC_ADDRESSING_MODE_MASK (3 << 0)
524#define DCC_CHANNEL_XOR_DISABLE (1 << 10) 524#define DCC_CHANNEL_XOR_DISABLE (1 << 10)
525#define DCC_CHANNEL_XOR_BIT_17 (1 << 9)
525 526
526/** 965 MCH register controlling DRAM channel configuration */ 527/** 965 MCH register controlling DRAM channel configuration */
527#define C0DRB3 0x10206 528#define C0DRB3 0x10206
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index 5ddc6e595c0c..5d84027ee8f3 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -244,6 +244,9 @@ int i915_save_state(struct drm_device *dev)
244 if (IS_I965G(dev) && IS_MOBILE(dev)) 244 if (IS_I965G(dev) && IS_MOBILE(dev))
245 dev_priv->saveRENDERSTANDBY = I915_READ(MCHBAR_RENDER_STANDBY); 245 dev_priv->saveRENDERSTANDBY = I915_READ(MCHBAR_RENDER_STANDBY);
246 246
247 /* Hardware status page */
248 dev_priv->saveHWS = I915_READ(HWS_PGA);
249
247 /* Display arbitration control */ 250 /* Display arbitration control */
248 dev_priv->saveDSPARB = I915_READ(DSPARB); 251 dev_priv->saveDSPARB = I915_READ(DSPARB);
249 252
@@ -373,6 +376,9 @@ int i915_restore_state(struct drm_device *dev)
373 if (IS_I965G(dev) && IS_MOBILE(dev)) 376 if (IS_I965G(dev) && IS_MOBILE(dev))
374 I915_WRITE(MCHBAR_RENDER_STANDBY, dev_priv->saveRENDERSTANDBY); 377 I915_WRITE(MCHBAR_RENDER_STANDBY, dev_priv->saveRENDERSTANDBY);
375 378
379 /* Hardware status page */
380 I915_WRITE(HWS_PGA, dev_priv->saveHWS);
381
376 /* Display arbitration */ 382 /* Display arbitration */
377 I915_WRITE(DSPARB, dev_priv->saveDSPARB); 383 I915_WRITE(DSPARB, dev_priv->saveDSPARB);
378 384
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
index c1d12dbfa8d8..b49c5ff29585 100644
--- a/drivers/gpu/drm/mga/mga_dma.c
+++ b/drivers/gpu/drm/mga/mga_dma.c
@@ -396,6 +396,7 @@ int mga_freelist_put(struct drm_device * dev, struct drm_buf * buf)
396int mga_driver_load(struct drm_device * dev, unsigned long flags) 396int mga_driver_load(struct drm_device * dev, unsigned long flags)
397{ 397{
398 drm_mga_private_t *dev_priv; 398 drm_mga_private_t *dev_priv;
399 int ret;
399 400
400 dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); 401 dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
401 if (!dev_priv) 402 if (!dev_priv)
@@ -415,6 +416,13 @@ int mga_driver_load(struct drm_device * dev, unsigned long flags)
415 dev->types[7] = _DRM_STAT_PRIMARY; 416 dev->types[7] = _DRM_STAT_PRIMARY;
416 dev->types[8] = _DRM_STAT_SECONDARY; 417 dev->types[8] = _DRM_STAT_SECONDARY;
417 418
419 ret = drm_vblank_init(dev, 1);
420
421 if (ret) {
422 (void) mga_driver_unload(dev);
423 return ret;
424 }
425
418 return 0; 426 return 0;
419} 427}
420 428
diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
index bab42f41188b..daa6041a483a 100644
--- a/drivers/gpu/drm/mga/mga_irq.c
+++ b/drivers/gpu/drm/mga/mga_irq.c
@@ -152,11 +152,6 @@ void mga_driver_irq_preinstall(struct drm_device * dev)
152int mga_driver_irq_postinstall(struct drm_device *dev) 152int mga_driver_irq_postinstall(struct drm_device *dev)
153{ 153{
154 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; 154 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
155 int ret;
156
157 ret = drm_vblank_init(dev, 1);
158 if (ret)
159 return ret;
160 155
161 DRM_INIT_WAITQUEUE(&dev_priv->fence_queue); 156 DRM_INIT_WAITQUEUE(&dev_priv->fence_queue);
162 157
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 3265d53ba91f..601f4c0e5da5 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -45,6 +45,7 @@ static struct drm_driver driver = {
45 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | 45 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
46 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, 46 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
47 .dev_priv_size = sizeof(drm_r128_buf_priv_t), 47 .dev_priv_size = sizeof(drm_r128_buf_priv_t),
48 .load = r128_driver_load,
48 .preclose = r128_driver_preclose, 49 .preclose = r128_driver_preclose,
49 .lastclose = r128_driver_lastclose, 50 .lastclose = r128_driver_lastclose,
50 .get_vblank_counter = r128_get_vblank_counter, 51 .get_vblank_counter = r128_get_vblank_counter,
@@ -84,6 +85,11 @@ static struct drm_driver driver = {
84 .patchlevel = DRIVER_PATCHLEVEL, 85 .patchlevel = DRIVER_PATCHLEVEL,
85}; 86};
86 87
88int r128_driver_load(struct drm_device * dev, unsigned long flags)
89{
90 return drm_vblank_init(dev, 1);
91}
92
87static int __init r128_init(void) 93static int __init r128_init(void)
88{ 94{
89 driver.num_ioctls = r128_max_ioctl; 95 driver.num_ioctls = r128_max_ioctl;
diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
index 5898b274279d..797a26c42dab 100644
--- a/drivers/gpu/drm/r128/r128_drv.h
+++ b/drivers/gpu/drm/r128/r128_drv.h
@@ -159,6 +159,7 @@ extern void r128_driver_irq_preinstall(struct drm_device * dev);
159extern int r128_driver_irq_postinstall(struct drm_device *dev); 159extern int r128_driver_irq_postinstall(struct drm_device *dev);
160extern void r128_driver_irq_uninstall(struct drm_device * dev); 160extern void r128_driver_irq_uninstall(struct drm_device * dev);
161extern void r128_driver_lastclose(struct drm_device * dev); 161extern void r128_driver_lastclose(struct drm_device * dev);
162extern int r128_driver_load(struct drm_device * dev, unsigned long flags);
162extern void r128_driver_preclose(struct drm_device * dev, 163extern void r128_driver_preclose(struct drm_device * dev,
163 struct drm_file *file_priv); 164 struct drm_file *file_priv);
164 165
diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
index d7349012a680..69810fb8ac49 100644
--- a/drivers/gpu/drm/r128/r128_irq.c
+++ b/drivers/gpu/drm/r128/r128_irq.c
@@ -102,7 +102,7 @@ void r128_driver_irq_preinstall(struct drm_device * dev)
102 102
103int r128_driver_irq_postinstall(struct drm_device *dev) 103int r128_driver_irq_postinstall(struct drm_device *dev)
104{ 104{
105 return drm_vblank_init(dev, 1); 105 return 0;
106} 106}
107 107
108void r128_driver_irq_uninstall(struct drm_device * dev) 108void r128_driver_irq_uninstall(struct drm_device * dev)
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index abdc1ae38467..dcebb4bee7aa 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -1757,6 +1757,12 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags)
1757 if (ret != 0) 1757 if (ret != 0)
1758 return ret; 1758 return ret;
1759 1759
1760 ret = drm_vblank_init(dev, 2);
1761 if (ret) {
1762 radeon_driver_unload(dev);
1763 return ret;
1764 }
1765
1760 DRM_DEBUG("%s card detected\n", 1766 DRM_DEBUG("%s card detected\n",
1761 ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI")))); 1767 ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI"))));
1762 return ret; 1768 return ret;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index 7a183789be97..3bbb871b25d5 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -299,7 +299,6 @@ typedef struct drm_radeon_private {
299 atomic_t swi_emitted; 299 atomic_t swi_emitted;
300 int vblank_crtc; 300 int vblank_crtc;
301 uint32_t irq_enable_reg; 301 uint32_t irq_enable_reg;
302 int irq_enabled;
303 uint32_t r500_disp_irq_reg; 302 uint32_t r500_disp_irq_reg;
304 303
305 struct radeon_surface surfaces[RADEON_MAX_SURFACES]; 304 struct radeon_surface surfaces[RADEON_MAX_SURFACES];
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index 5079f7054a2f..8289e16419a8 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -44,7 +44,8 @@ void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state)
44 else 44 else
45 dev_priv->irq_enable_reg &= ~mask; 45 dev_priv->irq_enable_reg &= ~mask;
46 46
47 RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg); 47 if (dev->irq_enabled)
48 RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
48} 49}
49 50
50static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state) 51static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
@@ -56,7 +57,8 @@ static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
56 else 57 else
57 dev_priv->r500_disp_irq_reg &= ~mask; 58 dev_priv->r500_disp_irq_reg &= ~mask;
58 59
59 RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg); 60 if (dev->irq_enabled)
61 RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
60} 62}
61 63
62int radeon_enable_vblank(struct drm_device *dev, int crtc) 64int radeon_enable_vblank(struct drm_device *dev, int crtc)
@@ -337,15 +339,10 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
337{ 339{
338 drm_radeon_private_t *dev_priv = 340 drm_radeon_private_t *dev_priv =
339 (drm_radeon_private_t *) dev->dev_private; 341 (drm_radeon_private_t *) dev->dev_private;
340 int ret;
341 342
342 atomic_set(&dev_priv->swi_emitted, 0); 343 atomic_set(&dev_priv->swi_emitted, 0);
343 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue); 344 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
344 345
345 ret = drm_vblank_init(dev, 2);
346 if (ret)
347 return ret;
348
349 dev->max_vblank_count = 0x001fffff; 346 dev->max_vblank_count = 0x001fffff;
350 347
351 radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1); 348 radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1);
@@ -360,8 +357,6 @@ void radeon_driver_irq_uninstall(struct drm_device * dev)
360 if (!dev_priv) 357 if (!dev_priv)
361 return; 358 return;
362 359
363 dev_priv->irq_enabled = 0;
364
365 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690) 360 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690)
366 RADEON_WRITE(R500_DxMODE_INT_MASK, 0); 361 RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
367 /* Disable *all* interrupts */ 362 /* Disable *all* interrupts */
diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index 665d319b927b..c248c1d37268 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -314,7 +314,6 @@ int via_driver_irq_postinstall(struct drm_device *dev)
314 if (!dev_priv) 314 if (!dev_priv)
315 return -EINVAL; 315 return -EINVAL;
316 316
317 drm_vblank_init(dev, 1);
318 status = VIA_READ(VIA_REG_INTERRUPT); 317 status = VIA_READ(VIA_REG_INTERRUPT);
319 VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_GLOBAL 318 VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_GLOBAL
320 | dev_priv->irq_enable_mask); 319 | dev_priv->irq_enable_mask);
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index a967556be014..2c4f0b485792 100644
--- a/drivers/gpu/drm/via/via_map.c
+++ b/drivers/gpu/drm/via/via_map.c
@@ -107,8 +107,17 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset)
107 ret = drm_sman_init(&dev_priv->sman, 2, 12, 8); 107 ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
108 if (ret) { 108 if (ret) {
109 drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); 109 drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
110 return ret;
110 } 111 }
111 return ret; 112
113 ret = drm_vblank_init(dev, 1);
114 if (ret) {
115 drm_sman_takedown(&dev_priv->sman);
116 drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER);
117 return ret;
118 }
119
120 return 0;
112} 121}
113 122
114int via_driver_unload(struct drm_device *dev) 123int via_driver_unload(struct drm_device *dev)
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 9b97795e45ad..aa28aed0e46c 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -400,12 +400,12 @@ static const struct hid_device_id apple_devices[] = {
400 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), 400 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
401 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | 401 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
402 APPLE_RDESC_JIS }, 402 APPLE_RDESC_JIS },
403 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), 403 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
404 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 404 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
405 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO), 405 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
406 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | 406 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
407 APPLE_ISO_KEYBOARD }, 407 APPLE_ISO_KEYBOARD },
408 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), 408 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
409 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 409 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
410 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), 410 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
411 .driver_data = APPLE_HAS_FN }, 411 .driver_data = APPLE_HAS_FN },
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 147ec591a806..40df3e1b4bd1 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1241,9 +1241,9 @@ static const struct hid_device_id hid_blacklist[] = {
1241 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 1241 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
1242 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 1242 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
1243 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1243 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
1244 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, 1244 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) },
1245 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, 1245 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) },
1246 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, 1246 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) },
1247 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 1247 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
1248 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 1248 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
1249 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 1249 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
@@ -1266,6 +1266,9 @@ static const struct hid_device_id hid_blacklist[] = {
1266 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) }, 1266 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) },
1267 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1267 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
1268 { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) }, 1268 { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) },
1269 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
1270 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
1271 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
1269 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 1272 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
1270 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1273 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
1271 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 1274 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
@@ -1420,7 +1423,6 @@ static const struct hid_device_id hid_ignore_list[] = {
1420 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1423 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
1421 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 1424 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
1422 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 1425 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
1423 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
1424 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1426 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
1425 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1427 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
1426 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, 1428 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) },
@@ -1436,7 +1438,6 @@ static const struct hid_device_id hid_ignore_list[] = {
1436 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 1438 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
1437 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 1439 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
1438 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, 1440 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
1439 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
1440 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, 1441 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) },
1441 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, 1442 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) },
1442 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, 1443 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) },
@@ -1576,9 +1577,6 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
1576 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1577 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1577 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1578 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1578 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1579 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
1579 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1580 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1581 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
1582 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1580 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1583 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1581 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1584 { } 1582 { }
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index d70075dd3d81..39289699c32f 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -163,6 +163,7 @@
163 163
164#define USB_VENDOR_ID_GAMERON 0x0810 164#define USB_VENDOR_ID_GAMERON 0x0810
165#define USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR 0x0001 165#define USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR 0x0001
166#define USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR 0x0002
166 167
167#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc 168#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc
168 169
diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
index acd815586182..46941f979b9d 100644
--- a/drivers/hid/hid-pl.c
+++ b/drivers/hid/hid-pl.c
@@ -178,6 +178,8 @@ err:
178static const struct hid_device_id pl_devices[] = { 178static const struct hid_device_id pl_devices[] = {
179 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR), 179 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR),
180 .driver_data = 1 }, /* Twin USB Joystick */ 180 .driver_data = 1 }, /* Twin USB Joystick */
181 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR),
182 .driver_data = 1 }, /* Twin USB Joystick */
181 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003), }, /* GreenAsia Inc. USB Joystick */ 183 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003), }, /* GreenAsia Inc. USB Joystick */
182 { } 184 { }
183}; 185};
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index d746bf8284dd..606369ea24ca 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -796,7 +796,6 @@ static int usbhid_start(struct hid_device *hid)
796 if (insize > HID_MAX_BUFFER_SIZE) 796 if (insize > HID_MAX_BUFFER_SIZE)
797 insize = HID_MAX_BUFFER_SIZE; 797 insize = HID_MAX_BUFFER_SIZE;
798 798
799 mutex_lock(&usbhid->setup);
800 if (hid_alloc_buffers(dev, hid)) { 799 if (hid_alloc_buffers(dev, hid)) {
801 ret = -ENOMEM; 800 ret = -ENOMEM;
802 goto fail; 801 goto fail;
@@ -876,7 +875,6 @@ static int usbhid_start(struct hid_device *hid)
876 hid_dump_device(hid); 875 hid_dump_device(hid);
877 876
878 set_bit(HID_STARTED, &usbhid->iofl); 877 set_bit(HID_STARTED, &usbhid->iofl);
879 mutex_unlock(&usbhid->setup);
880 878
881 return 0; 879 return 0;
882 880
@@ -888,7 +886,6 @@ fail:
888 usbhid->urbout = NULL; 886 usbhid->urbout = NULL;
889 usbhid->urbctrl = NULL; 887 usbhid->urbctrl = NULL;
890 hid_free_buffers(dev, hid); 888 hid_free_buffers(dev, hid);
891 mutex_unlock(&usbhid->setup);
892 return ret; 889 return ret;
893} 890}
894 891
@@ -899,7 +896,6 @@ static void usbhid_stop(struct hid_device *hid)
899 if (WARN_ON(!usbhid)) 896 if (WARN_ON(!usbhid))
900 return; 897 return;
901 898
902 mutex_lock(&usbhid->setup);
903 clear_bit(HID_STARTED, &usbhid->iofl); 899 clear_bit(HID_STARTED, &usbhid->iofl);
904 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ 900 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
905 set_bit(HID_DISCONNECTED, &usbhid->iofl); 901 set_bit(HID_DISCONNECTED, &usbhid->iofl);
@@ -928,7 +924,6 @@ static void usbhid_stop(struct hid_device *hid)
928 usbhid->urbout = NULL; 924 usbhid->urbout = NULL;
929 925
930 hid_free_buffers(hid_to_usb_dev(hid), hid); 926 hid_free_buffers(hid_to_usb_dev(hid), hid);
931 mutex_unlock(&usbhid->setup);
932} 927}
933 928
934static struct hid_ll_driver usb_hid_driver = { 929static struct hid_ll_driver usb_hid_driver = {
@@ -1016,7 +1011,6 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
1016 1011
1017 hid->driver_data = usbhid; 1012 hid->driver_data = usbhid;
1018 usbhid->hid = hid; 1013 usbhid->hid = hid;
1019 mutex_init(&usbhid->setup); /* needed on suspend/resume */
1020 1014
1021 ret = hid_add_device(hid); 1015 ret = hid_add_device(hid);
1022 if (ret) { 1016 if (ret) {
@@ -1051,18 +1045,14 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1051 struct hid_device *hid = usb_get_intfdata (intf); 1045 struct hid_device *hid = usb_get_intfdata (intf);
1052 struct usbhid_device *usbhid = hid->driver_data; 1046 struct usbhid_device *usbhid = hid->driver_data;
1053 1047
1054 mutex_lock(&usbhid->setup); 1048 if (!test_bit(HID_STARTED, &usbhid->iofl))
1055 if (!test_bit(HID_STARTED, &usbhid->iofl)) {
1056 mutex_unlock(&usbhid->setup);
1057 return 0; 1049 return 0;
1058 }
1059 1050
1060 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ 1051 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
1061 set_bit(HID_SUSPENDED, &usbhid->iofl); 1052 set_bit(HID_SUSPENDED, &usbhid->iofl);
1062 spin_unlock_irq(&usbhid->inlock); 1053 spin_unlock_irq(&usbhid->inlock);
1063 del_timer_sync(&usbhid->io_retry); 1054 del_timer_sync(&usbhid->io_retry);
1064 usb_kill_urb(usbhid->urbin); 1055 usb_kill_urb(usbhid->urbin);
1065 mutex_unlock(&usbhid->setup);
1066 dev_dbg(&intf->dev, "suspend\n"); 1056 dev_dbg(&intf->dev, "suspend\n");
1067 return 0; 1057 return 0;
1068} 1058}
@@ -1073,16 +1063,12 @@ static int hid_resume(struct usb_interface *intf)
1073 struct usbhid_device *usbhid = hid->driver_data; 1063 struct usbhid_device *usbhid = hid->driver_data;
1074 int status; 1064 int status;
1075 1065
1076 mutex_lock(&usbhid->setup); 1066 if (!test_bit(HID_STARTED, &usbhid->iofl))
1077 if (!test_bit(HID_STARTED, &usbhid->iofl)) {
1078 mutex_unlock(&usbhid->setup);
1079 return 0; 1067 return 0;
1080 }
1081 1068
1082 clear_bit(HID_SUSPENDED, &usbhid->iofl); 1069 clear_bit(HID_SUSPENDED, &usbhid->iofl);
1083 usbhid->retry_delay = 0; 1070 usbhid->retry_delay = 0;
1084 status = hid_start_in(hid); 1071 status = hid_start_in(hid);
1085 mutex_unlock(&usbhid->setup);
1086 dev_dbg(&intf->dev, "resume status %d\n", status); 1072 dev_dbg(&intf->dev, "resume status %d\n", status);
1087 return status; 1073 return status;
1088} 1074}
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index 55973ff54008..332abcdf9956 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -74,7 +74,6 @@ struct usbhid_device {
74 dma_addr_t outbuf_dma; /* Output buffer dma */ 74 dma_addr_t outbuf_dma; /* Output buffer dma */
75 spinlock_t outlock; /* Output fifo spinlock */ 75 spinlock_t outlock; /* Output fifo spinlock */
76 76
77 struct mutex setup;
78 unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ 77 unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
79 struct timer_list io_retry; /* Retry timer */ 78 struct timer_list io_retry; /* Retry timer */
80 unsigned long stop_retry; /* Time to give up, in jiffies */ 79 unsigned long stop_retry; /* Time to give up, in jiffies */
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index f7dce8b9f64b..086c2a5cef0b 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1564,3 +1564,4 @@ module_exit(applesmc_exit);
1564MODULE_AUTHOR("Nicolas Boichat"); 1564MODULE_AUTHOR("Nicolas Boichat");
1565MODULE_DESCRIPTION("Apple SMC"); 1565MODULE_DESCRIPTION("Apple SMC");
1566MODULE_LICENSE("GPL v2"); 1566MODULE_LICENSE("GPL v2");
1567MODULE_DEVICE_TABLE(dmi, applesmc_whitelist);
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index 228f75723063..3fcf78e906db 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -365,6 +365,7 @@ static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
365 pmsg = &msgs[tptr]; 365 pmsg = &msgs[tptr];
366 if (pmsg->flags & I2C_M_RD) 366 if (pmsg->flags & I2C_M_RD)
367 ret = wait_event_interruptible_timeout(cpm->i2c_wait, 367 ret = wait_event_interruptible_timeout(cpm->i2c_wait,
368 (in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) ||
368 !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY), 369 !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
369 1 * HZ); 370 1 * HZ);
370 else 371 else
diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c
index f4d22ae9d294..e5a8dae4a289 100644
--- a/drivers/i2c/busses/i2c-highlander.c
+++ b/drivers/i2c/busses/i2c-highlander.c
@@ -92,7 +92,7 @@ static void highlander_i2c_setup(struct highlander_i2c_dev *dev)
92static void smbus_write_data(u8 *src, u16 *dst, int len) 92static void smbus_write_data(u8 *src, u16 *dst, int len)
93{ 93{
94 for (; len > 1; len -= 2) { 94 for (; len > 1; len -= 2) {
95 *dst++ = be16_to_cpup((u16 *)src); 95 *dst++ = be16_to_cpup((__be16 *)src);
96 src += 2; 96 src += 2;
97 } 97 }
98 98
@@ -103,7 +103,7 @@ static void smbus_write_data(u8 *src, u16 *dst, int len)
103static void smbus_read_data(u16 *src, u8 *dst, int len) 103static void smbus_read_data(u16 *src, u8 *dst, int len)
104{ 104{
105 for (; len > 1; len -= 2) { 105 for (; len > 1; len -= 2) {
106 *(u16 *)dst = cpu_to_be16p(src++); 106 *(__be16 *)dst = cpu_to_be16p(src++);
107 dst += 2; 107 dst += 2;
108 } 108 }
109 109
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 59ba2086d2f9..a257cd5cd134 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -189,8 +189,6 @@ static void i2c_parport_attach (struct parport *port)
189 if (adapter_parm[type].init.val) 189 if (adapter_parm[type].init.val)
190 line_set(port, 1, &adapter_parm[type].init); 190 line_set(port, 1, &adapter_parm[type].init);
191 191
192 parport_release(adapter->pdev);
193
194 if (i2c_bit_add_bus(&adapter->adapter) < 0) { 192 if (i2c_bit_add_bus(&adapter->adapter) < 0) {
195 printk(KERN_ERR "i2c-parport: Unable to register with I2C\n"); 193 printk(KERN_ERR "i2c-parport: Unable to register with I2C\n");
196 goto ERROR1; 194 goto ERROR1;
@@ -202,6 +200,7 @@ static void i2c_parport_attach (struct parport *port)
202 return; 200 return;
203 201
204ERROR1: 202ERROR1:
203 parport_release(adapter->pdev);
205 parport_unregister_device(adapter->pdev); 204 parport_unregister_device(adapter->pdev);
206ERROR0: 205ERROR0:
207 kfree(adapter); 206 kfree(adapter);
@@ -221,6 +220,7 @@ static void i2c_parport_detach (struct parport *port)
221 if (adapter_parm[type].init.val) 220 if (adapter_parm[type].init.val)
222 line_set(port, 0, &adapter_parm[type].init); 221 line_set(port, 0, &adapter_parm[type].init);
223 222
223 parport_release(adapter->pdev);
224 parport_unregister_device(adapter->pdev); 224 parport_unregister_device(adapter->pdev);
225 if (prev) 225 if (prev)
226 prev->next = adapter->next; 226 prev->next = adapter->next;
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c
index dcf2045b5222..0bdb2d7f0570 100644
--- a/drivers/i2c/busses/i2c-pmcmsp.c
+++ b/drivers/i2c/busses/i2c-pmcmsp.c
@@ -486,7 +486,7 @@ static enum pmcmsptwi_xfer_result pmcmsptwi_xfer_cmd(
486 486
487 if (cmd->type == MSP_TWI_CMD_WRITE || 487 if (cmd->type == MSP_TWI_CMD_WRITE ||
488 cmd->type == MSP_TWI_CMD_WRITE_READ) { 488 cmd->type == MSP_TWI_CMD_WRITE_READ) {
489 __be64 tmp = cpu_to_be64p((u64 *)cmd->write_data); 489 u64 tmp = be64_to_cpup((__be64 *)cmd->write_data);
490 tmp >>= (MSP_MAX_BYTES_PER_RW - cmd->write_len) * 8; 490 tmp >>= (MSP_MAX_BYTES_PER_RW - cmd->write_len) * 8;
491 dev_dbg(&pmcmsptwi_adapter.dev, "Writing 0x%016llx\n", tmp); 491 dev_dbg(&pmcmsptwi_adapter.dev, "Writing 0x%016llx\n", tmp);
492 pmcmsptwi_writel(tmp & 0x00000000ffffffffLL, 492 pmcmsptwi_writel(tmp & 0x00000000ffffffffLL,
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 1fac4e233133..b7434d24904e 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -56,6 +56,7 @@ enum s3c24xx_i2c_state {
56struct s3c24xx_i2c { 56struct s3c24xx_i2c {
57 spinlock_t lock; 57 spinlock_t lock;
58 wait_queue_head_t wait; 58 wait_queue_head_t wait;
59 unsigned int suspended:1;
59 60
60 struct i2c_msg *msg; 61 struct i2c_msg *msg;
61 unsigned int msg_num; 62 unsigned int msg_num;
@@ -507,7 +508,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
507 unsigned long timeout; 508 unsigned long timeout;
508 int ret; 509 int ret;
509 510
510 if (!(readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN)) 511 if (i2c->suspended)
511 return -EIO; 512 return -EIO;
512 513
513 ret = s3c24xx_i2c_set_master(i2c); 514 ret = s3c24xx_i2c_set_master(i2c);
@@ -986,17 +987,26 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
986} 987}
987 988
988#ifdef CONFIG_PM 989#ifdef CONFIG_PM
990static int s3c24xx_i2c_suspend_late(struct platform_device *dev,
991 pm_message_t msg)
992{
993 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
994 i2c->suspended = 1;
995 return 0;
996}
997
989static int s3c24xx_i2c_resume(struct platform_device *dev) 998static int s3c24xx_i2c_resume(struct platform_device *dev)
990{ 999{
991 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev); 1000 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
992 1001
993 if (i2c != NULL) 1002 i2c->suspended = 0;
994 s3c24xx_i2c_init(i2c); 1003 s3c24xx_i2c_init(i2c);
995 1004
996 return 0; 1005 return 0;
997} 1006}
998 1007
999#else 1008#else
1009#define s3c24xx_i2c_suspend_late NULL
1000#define s3c24xx_i2c_resume NULL 1010#define s3c24xx_i2c_resume NULL
1001#endif 1011#endif
1002 1012
@@ -1005,6 +1015,7 @@ static int s3c24xx_i2c_resume(struct platform_device *dev)
1005static struct platform_driver s3c2410_i2c_driver = { 1015static struct platform_driver s3c2410_i2c_driver = {
1006 .probe = s3c24xx_i2c_probe, 1016 .probe = s3c24xx_i2c_probe,
1007 .remove = s3c24xx_i2c_remove, 1017 .remove = s3c24xx_i2c_remove,
1018 .suspend_late = s3c24xx_i2c_suspend_late,
1008 .resume = s3c24xx_i2c_resume, 1019 .resume = s3c24xx_i2c_resume,
1009 .driver = { 1020 .driver = {
1010 .owner = THIS_MODULE, 1021 .owner = THIS_MODULE,
@@ -1015,6 +1026,7 @@ static struct platform_driver s3c2410_i2c_driver = {
1015static struct platform_driver s3c2440_i2c_driver = { 1026static struct platform_driver s3c2440_i2c_driver = {
1016 .probe = s3c24xx_i2c_probe, 1027 .probe = s3c24xx_i2c_probe,
1017 .remove = s3c24xx_i2c_remove, 1028 .remove = s3c24xx_i2c_remove,
1029 .suspend_late = s3c24xx_i2c_suspend_late,
1018 .resume = s3c24xx_i2c_resume, 1030 .resume = s3c24xx_i2c_resume,
1019 .driver = { 1031 .driver = {
1020 .owner = THIS_MODULE, 1032 .owner = THIS_MODULE,
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index 28902ebd5539..e0d56ef2bcb0 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -25,6 +25,7 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/gpio.h>
28#include <linux/usb/ch9.h> 29#include <linux/usb/ch9.h>
29#include <linux/usb/gadget.h> 30#include <linux/usb/gadget.h>
30#include <linux/usb.h> 31#include <linux/usb.h>
@@ -33,7 +34,10 @@
33#include <linux/workqueue.h> 34#include <linux/workqueue.h>
34 35
35#include <asm/irq.h> 36#include <asm/irq.h>
37#include <asm/mach-types.h>
38
36#include <mach/usb.h> 39#include <mach/usb.h>
40#include <mach/mux.h>
37 41
38 42
39#ifndef DEBUG 43#ifndef DEBUG
@@ -88,14 +92,9 @@ struct isp1301 {
88 92
89/*-------------------------------------------------------------------------*/ 93/*-------------------------------------------------------------------------*/
90 94
91#ifdef CONFIG_MACH_OMAP_H2
92
93/* board-specific PM hooks */ 95/* board-specific PM hooks */
94 96
95#include <asm/gpio.h> 97#if defined(CONFIG_MACH_OMAP_H2) || defined(CONFIG_MACH_OMAP_H3)
96#include <mach/mux.h>
97#include <asm/mach-types.h>
98
99 98
100#if defined(CONFIG_TPS65010) || defined(CONFIG_TPS65010_MODULE) 99#if defined(CONFIG_TPS65010) || defined(CONFIG_TPS65010_MODULE)
101 100
@@ -135,6 +134,33 @@ static inline void notresponding(struct isp1301 *isp)
135 134
136#endif 135#endif
137 136
137#if defined(CONFIG_MACH_OMAP_H4)
138
139static void enable_vbus_draw(struct isp1301 *isp, unsigned mA)
140{
141 /* H4 controls this by DIP switch S2.4; no soft control.
142 * ON means the charger is always enabled. Leave it OFF
143 * unless the OTG port is used only in B-peripheral mode.
144 */
145}
146
147static void enable_vbus_source(struct isp1301 *isp)
148{
149 /* this board won't supply more than 8mA vbus power.
150 * some boards can switch a 100ma "unit load" (or more).
151 */
152}
153
154
155/* products will deliver OTG messages with LEDs, GUI, etc */
156static inline void notresponding(struct isp1301 *isp)
157{
158 printk(KERN_NOTICE "OTG device not responding.\n");
159}
160
161
162#endif
163
138/*-------------------------------------------------------------------------*/ 164/*-------------------------------------------------------------------------*/
139 165
140static struct i2c_driver isp1301_driver; 166static struct i2c_driver isp1301_driver;
@@ -334,8 +360,7 @@ static int gadget_suspend(struct isp1301 *isp)
334 * NOTE: guaranteeing certain response times might mean we shouldn't 360 * NOTE: guaranteeing certain response times might mean we shouldn't
335 * share keventd's work queue; a realtime task might be safest. 361 * share keventd's work queue; a realtime task might be safest.
336 */ 362 */
337void 363static void isp1301_defer_work(struct isp1301 *isp, int work)
338isp1301_defer_work(struct isp1301 *isp, int work)
339{ 364{
340 int status; 365 int status;
341 366
@@ -512,7 +537,6 @@ static void update_otg1(struct isp1301 *isp, u8 int_src)
512 otg_ctrl &= ~OTG_XCEIV_INPUTS; 537 otg_ctrl &= ~OTG_XCEIV_INPUTS;
513 otg_ctrl &= ~(OTG_ID|OTG_ASESSVLD|OTG_VBUSVLD); 538 otg_ctrl &= ~(OTG_ID|OTG_ASESSVLD|OTG_VBUSVLD);
514 539
515
516 if (int_src & INTR_SESS_VLD) 540 if (int_src & INTR_SESS_VLD)
517 otg_ctrl |= OTG_ASESSVLD; 541 otg_ctrl |= OTG_ASESSVLD;
518 else if (isp->otg.state == OTG_STATE_A_WAIT_VFALL) { 542 else if (isp->otg.state == OTG_STATE_A_WAIT_VFALL) {
@@ -886,11 +910,11 @@ static int otg_probe(struct platform_device *dev)
886 910
887static int otg_remove(struct platform_device *dev) 911static int otg_remove(struct platform_device *dev)
888{ 912{
889 otg_dev = 0; 913 otg_dev = NULL;
890 return 0; 914 return 0;
891} 915}
892 916
893struct platform_driver omap_otg_driver = { 917static struct platform_driver omap_otg_driver = {
894 .probe = otg_probe, 918 .probe = otg_probe,
895 .remove = otg_remove, 919 .remove = otg_remove,
896 .driver = { 920 .driver = {
@@ -1212,6 +1236,8 @@ static void isp1301_release(struct device *dev)
1212 1236
1213 isp = dev_get_drvdata(dev); 1237 isp = dev_get_drvdata(dev);
1214 1238
1239 /* FIXME -- not with a "new style" driver, it doesn't!! */
1240
1215 /* ugly -- i2c hijacks our memory hook to wait_for_completion() */ 1241 /* ugly -- i2c hijacks our memory hook to wait_for_completion() */
1216 if (isp->i2c_release) 1242 if (isp->i2c_release)
1217 isp->i2c_release(dev); 1243 isp->i2c_release(dev);
@@ -1233,7 +1259,7 @@ static int __exit isp1301_remove(struct i2c_client *i2c)
1233 otg_unbind(isp); 1259 otg_unbind(isp);
1234#endif 1260#endif
1235 if (machine_is_omap_h2()) 1261 if (machine_is_omap_h2())
1236 omap_free_gpio(2); 1262 gpio_free(2);
1237 1263
1238 isp->timer.data = 0; 1264 isp->timer.data = 0;
1239 set_bit(WORK_STOP, &isp->todo); 1265 set_bit(WORK_STOP, &isp->todo);
@@ -1241,7 +1267,7 @@ static int __exit isp1301_remove(struct i2c_client *i2c)
1241 flush_scheduled_work(); 1267 flush_scheduled_work();
1242 1268
1243 put_device(&i2c->dev); 1269 put_device(&i2c->dev);
1244 the_transceiver = 0; 1270 the_transceiver = NULL;
1245 1271
1246 return 0; 1272 return 0;
1247} 1273}
@@ -1295,7 +1321,7 @@ isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host)
1295 if (!host) { 1321 if (!host) {
1296 omap_writew(0, OTG_IRQ_EN); 1322 omap_writew(0, OTG_IRQ_EN);
1297 power_down(isp); 1323 power_down(isp);
1298 isp->otg.host = 0; 1324 isp->otg.host = NULL;
1299 return 0; 1325 return 0;
1300 } 1326 }
1301 1327
@@ -1344,7 +1370,9 @@ static int
1344isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) 1370isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget)
1345{ 1371{
1346 struct isp1301 *isp = container_of(otg, struct isp1301, otg); 1372 struct isp1301 *isp = container_of(otg, struct isp1301, otg);
1373#ifndef CONFIG_USB_OTG
1347 u32 l; 1374 u32 l;
1375#endif
1348 1376
1349 if (!otg || isp != the_transceiver) 1377 if (!otg || isp != the_transceiver)
1350 return -ENODEV; 1378 return -ENODEV;
@@ -1354,7 +1382,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget)
1354 if (!isp->otg.default_a) 1382 if (!isp->otg.default_a)
1355 enable_vbus_draw(isp, 0); 1383 enable_vbus_draw(isp, 0);
1356 usb_gadget_vbus_disconnect(isp->otg.gadget); 1384 usb_gadget_vbus_disconnect(isp->otg.gadget);
1357 isp->otg.gadget = 0; 1385 isp->otg.gadget = NULL;
1358 power_down(isp); 1386 power_down(isp);
1359 return 0; 1387 return 0;
1360 } 1388 }
@@ -1379,7 +1407,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget)
1379 power_up(isp); 1407 power_up(isp);
1380 isp->otg.state = OTG_STATE_B_IDLE; 1408 isp->otg.state = OTG_STATE_B_IDLE;
1381 1409
1382 if (machine_is_omap_h2()) 1410 if (machine_is_omap_h2() || machine_is_omap_h3())
1383 isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); 1411 isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0);
1384 1412
1385 isp1301_set_bits(isp, ISP1301_INTERRUPT_RISING, 1413 isp1301_set_bits(isp, ISP1301_INTERRUPT_RISING,
@@ -1499,7 +1527,8 @@ isp1301_start_hnp(struct otg_transceiver *dev)
1499 1527
1500/*-------------------------------------------------------------------------*/ 1528/*-------------------------------------------------------------------------*/
1501 1529
1502static int __init isp1301_probe(struct i2c_client *i2c) 1530static int __init
1531isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
1503{ 1532{
1504 int status; 1533 int status;
1505 struct isp1301 *isp; 1534 struct isp1301 *isp;
@@ -1647,7 +1676,7 @@ module_init(isp_init);
1647static void __exit isp_exit(void) 1676static void __exit isp_exit(void)
1648{ 1677{
1649 if (the_transceiver) 1678 if (the_transceiver)
1650 otg_set_transceiver(0); 1679 otg_set_transceiver(NULL);
1651 i2c_del_driver(&isp1301_driver); 1680 i2c_del_driver(&isp1301_driver);
1652} 1681}
1653module_exit(isp_exit); 1682module_exit(isp_exit);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 5a485c22660a..c6a63f46bc15 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -631,7 +631,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
631 631
632 /* detach any active clients. This must be done first, because 632 /* detach any active clients. This must be done first, because
633 * it can fail; in which case we give up. */ 633 * it can fail; in which case we give up. */
634 list_for_each_entry_safe(client, _n, &adap->clients, list) { 634 list_for_each_entry_safe_reverse(client, _n, &adap->clients, list) {
635 struct i2c_driver *driver; 635 struct i2c_driver *driver;
636 636
637 driver = client->driver; 637 driver = client->driver;
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 6d7401772a8f..e6857e01d1ba 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -669,10 +669,12 @@ config BLK_DEV_CELLEB
669 669
670endif 670endif
671 671
672# TODO: BLK_DEV_IDEDMA_PCI -> BLK_DEV_IDEDMA_SFF
672config BLK_DEV_IDE_PMAC 673config BLK_DEV_IDE_PMAC
673 tristate "PowerMac on-board IDE support" 674 tristate "PowerMac on-board IDE support"
674 depends on PPC_PMAC && IDE=y 675 depends on PPC_PMAC && IDE=y
675 select IDE_TIMINGS 676 select IDE_TIMINGS
677 select BLK_DEV_IDEDMA_PCI
676 help 678 help
677 This driver provides support for the on-board IDE controller on 679 This driver provides support for the on-board IDE controller on
678 most of the recent Apple Power Macintoshes and PowerBooks. 680 most of the recent Apple Power Macintoshes and PowerBooks.
@@ -689,16 +691,6 @@ config BLK_DEV_IDE_PMAC_ATA100FIRST
689 CD-ROM on hda. This option changes this to more natural hda for 691 CD-ROM on hda. This option changes this to more natural hda for
690 hard disk and hdc for CD-ROM. 692 hard disk and hdc for CD-ROM.
691 693
692config BLK_DEV_IDEDMA_PMAC
693 bool "PowerMac IDE DMA support"
694 depends on BLK_DEV_IDE_PMAC
695 select BLK_DEV_IDEDMA_PCI
696 help
697 This option allows the driver for the on-board IDE controller on
698 Power Macintoshes and PowerBooks to use DMA (direct memory access)
699 to transfer data to and from memory. Saying Y is safe and improves
700 performance.
701
702config BLK_DEV_IDE_AU1XXX 694config BLK_DEV_IDE_AU1XXX
703 bool "IDE for AMD Alchemy Au1200" 695 bool "IDE for AMD Alchemy Au1200"
704 depends on SOC_AU1200 696 depends on SOC_AU1200
@@ -912,7 +904,7 @@ config BLK_DEV_UMC8672
912endif 904endif
913 905
914config BLK_DEV_IDEDMA 906config BLK_DEV_IDEDMA
915 def_bool BLK_DEV_IDEDMA_SFF || BLK_DEV_IDEDMA_PMAC || \ 907 def_bool BLK_DEV_IDEDMA_SFF || \
916 BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 908 BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
917 909
918endif # IDE 910endif # IDE
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
index e56c7b72f9e2..45d2356bb725 100644
--- a/drivers/ide/alim15x3.c
+++ b/drivers/ide/alim15x3.c
@@ -591,7 +591,7 @@ static int __init ali15x3_ide_init(void)
591 591
592static void __exit ali15x3_ide_exit(void) 592static void __exit ali15x3_ide_exit(void)
593{ 593{
594 return pci_unregister_driver(&alim15x3_pci_driver); 594 pci_unregister_driver(&alim15x3_pci_driver);
595} 595}
596 596
597module_init(ali15x3_ide_init); 597module_init(ali15x3_ide_init);
diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c
index 81ec73134eda..c6bcd3014a29 100644
--- a/drivers/ide/amd74xx.c
+++ b/drivers/ide/amd74xx.c
@@ -3,7 +3,7 @@
3 * IDE driver for Linux. 3 * IDE driver for Linux.
4 * 4 *
5 * Copyright (c) 2000-2002 Vojtech Pavlik 5 * Copyright (c) 2000-2002 Vojtech Pavlik
6 * Copyright (c) 2007 Bartlomiej Zolnierkiewicz 6 * Copyright (c) 2007-2008 Bartlomiej Zolnierkiewicz
7 * 7 *
8 * Based on the work of: 8 * Based on the work of:
9 * Andre Hedrick 9 * Andre Hedrick
@@ -263,6 +263,15 @@ static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_
263 d.udma_mask = ATA_UDMA5; 263 d.udma_mask = ATA_UDMA5;
264 } 264 }
265 265
266 /*
267 * It seems that on some nVidia controllers using AltStatus
268 * register can be unreliable so default to Status register
269 * if the device is in Compatibility Mode.
270 */
271 if (dev->vendor == PCI_VENDOR_ID_NVIDIA &&
272 ide_pci_is_in_compatibility_mode(dev))
273 d.host_flags |= IDE_HFLAG_BROKEN_ALTSTATUS;
274
266 printk(KERN_INFO "%s %s: UDMA%s controller\n", 275 printk(KERN_INFO "%s %s: UDMA%s controller\n",
267 d.name, pci_name(dev), amd_dma[fls(d.udma_mask) - 1]); 276 d.name, pci_name(dev), amd_dma[fls(d.udma_mask) - 1]);
268 277
diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c
index 53f079cc00af..d8ede85fe17f 100644
--- a/drivers/ide/cs5530.c
+++ b/drivers/ide/cs5530.c
@@ -81,11 +81,12 @@ static u8 cs5530_udma_filter(ide_drive_t *drive)
81{ 81{
82 ide_hwif_t *hwif = drive->hwif; 82 ide_hwif_t *hwif = drive->hwif;
83 ide_drive_t *mate = ide_get_pair_dev(drive); 83 ide_drive_t *mate = ide_get_pair_dev(drive);
84 u16 *mateid = mate->id; 84 u16 *mateid;
85 u8 mask = hwif->ultra_mask; 85 u8 mask = hwif->ultra_mask;
86 86
87 if (mate == NULL) 87 if (mate == NULL)
88 goto out; 88 goto out;
89 mateid = mate->id;
89 90
90 if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) { 91 if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) {
91 if ((mateid[ATA_ID_FIELD_VALID] & 4) && 92 if ((mateid[ATA_ID_FIELD_VALID] & 4) &&
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
index 2d848010499d..81f70caeb40f 100644
--- a/drivers/ide/icside.c
+++ b/drivers/ide/icside.c
@@ -419,7 +419,7 @@ static void icside_setup_ports(hw_regs_t *hw, void __iomem *base,
419 hw->chipset = ide_acorn; 419 hw->chipset = ide_acorn;
420} 420}
421 421
422static int __init 422static int __devinit
423icside_register_v5(struct icside_state *state, struct expansion_card *ec) 423icside_register_v5(struct icside_state *state, struct expansion_card *ec)
424{ 424{
425 void __iomem *base; 425 void __iomem *base;
@@ -473,7 +473,7 @@ static const struct ide_port_info icside_v6_port_info __initdata = {
473 .swdma_mask = ATA_SWDMA2, 473 .swdma_mask = ATA_SWDMA2,
474}; 474};
475 475
476static int __init 476static int __devinit
477icside_register_v6(struct icside_state *state, struct expansion_card *ec) 477icside_register_v6(struct icside_state *state, struct expansion_card *ec)
478{ 478{
479 void __iomem *ioc_base, *easi_base; 479 void __iomem *ioc_base, *easi_base;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 7162d67562af..cc35d6dbd410 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -132,10 +132,14 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
132} 132}
133EXPORT_SYMBOL(ide_end_request); 133EXPORT_SYMBOL(ide_end_request);
134 134
135static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error) 135static void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
136{ 136{
137 struct request_pm_state *pm = rq->data; 137 struct request_pm_state *pm = rq->data;
138 138
139#ifdef DEBUG_PM
140 printk(KERN_INFO "%s: complete_power_step(step: %d)\n",
141 drive->name, pm->pm_step);
142#endif
139 if (drive->media != ide_disk) 143 if (drive->media != ide_disk)
140 return; 144 return;
141 145
@@ -172,7 +176,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
172 /* Not supported? Switch to next step now. */ 176 /* Not supported? Switch to next step now. */
173 if (ata_id_flush_enabled(drive->id) == 0 || 177 if (ata_id_flush_enabled(drive->id) == 0 ||
174 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) { 178 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) {
175 ide_complete_power_step(drive, rq, 0, 0); 179 ide_complete_power_step(drive, rq);
176 return ide_stopped; 180 return ide_stopped;
177 } 181 }
178 if (ata_id_flush_ext_enabled(drive->id)) 182 if (ata_id_flush_ext_enabled(drive->id))
@@ -191,7 +195,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
191 if (drive->media != ide_disk) 195 if (drive->media != ide_disk)
192 pm->pm_step = IDE_PM_RESTORE_DMA; 196 pm->pm_step = IDE_PM_RESTORE_DMA;
193 else 197 else
194 ide_complete_power_step(drive, rq, 0, 0); 198 ide_complete_power_step(drive, rq);
195 return ide_stopped; 199 return ide_stopped;
196 case IDE_PM_IDLE: /* Resume step 2 (idle) */ 200 case IDE_PM_IDLE: /* Resume step 2 (idle) */
197 args->tf.command = ATA_CMD_IDLEIMMEDIATE; 201 args->tf.command = ATA_CMD_IDLEIMMEDIATE;
@@ -322,11 +326,8 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
322 } 326 }
323 } else if (blk_pm_request(rq)) { 327 } else if (blk_pm_request(rq)) {
324 struct request_pm_state *pm = rq->data; 328 struct request_pm_state *pm = rq->data;
325#ifdef DEBUG_PM 329
326 printk("%s: complete_power_step(step: %d, stat: %x, err: %x)\n", 330 ide_complete_power_step(drive, rq);
327 drive->name, rq->pm->pm_step, stat, err);
328#endif
329 ide_complete_power_step(drive, rq, stat, err);
330 if (pm->pm_step == IDE_PM_COMPLETED) 331 if (pm->pm_step == IDE_PM_COMPLETED)
331 ide_complete_pm_request(drive, rq); 332 ide_complete_pm_request(drive, rq);
332 return; 333 return;
@@ -804,7 +805,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
804 struct request_pm_state *pm = rq->data; 805 struct request_pm_state *pm = rq->data;
805#ifdef DEBUG_PM 806#ifdef DEBUG_PM
806 printk("%s: start_power_step(step: %d)\n", 807 printk("%s: start_power_step(step: %d)\n",
807 drive->name, rq->pm->pm_step); 808 drive->name, pm->pm_step);
808#endif 809#endif
809 startstop = ide_start_power_step(drive, rq); 810 startstop = ide_start_power_step(drive, rq);
810 if (startstop == ide_stopped && 811 if (startstop == ide_stopped &&
@@ -967,14 +968,13 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
967 ide_startstop_t startstop; 968 ide_startstop_t startstop;
968 int loops = 0; 969 int loops = 0;
969 970
970 /* for atari only: POSSIBLY BROKEN HERE(?) */
971 ide_get_lock(ide_intr, hwgroup);
972
973 /* caller must own ide_lock */ 971 /* caller must own ide_lock */
974 BUG_ON(!irqs_disabled()); 972 BUG_ON(!irqs_disabled());
975 973
976 while (!hwgroup->busy) { 974 while (!hwgroup->busy) {
977 hwgroup->busy = 1; 975 hwgroup->busy = 1;
976 /* for atari only */
977 ide_get_lock(ide_intr, hwgroup);
978 drive = choose_drive(hwgroup); 978 drive = choose_drive(hwgroup);
979 if (drive == NULL) { 979 if (drive == NULL) {
980 int sleeping = 0; 980 int sleeping = 0;
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 5d6ba14e211d..c41c3b9b6f02 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -457,18 +457,14 @@ int drive_is_ready (ide_drive_t *drive)
457 if (drive->waiting_for_dma) 457 if (drive->waiting_for_dma)
458 return hwif->dma_ops->dma_test_irq(drive); 458 return hwif->dma_ops->dma_test_irq(drive);
459 459
460#if 0
461 /* need to guarantee 400ns since last command was issued */
462 udelay(1);
463#endif
464
465 /* 460 /*
466 * We do a passive status test under shared PCI interrupts on 461 * We do a passive status test under shared PCI interrupts on
467 * cards that truly share the ATA side interrupt, but may also share 462 * cards that truly share the ATA side interrupt, but may also share
468 * an interrupt with another pci card/device. We make no assumptions 463 * an interrupt with another pci card/device. We make no assumptions
469 * about possible isa-pnp and pci-pnp issues yet. 464 * about possible isa-pnp and pci-pnp issues yet.
470 */ 465 */
471 if (hwif->io_ports.ctl_addr) 466 if (hwif->io_ports.ctl_addr &&
467 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0)
472 stat = hwif->tp_ops->read_altstatus(hwif); 468 stat = hwif->tp_ops->read_altstatus(hwif);
473 else 469 else
474 /* Note: this may clear a pending IRQ!! */ 470 /* Note: this may clear a pending IRQ!! */
@@ -610,6 +606,7 @@ static const struct drive_list_entry ivb_list[] = {
610 { "TSSTcorp CDDVDW SH-S202N" , "SB01" }, 606 { "TSSTcorp CDDVDW SH-S202N" , "SB01" },
611 { "TSSTcorp CDDVDW SH-S202H" , "SB00" }, 607 { "TSSTcorp CDDVDW SH-S202H" , "SB00" },
612 { "TSSTcorp CDDVDW SH-S202H" , "SB01" }, 608 { "TSSTcorp CDDVDW SH-S202H" , "SB01" },
609 { "SAMSUNG SP0822N" , "WA100-10" },
613 { NULL , NULL } 610 { NULL , NULL }
614}; 611};
615 612
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 1649ea54f76c..c55bdbd22314 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -266,7 +266,8 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
266 /* take a deep breath */ 266 /* take a deep breath */
267 msleep(50); 267 msleep(50);
268 268
269 if (io_ports->ctl_addr) { 269 if (io_ports->ctl_addr &&
270 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) {
270 a = tp_ops->read_altstatus(hwif); 271 a = tp_ops->read_altstatus(hwif);
271 s = tp_ops->read_status(hwif); 272 s = tp_ops->read_status(hwif);
272 if ((a ^ s) & ~ATA_IDX) 273 if ((a ^ s) & ~ATA_IDX)
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index 2e19d6298536..7c481bb56fab 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -66,7 +66,6 @@ typedef struct pmac_ide_hwif {
66 struct macio_dev *mdev; 66 struct macio_dev *mdev;
67 u32 timings[4]; 67 u32 timings[4];
68 volatile u32 __iomem * *kauai_fcr; 68 volatile u32 __iomem * *kauai_fcr;
69#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
70 /* Those fields are duplicating what is in hwif. We currently 69 /* Those fields are duplicating what is in hwif. We currently
71 * can't use the hwif ones because of some assumptions that are 70 * can't use the hwif ones because of some assumptions that are
72 * beeing done by the generic code about the kind of dma controller 71 * beeing done by the generic code about the kind of dma controller
@@ -74,8 +73,6 @@ typedef struct pmac_ide_hwif {
74 */ 73 */
75 volatile struct dbdma_regs __iomem * dma_regs; 74 volatile struct dbdma_regs __iomem * dma_regs;
76 struct dbdma_cmd* dma_table_cpu; 75 struct dbdma_cmd* dma_table_cpu;
77#endif
78
79} pmac_ide_hwif_t; 76} pmac_ide_hwif_t;
80 77
81enum { 78enum {
@@ -222,8 +219,6 @@ static const char* model_name[] = {
222#define KAUAI_FCR_UATA_RESET_N 0x00000002 219#define KAUAI_FCR_UATA_RESET_N 0x00000002
223#define KAUAI_FCR_UATA_ENABLE 0x00000001 220#define KAUAI_FCR_UATA_ENABLE 0x00000001
224 221
225#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
226
227/* Rounded Multiword DMA timings 222/* Rounded Multiword DMA timings
228 * 223 *
229 * I gave up finding a generic formula for all controller 224 * I gave up finding a generic formula for all controller
@@ -413,8 +408,6 @@ static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq);
413static void pmac_ide_selectproc(ide_drive_t *drive); 408static void pmac_ide_selectproc(ide_drive_t *drive);
414static void pmac_ide_kauai_selectproc(ide_drive_t *drive); 409static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
415 410
416#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
417
418#define PMAC_IDE_REG(x) \ 411#define PMAC_IDE_REG(x) \
419 ((void __iomem *)((drive)->hwif->io_ports.data_addr + (x))) 412 ((void __iomem *)((drive)->hwif->io_ports.data_addr + (x)))
420 413
@@ -584,8 +577,6 @@ pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
584 pmac_ide_do_update_timings(drive); 577 pmac_ide_do_update_timings(drive);
585} 578}
586 579
587#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
588
589/* 580/*
590 * Calculate KeyLargo ATA/66 UDMA timings 581 * Calculate KeyLargo ATA/66 UDMA timings
591 */ 582 */
@@ -786,7 +777,6 @@ set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2,
786 drive->name, speed & 0xf, *timings); 777 drive->name, speed & 0xf, *timings);
787#endif 778#endif
788} 779}
789#endif /* #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC */
790 780
791static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) 781static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed)
792{ 782{
@@ -804,7 +794,6 @@ static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed)
804 tl[0] = *timings; 794 tl[0] = *timings;
805 tl[1] = *timings2; 795 tl[1] = *timings2;
806 796
807#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
808 if (speed >= XFER_UDMA_0) { 797 if (speed >= XFER_UDMA_0) {
809 if (pmif->kind == controller_kl_ata4) 798 if (pmif->kind == controller_kl_ata4)
810 ret = set_timings_udma_ata4(&tl[0], speed); 799 ret = set_timings_udma_ata4(&tl[0], speed);
@@ -817,7 +806,7 @@ static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed)
817 ret = -1; 806 ret = -1;
818 } else 807 } else
819 set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed); 808 set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed);
820#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 809
821 if (ret) 810 if (ret)
822 return; 811 return;
823 812
@@ -1008,9 +997,7 @@ static const struct ide_port_info pmac_port_info = {
1008 .chipset = ide_pmac, 997 .chipset = ide_pmac,
1009 .tp_ops = &pmac_tp_ops, 998 .tp_ops = &pmac_tp_ops,
1010 .port_ops = &pmac_ide_port_ops, 999 .port_ops = &pmac_ide_port_ops,
1011#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
1012 .dma_ops = &pmac_dma_ops, 1000 .dma_ops = &pmac_dma_ops,
1013#endif
1014 .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | 1001 .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA |
1015 IDE_HFLAG_POST_SET_MODE | 1002 IDE_HFLAG_POST_SET_MODE |
1016 IDE_HFLAG_MMIO | 1003 IDE_HFLAG_MMIO |
@@ -1182,7 +1169,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1182 pmif->regbase = regbase; 1169 pmif->regbase = regbase;
1183 pmif->irq = irq; 1170 pmif->irq = irq;
1184 pmif->kauai_fcr = NULL; 1171 pmif->kauai_fcr = NULL;
1185#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 1172
1186 if (macio_resource_count(mdev) >= 2) { 1173 if (macio_resource_count(mdev) >= 2) {
1187 if (macio_request_resource(mdev, 1, "ide-pmac (dma)")) 1174 if (macio_request_resource(mdev, 1, "ide-pmac (dma)"))
1188 printk(KERN_WARNING "ide-pmac: can't request DMA " 1175 printk(KERN_WARNING "ide-pmac: can't request DMA "
@@ -1192,7 +1179,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1192 pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000); 1179 pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000);
1193 } else 1180 } else
1194 pmif->dma_regs = NULL; 1181 pmif->dma_regs = NULL;
1195#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 1182
1196 dev_set_drvdata(&mdev->ofdev.dev, pmif); 1183 dev_set_drvdata(&mdev->ofdev.dev, pmif);
1197 1184
1198 memset(&hw, 0, sizeof(hw)); 1185 memset(&hw, 0, sizeof(hw));
@@ -1300,9 +1287,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1300 1287
1301 base = ioremap(rbase, rlen); 1288 base = ioremap(rbase, rlen);
1302 pmif->regbase = (unsigned long) base + 0x2000; 1289 pmif->regbase = (unsigned long) base + 0x2000;
1303#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
1304 pmif->dma_regs = base + 0x1000; 1290 pmif->dma_regs = base + 0x1000;
1305#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
1306 pmif->kauai_fcr = base; 1291 pmif->kauai_fcr = base;
1307 pmif->irq = pdev->irq; 1292 pmif->irq = pdev->irq;
1308 1293
@@ -1434,8 +1419,6 @@ out:
1434 return error; 1419 return error;
1435} 1420}
1436 1421
1437#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
1438
1439/* 1422/*
1440 * pmac_ide_build_dmatable builds the DBDMA command list 1423 * pmac_ide_build_dmatable builds the DBDMA command list
1441 * for a transfer and sets the DBDMA channel to point to it. 1424 * for a transfer and sets the DBDMA channel to point to it.
@@ -1723,13 +1706,6 @@ static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif,
1723 1706
1724 return 0; 1707 return 0;
1725} 1708}
1726#else
1727static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif,
1728 const struct ide_port_info *d)
1729{
1730 return -EOPNOTSUPP;
1731}
1732#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
1733 1709
1734module_init(pmac_ide_probe); 1710module_init(pmac_ide_probe);
1735 1711
diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.c
index f1a8758e3a99..ec7f766ef5e4 100644
--- a/drivers/ide/sc1200.c
+++ b/drivers/ide/sc1200.c
@@ -104,11 +104,12 @@ static u8 sc1200_udma_filter(ide_drive_t *drive)
104{ 104{
105 ide_hwif_t *hwif = drive->hwif; 105 ide_hwif_t *hwif = drive->hwif;
106 ide_drive_t *mate = ide_get_pair_dev(drive); 106 ide_drive_t *mate = ide_get_pair_dev(drive);
107 u16 *mateid = mate->id; 107 u16 *mateid;
108 u8 mask = hwif->ultra_mask; 108 u8 mask = hwif->ultra_mask;
109 109
110 if (mate == NULL) 110 if (mate == NULL)
111 goto out; 111 goto out;
112 mateid = mate->id;
112 113
113 if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) { 114 if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) {
114 if ((mateid[ATA_ID_FIELD_VALID] & 4) && 115 if ((mateid[ATA_ID_FIELD_VALID] & 4) &&
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c
index 7defa0ae2014..a687a7dfea6f 100644
--- a/drivers/ide/sgiioc4.c
+++ b/drivers/ide/sgiioc4.c
@@ -550,7 +550,7 @@ static const struct ide_dma_ops sgiioc4_dma_ops = {
550 .dma_timeout = ide_dma_timeout, 550 .dma_timeout = ide_dma_timeout,
551}; 551};
552 552
553static const struct ide_port_info sgiioc4_port_info __devinitdata = { 553static const struct ide_port_info sgiioc4_port_info __devinitconst = {
554 .name = DRV_NAME, 554 .name = DRV_NAME,
555 .chipset = ide_pci, 555 .chipset = ide_pci,
556 .init_dma = ide_dma_sgiioc4, 556 .init_dma = ide_dma_sgiioc4,
@@ -633,7 +633,7 @@ out:
633 return ret; 633 return ret;
634} 634}
635 635
636int 636int __devinit
637ioc4_ide_attach_one(struct ioc4_driver_data *idd) 637ioc4_ide_attach_one(struct ioc4_driver_data *idd)
638{ 638{
639 /* PCI-RT does not bring out IDE connection. 639 /* PCI-RT does not bring out IDE connection.
@@ -645,7 +645,7 @@ ioc4_ide_attach_one(struct ioc4_driver_data *idd)
645 return pci_init_sgiioc4(idd->idd_pdev); 645 return pci_init_sgiioc4(idd->idd_pdev);
646} 646}
647 647
648static struct ioc4_submodule ioc4_ide_submodule = { 648static struct ioc4_submodule __devinitdata ioc4_ide_submodule = {
649 .is_name = "IOC4_ide", 649 .is_name = "IOC4_ide",
650 .is_owner = THIS_MODULE, 650 .is_owner = THIS_MODULE,
651 .is_probe = ioc4_ide_attach_one, 651 .is_probe = ioc4_ide_attach_one,
diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c
index 918ffc4fc8ac..272543a42a43 100644
--- a/drivers/ieee1394/highlevel.c
+++ b/drivers/ieee1394/highlevel.c
@@ -46,10 +46,6 @@ static DEFINE_RWLOCK(hl_irqs_lock);
46 46
47static DEFINE_RWLOCK(addr_space_lock); 47static DEFINE_RWLOCK(addr_space_lock);
48 48
49/* addr_space list will have zero and max already included as bounds */
50static struct hpsb_address_ops dummy_ops = { NULL, NULL, NULL, NULL };
51static struct hpsb_address_serve dummy_zero_addr, dummy_max_addr;
52
53 49
54static struct hl_host_info *hl_get_hostinfo(struct hpsb_highlevel *hl, 50static struct hl_host_info *hl_get_hostinfo(struct hpsb_highlevel *hl,
55 struct hpsb_host *host) 51 struct hpsb_host *host)
@@ -481,20 +477,23 @@ int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
481 return retval; 477 return retval;
482} 478}
483 479
480static struct hpsb_address_ops dummy_ops;
481
482/* dummy address spaces as lower and upper bounds of the host's a.s. list */
484static void init_hpsb_highlevel(struct hpsb_host *host) 483static void init_hpsb_highlevel(struct hpsb_host *host)
485{ 484{
486 INIT_LIST_HEAD(&dummy_zero_addr.host_list); 485 INIT_LIST_HEAD(&host->dummy_zero_addr.host_list);
487 INIT_LIST_HEAD(&dummy_zero_addr.hl_list); 486 INIT_LIST_HEAD(&host->dummy_zero_addr.hl_list);
488 INIT_LIST_HEAD(&dummy_max_addr.host_list); 487 INIT_LIST_HEAD(&host->dummy_max_addr.host_list);
489 INIT_LIST_HEAD(&dummy_max_addr.hl_list); 488 INIT_LIST_HEAD(&host->dummy_max_addr.hl_list);
490 489
491 dummy_zero_addr.op = dummy_max_addr.op = &dummy_ops; 490 host->dummy_zero_addr.op = host->dummy_max_addr.op = &dummy_ops;
492 491
493 dummy_zero_addr.start = dummy_zero_addr.end = 0; 492 host->dummy_zero_addr.start = host->dummy_zero_addr.end = 0;
494 dummy_max_addr.start = dummy_max_addr.end = ((u64) 1) << 48; 493 host->dummy_max_addr.start = host->dummy_max_addr.end = ((u64) 1) << 48;
495 494
496 list_add_tail(&dummy_zero_addr.host_list, &host->addr_space); 495 list_add_tail(&host->dummy_zero_addr.host_list, &host->addr_space);
497 list_add_tail(&dummy_max_addr.host_list, &host->addr_space); 496 list_add_tail(&host->dummy_max_addr.host_list, &host->addr_space);
498} 497}
499 498
500void highlevel_add_host(struct hpsb_host *host) 499void highlevel_add_host(struct hpsb_host *host)
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index e4e8aeb4d778..dd229950acca 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -13,6 +13,7 @@ struct module;
13 13
14#include "ieee1394_types.h" 14#include "ieee1394_types.h"
15#include "csr.h" 15#include "csr.h"
16#include "highlevel.h"
16 17
17struct hpsb_packet; 18struct hpsb_packet;
18struct hpsb_iso; 19struct hpsb_iso;
@@ -72,6 +73,9 @@ struct hpsb_host {
72 struct { DECLARE_BITMAP(map, 64); } tl_pool[ALL_NODES]; 73 struct { DECLARE_BITMAP(map, 64); } tl_pool[ALL_NODES];
73 74
74 struct csr_control csr; 75 struct csr_control csr;
76
77 struct hpsb_address_serve dummy_zero_addr;
78 struct hpsb_address_serve dummy_max_addr;
75}; 79};
76 80
77enum devctl_cmd { 81enum devctl_cmd {
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 9e39f73282ee..79ef5fd928ae 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -115,8 +115,14 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
115 return error; 115 return error;
116} 116}
117 117
118#define OUI_FREECOM_TECHNOLOGIES_GMBH 0x0001db
119
118static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci) 120static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci)
119{ 121{
122 /* Freecom FireWire Hard Drive firmware bug */
123 if (be32_to_cpu(bus_info_data[3]) >> 8 == OUI_FREECOM_TECHNOLOGIES_GMBH)
124 return 0;
125
120 return (be32_to_cpu(bus_info_data[2]) >> 8) & 0x3; 126 return (be32_to_cpu(bus_info_data[2]) >> 8) & 0x3;
121} 127}
122 128
@@ -1685,6 +1691,7 @@ static int nodemgr_host_thread(void *data)
1685 g = get_hpsb_generation(host); 1691 g = get_hpsb_generation(host);
1686 for (i = 0; i < 4 ; i++) { 1692 for (i = 0; i < 4 ; i++) {
1687 msleep_interruptible(63); 1693 msleep_interruptible(63);
1694 try_to_freeze();
1688 if (kthread_should_stop()) 1695 if (kthread_should_stop())
1689 goto exit; 1696 goto exit;
1690 1697
@@ -1725,6 +1732,7 @@ static int nodemgr_host_thread(void *data)
1725 /* Sleep 3 seconds */ 1732 /* Sleep 3 seconds */
1726 for (i = 3000/200; i; i--) { 1733 for (i = 3000/200; i; i--) {
1727 msleep_interruptible(200); 1734 msleep_interruptible(200);
1735 try_to_freeze();
1728 if (kthread_should_stop()) 1736 if (kthread_should_stop())
1729 goto exit; 1737 goto exit;
1730 1738
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index c52f6e6e8af2..a373c18cf7b8 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -402,6 +402,11 @@ static const struct {
402 }, 402 },
403 /* iPod mini */ { 403 /* iPod mini */ {
404 .firmware_revision = 0x0a2700, 404 .firmware_revision = 0x0a2700,
405 .model_id = 0x000022,
406 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
407 },
408 /* iPod mini */ {
409 .firmware_revision = 0x0a2700,
405 .model_id = 0x000023, 410 .model_id = 0x000023,
406 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 411 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
407 }, 412 },
@@ -890,12 +895,13 @@ static void sbp2_host_reset(struct hpsb_host *host)
890 return; 895 return;
891 896
892 read_lock_irqsave(&sbp2_hi_logical_units_lock, flags); 897 read_lock_irqsave(&sbp2_hi_logical_units_lock, flags);
898
893 list_for_each_entry(lu, &hi->logical_units, lu_list) 899 list_for_each_entry(lu, &hi->logical_units, lu_list)
894 if (likely(atomic_read(&lu->state) != 900 if (atomic_cmpxchg(&lu->state,
895 SBP2LU_STATE_IN_SHUTDOWN)) { 901 SBP2LU_STATE_RUNNING, SBP2LU_STATE_IN_RESET)
896 atomic_set(&lu->state, SBP2LU_STATE_IN_RESET); 902 == SBP2LU_STATE_RUNNING)
897 scsi_block_requests(lu->shost); 903 scsi_block_requests(lu->shost);
898 } 904
899 read_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags); 905 read_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags);
900} 906}
901 907
diff --git a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h
index 4df887af66a5..7fc35cf0cddf 100644
--- a/drivers/infiniband/hw/ehca/ehca_classes.h
+++ b/drivers/infiniband/hw/ehca/ehca_classes.h
@@ -163,7 +163,8 @@ struct ehca_mod_qp_parm {
163/* struct for tracking if cqes have been reported to the application */ 163/* struct for tracking if cqes have been reported to the application */
164struct ehca_qmap_entry { 164struct ehca_qmap_entry {
165 u16 app_wr_id; 165 u16 app_wr_id;
166 u16 reported; 166 u8 reported;
167 u8 cqe_req;
167}; 168};
168 169
169struct ehca_queue_map { 170struct ehca_queue_map {
@@ -171,6 +172,7 @@ struct ehca_queue_map {
171 unsigned int entries; 172 unsigned int entries;
172 unsigned int tail; 173 unsigned int tail;
173 unsigned int left_to_poll; 174 unsigned int left_to_poll;
175 unsigned int next_wqe_idx; /* Idx to first wqe to be flushed */
174}; 176};
175 177
176struct ehca_qp { 178struct ehca_qp {
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index bb02a86aa526..bec7e0249358 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -994,8 +994,7 @@ static int ehca_mem_notifier(struct notifier_block *nb,
994 if (printk_timed_ratelimit(&ehca_dmem_warn_time, 994 if (printk_timed_ratelimit(&ehca_dmem_warn_time,
995 30 * 1000)) 995 30 * 1000))
996 ehca_gen_err("DMEM operations are not allowed" 996 ehca_gen_err("DMEM operations are not allowed"
997 "as long as an ehca adapter is" 997 "in conjunction with eHCA");
998 "attached to the LPAR");
999 return NOTIFY_BAD; 998 return NOTIFY_BAD;
1000 } 999 }
1001 } 1000 }
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 9e05ee2db39b..cadbf0cdd910 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -435,9 +435,13 @@ static void reset_queue_map(struct ehca_queue_map *qmap)
435{ 435{
436 int i; 436 int i;
437 437
438 qmap->tail = 0; 438 qmap->tail = qmap->entries - 1;
439 for (i = 0; i < qmap->entries; i++) 439 qmap->left_to_poll = 0;
440 qmap->next_wqe_idx = 0;
441 for (i = 0; i < qmap->entries; i++) {
440 qmap->map[i].reported = 1; 442 qmap->map[i].reported = 1;
443 qmap->map[i].cqe_req = 0;
444 }
441} 445}
442 446
443/* 447/*
@@ -1121,6 +1125,7 @@ static int calc_left_cqes(u64 wqe_p, struct ipz_queue *ipz_queue,
1121 void *wqe_v; 1125 void *wqe_v;
1122 u64 q_ofs; 1126 u64 q_ofs;
1123 u32 wqe_idx; 1127 u32 wqe_idx;
1128 unsigned int tail_idx;
1124 1129
1125 /* convert real to abs address */ 1130 /* convert real to abs address */
1126 wqe_p = wqe_p & (~(1UL << 63)); 1131 wqe_p = wqe_p & (~(1UL << 63));
@@ -1133,12 +1138,17 @@ static int calc_left_cqes(u64 wqe_p, struct ipz_queue *ipz_queue,
1133 return -EFAULT; 1138 return -EFAULT;
1134 } 1139 }
1135 1140
1141 tail_idx = (qmap->tail + 1) % qmap->entries;
1136 wqe_idx = q_ofs / ipz_queue->qe_size; 1142 wqe_idx = q_ofs / ipz_queue->qe_size;
1137 if (wqe_idx < qmap->tail)
1138 qmap->left_to_poll = (qmap->entries - qmap->tail) + wqe_idx;
1139 else
1140 qmap->left_to_poll = wqe_idx - qmap->tail;
1141 1143
1144 /* check all processed wqes, whether a cqe is requested or not */
1145 while (tail_idx != wqe_idx) {
1146 if (qmap->map[tail_idx].cqe_req)
1147 qmap->left_to_poll++;
1148 tail_idx = (tail_idx + 1) % qmap->entries;
1149 }
1150 /* save index in queue, where we have to start flushing */
1151 qmap->next_wqe_idx = wqe_idx;
1142 return 0; 1152 return 0;
1143} 1153}
1144 1154
@@ -1185,10 +1195,14 @@ static int check_for_left_cqes(struct ehca_qp *my_qp, struct ehca_shca *shca)
1185 } else { 1195 } else {
1186 spin_lock_irqsave(&my_qp->send_cq->spinlock, flags); 1196 spin_lock_irqsave(&my_qp->send_cq->spinlock, flags);
1187 my_qp->sq_map.left_to_poll = 0; 1197 my_qp->sq_map.left_to_poll = 0;
1198 my_qp->sq_map.next_wqe_idx = (my_qp->sq_map.tail + 1) %
1199 my_qp->sq_map.entries;
1188 spin_unlock_irqrestore(&my_qp->send_cq->spinlock, flags); 1200 spin_unlock_irqrestore(&my_qp->send_cq->spinlock, flags);
1189 1201
1190 spin_lock_irqsave(&my_qp->recv_cq->spinlock, flags); 1202 spin_lock_irqsave(&my_qp->recv_cq->spinlock, flags);
1191 my_qp->rq_map.left_to_poll = 0; 1203 my_qp->rq_map.left_to_poll = 0;
1204 my_qp->rq_map.next_wqe_idx = (my_qp->rq_map.tail + 1) %
1205 my_qp->rq_map.entries;
1192 spin_unlock_irqrestore(&my_qp->recv_cq->spinlock, flags); 1206 spin_unlock_irqrestore(&my_qp->recv_cq->spinlock, flags);
1193 } 1207 }
1194 1208
diff --git a/drivers/infiniband/hw/ehca/ehca_reqs.c b/drivers/infiniband/hw/ehca/ehca_reqs.c
index 64928079eafa..00a648f4316c 100644
--- a/drivers/infiniband/hw/ehca/ehca_reqs.c
+++ b/drivers/infiniband/hw/ehca/ehca_reqs.c
@@ -179,6 +179,7 @@ static inline int ehca_write_swqe(struct ehca_qp *qp,
179 179
180 qmap_entry->app_wr_id = get_app_wr_id(send_wr->wr_id); 180 qmap_entry->app_wr_id = get_app_wr_id(send_wr->wr_id);
181 qmap_entry->reported = 0; 181 qmap_entry->reported = 0;
182 qmap_entry->cqe_req = 0;
182 183
183 switch (send_wr->opcode) { 184 switch (send_wr->opcode) {
184 case IB_WR_SEND: 185 case IB_WR_SEND:
@@ -203,8 +204,10 @@ static inline int ehca_write_swqe(struct ehca_qp *qp,
203 204
204 if ((send_wr->send_flags & IB_SEND_SIGNALED || 205 if ((send_wr->send_flags & IB_SEND_SIGNALED ||
205 qp->init_attr.sq_sig_type == IB_SIGNAL_ALL_WR) 206 qp->init_attr.sq_sig_type == IB_SIGNAL_ALL_WR)
206 && !hidden) 207 && !hidden) {
207 wqe_p->wr_flag |= WQE_WRFLAG_REQ_SIGNAL_COM; 208 wqe_p->wr_flag |= WQE_WRFLAG_REQ_SIGNAL_COM;
209 qmap_entry->cqe_req = 1;
210 }
208 211
209 if (send_wr->opcode == IB_WR_SEND_WITH_IMM || 212 if (send_wr->opcode == IB_WR_SEND_WITH_IMM ||
210 send_wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) { 213 send_wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) {
@@ -569,6 +572,7 @@ static int internal_post_recv(struct ehca_qp *my_qp,
569 qmap_entry = &my_qp->rq_map.map[rq_map_idx]; 572 qmap_entry = &my_qp->rq_map.map[rq_map_idx];
570 qmap_entry->app_wr_id = get_app_wr_id(cur_recv_wr->wr_id); 573 qmap_entry->app_wr_id = get_app_wr_id(cur_recv_wr->wr_id);
571 qmap_entry->reported = 0; 574 qmap_entry->reported = 0;
575 qmap_entry->cqe_req = 1;
572 576
573 wqe_cnt++; 577 wqe_cnt++;
574 } /* eof for cur_recv_wr */ 578 } /* eof for cur_recv_wr */
@@ -706,27 +710,34 @@ repoll:
706 goto repoll; 710 goto repoll;
707 wc->qp = &my_qp->ib_qp; 711 wc->qp = &my_qp->ib_qp;
708 712
713 qmap_tail_idx = get_app_wr_id(cqe->work_request_id);
714 if (!(cqe->w_completion_flags & WC_SEND_RECEIVE_BIT))
715 /* We got a send completion. */
716 qmap = &my_qp->sq_map;
717 else
718 /* We got a receive completion. */
719 qmap = &my_qp->rq_map;
720
721 /* advance the tail pointer */
722 qmap->tail = qmap_tail_idx;
723
709 if (is_error) { 724 if (is_error) {
710 /* 725 /*
711 * set left_to_poll to 0 because in error state, we will not 726 * set left_to_poll to 0 because in error state, we will not
712 * get any additional CQEs 727 * get any additional CQEs
713 */ 728 */
714 ehca_add_to_err_list(my_qp, 1); 729 my_qp->sq_map.next_wqe_idx = (my_qp->sq_map.tail + 1) %
730 my_qp->sq_map.entries;
715 my_qp->sq_map.left_to_poll = 0; 731 my_qp->sq_map.left_to_poll = 0;
732 ehca_add_to_err_list(my_qp, 1);
716 733
734 my_qp->rq_map.next_wqe_idx = (my_qp->rq_map.tail + 1) %
735 my_qp->rq_map.entries;
736 my_qp->rq_map.left_to_poll = 0;
717 if (HAS_RQ(my_qp)) 737 if (HAS_RQ(my_qp))
718 ehca_add_to_err_list(my_qp, 0); 738 ehca_add_to_err_list(my_qp, 0);
719 my_qp->rq_map.left_to_poll = 0;
720 } 739 }
721 740
722 qmap_tail_idx = get_app_wr_id(cqe->work_request_id);
723 if (!(cqe->w_completion_flags & WC_SEND_RECEIVE_BIT))
724 /* We got a send completion. */
725 qmap = &my_qp->sq_map;
726 else
727 /* We got a receive completion. */
728 qmap = &my_qp->rq_map;
729
730 qmap_entry = &qmap->map[qmap_tail_idx]; 741 qmap_entry = &qmap->map[qmap_tail_idx];
731 if (qmap_entry->reported) { 742 if (qmap_entry->reported) {
732 ehca_warn(cq->device, "Double cqe on qp_num=%#x", 743 ehca_warn(cq->device, "Double cqe on qp_num=%#x",
@@ -738,10 +749,6 @@ repoll:
738 wc->wr_id = replace_wr_id(cqe->work_request_id, qmap_entry->app_wr_id); 749 wc->wr_id = replace_wr_id(cqe->work_request_id, qmap_entry->app_wr_id);
739 qmap_entry->reported = 1; 750 qmap_entry->reported = 1;
740 751
741 /* this is a proper completion, we need to advance the tail pointer */
742 if (++qmap->tail == qmap->entries)
743 qmap->tail = 0;
744
745 /* if left_to_poll is decremented to 0, add the QP to the error list */ 752 /* if left_to_poll is decremented to 0, add the QP to the error list */
746 if (qmap->left_to_poll > 0) { 753 if (qmap->left_to_poll > 0) {
747 qmap->left_to_poll--; 754 qmap->left_to_poll--;
@@ -805,13 +812,14 @@ static int generate_flush_cqes(struct ehca_qp *my_qp, struct ib_cq *cq,
805 else 812 else
806 qmap = &my_qp->rq_map; 813 qmap = &my_qp->rq_map;
807 814
808 qmap_entry = &qmap->map[qmap->tail]; 815 qmap_entry = &qmap->map[qmap->next_wqe_idx];
809 816
810 while ((nr < num_entries) && (qmap_entry->reported == 0)) { 817 while ((nr < num_entries) && (qmap_entry->reported == 0)) {
811 /* generate flush CQE */ 818 /* generate flush CQE */
819
812 memset(wc, 0, sizeof(*wc)); 820 memset(wc, 0, sizeof(*wc));
813 821
814 offset = qmap->tail * ipz_queue->qe_size; 822 offset = qmap->next_wqe_idx * ipz_queue->qe_size;
815 wqe = (struct ehca_wqe *)ipz_qeit_calc(ipz_queue, offset); 823 wqe = (struct ehca_wqe *)ipz_qeit_calc(ipz_queue, offset);
816 if (!wqe) { 824 if (!wqe) {
817 ehca_err(cq->device, "Invalid wqe offset=%#lx on " 825 ehca_err(cq->device, "Invalid wqe offset=%#lx on "
@@ -850,11 +858,12 @@ static int generate_flush_cqes(struct ehca_qp *my_qp, struct ib_cq *cq,
850 858
851 wc->qp = &my_qp->ib_qp; 859 wc->qp = &my_qp->ib_qp;
852 860
853 /* mark as reported and advance tail pointer */ 861 /* mark as reported and advance next_wqe pointer */
854 qmap_entry->reported = 1; 862 qmap_entry->reported = 1;
855 if (++qmap->tail == qmap->entries) 863 qmap->next_wqe_idx++;
856 qmap->tail = 0; 864 if (qmap->next_wqe_idx == qmap->entries)
857 qmap_entry = &qmap->map[qmap->tail]; 865 qmap->next_wqe_idx = 0;
866 qmap_entry = &qmap->map[qmap->next_wqe_idx];
858 867
859 wc++; nr++; 868 wc++; nr++;
860 } 869 }
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index d0866a3636e2..18308494a195 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -343,6 +343,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
343{ 343{
344 struct mlx4_ib_dev *dev = to_mdev(ibcq->device); 344 struct mlx4_ib_dev *dev = to_mdev(ibcq->device);
345 struct mlx4_ib_cq *cq = to_mcq(ibcq); 345 struct mlx4_ib_cq *cq = to_mcq(ibcq);
346 struct mlx4_mtt mtt;
346 int outst_cqe; 347 int outst_cqe;
347 int err; 348 int err;
348 349
@@ -376,10 +377,13 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
376 goto out; 377 goto out;
377 } 378 }
378 379
380 mtt = cq->buf.mtt;
381
379 err = mlx4_cq_resize(dev->dev, &cq->mcq, entries, &cq->resize_buf->buf.mtt); 382 err = mlx4_cq_resize(dev->dev, &cq->mcq, entries, &cq->resize_buf->buf.mtt);
380 if (err) 383 if (err)
381 goto err_buf; 384 goto err_buf;
382 385
386 mlx4_mtt_cleanup(dev->dev, &mtt);
383 if (ibcq->uobject) { 387 if (ibcq->uobject) {
384 cq->buf = cq->resize_buf->buf; 388 cq->buf = cq->resize_buf->buf;
385 cq->ibcq.cqe = cq->resize_buf->cqe; 389 cq->ibcq.cqe = cq->resize_buf->cqe;
@@ -406,6 +410,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
406 goto out; 410 goto out;
407 411
408err_buf: 412err_buf:
413 mlx4_mtt_cleanup(dev->dev, &cq->resize_buf->buf.mtt);
409 if (!ibcq->uobject) 414 if (!ibcq->uobject)
410 mlx4_ib_free_cq_buf(dev, &cq->resize_buf->buf, 415 mlx4_ib_free_cq_buf(dev, &cq->resize_buf->buf,
411 cq->resize_buf->cqe); 416 cq->resize_buf->cqe);
diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c
index 6790e975a98c..bc4e40f3ede7 100644
--- a/drivers/input/ff-memless.c
+++ b/drivers/input/ff-memless.c
@@ -397,8 +397,9 @@ static int ml_ff_playback(struct input_dev *dev, int effect_id, int value)
397{ 397{
398 struct ml_device *ml = dev->ff->private; 398 struct ml_device *ml = dev->ff->private;
399 struct ml_effect_state *state = &ml->states[effect_id]; 399 struct ml_effect_state *state = &ml->states[effect_id];
400 unsigned long flags;
400 401
401 spin_lock_bh(&ml->timer_lock); 402 spin_lock_irqsave(&ml->timer_lock, flags);
402 403
403 if (value > 0) { 404 if (value > 0) {
404 debug("initiated play"); 405 debug("initiated play");
@@ -424,7 +425,7 @@ static int ml_ff_playback(struct input_dev *dev, int effect_id, int value)
424 ml_play_effects(ml); 425 ml_play_effects(ml);
425 } 426 }
426 427
427 spin_unlock_bh(&ml->timer_lock); 428 spin_unlock_irqrestore(&ml->timer_lock, flags);
428 429
429 return 0; 430 return 0;
430} 431}
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 22016ca15351..379b7ff354ec 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -824,7 +824,7 @@ static void atkbd_disconnect(struct serio *serio)
824 atkbd_disable(atkbd); 824 atkbd_disable(atkbd);
825 825
826 /* make sure we don't have a command in flight */ 826 /* make sure we don't have a command in flight */
827 flush_scheduled_work(); 827 cancel_delayed_work_sync(&atkbd->event_work);
828 828
829 sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group); 829 sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group);
830 input_unregister_device(atkbd->dev); 830 input_unregister_device(atkbd->dev);
@@ -868,6 +868,22 @@ static void atkbd_hp_keymap_fixup(struct atkbd *atkbd)
868} 868}
869 869
870/* 870/*
871 * Inventec system with broken key release on volume keys
872 */
873static void atkbd_inventec_keymap_fixup(struct atkbd *atkbd)
874{
875 const unsigned int forced_release_keys[] = {
876 0xae, 0xb0,
877 };
878 int i;
879
880 if (atkbd->set == 2)
881 for (i = 0; i < ARRAY_SIZE(forced_release_keys); i++)
882 __set_bit(forced_release_keys[i],
883 atkbd->force_release_mask);
884}
885
886/*
871 * atkbd_set_keycode_table() initializes keyboard's keycode table 887 * atkbd_set_keycode_table() initializes keyboard's keycode table
872 * according to the selected scancode set 888 * according to the selected scancode set
873 */ 889 */
@@ -1468,6 +1484,15 @@ static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1468 .callback = atkbd_setup_fixup, 1484 .callback = atkbd_setup_fixup,
1469 .driver_data = atkbd_hp_keymap_fixup, 1485 .driver_data = atkbd_hp_keymap_fixup,
1470 }, 1486 },
1487 {
1488 .ident = "Inventec Symphony",
1489 .matches = {
1490 DMI_MATCH(DMI_SYS_VENDOR, "INVENTEC"),
1491 DMI_MATCH(DMI_PRODUCT_NAME, "SYMPHONY 6.0/7.0"),
1492 },
1493 .callback = atkbd_setup_fixup,
1494 .driver_data = atkbd_inventec_keymap_fixup,
1495 },
1471 { } 1496 { }
1472}; 1497};
1473 1498
diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
index bce160f4349b..86457feccfc4 100644
--- a/drivers/input/misc/cm109.c
+++ b/drivers/input/misc/cm109.c
@@ -42,7 +42,7 @@
42 42
43static char *phone = "kip1000"; 43static char *phone = "kip1000";
44module_param(phone, charp, S_IRUSR); 44module_param(phone, charp, S_IRUSR);
45MODULE_PARM_DESC(phone, "Phone name {kip1000, gtalk, usbph01}"); 45MODULE_PARM_DESC(phone, "Phone name {kip1000, gtalk, usbph01, atcom}");
46 46
47enum { 47enum {
48 /* HID Registers */ 48 /* HID Registers */
@@ -258,6 +258,37 @@ static unsigned short keymap_usbph01(int scancode)
258 } 258 }
259} 259}
260 260
261/*
262 * Keymap for ATCom AU-100
263 * http://www.atcom.cn/En_products_AU100.html
264 * http://www.packetizer.com/products/au100/
265 * http://www.voip-info.org/wiki/view/AU-100
266 *
267 * Contributed by daniel@gimpelevich.san-francisco.ca.us
268 */
269static unsigned short keymap_atcom(int scancode)
270{
271 switch (scancode) { /* phone key: */
272 case 0x82: return KEY_NUMERIC_0; /* 0 */
273 case 0x11: return KEY_NUMERIC_1; /* 1 */
274 case 0x12: return KEY_NUMERIC_2; /* 2 */
275 case 0x14: return KEY_NUMERIC_3; /* 3 */
276 case 0x21: return KEY_NUMERIC_4; /* 4 */
277 case 0x22: return KEY_NUMERIC_5; /* 5 */
278 case 0x24: return KEY_NUMERIC_6; /* 6 */
279 case 0x41: return KEY_NUMERIC_7; /* 7 */
280 case 0x42: return KEY_NUMERIC_8; /* 8 */
281 case 0x44: return KEY_NUMERIC_9; /* 9 */
282 case 0x84: return KEY_NUMERIC_POUND; /* # */
283 case 0x81: return KEY_NUMERIC_STAR; /* * */
284 case 0x18: return KEY_ENTER; /* pickup */
285 case 0x28: return KEY_ESC; /* hangup */
286 case 0x48: return KEY_LEFT; /* left arrow */
287 case 0x88: return KEY_RIGHT; /* right arrow */
288 default: return special_keymap(scancode);
289 }
290}
291
261static unsigned short (*keymap)(int) = keymap_kip1000; 292static unsigned short (*keymap)(int) = keymap_kip1000;
262 293
263/* 294/*
@@ -840,6 +871,10 @@ static int __init cm109_select_keymap(void)
840 keymap = keymap_usbph01; 871 keymap = keymap_usbph01;
841 printk(KERN_INFO KBUILD_MODNAME ": " 872 printk(KERN_INFO KBUILD_MODNAME ": "
842 "Keymap for Allied-Telesis Corega USBPH01 phone loaded\n"); 873 "Keymap for Allied-Telesis Corega USBPH01 phone loaded\n");
874 } else if (!strcasecmp(phone, "atcom")) {
875 keymap = keymap_atcom;
876 printk(KERN_INFO KBUILD_MODNAME ": "
877 "Keymap for ATCom AU-100 phone loaded\n");
843 } else { 878 } else {
844 printk(KERN_ERR KBUILD_MODNAME ": " 879 printk(KERN_ERR KBUILD_MODNAME ": "
845 "Unsupported phone: %s\n", phone); 880 "Unsupported phone: %s\n", phone);
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index e82d34201e97..88f04bf2ad6c 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -125,7 +125,7 @@ static void hgpk_spewing_hack(struct psmouse *psmouse,
125 */ 125 */
126static int hgpk_validate_byte(unsigned char *packet) 126static int hgpk_validate_byte(unsigned char *packet)
127{ 127{
128 return (packet[0] & 0x0C) == 0x08; 128 return (packet[0] & 0x0C) != 0x08;
129} 129}
130 130
131static void hgpk_process_packet(struct psmouse *psmouse) 131static void hgpk_process_packet(struct psmouse *psmouse)
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index eec375cd10e6..29e686388a2c 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -337,6 +337,20 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
337 DMI_MATCH(DMI_PRODUCT_NAME, "2656"), 337 DMI_MATCH(DMI_PRODUCT_NAME, "2656"),
338 }, 338 },
339 }, 339 },
340 {
341 .ident = "Dell XPS M1530",
342 .matches = {
343 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
344 DMI_MATCH(DMI_PRODUCT_NAME, "XPS M1530"),
345 },
346 },
347 {
348 .ident = "Compal HEL80I",
349 .matches = {
350 DMI_MATCH(DMI_SYS_VENDOR, "COMPAL"),
351 DMI_MATCH(DMI_PRODUCT_NAME, "HEL80I"),
352 },
353 },
340 { } 354 { }
341}; 355};
342 356
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index ca62ec639f8f..677680e9f54f 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -66,6 +66,7 @@
66 * - Support Intuos3 4x6 66 * - Support Intuos3 4x6
67 * v1.47 (pc) - Added support for Bamboo 67 * v1.47 (pc) - Added support for Bamboo
68 * v1.48 (pc) - Added support for Bamboo1, BambooFun, and Cintiq 12WX 68 * v1.48 (pc) - Added support for Bamboo1, BambooFun, and Cintiq 12WX
69 * v1.49 (pc) - Added support for USB Tablet PC (0x90, 0x93, and 0x9A)
69 */ 70 */
70 71
71/* 72/*
@@ -86,7 +87,7 @@
86/* 87/*
87 * Version Information 88 * Version Information
88 */ 89 */
89#define DRIVER_VERSION "v1.48" 90#define DRIVER_VERSION "v1.49"
90#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" 91#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
91#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" 92#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
92#define DRIVER_LICENSE "GPL" 93#define DRIVER_LICENSE "GPL"
@@ -103,15 +104,15 @@ struct wacom {
103 struct usb_device *usbdev; 104 struct usb_device *usbdev;
104 struct usb_interface *intf; 105 struct usb_interface *intf;
105 struct urb *irq; 106 struct urb *irq;
106 struct wacom_wac * wacom_wac; 107 struct wacom_wac *wacom_wac;
107 struct mutex lock; 108 struct mutex lock;
108 unsigned int open:1; 109 unsigned int open:1;
109 char phys[32]; 110 char phys[32];
110}; 111};
111 112
112struct wacom_combo { 113struct wacom_combo {
113 struct wacom * wacom; 114 struct wacom *wacom;
114 struct urb * urb; 115 struct urb *urb;
115}; 116};
116 117
117extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 118extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
@@ -132,7 +133,7 @@ extern void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wa
132extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 133extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
133extern __u16 wacom_le16_to_cpu(unsigned char *data); 134extern __u16 wacom_le16_to_cpu(unsigned char *data);
134extern __u16 wacom_be16_to_cpu(unsigned char *data); 135extern __u16 wacom_be16_to_cpu(unsigned char *data);
135extern struct wacom_features * get_wacom_feature(const struct usb_device_id *id); 136extern struct wacom_features *get_wacom_feature(const struct usb_device_id *id);
136extern const struct usb_device_id * get_device_table(void); 137extern const struct usb_device_id *get_device_table(void);
137 138
138#endif 139#endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 09e227aa0d49..484496daa0f3 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -14,8 +14,41 @@
14#include "wacom.h" 14#include "wacom.h"
15#include "wacom_wac.h" 15#include "wacom_wac.h"
16 16
17/* defines to get HID report descriptor */
18#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
19#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
20#define HID_USAGE_UNDEFINED 0x00
21#define HID_USAGE_PAGE 0x05
22#define HID_USAGE_PAGE_DIGITIZER 0x0d
23#define HID_USAGE_PAGE_DESKTOP 0x01
24#define HID_USAGE 0x09
25#define HID_USAGE_X 0x30
26#define HID_USAGE_Y 0x31
27#define HID_USAGE_X_TILT 0x3d
28#define HID_USAGE_Y_TILT 0x3e
29#define HID_USAGE_FINGER 0x22
30#define HID_USAGE_STYLUS 0x20
31#define HID_COLLECTION 0xc0
32
33enum {
34 WCM_UNDEFINED = 0,
35 WCM_DESKTOP,
36 WCM_DIGITIZER,
37};
38
39struct hid_descriptor {
40 struct usb_descriptor_header header;
41 __le16 bcdHID;
42 u8 bCountryCode;
43 u8 bNumDescriptors;
44 u8 bDescriptorType;
45 __le16 wDescriptorLength;
46} __attribute__ ((packed));
47
48/* defines to get/set USB message */
17#define USB_REQ_GET_REPORT 0x01 49#define USB_REQ_GET_REPORT 0x01
18#define USB_REQ_SET_REPORT 0x09 50#define USB_REQ_SET_REPORT 0x09
51#define WAC_HID_FEATURE_REPORT 0x03
19 52
20static int usb_get_report(struct usb_interface *intf, unsigned char type, 53static int usb_get_report(struct usb_interface *intf, unsigned char type,
21 unsigned char id, void *buf, int size) 54 unsigned char id, void *buf, int size)
@@ -80,25 +113,21 @@ static void wacom_sys_irq(struct urb *urb)
80void wacom_report_key(void *wcombo, unsigned int key_type, int key_data) 113void wacom_report_key(void *wcombo, unsigned int key_type, int key_data)
81{ 114{
82 input_report_key(get_input_dev((struct wacom_combo *)wcombo), key_type, key_data); 115 input_report_key(get_input_dev((struct wacom_combo *)wcombo), key_type, key_data);
83 return;
84} 116}
85 117
86void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data) 118void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data)
87{ 119{
88 input_report_abs(get_input_dev((struct wacom_combo *)wcombo), abs_type, abs_data); 120 input_report_abs(get_input_dev((struct wacom_combo *)wcombo), abs_type, abs_data);
89 return;
90} 121}
91 122
92void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data) 123void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data)
93{ 124{
94 input_report_rel(get_input_dev((struct wacom_combo *)wcombo), rel_type, rel_data); 125 input_report_rel(get_input_dev((struct wacom_combo *)wcombo), rel_type, rel_data);
95 return;
96} 126}
97 127
98void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value) 128void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value)
99{ 129{
100 input_event(get_input_dev((struct wacom_combo *)wcombo), type, code, value); 130 input_event(get_input_dev((struct wacom_combo *)wcombo), type, code, value);
101 return;
102} 131}
103 132
104__u16 wacom_be16_to_cpu(unsigned char *data) 133__u16 wacom_be16_to_cpu(unsigned char *data)
@@ -118,7 +147,6 @@ __u16 wacom_le16_to_cpu(unsigned char *data)
118void wacom_input_sync(void *wcombo) 147void wacom_input_sync(void *wcombo)
119{ 148{
120 input_sync(get_input_dev((struct wacom_combo *)wcombo)); 149 input_sync(get_input_dev((struct wacom_combo *)wcombo));
121 return;
122} 150}
123 151
124static int wacom_open(struct input_dev *dev) 152static int wacom_open(struct input_dev *dev)
@@ -160,7 +188,7 @@ static void wacom_close(struct input_dev *dev)
160 188
161void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 189void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
162{ 190{
163 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_1) | 191 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_1) |
164 BIT_MASK(BTN_5); 192 BIT_MASK(BTN_5);
165 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 193 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
166} 194}
@@ -170,7 +198,7 @@ void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
170 input_dev->evbit[0] |= BIT_MASK(EV_MSC); 198 input_dev->evbit[0] |= BIT_MASK(EV_MSC);
171 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); 199 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
172 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); 200 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
173 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) | 201 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
174 BIT_MASK(BTN_4); 202 BIT_MASK(BTN_4);
175} 203}
176 204
@@ -178,7 +206,7 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
178{ 206{
179 input_dev->evbit[0] |= BIT_MASK(EV_REL); 207 input_dev->evbit[0] |= BIT_MASK(EV_REL);
180 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); 208 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
181 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | 209 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
182 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); 210 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
183 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | 211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
184 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); 212 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2);
@@ -188,7 +216,7 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
188void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 216void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
189{ 217{
190 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); 218 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
191 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) | 219 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
192 BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3); 220 BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
193 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); 221 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
194 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 222 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
@@ -196,14 +224,14 @@ void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
196 224
197void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 225void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
198{ 226{
199 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_4) | 227 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) |
200 BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | BIT_MASK(BTN_7); 228 BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | BIT_MASK(BTN_7);
201 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); 229 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
202} 230}
203 231
204void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 232void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
205{ 233{
206 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9); 234 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9);
207} 235}
208 236
209void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 237void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -211,7 +239,7 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
211 input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL); 239 input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL);
212 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); 240 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
213 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); 241 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
214 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | 242 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
215 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE) | 243 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE) |
216 BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA); 244 BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA);
217 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | 245 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
@@ -228,8 +256,7 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
228 256
229void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 257void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
230{ 258{
231 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_STYLUS2) | 259 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_STYLUS2);
232 BIT_MASK(BTN_TOOL_RUBBER);
233} 260}
234 261
235void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 262void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -237,15 +264,129 @@ void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
237 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER); 264 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER);
238} 265}
239 266
267static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc,
268 struct wacom_wac *wacom_wac)
269{
270 struct usb_device *dev = interface_to_usbdev(intf);
271 struct wacom_features *features = wacom_wac->features;
272 char limit = 0, result = 0;
273 int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0;
274 unsigned char *report;
275
276 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
277 if (!report)
278 return -ENOMEM;
279
280 /* retrive report descriptors */
281 do {
282 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
283 USB_REQ_GET_DESCRIPTOR,
284 USB_RECIP_INTERFACE | USB_DIR_IN,
285 HID_DEVICET_REPORT << 8,
286 intf->altsetting[0].desc.bInterfaceNumber, /* interface */
287 report,
288 hid_desc->wDescriptorLength,
289 5000); /* 5 secs */
290 } while (result < 0 && limit++ < 5);
291
292 if (result < 0)
293 goto out;
294
295 for (i = 0; i < hid_desc->wDescriptorLength; i++) {
296
297 switch (report[i]) {
298 case HID_USAGE_PAGE:
299 switch (report[i + 1]) {
300 case HID_USAGE_PAGE_DIGITIZER:
301 usage = WCM_DIGITIZER;
302 i++;
303 break;
304
305 case HID_USAGE_PAGE_DESKTOP:
306 usage = WCM_DESKTOP;
307 i++;
308 break;
309 }
310 break;
311
312 case HID_USAGE:
313 switch (report[i + 1]) {
314 case HID_USAGE_X:
315 if (usage == WCM_DESKTOP) {
316 if (finger) {
317 features->touch_x_max =
318 features->touch_y_max =
319 wacom_le16_to_cpu(&report[i + 3]);
320 features->x_max =
321 wacom_le16_to_cpu(&report[i + 6]);
322 i += 7;
323 } else if (pen) {
324 features->x_max =
325 wacom_le16_to_cpu(&report[i + 3]);
326 i += 4;
327 }
328 } else if (usage == WCM_DIGITIZER) {
329 /* max pressure isn't reported
330 features->pressure_max = (unsigned short)
331 (report[i+4] << 8 | report[i + 3]);
332 */
333 features->pressure_max = 255;
334 i += 4;
335 }
336 break;
337
338 case HID_USAGE_Y:
339 if (usage == WCM_DESKTOP)
340 features->y_max =
341 wacom_le16_to_cpu(&report[i + 3]);
342 i += 4;
343 break;
344
345 case HID_USAGE_FINGER:
346 finger = 1;
347 i++;
348 break;
349
350 case HID_USAGE_STYLUS:
351 pen = 1;
352 i++;
353 break;
354
355 case HID_USAGE_UNDEFINED:
356 if (usage == WCM_DESKTOP && finger) /* capacity */
357 features->pressure_max =
358 wacom_le16_to_cpu(&report[i + 3]);
359 i += 4;
360 break;
361 }
362 break;
363
364 case HID_COLLECTION:
365 /* reset UsagePage ans Finger */
366 finger = usage = 0;
367 break;
368 }
369 }
370
371 result = 0;
372
373 out:
374 kfree(report);
375 return result;
376}
377
240static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 378static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
241{ 379{
242 struct usb_device *dev = interface_to_usbdev(intf); 380 struct usb_device *dev = interface_to_usbdev(intf);
381 struct usb_host_interface *interface = intf->cur_altsetting;
243 struct usb_endpoint_descriptor *endpoint; 382 struct usb_endpoint_descriptor *endpoint;
244 struct wacom *wacom; 383 struct wacom *wacom;
245 struct wacom_wac *wacom_wac; 384 struct wacom_wac *wacom_wac;
385 struct wacom_features *features;
246 struct input_dev *input_dev; 386 struct input_dev *input_dev;
247 int error = -ENOMEM; 387 int error = -ENOMEM;
248 char rep_data[2], limit = 0; 388 char rep_data[2], limit = 0;
389 struct hid_descriptor *hid_desc;
249 390
250 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 391 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
251 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); 392 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL);
@@ -268,8 +409,8 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
268 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 409 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
269 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 410 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
270 411
271 wacom_wac->features = get_wacom_feature(id); 412 wacom_wac->features = features = get_wacom_feature(id);
272 BUG_ON(wacom_wac->features->pktlen > 10); 413 BUG_ON(features->pktlen > 10);
273 414
274 input_dev->name = wacom_wac->features->name; 415 input_dev->name = wacom_wac->features->name;
275 wacom->wacom_wac = wacom_wac; 416 wacom->wacom_wac = wacom_wac;
@@ -282,18 +423,37 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
282 input_dev->open = wacom_open; 423 input_dev->open = wacom_open;
283 input_dev->close = wacom_close; 424 input_dev->close = wacom_close;
284 425
426 endpoint = &intf->cur_altsetting->endpoint[0].desc;
427
428 /* TabletPC need to retrieve the physical and logical maximum from report descriptor */
429 if (wacom_wac->features->type == TABLETPC) {
430 if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
431 if (usb_get_extra_descriptor(&interface->endpoint[0],
432 HID_DEVICET_REPORT, &hid_desc)) {
433 printk("wacom: can not retrive extra class descriptor\n");
434 goto fail2;
435 }
436 }
437 error = wacom_parse_hid(intf, hid_desc, wacom_wac);
438 if (error)
439 goto fail2;
440 }
441
285 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 442 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
286 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) | 443 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) |
287 BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS); 444 BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS);
288 input_set_abs_params(input_dev, ABS_X, 0, wacom_wac->features->x_max, 4, 0); 445 input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0);
289 input_set_abs_params(input_dev, ABS_Y, 0, wacom_wac->features->y_max, 4, 0); 446 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0);
290 input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom_wac->features->pressure_max, 0, 0); 447 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0);
448 if (features->type == TABLETPC) {
449 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP);
450 input_set_abs_params(input_dev, ABS_RX, 0, features->touch_x_max, 4, 0);
451 input_set_abs_params(input_dev, ABS_RY, 0, features->touch_y_max, 4, 0);
452 }
291 input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); 453 input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
292 454
293 wacom_init_input_dev(input_dev, wacom_wac); 455 wacom_init_input_dev(input_dev, wacom_wac);
294 456
295 endpoint = &intf->cur_altsetting->endpoint[0].desc;
296
297 usb_fill_int_urb(wacom->irq, dev, 457 usb_fill_int_urb(wacom->irq, dev,
298 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 458 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
299 wacom_wac->data, wacom_wac->features->pktlen, 459 wacom_wac->data, wacom_wac->features->pktlen,
@@ -305,13 +465,22 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
305 if (error) 465 if (error)
306 goto fail3; 466 goto fail3;
307 467
308 /* Ask the tablet to report tablet data. Repeat until it succeeds */ 468 /*
309 do { 469 * Ask the tablet to report tablet data if it is not a Tablet PC.
310 rep_data[0] = 2; 470 * Repeat until it succeeds
311 rep_data[1] = 2; 471 */
312 usb_set_report(intf, 3, 2, rep_data, 2); 472 if (wacom_wac->features->type != TABLETPC) {
313 usb_get_report(intf, 3, 2, rep_data, 2); 473 do {
314 } while (rep_data[1] != 2 && limit++ < 5); 474 rep_data[0] = 2;
475 rep_data[1] = 2;
476 error = usb_set_report(intf, WAC_HID_FEATURE_REPORT,
477 2, rep_data, 2);
478 if (error >= 0)
479 error = usb_get_report(intf,
480 WAC_HID_FEATURE_REPORT, 2,
481 rep_data, 2);
482 } while ((error < 0 || rep_data[1] != 2) && limit++ < 5);
483 }
315 484
316 usb_set_intfdata(intf, wacom); 485 usb_set_intfdata(intf, wacom);
317 return 0; 486 return 0;
@@ -333,7 +502,8 @@ static void wacom_disconnect(struct usb_interface *intf)
333 usb_kill_urb(wacom->irq); 502 usb_kill_urb(wacom->irq);
334 input_unregister_device(wacom->dev); 503 input_unregister_device(wacom->dev);
335 usb_free_urb(wacom->irq); 504 usb_free_urb(wacom->irq);
336 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma); 505 usb_buffer_free(interface_to_usbdev(intf), 10,
506 wacom->wacom_wac->data, wacom->data_dma);
337 kfree(wacom->wacom_wac); 507 kfree(wacom->wacom_wac);
338 kfree(wacom); 508 kfree(wacom);
339} 509}
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index bf3d9a8b2c1b..8dc8d1e59bea 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -535,31 +535,147 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
535 return 1; 535 return 1;
536} 536}
537 537
538int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
539{
540 char *data = wacom->data;
541 int prox = 0, pressure;
542 static int stylusInProx, touchInProx = 1, touchOut;
543 struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
544
545 dbg("wacom_tpc_irq: received report #%d", data[0]);
546
547 if (urb->actual_length == 5 || data[0] == 6) { /* Touch data */
548 if (urb->actual_length == 5) { /* with touch */
549 prox = data[0] & 0x03;
550 } else { /* with capacity */
551 prox = data[1] & 0x03;
552 }
553
554 if (!stylusInProx) { /* stylus not in prox */
555 if (prox) {
556 if (touchInProx) {
557 wacom->tool[1] = BTN_TOOL_DOUBLETAP;
558 wacom->id[0] = TOUCH_DEVICE_ID;
559 if (urb->actual_length != 5) {
560 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
561 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
562 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
563 wacom_report_key(wcombo, BTN_TOUCH, wacom_le16_to_cpu(&data[6]));
564 } else {
565 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
566 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
567 wacom_report_key(wcombo, BTN_TOUCH, 1);
568 }
569 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
570 wacom_report_key(wcombo, wacom->tool[1], prox & 0x01);
571 touchOut = 1;
572 return 1;
573 }
574 } else {
575 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
576 wacom_report_key(wcombo, wacom->tool[1], prox & 0x01);
577 wacom_report_key(wcombo, BTN_TOUCH, 0);
578 touchOut = 0;
579 touchInProx = 1;
580 return 1;
581 }
582 } else if (touchOut || !prox) { /* force touch out-prox */
583 wacom_report_abs(wcombo, ABS_MISC, TOUCH_DEVICE_ID);
584 wacom_report_key(wcombo, BTN_TOUCH, 0);
585 touchOut = 0;
586 touchInProx = 1;
587 return 1;
588 }
589 } else if (data[0] == 2) { /* Penabled */
590 prox = data[1] & 0x20;
591
592 touchInProx = 0;
593
594 wacom->id[0] = ERASER_DEVICE_ID;
595
596 /*
597 * if going from out of proximity into proximity select between the eraser
598 * and the pen based on the state of the stylus2 button, choose eraser if
599 * pressed else choose pen. if not a proximity change from out to in, send
600 * an out of proximity for previous tool then a in for new tool.
601 */
602 if (prox) { /* in prox */
603 if (!wacom->tool[0]) {
604 /* Going into proximity select tool */
605 wacom->tool[1] = (data[1] & 0x08) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
606 if (wacom->tool[1] == BTN_TOOL_PEN)
607 wacom->id[0] = STYLUS_DEVICE_ID;
608 } else if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[1] & 0x08)) {
609 /*
610 * was entered with stylus2 pressed
611 * report out proximity for previous tool
612 */
613 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
614 wacom_report_key(wcombo, wacom->tool[1], 0);
615 wacom_input_sync(wcombo);
616
617 /* set new tool */
618 wacom->tool[1] = BTN_TOOL_PEN;
619 wacom->id[0] = STYLUS_DEVICE_ID;
620 return 0;
621 }
622 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
623 /* Unknown tool selected default to pen tool */
624 wacom->tool[1] = BTN_TOOL_PEN;
625 wacom->id[0] = STYLUS_DEVICE_ID;
626 }
627 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
628 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
629 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
630 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
631 pressure = ((data[7] & 0x01) << 8) | data[6];
632 if (pressure < 0)
633 pressure = wacom->features->pressure_max + pressure + 1;
634 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
635 wacom_report_key(wcombo, BTN_TOUCH, pressure);
636 } else {
637 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
638 wacom_report_key(wcombo, BTN_STYLUS, 0);
639 wacom_report_key(wcombo, BTN_STYLUS2, 0);
640 wacom_report_key(wcombo, BTN_TOUCH, 0);
641 }
642 wacom_report_key(wcombo, wacom->tool[1], prox);
643 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
644 stylusInProx = prox;
645 wacom->tool[0] = prox;
646 return 1;
647 }
648 return 0;
649}
650
538int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo) 651int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
539{ 652{
540 switch (wacom_wac->features->type) { 653 switch (wacom_wac->features->type) {
541 case PENPARTNER: 654 case PENPARTNER:
542 return (wacom_penpartner_irq(wacom_wac, wcombo)); 655 return wacom_penpartner_irq(wacom_wac, wcombo);
543 break; 656
544 case PL: 657 case PL:
545 return (wacom_pl_irq(wacom_wac, wcombo)); 658 return wacom_pl_irq(wacom_wac, wcombo);
546 break; 659
547 case WACOM_G4: 660 case WACOM_G4:
548 case GRAPHIRE: 661 case GRAPHIRE:
549 case WACOM_MO: 662 case WACOM_MO:
550 return (wacom_graphire_irq(wacom_wac, wcombo)); 663 return wacom_graphire_irq(wacom_wac, wcombo);
551 break; 664
552 case PTU: 665 case PTU:
553 return (wacom_ptu_irq(wacom_wac, wcombo)); 666 return wacom_ptu_irq(wacom_wac, wcombo);
554 break; 667
555 case INTUOS: 668 case INTUOS:
556 case INTUOS3S: 669 case INTUOS3S:
557 case INTUOS3: 670 case INTUOS3:
558 case INTUOS3L: 671 case INTUOS3L:
559 case CINTIQ: 672 case CINTIQ:
560 case WACOM_BEE: 673 case WACOM_BEE:
561 return (wacom_intuos_irq(wacom_wac, wcombo)); 674 return wacom_intuos_irq(wacom_wac, wcombo);
562 break; 675
676 case TABLETPC:
677 return wacom_tpc_irq(wacom_wac, wcombo);
678
563 default: 679 default:
564 return 0; 680 return 0;
565 } 681 }
@@ -586,13 +702,15 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
586 /* fall through */ 702 /* fall through */
587 case INTUOS3S: 703 case INTUOS3S:
588 input_dev_i3s(input_dev, wacom_wac); 704 input_dev_i3s(input_dev, wacom_wac);
705 /* fall through */
589 case INTUOS: 706 case INTUOS:
590 input_dev_i(input_dev, wacom_wac); 707 input_dev_i(input_dev, wacom_wac);
591 break; 708 break;
592 case PL: 709 case PL:
593 case PTU: 710 case PTU:
711 case TABLETPC:
594 input_dev_pl(input_dev, wacom_wac); 712 input_dev_pl(input_dev, wacom_wac);
595 break; 713 /* fall through */
596 case PENPARTNER: 714 case PENPARTNER:
597 input_dev_pt(input_dev, wacom_wac); 715 input_dev_pt(input_dev, wacom_wac);
598 break; 716 break;
@@ -611,6 +729,7 @@ static struct wacom_features wacom_features[] = {
611 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 }, 729 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
612 { "Wacom BambooFun 4x5", 9, 14760, 9225, 511, 63, WACOM_MO }, 730 { "Wacom BambooFun 4x5", 9, 14760, 9225, 511, 63, WACOM_MO },
613 { "Wacom BambooFun 6x8", 9, 21648, 13530, 511, 63, WACOM_MO }, 731 { "Wacom BambooFun 6x8", 9, 21648, 13530, 511, 63, WACOM_MO },
732 { "Wacom Bamboo1 Medium",8, 16704, 12064, 511, 63, GRAPHIRE },
614 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE }, 733 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE },
615 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE }, 734 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE },
616 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE }, 735 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE },
@@ -650,6 +769,10 @@ static struct wacom_features wacom_features[] = {
650 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ }, 769 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
651 { "Wacom Cintiq 20WSX", 10, 86680, 54180, 1023, 63, WACOM_BEE }, 770 { "Wacom Cintiq 20WSX", 10, 86680, 54180, 1023, 63, WACOM_BEE },
652 { "Wacom Cintiq 12WX", 10, 53020, 33440, 1023, 63, WACOM_BEE }, 771 { "Wacom Cintiq 12WX", 10, 53020, 33440, 1023, 63, WACOM_BEE },
772 { "Wacom DTU1931", 8, 37832, 30305, 511, 0, PL },
773 { "Wacom ISDv4 90", 8, 26202, 16325, 255, 0, TABLETPC },
774 { "Wacom ISDv4 93", 8, 26202, 16325, 255, 0, TABLETPC },
775 { "Wacom ISDv4 9A", 8, 26202, 16325, 255, 0, TABLETPC },
653 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS }, 776 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
654 { } 777 { }
655}; 778};
@@ -665,6 +788,7 @@ static struct usb_device_id wacom_ids[] = {
665 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) }, 788 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
666 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) }, 789 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
667 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) }, 790 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
791 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x19) },
668 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) }, 792 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
669 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) }, 793 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
670 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) }, 794 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
@@ -704,18 +828,26 @@ static struct usb_device_id wacom_ids[] = {
704 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 828 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
705 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) }, 829 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) },
706 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) }, 830 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
831 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC7) },
832 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x90) },
833 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x93) },
834 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9A) },
707 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 835 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
708 { } 836 { }
709}; 837};
710 838
711const struct usb_device_id * get_device_table(void) { 839const struct usb_device_id *get_device_table(void)
712 const struct usb_device_id * id_table = wacom_ids; 840{
841 const struct usb_device_id *id_table = wacom_ids;
842
713 return id_table; 843 return id_table;
714} 844}
715 845
716struct wacom_features * get_wacom_feature(const struct usb_device_id * id) { 846struct wacom_features * get_wacom_feature(const struct usb_device_id *id)
847{
717 int index = id - wacom_ids; 848 int index = id - wacom_ids;
718 struct wacom_features *wf = &wacom_features[index]; 849 struct wacom_features *wf = &wacom_features[index];
850
719 return wf; 851 return wf;
720} 852}
721 853
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 3342bc05847d..f9c8b69673b7 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -10,6 +10,7 @@
10#define WACOM_WAC_H 10#define WACOM_WAC_H
11 11
12#define STYLUS_DEVICE_ID 0x02 12#define STYLUS_DEVICE_ID 0x02
13#define TOUCH_DEVICE_ID 0x03
13#define CURSOR_DEVICE_ID 0x06 14#define CURSOR_DEVICE_ID 0x06
14#define ERASER_DEVICE_ID 0x0A 15#define ERASER_DEVICE_ID 0x0A
15#define PAD_DEVICE_ID 0x0F 16#define PAD_DEVICE_ID 0x0F
@@ -27,6 +28,7 @@ enum {
27 CINTIQ, 28 CINTIQ,
28 WACOM_BEE, 29 WACOM_BEE,
29 WACOM_MO, 30 WACOM_MO,
31 TABLETPC,
30 MAX_TYPE 32 MAX_TYPE
31}; 33};
32 34
@@ -38,6 +40,8 @@ struct wacom_features {
38 int pressure_max; 40 int pressure_max;
39 int distance_max; 41 int distance_max;
40 int type; 42 int type;
43 int touch_x_max;
44 int touch_y_max;
41}; 45};
42 46
43struct wacom_wac { 47struct wacom_wac {
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index d20689cdbd5d..8f38c5e55ce6 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -262,7 +262,7 @@ static int elo_setup_10(struct elo *elo)
262 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); 262 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
263 263
264 printk(KERN_INFO "elo: %sTouch touchscreen, fw: %02x.%02x, " 264 printk(KERN_INFO "elo: %sTouch touchscreen, fw: %02x.%02x, "
265 "features: %x02x, controller: 0x%02x\n", 265 "features: 0x%02x, controller: 0x%02x\n",
266 elo_types[(packet[1] -'0') & 0x03], 266 elo_types[(packet[1] -'0') & 0x03],
267 packet[5], packet[4], packet[3], packet[7]); 267 packet[5], packet[4], packet[3], packet[7]);
268 268
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c
index 3ab6362f043c..928d2ed8865f 100644
--- a/drivers/input/xen-kbdfront.c
+++ b/drivers/input/xen-kbdfront.c
@@ -323,7 +323,7 @@ static struct xenbus_device_id xenkbd_ids[] = {
323 { "" } 323 { "" }
324}; 324};
325 325
326static struct xenbus_driver xenkbd = { 326static struct xenbus_driver xenkbd_driver = {
327 .name = "vkbd", 327 .name = "vkbd",
328 .owner = THIS_MODULE, 328 .owner = THIS_MODULE,
329 .ids = xenkbd_ids, 329 .ids = xenkbd_ids,
@@ -342,12 +342,12 @@ static int __init xenkbd_init(void)
342 if (xen_initial_domain()) 342 if (xen_initial_domain())
343 return -ENODEV; 343 return -ENODEV;
344 344
345 return xenbus_register_frontend(&xenkbd); 345 return xenbus_register_frontend(&xenkbd_driver);
346} 346}
347 347
348static void __exit xenkbd_cleanup(void) 348static void __exit xenkbd_cleanup(void)
349{ 349{
350 xenbus_unregister_driver(&xenkbd); 350 xenbus_unregister_driver(&xenkbd_driver);
351} 351}
352 352
353module_init(xenkbd_init); 353module_init(xenkbd_init);
diff --git a/drivers/isdn/hardware/avm/b1isa.c b/drivers/isdn/hardware/avm/b1isa.c
index 1e288eeb5e2a..6461a32bc838 100644
--- a/drivers/isdn/hardware/avm/b1isa.c
+++ b/drivers/isdn/hardware/avm/b1isa.c
@@ -233,10 +233,8 @@ static void __exit b1isa_exit(void)
233 int i; 233 int i;
234 234
235 for (i = 0; i < MAX_CARDS; i++) { 235 for (i = 0; i < MAX_CARDS; i++) {
236 if (!io[i]) 236 if (isa_dev[i].resource[0].start)
237 break; 237 b1isa_remove(&isa_dev[i]);
238
239 b1isa_remove(&isa_dev[i]);
240 } 238 }
241 unregister_capi_driver(&capi_driver_b1isa); 239 unregister_capi_driver(&capi_driver_b1isa);
242} 240}
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 84d75a3f5d17..ded9d0baf607 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1213,7 +1213,7 @@ static void HiSax_shiftcards(int idx)
1213 memcpy(&cards[i], &cards[i + 1], sizeof(cards[i])); 1213 memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
1214} 1214}
1215 1215
1216static int HiSax_inithardware(int *busy_flag) 1216static int __init HiSax_inithardware(int *busy_flag)
1217{ 1217{
1218 int foundcards = 0; 1218 int foundcards = 0;
1219 int i = 0; 1219 int i = 0;
@@ -1542,7 +1542,9 @@ static void __exit HiSax_exit(void)
1542 printk(KERN_INFO "HiSax module removed\n"); 1542 printk(KERN_INFO "HiSax module removed\n");
1543} 1543}
1544 1544
1545int hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card) 1545#ifdef CONFIG_HOTPLUG
1546
1547int __devinit hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
1546{ 1548{
1547 u_char ids[16]; 1549 u_char ids[16];
1548 int ret = -1; 1550 int ret = -1;
@@ -1563,6 +1565,8 @@ error:
1563} 1565}
1564 1566
1565EXPORT_SYMBOL(hisax_init_pcmcia); 1567EXPORT_SYMBOL(hisax_init_pcmcia);
1568#endif
1569
1566EXPORT_SYMBOL(HiSax_closecard); 1570EXPORT_SYMBOL(HiSax_closecard);
1567 1571
1568#include "hisax_if.h" 1572#include "hisax_if.h"
@@ -1580,6 +1584,11 @@ static void hisax_bc_close(struct BCState *bcs);
1580static void hisax_bh(struct work_struct *work); 1584static void hisax_bh(struct work_struct *work);
1581static void EChannel_proc_rcv(struct hisax_d_if *d_if); 1585static void EChannel_proc_rcv(struct hisax_d_if *d_if);
1582 1586
1587static int hisax_setup_card_dynamic(struct IsdnCard *card)
1588{
1589 return 2;
1590}
1591
1583int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[], 1592int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1584 char *name, int protocol) 1593 char *name, int protocol)
1585{ 1594{
@@ -1599,7 +1608,8 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1599 cards[i].protocol = protocol; 1608 cards[i].protocol = protocol;
1600 sprintf(id, "%s%d", name, i); 1609 sprintf(id, "%s%d", name, i);
1601 nrcards++; 1610 nrcards++;
1602 retval = checkcard(i, id, NULL, hisax_d_if->owner, hisax_cs_setup_card); 1611 retval = checkcard(i, id, NULL, hisax_d_if->owner,
1612 hisax_setup_card_dynamic);
1603 if (retval == 0) { // yuck 1613 if (retval == 0) { // yuck
1604 cards[i].typ = 0; 1614 cards[i].typ = 0;
1605 nrcards--; 1615 nrcards--;
diff --git a/drivers/isdn/hysdn/hysdn_net.c b/drivers/isdn/hysdn/hysdn_net.c
index cfa8fa5e44ab..3f2a0a20c19b 100644
--- a/drivers/isdn/hysdn/hysdn_net.c
+++ b/drivers/isdn/hysdn/hysdn_net.c
@@ -83,12 +83,12 @@ net_open(struct net_device *dev)
83 83
84 /* Fill in the MAC-level header (if not already set) */ 84 /* Fill in the MAC-level header (if not already set) */
85 if (!card->mac_addr[0]) { 85 if (!card->mac_addr[0]) {
86 for (i = 0; i < ETH_ALEN - sizeof(unsigned long); i++) 86 for (i = 0; i < ETH_ALEN; i++)
87 dev->dev_addr[i] = 0xfc; 87 dev->dev_addr[i] = 0xfc;
88 if ((in_dev = dev->ip_ptr) != NULL) { 88 if ((in_dev = dev->ip_ptr) != NULL) {
89 struct in_ifaddr *ifa = in_dev->ifa_list; 89 struct in_ifaddr *ifa = in_dev->ifa_list;
90 if (ifa != NULL) 90 if (ifa != NULL)
91 memcpy(dev->dev_addr + (ETH_ALEN - sizeof(unsigned long)), &ifa->ifa_local, sizeof(unsigned long)); 91 memcpy(dev->dev_addr + (ETH_ALEN - sizeof(ifa->ifa_local)), &ifa->ifa_local, sizeof(ifa->ifa_local));
92 } 92 }
93 } else 93 } else
94 memcpy(dev->dev_addr, card->mac_addr, ETH_ALEN); 94 memcpy(dev->dev_addr, card->mac_addr, ETH_ALEN);
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index 2c21d4f25cc8..a98ab72adf95 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -288,7 +288,7 @@ static void __devexit rackmeter_stop_cpu_sniffer(struct rackmeter *rm)
288 cancel_rearming_delayed_work(&rm->cpu[1].sniffer); 288 cancel_rearming_delayed_work(&rm->cpu[1].sniffer);
289} 289}
290 290
291static int rackmeter_setup(struct rackmeter *rm) 291static int __devinit rackmeter_setup(struct rackmeter *rm)
292{ 292{
293 pr_debug("rackmeter: setting up i2s..\n"); 293 pr_debug("rackmeter: setting up i2s..\n");
294 rackmeter_setup_i2s(rm); 294 rackmeter_setup_i2s(rm);
@@ -582,12 +582,12 @@ static struct of_device_id rackmeter_match[] = {
582 { } 582 { }
583}; 583};
584 584
585static struct macio_driver rackmeter_drv = { 585static struct macio_driver rackmeter_driver = {
586 .name = "rackmeter", 586 .name = "rackmeter",
587 .owner = THIS_MODULE, 587 .owner = THIS_MODULE,
588 .match_table = rackmeter_match, 588 .match_table = rackmeter_match,
589 .probe = rackmeter_probe, 589 .probe = rackmeter_probe,
590 .remove = rackmeter_remove, 590 .remove = __devexit_p(rackmeter_remove),
591 .shutdown = rackmeter_shutdown, 591 .shutdown = rackmeter_shutdown,
592}; 592};
593 593
@@ -596,14 +596,14 @@ static int __init rackmeter_init(void)
596{ 596{
597 pr_debug("rackmeter_init()\n"); 597 pr_debug("rackmeter_init()\n");
598 598
599 return macio_register_driver(&rackmeter_drv); 599 return macio_register_driver(&rackmeter_driver);
600} 600}
601 601
602static void __exit rackmeter_exit(void) 602static void __exit rackmeter_exit(void)
603{ 603{
604 pr_debug("rackmeter_exit()\n"); 604 pr_debug("rackmeter_exit()\n");
605 605
606 macio_unregister_driver(&rackmeter_drv); 606 macio_unregister_driver(&rackmeter_driver);
607} 607}
608 608
609module_init(rackmeter_init); 609module_init(rackmeter_init);
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index ac89a5deaca2..ab7c8e4a61f9 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -208,16 +208,19 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
208 */ 208 */
209 209
210/* IO operations when bitmap is stored near all superblocks */ 210/* IO operations when bitmap is stored near all superblocks */
211static struct page *read_sb_page(mddev_t *mddev, long offset, unsigned long index) 211static struct page *read_sb_page(mddev_t *mddev, long offset,
212 struct page *page,
213 unsigned long index, int size)
212{ 214{
213 /* choose a good rdev and read the page from there */ 215 /* choose a good rdev and read the page from there */
214 216
215 mdk_rdev_t *rdev; 217 mdk_rdev_t *rdev;
216 struct list_head *tmp; 218 struct list_head *tmp;
217 struct page *page = alloc_page(GFP_KERNEL);
218 sector_t target; 219 sector_t target;
219 220
220 if (!page) 221 if (!page)
222 page = alloc_page(GFP_KERNEL);
223 if (!page)
221 return ERR_PTR(-ENOMEM); 224 return ERR_PTR(-ENOMEM);
222 225
223 rdev_for_each(rdev, tmp, mddev) { 226 rdev_for_each(rdev, tmp, mddev) {
@@ -227,7 +230,9 @@ static struct page *read_sb_page(mddev_t *mddev, long offset, unsigned long inde
227 230
228 target = rdev->sb_start + offset + index * (PAGE_SIZE/512); 231 target = rdev->sb_start + offset + index * (PAGE_SIZE/512);
229 232
230 if (sync_page_io(rdev->bdev, target, PAGE_SIZE, page, READ)) { 233 if (sync_page_io(rdev->bdev, target,
234 roundup(size, bdev_hardsect_size(rdev->bdev)),
235 page, READ)) {
231 page->index = index; 236 page->index = index;
232 attach_page_buffers(page, NULL); /* so that free_buffer will 237 attach_page_buffers(page, NULL); /* so that free_buffer will
233 * quietly no-op */ 238 * quietly no-op */
@@ -544,7 +549,9 @@ static int bitmap_read_sb(struct bitmap *bitmap)
544 549
545 bitmap->sb_page = read_page(bitmap->file, 0, bitmap, bytes); 550 bitmap->sb_page = read_page(bitmap->file, 0, bitmap, bytes);
546 } else { 551 } else {
547 bitmap->sb_page = read_sb_page(bitmap->mddev, bitmap->offset, 0); 552 bitmap->sb_page = read_sb_page(bitmap->mddev, bitmap->offset,
553 NULL,
554 0, sizeof(bitmap_super_t));
548 } 555 }
549 if (IS_ERR(bitmap->sb_page)) { 556 if (IS_ERR(bitmap->sb_page)) {
550 err = PTR_ERR(bitmap->sb_page); 557 err = PTR_ERR(bitmap->sb_page);
@@ -957,11 +964,16 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
957 */ 964 */
958 page = bitmap->sb_page; 965 page = bitmap->sb_page;
959 offset = sizeof(bitmap_super_t); 966 offset = sizeof(bitmap_super_t);
967 read_sb_page(bitmap->mddev, bitmap->offset,
968 page,
969 index, count);
960 } else if (file) { 970 } else if (file) {
961 page = read_page(file, index, bitmap, count); 971 page = read_page(file, index, bitmap, count);
962 offset = 0; 972 offset = 0;
963 } else { 973 } else {
964 page = read_sb_page(bitmap->mddev, bitmap->offset, index); 974 page = read_sb_page(bitmap->mddev, bitmap->offset,
975 NULL,
976 index, count);
965 offset = 0; 977 offset = 0;
966 } 978 }
967 if (IS_ERR(page)) { /* read error */ 979 if (IS_ERR(page)) { /* read error */
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index a63161aec487..04e5fd742c2c 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -668,7 +668,7 @@ static void check_for_valid_limits(struct io_restrictions *rs)
668 if (!rs->max_segment_size) 668 if (!rs->max_segment_size)
669 rs->max_segment_size = MAX_SEGMENT_SIZE; 669 rs->max_segment_size = MAX_SEGMENT_SIZE;
670 if (!rs->seg_boundary_mask) 670 if (!rs->seg_boundary_mask)
671 rs->seg_boundary_mask = -1; 671 rs->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
672 if (!rs->bounce_pfn) 672 if (!rs->bounce_pfn)
673 rs->bounce_pfn = -1; 673 rs->bounce_pfn = -1;
674} 674}
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig
index 73dc2ee9b014..b34301d56cd2 100644
--- a/drivers/media/dvb/b2c2/Kconfig
+++ b/drivers/media/dvb/b2c2/Kconfig
@@ -9,11 +9,11 @@ config DVB_B2C2_FLEXCOP
9 select DVB_STV0297 if !DVB_FE_CUSTOMISE 9 select DVB_STV0297 if !DVB_FE_CUSTOMISE
10 select DVB_BCM3510 if !DVB_FE_CUSTOMISE 10 select DVB_BCM3510 if !DVB_FE_CUSTOMISE
11 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 11 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
12 select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE
13 select DVB_S5H1420 if !DVB_FE_CUSTOMISE 12 select DVB_S5H1420 if !DVB_FE_CUSTOMISE
14 select DVB_TUNER_ITD1000 if !DVB_FE_CUSTOMISE 13 select DVB_TUNER_ITD1000 if !DVB_FE_CUSTOMISE
15 select DVB_ISL6421 if !DVB_FE_CUSTOMISE 14 select DVB_ISL6421 if !DVB_FE_CUSTOMISE
16 select DVB_CX24123 if !DVB_FE_CUSTOMISE 15 select DVB_CX24123 if !DVB_FE_CUSTOMISE
16 select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE
17 help 17 help
18 Support for the digital TV receiver chip made by B2C2 Inc. included in 18 Support for the digital TV receiver chip made by B2C2 Inc. included in
19 Technisats PCI cards and USB boxes. 19 Technisats PCI cards and USB boxes.
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index a127a4175c40..5cded3708541 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -628,12 +628,14 @@ int flexcop_frontend_init(struct flexcop_device *fc)
628 } 628 }
629 629
630 /* try the cable dvb (stv0297) */ 630 /* try the cable dvb (stv0297) */
631 fc->fc_i2c_adap[0].no_base_addr = 1;
631 fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c); 632 fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c);
632 if (fc->fe != NULL) { 633 if (fc->fe != NULL) {
633 fc->dev_type = FC_CABLE; 634 fc->dev_type = FC_CABLE;
634 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; 635 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
635 goto fe_found; 636 goto fe_found;
636 } 637 }
638 fc->fc_i2c_adap[0].no_base_addr = 0;
637 639
638 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 640 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
639 fc->fe = dvb_attach(mt312_attach, 641 fc->fe = dvb_attach(mt312_attach,
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
index 43a112ec6d44..f13783f08f0f 100644
--- a/drivers/media/dvb/b2c2/flexcop-i2c.c
+++ b/drivers/media/dvb/b2c2/flexcop-i2c.c
@@ -47,9 +47,13 @@ static int flexcop_i2c_read4(struct flexcop_i2c_adapter *i2c,
47 int len = r100.tw_sm_c_100.total_bytes, /* remember total_bytes is buflen-1 */ 47 int len = r100.tw_sm_c_100.total_bytes, /* remember total_bytes is buflen-1 */
48 ret; 48 ret;
49 49
50 r100.tw_sm_c_100.no_base_addr_ack_error = i2c->no_base_addr;
51 ret = flexcop_i2c_operation(i2c->fc, &r100); 50 ret = flexcop_i2c_operation(i2c->fc, &r100);
52 if (ret != 0) { 51 if (ret != 0) {
52 deb_i2c("Retrying operation\n");
53 r100.tw_sm_c_100.no_base_addr_ack_error = i2c->no_base_addr;
54 ret = flexcop_i2c_operation(i2c->fc, &r100);
55 }
56 if (ret != 0) {
53 deb_i2c("read failed. %d\n", ret); 57 deb_i2c("read failed. %d\n", ret);
54 return ret; 58 return ret;
55 } 59 }
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
index 7e9c090fc04e..27edb0ece587 100644
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ b/drivers/media/dvb/bt8xx/Kconfig
@@ -8,7 +8,7 @@ config DVB_BT8XX
8 select DVB_OR51211 if !DVB_FE_CUSTOMISE 8 select DVB_OR51211 if !DVB_FE_CUSTOMISE
9 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 9 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
10 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 10 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
11 select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE 11 select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE
12 help 12 help
13 Support for PCI cards based on the Bt8xx PCI bridge. Examples are 13 Support for PCI cards based on the Bt8xx PCI bridge. Examples are
14 the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards, 14 the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards,
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index 14e627ef6465..c1d92f838ca8 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -376,7 +376,7 @@ static void dm1105dvb_dma_unmap(struct dm1105dvb *dm1105dvb)
376 pci_free_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, dm1105dvb->ts_buf, dm1105dvb->dma_addr); 376 pci_free_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, dm1105dvb->ts_buf, dm1105dvb->dma_addr);
377} 377}
378 378
379static void __devinit dm1105dvb_enable_irqs(struct dm1105dvb *dm1105dvb) 379static void dm1105dvb_enable_irqs(struct dm1105dvb *dm1105dvb)
380{ 380{
381 outb(INTMAK_ALLMASK, dm_io_mem(DM1105_INTMAK)); 381 outb(INTMAK_ALLMASK, dm_io_mem(DM1105_INTMAK));
382 outb(1, dm_io_mem(DM1105_CR)); 382 outb(1, dm_io_mem(DM1105_CR));
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 8557bf12cfb4..7a421e9dba5a 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -585,6 +585,8 @@ restart:
585 if (fe->ops.set_voltage) 585 if (fe->ops.set_voltage)
586 fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF); 586 fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF);
587 if (fe->ops.tuner_ops.sleep) { 587 if (fe->ops.tuner_ops.sleep) {
588 if (fe->ops.i2c_gate_ctrl)
589 fe->ops.i2c_gate_ctrl(fe, 1);
588 fe->ops.tuner_ops.sleep(fe); 590 fe->ops.tuner_ops.sleep(fe);
589 if (fe->ops.i2c_gate_ctrl) 591 if (fe->ops.i2c_gate_ctrl)
590 fe->ops.i2c_gate_ctrl(fe, 0); 592 fe->ops.i2c_gate_ctrl(fe, 0);
@@ -934,7 +936,8 @@ void dtv_property_dump(struct dtv_property *tvp)
934int is_legacy_delivery_system(fe_delivery_system_t s) 936int is_legacy_delivery_system(fe_delivery_system_t s)
935{ 937{
936 if((s == SYS_UNDEFINED) || (s == SYS_DVBC_ANNEX_AC) || 938 if((s == SYS_UNDEFINED) || (s == SYS_DVBC_ANNEX_AC) ||
937 (s == SYS_DVBC_ANNEX_B) || (s == SYS_DVBT) || (s == SYS_DVBS)) 939 (s == SYS_DVBC_ANNEX_B) || (s == SYS_DVBT) || (s == SYS_DVBS) ||
940 (s == SYS_ATSC))
938 return 1; 941 return 1;
939 942
940 return 0; 943 return 0;
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 62b68c291d99..49f7b20c25d6 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -24,8 +24,8 @@ config DVB_USB_A800
24 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)" 24 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)"
25 depends on DVB_USB 25 depends on DVB_USB
26 select DVB_DIB3000MC 26 select DVB_DIB3000MC
27 select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE
28 select DVB_PLL if !DVB_FE_CUSTOMISE 27 select DVB_PLL if !DVB_FE_CUSTOMISE
28 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMIZE
29 help 29 help
30 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver. 30 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver.
31 31
@@ -34,7 +34,7 @@ config DVB_USB_DIBUSB_MB
34 depends on DVB_USB 34 depends on DVB_USB
35 select DVB_PLL if !DVB_FE_CUSTOMISE 35 select DVB_PLL if !DVB_FE_CUSTOMISE
36 select DVB_DIB3000MB 36 select DVB_DIB3000MB
37 select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE 37 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMIZE
38 help 38 help
39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by 39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by
40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. 40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.
@@ -55,7 +55,7 @@ config DVB_USB_DIBUSB_MC
55 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)" 55 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)"
56 depends on DVB_USB 56 depends on DVB_USB
57 select DVB_DIB3000MC 57 select DVB_DIB3000MC
58 select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE 58 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMIZE
59 help 59 help
60 Support for USB2.0 DVB-T receivers based on reference designs made by 60 Support for USB2.0 DVB-T receivers based on reference designs made by
61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. 61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.
@@ -73,11 +73,11 @@ config DVB_USB_DIB0700
73 select DVB_DIB7000M 73 select DVB_DIB7000M
74 select DVB_DIB3000MC 74 select DVB_DIB3000MC
75 select DVB_S5H1411 if !DVB_FE_CUSTOMISE 75 select DVB_S5H1411 if !DVB_FE_CUSTOMISE
76 select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE
77 select MEDIA_TUNER_MT2266 if !DVB_FE_CUSTOMISE
78 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMISE
79 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE
80 select DVB_TUNER_DIB0070 76 select DVB_TUNER_DIB0070
77 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMIZE
78 select MEDIA_TUNER_MT2266 if !MEDIA_TUNER_CUSTOMIZE
79 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE
80 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE
81 help 81 help
82 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The 82 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The
83 USB bridge is also present in devices having the DiB7700 DVB-T-USB 83 USB bridge is also present in devices having the DiB7700 DVB-T-USB
@@ -95,7 +95,7 @@ config DVB_USB_UMT_010
95 depends on DVB_USB 95 depends on DVB_USB
96 select DVB_PLL if !DVB_FE_CUSTOMISE 96 select DVB_PLL if !DVB_FE_CUSTOMISE
97 select DVB_DIB3000MC 97 select DVB_DIB3000MC
98 select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE 98 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMIZE
99 help 99 help
100 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver. 100 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver.
101 101
@@ -107,11 +107,11 @@ config DVB_USB_CXUSB
107 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 107 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
108 select DVB_MT352 if !DVB_FE_CUSTOMISE 108 select DVB_MT352 if !DVB_FE_CUSTOMISE
109 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 109 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
110 select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE
111 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMISE
112 select MEDIA_TUNER_MXL5005S if !DVB_FE_CUSTOMISE
113 select DVB_DIB7000P if !DVB_FE_CUSTOMISE 110 select DVB_DIB7000P if !DVB_FE_CUSTOMISE
114 select DVB_TUNER_DIB0070 if !DVB_FE_CUSTOMISE 111 select DVB_TUNER_DIB0070 if !DVB_FE_CUSTOMISE
112 select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE
113 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE
114 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMIZE
115 help 115 help
116 Say Y here to support the Conexant USB2.0 hybrid reference design. 116 Say Y here to support the Conexant USB2.0 hybrid reference design.
117 Currently, only DVB and ATSC modes are supported, analog mode 117 Currently, only DVB and ATSC modes are supported, analog mode
@@ -124,9 +124,9 @@ config DVB_USB_M920X
124 tristate "Uli m920x DVB-T USB2.0 support" 124 tristate "Uli m920x DVB-T USB2.0 support"
125 depends on DVB_USB 125 depends on DVB_USB
126 select DVB_MT352 if !DVB_FE_CUSTOMISE 126 select DVB_MT352 if !DVB_FE_CUSTOMISE
127 select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE
128 select MEDIA_TUNER_TDA827X if !DVB_FE_CUSTOMISE
129 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 127 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
128 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMIZE
129 select MEDIA_TUNER_TDA827X if !MEDIA_TUNER_CUSTOMIZE
130 help 130 help
131 Say Y here to support the MSI Mega Sky 580 USB2.0 DVB-T receiver. 131 Say Y here to support the MSI Mega Sky 580 USB2.0 DVB-T receiver.
132 Currently, only devices with a product id of 132 Currently, only devices with a product id of
@@ -137,7 +137,7 @@ config DVB_USB_GL861
137 tristate "Genesys Logic GL861 USB2.0 support" 137 tristate "Genesys Logic GL861 USB2.0 support"
138 depends on DVB_USB 138 depends on DVB_USB
139 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 139 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
140 select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE 140 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMIZE
141 help 141 help
142 Say Y here to support the MSI Megasky 580 (55801) DVB-T USB2.0 142 Say Y here to support the MSI Megasky 580 (55801) DVB-T USB2.0
143 receiver with USB ID 0db0:5581. 143 receiver with USB ID 0db0:5581.
@@ -146,7 +146,7 @@ config DVB_USB_AU6610
146 tristate "Alcor Micro AU6610 USB2.0 support" 146 tristate "Alcor Micro AU6610 USB2.0 support"
147 depends on DVB_USB 147 depends on DVB_USB
148 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 148 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
149 select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE 149 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMIZE
150 help 150 help
151 Say Y here to support the Sigmatek DVB-110 DVB-T USB2.0 receiver. 151 Say Y here to support the Sigmatek DVB-110 DVB-T USB2.0 receiver.
152 152
@@ -198,8 +198,8 @@ config DVB_USB_NOVA_T_USB2
198 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" 198 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support"
199 depends on DVB_USB 199 depends on DVB_USB
200 select DVB_DIB3000MC 200 select DVB_DIB3000MC
201 select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE
202 select DVB_PLL if !DVB_FE_CUSTOMISE 201 select DVB_PLL if !DVB_FE_CUSTOMISE
202 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMIZE
203 help 203 help
204 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver. 204 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver.
205 205
@@ -235,8 +235,8 @@ config DVB_USB_OPERA1
235config DVB_USB_AF9005 235config DVB_USB_AF9005
236 tristate "Afatech AF9005 DVB-T USB1.1 support" 236 tristate "Afatech AF9005 DVB-T USB1.1 support"
237 depends on DVB_USB && EXPERIMENTAL 237 depends on DVB_USB && EXPERIMENTAL
238 select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE 238 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMIZE
239 select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE 239 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMIZE
240 help 240 help
241 Say Y here to support the Afatech AF9005 based DVB-T USB1.1 receiver 241 Say Y here to support the Afatech AF9005 based DVB-T USB1.1 receiver
242 and the TerraTec Cinergy T USB XE (Rev.1) 242 and the TerraTec Cinergy T USB XE (Rev.1)
@@ -284,7 +284,7 @@ config DVB_USB_DTV5100
284 tristate "AME DTV-5100 USB2.0 DVB-T support" 284 tristate "AME DTV-5100 USB2.0 DVB-T support"
285 depends on DVB_USB 285 depends on DVB_USB
286 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 286 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
287 select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE 287 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMIZE
288 help 288 help
289 Say Y here to support the AME DTV-5100 USB2.0 DVB-T receiver. 289 Say Y here to support the AME DTV-5100 USB2.0 DVB-T receiver.
290 290
@@ -293,9 +293,9 @@ config DVB_USB_AF9015
293 depends on DVB_USB && EXPERIMENTAL 293 depends on DVB_USB && EXPERIMENTAL
294 select DVB_AF9013 294 select DVB_AF9013
295 select DVB_PLL if !DVB_FE_CUSTOMISE 295 select DVB_PLL if !DVB_FE_CUSTOMISE
296 select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE 296 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMIZE
297 select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE 297 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMIZE
298 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMISE 298 select MEDIA_TUNER_TDA18271 if !MEDIA_TUNER_CUSTOMIZE
299 select MEDIA_TUNER_MXL5005S if !DVB_FE_CUSTOMISE 299 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMIZE
300 help 300 help
301 Say Y here to support the Afatech AF9015 based DVB-T USB2.0 receiver 301 Say Y here to support the Afatech AF9015 based DVB-T USB2.0 receiver
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 847d8fdd9ec4..e9ab0249d133 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -681,12 +681,6 @@ static int af9015_download_firmware(struct usb_device *udev,
681 goto error; 681 goto error;
682 } 682 }
683 683
684 /* firmware is running, reconnect device in the usb bus */
685 req.cmd = RECONNECT_USB;
686 ret = af9015_rw_udev(udev, &req);
687 if (ret)
688 err("reconnect failed: %d", ret);
689
690error: 684error:
691 return ret; 685 return ret;
692} 686}
@@ -1208,6 +1202,7 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1208 .usb_ctrl = DEVICE_SPECIFIC, 1202 .usb_ctrl = DEVICE_SPECIFIC,
1209 .download_firmware = af9015_download_firmware, 1203 .download_firmware = af9015_download_firmware,
1210 .firmware = "dvb-usb-af9015.fw", 1204 .firmware = "dvb-usb-af9015.fw",
1205 .no_reconnect = 1,
1211 1206
1212 .size_of_priv = sizeof(struct af9015_state), \ 1207 .size_of_priv = sizeof(struct af9015_state), \
1213 1208
@@ -1306,6 +1301,7 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1306 .usb_ctrl = DEVICE_SPECIFIC, 1301 .usb_ctrl = DEVICE_SPECIFIC,
1307 .download_firmware = af9015_download_firmware, 1302 .download_firmware = af9015_download_firmware,
1308 .firmware = "dvb-usb-af9015.fw", 1303 .firmware = "dvb-usb-af9015.fw",
1304 .no_reconnect = 1,
1309 1305
1310 .size_of_priv = sizeof(struct af9015_state), \ 1306 .size_of_priv = sizeof(struct af9015_state), \
1311 1307
diff --git a/drivers/media/dvb/dvb-usb/dib0700.h b/drivers/media/dvb/dvb-usb/dib0700.h
index 739193943c17..8b544fe79b0d 100644
--- a/drivers/media/dvb/dvb-usb/dib0700.h
+++ b/drivers/media/dvb/dvb-usb/dib0700.h
@@ -22,7 +22,7 @@ extern int dvb_usb_dib0700_debug;
22 22
23#define REQUEST_I2C_READ 0x2 23#define REQUEST_I2C_READ 0x2
24#define REQUEST_I2C_WRITE 0x3 24#define REQUEST_I2C_WRITE 0x3
25#define REQUEST_POLL_RC 0x4 25#define REQUEST_POLL_RC 0x4 /* deprecated in firmware v1.20 */
26#define REQUEST_JUMPRAM 0x8 26#define REQUEST_JUMPRAM 0x8
27#define REQUEST_SET_CLOCK 0xB 27#define REQUEST_SET_CLOCK 0xB
28#define REQUEST_SET_GPIO 0xC 28#define REQUEST_SET_GPIO 0xC
@@ -40,11 +40,14 @@ struct dib0700_state {
40 u16 mt2060_if1[2]; 40 u16 mt2060_if1[2];
41 u8 rc_toggle; 41 u8 rc_toggle;
42 u8 rc_counter; 42 u8 rc_counter;
43 u8 rc_func_version;
43 u8 is_dib7000pc; 44 u8 is_dib7000pc;
44 u8 fw_use_new_i2c_api; 45 u8 fw_use_new_i2c_api;
45 u8 disable_streaming_master_mode; 46 u8 disable_streaming_master_mode;
46}; 47};
47 48
49extern int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
50 u32 *romversion, u32 *ramversion, u32 *fwtype);
48extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val); 51extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val);
49extern int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3); 52extern int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3);
50extern int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen); 53extern int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen);
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index dd53cee3896d..200b215f4d8b 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -19,6 +19,22 @@ MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (defau
19 19
20DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 20DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
21 21
22
23int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
24 u32 *romversion, u32 *ramversion, u32 *fwtype)
25{
26 u8 b[16];
27 int ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
28 REQUEST_GET_VERSION,
29 USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
30 b, sizeof(b), USB_CTRL_GET_TIMEOUT);
31 *hwversion = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
32 *romversion = (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | b[7];
33 *ramversion = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
34 *fwtype = (b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15];
35 return ret;
36}
37
22/* expecting rx buffer: request data[0] data[1] ... data[2] */ 38/* expecting rx buffer: request data[0] data[1] ... data[2] */
23static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen) 39static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
24{ 40{
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 0cfccc24b190..391732788911 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -38,6 +38,7 @@ static struct mt2060_config bristol_mt2060_config[2] = {
38 } 38 }
39}; 39};
40 40
41
41static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = { 42static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
42 .band_caps = BAND_VHF | BAND_UHF, 43 .band_caps = BAND_VHF | BAND_UHF,
43 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0), 44 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
@@ -445,14 +446,19 @@ static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
445 == NULL ? -ENODEV : 0; 446 == NULL ? -ENODEV : 0;
446} 447}
447 448
448#define DEFAULT_RC_INTERVAL 150 449#define DEFAULT_RC_INTERVAL 50
449 450
450static u8 rc_request[] = { REQUEST_POLL_RC, 0 }; 451static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
451 452
452/* Number of keypresses to ignore before start repeating */ 453/* Number of keypresses to ignore before start repeating */
453#define RC_REPEAT_DELAY 2 454#define RC_REPEAT_DELAY 6
455#define RC_REPEAT_DELAY_V1_20 10
454 456
455static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 457
458
459/* Used by firmware versions < 1.20 (deprecated) */
460static int dib0700_rc_query_legacy(struct dvb_usb_device *d, u32 *event,
461 int *state)
456{ 462{
457 u8 key[4]; 463 u8 key[4];
458 int i; 464 int i;
@@ -529,6 +535,137 @@ static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
529 return 0; 535 return 0;
530} 536}
531 537
538/* This is the structure of the RC response packet starting in firmware 1.20 */
539struct dib0700_rc_response {
540 u8 report_id;
541 u8 data_state;
542 u8 system_msb;
543 u8 system_lsb;
544 u8 data;
545 u8 not_data;
546};
547
548/* This supports the new IR response format for firmware v1.20 */
549static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
550 int *state)
551{
552 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
553 struct dib0700_state *st = d->priv;
554 struct dib0700_rc_response poll_reply;
555 u8 buf[6];
556 int i;
557 int status;
558 int actlen;
559 int found = 0;
560
561 /* Set initial results in case we exit the function early */
562 *event = 0;
563 *state = REMOTE_NO_KEY_PRESSED;
564
565 /* Firmware v1.20 provides RC data via bulk endpoint 1 */
566 status = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, 1), buf,
567 sizeof(buf), &actlen, 50);
568 if (status < 0) {
569 /* No data available (meaning no key press) */
570 return 0;
571 }
572
573 if (actlen != sizeof(buf)) {
574 /* We didn't get back the 6 byte message we expected */
575 err("Unexpected RC response size [%d]", actlen);
576 return -1;
577 }
578
579 poll_reply.report_id = buf[0];
580 poll_reply.data_state = buf[1];
581 poll_reply.system_msb = buf[2];
582 poll_reply.system_lsb = buf[3];
583 poll_reply.data = buf[4];
584 poll_reply.not_data = buf[5];
585
586 /*
587 info("rid=%02x ds=%02x sm=%02x sl=%02x d=%02x nd=%02x\n",
588 poll_reply.report_id, poll_reply.data_state,
589 poll_reply.system_msb, poll_reply.system_lsb,
590 poll_reply.data, poll_reply.not_data);
591 */
592
593 if ((poll_reply.data + poll_reply.not_data) != 0xff) {
594 /* Key failed integrity check */
595 err("key failed integrity check: %02x %02x %02x %02x",
596 poll_reply.system_msb, poll_reply.system_lsb,
597 poll_reply.data, poll_reply.not_data);
598 return -1;
599 }
600
601 /* Find the key in the map */
602 for (i = 0; i < d->props.rc_key_map_size; i++) {
603 if (keymap[i].custom == poll_reply.system_lsb &&
604 keymap[i].data == poll_reply.data) {
605 *event = keymap[i].event;
606 found = 1;
607 break;
608 }
609 }
610
611 if (found == 0) {
612 err("Unknown remote controller key: %02x %02x %02x %02x",
613 poll_reply.system_msb, poll_reply.system_lsb,
614 poll_reply.data, poll_reply.not_data);
615 d->last_event = 0;
616 return 0;
617 }
618
619 if (poll_reply.data_state == 1) {
620 /* New key hit */
621 st->rc_counter = 0;
622 *event = keymap[i].event;
623 *state = REMOTE_KEY_PRESSED;
624 d->last_event = keymap[i].event;
625 } else if (poll_reply.data_state == 2) {
626 /* Key repeated */
627 st->rc_counter++;
628
629 /* prevents unwanted double hits */
630 if (st->rc_counter > RC_REPEAT_DELAY_V1_20) {
631 *event = d->last_event;
632 *state = REMOTE_KEY_PRESSED;
633 st->rc_counter = RC_REPEAT_DELAY_V1_20;
634 }
635 } else {
636 err("Unknown data state [%d]", poll_reply.data_state);
637 }
638
639 return 0;
640}
641
642static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
643{
644 struct dib0700_state *st = d->priv;
645
646 /* Because some people may have improperly named firmware files,
647 let's figure out whether to use the new firmware call or the legacy
648 call based on the firmware version embedded in the file */
649 if (st->rc_func_version == 0) {
650 u32 hwver, romver, ramver, fwtype;
651 int ret = dib0700_get_version(d, &hwver, &romver, &ramver,
652 &fwtype);
653 if (ret < 0) {
654 err("Could not determine version info");
655 return -1;
656 }
657 if (ramver < 0x10200)
658 st->rc_func_version = 1;
659 else
660 st->rc_func_version = 2;
661 }
662
663 if (st->rc_func_version == 2)
664 return dib0700_rc_query_v1_20(d, event, state);
665 else
666 return dib0700_rc_query_legacy(d, event, state);
667}
668
532static struct dvb_usb_rc_key dib0700_rc_keys[] = { 669static struct dvb_usb_rc_key dib0700_rc_keys[] = {
533 /* Key codes for the tiny Pinnacle remote*/ 670 /* Key codes for the tiny Pinnacle remote*/
534 { 0x07, 0x00, KEY_MUTE }, 671 { 0x07, 0x00, KEY_MUTE },
diff --git a/drivers/media/dvb/dvb-usb/usb-urb.c b/drivers/media/dvb/dvb-usb/usb-urb.c
index 397f51a7b2ad..da93b9e982c0 100644
--- a/drivers/media/dvb/dvb-usb/usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/usb-urb.c
@@ -135,7 +135,7 @@ stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num])
135 135
136static int usb_bulk_urb_init(struct usb_data_stream *stream) 136static int usb_bulk_urb_init(struct usb_data_stream *stream)
137{ 137{
138 int i; 138 int i, j;
139 139
140 if ((i = usb_allocate_stream_buffers(stream,stream->props.count, 140 if ((i = usb_allocate_stream_buffers(stream,stream->props.count,
141 stream->props.u.bulk.buffersize)) < 0) 141 stream->props.u.bulk.buffersize)) < 0)
@@ -143,9 +143,13 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream)
143 143
144 /* allocate the URBs */ 144 /* allocate the URBs */
145 for (i = 0; i < stream->props.count; i++) { 145 for (i = 0; i < stream->props.count; i++) {
146 if ((stream->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL) 146 stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
147 if (!stream->urb_list[i]) {
148 deb_mem("not enough memory for urb_alloc_urb!.\n");
149 for (j = 0; j < i; j++)
150 usb_free_urb(stream->urb_list[i]);
147 return -ENOMEM; 151 return -ENOMEM;
148 152 }
149 usb_fill_bulk_urb( stream->urb_list[i], stream->udev, 153 usb_fill_bulk_urb( stream->urb_list[i], stream->udev,
150 usb_rcvbulkpipe(stream->udev,stream->props.endpoint), 154 usb_rcvbulkpipe(stream->udev,stream->props.endpoint),
151 stream->buf_list[i], 155 stream->buf_list[i],
@@ -170,9 +174,14 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
170 for (i = 0; i < stream->props.count; i++) { 174 for (i = 0; i < stream->props.count; i++) {
171 struct urb *urb; 175 struct urb *urb;
172 int frame_offset = 0; 176 int frame_offset = 0;
173 if ((stream->urb_list[i] = 177
174 usb_alloc_urb(stream->props.u.isoc.framesperurb,GFP_ATOMIC)) == NULL) 178 stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC);
179 if (!stream->urb_list[i]) {
180 deb_mem("not enough memory for urb_alloc_urb!\n");
181 for (j = 0; j < i; j++)
182 usb_free_urb(stream->urb_list[i]);
175 return -ENOMEM; 183 return -ENOMEM;
184 }
176 185
177 urb = stream->urb_list[i]; 186 urb = stream->urb_list[i];
178 187
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c
index 6f9b77360440..e98d6caf2c23 100644
--- a/drivers/media/dvb/siano/sms-cards.c
+++ b/drivers/media/dvb/siano/sms-cards.c
@@ -95,7 +95,7 @@ static struct sms_board sms_boards[] = {
95 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = { 95 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = {
96 .name = "Hauppauge WinTV MiniStick", 96 .name = "Hauppauge WinTV MiniStick",
97 .type = SMS_NOVA_B0, 97 .type = SMS_NOVA_B0,
98 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-01.fw", 98 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
99 }, 99 },
100}; 100};
101 101
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index 867027ceab3e..401a04effc06 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -106,7 +106,7 @@ config DVB_BUDGET_CI
106 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 106 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
107 select DVB_LNBP21 if !DVB_FE_CUSTOMISE 107 select DVB_LNBP21 if !DVB_FE_CUSTOMISE
108 select DVB_TDA10023 if !DVB_FE_CUSTOMISE 108 select DVB_TDA10023 if !DVB_FE_CUSTOMISE
109 select MEDIA_TUNER_TDA827X if !DVB_FE_CUSTOMISE 109 select MEDIA_TUNER_TDA827X if !MEDIA_TUNER_CUSTOMIZE
110 select VIDEO_IR 110 select VIDEO_IR
111 help 111 help
112 Support for simple SAA7146 based DVB cards 112 Support for simple SAA7146 based DVB cards
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 66ab0c6e9783..4a3f2b8ea37d 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -808,6 +808,12 @@ static int ttusb_alloc_iso_urbs(struct ttusb *ttusb)
808 ISO_BUF_COUNT, 808 ISO_BUF_COUNT,
809 &ttusb->iso_dma_handle); 809 &ttusb->iso_dma_handle);
810 810
811 if (!ttusb->iso_buffer) {
812 dprintk("%s: pci_alloc_consistent - not enough memory\n",
813 __func__);
814 return -ENOMEM;
815 }
816
811 memset(ttusb->iso_buffer, 0, 817 memset(ttusb->iso_buffer, 0,
812 ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT); 818 ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT);
813 819
@@ -1659,7 +1665,14 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1659 1665
1660 ttusb_setup_interfaces(ttusb); 1666 ttusb_setup_interfaces(ttusb);
1661 1667
1662 ttusb_alloc_iso_urbs(ttusb); 1668 result = ttusb_alloc_iso_urbs(ttusb);
1669 if (result < 0) {
1670 dprintk("%s: ttusb_alloc_iso_urbs - failed\n", __func__);
1671 mutex_unlock(&ttusb->semi2c);
1672 kfree(ttusb);
1673 return result;
1674 }
1675
1663 if (ttusb_init_controller(ttusb)) 1676 if (ttusb_init_controller(ttusb))
1664 printk("ttusb_init_controller: error\n"); 1677 printk("ttusb_init_controller: error\n");
1665 1678
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index ab33fec8a19f..0aa96df80fc2 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1157,6 +1157,12 @@ static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec)
1157 ISO_BUF_COUNT), 1157 ISO_BUF_COUNT),
1158 &dec->iso_dma_handle); 1158 &dec->iso_dma_handle);
1159 1159
1160 if (!dec->iso_buffer) {
1161 dprintk("%s: pci_alloc_consistent - not enough memory\n",
1162 __func__);
1163 return -ENOMEM;
1164 }
1165
1160 memset(dec->iso_buffer, 0, 1166 memset(dec->iso_buffer, 0,
1161 ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT)); 1167 ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT));
1162 1168
@@ -1254,6 +1260,7 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1254 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE, 1260 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE,
1255 GFP_ATOMIC, &dec->irq_dma_handle); 1261 GFP_ATOMIC, &dec->irq_dma_handle);
1256 if(!dec->irq_buffer) { 1262 if(!dec->irq_buffer) {
1263 usb_free_urb(dec->irq_urb);
1257 return -ENOMEM; 1264 return -ENOMEM;
1258 } 1265 }
1259 usb_fill_int_urb(dec->irq_urb, dec->udev,dec->irq_pipe, 1266 usb_fill_int_urb(dec->irq_urb, dec->udev,dec->irq_pipe,
diff --git a/drivers/media/video/compat_ioctl32.c b/drivers/media/video/compat_ioctl32.c
index e6ca4012b5f0..0ea85a05e5c0 100644
--- a/drivers/media/video/compat_ioctl32.c
+++ b/drivers/media/video/compat_ioctl32.c
@@ -831,7 +831,7 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
831{ 831{
832 int ret = -ENOIOCTLCMD; 832 int ret = -ENOIOCTLCMD;
833 833
834 if (!file->f_op->ioctl) 834 if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl)
835 return ret; 835 return ret;
836 836
837 switch (cmd) { 837 switch (cmd) {
diff --git a/drivers/media/video/cx18/Kconfig b/drivers/media/video/cx18/Kconfig
index ef48565de7f1..8940b5387dec 100644
--- a/drivers/media/video/cx18/Kconfig
+++ b/drivers/media/video/cx18/Kconfig
@@ -9,7 +9,7 @@ config VIDEO_CX18
9 select VIDEO_CX2341X 9 select VIDEO_CX2341X
10 select VIDEO_CS5345 10 select VIDEO_CS5345
11 select DVB_S5H1409 if !DVB_FE_CUSTOMISE 11 select DVB_S5H1409 if !DVB_FE_CUSTOMISE
12 select MEDIA_TUNER_MXL5005S if !DVB_FE_CUSTOMISE 12 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMIZE
13 ---help--- 13 ---help---
14 This is a video4linux driver for Conexant cx23418 based 14 This is a video4linux driver for Conexant cx23418 based
15 PCI combo video recorder devices. 15 PCI combo video recorder devices.
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig
index 8c1b7fa47a41..00f1e2e8889e 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -11,16 +11,16 @@ config VIDEO_CX23885
11 select VIDEO_CX25840 11 select VIDEO_CX25840
12 select VIDEO_CX2341X 12 select VIDEO_CX2341X
13 select DVB_DIB7000P if !DVB_FE_CUSTOMISE 13 select DVB_DIB7000P if !DVB_FE_CUSTOMISE
14 select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE
15 select DVB_S5H1409 if !DVB_FE_CUSTOMISE 14 select DVB_S5H1409 if !DVB_FE_CUSTOMISE
16 select DVB_S5H1411 if !DVB_FE_CUSTOMISE 15 select DVB_S5H1411 if !DVB_FE_CUSTOMISE
17 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 16 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
18 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 17 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
18 select DVB_TDA10048 if !DVB_FE_CUSTOMIZE
19 select MEDIA_TUNER_MT2131 if !MEDIA_TUNER_CUSTOMIZE
19 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE 20 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE
20 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE 21 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE
21 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE 22 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE
22 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE 23 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE
23 select DVB_TDA10048 if !DVB_FE_CUSTOMIZE
24 ---help--- 24 ---help---
25 This is a video4linux driver for Conexant 23885 based 25 This is a video4linux driver for Conexant 23885 based
26 TV cards. 26 TV cards.
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index 0b9e5fac6239..b0f837588e01 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -56,12 +56,12 @@ config VIDEO_CX88_DVB
56 select DVB_NXT200X if !DVB_FE_CUSTOMISE 56 select DVB_NXT200X if !DVB_FE_CUSTOMISE
57 select DVB_CX24123 if !DVB_FE_CUSTOMISE 57 select DVB_CX24123 if !DVB_FE_CUSTOMISE
58 select DVB_ISL6421 if !DVB_FE_CUSTOMISE 58 select DVB_ISL6421 if !DVB_FE_CUSTOMISE
59 select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE
60 select DVB_S5H1411 if !DVB_FE_CUSTOMISE 59 select DVB_S5H1411 if !DVB_FE_CUSTOMISE
61 select DVB_CX24116 if !DVB_FE_CUSTOMISE 60 select DVB_CX24116 if !DVB_FE_CUSTOMISE
62 select DVB_STV0299 if !DVB_FE_CUSTOMISE 61 select DVB_STV0299 if !DVB_FE_CUSTOMISE
63 select DVB_STV0288 if !DVB_FE_CUSTOMISE 62 select DVB_STV0288 if !DVB_FE_CUSTOMISE
64 select DVB_STB6000 if !DVB_FE_CUSTOMISE 63 select DVB_STB6000 if !DVB_FE_CUSTOMISE
64 select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE
65 ---help--- 65 ---help---
66 This adds support for DVB/ATSC cards based on the 66 This adds support for DVB/ATSC cards based on the
67 Conexant 2388x chip. 67 Conexant 2388x chip.
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index ac3292d7646c..7a8d49ef646e 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -62,7 +62,7 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev)
62 62
63 dprintk("Stopping isoc\n"); 63 dprintk("Stopping isoc\n");
64 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { 64 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
65 usb_kill_urb(dev->adev->urb[i]); 65 usb_unlink_urb(dev->adev->urb[i]);
66 usb_free_urb(dev->adev->urb[i]); 66 usb_free_urb(dev->adev->urb[i]);
67 dev->adev->urb[i] = NULL; 67 dev->adev->urb[i] = NULL;
68 } 68 }
@@ -75,7 +75,6 @@ static void em28xx_audio_isocirq(struct urb *urb)
75 struct em28xx *dev = urb->context; 75 struct em28xx *dev = urb->context;
76 int i; 76 int i;
77 unsigned int oldptr; 77 unsigned int oldptr;
78 unsigned long flags;
79 int period_elapsed = 0; 78 int period_elapsed = 0;
80 int status; 79 int status;
81 unsigned char *cp; 80 unsigned char *cp;
@@ -96,9 +95,21 @@ static void em28xx_audio_isocirq(struct urb *urb)
96 if (!length) 95 if (!length)
97 continue; 96 continue;
98 97
99 spin_lock_irqsave(&dev->adev->slock, flags);
100
101 oldptr = dev->adev->hwptr_done_capture; 98 oldptr = dev->adev->hwptr_done_capture;
99 if (oldptr + length >= runtime->buffer_size) {
100 unsigned int cnt =
101 runtime->buffer_size - oldptr;
102 memcpy(runtime->dma_area + oldptr * stride, cp,
103 cnt * stride);
104 memcpy(runtime->dma_area, cp + cnt * stride,
105 length * stride - cnt * stride);
106 } else {
107 memcpy(runtime->dma_area + oldptr * stride, cp,
108 length * stride);
109 }
110
111 snd_pcm_stream_lock(substream);
112
102 dev->adev->hwptr_done_capture += length; 113 dev->adev->hwptr_done_capture += length;
103 if (dev->adev->hwptr_done_capture >= 114 if (dev->adev->hwptr_done_capture >=
104 runtime->buffer_size) 115 runtime->buffer_size)
@@ -113,19 +124,7 @@ static void em28xx_audio_isocirq(struct urb *urb)
113 period_elapsed = 1; 124 period_elapsed = 1;
114 } 125 }
115 126
116 spin_unlock_irqrestore(&dev->adev->slock, flags); 127 snd_pcm_stream_unlock(substream);
117
118 if (oldptr + length >= runtime->buffer_size) {
119 unsigned int cnt =
120 runtime->buffer_size - oldptr;
121 memcpy(runtime->dma_area + oldptr * stride, cp,
122 cnt * stride);
123 memcpy(runtime->dma_area, cp + cnt * stride,
124 length * stride - cnt * stride);
125 } else {
126 memcpy(runtime->dma_area + oldptr * stride, cp,
127 length * stride);
128 }
129 } 128 }
130 if (period_elapsed) 129 if (period_elapsed)
131 snd_pcm_period_elapsed(substream); 130 snd_pcm_period_elapsed(substream);
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 5d837c16ee22..15e2b525310d 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -69,19 +69,33 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
69 int ret, byte; 69 int ret, byte;
70 70
71 if (dev->state & DEV_DISCONNECTED) 71 if (dev->state & DEV_DISCONNECTED)
72 return(-ENODEV); 72 return -ENODEV;
73
74 if (len > URB_MAX_CTRL_SIZE)
75 return -EINVAL;
73 76
74 em28xx_regdbg("req=%02x, reg=%02x ", req, reg); 77 em28xx_regdbg("req=%02x, reg=%02x ", req, reg);
75 78
79 mutex_lock(&dev->ctrl_urb_lock);
76 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 80 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
77 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 81 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
78 0x0000, reg, buf, len, HZ); 82 0x0000, reg, dev->urb_buf, len, HZ);
83 if (ret < 0) {
84 if (reg_debug)
85 printk(" failed!\n");
86 mutex_unlock(&dev->ctrl_urb_lock);
87 return ret;
88 }
89
90 if (len)
91 memcpy(buf, dev->urb_buf, len);
92
93 mutex_unlock(&dev->ctrl_urb_lock);
79 94
80 if (reg_debug) { 95 if (reg_debug) {
81 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); 96 printk("%02x values: ", ret);
82 for (byte = 0; byte < len; byte++) 97 for (byte = 0; byte < len; byte++)
83 printk(" %02x", (unsigned char)buf[byte]); 98 printk(" %02x", (unsigned char)buf[byte]);
84
85 printk("\n"); 99 printk("\n");
86 } 100 }
87 101
@@ -102,16 +116,20 @@ int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg)
102 116
103 em28xx_regdbg("req=%02x, reg=%02x:", req, reg); 117 em28xx_regdbg("req=%02x, reg=%02x:", req, reg);
104 118
119 mutex_lock(&dev->ctrl_urb_lock);
105 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 120 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
106 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 121 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
107 0x0000, reg, &val, 1, HZ); 122 0x0000, reg, dev->urb_buf, 1, HZ);
108 123 val = dev->urb_buf[0];
109 if (reg_debug) 124 mutex_unlock(&dev->ctrl_urb_lock);
110 printk(ret < 0 ? " failed!\n" :
111 "%02x\n", (unsigned char) val);
112 125
113 if (ret < 0) 126 if (ret < 0) {
127 printk(" failed!\n");
114 return ret; 128 return ret;
129 }
130
131 if (reg_debug)
132 printk("%02x\n", (unsigned char) val);
115 133
116 return val; 134 return val;
117} 135}
@@ -130,19 +148,13 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
130{ 148{
131 int ret; 149 int ret;
132 150
133 /*usb_control_msg seems to expect a kmalloced buffer */
134 unsigned char *bufs;
135
136 if (dev->state & DEV_DISCONNECTED) 151 if (dev->state & DEV_DISCONNECTED)
137 return -ENODEV; 152 return -ENODEV;
138 153
139 if (len < 1) 154 if ((len < 1) || (len > URB_MAX_CTRL_SIZE))
140 return -EINVAL; 155 return -EINVAL;
141 156
142 bufs = kmalloc(len, GFP_KERNEL);
143
144 em28xx_regdbg("req=%02x reg=%02x:", req, reg); 157 em28xx_regdbg("req=%02x reg=%02x:", req, reg);
145
146 if (reg_debug) { 158 if (reg_debug) {
147 int i; 159 int i;
148 for (i = 0; i < len; ++i) 160 for (i = 0; i < len; ++i)
@@ -150,16 +162,16 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
150 printk("\n"); 162 printk("\n");
151 } 163 }
152 164
153 if (!bufs) 165 mutex_lock(&dev->ctrl_urb_lock);
154 return -ENOMEM; 166 memcpy(dev->urb_buf, buf, len);
155 memcpy(bufs, buf, len);
156 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req, 167 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req,
157 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 168 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
158 0x0000, reg, bufs, len, HZ); 169 0x0000, reg, dev->urb_buf, len, HZ);
170 mutex_unlock(&dev->ctrl_urb_lock);
171
159 if (dev->wait_after_write) 172 if (dev->wait_after_write)
160 msleep(dev->wait_after_write); 173 msleep(dev->wait_after_write);
161 174
162 kfree(bufs);
163 return ret; 175 return ret;
164} 176}
165 177
@@ -270,6 +282,8 @@ static int em28xx_set_audio_source(struct em28xx *dev)
270 break; 282 break;
271 case EM28XX_AMUX_LINE_IN: 283 case EM28XX_AMUX_LINE_IN:
272 input = EM28XX_AUDIO_SRC_LINE; 284 input = EM28XX_AUDIO_SRC_LINE;
285 video = disable;
286 line = enable;
273 break; 287 break;
274 case EM28XX_AMUX_AC97_VIDEO: 288 case EM28XX_AMUX_AC97_VIDEO:
275 input = EM28XX_AUDIO_SRC_LINE; 289 input = EM28XX_AUDIO_SRC_LINE;
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index 3bab56b997fc..2360c61ddca9 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -337,9 +337,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
337 /* Check if board has eeprom */ 337 /* Check if board has eeprom */
338 err = i2c_master_recv(&dev->i2c_client, &buf, 0); 338 err = i2c_master_recv(&dev->i2c_client, &buf, 0);
339 if (err < 0) { 339 if (err < 0) {
340 em28xx_errdev("%s: i2c_master_recv failed! err [%d]\n", 340 em28xx_errdev("board has no eeprom\n");
341 __func__, err); 341 memset(eedata, 0, len);
342 return err; 342 return -ENODEV;
343 } 343 }
344 344
345 buf = 0; 345 buf = 0;
@@ -609,14 +609,16 @@ int em28xx_i2c_register(struct em28xx *dev)
609 dev->i2c_client.adapter = &dev->i2c_adap; 609 dev->i2c_client.adapter = &dev->i2c_adap;
610 610
611 retval = em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata)); 611 retval = em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata));
612 if (retval < 0) { 612 if ((retval < 0) && (retval != -ENODEV)) {
613 em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n", 613 em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n",
614 __func__, retval); 614 __func__, retval);
615
615 return retval; 616 return retval;
616 } 617 }
617 618
618 if (i2c_scan) 619 if (i2c_scan)
619 em28xx_do_i2c_scan(dev); 620 em28xx_do_i2c_scan(dev);
621
620 return 0; 622 return 0;
621} 623}
622 624
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index a1ab2ef45578..4ea1f1e04897 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -73,6 +73,7 @@ MODULE_DESCRIPTION(DRIVER_DESC);
73MODULE_LICENSE("GPL"); 73MODULE_LICENSE("GPL");
74 74
75static LIST_HEAD(em28xx_devlist); 75static LIST_HEAD(em28xx_devlist);
76static DEFINE_MUTEX(em28xx_devlist_mutex);
76 77
77static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; 78static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
78static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; 79static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
@@ -548,10 +549,11 @@ static int em28xx_config(struct em28xx *dev)
548static void em28xx_config_i2c(struct em28xx *dev) 549static void em28xx_config_i2c(struct em28xx *dev)
549{ 550{
550 struct v4l2_routing route; 551 struct v4l2_routing route;
552 int zero = 0;
551 553
552 route.input = INPUT(dev->ctl_input)->vmux; 554 route.input = INPUT(dev->ctl_input)->vmux;
553 route.output = 0; 555 route.output = 0;
554 em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, NULL); 556 em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, &zero);
555 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); 557 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
556 em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL); 558 em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL);
557} 559}
@@ -1519,7 +1521,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1519 struct em28xx_fh *fh; 1521 struct em28xx_fh *fh;
1520 enum v4l2_buf_type fh_type = 0; 1522 enum v4l2_buf_type fh_type = 0;
1521 1523
1522 lock_kernel(); 1524 mutex_lock(&em28xx_devlist_mutex);
1523 list_for_each_entry(h, &em28xx_devlist, devlist) { 1525 list_for_each_entry(h, &em28xx_devlist, devlist) {
1524 if (h->vdev->minor == minor) { 1526 if (h->vdev->minor == minor) {
1525 dev = h; 1527 dev = h;
@@ -1535,10 +1537,11 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1535 dev = h; 1537 dev = h;
1536 } 1538 }
1537 } 1539 }
1538 if (NULL == dev) { 1540 mutex_unlock(&em28xx_devlist_mutex);
1539 unlock_kernel(); 1541 if (NULL == dev)
1540 return -ENODEV; 1542 return -ENODEV;
1541 } 1543
1544 mutex_lock(&dev->lock);
1542 1545
1543 em28xx_videodbg("open minor=%d type=%s users=%d\n", 1546 em28xx_videodbg("open minor=%d type=%s users=%d\n",
1544 minor, v4l2_type_names[fh_type], dev->users); 1547 minor, v4l2_type_names[fh_type], dev->users);
@@ -1547,10 +1550,9 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1547 fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); 1550 fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL);
1548 if (!fh) { 1551 if (!fh) {
1549 em28xx_errdev("em28xx-video.c: Out of memory?!\n"); 1552 em28xx_errdev("em28xx-video.c: Out of memory?!\n");
1550 unlock_kernel(); 1553 mutex_unlock(&dev->lock);
1551 return -ENOMEM; 1554 return -ENOMEM;
1552 } 1555 }
1553 mutex_lock(&dev->lock);
1554 fh->dev = dev; 1556 fh->dev = dev;
1555 fh->radio = radio; 1557 fh->radio = radio;
1556 fh->type = fh_type; 1558 fh->type = fh_type;
@@ -1584,7 +1586,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1584 sizeof(struct em28xx_buffer), fh); 1586 sizeof(struct em28xx_buffer), fh);
1585 1587
1586 mutex_unlock(&dev->lock); 1588 mutex_unlock(&dev->lock);
1587 unlock_kernel();
1588 1589
1589 return errCode; 1590 return errCode;
1590} 1591}
@@ -1871,6 +1872,7 @@ int em28xx_register_extension(struct em28xx_ops *ops)
1871{ 1872{
1872 struct em28xx *dev = NULL; 1873 struct em28xx *dev = NULL;
1873 1874
1875 mutex_lock(&em28xx_devlist_mutex);
1874 mutex_lock(&em28xx_extension_devlist_lock); 1876 mutex_lock(&em28xx_extension_devlist_lock);
1875 list_add_tail(&ops->next, &em28xx_extension_devlist); 1877 list_add_tail(&ops->next, &em28xx_extension_devlist);
1876 list_for_each_entry(dev, &em28xx_devlist, devlist) { 1878 list_for_each_entry(dev, &em28xx_devlist, devlist) {
@@ -1879,6 +1881,7 @@ int em28xx_register_extension(struct em28xx_ops *ops)
1879 } 1881 }
1880 printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name); 1882 printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name);
1881 mutex_unlock(&em28xx_extension_devlist_lock); 1883 mutex_unlock(&em28xx_extension_devlist_lock);
1884 mutex_unlock(&em28xx_devlist_mutex);
1882 return 0; 1885 return 0;
1883} 1886}
1884EXPORT_SYMBOL(em28xx_register_extension); 1887EXPORT_SYMBOL(em28xx_register_extension);
@@ -1887,6 +1890,7 @@ void em28xx_unregister_extension(struct em28xx_ops *ops)
1887{ 1890{
1888 struct em28xx *dev = NULL; 1891 struct em28xx *dev = NULL;
1889 1892
1893 mutex_lock(&em28xx_devlist_mutex);
1890 list_for_each_entry(dev, &em28xx_devlist, devlist) { 1894 list_for_each_entry(dev, &em28xx_devlist, devlist) {
1891 if (dev) 1895 if (dev)
1892 ops->fini(dev); 1896 ops->fini(dev);
@@ -1896,6 +1900,7 @@ void em28xx_unregister_extension(struct em28xx_ops *ops)
1896 printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); 1900 printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name);
1897 list_del(&ops->next); 1901 list_del(&ops->next);
1898 mutex_unlock(&em28xx_extension_devlist_lock); 1902 mutex_unlock(&em28xx_extension_devlist_lock);
1903 mutex_unlock(&em28xx_devlist_mutex);
1899} 1904}
1900EXPORT_SYMBOL(em28xx_unregister_extension); 1905EXPORT_SYMBOL(em28xx_unregister_extension);
1901 1906
@@ -1921,6 +1926,60 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
1921} 1926}
1922 1927
1923 1928
1929static int register_analog_devices(struct em28xx *dev)
1930{
1931 int ret;
1932
1933 /* allocate and fill video video_device struct */
1934 dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video");
1935 if (!dev->vdev) {
1936 em28xx_errdev("cannot allocate video_device.\n");
1937 return -ENODEV;
1938 }
1939
1940 /* register v4l2 video video_device */
1941 ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
1942 video_nr[dev->devno]);
1943 if (ret) {
1944 em28xx_errdev("unable to register video device (error=%i).\n",
1945 ret);
1946 return ret;
1947 }
1948
1949 /* Allocate and fill vbi video_device struct */
1950 dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, "vbi");
1951
1952 /* register v4l2 vbi video_device */
1953 ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
1954 vbi_nr[dev->devno]);
1955 if (ret < 0) {
1956 em28xx_errdev("unable to register vbi device\n");
1957 return ret;
1958 }
1959
1960 if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) {
1961 dev->radio_dev = em28xx_vdev_init(dev, &em28xx_radio_template, "radio");
1962 if (!dev->radio_dev) {
1963 em28xx_errdev("cannot allocate video_device.\n");
1964 return -ENODEV;
1965 }
1966 ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO,
1967 radio_nr[dev->devno]);
1968 if (ret < 0) {
1969 em28xx_errdev("can't register radio device\n");
1970 return ret;
1971 }
1972 em28xx_info("Registered radio device as /dev/radio%d\n",
1973 dev->radio_dev->num);
1974 }
1975
1976 em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n",
1977 dev->vdev->num, dev->vbi_dev->num);
1978
1979 return 0;
1980}
1981
1982
1924/* 1983/*
1925 * em28xx_init_dev() 1984 * em28xx_init_dev()
1926 * allocates and inits the device structs, registers i2c bus and v4l device 1985 * allocates and inits the device structs, registers i2c bus and v4l device
@@ -1936,6 +1995,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1936 1995
1937 dev->udev = udev; 1996 dev->udev = udev;
1938 mutex_init(&dev->lock); 1997 mutex_init(&dev->lock);
1998 mutex_init(&dev->ctrl_urb_lock);
1939 spin_lock_init(&dev->slock); 1999 spin_lock_init(&dev->slock);
1940 init_waitqueue_head(&dev->open); 2000 init_waitqueue_head(&dev->open);
1941 init_waitqueue_head(&dev->wait_frame); 2001 init_waitqueue_head(&dev->wait_frame);
@@ -1953,8 +2013,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1953 errCode = em28xx_config(dev); 2013 errCode = em28xx_config(dev);
1954 if (errCode) { 2014 if (errCode) {
1955 em28xx_errdev("error configuring device\n"); 2015 em28xx_errdev("error configuring device\n");
1956 em28xx_devused &= ~(1<<dev->devno);
1957 kfree(dev);
1958 return -ENOMEM; 2016 return -ENOMEM;
1959 } 2017 }
1960 2018
@@ -2001,50 +2059,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2001 return errCode; 2059 return errCode;
2002 } 2060 }
2003 2061
2004 list_add_tail(&dev->devlist, &em28xx_devlist);
2005
2006 /* allocate and fill video video_device struct */
2007 dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video");
2008 if (NULL == dev->vdev) {
2009 em28xx_errdev("cannot allocate video_device.\n");
2010 goto fail_unreg;
2011 }
2012
2013 /* register v4l2 video video_device */
2014 retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
2015 video_nr[dev->devno]);
2016 if (retval) {
2017 em28xx_errdev("unable to register video device (error=%i).\n",
2018 retval);
2019 goto fail_unreg;
2020 }
2021
2022 /* Allocate and fill vbi video_device struct */
2023 dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, "vbi");
2024 /* register v4l2 vbi video_device */
2025 if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
2026 vbi_nr[dev->devno]) < 0) {
2027 em28xx_errdev("unable to register vbi device\n");
2028 retval = -ENODEV;
2029 goto fail_unreg;
2030 }
2031
2032 if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) {
2033 dev->radio_dev = em28xx_vdev_init(dev, &em28xx_radio_template, "radio");
2034 if (NULL == dev->radio_dev) {
2035 em28xx_errdev("cannot allocate video_device.\n");
2036 goto fail_unreg;
2037 }
2038 retval = video_register_device(dev->radio_dev, VFL_TYPE_RADIO,
2039 radio_nr[dev->devno]);
2040 if (retval < 0) {
2041 em28xx_errdev("can't register radio device\n");
2042 goto fail_unreg;
2043 }
2044 em28xx_info("Registered radio device as /dev/radio%d\n",
2045 dev->radio_dev->num);
2046 }
2047
2048 /* init video dma queues */ 2062 /* init video dma queues */
2049 INIT_LIST_HEAD(&dev->vidq.active); 2063 INIT_LIST_HEAD(&dev->vidq.active);
2050 INIT_LIST_HEAD(&dev->vidq.queued); 2064 INIT_LIST_HEAD(&dev->vidq.queued);
@@ -2071,8 +2085,14 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2071 2085
2072 video_mux(dev, 0); 2086 video_mux(dev, 0);
2073 2087
2074 em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", 2088 mutex_lock(&em28xx_devlist_mutex);
2075 dev->vdev->num, dev->vbi_dev->num); 2089 list_add_tail(&dev->devlist, &em28xx_devlist);
2090 retval = register_analog_devices(dev);
2091 if (retval < 0) {
2092 em28xx_release_resources(dev);
2093 mutex_unlock(&em28xx_devlist_mutex);
2094 goto fail_reg_devices;
2095 }
2076 2096
2077 mutex_lock(&em28xx_extension_devlist_lock); 2097 mutex_lock(&em28xx_extension_devlist_lock);
2078 if (!list_empty(&em28xx_extension_devlist)) { 2098 if (!list_empty(&em28xx_extension_devlist)) {
@@ -2082,13 +2102,12 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2082 } 2102 }
2083 } 2103 }
2084 mutex_unlock(&em28xx_extension_devlist_lock); 2104 mutex_unlock(&em28xx_extension_devlist_lock);
2105 mutex_unlock(&em28xx_devlist_mutex);
2085 2106
2086 return 0; 2107 return 0;
2087 2108
2088fail_unreg: 2109fail_reg_devices:
2089 em28xx_release_resources(dev);
2090 mutex_unlock(&dev->lock); 2110 mutex_unlock(&dev->lock);
2091 kfree(dev);
2092 return retval; 2111 return retval;
2093} 2112}
2094 2113
@@ -2231,8 +2250,12 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2231 2250
2232 /* allocate device struct */ 2251 /* allocate device struct */
2233 retval = em28xx_init_dev(&dev, udev, nr); 2252 retval = em28xx_init_dev(&dev, udev, nr);
2234 if (retval) 2253 if (retval) {
2254 em28xx_devused &= ~(1<<dev->devno);
2255 kfree(dev);
2256
2235 return retval; 2257 return retval;
2258 }
2236 2259
2237 em28xx_info("Found %s\n", em28xx_boards[dev->model].name); 2260 em28xx_info("Found %s\n", em28xx_boards[dev->model].name);
2238 2261
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 82781178e0a3..5956e9b3062f 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -102,6 +102,9 @@
102#define EM28XX_MIN_BUF 4 102#define EM28XX_MIN_BUF 4
103#define EM28XX_DEF_BUF 8 103#define EM28XX_DEF_BUF 8
104 104
105/*Limits the max URB message size */
106#define URB_MAX_CTRL_SIZE 80
107
105/* Params for validated field */ 108/* Params for validated field */
106#define EM28XX_BOARD_NOT_VALIDATED 1 109#define EM28XX_BOARD_NOT_VALIDATED 1
107#define EM28XX_BOARD_VALIDATED 0 110#define EM28XX_BOARD_VALIDATED 0
@@ -430,6 +433,7 @@ struct em28xx {
430 433
431 /* locks */ 434 /* locks */
432 struct mutex lock; 435 struct mutex lock;
436 struct mutex ctrl_urb_lock; /* protects urb_buf */
433 /* spinlock_t queue_lock; */ 437 /* spinlock_t queue_lock; */
434 struct list_head inqueue, outqueue; 438 struct list_head inqueue, outqueue;
435 wait_queue_head_t open, wait_frame, wait_stream; 439 wait_queue_head_t open, wait_frame, wait_stream;
@@ -451,6 +455,8 @@ struct em28xx {
451 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ 455 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
452 struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ 456 struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */
453 char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ 457 char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */
458 char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */
459
454 /* helper funcs that call usb_control_msg */ 460 /* helper funcs that call usb_control_msg */
455 int (*em28xx_write_regs) (struct em28xx *dev, u16 reg, 461 int (*em28xx_write_regs) (struct em28xx *dev, u16 reg,
456 char *buf, int len); 462 char *buf, int len);
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index a9d51ba7c57c..de28354ea5ba 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -846,10 +846,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
846 return 0; 846 return 0;
847} 847}
848 848
849/* called on streamoff with alt 0 and on disconnect */
849static void sd_stop0(struct gspca_dev *gspca_dev) 850static void sd_stop0(struct gspca_dev *gspca_dev)
850{ 851{
851 int retry = 50; 852 int retry = 50;
852 853
854 if (!gspca_dev->present)
855 return;
853 reg_w_val(gspca_dev, 0x0000, 0x00); 856 reg_w_val(gspca_dev, 0x0000, 0x00);
854 reg_r(gspca_dev, 0x0002, 1); 857 reg_r(gspca_dev, 0x0002, 1);
855 reg_w_val(gspca_dev, 0x0053, 0x00); 858 reg_w_val(gspca_dev, 0x0053, 0x00);
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c
index 65d3cbfe6b27..607942fd7970 100644
--- a/drivers/media/video/gspca/finepix.c
+++ b/drivers/media/video/gspca/finepix.c
@@ -276,6 +276,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
276 /* Stop the state machine */ 276 /* Stop the state machine */
277 if (dev->state != FPIX_NOP) 277 if (dev->state != FPIX_NOP)
278 wait_for_completion(&dev->can_close); 278 wait_for_completion(&dev->can_close);
279}
280
281/* called on streamoff with alt 0 and disconnect */
282static void sd_stop0(struct gspca_dev *gspca_dev)
283{
284 struct usb_fpix *dev = (struct usb_fpix *) gspca_dev;
279 285
280 usb_free_urb(dev->control_urb); 286 usb_free_urb(dev->control_urb);
281 dev->control_urb = NULL; 287 dev->control_urb = NULL;
@@ -385,6 +391,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
385error: 391error:
386 /* Free the ressources */ 392 /* Free the ressources */
387 sd_stopN(gspca_dev); 393 sd_stopN(gspca_dev);
394 sd_stop0(gspca_dev);
388 return ret; 395 return ret;
389} 396}
390 397
@@ -425,6 +432,7 @@ static const struct sd_desc sd_desc = {
425 .init = sd_init, 432 .init = sd_init,
426 .start = sd_start, 433 .start = sd_start,
427 .stopN = sd_stopN, 434 .stopN = sd_stopN,
435 .stop0 = sd_stop0,
428}; 436};
429 437
430/* -- device connect -- */ 438/* -- device connect -- */
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index e48fbfc8ad05..02a6e9ef0337 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -646,15 +646,14 @@ static void gspca_stream_off(struct gspca_dev *gspca_dev)
646{ 646{
647 gspca_dev->streaming = 0; 647 gspca_dev->streaming = 0;
648 atomic_set(&gspca_dev->nevent, 0); 648 atomic_set(&gspca_dev->nevent, 0);
649 if (gspca_dev->present) { 649 if (gspca_dev->present
650 if (gspca_dev->sd_desc->stopN) 650 && gspca_dev->sd_desc->stopN)
651 gspca_dev->sd_desc->stopN(gspca_dev); 651 gspca_dev->sd_desc->stopN(gspca_dev);
652 destroy_urbs(gspca_dev); 652 destroy_urbs(gspca_dev);
653 gspca_set_alt0(gspca_dev); 653 gspca_set_alt0(gspca_dev);
654 if (gspca_dev->sd_desc->stop0) 654 if (gspca_dev->sd_desc->stop0)
655 gspca_dev->sd_desc->stop0(gspca_dev); 655 gspca_dev->sd_desc->stop0(gspca_dev);
656 PDEBUG(D_STREAM, "stream off OK"); 656 PDEBUG(D_STREAM, "stream off OK");
657 }
658} 657}
659 658
660static void gspca_set_default_mode(struct gspca_dev *gspca_dev) 659static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
@@ -863,7 +862,7 @@ static int dev_open(struct inode *inode, struct file *file)
863 int ret; 862 int ret;
864 863
865 PDEBUG(D_STREAM, "%s open", current->comm); 864 PDEBUG(D_STREAM, "%s open", current->comm);
866 gspca_dev = (struct gspca_dev *) video_devdata(file); 865 gspca_dev = video_drvdata(file);
867 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 866 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
868 return -ERESTARTSYS; 867 return -ERESTARTSYS;
869 if (!gspca_dev->present) { 868 if (!gspca_dev->present) {
@@ -875,6 +874,13 @@ static int dev_open(struct inode *inode, struct file *file)
875 ret = -EBUSY; 874 ret = -EBUSY;
876 goto out; 875 goto out;
877 } 876 }
877
878 /* protect the subdriver against rmmod */
879 if (!try_module_get(gspca_dev->module)) {
880 ret = -ENODEV;
881 goto out;
882 }
883
878 gspca_dev->users++; 884 gspca_dev->users++;
879 885
880 /* one more user */ 886 /* one more user */
@@ -884,10 +890,10 @@ static int dev_open(struct inode *inode, struct file *file)
884#ifdef GSPCA_DEBUG 890#ifdef GSPCA_DEBUG
885 /* activate the v4l2 debug */ 891 /* activate the v4l2 debug */
886 if (gspca_debug & D_V4L2) 892 if (gspca_debug & D_V4L2)
887 gspca_dev->vdev.debug |= V4L2_DEBUG_IOCTL 893 gspca_dev->vdev->debug |= V4L2_DEBUG_IOCTL
888 | V4L2_DEBUG_IOCTL_ARG; 894 | V4L2_DEBUG_IOCTL_ARG;
889 else 895 else
890 gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL 896 gspca_dev->vdev->debug &= ~(V4L2_DEBUG_IOCTL
891 | V4L2_DEBUG_IOCTL_ARG); 897 | V4L2_DEBUG_IOCTL_ARG);
892#endif 898#endif
893 ret = 0; 899 ret = 0;
@@ -921,6 +927,7 @@ static int dev_close(struct inode *inode, struct file *file)
921 gspca_dev->memory = GSPCA_MEMORY_NO; 927 gspca_dev->memory = GSPCA_MEMORY_NO;
922 } 928 }
923 file->private_data = NULL; 929 file->private_data = NULL;
930 module_put(gspca_dev->module);
924 mutex_unlock(&gspca_dev->queue_lock); 931 mutex_unlock(&gspca_dev->queue_lock);
925 932
926 PDEBUG(D_STREAM, "close done"); 933 PDEBUG(D_STREAM, "close done");
@@ -1257,10 +1264,10 @@ static int vidioc_s_jpegcomp(struct file *file, void *priv,
1257 struct gspca_dev *gspca_dev = priv; 1264 struct gspca_dev *gspca_dev = priv;
1258 int ret; 1265 int ret;
1259 1266
1260 if (mutex_lock_interruptible(&gspca_dev->usb_lock))
1261 return -ERESTARTSYS;
1262 if (!gspca_dev->sd_desc->set_jcomp) 1267 if (!gspca_dev->sd_desc->set_jcomp)
1263 return -EINVAL; 1268 return -EINVAL;
1269 if (mutex_lock_interruptible(&gspca_dev->usb_lock))
1270 return -ERESTARTSYS;
1264 ret = gspca_dev->sd_desc->set_jcomp(gspca_dev, jpegcomp); 1271 ret = gspca_dev->sd_desc->set_jcomp(gspca_dev, jpegcomp);
1265 mutex_unlock(&gspca_dev->usb_lock); 1272 mutex_unlock(&gspca_dev->usb_lock);
1266 return ret; 1273 return ret;
@@ -1748,11 +1755,6 @@ out:
1748 return ret; 1755 return ret;
1749} 1756}
1750 1757
1751static void dev_release(struct video_device *vfd)
1752{
1753 /* nothing */
1754}
1755
1756static struct file_operations dev_fops = { 1758static struct file_operations dev_fops = {
1757 .owner = THIS_MODULE, 1759 .owner = THIS_MODULE,
1758 .open = dev_open, 1760 .open = dev_open,
@@ -1800,7 +1802,7 @@ static struct video_device gspca_template = {
1800 .name = "gspca main driver", 1802 .name = "gspca main driver",
1801 .fops = &dev_fops, 1803 .fops = &dev_fops,
1802 .ioctl_ops = &dev_ioctl_ops, 1804 .ioctl_ops = &dev_ioctl_ops,
1803 .release = dev_release, /* mandatory */ 1805 .release = video_device_release,
1804 .minor = -1, 1806 .minor = -1,
1805}; 1807};
1806 1808
@@ -1869,17 +1871,18 @@ int gspca_dev_probe(struct usb_interface *intf,
1869 init_waitqueue_head(&gspca_dev->wq); 1871 init_waitqueue_head(&gspca_dev->wq);
1870 1872
1871 /* init video stuff */ 1873 /* init video stuff */
1872 memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template); 1874 gspca_dev->vdev = video_device_alloc();
1873 gspca_dev->vdev.parent = &dev->dev; 1875 memcpy(gspca_dev->vdev, &gspca_template, sizeof gspca_template);
1874 memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops); 1876 gspca_dev->vdev->parent = &dev->dev;
1875 gspca_dev->vdev.fops = &gspca_dev->fops; 1877 gspca_dev->module = module;
1876 gspca_dev->fops.owner = module; /* module protection */
1877 gspca_dev->present = 1; 1878 gspca_dev->present = 1;
1878 ret = video_register_device(&gspca_dev->vdev, 1879 video_set_drvdata(gspca_dev->vdev, gspca_dev);
1880 ret = video_register_device(gspca_dev->vdev,
1879 VFL_TYPE_GRABBER, 1881 VFL_TYPE_GRABBER,
1880 video_nr); 1882 video_nr);
1881 if (ret < 0) { 1883 if (ret < 0) {
1882 err("video_register_device err %d", ret); 1884 err("video_register_device err %d", ret);
1885 video_device_release(gspca_dev->vdev);
1883 goto out; 1886 goto out;
1884 } 1887 }
1885 1888
@@ -1887,7 +1890,8 @@ int gspca_dev_probe(struct usb_interface *intf,
1887 PDEBUG(D_PROBE, "probe ok"); 1890 PDEBUG(D_PROBE, "probe ok");
1888 return 0; 1891 return 0;
1889out: 1892out:
1890 kref_put(&gspca_dev->kref, gspca_delete); 1893 kfree(gspca_dev->usb_buf);
1894 kfree(gspca_dev);
1891 return ret; 1895 return ret;
1892} 1896}
1893EXPORT_SYMBOL(gspca_dev_probe); 1897EXPORT_SYMBOL(gspca_dev_probe);
@@ -1905,7 +1909,7 @@ void gspca_disconnect(struct usb_interface *intf)
1905 usb_set_intfdata(intf, NULL); 1909 usb_set_intfdata(intf, NULL);
1906 1910
1907/* We don't want people trying to open up the device */ 1911/* We don't want people trying to open up the device */
1908 video_unregister_device(&gspca_dev->vdev); 1912 video_unregister_device(gspca_dev->vdev);
1909 1913
1910 gspca_dev->present = 0; 1914 gspca_dev->present = 0;
1911 gspca_dev->streaming = 0; 1915 gspca_dev->streaming = 0;
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 1d9dc90b4791..d25e8d69373b 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -97,7 +97,7 @@ struct sd_desc {
97 cam_pkt_op pkt_scan; 97 cam_pkt_op pkt_scan;
98/* optional operations */ 98/* optional operations */
99 cam_v_op stopN; /* called on stream off - main alt */ 99 cam_v_op stopN; /* called on stream off - main alt */
100 cam_v_op stop0; /* called on stream off - alt 0 */ 100 cam_v_op stop0; /* called on stream off & disconnect - alt 0 */
101 cam_v_op dq_callback; /* called when a frame has been dequeued */ 101 cam_v_op dq_callback; /* called when a frame has been dequeued */
102 cam_jpg_op get_jcomp; 102 cam_jpg_op get_jcomp;
103 cam_jpg_op set_jcomp; 103 cam_jpg_op set_jcomp;
@@ -120,8 +120,8 @@ struct gspca_frame {
120}; 120};
121 121
122struct gspca_dev { 122struct gspca_dev {
123 struct video_device vdev; /* !! must be the first item */ 123 struct video_device *vdev;
124 struct file_operations fops; 124 struct module *module; /* subdriver handling the device */
125 struct usb_device *dev; 125 struct usb_device *dev;
126 struct kref kref; 126 struct kref kref;
127 struct file *capt_file; /* file doing video capture */ 127 struct file *capt_file; /* file doing video capture */
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index e5ff9a6199ef..fbd45e235d97 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -749,10 +749,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
749 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ 749 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
750} 750}
751 751
752/* called on streamoff with alt 0 and on disconnect */
752static void sd_stop0(struct gspca_dev *gspca_dev) 753static void sd_stop0(struct gspca_dev *gspca_dev)
753{ 754{
754 struct sd *sd = (struct sd *) gspca_dev; 755 struct sd *sd = (struct sd *) gspca_dev;
755 756
757 if (!gspca_dev->present)
758 return;
756 if (sd->sensor == SENSOR_PAC7302) { 759 if (sd->sensor == SENSOR_PAC7302) {
757 reg_w(gspca_dev, 0xff, 0x01); 760 reg_w(gspca_dev, 0xff, 0x01);
758 reg_w(gspca_dev, 0x78, 0x40); 761 reg_w(gspca_dev, 0x78, 0x40);
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index b742f260c7ca..e29954c1c38c 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -2022,8 +2022,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2022 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00); 2022 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00);
2023} 2023}
2024 2024
2025/* called on streamoff with alt 0 and on disconnect */
2025static void sd_stop0(struct gspca_dev *gspca_dev) 2026static void sd_stop0(struct gspca_dev *gspca_dev)
2026{ 2027{
2028 if (!gspca_dev->present)
2029 return;
2027 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00); 2030 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00);
2028} 2031}
2029 2032
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index b345749213cf..895b9fe4018c 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -742,8 +742,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
742 reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); 742 reg_write(gspca_dev->dev, 0x02, 0x00, 0x00);
743} 743}
744 744
745/* called on streamoff with alt 0 and on disconnect */
745static void sd_stop0(struct gspca_dev *gspca_dev) 746static void sd_stop0(struct gspca_dev *gspca_dev)
746{ 747{
748 if (!gspca_dev->present)
749 return;
750
747 /* This maybe reset or power control */ 751 /* This maybe reset or power control */
748 reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); 752 reg_write(gspca_dev->dev, 0x03, 0x03, 0x20);
749 reg_write(gspca_dev->dev, 0x03, 0x01, 0x0); 753 reg_write(gspca_dev->dev, 0x03, 0x01, 0x0);
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index 020a03c466c1..c3de4e44123d 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -766,10 +766,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
766 } 766 }
767} 767}
768 768
769/* called on streamoff with alt 0 and on disconnect */
769static void sd_stop0(struct gspca_dev *gspca_dev) 770static void sd_stop0(struct gspca_dev *gspca_dev)
770{ 771{
771 struct sd *sd = (struct sd *) gspca_dev; 772 struct sd *sd = (struct sd *) gspca_dev;
772 773
774 if (!gspca_dev->present)
775 return;
773 if (sd->chip_revision == Rev012A) { 776 if (sd->chip_revision == Rev012A) {
774 reg_w_val(gspca_dev->dev, 0x8118, 0x29); 777 reg_w_val(gspca_dev->dev, 0x8118, 0x29);
775 reg_w_val(gspca_dev->dev, 0x8114, 0x08); 778 reg_w_val(gspca_dev->dev, 0x8114, 0x08);
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index be46d9232540..17af353ddd1c 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -1633,10 +1633,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1633 reg_w(dev, 0xa0, 0x09, 0xb003); 1633 reg_w(dev, 0xa0, 0x09, 0xb003);
1634} 1634}
1635 1635
1636/* called on streamoff with alt 0 and on disconnect */
1636static void sd_stop0(struct gspca_dev *gspca_dev) 1637static void sd_stop0(struct gspca_dev *gspca_dev)
1637{ 1638{
1638 struct usb_device *dev = gspca_dev->dev; 1639 struct usb_device *dev = gspca_dev->dev;
1639 1640
1641 if (!gspca_dev->present)
1642 return;
1640 reg_w(dev, 0x89, 0xffff, 0xffff); 1643 reg_w(dev, 0x89, 0xffff, 0xffff);
1641} 1644}
1642 1645
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 8b3101d347c3..0befacf49855 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -7336,10 +7336,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
7336 return 0; 7336 return 0;
7337} 7337}
7338 7338
7339/* called on streamoff with alt 0 and on disconnect */
7339static void sd_stop0(struct gspca_dev *gspca_dev) 7340static void sd_stop0(struct gspca_dev *gspca_dev)
7340{ 7341{
7341 struct sd *sd = (struct sd *) gspca_dev; 7342 struct sd *sd = (struct sd *) gspca_dev;
7342 7343
7344 if (!gspca_dev->present)
7345 return;
7343 send_unknown(gspca_dev->dev, sd->sensor); 7346 send_unknown(gspca_dev->dev, sd->sensor);
7344} 7347}
7345 7348
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index 19eb274c9cd0..854c2a885358 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -42,7 +42,7 @@ config VIDEO_PVRUSB2_DVB
42 select DVB_S5H1411 if !DVB_FE_CUSTOMISE 42 select DVB_S5H1411 if !DVB_FE_CUSTOMISE
43 select DVB_TDA10048 if !DVB_FE_CUSTOMIZE 43 select DVB_TDA10048 if !DVB_FE_CUSTOMIZE
44 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE 44 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE
45 select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE 45 select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE
46 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE 46 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE
47 ---help--- 47 ---help---
48 48
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 5272926db73e..3c3f8cf73108 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -192,7 +192,7 @@ struct s2255_dmaqueue {
192#define S2255_FW_FAILED 3 192#define S2255_FW_FAILED 3
193#define S2255_FW_DISCONNECTING 4 193#define S2255_FW_DISCONNECTING 4
194 194
195#define S2255_FW_MARKER 0x22552f2f 195#define S2255_FW_MARKER cpu_to_le32(0x22552f2f)
196/* 2255 read states */ 196/* 2255 read states */
197#define S2255_READ_IDLE 0 197#define S2255_READ_IDLE 0
198#define S2255_READ_FRAME 1 198#define S2255_READ_FRAME 1
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 7021bbf5897b..fc2164e28e76 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -34,9 +34,9 @@ config VIDEO_SAA7134_DVB
34 select DVB_NXT200X if !DVB_FE_CUSTOMISE 34 select DVB_NXT200X if !DVB_FE_CUSTOMISE
35 select DVB_TDA10086 if !DVB_FE_CUSTOMISE 35 select DVB_TDA10086 if !DVB_FE_CUSTOMISE
36 select DVB_TDA826X if !DVB_FE_CUSTOMISE 36 select DVB_TDA826X if !DVB_FE_CUSTOMISE
37 select MEDIA_TUNER_TDA827X if !DVB_FE_CUSTOMISE
38 select DVB_ISL6421 if !DVB_FE_CUSTOMISE 37 select DVB_ISL6421 if !DVB_FE_CUSTOMISE
39 select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE 38 select MEDIA_TUNER_TDA827X if !MEDIA_TUNER_CUSTOMIZE
39 select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE
40 ---help--- 40 ---help---
41 This adds support for DVB cards based on the 41 This adds support for DVB cards based on the
42 Philips saa7134 chip. 42 Philips saa7134 chip.
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index d62fd4f6b52e..ee090413e598 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -2008,6 +2008,9 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
2008 return FAILED; 2008 return FAILED;
2009 } 2009 }
2010 2010
2011 /* make sure we have no outstanding commands at this stage */
2012 mptscsih_flush_running_cmds(hd);
2013
2011 ioc = hd->ioc; 2014 ioc = hd->ioc;
2012 printk(MYIOC_s_INFO_FMT "attempting host reset! (sc=%p)\n", 2015 printk(MYIOC_s_INFO_FMT "attempting host reset! (sc=%p)\n",
2013 ioc->name, SCpnt); 2016 ioc->name, SCpnt);
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index 84bdc2ee69e6..a443e136dc41 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -354,7 +354,7 @@ static inline void i2o_block_sglist_free(struct i2o_block_request *ireq)
354 * @req: the request to prepare 354 * @req: the request to prepare
355 * 355 *
356 * Allocate the necessary i2o_block_request struct and connect it to 356 * Allocate the necessary i2o_block_request struct and connect it to
357 * the request. This is needed that we not loose the SG list later on. 357 * the request. This is needed that we not lose the SG list later on.
358 * 358 *
359 * Returns BLKPREP_OK on success or BLKPREP_DEFER on failure. 359 * Returns BLKPREP_OK on success or BLKPREP_DEFER on failure.
360 */ 360 */
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index be2b5926d26c..6e53a30bfd38 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -49,7 +49,6 @@ static int i2o_hrt_get(struct i2o_controller *c);
49/** 49/**
50 * i2o_msg_get_wait - obtain an I2O message from the IOP 50 * i2o_msg_get_wait - obtain an I2O message from the IOP
51 * @c: I2O controller 51 * @c: I2O controller
52 * @msg: pointer to a I2O message pointer
53 * @wait: how long to wait until timeout 52 * @wait: how long to wait until timeout
54 * 53 *
55 * This function waits up to wait seconds for a message slot to be 54 * This function waits up to wait seconds for a message slot to be
diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
index 8c389d606c30..3ee698ad8599 100644
--- a/drivers/misc/sgi-gru/grufault.c
+++ b/drivers/misc/sgi-gru/grufault.c
@@ -254,7 +254,11 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
254 return 1; 254 return 1;
255 255
256 *paddr = pte_pfn(pte) << PAGE_SHIFT; 256 *paddr = pte_pfn(pte) << PAGE_SHIFT;
257#ifdef CONFIG_HUGETLB_PAGE
257 *pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT; 258 *pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
259#else
260 *pageshift = PAGE_SHIFT;
261#endif
258 return 0; 262 return 0;
259 263
260err: 264err:
diff --git a/drivers/misc/sgi-gru/grufile.c b/drivers/misc/sgi-gru/grufile.c
index 5c027b6b4e5a..650983806392 100644
--- a/drivers/misc/sgi-gru/grufile.c
+++ b/drivers/misc/sgi-gru/grufile.c
@@ -481,7 +481,7 @@ struct vm_operations_struct gru_vm_ops = {
481 .fault = gru_fault, 481 .fault = gru_fault,
482}; 482};
483 483
484module_init(gru_init); 484fs_initcall(gru_init);
485module_exit(gru_exit); 485module_exit(gru_exit);
486 486
487module_param(gru_options, ulong, 0644); 487module_param(gru_options, ulong, 0644);
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 7bcb81002dcf..571b211608d1 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -1038,8 +1038,8 @@ static int sony_nc_add(struct acpi_device *device)
1038 goto outinput; 1038 goto outinput;
1039 } 1039 }
1040 1040
1041 if (!acpi_video_backlight_support()) { 1041 if (acpi_video_backlight_support()) {
1042 printk(KERN_INFO DRV_PFX "Sony: Brightness ignored, must be " 1042 printk(KERN_INFO DRV_PFX "brightness ignored, must be "
1043 "controlled by ACPI video driver\n"); 1043 "controlled by ACPI video driver\n");
1044 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", 1044 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
1045 &handle))) { 1045 &handle))) {
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 7a4a26b0edd2..899766e16fa8 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -5318,6 +5318,7 @@ static enum fan_control_commands fan_control_commands;
5318 5318
5319static u8 fan_control_initial_status; 5319static u8 fan_control_initial_status;
5320static u8 fan_control_desired_level; 5320static u8 fan_control_desired_level;
5321static u8 fan_control_resume_level;
5321static int fan_watchdog_maxinterval; 5322static int fan_watchdog_maxinterval;
5322 5323
5323static struct mutex fan_mutex; 5324static struct mutex fan_mutex;
@@ -5440,8 +5441,8 @@ static int fan_set_level(int level)
5440 5441
5441 case TPACPI_FAN_WR_ACPI_FANS: 5442 case TPACPI_FAN_WR_ACPI_FANS:
5442 case TPACPI_FAN_WR_TPEC: 5443 case TPACPI_FAN_WR_TPEC:
5443 if ((level != TP_EC_FAN_AUTO) && 5444 if (!(level & TP_EC_FAN_AUTO) &&
5444 (level != TP_EC_FAN_FULLSPEED) && 5445 !(level & TP_EC_FAN_FULLSPEED) &&
5445 ((level < 0) || (level > 7))) 5446 ((level < 0) || (level > 7)))
5446 return -EINVAL; 5447 return -EINVAL;
5447 5448
@@ -6005,38 +6006,67 @@ static void fan_exit(void)
6005 6006
6006static void fan_suspend(pm_message_t state) 6007static void fan_suspend(pm_message_t state)
6007{ 6008{
6009 int rc;
6010
6008 if (!fan_control_allowed) 6011 if (!fan_control_allowed)
6009 return; 6012 return;
6010 6013
6011 /* Store fan status in cache */ 6014 /* Store fan status in cache */
6012 fan_get_status_safe(NULL); 6015 fan_control_resume_level = 0;
6016 rc = fan_get_status_safe(&fan_control_resume_level);
6017 if (rc < 0)
6018 printk(TPACPI_NOTICE
6019 "failed to read fan level for later "
6020 "restore during resume: %d\n", rc);
6021
6022 /* if it is undefined, don't attempt to restore it.
6023 * KEEP THIS LAST */
6013 if (tp_features.fan_ctrl_status_undef) 6024 if (tp_features.fan_ctrl_status_undef)
6014 fan_control_desired_level = TP_EC_FAN_AUTO; 6025 fan_control_resume_level = 0;
6015} 6026}
6016 6027
6017static void fan_resume(void) 6028static void fan_resume(void)
6018{ 6029{
6019 u8 saved_fan_level;
6020 u8 current_level = 7; 6030 u8 current_level = 7;
6021 bool do_set = false; 6031 bool do_set = false;
6032 int rc;
6022 6033
6023 /* DSDT *always* updates status on resume */ 6034 /* DSDT *always* updates status on resume */
6024 tp_features.fan_ctrl_status_undef = 0; 6035 tp_features.fan_ctrl_status_undef = 0;
6025 6036
6026 saved_fan_level = fan_control_desired_level;
6027 if (!fan_control_allowed || 6037 if (!fan_control_allowed ||
6038 !fan_control_resume_level ||
6028 (fan_get_status_safe(&current_level) < 0)) 6039 (fan_get_status_safe(&current_level) < 0))
6029 return; 6040 return;
6030 6041
6031 switch (fan_control_access_mode) { 6042 switch (fan_control_access_mode) {
6032 case TPACPI_FAN_WR_ACPI_SFAN: 6043 case TPACPI_FAN_WR_ACPI_SFAN:
6033 do_set = (saved_fan_level > current_level); 6044 /* never decrease fan level */
6045 do_set = (fan_control_resume_level > current_level);
6034 break; 6046 break;
6035 case TPACPI_FAN_WR_ACPI_FANS: 6047 case TPACPI_FAN_WR_ACPI_FANS:
6036 case TPACPI_FAN_WR_TPEC: 6048 case TPACPI_FAN_WR_TPEC:
6037 do_set = ((saved_fan_level & TP_EC_FAN_FULLSPEED) || 6049 /* never decrease fan level, scale is:
6038 (saved_fan_level == 7 && 6050 * TP_EC_FAN_FULLSPEED > 7 >= TP_EC_FAN_AUTO
6039 !(current_level & TP_EC_FAN_FULLSPEED))); 6051 *
6052 * We expect the firmware to set either 7 or AUTO, but we
6053 * handle FULLSPEED out of paranoia.
6054 *
6055 * So, we can safely only restore FULLSPEED or 7, anything
6056 * else could slow the fan. Restoring AUTO is useless, at
6057 * best that's exactly what the DSDT already set (it is the
6058 * slower it uses).
6059 *
6060 * Always keep in mind that the DSDT *will* have set the
6061 * fans to what the vendor supposes is the best level. We
6062 * muck with it only to speed the fan up.
6063 */
6064 if (fan_control_resume_level != 7 &&
6065 !(fan_control_resume_level & TP_EC_FAN_FULLSPEED))
6066 return;
6067 else
6068 do_set = !(current_level & TP_EC_FAN_FULLSPEED) &&
6069 (current_level != fan_control_resume_level);
6040 break; 6070 break;
6041 default: 6071 default:
6042 return; 6072 return;
@@ -6044,8 +6074,11 @@ static void fan_resume(void)
6044 if (do_set) { 6074 if (do_set) {
6045 printk(TPACPI_NOTICE 6075 printk(TPACPI_NOTICE
6046 "restoring fan level to 0x%02x\n", 6076 "restoring fan level to 0x%02x\n",
6047 saved_fan_level); 6077 fan_control_resume_level);
6048 fan_set_level_safe(saved_fan_level); 6078 rc = fan_set_level_safe(fan_control_resume_level);
6079 if (rc < 0)
6080 printk(TPACPI_NOTICE
6081 "failed to restore fan level: %d\n", rc);
6049 } 6082 }
6050} 6083}
6051 6084
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 76a76751da36..6659b2275c0c 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -37,9 +37,9 @@
37#define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */ 37#define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */
38#define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */ 38#define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */
39#define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */ 39#define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */
40#define OPCODE_BE_4K 0x20 /* Erase 4KiB block */ 40#define OPCODE_BE_4K 0x20 /* Erase 4KiB block */
41#define OPCODE_BE_32K 0x52 /* Erase 32KiB block */ 41#define OPCODE_BE_32K 0x52 /* Erase 32KiB block */
42#define OPCODE_BE 0xc7 /* Erase whole flash block */ 42#define OPCODE_CHIP_ERASE 0xc7 /* Erase whole flash chip */
43#define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */ 43#define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */
44#define OPCODE_RDID 0x9f /* Read JEDEC ID */ 44#define OPCODE_RDID 0x9f /* Read JEDEC ID */
45 45
@@ -167,7 +167,7 @@ static int wait_till_ready(struct m25p *flash)
167 * 167 *
168 * Returns 0 if successful, non-zero otherwise. 168 * Returns 0 if successful, non-zero otherwise.
169 */ 169 */
170static int erase_block(struct m25p *flash) 170static int erase_chip(struct m25p *flash)
171{ 171{
172 DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n", 172 DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n",
173 flash->spi->dev.bus_id, __func__, 173 flash->spi->dev.bus_id, __func__,
@@ -181,7 +181,7 @@ static int erase_block(struct m25p *flash)
181 write_enable(flash); 181 write_enable(flash);
182 182
183 /* Set up command buffer. */ 183 /* Set up command buffer. */
184 flash->command[0] = OPCODE_BE; 184 flash->command[0] = OPCODE_CHIP_ERASE;
185 185
186 spi_write(flash->spi, flash->command, 1); 186 spi_write(flash->spi, flash->command, 1);
187 187
@@ -250,15 +250,18 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
250 250
251 mutex_lock(&flash->lock); 251 mutex_lock(&flash->lock);
252 252
253 /* REVISIT in some cases we could speed up erasing large regions 253 /* whole-chip erase? */
254 * by using OPCODE_SE instead of OPCODE_BE_4K 254 if (len == flash->mtd.size && erase_chip(flash)) {
255 */
256
257 /* now erase those sectors */
258 if (len == flash->mtd.size && erase_block(flash)) {
259 instr->state = MTD_ERASE_FAILED; 255 instr->state = MTD_ERASE_FAILED;
260 mutex_unlock(&flash->lock); 256 mutex_unlock(&flash->lock);
261 return -EIO; 257 return -EIO;
258
259 /* REVISIT in some cases we could speed up erasing large regions
260 * by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up
261 * to use "small sector erase", but that's not always optimal.
262 */
263
264 /* "sector"-at-a-time erase */
262 } else { 265 } else {
263 while (len) { 266 while (len) {
264 if (erase_sector(flash, addr)) { 267 if (erase_sector(flash, addr)) {
@@ -574,10 +577,11 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
574 for (tmp = 0, info = m25p_data; 577 for (tmp = 0, info = m25p_data;
575 tmp < ARRAY_SIZE(m25p_data); 578 tmp < ARRAY_SIZE(m25p_data);
576 tmp++, info++) { 579 tmp++, info++) {
577 if (info->jedec_id == jedec) 580 if (info->jedec_id == jedec) {
578 if (ext_jedec != 0 && info->ext_id != ext_jedec) 581 if (info->ext_id != 0 && info->ext_id != ext_jedec)
579 continue; 582 continue;
580 return info; 583 return info;
584 }
581 } 585 }
582 dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec); 586 dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec);
583 return NULL; 587 return NULL;
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 42d844f8f6bf..dfbf3f270cea 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -19,7 +19,7 @@
19#include <linux/mtd/partitions.h> 19#include <linux/mtd/partitions.h>
20#include <linux/mtd/physmap.h> 20#include <linux/mtd/physmap.h>
21#include <linux/mtd/concat.h> 21#include <linux/mtd/concat.h>
22#include <asm/io.h> 22#include <linux/io.h>
23 23
24#define MAX_RESOURCES 4 24#define MAX_RESOURCES 4
25 25
@@ -27,7 +27,6 @@ struct physmap_flash_info {
27 struct mtd_info *mtd[MAX_RESOURCES]; 27 struct mtd_info *mtd[MAX_RESOURCES];
28 struct mtd_info *cmtd; 28 struct mtd_info *cmtd;
29 struct map_info map[MAX_RESOURCES]; 29 struct map_info map[MAX_RESOURCES];
30 struct resource *res;
31#ifdef CONFIG_MTD_PARTITIONS 30#ifdef CONFIG_MTD_PARTITIONS
32 int nr_parts; 31 int nr_parts;
33 struct mtd_partition *parts; 32 struct mtd_partition *parts;
@@ -70,16 +69,7 @@ static int physmap_flash_remove(struct platform_device *dev)
70#endif 69#endif
71 map_destroy(info->mtd[i]); 70 map_destroy(info->mtd[i]);
72 } 71 }
73
74 if (info->map[i].virt != NULL)
75 iounmap(info->map[i].virt);
76 }
77
78 if (info->res != NULL) {
79 release_resource(info->res);
80 kfree(info->res);
81 } 72 }
82
83 return 0; 73 return 0;
84} 74}
85 75
@@ -101,7 +91,8 @@ static int physmap_flash_probe(struct platform_device *dev)
101 if (physmap_data == NULL) 91 if (physmap_data == NULL)
102 return -ENODEV; 92 return -ENODEV;
103 93
104 info = kzalloc(sizeof(struct physmap_flash_info), GFP_KERNEL); 94 info = devm_kzalloc(&dev->dev, sizeof(struct physmap_flash_info),
95 GFP_KERNEL);
105 if (info == NULL) { 96 if (info == NULL) {
106 err = -ENOMEM; 97 err = -ENOMEM;
107 goto err_out; 98 goto err_out;
@@ -114,10 +105,10 @@ static int physmap_flash_probe(struct platform_device *dev)
114 (unsigned long long)(dev->resource[i].end - dev->resource[i].start + 1), 105 (unsigned long long)(dev->resource[i].end - dev->resource[i].start + 1),
115 (unsigned long long)dev->resource[i].start); 106 (unsigned long long)dev->resource[i].start);
116 107
117 info->res = request_mem_region(dev->resource[i].start, 108 if (!devm_request_mem_region(&dev->dev,
118 dev->resource[i].end - dev->resource[i].start + 1, 109 dev->resource[i].start,
119 dev->dev.bus_id); 110 dev->resource[i].end - dev->resource[i].start + 1,
120 if (info->res == NULL) { 111 dev->dev.bus_id)) {
121 dev_err(&dev->dev, "Could not reserve memory region\n"); 112 dev_err(&dev->dev, "Could not reserve memory region\n");
122 err = -ENOMEM; 113 err = -ENOMEM;
123 goto err_out; 114 goto err_out;
@@ -129,7 +120,8 @@ static int physmap_flash_probe(struct platform_device *dev)
129 info->map[i].bankwidth = physmap_data->width; 120 info->map[i].bankwidth = physmap_data->width;
130 info->map[i].set_vpp = physmap_data->set_vpp; 121 info->map[i].set_vpp = physmap_data->set_vpp;
131 122
132 info->map[i].virt = ioremap(info->map[i].phys, info->map[i].size); 123 info->map[i].virt = devm_ioremap(&dev->dev, info->map[i].phys,
124 info->map[i].size);
133 if (info->map[i].virt == NULL) { 125 if (info->map[i].virt == NULL) {
134 dev_err(&dev->dev, "Failed to ioremap flash region\n"); 126 dev_err(&dev->dev, "Failed to ioremap flash region\n");
135 err = EIO; 127 err = EIO;
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index 024e3fffd4bb..a83192f80eba 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -163,9 +163,11 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
163 ret = parse_mtd_partitions(&fun->mtd, part_types, &fun->parts, 0); 163 ret = parse_mtd_partitions(&fun->mtd, part_types, &fun->parts, 0);
164 164
165#ifdef CONFIG_MTD_OF_PARTS 165#ifdef CONFIG_MTD_OF_PARTS
166 if (ret == 0) 166 if (ret == 0) {
167 ret = of_mtd_parse_partitions(fun->dev, &fun->mtd, 167 ret = of_mtd_parse_partitions(fun->dev, flash_np, &fun->parts);
168 flash_np, &fun->parts); 168 if (ret < 0)
169 goto err;
170 }
169#endif 171#endif
170 if (ret > 0) 172 if (ret > 0)
171 ret = add_mtd_partitions(&fun->mtd, fun->parts, ret); 173 ret = add_mtd_partitions(&fun->mtd, fun->parts, ret);
diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
index 75c899039023..9bd6c9ac8443 100644
--- a/drivers/mtd/nand/pasemi_nand.c
+++ b/drivers/mtd/nand/pasemi_nand.c
@@ -141,6 +141,7 @@ static int __devinit pasemi_nand_probe(struct of_device *ofdev,
141 } 141 }
142 142
143 lpcctl = pci_resource_start(pdev, 0); 143 lpcctl = pci_resource_start(pdev, 0);
144 pci_dev_put(pdev);
144 145
145 if (!request_region(lpcctl, 4, driver_name)) { 146 if (!request_region(lpcctl, 4, driver_name)) {
146 err = -EBUSY; 147 err = -EBUSY;
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index c0fa9c9edf08..15f0a26730ae 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -269,6 +269,7 @@ static struct pxa3xx_nand_timing stm2GbX16_timing = {
269 269
270static struct pxa3xx_nand_flash stm2GbX16 = { 270static struct pxa3xx_nand_flash stm2GbX16 = {
271 .timing = &stm2GbX16_timing, 271 .timing = &stm2GbX16_timing,
272 .cmdset = &largepage_cmdset,
272 .page_per_block = 64, 273 .page_per_block = 64,
273 .page_size = 2048, 274 .page_size = 2048,
274 .flash_width = 16, 275 .flash_width = 16,
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index e39b21d3e168..a7e4d985f5ef 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -32,19 +32,18 @@
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/dma-mapping.h>
36#include <linux/io.h>
35 37
36#include <asm/io.h>
37#include <asm/mach/flash.h> 38#include <asm/mach/flash.h>
38#include <asm/arch/gpmc.h> 39#include <mach/gpmc.h>
39#include <asm/arch/onenand.h> 40#include <mach/onenand.h>
40#include <asm/arch/gpio.h> 41#include <mach/gpio.h>
41#include <asm/arch/pm.h> 42#include <mach/pm.h>
42 43
43#include <linux/dma-mapping.h> 44#include <mach/dma.h>
44#include <asm/dma-mapping.h>
45#include <asm/arch/dma.h>
46 45
47#include <asm/arch/board.h> 46#include <mach/board.h>
48 47
49#define DRIVER_NAME "omap2-onenand" 48#define DRIVER_NAME "omap2-onenand"
50 49
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index e04bcf1dff87..d8966bae0e0b 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -1022,7 +1022,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
1022 } 1022 }
1023 1023
1024 /* 1024 /*
1025 * OK, now the LEB is locked and we can safely start moving iy. Since 1025 * OK, now the LEB is locked and we can safely start moving it. Since
1026 * this function utilizes thie @ubi->peb1_buf buffer which is shared 1026 * this function utilizes thie @ubi->peb1_buf buffer which is shared
1027 * with some other functions, so lock the buffer by taking the 1027 * with some other functions, so lock the buffer by taking the
1028 * @ubi->buf_mutex. 1028 * @ubi->buf_mutex.
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 4f2daa5bbecf..41d47e1cf15c 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -320,7 +320,7 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb,
320 } 320 }
321 321
322 err = ubi_io_read_data(ubi, buf, pnum, 0, len); 322 err = ubi_io_read_data(ubi, buf, pnum, 0, len);
323 if (err && err != UBI_IO_BITFLIPS) 323 if (err && err != UBI_IO_BITFLIPS && err != -EBADMSG)
324 goto out_free_buf; 324 goto out_free_buf;
325 325
326 data_crc = be32_to_cpu(vid_hdr->data_crc); 326 data_crc = be32_to_cpu(vid_hdr->data_crc);
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 05d70937b543..dcb6dac1dc54 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1396,7 +1396,8 @@ int ubi_thread(void *u)
1396 ubi_msg("%s: %d consecutive failures", 1396 ubi_msg("%s: %d consecutive failures",
1397 ubi->bgt_name, WL_MAX_FAILURES); 1397 ubi->bgt_name, WL_MAX_FAILURES);
1398 ubi_ro_mode(ubi); 1398 ubi_ro_mode(ubi);
1399 break; 1399 ubi->thread_enabled = 0;
1400 continue;
1400 } 1401 }
1401 } else 1402 } else
1402 failures = 0; 1403 failures = 0;
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 11f143f4adf6..231eeaf1d552 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1825,9 +1825,10 @@ config FEC2
1825 1825
1826config FEC_MPC52xx 1826config FEC_MPC52xx
1827 tristate "MPC52xx FEC driver" 1827 tristate "MPC52xx FEC driver"
1828 depends on PPC_MPC52xx && PPC_BESTCOMM_FEC 1828 depends on PPC_MPC52xx && PPC_BESTCOMM
1829 select CRC32 1829 select CRC32
1830 select PHYLIB 1830 select PHYLIB
1831 select PPC_BESTCOMM_FEC
1831 ---help--- 1832 ---help---
1832 This option enables support for the MPC5200's on-chip 1833 This option enables support for the MPC5200's on-chip
1833 Fast Ethernet Controller 1834 Fast Ethernet Controller
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index f19acf8b9220..017383ad5ec6 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -114,7 +114,7 @@ obj-$(CONFIG_EL2) += 3c503.o 8390p.o
114obj-$(CONFIG_NE2000) += ne.o 8390p.o 114obj-$(CONFIG_NE2000) += ne.o 8390p.o
115obj-$(CONFIG_NE2_MCA) += ne2.o 8390p.o 115obj-$(CONFIG_NE2_MCA) += ne2.o 8390p.o
116obj-$(CONFIG_HPLAN) += hp.o 8390p.o 116obj-$(CONFIG_HPLAN) += hp.o 8390p.o
117obj-$(CONFIG_HPLAN_PLUS) += hp-plus.o 8390.o 117obj-$(CONFIG_HPLAN_PLUS) += hp-plus.o 8390p.o
118obj-$(CONFIG_ULTRA) += smc-ultra.o 8390.o 118obj-$(CONFIG_ULTRA) += smc-ultra.o 8390.o
119obj-$(CONFIG_ULTRAMCA) += smc-mca.o 8390.o 119obj-$(CONFIG_ULTRAMCA) += smc-mca.o 8390.o
120obj-$(CONFIG_ULTRA32) += smc-ultra32.o 8390.o 120obj-$(CONFIG_ULTRA32) += smc-ultra32.o 8390.o
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index d07e3f148951..9e8222f9e90e 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -543,9 +543,9 @@ bnx2_free_rx_mem(struct bnx2 *bp)
543 for (j = 0; j < bp->rx_max_pg_ring; j++) { 543 for (j = 0; j < bp->rx_max_pg_ring; j++) {
544 if (rxr->rx_pg_desc_ring[j]) 544 if (rxr->rx_pg_desc_ring[j])
545 pci_free_consistent(bp->pdev, RXBD_RING_SIZE, 545 pci_free_consistent(bp->pdev, RXBD_RING_SIZE,
546 rxr->rx_pg_desc_ring[i], 546 rxr->rx_pg_desc_ring[j],
547 rxr->rx_pg_desc_mapping[i]); 547 rxr->rx_pg_desc_mapping[j]);
548 rxr->rx_pg_desc_ring[i] = NULL; 548 rxr->rx_pg_desc_ring[j] = NULL;
549 } 549 }
550 if (rxr->rx_pg_ring) 550 if (rxr->rx_pg_ring)
551 vfree(rxr->rx_pg_ring); 551 vfree(rxr->rx_pg_ring);
@@ -3144,6 +3144,28 @@ bnx2_has_work(struct bnx2_napi *bnapi)
3144 return 0; 3144 return 0;
3145} 3145}
3146 3146
3147static void
3148bnx2_chk_missed_msi(struct bnx2 *bp)
3149{
3150 struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
3151 u32 msi_ctrl;
3152
3153 if (bnx2_has_work(bnapi)) {
3154 msi_ctrl = REG_RD(bp, BNX2_PCICFG_MSI_CONTROL);
3155 if (!(msi_ctrl & BNX2_PCICFG_MSI_CONTROL_ENABLE))
3156 return;
3157
3158 if (bnapi->last_status_idx == bp->idle_chk_status_idx) {
3159 REG_WR(bp, BNX2_PCICFG_MSI_CONTROL, msi_ctrl &
3160 ~BNX2_PCICFG_MSI_CONTROL_ENABLE);
3161 REG_WR(bp, BNX2_PCICFG_MSI_CONTROL, msi_ctrl);
3162 bnx2_msi(bp->irq_tbl[0].vector, bnapi);
3163 }
3164 }
3165
3166 bp->idle_chk_status_idx = bnapi->last_status_idx;
3167}
3168
3147static void bnx2_poll_link(struct bnx2 *bp, struct bnx2_napi *bnapi) 3169static void bnx2_poll_link(struct bnx2 *bp, struct bnx2_napi *bnapi)
3148{ 3170{
3149 struct status_block *sblk = bnapi->status_blk.msi; 3171 struct status_block *sblk = bnapi->status_blk.msi;
@@ -3218,14 +3240,15 @@ static int bnx2_poll(struct napi_struct *napi, int budget)
3218 3240
3219 work_done = bnx2_poll_work(bp, bnapi, work_done, budget); 3241 work_done = bnx2_poll_work(bp, bnapi, work_done, budget);
3220 3242
3221 if (unlikely(work_done >= budget))
3222 break;
3223
3224 /* bnapi->last_status_idx is used below to tell the hw how 3243 /* bnapi->last_status_idx is used below to tell the hw how
3225 * much work has been processed, so we must read it before 3244 * much work has been processed, so we must read it before
3226 * checking for more work. 3245 * checking for more work.
3227 */ 3246 */
3228 bnapi->last_status_idx = sblk->status_idx; 3247 bnapi->last_status_idx = sblk->status_idx;
3248
3249 if (unlikely(work_done >= budget))
3250 break;
3251
3229 rmb(); 3252 rmb();
3230 if (likely(!bnx2_has_work(bnapi))) { 3253 if (likely(!bnx2_has_work(bnapi))) {
3231 netif_rx_complete(bp->dev, napi); 3254 netif_rx_complete(bp->dev, napi);
@@ -4570,6 +4593,8 @@ bnx2_init_chip(struct bnx2 *bp)
4570 for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) 4593 for (i = 0; i < BNX2_MAX_MSIX_VEC; i++)
4571 bp->bnx2_napi[i].last_status_idx = 0; 4594 bp->bnx2_napi[i].last_status_idx = 0;
4572 4595
4596 bp->idle_chk_status_idx = 0xffff;
4597
4573 bp->rx_mode = BNX2_EMAC_RX_MODE_SORT_MODE; 4598 bp->rx_mode = BNX2_EMAC_RX_MODE_SORT_MODE;
4574 4599
4575 /* Set up how to generate a link change interrupt. */ 4600 /* Set up how to generate a link change interrupt. */
@@ -5718,6 +5743,10 @@ bnx2_timer(unsigned long data)
5718 if (atomic_read(&bp->intr_sem) != 0) 5743 if (atomic_read(&bp->intr_sem) != 0)
5719 goto bnx2_restart_timer; 5744 goto bnx2_restart_timer;
5720 5745
5746 if ((bp->flags & (BNX2_FLAG_USING_MSI | BNX2_FLAG_ONE_SHOT_MSI)) ==
5747 BNX2_FLAG_USING_MSI)
5748 bnx2_chk_missed_msi(bp);
5749
5721 bnx2_send_heart_beat(bp); 5750 bnx2_send_heart_beat(bp);
5722 5751
5723 bp->stats_blk->stat_FwRxDrop = 5752 bp->stats_blk->stat_FwRxDrop =
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 617d95340160..0b032c3c7b61 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -378,6 +378,9 @@ struct l2_fhdr {
378 * pci_config_l definition 378 * pci_config_l definition
379 * offset: 0000 379 * offset: 0000
380 */ 380 */
381#define BNX2_PCICFG_MSI_CONTROL 0x00000058
382#define BNX2_PCICFG_MSI_CONTROL_ENABLE (1L<<16)
383
381#define BNX2_PCICFG_MISC_CONFIG 0x00000068 384#define BNX2_PCICFG_MISC_CONFIG 0x00000068
382#define BNX2_PCICFG_MISC_CONFIG_TARGET_BYTE_SWAP (1L<<2) 385#define BNX2_PCICFG_MISC_CONFIG_TARGET_BYTE_SWAP (1L<<2)
383#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP (1L<<3) 386#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP (1L<<3)
@@ -6863,6 +6866,9 @@ struct bnx2 {
6863 6866
6864 u8 num_tx_rings; 6867 u8 num_tx_rings;
6865 u8 num_rx_rings; 6868 u8 num_rx_rings;
6869
6870 u32 idle_chk_status_idx;
6871
6866}; 6872};
6867 6873
6868#define REG_RD(bp, offset) \ 6874#define REG_RD(bp, offset) \
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index d6c7d2aa761b..7092df50ff78 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -1035,10 +1035,6 @@ MODULE_PARM_DESC(copybreak, "Receive copy threshold");
1035 * @pdev: the PCI device that received the packet 1035 * @pdev: the PCI device that received the packet
1036 * @fl: the SGE free list holding the packet 1036 * @fl: the SGE free list holding the packet
1037 * @len: the actual packet length, excluding any SGE padding 1037 * @len: the actual packet length, excluding any SGE padding
1038 * @dma_pad: padding at beginning of buffer left by SGE DMA
1039 * @skb_pad: padding to be used if the packet is copied
1040 * @copy_thres: length threshold under which a packet should be copied
1041 * @drop_thres: # of remaining buffers before we start dropping packets
1042 * 1038 *
1043 * Get the next packet from a free list and complete setup of the 1039 * Get the next packet from a free list and complete setup of the
1044 * sk_buff. If the packet is small we make a copy and recycle the 1040 * sk_buff. If the packet is small we make a copy and recycle the
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 523b9716a543..d115a6d30f29 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -1893,12 +1893,17 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
1893 ctrl |= E1000_CTRL_PHY_RST; 1893 ctrl |= E1000_CTRL_PHY_RST;
1894 } 1894 }
1895 ret_val = e1000_acquire_swflag_ich8lan(hw); 1895 ret_val = e1000_acquire_swflag_ich8lan(hw);
1896 /* Whether or not the swflag was acquired, we need to reset the part */
1896 hw_dbg(hw, "Issuing a global reset to ich8lan"); 1897 hw_dbg(hw, "Issuing a global reset to ich8lan");
1897 ew32(CTRL, (ctrl | E1000_CTRL_RST)); 1898 ew32(CTRL, (ctrl | E1000_CTRL_RST));
1898 msleep(20); 1899 msleep(20);
1899 1900
1900 /* release the swflag because it is not reset by hardware reset */ 1901 if (!ret_val) {
1901 e1000_release_swflag_ich8lan(hw); 1902 /* release the swflag because it is not reset by
1903 * hardware reset
1904 */
1905 e1000_release_swflag_ich8lan(hw);
1906 }
1902 1907
1903 ret_val = e1000e_get_auto_rd_done(hw); 1908 ret_val = e1000e_get_auto_rd_done(hw);
1904 if (ret_val) { 1909 if (ret_val) {
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 91795f78c3e4..122539a0e1fe 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -345,7 +345,6 @@ no_buffers:
345/** 345/**
346 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers 346 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
347 * @adapter: address of board private structure 347 * @adapter: address of board private structure
348 * @rx_ring: pointer to receive ring structure
349 * @cleaned_count: number of buffers to allocate this pass 348 * @cleaned_count: number of buffers to allocate this pass
350 **/ 349 **/
351 350
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index e1b441effbbe..36cb6e95b465 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -568,6 +568,17 @@ static u16 erxrdpt_workaround(u16 next_packet_ptr, u16 start, u16 end)
568 return erxrdpt; 568 return erxrdpt;
569} 569}
570 570
571/*
572 * Calculate wrap around when reading beyond the end of the RX buffer
573 */
574static u16 rx_packet_start(u16 ptr)
575{
576 if (ptr + RSV_SIZE > RXEND_INIT)
577 return (ptr + RSV_SIZE) - (RXEND_INIT - RXSTART_INIT + 1);
578 else
579 return ptr + RSV_SIZE;
580}
581
571static void nolock_rxfifo_init(struct enc28j60_net *priv, u16 start, u16 end) 582static void nolock_rxfifo_init(struct enc28j60_net *priv, u16 start, u16 end)
572{ 583{
573 u16 erxrdpt; 584 u16 erxrdpt;
@@ -938,8 +949,9 @@ static void enc28j60_hw_rx(struct net_device *ndev)
938 skb->dev = ndev; 949 skb->dev = ndev;
939 skb_reserve(skb, NET_IP_ALIGN); 950 skb_reserve(skb, NET_IP_ALIGN);
940 /* copy the packet from the receive buffer */ 951 /* copy the packet from the receive buffer */
941 enc28j60_mem_read(priv, priv->next_pk_ptr + sizeof(rsv), 952 enc28j60_mem_read(priv,
942 len, skb_put(skb, len)); 953 rx_packet_start(priv->next_pk_ptr),
954 len, skb_put(skb, len));
943 if (netif_msg_pktdata(priv)) 955 if (netif_msg_pktdata(priv))
944 dump_packet(__func__, skb->len, skb->data); 956 dump_packet(__func__, skb->len, skb->data);
945 skb->protocol = eth_type_trans(skb, ndev); 957 skb->protocol = eth_type_trans(skb, ndev);
@@ -947,7 +959,7 @@ static void enc28j60_hw_rx(struct net_device *ndev)
947 ndev->stats.rx_packets++; 959 ndev->stats.rx_packets++;
948 ndev->stats.rx_bytes += len; 960 ndev->stats.rx_bytes += len;
949 ndev->last_rx = jiffies; 961 ndev->last_rx = jiffies;
950 netif_rx(skb); 962 netif_rx_ni(skb);
951 } 963 }
952 } 964 }
953 /* 965 /*
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index fbbd3e660c27..c01e290d09d2 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -230,7 +230,7 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr)
230 dev->open = &hpp_open; 230 dev->open = &hpp_open;
231 dev->stop = &hpp_close; 231 dev->stop = &hpp_close;
232#ifdef CONFIG_NET_POLL_CONTROLLER 232#ifdef CONFIG_NET_POLL_CONTROLLER
233 dev->poll_controller = ei_poll; 233 dev->poll_controller = eip_poll;
234#endif 234#endif
235 235
236 ei_status.name = name; 236 ei_status.name = name;
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 1cbae85b1426..20d27e622ec1 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1980,7 +1980,6 @@ static void igb_configure_rx(struct igb_adapter *adapter)
1980 1980
1981/** 1981/**
1982 * igb_free_tx_resources - Free Tx Resources per Queue 1982 * igb_free_tx_resources - Free Tx Resources per Queue
1983 * @adapter: board private structure
1984 * @tx_ring: Tx descriptor ring for a specific queue 1983 * @tx_ring: Tx descriptor ring for a specific queue
1985 * 1984 *
1986 * Free all transmit software resources 1985 * Free all transmit software resources
@@ -2033,7 +2032,6 @@ static void igb_unmap_and_free_tx_resource(struct igb_adapter *adapter,
2033 2032
2034/** 2033/**
2035 * igb_clean_tx_ring - Free Tx Buffers 2034 * igb_clean_tx_ring - Free Tx Buffers
2036 * @adapter: board private structure
2037 * @tx_ring: ring to be cleaned 2035 * @tx_ring: ring to be cleaned
2038 **/ 2036 **/
2039static void igb_clean_tx_ring(struct igb_ring *tx_ring) 2037static void igb_clean_tx_ring(struct igb_ring *tx_ring)
@@ -2080,7 +2078,6 @@ static void igb_clean_all_tx_rings(struct igb_adapter *adapter)
2080 2078
2081/** 2079/**
2082 * igb_free_rx_resources - Free Rx Resources 2080 * igb_free_rx_resources - Free Rx Resources
2083 * @adapter: board private structure
2084 * @rx_ring: ring to clean the resources from 2081 * @rx_ring: ring to clean the resources from
2085 * 2082 *
2086 * Free all receive software resources 2083 * Free all receive software resources
@@ -2120,7 +2117,6 @@ static void igb_free_all_rx_resources(struct igb_adapter *adapter)
2120 2117
2121/** 2118/**
2122 * igb_clean_rx_ring - Free Rx Buffers per Queue 2119 * igb_clean_rx_ring - Free Rx Buffers per Queue
2123 * @adapter: board private structure
2124 * @rx_ring: ring to free buffers from 2120 * @rx_ring: ring to free buffers from
2125 **/ 2121 **/
2126static void igb_clean_rx_ring(struct igb_ring *rx_ring) 2122static void igb_clean_rx_ring(struct igb_ring *rx_ring)
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 36f2bb666bf7..5236f633ee36 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -1320,7 +1320,6 @@ static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
1320 * ixgbe_intr - legacy mode Interrupt Handler 1320 * ixgbe_intr - legacy mode Interrupt Handler
1321 * @irq: interrupt number 1321 * @irq: interrupt number
1322 * @data: pointer to a network interface device structure 1322 * @data: pointer to a network interface device structure
1323 * @pt_regs: CPU registers structure
1324 **/ 1323 **/
1325static irqreturn_t ixgbe_intr(int irq, void *data) 1324static irqreturn_t ixgbe_intr(int irq, void *data)
1326{ 1325{
@@ -2330,7 +2329,7 @@ static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
2330 * Once we know the feature-set enabled for the device, we'll cache 2329 * Once we know the feature-set enabled for the device, we'll cache
2331 * the register offset the descriptor ring is assigned to. 2330 * the register offset the descriptor ring is assigned to.
2332 **/ 2331 **/
2333static void __devinit ixgbe_cache_ring_register(struct ixgbe_adapter *adapter) 2332static void ixgbe_cache_ring_register(struct ixgbe_adapter *adapter)
2334{ 2333{
2335 int feature_mask = 0, rss_i; 2334 int feature_mask = 0, rss_i;
2336 int i, txr_idx, rxr_idx; 2335 int i, txr_idx, rxr_idx;
@@ -2367,7 +2366,7 @@ static void __devinit ixgbe_cache_ring_register(struct ixgbe_adapter *adapter)
2367 * number of queues at compile-time. The polling_netdev array is 2366 * number of queues at compile-time. The polling_netdev array is
2368 * intended for Multiqueue, but should work fine with a single queue. 2367 * intended for Multiqueue, but should work fine with a single queue.
2369 **/ 2368 **/
2370static int __devinit ixgbe_alloc_queues(struct ixgbe_adapter *adapter) 2369static int ixgbe_alloc_queues(struct ixgbe_adapter *adapter)
2371{ 2370{
2372 int i; 2371 int i;
2373 2372
@@ -2408,8 +2407,7 @@ err_tx_ring_allocation:
2408 * Attempt to configure the interrupts using the best available 2407 * Attempt to configure the interrupts using the best available
2409 * capabilities of the hardware and the kernel. 2408 * capabilities of the hardware and the kernel.
2410 **/ 2409 **/
2411static int __devinit ixgbe_set_interrupt_capability(struct ixgbe_adapter 2410static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter)
2412 *adapter)
2413{ 2411{
2414 int err = 0; 2412 int err = 0;
2415 int vector, v_budget; 2413 int vector, v_budget;
@@ -2501,7 +2499,7 @@ static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter)
2501 * - Hardware queue count (num_*_queues) 2499 * - Hardware queue count (num_*_queues)
2502 * - defined by miscellaneous hardware support/features (RSS, etc.) 2500 * - defined by miscellaneous hardware support/features (RSS, etc.)
2503 **/ 2501 **/
2504static int __devinit ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter) 2502static int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter)
2505{ 2503{
2506 int err; 2504 int err;
2507 2505
diff --git a/drivers/net/jme.h b/drivers/net/jme.h
index f863aee6648b..3f5d91543246 100644
--- a/drivers/net/jme.h
+++ b/drivers/net/jme.h
@@ -22,7 +22,7 @@
22 */ 22 */
23 23
24#ifndef __JME_H_INCLUDED__ 24#ifndef __JME_H_INCLUDED__
25#define __JME_H_INCLUDEE__ 25#define __JME_H_INCLUDED__
26 26
27#define DRV_NAME "jme" 27#define DRV_NAME "jme"
28#define DRV_VERSION "1.0.3" 28#define DRV_VERSION "1.0.3"
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 42394505bb50..590039cbb146 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -70,6 +70,9 @@ static void macvlan_broadcast(struct sk_buff *skb,
70 struct sk_buff *nskb; 70 struct sk_buff *nskb;
71 unsigned int i; 71 unsigned int i;
72 72
73 if (skb->protocol == htons(ETH_P_PAUSE))
74 return;
75
73 for (i = 0; i < MACVLAN_HASH_SIZE; i++) { 76 for (i = 0; i < MACVLAN_HASH_SIZE; i++) {
74 hlist_for_each_entry_rcu(vlan, n, &port->vlan_hash[i], hlist) { 77 hlist_for_each_entry_rcu(vlan, n, &port->vlan_hash[i], hlist) {
75 dev = vlan->dev; 78 dev = vlan->dev;
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index 468921b8f4b6..90a0281d15ea 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -753,6 +753,7 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
753 struct mlx4_priv *priv = mlx4_priv(dev); 753 struct mlx4_priv *priv = mlx4_priv(dev);
754 int err; 754 int err;
755 int port; 755 int port;
756 __be32 ib_port_default_caps;
756 757
757 err = mlx4_init_uar_table(dev); 758 err = mlx4_init_uar_table(dev);
758 if (err) { 759 if (err) {
@@ -852,6 +853,13 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
852 } 853 }
853 854
854 for (port = 1; port <= dev->caps.num_ports; port++) { 855 for (port = 1; port <= dev->caps.num_ports; port++) {
856 ib_port_default_caps = 0;
857 err = mlx4_get_port_ib_caps(dev, port, &ib_port_default_caps);
858 if (err)
859 mlx4_warn(dev, "failed to get port %d default "
860 "ib capabilities (%d). Continuing with "
861 "caps = 0\n", port, err);
862 dev->caps.ib_port_def_cap[port] = ib_port_default_caps;
855 err = mlx4_SET_PORT(dev, port); 863 err = mlx4_SET_PORT(dev, port);
856 if (err) { 864 if (err) {
857 mlx4_err(dev, "Failed to set port %d, aborting\n", 865 mlx4_err(dev, "Failed to set port %d, aborting\n",
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h
index 56a2e213fe62..34c909deaff3 100644
--- a/drivers/net/mlx4/mlx4.h
+++ b/drivers/net/mlx4/mlx4.h
@@ -385,5 +385,6 @@ void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table);
385void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table); 385void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
386 386
387int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port); 387int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port);
388int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
388 389
389#endif /* MLX4_H */ 390#endif /* MLX4_H */
diff --git a/drivers/net/mlx4/port.c b/drivers/net/mlx4/port.c
index e2fdab42c4ce..0a057e5dc63b 100644
--- a/drivers/net/mlx4/port.c
+++ b/drivers/net/mlx4/port.c
@@ -258,6 +258,42 @@ out:
258} 258}
259EXPORT_SYMBOL_GPL(mlx4_unregister_vlan); 259EXPORT_SYMBOL_GPL(mlx4_unregister_vlan);
260 260
261int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps)
262{
263 struct mlx4_cmd_mailbox *inmailbox, *outmailbox;
264 u8 *inbuf, *outbuf;
265 int err;
266
267 inmailbox = mlx4_alloc_cmd_mailbox(dev);
268 if (IS_ERR(inmailbox))
269 return PTR_ERR(inmailbox);
270
271 outmailbox = mlx4_alloc_cmd_mailbox(dev);
272 if (IS_ERR(outmailbox)) {
273 mlx4_free_cmd_mailbox(dev, inmailbox);
274 return PTR_ERR(outmailbox);
275 }
276
277 inbuf = inmailbox->buf;
278 outbuf = outmailbox->buf;
279 memset(inbuf, 0, 256);
280 memset(outbuf, 0, 256);
281 inbuf[0] = 1;
282 inbuf[1] = 1;
283 inbuf[2] = 1;
284 inbuf[3] = 1;
285 *(__be16 *) (&inbuf[16]) = cpu_to_be16(0x0015);
286 *(__be32 *) (&inbuf[20]) = cpu_to_be32(port);
287
288 err = mlx4_cmd_box(dev, inmailbox->dma, outmailbox->dma, port, 3,
289 MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C);
290 if (!err)
291 *caps = *(__be32 *) (outbuf + 84);
292 mlx4_free_cmd_mailbox(dev, inmailbox);
293 mlx4_free_cmd_mailbox(dev, outmailbox);
294 return err;
295}
296
261int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port) 297int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port)
262{ 298{
263 struct mlx4_cmd_mailbox *mailbox; 299 struct mlx4_cmd_mailbox *mailbox;
@@ -273,7 +309,8 @@ int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port)
273 ((u8 *) mailbox->buf)[3] = 6; 309 ((u8 *) mailbox->buf)[3] = 6;
274 ((__be16 *) mailbox->buf)[4] = cpu_to_be16(1 << 15); 310 ((__be16 *) mailbox->buf)[4] = cpu_to_be16(1 << 15);
275 ((__be16 *) mailbox->buf)[6] = cpu_to_be16(1 << 15); 311 ((__be16 *) mailbox->buf)[6] = cpu_to_be16(1 << 15);
276 } 312 } else
313 ((__be32 *) mailbox->buf)[1] = dev->caps.ib_port_def_cap[port];
277 err = mlx4_cmd(dev, mailbox->dma, port, is_eth, MLX4_CMD_SET_PORT, 314 err = mlx4_cmd(dev, mailbox->dma, port, is_eth, MLX4_CMD_SET_PORT,
278 MLX4_CMD_TIME_CLASS_B); 315 MLX4_CMD_TIME_CLASS_B);
279 316
diff --git a/drivers/net/netx-eth.c b/drivers/net/netx-eth.c
index b9bed82e1d21..b289a0a2b945 100644
--- a/drivers/net/netx-eth.c
+++ b/drivers/net/netx-eth.c
@@ -401,6 +401,8 @@ static int netx_eth_drv_probe(struct platform_device *pdev)
401 priv->xmac_base = priv->xc->xmac_base; 401 priv->xmac_base = priv->xc->xmac_base;
402 priv->sram_base = priv->xc->sram_base; 402 priv->sram_base = priv->xc->sram_base;
403 403
404 spin_lock_init(&priv->lock);
405
404 ret = pfifo_request(PFIFO_MASK(priv->id)); 406 ret = pfifo_request(PFIFO_MASK(priv->id));
405 if (ret) { 407 if (ret) {
406 printk("unable to request PFIFO\n"); 408 printk("unable to request PFIFO\n");
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index b37a498939ae..0418045166c3 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -779,6 +779,7 @@ static struct pcmcia_device_id axnet_ids[] = {
779 PCMCIA_DEVICE_PROD_ID12("IO DATA", "ETXPCM", 0x547e66dc, 0x233adac2), 779 PCMCIA_DEVICE_PROD_ID12("IO DATA", "ETXPCM", 0x547e66dc, 0x233adac2),
780 PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100 V3)", 0x0733cc81, 0x232019a8), 780 PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100 V3)", 0x0733cc81, 0x232019a8),
781 PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC3-TX", 0x481e0094, 0xf91af609), 781 PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC3-TX", 0x481e0094, 0xf91af609),
782 PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA411", 0x9aa79dc3, 0x40fad875),
782 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "100BASE", 0x281f1c5d, 0x7c2add04), 783 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "100BASE", 0x281f1c5d, 0x7c2add04),
783 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FastEtherCard", 0x281f1c5d, 0x7ef26116), 784 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FastEtherCard", 0x281f1c5d, 0x7ef26116),
784 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FEP501", 0x281f1c5d, 0x2e272058), 785 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FEP501", 0x281f1c5d, 0x2e272058),
@@ -1174,7 +1175,6 @@ static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
1174 * ax_interrupt - handle the interrupts from an 8390 1175 * ax_interrupt - handle the interrupts from an 8390
1175 * @irq: interrupt number 1176 * @irq: interrupt number
1176 * @dev_id: a pointer to the net_device 1177 * @dev_id: a pointer to the net_device
1177 * @regs: unused
1178 * 1178 *
1179 * Handle the ether interface interrupts. We pull packets from 1179 * Handle the ether interface interrupts. We pull packets from
1180 * the 8390 via the card specific functions and fire them at the networking 1180 * the 8390 via the card specific functions and fire them at the networking
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index cf3cca4642f2..f51944b28cfa 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -349,7 +349,7 @@ static int ibmtr_suspend(struct pcmcia_device *link)
349 return 0; 349 return 0;
350} 350}
351 351
352static int ibmtr_resume(struct pcmcia_device *link) 352static int __devinit ibmtr_resume(struct pcmcia_device *link)
353{ 353{
354 ibmtr_dev_t *info = link->priv; 354 ibmtr_dev_t *info = link->priv;
355 struct net_device *dev = info->dev; 355 struct net_device *dev = info->dev;
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index e40d6301aa7a..ce486f094492 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -1693,7 +1693,6 @@ static struct pcmcia_device_id pcnet_ids[] = {
1693 PCMCIA_DEVICE_PROD_ID12("National Semiconductor", "InfoMover NE4100", 0x36e1191f, 0xa6617ec8), 1693 PCMCIA_DEVICE_PROD_ID12("National Semiconductor", "InfoMover NE4100", 0x36e1191f, 0xa6617ec8),
1694 PCMCIA_DEVICE_PROD_ID12("NEC", "PC-9801N-J12", 0x18df0ba0, 0xbc912d76), 1694 PCMCIA_DEVICE_PROD_ID12("NEC", "PC-9801N-J12", 0x18df0ba0, 0xbc912d76),
1695 PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA410TX", 0x9aa79dc3, 0x60e5bc0e), 1695 PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA410TX", 0x9aa79dc3, 0x60e5bc0e),
1696 PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA411", 0x9aa79dc3, 0x40fad875),
1697 PCMCIA_DEVICE_PROD_ID12("Network Everywhere", "Fast Ethernet 10/100 PC Card", 0x820a67b6, 0x31ed1a5f), 1696 PCMCIA_DEVICE_PROD_ID12("Network Everywhere", "Fast Ethernet 10/100 PC Card", 0x820a67b6, 0x31ed1a5f),
1698 PCMCIA_DEVICE_PROD_ID12("NextCom K.K.", "Next Hawk", 0xaedaec74, 0xad050ef1), 1697 PCMCIA_DEVICE_PROD_ID12("NextCom K.K.", "Next Hawk", 0xaedaec74, 0xad050ef1),
1699 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100Mbps Ethernet Card", 0x281f1c5d, 0x6e41773b), 1698 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100Mbps Ethernet Card", 0x281f1c5d, 0x6e41773b),
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 536bda1f428b..289fc267edf3 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -105,8 +105,6 @@ int mdiobus_register(struct mii_bus *bus)
105 return -EINVAL; 105 return -EINVAL;
106 } 106 }
107 107
108 bus->state = MDIOBUS_REGISTERED;
109
110 mutex_init(&bus->mdio_lock); 108 mutex_init(&bus->mdio_lock);
111 109
112 if (bus->reset) 110 if (bus->reset)
@@ -123,6 +121,9 @@ int mdiobus_register(struct mii_bus *bus)
123 } 121 }
124 } 122 }
125 123
124 if (!err)
125 bus->state = MDIOBUS_REGISTERED;
126
126 pr_info("%s: probed\n", bus->name); 127 pr_info("%s: probed\n", bus->name);
127 128
128 return err; 129 return err;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 55bc24b234e3..25acbbde4a60 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -227,8 +227,17 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
227 if (r) 227 if (r)
228 return ERR_PTR(r); 228 return ERR_PTR(r);
229 229
230 /* If the phy_id is all Fs or all 0s, there is no device there */ 230 /* If the phy_id is mostly Fs, there is no device there */
231 if ((0xffff == phy_id) || (0x00 == phy_id)) 231 if ((phy_id & 0x1fffffff) == 0x1fffffff)
232 return NULL;
233
234 /*
235 * Broken hardware is sometimes missing the pull down resistor on the
236 * MDIO line, which results in reads to non-existent devices returning
237 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
238 * device as well.
239 */
240 if (phy_id == 0)
232 return NULL; 241 return NULL;
233 242
234 dev = phy_device_create(bus, addr, phy_id); 243 dev = phy_device_create(bus, addr, phy_id);
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 8874497b6bbf..dd3b2447e85a 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -34,6 +34,8 @@
34#define MII_VSC8244_IMASK_DUPLEX 0x1000 34#define MII_VSC8244_IMASK_DUPLEX 0x1000
35#define MII_VSC8244_IMASK_MASK 0xf000 35#define MII_VSC8244_IMASK_MASK 0xf000
36 36
37#define MII_VSC8221_IMASK_MASK 0xa000
38
37/* Vitesse Interrupt Status Register */ 39/* Vitesse Interrupt Status Register */
38#define MII_VSC8244_ISTAT 0x1a 40#define MII_VSC8244_ISTAT 0x1a
39#define MII_VSC8244_ISTAT_STATUS 0x8000 41#define MII_VSC8244_ISTAT_STATUS 0x8000
@@ -49,6 +51,12 @@
49#define MII_VSC8244_AUXCONSTAT_GBIT 0x0010 51#define MII_VSC8244_AUXCONSTAT_GBIT 0x0010
50#define MII_VSC8244_AUXCONSTAT_100 0x0008 52#define MII_VSC8244_AUXCONSTAT_100 0x0008
51 53
54#define MII_VSC8221_AUXCONSTAT_INIT 0x0004 /* need to set this bit? */
55#define MII_VSC8221_AUXCONSTAT_RESERVED 0x0004
56
57#define PHY_ID_VSC8244 0x000fc6c0
58#define PHY_ID_VSC8221 0x000fc550
59
52MODULE_DESCRIPTION("Vitesse PHY driver"); 60MODULE_DESCRIPTION("Vitesse PHY driver");
53MODULE_AUTHOR("Kriston Carson"); 61MODULE_AUTHOR("Kriston Carson");
54MODULE_LICENSE("GPL"); 62MODULE_LICENSE("GPL");
@@ -95,13 +103,15 @@ static int vsc824x_ack_interrupt(struct phy_device *phydev)
95 return (err < 0) ? err : 0; 103 return (err < 0) ? err : 0;
96} 104}
97 105
98static int vsc824x_config_intr(struct phy_device *phydev) 106static int vsc82xx_config_intr(struct phy_device *phydev)
99{ 107{
100 int err; 108 int err;
101 109
102 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) 110 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
103 err = phy_write(phydev, MII_VSC8244_IMASK, 111 err = phy_write(phydev, MII_VSC8244_IMASK,
104 MII_VSC8244_IMASK_MASK); 112 phydev->drv->phy_id == PHY_ID_VSC8244 ?
113 MII_VSC8244_IMASK_MASK :
114 MII_VSC8221_IMASK_MASK);
105 else { 115 else {
106 /* 116 /*
107 * The Vitesse PHY cannot clear the interrupt 117 * The Vitesse PHY cannot clear the interrupt
@@ -120,7 +130,7 @@ static int vsc824x_config_intr(struct phy_device *phydev)
120 130
121/* Vitesse 824x */ 131/* Vitesse 824x */
122static struct phy_driver vsc8244_driver = { 132static struct phy_driver vsc8244_driver = {
123 .phy_id = 0x000fc6c0, 133 .phy_id = PHY_ID_VSC8244,
124 .name = "Vitesse VSC8244", 134 .name = "Vitesse VSC8244",
125 .phy_id_mask = 0x000fffc0, 135 .phy_id_mask = 0x000fffc0,
126 .features = PHY_GBIT_FEATURES, 136 .features = PHY_GBIT_FEATURES,
@@ -129,19 +139,55 @@ static struct phy_driver vsc8244_driver = {
129 .config_aneg = &genphy_config_aneg, 139 .config_aneg = &genphy_config_aneg,
130 .read_status = &genphy_read_status, 140 .read_status = &genphy_read_status,
131 .ack_interrupt = &vsc824x_ack_interrupt, 141 .ack_interrupt = &vsc824x_ack_interrupt,
132 .config_intr = &vsc824x_config_intr, 142 .config_intr = &vsc82xx_config_intr,
133 .driver = { .owner = THIS_MODULE,}, 143 .driver = { .owner = THIS_MODULE,},
134}; 144};
135 145
136static int __init vsc8244_init(void) 146static int vsc8221_config_init(struct phy_device *phydev)
137{ 147{
138 return phy_driver_register(&vsc8244_driver); 148 int err;
149
150 err = phy_write(phydev, MII_VSC8244_AUX_CONSTAT,
151 MII_VSC8221_AUXCONSTAT_INIT);
152 return err;
153
154 /* Perhaps we should set EXT_CON1 based on the interface?
155 Options are 802.3Z SerDes or SGMII */
156}
157
158/* Vitesse 8221 */
159static struct phy_driver vsc8221_driver = {
160 .phy_id = PHY_ID_VSC8221,
161 .phy_id_mask = 0x000ffff0,
162 .name = "Vitesse VSC8221",
163 .features = PHY_GBIT_FEATURES,
164 .flags = PHY_HAS_INTERRUPT,
165 .config_init = &vsc8221_config_init,
166 .config_aneg = &genphy_config_aneg,
167 .read_status = &genphy_read_status,
168 .ack_interrupt = &vsc824x_ack_interrupt,
169 .config_intr = &vsc82xx_config_intr,
170 .driver = { .owner = THIS_MODULE,},
171};
172
173static int __init vsc82xx_init(void)
174{
175 int err;
176
177 err = phy_driver_register(&vsc8244_driver);
178 if (err < 0)
179 return err;
180 err = phy_driver_register(&vsc8221_driver);
181 if (err < 0)
182 phy_driver_unregister(&vsc8244_driver);
183 return err;
139} 184}
140 185
141static void __exit vsc8244_exit(void) 186static void __exit vsc82xx_exit(void)
142{ 187{
143 phy_driver_unregister(&vsc8244_driver); 188 phy_driver_unregister(&vsc8244_driver);
189 phy_driver_unregister(&vsc8221_driver);
144} 190}
145 191
146module_init(vsc8244_init); 192module_init(vsc82xx_init);
147module_exit(vsc8244_exit); 193module_exit(vsc82xx_exit);
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 7e857e938adb..714a23035de1 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -116,6 +116,7 @@ struct ppp {
116 unsigned long last_xmit; /* jiffies when last pkt sent 9c */ 116 unsigned long last_xmit; /* jiffies when last pkt sent 9c */
117 unsigned long last_recv; /* jiffies when last pkt rcvd a0 */ 117 unsigned long last_recv; /* jiffies when last pkt rcvd a0 */
118 struct net_device *dev; /* network interface device a4 */ 118 struct net_device *dev; /* network interface device a4 */
119 int closing; /* is device closing down? a8 */
119#ifdef CONFIG_PPP_MULTILINK 120#ifdef CONFIG_PPP_MULTILINK
120 int nxchan; /* next channel to send something on */ 121 int nxchan; /* next channel to send something on */
121 u32 nxseq; /* next sequence number to send */ 122 u32 nxseq; /* next sequence number to send */
@@ -995,7 +996,7 @@ ppp_xmit_process(struct ppp *ppp)
995 struct sk_buff *skb; 996 struct sk_buff *skb;
996 997
997 ppp_xmit_lock(ppp); 998 ppp_xmit_lock(ppp);
998 if (ppp->dev) { 999 if (!ppp->closing) {
999 ppp_push(ppp); 1000 ppp_push(ppp);
1000 while (!ppp->xmit_pending 1001 while (!ppp->xmit_pending
1001 && (skb = skb_dequeue(&ppp->file.xq))) 1002 && (skb = skb_dequeue(&ppp->file.xq)))
@@ -1463,8 +1464,7 @@ static inline void
1463ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) 1464ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1464{ 1465{
1465 ppp_recv_lock(ppp); 1466 ppp_recv_lock(ppp);
1466 /* ppp->dev == 0 means interface is closing down */ 1467 if (!ppp->closing)
1467 if (ppp->dev)
1468 ppp_receive_frame(ppp, skb, pch); 1468 ppp_receive_frame(ppp, skb, pch);
1469 else 1469 else
1470 kfree_skb(skb); 1470 kfree_skb(skb);
@@ -2498,18 +2498,16 @@ init_ppp_file(struct ppp_file *pf, int kind)
2498 */ 2498 */
2499static void ppp_shutdown_interface(struct ppp *ppp) 2499static void ppp_shutdown_interface(struct ppp *ppp)
2500{ 2500{
2501 struct net_device *dev;
2502
2503 mutex_lock(&all_ppp_mutex); 2501 mutex_lock(&all_ppp_mutex);
2504 ppp_lock(ppp);
2505 dev = ppp->dev;
2506 ppp->dev = NULL;
2507 ppp_unlock(ppp);
2508 /* This will call dev_close() for us. */ 2502 /* This will call dev_close() for us. */
2509 if (dev) { 2503 ppp_lock(ppp);
2510 unregister_netdev(dev); 2504 if (!ppp->closing) {
2511 free_netdev(dev); 2505 ppp->closing = 1;
2512 } 2506 ppp_unlock(ppp);
2507 unregister_netdev(ppp->dev);
2508 } else
2509 ppp_unlock(ppp);
2510
2513 cardmap_set(&all_ppp_units, ppp->file.index, NULL); 2511 cardmap_set(&all_ppp_units, ppp->file.index, NULL);
2514 ppp->file.dead = 1; 2512 ppp->file.dead = 1;
2515 ppp->owner = NULL; 2513 ppp->owner = NULL;
@@ -2554,7 +2552,7 @@ static void ppp_destroy_interface(struct ppp *ppp)
2554 if (ppp->xmit_pending) 2552 if (ppp->xmit_pending)
2555 kfree_skb(ppp->xmit_pending); 2553 kfree_skb(ppp->xmit_pending);
2556 2554
2557 kfree(ppp); 2555 free_netdev(ppp->dev);
2558} 2556}
2559 2557
2560/* 2558/*
@@ -2616,7 +2614,7 @@ ppp_connect_channel(struct channel *pch, int unit)
2616 if (pch->file.hdrlen > ppp->file.hdrlen) 2614 if (pch->file.hdrlen > ppp->file.hdrlen)
2617 ppp->file.hdrlen = pch->file.hdrlen; 2615 ppp->file.hdrlen = pch->file.hdrlen;
2618 hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */ 2616 hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */
2619 if (ppp->dev && hdrlen > ppp->dev->hard_header_len) 2617 if (hdrlen > ppp->dev->hard_header_len)
2620 ppp->dev->hard_header_len = hdrlen; 2618 ppp->dev->hard_header_len = hdrlen;
2621 list_add_tail(&pch->clist, &ppp->channels); 2619 list_add_tail(&pch->clist, &ppp->channels);
2622 ++ppp->n_channels; 2620 ++ppp->n_channels;
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index 185b1dff10a8..e98d9773158d 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -1353,6 +1353,7 @@ static int pppol2tp_release(struct socket *sock)
1353 kfree_skb(skb); 1353 kfree_skb(skb);
1354 sock_put(sk); 1354 sock_put(sk);
1355 } 1355 }
1356 sock_put(sk);
1356 } 1357 }
1357 1358
1358 release_sock(sk); 1359 release_sock(sk);
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index fa3a460f8e2f..8e8337e8b072 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -1630,7 +1630,6 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
1630 * sis900_interrupt - sis900 interrupt handler 1630 * sis900_interrupt - sis900 interrupt handler
1631 * @irq: the irq number 1631 * @irq: the irq number
1632 * @dev_instance: the client data object 1632 * @dev_instance: the client data object
1633 * @regs: snapshot of processor context
1634 * 1633 *
1635 * The interrupt handler does all of the Rx thread work, 1634 * The interrupt handler does all of the Rx thread work,
1636 * and cleans up after the Tx thread 1635 * and cleans up after the Tx thread
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index b185cd12269c..9a16a79b67d0 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -1735,7 +1735,7 @@ static const struct ethtool_ops smc911x_ethtool_ops = {
1735 * This routine has a simple purpose -- make the SMC chip generate an 1735 * This routine has a simple purpose -- make the SMC chip generate an
1736 * interrupt, so an auto-detect routine can detect it, and find the IRQ, 1736 * interrupt, so an auto-detect routine can detect it, and find the IRQ,
1737 */ 1737 */
1738static int __init smc911x_findirq(struct net_device *dev) 1738static int __devinit smc911x_findirq(struct net_device *dev)
1739{ 1739{
1740 struct smc911x_local *lp = netdev_priv(dev); 1740 struct smc911x_local *lp = netdev_priv(dev);
1741 int timeout = 20; 1741 int timeout = 20;
@@ -1799,7 +1799,7 @@ static int __init smc911x_findirq(struct net_device *dev)
1799 * o actually GRAB the irq. 1799 * o actually GRAB the irq.
1800 * o GRAB the region 1800 * o GRAB the region
1801 */ 1801 */
1802static int __init smc911x_probe(struct net_device *dev) 1802static int __devinit smc911x_probe(struct net_device *dev)
1803{ 1803{
1804 struct smc911x_local *lp = netdev_priv(dev); 1804 struct smc911x_local *lp = netdev_priv(dev);
1805 int i, retval; 1805 int i, retval;
@@ -2048,7 +2048,7 @@ err_out:
2048 * 0 --> there is a device 2048 * 0 --> there is a device
2049 * anything else, error 2049 * anything else, error
2050 */ 2050 */
2051static int smc911x_drv_probe(struct platform_device *pdev) 2051static int __devinit smc911x_drv_probe(struct platform_device *pdev)
2052{ 2052{
2053#ifdef SMC_DYNAMIC_BUS_CONFIG 2053#ifdef SMC_DYNAMIC_BUS_CONFIG
2054 struct smc911x_platdata *pd = pdev->dev.platform_data; 2054 struct smc911x_platdata *pd = pdev->dev.platform_data;
@@ -2124,7 +2124,7 @@ out:
2124 return ret; 2124 return ret;
2125} 2125}
2126 2126
2127static int smc911x_drv_remove(struct platform_device *pdev) 2127static int __devexit smc911x_drv_remove(struct platform_device *pdev)
2128{ 2128{
2129 struct net_device *ndev = platform_get_drvdata(pdev); 2129 struct net_device *ndev = platform_get_drvdata(pdev);
2130 struct smc911x_local *lp = netdev_priv(ndev); 2130 struct smc911x_local *lp = netdev_priv(ndev);
@@ -2195,7 +2195,7 @@ static int smc911x_drv_resume(struct platform_device *dev)
2195 2195
2196static struct platform_driver smc911x_driver = { 2196static struct platform_driver smc911x_driver = {
2197 .probe = smc911x_drv_probe, 2197 .probe = smc911x_drv_probe,
2198 .remove = smc911x_drv_remove, 2198 .remove = __devexit_p(smc911x_drv_remove),
2199 .suspend = smc911x_drv_suspend, 2199 .suspend = smc911x_drv_suspend,
2200 .resume = smc911x_drv_resume, 2200 .resume = smc911x_drv_resume,
2201 .driver = { 2201 .driver = {
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index fc80f250da31..35c56abf4113 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -1696,7 +1696,7 @@ static const struct ethtool_ops smc_ethtool_ops = {
1696 * I just deleted auto_irq.c, since it was never built... 1696 * I just deleted auto_irq.c, since it was never built...
1697 * --jgarzik 1697 * --jgarzik
1698 */ 1698 */
1699static int __init smc_findirq(struct smc_local *lp) 1699static int __devinit smc_findirq(struct smc_local *lp)
1700{ 1700{
1701 void __iomem *ioaddr = lp->base; 1701 void __iomem *ioaddr = lp->base;
1702 int timeout = 20; 1702 int timeout = 20;
@@ -1770,7 +1770,7 @@ static int __init smc_findirq(struct smc_local *lp)
1770 * o actually GRAB the irq. 1770 * o actually GRAB the irq.
1771 * o GRAB the region 1771 * o GRAB the region
1772 */ 1772 */
1773static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr, 1773static int __devinit smc_probe(struct net_device *dev, void __iomem *ioaddr,
1774 unsigned long irq_flags) 1774 unsigned long irq_flags)
1775{ 1775{
1776 struct smc_local *lp = netdev_priv(dev); 1776 struct smc_local *lp = netdev_priv(dev);
@@ -2126,7 +2126,7 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
2126 * 0 --> there is a device 2126 * 0 --> there is a device
2127 * anything else, error 2127 * anything else, error
2128 */ 2128 */
2129static int smc_drv_probe(struct platform_device *pdev) 2129static int __devinit smc_drv_probe(struct platform_device *pdev)
2130{ 2130{
2131 struct smc91x_platdata *pd = pdev->dev.platform_data; 2131 struct smc91x_platdata *pd = pdev->dev.platform_data;
2132 struct smc_local *lp; 2132 struct smc_local *lp;
@@ -2240,7 +2240,7 @@ static int smc_drv_probe(struct platform_device *pdev)
2240 return ret; 2240 return ret;
2241} 2241}
2242 2242
2243static int smc_drv_remove(struct platform_device *pdev) 2243static int __devexit smc_drv_remove(struct platform_device *pdev)
2244{ 2244{
2245 struct net_device *ndev = platform_get_drvdata(pdev); 2245 struct net_device *ndev = platform_get_drvdata(pdev);
2246 struct smc_local *lp = netdev_priv(ndev); 2246 struct smc_local *lp = netdev_priv(ndev);
@@ -2305,7 +2305,7 @@ static int smc_drv_resume(struct platform_device *dev)
2305 2305
2306static struct platform_driver smc_driver = { 2306static struct platform_driver smc_driver = {
2307 .probe = smc_drv_probe, 2307 .probe = smc_drv_probe,
2308 .remove = smc_drv_remove, 2308 .remove = __devexit_p(smc_drv_remove),
2309 .suspend = smc_drv_suspend, 2309 .suspend = smc_drv_suspend,
2310 .resume = smc_drv_resume, 2310 .resume = smc_drv_resume,
2311 .driver = { 2311 .driver = {
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index b6435d0d71f9..07599b492359 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -672,7 +672,6 @@ write_hash:
672/** 672/**
673 * spider_net_prepare_tx_descr - fill tx descriptor with skb data 673 * spider_net_prepare_tx_descr - fill tx descriptor with skb data
674 * @card: card structure 674 * @card: card structure
675 * @descr: descriptor structure to fill out
676 * @skb: packet to use 675 * @skb: packet to use
677 * 676 *
678 * returns 0 on success, <0 on failure. 677 * returns 0 on success, <0 on failure.
@@ -867,7 +866,6 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
867/** 866/**
868 * spider_net_kick_tx_dma - enables TX DMA processing 867 * spider_net_kick_tx_dma - enables TX DMA processing
869 * @card: card structure 868 * @card: card structure
870 * @descr: descriptor address to enable TX processing at
871 * 869 *
872 * This routine will start the transmit DMA running if 870 * This routine will start the transmit DMA running if
873 * it is not already running. This routine ned only be 871 * it is not already running. This routine ned only be
@@ -1637,7 +1635,6 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg,
1637 * spider_net_interrupt - interrupt handler for spider_net 1635 * spider_net_interrupt - interrupt handler for spider_net
1638 * @irq: interrupt number 1636 * @irq: interrupt number
1639 * @ptr: pointer to net_device 1637 * @ptr: pointer to net_device
1640 * @regs: PU registers
1641 * 1638 *
1642 * returns IRQ_HANDLED, if interrupt was for driver, or IRQ_NONE, if no 1639 * returns IRQ_HANDLED, if interrupt was for driver, or IRQ_NONE, if no
1643 * interrupt found raised by card. 1640 * interrupt found raised by card.
@@ -2419,7 +2416,6 @@ spider_net_undo_pci_setup(struct spider_net_card *card)
2419 2416
2420/** 2417/**
2421 * spider_net_setup_pci_dev - sets up the device in terms of PCI operations 2418 * spider_net_setup_pci_dev - sets up the device in terms of PCI operations
2422 * @card: card structure
2423 * @pdev: PCI device 2419 * @pdev: PCI device
2424 * 2420 *
2425 * Returns the card structure or NULL if any errors occur 2421 * Returns the card structure or NULL if any errors occur
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 1d2ef8f47780..5a40f2d78beb 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -1509,6 +1509,11 @@ static int __netdev_rx(struct net_device *dev, int *quota)
1509 desc->status = 0; 1509 desc->status = 0;
1510 np->rx_done = (np->rx_done + 1) % DONE_Q_SIZE; 1510 np->rx_done = (np->rx_done + 1) % DONE_Q_SIZE;
1511 } 1511 }
1512
1513 if (*quota == 0) { /* out of rx quota */
1514 retcode = 1;
1515 goto out;
1516 }
1512 writew(np->rx_done, np->base + CompletionQConsumerIdx); 1517 writew(np->rx_done, np->base + CompletionQConsumerIdx);
1513 1518
1514 out: 1519 out:
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 4291458955ef..fed7eba65ead 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -1142,6 +1142,70 @@ static int gem_start_xmit(struct sk_buff *skb, struct net_device *dev)
1142 return NETDEV_TX_OK; 1142 return NETDEV_TX_OK;
1143} 1143}
1144 1144
1145static void gem_pcs_reset(struct gem *gp)
1146{
1147 int limit;
1148 u32 val;
1149
1150 /* Reset PCS unit. */
1151 val = readl(gp->regs + PCS_MIICTRL);
1152 val |= PCS_MIICTRL_RST;
1153 writel(val, gp->regs + PCS_MIICTRL);
1154
1155 limit = 32;
1156 while (readl(gp->regs + PCS_MIICTRL) & PCS_MIICTRL_RST) {
1157 udelay(100);
1158 if (limit-- <= 0)
1159 break;
1160 }
1161 if (limit <= 0)
1162 printk(KERN_WARNING "%s: PCS reset bit would not clear.\n",
1163 gp->dev->name);
1164}
1165
1166static void gem_pcs_reinit_adv(struct gem *gp)
1167{
1168 u32 val;
1169
1170 /* Make sure PCS is disabled while changing advertisement
1171 * configuration.
1172 */
1173 val = readl(gp->regs + PCS_CFG);
1174 val &= ~(PCS_CFG_ENABLE | PCS_CFG_TO);
1175 writel(val, gp->regs + PCS_CFG);
1176
1177 /* Advertise all capabilities except assymetric
1178 * pause.
1179 */
1180 val = readl(gp->regs + PCS_MIIADV);
1181 val |= (PCS_MIIADV_FD | PCS_MIIADV_HD |
1182 PCS_MIIADV_SP | PCS_MIIADV_AP);
1183 writel(val, gp->regs + PCS_MIIADV);
1184
1185 /* Enable and restart auto-negotiation, disable wrapback/loopback,
1186 * and re-enable PCS.
1187 */
1188 val = readl(gp->regs + PCS_MIICTRL);
1189 val |= (PCS_MIICTRL_RAN | PCS_MIICTRL_ANE);
1190 val &= ~PCS_MIICTRL_WB;
1191 writel(val, gp->regs + PCS_MIICTRL);
1192
1193 val = readl(gp->regs + PCS_CFG);
1194 val |= PCS_CFG_ENABLE;
1195 writel(val, gp->regs + PCS_CFG);
1196
1197 /* Make sure serialink loopback is off. The meaning
1198 * of this bit is logically inverted based upon whether
1199 * you are in Serialink or SERDES mode.
1200 */
1201 val = readl(gp->regs + PCS_SCTRL);
1202 if (gp->phy_type == phy_serialink)
1203 val &= ~PCS_SCTRL_LOOP;
1204 else
1205 val |= PCS_SCTRL_LOOP;
1206 writel(val, gp->regs + PCS_SCTRL);
1207}
1208
1145#define STOP_TRIES 32 1209#define STOP_TRIES 32
1146 1210
1147/* Must be invoked under gp->lock and gp->tx_lock. */ 1211/* Must be invoked under gp->lock and gp->tx_lock. */
@@ -1168,6 +1232,9 @@ static void gem_reset(struct gem *gp)
1168 1232
1169 if (limit <= 0) 1233 if (limit <= 0)
1170 printk(KERN_ERR "%s: SW reset is ghetto.\n", gp->dev->name); 1234 printk(KERN_ERR "%s: SW reset is ghetto.\n", gp->dev->name);
1235
1236 if (gp->phy_type == phy_serialink || gp->phy_type == phy_serdes)
1237 gem_pcs_reinit_adv(gp);
1171} 1238}
1172 1239
1173/* Must be invoked under gp->lock and gp->tx_lock. */ 1240/* Must be invoked under gp->lock and gp->tx_lock. */
@@ -1324,7 +1391,7 @@ static int gem_set_link_modes(struct gem *gp)
1324 gp->phy_type == phy_serdes) { 1391 gp->phy_type == phy_serdes) {
1325 u32 pcs_lpa = readl(gp->regs + PCS_MIILP); 1392 u32 pcs_lpa = readl(gp->regs + PCS_MIILP);
1326 1393
1327 if (pcs_lpa & PCS_MIIADV_FD) 1394 if ((pcs_lpa & PCS_MIIADV_FD) || gp->phy_type == phy_serdes)
1328 full_duplex = 1; 1395 full_duplex = 1;
1329 speed = SPEED_1000; 1396 speed = SPEED_1000;
1330 } 1397 }
@@ -1488,6 +1555,9 @@ static void gem_link_timer(unsigned long data)
1488 val = readl(gp->regs + PCS_MIISTAT); 1555 val = readl(gp->regs + PCS_MIISTAT);
1489 1556
1490 if ((val & PCS_MIISTAT_LS) != 0) { 1557 if ((val & PCS_MIISTAT_LS) != 0) {
1558 if (gp->lstate == link_up)
1559 goto restart;
1560
1491 gp->lstate = link_up; 1561 gp->lstate = link_up;
1492 netif_carrier_on(gp->dev); 1562 netif_carrier_on(gp->dev);
1493 (void)gem_set_link_modes(gp); 1563 (void)gem_set_link_modes(gp);
@@ -1708,61 +1778,8 @@ static void gem_init_phy(struct gem *gp)
1708 if (gp->phy_mii.def && gp->phy_mii.def->ops->init) 1778 if (gp->phy_mii.def && gp->phy_mii.def->ops->init)
1709 gp->phy_mii.def->ops->init(&gp->phy_mii); 1779 gp->phy_mii.def->ops->init(&gp->phy_mii);
1710 } else { 1780 } else {
1711 u32 val; 1781 gem_pcs_reset(gp);
1712 int limit; 1782 gem_pcs_reinit_adv(gp);
1713
1714 /* Reset PCS unit. */
1715 val = readl(gp->regs + PCS_MIICTRL);
1716 val |= PCS_MIICTRL_RST;
1717 writeb(val, gp->regs + PCS_MIICTRL);
1718
1719 limit = 32;
1720 while (readl(gp->regs + PCS_MIICTRL) & PCS_MIICTRL_RST) {
1721 udelay(100);
1722 if (limit-- <= 0)
1723 break;
1724 }
1725 if (limit <= 0)
1726 printk(KERN_WARNING "%s: PCS reset bit would not clear.\n",
1727 gp->dev->name);
1728
1729 /* Make sure PCS is disabled while changing advertisement
1730 * configuration.
1731 */
1732 val = readl(gp->regs + PCS_CFG);
1733 val &= ~(PCS_CFG_ENABLE | PCS_CFG_TO);
1734 writel(val, gp->regs + PCS_CFG);
1735
1736 /* Advertise all capabilities except assymetric
1737 * pause.
1738 */
1739 val = readl(gp->regs + PCS_MIIADV);
1740 val |= (PCS_MIIADV_FD | PCS_MIIADV_HD |
1741 PCS_MIIADV_SP | PCS_MIIADV_AP);
1742 writel(val, gp->regs + PCS_MIIADV);
1743
1744 /* Enable and restart auto-negotiation, disable wrapback/loopback,
1745 * and re-enable PCS.
1746 */
1747 val = readl(gp->regs + PCS_MIICTRL);
1748 val |= (PCS_MIICTRL_RAN | PCS_MIICTRL_ANE);
1749 val &= ~PCS_MIICTRL_WB;
1750 writel(val, gp->regs + PCS_MIICTRL);
1751
1752 val = readl(gp->regs + PCS_CFG);
1753 val |= PCS_CFG_ENABLE;
1754 writel(val, gp->regs + PCS_CFG);
1755
1756 /* Make sure serialink loopback is off. The meaning
1757 * of this bit is logically inverted based upon whether
1758 * you are in Serialink or SERDES mode.
1759 */
1760 val = readl(gp->regs + PCS_SCTRL);
1761 if (gp->phy_type == phy_serialink)
1762 val &= ~PCS_SCTRL_LOOP;
1763 else
1764 val |= PCS_SCTRL_LOOP;
1765 writel(val, gp->regs + PCS_SCTRL);
1766 } 1783 }
1767 1784
1768 /* Default aneg parameters */ 1785 /* Default aneg parameters */
@@ -2680,6 +2697,21 @@ static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2680 cmd->speed = 0; 2697 cmd->speed = 0;
2681 cmd->duplex = cmd->port = cmd->phy_address = 2698 cmd->duplex = cmd->port = cmd->phy_address =
2682 cmd->transceiver = cmd->autoneg = 0; 2699 cmd->transceiver = cmd->autoneg = 0;
2700
2701 /* serdes means usually a Fibre connector, with most fixed */
2702 if (gp->phy_type == phy_serdes) {
2703 cmd->port = PORT_FIBRE;
2704 cmd->supported = (SUPPORTED_1000baseT_Half |
2705 SUPPORTED_1000baseT_Full |
2706 SUPPORTED_FIBRE | SUPPORTED_Autoneg |
2707 SUPPORTED_Pause | SUPPORTED_Asym_Pause);
2708 cmd->advertising = cmd->supported;
2709 cmd->transceiver = XCVR_INTERNAL;
2710 if (gp->lstate == link_up)
2711 cmd->speed = SPEED_1000;
2712 cmd->duplex = DUPLEX_FULL;
2713 cmd->autoneg = 1;
2714 }
2683 } 2715 }
2684 cmd->maxtxpkt = cmd->maxrxpkt = 0; 2716 cmd->maxtxpkt = cmd->maxrxpkt = 0;
2685 2717
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index c41d68761364..e60498232b94 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -1098,6 +1098,7 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
1098 dma_addr_t tail_list_phys; 1098 dma_addr_t tail_list_phys;
1099 u8 *tail_buffer; 1099 u8 *tail_buffer;
1100 unsigned long flags; 1100 unsigned long flags;
1101 unsigned int txlen;
1101 1102
1102 if ( ! priv->phyOnline ) { 1103 if ( ! priv->phyOnline ) {
1103 TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n", 1104 TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n",
@@ -1108,6 +1109,7 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
1108 1109
1109 if (skb_padto(skb, TLAN_MIN_FRAME_SIZE)) 1110 if (skb_padto(skb, TLAN_MIN_FRAME_SIZE))
1110 return 0; 1111 return 0;
1112 txlen = max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE);
1111 1113
1112 tail_list = priv->txList + priv->txTail; 1114 tail_list = priv->txList + priv->txTail;
1113 tail_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txTail; 1115 tail_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txTail;
@@ -1125,16 +1127,16 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
1125 1127
1126 if ( bbuf ) { 1128 if ( bbuf ) {
1127 tail_buffer = priv->txBuffer + ( priv->txTail * TLAN_MAX_FRAME_SIZE ); 1129 tail_buffer = priv->txBuffer + ( priv->txTail * TLAN_MAX_FRAME_SIZE );
1128 skb_copy_from_linear_data(skb, tail_buffer, skb->len); 1130 skb_copy_from_linear_data(skb, tail_buffer, txlen);
1129 } else { 1131 } else {
1130 tail_list->buffer[0].address = pci_map_single(priv->pciDev, 1132 tail_list->buffer[0].address = pci_map_single(priv->pciDev,
1131 skb->data, skb->len, 1133 skb->data, txlen,
1132 PCI_DMA_TODEVICE); 1134 PCI_DMA_TODEVICE);
1133 TLan_StoreSKB(tail_list, skb); 1135 TLan_StoreSKB(tail_list, skb);
1134 } 1136 }
1135 1137
1136 tail_list->frameSize = (u16) skb->len; 1138 tail_list->frameSize = (u16) txlen;
1137 tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) skb->len; 1139 tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) txlen;
1138 tail_list->buffer[1].count = 0; 1140 tail_list->buffer[1].count = 0;
1139 tail_list->buffer[1].address = 0; 1141 tail_list->buffer[1].address = 0;
1140 1142
@@ -1431,7 +1433,9 @@ static u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
1431 if ( ! bbuf ) { 1433 if ( ! bbuf ) {
1432 struct sk_buff *skb = TLan_GetSKB(head_list); 1434 struct sk_buff *skb = TLan_GetSKB(head_list);
1433 pci_unmap_single(priv->pciDev, head_list->buffer[0].address, 1435 pci_unmap_single(priv->pciDev, head_list->buffer[0].address,
1434 skb->len, PCI_DMA_TODEVICE); 1436 max(skb->len,
1437 (unsigned int)TLAN_MIN_FRAME_SIZE),
1438 PCI_DMA_TODEVICE);
1435 dev_kfree_skb_any(skb); 1439 dev_kfree_skb_any(skb);
1436 head_list->buffer[8].address = 0; 1440 head_list->buffer[8].address = 0;
1437 head_list->buffer[9].address = 0; 1441 head_list->buffer[9].address = 0;
@@ -2055,9 +2059,12 @@ static void TLan_FreeLists( struct net_device *dev )
2055 list = priv->txList + i; 2059 list = priv->txList + i;
2056 skb = TLan_GetSKB(list); 2060 skb = TLan_GetSKB(list);
2057 if ( skb ) { 2061 if ( skb ) {
2058 pci_unmap_single(priv->pciDev, 2062 pci_unmap_single(
2059 list->buffer[0].address, skb->len, 2063 priv->pciDev,
2060 PCI_DMA_TODEVICE); 2064 list->buffer[0].address,
2065 max(skb->len,
2066 (unsigned int)TLAN_MIN_FRAME_SIZE),
2067 PCI_DMA_TODEVICE);
2061 dev_kfree_skb_any( skb ); 2068 dev_kfree_skb_any( skb );
2062 list->buffer[8].address = 0; 2069 list->buffer[8].address = 0;
2063 list->buffer[9].address = 0; 2070 list->buffer[9].address = 0;
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index cfd4d052d666..2d14255eb103 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -240,6 +240,10 @@ static u64 ath5k_get_tsf(struct ieee80211_hw *hw);
240static void ath5k_reset_tsf(struct ieee80211_hw *hw); 240static void ath5k_reset_tsf(struct ieee80211_hw *hw);
241static int ath5k_beacon_update(struct ieee80211_hw *hw, 241static int ath5k_beacon_update(struct ieee80211_hw *hw,
242 struct sk_buff *skb); 242 struct sk_buff *skb);
243static void ath5k_bss_info_changed(struct ieee80211_hw *hw,
244 struct ieee80211_vif *vif,
245 struct ieee80211_bss_conf *bss_conf,
246 u32 changes);
243 247
244static struct ieee80211_ops ath5k_hw_ops = { 248static struct ieee80211_ops ath5k_hw_ops = {
245 .tx = ath5k_tx, 249 .tx = ath5k_tx,
@@ -256,6 +260,7 @@ static struct ieee80211_ops ath5k_hw_ops = {
256 .get_tx_stats = ath5k_get_tx_stats, 260 .get_tx_stats = ath5k_get_tx_stats,
257 .get_tsf = ath5k_get_tsf, 261 .get_tsf = ath5k_get_tsf,
258 .reset_tsf = ath5k_reset_tsf, 262 .reset_tsf = ath5k_reset_tsf,
263 .bss_info_changed = ath5k_bss_info_changed,
259}; 264};
260 265
261/* 266/*
@@ -2942,7 +2947,7 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
2942 sc->opmode != NL80211_IFTYPE_MESH_POINT && 2947 sc->opmode != NL80211_IFTYPE_MESH_POINT &&
2943 test_bit(ATH_STAT_PROMISC, sc->status)) 2948 test_bit(ATH_STAT_PROMISC, sc->status))
2944 rfilt |= AR5K_RX_FILTER_PROM; 2949 rfilt |= AR5K_RX_FILTER_PROM;
2945 if (sc->opmode == NL80211_IFTYPE_STATION || 2950 if ((sc->opmode == NL80211_IFTYPE_STATION && sc->assoc) ||
2946 sc->opmode == NL80211_IFTYPE_ADHOC) { 2951 sc->opmode == NL80211_IFTYPE_ADHOC) {
2947 rfilt |= AR5K_RX_FILTER_BEACON; 2952 rfilt |= AR5K_RX_FILTER_BEACON;
2948 } 2953 }
@@ -3083,4 +3088,32 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
3083end: 3088end:
3084 return ret; 3089 return ret;
3085} 3090}
3091static void
3092set_beacon_filter(struct ieee80211_hw *hw, bool enable)
3093{
3094 struct ath5k_softc *sc = hw->priv;
3095 struct ath5k_hw *ah = sc->ah;
3096 u32 rfilt;
3097 rfilt = ath5k_hw_get_rx_filter(ah);
3098 if (enable)
3099 rfilt |= AR5K_RX_FILTER_BEACON;
3100 else
3101 rfilt &= ~AR5K_RX_FILTER_BEACON;
3102 ath5k_hw_set_rx_filter(ah, rfilt);
3103 sc->filter_flags = rfilt;
3104}
3086 3105
3106static void ath5k_bss_info_changed(struct ieee80211_hw *hw,
3107 struct ieee80211_vif *vif,
3108 struct ieee80211_bss_conf *bss_conf,
3109 u32 changes)
3110{
3111 struct ath5k_softc *sc = hw->priv;
3112 if (changes & BSS_CHANGED_ASSOC) {
3113 mutex_lock(&sc->lock);
3114 sc->assoc = bss_conf->assoc;
3115 if (sc->opmode == NL80211_IFTYPE_STATION)
3116 set_beacon_filter(hw, sc->assoc);
3117 mutex_unlock(&sc->lock);
3118 }
3119}
diff --git a/drivers/net/wireless/ath5k/base.h b/drivers/net/wireless/ath5k/base.h
index 06d1054ca94b..facc60ddada2 100644
--- a/drivers/net/wireless/ath5k/base.h
+++ b/drivers/net/wireless/ath5k/base.h
@@ -179,6 +179,7 @@ struct ath5k_softc {
179 179
180 struct timer_list calib_tim; /* calibration timer */ 180 struct timer_list calib_tim; /* calibration timer */
181 int power_level; /* Requested tx power in dbm */ 181 int power_level; /* Requested tx power in dbm */
182 bool assoc; /* assocate state */
182}; 183};
183 184
184#define ath5k_hw_hasbssidmask(_ah) \ 185#define ath5k_hw_hasbssidmask(_ah) \
diff --git a/drivers/net/wireless/ath5k/debug.c b/drivers/net/wireless/ath5k/debug.c
index 19980cbd5d5f..ccaeb5c219d2 100644
--- a/drivers/net/wireless/ath5k/debug.c
+++ b/drivers/net/wireless/ath5k/debug.c
@@ -417,19 +417,19 @@ ath5k_debug_init_device(struct ath5k_softc *sc)
417 sc->debug.debugfs_phydir = debugfs_create_dir(wiphy_name(sc->hw->wiphy), 417 sc->debug.debugfs_phydir = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
418 ath5k_global_debugfs); 418 ath5k_global_debugfs);
419 419
420 sc->debug.debugfs_debug = debugfs_create_file("debug", 0666, 420 sc->debug.debugfs_debug = debugfs_create_file("debug", S_IWUSR | S_IRUGO,
421 sc->debug.debugfs_phydir, sc, &fops_debug); 421 sc->debug.debugfs_phydir, sc, &fops_debug);
422 422
423 sc->debug.debugfs_registers = debugfs_create_file("registers", 0444, 423 sc->debug.debugfs_registers = debugfs_create_file("registers", S_IRUGO,
424 sc->debug.debugfs_phydir, sc, &fops_registers); 424 sc->debug.debugfs_phydir, sc, &fops_registers);
425 425
426 sc->debug.debugfs_tsf = debugfs_create_file("tsf", 0666, 426 sc->debug.debugfs_tsf = debugfs_create_file("tsf", S_IWUSR | S_IRUGO,
427 sc->debug.debugfs_phydir, sc, &fops_tsf); 427 sc->debug.debugfs_phydir, sc, &fops_tsf);
428 428
429 sc->debug.debugfs_beacon = debugfs_create_file("beacon", 0666, 429 sc->debug.debugfs_beacon = debugfs_create_file("beacon", S_IWUSR | S_IRUGO,
430 sc->debug.debugfs_phydir, sc, &fops_beacon); 430 sc->debug.debugfs_phydir, sc, &fops_beacon);
431 431
432 sc->debug.debugfs_reset = debugfs_create_file("reset", 0222, 432 sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
433 sc->debug.debugfs_phydir, sc, &fops_reset); 433 sc->debug.debugfs_phydir, sc, &fops_reset);
434} 434}
435 435
diff --git a/drivers/net/wireless/ath9k/beacon.c b/drivers/net/wireless/ath9k/beacon.c
index 9e15c30bbc06..4dd1c1bda0fb 100644
--- a/drivers/net/wireless/ath9k/beacon.c
+++ b/drivers/net/wireless/ath9k/beacon.c
@@ -170,7 +170,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
170 skb = (struct sk_buff *)bf->bf_mpdu; 170 skb = (struct sk_buff *)bf->bf_mpdu;
171 if (skb) { 171 if (skb) {
172 pci_unmap_single(sc->pdev, bf->bf_dmacontext, 172 pci_unmap_single(sc->pdev, bf->bf_dmacontext,
173 skb_end_pointer(skb) - skb->head, 173 skb->len,
174 PCI_DMA_TODEVICE); 174 PCI_DMA_TODEVICE);
175 } 175 }
176 176
@@ -193,7 +193,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
193 193
194 bf->bf_buf_addr = bf->bf_dmacontext = 194 bf->bf_buf_addr = bf->bf_dmacontext =
195 pci_map_single(sc->pdev, skb->data, 195 pci_map_single(sc->pdev, skb->data,
196 skb_end_pointer(skb) - skb->head, 196 skb->len,
197 PCI_DMA_TODEVICE); 197 PCI_DMA_TODEVICE);
198 198
199 skb = ieee80211_get_buffered_bc(sc->hw, avp->av_if_data); 199 skb = ieee80211_get_buffered_bc(sc->hw, avp->av_if_data);
@@ -352,7 +352,7 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
352 if (bf->bf_mpdu != NULL) { 352 if (bf->bf_mpdu != NULL) {
353 skb = (struct sk_buff *)bf->bf_mpdu; 353 skb = (struct sk_buff *)bf->bf_mpdu;
354 pci_unmap_single(sc->pdev, bf->bf_dmacontext, 354 pci_unmap_single(sc->pdev, bf->bf_dmacontext,
355 skb_end_pointer(skb) - skb->head, 355 skb->len,
356 PCI_DMA_TODEVICE); 356 PCI_DMA_TODEVICE);
357 dev_kfree_skb_any(skb); 357 dev_kfree_skb_any(skb);
358 bf->bf_mpdu = NULL; 358 bf->bf_mpdu = NULL;
@@ -412,7 +412,7 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
412 412
413 bf->bf_buf_addr = bf->bf_dmacontext = 413 bf->bf_buf_addr = bf->bf_dmacontext =
414 pci_map_single(sc->pdev, skb->data, 414 pci_map_single(sc->pdev, skb->data,
415 skb_end_pointer(skb) - skb->head, 415 skb->len,
416 PCI_DMA_TODEVICE); 416 PCI_DMA_TODEVICE);
417 bf->bf_mpdu = skb; 417 bf->bf_mpdu = skb;
418 418
@@ -439,7 +439,7 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
439 if (bf->bf_mpdu != NULL) { 439 if (bf->bf_mpdu != NULL) {
440 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu; 440 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
441 pci_unmap_single(sc->pdev, bf->bf_dmacontext, 441 pci_unmap_single(sc->pdev, bf->bf_dmacontext,
442 skb_end_pointer(skb) - skb->head, 442 skb->len,
443 PCI_DMA_TODEVICE); 443 PCI_DMA_TODEVICE);
444 dev_kfree_skb_any(skb); 444 dev_kfree_skb_any(skb);
445 bf->bf_mpdu = NULL; 445 bf->bf_mpdu = NULL;
diff --git a/drivers/net/wireless/ath9k/recv.c b/drivers/net/wireless/ath9k/recv.c
index 4983402af559..504a0444d89f 100644
--- a/drivers/net/wireless/ath9k/recv.c
+++ b/drivers/net/wireless/ath9k/recv.c
@@ -49,10 +49,12 @@ static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
49 ASSERT(skb != NULL); 49 ASSERT(skb != NULL);
50 ds->ds_vdata = skb->data; 50 ds->ds_vdata = skb->data;
51 51
52 /* setup rx descriptors */ 52 /* setup rx descriptors. The sc_rxbufsize here tells the harware
53 * how much data it can DMA to us and that we are prepared
54 * to process */
53 ath9k_hw_setuprxdesc(ah, 55 ath9k_hw_setuprxdesc(ah,
54 ds, 56 ds,
55 skb_tailroom(skb), /* buffer size */ 57 sc->sc_rxbufsize,
56 0); 58 0);
57 59
58 if (sc->sc_rxlink == NULL) 60 if (sc->sc_rxlink == NULL)
@@ -398,6 +400,13 @@ static struct sk_buff *ath_rxbuf_alloc(struct ath_softc *sc,
398 * in rx'd frames. 400 * in rx'd frames.
399 */ 401 */
400 402
403 /* Note: the kernel can allocate a value greater than
404 * what we ask it to give us. We really only need 4 KB as that
405 * is this hardware supports and in fact we need at least 3849
406 * as that is the MAX AMSDU size this hardware supports.
407 * Unfortunately this means we may get 8 KB here from the
408 * kernel... and that is actually what is observed on some
409 * systems :( */
401 skb = dev_alloc_skb(len + sc->sc_cachelsz - 1); 410 skb = dev_alloc_skb(len + sc->sc_cachelsz - 1);
402 if (skb != NULL) { 411 if (skb != NULL) {
403 off = ((unsigned long) skb->data) % sc->sc_cachelsz; 412 off = ((unsigned long) skb->data) % sc->sc_cachelsz;
@@ -456,7 +465,7 @@ static int ath_rx_indicate(struct ath_softc *sc,
456 if (nskb != NULL) { 465 if (nskb != NULL) {
457 bf->bf_mpdu = nskb; 466 bf->bf_mpdu = nskb;
458 bf->bf_buf_addr = pci_map_single(sc->pdev, nskb->data, 467 bf->bf_buf_addr = pci_map_single(sc->pdev, nskb->data,
459 skb_end_pointer(nskb) - nskb->head, 468 sc->sc_rxbufsize,
460 PCI_DMA_FROMDEVICE); 469 PCI_DMA_FROMDEVICE);
461 bf->bf_dmacontext = bf->bf_buf_addr; 470 bf->bf_dmacontext = bf->bf_buf_addr;
462 ATH_RX_CONTEXT(nskb)->ctx_rxbuf = bf; 471 ATH_RX_CONTEXT(nskb)->ctx_rxbuf = bf;
@@ -542,7 +551,7 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
542 551
543 bf->bf_mpdu = skb; 552 bf->bf_mpdu = skb;
544 bf->bf_buf_addr = pci_map_single(sc->pdev, skb->data, 553 bf->bf_buf_addr = pci_map_single(sc->pdev, skb->data,
545 skb_end_pointer(skb) - skb->head, 554 sc->sc_rxbufsize,
546 PCI_DMA_FROMDEVICE); 555 PCI_DMA_FROMDEVICE);
547 bf->bf_dmacontext = bf->bf_buf_addr; 556 bf->bf_dmacontext = bf->bf_buf_addr;
548 ATH_RX_CONTEXT(skb)->ctx_rxbuf = bf; 557 ATH_RX_CONTEXT(skb)->ctx_rxbuf = bf;
@@ -1007,7 +1016,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
1007 1016
1008 pci_dma_sync_single_for_cpu(sc->pdev, 1017 pci_dma_sync_single_for_cpu(sc->pdev,
1009 bf->bf_buf_addr, 1018 bf->bf_buf_addr,
1010 skb_tailroom(skb), 1019 sc->sc_rxbufsize,
1011 PCI_DMA_FROMDEVICE); 1020 PCI_DMA_FROMDEVICE);
1012 pci_unmap_single(sc->pdev, 1021 pci_unmap_single(sc->pdev,
1013 bf->bf_buf_addr, 1022 bf->bf_buf_addr,
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index dcce3542d5a7..7a9f901d4ff6 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -3897,6 +3897,7 @@ static int ipw_disassociate(void *data)
3897 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) 3897 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)))
3898 return 0; 3898 return 0;
3899 ipw_send_disassociate(data, 0); 3899 ipw_send_disassociate(data, 0);
3900 netif_carrier_off(priv->net_dev);
3900 return 1; 3901 return 1;
3901} 3902}
3902 3903
@@ -10190,6 +10191,9 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
10190 u16 remaining_bytes; 10191 u16 remaining_bytes;
10191 int fc; 10192 int fc;
10192 10193
10194 if (!(priv->status & STATUS_ASSOCIATED))
10195 goto drop;
10196
10193 hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 10197 hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
10194 switch (priv->ieee->iw_mode) { 10198 switch (priv->ieee->iw_mode) {
10195 case IW_MODE_ADHOC: 10199 case IW_MODE_ADHOC:
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 444c5cc05f03..c4c0371c763b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1384,9 +1384,11 @@ void iwl_rx_handle(struct iwl_priv *priv)
1384 1384
1385 rxq->queue[i] = NULL; 1385 rxq->queue[i] = NULL;
1386 1386
1387 pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->aligned_dma_addr, 1387 dma_sync_single_range_for_cpu(
1388 priv->hw_params.rx_buf_size, 1388 &priv->pci_dev->dev, rxb->real_dma_addr,
1389 PCI_DMA_FROMDEVICE); 1389 rxb->aligned_dma_addr - rxb->real_dma_addr,
1390 priv->hw_params.rx_buf_size,
1391 PCI_DMA_FROMDEVICE);
1390 pkt = (struct iwl_rx_packet *)rxb->skb->data; 1392 pkt = (struct iwl_rx_packet *)rxb->skb->data;
1391 1393
1392 /* Reclaim a command buffer only if this packet is a response 1394 /* Reclaim a command buffer only if this packet is a response
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 4c312c55f90c..01a845851338 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -290,6 +290,9 @@ void iwl_clear_stations_table(struct iwl_priv *priv)
290 priv->num_stations = 0; 290 priv->num_stations = 0;
291 memset(priv->stations, 0, sizeof(priv->stations)); 291 memset(priv->stations, 0, sizeof(priv->stations));
292 292
293 /* clean ucode key table bit map */
294 priv->ucode_key_table = 0;
295
293 spin_unlock_irqrestore(&priv->sta_lock, flags); 296 spin_unlock_irqrestore(&priv->sta_lock, flags);
294} 297}
295EXPORT_SYMBOL(iwl_clear_stations_table); 298EXPORT_SYMBOL(iwl_clear_stations_table);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 61797f3f8d5c..26f7084d3011 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -475,7 +475,7 @@ static int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
475 if (!test_and_set_bit(i, &priv->ucode_key_table)) 475 if (!test_and_set_bit(i, &priv->ucode_key_table))
476 return i; 476 return i;
477 477
478 return -1; 478 return WEP_INVALID_OFFSET;
479} 479}
480 480
481int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty) 481int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
@@ -620,6 +620,9 @@ static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
620 /* else, we are overriding an existing key => no need to allocated room 620 /* else, we are overriding an existing key => no need to allocated room
621 * in uCode. */ 621 * in uCode. */
622 622
623 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
624 "no space for new kew");
625
623 priv->stations[sta_id].sta.key.key_flags = key_flags; 626 priv->stations[sta_id].sta.key.key_flags = key_flags;
624 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; 627 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
625 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 628 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
@@ -637,6 +640,7 @@ static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
637{ 640{
638 unsigned long flags; 641 unsigned long flags;
639 __le16 key_flags = 0; 642 __le16 key_flags = 0;
643 int ret;
640 644
641 key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); 645 key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK);
642 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); 646 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
@@ -664,14 +668,18 @@ static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
664 /* else, we are overriding an existing key => no need to allocated room 668 /* else, we are overriding an existing key => no need to allocated room
665 * in uCode. */ 669 * in uCode. */
666 670
671 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
672 "no space for new kew");
673
667 priv->stations[sta_id].sta.key.key_flags = key_flags; 674 priv->stations[sta_id].sta.key.key_flags = key_flags;
668 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; 675 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
669 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 676 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
670 677
678 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
679
671 spin_unlock_irqrestore(&priv->sta_lock, flags); 680 spin_unlock_irqrestore(&priv->sta_lock, flags);
672 681
673 IWL_DEBUG_INFO("hwcrypto: modify ucode station key info\n"); 682 return ret;
674 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
675} 683}
676 684
677static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv, 685static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
@@ -696,6 +704,9 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
696 /* else, we are overriding an existing key => no need to allocated room 704 /* else, we are overriding an existing key => no need to allocated room
697 * in uCode. */ 705 * in uCode. */
698 706
707 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
708 "no space for new kew");
709
699 /* This copy is acutally not needed: we get the key with each TX */ 710 /* This copy is acutally not needed: we get the key with each TX */
700 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16); 711 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16);
701 712
@@ -734,6 +745,13 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
734 return 0; 745 return 0;
735 } 746 }
736 747
748 if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) {
749 IWL_WARNING("Removing wrong key %d 0x%x\n",
750 keyconf->keyidx, key_flags);
751 spin_unlock_irqrestore(&priv->sta_lock, flags);
752 return 0;
753 }
754
737 if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset, 755 if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset,
738 &priv->ucode_key_table)) 756 &priv->ucode_key_table))
739 IWL_ERROR("index %d not used in uCode key table.\n", 757 IWL_ERROR("index %d not used in uCode key table.\n",
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index fe1867b25ff7..cac732f4047f 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -615,7 +615,7 @@ static int filter_ack(struct ieee80211_hw *hw, struct ieee80211_hdr *rx_hdr,
615 struct ieee80211_hdr *tx_hdr; 615 struct ieee80211_hdr *tx_hdr;
616 616
617 tx_hdr = (struct ieee80211_hdr *)skb->data; 617 tx_hdr = (struct ieee80211_hdr *)skb->data;
618 if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1))) 618 if (likely(!memcmp(tx_hdr->addr2, rx_hdr->addr1, ETH_ALEN)))
619 { 619 {
620 __skb_unlink(skb, q); 620 __skb_unlink(skb, q);
621 tx_status(hw, skb, IEEE80211_TX_STAT_ACK, stats->signal, 1); 621 tx_status(hw, skb, IEEE80211_TX_STAT_ACK, stats->signal, 1);
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index c6948d8f53f6..6d017adc914a 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1785,7 +1785,7 @@ static int __devexit xennet_remove(struct xenbus_device *dev)
1785 return 0; 1785 return 0;
1786} 1786}
1787 1787
1788static struct xenbus_driver netfront = { 1788static struct xenbus_driver netfront_driver = {
1789 .name = "vif", 1789 .name = "vif",
1790 .owner = THIS_MODULE, 1790 .owner = THIS_MODULE,
1791 .ids = netfront_ids, 1791 .ids = netfront_ids,
@@ -1805,7 +1805,7 @@ static int __init netif_init(void)
1805 1805
1806 printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n"); 1806 printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n");
1807 1807
1808 return xenbus_register_frontend(&netfront); 1808 return xenbus_register_frontend(&netfront_driver);
1809} 1809}
1810module_init(netif_init); 1810module_init(netif_init);
1811 1811
@@ -1815,7 +1815,7 @@ static void __exit netif_exit(void)
1815 if (xen_initial_domain()) 1815 if (xen_initial_domain())
1816 return; 1816 return;
1817 1817
1818 xenbus_unregister_driver(&netfront); 1818 xenbus_unregister_driver(&netfront_driver);
1819} 1819}
1820module_exit(netif_exit); 1820module_exit(netif_exit);
1821 1821
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index e2e95b36a603..101ed49a2d15 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -70,6 +70,8 @@ static int __devinit netmos_parallel_init(struct pci_dev *dev, struct parport_pc
70 * parallel ports and <S> is the number of serial ports. 70 * parallel ports and <S> is the number of serial ports.
71 */ 71 */
72 card->numports = (dev->subsystem_device & 0xf0) >> 4; 72 card->numports = (dev->subsystem_device & 0xf0) >> 4;
73 if (card->numports > ARRAY_SIZE(card->addr))
74 card->numports = ARRAY_SIZE(card->addr);
73 return 0; 75 return 0;
74} 76}
75 77
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index f9e244da30ae..9bcb6cbd5aa9 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -113,7 +113,7 @@ struct acpiphp_slot {
113 113
114 u8 device; /* pci device# */ 114 u8 device; /* pci device# */
115 115
116 u32 sun; /* ACPI _SUN (slot unique number) */ 116 unsigned long long sun; /* ACPI _SUN (slot unique number) */
117 u32 flags; /* see below */ 117 u32 flags; /* see below */
118}; 118};
119 119
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 95b536a23d25..43c10bd261b4 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -337,7 +337,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
337 slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; 337 slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
338 338
339 acpiphp_slot->slot = slot; 339 acpiphp_slot->slot = slot;
340 snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun); 340 snprintf(name, SLOT_NAME_SIZE, "%llu", slot->acpi_slot->sun);
341 341
342 retval = pci_hp_register(slot->hotplug_slot, 342 retval = pci_hp_register(slot->hotplug_slot,
343 acpiphp_slot->bridge->pci_bus, 343 acpiphp_slot->bridge->pci_bus,
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 955aae4071f7..3affc6472e65 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -255,13 +255,13 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
255 255
256 bridge->nr_slots++; 256 bridge->nr_slots++;
257 257
258 dbg("found ACPI PCI Hotplug slot %d at PCI %04x:%02x:%02x\n", 258 dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
259 slot->sun, pci_domain_nr(bridge->pci_bus), 259 slot->sun, pci_domain_nr(bridge->pci_bus),
260 bridge->pci_bus->number, slot->device); 260 bridge->pci_bus->number, slot->device);
261 retval = acpiphp_register_hotplug_slot(slot); 261 retval = acpiphp_register_hotplug_slot(slot);
262 if (retval) { 262 if (retval) {
263 if (retval == -EBUSY) 263 if (retval == -EBUSY)
264 warn("Slot %d already registered by another " 264 warn("Slot %llu already registered by another "
265 "hotplug driver\n", slot->sun); 265 "hotplug driver\n", slot->sun);
266 else 266 else
267 warn("acpiphp_register_hotplug_slot failed " 267 warn("acpiphp_register_hotplug_slot failed "
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index c892daae74d6..633e743442ac 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -1402,10 +1402,6 @@ static int __init ibmphp_init(void)
1402 goto error; 1402 goto error;
1403 } 1403 }
1404 1404
1405 /* lock ourselves into memory with a module
1406 * count of -1 so that no one can unload us. */
1407 module_put(THIS_MODULE);
1408
1409exit: 1405exit:
1410 return rc; 1406 return rc;
1411 1407
@@ -1423,4 +1419,3 @@ static void __exit ibmphp_exit(void)
1423} 1419}
1424 1420
1425module_init(ibmphp_init); 1421module_init(ibmphp_init);
1426module_exit(ibmphp_exit);
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 4b23bc39b11e..39cf248d24e3 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -432,18 +432,19 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
432 goto err_out_release_ctlr; 432 goto err_out_release_ctlr;
433 } 433 }
434 434
435 /* Check if slot is occupied */
435 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset); 436 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset);
436 437 t_slot->hpc_ops->get_adapter_status(t_slot, &value);
437 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ 438 if (value) {
438 if (value && pciehp_force) { 439 if (pciehp_force)
439 rc = pciehp_enable_slot(t_slot); 440 pciehp_enable_slot(t_slot);
440 if (rc) /* -ENODEV: shouldn't happen, but deal with it */ 441 } else {
441 value = 0; 442 /* Power off slot if not occupied */
442 } 443 if (POWER_CTRL(ctrl)) {
443 if ((POWER_CTRL(ctrl)) && !value) { 444 rc = t_slot->hpc_ops->power_off_slot(t_slot);
444 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ 445 if (rc)
445 if (rc) 446 goto err_out_free_ctrl_slot;
446 goto err_out_free_ctrl_slot; 447 }
447 } 448 }
448 449
449 return 0; 450 return 0;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 28af496b441e..061d1ee0046a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2042,7 +2042,7 @@ static int __devinit pci_init(void)
2042 return 0; 2042 return 0;
2043} 2043}
2044 2044
2045static int __devinit pci_setup(char *str) 2045static int __init pci_setup(char *str)
2046{ 2046{
2047 while (str) { 2047 while (str) {
2048 char *k = strchr(str, ','); 2048 char *k = strchr(str, ',');
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index dfc63d01f20a..aac7006949f1 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -252,7 +252,7 @@ static void report_resume(struct pci_dev *dev, void *data)
252 252
253 if (!dev->driver || 253 if (!dev->driver ||
254 !dev->driver->err_handler || 254 !dev->driver->err_handler ||
255 !dev->driver->err_handler->slot_reset) 255 !dev->driver->err_handler->resume)
256 return; 256 return;
257 257
258 err_handler = dev->driver->err_handler; 258 err_handler = dev->driver->err_handler;
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 8f63f4c6b85f..9aad608bcf3f 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -16,6 +16,7 @@
16#include <linux/pm.h> 16#include <linux/pm.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/jiffies.h>
19#include <linux/pci-aspm.h> 20#include <linux/pci-aspm.h>
20#include "../pci.h" 21#include "../pci.h"
21 22
@@ -161,11 +162,12 @@ static void pcie_check_clock_pm(struct pci_dev *pdev)
161 */ 162 */
162static void pcie_aspm_configure_common_clock(struct pci_dev *pdev) 163static void pcie_aspm_configure_common_clock(struct pci_dev *pdev)
163{ 164{
164 int pos, child_pos; 165 int pos, child_pos, i = 0;
165 u16 reg16 = 0; 166 u16 reg16 = 0;
166 struct pci_dev *child_dev; 167 struct pci_dev *child_dev;
167 int same_clock = 1; 168 int same_clock = 1;
168 169 unsigned long start_jiffies;
170 u16 child_regs[8], parent_reg;
169 /* 171 /*
170 * all functions of a slot should have the same Slot Clock 172 * all functions of a slot should have the same Slot Clock
171 * Configuration, so just check one function 173 * Configuration, so just check one function
@@ -191,16 +193,19 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev)
191 child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP); 193 child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP);
192 pci_read_config_word(child_dev, child_pos + PCI_EXP_LNKCTL, 194 pci_read_config_word(child_dev, child_pos + PCI_EXP_LNKCTL,
193 &reg16); 195 &reg16);
196 child_regs[i] = reg16;
194 if (same_clock) 197 if (same_clock)
195 reg16 |= PCI_EXP_LNKCTL_CCC; 198 reg16 |= PCI_EXP_LNKCTL_CCC;
196 else 199 else
197 reg16 &= ~PCI_EXP_LNKCTL_CCC; 200 reg16 &= ~PCI_EXP_LNKCTL_CCC;
198 pci_write_config_word(child_dev, child_pos + PCI_EXP_LNKCTL, 201 pci_write_config_word(child_dev, child_pos + PCI_EXP_LNKCTL,
199 reg16); 202 reg16);
203 i++;
200 } 204 }
201 205
202 /* Configure upstream component */ 206 /* Configure upstream component */
203 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16); 207 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
208 parent_reg = reg16;
204 if (same_clock) 209 if (same_clock)
205 reg16 |= PCI_EXP_LNKCTL_CCC; 210 reg16 |= PCI_EXP_LNKCTL_CCC;
206 else 211 else
@@ -212,12 +217,30 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev)
212 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); 217 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
213 218
214 /* Wait for link training end */ 219 /* Wait for link training end */
215 while (1) { 220 /* break out after waiting for 1 second */
221 start_jiffies = jiffies;
222 while ((jiffies - start_jiffies) < HZ) {
216 pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, &reg16); 223 pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, &reg16);
217 if (!(reg16 & PCI_EXP_LNKSTA_LT)) 224 if (!(reg16 & PCI_EXP_LNKSTA_LT))
218 break; 225 break;
219 cpu_relax(); 226 cpu_relax();
220 } 227 }
228 /* training failed -> recover */
229 if ((jiffies - start_jiffies) >= HZ) {
230 dev_printk (KERN_ERR, &pdev->dev, "ASPM: Could not configure"
231 " common clock\n");
232 i = 0;
233 list_for_each_entry(child_dev, &pdev->subordinate->devices,
234 bus_list) {
235 child_pos = pci_find_capability(child_dev,
236 PCI_CAP_ID_EXP);
237 pci_write_config_word(child_dev,
238 child_pos + PCI_EXP_LNKCTL,
239 child_regs[i]);
240 i++;
241 }
242 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, parent_reg);
243 }
221} 244}
222 245
223/* 246/*
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 5049a47030ac..5f4f85f56cb7 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -22,6 +22,7 @@
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/acpi.h> 23#include <linux/acpi.h>
24#include <linux/kallsyms.h> 24#include <linux/kallsyms.h>
25#include <linux/dmi.h>
25#include "pci.h" 26#include "pci.h"
26 27
27int isa_dma_bridge_buggy; 28int isa_dma_bridge_buggy;
@@ -1828,6 +1829,22 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SERVERWORKS,
1828 PCI_DEVICE_ID_SERVERWORKS_HT1000_PXB, 1829 PCI_DEVICE_ID_SERVERWORKS_HT1000_PXB,
1829 ht_enable_msi_mapping); 1830 ht_enable_msi_mapping);
1830 1831
1832/* The P5N32-SLI Premium motherboard from Asus has a problem with msi
1833 * for the MCP55 NIC. It is not yet determined whether the msi problem
1834 * also affects other devices. As for now, turn off msi for this device.
1835 */
1836static void __devinit nvenet_msi_disable(struct pci_dev *dev)
1837{
1838 if (dmi_name_in_vendors("P5N32-SLI PREMIUM")) {
1839 dev_info(&dev->dev,
1840 "Disabling msi for MCP55 NIC on P5N32-SLI Premium\n");
1841 dev->no_msi = 1;
1842 }
1843}
1844DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA,
1845 PCI_DEVICE_ID_NVIDIA_NVENET_15,
1846 nvenet_msi_disable);
1847
1831static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev) 1848static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev)
1832{ 1849{
1833 struct pci_dev *host_bridge; 1850 struct pci_dev *host_bridge;
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 4dd1c3e157ae..5a8ccb4f604d 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -253,6 +253,7 @@ placeholder:
253 __func__, pci_domain_nr(parent), parent->number, slot_nr); 253 __func__, pci_domain_nr(parent), parent->number, slot_nr);
254 254
255out: 255out:
256 kfree(slot_name);
256 up_write(&pci_bus_sem); 257 up_write(&pci_bus_sem);
257 return slot; 258 return slot;
258err: 259err:
diff --git a/drivers/pcmcia/bfin_cf_pcmcia.c b/drivers/pcmcia/bfin_cf_pcmcia.c
index bb7338863fb9..b59d4115d20f 100644
--- a/drivers/pcmcia/bfin_cf_pcmcia.c
+++ b/drivers/pcmcia/bfin_cf_pcmcia.c
@@ -334,6 +334,6 @@ static void __exit bfin_cf_exit(void)
334module_init(bfin_cf_init); 334module_init(bfin_cf_init);
335module_exit(bfin_cf_exit); 335module_exit(bfin_cf_exit);
336 336
337MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>") 337MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
338MODULE_DESCRIPTION("BFIN CF/PCMCIA Driver"); 338MODULE_DESCRIPTION("BFIN CF/PCMCIA Driver");
339MODULE_LICENSE("GPL"); 339MODULE_LICENSE("GPL");
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index a926c896475e..643a6b98462b 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -879,7 +879,7 @@ static void rio_update_route_tables(struct rio_mport *port)
879 * link, then start recursive peer enumeration. Returns %0 if 879 * link, then start recursive peer enumeration. Returns %0 if
880 * enumeration succeeds or %-EBUSY if enumeration fails. 880 * enumeration succeeds or %-EBUSY if enumeration fails.
881 */ 881 */
882int rio_enum_mport(struct rio_mport *mport) 882int __devinit rio_enum_mport(struct rio_mport *mport)
883{ 883{
884 struct rio_net *net = NULL; 884 struct rio_net *net = NULL;
885 int rc = 0; 885 int rc = 0;
@@ -972,7 +972,7 @@ static void rio_enum_timeout(unsigned long data)
972 * peer discovery. Returns %0 if discovery succeeds or %-EBUSY 972 * peer discovery. Returns %0 if discovery succeeds or %-EBUSY
973 * on failure. 973 * on failure.
974 */ 974 */
975int rio_disc_mport(struct rio_mport *mport) 975int __devinit rio_disc_mport(struct rio_mport *mport)
976{ 976{
977 struct rio_net *net = NULL; 977 struct rio_net *net = NULL;
978 int enum_timeout_flag = 0; 978 int enum_timeout_flag = 0;
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index 680661abbc4b..6395c780008b 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -467,7 +467,7 @@ static int __devinit rio_init(void)
467 467
468device_initcall(rio_init); 468device_initcall(rio_init);
469 469
470int rio_init_mports(void) 470int __devinit rio_init_mports(void)
471{ 471{
472 int rc = 0; 472 int rc = 0;
473 struct rio_mport *port; 473 struct rio_mport *port;
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 341d7a5b45a2..4e91419e8911 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -209,12 +209,18 @@ static int ds1672_probe(struct i2c_client *client,
209 return err; 209 return err;
210} 210}
211 211
212static struct i2c_device_id ds1672_id[] = {
213 { "ds1672", 0 },
214 { }
215};
216
212static struct i2c_driver ds1672_driver = { 217static struct i2c_driver ds1672_driver = {
213 .driver = { 218 .driver = {
214 .name = "rtc-ds1672", 219 .name = "rtc-ds1672",
215 }, 220 },
216 .probe = &ds1672_probe, 221 .probe = &ds1672_probe,
217 .remove = &ds1672_remove, 222 .remove = &ds1672_remove,
223 .id_table = ds1672_id,
218}; 224};
219 225
220static int __init ds1672_init(void) 226static int __init ds1672_init(void)
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 2cd77ab8fc66..054e05294af8 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -328,6 +328,13 @@ isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm)
328 int sr; 328 int sr;
329 u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; 329 u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
330 330
331 /* The clock has an 8 bit wide bcd-coded register (they never learn)
332 * for the year. tm_year is an offset from 1900 and we are interested
333 * in the 2000-2099 range, so any value less than 100 is invalid.
334 */
335 if (tm->tm_year < 100)
336 return -EINVAL;
337
331 regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec); 338 regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec);
332 regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min); 339 regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min);
333 regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL; 340 regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL;
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c
index 80782798763f..a4f6665ab3c5 100644
--- a/drivers/rtc/rtc-max6900.c
+++ b/drivers/rtc/rtc-max6900.c
@@ -247,12 +247,18 @@ max6900_probe(struct i2c_client *client, const struct i2c_device_id *id)
247 return 0; 247 return 0;
248} 248}
249 249
250static struct i2c_device_id max6900_id[] = {
251 { "max6900", 0 },
252 { }
253};
254
250static struct i2c_driver max6900_driver = { 255static struct i2c_driver max6900_driver = {
251 .driver = { 256 .driver = {
252 .name = "rtc-max6900", 257 .name = "rtc-max6900",
253 }, 258 },
254 .probe = max6900_probe, 259 .probe = max6900_probe,
255 .remove = max6900_remove, 260 .remove = max6900_remove,
261 .id_table = max6900_id,
256}; 262};
257 263
258static int __init max6900_init(void) 264static int __init max6900_init(void)
diff --git a/drivers/rtc/rtc-starfire.c b/drivers/rtc/rtc-starfire.c
index 7ccb0dd700af..5be98bfd7ed3 100644
--- a/drivers/rtc/rtc-starfire.c
+++ b/drivers/rtc/rtc-starfire.c
@@ -6,7 +6,6 @@
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/time.h>
10#include <linux/rtc.h> 9#include <linux/rtc.h>
11#include <linux/platform_device.h> 10#include <linux/platform_device.h>
12 11
@@ -16,11 +15,6 @@ MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
16MODULE_DESCRIPTION("Starfire RTC driver"); 15MODULE_DESCRIPTION("Starfire RTC driver");
17MODULE_LICENSE("GPL"); 16MODULE_LICENSE("GPL");
18 17
19struct starfire_rtc {
20 struct rtc_device *rtc;
21 spinlock_t lock;
22};
23
24static u32 starfire_get_time(void) 18static u32 starfire_get_time(void)
25{ 19{
26 static char obp_gettod[32]; 20 static char obp_gettod[32];
@@ -35,64 +29,31 @@ static u32 starfire_get_time(void)
35 29
36static int starfire_read_time(struct device *dev, struct rtc_time *tm) 30static int starfire_read_time(struct device *dev, struct rtc_time *tm)
37{ 31{
38 struct starfire_rtc *p = dev_get_drvdata(dev); 32 rtc_time_to_tm(starfire_get_time(), tm);
39 unsigned long flags, secs; 33 return rtc_valid_tm(tm);
40
41 spin_lock_irqsave(&p->lock, flags);
42 secs = starfire_get_time();
43 spin_unlock_irqrestore(&p->lock, flags);
44
45 rtc_time_to_tm(secs, tm);
46
47 return 0;
48}
49
50static int starfire_set_time(struct device *dev, struct rtc_time *tm)
51{
52 unsigned long secs;
53 int err;
54
55 err = rtc_tm_to_time(tm, &secs);
56 if (err)
57 return err;
58
59 /* Do nothing, time is set using the service processor
60 * console on this platform.
61 */
62 return 0;
63} 34}
64 35
65static const struct rtc_class_ops starfire_rtc_ops = { 36static const struct rtc_class_ops starfire_rtc_ops = {
66 .read_time = starfire_read_time, 37 .read_time = starfire_read_time,
67 .set_time = starfire_set_time,
68}; 38};
69 39
70static int __devinit starfire_rtc_probe(struct platform_device *pdev) 40static int __init starfire_rtc_probe(struct platform_device *pdev)
71{ 41{
72 struct starfire_rtc *p = kzalloc(sizeof(*p), GFP_KERNEL); 42 struct rtc_device *rtc = rtc_device_register("starfire", &pdev->dev,
73 43 &starfire_rtc_ops, THIS_MODULE);
74 if (!p) 44 if (IS_ERR(rtc))
75 return -ENOMEM; 45 return PTR_ERR(rtc);
76 46
77 spin_lock_init(&p->lock); 47 platform_set_drvdata(pdev, rtc);
78 48
79 p->rtc = rtc_device_register("starfire", &pdev->dev,
80 &starfire_rtc_ops, THIS_MODULE);
81 if (IS_ERR(p->rtc)) {
82 int err = PTR_ERR(p->rtc);
83 kfree(p);
84 return err;
85 }
86 platform_set_drvdata(pdev, p);
87 return 0; 49 return 0;
88} 50}
89 51
90static int __devexit starfire_rtc_remove(struct platform_device *pdev) 52static int __exit starfire_rtc_remove(struct platform_device *pdev)
91{ 53{
92 struct starfire_rtc *p = platform_get_drvdata(pdev); 54 struct rtc_device *rtc = platform_get_drvdata(pdev);
93 55
94 rtc_device_unregister(p->rtc); 56 rtc_device_unregister(rtc);
95 kfree(p);
96 57
97 return 0; 58 return 0;
98} 59}
@@ -102,13 +63,12 @@ static struct platform_driver starfire_rtc_driver = {
102 .name = "rtc-starfire", 63 .name = "rtc-starfire",
103 .owner = THIS_MODULE, 64 .owner = THIS_MODULE,
104 }, 65 },
105 .probe = starfire_rtc_probe, 66 .remove = __exit_p(starfire_rtc_remove),
106 .remove = __devexit_p(starfire_rtc_remove),
107}; 67};
108 68
109static int __init starfire_rtc_init(void) 69static int __init starfire_rtc_init(void)
110{ 70{
111 return platform_driver_register(&starfire_rtc_driver); 71 return platform_driver_probe(&starfire_rtc_driver, starfire_rtc_probe);
112} 72}
113 73
114static void __exit starfire_rtc_exit(void) 74static void __exit starfire_rtc_exit(void)
diff --git a/drivers/rtc/rtc-twl4030.c b/drivers/rtc/rtc-twl4030.c
index abe87a4d2665..01d8da9afdc8 100644
--- a/drivers/rtc/rtc-twl4030.c
+++ b/drivers/rtc/rtc-twl4030.c
@@ -337,7 +337,7 @@ static int twl4030_rtc_ioctl(struct device *dev, unsigned int cmd,
337} 337}
338 338
339#else 339#else
340#define omap_rtc_ioctl NULL 340#define twl4030_rtc_ioctl NULL
341#endif 341#endif
342 342
343static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc) 343static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc)
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 35364f64da7f..c557ba34e1aa 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -720,7 +720,6 @@ static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *act,
720 goto failed_openfcp; 720 goto failed_openfcp;
721 721
722 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &act->adapter->status); 722 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &act->adapter->status);
723 schedule_work(&act->adapter->scan_work);
724 723
725 return ZFCP_ERP_SUCCEEDED; 724 return ZFCP_ERP_SUCCEEDED;
726 725
@@ -1186,7 +1185,9 @@ static void zfcp_erp_scsi_scan(struct work_struct *work)
1186 container_of(work, struct zfcp_erp_add_work, work); 1185 container_of(work, struct zfcp_erp_add_work, work);
1187 struct zfcp_unit *unit = p->unit; 1186 struct zfcp_unit *unit = p->unit;
1188 struct fc_rport *rport = unit->port->rport; 1187 struct fc_rport *rport = unit->port->rport;
1189 scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, 1188
1189 if (rport && rport->port_state == FC_PORTSTATE_ONLINE)
1190 scsi_scan_target(&rport->dev, 0, rport->scsi_target_id,
1190 scsilun_to_int((struct scsi_lun *)&unit->fcp_lun), 0); 1191 scsilun_to_int((struct scsi_lun *)&unit->fcp_lun), 0);
1191 atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status); 1192 atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);
1192 zfcp_unit_put(unit); 1193 zfcp_unit_put(unit);
@@ -1282,6 +1283,8 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
1282 case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 1283 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1283 if (result != ZFCP_ERP_SUCCEEDED) 1284 if (result != ZFCP_ERP_SUCCEEDED)
1284 zfcp_erp_rports_del(adapter); 1285 zfcp_erp_rports_del(adapter);
1286 else
1287 schedule_work(&adapter->scan_work);
1285 zfcp_adapter_put(adapter); 1288 zfcp_adapter_put(adapter);
1286 break; 1289 break;
1287 } 1290 }
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index 1a7c80a77ff5..8aab3091a7b1 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -50,7 +50,8 @@ static int zfcp_wka_port_get(struct zfcp_wka_port *wka_port)
50 if (mutex_lock_interruptible(&wka_port->mutex)) 50 if (mutex_lock_interruptible(&wka_port->mutex))
51 return -ERESTARTSYS; 51 return -ERESTARTSYS;
52 52
53 if (wka_port->status != ZFCP_WKA_PORT_ONLINE) { 53 if (wka_port->status == ZFCP_WKA_PORT_OFFLINE ||
54 wka_port->status == ZFCP_WKA_PORT_CLOSING) {
54 wka_port->status = ZFCP_WKA_PORT_OPENING; 55 wka_port->status = ZFCP_WKA_PORT_OPENING;
55 if (zfcp_fsf_open_wka_port(wka_port)) 56 if (zfcp_fsf_open_wka_port(wka_port))
56 wka_port->status = ZFCP_WKA_PORT_OFFLINE; 57 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
@@ -125,8 +126,7 @@ static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range,
125 126
126 read_lock_irqsave(&zfcp_data.config_lock, flags); 127 read_lock_irqsave(&zfcp_data.config_lock, flags);
127 list_for_each_entry(port, &fsf_req->adapter->port_list_head, list) { 128 list_for_each_entry(port, &fsf_req->adapter->port_list_head, list) {
128 /* FIXME: ZFCP_STATUS_PORT_DID_DID check is racy */ 129 if (!(atomic_read(&port->status) & ZFCP_STATUS_PORT_PHYS_OPEN))
129 if (!(atomic_read(&port->status) & ZFCP_STATUS_PORT_DID_DID))
130 /* Try to connect to unused ports anyway. */ 130 /* Try to connect to unused ports anyway. */
131 zfcp_erp_port_reopen(port, 131 zfcp_erp_port_reopen(port,
132 ZFCP_STATUS_COMMON_ERP_FAILED, 132 ZFCP_STATUS_COMMON_ERP_FAILED,
@@ -610,7 +610,6 @@ int zfcp_scan_ports(struct zfcp_adapter *adapter)
610 int ret, i; 610 int ret, i;
611 struct zfcp_gpn_ft *gpn_ft; 611 struct zfcp_gpn_ft *gpn_ft;
612 612
613 zfcp_erp_wait(adapter); /* wait until adapter is finished with ERP */
614 if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT) 613 if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT)
615 return 0; 614 return 0;
616 615
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index d024442ee128..dc0367690405 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -930,8 +930,10 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
930 goto out; 930 goto out;
931 req = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND, 931 req = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND,
932 req_flags, adapter->pool.fsf_req_abort); 932 req_flags, adapter->pool.fsf_req_abort);
933 if (IS_ERR(req)) 933 if (IS_ERR(req)) {
934 req = NULL;
934 goto out; 935 goto out;
936 }
935 937
936 if (unlikely(!(atomic_read(&unit->status) & 938 if (unlikely(!(atomic_read(&unit->status) &
937 ZFCP_STATUS_COMMON_UNBLOCKED))) 939 ZFCP_STATUS_COMMON_UNBLOCKED)))
@@ -1584,6 +1586,7 @@ static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
1584 wka_port->status = ZFCP_WKA_PORT_OFFLINE; 1586 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1585 break; 1587 break;
1586 case FSF_PORT_ALREADY_OPEN: 1588 case FSF_PORT_ALREADY_OPEN:
1589 break;
1587 case FSF_GOOD: 1590 case FSF_GOOD:
1588 wka_port->handle = header->port_handle; 1591 wka_port->handle = header->port_handle;
1589 wka_port->status = ZFCP_WKA_PORT_ONLINE; 1592 wka_port->status = ZFCP_WKA_PORT_ONLINE;
@@ -2113,18 +2116,21 @@ static inline void zfcp_fsf_trace_latency(struct zfcp_fsf_req *fsf_req)
2113 2116
2114static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req) 2117static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req)
2115{ 2118{
2116 struct scsi_cmnd *scpnt = req->data; 2119 struct scsi_cmnd *scpnt;
2117 struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *) 2120 struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
2118 &(req->qtcb->bottom.io.fcp_rsp); 2121 &(req->qtcb->bottom.io.fcp_rsp);
2119 u32 sns_len; 2122 u32 sns_len;
2120 char *fcp_rsp_info = (unsigned char *) &fcp_rsp_iu[1]; 2123 char *fcp_rsp_info = (unsigned char *) &fcp_rsp_iu[1];
2121 unsigned long flags; 2124 unsigned long flags;
2122 2125
2123 if (unlikely(!scpnt))
2124 return;
2125
2126 read_lock_irqsave(&req->adapter->abort_lock, flags); 2126 read_lock_irqsave(&req->adapter->abort_lock, flags);
2127 2127
2128 scpnt = req->data;
2129 if (unlikely(!scpnt)) {
2130 read_unlock_irqrestore(&req->adapter->abort_lock, flags);
2131 return;
2132 }
2133
2128 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ABORTED)) { 2134 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ABORTED)) {
2129 set_host_byte(scpnt, DID_SOFT_ERROR); 2135 set_host_byte(scpnt, DID_SOFT_ERROR);
2130 set_driver_byte(scpnt, SUGGEST_RETRY); 2136 set_driver_byte(scpnt, SUGGEST_RETRY);
@@ -2442,8 +2448,10 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter,
2442 goto out; 2448 goto out;
2443 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, 2449 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
2444 adapter->pool.fsf_req_scsi); 2450 adapter->pool.fsf_req_scsi);
2445 if (IS_ERR(req)) 2451 if (IS_ERR(req)) {
2452 req = NULL;
2446 goto out; 2453 goto out;
2454 }
2447 2455
2448 req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT; 2456 req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT;
2449 req->data = unit; 2457 req->data = unit;
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index e46fd3e9f68f..468c880f8b6d 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -88,7 +88,7 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
88 ret = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, 0, 88 ret = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, 0,
89 ZFCP_REQ_AUTO_CLEANUP); 89 ZFCP_REQ_AUTO_CLEANUP);
90 if (unlikely(ret == -EBUSY)) 90 if (unlikely(ret == -EBUSY))
91 zfcp_scsi_command_fail(scpnt, DID_NO_CONNECT); 91 return SCSI_MLQUEUE_DEVICE_BUSY;
92 else if (unlikely(ret < 0)) 92 else if (unlikely(ret < 0))
93 return SCSI_MLQUEUE_HOST_BUSY; 93 return SCSI_MLQUEUE_HOST_BUSY;
94 94
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 9aa301c1ed07..94acbeed4e7c 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -175,8 +175,8 @@ static struct aac_driver_ident aac_drivers[] = {
175 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Boxster/PERC3DiB) */ 175 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Boxster/PERC3DiB) */
176 { aac_rx_init, "aacraid", "ADAPTEC ", "catapult ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* catapult */ 176 { aac_rx_init, "aacraid", "ADAPTEC ", "catapult ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* catapult */
177 { aac_rx_init, "aacraid", "ADAPTEC ", "tomcat ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* tomcat */ 177 { aac_rx_init, "aacraid", "ADAPTEC ", "tomcat ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* tomcat */
178 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2120S ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2120S (Crusader) */ 178 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2120S ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Adaptec 2120S (Crusader) */
179 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2200S (Vulcan) */ 179 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Adaptec 2200S (Vulcan) */
180 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2200S (Vulcan-2m) */ 180 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2200S (Vulcan-2m) */
181 { aac_rx_init, "aacraid", "Legend ", "Legend S220 ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend S220 (Legend Crusader) */ 181 { aac_rx_init, "aacraid", "Legend ", "Legend S220 ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend S220 (Legend Crusader) */
182 { aac_rx_init, "aacraid", "Legend ", "Legend S230 ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend S230 (Legend Vulcan) */ 182 { aac_rx_init, "aacraid", "Legend ", "Legend S230 ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend S230 (Legend Vulcan) */
@@ -427,8 +427,8 @@ static int aac_slave_configure(struct scsi_device *sdev)
427 * Firmware has an individual device recovery time typically 427 * Firmware has an individual device recovery time typically
428 * of 35 seconds, give us a margin. 428 * of 35 seconds, give us a margin.
429 */ 429 */
430 if (sdev->timeout < (45 * HZ)) 430 if (sdev->request_queue->rq_timeout < (45 * HZ))
431 sdev->timeout = 45 * HZ; 431 blk_queue_rq_timeout(sdev->request_queue, 45*HZ);
432 for (cid = 0; cid < aac->maximum_num_containers; ++cid) 432 for (cid = 0; cid < aac->maximum_num_containers; ++cid)
433 if (aac->fsa_dev[cid].valid) 433 if (aac->fsa_dev[cid].valid)
434 ++num_lsu; 434 ++num_lsu;
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 218777bfc143..399fe559e4de 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -13872,8 +13872,10 @@ static int __devinit advansys_board_found(struct Scsi_Host *shost,
13872 advansys_wide_free_mem(boardp); 13872 advansys_wide_free_mem(boardp);
13873 free_irq(boardp->irq, shost); 13873 free_irq(boardp->irq, shost);
13874 err_free_dma: 13874 err_free_dma:
13875#ifdef CONFIG_ISA
13875 if (shost->dma_channel != NO_ISA_DMA) 13876 if (shost->dma_channel != NO_ISA_DMA)
13876 free_dma(shost->dma_channel); 13877 free_dma(shost->dma_channel);
13878#endif
13877 err_free_proc: 13879 err_free_proc:
13878 kfree(boardp->prtbuf); 13880 kfree(boardp->prtbuf);
13879 err_unmap: 13881 err_unmap:
@@ -13894,10 +13896,12 @@ static int advansys_release(struct Scsi_Host *shost)
13894 ASC_DBG(1, "begin\n"); 13896 ASC_DBG(1, "begin\n");
13895 scsi_remove_host(shost); 13897 scsi_remove_host(shost);
13896 free_irq(board->irq, shost); 13898 free_irq(board->irq, shost);
13899#ifdef CONFIG_ISA
13897 if (shost->dma_channel != NO_ISA_DMA) { 13900 if (shost->dma_channel != NO_ISA_DMA) {
13898 ASC_DBG(1, "free_dma()\n"); 13901 ASC_DBG(1, "free_dma()\n");
13899 free_dma(shost->dma_channel); 13902 free_dma(shost->dma_channel);
13900 } 13903 }
13904#endif
13901 if (ASC_NARROW_BOARD(board)) { 13905 if (ASC_NARROW_BOARD(board)) {
13902 dma_unmap_single(board->dev, 13906 dma_unmap_single(board->dev,
13903 board->dvc_var.asc_dvc_var.overrun_dma, 13907 board->dvc_var.asc_dvc_var.overrun_dma,
diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
index 9aec4ca64e56..f7da7530875e 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -107,6 +107,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
107 struct request *req; 107 struct request *req;
108 int ret; 108 int ret;
109 109
110retry:
110 req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO); 111 req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
111 if (!req) 112 if (!req)
112 return SCSI_DH_RES_TEMP_UNAVAIL; 113 return SCSI_DH_RES_TEMP_UNAVAIL;
@@ -121,7 +122,6 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
121 memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE); 122 memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE);
122 req->sense_len = 0; 123 req->sense_len = 0;
123 124
124retry:
125 ret = blk_execute_rq(req->q, NULL, req, 1); 125 ret = blk_execute_rq(req->q, NULL, req, 1);
126 if (ret == -EIO) { 126 if (ret == -EIO) {
127 if (req->sense_len > 0) { 127 if (req->sense_len > 0) {
@@ -136,8 +136,10 @@ retry:
136 h->path_state = HP_SW_PATH_ACTIVE; 136 h->path_state = HP_SW_PATH_ACTIVE;
137 ret = SCSI_DH_OK; 137 ret = SCSI_DH_OK;
138 } 138 }
139 if (ret == SCSI_DH_IMM_RETRY) 139 if (ret == SCSI_DH_IMM_RETRY) {
140 blk_put_request(req);
140 goto retry; 141 goto retry;
142 }
141 if (ret == SCSI_DH_DEV_OFFLINED) { 143 if (ret == SCSI_DH_DEV_OFFLINED) {
142 h->path_state = HP_SW_PATH_PASSIVE; 144 h->path_state = HP_SW_PATH_PASSIVE;
143 ret = SCSI_DH_OK; 145 ret = SCSI_DH_OK;
@@ -200,6 +202,7 @@ static int hp_sw_start_stop(struct scsi_device *sdev, struct hp_sw_dh_data *h)
200 struct request *req; 202 struct request *req;
201 int ret, retry; 203 int ret, retry;
202 204
205retry:
203 req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO); 206 req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
204 if (!req) 207 if (!req)
205 return SCSI_DH_RES_TEMP_UNAVAIL; 208 return SCSI_DH_RES_TEMP_UNAVAIL;
@@ -216,7 +219,6 @@ static int hp_sw_start_stop(struct scsi_device *sdev, struct hp_sw_dh_data *h)
216 req->sense_len = 0; 219 req->sense_len = 0;
217 retry = h->retries; 220 retry = h->retries;
218 221
219retry:
220 ret = blk_execute_rq(req->q, NULL, req, 1); 222 ret = blk_execute_rq(req->q, NULL, req, 1);
221 if (ret == -EIO) { 223 if (ret == -EIO) {
222 if (req->sense_len > 0) { 224 if (req->sense_len > 0) {
@@ -231,8 +233,10 @@ retry:
231 ret = SCSI_DH_OK; 233 ret = SCSI_DH_OK;
232 234
233 if (ret == SCSI_DH_RETRY) { 235 if (ret == SCSI_DH_RETRY) {
234 if (--retry) 236 if (--retry) {
237 blk_put_request(req);
235 goto retry; 238 goto retry;
239 }
236 ret = SCSI_DH_IO; 240 ret = SCSI_DH_IO;
237 } 241 }
238 242
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index c387c15a2128..fb247fdfa2bd 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -588,7 +588,7 @@ static struct pci_driver gdth_pci_driver = {
588 .remove = gdth_pci_remove_one, 588 .remove = gdth_pci_remove_one,
589}; 589};
590 590
591static void gdth_pci_remove_one(struct pci_dev *pdev) 591static void __devexit gdth_pci_remove_one(struct pci_dev *pdev)
592{ 592{
593 gdth_ha_str *ha = pci_get_drvdata(pdev); 593 gdth_ha_str *ha = pci_get_drvdata(pdev);
594 594
@@ -600,7 +600,7 @@ static void gdth_pci_remove_one(struct pci_dev *pdev)
600 pci_disable_device(pdev); 600 pci_disable_device(pdev);
601} 601}
602 602
603static int gdth_pci_init_one(struct pci_dev *pdev, 603static int __devinit gdth_pci_init_one(struct pci_dev *pdev,
604 const struct pci_device_id *ent) 604 const struct pci_device_id *ent)
605{ 605{
606 ushort vendor = pdev->vendor; 606 ushort vendor = pdev->vendor;
@@ -853,7 +853,7 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)
853#endif /* CONFIG_ISA */ 853#endif /* CONFIG_ISA */
854 854
855#ifdef CONFIG_PCI 855#ifdef CONFIG_PCI
856static int gdth_init_pci(struct pci_dev *pdev, gdth_pci_str *pcistr, 856static int __devinit gdth_init_pci(struct pci_dev *pdev, gdth_pci_str *pcistr,
857 gdth_ha_str *ha) 857 gdth_ha_str *ha)
858{ 858{
859 register gdt6_dpram_str __iomem *dp6_ptr; 859 register gdt6_dpram_str __iomem *dp6_ptr;
@@ -1237,7 +1237,7 @@ static int gdth_init_pci(struct pci_dev *pdev, gdth_pci_str *pcistr,
1237 1237
1238/* controller protocol functions */ 1238/* controller protocol functions */
1239 1239
1240static void __init gdth_enable_int(gdth_ha_str *ha) 1240static void __devinit gdth_enable_int(gdth_ha_str *ha)
1241{ 1241{
1242 ulong flags; 1242 ulong flags;
1243 gdt2_dpram_str __iomem *dp2_ptr; 1243 gdt2_dpram_str __iomem *dp2_ptr;
@@ -1553,7 +1553,7 @@ static int gdth_internal_cmd(gdth_ha_str *ha, unchar service, ushort opcode,
1553 1553
1554/* search for devices */ 1554/* search for devices */
1555 1555
1556static int __init gdth_search_drives(gdth_ha_str *ha) 1556static int __devinit gdth_search_drives(gdth_ha_str *ha)
1557{ 1557{
1558 ushort cdev_cnt, i; 1558 ushort cdev_cnt, i;
1559 int ok; 1559 int ok;
@@ -4935,7 +4935,7 @@ static int __init gdth_eisa_probe_one(ushort eisa_slot)
4935#endif /* CONFIG_EISA */ 4935#endif /* CONFIG_EISA */
4936 4936
4937#ifdef CONFIG_PCI 4937#ifdef CONFIG_PCI
4938static int gdth_pci_probe_one(gdth_pci_str *pcistr, 4938static int __devinit gdth_pci_probe_one(gdth_pci_str *pcistr,
4939 gdth_ha_str **ha_out) 4939 gdth_ha_str **ha_out)
4940{ 4940{
4941 struct Scsi_Host *shp; 4941 struct Scsi_Host *shp;
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 87e09f35d3d4..6cad1758243a 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1442,7 +1442,7 @@ static int ibmvscsi_slave_configure(struct scsi_device *sdev)
1442 spin_lock_irqsave(shost->host_lock, lock_flags); 1442 spin_lock_irqsave(shost->host_lock, lock_flags);
1443 if (sdev->type == TYPE_DISK) { 1443 if (sdev->type == TYPE_DISK) {
1444 sdev->allow_restart = 1; 1444 sdev->allow_restart = 1;
1445 sdev->timeout = 60 * HZ; 1445 blk_queue_rq_timeout(sdev->request_queue, 60 * HZ);
1446 } 1446 }
1447 scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun); 1447 scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun);
1448 spin_unlock_irqrestore(shost->host_lock, lock_flags); 1448 spin_unlock_irqrestore(shost->host_lock, lock_flags);
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index 2a5b29d12172..e2dd6a45924a 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -864,21 +864,23 @@ static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id)
864 864
865 INIT_WORK(&vport->crq_work, handle_crq); 865 INIT_WORK(&vport->crq_work, handle_crq);
866 866
867 err = crq_queue_create(&vport->crq_queue, target); 867 err = scsi_add_host(shost, target->dev);
868 if (err) 868 if (err)
869 goto free_srp_target; 869 goto free_srp_target;
870 870
871 err = scsi_add_host(shost, target->dev); 871 err = scsi_tgt_alloc_queue(shost);
872 if (err) 872 if (err)
873 goto destroy_queue; 873 goto remove_host;
874 874
875 err = scsi_tgt_alloc_queue(shost); 875 err = crq_queue_create(&vport->crq_queue, target);
876 if (err) 876 if (err)
877 goto destroy_queue; 877 goto free_queue;
878 878
879 return 0; 879 return 0;
880destroy_queue: 880free_queue:
881 crq_queue_destroy(target); 881 scsi_tgt_free_queue(shost);
882remove_host:
883 scsi_remove_host(shost);
882free_srp_target: 884free_srp_target:
883 srp_target_free(target); 885 srp_target_free(target);
884put_host: 886put_host:
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 801c7cf54d2e..3fdee7370ccc 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -489,12 +489,6 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
489 if (!__kfifo_get(session->cmdpool.queue, 489 if (!__kfifo_get(session->cmdpool.queue,
490 (void*)&task, sizeof(void*))) 490 (void*)&task, sizeof(void*)))
491 return NULL; 491 return NULL;
492
493 if ((hdr->opcode == (ISCSI_OP_NOOP_OUT | ISCSI_OP_IMMEDIATE)) &&
494 hdr->ttt == RESERVED_ITT) {
495 conn->ping_task = task;
496 conn->last_ping = jiffies;
497 }
498 } 492 }
499 /* 493 /*
500 * released in complete pdu for task we expect a response for, and 494 * released in complete pdu for task we expect a response for, and
@@ -703,6 +697,11 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
703 task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0); 697 task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0);
704 if (!task) 698 if (!task)
705 iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n"); 699 iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n");
700 else if (!rhdr) {
701 /* only track our nops */
702 conn->ping_task = task;
703 conn->last_ping = jiffies;
704 }
706} 705}
707 706
708static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr, 707static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index a454f94623d7..17ce7abe17ee 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -1016,7 +1016,8 @@ static int megasas_slave_configure(struct scsi_device *sdev)
1016 * The RAID firmware may require extended timeouts. 1016 * The RAID firmware may require extended timeouts.
1017 */ 1017 */
1018 if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS) 1018 if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS)
1019 sdev->timeout = MEGASAS_DEFAULT_CMD_TIMEOUT * HZ; 1019 blk_queue_rq_timeout(sdev->request_queue,
1020 MEGASAS_DEFAULT_CMD_TIMEOUT * HZ);
1020 return 0; 1021 return 0;
1021} 1022}
1022 1023
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 386361778ebb..edfaf241c5ba 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -932,8 +932,7 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd)
932 int i, rtn = NEEDS_RETRY; 932 int i, rtn = NEEDS_RETRY;
933 933
934 for (i = 0; rtn == NEEDS_RETRY && i < 2; i++) 934 for (i = 0; rtn == NEEDS_RETRY && i < 2; i++)
935 rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, 935 rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, scmd->device->request_queue->rq_timeout, 0);
936 scmd->device->timeout, 0);
937 936
938 if (rtn == SUCCESS) 937 if (rtn == SUCCESS)
939 return 0; 938 return 0;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f5d3b96890dc..148d3af92aef 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -567,15 +567,18 @@ static inline int scsi_host_is_busy(struct Scsi_Host *shost)
567 */ 567 */
568static void scsi_run_queue(struct request_queue *q) 568static void scsi_run_queue(struct request_queue *q)
569{ 569{
570 struct scsi_device *starved_head = NULL, *sdev = q->queuedata; 570 struct scsi_device *sdev = q->queuedata;
571 struct Scsi_Host *shost = sdev->host; 571 struct Scsi_Host *shost = sdev->host;
572 LIST_HEAD(starved_list);
572 unsigned long flags; 573 unsigned long flags;
573 574
574 if (scsi_target(sdev)->single_lun) 575 if (scsi_target(sdev)->single_lun)
575 scsi_single_lun_run(sdev); 576 scsi_single_lun_run(sdev);
576 577
577 spin_lock_irqsave(shost->host_lock, flags); 578 spin_lock_irqsave(shost->host_lock, flags);
578 while (!list_empty(&shost->starved_list) && !scsi_host_is_busy(shost)) { 579 list_splice_init(&shost->starved_list, &starved_list);
580
581 while (!list_empty(&starved_list)) {
579 int flagset; 582 int flagset;
580 583
581 /* 584 /*
@@ -588,24 +591,18 @@ static void scsi_run_queue(struct request_queue *q)
588 * scsi_request_fn must get the host_lock before checking 591 * scsi_request_fn must get the host_lock before checking
589 * or modifying starved_list or starved_entry. 592 * or modifying starved_list or starved_entry.
590 */ 593 */
591 sdev = list_entry(shost->starved_list.next, 594 if (scsi_host_is_busy(shost))
592 struct scsi_device, starved_entry);
593 /*
594 * The *queue_ready functions can add a device back onto the
595 * starved list's tail, so we must check for a infinite loop.
596 */
597 if (sdev == starved_head)
598 break; 595 break;
599 if (!starved_head)
600 starved_head = sdev;
601 596
597 sdev = list_entry(starved_list.next,
598 struct scsi_device, starved_entry);
599 list_del_init(&sdev->starved_entry);
602 if (scsi_target_is_busy(scsi_target(sdev))) { 600 if (scsi_target_is_busy(scsi_target(sdev))) {
603 list_move_tail(&sdev->starved_entry, 601 list_move_tail(&sdev->starved_entry,
604 &shost->starved_list); 602 &shost->starved_list);
605 continue; 603 continue;
606 } 604 }
607 605
608 list_del_init(&sdev->starved_entry);
609 spin_unlock(shost->host_lock); 606 spin_unlock(shost->host_lock);
610 607
611 spin_lock(sdev->request_queue->queue_lock); 608 spin_lock(sdev->request_queue->queue_lock);
@@ -621,6 +618,8 @@ static void scsi_run_queue(struct request_queue *q)
621 618
622 spin_lock(shost->host_lock); 619 spin_lock(shost->host_lock);
623 } 620 }
621 /* put any unprocessed entries back */
622 list_splice(&starved_list, &shost->starved_list);
624 spin_unlock_irqrestore(shost->host_lock, flags); 623 spin_unlock_irqrestore(shost->host_lock, flags);
625 624
626 blk_run_queue(q); 625 blk_run_queue(q);
@@ -649,8 +648,8 @@ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
649 struct request *req = cmd->request; 648 struct request *req = cmd->request;
650 unsigned long flags; 649 unsigned long flags;
651 650
652 scsi_unprep_request(req);
653 spin_lock_irqsave(q->queue_lock, flags); 651 spin_lock_irqsave(q->queue_lock, flags);
652 scsi_unprep_request(req);
654 blk_requeue_request(q, req); 653 blk_requeue_request(q, req);
655 spin_unlock_irqrestore(q->queue_lock, flags); 654 spin_unlock_irqrestore(q->queue_lock, flags);
656 655
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c9e1242eaf25..5081b3981d3c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -757,7 +757,7 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
757 * access to the device is prohibited. 757 * access to the device is prohibited.
758 */ 758 */
759 error = scsi_nonblockable_ioctl(sdp, cmd, p, 759 error = scsi_nonblockable_ioctl(sdp, cmd, p,
760 (mode & FMODE_NDELAY_NOW) != 0); 760 (mode & FMODE_NDELAY) != 0);
761 if (!scsi_block_when_processing_errors(sdp) || !error) 761 if (!scsi_block_when_processing_errors(sdp) || !error)
762 return error; 762 return error;
763 763
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 62b6633e3a97..45b66b98a516 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -521,7 +521,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
521 * if it doesn't recognise the ioctl 521 * if it doesn't recognise the ioctl
522 */ 522 */
523 ret = scsi_nonblockable_ioctl(sdev, cmd, argp, 523 ret = scsi_nonblockable_ioctl(sdev, cmd, argp,
524 (mode & FMODE_NDELAY_NOW) != 0); 524 (mode & FMODE_NDELAY) != 0);
525 if (ret != -ENODEV) 525 if (ret != -ENODEV)
526 return ret; 526 return ret;
527 return scsi_ioctl(sdev, cmd, argp); 527 return scsi_ioctl(sdev, cmd, argp);
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 3790906a77d1..2fa830c0be27 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -477,7 +477,7 @@ stex_slave_config(struct scsi_device *sdev)
477{ 477{
478 sdev->use_10_for_rw = 1; 478 sdev->use_10_for_rw = 1;
479 sdev->use_10_for_ms = 1; 479 sdev->use_10_for_ms = 1;
480 sdev->timeout = 60 * HZ; 480 blk_queue_rq_timeout(sdev->request_queue, 60 * HZ);
481 sdev->tagged_supported = 1; 481 sdev->tagged_supported = 1;
482 482
483 return 0; 483 return 0;
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c
index 6dd98f9fb89c..ae3699d77dd0 100644
--- a/drivers/serial/ioc3_serial.c
+++ b/drivers/serial/ioc3_serial.c
@@ -2149,7 +2149,7 @@ out4:
2149 return ret; 2149 return ret;
2150} 2150}
2151 2151
2152static struct ioc3_submodule ioc3uart_submodule = { 2152static struct ioc3_submodule ioc3uart_ops = {
2153 .name = "IOC3uart", 2153 .name = "IOC3uart",
2154 .probe = ioc3uart_probe, 2154 .probe = ioc3uart_probe,
2155 .remove = ioc3uart_remove, 2155 .remove = ioc3uart_remove,
@@ -2173,7 +2173,7 @@ static int __devinit ioc3uart_init(void)
2173 __func__); 2173 __func__);
2174 return ret; 2174 return ret;
2175 } 2175 }
2176 ret = ioc3_register_submodule(&ioc3uart_submodule); 2176 ret = ioc3_register_submodule(&ioc3uart_ops);
2177 if (ret) 2177 if (ret)
2178 uart_unregister_driver(&ioc3_uart); 2178 uart_unregister_driver(&ioc3_uart);
2179 return ret; 2179 return ret;
@@ -2181,7 +2181,7 @@ static int __devinit ioc3uart_init(void)
2181 2181
2182static void __devexit ioc3uart_exit(void) 2182static void __devexit ioc3uart_exit(void)
2183{ 2183{
2184 ioc3_unregister_submodule(&ioc3uart_submodule); 2184 ioc3_unregister_submodule(&ioc3uart_ops);
2185 uart_unregister_driver(&ioc3_uart); 2185 uart_unregister_driver(&ioc3_uart);
2186} 2186}
2187 2187
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 6117d3db0b66..28c00c3d58f5 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -591,8 +591,8 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new,
591 /* Update the per-port timeout */ 591 /* Update the per-port timeout */
592 uart_update_timeout(port, new->c_cflag, baud); 592 uart_update_timeout(port, new->c_cflag, baud);
593 593
594 /* Do our best to flush TX & RX, so we don't loose anything */ 594 /* Do our best to flush TX & RX, so we don't lose anything */
595 /* But we don't wait indefinitly ! */ 595 /* But we don't wait indefinitely ! */
596 j = 5000000; /* Maximum wait */ 596 j = 5000000; /* Maximum wait */
597 /* FIXME Can't receive chars since set_termios might be called at early 597 /* FIXME Can't receive chars since set_termios might be called at early
598 * boot for the console, all stuff is not yet ready to receive at that 598 * boot for the console, all stuff is not yet ready to receive at that
diff --git a/drivers/serial/s3c2440.c b/drivers/serial/s3c2440.c
index 317d239ab740..29cbb0afef8e 100644
--- a/drivers/serial/s3c2440.c
+++ b/drivers/serial/s3c2440.c
@@ -177,5 +177,5 @@ module_exit(s3c2440_serial_exit);
177 177
178MODULE_DESCRIPTION("Samsung S3C2440,S3C2442 SoC Serial port driver"); 178MODULE_DESCRIPTION("Samsung S3C2440,S3C2442 SoC Serial port driver");
179MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); 179MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
180MODULE_LICENSE("GPLi v2"); 180MODULE_LICENSE("GPL v2");
181MODULE_ALIAS("platform:s3c2440-uart"); 181MODULE_ALIAS("platform:s3c2440-uart");
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
index 6a3f8fb0c9dd..3317148a4b93 100644
--- a/drivers/serial/uartlite.c
+++ b/drivers/serial/uartlite.c
@@ -286,8 +286,8 @@ static void ulite_release_port(struct uart_port *port)
286 286
287static int ulite_request_port(struct uart_port *port) 287static int ulite_request_port(struct uart_port *port)
288{ 288{
289 pr_debug("ulite console: port=%p; port->mapbase=%x\n", 289 pr_debug("ulite console: port=%p; port->mapbase=%llx\n",
290 port, port->mapbase); 290 port, (unsigned long long) port->mapbase);
291 291
292 if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) { 292 if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
293 dev_err(port->dev, "Memory region busy\n"); 293 dev_err(port->dev, "Memory region busy\n");
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index d1812d32f47d..63f0de29aa14 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -827,7 +827,7 @@ static int __init maple_bus_init(void)
827 827
828 maple_queue_cache = 828 maple_queue_cache =
829 kmem_cache_create("maple_queue_cache", 0x400, 0, 829 kmem_cache_create("maple_queue_cache", 0x400, 0,
830 SLAB_POISON|SLAB_HWCACHE_ALIGN, NULL); 830 SLAB_HWCACHE_ALIGN, NULL);
831 831
832 if (!maple_queue_cache) 832 if (!maple_queue_cache)
833 goto cleanup_bothirqs; 833 goto cleanup_bothirqs;
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c
index 87b73e0169c5..b02f25c702fd 100644
--- a/drivers/spi/au1550_spi.c
+++ b/drivers/spi/au1550_spi.c
@@ -369,10 +369,23 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
369 dma_rx_addr = t->rx_dma; 369 dma_rx_addr = t->rx_dma;
370 370
371 /* 371 /*
372 * check if buffers are already dma mapped, map them otherwise 372 * check if buffers are already dma mapped, map them otherwise:
373 * - first map the TX buffer, so cache data gets written to memory
374 * - then map the RX buffer, so that cache entries (with
375 * soon-to-be-stale data) get removed
373 * use rx buffer in place of tx if tx buffer was not provided 376 * use rx buffer in place of tx if tx buffer was not provided
374 * use temp rx buffer (preallocated or realloc to fit) for rx dma 377 * use temp rx buffer (preallocated or realloc to fit) for rx dma
375 */ 378 */
379 if (t->tx_buf) {
380 if (t->tx_dma == 0) { /* if DMA_ADDR_INVALID, map it */
381 dma_tx_addr = dma_map_single(hw->dev,
382 (void *)t->tx_buf,
383 t->len, DMA_TO_DEVICE);
384 if (dma_mapping_error(hw->dev, dma_tx_addr))
385 dev_err(hw->dev, "tx dma map error\n");
386 }
387 }
388
376 if (t->rx_buf) { 389 if (t->rx_buf) {
377 if (t->rx_dma == 0) { /* if DMA_ADDR_INVALID, map it */ 390 if (t->rx_dma == 0) { /* if DMA_ADDR_INVALID, map it */
378 dma_rx_addr = dma_map_single(hw->dev, 391 dma_rx_addr = dma_map_single(hw->dev,
@@ -396,15 +409,8 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
396 dma_sync_single_for_device(hw->dev, dma_rx_addr, 409 dma_sync_single_for_device(hw->dev, dma_rx_addr,
397 t->len, DMA_FROM_DEVICE); 410 t->len, DMA_FROM_DEVICE);
398 } 411 }
399 if (t->tx_buf) { 412
400 if (t->tx_dma == 0) { /* if DMA_ADDR_INVALID, map it */ 413 if (!t->tx_buf) {
401 dma_tx_addr = dma_map_single(hw->dev,
402 (void *)t->tx_buf,
403 t->len, DMA_TO_DEVICE);
404 if (dma_mapping_error(hw->dev, dma_tx_addr))
405 dev_err(hw->dev, "tx dma map error\n");
406 }
407 } else {
408 dma_sync_single_for_device(hw->dev, dma_rx_addr, 414 dma_sync_single_for_device(hw->dev, dma_rx_addr,
409 t->len, DMA_BIDIRECTIONAL); 415 t->len, DMA_BIDIRECTIONAL);
410 hw->tx = hw->rx; 416 hw->tx = hw->rx;
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 0debe11b67b4..3b97803e1d11 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -142,6 +142,7 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
142 unsigned rfalarm; 142 unsigned rfalarm;
143 unsigned send_at_once = MPC52xx_PSC_BUFSIZE; 143 unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
144 unsigned recv_at_once; 144 unsigned recv_at_once;
145 int last_block = 0;
145 146
146 if (!t->tx_buf && !t->rx_buf && t->len) 147 if (!t->tx_buf && !t->rx_buf && t->len)
147 return -EINVAL; 148 return -EINVAL;
@@ -151,15 +152,17 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
151 while (rb < t->len) { 152 while (rb < t->len) {
152 if (t->len - rb > MPC52xx_PSC_BUFSIZE) { 153 if (t->len - rb > MPC52xx_PSC_BUFSIZE) {
153 rfalarm = MPC52xx_PSC_RFALARM; 154 rfalarm = MPC52xx_PSC_RFALARM;
155 last_block = 0;
154 } else { 156 } else {
155 send_at_once = t->len - sb; 157 send_at_once = t->len - sb;
156 rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb); 158 rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb);
159 last_block = 1;
157 } 160 }
158 161
159 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); 162 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
160 for (; send_at_once; sb++, send_at_once--) { 163 for (; send_at_once; sb++, send_at_once--) {
161 /* set EOF flag before the last word is sent */ 164 /* set EOF flag before the last word is sent */
162 if (send_at_once == 1) 165 if (send_at_once == 1 && last_block)
163 out_8(&psc->ircr2, 0x01); 166 out_8(&psc->ircr2, 0x01);
164 167
165 if (tx_buf) 168 if (tx_buf)
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 0b4db0ce78d6..269a55ec52ef 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -1456,7 +1456,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1456 struct device *dev = &pdev->dev; 1456 struct device *dev = &pdev->dev;
1457 struct spi_imx_master *platform_info; 1457 struct spi_imx_master *platform_info;
1458 struct spi_master *master; 1458 struct spi_master *master;
1459 struct driver_data *drv_data = NULL; 1459 struct driver_data *drv_data;
1460 struct resource *res; 1460 struct resource *res;
1461 int irq, status = 0; 1461 int irq, status = 0;
1462 1462
@@ -1467,14 +1467,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1467 goto err_no_pdata; 1467 goto err_no_pdata;
1468 } 1468 }
1469 1469
1470 drv_data->clk = clk_get(&pdev->dev, "perclk2");
1471 if (IS_ERR(drv_data->clk)) {
1472 dev_err(&pdev->dev, "probe - cannot get get\n");
1473 status = PTR_ERR(drv_data->clk);
1474 goto err_no_clk;
1475 }
1476 clk_enable(drv_data->clk);
1477
1478 /* Allocate master with space for drv_data */ 1470 /* Allocate master with space for drv_data */
1479 master = spi_alloc_master(dev, sizeof(struct driver_data)); 1471 master = spi_alloc_master(dev, sizeof(struct driver_data));
1480 if (!master) { 1472 if (!master) {
@@ -1495,6 +1487,14 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1495 1487
1496 drv_data->dummy_dma_buf = SPI_DUMMY_u32; 1488 drv_data->dummy_dma_buf = SPI_DUMMY_u32;
1497 1489
1490 drv_data->clk = clk_get(&pdev->dev, "perclk2");
1491 if (IS_ERR(drv_data->clk)) {
1492 dev_err(&pdev->dev, "probe - cannot get clock\n");
1493 status = PTR_ERR(drv_data->clk);
1494 goto err_no_clk;
1495 }
1496 clk_enable(drv_data->clk);
1497
1498 /* Find and map resources */ 1498 /* Find and map resources */
1499 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1499 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1500 if (!res) { 1500 if (!res) {
@@ -1630,12 +1630,13 @@ err_no_iomap:
1630 kfree(drv_data->ioarea); 1630 kfree(drv_data->ioarea);
1631 1631
1632err_no_iores: 1632err_no_iores:
1633 spi_master_put(master);
1634
1635err_no_pdata:
1636 clk_disable(drv_data->clk); 1633 clk_disable(drv_data->clk);
1637 clk_put(drv_data->clk); 1634 clk_put(drv_data->clk);
1635
1638err_no_clk: 1636err_no_clk:
1637 spi_master_put(master);
1638
1639err_no_pdata:
1639err_no_mem: 1640err_no_mem:
1640 return status; 1641 return status;
1641} 1642}
diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c
index cc1f647f579b..f2447a5476bb 100644
--- a/drivers/spi/spi_s3c24xx_gpio.c
+++ b/drivers/spi/spi_s3c24xx_gpio.c
@@ -34,7 +34,7 @@ struct s3c2410_spigpio {
34 34
35static inline struct s3c2410_spigpio *spidev_to_sg(struct spi_device *spi) 35static inline struct s3c2410_spigpio *spidev_to_sg(struct spi_device *spi)
36{ 36{
37 return spi->controller_data; 37 return spi_master_get_devdata(spi->master);
38} 38}
39 39
40static inline void setsck(struct spi_device *dev, int on) 40static inline void setsck(struct spi_device *dev, int on)
@@ -118,6 +118,7 @@ static int s3c2410_spigpio_probe(struct platform_device *dev)
118 /* setup spi bitbang adaptor */ 118 /* setup spi bitbang adaptor */
119 sp->bitbang.master = spi_master_get(master); 119 sp->bitbang.master = spi_master_get(master);
120 sp->bitbang.master->bus_num = info->bus_num; 120 sp->bitbang.master->bus_num = info->bus_num;
121 sp->bitbang.master->num_chipselect = info->num_chipselect;
121 sp->bitbang.chipselect = s3c2410_spigpio_chipselect; 122 sp->bitbang.chipselect = s3c2410_spigpio_chipselect;
122 123
123 sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0; 124 sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0;
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 89a43755a453..5d869c4d3eb2 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -597,7 +597,9 @@ static int spidev_probe(struct spi_device *spi)
597 } 597 }
598 mutex_unlock(&device_list_lock); 598 mutex_unlock(&device_list_lock);
599 599
600 if (status != 0) 600 if (status == 0)
601 spi_set_drvdata(spi, spidev);
602 else
601 kfree(spidev); 603 kfree(spidev);
602 604
603 return status; 605 return status;
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index c95b286a1239..5d457c96bd7e 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -22,6 +22,8 @@ menuconfig STAGING
22 If in doubt, say N here. 22 If in doubt, say N here.
23 23
24 24
25if STAGING
26
25config STAGING_EXCLUDE_BUILD 27config STAGING_EXCLUDE_BUILD
26 bool "Exclude Staging drivers from being built" if STAGING 28 bool "Exclude Staging drivers from being built" if STAGING
27 default y 29 default y
@@ -62,3 +64,4 @@ source "drivers/staging/at76_usb/Kconfig"
62source "drivers/staging/poch/Kconfig" 64source "drivers/staging/poch/Kconfig"
63 65
64endif # !STAGING_EXCLUDE_BUILD 66endif # !STAGING_EXCLUDE_BUILD
67endif # STAGING
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 8e74657f106c..43a863c5cc43 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -51,6 +51,7 @@ static struct usb_device_id usbtmc_devices[] = {
51 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), }, 51 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), },
52 { 0, } /* terminating entry */ 52 { 0, } /* terminating entry */
53}; 53};
54MODULE_DEVICE_TABLE(usb, usbtmc_devices);
54 55
55/* 56/*
56 * This structure is the capabilities for the device 57 * This structure is the capabilities for the device
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 3d7793d93031..8c081308b0e2 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -279,7 +279,9 @@ static int usb_unbind_interface(struct device *dev)
279 * altsetting means creating new endpoint device entries). 279 * altsetting means creating new endpoint device entries).
280 * When either of these happens, defer the Set-Interface. 280 * When either of these happens, defer the Set-Interface.
281 */ 281 */
282 if (!error && intf->dev.power.status == DPM_ON) 282 if (intf->cur_altsetting->desc.bAlternateSetting == 0)
283 ; /* Already in altsetting 0 so skip Set-Interface */
284 else if (!error && intf->dev.power.status == DPM_ON)
283 usb_set_interface(udev, intf->altsetting[0]. 285 usb_set_interface(udev, intf->altsetting[0].
284 desc.bInterfaceNumber, 0); 286 desc.bInterfaceNumber, 0);
285 else 287 else
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 428b5993575a..3a8bb53fc473 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -651,6 +651,8 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
651 fs_in_desc.bEndpointAddress; 651 fs_in_desc.bEndpointAddress;
652 hs_out_desc.bEndpointAddress = 652 hs_out_desc.bEndpointAddress =
653 fs_out_desc.bEndpointAddress; 653 fs_out_desc.bEndpointAddress;
654 hs_notify_desc.bEndpointAddress =
655 fs_notify_desc.bEndpointAddress;
654 656
655 /* copy descriptors, and track endpoint copies */ 657 /* copy descriptors, and track endpoint copies */
656 f->hs_descriptors = usb_copy_descriptors(eth_hs_function); 658 f->hs_descriptors = usb_copy_descriptors(eth_hs_function);
@@ -662,6 +664,8 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
662 f->hs_descriptors, &hs_in_desc); 664 f->hs_descriptors, &hs_in_desc);
663 rndis->hs.out = usb_find_endpoint(eth_hs_function, 665 rndis->hs.out = usb_find_endpoint(eth_hs_function,
664 f->hs_descriptors, &hs_out_desc); 666 f->hs_descriptors, &hs_out_desc);
667 rndis->hs.notify = usb_find_endpoint(eth_hs_function,
668 f->hs_descriptors, &hs_notify_desc);
665 } 669 }
666 670
667 rndis->port.open = rndis_open; 671 rndis->port.open = rndis_open;
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index 1fe8b44787b3..b3408ff39fba 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -2363,6 +2363,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2363 nuke(loop_ep, -ESHUTDOWN); 2363 nuke(loop_ep, -ESHUTDOWN);
2364 spin_unlock_irqrestore(&udc_controller->lock, flags); 2364 spin_unlock_irqrestore(&udc_controller->lock, flags);
2365 2365
2366 /* report disconnect; the controller is already quiesced */
2367 driver->disconnect(&udc_controller->gadget);
2368
2366 /* unbind gadget and unhook driver. */ 2369 /* unbind gadget and unhook driver. */
2367 driver->unbind(&udc_controller->gadget); 2370 driver->unbind(&udc_controller->gadget);
2368 udc_controller->gadget.dev.driver = NULL; 2371 udc_controller->gadget.dev.driver = NULL;
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 091bb55c9aa7..f3c6703cffda 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -1836,6 +1836,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1836 nuke(loop_ep, -ESHUTDOWN); 1836 nuke(loop_ep, -ESHUTDOWN);
1837 spin_unlock_irqrestore(&udc_controller->lock, flags); 1837 spin_unlock_irqrestore(&udc_controller->lock, flags);
1838 1838
1839 /* report disconnect; the controller is already quiesced */
1840 driver->disconnect(&udc_controller->gadget);
1841
1839 /* unbind gadget and unhook driver. */ 1842 /* unbind gadget and unhook driver. */
1840 driver->unbind(&udc_controller->gadget); 1843 driver->unbind(&udc_controller->gadget);
1841 udc_controller->gadget.dev.driver = NULL; 1844 udc_controller->gadget.dev.driver = NULL;
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index da6e93c201d2..2dbc0db0b46c 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -141,7 +141,11 @@ static int is_vbus_present(void)
141 141
142 if (mach->gpio_vbus) { 142 if (mach->gpio_vbus) {
143 int value = gpio_get_value(mach->gpio_vbus); 143 int value = gpio_get_value(mach->gpio_vbus);
144 return mach->gpio_vbus_inverted ? !value : value; 144
145 if (mach->gpio_vbus_inverted)
146 return !value;
147 else
148 return !!value;
145 } 149 }
146 if (mach->udc_is_connected) 150 if (mach->udc_is_connected)
147 return mach->udc_is_connected(); 151 return mach->udc_is_connected();
@@ -982,7 +986,7 @@ static int pxa25x_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
982 struct pxa25x_udc *udc; 986 struct pxa25x_udc *udc;
983 987
984 udc = container_of(_gadget, struct pxa25x_udc, gadget); 988 udc = container_of(_gadget, struct pxa25x_udc, gadget);
985 udc->vbus = (is_active != 0); 989 udc->vbus = is_active;
986 DMSG("vbus %s\n", is_active ? "supplied" : "inactive"); 990 DMSG("vbus %s\n", is_active ? "supplied" : "inactive");
987 pullup(udc); 991 pullup(udc);
988 return 0; 992 return 0;
@@ -1399,12 +1403,8 @@ lubbock_vbus_irq(int irq, void *_dev)
1399static irqreturn_t udc_vbus_irq(int irq, void *_dev) 1403static irqreturn_t udc_vbus_irq(int irq, void *_dev)
1400{ 1404{
1401 struct pxa25x_udc *dev = _dev; 1405 struct pxa25x_udc *dev = _dev;
1402 int vbus = gpio_get_value(dev->mach->gpio_vbus);
1403 1406
1404 if (dev->mach->gpio_vbus_inverted) 1407 pxa25x_udc_vbus_session(&dev->gadget, is_vbus_present());
1405 vbus = !vbus;
1406
1407 pxa25x_udc_vbus_session(&dev->gadget, vbus);
1408 return IRQ_HANDLED; 1408 return IRQ_HANDLED;
1409} 1409}
1410 1410
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 9d0ea573aef6..36864f958444 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -169,18 +169,21 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
169 } 169 }
170 break; 170 break;
171 case PCI_VENDOR_ID_ATI: 171 case PCI_VENDOR_ID_ATI:
172 /* SB700 old version has a bug in EHCI controller, 172 /* SB600 and old version of SB700 have a bug in EHCI controller,
173 * which causes usb devices lose response in some cases. 173 * which causes usb devices lose response in some cases.
174 */ 174 */
175 if (pdev->device == 0x4396) { 175 if ((pdev->device == 0x4386) || (pdev->device == 0x4396)) {
176 p_smbus = pci_get_device(PCI_VENDOR_ID_ATI, 176 p_smbus = pci_get_device(PCI_VENDOR_ID_ATI,
177 PCI_DEVICE_ID_ATI_SBX00_SMBUS, 177 PCI_DEVICE_ID_ATI_SBX00_SMBUS,
178 NULL); 178 NULL);
179 if (!p_smbus) 179 if (!p_smbus)
180 break; 180 break;
181 rev = p_smbus->revision; 181 rev = p_smbus->revision;
182 if ((rev == 0x3a) || (rev == 0x3b)) { 182 if ((pdev->device == 0x4386) || (rev == 0x3a)
183 || (rev == 0x3b)) {
183 u8 tmp; 184 u8 tmp;
185 ehci_info(ehci, "applying AMD SB600/SB700 USB "
186 "freeze workaround\n");
184 pci_read_config_byte(pdev, 0x53, &tmp); 187 pci_read_config_byte(pdev, 0x53, &tmp);
185 pci_write_config_byte(pdev, 0x53, tmp | (1<<3)); 188 pci_write_config_byte(pdev, 0x53, tmp | (1<<3));
186 } 189 }
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index b11798d17ae5..c7d4b5a06bdb 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -183,16 +183,14 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
183 * the async ring; just the I/O watchdog. Note that if a 183 * the async ring; just the I/O watchdog. Note that if a
184 * SHRINK were pending, OFF would never be requested. 184 * SHRINK were pending, OFF would never be requested.
185 */ 185 */
186 enum ehci_timer_action oldactions = ehci->actions; 186 if (timer_pending(&ehci->watchdog)
187 && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
188 & ehci->actions))
189 return;
187 190
188 if (!test_and_set_bit (action, &ehci->actions)) { 191 if (!test_and_set_bit (action, &ehci->actions)) {
189 unsigned long t; 192 unsigned long t;
190 193
191 if (timer_pending(&ehci->watchdog)
192 && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
193 & oldactions))
194 return;
195
196 switch (action) { 194 switch (action) {
197 case TIMER_IO_WATCHDOG: 195 case TIMER_IO_WATCHDOG:
198 t = EHCI_IO_JIFFIES; 196 t = EHCI_IO_JIFFIES;
@@ -208,7 +206,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
208 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1; 206 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
209 break; 207 break;
210 } 208 }
211 mod_timer(&ehci->watchdog, round_jiffies(t + jiffies)); 209 mod_timer(&ehci->watchdog, t + jiffies);
212 } 210 }
213} 211}
214 212
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 5b20de130e08..5b95009d2fbb 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -135,6 +135,7 @@ static int usb_console_setup(struct console *co, char *options)
135 err("no more memory"); 135 err("no more memory");
136 goto reset_open_count; 136 goto reset_open_count;
137 } 137 }
138 kref_init(&tty->kref);
138 termios = kzalloc(sizeof(*termios), GFP_KERNEL); 139 termios = kzalloc(sizeof(*termios), GFP_KERNEL);
139 if (!termios) { 140 if (!termios) {
140 retval = -ENOMEM; 141 retval = -ENOMEM;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 51d7bdea2869..fb6f2933b01b 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -143,6 +143,7 @@ static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {
143static struct usb_device_id id_table_combined [] = { 143static struct usb_device_id id_table_combined [] = {
144 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, 144 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
145 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, 145 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
146 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
146 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) }, 147 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
147 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_1_PID) }, 148 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_1_PID) },
148 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_2_PID) }, 149 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_2_PID) },
@@ -166,6 +167,7 @@ static struct usb_device_id id_table_combined [] = {
166 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, 167 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) },
167 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 168 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
168 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 169 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
170 { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) },
169 { USB_DEVICE(FTDI_VID, FTDI_XF_632_PID) }, 171 { USB_DEVICE(FTDI_VID, FTDI_XF_632_PID) },
170 { USB_DEVICE(FTDI_VID, FTDI_XF_634_PID) }, 172 { USB_DEVICE(FTDI_VID, FTDI_XF_634_PID) },
171 { USB_DEVICE(FTDI_VID, FTDI_XF_547_PID) }, 173 { USB_DEVICE(FTDI_VID, FTDI_XF_547_PID) },
@@ -1498,7 +1500,7 @@ static int ftdi_open(struct tty_struct *tty,
1498 priv->interface, buf, 0, WDR_TIMEOUT); 1500 priv->interface, buf, 0, WDR_TIMEOUT);
1499 1501
1500 /* Termios defaults are set by usb_serial_init. We don't change 1502 /* Termios defaults are set by usb_serial_init. We don't change
1501 port->tty->termios - this would loose speed settings, etc. 1503 port->tty->termios - this would lose speed settings, etc.
1502 This is same behaviour as serial.c/rs_open() - Kuba */ 1504 This is same behaviour as serial.c/rs_open() - Kuba */
1503 1505
1504 /* ftdi_set_termios will send usb control messages */ 1506 /* ftdi_set_termios will send usb control messages */
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 07a3992abad2..373ee09975bb 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -40,6 +40,9 @@
40/* AlphaMicro Components AMC-232USB01 device */ 40/* AlphaMicro Components AMC-232USB01 device */
41#define FTDI_AMC232_PID 0xFF00 /* Product Id */ 41#define FTDI_AMC232_PID 0xFF00 /* Product Id */
42 42
43/* www.candapter.com Ewert Energy Systems CANdapter device */
44#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
45
43/* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */ 46/* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */
44/* the VID is the standard ftdi vid (FTDI_VID) */ 47/* the VID is the standard ftdi vid (FTDI_VID) */
45#define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */ 48#define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */
@@ -75,6 +78,9 @@
75/* OpenDCC (www.opendcc.de) product id */ 78/* OpenDCC (www.opendcc.de) product id */
76#define FTDI_OPENDCC_PID 0xBFD8 79#define FTDI_OPENDCC_PID 0xBFD8
77 80
81/* Sprog II (Andrew Crosland's SprogII DCC interface) */
82#define FTDI_SPROG_II 0xF0C8
83
78/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ 84/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
79/* they use the ftdi chipset for the USB interface and the vendor id is the same */ 85/* they use the ftdi chipset for the USB interface and the vendor id is the same */
80#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 86#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6fa1ec441b61..809697b3c7fc 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -224,6 +224,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
224#define ONDA_VENDOR_ID 0x19d2 224#define ONDA_VENDOR_ID 0x19d2
225#define ONDA_PRODUCT_MSA501HS 0x0001 225#define ONDA_PRODUCT_MSA501HS 0x0001
226#define ONDA_PRODUCT_ET502HS 0x0002 226#define ONDA_PRODUCT_ET502HS 0x0002
227#define ONDA_PRODUCT_MT503HS 0x0200
227 228
228#define BANDRICH_VENDOR_ID 0x1A8D 229#define BANDRICH_VENDOR_ID 0x1A8D
229#define BANDRICH_PRODUCT_C100_1 0x1002 230#define BANDRICH_PRODUCT_C100_1 0x1002
@@ -413,6 +414,40 @@ static struct usb_device_id option_ids[] = {
413 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, 414 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) },
414 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) }, 415 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) },
415 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, 416 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) },
417 { USB_DEVICE(ONDA_VENDOR_ID, 0x0003) },
418 { USB_DEVICE(ONDA_VENDOR_ID, 0x0004) },
419 { USB_DEVICE(ONDA_VENDOR_ID, 0x0005) },
420 { USB_DEVICE(ONDA_VENDOR_ID, 0x0006) },
421 { USB_DEVICE(ONDA_VENDOR_ID, 0x0007) },
422 { USB_DEVICE(ONDA_VENDOR_ID, 0x0008) },
423 { USB_DEVICE(ONDA_VENDOR_ID, 0x0009) },
424 { USB_DEVICE(ONDA_VENDOR_ID, 0x000a) },
425 { USB_DEVICE(ONDA_VENDOR_ID, 0x000b) },
426 { USB_DEVICE(ONDA_VENDOR_ID, 0x000c) },
427 { USB_DEVICE(ONDA_VENDOR_ID, 0x000d) },
428 { USB_DEVICE(ONDA_VENDOR_ID, 0x000e) },
429 { USB_DEVICE(ONDA_VENDOR_ID, 0x000f) },
430 { USB_DEVICE(ONDA_VENDOR_ID, 0x0010) },
431 { USB_DEVICE(ONDA_VENDOR_ID, 0x0011) },
432 { USB_DEVICE(ONDA_VENDOR_ID, 0x0012) },
433 { USB_DEVICE(ONDA_VENDOR_ID, 0x0013) },
434 { USB_DEVICE(ONDA_VENDOR_ID, 0x0014) },
435 { USB_DEVICE(ONDA_VENDOR_ID, 0x0015) },
436 { USB_DEVICE(ONDA_VENDOR_ID, 0x0016) },
437 { USB_DEVICE(ONDA_VENDOR_ID, 0x0017) },
438 { USB_DEVICE(ONDA_VENDOR_ID, 0x0018) },
439 { USB_DEVICE(ONDA_VENDOR_ID, 0x0019) },
440 { USB_DEVICE(ONDA_VENDOR_ID, 0x0020) },
441 { USB_DEVICE(ONDA_VENDOR_ID, 0x0021) },
442 { USB_DEVICE(ONDA_VENDOR_ID, 0x0022) },
443 { USB_DEVICE(ONDA_VENDOR_ID, 0x0023) },
444 { USB_DEVICE(ONDA_VENDOR_ID, 0x0024) },
445 { USB_DEVICE(ONDA_VENDOR_ID, 0x0025) },
446 { USB_DEVICE(ONDA_VENDOR_ID, 0x0026) },
447 { USB_DEVICE(ONDA_VENDOR_ID, 0x0027) },
448 { USB_DEVICE(ONDA_VENDOR_ID, 0x0028) },
449 { USB_DEVICE(ONDA_VENDOR_ID, 0x0029) },
450 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MT503HS) },
416 { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, 451 { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) },
417 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, 452 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) },
418 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, 453 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) },
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 491c8857b644..1aed584be5eb 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -91,6 +91,8 @@ static struct usb_device_id id_table [] = {
91 { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, 91 { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) },
92 { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) }, 92 { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) },
93 { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) }, 93 { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) },
94 { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) },
95 { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) },
94 { } /* Terminating entry */ 96 { } /* Terminating entry */
95}; 97};
96 98
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index a3bd039c78e9..54974f446a8c 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -110,3 +110,11 @@
110/* Y.C. Cable U.S.A., Inc - USB to RS-232 */ 110/* Y.C. Cable U.S.A., Inc - USB to RS-232 */
111#define YCCABLE_VENDOR_ID 0x05ad 111#define YCCABLE_VENDOR_ID 0x05ad
112#define YCCABLE_PRODUCT_ID 0x0fba 112#define YCCABLE_PRODUCT_ID 0x0fba
113
114/* "Superial" USB - Serial */
115#define SUPERIAL_VENDOR_ID 0x5372
116#define SUPERIAL_PRODUCT_ID 0x2303
117
118/* Hewlett-Packard LD220-HP POS Pole Display */
119#define HP_VENDOR_ID 0x03f0
120#define HP_LD220_PRODUCT_ID 0x3524
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 31c42d1cae13..01d0c70d60e9 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -16,56 +16,6 @@
16 * For questions or problems with this driver, contact Texas Instruments 16 * For questions or problems with this driver, contact Texas Instruments
17 * technical support, or Al Borchers <alborchers@steinerpoint.com>, or 17 * technical support, or Al Borchers <alborchers@steinerpoint.com>, or
18 * Peter Berger <pberger@brimson.com>. 18 * Peter Berger <pberger@brimson.com>.
19 *
20 * This driver needs this hotplug script in /etc/hotplug/usb/ti_usb_3410_5052
21 * or in /etc/hotplug.d/usb/ti_usb_3410_5052.hotplug to set the device
22 * configuration.
23 *
24 * #!/bin/bash
25 *
26 * BOOT_CONFIG=1
27 * ACTIVE_CONFIG=2
28 *
29 * if [[ "$ACTION" != "add" ]]
30 * then
31 * exit
32 * fi
33 *
34 * CONFIG_PATH=/sys${DEVPATH%/?*}/bConfigurationValue
35 *
36 * if [[ 0`cat $CONFIG_PATH` -ne $BOOT_CONFIG ]]
37 * then
38 * exit
39 * fi
40 *
41 * PRODUCT=${PRODUCT%/?*} # delete version
42 * VENDOR_ID=`printf "%d" 0x${PRODUCT%/?*}`
43 * PRODUCT_ID=`printf "%d" 0x${PRODUCT#*?/}`
44 *
45 * PARAM_PATH=/sys/module/ti_usb_3410_5052/parameters
46 *
47 * function scan() {
48 * s=$1
49 * shift
50 * for i
51 * do
52 * if [[ $s -eq $i ]]
53 * then
54 * return 0
55 * fi
56 * done
57 * return 1
58 * }
59 *
60 * IFS=$IFS,
61 *
62 * if (scan $VENDOR_ID 1105 `cat $PARAM_PATH/vendor_3410` &&
63 * scan $PRODUCT_ID 13328 `cat $PARAM_PATH/product_3410`) ||
64 * (scan $VENDOR_ID 1105 `cat $PARAM_PATH/vendor_5052` &&
65 * scan $PRODUCT_ID 20562 20818 20570 20575 `cat $PARAM_PATH/product_5052`)
66 * then
67 * echo $ACTIVE_CONFIG > $CONFIG_PATH
68 * fi
69 */ 19 */
70 20
71#include <linux/kernel.h> 21#include <linux/kernel.h>
@@ -457,9 +407,10 @@ static int ti_startup(struct usb_serial *serial)
457 goto free_tdev; 407 goto free_tdev;
458 } 408 }
459 409
460 /* the second configuration must be set (in sysfs by hotplug script) */ 410 /* the second configuration must be set */
461 if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) { 411 if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) {
462 status = -ENODEV; 412 status = usb_driver_set_configuration(dev, TI_ACTIVE_CONFIG);
413 status = status ? status : -ENODEV;
463 goto free_tdev; 414 goto free_tdev;
464 } 415 }
465 416
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 6da9a7a962a8..bfcc1fe82518 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -167,8 +167,22 @@ UNUSUAL_DEV( 0x0421, 0x005d, 0x0001, 0x0600,
167 US_SC_DEVICE, US_PR_DEVICE, NULL, 167 US_SC_DEVICE, US_PR_DEVICE, NULL,
168 US_FL_FIX_CAPACITY ), 168 US_FL_FIX_CAPACITY ),
169 169
170/* Reported by Ozan Sener <themgzzy@gmail.com> */
171UNUSUAL_DEV( 0x0421, 0x0060, 0x0551, 0x0551,
172 "Nokia",
173 "3500c",
174 US_SC_DEVICE, US_PR_DEVICE, NULL,
175 US_FL_FIX_CAPACITY ),
176
177/* Reported by CSECSY Laszlo <boobaa@frugalware.org> */
178UNUSUAL_DEV( 0x0421, 0x0063, 0x0001, 0x0601,
179 "Nokia",
180 "Nokia 3109c",
181 US_SC_DEVICE, US_PR_DEVICE, NULL,
182 US_FL_FIX_CAPACITY ),
183
170/* Patch for Nokia 5310 capacity */ 184/* Patch for Nokia 5310 capacity */
171UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591, 185UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0701,
172 "Nokia", 186 "Nokia",
173 "5310", 187 "5310",
174 US_SC_DEVICE, US_PR_DEVICE, NULL, 188 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -318,6 +332,18 @@ UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101,
318 US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0), 332 US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0),
319#endif 333#endif
320 334
335/* Reported by Tamas Kerecsen <kerecsen@bigfoot.com>
336 * Obviously the PROM has not been customized by the VAR;
337 * the Vendor and Product string descriptors are:
338 * Generic Mass Storage (PROTOTYPE--Remember to change idVendor)
339 * Generic Manufacturer (PROTOTYPE--Remember to change idVendor)
340 */
341UNUSUAL_DEV( 0x045e, 0xffff, 0x0000, 0x0000,
342 "Mitac",
343 "GPS",
344 US_SC_DEVICE, US_PR_DEVICE, NULL,
345 US_FL_MAX_SECTORS_64 ),
346
321/* 347/*
322 * This virtual floppy is found in Sun equipment (x4600, x4200m2, etc.) 348 * This virtual floppy is found in Sun equipment (x4600, x4200m2, etc.)
323 * Reported by Pete Zaitcev <zaitcev@redhat.com> 349 * Reported by Pete Zaitcev <zaitcev@redhat.com>
@@ -377,6 +403,13 @@ UNUSUAL_DEV( 0x04b0, 0x0401, 0x0200, 0x0200,
377 US_SC_DEVICE, US_PR_DEVICE, NULL, 403 US_SC_DEVICE, US_PR_DEVICE, NULL,
378 US_FL_FIX_CAPACITY), 404 US_FL_FIX_CAPACITY),
379 405
406/* Reported by Tobias Kunze Briseno <t-linux@fictive.com> */
407UNUSUAL_DEV( 0x04b0, 0x0403, 0x0200, 0x0200,
408 "NIKON",
409 "NIKON DSC D2H",
410 US_SC_DEVICE, US_PR_DEVICE, NULL,
411 US_FL_FIX_CAPACITY),
412
380/* Reported by Milinevsky Dmitry <niam.niam@gmail.com> */ 413/* Reported by Milinevsky Dmitry <niam.niam@gmail.com> */
381UNUSUAL_DEV( 0x04b0, 0x0409, 0x0100, 0x0100, 414UNUSUAL_DEV( 0x04b0, 0x0409, 0x0100, 0x0100,
382 "NIKON", 415 "NIKON",
diff --git a/drivers/video/aty/radeon_accel.c b/drivers/video/aty/radeon_accel.c
index 8718f7349d6b..a469a3d6edcb 100644
--- a/drivers/video/aty/radeon_accel.c
+++ b/drivers/video/aty/radeon_accel.c
@@ -5,61 +5,61 @@
5 * --dte 5 * --dte
6 */ 6 */
7 7
8#define FLUSH_CACHE_WORKAROUND 1 8static void radeon_fixup_offset(struct radeonfb_info *rinfo)
9
10void radeon_fifo_update_and_wait(struct radeonfb_info *rinfo, int entries)
11{ 9{
12 int i; 10 u32 local_base;
11
12 /* *** Ugly workaround *** */
13 /*
14 * On some platforms, the video memory is mapped at 0 in radeon chip space
15 * (like PPCs) by the firmware. X will always move it up so that it's seen
16 * by the chip to be at the same address as the PCI BAR.
17 * That means that when switching back from X, there is a mismatch between
18 * the offsets programmed into the engine. This means that potentially,
19 * accel operations done before radeonfb has a chance to re-init the engine
20 * will have incorrect offsets, and potentially trash system memory !
21 *
22 * The correct fix is for fbcon to never call any accel op before the engine
23 * has properly been re-initialized (by a call to set_var), but this is a
24 * complex fix. This workaround in the meantime, called before every accel
25 * operation, makes sure the offsets are in sync.
26 */
13 27
14 for (i=0; i<2000000; i++) { 28 radeon_fifo_wait (1);
15 rinfo->fifo_free = INREG(RBBM_STATUS) & 0x7f; 29 local_base = INREG(MC_FB_LOCATION) << 16;
16 if (rinfo->fifo_free >= entries) 30 if (local_base == rinfo->fb_local_base)
17 return; 31 return;
18 udelay(10);
19 }
20 printk(KERN_ERR "radeonfb: FIFO Timeout !\n");
21 /* XXX Todo: attempt to reset the engine */
22}
23 32
24static inline void radeon_fifo_wait(struct radeonfb_info *rinfo, int entries) 33 rinfo->fb_local_base = local_base;
25{
26 if (entries <= rinfo->fifo_free)
27 rinfo->fifo_free -= entries;
28 else
29 radeon_fifo_update_and_wait(rinfo, entries);
30}
31 34
32static inline void radeonfb_set_creg(struct radeonfb_info *rinfo, u32 reg, 35 radeon_fifo_wait (3);
33 u32 *cache, u32 new_val) 36 OUTREG(DEFAULT_PITCH_OFFSET, (rinfo->pitch << 0x16) |
34{ 37 (rinfo->fb_local_base >> 10));
35 if (new_val == *cache) 38 OUTREG(DST_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
36 return; 39 OUTREG(SRC_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
37 *cache = new_val;
38 radeon_fifo_wait(rinfo, 1);
39 OUTREG(reg, new_val);
40} 40}
41 41
42static void radeonfb_prim_fillrect(struct radeonfb_info *rinfo, 42static void radeonfb_prim_fillrect(struct radeonfb_info *rinfo,
43 const struct fb_fillrect *region) 43 const struct fb_fillrect *region)
44{ 44{
45 radeonfb_set_creg(rinfo, DP_GUI_MASTER_CNTL, &rinfo->dp_gui_mc_cache, 45 radeon_fifo_wait(4);
46 rinfo->dp_gui_mc_base | GMC_BRUSH_SOLID_COLOR | ROP3_P); 46
47 radeonfb_set_creg(rinfo, DP_CNTL, &rinfo->dp_cntl_cache, 47 OUTREG(DP_GUI_MASTER_CNTL,
48 DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM); 48 rinfo->dp_gui_master_cntl /* contains, like GMC_DST_32BPP */
49 radeonfb_set_creg(rinfo, DP_BRUSH_FRGD_CLR, &rinfo->dp_brush_fg_cache, 49 | GMC_BRUSH_SOLID_COLOR
50 region->color); 50 | ROP3_P);
51 51 if (radeon_get_dstbpp(rinfo->depth) != DST_8BPP)
52 /* Ensure the dst cache is flushed and the engine idle before 52 OUTREG(DP_BRUSH_FRGD_CLR, rinfo->pseudo_palette[region->color]);
53 * issuing the operation. 53 else
54 * 54 OUTREG(DP_BRUSH_FRGD_CLR, region->color);
55 * This works around engine lockups on some cards 55 OUTREG(DP_WRITE_MSK, 0xffffffff);
56 */ 56 OUTREG(DP_CNTL, (DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM));
57#if FLUSH_CACHE_WORKAROUND 57
58 radeon_fifo_wait(rinfo, 2); 58 radeon_fifo_wait(2);
59 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL); 59 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
60 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE)); 60 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
61#endif 61
62 radeon_fifo_wait(rinfo, 2); 62 radeon_fifo_wait(2);
63 OUTREG(DST_Y_X, (region->dy << 16) | region->dx); 63 OUTREG(DST_Y_X, (region->dy << 16) | region->dx);
64 OUTREG(DST_WIDTH_HEIGHT, (region->width << 16) | region->height); 64 OUTREG(DST_WIDTH_HEIGHT, (region->width << 16) | region->height);
65} 65}
@@ -70,14 +70,15 @@ void radeonfb_fillrect(struct fb_info *info, const struct fb_fillrect *region)
70 struct fb_fillrect modded; 70 struct fb_fillrect modded;
71 int vxres, vyres; 71 int vxres, vyres;
72 72
73 WARN_ON(rinfo->gfx_mode); 73 if (info->state != FBINFO_STATE_RUNNING)
74 if (info->state != FBINFO_STATE_RUNNING || rinfo->gfx_mode)
75 return; 74 return;
76 if (info->flags & FBINFO_HWACCEL_DISABLED) { 75 if (info->flags & FBINFO_HWACCEL_DISABLED) {
77 cfb_fillrect(info, region); 76 cfb_fillrect(info, region);
78 return; 77 return;
79 } 78 }
80 79
80 radeon_fixup_offset(rinfo);
81
81 vxres = info->var.xres_virtual; 82 vxres = info->var.xres_virtual;
82 vyres = info->var.yres_virtual; 83 vyres = info->var.yres_virtual;
83 84
@@ -90,10 +91,6 @@ void radeonfb_fillrect(struct fb_info *info, const struct fb_fillrect *region)
90 if(modded.dx + modded.width > vxres) modded.width = vxres - modded.dx; 91 if(modded.dx + modded.width > vxres) modded.width = vxres - modded.dx;
91 if(modded.dy + modded.height > vyres) modded.height = vyres - modded.dy; 92 if(modded.dy + modded.height > vyres) modded.height = vyres - modded.dy;
92 93
93 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
94 info->fix.visual == FB_VISUAL_DIRECTCOLOR )
95 modded.color = ((u32 *) (info->pseudo_palette))[region->color];
96
97 radeonfb_prim_fillrect(rinfo, &modded); 94 radeonfb_prim_fillrect(rinfo, &modded);
98} 95}
99 96
@@ -112,22 +109,22 @@ static void radeonfb_prim_copyarea(struct radeonfb_info *rinfo,
112 if ( xdir < 0 ) { sx += w-1; dx += w-1; } 109 if ( xdir < 0 ) { sx += w-1; dx += w-1; }
113 if ( ydir < 0 ) { sy += h-1; dy += h-1; } 110 if ( ydir < 0 ) { sy += h-1; dy += h-1; }
114 111
115 radeonfb_set_creg(rinfo, DP_GUI_MASTER_CNTL, &rinfo->dp_gui_mc_cache, 112 radeon_fifo_wait(3);
116 rinfo->dp_gui_mc_base | 113 OUTREG(DP_GUI_MASTER_CNTL,
117 GMC_BRUSH_NONE | 114 rinfo->dp_gui_master_cntl /* i.e. GMC_DST_32BPP */
118 GMC_SRC_DATATYPE_COLOR | 115 | GMC_BRUSH_NONE
119 ROP3_S | 116 | GMC_SRC_DSTCOLOR
120 DP_SRC_SOURCE_MEMORY); 117 | ROP3_S
121 radeonfb_set_creg(rinfo, DP_CNTL, &rinfo->dp_cntl_cache, 118 | DP_SRC_SOURCE_MEMORY );
122 (xdir>=0 ? DST_X_LEFT_TO_RIGHT : 0) | 119 OUTREG(DP_WRITE_MSK, 0xffffffff);
123 (ydir>=0 ? DST_Y_TOP_TO_BOTTOM : 0)); 120 OUTREG(DP_CNTL, (xdir>=0 ? DST_X_LEFT_TO_RIGHT : 0)
124 121 | (ydir>=0 ? DST_Y_TOP_TO_BOTTOM : 0));
125#if FLUSH_CACHE_WORKAROUND 122
126 radeon_fifo_wait(rinfo, 2); 123 radeon_fifo_wait(2);
127 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL); 124 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
128 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE)); 125 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
129#endif 126
130 radeon_fifo_wait(rinfo, 3); 127 radeon_fifo_wait(3);
131 OUTREG(SRC_Y_X, (sy << 16) | sx); 128 OUTREG(SRC_Y_X, (sy << 16) | sx);
132 OUTREG(DST_Y_X, (dy << 16) | dx); 129 OUTREG(DST_Y_X, (dy << 16) | dx);
133 OUTREG(DST_HEIGHT_WIDTH, (h << 16) | w); 130 OUTREG(DST_HEIGHT_WIDTH, (h << 16) | w);
@@ -146,14 +143,15 @@ void radeonfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
146 modded.width = area->width; 143 modded.width = area->width;
147 modded.height = area->height; 144 modded.height = area->height;
148 145
149 WARN_ON(rinfo->gfx_mode); 146 if (info->state != FBINFO_STATE_RUNNING)
150 if (info->state != FBINFO_STATE_RUNNING || rinfo->gfx_mode)
151 return; 147 return;
152 if (info->flags & FBINFO_HWACCEL_DISABLED) { 148 if (info->flags & FBINFO_HWACCEL_DISABLED) {
153 cfb_copyarea(info, area); 149 cfb_copyarea(info, area);
154 return; 150 return;
155 } 151 }
156 152
153 radeon_fixup_offset(rinfo);
154
157 vxres = info->var.xres_virtual; 155 vxres = info->var.xres_virtual;
158 vyres = info->var.yres_virtual; 156 vyres = info->var.yres_virtual;
159 157
@@ -170,112 +168,13 @@ void radeonfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
170 radeonfb_prim_copyarea(rinfo, &modded); 168 radeonfb_prim_copyarea(rinfo, &modded);
171} 169}
172 170
173static void radeonfb_prim_imageblit(struct radeonfb_info *rinfo,
174 const struct fb_image *image,
175 u32 fg, u32 bg)
176{
177 unsigned int src_bytes, dwords;
178 u32 *bits;
179
180 radeonfb_set_creg(rinfo, DP_GUI_MASTER_CNTL, &rinfo->dp_gui_mc_cache,
181 rinfo->dp_gui_mc_base |
182 GMC_BRUSH_NONE |
183 GMC_SRC_DATATYPE_MONO_FG_BG |
184 ROP3_S |
185 GMC_BYTE_ORDER_MSB_TO_LSB |
186 DP_SRC_SOURCE_HOST_DATA);
187 radeonfb_set_creg(rinfo, DP_CNTL, &rinfo->dp_cntl_cache,
188 DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM);
189 radeonfb_set_creg(rinfo, DP_SRC_FRGD_CLR, &rinfo->dp_src_fg_cache, fg);
190 radeonfb_set_creg(rinfo, DP_SRC_BKGD_CLR, &rinfo->dp_src_bg_cache, bg);
191
192 radeon_fifo_wait(rinfo, 1);
193 OUTREG(DST_Y_X, (image->dy << 16) | image->dx);
194
195 /* Ensure the dst cache is flushed and the engine idle before
196 * issuing the operation.
197 *
198 * This works around engine lockups on some cards
199 */
200#if FLUSH_CACHE_WORKAROUND
201 radeon_fifo_wait(rinfo, 2);
202 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
203 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
204#endif
205
206 /* X here pads width to a multiple of 32 and uses the clipper to
207 * adjust the result. Is that really necessary ? Things seem to
208 * work ok for me without that and the doco doesn't seem to imply
209 * there is such a restriction.
210 */
211 OUTREG(DST_WIDTH_HEIGHT, (image->width << 16) | image->height);
212
213 src_bytes = (((image->width * image->depth) + 7) / 8) * image->height;
214 dwords = (src_bytes + 3) / 4;
215 bits = (u32*)(image->data);
216
217 while(dwords >= 8) {
218 radeon_fifo_wait(rinfo, 8);
219#if BITS_PER_LONG == 64
220 __raw_writeq(*((u64 *)(bits)), rinfo->mmio_base + HOST_DATA0);
221 __raw_writeq(*((u64 *)(bits+2)), rinfo->mmio_base + HOST_DATA2);
222 __raw_writeq(*((u64 *)(bits+4)), rinfo->mmio_base + HOST_DATA4);
223 __raw_writeq(*((u64 *)(bits+6)), rinfo->mmio_base + HOST_DATA6);
224 bits += 8;
225#else
226 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA0);
227 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA1);
228 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA2);
229 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA3);
230 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA4);
231 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA5);
232 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA6);
233 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA7);
234#endif
235 dwords -= 8;
236 }
237 while(dwords--) {
238 radeon_fifo_wait(rinfo, 1);
239 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA0);
240 }
241}
242
243void radeonfb_imageblit(struct fb_info *info, const struct fb_image *image) 171void radeonfb_imageblit(struct fb_info *info, const struct fb_image *image)
244{ 172{
245 struct radeonfb_info *rinfo = info->par; 173 struct radeonfb_info *rinfo = info->par;
246 u32 fg, bg;
247
248 WARN_ON(rinfo->gfx_mode);
249 if (info->state != FBINFO_STATE_RUNNING || rinfo->gfx_mode)
250 return;
251 174
252 if (!image->width || !image->height) 175 if (info->state != FBINFO_STATE_RUNNING)
253 return; 176 return;
254 177 radeon_engine_idle();
255 /* We only do 1 bpp color expansion for now */
256 if (info->flags & FBINFO_HWACCEL_DISABLED || image->depth != 1)
257 goto fallback;
258
259 /* Fallback if running out of the screen. We may do clipping
260 * in the future */
261 if ((image->dx + image->width) > info->var.xres_virtual ||
262 (image->dy + image->height) > info->var.yres_virtual)
263 goto fallback;
264
265 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
266 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
267 fg = ((u32*)(info->pseudo_palette))[image->fg_color];
268 bg = ((u32*)(info->pseudo_palette))[image->bg_color];
269 } else {
270 fg = image->fg_color;
271 bg = image->bg_color;
272 }
273
274 radeonfb_prim_imageblit(rinfo, image, fg, bg);
275 return;
276
277 fallback:
278 radeon_engine_idle(rinfo);
279 178
280 cfb_imageblit(info, image); 179 cfb_imageblit(info, image);
281} 180}
@@ -286,8 +185,7 @@ int radeonfb_sync(struct fb_info *info)
286 185
287 if (info->state != FBINFO_STATE_RUNNING) 186 if (info->state != FBINFO_STATE_RUNNING)
288 return 0; 187 return 0;
289 188 radeon_engine_idle();
290 radeon_engine_idle(rinfo);
291 189
292 return 0; 190 return 0;
293} 191}
@@ -363,10 +261,9 @@ void radeonfb_engine_init (struct radeonfb_info *rinfo)
363 /* disable 3D engine */ 261 /* disable 3D engine */
364 OUTREG(RB3D_CNTL, 0); 262 OUTREG(RB3D_CNTL, 0);
365 263
366 rinfo->fifo_free = 0;
367 radeonfb_engine_reset(rinfo); 264 radeonfb_engine_reset(rinfo);
368 265
369 radeon_fifo_wait(rinfo, 1); 266 radeon_fifo_wait (1);
370 if (IS_R300_VARIANT(rinfo)) { 267 if (IS_R300_VARIANT(rinfo)) {
371 OUTREG(RB2D_DSTCACHE_MODE, INREG(RB2D_DSTCACHE_MODE) | 268 OUTREG(RB2D_DSTCACHE_MODE, INREG(RB2D_DSTCACHE_MODE) |
372 RB2D_DC_AUTOFLUSH_ENABLE | 269 RB2D_DC_AUTOFLUSH_ENABLE |
@@ -380,7 +277,7 @@ void radeonfb_engine_init (struct radeonfb_info *rinfo)
380 OUTREG(RB2D_DSTCACHE_MODE, 0); 277 OUTREG(RB2D_DSTCACHE_MODE, 0);
381 } 278 }
382 279
383 radeon_fifo_wait(rinfo, 3); 280 radeon_fifo_wait (3);
384 /* We re-read MC_FB_LOCATION from card as it can have been 281 /* We re-read MC_FB_LOCATION from card as it can have been
385 * modified by XFree drivers (ouch !) 282 * modified by XFree drivers (ouch !)
386 */ 283 */
@@ -391,57 +288,41 @@ void radeonfb_engine_init (struct radeonfb_info *rinfo)
391 OUTREG(DST_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10)); 288 OUTREG(DST_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
392 OUTREG(SRC_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10)); 289 OUTREG(SRC_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
393 290
394 radeon_fifo_wait(rinfo, 1); 291 radeon_fifo_wait (1);
395#ifdef __BIG_ENDIAN 292#if defined(__BIG_ENDIAN)
396 OUTREGP(DP_DATATYPE, HOST_BIG_ENDIAN_EN, ~HOST_BIG_ENDIAN_EN); 293 OUTREGP(DP_DATATYPE, HOST_BIG_ENDIAN_EN, ~HOST_BIG_ENDIAN_EN);
397#else 294#else
398 OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN); 295 OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN);
399#endif 296#endif
400 radeon_fifo_wait(rinfo, 2); 297 radeon_fifo_wait (2);
401 OUTREG(DEFAULT_SC_TOP_LEFT, 0); 298 OUTREG(DEFAULT_SC_TOP_LEFT, 0);
402 OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX | 299 OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX |
403 DEFAULT_SC_BOTTOM_MAX)); 300 DEFAULT_SC_BOTTOM_MAX));
404 301
405 /* set default DP_GUI_MASTER_CNTL */
406 temp = radeon_get_dstbpp(rinfo->depth); 302 temp = radeon_get_dstbpp(rinfo->depth);
407 rinfo->dp_gui_mc_base = ((temp << 8) | GMC_CLR_CMP_CNTL_DIS); 303 rinfo->dp_gui_master_cntl = ((temp << 8) | GMC_CLR_CMP_CNTL_DIS);
408 304
409 rinfo->dp_gui_mc_cache = rinfo->dp_gui_mc_base | 305 radeon_fifo_wait (1);
410 GMC_BRUSH_SOLID_COLOR | 306 OUTREG(DP_GUI_MASTER_CNTL, (rinfo->dp_gui_master_cntl |
411 GMC_SRC_DATATYPE_COLOR; 307 GMC_BRUSH_SOLID_COLOR |
412 radeon_fifo_wait(rinfo, 1); 308 GMC_SRC_DATATYPE_COLOR));
413 OUTREG(DP_GUI_MASTER_CNTL, rinfo->dp_gui_mc_cache);
414 309
310 radeon_fifo_wait (7);
415 311
416 /* clear line drawing regs */ 312 /* clear line drawing regs */
417 radeon_fifo_wait(rinfo, 2);
418 OUTREG(DST_LINE_START, 0); 313 OUTREG(DST_LINE_START, 0);
419 OUTREG(DST_LINE_END, 0); 314 OUTREG(DST_LINE_END, 0);
420 315
421 /* set brush and source color regs */ 316 /* set brush color regs */
422 rinfo->dp_brush_fg_cache = 0xffffffff; 317 OUTREG(DP_BRUSH_FRGD_CLR, 0xffffffff);
423 rinfo->dp_brush_bg_cache = 0x00000000; 318 OUTREG(DP_BRUSH_BKGD_CLR, 0x00000000);
424 rinfo->dp_src_fg_cache = 0xffffffff; 319
425 rinfo->dp_src_bg_cache = 0x00000000; 320 /* set source color regs */
426 radeon_fifo_wait(rinfo, 4); 321 OUTREG(DP_SRC_FRGD_CLR, 0xffffffff);
427 OUTREG(DP_BRUSH_FRGD_CLR, rinfo->dp_brush_fg_cache); 322 OUTREG(DP_SRC_BKGD_CLR, 0x00000000);
428 OUTREG(DP_BRUSH_BKGD_CLR, rinfo->dp_brush_bg_cache);
429 OUTREG(DP_SRC_FRGD_CLR, rinfo->dp_src_fg_cache);
430 OUTREG(DP_SRC_BKGD_CLR, rinfo->dp_src_bg_cache);
431
432 /* Default direction */
433 rinfo->dp_cntl_cache = DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM;
434 radeon_fifo_wait(rinfo, 1);
435 OUTREG(DP_CNTL, rinfo->dp_cntl_cache);
436 323
437 /* default write mask */ 324 /* default write mask */
438 radeon_fifo_wait(rinfo, 1);
439 OUTREG(DP_WRITE_MSK, 0xffffffff); 325 OUTREG(DP_WRITE_MSK, 0xffffffff);
440 326
441 /* Default to no swapping of host data */ 327 radeon_engine_idle ();
442 radeon_fifo_wait(rinfo, 1);
443 OUTREG(RBBM_GUICNTL, RBBM_GUICNTL_HOST_DATA_SWAP_NONE);
444
445 /* Make sure it's settled */
446 radeon_engine_idle(rinfo);
447} 328}
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c
index f343ba83f0ae..1a056adb61c8 100644
--- a/drivers/video/aty/radeon_backlight.c
+++ b/drivers/video/aty/radeon_backlight.c
@@ -66,7 +66,7 @@ static int radeon_bl_update_status(struct backlight_device *bd)
66 level = bd->props.brightness; 66 level = bd->props.brightness;
67 67
68 del_timer_sync(&rinfo->lvds_timer); 68 del_timer_sync(&rinfo->lvds_timer);
69 radeon_engine_idle(rinfo); 69 radeon_engine_idle();
70 70
71 lvds_gen_cntl = INREG(LVDS_GEN_CNTL); 71 lvds_gen_cntl = INREG(LVDS_GEN_CNTL);
72 if (level > 0) { 72 if (level > 0) {
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 9a5821c65ebf..d0f1a7fc2c9d 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -852,6 +852,7 @@ static int radeonfb_pan_display (struct fb_var_screeninfo *var,
852 if (rinfo->asleep) 852 if (rinfo->asleep)
853 return 0; 853 return 0;
854 854
855 radeon_fifo_wait(2);
855 OUTREG(CRTC_OFFSET, ((var->yoffset * var->xres_virtual + var->xoffset) 856 OUTREG(CRTC_OFFSET, ((var->yoffset * var->xres_virtual + var->xoffset)
856 * var->bits_per_pixel / 8) & ~7); 857 * var->bits_per_pixel / 8) & ~7);
857 return 0; 858 return 0;
@@ -881,6 +882,7 @@ static int radeonfb_ioctl (struct fb_info *info, unsigned int cmd,
881 if (rc) 882 if (rc)
882 return rc; 883 return rc;
883 884
885 radeon_fifo_wait(2);
884 if (value & 0x01) { 886 if (value & 0x01) {
885 tmp = INREG(LVDS_GEN_CNTL); 887 tmp = INREG(LVDS_GEN_CNTL);
886 888
@@ -938,7 +940,7 @@ int radeon_screen_blank(struct radeonfb_info *rinfo, int blank, int mode_switch)
938 if (rinfo->lock_blank) 940 if (rinfo->lock_blank)
939 return 0; 941 return 0;
940 942
941 radeon_engine_idle(rinfo); 943 radeon_engine_idle();
942 944
943 val = INREG(CRTC_EXT_CNTL); 945 val = INREG(CRTC_EXT_CNTL);
944 val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS | 946 val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS |
@@ -1046,7 +1048,7 @@ static int radeonfb_blank (int blank, struct fb_info *info)
1046 1048
1047 if (rinfo->asleep) 1049 if (rinfo->asleep)
1048 return 0; 1050 return 0;
1049 1051
1050 return radeon_screen_blank(rinfo, blank, 0); 1052 return radeon_screen_blank(rinfo, blank, 0);
1051} 1053}
1052 1054
@@ -1072,6 +1074,8 @@ static int radeon_setcolreg (unsigned regno, unsigned red, unsigned green,
1072 pindex = regno; 1074 pindex = regno;
1073 1075
1074 if (!rinfo->asleep) { 1076 if (!rinfo->asleep) {
1077 radeon_fifo_wait(9);
1078
1075 if (rinfo->bpp == 16) { 1079 if (rinfo->bpp == 16) {
1076 pindex = regno * 8; 1080 pindex = regno * 8;
1077 1081
@@ -1240,6 +1244,8 @@ static void radeon_write_pll_regs(struct radeonfb_info *rinfo, struct radeon_reg
1240{ 1244{
1241 int i; 1245 int i;
1242 1246
1247 radeon_fifo_wait(20);
1248
1243 /* Workaround from XFree */ 1249 /* Workaround from XFree */
1244 if (rinfo->is_mobility) { 1250 if (rinfo->is_mobility) {
1245 /* A temporal workaround for the occational blanking on certain laptop 1251 /* A temporal workaround for the occational blanking on certain laptop
@@ -1335,7 +1341,7 @@ static void radeon_lvds_timer_func(unsigned long data)
1335{ 1341{
1336 struct radeonfb_info *rinfo = (struct radeonfb_info *)data; 1342 struct radeonfb_info *rinfo = (struct radeonfb_info *)data;
1337 1343
1338 radeon_engine_idle(rinfo); 1344 radeon_engine_idle();
1339 1345
1340 OUTREG(LVDS_GEN_CNTL, rinfo->pending_lvds_gen_cntl); 1346 OUTREG(LVDS_GEN_CNTL, rinfo->pending_lvds_gen_cntl);
1341} 1347}
@@ -1353,11 +1359,10 @@ void radeon_write_mode (struct radeonfb_info *rinfo, struct radeon_regs *mode,
1353 if (nomodeset) 1359 if (nomodeset)
1354 return; 1360 return;
1355 1361
1356 radeon_engine_idle(rinfo);
1357
1358 if (!regs_only) 1362 if (!regs_only)
1359 radeon_screen_blank(rinfo, FB_BLANK_NORMAL, 0); 1363 radeon_screen_blank(rinfo, FB_BLANK_NORMAL, 0);
1360 1364
1365 radeon_fifo_wait(31);
1361 for (i=0; i<10; i++) 1366 for (i=0; i<10; i++)
1362 OUTREG(common_regs[i].reg, common_regs[i].val); 1367 OUTREG(common_regs[i].reg, common_regs[i].val);
1363 1368
@@ -1385,6 +1390,7 @@ void radeon_write_mode (struct radeonfb_info *rinfo, struct radeon_regs *mode,
1385 radeon_write_pll_regs(rinfo, mode); 1390 radeon_write_pll_regs(rinfo, mode);
1386 1391
1387 if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) { 1392 if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) {
1393 radeon_fifo_wait(10);
1388 OUTREG(FP_CRTC_H_TOTAL_DISP, mode->fp_crtc_h_total_disp); 1394 OUTREG(FP_CRTC_H_TOTAL_DISP, mode->fp_crtc_h_total_disp);
1389 OUTREG(FP_CRTC_V_TOTAL_DISP, mode->fp_crtc_v_total_disp); 1395 OUTREG(FP_CRTC_V_TOTAL_DISP, mode->fp_crtc_v_total_disp);
1390 OUTREG(FP_H_SYNC_STRT_WID, mode->fp_h_sync_strt_wid); 1396 OUTREG(FP_H_SYNC_STRT_WID, mode->fp_h_sync_strt_wid);
@@ -1399,6 +1405,7 @@ void radeon_write_mode (struct radeonfb_info *rinfo, struct radeon_regs *mode,
1399 if (!regs_only) 1405 if (!regs_only)
1400 radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 0); 1406 radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 0);
1401 1407
1408 radeon_fifo_wait(2);
1402 OUTPLL(VCLK_ECP_CNTL, mode->vclk_ecp_cntl); 1409 OUTPLL(VCLK_ECP_CNTL, mode->vclk_ecp_cntl);
1403 1410
1404 return; 1411 return;
@@ -1549,7 +1556,7 @@ static int radeonfb_set_par(struct fb_info *info)
1549 /* We always want engine to be idle on a mode switch, even 1556 /* We always want engine to be idle on a mode switch, even
1550 * if we won't actually change the mode 1557 * if we won't actually change the mode
1551 */ 1558 */
1552 radeon_engine_idle(rinfo); 1559 radeon_engine_idle();
1553 1560
1554 hSyncStart = mode->xres + mode->right_margin; 1561 hSyncStart = mode->xres + mode->right_margin;
1555 hSyncEnd = hSyncStart + mode->hsync_len; 1562 hSyncEnd = hSyncStart + mode->hsync_len;
@@ -1844,6 +1851,7 @@ static int radeonfb_set_par(struct fb_info *info)
1844 return 0; 1851 return 0;
1845} 1852}
1846 1853
1854
1847static struct fb_ops radeonfb_ops = { 1855static struct fb_ops radeonfb_ops = {
1848 .owner = THIS_MODULE, 1856 .owner = THIS_MODULE,
1849 .fb_check_var = radeonfb_check_var, 1857 .fb_check_var = radeonfb_check_var,
@@ -1867,7 +1875,6 @@ static int __devinit radeon_set_fbinfo (struct radeonfb_info *rinfo)
1867 info->par = rinfo; 1875 info->par = rinfo;
1868 info->pseudo_palette = rinfo->pseudo_palette; 1876 info->pseudo_palette = rinfo->pseudo_palette;
1869 info->flags = FBINFO_DEFAULT 1877 info->flags = FBINFO_DEFAULT
1870 | FBINFO_HWACCEL_IMAGEBLIT
1871 | FBINFO_HWACCEL_COPYAREA 1878 | FBINFO_HWACCEL_COPYAREA
1872 | FBINFO_HWACCEL_FILLRECT 1879 | FBINFO_HWACCEL_FILLRECT
1873 | FBINFO_HWACCEL_XPAN 1880 | FBINFO_HWACCEL_XPAN
@@ -1999,6 +2006,7 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
1999 u32 tom = INREG(NB_TOM); 2006 u32 tom = INREG(NB_TOM);
2000 tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024); 2007 tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);
2001 2008
2009 radeon_fifo_wait(6);
2002 OUTREG(MC_FB_LOCATION, tom); 2010 OUTREG(MC_FB_LOCATION, tom);
2003 OUTREG(DISPLAY_BASE_ADDR, (tom & 0xffff) << 16); 2011 OUTREG(DISPLAY_BASE_ADDR, (tom & 0xffff) << 16);
2004 OUTREG(CRTC2_DISPLAY_BASE_ADDR, (tom & 0xffff) << 16); 2012 OUTREG(CRTC2_DISPLAY_BASE_ADDR, (tom & 0xffff) << 16);
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 3df5015f1d13..675abdafc2d8 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2653,9 +2653,9 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2653 2653
2654 if (!(info->flags & FBINFO_HWACCEL_DISABLED)) { 2654 if (!(info->flags & FBINFO_HWACCEL_DISABLED)) {
2655 /* Make sure engine is reset */ 2655 /* Make sure engine is reset */
2656 radeon_engine_idle(rinfo); 2656 radeon_engine_idle();
2657 radeonfb_engine_reset(rinfo); 2657 radeonfb_engine_reset(rinfo);
2658 radeon_engine_idle(rinfo); 2658 radeon_engine_idle();
2659 } 2659 }
2660 2660
2661 /* Blank display and LCD */ 2661 /* Blank display and LCD */
@@ -2767,7 +2767,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2767 2767
2768 rinfo->asleep = 0; 2768 rinfo->asleep = 0;
2769 } else 2769 } else
2770 radeon_engine_idle(rinfo); 2770 radeon_engine_idle();
2771 2771
2772 /* Restore display & engine */ 2772 /* Restore display & engine */
2773 radeon_write_mode (rinfo, &rinfo->state, 1); 2773 radeon_write_mode (rinfo, &rinfo->state, 1);
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
index ea0b5b47acaf..3ea1b00fdd22 100644
--- a/drivers/video/aty/radeonfb.h
+++ b/drivers/video/aty/radeonfb.h
@@ -336,15 +336,7 @@ struct radeonfb_info {
336 int mon2_type; 336 int mon2_type;
337 u8 *mon2_EDID; 337 u8 *mon2_EDID;
338 338
339 /* accel bits */ 339 u32 dp_gui_master_cntl;
340 u32 dp_gui_mc_base;
341 u32 dp_gui_mc_cache;
342 u32 dp_cntl_cache;
343 u32 dp_brush_fg_cache;
344 u32 dp_brush_bg_cache;
345 u32 dp_src_fg_cache;
346 u32 dp_src_bg_cache;
347 u32 fifo_free;
348 340
349 struct pll_info pll; 341 struct pll_info pll;
350 342
@@ -356,7 +348,6 @@ struct radeonfb_info {
356 int lock_blank; 348 int lock_blank;
357 int dynclk; 349 int dynclk;
358 int no_schedule; 350 int no_schedule;
359 int gfx_mode;
360 enum radeon_pm_mode pm_mode; 351 enum radeon_pm_mode pm_mode;
361 reinit_function_ptr reinit_func; 352 reinit_function_ptr reinit_func;
362 353
@@ -401,14 +392,8 @@ static inline void _radeon_msleep(struct radeonfb_info *rinfo, unsigned long ms)
401#define OUTREG8(addr,val) writeb(val, (rinfo->mmio_base)+addr) 392#define OUTREG8(addr,val) writeb(val, (rinfo->mmio_base)+addr)
402#define INREG16(addr) readw((rinfo->mmio_base)+addr) 393#define INREG16(addr) readw((rinfo->mmio_base)+addr)
403#define OUTREG16(addr,val) writew(val, (rinfo->mmio_base)+addr) 394#define OUTREG16(addr,val) writew(val, (rinfo->mmio_base)+addr)
404
405#ifdef CONFIG_PPC
406#define INREG(addr) ({ eieio(); ld_le32(rinfo->mmio_base+(addr)); })
407#define OUTREG(addr,val) do { eieio(); st_le32(rinfo->mmio_base+(addr),(val)); } while(0)
408#else
409#define INREG(addr) readl((rinfo->mmio_base)+addr) 395#define INREG(addr) readl((rinfo->mmio_base)+addr)
410#define OUTREG(addr,val) writel(val, (rinfo->mmio_base)+addr) 396#define OUTREG(addr,val) writel(val, (rinfo->mmio_base)+addr)
411#endif
412 397
413static inline void _OUTREGP(struct radeonfb_info *rinfo, u32 addr, 398static inline void _OUTREGP(struct radeonfb_info *rinfo, u32 addr,
414 u32 val, u32 mask) 399 u32 val, u32 mask)
@@ -550,7 +535,17 @@ static inline u32 radeon_get_dstbpp(u16 depth)
550 * 2D Engine helper routines 535 * 2D Engine helper routines
551 */ 536 */
552 537
553extern void radeon_fifo_update_and_wait(struct radeonfb_info *rinfo, int entries); 538static inline void _radeon_fifo_wait(struct radeonfb_info *rinfo, int entries)
539{
540 int i;
541
542 for (i=0; i<2000000; i++) {
543 if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
544 return;
545 udelay(1);
546 }
547 printk(KERN_ERR "radeonfb: FIFO Timeout !\n");
548}
554 549
555static inline void radeon_engine_flush (struct radeonfb_info *rinfo) 550static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
556{ 551{
@@ -563,7 +558,7 @@ static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
563 /* Ensure FIFO is empty, ie, make sure the flush commands 558 /* Ensure FIFO is empty, ie, make sure the flush commands
564 * has reached the cache 559 * has reached the cache
565 */ 560 */
566 radeon_fifo_update_and_wait(rinfo, 64); 561 _radeon_fifo_wait (rinfo, 64);
567 562
568 /* Wait for the flush to complete */ 563 /* Wait for the flush to complete */
569 for (i=0; i < 2000000; i++) { 564 for (i=0; i < 2000000; i++) {
@@ -575,12 +570,12 @@ static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
575} 570}
576 571
577 572
578static inline void radeon_engine_idle(struct radeonfb_info *rinfo) 573static inline void _radeon_engine_idle(struct radeonfb_info *rinfo)
579{ 574{
580 int i; 575 int i;
581 576
582 /* ensure FIFO is empty before waiting for idle */ 577 /* ensure FIFO is empty before waiting for idle */
583 radeon_fifo_update_and_wait (rinfo, 64); 578 _radeon_fifo_wait (rinfo, 64);
584 579
585 for (i=0; i<2000000; i++) { 580 for (i=0; i<2000000; i++) {
586 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) { 581 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) {
@@ -593,6 +588,8 @@ static inline void radeon_engine_idle(struct radeonfb_info *rinfo)
593} 588}
594 589
595 590
591#define radeon_engine_idle() _radeon_engine_idle(rinfo)
592#define radeon_fifo_wait(entries) _radeon_fifo_wait(rinfo,entries)
596#define radeon_msleep(ms) _radeon_msleep(rinfo,ms) 593#define radeon_msleep(ms) _radeon_msleep(rinfo,ms)
597 594
598 595
@@ -622,7 +619,6 @@ extern void radeonfb_imageblit(struct fb_info *p, const struct fb_image *image);
622extern int radeonfb_sync(struct fb_info *info); 619extern int radeonfb_sync(struct fb_info *info);
623extern void radeonfb_engine_init (struct radeonfb_info *rinfo); 620extern void radeonfb_engine_init (struct radeonfb_info *rinfo);
624extern void radeonfb_engine_reset(struct radeonfb_info *rinfo); 621extern void radeonfb_engine_reset(struct radeonfb_info *rinfo);
625extern void radeon_fixup_mem_offset(struct radeonfb_info *rinfo);
626 622
627/* Other functions */ 623/* Other functions */
628extern int radeon_screen_blank(struct radeonfb_info *rinfo, int blank, int mode_switch); 624extern int radeon_screen_blank(struct radeonfb_info *rinfo, int blank, int mode_switch);
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index b92947d62ad6..0b2adefe9e3d 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -2389,16 +2389,13 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2389 2389
2390 if (!fbcon_is_inactive(vc, info)) { 2390 if (!fbcon_is_inactive(vc, info)) {
2391 if (ops->blank_state != blank) { 2391 if (ops->blank_state != blank) {
2392 int ret = 1;
2393
2394 ops->blank_state = blank; 2392 ops->blank_state = blank;
2395 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); 2393 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2396 ops->cursor_flash = (!blank); 2394 ops->cursor_flash = (!blank);
2397 2395
2398 if (info->fbops->fb_blank) 2396 if (!(info->flags & FBINFO_MISC_USEREVENT))
2399 ret = info->fbops->fb_blank(blank, info); 2397 if (fb_blank(info, blank))
2400 if (ret) 2398 fbcon_generic_blank(vc, info, blank);
2401 fbcon_generic_blank(vc, info, blank);
2402 } 2399 }
2403 2400
2404 if (!blank) 2401 if (!blank)
@@ -3534,12 +3531,18 @@ static void fbcon_exit(void)
3534 softback_buf = 0UL; 3531 softback_buf = 0UL;
3535 3532
3536 for (i = 0; i < FB_MAX; i++) { 3533 for (i = 0; i < FB_MAX; i++) {
3534 int pending;
3535
3537 mapped = 0; 3536 mapped = 0;
3538 info = registered_fb[i]; 3537 info = registered_fb[i];
3539 3538
3540 if (info == NULL) 3539 if (info == NULL)
3541 continue; 3540 continue;
3542 3541
3542 pending = cancel_work_sync(&info->queue);
3543 DPRINTK("fbcon: %s pending work\n", (pending ? "canceled" :
3544 "no"));
3545
3543 for (j = first_fb_vc; j <= last_fb_vc; j++) { 3546 for (j = first_fb_vc; j <= last_fb_vc; j++) {
3544 if (con2fb_map[j] == i) 3547 if (con2fb_map[j] == i)
3545 mapped = 1; 3548 mapped = 1;
diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c
index b790ddff76f9..ee380d5f3410 100644
--- a/drivers/video/macfb.c
+++ b/drivers/video/macfb.c
@@ -164,7 +164,6 @@ static struct fb_var_screeninfo macfb_defined = {
164}; 164};
165 165
166static struct fb_fix_screeninfo macfb_fix = { 166static struct fb_fix_screeninfo macfb_fix = {
167 .id = "Macintosh ",
168 .type = FB_TYPE_PACKED_PIXELS, 167 .type = FB_TYPE_PACKED_PIXELS,
169 .accel = FB_ACCEL_NONE, 168 .accel = FB_ACCEL_NONE,
170}; 169};
@@ -760,22 +759,22 @@ static int __init macfb_init(void)
760 759
761 switch(ndev->dr_hw) { 760 switch(ndev->dr_hw) {
762 case NUBUS_DRHW_APPLE_MDC: 761 case NUBUS_DRHW_APPLE_MDC:
763 strcat( macfb_fix.id, "Display Card" ); 762 strcpy(macfb_fix.id, "Mac Disp. Card");
764 macfb_setpalette = mdc_setpalette; 763 macfb_setpalette = mdc_setpalette;
765 macfb_defined.activate = FB_ACTIVATE_NOW; 764 macfb_defined.activate = FB_ACTIVATE_NOW;
766 break; 765 break;
767 case NUBUS_DRHW_APPLE_TFB: 766 case NUBUS_DRHW_APPLE_TFB:
768 strcat( macfb_fix.id, "Toby" ); 767 strcpy(macfb_fix.id, "Toby");
769 macfb_setpalette = toby_setpalette; 768 macfb_setpalette = toby_setpalette;
770 macfb_defined.activate = FB_ACTIVATE_NOW; 769 macfb_defined.activate = FB_ACTIVATE_NOW;
771 break; 770 break;
772 case NUBUS_DRHW_APPLE_JET: 771 case NUBUS_DRHW_APPLE_JET:
773 strcat( macfb_fix.id, "Jet"); 772 strcpy(macfb_fix.id, "Jet");
774 macfb_setpalette = jet_setpalette; 773 macfb_setpalette = jet_setpalette;
775 macfb_defined.activate = FB_ACTIVATE_NOW; 774 macfb_defined.activate = FB_ACTIVATE_NOW;
776 break; 775 break;
777 default: 776 default:
778 strcat( macfb_fix.id, "Generic NuBus" ); 777 strcpy(macfb_fix.id, "Generic NuBus");
779 break; 778 break;
780 } 779 }
781 } 780 }
@@ -786,21 +785,11 @@ static int __init macfb_init(void)
786 if (!video_is_nubus) 785 if (!video_is_nubus)
787 switch( mac_bi_data.id ) 786 switch( mac_bi_data.id )
788 { 787 {
789 /* These don't have onboard video. Eventually, we may
790 be able to write separate framebuffer drivers for
791 them (tobyfb.c, hiresfb.c, etc, etc) */
792 case MAC_MODEL_II:
793 case MAC_MODEL_IIX:
794 case MAC_MODEL_IICX:
795 case MAC_MODEL_IIFX:
796 strcat( macfb_fix.id, "Generic NuBus" );
797 break;
798
799 /* Valkyrie Quadras */ 788 /* Valkyrie Quadras */
800 case MAC_MODEL_Q630: 789 case MAC_MODEL_Q630:
801 /* I'm not sure about this one */ 790 /* I'm not sure about this one */
802 case MAC_MODEL_P588: 791 case MAC_MODEL_P588:
803 strcat( macfb_fix.id, "Valkyrie built-in" ); 792 strcpy(macfb_fix.id, "Valkyrie");
804 macfb_setpalette = valkyrie_setpalette; 793 macfb_setpalette = valkyrie_setpalette;
805 macfb_defined.activate = FB_ACTIVATE_NOW; 794 macfb_defined.activate = FB_ACTIVATE_NOW;
806 valkyrie_cmap_regs = ioremap(DAC_BASE, 0x1000); 795 valkyrie_cmap_regs = ioremap(DAC_BASE, 0x1000);
@@ -823,7 +812,7 @@ static int __init macfb_init(void)
823 case MAC_MODEL_Q700: 812 case MAC_MODEL_Q700:
824 case MAC_MODEL_Q900: 813 case MAC_MODEL_Q900:
825 case MAC_MODEL_Q950: 814 case MAC_MODEL_Q950:
826 strcat( macfb_fix.id, "DAFB built-in" ); 815 strcpy(macfb_fix.id, "DAFB");
827 macfb_setpalette = dafb_setpalette; 816 macfb_setpalette = dafb_setpalette;
828 macfb_defined.activate = FB_ACTIVATE_NOW; 817 macfb_defined.activate = FB_ACTIVATE_NOW;
829 dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000); 818 dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000);
@@ -831,7 +820,7 @@ static int __init macfb_init(void)
831 820
832 /* LC II uses the V8 framebuffer */ 821 /* LC II uses the V8 framebuffer */
833 case MAC_MODEL_LCII: 822 case MAC_MODEL_LCII:
834 strcat( macfb_fix.id, "V8 built-in" ); 823 strcpy(macfb_fix.id, "V8");
835 macfb_setpalette = v8_brazil_setpalette; 824 macfb_setpalette = v8_brazil_setpalette;
836 macfb_defined.activate = FB_ACTIVATE_NOW; 825 macfb_defined.activate = FB_ACTIVATE_NOW;
837 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 826 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
@@ -843,7 +832,7 @@ static int __init macfb_init(void)
843 case MAC_MODEL_IIVI: 832 case MAC_MODEL_IIVI:
844 case MAC_MODEL_IIVX: 833 case MAC_MODEL_IIVX:
845 case MAC_MODEL_P600: 834 case MAC_MODEL_P600:
846 strcat( macfb_fix.id, "Brazil built-in" ); 835 strcpy(macfb_fix.id, "Brazil");
847 macfb_setpalette = v8_brazil_setpalette; 836 macfb_setpalette = v8_brazil_setpalette;
848 macfb_defined.activate = FB_ACTIVATE_NOW; 837 macfb_defined.activate = FB_ACTIVATE_NOW;
849 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 838 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
@@ -860,7 +849,7 @@ static int __init macfb_init(void)
860 case MAC_MODEL_P460: 849 case MAC_MODEL_P460:
861 macfb_setpalette = v8_brazil_setpalette; 850 macfb_setpalette = v8_brazil_setpalette;
862 macfb_defined.activate = FB_ACTIVATE_NOW; 851 macfb_defined.activate = FB_ACTIVATE_NOW;
863 strcat( macfb_fix.id, "Sonora built-in" ); 852 strcpy(macfb_fix.id, "Sonora");
864 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 853 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
865 break; 854 break;
866 855
@@ -871,7 +860,7 @@ static int __init macfb_init(void)
871 case MAC_MODEL_IISI: 860 case MAC_MODEL_IISI:
872 macfb_setpalette = rbv_setpalette; 861 macfb_setpalette = rbv_setpalette;
873 macfb_defined.activate = FB_ACTIVATE_NOW; 862 macfb_defined.activate = FB_ACTIVATE_NOW;
874 strcat( macfb_fix.id, "RBV built-in" ); 863 strcpy(macfb_fix.id, "RBV");
875 rbv_cmap_regs = ioremap(DAC_BASE, 0x1000); 864 rbv_cmap_regs = ioremap(DAC_BASE, 0x1000);
876 break; 865 break;
877 866
@@ -880,7 +869,7 @@ static int __init macfb_init(void)
880 case MAC_MODEL_C660: 869 case MAC_MODEL_C660:
881 macfb_setpalette = civic_setpalette; 870 macfb_setpalette = civic_setpalette;
882 macfb_defined.activate = FB_ACTIVATE_NOW; 871 macfb_defined.activate = FB_ACTIVATE_NOW;
883 strcat( macfb_fix.id, "Civic built-in" ); 872 strcpy(macfb_fix.id, "Civic");
884 civic_cmap_regs = ioremap(CIVIC_BASE, 0x1000); 873 civic_cmap_regs = ioremap(CIVIC_BASE, 0x1000);
885 break; 874 break;
886 875
@@ -901,7 +890,7 @@ static int __init macfb_init(void)
901 v8_brazil_cmap_regs = 890 v8_brazil_cmap_regs =
902 ioremap(DAC_BASE, 0x1000); 891 ioremap(DAC_BASE, 0x1000);
903 } 892 }
904 strcat( macfb_fix.id, "LC built-in" ); 893 strcpy(macfb_fix.id, "LC");
905 break; 894 break;
906 /* We think this may be like the LC II */ 895 /* We think this may be like the LC II */
907 case MAC_MODEL_CCL: 896 case MAC_MODEL_CCL:
@@ -911,18 +900,18 @@ static int __init macfb_init(void)
911 v8_brazil_cmap_regs = 900 v8_brazil_cmap_regs =
912 ioremap(DAC_BASE, 0x1000); 901 ioremap(DAC_BASE, 0x1000);
913 } 902 }
914 strcat( macfb_fix.id, "Color Classic built-in" ); 903 strcpy(macfb_fix.id, "Color Classic");
915 break; 904 break;
916 905
917 /* And we *do* mean "weirdos" */ 906 /* And we *do* mean "weirdos" */
918 case MAC_MODEL_TV: 907 case MAC_MODEL_TV:
919 strcat( macfb_fix.id, "Mac TV built-in" ); 908 strcpy(macfb_fix.id, "Mac TV");
920 break; 909 break;
921 910
922 /* These don't have colour, so no need to worry */ 911 /* These don't have colour, so no need to worry */
923 case MAC_MODEL_SE30: 912 case MAC_MODEL_SE30:
924 case MAC_MODEL_CLII: 913 case MAC_MODEL_CLII:
925 strcat( macfb_fix.id, "Monochrome built-in" ); 914 strcpy(macfb_fix.id, "Monochrome");
926 break; 915 break;
927 916
928 /* Powerbooks are particularly difficult. Many of 917 /* Powerbooks are particularly difficult. Many of
@@ -935,7 +924,7 @@ static int __init macfb_init(void)
935 case MAC_MODEL_PB140: 924 case MAC_MODEL_PB140:
936 case MAC_MODEL_PB145: 925 case MAC_MODEL_PB145:
937 case MAC_MODEL_PB170: 926 case MAC_MODEL_PB170:
938 strcat( macfb_fix.id, "DDC built-in" ); 927 strcpy(macfb_fix.id, "DDC");
939 break; 928 break;
940 929
941 /* Internal is GSC, External (if present) is ViSC */ 930 /* Internal is GSC, External (if present) is ViSC */
@@ -945,13 +934,13 @@ static int __init macfb_init(void)
945 case MAC_MODEL_PB180: 934 case MAC_MODEL_PB180:
946 case MAC_MODEL_PB210: 935 case MAC_MODEL_PB210:
947 case MAC_MODEL_PB230: 936 case MAC_MODEL_PB230:
948 strcat( macfb_fix.id, "GSC built-in" ); 937 strcpy(macfb_fix.id, "GSC");
949 break; 938 break;
950 939
951 /* Internal is TIM, External is ViSC */ 940 /* Internal is TIM, External is ViSC */
952 case MAC_MODEL_PB165C: 941 case MAC_MODEL_PB165C:
953 case MAC_MODEL_PB180C: 942 case MAC_MODEL_PB180C:
954 strcat( macfb_fix.id, "TIM built-in" ); 943 strcpy(macfb_fix.id, "TIM");
955 break; 944 break;
956 945
957 /* Internal is CSC, External is Keystone+Ariel. */ 946 /* Internal is CSC, External is Keystone+Ariel. */
@@ -963,12 +952,12 @@ static int __init macfb_init(void)
963 case MAC_MODEL_PB280C: 952 case MAC_MODEL_PB280C:
964 macfb_setpalette = csc_setpalette; 953 macfb_setpalette = csc_setpalette;
965 macfb_defined.activate = FB_ACTIVATE_NOW; 954 macfb_defined.activate = FB_ACTIVATE_NOW;
966 strcat( macfb_fix.id, "CSC built-in" ); 955 strcpy(macfb_fix.id, "CSC");
967 csc_cmap_regs = ioremap(CSC_BASE, 0x1000); 956 csc_cmap_regs = ioremap(CSC_BASE, 0x1000);
968 break; 957 break;
969 958
970 default: 959 default:
971 strcat( macfb_fix.id, "Unknown/Unsupported built-in" ); 960 strcpy(macfb_fix.id, "Unknown");
972 break; 961 break;
973 } 962 }
974 963
@@ -978,16 +967,23 @@ static int __init macfb_init(void)
978 fb_info.pseudo_palette = pseudo_palette; 967 fb_info.pseudo_palette = pseudo_palette;
979 fb_info.flags = FBINFO_DEFAULT; 968 fb_info.flags = FBINFO_DEFAULT;
980 969
981 fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0); 970 err = fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0);
971 if (err)
972 goto fail_unmap;
982 973
983 err = register_framebuffer(&fb_info); 974 err = register_framebuffer(&fb_info);
984 if (!err) 975 if (err)
985 printk("fb%d: %s frame buffer device\n", 976 goto fail_dealloc;
986 fb_info.node, fb_info.fix.id); 977
987 else { 978 printk("fb%d: %s frame buffer device\n",
988 iounmap(fb_info.screen_base); 979 fb_info.node, fb_info.fix.id);
989 iounmap_macfb(); 980 return 0;
990 } 981
982fail_dealloc:
983 fb_dealloc_cmap(&fb_info.cmap);
984fail_unmap:
985 iounmap(fb_info.screen_base);
986 iounmap_macfb();
991 return err; 987 return err;
992} 988}
993 989
diff --git a/drivers/video/mb862xx/mb862xxfb.c b/drivers/video/mb862xx/mb862xxfb.c
index 38718d95fbb9..fb64234a3825 100644
--- a/drivers/video/mb862xx/mb862xxfb.c
+++ b/drivers/video/mb862xx/mb862xxfb.c
@@ -927,9 +927,9 @@ static int __devinit mb862xx_pci_probe(struct pci_dev *pdev,
927 } 927 }
928 928
929 dev_dbg(dev, "fb phys 0x%llx 0x%lx\n", 929 dev_dbg(dev, "fb phys 0x%llx 0x%lx\n",
930 (u64)par->fb_base_phys, (ulong)par->mapped_vram); 930 (unsigned long long)par->fb_base_phys, (ulong)par->mapped_vram);
931 dev_dbg(dev, "mmio phys 0x%llx 0x%lx\n", 931 dev_dbg(dev, "mmio phys 0x%llx 0x%lx\n",
932 (u64)par->mmio_base_phys, (ulong)par->mmio_len); 932 (unsigned long long)par->mmio_base_phys, (ulong)par->mmio_len);
933 933
934 if (mb862xx_pci_gdc_init(par)) 934 if (mb862xx_pci_gdc_init(par))
935 goto io_unmap; 935 goto io_unmap;
diff --git a/drivers/video/omap/Makefile b/drivers/video/omap/Makefile
index 99da8b6d2c36..ed13889c1162 100644
--- a/drivers/video/omap/Makefile
+++ b/drivers/video/omap/Makefile
@@ -23,7 +23,6 @@ objs-y$(CONFIG_MACH_OMAP_PALMZ71) += lcd_palmz71.o
23objs-$(CONFIG_ARCH_OMAP16XX)$(CONFIG_MACH_OMAP_INNOVATOR) += lcd_inn1610.o 23objs-$(CONFIG_ARCH_OMAP16XX)$(CONFIG_MACH_OMAP_INNOVATOR) += lcd_inn1610.o
24objs-$(CONFIG_ARCH_OMAP15XX)$(CONFIG_MACH_OMAP_INNOVATOR) += lcd_inn1510.o 24objs-$(CONFIG_ARCH_OMAP15XX)$(CONFIG_MACH_OMAP_INNOVATOR) += lcd_inn1510.o
25objs-y$(CONFIG_MACH_OMAP_OSK) += lcd_osk.o 25objs-y$(CONFIG_MACH_OMAP_OSK) += lcd_osk.o
26objs-y$(CONFIG_MACH_SX1) += lcd_sx1.o
27 26
28omapfb-objs := $(objs-yy) 27omapfb-objs := $(objs-yy)
29 28
diff --git a/drivers/video/omap/lcd_sx1.c b/drivers/video/omap/lcd_sx1.c
deleted file mode 100644
index e55de201b8ff..000000000000
--- a/drivers/video/omap/lcd_sx1.c
+++ /dev/null
@@ -1,327 +0,0 @@
1/*
2 * LCD panel support for the Siemens SX1 mobile phone
3 *
4 * Current version : Vovan888@gmail.com, great help from FCA00000
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/delay.h>
24#include <linux/io.h>
25
26#include <mach/gpio.h>
27#include <mach/omapfb.h>
28#include <mach/mcbsp.h>
29#include <mach/mux.h>
30
31/*
32 * OMAP310 GPIO registers
33 */
34#define GPIO_DATA_INPUT 0xfffce000
35#define GPIO_DATA_OUTPUT 0xfffce004
36#define GPIO_DIR_CONTROL 0xfffce008
37#define GPIO_INT_CONTROL 0xfffce00c
38#define GPIO_INT_MASK 0xfffce010
39#define GPIO_INT_STATUS 0xfffce014
40#define GPIO_PIN_CONTROL 0xfffce018
41
42
43#define A_LCD_SSC_RD 3
44#define A_LCD_SSC_SD 7
45#define _A_LCD_RESET 9
46#define _A_LCD_SSC_CS 12
47#define _A_LCD_SSC_A0 13
48
49#define DSP_REG 0xE1017024
50
51const unsigned char INIT_1[12] = {
52 0x1C, 0x02, 0x88, 0x00, 0x1E, 0xE0, 0x00, 0xDC, 0x00, 0x02, 0x00
53};
54
55const unsigned char INIT_2[127] = {
56 0x15, 0x00, 0x29, 0x00, 0x3E, 0x00, 0x51, 0x00,
57 0x65, 0x00, 0x7A, 0x00, 0x8D, 0x00, 0xA1, 0x00,
58 0xB6, 0x00, 0xC7, 0x00, 0xD8, 0x00, 0xEB, 0x00,
59 0xFB, 0x00, 0x0B, 0x01, 0x1B, 0x01, 0x27, 0x01,
60 0x34, 0x01, 0x41, 0x01, 0x4C, 0x01, 0x55, 0x01,
61 0x5F, 0x01, 0x68, 0x01, 0x70, 0x01, 0x78, 0x01,
62 0x7E, 0x01, 0x86, 0x01, 0x8C, 0x01, 0x94, 0x01,
63 0x9B, 0x01, 0xA1, 0x01, 0xA4, 0x01, 0xA9, 0x01,
64 0xAD, 0x01, 0xB2, 0x01, 0xB7, 0x01, 0xBC, 0x01,
65 0xC0, 0x01, 0xC4, 0x01, 0xC8, 0x01, 0xCB, 0x01,
66 0xCF, 0x01, 0xD2, 0x01, 0xD5, 0x01, 0xD8, 0x01,
67 0xDB, 0x01, 0xE0, 0x01, 0xE3, 0x01, 0xE6, 0x01,
68 0xE8, 0x01, 0xEB, 0x01, 0xEE, 0x01, 0xF1, 0x01,
69 0xF3, 0x01, 0xF8, 0x01, 0xF9, 0x01, 0xFC, 0x01,
70 0x00, 0x02, 0x03, 0x02, 0x07, 0x02, 0x09, 0x02,
71 0x0E, 0x02, 0x13, 0x02, 0x1C, 0x02, 0x00
72};
73
74const unsigned char INIT_3[15] = {
75 0x14, 0x26, 0x33, 0x3D, 0x45, 0x4D, 0x53, 0x59,
76 0x5E, 0x63, 0x67, 0x6D, 0x71, 0x78, 0xFF
77};
78
79static void epson_sendbyte(int flag, unsigned char byte)
80{
81 int i, shifter = 0x80;
82
83 if (!flag)
84 gpio_set_value(_A_LCD_SSC_A0, 0);
85 mdelay(2);
86 gpio_set_value(A_LCD_SSC_RD, 1);
87
88 gpio_set_value(A_LCD_SSC_SD, flag);
89
90 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2200);
91 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2202);
92 for (i = 0; i < 8; i++) {
93 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2200);
94 gpio_set_value(A_LCD_SSC_SD, shifter & byte);
95 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2202);
96 shifter >>= 1;
97 }
98 gpio_set_value(_A_LCD_SSC_A0, 1);
99}
100
101static void init_system(void)
102{
103 omap_mcbsp_request(OMAP_MCBSP3);
104 omap_mcbsp_stop(OMAP_MCBSP3);
105}
106
107static void setup_GPIO(void)
108{
109 /* new wave */
110 gpio_request(A_LCD_SSC_RD, "lcd_ssc_rd");
111 gpio_request(A_LCD_SSC_SD, "lcd_ssc_sd");
112 gpio_request(_A_LCD_RESET, "lcd_reset");
113 gpio_request(_A_LCD_SSC_CS, "lcd_ssc_cs");
114 gpio_request(_A_LCD_SSC_A0, "lcd_ssc_a0");
115
116 /* set GPIOs to output, with initial data */
117 gpio_direction_output(A_LCD_SSC_RD, 1);
118 gpio_direction_output(A_LCD_SSC_SD, 0);
119 gpio_direction_output(_A_LCD_RESET, 0);
120 gpio_direction_output(_A_LCD_SSC_CS, 1);
121 gpio_direction_output(_A_LCD_SSC_A0, 1);
122}
123
124static void display_init(void)
125{
126 int i;
127
128 omap_cfg_reg(MCBSP3_CLKX);
129
130 mdelay(2);
131 setup_GPIO();
132 mdelay(2);
133
134 /* reset LCD */
135 gpio_set_value(A_LCD_SSC_SD, 1);
136 epson_sendbyte(0, 0x25);
137
138 gpio_set_value(_A_LCD_RESET, 0);
139 mdelay(10);
140 gpio_set_value(_A_LCD_RESET, 1);
141
142 gpio_set_value(_A_LCD_SSC_CS, 1);
143 mdelay(2);
144 gpio_set_value(_A_LCD_SSC_CS, 0);
145
146 /* init LCD, phase 1 */
147 epson_sendbyte(0, 0xCA);
148 for (i = 0; i < 10; i++)
149 epson_sendbyte(1, INIT_1[i]);
150 gpio_set_value(_A_LCD_SSC_CS, 1);
151 gpio_set_value(_A_LCD_SSC_CS, 0);
152
153 /* init LCD phase 2 */
154 epson_sendbyte(0, 0xCB);
155 for (i = 0; i < 125; i++)
156 epson_sendbyte(1, INIT_2[i]);
157 gpio_set_value(_A_LCD_SSC_CS, 1);
158 gpio_set_value(_A_LCD_SSC_CS, 0);
159
160 /* init LCD phase 2a */
161 epson_sendbyte(0, 0xCC);
162 for (i = 0; i < 14; i++)
163 epson_sendbyte(1, INIT_3[i]);
164 gpio_set_value(_A_LCD_SSC_CS, 1);
165 gpio_set_value(_A_LCD_SSC_CS, 0);
166
167 /* init LCD phase 3 */
168 epson_sendbyte(0, 0xBC);
169 epson_sendbyte(1, 0x08);
170 gpio_set_value(_A_LCD_SSC_CS, 1);
171 gpio_set_value(_A_LCD_SSC_CS, 0);
172
173 /* init LCD phase 4 */
174 epson_sendbyte(0, 0x07);
175 epson_sendbyte(1, 0x05);
176 gpio_set_value(_A_LCD_SSC_CS, 1);
177 gpio_set_value(_A_LCD_SSC_CS, 0);
178
179 /* init LCD phase 5 */
180 epson_sendbyte(0, 0x94);
181 gpio_set_value(_A_LCD_SSC_CS, 1);
182 gpio_set_value(_A_LCD_SSC_CS, 0);
183
184 /* init LCD phase 6 */
185 epson_sendbyte(0, 0xC6);
186 epson_sendbyte(1, 0x80);
187 gpio_set_value(_A_LCD_SSC_CS, 1);
188 mdelay(100); /* used to be 1000 */
189 gpio_set_value(_A_LCD_SSC_CS, 0);
190
191 /* init LCD phase 7 */
192 epson_sendbyte(0, 0x16);
193 epson_sendbyte(1, 0x02);
194 epson_sendbyte(1, 0x00);
195 epson_sendbyte(1, 0xB1);
196 epson_sendbyte(1, 0x00);
197 gpio_set_value(_A_LCD_SSC_CS, 1);
198 gpio_set_value(_A_LCD_SSC_CS, 0);
199
200 /* init LCD phase 8 */
201 epson_sendbyte(0, 0x76);
202 epson_sendbyte(1, 0x00);
203 epson_sendbyte(1, 0x00);
204 epson_sendbyte(1, 0xDB);
205 epson_sendbyte(1, 0x00);
206 gpio_set_value(_A_LCD_SSC_CS, 1);
207 gpio_set_value(_A_LCD_SSC_CS, 0);
208
209 /* init LCD phase 9 */
210 epson_sendbyte(0, 0xAF);
211 gpio_set_value(_A_LCD_SSC_CS, 1);
212}
213
214static int sx1_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
215{
216 return 0;
217}
218
219static void sx1_panel_cleanup(struct lcd_panel *panel)
220{
221}
222
223static void sx1_panel_disable(struct lcd_panel *panel)
224{
225 printk(KERN_INFO "SX1: LCD panel disable\n");
226 sx1_setmmipower(0);
227 gpio_set_value(_A_LCD_SSC_CS, 1);
228
229 epson_sendbyte(0, 0x25);
230 gpio_set_value(_A_LCD_SSC_CS, 0);
231
232 epson_sendbyte(0, 0xAE);
233 gpio_set_value(_A_LCD_SSC_CS, 1);
234 mdelay(100);
235 gpio_set_value(_A_LCD_SSC_CS, 0);
236
237 epson_sendbyte(0, 0x95);
238 gpio_set_value(_A_LCD_SSC_CS, 1);
239}
240
241static int sx1_panel_enable(struct lcd_panel *panel)
242{
243 printk(KERN_INFO "lcd_sx1: LCD panel enable\n");
244 init_system();
245 display_init();
246
247 sx1_setmmipower(1);
248 sx1_setbacklight(0x18);
249 sx1_setkeylight (0x06);
250 return 0;
251}
252
253
254static unsigned long sx1_panel_get_caps(struct lcd_panel *panel)
255{
256 return 0;
257}
258
259struct lcd_panel sx1_panel = {
260 .name = "sx1",
261 .config = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
262 OMAP_LCDC_INV_HSYNC | OMAP_LCDC_INV_PIX_CLOCK |
263 OMAP_LCDC_INV_OUTPUT_EN,
264
265 .x_res = 176,
266 .y_res = 220,
267 .data_lines = 16,
268 .bpp = 16,
269 .hsw = 5,
270 .hfp = 5,
271 .hbp = 5,
272 .vsw = 2,
273 .vfp = 1,
274 .vbp = 1,
275 .pixel_clock = 1500,
276
277 .init = sx1_panel_init,
278 .cleanup = sx1_panel_cleanup,
279 .enable = sx1_panel_enable,
280 .disable = sx1_panel_disable,
281 .get_caps = sx1_panel_get_caps,
282};
283
284static int sx1_panel_probe(struct platform_device *pdev)
285{
286 omapfb_register_panel(&sx1_panel);
287 return 0;
288}
289
290static int sx1_panel_remove(struct platform_device *pdev)
291{
292 return 0;
293}
294
295static int sx1_panel_suspend(struct platform_device *pdev, pm_message_t mesg)
296{
297 return 0;
298}
299
300static int sx1_panel_resume(struct platform_device *pdev)
301{
302 return 0;
303}
304
305struct platform_driver sx1_panel_driver = {
306 .probe = sx1_panel_probe,
307 .remove = sx1_panel_remove,
308 .suspend = sx1_panel_suspend,
309 .resume = sx1_panel_resume,
310 .driver = {
311 .name = "lcd_sx1",
312 .owner = THIS_MODULE,
313 },
314};
315
316static int sx1_panel_drv_init(void)
317{
318 return platform_driver_register(&sx1_panel_driver);
319}
320
321static void sx1_panel_drv_cleanup(void)
322{
323 platform_driver_unregister(&sx1_panel_driver);
324}
325
326module_init(sx1_panel_drv_init);
327module_exit(sx1_panel_drv_cleanup);
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
index 5a5e407dc45f..1a49519dafa4 100644
--- a/drivers/video/omap/omapfb_main.c
+++ b/drivers/video/omap/omapfb_main.c
@@ -392,7 +392,7 @@ static void set_fb_fix(struct fb_info *fbi)
392 int bpp; 392 int bpp;
393 393
394 rg = &plane->fbdev->mem_desc.region[plane->idx]; 394 rg = &plane->fbdev->mem_desc.region[plane->idx];
395 fbi->screen_base = (char __iomem *)rg->vaddr; 395 fbi->screen_base = rg->vaddr;
396 fix->smem_start = rg->paddr; 396 fix->smem_start = rg->paddr;
397 fix->smem_len = rg->size; 397 fix->smem_len = rg->size;
398 398
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index a463b3dd837b..2493f05e9f61 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -668,7 +668,7 @@ static struct xenbus_device_id xenfb_ids[] = {
668 { "" } 668 { "" }
669}; 669};
670 670
671static struct xenbus_driver xenfb = { 671static struct xenbus_driver xenfb_driver = {
672 .name = "vfb", 672 .name = "vfb",
673 .owner = THIS_MODULE, 673 .owner = THIS_MODULE,
674 .ids = xenfb_ids, 674 .ids = xenfb_ids,
@@ -687,12 +687,12 @@ static int __init xenfb_init(void)
687 if (xen_initial_domain()) 687 if (xen_initial_domain())
688 return -ENODEV; 688 return -ENODEV;
689 689
690 return xenbus_register_frontend(&xenfb); 690 return xenbus_register_frontend(&xenfb_driver);
691} 691}
692 692
693static void __exit xenfb_cleanup(void) 693static void __exit xenfb_cleanup(void)
694{ 694{
695 xenbus_unregister_driver(&xenfb); 695 xenbus_unregister_driver(&xenfb_driver);
696} 696}
697 697
698module_init(xenfb_init); 698module_init(xenfb_init);
diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index 5da3d2423cc0..40a3a2afbfe7 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -298,8 +298,9 @@ static int xilinxfb_assign(struct device *dev, unsigned long physaddr,
298 298
299 /* Put a banner in the log (for DEBUG) */ 299 /* Put a banner in the log (for DEBUG) */
300 dev_dbg(dev, "regs: phys=%lx, virt=%p\n", physaddr, drvdata->regs); 300 dev_dbg(dev, "regs: phys=%lx, virt=%p\n", physaddr, drvdata->regs);
301 dev_dbg(dev, "fb: phys=%p, virt=%p, size=%x\n", 301 dev_dbg(dev, "fb: phys=%llx, virt=%p, size=%x\n",
302 (void*)drvdata->fb_phys, drvdata->fb_virt, fbsize); 302 (unsigned long long) drvdata->fb_phys, drvdata->fb_virt,
303 fbsize);
303 304
304 return 0; /* success */ 305 return 0; /* success */
305 306
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig
index a14d5b6e4c7c..90616822cd20 100644
--- a/drivers/w1/masters/Kconfig
+++ b/drivers/w1/masters/Kconfig
@@ -36,7 +36,7 @@ config W1_MASTER_DS2482
36 36
37config W1_MASTER_DS1WM 37config W1_MASTER_DS1WM
38 tristate "Maxim DS1WM 1-wire busmaster" 38 tristate "Maxim DS1WM 1-wire busmaster"
39 depends on W1 && ARM 39 depends on W1 && ARM && HAVE_CLK
40 help 40 help
41 Say Y here to enable the DS1WM 1-wire driver, such as that 41 Say Y here to enable the DS1WM 1-wire driver, such as that
42 in HP iPAQ devices like h5xxx, h2200, and ASIC3-based like 42 in HP iPAQ devices like h5xxx, h2200, and ASIC3-based like
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 0d15b0eaf79a..5139c25ca962 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -356,7 +356,9 @@ int w1_reset_select_slave(struct w1_slave *sl)
356 w1_write_8(sl->master, W1_SKIP_ROM); 356 w1_write_8(sl->master, W1_SKIP_ROM);
357 else { 357 else {
358 u8 match[9] = {W1_MATCH_ROM, }; 358 u8 match[9] = {W1_MATCH_ROM, };
359 memcpy(&match[1], (u8 *)&sl->reg_num, 8); 359 u64 rn = le64_to_cpu(*((u64*)&sl->reg_num));
360
361 memcpy(&match[1], &rn, 8);
360 w1_write_block(sl->master, match, 9); 362 w1_write_block(sl->master, match, 9);
361 } 363 }
362 return 0; 364 return 0;
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index a3765e0be4a8..763c1ea5dce5 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -40,6 +40,7 @@
40#include <linux/bootmem.h> 40#include <linux/bootmem.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <asm/desc.h> 42#include <asm/desc.h>
43#include <asm/cacheflush.h>
43 44
44#define PCI_BIOS32_SD_VALUE 0x5F32335F /* "_32_" */ 45#define PCI_BIOS32_SD_VALUE 0x5F32335F /* "_32_" */
45#define CRU_BIOS_SIGNATURE_VALUE 0x55524324 46#define CRU_BIOS_SIGNATURE_VALUE 0x55524324
@@ -394,6 +395,8 @@ static void __devinit dmi_find_cru(const struct dmi_header *dm)
394 smbios_cru64_ptr->double_offset; 395 smbios_cru64_ptr->double_offset;
395 cru_rom_addr = ioremap(cru_physical_address, 396 cru_rom_addr = ioremap(cru_physical_address,
396 smbios_cru64_ptr->double_length); 397 smbios_cru64_ptr->double_length);
398 set_memory_x((unsigned long)cru_rom_addr & PAGE_MASK,
399 smbios_cru64_ptr->double_length >> PAGE_SHIFT);
397 } 400 }
398 } 401 }
399} 402}
@@ -482,7 +485,7 @@ static int hpwdt_pretimeout(struct notifier_block *nb, unsigned long ulReason,
482 "Management Log for details.\n"); 485 "Management Log for details.\n");
483 } 486 }
484 487
485 return NOTIFY_STOP; 488 return NOTIFY_OK;
486} 489}
487 490
488/* 491/*
diff --git a/drivers/watchdog/iTCO_vendor_support.c b/drivers/watchdog/iTCO_vendor_support.c
index ca344a85eb95..2474ebca88f6 100644
--- a/drivers/watchdog/iTCO_vendor_support.c
+++ b/drivers/watchdog/iTCO_vendor_support.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * intel TCO vendor specific watchdog driver support 2 * intel TCO vendor specific watchdog driver support
3 * 3 *
4 * (c) Copyright 2006 Wim Van Sebroeck <wim@iguana.be>. 4 * (c) Copyright 2006-2008 Wim Van Sebroeck <wim@iguana.be>.
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -19,8 +19,7 @@
19 19
20/* Module and version information */ 20/* Module and version information */
21#define DRV_NAME "iTCO_vendor_support" 21#define DRV_NAME "iTCO_vendor_support"
22#define DRV_VERSION "1.01" 22#define DRV_VERSION "1.02"
23#define DRV_RELDATE "11-Nov-2006"
24#define PFX DRV_NAME ": " 23#define PFX DRV_NAME ": "
25 24
26/* Includes */ 25/* Includes */
@@ -78,24 +77,6 @@ MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default=0 (n
78 * 20.6 seconds. 77 * 20.6 seconds.
79 */ 78 */
80 79
81static void supermicro_old_pre_start(unsigned long acpibase)
82{
83 unsigned long val32;
84
85 val32 = inl(SMI_EN);
86 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
87 outl(val32, SMI_EN); /* Needed to activate watchdog */
88}
89
90static void supermicro_old_pre_stop(unsigned long acpibase)
91{
92 unsigned long val32;
93
94 val32 = inl(SMI_EN);
95 val32 &= 0x00002000; /* Turn on SMI clearing watchdog */
96 outl(val32, SMI_EN); /* Needed to deactivate watchdog */
97}
98
99static void supermicro_old_pre_keepalive(unsigned long acpibase) 80static void supermicro_old_pre_keepalive(unsigned long acpibase)
100{ 81{
101 /* Reload TCO Timer (done in iTCO_wdt_keepalive) + */ 82 /* Reload TCO Timer (done in iTCO_wdt_keepalive) + */
@@ -247,18 +228,14 @@ static void supermicro_new_pre_set_heartbeat(unsigned int heartbeat)
247void iTCO_vendor_pre_start(unsigned long acpibase, 228void iTCO_vendor_pre_start(unsigned long acpibase,
248 unsigned int heartbeat) 229 unsigned int heartbeat)
249{ 230{
250 if (vendorsupport == SUPERMICRO_OLD_BOARD) 231 if (vendorsupport == SUPERMICRO_NEW_BOARD)
251 supermicro_old_pre_start(acpibase);
252 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
253 supermicro_new_pre_start(heartbeat); 232 supermicro_new_pre_start(heartbeat);
254} 233}
255EXPORT_SYMBOL(iTCO_vendor_pre_start); 234EXPORT_SYMBOL(iTCO_vendor_pre_start);
256 235
257void iTCO_vendor_pre_stop(unsigned long acpibase) 236void iTCO_vendor_pre_stop(unsigned long acpibase)
258{ 237{
259 if (vendorsupport == SUPERMICRO_OLD_BOARD) 238 if (vendorsupport == SUPERMICRO_NEW_BOARD)
260 supermicro_old_pre_stop(acpibase);
261 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
262 supermicro_new_pre_stop(); 239 supermicro_new_pre_stop();
263} 240}
264EXPORT_SYMBOL(iTCO_vendor_pre_stop); 241EXPORT_SYMBOL(iTCO_vendor_pre_stop);
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index bfb93bc2ca9f..5b395a4ddfdf 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * intel TCO Watchdog Driver (Used in i82801 and i6300ESB chipsets) 2 * intel TCO Watchdog Driver (Used in i82801 and i6300ESB chipsets)
3 * 3 *
4 * (c) Copyright 2006-2007 Wim Van Sebroeck <wim@iguana.be>. 4 * (c) Copyright 2006-2008 Wim Van Sebroeck <wim@iguana.be>.
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -20,34 +20,41 @@
20 * 82801BAM (ICH2-M) : document number 290687-002, 298242-027, 20 * 82801BAM (ICH2-M) : document number 290687-002, 298242-027,
21 * 82801CA (ICH3-S) : document number 290733-003, 290739-013, 21 * 82801CA (ICH3-S) : document number 290733-003, 290739-013,
22 * 82801CAM (ICH3-M) : document number 290716-001, 290718-007, 22 * 82801CAM (ICH3-M) : document number 290716-001, 290718-007,
23 * 82801DB (ICH4) : document number 290744-001, 290745-020, 23 * 82801DB (ICH4) : document number 290744-001, 290745-025,
24 * 82801DBM (ICH4-M) : document number 252337-001, 252663-005, 24 * 82801DBM (ICH4-M) : document number 252337-001, 252663-008,
25 * 82801E (C-ICH) : document number 273599-001, 273645-002, 25 * 82801E (C-ICH) : document number 273599-001, 273645-002,
26 * 82801EB (ICH5) : document number 252516-001, 252517-003, 26 * 82801EB (ICH5) : document number 252516-001, 252517-028,
27 * 82801ER (ICH5R) : document number 252516-001, 252517-003, 27 * 82801ER (ICH5R) : document number 252516-001, 252517-028,
28 * 82801FB (ICH6) : document number 301473-002, 301474-007, 28 * 6300ESB (6300ESB) : document number 300641-004, 300884-013,
29 * 82801FR (ICH6R) : document number 301473-002, 301474-007, 29 * 82801FB (ICH6) : document number 301473-002, 301474-026,
30 * 82801FBM (ICH6-M) : document number 301473-002, 301474-007, 30 * 82801FR (ICH6R) : document number 301473-002, 301474-026,
31 * 82801FW (ICH6W) : document number 301473-001, 301474-007, 31 * 82801FBM (ICH6-M) : document number 301473-002, 301474-026,
32 * 82801FRW (ICH6RW) : document number 301473-001, 301474-007, 32 * 82801FW (ICH6W) : document number 301473-001, 301474-026,
33 * 82801GB (ICH7) : document number 307013-002, 307014-009, 33 * 82801FRW (ICH6RW) : document number 301473-001, 301474-026,
34 * 82801GR (ICH7R) : document number 307013-002, 307014-009, 34 * 631xESB (631xESB) : document number 313082-001, 313075-006,
35 * 82801GDH (ICH7DH) : document number 307013-002, 307014-009, 35 * 632xESB (632xESB) : document number 313082-001, 313075-006,
36 * 82801GBM (ICH7-M) : document number 307013-002, 307014-009, 36 * 82801GB (ICH7) : document number 307013-003, 307014-024,
37 * 82801GHM (ICH7-M DH) : document number 307013-002, 307014-009, 37 * 82801GR (ICH7R) : document number 307013-003, 307014-024,
38 * 82801HB (ICH8) : document number 313056-003, 313057-009, 38 * 82801GDH (ICH7DH) : document number 307013-003, 307014-024,
39 * 82801HR (ICH8R) : document number 313056-003, 313057-009, 39 * 82801GBM (ICH7-M) : document number 307013-003, 307014-024,
40 * 82801HBM (ICH8M) : document number 313056-003, 313057-009, 40 * 82801GHM (ICH7-M DH) : document number 307013-003, 307014-024,
41 * 82801HH (ICH8DH) : document number 313056-003, 313057-009, 41 * 82801GU (ICH7-U) : document number 307013-003, 307014-024,
42 * 82801HO (ICH8DO) : document number 313056-003, 313057-009, 42 * 82801HB (ICH8) : document number 313056-003, 313057-017,
43 * 82801HEM (ICH8M-E) : document number 313056-003, 313057-009, 43 * 82801HR (ICH8R) : document number 313056-003, 313057-017,
44 * 82801IB (ICH9) : document number 316972-001, 316973-006, 44 * 82801HBM (ICH8M) : document number 313056-003, 313057-017,
45 * 82801IR (ICH9R) : document number 316972-001, 316973-006, 45 * 82801HH (ICH8DH) : document number 313056-003, 313057-017,
46 * 82801IH (ICH9DH) : document number 316972-001, 316973-006, 46 * 82801HO (ICH8DO) : document number 313056-003, 313057-017,
47 * 82801IO (ICH9DO) : document number 316972-001, 316973-006, 47 * 82801HEM (ICH8M-E) : document number 313056-003, 313057-017,
48 * 6300ESB (6300ESB) : document number 300641-003, 300884-010, 48 * 82801IB (ICH9) : document number 316972-004, 316973-012,
49 * 631xESB (631xESB) : document number 313082-001, 313075-005, 49 * 82801IR (ICH9R) : document number 316972-004, 316973-012,
50 * 632xESB (632xESB) : document number 313082-001, 313075-005 50 * 82801IH (ICH9DH) : document number 316972-004, 316973-012,
51 * 82801IO (ICH9DO) : document number 316972-004, 316973-012,
52 * 82801IBM (ICH9M) : document number 316972-004, 316973-012,
53 * 82801IEM (ICH9M-E) : document number 316972-004, 316973-012,
54 * 82801JIB (ICH10) : document number 319973-002, 319974-002,
55 * 82801JIR (ICH10R) : document number 319973-002, 319974-002,
56 * 82801JD (ICH10D) : document number 319973-002, 319974-002,
57 * 82801JDO (ICH10DO) : document number 319973-002, 319974-002
51 */ 58 */
52 59
53/* 60/*
@@ -56,8 +63,7 @@
56 63
57/* Module and version information */ 64/* Module and version information */
58#define DRV_NAME "iTCO_wdt" 65#define DRV_NAME "iTCO_wdt"
59#define DRV_VERSION "1.03" 66#define DRV_VERSION "1.04"
60#define DRV_RELDATE "30-Apr-2008"
61#define PFX DRV_NAME ": " 67#define PFX DRV_NAME ": "
62 68
63/* Includes */ 69/* Includes */
@@ -96,19 +102,26 @@ enum iTCO_chipsets {
96 TCO_ICH6, /* ICH6 & ICH6R */ 102 TCO_ICH6, /* ICH6 & ICH6R */
97 TCO_ICH6M, /* ICH6-M */ 103 TCO_ICH6M, /* ICH6-M */
98 TCO_ICH6W, /* ICH6W & ICH6RW */ 104 TCO_ICH6W, /* ICH6W & ICH6RW */
105 TCO_631XESB, /* 631xESB/632xESB */
99 TCO_ICH7, /* ICH7 & ICH7R */ 106 TCO_ICH7, /* ICH7 & ICH7R */
100 TCO_ICH7M, /* ICH7-M */ 107 TCO_ICH7DH, /* ICH7DH */
108 TCO_ICH7M, /* ICH7-M & ICH7-U */
101 TCO_ICH7MDH, /* ICH7-M DH */ 109 TCO_ICH7MDH, /* ICH7-M DH */
102 TCO_ICH8, /* ICH8 & ICH8R */ 110 TCO_ICH8, /* ICH8 & ICH8R */
103 TCO_ICH8ME, /* ICH8M-E */
104 TCO_ICH8DH, /* ICH8DH */ 111 TCO_ICH8DH, /* ICH8DH */
105 TCO_ICH8DO, /* ICH8DO */ 112 TCO_ICH8DO, /* ICH8DO */
106 TCO_ICH8M, /* ICH8M */ 113 TCO_ICH8M, /* ICH8M */
114 TCO_ICH8ME, /* ICH8M-E */
107 TCO_ICH9, /* ICH9 */ 115 TCO_ICH9, /* ICH9 */
108 TCO_ICH9R, /* ICH9R */ 116 TCO_ICH9R, /* ICH9R */
109 TCO_ICH9DH, /* ICH9DH */ 117 TCO_ICH9DH, /* ICH9DH */
110 TCO_ICH9DO, /* ICH9DO */ 118 TCO_ICH9DO, /* ICH9DO */
111 TCO_631XESB, /* 631xESB/632xESB */ 119 TCO_ICH9M, /* ICH9M */
120 TCO_ICH9ME, /* ICH9M-E */
121 TCO_ICH10, /* ICH10 */
122 TCO_ICH10R, /* ICH10R */
123 TCO_ICH10D, /* ICH10D */
124 TCO_ICH10DO, /* ICH10DO */
112}; 125};
113 126
114static struct { 127static struct {
@@ -129,19 +142,26 @@ static struct {
129 {"ICH6 or ICH6R", 2}, 142 {"ICH6 or ICH6R", 2},
130 {"ICH6-M", 2}, 143 {"ICH6-M", 2},
131 {"ICH6W or ICH6RW", 2}, 144 {"ICH6W or ICH6RW", 2},
145 {"631xESB/632xESB", 2},
132 {"ICH7 or ICH7R", 2}, 146 {"ICH7 or ICH7R", 2},
133 {"ICH7-M", 2}, 147 {"ICH7DH", 2},
148 {"ICH7-M or ICH7-U", 2},
134 {"ICH7-M DH", 2}, 149 {"ICH7-M DH", 2},
135 {"ICH8 or ICH8R", 2}, 150 {"ICH8 or ICH8R", 2},
136 {"ICH8M-E", 2},
137 {"ICH8DH", 2}, 151 {"ICH8DH", 2},
138 {"ICH8DO", 2}, 152 {"ICH8DO", 2},
139 {"ICH8M", 2}, 153 {"ICH8M", 2},
154 {"ICH8M-E", 2},
140 {"ICH9", 2}, 155 {"ICH9", 2},
141 {"ICH9R", 2}, 156 {"ICH9R", 2},
142 {"ICH9DH", 2}, 157 {"ICH9DH", 2},
143 {"ICH9DO", 2}, 158 {"ICH9DO", 2},
144 {"631xESB/632xESB", 2}, 159 {"ICH9M", 2},
160 {"ICH9M-E", 2},
161 {"ICH10", 2},
162 {"ICH10R", 2},
163 {"ICH10D", 2},
164 {"ICH10DO", 2},
145 {NULL, 0} 165 {NULL, 0}
146}; 166};
147 167
@@ -175,18 +195,6 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = {
175 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_0, TCO_ICH6)}, 195 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_0, TCO_ICH6)},
176 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_1, TCO_ICH6M)}, 196 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_1, TCO_ICH6M)},
177 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_2, TCO_ICH6W)}, 197 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_2, TCO_ICH6W)},
178 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_0, TCO_ICH7)},
179 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_1, TCO_ICH7M)},
180 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_31, TCO_ICH7MDH)},
181 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_0, TCO_ICH8)},
182 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_1, TCO_ICH8ME)},
183 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_2, TCO_ICH8DH)},
184 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_3, TCO_ICH8DO)},
185 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_4, TCO_ICH8M)},
186 { ITCO_PCI_DEVICE(0x2918, TCO_ICH9)},
187 { ITCO_PCI_DEVICE(0x2916, TCO_ICH9R)},
188 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH9_2, TCO_ICH9DH)},
189 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH9_4, TCO_ICH9DO)},
190 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ESB2_0, TCO_631XESB)}, 198 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ESB2_0, TCO_631XESB)},
191 { ITCO_PCI_DEVICE(0x2671, TCO_631XESB)}, 199 { ITCO_PCI_DEVICE(0x2671, TCO_631XESB)},
192 { ITCO_PCI_DEVICE(0x2672, TCO_631XESB)}, 200 { ITCO_PCI_DEVICE(0x2672, TCO_631XESB)},
@@ -203,6 +211,25 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = {
203 { ITCO_PCI_DEVICE(0x267d, TCO_631XESB)}, 211 { ITCO_PCI_DEVICE(0x267d, TCO_631XESB)},
204 { ITCO_PCI_DEVICE(0x267e, TCO_631XESB)}, 212 { ITCO_PCI_DEVICE(0x267e, TCO_631XESB)},
205 { ITCO_PCI_DEVICE(0x267f, TCO_631XESB)}, 213 { ITCO_PCI_DEVICE(0x267f, TCO_631XESB)},
214 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_0, TCO_ICH7)},
215 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_30, TCO_ICH7DH)},
216 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_1, TCO_ICH7M)},
217 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_31, TCO_ICH7MDH)},
218 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_0, TCO_ICH8)},
219 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_2, TCO_ICH8DH)},
220 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_3, TCO_ICH8DO)},
221 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_4, TCO_ICH8M)},
222 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_1, TCO_ICH8ME)},
223 { ITCO_PCI_DEVICE(0x2918, TCO_ICH9)},
224 { ITCO_PCI_DEVICE(0x2916, TCO_ICH9R)},
225 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH9_2, TCO_ICH9DH)},
226 { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH9_4, TCO_ICH9DO)},
227 { ITCO_PCI_DEVICE(0x2919, TCO_ICH9M)},
228 { ITCO_PCI_DEVICE(0x2917, TCO_ICH9ME)},
229 { ITCO_PCI_DEVICE(0x3a18, TCO_ICH10)},
230 { ITCO_PCI_DEVICE(0x3a16, TCO_ICH10R)},
231 { ITCO_PCI_DEVICE(0x3a1a, TCO_ICH10D)},
232 { ITCO_PCI_DEVICE(0x3a14, TCO_ICH10DO)},
206 { 0, }, /* End of list */ 233 { 0, }, /* End of list */
207}; 234};
208MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl); 235MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
@@ -311,6 +338,7 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
311static int iTCO_wdt_start(void) 338static int iTCO_wdt_start(void)
312{ 339{
313 unsigned int val; 340 unsigned int val;
341 unsigned long val32;
314 342
315 spin_lock(&iTCO_wdt_private.io_lock); 343 spin_lock(&iTCO_wdt_private.io_lock);
316 344
@@ -323,6 +351,18 @@ static int iTCO_wdt_start(void)
323 return -EIO; 351 return -EIO;
324 } 352 }
325 353
354 /* Bit 13: TCO_EN -> 0 = Disables TCO logic generating an SMI# */
355 val32 = inl(SMI_EN);
356 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
357 outl(val32, SMI_EN);
358
359 /* Force the timer to its reload value by writing to the TCO_RLD
360 register */
361 if (iTCO_wdt_private.iTCO_version == 2)
362 outw(0x01, TCO_RLD);
363 else if (iTCO_wdt_private.iTCO_version == 1)
364 outb(0x01, TCO_RLD);
365
326 /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled to count */ 366 /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled to count */
327 val = inw(TCO1_CNT); 367 val = inw(TCO1_CNT);
328 val &= 0xf7ff; 368 val &= 0xf7ff;
@@ -338,6 +378,7 @@ static int iTCO_wdt_start(void)
338static int iTCO_wdt_stop(void) 378static int iTCO_wdt_stop(void)
339{ 379{
340 unsigned int val; 380 unsigned int val;
381 unsigned long val32;
341 382
342 spin_lock(&iTCO_wdt_private.io_lock); 383 spin_lock(&iTCO_wdt_private.io_lock);
343 384
@@ -349,6 +390,11 @@ static int iTCO_wdt_stop(void)
349 outw(val, TCO1_CNT); 390 outw(val, TCO1_CNT);
350 val = inw(TCO1_CNT); 391 val = inw(TCO1_CNT);
351 392
393 /* Bit 13: TCO_EN -> 1 = Enables the TCO logic to generate SMI# */
394 val32 = inl(SMI_EN);
395 val32 |= 0x00002000;
396 outl(val32, SMI_EN);
397
352 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ 398 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
353 iTCO_wdt_set_NO_REBOOT_bit(); 399 iTCO_wdt_set_NO_REBOOT_bit();
354 400
@@ -459,7 +505,6 @@ static int iTCO_wdt_open(struct inode *inode, struct file *file)
459 /* 505 /*
460 * Reload and activate timer 506 * Reload and activate timer
461 */ 507 */
462 iTCO_wdt_keepalive();
463 iTCO_wdt_start(); 508 iTCO_wdt_start();
464 return nonseekable_open(inode, file); 509 return nonseekable_open(inode, file);
465} 510}
@@ -604,7 +649,6 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
604 int ret; 649 int ret;
605 u32 base_address; 650 u32 base_address;
606 unsigned long RCBA; 651 unsigned long RCBA;
607 unsigned long val32;
608 652
609 /* 653 /*
610 * Find the ACPI/PM base I/O address which is the base 654 * Find the ACPI/PM base I/O address which is the base
@@ -644,17 +688,13 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
644 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ 688 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
645 iTCO_wdt_set_NO_REBOOT_bit(); 689 iTCO_wdt_set_NO_REBOOT_bit();
646 690
647 /* Set the TCO_EN bit in SMI_EN register */ 691 /* The TCO logic uses the TCO_EN bit in the SMI_EN register */
648 if (!request_region(SMI_EN, 4, "iTCO_wdt")) { 692 if (!request_region(SMI_EN, 4, "iTCO_wdt")) {
649 printk(KERN_ERR PFX 693 printk(KERN_ERR PFX
650 "I/O address 0x%04lx already in use\n", SMI_EN); 694 "I/O address 0x%04lx already in use\n", SMI_EN);
651 ret = -EIO; 695 ret = -EIO;
652 goto out; 696 goto out;
653 } 697 }
654 val32 = inl(SMI_EN);
655 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
656 outl(val32, SMI_EN);
657 release_region(SMI_EN, 4);
658 698
659 /* The TCO I/O registers reside in a 32-byte range pointed to 699 /* The TCO I/O registers reside in a 32-byte range pointed to
660 by the TCOBASE value */ 700 by the TCOBASE value */
@@ -662,7 +702,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
662 printk(KERN_ERR PFX "I/O address 0x%04lx already in use\n", 702 printk(KERN_ERR PFX "I/O address 0x%04lx already in use\n",
663 TCOBASE); 703 TCOBASE);
664 ret = -EIO; 704 ret = -EIO;
665 goto out; 705 goto unreg_smi_en;
666 } 706 }
667 707
668 printk(KERN_INFO PFX 708 printk(KERN_INFO PFX
@@ -672,8 +712,9 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
672 TCOBASE); 712 TCOBASE);
673 713
674 /* Clear out the (probably old) status */ 714 /* Clear out the (probably old) status */
675 outb(0, TCO1_STS); 715 outb(8, TCO1_STS); /* Clear the Time Out Status bit */
676 outb(3, TCO2_STS); 716 outb(2, TCO2_STS); /* Clear SECOND_TO_STS bit */
717 outb(4, TCO2_STS); /* Clear BOOT_STS bit */
677 718
678 /* Make sure the watchdog is not running */ 719 /* Make sure the watchdog is not running */
679 iTCO_wdt_stop(); 720 iTCO_wdt_stop();
@@ -701,6 +742,8 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
701 742
702unreg_region: 743unreg_region:
703 release_region(TCOBASE, 0x20); 744 release_region(TCOBASE, 0x20);
745unreg_smi_en:
746 release_region(SMI_EN, 4);
704out: 747out:
705 if (iTCO_wdt_private.iTCO_version == 2) 748 if (iTCO_wdt_private.iTCO_version == 2)
706 iounmap(iTCO_wdt_private.gcs); 749 iounmap(iTCO_wdt_private.gcs);
@@ -718,6 +761,7 @@ static void __devexit iTCO_wdt_cleanup(void)
718 /* Deregister */ 761 /* Deregister */
719 misc_deregister(&iTCO_wdt_miscdev); 762 misc_deregister(&iTCO_wdt_miscdev);
720 release_region(TCOBASE, 0x20); 763 release_region(TCOBASE, 0x20);
764 release_region(SMI_EN, 4);
721 if (iTCO_wdt_private.iTCO_version == 2) 765 if (iTCO_wdt_private.iTCO_version == 2)
722 iounmap(iTCO_wdt_private.gcs); 766 iounmap(iTCO_wdt_private.gcs);
723 pci_dev_put(iTCO_wdt_private.pdev); 767 pci_dev_put(iTCO_wdt_private.pdev);
@@ -782,8 +826,8 @@ static int __init iTCO_wdt_init_module(void)
782{ 826{
783 int err; 827 int err;
784 828
785 printk(KERN_INFO PFX "Intel TCO WatchDog Timer Driver v%s (%s)\n", 829 printk(KERN_INFO PFX "Intel TCO WatchDog Timer Driver v%s\n",
786 DRV_VERSION, DRV_RELDATE); 830 DRV_VERSION);
787 831
788 err = platform_driver_register(&iTCO_wdt_driver); 832 err = platform_driver_register(&iTCO_wdt_driver);
789 if (err) 833 if (err)
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index b4b7b0a4c119..3acce623f209 100644
--- a/drivers/watchdog/mtx-1_wdt.c
+++ b/drivers/watchdog/mtx-1_wdt.c
@@ -98,6 +98,8 @@ static void mtx1_wdt_reset(void)
98 98
99static void mtx1_wdt_start(void) 99static void mtx1_wdt_start(void)
100{ 100{
101 unsigned long flags;
102
101 spin_lock_irqsave(&mtx1_wdt_device.lock, flags); 103 spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
102 if (!mtx1_wdt_device.queue) { 104 if (!mtx1_wdt_device.queue) {
103 mtx1_wdt_device.queue = 1; 105 mtx1_wdt_device.queue = 1;
@@ -110,6 +112,8 @@ static void mtx1_wdt_start(void)
110 112
111static int mtx1_wdt_stop(void) 113static int mtx1_wdt_stop(void)
112{ 114{
115 unsigned long flags;
116
113 spin_lock_irqsave(&mtx1_wdt_device.lock, flags); 117 spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
114 if (mtx1_wdt_device.queue) { 118 if (mtx1_wdt_device.queue) {
115 mtx1_wdt_device.queue = 0; 119 mtx1_wdt_device.queue = 0;