aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/bus.c10
-rw-r--r--drivers/acpi/power.c36
-rw-r--r--drivers/ata/ahci.c10
-rw-r--r--drivers/block/aoe/aoecmd.c1
-rw-r--r--drivers/block/cciss_scsi.c1
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c38
-rw-r--r--drivers/block/mtip32xx/mtip32xx.h10
-rw-r--r--drivers/block/nbd.c9
-rw-r--r--drivers/block/xen-blkback/blkback.c2
-rw-r--r--drivers/bluetooth/ath3k.c2
-rw-r--r--drivers/bluetooth/btusb.c12
-rw-r--r--drivers/clk/Makefile1
-rw-r--r--drivers/clk/clk-devres.c55
-rw-r--r--drivers/clk/clkdev.c45
-rw-r--r--drivers/cpufreq/powernow-k8.c63
-rw-r--r--drivers/crypto/caam/key_gen.c1
-rw-r--r--drivers/dma/at_hdmac.c13
-rw-r--r--drivers/dma/pl330.c21
-rw-r--r--drivers/edac/edac_mc.c57
-rw-r--r--drivers/extcon/extcon-max77693.c19
-rw-r--r--drivers/gpu/drm/ast/ast_drv.c3
-rw-r--r--drivers/gpu/drm/ast/ast_mode.c2
-rw-r--r--drivers/gpu/drm/cirrus/cirrus_drv.c3
-rw-r--r--drivers/gpu/drm/exynos/Kconfig2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dmabuf.c7
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_g2d.c52
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c1
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c11
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c6
-rw-r--r--drivers/gpu/drm/gma500/oaktrail_device.c2
-rw-r--r--drivers/gpu/drm/i810/i810_dma.c3
-rw-r--r--drivers/gpu/drm/i810/i810_drv.c3
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c1
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c3
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c3
-rw-r--r--drivers/gpu/drm/i915/intel_display.c18
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c11
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c2
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c31
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c3
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c15
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_drv.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv50_gpio.c16
-rw-r--r--drivers/gpu/drm/nouveau/nvd0_display.c4
-rw-r--r--drivers/gpu/drm/radeon/r100.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_fence.c8
-rw-r--r--drivers/gpu/drm/savage/savage_drv.c3
-rw-r--r--drivers/gpu/drm/sis/sis_drv.c3
-rw-r--r--drivers/gpu/drm/tdfx/tdfx_drv.c3
-rw-r--r--drivers/gpu/drm/udl/udl_drv.c3
-rw-r--r--drivers/gpu/drm/via/via_drv.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/Kconfig8
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c8
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h10
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_resource.c73
-rw-r--r--drivers/hid/hid-lenovo-tpkbd.c2
-rw-r--r--drivers/hid/hid-logitech-dj.c45
-rw-r--r--drivers/hid/hid-logitech-dj.h1
-rw-r--r--drivers/hwmon/ad7314.c8
-rw-r--r--drivers/hwmon/ads7871.c9
-rw-r--r--drivers/hwmon/applesmc.c4
-rw-r--r--drivers/hwmon/coretemp.c5
-rw-r--r--drivers/hwmon/fam15h_power.c15
-rw-r--r--drivers/hwmon/ina2xx.c30
-rw-r--r--drivers/hwmon/twl4030-madc-hwmon.c9
-rw-r--r--drivers/hwmon/via-cputemp.c5
-rw-r--r--drivers/hwspinlock/hwspinlock_core.c3
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c6
-rw-r--r--drivers/i2c/busses/Kconfig6
-rw-r--r--drivers/i2c/busses/Makefile5
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c11
-rw-r--r--drivers/i2c/busses/i2c-i801.c3
-rw-r--r--drivers/i2c/busses/i2c-mxs.c13
-rw-r--r--drivers/i2c/busses/i2c-pnx.c53
-rw-r--r--drivers/i2c/i2c-core.c22
-rw-r--r--drivers/iio/adc/at91_adc.c2
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c2
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_verbs.c8
-rw-r--r--drivers/infiniband/hw/qib/qib_mad.c3
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h5
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c93
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c2
-rw-r--r--drivers/input/keyboard/imx_keypad.c4
-rw-r--r--drivers/input/misc/ab8500-ponkey.c4
-rw-r--r--drivers/input/mouse/sentelic.c11
-rw-r--r--drivers/input/serio/ambakmi.c6
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h6
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c9
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c40
-rw-r--r--drivers/isdn/hardware/mISDN/avmfritz.c3
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c2
-rw-r--r--drivers/isdn/hardware/mISDN/mISDNipac.c3
-rw-r--r--drivers/isdn/hardware/mISDN/mISDNisar.c3
-rw-r--r--drivers/isdn/hardware/mISDN/netjet.c3
-rw-r--r--drivers/isdn/hardware/mISDN/w6692.c3
-rw-r--r--drivers/isdn/mISDN/hwchannel.c9
-rw-r--r--drivers/md/md.c6
-rw-r--r--drivers/md/raid5.c6
-rw-r--r--drivers/mfd/88pm800.c5
-rw-r--r--drivers/mfd/88pm805.c3
-rw-r--r--drivers/mfd/88pm860x-core.c21
-rw-r--r--drivers/mfd/aat2870-core.c2
-rw-r--r--drivers/mfd/ab3100-core.c2
-rw-r--r--drivers/mfd/ab8500-core.c10
-rw-r--r--drivers/mfd/arizona-core.c6
-rw-r--r--drivers/mfd/asic3.c6
-rw-r--r--drivers/mfd/cs5535-mfd.c2
-rw-r--r--drivers/mfd/da9052-core.c2
-rw-r--r--drivers/mfd/davinci_voicecodec.c2
-rw-r--r--drivers/mfd/db8500-prcmu.c2
-rw-r--r--drivers/mfd/htc-pasic3.c5
-rw-r--r--drivers/mfd/intel_msic.c4
-rw-r--r--drivers/mfd/janz-cmodio.c2
-rw-r--r--drivers/mfd/jz4740-adc.c3
-rw-r--r--drivers/mfd/lm3533-core.c7
-rw-r--r--drivers/mfd/lpc_ich.c24
-rw-r--r--drivers/mfd/lpc_sch.c6
-rw-r--r--drivers/mfd/max77686.c2
-rw-r--r--drivers/mfd/max77693-irq.c36
-rw-r--r--drivers/mfd/max77693.c16
-rw-r--r--drivers/mfd/max8925-core.c12
-rw-r--r--drivers/mfd/max8997.c2
-rw-r--r--drivers/mfd/max8998.c8
-rw-r--r--drivers/mfd/mc13xxx-core.c2
-rw-r--r--drivers/mfd/mfd-core.c12
-rw-r--r--drivers/mfd/palmas.c3
-rw-r--r--drivers/mfd/rc5t583.c2
-rw-r--r--drivers/mfd/rdc321x-southbridge.c3
-rw-r--r--drivers/mfd/sec-core.c8
-rw-r--r--drivers/mfd/sta2x11-mfd.c4
-rw-r--r--drivers/mfd/stmpe.c2
-rw-r--r--drivers/mfd/t7l66xb.c2
-rw-r--r--drivers/mfd/tc3589x.c8
-rw-r--r--drivers/mfd/tc6387xb.c2
-rw-r--r--drivers/mfd/tc6393xb.c4
-rw-r--r--drivers/mfd/ti-ssp.c2
-rw-r--r--drivers/mfd/timberdale.c12
-rw-r--r--drivers/mfd/tps6105x.c2
-rw-r--r--drivers/mfd/tps6507x.c2
-rw-r--r--drivers/mfd/tps65090.c2
-rw-r--r--drivers/mfd/tps65217.c130
-rw-r--r--drivers/mfd/tps6586x.c3
-rw-r--r--drivers/mfd/tps65910.c2
-rw-r--r--drivers/mfd/tps65912-core.c2
-rw-r--r--drivers/mfd/twl4030-audio.c2
-rw-r--r--drivers/mfd/twl6040-core.c2
-rw-r--r--drivers/mfd/vx855.c2
-rw-r--r--drivers/mfd/wl1273-core.c2
-rw-r--r--drivers/mfd/wm831x-core.c16
-rw-r--r--drivers/mfd/wm8400-core.c2
-rw-r--r--drivers/mfd/wm8994-core.c4
-rw-r--r--drivers/net/can/janz-ican3.c4
-rw-r--r--drivers/net/can/mcp251x.c11
-rw-r--r--drivers/net/can/ti_hecc.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h11
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h25
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c8
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c18
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c32
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c15
-rw-r--r--drivers/net/ethernet/cadence/at91_ether.c2
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ethtool.c1
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ptp.c4
-rw-r--r--drivers/net/ethernet/i825xx/znet.c13
-rw-r--r--drivers/net/ethernet/ibm/ibmveth.c26
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_main.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/icm.c30
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/icm.h10
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c16
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mcg.c106
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h76
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c116
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c4
-rw-r--r--drivers/net/ethernet/seeq/sgiseeq.c1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c10
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c8
-rw-r--r--drivers/net/irda/sh_sir.c2
-rw-r--r--drivers/net/usb/asix_devices.c4
-rw-r--r--drivers/net/usb/qmi_wwan.c20
-rw-r--r--drivers/net/usb/sierra_net.c2
-rw-r--r--drivers/net/usb/usbnet.c16
-rw-r--r--drivers/net/wan/ixp4xx_hss.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_paprd.c105
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.h4
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/gpio.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h4
-rw-r--r--drivers/net/wireless/ath/ath9k/link.c20
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c3
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c26
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/usb.c30
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c21
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/channel.c2
-rw-r--r--drivers/net/wireless/libertas/if_sdio.c5
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c15
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.h1
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.h17
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c22
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.h1
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.h3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/def.h1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/hw.c12
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.c6
-rw-r--r--drivers/platform/x86/acer-wmi.c2
-rw-r--r--drivers/platform/x86/apple-gmux.c24
-rw-r--r--drivers/platform/x86/asus-laptop.c10
-rw-r--r--drivers/platform/x86/asus-wmi.c4
-rw-r--r--drivers/platform/x86/eeepc-laptop.c10
-rw-r--r--drivers/platform/x86/samsung-laptop.c4
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c13
-rw-r--r--drivers/pwm/pwm-tiecap.c7
-rw-r--r--drivers/pwm/pwm-tiehrpwm.c29
-rw-r--r--drivers/regulator/tps65217-regulator.c124
-rw-r--r--drivers/rpmsg/virtio_rpmsg_bus.c6
-rw-r--r--drivers/rtc/rtc-twl.c5
-rw-r--r--drivers/s390/block/dasd.c17
-rw-r--r--drivers/s390/block/dasd_alias.c27
-rw-r--r--drivers/s390/block/dasd_eckd.c32
-rw-r--r--drivers/s390/cio/device.c7
-rw-r--r--drivers/scsi/bnx2i/bnx2i_hwi.c3
-rw-r--r--drivers/scsi/hpsa.c3
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c3
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c20
-rw-r--r--drivers/scsi/scsi_error.c10
-rw-r--r--drivers/scsi/scsi_lib.c5
-rw-r--r--drivers/scsi/scsi_scan.c10
-rw-r--r--drivers/scsi/virtio_scsi.c2
-rw-r--r--drivers/sh/intc/core.c2
-rw-r--r--drivers/sh/pfc/pinctrl.c3
-rw-r--r--drivers/staging/android/android_alarm.h4
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.c7
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc236.c7
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc263.c7
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci224.c7
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci230.c7
-rw-r--r--drivers/staging/comedi/drivers/das08.c11
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_ring.c4
-rw-r--r--drivers/staging/iio/adc/ad7192.c2
-rw-r--r--drivers/staging/iio/gyro/adis16260_core.c2
-rw-r--r--drivers/staging/iio/imu/adis16400_core.c2
-rw-r--r--drivers/staging/iio/meter/ade7753.c2
-rw-r--r--drivers/staging/iio/meter/ade7754.c2
-rw-r--r--drivers/staging/iio/meter/ade7759.c2
-rw-r--r--drivers/staging/nvec/nvec.c2
-rw-r--r--drivers/staging/omapdrm/omap_connector.c41
-rw-r--r--drivers/staging/ozwpan/ozcdev.c3
-rw-r--r--drivers/staging/rtl8712/recv_linux.c7
-rw-r--r--drivers/staging/vt6656/dpc.c2
-rw-r--r--drivers/staging/vt6656/rxtx.c38
-rw-r--r--drivers/staging/wlan-ng/cfg80211.c4
-rw-r--r--drivers/staging/zcache/zcache-main.c7
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c11
-rw-r--r--drivers/target/target_core_alua.c7
-rw-r--r--drivers/target/target_core_device.c7
-rw-r--r--drivers/target/target_core_iblock.c17
-rw-r--r--drivers/target/target_core_pr.c8
-rw-r--r--drivers/target/target_core_pscsi.c29
-rw-r--r--drivers/target/target_core_spc.c35
-rw-r--r--drivers/target/target_core_transport.c148
-rw-r--r--drivers/tty/serial/imx.c30
-rw-r--r--drivers/usb/chipidea/udc.c59
-rw-r--r--drivers/usb/class/cdc-wdm.c12
-rw-r--r--drivers/usb/core/quirks.c4
-rw-r--r--drivers/usb/dwc3/core.c9
-rw-r--r--drivers/usb/dwc3/ep0.c1
-rw-r--r--drivers/usb/dwc3/gadget.c19
-rw-r--r--drivers/usb/gadget/at91_udc.c6
-rw-r--r--drivers/usb/gadget/dummy_hcd.c41
-rw-r--r--drivers/usb/gadget/f_fs.c4
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c3
-rw-r--r--drivers/usb/gadget/u_serial.c4
-rw-r--r--drivers/usb/host/ehci-q.c12
-rw-r--r--drivers/usb/host/ohci-at91.c10
-rw-r--r--drivers/usb/host/pci-quirks.c42
-rw-r--r--drivers/usb/host/pci-quirks.h1
-rw-r--r--drivers/usb/host/xhci-hub.c42
-rw-r--r--drivers/usb/host/xhci-plat.c2
-rw-r--r--drivers/usb/host/xhci.c123
-rw-r--r--drivers/usb/host/xhci.h6
-rw-r--r--drivers/usb/musb/musb_host.c2
-rw-r--r--drivers/usb/musb/musbhsdma.c2
-rw-r--r--drivers/usb/musb/tusb6010.c2
-rw-r--r--drivers/usb/renesas_usbhs/fifo.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c22
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h29
-rw-r--r--drivers/usb/serial/option.c6
-rw-r--r--drivers/watchdog/hpwdt.c3
-rw-r--r--drivers/watchdog/watchdog_core.c3
-rw-r--r--drivers/xen/gntdev.c5
-rw-r--r--drivers/xen/grant-table.c6
308 files changed, 2761 insertions, 1239 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 9628652e080c..e0596954290b 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -237,6 +237,16 @@ static int __acpi_bus_get_power(struct acpi_device *device, int *state)
237 } else if (result == ACPI_STATE_D3_HOT) { 237 } else if (result == ACPI_STATE_D3_HOT) {
238 result = ACPI_STATE_D3; 238 result = ACPI_STATE_D3;
239 } 239 }
240
241 /*
242 * If we were unsure about the device parent's power state up to this
243 * point, the fact that the device is in D0 implies that the parent has
244 * to be in D0 too.
245 */
246 if (device->parent && device->parent->power.state == ACPI_STATE_UNKNOWN
247 && result == ACPI_STATE_D0)
248 device->parent->power.state = ACPI_STATE_D0;
249
240 *state = result; 250 *state = result;
241 251
242 out: 252 out:
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index fc1803414629..40e38a06ba85 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -107,6 +107,7 @@ struct acpi_power_resource {
107 107
108 /* List of devices relying on this power resource */ 108 /* List of devices relying on this power resource */
109 struct acpi_power_resource_device *devices; 109 struct acpi_power_resource_device *devices;
110 struct mutex devices_lock;
110}; 111};
111 112
112static struct list_head acpi_power_resource_list; 113static struct list_head acpi_power_resource_list;
@@ -225,7 +226,6 @@ static void acpi_power_on_device(struct acpi_power_managed_device *device)
225 226
226static int __acpi_power_on(struct acpi_power_resource *resource) 227static int __acpi_power_on(struct acpi_power_resource *resource)
227{ 228{
228 struct acpi_power_resource_device *device_list = resource->devices;
229 acpi_status status = AE_OK; 229 acpi_status status = AE_OK;
230 230
231 status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); 231 status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL);
@@ -238,19 +238,15 @@ static int __acpi_power_on(struct acpi_power_resource *resource)
238 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned on\n", 238 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned on\n",
239 resource->name)); 239 resource->name));
240 240
241 while (device_list) {
242 acpi_power_on_device(device_list->device);
243
244 device_list = device_list->next;
245 }
246
247 return 0; 241 return 0;
248} 242}
249 243
250static int acpi_power_on(acpi_handle handle) 244static int acpi_power_on(acpi_handle handle)
251{ 245{
252 int result = 0; 246 int result = 0;
247 bool resume_device = false;
253 struct acpi_power_resource *resource = NULL; 248 struct acpi_power_resource *resource = NULL;
249 struct acpi_power_resource_device *device_list;
254 250
255 result = acpi_power_get_context(handle, &resource); 251 result = acpi_power_get_context(handle, &resource);
256 if (result) 252 if (result)
@@ -266,10 +262,25 @@ static int acpi_power_on(acpi_handle handle)
266 result = __acpi_power_on(resource); 262 result = __acpi_power_on(resource);
267 if (result) 263 if (result)
268 resource->ref_count--; 264 resource->ref_count--;
265 else
266 resume_device = true;
269 } 267 }
270 268
271 mutex_unlock(&resource->resource_lock); 269 mutex_unlock(&resource->resource_lock);
272 270
271 if (!resume_device)
272 return result;
273
274 mutex_lock(&resource->devices_lock);
275
276 device_list = resource->devices;
277 while (device_list) {
278 acpi_power_on_device(device_list->device);
279 device_list = device_list->next;
280 }
281
282 mutex_unlock(&resource->devices_lock);
283
273 return result; 284 return result;
274} 285}
275 286
@@ -355,7 +366,7 @@ static void __acpi_power_resource_unregister_device(struct device *dev,
355 if (acpi_power_get_context(res_handle, &resource)) 366 if (acpi_power_get_context(res_handle, &resource))
356 return; 367 return;
357 368
358 mutex_lock(&resource->resource_lock); 369 mutex_lock(&resource->devices_lock);
359 prev = NULL; 370 prev = NULL;
360 curr = resource->devices; 371 curr = resource->devices;
361 while (curr) { 372 while (curr) {
@@ -372,7 +383,7 @@ static void __acpi_power_resource_unregister_device(struct device *dev,
372 prev = curr; 383 prev = curr;
373 curr = curr->next; 384 curr = curr->next;
374 } 385 }
375 mutex_unlock(&resource->resource_lock); 386 mutex_unlock(&resource->devices_lock);
376} 387}
377 388
378/* Unlink dev from all power resources in _PR0 */ 389/* Unlink dev from all power resources in _PR0 */
@@ -414,10 +425,10 @@ static int __acpi_power_resource_register_device(
414 425
415 power_resource_device->device = powered_device; 426 power_resource_device->device = powered_device;
416 427
417 mutex_lock(&resource->resource_lock); 428 mutex_lock(&resource->devices_lock);
418 power_resource_device->next = resource->devices; 429 power_resource_device->next = resource->devices;
419 resource->devices = power_resource_device; 430 resource->devices = power_resource_device;
420 mutex_unlock(&resource->resource_lock); 431 mutex_unlock(&resource->devices_lock);
421 432
422 return 0; 433 return 0;
423} 434}
@@ -462,7 +473,7 @@ int acpi_power_resource_register_device(struct device *dev, acpi_handle handle)
462 return ret; 473 return ret;
463 474
464no_power_resource: 475no_power_resource:
465 printk(KERN_WARNING PREFIX "Invalid Power Resource to register!"); 476 printk(KERN_DEBUG PREFIX "Invalid Power Resource to register!");
466 return -ENODEV; 477 return -ENODEV;
467} 478}
468EXPORT_SYMBOL_GPL(acpi_power_resource_register_device); 479EXPORT_SYMBOL_GPL(acpi_power_resource_register_device);
@@ -721,6 +732,7 @@ static int acpi_power_add(struct acpi_device *device)
721 732
722 resource->device = device; 733 resource->device = device;
723 mutex_init(&resource->resource_lock); 734 mutex_init(&resource->resource_lock);
735 mutex_init(&resource->devices_lock);
724 strcpy(resource->name, device->pnp.bus_id); 736 strcpy(resource->name, device->pnp.bus_id);
725 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); 737 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
726 strcpy(acpi_device_class(device), ACPI_POWER_CLASS); 738 strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 50d5dea0ff59..7862d17976b7 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -268,6 +268,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
268 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 268 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
269 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 269 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
270 PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci_ign_iferr }, 270 PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci_ign_iferr },
271 /* JMicron 362B and 362C have an AHCI function with IDE class code */
272 { PCI_VDEVICE(JMICRON, 0x2362), board_ahci_ign_iferr },
273 { PCI_VDEVICE(JMICRON, 0x236f), board_ahci_ign_iferr },
271 274
272 /* ATI */ 275 /* ATI */
273 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ 276 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
@@ -393,6 +396,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
393 .driver_data = board_ahci_yes_fbs }, /* 88se9125 */ 396 .driver_data = board_ahci_yes_fbs }, /* 88se9125 */
394 { PCI_DEVICE(0x1b4b, 0x917a), 397 { PCI_DEVICE(0x1b4b, 0x917a),
395 .driver_data = board_ahci_yes_fbs }, /* 88se9172 */ 398 .driver_data = board_ahci_yes_fbs }, /* 88se9172 */
399 { PCI_DEVICE(0x1b4b, 0x9192),
400 .driver_data = board_ahci_yes_fbs }, /* 88se9172 on some Gigabyte */
396 { PCI_DEVICE(0x1b4b, 0x91a3), 401 { PCI_DEVICE(0x1b4b, 0x91a3),
397 .driver_data = board_ahci_yes_fbs }, 402 .driver_data = board_ahci_yes_fbs },
398 403
@@ -400,7 +405,10 @@ static const struct pci_device_id ahci_pci_tbl[] = {
400 { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */ 405 { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */
401 406
402 /* Asmedia */ 407 /* Asmedia */
403 { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1061 */ 408 { PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci }, /* ASM1060 */
409 { PCI_VDEVICE(ASMEDIA, 0x0602), board_ahci }, /* ASM1060 */
410 { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci }, /* ASM1061 */
411 { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */
404 412
405 /* Generic, PCI class code for AHCI */ 413 /* Generic, PCI class code for AHCI */
406 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 414 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index de0435e63b02..887f68f6d79a 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -35,6 +35,7 @@ new_skb(ulong len)
35 skb_reset_mac_header(skb); 35 skb_reset_mac_header(skb);
36 skb_reset_network_header(skb); 36 skb_reset_network_header(skb);
37 skb->protocol = __constant_htons(ETH_P_AOE); 37 skb->protocol = __constant_htons(ETH_P_AOE);
38 skb_checksum_none_assert(skb);
38 } 39 }
39 return skb; 40 return skb;
40} 41}
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 38aa6dda6b81..da3311129a0c 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -795,6 +795,7 @@ static void complete_scsi_command(CommandList_struct *c, int timeout,
795 } 795 }
796 break; 796 break;
797 case CMD_PROTOCOL_ERR: 797 case CMD_PROTOCOL_ERR:
798 cmd->result = DID_ERROR << 16;
798 dev_warn(&h->pdev->dev, 799 dev_warn(&h->pdev->dev,
799 "%p has protocol error\n", c); 800 "%p has protocol error\n", c);
800 break; 801 break;
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index a8fddeb3d638..f946d31d6917 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1148,11 +1148,15 @@ static bool mtip_pause_ncq(struct mtip_port *port,
1148 reply = port->rxfis + RX_FIS_D2H_REG; 1148 reply = port->rxfis + RX_FIS_D2H_REG;
1149 task_file_data = readl(port->mmio+PORT_TFDATA); 1149 task_file_data = readl(port->mmio+PORT_TFDATA);
1150 1150
1151 if ((task_file_data & 1) || (fis->command == ATA_CMD_SEC_ERASE_UNIT)) 1151 if (fis->command == ATA_CMD_SEC_ERASE_UNIT)
1152 clear_bit(MTIP_DDF_SEC_LOCK_BIT, &port->dd->dd_flag);
1153
1154 if ((task_file_data & 1))
1152 return false; 1155 return false;
1153 1156
1154 if (fis->command == ATA_CMD_SEC_ERASE_PREP) { 1157 if (fis->command == ATA_CMD_SEC_ERASE_PREP) {
1155 set_bit(MTIP_PF_SE_ACTIVE_BIT, &port->flags); 1158 set_bit(MTIP_PF_SE_ACTIVE_BIT, &port->flags);
1159 set_bit(MTIP_DDF_SEC_LOCK_BIT, &port->dd->dd_flag);
1156 port->ic_pause_timer = jiffies; 1160 port->ic_pause_timer = jiffies;
1157 return true; 1161 return true;
1158 } else if ((fis->command == ATA_CMD_DOWNLOAD_MICRO) && 1162 } else if ((fis->command == ATA_CMD_DOWNLOAD_MICRO) &&
@@ -1900,7 +1904,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command,
1900 int rv = 0, xfer_sz = command[3]; 1904 int rv = 0, xfer_sz = command[3];
1901 1905
1902 if (xfer_sz) { 1906 if (xfer_sz) {
1903 if (user_buffer) 1907 if (!user_buffer)
1904 return -EFAULT; 1908 return -EFAULT;
1905 1909
1906 buf = dmam_alloc_coherent(&port->dd->pdev->dev, 1910 buf = dmam_alloc_coherent(&port->dd->pdev->dev,
@@ -2043,7 +2047,7 @@ static void mtip_set_timeout(struct host_to_dev_fis *fis, unsigned int *timeout)
2043 *timeout = 240000; /* 4 minutes */ 2047 *timeout = 240000; /* 4 minutes */
2044 break; 2048 break;
2045 case ATA_CMD_STANDBYNOW1: 2049 case ATA_CMD_STANDBYNOW1:
2046 *timeout = 10000; /* 10 seconds */ 2050 *timeout = 120000; /* 2 minutes */
2047 break; 2051 break;
2048 case 0xF7: 2052 case 0xF7:
2049 case 0xFA: 2053 case 0xFA:
@@ -2588,9 +2592,6 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
2588 if (!len || size) 2592 if (!len || size)
2589 return 0; 2593 return 0;
2590 2594
2591 if (size < 0)
2592 return -EINVAL;
2593
2594 size += sprintf(&buf[size], "H/ S ACTive : [ 0x"); 2595 size += sprintf(&buf[size], "H/ S ACTive : [ 0x");
2595 2596
2596 for (n = dd->slot_groups-1; n >= 0; n--) 2597 for (n = dd->slot_groups-1; n >= 0; n--)
@@ -2660,9 +2661,6 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
2660 if (!len || size) 2661 if (!len || size)
2661 return 0; 2662 return 0;
2662 2663
2663 if (size < 0)
2664 return -EINVAL;
2665
2666 size += sprintf(&buf[size], "Flag-port : [ %08lX ]\n", 2664 size += sprintf(&buf[size], "Flag-port : [ %08lX ]\n",
2667 dd->port->flags); 2665 dd->port->flags);
2668 size += sprintf(&buf[size], "Flag-dd : [ %08lX ]\n", 2666 size += sprintf(&buf[size], "Flag-dd : [ %08lX ]\n",
@@ -3214,8 +3212,8 @@ static int mtip_hw_init(struct driver_data *dd)
3214 "Unable to check write protect progress\n"); 3212 "Unable to check write protect progress\n");
3215 else 3213 else
3216 dev_info(&dd->pdev->dev, 3214 dev_info(&dd->pdev->dev,
3217 "Write protect progress: %d%% (%d blocks)\n", 3215 "Write protect progress: %u%% (%u blocks)\n",
3218 attr242.cur, attr242.data); 3216 attr242.cur, le32_to_cpu(attr242.data));
3219 return rv; 3217 return rv;
3220 3218
3221out3: 3219out3:
@@ -3619,6 +3617,10 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio)
3619 bio_endio(bio, -ENODATA); 3617 bio_endio(bio, -ENODATA);
3620 return; 3618 return;
3621 } 3619 }
3620 if (unlikely(test_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag))) {
3621 bio_endio(bio, -ENODATA);
3622 return;
3623 }
3622 } 3624 }
3623 3625
3624 if (unlikely(!bio_has_data(bio))) { 3626 if (unlikely(!bio_has_data(bio))) {
@@ -4168,7 +4170,13 @@ static void mtip_pci_shutdown(struct pci_dev *pdev)
4168 4170
4169/* Table of device ids supported by this driver. */ 4171/* Table of device ids supported by this driver. */
4170static DEFINE_PCI_DEVICE_TABLE(mtip_pci_tbl) = { 4172static DEFINE_PCI_DEVICE_TABLE(mtip_pci_tbl) = {
4171 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320_DEVICE_ID) }, 4173 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320H_DEVICE_ID) },
4174 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320M_DEVICE_ID) },
4175 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320S_DEVICE_ID) },
4176 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P325M_DEVICE_ID) },
4177 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P420H_DEVICE_ID) },
4178 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P420M_DEVICE_ID) },
4179 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P425M_DEVICE_ID) },
4172 { 0 } 4180 { 0 }
4173}; 4181};
4174 4182
@@ -4199,12 +4207,12 @@ static int __init mtip_init(void)
4199{ 4207{
4200 int error; 4208 int error;
4201 4209
4202 printk(KERN_INFO MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n"); 4210 pr_info(MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n");
4203 4211
4204 /* Allocate a major block device number to use with this driver. */ 4212 /* Allocate a major block device number to use with this driver. */
4205 error = register_blkdev(0, MTIP_DRV_NAME); 4213 error = register_blkdev(0, MTIP_DRV_NAME);
4206 if (error <= 0) { 4214 if (error <= 0) {
4207 printk(KERN_ERR "Unable to register block device (%d)\n", 4215 pr_err("Unable to register block device (%d)\n",
4208 error); 4216 error);
4209 return -EBUSY; 4217 return -EBUSY;
4210 } 4218 }
@@ -4213,7 +4221,7 @@ static int __init mtip_init(void)
4213 if (!dfs_parent) { 4221 if (!dfs_parent) {
4214 dfs_parent = debugfs_create_dir("rssd", NULL); 4222 dfs_parent = debugfs_create_dir("rssd", NULL);
4215 if (IS_ERR_OR_NULL(dfs_parent)) { 4223 if (IS_ERR_OR_NULL(dfs_parent)) {
4216 printk(KERN_WARNING "Error creating debugfs parent\n"); 4224 pr_warn("Error creating debugfs parent\n");
4217 dfs_parent = NULL; 4225 dfs_parent = NULL;
4218 } 4226 }
4219 } 4227 }
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index f51fc23d17bb..18627a1d04c5 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -76,7 +76,13 @@
76 76
77/* Micron Vendor ID & P320x SSD Device ID */ 77/* Micron Vendor ID & P320x SSD Device ID */
78#define PCI_VENDOR_ID_MICRON 0x1344 78#define PCI_VENDOR_ID_MICRON 0x1344
79#define P320_DEVICE_ID 0x5150 79#define P320H_DEVICE_ID 0x5150
80#define P320M_DEVICE_ID 0x5151
81#define P320S_DEVICE_ID 0x5152
82#define P325M_DEVICE_ID 0x5153
83#define P420H_DEVICE_ID 0x5160
84#define P420M_DEVICE_ID 0x5161
85#define P425M_DEVICE_ID 0x5163
80 86
81/* Driver name and version strings */ 87/* Driver name and version strings */
82#define MTIP_DRV_NAME "mtip32xx" 88#define MTIP_DRV_NAME "mtip32xx"
@@ -131,10 +137,12 @@ enum {
131 MTIP_PF_SVC_THD_STOP_BIT = 8, 137 MTIP_PF_SVC_THD_STOP_BIT = 8,
132 138
133 /* below are bit numbers in 'dd_flag' defined in driver_data */ 139 /* below are bit numbers in 'dd_flag' defined in driver_data */
140 MTIP_DDF_SEC_LOCK_BIT = 0,
134 MTIP_DDF_REMOVE_PENDING_BIT = 1, 141 MTIP_DDF_REMOVE_PENDING_BIT = 1,
135 MTIP_DDF_OVER_TEMP_BIT = 2, 142 MTIP_DDF_OVER_TEMP_BIT = 2,
136 MTIP_DDF_WRITE_PROTECT_BIT = 3, 143 MTIP_DDF_WRITE_PROTECT_BIT = 3,
137 MTIP_DDF_STOP_IO = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) | \ 144 MTIP_DDF_STOP_IO = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) | \
145 (1 << MTIP_DDF_SEC_LOCK_BIT) | \
138 (1 << MTIP_DDF_OVER_TEMP_BIT) | \ 146 (1 << MTIP_DDF_OVER_TEMP_BIT) | \
139 (1 << MTIP_DDF_WRITE_PROTECT_BIT)), 147 (1 << MTIP_DDF_WRITE_PROTECT_BIT)),
140 148
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index d07c9f7fded6..0c03411c59eb 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -449,6 +449,14 @@ static void nbd_clear_que(struct nbd_device *nbd)
449 req->errors++; 449 req->errors++;
450 nbd_end_request(req); 450 nbd_end_request(req);
451 } 451 }
452
453 while (!list_empty(&nbd->waiting_queue)) {
454 req = list_entry(nbd->waiting_queue.next, struct request,
455 queuelist);
456 list_del_init(&req->queuelist);
457 req->errors++;
458 nbd_end_request(req);
459 }
452} 460}
453 461
454 462
@@ -598,6 +606,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
598 nbd->file = NULL; 606 nbd->file = NULL;
599 nbd_clear_que(nbd); 607 nbd_clear_que(nbd);
600 BUG_ON(!list_empty(&nbd->queue_head)); 608 BUG_ON(!list_empty(&nbd->queue_head));
609 BUG_ON(!list_empty(&nbd->waiting_queue));
601 if (file) 610 if (file)
602 fput(file); 611 fput(file);
603 return 0; 612 return 0;
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 73f196ca713f..c6decb901e5e 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -337,7 +337,7 @@ static void xen_blkbk_unmap(struct pending_req *req)
337 invcount++; 337 invcount++;
338 } 338 }
339 339
340 ret = gnttab_unmap_refs(unmap, pages, invcount, false); 340 ret = gnttab_unmap_refs(unmap, NULL, pages, invcount);
341 BUG_ON(ret); 341 BUG_ON(ret);
342} 342}
343 343
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 11f36e502136..fc2de5528dcc 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -86,6 +86,7 @@ static struct usb_device_id ath3k_table[] = {
86 86
87 /* Atheros AR5BBU22 with sflash firmware */ 87 /* Atheros AR5BBU22 with sflash firmware */
88 { USB_DEVICE(0x0489, 0xE03C) }, 88 { USB_DEVICE(0x0489, 0xE03C) },
89 { USB_DEVICE(0x0489, 0xE036) },
89 90
90 { } /* Terminating entry */ 91 { } /* Terminating entry */
91}; 92};
@@ -109,6 +110,7 @@ static struct usb_device_id ath3k_blist_tbl[] = {
109 110
110 /* Atheros AR5BBU22 with sflash firmware */ 111 /* Atheros AR5BBU22 with sflash firmware */
111 { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 }, 112 { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 },
113 { USB_DEVICE(0x0489, 0xE036), .driver_info = BTUSB_ATH3012 },
112 114
113 { } /* Terminating entry */ 115 { } /* Terminating entry */
114}; 116};
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index cef3bac1a543..654e248763ef 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -52,6 +52,9 @@ static struct usb_device_id btusb_table[] = {
52 /* Generic Bluetooth USB device */ 52 /* Generic Bluetooth USB device */
53 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, 53 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
54 54
55 /* Apple-specific (Broadcom) devices */
56 { USB_VENDOR_AND_INTERFACE_INFO(0x05ac, 0xff, 0x01, 0x01) },
57
55 /* Broadcom SoftSailing reporting vendor specific */ 58 /* Broadcom SoftSailing reporting vendor specific */
56 { USB_DEVICE(0x0a5c, 0x21e1) }, 59 { USB_DEVICE(0x0a5c, 0x21e1) },
57 60
@@ -94,16 +97,14 @@ static struct usb_device_id btusb_table[] = {
94 97
95 /* Broadcom BCM20702A0 */ 98 /* Broadcom BCM20702A0 */
96 { USB_DEVICE(0x0489, 0xe042) }, 99 { USB_DEVICE(0x0489, 0xe042) },
97 { USB_DEVICE(0x0a5c, 0x21e3) },
98 { USB_DEVICE(0x0a5c, 0x21e6) },
99 { USB_DEVICE(0x0a5c, 0x21e8) },
100 { USB_DEVICE(0x0a5c, 0x21f3) },
101 { USB_DEVICE(0x0a5c, 0x21f4) },
102 { USB_DEVICE(0x413c, 0x8197) }, 100 { USB_DEVICE(0x413c, 0x8197) },
103 101
104 /* Foxconn - Hon Hai */ 102 /* Foxconn - Hon Hai */
105 { USB_DEVICE(0x0489, 0xe033) }, 103 { USB_DEVICE(0x0489, 0xe033) },
106 104
105 /*Broadcom devices with vendor specific id */
106 { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) },
107
107 { } /* Terminating entry */ 108 { } /* Terminating entry */
108}; 109};
109 110
@@ -141,6 +142,7 @@ static struct usb_device_id blacklist_table[] = {
141 142
142 /* Atheros AR5BBU12 with sflash firmware */ 143 /* Atheros AR5BBU12 with sflash firmware */
143 { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 }, 144 { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
145 { USB_DEVICE(0x0489, 0xe036), .driver_info = BTUSB_ATH3012 },
144 146
145 /* Broadcom BCM2035 */ 147 /* Broadcom BCM2035 */
146 { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU }, 148 { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 5869ea387054..72ce247a0e8d 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -1,4 +1,5 @@
1# common clock types 1# common clock types
2obj-$(CONFIG_HAVE_CLK) += clk-devres.o
2obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o 3obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o
3obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \ 4obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \
4 clk-mux.o clk-divider.o clk-fixed-factor.o 5 clk-mux.o clk-divider.o clk-fixed-factor.o
diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
new file mode 100644
index 000000000000..8f571548870f
--- /dev/null
+++ b/drivers/clk/clk-devres.c
@@ -0,0 +1,55 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 */
6
7#include <linux/clk.h>
8#include <linux/device.h>
9#include <linux/export.h>
10#include <linux/gfp.h>
11
12static void devm_clk_release(struct device *dev, void *res)
13{
14 clk_put(*(struct clk **)res);
15}
16
17struct clk *devm_clk_get(struct device *dev, const char *id)
18{
19 struct clk **ptr, *clk;
20
21 ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
22 if (!ptr)
23 return ERR_PTR(-ENOMEM);
24
25 clk = clk_get(dev, id);
26 if (!IS_ERR(clk)) {
27 *ptr = clk;
28 devres_add(dev, ptr);
29 } else {
30 devres_free(ptr);
31 }
32
33 return clk;
34}
35EXPORT_SYMBOL(devm_clk_get);
36
37static int devm_clk_match(struct device *dev, void *res, void *data)
38{
39 struct clk **c = res;
40 if (!c || !*c) {
41 WARN_ON(!c || !*c);
42 return 0;
43 }
44 return *c == data;
45}
46
47void devm_clk_put(struct device *dev, struct clk *clk)
48{
49 int ret;
50
51 ret = devres_release(dev, devm_clk_release, devm_clk_match, clk);
52
53 WARN_ON(ret);
54}
55EXPORT_SYMBOL(devm_clk_put);
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index d423c9bdd71a..442a31363873 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -171,51 +171,6 @@ void clk_put(struct clk *clk)
171} 171}
172EXPORT_SYMBOL(clk_put); 172EXPORT_SYMBOL(clk_put);
173 173
174static void devm_clk_release(struct device *dev, void *res)
175{
176 clk_put(*(struct clk **)res);
177}
178
179struct clk *devm_clk_get(struct device *dev, const char *id)
180{
181 struct clk **ptr, *clk;
182
183 ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
184 if (!ptr)
185 return ERR_PTR(-ENOMEM);
186
187 clk = clk_get(dev, id);
188 if (!IS_ERR(clk)) {
189 *ptr = clk;
190 devres_add(dev, ptr);
191 } else {
192 devres_free(ptr);
193 }
194
195 return clk;
196}
197EXPORT_SYMBOL(devm_clk_get);
198
199static int devm_clk_match(struct device *dev, void *res, void *data)
200{
201 struct clk **c = res;
202 if (!c || !*c) {
203 WARN_ON(!c || !*c);
204 return 0;
205 }
206 return *c == data;
207}
208
209void devm_clk_put(struct device *dev, struct clk *clk)
210{
211 int ret;
212
213 ret = devres_destroy(dev, devm_clk_release, devm_clk_match, clk);
214
215 WARN_ON(ret);
216}
217EXPORT_SYMBOL(devm_clk_put);
218
219void clkdev_add(struct clk_lookup *cl) 174void clkdev_add(struct clk_lookup *cl)
220{ 175{
221 mutex_lock(&clocks_mutex); 176 mutex_lock(&clocks_mutex);
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index c0e816468e30..1a40935c85fd 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -35,7 +35,6 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/string.h> 36#include <linux/string.h>
37#include <linux/cpumask.h> 37#include <linux/cpumask.h>
38#include <linux/sched.h> /* for current / set_cpus_allowed() */
39#include <linux/io.h> 38#include <linux/io.h>
40#include <linux/delay.h> 39#include <linux/delay.h>
41 40
@@ -1139,16 +1138,23 @@ static int transition_frequency_pstate(struct powernow_k8_data *data,
1139 return res; 1138 return res;
1140} 1139}
1141 1140
1142/* Driver entry point to switch to the target frequency */ 1141struct powernowk8_target_arg {
1143static int powernowk8_target(struct cpufreq_policy *pol, 1142 struct cpufreq_policy *pol;
1144 unsigned targfreq, unsigned relation) 1143 unsigned targfreq;
1144 unsigned relation;
1145};
1146
1147static long powernowk8_target_fn(void *arg)
1145{ 1148{
1146 cpumask_var_t oldmask; 1149 struct powernowk8_target_arg *pta = arg;
1150 struct cpufreq_policy *pol = pta->pol;
1151 unsigned targfreq = pta->targfreq;
1152 unsigned relation = pta->relation;
1147 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); 1153 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
1148 u32 checkfid; 1154 u32 checkfid;
1149 u32 checkvid; 1155 u32 checkvid;
1150 unsigned int newstate; 1156 unsigned int newstate;
1151 int ret = -EIO; 1157 int ret;
1152 1158
1153 if (!data) 1159 if (!data)
1154 return -EINVAL; 1160 return -EINVAL;
@@ -1156,29 +1162,16 @@ static int powernowk8_target(struct cpufreq_policy *pol,
1156 checkfid = data->currfid; 1162 checkfid = data->currfid;
1157 checkvid = data->currvid; 1163 checkvid = data->currvid;
1158 1164
1159 /* only run on specific CPU from here on. */
1160 /* This is poor form: use a workqueue or smp_call_function_single */
1161 if (!alloc_cpumask_var(&oldmask, GFP_KERNEL))
1162 return -ENOMEM;
1163
1164 cpumask_copy(oldmask, tsk_cpus_allowed(current));
1165 set_cpus_allowed_ptr(current, cpumask_of(pol->cpu));
1166
1167 if (smp_processor_id() != pol->cpu) {
1168 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
1169 goto err_out;
1170 }
1171
1172 if (pending_bit_stuck()) { 1165 if (pending_bit_stuck()) {
1173 printk(KERN_ERR PFX "failing targ, change pending bit set\n"); 1166 printk(KERN_ERR PFX "failing targ, change pending bit set\n");
1174 goto err_out; 1167 return -EIO;
1175 } 1168 }
1176 1169
1177 pr_debug("targ: cpu %d, %d kHz, min %d, max %d, relation %d\n", 1170 pr_debug("targ: cpu %d, %d kHz, min %d, max %d, relation %d\n",
1178 pol->cpu, targfreq, pol->min, pol->max, relation); 1171 pol->cpu, targfreq, pol->min, pol->max, relation);
1179 1172
1180 if (query_current_values_with_pending_wait(data)) 1173 if (query_current_values_with_pending_wait(data))
1181 goto err_out; 1174 return -EIO;
1182 1175
1183 if (cpu_family != CPU_HW_PSTATE) { 1176 if (cpu_family != CPU_HW_PSTATE) {
1184 pr_debug("targ: curr fid 0x%x, vid 0x%x\n", 1177 pr_debug("targ: curr fid 0x%x, vid 0x%x\n",
@@ -1196,7 +1189,7 @@ static int powernowk8_target(struct cpufreq_policy *pol,
1196 1189
1197 if (cpufreq_frequency_table_target(pol, data->powernow_table, 1190 if (cpufreq_frequency_table_target(pol, data->powernow_table,
1198 targfreq, relation, &newstate)) 1191 targfreq, relation, &newstate))
1199 goto err_out; 1192 return -EIO;
1200 1193
1201 mutex_lock(&fidvid_mutex); 1194 mutex_lock(&fidvid_mutex);
1202 1195
@@ -1209,9 +1202,8 @@ static int powernowk8_target(struct cpufreq_policy *pol,
1209 ret = transition_frequency_fidvid(data, newstate); 1202 ret = transition_frequency_fidvid(data, newstate);
1210 if (ret) { 1203 if (ret) {
1211 printk(KERN_ERR PFX "transition frequency failed\n"); 1204 printk(KERN_ERR PFX "transition frequency failed\n");
1212 ret = 1;
1213 mutex_unlock(&fidvid_mutex); 1205 mutex_unlock(&fidvid_mutex);
1214 goto err_out; 1206 return 1;
1215 } 1207 }
1216 mutex_unlock(&fidvid_mutex); 1208 mutex_unlock(&fidvid_mutex);
1217 1209
@@ -1220,12 +1212,25 @@ static int powernowk8_target(struct cpufreq_policy *pol,
1220 data->powernow_table[newstate].index); 1212 data->powernow_table[newstate].index);
1221 else 1213 else
1222 pol->cur = find_khz_freq_from_fid(data->currfid); 1214 pol->cur = find_khz_freq_from_fid(data->currfid);
1223 ret = 0;
1224 1215
1225err_out: 1216 return 0;
1226 set_cpus_allowed_ptr(current, oldmask); 1217}
1227 free_cpumask_var(oldmask); 1218
1228 return ret; 1219/* Driver entry point to switch to the target frequency */
1220static int powernowk8_target(struct cpufreq_policy *pol,
1221 unsigned targfreq, unsigned relation)
1222{
1223 struct powernowk8_target_arg pta = { .pol = pol, .targfreq = targfreq,
1224 .relation = relation };
1225
1226 /*
1227 * Must run on @pol->cpu. cpufreq core is responsible for ensuring
1228 * that we're bound to the current CPU and pol->cpu stays online.
1229 */
1230 if (smp_processor_id() == pol->cpu)
1231 return powernowk8_target_fn(&pta);
1232 else
1233 return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
1229} 1234}
1230 1235
1231/* Driver entry point to verify the policy and range of frequencies */ 1236/* Driver entry point to verify the policy and range of frequencies */
diff --git a/drivers/crypto/caam/key_gen.c b/drivers/crypto/caam/key_gen.c
index 002888185f17..d216cd3cc569 100644
--- a/drivers/crypto/caam/key_gen.c
+++ b/drivers/crypto/caam/key_gen.c
@@ -120,3 +120,4 @@ u32 gen_split_key(struct device *jrdev, u8 *key_out, int split_key_len,
120 120
121 return ret; 121 return ret;
122} 122}
123EXPORT_SYMBOL(gen_split_key);
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 3934fcc4e00b..7ab6e26664a7 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -661,7 +661,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
661 flags); 661 flags);
662 662
663 if (unlikely(!atslave || !sg_len)) { 663 if (unlikely(!atslave || !sg_len)) {
664 dev_dbg(chan2dev(chan), "prep_dma_memcpy: length is zero!\n"); 664 dev_dbg(chan2dev(chan), "prep_slave_sg: sg length is zero!\n");
665 return NULL; 665 return NULL;
666 } 666 }
667 667
@@ -689,6 +689,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
689 689
690 mem = sg_dma_address(sg); 690 mem = sg_dma_address(sg);
691 len = sg_dma_len(sg); 691 len = sg_dma_len(sg);
692 if (unlikely(!len)) {
693 dev_dbg(chan2dev(chan),
694 "prep_slave_sg: sg(%d) data length is zero\n", i);
695 goto err;
696 }
692 mem_width = 2; 697 mem_width = 2;
693 if (unlikely(mem & 3 || len & 3)) 698 if (unlikely(mem & 3 || len & 3))
694 mem_width = 0; 699 mem_width = 0;
@@ -724,6 +729,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
724 729
725 mem = sg_dma_address(sg); 730 mem = sg_dma_address(sg);
726 len = sg_dma_len(sg); 731 len = sg_dma_len(sg);
732 if (unlikely(!len)) {
733 dev_dbg(chan2dev(chan),
734 "prep_slave_sg: sg(%d) data length is zero\n", i);
735 goto err;
736 }
727 mem_width = 2; 737 mem_width = 2;
728 if (unlikely(mem & 3 || len & 3)) 738 if (unlikely(mem & 3 || len & 3))
729 mem_width = 0; 739 mem_width = 0;
@@ -757,6 +767,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
757 767
758err_desc_get: 768err_desc_get:
759 dev_err(chan2dev(chan), "not enough descriptors available\n"); 769 dev_err(chan2dev(chan), "not enough descriptors available\n");
770err:
760 atc_desc_put(atchan, first); 771 atc_desc_put(atchan, first);
761 return NULL; 772 return NULL;
762} 773}
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index e4feba6b03c0..f5843bc80baa 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -1567,17 +1567,19 @@ static int pl330_submit_req(void *ch_id, struct pl330_req *r)
1567 goto xfer_exit; 1567 goto xfer_exit;
1568 } 1568 }
1569 1569
1570 /* Prefer Secure Channel */
1571 if (!_manager_ns(thrd))
1572 r->cfg->nonsecure = 0;
1573 else
1574 r->cfg->nonsecure = 1;
1575 1570
1576 /* Use last settings, if not provided */ 1571 /* Use last settings, if not provided */
1577 if (r->cfg) 1572 if (r->cfg) {
1573 /* Prefer Secure Channel */
1574 if (!_manager_ns(thrd))
1575 r->cfg->nonsecure = 0;
1576 else
1577 r->cfg->nonsecure = 1;
1578
1578 ccr = _prepare_ccr(r->cfg); 1579 ccr = _prepare_ccr(r->cfg);
1579 else 1580 } else {
1580 ccr = readl(regs + CC(thrd->id)); 1581 ccr = readl(regs + CC(thrd->id));
1582 }
1581 1583
1582 /* If this req doesn't have valid xfer settings */ 1584 /* If this req doesn't have valid xfer settings */
1583 if (!_is_valid(ccr)) { 1585 if (!_is_valid(ccr)) {
@@ -2928,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
2928 num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan); 2930 num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan);
2929 2931
2930 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); 2932 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
2933 if (!pdmac->peripherals) {
2934 ret = -ENOMEM;
2935 dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n");
2936 goto probe_err5;
2937 }
2931 2938
2932 for (i = 0; i < num_chan; i++) { 2939 for (i = 0; i < num_chan; i++) {
2933 pch = &pdmac->peripherals[i]; 2940 pch = &pdmac->peripherals[i];
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 616d90bcb3a4..d5dc9da7f99f 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -199,6 +199,36 @@ void *edac_align_ptr(void **p, unsigned size, int n_elems)
199 return (void *)(((unsigned long)ptr) + align - r); 199 return (void *)(((unsigned long)ptr) + align - r);
200} 200}
201 201
202static void _edac_mc_free(struct mem_ctl_info *mci)
203{
204 int i, chn, row;
205 struct csrow_info *csr;
206 const unsigned int tot_dimms = mci->tot_dimms;
207 const unsigned int tot_channels = mci->num_cschannel;
208 const unsigned int tot_csrows = mci->nr_csrows;
209
210 if (mci->dimms) {
211 for (i = 0; i < tot_dimms; i++)
212 kfree(mci->dimms[i]);
213 kfree(mci->dimms);
214 }
215 if (mci->csrows) {
216 for (row = 0; row < tot_csrows; row++) {
217 csr = mci->csrows[row];
218 if (csr) {
219 if (csr->channels) {
220 for (chn = 0; chn < tot_channels; chn++)
221 kfree(csr->channels[chn]);
222 kfree(csr->channels);
223 }
224 kfree(csr);
225 }
226 }
227 kfree(mci->csrows);
228 }
229 kfree(mci);
230}
231
202/** 232/**
203 * edac_mc_alloc: Allocate and partially fill a struct mem_ctl_info structure 233 * edac_mc_alloc: Allocate and partially fill a struct mem_ctl_info structure
204 * @mc_num: Memory controller number 234 * @mc_num: Memory controller number
@@ -413,24 +443,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
413 return mci; 443 return mci;
414 444
415error: 445error:
416 if (mci->dimms) { 446 _edac_mc_free(mci);
417 for (i = 0; i < tot_dimms; i++)
418 kfree(mci->dimms[i]);
419 kfree(mci->dimms);
420 }
421 if (mci->csrows) {
422 for (chn = 0; chn < tot_channels; chn++) {
423 csr = mci->csrows[chn];
424 if (csr) {
425 for (chn = 0; chn < tot_channels; chn++)
426 kfree(csr->channels[chn]);
427 kfree(csr);
428 }
429 kfree(mci->csrows[i]);
430 }
431 kfree(mci->csrows);
432 }
433 kfree(mci);
434 447
435 return NULL; 448 return NULL;
436} 449}
@@ -445,6 +458,14 @@ void edac_mc_free(struct mem_ctl_info *mci)
445{ 458{
446 edac_dbg(1, "\n"); 459 edac_dbg(1, "\n");
447 460
461 /* If we're not yet registered with sysfs free only what was allocated
462 * in edac_mc_alloc().
463 */
464 if (!device_is_registered(&mci->dev)) {
465 _edac_mc_free(mci);
466 return;
467 }
468
448 /* the mci instance is freed here, when the sysfs object is dropped */ 469 /* the mci instance is freed here, when the sysfs object is dropped */
449 edac_unregister_sysfs(mci); 470 edac_unregister_sysfs(mci);
450} 471}
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 920a609b2c35..38f9e52f358b 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -669,13 +669,18 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev)
669 } 669 }
670 info->dev = &pdev->dev; 670 info->dev = &pdev->dev;
671 info->max77693 = max77693; 671 info->max77693 = max77693;
672 info->max77693->regmap_muic = regmap_init_i2c(info->max77693->muic, 672 if (info->max77693->regmap_muic)
673 &max77693_muic_regmap_config); 673 dev_dbg(&pdev->dev, "allocate register map\n");
674 if (IS_ERR(info->max77693->regmap_muic)) { 674 else {
675 ret = PTR_ERR(info->max77693->regmap_muic); 675 info->max77693->regmap_muic = devm_regmap_init_i2c(
676 dev_err(max77693->dev, 676 info->max77693->muic,
677 "failed to allocate register map: %d\n", ret); 677 &max77693_muic_regmap_config);
678 goto err_regmap; 678 if (IS_ERR(info->max77693->regmap_muic)) {
679 ret = PTR_ERR(info->max77693->regmap_muic);
680 dev_err(max77693->dev,
681 "failed to allocate register map: %d\n", ret);
682 goto err_regmap;
683 }
679 } 684 }
680 platform_set_drvdata(pdev, info); 685 platform_set_drvdata(pdev, info);
681 mutex_init(&info->mutex); 686 mutex_init(&info->mutex);
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index d0c4574ef49c..36164806b9d4 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -193,6 +193,9 @@ static const struct file_operations ast_fops = {
193 .mmap = ast_mmap, 193 .mmap = ast_mmap,
194 .poll = drm_poll, 194 .poll = drm_poll,
195 .fasync = drm_fasync, 195 .fasync = drm_fasync,
196#ifdef CONFIG_COMPAT
197 .compat_ioctl = drm_compat_ioctl,
198#endif
196 .read = drm_read, 199 .read = drm_read,
197}; 200};
198 201
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 7282c081fb53..a712cafcfa1d 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -841,7 +841,7 @@ int ast_cursor_init(struct drm_device *dev)
841 841
842 ast->cursor_cache = obj; 842 ast->cursor_cache = obj;
843 ast->cursor_cache_gpu_addr = gpu_addr; 843 ast->cursor_cache_gpu_addr = gpu_addr;
844 DRM_ERROR("pinned cursor cache at %llx\n", ast->cursor_cache_gpu_addr); 844 DRM_DEBUG_KMS("pinned cursor cache at %llx\n", ast->cursor_cache_gpu_addr);
845 return 0; 845 return 0;
846fail: 846fail:
847 return ret; 847 return ret;
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 7053140c6596..b83a2d7ddd1a 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -74,6 +74,9 @@ static const struct file_operations cirrus_driver_fops = {
74 .unlocked_ioctl = drm_ioctl, 74 .unlocked_ioctl = drm_ioctl,
75 .mmap = cirrus_mmap, 75 .mmap = cirrus_mmap,
76 .poll = drm_poll, 76 .poll = drm_poll,
77#ifdef CONFIG_COMPAT
78 .compat_ioctl = drm_compat_ioctl,
79#endif
77 .fasync = drm_fasync, 80 .fasync = drm_fasync,
78}; 81};
79static struct drm_driver driver = { 82static struct drm_driver driver = {
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 7f5096763b7d..59a26e577b57 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -36,6 +36,6 @@ config DRM_EXYNOS_VIDI
36 36
37config DRM_EXYNOS_G2D 37config DRM_EXYNOS_G2D
38 bool "Exynos DRM G2D" 38 bool "Exynos DRM G2D"
39 depends on DRM_EXYNOS 39 depends on DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_G2D
40 help 40 help
41 Choose this option if you want to use Exynos G2D for DRM. 41 Choose this option if you want to use Exynos G2D for DRM.
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
index 613bf8a5d9b2..ae13febe0eaa 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
@@ -163,6 +163,12 @@ static void exynos_gem_dmabuf_kunmap(struct dma_buf *dma_buf,
163 /* TODO */ 163 /* TODO */
164} 164}
165 165
166static int exynos_gem_dmabuf_mmap(struct dma_buf *dma_buf,
167 struct vm_area_struct *vma)
168{
169 return -ENOTTY;
170}
171
166static struct dma_buf_ops exynos_dmabuf_ops = { 172static struct dma_buf_ops exynos_dmabuf_ops = {
167 .map_dma_buf = exynos_gem_map_dma_buf, 173 .map_dma_buf = exynos_gem_map_dma_buf,
168 .unmap_dma_buf = exynos_gem_unmap_dma_buf, 174 .unmap_dma_buf = exynos_gem_unmap_dma_buf,
@@ -170,6 +176,7 @@ static struct dma_buf_ops exynos_dmabuf_ops = {
170 .kmap_atomic = exynos_gem_dmabuf_kmap_atomic, 176 .kmap_atomic = exynos_gem_dmabuf_kmap_atomic,
171 .kunmap = exynos_gem_dmabuf_kunmap, 177 .kunmap = exynos_gem_dmabuf_kunmap,
172 .kunmap_atomic = exynos_gem_dmabuf_kunmap_atomic, 178 .kunmap_atomic = exynos_gem_dmabuf_kunmap_atomic,
179 .mmap = exynos_gem_dmabuf_mmap,
173 .release = exynos_dmabuf_release, 180 .release = exynos_dmabuf_release,
174}; 181};
175 182
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index ebacec6f1e48..d07071937453 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -160,7 +160,6 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
160 if (!file_priv) 160 if (!file_priv)
161 return -ENOMEM; 161 return -ENOMEM;
162 162
163 drm_prime_init_file_private(&file->prime);
164 file->driver_priv = file_priv; 163 file->driver_priv = file_priv;
165 164
166 return exynos_drm_subdrv_open(dev, file); 165 return exynos_drm_subdrv_open(dev, file);
@@ -184,7 +183,6 @@ static void exynos_drm_preclose(struct drm_device *dev,
184 e->base.destroy(&e->base); 183 e->base.destroy(&e->base);
185 } 184 }
186 } 185 }
187 drm_prime_destroy_file_private(&file->prime);
188 spin_unlock_irqrestore(&dev->event_lock, flags); 186 spin_unlock_irqrestore(&dev->event_lock, flags);
189 187
190 exynos_drm_subdrv_close(dev, file); 188 exynos_drm_subdrv_close(dev, file);
@@ -241,6 +239,9 @@ static const struct file_operations exynos_drm_driver_fops = {
241 .poll = drm_poll, 239 .poll = drm_poll,
242 .read = drm_read, 240 .read = drm_read,
243 .unlocked_ioctl = drm_ioctl, 241 .unlocked_ioctl = drm_ioctl,
242#ifdef CONFIG_COMPAT
243 .compat_ioctl = drm_compat_ioctl,
244#endif
244 .release = drm_release, 245 .release = drm_release,
245}; 246};
246 247
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index a68d2b313f03..b19cd93e7047 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -831,11 +831,6 @@ static int __devinit fimd_probe(struct platform_device *pdev)
831 } 831 }
832 832
833 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 833 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
834 if (!res) {
835 dev_err(dev, "failed to find registers\n");
836 ret = -ENOENT;
837 goto err_clk;
838 }
839 834
840 ctx->regs = devm_request_and_ioremap(&pdev->dev, res); 835 ctx->regs = devm_request_and_ioremap(&pdev->dev, res);
841 if (!ctx->regs) { 836 if (!ctx->regs) {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index d2d88f22a037..1065e90d0919 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -129,7 +129,6 @@ struct g2d_runqueue_node {
129struct g2d_data { 129struct g2d_data {
130 struct device *dev; 130 struct device *dev;
131 struct clk *gate_clk; 131 struct clk *gate_clk;
132 struct resource *regs_res;
133 void __iomem *regs; 132 void __iomem *regs;
134 int irq; 133 int irq;
135 struct workqueue_struct *g2d_workq; 134 struct workqueue_struct *g2d_workq;
@@ -751,7 +750,7 @@ static int __devinit g2d_probe(struct platform_device *pdev)
751 struct exynos_drm_subdrv *subdrv; 750 struct exynos_drm_subdrv *subdrv;
752 int ret; 751 int ret;
753 752
754 g2d = kzalloc(sizeof(*g2d), GFP_KERNEL); 753 g2d = devm_kzalloc(&pdev->dev, sizeof(*g2d), GFP_KERNEL);
755 if (!g2d) { 754 if (!g2d) {
756 dev_err(dev, "failed to allocate driver data\n"); 755 dev_err(dev, "failed to allocate driver data\n");
757 return -ENOMEM; 756 return -ENOMEM;
@@ -759,10 +758,8 @@ static int __devinit g2d_probe(struct platform_device *pdev)
759 758
760 g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab", 759 g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab",
761 sizeof(struct g2d_runqueue_node), 0, 0, NULL); 760 sizeof(struct g2d_runqueue_node), 0, 0, NULL);
762 if (!g2d->runqueue_slab) { 761 if (!g2d->runqueue_slab)
763 ret = -ENOMEM; 762 return -ENOMEM;
764 goto err_free_mem;
765 }
766 763
767 g2d->dev = dev; 764 g2d->dev = dev;
768 765
@@ -794,38 +791,26 @@ static int __devinit g2d_probe(struct platform_device *pdev)
794 pm_runtime_enable(dev); 791 pm_runtime_enable(dev);
795 792
796 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 793 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
797 if (!res) {
798 dev_err(dev, "failed to get I/O memory\n");
799 ret = -ENOENT;
800 goto err_put_clk;
801 }
802 794
803 g2d->regs_res = request_mem_region(res->start, resource_size(res), 795 g2d->regs = devm_request_and_ioremap(&pdev->dev, res);
804 dev_name(dev));
805 if (!g2d->regs_res) {
806 dev_err(dev, "failed to request I/O memory\n");
807 ret = -ENOENT;
808 goto err_put_clk;
809 }
810
811 g2d->regs = ioremap(res->start, resource_size(res));
812 if (!g2d->regs) { 796 if (!g2d->regs) {
813 dev_err(dev, "failed to remap I/O memory\n"); 797 dev_err(dev, "failed to remap I/O memory\n");
814 ret = -ENXIO; 798 ret = -ENXIO;
815 goto err_release_res; 799 goto err_put_clk;
816 } 800 }
817 801
818 g2d->irq = platform_get_irq(pdev, 0); 802 g2d->irq = platform_get_irq(pdev, 0);
819 if (g2d->irq < 0) { 803 if (g2d->irq < 0) {
820 dev_err(dev, "failed to get irq\n"); 804 dev_err(dev, "failed to get irq\n");
821 ret = g2d->irq; 805 ret = g2d->irq;
822 goto err_unmap_base; 806 goto err_put_clk;
823 } 807 }
824 808
825 ret = request_irq(g2d->irq, g2d_irq_handler, 0, "drm_g2d", g2d); 809 ret = devm_request_irq(&pdev->dev, g2d->irq, g2d_irq_handler, 0,
810 "drm_g2d", g2d);
826 if (ret < 0) { 811 if (ret < 0) {
827 dev_err(dev, "irq request failed\n"); 812 dev_err(dev, "irq request failed\n");
828 goto err_unmap_base; 813 goto err_put_clk;
829 } 814 }
830 815
831 platform_set_drvdata(pdev, g2d); 816 platform_set_drvdata(pdev, g2d);
@@ -838,7 +823,7 @@ static int __devinit g2d_probe(struct platform_device *pdev)
838 ret = exynos_drm_subdrv_register(subdrv); 823 ret = exynos_drm_subdrv_register(subdrv);
839 if (ret < 0) { 824 if (ret < 0) {
840 dev_err(dev, "failed to register drm g2d device\n"); 825 dev_err(dev, "failed to register drm g2d device\n");
841 goto err_free_irq; 826 goto err_put_clk;
842 } 827 }
843 828
844 dev_info(dev, "The exynos g2d(ver %d.%d) successfully probed\n", 829 dev_info(dev, "The exynos g2d(ver %d.%d) successfully probed\n",
@@ -846,13 +831,6 @@ static int __devinit g2d_probe(struct platform_device *pdev)
846 831
847 return 0; 832 return 0;
848 833
849err_free_irq:
850 free_irq(g2d->irq, g2d);
851err_unmap_base:
852 iounmap(g2d->regs);
853err_release_res:
854 release_resource(g2d->regs_res);
855 kfree(g2d->regs_res);
856err_put_clk: 834err_put_clk:
857 pm_runtime_disable(dev); 835 pm_runtime_disable(dev);
858 clk_put(g2d->gate_clk); 836 clk_put(g2d->gate_clk);
@@ -862,8 +840,6 @@ err_destroy_workqueue:
862 destroy_workqueue(g2d->g2d_workq); 840 destroy_workqueue(g2d->g2d_workq);
863err_destroy_slab: 841err_destroy_slab:
864 kmem_cache_destroy(g2d->runqueue_slab); 842 kmem_cache_destroy(g2d->runqueue_slab);
865err_free_mem:
866 kfree(g2d);
867 return ret; 843 return ret;
868} 844}
869 845
@@ -873,24 +849,18 @@ static int __devexit g2d_remove(struct platform_device *pdev)
873 849
874 cancel_work_sync(&g2d->runqueue_work); 850 cancel_work_sync(&g2d->runqueue_work);
875 exynos_drm_subdrv_unregister(&g2d->subdrv); 851 exynos_drm_subdrv_unregister(&g2d->subdrv);
876 free_irq(g2d->irq, g2d);
877 852
878 while (g2d->runqueue_node) { 853 while (g2d->runqueue_node) {
879 g2d_free_runqueue_node(g2d, g2d->runqueue_node); 854 g2d_free_runqueue_node(g2d, g2d->runqueue_node);
880 g2d->runqueue_node = g2d_get_runqueue_node(g2d); 855 g2d->runqueue_node = g2d_get_runqueue_node(g2d);
881 } 856 }
882 857
883 iounmap(g2d->regs);
884 release_resource(g2d->regs_res);
885 kfree(g2d->regs_res);
886
887 pm_runtime_disable(&pdev->dev); 858 pm_runtime_disable(&pdev->dev);
888 clk_put(g2d->gate_clk); 859 clk_put(g2d->gate_clk);
889 860
890 g2d_fini_cmdlist(g2d); 861 g2d_fini_cmdlist(g2d);
891 destroy_workqueue(g2d->g2d_workq); 862 destroy_workqueue(g2d->g2d_workq);
892 kmem_cache_destroy(g2d->runqueue_slab); 863 kmem_cache_destroy(g2d->runqueue_slab);
893 kfree(g2d);
894 864
895 return 0; 865 return 0;
896} 866}
@@ -924,7 +894,7 @@ static int g2d_resume(struct device *dev)
924} 894}
925#endif 895#endif
926 896
927SIMPLE_DEV_PM_OPS(g2d_pm_ops, g2d_suspend, g2d_resume); 897static SIMPLE_DEV_PM_OPS(g2d_pm_ops, g2d_suspend, g2d_resume);
928 898
929struct platform_driver g2d_driver = { 899struct platform_driver g2d_driver = {
930 .probe = g2d_probe, 900 .probe = g2d_probe,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index f9efde40c097..a38051c95ec4 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -122,7 +122,7 @@ fail:
122 __free_page(pages[i]); 122 __free_page(pages[i]);
123 123
124 drm_free_large(pages); 124 drm_free_large(pages);
125 return ERR_PTR(PTR_ERR(p)); 125 return ERR_CAST(p);
126} 126}
127 127
128static void exynos_gem_put_pages(struct drm_gem_object *obj, 128static void exynos_gem_put_pages(struct drm_gem_object *obj,
@@ -662,7 +662,7 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
662 */ 662 */
663 663
664 args->pitch = args->width * ((args->bpp + 7) / 8); 664 args->pitch = args->width * ((args->bpp + 7) / 8);
665 args->size = PAGE_ALIGN(args->pitch * args->height); 665 args->size = args->pitch * args->height;
666 666
667 exynos_gem_obj = exynos_drm_gem_create(dev, args->flags, args->size); 667 exynos_gem_obj = exynos_drm_gem_create(dev, args->flags, args->size);
668 if (IS_ERR(exynos_gem_obj)) 668 if (IS_ERR(exynos_gem_obj))
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
index 8ffcdf8b9e22..3fdf0b65f47e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
@@ -345,7 +345,7 @@ static int __devinit exynos_drm_hdmi_probe(struct platform_device *pdev)
345 345
346 DRM_DEBUG_KMS("%s\n", __FILE__); 346 DRM_DEBUG_KMS("%s\n", __FILE__);
347 347
348 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 348 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
349 if (!ctx) { 349 if (!ctx) {
350 DRM_LOG_KMS("failed to alloc common hdmi context.\n"); 350 DRM_LOG_KMS("failed to alloc common hdmi context.\n");
351 return -ENOMEM; 351 return -ENOMEM;
@@ -371,7 +371,6 @@ static int __devexit exynos_drm_hdmi_remove(struct platform_device *pdev)
371 DRM_DEBUG_KMS("%s\n", __FILE__); 371 DRM_DEBUG_KMS("%s\n", __FILE__);
372 372
373 exynos_drm_subdrv_unregister(&ctx->subdrv); 373 exynos_drm_subdrv_unregister(&ctx->subdrv);
374 kfree(ctx);
375 374
376 return 0; 375 return 0;
377} 376}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index b89829e5043a..e1f94b746bd7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -29,7 +29,6 @@ static const uint32_t formats[] = {
29 DRM_FORMAT_XRGB8888, 29 DRM_FORMAT_XRGB8888,
30 DRM_FORMAT_ARGB8888, 30 DRM_FORMAT_ARGB8888,
31 DRM_FORMAT_NV12, 31 DRM_FORMAT_NV12,
32 DRM_FORMAT_NV12M,
33 DRM_FORMAT_NV12MT, 32 DRM_FORMAT_NV12MT,
34}; 33};
35 34
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index bb1550c4dd57..537027a74fd5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -633,7 +633,7 @@ static int __devinit vidi_probe(struct platform_device *pdev)
633 633
634 DRM_DEBUG_KMS("%s\n", __FILE__); 634 DRM_DEBUG_KMS("%s\n", __FILE__);
635 635
636 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 636 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
637 if (!ctx) 637 if (!ctx)
638 return -ENOMEM; 638 return -ENOMEM;
639 639
@@ -673,8 +673,6 @@ static int __devexit vidi_remove(struct platform_device *pdev)
673 ctx->raw_edid = NULL; 673 ctx->raw_edid = NULL;
674 } 674 }
675 675
676 kfree(ctx);
677
678 return 0; 676 return 0;
679} 677}
680 678
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 409e2ec1207c..a6aea6f3ea1a 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -2172,7 +2172,7 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
2172 2172
2173 DRM_DEBUG_KMS("HDMI resource init\n"); 2173 DRM_DEBUG_KMS("HDMI resource init\n");
2174 2174
2175 memset(res, 0, sizeof *res); 2175 memset(res, 0, sizeof(*res));
2176 2176
2177 /* get clocks, power */ 2177 /* get clocks, power */
2178 res->hdmi = clk_get(dev, "hdmi"); 2178 res->hdmi = clk_get(dev, "hdmi");
@@ -2204,7 +2204,7 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
2204 clk_set_parent(res->sclk_hdmi, res->sclk_pixel); 2204 clk_set_parent(res->sclk_hdmi, res->sclk_pixel);
2205 2205
2206 res->regul_bulk = kzalloc(ARRAY_SIZE(supply) * 2206 res->regul_bulk = kzalloc(ARRAY_SIZE(supply) *
2207 sizeof res->regul_bulk[0], GFP_KERNEL); 2207 sizeof(res->regul_bulk[0]), GFP_KERNEL);
2208 if (!res->regul_bulk) { 2208 if (!res->regul_bulk) {
2209 DRM_ERROR("failed to get memory for regulators\n"); 2209 DRM_ERROR("failed to get memory for regulators\n");
2210 goto fail; 2210 goto fail;
@@ -2243,7 +2243,7 @@ static int hdmi_resources_cleanup(struct hdmi_context *hdata)
2243 clk_put(res->sclk_hdmi); 2243 clk_put(res->sclk_hdmi);
2244 if (!IS_ERR_OR_NULL(res->hdmi)) 2244 if (!IS_ERR_OR_NULL(res->hdmi))
2245 clk_put(res->hdmi); 2245 clk_put(res->hdmi);
2246 memset(res, 0, sizeof *res); 2246 memset(res, 0, sizeof(*res));
2247 2247
2248 return 0; 2248 return 0;
2249} 2249}
@@ -2312,11 +2312,6 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
2312 } 2312 }
2313 2313
2314 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2314 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2315 if (!res) {
2316 DRM_ERROR("failed to find registers\n");
2317 ret = -ENOENT;
2318 goto err_resource;
2319 }
2320 2315
2321 hdata->regs = devm_request_and_ioremap(&pdev->dev, res); 2316 hdata->regs = devm_request_and_ioremap(&pdev->dev, res);
2322 if (!hdata->regs) { 2317 if (!hdata->regs) {
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 30fcc12f81dd..25b97d5e5fcb 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -236,11 +236,11 @@ static inline void vp_filter_set(struct mixer_resources *res,
236static void vp_default_filter(struct mixer_resources *res) 236static void vp_default_filter(struct mixer_resources *res)
237{ 237{
238 vp_filter_set(res, VP_POLY8_Y0_LL, 238 vp_filter_set(res, VP_POLY8_Y0_LL,
239 filter_y_horiz_tap8, sizeof filter_y_horiz_tap8); 239 filter_y_horiz_tap8, sizeof(filter_y_horiz_tap8));
240 vp_filter_set(res, VP_POLY4_Y0_LL, 240 vp_filter_set(res, VP_POLY4_Y0_LL,
241 filter_y_vert_tap4, sizeof filter_y_vert_tap4); 241 filter_y_vert_tap4, sizeof(filter_y_vert_tap4));
242 vp_filter_set(res, VP_POLY4_C0_LL, 242 vp_filter_set(res, VP_POLY4_C0_LL,
243 filter_cr_horiz_tap4, sizeof filter_cr_horiz_tap4); 243 filter_cr_horiz_tap4, sizeof(filter_cr_horiz_tap4));
244} 244}
245 245
246static void mixer_vsync_set_update(struct mixer_context *ctx, bool enable) 246static void mixer_vsync_set_update(struct mixer_context *ctx, bool enable)
diff --git a/drivers/gpu/drm/gma500/oaktrail_device.c b/drivers/gpu/drm/gma500/oaktrail_device.c
index 0f9b7db80f6b..cf49ba5a54bf 100644
--- a/drivers/gpu/drm/gma500/oaktrail_device.c
+++ b/drivers/gpu/drm/gma500/oaktrail_device.c
@@ -476,6 +476,7 @@ static const struct psb_offset oaktrail_regmap[2] = {
476 .pos = DSPAPOS, 476 .pos = DSPAPOS,
477 .surf = DSPASURF, 477 .surf = DSPASURF,
478 .addr = MRST_DSPABASE, 478 .addr = MRST_DSPABASE,
479 .base = MRST_DSPABASE,
479 .status = PIPEASTAT, 480 .status = PIPEASTAT,
480 .linoff = DSPALINOFF, 481 .linoff = DSPALINOFF,
481 .tileoff = DSPATILEOFF, 482 .tileoff = DSPATILEOFF,
@@ -499,6 +500,7 @@ static const struct psb_offset oaktrail_regmap[2] = {
499 .pos = DSPBPOS, 500 .pos = DSPBPOS,
500 .surf = DSPBSURF, 501 .surf = DSPBSURF,
501 .addr = DSPBBASE, 502 .addr = DSPBBASE,
503 .base = DSPBBASE,
502 .status = PIPEBSTAT, 504 .status = PIPEBSTAT,
503 .linoff = DSPBLINOFF, 505 .linoff = DSPBLINOFF,
504 .tileoff = DSPBTILEOFF, 506 .tileoff = DSPBTILEOFF,
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 57d892eaaa6e..463ec6871fe9 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -115,6 +115,9 @@ static const struct file_operations i810_buffer_fops = {
115 .unlocked_ioctl = drm_ioctl, 115 .unlocked_ioctl = drm_ioctl,
116 .mmap = i810_mmap_buffers, 116 .mmap = i810_mmap_buffers,
117 .fasync = drm_fasync, 117 .fasync = drm_fasync,
118#ifdef CONFIG_COMPAT
119 .compat_ioctl = drm_compat_ioctl,
120#endif
118 .llseek = noop_llseek, 121 .llseek = noop_llseek,
119}; 122};
120 123
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index f9924ad04d09..48cfcca2b350 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -51,6 +51,9 @@ static const struct file_operations i810_driver_fops = {
51 .mmap = drm_mmap, 51 .mmap = drm_mmap,
52 .poll = drm_poll, 52 .poll = drm_poll,
53 .fasync = drm_fasync, 53 .fasync = drm_fasync,
54#ifdef CONFIG_COMPAT
55 .compat_ioctl = drm_compat_ioctl,
56#endif
54 .llseek = noop_llseek, 57 .llseek = noop_llseek,
55}; 58};
56 59
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 9cf7dfe022b9..914c0dfabe60 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1587,6 +1587,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1587 spin_lock_init(&dev_priv->irq_lock); 1587 spin_lock_init(&dev_priv->irq_lock);
1588 spin_lock_init(&dev_priv->error_lock); 1588 spin_lock_init(&dev_priv->error_lock);
1589 spin_lock_init(&dev_priv->rps_lock); 1589 spin_lock_init(&dev_priv->rps_lock);
1590 spin_lock_init(&dev_priv->dpio_lock);
1590 1591
1591 if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) 1592 if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
1592 dev_priv->num_pipe = 3; 1593 dev_priv->num_pipe = 3;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 489e2b162b27..274d25de521e 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3242,7 +3242,8 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
3242{ 3242{
3243 int ret; 3243 int ret;
3244 3244
3245 BUG_ON(obj->pin_count == DRM_I915_GEM_OBJECT_MAX_PIN_COUNT); 3245 if (WARN_ON(obj->pin_count == DRM_I915_GEM_OBJECT_MAX_PIN_COUNT))
3246 return -EBUSY;
3246 3247
3247 if (obj->gtt_space != NULL) { 3248 if (obj->gtt_space != NULL) {
3248 if ((alignment && obj->gtt_offset & (alignment - 1)) || 3249 if ((alignment && obj->gtt_offset & (alignment - 1)) ||
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 8a3828528b9d..5249640cce13 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -2700,9 +2700,6 @@ void intel_irq_init(struct drm_device *dev)
2700 dev->driver->irq_handler = i8xx_irq_handler; 2700 dev->driver->irq_handler = i8xx_irq_handler;
2701 dev->driver->irq_uninstall = i8xx_irq_uninstall; 2701 dev->driver->irq_uninstall = i8xx_irq_uninstall;
2702 } else if (INTEL_INFO(dev)->gen == 3) { 2702 } else if (INTEL_INFO(dev)->gen == 3) {
2703 /* IIR "flip pending" means done if this bit is set */
2704 I915_WRITE(ECOSKPD, _MASKED_BIT_DISABLE(ECO_FLIP_DONE));
2705
2706 dev->driver->irq_preinstall = i915_irq_preinstall; 2703 dev->driver->irq_preinstall = i915_irq_preinstall;
2707 dev->driver->irq_postinstall = i915_irq_postinstall; 2704 dev->driver->irq_postinstall = i915_irq_postinstall;
2708 dev->driver->irq_uninstall = i915_irq_uninstall; 2705 dev->driver->irq_uninstall = i915_irq_uninstall;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2dfa6cf4886b..c040aee1341c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1376,7 +1376,8 @@ static void assert_pch_dp_disabled(struct drm_i915_private *dev_priv,
1376 "PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n", 1376 "PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n",
1377 reg, pipe_name(pipe)); 1377 reg, pipe_name(pipe));
1378 1378
1379 WARN(HAS_PCH_IBX(dev_priv->dev) && (val & SDVO_PIPE_B_SELECT), 1379 WARN(HAS_PCH_IBX(dev_priv->dev) && (val & DP_PORT_EN) == 0
1380 && (val & DP_PIPEB_SELECT),
1380 "IBX PCH dp port still using transcoder B\n"); 1381 "IBX PCH dp port still using transcoder B\n");
1381} 1382}
1382 1383
@@ -1388,7 +1389,8 @@ static void assert_pch_hdmi_disabled(struct drm_i915_private *dev_priv,
1388 "PCH HDMI (0x%08x) enabled on transcoder %c, should be disabled\n", 1389 "PCH HDMI (0x%08x) enabled on transcoder %c, should be disabled\n",
1389 reg, pipe_name(pipe)); 1390 reg, pipe_name(pipe));
1390 1391
1391 WARN(HAS_PCH_IBX(dev_priv->dev) && (val & SDVO_PIPE_B_SELECT), 1392 WARN(HAS_PCH_IBX(dev_priv->dev) && (val & PORT_ENABLE) == 0
1393 && (val & SDVO_PIPE_B_SELECT),
1392 "IBX PCH hdmi port still using transcoder B\n"); 1394 "IBX PCH hdmi port still using transcoder B\n");
1393} 1395}
1394 1396
@@ -4189,12 +4191,6 @@ static void i8xx_update_pll(struct drm_crtc *crtc,
4189 POSTING_READ(DPLL(pipe)); 4191 POSTING_READ(DPLL(pipe));
4190 udelay(150); 4192 udelay(150);
4191 4193
4192 I915_WRITE(DPLL(pipe), dpll);
4193
4194 /* Wait for the clocks to stabilize. */
4195 POSTING_READ(DPLL(pipe));
4196 udelay(150);
4197
4198 /* The LVDS pin pair needs to be on before the DPLLs are enabled. 4194 /* The LVDS pin pair needs to be on before the DPLLs are enabled.
4199 * This is an exception to the general rule that mode_set doesn't turn 4195 * This is an exception to the general rule that mode_set doesn't turn
4200 * things on. 4196 * things on.
@@ -4202,6 +4198,12 @@ static void i8xx_update_pll(struct drm_crtc *crtc,
4202 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) 4198 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
4203 intel_update_lvds(crtc, clock, adjusted_mode); 4199 intel_update_lvds(crtc, clock, adjusted_mode);
4204 4200
4201 I915_WRITE(DPLL(pipe), dpll);
4202
4203 /* Wait for the clocks to stabilize. */
4204 POSTING_READ(DPLL(pipe));
4205 udelay(150);
4206
4205 /* The pixel multiplier can only be updated once the 4207 /* The pixel multiplier can only be updated once the
4206 * DPLL is enabled and the clocks are stable. 4208 * DPLL is enabled and the clocks are stable.
4207 * 4209 *
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index a6c426afaa7a..ace757af9133 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -2533,14 +2533,10 @@ intel_dp_init(struct drm_device *dev, int output_reg)
2533 break; 2533 break;
2534 } 2534 }
2535 2535
2536 intel_dp_i2c_init(intel_dp, intel_connector, name);
2537
2538 /* Cache some DPCD data in the eDP case */ 2536 /* Cache some DPCD data in the eDP case */
2539 if (is_edp(intel_dp)) { 2537 if (is_edp(intel_dp)) {
2540 bool ret;
2541 struct edp_power_seq cur, vbt; 2538 struct edp_power_seq cur, vbt;
2542 u32 pp_on, pp_off, pp_div; 2539 u32 pp_on, pp_off, pp_div;
2543 struct edid *edid;
2544 2540
2545 pp_on = I915_READ(PCH_PP_ON_DELAYS); 2541 pp_on = I915_READ(PCH_PP_ON_DELAYS);
2546 pp_off = I915_READ(PCH_PP_OFF_DELAYS); 2542 pp_off = I915_READ(PCH_PP_OFF_DELAYS);
@@ -2591,6 +2587,13 @@ intel_dp_init(struct drm_device *dev, int output_reg)
2591 2587
2592 DRM_DEBUG_KMS("backlight on delay %d, off delay %d\n", 2588 DRM_DEBUG_KMS("backlight on delay %d, off delay %d\n",
2593 intel_dp->backlight_on_delay, intel_dp->backlight_off_delay); 2589 intel_dp->backlight_on_delay, intel_dp->backlight_off_delay);
2590 }
2591
2592 intel_dp_i2c_init(intel_dp, intel_connector, name);
2593
2594 if (is_edp(intel_dp)) {
2595 bool ret;
2596 struct edid *edid;
2594 2597
2595 ironlake_edp_panel_vdd_on(intel_dp); 2598 ironlake_edp_panel_vdd_on(intel_dp);
2596 ret = intel_dp_get_dpcd(intel_dp); 2599 ret = intel_dp_get_dpcd(intel_dp);
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 98f602427eb8..12dc3308ab8c 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -609,7 +609,7 @@ static void intel_hdmi_dpms(struct drm_encoder *encoder, int mode)
609 u32 temp; 609 u32 temp;
610 u32 enable_bits = SDVO_ENABLE; 610 u32 enable_bits = SDVO_ENABLE;
611 611
612 if (intel_hdmi->has_audio) 612 if (intel_hdmi->has_audio || mode != DRM_MODE_DPMS_ON)
613 enable_bits |= SDVO_AUDIO_ENABLE; 613 enable_bits |= SDVO_AUDIO_ENABLE;
614 614
615 temp = I915_READ(intel_hdmi->sdvox_reg); 615 temp = I915_READ(intel_hdmi->sdvox_reg);
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 3df4f5fa892a..e019b2369861 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -162,19 +162,12 @@ static u32 i915_read_blc_pwm_ctl(struct drm_i915_private *dev_priv)
162 return val; 162 return val;
163} 163}
164 164
165u32 intel_panel_get_max_backlight(struct drm_device *dev) 165static u32 _intel_panel_get_max_backlight(struct drm_device *dev)
166{ 166{
167 struct drm_i915_private *dev_priv = dev->dev_private; 167 struct drm_i915_private *dev_priv = dev->dev_private;
168 u32 max; 168 u32 max;
169 169
170 max = i915_read_blc_pwm_ctl(dev_priv); 170 max = i915_read_blc_pwm_ctl(dev_priv);
171 if (max == 0) {
172 /* XXX add code here to query mode clock or hardware clock
173 * and program max PWM appropriately.
174 */
175 pr_warn_once("fixme: max PWM is zero\n");
176 return 1;
177 }
178 171
179 if (HAS_PCH_SPLIT(dev)) { 172 if (HAS_PCH_SPLIT(dev)) {
180 max >>= 16; 173 max >>= 16;
@@ -188,6 +181,22 @@ u32 intel_panel_get_max_backlight(struct drm_device *dev)
188 max *= 0xff; 181 max *= 0xff;
189 } 182 }
190 183
184 return max;
185}
186
187u32 intel_panel_get_max_backlight(struct drm_device *dev)
188{
189 u32 max;
190
191 max = _intel_panel_get_max_backlight(dev);
192 if (max == 0) {
193 /* XXX add code here to query mode clock or hardware clock
194 * and program max PWM appropriately.
195 */
196 pr_warn_once("fixme: max PWM is zero\n");
197 return 1;
198 }
199
191 DRM_DEBUG_DRIVER("max backlight PWM = %d\n", max); 200 DRM_DEBUG_DRIVER("max backlight PWM = %d\n", max);
192 return max; 201 return max;
193} 202}
@@ -424,7 +433,11 @@ int intel_panel_setup_backlight(struct drm_device *dev)
424 433
425 memset(&props, 0, sizeof(props)); 434 memset(&props, 0, sizeof(props));
426 props.type = BACKLIGHT_RAW; 435 props.type = BACKLIGHT_RAW;
427 props.max_brightness = intel_panel_get_max_backlight(dev); 436 props.max_brightness = _intel_panel_get_max_backlight(dev);
437 if (props.max_brightness == 0) {
438 DRM_ERROR("Failed to get maximum backlight value\n");
439 return -ENODEV;
440 }
428 dev_priv->backlight = 441 dev_priv->backlight =
429 backlight_device_register("intel_backlight", 442 backlight_device_register("intel_backlight",
430 &connector->kdev, dev, 443 &connector->kdev, dev,
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 1881c8c83f0e..ba8a27b1757a 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3672,6 +3672,9 @@ static void gen3_init_clock_gating(struct drm_device *dev)
3672 3672
3673 if (IS_PINEVIEW(dev)) 3673 if (IS_PINEVIEW(dev))
3674 I915_WRITE(ECOSKPD, _MASKED_BIT_ENABLE(ECO_GATING_CX_ONLY)); 3674 I915_WRITE(ECOSKPD, _MASKED_BIT_ENABLE(ECO_GATING_CX_ONLY));
3675
3676 /* IIR "flip pending" means done if this bit is set */
3677 I915_WRITE(ECOSKPD, _MASKED_BIT_DISABLE(ECO_FLIP_DONE));
3675} 3678}
3676 3679
3677static void i85x_init_clock_gating(struct drm_device *dev) 3680static void i85x_init_clock_gating(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index d81bb0bf2885..123afd357611 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -2573,7 +2573,6 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2573 hotplug_mask = intel_sdvo->is_sdvob ? 2573 hotplug_mask = intel_sdvo->is_sdvob ?
2574 SDVOB_HOTPLUG_INT_STATUS_I915 : SDVOC_HOTPLUG_INT_STATUS_I915; 2574 SDVOB_HOTPLUG_INT_STATUS_I915 : SDVOC_HOTPLUG_INT_STATUS_I915;
2575 } 2575 }
2576 dev_priv->hotplug_supported_mask |= hotplug_mask;
2577 2576
2578 drm_encoder_helper_add(&intel_encoder->base, &intel_sdvo_helper_funcs); 2577 drm_encoder_helper_add(&intel_encoder->base, &intel_sdvo_helper_funcs);
2579 2578
@@ -2581,14 +2580,6 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2581 if (!intel_sdvo_get_capabilities(intel_sdvo, &intel_sdvo->caps)) 2580 if (!intel_sdvo_get_capabilities(intel_sdvo, &intel_sdvo->caps))
2582 goto err; 2581 goto err;
2583 2582
2584 /* Set up hotplug command - note paranoia about contents of reply.
2585 * We assume that the hardware is in a sane state, and only touch
2586 * the bits we think we understand.
2587 */
2588 intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG,
2589 &intel_sdvo->hotplug_active, 2);
2590 intel_sdvo->hotplug_active[0] &= ~0x3;
2591
2592 if (intel_sdvo_output_setup(intel_sdvo, 2583 if (intel_sdvo_output_setup(intel_sdvo,
2593 intel_sdvo->caps.output_flags) != true) { 2584 intel_sdvo->caps.output_flags) != true) {
2594 DRM_DEBUG_KMS("SDVO output failed to setup on %s\n", 2585 DRM_DEBUG_KMS("SDVO output failed to setup on %s\n",
@@ -2596,6 +2587,12 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2596 goto err; 2587 goto err;
2597 } 2588 }
2598 2589
2590 /* Only enable the hotplug irq if we need it, to work around noisy
2591 * hotplug lines.
2592 */
2593 if (intel_sdvo->hotplug_active[0])
2594 dev_priv->hotplug_supported_mask |= hotplug_mask;
2595
2599 intel_sdvo_select_ddc_bus(dev_priv, intel_sdvo, sdvo_reg); 2596 intel_sdvo_select_ddc_bus(dev_priv, intel_sdvo, sdvo_reg);
2600 2597
2601 /* Set the input timing to the screen. Assume always input 0. */ 2598 /* Set the input timing to the screen. Assume always input 0. */
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index ea1024d79974..e5f145d2cb3b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -84,6 +84,9 @@ static const struct file_operations mgag200_driver_fops = {
84 .mmap = mgag200_mmap, 84 .mmap = mgag200_mmap,
85 .poll = drm_poll, 85 .poll = drm_poll,
86 .fasync = drm_fasync, 86 .fasync = drm_fasync,
87#ifdef CONFIG_COMPAT
88 .compat_ioctl = drm_compat_ioctl,
89#endif
87 .read = drm_read, 90 .read = drm_read,
88}; 91};
89 92
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 69688ef5cf46..7e16dc5e6467 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -598,7 +598,7 @@ nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
598 args->size = args->pitch * args->height; 598 args->size = args->pitch * args->height;
599 args->size = roundup(args->size, PAGE_SIZE); 599 args->size = roundup(args->size, PAGE_SIZE);
600 600
601 ret = nouveau_gem_new(dev, args->size, 0, TTM_PL_FLAG_VRAM, 0, 0, &bo); 601 ret = nouveau_gem_new(dev, args->size, 0, NOUVEAU_GEM_DOMAIN_VRAM, 0, 0, &bo);
602 if (ret) 602 if (ret)
603 return ret; 603 return ret;
604 604
diff --git a/drivers/gpu/drm/nouveau/nv50_gpio.c b/drivers/gpu/drm/nouveau/nv50_gpio.c
index f429e6a8ca7a..c399d510b27a 100644
--- a/drivers/gpu/drm/nouveau/nv50_gpio.c
+++ b/drivers/gpu/drm/nouveau/nv50_gpio.c
@@ -22,6 +22,7 @@
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25#include <linux/dmi.h>
25#include "drmP.h" 26#include "drmP.h"
26#include "nouveau_drv.h" 27#include "nouveau_drv.h"
27#include "nouveau_hw.h" 28#include "nouveau_hw.h"
@@ -110,11 +111,26 @@ nv50_gpio_isr(struct drm_device *dev)
110 nv_wr32(dev, 0xe074, intr1); 111 nv_wr32(dev, 0xe074, intr1);
111} 112}
112 113
114static struct dmi_system_id gpio_reset_ids[] = {
115 {
116 .ident = "Apple Macbook 10,1",
117 .matches = {
118 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
119 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro10,1"),
120 }
121 },
122 { }
123};
124
113int 125int
114nv50_gpio_init(struct drm_device *dev) 126nv50_gpio_init(struct drm_device *dev)
115{ 127{
116 struct drm_nouveau_private *dev_priv = dev->dev_private; 128 struct drm_nouveau_private *dev_priv = dev->dev_private;
117 129
130 /* initialise gpios and routing to vbios defaults */
131 if (dmi_check_system(gpio_reset_ids))
132 nouveau_gpio_reset(dev);
133
118 /* disable, and ack any pending gpio interrupts */ 134 /* disable, and ack any pending gpio interrupts */
119 nv_wr32(dev, 0xe050, 0x00000000); 135 nv_wr32(dev, 0xe050, 0x00000000);
120 nv_wr32(dev, 0xe054, 0xffffffff); 136 nv_wr32(dev, 0xe054, 0xffffffff);
diff --git a/drivers/gpu/drm/nouveau/nvd0_display.c b/drivers/gpu/drm/nouveau/nvd0_display.c
index dac525b2994e..8a2fc89b7763 100644
--- a/drivers/gpu/drm/nouveau/nvd0_display.c
+++ b/drivers/gpu/drm/nouveau/nvd0_display.c
@@ -1510,10 +1510,10 @@ nvd0_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode,
1510 case OUTPUT_DP: 1510 case OUTPUT_DP:
1511 if (nv_connector->base.display_info.bpc == 6) { 1511 if (nv_connector->base.display_info.bpc == 6) {
1512 nv_encoder->dp.datarate = mode->clock * 18 / 8; 1512 nv_encoder->dp.datarate = mode->clock * 18 / 8;
1513 syncs |= 0x00000140; 1513 syncs |= 0x00000002 << 6;
1514 } else { 1514 } else {
1515 nv_encoder->dp.datarate = mode->clock * 24 / 8; 1515 nv_encoder->dp.datarate = mode->clock * 24 / 8;
1516 syncs |= 0x00000180; 1516 syncs |= 0x00000005 << 6;
1517 } 1517 }
1518 1518
1519 if (nv_encoder->dcb->sorconf.link & 1) 1519 if (nv_encoder->dcb->sorconf.link & 1)
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 8acb34fd3fd5..8d7e33a0b243 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -1182,7 +1182,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
1182 ring->ready = true; 1182 ring->ready = true;
1183 radeon_ttm_set_active_vram_size(rdev, rdev->mc.real_vram_size); 1183 radeon_ttm_set_active_vram_size(rdev, rdev->mc.real_vram_size);
1184 1184
1185 if (radeon_ring_supports_scratch_reg(rdev, ring)) { 1185 if (!ring->rptr_save_reg /* not resuming from suspend */
1186 && radeon_ring_supports_scratch_reg(rdev, ring)) {
1186 r = radeon_scratch_get(rdev, &ring->rptr_save_reg); 1187 r = radeon_scratch_get(rdev, &ring->rptr_save_reg);
1187 if (r) { 1188 if (r) {
1188 DRM_ERROR("failed to get scratch reg for rptr save (%d).\n", r); 1189 DRM_ERROR("failed to get scratch reg for rptr save (%d).\n", r);
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 7b737b9339ad..2a59375dbe52 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -131,7 +131,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
131 */ 131 */
132void radeon_fence_process(struct radeon_device *rdev, int ring) 132void radeon_fence_process(struct radeon_device *rdev, int ring)
133{ 133{
134 uint64_t seq, last_seq; 134 uint64_t seq, last_seq, last_emitted;
135 unsigned count_loop = 0; 135 unsigned count_loop = 0;
136 bool wake = false; 136 bool wake = false;
137 137
@@ -158,13 +158,15 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
158 */ 158 */
159 last_seq = atomic64_read(&rdev->fence_drv[ring].last_seq); 159 last_seq = atomic64_read(&rdev->fence_drv[ring].last_seq);
160 do { 160 do {
161 last_emitted = rdev->fence_drv[ring].sync_seq[ring];
161 seq = radeon_fence_read(rdev, ring); 162 seq = radeon_fence_read(rdev, ring);
162 seq |= last_seq & 0xffffffff00000000LL; 163 seq |= last_seq & 0xffffffff00000000LL;
163 if (seq < last_seq) { 164 if (seq < last_seq) {
164 seq += 0x100000000LL; 165 seq &= 0xffffffff;
166 seq |= last_emitted & 0xffffffff00000000LL;
165 } 167 }
166 168
167 if (seq == last_seq) { 169 if (seq <= last_seq || seq > last_emitted) {
168 break; 170 break;
169 } 171 }
170 /* If we loop over we don't want to return without 172 /* If we loop over we don't want to return without
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index d31d4cca9a4c..c5a164337bd5 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -43,6 +43,9 @@ static const struct file_operations savage_driver_fops = {
43 .mmap = drm_mmap, 43 .mmap = drm_mmap,
44 .poll = drm_poll, 44 .poll = drm_poll,
45 .fasync = drm_fasync, 45 .fasync = drm_fasync,
46#ifdef CONFIG_COMPAT
47 .compat_ioctl = drm_compat_ioctl,
48#endif
46 .llseek = noop_llseek, 49 .llseek = noop_llseek,
47}; 50};
48 51
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 7f119870147c..867dc03000e6 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -74,6 +74,9 @@ static const struct file_operations sis_driver_fops = {
74 .mmap = drm_mmap, 74 .mmap = drm_mmap,
75 .poll = drm_poll, 75 .poll = drm_poll,
76 .fasync = drm_fasync, 76 .fasync = drm_fasync,
77#ifdef CONFIG_COMPAT
78 .compat_ioctl = drm_compat_ioctl,
79#endif
77 .llseek = noop_llseek, 80 .llseek = noop_llseek,
78}; 81};
79 82
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 90f6b13acfac..a7f4d6bd1330 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -49,6 +49,9 @@ static const struct file_operations tdfx_driver_fops = {
49 .mmap = drm_mmap, 49 .mmap = drm_mmap,
50 .poll = drm_poll, 50 .poll = drm_poll,
51 .fasync = drm_fasync, 51 .fasync = drm_fasync,
52#ifdef CONFIG_COMPAT
53 .compat_ioctl = drm_compat_ioctl,
54#endif
52 .llseek = noop_llseek, 55 .llseek = noop_llseek,
53}; 56};
54 57
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 6e52069894b3..9f84128505bb 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -66,6 +66,9 @@ static const struct file_operations udl_driver_fops = {
66 .unlocked_ioctl = drm_ioctl, 66 .unlocked_ioctl = drm_ioctl,
67 .release = drm_release, 67 .release = drm_release,
68 .fasync = drm_fasync, 68 .fasync = drm_fasync,
69#ifdef CONFIG_COMPAT
70 .compat_ioctl = drm_compat_ioctl,
71#endif
69 .llseek = noop_llseek, 72 .llseek = noop_llseek,
70}; 73};
71 74
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index e927b4c052f5..af1b914b17e3 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -65,6 +65,9 @@ static const struct file_operations via_driver_fops = {
65 .mmap = drm_mmap, 65 .mmap = drm_mmap,
66 .poll = drm_poll, 66 .poll = drm_poll,
67 .fasync = drm_fasync, 67 .fasync = drm_fasync,
68#ifdef CONFIG_COMPAT
69 .compat_ioctl = drm_compat_ioctl,
70#endif
68 .llseek = noop_llseek, 71 .llseek = noop_llseek,
69}; 72};
70 73
diff --git a/drivers/gpu/drm/vmwgfx/Kconfig b/drivers/gpu/drm/vmwgfx/Kconfig
index 794ff67c5701..b71bcd0bfbbf 100644
--- a/drivers/gpu/drm/vmwgfx/Kconfig
+++ b/drivers/gpu/drm/vmwgfx/Kconfig
@@ -12,3 +12,11 @@ config DRM_VMWGFX
12 This is a KMS enabled DRM driver for the VMware SVGA2 12 This is a KMS enabled DRM driver for the VMware SVGA2
13 virtual hardware. 13 virtual hardware.
14 The compiled module will be called "vmwgfx.ko". 14 The compiled module will be called "vmwgfx.ko".
15
16config DRM_VMWGFX_FBCON
17 depends on DRM_VMWGFX
18 bool "Enable framebuffer console under vmwgfx by default"
19 help
20 Choose this option if you are shipping a new vmwgfx
21 userspace driver that supports using the kernel driver.
22
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 4d9edead01ac..ba2c35dbf10e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -182,8 +182,9 @@ static struct pci_device_id vmw_pci_id_list[] = {
182 {0x15ad, 0x0405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VMWGFX_CHIP_SVGAII}, 182 {0x15ad, 0x0405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VMWGFX_CHIP_SVGAII},
183 {0, 0, 0} 183 {0, 0, 0}
184}; 184};
185MODULE_DEVICE_TABLE(pci, vmw_pci_id_list);
185 186
186static int enable_fbdev; 187static int enable_fbdev = IS_ENABLED(CONFIG_DRM_VMWGFX_FBCON);
187 188
188static int vmw_probe(struct pci_dev *, const struct pci_device_id *); 189static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
189static void vmw_master_init(struct vmw_master *); 190static void vmw_master_init(struct vmw_master *);
@@ -1154,6 +1155,11 @@ static struct drm_driver driver = {
1154 .open = vmw_driver_open, 1155 .open = vmw_driver_open,
1155 .preclose = vmw_preclose, 1156 .preclose = vmw_preclose,
1156 .postclose = vmw_postclose, 1157 .postclose = vmw_postclose,
1158
1159 .dumb_create = vmw_dumb_create,
1160 .dumb_map_offset = vmw_dumb_map_offset,
1161 .dumb_destroy = vmw_dumb_destroy,
1162
1157 .fops = &vmwgfx_driver_fops, 1163 .fops = &vmwgfx_driver_fops,
1158 .name = VMWGFX_DRIVER_NAME, 1164 .name = VMWGFX_DRIVER_NAME,
1159 .desc = VMWGFX_DRIVER_DESC, 1165 .desc = VMWGFX_DRIVER_DESC,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index d0f2c079ee27..29c984ff7f23 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -645,6 +645,16 @@ int vmw_kms_readback(struct vmw_private *dev_priv,
645int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, 645int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
646 struct drm_file *file_priv); 646 struct drm_file *file_priv);
647 647
648int vmw_dumb_create(struct drm_file *file_priv,
649 struct drm_device *dev,
650 struct drm_mode_create_dumb *args);
651
652int vmw_dumb_map_offset(struct drm_file *file_priv,
653 struct drm_device *dev, uint32_t handle,
654 uint64_t *offset);
655int vmw_dumb_destroy(struct drm_file *file_priv,
656 struct drm_device *dev,
657 uint32_t handle);
648/** 658/**
649 * Overlay control - vmwgfx_overlay.c 659 * Overlay control - vmwgfx_overlay.c
650 */ 660 */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 22bf9a21ec71..2c6ffe0e2c07 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -1917,3 +1917,76 @@ err_ref:
1917 vmw_resource_unreference(&res); 1917 vmw_resource_unreference(&res);
1918 return ret; 1918 return ret;
1919} 1919}
1920
1921
1922int vmw_dumb_create(struct drm_file *file_priv,
1923 struct drm_device *dev,
1924 struct drm_mode_create_dumb *args)
1925{
1926 struct vmw_private *dev_priv = vmw_priv(dev);
1927 struct vmw_master *vmaster = vmw_master(file_priv->master);
1928 struct vmw_user_dma_buffer *vmw_user_bo;
1929 struct ttm_buffer_object *tmp;
1930 int ret;
1931
1932 args->pitch = args->width * ((args->bpp + 7) / 8);
1933 args->size = args->pitch * args->height;
1934
1935 vmw_user_bo = kzalloc(sizeof(*vmw_user_bo), GFP_KERNEL);
1936 if (vmw_user_bo == NULL)
1937 return -ENOMEM;
1938
1939 ret = ttm_read_lock(&vmaster->lock, true);
1940 if (ret != 0) {
1941 kfree(vmw_user_bo);
1942 return ret;
1943 }
1944
1945 ret = vmw_dmabuf_init(dev_priv, &vmw_user_bo->dma, args->size,
1946 &vmw_vram_sys_placement, true,
1947 &vmw_user_dmabuf_destroy);
1948 if (ret != 0)
1949 goto out_no_dmabuf;
1950
1951 tmp = ttm_bo_reference(&vmw_user_bo->dma.base);
1952 ret = ttm_base_object_init(vmw_fpriv(file_priv)->tfile,
1953 &vmw_user_bo->base,
1954 false,
1955 ttm_buffer_type,
1956 &vmw_user_dmabuf_release, NULL);
1957 if (unlikely(ret != 0))
1958 goto out_no_base_object;
1959
1960 args->handle = vmw_user_bo->base.hash.key;
1961
1962out_no_base_object:
1963 ttm_bo_unref(&tmp);
1964out_no_dmabuf:
1965 ttm_read_unlock(&vmaster->lock);
1966 return ret;
1967}
1968
1969int vmw_dumb_map_offset(struct drm_file *file_priv,
1970 struct drm_device *dev, uint32_t handle,
1971 uint64_t *offset)
1972{
1973 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
1974 struct vmw_dma_buffer *out_buf;
1975 int ret;
1976
1977 ret = vmw_user_dmabuf_lookup(tfile, handle, &out_buf);
1978 if (ret != 0)
1979 return -EINVAL;
1980
1981 *offset = out_buf->base.addr_space_offset;
1982 vmw_dmabuf_unreference(&out_buf);
1983 return 0;
1984}
1985
1986int vmw_dumb_destroy(struct drm_file *file_priv,
1987 struct drm_device *dev,
1988 uint32_t handle)
1989{
1990 return ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile,
1991 handle, TTM_REF_USAGE);
1992}
diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
index 77d2df04c97b..60c4e1e85913 100644
--- a/drivers/hid/hid-lenovo-tpkbd.c
+++ b/drivers/hid/hid-lenovo-tpkbd.c
@@ -519,6 +519,8 @@ static void tpkbd_remove_tp(struct hid_device *hdev)
519 led_classdev_unregister(&data_pointer->led_mute); 519 led_classdev_unregister(&data_pointer->led_mute);
520 520
521 hid_set_drvdata(hdev, NULL); 521 hid_set_drvdata(hdev, NULL);
522 kfree(data_pointer->led_micmute.name);
523 kfree(data_pointer->led_mute.name);
522 kfree(data_pointer); 524 kfree(data_pointer);
523} 525}
524 526
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 4d524b5f52f5..9500f2f3f8fe 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -193,6 +193,7 @@ static struct hid_ll_driver logi_dj_ll_driver;
193static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf, 193static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf,
194 size_t count, 194 size_t count,
195 unsigned char report_type); 195 unsigned char report_type);
196static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev);
196 197
197static void logi_dj_recv_destroy_djhid_device(struct dj_receiver_dev *djrcv_dev, 198static void logi_dj_recv_destroy_djhid_device(struct dj_receiver_dev *djrcv_dev,
198 struct dj_report *dj_report) 199 struct dj_report *dj_report)
@@ -233,6 +234,7 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
233 if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] & 234 if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] &
234 SPFUNCTION_DEVICE_LIST_EMPTY) { 235 SPFUNCTION_DEVICE_LIST_EMPTY) {
235 dbg_hid("%s: device list is empty\n", __func__); 236 dbg_hid("%s: device list is empty\n", __func__);
237 djrcv_dev->querying_devices = false;
236 return; 238 return;
237 } 239 }
238 240
@@ -243,6 +245,12 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
243 return; 245 return;
244 } 246 }
245 247
248 if (djrcv_dev->paired_dj_devices[dj_report->device_index]) {
249 /* The device is already known. No need to reallocate it. */
250 dbg_hid("%s: device is already known\n", __func__);
251 return;
252 }
253
246 dj_hiddev = hid_allocate_device(); 254 dj_hiddev = hid_allocate_device();
247 if (IS_ERR(dj_hiddev)) { 255 if (IS_ERR(dj_hiddev)) {
248 dev_err(&djrcv_hdev->dev, "%s: hid_allocate_device failed\n", 256 dev_err(&djrcv_hdev->dev, "%s: hid_allocate_device failed\n",
@@ -306,6 +314,7 @@ static void delayedwork_callback(struct work_struct *work)
306 struct dj_report dj_report; 314 struct dj_report dj_report;
307 unsigned long flags; 315 unsigned long flags;
308 int count; 316 int count;
317 int retval;
309 318
310 dbg_hid("%s\n", __func__); 319 dbg_hid("%s\n", __func__);
311 320
@@ -338,6 +347,25 @@ static void delayedwork_callback(struct work_struct *work)
338 logi_dj_recv_destroy_djhid_device(djrcv_dev, &dj_report); 347 logi_dj_recv_destroy_djhid_device(djrcv_dev, &dj_report);
339 break; 348 break;
340 default: 349 default:
350 /* A normal report (i. e. not belonging to a pair/unpair notification)
351 * arriving here, means that the report arrived but we did not have a
352 * paired dj_device associated to the report's device_index, this
353 * means that the original "device paired" notification corresponding
354 * to this dj_device never arrived to this driver. The reason is that
355 * hid-core discards all packets coming from a device while probe() is
356 * executing. */
357 if (!djrcv_dev->paired_dj_devices[dj_report.device_index]) {
358 /* ok, we don't know the device, just re-ask the
359 * receiver for the list of connected devices. */
360 retval = logi_dj_recv_query_paired_devices(djrcv_dev);
361 if (!retval) {
362 /* everything went fine, so just leave */
363 break;
364 }
365 dev_err(&djrcv_dev->hdev->dev,
366 "%s:logi_dj_recv_query_paired_devices "
367 "error:%d\n", __func__, retval);
368 }
341 dbg_hid("%s: unexpected report type\n", __func__); 369 dbg_hid("%s: unexpected report type\n", __func__);
342 } 370 }
343} 371}
@@ -368,6 +396,12 @@ static void logi_dj_recv_forward_null_report(struct dj_receiver_dev *djrcv_dev,
368 if (!djdev) { 396 if (!djdev) {
369 dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]" 397 dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]"
370 " is NULL, index %d\n", dj_report->device_index); 398 " is NULL, index %d\n", dj_report->device_index);
399 kfifo_in(&djrcv_dev->notif_fifo, dj_report, sizeof(struct dj_report));
400
401 if (schedule_work(&djrcv_dev->work) == 0) {
402 dbg_hid("%s: did not schedule the work item, was already "
403 "queued\n", __func__);
404 }
371 return; 405 return;
372 } 406 }
373 407
@@ -398,6 +432,12 @@ static void logi_dj_recv_forward_report(struct dj_receiver_dev *djrcv_dev,
398 if (dj_device == NULL) { 432 if (dj_device == NULL) {
399 dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]" 433 dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]"
400 " is NULL, index %d\n", dj_report->device_index); 434 " is NULL, index %d\n", dj_report->device_index);
435 kfifo_in(&djrcv_dev->notif_fifo, dj_report, sizeof(struct dj_report));
436
437 if (schedule_work(&djrcv_dev->work) == 0) {
438 dbg_hid("%s: did not schedule the work item, was already "
439 "queued\n", __func__);
440 }
401 return; 441 return;
402 } 442 }
403 443
@@ -439,6 +479,10 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
439 struct dj_report *dj_report; 479 struct dj_report *dj_report;
440 int retval; 480 int retval;
441 481
482 /* no need to protect djrcv_dev->querying_devices */
483 if (djrcv_dev->querying_devices)
484 return 0;
485
442 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL); 486 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL);
443 if (!dj_report) 487 if (!dj_report)
444 return -ENOMEM; 488 return -ENOMEM;
@@ -450,6 +494,7 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
450 return retval; 494 return retval;
451} 495}
452 496
497
453static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, 498static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
454 unsigned timeout) 499 unsigned timeout)
455{ 500{
diff --git a/drivers/hid/hid-logitech-dj.h b/drivers/hid/hid-logitech-dj.h
index fd28a5e0ca3b..4a4000340ce1 100644
--- a/drivers/hid/hid-logitech-dj.h
+++ b/drivers/hid/hid-logitech-dj.h
@@ -101,6 +101,7 @@ struct dj_receiver_dev {
101 struct work_struct work; 101 struct work_struct work;
102 struct kfifo notif_fifo; 102 struct kfifo notif_fifo;
103 spinlock_t lock; 103 spinlock_t lock;
104 bool querying_devices;
104}; 105};
105 106
106struct dj_device { 107struct dj_device {
diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c
index cfec802cf9ca..f915eb1c29f7 100644
--- a/drivers/hwmon/ad7314.c
+++ b/drivers/hwmon/ad7314.c
@@ -87,10 +87,18 @@ static ssize_t ad7314_show_temperature(struct device *dev,
87 } 87 }
88} 88}
89 89
90static ssize_t ad7314_show_name(struct device *dev,
91 struct device_attribute *devattr, char *buf)
92{
93 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
94}
95
96static DEVICE_ATTR(name, S_IRUGO, ad7314_show_name, NULL);
90static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, 97static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
91 ad7314_show_temperature, NULL, 0); 98 ad7314_show_temperature, NULL, 0);
92 99
93static struct attribute *ad7314_attributes[] = { 100static struct attribute *ad7314_attributes[] = {
101 &dev_attr_name.attr,
94 &sensor_dev_attr_temp1_input.dev_attr.attr, 102 &sensor_dev_attr_temp1_input.dev_attr.attr,
95 NULL, 103 NULL,
96}; 104};
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index e65c6e45d36b..7bf4ce3d405e 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -139,6 +139,12 @@ static ssize_t show_voltage(struct device *dev,
139 } 139 }
140} 140}
141 141
142static ssize_t ads7871_show_name(struct device *dev,
143 struct device_attribute *devattr, char *buf)
144{
145 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
146}
147
142static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_voltage, NULL, 0); 148static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_voltage, NULL, 0);
143static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 1); 149static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 1);
144static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 2); 150static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 2);
@@ -148,6 +154,8 @@ static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_voltage, NULL, 5);
148static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 6); 154static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 6);
149static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 7); 155static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 7);
150 156
157static DEVICE_ATTR(name, S_IRUGO, ads7871_show_name, NULL);
158
151static struct attribute *ads7871_attributes[] = { 159static struct attribute *ads7871_attributes[] = {
152 &sensor_dev_attr_in0_input.dev_attr.attr, 160 &sensor_dev_attr_in0_input.dev_attr.attr,
153 &sensor_dev_attr_in1_input.dev_attr.attr, 161 &sensor_dev_attr_in1_input.dev_attr.attr,
@@ -157,6 +165,7 @@ static struct attribute *ads7871_attributes[] = {
157 &sensor_dev_attr_in5_input.dev_attr.attr, 165 &sensor_dev_attr_in5_input.dev_attr.attr,
158 &sensor_dev_attr_in6_input.dev_attr.attr, 166 &sensor_dev_attr_in6_input.dev_attr.attr,
159 &sensor_dev_attr_in7_input.dev_attr.attr, 167 &sensor_dev_attr_in7_input.dev_attr.attr,
168 &dev_attr_name.attr,
160 NULL 169 NULL
161}; 170};
162 171
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 282708860517..8f3f6f2c45fd 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -53,10 +53,10 @@
53 53
54#define APPLESMC_MAX_DATA_LENGTH 32 54#define APPLESMC_MAX_DATA_LENGTH 32
55 55
56/* wait up to 32 ms for a status change. */ 56/* wait up to 128 ms for a status change. */
57#define APPLESMC_MIN_WAIT 0x0010 57#define APPLESMC_MIN_WAIT 0x0010
58#define APPLESMC_RETRY_WAIT 0x0100 58#define APPLESMC_RETRY_WAIT 0x0100
59#define APPLESMC_MAX_WAIT 0x8000 59#define APPLESMC_MAX_WAIT 0x20000
60 60
61#define APPLESMC_READ_CMD 0x10 61#define APPLESMC_READ_CMD 0x10
62#define APPLESMC_WRITE_CMD 0x11 62#define APPLESMC_WRITE_CMD 0x11
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 0fa356fe82cc..984a3f13923b 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -815,17 +815,20 @@ static int __init coretemp_init(void)
815 if (err) 815 if (err)
816 goto exit; 816 goto exit;
817 817
818 get_online_cpus();
818 for_each_online_cpu(i) 819 for_each_online_cpu(i)
819 get_core_online(i); 820 get_core_online(i);
820 821
821#ifndef CONFIG_HOTPLUG_CPU 822#ifndef CONFIG_HOTPLUG_CPU
822 if (list_empty(&pdev_list)) { 823 if (list_empty(&pdev_list)) {
824 put_online_cpus();
823 err = -ENODEV; 825 err = -ENODEV;
824 goto exit_driver_unreg; 826 goto exit_driver_unreg;
825 } 827 }
826#endif 828#endif
827 829
828 register_hotcpu_notifier(&coretemp_cpu_notifier); 830 register_hotcpu_notifier(&coretemp_cpu_notifier);
831 put_online_cpus();
829 return 0; 832 return 0;
830 833
831#ifndef CONFIG_HOTPLUG_CPU 834#ifndef CONFIG_HOTPLUG_CPU
@@ -840,6 +843,7 @@ static void __exit coretemp_exit(void)
840{ 843{
841 struct pdev_entry *p, *n; 844 struct pdev_entry *p, *n;
842 845
846 get_online_cpus();
843 unregister_hotcpu_notifier(&coretemp_cpu_notifier); 847 unregister_hotcpu_notifier(&coretemp_cpu_notifier);
844 mutex_lock(&pdev_list_mutex); 848 mutex_lock(&pdev_list_mutex);
845 list_for_each_entry_safe(p, n, &pdev_list, list) { 849 list_for_each_entry_safe(p, n, &pdev_list, list) {
@@ -848,6 +852,7 @@ static void __exit coretemp_exit(void)
848 kfree(p); 852 kfree(p);
849 } 853 }
850 mutex_unlock(&pdev_list_mutex); 854 mutex_unlock(&pdev_list_mutex);
855 put_online_cpus();
851 platform_driver_unregister(&coretemp_driver); 856 platform_driver_unregister(&coretemp_driver);
852} 857}
853 858
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 2764b78a784b..af69073b3fe8 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -129,12 +129,12 @@ static bool __devinit fam15h_power_is_internal_node0(struct pci_dev *f4)
129 * counter saturations resulting in bogus power readings. 129 * counter saturations resulting in bogus power readings.
130 * We correct this value ourselves to cope with older BIOSes. 130 * We correct this value ourselves to cope with older BIOSes.
131 */ 131 */
132static DEFINE_PCI_DEVICE_TABLE(affected_device) = { 132static const struct pci_device_id affected_device[] = {
133 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, 133 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
134 { 0 } 134 { 0 }
135}; 135};
136 136
137static void __devinit tweak_runavg_range(struct pci_dev *pdev) 137static void tweak_runavg_range(struct pci_dev *pdev)
138{ 138{
139 u32 val; 139 u32 val;
140 140
@@ -158,6 +158,16 @@ static void __devinit tweak_runavg_range(struct pci_dev *pdev)
158 REG_TDP_RUNNING_AVERAGE, val); 158 REG_TDP_RUNNING_AVERAGE, val);
159} 159}
160 160
161#ifdef CONFIG_PM
162static int fam15h_power_resume(struct pci_dev *pdev)
163{
164 tweak_runavg_range(pdev);
165 return 0;
166}
167#else
168#define fam15h_power_resume NULL
169#endif
170
161static void __devinit fam15h_power_init_data(struct pci_dev *f4, 171static void __devinit fam15h_power_init_data(struct pci_dev *f4,
162 struct fam15h_power_data *data) 172 struct fam15h_power_data *data)
163{ 173{
@@ -256,6 +266,7 @@ static struct pci_driver fam15h_power_driver = {
256 .id_table = fam15h_power_id_table, 266 .id_table = fam15h_power_id_table,
257 .probe = fam15h_power_probe, 267 .probe = fam15h_power_probe,
258 .remove = __devexit_p(fam15h_power_remove), 268 .remove = __devexit_p(fam15h_power_remove),
269 .resume = fam15h_power_resume,
259}; 270};
260 271
261module_pci_driver(fam15h_power_driver); 272module_pci_driver(fam15h_power_driver);
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index 7f3f4a385729..602148299f68 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -69,22 +69,6 @@ struct ina2xx_data {
69 u16 regs[INA2XX_MAX_REGISTERS]; 69 u16 regs[INA2XX_MAX_REGISTERS];
70}; 70};
71 71
72int ina2xx_read_word(struct i2c_client *client, int reg)
73{
74 int val = i2c_smbus_read_word_data(client, reg);
75 if (unlikely(val < 0)) {
76 dev_dbg(&client->dev,
77 "Failed to read register: %d\n", reg);
78 return val;
79 }
80 return be16_to_cpu(val);
81}
82
83void ina2xx_write_word(struct i2c_client *client, int reg, int data)
84{
85 i2c_smbus_write_word_data(client, reg, cpu_to_be16(data));
86}
87
88static struct ina2xx_data *ina2xx_update_device(struct device *dev) 72static struct ina2xx_data *ina2xx_update_device(struct device *dev)
89{ 73{
90 struct i2c_client *client = to_i2c_client(dev); 74 struct i2c_client *client = to_i2c_client(dev);
@@ -102,7 +86,7 @@ static struct ina2xx_data *ina2xx_update_device(struct device *dev)
102 86
103 /* Read all registers */ 87 /* Read all registers */
104 for (i = 0; i < data->registers; i++) { 88 for (i = 0; i < data->registers; i++) {
105 int rv = ina2xx_read_word(client, i); 89 int rv = i2c_smbus_read_word_swapped(client, i);
106 if (rv < 0) { 90 if (rv < 0) {
107 ret = ERR_PTR(rv); 91 ret = ERR_PTR(rv);
108 goto abort; 92 goto abort;
@@ -279,22 +263,26 @@ static int ina2xx_probe(struct i2c_client *client,
279 switch (data->kind) { 263 switch (data->kind) {
280 case ina219: 264 case ina219:
281 /* device configuration */ 265 /* device configuration */
282 ina2xx_write_word(client, INA2XX_CONFIG, INA219_CONFIG_DEFAULT); 266 i2c_smbus_write_word_swapped(client, INA2XX_CONFIG,
267 INA219_CONFIG_DEFAULT);
283 268
284 /* set current LSB to 1mA, shunt is in uOhms */ 269 /* set current LSB to 1mA, shunt is in uOhms */
285 /* (equation 13 in datasheet) */ 270 /* (equation 13 in datasheet) */
286 ina2xx_write_word(client, INA2XX_CALIBRATION, 40960000 / shunt); 271 i2c_smbus_write_word_swapped(client, INA2XX_CALIBRATION,
272 40960000 / shunt);
287 dev_info(&client->dev, 273 dev_info(&client->dev,
288 "power monitor INA219 (Rshunt = %li uOhm)\n", shunt); 274 "power monitor INA219 (Rshunt = %li uOhm)\n", shunt);
289 data->registers = INA219_REGISTERS; 275 data->registers = INA219_REGISTERS;
290 break; 276 break;
291 case ina226: 277 case ina226:
292 /* device configuration */ 278 /* device configuration */
293 ina2xx_write_word(client, INA2XX_CONFIG, INA226_CONFIG_DEFAULT); 279 i2c_smbus_write_word_swapped(client, INA2XX_CONFIG,
280 INA226_CONFIG_DEFAULT);
294 281
295 /* set current LSB to 1mA, shunt is in uOhms */ 282 /* set current LSB to 1mA, shunt is in uOhms */
296 /* (equation 1 in datasheet)*/ 283 /* (equation 1 in datasheet)*/
297 ina2xx_write_word(client, INA2XX_CALIBRATION, 5120000 / shunt); 284 i2c_smbus_write_word_swapped(client, INA2XX_CALIBRATION,
285 5120000 / shunt);
298 dev_info(&client->dev, 286 dev_info(&client->dev,
299 "power monitor INA226 (Rshunt = %li uOhm)\n", shunt); 287 "power monitor INA226 (Rshunt = %li uOhm)\n", shunt);
300 data->registers = INA226_REGISTERS; 288 data->registers = INA226_REGISTERS;
diff --git a/drivers/hwmon/twl4030-madc-hwmon.c b/drivers/hwmon/twl4030-madc-hwmon.c
index 0018c7dd0097..1a174f0a3cde 100644
--- a/drivers/hwmon/twl4030-madc-hwmon.c
+++ b/drivers/hwmon/twl4030-madc-hwmon.c
@@ -44,12 +44,13 @@ static ssize_t madc_read(struct device *dev,
44 struct device_attribute *devattr, char *buf) 44 struct device_attribute *devattr, char *buf)
45{ 45{
46 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 46 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
47 struct twl4030_madc_request req; 47 struct twl4030_madc_request req = {
48 .channels = 1 << attr->index,
49 .method = TWL4030_MADC_SW2,
50 .type = TWL4030_MADC_WAIT,
51 };
48 long val; 52 long val;
49 53
50 req.channels = (1 << attr->index);
51 req.method = TWL4030_MADC_SW2;
52 req.func_cb = NULL;
53 val = twl4030_madc_conversion(&req); 54 val = twl4030_madc_conversion(&req);
54 if (val < 0) 55 if (val < 0)
55 return val; 56 return val;
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index ee4ebc198a94..2e56c6ce9fb6 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -328,6 +328,7 @@ static int __init via_cputemp_init(void)
328 if (err) 328 if (err)
329 goto exit; 329 goto exit;
330 330
331 get_online_cpus();
331 for_each_online_cpu(i) { 332 for_each_online_cpu(i) {
332 struct cpuinfo_x86 *c = &cpu_data(i); 333 struct cpuinfo_x86 *c = &cpu_data(i);
333 334
@@ -347,12 +348,14 @@ static int __init via_cputemp_init(void)
347 348
348#ifndef CONFIG_HOTPLUG_CPU 349#ifndef CONFIG_HOTPLUG_CPU
349 if (list_empty(&pdev_list)) { 350 if (list_empty(&pdev_list)) {
351 put_online_cpus();
350 err = -ENODEV; 352 err = -ENODEV;
351 goto exit_driver_unreg; 353 goto exit_driver_unreg;
352 } 354 }
353#endif 355#endif
354 356
355 register_hotcpu_notifier(&via_cputemp_cpu_notifier); 357 register_hotcpu_notifier(&via_cputemp_cpu_notifier);
358 put_online_cpus();
356 return 0; 359 return 0;
357 360
358#ifndef CONFIG_HOTPLUG_CPU 361#ifndef CONFIG_HOTPLUG_CPU
@@ -367,6 +370,7 @@ static void __exit via_cputemp_exit(void)
367{ 370{
368 struct pdev_entry *p, *n; 371 struct pdev_entry *p, *n;
369 372
373 get_online_cpus();
370 unregister_hotcpu_notifier(&via_cputemp_cpu_notifier); 374 unregister_hotcpu_notifier(&via_cputemp_cpu_notifier);
371 mutex_lock(&pdev_list_mutex); 375 mutex_lock(&pdev_list_mutex);
372 list_for_each_entry_safe(p, n, &pdev_list, list) { 376 list_for_each_entry_safe(p, n, &pdev_list, list) {
@@ -375,6 +379,7 @@ static void __exit via_cputemp_exit(void)
375 kfree(p); 379 kfree(p);
376 } 380 }
377 mutex_unlock(&pdev_list_mutex); 381 mutex_unlock(&pdev_list_mutex);
382 put_online_cpus();
378 platform_driver_unregister(&via_cputemp_driver); 383 platform_driver_unregister(&via_cputemp_driver);
379} 384}
380 385
diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
index 1201a15784c3..db713c0dfba4 100644
--- a/drivers/hwspinlock/hwspinlock_core.c
+++ b/drivers/hwspinlock/hwspinlock_core.c
@@ -552,7 +552,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_request_specific);
552 */ 552 */
553int hwspin_lock_free(struct hwspinlock *hwlock) 553int hwspin_lock_free(struct hwspinlock *hwlock)
554{ 554{
555 struct device *dev = hwlock->bank->dev; 555 struct device *dev;
556 struct hwspinlock *tmp; 556 struct hwspinlock *tmp;
557 int ret; 557 int ret;
558 558
@@ -561,6 +561,7 @@ int hwspin_lock_free(struct hwspinlock *hwlock)
561 return -EINVAL; 561 return -EINVAL;
562 } 562 }
563 563
564 dev = hwlock->bank->dev;
564 mutex_lock(&hwspinlock_tree_lock); 565 mutex_lock(&hwspinlock_tree_lock);
565 566
566 /* make sure the hwspinlock is used */ 567 /* make sure the hwspinlock is used */
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index 73133b1063f0..6f5f98d69af7 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -476,17 +476,17 @@ static int pca_init(struct i2c_adapter *adap)
476 /* To avoid integer overflow, use clock/100 for calculations */ 476 /* To avoid integer overflow, use clock/100 for calculations */
477 clock = pca_clock(pca_data) / 100; 477 clock = pca_clock(pca_data) / 100;
478 478
479 if (pca_data->i2c_clock > 10000) { 479 if (pca_data->i2c_clock > 1000000) {
480 mode = I2C_PCA_MODE_TURBO; 480 mode = I2C_PCA_MODE_TURBO;
481 min_tlow = 14; 481 min_tlow = 14;
482 min_thi = 5; 482 min_thi = 5;
483 raise_fall_time = 22; /* Raise 11e-8s, Fall 11e-8s */ 483 raise_fall_time = 22; /* Raise 11e-8s, Fall 11e-8s */
484 } else if (pca_data->i2c_clock > 4000) { 484 } else if (pca_data->i2c_clock > 400000) {
485 mode = I2C_PCA_MODE_FASTP; 485 mode = I2C_PCA_MODE_FASTP;
486 min_tlow = 17; 486 min_tlow = 17;
487 min_thi = 9; 487 min_thi = 9;
488 raise_fall_time = 22; /* Raise 11e-8s, Fall 11e-8s */ 488 raise_fall_time = 22; /* Raise 11e-8s, Fall 11e-8s */
489 } else if (pca_data->i2c_clock > 1000) { 489 } else if (pca_data->i2c_clock > 100000) {
490 mode = I2C_PCA_MODE_FAST; 490 mode = I2C_PCA_MODE_FAST;
491 min_tlow = 44; 491 min_tlow = 44;
492 min_thi = 20; 492 min_thi = 20;
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index b4aaa1bd6728..970a1612e795 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -104,6 +104,7 @@ config I2C_I801
104 DH89xxCC (PCH) 104 DH89xxCC (PCH)
105 Panther Point (PCH) 105 Panther Point (PCH)
106 Lynx Point (PCH) 106 Lynx Point (PCH)
107 Lynx Point-LP (PCH)
107 108
108 This driver can also be built as a module. If so, the module 109 This driver can also be built as a module. If so, the module
109 will be called i2c-i801. 110 will be called i2c-i801.
@@ -354,9 +355,13 @@ config I2C_DAVINCI
354 devices such as DaVinci NIC. 355 devices such as DaVinci NIC.
355 For details please see http://www.ti.com/davinci 356 For details please see http://www.ti.com/davinci
356 357
358config I2C_DESIGNWARE_CORE
359 tristate
360
357config I2C_DESIGNWARE_PLATFORM 361config I2C_DESIGNWARE_PLATFORM
358 tristate "Synopsys DesignWare Platform" 362 tristate "Synopsys DesignWare Platform"
359 depends on HAVE_CLK 363 depends on HAVE_CLK
364 select I2C_DESIGNWARE_CORE
360 help 365 help
361 If you say yes to this option, support will be included for the 366 If you say yes to this option, support will be included for the
362 Synopsys DesignWare I2C adapter. Only master mode is supported. 367 Synopsys DesignWare I2C adapter. Only master mode is supported.
@@ -367,6 +372,7 @@ config I2C_DESIGNWARE_PLATFORM
367config I2C_DESIGNWARE_PCI 372config I2C_DESIGNWARE_PCI
368 tristate "Synopsys DesignWare PCI" 373 tristate "Synopsys DesignWare PCI"
369 depends on PCI 374 depends on PCI
375 select I2C_DESIGNWARE_CORE
370 help 376 help
371 If you say yes to this option, support will be included for the 377 If you say yes to this option, support will be included for the
372 Synopsys DesignWare I2C adapter. Only master mode is supported. 378 Synopsys DesignWare I2C adapter. Only master mode is supported.
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index ce3c2be7fb40..37c4182cc98b 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -33,10 +33,11 @@ obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
33obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o 33obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
34obj-$(CONFIG_I2C_CPM) += i2c-cpm.o 34obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
35obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o 35obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
36obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o
36obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o 37obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o
37i2c-designware-platform-objs := i2c-designware-platdrv.o i2c-designware-core.o 38i2c-designware-platform-objs := i2c-designware-platdrv.o
38obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o 39obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o
39i2c-designware-pci-objs := i2c-designware-pcidrv.o i2c-designware-core.o 40i2c-designware-pci-objs := i2c-designware-pcidrv.o
40obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o 41obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
41obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o 42obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
42obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o 43obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 1e48bec80edf..7b8ebbefb581 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -25,6 +25,7 @@
25 * ---------------------------------------------------------------------------- 25 * ----------------------------------------------------------------------------
26 * 26 *
27 */ 27 */
28#include <linux/export.h>
28#include <linux/clk.h> 29#include <linux/clk.h>
29#include <linux/errno.h> 30#include <linux/errno.h>
30#include <linux/err.h> 31#include <linux/err.h>
@@ -316,6 +317,7 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
316 dw_writel(dev, dev->master_cfg , DW_IC_CON); 317 dw_writel(dev, dev->master_cfg , DW_IC_CON);
317 return 0; 318 return 0;
318} 319}
320EXPORT_SYMBOL_GPL(i2c_dw_init);
319 321
320/* 322/*
321 * Waiting for bus not busy 323 * Waiting for bus not busy
@@ -568,12 +570,14 @@ done:
568 570
569 return ret; 571 return ret;
570} 572}
573EXPORT_SYMBOL_GPL(i2c_dw_xfer);
571 574
572u32 i2c_dw_func(struct i2c_adapter *adap) 575u32 i2c_dw_func(struct i2c_adapter *adap)
573{ 576{
574 struct dw_i2c_dev *dev = i2c_get_adapdata(adap); 577 struct dw_i2c_dev *dev = i2c_get_adapdata(adap);
575 return dev->functionality; 578 return dev->functionality;
576} 579}
580EXPORT_SYMBOL_GPL(i2c_dw_func);
577 581
578static u32 i2c_dw_read_clear_intrbits(struct dw_i2c_dev *dev) 582static u32 i2c_dw_read_clear_intrbits(struct dw_i2c_dev *dev)
579{ 583{
@@ -678,17 +682,20 @@ tx_aborted:
678 682
679 return IRQ_HANDLED; 683 return IRQ_HANDLED;
680} 684}
685EXPORT_SYMBOL_GPL(i2c_dw_isr);
681 686
682void i2c_dw_enable(struct dw_i2c_dev *dev) 687void i2c_dw_enable(struct dw_i2c_dev *dev)
683{ 688{
684 /* Enable the adapter */ 689 /* Enable the adapter */
685 dw_writel(dev, 1, DW_IC_ENABLE); 690 dw_writel(dev, 1, DW_IC_ENABLE);
686} 691}
692EXPORT_SYMBOL_GPL(i2c_dw_enable);
687 693
688u32 i2c_dw_is_enabled(struct dw_i2c_dev *dev) 694u32 i2c_dw_is_enabled(struct dw_i2c_dev *dev)
689{ 695{
690 return dw_readl(dev, DW_IC_ENABLE); 696 return dw_readl(dev, DW_IC_ENABLE);
691} 697}
698EXPORT_SYMBOL_GPL(i2c_dw_is_enabled);
692 699
693void i2c_dw_disable(struct dw_i2c_dev *dev) 700void i2c_dw_disable(struct dw_i2c_dev *dev)
694{ 701{
@@ -699,18 +706,22 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)
699 dw_writel(dev, 0, DW_IC_INTR_MASK); 706 dw_writel(dev, 0, DW_IC_INTR_MASK);
700 dw_readl(dev, DW_IC_CLR_INTR); 707 dw_readl(dev, DW_IC_CLR_INTR);
701} 708}
709EXPORT_SYMBOL_GPL(i2c_dw_disable);
702 710
703void i2c_dw_clear_int(struct dw_i2c_dev *dev) 711void i2c_dw_clear_int(struct dw_i2c_dev *dev)
704{ 712{
705 dw_readl(dev, DW_IC_CLR_INTR); 713 dw_readl(dev, DW_IC_CLR_INTR);
706} 714}
715EXPORT_SYMBOL_GPL(i2c_dw_clear_int);
707 716
708void i2c_dw_disable_int(struct dw_i2c_dev *dev) 717void i2c_dw_disable_int(struct dw_i2c_dev *dev)
709{ 718{
710 dw_writel(dev, 0, DW_IC_INTR_MASK); 719 dw_writel(dev, 0, DW_IC_INTR_MASK);
711} 720}
721EXPORT_SYMBOL_GPL(i2c_dw_disable_int);
712 722
713u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev) 723u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev)
714{ 724{
715 return dw_readl(dev, DW_IC_COMP_PARAM_1); 725 return dw_readl(dev, DW_IC_COMP_PARAM_1);
716} 726}
727EXPORT_SYMBOL_GPL(i2c_dw_read_comp_param);
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 898dcf9c7ade..33e9b0c09af2 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -52,6 +52,7 @@
52 DH89xxCC (PCH) 0x2330 32 hard yes yes yes 52 DH89xxCC (PCH) 0x2330 32 hard yes yes yes
53 Panther Point (PCH) 0x1e22 32 hard yes yes yes 53 Panther Point (PCH) 0x1e22 32 hard yes yes yes
54 Lynx Point (PCH) 0x8c22 32 hard yes yes yes 54 Lynx Point (PCH) 0x8c22 32 hard yes yes yes
55 Lynx Point-LP (PCH) 0x9c22 32 hard yes yes yes
55 56
56 Features supported by this driver: 57 Features supported by this driver:
57 Software PEC no 58 Software PEC no
@@ -155,6 +156,7 @@
155#define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330 156#define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330
156#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 157#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30
157#define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22 158#define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22
159#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS 0x9c22
158 160
159struct i801_priv { 161struct i801_priv {
160 struct i2c_adapter adapter; 162 struct i2c_adapter adapter;
@@ -771,6 +773,7 @@ static DEFINE_PCI_DEVICE_TABLE(i801_ids) = {
771 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) }, 773 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) },
772 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS) }, 774 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS) },
773 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS) }, 775 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS) },
776 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS) },
774 { 0, } 777 { 0, }
775}; 778};
776 779
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 088c5c1ed17d..51f05b8520ed 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -365,10 +365,6 @@ static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c)
365 struct device_node *node = dev->of_node; 365 struct device_node *node = dev->of_node;
366 int ret; 366 int ret;
367 367
368 if (!node)
369 return -EINVAL;
370
371 i2c->speed = &mxs_i2c_95kHz_config;
372 ret = of_property_read_u32(node, "clock-frequency", &speed); 368 ret = of_property_read_u32(node, "clock-frequency", &speed);
373 if (ret) 369 if (ret)
374 dev_warn(dev, "No I2C speed selected, using 100kHz\n"); 370 dev_warn(dev, "No I2C speed selected, using 100kHz\n");
@@ -419,10 +415,13 @@ static int __devinit mxs_i2c_probe(struct platform_device *pdev)
419 return err; 415 return err;
420 416
421 i2c->dev = dev; 417 i2c->dev = dev;
418 i2c->speed = &mxs_i2c_95kHz_config;
422 419
423 err = mxs_i2c_get_ofdata(i2c); 420 if (dev->of_node) {
424 if (err) 421 err = mxs_i2c_get_ofdata(i2c);
425 return err; 422 if (err)
423 return err;
424 }
426 425
427 platform_set_drvdata(pdev, i2c); 426 platform_set_drvdata(pdev, i2c);
428 427
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 5d54416770b0..8488bddfe465 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -48,8 +48,9 @@ enum {
48 mcntrl_afie = 0x00000002, 48 mcntrl_afie = 0x00000002,
49 mcntrl_naie = 0x00000004, 49 mcntrl_naie = 0x00000004,
50 mcntrl_drmie = 0x00000008, 50 mcntrl_drmie = 0x00000008,
51 mcntrl_daie = 0x00000020, 51 mcntrl_drsie = 0x00000010,
52 mcntrl_rffie = 0x00000040, 52 mcntrl_rffie = 0x00000020,
53 mcntrl_daie = 0x00000040,
53 mcntrl_tffie = 0x00000080, 54 mcntrl_tffie = 0x00000080,
54 mcntrl_reset = 0x00000100, 55 mcntrl_reset = 0x00000100,
55 mcntrl_cdbmode = 0x00000400, 56 mcntrl_cdbmode = 0x00000400,
@@ -290,31 +291,37 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
290 * or we didn't 'ask' for it yet. 291 * or we didn't 'ask' for it yet.
291 */ 292 */
292 if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) { 293 if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) {
293 dev_dbg(&alg_data->adapter.dev, 294 /* 'Asking' is done asynchronously, e.g. dummy TX of several
294 "%s(): Write dummy data to fill Rx-fifo...\n", 295 * bytes is done before the first actual RX arrives in FIFO.
295 __func__); 296 * Therefore, ordered bytes (via TX) are counted separately.
297 */
298 if (alg_data->mif.order) {
299 dev_dbg(&alg_data->adapter.dev,
300 "%s(): Write dummy data to fill Rx-fifo...\n",
301 __func__);
296 302
297 if (alg_data->mif.len == 1) { 303 if (alg_data->mif.order == 1) {
298 /* Last byte, do not acknowledge next rcv. */ 304 /* Last byte, do not acknowledge next rcv. */
299 val |= stop_bit; 305 val |= stop_bit;
306
307 /*
308 * Enable interrupt RFDAIE (data in Rx fifo),
309 * and disable DRMIE (need data for Tx)
310 */
311 ctl = ioread32(I2C_REG_CTL(alg_data));
312 ctl |= mcntrl_rffie | mcntrl_daie;
313 ctl &= ~mcntrl_drmie;
314 iowrite32(ctl, I2C_REG_CTL(alg_data));
315 }
300 316
301 /* 317 /*
302 * Enable interrupt RFDAIE (data in Rx fifo), 318 * Now we'll 'ask' for data:
303 * and disable DRMIE (need data for Tx) 319 * For each byte we want to receive, we must
320 * write a (dummy) byte to the Tx-FIFO.
304 */ 321 */
305 ctl = ioread32(I2C_REG_CTL(alg_data)); 322 iowrite32(val, I2C_REG_TX(alg_data));
306 ctl |= mcntrl_rffie | mcntrl_daie; 323 alg_data->mif.order--;
307 ctl &= ~mcntrl_drmie;
308 iowrite32(ctl, I2C_REG_CTL(alg_data));
309 } 324 }
310
311 /*
312 * Now we'll 'ask' for data:
313 * For each byte we want to receive, we must
314 * write a (dummy) byte to the Tx-FIFO.
315 */
316 iowrite32(val, I2C_REG_TX(alg_data));
317
318 return 0; 325 return 0;
319 } 326 }
320 327
@@ -514,6 +521,7 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
514 521
515 alg_data->mif.buf = pmsg->buf; 522 alg_data->mif.buf = pmsg->buf;
516 alg_data->mif.len = pmsg->len; 523 alg_data->mif.len = pmsg->len;
524 alg_data->mif.order = pmsg->len;
517 alg_data->mif.mode = (pmsg->flags & I2C_M_RD) ? 525 alg_data->mif.mode = (pmsg->flags & I2C_M_RD) ?
518 I2C_SMBUS_READ : I2C_SMBUS_WRITE; 526 I2C_SMBUS_READ : I2C_SMBUS_WRITE;
519 alg_data->mif.ret = 0; 527 alg_data->mif.ret = 0;
@@ -566,6 +574,7 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
566 /* Cleanup to be sure... */ 574 /* Cleanup to be sure... */
567 alg_data->mif.buf = NULL; 575 alg_data->mif.buf = NULL;
568 alg_data->mif.len = 0; 576 alg_data->mif.len = 0;
577 alg_data->mif.order = 0;
569 578
570 dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x\n", 579 dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x\n",
571 __func__, ioread32(I2C_REG_STS(alg_data))); 580 __func__, ioread32(I2C_REG_STS(alg_data)));
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 2efa56c5ff2c..2091ae8f539a 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -637,6 +637,22 @@ static void i2c_adapter_dev_release(struct device *dev)
637} 637}
638 638
639/* 639/*
640 * This function is only needed for mutex_lock_nested, so it is never
641 * called unless locking correctness checking is enabled. Thus we
642 * make it inline to avoid a compiler warning. That's what gcc ends up
643 * doing anyway.
644 */
645static inline unsigned int i2c_adapter_depth(struct i2c_adapter *adapter)
646{
647 unsigned int depth = 0;
648
649 while ((adapter = i2c_parent_is_i2c_adapter(adapter)))
650 depth++;
651
652 return depth;
653}
654
655/*
640 * Let users instantiate I2C devices through sysfs. This can be used when 656 * Let users instantiate I2C devices through sysfs. This can be used when
641 * platform initialization code doesn't contain the proper data for 657 * platform initialization code doesn't contain the proper data for
642 * whatever reason. Also useful for drivers that do device detection and 658 * whatever reason. Also useful for drivers that do device detection and
@@ -726,7 +742,8 @@ i2c_sysfs_delete_device(struct device *dev, struct device_attribute *attr,
726 742
727 /* Make sure the device was added through sysfs */ 743 /* Make sure the device was added through sysfs */
728 res = -ENOENT; 744 res = -ENOENT;
729 mutex_lock(&adap->userspace_clients_lock); 745 mutex_lock_nested(&adap->userspace_clients_lock,
746 i2c_adapter_depth(adap));
730 list_for_each_entry_safe(client, next, &adap->userspace_clients, 747 list_for_each_entry_safe(client, next, &adap->userspace_clients,
731 detected) { 748 detected) {
732 if (client->addr == addr) { 749 if (client->addr == addr) {
@@ -1073,7 +1090,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
1073 return res; 1090 return res;
1074 1091
1075 /* Remove devices instantiated from sysfs */ 1092 /* Remove devices instantiated from sysfs */
1076 mutex_lock(&adap->userspace_clients_lock); 1093 mutex_lock_nested(&adap->userspace_clients_lock,
1094 i2c_adapter_depth(adap));
1077 list_for_each_entry_safe(client, next, &adap->userspace_clients, 1095 list_for_each_entry_safe(client, next, &adap->userspace_clients,
1078 detected) { 1096 detected) {
1079 dev_dbg(&adap->dev, "Removing %s at 0x%x\n", client->name, 1097 dev_dbg(&adap->dev, "Removing %s at 0x%x\n", client->name,
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index f61780a02374..3bd5540238a7 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -617,7 +617,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
617 st->adc_clk = clk_get(&pdev->dev, "adc_op_clk"); 617 st->adc_clk = clk_get(&pdev->dev, "adc_op_clk");
618 if (IS_ERR(st->adc_clk)) { 618 if (IS_ERR(st->adc_clk)) {
619 dev_err(&pdev->dev, "Failed to get the ADC clock.\n"); 619 dev_err(&pdev->dev, "Failed to get the ADC clock.\n");
620 ret = PTR_ERR(st->clk); 620 ret = PTR_ERR(st->adc_clk);
621 goto error_disable_clk; 621 goto error_disable_clk;
622 } 622 }
623 623
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 51f42061dae9..6cfd4d8fd0bd 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1361,11 +1361,11 @@ static int abort_rpl(struct c4iw_dev *dev, struct sk_buff *skb)
1361 struct tid_info *t = dev->rdev.lldi.tids; 1361 struct tid_info *t = dev->rdev.lldi.tids;
1362 1362
1363 ep = lookup_tid(t, tid); 1363 ep = lookup_tid(t, tid);
1364 PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
1365 if (!ep) { 1364 if (!ep) {
1366 printk(KERN_WARNING MOD "Abort rpl to freed endpoint\n"); 1365 printk(KERN_WARNING MOD "Abort rpl to freed endpoint\n");
1367 return 0; 1366 return 0;
1368 } 1367 }
1368 PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
1369 mutex_lock(&ep->com.mutex); 1369 mutex_lock(&ep->com.mutex);
1370 switch (ep->com.state) { 1370 switch (ep->com.state) {
1371 case ABORTING: 1371 case ABORTING:
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index cb5b7f7d4d38..b29a4246ef41 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -2219,7 +2219,6 @@ static bool ocrdma_poll_success_scqe(struct ocrdma_qp *qp,
2219 u32 wqe_idx; 2219 u32 wqe_idx;
2220 2220
2221 if (!qp->wqe_wr_id_tbl[tail].signaled) { 2221 if (!qp->wqe_wr_id_tbl[tail].signaled) {
2222 expand = true; /* CQE cannot be consumed yet */
2223 *polled = false; /* WC cannot be consumed yet */ 2222 *polled = false; /* WC cannot be consumed yet */
2224 } else { 2223 } else {
2225 ibwc->status = IB_WC_SUCCESS; 2224 ibwc->status = IB_WC_SUCCESS;
@@ -2227,10 +2226,11 @@ static bool ocrdma_poll_success_scqe(struct ocrdma_qp *qp,
2227 ibwc->qp = &qp->ibqp; 2226 ibwc->qp = &qp->ibqp;
2228 ocrdma_update_wc(qp, ibwc, tail); 2227 ocrdma_update_wc(qp, ibwc, tail);
2229 *polled = true; 2228 *polled = true;
2230 wqe_idx = le32_to_cpu(cqe->wq.wqeidx) & OCRDMA_CQE_WQEIDX_MASK;
2231 if (tail != wqe_idx)
2232 expand = true; /* Coalesced CQE can't be consumed yet */
2233 } 2229 }
2230 wqe_idx = le32_to_cpu(cqe->wq.wqeidx) & OCRDMA_CQE_WQEIDX_MASK;
2231 if (tail != wqe_idx)
2232 expand = true; /* Coalesced CQE can't be consumed yet */
2233
2234 ocrdma_hwq_inc_tail(&qp->sq); 2234 ocrdma_hwq_inc_tail(&qp->sq);
2235 return expand; 2235 return expand;
2236} 2236}
diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index 19f1e6c45fb6..ccb119143d20 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -471,9 +471,10 @@ static int subn_get_portinfo(struct ib_smp *smp, struct ib_device *ibdev,
471 if (port_num != port) { 471 if (port_num != port) {
472 ibp = to_iport(ibdev, port_num); 472 ibp = to_iport(ibdev, port_num);
473 ret = check_mkey(ibp, smp, 0); 473 ret = check_mkey(ibp, smp, 0);
474 if (ret) 474 if (ret) {
475 ret = IB_MAD_RESULT_FAILURE; 475 ret = IB_MAD_RESULT_FAILURE;
476 goto bail; 476 goto bail;
477 }
477 } 478 }
478 } 479 }
479 480
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index ca43901ed861..0af216d21f87 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -262,7 +262,10 @@ struct ipoib_ethtool_st {
262 u16 max_coalesced_frames; 262 u16 max_coalesced_frames;
263}; 263};
264 264
265struct ipoib_neigh_table;
266
265struct ipoib_neigh_hash { 267struct ipoib_neigh_hash {
268 struct ipoib_neigh_table *ntbl;
266 struct ipoib_neigh __rcu **buckets; 269 struct ipoib_neigh __rcu **buckets;
267 struct rcu_head rcu; 270 struct rcu_head rcu;
268 u32 mask; 271 u32 mask;
@@ -271,9 +274,9 @@ struct ipoib_neigh_hash {
271 274
272struct ipoib_neigh_table { 275struct ipoib_neigh_table {
273 struct ipoib_neigh_hash __rcu *htbl; 276 struct ipoib_neigh_hash __rcu *htbl;
274 rwlock_t rwlock;
275 atomic_t entries; 277 atomic_t entries;
276 struct completion flushed; 278 struct completion flushed;
279 struct completion deleted;
277}; 280};
278 281
279/* 282/*
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 3e2085a3ee47..1e19b5ae7c47 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -546,15 +546,15 @@ static void neigh_add_path(struct sk_buff *skb, u8 *daddr,
546 struct ipoib_neigh *neigh; 546 struct ipoib_neigh *neigh;
547 unsigned long flags; 547 unsigned long flags;
548 548
549 spin_lock_irqsave(&priv->lock, flags);
549 neigh = ipoib_neigh_alloc(daddr, dev); 550 neigh = ipoib_neigh_alloc(daddr, dev);
550 if (!neigh) { 551 if (!neigh) {
552 spin_unlock_irqrestore(&priv->lock, flags);
551 ++dev->stats.tx_dropped; 553 ++dev->stats.tx_dropped;
552 dev_kfree_skb_any(skb); 554 dev_kfree_skb_any(skb);
553 return; 555 return;
554 } 556 }
555 557
556 spin_lock_irqsave(&priv->lock, flags);
557
558 path = __path_find(dev, daddr + 4); 558 path = __path_find(dev, daddr + 4);
559 if (!path) { 559 if (!path) {
560 path = path_rec_create(dev, daddr + 4); 560 path = path_rec_create(dev, daddr + 4);
@@ -863,10 +863,10 @@ static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv)
863 if (test_bit(IPOIB_STOP_NEIGH_GC, &priv->flags)) 863 if (test_bit(IPOIB_STOP_NEIGH_GC, &priv->flags))
864 return; 864 return;
865 865
866 write_lock_bh(&ntbl->rwlock); 866 spin_lock_irqsave(&priv->lock, flags);
867 867
868 htbl = rcu_dereference_protected(ntbl->htbl, 868 htbl = rcu_dereference_protected(ntbl->htbl,
869 lockdep_is_held(&ntbl->rwlock)); 869 lockdep_is_held(&priv->lock));
870 870
871 if (!htbl) 871 if (!htbl)
872 goto out_unlock; 872 goto out_unlock;
@@ -883,16 +883,14 @@ static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv)
883 struct ipoib_neigh __rcu **np = &htbl->buckets[i]; 883 struct ipoib_neigh __rcu **np = &htbl->buckets[i];
884 884
885 while ((neigh = rcu_dereference_protected(*np, 885 while ((neigh = rcu_dereference_protected(*np,
886 lockdep_is_held(&ntbl->rwlock))) != NULL) { 886 lockdep_is_held(&priv->lock))) != NULL) {
887 /* was the neigh idle for two GC periods */ 887 /* was the neigh idle for two GC periods */
888 if (time_after(neigh_obsolete, neigh->alive)) { 888 if (time_after(neigh_obsolete, neigh->alive)) {
889 rcu_assign_pointer(*np, 889 rcu_assign_pointer(*np,
890 rcu_dereference_protected(neigh->hnext, 890 rcu_dereference_protected(neigh->hnext,
891 lockdep_is_held(&ntbl->rwlock))); 891 lockdep_is_held(&priv->lock)));
892 /* remove from path/mc list */ 892 /* remove from path/mc list */
893 spin_lock_irqsave(&priv->lock, flags);
894 list_del(&neigh->list); 893 list_del(&neigh->list);
895 spin_unlock_irqrestore(&priv->lock, flags);
896 call_rcu(&neigh->rcu, ipoib_neigh_reclaim); 894 call_rcu(&neigh->rcu, ipoib_neigh_reclaim);
897 } else { 895 } else {
898 np = &neigh->hnext; 896 np = &neigh->hnext;
@@ -902,7 +900,7 @@ static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv)
902 } 900 }
903 901
904out_unlock: 902out_unlock:
905 write_unlock_bh(&ntbl->rwlock); 903 spin_unlock_irqrestore(&priv->lock, flags);
906} 904}
907 905
908static void ipoib_reap_neigh(struct work_struct *work) 906static void ipoib_reap_neigh(struct work_struct *work)
@@ -947,10 +945,8 @@ struct ipoib_neigh *ipoib_neigh_alloc(u8 *daddr,
947 struct ipoib_neigh *neigh; 945 struct ipoib_neigh *neigh;
948 u32 hash_val; 946 u32 hash_val;
949 947
950 write_lock_bh(&ntbl->rwlock);
951
952 htbl = rcu_dereference_protected(ntbl->htbl, 948 htbl = rcu_dereference_protected(ntbl->htbl,
953 lockdep_is_held(&ntbl->rwlock)); 949 lockdep_is_held(&priv->lock));
954 if (!htbl) { 950 if (!htbl) {
955 neigh = NULL; 951 neigh = NULL;
956 goto out_unlock; 952 goto out_unlock;
@@ -961,10 +957,10 @@ struct ipoib_neigh *ipoib_neigh_alloc(u8 *daddr,
961 */ 957 */
962 hash_val = ipoib_addr_hash(htbl, daddr); 958 hash_val = ipoib_addr_hash(htbl, daddr);
963 for (neigh = rcu_dereference_protected(htbl->buckets[hash_val], 959 for (neigh = rcu_dereference_protected(htbl->buckets[hash_val],
964 lockdep_is_held(&ntbl->rwlock)); 960 lockdep_is_held(&priv->lock));
965 neigh != NULL; 961 neigh != NULL;
966 neigh = rcu_dereference_protected(neigh->hnext, 962 neigh = rcu_dereference_protected(neigh->hnext,
967 lockdep_is_held(&ntbl->rwlock))) { 963 lockdep_is_held(&priv->lock))) {
968 if (memcmp(daddr, neigh->daddr, INFINIBAND_ALEN) == 0) { 964 if (memcmp(daddr, neigh->daddr, INFINIBAND_ALEN) == 0) {
969 /* found, take one ref on behalf of the caller */ 965 /* found, take one ref on behalf of the caller */
970 if (!atomic_inc_not_zero(&neigh->refcnt)) { 966 if (!atomic_inc_not_zero(&neigh->refcnt)) {
@@ -987,12 +983,11 @@ struct ipoib_neigh *ipoib_neigh_alloc(u8 *daddr,
987 /* put in hash */ 983 /* put in hash */
988 rcu_assign_pointer(neigh->hnext, 984 rcu_assign_pointer(neigh->hnext,
989 rcu_dereference_protected(htbl->buckets[hash_val], 985 rcu_dereference_protected(htbl->buckets[hash_val],
990 lockdep_is_held(&ntbl->rwlock))); 986 lockdep_is_held(&priv->lock)));
991 rcu_assign_pointer(htbl->buckets[hash_val], neigh); 987 rcu_assign_pointer(htbl->buckets[hash_val], neigh);
992 atomic_inc(&ntbl->entries); 988 atomic_inc(&ntbl->entries);
993 989
994out_unlock: 990out_unlock:
995 write_unlock_bh(&ntbl->rwlock);
996 991
997 return neigh; 992 return neigh;
998} 993}
@@ -1040,35 +1035,29 @@ void ipoib_neigh_free(struct ipoib_neigh *neigh)
1040 struct ipoib_neigh *n; 1035 struct ipoib_neigh *n;
1041 u32 hash_val; 1036 u32 hash_val;
1042 1037
1043 write_lock_bh(&ntbl->rwlock);
1044
1045 htbl = rcu_dereference_protected(ntbl->htbl, 1038 htbl = rcu_dereference_protected(ntbl->htbl,
1046 lockdep_is_held(&ntbl->rwlock)); 1039 lockdep_is_held(&priv->lock));
1047 if (!htbl) 1040 if (!htbl)
1048 goto out_unlock; 1041 return;
1049 1042
1050 hash_val = ipoib_addr_hash(htbl, neigh->daddr); 1043 hash_val = ipoib_addr_hash(htbl, neigh->daddr);
1051 np = &htbl->buckets[hash_val]; 1044 np = &htbl->buckets[hash_val];
1052 for (n = rcu_dereference_protected(*np, 1045 for (n = rcu_dereference_protected(*np,
1053 lockdep_is_held(&ntbl->rwlock)); 1046 lockdep_is_held(&priv->lock));
1054 n != NULL; 1047 n != NULL;
1055 n = rcu_dereference_protected(*np, 1048 n = rcu_dereference_protected(*np,
1056 lockdep_is_held(&ntbl->rwlock))) { 1049 lockdep_is_held(&priv->lock))) {
1057 if (n == neigh) { 1050 if (n == neigh) {
1058 /* found */ 1051 /* found */
1059 rcu_assign_pointer(*np, 1052 rcu_assign_pointer(*np,
1060 rcu_dereference_protected(neigh->hnext, 1053 rcu_dereference_protected(neigh->hnext,
1061 lockdep_is_held(&ntbl->rwlock))); 1054 lockdep_is_held(&priv->lock)));
1062 call_rcu(&neigh->rcu, ipoib_neigh_reclaim); 1055 call_rcu(&neigh->rcu, ipoib_neigh_reclaim);
1063 goto out_unlock; 1056 return;
1064 } else { 1057 } else {
1065 np = &n->hnext; 1058 np = &n->hnext;
1066 } 1059 }
1067 } 1060 }
1068
1069out_unlock:
1070 write_unlock_bh(&ntbl->rwlock);
1071
1072} 1061}
1073 1062
1074static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv) 1063static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv)
@@ -1080,7 +1069,6 @@ static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv)
1080 1069
1081 clear_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags); 1070 clear_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags);
1082 ntbl->htbl = NULL; 1071 ntbl->htbl = NULL;
1083 rwlock_init(&ntbl->rwlock);
1084 htbl = kzalloc(sizeof(*htbl), GFP_KERNEL); 1072 htbl = kzalloc(sizeof(*htbl), GFP_KERNEL);
1085 if (!htbl) 1073 if (!htbl)
1086 return -ENOMEM; 1074 return -ENOMEM;
@@ -1095,6 +1083,7 @@ static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv)
1095 htbl->mask = (size - 1); 1083 htbl->mask = (size - 1);
1096 htbl->buckets = buckets; 1084 htbl->buckets = buckets;
1097 ntbl->htbl = htbl; 1085 ntbl->htbl = htbl;
1086 htbl->ntbl = ntbl;
1098 atomic_set(&ntbl->entries, 0); 1087 atomic_set(&ntbl->entries, 0);
1099 1088
1100 /* start garbage collection */ 1089 /* start garbage collection */
@@ -1111,9 +1100,11 @@ static void neigh_hash_free_rcu(struct rcu_head *head)
1111 struct ipoib_neigh_hash, 1100 struct ipoib_neigh_hash,
1112 rcu); 1101 rcu);
1113 struct ipoib_neigh __rcu **buckets = htbl->buckets; 1102 struct ipoib_neigh __rcu **buckets = htbl->buckets;
1103 struct ipoib_neigh_table *ntbl = htbl->ntbl;
1114 1104
1115 kfree(buckets); 1105 kfree(buckets);
1116 kfree(htbl); 1106 kfree(htbl);
1107 complete(&ntbl->deleted);
1117} 1108}
1118 1109
1119void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid) 1110void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid)
@@ -1125,10 +1116,10 @@ void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid)
1125 int i; 1116 int i;
1126 1117
1127 /* remove all neigh connected to a given path or mcast */ 1118 /* remove all neigh connected to a given path or mcast */
1128 write_lock_bh(&ntbl->rwlock); 1119 spin_lock_irqsave(&priv->lock, flags);
1129 1120
1130 htbl = rcu_dereference_protected(ntbl->htbl, 1121 htbl = rcu_dereference_protected(ntbl->htbl,
1131 lockdep_is_held(&ntbl->rwlock)); 1122 lockdep_is_held(&priv->lock));
1132 1123
1133 if (!htbl) 1124 if (!htbl)
1134 goto out_unlock; 1125 goto out_unlock;
@@ -1138,16 +1129,14 @@ void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid)
1138 struct ipoib_neigh __rcu **np = &htbl->buckets[i]; 1129 struct ipoib_neigh __rcu **np = &htbl->buckets[i];
1139 1130
1140 while ((neigh = rcu_dereference_protected(*np, 1131 while ((neigh = rcu_dereference_protected(*np,
1141 lockdep_is_held(&ntbl->rwlock))) != NULL) { 1132 lockdep_is_held(&priv->lock))) != NULL) {
1142 /* delete neighs belong to this parent */ 1133 /* delete neighs belong to this parent */
1143 if (!memcmp(gid, neigh->daddr + 4, sizeof (union ib_gid))) { 1134 if (!memcmp(gid, neigh->daddr + 4, sizeof (union ib_gid))) {
1144 rcu_assign_pointer(*np, 1135 rcu_assign_pointer(*np,
1145 rcu_dereference_protected(neigh->hnext, 1136 rcu_dereference_protected(neigh->hnext,
1146 lockdep_is_held(&ntbl->rwlock))); 1137 lockdep_is_held(&priv->lock)));
1147 /* remove from parent list */ 1138 /* remove from parent list */
1148 spin_lock_irqsave(&priv->lock, flags);
1149 list_del(&neigh->list); 1139 list_del(&neigh->list);
1150 spin_unlock_irqrestore(&priv->lock, flags);
1151 call_rcu(&neigh->rcu, ipoib_neigh_reclaim); 1140 call_rcu(&neigh->rcu, ipoib_neigh_reclaim);
1152 } else { 1141 } else {
1153 np = &neigh->hnext; 1142 np = &neigh->hnext;
@@ -1156,7 +1145,7 @@ void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid)
1156 } 1145 }
1157 } 1146 }
1158out_unlock: 1147out_unlock:
1159 write_unlock_bh(&ntbl->rwlock); 1148 spin_unlock_irqrestore(&priv->lock, flags);
1160} 1149}
1161 1150
1162static void ipoib_flush_neighs(struct ipoib_dev_priv *priv) 1151static void ipoib_flush_neighs(struct ipoib_dev_priv *priv)
@@ -1164,37 +1153,44 @@ static void ipoib_flush_neighs(struct ipoib_dev_priv *priv)
1164 struct ipoib_neigh_table *ntbl = &priv->ntbl; 1153 struct ipoib_neigh_table *ntbl = &priv->ntbl;
1165 struct ipoib_neigh_hash *htbl; 1154 struct ipoib_neigh_hash *htbl;
1166 unsigned long flags; 1155 unsigned long flags;
1167 int i; 1156 int i, wait_flushed = 0;
1168 1157
1169 write_lock_bh(&ntbl->rwlock); 1158 init_completion(&priv->ntbl.flushed);
1159
1160 spin_lock_irqsave(&priv->lock, flags);
1170 1161
1171 htbl = rcu_dereference_protected(ntbl->htbl, 1162 htbl = rcu_dereference_protected(ntbl->htbl,
1172 lockdep_is_held(&ntbl->rwlock)); 1163 lockdep_is_held(&priv->lock));
1173 if (!htbl) 1164 if (!htbl)
1174 goto out_unlock; 1165 goto out_unlock;
1175 1166
1167 wait_flushed = atomic_read(&priv->ntbl.entries);
1168 if (!wait_flushed)
1169 goto free_htbl;
1170
1176 for (i = 0; i < htbl->size; i++) { 1171 for (i = 0; i < htbl->size; i++) {
1177 struct ipoib_neigh *neigh; 1172 struct ipoib_neigh *neigh;
1178 struct ipoib_neigh __rcu **np = &htbl->buckets[i]; 1173 struct ipoib_neigh __rcu **np = &htbl->buckets[i];
1179 1174
1180 while ((neigh = rcu_dereference_protected(*np, 1175 while ((neigh = rcu_dereference_protected(*np,
1181 lockdep_is_held(&ntbl->rwlock))) != NULL) { 1176 lockdep_is_held(&priv->lock))) != NULL) {
1182 rcu_assign_pointer(*np, 1177 rcu_assign_pointer(*np,
1183 rcu_dereference_protected(neigh->hnext, 1178 rcu_dereference_protected(neigh->hnext,
1184 lockdep_is_held(&ntbl->rwlock))); 1179 lockdep_is_held(&priv->lock)));
1185 /* remove from path/mc list */ 1180 /* remove from path/mc list */
1186 spin_lock_irqsave(&priv->lock, flags);
1187 list_del(&neigh->list); 1181 list_del(&neigh->list);
1188 spin_unlock_irqrestore(&priv->lock, flags);
1189 call_rcu(&neigh->rcu, ipoib_neigh_reclaim); 1182 call_rcu(&neigh->rcu, ipoib_neigh_reclaim);
1190 } 1183 }
1191 } 1184 }
1192 1185
1186free_htbl:
1193 rcu_assign_pointer(ntbl->htbl, NULL); 1187 rcu_assign_pointer(ntbl->htbl, NULL);
1194 call_rcu(&htbl->rcu, neigh_hash_free_rcu); 1188 call_rcu(&htbl->rcu, neigh_hash_free_rcu);
1195 1189
1196out_unlock: 1190out_unlock:
1197 write_unlock_bh(&ntbl->rwlock); 1191 spin_unlock_irqrestore(&priv->lock, flags);
1192 if (wait_flushed)
1193 wait_for_completion(&priv->ntbl.flushed);
1198} 1194}
1199 1195
1200static void ipoib_neigh_hash_uninit(struct net_device *dev) 1196static void ipoib_neigh_hash_uninit(struct net_device *dev)
@@ -1203,7 +1199,7 @@ static void ipoib_neigh_hash_uninit(struct net_device *dev)
1203 int stopped; 1199 int stopped;
1204 1200
1205 ipoib_dbg(priv, "ipoib_neigh_hash_uninit\n"); 1201 ipoib_dbg(priv, "ipoib_neigh_hash_uninit\n");
1206 init_completion(&priv->ntbl.flushed); 1202 init_completion(&priv->ntbl.deleted);
1207 set_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags); 1203 set_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags);
1208 1204
1209 /* Stop GC if called at init fail need to cancel work */ 1205 /* Stop GC if called at init fail need to cancel work */
@@ -1211,10 +1207,9 @@ static void ipoib_neigh_hash_uninit(struct net_device *dev)
1211 if (!stopped) 1207 if (!stopped)
1212 cancel_delayed_work(&priv->neigh_reap_task); 1208 cancel_delayed_work(&priv->neigh_reap_task);
1213 1209
1214 if (atomic_read(&priv->ntbl.entries)) { 1210 ipoib_flush_neighs(priv);
1215 ipoib_flush_neighs(priv); 1211
1216 wait_for_completion(&priv->ntbl.flushed); 1212 wait_for_completion(&priv->ntbl.deleted);
1217 }
1218} 1213}
1219 1214
1220 1215
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 13f4aa7593c8..75367249f447 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -707,9 +707,7 @@ out:
707 neigh = ipoib_neigh_get(dev, daddr); 707 neigh = ipoib_neigh_get(dev, daddr);
708 spin_lock_irqsave(&priv->lock, flags); 708 spin_lock_irqsave(&priv->lock, flags);
709 if (!neigh) { 709 if (!neigh) {
710 spin_unlock_irqrestore(&priv->lock, flags);
711 neigh = ipoib_neigh_alloc(daddr, dev); 710 neigh = ipoib_neigh_alloc(daddr, dev);
712 spin_lock_irqsave(&priv->lock, flags);
713 if (neigh) { 711 if (neigh) {
714 kref_get(&mcast->ah->ref); 712 kref_get(&mcast->ah->ref);
715 neigh->ah = mcast->ah; 713 neigh->ah = mcast->ah;
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index ce68e361558c..cdc252612c0b 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -516,9 +516,9 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev)
516 input_set_drvdata(input_dev, keypad); 516 input_set_drvdata(input_dev, keypad);
517 517
518 /* Ensure that the keypad will stay dormant until opened */ 518 /* Ensure that the keypad will stay dormant until opened */
519 clk_enable(keypad->clk); 519 clk_prepare_enable(keypad->clk);
520 imx_keypad_inhibit(keypad); 520 imx_keypad_inhibit(keypad);
521 clk_disable(keypad->clk); 521 clk_disable_unprepare(keypad->clk);
522 522
523 error = request_irq(irq, imx_keypad_irq_handler, 0, 523 error = request_irq(irq, imx_keypad_irq_handler, 0,
524 pdev->name, keypad); 524 pdev->name, keypad);
diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c
index f06231b7cab1..84ec691c05aa 100644
--- a/drivers/input/misc/ab8500-ponkey.c
+++ b/drivers/input/misc/ab8500-ponkey.c
@@ -74,8 +74,8 @@ static int __devinit ab8500_ponkey_probe(struct platform_device *pdev)
74 74
75 ponkey->idev = input; 75 ponkey->idev = input;
76 ponkey->ab8500 = ab8500; 76 ponkey->ab8500 = ab8500;
77 ponkey->irq_dbf = ab8500_irq_get_virq(ab8500, irq_dbf); 77 ponkey->irq_dbf = irq_dbf;
78 ponkey->irq_dbr = ab8500_irq_get_virq(ab8500, irq_dbr); 78 ponkey->irq_dbr = irq_dbr;
79 79
80 input->name = "AB8500 POn(PowerOn) Key"; 80 input->name = "AB8500 POn(PowerOn) Key";
81 input->dev.parent = &pdev->dev; 81 input->dev.parent = &pdev->dev;
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index 3f5649f19082..a261d8576919 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -721,6 +721,17 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
721 721
722 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) { 722 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) {
723 case FSP_PKT_TYPE_ABS: 723 case FSP_PKT_TYPE_ABS:
724
725 if ((packet[0] == 0x48 || packet[0] == 0x49) &&
726 packet[1] == 0 && packet[2] == 0) {
727 /*
728 * Ignore coordinate noise when finger leaving the
729 * surface, otherwise cursor may jump to upper-left
730 * corner.
731 */
732 packet[3] &= 0xf0;
733 }
734
724 abs_x = GET_ABS_X(packet); 735 abs_x = GET_ABS_X(packet);
725 abs_y = GET_ABS_Y(packet); 736 abs_y = GET_ABS_Y(packet);
726 737
diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
index 2ffd110bd5bc..2e77246c2e5a 100644
--- a/drivers/input/serio/ambakmi.c
+++ b/drivers/input/serio/ambakmi.c
@@ -72,7 +72,7 @@ static int amba_kmi_open(struct serio *io)
72 unsigned int divisor; 72 unsigned int divisor;
73 int ret; 73 int ret;
74 74
75 ret = clk_enable(kmi->clk); 75 ret = clk_prepare_enable(kmi->clk);
76 if (ret) 76 if (ret)
77 goto out; 77 goto out;
78 78
@@ -92,7 +92,7 @@ static int amba_kmi_open(struct serio *io)
92 return 0; 92 return 0;
93 93
94 clk_disable: 94 clk_disable:
95 clk_disable(kmi->clk); 95 clk_disable_unprepare(kmi->clk);
96 out: 96 out:
97 return ret; 97 return ret;
98} 98}
@@ -104,7 +104,7 @@ static void amba_kmi_close(struct serio *io)
104 writeb(0, KMICR); 104 writeb(0, KMICR);
105 105
106 free_irq(kmi->irq, kmi); 106 free_irq(kmi->irq, kmi);
107 clk_disable(kmi->clk); 107 clk_disable_unprepare(kmi->clk);
108} 108}
109 109
110static int __devinit amba_kmi_probe(struct amba_device *dev, 110static int __devinit amba_kmi_probe(struct amba_device *dev,
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 6918773ce024..d6cc77a53c7e 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -335,6 +335,12 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
335 }, 335 },
336 { 336 {
337 .matches = { 337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE C850D"),
340 },
341 },
342 {
343 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"), 344 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"), 345 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
340 }, 346 },
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index b06a5e3a665e..64957770b522 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -566,9 +566,12 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
566 } 566 }
567 567
568 read = min_t(size_t, count, tsdata->raw_bufsize - *off); 568 read = min_t(size_t, count, tsdata->raw_bufsize - *off);
569 error = copy_to_user(buf, tsdata->raw_buffer + *off, read); 569 if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) {
570 if (!error) 570 error = -EFAULT;
571 *off += read; 571 goto out;
572 }
573
574 *off += read;
572out: 575out:
573 mutex_unlock(&tsdata->mutex); 576 mutex_unlock(&tsdata->mutex);
574 return error ?: read; 577 return error ?: read;
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index e32709e0dd65..721fdb3597ca 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -304,6 +304,45 @@ static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
304#define EGALAX_PKT_TYPE_REPT 0x80 304#define EGALAX_PKT_TYPE_REPT 0x80
305#define EGALAX_PKT_TYPE_DIAG 0x0A 305#define EGALAX_PKT_TYPE_DIAG 0x0A
306 306
307static int egalax_init(struct usbtouch_usb *usbtouch)
308{
309 int ret, i;
310 unsigned char *buf;
311 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
312
313 /*
314 * An eGalax diagnostic packet kicks the device into using the right
315 * protocol. We send a "check active" packet. The response will be
316 * read later and ignored.
317 */
318
319 buf = kmalloc(3, GFP_KERNEL);
320 if (!buf)
321 return -ENOMEM;
322
323 buf[0] = EGALAX_PKT_TYPE_DIAG;
324 buf[1] = 1; /* length */
325 buf[2] = 'A'; /* command - check active */
326
327 for (i = 0; i < 3; i++) {
328 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
329 0,
330 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
331 0, 0, buf, 3,
332 USB_CTRL_SET_TIMEOUT);
333 if (ret >= 0) {
334 ret = 0;
335 break;
336 }
337 if (ret != -EPIPE)
338 break;
339 }
340
341 kfree(buf);
342
343 return ret;
344}
345
307static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt) 346static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
308{ 347{
309 if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT) 348 if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
@@ -1056,6 +1095,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
1056 .process_pkt = usbtouch_process_multi, 1095 .process_pkt = usbtouch_process_multi,
1057 .get_pkt_len = egalax_get_pkt_len, 1096 .get_pkt_len = egalax_get_pkt_len,
1058 .read_data = egalax_read_data, 1097 .read_data = egalax_read_data,
1098 .init = egalax_init,
1059 }, 1099 },
1060#endif 1100#endif
1061 1101
diff --git a/drivers/isdn/hardware/mISDN/avmfritz.c b/drivers/isdn/hardware/mISDN/avmfritz.c
index fa6ca4733725..dceaec821b0e 100644
--- a/drivers/isdn/hardware/mISDN/avmfritz.c
+++ b/drivers/isdn/hardware/mISDN/avmfritz.c
@@ -857,8 +857,9 @@ avm_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
857 switch (cmd) { 857 switch (cmd) {
858 case CLOSE_CHANNEL: 858 case CLOSE_CHANNEL:
859 test_and_clear_bit(FLG_OPEN, &bch->Flags); 859 test_and_clear_bit(FLG_OPEN, &bch->Flags);
860 cancel_work_sync(&bch->workq);
860 spin_lock_irqsave(&fc->lock, flags); 861 spin_lock_irqsave(&fc->lock, flags);
861 mISDN_freebchannel(bch); 862 mISDN_clear_bchannel(bch);
862 modehdlc(bch, ISDN_P_NONE); 863 modehdlc(bch, ISDN_P_NONE);
863 spin_unlock_irqrestore(&fc->lock, flags); 864 spin_unlock_irqrestore(&fc->lock, flags);
864 ch->protocol = ISDN_P_NONE; 865 ch->protocol = ISDN_P_NONE;
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 5e402cf2e795..f02794203bb1 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -5059,6 +5059,7 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
5059 printk(KERN_INFO 5059 printk(KERN_INFO
5060 "HFC-E1 #%d has overlapping B-channels on fragment #%d\n", 5060 "HFC-E1 #%d has overlapping B-channels on fragment #%d\n",
5061 E1_cnt + 1, pt); 5061 E1_cnt + 1, pt);
5062 kfree(hc);
5062 return -EINVAL; 5063 return -EINVAL;
5063 } 5064 }
5064 maskcheck |= hc->bmask[pt]; 5065 maskcheck |= hc->bmask[pt];
@@ -5086,6 +5087,7 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
5086 if ((poll >> 1) > sizeof(hc->silence_data)) { 5087 if ((poll >> 1) > sizeof(hc->silence_data)) {
5087 printk(KERN_ERR "HFCMULTI error: silence_data too small, " 5088 printk(KERN_ERR "HFCMULTI error: silence_data too small, "
5088 "please fix\n"); 5089 "please fix\n");
5090 kfree(hc);
5089 return -EINVAL; 5091 return -EINVAL;
5090 } 5092 }
5091 for (i = 0; i < (poll >> 1); i++) 5093 for (i = 0; i < (poll >> 1); i++)
diff --git a/drivers/isdn/hardware/mISDN/mISDNipac.c b/drivers/isdn/hardware/mISDN/mISDNipac.c
index 752e0825591f..ccd7d851be26 100644
--- a/drivers/isdn/hardware/mISDN/mISDNipac.c
+++ b/drivers/isdn/hardware/mISDN/mISDNipac.c
@@ -1406,8 +1406,9 @@ hscx_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
1406 switch (cmd) { 1406 switch (cmd) {
1407 case CLOSE_CHANNEL: 1407 case CLOSE_CHANNEL:
1408 test_and_clear_bit(FLG_OPEN, &bch->Flags); 1408 test_and_clear_bit(FLG_OPEN, &bch->Flags);
1409 cancel_work_sync(&bch->workq);
1409 spin_lock_irqsave(hx->ip->hwlock, flags); 1410 spin_lock_irqsave(hx->ip->hwlock, flags);
1410 mISDN_freebchannel(bch); 1411 mISDN_clear_bchannel(bch);
1411 hscx_mode(hx, ISDN_P_NONE); 1412 hscx_mode(hx, ISDN_P_NONE);
1412 spin_unlock_irqrestore(hx->ip->hwlock, flags); 1413 spin_unlock_irqrestore(hx->ip->hwlock, flags);
1413 ch->protocol = ISDN_P_NONE; 1414 ch->protocol = ISDN_P_NONE;
diff --git a/drivers/isdn/hardware/mISDN/mISDNisar.c b/drivers/isdn/hardware/mISDN/mISDNisar.c
index be5973ded6d6..182ecf0626c2 100644
--- a/drivers/isdn/hardware/mISDN/mISDNisar.c
+++ b/drivers/isdn/hardware/mISDN/mISDNisar.c
@@ -1588,8 +1588,9 @@ isar_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
1588 switch (cmd) { 1588 switch (cmd) {
1589 case CLOSE_CHANNEL: 1589 case CLOSE_CHANNEL:
1590 test_and_clear_bit(FLG_OPEN, &bch->Flags); 1590 test_and_clear_bit(FLG_OPEN, &bch->Flags);
1591 cancel_work_sync(&bch->workq);
1591 spin_lock_irqsave(ich->is->hwlock, flags); 1592 spin_lock_irqsave(ich->is->hwlock, flags);
1592 mISDN_freebchannel(bch); 1593 mISDN_clear_bchannel(bch);
1593 modeisar(ich, ISDN_P_NONE); 1594 modeisar(ich, ISDN_P_NONE);
1594 spin_unlock_irqrestore(ich->is->hwlock, flags); 1595 spin_unlock_irqrestore(ich->is->hwlock, flags);
1595 ch->protocol = ISDN_P_NONE; 1596 ch->protocol = ISDN_P_NONE;
diff --git a/drivers/isdn/hardware/mISDN/netjet.c b/drivers/isdn/hardware/mISDN/netjet.c
index c3e3e7686273..9bcade59eb73 100644
--- a/drivers/isdn/hardware/mISDN/netjet.c
+++ b/drivers/isdn/hardware/mISDN/netjet.c
@@ -812,8 +812,9 @@ nj_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
812 switch (cmd) { 812 switch (cmd) {
813 case CLOSE_CHANNEL: 813 case CLOSE_CHANNEL:
814 test_and_clear_bit(FLG_OPEN, &bch->Flags); 814 test_and_clear_bit(FLG_OPEN, &bch->Flags);
815 cancel_work_sync(&bch->workq);
815 spin_lock_irqsave(&card->lock, flags); 816 spin_lock_irqsave(&card->lock, flags);
816 mISDN_freebchannel(bch); 817 mISDN_clear_bchannel(bch);
817 mode_tiger(bc, ISDN_P_NONE); 818 mode_tiger(bc, ISDN_P_NONE);
818 spin_unlock_irqrestore(&card->lock, flags); 819 spin_unlock_irqrestore(&card->lock, flags);
819 ch->protocol = ISDN_P_NONE; 820 ch->protocol = ISDN_P_NONE;
diff --git a/drivers/isdn/hardware/mISDN/w6692.c b/drivers/isdn/hardware/mISDN/w6692.c
index 26a86b846099..335fe6455002 100644
--- a/drivers/isdn/hardware/mISDN/w6692.c
+++ b/drivers/isdn/hardware/mISDN/w6692.c
@@ -1054,8 +1054,9 @@ w6692_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
1054 switch (cmd) { 1054 switch (cmd) {
1055 case CLOSE_CHANNEL: 1055 case CLOSE_CHANNEL:
1056 test_and_clear_bit(FLG_OPEN, &bch->Flags); 1056 test_and_clear_bit(FLG_OPEN, &bch->Flags);
1057 cancel_work_sync(&bch->workq);
1057 spin_lock_irqsave(&card->lock, flags); 1058 spin_lock_irqsave(&card->lock, flags);
1058 mISDN_freebchannel(bch); 1059 mISDN_clear_bchannel(bch);
1059 w6692_mode(bc, ISDN_P_NONE); 1060 w6692_mode(bc, ISDN_P_NONE);
1060 spin_unlock_irqrestore(&card->lock, flags); 1061 spin_unlock_irqrestore(&card->lock, flags);
1061 ch->protocol = ISDN_P_NONE; 1062 ch->protocol = ISDN_P_NONE;
diff --git a/drivers/isdn/mISDN/hwchannel.c b/drivers/isdn/mISDN/hwchannel.c
index ef34fd40867c..2602be23f341 100644
--- a/drivers/isdn/mISDN/hwchannel.c
+++ b/drivers/isdn/mISDN/hwchannel.c
@@ -148,17 +148,16 @@ mISDN_clear_bchannel(struct bchannel *ch)
148 ch->next_minlen = ch->init_minlen; 148 ch->next_minlen = ch->init_minlen;
149 ch->maxlen = ch->init_maxlen; 149 ch->maxlen = ch->init_maxlen;
150 ch->next_maxlen = ch->init_maxlen; 150 ch->next_maxlen = ch->init_maxlen;
151 skb_queue_purge(&ch->rqueue);
152 ch->rcount = 0;
151} 153}
152EXPORT_SYMBOL(mISDN_clear_bchannel); 154EXPORT_SYMBOL(mISDN_clear_bchannel);
153 155
154int 156void
155mISDN_freebchannel(struct bchannel *ch) 157mISDN_freebchannel(struct bchannel *ch)
156{ 158{
159 cancel_work_sync(&ch->workq);
157 mISDN_clear_bchannel(ch); 160 mISDN_clear_bchannel(ch);
158 skb_queue_purge(&ch->rqueue);
159 ch->rcount = 0;
160 flush_work_sync(&ch->workq);
161 return 0;
162} 161}
163EXPORT_SYMBOL(mISDN_freebchannel); 162EXPORT_SYMBOL(mISDN_freebchannel);
164 163
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3f6203a4c7ea..308e87b417e0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7619,6 +7619,8 @@ static int remove_and_add_spares(struct mddev *mddev)
7619 } 7619 }
7620 } 7620 }
7621 } 7621 }
7622 if (removed)
7623 set_bit(MD_CHANGE_DEVS, &mddev->flags);
7622 return spares; 7624 return spares;
7623} 7625}
7624 7626
@@ -7632,9 +7634,11 @@ static void reap_sync_thread(struct mddev *mddev)
7632 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { 7634 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
7633 /* success...*/ 7635 /* success...*/
7634 /* activate any spares */ 7636 /* activate any spares */
7635 if (mddev->pers->spare_active(mddev)) 7637 if (mddev->pers->spare_active(mddev)) {
7636 sysfs_notify(&mddev->kobj, NULL, 7638 sysfs_notify(&mddev->kobj, NULL,
7637 "degraded"); 7639 "degraded");
7640 set_bit(MD_CHANGE_DEVS, &mddev->flags);
7641 }
7638 } 7642 }
7639 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && 7643 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
7640 mddev->pers->finish_reshape) 7644 mddev->pers->finish_reshape)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index adda94df5eb2..7031b865b3a0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -393,6 +393,8 @@ static int calc_degraded(struct r5conf *conf)
393 degraded = 0; 393 degraded = 0;
394 for (i = 0; i < conf->previous_raid_disks; i++) { 394 for (i = 0; i < conf->previous_raid_disks; i++) {
395 struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev); 395 struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev);
396 if (rdev && test_bit(Faulty, &rdev->flags))
397 rdev = rcu_dereference(conf->disks[i].replacement);
396 if (!rdev || test_bit(Faulty, &rdev->flags)) 398 if (!rdev || test_bit(Faulty, &rdev->flags))
397 degraded++; 399 degraded++;
398 else if (test_bit(In_sync, &rdev->flags)) 400 else if (test_bit(In_sync, &rdev->flags))
@@ -417,6 +419,8 @@ static int calc_degraded(struct r5conf *conf)
417 degraded2 = 0; 419 degraded2 = 0;
418 for (i = 0; i < conf->raid_disks; i++) { 420 for (i = 0; i < conf->raid_disks; i++) {
419 struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev); 421 struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev);
422 if (rdev && test_bit(Faulty, &rdev->flags))
423 rdev = rcu_dereference(conf->disks[i].replacement);
420 if (!rdev || test_bit(Faulty, &rdev->flags)) 424 if (!rdev || test_bit(Faulty, &rdev->flags))
421 degraded2++; 425 degraded2++;
422 else if (test_bit(In_sync, &rdev->flags)) 426 else if (test_bit(In_sync, &rdev->flags))
@@ -4192,7 +4196,7 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4192 finish_wait(&conf->wait_for_overlap, &w); 4196 finish_wait(&conf->wait_for_overlap, &w);
4193 set_bit(STRIPE_HANDLE, &sh->state); 4197 set_bit(STRIPE_HANDLE, &sh->state);
4194 clear_bit(STRIPE_DELAYED, &sh->state); 4198 clear_bit(STRIPE_DELAYED, &sh->state);
4195 if ((bi->bi_rw & REQ_NOIDLE) && 4199 if ((bi->bi_rw & REQ_SYNC) &&
4196 !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) 4200 !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
4197 atomic_inc(&conf->preread_active_stripes); 4201 atomic_inc(&conf->preread_active_stripes);
4198 release_stripe_plug(mddev, sh); 4202 release_stripe_plug(mddev, sh);
diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
index b67a3018b136..ce229ea933d1 100644
--- a/drivers/mfd/88pm800.c
+++ b/drivers/mfd/88pm800.c
@@ -470,7 +470,8 @@ static int __devinit device_800_init(struct pm80x_chip *chip,
470 470
471 ret = 471 ret =
472 mfd_add_devices(chip->dev, 0, &onkey_devs[0], 472 mfd_add_devices(chip->dev, 0, &onkey_devs[0],
473 ARRAY_SIZE(onkey_devs), &onkey_resources[0], 0); 473 ARRAY_SIZE(onkey_devs), &onkey_resources[0], 0,
474 NULL);
474 if (ret < 0) { 475 if (ret < 0) {
475 dev_err(chip->dev, "Failed to add onkey subdev\n"); 476 dev_err(chip->dev, "Failed to add onkey subdev\n");
476 goto out_dev; 477 goto out_dev;
@@ -481,7 +482,7 @@ static int __devinit device_800_init(struct pm80x_chip *chip,
481 rtc_devs[0].platform_data = pdata->rtc; 482 rtc_devs[0].platform_data = pdata->rtc;
482 rtc_devs[0].pdata_size = sizeof(struct pm80x_rtc_pdata); 483 rtc_devs[0].pdata_size = sizeof(struct pm80x_rtc_pdata);
483 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 484 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
484 ARRAY_SIZE(rtc_devs), NULL, 0); 485 ARRAY_SIZE(rtc_devs), NULL, 0, NULL);
485 if (ret < 0) { 486 if (ret < 0) {
486 dev_err(chip->dev, "Failed to add rtc subdev\n"); 487 dev_err(chip->dev, "Failed to add rtc subdev\n");
487 goto out_dev; 488 goto out_dev;
diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c
index 6146583589f6..c20a31136f04 100644
--- a/drivers/mfd/88pm805.c
+++ b/drivers/mfd/88pm805.c
@@ -216,7 +216,8 @@ static int __devinit device_805_init(struct pm80x_chip *chip)
216 } 216 }
217 217
218 ret = mfd_add_devices(chip->dev, 0, &codec_devs[0], 218 ret = mfd_add_devices(chip->dev, 0, &codec_devs[0],
219 ARRAY_SIZE(codec_devs), &codec_resources[0], 0); 219 ARRAY_SIZE(codec_devs), &codec_resources[0], 0,
220 NULL);
220 if (ret < 0) { 221 if (ret < 0) {
221 dev_err(chip->dev, "Failed to add codec subdev\n"); 222 dev_err(chip->dev, "Failed to add codec subdev\n");
222 goto out_codec; 223 goto out_codec;
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index d09918cf1b15..b73f033b2c60 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -637,7 +637,7 @@ static void __devinit device_bk_init(struct pm860x_chip *chip,
637 bk_devs[i].resources = &bk_resources[j]; 637 bk_devs[i].resources = &bk_resources[j];
638 ret = mfd_add_devices(chip->dev, 0, 638 ret = mfd_add_devices(chip->dev, 0,
639 &bk_devs[i], 1, 639 &bk_devs[i], 1,
640 &bk_resources[j], 0); 640 &bk_resources[j], 0, NULL);
641 if (ret < 0) { 641 if (ret < 0) {
642 dev_err(chip->dev, "Failed to add " 642 dev_err(chip->dev, "Failed to add "
643 "backlight subdev\n"); 643 "backlight subdev\n");
@@ -672,7 +672,7 @@ static void __devinit device_led_init(struct pm860x_chip *chip,
672 led_devs[i].resources = &led_resources[j], 672 led_devs[i].resources = &led_resources[j],
673 ret = mfd_add_devices(chip->dev, 0, 673 ret = mfd_add_devices(chip->dev, 0,
674 &led_devs[i], 1, 674 &led_devs[i], 1,
675 &led_resources[j], 0); 675 &led_resources[j], 0, NULL);
676 if (ret < 0) { 676 if (ret < 0) {
677 dev_err(chip->dev, "Failed to add " 677 dev_err(chip->dev, "Failed to add "
678 "led subdev\n"); 678 "led subdev\n");
@@ -709,7 +709,7 @@ static void __devinit device_regulator_init(struct pm860x_chip *chip,
709 regulator_devs[i].resources = &regulator_resources[seq]; 709 regulator_devs[i].resources = &regulator_resources[seq];
710 710
711 ret = mfd_add_devices(chip->dev, 0, &regulator_devs[i], 1, 711 ret = mfd_add_devices(chip->dev, 0, &regulator_devs[i], 1,
712 &regulator_resources[seq], 0); 712 &regulator_resources[seq], 0, NULL);
713 if (ret < 0) { 713 if (ret < 0) {
714 dev_err(chip->dev, "Failed to add regulator subdev\n"); 714 dev_err(chip->dev, "Failed to add regulator subdev\n");
715 goto out; 715 goto out;
@@ -733,7 +733,7 @@ static void __devinit device_rtc_init(struct pm860x_chip *chip,
733 rtc_devs[0].resources = &rtc_resources[0]; 733 rtc_devs[0].resources = &rtc_resources[0];
734 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 734 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
735 ARRAY_SIZE(rtc_devs), &rtc_resources[0], 735 ARRAY_SIZE(rtc_devs), &rtc_resources[0],
736 chip->irq_base); 736 chip->irq_base, NULL);
737 if (ret < 0) 737 if (ret < 0)
738 dev_err(chip->dev, "Failed to add rtc subdev\n"); 738 dev_err(chip->dev, "Failed to add rtc subdev\n");
739} 739}
@@ -752,7 +752,7 @@ static void __devinit device_touch_init(struct pm860x_chip *chip,
752 touch_devs[0].resources = &touch_resources[0]; 752 touch_devs[0].resources = &touch_resources[0];
753 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0], 753 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
754 ARRAY_SIZE(touch_devs), &touch_resources[0], 754 ARRAY_SIZE(touch_devs), &touch_resources[0],
755 chip->irq_base); 755 chip->irq_base, NULL);
756 if (ret < 0) 756 if (ret < 0)
757 dev_err(chip->dev, "Failed to add touch subdev\n"); 757 dev_err(chip->dev, "Failed to add touch subdev\n");
758} 758}
@@ -770,7 +770,7 @@ static void __devinit device_power_init(struct pm860x_chip *chip,
770 power_devs[0].num_resources = ARRAY_SIZE(battery_resources); 770 power_devs[0].num_resources = ARRAY_SIZE(battery_resources);
771 power_devs[0].resources = &battery_resources[0], 771 power_devs[0].resources = &battery_resources[0],
772 ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 1, 772 ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 1,
773 &battery_resources[0], chip->irq_base); 773 &battery_resources[0], chip->irq_base, NULL);
774 if (ret < 0) 774 if (ret < 0)
775 dev_err(chip->dev, "Failed to add battery subdev\n"); 775 dev_err(chip->dev, "Failed to add battery subdev\n");
776 776
@@ -779,7 +779,7 @@ static void __devinit device_power_init(struct pm860x_chip *chip,
779 power_devs[1].num_resources = ARRAY_SIZE(charger_resources); 779 power_devs[1].num_resources = ARRAY_SIZE(charger_resources);
780 power_devs[1].resources = &charger_resources[0], 780 power_devs[1].resources = &charger_resources[0],
781 ret = mfd_add_devices(chip->dev, 0, &power_devs[1], 1, 781 ret = mfd_add_devices(chip->dev, 0, &power_devs[1], 1,
782 &charger_resources[0], chip->irq_base); 782 &charger_resources[0], chip->irq_base, NULL);
783 if (ret < 0) 783 if (ret < 0)
784 dev_err(chip->dev, "Failed to add charger subdev\n"); 784 dev_err(chip->dev, "Failed to add charger subdev\n");
785 785
@@ -788,7 +788,7 @@ static void __devinit device_power_init(struct pm860x_chip *chip,
788 power_devs[2].num_resources = ARRAY_SIZE(preg_resources); 788 power_devs[2].num_resources = ARRAY_SIZE(preg_resources);
789 power_devs[2].resources = &preg_resources[0], 789 power_devs[2].resources = &preg_resources[0],
790 ret = mfd_add_devices(chip->dev, 0, &power_devs[2], 1, 790 ret = mfd_add_devices(chip->dev, 0, &power_devs[2], 1,
791 &preg_resources[0], chip->irq_base); 791 &preg_resources[0], chip->irq_base, NULL);
792 if (ret < 0) 792 if (ret < 0)
793 dev_err(chip->dev, "Failed to add preg subdev\n"); 793 dev_err(chip->dev, "Failed to add preg subdev\n");
794} 794}
@@ -802,7 +802,7 @@ static void __devinit device_onkey_init(struct pm860x_chip *chip,
802 onkey_devs[0].resources = &onkey_resources[0], 802 onkey_devs[0].resources = &onkey_resources[0],
803 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0], 803 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
804 ARRAY_SIZE(onkey_devs), &onkey_resources[0], 804 ARRAY_SIZE(onkey_devs), &onkey_resources[0],
805 chip->irq_base); 805 chip->irq_base, NULL);
806 if (ret < 0) 806 if (ret < 0)
807 dev_err(chip->dev, "Failed to add onkey subdev\n"); 807 dev_err(chip->dev, "Failed to add onkey subdev\n");
808} 808}
@@ -815,7 +815,8 @@ static void __devinit device_codec_init(struct pm860x_chip *chip,
815 codec_devs[0].num_resources = ARRAY_SIZE(codec_resources); 815 codec_devs[0].num_resources = ARRAY_SIZE(codec_resources);
816 codec_devs[0].resources = &codec_resources[0], 816 codec_devs[0].resources = &codec_resources[0],
817 ret = mfd_add_devices(chip->dev, 0, &codec_devs[0], 817 ret = mfd_add_devices(chip->dev, 0, &codec_devs[0],
818 ARRAY_SIZE(codec_devs), &codec_resources[0], 0); 818 ARRAY_SIZE(codec_devs), &codec_resources[0], 0,
819 NULL);
819 if (ret < 0) 820 if (ret < 0)
820 dev_err(chip->dev, "Failed to add codec subdev\n"); 821 dev_err(chip->dev, "Failed to add codec subdev\n");
821} 822}
diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c
index 44a3fdbadef4..f1beb4971f87 100644
--- a/drivers/mfd/aat2870-core.c
+++ b/drivers/mfd/aat2870-core.c
@@ -424,7 +424,7 @@ static int aat2870_i2c_probe(struct i2c_client *client,
424 } 424 }
425 425
426 ret = mfd_add_devices(aat2870->dev, 0, aat2870_devs, 426 ret = mfd_add_devices(aat2870->dev, 0, aat2870_devs,
427 ARRAY_SIZE(aat2870_devs), NULL, 0); 427 ARRAY_SIZE(aat2870_devs), NULL, 0, NULL);
428 if (ret != 0) { 428 if (ret != 0) {
429 dev_err(aat2870->dev, "Failed to add subdev: %d\n", ret); 429 dev_err(aat2870->dev, "Failed to add subdev: %d\n", ret);
430 goto out_disable; 430 goto out_disable;
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 78fca2902c8d..01781ae5d0d7 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -946,7 +946,7 @@ static int __devinit ab3100_probe(struct i2c_client *client,
946 } 946 }
947 947
948 err = mfd_add_devices(&client->dev, 0, ab3100_devs, 948 err = mfd_add_devices(&client->dev, 0, ab3100_devs,
949 ARRAY_SIZE(ab3100_devs), NULL, 0); 949 ARRAY_SIZE(ab3100_devs), NULL, 0, NULL);
950 950
951 ab3100_setup_debugfs(ab3100); 951 ab3100_setup_debugfs(ab3100);
952 952
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 626b4ecaf647..47adf800024e 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -1418,25 +1418,25 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
1418 1418
1419 ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, 1419 ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs,
1420 ARRAY_SIZE(abx500_common_devs), NULL, 1420 ARRAY_SIZE(abx500_common_devs), NULL,
1421 ab8500->irq_base); 1421 ab8500->irq_base, ab8500->domain);
1422 if (ret) 1422 if (ret)
1423 goto out_freeirq; 1423 goto out_freeirq;
1424 1424
1425 if (is_ab9540(ab8500)) 1425 if (is_ab9540(ab8500))
1426 ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, 1426 ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs,
1427 ARRAY_SIZE(ab9540_devs), NULL, 1427 ARRAY_SIZE(ab9540_devs), NULL,
1428 ab8500->irq_base); 1428 ab8500->irq_base, ab8500->domain);
1429 else 1429 else
1430 ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, 1430 ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs,
1431 ARRAY_SIZE(ab8500_devs), NULL, 1431 ARRAY_SIZE(ab8500_devs), NULL,
1432 ab8500->irq_base); 1432 ab8500->irq_base, ab8500->domain);
1433 if (ret) 1433 if (ret)
1434 goto out_freeirq; 1434 goto out_freeirq;
1435 1435
1436 if (is_ab9540(ab8500) || is_ab8505(ab8500)) 1436 if (is_ab9540(ab8500) || is_ab8505(ab8500))
1437 ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, 1437 ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs,
1438 ARRAY_SIZE(ab9540_ab8505_devs), NULL, 1438 ARRAY_SIZE(ab9540_ab8505_devs), NULL,
1439 ab8500->irq_base); 1439 ab8500->irq_base, ab8500->domain);
1440 if (ret) 1440 if (ret)
1441 goto out_freeirq; 1441 goto out_freeirq;
1442 1442
@@ -1444,7 +1444,7 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
1444 /* Add battery management devices */ 1444 /* Add battery management devices */
1445 ret = mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs, 1445 ret = mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs,
1446 ARRAY_SIZE(ab8500_bm_devs), NULL, 1446 ARRAY_SIZE(ab8500_bm_devs), NULL,
1447 ab8500->irq_base); 1447 ab8500->irq_base, ab8500->domain);
1448 if (ret) 1448 if (ret)
1449 dev_err(ab8500->dev, "error adding bm devices\n"); 1449 dev_err(ab8500->dev, "error adding bm devices\n");
1450 } 1450 }
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index c7983e862549..1b48f2094806 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -316,7 +316,7 @@ int __devinit arizona_dev_init(struct arizona *arizona)
316 } 316 }
317 317
318 ret = mfd_add_devices(arizona->dev, -1, early_devs, 318 ret = mfd_add_devices(arizona->dev, -1, early_devs,
319 ARRAY_SIZE(early_devs), NULL, 0); 319 ARRAY_SIZE(early_devs), NULL, 0, NULL);
320 if (ret != 0) { 320 if (ret != 0) {
321 dev_err(dev, "Failed to add early children: %d\n", ret); 321 dev_err(dev, "Failed to add early children: %d\n", ret);
322 return ret; 322 return ret;
@@ -516,11 +516,11 @@ int __devinit arizona_dev_init(struct arizona *arizona)
516 switch (arizona->type) { 516 switch (arizona->type) {
517 case WM5102: 517 case WM5102:
518 ret = mfd_add_devices(arizona->dev, -1, wm5102_devs, 518 ret = mfd_add_devices(arizona->dev, -1, wm5102_devs,
519 ARRAY_SIZE(wm5102_devs), NULL, 0); 519 ARRAY_SIZE(wm5102_devs), NULL, 0, NULL);
520 break; 520 break;
521 case WM5110: 521 case WM5110:
522 ret = mfd_add_devices(arizona->dev, -1, wm5110_devs, 522 ret = mfd_add_devices(arizona->dev, -1, wm5110_devs,
523 ARRAY_SIZE(wm5102_devs), NULL, 0); 523 ARRAY_SIZE(wm5102_devs), NULL, 0, NULL);
524 break; 524 break;
525 } 525 }
526 526
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 683e18a23329..62f0883a7630 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -913,14 +913,14 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
913 if (pdata->clock_rate) { 913 if (pdata->clock_rate) {
914 ds1wm_pdata.clock_rate = pdata->clock_rate; 914 ds1wm_pdata.clock_rate = pdata->clock_rate;
915 ret = mfd_add_devices(&pdev->dev, pdev->id, 915 ret = mfd_add_devices(&pdev->dev, pdev->id,
916 &asic3_cell_ds1wm, 1, mem, asic->irq_base); 916 &asic3_cell_ds1wm, 1, mem, asic->irq_base, NULL);
917 if (ret < 0) 917 if (ret < 0)
918 goto out; 918 goto out;
919 } 919 }
920 920
921 if (mem_sdio && (irq >= 0)) { 921 if (mem_sdio && (irq >= 0)) {
922 ret = mfd_add_devices(&pdev->dev, pdev->id, 922 ret = mfd_add_devices(&pdev->dev, pdev->id,
923 &asic3_cell_mmc, 1, mem_sdio, irq); 923 &asic3_cell_mmc, 1, mem_sdio, irq, NULL);
924 if (ret < 0) 924 if (ret < 0)
925 goto out; 925 goto out;
926 } 926 }
@@ -934,7 +934,7 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
934 asic3_cell_leds[i].pdata_size = sizeof(pdata->leds[i]); 934 asic3_cell_leds[i].pdata_size = sizeof(pdata->leds[i]);
935 } 935 }
936 ret = mfd_add_devices(&pdev->dev, 0, 936 ret = mfd_add_devices(&pdev->dev, 0,
937 asic3_cell_leds, ASIC3_NUM_LEDS, NULL, 0); 937 asic3_cell_leds, ASIC3_NUM_LEDS, NULL, 0, NULL);
938 } 938 }
939 939
940 out: 940 out:
diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c
index 3419e726de47..2b282133c725 100644
--- a/drivers/mfd/cs5535-mfd.c
+++ b/drivers/mfd/cs5535-mfd.c
@@ -149,7 +149,7 @@ static int __devinit cs5535_mfd_probe(struct pci_dev *pdev,
149 } 149 }
150 150
151 err = mfd_add_devices(&pdev->dev, -1, cs5535_mfd_cells, 151 err = mfd_add_devices(&pdev->dev, -1, cs5535_mfd_cells,
152 ARRAY_SIZE(cs5535_mfd_cells), NULL, 0); 152 ARRAY_SIZE(cs5535_mfd_cells), NULL, 0, NULL);
153 if (err) { 153 if (err) {
154 dev_err(&pdev->dev, "MFD add devices failed: %d\n", err); 154 dev_err(&pdev->dev, "MFD add devices failed: %d\n", err);
155 goto err_disable; 155 goto err_disable;
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
index 2544910e1fd6..a0a62b24621b 100644
--- a/drivers/mfd/da9052-core.c
+++ b/drivers/mfd/da9052-core.c
@@ -803,7 +803,7 @@ int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id)
803 dev_err(da9052->dev, "DA9052 ADC IRQ failed ret=%d\n", ret); 803 dev_err(da9052->dev, "DA9052 ADC IRQ failed ret=%d\n", ret);
804 804
805 ret = mfd_add_devices(da9052->dev, -1, da9052_subdev_info, 805 ret = mfd_add_devices(da9052->dev, -1, da9052_subdev_info,
806 ARRAY_SIZE(da9052_subdev_info), NULL, 0); 806 ARRAY_SIZE(da9052_subdev_info), NULL, 0, NULL);
807 if (ret) 807 if (ret)
808 goto err; 808 goto err;
809 809
diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c
index 4e2af2cb2d26..45e83a68641b 100644
--- a/drivers/mfd/davinci_voicecodec.c
+++ b/drivers/mfd/davinci_voicecodec.c
@@ -129,7 +129,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
129 cell->pdata_size = sizeof(*davinci_vc); 129 cell->pdata_size = sizeof(*davinci_vc);
130 130
131 ret = mfd_add_devices(&pdev->dev, pdev->id, davinci_vc->cells, 131 ret = mfd_add_devices(&pdev->dev, pdev->id, davinci_vc->cells,
132 DAVINCI_VC_CELLS, NULL, 0); 132 DAVINCI_VC_CELLS, NULL, 0, NULL);
133 if (ret != 0) { 133 if (ret != 0) {
134 dev_err(&pdev->dev, "fail to register client devices\n"); 134 dev_err(&pdev->dev, "fail to register client devices\n");
135 goto fail4; 135 goto fail4;
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index 7040a0081130..0e63cdd9b52a 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -3010,7 +3010,7 @@ static int __devinit db8500_prcmu_probe(struct platform_device *pdev)
3010 prcmu_config_esram0_deep_sleep(ESRAM0_DEEP_SLEEP_STATE_RET); 3010 prcmu_config_esram0_deep_sleep(ESRAM0_DEEP_SLEEP_STATE_RET);
3011 3011
3012 err = mfd_add_devices(&pdev->dev, 0, db8500_prcmu_devs, 3012 err = mfd_add_devices(&pdev->dev, 0, db8500_prcmu_devs,
3013 ARRAY_SIZE(db8500_prcmu_devs), NULL, 0); 3013 ARRAY_SIZE(db8500_prcmu_devs), NULL, 0, NULL);
3014 if (err) { 3014 if (err) {
3015 pr_err("prcmu: Failed to add subdevices\n"); 3015 pr_err("prcmu: Failed to add subdevices\n");
3016 return err; 3016 return err;
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
index 04c7093d6499..9e5453d21a68 100644
--- a/drivers/mfd/htc-pasic3.c
+++ b/drivers/mfd/htc-pasic3.c
@@ -168,7 +168,7 @@ static int __init pasic3_probe(struct platform_device *pdev)
168 /* the first 5 PASIC3 registers control the DS1WM */ 168 /* the first 5 PASIC3 registers control the DS1WM */
169 ds1wm_resources[0].end = (5 << asic->bus_shift) - 1; 169 ds1wm_resources[0].end = (5 << asic->bus_shift) - 1;
170 ret = mfd_add_devices(&pdev->dev, pdev->id, 170 ret = mfd_add_devices(&pdev->dev, pdev->id,
171 &ds1wm_cell, 1, r, irq); 171 &ds1wm_cell, 1, r, irq, NULL);
172 if (ret < 0) 172 if (ret < 0)
173 dev_warn(dev, "failed to register DS1WM\n"); 173 dev_warn(dev, "failed to register DS1WM\n");
174 } 174 }
@@ -176,7 +176,8 @@ static int __init pasic3_probe(struct platform_device *pdev)
176 if (pdata && pdata->led_pdata) { 176 if (pdata && pdata->led_pdata) {
177 led_cell.platform_data = pdata->led_pdata; 177 led_cell.platform_data = pdata->led_pdata;
178 led_cell.pdata_size = sizeof(struct pasic3_leds_machinfo); 178 led_cell.pdata_size = sizeof(struct pasic3_leds_machinfo);
179 ret = mfd_add_devices(&pdev->dev, pdev->id, &led_cell, 1, r, 0); 179 ret = mfd_add_devices(&pdev->dev, pdev->id, &led_cell, 1, r,
180 0, NULL);
180 if (ret < 0) 181 if (ret < 0)
181 dev_warn(dev, "failed to register LED device\n"); 182 dev_warn(dev, "failed to register LED device\n");
182 } 183 }
diff --git a/drivers/mfd/intel_msic.c b/drivers/mfd/intel_msic.c
index 59df5584cb58..266bdc5bd96d 100644
--- a/drivers/mfd/intel_msic.c
+++ b/drivers/mfd/intel_msic.c
@@ -344,13 +344,13 @@ static int __devinit intel_msic_init_devices(struct intel_msic *msic)
344 continue; 344 continue;
345 345
346 ret = mfd_add_devices(&pdev->dev, -1, &msic_devs[i], 1, NULL, 346 ret = mfd_add_devices(&pdev->dev, -1, &msic_devs[i], 1, NULL,
347 pdata->irq[i]); 347 pdata->irq[i], NULL);
348 if (ret) 348 if (ret)
349 goto fail; 349 goto fail;
350 } 350 }
351 351
352 ret = mfd_add_devices(&pdev->dev, 0, msic_other_devs, 352 ret = mfd_add_devices(&pdev->dev, 0, msic_other_devs,
353 ARRAY_SIZE(msic_other_devs), NULL, 0); 353 ARRAY_SIZE(msic_other_devs), NULL, 0, NULL);
354 if (ret) 354 if (ret)
355 goto fail; 355 goto fail;
356 356
diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
index 2ea99989551a..965c4801df8a 100644
--- a/drivers/mfd/janz-cmodio.c
+++ b/drivers/mfd/janz-cmodio.c
@@ -147,7 +147,7 @@ static int __devinit cmodio_probe_submodules(struct cmodio_device *priv)
147 } 147 }
148 148
149 return mfd_add_devices(&pdev->dev, 0, priv->cells, 149 return mfd_add_devices(&pdev->dev, 0, priv->cells,
150 num_probed, NULL, pdev->irq); 150 num_probed, NULL, pdev->irq, NULL);
151} 151}
152 152
153/* 153/*
diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c
index 87662a17dec6..c6b6d7dda517 100644
--- a/drivers/mfd/jz4740-adc.c
+++ b/drivers/mfd/jz4740-adc.c
@@ -287,7 +287,8 @@ static int __devinit jz4740_adc_probe(struct platform_device *pdev)
287 writeb(0xff, adc->base + JZ_REG_ADC_CTRL); 287 writeb(0xff, adc->base + JZ_REG_ADC_CTRL);
288 288
289 ret = mfd_add_devices(&pdev->dev, 0, jz4740_adc_cells, 289 ret = mfd_add_devices(&pdev->dev, 0, jz4740_adc_cells,
290 ARRAY_SIZE(jz4740_adc_cells), mem_base, irq_base); 290 ARRAY_SIZE(jz4740_adc_cells), mem_base,
291 irq_base, NULL);
291 if (ret < 0) 292 if (ret < 0)
292 goto err_clk_put; 293 goto err_clk_put;
293 294
diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
index 0b2879b87fd9..24212f45b201 100644
--- a/drivers/mfd/lm3533-core.c
+++ b/drivers/mfd/lm3533-core.c
@@ -393,7 +393,8 @@ static int __devinit lm3533_device_als_init(struct lm3533 *lm3533)
393 lm3533_als_devs[0].platform_data = pdata->als; 393 lm3533_als_devs[0].platform_data = pdata->als;
394 lm3533_als_devs[0].pdata_size = sizeof(*pdata->als); 394 lm3533_als_devs[0].pdata_size = sizeof(*pdata->als);
395 395
396 ret = mfd_add_devices(lm3533->dev, 0, lm3533_als_devs, 1, NULL, 0); 396 ret = mfd_add_devices(lm3533->dev, 0, lm3533_als_devs, 1, NULL,
397 0, NULL);
397 if (ret) { 398 if (ret) {
398 dev_err(lm3533->dev, "failed to add ALS device\n"); 399 dev_err(lm3533->dev, "failed to add ALS device\n");
399 return ret; 400 return ret;
@@ -422,7 +423,7 @@ static int __devinit lm3533_device_bl_init(struct lm3533 *lm3533)
422 } 423 }
423 424
424 ret = mfd_add_devices(lm3533->dev, 0, lm3533_bl_devs, 425 ret = mfd_add_devices(lm3533->dev, 0, lm3533_bl_devs,
425 pdata->num_backlights, NULL, 0); 426 pdata->num_backlights, NULL, 0, NULL);
426 if (ret) { 427 if (ret) {
427 dev_err(lm3533->dev, "failed to add backlight devices\n"); 428 dev_err(lm3533->dev, "failed to add backlight devices\n");
428 return ret; 429 return ret;
@@ -451,7 +452,7 @@ static int __devinit lm3533_device_led_init(struct lm3533 *lm3533)
451 } 452 }
452 453
453 ret = mfd_add_devices(lm3533->dev, 0, lm3533_led_devs, 454 ret = mfd_add_devices(lm3533->dev, 0, lm3533_led_devs,
454 pdata->num_leds, NULL, 0); 455 pdata->num_leds, NULL, 0, NULL);
455 if (ret) { 456 if (ret) {
456 dev_err(lm3533->dev, "failed to add LED devices\n"); 457 dev_err(lm3533->dev, "failed to add LED devices\n");
457 return ret; 458 return ret;
diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index 027cc8f86132..092ad4b44b6d 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -750,7 +750,7 @@ gpe0_done:
750 750
751 lpc_ich_finalize_cell(&lpc_ich_cells[LPC_GPIO], id); 751 lpc_ich_finalize_cell(&lpc_ich_cells[LPC_GPIO], id);
752 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_GPIO], 752 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_GPIO],
753 1, NULL, 0); 753 1, NULL, 0, NULL);
754 754
755gpio_done: 755gpio_done:
756 if (acpi_conflict) 756 if (acpi_conflict)
@@ -765,7 +765,6 @@ static int __devinit lpc_ich_init_wdt(struct pci_dev *dev,
765 u32 base_addr_cfg; 765 u32 base_addr_cfg;
766 u32 base_addr; 766 u32 base_addr;
767 int ret; 767 int ret;
768 bool acpi_conflict = false;
769 struct resource *res; 768 struct resource *res;
770 769
771 /* Setup power management base register */ 770 /* Setup power management base register */
@@ -780,20 +779,11 @@ static int __devinit lpc_ich_init_wdt(struct pci_dev *dev,
780 res = wdt_io_res(ICH_RES_IO_TCO); 779 res = wdt_io_res(ICH_RES_IO_TCO);
781 res->start = base_addr + ACPIBASE_TCO_OFF; 780 res->start = base_addr + ACPIBASE_TCO_OFF;
782 res->end = base_addr + ACPIBASE_TCO_END; 781 res->end = base_addr + ACPIBASE_TCO_END;
783 ret = acpi_check_resource_conflict(res);
784 if (ret) {
785 acpi_conflict = true;
786 goto wdt_done;
787 }
788 782
789 res = wdt_io_res(ICH_RES_IO_SMI); 783 res = wdt_io_res(ICH_RES_IO_SMI);
790 res->start = base_addr + ACPIBASE_SMI_OFF; 784 res->start = base_addr + ACPIBASE_SMI_OFF;
791 res->end = base_addr + ACPIBASE_SMI_END; 785 res->end = base_addr + ACPIBASE_SMI_END;
792 ret = acpi_check_resource_conflict(res); 786
793 if (ret) {
794 acpi_conflict = true;
795 goto wdt_done;
796 }
797 lpc_ich_enable_acpi_space(dev); 787 lpc_ich_enable_acpi_space(dev);
798 788
799 /* 789 /*
@@ -813,21 +803,13 @@ static int __devinit lpc_ich_init_wdt(struct pci_dev *dev,
813 res = wdt_mem_res(ICH_RES_MEM_GCS); 803 res = wdt_mem_res(ICH_RES_MEM_GCS);
814 res->start = base_addr + ACPIBASE_GCS_OFF; 804 res->start = base_addr + ACPIBASE_GCS_OFF;
815 res->end = base_addr + ACPIBASE_GCS_END; 805 res->end = base_addr + ACPIBASE_GCS_END;
816 ret = acpi_check_resource_conflict(res);
817 if (ret) {
818 acpi_conflict = true;
819 goto wdt_done;
820 }
821 } 806 }
822 807
823 lpc_ich_finalize_cell(&lpc_ich_cells[LPC_WDT], id); 808 lpc_ich_finalize_cell(&lpc_ich_cells[LPC_WDT], id);
824 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_WDT], 809 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_WDT],
825 1, NULL, 0); 810 1, NULL, 0, NULL);
826 811
827wdt_done: 812wdt_done:
828 if (acpi_conflict)
829 pr_warn("Resource conflict(s) found affecting %s\n",
830 lpc_ich_cells[LPC_WDT].name);
831 return ret; 813 return ret;
832} 814}
833 815
diff --git a/drivers/mfd/lpc_sch.c b/drivers/mfd/lpc_sch.c
index 9f20abc5e393..f6b9c5c96b24 100644
--- a/drivers/mfd/lpc_sch.c
+++ b/drivers/mfd/lpc_sch.c
@@ -127,7 +127,8 @@ static int __devinit lpc_sch_probe(struct pci_dev *dev,
127 lpc_sch_cells[i].id = id->device; 127 lpc_sch_cells[i].id = id->device;
128 128
129 ret = mfd_add_devices(&dev->dev, 0, 129 ret = mfd_add_devices(&dev->dev, 0,
130 lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); 130 lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL,
131 0, NULL);
131 if (ret) 132 if (ret)
132 goto out_dev; 133 goto out_dev;
133 134
@@ -153,7 +154,8 @@ static int __devinit lpc_sch_probe(struct pci_dev *dev,
153 tunnelcreek_cells[i].id = id->device; 154 tunnelcreek_cells[i].id = id->device;
154 155
155 ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells, 156 ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells,
156 ARRAY_SIZE(tunnelcreek_cells), NULL, 0); 157 ARRAY_SIZE(tunnelcreek_cells), NULL,
158 0, NULL);
157 } 159 }
158 160
159 return ret; 161 return ret;
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index c03e12b51924..d9e24c849a00 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -126,7 +126,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
126 max77686_irq_init(max77686); 126 max77686_irq_init(max77686);
127 127
128 ret = mfd_add_devices(max77686->dev, -1, max77686_devs, 128 ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
129 ARRAY_SIZE(max77686_devs), NULL, 0); 129 ARRAY_SIZE(max77686_devs), NULL, 0, NULL);
130 130
131 if (ret < 0) 131 if (ret < 0)
132 goto err_mfd; 132 goto err_mfd;
diff --git a/drivers/mfd/max77693-irq.c b/drivers/mfd/max77693-irq.c
index 2b403569e0a6..1029d018c739 100644
--- a/drivers/mfd/max77693-irq.c
+++ b/drivers/mfd/max77693-irq.c
@@ -137,6 +137,9 @@ static void max77693_irq_mask(struct irq_data *data)
137 const struct max77693_irq_data *irq_data = 137 const struct max77693_irq_data *irq_data =
138 irq_to_max77693_irq(max77693, data->irq); 138 irq_to_max77693_irq(max77693, data->irq);
139 139
140 if (irq_data->group >= MAX77693_IRQ_GROUP_NR)
141 return;
142
140 if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3) 143 if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3)
141 max77693->irq_masks_cur[irq_data->group] &= ~irq_data->mask; 144 max77693->irq_masks_cur[irq_data->group] &= ~irq_data->mask;
142 else 145 else
@@ -149,6 +152,9 @@ static void max77693_irq_unmask(struct irq_data *data)
149 const struct max77693_irq_data *irq_data = 152 const struct max77693_irq_data *irq_data =
150 irq_to_max77693_irq(max77693, data->irq); 153 irq_to_max77693_irq(max77693, data->irq);
151 154
155 if (irq_data->group >= MAX77693_IRQ_GROUP_NR)
156 return;
157
152 if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3) 158 if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3)
153 max77693->irq_masks_cur[irq_data->group] |= irq_data->mask; 159 max77693->irq_masks_cur[irq_data->group] |= irq_data->mask;
154 else 160 else
@@ -200,7 +206,7 @@ static irqreturn_t max77693_irq_thread(int irq, void *data)
200 206
201 if (irq_src & MAX77693_IRQSRC_MUIC) 207 if (irq_src & MAX77693_IRQSRC_MUIC)
202 /* MUIC INT1 ~ INT3 */ 208 /* MUIC INT1 ~ INT3 */
203 max77693_bulk_read(max77693->regmap, MAX77693_MUIC_REG_INT1, 209 max77693_bulk_read(max77693->regmap_muic, MAX77693_MUIC_REG_INT1,
204 MAX77693_NUM_IRQ_MUIC_REGS, &irq_reg[MUIC_INT1]); 210 MAX77693_NUM_IRQ_MUIC_REGS, &irq_reg[MUIC_INT1]);
205 211
206 /* Apply masking */ 212 /* Apply masking */
@@ -255,7 +261,8 @@ int max77693_irq_init(struct max77693_dev *max77693)
255{ 261{
256 struct irq_domain *domain; 262 struct irq_domain *domain;
257 int i; 263 int i;
258 int ret; 264 int ret = 0;
265 u8 intsrc_mask;
259 266
260 mutex_init(&max77693->irqlock); 267 mutex_init(&max77693->irqlock);
261 268
@@ -287,19 +294,38 @@ int max77693_irq_init(struct max77693_dev *max77693)
287 &max77693_irq_domain_ops, max77693); 294 &max77693_irq_domain_ops, max77693);
288 if (!domain) { 295 if (!domain) {
289 dev_err(max77693->dev, "could not create irq domain\n"); 296 dev_err(max77693->dev, "could not create irq domain\n");
290 return -ENODEV; 297 ret = -ENODEV;
298 goto err_irq;
291 } 299 }
292 max77693->irq_domain = domain; 300 max77693->irq_domain = domain;
293 301
302 /* Unmask max77693 interrupt */
303 ret = max77693_read_reg(max77693->regmap,
304 MAX77693_PMIC_REG_INTSRC_MASK, &intsrc_mask);
305 if (ret < 0) {
306 dev_err(max77693->dev, "fail to read PMIC register\n");
307 goto err_irq;
308 }
309
310 intsrc_mask &= ~(MAX77693_IRQSRC_CHG);
311 intsrc_mask &= ~(MAX77693_IRQSRC_FLASH);
312 intsrc_mask &= ~(MAX77693_IRQSRC_MUIC);
313 ret = max77693_write_reg(max77693->regmap,
314 MAX77693_PMIC_REG_INTSRC_MASK, intsrc_mask);
315 if (ret < 0) {
316 dev_err(max77693->dev, "fail to write PMIC register\n");
317 goto err_irq;
318 }
319
294 ret = request_threaded_irq(max77693->irq, NULL, max77693_irq_thread, 320 ret = request_threaded_irq(max77693->irq, NULL, max77693_irq_thread,
295 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 321 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
296 "max77693-irq", max77693); 322 "max77693-irq", max77693);
297
298 if (ret) 323 if (ret)
299 dev_err(max77693->dev, "Failed to request IRQ %d: %d\n", 324 dev_err(max77693->dev, "Failed to request IRQ %d: %d\n",
300 max77693->irq, ret); 325 max77693->irq, ret);
301 326
302 return 0; 327err_irq:
328 return ret;
303} 329}
304 330
305void max77693_irq_exit(struct max77693_dev *max77693) 331void max77693_irq_exit(struct max77693_dev *max77693)
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index a1811cb50ec7..cc5155e20494 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -152,6 +152,20 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
152 max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); 152 max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
153 i2c_set_clientdata(max77693->haptic, max77693); 153 i2c_set_clientdata(max77693->haptic, max77693);
154 154
155 /*
156 * Initialize register map for MUIC device because use regmap-muic
157 * instance of MUIC device when irq of max77693 is initialized
158 * before call max77693-muic probe() function.
159 */
160 max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic,
161 &max77693_regmap_config);
162 if (IS_ERR(max77693->regmap_muic)) {
163 ret = PTR_ERR(max77693->regmap_muic);
164 dev_err(max77693->dev,
165 "failed to allocate register map: %d\n", ret);
166 goto err_regmap;
167 }
168
155 ret = max77693_irq_init(max77693); 169 ret = max77693_irq_init(max77693);
156 if (ret < 0) 170 if (ret < 0)
157 goto err_irq; 171 goto err_irq;
@@ -159,7 +173,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
159 pm_runtime_set_active(max77693->dev); 173 pm_runtime_set_active(max77693->dev);
160 174
161 ret = mfd_add_devices(max77693->dev, -1, max77693_devs, 175 ret = mfd_add_devices(max77693->dev, -1, max77693_devs,
162 ARRAY_SIZE(max77693_devs), NULL, 0); 176 ARRAY_SIZE(max77693_devs), NULL, 0, NULL);
163 if (ret < 0) 177 if (ret < 0)
164 goto err_mfd; 178 goto err_mfd;
165 179
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index 825a7f06d9ba..ee53757beca7 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -598,7 +598,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
598 598
599 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 599 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
600 ARRAY_SIZE(rtc_devs), 600 ARRAY_SIZE(rtc_devs),
601 &rtc_resources[0], chip->irq_base); 601 &rtc_resources[0], chip->irq_base, NULL);
602 if (ret < 0) { 602 if (ret < 0) {
603 dev_err(chip->dev, "Failed to add rtc subdev\n"); 603 dev_err(chip->dev, "Failed to add rtc subdev\n");
604 goto out; 604 goto out;
@@ -606,7 +606,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
606 606
607 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0], 607 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
608 ARRAY_SIZE(onkey_devs), 608 ARRAY_SIZE(onkey_devs),
609 &onkey_resources[0], 0); 609 &onkey_resources[0], 0, NULL);
610 if (ret < 0) { 610 if (ret < 0) {
611 dev_err(chip->dev, "Failed to add onkey subdev\n"); 611 dev_err(chip->dev, "Failed to add onkey subdev\n");
612 goto out_dev; 612 goto out_dev;
@@ -615,7 +615,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
615 if (pdata) { 615 if (pdata) {
616 ret = mfd_add_devices(chip->dev, 0, &regulator_devs[0], 616 ret = mfd_add_devices(chip->dev, 0, &regulator_devs[0],
617 ARRAY_SIZE(regulator_devs), 617 ARRAY_SIZE(regulator_devs),
618 &regulator_resources[0], 0); 618 &regulator_resources[0], 0, NULL);
619 if (ret < 0) { 619 if (ret < 0) {
620 dev_err(chip->dev, "Failed to add regulator subdev\n"); 620 dev_err(chip->dev, "Failed to add regulator subdev\n");
621 goto out_dev; 621 goto out_dev;
@@ -625,7 +625,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
625 if (pdata && pdata->backlight) { 625 if (pdata && pdata->backlight) {
626 ret = mfd_add_devices(chip->dev, 0, &backlight_devs[0], 626 ret = mfd_add_devices(chip->dev, 0, &backlight_devs[0],
627 ARRAY_SIZE(backlight_devs), 627 ARRAY_SIZE(backlight_devs),
628 &backlight_resources[0], 0); 628 &backlight_resources[0], 0, NULL);
629 if (ret < 0) { 629 if (ret < 0) {
630 dev_err(chip->dev, "Failed to add backlight subdev\n"); 630 dev_err(chip->dev, "Failed to add backlight subdev\n");
631 goto out_dev; 631 goto out_dev;
@@ -635,7 +635,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
635 if (pdata && pdata->power) { 635 if (pdata && pdata->power) {
636 ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 636 ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
637 ARRAY_SIZE(power_devs), 637 ARRAY_SIZE(power_devs),
638 &power_supply_resources[0], 0); 638 &power_supply_resources[0], 0, NULL);
639 if (ret < 0) { 639 if (ret < 0) {
640 dev_err(chip->dev, "Failed to add power supply " 640 dev_err(chip->dev, "Failed to add power supply "
641 "subdev\n"); 641 "subdev\n");
@@ -646,7 +646,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
646 if (pdata && pdata->touch) { 646 if (pdata && pdata->touch) {
647 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0], 647 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
648 ARRAY_SIZE(touch_devs), 648 ARRAY_SIZE(touch_devs),
649 &touch_resources[0], 0); 649 &touch_resources[0], 0, NULL);
650 if (ret < 0) { 650 if (ret < 0) {
651 dev_err(chip->dev, "Failed to add touch subdev\n"); 651 dev_err(chip->dev, "Failed to add touch subdev\n");
652 goto out_dev; 652 goto out_dev;
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 10b629c245b6..f123517065ec 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -160,7 +160,7 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
160 160
161 mfd_add_devices(max8997->dev, -1, max8997_devs, 161 mfd_add_devices(max8997->dev, -1, max8997_devs,
162 ARRAY_SIZE(max8997_devs), 162 ARRAY_SIZE(max8997_devs),
163 NULL, 0); 163 NULL, 0, NULL);
164 164
165 /* 165 /*
166 * TODO: enable others (flash, muic, rtc, battery, ...) and 166 * TODO: enable others (flash, muic, rtc, battery, ...) and
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index 6ef56d28c056..d7218cc90945 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -161,13 +161,13 @@ static int max8998_i2c_probe(struct i2c_client *i2c,
161 switch (id->driver_data) { 161 switch (id->driver_data) {
162 case TYPE_LP3974: 162 case TYPE_LP3974:
163 ret = mfd_add_devices(max8998->dev, -1, 163 ret = mfd_add_devices(max8998->dev, -1,
164 lp3974_devs, ARRAY_SIZE(lp3974_devs), 164 lp3974_devs, ARRAY_SIZE(lp3974_devs),
165 NULL, 0); 165 NULL, 0, NULL);
166 break; 166 break;
167 case TYPE_MAX8998: 167 case TYPE_MAX8998:
168 ret = mfd_add_devices(max8998->dev, -1, 168 ret = mfd_add_devices(max8998->dev, -1,
169 max8998_devs, ARRAY_SIZE(max8998_devs), 169 max8998_devs, ARRAY_SIZE(max8998_devs),
170 NULL, 0); 170 NULL, 0, NULL);
171 break; 171 break;
172 default: 172 default:
173 ret = -EINVAL; 173 ret = -EINVAL;
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index b801dc72f041..1ec79b54bd2f 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -612,7 +612,7 @@ static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
612 if (!cell.name) 612 if (!cell.name)
613 return -ENOMEM; 613 return -ENOMEM;
614 614
615 return mfd_add_devices(mc13xxx->dev, -1, &cell, 1, NULL, 0); 615 return mfd_add_devices(mc13xxx->dev, -1, &cell, 1, NULL, 0, NULL);
616} 616}
617 617
618static int mc13xxx_add_subdevice(struct mc13xxx *mc13xxx, const char *format) 618static int mc13xxx_add_subdevice(struct mc13xxx *mc13xxx, const char *format)
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 0c3a01cde2f7..f8b77711ad2d 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -74,12 +74,11 @@ static int mfd_platform_add_cell(struct platform_device *pdev,
74static int mfd_add_device(struct device *parent, int id, 74static int mfd_add_device(struct device *parent, int id,
75 const struct mfd_cell *cell, 75 const struct mfd_cell *cell,
76 struct resource *mem_base, 76 struct resource *mem_base,
77 int irq_base) 77 int irq_base, struct irq_domain *domain)
78{ 78{
79 struct resource *res; 79 struct resource *res;
80 struct platform_device *pdev; 80 struct platform_device *pdev;
81 struct device_node *np = NULL; 81 struct device_node *np = NULL;
82 struct irq_domain *domain = NULL;
83 int ret = -ENOMEM; 82 int ret = -ENOMEM;
84 int r; 83 int r;
85 84
@@ -97,7 +96,6 @@ static int mfd_add_device(struct device *parent, int id,
97 for_each_child_of_node(parent->of_node, np) { 96 for_each_child_of_node(parent->of_node, np) {
98 if (of_device_is_compatible(np, cell->of_compatible)) { 97 if (of_device_is_compatible(np, cell->of_compatible)) {
99 pdev->dev.of_node = np; 98 pdev->dev.of_node = np;
100 domain = irq_find_host(parent->of_node);
101 break; 99 break;
102 } 100 }
103 } 101 }
@@ -177,7 +175,7 @@ fail_alloc:
177int mfd_add_devices(struct device *parent, int id, 175int mfd_add_devices(struct device *parent, int id,
178 struct mfd_cell *cells, int n_devs, 176 struct mfd_cell *cells, int n_devs,
179 struct resource *mem_base, 177 struct resource *mem_base,
180 int irq_base) 178 int irq_base, struct irq_domain *domain)
181{ 179{
182 int i; 180 int i;
183 int ret = 0; 181 int ret = 0;
@@ -191,7 +189,8 @@ int mfd_add_devices(struct device *parent, int id,
191 for (i = 0; i < n_devs; i++) { 189 for (i = 0; i < n_devs; i++) {
192 atomic_set(&cnts[i], 0); 190 atomic_set(&cnts[i], 0);
193 cells[i].usage_count = &cnts[i]; 191 cells[i].usage_count = &cnts[i];
194 ret = mfd_add_device(parent, id, cells + i, mem_base, irq_base); 192 ret = mfd_add_device(parent, id, cells + i, mem_base,
193 irq_base, domain);
195 if (ret) 194 if (ret)
196 break; 195 break;
197 } 196 }
@@ -247,7 +246,8 @@ int mfd_clone_cell(const char *cell, const char **clones, size_t n_clones)
247 for (i = 0; i < n_clones; i++) { 246 for (i = 0; i < n_clones; i++) {
248 cell_entry.name = clones[i]; 247 cell_entry.name = clones[i];
249 /* don't give up if a single call fails; just report error */ 248 /* don't give up if a single call fails; just report error */
250 if (mfd_add_device(pdev->dev.parent, -1, &cell_entry, NULL, 0)) 249 if (mfd_add_device(pdev->dev.parent, -1, &cell_entry, NULL, 0,
250 NULL))
251 dev_err(dev, "failed to create platform device '%s'\n", 251 dev_err(dev, "failed to create platform device '%s'\n",
252 clones[i]); 252 clones[i]);
253 } 253 }
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index c4a69f193a1d..a345f9bb7b47 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -453,7 +453,8 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
453 453
454 ret = mfd_add_devices(palmas->dev, -1, 454 ret = mfd_add_devices(palmas->dev, -1,
455 children, ARRAY_SIZE(palmas_children), 455 children, ARRAY_SIZE(palmas_children),
456 NULL, regmap_irq_chip_get_base(palmas->irq_data)); 456 NULL, regmap_irq_chip_get_base(palmas->irq_data),
457 NULL);
457 kfree(children); 458 kfree(children);
458 459
459 if (ret < 0) 460 if (ret < 0)
diff --git a/drivers/mfd/rc5t583.c b/drivers/mfd/rc5t583.c
index cdc1df7fa0e9..3a8fa88567b1 100644
--- a/drivers/mfd/rc5t583.c
+++ b/drivers/mfd/rc5t583.c
@@ -289,7 +289,7 @@ static int __devinit rc5t583_i2c_probe(struct i2c_client *i2c,
289 } 289 }
290 290
291 ret = mfd_add_devices(rc5t583->dev, -1, rc5t583_subdevs, 291 ret = mfd_add_devices(rc5t583->dev, -1, rc5t583_subdevs,
292 ARRAY_SIZE(rc5t583_subdevs), NULL, 0); 292 ARRAY_SIZE(rc5t583_subdevs), NULL, 0, NULL);
293 if (ret) { 293 if (ret) {
294 dev_err(&i2c->dev, "add mfd devices failed: %d\n", ret); 294 dev_err(&i2c->dev, "add mfd devices failed: %d\n", ret);
295 goto err_add_devs; 295 goto err_add_devs;
diff --git a/drivers/mfd/rdc321x-southbridge.c b/drivers/mfd/rdc321x-southbridge.c
index 685d61e431ad..0f70dce61160 100644
--- a/drivers/mfd/rdc321x-southbridge.c
+++ b/drivers/mfd/rdc321x-southbridge.c
@@ -87,7 +87,8 @@ static int __devinit rdc321x_sb_probe(struct pci_dev *pdev,
87 rdc321x_wdt_pdata.sb_pdev = pdev; 87 rdc321x_wdt_pdata.sb_pdev = pdev;
88 88
89 return mfd_add_devices(&pdev->dev, -1, 89 return mfd_add_devices(&pdev->dev, -1,
90 rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells), NULL, 0); 90 rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells),
91 NULL, 0, NULL);
91} 92}
92 93
93static void __devexit rdc321x_sb_remove(struct pci_dev *pdev) 94static void __devexit rdc321x_sb_remove(struct pci_dev *pdev)
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index 2988efde11eb..49d361a618d0 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -141,19 +141,19 @@ static int sec_pmic_probe(struct i2c_client *i2c,
141 switch (sec_pmic->device_type) { 141 switch (sec_pmic->device_type) {
142 case S5M8751X: 142 case S5M8751X:
143 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8751_devs, 143 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8751_devs,
144 ARRAY_SIZE(s5m8751_devs), NULL, 0); 144 ARRAY_SIZE(s5m8751_devs), NULL, 0, NULL);
145 break; 145 break;
146 case S5M8763X: 146 case S5M8763X:
147 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8763_devs, 147 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8763_devs,
148 ARRAY_SIZE(s5m8763_devs), NULL, 0); 148 ARRAY_SIZE(s5m8763_devs), NULL, 0, NULL);
149 break; 149 break;
150 case S5M8767X: 150 case S5M8767X:
151 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8767_devs, 151 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8767_devs,
152 ARRAY_SIZE(s5m8767_devs), NULL, 0); 152 ARRAY_SIZE(s5m8767_devs), NULL, 0, NULL);
153 break; 153 break;
154 case S2MPS11X: 154 case S2MPS11X:
155 ret = mfd_add_devices(sec_pmic->dev, -1, s2mps11_devs, 155 ret = mfd_add_devices(sec_pmic->dev, -1, s2mps11_devs,
156 ARRAY_SIZE(s2mps11_devs), NULL, 0); 156 ARRAY_SIZE(s2mps11_devs), NULL, 0, NULL);
157 break; 157 break;
158 default: 158 default:
159 /* If this happens the probe function is problem */ 159 /* If this happens the probe function is problem */
diff --git a/drivers/mfd/sta2x11-mfd.c b/drivers/mfd/sta2x11-mfd.c
index d31fed07aefb..d35da6820bea 100644
--- a/drivers/mfd/sta2x11-mfd.c
+++ b/drivers/mfd/sta2x11-mfd.c
@@ -407,7 +407,7 @@ static int __devinit sta2x11_mfd_probe(struct pci_dev *pdev,
407 sta2x11_mfd_bar0, 407 sta2x11_mfd_bar0,
408 ARRAY_SIZE(sta2x11_mfd_bar0), 408 ARRAY_SIZE(sta2x11_mfd_bar0),
409 &pdev->resource[0], 409 &pdev->resource[0],
410 0); 410 0, NULL);
411 if (err) { 411 if (err) {
412 dev_err(&pdev->dev, "mfd_add_devices[0] failed: %d\n", err); 412 dev_err(&pdev->dev, "mfd_add_devices[0] failed: %d\n", err);
413 goto err_disable; 413 goto err_disable;
@@ -417,7 +417,7 @@ static int __devinit sta2x11_mfd_probe(struct pci_dev *pdev,
417 sta2x11_mfd_bar1, 417 sta2x11_mfd_bar1,
418 ARRAY_SIZE(sta2x11_mfd_bar1), 418 ARRAY_SIZE(sta2x11_mfd_bar1),
419 &pdev->resource[1], 419 &pdev->resource[1],
420 0); 420 0, NULL);
421 if (err) { 421 if (err) {
422 dev_err(&pdev->dev, "mfd_add_devices[1] failed: %d\n", err); 422 dev_err(&pdev->dev, "mfd_add_devices[1] failed: %d\n", err);
423 goto err_disable; 423 goto err_disable;
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 2dd8d49cb30b..c94f521f392c 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -962,7 +962,7 @@ static int __devinit stmpe_add_device(struct stmpe *stmpe,
962 struct mfd_cell *cell, int irq) 962 struct mfd_cell *cell, int irq)
963{ 963{
964 return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1, 964 return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1,
965 NULL, stmpe->irq_base + irq); 965 NULL, stmpe->irq_base + irq, NULL);
966} 966}
967 967
968static int __devinit stmpe_devices_init(struct stmpe *stmpe) 968static int __devinit stmpe_devices_init(struct stmpe *stmpe)
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
index 2d9e8799e733..b32940ec9034 100644
--- a/drivers/mfd/t7l66xb.c
+++ b/drivers/mfd/t7l66xb.c
@@ -388,7 +388,7 @@ static int t7l66xb_probe(struct platform_device *dev)
388 388
389 ret = mfd_add_devices(&dev->dev, dev->id, 389 ret = mfd_add_devices(&dev->dev, dev->id,
390 t7l66xb_cells, ARRAY_SIZE(t7l66xb_cells), 390 t7l66xb_cells, ARRAY_SIZE(t7l66xb_cells),
391 iomem, t7l66xb->irq_base); 391 iomem, t7l66xb->irq_base, NULL);
392 392
393 if (!ret) 393 if (!ret)
394 return 0; 394 return 0;
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index 048bf0532a09..b56ba6b43294 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -262,8 +262,8 @@ static int __devinit tc3589x_device_init(struct tc3589x *tc3589x)
262 262
263 if (blocks & TC3589x_BLOCK_GPIO) { 263 if (blocks & TC3589x_BLOCK_GPIO) {
264 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio, 264 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio,
265 ARRAY_SIZE(tc3589x_dev_gpio), NULL, 265 ARRAY_SIZE(tc3589x_dev_gpio), NULL,
266 tc3589x->irq_base); 266 tc3589x->irq_base, NULL);
267 if (ret) { 267 if (ret) {
268 dev_err(tc3589x->dev, "failed to add gpio child\n"); 268 dev_err(tc3589x->dev, "failed to add gpio child\n");
269 return ret; 269 return ret;
@@ -273,8 +273,8 @@ static int __devinit tc3589x_device_init(struct tc3589x *tc3589x)
273 273
274 if (blocks & TC3589x_BLOCK_KEYPAD) { 274 if (blocks & TC3589x_BLOCK_KEYPAD) {
275 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad, 275 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad,
276 ARRAY_SIZE(tc3589x_dev_keypad), NULL, 276 ARRAY_SIZE(tc3589x_dev_keypad), NULL,
277 tc3589x->irq_base); 277 tc3589x->irq_base, NULL);
278 if (ret) { 278 if (ret) {
279 dev_err(tc3589x->dev, "failed to keypad child\n"); 279 dev_err(tc3589x->dev, "failed to keypad child\n");
280 return ret; 280 return ret;
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c
index d20a284ad4ba..413c891102f8 100644
--- a/drivers/mfd/tc6387xb.c
+++ b/drivers/mfd/tc6387xb.c
@@ -192,7 +192,7 @@ static int __devinit tc6387xb_probe(struct platform_device *dev)
192 printk(KERN_INFO "Toshiba tc6387xb initialised\n"); 192 printk(KERN_INFO "Toshiba tc6387xb initialised\n");
193 193
194 ret = mfd_add_devices(&dev->dev, dev->id, tc6387xb_cells, 194 ret = mfd_add_devices(&dev->dev, dev->id, tc6387xb_cells,
195 ARRAY_SIZE(tc6387xb_cells), iomem, irq); 195 ARRAY_SIZE(tc6387xb_cells), iomem, irq, NULL);
196 196
197 if (!ret) 197 if (!ret)
198 return 0; 198 return 0;
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c
index 9612264f0e6d..dcab026fcbb2 100644
--- a/drivers/mfd/tc6393xb.c
+++ b/drivers/mfd/tc6393xb.c
@@ -700,8 +700,8 @@ static int __devinit tc6393xb_probe(struct platform_device *dev)
700 tc6393xb_cells[TC6393XB_CELL_FB].pdata_size = sizeof(*tcpd->fb_data); 700 tc6393xb_cells[TC6393XB_CELL_FB].pdata_size = sizeof(*tcpd->fb_data);
701 701
702 ret = mfd_add_devices(&dev->dev, dev->id, 702 ret = mfd_add_devices(&dev->dev, dev->id,
703 tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells), 703 tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells),
704 iomem, tcpd->irq_base); 704 iomem, tcpd->irq_base, NULL);
705 705
706 if (!ret) 706 if (!ret)
707 return 0; 707 return 0;
diff --git a/drivers/mfd/ti-ssp.c b/drivers/mfd/ti-ssp.c
index 4fb0e6c8e8fe..7c3675a74f93 100644
--- a/drivers/mfd/ti-ssp.c
+++ b/drivers/mfd/ti-ssp.c
@@ -412,7 +412,7 @@ static int __devinit ti_ssp_probe(struct platform_device *pdev)
412 cells[id].data_size = data->pdata_size; 412 cells[id].data_size = data->pdata_size;
413 } 413 }
414 414
415 error = mfd_add_devices(dev, 0, cells, 2, NULL, 0); 415 error = mfd_add_devices(dev, 0, cells, 2, NULL, 0, NULL);
416 if (error < 0) { 416 if (error < 0) {
417 dev_err(dev, "cannot add mfd cells\n"); 417 dev_err(dev, "cannot add mfd cells\n");
418 goto error_enable; 418 goto error_enable;
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c
index a447f4ec11fb..cccc626c83c8 100644
--- a/drivers/mfd/timberdale.c
+++ b/drivers/mfd/timberdale.c
@@ -757,25 +757,25 @@ static int __devinit timb_probe(struct pci_dev *dev,
757 err = mfd_add_devices(&dev->dev, -1, 757 err = mfd_add_devices(&dev->dev, -1,
758 timberdale_cells_bar0_cfg0, 758 timberdale_cells_bar0_cfg0,
759 ARRAY_SIZE(timberdale_cells_bar0_cfg0), 759 ARRAY_SIZE(timberdale_cells_bar0_cfg0),
760 &dev->resource[0], msix_entries[0].vector); 760 &dev->resource[0], msix_entries[0].vector, NULL);
761 break; 761 break;
762 case TIMB_HW_VER1: 762 case TIMB_HW_VER1:
763 err = mfd_add_devices(&dev->dev, -1, 763 err = mfd_add_devices(&dev->dev, -1,
764 timberdale_cells_bar0_cfg1, 764 timberdale_cells_bar0_cfg1,
765 ARRAY_SIZE(timberdale_cells_bar0_cfg1), 765 ARRAY_SIZE(timberdale_cells_bar0_cfg1),
766 &dev->resource[0], msix_entries[0].vector); 766 &dev->resource[0], msix_entries[0].vector, NULL);
767 break; 767 break;
768 case TIMB_HW_VER2: 768 case TIMB_HW_VER2:
769 err = mfd_add_devices(&dev->dev, -1, 769 err = mfd_add_devices(&dev->dev, -1,
770 timberdale_cells_bar0_cfg2, 770 timberdale_cells_bar0_cfg2,
771 ARRAY_SIZE(timberdale_cells_bar0_cfg2), 771 ARRAY_SIZE(timberdale_cells_bar0_cfg2),
772 &dev->resource[0], msix_entries[0].vector); 772 &dev->resource[0], msix_entries[0].vector, NULL);
773 break; 773 break;
774 case TIMB_HW_VER3: 774 case TIMB_HW_VER3:
775 err = mfd_add_devices(&dev->dev, -1, 775 err = mfd_add_devices(&dev->dev, -1,
776 timberdale_cells_bar0_cfg3, 776 timberdale_cells_bar0_cfg3,
777 ARRAY_SIZE(timberdale_cells_bar0_cfg3), 777 ARRAY_SIZE(timberdale_cells_bar0_cfg3),
778 &dev->resource[0], msix_entries[0].vector); 778 &dev->resource[0], msix_entries[0].vector, NULL);
779 break; 779 break;
780 default: 780 default:
781 dev_err(&dev->dev, "Uknown IP setup: %d.%d.%d\n", 781 dev_err(&dev->dev, "Uknown IP setup: %d.%d.%d\n",
@@ -792,7 +792,7 @@ static int __devinit timb_probe(struct pci_dev *dev,
792 792
793 err = mfd_add_devices(&dev->dev, 0, 793 err = mfd_add_devices(&dev->dev, 0,
794 timberdale_cells_bar1, ARRAY_SIZE(timberdale_cells_bar1), 794 timberdale_cells_bar1, ARRAY_SIZE(timberdale_cells_bar1),
795 &dev->resource[1], msix_entries[0].vector); 795 &dev->resource[1], msix_entries[0].vector, NULL);
796 if (err) { 796 if (err) {
797 dev_err(&dev->dev, "mfd_add_devices failed: %d\n", err); 797 dev_err(&dev->dev, "mfd_add_devices failed: %d\n", err);
798 goto err_mfd2; 798 goto err_mfd2;
@@ -803,7 +803,7 @@ static int __devinit timb_probe(struct pci_dev *dev,
803 ((priv->fw.config & TIMB_HW_VER_MASK) == TIMB_HW_VER3)) { 803 ((priv->fw.config & TIMB_HW_VER_MASK) == TIMB_HW_VER3)) {
804 err = mfd_add_devices(&dev->dev, 1, timberdale_cells_bar2, 804 err = mfd_add_devices(&dev->dev, 1, timberdale_cells_bar2,
805 ARRAY_SIZE(timberdale_cells_bar2), 805 ARRAY_SIZE(timberdale_cells_bar2),
806 &dev->resource[2], msix_entries[0].vector); 806 &dev->resource[2], msix_entries[0].vector, NULL);
807 if (err) { 807 if (err) {
808 dev_err(&dev->dev, "mfd_add_devices failed: %d\n", err); 808 dev_err(&dev->dev, "mfd_add_devices failed: %d\n", err);
809 goto err_mfd2; 809 goto err_mfd2;
diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c
index a293b978e27c..14051bdc714b 100644
--- a/drivers/mfd/tps6105x.c
+++ b/drivers/mfd/tps6105x.c
@@ -188,7 +188,7 @@ static int __devinit tps6105x_probe(struct i2c_client *client,
188 } 188 }
189 189
190 ret = mfd_add_devices(&client->dev, 0, tps6105x_cells, 190 ret = mfd_add_devices(&client->dev, 0, tps6105x_cells,
191 ARRAY_SIZE(tps6105x_cells), NULL, 0); 191 ARRAY_SIZE(tps6105x_cells), NULL, 0, NULL);
192 if (ret) 192 if (ret)
193 goto fail; 193 goto fail;
194 194
diff --git a/drivers/mfd/tps6507x.c b/drivers/mfd/tps6507x.c
index 33ba7723c967..1b203499c744 100644
--- a/drivers/mfd/tps6507x.c
+++ b/drivers/mfd/tps6507x.c
@@ -100,7 +100,7 @@ static int tps6507x_i2c_probe(struct i2c_client *i2c,
100 100
101 ret = mfd_add_devices(tps6507x->dev, -1, 101 ret = mfd_add_devices(tps6507x->dev, -1,
102 tps6507x_devs, ARRAY_SIZE(tps6507x_devs), 102 tps6507x_devs, ARRAY_SIZE(tps6507x_devs),
103 NULL, 0); 103 NULL, 0, NULL);
104 104
105 if (ret < 0) 105 if (ret < 0)
106 goto err; 106 goto err;
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index 80e24f4b47bf..50fd87c87a1c 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -292,7 +292,7 @@ static int __devinit tps65090_i2c_probe(struct i2c_client *client,
292 } 292 }
293 293
294 ret = mfd_add_devices(tps65090->dev, -1, tps65090s, 294 ret = mfd_add_devices(tps65090->dev, -1, tps65090s,
295 ARRAY_SIZE(tps65090s), NULL, 0); 295 ARRAY_SIZE(tps65090s), NULL, 0, NULL);
296 if (ret) { 296 if (ret) {
297 dev_err(&client->dev, "add mfd devices failed with err: %d\n", 297 dev_err(&client->dev, "add mfd devices failed with err: %d\n",
298 ret); 298 ret);
diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index 61c097a98f5d..a95e9421b735 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -24,11 +24,18 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/regmap.h> 25#include <linux/regmap.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/regulator/of_regulator.h> 27#include <linux/of.h>
28#include <linux/of_device.h>
28 29
29#include <linux/mfd/core.h> 30#include <linux/mfd/core.h>
30#include <linux/mfd/tps65217.h> 31#include <linux/mfd/tps65217.h>
31 32
33static struct mfd_cell tps65217s[] = {
34 {
35 .name = "tps65217-pmic",
36 },
37};
38
32/** 39/**
33 * tps65217_reg_read: Read a single tps65217 register. 40 * tps65217_reg_read: Read a single tps65217 register.
34 * 41 *
@@ -133,83 +140,48 @@ int tps65217_clear_bits(struct tps65217 *tps, unsigned int reg,
133} 140}
134EXPORT_SYMBOL_GPL(tps65217_clear_bits); 141EXPORT_SYMBOL_GPL(tps65217_clear_bits);
135 142
136#ifdef CONFIG_OF
137static struct of_regulator_match reg_matches[] = {
138 { .name = "dcdc1", .driver_data = (void *)TPS65217_DCDC_1 },
139 { .name = "dcdc2", .driver_data = (void *)TPS65217_DCDC_2 },
140 { .name = "dcdc3", .driver_data = (void *)TPS65217_DCDC_3 },
141 { .name = "ldo1", .driver_data = (void *)TPS65217_LDO_1 },
142 { .name = "ldo2", .driver_data = (void *)TPS65217_LDO_2 },
143 { .name = "ldo3", .driver_data = (void *)TPS65217_LDO_3 },
144 { .name = "ldo4", .driver_data = (void *)TPS65217_LDO_4 },
145};
146
147static struct tps65217_board *tps65217_parse_dt(struct i2c_client *client)
148{
149 struct device_node *node = client->dev.of_node;
150 struct tps65217_board *pdata;
151 struct device_node *regs;
152 int count = ARRAY_SIZE(reg_matches);
153 int ret, i;
154
155 regs = of_find_node_by_name(node, "regulators");
156 if (!regs)
157 return NULL;
158
159 ret = of_regulator_match(&client->dev, regs, reg_matches, count);
160 of_node_put(regs);
161 if ((ret < 0) || (ret > count))
162 return NULL;
163
164 count = ret;
165 pdata = devm_kzalloc(&client->dev, count * sizeof(*pdata), GFP_KERNEL);
166 if (!pdata)
167 return NULL;
168
169 for (i = 0; i < count; i++) {
170 if (!reg_matches[i].init_data || !reg_matches[i].of_node)
171 continue;
172
173 pdata->tps65217_init_data[i] = reg_matches[i].init_data;
174 pdata->of_node[i] = reg_matches[i].of_node;
175 }
176
177 return pdata;
178}
179
180static struct of_device_id tps65217_of_match[] = {
181 { .compatible = "ti,tps65217", },
182 { },
183};
184#else
185static struct tps65217_board *tps65217_parse_dt(struct i2c_client *client)
186{
187 return NULL;
188}
189#endif
190
191static struct regmap_config tps65217_regmap_config = { 143static struct regmap_config tps65217_regmap_config = {
192 .reg_bits = 8, 144 .reg_bits = 8,
193 .val_bits = 8, 145 .val_bits = 8,
194}; 146};
195 147
148static const struct of_device_id tps65217_of_match[] = {
149 { .compatible = "ti,tps65217", .data = (void *)TPS65217 },
150 { /* sentinel */ },
151};
152
196static int __devinit tps65217_probe(struct i2c_client *client, 153static int __devinit tps65217_probe(struct i2c_client *client,
197 const struct i2c_device_id *ids) 154 const struct i2c_device_id *ids)
198{ 155{
199 struct tps65217 *tps; 156 struct tps65217 *tps;
200 struct regulator_init_data *reg_data;
201 struct tps65217_board *pdata = client->dev.platform_data;
202 int i, ret;
203 unsigned int version; 157 unsigned int version;
158 unsigned int chip_id = ids->driver_data;
159 const struct of_device_id *match;
160 int ret;
204 161
205 if (!pdata && client->dev.of_node) 162 if (client->dev.of_node) {
206 pdata = tps65217_parse_dt(client); 163 match = of_match_device(tps65217_of_match, &client->dev);
164 if (!match) {
165 dev_err(&client->dev,
166 "Failed to find matching dt id\n");
167 return -EINVAL;
168 }
169 chip_id = (unsigned int)match->data;
170 }
171
172 if (!chip_id) {
173 dev_err(&client->dev, "id is null.\n");
174 return -ENODEV;
175 }
207 176
208 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 177 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
209 if (!tps) 178 if (!tps)
210 return -ENOMEM; 179 return -ENOMEM;
211 180
212 tps->pdata = pdata; 181 i2c_set_clientdata(client, tps);
182 tps->dev = &client->dev;
183 tps->id = chip_id;
184
213 tps->regmap = devm_regmap_init_i2c(client, &tps65217_regmap_config); 185 tps->regmap = devm_regmap_init_i2c(client, &tps65217_regmap_config);
214 if (IS_ERR(tps->regmap)) { 186 if (IS_ERR(tps->regmap)) {
215 ret = PTR_ERR(tps->regmap); 187 ret = PTR_ERR(tps->regmap);
@@ -218,8 +190,12 @@ static int __devinit tps65217_probe(struct i2c_client *client,
218 return ret; 190 return ret;
219 } 191 }
220 192
221 i2c_set_clientdata(client, tps); 193 ret = mfd_add_devices(tps->dev, -1, tps65217s,
222 tps->dev = &client->dev; 194 ARRAY_SIZE(tps65217s), NULL, 0, NULL);
195 if (ret < 0) {
196 dev_err(tps->dev, "mfd_add_devices failed: %d\n", ret);
197 return ret;
198 }
223 199
224 ret = tps65217_reg_read(tps, TPS65217_REG_CHIPID, &version); 200 ret = tps65217_reg_read(tps, TPS65217_REG_CHIPID, &version);
225 if (ret < 0) { 201 if (ret < 0) {
@@ -232,41 +208,21 @@ static int __devinit tps65217_probe(struct i2c_client *client,
232 (version & TPS65217_CHIPID_CHIP_MASK) >> 4, 208 (version & TPS65217_CHIPID_CHIP_MASK) >> 4,
233 version & TPS65217_CHIPID_REV_MASK); 209 version & TPS65217_CHIPID_REV_MASK);
234 210
235 for (i = 0; i < TPS65217_NUM_REGULATOR; i++) {
236 struct platform_device *pdev;
237
238 pdev = platform_device_alloc("tps65217-pmic", i);
239 if (!pdev) {
240 dev_err(tps->dev, "Cannot create regulator %d\n", i);
241 continue;
242 }
243
244 pdev->dev.parent = tps->dev;
245 pdev->dev.of_node = pdata->of_node[i];
246 reg_data = pdata->tps65217_init_data[i];
247 platform_device_add_data(pdev, reg_data, sizeof(*reg_data));
248 tps->regulator_pdev[i] = pdev;
249
250 platform_device_add(pdev);
251 }
252
253 return 0; 211 return 0;
254} 212}
255 213
256static int __devexit tps65217_remove(struct i2c_client *client) 214static int __devexit tps65217_remove(struct i2c_client *client)
257{ 215{
258 struct tps65217 *tps = i2c_get_clientdata(client); 216 struct tps65217 *tps = i2c_get_clientdata(client);
259 int i;
260 217
261 for (i = 0; i < TPS65217_NUM_REGULATOR; i++) 218 mfd_remove_devices(tps->dev);
262 platform_device_unregister(tps->regulator_pdev[i]);
263 219
264 return 0; 220 return 0;
265} 221}
266 222
267static const struct i2c_device_id tps65217_id_table[] = { 223static const struct i2c_device_id tps65217_id_table[] = {
268 {"tps65217", 0xF0}, 224 {"tps65217", TPS65217},
269 {/* end of list */} 225 { /* sentinel */ }
270}; 226};
271MODULE_DEVICE_TABLE(i2c, tps65217_id_table); 227MODULE_DEVICE_TABLE(i2c, tps65217_id_table);
272 228
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 353c34812120..5f58370ccf55 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -493,7 +493,8 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
493 } 493 }
494 494
495 ret = mfd_add_devices(tps6586x->dev, -1, 495 ret = mfd_add_devices(tps6586x->dev, -1,
496 tps6586x_cell, ARRAY_SIZE(tps6586x_cell), NULL, 0); 496 tps6586x_cell, ARRAY_SIZE(tps6586x_cell),
497 NULL, 0, NULL);
497 if (ret < 0) { 498 if (ret < 0) {
498 dev_err(&client->dev, "mfd_add_devices failed: %d\n", ret); 499 dev_err(&client->dev, "mfd_add_devices failed: %d\n", ret);
499 goto err_mfd_add; 500 goto err_mfd_add;
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 1c563792c777..d3ce4d569deb 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -254,7 +254,7 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
254 254
255 ret = mfd_add_devices(tps65910->dev, -1, 255 ret = mfd_add_devices(tps65910->dev, -1,
256 tps65910s, ARRAY_SIZE(tps65910s), 256 tps65910s, ARRAY_SIZE(tps65910s),
257 NULL, 0); 257 NULL, 0, NULL);
258 if (ret < 0) { 258 if (ret < 0) {
259 dev_err(&i2c->dev, "mfd_add_devices failed: %d\n", ret); 259 dev_err(&i2c->dev, "mfd_add_devices failed: %d\n", ret);
260 return ret; 260 return ret;
diff --git a/drivers/mfd/tps65912-core.c b/drivers/mfd/tps65912-core.c
index 74fd8cb5f372..4658b5bdcd84 100644
--- a/drivers/mfd/tps65912-core.c
+++ b/drivers/mfd/tps65912-core.c
@@ -146,7 +146,7 @@ int tps65912_device_init(struct tps65912 *tps65912)
146 146
147 ret = mfd_add_devices(tps65912->dev, -1, 147 ret = mfd_add_devices(tps65912->dev, -1,
148 tps65912s, ARRAY_SIZE(tps65912s), 148 tps65912s, ARRAY_SIZE(tps65912s),
149 NULL, 0); 149 NULL, 0, NULL);
150 if (ret < 0) 150 if (ret < 0)
151 goto err; 151 goto err;
152 152
diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c
index 838ce4eb444e..77c9acb14583 100644
--- a/drivers/mfd/twl4030-audio.c
+++ b/drivers/mfd/twl4030-audio.c
@@ -223,7 +223,7 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev)
223 223
224 if (childs) 224 if (childs)
225 ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells, 225 ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells,
226 childs, NULL, 0); 226 childs, NULL, 0, NULL);
227 else { 227 else {
228 dev_err(&pdev->dev, "No platform data found for childs\n"); 228 dev_err(&pdev->dev, "No platform data found for childs\n");
229 ret = -ENODEV; 229 ret = -ENODEV;
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index b0fad0ffca56..3dca5c195a20 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -632,7 +632,7 @@ static int __devinit twl6040_probe(struct i2c_client *client,
632 } 632 }
633 633
634 ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, 634 ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children,
635 NULL, 0); 635 NULL, 0, NULL);
636 if (ret) 636 if (ret)
637 goto mfd_err; 637 goto mfd_err;
638 638
diff --git a/drivers/mfd/vx855.c b/drivers/mfd/vx855.c
index 872aff21e4be..b9a636d44c7f 100644
--- a/drivers/mfd/vx855.c
+++ b/drivers/mfd/vx855.c
@@ -102,7 +102,7 @@ static __devinit int vx855_probe(struct pci_dev *pdev,
102 vx855_gpio_resources[1].end = vx855_gpio_resources[1].start + 3; 102 vx855_gpio_resources[1].end = vx855_gpio_resources[1].start + 3;
103 103
104 ret = mfd_add_devices(&pdev->dev, -1, vx855_cells, ARRAY_SIZE(vx855_cells), 104 ret = mfd_add_devices(&pdev->dev, -1, vx855_cells, ARRAY_SIZE(vx855_cells),
105 NULL, 0); 105 NULL, 0, NULL);
106 106
107 /* we always return -ENODEV here in order to enable other 107 /* we always return -ENODEV here in order to enable other
108 * drivers like old, not-yet-platform_device ported i2c-viapro */ 108 * drivers like old, not-yet-platform_device ported i2c-viapro */
diff --git a/drivers/mfd/wl1273-core.c b/drivers/mfd/wl1273-core.c
index f39b756df561..86e0e4309fc2 100644
--- a/drivers/mfd/wl1273-core.c
+++ b/drivers/mfd/wl1273-core.c
@@ -241,7 +241,7 @@ static int __devinit wl1273_core_probe(struct i2c_client *client,
241 __func__, children); 241 __func__, children);
242 242
243 r = mfd_add_devices(&client->dev, -1, core->cells, 243 r = mfd_add_devices(&client->dev, -1, core->cells,
244 children, NULL, 0); 244 children, NULL, 0, NULL);
245 if (r) 245 if (r)
246 goto err; 246 goto err;
247 247
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
index 946698fd2dc6..301731035940 100644
--- a/drivers/mfd/wm831x-core.c
+++ b/drivers/mfd/wm831x-core.c
@@ -1813,27 +1813,27 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1813 case WM8310: 1813 case WM8310:
1814 ret = mfd_add_devices(wm831x->dev, wm831x_num, 1814 ret = mfd_add_devices(wm831x->dev, wm831x_num,
1815 wm8310_devs, ARRAY_SIZE(wm8310_devs), 1815 wm8310_devs, ARRAY_SIZE(wm8310_devs),
1816 NULL, 0); 1816 NULL, 0, NULL);
1817 break; 1817 break;
1818 1818
1819 case WM8311: 1819 case WM8311:
1820 ret = mfd_add_devices(wm831x->dev, wm831x_num, 1820 ret = mfd_add_devices(wm831x->dev, wm831x_num,
1821 wm8311_devs, ARRAY_SIZE(wm8311_devs), 1821 wm8311_devs, ARRAY_SIZE(wm8311_devs),
1822 NULL, 0); 1822 NULL, 0, NULL);
1823 if (!pdata || !pdata->disable_touch) 1823 if (!pdata || !pdata->disable_touch)
1824 mfd_add_devices(wm831x->dev, wm831x_num, 1824 mfd_add_devices(wm831x->dev, wm831x_num,
1825 touch_devs, ARRAY_SIZE(touch_devs), 1825 touch_devs, ARRAY_SIZE(touch_devs),
1826 NULL, 0); 1826 NULL, 0, NULL);
1827 break; 1827 break;
1828 1828
1829 case WM8312: 1829 case WM8312:
1830 ret = mfd_add_devices(wm831x->dev, wm831x_num, 1830 ret = mfd_add_devices(wm831x->dev, wm831x_num,
1831 wm8312_devs, ARRAY_SIZE(wm8312_devs), 1831 wm8312_devs, ARRAY_SIZE(wm8312_devs),
1832 NULL, 0); 1832 NULL, 0, NULL);
1833 if (!pdata || !pdata->disable_touch) 1833 if (!pdata || !pdata->disable_touch)
1834 mfd_add_devices(wm831x->dev, wm831x_num, 1834 mfd_add_devices(wm831x->dev, wm831x_num,
1835 touch_devs, ARRAY_SIZE(touch_devs), 1835 touch_devs, ARRAY_SIZE(touch_devs),
1836 NULL, 0); 1836 NULL, 0, NULL);
1837 break; 1837 break;
1838 1838
1839 case WM8320: 1839 case WM8320:
@@ -1842,7 +1842,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1842 case WM8326: 1842 case WM8326:
1843 ret = mfd_add_devices(wm831x->dev, wm831x_num, 1843 ret = mfd_add_devices(wm831x->dev, wm831x_num,
1844 wm8320_devs, ARRAY_SIZE(wm8320_devs), 1844 wm8320_devs, ARRAY_SIZE(wm8320_devs),
1845 NULL, 0); 1845 NULL, 0, NULL);
1846 break; 1846 break;
1847 1847
1848 default: 1848 default:
@@ -1867,7 +1867,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1867 if (ret & WM831X_XTAL_ENA) { 1867 if (ret & WM831X_XTAL_ENA) {
1868 ret = mfd_add_devices(wm831x->dev, wm831x_num, 1868 ret = mfd_add_devices(wm831x->dev, wm831x_num,
1869 rtc_devs, ARRAY_SIZE(rtc_devs), 1869 rtc_devs, ARRAY_SIZE(rtc_devs),
1870 NULL, 0); 1870 NULL, 0, NULL);
1871 if (ret != 0) { 1871 if (ret != 0) {
1872 dev_err(wm831x->dev, "Failed to add RTC: %d\n", ret); 1872 dev_err(wm831x->dev, "Failed to add RTC: %d\n", ret);
1873 goto err_irq; 1873 goto err_irq;
@@ -1880,7 +1880,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1880 /* Treat errors as non-critical */ 1880 /* Treat errors as non-critical */
1881 ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs, 1881 ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs,
1882 ARRAY_SIZE(backlight_devs), NULL, 1882 ARRAY_SIZE(backlight_devs), NULL,
1883 0); 1883 0, NULL);
1884 if (ret < 0) 1884 if (ret < 0)
1885 dev_err(wm831x->dev, "Failed to add backlight: %d\n", 1885 dev_err(wm831x->dev, "Failed to add backlight: %d\n",
1886 ret); 1886 ret);
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 4b7d378551d5..639ca359242f 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -70,7 +70,7 @@ static int wm8400_register_codec(struct wm8400 *wm8400)
70 .pdata_size = sizeof(*wm8400), 70 .pdata_size = sizeof(*wm8400),
71 }; 71 };
72 72
73 return mfd_add_devices(wm8400->dev, -1, &cell, 1, NULL, 0); 73 return mfd_add_devices(wm8400->dev, -1, &cell, 1, NULL, 0, NULL);
74} 74}
75 75
76/* 76/*
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index eec74aa55fdf..2febf88cfce8 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -414,7 +414,7 @@ static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq)
414 ret = mfd_add_devices(wm8994->dev, -1, 414 ret = mfd_add_devices(wm8994->dev, -1,
415 wm8994_regulator_devs, 415 wm8994_regulator_devs,
416 ARRAY_SIZE(wm8994_regulator_devs), 416 ARRAY_SIZE(wm8994_regulator_devs),
417 NULL, 0); 417 NULL, 0, NULL);
418 if (ret != 0) { 418 if (ret != 0) {
419 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); 419 dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
420 goto err; 420 goto err;
@@ -648,7 +648,7 @@ static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq)
648 648
649 ret = mfd_add_devices(wm8994->dev, -1, 649 ret = mfd_add_devices(wm8994->dev, -1,
650 wm8994_devs, ARRAY_SIZE(wm8994_devs), 650 wm8994_devs, ARRAY_SIZE(wm8994_devs),
651 NULL, 0); 651 NULL, 0, NULL);
652 if (ret != 0) { 652 if (ret != 0) {
653 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); 653 dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
654 goto err_irq; 654 goto err_irq;
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index 98ee43819911..7edadee487ba 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -1391,7 +1391,6 @@ static irqreturn_t ican3_irq(int irq, void *dev_id)
1391 */ 1391 */
1392static int ican3_reset_module(struct ican3_dev *mod) 1392static int ican3_reset_module(struct ican3_dev *mod)
1393{ 1393{
1394 u8 val = 1 << mod->num;
1395 unsigned long start; 1394 unsigned long start;
1396 u8 runold, runnew; 1395 u8 runold, runnew;
1397 1396
@@ -1405,8 +1404,7 @@ static int ican3_reset_module(struct ican3_dev *mod)
1405 runold = ioread8(mod->dpm + TARGET_RUNNING); 1404 runold = ioread8(mod->dpm + TARGET_RUNNING);
1406 1405
1407 /* reset the module */ 1406 /* reset the module */
1408 iowrite8(val, &mod->ctrl->reset_assert); 1407 iowrite8(0x00, &mod->dpmctrl->hwreset);
1409 iowrite8(val, &mod->ctrl->reset_deassert);
1410 1408
1411 /* wait until the module has finished resetting and is running */ 1409 /* wait until the module has finished resetting and is running */
1412 start = jiffies; 1410 start = jiffies;
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index a580db29e503..26e7129332ab 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -83,6 +83,11 @@
83#define INSTRUCTION_LOAD_TXB(n) (0x40 + 2 * (n)) 83#define INSTRUCTION_LOAD_TXB(n) (0x40 + 2 * (n))
84#define INSTRUCTION_READ_RXB(n) (((n) == 0) ? 0x90 : 0x94) 84#define INSTRUCTION_READ_RXB(n) (((n) == 0) ? 0x90 : 0x94)
85#define INSTRUCTION_RESET 0xC0 85#define INSTRUCTION_RESET 0xC0
86#define RTS_TXB0 0x01
87#define RTS_TXB1 0x02
88#define RTS_TXB2 0x04
89#define INSTRUCTION_RTS(n) (0x80 | ((n) & 0x07))
90
86 91
87/* MPC251x registers */ 92/* MPC251x registers */
88#define CANSTAT 0x0e 93#define CANSTAT 0x0e
@@ -397,6 +402,7 @@ static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf,
397static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame, 402static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame,
398 int tx_buf_idx) 403 int tx_buf_idx)
399{ 404{
405 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
400 u32 sid, eid, exide, rtr; 406 u32 sid, eid, exide, rtr;
401 u8 buf[SPI_TRANSFER_BUF_LEN]; 407 u8 buf[SPI_TRANSFER_BUF_LEN];
402 408
@@ -418,7 +424,10 @@ static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame,
418 buf[TXBDLC_OFF] = (rtr << DLC_RTR_SHIFT) | frame->can_dlc; 424 buf[TXBDLC_OFF] = (rtr << DLC_RTR_SHIFT) | frame->can_dlc;
419 memcpy(buf + TXBDAT_OFF, frame->data, frame->can_dlc); 425 memcpy(buf + TXBDAT_OFF, frame->data, frame->can_dlc);
420 mcp251x_hw_tx_frame(spi, buf, frame->can_dlc, tx_buf_idx); 426 mcp251x_hw_tx_frame(spi, buf, frame->can_dlc, tx_buf_idx);
421 mcp251x_write_reg(spi, TXBCTRL(tx_buf_idx), TXBCTRL_TXREQ); 427
428 /* use INSTRUCTION_RTS, to avoid "repeated frame problem" */
429 priv->spi_tx_buf[0] = INSTRUCTION_RTS(1 << tx_buf_idx);
430 mcp251x_spi_trans(priv->spi, 1);
422} 431}
423 432
424static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf, 433static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 527dbcf95335..9ded21e79db5 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -984,12 +984,12 @@ static int __devexit ti_hecc_remove(struct platform_device *pdev)
984 struct net_device *ndev = platform_get_drvdata(pdev); 984 struct net_device *ndev = platform_get_drvdata(pdev);
985 struct ti_hecc_priv *priv = netdev_priv(ndev); 985 struct ti_hecc_priv *priv = netdev_priv(ndev);
986 986
987 unregister_candev(ndev);
987 clk_disable(priv->clk); 988 clk_disable(priv->clk);
988 clk_put(priv->clk); 989 clk_put(priv->clk);
989 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 990 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
990 iounmap(priv->base); 991 iounmap(priv->base);
991 release_mem_region(res->start, resource_size(res)); 992 release_mem_region(res->start, resource_size(res));
992 unregister_candev(ndev);
993 free_candev(ndev); 993 free_candev(ndev);
994 platform_set_drvdata(pdev, NULL); 994 platform_set_drvdata(pdev, NULL);
995 995
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index af20c6ee2cd9..e8e97a7d1d06 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -662,14 +662,16 @@ void bnx2x_csum_validate(struct sk_buff *skb, union eth_rx_cqe *cqe,
662 struct bnx2x_fastpath *fp, 662 struct bnx2x_fastpath *fp,
663 struct bnx2x_eth_q_stats *qstats) 663 struct bnx2x_eth_q_stats *qstats)
664{ 664{
665 /* Do nothing if no IP/L4 csum validation was done */ 665 /* Do nothing if no L4 csum validation was done.
666 666 * We do not check whether IP csum was validated. For IPv4 we assume
667 * that if the card got as far as validating the L4 csum, it also
668 * validated the IP csum. IPv6 has no IP csum.
669 */
667 if (cqe->fast_path_cqe.status_flags & 670 if (cqe->fast_path_cqe.status_flags &
668 (ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG | 671 ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG)
669 ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG))
670 return; 672 return;
671 673
672 /* If both IP/L4 validation were done, check if an error was found. */ 674 /* If L4 validation was done, check if an error was found. */
673 675
674 if (cqe->fast_path_cqe.type_error_flags & 676 if (cqe->fast_path_cqe.type_error_flags &
675 (ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG | 677 (ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 21b553229ea4..dfd86a55f1dc 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -710,17 +710,15 @@ static inline u16 bnx2x_tx_avail(struct bnx2x *bp,
710 prod = txdata->tx_bd_prod; 710 prod = txdata->tx_bd_prod;
711 cons = txdata->tx_bd_cons; 711 cons = txdata->tx_bd_cons;
712 712
713 /* NUM_TX_RINGS = number of "next-page" entries 713 used = SUB_S16(prod, cons);
714 It will be used as a threshold */
715 used = SUB_S16(prod, cons) + (s16)NUM_TX_RINGS;
716 714
717#ifdef BNX2X_STOP_ON_ERROR 715#ifdef BNX2X_STOP_ON_ERROR
718 WARN_ON(used < 0); 716 WARN_ON(used < 0);
719 WARN_ON(used > bp->tx_ring_size); 717 WARN_ON(used > txdata->tx_ring_size);
720 WARN_ON((bp->tx_ring_size - used) > MAX_TX_AVAIL); 718 WARN_ON((txdata->tx_ring_size - used) > MAX_TX_AVAIL);
721#endif 719#endif
722 720
723 return (s16)(bp->tx_ring_size) - used; 721 return (s16)(txdata->tx_ring_size) - used;
724} 722}
725 723
726static inline int bnx2x_tx_queue_has_work(struct bnx2x_fp_txdata *txdata) 724static inline int bnx2x_tx_queue_has_work(struct bnx2x_fp_txdata *txdata)
@@ -1088,6 +1086,7 @@ static inline void bnx2x_init_txdata(struct bnx2x *bp,
1088 txdata->txq_index = txq_index; 1086 txdata->txq_index = txq_index;
1089 txdata->tx_cons_sb = tx_cons_sb; 1087 txdata->tx_cons_sb = tx_cons_sb;
1090 txdata->parent_fp = fp; 1088 txdata->parent_fp = fp;
1089 txdata->tx_ring_size = IS_FCOE_FP(fp) ? MAX_TX_AVAIL : bp->tx_ring_size;
1091 1090
1092 DP(NETIF_MSG_IFUP, "created tx data cid %d, txq %d\n", 1091 DP(NETIF_MSG_IFUP, "created tx data cid %d, txq %d\n",
1093 txdata->cid, txdata->txq_index); 1092 txdata->cid, txdata->txq_index);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h
index 3e4cff9b1ebe..b926f58e983b 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h
@@ -401,11 +401,11 @@ static const struct reg_addr reg_addrs[] = {
401 { 0x70000, 8, RI_ALL_ONLINE }, 401 { 0x70000, 8, RI_ALL_ONLINE },
402 { 0x70020, 8184, RI_ALL_OFFLINE }, 402 { 0x70020, 8184, RI_ALL_OFFLINE },
403 { 0x78000, 8192, RI_E3E3B0_OFFLINE }, 403 { 0x78000, 8192, RI_E3E3B0_OFFLINE },
404 { 0x85000, 3, RI_ALL_ONLINE }, 404 { 0x85000, 3, RI_ALL_OFFLINE },
405 { 0x8501c, 7, RI_ALL_ONLINE }, 405 { 0x8501c, 7, RI_ALL_OFFLINE },
406 { 0x85048, 1, RI_ALL_ONLINE }, 406 { 0x85048, 1, RI_ALL_OFFLINE },
407 { 0x85200, 32, RI_ALL_ONLINE }, 407 { 0x85200, 32, RI_ALL_OFFLINE },
408 { 0xb0000, 16384, RI_E1H_ONLINE }, 408 { 0xb0000, 16384, RI_E1H_OFFLINE },
409 { 0xc1000, 7, RI_ALL_ONLINE }, 409 { 0xc1000, 7, RI_ALL_ONLINE },
410 { 0xc103c, 2, RI_E2E3E3B0_ONLINE }, 410 { 0xc103c, 2, RI_E2E3E3B0_ONLINE },
411 { 0xc1800, 2, RI_ALL_ONLINE }, 411 { 0xc1800, 2, RI_ALL_ONLINE },
@@ -581,17 +581,12 @@ static const struct reg_addr reg_addrs[] = {
581 { 0x140188, 3, RI_E1E1HE2E3_ONLINE }, 581 { 0x140188, 3, RI_E1E1HE2E3_ONLINE },
582 { 0x140194, 13, RI_ALL_ONLINE }, 582 { 0x140194, 13, RI_ALL_ONLINE },
583 { 0x140200, 6, RI_E1E1HE2E3_ONLINE }, 583 { 0x140200, 6, RI_E1E1HE2E3_ONLINE },
584 { 0x140220, 4, RI_E2E3_ONLINE },
585 { 0x140240, 4, RI_E2E3_ONLINE },
586 { 0x140260, 4, RI_E2E3_ONLINE }, 584 { 0x140260, 4, RI_E2E3_ONLINE },
587 { 0x140280, 4, RI_E2E3_ONLINE }, 585 { 0x140280, 4, RI_E2E3_ONLINE },
588 { 0x1402a0, 4, RI_E2E3_ONLINE },
589 { 0x1402c0, 4, RI_E2E3_ONLINE },
590 { 0x1402e0, 2, RI_E2E3_ONLINE }, 586 { 0x1402e0, 2, RI_E2E3_ONLINE },
591 { 0x1402e8, 2, RI_E2E3E3B0_ONLINE }, 587 { 0x1402e8, 2, RI_E2E3E3B0_ONLINE },
592 { 0x1402f0, 9, RI_E2E3_ONLINE }, 588 { 0x1402f0, 9, RI_E2E3_ONLINE },
593 { 0x140314, 44, RI_E3B0_ONLINE }, 589 { 0x140314, 44, RI_E3B0_ONLINE },
594 { 0x1403d0, 70, RI_E3B0_ONLINE },
595 { 0x144000, 4, RI_E1E1H_ONLINE }, 590 { 0x144000, 4, RI_E1E1H_ONLINE },
596 { 0x148000, 4, RI_E1E1H_ONLINE }, 591 { 0x148000, 4, RI_E1E1H_ONLINE },
597 { 0x14c000, 4, RI_E1E1H_ONLINE }, 592 { 0x14c000, 4, RI_E1E1H_ONLINE },
@@ -704,7 +699,6 @@ static const struct reg_addr reg_addrs[] = {
704 { 0x180398, 1, RI_E2E3E3B0_ONLINE }, 699 { 0x180398, 1, RI_E2E3E3B0_ONLINE },
705 { 0x1803a0, 5, RI_E2E3E3B0_ONLINE }, 700 { 0x1803a0, 5, RI_E2E3E3B0_ONLINE },
706 { 0x1803b4, 2, RI_E3E3B0_ONLINE }, 701 { 0x1803b4, 2, RI_E3E3B0_ONLINE },
707 { 0x180400, 1, RI_ALL_ONLINE },
708 { 0x180404, 255, RI_E1E1H_OFFLINE }, 702 { 0x180404, 255, RI_E1E1H_OFFLINE },
709 { 0x181000, 4, RI_ALL_ONLINE }, 703 { 0x181000, 4, RI_ALL_ONLINE },
710 { 0x181010, 1020, RI_ALL_OFFLINE }, 704 { 0x181010, 1020, RI_ALL_OFFLINE },
@@ -800,9 +794,9 @@ static const struct reg_addr reg_addrs[] = {
800 { 0x1b905c, 1, RI_E3E3B0_ONLINE }, 794 { 0x1b905c, 1, RI_E3E3B0_ONLINE },
801 { 0x1b9064, 1, RI_E3B0_ONLINE }, 795 { 0x1b9064, 1, RI_E3B0_ONLINE },
802 { 0x1b9080, 10, RI_E3B0_ONLINE }, 796 { 0x1b9080, 10, RI_E3B0_ONLINE },
803 { 0x1b9400, 14, RI_E2E3E3B0_ONLINE }, 797 { 0x1b9400, 14, RI_E2E3E3B0_OFFLINE },
804 { 0x1b943c, 19, RI_E2E3E3B0_ONLINE }, 798 { 0x1b943c, 19, RI_E2E3E3B0_OFFLINE },
805 { 0x1b9490, 10, RI_E2E3E3B0_ONLINE }, 799 { 0x1b9490, 10, RI_E2E3E3B0_OFFLINE },
806 { 0x1c0000, 2, RI_ALL_ONLINE }, 800 { 0x1c0000, 2, RI_ALL_ONLINE },
807 { 0x200000, 65, RI_ALL_ONLINE }, 801 { 0x200000, 65, RI_ALL_ONLINE },
808 { 0x20014c, 2, RI_E1HE2E3E3B0_ONLINE }, 802 { 0x20014c, 2, RI_E1HE2E3E3B0_ONLINE },
@@ -814,7 +808,6 @@ static const struct reg_addr reg_addrs[] = {
814 { 0x200398, 1, RI_E2E3E3B0_ONLINE }, 808 { 0x200398, 1, RI_E2E3E3B0_ONLINE },
815 { 0x2003a0, 1, RI_E2E3E3B0_ONLINE }, 809 { 0x2003a0, 1, RI_E2E3E3B0_ONLINE },
816 { 0x2003a8, 2, RI_E2E3E3B0_ONLINE }, 810 { 0x2003a8, 2, RI_E2E3E3B0_ONLINE },
817 { 0x200400, 1, RI_ALL_ONLINE },
818 { 0x200404, 255, RI_E1E1H_OFFLINE }, 811 { 0x200404, 255, RI_E1E1H_OFFLINE },
819 { 0x202000, 4, RI_ALL_ONLINE }, 812 { 0x202000, 4, RI_ALL_ONLINE },
820 { 0x202010, 2044, RI_ALL_OFFLINE }, 813 { 0x202010, 2044, RI_ALL_OFFLINE },
@@ -921,7 +914,6 @@ static const struct reg_addr reg_addrs[] = {
921 { 0x280398, 1, RI_E2E3E3B0_ONLINE }, 914 { 0x280398, 1, RI_E2E3E3B0_ONLINE },
922 { 0x2803a0, 1, RI_E2E3E3B0_ONLINE }, 915 { 0x2803a0, 1, RI_E2E3E3B0_ONLINE },
923 { 0x2803a8, 2, RI_E2E3E3B0_ONLINE }, 916 { 0x2803a8, 2, RI_E2E3E3B0_ONLINE },
924 { 0x280400, 1, RI_ALL_ONLINE },
925 { 0x280404, 255, RI_E1E1H_OFFLINE }, 917 { 0x280404, 255, RI_E1E1H_OFFLINE },
926 { 0x282000, 4, RI_ALL_ONLINE }, 918 { 0x282000, 4, RI_ALL_ONLINE },
927 { 0x282010, 2044, RI_ALL_OFFLINE }, 919 { 0x282010, 2044, RI_ALL_OFFLINE },
@@ -1031,7 +1023,6 @@ static const struct reg_addr reg_addrs[] = {
1031 { 0x300398, 1, RI_E2E3E3B0_ONLINE }, 1023 { 0x300398, 1, RI_E2E3E3B0_ONLINE },
1032 { 0x3003a0, 1, RI_E2E3E3B0_ONLINE }, 1024 { 0x3003a0, 1, RI_E2E3E3B0_ONLINE },
1033 { 0x3003a8, 2, RI_E2E3E3B0_ONLINE }, 1025 { 0x3003a8, 2, RI_E2E3E3B0_ONLINE },
1034 { 0x300400, 1, RI_ALL_ONLINE },
1035 { 0x300404, 255, RI_E1E1H_OFFLINE }, 1026 { 0x300404, 255, RI_E1E1H_OFFLINE },
1036 { 0x302000, 4, RI_ALL_ONLINE }, 1027 { 0x302000, 4, RI_ALL_ONLINE },
1037 { 0x302010, 2044, RI_ALL_OFFLINE }, 1028 { 0x302010, 2044, RI_ALL_OFFLINE },
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index c37a68d68090..ebf40cd7aa10 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -775,7 +775,7 @@ static void bnx2x_get_regs(struct net_device *dev,
775 struct bnx2x *bp = netdev_priv(dev); 775 struct bnx2x *bp = netdev_priv(dev);
776 struct dump_hdr dump_hdr = {0}; 776 struct dump_hdr dump_hdr = {0};
777 777
778 regs->version = 0; 778 regs->version = 1;
779 memset(p, 0, regs->len); 779 memset(p, 0, regs->len);
780 780
781 if (!netif_running(bp->dev)) 781 if (!netif_running(bp->dev))
@@ -1587,6 +1587,12 @@ static int bnx2x_set_pauseparam(struct net_device *dev,
1587 bp->link_params.req_flow_ctrl[cfg_idx] = 1587 bp->link_params.req_flow_ctrl[cfg_idx] =
1588 BNX2X_FLOW_CTRL_AUTO; 1588 BNX2X_FLOW_CTRL_AUTO;
1589 } 1589 }
1590 bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_NONE;
1591 if (epause->rx_pause)
1592 bp->link_params.req_fc_auto_adv |= BNX2X_FLOW_CTRL_RX;
1593
1594 if (epause->tx_pause)
1595 bp->link_params.req_fc_auto_adv |= BNX2X_FLOW_CTRL_TX;
1590 } 1596 }
1591 1597
1592 DP(BNX2X_MSG_ETHTOOL, 1598 DP(BNX2X_MSG_ETHTOOL,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
index f4beb46c4709..b046beb435b2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
@@ -2667,9 +2667,11 @@ int bnx2x_update_pfc(struct link_params *params,
2667 return bnx2x_status; 2667 return bnx2x_status;
2668 2668
2669 DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n"); 2669 DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n");
2670 if (CHIP_IS_E3(bp)) 2670
2671 bnx2x_update_pfc_xmac(params, vars, 0); 2671 if (CHIP_IS_E3(bp)) {
2672 else { 2672 if (vars->mac_type == MAC_TYPE_XMAC)
2673 bnx2x_update_pfc_xmac(params, vars, 0);
2674 } else {
2673 val = REG_RD(bp, MISC_REG_RESET_REG_2); 2675 val = REG_RD(bp, MISC_REG_RESET_REG_2);
2674 if ((val & 2676 if ((val &
2675 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) 2677 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port))
@@ -5432,7 +5434,7 @@ static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy,
5432 switch (speed_mask) { 5434 switch (speed_mask) {
5433 case GP_STATUS_10M: 5435 case GP_STATUS_10M:
5434 vars->line_speed = SPEED_10; 5436 vars->line_speed = SPEED_10;
5435 if (vars->duplex == DUPLEX_FULL) 5437 if (is_duplex == DUPLEX_FULL)
5436 vars->link_status |= LINK_10TFD; 5438 vars->link_status |= LINK_10TFD;
5437 else 5439 else
5438 vars->link_status |= LINK_10THD; 5440 vars->link_status |= LINK_10THD;
@@ -5440,7 +5442,7 @@ static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy,
5440 5442
5441 case GP_STATUS_100M: 5443 case GP_STATUS_100M:
5442 vars->line_speed = SPEED_100; 5444 vars->line_speed = SPEED_100;
5443 if (vars->duplex == DUPLEX_FULL) 5445 if (is_duplex == DUPLEX_FULL)
5444 vars->link_status |= LINK_100TXFD; 5446 vars->link_status |= LINK_100TXFD;
5445 else 5447 else
5446 vars->link_status |= LINK_100TXHD; 5448 vars->link_status |= LINK_100TXHD;
@@ -5449,7 +5451,7 @@ static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy,
5449 case GP_STATUS_1G: 5451 case GP_STATUS_1G:
5450 case GP_STATUS_1G_KX: 5452 case GP_STATUS_1G_KX:
5451 vars->line_speed = SPEED_1000; 5453 vars->line_speed = SPEED_1000;
5452 if (vars->duplex == DUPLEX_FULL) 5454 if (is_duplex == DUPLEX_FULL)
5453 vars->link_status |= LINK_1000TFD; 5455 vars->link_status |= LINK_1000TFD;
5454 else 5456 else
5455 vars->link_status |= LINK_1000THD; 5457 vars->link_status |= LINK_1000THD;
@@ -5457,7 +5459,7 @@ static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy,
5457 5459
5458 case GP_STATUS_2_5G: 5460 case GP_STATUS_2_5G:
5459 vars->line_speed = SPEED_2500; 5461 vars->line_speed = SPEED_2500;
5460 if (vars->duplex == DUPLEX_FULL) 5462 if (is_duplex == DUPLEX_FULL)
5461 vars->link_status |= LINK_2500TFD; 5463 vars->link_status |= LINK_2500TFD;
5462 else 5464 else
5463 vars->link_status |= LINK_2500THD; 5465 vars->link_status |= LINK_2500THD;
@@ -5531,6 +5533,7 @@ static int bnx2x_link_settings_status(struct bnx2x_phy *phy,
5531 5533
5532 if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { 5534 if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) {
5533 if (SINGLE_MEDIA_DIRECT(params)) { 5535 if (SINGLE_MEDIA_DIRECT(params)) {
5536 vars->duplex = duplex;
5534 bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status); 5537 bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status);
5535 if (phy->req_line_speed == SPEED_AUTO_NEG) 5538 if (phy->req_line_speed == SPEED_AUTO_NEG)
5536 bnx2x_xgxs_an_resolve(phy, params, vars, 5539 bnx2x_xgxs_an_resolve(phy, params, vars,
@@ -5625,6 +5628,7 @@ static int bnx2x_warpcore_read_status(struct bnx2x_phy *phy,
5625 LINK_STATUS_PARALLEL_DETECTION_USED; 5628 LINK_STATUS_PARALLEL_DETECTION_USED;
5626 } 5629 }
5627 bnx2x_ext_phy_resolve_fc(phy, params, vars); 5630 bnx2x_ext_phy_resolve_fc(phy, params, vars);
5631 vars->duplex = duplex;
5628 } 5632 }
5629 } 5633 }
5630 5634
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 21054987257a..0875ecfe3372 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -7561,8 +7561,14 @@ int bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac,
7561 } 7561 }
7562 7562
7563 rc = bnx2x_config_vlan_mac(bp, &ramrod_param); 7563 rc = bnx2x_config_vlan_mac(bp, &ramrod_param);
7564 if (rc < 0) 7564
7565 if (rc == -EEXIST) {
7566 DP(BNX2X_MSG_SP, "Failed to schedule ADD operations: %d\n", rc);
7567 /* do not treat adding same MAC as error */
7568 rc = 0;
7569 } else if (rc < 0)
7565 BNX2X_ERR("%s MAC failed\n", (set ? "Set" : "Del")); 7570 BNX2X_ERR("%s MAC failed\n", (set ? "Set" : "Del"));
7571
7566 return rc; 7572 return rc;
7567} 7573}
7568 7574
@@ -9825,12 +9831,13 @@ static void __devinit bnx2x_get_igu_cam_info(struct bnx2x *bp)
9825 } 9831 }
9826 9832
9827#ifdef CONFIG_PCI_MSI 9833#ifdef CONFIG_PCI_MSI
9828 /* 9834 /* Due to new PF resource allocation by MFW T7.4 and above, it's
9829 * It's expected that number of CAM entries for this functions is equal 9835 * optional that number of CAM entries will not be equal to the value
9830 * to the number evaluated based on the MSI-X table size. We want a 9836 * advertised in PCI.
9831 * harsh warning if these values are different! 9837 * Driver should use the minimal value of both as the actual status
9838 * block count
9832 */ 9839 */
9833 WARN_ON(bp->igu_sb_cnt != igu_sb_cnt); 9840 bp->igu_sb_cnt = min_t(int, bp->igu_sb_cnt, igu_sb_cnt);
9834#endif 9841#endif
9835 9842
9836 if (igu_sb_cnt == 0) 9843 if (igu_sb_cnt == 0)
@@ -10294,13 +10301,11 @@ static void __devinit bnx2x_get_fcoe_info(struct bnx2x *bp)
10294 dev_info.port_hw_config[port]. 10301 dev_info.port_hw_config[port].
10295 fcoe_wwn_node_name_lower); 10302 fcoe_wwn_node_name_lower);
10296 } else if (!IS_MF_SD(bp)) { 10303 } else if (!IS_MF_SD(bp)) {
10297 u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg);
10298
10299 /* 10304 /*
10300 * Read the WWN info only if the FCoE feature is enabled for 10305 * Read the WWN info only if the FCoE feature is enabled for
10301 * this function. 10306 * this function.
10302 */ 10307 */
10303 if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) 10308 if (BNX2X_MF_EXT_PROTOCOL_FCOE(bp) && !CHIP_IS_E1x(bp))
10304 bnx2x_get_ext_wwn_info(bp, func); 10309 bnx2x_get_ext_wwn_info(bp, func);
10305 10310
10306 } else if (IS_MF_FCOE_SD(bp)) 10311 } else if (IS_MF_FCOE_SD(bp))
@@ -11073,7 +11078,14 @@ static int bnx2x_set_uc_list(struct bnx2x *bp)
11073 netdev_for_each_uc_addr(ha, dev) { 11078 netdev_for_each_uc_addr(ha, dev) {
11074 rc = bnx2x_set_mac_one(bp, bnx2x_uc_addr(ha), mac_obj, true, 11079 rc = bnx2x_set_mac_one(bp, bnx2x_uc_addr(ha), mac_obj, true,
11075 BNX2X_UC_LIST_MAC, &ramrod_flags); 11080 BNX2X_UC_LIST_MAC, &ramrod_flags);
11076 if (rc < 0) { 11081 if (rc == -EEXIST) {
11082 DP(BNX2X_MSG_SP,
11083 "Failed to schedule ADD operations: %d\n", rc);
11084 /* do not treat adding same MAC as error */
11085 rc = 0;
11086
11087 } else if (rc < 0) {
11088
11077 BNX2X_ERR("Failed to schedule ADD operations: %d\n", 11089 BNX2X_ERR("Failed to schedule ADD operations: %d\n",
11078 rc); 11090 rc);
11079 return rc; 11091 return rc;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index 332db64dd5be..a1d0446b39b3 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -101,6 +101,11 @@ static void bnx2x_hw_stats_post(struct bnx2x *bp)
101 if (CHIP_REV_IS_SLOW(bp)) 101 if (CHIP_REV_IS_SLOW(bp))
102 return; 102 return;
103 103
104 /* Update MCP's statistics if possible */
105 if (bp->func_stx)
106 memcpy(bnx2x_sp(bp, func_stats), &bp->func_stats,
107 sizeof(bp->func_stats));
108
104 /* loader */ 109 /* loader */
105 if (bp->executer_idx) { 110 if (bp->executer_idx) {
106 int loader_idx = PMF_DMAE_C(bp); 111 int loader_idx = PMF_DMAE_C(bp);
@@ -128,8 +133,6 @@ static void bnx2x_hw_stats_post(struct bnx2x *bp)
128 133
129 } else if (bp->func_stx) { 134 } else if (bp->func_stx) {
130 *stats_comp = 0; 135 *stats_comp = 0;
131 memcpy(bnx2x_sp(bp, func_stats), &bp->func_stats,
132 sizeof(bp->func_stats));
133 bnx2x_post_dmae(bp, dmae, INIT_DMAE_C(bp)); 136 bnx2x_post_dmae(bp, dmae, INIT_DMAE_C(bp));
134 } 137 }
135} 138}
@@ -1151,9 +1154,11 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1151 if (bp->port.pmf) 1154 if (bp->port.pmf)
1152 bnx2x_hw_stats_update(bp); 1155 bnx2x_hw_stats_update(bp);
1153 1156
1154 if (bnx2x_storm_stats_update(bp) && (bp->stats_pending++ == 3)) { 1157 if (bnx2x_storm_stats_update(bp)) {
1155 BNX2X_ERR("storm stats were not updated for 3 times\n"); 1158 if (bp->stats_pending++ == 3) {
1156 bnx2x_panic(); 1159 BNX2X_ERR("storm stats were not updated for 3 times\n");
1160 bnx2x_panic();
1161 }
1157 return; 1162 return;
1158 } 1163 }
1159 1164
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 77884191a8c6..4e980a7886fb 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -1086,7 +1086,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
1086 /* Clock */ 1086 /* Clock */
1087 lp->ether_clk = clk_get(&pdev->dev, "ether_clk"); 1087 lp->ether_clk = clk_get(&pdev->dev, "ether_clk");
1088 if (IS_ERR(lp->ether_clk)) { 1088 if (IS_ERR(lp->ether_clk)) {
1089 res = -ENODEV; 1089 res = PTR_ERR(lp->ether_clk);
1090 goto err_ioumap; 1090 goto err_ioumap;
1091 } 1091 }
1092 clk_enable(lp->ether_clk); 1092 clk_enable(lp->ether_clk);
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 8971921cc1c8..ab6762caa957 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -1773,6 +1773,7 @@ static int gfar_get_nfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
1773} 1773}
1774 1774
1775int gfar_phc_index = -1; 1775int gfar_phc_index = -1;
1776EXPORT_SYMBOL(gfar_phc_index);
1776 1777
1777static int gfar_get_ts_info(struct net_device *dev, 1778static int gfar_get_ts_info(struct net_device *dev,
1778 struct ethtool_ts_info *info) 1779 struct ethtool_ts_info *info)
diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
index c08e5d40fecb..0daa66b8eca0 100644
--- a/drivers/net/ethernet/freescale/gianfar_ptp.c
+++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
@@ -515,7 +515,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)
515 err = PTR_ERR(etsects->clock); 515 err = PTR_ERR(etsects->clock);
516 goto no_clock; 516 goto no_clock;
517 } 517 }
518 gfar_phc_clock = ptp_clock_index(etsects->clock); 518 gfar_phc_index = ptp_clock_index(etsects->clock);
519 519
520 dev_set_drvdata(&dev->dev, etsects); 520 dev_set_drvdata(&dev->dev, etsects);
521 521
@@ -539,7 +539,7 @@ static int gianfar_ptp_remove(struct platform_device *dev)
539 gfar_write(&etsects->regs->tmr_temask, 0); 539 gfar_write(&etsects->regs->tmr_temask, 0);
540 gfar_write(&etsects->regs->tmr_ctrl, 0); 540 gfar_write(&etsects->regs->tmr_ctrl, 0);
541 541
542 gfar_phc_clock = -1; 542 gfar_phc_index = -1;
543 ptp_clock_unregister(etsects->clock); 543 ptp_clock_unregister(etsects->clock);
544 iounmap(etsects->regs); 544 iounmap(etsects->regs);
545 release_resource(etsects->rsrc); 545 release_resource(etsects->rsrc);
diff --git a/drivers/net/ethernet/i825xx/znet.c b/drivers/net/ethernet/i825xx/znet.c
index bd1f1ef91e19..ba4e0cea3506 100644
--- a/drivers/net/ethernet/i825xx/znet.c
+++ b/drivers/net/ethernet/i825xx/znet.c
@@ -139,8 +139,11 @@ struct znet_private {
139/* Only one can be built-in;-> */ 139/* Only one can be built-in;-> */
140static struct net_device *znet_dev; 140static struct net_device *znet_dev;
141 141
142#define NETIDBLK_MAGIC "NETIDBLK"
143#define NETIDBLK_MAGIC_SIZE 8
144
142struct netidblk { 145struct netidblk {
143 char magic[8]; /* The magic number (string) "NETIDBLK" */ 146 char magic[NETIDBLK_MAGIC_SIZE]; /* The magic number (string) "NETIDBLK" */
144 unsigned char netid[8]; /* The physical station address */ 147 unsigned char netid[8]; /* The physical station address */
145 char nettype, globalopt; 148 char nettype, globalopt;
146 char vendor[8]; /* The machine vendor and product name. */ 149 char vendor[8]; /* The machine vendor and product name. */
@@ -373,14 +376,16 @@ static int __init znet_probe (void)
373 struct znet_private *znet; 376 struct znet_private *znet;
374 struct net_device *dev; 377 struct net_device *dev;
375 char *p; 378 char *p;
379 char *plast = phys_to_virt(0x100000 - NETIDBLK_MAGIC_SIZE);
376 int err = -ENOMEM; 380 int err = -ENOMEM;
377 381
378 /* This code scans the region 0xf0000 to 0xfffff for a "NETIDBLK". */ 382 /* This code scans the region 0xf0000 to 0xfffff for a "NETIDBLK". */
379 for(p = (char *)phys_to_virt(0xf0000); p < (char *)phys_to_virt(0x100000); p++) 383 for(p = (char *)phys_to_virt(0xf0000); p <= plast; p++)
380 if (*p == 'N' && strncmp(p, "NETIDBLK", 8) == 0) 384 if (*p == 'N' &&
385 strncmp(p, NETIDBLK_MAGIC, NETIDBLK_MAGIC_SIZE) == 0)
381 break; 386 break;
382 387
383 if (p >= (char *)phys_to_virt(0x100000)) { 388 if (p > plast) {
384 if (znet_debug > 1) 389 if (znet_debug > 1)
385 printk(KERN_INFO "No Z-Note ethernet adaptor found.\n"); 390 printk(KERN_INFO "No Z-Note ethernet adaptor found.\n");
386 return -ENODEV; 391 return -ENODEV;
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 9010cea68bc3..b68d28a130e6 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -472,14 +472,9 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
472 } 472 }
473 473
474 if (adapter->rx_queue.queue_addr != NULL) { 474 if (adapter->rx_queue.queue_addr != NULL) {
475 if (!dma_mapping_error(dev, adapter->rx_queue.queue_dma)) { 475 dma_free_coherent(dev, adapter->rx_queue.queue_len,
476 dma_unmap_single(dev, 476 adapter->rx_queue.queue_addr,
477 adapter->rx_queue.queue_dma, 477 adapter->rx_queue.queue_dma);
478 adapter->rx_queue.queue_len,
479 DMA_BIDIRECTIONAL);
480 adapter->rx_queue.queue_dma = DMA_ERROR_CODE;
481 }
482 kfree(adapter->rx_queue.queue_addr);
483 adapter->rx_queue.queue_addr = NULL; 478 adapter->rx_queue.queue_addr = NULL;
484 } 479 }
485 480
@@ -556,10 +551,13 @@ static int ibmveth_open(struct net_device *netdev)
556 goto err_out; 551 goto err_out;
557 } 552 }
558 553
554 dev = &adapter->vdev->dev;
555
559 adapter->rx_queue.queue_len = sizeof(struct ibmveth_rx_q_entry) * 556 adapter->rx_queue.queue_len = sizeof(struct ibmveth_rx_q_entry) *
560 rxq_entries; 557 rxq_entries;
561 adapter->rx_queue.queue_addr = kmalloc(adapter->rx_queue.queue_len, 558 adapter->rx_queue.queue_addr =
562 GFP_KERNEL); 559 dma_alloc_coherent(dev, adapter->rx_queue.queue_len,
560 &adapter->rx_queue.queue_dma, GFP_KERNEL);
563 561
564 if (!adapter->rx_queue.queue_addr) { 562 if (!adapter->rx_queue.queue_addr) {
565 netdev_err(netdev, "unable to allocate rx queue pages\n"); 563 netdev_err(netdev, "unable to allocate rx queue pages\n");
@@ -567,19 +565,13 @@ static int ibmveth_open(struct net_device *netdev)
567 goto err_out; 565 goto err_out;
568 } 566 }
569 567
570 dev = &adapter->vdev->dev;
571
572 adapter->buffer_list_dma = dma_map_single(dev, 568 adapter->buffer_list_dma = dma_map_single(dev,
573 adapter->buffer_list_addr, 4096, DMA_BIDIRECTIONAL); 569 adapter->buffer_list_addr, 4096, DMA_BIDIRECTIONAL);
574 adapter->filter_list_dma = dma_map_single(dev, 570 adapter->filter_list_dma = dma_map_single(dev,
575 adapter->filter_list_addr, 4096, DMA_BIDIRECTIONAL); 571 adapter->filter_list_addr, 4096, DMA_BIDIRECTIONAL);
576 adapter->rx_queue.queue_dma = dma_map_single(dev,
577 adapter->rx_queue.queue_addr,
578 adapter->rx_queue.queue_len, DMA_BIDIRECTIONAL);
579 572
580 if ((dma_mapping_error(dev, adapter->buffer_list_dma)) || 573 if ((dma_mapping_error(dev, adapter->buffer_list_dma)) ||
581 (dma_mapping_error(dev, adapter->filter_list_dma)) || 574 (dma_mapping_error(dev, adapter->filter_list_dma))) {
582 (dma_mapping_error(dev, adapter->rx_queue.queue_dma))) {
583 netdev_err(netdev, "unable to map filter or buffer list " 575 netdev_err(netdev, "unable to map filter or buffer list "
584 "pages\n"); 576 "pages\n");
585 rc = -ENOMEM; 577 rc = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 3bfbb8df8989..bde337ee1a34 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -3149,6 +3149,17 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3149 return NETDEV_TX_OK; 3149 return NETDEV_TX_OK;
3150 } 3150 }
3151 3151
3152 /* On PCI/PCI-X HW, if packet size is less than ETH_ZLEN,
3153 * packets may get corrupted during padding by HW.
3154 * To WA this issue, pad all small packets manually.
3155 */
3156 if (skb->len < ETH_ZLEN) {
3157 if (skb_pad(skb, ETH_ZLEN - skb->len))
3158 return NETDEV_TX_OK;
3159 skb->len = ETH_ZLEN;
3160 skb_set_tail_pointer(skb, ETH_ZLEN);
3161 }
3162
3152 mss = skb_shinfo(skb)->gso_size; 3163 mss = skb_shinfo(skb)->gso_size;
3153 /* The controller does a simple calculation to 3164 /* The controller does a simple calculation to
3154 * make sure there is enough room in the FIFO before 3165 * make sure there is enough room in the FIFO before
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c
index daf417923661..31d02649be41 100644
--- a/drivers/net/ethernet/mellanox/mlx4/icm.c
+++ b/drivers/net/ethernet/mellanox/mlx4/icm.c
@@ -227,9 +227,10 @@ int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev)
227 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); 227 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
228} 228}
229 229
230int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, int obj) 230int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj)
231{ 231{
232 int i = (obj & (table->num_obj - 1)) / (MLX4_TABLE_CHUNK_SIZE / table->obj_size); 232 u32 i = (obj & (table->num_obj - 1)) /
233 (MLX4_TABLE_CHUNK_SIZE / table->obj_size);
233 int ret = 0; 234 int ret = 0;
234 235
235 mutex_lock(&table->mutex); 236 mutex_lock(&table->mutex);
@@ -262,16 +263,18 @@ out:
262 return ret; 263 return ret;
263} 264}
264 265
265void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, int obj) 266void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj)
266{ 267{
267 int i; 268 u32 i;
269 u64 offset;
268 270
269 i = (obj & (table->num_obj - 1)) / (MLX4_TABLE_CHUNK_SIZE / table->obj_size); 271 i = (obj & (table->num_obj - 1)) / (MLX4_TABLE_CHUNK_SIZE / table->obj_size);
270 272
271 mutex_lock(&table->mutex); 273 mutex_lock(&table->mutex);
272 274
273 if (--table->icm[i]->refcount == 0) { 275 if (--table->icm[i]->refcount == 0) {
274 mlx4_UNMAP_ICM(dev, table->virt + i * MLX4_TABLE_CHUNK_SIZE, 276 offset = (u64) i * MLX4_TABLE_CHUNK_SIZE;
277 mlx4_UNMAP_ICM(dev, table->virt + offset,
275 MLX4_TABLE_CHUNK_SIZE / MLX4_ICM_PAGE_SIZE); 278 MLX4_TABLE_CHUNK_SIZE / MLX4_ICM_PAGE_SIZE);
276 mlx4_free_icm(dev, table->icm[i], table->coherent); 279 mlx4_free_icm(dev, table->icm[i], table->coherent);
277 table->icm[i] = NULL; 280 table->icm[i] = NULL;
@@ -280,9 +283,11 @@ void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, int obj)
280 mutex_unlock(&table->mutex); 283 mutex_unlock(&table->mutex);
281} 284}
282 285
283void *mlx4_table_find(struct mlx4_icm_table *table, int obj, dma_addr_t *dma_handle) 286void *mlx4_table_find(struct mlx4_icm_table *table, u32 obj,
287 dma_addr_t *dma_handle)
284{ 288{
285 int idx, offset, dma_offset, i; 289 int offset, dma_offset, i;
290 u64 idx;
286 struct mlx4_icm_chunk *chunk; 291 struct mlx4_icm_chunk *chunk;
287 struct mlx4_icm *icm; 292 struct mlx4_icm *icm;
288 struct page *page = NULL; 293 struct page *page = NULL;
@@ -292,7 +297,7 @@ void *mlx4_table_find(struct mlx4_icm_table *table, int obj, dma_addr_t *dma_han
292 297
293 mutex_lock(&table->mutex); 298 mutex_lock(&table->mutex);
294 299
295 idx = (obj & (table->num_obj - 1)) * table->obj_size; 300 idx = (u64) (obj & (table->num_obj - 1)) * table->obj_size;
296 icm = table->icm[idx / MLX4_TABLE_CHUNK_SIZE]; 301 icm = table->icm[idx / MLX4_TABLE_CHUNK_SIZE];
297 dma_offset = offset = idx % MLX4_TABLE_CHUNK_SIZE; 302 dma_offset = offset = idx % MLX4_TABLE_CHUNK_SIZE;
298 303
@@ -326,10 +331,11 @@ out:
326} 331}
327 332
328int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, 333int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table,
329 int start, int end) 334 u32 start, u32 end)
330{ 335{
331 int inc = MLX4_TABLE_CHUNK_SIZE / table->obj_size; 336 int inc = MLX4_TABLE_CHUNK_SIZE / table->obj_size;
332 int i, err; 337 int err;
338 u32 i;
333 339
334 for (i = start; i <= end; i += inc) { 340 for (i = start; i <= end; i += inc) {
335 err = mlx4_table_get(dev, table, i); 341 err = mlx4_table_get(dev, table, i);
@@ -349,9 +355,9 @@ fail:
349} 355}
350 356
351void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, 357void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table,
352 int start, int end) 358 u32 start, u32 end)
353{ 359{
354 int i; 360 u32 i;
355 361
356 for (i = start; i <= end; i += MLX4_TABLE_CHUNK_SIZE / table->obj_size) 362 for (i = start; i <= end; i += MLX4_TABLE_CHUNK_SIZE / table->obj_size)
357 mlx4_table_put(dev, table, i); 363 mlx4_table_put(dev, table, i);
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.h b/drivers/net/ethernet/mellanox/mlx4/icm.h
index a67744f53506..dee67fa39107 100644
--- a/drivers/net/ethernet/mellanox/mlx4/icm.h
+++ b/drivers/net/ethernet/mellanox/mlx4/icm.h
@@ -71,17 +71,17 @@ struct mlx4_icm *mlx4_alloc_icm(struct mlx4_dev *dev, int npages,
71 gfp_t gfp_mask, int coherent); 71 gfp_t gfp_mask, int coherent);
72void mlx4_free_icm(struct mlx4_dev *dev, struct mlx4_icm *icm, int coherent); 72void mlx4_free_icm(struct mlx4_dev *dev, struct mlx4_icm *icm, int coherent);
73 73
74int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, int obj); 74int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj);
75void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, int obj); 75void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj);
76int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, 76int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table,
77 int start, int end); 77 u32 start, u32 end);
78void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, 78void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table,
79 int start, int end); 79 u32 start, u32 end);
80int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, 80int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table,
81 u64 virt, int obj_size, u32 nobj, int reserved, 81 u64 virt, int obj_size, u32 nobj, int reserved,
82 int use_lowmem, int use_coherent); 82 int use_lowmem, int use_coherent);
83void mlx4_cleanup_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table); 83void mlx4_cleanup_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table);
84void *mlx4_table_find(struct mlx4_icm_table *table, int obj, dma_addr_t *dma_handle); 84void *mlx4_table_find(struct mlx4_icm_table *table, u32 obj, dma_addr_t *dma_handle);
85 85
86static inline void mlx4_icm_first(struct mlx4_icm *icm, 86static inline void mlx4_icm_first(struct mlx4_icm *icm,
87 struct mlx4_icm_iter *iter) 87 struct mlx4_icm_iter *iter)
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 827b72dfce99..2f816c6aed72 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1234,13 +1234,13 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1234 mlx4_info(dev, "non-primary physical function, skipping.\n"); 1234 mlx4_info(dev, "non-primary physical function, skipping.\n");
1235 else 1235 else
1236 mlx4_err(dev, "QUERY_FW command failed, aborting.\n"); 1236 mlx4_err(dev, "QUERY_FW command failed, aborting.\n");
1237 goto unmap_bf; 1237 return err;
1238 } 1238 }
1239 1239
1240 err = mlx4_load_fw(dev); 1240 err = mlx4_load_fw(dev);
1241 if (err) { 1241 if (err) {
1242 mlx4_err(dev, "Failed to start FW, aborting.\n"); 1242 mlx4_err(dev, "Failed to start FW, aborting.\n");
1243 goto unmap_bf; 1243 return err;
1244 } 1244 }
1245 1245
1246 mlx4_cfg.log_pg_sz_m = 1; 1246 mlx4_cfg.log_pg_sz_m = 1;
@@ -1304,7 +1304,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1304 err = mlx4_init_slave(dev); 1304 err = mlx4_init_slave(dev);
1305 if (err) { 1305 if (err) {
1306 mlx4_err(dev, "Failed to initialize slave\n"); 1306 mlx4_err(dev, "Failed to initialize slave\n");
1307 goto unmap_bf; 1307 return err;
1308 } 1308 }
1309 1309
1310 err = mlx4_slave_cap(dev); 1310 err = mlx4_slave_cap(dev);
@@ -1324,7 +1324,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1324 err = mlx4_QUERY_ADAPTER(dev, &adapter); 1324 err = mlx4_QUERY_ADAPTER(dev, &adapter);
1325 if (err) { 1325 if (err) {
1326 mlx4_err(dev, "QUERY_ADAPTER command failed, aborting.\n"); 1326 mlx4_err(dev, "QUERY_ADAPTER command failed, aborting.\n");
1327 goto err_close; 1327 goto unmap_bf;
1328 } 1328 }
1329 1329
1330 priv->eq_table.inta_pin = adapter.inta_pin; 1330 priv->eq_table.inta_pin = adapter.inta_pin;
@@ -1332,6 +1332,9 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1332 1332
1333 return 0; 1333 return 0;
1334 1334
1335unmap_bf:
1336 unmap_bf_area(dev);
1337
1335err_close: 1338err_close:
1336 mlx4_close_hca(dev); 1339 mlx4_close_hca(dev);
1337 1340
@@ -1344,8 +1347,6 @@ err_stop_fw:
1344 mlx4_UNMAP_FA(dev); 1347 mlx4_UNMAP_FA(dev);
1345 mlx4_free_icm(dev, priv->fw.fw_icm, 0); 1348 mlx4_free_icm(dev, priv->fw.fw_icm, 0);
1346 } 1349 }
1347unmap_bf:
1348 unmap_bf_area(dev);
1349 return err; 1350 return err;
1350} 1351}
1351 1352
@@ -1996,7 +1997,8 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1996 } 1997 }
1997 1998
1998slave_start: 1999slave_start:
1999 if (mlx4_cmd_init(dev)) { 2000 err = mlx4_cmd_init(dev);
2001 if (err) {
2000 mlx4_err(dev, "Failed to init command interface, aborting.\n"); 2002 mlx4_err(dev, "Failed to init command interface, aborting.\n");
2001 goto err_sriov; 2003 goto err_sriov;
2002 } 2004 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index a018ea2a43de..e151c21baf2b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -137,11 +137,11 @@ static int mlx4_GID_HASH(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
137 return err; 137 return err;
138} 138}
139 139
140static struct mlx4_promisc_qp *get_promisc_qp(struct mlx4_dev *dev, u8 pf_num, 140static struct mlx4_promisc_qp *get_promisc_qp(struct mlx4_dev *dev, u8 port,
141 enum mlx4_steer_type steer, 141 enum mlx4_steer_type steer,
142 u32 qpn) 142 u32 qpn)
143{ 143{
144 struct mlx4_steer *s_steer = &mlx4_priv(dev)->steer[pf_num]; 144 struct mlx4_steer *s_steer = &mlx4_priv(dev)->steer[port - 1];
145 struct mlx4_promisc_qp *pqp; 145 struct mlx4_promisc_qp *pqp;
146 146
147 list_for_each_entry(pqp, &s_steer->promisc_qps[steer], list) { 147 list_for_each_entry(pqp, &s_steer->promisc_qps[steer], list) {
@@ -182,7 +182,7 @@ static int new_steering_entry(struct mlx4_dev *dev, u8 port,
182 /* If the given qpn is also a promisc qp, 182 /* If the given qpn is also a promisc qp,
183 * it should be inserted to duplicates list 183 * it should be inserted to duplicates list
184 */ 184 */
185 pqp = get_promisc_qp(dev, 0, steer, qpn); 185 pqp = get_promisc_qp(dev, port, steer, qpn);
186 if (pqp) { 186 if (pqp) {
187 dqp = kmalloc(sizeof *dqp, GFP_KERNEL); 187 dqp = kmalloc(sizeof *dqp, GFP_KERNEL);
188 if (!dqp) { 188 if (!dqp) {
@@ -256,7 +256,7 @@ static int existing_steering_entry(struct mlx4_dev *dev, u8 port,
256 256
257 s_steer = &mlx4_priv(dev)->steer[port - 1]; 257 s_steer = &mlx4_priv(dev)->steer[port - 1];
258 258
259 pqp = get_promisc_qp(dev, 0, steer, qpn); 259 pqp = get_promisc_qp(dev, port, steer, qpn);
260 if (!pqp) 260 if (!pqp)
261 return 0; /* nothing to do */ 261 return 0; /* nothing to do */
262 262
@@ -302,7 +302,7 @@ static bool check_duplicate_entry(struct mlx4_dev *dev, u8 port,
302 s_steer = &mlx4_priv(dev)->steer[port - 1]; 302 s_steer = &mlx4_priv(dev)->steer[port - 1];
303 303
304 /* if qp is not promisc, it cannot be duplicated */ 304 /* if qp is not promisc, it cannot be duplicated */
305 if (!get_promisc_qp(dev, 0, steer, qpn)) 305 if (!get_promisc_qp(dev, port, steer, qpn))
306 return false; 306 return false;
307 307
308 /* The qp is promisc qp so it is a duplicate on this index 308 /* The qp is promisc qp so it is a duplicate on this index
@@ -352,7 +352,7 @@ static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port,
352 members_count = be32_to_cpu(mgm->members_count) & 0xffffff; 352 members_count = be32_to_cpu(mgm->members_count) & 0xffffff;
353 for (i = 0; i < members_count; i++) { 353 for (i = 0; i < members_count; i++) {
354 qpn = be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK; 354 qpn = be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK;
355 if (!get_promisc_qp(dev, 0, steer, qpn) && qpn != tqpn) { 355 if (!get_promisc_qp(dev, port, steer, qpn) && qpn != tqpn) {
356 /* the qp is not promisc, the entry can't be removed */ 356 /* the qp is not promisc, the entry can't be removed */
357 goto out; 357 goto out;
358 } 358 }
@@ -398,7 +398,7 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port,
398 398
399 mutex_lock(&priv->mcg_table.mutex); 399 mutex_lock(&priv->mcg_table.mutex);
400 400
401 if (get_promisc_qp(dev, 0, steer, qpn)) { 401 if (get_promisc_qp(dev, port, steer, qpn)) {
402 err = 0; /* Noting to do, already exists */ 402 err = 0; /* Noting to do, already exists */
403 goto out_mutex; 403 goto out_mutex;
404 } 404 }
@@ -503,7 +503,7 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port,
503 s_steer = &mlx4_priv(dev)->steer[port - 1]; 503 s_steer = &mlx4_priv(dev)->steer[port - 1];
504 mutex_lock(&priv->mcg_table.mutex); 504 mutex_lock(&priv->mcg_table.mutex);
505 505
506 pqp = get_promisc_qp(dev, 0, steer, qpn); 506 pqp = get_promisc_qp(dev, port, steer, qpn);
507 if (unlikely(!pqp)) { 507 if (unlikely(!pqp)) {
508 mlx4_warn(dev, "QP %x is not promiscuous QP\n", qpn); 508 mlx4_warn(dev, "QP %x is not promiscuous QP\n", qpn);
509 /* nothing to do */ 509 /* nothing to do */
@@ -650,13 +650,6 @@ static int find_entry(struct mlx4_dev *dev, u8 port,
650 return err; 650 return err;
651} 651}
652 652
653struct mlx4_net_trans_rule_hw_ctrl {
654 __be32 ctrl;
655 __be32 vf_vep_port;
656 __be32 qpn;
657 __be32 reserved;
658};
659
660static void trans_rule_ctrl_to_hw(struct mlx4_net_trans_rule *ctrl, 653static void trans_rule_ctrl_to_hw(struct mlx4_net_trans_rule *ctrl,
661 struct mlx4_net_trans_rule_hw_ctrl *hw) 654 struct mlx4_net_trans_rule_hw_ctrl *hw)
662{ 655{
@@ -680,87 +673,18 @@ static void trans_rule_ctrl_to_hw(struct mlx4_net_trans_rule *ctrl,
680 hw->qpn = cpu_to_be32(ctrl->qpn); 673 hw->qpn = cpu_to_be32(ctrl->qpn);
681} 674}
682 675
683struct mlx4_net_trans_rule_hw_ib { 676const u16 __sw_id_hw[] = {
684 u8 size; 677 [MLX4_NET_TRANS_RULE_ID_ETH] = 0xE001,
685 u8 rsvd1; 678 [MLX4_NET_TRANS_RULE_ID_IB] = 0xE005,
686 __be16 id; 679 [MLX4_NET_TRANS_RULE_ID_IPV6] = 0xE003,
687 u32 rsvd2; 680 [MLX4_NET_TRANS_RULE_ID_IPV4] = 0xE002,
688 __be32 qpn; 681 [MLX4_NET_TRANS_RULE_ID_TCP] = 0xE004,
689 __be32 qpn_mask; 682 [MLX4_NET_TRANS_RULE_ID_UDP] = 0xE006
690 u8 dst_gid[16];
691 u8 dst_gid_msk[16];
692} __packed;
693
694struct mlx4_net_trans_rule_hw_eth {
695 u8 size;
696 u8 rsvd;
697 __be16 id;
698 u8 rsvd1[6];
699 u8 dst_mac[6];
700 u16 rsvd2;
701 u8 dst_mac_msk[6];
702 u16 rsvd3;
703 u8 src_mac[6];
704 u16 rsvd4;
705 u8 src_mac_msk[6];
706 u8 rsvd5;
707 u8 ether_type_enable;
708 __be16 ether_type;
709 __be16 vlan_id_msk;
710 __be16 vlan_id;
711} __packed;
712
713struct mlx4_net_trans_rule_hw_tcp_udp {
714 u8 size;
715 u8 rsvd;
716 __be16 id;
717 __be16 rsvd1[3];
718 __be16 dst_port;
719 __be16 rsvd2;
720 __be16 dst_port_msk;
721 __be16 rsvd3;
722 __be16 src_port;
723 __be16 rsvd4;
724 __be16 src_port_msk;
725} __packed;
726
727struct mlx4_net_trans_rule_hw_ipv4 {
728 u8 size;
729 u8 rsvd;
730 __be16 id;
731 __be32 rsvd1;
732 __be32 dst_ip;
733 __be32 dst_ip_msk;
734 __be32 src_ip;
735 __be32 src_ip_msk;
736} __packed;
737
738struct _rule_hw {
739 union {
740 struct {
741 u8 size;
742 u8 rsvd;
743 __be16 id;
744 };
745 struct mlx4_net_trans_rule_hw_eth eth;
746 struct mlx4_net_trans_rule_hw_ib ib;
747 struct mlx4_net_trans_rule_hw_ipv4 ipv4;
748 struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp;
749 };
750}; 683};
751 684
752static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec, 685static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec,
753 struct _rule_hw *rule_hw) 686 struct _rule_hw *rule_hw)
754{ 687{
755 static const u16 __sw_id_hw[] = {
756 [MLX4_NET_TRANS_RULE_ID_ETH] = 0xE001,
757 [MLX4_NET_TRANS_RULE_ID_IB] = 0xE005,
758 [MLX4_NET_TRANS_RULE_ID_IPV6] = 0xE003,
759 [MLX4_NET_TRANS_RULE_ID_IPV4] = 0xE002,
760 [MLX4_NET_TRANS_RULE_ID_TCP] = 0xE004,
761 [MLX4_NET_TRANS_RULE_ID_UDP] = 0xE006
762 };
763
764 static const size_t __rule_hw_sz[] = { 688 static const size_t __rule_hw_sz[] = {
765 [MLX4_NET_TRANS_RULE_ID_ETH] = 689 [MLX4_NET_TRANS_RULE_ID_ETH] =
766 sizeof(struct mlx4_net_trans_rule_hw_eth), 690 sizeof(struct mlx4_net_trans_rule_hw_eth),
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 4d9df8f2a126..dba69d98734a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -690,6 +690,82 @@ struct mlx4_steer {
690 struct list_head steer_entries[MLX4_NUM_STEERS]; 690 struct list_head steer_entries[MLX4_NUM_STEERS];
691}; 691};
692 692
693struct mlx4_net_trans_rule_hw_ctrl {
694 __be32 ctrl;
695 __be32 vf_vep_port;
696 __be32 qpn;
697 __be32 reserved;
698};
699
700struct mlx4_net_trans_rule_hw_ib {
701 u8 size;
702 u8 rsvd1;
703 __be16 id;
704 u32 rsvd2;
705 __be32 qpn;
706 __be32 qpn_mask;
707 u8 dst_gid[16];
708 u8 dst_gid_msk[16];
709} __packed;
710
711struct mlx4_net_trans_rule_hw_eth {
712 u8 size;
713 u8 rsvd;
714 __be16 id;
715 u8 rsvd1[6];
716 u8 dst_mac[6];
717 u16 rsvd2;
718 u8 dst_mac_msk[6];
719 u16 rsvd3;
720 u8 src_mac[6];
721 u16 rsvd4;
722 u8 src_mac_msk[6];
723 u8 rsvd5;
724 u8 ether_type_enable;
725 __be16 ether_type;
726 __be16 vlan_id_msk;
727 __be16 vlan_id;
728} __packed;
729
730struct mlx4_net_trans_rule_hw_tcp_udp {
731 u8 size;
732 u8 rsvd;
733 __be16 id;
734 __be16 rsvd1[3];
735 __be16 dst_port;
736 __be16 rsvd2;
737 __be16 dst_port_msk;
738 __be16 rsvd3;
739 __be16 src_port;
740 __be16 rsvd4;
741 __be16 src_port_msk;
742} __packed;
743
744struct mlx4_net_trans_rule_hw_ipv4 {
745 u8 size;
746 u8 rsvd;
747 __be16 id;
748 __be32 rsvd1;
749 __be32 dst_ip;
750 __be32 dst_ip_msk;
751 __be32 src_ip;
752 __be32 src_ip_msk;
753} __packed;
754
755struct _rule_hw {
756 union {
757 struct {
758 u8 size;
759 u8 rsvd;
760 __be16 id;
761 };
762 struct mlx4_net_trans_rule_hw_eth eth;
763 struct mlx4_net_trans_rule_hw_ib ib;
764 struct mlx4_net_trans_rule_hw_ipv4 ipv4;
765 struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp;
766 };
767};
768
693struct mlx4_priv { 769struct mlx4_priv {
694 struct mlx4_dev dev; 770 struct mlx4_dev dev;
695 771
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 94ceddd17ab2..293c9e820c49 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -42,6 +42,7 @@
42#include <linux/mlx4/cmd.h> 42#include <linux/mlx4/cmd.h>
43#include <linux/mlx4/qp.h> 43#include <linux/mlx4/qp.h>
44#include <linux/if_ether.h> 44#include <linux/if_ether.h>
45#include <linux/etherdevice.h>
45 46
46#include "mlx4.h" 47#include "mlx4.h"
47#include "fw.h" 48#include "fw.h"
@@ -2776,18 +2777,133 @@ ex_put:
2776 return err; 2777 return err;
2777} 2778}
2778 2779
2780/*
2781 * MAC validation for Flow Steering rules.
2782 * VF can attach rules only with a mac address which is assigned to it.
2783 */
2784static int validate_eth_header_mac(int slave, struct _rule_hw *eth_header,
2785 struct list_head *rlist)
2786{
2787 struct mac_res *res, *tmp;
2788 __be64 be_mac;
2789
2790 /* make sure it isn't multicast or broadcast mac*/
2791 if (!is_multicast_ether_addr(eth_header->eth.dst_mac) &&
2792 !is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
2793 list_for_each_entry_safe(res, tmp, rlist, list) {
2794 be_mac = cpu_to_be64(res->mac << 16);
2795 if (!memcmp(&be_mac, eth_header->eth.dst_mac, ETH_ALEN))
2796 return 0;
2797 }
2798 pr_err("MAC %pM doesn't belong to VF %d, Steering rule rejected\n",
2799 eth_header->eth.dst_mac, slave);
2800 return -EINVAL;
2801 }
2802 return 0;
2803}
2804
2805/*
2806 * In case of missing eth header, append eth header with a MAC address
2807 * assigned to the VF.
2808 */
2809static int add_eth_header(struct mlx4_dev *dev, int slave,
2810 struct mlx4_cmd_mailbox *inbox,
2811 struct list_head *rlist, int header_id)
2812{
2813 struct mac_res *res, *tmp;
2814 u8 port;
2815 struct mlx4_net_trans_rule_hw_ctrl *ctrl;
2816 struct mlx4_net_trans_rule_hw_eth *eth_header;
2817 struct mlx4_net_trans_rule_hw_ipv4 *ip_header;
2818 struct mlx4_net_trans_rule_hw_tcp_udp *l4_header;
2819 __be64 be_mac = 0;
2820 __be64 mac_msk = cpu_to_be64(MLX4_MAC_MASK << 16);
2821
2822 ctrl = (struct mlx4_net_trans_rule_hw_ctrl *)inbox->buf;
2823 port = be32_to_cpu(ctrl->vf_vep_port) & 0xff;
2824 eth_header = (struct mlx4_net_trans_rule_hw_eth *)(ctrl + 1);
2825
2826 /* Clear a space in the inbox for eth header */
2827 switch (header_id) {
2828 case MLX4_NET_TRANS_RULE_ID_IPV4:
2829 ip_header =
2830 (struct mlx4_net_trans_rule_hw_ipv4 *)(eth_header + 1);
2831 memmove(ip_header, eth_header,
2832 sizeof(*ip_header) + sizeof(*l4_header));
2833 break;
2834 case MLX4_NET_TRANS_RULE_ID_TCP:
2835 case MLX4_NET_TRANS_RULE_ID_UDP:
2836 l4_header = (struct mlx4_net_trans_rule_hw_tcp_udp *)
2837 (eth_header + 1);
2838 memmove(l4_header, eth_header, sizeof(*l4_header));
2839 break;
2840 default:
2841 return -EINVAL;
2842 }
2843 list_for_each_entry_safe(res, tmp, rlist, list) {
2844 if (port == res->port) {
2845 be_mac = cpu_to_be64(res->mac << 16);
2846 break;
2847 }
2848 }
2849 if (!be_mac) {
2850 pr_err("Failed adding eth header to FS rule, Can't find matching MAC for port %d .\n",
2851 port);
2852 return -EINVAL;
2853 }
2854
2855 memset(eth_header, 0, sizeof(*eth_header));
2856 eth_header->size = sizeof(*eth_header) >> 2;
2857 eth_header->id = cpu_to_be16(__sw_id_hw[MLX4_NET_TRANS_RULE_ID_ETH]);
2858 memcpy(eth_header->dst_mac, &be_mac, ETH_ALEN);
2859 memcpy(eth_header->dst_mac_msk, &mac_msk, ETH_ALEN);
2860
2861 return 0;
2862
2863}
2864
2779int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, 2865int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
2780 struct mlx4_vhcr *vhcr, 2866 struct mlx4_vhcr *vhcr,
2781 struct mlx4_cmd_mailbox *inbox, 2867 struct mlx4_cmd_mailbox *inbox,
2782 struct mlx4_cmd_mailbox *outbox, 2868 struct mlx4_cmd_mailbox *outbox,
2783 struct mlx4_cmd_info *cmd) 2869 struct mlx4_cmd_info *cmd)
2784{ 2870{
2871
2872 struct mlx4_priv *priv = mlx4_priv(dev);
2873 struct mlx4_resource_tracker *tracker = &priv->mfunc.master.res_tracker;
2874 struct list_head *rlist = &tracker->slave_list[slave].res_list[RES_MAC];
2785 int err; 2875 int err;
2876 struct mlx4_net_trans_rule_hw_ctrl *ctrl;
2877 struct _rule_hw *rule_header;
2878 int header_id;
2786 2879
2787 if (dev->caps.steering_mode != 2880 if (dev->caps.steering_mode !=
2788 MLX4_STEERING_MODE_DEVICE_MANAGED) 2881 MLX4_STEERING_MODE_DEVICE_MANAGED)
2789 return -EOPNOTSUPP; 2882 return -EOPNOTSUPP;
2790 2883
2884 ctrl = (struct mlx4_net_trans_rule_hw_ctrl *)inbox->buf;
2885 rule_header = (struct _rule_hw *)(ctrl + 1);
2886 header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id));
2887
2888 switch (header_id) {
2889 case MLX4_NET_TRANS_RULE_ID_ETH:
2890 if (validate_eth_header_mac(slave, rule_header, rlist))
2891 return -EINVAL;
2892 break;
2893 case MLX4_NET_TRANS_RULE_ID_IPV4:
2894 case MLX4_NET_TRANS_RULE_ID_TCP:
2895 case MLX4_NET_TRANS_RULE_ID_UDP:
2896 pr_warn("Can't attach FS rule without L2 headers, adding L2 header.\n");
2897 if (add_eth_header(dev, slave, inbox, rlist, header_id))
2898 return -EINVAL;
2899 vhcr->in_modifier +=
2900 sizeof(struct mlx4_net_trans_rule_hw_eth) >> 2;
2901 break;
2902 default:
2903 pr_err("Corrupted mailbox.\n");
2904 return -EINVAL;
2905 }
2906
2791 err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param, 2907 err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param,
2792 vhcr->in_modifier, 0, 2908 vhcr->in_modifier, 0,
2793 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A, 2909 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 342b3a79bd0f..a77c558d8f40 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -1378,6 +1378,10 @@ static void netxen_mask_aer_correctable(struct netxen_adapter *adapter)
1378 struct pci_dev *root = pdev->bus->self; 1378 struct pci_dev *root = pdev->bus->self;
1379 u32 aer_pos; 1379 u32 aer_pos;
1380 1380
1381 /* root bus? */
1382 if (!root)
1383 return;
1384
1381 if (adapter->ahw.board_type != NETXEN_BRDTYPE_P3_4_GB_MM && 1385 if (adapter->ahw.board_type != NETXEN_BRDTYPE_P3_4_GB_MM &&
1382 adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP) 1386 adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP)
1383 return; 1387 return;
diff --git a/drivers/net/ethernet/seeq/sgiseeq.c b/drivers/net/ethernet/seeq/sgiseeq.c
index bb8c8222122b..4d15bf413bdc 100644
--- a/drivers/net/ethernet/seeq/sgiseeq.c
+++ b/drivers/net/ethernet/seeq/sgiseeq.c
@@ -751,6 +751,7 @@ static int __devinit sgiseeq_probe(struct platform_device *pdev)
751 sp->srings = sr; 751 sp->srings = sr;
752 sp->rx_desc = sp->srings->rxvector; 752 sp->rx_desc = sp->srings->rxvector;
753 sp->tx_desc = sp->srings->txvector; 753 sp->tx_desc = sp->srings->txvector;
754 spin_lock_init(&sp->tx_lock);
754 755
755 /* A couple calculations now, saves many cycles later. */ 756 /* A couple calculations now, saves many cycles later. */
756 setup_rx_ring(dev, sp->rx_desc, SEEQ_RX_BUFFERS); 757 setup_rx_ring(dev, sp->rx_desc, SEEQ_RX_BUFFERS);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c136162e6473..3be88331d17a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1066,7 +1066,7 @@ static int stmmac_open(struct net_device *dev)
1066 } else 1066 } else
1067 priv->tm->enable = 1; 1067 priv->tm->enable = 1;
1068#endif 1068#endif
1069 clk_enable(priv->stmmac_clk); 1069 clk_prepare_enable(priv->stmmac_clk);
1070 1070
1071 stmmac_check_ether_addr(priv); 1071 stmmac_check_ether_addr(priv);
1072 1072
@@ -1188,7 +1188,7 @@ open_error:
1188 if (priv->phydev) 1188 if (priv->phydev)
1189 phy_disconnect(priv->phydev); 1189 phy_disconnect(priv->phydev);
1190 1190
1191 clk_disable(priv->stmmac_clk); 1191 clk_disable_unprepare(priv->stmmac_clk);
1192 1192
1193 return ret; 1193 return ret;
1194} 1194}
@@ -1246,7 +1246,7 @@ static int stmmac_release(struct net_device *dev)
1246#ifdef CONFIG_STMMAC_DEBUG_FS 1246#ifdef CONFIG_STMMAC_DEBUG_FS
1247 stmmac_exit_fs(); 1247 stmmac_exit_fs();
1248#endif 1248#endif
1249 clk_disable(priv->stmmac_clk); 1249 clk_disable_unprepare(priv->stmmac_clk);
1250 1250
1251 return 0; 1251 return 0;
1252} 1252}
@@ -2178,7 +2178,7 @@ int stmmac_suspend(struct net_device *ndev)
2178 else { 2178 else {
2179 stmmac_set_mac(priv->ioaddr, false); 2179 stmmac_set_mac(priv->ioaddr, false);
2180 /* Disable clock in case of PWM is off */ 2180 /* Disable clock in case of PWM is off */
2181 clk_disable(priv->stmmac_clk); 2181 clk_disable_unprepare(priv->stmmac_clk);
2182 } 2182 }
2183 spin_unlock_irqrestore(&priv->lock, flags); 2183 spin_unlock_irqrestore(&priv->lock, flags);
2184 return 0; 2184 return 0;
@@ -2203,7 +2203,7 @@ int stmmac_resume(struct net_device *ndev)
2203 priv->hw->mac->pmt(priv->ioaddr, 0); 2203 priv->hw->mac->pmt(priv->ioaddr, 0);
2204 else 2204 else
2205 /* enable the clk prevously disabled */ 2205 /* enable the clk prevously disabled */
2206 clk_enable(priv->stmmac_clk); 2206 clk_prepare_enable(priv->stmmac_clk);
2207 2207
2208 netif_device_attach(ndev); 2208 netif_device_attach(ndev);
2209 2209
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c
index 2a0e1abde7e7..4ccd4e2977b7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c
@@ -97,19 +97,19 @@ static struct clk *timer_clock;
97static void stmmac_tmu_start(unsigned int new_freq) 97static void stmmac_tmu_start(unsigned int new_freq)
98{ 98{
99 clk_set_rate(timer_clock, new_freq); 99 clk_set_rate(timer_clock, new_freq);
100 clk_enable(timer_clock); 100 clk_prepare_enable(timer_clock);
101} 101}
102 102
103static void stmmac_tmu_stop(void) 103static void stmmac_tmu_stop(void)
104{ 104{
105 clk_disable(timer_clock); 105 clk_disable_unprepare(timer_clock);
106} 106}
107 107
108int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm) 108int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm)
109{ 109{
110 timer_clock = clk_get(NULL, TMU_CHANNEL); 110 timer_clock = clk_get(NULL, TMU_CHANNEL);
111 111
112 if (timer_clock == NULL) 112 if (IS_ERR(timer_clock))
113 return -1; 113 return -1;
114 114
115 if (tmu2_register_user(stmmac_timer_handler, (void *)dev) < 0) { 115 if (tmu2_register_user(stmmac_timer_handler, (void *)dev) < 0) {
@@ -126,7 +126,7 @@ int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm)
126 126
127int stmmac_close_ext_timer(void) 127int stmmac_close_ext_timer(void)
128{ 128{
129 clk_disable(timer_clock); 129 clk_disable_unprepare(timer_clock);
130 tmu2_unregister_user(); 130 tmu2_unregister_user();
131 clk_put(timer_clock); 131 clk_put(timer_clock);
132 return 0; 132 return 0;
diff --git a/drivers/net/irda/sh_sir.c b/drivers/net/irda/sh_sir.c
index 256eddf1f75a..795109425568 100644
--- a/drivers/net/irda/sh_sir.c
+++ b/drivers/net/irda/sh_sir.c
@@ -280,7 +280,7 @@ static int sh_sir_set_baudrate(struct sh_sir_self *self, u32 baudrate)
280 } 280 }
281 281
282 clk = clk_get(NULL, "irda_clk"); 282 clk = clk_get(NULL, "irda_clk");
283 if (!clk) { 283 if (IS_ERR(clk)) {
284 dev_err(dev, "can not get irda_clk\n"); 284 dev_err(dev, "can not get irda_clk\n");
285 return -EIO; 285 return -EIO;
286 } 286 }
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 4fd48df6b989..32e31c5c5dc6 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -962,6 +962,10 @@ static const struct usb_device_id products [] = {
962 USB_DEVICE (0x2001, 0x3c05), 962 USB_DEVICE (0x2001, 0x3c05),
963 .driver_info = (unsigned long) &ax88772_info, 963 .driver_info = (unsigned long) &ax88772_info,
964}, { 964}, {
965 // DLink DUB-E100 H/W Ver C1
966 USB_DEVICE (0x2001, 0x1a02),
967 .driver_info = (unsigned long) &ax88772_info,
968}, {
965 // Linksys USB1000 969 // Linksys USB1000
966 USB_DEVICE (0x1737, 0x0039), 970 USB_DEVICE (0x1737, 0x0039),
967 .driver_info = (unsigned long) &ax88178_info, 971 .driver_info = (unsigned long) &ax88178_info,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index adfab3fc5478..3543c9e57824 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -297,7 +297,7 @@ static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
297 if (ret < 0) 297 if (ret < 0)
298 goto err; 298 goto err;
299 299
300 if (info->subdriver && info->subdriver->suspend) 300 if (intf == info->control && info->subdriver && info->subdriver->suspend)
301 ret = info->subdriver->suspend(intf, message); 301 ret = info->subdriver->suspend(intf, message);
302 if (ret < 0) 302 if (ret < 0)
303 usbnet_resume(intf); 303 usbnet_resume(intf);
@@ -310,13 +310,14 @@ static int qmi_wwan_resume(struct usb_interface *intf)
310 struct usbnet *dev = usb_get_intfdata(intf); 310 struct usbnet *dev = usb_get_intfdata(intf);
311 struct qmi_wwan_state *info = (void *)&dev->data; 311 struct qmi_wwan_state *info = (void *)&dev->data;
312 int ret = 0; 312 int ret = 0;
313 bool callsub = (intf == info->control && info->subdriver && info->subdriver->resume);
313 314
314 if (info->subdriver && info->subdriver->resume) 315 if (callsub)
315 ret = info->subdriver->resume(intf); 316 ret = info->subdriver->resume(intf);
316 if (ret < 0) 317 if (ret < 0)
317 goto err; 318 goto err;
318 ret = usbnet_resume(intf); 319 ret = usbnet_resume(intf);
319 if (ret < 0 && info->subdriver && info->subdriver->resume && info->subdriver->suspend) 320 if (ret < 0 && callsub && info->subdriver->suspend)
320 info->subdriver->suspend(intf, PMSG_SUSPEND); 321 info->subdriver->suspend(intf, PMSG_SUSPEND);
321err: 322err:
322 return ret; 323 return ret;
@@ -365,16 +366,20 @@ static const struct usb_device_id products[] = {
365 }, 366 },
366 367
367 /* 2. Combined interface devices matching on class+protocol */ 368 /* 2. Combined interface devices matching on class+protocol */
369 { /* Huawei E367 and possibly others in "Windows mode" */
370 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
371 .driver_info = (unsigned long)&qmi_wwan_info,
372 },
368 { /* Huawei E392, E398 and possibly others in "Windows mode" */ 373 { /* Huawei E392, E398 and possibly others in "Windows mode" */
369 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17), 374 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
370 .driver_info = (unsigned long)&qmi_wwan_shared, 375 .driver_info = (unsigned long)&qmi_wwan_shared,
371 }, 376 },
372 { /* Pantech UML290 */ 377 { /* Pantech UML290, P4200 and more */
373 USB_DEVICE_AND_INTERFACE_INFO(0x106c, 0x3718, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff), 378 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
374 .driver_info = (unsigned long)&qmi_wwan_shared, 379 .driver_info = (unsigned long)&qmi_wwan_shared,
375 }, 380 },
376 { /* Pantech UML290 - newer firmware */ 381 { /* Pantech UML290 - newer firmware */
377 USB_DEVICE_AND_INTERFACE_INFO(0x106c, 0x3718, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff), 382 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
378 .driver_info = (unsigned long)&qmi_wwan_shared, 383 .driver_info = (unsigned long)&qmi_wwan_shared,
379 }, 384 },
380 385
@@ -382,6 +387,7 @@ static const struct usb_device_id products[] = {
382 {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */ 387 {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */
383 {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */ 388 {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */
384 {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */ 389 {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */
390 {QMI_FIXED_INTF(0x19d2, 0x0157, 5)}, /* ZTE MF683 */
385 {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */ 391 {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */
386 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */ 392 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */
387 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */ 393 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */
@@ -398,7 +404,6 @@ static const struct usb_device_id products[] = {
398 /* 4. Gobi 1000 devices */ 404 /* 4. Gobi 1000 devices */
399 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 405 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
400 {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */ 406 {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
401 {QMI_GOBI1K_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
402 {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */ 407 {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
403 {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */ 408 {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
404 {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */ 409 {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
@@ -440,6 +445,7 @@ static const struct usb_device_id products[] = {
440 {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */ 445 {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
441 {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */ 446 {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
442 {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */ 447 {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
448 {QMI_GOBI_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
443 {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */ 449 {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
444 {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */ 450 {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
445 {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */ 451 {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 7be49ea60b6d..8e22417fa6c1 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -656,7 +656,7 @@ static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap)
656 return -EIO; 656 return -EIO;
657 } 657 }
658 658
659 *datap = *attrdata; 659 *datap = le16_to_cpu(*attrdata);
660 660
661 kfree(attrdata); 661 kfree(attrdata);
662 return result; 662 return result;
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index fd4b26d46fd5..fc9f578a1e25 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1201,19 +1201,26 @@ deferred:
1201} 1201}
1202EXPORT_SYMBOL_GPL(usbnet_start_xmit); 1202EXPORT_SYMBOL_GPL(usbnet_start_xmit);
1203 1203
1204static void rx_alloc_submit(struct usbnet *dev, gfp_t flags) 1204static int rx_alloc_submit(struct usbnet *dev, gfp_t flags)
1205{ 1205{
1206 struct urb *urb; 1206 struct urb *urb;
1207 int i; 1207 int i;
1208 int ret = 0;
1208 1209
1209 /* don't refill the queue all at once */ 1210 /* don't refill the queue all at once */
1210 for (i = 0; i < 10 && dev->rxq.qlen < RX_QLEN(dev); i++) { 1211 for (i = 0; i < 10 && dev->rxq.qlen < RX_QLEN(dev); i++) {
1211 urb = usb_alloc_urb(0, flags); 1212 urb = usb_alloc_urb(0, flags);
1212 if (urb != NULL) { 1213 if (urb != NULL) {
1213 if (rx_submit(dev, urb, flags) == -ENOLINK) 1214 ret = rx_submit(dev, urb, flags);
1214 return; 1215 if (ret)
1216 goto err;
1217 } else {
1218 ret = -ENOMEM;
1219 goto err;
1215 } 1220 }
1216 } 1221 }
1222err:
1223 return ret;
1217} 1224}
1218 1225
1219/*-------------------------------------------------------------------------*/ 1226/*-------------------------------------------------------------------------*/
@@ -1257,7 +1264,8 @@ static void usbnet_bh (unsigned long param)
1257 int temp = dev->rxq.qlen; 1264 int temp = dev->rxq.qlen;
1258 1265
1259 if (temp < RX_QLEN(dev)) { 1266 if (temp < RX_QLEN(dev)) {
1260 rx_alloc_submit(dev, GFP_ATOMIC); 1267 if (rx_alloc_submit(dev, GFP_ATOMIC) == -ENOLINK)
1268 return;
1261 if (temp != dev->rxq.qlen) 1269 if (temp != dev->rxq.qlen)
1262 netif_dbg(dev, link, dev->net, 1270 netif_dbg(dev, link, dev->net,
1263 "rxqlen %d --> %d\n", 1271 "rxqlen %d --> %d\n",
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index aaaca9aa2293..3f575afd8cfc 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -10,6 +10,7 @@
10 10
11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12 12
13#include <linux/module.h>
13#include <linux/bitops.h> 14#include <linux/bitops.h>
14#include <linux/cdev.h> 15#include <linux/cdev.h>
15#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 2588848f4a82..d066f2516e47 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -2982,6 +2982,10 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
2982 case EEP_RX_MASK: 2982 case EEP_RX_MASK:
2983 return pBase->txrxMask & 0xf; 2983 return pBase->txrxMask & 0xf;
2984 case EEP_PAPRD: 2984 case EEP_PAPRD:
2985 if (AR_SREV_9462(ah))
2986 return false;
2987 if (!ah->config.enable_paprd);
2988 return false;
2985 return !!(pBase->featureEnable & BIT(5)); 2989 return !!(pBase->featureEnable & BIT(5));
2986 case EEP_CHAIN_MASK_REDUCE: 2990 case EEP_CHAIN_MASK_REDUCE:
2987 return (pBase->miscConfiguration >> 0x3) & 0x1; 2991 return (pBase->miscConfiguration >> 0x3) & 0x1;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
index 2c9f7d7ed4cc..0ed3846f9cbb 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
@@ -142,6 +142,7 @@ static int ar9003_paprd_setup_single_table(struct ath_hw *ah)
142 }; 142 };
143 int training_power; 143 int training_power;
144 int i, val; 144 int i, val;
145 u32 am2pm_mask = ah->paprd_ratemask;
145 146
146 if (IS_CHAN_2GHZ(ah->curchan)) 147 if (IS_CHAN_2GHZ(ah->curchan))
147 training_power = ar9003_get_training_power_2g(ah); 148 training_power = ar9003_get_training_power_2g(ah);
@@ -158,10 +159,13 @@ static int ar9003_paprd_setup_single_table(struct ath_hw *ah)
158 } 159 }
159 ah->paprd_training_power = training_power; 160 ah->paprd_training_power = training_power;
160 161
162 if (AR_SREV_9330(ah))
163 am2pm_mask = 0;
164
161 REG_RMW_FIELD(ah, AR_PHY_PAPRD_AM2AM, AR_PHY_PAPRD_AM2AM_MASK, 165 REG_RMW_FIELD(ah, AR_PHY_PAPRD_AM2AM, AR_PHY_PAPRD_AM2AM_MASK,
162 ah->paprd_ratemask); 166 ah->paprd_ratemask);
163 REG_RMW_FIELD(ah, AR_PHY_PAPRD_AM2PM, AR_PHY_PAPRD_AM2PM_MASK, 167 REG_RMW_FIELD(ah, AR_PHY_PAPRD_AM2PM, AR_PHY_PAPRD_AM2PM_MASK,
164 ah->paprd_ratemask); 168 am2pm_mask);
165 REG_RMW_FIELD(ah, AR_PHY_PAPRD_HT40, AR_PHY_PAPRD_HT40_MASK, 169 REG_RMW_FIELD(ah, AR_PHY_PAPRD_HT40, AR_PHY_PAPRD_HT40_MASK,
166 ah->paprd_ratemask_ht40); 170 ah->paprd_ratemask_ht40);
167 171
@@ -782,6 +786,102 @@ int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain)
782} 786}
783EXPORT_SYMBOL(ar9003_paprd_setup_gain_table); 787EXPORT_SYMBOL(ar9003_paprd_setup_gain_table);
784 788
789static bool ar9003_paprd_retrain_pa_in(struct ath_hw *ah,
790 struct ath9k_hw_cal_data *caldata,
791 int chain)
792{
793 u32 *pa_in = caldata->pa_table[chain];
794 int capdiv_offset, quick_drop_offset;
795 int capdiv2g, quick_drop;
796 int count = 0;
797 int i;
798
799 if (!AR_SREV_9485(ah) && !AR_SREV_9330(ah))
800 return false;
801
802 capdiv2g = REG_READ_FIELD(ah, AR_PHY_65NM_CH0_TXRF3,
803 AR_PHY_65NM_CH0_TXRF3_CAPDIV2G);
804
805 quick_drop = REG_READ_FIELD(ah, AR_PHY_PAPRD_TRAINER_CNTL3,
806 AR_PHY_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP);
807
808 if (quick_drop)
809 quick_drop -= 0x40;
810
811 for (i = 0; i < NUM_BIN + 1; i++) {
812 if (pa_in[i] == 1400)
813 count++;
814 }
815
816 if (AR_SREV_9485(ah)) {
817 if (pa_in[23] < 800) {
818 capdiv_offset = (int)((1000 - pa_in[23] + 75) / 150);
819 capdiv2g += capdiv_offset;
820 if (capdiv2g > 7) {
821 capdiv2g = 7;
822 if (pa_in[23] < 600) {
823 quick_drop++;
824 if (quick_drop > 0)
825 quick_drop = 0;
826 }
827 }
828 } else if (pa_in[23] == 1400) {
829 quick_drop_offset = min_t(int, count / 3, 2);
830 quick_drop += quick_drop_offset;
831 capdiv2g += quick_drop_offset / 2;
832
833 if (capdiv2g > 7)
834 capdiv2g = 7;
835
836 if (quick_drop > 0) {
837 quick_drop = 0;
838 capdiv2g -= quick_drop_offset;
839 if (capdiv2g < 0)
840 capdiv2g = 0;
841 }
842 } else {
843 return false;
844 }
845 } else if (AR_SREV_9330(ah)) {
846 if (pa_in[23] < 1000) {
847 capdiv_offset = (1000 - pa_in[23]) / 100;
848 capdiv2g += capdiv_offset;
849 if (capdiv_offset > 3) {
850 capdiv_offset = 1;
851 quick_drop--;
852 }
853
854 capdiv2g += capdiv_offset;
855 if (capdiv2g > 6)
856 capdiv2g = 6;
857 if (quick_drop < -4)
858 quick_drop = -4;
859 } else if (pa_in[23] == 1400) {
860 if (count > 3) {
861 quick_drop++;
862 capdiv2g -= count / 4;
863 if (quick_drop > -2)
864 quick_drop = -2;
865 } else {
866 capdiv2g--;
867 }
868
869 if (capdiv2g < 0)
870 capdiv2g = 0;
871 } else {
872 return false;
873 }
874 }
875
876 REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_TXRF3,
877 AR_PHY_65NM_CH0_TXRF3_CAPDIV2G, capdiv2g);
878 REG_RMW_FIELD(ah, AR_PHY_PAPRD_TRAINER_CNTL3,
879 AR_PHY_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP,
880 quick_drop);
881
882 return true;
883}
884
785int ar9003_paprd_create_curve(struct ath_hw *ah, 885int ar9003_paprd_create_curve(struct ath_hw *ah,
786 struct ath9k_hw_cal_data *caldata, int chain) 886 struct ath9k_hw_cal_data *caldata, int chain)
787{ 887{
@@ -817,6 +917,9 @@ int ar9003_paprd_create_curve(struct ath_hw *ah,
817 if (!create_pa_curve(data_L, data_U, pa_table, small_signal_gain)) 917 if (!create_pa_curve(data_L, data_U, pa_table, small_signal_gain))
818 status = -2; 918 status = -2;
819 919
920 if (ar9003_paprd_retrain_pa_in(ah, caldata, chain))
921 status = -EINPROGRESS;
922
820 REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1, 923 REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1,
821 AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE); 924 AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE);
822 925
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
index 7bfbaf065a43..84d3d4956861 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
@@ -625,6 +625,10 @@
625#define AR_PHY_AIC_CTRL_4_B0 (AR_SM_BASE + 0x4c0) 625#define AR_PHY_AIC_CTRL_4_B0 (AR_SM_BASE + 0x4c0)
626#define AR_PHY_AIC_STAT_2_B0 (AR_SM_BASE + 0x4cc) 626#define AR_PHY_AIC_STAT_2_B0 (AR_SM_BASE + 0x4cc)
627 627
628#define AR_PHY_65NM_CH0_TXRF3 0x16048
629#define AR_PHY_65NM_CH0_TXRF3_CAPDIV2G 0x0000001e
630#define AR_PHY_65NM_CH0_TXRF3_CAPDIV2G_S 1
631
628#define AR_PHY_65NM_CH0_SYNTH4 0x1608c 632#define AR_PHY_65NM_CH0_SYNTH4 0x1608c
629#define AR_PHY_SYNTH4_LONG_SHIFT_SELECT (AR_SREV_9462(ah) ? 0x00000001 : 0x00000002) 633#define AR_PHY_SYNTH4_LONG_SHIFT_SELECT (AR_SREV_9462(ah) ? 0x00000001 : 0x00000002)
630#define AR_PHY_SYNTH4_LONG_SHIFT_SELECT_S (AR_SREV_9462(ah) ? 0 : 1) 634#define AR_PHY_SYNTH4_LONG_SHIFT_SELECT_S (AR_SREV_9462(ah) ? 0 : 1)
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 68b643c8943c..c8ef30127adb 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -1577,6 +1577,8 @@ int ath9k_init_debug(struct ath_hw *ah)
1577 sc->debug.debugfs_phy, sc, &fops_tx_chainmask); 1577 sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
1578 debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR, 1578 debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
1579 sc->debug.debugfs_phy, sc, &fops_disable_ani); 1579 sc->debug.debugfs_phy, sc, &fops_disable_ani);
1580 debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1581 &sc->sc_ah->config.enable_paprd);
1580 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1582 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1581 sc, &fops_regidx); 1583 sc, &fops_regidx);
1582 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1584 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c
index bacdb8fb4ef4..9f83f71742a5 100644
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
@@ -341,7 +341,8 @@ void ath9k_btcoex_stop_gen_timer(struct ath_softc *sc)
341{ 341{
342 struct ath_btcoex *btcoex = &sc->btcoex; 342 struct ath_btcoex *btcoex = &sc->btcoex;
343 343
344 ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer); 344 if (btcoex->hw_timer_enabled)
345 ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
345} 346}
346 347
347u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen) 348u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen)
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 60b6a9daff7e..4faf0a395876 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -463,9 +463,6 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
463 ah->config.spurchans[i][1] = AR_NO_SPUR; 463 ah->config.spurchans[i][1] = AR_NO_SPUR;
464 } 464 }
465 465
466 /* PAPRD needs some more work to be enabled */
467 ah->config.paprd_disable = 1;
468
469 ah->config.rx_intr_mitigation = true; 466 ah->config.rx_intr_mitigation = true;
470 ah->config.pcieSerDesWrite = true; 467 ah->config.pcieSerDesWrite = true;
471 468
@@ -978,9 +975,6 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
978 else 975 else
979 imr_reg |= AR_IMR_TXOK; 976 imr_reg |= AR_IMR_TXOK;
980 977
981 if (opmode == NL80211_IFTYPE_AP)
982 imr_reg |= AR_IMR_MIB;
983
984 ENABLE_REGWRITE_BUFFER(ah); 978 ENABLE_REGWRITE_BUFFER(ah);
985 979
986 REG_WRITE(ah, AR_IMR, imr_reg); 980 REG_WRITE(ah, AR_IMR, imr_reg);
@@ -1778,6 +1772,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1778 /* Operating channel changed, reset channel calibration data */ 1772 /* Operating channel changed, reset channel calibration data */
1779 memset(caldata, 0, sizeof(*caldata)); 1773 memset(caldata, 0, sizeof(*caldata));
1780 ath9k_init_nfcal_hist_buffer(ah, chan); 1774 ath9k_init_nfcal_hist_buffer(ah, chan);
1775 } else if (caldata) {
1776 caldata->paprd_packet_sent = false;
1781 } 1777 }
1782 ah->noise = ath9k_hw_getchan_noise(ah, chan); 1778 ah->noise = ath9k_hw_getchan_noise(ah, chan);
1783 1779
@@ -2501,9 +2497,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2501 pCap->rx_status_len = sizeof(struct ar9003_rxs); 2497 pCap->rx_status_len = sizeof(struct ar9003_rxs);
2502 pCap->tx_desc_len = sizeof(struct ar9003_txc); 2498 pCap->tx_desc_len = sizeof(struct ar9003_txc);
2503 pCap->txs_len = sizeof(struct ar9003_txs); 2499 pCap->txs_len = sizeof(struct ar9003_txs);
2504 if (!ah->config.paprd_disable &&
2505 ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
2506 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
2507 } else { 2500 } else {
2508 pCap->tx_desc_len = sizeof(struct ath_desc); 2501 pCap->tx_desc_len = sizeof(struct ath_desc);
2509 if (AR_SREV_9280_20(ah)) 2502 if (AR_SREV_9280_20(ah))
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index ce7332c64efb..de6968fc64f4 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -236,7 +236,6 @@ enum ath9k_hw_caps {
236 ATH9K_HW_CAP_LDPC = BIT(6), 236 ATH9K_HW_CAP_LDPC = BIT(6),
237 ATH9K_HW_CAP_FASTCLOCK = BIT(7), 237 ATH9K_HW_CAP_FASTCLOCK = BIT(7),
238 ATH9K_HW_CAP_SGI_20 = BIT(8), 238 ATH9K_HW_CAP_SGI_20 = BIT(8),
239 ATH9K_HW_CAP_PAPRD = BIT(9),
240 ATH9K_HW_CAP_ANT_DIV_COMB = BIT(10), 239 ATH9K_HW_CAP_ANT_DIV_COMB = BIT(10),
241 ATH9K_HW_CAP_2GHZ = BIT(11), 240 ATH9K_HW_CAP_2GHZ = BIT(11),
242 ATH9K_HW_CAP_5GHZ = BIT(12), 241 ATH9K_HW_CAP_5GHZ = BIT(12),
@@ -287,12 +286,12 @@ struct ath9k_ops_config {
287 u8 pcie_clock_req; 286 u8 pcie_clock_req;
288 u32 pcie_waen; 287 u32 pcie_waen;
289 u8 analog_shiftreg; 288 u8 analog_shiftreg;
290 u8 paprd_disable;
291 u32 ofdm_trig_low; 289 u32 ofdm_trig_low;
292 u32 ofdm_trig_high; 290 u32 ofdm_trig_high;
293 u32 cck_trig_high; 291 u32 cck_trig_high;
294 u32 cck_trig_low; 292 u32 cck_trig_low;
295 u32 enable_ani; 293 u32 enable_ani;
294 u32 enable_paprd;
296 int serialize_regmode; 295 int serialize_regmode;
297 bool rx_intr_mitigation; 296 bool rx_intr_mitigation;
298 bool tx_intr_mitigation; 297 bool tx_intr_mitigation;
@@ -405,6 +404,7 @@ struct ath9k_hw_cal_data {
405 int8_t iCoff; 404 int8_t iCoff;
406 int8_t qCoff; 405 int8_t qCoff;
407 bool rtt_done; 406 bool rtt_done;
407 bool paprd_packet_sent;
408 bool paprd_done; 408 bool paprd_done;
409 bool nfcal_pending; 409 bool nfcal_pending;
410 bool nfcal_interference; 410 bool nfcal_interference;
diff --git a/drivers/net/wireless/ath/ath9k/link.c b/drivers/net/wireless/ath/ath9k/link.c
index d4549e9aac5c..7b88b9c39ccd 100644
--- a/drivers/net/wireless/ath/ath9k/link.c
+++ b/drivers/net/wireless/ath/ath9k/link.c
@@ -254,8 +254,9 @@ void ath_paprd_calibrate(struct work_struct *work)
254 int chain_ok = 0; 254 int chain_ok = 0;
255 int chain; 255 int chain;
256 int len = 1800; 256 int len = 1800;
257 int ret;
257 258
258 if (!caldata) 259 if (!caldata || !caldata->paprd_packet_sent || caldata->paprd_done)
259 return; 260 return;
260 261
261 ath9k_ps_wakeup(sc); 262 ath9k_ps_wakeup(sc);
@@ -282,13 +283,6 @@ void ath_paprd_calibrate(struct work_struct *work)
282 continue; 283 continue;
283 284
284 chain_ok = 0; 285 chain_ok = 0;
285
286 ath_dbg(common, CALIBRATE,
287 "Sending PAPRD frame for thermal measurement on chain %d\n",
288 chain);
289 if (!ath_paprd_send_frame(sc, skb, chain))
290 goto fail_paprd;
291
292 ar9003_paprd_setup_gain_table(ah, chain); 286 ar9003_paprd_setup_gain_table(ah, chain);
293 287
294 ath_dbg(common, CALIBRATE, 288 ath_dbg(common, CALIBRATE,
@@ -302,7 +296,13 @@ void ath_paprd_calibrate(struct work_struct *work)
302 break; 296 break;
303 } 297 }
304 298
305 if (ar9003_paprd_create_curve(ah, caldata, chain)) { 299 ret = ar9003_paprd_create_curve(ah, caldata, chain);
300 if (ret == -EINPROGRESS) {
301 ath_dbg(common, CALIBRATE,
302 "PAPRD curve on chain %d needs to be re-trained\n",
303 chain);
304 break;
305 } else if (ret) {
306 ath_dbg(common, CALIBRATE, 306 ath_dbg(common, CALIBRATE,
307 "PAPRD create curve failed on chain %d\n", 307 "PAPRD create curve failed on chain %d\n",
308 chain); 308 chain);
@@ -423,7 +423,7 @@ set_timer:
423 cal_interval = min(cal_interval, (u32)short_cal_interval); 423 cal_interval = min(cal_interval, (u32)short_cal_interval);
424 424
425 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval)); 425 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
426 if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && ah->caldata) { 426 if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD) && ah->caldata) {
427 if (!ah->caldata->paprd_done) 427 if (!ah->caldata->paprd_done)
428 ieee80211_queue_work(sc->hw, &sc->paprd_work); 428 ieee80211_queue_work(sc->hw, &sc->paprd_work);
429 else if (!ah->paprd_table_write_done) 429 else if (!ah->paprd_table_write_done)
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 2c9da6b2ecb1..0d4155aec48d 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2018,6 +2018,9 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
2018 2018
2019 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb); 2019 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
2020 2020
2021 if (sc->sc_ah->caldata)
2022 sc->sc_ah->caldata->paprd_packet_sent = true;
2023
2021 if (!(tx_flags & ATH_TX_ERROR)) 2024 if (!(tx_flags & ATH_TX_ERROR))
2022 /* Frame was ACKed */ 2025 /* Frame was ACKed */
2023 tx_info->flags |= IEEE80211_TX_STAT_ACK; 2026 tx_info->flags |= IEEE80211_TX_STAT_ACK;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
index 49765d34b4e0..7c4ee72f9d56 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
@@ -638,6 +638,8 @@ static int brcmf_sdio_pd_probe(struct platform_device *pdev)
638 638
639 oobirq_entry = kzalloc(sizeof(struct brcmf_sdio_oobirq), 639 oobirq_entry = kzalloc(sizeof(struct brcmf_sdio_oobirq),
640 GFP_KERNEL); 640 GFP_KERNEL);
641 if (!oobirq_entry)
642 return -ENOMEM;
641 oobirq_entry->irq = res->start; 643 oobirq_entry->irq = res->start;
642 oobirq_entry->flags = res->flags & IRQF_TRIGGER_MASK; 644 oobirq_entry->flags = res->flags & IRQF_TRIGGER_MASK;
643 list_add_tail(&oobirq_entry->list, &oobirq_lh); 645 list_add_tail(&oobirq_entry->list, &oobirq_lh);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
index 2621dd3d7dcd..6f70953f0bad 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
@@ -764,8 +764,11 @@ static void brcmf_c_arp_offload_set(struct brcmf_pub *drvr, int arp_mode)
764{ 764{
765 char iovbuf[32]; 765 char iovbuf[32];
766 int retcode; 766 int retcode;
767 __le32 arp_mode_le;
767 768
768 brcmf_c_mkiovar("arp_ol", (char *)&arp_mode, 4, iovbuf, sizeof(iovbuf)); 769 arp_mode_le = cpu_to_le32(arp_mode);
770 brcmf_c_mkiovar("arp_ol", (char *)&arp_mode_le, 4, iovbuf,
771 sizeof(iovbuf));
769 retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, 772 retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR,
770 iovbuf, sizeof(iovbuf)); 773 iovbuf, sizeof(iovbuf));
771 retcode = retcode >= 0 ? 0 : retcode; 774 retcode = retcode >= 0 ? 0 : retcode;
@@ -781,8 +784,11 @@ static void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable)
781{ 784{
782 char iovbuf[32]; 785 char iovbuf[32];
783 int retcode; 786 int retcode;
787 __le32 arp_enable_le;
784 788
785 brcmf_c_mkiovar("arpoe", (char *)&arp_enable, 4, 789 arp_enable_le = cpu_to_le32(arp_enable);
790
791 brcmf_c_mkiovar("arpoe", (char *)&arp_enable_le, 4,
786 iovbuf, sizeof(iovbuf)); 792 iovbuf, sizeof(iovbuf));
787 retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, 793 retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR,
788 iovbuf, sizeof(iovbuf)); 794 iovbuf, sizeof(iovbuf));
@@ -800,10 +806,10 @@ int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr)
800 char iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; /* Room for 806 char iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; /* Room for
801 "event_msgs" + '\0' + bitvec */ 807 "event_msgs" + '\0' + bitvec */
802 char buf[128], *ptr; 808 char buf[128], *ptr;
803 u32 roaming = 1; 809 __le32 roaming_le = cpu_to_le32(1);
804 uint bcn_timeout = 3; 810 __le32 bcn_timeout_le = cpu_to_le32(3);
805 int scan_assoc_time = 40; 811 __le32 scan_assoc_time_le = cpu_to_le32(40);
806 int scan_unassoc_time = 40; 812 __le32 scan_unassoc_time_le = cpu_to_le32(40);
807 int i; 813 int i;
808 struct brcmf_bus_dcmd *cmdlst; 814 struct brcmf_bus_dcmd *cmdlst;
809 struct list_head *cur, *q; 815 struct list_head *cur, *q;
@@ -829,14 +835,14 @@ int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr)
829 835
830 /* Setup timeout if Beacons are lost and roam is off to report 836 /* Setup timeout if Beacons are lost and roam is off to report
831 link down */ 837 link down */
832 brcmf_c_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf, 838 brcmf_c_mkiovar("bcn_timeout", (char *)&bcn_timeout_le, 4, iovbuf,
833 sizeof(iovbuf)); 839 sizeof(iovbuf));
834 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, 840 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
835 sizeof(iovbuf)); 841 sizeof(iovbuf));
836 842
837 /* Enable/Disable build-in roaming to allowed ext supplicant to take 843 /* Enable/Disable build-in roaming to allowed ext supplicant to take
838 of romaing */ 844 of romaing */
839 brcmf_c_mkiovar("roam_off", (char *)&roaming, 4, 845 brcmf_c_mkiovar("roam_off", (char *)&roaming_le, 4,
840 iovbuf, sizeof(iovbuf)); 846 iovbuf, sizeof(iovbuf));
841 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, 847 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
842 sizeof(iovbuf)); 848 sizeof(iovbuf));
@@ -848,9 +854,9 @@ int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr)
848 sizeof(iovbuf)); 854 sizeof(iovbuf));
849 855
850 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME, 856 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME,
851 (char *)&scan_assoc_time, sizeof(scan_assoc_time)); 857 (char *)&scan_assoc_time_le, sizeof(scan_assoc_time_le));
852 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME, 858 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME,
853 (char *)&scan_unassoc_time, sizeof(scan_unassoc_time)); 859 (char *)&scan_unassoc_time_le, sizeof(scan_unassoc_time_le));
854 860
855 /* Set and enable ARP offload feature */ 861 /* Set and enable ARP offload feature */
856 brcmf_c_arp_offload_set(drvr, BRCMF_ARPOL_MODE); 862 brcmf_c_arp_offload_set(drvr, BRCMF_ARPOL_MODE);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
index a299d42da8e7..58f89fa9c9f8 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
@@ -519,7 +519,7 @@ static void brcmf_usb_tx_complete(struct urb *urb)
519 else 519 else
520 devinfo->bus_pub.bus->dstats.tx_errors++; 520 devinfo->bus_pub.bus->dstats.tx_errors++;
521 521
522 dev_kfree_skb(req->skb); 522 brcmu_pkt_buf_free_skb(req->skb);
523 req->skb = NULL; 523 req->skb = NULL;
524 brcmf_usb_enq(devinfo, &devinfo->tx_freeq, req); 524 brcmf_usb_enq(devinfo, &devinfo->tx_freeq, req);
525 525
@@ -540,7 +540,7 @@ static void brcmf_usb_rx_complete(struct urb *urb)
540 devinfo->bus_pub.bus->dstats.rx_packets++; 540 devinfo->bus_pub.bus->dstats.rx_packets++;
541 } else { 541 } else {
542 devinfo->bus_pub.bus->dstats.rx_errors++; 542 devinfo->bus_pub.bus->dstats.rx_errors++;
543 dev_kfree_skb(skb); 543 brcmu_pkt_buf_free_skb(skb);
544 brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req); 544 brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req);
545 return; 545 return;
546 } 546 }
@@ -550,13 +550,15 @@ static void brcmf_usb_rx_complete(struct urb *urb)
550 if (brcmf_proto_hdrpull(devinfo->dev, &ifidx, skb) != 0) { 550 if (brcmf_proto_hdrpull(devinfo->dev, &ifidx, skb) != 0) {
551 brcmf_dbg(ERROR, "rx protocol error\n"); 551 brcmf_dbg(ERROR, "rx protocol error\n");
552 brcmu_pkt_buf_free_skb(skb); 552 brcmu_pkt_buf_free_skb(skb);
553 brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req);
553 devinfo->bus_pub.bus->dstats.rx_errors++; 554 devinfo->bus_pub.bus->dstats.rx_errors++;
554 } else { 555 } else {
555 brcmf_rx_packet(devinfo->dev, ifidx, skb); 556 brcmf_rx_packet(devinfo->dev, ifidx, skb);
556 brcmf_usb_rx_refill(devinfo, req); 557 brcmf_usb_rx_refill(devinfo, req);
557 } 558 }
558 } else { 559 } else {
559 dev_kfree_skb(skb); 560 brcmu_pkt_buf_free_skb(skb);
561 brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req);
560 } 562 }
561 return; 563 return;
562 564
@@ -581,14 +583,13 @@ static void brcmf_usb_rx_refill(struct brcmf_usbdev_info *devinfo,
581 usb_fill_bulk_urb(req->urb, devinfo->usbdev, devinfo->rx_pipe, 583 usb_fill_bulk_urb(req->urb, devinfo->usbdev, devinfo->rx_pipe,
582 skb->data, skb_tailroom(skb), brcmf_usb_rx_complete, 584 skb->data, skb_tailroom(skb), brcmf_usb_rx_complete,
583 req); 585 req);
584 req->urb->transfer_flags |= URB_ZERO_PACKET;
585 req->devinfo = devinfo; 586 req->devinfo = devinfo;
587 brcmf_usb_enq(devinfo, &devinfo->rx_postq, req);
586 588
587 ret = usb_submit_urb(req->urb, GFP_ATOMIC); 589 ret = usb_submit_urb(req->urb, GFP_ATOMIC);
588 if (ret == 0) { 590 if (ret) {
589 brcmf_usb_enq(devinfo, &devinfo->rx_postq, req); 591 brcmf_usb_del_fromq(devinfo, req);
590 } else { 592 brcmu_pkt_buf_free_skb(req->skb);
591 dev_kfree_skb(req->skb);
592 req->skb = NULL; 593 req->skb = NULL;
593 brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req); 594 brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req);
594 } 595 }
@@ -683,23 +684,22 @@ static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb)
683 684
684 req = brcmf_usb_deq(devinfo, &devinfo->tx_freeq); 685 req = brcmf_usb_deq(devinfo, &devinfo->tx_freeq);
685 if (!req) { 686 if (!req) {
687 brcmu_pkt_buf_free_skb(skb);
686 brcmf_dbg(ERROR, "no req to send\n"); 688 brcmf_dbg(ERROR, "no req to send\n");
687 return -ENOMEM; 689 return -ENOMEM;
688 } 690 }
689 if (!req->urb) {
690 brcmf_dbg(ERROR, "no urb for req %p\n", req);
691 return -ENOBUFS;
692 }
693 691
694 req->skb = skb; 692 req->skb = skb;
695 req->devinfo = devinfo; 693 req->devinfo = devinfo;
696 usb_fill_bulk_urb(req->urb, devinfo->usbdev, devinfo->tx_pipe, 694 usb_fill_bulk_urb(req->urb, devinfo->usbdev, devinfo->tx_pipe,
697 skb->data, skb->len, brcmf_usb_tx_complete, req); 695 skb->data, skb->len, brcmf_usb_tx_complete, req);
698 req->urb->transfer_flags |= URB_ZERO_PACKET; 696 req->urb->transfer_flags |= URB_ZERO_PACKET;
697 brcmf_usb_enq(devinfo, &devinfo->tx_postq, req);
699 ret = usb_submit_urb(req->urb, GFP_ATOMIC); 698 ret = usb_submit_urb(req->urb, GFP_ATOMIC);
700 if (!ret) { 699 if (ret) {
701 brcmf_usb_enq(devinfo, &devinfo->tx_postq, req); 700 brcmf_dbg(ERROR, "brcmf_usb_tx usb_submit_urb FAILED\n");
702 } else { 701 brcmf_usb_del_fromq(devinfo, req);
702 brcmu_pkt_buf_free_skb(req->skb);
703 req->skb = NULL; 703 req->skb = NULL;
704 brcmf_usb_enq(devinfo, &devinfo->tx_freeq, req); 704 brcmf_usb_enq(devinfo, &devinfo->tx_freeq, req);
705 } 705 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index 28c5fbb4af26..50b5553b6964 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -500,8 +500,10 @@ static void wl_iscan_prep(struct brcmf_scan_params_le *params_le,
500 params_le->active_time = cpu_to_le32(-1); 500 params_le->active_time = cpu_to_le32(-1);
501 params_le->passive_time = cpu_to_le32(-1); 501 params_le->passive_time = cpu_to_le32(-1);
502 params_le->home_time = cpu_to_le32(-1); 502 params_le->home_time = cpu_to_le32(-1);
503 if (ssid && ssid->SSID_len) 503 if (ssid && ssid->SSID_len) {
504 memcpy(&params_le->ssid_le, ssid, sizeof(struct brcmf_ssid)); 504 params_le->ssid_le.SSID_len = cpu_to_le32(ssid->SSID_len);
505 memcpy(&params_le->ssid_le.SSID, ssid->SSID, ssid->SSID_len);
506 }
505} 507}
506 508
507static s32 509static s32
@@ -1876,16 +1878,17 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
1876 } 1878 }
1877 1879
1878 if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) { 1880 if (test_bit(WL_STATUS_CONNECTED, &cfg_priv->status)) {
1879 scb_val.val = cpu_to_le32(0); 1881 memset(&scb_val, 0, sizeof(scb_val));
1880 err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_RSSI, &scb_val, 1882 err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_RSSI, &scb_val,
1881 sizeof(struct brcmf_scb_val_le)); 1883 sizeof(struct brcmf_scb_val_le));
1882 if (err) 1884 if (err) {
1883 WL_ERR("Could not get rssi (%d)\n", err); 1885 WL_ERR("Could not get rssi (%d)\n", err);
1884 1886 } else {
1885 rssi = le32_to_cpu(scb_val.val); 1887 rssi = le32_to_cpu(scb_val.val);
1886 sinfo->filled |= STATION_INFO_SIGNAL; 1888 sinfo->filled |= STATION_INFO_SIGNAL;
1887 sinfo->signal = rssi; 1889 sinfo->signal = rssi;
1888 WL_CONN("RSSI %d dBm\n", rssi); 1890 WL_CONN("RSSI %d dBm\n", rssi);
1891 }
1889 } 1892 }
1890 1893
1891done: 1894done:
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
index 7ed7d7577024..64a48f06d68b 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
@@ -77,7 +77,7 @@
77 NL80211_RRF_NO_IBSS) 77 NL80211_RRF_NO_IBSS)
78 78
79static const struct ieee80211_regdomain brcms_regdom_x2 = { 79static const struct ieee80211_regdomain brcms_regdom_x2 = {
80 .n_reg_rules = 7, 80 .n_reg_rules = 6,
81 .alpha2 = "X2", 81 .alpha2 = "X2",
82 .reg_rules = { 82 .reg_rules = {
83 BRCM_2GHZ_2412_2462, 83 BRCM_2GHZ_2412_2462,
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index e970897f6ab5..4cb234349fbf 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -1326,6 +1326,11 @@ static int if_sdio_suspend(struct device *dev)
1326 1326
1327 mmc_pm_flag_t flags = sdio_get_host_pm_caps(func); 1327 mmc_pm_flag_t flags = sdio_get_host_pm_caps(func);
1328 1328
1329 /* If we're powered off anyway, just let the mmc layer remove the
1330 * card. */
1331 if (!lbs_iface_active(card->priv))
1332 return -ENOSYS;
1333
1329 dev_info(dev, "%s: suspend: PM flags = 0x%x\n", 1334 dev_info(dev, "%s: suspend: PM flags = 0x%x\n",
1330 sdio_func_id(func), flags); 1335 sdio_func_id(func), flags);
1331 1336
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index c68adec3cc8b..565527aee0ea 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -170,7 +170,20 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
170 cmd_code = le16_to_cpu(host_cmd->command); 170 cmd_code = le16_to_cpu(host_cmd->command);
171 cmd_size = le16_to_cpu(host_cmd->size); 171 cmd_size = le16_to_cpu(host_cmd->size);
172 172
173 skb_trim(cmd_node->cmd_skb, cmd_size); 173 /* Adjust skb length */
174 if (cmd_node->cmd_skb->len > cmd_size)
175 /*
176 * cmd_size is less than sizeof(struct host_cmd_ds_command).
177 * Trim off the unused portion.
178 */
179 skb_trim(cmd_node->cmd_skb, cmd_size);
180 else if (cmd_node->cmd_skb->len < cmd_size)
181 /*
182 * cmd_size is larger than sizeof(struct host_cmd_ds_command)
183 * because we have appended custom IE TLV. Increase skb length
184 * accordingly.
185 */
186 skb_put(cmd_node->cmd_skb, cmd_size - cmd_node->cmd_skb->len);
174 187
175 do_gettimeofday(&tstamp); 188 do_gettimeofday(&tstamp);
176 dev_dbg(adapter->dev, "cmd: DNLD_CMD: (%lu.%lu): %#x, act %#x, len %d," 189 dev_dbg(adapter->dev, "cmd: DNLD_CMD: (%lu.%lu): %#x, act %#x, len %d,"
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 8b9dbd76a252..64328af496f5 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -1611,6 +1611,7 @@ static int rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1611static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev) 1611static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1612{ 1612{
1613 int retval; 1613 int retval;
1614 u32 reg;
1614 1615
1615 /* 1616 /*
1616 * Allocate eeprom data. 1617 * Allocate eeprom data.
@@ -1624,6 +1625,14 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1624 return retval; 1625 return retval;
1625 1626
1626 /* 1627 /*
1628 * Enable rfkill polling by setting GPIO direction of the
1629 * rfkill switch GPIO pin correctly.
1630 */
1631 rt2x00pci_register_read(rt2x00dev, GPIOCSR, &reg);
1632 rt2x00_set_field32(&reg, GPIOCSR_BIT8, 1);
1633 rt2x00pci_register_write(rt2x00dev, GPIOCSR, reg);
1634
1635 /*
1627 * Initialize hw specifications. 1636 * Initialize hw specifications.
1628 */ 1637 */
1629 retval = rt2400pci_probe_hw_mode(rt2x00dev); 1638 retval = rt2400pci_probe_hw_mode(rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.h b/drivers/net/wireless/rt2x00/rt2400pci.h
index d3a4a68cc439..7564ae992b73 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.h
+++ b/drivers/net/wireless/rt2x00/rt2400pci.h
@@ -670,6 +670,7 @@
670#define GPIOCSR_BIT5 FIELD32(0x00000020) 670#define GPIOCSR_BIT5 FIELD32(0x00000020)
671#define GPIOCSR_BIT6 FIELD32(0x00000040) 671#define GPIOCSR_BIT6 FIELD32(0x00000040)
672#define GPIOCSR_BIT7 FIELD32(0x00000080) 672#define GPIOCSR_BIT7 FIELD32(0x00000080)
673#define GPIOCSR_BIT8 FIELD32(0x00000100)
673 674
674/* 675/*
675 * BBPPCSR: BBP Pin control register. 676 * BBPPCSR: BBP Pin control register.
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index d2cf8a4bc8b5..3de0406735f6 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1929,6 +1929,7 @@ static int rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1929static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev) 1929static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1930{ 1930{
1931 int retval; 1931 int retval;
1932 u32 reg;
1932 1933
1933 /* 1934 /*
1934 * Allocate eeprom data. 1935 * Allocate eeprom data.
@@ -1942,6 +1943,14 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1942 return retval; 1943 return retval;
1943 1944
1944 /* 1945 /*
1946 * Enable rfkill polling by setting GPIO direction of the
1947 * rfkill switch GPIO pin correctly.
1948 */
1949 rt2x00pci_register_read(rt2x00dev, GPIOCSR, &reg);
1950 rt2x00_set_field32(&reg, GPIOCSR_DIR0, 1);
1951 rt2x00pci_register_write(rt2x00dev, GPIOCSR, reg);
1952
1953 /*
1945 * Initialize hw specifications. 1954 * Initialize hw specifications.
1946 */ 1955 */
1947 retval = rt2500pci_probe_hw_mode(rt2x00dev); 1956 retval = rt2500pci_probe_hw_mode(rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 3aae36bb0a9e..89fee311d8fd 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -283,7 +283,7 @@ static int rt2500usb_rfkill_poll(struct rt2x00_dev *rt2x00dev)
283 u16 reg; 283 u16 reg;
284 284
285 rt2500usb_register_read(rt2x00dev, MAC_CSR19, &reg); 285 rt2500usb_register_read(rt2x00dev, MAC_CSR19, &reg);
286 return rt2x00_get_field32(reg, MAC_CSR19_BIT7); 286 return rt2x00_get_field16(reg, MAC_CSR19_BIT7);
287} 287}
288 288
289#ifdef CONFIG_RT2X00_LIB_LEDS 289#ifdef CONFIG_RT2X00_LIB_LEDS
@@ -1768,6 +1768,7 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1768static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev) 1768static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1769{ 1769{
1770 int retval; 1770 int retval;
1771 u16 reg;
1771 1772
1772 /* 1773 /*
1773 * Allocate eeprom data. 1774 * Allocate eeprom data.
@@ -1781,6 +1782,14 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1781 return retval; 1782 return retval;
1782 1783
1783 /* 1784 /*
1785 * Enable rfkill polling by setting GPIO direction of the
1786 * rfkill switch GPIO pin correctly.
1787 */
1788 rt2500usb_register_read(rt2x00dev, MAC_CSR19, &reg);
1789 rt2x00_set_field16(&reg, MAC_CSR19_BIT8, 0);
1790 rt2500usb_register_write(rt2x00dev, MAC_CSR19, reg);
1791
1792 /*
1784 * Initialize hw specifications. 1793 * Initialize hw specifications.
1785 */ 1794 */
1786 retval = rt2500usb_probe_hw_mode(rt2x00dev); 1795 retval = rt2500usb_probe_hw_mode(rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.h b/drivers/net/wireless/rt2x00/rt2500usb.h
index b493306a7eed..196bd5103e4f 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.h
+++ b/drivers/net/wireless/rt2x00/rt2500usb.h
@@ -189,14 +189,15 @@
189 * MAC_CSR19: GPIO control register. 189 * MAC_CSR19: GPIO control register.
190 */ 190 */
191#define MAC_CSR19 0x0426 191#define MAC_CSR19 0x0426
192#define MAC_CSR19_BIT0 FIELD32(0x0001) 192#define MAC_CSR19_BIT0 FIELD16(0x0001)
193#define MAC_CSR19_BIT1 FIELD32(0x0002) 193#define MAC_CSR19_BIT1 FIELD16(0x0002)
194#define MAC_CSR19_BIT2 FIELD32(0x0004) 194#define MAC_CSR19_BIT2 FIELD16(0x0004)
195#define MAC_CSR19_BIT3 FIELD32(0x0008) 195#define MAC_CSR19_BIT3 FIELD16(0x0008)
196#define MAC_CSR19_BIT4 FIELD32(0x0010) 196#define MAC_CSR19_BIT4 FIELD16(0x0010)
197#define MAC_CSR19_BIT5 FIELD32(0x0020) 197#define MAC_CSR19_BIT5 FIELD16(0x0020)
198#define MAC_CSR19_BIT6 FIELD32(0x0040) 198#define MAC_CSR19_BIT6 FIELD16(0x0040)
199#define MAC_CSR19_BIT7 FIELD32(0x0080) 199#define MAC_CSR19_BIT7 FIELD16(0x0080)
200#define MAC_CSR19_BIT8 FIELD16(0x0100)
200 201
201/* 202/*
202 * MAC_CSR20: LED control register. 203 * MAC_CSR20: LED control register.
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index cb8c2aca54e4..b93516d832fb 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4089,6 +4089,7 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
4089 rt2800_register_write(rt2x00dev, LDO_CFG0, reg); 4089 rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
4090 msleep(1); 4090 msleep(1);
4091 rt2800_register_read(rt2x00dev, LDO_CFG0, &reg); 4091 rt2800_register_read(rt2x00dev, LDO_CFG0, &reg);
4092 rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
4092 rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1); 4093 rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
4093 rt2800_register_write(rt2x00dev, LDO_CFG0, reg); 4094 rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
4094 } 4095 }
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 98aa426a3564..4765bbd654cd 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -983,6 +983,7 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
983static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev) 983static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
984{ 984{
985 int retval; 985 int retval;
986 u32 reg;
986 987
987 /* 988 /*
988 * Allocate eeprom data. 989 * Allocate eeprom data.
@@ -996,6 +997,14 @@ static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
996 return retval; 997 return retval;
997 998
998 /* 999 /*
1000 * Enable rfkill polling by setting GPIO direction of the
1001 * rfkill switch GPIO pin correctly.
1002 */
1003 rt2x00pci_register_read(rt2x00dev, GPIO_CTRL_CFG, &reg);
1004 rt2x00_set_field32(&reg, GPIO_CTRL_CFG_GPIOD_BIT2, 1);
1005 rt2x00pci_register_write(rt2x00dev, GPIO_CTRL_CFG, reg);
1006
1007 /*
999 * Initialize hw specifications. 1008 * Initialize hw specifications.
1000 */ 1009 */
1001 retval = rt2800_probe_hw_mode(rt2x00dev); 1010 retval = rt2800_probe_hw_mode(rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 6cf336595e25..6b4226b71618 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -667,8 +667,16 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
667 skb_pull(entry->skb, RXINFO_DESC_SIZE); 667 skb_pull(entry->skb, RXINFO_DESC_SIZE);
668 668
669 /* 669 /*
670 * FIXME: we need to check for rx_pkt_len validity 670 * Check for rx_pkt_len validity. Return if invalid, leaving
671 * rxdesc->size zeroed out by the upper level.
671 */ 672 */
673 if (unlikely(rx_pkt_len == 0 ||
674 rx_pkt_len > entry->queue->data_size)) {
675 ERROR(entry->queue->rt2x00dev,
676 "Bad frame size %d, forcing to 0\n", rx_pkt_len);
677 return;
678 }
679
672 rxd = (__le32 *)(entry->skb->data + rx_pkt_len); 680 rxd = (__le32 *)(entry->skb->data + rx_pkt_len);
673 681
674 /* 682 /*
@@ -736,6 +744,7 @@ static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
736static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) 744static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
737{ 745{
738 int retval; 746 int retval;
747 u32 reg;
739 748
740 /* 749 /*
741 * Allocate eeprom data. 750 * Allocate eeprom data.
@@ -749,6 +758,14 @@ static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
749 return retval; 758 return retval;
750 759
751 /* 760 /*
761 * Enable rfkill polling by setting GPIO direction of the
762 * rfkill switch GPIO pin correctly.
763 */
764 rt2x00usb_register_read(rt2x00dev, GPIO_CTRL_CFG, &reg);
765 rt2x00_set_field32(&reg, GPIO_CTRL_CFG_GPIOD_BIT2, 1);
766 rt2x00usb_register_write(rt2x00dev, GPIO_CTRL_CFG, reg);
767
768 /*
752 * Initialize hw specifications. 769 * Initialize hw specifications.
753 */ 770 */
754 retval = rt2800_probe_hw_mode(rt2x00dev); 771 retval = rt2800_probe_hw_mode(rt2x00dev);
@@ -1157,6 +1174,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
1157 { USB_DEVICE(0x1690, 0x0744) }, 1174 { USB_DEVICE(0x1690, 0x0744) },
1158 { USB_DEVICE(0x1690, 0x0761) }, 1175 { USB_DEVICE(0x1690, 0x0761) },
1159 { USB_DEVICE(0x1690, 0x0764) }, 1176 { USB_DEVICE(0x1690, 0x0764) },
1177 /* ASUS */
1178 { USB_DEVICE(0x0b05, 0x179d) },
1160 /* Cisco */ 1179 /* Cisco */
1161 { USB_DEVICE(0x167b, 0x4001) }, 1180 { USB_DEVICE(0x167b, 0x4001) },
1162 /* EnGenius */ 1181 /* EnGenius */
@@ -1222,7 +1241,6 @@ static struct usb_device_id rt2800usb_device_table[] = {
1222 { USB_DEVICE(0x0b05, 0x1760) }, 1241 { USB_DEVICE(0x0b05, 0x1760) },
1223 { USB_DEVICE(0x0b05, 0x1761) }, 1242 { USB_DEVICE(0x0b05, 0x1761) },
1224 { USB_DEVICE(0x0b05, 0x1790) }, 1243 { USB_DEVICE(0x0b05, 0x1790) },
1225 { USB_DEVICE(0x0b05, 0x179d) },
1226 /* AzureWave */ 1244 /* AzureWave */
1227 { USB_DEVICE(0x13d3, 0x3262) }, 1245 { USB_DEVICE(0x13d3, 0x3262) },
1228 { USB_DEVICE(0x13d3, 0x3284) }, 1246 { USB_DEVICE(0x13d3, 0x3284) },
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index a6b88bd4a1a5..3f07e36f462b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -629,7 +629,7 @@ void rt2x00lib_rxdone(struct queue_entry *entry, gfp_t gfp)
629 */ 629 */
630 if (unlikely(rxdesc.size == 0 || 630 if (unlikely(rxdesc.size == 0 ||
631 rxdesc.size > entry->queue->data_size)) { 631 rxdesc.size > entry->queue->data_size)) {
632 WARNING(rt2x00dev, "Wrong frame size %d max %d.\n", 632 ERROR(rt2x00dev, "Wrong frame size %d max %d.\n",
633 rxdesc.size, entry->queue->data_size); 633 rxdesc.size, entry->queue->data_size);
634 dev_kfree_skb(entry->skb); 634 dev_kfree_skb(entry->skb);
635 goto renew_skb; 635 goto renew_skb;
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 3f7bc5cadf9a..b8ec96163922 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -2832,6 +2832,7 @@ static int rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2832static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev) 2832static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)
2833{ 2833{
2834 int retval; 2834 int retval;
2835 u32 reg;
2835 2836
2836 /* 2837 /*
2837 * Disable power saving. 2838 * Disable power saving.
@@ -2850,6 +2851,14 @@ static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)
2850 return retval; 2851 return retval;
2851 2852
2852 /* 2853 /*
2854 * Enable rfkill polling by setting GPIO direction of the
2855 * rfkill switch GPIO pin correctly.
2856 */
2857 rt2x00pci_register_read(rt2x00dev, MAC_CSR13, &reg);
2858 rt2x00_set_field32(&reg, MAC_CSR13_BIT13, 1);
2859 rt2x00pci_register_write(rt2x00dev, MAC_CSR13, reg);
2860
2861 /*
2853 * Initialize hw specifications. 2862 * Initialize hw specifications.
2854 */ 2863 */
2855 retval = rt61pci_probe_hw_mode(rt2x00dev); 2864 retval = rt61pci_probe_hw_mode(rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt61pci.h b/drivers/net/wireless/rt2x00/rt61pci.h
index e3cd6db76b0e..8f3da5a56766 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.h
+++ b/drivers/net/wireless/rt2x00/rt61pci.h
@@ -372,6 +372,7 @@ struct hw_pairwise_ta_entry {
372#define MAC_CSR13_BIT10 FIELD32(0x00000400) 372#define MAC_CSR13_BIT10 FIELD32(0x00000400)
373#define MAC_CSR13_BIT11 FIELD32(0x00000800) 373#define MAC_CSR13_BIT11 FIELD32(0x00000800)
374#define MAC_CSR13_BIT12 FIELD32(0x00001000) 374#define MAC_CSR13_BIT12 FIELD32(0x00001000)
375#define MAC_CSR13_BIT13 FIELD32(0x00002000)
375 376
376/* 377/*
377 * MAC_CSR14: LED control register. 378 * MAC_CSR14: LED control register.
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index ba6e434b859d..248436c13ce0 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2177,6 +2177,7 @@ static int rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2177static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev) 2177static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
2178{ 2178{
2179 int retval; 2179 int retval;
2180 u32 reg;
2180 2181
2181 /* 2182 /*
2182 * Allocate eeprom data. 2183 * Allocate eeprom data.
@@ -2190,6 +2191,14 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
2190 return retval; 2191 return retval;
2191 2192
2192 /* 2193 /*
2194 * Enable rfkill polling by setting GPIO direction of the
2195 * rfkill switch GPIO pin correctly.
2196 */
2197 rt2x00usb_register_read(rt2x00dev, MAC_CSR13, &reg);
2198 rt2x00_set_field32(&reg, MAC_CSR13_BIT15, 0);
2199 rt2x00usb_register_write(rt2x00dev, MAC_CSR13, reg);
2200
2201 /*
2193 * Initialize hw specifications. 2202 * Initialize hw specifications.
2194 */ 2203 */
2195 retval = rt73usb_probe_hw_mode(rt2x00dev); 2204 retval = rt73usb_probe_hw_mode(rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt73usb.h b/drivers/net/wireless/rt2x00/rt73usb.h
index 9f6b470414d3..df1cc116b83b 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.h
+++ b/drivers/net/wireless/rt2x00/rt73usb.h
@@ -282,6 +282,9 @@ struct hw_pairwise_ta_entry {
282#define MAC_CSR13_BIT10 FIELD32(0x00000400) 282#define MAC_CSR13_BIT10 FIELD32(0x00000400)
283#define MAC_CSR13_BIT11 FIELD32(0x00000800) 283#define MAC_CSR13_BIT11 FIELD32(0x00000800)
284#define MAC_CSR13_BIT12 FIELD32(0x00001000) 284#define MAC_CSR13_BIT12 FIELD32(0x00001000)
285#define MAC_CSR13_BIT13 FIELD32(0x00002000)
286#define MAC_CSR13_BIT14 FIELD32(0x00004000)
287#define MAC_CSR13_BIT15 FIELD32(0x00008000)
285 288
286/* 289/*
287 * MAC_CSR14: LED control register. 290 * MAC_CSR14: LED control register.
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
index 04c3aef8a4f6..2925094b2d91 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
@@ -117,6 +117,7 @@
117 117
118#define CHIP_VER_B BIT(4) 118#define CHIP_VER_B BIT(4)
119#define CHIP_92C_BITMASK BIT(0) 119#define CHIP_92C_BITMASK BIT(0)
120#define CHIP_UNKNOWN BIT(7)
120#define CHIP_92C_1T2R 0x03 121#define CHIP_92C_1T2R 0x03
121#define CHIP_92C 0x01 122#define CHIP_92C 0x01
122#define CHIP_88C 0x00 123#define CHIP_88C 0x00
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
index bd0da7ef290b..dd4bb0950a57 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
@@ -994,8 +994,16 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw)
994 version = (value32 & TYPE_ID) ? VERSION_A_CHIP_92C : 994 version = (value32 & TYPE_ID) ? VERSION_A_CHIP_92C :
995 VERSION_A_CHIP_88C; 995 VERSION_A_CHIP_88C;
996 } else { 996 } else {
997 version = (value32 & TYPE_ID) ? VERSION_B_CHIP_92C : 997 version = (enum version_8192c) (CHIP_VER_B |
998 VERSION_B_CHIP_88C; 998 ((value32 & TYPE_ID) ? CHIP_92C_BITMASK : 0) |
999 ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : 0));
1000 if ((!IS_CHIP_VENDOR_UMC(version)) && (value32 &
1001 CHIP_VER_RTL_MASK)) {
1002 version = (enum version_8192c)(version |
1003 ((((value32 & CHIP_VER_RTL_MASK) == BIT(12))
1004 ? CHIP_VENDOR_UMC_B_CUT : CHIP_UNKNOWN) |
1005 CHIP_VENDOR_UMC));
1006 }
999 } 1007 }
1000 1008
1001 switch (version) { 1009 switch (version) {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index 3aa927f8b9b9..7d8f96405f42 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -162,10 +162,12 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
162 162
163 /* request fw */ 163 /* request fw */
164 if (IS_VENDOR_UMC_A_CUT(rtlhal->version) && 164 if (IS_VENDOR_UMC_A_CUT(rtlhal->version) &&
165 !IS_92C_SERIAL(rtlhal->version)) 165 !IS_92C_SERIAL(rtlhal->version)) {
166 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU.bin"; 166 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU.bin";
167 else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) 167 } else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) {
168 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU_B.bin"; 168 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU_B.bin";
169 pr_info("****** This B_CUT device may not work with kernels 3.6 and earlier\n");
170 }
169 171
170 rtlpriv->max_fw_size = 0x4000; 172 rtlpriv->max_fw_size = 0x4000;
171 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); 173 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name);
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 3782e1cd3697..934d861a3235 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -2196,10 +2196,8 @@ static int __init acer_wmi_init(void)
2196 interface->capability &= ~ACER_CAP_BRIGHTNESS; 2196 interface->capability &= ~ACER_CAP_BRIGHTNESS;
2197 pr_info("Brightness must be controlled by acpi video driver\n"); 2197 pr_info("Brightness must be controlled by acpi video driver\n");
2198 } else { 2198 } else {
2199#ifdef CONFIG_ACPI_VIDEO
2200 pr_info("Disabling ACPI video driver\n"); 2199 pr_info("Disabling ACPI video driver\n");
2201 acpi_video_unregister(); 2200 acpi_video_unregister();
2202#endif
2203 } 2201 }
2204 2202
2205 if (wmi_has_guid(WMID_GUID3)) { 2203 if (wmi_has_guid(WMID_GUID3)) {
diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index dfb1a92ce949..db8f63841b42 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -101,7 +101,7 @@ static void gmux_pio_write32(struct apple_gmux_data *gmux_data, int port,
101 101
102 for (i = 0; i < 4; i++) { 102 for (i = 0; i < 4; i++) {
103 tmpval = (val >> (i * 8)) & 0xff; 103 tmpval = (val >> (i * 8)) & 0xff;
104 outb(tmpval, port + i); 104 outb(tmpval, gmux_data->iostart + port + i);
105 } 105 }
106} 106}
107 107
@@ -142,8 +142,9 @@ static u8 gmux_index_read8(struct apple_gmux_data *gmux_data, int port)
142 u8 val; 142 u8 val;
143 143
144 mutex_lock(&gmux_data->index_lock); 144 mutex_lock(&gmux_data->index_lock);
145 outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ);
146 gmux_index_wait_ready(gmux_data); 145 gmux_index_wait_ready(gmux_data);
146 outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ);
147 gmux_index_wait_complete(gmux_data);
147 val = inb(gmux_data->iostart + GMUX_PORT_VALUE); 148 val = inb(gmux_data->iostart + GMUX_PORT_VALUE);
148 mutex_unlock(&gmux_data->index_lock); 149 mutex_unlock(&gmux_data->index_lock);
149 150
@@ -166,8 +167,9 @@ static u32 gmux_index_read32(struct apple_gmux_data *gmux_data, int port)
166 u32 val; 167 u32 val;
167 168
168 mutex_lock(&gmux_data->index_lock); 169 mutex_lock(&gmux_data->index_lock);
169 outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ);
170 gmux_index_wait_ready(gmux_data); 170 gmux_index_wait_ready(gmux_data);
171 outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ);
172 gmux_index_wait_complete(gmux_data);
171 val = inl(gmux_data->iostart + GMUX_PORT_VALUE); 173 val = inl(gmux_data->iostart + GMUX_PORT_VALUE);
172 mutex_unlock(&gmux_data->index_lock); 174 mutex_unlock(&gmux_data->index_lock);
173 175
@@ -461,18 +463,22 @@ static int __devinit gmux_probe(struct pnp_dev *pnp,
461 ver_release = gmux_read8(gmux_data, GMUX_PORT_VERSION_RELEASE); 463 ver_release = gmux_read8(gmux_data, GMUX_PORT_VERSION_RELEASE);
462 if (ver_major == 0xff && ver_minor == 0xff && ver_release == 0xff) { 464 if (ver_major == 0xff && ver_minor == 0xff && ver_release == 0xff) {
463 if (gmux_is_indexed(gmux_data)) { 465 if (gmux_is_indexed(gmux_data)) {
466 u32 version;
464 mutex_init(&gmux_data->index_lock); 467 mutex_init(&gmux_data->index_lock);
465 gmux_data->indexed = true; 468 gmux_data->indexed = true;
469 version = gmux_read32(gmux_data,
470 GMUX_PORT_VERSION_MAJOR);
471 ver_major = (version >> 24) & 0xff;
472 ver_minor = (version >> 16) & 0xff;
473 ver_release = (version >> 8) & 0xff;
466 } else { 474 } else {
467 pr_info("gmux device not present\n"); 475 pr_info("gmux device not present\n");
468 ret = -ENODEV; 476 ret = -ENODEV;
469 goto err_release; 477 goto err_release;
470 } 478 }
471 pr_info("Found indexed gmux\n");
472 } else {
473 pr_info("Found gmux version %d.%d.%d\n", ver_major, ver_minor,
474 ver_release);
475 } 479 }
480 pr_info("Found gmux version %d.%d.%d [%s]\n", ver_major, ver_minor,
481 ver_release, (gmux_data->indexed ? "indexed" : "classic"));
476 482
477 memset(&props, 0, sizeof(props)); 483 memset(&props, 0, sizeof(props));
478 props.type = BACKLIGHT_PLATFORM; 484 props.type = BACKLIGHT_PLATFORM;
@@ -505,9 +511,7 @@ static int __devinit gmux_probe(struct pnp_dev *pnp,
505 * Disable the other backlight choices. 511 * Disable the other backlight choices.
506 */ 512 */
507 acpi_video_dmi_promote_vendor(); 513 acpi_video_dmi_promote_vendor();
508#if defined (CONFIG_ACPI_VIDEO) || defined (CONFIG_ACPI_VIDEO_MODULE)
509 acpi_video_unregister(); 514 acpi_video_unregister();
510#endif
511 apple_bl_unregister(); 515 apple_bl_unregister();
512 516
513 gmux_data->power_state = VGA_SWITCHEROO_ON; 517 gmux_data->power_state = VGA_SWITCHEROO_ON;
@@ -593,9 +597,7 @@ static void __devexit gmux_remove(struct pnp_dev *pnp)
593 kfree(gmux_data); 597 kfree(gmux_data);
594 598
595 acpi_video_dmi_demote_vendor(); 599 acpi_video_dmi_demote_vendor();
596#if defined (CONFIG_ACPI_VIDEO) || defined (CONFIG_ACPI_VIDEO_MODULE)
597 acpi_video_register(); 600 acpi_video_register();
598#endif
599 apple_bl_register(); 601 apple_bl_register();
600} 602}
601 603
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index e38f91be0b10..4b568df56643 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -85,7 +85,7 @@ static char *wled_type = "unknown";
85static char *bled_type = "unknown"; 85static char *bled_type = "unknown";
86 86
87module_param(wled_type, charp, 0444); 87module_param(wled_type, charp, 0444);
88MODULE_PARM_DESC(wlan_status, "Set the wled type on boot " 88MODULE_PARM_DESC(wled_type, "Set the wled type on boot "
89 "(unknown, led or rfkill). " 89 "(unknown, led or rfkill). "
90 "default is unknown"); 90 "default is unknown");
91 91
@@ -863,9 +863,9 @@ static ssize_t show_infos(struct device *dev,
863 * The significance of others is yet to be found. 863 * The significance of others is yet to be found.
864 * If we don't find the method, we assume the device are present. 864 * If we don't find the method, we assume the device are present.
865 */ 865 */
866 rv = acpi_evaluate_integer(asus->handle, "HRWS", NULL, &temp); 866 rv = acpi_evaluate_integer(asus->handle, "HWRS", NULL, &temp);
867 if (!ACPI_FAILURE(rv)) 867 if (!ACPI_FAILURE(rv))
868 len += sprintf(page + len, "HRWS value : %#x\n", 868 len += sprintf(page + len, "HWRS value : %#x\n",
869 (uint) temp); 869 (uint) temp);
870 /* 870 /*
871 * Another value for userspace: the ASYM method returns 0x02 for 871 * Another value for userspace: the ASYM method returns 0x02 for
@@ -1751,9 +1751,9 @@ static int asus_laptop_get_info(struct asus_laptop *asus)
1751 * The significance of others is yet to be found. 1751 * The significance of others is yet to be found.
1752 */ 1752 */
1753 status = 1753 status =
1754 acpi_evaluate_integer(asus->handle, "HRWS", NULL, &hwrs_result); 1754 acpi_evaluate_integer(asus->handle, "HWRS", NULL, &hwrs_result);
1755 if (!ACPI_FAILURE(status)) 1755 if (!ACPI_FAILURE(status))
1756 pr_notice(" HRWS returned %x", (int)hwrs_result); 1756 pr_notice(" HWRS returned %x", (int)hwrs_result);
1757 1757
1758 if (!acpi_check_handle(asus->handle, METHOD_WL_STATUS, NULL)) 1758 if (!acpi_check_handle(asus->handle, METHOD_WL_STATUS, NULL))
1759 asus->have_rsts = true; 1759 asus->have_rsts = true;
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 2eb9fe8e8efd..c0e9ff489b24 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -47,9 +47,7 @@
47#include <linux/thermal.h> 47#include <linux/thermal.h>
48#include <acpi/acpi_bus.h> 48#include <acpi/acpi_bus.h>
49#include <acpi/acpi_drivers.h> 49#include <acpi/acpi_drivers.h>
50#ifdef CONFIG_ACPI_VIDEO
51#include <acpi/video.h> 50#include <acpi/video.h>
52#endif
53 51
54#include "asus-wmi.h" 52#include "asus-wmi.h"
55 53
@@ -1704,10 +1702,8 @@ static int asus_wmi_add(struct platform_device *pdev)
1704 if (asus->driver->quirks->wmi_backlight_power) 1702 if (asus->driver->quirks->wmi_backlight_power)
1705 acpi_video_dmi_promote_vendor(); 1703 acpi_video_dmi_promote_vendor();
1706 if (!acpi_video_backlight_support()) { 1704 if (!acpi_video_backlight_support()) {
1707#ifdef CONFIG_ACPI_VIDEO
1708 pr_info("Disabling ACPI video driver\n"); 1705 pr_info("Disabling ACPI video driver\n");
1709 acpi_video_unregister(); 1706 acpi_video_unregister();
1710#endif
1711 err = asus_wmi_backlight_init(asus); 1707 err = asus_wmi_backlight_init(asus);
1712 if (err && err != -ENODEV) 1708 if (err && err != -ENODEV)
1713 goto fail_backlight; 1709 goto fail_backlight;
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index dab91b48d22c..5ca264179f4e 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -610,12 +610,12 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
610 610
611 if (!bus) { 611 if (!bus) {
612 pr_warn("Unable to find PCI bus 1?\n"); 612 pr_warn("Unable to find PCI bus 1?\n");
613 goto out_unlock; 613 goto out_put_dev;
614 } 614 }
615 615
616 if (pci_bus_read_config_dword(bus, 0, PCI_VENDOR_ID, &l)) { 616 if (pci_bus_read_config_dword(bus, 0, PCI_VENDOR_ID, &l)) {
617 pr_err("Unable to read PCI config space?\n"); 617 pr_err("Unable to read PCI config space?\n");
618 goto out_unlock; 618 goto out_put_dev;
619 } 619 }
620 620
621 absent = (l == 0xffffffff); 621 absent = (l == 0xffffffff);
@@ -627,7 +627,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
627 absent ? "absent" : "present"); 627 absent ? "absent" : "present");
628 pr_warn("skipped wireless hotplug as probably " 628 pr_warn("skipped wireless hotplug as probably "
629 "inappropriate for this model\n"); 629 "inappropriate for this model\n");
630 goto out_unlock; 630 goto out_put_dev;
631 } 631 }
632 632
633 if (!blocked) { 633 if (!blocked) {
@@ -635,7 +635,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
635 if (dev) { 635 if (dev) {
636 /* Device already present */ 636 /* Device already present */
637 pci_dev_put(dev); 637 pci_dev_put(dev);
638 goto out_unlock; 638 goto out_put_dev;
639 } 639 }
640 dev = pci_scan_single_device(bus, 0); 640 dev = pci_scan_single_device(bus, 0);
641 if (dev) { 641 if (dev) {
@@ -650,6 +650,8 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
650 pci_dev_put(dev); 650 pci_dev_put(dev);
651 } 651 }
652 } 652 }
653out_put_dev:
654 pci_dev_put(port);
653 } 655 }
654 656
655out_unlock: 657out_unlock:
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index c1ca7bcebb66..dd90d15f5210 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -26,9 +26,7 @@
26#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#include <linux/debugfs.h> 27#include <linux/debugfs.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#ifdef CONFIG_ACPI_VIDEO
30#include <acpi/video.h> 29#include <acpi/video.h>
31#endif
32 30
33/* 31/*
34 * This driver is needed because a number of Samsung laptops do not hook 32 * This driver is needed because a number of Samsung laptops do not hook
@@ -1558,9 +1556,7 @@ static int __init samsung_init(void)
1558 samsung->handle_backlight = false; 1556 samsung->handle_backlight = false;
1559 } else if (samsung->quirks->broken_acpi_video) { 1557 } else if (samsung->quirks->broken_acpi_video) {
1560 pr_info("Disabling ACPI video driver\n"); 1558 pr_info("Disabling ACPI video driver\n");
1561#ifdef CONFIG_ACPI_VIDEO
1562 acpi_video_unregister(); 1559 acpi_video_unregister();
1563#endif
1564 } 1560 }
1565#endif 1561#endif
1566 1562
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 80e377949314..52daaa816e53 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -545,7 +545,7 @@ TPACPI_HANDLE(hkey, ec, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
545 */ 545 */
546 546
547static int acpi_evalf(acpi_handle handle, 547static int acpi_evalf(acpi_handle handle,
548 void *res, char *method, char *fmt, ...) 548 int *res, char *method, char *fmt, ...)
549{ 549{
550 char *fmt0 = fmt; 550 char *fmt0 = fmt;
551 struct acpi_object_list params; 551 struct acpi_object_list params;
@@ -606,7 +606,7 @@ static int acpi_evalf(acpi_handle handle,
606 success = (status == AE_OK && 606 success = (status == AE_OK &&
607 out_obj.type == ACPI_TYPE_INTEGER); 607 out_obj.type == ACPI_TYPE_INTEGER);
608 if (success && res) 608 if (success && res)
609 *(int *)res = out_obj.integer.value; 609 *res = out_obj.integer.value;
610 break; 610 break;
611 case 'v': /* void */ 611 case 'v': /* void */
612 success = status == AE_OK; 612 success = status == AE_OK;
@@ -7386,17 +7386,18 @@ static int fan_get_status(u8 *status)
7386 * Add TPACPI_FAN_RD_ACPI_FANS ? */ 7386 * Add TPACPI_FAN_RD_ACPI_FANS ? */
7387 7387
7388 switch (fan_status_access_mode) { 7388 switch (fan_status_access_mode) {
7389 case TPACPI_FAN_RD_ACPI_GFAN: 7389 case TPACPI_FAN_RD_ACPI_GFAN: {
7390 /* 570, 600e/x, 770e, 770x */ 7390 /* 570, 600e/x, 770e, 770x */
7391 int res;
7391 7392
7392 if (unlikely(!acpi_evalf(gfan_handle, &s, NULL, "d"))) 7393 if (unlikely(!acpi_evalf(gfan_handle, &res, NULL, "d")))
7393 return -EIO; 7394 return -EIO;
7394 7395
7395 if (likely(status)) 7396 if (likely(status))
7396 *status = s & 0x07; 7397 *status = res & 0x07;
7397 7398
7398 break; 7399 break;
7399 7400 }
7400 case TPACPI_FAN_RD_TPEC: 7401 case TPACPI_FAN_RD_TPEC:
7401 /* all except 570, 600e/x, 770e, 770x */ 7402 /* all except 570, 600e/x, 770e, 770x */
7402 if (unlikely(!acpi_ec_read(fan_status_offset, &s))) 7403 if (unlikely(!acpi_ec_read(fan_status_offset, &s)))
diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 0b66d0f25922..4b6688909fee 100644
--- a/drivers/pwm/pwm-tiecap.c
+++ b/drivers/pwm/pwm-tiecap.c
@@ -100,6 +100,13 @@ static int ecap_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
100 writel(period_cycles, pc->mmio_base + CAP3); 100 writel(period_cycles, pc->mmio_base + CAP3);
101 } 101 }
102 102
103 if (!test_bit(PWMF_ENABLED, &pwm->flags)) {
104 reg_val = readw(pc->mmio_base + ECCTL2);
105 /* Disable APWM mode to put APWM output Low */
106 reg_val &= ~ECCTL2_APWM_MODE;
107 writew(reg_val, pc->mmio_base + ECCTL2);
108 }
109
103 pm_runtime_put_sync(pc->chip.dev); 110 pm_runtime_put_sync(pc->chip.dev);
104 return 0; 111 return 0;
105} 112}
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index c3756d1be194..b1996bcd5b78 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -104,6 +104,7 @@ struct ehrpwm_pwm_chip {
104 struct pwm_chip chip; 104 struct pwm_chip chip;
105 unsigned int clk_rate; 105 unsigned int clk_rate;
106 void __iomem *mmio_base; 106 void __iomem *mmio_base;
107 unsigned long period_cycles[NUM_PWM_CHANNEL];
107}; 108};
108 109
109static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip) 110static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip)
@@ -210,6 +211,7 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
210 unsigned long long c; 211 unsigned long long c;
211 unsigned long period_cycles, duty_cycles; 212 unsigned long period_cycles, duty_cycles;
212 unsigned short ps_divval, tb_divval; 213 unsigned short ps_divval, tb_divval;
214 int i;
213 215
214 if (period_ns < 0 || duty_ns < 0 || period_ns > NSEC_PER_SEC) 216 if (period_ns < 0 || duty_ns < 0 || period_ns > NSEC_PER_SEC)
215 return -ERANGE; 217 return -ERANGE;
@@ -229,6 +231,28 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
229 duty_cycles = (unsigned long)c; 231 duty_cycles = (unsigned long)c;
230 } 232 }
231 233
234 /*
235 * Period values should be same for multiple PWM channels as IP uses
236 * same period register for multiple channels.
237 */
238 for (i = 0; i < NUM_PWM_CHANNEL; i++) {
239 if (pc->period_cycles[i] &&
240 (pc->period_cycles[i] != period_cycles)) {
241 /*
242 * Allow channel to reconfigure period if no other
243 * channels being configured.
244 */
245 if (i == pwm->hwpwm)
246 continue;
247
248 dev_err(chip->dev, "Period value conflicts with channel %d\n",
249 i);
250 return -EINVAL;
251 }
252 }
253
254 pc->period_cycles[pwm->hwpwm] = period_cycles;
255
232 /* Configure clock prescaler to support Low frequency PWM wave */ 256 /* Configure clock prescaler to support Low frequency PWM wave */
233 if (set_prescale_div(period_cycles/PERIOD_MAX, &ps_divval, 257 if (set_prescale_div(period_cycles/PERIOD_MAX, &ps_divval,
234 &tb_divval)) { 258 &tb_divval)) {
@@ -320,10 +344,15 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
320 344
321static void ehrpwm_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) 345static void ehrpwm_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
322{ 346{
347 struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
348
323 if (test_bit(PWMF_ENABLED, &pwm->flags)) { 349 if (test_bit(PWMF_ENABLED, &pwm->flags)) {
324 dev_warn(chip->dev, "Removing PWM device without disabling\n"); 350 dev_warn(chip->dev, "Removing PWM device without disabling\n");
325 pm_runtime_put_sync(chip->dev); 351 pm_runtime_put_sync(chip->dev);
326 } 352 }
353
354 /* set period value to zero on free */
355 pc->period_cycles[pwm->hwpwm] = 0;
327} 356}
328 357
329static const struct pwm_ops ehrpwm_pwm_ops = { 358static const struct pwm_ops ehrpwm_pwm_ops = {
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
index 6caa222af77a..ab00cab905b7 100644
--- a/drivers/regulator/tps65217-regulator.c
+++ b/drivers/regulator/tps65217-regulator.c
@@ -22,6 +22,7 @@
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24 24
25#include <linux/regulator/of_regulator.h>
25#include <linux/regulator/driver.h> 26#include <linux/regulator/driver.h>
26#include <linux/regulator/machine.h> 27#include <linux/regulator/machine.h>
27#include <linux/mfd/tps65217.h> 28#include <linux/mfd/tps65217.h>
@@ -281,37 +282,130 @@ static const struct regulator_desc regulators[] = {
281 NULL), 282 NULL),
282}; 283};
283 284
285#ifdef CONFIG_OF
286static struct of_regulator_match reg_matches[] = {
287 { .name = "dcdc1", .driver_data = (void *)TPS65217_DCDC_1 },
288 { .name = "dcdc2", .driver_data = (void *)TPS65217_DCDC_2 },
289 { .name = "dcdc3", .driver_data = (void *)TPS65217_DCDC_3 },
290 { .name = "ldo1", .driver_data = (void *)TPS65217_LDO_1 },
291 { .name = "ldo2", .driver_data = (void *)TPS65217_LDO_2 },
292 { .name = "ldo3", .driver_data = (void *)TPS65217_LDO_3 },
293 { .name = "ldo4", .driver_data = (void *)TPS65217_LDO_4 },
294};
295
296static struct tps65217_board *tps65217_parse_dt(struct platform_device *pdev)
297{
298 struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
299 struct device_node *node = tps->dev->of_node;
300 struct tps65217_board *pdata;
301 struct device_node *regs;
302 int i, count;
303
304 regs = of_find_node_by_name(node, "regulators");
305 if (!regs)
306 return NULL;
307
308 count = of_regulator_match(pdev->dev.parent, regs,
309 reg_matches, TPS65217_NUM_REGULATOR);
310 of_node_put(regs);
311 if ((count < 0) || (count > TPS65217_NUM_REGULATOR))
312 return NULL;
313
314 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
315 if (!pdata)
316 return NULL;
317
318 for (i = 0; i < count; i++) {
319 if (!reg_matches[i].init_data || !reg_matches[i].of_node)
320 continue;
321
322 pdata->tps65217_init_data[i] = reg_matches[i].init_data;
323 pdata->of_node[i] = reg_matches[i].of_node;
324 }
325
326 return pdata;
327}
328#else
329static struct tps65217_board *tps65217_parse_dt(struct platform_device *pdev)
330{
331 return NULL;
332}
333#endif
334
284static int __devinit tps65217_regulator_probe(struct platform_device *pdev) 335static int __devinit tps65217_regulator_probe(struct platform_device *pdev)
285{ 336{
337 struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
338 struct tps65217_board *pdata = dev_get_platdata(tps->dev);
339 struct regulator_init_data *reg_data;
286 struct regulator_dev *rdev; 340 struct regulator_dev *rdev;
287 struct tps65217 *tps;
288 struct tps_info *info = &tps65217_pmic_regs[pdev->id];
289 struct regulator_config config = { }; 341 struct regulator_config config = { };
342 int i, ret;
290 343
291 /* Already set by core driver */ 344 if (tps->dev->of_node)
292 tps = dev_to_tps65217(pdev->dev.parent); 345 pdata = tps65217_parse_dt(pdev);
293 tps->info[pdev->id] = info;
294 346
295 config.dev = &pdev->dev; 347 if (!pdata) {
296 config.of_node = pdev->dev.of_node; 348 dev_err(&pdev->dev, "Platform data not found\n");
297 config.init_data = pdev->dev.platform_data; 349 return -EINVAL;
298 config.driver_data = tps; 350 }
299 351
300 rdev = regulator_register(&regulators[pdev->id], &config); 352 if (tps65217_chip_id(tps) != TPS65217) {
301 if (IS_ERR(rdev)) 353 dev_err(&pdev->dev, "Invalid tps chip version\n");
302 return PTR_ERR(rdev); 354 return -ENODEV;
355 }
303 356
304 platform_set_drvdata(pdev, rdev); 357 platform_set_drvdata(pdev, tps);
305 358
359 for (i = 0; i < TPS65217_NUM_REGULATOR; i++) {
360
361 reg_data = pdata->tps65217_init_data[i];
362
363 /*
364 * Regulator API handles empty constraints but not NULL
365 * constraints
366 */
367 if (!reg_data)
368 continue;
369
370 /* Register the regulators */
371 tps->info[i] = &tps65217_pmic_regs[i];
372
373 config.dev = tps->dev;
374 config.init_data = reg_data;
375 config.driver_data = tps;
376 config.regmap = tps->regmap;
377 if (tps->dev->of_node)
378 config.of_node = pdata->of_node[i];
379
380 rdev = regulator_register(&regulators[i], &config);
381 if (IS_ERR(rdev)) {
382 dev_err(tps->dev, "failed to register %s regulator\n",
383 pdev->name);
384 ret = PTR_ERR(rdev);
385 goto err_unregister_regulator;
386 }
387
388 /* Save regulator for cleanup */
389 tps->rdev[i] = rdev;
390 }
306 return 0; 391 return 0;
392
393err_unregister_regulator:
394 while (--i >= 0)
395 regulator_unregister(tps->rdev[i]);
396
397 return ret;
307} 398}
308 399
309static int __devexit tps65217_regulator_remove(struct platform_device *pdev) 400static int __devexit tps65217_regulator_remove(struct platform_device *pdev)
310{ 401{
311 struct regulator_dev *rdev = platform_get_drvdata(pdev); 402 struct tps65217 *tps = platform_get_drvdata(pdev);
403 unsigned int i;
404
405 for (i = 0; i < TPS65217_NUM_REGULATOR; i++)
406 regulator_unregister(tps->rdev[i]);
312 407
313 platform_set_drvdata(pdev, NULL); 408 platform_set_drvdata(pdev, NULL);
314 regulator_unregister(rdev);
315 409
316 return 0; 410 return 0;
317} 411}
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 590cfafc7c17..1859f71372e2 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -1008,8 +1008,8 @@ static int rpmsg_probe(struct virtio_device *vdev)
1008 return 0; 1008 return 0;
1009 1009
1010free_coherent: 1010free_coherent:
1011 dma_free_coherent(vdev->dev.parent, RPMSG_TOTAL_BUF_SPACE, bufs_va, 1011 dma_free_coherent(vdev->dev.parent->parent, RPMSG_TOTAL_BUF_SPACE,
1012 vrp->bufs_dma); 1012 bufs_va, vrp->bufs_dma);
1013vqs_del: 1013vqs_del:
1014 vdev->config->del_vqs(vrp->vdev); 1014 vdev->config->del_vqs(vrp->vdev);
1015free_vrp: 1015free_vrp:
@@ -1043,7 +1043,7 @@ static void __devexit rpmsg_remove(struct virtio_device *vdev)
1043 1043
1044 vdev->config->del_vqs(vrp->vdev); 1044 vdev->config->del_vqs(vrp->vdev);
1045 1045
1046 dma_free_coherent(vdev->dev.parent, RPMSG_TOTAL_BUF_SPACE, 1046 dma_free_coherent(vdev->dev.parent->parent, RPMSG_TOTAL_BUF_SPACE,
1047 vrp->rbufs, vrp->bufs_dma); 1047 vrp->rbufs, vrp->bufs_dma);
1048 1048
1049 kfree(vrp); 1049 kfree(vrp);
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index c5d06fe83bba..9277d945bf48 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -495,6 +495,11 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev)
495 if (ret < 0) 495 if (ret < 0)
496 goto out1; 496 goto out1;
497 497
498 /* ensure interrupts are disabled, bootloaders can be strange */
499 ret = twl_rtc_write_u8(0, REG_RTC_INTERRUPTS_REG);
500 if (ret < 0)
501 dev_warn(&pdev->dev, "unable to disable interrupt\n");
502
498 /* init cached IRQ enable bits */ 503 /* init cached IRQ enable bits */
499 ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); 504 ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG);
500 if (ret < 0) 505 if (ret < 0)
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 15370a2c5ff0..0595c763dafd 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -534,11 +534,11 @@ static void dasd_change_state(struct dasd_device *device)
534 if (rc) 534 if (rc)
535 device->target = device->state; 535 device->target = device->state;
536 536
537 if (device->state == device->target)
538 wake_up(&dasd_init_waitq);
539
540 /* let user-space know that the device status changed */ 537 /* let user-space know that the device status changed */
541 kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE); 538 kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE);
539
540 if (device->state == device->target)
541 wake_up(&dasd_init_waitq);
542} 542}
543 543
544/* 544/*
@@ -2157,6 +2157,7 @@ static int _dasd_sleep_on(struct dasd_ccw_req *maincqr, int interruptible)
2157 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && 2157 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
2158 (!dasd_eer_enabled(device))) { 2158 (!dasd_eer_enabled(device))) {
2159 cqr->status = DASD_CQR_FAILED; 2159 cqr->status = DASD_CQR_FAILED;
2160 cqr->intrc = -EAGAIN;
2160 continue; 2161 continue;
2161 } 2162 }
2162 /* Don't try to start requests if device is stopped */ 2163 /* Don't try to start requests if device is stopped */
@@ -3270,6 +3271,16 @@ void dasd_generic_path_event(struct ccw_device *cdev, int *path_event)
3270 dasd_schedule_device_bh(device); 3271 dasd_schedule_device_bh(device);
3271 } 3272 }
3272 if (path_event[chp] & PE_PATHGROUP_ESTABLISHED) { 3273 if (path_event[chp] & PE_PATHGROUP_ESTABLISHED) {
3274 if (!(device->path_data.opm & eventlpm) &&
3275 !(device->path_data.tbvpm & eventlpm)) {
3276 /*
3277 * we can not establish a pathgroup on an
3278 * unavailable path, so trigger a path
3279 * verification first
3280 */
3281 device->path_data.tbvpm |= eventlpm;
3282 dasd_schedule_device_bh(device);
3283 }
3273 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 3284 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
3274 "Pathgroup re-established\n"); 3285 "Pathgroup re-established\n");
3275 if (device->discipline->kick_validate) 3286 if (device->discipline->kick_validate)
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 157defe5e069..6b556995bb33 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -384,6 +384,29 @@ static void _remove_device_from_lcu(struct alias_lcu *lcu,
384 group->next = NULL; 384 group->next = NULL;
385}; 385};
386 386
387static int
388suborder_not_supported(struct dasd_ccw_req *cqr)
389{
390 char *sense;
391 char reason;
392 char msg_format;
393 char msg_no;
394
395 sense = dasd_get_sense(&cqr->irb);
396 if (!sense)
397 return 0;
398
399 reason = sense[0];
400 msg_format = (sense[7] & 0xF0);
401 msg_no = (sense[7] & 0x0F);
402
403 /* command reject, Format 0 MSG 4 - invalid parameter */
404 if ((reason == 0x80) && (msg_format == 0x00) && (msg_no == 0x04))
405 return 1;
406
407 return 0;
408}
409
387static int read_unit_address_configuration(struct dasd_device *device, 410static int read_unit_address_configuration(struct dasd_device *device,
388 struct alias_lcu *lcu) 411 struct alias_lcu *lcu)
389{ 412{
@@ -435,6 +458,8 @@ static int read_unit_address_configuration(struct dasd_device *device,
435 458
436 do { 459 do {
437 rc = dasd_sleep_on(cqr); 460 rc = dasd_sleep_on(cqr);
461 if (rc && suborder_not_supported(cqr))
462 return -EOPNOTSUPP;
438 } while (rc && (cqr->retries > 0)); 463 } while (rc && (cqr->retries > 0));
439 if (rc) { 464 if (rc) {
440 spin_lock_irqsave(&lcu->lock, flags); 465 spin_lock_irqsave(&lcu->lock, flags);
@@ -521,7 +546,7 @@ static void lcu_update_work(struct work_struct *work)
521 * processing the data 546 * processing the data
522 */ 547 */
523 spin_lock_irqsave(&lcu->lock, flags); 548 spin_lock_irqsave(&lcu->lock, flags);
524 if (rc || (lcu->flags & NEED_UAC_UPDATE)) { 549 if ((rc && (rc != -EOPNOTSUPP)) || (lcu->flags & NEED_UAC_UPDATE)) {
525 DBF_DEV_EVENT(DBF_WARNING, device, "could not update" 550 DBF_DEV_EVENT(DBF_WARNING, device, "could not update"
526 " alias data in lcu (rc = %d), retry later", rc); 551 " alias data in lcu (rc = %d), retry later", rc);
527 schedule_delayed_work(&lcu->ruac_data.dwork, 30*HZ); 552 schedule_delayed_work(&lcu->ruac_data.dwork, 30*HZ);
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 2fb2b9ea97ec..c48c72abbefc 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1507,7 +1507,8 @@ static struct dasd_ccw_req *dasd_eckd_build_psf_ssc(struct dasd_device *device,
1507 * call might change behaviour of DASD devices. 1507 * call might change behaviour of DASD devices.
1508 */ 1508 */
1509static int 1509static int
1510dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav) 1510dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav,
1511 unsigned long flags)
1511{ 1512{
1512 struct dasd_ccw_req *cqr; 1513 struct dasd_ccw_req *cqr;
1513 int rc; 1514 int rc;
@@ -1516,10 +1517,19 @@ dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav)
1516 if (IS_ERR(cqr)) 1517 if (IS_ERR(cqr))
1517 return PTR_ERR(cqr); 1518 return PTR_ERR(cqr);
1518 1519
1520 /*
1521 * set flags e.g. turn on failfast, to prevent blocking
1522 * the calling function should handle failed requests
1523 */
1524 cqr->flags |= flags;
1525
1519 rc = dasd_sleep_on(cqr); 1526 rc = dasd_sleep_on(cqr);
1520 if (!rc) 1527 if (!rc)
1521 /* trigger CIO to reprobe devices */ 1528 /* trigger CIO to reprobe devices */
1522 css_schedule_reprobe(); 1529 css_schedule_reprobe();
1530 else if (cqr->intrc == -EAGAIN)
1531 rc = -EAGAIN;
1532
1523 dasd_sfree_request(cqr, cqr->memdev); 1533 dasd_sfree_request(cqr, cqr->memdev);
1524 return rc; 1534 return rc;
1525} 1535}
@@ -1527,7 +1537,8 @@ dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav)
1527/* 1537/*
1528 * Valide storage server of current device. 1538 * Valide storage server of current device.
1529 */ 1539 */
1530static void dasd_eckd_validate_server(struct dasd_device *device) 1540static int dasd_eckd_validate_server(struct dasd_device *device,
1541 unsigned long flags)
1531{ 1542{
1532 int rc; 1543 int rc;
1533 struct dasd_eckd_private *private; 1544 struct dasd_eckd_private *private;
@@ -1536,17 +1547,18 @@ static void dasd_eckd_validate_server(struct dasd_device *device)
1536 private = (struct dasd_eckd_private *) device->private; 1547 private = (struct dasd_eckd_private *) device->private;
1537 if (private->uid.type == UA_BASE_PAV_ALIAS || 1548 if (private->uid.type == UA_BASE_PAV_ALIAS ||
1538 private->uid.type == UA_HYPER_PAV_ALIAS) 1549 private->uid.type == UA_HYPER_PAV_ALIAS)
1539 return; 1550 return 0;
1540 if (dasd_nopav || MACHINE_IS_VM) 1551 if (dasd_nopav || MACHINE_IS_VM)
1541 enable_pav = 0; 1552 enable_pav = 0;
1542 else 1553 else
1543 enable_pav = 1; 1554 enable_pav = 1;
1544 rc = dasd_eckd_psf_ssc(device, enable_pav); 1555 rc = dasd_eckd_psf_ssc(device, enable_pav, flags);
1545 1556
1546 /* may be requested feature is not available on server, 1557 /* may be requested feature is not available on server,
1547 * therefore just report error and go ahead */ 1558 * therefore just report error and go ahead */
1548 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x " 1559 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x "
1549 "returned rc=%d", private->uid.ssid, rc); 1560 "returned rc=%d", private->uid.ssid, rc);
1561 return rc;
1550} 1562}
1551 1563
1552/* 1564/*
@@ -1556,7 +1568,13 @@ static void dasd_eckd_do_validate_server(struct work_struct *work)
1556{ 1568{
1557 struct dasd_device *device = container_of(work, struct dasd_device, 1569 struct dasd_device *device = container_of(work, struct dasd_device,
1558 kick_validate); 1570 kick_validate);
1559 dasd_eckd_validate_server(device); 1571 if (dasd_eckd_validate_server(device, DASD_CQR_FLAGS_FAILFAST)
1572 == -EAGAIN) {
1573 /* schedule worker again if failed */
1574 schedule_work(&device->kick_validate);
1575 return;
1576 }
1577
1560 dasd_put_device(device); 1578 dasd_put_device(device);
1561} 1579}
1562 1580
@@ -1685,7 +1703,7 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
1685 if (rc) 1703 if (rc)
1686 goto out_err2; 1704 goto out_err2;
1687 1705
1688 dasd_eckd_validate_server(device); 1706 dasd_eckd_validate_server(device, 0);
1689 1707
1690 /* device may report different configuration data after LCU setup */ 1708 /* device may report different configuration data after LCU setup */
1691 rc = dasd_eckd_read_conf(device); 1709 rc = dasd_eckd_read_conf(device);
@@ -4153,7 +4171,7 @@ static int dasd_eckd_restore_device(struct dasd_device *device)
4153 rc = dasd_alias_make_device_known_to_lcu(device); 4171 rc = dasd_alias_make_device_known_to_lcu(device);
4154 if (rc) 4172 if (rc)
4155 return rc; 4173 return rc;
4156 dasd_eckd_validate_server(device); 4174 dasd_eckd_validate_server(device, DASD_CQR_FLAGS_FAILFAST);
4157 4175
4158 /* RE-Read Configuration Data */ 4176 /* RE-Read Configuration Data */
4159 rc = dasd_eckd_read_conf(device); 4177 rc = dasd_eckd_read_conf(device);
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index ed25c8740a9c..fc916f5d7314 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1426,6 +1426,8 @@ static enum io_sch_action sch_get_action(struct subchannel *sch)
1426 return IO_SCH_REPROBE; 1426 return IO_SCH_REPROBE;
1427 if (cdev->online) 1427 if (cdev->online)
1428 return IO_SCH_VERIFY; 1428 return IO_SCH_VERIFY;
1429 if (cdev->private->state == DEV_STATE_NOT_OPER)
1430 return IO_SCH_UNREG_ATTACH;
1429 return IO_SCH_NOP; 1431 return IO_SCH_NOP;
1430} 1432}
1431 1433
@@ -1519,11 +1521,14 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process)
1519 goto out; 1521 goto out;
1520 break; 1522 break;
1521 case IO_SCH_UNREG_ATTACH: 1523 case IO_SCH_UNREG_ATTACH:
1524 spin_lock_irqsave(sch->lock, flags);
1522 if (cdev->private->flags.resuming) { 1525 if (cdev->private->flags.resuming) {
1523 /* Device will be handled later. */ 1526 /* Device will be handled later. */
1524 rc = 0; 1527 rc = 0;
1525 goto out; 1528 goto out_unlock;
1526 } 1529 }
1530 sch_set_cdev(sch, NULL);
1531 spin_unlock_irqrestore(sch->lock, flags);
1527 /* Unregister ccw device. */ 1532 /* Unregister ccw device. */
1528 ccw_device_unregister(cdev); 1533 ccw_device_unregister(cdev);
1529 break; 1534 break;
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 33d6630529de..91eec60252ee 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1264,6 +1264,9 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
1264 int rc = 0; 1264 int rc = 0;
1265 u64 mask64; 1265 u64 mask64;
1266 1266
1267 memset(&iscsi_init, 0x00, sizeof(struct iscsi_kwqe_init1));
1268 memset(&iscsi_init2, 0x00, sizeof(struct iscsi_kwqe_init2));
1269
1267 bnx2i_adjust_qp_size(hba); 1270 bnx2i_adjust_qp_size(hba);
1268 1271
1269 iscsi_init.flags = 1272 iscsi_init.flags =
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 796482badf13..2b4261cb7742 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1315,8 +1315,9 @@ static void complete_scsi_command(struct CommandList *cp)
1315 } 1315 }
1316 break; 1316 break;
1317 case CMD_PROTOCOL_ERR: 1317 case CMD_PROTOCOL_ERR:
1318 cmd->result = DID_ERROR << 16;
1318 dev_warn(&h->pdev->dev, "cp %p has " 1319 dev_warn(&h->pdev->dev, "cp %p has "
1319 "protocol error \n", cp); 1320 "protocol error\n", cp);
1320 break; 1321 break;
1321 case CMD_HARDWARE_ERR: 1322 case CMD_HARDWARE_ERR:
1322 cmd->result = DID_ERROR << 16; 1323 cmd->result = DID_ERROR << 16;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index dc27598785e5..ed38454228c6 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4066,7 +4066,6 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4066 spin_lock_init(&instance->cmd_pool_lock); 4066 spin_lock_init(&instance->cmd_pool_lock);
4067 spin_lock_init(&instance->hba_lock); 4067 spin_lock_init(&instance->hba_lock);
4068 spin_lock_init(&instance->completion_lock); 4068 spin_lock_init(&instance->completion_lock);
4069 spin_lock_init(&poll_aen_lock);
4070 4069
4071 mutex_init(&instance->aen_mutex); 4070 mutex_init(&instance->aen_mutex);
4072 mutex_init(&instance->reset_mutex); 4071 mutex_init(&instance->reset_mutex);
@@ -5392,6 +5391,8 @@ static int __init megasas_init(void)
5392 printk(KERN_INFO "megasas: %s %s\n", MEGASAS_VERSION, 5391 printk(KERN_INFO "megasas: %s %s\n", MEGASAS_VERSION,
5393 MEGASAS_EXT_VERSION); 5392 MEGASAS_EXT_VERSION);
5394 5393
5394 spin_lock_init(&poll_aen_lock);
5395
5395 support_poll_for_event = 2; 5396 support_poll_for_event = 2;
5396 support_device_change = 1; 5397 support_device_change = 1;
5397 5398
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 9d46fcbe7755..9d5a56c4b332 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -1209,6 +1209,13 @@ _base_check_enable_msix(struct MPT2SAS_ADAPTER *ioc)
1209 u16 message_control; 1209 u16 message_control;
1210 1210
1211 1211
1212 /* Check whether controller SAS2008 B0 controller,
1213 if it is SAS2008 B0 controller use IO-APIC instead of MSIX */
1214 if (ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2008 &&
1215 ioc->pdev->revision == 0x01) {
1216 return -EINVAL;
1217 }
1218
1212 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX); 1219 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX);
1213 if (!base) { 1220 if (!base) {
1214 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "msix not " 1221 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "msix not "
@@ -2424,10 +2431,13 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2424 } 2431 }
2425 2432
2426 /* command line tunables for max controller queue depth */ 2433 /* command line tunables for max controller queue depth */
2427 if (max_queue_depth != -1) 2434 if (max_queue_depth != -1 && max_queue_depth != 0) {
2428 max_request_credit = (max_queue_depth < facts->RequestCredit) 2435 max_request_credit = min_t(u16, max_queue_depth +
2429 ? max_queue_depth : facts->RequestCredit; 2436 ioc->hi_priority_depth + ioc->internal_depth,
2430 else 2437 facts->RequestCredit);
2438 if (max_request_credit > MAX_HBA_QUEUE_DEPTH)
2439 max_request_credit = MAX_HBA_QUEUE_DEPTH;
2440 } else
2431 max_request_credit = min_t(u16, facts->RequestCredit, 2441 max_request_credit = min_t(u16, facts->RequestCredit,
2432 MAX_HBA_QUEUE_DEPTH); 2442 MAX_HBA_QUEUE_DEPTH);
2433 2443
@@ -2502,7 +2512,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2502 /* set the scsi host can_queue depth 2512 /* set the scsi host can_queue depth
2503 * with some internal commands that could be outstanding 2513 * with some internal commands that could be outstanding
2504 */ 2514 */
2505 ioc->shost->can_queue = ioc->scsiio_depth - (2); 2515 ioc->shost->can_queue = ioc->scsiio_depth;
2506 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: " 2516 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: "
2507 "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue)); 2517 "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue));
2508 2518
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 4a6381c87253..de2337f255a7 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -42,6 +42,8 @@
42 42
43#include <trace/events/scsi.h> 43#include <trace/events/scsi.h>
44 44
45static void scsi_eh_done(struct scsi_cmnd *scmd);
46
45#define SENSE_TIMEOUT (10*HZ) 47#define SENSE_TIMEOUT (10*HZ)
46 48
47/* 49/*
@@ -241,6 +243,14 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
241 if (! scsi_command_normalize_sense(scmd, &sshdr)) 243 if (! scsi_command_normalize_sense(scmd, &sshdr))
242 return FAILED; /* no valid sense data */ 244 return FAILED; /* no valid sense data */
243 245
246 if (scmd->cmnd[0] == TEST_UNIT_READY && scmd->scsi_done != scsi_eh_done)
247 /*
248 * nasty: for mid-layer issued TURs, we need to return the
249 * actual sense data without any recovery attempt. For eh
250 * issued ones, we need to try to recover and interpret
251 */
252 return SUCCESS;
253
244 if (scsi_sense_is_deferred(&sshdr)) 254 if (scsi_sense_is_deferred(&sshdr))
245 return NEEDS_RETRY; 255 return NEEDS_RETRY;
246 256
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ffd77739ae3e..faa790fba134 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -776,7 +776,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
776 } 776 }
777 777
778 if (req->cmd_type == REQ_TYPE_BLOCK_PC) { /* SG_IO ioctl from block level */ 778 if (req->cmd_type == REQ_TYPE_BLOCK_PC) { /* SG_IO ioctl from block level */
779 req->errors = result;
780 if (result) { 779 if (result) {
781 if (sense_valid && req->sense) { 780 if (sense_valid && req->sense) {
782 /* 781 /*
@@ -792,6 +791,10 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
792 if (!sense_deferred) 791 if (!sense_deferred)
793 error = __scsi_error_from_host_byte(cmd, result); 792 error = __scsi_error_from_host_byte(cmd, result);
794 } 793 }
794 /*
795 * __scsi_error_from_host_byte may have reset the host_byte
796 */
797 req->errors = cmd->result;
795 798
796 req->resid_len = scsi_get_resid(cmd); 799 req->resid_len = scsi_get_resid(cmd);
797 800
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 56a93794c470..d947ffc20ceb 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -764,6 +764,16 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
764 sdev->model = (char *) (sdev->inquiry + 16); 764 sdev->model = (char *) (sdev->inquiry + 16);
765 sdev->rev = (char *) (sdev->inquiry + 32); 765 sdev->rev = (char *) (sdev->inquiry + 32);
766 766
767 if (strncmp(sdev->vendor, "ATA ", 8) == 0) {
768 /*
769 * sata emulation layer device. This is a hack to work around
770 * the SATL power management specifications which state that
771 * when the SATL detects the device has gone into standby
772 * mode, it shall respond with NOT READY.
773 */
774 sdev->allow_restart = 1;
775 }
776
767 if (*bflags & BLIST_ISROM) { 777 if (*bflags & BLIST_ISROM) {
768 sdev->type = TYPE_ROM; 778 sdev->type = TYPE_ROM;
769 sdev->removable = 1; 779 sdev->removable = 1;
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index c7030fbee79c..3e79a2f00042 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -331,7 +331,7 @@ static void virtscsi_map_sgl(struct scatterlist *sg, unsigned int *p_idx,
331 int i; 331 int i;
332 332
333 for_each_sg(table->sgl, sg_elem, table->nents, i) 333 for_each_sg(table->sgl, sg_elem, table->nents, i)
334 sg_set_buf(&sg[idx++], sg_virt(sg_elem), sg_elem->length); 334 sg[idx++] = *sg_elem;
335 335
336 *p_idx = idx; 336 *p_idx = idx;
337} 337}
diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 32c26d795ed0..8f32a1323a79 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -355,7 +355,7 @@ int __init register_intc_controller(struct intc_desc *desc)
355 if (unlikely(res)) { 355 if (unlikely(res)) {
356 if (res == -EEXIST) { 356 if (res == -EEXIST) {
357 res = irq_domain_associate(d->domain, 357 res = irq_domain_associate(d->domain,
358 irq, irq); 358 irq2, irq2);
359 if (unlikely(res)) { 359 if (unlikely(res)) {
360 pr_err("domain association " 360 pr_err("domain association "
361 "failure\n"); 361 "failure\n");
diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index 2804eaae804e..a3ac39b79192 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -211,7 +211,8 @@ static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev,
211 break; 211 break;
212 default: 212 default:
213 pr_err("Unsupported mux type (%d), bailing...\n", pinmux_type); 213 pr_err("Unsupported mux type (%d), bailing...\n", pinmux_type);
214 return -ENOTSUPP; 214 ret = -ENOTSUPP;
215 goto err;
215 } 216 }
216 217
217 ret = 0; 218 ret = 0;
diff --git a/drivers/staging/android/android_alarm.h b/drivers/staging/android/android_alarm.h
index d0cafd637199..f2ffd963f1c3 100644
--- a/drivers/staging/android/android_alarm.h
+++ b/drivers/staging/android/android_alarm.h
@@ -51,10 +51,12 @@ enum android_alarm_return_flags {
51#define ANDROID_ALARM_WAIT _IO('a', 1) 51#define ANDROID_ALARM_WAIT _IO('a', 1)
52 52
53#define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size) 53#define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size)
54#define ALARM_IOR(c, type, size) _IOR('a', (c) | ((type) << 4), size)
55
54/* Set alarm */ 56/* Set alarm */
55#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) 57#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec)
56#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) 58#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec)
57#define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec) 59#define ANDROID_ALARM_GET_TIME(type) ALARM_IOR(4, type, struct timespec)
58#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) 60#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec)
59#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) 61#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0)))
60#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) 62#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4)
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c
index 6c81e377262c..cc8931fde839 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200.c
@@ -1412,6 +1412,13 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev,
1412 dev_err(dev->class_dev, "BUG! cannot determine board type!\n"); 1412 dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
1413 return -EINVAL; 1413 return -EINVAL;
1414 } 1414 }
1415 /*
1416 * Need to 'get' the PCI device to match the 'put' in dio200_detach().
1417 * TODO: Remove the pci_dev_get() and matching pci_dev_put() once
1418 * support for manual attachment of PCI devices via dio200_attach()
1419 * has been removed.
1420 */
1421 pci_dev_get(pci_dev);
1415 return dio200_pci_common_attach(dev, pci_dev); 1422 return dio200_pci_common_attach(dev, pci_dev);
1416} 1423}
1417 1424
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c
index aabba9886b7d..f50287903038 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/staging/comedi/drivers/amplc_pc236.c
@@ -565,6 +565,13 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev,
565 dev_err(dev->class_dev, "BUG! cannot determine board type!\n"); 565 dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
566 return -EINVAL; 566 return -EINVAL;
567 } 567 }
568 /*
569 * Need to 'get' the PCI device to match the 'put' in pc236_detach().
570 * TODO: Remove the pci_dev_get() and matching pci_dev_put() once
571 * support for manual attachment of PCI devices via pc236_attach()
572 * has been removed.
573 */
574 pci_dev_get(pci_dev);
568 return pc236_pci_common_attach(dev, pci_dev); 575 return pc236_pci_common_attach(dev, pci_dev);
569} 576}
570 577
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c
index 40ec1ffebba6..8191c4e28e0a 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/staging/comedi/drivers/amplc_pc263.c
@@ -298,6 +298,13 @@ static int __devinit pc263_attach_pci(struct comedi_device *dev,
298 dev_err(dev->class_dev, "BUG! cannot determine board type!\n"); 298 dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
299 return -EINVAL; 299 return -EINVAL;
300 } 300 }
301 /*
302 * Need to 'get' the PCI device to match the 'put' in pc263_detach().
303 * TODO: Remove the pci_dev_get() and matching pci_dev_put() once
304 * support for manual attachment of PCI devices via pc263_attach()
305 * has been removed.
306 */
307 pci_dev_get(pci_dev);
301 return pc263_pci_common_attach(dev, pci_dev); 308 return pc263_pci_common_attach(dev, pci_dev);
302} 309}
303 310
diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c
index 4e17f13e57f6..8bf109e7bb05 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -1503,6 +1503,13 @@ pci224_attach_pci(struct comedi_device *dev, struct pci_dev *pci_dev)
1503 DRIVER_NAME ": BUG! cannot determine board type!\n"); 1503 DRIVER_NAME ": BUG! cannot determine board type!\n");
1504 return -EINVAL; 1504 return -EINVAL;
1505 } 1505 }
1506 /*
1507 * Need to 'get' the PCI device to match the 'put' in pci224_detach().
1508 * TODO: Remove the pci_dev_get() and matching pci_dev_put() once
1509 * support for manual attachment of PCI devices via pci224_attach()
1510 * has been removed.
1511 */
1512 pci_dev_get(pci_dev);
1506 return pci224_attach_common(dev, pci_dev, NULL); 1513 return pci224_attach_common(dev, pci_dev, NULL);
1507} 1514}
1508 1515
diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
index 1b67d0c61fa7..66e74bd12267 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -2925,6 +2925,13 @@ static int __devinit pci230_attach_pci(struct comedi_device *dev,
2925 "amplc_pci230: BUG! cannot determine board type!\n"); 2925 "amplc_pci230: BUG! cannot determine board type!\n");
2926 return -EINVAL; 2926 return -EINVAL;
2927 } 2927 }
2928 /*
2929 * Need to 'get' the PCI device to match the 'put' in pci230_detach().
2930 * TODO: Remove the pci_dev_get() and matching pci_dev_put() once
2931 * support for manual attachment of PCI devices via pci230_attach()
2932 * has been removed.
2933 */
2934 pci_dev_get(pci_dev);
2928 return pci230_attach_common(dev, pci_dev); 2935 return pci230_attach_common(dev, pci_dev);
2929} 2936}
2930 2937
diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index 874e02e47668..67a914a10b55 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -378,7 +378,7 @@ das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
378 int chan; 378 int chan;
379 379
380 lsb = data[0] & 0xff; 380 lsb = data[0] & 0xff;
381 msb = (data[0] >> 8) & 0xf; 381 msb = (data[0] >> 8) & 0xff;
382 382
383 chan = CR_CHAN(insn->chanspec); 383 chan = CR_CHAN(insn->chanspec);
384 384
@@ -623,7 +623,7 @@ static const struct das08_board_struct das08_boards[] = {
623 .ai = das08_ai_rinsn, 623 .ai = das08_ai_rinsn,
624 .ai_nbits = 16, 624 .ai_nbits = 16,
625 .ai_pg = das08_pg_none, 625 .ai_pg = das08_pg_none,
626 .ai_encoding = das08_encode12, 626 .ai_encoding = das08_encode16,
627 .ao = das08jr_ao_winsn, 627 .ao = das08jr_ao_winsn,
628 .ao_nbits = 16, 628 .ao_nbits = 16,
629 .di = das08jr_di_rbits, 629 .di = das08jr_di_rbits,
@@ -922,6 +922,13 @@ das08_attach_pci(struct comedi_device *dev, struct pci_dev *pdev)
922 dev_err(dev->class_dev, "BUG! cannot determine board type!\n"); 922 dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
923 return -EINVAL; 923 return -EINVAL;
924 } 924 }
925 /*
926 * Need to 'get' the PCI device to match the 'put' in das08_detach().
927 * TODO: Remove the pci_dev_get() and matching pci_dev_put() once
928 * support for manual attachment of PCI devices via das08_attach()
929 * has been removed.
930 */
931 pci_dev_get(pdev);
925 return das08_pci_attach_common(dev, pdev); 932 return das08_pci_attach_common(dev, pdev);
926} 933}
927 934
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index 18d108fd967a..f3da59063ed2 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -121,8 +121,10 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
121 if (rx_array == NULL) 121 if (rx_array == NULL)
122 return -ENOMEM; 122 return -ENOMEM;
123 ret = lis3l02dq_read_all(indio_dev, rx_array); 123 ret = lis3l02dq_read_all(indio_dev, rx_array);
124 if (ret < 0) 124 if (ret < 0) {
125 kfree(rx_array);
125 return ret; 126 return ret;
127 }
126 for (i = 0; i < scan_count; i++) 128 for (i = 0; i < scan_count; i++)
127 data[i] = combine_8_to_16(rx_array[i*4+1], 129 data[i] = combine_8_to_16(rx_array[i*4+1],
128 rx_array[i*4+3]); 130 rx_array[i*4+3]);
diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index 095837285f4f..19a064d649e3 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -647,6 +647,8 @@ static ssize_t ad7192_write_frequency(struct device *dev,
647 ret = strict_strtoul(buf, 10, &lval); 647 ret = strict_strtoul(buf, 10, &lval);
648 if (ret) 648 if (ret)
649 return ret; 649 return ret;
650 if (lval == 0)
651 return -EINVAL;
650 652
651 mutex_lock(&indio_dev->mlock); 653 mutex_lock(&indio_dev->mlock);
652 if (iio_buffer_enabled(indio_dev)) { 654 if (iio_buffer_enabled(indio_dev)) {
diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c
index 93aa431287ac..eb8e9d69efd3 100644
--- a/drivers/staging/iio/gyro/adis16260_core.c
+++ b/drivers/staging/iio/gyro/adis16260_core.c
@@ -195,6 +195,8 @@ static ssize_t adis16260_write_frequency(struct device *dev,
195 ret = strict_strtol(buf, 10, &val); 195 ret = strict_strtol(buf, 10, &val);
196 if (ret) 196 if (ret)
197 return ret; 197 return ret;
198 if (val == 0)
199 return -EINVAL;
198 200
199 mutex_lock(&indio_dev->mlock); 201 mutex_lock(&indio_dev->mlock);
200 if (spi_get_device_id(st->us)) { 202 if (spi_get_device_id(st->us)) {
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index 1f4c17779b5a..a618327e06ed 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -234,6 +234,8 @@ static ssize_t adis16400_write_frequency(struct device *dev,
234 ret = strict_strtol(buf, 10, &val); 234 ret = strict_strtol(buf, 10, &val);
235 if (ret) 235 if (ret)
236 return ret; 236 return ret;
237 if (val == 0)
238 return -EINVAL;
237 239
238 mutex_lock(&indio_dev->mlock); 240 mutex_lock(&indio_dev->mlock);
239 241
diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
index f04ece7fbc2f..3ccff189f258 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -425,6 +425,8 @@ static ssize_t ade7753_write_frequency(struct device *dev,
425 ret = strict_strtol(buf, 10, &val); 425 ret = strict_strtol(buf, 10, &val);
426 if (ret) 426 if (ret)
427 return ret; 427 return ret;
428 if (val == 0)
429 return -EINVAL;
428 430
429 mutex_lock(&indio_dev->mlock); 431 mutex_lock(&indio_dev->mlock);
430 432
diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c
index 6cee28a5e877..abb1e9c8d094 100644
--- a/drivers/staging/iio/meter/ade7754.c
+++ b/drivers/staging/iio/meter/ade7754.c
@@ -445,6 +445,8 @@ static ssize_t ade7754_write_frequency(struct device *dev,
445 ret = strict_strtol(buf, 10, &val); 445 ret = strict_strtol(buf, 10, &val);
446 if (ret) 446 if (ret)
447 return ret; 447 return ret;
448 if (val == 0)
449 return -EINVAL;
448 450
449 mutex_lock(&indio_dev->mlock); 451 mutex_lock(&indio_dev->mlock);
450 452
diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c
index b3f7e0fa9612..eb0a2a98f388 100644
--- a/drivers/staging/iio/meter/ade7759.c
+++ b/drivers/staging/iio/meter/ade7759.c
@@ -385,6 +385,8 @@ static ssize_t ade7759_write_frequency(struct device *dev,
385 ret = strict_strtol(buf, 10, &val); 385 ret = strict_strtol(buf, 10, &val);
386 if (ret) 386 if (ret)
387 return ret; 387 return ret;
388 if (val == 0)
389 return -EINVAL;
388 390
389 mutex_lock(&indio_dev->mlock); 391 mutex_lock(&indio_dev->mlock);
390 392
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 695ea35f75b0..d0a7e408efe9 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -837,7 +837,7 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
837 } 837 }
838 838
839 ret = mfd_add_devices(nvec->dev, -1, nvec_devices, 839 ret = mfd_add_devices(nvec->dev, -1, nvec_devices,
840 ARRAY_SIZE(nvec_devices), base, 0); 840 ARRAY_SIZE(nvec_devices), base, 0, NULL);
841 if (ret) 841 if (ret)
842 dev_err(nvec->dev, "error adding subdevices\n"); 842 dev_err(nvec->dev, "error adding subdevices\n");
843 843
diff --git a/drivers/staging/omapdrm/omap_connector.c b/drivers/staging/omapdrm/omap_connector.c
index 5e2856c0e0bb..55e9c8655850 100644
--- a/drivers/staging/omapdrm/omap_connector.c
+++ b/drivers/staging/omapdrm/omap_connector.c
@@ -48,13 +48,20 @@ static inline void copy_timings_omap_to_drm(struct drm_display_mode *mode,
48 mode->vsync_end = mode->vsync_start + timings->vsw; 48 mode->vsync_end = mode->vsync_start + timings->vsw;
49 mode->vtotal = mode->vsync_end + timings->vbp; 49 mode->vtotal = mode->vsync_end + timings->vbp;
50 50
51 /* note: whether or not it is interlaced, +/- h/vsync, etc, 51 mode->flags = 0;
52 * which should be set in the mode flags, is not exposed in 52
53 * the omap_video_timings struct.. but hdmi driver tracks 53 if (timings->interlace)
54 * those separately so all we have to have to set the mode 54 mode->flags |= DRM_MODE_FLAG_INTERLACE;
55 * is the way to recover these timings values, and the 55
56 * omap_dss_driver would do the rest. 56 if (timings->hsync_level == OMAPDSS_SIG_ACTIVE_HIGH)
57 */ 57 mode->flags |= DRM_MODE_FLAG_PHSYNC;
58 else
59 mode->flags |= DRM_MODE_FLAG_NHSYNC;
60
61 if (timings->vsync_level == OMAPDSS_SIG_ACTIVE_HIGH)
62 mode->flags |= DRM_MODE_FLAG_PVSYNC;
63 else
64 mode->flags |= DRM_MODE_FLAG_NVSYNC;
58} 65}
59 66
60static inline void copy_timings_drm_to_omap(struct omap_video_timings *timings, 67static inline void copy_timings_drm_to_omap(struct omap_video_timings *timings,
@@ -71,6 +78,22 @@ static inline void copy_timings_drm_to_omap(struct omap_video_timings *timings,
71 timings->vfp = mode->vsync_start - mode->vdisplay; 78 timings->vfp = mode->vsync_start - mode->vdisplay;
72 timings->vsw = mode->vsync_end - mode->vsync_start; 79 timings->vsw = mode->vsync_end - mode->vsync_start;
73 timings->vbp = mode->vtotal - mode->vsync_end; 80 timings->vbp = mode->vtotal - mode->vsync_end;
81
82 timings->interlace = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
83
84 if (mode->flags & DRM_MODE_FLAG_PHSYNC)
85 timings->hsync_level = OMAPDSS_SIG_ACTIVE_HIGH;
86 else
87 timings->hsync_level = OMAPDSS_SIG_ACTIVE_LOW;
88
89 if (mode->flags & DRM_MODE_FLAG_PVSYNC)
90 timings->vsync_level = OMAPDSS_SIG_ACTIVE_HIGH;
91 else
92 timings->vsync_level = OMAPDSS_SIG_ACTIVE_LOW;
93
94 timings->data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE;
95 timings->de_level = OMAPDSS_SIG_ACTIVE_HIGH;
96 timings->sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES;
74} 97}
75 98
76static void omap_connector_dpms(struct drm_connector *connector, int mode) 99static void omap_connector_dpms(struct drm_connector *connector, int mode)
@@ -187,7 +210,7 @@ static int omap_connector_get_modes(struct drm_connector *connector)
187 } 210 }
188 } else { 211 } else {
189 struct drm_display_mode *mode = drm_mode_create(dev); 212 struct drm_display_mode *mode = drm_mode_create(dev);
190 struct omap_video_timings timings; 213 struct omap_video_timings timings = {0};
191 214
192 dssdrv->get_timings(dssdev, &timings); 215 dssdrv->get_timings(dssdev, &timings);
193 216
@@ -291,7 +314,7 @@ void omap_connector_mode_set(struct drm_connector *connector,
291 struct omap_connector *omap_connector = to_omap_connector(connector); 314 struct omap_connector *omap_connector = to_omap_connector(connector);
292 struct omap_dss_device *dssdev = omap_connector->dssdev; 315 struct omap_dss_device *dssdev = omap_connector->dssdev;
293 struct omap_dss_driver *dssdrv = dssdev->driver; 316 struct omap_dss_driver *dssdrv = dssdev->driver;
294 struct omap_video_timings timings; 317 struct omap_video_timings timings = {0};
295 318
296 copy_timings_drm_to_omap(&timings, mode); 319 copy_timings_drm_to_omap(&timings, mode);
297 320
diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
index d98321945802..758ce0a8d82e 100644
--- a/drivers/staging/ozwpan/ozcdev.c
+++ b/drivers/staging/ozwpan/ozcdev.c
@@ -8,6 +8,7 @@
8#include <linux/cdev.h> 8#include <linux/cdev.h>
9#include <linux/uaccess.h> 9#include <linux/uaccess.h>
10#include <linux/netdevice.h> 10#include <linux/netdevice.h>
11#include <linux/etherdevice.h>
11#include <linux/poll.h> 12#include <linux/poll.h>
12#include <linux/sched.h> 13#include <linux/sched.h>
13#include "ozconfig.h" 14#include "ozconfig.h"
@@ -213,7 +214,7 @@ static int oz_set_active_pd(u8 *addr)
213 if (old_pd) 214 if (old_pd)
214 oz_pd_put(old_pd); 215 oz_pd_put(old_pd);
215 } else { 216 } else {
216 if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) { 217 if (is_zero_ether_addr(addr)) {
217 spin_lock_bh(&g_cdev.lock); 218 spin_lock_bh(&g_cdev.lock);
218 pd = g_cdev.active_pd; 219 pd = g_cdev.active_pd;
219 g_cdev.active_pd = 0; 220 g_cdev.active_pd = 0;
diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c
index 0e26d5f6cf2d..495ee1205e02 100644
--- a/drivers/staging/rtl8712/recv_linux.c
+++ b/drivers/staging/rtl8712/recv_linux.c
@@ -117,13 +117,8 @@ void r8712_recv_indicatepkt(struct _adapter *padapter,
117 if (skb == NULL) 117 if (skb == NULL)
118 goto _recv_indicatepkt_drop; 118 goto _recv_indicatepkt_drop;
119 skb->data = precv_frame->u.hdr.rx_data; 119 skb->data = precv_frame->u.hdr.rx_data;
120#ifdef NET_SKBUFF_DATA_USES_OFFSET
121 skb->tail = (sk_buff_data_t)(precv_frame->u.hdr.rx_tail -
122 precv_frame->u.hdr.rx_head);
123#else
124 skb->tail = (sk_buff_data_t)precv_frame->u.hdr.rx_tail;
125#endif
126 skb->len = precv_frame->u.hdr.len; 120 skb->len = precv_frame->u.hdr.len;
121 skb_set_tail_pointer(skb, skb->len);
127 if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1)) 122 if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
128 skb->ip_summed = CHECKSUM_UNNECESSARY; 123 skb->ip_summed = CHECKSUM_UNNECESSARY;
129 else 124 else
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index e4bdf2a2b582..3aa895ec6507 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -200,7 +200,7 @@ s_vProcessRxMACHeader (
200 } else if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) { 200 } else if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) {
201 cbHeaderSize += 6; 201 cbHeaderSize += 6;
202 pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize); 202 pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
203 if ((*pwType == cpu_to_le16(ETH_P_IPX)) || 203 if ((*pwType == cpu_to_be16(ETH_P_IPX)) ||
204 (*pwType == cpu_to_le16(0xF380))) { 204 (*pwType == cpu_to_le16(0xF380))) {
205 cbHeaderSize -= 8; 205 cbHeaderSize -= 8;
206 pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize); 206 pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index bb464527fc1b..b6e04e7b629b 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -1699,7 +1699,7 @@ s_bPacketToWirelessUsb(
1699 // 802.1H 1699 // 802.1H
1700 if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { 1700 if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) {
1701 if (pDevice->dwDiagRefCount == 0) { 1701 if (pDevice->dwDiagRefCount == 0) {
1702 if ((psEthHeader->wType == cpu_to_le16(ETH_P_IPX)) || 1702 if ((psEthHeader->wType == cpu_to_be16(ETH_P_IPX)) ||
1703 (psEthHeader->wType == cpu_to_le16(0xF380))) { 1703 (psEthHeader->wType == cpu_to_le16(0xF380))) {
1704 memcpy((PBYTE) (pbyPayloadHead), 1704 memcpy((PBYTE) (pbyPayloadHead),
1705 abySNAP_Bridgetunnel, 6); 1705 abySNAP_Bridgetunnel, 6);
@@ -2838,10 +2838,10 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
2838 Packet_Type = skb->data[ETH_HLEN+1]; 2838 Packet_Type = skb->data[ETH_HLEN+1];
2839 Descriptor_type = skb->data[ETH_HLEN+1+1+2]; 2839 Descriptor_type = skb->data[ETH_HLEN+1+1+2];
2840 Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]); 2840 Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]);
2841 if (pDevice->sTxEthHeader.wType == cpu_to_le16(ETH_P_PAE)) { 2841 if (pDevice->sTxEthHeader.wType == cpu_to_be16(ETH_P_PAE)) {
2842 /* 802.1x OR eapol-key challenge frame transfer */ 2842 /* 802.1x OR eapol-key challenge frame transfer */
2843 if (((Protocol_Version == 1) || (Protocol_Version == 2)) && 2843 if (((Protocol_Version == 1) || (Protocol_Version == 2)) &&
2844 (Packet_Type == 3)) { 2844 (Packet_Type == 3)) {
2845 bTxeapol_key = TRUE; 2845 bTxeapol_key = TRUE;
2846 if(!(Key_info & BIT3) && //WPA or RSN group-key challenge 2846 if(!(Key_info & BIT3) && //WPA or RSN group-key challenge
2847 (Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key 2847 (Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key
@@ -2987,19 +2987,19 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
2987 } 2987 }
2988 } 2988 }
2989 2989
2990 if (pDevice->sTxEthHeader.wType == cpu_to_le16(ETH_P_PAE)) { 2990 if (pDevice->sTxEthHeader.wType == cpu_to_be16(ETH_P_PAE)) {
2991 if (pDevice->byBBType != BB_TYPE_11A) { 2991 if (pDevice->byBBType != BB_TYPE_11A) {
2992 pDevice->wCurrentRate = RATE_1M; 2992 pDevice->wCurrentRate = RATE_1M;
2993 pDevice->byACKRate = RATE_1M; 2993 pDevice->byACKRate = RATE_1M;
2994 pDevice->byTopCCKBasicRate = RATE_1M; 2994 pDevice->byTopCCKBasicRate = RATE_1M;
2995 pDevice->byTopOFDMBasicRate = RATE_6M; 2995 pDevice->byTopOFDMBasicRate = RATE_6M;
2996 } else { 2996 } else {
2997 pDevice->wCurrentRate = RATE_6M; 2997 pDevice->wCurrentRate = RATE_6M;
2998 pDevice->byACKRate = RATE_6M; 2998 pDevice->byACKRate = RATE_6M;
2999 pDevice->byTopCCKBasicRate = RATE_1M; 2999 pDevice->byTopCCKBasicRate = RATE_1M;
3000 pDevice->byTopOFDMBasicRate = RATE_6M; 3000 pDevice->byTopOFDMBasicRate = RATE_6M;
3001 } 3001 }
3002 } 3002 }
3003 3003
3004 DBG_PRT(MSG_LEVEL_DEBUG, 3004 DBG_PRT(MSG_LEVEL_DEBUG,
3005 KERN_INFO "dma_tx: pDevice->wCurrentRate = %d\n", 3005 KERN_INFO "dma_tx: pDevice->wCurrentRate = %d\n",
@@ -3015,7 +3015,7 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
3015 3015
3016 if (bNeedEncryption == TRUE) { 3016 if (bNeedEncryption == TRUE) {
3017 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ntohs Pkt Type=%04x\n", ntohs(pDevice->sTxEthHeader.wType)); 3017 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ntohs Pkt Type=%04x\n", ntohs(pDevice->sTxEthHeader.wType));
3018 if ((pDevice->sTxEthHeader.wType) == cpu_to_le16(ETH_P_PAE)) { 3018 if ((pDevice->sTxEthHeader.wType) == cpu_to_be16(ETH_P_PAE)) {
3019 bNeedEncryption = FALSE; 3019 bNeedEncryption = FALSE;
3020 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Pkt Type=%04x\n", (pDevice->sTxEthHeader.wType)); 3020 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Pkt Type=%04x\n", (pDevice->sTxEthHeader.wType));
3021 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { 3021 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c
index fabff4d650ef..0970127344e6 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -327,9 +327,9 @@ int prism2_get_station(struct wiphy *wiphy, struct net_device *dev,
327 return result; 327 return result;
328} 328}
329 329
330int prism2_scan(struct wiphy *wiphy, struct net_device *dev, 330int prism2_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
331 struct cfg80211_scan_request *request)
332{ 331{
332 struct net_device *dev = request->wdev->netdev;
333 struct prism2_wiphy_private *priv = wiphy_priv(wiphy); 333 struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
334 wlandevice_t *wlandev = dev->ml_priv; 334 wlandevice_t *wlandev = dev->ml_priv;
335 struct p80211msg_dot11req_scan msg1; 335 struct p80211msg_dot11req_scan msg1;
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index c214977b4ab4..52b43b7b83d7 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1251,13 +1251,12 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *bufsize, bool raw,
1251 void *pampd, struct tmem_pool *pool, 1251 void *pampd, struct tmem_pool *pool,
1252 struct tmem_oid *oid, uint32_t index) 1252 struct tmem_oid *oid, uint32_t index)
1253{ 1253{
1254 int ret = 0;
1255
1256 BUG_ON(!is_ephemeral(pool)); 1254 BUG_ON(!is_ephemeral(pool));
1257 zbud_decompress((struct page *)(data), pampd); 1255 if (zbud_decompress((struct page *)(data), pampd) < 0)
1256 return -EINVAL;
1258 zbud_free_and_delist((struct zbud_hdr *)pampd); 1257 zbud_free_and_delist((struct zbud_hdr *)pampd);
1259 atomic_dec(&zcache_curr_eph_pampd_count); 1258 atomic_dec(&zcache_curr_eph_pampd_count);
1260 return ret; 1259 return 0;
1261} 1260}
1262 1261
1263/* 1262/*
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 0694d9b1bce6..6aba4395e8d8 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -221,6 +221,7 @@ static int iscsi_login_zero_tsih_s1(
221{ 221{
222 struct iscsi_session *sess = NULL; 222 struct iscsi_session *sess = NULL;
223 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf; 223 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
224 int ret;
224 225
225 sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL); 226 sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL);
226 if (!sess) { 227 if (!sess) {
@@ -257,9 +258,17 @@ static int iscsi_login_zero_tsih_s1(
257 return -ENOMEM; 258 return -ENOMEM;
258 } 259 }
259 spin_lock(&sess_idr_lock); 260 spin_lock(&sess_idr_lock);
260 idr_get_new(&sess_idr, NULL, &sess->session_index); 261 ret = idr_get_new(&sess_idr, NULL, &sess->session_index);
261 spin_unlock(&sess_idr_lock); 262 spin_unlock(&sess_idr_lock);
262 263
264 if (ret < 0) {
265 pr_err("idr_get_new() for sess_idr failed\n");
266 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
267 ISCSI_LOGIN_STATUS_NO_RESOURCES);
268 kfree(sess);
269 return -ENOMEM;
270 }
271
263 sess->creation_time = get_jiffies_64(); 272 sess->creation_time = get_jiffies_64();
264 spin_lock_init(&sess->session_stats_lock); 273 spin_lock_init(&sess->session_stats_lock);
265 /* 274 /*
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 91799973081a..41641ba54828 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -218,6 +218,13 @@ int target_emulate_set_target_port_groups(struct se_cmd *cmd)
218 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 218 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
219 return -EINVAL; 219 return -EINVAL;
220 } 220 }
221 if (cmd->data_length < 4) {
222 pr_warn("SET TARGET PORT GROUPS parameter list length %u too"
223 " small\n", cmd->data_length);
224 cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST;
225 return -EINVAL;
226 }
227
221 buf = transport_kmap_data_sg(cmd); 228 buf = transport_kmap_data_sg(cmd);
222 229
223 /* 230 /*
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index cf2c66f3c116..9fc9a6006ca0 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -669,6 +669,13 @@ int target_report_luns(struct se_cmd *se_cmd)
669 unsigned char *buf; 669 unsigned char *buf;
670 u32 lun_count = 0, offset = 8, i; 670 u32 lun_count = 0, offset = 8, i;
671 671
672 if (se_cmd->data_length < 16) {
673 pr_warn("REPORT LUNS allocation length %u too small\n",
674 se_cmd->data_length);
675 se_cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD;
676 return -EINVAL;
677 }
678
672 buf = transport_kmap_data_sg(se_cmd); 679 buf = transport_kmap_data_sg(se_cmd);
673 if (!buf) 680 if (!buf)
674 return -ENOMEM; 681 return -ENOMEM;
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 76db75e836ed..9ba495477fd2 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -325,17 +325,30 @@ static int iblock_execute_unmap(struct se_cmd *cmd)
325 struct iblock_dev *ibd = dev->dev_ptr; 325 struct iblock_dev *ibd = dev->dev_ptr;
326 unsigned char *buf, *ptr = NULL; 326 unsigned char *buf, *ptr = NULL;
327 sector_t lba; 327 sector_t lba;
328 int size = cmd->data_length; 328 int size;
329 u32 range; 329 u32 range;
330 int ret = 0; 330 int ret = 0;
331 int dl, bd_dl; 331 int dl, bd_dl;
332 332
333 if (cmd->data_length < 8) {
334 pr_warn("UNMAP parameter list length %u too small\n",
335 cmd->data_length);
336 cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST;
337 return -EINVAL;
338 }
339
333 buf = transport_kmap_data_sg(cmd); 340 buf = transport_kmap_data_sg(cmd);
334 341
335 dl = get_unaligned_be16(&buf[0]); 342 dl = get_unaligned_be16(&buf[0]);
336 bd_dl = get_unaligned_be16(&buf[2]); 343 bd_dl = get_unaligned_be16(&buf[2]);
337 344
338 size = min(size - 8, bd_dl); 345 size = cmd->data_length - 8;
346 if (bd_dl > size)
347 pr_warn("UNMAP parameter list length %u too small, ignoring bd_dl %u\n",
348 cmd->data_length, bd_dl);
349 else
350 size = bd_dl;
351
339 if (size / 16 > dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { 352 if (size / 16 > dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) {
340 cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; 353 cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST;
341 ret = -EINVAL; 354 ret = -EINVAL;
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 1e946502c378..956c84c6b666 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1540,6 +1540,14 @@ static int core_scsi3_decode_spec_i_port(
1540 tidh_new->dest_local_nexus = 1; 1540 tidh_new->dest_local_nexus = 1;
1541 list_add_tail(&tidh_new->dest_list, &tid_dest_list); 1541 list_add_tail(&tidh_new->dest_list, &tid_dest_list);
1542 1542
1543 if (cmd->data_length < 28) {
1544 pr_warn("SPC-PR: Received PR OUT parameter list"
1545 " length too small: %u\n", cmd->data_length);
1546 cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST;
1547 ret = -EINVAL;
1548 goto out;
1549 }
1550
1543 buf = transport_kmap_data_sg(cmd); 1551 buf = transport_kmap_data_sg(cmd);
1544 /* 1552 /*
1545 * For a PERSISTENT RESERVE OUT specify initiator ports payload, 1553 * For a PERSISTENT RESERVE OUT specify initiator ports payload,
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 5552fa7426bc..9d7ce3daa262 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -667,7 +667,8 @@ static void pscsi_free_device(void *p)
667 kfree(pdv); 667 kfree(pdv);
668} 668}
669 669
670static int pscsi_transport_complete(struct se_cmd *cmd, struct scatterlist *sg) 670static void pscsi_transport_complete(struct se_cmd *cmd, struct scatterlist *sg,
671 unsigned char *sense_buffer)
671{ 672{
672 struct pscsi_dev_virt *pdv = cmd->se_dev->dev_ptr; 673 struct pscsi_dev_virt *pdv = cmd->se_dev->dev_ptr;
673 struct scsi_device *sd = pdv->pdv_sd; 674 struct scsi_device *sd = pdv->pdv_sd;
@@ -679,7 +680,7 @@ static int pscsi_transport_complete(struct se_cmd *cmd, struct scatterlist *sg)
679 * not been allocated because TCM is handling the emulation directly. 680 * not been allocated because TCM is handling the emulation directly.
680 */ 681 */
681 if (!pt) 682 if (!pt)
682 return 0; 683 return;
683 684
684 cdb = &pt->pscsi_cdb[0]; 685 cdb = &pt->pscsi_cdb[0];
685 result = pt->pscsi_result; 686 result = pt->pscsi_result;
@@ -687,11 +688,11 @@ static int pscsi_transport_complete(struct se_cmd *cmd, struct scatterlist *sg)
687 * Hack to make sure that Write-Protect modepage is set if R/O mode is 688 * Hack to make sure that Write-Protect modepage is set if R/O mode is
688 * forced. 689 * forced.
689 */ 690 */
691 if (!cmd->se_deve || !cmd->data_length)
692 goto after_mode_sense;
693
690 if (((cdb[0] == MODE_SENSE) || (cdb[0] == MODE_SENSE_10)) && 694 if (((cdb[0] == MODE_SENSE) || (cdb[0] == MODE_SENSE_10)) &&
691 (status_byte(result) << 1) == SAM_STAT_GOOD) { 695 (status_byte(result) << 1) == SAM_STAT_GOOD) {
692 if (!cmd->se_deve)
693 goto after_mode_sense;
694
695 if (cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) { 696 if (cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) {
696 unsigned char *buf = transport_kmap_data_sg(cmd); 697 unsigned char *buf = transport_kmap_data_sg(cmd);
697 698
@@ -708,7 +709,7 @@ static int pscsi_transport_complete(struct se_cmd *cmd, struct scatterlist *sg)
708 } 709 }
709after_mode_sense: 710after_mode_sense:
710 711
711 if (sd->type != TYPE_TAPE) 712 if (sd->type != TYPE_TAPE || !cmd->data_length)
712 goto after_mode_select; 713 goto after_mode_select;
713 714
714 /* 715 /*
@@ -750,10 +751,10 @@ after_mode_sense:
750 } 751 }
751after_mode_select: 752after_mode_select:
752 753
753 if (status_byte(result) & CHECK_CONDITION) 754 if (sense_buffer && (status_byte(result) & CHECK_CONDITION)) {
754 return 1; 755 memcpy(sense_buffer, pt->pscsi_sense, TRANSPORT_SENSE_BUFFER);
755 756 cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE;
756 return 0; 757 }
757} 758}
758 759
759enum { 760enum {
@@ -1184,13 +1185,6 @@ fail:
1184 return -ENOMEM; 1185 return -ENOMEM;
1185} 1186}
1186 1187
1187static unsigned char *pscsi_get_sense_buffer(struct se_cmd *cmd)
1188{
1189 struct pscsi_plugin_task *pt = cmd->priv;
1190
1191 return pt->pscsi_sense;
1192}
1193
1194/* pscsi_get_device_rev(): 1188/* pscsi_get_device_rev():
1195 * 1189 *
1196 * 1190 *
@@ -1273,7 +1267,6 @@ static struct se_subsystem_api pscsi_template = {
1273 .check_configfs_dev_params = pscsi_check_configfs_dev_params, 1267 .check_configfs_dev_params = pscsi_check_configfs_dev_params,
1274 .set_configfs_dev_params = pscsi_set_configfs_dev_params, 1268 .set_configfs_dev_params = pscsi_set_configfs_dev_params,
1275 .show_configfs_dev_params = pscsi_show_configfs_dev_params, 1269 .show_configfs_dev_params = pscsi_show_configfs_dev_params,
1276 .get_sense_buffer = pscsi_get_sense_buffer,
1277 .get_device_rev = pscsi_get_device_rev, 1270 .get_device_rev = pscsi_get_device_rev,
1278 .get_device_type = pscsi_get_device_type, 1271 .get_device_type = pscsi_get_device_type,
1279 .get_blocks = pscsi_get_blocks, 1272 .get_blocks = pscsi_get_blocks,
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 4c861de538c9..388a922c8f6d 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -877,9 +877,11 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
877static int spc_emulate_request_sense(struct se_cmd *cmd) 877static int spc_emulate_request_sense(struct se_cmd *cmd)
878{ 878{
879 unsigned char *cdb = cmd->t_task_cdb; 879 unsigned char *cdb = cmd->t_task_cdb;
880 unsigned char *buf; 880 unsigned char *rbuf;
881 u8 ua_asc = 0, ua_ascq = 0; 881 u8 ua_asc = 0, ua_ascq = 0;
882 int err = 0; 882 unsigned char buf[SE_SENSE_BUF];
883
884 memset(buf, 0, SE_SENSE_BUF);
883 885
884 if (cdb[1] & 0x01) { 886 if (cdb[1] & 0x01) {
885 pr_err("REQUEST_SENSE description emulation not" 887 pr_err("REQUEST_SENSE description emulation not"
@@ -888,20 +890,21 @@ static int spc_emulate_request_sense(struct se_cmd *cmd)
888 return -ENOSYS; 890 return -ENOSYS;
889 } 891 }
890 892
891 buf = transport_kmap_data_sg(cmd); 893 rbuf = transport_kmap_data_sg(cmd);
892 894 if (cmd->scsi_sense_reason != 0) {
893 if (!core_scsi3_ua_clear_for_request_sense(cmd, &ua_asc, &ua_ascq)) { 895 /*
896 * Out of memory. We will fail with CHECK CONDITION, so
897 * we must not clear the unit attention condition.
898 */
899 target_complete_cmd(cmd, CHECK_CONDITION);
900 return 0;
901 } else if (!core_scsi3_ua_clear_for_request_sense(cmd, &ua_asc, &ua_ascq)) {
894 /* 902 /*
895 * CURRENT ERROR, UNIT ATTENTION 903 * CURRENT ERROR, UNIT ATTENTION
896 */ 904 */
897 buf[0] = 0x70; 905 buf[0] = 0x70;
898 buf[SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; 906 buf[SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION;
899 907
900 if (cmd->data_length < 18) {
901 buf[7] = 0x00;
902 err = -EINVAL;
903 goto end;
904 }
905 /* 908 /*
906 * The Additional Sense Code (ASC) from the UNIT ATTENTION 909 * The Additional Sense Code (ASC) from the UNIT ATTENTION
907 */ 910 */
@@ -915,11 +918,6 @@ static int spc_emulate_request_sense(struct se_cmd *cmd)
915 buf[0] = 0x70; 918 buf[0] = 0x70;
916 buf[SPC_SENSE_KEY_OFFSET] = NO_SENSE; 919 buf[SPC_SENSE_KEY_OFFSET] = NO_SENSE;
917 920
918 if (cmd->data_length < 18) {
919 buf[7] = 0x00;
920 err = -EINVAL;
921 goto end;
922 }
923 /* 921 /*
924 * NO ADDITIONAL SENSE INFORMATION 922 * NO ADDITIONAL SENSE INFORMATION
925 */ 923 */
@@ -927,8 +925,11 @@ static int spc_emulate_request_sense(struct se_cmd *cmd)
927 buf[7] = 0x0A; 925 buf[7] = 0x0A;
928 } 926 }
929 927
930end: 928 if (rbuf) {
931 transport_kunmap_data_sg(cmd); 929 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length));
930 transport_kunmap_data_sg(cmd);
931 }
932
932 target_complete_cmd(cmd, GOOD); 933 target_complete_cmd(cmd, GOOD);
933 return 0; 934 return 0;
934} 935}
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 4de3186dc44e..269f54488397 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -567,6 +567,34 @@ static void target_complete_failure_work(struct work_struct *work)
567 transport_generic_request_failure(cmd); 567 transport_generic_request_failure(cmd);
568} 568}
569 569
570/*
571 * Used when asking transport to copy Sense Data from the underlying
572 * Linux/SCSI struct scsi_cmnd
573 */
574static unsigned char *transport_get_sense_buffer(struct se_cmd *cmd)
575{
576 unsigned char *buffer = cmd->sense_buffer;
577 struct se_device *dev = cmd->se_dev;
578 u32 offset = 0;
579
580 WARN_ON(!cmd->se_lun);
581
582 if (!dev)
583 return NULL;
584
585 if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION)
586 return NULL;
587
588 offset = cmd->se_tfo->set_fabric_sense_len(cmd, TRANSPORT_SENSE_BUFFER);
589
590 /* Automatically padded */
591 cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER + offset;
592
593 pr_debug("HBA_[%u]_PLUG[%s]: Requesting sense for SAM STATUS: 0x%02x\n",
594 dev->se_hba->hba_id, dev->transport->name, cmd->scsi_status);
595 return &buffer[offset];
596}
597
570void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) 598void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)
571{ 599{
572 struct se_device *dev = cmd->se_dev; 600 struct se_device *dev = cmd->se_dev;
@@ -580,11 +608,11 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)
580 cmd->transport_state &= ~CMD_T_BUSY; 608 cmd->transport_state &= ~CMD_T_BUSY;
581 609
582 if (dev && dev->transport->transport_complete) { 610 if (dev && dev->transport->transport_complete) {
583 if (dev->transport->transport_complete(cmd, 611 dev->transport->transport_complete(cmd,
584 cmd->t_data_sg) != 0) { 612 cmd->t_data_sg,
585 cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE; 613 transport_get_sense_buffer(cmd));
614 if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE)
586 success = 1; 615 success = 1;
587 }
588 } 616 }
589 617
590 /* 618 /*
@@ -1181,15 +1209,20 @@ int target_cmd_size_check(struct se_cmd *cmd, unsigned int size)
1181 /* Returns CHECK_CONDITION + INVALID_CDB_FIELD */ 1209 /* Returns CHECK_CONDITION + INVALID_CDB_FIELD */
1182 goto out_invalid_cdb_field; 1210 goto out_invalid_cdb_field;
1183 } 1211 }
1184 1212 /*
1213 * For the overflow case keep the existing fabric provided
1214 * ->data_length. Otherwise for the underflow case, reset
1215 * ->data_length to the smaller SCSI expected data transfer
1216 * length.
1217 */
1185 if (size > cmd->data_length) { 1218 if (size > cmd->data_length) {
1186 cmd->se_cmd_flags |= SCF_OVERFLOW_BIT; 1219 cmd->se_cmd_flags |= SCF_OVERFLOW_BIT;
1187 cmd->residual_count = (size - cmd->data_length); 1220 cmd->residual_count = (size - cmd->data_length);
1188 } else { 1221 } else {
1189 cmd->se_cmd_flags |= SCF_UNDERFLOW_BIT; 1222 cmd->se_cmd_flags |= SCF_UNDERFLOW_BIT;
1190 cmd->residual_count = (cmd->data_length - size); 1223 cmd->residual_count = (cmd->data_length - size);
1224 cmd->data_length = size;
1191 } 1225 }
1192 cmd->data_length = size;
1193 } 1226 }
1194 1227
1195 return 0; 1228 return 0;
@@ -1816,61 +1849,6 @@ execute:
1816EXPORT_SYMBOL(target_execute_cmd); 1849EXPORT_SYMBOL(target_execute_cmd);
1817 1850
1818/* 1851/*
1819 * Used to obtain Sense Data from underlying Linux/SCSI struct scsi_cmnd
1820 */
1821static int transport_get_sense_data(struct se_cmd *cmd)
1822{
1823 unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL;
1824 struct se_device *dev = cmd->se_dev;
1825 unsigned long flags;
1826 u32 offset = 0;
1827
1828 WARN_ON(!cmd->se_lun);
1829
1830 if (!dev)
1831 return 0;
1832
1833 spin_lock_irqsave(&cmd->t_state_lock, flags);
1834 if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) {
1835 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
1836 return 0;
1837 }
1838
1839 if (!(cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE))
1840 goto out;
1841
1842 if (!dev->transport->get_sense_buffer) {
1843 pr_err("dev->transport->get_sense_buffer is NULL\n");
1844 goto out;
1845 }
1846
1847 sense_buffer = dev->transport->get_sense_buffer(cmd);
1848 if (!sense_buffer) {
1849 pr_err("ITT 0x%08x cmd %p: Unable to locate"
1850 " sense buffer for task with sense\n",
1851 cmd->se_tfo->get_task_tag(cmd), cmd);
1852 goto out;
1853 }
1854
1855 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
1856
1857 offset = cmd->se_tfo->set_fabric_sense_len(cmd, TRANSPORT_SENSE_BUFFER);
1858
1859 memcpy(&buffer[offset], sense_buffer, TRANSPORT_SENSE_BUFFER);
1860
1861 /* Automatically padded */
1862 cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER + offset;
1863
1864 pr_debug("HBA_[%u]_PLUG[%s]: Set SAM STATUS: 0x%02x and sense\n",
1865 dev->se_hba->hba_id, dev->transport->name, cmd->scsi_status);
1866 return 0;
1867
1868out:
1869 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
1870 return -1;
1871}
1872
1873/*
1874 * Process all commands up to the last received ORDERED task attribute which 1852 * Process all commands up to the last received ORDERED task attribute which
1875 * requires another blocking boundary 1853 * requires another blocking boundary
1876 */ 1854 */
@@ -1985,7 +1963,7 @@ static void transport_handle_queue_full(
1985static void target_complete_ok_work(struct work_struct *work) 1963static void target_complete_ok_work(struct work_struct *work)
1986{ 1964{
1987 struct se_cmd *cmd = container_of(work, struct se_cmd, work); 1965 struct se_cmd *cmd = container_of(work, struct se_cmd, work);
1988 int reason = 0, ret; 1966 int ret;
1989 1967
1990 /* 1968 /*
1991 * Check if we need to move delayed/dormant tasks from cmds on the 1969 * Check if we need to move delayed/dormant tasks from cmds on the
@@ -2002,23 +1980,19 @@ static void target_complete_ok_work(struct work_struct *work)
2002 schedule_work(&cmd->se_dev->qf_work_queue); 1980 schedule_work(&cmd->se_dev->qf_work_queue);
2003 1981
2004 /* 1982 /*
2005 * Check if we need to retrieve a sense buffer from 1983 * Check if we need to send a sense buffer from
2006 * the struct se_cmd in question. 1984 * the struct se_cmd in question.
2007 */ 1985 */
2008 if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { 1986 if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) {
2009 if (transport_get_sense_data(cmd) < 0) 1987 WARN_ON(!cmd->scsi_status);
2010 reason = TCM_NON_EXISTENT_LUN; 1988 ret = transport_send_check_condition_and_sense(
2011 1989 cmd, 0, 1);
2012 if (cmd->scsi_status) { 1990 if (ret == -EAGAIN || ret == -ENOMEM)
2013 ret = transport_send_check_condition_and_sense( 1991 goto queue_full;
2014 cmd, reason, 1);
2015 if (ret == -EAGAIN || ret == -ENOMEM)
2016 goto queue_full;
2017 1992
2018 transport_lun_remove_cmd(cmd); 1993 transport_lun_remove_cmd(cmd);
2019 transport_cmd_check_stop_to_fabric(cmd); 1994 transport_cmd_check_stop_to_fabric(cmd);
2020 return; 1995 return;
2021 }
2022 } 1996 }
2023 /* 1997 /*
2024 * Check for a callback, used by amongst other things 1998 * Check for a callback, used by amongst other things
@@ -2216,7 +2190,6 @@ void *transport_kmap_data_sg(struct se_cmd *cmd)
2216 struct page **pages; 2190 struct page **pages;
2217 int i; 2191 int i;
2218 2192
2219 BUG_ON(!sg);
2220 /* 2193 /*
2221 * We need to take into account a possible offset here for fabrics like 2194 * We need to take into account a possible offset here for fabrics like
2222 * tcm_loop who may be using a contig buffer from the SCSI midlayer for 2195 * tcm_loop who may be using a contig buffer from the SCSI midlayer for
@@ -2224,13 +2197,17 @@ void *transport_kmap_data_sg(struct se_cmd *cmd)
2224 */ 2197 */
2225 if (!cmd->t_data_nents) 2198 if (!cmd->t_data_nents)
2226 return NULL; 2199 return NULL;
2227 else if (cmd->t_data_nents == 1) 2200
2201 BUG_ON(!sg);
2202 if (cmd->t_data_nents == 1)
2228 return kmap(sg_page(sg)) + sg->offset; 2203 return kmap(sg_page(sg)) + sg->offset;
2229 2204
2230 /* >1 page. use vmap */ 2205 /* >1 page. use vmap */
2231 pages = kmalloc(sizeof(*pages) * cmd->t_data_nents, GFP_KERNEL); 2206 pages = kmalloc(sizeof(*pages) * cmd->t_data_nents, GFP_KERNEL);
2232 if (!pages) 2207 if (!pages) {
2208 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
2233 return NULL; 2209 return NULL;
2210 }
2234 2211
2235 /* convert sg[] to pages[] */ 2212 /* convert sg[] to pages[] */
2236 for_each_sg(cmd->t_data_sg, sg, cmd->t_data_nents, i) { 2213 for_each_sg(cmd->t_data_sg, sg, cmd->t_data_nents, i) {
@@ -2239,8 +2216,10 @@ void *transport_kmap_data_sg(struct se_cmd *cmd)
2239 2216
2240 cmd->t_data_vmap = vmap(pages, cmd->t_data_nents, VM_MAP, PAGE_KERNEL); 2217 cmd->t_data_vmap = vmap(pages, cmd->t_data_nents, VM_MAP, PAGE_KERNEL);
2241 kfree(pages); 2218 kfree(pages);
2242 if (!cmd->t_data_vmap) 2219 if (!cmd->t_data_vmap) {
2220 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
2243 return NULL; 2221 return NULL;
2222 }
2244 2223
2245 return cmd->t_data_vmap + cmd->t_data_sg[0].offset; 2224 return cmd->t_data_vmap + cmd->t_data_sg[0].offset;
2246} 2225}
@@ -2326,19 +2305,14 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
2326 * into the fabric for data transfers, go ahead and complete it right 2305 * into the fabric for data transfers, go ahead and complete it right
2327 * away. 2306 * away.
2328 */ 2307 */
2329 if (!cmd->data_length) { 2308 if (!cmd->data_length &&
2309 cmd->t_task_cdb[0] != REQUEST_SENSE &&
2310 cmd->se_dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV) {
2330 spin_lock_irq(&cmd->t_state_lock); 2311 spin_lock_irq(&cmd->t_state_lock);
2331 cmd->t_state = TRANSPORT_COMPLETE; 2312 cmd->t_state = TRANSPORT_COMPLETE;
2332 cmd->transport_state |= CMD_T_ACTIVE; 2313 cmd->transport_state |= CMD_T_ACTIVE;
2333 spin_unlock_irq(&cmd->t_state_lock); 2314 spin_unlock_irq(&cmd->t_state_lock);
2334 2315
2335 if (cmd->t_task_cdb[0] == REQUEST_SENSE) {
2336 u8 ua_asc = 0, ua_ascq = 0;
2337
2338 core_scsi3_ua_clear_for_request_sense(cmd,
2339 &ua_asc, &ua_ascq);
2340 }
2341
2342 INIT_WORK(&cmd->work, target_complete_ok_work); 2316 INIT_WORK(&cmd->work, target_complete_ok_work);
2343 queue_work(target_completion_wq, &cmd->work); 2317 queue_work(target_completion_wq, &cmd->work);
2344 return 0; 2318 return 0;
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index d5c689d6217e..e309e8b0aaba 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -132,6 +132,7 @@
132#define UCR4_OREN (1<<1) /* Receiver overrun interrupt enable */ 132#define UCR4_OREN (1<<1) /* Receiver overrun interrupt enable */
133#define UCR4_DREN (1<<0) /* Recv data ready interrupt enable */ 133#define UCR4_DREN (1<<0) /* Recv data ready interrupt enable */
134#define UFCR_RXTL_SHF 0 /* Receiver trigger level shift */ 134#define UFCR_RXTL_SHF 0 /* Receiver trigger level shift */
135#define UFCR_DCEDTE (1<<6) /* DCE/DTE mode select */
135#define UFCR_RFDIV (7<<7) /* Reference freq divider mask */ 136#define UFCR_RFDIV (7<<7) /* Reference freq divider mask */
136#define UFCR_RFDIV_REG(x) (((x) < 7 ? 6 - (x) : 6) << 7) 137#define UFCR_RFDIV_REG(x) (((x) < 7 ? 6 - (x) : 6) << 7)
137#define UFCR_TXTL_SHF 10 /* Transmitter trigger level shift */ 138#define UFCR_TXTL_SHF 10 /* Transmitter trigger level shift */
@@ -667,22 +668,11 @@ static void imx_break_ctl(struct uart_port *port, int break_state)
667static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode) 668static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode)
668{ 669{
669 unsigned int val; 670 unsigned int val;
670 unsigned int ufcr_rfdiv;
671
672 /* set receiver / transmitter trigger level.
673 * RFDIV is set such way to satisfy requested uartclk value
674 */
675 val = TXTL << 10 | RXTL;
676 ufcr_rfdiv = (clk_get_rate(sport->clk_per) + sport->port.uartclk / 2)
677 / sport->port.uartclk;
678
679 if(!ufcr_rfdiv)
680 ufcr_rfdiv = 1;
681
682 val |= UFCR_RFDIV_REG(ufcr_rfdiv);
683 671
672 /* set receiver / transmitter trigger level */
673 val = readl(sport->port.membase + UFCR) & (UFCR_RFDIV | UFCR_DCEDTE);
674 val |= TXTL << UFCR_TXTL_SHF | RXTL;
684 writel(val, sport->port.membase + UFCR); 675 writel(val, sport->port.membase + UFCR);
685
686 return 0; 676 return 0;
687} 677}
688 678
@@ -754,6 +744,7 @@ static int imx_startup(struct uart_port *port)
754 } 744 }
755 } 745 }
756 746
747 spin_lock_irqsave(&sport->port.lock, flags);
757 /* 748 /*
758 * Finally, clear and enable interrupts 749 * Finally, clear and enable interrupts
759 */ 750 */
@@ -807,7 +798,6 @@ static int imx_startup(struct uart_port *port)
807 /* 798 /*
808 * Enable modem status interrupts 799 * Enable modem status interrupts
809 */ 800 */
810 spin_lock_irqsave(&sport->port.lock,flags);
811 imx_enable_ms(&sport->port); 801 imx_enable_ms(&sport->port);
812 spin_unlock_irqrestore(&sport->port.lock,flags); 802 spin_unlock_irqrestore(&sport->port.lock,flags);
813 803
@@ -837,10 +827,13 @@ static void imx_shutdown(struct uart_port *port)
837{ 827{
838 struct imx_port *sport = (struct imx_port *)port; 828 struct imx_port *sport = (struct imx_port *)port;
839 unsigned long temp; 829 unsigned long temp;
830 unsigned long flags;
840 831
832 spin_lock_irqsave(&sport->port.lock, flags);
841 temp = readl(sport->port.membase + UCR2); 833 temp = readl(sport->port.membase + UCR2);
842 temp &= ~(UCR2_TXEN); 834 temp &= ~(UCR2_TXEN);
843 writel(temp, sport->port.membase + UCR2); 835 writel(temp, sport->port.membase + UCR2);
836 spin_unlock_irqrestore(&sport->port.lock, flags);
844 837
845 if (USE_IRDA(sport)) { 838 if (USE_IRDA(sport)) {
846 struct imxuart_platform_data *pdata; 839 struct imxuart_platform_data *pdata;
@@ -869,12 +862,14 @@ static void imx_shutdown(struct uart_port *port)
869 * Disable all interrupts, port and break condition. 862 * Disable all interrupts, port and break condition.
870 */ 863 */
871 864
865 spin_lock_irqsave(&sport->port.lock, flags);
872 temp = readl(sport->port.membase + UCR1); 866 temp = readl(sport->port.membase + UCR1);
873 temp &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN); 867 temp &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN);
874 if (USE_IRDA(sport)) 868 if (USE_IRDA(sport))
875 temp &= ~(UCR1_IREN); 869 temp &= ~(UCR1_IREN);
876 870
877 writel(temp, sport->port.membase + UCR1); 871 writel(temp, sport->port.membase + UCR1);
872 spin_unlock_irqrestore(&sport->port.lock, flags);
878} 873}
879 874
880static void 875static void
@@ -1217,6 +1212,9 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
1217 struct imx_port *sport = imx_ports[co->index]; 1212 struct imx_port *sport = imx_ports[co->index];
1218 struct imx_port_ucrs old_ucr; 1213 struct imx_port_ucrs old_ucr;
1219 unsigned int ucr1; 1214 unsigned int ucr1;
1215 unsigned long flags;
1216
1217 spin_lock_irqsave(&sport->port.lock, flags);
1220 1218
1221 /* 1219 /*
1222 * First, save UCR1/2/3 and then disable interrupts 1220 * First, save UCR1/2/3 and then disable interrupts
@@ -1242,6 +1240,8 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
1242 while (!(readl(sport->port.membase + USR2) & USR2_TXDC)); 1240 while (!(readl(sport->port.membase + USR2) & USR2_TXDC));
1243 1241
1244 imx_port_ucrs_restore(&sport->port, &old_ucr); 1242 imx_port_ucrs_restore(&sport->port, &old_ucr);
1243
1244 spin_unlock_irqrestore(&sport->port.lock, flags);
1245} 1245}
1246 1246
1247/* 1247/*
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c7a032a4f0c5..d214448b677e 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -78,8 +78,7 @@ static inline int ep_to_bit(struct ci13xxx *ci, int n)
78} 78}
79 79
80/** 80/**
81 * hw_device_state: enables/disables interrupts & starts/stops device (execute 81 * hw_device_state: enables/disables interrupts (execute without interruption)
82 * without interruption)
83 * @dma: 0 => disable, !0 => enable and set dma engine 82 * @dma: 0 => disable, !0 => enable and set dma engine
84 * 83 *
85 * This function returns an error code 84 * This function returns an error code
@@ -91,9 +90,7 @@ static int hw_device_state(struct ci13xxx *ci, u32 dma)
91 /* interrupt, error, port change, reset, sleep/suspend */ 90 /* interrupt, error, port change, reset, sleep/suspend */
92 hw_write(ci, OP_USBINTR, ~0, 91 hw_write(ci, OP_USBINTR, ~0,
93 USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI); 92 USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
94 hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
95 } else { 93 } else {
96 hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
97 hw_write(ci, OP_USBINTR, ~0, 0); 94 hw_write(ci, OP_USBINTR, ~0, 0);
98 } 95 }
99 return 0; 96 return 0;
@@ -774,10 +771,7 @@ __acquires(mEp->lock)
774{ 771{
775 struct ci13xxx_req *mReq, *mReqTemp; 772 struct ci13xxx_req *mReq, *mReqTemp;
776 struct ci13xxx_ep *mEpTemp = mEp; 773 struct ci13xxx_ep *mEpTemp = mEp;
777 int uninitialized_var(retval); 774 int retval = 0;
778
779 if (list_empty(&mEp->qh.queue))
780 return -EINVAL;
781 775
782 list_for_each_entry_safe(mReq, mReqTemp, &mEp->qh.queue, 776 list_for_each_entry_safe(mReq, mReqTemp, &mEp->qh.queue,
783 queue) { 777 queue) {
@@ -1420,6 +1414,21 @@ static int ci13xxx_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
1420 return -ENOTSUPP; 1414 return -ENOTSUPP;
1421} 1415}
1422 1416
1417/* Change Data+ pullup status
1418 * this func is used by usb_gadget_connect/disconnet
1419 */
1420static int ci13xxx_pullup(struct usb_gadget *_gadget, int is_on)
1421{
1422 struct ci13xxx *ci = container_of(_gadget, struct ci13xxx, gadget);
1423
1424 if (is_on)
1425 hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
1426 else
1427 hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
1428
1429 return 0;
1430}
1431
1423static int ci13xxx_start(struct usb_gadget *gadget, 1432static int ci13xxx_start(struct usb_gadget *gadget,
1424 struct usb_gadget_driver *driver); 1433 struct usb_gadget_driver *driver);
1425static int ci13xxx_stop(struct usb_gadget *gadget, 1434static int ci13xxx_stop(struct usb_gadget *gadget,
@@ -1432,6 +1441,7 @@ static int ci13xxx_stop(struct usb_gadget *gadget,
1432static const struct usb_gadget_ops usb_gadget_ops = { 1441static const struct usb_gadget_ops usb_gadget_ops = {
1433 .vbus_session = ci13xxx_vbus_session, 1442 .vbus_session = ci13xxx_vbus_session,
1434 .wakeup = ci13xxx_wakeup, 1443 .wakeup = ci13xxx_wakeup,
1444 .pullup = ci13xxx_pullup,
1435 .vbus_draw = ci13xxx_vbus_draw, 1445 .vbus_draw = ci13xxx_vbus_draw,
1436 .udc_start = ci13xxx_start, 1446 .udc_start = ci13xxx_start,
1437 .udc_stop = ci13xxx_stop, 1447 .udc_stop = ci13xxx_stop,
@@ -1455,7 +1465,12 @@ static int init_eps(struct ci13xxx *ci)
1455 1465
1456 mEp->ep.name = mEp->name; 1466 mEp->ep.name = mEp->name;
1457 mEp->ep.ops = &usb_ep_ops; 1467 mEp->ep.ops = &usb_ep_ops;
1458 mEp->ep.maxpacket = CTRL_PAYLOAD_MAX; 1468 /*
1469 * for ep0: maxP defined in desc, for other
1470 * eps, maxP is set by epautoconfig() called
1471 * by gadget layer
1472 */
1473 mEp->ep.maxpacket = (unsigned short)~0;
1459 1474
1460 INIT_LIST_HEAD(&mEp->qh.queue); 1475 INIT_LIST_HEAD(&mEp->qh.queue);
1461 mEp->qh.ptr = dma_pool_alloc(ci->qh_pool, GFP_KERNEL, 1476 mEp->qh.ptr = dma_pool_alloc(ci->qh_pool, GFP_KERNEL,
@@ -1475,6 +1490,7 @@ static int init_eps(struct ci13xxx *ci)
1475 else 1490 else
1476 ci->ep0in = mEp; 1491 ci->ep0in = mEp;
1477 1492
1493 mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;
1478 continue; 1494 continue;
1479 } 1495 }
1480 1496
@@ -1484,6 +1500,17 @@ static int init_eps(struct ci13xxx *ci)
1484 return retval; 1500 return retval;
1485} 1501}
1486 1502
1503static void destroy_eps(struct ci13xxx *ci)
1504{
1505 int i;
1506
1507 for (i = 0; i < ci->hw_ep_max; i++) {
1508 struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
1509
1510 dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
1511 }
1512}
1513
1487/** 1514/**
1488 * ci13xxx_start: register a gadget driver 1515 * ci13xxx_start: register a gadget driver
1489 * @gadget: our gadget 1516 * @gadget: our gadget
@@ -1691,7 +1718,7 @@ static int udc_start(struct ci13xxx *ci)
1691 if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) { 1718 if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
1692 if (ci->transceiver == NULL) { 1719 if (ci->transceiver == NULL) {
1693 retval = -ENODEV; 1720 retval = -ENODEV;
1694 goto free_pools; 1721 goto destroy_eps;
1695 } 1722 }
1696 } 1723 }
1697 1724
@@ -1729,7 +1756,7 @@ static int udc_start(struct ci13xxx *ci)
1729 1756
1730remove_trans: 1757remove_trans:
1731 if (!IS_ERR_OR_NULL(ci->transceiver)) { 1758 if (!IS_ERR_OR_NULL(ci->transceiver)) {
1732 otg_set_peripheral(ci->transceiver->otg, &ci->gadget); 1759 otg_set_peripheral(ci->transceiver->otg, NULL);
1733 if (ci->global_phy) 1760 if (ci->global_phy)
1734 usb_put_phy(ci->transceiver); 1761 usb_put_phy(ci->transceiver);
1735 } 1762 }
@@ -1742,6 +1769,8 @@ unreg_device:
1742put_transceiver: 1769put_transceiver:
1743 if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy) 1770 if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy)
1744 usb_put_phy(ci->transceiver); 1771 usb_put_phy(ci->transceiver);
1772destroy_eps:
1773 destroy_eps(ci);
1745free_pools: 1774free_pools:
1746 dma_pool_destroy(ci->td_pool); 1775 dma_pool_destroy(ci->td_pool);
1747free_qh_pool: 1776free_qh_pool:
@@ -1756,18 +1785,12 @@ free_qh_pool:
1756 */ 1785 */
1757static void udc_stop(struct ci13xxx *ci) 1786static void udc_stop(struct ci13xxx *ci)
1758{ 1787{
1759 int i;
1760
1761 if (ci == NULL) 1788 if (ci == NULL)
1762 return; 1789 return;
1763 1790
1764 usb_del_gadget_udc(&ci->gadget); 1791 usb_del_gadget_udc(&ci->gadget);
1765 1792
1766 for (i = 0; i < ci->hw_ep_max; i++) { 1793 destroy_eps(ci);
1767 struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
1768
1769 dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
1770 }
1771 1794
1772 dma_pool_destroy(ci->td_pool); 1795 dma_pool_destroy(ci->td_pool);
1773 dma_pool_destroy(ci->qh_pool); 1796 dma_pool_destroy(ci->qh_pool);
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 65a55abb791f..5f0cb417b736 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -109,12 +109,14 @@ static struct usb_driver wdm_driver;
109/* return intfdata if we own the interface, else look up intf in the list */ 109/* return intfdata if we own the interface, else look up intf in the list */
110static struct wdm_device *wdm_find_device(struct usb_interface *intf) 110static struct wdm_device *wdm_find_device(struct usb_interface *intf)
111{ 111{
112 struct wdm_device *desc = NULL; 112 struct wdm_device *desc;
113 113
114 spin_lock(&wdm_device_list_lock); 114 spin_lock(&wdm_device_list_lock);
115 list_for_each_entry(desc, &wdm_device_list, device_list) 115 list_for_each_entry(desc, &wdm_device_list, device_list)
116 if (desc->intf == intf) 116 if (desc->intf == intf)
117 break; 117 goto found;
118 desc = NULL;
119found:
118 spin_unlock(&wdm_device_list_lock); 120 spin_unlock(&wdm_device_list_lock);
119 121
120 return desc; 122 return desc;
@@ -122,12 +124,14 @@ static struct wdm_device *wdm_find_device(struct usb_interface *intf)
122 124
123static struct wdm_device *wdm_find_device_by_minor(int minor) 125static struct wdm_device *wdm_find_device_by_minor(int minor)
124{ 126{
125 struct wdm_device *desc = NULL; 127 struct wdm_device *desc;
126 128
127 spin_lock(&wdm_device_list_lock); 129 spin_lock(&wdm_device_list_lock);
128 list_for_each_entry(desc, &wdm_device_list, device_list) 130 list_for_each_entry(desc, &wdm_device_list, device_list)
129 if (desc->intf->minor == minor) 131 if (desc->intf->minor == minor)
130 break; 132 goto found;
133 desc = NULL;
134found:
131 spin_unlock(&wdm_device_list_lock); 135 spin_unlock(&wdm_device_list_lock);
132 136
133 return desc; 137 return desc;
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index f15501f4c585..e77a8e8eaa23 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -71,6 +71,10 @@ static const struct usb_device_id usb_quirk_list[] = {
71 { USB_DEVICE(0x04b4, 0x0526), .driver_info = 71 { USB_DEVICE(0x04b4, 0x0526), .driver_info =
72 USB_QUIRK_CONFIG_INTF_STRINGS }, 72 USB_QUIRK_CONFIG_INTF_STRINGS },
73 73
74 /* Microchip Joss Optical infrared touchboard device */
75 { USB_DEVICE(0x04d8, 0x000c), .driver_info =
76 USB_QUIRK_CONFIG_INTF_STRINGS },
77
74 /* Samsung Android phone modem - ID conflict with SPH-I500 */ 78 /* Samsung Android phone modem - ID conflict with SPH-I500 */
75 { USB_DEVICE(0x04e8, 0x6601), .driver_info = 79 { USB_DEVICE(0x04e8, 0x6601), .driver_info =
76 USB_QUIRK_CONFIG_INTF_STRINGS }, 80 USB_QUIRK_CONFIG_INTF_STRINGS },
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c34452a7304f..a68ff53124dc 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -436,16 +436,21 @@ static int __devinit dwc3_probe(struct platform_device *pdev)
436 dev_err(dev, "missing IRQ\n"); 436 dev_err(dev, "missing IRQ\n");
437 return -ENODEV; 437 return -ENODEV;
438 } 438 }
439 dwc->xhci_resources[1] = *res; 439 dwc->xhci_resources[1].start = res->start;
440 dwc->xhci_resources[1].end = res->end;
441 dwc->xhci_resources[1].flags = res->flags;
442 dwc->xhci_resources[1].name = res->name;
440 443
441 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 444 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
442 if (!res) { 445 if (!res) {
443 dev_err(dev, "missing memory resource\n"); 446 dev_err(dev, "missing memory resource\n");
444 return -ENODEV; 447 return -ENODEV;
445 } 448 }
446 dwc->xhci_resources[0] = *res; 449 dwc->xhci_resources[0].start = res->start;
447 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + 450 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
448 DWC3_XHCI_REGS_END; 451 DWC3_XHCI_REGS_END;
452 dwc->xhci_resources[0].flags = res->flags;
453 dwc->xhci_resources[0].name = res->name;
449 454
450 /* 455 /*
451 * Request memory region but exclude xHCI regs, 456 * Request memory region but exclude xHCI regs,
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 9b94886b66e5..e4d5ca86b9da 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -720,7 +720,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
720 transferred = min_t(u32, ur->length, 720 transferred = min_t(u32, ur->length,
721 transfer_size - length); 721 transfer_size - length);
722 memcpy(ur->buf, dwc->ep0_bounce, transferred); 722 memcpy(ur->buf, dwc->ep0_bounce, transferred);
723 dwc->ep0_bounced = false;
724 } else { 723 } else {
725 transferred = ur->length - length; 724 transferred = ur->length - length;
726 } 725 }
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 58fdfad96b4d..c2813c2b005a 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -263,8 +263,11 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
263 if (req->request.status == -EINPROGRESS) 263 if (req->request.status == -EINPROGRESS)
264 req->request.status = status; 264 req->request.status = status;
265 265
266 usb_gadget_unmap_request(&dwc->gadget, &req->request, 266 if (dwc->ep0_bounced && dep->number == 0)
267 req->direction); 267 dwc->ep0_bounced = false;
268 else
269 usb_gadget_unmap_request(&dwc->gadget, &req->request,
270 req->direction);
268 271
269 dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n", 272 dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n",
270 req, dep->name, req->request.actual, 273 req, dep->name, req->request.actual,
@@ -1026,6 +1029,7 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
1026 if (list_empty(&dep->request_list)) { 1029 if (list_empty(&dep->request_list)) {
1027 dev_vdbg(dwc->dev, "ISOC ep %s run out for requests.\n", 1030 dev_vdbg(dwc->dev, "ISOC ep %s run out for requests.\n",
1028 dep->name); 1031 dep->name);
1032 dep->flags |= DWC3_EP_PENDING_REQUEST;
1029 return; 1033 return;
1030 } 1034 }
1031 1035
@@ -1089,6 +1093,17 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
1089 if (dep->flags & DWC3_EP_PENDING_REQUEST) { 1093 if (dep->flags & DWC3_EP_PENDING_REQUEST) {
1090 int ret; 1094 int ret;
1091 1095
1096 /*
1097 * If xfernotready is already elapsed and it is a case
1098 * of isoc transfer, then issue END TRANSFER, so that
1099 * you can receive xfernotready again and can have
1100 * notion of current microframe.
1101 */
1102 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
1103 dwc3_stop_active_transfer(dwc, dep->number);
1104 return 0;
1105 }
1106
1092 ret = __dwc3_gadget_kick_transfer(dep, 0, true); 1107 ret = __dwc3_gadget_kick_transfer(dep, 0, true);
1093 if (ret && ret != -EBUSY) { 1108 if (ret && ret != -EBUSY) {
1094 struct dwc3 *dwc = dep->dwc; 1109 struct dwc3 *dwc = dep->dwc;
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index c9e66dfb02e6..1e35963bd4ed 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -475,8 +475,7 @@ static int at91_ep_enable(struct usb_ep *_ep,
475 unsigned long flags; 475 unsigned long flags;
476 476
477 if (!_ep || !ep 477 if (!_ep || !ep
478 || !desc || ep->ep.desc 478 || !desc || _ep->name == ep0name
479 || _ep->name == ep0name
480 || desc->bDescriptorType != USB_DT_ENDPOINT 479 || desc->bDescriptorType != USB_DT_ENDPOINT
481 || (maxpacket = usb_endpoint_maxp(desc)) == 0 480 || (maxpacket = usb_endpoint_maxp(desc)) == 0
482 || maxpacket > ep->maxpacket) { 481 || maxpacket > ep->maxpacket) {
@@ -530,7 +529,6 @@ ok:
530 tmp |= AT91_UDP_EPEDS; 529 tmp |= AT91_UDP_EPEDS;
531 __raw_writel(tmp, ep->creg); 530 __raw_writel(tmp, ep->creg);
532 531
533 ep->ep.desc = desc;
534 ep->ep.maxpacket = maxpacket; 532 ep->ep.maxpacket = maxpacket;
535 533
536 /* 534 /*
@@ -1635,7 +1633,6 @@ static int at91_start(struct usb_gadget *gadget,
1635 udc->driver = driver; 1633 udc->driver = driver;
1636 udc->gadget.dev.driver = &driver->driver; 1634 udc->gadget.dev.driver = &driver->driver;
1637 udc->gadget.dev.of_node = udc->pdev->dev.of_node; 1635 udc->gadget.dev.of_node = udc->pdev->dev.of_node;
1638 dev_set_drvdata(&udc->gadget.dev, &driver->driver);
1639 udc->enabled = 1; 1636 udc->enabled = 1;
1640 udc->selfpowered = 1; 1637 udc->selfpowered = 1;
1641 1638
@@ -1656,7 +1653,6 @@ static int at91_stop(struct usb_gadget *gadget,
1656 spin_unlock_irqrestore(&udc->lock, flags); 1653 spin_unlock_irqrestore(&udc->lock, flags);
1657 1654
1658 udc->gadget.dev.driver = NULL; 1655 udc->gadget.dev.driver = NULL;
1659 dev_set_drvdata(&udc->gadget.dev, NULL);
1660 udc->driver = NULL; 1656 udc->driver = NULL;
1661 1657
1662 DBG("unbound from %s\n", driver->driver.name); 1658 DBG("unbound from %s\n", driver->driver.name);
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index b799106027ad..afdbb1cbf5d9 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -1916,6 +1916,27 @@ done:
1916 return retval; 1916 return retval;
1917} 1917}
1918 1918
1919/* usb 3.0 root hub device descriptor */
1920struct {
1921 struct usb_bos_descriptor bos;
1922 struct usb_ss_cap_descriptor ss_cap;
1923} __packed usb3_bos_desc = {
1924
1925 .bos = {
1926 .bLength = USB_DT_BOS_SIZE,
1927 .bDescriptorType = USB_DT_BOS,
1928 .wTotalLength = cpu_to_le16(sizeof(usb3_bos_desc)),
1929 .bNumDeviceCaps = 1,
1930 },
1931 .ss_cap = {
1932 .bLength = USB_DT_USB_SS_CAP_SIZE,
1933 .bDescriptorType = USB_DT_DEVICE_CAPABILITY,
1934 .bDevCapabilityType = USB_SS_CAP_TYPE,
1935 .wSpeedSupported = cpu_to_le16(USB_5GBPS_OPERATION),
1936 .bFunctionalitySupport = ilog2(USB_5GBPS_OPERATION),
1937 },
1938};
1939
1919static inline void 1940static inline void
1920ss_hub_descriptor(struct usb_hub_descriptor *desc) 1941ss_hub_descriptor(struct usb_hub_descriptor *desc)
1921{ 1942{
@@ -2006,6 +2027,18 @@ static int dummy_hub_control(
2006 else 2027 else
2007 hub_descriptor((struct usb_hub_descriptor *) buf); 2028 hub_descriptor((struct usb_hub_descriptor *) buf);
2008 break; 2029 break;
2030
2031 case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
2032 if (hcd->speed != HCD_USB3)
2033 goto error;
2034
2035 if ((wValue >> 8) != USB_DT_BOS)
2036 goto error;
2037
2038 memcpy(buf, &usb3_bos_desc, sizeof(usb3_bos_desc));
2039 retval = sizeof(usb3_bos_desc);
2040 break;
2041
2009 case GetHubStatus: 2042 case GetHubStatus:
2010 *(__le32 *) buf = cpu_to_le32(0); 2043 *(__le32 *) buf = cpu_to_le32(0);
2011 break; 2044 break;
@@ -2503,10 +2536,8 @@ static int dummy_hcd_probe(struct platform_device *pdev)
2503 hs_hcd->has_tt = 1; 2536 hs_hcd->has_tt = 1;
2504 2537
2505 retval = usb_add_hcd(hs_hcd, 0, 0); 2538 retval = usb_add_hcd(hs_hcd, 0, 0);
2506 if (retval != 0) { 2539 if (retval)
2507 usb_put_hcd(hs_hcd); 2540 goto put_usb2_hcd;
2508 return retval;
2509 }
2510 2541
2511 if (mod_data.is_super_speed) { 2542 if (mod_data.is_super_speed) {
2512 ss_hcd = usb_create_shared_hcd(&dummy_hcd, &pdev->dev, 2543 ss_hcd = usb_create_shared_hcd(&dummy_hcd, &pdev->dev,
@@ -2525,6 +2556,8 @@ static int dummy_hcd_probe(struct platform_device *pdev)
2525put_usb3_hcd: 2556put_usb3_hcd:
2526 usb_put_hcd(ss_hcd); 2557 usb_put_hcd(ss_hcd);
2527dealloc_usb2_hcd: 2558dealloc_usb2_hcd:
2559 usb_remove_hcd(hs_hcd);
2560put_usb2_hcd:
2528 usb_put_hcd(hs_hcd); 2561 usb_put_hcd(hs_hcd);
2529 the_controller.hs_hcd = the_controller.ss_hcd = NULL; 2562 the_controller.hs_hcd = the_controller.ss_hcd = NULL;
2530 return retval; 2563 return retval;
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 8adc79d1b402..829aba75a6df 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -34,11 +34,15 @@
34/* Debugging ****************************************************************/ 34/* Debugging ****************************************************************/
35 35
36#ifdef VERBOSE_DEBUG 36#ifdef VERBOSE_DEBUG
37#ifndef pr_vdebug
37# define pr_vdebug pr_debug 38# define pr_vdebug pr_debug
39#endif /* pr_vdebug */
38# define ffs_dump_mem(prefix, ptr, len) \ 40# define ffs_dump_mem(prefix, ptr, len) \
39 print_hex_dump_bytes(pr_fmt(prefix ": "), DUMP_PREFIX_NONE, ptr, len) 41 print_hex_dump_bytes(pr_fmt(prefix ": "), DUMP_PREFIX_NONE, ptr, len)
40#else 42#else
43#ifndef pr_vdebug
41# define pr_vdebug(...) do { } while (0) 44# define pr_vdebug(...) do { } while (0)
45#endif /* pr_vdebug */
42# define ffs_dump_mem(prefix, ptr, len) do { } while (0) 46# define ffs_dump_mem(prefix, ptr, len) do { } while (0)
43#endif /* VERBOSE_DEBUG */ 47#endif /* VERBOSE_DEBUG */
44 48
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index b13e0bb5f5b8..0bb617e1dda2 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3599,6 +3599,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
3599 3599
3600 if (hsotg->num_of_eps == 0) { 3600 if (hsotg->num_of_eps == 0) {
3601 dev_err(dev, "wrong number of EPs (zero)\n"); 3601 dev_err(dev, "wrong number of EPs (zero)\n");
3602 ret = -EINVAL;
3602 goto err_supplies; 3603 goto err_supplies;
3603 } 3604 }
3604 3605
@@ -3606,6 +3607,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
3606 GFP_KERNEL); 3607 GFP_KERNEL);
3607 if (!eps) { 3608 if (!eps) {
3608 dev_err(dev, "cannot get memory\n"); 3609 dev_err(dev, "cannot get memory\n");
3610 ret = -ENOMEM;
3609 goto err_supplies; 3611 goto err_supplies;
3610 } 3612 }
3611 3613
@@ -3622,6 +3624,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
3622 GFP_KERNEL); 3624 GFP_KERNEL);
3623 if (!hsotg->ctrl_req) { 3625 if (!hsotg->ctrl_req) {
3624 dev_err(dev, "failed to allocate ctrl req\n"); 3626 dev_err(dev, "failed to allocate ctrl req\n");
3627 ret = -ENOMEM;
3625 goto err_ep_mem; 3628 goto err_ep_mem;
3626 } 3629 }
3627 3630
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index 5b3f5fffea92..da6d479ff9a6 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -132,11 +132,15 @@ static unsigned n_ports;
132 132
133 133
134#ifdef VERBOSE_DEBUG 134#ifdef VERBOSE_DEBUG
135#ifndef pr_vdebug
135#define pr_vdebug(fmt, arg...) \ 136#define pr_vdebug(fmt, arg...) \
136 pr_debug(fmt, ##arg) 137 pr_debug(fmt, ##arg)
138#endif /* pr_vdebug */
137#else 139#else
140#ifndef pr_vdebig
138#define pr_vdebug(fmt, arg...) \ 141#define pr_vdebug(fmt, arg...) \
139 ({ if (0) pr_debug(fmt, ##arg); }) 142 ({ if (0) pr_debug(fmt, ##arg); })
143#endif /* pr_vdebug */
140#endif 144#endif
141 145
142/*-------------------------------------------------------------------------*/ 146/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 9bc39ca460c8..4b66374bdc8e 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -128,9 +128,17 @@ qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
128 else { 128 else {
129 qtd = list_entry (qh->qtd_list.next, 129 qtd = list_entry (qh->qtd_list.next,
130 struct ehci_qtd, qtd_list); 130 struct ehci_qtd, qtd_list);
131 /* first qtd may already be partially processed */ 131 /*
132 if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current) 132 * first qtd may already be partially processed.
133 * If we come here during unlink, the QH overlay region
134 * might have reference to the just unlinked qtd. The
135 * qtd is updated in qh_completions(). Update the QH
136 * overlay here.
137 */
138 if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current) {
139 qh->hw->hw_qtd_next = qtd->hw_next;
133 qtd = NULL; 140 qtd = NULL;
141 }
134 } 142 }
135 143
136 if (qtd) 144 if (qtd)
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index a665b3eaa746..aaa8d2bce217 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -570,6 +570,16 @@ static int __devinit ohci_hcd_at91_drv_probe(struct platform_device *pdev)
570 570
571 if (pdata) { 571 if (pdata) {
572 at91_for_each_port(i) { 572 at91_for_each_port(i) {
573 /*
574 * do not configure PIO if not in relation with
575 * real USB port on board
576 */
577 if (i >= pdata->ports) {
578 pdata->vbus_pin[i] = -EINVAL;
579 pdata->overcurrent_pin[i] = -EINVAL;
580 break;
581 }
582
573 if (!gpio_is_valid(pdata->vbus_pin[i])) 583 if (!gpio_is_valid(pdata->vbus_pin[i]))
574 continue; 584 continue;
575 gpio = pdata->vbus_pin[i]; 585 gpio = pdata->vbus_pin[i];
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index c5e9e4a76f14..966d1484ee79 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -75,7 +75,9 @@
75#define NB_PIF0_PWRDOWN_1 0x01100013 75#define NB_PIF0_PWRDOWN_1 0x01100013
76 76
77#define USB_INTEL_XUSB2PR 0xD0 77#define USB_INTEL_XUSB2PR 0xD0
78#define USB_INTEL_USB2PRM 0xD4
78#define USB_INTEL_USB3_PSSEN 0xD8 79#define USB_INTEL_USB3_PSSEN 0xD8
80#define USB_INTEL_USB3PRM 0xDC
79 81
80static struct amd_chipset_info { 82static struct amd_chipset_info {
81 struct pci_dev *nb_dev; 83 struct pci_dev *nb_dev;
@@ -772,10 +774,18 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev)
772 return; 774 return;
773 } 775 }
774 776
775 ports_available = 0xffffffff; 777 /* Read USB3PRM, the USB 3.0 Port Routing Mask Register
778 * Indicate the ports that can be changed from OS.
779 */
780 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3PRM,
781 &ports_available);
782
783 dev_dbg(&xhci_pdev->dev, "Configurable ports to enable SuperSpeed: 0x%x\n",
784 ports_available);
785
776 /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable 786 /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable
777 * Register, to turn on SuperSpeed terminations for all 787 * Register, to turn on SuperSpeed terminations for the
778 * available ports. 788 * switchable ports.
779 */ 789 */
780 pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, 790 pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
781 cpu_to_le32(ports_available)); 791 cpu_to_le32(ports_available));
@@ -785,7 +795,16 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev)
785 dev_dbg(&xhci_pdev->dev, "USB 3.0 ports that are now enabled " 795 dev_dbg(&xhci_pdev->dev, "USB 3.0 ports that are now enabled "
786 "under xHCI: 0x%x\n", ports_available); 796 "under xHCI: 0x%x\n", ports_available);
787 797
788 ports_available = 0xffffffff; 798 /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register
799 * Indicate the USB 2.0 ports to be controlled by the xHCI host.
800 */
801
802 pci_read_config_dword(xhci_pdev, USB_INTEL_USB2PRM,
803 &ports_available);
804
805 dev_dbg(&xhci_pdev->dev, "Configurable USB 2.0 ports to hand over to xCHI: 0x%x\n",
806 ports_available);
807
789 /* Write XUSB2PR, the xHC USB 2.0 Port Routing Register, to 808 /* Write XUSB2PR, the xHC USB 2.0 Port Routing Register, to
790 * switch the USB 2.0 power and data lines over to the xHCI 809 * switch the USB 2.0 power and data lines over to the xHCI
791 * host. 810 * host.
@@ -822,12 +841,12 @@ static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev)
822 void __iomem *op_reg_base; 841 void __iomem *op_reg_base;
823 u32 val; 842 u32 val;
824 int timeout; 843 int timeout;
844 int len = pci_resource_len(pdev, 0);
825 845
826 if (!mmio_resource_enabled(pdev, 0)) 846 if (!mmio_resource_enabled(pdev, 0))
827 return; 847 return;
828 848
829 base = ioremap_nocache(pci_resource_start(pdev, 0), 849 base = ioremap_nocache(pci_resource_start(pdev, 0), len);
830 pci_resource_len(pdev, 0));
831 if (base == NULL) 850 if (base == NULL)
832 return; 851 return;
833 852
@@ -837,9 +856,17 @@ static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev)
837 */ 856 */
838 ext_cap_offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET); 857 ext_cap_offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET);
839 do { 858 do {
859 if ((ext_cap_offset + sizeof(val)) > len) {
860 /* We're reading garbage from the controller */
861 dev_warn(&pdev->dev,
862 "xHCI controller failing to respond");
863 return;
864 }
865
840 if (!ext_cap_offset) 866 if (!ext_cap_offset)
841 /* We've reached the end of the extended capabilities */ 867 /* We've reached the end of the extended capabilities */
842 goto hc_init; 868 goto hc_init;
869
843 val = readl(base + ext_cap_offset); 870 val = readl(base + ext_cap_offset);
844 if (XHCI_EXT_CAPS_ID(val) == XHCI_EXT_CAPS_LEGACY) 871 if (XHCI_EXT_CAPS_ID(val) == XHCI_EXT_CAPS_LEGACY)
845 break; 872 break;
@@ -870,9 +897,10 @@ static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev)
870 /* Disable any BIOS SMIs and clear all SMI events*/ 897 /* Disable any BIOS SMIs and clear all SMI events*/
871 writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET); 898 writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
872 899
900hc_init:
873 if (usb_is_intel_switchable_xhci(pdev)) 901 if (usb_is_intel_switchable_xhci(pdev))
874 usb_enable_xhci_ports(pdev); 902 usb_enable_xhci_ports(pdev);
875hc_init: 903
876 op_reg_base = base + XHCI_HC_LENGTH(readl(base)); 904 op_reg_base = base + XHCI_HC_LENGTH(readl(base));
877 905
878 /* Wait for the host controller to be ready before writing any 906 /* Wait for the host controller to be ready before writing any
diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h
index ef004a5de20f..7f69a39163ce 100644
--- a/drivers/usb/host/pci-quirks.h
+++ b/drivers/usb/host/pci-quirks.h
@@ -15,6 +15,7 @@ void usb_disable_xhci_ports(struct pci_dev *xhci_pdev);
15static inline void usb_amd_quirk_pll_disable(void) {} 15static inline void usb_amd_quirk_pll_disable(void) {}
16static inline void usb_amd_quirk_pll_enable(void) {} 16static inline void usb_amd_quirk_pll_enable(void) {}
17static inline void usb_amd_dev_put(void) {} 17static inline void usb_amd_dev_put(void) {}
18static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
18#endif /* CONFIG_PCI */ 19#endif /* CONFIG_PCI */
19 20
20#endif /* __LINUX_USB_PCI_QUIRKS_H */ 21#endif /* __LINUX_USB_PCI_QUIRKS_H */
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 74bfc868b7ad..d5eb357aa5c4 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -493,11 +493,48 @@ static void xhci_hub_report_link_state(u32 *status, u32 status_reg)
493 * when this bit is set. 493 * when this bit is set.
494 */ 494 */
495 pls |= USB_PORT_STAT_CONNECTION; 495 pls |= USB_PORT_STAT_CONNECTION;
496 } else {
497 /*
498 * If CAS bit isn't set but the Port is already at
499 * Compliance Mode, fake a connection so the USB core
500 * notices the Compliance state and resets the port.
501 * This resolves an issue generated by the SN65LVPE502CP
502 * in which sometimes the port enters compliance mode
503 * caused by a delay on the host-device negotiation.
504 */
505 if (pls == USB_SS_PORT_LS_COMP_MOD)
506 pls |= USB_PORT_STAT_CONNECTION;
496 } 507 }
508
497 /* update status field */ 509 /* update status field */
498 *status |= pls; 510 *status |= pls;
499} 511}
500 512
513/*
514 * Function for Compliance Mode Quirk.
515 *
516 * This Function verifies if all xhc USB3 ports have entered U0, if so,
517 * the compliance mode timer is deleted. A port won't enter
518 * compliance mode if it has previously entered U0.
519 */
520void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, u16 wIndex)
521{
522 u32 all_ports_seen_u0 = ((1 << xhci->num_usb3_ports)-1);
523 bool port_in_u0 = ((status & PORT_PLS_MASK) == XDEV_U0);
524
525 if (!(xhci->quirks & XHCI_COMP_MODE_QUIRK))
526 return;
527
528 if ((xhci->port_status_u0 != all_ports_seen_u0) && port_in_u0) {
529 xhci->port_status_u0 |= 1 << wIndex;
530 if (xhci->port_status_u0 == all_ports_seen_u0) {
531 del_timer_sync(&xhci->comp_mode_recovery_timer);
532 xhci_dbg(xhci, "All USB3 ports have entered U0 already!\n");
533 xhci_dbg(xhci, "Compliance Mode Recovery Timer Deleted.\n");
534 }
535 }
536}
537
501int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 538int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
502 u16 wIndex, char *buf, u16 wLength) 539 u16 wIndex, char *buf, u16 wLength)
503{ 540{
@@ -651,6 +688,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
651 /* Update Port Link State for super speed ports*/ 688 /* Update Port Link State for super speed ports*/
652 if (hcd->speed == HCD_USB3) { 689 if (hcd->speed == HCD_USB3) {
653 xhci_hub_report_link_state(&status, temp); 690 xhci_hub_report_link_state(&status, temp);
691 /*
692 * Verify if all USB3 Ports Have entered U0 already.
693 * Delete Compliance Mode Timer if so.
694 */
695 xhci_del_comp_mod_timer(xhci, temp, wIndex);
654 } 696 }
655 if (bus_state->port_c_suspend & (1 << wIndex)) 697 if (bus_state->port_c_suspend & (1 << wIndex))
656 status |= 1 << USB_PORT_FEAT_C_SUSPEND; 698 status |= 1 << USB_PORT_FEAT_C_SUSPEND;
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 689bc18b051d..df90fe51b4aa 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -118,7 +118,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
118 goto put_hcd; 118 goto put_hcd;
119 } 119 }
120 120
121 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 121 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
122 if (!hcd->regs) { 122 if (!hcd->regs) {
123 dev_dbg(&pdev->dev, "error mapping memory\n"); 123 dev_dbg(&pdev->dev, "error mapping memory\n");
124 ret = -EFAULT; 124 ret = -EFAULT;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index c59d5b5b6c7d..6ece0ed288d4 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -26,6 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/dmi.h>
29 30
30#include "xhci.h" 31#include "xhci.h"
31 32
@@ -398,6 +399,95 @@ static void xhci_msix_sync_irqs(struct xhci_hcd *xhci)
398 399
399#endif 400#endif
400 401
402static void compliance_mode_recovery(unsigned long arg)
403{
404 struct xhci_hcd *xhci;
405 struct usb_hcd *hcd;
406 u32 temp;
407 int i;
408
409 xhci = (struct xhci_hcd *)arg;
410
411 for (i = 0; i < xhci->num_usb3_ports; i++) {
412 temp = xhci_readl(xhci, xhci->usb3_ports[i]);
413 if ((temp & PORT_PLS_MASK) == USB_SS_PORT_LS_COMP_MOD) {
414 /*
415 * Compliance Mode Detected. Letting USB Core
416 * handle the Warm Reset
417 */
418 xhci_dbg(xhci, "Compliance Mode Detected->Port %d!\n",
419 i + 1);
420 xhci_dbg(xhci, "Attempting Recovery routine!\n");
421 hcd = xhci->shared_hcd;
422
423 if (hcd->state == HC_STATE_SUSPENDED)
424 usb_hcd_resume_root_hub(hcd);
425
426 usb_hcd_poll_rh_status(hcd);
427 }
428 }
429
430 if (xhci->port_status_u0 != ((1 << xhci->num_usb3_ports)-1))
431 mod_timer(&xhci->comp_mode_recovery_timer,
432 jiffies + msecs_to_jiffies(COMP_MODE_RCVRY_MSECS));
433}
434
435/*
436 * Quirk to work around issue generated by the SN65LVPE502CP USB3.0 re-driver
437 * that causes ports behind that hardware to enter compliance mode sometimes.
438 * The quirk creates a timer that polls every 2 seconds the link state of
439 * each host controller's port and recovers it by issuing a Warm reset
440 * if Compliance mode is detected, otherwise the port will become "dead" (no
441 * device connections or disconnections will be detected anymore). Becasue no
442 * status event is generated when entering compliance mode (per xhci spec),
443 * this quirk is needed on systems that have the failing hardware installed.
444 */
445static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci)
446{
447 xhci->port_status_u0 = 0;
448 init_timer(&xhci->comp_mode_recovery_timer);
449
450 xhci->comp_mode_recovery_timer.data = (unsigned long) xhci;
451 xhci->comp_mode_recovery_timer.function = compliance_mode_recovery;
452 xhci->comp_mode_recovery_timer.expires = jiffies +
453 msecs_to_jiffies(COMP_MODE_RCVRY_MSECS);
454
455 set_timer_slack(&xhci->comp_mode_recovery_timer,
456 msecs_to_jiffies(COMP_MODE_RCVRY_MSECS));
457 add_timer(&xhci->comp_mode_recovery_timer);
458 xhci_dbg(xhci, "Compliance Mode Recovery Timer Initialized.\n");
459}
460
461/*
462 * This function identifies the systems that have installed the SN65LVPE502CP
463 * USB3.0 re-driver and that need the Compliance Mode Quirk.
464 * Systems:
465 * Vendor: Hewlett-Packard -> System Models: Z420, Z620 and Z820
466 */
467static bool compliance_mode_recovery_timer_quirk_check(void)
468{
469 const char *dmi_product_name, *dmi_sys_vendor;
470
471 dmi_product_name = dmi_get_system_info(DMI_PRODUCT_NAME);
472 dmi_sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR);
473
474 if (!(strstr(dmi_sys_vendor, "Hewlett-Packard")))
475 return false;
476
477 if (strstr(dmi_product_name, "Z420") ||
478 strstr(dmi_product_name, "Z620") ||
479 strstr(dmi_product_name, "Z820"))
480 return true;
481
482 return false;
483}
484
485static int xhci_all_ports_seen_u0(struct xhci_hcd *xhci)
486{
487 return (xhci->port_status_u0 == ((1 << xhci->num_usb3_ports)-1));
488}
489
490
401/* 491/*
402 * Initialize memory for HCD and xHC (one-time init). 492 * Initialize memory for HCD and xHC (one-time init).
403 * 493 *
@@ -421,6 +511,12 @@ int xhci_init(struct usb_hcd *hcd)
421 retval = xhci_mem_init(xhci, GFP_KERNEL); 511 retval = xhci_mem_init(xhci, GFP_KERNEL);
422 xhci_dbg(xhci, "Finished xhci_init\n"); 512 xhci_dbg(xhci, "Finished xhci_init\n");
423 513
514 /* Initializing Compliance Mode Recovery Data If Needed */
515 if (compliance_mode_recovery_timer_quirk_check()) {
516 xhci->quirks |= XHCI_COMP_MODE_QUIRK;
517 compliance_mode_recovery_timer_init(xhci);
518 }
519
424 return retval; 520 return retval;
425} 521}
426 522
@@ -629,6 +725,11 @@ void xhci_stop(struct usb_hcd *hcd)
629 del_timer_sync(&xhci->event_ring_timer); 725 del_timer_sync(&xhci->event_ring_timer);
630#endif 726#endif
631 727
728 /* Deleting Compliance Mode Recovery Timer */
729 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
730 (!(xhci_all_ports_seen_u0(xhci))))
731 del_timer_sync(&xhci->comp_mode_recovery_timer);
732
632 if (xhci->quirks & XHCI_AMD_PLL_FIX) 733 if (xhci->quirks & XHCI_AMD_PLL_FIX)
633 usb_amd_dev_put(); 734 usb_amd_dev_put();
634 735
@@ -659,7 +760,7 @@ void xhci_shutdown(struct usb_hcd *hcd)
659{ 760{
660 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 761 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
661 762
662 if (xhci->quirks && XHCI_SPURIOUS_REBOOT) 763 if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
663 usb_disable_xhci_ports(to_pci_dev(hcd->self.controller)); 764 usb_disable_xhci_ports(to_pci_dev(hcd->self.controller));
664 765
665 spin_lock_irq(&xhci->lock); 766 spin_lock_irq(&xhci->lock);
@@ -806,6 +907,16 @@ int xhci_suspend(struct xhci_hcd *xhci)
806 } 907 }
807 spin_unlock_irq(&xhci->lock); 908 spin_unlock_irq(&xhci->lock);
808 909
910 /*
911 * Deleting Compliance Mode Recovery Timer because the xHCI Host
912 * is about to be suspended.
913 */
914 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
915 (!(xhci_all_ports_seen_u0(xhci)))) {
916 del_timer_sync(&xhci->comp_mode_recovery_timer);
917 xhci_dbg(xhci, "Compliance Mode Recovery Timer Deleted!\n");
918 }
919
809 /* step 5: remove core well power */ 920 /* step 5: remove core well power */
810 /* synchronize irq when using MSI-X */ 921 /* synchronize irq when using MSI-X */
811 xhci_msix_sync_irqs(xhci); 922 xhci_msix_sync_irqs(xhci);
@@ -938,6 +1049,16 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
938 usb_hcd_resume_root_hub(hcd); 1049 usb_hcd_resume_root_hub(hcd);
939 usb_hcd_resume_root_hub(xhci->shared_hcd); 1050 usb_hcd_resume_root_hub(xhci->shared_hcd);
940 } 1051 }
1052
1053 /*
1054 * If system is subject to the Quirk, Compliance Mode Timer needs to
1055 * be re-initialized Always after a system resume. Ports are subject
1056 * to suffer the Compliance Mode issue again. It doesn't matter if
1057 * ports have entered previously to U0 before system's suspension.
1058 */
1059 if (xhci->quirks & XHCI_COMP_MODE_QUIRK)
1060 compliance_mode_recovery_timer_init(xhci);
1061
941 return retval; 1062 return retval;
942} 1063}
943#endif /* CONFIG_PM */ 1064#endif /* CONFIG_PM */
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index c713256297ac..1a05908c6673 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1495,6 +1495,7 @@ struct xhci_hcd {
1495#define XHCI_LPM_SUPPORT (1 << 11) 1495#define XHCI_LPM_SUPPORT (1 << 11)
1496#define XHCI_INTEL_HOST (1 << 12) 1496#define XHCI_INTEL_HOST (1 << 12)
1497#define XHCI_SPURIOUS_REBOOT (1 << 13) 1497#define XHCI_SPURIOUS_REBOOT (1 << 13)
1498#define XHCI_COMP_MODE_QUIRK (1 << 14)
1498 unsigned int num_active_eps; 1499 unsigned int num_active_eps;
1499 unsigned int limit_active_eps; 1500 unsigned int limit_active_eps;
1500 /* There are two roothubs to keep track of bus suspend info for */ 1501 /* There are two roothubs to keep track of bus suspend info for */
@@ -1511,6 +1512,11 @@ struct xhci_hcd {
1511 unsigned sw_lpm_support:1; 1512 unsigned sw_lpm_support:1;
1512 /* support xHCI 1.0 spec USB2 hardware LPM */ 1513 /* support xHCI 1.0 spec USB2 hardware LPM */
1513 unsigned hw_lpm_support:1; 1514 unsigned hw_lpm_support:1;
1515 /* Compliance Mode Recovery Data */
1516 struct timer_list comp_mode_recovery_timer;
1517 u32 port_status_u0;
1518/* Compliance Mode Timer Triggered every 2 seconds */
1519#define COMP_MODE_RCVRY_MSECS 2000
1514}; 1520};
1515 1521
1516/* convert between an HCD pointer and the corresponding EHCI_HCD */ 1522/* convert between an HCD pointer and the corresponding EHCI_HCD */
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 4bb717d0bd41..1ae378d5fc6f 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2049,7 +2049,7 @@ static int musb_urb_enqueue(
2049 * we only have work to do in the former case. 2049 * we only have work to do in the former case.
2050 */ 2050 */
2051 spin_lock_irqsave(&musb->lock, flags); 2051 spin_lock_irqsave(&musb->lock, flags);
2052 if (hep->hcpriv) { 2052 if (hep->hcpriv || !next_urb(qh)) {
2053 /* some concurrent activity submitted another urb to hep... 2053 /* some concurrent activity submitted another urb to hep...
2054 * odd, rare, error prone, but legal. 2054 * odd, rare, error prone, but legal.
2055 */ 2055 */
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 57a608584e16..c1be687e00ec 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -388,7 +388,7 @@ dma_controller_create(struct musb *musb, void __iomem *base)
388 struct platform_device *pdev = to_platform_device(dev); 388 struct platform_device *pdev = to_platform_device(dev);
389 int irq = platform_get_irq_byname(pdev, "dma"); 389 int irq = platform_get_irq_byname(pdev, "dma");
390 390
391 if (irq == 0) { 391 if (irq <= 0) {
392 dev_err(dev, "No DMA interrupt line!\n"); 392 dev_err(dev, "No DMA interrupt line!\n");
393 return NULL; 393 return NULL;
394 } 394 }
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 1a1bd9cf40c5..341625442377 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1215,7 +1215,7 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1215 ret = platform_device_add(musb); 1215 ret = platform_device_add(musb);
1216 if (ret) { 1216 if (ret) {
1217 dev_err(&pdev->dev, "failed to register musb device\n"); 1217 dev_err(&pdev->dev, "failed to register musb device\n");
1218 goto err1; 1218 goto err2;
1219 } 1219 }
1220 1220
1221 return 0; 1221 return 0;
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index ecd173032fd4..143c4e9e1be4 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -818,7 +818,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
818 usbhs_pipe_is_dcp(pipe)) 818 usbhs_pipe_is_dcp(pipe))
819 goto usbhsf_pio_prepare_push; 819 goto usbhsf_pio_prepare_push;
820 820
821 if (len % 4) /* 32bit alignment */ 821 if (len & 0x7) /* 8byte alignment */
822 goto usbhsf_pio_prepare_push; 822 goto usbhsf_pio_prepare_push;
823 823
824 if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */ 824 if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */
@@ -905,7 +905,7 @@ static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int *is_done)
905 /* use PIO if packet is less than pio_dma_border */ 905 /* use PIO if packet is less than pio_dma_border */
906 len = usbhsf_fifo_rcv_len(priv, fifo); 906 len = usbhsf_fifo_rcv_len(priv, fifo);
907 len = min(pkt->length - pkt->actual, len); 907 len = min(pkt->length - pkt->actual, len);
908 if (len % 4) /* 32bit alignment */ 908 if (len & 0x7) /* 8byte alignment */
909 goto usbhsf_pio_prepare_pop_unselect; 909 goto usbhsf_pio_prepare_pop_unselect;
910 910
911 if (len < usbhs_get_dparam(priv, pio_dma_border)) 911 if (len < usbhs_get_dparam(priv, pio_dma_border))
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 5620db6469e5..f906b3aec217 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -704,6 +704,7 @@ static struct usb_device_id id_table_combined [] = {
704 { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) }, 704 { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) },
705 { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) }, 705 { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) },
706 { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) }, 706 { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) },
707 { USB_DEVICE(FTDI_VID, FTDI_NZR_SEM_USB_PID) },
707 { USB_DEVICE(ICOM_VID, ICOM_ID_1_PID) }, 708 { USB_DEVICE(ICOM_VID, ICOM_ID_1_PID) },
708 { USB_DEVICE(ICOM_VID, ICOM_OPC_U_UC_PID) }, 709 { USB_DEVICE(ICOM_VID, ICOM_OPC_U_UC_PID) },
709 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2C1_PID) }, 710 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2C1_PID) },
@@ -804,13 +805,32 @@ static struct usb_device_id id_table_combined [] = {
804 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 805 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
805 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), 806 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID),
806 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 807 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
807 { USB_DEVICE(MICROCHIP_VID, MICROCHIP_USB_BOARD_PID) }, 808 { USB_DEVICE_AND_INTERFACE_INFO(MICROCHIP_VID, MICROCHIP_USB_BOARD_PID,
809 USB_CLASS_VENDOR_SPEC,
810 USB_SUBCLASS_VENDOR_SPEC, 0x00) },
808 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, 811 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
809 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), 812 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
810 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 813 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
811 { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) }, 814 { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) },
812 { USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) }, 815 { USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) },
816 { USB_DEVICE(FTDI_VID, PI_C865_PID) },
817 { USB_DEVICE(FTDI_VID, PI_C857_PID) },
818 { USB_DEVICE(PI_VID, PI_C866_PID) },
819 { USB_DEVICE(PI_VID, PI_C663_PID) },
820 { USB_DEVICE(PI_VID, PI_C725_PID) },
821 { USB_DEVICE(PI_VID, PI_E517_PID) },
822 { USB_DEVICE(PI_VID, PI_C863_PID) },
813 { USB_DEVICE(PI_VID, PI_E861_PID) }, 823 { USB_DEVICE(PI_VID, PI_E861_PID) },
824 { USB_DEVICE(PI_VID, PI_C867_PID) },
825 { USB_DEVICE(PI_VID, PI_E609_PID) },
826 { USB_DEVICE(PI_VID, PI_E709_PID) },
827 { USB_DEVICE(PI_VID, PI_100F_PID) },
828 { USB_DEVICE(PI_VID, PI_1011_PID) },
829 { USB_DEVICE(PI_VID, PI_1012_PID) },
830 { USB_DEVICE(PI_VID, PI_1013_PID) },
831 { USB_DEVICE(PI_VID, PI_1014_PID) },
832 { USB_DEVICE(PI_VID, PI_1015_PID) },
833 { USB_DEVICE(PI_VID, PI_1016_PID) },
814 { USB_DEVICE(KONDO_VID, KONDO_USB_SERIAL_PID) }, 834 { USB_DEVICE(KONDO_VID, KONDO_USB_SERIAL_PID) },
815 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) }, 835 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
816 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID), 836 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 5dd96ca6c380..41fe5826100c 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -75,6 +75,9 @@
75#define FTDI_OPENDCC_GATEWAY_PID 0xBFDB 75#define FTDI_OPENDCC_GATEWAY_PID 0xBFDB
76#define FTDI_OPENDCC_GBM_PID 0xBFDC 76#define FTDI_OPENDCC_GBM_PID 0xBFDC
77 77
78/* NZR SEM 16+ USB (http://www.nzr.de) */
79#define FTDI_NZR_SEM_USB_PID 0xC1E0 /* NZR SEM-LOG16+ */
80
78/* 81/*
79 * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com) 82 * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
80 */ 83 */
@@ -539,7 +542,10 @@
539/* 542/*
540 * Microchip Technology, Inc. 543 * Microchip Technology, Inc.
541 * 544 *
542 * MICROCHIP_VID (0x04D8) and MICROCHIP_USB_BOARD_PID (0x000A) are also used by: 545 * MICROCHIP_VID (0x04D8) and MICROCHIP_USB_BOARD_PID (0x000A) are
546 * used by single function CDC ACM class based firmware demo
547 * applications. The VID/PID has also been used in firmware
548 * emulating FTDI serial chips by:
543 * Hornby Elite - Digital Command Control Console 549 * Hornby Elite - Digital Command Control Console
544 * http://www.hornby.com/hornby-dcc/controllers/ 550 * http://www.hornby.com/hornby-dcc/controllers/
545 */ 551 */
@@ -791,8 +797,27 @@
791 * Physik Instrumente 797 * Physik Instrumente
792 * http://www.physikinstrumente.com/en/products/ 798 * http://www.physikinstrumente.com/en/products/
793 */ 799 */
800/* These two devices use the VID of FTDI */
801#define PI_C865_PID 0xe0a0 /* PI C-865 Piezomotor Controller */
802#define PI_C857_PID 0xe0a1 /* PI Encoder Trigger Box */
803
794#define PI_VID 0x1a72 /* Vendor ID */ 804#define PI_VID 0x1a72 /* Vendor ID */
795#define PI_E861_PID 0x1008 /* E-861 piezo controller USB connection */ 805#define PI_C866_PID 0x1000 /* PI C-866 Piezomotor Controller */
806#define PI_C663_PID 0x1001 /* PI C-663 Mercury-Step */
807#define PI_C725_PID 0x1002 /* PI C-725 Piezomotor Controller */
808#define PI_E517_PID 0x1005 /* PI E-517 Digital Piezo Controller Operation Module */
809#define PI_C863_PID 0x1007 /* PI C-863 */
810#define PI_E861_PID 0x1008 /* PI E-861 Piezomotor Controller */
811#define PI_C867_PID 0x1009 /* PI C-867 Piezomotor Controller */
812#define PI_E609_PID 0x100D /* PI E-609 Digital Piezo Controller */
813#define PI_E709_PID 0x100E /* PI E-709 Digital Piezo Controller */
814#define PI_100F_PID 0x100F /* PI Digital Piezo Controller */
815#define PI_1011_PID 0x1011 /* PI Digital Piezo Controller */
816#define PI_1012_PID 0x1012 /* PI Motion Controller */
817#define PI_1013_PID 0x1013 /* PI Motion Controller */
818#define PI_1014_PID 0x1014 /* PI Device */
819#define PI_1015_PID 0x1015 /* PI Device */
820#define PI_1016_PID 0x1016 /* PI Digital Servo Module */
796 821
797/* 822/*
798 * Kondo Kagaku Co.Ltd. 823 * Kondo Kagaku Co.Ltd.
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index cc40f47ecea1..5ce88d1bc6f1 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -886,8 +886,6 @@ static const struct usb_device_id option_ids[] = {
886 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), 886 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
887 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 887 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
888 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, 888 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) },
889 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1018, 0xff, 0xff, 0xff),
890 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
891 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, 889 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) },
892 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) }, 890 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) },
893 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) }, 891 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) },
@@ -1092,6 +1090,10 @@ static const struct usb_device_id option_ids[] = {
1092 .driver_info = (kernel_ulong_t)&zte_ad3812_z_blacklist }, 1090 .driver_info = (kernel_ulong_t)&zte_ad3812_z_blacklist },
1093 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2716, 0xff, 0xff, 0xff), 1091 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2716, 0xff, 0xff, 0xff),
1094 .driver_info = (kernel_ulong_t)&zte_mc2716_z_blacklist }, 1092 .driver_info = (kernel_ulong_t)&zte_mc2716_z_blacklist },
1093 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) },
1094 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
1095 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
1096
1095 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 1097 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
1096 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 1098 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
1097 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */ 1099 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 1eff743ec497..ae60406ea8a1 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -814,6 +814,9 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
814 hpwdt_timer_reg = pci_mem_addr + 0x70; 814 hpwdt_timer_reg = pci_mem_addr + 0x70;
815 hpwdt_timer_con = pci_mem_addr + 0x72; 815 hpwdt_timer_con = pci_mem_addr + 0x72;
816 816
817 /* Make sure that timer is disabled until /dev/watchdog is opened */
818 hpwdt_stop();
819
817 /* Make sure that we have a valid soft_margin */ 820 /* Make sure that we have a valid soft_margin */
818 if (hpwdt_change_timer(soft_margin)) 821 if (hpwdt_change_timer(soft_margin))
819 hpwdt_change_timer(DEFAULT_MARGIN); 822 hpwdt_change_timer(DEFAULT_MARGIN);
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 6aa46a90ff02..3796434991fa 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -128,11 +128,12 @@ EXPORT_SYMBOL_GPL(watchdog_register_device);
128void watchdog_unregister_device(struct watchdog_device *wdd) 128void watchdog_unregister_device(struct watchdog_device *wdd)
129{ 129{
130 int ret; 130 int ret;
131 int devno = wdd->cdev.dev; 131 int devno;
132 132
133 if (wdd == NULL) 133 if (wdd == NULL)
134 return; 134 return;
135 135
136 devno = wdd->cdev.dev;
136 ret = watchdog_dev_unregister(wdd); 137 ret = watchdog_dev_unregister(wdd);
137 if (ret) 138 if (ret)
138 pr_err("error unregistering /dev/watchdog (err=%d)\n", ret); 139 pr_err("error unregistering /dev/watchdog (err=%d)\n", ret);
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 1ffd03bf8e10..7f1241608489 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -314,8 +314,9 @@ static int __unmap_grant_pages(struct grant_map *map, int offset, int pages)
314 } 314 }
315 } 315 }
316 316
317 err = gnttab_unmap_refs(map->unmap_ops + offset, map->pages + offset, 317 err = gnttab_unmap_refs(map->unmap_ops + offset,
318 pages, true); 318 use_ptemod ? map->kmap_ops + offset : NULL, map->pages + offset,
319 pages);
319 if (err) 320 if (err)
320 return err; 321 return err;
321 322
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 0bfc1ef11259..006726688baf 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -870,7 +870,8 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
870EXPORT_SYMBOL_GPL(gnttab_map_refs); 870EXPORT_SYMBOL_GPL(gnttab_map_refs);
871 871
872int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, 872int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
873 struct page **pages, unsigned int count, bool clear_pte) 873 struct gnttab_map_grant_ref *kmap_ops,
874 struct page **pages, unsigned int count)
874{ 875{
875 int i, ret; 876 int i, ret;
876 bool lazy = false; 877 bool lazy = false;
@@ -888,7 +889,8 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
888 } 889 }
889 890
890 for (i = 0; i < count; i++) { 891 for (i = 0; i < count; i++) {
891 ret = m2p_remove_override(pages[i], clear_pte); 892 ret = m2p_remove_override(pages[i], kmap_ops ?
893 &kmap_ops[i] : NULL);
892 if (ret) 894 if (ret)
893 return ret; 895 return ret;
894 } 896 }