aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/ec_sys.c8
-rw-r--r--drivers/base/firmware_class.c208
-rw-r--r--drivers/base/power/runtime.c3
-rw-r--r--drivers/base/regmap/regcache-rbtree.c2
-rw-r--r--drivers/base/regmap/regmap-debugfs.c12
-rw-r--r--drivers/block/floppy.c36
-rw-r--r--drivers/block/xen-blkfront.c2
-rw-r--r--drivers/bluetooth/btmrvl_debugfs.c26
-rw-r--r--drivers/char/agp/intel-agp.h1
-rw-r--r--drivers/char/agp/intel-gtt.c3
-rw-r--r--drivers/char/apm-emulation.c2
-rw-r--r--drivers/char/tile-srom.c12
-rw-r--r--drivers/char/virtio_console.c8
-rw-r--r--drivers/cpufreq/Kconfig.arm10
-rw-r--r--drivers/cpufreq/db8500-cpufreq.c2
-rw-r--r--drivers/dma/coh901318.c9
-rw-r--r--drivers/dma/sa11x0-dma.c2
-rw-r--r--drivers/edac/mce_amd.c6
-rw-r--r--drivers/edac/tile_edac.c4
-rw-r--r--drivers/gpio/gpio-tegra.c59
-rw-r--r--drivers/gpu/drm/Kconfig1
-rw-r--r--drivers/gpu/drm/Makefile2
-rw-r--r--drivers/gpu/drm/drm_drv.c4
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c8
-rw-r--r--drivers/gpu/drm/drm_fops.c7
-rw-r--r--drivers/gpu/drm/drm_gem.c9
-rw-r--r--drivers/gpu/drm/drm_prime.c304
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c14
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c21
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c13
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h23
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c37
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c9
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c23
-rw-r--r--drivers/gpu/drm/i915/intel_display.c37
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c8
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c2
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c3
-rw-r--r--drivers/gpu/drm/nouveau/Kconfig1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_channel.c10
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_dma.h4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c2
-rw-r--r--drivers/gpu/drm/radeon/atom.c15
-rw-r--r--drivers/gpu/drm/radeon/atom.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c3
-rw-r--r--drivers/gpu/drm/udl/udl_drv.c2
-rw-r--r--drivers/gpu/drm/udl/udl_drv.h1
-rw-r--r--drivers/gpu/drm/udl/udl_gem.c14
-rw-r--r--drivers/hid/hid-picolcd.c16
-rw-r--r--drivers/hid/hid-wiimote-debug.c8
-rw-r--r--drivers/hsi/Kconfig19
-rw-r--r--drivers/hsi/Makefile6
-rw-r--r--drivers/hsi/clients/Kconfig13
-rw-r--r--drivers/hsi/clients/Makefile5
-rw-r--r--drivers/hsi/clients/hsi_char.c802
-rw-r--r--drivers/hsi/hsi.c494
-rw-r--r--drivers/hsi/hsi_boardinfo.c62
-rw-r--r--drivers/hsi/hsi_core.h35
-rw-r--r--drivers/hwmon/Kconfig7
-rw-r--r--drivers/hwmon/acpi_power_meter.c2
-rw-r--r--drivers/hwmon/ad7314.c1
-rw-r--r--drivers/hwmon/adm1031.c20
-rw-r--r--drivers/hwmon/f75375s.c2
-rw-r--r--drivers/hwmon/k10temp.c4
-rw-r--r--drivers/hwmon/max6639.c15
-rw-r--r--drivers/hwmon/w83627ehf.c18
-rw-r--r--drivers/idle/i7300_idle.c8
-rw-r--r--drivers/iommu/amd_iommu.c10
-rw-r--r--drivers/iommu/intel-iommu.c9
-rw-r--r--drivers/iommu/omap-iommu-debug.c10
-rw-r--r--drivers/isdn/hardware/mISDN/avmfritz.c2
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c2
-rw-r--r--drivers/isdn/hardware/mISDN/hfcsusb.c2
-rw-r--r--drivers/isdn/hardware/mISDN/mISDNipac.c2
-rw-r--r--drivers/isdn/hardware/mISDN/mISDNisar.c2
-rw-r--r--drivers/isdn/hardware/mISDN/netjet.c2
-rw-r--r--drivers/isdn/hardware/mISDN/w6692.c2
-rw-r--r--drivers/md/linear.c9
-rw-r--r--drivers/md/raid0.c27
-rw-r--r--drivers/md/raid1.c13
-rw-r--r--drivers/md/raid10.c2
-rw-r--r--drivers/md/raid5.c59
-rw-r--r--drivers/mfd/aat2870-core.c9
-rw-r--r--drivers/mfd/ab3100-core.c8
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c8
-rw-r--r--drivers/misc/kgdbts.c160
-rw-r--r--drivers/mmc/card/block.c27
-rw-r--r--drivers/mmc/core/bus.c17
-rw-r--r--drivers/mmc/core/core.c10
-rw-r--r--drivers/mmc/core/mmc.c30
-rw-r--r--drivers/mmc/core/sdio_bus.c12
-rw-r--r--drivers/mmc/host/atmel-mci-regs.h1
-rw-r--r--drivers/mmc/host/atmel-mci.c55
-rw-r--r--drivers/mmc/host/omap_hsmmc.c181
-rw-r--r--drivers/mmc/host/sdhci-dove.c1
-rw-r--r--drivers/mmc/host/sdhci-pci.c6
-rw-r--r--drivers/mmc/host/sdhci-s3c.c159
-rw-r--r--drivers/mmc/host/sdhci.c5
-rw-r--r--drivers/mmc/host/sh_mmcif.c13
-rw-r--r--drivers/mtd/ubi/debug.c10
-rw-r--r--drivers/net/bonding/bond_main.c68
-rw-r--r--drivers/net/caif/caif_spi.c10
-rw-r--r--drivers/net/eql.c7
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h7
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c41
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h110
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c148
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c464
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c4
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c9
-rw-r--r--drivers/net/ethernet/freescale/fsl_pq_mdio.c12
-rw-r--r--drivers/net/ethernet/freescale/ucc_geth.c6
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_main.c40
-rw-r--r--drivers/net/ethernet/intel/e1000e/e1000.h6
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c33
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c7
-rw-r--r--drivers/net/ethernet/intel/igbvf/netdev.c7
-rw-r--r--drivers/net/ethernet/intel/ixgb/ixgb_main.c6
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c164
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c13
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c7
-rw-r--r--drivers/net/ethernet/marvell/sky2.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h5
-rw-r--r--drivers/net/ethernet/nxp/lpc_eth.c2
-rw-r--r--drivers/net/ethernet/realtek/r8169.c3
-rw-r--r--drivers/net/ethernet/renesas/Kconfig5
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c22
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.h15
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c6
-rw-r--r--drivers/net/ethernet/tile/tilepro.c77
-rw-r--r--drivers/net/ethernet/via/via-rhine.c12
-rw-r--r--drivers/net/irda/sa1100_ir.c2
-rw-r--r--drivers/net/phy/icplus.c3
-rw-r--r--drivers/net/ppp/ppp_generic.c14
-rw-r--r--drivers/net/rionet.c11
-rw-r--r--drivers/net/usb/cdc-phonet.c4
-rw-r--r--drivers/net/usb/cdc_eem.c1
-rw-r--r--drivers/net/usb/rtl8150.c26
-rw-r--r--drivers/net/usb/zaurus.c5
-rw-r--r--drivers/net/virtio_net.c7
-rw-r--r--drivers/net/wimax/i2400m/debugfs.c15
-rw-r--r--drivers/net/wimax/i2400m/netdev.c3
-rw-r--r--drivers/net/wimax/i2400m/usb.c18
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c23
-rw-r--r--drivers/net/wireless/ath/ath6kl/debug.c42
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c37
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_debug.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_debug.c26
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c4
-rw-r--r--drivers/net/wireless/ath/carl9170/debug.c7
-rw-r--r--drivers/net/wireless/b43/debugfs.c8
-rw-r--r--drivers/net/wireless/b43legacy/debugfs.c8
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c4
-rw-r--r--drivers/net/wireless/iwlegacy/3945-mac.c2
-rw-r--r--drivers/net/wireless/iwlegacy/3945-rs.c8
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c2
-rw-r--r--drivers/net/wireless/iwlegacy/4965-rs.c12
-rw-r--r--drivers/net/wireless/iwlegacy/common.c31
-rw-r--r--drivers/net/wireless/iwlegacy/debug.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie.c12
-rw-r--r--drivers/net/wireless/iwmc3200wifi/debugfs.c14
-rw-r--r--drivers/net/wireless/iwmc3200wifi/sdio.c9
-rw-r--r--drivers/net/wireless/libertas/debugfs.c10
-rw-r--r--drivers/net/wireless/mwifiex/debugfs.c18
-rw-r--r--drivers/net/wireless/orinoco/main.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c10
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/phy.c2
-rw-r--r--drivers/net/wireless/wl1251/debugfs.c14
-rw-r--r--drivers/net/wireless/wl12xx/debugfs.c38
-rw-r--r--drivers/net/xen-netfront.c2
-rw-r--r--drivers/oprofile/oprofilefs.c14
-rw-r--r--drivers/pci/xen-pcifront.c1
-rw-r--r--drivers/regulator/anatop-regulator.c5
-rw-r--r--drivers/regulator/core.c4
-rw-r--r--drivers/regulator/fixed-helper.c3
-rw-r--r--drivers/regulator/mc13892-regulator.c10
-rw-r--r--drivers/regulator/s5m8767.c14
-rw-r--r--drivers/regulator/tps6586x-regulator.c5
-rw-r--r--drivers/regulator/wm831x-dcdc.c9
-rw-r--r--drivers/regulator/wm831x-isink.c2
-rw-r--r--drivers/regulator/wm831x-ldo.c7
-rw-r--r--drivers/regulator/wm8350-regulator.c34
-rw-r--r--drivers/remoteproc/remoteproc_debugfs.c13
-rw-r--r--drivers/rtc/rtc-88pm860x.c4
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c9
-rw-r--r--drivers/spi/spi-dw.c8
-rw-r--r--drivers/target/tcm_fc/tcm_fc.h1
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c10
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c13
-rw-r--r--drivers/target/tcm_fc/tfc_io.c2
-rw-r--r--drivers/tty/serial/mfd.c9
-rw-r--r--drivers/tty/serial/pch_uart.c8
-rw-r--r--drivers/tty/serial/sunzilog.c4
-rw-r--r--drivers/tty/sysrq.c2
-rw-r--r--drivers/usb/core/inode.c10
-rw-r--r--drivers/usb/gadget/f_phonet.c2
-rw-r--r--drivers/usb/host/ehci-atmel.c1
-rw-r--r--drivers/usb/host/ehci-dbg.c9
-rw-r--r--drivers/usb/host/ohci-at91.c163
-rw-r--r--drivers/uwb/uwb-debug.c9
-rw-r--r--drivers/video/backlight/Kconfig6
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/da9052_bl.c187
-rw-r--r--drivers/video/backlight/locomolcd.c9
-rw-r--r--drivers/xen/swiotlb-xen.c5
-rw-r--r--drivers/xen/xen-pciback/pciback_ops.c2
224 files changed, 4250 insertions, 1634 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 6f0459cb745b..d236aef7e59f 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -50,6 +50,8 @@ source "drivers/i2c/Kconfig"
50 50
51source "drivers/spi/Kconfig" 51source "drivers/spi/Kconfig"
52 52
53source "drivers/hsi/Kconfig"
54
53source "drivers/pps/Kconfig" 55source "drivers/pps/Kconfig"
54 56
55source "drivers/ptp/Kconfig" 57source "drivers/ptp/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 262b19d6b627..95952c82bf16 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_ATA) += ata/
53obj-$(CONFIG_TARGET_CORE) += target/ 53obj-$(CONFIG_TARGET_CORE) += target/
54obj-$(CONFIG_MTD) += mtd/ 54obj-$(CONFIG_MTD) += mtd/
55obj-$(CONFIG_SPI) += spi/ 55obj-$(CONFIG_SPI) += spi/
56obj-y += hsi/
56obj-y += net/ 57obj-y += net/
57obj-$(CONFIG_ATM) += atm/ 58obj-$(CONFIG_ATM) += atm/
58obj-$(CONFIG_FUSION) += message/ 59obj-$(CONFIG_FUSION) += message/
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index b258cab9061c..7586544fddb4 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -27,12 +27,6 @@ MODULE_PARM_DESC(write_support, "Dangerous, reboot and removal of battery may "
27 27
28static struct dentry *acpi_ec_debugfs_dir; 28static struct dentry *acpi_ec_debugfs_dir;
29 29
30static int acpi_ec_open_io(struct inode *i, struct file *f)
31{
32 f->private_data = i->i_private;
33 return 0;
34}
35
36static ssize_t acpi_ec_read_io(struct file *f, char __user *buf, 30static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
37 size_t count, loff_t *off) 31 size_t count, loff_t *off)
38{ 32{
@@ -95,7 +89,7 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
95 89
96static const struct file_operations acpi_ec_io_ops = { 90static const struct file_operations acpi_ec_io_ops = {
97 .owner = THIS_MODULE, 91 .owner = THIS_MODULE,
98 .open = acpi_ec_open_io, 92 .open = simple_open,
99 .read = acpi_ec_read_io, 93 .read = acpi_ec_read_io,
100 .write = acpi_ec_write_io, 94 .write = acpi_ec_write_io,
101 .llseek = default_llseek, 95 .llseek = default_llseek,
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 6c9387d646ec..5401814c874d 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -16,10 +16,11 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/bitops.h> 17#include <linux/bitops.h>
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19#include <linux/kthread.h> 19#include <linux/workqueue.h>
20#include <linux/highmem.h> 20#include <linux/highmem.h>
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/sched.h>
23 24
24#define to_dev(obj) container_of(obj, struct device, kobj) 25#define to_dev(obj) container_of(obj, struct device, kobj)
25 26
@@ -81,6 +82,11 @@ enum {
81 82
82static int loading_timeout = 60; /* In seconds */ 83static int loading_timeout = 60; /* In seconds */
83 84
85static inline long firmware_loading_timeout(void)
86{
87 return loading_timeout > 0 ? loading_timeout * HZ : MAX_SCHEDULE_TIMEOUT;
88}
89
84/* fw_lock could be moved to 'struct firmware_priv' but since it is just 90/* fw_lock could be moved to 'struct firmware_priv' but since it is just
85 * guarding for corner cases a global lock should be OK */ 91 * guarding for corner cases a global lock should be OK */
86static DEFINE_MUTEX(fw_lock); 92static DEFINE_MUTEX(fw_lock);
@@ -440,13 +446,11 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,
440{ 446{
441 struct firmware_priv *fw_priv; 447 struct firmware_priv *fw_priv;
442 struct device *f_dev; 448 struct device *f_dev;
443 int error;
444 449
445 fw_priv = kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); 450 fw_priv = kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL);
446 if (!fw_priv) { 451 if (!fw_priv) {
447 dev_err(device, "%s: kmalloc failed\n", __func__); 452 dev_err(device, "%s: kmalloc failed\n", __func__);
448 error = -ENOMEM; 453 return ERR_PTR(-ENOMEM);
449 goto err_out;
450 } 454 }
451 455
452 fw_priv->fw = firmware; 456 fw_priv->fw = firmware;
@@ -463,98 +467,80 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,
463 f_dev->parent = device; 467 f_dev->parent = device;
464 f_dev->class = &firmware_class; 468 f_dev->class = &firmware_class;
465 469
466 dev_set_uevent_suppress(f_dev, true);
467
468 /* Need to pin this module until class device is destroyed */
469 __module_get(THIS_MODULE);
470
471 error = device_add(f_dev);
472 if (error) {
473 dev_err(device, "%s: device_register failed\n", __func__);
474 goto err_put_dev;
475 }
476
477 error = device_create_bin_file(f_dev, &firmware_attr_data);
478 if (error) {
479 dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__);
480 goto err_del_dev;
481 }
482
483 error = device_create_file(f_dev, &dev_attr_loading);
484 if (error) {
485 dev_err(device, "%s: device_create_file failed\n", __func__);
486 goto err_del_bin_attr;
487 }
488
489 if (uevent)
490 dev_set_uevent_suppress(f_dev, false);
491
492 return fw_priv; 470 return fw_priv;
493
494err_del_bin_attr:
495 device_remove_bin_file(f_dev, &firmware_attr_data);
496err_del_dev:
497 device_del(f_dev);
498err_put_dev:
499 put_device(f_dev);
500err_out:
501 return ERR_PTR(error);
502} 471}
503 472
504static void fw_destroy_instance(struct firmware_priv *fw_priv) 473static struct firmware_priv *
505{ 474_request_firmware_prepare(const struct firmware **firmware_p, const char *name,
506 struct device *f_dev = &fw_priv->dev; 475 struct device *device, bool uevent, bool nowait)
507
508 device_remove_file(f_dev, &dev_attr_loading);
509 device_remove_bin_file(f_dev, &firmware_attr_data);
510 device_unregister(f_dev);
511}
512
513static int _request_firmware(const struct firmware **firmware_p,
514 const char *name, struct device *device,
515 bool uevent, bool nowait)
516{ 476{
517 struct firmware_priv *fw_priv;
518 struct firmware *firmware; 477 struct firmware *firmware;
519 int retval = 0; 478 struct firmware_priv *fw_priv;
520 479
521 if (!firmware_p) 480 if (!firmware_p)
522 return -EINVAL; 481 return ERR_PTR(-EINVAL);
523 482
524 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); 483 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
525 if (!firmware) { 484 if (!firmware) {
526 dev_err(device, "%s: kmalloc(struct firmware) failed\n", 485 dev_err(device, "%s: kmalloc(struct firmware) failed\n",
527 __func__); 486 __func__);
528 return -ENOMEM; 487 return ERR_PTR(-ENOMEM);
529 } 488 }
530 489
531 if (fw_get_builtin_firmware(firmware, name)) { 490 if (fw_get_builtin_firmware(firmware, name)) {
532 dev_dbg(device, "firmware: using built-in firmware %s\n", name); 491 dev_dbg(device, "firmware: using built-in firmware %s\n", name);
533 return 0; 492 return NULL;
493 }
494
495 fw_priv = fw_create_instance(firmware, name, device, uevent, nowait);
496 if (IS_ERR(fw_priv)) {
497 release_firmware(firmware);
498 *firmware_p = NULL;
534 } 499 }
500 return fw_priv;
501}
535 502
536 read_lock_usermodehelper(); 503static void _request_firmware_cleanup(const struct firmware **firmware_p)
504{
505 release_firmware(*firmware_p);
506 *firmware_p = NULL;
507}
537 508
538 if (WARN_ON(usermodehelper_is_disabled())) { 509static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
539 dev_err(device, "firmware: %s will not be loaded\n", name); 510 long timeout)
540 retval = -EBUSY; 511{
541 goto out; 512 int retval = 0;
513 struct device *f_dev = &fw_priv->dev;
514
515 dev_set_uevent_suppress(f_dev, true);
516
517 /* Need to pin this module until class device is destroyed */
518 __module_get(THIS_MODULE);
519
520 retval = device_add(f_dev);
521 if (retval) {
522 dev_err(f_dev, "%s: device_register failed\n", __func__);
523 goto err_put_dev;
542 } 524 }
543 525
544 if (uevent) 526 retval = device_create_bin_file(f_dev, &firmware_attr_data);
545 dev_dbg(device, "firmware: requesting %s\n", name); 527 if (retval) {
528 dev_err(f_dev, "%s: sysfs_create_bin_file failed\n", __func__);
529 goto err_del_dev;
530 }
546 531
547 fw_priv = fw_create_instance(firmware, name, device, uevent, nowait); 532 retval = device_create_file(f_dev, &dev_attr_loading);
548 if (IS_ERR(fw_priv)) { 533 if (retval) {
549 retval = PTR_ERR(fw_priv); 534 dev_err(f_dev, "%s: device_create_file failed\n", __func__);
550 goto out; 535 goto err_del_bin_attr;
551 } 536 }
552 537
553 if (uevent) { 538 if (uevent) {
554 if (loading_timeout > 0) 539 dev_set_uevent_suppress(f_dev, false);
540 dev_dbg(f_dev, "firmware: requesting %s\n", fw_priv->fw_id);
541 if (timeout != MAX_SCHEDULE_TIMEOUT)
555 mod_timer(&fw_priv->timeout, 542 mod_timer(&fw_priv->timeout,
556 round_jiffies_up(jiffies + 543 round_jiffies_up(jiffies + timeout));
557 loading_timeout * HZ));
558 544
559 kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD); 545 kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD);
560 } 546 }
@@ -570,16 +556,13 @@ static int _request_firmware(const struct firmware **firmware_p,
570 fw_priv->fw = NULL; 556 fw_priv->fw = NULL;
571 mutex_unlock(&fw_lock); 557 mutex_unlock(&fw_lock);
572 558
573 fw_destroy_instance(fw_priv); 559 device_remove_file(f_dev, &dev_attr_loading);
574 560err_del_bin_attr:
575out: 561 device_remove_bin_file(f_dev, &firmware_attr_data);
576 read_unlock_usermodehelper(); 562err_del_dev:
577 563 device_del(f_dev);
578 if (retval) { 564err_put_dev:
579 release_firmware(firmware); 565 put_device(f_dev);
580 *firmware_p = NULL;
581 }
582
583 return retval; 566 return retval;
584} 567}
585 568
@@ -602,7 +585,26 @@ int
602request_firmware(const struct firmware **firmware_p, const char *name, 585request_firmware(const struct firmware **firmware_p, const char *name,
603 struct device *device) 586 struct device *device)
604{ 587{
605 return _request_firmware(firmware_p, name, device, true, false); 588 struct firmware_priv *fw_priv;
589 int ret;
590
591 fw_priv = _request_firmware_prepare(firmware_p, name, device, true,
592 false);
593 if (IS_ERR_OR_NULL(fw_priv))
594 return PTR_RET(fw_priv);
595
596 ret = usermodehelper_read_trylock();
597 if (WARN_ON(ret)) {
598 dev_err(device, "firmware: %s will not be loaded\n", name);
599 } else {
600 ret = _request_firmware_load(fw_priv, true,
601 firmware_loading_timeout());
602 usermodehelper_read_unlock();
603 }
604 if (ret)
605 _request_firmware_cleanup(firmware_p);
606
607 return ret;
606} 608}
607 609
608/** 610/**
@@ -629,25 +631,39 @@ struct firmware_work {
629 bool uevent; 631 bool uevent;
630}; 632};
631 633
632static int request_firmware_work_func(void *arg) 634static void request_firmware_work_func(struct work_struct *work)
633{ 635{
634 struct firmware_work *fw_work = arg; 636 struct firmware_work *fw_work;
635 const struct firmware *fw; 637 const struct firmware *fw;
638 struct firmware_priv *fw_priv;
639 long timeout;
636 int ret; 640 int ret;
637 641
638 if (!arg) { 642 fw_work = container_of(work, struct firmware_work, work);
639 WARN_ON(1); 643 fw_priv = _request_firmware_prepare(&fw, fw_work->name, fw_work->device,
640 return 0; 644 fw_work->uevent, true);
645 if (IS_ERR_OR_NULL(fw_priv)) {
646 ret = PTR_RET(fw_priv);
647 goto out;
648 }
649
650 timeout = usermodehelper_read_lock_wait(firmware_loading_timeout());
651 if (timeout) {
652 ret = _request_firmware_load(fw_priv, fw_work->uevent, timeout);
653 usermodehelper_read_unlock();
654 } else {
655 dev_dbg(fw_work->device, "firmware: %s loading timed out\n",
656 fw_work->name);
657 ret = -EAGAIN;
641 } 658 }
659 if (ret)
660 _request_firmware_cleanup(&fw);
642 661
643 ret = _request_firmware(&fw, fw_work->name, fw_work->device, 662 out:
644 fw_work->uevent, true);
645 fw_work->cont(fw, fw_work->context); 663 fw_work->cont(fw, fw_work->context);
646 664
647 module_put(fw_work->module); 665 module_put(fw_work->module);
648 kfree(fw_work); 666 kfree(fw_work);
649
650 return ret;
651} 667}
652 668
653/** 669/**
@@ -673,7 +689,6 @@ request_firmware_nowait(
673 const char *name, struct device *device, gfp_t gfp, void *context, 689 const char *name, struct device *device, gfp_t gfp, void *context,
674 void (*cont)(const struct firmware *fw, void *context)) 690 void (*cont)(const struct firmware *fw, void *context))
675{ 691{
676 struct task_struct *task;
677 struct firmware_work *fw_work; 692 struct firmware_work *fw_work;
678 693
679 fw_work = kzalloc(sizeof (struct firmware_work), gfp); 694 fw_work = kzalloc(sizeof (struct firmware_work), gfp);
@@ -692,15 +707,8 @@ request_firmware_nowait(
692 return -EFAULT; 707 return -EFAULT;
693 } 708 }
694 709
695 task = kthread_run(request_firmware_work_func, fw_work, 710 INIT_WORK(&fw_work->work, request_firmware_work_func);
696 "firmware/%s", name); 711 schedule_work(&fw_work->work);
697 if (IS_ERR(task)) {
698 fw_work->cont(NULL, fw_work->context);
699 module_put(fw_work->module);
700 kfree(fw_work);
701 return PTR_ERR(task);
702 }
703
704 return 0; 712 return 0;
705} 713}
706 714
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 541f821d4ea6..bd0f3949bcf9 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -532,6 +532,8 @@ static int rpm_suspend(struct device *dev, int rpmflags)
532 dev->power.suspend_time = ktime_set(0, 0); 532 dev->power.suspend_time = ktime_set(0, 0);
533 dev->power.max_time_suspended_ns = -1; 533 dev->power.max_time_suspended_ns = -1;
534 dev->power.deferred_resume = false; 534 dev->power.deferred_resume = false;
535 wake_up_all(&dev->power.wait_queue);
536
535 if (retval == -EAGAIN || retval == -EBUSY) { 537 if (retval == -EAGAIN || retval == -EBUSY) {
536 dev->power.runtime_error = 0; 538 dev->power.runtime_error = 0;
537 539
@@ -547,7 +549,6 @@ static int rpm_suspend(struct device *dev, int rpmflags)
547 } else { 549 } else {
548 pm_runtime_cancel_pending(dev); 550 pm_runtime_cancel_pending(dev);
549 } 551 }
550 wake_up_all(&dev->power.wait_queue);
551 goto out; 552 goto out;
552} 553}
553 554
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index 5157fa04c2f0..fb14a6343d4f 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -396,7 +396,7 @@ static int regcache_rbtree_sync(struct regmap *map, unsigned int min,
396 map->cache_word_size); 396 map->cache_word_size);
397 397
398 /* Is this the hardware default? If so skip. */ 398 /* Is this the hardware default? If so skip. */
399 ret = regcache_lookup_reg(map, i); 399 ret = regcache_lookup_reg(map, regtmp);
400 if (ret >= 0 && val == map->reg_defaults[ret].def) 400 if (ret >= 0 && val == map->reg_defaults[ret].def)
401 continue; 401 continue;
402 402
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 58517a5dac13..251eb70f83e7 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -27,12 +27,6 @@ static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
27 return strlen(buf); 27 return strlen(buf);
28} 28}
29 29
30static int regmap_open_file(struct inode *inode, struct file *file)
31{
32 file->private_data = inode->i_private;
33 return 0;
34}
35
36static ssize_t regmap_name_read_file(struct file *file, 30static ssize_t regmap_name_read_file(struct file *file,
37 char __user *user_buf, size_t count, 31 char __user *user_buf, size_t count,
38 loff_t *ppos) 32 loff_t *ppos)
@@ -57,7 +51,7 @@ static ssize_t regmap_name_read_file(struct file *file,
57} 51}
58 52
59static const struct file_operations regmap_name_fops = { 53static const struct file_operations regmap_name_fops = {
60 .open = regmap_open_file, 54 .open = simple_open,
61 .read = regmap_name_read_file, 55 .read = regmap_name_read_file,
62 .llseek = default_llseek, 56 .llseek = default_llseek,
63}; 57};
@@ -174,7 +168,7 @@ static ssize_t regmap_map_write_file(struct file *file,
174#endif 168#endif
175 169
176static const struct file_operations regmap_map_fops = { 170static const struct file_operations regmap_map_fops = {
177 .open = regmap_open_file, 171 .open = simple_open,
178 .read = regmap_map_read_file, 172 .read = regmap_map_read_file,
179 .write = regmap_map_write_file, 173 .write = regmap_map_write_file,
180 .llseek = default_llseek, 174 .llseek = default_llseek,
@@ -243,7 +237,7 @@ out:
243} 237}
244 238
245static const struct file_operations regmap_access_fops = { 239static const struct file_operations regmap_access_fops = {
246 .open = regmap_open_file, 240 .open = simple_open,
247 .read = regmap_access_read_file, 241 .read = regmap_access_read_file,
248 .llseek = default_llseek, 242 .llseek = default_llseek,
249}; 243};
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 76a08236430a..b0b00d70c166 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -1030,37 +1030,6 @@ static int fd_wait_for_completion(unsigned long delay, timeout_fn function)
1030 return 0; 1030 return 0;
1031} 1031}
1032 1032
1033static DEFINE_SPINLOCK(floppy_hlt_lock);
1034static int hlt_disabled;
1035static void floppy_disable_hlt(void)
1036{
1037 unsigned long flags;
1038
1039 WARN_ONCE(1, "floppy_disable_hlt() scheduled for removal in 2012");
1040 spin_lock_irqsave(&floppy_hlt_lock, flags);
1041 if (!hlt_disabled) {
1042 hlt_disabled = 1;
1043#ifdef HAVE_DISABLE_HLT
1044 disable_hlt();
1045#endif
1046 }
1047 spin_unlock_irqrestore(&floppy_hlt_lock, flags);
1048}
1049
1050static void floppy_enable_hlt(void)
1051{
1052 unsigned long flags;
1053
1054 spin_lock_irqsave(&floppy_hlt_lock, flags);
1055 if (hlt_disabled) {
1056 hlt_disabled = 0;
1057#ifdef HAVE_DISABLE_HLT
1058 enable_hlt();
1059#endif
1060 }
1061 spin_unlock_irqrestore(&floppy_hlt_lock, flags);
1062}
1063
1064static void setup_DMA(void) 1033static void setup_DMA(void)
1065{ 1034{
1066 unsigned long f; 1035 unsigned long f;
@@ -1105,7 +1074,6 @@ static void setup_DMA(void)
1105 fd_enable_dma(); 1074 fd_enable_dma();
1106 release_dma_lock(f); 1075 release_dma_lock(f);
1107#endif 1076#endif
1108 floppy_disable_hlt();
1109} 1077}
1110 1078
1111static void show_floppy(void); 1079static void show_floppy(void);
@@ -1707,7 +1675,6 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id)
1707 fd_disable_dma(); 1675 fd_disable_dma();
1708 release_dma_lock(f); 1676 release_dma_lock(f);
1709 1677
1710 floppy_enable_hlt();
1711 do_floppy = NULL; 1678 do_floppy = NULL;
1712 if (fdc >= N_FDC || FDCS->address == -1) { 1679 if (fdc >= N_FDC || FDCS->address == -1) {
1713 /* we don't even know which FDC is the culprit */ 1680 /* we don't even know which FDC is the culprit */
@@ -1856,8 +1823,6 @@ static void floppy_shutdown(unsigned long data)
1856 show_floppy(); 1823 show_floppy();
1857 cancel_activity(); 1824 cancel_activity();
1858 1825
1859 floppy_enable_hlt();
1860
1861 flags = claim_dma_lock(); 1826 flags = claim_dma_lock();
1862 fd_disable_dma(); 1827 fd_disable_dma();
1863 release_dma_lock(flags); 1828 release_dma_lock(flags);
@@ -4508,7 +4473,6 @@ static void floppy_release_irq_and_dma(void)
4508#if N_FDC > 1 4473#if N_FDC > 1
4509 set_dor(1, ~8, 0); 4474 set_dor(1, ~8, 0);
4510#endif 4475#endif
4511 floppy_enable_hlt();
4512 4476
4513 if (floppy_track_buffer && max_buffer_sectors) { 4477 if (floppy_track_buffer && max_buffer_sectors) {
4514 tmpsize = max_buffer_sectors * 1024; 4478 tmpsize = max_buffer_sectors * 1024;
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index d5e1ab956740..98cbeba8cd53 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -1475,7 +1475,7 @@ static int __init xlblk_init(void)
1475 if (!xen_domain()) 1475 if (!xen_domain())
1476 return -ENODEV; 1476 return -ENODEV;
1477 1477
1478 if (!xen_platform_pci_unplug) 1478 if (xen_hvm_domain() && !xen_platform_pci_unplug)
1479 return -ENODEV; 1479 return -ENODEV;
1480 1480
1481 if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) { 1481 if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) {
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index 6c20bbb54b71..428dbb7574bd 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -45,12 +45,6 @@ struct btmrvl_debugfs_data {
45 struct dentry *txdnldready; 45 struct dentry *txdnldready;
46}; 46};
47 47
48static int btmrvl_open_generic(struct inode *inode, struct file *file)
49{
50 file->private_data = inode->i_private;
51 return 0;
52}
53
54static ssize_t btmrvl_hscfgcmd_write(struct file *file, 48static ssize_t btmrvl_hscfgcmd_write(struct file *file,
55 const char __user *ubuf, size_t count, loff_t *ppos) 49 const char __user *ubuf, size_t count, loff_t *ppos)
56{ 50{
@@ -93,7 +87,7 @@ static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf,
93static const struct file_operations btmrvl_hscfgcmd_fops = { 87static const struct file_operations btmrvl_hscfgcmd_fops = {
94 .read = btmrvl_hscfgcmd_read, 88 .read = btmrvl_hscfgcmd_read,
95 .write = btmrvl_hscfgcmd_write, 89 .write = btmrvl_hscfgcmd_write,
96 .open = btmrvl_open_generic, 90 .open = simple_open,
97 .llseek = default_llseek, 91 .llseek = default_llseek,
98}; 92};
99 93
@@ -134,7 +128,7 @@ static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf,
134static const struct file_operations btmrvl_psmode_fops = { 128static const struct file_operations btmrvl_psmode_fops = {
135 .read = btmrvl_psmode_read, 129 .read = btmrvl_psmode_read,
136 .write = btmrvl_psmode_write, 130 .write = btmrvl_psmode_write,
137 .open = btmrvl_open_generic, 131 .open = simple_open,
138 .llseek = default_llseek, 132 .llseek = default_llseek,
139}; 133};
140 134
@@ -180,7 +174,7 @@ static ssize_t btmrvl_pscmd_read(struct file *file, char __user *userbuf,
180static const struct file_operations btmrvl_pscmd_fops = { 174static const struct file_operations btmrvl_pscmd_fops = {
181 .read = btmrvl_pscmd_read, 175 .read = btmrvl_pscmd_read,
182 .write = btmrvl_pscmd_write, 176 .write = btmrvl_pscmd_write,
183 .open = btmrvl_open_generic, 177 .open = simple_open,
184 .llseek = default_llseek, 178 .llseek = default_llseek,
185}; 179};
186 180
@@ -221,7 +215,7 @@ static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf,
221static const struct file_operations btmrvl_gpiogap_fops = { 215static const struct file_operations btmrvl_gpiogap_fops = {
222 .read = btmrvl_gpiogap_read, 216 .read = btmrvl_gpiogap_read,
223 .write = btmrvl_gpiogap_write, 217 .write = btmrvl_gpiogap_write,
224 .open = btmrvl_open_generic, 218 .open = simple_open,
225 .llseek = default_llseek, 219 .llseek = default_llseek,
226}; 220};
227 221
@@ -265,7 +259,7 @@ static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf,
265static const struct file_operations btmrvl_hscmd_fops = { 259static const struct file_operations btmrvl_hscmd_fops = {
266 .read = btmrvl_hscmd_read, 260 .read = btmrvl_hscmd_read,
267 .write = btmrvl_hscmd_write, 261 .write = btmrvl_hscmd_write,
268 .open = btmrvl_open_generic, 262 .open = simple_open,
269 .llseek = default_llseek, 263 .llseek = default_llseek,
270}; 264};
271 265
@@ -305,7 +299,7 @@ static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf,
305static const struct file_operations btmrvl_hsmode_fops = { 299static const struct file_operations btmrvl_hsmode_fops = {
306 .read = btmrvl_hsmode_read, 300 .read = btmrvl_hsmode_read,
307 .write = btmrvl_hsmode_write, 301 .write = btmrvl_hsmode_write,
308 .open = btmrvl_open_generic, 302 .open = simple_open,
309 .llseek = default_llseek, 303 .llseek = default_llseek,
310}; 304};
311 305
@@ -323,7 +317,7 @@ static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
323 317
324static const struct file_operations btmrvl_curpsmode_fops = { 318static const struct file_operations btmrvl_curpsmode_fops = {
325 .read = btmrvl_curpsmode_read, 319 .read = btmrvl_curpsmode_read,
326 .open = btmrvl_open_generic, 320 .open = simple_open,
327 .llseek = default_llseek, 321 .llseek = default_llseek,
328}; 322};
329 323
@@ -341,7 +335,7 @@ static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
341 335
342static const struct file_operations btmrvl_psstate_fops = { 336static const struct file_operations btmrvl_psstate_fops = {
343 .read = btmrvl_psstate_read, 337 .read = btmrvl_psstate_read,
344 .open = btmrvl_open_generic, 338 .open = simple_open,
345 .llseek = default_llseek, 339 .llseek = default_llseek,
346}; 340};
347 341
@@ -359,7 +353,7 @@ static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
359 353
360static const struct file_operations btmrvl_hsstate_fops = { 354static const struct file_operations btmrvl_hsstate_fops = {
361 .read = btmrvl_hsstate_read, 355 .read = btmrvl_hsstate_read,
362 .open = btmrvl_open_generic, 356 .open = simple_open,
363 .llseek = default_llseek, 357 .llseek = default_llseek,
364}; 358};
365 359
@@ -378,7 +372,7 @@ static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
378 372
379static const struct file_operations btmrvl_txdnldready_fops = { 373static const struct file_operations btmrvl_txdnldready_fops = {
380 .read = btmrvl_txdnldready_read, 374 .read = btmrvl_txdnldready_read,
381 .open = btmrvl_open_generic, 375 .open = simple_open,
382 .llseek = default_llseek, 376 .llseek = default_llseek,
383}; 377};
384 378
diff --git a/drivers/char/agp/intel-agp.h b/drivers/char/agp/intel-agp.h
index 5da67f165afa..7ea18a5fe71c 100644
--- a/drivers/char/agp/intel-agp.h
+++ b/drivers/char/agp/intel-agp.h
@@ -234,6 +234,7 @@
234#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT2_IG 0x0166 234#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT2_IG 0x0166
235#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_HB 0x0158 /* Server */ 235#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_HB 0x0158 /* Server */
236#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG 0x015A 236#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG 0x015A
237#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT2_IG 0x016A
237 238
238int intel_gmch_probe(struct pci_dev *pdev, 239int intel_gmch_probe(struct pci_dev *pdev,
239 struct agp_bridge_data *bridge); 240 struct agp_bridge_data *bridge);
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 5cf47ac2d401..7f025fb620de 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -1190,7 +1190,6 @@ static inline int needs_idle_maps(void)
1190{ 1190{
1191#ifdef CONFIG_INTEL_IOMMU 1191#ifdef CONFIG_INTEL_IOMMU
1192 const unsigned short gpu_devid = intel_private.pcidev->device; 1192 const unsigned short gpu_devid = intel_private.pcidev->device;
1193 extern int intel_iommu_gfx_mapped;
1194 1193
1195 /* Query intel_iommu to see if we need the workaround. Presumably that 1194 /* Query intel_iommu to see if we need the workaround. Presumably that
1196 * was loaded first. 1195 * was loaded first.
@@ -1459,6 +1458,8 @@ static const struct intel_gtt_driver_description {
1459 "Ivybridge", &sandybridge_gtt_driver }, 1458 "Ivybridge", &sandybridge_gtt_driver },
1460 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG, 1459 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG,
1461 "Ivybridge", &sandybridge_gtt_driver }, 1460 "Ivybridge", &sandybridge_gtt_driver },
1461 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT2_IG,
1462 "Ivybridge", &sandybridge_gtt_driver },
1462 { 0, NULL, NULL } 1463 { 0, NULL, NULL }
1463}; 1464};
1464 1465
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 57501ca9204b..46118f845948 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -301,7 +301,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
301 * anything critical, chill a bit on each iteration. 301 * anything critical, chill a bit on each iteration.
302 */ 302 */
303 while (wait_event_freezable(apm_suspend_waitqueue, 303 while (wait_event_freezable(apm_suspend_waitqueue,
304 as->suspend_state == SUSPEND_DONE)) 304 as->suspend_state != SUSPEND_ACKED))
305 msleep(10); 305 msleep(10);
306 break; 306 break;
307 case SUSPEND_ACKTO: 307 case SUSPEND_ACKTO:
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index 4dc019408fac..3b22a606f79d 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -194,17 +194,17 @@ static ssize_t srom_read(struct file *filp, char __user *buf,
194 194
195 hv_retval = _srom_read(srom->hv_devhdl, kernbuf, 195 hv_retval = _srom_read(srom->hv_devhdl, kernbuf,
196 *f_pos, bytes_this_pass); 196 *f_pos, bytes_this_pass);
197 if (hv_retval > 0) { 197 if (hv_retval <= 0) {
198 if (copy_to_user(buf, kernbuf, hv_retval) != 0) {
199 retval = -EFAULT;
200 break;
201 }
202 } else if (hv_retval <= 0) {
203 if (retval == 0) 198 if (retval == 0)
204 retval = hv_retval; 199 retval = hv_retval;
205 break; 200 break;
206 } 201 }
207 202
203 if (copy_to_user(buf, kernbuf, hv_retval) != 0) {
204 retval = -EFAULT;
205 break;
206 }
207
208 retval += hv_retval; 208 retval += hv_retval;
209 *f_pos += hv_retval; 209 *f_pos += hv_retval;
210 buf += hv_retval; 210 buf += hv_retval;
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index b58b56187065..ddf86b6500b7 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1038,12 +1038,6 @@ static struct attribute_group port_attribute_group = {
1038 .attrs = port_sysfs_entries, 1038 .attrs = port_sysfs_entries,
1039}; 1039};
1040 1040
1041static int debugfs_open(struct inode *inode, struct file *filp)
1042{
1043 filp->private_data = inode->i_private;
1044 return 0;
1045}
1046
1047static ssize_t debugfs_read(struct file *filp, char __user *ubuf, 1041static ssize_t debugfs_read(struct file *filp, char __user *ubuf,
1048 size_t count, loff_t *offp) 1042 size_t count, loff_t *offp)
1049{ 1043{
@@ -1087,7 +1081,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf,
1087 1081
1088static const struct file_operations port_debugfs_ops = { 1082static const struct file_operations port_debugfs_ops = {
1089 .owner = THIS_MODULE, 1083 .owner = THIS_MODULE,
1090 .open = debugfs_open, 1084 .open = simple_open,
1091 .read = debugfs_read, 1085 .read = debugfs_read,
1092}; 1086};
1093 1087
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 32d790dd8180..ffbb44685915 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -51,9 +51,6 @@ config ARM_S5PV210_CPUFREQ
51config ARM_EXYNOS_CPUFREQ 51config ARM_EXYNOS_CPUFREQ
52 bool "SAMSUNG EXYNOS SoCs" 52 bool "SAMSUNG EXYNOS SoCs"
53 depends on ARCH_EXYNOS 53 depends on ARCH_EXYNOS
54 select ARM_EXYNOS4210_CPUFREQ if CPU_EXYNOS4210
55 select ARM_EXYNOS4X12_CPUFREQ if (SOC_EXYNOS4212 || SOC_EXYNOS4412)
56 select ARM_EXYNOS5250_CPUFREQ if SOC_EXYNOS5250
57 default y 54 default y
58 help 55 help
59 This adds the CPUFreq driver common part for Samsung 56 This adds the CPUFreq driver common part for Samsung
@@ -62,20 +59,19 @@ config ARM_EXYNOS_CPUFREQ
62 If in doubt, say N. 59 If in doubt, say N.
63 60
64config ARM_EXYNOS4210_CPUFREQ 61config ARM_EXYNOS4210_CPUFREQ
65 bool "Samsung EXYNOS4210" 62 def_bool CPU_EXYNOS4210
66 depends on ARCH_EXYNOS
67 help 63 help
68 This adds the CPUFreq driver for Samsung EXYNOS4210 64 This adds the CPUFreq driver for Samsung EXYNOS4210
69 SoC (S5PV310 or S5PC210). 65 SoC (S5PV310 or S5PC210).
70 66
71config ARM_EXYNOS4X12_CPUFREQ 67config ARM_EXYNOS4X12_CPUFREQ
72 bool "Samsung EXYNOS4X12" 68 def_bool (SOC_EXYNOS4212 || SOC_EXYNOS4412)
73 help 69 help
74 This adds the CPUFreq driver for Samsung EXYNOS4X12 70 This adds the CPUFreq driver for Samsung EXYNOS4X12
75 SoC (EXYNOS4212 or EXYNOS4412). 71 SoC (EXYNOS4212 or EXYNOS4412).
76 72
77config ARM_EXYNOS5250_CPUFREQ 73config ARM_EXYNOS5250_CPUFREQ
78 bool "Samsung EXYNOS5250" 74 def_bool SOC_EXYNOS5250
79 help 75 help
80 This adds the CPUFreq driver for Samsung EXYNOS5250 76 This adds the CPUFreq driver for Samsung EXYNOS5250
81 SoC. 77 SoC.
diff --git a/drivers/cpufreq/db8500-cpufreq.c b/drivers/cpufreq/db8500-cpufreq.c
index a22ffa5bff9f..0bf1b8910eeb 100644
--- a/drivers/cpufreq/db8500-cpufreq.c
+++ b/drivers/cpufreq/db8500-cpufreq.c
@@ -142,7 +142,7 @@ static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy)
142 policy->cpuinfo.transition_latency = 20 * 1000; /* in ns */ 142 policy->cpuinfo.transition_latency = 20 * 1000; /* in ns */
143 143
144 /* policy sharing between dual CPUs */ 144 /* policy sharing between dual CPUs */
145 cpumask_copy(policy->cpus, &cpu_present_map); 145 cpumask_copy(policy->cpus, cpu_present_mask);
146 146
147 policy->shared_type = CPUFREQ_SHARED_TYPE_ALL; 147 policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
148 148
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index dc89455f5550..750925f9638b 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -104,13 +104,6 @@ static void coh901318_list_print(struct coh901318_chan *cohc,
104static struct coh901318_base *debugfs_dma_base; 104static struct coh901318_base *debugfs_dma_base;
105static struct dentry *dma_dentry; 105static struct dentry *dma_dentry;
106 106
107static int coh901318_debugfs_open(struct inode *inode, struct file *file)
108{
109
110 file->private_data = inode->i_private;
111 return 0;
112}
113
114static int coh901318_debugfs_read(struct file *file, char __user *buf, 107static int coh901318_debugfs_read(struct file *file, char __user *buf,
115 size_t count, loff_t *f_pos) 108 size_t count, loff_t *f_pos)
116{ 109{
@@ -158,7 +151,7 @@ static int coh901318_debugfs_read(struct file *file, char __user *buf,
158 151
159static const struct file_operations coh901318_debugfs_status_operations = { 152static const struct file_operations coh901318_debugfs_status_operations = {
160 .owner = THIS_MODULE, 153 .owner = THIS_MODULE,
161 .open = coh901318_debugfs_open, 154 .open = simple_open,
162 .read = coh901318_debugfs_read, 155 .read = coh901318_debugfs_read,
163 .llseek = default_llseek, 156 .llseek = default_llseek,
164}; 157};
diff --git a/drivers/dma/sa11x0-dma.c b/drivers/dma/sa11x0-dma.c
index 16a6b48883cf..ec78ccef9132 100644
--- a/drivers/dma/sa11x0-dma.c
+++ b/drivers/dma/sa11x0-dma.c
@@ -585,7 +585,7 @@ static dma_cookie_t sa11x0_dma_tx_submit(struct dma_async_tx_descriptor *tx)
585 585
586static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg( 586static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(
587 struct dma_chan *chan, struct scatterlist *sg, unsigned int sglen, 587 struct dma_chan *chan, struct scatterlist *sg, unsigned int sglen,
588 enum dma_transfer_direction dir, unsigned long flags) 588 enum dma_transfer_direction dir, unsigned long flags, void *context)
589{ 589{
590 struct sa11x0_dma_chan *c = to_sa11x0_dma_chan(chan); 590 struct sa11x0_dma_chan *c = to_sa11x0_dma_chan(chan);
591 struct sa11x0_dma_desc *txd; 591 struct sa11x0_dma_desc *txd;
diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c
index 36e1486eb9aa..d0c372e30de4 100644
--- a/drivers/edac/mce_amd.c
+++ b/drivers/edac/mce_amd.c
@@ -754,9 +754,7 @@ static int __init mce_amd_init(void)
754 if (c->x86_vendor != X86_VENDOR_AMD) 754 if (c->x86_vendor != X86_VENDOR_AMD)
755 return 0; 755 return 0;
756 756
757 if ((c->x86 < 0xf || c->x86 > 0x12) && 757 if (c->x86 < 0xf || c->x86 > 0x15)
758 (c->x86 != 0x14 || c->x86_model > 0xf) &&
759 (c->x86 != 0x15 || c->x86_model > 0xf))
760 return 0; 758 return 0;
761 759
762 fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL); 760 fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL);
@@ -797,7 +795,7 @@ static int __init mce_amd_init(void)
797 break; 795 break;
798 796
799 default: 797 default:
800 printk(KERN_WARNING "Huh? What family is that: %d?!\n", c->x86); 798 printk(KERN_WARNING "Huh? What family is it: 0x%x?!\n", c->x86);
801 kfree(fam_ops); 799 kfree(fam_ops);
802 return -EINVAL; 800 return -EINVAL;
803 } 801 }
diff --git a/drivers/edac/tile_edac.c b/drivers/edac/tile_edac.c
index 1d5cf06f6c6b..e99d00976189 100644
--- a/drivers/edac/tile_edac.c
+++ b/drivers/edac/tile_edac.c
@@ -145,7 +145,11 @@ static int __devinit tile_edac_mc_probe(struct platform_device *pdev)
145 mci->edac_ctl_cap = EDAC_FLAG_SECDED; 145 mci->edac_ctl_cap = EDAC_FLAG_SECDED;
146 146
147 mci->mod_name = DRV_NAME; 147 mci->mod_name = DRV_NAME;
148#ifdef __tilegx__
149 mci->ctl_name = "TILEGx_Memory_Controller";
150#else
148 mci->ctl_name = "TILEPro_Memory_Controller"; 151 mci->ctl_name = "TILEPro_Memory_Controller";
152#endif
149 mci->dev_name = dev_name(&pdev->dev); 153 mci->dev_name = dev_name(&pdev->dev);
150 mci->edac_check = tile_edac_check; 154 mci->edac_check = tile_edac_check;
151 155
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 32de6707e3c4..12f349b3830d 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -22,7 +22,7 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/of.h> 25#include <linux/of_device.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/irqdomain.h> 28#include <linux/irqdomain.h>
@@ -37,7 +37,8 @@
37#define GPIO_PORT(x) (((x) >> 3) & 0x3) 37#define GPIO_PORT(x) (((x) >> 3) & 0x3)
38#define GPIO_BIT(x) ((x) & 0x7) 38#define GPIO_BIT(x) ((x) & 0x7)
39 39
40#define GPIO_REG(x) (GPIO_BANK(x) * 0x80 + GPIO_PORT(x) * 4) 40#define GPIO_REG(x) (GPIO_BANK(x) * tegra_gpio_bank_stride + \
41 GPIO_PORT(x) * 4)
41 42
42#define GPIO_CNF(x) (GPIO_REG(x) + 0x00) 43#define GPIO_CNF(x) (GPIO_REG(x) + 0x00)
43#define GPIO_OE(x) (GPIO_REG(x) + 0x10) 44#define GPIO_OE(x) (GPIO_REG(x) + 0x10)
@@ -48,12 +49,12 @@
48#define GPIO_INT_LVL(x) (GPIO_REG(x) + 0x60) 49#define GPIO_INT_LVL(x) (GPIO_REG(x) + 0x60)
49#define GPIO_INT_CLR(x) (GPIO_REG(x) + 0x70) 50#define GPIO_INT_CLR(x) (GPIO_REG(x) + 0x70)
50 51
51#define GPIO_MSK_CNF(x) (GPIO_REG(x) + 0x800) 52#define GPIO_MSK_CNF(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x00)
52#define GPIO_MSK_OE(x) (GPIO_REG(x) + 0x810) 53#define GPIO_MSK_OE(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x10)
53#define GPIO_MSK_OUT(x) (GPIO_REG(x) + 0X820) 54#define GPIO_MSK_OUT(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0X20)
54#define GPIO_MSK_INT_STA(x) (GPIO_REG(x) + 0x840) 55#define GPIO_MSK_INT_STA(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x40)
55#define GPIO_MSK_INT_ENB(x) (GPIO_REG(x) + 0x850) 56#define GPIO_MSK_INT_ENB(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x50)
56#define GPIO_MSK_INT_LVL(x) (GPIO_REG(x) + 0x860) 57#define GPIO_MSK_INT_LVL(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x60)
57 58
58#define GPIO_INT_LVL_MASK 0x010101 59#define GPIO_INT_LVL_MASK 0x010101
59#define GPIO_INT_LVL_EDGE_RISING 0x000101 60#define GPIO_INT_LVL_EDGE_RISING 0x000101
@@ -78,6 +79,8 @@ struct tegra_gpio_bank {
78static struct irq_domain *irq_domain; 79static struct irq_domain *irq_domain;
79static void __iomem *regs; 80static void __iomem *regs;
80static u32 tegra_gpio_bank_count; 81static u32 tegra_gpio_bank_count;
82static u32 tegra_gpio_bank_stride;
83static u32 tegra_gpio_upper_offset;
81static struct tegra_gpio_bank *tegra_gpio_banks; 84static struct tegra_gpio_bank *tegra_gpio_banks;
82 85
83static inline void tegra_gpio_writel(u32 val, u32 reg) 86static inline void tegra_gpio_writel(u32 val, u32 reg)
@@ -333,6 +336,26 @@ static struct irq_chip tegra_gpio_irq_chip = {
333#endif 336#endif
334}; 337};
335 338
339struct tegra_gpio_soc_config {
340 u32 bank_stride;
341 u32 upper_offset;
342};
343
344static struct tegra_gpio_soc_config tegra20_gpio_config = {
345 .bank_stride = 0x80,
346 .upper_offset = 0x800,
347};
348
349static struct tegra_gpio_soc_config tegra30_gpio_config = {
350 .bank_stride = 0x100,
351 .upper_offset = 0x80,
352};
353
354static struct of_device_id tegra_gpio_of_match[] __devinitdata = {
355 { .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config },
356 { .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config },
357 { },
358};
336 359
337/* This lock class tells lockdep that GPIO irqs are in a different 360/* This lock class tells lockdep that GPIO irqs are in a different
338 * category than their parents, so it won't report false recursion. 361 * category than their parents, so it won't report false recursion.
@@ -341,6 +364,8 @@ static struct lock_class_key gpio_lock_class;
341 364
342static int __devinit tegra_gpio_probe(struct platform_device *pdev) 365static int __devinit tegra_gpio_probe(struct platform_device *pdev)
343{ 366{
367 const struct of_device_id *match;
368 struct tegra_gpio_soc_config *config;
344 int irq_base; 369 int irq_base;
345 struct resource *res; 370 struct resource *res;
346 struct tegra_gpio_bank *bank; 371 struct tegra_gpio_bank *bank;
@@ -348,6 +373,15 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev)
348 int i; 373 int i;
349 int j; 374 int j;
350 375
376 match = of_match_device(tegra_gpio_of_match, &pdev->dev);
377 if (match)
378 config = (struct tegra_gpio_soc_config *)match->data;
379 else
380 config = &tegra20_gpio_config;
381
382 tegra_gpio_bank_stride = config->bank_stride;
383 tegra_gpio_upper_offset = config->upper_offset;
384
351 for (;;) { 385 for (;;) {
352 res = platform_get_resource(pdev, IORESOURCE_IRQ, tegra_gpio_bank_count); 386 res = platform_get_resource(pdev, IORESOURCE_IRQ, tegra_gpio_bank_count);
353 if (!res) 387 if (!res)
@@ -402,7 +436,7 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev)
402 return -ENODEV; 436 return -ENODEV;
403 } 437 }
404 438
405 for (i = 0; i < 7; i++) { 439 for (i = 0; i < tegra_gpio_bank_count; i++) {
406 for (j = 0; j < 4; j++) { 440 for (j = 0; j < 4; j++) {
407 int gpio = tegra_gpio_compose(i, j, 0); 441 int gpio = tegra_gpio_compose(i, j, 0);
408 tegra_gpio_writel(0x00, GPIO_INT_ENB(gpio)); 442 tegra_gpio_writel(0x00, GPIO_INT_ENB(gpio));
@@ -441,11 +475,6 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev)
441 return 0; 475 return 0;
442} 476}
443 477
444static struct of_device_id tegra_gpio_of_match[] __devinitdata = {
445 { .compatible = "nvidia,tegra20-gpio", },
446 { },
447};
448
449static struct platform_driver tegra_gpio_driver = { 478static struct platform_driver tegra_gpio_driver = {
450 .driver = { 479 .driver = {
451 .name = "tegra-gpio", 480 .name = "tegra-gpio",
@@ -485,7 +514,7 @@ static int dbg_gpio_show(struct seq_file *s, void *unused)
485 int i; 514 int i;
486 int j; 515 int j;
487 516
488 for (i = 0; i < 7; i++) { 517 for (i = 0; i < tegra_gpio_bank_count; i++) {
489 for (j = 0; j < 4; j++) { 518 for (j = 0; j < 4; j++) {
490 int gpio = tegra_gpio_compose(i, j, 0); 519 int gpio = tegra_gpio_compose(i, j, 0);
491 seq_printf(s, 520 seq_printf(s,
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index cc1148837e24..e354bc0b052a 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -9,6 +9,7 @@ menuconfig DRM
9 depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && MMU 9 depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && MMU
10 select I2C 10 select I2C
11 select I2C_ALGOBIT 11 select I2C_ALGOBIT
12 select DMA_SHARED_BUFFER
12 help 13 help
13 Kernel-level support for the Direct Rendering Infrastructure (DRI) 14 Kernel-level support for the Direct Rendering Infrastructure (DRI)
14 introduced in XFree86 4.0. If you say Y here, you need to select 15 introduced in XFree86 4.0. If you say Y here, you need to select
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index a858532806ae..c20da5bda355 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -12,7 +12,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
12 drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \ 12 drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
13 drm_crtc.o drm_modes.o drm_edid.o \ 13 drm_crtc.o drm_modes.o drm_edid.o \
14 drm_info.o drm_debugfs.o drm_encoder_slave.o \ 14 drm_info.o drm_debugfs.o drm_encoder_slave.o \
15 drm_trace_points.o drm_global.o 15 drm_trace_points.o drm_global.o drm_prime.o
16 16
17drm-$(CONFIG_COMPAT) += drm_ioc32.o 17drm-$(CONFIG_COMPAT) += drm_ioc32.o
18 18
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 0b65fbc8a630..6116e3b75393 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -136,6 +136,10 @@ static struct drm_ioctl_desc drm_ioctls[] = {
136 DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH|DRM_UNLOCKED), 136 DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH|DRM_UNLOCKED),
137 137
138 DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_CONTROL_ALLOW|DRM_UNLOCKED), 138 DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
139
140 DRM_IOCTL_DEF(DRM_IOCTL_PRIME_HANDLE_TO_FD, drm_prime_handle_to_fd_ioctl, DRM_AUTH|DRM_UNLOCKED),
141 DRM_IOCTL_DEF(DRM_IOCTL_PRIME_FD_TO_HANDLE, drm_prime_fd_to_handle_ioctl, DRM_AUTH|DRM_UNLOCKED),
142
139 DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), 143 DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
140 DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_CONTROL_ALLOW|DRM_UNLOCKED), 144 DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
141 DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), 145 DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 7740dd26f007..a0d6e894d97c 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -559,9 +559,13 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
559 return -EINVAL; 559 return -EINVAL;
560 560
561 /* Need to resize the fb object !!! */ 561 /* Need to resize the fb object !!! */
562 if (var->bits_per_pixel > fb->bits_per_pixel || var->xres > fb->width || var->yres > fb->height) { 562 if (var->bits_per_pixel > fb->bits_per_pixel ||
563 var->xres > fb->width || var->yres > fb->height ||
564 var->xres_virtual > fb->width || var->yres_virtual > fb->height) {
563 DRM_DEBUG("fb userspace requested width/height/bpp is greater than current fb " 565 DRM_DEBUG("fb userspace requested width/height/bpp is greater than current fb "
564 "object %dx%d-%d > %dx%d-%d\n", var->xres, var->yres, var->bits_per_pixel, 566 "request %dx%d-%d (virtual %dx%d) > %dx%d-%d\n",
567 var->xres, var->yres, var->bits_per_pixel,
568 var->xres_virtual, var->yres_virtual,
565 fb->width, fb->height, fb->bits_per_pixel); 569 fb->width, fb->height, fb->bits_per_pixel);
566 return -EINVAL; 570 return -EINVAL;
567 } 571 }
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 7348a3dab250..cdfbf27b2b3c 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -271,6 +271,9 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
271 if (dev->driver->driver_features & DRIVER_GEM) 271 if (dev->driver->driver_features & DRIVER_GEM)
272 drm_gem_open(dev, priv); 272 drm_gem_open(dev, priv);
273 273
274 if (drm_core_check_feature(dev, DRIVER_PRIME))
275 drm_prime_init_file_private(&priv->prime);
276
274 if (dev->driver->open) { 277 if (dev->driver->open) {
275 ret = dev->driver->open(dev, priv); 278 ret = dev->driver->open(dev, priv);
276 if (ret < 0) 279 if (ret < 0)
@@ -571,6 +574,10 @@ int drm_release(struct inode *inode, struct file *filp)
571 574
572 if (dev->driver->postclose) 575 if (dev->driver->postclose)
573 dev->driver->postclose(dev, file_priv); 576 dev->driver->postclose(dev, file_priv);
577
578 if (drm_core_check_feature(dev, DRIVER_PRIME))
579 drm_prime_destroy_file_private(&file_priv->prime);
580
574 kfree(file_priv); 581 kfree(file_priv);
575 582
576 /* ======================================================== 583 /* ========================================================
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 0ef358e53245..83114b5e3cee 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -35,6 +35,7 @@
35#include <linux/mman.h> 35#include <linux/mman.h>
36#include <linux/pagemap.h> 36#include <linux/pagemap.h>
37#include <linux/shmem_fs.h> 37#include <linux/shmem_fs.h>
38#include <linux/dma-buf.h>
38#include "drmP.h" 39#include "drmP.h"
39 40
40/** @file drm_gem.c 41/** @file drm_gem.c
@@ -232,6 +233,10 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
232 idr_remove(&filp->object_idr, handle); 233 idr_remove(&filp->object_idr, handle);
233 spin_unlock(&filp->table_lock); 234 spin_unlock(&filp->table_lock);
234 235
236 if (obj->import_attach)
237 drm_prime_remove_imported_buf_handle(&filp->prime,
238 obj->import_attach->dmabuf);
239
235 if (dev->driver->gem_close_object) 240 if (dev->driver->gem_close_object)
236 dev->driver->gem_close_object(obj, filp); 241 dev->driver->gem_close_object(obj, filp);
237 drm_gem_object_handle_unreference_unlocked(obj); 242 drm_gem_object_handle_unreference_unlocked(obj);
@@ -527,6 +532,10 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
527 struct drm_gem_object *obj = ptr; 532 struct drm_gem_object *obj = ptr;
528 struct drm_device *dev = obj->dev; 533 struct drm_device *dev = obj->dev;
529 534
535 if (obj->import_attach)
536 drm_prime_remove_imported_buf_handle(&file_priv->prime,
537 obj->import_attach->dmabuf);
538
530 if (dev->driver->gem_close_object) 539 if (dev->driver->gem_close_object)
531 dev->driver->gem_close_object(obj, file_priv); 540 dev->driver->gem_close_object(obj, file_priv);
532 541
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
new file mode 100644
index 000000000000..1bdf2b54eaf6
--- /dev/null
+++ b/drivers/gpu/drm/drm_prime.c
@@ -0,0 +1,304 @@
1/*
2 * Copyright © 2012 Red Hat
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Dave Airlie <airlied@redhat.com>
25 * Rob Clark <rob.clark@linaro.org>
26 *
27 */
28
29#include <linux/export.h>
30#include <linux/dma-buf.h>
31#include "drmP.h"
32
33/*
34 * DMA-BUF/GEM Object references and lifetime overview:
35 *
36 * On the export the dma_buf holds a reference to the exporting GEM
37 * object. It takes this reference in handle_to_fd_ioctl, when it
38 * first calls .prime_export and stores the exporting GEM object in
39 * the dma_buf priv. This reference is released when the dma_buf
40 * object goes away in the driver .release function.
41 *
42 * On the import the importing GEM object holds a reference to the
43 * dma_buf (which in turn holds a ref to the exporting GEM object).
44 * It takes that reference in the fd_to_handle ioctl.
45 * It calls dma_buf_get, creates an attachment to it and stores the
46 * attachment in the GEM object. When this attachment is destroyed
47 * when the imported object is destroyed, we remove the attachment
48 * and drop the reference to the dma_buf.
49 *
50 * Thus the chain of references always flows in one direction
51 * (avoiding loops): importing_gem -> dmabuf -> exporting_gem
52 *
53 * Self-importing: if userspace is using PRIME as a replacement for flink
54 * then it will get a fd->handle request for a GEM object that it created.
55 * Drivers should detect this situation and return back the gem object
56 * from the dma-buf private.
57 */
58
59struct drm_prime_member {
60 struct list_head entry;
61 struct dma_buf *dma_buf;
62 uint32_t handle;
63};
64
65int drm_gem_prime_handle_to_fd(struct drm_device *dev,
66 struct drm_file *file_priv, uint32_t handle, uint32_t flags,
67 int *prime_fd)
68{
69 struct drm_gem_object *obj;
70 void *buf;
71
72 obj = drm_gem_object_lookup(dev, file_priv, handle);
73 if (!obj)
74 return -ENOENT;
75
76 mutex_lock(&file_priv->prime.lock);
77 /* re-export the original imported object */
78 if (obj->import_attach) {
79 get_dma_buf(obj->import_attach->dmabuf);
80 *prime_fd = dma_buf_fd(obj->import_attach->dmabuf, flags);
81 drm_gem_object_unreference_unlocked(obj);
82 mutex_unlock(&file_priv->prime.lock);
83 return 0;
84 }
85
86 if (obj->export_dma_buf) {
87 get_dma_buf(obj->export_dma_buf);
88 *prime_fd = dma_buf_fd(obj->export_dma_buf, flags);
89 drm_gem_object_unreference_unlocked(obj);
90 } else {
91 buf = dev->driver->gem_prime_export(dev, obj, flags);
92 if (IS_ERR(buf)) {
93 /* normally the created dma-buf takes ownership of the ref,
94 * but if that fails then drop the ref
95 */
96 drm_gem_object_unreference_unlocked(obj);
97 mutex_unlock(&file_priv->prime.lock);
98 return PTR_ERR(buf);
99 }
100 obj->export_dma_buf = buf;
101 *prime_fd = dma_buf_fd(buf, flags);
102 }
103 mutex_unlock(&file_priv->prime.lock);
104 return 0;
105}
106EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);
107
108int drm_gem_prime_fd_to_handle(struct drm_device *dev,
109 struct drm_file *file_priv, int prime_fd, uint32_t *handle)
110{
111 struct dma_buf *dma_buf;
112 struct drm_gem_object *obj;
113 int ret;
114
115 dma_buf = dma_buf_get(prime_fd);
116 if (IS_ERR(dma_buf))
117 return PTR_ERR(dma_buf);
118
119 mutex_lock(&file_priv->prime.lock);
120
121 ret = drm_prime_lookup_imported_buf_handle(&file_priv->prime,
122 dma_buf, handle);
123 if (!ret) {
124 ret = 0;
125 goto out_put;
126 }
127
128 /* never seen this one, need to import */
129 obj = dev->driver->gem_prime_import(dev, dma_buf);
130 if (IS_ERR(obj)) {
131 ret = PTR_ERR(obj);
132 goto out_put;
133 }
134
135 ret = drm_gem_handle_create(file_priv, obj, handle);
136 drm_gem_object_unreference_unlocked(obj);
137 if (ret)
138 goto out_put;
139
140 ret = drm_prime_add_imported_buf_handle(&file_priv->prime,
141 dma_buf, *handle);
142 if (ret)
143 goto fail;
144
145 mutex_unlock(&file_priv->prime.lock);
146 return 0;
147
148fail:
149 /* hmm, if driver attached, we are relying on the free-object path
150 * to detach.. which seems ok..
151 */
152 drm_gem_object_handle_unreference_unlocked(obj);
153out_put:
154 dma_buf_put(dma_buf);
155 mutex_unlock(&file_priv->prime.lock);
156 return ret;
157}
158EXPORT_SYMBOL(drm_gem_prime_fd_to_handle);
159
160int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
161 struct drm_file *file_priv)
162{
163 struct drm_prime_handle *args = data;
164 uint32_t flags;
165
166 if (!drm_core_check_feature(dev, DRIVER_PRIME))
167 return -EINVAL;
168
169 if (!dev->driver->prime_handle_to_fd)
170 return -ENOSYS;
171
172 /* check flags are valid */
173 if (args->flags & ~DRM_CLOEXEC)
174 return -EINVAL;
175
176 /* we only want to pass DRM_CLOEXEC which is == O_CLOEXEC */
177 flags = args->flags & DRM_CLOEXEC;
178
179 return dev->driver->prime_handle_to_fd(dev, file_priv,
180 args->handle, flags, &args->fd);
181}
182
183int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
184 struct drm_file *file_priv)
185{
186 struct drm_prime_handle *args = data;
187
188 if (!drm_core_check_feature(dev, DRIVER_PRIME))
189 return -EINVAL;
190
191 if (!dev->driver->prime_fd_to_handle)
192 return -ENOSYS;
193
194 return dev->driver->prime_fd_to_handle(dev, file_priv,
195 args->fd, &args->handle);
196}
197
198/*
199 * drm_prime_pages_to_sg
200 *
201 * this helper creates an sg table object from a set of pages
202 * the driver is responsible for mapping the pages into the
203 * importers address space
204 */
205struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages)
206{
207 struct sg_table *sg = NULL;
208 struct scatterlist *iter;
209 int i;
210 int ret;
211
212 sg = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
213 if (!sg)
214 goto out;
215
216 ret = sg_alloc_table(sg, nr_pages, GFP_KERNEL);
217 if (ret)
218 goto out;
219
220 for_each_sg(sg->sgl, iter, nr_pages, i)
221 sg_set_page(iter, pages[i], PAGE_SIZE, 0);
222
223 return sg;
224out:
225 kfree(sg);
226 return NULL;
227}
228EXPORT_SYMBOL(drm_prime_pages_to_sg);
229
230/* helper function to cleanup a GEM/prime object */
231void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg)
232{
233 struct dma_buf_attachment *attach;
234 struct dma_buf *dma_buf;
235 attach = obj->import_attach;
236 if (sg)
237 dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL);
238 dma_buf = attach->dmabuf;
239 dma_buf_detach(attach->dmabuf, attach);
240 /* remove the reference */
241 dma_buf_put(dma_buf);
242}
243EXPORT_SYMBOL(drm_prime_gem_destroy);
244
245void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv)
246{
247 INIT_LIST_HEAD(&prime_fpriv->head);
248 mutex_init(&prime_fpriv->lock);
249}
250EXPORT_SYMBOL(drm_prime_init_file_private);
251
252void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv)
253{
254 struct drm_prime_member *member, *safe;
255 list_for_each_entry_safe(member, safe, &prime_fpriv->head, entry) {
256 list_del(&member->entry);
257 kfree(member);
258 }
259}
260EXPORT_SYMBOL(drm_prime_destroy_file_private);
261
262int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle)
263{
264 struct drm_prime_member *member;
265
266 member = kmalloc(sizeof(*member), GFP_KERNEL);
267 if (!member)
268 return -ENOMEM;
269
270 member->dma_buf = dma_buf;
271 member->handle = handle;
272 list_add(&member->entry, &prime_fpriv->head);
273 return 0;
274}
275EXPORT_SYMBOL(drm_prime_add_imported_buf_handle);
276
277int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle)
278{
279 struct drm_prime_member *member;
280
281 list_for_each_entry(member, &prime_fpriv->head, entry) {
282 if (member->dma_buf == dma_buf) {
283 *handle = member->handle;
284 return 0;
285 }
286 }
287 return -ENOENT;
288}
289EXPORT_SYMBOL(drm_prime_lookup_imported_buf_handle);
290
291void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf)
292{
293 struct drm_prime_member *member, *safe;
294
295 mutex_lock(&prime_fpriv->lock);
296 list_for_each_entry_safe(member, safe, &prime_fpriv->head, entry) {
297 if (member->dma_buf == dma_buf) {
298 list_del(&member->entry);
299 kfree(member);
300 }
301 }
302 mutex_unlock(&prime_fpriv->lock);
303}
304EXPORT_SYMBOL(drm_prime_remove_imported_buf_handle);
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index fdb7ccefffbd..b505b70dba05 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1502,14 +1502,6 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)
1502 return 0; 1502 return 0;
1503} 1503}
1504 1504
1505static int
1506i915_debugfs_common_open(struct inode *inode,
1507 struct file *filp)
1508{
1509 filp->private_data = inode->i_private;
1510 return 0;
1511}
1512
1513static ssize_t 1505static ssize_t
1514i915_wedged_read(struct file *filp, 1506i915_wedged_read(struct file *filp,
1515 char __user *ubuf, 1507 char __user *ubuf,
@@ -1560,7 +1552,7 @@ i915_wedged_write(struct file *filp,
1560 1552
1561static const struct file_operations i915_wedged_fops = { 1553static const struct file_operations i915_wedged_fops = {
1562 .owner = THIS_MODULE, 1554 .owner = THIS_MODULE,
1563 .open = i915_debugfs_common_open, 1555 .open = simple_open,
1564 .read = i915_wedged_read, 1556 .read = i915_wedged_read,
1565 .write = i915_wedged_write, 1557 .write = i915_wedged_write,
1566 .llseek = default_llseek, 1558 .llseek = default_llseek,
@@ -1622,7 +1614,7 @@ i915_max_freq_write(struct file *filp,
1622 1614
1623static const struct file_operations i915_max_freq_fops = { 1615static const struct file_operations i915_max_freq_fops = {
1624 .owner = THIS_MODULE, 1616 .owner = THIS_MODULE,
1625 .open = i915_debugfs_common_open, 1617 .open = simple_open,
1626 .read = i915_max_freq_read, 1618 .read = i915_max_freq_read,
1627 .write = i915_max_freq_write, 1619 .write = i915_max_freq_write,
1628 .llseek = default_llseek, 1620 .llseek = default_llseek,
@@ -1693,7 +1685,7 @@ i915_cache_sharing_write(struct file *filp,
1693 1685
1694static const struct file_operations i915_cache_sharing_fops = { 1686static const struct file_operations i915_cache_sharing_fops = {
1695 .owner = THIS_MODULE, 1687 .owner = THIS_MODULE,
1696 .open = i915_debugfs_common_open, 1688 .open = simple_open,
1697 .read = i915_cache_sharing_read, 1689 .read = i915_cache_sharing_read,
1698 .write = i915_cache_sharing_write, 1690 .write = i915_cache_sharing_write,
1699 .llseek = default_llseek, 1691 .llseek = default_llseek,
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 9341eb8ce93b..785f67f963ef 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1183,6 +1183,21 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
1183 return can_switch; 1183 return can_switch;
1184} 1184}
1185 1185
1186static bool
1187intel_enable_ppgtt(struct drm_device *dev)
1188{
1189 if (i915_enable_ppgtt >= 0)
1190 return i915_enable_ppgtt;
1191
1192#ifdef CONFIG_INTEL_IOMMU
1193 /* Disable ppgtt on SNB if VT-d is on. */
1194 if (INTEL_INFO(dev)->gen == 6 && intel_iommu_gfx_mapped)
1195 return false;
1196#endif
1197
1198 return true;
1199}
1200
1186static int i915_load_gem_init(struct drm_device *dev) 1201static int i915_load_gem_init(struct drm_device *dev)
1187{ 1202{
1188 struct drm_i915_private *dev_priv = dev->dev_private; 1203 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1197,7 +1212,7 @@ static int i915_load_gem_init(struct drm_device *dev)
1197 drm_mm_init(&dev_priv->mm.stolen, 0, prealloc_size); 1212 drm_mm_init(&dev_priv->mm.stolen, 0, prealloc_size);
1198 1213
1199 mutex_lock(&dev->struct_mutex); 1214 mutex_lock(&dev->struct_mutex);
1200 if (i915_enable_ppgtt && HAS_ALIASING_PPGTT(dev)) { 1215 if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) {
1201 /* PPGTT pdes are stolen from global gtt ptes, so shrink the 1216 /* PPGTT pdes are stolen from global gtt ptes, so shrink the
1202 * aperture accordingly when using aliasing ppgtt. */ 1217 * aperture accordingly when using aliasing ppgtt. */
1203 gtt_size -= I915_PPGTT_PD_ENTRIES*PAGE_SIZE; 1218 gtt_size -= I915_PPGTT_PD_ENTRIES*PAGE_SIZE;
@@ -1207,8 +1222,10 @@ static int i915_load_gem_init(struct drm_device *dev)
1207 i915_gem_do_init(dev, 0, mappable_size, gtt_size); 1222 i915_gem_do_init(dev, 0, mappable_size, gtt_size);
1208 1223
1209 ret = i915_gem_init_aliasing_ppgtt(dev); 1224 ret = i915_gem_init_aliasing_ppgtt(dev);
1210 if (ret) 1225 if (ret) {
1226 mutex_unlock(&dev->struct_mutex);
1211 return ret; 1227 return ret;
1228 }
1212 } else { 1229 } else {
1213 /* Let GEM Manage all of the aperture. 1230 /* Let GEM Manage all of the aperture.
1214 * 1231 *
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 1a7559b59997..dfa55e7478fb 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -66,7 +66,11 @@ MODULE_PARM_DESC(semaphores,
66int i915_enable_rc6 __read_mostly = -1; 66int i915_enable_rc6 __read_mostly = -1;
67module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0600); 67module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0600);
68MODULE_PARM_DESC(i915_enable_rc6, 68MODULE_PARM_DESC(i915_enable_rc6,
69 "Enable power-saving render C-state 6 (default: -1 (use per-chip default)"); 69 "Enable power-saving render C-state 6. "
70 "Different stages can be selected via bitmask values "
71 "(0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). "
72 "For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. "
73 "default: -1 (use per-chip default)");
70 74
71int i915_enable_fbc __read_mostly = -1; 75int i915_enable_fbc __read_mostly = -1;
72module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600); 76module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600);
@@ -103,8 +107,8 @@ MODULE_PARM_DESC(enable_hangcheck,
103 "WARNING: Disabling this can cause system wide hangs. " 107 "WARNING: Disabling this can cause system wide hangs. "
104 "(default: true)"); 108 "(default: true)");
105 109
106bool i915_enable_ppgtt __read_mostly = 1; 110int i915_enable_ppgtt __read_mostly = -1;
107module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, bool, 0600); 111module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0600);
108MODULE_PARM_DESC(i915_enable_ppgtt, 112MODULE_PARM_DESC(i915_enable_ppgtt,
109 "Enable PPGTT (default: true)"); 113 "Enable PPGTT (default: true)");
110 114
@@ -292,6 +296,7 @@ static const struct pci_device_id pciidlist[] = { /* aka */
292 INTEL_VGA_DEVICE(0x0152, &intel_ivybridge_d_info), /* GT1 desktop */ 296 INTEL_VGA_DEVICE(0x0152, &intel_ivybridge_d_info), /* GT1 desktop */
293 INTEL_VGA_DEVICE(0x0162, &intel_ivybridge_d_info), /* GT2 desktop */ 297 INTEL_VGA_DEVICE(0x0162, &intel_ivybridge_d_info), /* GT2 desktop */
294 INTEL_VGA_DEVICE(0x015a, &intel_ivybridge_d_info), /* GT1 server */ 298 INTEL_VGA_DEVICE(0x015a, &intel_ivybridge_d_info), /* GT1 server */
299 INTEL_VGA_DEVICE(0x016a, &intel_ivybridge_d_info), /* GT2 server */
295 {0, 0, 0} 300 {0, 0, 0}
296}; 301};
297 302
@@ -533,7 +538,9 @@ static int i915_drm_thaw(struct drm_device *dev)
533 drm_irq_install(dev); 538 drm_irq_install(dev);
534 539
535 /* Resume the modeset for every activated CRTC */ 540 /* Resume the modeset for every activated CRTC */
541 mutex_lock(&dev->mode_config.mutex);
536 drm_helper_resume_force_mode(dev); 542 drm_helper_resume_force_mode(dev);
543 mutex_unlock(&dev->mode_config.mutex);
537 544
538 if (IS_IRONLAKE_M(dev)) 545 if (IS_IRONLAKE_M(dev))
539 ironlake_enable_rc6(dev); 546 ironlake_enable_rc6(dev);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index c0f19f572004..5fabc6c31fec 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1053,6 +1053,27 @@ struct drm_i915_file_private {
1053 1053
1054#include "i915_trace.h" 1054#include "i915_trace.h"
1055 1055
1056/**
1057 * RC6 is a special power stage which allows the GPU to enter an very
1058 * low-voltage mode when idle, using down to 0V while at this stage. This
1059 * stage is entered automatically when the GPU is idle when RC6 support is
1060 * enabled, and as soon as new workload arises GPU wakes up automatically as well.
1061 *
1062 * There are different RC6 modes available in Intel GPU, which differentiate
1063 * among each other with the latency required to enter and leave RC6 and
1064 * voltage consumed by the GPU in different states.
1065 *
1066 * The combination of the following flags define which states GPU is allowed
1067 * to enter, while RC6 is the normal RC6 state, RC6p is the deep RC6, and
1068 * RC6pp is deepest RC6. Their support by hardware varies according to the
1069 * GPU, BIOS, chipset and platform. RC6 is usually the safest one and the one
1070 * which brings the most power savings; deeper states save more power, but
1071 * require higher latency to switch to and wake up.
1072 */
1073#define INTEL_RC6_ENABLE (1<<0)
1074#define INTEL_RC6p_ENABLE (1<<1)
1075#define INTEL_RC6pp_ENABLE (1<<2)
1076
1056extern struct drm_ioctl_desc i915_ioctls[]; 1077extern struct drm_ioctl_desc i915_ioctls[];
1057extern int i915_max_ioctl; 1078extern int i915_max_ioctl;
1058extern unsigned int i915_fbpercrtc __always_unused; 1079extern unsigned int i915_fbpercrtc __always_unused;
@@ -1065,7 +1086,7 @@ extern int i915_vbt_sdvo_panel_type __read_mostly;
1065extern int i915_enable_rc6 __read_mostly; 1086extern int i915_enable_rc6 __read_mostly;
1066extern int i915_enable_fbc __read_mostly; 1087extern int i915_enable_fbc __read_mostly;
1067extern bool i915_enable_hangcheck __read_mostly; 1088extern bool i915_enable_hangcheck __read_mostly;
1068extern bool i915_enable_ppgtt __read_mostly; 1089extern int i915_enable_ppgtt __read_mostly;
1069 1090
1070extern int i915_suspend(struct drm_device *dev, pm_message_t state); 1091extern int i915_suspend(struct drm_device *dev, pm_message_t state);
1071extern int i915_resume(struct drm_device *dev); 1092extern int i915_resume(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 1f441f5c2405..4c65c639f772 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1472,16 +1472,19 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
1472 list_move_tail(&obj->ring_list, &ring->active_list); 1472 list_move_tail(&obj->ring_list, &ring->active_list);
1473 1473
1474 obj->last_rendering_seqno = seqno; 1474 obj->last_rendering_seqno = seqno;
1475 if (obj->fenced_gpu_access) {
1476 struct drm_i915_fence_reg *reg;
1477
1478 BUG_ON(obj->fence_reg == I915_FENCE_REG_NONE);
1479 1475
1476 if (obj->fenced_gpu_access) {
1480 obj->last_fenced_seqno = seqno; 1477 obj->last_fenced_seqno = seqno;
1481 obj->last_fenced_ring = ring; 1478 obj->last_fenced_ring = ring;
1482 1479
1483 reg = &dev_priv->fence_regs[obj->fence_reg]; 1480 /* Bump MRU to take account of the delayed flush */
1484 list_move_tail(&reg->lru_list, &dev_priv->mm.fence_list); 1481 if (obj->fence_reg != I915_FENCE_REG_NONE) {
1482 struct drm_i915_fence_reg *reg;
1483
1484 reg = &dev_priv->fence_regs[obj->fence_reg];
1485 list_move_tail(&reg->lru_list,
1486 &dev_priv->mm.fence_list);
1487 }
1485 } 1488 }
1486} 1489}
1487 1490
@@ -3754,12 +3757,32 @@ void i915_gem_init_ppgtt(struct drm_device *dev)
3754 drm_i915_private_t *dev_priv = dev->dev_private; 3757 drm_i915_private_t *dev_priv = dev->dev_private;
3755 uint32_t pd_offset; 3758 uint32_t pd_offset;
3756 struct intel_ring_buffer *ring; 3759 struct intel_ring_buffer *ring;
3760 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
3761 uint32_t __iomem *pd_addr;
3762 uint32_t pd_entry;
3757 int i; 3763 int i;
3758 3764
3759 if (!dev_priv->mm.aliasing_ppgtt) 3765 if (!dev_priv->mm.aliasing_ppgtt)
3760 return; 3766 return;
3761 3767
3762 pd_offset = dev_priv->mm.aliasing_ppgtt->pd_offset; 3768
3769 pd_addr = dev_priv->mm.gtt->gtt + ppgtt->pd_offset/sizeof(uint32_t);
3770 for (i = 0; i < ppgtt->num_pd_entries; i++) {
3771 dma_addr_t pt_addr;
3772
3773 if (dev_priv->mm.gtt->needs_dmar)
3774 pt_addr = ppgtt->pt_dma_addr[i];
3775 else
3776 pt_addr = page_to_phys(ppgtt->pt_pages[i]);
3777
3778 pd_entry = GEN6_PDE_ADDR_ENCODE(pt_addr);
3779 pd_entry |= GEN6_PDE_VALID;
3780
3781 writel(pd_entry, pd_addr + i);
3782 }
3783 readl(pd_addr);
3784
3785 pd_offset = ppgtt->pd_offset;
3763 pd_offset /= 64; /* in cachelines, */ 3786 pd_offset /= 64; /* in cachelines, */
3764 pd_offset <<= 16; 3787 pd_offset <<= 16;
3765 3788
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 81687af00893..f51a696486cb 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -498,8 +498,8 @@ pin_and_fence_object(struct drm_i915_gem_object *obj,
498 if (ret) 498 if (ret)
499 goto err_unpin; 499 goto err_unpin;
500 } 500 }
501 obj->pending_fenced_gpu_access = true;
501 } 502 }
502 obj->pending_fenced_gpu_access = need_fence;
503 } 503 }
504 504
505 entry->offset = obj->gtt_offset; 505 entry->offset = obj->gtt_offset;
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 2eacd78bb93b..a135c61f4119 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -65,9 +65,7 @@ int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
65{ 65{
66 struct drm_i915_private *dev_priv = dev->dev_private; 66 struct drm_i915_private *dev_priv = dev->dev_private;
67 struct i915_hw_ppgtt *ppgtt; 67 struct i915_hw_ppgtt *ppgtt;
68 uint32_t pd_entry;
69 unsigned first_pd_entry_in_global_pt; 68 unsigned first_pd_entry_in_global_pt;
70 uint32_t __iomem *pd_addr;
71 int i; 69 int i;
72 int ret = -ENOMEM; 70 int ret = -ENOMEM;
73 71
@@ -100,7 +98,6 @@ int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
100 goto err_pt_alloc; 98 goto err_pt_alloc;
101 } 99 }
102 100
103 pd_addr = dev_priv->mm.gtt->gtt + first_pd_entry_in_global_pt;
104 for (i = 0; i < ppgtt->num_pd_entries; i++) { 101 for (i = 0; i < ppgtt->num_pd_entries; i++) {
105 dma_addr_t pt_addr; 102 dma_addr_t pt_addr;
106 if (dev_priv->mm.gtt->needs_dmar) { 103 if (dev_priv->mm.gtt->needs_dmar) {
@@ -117,13 +114,7 @@ int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
117 ppgtt->pt_dma_addr[i] = pt_addr; 114 ppgtt->pt_dma_addr[i] = pt_addr;
118 } else 115 } else
119 pt_addr = page_to_phys(ppgtt->pt_pages[i]); 116 pt_addr = page_to_phys(ppgtt->pt_pages[i]);
120
121 pd_entry = GEN6_PDE_ADDR_ENCODE(pt_addr);
122 pd_entry |= GEN6_PDE_VALID;
123
124 writel(pd_entry, pd_addr + i);
125 } 117 }
126 readl(pd_addr);
127 118
128 ppgtt->scratch_page_dma_addr = dev_priv->mm.gtt->scratch_page_dma; 119 ppgtt->scratch_page_dma_addr = dev_priv->mm.gtt->scratch_page_dma;
129 120
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 3886cf051bac..2abf4eb94039 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2385,6 +2385,7 @@
2385#define PIPECONF_DISABLE 0 2385#define PIPECONF_DISABLE 0
2386#define PIPECONF_DOUBLE_WIDE (1<<30) 2386#define PIPECONF_DOUBLE_WIDE (1<<30)
2387#define I965_PIPECONF_ACTIVE (1<<30) 2387#define I965_PIPECONF_ACTIVE (1<<30)
2388#define PIPECONF_FRAME_START_DELAY_MASK (3<<27)
2388#define PIPECONF_SINGLE_WIDE 0 2389#define PIPECONF_SINGLE_WIDE 0
2389#define PIPECONF_PIPE_UNLOCKED 0 2390#define PIPECONF_PIPE_UNLOCKED 0
2390#define PIPECONF_PIPE_LOCKED (1<<25) 2391#define PIPECONF_PIPE_LOCKED (1<<25)
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 8168d8f8a634..b48fc2a8410c 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -24,6 +24,7 @@
24 * Eric Anholt <eric@anholt.net> 24 * Eric Anholt <eric@anholt.net>
25 * 25 *
26 */ 26 */
27#include <linux/dmi.h>
27#include <drm/drm_dp_helper.h> 28#include <drm/drm_dp_helper.h>
28#include "drmP.h" 29#include "drmP.h"
29#include "drm.h" 30#include "drm.h"
@@ -621,6 +622,26 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
621 dev_priv->edp.bpp = 18; 622 dev_priv->edp.bpp = 18;
622} 623}
623 624
625static int __init intel_no_opregion_vbt_callback(const struct dmi_system_id *id)
626{
627 DRM_DEBUG_KMS("Falling back to manually reading VBT from "
628 "VBIOS ROM for %s\n",
629 id->ident);
630 return 1;
631}
632
633static const struct dmi_system_id intel_no_opregion_vbt[] = {
634 {
635 .callback = intel_no_opregion_vbt_callback,
636 .ident = "ThinkCentre A57",
637 .matches = {
638 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
639 DMI_MATCH(DMI_PRODUCT_NAME, "97027RG"),
640 },
641 },
642 { }
643};
644
624/** 645/**
625 * intel_parse_bios - find VBT and initialize settings from the BIOS 646 * intel_parse_bios - find VBT and initialize settings from the BIOS
626 * @dev: DRM device 647 * @dev: DRM device
@@ -641,7 +662,7 @@ intel_parse_bios(struct drm_device *dev)
641 init_vbt_defaults(dev_priv); 662 init_vbt_defaults(dev_priv);
642 663
643 /* XXX Should this validation be moved to intel_opregion.c? */ 664 /* XXX Should this validation be moved to intel_opregion.c? */
644 if (dev_priv->opregion.vbt) { 665 if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt) {
645 struct vbt_header *vbt = dev_priv->opregion.vbt; 666 struct vbt_header *vbt = dev_priv->opregion.vbt;
646 if (memcmp(vbt->signature, "$VBT", 4) == 0) { 667 if (memcmp(vbt->signature, "$VBT", 4) == 0) {
647 DRM_DEBUG_KMS("Using VBT from OpRegion: %20s\n", 668 DRM_DEBUG_KMS("Using VBT from OpRegion: %20s\n",
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index d514719f65e2..91b35fd1db8c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5539,7 +5539,8 @@ void ironlake_init_pch_refclk(struct drm_device *dev)
5539 if (intel_panel_use_ssc(dev_priv) && can_ssc) { 5539 if (intel_panel_use_ssc(dev_priv) && can_ssc) {
5540 DRM_DEBUG_KMS("Using SSC on panel\n"); 5540 DRM_DEBUG_KMS("Using SSC on panel\n");
5541 temp |= DREF_SSC1_ENABLE; 5541 temp |= DREF_SSC1_ENABLE;
5542 } 5542 } else
5543 temp &= ~DREF_SSC1_ENABLE;
5543 5544
5544 /* Get SSC going before enabling the outputs */ 5545 /* Get SSC going before enabling the outputs */
5545 I915_WRITE(PCH_DREF_CONTROL, temp); 5546 I915_WRITE(PCH_DREF_CONTROL, temp);
@@ -7580,6 +7581,12 @@ static void intel_sanitize_modesetting(struct drm_device *dev,
7580 struct drm_i915_private *dev_priv = dev->dev_private; 7581 struct drm_i915_private *dev_priv = dev->dev_private;
7581 u32 reg, val; 7582 u32 reg, val;
7582 7583
7584 /* Clear any frame start delays used for debugging left by the BIOS */
7585 for_each_pipe(pipe) {
7586 reg = PIPECONF(pipe);
7587 I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK);
7588 }
7589
7583 if (HAS_PCH_SPLIT(dev)) 7590 if (HAS_PCH_SPLIT(dev))
7584 return; 7591 return;
7585 7592
@@ -8215,7 +8222,7 @@ void intel_init_emon(struct drm_device *dev)
8215 dev_priv->corr = (lcfuse & LCFUSE_HIV_MASK); 8222 dev_priv->corr = (lcfuse & LCFUSE_HIV_MASK);
8216} 8223}
8217 8224
8218static bool intel_enable_rc6(struct drm_device *dev) 8225static int intel_enable_rc6(struct drm_device *dev)
8219{ 8226{
8220 /* 8227 /*
8221 * Respect the kernel parameter if it is set 8228 * Respect the kernel parameter if it is set
@@ -8233,11 +8240,11 @@ static bool intel_enable_rc6(struct drm_device *dev)
8233 * Disable rc6 on Sandybridge 8240 * Disable rc6 on Sandybridge
8234 */ 8241 */
8235 if (INTEL_INFO(dev)->gen == 6) { 8242 if (INTEL_INFO(dev)->gen == 6) {
8236 DRM_DEBUG_DRIVER("Sandybridge: RC6 disabled\n"); 8243 DRM_DEBUG_DRIVER("Sandybridge: deep RC6 disabled\n");
8237 return 0; 8244 return INTEL_RC6_ENABLE;
8238 } 8245 }
8239 DRM_DEBUG_DRIVER("RC6 enabled\n"); 8246 DRM_DEBUG_DRIVER("RC6 and deep RC6 enabled\n");
8240 return 1; 8247 return (INTEL_RC6_ENABLE | INTEL_RC6p_ENABLE);
8241} 8248}
8242 8249
8243void gen6_enable_rps(struct drm_i915_private *dev_priv) 8250void gen6_enable_rps(struct drm_i915_private *dev_priv)
@@ -8247,6 +8254,7 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv)
8247 u32 pcu_mbox, rc6_mask = 0; 8254 u32 pcu_mbox, rc6_mask = 0;
8248 u32 gtfifodbg; 8255 u32 gtfifodbg;
8249 int cur_freq, min_freq, max_freq; 8256 int cur_freq, min_freq, max_freq;
8257 int rc6_mode;
8250 int i; 8258 int i;
8251 8259
8252 /* Here begins a magic sequence of register writes to enable 8260 /* Here begins a magic sequence of register writes to enable
@@ -8284,9 +8292,20 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv)
8284 I915_WRITE(GEN6_RC6p_THRESHOLD, 100000); 8292 I915_WRITE(GEN6_RC6p_THRESHOLD, 100000);
8285 I915_WRITE(GEN6_RC6pp_THRESHOLD, 64000); /* unused */ 8293 I915_WRITE(GEN6_RC6pp_THRESHOLD, 64000); /* unused */
8286 8294
8287 if (intel_enable_rc6(dev_priv->dev)) 8295 rc6_mode = intel_enable_rc6(dev_priv->dev);
8288 rc6_mask = GEN6_RC_CTL_RC6_ENABLE | 8296 if (rc6_mode & INTEL_RC6_ENABLE)
8289 ((IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 0); 8297 rc6_mask |= GEN6_RC_CTL_RC6_ENABLE;
8298
8299 if (rc6_mode & INTEL_RC6p_ENABLE)
8300 rc6_mask |= GEN6_RC_CTL_RC6p_ENABLE;
8301
8302 if (rc6_mode & INTEL_RC6pp_ENABLE)
8303 rc6_mask |= GEN6_RC_CTL_RC6pp_ENABLE;
8304
8305 DRM_INFO("Enabling RC6 states: RC6 %s, RC6p %s, RC6pp %s\n",
8306 (rc6_mode & INTEL_RC6_ENABLE) ? "on" : "off",
8307 (rc6_mode & INTEL_RC6p_ENABLE) ? "on" : "off",
8308 (rc6_mode & INTEL_RC6pp_ENABLE) ? "on" : "off");
8290 8309
8291 I915_WRITE(GEN6_RC_CONTROL, 8310 I915_WRITE(GEN6_RC_CONTROL,
8292 rc6_mask | 8311 rc6_mask |
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index c5c0973af8a1..95db2e988227 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -755,6 +755,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
755 DMI_MATCH(DMI_BOARD_NAME, "hp st5747"), 755 DMI_MATCH(DMI_BOARD_NAME, "hp st5747"),
756 }, 756 },
757 }, 757 },
758 {
759 .callback = intel_no_lvds_dmi_callback,
760 .ident = "MSI Wind Box DC500",
761 .matches = {
762 DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
763 DMI_MATCH(DMI_BOARD_NAME, "MS-7469"),
764 },
765 },
758 766
759 { } /* terminating entry */ 767 { } /* terminating entry */
760}; 768};
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index fc66af6a9448..e25581a9f60f 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -626,7 +626,7 @@ gen6_ring_get_seqno(struct intel_ring_buffer *ring)
626 /* Workaround to force correct ordering between irq and seqno writes on 626 /* Workaround to force correct ordering between irq and seqno writes on
627 * ivb (and maybe also on snb) by reading from a CS register (like 627 * ivb (and maybe also on snb) by reading from a CS register (like
628 * ACTHD) before reading the status page. */ 628 * ACTHD) before reading the status page. */
629 if (IS_GEN7(dev)) 629 if (IS_GEN6(dev) || IS_GEN7(dev))
630 intel_ring_get_active_head(ring); 630 intel_ring_get_active_head(ring);
631 return intel_read_status_page(ring, I915_GEM_HWS_INDEX); 631 return intel_read_status_page(ring, I915_GEM_HWS_INDEX);
632} 632}
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 7aa0450399a1..a464771a7240 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -411,6 +411,9 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
411 411
412 old_obj = intel_plane->obj; 412 old_obj = intel_plane->obj;
413 413
414 src_w = src_w >> 16;
415 src_h = src_h >> 16;
416
414 /* Pipe must be running... */ 417 /* Pipe must be running... */
415 if (!(I915_READ(PIPECONF(pipe)) & PIPECONF_ENABLE)) 418 if (!(I915_READ(PIPECONF(pipe)) & PIPECONF_ENABLE))
416 return -EINVAL; 419 return -EINVAL;
diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index ca1639918f57..97a81260485a 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -13,6 +13,7 @@ config DRM_NOUVEAU
13 select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL && INPUT 13 select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL && INPUT
14 select ACPI_WMI if ACPI 14 select ACPI_WMI if ACPI
15 select MXM_WMI if ACPI 15 select MXM_WMI if ACPI
16 select POWER_SUPPLY
16 help 17 help
17 Choose this option for open-source nVidia support. 18 Choose this option for open-source nVidia support.
18 19
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 637afe71de56..80963d05b54a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -177,14 +177,15 @@ bios_shadow_pci(struct nvbios *bios)
177 177
178 if (!pci_enable_rom(pdev)) { 178 if (!pci_enable_rom(pdev)) {
179 void __iomem *rom = pci_map_rom(pdev, &length); 179 void __iomem *rom = pci_map_rom(pdev, &length);
180 if (rom) { 180 if (rom && length) {
181 bios->data = kmalloc(length, GFP_KERNEL); 181 bios->data = kmalloc(length, GFP_KERNEL);
182 if (bios->data) { 182 if (bios->data) {
183 memcpy_fromio(bios->data, rom, length); 183 memcpy_fromio(bios->data, rom, length);
184 bios->length = length; 184 bios->length = length;
185 } 185 }
186 pci_unmap_rom(pdev, rom);
187 } 186 }
187 if (rom)
188 pci_unmap_rom(pdev, rom);
188 189
189 pci_disable_rom(pdev); 190 pci_disable_rom(pdev);
190 } 191 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index 44e6416d4a33..846afb0bfef4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_channel.c
+++ b/drivers/gpu/drm/nouveau/nouveau_channel.c
@@ -436,11 +436,11 @@ nouveau_ioctl_fifo_alloc(struct drm_device *dev, void *data,
436 } 436 }
437 437
438 if (dev_priv->card_type < NV_C0) { 438 if (dev_priv->card_type < NV_C0) {
439 init->subchan[0].handle = NvSw; 439 init->subchan[0].handle = 0x00000000;
440 init->subchan[0].grclass = NV_SW; 440 init->subchan[0].grclass = 0x0000;
441 init->nr_subchan = 1; 441 init->subchan[1].handle = NvSw;
442 } else { 442 init->subchan[1].grclass = NV_SW;
443 init->nr_subchan = 0; 443 init->nr_subchan = 2;
444 } 444 }
445 445
446 /* Named memory object area */ 446 /* Named memory object area */
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.h b/drivers/gpu/drm/nouveau/nouveau_dma.h
index bcf0fd9e313e..23d4edf992b7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.h
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.h
@@ -48,8 +48,8 @@ void nv50_dma_push(struct nouveau_channel *, struct nouveau_bo *,
48 48
49/* Hardcoded object assignments to subchannels (subchannel id). */ 49/* Hardcoded object assignments to subchannels (subchannel id). */
50enum { 50enum {
51 NvSubSw = 0, 51 NvSubM2MF = 0,
52 NvSubM2MF = 1, 52 NvSubSw = 1,
53 NvSub2D = 2, 53 NvSub2D = 2,
54 NvSubCtxSurf2D = 2, 54 NvSubCtxSurf2D = 2,
55 NvSubGdiRect = 3, 55 NvSubGdiRect = 3,
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index a4886b36d0fa..c2a8511e855a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -642,7 +642,7 @@ nouveau_card_channel_init(struct drm_device *dev)
642 OUT_RING (chan, chan->vram_handle); 642 OUT_RING (chan, chan->vram_handle);
643 OUT_RING (chan, chan->gart_handle); 643 OUT_RING (chan, chan->gart_handle);
644 } else 644 } else
645 if (dev_priv->card_type <= NV_C0) { 645 if (dev_priv->card_type <= NV_D0) {
646 ret = nouveau_gpuobj_gr_new(chan, 0x9039, 0x9039); 646 ret = nouveau_gpuobj_gr_new(chan, 0x9039, 0x9039);
647 if (ret) 647 if (ret)
648 goto error; 648 goto error;
diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
index d1bd239cd9e9..5ce9bf51a8de 100644
--- a/drivers/gpu/drm/radeon/atom.c
+++ b/drivers/gpu/drm/radeon/atom.c
@@ -1306,8 +1306,11 @@ struct atom_context *atom_parse(struct card_info *card, void *bios)
1306 1306
1307int atom_asic_init(struct atom_context *ctx) 1307int atom_asic_init(struct atom_context *ctx)
1308{ 1308{
1309 struct radeon_device *rdev = ctx->card->dev->dev_private;
1309 int hwi = CU16(ctx->data_table + ATOM_DATA_FWI_PTR); 1310 int hwi = CU16(ctx->data_table + ATOM_DATA_FWI_PTR);
1310 uint32_t ps[16]; 1311 uint32_t ps[16];
1312 int ret;
1313
1311 memset(ps, 0, 64); 1314 memset(ps, 0, 64);
1312 1315
1313 ps[0] = cpu_to_le32(CU32(hwi + ATOM_FWI_DEFSCLK_PTR)); 1316 ps[0] = cpu_to_le32(CU32(hwi + ATOM_FWI_DEFSCLK_PTR));
@@ -1317,7 +1320,17 @@ int atom_asic_init(struct atom_context *ctx)
1317 1320
1318 if (!CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_INIT)) 1321 if (!CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_INIT))
1319 return 1; 1322 return 1;
1320 return atom_execute_table(ctx, ATOM_CMD_INIT, ps); 1323 ret = atom_execute_table(ctx, ATOM_CMD_INIT, ps);
1324 if (ret)
1325 return ret;
1326
1327 memset(ps, 0, 64);
1328
1329 if (rdev->family < CHIP_R600) {
1330 if (CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_SPDFANCNTL))
1331 atom_execute_table(ctx, ATOM_CMD_SPDFANCNTL, ps);
1332 }
1333 return ret;
1321} 1334}
1322 1335
1323void atom_destroy(struct atom_context *ctx) 1336void atom_destroy(struct atom_context *ctx)
diff --git a/drivers/gpu/drm/radeon/atom.h b/drivers/gpu/drm/radeon/atom.h
index 93cfe2086ba0..25fea631dad2 100644
--- a/drivers/gpu/drm/radeon/atom.h
+++ b/drivers/gpu/drm/radeon/atom.h
@@ -44,6 +44,7 @@
44#define ATOM_CMD_SETSCLK 0x0A 44#define ATOM_CMD_SETSCLK 0x0A
45#define ATOM_CMD_SETMCLK 0x0B 45#define ATOM_CMD_SETMCLK 0x0B
46#define ATOM_CMD_SETPCLK 0x0C 46#define ATOM_CMD_SETPCLK 0x0C
47#define ATOM_CMD_SPDFANCNTL 0x39
47 48
48#define ATOM_DATA_FWI_PTR 0xC 49#define ATOM_DATA_FWI_PTR 0xC
49#define ATOM_DATA_IIO_PTR 0x32 50#define ATOM_DATA_IIO_PTR 0x32
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 6f70158d34e4..df6a4dbd93f8 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -241,7 +241,8 @@ int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset,
241 domain_start = bo->rdev->mc.vram_start; 241 domain_start = bo->rdev->mc.vram_start;
242 else 242 else
243 domain_start = bo->rdev->mc.gtt_start; 243 domain_start = bo->rdev->mc.gtt_start;
244 WARN_ON_ONCE((*gpu_addr - domain_start) > max_offset); 244 WARN_ON_ONCE(max_offset <
245 (radeon_bo_gpu_offset(bo) - domain_start));
245 } 246 }
246 247
247 return 0; 248 return 0;
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 5340c5f3987b..53673907a6a0 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -47,7 +47,7 @@ static struct vm_operations_struct udl_gem_vm_ops = {
47static const struct file_operations udl_driver_fops = { 47static const struct file_operations udl_driver_fops = {
48 .owner = THIS_MODULE, 48 .owner = THIS_MODULE,
49 .open = drm_open, 49 .open = drm_open,
50 .mmap = drm_gem_mmap, 50 .mmap = udl_drm_gem_mmap,
51 .poll = drm_poll, 51 .poll = drm_poll,
52 .read = drm_read, 52 .read = drm_read,
53 .unlocked_ioctl = drm_ioctl, 53 .unlocked_ioctl = drm_ioctl,
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 1612954a5bc4..96820d03a303 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -121,6 +121,7 @@ struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
121 121
122int udl_gem_vmap(struct udl_gem_object *obj); 122int udl_gem_vmap(struct udl_gem_object *obj);
123void udl_gem_vunmap(struct udl_gem_object *obj); 123void udl_gem_vunmap(struct udl_gem_object *obj);
124int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
124int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); 125int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
125 126
126int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, 127int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 852642dc1187..92f19ef329b0 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -71,6 +71,20 @@ int udl_dumb_destroy(struct drm_file *file, struct drm_device *dev,
71 return drm_gem_handle_delete(file, handle); 71 return drm_gem_handle_delete(file, handle);
72} 72}
73 73
74int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
75{
76 int ret;
77
78 ret = drm_gem_mmap(filp, vma);
79 if (ret)
80 return ret;
81
82 vma->vm_flags &= ~VM_PFNMAP;
83 vma->vm_flags |= VM_MIXEDMAP;
84
85 return ret;
86}
87
74int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 88int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
75{ 89{
76 struct udl_gem_object *obj = to_udl_bo(vma->vm_private_data); 90 struct udl_gem_object *obj = to_udl_bo(vma->vm_private_data);
diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
index 12f9777c385d..45c3433f7986 100644
--- a/drivers/hid/hid-picolcd.c
+++ b/drivers/hid/hid-picolcd.c
@@ -1525,12 +1525,6 @@ static const struct file_operations picolcd_debug_reset_fops = {
1525/* 1525/*
1526 * The "eeprom" file 1526 * The "eeprom" file
1527 */ 1527 */
1528static int picolcd_debug_eeprom_open(struct inode *i, struct file *f)
1529{
1530 f->private_data = i->i_private;
1531 return 0;
1532}
1533
1534static ssize_t picolcd_debug_eeprom_read(struct file *f, char __user *u, 1528static ssize_t picolcd_debug_eeprom_read(struct file *f, char __user *u,
1535 size_t s, loff_t *off) 1529 size_t s, loff_t *off)
1536{ 1530{
@@ -1618,7 +1612,7 @@ static ssize_t picolcd_debug_eeprom_write(struct file *f, const char __user *u,
1618 */ 1612 */
1619static const struct file_operations picolcd_debug_eeprom_fops = { 1613static const struct file_operations picolcd_debug_eeprom_fops = {
1620 .owner = THIS_MODULE, 1614 .owner = THIS_MODULE,
1621 .open = picolcd_debug_eeprom_open, 1615 .open = simple_open,
1622 .read = picolcd_debug_eeprom_read, 1616 .read = picolcd_debug_eeprom_read,
1623 .write = picolcd_debug_eeprom_write, 1617 .write = picolcd_debug_eeprom_write,
1624 .llseek = generic_file_llseek, 1618 .llseek = generic_file_llseek,
@@ -1627,12 +1621,6 @@ static const struct file_operations picolcd_debug_eeprom_fops = {
1627/* 1621/*
1628 * The "flash" file 1622 * The "flash" file
1629 */ 1623 */
1630static int picolcd_debug_flash_open(struct inode *i, struct file *f)
1631{
1632 f->private_data = i->i_private;
1633 return 0;
1634}
1635
1636/* record a flash address to buf (bounds check to be done by caller) */ 1624/* record a flash address to buf (bounds check to be done by caller) */
1637static int _picolcd_flash_setaddr(struct picolcd_data *data, u8 *buf, long off) 1625static int _picolcd_flash_setaddr(struct picolcd_data *data, u8 *buf, long off)
1638{ 1626{
@@ -1817,7 +1805,7 @@ static ssize_t picolcd_debug_flash_write(struct file *f, const char __user *u,
1817 */ 1805 */
1818static const struct file_operations picolcd_debug_flash_fops = { 1806static const struct file_operations picolcd_debug_flash_fops = {
1819 .owner = THIS_MODULE, 1807 .owner = THIS_MODULE,
1820 .open = picolcd_debug_flash_open, 1808 .open = simple_open,
1821 .read = picolcd_debug_flash_read, 1809 .read = picolcd_debug_flash_read,
1822 .write = picolcd_debug_flash_write, 1810 .write = picolcd_debug_flash_write,
1823 .llseek = generic_file_llseek, 1811 .llseek = generic_file_llseek,
diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
index 17dabc1f339e..eec329197c16 100644
--- a/drivers/hid/hid-wiimote-debug.c
+++ b/drivers/hid/hid-wiimote-debug.c
@@ -23,12 +23,6 @@ struct wiimote_debug {
23 struct dentry *drm; 23 struct dentry *drm;
24}; 24};
25 25
26static int wiidebug_eeprom_open(struct inode *i, struct file *f)
27{
28 f->private_data = i->i_private;
29 return 0;
30}
31
32static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s, 26static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
33 loff_t *off) 27 loff_t *off)
34{ 28{
@@ -83,7 +77,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
83 77
84static const struct file_operations wiidebug_eeprom_fops = { 78static const struct file_operations wiidebug_eeprom_fops = {
85 .owner = THIS_MODULE, 79 .owner = THIS_MODULE,
86 .open = wiidebug_eeprom_open, 80 .open = simple_open,
87 .read = wiidebug_eeprom_read, 81 .read = wiidebug_eeprom_read,
88 .llseek = generic_file_llseek, 82 .llseek = generic_file_llseek,
89}; 83};
diff --git a/drivers/hsi/Kconfig b/drivers/hsi/Kconfig
new file mode 100644
index 000000000000..d94e38dd80c7
--- /dev/null
+++ b/drivers/hsi/Kconfig
@@ -0,0 +1,19 @@
1#
2# HSI driver configuration
3#
4menuconfig HSI
5 tristate "HSI support"
6 ---help---
7 The "High speed synchronous Serial Interface" is
8 synchronous serial interface used mainly to connect
9 application engines and cellular modems.
10
11if HSI
12
13config HSI_BOARDINFO
14 bool
15 default y
16
17source "drivers/hsi/clients/Kconfig"
18
19endif # HSI
diff --git a/drivers/hsi/Makefile b/drivers/hsi/Makefile
new file mode 100644
index 000000000000..9d5d33f90de2
--- /dev/null
+++ b/drivers/hsi/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for HSI
3#
4obj-$(CONFIG_HSI_BOARDINFO) += hsi_boardinfo.o
5obj-$(CONFIG_HSI) += hsi.o
6obj-y += clients/
diff --git a/drivers/hsi/clients/Kconfig b/drivers/hsi/clients/Kconfig
new file mode 100644
index 000000000000..3bacd275f479
--- /dev/null
+++ b/drivers/hsi/clients/Kconfig
@@ -0,0 +1,13 @@
1#
2# HSI clients configuration
3#
4
5comment "HSI clients"
6
7config HSI_CHAR
8 tristate "HSI/SSI character driver"
9 depends on HSI
10 ---help---
11 If you say Y here, you will enable the HSI/SSI character driver.
12 This driver provides a simple character device interface for
13 serial communication with the cellular modem over HSI/SSI bus.
diff --git a/drivers/hsi/clients/Makefile b/drivers/hsi/clients/Makefile
new file mode 100644
index 000000000000..327c0e27c8b0
--- /dev/null
+++ b/drivers/hsi/clients/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for HSI clients
3#
4
5obj-$(CONFIG_HSI_CHAR) += hsi_char.o
diff --git a/drivers/hsi/clients/hsi_char.c b/drivers/hsi/clients/hsi_char.c
new file mode 100644
index 000000000000..88a050df2389
--- /dev/null
+++ b/drivers/hsi/clients/hsi_char.c
@@ -0,0 +1,802 @@
1/*
2 * HSI character device driver, implements the character device
3 * interface.
4 *
5 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
6 *
7 * Contact: Andras Domokos <andras.domokos@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24#include <linux/errno.h>
25#include <linux/types.h>
26#include <linux/atomic.h>
27#include <linux/kernel.h>
28#include <linux/init.h>
29#include <linux/module.h>
30#include <linux/mutex.h>
31#include <linux/list.h>
32#include <linux/slab.h>
33#include <linux/kmemleak.h>
34#include <linux/ioctl.h>
35#include <linux/wait.h>
36#include <linux/fs.h>
37#include <linux/sched.h>
38#include <linux/device.h>
39#include <linux/cdev.h>
40#include <linux/uaccess.h>
41#include <linux/scatterlist.h>
42#include <linux/stat.h>
43#include <linux/hsi/hsi.h>
44#include <linux/hsi/hsi_char.h>
45
46#define HSC_DEVS 16 /* Num of channels */
47#define HSC_MSGS 4
48
49#define HSC_RXBREAK 0
50
51#define HSC_ID_BITS 6
52#define HSC_PORT_ID_BITS 4
53#define HSC_ID_MASK 3
54#define HSC_PORT_ID_MASK 3
55#define HSC_CH_MASK 0xf
56
57/*
58 * We support up to 4 controllers that can have up to 4
59 * ports, which should currently be more than enough.
60 */
61#define HSC_BASEMINOR(id, port_id) \
62 ((((id) & HSC_ID_MASK) << HSC_ID_BITS) | \
63 (((port_id) & HSC_PORT_ID_MASK) << HSC_PORT_ID_BITS))
64
65enum {
66 HSC_CH_OPEN,
67 HSC_CH_READ,
68 HSC_CH_WRITE,
69 HSC_CH_WLINE,
70};
71
72enum {
73 HSC_RX,
74 HSC_TX,
75};
76
77struct hsc_client_data;
78/**
79 * struct hsc_channel - hsi_char internal channel data
80 * @ch: channel number
81 * @flags: Keeps state of the channel (open/close, reading, writing)
82 * @free_msgs_list: List of free HSI messages/requests
83 * @rx_msgs_queue: List of pending RX requests
84 * @tx_msgs_queue: List of pending TX requests
85 * @lock: Serialize access to the lists
86 * @cl: reference to the associated hsi_client
87 * @cl_data: reference to the client data that this channels belongs to
88 * @rx_wait: RX requests wait queue
89 * @tx_wait: TX requests wait queue
90 */
91struct hsc_channel {
92 unsigned int ch;
93 unsigned long flags;
94 struct list_head free_msgs_list;
95 struct list_head rx_msgs_queue;
96 struct list_head tx_msgs_queue;
97 spinlock_t lock;
98 struct hsi_client *cl;
99 struct hsc_client_data *cl_data;
100 wait_queue_head_t rx_wait;
101 wait_queue_head_t tx_wait;
102};
103
104/**
105 * struct hsc_client_data - hsi_char internal client data
106 * @cdev: Characther device associated to the hsi_client
107 * @lock: Lock to serialize open/close access
108 * @flags: Keeps track of port state (rx hwbreak armed)
109 * @usecnt: Use count for claiming the HSI port (mutex protected)
110 * @cl: Referece to the HSI client
111 * @channels: Array of channels accessible by the client
112 */
113struct hsc_client_data {
114 struct cdev cdev;
115 struct mutex lock;
116 unsigned long flags;
117 unsigned int usecnt;
118 struct hsi_client *cl;
119 struct hsc_channel channels[HSC_DEVS];
120};
121
122/* Stores the major number dynamically allocated for hsi_char */
123static unsigned int hsc_major;
124/* Maximum buffer size that hsi_char will accept from userspace */
125static unsigned int max_data_size = 0x1000;
126module_param(max_data_size, uint, S_IRUSR | S_IWUSR);
127MODULE_PARM_DESC(max_data_size, "max read/write data size [4,8..65536] (^2)");
128
129static void hsc_add_tail(struct hsc_channel *channel, struct hsi_msg *msg,
130 struct list_head *queue)
131{
132 unsigned long flags;
133
134 spin_lock_irqsave(&channel->lock, flags);
135 list_add_tail(&msg->link, queue);
136 spin_unlock_irqrestore(&channel->lock, flags);
137}
138
139static struct hsi_msg *hsc_get_first_msg(struct hsc_channel *channel,
140 struct list_head *queue)
141{
142 struct hsi_msg *msg = NULL;
143 unsigned long flags;
144
145 spin_lock_irqsave(&channel->lock, flags);
146
147 if (list_empty(queue))
148 goto out;
149
150 msg = list_first_entry(queue, struct hsi_msg, link);
151 list_del(&msg->link);
152out:
153 spin_unlock_irqrestore(&channel->lock, flags);
154
155 return msg;
156}
157
158static inline void hsc_msg_free(struct hsi_msg *msg)
159{
160 kfree(sg_virt(msg->sgt.sgl));
161 hsi_free_msg(msg);
162}
163
164static void hsc_free_list(struct list_head *list)
165{
166 struct hsi_msg *msg, *tmp;
167
168 list_for_each_entry_safe(msg, tmp, list, link) {
169 list_del(&msg->link);
170 hsc_msg_free(msg);
171 }
172}
173
174static void hsc_reset_list(struct hsc_channel *channel, struct list_head *l)
175{
176 unsigned long flags;
177 LIST_HEAD(list);
178
179 spin_lock_irqsave(&channel->lock, flags);
180 list_splice_init(l, &list);
181 spin_unlock_irqrestore(&channel->lock, flags);
182
183 hsc_free_list(&list);
184}
185
186static inline struct hsi_msg *hsc_msg_alloc(unsigned int alloc_size)
187{
188 struct hsi_msg *msg;
189 void *buf;
190
191 msg = hsi_alloc_msg(1, GFP_KERNEL);
192 if (!msg)
193 goto out;
194 buf = kmalloc(alloc_size, GFP_KERNEL);
195 if (!buf) {
196 hsi_free_msg(msg);
197 goto out;
198 }
199 sg_init_one(msg->sgt.sgl, buf, alloc_size);
200 /* Ignore false positive, due to sg pointer handling */
201 kmemleak_ignore(buf);
202
203 return msg;
204out:
205 return NULL;
206}
207
208static inline int hsc_msgs_alloc(struct hsc_channel *channel)
209{
210 struct hsi_msg *msg;
211 int i;
212
213 for (i = 0; i < HSC_MSGS; i++) {
214 msg = hsc_msg_alloc(max_data_size);
215 if (!msg)
216 goto out;
217 msg->channel = channel->ch;
218 list_add_tail(&msg->link, &channel->free_msgs_list);
219 }
220
221 return 0;
222out:
223 hsc_free_list(&channel->free_msgs_list);
224
225 return -ENOMEM;
226}
227
228static inline unsigned int hsc_msg_len_get(struct hsi_msg *msg)
229{
230 return msg->sgt.sgl->length;
231}
232
233static inline void hsc_msg_len_set(struct hsi_msg *msg, unsigned int len)
234{
235 msg->sgt.sgl->length = len;
236}
237
238static void hsc_rx_completed(struct hsi_msg *msg)
239{
240 struct hsc_client_data *cl_data = hsi_client_drvdata(msg->cl);
241 struct hsc_channel *channel = cl_data->channels + msg->channel;
242
243 if (test_bit(HSC_CH_READ, &channel->flags)) {
244 hsc_add_tail(channel, msg, &channel->rx_msgs_queue);
245 wake_up(&channel->rx_wait);
246 } else {
247 hsc_add_tail(channel, msg, &channel->free_msgs_list);
248 }
249}
250
251static void hsc_rx_msg_destructor(struct hsi_msg *msg)
252{
253 msg->status = HSI_STATUS_ERROR;
254 hsc_msg_len_set(msg, 0);
255 hsc_rx_completed(msg);
256}
257
258static void hsc_tx_completed(struct hsi_msg *msg)
259{
260 struct hsc_client_data *cl_data = hsi_client_drvdata(msg->cl);
261 struct hsc_channel *channel = cl_data->channels + msg->channel;
262
263 if (test_bit(HSC_CH_WRITE, &channel->flags)) {
264 hsc_add_tail(channel, msg, &channel->tx_msgs_queue);
265 wake_up(&channel->tx_wait);
266 } else {
267 hsc_add_tail(channel, msg, &channel->free_msgs_list);
268 }
269}
270
271static void hsc_tx_msg_destructor(struct hsi_msg *msg)
272{
273 msg->status = HSI_STATUS_ERROR;
274 hsc_msg_len_set(msg, 0);
275 hsc_tx_completed(msg);
276}
277
278static void hsc_break_req_destructor(struct hsi_msg *msg)
279{
280 struct hsc_client_data *cl_data = hsi_client_drvdata(msg->cl);
281
282 hsi_free_msg(msg);
283 clear_bit(HSC_RXBREAK, &cl_data->flags);
284}
285
286static void hsc_break_received(struct hsi_msg *msg)
287{
288 struct hsc_client_data *cl_data = hsi_client_drvdata(msg->cl);
289 struct hsc_channel *channel = cl_data->channels;
290 int i, ret;
291
292 /* Broadcast HWBREAK on all channels */
293 for (i = 0; i < HSC_DEVS; i++, channel++) {
294 struct hsi_msg *msg2;
295
296 if (!test_bit(HSC_CH_READ, &channel->flags))
297 continue;
298 msg2 = hsc_get_first_msg(channel, &channel->free_msgs_list);
299 if (!msg2)
300 continue;
301 clear_bit(HSC_CH_READ, &channel->flags);
302 hsc_msg_len_set(msg2, 0);
303 msg2->status = HSI_STATUS_COMPLETED;
304 hsc_add_tail(channel, msg2, &channel->rx_msgs_queue);
305 wake_up(&channel->rx_wait);
306 }
307 hsi_flush(msg->cl);
308 ret = hsi_async_read(msg->cl, msg);
309 if (ret < 0)
310 hsc_break_req_destructor(msg);
311}
312
313static int hsc_break_request(struct hsi_client *cl)
314{
315 struct hsc_client_data *cl_data = hsi_client_drvdata(cl);
316 struct hsi_msg *msg;
317 int ret;
318
319 if (test_and_set_bit(HSC_RXBREAK, &cl_data->flags))
320 return -EBUSY;
321
322 msg = hsi_alloc_msg(0, GFP_KERNEL);
323 if (!msg) {
324 clear_bit(HSC_RXBREAK, &cl_data->flags);
325 return -ENOMEM;
326 }
327 msg->break_frame = 1;
328 msg->complete = hsc_break_received;
329 msg->destructor = hsc_break_req_destructor;
330 ret = hsi_async_read(cl, msg);
331 if (ret < 0)
332 hsc_break_req_destructor(msg);
333
334 return ret;
335}
336
337static int hsc_break_send(struct hsi_client *cl)
338{
339 struct hsi_msg *msg;
340 int ret;
341
342 msg = hsi_alloc_msg(0, GFP_ATOMIC);
343 if (!msg)
344 return -ENOMEM;
345 msg->break_frame = 1;
346 msg->complete = hsi_free_msg;
347 msg->destructor = hsi_free_msg;
348 ret = hsi_async_write(cl, msg);
349 if (ret < 0)
350 hsi_free_msg(msg);
351
352 return ret;
353}
354
355static int hsc_rx_set(struct hsi_client *cl, struct hsc_rx_config *rxc)
356{
357 struct hsi_config tmp;
358 int ret;
359
360 if ((rxc->mode != HSI_MODE_STREAM) && (rxc->mode != HSI_MODE_FRAME))
361 return -EINVAL;
362 if ((rxc->channels == 0) || (rxc->channels > HSC_DEVS))
363 return -EINVAL;
364 if (rxc->channels & (rxc->channels - 1))
365 return -EINVAL;
366 if ((rxc->flow != HSI_FLOW_SYNC) && (rxc->flow != HSI_FLOW_PIPE))
367 return -EINVAL;
368 tmp = cl->rx_cfg;
369 cl->rx_cfg.mode = rxc->mode;
370 cl->rx_cfg.channels = rxc->channels;
371 cl->rx_cfg.flow = rxc->flow;
372 ret = hsi_setup(cl);
373 if (ret < 0) {
374 cl->rx_cfg = tmp;
375 return ret;
376 }
377 if (rxc->mode == HSI_MODE_FRAME)
378 hsc_break_request(cl);
379
380 return ret;
381}
382
383static inline void hsc_rx_get(struct hsi_client *cl, struct hsc_rx_config *rxc)
384{
385 rxc->mode = cl->rx_cfg.mode;
386 rxc->channels = cl->rx_cfg.channels;
387 rxc->flow = cl->rx_cfg.flow;
388}
389
390static int hsc_tx_set(struct hsi_client *cl, struct hsc_tx_config *txc)
391{
392 struct hsi_config tmp;
393 int ret;
394
395 if ((txc->mode != HSI_MODE_STREAM) && (txc->mode != HSI_MODE_FRAME))
396 return -EINVAL;
397 if ((txc->channels == 0) || (txc->channels > HSC_DEVS))
398 return -EINVAL;
399 if (txc->channels & (txc->channels - 1))
400 return -EINVAL;
401 if ((txc->arb_mode != HSI_ARB_RR) && (txc->arb_mode != HSI_ARB_PRIO))
402 return -EINVAL;
403 tmp = cl->tx_cfg;
404 cl->tx_cfg.mode = txc->mode;
405 cl->tx_cfg.channels = txc->channels;
406 cl->tx_cfg.speed = txc->speed;
407 cl->tx_cfg.arb_mode = txc->arb_mode;
408 ret = hsi_setup(cl);
409 if (ret < 0) {
410 cl->tx_cfg = tmp;
411 return ret;
412 }
413
414 return ret;
415}
416
417static inline void hsc_tx_get(struct hsi_client *cl, struct hsc_tx_config *txc)
418{
419 txc->mode = cl->tx_cfg.mode;
420 txc->channels = cl->tx_cfg.channels;
421 txc->speed = cl->tx_cfg.speed;
422 txc->arb_mode = cl->tx_cfg.arb_mode;
423}
424
425static ssize_t hsc_read(struct file *file, char __user *buf, size_t len,
426 loff_t *ppos __maybe_unused)
427{
428 struct hsc_channel *channel = file->private_data;
429 struct hsi_msg *msg;
430 ssize_t ret;
431
432 if (len == 0)
433 return 0;
434 if (!IS_ALIGNED(len, sizeof(u32)))
435 return -EINVAL;
436 if (len > max_data_size)
437 len = max_data_size;
438 if (channel->ch >= channel->cl->rx_cfg.channels)
439 return -ECHRNG;
440 if (test_and_set_bit(HSC_CH_READ, &channel->flags))
441 return -EBUSY;
442 msg = hsc_get_first_msg(channel, &channel->free_msgs_list);
443 if (!msg) {
444 ret = -ENOSPC;
445 goto out;
446 }
447 hsc_msg_len_set(msg, len);
448 msg->complete = hsc_rx_completed;
449 msg->destructor = hsc_rx_msg_destructor;
450 ret = hsi_async_read(channel->cl, msg);
451 if (ret < 0) {
452 hsc_add_tail(channel, msg, &channel->free_msgs_list);
453 goto out;
454 }
455
456 ret = wait_event_interruptible(channel->rx_wait,
457 !list_empty(&channel->rx_msgs_queue));
458 if (ret < 0) {
459 clear_bit(HSC_CH_READ, &channel->flags);
460 hsi_flush(channel->cl);
461 return -EINTR;
462 }
463
464 msg = hsc_get_first_msg(channel, &channel->rx_msgs_queue);
465 if (msg) {
466 if (msg->status != HSI_STATUS_ERROR) {
467 ret = copy_to_user((void __user *)buf,
468 sg_virt(msg->sgt.sgl), hsc_msg_len_get(msg));
469 if (ret)
470 ret = -EFAULT;
471 else
472 ret = hsc_msg_len_get(msg);
473 } else {
474 ret = -EIO;
475 }
476 hsc_add_tail(channel, msg, &channel->free_msgs_list);
477 }
478out:
479 clear_bit(HSC_CH_READ, &channel->flags);
480
481 return ret;
482}
483
484static ssize_t hsc_write(struct file *file, const char __user *buf, size_t len,
485 loff_t *ppos __maybe_unused)
486{
487 struct hsc_channel *channel = file->private_data;
488 struct hsi_msg *msg;
489 ssize_t ret;
490
491 if ((len == 0) || !IS_ALIGNED(len, sizeof(u32)))
492 return -EINVAL;
493 if (len > max_data_size)
494 len = max_data_size;
495 if (channel->ch >= channel->cl->tx_cfg.channels)
496 return -ECHRNG;
497 if (test_and_set_bit(HSC_CH_WRITE, &channel->flags))
498 return -EBUSY;
499 msg = hsc_get_first_msg(channel, &channel->free_msgs_list);
500 if (!msg) {
501 clear_bit(HSC_CH_WRITE, &channel->flags);
502 return -ENOSPC;
503 }
504 if (copy_from_user(sg_virt(msg->sgt.sgl), (void __user *)buf, len)) {
505 ret = -EFAULT;
506 goto out;
507 }
508 hsc_msg_len_set(msg, len);
509 msg->complete = hsc_tx_completed;
510 msg->destructor = hsc_tx_msg_destructor;
511 ret = hsi_async_write(channel->cl, msg);
512 if (ret < 0)
513 goto out;
514
515 ret = wait_event_interruptible(channel->tx_wait,
516 !list_empty(&channel->tx_msgs_queue));
517 if (ret < 0) {
518 clear_bit(HSC_CH_WRITE, &channel->flags);
519 hsi_flush(channel->cl);
520 return -EINTR;
521 }
522
523 msg = hsc_get_first_msg(channel, &channel->tx_msgs_queue);
524 if (msg) {
525 if (msg->status == HSI_STATUS_ERROR)
526 ret = -EIO;
527 else
528 ret = hsc_msg_len_get(msg);
529
530 hsc_add_tail(channel, msg, &channel->free_msgs_list);
531 }
532out:
533 clear_bit(HSC_CH_WRITE, &channel->flags);
534
535 return ret;
536}
537
538static long hsc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
539{
540 struct hsc_channel *channel = file->private_data;
541 unsigned int state;
542 struct hsc_rx_config rxc;
543 struct hsc_tx_config txc;
544 long ret = 0;
545
546 switch (cmd) {
547 case HSC_RESET:
548 hsi_flush(channel->cl);
549 break;
550 case HSC_SET_PM:
551 if (copy_from_user(&state, (void __user *)arg, sizeof(state)))
552 return -EFAULT;
553 if (state == HSC_PM_DISABLE) {
554 if (test_and_set_bit(HSC_CH_WLINE, &channel->flags))
555 return -EINVAL;
556 ret = hsi_start_tx(channel->cl);
557 } else if (state == HSC_PM_ENABLE) {
558 if (!test_and_clear_bit(HSC_CH_WLINE, &channel->flags))
559 return -EINVAL;
560 ret = hsi_stop_tx(channel->cl);
561 } else {
562 ret = -EINVAL;
563 }
564 break;
565 case HSC_SEND_BREAK:
566 return hsc_break_send(channel->cl);
567 case HSC_SET_RX:
568 if (copy_from_user(&rxc, (void __user *)arg, sizeof(rxc)))
569 return -EFAULT;
570 return hsc_rx_set(channel->cl, &rxc);
571 case HSC_GET_RX:
572 hsc_rx_get(channel->cl, &rxc);
573 if (copy_to_user((void __user *)arg, &rxc, sizeof(rxc)))
574 return -EFAULT;
575 break;
576 case HSC_SET_TX:
577 if (copy_from_user(&txc, (void __user *)arg, sizeof(txc)))
578 return -EFAULT;
579 return hsc_tx_set(channel->cl, &txc);
580 case HSC_GET_TX:
581 hsc_tx_get(channel->cl, &txc);
582 if (copy_to_user((void __user *)arg, &txc, sizeof(txc)))
583 return -EFAULT;
584 break;
585 default:
586 return -ENOIOCTLCMD;
587 }
588
589 return ret;
590}
591
592static inline void __hsc_port_release(struct hsc_client_data *cl_data)
593{
594 BUG_ON(cl_data->usecnt == 0);
595
596 if (--cl_data->usecnt == 0) {
597 hsi_flush(cl_data->cl);
598 hsi_release_port(cl_data->cl);
599 }
600}
601
602static int hsc_open(struct inode *inode, struct file *file)
603{
604 struct hsc_client_data *cl_data;
605 struct hsc_channel *channel;
606 int ret = 0;
607
608 pr_debug("open, minor = %d\n", iminor(inode));
609
610 cl_data = container_of(inode->i_cdev, struct hsc_client_data, cdev);
611 mutex_lock(&cl_data->lock);
612 channel = cl_data->channels + (iminor(inode) & HSC_CH_MASK);
613
614 if (test_and_set_bit(HSC_CH_OPEN, &channel->flags)) {
615 ret = -EBUSY;
616 goto out;
617 }
618 /*
619 * Check if we have already claimed the port associated to the HSI
620 * client. If not then try to claim it, else increase its refcount
621 */
622 if (cl_data->usecnt == 0) {
623 ret = hsi_claim_port(cl_data->cl, 0);
624 if (ret < 0)
625 goto out;
626 hsi_setup(cl_data->cl);
627 }
628 cl_data->usecnt++;
629
630 ret = hsc_msgs_alloc(channel);
631 if (ret < 0) {
632 __hsc_port_release(cl_data);
633 goto out;
634 }
635
636 file->private_data = channel;
637 mutex_unlock(&cl_data->lock);
638
639 return ret;
640out:
641 mutex_unlock(&cl_data->lock);
642
643 return ret;
644}
645
646static int hsc_release(struct inode *inode __maybe_unused, struct file *file)
647{
648 struct hsc_channel *channel = file->private_data;
649 struct hsc_client_data *cl_data = channel->cl_data;
650
651 mutex_lock(&cl_data->lock);
652 file->private_data = NULL;
653 if (test_and_clear_bit(HSC_CH_WLINE, &channel->flags))
654 hsi_stop_tx(channel->cl);
655 __hsc_port_release(cl_data);
656 hsc_reset_list(channel, &channel->rx_msgs_queue);
657 hsc_reset_list(channel, &channel->tx_msgs_queue);
658 hsc_reset_list(channel, &channel->free_msgs_list);
659 clear_bit(HSC_CH_READ, &channel->flags);
660 clear_bit(HSC_CH_WRITE, &channel->flags);
661 clear_bit(HSC_CH_OPEN, &channel->flags);
662 wake_up(&channel->rx_wait);
663 wake_up(&channel->tx_wait);
664 mutex_unlock(&cl_data->lock);
665
666 return 0;
667}
668
669static const struct file_operations hsc_fops = {
670 .owner = THIS_MODULE,
671 .read = hsc_read,
672 .write = hsc_write,
673 .unlocked_ioctl = hsc_ioctl,
674 .open = hsc_open,
675 .release = hsc_release,
676};
677
678static void __devinit hsc_channel_init(struct hsc_channel *channel)
679{
680 init_waitqueue_head(&channel->rx_wait);
681 init_waitqueue_head(&channel->tx_wait);
682 spin_lock_init(&channel->lock);
683 INIT_LIST_HEAD(&channel->free_msgs_list);
684 INIT_LIST_HEAD(&channel->rx_msgs_queue);
685 INIT_LIST_HEAD(&channel->tx_msgs_queue);
686}
687
688static int __devinit hsc_probe(struct device *dev)
689{
690 const char devname[] = "hsi_char";
691 struct hsc_client_data *cl_data;
692 struct hsc_channel *channel;
693 struct hsi_client *cl = to_hsi_client(dev);
694 unsigned int hsc_baseminor;
695 dev_t hsc_dev;
696 int ret;
697 int i;
698
699 cl_data = kzalloc(sizeof(*cl_data), GFP_KERNEL);
700 if (!cl_data) {
701 dev_err(dev, "Could not allocate hsc_client_data\n");
702 return -ENOMEM;
703 }
704 hsc_baseminor = HSC_BASEMINOR(hsi_id(cl), hsi_port_id(cl));
705 if (!hsc_major) {
706 ret = alloc_chrdev_region(&hsc_dev, hsc_baseminor,
707 HSC_DEVS, devname);
708 if (ret > 0)
709 hsc_major = MAJOR(hsc_dev);
710 } else {
711 hsc_dev = MKDEV(hsc_major, hsc_baseminor);
712 ret = register_chrdev_region(hsc_dev, HSC_DEVS, devname);
713 }
714 if (ret < 0) {
715 dev_err(dev, "Device %s allocation failed %d\n",
716 hsc_major ? "minor" : "major", ret);
717 goto out1;
718 }
719 mutex_init(&cl_data->lock);
720 hsi_client_set_drvdata(cl, cl_data);
721 cdev_init(&cl_data->cdev, &hsc_fops);
722 cl_data->cdev.owner = THIS_MODULE;
723 cl_data->cl = cl;
724 for (i = 0, channel = cl_data->channels; i < HSC_DEVS; i++, channel++) {
725 hsc_channel_init(channel);
726 channel->ch = i;
727 channel->cl = cl;
728 channel->cl_data = cl_data;
729 }
730
731 /* 1 hsi client -> N char devices (one for each channel) */
732 ret = cdev_add(&cl_data->cdev, hsc_dev, HSC_DEVS);
733 if (ret) {
734 dev_err(dev, "Could not add char device %d\n", ret);
735 goto out2;
736 }
737
738 return 0;
739out2:
740 unregister_chrdev_region(hsc_dev, HSC_DEVS);
741out1:
742 kfree(cl_data);
743
744 return ret;
745}
746
747static int __devexit hsc_remove(struct device *dev)
748{
749 struct hsi_client *cl = to_hsi_client(dev);
750 struct hsc_client_data *cl_data = hsi_client_drvdata(cl);
751 dev_t hsc_dev = cl_data->cdev.dev;
752
753 cdev_del(&cl_data->cdev);
754 unregister_chrdev_region(hsc_dev, HSC_DEVS);
755 hsi_client_set_drvdata(cl, NULL);
756 kfree(cl_data);
757
758 return 0;
759}
760
761static struct hsi_client_driver hsc_driver = {
762 .driver = {
763 .name = "hsi_char",
764 .owner = THIS_MODULE,
765 .probe = hsc_probe,
766 .remove = __devexit_p(hsc_remove),
767 },
768};
769
770static int __init hsc_init(void)
771{
772 int ret;
773
774 if ((max_data_size < 4) || (max_data_size > 0x10000) ||
775 (max_data_size & (max_data_size - 1))) {
776 pr_err("Invalid max read/write data size");
777 return -EINVAL;
778 }
779
780 ret = hsi_register_client_driver(&hsc_driver);
781 if (ret) {
782 pr_err("Error while registering HSI/SSI driver %d", ret);
783 return ret;
784 }
785
786 pr_info("HSI/SSI char device loaded\n");
787
788 return 0;
789}
790module_init(hsc_init);
791
792static void __exit hsc_exit(void)
793{
794 hsi_unregister_client_driver(&hsc_driver);
795 pr_info("HSI char device removed\n");
796}
797module_exit(hsc_exit);
798
799MODULE_AUTHOR("Andras Domokos <andras.domokos@nokia.com>");
800MODULE_ALIAS("hsi:hsi_char");
801MODULE_DESCRIPTION("HSI character device");
802MODULE_LICENSE("GPL v2");
diff --git a/drivers/hsi/hsi.c b/drivers/hsi/hsi.c
new file mode 100644
index 000000000000..4e2d79b79334
--- /dev/null
+++ b/drivers/hsi/hsi.c
@@ -0,0 +1,494 @@
1/*
2 * HSI core.
3 *
4 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
5 *
6 * Contact: Carlos Chinea <carlos.chinea@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22#include <linux/hsi/hsi.h>
23#include <linux/compiler.h>
24#include <linux/rwsem.h>
25#include <linux/list.h>
26#include <linux/spinlock.h>
27#include <linux/kobject.h>
28#include <linux/slab.h>
29#include <linux/string.h>
30#include "hsi_core.h"
31
32static struct device_type hsi_ctrl = {
33 .name = "hsi_controller",
34};
35
36static struct device_type hsi_cl = {
37 .name = "hsi_client",
38};
39
40static struct device_type hsi_port = {
41 .name = "hsi_port",
42};
43
44static ssize_t modalias_show(struct device *dev,
45 struct device_attribute *a __maybe_unused, char *buf)
46{
47 return sprintf(buf, "hsi:%s\n", dev_name(dev));
48}
49
50static struct device_attribute hsi_bus_dev_attrs[] = {
51 __ATTR_RO(modalias),
52 __ATTR_NULL,
53};
54
55static int hsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
56{
57 if (dev->type == &hsi_cl)
58 add_uevent_var(env, "MODALIAS=hsi:%s", dev_name(dev));
59
60 return 0;
61}
62
63static int hsi_bus_match(struct device *dev, struct device_driver *driver)
64{
65 return strcmp(dev_name(dev), driver->name) == 0;
66}
67
68static struct bus_type hsi_bus_type = {
69 .name = "hsi",
70 .dev_attrs = hsi_bus_dev_attrs,
71 .match = hsi_bus_match,
72 .uevent = hsi_bus_uevent,
73};
74
75static void hsi_client_release(struct device *dev)
76{
77 kfree(to_hsi_client(dev));
78}
79
80static void hsi_new_client(struct hsi_port *port, struct hsi_board_info *info)
81{
82 struct hsi_client *cl;
83 unsigned long flags;
84
85 cl = kzalloc(sizeof(*cl), GFP_KERNEL);
86 if (!cl)
87 return;
88 cl->device.type = &hsi_cl;
89 cl->tx_cfg = info->tx_cfg;
90 cl->rx_cfg = info->rx_cfg;
91 cl->device.bus = &hsi_bus_type;
92 cl->device.parent = &port->device;
93 cl->device.release = hsi_client_release;
94 dev_set_name(&cl->device, info->name);
95 cl->device.platform_data = info->platform_data;
96 spin_lock_irqsave(&port->clock, flags);
97 list_add_tail(&cl->link, &port->clients);
98 spin_unlock_irqrestore(&port->clock, flags);
99 if (info->archdata)
100 cl->device.archdata = *info->archdata;
101 if (device_register(&cl->device) < 0) {
102 pr_err("hsi: failed to register client: %s\n", info->name);
103 kfree(cl);
104 }
105}
106
107static void hsi_scan_board_info(struct hsi_controller *hsi)
108{
109 struct hsi_cl_info *cl_info;
110 struct hsi_port *p;
111
112 list_for_each_entry(cl_info, &hsi_board_list, list)
113 if (cl_info->info.hsi_id == hsi->id) {
114 p = hsi_find_port_num(hsi, cl_info->info.port);
115 if (!p)
116 continue;
117 hsi_new_client(p, &cl_info->info);
118 }
119}
120
121static int hsi_remove_client(struct device *dev, void *data __maybe_unused)
122{
123 struct hsi_client *cl = to_hsi_client(dev);
124 struct hsi_port *port = to_hsi_port(dev->parent);
125 unsigned long flags;
126
127 spin_lock_irqsave(&port->clock, flags);
128 list_del(&cl->link);
129 spin_unlock_irqrestore(&port->clock, flags);
130 device_unregister(dev);
131
132 return 0;
133}
134
135static int hsi_remove_port(struct device *dev, void *data __maybe_unused)
136{
137 device_for_each_child(dev, NULL, hsi_remove_client);
138 device_unregister(dev);
139
140 return 0;
141}
142
143static void hsi_controller_release(struct device *dev __maybe_unused)
144{
145}
146
147static void hsi_port_release(struct device *dev __maybe_unused)
148{
149}
150
151/**
152 * hsi_unregister_controller - Unregister an HSI controller
153 * @hsi: The HSI controller to register
154 */
155void hsi_unregister_controller(struct hsi_controller *hsi)
156{
157 device_for_each_child(&hsi->device, NULL, hsi_remove_port);
158 device_unregister(&hsi->device);
159}
160EXPORT_SYMBOL_GPL(hsi_unregister_controller);
161
162/**
163 * hsi_register_controller - Register an HSI controller and its ports
164 * @hsi: The HSI controller to register
165 *
166 * Returns -errno on failure, 0 on success.
167 */
168int hsi_register_controller(struct hsi_controller *hsi)
169{
170 unsigned int i;
171 int err;
172
173 hsi->device.type = &hsi_ctrl;
174 hsi->device.bus = &hsi_bus_type;
175 hsi->device.release = hsi_controller_release;
176 err = device_register(&hsi->device);
177 if (err < 0)
178 return err;
179 for (i = 0; i < hsi->num_ports; i++) {
180 hsi->port[i].device.parent = &hsi->device;
181 hsi->port[i].device.bus = &hsi_bus_type;
182 hsi->port[i].device.release = hsi_port_release;
183 hsi->port[i].device.type = &hsi_port;
184 INIT_LIST_HEAD(&hsi->port[i].clients);
185 spin_lock_init(&hsi->port[i].clock);
186 err = device_register(&hsi->port[i].device);
187 if (err < 0)
188 goto out;
189 }
190 /* Populate HSI bus with HSI clients */
191 hsi_scan_board_info(hsi);
192
193 return 0;
194out:
195 hsi_unregister_controller(hsi);
196
197 return err;
198}
199EXPORT_SYMBOL_GPL(hsi_register_controller);
200
201/**
202 * hsi_register_client_driver - Register an HSI client to the HSI bus
203 * @drv: HSI client driver to register
204 *
205 * Returns -errno on failure, 0 on success.
206 */
207int hsi_register_client_driver(struct hsi_client_driver *drv)
208{
209 drv->driver.bus = &hsi_bus_type;
210
211 return driver_register(&drv->driver);
212}
213EXPORT_SYMBOL_GPL(hsi_register_client_driver);
214
215static inline int hsi_dummy_msg(struct hsi_msg *msg __maybe_unused)
216{
217 return 0;
218}
219
220static inline int hsi_dummy_cl(struct hsi_client *cl __maybe_unused)
221{
222 return 0;
223}
224
225/**
226 * hsi_alloc_controller - Allocate an HSI controller and its ports
227 * @n_ports: Number of ports on the HSI controller
228 * @flags: Kernel allocation flags
229 *
230 * Return NULL on failure or a pointer to an hsi_controller on success.
231 */
232struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags)
233{
234 struct hsi_controller *hsi;
235 struct hsi_port *port;
236 unsigned int i;
237
238 if (!n_ports)
239 return NULL;
240
241 port = kzalloc(sizeof(*port)*n_ports, flags);
242 if (!port)
243 return NULL;
244 hsi = kzalloc(sizeof(*hsi), flags);
245 if (!hsi)
246 goto out;
247 for (i = 0; i < n_ports; i++) {
248 dev_set_name(&port[i].device, "port%d", i);
249 port[i].num = i;
250 port[i].async = hsi_dummy_msg;
251 port[i].setup = hsi_dummy_cl;
252 port[i].flush = hsi_dummy_cl;
253 port[i].start_tx = hsi_dummy_cl;
254 port[i].stop_tx = hsi_dummy_cl;
255 port[i].release = hsi_dummy_cl;
256 mutex_init(&port[i].lock);
257 }
258 hsi->num_ports = n_ports;
259 hsi->port = port;
260
261 return hsi;
262out:
263 kfree(port);
264
265 return NULL;
266}
267EXPORT_SYMBOL_GPL(hsi_alloc_controller);
268
269/**
270 * hsi_free_controller - Free an HSI controller
271 * @hsi: Pointer to HSI controller
272 */
273void hsi_free_controller(struct hsi_controller *hsi)
274{
275 if (!hsi)
276 return;
277
278 kfree(hsi->port);
279 kfree(hsi);
280}
281EXPORT_SYMBOL_GPL(hsi_free_controller);
282
283/**
284 * hsi_free_msg - Free an HSI message
285 * @msg: Pointer to the HSI message
286 *
287 * Client is responsible to free the buffers pointed by the scatterlists.
288 */
289void hsi_free_msg(struct hsi_msg *msg)
290{
291 if (!msg)
292 return;
293 sg_free_table(&msg->sgt);
294 kfree(msg);
295}
296EXPORT_SYMBOL_GPL(hsi_free_msg);
297
298/**
299 * hsi_alloc_msg - Allocate an HSI message
300 * @nents: Number of memory entries
301 * @flags: Kernel allocation flags
302 *
303 * nents can be 0. This mainly makes sense for read transfer.
304 * In that case, HSI drivers will call the complete callback when
305 * there is data to be read without consuming it.
306 *
307 * Return NULL on failure or a pointer to an hsi_msg on success.
308 */
309struct hsi_msg *hsi_alloc_msg(unsigned int nents, gfp_t flags)
310{
311 struct hsi_msg *msg;
312 int err;
313
314 msg = kzalloc(sizeof(*msg), flags);
315 if (!msg)
316 return NULL;
317
318 if (!nents)
319 return msg;
320
321 err = sg_alloc_table(&msg->sgt, nents, flags);
322 if (unlikely(err)) {
323 kfree(msg);
324 msg = NULL;
325 }
326
327 return msg;
328}
329EXPORT_SYMBOL_GPL(hsi_alloc_msg);
330
331/**
332 * hsi_async - Submit an HSI transfer to the controller
333 * @cl: HSI client sending the transfer
334 * @msg: The HSI transfer passed to controller
335 *
336 * The HSI message must have the channel, ttype, complete and destructor
337 * fields set beforehand. If nents > 0 then the client has to initialize
338 * also the scatterlists to point to the buffers to write to or read from.
339 *
340 * HSI controllers relay on pre-allocated buffers from their clients and they
341 * do not allocate buffers on their own.
342 *
343 * Once the HSI message transfer finishes, the HSI controller calls the
344 * complete callback with the status and actual_len fields of the HSI message
345 * updated. The complete callback can be called before returning from
346 * hsi_async.
347 *
348 * Returns -errno on failure or 0 on success
349 */
350int hsi_async(struct hsi_client *cl, struct hsi_msg *msg)
351{
352 struct hsi_port *port = hsi_get_port(cl);
353
354 if (!hsi_port_claimed(cl))
355 return -EACCES;
356
357 WARN_ON_ONCE(!msg->destructor || !msg->complete);
358 msg->cl = cl;
359
360 return port->async(msg);
361}
362EXPORT_SYMBOL_GPL(hsi_async);
363
364/**
365 * hsi_claim_port - Claim the HSI client's port
366 * @cl: HSI client that wants to claim its port
367 * @share: Flag to indicate if the client wants to share the port or not.
368 *
369 * Returns -errno on failure, 0 on success.
370 */
371int hsi_claim_port(struct hsi_client *cl, unsigned int share)
372{
373 struct hsi_port *port = hsi_get_port(cl);
374 int err = 0;
375
376 mutex_lock(&port->lock);
377 if ((port->claimed) && (!port->shared || !share)) {
378 err = -EBUSY;
379 goto out;
380 }
381 if (!try_module_get(to_hsi_controller(port->device.parent)->owner)) {
382 err = -ENODEV;
383 goto out;
384 }
385 port->claimed++;
386 port->shared = !!share;
387 cl->pclaimed = 1;
388out:
389 mutex_unlock(&port->lock);
390
391 return err;
392}
393EXPORT_SYMBOL_GPL(hsi_claim_port);
394
395/**
396 * hsi_release_port - Release the HSI client's port
397 * @cl: HSI client which previously claimed its port
398 */
399void hsi_release_port(struct hsi_client *cl)
400{
401 struct hsi_port *port = hsi_get_port(cl);
402
403 mutex_lock(&port->lock);
404 /* Allow HW driver to do some cleanup */
405 port->release(cl);
406 if (cl->pclaimed)
407 port->claimed--;
408 BUG_ON(port->claimed < 0);
409 cl->pclaimed = 0;
410 if (!port->claimed)
411 port->shared = 0;
412 module_put(to_hsi_controller(port->device.parent)->owner);
413 mutex_unlock(&port->lock);
414}
415EXPORT_SYMBOL_GPL(hsi_release_port);
416
417static int hsi_start_rx(struct hsi_client *cl, void *data __maybe_unused)
418{
419 if (cl->hsi_start_rx)
420 (*cl->hsi_start_rx)(cl);
421
422 return 0;
423}
424
425static int hsi_stop_rx(struct hsi_client *cl, void *data __maybe_unused)
426{
427 if (cl->hsi_stop_rx)
428 (*cl->hsi_stop_rx)(cl);
429
430 return 0;
431}
432
433static int hsi_port_for_each_client(struct hsi_port *port, void *data,
434 int (*fn)(struct hsi_client *cl, void *data))
435{
436 struct hsi_client *cl;
437
438 spin_lock(&port->clock);
439 list_for_each_entry(cl, &port->clients, link) {
440 spin_unlock(&port->clock);
441 (*fn)(cl, data);
442 spin_lock(&port->clock);
443 }
444 spin_unlock(&port->clock);
445
446 return 0;
447}
448
449/**
450 * hsi_event -Notifies clients about port events
451 * @port: Port where the event occurred
452 * @event: The event type
453 *
454 * Clients should not be concerned about wake line behavior. However, due
455 * to a race condition in HSI HW protocol, clients need to be notified
456 * about wake line changes, so they can implement a workaround for it.
457 *
458 * Events:
459 * HSI_EVENT_START_RX - Incoming wake line high
460 * HSI_EVENT_STOP_RX - Incoming wake line down
461 */
462void hsi_event(struct hsi_port *port, unsigned int event)
463{
464 int (*fn)(struct hsi_client *cl, void *data);
465
466 switch (event) {
467 case HSI_EVENT_START_RX:
468 fn = hsi_start_rx;
469 break;
470 case HSI_EVENT_STOP_RX:
471 fn = hsi_stop_rx;
472 break;
473 default:
474 return;
475 }
476 hsi_port_for_each_client(port, NULL, fn);
477}
478EXPORT_SYMBOL_GPL(hsi_event);
479
480static int __init hsi_init(void)
481{
482 return bus_register(&hsi_bus_type);
483}
484postcore_initcall(hsi_init);
485
486static void __exit hsi_exit(void)
487{
488 bus_unregister(&hsi_bus_type);
489}
490module_exit(hsi_exit);
491
492MODULE_AUTHOR("Carlos Chinea <carlos.chinea@nokia.com>");
493MODULE_DESCRIPTION("High-speed Synchronous Serial Interface (HSI) framework");
494MODULE_LICENSE("GPL v2");
diff --git a/drivers/hsi/hsi_boardinfo.c b/drivers/hsi/hsi_boardinfo.c
new file mode 100644
index 000000000000..e56bc6da5f98
--- /dev/null
+++ b/drivers/hsi/hsi_boardinfo.c
@@ -0,0 +1,62 @@
1/*
2 * HSI clients registration interface
3 *
4 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
5 *
6 * Contact: Carlos Chinea <carlos.chinea@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22#include <linux/hsi/hsi.h>
23#include <linux/list.h>
24#include <linux/slab.h>
25#include "hsi_core.h"
26
27/*
28 * hsi_board_list is only used internally by the HSI framework.
29 * No one else is allowed to make use of it.
30 */
31LIST_HEAD(hsi_board_list);
32EXPORT_SYMBOL_GPL(hsi_board_list);
33
34/**
35 * hsi_register_board_info - Register HSI clients information
36 * @info: Array of HSI clients on the board
37 * @len: Length of the array
38 *
39 * HSI clients are statically declared and registered on board files.
40 *
41 * HSI clients will be automatically registered to the HSI bus once the
42 * controller and the port where the clients wishes to attach are registered
43 * to it.
44 *
45 * Return -errno on failure, 0 on success.
46 */
47int __init hsi_register_board_info(struct hsi_board_info const *info,
48 unsigned int len)
49{
50 struct hsi_cl_info *cl_info;
51
52 cl_info = kzalloc(sizeof(*cl_info) * len, GFP_KERNEL);
53 if (!cl_info)
54 return -ENOMEM;
55
56 for (; len; len--, info++, cl_info++) {
57 cl_info->info = *info;
58 list_add_tail(&cl_info->list, &hsi_board_list);
59 }
60
61 return 0;
62}
diff --git a/drivers/hsi/hsi_core.h b/drivers/hsi/hsi_core.h
new file mode 100644
index 000000000000..ab5c2fb175fd
--- /dev/null
+++ b/drivers/hsi/hsi_core.h
@@ -0,0 +1,35 @@
1/*
2 * HSI framework internal interfaces,
3 *
4 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
5 *
6 * Contact: Carlos Chinea <carlos.chinea@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22
23#ifndef __LINUX_HSI_CORE_H__
24#define __LINUX_HSI_CORE_H__
25
26#include <linux/hsi/hsi.h>
27
28struct hsi_cl_info {
29 struct list_head list;
30 struct hsi_board_info info;
31};
32
33extern struct list_head hsi_board_list;
34
35#endif /* __LINUX_HSI_CORE_H__ */
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 5b32d56dbb4d..8deedc1b9840 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -253,7 +253,8 @@ config SENSORS_K10TEMP
253 If you say yes here you get support for the temperature 253 If you say yes here you get support for the temperature
254 sensor(s) inside your CPU. Supported are later revisions of 254 sensor(s) inside your CPU. Supported are later revisions of
255 the AMD Family 10h and all revisions of the AMD Family 11h, 255 the AMD Family 10h and all revisions of the AMD Family 11h,
256 12h (Llano), 14h (Brazos) and 15h (Bulldozer) microarchitectures. 256 12h (Llano), 14h (Brazos) and 15h (Bulldozer/Trinity)
257 microarchitectures.
257 258
258 This driver can also be built as a module. If so, the module 259 This driver can also be built as a module. If so, the module
259 will be called k10temp. 260 will be called k10temp.
@@ -425,7 +426,7 @@ config SENSORS_GL520SM
425 426
426config SENSORS_GPIO_FAN 427config SENSORS_GPIO_FAN
427 tristate "GPIO fan" 428 tristate "GPIO fan"
428 depends on GENERIC_GPIO 429 depends on GPIOLIB
429 help 430 help
430 If you say yes here you get support for fans connected to GPIO lines. 431 If you say yes here you get support for fans connected to GPIO lines.
431 432
@@ -883,7 +884,7 @@ source drivers/hwmon/pmbus/Kconfig
883 884
884config SENSORS_SHT15 885config SENSORS_SHT15
885 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." 886 tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
886 depends on GENERIC_GPIO 887 depends on GPIOLIB
887 help 888 help
888 If you say yes here you get support for the Sensiron SHT10, SHT11, 889 If you say yes here you get support for the Sensiron SHT10, SHT11,
889 SHT15, SHT71, SHT75 humidity and temperature sensors. 890 SHT15, SHT71, SHT75 humidity and temperature sensors.
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 554f046bcf20..145f13580ff0 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -632,6 +632,7 @@ static int register_ro_attrs(struct acpi_power_meter_resource *resource,
632 sensors->dev_attr.show = ro->show; 632 sensors->dev_attr.show = ro->show;
633 sensors->index = ro->index; 633 sensors->index = ro->index;
634 634
635 sysfs_attr_init(&sensors->dev_attr.attr);
635 res = device_create_file(dev, &sensors->dev_attr); 636 res = device_create_file(dev, &sensors->dev_attr);
636 if (res) { 637 if (res) {
637 sensors->dev_attr.attr.name = NULL; 638 sensors->dev_attr.attr.name = NULL;
@@ -661,6 +662,7 @@ static int register_rw_attrs(struct acpi_power_meter_resource *resource,
661 sensors->dev_attr.store = rw->set; 662 sensors->dev_attr.store = rw->set;
662 sensors->index = rw->index; 663 sensors->index = rw->index;
663 664
665 sysfs_attr_init(&sensors->dev_attr.attr);
664 res = device_create_file(dev, &sensors->dev_attr); 666 res = device_create_file(dev, &sensors->dev_attr);
665 if (res) { 667 if (res) {
666 sensors->dev_attr.attr.name = NULL; 668 sensors->dev_attr.attr.name = NULL;
diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c
index 0e0cfcc36f8d..ce43642ef03e 100644
--- a/drivers/hwmon/ad7314.c
+++ b/drivers/hwmon/ad7314.c
@@ -128,6 +128,7 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)
128 ret = PTR_ERR(chip->hwmon_dev); 128 ret = PTR_ERR(chip->hwmon_dev);
129 goto error_remove_group; 129 goto error_remove_group;
130 } 130 }
131 chip->spi_dev = spi_dev;
131 132
132 return 0; 133 return 0;
133error_remove_group: 134error_remove_group:
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index ff37363ea5bc..44e1fd7f3d81 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -233,18 +233,15 @@ static const auto_chan_table_t auto_channel_select_table_adm1030 = {
233 * nearest match if no exact match where found. 233 * nearest match if no exact match where found.
234 */ 234 */
235static int 235static int
236get_fan_auto_nearest(struct adm1031_data *data, 236get_fan_auto_nearest(struct adm1031_data *data, int chan, u8 val, u8 reg)
237 int chan, u8 val, u8 reg, u8 *new_reg)
238{ 237{
239 int i; 238 int i;
240 int first_match = -1, exact_match = -1; 239 int first_match = -1, exact_match = -1;
241 u8 other_reg_val = 240 u8 other_reg_val =
242 (*data->chan_select_table)[FAN_CHAN_FROM_REG(reg)][chan ? 0 : 1]; 241 (*data->chan_select_table)[FAN_CHAN_FROM_REG(reg)][chan ? 0 : 1];
243 242
244 if (val == 0) { 243 if (val == 0)
245 *new_reg = 0;
246 return 0; 244 return 0;
247 }
248 245
249 for (i = 0; i < 8; i++) { 246 for (i = 0; i < 8; i++) {
250 if ((val == (*data->chan_select_table)[i][chan]) && 247 if ((val == (*data->chan_select_table)[i][chan]) &&
@@ -264,13 +261,11 @@ get_fan_auto_nearest(struct adm1031_data *data,
264 } 261 }
265 262
266 if (exact_match >= 0) 263 if (exact_match >= 0)
267 *new_reg = exact_match; 264 return exact_match;
268 else if (first_match >= 0) 265 else if (first_match >= 0)
269 *new_reg = first_match; 266 return first_match;
270 else
271 return -EINVAL;
272 267
273 return 0; 268 return -EINVAL;
274} 269}
275 270
276static ssize_t show_fan_auto_channel(struct device *dev, 271static ssize_t show_fan_auto_channel(struct device *dev,
@@ -301,11 +296,12 @@ set_fan_auto_channel(struct device *dev, struct device_attribute *attr,
301 296
302 mutex_lock(&data->update_lock); 297 mutex_lock(&data->update_lock);
303 298
304 ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg); 299 ret = get_fan_auto_nearest(data, nr, val, data->conf1);
305 if (ret) { 300 if (ret < 0) {
306 mutex_unlock(&data->update_lock); 301 mutex_unlock(&data->update_lock);
307 return ret; 302 return ret;
308 } 303 }
304 reg = ret;
309 data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); 305 data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1);
310 if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) ^ 306 if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) ^
311 (old_fan_mode & ADM1031_CONF1_AUTO_MODE)) { 307 (old_fan_mode & ADM1031_CONF1_AUTO_MODE)) {
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 729499e75210..ece4159bd453 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -276,6 +276,7 @@ static bool duty_mode_enabled(u8 pwm_enable)
276 return false; 276 return false;
277 default: 277 default:
278 BUG(); 278 BUG();
279 return true;
279 } 280 }
280} 281}
281 282
@@ -291,6 +292,7 @@ static bool auto_mode_enabled(u8 pwm_enable)
291 return true; 292 return true;
292 default: 293 default:
293 BUG(); 294 BUG();
295 return false;
294 } 296 }
295} 297}
296 298
diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
index aba29d63f195..307bb325dde9 100644
--- a/drivers/hwmon/k10temp.c
+++ b/drivers/hwmon/k10temp.c
@@ -33,6 +33,9 @@ static bool force;
33module_param(force, bool, 0444); 33module_param(force, bool, 0444);
34MODULE_PARM_DESC(force, "force loading on processors with erratum 319"); 34MODULE_PARM_DESC(force, "force loading on processors with erratum 319");
35 35
36/* PCI-IDs for Northbridge devices not used anywhere else */
37#define PCI_DEVICE_ID_AMD_15H_M10H_NB_F3 0x1403
38
36/* CPUID function 0x80000001, ebx */ 39/* CPUID function 0x80000001, ebx */
37#define CPUID_PKGTYPE_MASK 0xf0000000 40#define CPUID_PKGTYPE_MASK 0xf0000000
38#define CPUID_PKGTYPE_F 0x00000000 41#define CPUID_PKGTYPE_F 0x00000000
@@ -210,6 +213,7 @@ static DEFINE_PCI_DEVICE_TABLE(k10temp_id_table) = {
210 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) }, 213 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
211 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) }, 214 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
212 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) }, 215 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) },
216 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M10H_NB_F3) },
213 {} 217 {}
214}; 218};
215MODULE_DEVICE_TABLE(pci, k10temp_id_table); 219MODULE_DEVICE_TABLE(pci, k10temp_id_table);
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c
index 193067e27b6f..de8f7adaccbd 100644
--- a/drivers/hwmon/max6639.c
+++ b/drivers/hwmon/max6639.c
@@ -596,8 +596,10 @@ static int max6639_remove(struct i2c_client *client)
596 return 0; 596 return 0;
597} 597}
598 598
599static int max6639_suspend(struct i2c_client *client, pm_message_t mesg) 599#ifdef CONFIG_PM_SLEEP
600static int max6639_suspend(struct device *dev)
600{ 601{
602 struct i2c_client *client = to_i2c_client(dev);
601 int data = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG); 603 int data = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG);
602 if (data < 0) 604 if (data < 0)
603 return data; 605 return data;
@@ -606,8 +608,9 @@ static int max6639_suspend(struct i2c_client *client, pm_message_t mesg)
606 MAX6639_REG_GCONFIG, data | MAX6639_GCONFIG_STANDBY); 608 MAX6639_REG_GCONFIG, data | MAX6639_GCONFIG_STANDBY);
607} 609}
608 610
609static int max6639_resume(struct i2c_client *client) 611static int max6639_resume(struct device *dev)
610{ 612{
613 struct i2c_client *client = to_i2c_client(dev);
611 int data = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG); 614 int data = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG);
612 if (data < 0) 615 if (data < 0)
613 return data; 616 return data;
@@ -615,6 +618,7 @@ static int max6639_resume(struct i2c_client *client)
615 return i2c_smbus_write_byte_data(client, 618 return i2c_smbus_write_byte_data(client,
616 MAX6639_REG_GCONFIG, data & ~MAX6639_GCONFIG_STANDBY); 619 MAX6639_REG_GCONFIG, data & ~MAX6639_GCONFIG_STANDBY);
617} 620}
621#endif /* CONFIG_PM_SLEEP */
618 622
619static const struct i2c_device_id max6639_id[] = { 623static const struct i2c_device_id max6639_id[] = {
620 {"max6639", 0}, 624 {"max6639", 0},
@@ -623,15 +627,18 @@ static const struct i2c_device_id max6639_id[] = {
623 627
624MODULE_DEVICE_TABLE(i2c, max6639_id); 628MODULE_DEVICE_TABLE(i2c, max6639_id);
625 629
630static const struct dev_pm_ops max6639_pm_ops = {
631 SET_SYSTEM_SLEEP_PM_OPS(max6639_suspend, max6639_resume)
632};
633
626static struct i2c_driver max6639_driver = { 634static struct i2c_driver max6639_driver = {
627 .class = I2C_CLASS_HWMON, 635 .class = I2C_CLASS_HWMON,
628 .driver = { 636 .driver = {
629 .name = "max6639", 637 .name = "max6639",
638 .pm = &max6639_pm_ops,
630 }, 639 },
631 .probe = max6639_probe, 640 .probe = max6639_probe,
632 .remove = max6639_remove, 641 .remove = max6639_remove,
633 .suspend = max6639_suspend,
634 .resume = max6639_resume,
635 .id_table = max6639_id, 642 .id_table = max6639_id,
636 .detect = max6639_detect, 643 .detect = max6639_detect,
637 .address_list = normal_i2c, 644 .address_list = normal_i2c,
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index a25350cf9554..54922ed12978 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -2619,15 +2619,15 @@ static struct platform_driver w83627ehf_driver = {
2619static int __init w83627ehf_find(int sioaddr, unsigned short *addr, 2619static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
2620 struct w83627ehf_sio_data *sio_data) 2620 struct w83627ehf_sio_data *sio_data)
2621{ 2621{
2622 static const char __initdata sio_name_W83627EHF[] = "W83627EHF"; 2622 static const char sio_name_W83627EHF[] __initconst = "W83627EHF";
2623 static const char __initdata sio_name_W83627EHG[] = "W83627EHG"; 2623 static const char sio_name_W83627EHG[] __initconst = "W83627EHG";
2624 static const char __initdata sio_name_W83627DHG[] = "W83627DHG"; 2624 static const char sio_name_W83627DHG[] __initconst = "W83627DHG";
2625 static const char __initdata sio_name_W83627DHG_P[] = "W83627DHG-P"; 2625 static const char sio_name_W83627DHG_P[] __initconst = "W83627DHG-P";
2626 static const char __initdata sio_name_W83627UHG[] = "W83627UHG"; 2626 static const char sio_name_W83627UHG[] __initconst = "W83627UHG";
2627 static const char __initdata sio_name_W83667HG[] = "W83667HG"; 2627 static const char sio_name_W83667HG[] __initconst = "W83667HG";
2628 static const char __initdata sio_name_W83667HG_B[] = "W83667HG-B"; 2628 static const char sio_name_W83667HG_B[] __initconst = "W83667HG-B";
2629 static const char __initdata sio_name_NCT6775[] = "NCT6775F"; 2629 static const char sio_name_NCT6775[] __initconst = "NCT6775F";
2630 static const char __initdata sio_name_NCT6776[] = "NCT6776F"; 2630 static const char sio_name_NCT6776[] __initconst = "NCT6776F";
2631 2631
2632 u16 val; 2632 u16 val;
2633 const char *sio_name; 2633 const char *sio_name;
diff --git a/drivers/idle/i7300_idle.c b/drivers/idle/i7300_idle.c
index c976285d313e..fa080ebd568f 100644
--- a/drivers/idle/i7300_idle.c
+++ b/drivers/idle/i7300_idle.c
@@ -516,12 +516,6 @@ static struct notifier_block i7300_idle_nb = {
516 516
517MODULE_DEVICE_TABLE(pci, pci_tbl); 517MODULE_DEVICE_TABLE(pci, pci_tbl);
518 518
519int stats_open_generic(struct inode *inode, struct file *fp)
520{
521 fp->private_data = inode->i_private;
522 return 0;
523}
524
525static ssize_t stats_read_ul(struct file *fp, char __user *ubuf, size_t count, 519static ssize_t stats_read_ul(struct file *fp, char __user *ubuf, size_t count,
526 loff_t *off) 520 loff_t *off)
527{ 521{
@@ -534,7 +528,7 @@ static ssize_t stats_read_ul(struct file *fp, char __user *ubuf, size_t count,
534} 528}
535 529
536static const struct file_operations idle_fops = { 530static const struct file_operations idle_fops = {
537 .open = stats_open_generic, 531 .open = simple_open,
538 .read = stats_read_ul, 532 .read = stats_read_ul,
539 .llseek = default_llseek, 533 .llseek = default_llseek,
540}; 534};
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index ae2ec929e52f..a5bee8e2dfce 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2707,7 +2707,8 @@ static void unmap_sg(struct device *dev, struct scatterlist *sglist,
2707 * The exported alloc_coherent function for dma_ops. 2707 * The exported alloc_coherent function for dma_ops.
2708 */ 2708 */
2709static void *alloc_coherent(struct device *dev, size_t size, 2709static void *alloc_coherent(struct device *dev, size_t size,
2710 dma_addr_t *dma_addr, gfp_t flag) 2710 dma_addr_t *dma_addr, gfp_t flag,
2711 struct dma_attrs *attrs)
2711{ 2712{
2712 unsigned long flags; 2713 unsigned long flags;
2713 void *virt_addr; 2714 void *virt_addr;
@@ -2765,7 +2766,8 @@ out_free:
2765 * The exported free_coherent function for dma_ops. 2766 * The exported free_coherent function for dma_ops.
2766 */ 2767 */
2767static void free_coherent(struct device *dev, size_t size, 2768static void free_coherent(struct device *dev, size_t size,
2768 void *virt_addr, dma_addr_t dma_addr) 2769 void *virt_addr, dma_addr_t dma_addr,
2770 struct dma_attrs *attrs)
2769{ 2771{
2770 unsigned long flags; 2772 unsigned long flags;
2771 struct protection_domain *domain; 2773 struct protection_domain *domain;
@@ -2846,8 +2848,8 @@ static void __init prealloc_protection_domains(void)
2846} 2848}
2847 2849
2848static struct dma_map_ops amd_iommu_dma_ops = { 2850static struct dma_map_ops amd_iommu_dma_ops = {
2849 .alloc_coherent = alloc_coherent, 2851 .alloc = alloc_coherent,
2850 .free_coherent = free_coherent, 2852 .free = free_coherent,
2851 .map_page = map_page, 2853 .map_page = map_page,
2852 .unmap_page = unmap_page, 2854 .unmap_page = unmap_page,
2853 .map_sg = map_sg, 2855 .map_sg = map_sg,
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 132f93b05154..f93d5ac8f81c 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2949,7 +2949,8 @@ static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr,
2949} 2949}
2950 2950
2951static void *intel_alloc_coherent(struct device *hwdev, size_t size, 2951static void *intel_alloc_coherent(struct device *hwdev, size_t size,
2952 dma_addr_t *dma_handle, gfp_t flags) 2952 dma_addr_t *dma_handle, gfp_t flags,
2953 struct dma_attrs *attrs)
2953{ 2954{
2954 void *vaddr; 2955 void *vaddr;
2955 int order; 2956 int order;
@@ -2981,7 +2982,7 @@ static void *intel_alloc_coherent(struct device *hwdev, size_t size,
2981} 2982}
2982 2983
2983static void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr, 2984static void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr,
2984 dma_addr_t dma_handle) 2985 dma_addr_t dma_handle, struct dma_attrs *attrs)
2985{ 2986{
2986 int order; 2987 int order;
2987 2988
@@ -3126,8 +3127,8 @@ static int intel_mapping_error(struct device *dev, dma_addr_t dma_addr)
3126} 3127}
3127 3128
3128struct dma_map_ops intel_dma_ops = { 3129struct dma_map_ops intel_dma_ops = {
3129 .alloc_coherent = intel_alloc_coherent, 3130 .alloc = intel_alloc_coherent,
3130 .free_coherent = intel_free_coherent, 3131 .free = intel_free_coherent,
3131 .map_sg = intel_map_sg, 3132 .map_sg = intel_map_sg,
3132 .unmap_sg = intel_unmap_sg, 3133 .unmap_sg = intel_unmap_sg,
3133 .map_page = intel_map_page, 3134 .map_page = intel_map_page,
diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index 103dbd92e256..f55fc5dfbadc 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -323,15 +323,9 @@ err_out:
323 return count; 323 return count;
324} 324}
325 325
326static int debug_open_generic(struct inode *inode, struct file *file)
327{
328 file->private_data = inode->i_private;
329 return 0;
330}
331
332#define DEBUG_FOPS(name) \ 326#define DEBUG_FOPS(name) \
333 static const struct file_operations debug_##name##_fops = { \ 327 static const struct file_operations debug_##name##_fops = { \
334 .open = debug_open_generic, \ 328 .open = simple_open, \
335 .read = debug_read_##name, \ 329 .read = debug_read_##name, \
336 .write = debug_write_##name, \ 330 .write = debug_write_##name, \
337 .llseek = generic_file_llseek, \ 331 .llseek = generic_file_llseek, \
@@ -339,7 +333,7 @@ static int debug_open_generic(struct inode *inode, struct file *file)
339 333
340#define DEBUG_FOPS_RO(name) \ 334#define DEBUG_FOPS_RO(name) \
341 static const struct file_operations debug_##name##_fops = { \ 335 static const struct file_operations debug_##name##_fops = { \
342 .open = debug_open_generic, \ 336 .open = simple_open, \
343 .read = debug_read_##name, \ 337 .read = debug_read_##name, \
344 .llseek = generic_file_llseek, \ 338 .llseek = generic_file_llseek, \
345 }; 339 };
diff --git a/drivers/isdn/hardware/mISDN/avmfritz.c b/drivers/isdn/hardware/mISDN/avmfritz.c
index 05ed4d0cb18b..c0b8c960ee3f 100644
--- a/drivers/isdn/hardware/mISDN/avmfritz.c
+++ b/drivers/isdn/hardware/mISDN/avmfritz.c
@@ -891,7 +891,7 @@ open_bchannel(struct fritzcard *fc, struct channel_req *rq)
891{ 891{
892 struct bchannel *bch; 892 struct bchannel *bch;
893 893
894 if (rq->adr.channel > 2) 894 if (rq->adr.channel == 0 || rq->adr.channel > 2)
895 return -EINVAL; 895 return -EINVAL;
896 if (rq->protocol == ISDN_P_NONE) 896 if (rq->protocol == ISDN_P_NONE)
897 return -EINVAL; 897 return -EINVAL;
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index d055ae7fa040..e2c83a2d7691 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -1962,7 +1962,7 @@ open_bchannel(struct hfc_pci *hc, struct channel_req *rq)
1962{ 1962{
1963 struct bchannel *bch; 1963 struct bchannel *bch;
1964 1964
1965 if (rq->adr.channel > 2) 1965 if (rq->adr.channel == 0 || rq->adr.channel > 2)
1966 return -EINVAL; 1966 return -EINVAL;
1967 if (rq->protocol == ISDN_P_NONE) 1967 if (rq->protocol == ISDN_P_NONE)
1968 return -EINVAL; 1968 return -EINVAL;
diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c
index 602338734634..8cde2a0538ab 100644
--- a/drivers/isdn/hardware/mISDN/hfcsusb.c
+++ b/drivers/isdn/hardware/mISDN/hfcsusb.c
@@ -486,7 +486,7 @@ open_bchannel(struct hfcsusb *hw, struct channel_req *rq)
486{ 486{
487 struct bchannel *bch; 487 struct bchannel *bch;
488 488
489 if (rq->adr.channel > 2) 489 if (rq->adr.channel == 0 || rq->adr.channel > 2)
490 return -EINVAL; 490 return -EINVAL;
491 if (rq->protocol == ISDN_P_NONE) 491 if (rq->protocol == ISDN_P_NONE)
492 return -EINVAL; 492 return -EINVAL;
diff --git a/drivers/isdn/hardware/mISDN/mISDNipac.c b/drivers/isdn/hardware/mISDN/mISDNipac.c
index b47e9bed2185..884369f09cad 100644
--- a/drivers/isdn/hardware/mISDN/mISDNipac.c
+++ b/drivers/isdn/hardware/mISDN/mISDNipac.c
@@ -1506,7 +1506,7 @@ open_bchannel(struct ipac_hw *ipac, struct channel_req *rq)
1506{ 1506{
1507 struct bchannel *bch; 1507 struct bchannel *bch;
1508 1508
1509 if (rq->adr.channel > 2) 1509 if (rq->adr.channel == 0 || rq->adr.channel > 2)
1510 return -EINVAL; 1510 return -EINVAL;
1511 if (rq->protocol == ISDN_P_NONE) 1511 if (rq->protocol == ISDN_P_NONE)
1512 return -EINVAL; 1512 return -EINVAL;
diff --git a/drivers/isdn/hardware/mISDN/mISDNisar.c b/drivers/isdn/hardware/mISDN/mISDNisar.c
index 10446ab404b5..9a6da6edcfa8 100644
--- a/drivers/isdn/hardware/mISDN/mISDNisar.c
+++ b/drivers/isdn/hardware/mISDN/mISDNisar.c
@@ -1670,7 +1670,7 @@ isar_open(struct isar_hw *isar, struct channel_req *rq)
1670{ 1670{
1671 struct bchannel *bch; 1671 struct bchannel *bch;
1672 1672
1673 if (rq->adr.channel > 2) 1673 if (rq->adr.channel == 0 || rq->adr.channel > 2)
1674 return -EINVAL; 1674 return -EINVAL;
1675 if (rq->protocol == ISDN_P_NONE) 1675 if (rq->protocol == ISDN_P_NONE)
1676 return -EINVAL; 1676 return -EINVAL;
diff --git a/drivers/isdn/hardware/mISDN/netjet.c b/drivers/isdn/hardware/mISDN/netjet.c
index dd6de9f7a8a3..c726e09d0981 100644
--- a/drivers/isdn/hardware/mISDN/netjet.c
+++ b/drivers/isdn/hardware/mISDN/netjet.c
@@ -860,7 +860,7 @@ open_bchannel(struct tiger_hw *card, struct channel_req *rq)
860{ 860{
861 struct bchannel *bch; 861 struct bchannel *bch;
862 862
863 if (rq->adr.channel > 2) 863 if (rq->adr.channel == 0 || rq->adr.channel > 2)
864 return -EINVAL; 864 return -EINVAL;
865 if (rq->protocol == ISDN_P_NONE) 865 if (rq->protocol == ISDN_P_NONE)
866 return -EINVAL; 866 return -EINVAL;
diff --git a/drivers/isdn/hardware/mISDN/w6692.c b/drivers/isdn/hardware/mISDN/w6692.c
index 7f1e7ba75cd1..2183357f0799 100644
--- a/drivers/isdn/hardware/mISDN/w6692.c
+++ b/drivers/isdn/hardware/mISDN/w6692.c
@@ -1015,7 +1015,7 @@ open_bchannel(struct w6692_hw *card, struct channel_req *rq)
1015{ 1015{
1016 struct bchannel *bch; 1016 struct bchannel *bch;
1017 1017
1018 if (rq->adr.channel > 2) 1018 if (rq->adr.channel == 0 || rq->adr.channel > 2)
1019 return -EINVAL; 1019 return -EINVAL;
1020 if (rq->protocol == ISDN_P_NONE) 1020 if (rq->protocol == ISDN_P_NONE)
1021 return -EINVAL; 1021 return -EINVAL;
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index b0fcc7d02adb..fa211d80fc0a 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -198,6 +198,7 @@ out:
198static int linear_run (struct mddev *mddev) 198static int linear_run (struct mddev *mddev)
199{ 199{
200 struct linear_conf *conf; 200 struct linear_conf *conf;
201 int ret;
201 202
202 if (md_check_no_bitmap(mddev)) 203 if (md_check_no_bitmap(mddev))
203 return -EINVAL; 204 return -EINVAL;
@@ -211,7 +212,13 @@ static int linear_run (struct mddev *mddev)
211 blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec); 212 blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec);
212 mddev->queue->backing_dev_info.congested_fn = linear_congested; 213 mddev->queue->backing_dev_info.congested_fn = linear_congested;
213 mddev->queue->backing_dev_info.congested_data = mddev; 214 mddev->queue->backing_dev_info.congested_data = mddev;
214 return md_integrity_register(mddev); 215
216 ret = md_integrity_register(mddev);
217 if (ret) {
218 kfree(conf);
219 mddev->private = NULL;
220 }
221 return ret;
215} 222}
216 223
217static int linear_add(struct mddev *mddev, struct md_rdev *rdev) 224static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 6f31f5596e01..de63a1fc3737 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -407,6 +407,8 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks
407 return array_sectors; 407 return array_sectors;
408} 408}
409 409
410static int raid0_stop(struct mddev *mddev);
411
410static int raid0_run(struct mddev *mddev) 412static int raid0_run(struct mddev *mddev)
411{ 413{
412 struct r0conf *conf; 414 struct r0conf *conf;
@@ -454,7 +456,12 @@ static int raid0_run(struct mddev *mddev)
454 456
455 blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec); 457 blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec);
456 dump_zones(mddev); 458 dump_zones(mddev);
457 return md_integrity_register(mddev); 459
460 ret = md_integrity_register(mddev);
461 if (ret)
462 raid0_stop(mddev);
463
464 return ret;
458} 465}
459 466
460static int raid0_stop(struct mddev *mddev) 467static int raid0_stop(struct mddev *mddev)
@@ -625,6 +632,7 @@ static void *raid0_takeover_raid10(struct mddev *mddev)
625static void *raid0_takeover_raid1(struct mddev *mddev) 632static void *raid0_takeover_raid1(struct mddev *mddev)
626{ 633{
627 struct r0conf *priv_conf; 634 struct r0conf *priv_conf;
635 int chunksect;
628 636
629 /* Check layout: 637 /* Check layout:
630 * - (N - 1) mirror drives must be already faulty 638 * - (N - 1) mirror drives must be already faulty
@@ -635,10 +643,25 @@ static void *raid0_takeover_raid1(struct mddev *mddev)
635 return ERR_PTR(-EINVAL); 643 return ERR_PTR(-EINVAL);
636 } 644 }
637 645
646 /*
647 * a raid1 doesn't have the notion of chunk size, so
648 * figure out the largest suitable size we can use.
649 */
650 chunksect = 64 * 2; /* 64K by default */
651
652 /* The array must be an exact multiple of chunksize */
653 while (chunksect && (mddev->array_sectors & (chunksect - 1)))
654 chunksect >>= 1;
655
656 if ((chunksect << 9) < PAGE_SIZE)
657 /* array size does not allow a suitable chunk size */
658 return ERR_PTR(-EINVAL);
659
638 /* Set new parameters */ 660 /* Set new parameters */
639 mddev->new_level = 0; 661 mddev->new_level = 0;
640 mddev->new_layout = 0; 662 mddev->new_layout = 0;
641 mddev->new_chunk_sectors = 128; /* by default set chunk size to 64k */ 663 mddev->new_chunk_sectors = chunksect;
664 mddev->chunk_sectors = chunksect;
642 mddev->delta_disks = 1 - mddev->raid_disks; 665 mddev->delta_disks = 1 - mddev->raid_disks;
643 mddev->raid_disks = 1; 666 mddev->raid_disks = 1;
644 /* make sure it will be not marked as dirty */ 667 /* make sure it will be not marked as dirty */
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4a40a200d769..d35e4c991e38 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1738,7 +1738,7 @@ static int process_checks(struct r1bio *r1_bio)
1738 s = sbio->bi_io_vec[j].bv_page; 1738 s = sbio->bi_io_vec[j].bv_page;
1739 if (memcmp(page_address(p), 1739 if (memcmp(page_address(p),
1740 page_address(s), 1740 page_address(s),
1741 PAGE_SIZE)) 1741 sbio->bi_io_vec[j].bv_len))
1742 break; 1742 break;
1743 } 1743 }
1744 } else 1744 } else
@@ -2386,8 +2386,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp
2386 int ok = 1; 2386 int ok = 1;
2387 for (i = 0 ; i < conf->raid_disks * 2 ; i++) 2387 for (i = 0 ; i < conf->raid_disks * 2 ; i++)
2388 if (r1_bio->bios[i]->bi_end_io == end_sync_write) { 2388 if (r1_bio->bios[i]->bi_end_io == end_sync_write) {
2389 struct md_rdev *rdev = 2389 struct md_rdev *rdev = conf->mirrors[i].rdev;
2390 rcu_dereference(conf->mirrors[i].rdev);
2391 ok = rdev_set_badblocks(rdev, sector_nr, 2390 ok = rdev_set_badblocks(rdev, sector_nr,
2392 min_bad, 0 2391 min_bad, 0
2393 ) && ok; 2392 ) && ok;
@@ -2636,11 +2635,13 @@ static struct r1conf *setup_conf(struct mddev *mddev)
2636 return ERR_PTR(err); 2635 return ERR_PTR(err);
2637} 2636}
2638 2637
2638static int stop(struct mddev *mddev);
2639static int run(struct mddev *mddev) 2639static int run(struct mddev *mddev)
2640{ 2640{
2641 struct r1conf *conf; 2641 struct r1conf *conf;
2642 int i; 2642 int i;
2643 struct md_rdev *rdev; 2643 struct md_rdev *rdev;
2644 int ret;
2644 2645
2645 if (mddev->level != 1) { 2646 if (mddev->level != 1) {
2646 printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n", 2647 printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n",
@@ -2705,7 +2706,11 @@ static int run(struct mddev *mddev)
2705 mddev->queue->backing_dev_info.congested_data = mddev; 2706 mddev->queue->backing_dev_info.congested_data = mddev;
2706 blk_queue_merge_bvec(mddev->queue, raid1_mergeable_bvec); 2707 blk_queue_merge_bvec(mddev->queue, raid1_mergeable_bvec);
2707 } 2708 }
2708 return md_integrity_register(mddev); 2709
2710 ret = md_integrity_register(mddev);
2711 if (ret)
2712 stop(mddev);
2713 return ret;
2709} 2714}
2710 2715
2711static int stop(struct mddev *mddev) 2716static int stop(struct mddev *mddev)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 3540316886f2..fff782189e48 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1821,7 +1821,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1821 for (j = 0; j < vcnt; j++) 1821 for (j = 0; j < vcnt; j++)
1822 if (memcmp(page_address(fbio->bi_io_vec[j].bv_page), 1822 if (memcmp(page_address(fbio->bi_io_vec[j].bv_page),
1823 page_address(tbio->bi_io_vec[j].bv_page), 1823 page_address(tbio->bi_io_vec[j].bv_page),
1824 PAGE_SIZE)) 1824 fbio->bi_io_vec[j].bv_len))
1825 break; 1825 break;
1826 if (j == vcnt) 1826 if (j == vcnt)
1827 continue; 1827 continue;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 23ac880bba9a..f351422938e0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2471,39 +2471,41 @@ handle_failed_sync(struct r5conf *conf, struct stripe_head *sh,
2471 int abort = 0; 2471 int abort = 0;
2472 int i; 2472 int i;
2473 2473
2474 md_done_sync(conf->mddev, STRIPE_SECTORS, 0);
2475 clear_bit(STRIPE_SYNCING, &sh->state); 2474 clear_bit(STRIPE_SYNCING, &sh->state);
2476 s->syncing = 0; 2475 s->syncing = 0;
2477 s->replacing = 0; 2476 s->replacing = 0;
2478 /* There is nothing more to do for sync/check/repair. 2477 /* There is nothing more to do for sync/check/repair.
2478 * Don't even need to abort as that is handled elsewhere
2479 * if needed, and not always wanted e.g. if there is a known
2480 * bad block here.
2479 * For recover/replace we need to record a bad block on all 2481 * For recover/replace we need to record a bad block on all
2480 * non-sync devices, or abort the recovery 2482 * non-sync devices, or abort the recovery
2481 */ 2483 */
2482 if (!test_bit(MD_RECOVERY_RECOVER, &conf->mddev->recovery)) 2484 if (test_bit(MD_RECOVERY_RECOVER, &conf->mddev->recovery)) {
2483 return; 2485 /* During recovery devices cannot be removed, so
2484 /* During recovery devices cannot be removed, so locking and 2486 * locking and refcounting of rdevs is not needed
2485 * refcounting of rdevs is not needed 2487 */
2486 */ 2488 for (i = 0; i < conf->raid_disks; i++) {
2487 for (i = 0; i < conf->raid_disks; i++) { 2489 struct md_rdev *rdev = conf->disks[i].rdev;
2488 struct md_rdev *rdev = conf->disks[i].rdev; 2490 if (rdev
2489 if (rdev 2491 && !test_bit(Faulty, &rdev->flags)
2490 && !test_bit(Faulty, &rdev->flags) 2492 && !test_bit(In_sync, &rdev->flags)
2491 && !test_bit(In_sync, &rdev->flags) 2493 && !rdev_set_badblocks(rdev, sh->sector,
2492 && !rdev_set_badblocks(rdev, sh->sector, 2494 STRIPE_SECTORS, 0))
2493 STRIPE_SECTORS, 0)) 2495 abort = 1;
2494 abort = 1; 2496 rdev = conf->disks[i].replacement;
2495 rdev = conf->disks[i].replacement; 2497 if (rdev
2496 if (rdev 2498 && !test_bit(Faulty, &rdev->flags)
2497 && !test_bit(Faulty, &rdev->flags) 2499 && !test_bit(In_sync, &rdev->flags)
2498 && !test_bit(In_sync, &rdev->flags) 2500 && !rdev_set_badblocks(rdev, sh->sector,
2499 && !rdev_set_badblocks(rdev, sh->sector, 2501 STRIPE_SECTORS, 0))
2500 STRIPE_SECTORS, 0)) 2502 abort = 1;
2501 abort = 1; 2503 }
2502 } 2504 if (abort)
2503 if (abort) { 2505 conf->recovery_disabled =
2504 conf->recovery_disabled = conf->mddev->recovery_disabled; 2506 conf->mddev->recovery_disabled;
2505 set_bit(MD_RECOVERY_INTR, &conf->mddev->recovery);
2506 } 2507 }
2508 md_done_sync(conf->mddev, STRIPE_SECTORS, !abort);
2507} 2509}
2508 2510
2509static int want_replace(struct stripe_head *sh, int disk_idx) 2511static int want_replace(struct stripe_head *sh, int disk_idx)
@@ -3203,7 +3205,8 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
3203 /* Not in-sync */; 3205 /* Not in-sync */;
3204 else if (is_bad) { 3206 else if (is_bad) {
3205 /* also not in-sync */ 3207 /* also not in-sync */
3206 if (!test_bit(WriteErrorSeen, &rdev->flags)) { 3208 if (!test_bit(WriteErrorSeen, &rdev->flags) &&
3209 test_bit(R5_UPTODATE, &dev->flags)) {
3207 /* treat as in-sync, but with a read error 3210 /* treat as in-sync, but with a read error
3208 * which we can now try to correct 3211 * which we can now try to correct
3209 */ 3212 */
@@ -3276,12 +3279,14 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
3276 /* If there is a failed device being replaced, 3279 /* If there is a failed device being replaced,
3277 * we must be recovering. 3280 * we must be recovering.
3278 * else if we are after recovery_cp, we must be syncing 3281 * else if we are after recovery_cp, we must be syncing
3282 * else if MD_RECOVERY_REQUESTED is set, we also are syncing.
3279 * else we can only be replacing 3283 * else we can only be replacing
3280 * sync and recovery both need to read all devices, and so 3284 * sync and recovery both need to read all devices, and so
3281 * use the same flag. 3285 * use the same flag.
3282 */ 3286 */
3283 if (do_recovery || 3287 if (do_recovery ||
3284 sh->sector >= conf->mddev->recovery_cp) 3288 sh->sector >= conf->mddev->recovery_cp ||
3289 test_bit(MD_RECOVERY_REQUESTED, &(conf->mddev->recovery)))
3285 s->syncing = 1; 3290 s->syncing = 1;
3286 else 3291 else
3287 s->replacing = 1; 3292 s->replacing = 1;
diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c
index 3aa36eb5c79b..44a3fdbadef4 100644
--- a/drivers/mfd/aat2870-core.c
+++ b/drivers/mfd/aat2870-core.c
@@ -262,13 +262,6 @@ static ssize_t aat2870_dump_reg(struct aat2870_data *aat2870, char *buf)
262 return count; 262 return count;
263} 263}
264 264
265static int aat2870_reg_open_file(struct inode *inode, struct file *file)
266{
267 file->private_data = inode->i_private;
268
269 return 0;
270}
271
272static ssize_t aat2870_reg_read_file(struct file *file, char __user *user_buf, 265static ssize_t aat2870_reg_read_file(struct file *file, char __user *user_buf,
273 size_t count, loff_t *ppos) 266 size_t count, loff_t *ppos)
274{ 267{
@@ -330,7 +323,7 @@ static ssize_t aat2870_reg_write_file(struct file *file,
330} 323}
331 324
332static const struct file_operations aat2870_reg_fops = { 325static const struct file_operations aat2870_reg_fops = {
333 .open = aat2870_reg_open_file, 326 .open = simple_open,
334 .read = aat2870_reg_read_file, 327 .read = aat2870_reg_read_file,
335 .write = aat2870_reg_write_file, 328 .write = aat2870_reg_write_file,
336}; 329};
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 60107ee166fc..1efad20fb175 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -483,12 +483,6 @@ struct ab3100_get_set_reg_priv {
483 bool mode; 483 bool mode;
484}; 484};
485 485
486static int ab3100_get_set_reg_open_file(struct inode *inode, struct file *file)
487{
488 file->private_data = inode->i_private;
489 return 0;
490}
491
492static ssize_t ab3100_get_set_reg(struct file *file, 486static ssize_t ab3100_get_set_reg(struct file *file,
493 const char __user *user_buf, 487 const char __user *user_buf,
494 size_t count, loff_t *ppos) 488 size_t count, loff_t *ppos)
@@ -583,7 +577,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
583} 577}
584 578
585static const struct file_operations ab3100_get_set_reg_fops = { 579static const struct file_operations ab3100_get_set_reg_fops = {
586 .open = ab3100_get_set_reg_open_file, 580 .open = simple_open,
587 .write = ab3100_get_set_reg, 581 .write = ab3100_get_set_reg,
588 .llseek = noop_llseek, 582 .llseek = noop_llseek,
589}; 583};
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index 1c034b80d408..6673e578b3e9 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -500,12 +500,6 @@ static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf,
500 return 1; 500 return 1;
501} 501}
502 502
503static int remote_settings_file_open(struct inode *inode, struct file *file)
504{
505 file->private_data = inode->i_private;
506 return 0;
507}
508
509static int remote_settings_file_close(struct inode *inode, struct file *file) 503static int remote_settings_file_close(struct inode *inode, struct file *file)
510{ 504{
511 return 0; 505 return 0;
@@ -600,7 +594,7 @@ static const struct file_operations r_heartbeat_fops = {
600}; 594};
601 595
602static const struct file_operations remote_settings_fops = { 596static const struct file_operations remote_settings_fops = {
603 .open = remote_settings_file_open, 597 .open = simple_open,
604 .release = remote_settings_file_close, 598 .release = remote_settings_file_close,
605 .read = remote_settings_file_read, 599 .read = remote_settings_file_read,
606 .write = remote_settings_file_write, 600 .write = remote_settings_file_write,
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 3f7ad83ed740..3aa9a969b373 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -134,12 +134,17 @@ static int force_hwbrks;
134static int hwbreaks_ok; 134static int hwbreaks_ok;
135static int hw_break_val; 135static int hw_break_val;
136static int hw_break_val2; 136static int hw_break_val2;
137static int cont_instead_of_sstep;
138static unsigned long cont_thread_id;
139static unsigned long sstep_thread_id;
137#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_SPARC) 140#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_SPARC)
138static int arch_needs_sstep_emulation = 1; 141static int arch_needs_sstep_emulation = 1;
139#else 142#else
140static int arch_needs_sstep_emulation; 143static int arch_needs_sstep_emulation;
141#endif 144#endif
145static unsigned long cont_addr;
142static unsigned long sstep_addr; 146static unsigned long sstep_addr;
147static int restart_from_top_after_write;
143static int sstep_state; 148static int sstep_state;
144 149
145/* Storage for the registers, in GDB format. */ 150/* Storage for the registers, in GDB format. */
@@ -187,7 +192,8 @@ static int kgdbts_unreg_thread(void *ptr)
187 */ 192 */
188 while (!final_ack) 193 while (!final_ack)
189 msleep_interruptible(1500); 194 msleep_interruptible(1500);
190 195 /* Pause for any other threads to exit after final ack. */
196 msleep_interruptible(1000);
191 if (configured) 197 if (configured)
192 kgdb_unregister_io_module(&kgdbts_io_ops); 198 kgdb_unregister_io_module(&kgdbts_io_ops);
193 configured = 0; 199 configured = 0;
@@ -211,7 +217,7 @@ static unsigned long lookup_addr(char *arg)
211 if (!strcmp(arg, "kgdbts_break_test")) 217 if (!strcmp(arg, "kgdbts_break_test"))
212 addr = (unsigned long)kgdbts_break_test; 218 addr = (unsigned long)kgdbts_break_test;
213 else if (!strcmp(arg, "sys_open")) 219 else if (!strcmp(arg, "sys_open"))
214 addr = (unsigned long)sys_open; 220 addr = (unsigned long)do_sys_open;
215 else if (!strcmp(arg, "do_fork")) 221 else if (!strcmp(arg, "do_fork"))
216 addr = (unsigned long)do_fork; 222 addr = (unsigned long)do_fork;
217 else if (!strcmp(arg, "hw_break_val")) 223 else if (!strcmp(arg, "hw_break_val"))
@@ -283,6 +289,16 @@ static void hw_break_val_write(void)
283 hw_break_val++; 289 hw_break_val++;
284} 290}
285 291
292static int get_thread_id_continue(char *put_str, char *arg)
293{
294 char *ptr = &put_str[11];
295
296 if (put_str[1] != 'T' || put_str[2] != '0')
297 return 1;
298 kgdb_hex2long(&ptr, &cont_thread_id);
299 return 0;
300}
301
286static int check_and_rewind_pc(char *put_str, char *arg) 302static int check_and_rewind_pc(char *put_str, char *arg)
287{ 303{
288 unsigned long addr = lookup_addr(arg); 304 unsigned long addr = lookup_addr(arg);
@@ -299,13 +315,21 @@ static int check_and_rewind_pc(char *put_str, char *arg)
299 if (addr + BREAK_INSTR_SIZE == ip) 315 if (addr + BREAK_INSTR_SIZE == ip)
300 offset = -BREAK_INSTR_SIZE; 316 offset = -BREAK_INSTR_SIZE;
301#endif 317#endif
302 if (strcmp(arg, "silent") && ip + offset != addr) { 318
319 if (arch_needs_sstep_emulation && sstep_addr &&
320 ip + offset == sstep_addr &&
321 ((!strcmp(arg, "sys_open") || !strcmp(arg, "do_fork")))) {
322 /* This is special case for emulated single step */
323 v2printk("Emul: rewind hit single step bp\n");
324 restart_from_top_after_write = 1;
325 } else if (strcmp(arg, "silent") && ip + offset != addr) {
303 eprintk("kgdbts: BP mismatch %lx expected %lx\n", 326 eprintk("kgdbts: BP mismatch %lx expected %lx\n",
304 ip + offset, addr); 327 ip + offset, addr);
305 return 1; 328 return 1;
306 } 329 }
307 /* Readjust the instruction pointer if needed */ 330 /* Readjust the instruction pointer if needed */
308 ip += offset; 331 ip += offset;
332 cont_addr = ip;
309#ifdef GDB_ADJUSTS_BREAK_OFFSET 333#ifdef GDB_ADJUSTS_BREAK_OFFSET
310 instruction_pointer_set(&kgdbts_regs, ip); 334 instruction_pointer_set(&kgdbts_regs, ip);
311#endif 335#endif
@@ -315,6 +339,8 @@ static int check_and_rewind_pc(char *put_str, char *arg)
315static int check_single_step(char *put_str, char *arg) 339static int check_single_step(char *put_str, char *arg)
316{ 340{
317 unsigned long addr = lookup_addr(arg); 341 unsigned long addr = lookup_addr(arg);
342 static int matched_id;
343
318 /* 344 /*
319 * From an arch indepent point of view the instruction pointer 345 * From an arch indepent point of view the instruction pointer
320 * should be on a different instruction 346 * should be on a different instruction
@@ -324,6 +350,29 @@ static int check_single_step(char *put_str, char *arg)
324 gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs); 350 gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs);
325 v2printk("Singlestep stopped at IP: %lx\n", 351 v2printk("Singlestep stopped at IP: %lx\n",
326 instruction_pointer(&kgdbts_regs)); 352 instruction_pointer(&kgdbts_regs));
353
354 if (sstep_thread_id != cont_thread_id) {
355 /*
356 * Ensure we stopped in the same thread id as before, else the
357 * debugger should continue until the original thread that was
358 * single stepped is scheduled again, emulating gdb's behavior.
359 */
360 v2printk("ThrID does not match: %lx\n", cont_thread_id);
361 if (arch_needs_sstep_emulation) {
362 if (matched_id &&
363 instruction_pointer(&kgdbts_regs) != addr)
364 goto continue_test;
365 matched_id++;
366 ts.idx -= 2;
367 sstep_state = 0;
368 return 0;
369 }
370 cont_instead_of_sstep = 1;
371 ts.idx -= 4;
372 return 0;
373 }
374continue_test:
375 matched_id = 0;
327 if (instruction_pointer(&kgdbts_regs) == addr) { 376 if (instruction_pointer(&kgdbts_regs) == addr) {
328 eprintk("kgdbts: SingleStep failed at %lx\n", 377 eprintk("kgdbts: SingleStep failed at %lx\n",
329 instruction_pointer(&kgdbts_regs)); 378 instruction_pointer(&kgdbts_regs));
@@ -365,10 +414,40 @@ static int got_break(char *put_str, char *arg)
365 return 1; 414 return 1;
366} 415}
367 416
417static void get_cont_catch(char *arg)
418{
419 /* Always send detach because the test is completed at this point */
420 fill_get_buf("D");
421}
422
423static int put_cont_catch(char *put_str, char *arg)
424{
425 /* This is at the end of the test and we catch any and all input */
426 v2printk("kgdbts: cleanup task: %lx\n", sstep_thread_id);
427 ts.idx--;
428 return 0;
429}
430
431static int emul_reset(char *put_str, char *arg)
432{
433 if (strncmp(put_str, "$OK", 3))
434 return 1;
435 if (restart_from_top_after_write) {
436 restart_from_top_after_write = 0;
437 ts.idx = -1;
438 }
439 return 0;
440}
441
368static void emul_sstep_get(char *arg) 442static void emul_sstep_get(char *arg)
369{ 443{
370 if (!arch_needs_sstep_emulation) { 444 if (!arch_needs_sstep_emulation) {
371 fill_get_buf(arg); 445 if (cont_instead_of_sstep) {
446 cont_instead_of_sstep = 0;
447 fill_get_buf("c");
448 } else {
449 fill_get_buf(arg);
450 }
372 return; 451 return;
373 } 452 }
374 switch (sstep_state) { 453 switch (sstep_state) {
@@ -398,9 +477,11 @@ static void emul_sstep_get(char *arg)
398static int emul_sstep_put(char *put_str, char *arg) 477static int emul_sstep_put(char *put_str, char *arg)
399{ 478{
400 if (!arch_needs_sstep_emulation) { 479 if (!arch_needs_sstep_emulation) {
401 if (!strncmp(put_str+1, arg, 2)) 480 char *ptr = &put_str[11];
402 return 0; 481 if (put_str[1] != 'T' || put_str[2] != '0')
403 return 1; 482 return 1;
483 kgdb_hex2long(&ptr, &sstep_thread_id);
484 return 0;
404 } 485 }
405 switch (sstep_state) { 486 switch (sstep_state) {
406 case 1: 487 case 1:
@@ -411,8 +492,7 @@ static int emul_sstep_put(char *put_str, char *arg)
411 v2printk("Stopped at IP: %lx\n", 492 v2printk("Stopped at IP: %lx\n",
412 instruction_pointer(&kgdbts_regs)); 493 instruction_pointer(&kgdbts_regs));
413 /* Want to stop at IP + break instruction size by default */ 494 /* Want to stop at IP + break instruction size by default */
414 sstep_addr = instruction_pointer(&kgdbts_regs) + 495 sstep_addr = cont_addr + BREAK_INSTR_SIZE;
415 BREAK_INSTR_SIZE;
416 break; 496 break;
417 case 2: 497 case 2:
418 if (strncmp(put_str, "$OK", 3)) { 498 if (strncmp(put_str, "$OK", 3)) {
@@ -424,6 +504,9 @@ static int emul_sstep_put(char *put_str, char *arg)
424 if (strncmp(put_str, "$T0", 3)) { 504 if (strncmp(put_str, "$T0", 3)) {
425 eprintk("kgdbts: failed continue sstep\n"); 505 eprintk("kgdbts: failed continue sstep\n");
426 return 1; 506 return 1;
507 } else {
508 char *ptr = &put_str[11];
509 kgdb_hex2long(&ptr, &sstep_thread_id);
427 } 510 }
428 break; 511 break;
429 case 4: 512 case 4:
@@ -502,10 +585,10 @@ static struct test_struct bad_read_test[] = {
502static struct test_struct singlestep_break_test[] = { 585static struct test_struct singlestep_break_test[] = {
503 { "?", "S0*" }, /* Clear break points */ 586 { "?", "S0*" }, /* Clear break points */
504 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ 587 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */
505 { "c", "T0*", }, /* Continue */ 588 { "c", "T0*", NULL, get_thread_id_continue }, /* Continue */
589 { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */
506 { "g", "kgdbts_break_test", NULL, check_and_rewind_pc }, 590 { "g", "kgdbts_break_test", NULL, check_and_rewind_pc },
507 { "write", "OK", write_regs }, /* Write registers */ 591 { "write", "OK", write_regs }, /* Write registers */
508 { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */
509 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ 592 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */
510 { "g", "kgdbts_break_test", NULL, check_single_step }, 593 { "g", "kgdbts_break_test", NULL, check_single_step },
511 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ 594 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */
@@ -523,16 +606,16 @@ static struct test_struct singlestep_break_test[] = {
523static struct test_struct do_fork_test[] = { 606static struct test_struct do_fork_test[] = {
524 { "?", "S0*" }, /* Clear break points */ 607 { "?", "S0*" }, /* Clear break points */
525 { "do_fork", "OK", sw_break, }, /* set sw breakpoint */ 608 { "do_fork", "OK", sw_break, }, /* set sw breakpoint */
526 { "c", "T0*", }, /* Continue */ 609 { "c", "T0*", NULL, get_thread_id_continue }, /* Continue */
527 { "g", "do_fork", NULL, check_and_rewind_pc }, /* check location */
528 { "write", "OK", write_regs }, /* Write registers */
529 { "do_fork", "OK", sw_rem_break }, /*remove breakpoint */ 610 { "do_fork", "OK", sw_rem_break }, /*remove breakpoint */
611 { "g", "do_fork", NULL, check_and_rewind_pc }, /* check location */
612 { "write", "OK", write_regs, emul_reset }, /* Write registers */
530 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ 613 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */
531 { "g", "do_fork", NULL, check_single_step }, 614 { "g", "do_fork", NULL, check_single_step },
532 { "do_fork", "OK", sw_break, }, /* set sw breakpoint */ 615 { "do_fork", "OK", sw_break, }, /* set sw breakpoint */
533 { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */ 616 { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */
534 { "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */ 617 { "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */
535 { "", "" }, 618 { "", "", get_cont_catch, put_cont_catch },
536}; 619};
537 620
538/* Test for hitting a breakpoint at sys_open for what ever the number 621/* Test for hitting a breakpoint at sys_open for what ever the number
@@ -541,16 +624,16 @@ static struct test_struct do_fork_test[] = {
541static struct test_struct sys_open_test[] = { 624static struct test_struct sys_open_test[] = {
542 { "?", "S0*" }, /* Clear break points */ 625 { "?", "S0*" }, /* Clear break points */
543 { "sys_open", "OK", sw_break, }, /* set sw breakpoint */ 626 { "sys_open", "OK", sw_break, }, /* set sw breakpoint */
544 { "c", "T0*", }, /* Continue */ 627 { "c", "T0*", NULL, get_thread_id_continue }, /* Continue */
545 { "g", "sys_open", NULL, check_and_rewind_pc }, /* check location */
546 { "write", "OK", write_regs }, /* Write registers */
547 { "sys_open", "OK", sw_rem_break }, /*remove breakpoint */ 628 { "sys_open", "OK", sw_rem_break }, /*remove breakpoint */
629 { "g", "sys_open", NULL, check_and_rewind_pc }, /* check location */
630 { "write", "OK", write_regs, emul_reset }, /* Write registers */
548 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ 631 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */
549 { "g", "sys_open", NULL, check_single_step }, 632 { "g", "sys_open", NULL, check_single_step },
550 { "sys_open", "OK", sw_break, }, /* set sw breakpoint */ 633 { "sys_open", "OK", sw_break, }, /* set sw breakpoint */
551 { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */ 634 { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */
552 { "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */ 635 { "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */
553 { "", "" }, 636 { "", "", get_cont_catch, put_cont_catch },
554}; 637};
555 638
556/* 639/*
@@ -693,8 +776,8 @@ static int run_simple_test(int is_get_char, int chr)
693 /* This callback is a put char which is when kgdb sends data to 776 /* This callback is a put char which is when kgdb sends data to
694 * this I/O module. 777 * this I/O module.
695 */ 778 */
696 if (ts.tst[ts.idx].get[0] == '\0' && 779 if (ts.tst[ts.idx].get[0] == '\0' && ts.tst[ts.idx].put[0] == '\0' &&
697 ts.tst[ts.idx].put[0] == '\0') { 780 !ts.tst[ts.idx].get_handler) {
698 eprintk("kgdbts: ERROR: beyond end of test on" 781 eprintk("kgdbts: ERROR: beyond end of test on"
699 " '%s' line %i\n", ts.name, ts.idx); 782 " '%s' line %i\n", ts.name, ts.idx);
700 return 0; 783 return 0;
@@ -907,6 +990,17 @@ static void kgdbts_run_tests(void)
907 if (ptr) 990 if (ptr)
908 sstep_test = simple_strtol(ptr+1, NULL, 10); 991 sstep_test = simple_strtol(ptr+1, NULL, 10);
909 992
993 /* All HW break point tests */
994 if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
995 hwbreaks_ok = 1;
996 v1printk("kgdbts:RUN hw breakpoint test\n");
997 run_breakpoint_test(1);
998 v1printk("kgdbts:RUN hw write breakpoint test\n");
999 run_hw_break_test(1);
1000 v1printk("kgdbts:RUN access write breakpoint test\n");
1001 run_hw_break_test(0);
1002 }
1003
910 /* required internal KGDB tests */ 1004 /* required internal KGDB tests */
911 v1printk("kgdbts:RUN plant and detach test\n"); 1005 v1printk("kgdbts:RUN plant and detach test\n");
912 run_plant_and_detach_test(0); 1006 run_plant_and_detach_test(0);
@@ -924,35 +1018,11 @@ static void kgdbts_run_tests(void)
924 1018
925 /* ===Optional tests=== */ 1019 /* ===Optional tests=== */
926 1020
927 /* All HW break point tests */
928 if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
929 hwbreaks_ok = 1;
930 v1printk("kgdbts:RUN hw breakpoint test\n");
931 run_breakpoint_test(1);
932 v1printk("kgdbts:RUN hw write breakpoint test\n");
933 run_hw_break_test(1);
934 v1printk("kgdbts:RUN access write breakpoint test\n");
935 run_hw_break_test(0);
936 }
937
938 if (nmi_sleep) { 1021 if (nmi_sleep) {
939 v1printk("kgdbts:RUN NMI sleep %i seconds test\n", nmi_sleep); 1022 v1printk("kgdbts:RUN NMI sleep %i seconds test\n", nmi_sleep);
940 run_nmi_sleep_test(nmi_sleep); 1023 run_nmi_sleep_test(nmi_sleep);
941 } 1024 }
942 1025
943#ifdef CONFIG_DEBUG_RODATA
944 /* Until there is an api to write to read-only text segments, use
945 * HW breakpoints for the remainder of any tests, else print a
946 * failure message if hw breakpoints do not work.
947 */
948 if (!(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT && hwbreaks_ok)) {
949 eprintk("kgdbts: HW breakpoints do not work,"
950 "skipping remaining tests\n");
951 return;
952 }
953 force_hwbrks = 1;
954#endif /* CONFIG_DEBUG_RODATA */
955
956 /* If the do_fork test is run it will be the last test that is 1026 /* If the do_fork test is run it will be the last test that is
957 * executed because a kernel thread will be spawned at the very 1027 * executed because a kernel thread will be spawned at the very
958 * end to unregister the debug hooks. 1028 * end to unregister the debug hooks.
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index eed213a5c8cb..b1809650b7aa 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1623,24 +1623,6 @@ static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md)
1623 return ret; 1623 return ret;
1624} 1624}
1625 1625
1626static int
1627mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
1628{
1629 int err;
1630
1631 mmc_claim_host(card->host);
1632 err = mmc_set_blocklen(card, 512);
1633 mmc_release_host(card->host);
1634
1635 if (err) {
1636 pr_err("%s: unable to set block size to 512: %d\n",
1637 md->disk->disk_name, err);
1638 return -EINVAL;
1639 }
1640
1641 return 0;
1642}
1643
1644static void mmc_blk_remove_req(struct mmc_blk_data *md) 1626static void mmc_blk_remove_req(struct mmc_blk_data *md)
1645{ 1627{
1646 struct mmc_card *card; 1628 struct mmc_card *card;
@@ -1768,7 +1750,6 @@ static const struct mmc_fixup blk_fixups[] =
1768static int mmc_blk_probe(struct mmc_card *card) 1750static int mmc_blk_probe(struct mmc_card *card)
1769{ 1751{
1770 struct mmc_blk_data *md, *part_md; 1752 struct mmc_blk_data *md, *part_md;
1771 int err;
1772 char cap_str[10]; 1753 char cap_str[10];
1773 1754
1774 /* 1755 /*
@@ -1781,10 +1762,6 @@ static int mmc_blk_probe(struct mmc_card *card)
1781 if (IS_ERR(md)) 1762 if (IS_ERR(md))
1782 return PTR_ERR(md); 1763 return PTR_ERR(md);
1783 1764
1784 err = mmc_blk_set_blksize(md, card);
1785 if (err)
1786 goto out;
1787
1788 string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2, 1765 string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2,
1789 cap_str, sizeof(cap_str)); 1766 cap_str, sizeof(cap_str));
1790 pr_info("%s: %s %s %s %s\n", 1767 pr_info("%s: %s %s %s %s\n",
@@ -1809,7 +1786,7 @@ static int mmc_blk_probe(struct mmc_card *card)
1809 out: 1786 out:
1810 mmc_blk_remove_parts(card, md); 1787 mmc_blk_remove_parts(card, md);
1811 mmc_blk_remove_req(md); 1788 mmc_blk_remove_req(md);
1812 return err; 1789 return 0;
1813} 1790}
1814 1791
1815static void mmc_blk_remove(struct mmc_card *card) 1792static void mmc_blk_remove(struct mmc_card *card)
@@ -1845,8 +1822,6 @@ static int mmc_blk_resume(struct mmc_card *card)
1845 struct mmc_blk_data *md = mmc_get_drvdata(card); 1822 struct mmc_blk_data *md = mmc_get_drvdata(card);
1846 1823
1847 if (md) { 1824 if (md) {
1848 mmc_blk_set_blksize(md, card);
1849
1850 /* 1825 /*
1851 * Resume involves the card going into idle state, 1826 * Resume involves the card going into idle state,
1852 * so current partition is always the main one. 1827 * so current partition is always the main one.
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 5d011a39dfff..3f606068d552 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -267,6 +267,15 @@ int mmc_add_card(struct mmc_card *card)
267{ 267{
268 int ret; 268 int ret;
269 const char *type; 269 const char *type;
270 const char *uhs_bus_speed_mode = "";
271 static const char *const uhs_speeds[] = {
272 [UHS_SDR12_BUS_SPEED] = "SDR12 ",
273 [UHS_SDR25_BUS_SPEED] = "SDR25 ",
274 [UHS_SDR50_BUS_SPEED] = "SDR50 ",
275 [UHS_SDR104_BUS_SPEED] = "SDR104 ",
276 [UHS_DDR50_BUS_SPEED] = "DDR50 ",
277 };
278
270 279
271 dev_set_name(&card->dev, "%s:%04x", mmc_hostname(card->host), card->rca); 280 dev_set_name(&card->dev, "%s:%04x", mmc_hostname(card->host), card->rca);
272 281
@@ -296,6 +305,10 @@ int mmc_add_card(struct mmc_card *card)
296 break; 305 break;
297 } 306 }
298 307
308 if (mmc_sd_card_uhs(card) &&
309 (card->sd_bus_speed < ARRAY_SIZE(uhs_speeds)))
310 uhs_bus_speed_mode = uhs_speeds[card->sd_bus_speed];
311
299 if (mmc_host_is_spi(card->host)) { 312 if (mmc_host_is_spi(card->host)) {
300 pr_info("%s: new %s%s%s card on SPI\n", 313 pr_info("%s: new %s%s%s card on SPI\n",
301 mmc_hostname(card->host), 314 mmc_hostname(card->host),
@@ -303,13 +316,13 @@ int mmc_add_card(struct mmc_card *card)
303 mmc_card_ddr_mode(card) ? "DDR " : "", 316 mmc_card_ddr_mode(card) ? "DDR " : "",
304 type); 317 type);
305 } else { 318 } else {
306 pr_info("%s: new %s%s%s%s card at address %04x\n", 319 pr_info("%s: new %s%s%s%s%s card at address %04x\n",
307 mmc_hostname(card->host), 320 mmc_hostname(card->host),
308 mmc_card_uhs(card) ? "ultra high speed " : 321 mmc_card_uhs(card) ? "ultra high speed " :
309 (mmc_card_highspeed(card) ? "high speed " : ""), 322 (mmc_card_highspeed(card) ? "high speed " : ""),
310 (mmc_card_hs200(card) ? "HS200 " : ""), 323 (mmc_card_hs200(card) ? "HS200 " : ""),
311 mmc_card_ddr_mode(card) ? "DDR " : "", 324 mmc_card_ddr_mode(card) ? "DDR " : "",
312 type, card->rca); 325 uhs_bus_speed_mode, type, card->rca);
313 } 326 }
314 327
315#ifdef CONFIG_DEBUG_FS 328#ifdef CONFIG_DEBUG_FS
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 14f262e9246d..7474c47b9c08 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -527,10 +527,14 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
527 527
528 if (data->flags & MMC_DATA_WRITE) 528 if (data->flags & MMC_DATA_WRITE)
529 /* 529 /*
530 * The limit is really 250 ms, but that is 530 * The MMC spec "It is strongly recommended
531 * insufficient for some crappy cards. 531 * for hosts to implement more than 500ms
532 * timeout value even if the card indicates
533 * the 250ms maximum busy length." Even the
534 * previous value of 300ms is known to be
535 * insufficient for some cards.
532 */ 536 */
533 limit_us = 300000; 537 limit_us = 3000000;
534 else 538 else
535 limit_us = 100000; 539 limit_us = 100000;
536 540
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 02914d609a91..54df5adc0413 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct mmc_card *card,
695 else if (host->ios.clock <= 200000000) 695 else if (host->ios.clock <= 200000000)
696 index = EXT_CSD_PWR_CL_200_195; 696 index = EXT_CSD_PWR_CL_200_195;
697 break; 697 break;
698 case MMC_VDD_27_28:
699 case MMC_VDD_28_29:
700 case MMC_VDD_29_30:
701 case MMC_VDD_30_31:
702 case MMC_VDD_31_32:
698 case MMC_VDD_32_33: 703 case MMC_VDD_32_33:
699 case MMC_VDD_33_34: 704 case MMC_VDD_33_34:
700 case MMC_VDD_34_35: 705 case MMC_VDD_34_35:
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1111 ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? 1116 ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ?
1112 EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; 1117 EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4;
1113 err = mmc_select_powerclass(card, ext_csd_bits, ext_csd); 1118 err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
1114 if (err) { 1119 if (err)
1115 pr_err("%s: power class selection to bus width %d failed\n", 1120 pr_warning("%s: power class selection to bus width %d"
1116 mmc_hostname(card->host), 1 << bus_width); 1121 " failed\n", mmc_hostname(card->host),
1117 goto err; 1122 1 << bus_width);
1118 }
1119 } 1123 }
1120 1124
1121 /* 1125 /*
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1147 err = mmc_select_powerclass(card, ext_csd_bits[idx][0], 1151 err = mmc_select_powerclass(card, ext_csd_bits[idx][0],
1148 ext_csd); 1152 ext_csd);
1149 if (err) 1153 if (err)
1150 pr_err("%s: power class selection to " 1154 pr_warning("%s: power class selection to "
1151 "bus width %d failed\n", 1155 "bus width %d failed\n",
1152 mmc_hostname(card->host), 1156 mmc_hostname(card->host),
1153 1 << bus_width); 1157 1 << bus_width);
1154 1158
1155 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1159 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1156 EXT_CSD_BUS_WIDTH, 1160 EXT_CSD_BUS_WIDTH,
@@ -1178,10 +1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1178 err = mmc_select_powerclass(card, ext_csd_bits[idx][1], 1182 err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
1179 ext_csd); 1183 ext_csd);
1180 if (err) 1184 if (err)
1181 pr_err("%s: power class selection to " 1185 pr_warning("%s: power class selection to "
1182 "bus width %d ddr %d failed\n", 1186 "bus width %d ddr %d failed\n",
1183 mmc_hostname(card->host), 1187 mmc_hostname(card->host),
1184 1 << bus_width, ddr); 1188 1 << bus_width, ddr);
1185 1189
1186 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1190 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1187 EXT_CSD_BUS_WIDTH, 1191 EXT_CSD_BUS_WIDTH,
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 40989e6bb53a..236842ec955a 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -192,9 +192,15 @@ static int sdio_bus_remove(struct device *dev)
192 return ret; 192 return ret;
193} 193}
194 194
195#ifdef CONFIG_PM_RUNTIME 195#ifdef CONFIG_PM
196
197static int pm_no_operation(struct device *dev)
198{
199 return 0;
200}
196 201
197static const struct dev_pm_ops sdio_bus_pm_ops = { 202static const struct dev_pm_ops sdio_bus_pm_ops = {
203 SET_SYSTEM_SLEEP_PM_OPS(pm_no_operation, pm_no_operation)
198 SET_RUNTIME_PM_OPS( 204 SET_RUNTIME_PM_OPS(
199 pm_generic_runtime_suspend, 205 pm_generic_runtime_suspend,
200 pm_generic_runtime_resume, 206 pm_generic_runtime_resume,
@@ -204,11 +210,11 @@ static const struct dev_pm_ops sdio_bus_pm_ops = {
204 210
205#define SDIO_PM_OPS_PTR (&sdio_bus_pm_ops) 211#define SDIO_PM_OPS_PTR (&sdio_bus_pm_ops)
206 212
207#else /* !CONFIG_PM_RUNTIME */ 213#else /* !CONFIG_PM */
208 214
209#define SDIO_PM_OPS_PTR NULL 215#define SDIO_PM_OPS_PTR NULL
210 216
211#endif /* !CONFIG_PM_RUNTIME */ 217#endif /* !CONFIG_PM */
212 218
213static struct bus_type sdio_bus_type = { 219static struct bus_type sdio_bus_type = {
214 .name = "sdio", 220 .name = "sdio",
diff --git a/drivers/mmc/host/atmel-mci-regs.h b/drivers/mmc/host/atmel-mci-regs.h
index 000b3ad0f5ca..787aba1682bb 100644
--- a/drivers/mmc/host/atmel-mci-regs.h
+++ b/drivers/mmc/host/atmel-mci-regs.h
@@ -31,6 +31,7 @@
31# define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */ 31# define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */
32# define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */ 32# define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */
33# define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */ 33# define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */
34# define ATMCI_MR_CLKODD(x) ((x) << 16) /* LSB of Clock Divider */
34#define ATMCI_DTOR 0x0008 /* Data Timeout */ 35#define ATMCI_DTOR 0x0008 /* Data Timeout */
35# define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */ 36# define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */
36# define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */ 37# define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 9819dc09ce08..e94476beca18 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -77,6 +77,7 @@ struct atmel_mci_caps {
77 bool has_cstor_reg; 77 bool has_cstor_reg;
78 bool has_highspeed; 78 bool has_highspeed;
79 bool has_rwproof; 79 bool has_rwproof;
80 bool has_odd_clk_div;
80}; 81};
81 82
82struct atmel_mci_dma { 83struct atmel_mci_dma {
@@ -482,7 +483,14 @@ err:
482static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, 483static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host,
483 unsigned int ns) 484 unsigned int ns)
484{ 485{
485 return (ns * (host->bus_hz / 1000000) + 999) / 1000; 486 /*
487 * It is easier here to use us instead of ns for the timeout,
488 * it prevents from overflows during calculation.
489 */
490 unsigned int us = DIV_ROUND_UP(ns, 1000);
491
492 /* Maximum clock frequency is host->bus_hz/2 */
493 return us * (DIV_ROUND_UP(host->bus_hz, 2000000));
486} 494}
487 495
488static void atmci_set_timeout(struct atmel_mci *host, 496static void atmci_set_timeout(struct atmel_mci *host,
@@ -1127,16 +1135,27 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1127 } 1135 }
1128 1136
1129 /* Calculate clock divider */ 1137 /* Calculate clock divider */
1130 clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1; 1138 if (host->caps.has_odd_clk_div) {
1131 if (clkdiv > 255) { 1139 clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2;
1132 dev_warn(&mmc->class_dev, 1140 if (clkdiv > 511) {
1133 "clock %u too slow; using %lu\n", 1141 dev_warn(&mmc->class_dev,
1134 clock_min, host->bus_hz / (2 * 256)); 1142 "clock %u too slow; using %lu\n",
1135 clkdiv = 255; 1143 clock_min, host->bus_hz / (511 + 2));
1144 clkdiv = 511;
1145 }
1146 host->mode_reg = ATMCI_MR_CLKDIV(clkdiv >> 1)
1147 | ATMCI_MR_CLKODD(clkdiv & 1);
1148 } else {
1149 clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1;
1150 if (clkdiv > 255) {
1151 dev_warn(&mmc->class_dev,
1152 "clock %u too slow; using %lu\n",
1153 clock_min, host->bus_hz / (2 * 256));
1154 clkdiv = 255;
1155 }
1156 host->mode_reg = ATMCI_MR_CLKDIV(clkdiv);
1136 } 1157 }
1137 1158
1138 host->mode_reg = ATMCI_MR_CLKDIV(clkdiv);
1139
1140 /* 1159 /*
1141 * WRPROOF and RDPROOF prevent overruns/underruns by 1160 * WRPROOF and RDPROOF prevent overruns/underruns by
1142 * stopping the clock when the FIFO is full/empty. 1161 * stopping the clock when the FIFO is full/empty.
@@ -2007,35 +2026,35 @@ static void __init atmci_get_cap(struct atmel_mci *host)
2007 "version: 0x%x\n", version); 2026 "version: 0x%x\n", version);
2008 2027
2009 host->caps.has_dma = 0; 2028 host->caps.has_dma = 0;
2010 host->caps.has_pdc = 0; 2029 host->caps.has_pdc = 1;
2011 host->caps.has_cfg_reg = 0; 2030 host->caps.has_cfg_reg = 0;
2012 host->caps.has_cstor_reg = 0; 2031 host->caps.has_cstor_reg = 0;
2013 host->caps.has_highspeed = 0; 2032 host->caps.has_highspeed = 0;
2014 host->caps.has_rwproof = 0; 2033 host->caps.has_rwproof = 0;
2034 host->caps.has_odd_clk_div = 0;
2015 2035
2016 /* keep only major version number */ 2036 /* keep only major version number */
2017 switch (version & 0xf00) { 2037 switch (version & 0xf00) {
2018 case 0x100:
2019 case 0x200:
2020 host->caps.has_pdc = 1;
2021 host->caps.has_rwproof = 1;
2022 break;
2023 case 0x300:
2024 case 0x400:
2025 case 0x500: 2038 case 0x500:
2039 host->caps.has_odd_clk_div = 1;
2040 case 0x400:
2041 case 0x300:
2026#ifdef CONFIG_AT_HDMAC 2042#ifdef CONFIG_AT_HDMAC
2027 host->caps.has_dma = 1; 2043 host->caps.has_dma = 1;
2028#else 2044#else
2029 host->caps.has_dma = 0;
2030 dev_info(&host->pdev->dev, 2045 dev_info(&host->pdev->dev,
2031 "has dma capability but dma engine is not selected, then use pio\n"); 2046 "has dma capability but dma engine is not selected, then use pio\n");
2032#endif 2047#endif
2048 host->caps.has_pdc = 0;
2033 host->caps.has_cfg_reg = 1; 2049 host->caps.has_cfg_reg = 1;
2034 host->caps.has_cstor_reg = 1; 2050 host->caps.has_cstor_reg = 1;
2035 host->caps.has_highspeed = 1; 2051 host->caps.has_highspeed = 1;
2052 case 0x200:
2036 host->caps.has_rwproof = 1; 2053 host->caps.has_rwproof = 1;
2054 case 0x100:
2037 break; 2055 break;
2038 default: 2056 default:
2057 host->caps.has_pdc = 0;
2039 dev_warn(&host->pdev->dev, 2058 dev_warn(&host->pdev->dev,
2040 "Unmanaged mci version, set minimum capabilities\n"); 2059 "Unmanaged mci version, set minimum capabilities\n");
2041 break; 2060 break;
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 47adb161d3ad..5c2b1c10af9c 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1785,7 +1785,7 @@ static inline struct omap_mmc_platform_data
1785} 1785}
1786#endif 1786#endif
1787 1787
1788static int __init omap_hsmmc_probe(struct platform_device *pdev) 1788static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
1789{ 1789{
1790 struct omap_mmc_platform_data *pdata = pdev->dev.platform_data; 1790 struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
1791 struct mmc_host *mmc; 1791 struct mmc_host *mmc;
@@ -1818,8 +1818,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1818 if (res == NULL || irq < 0) 1818 if (res == NULL || irq < 0)
1819 return -ENXIO; 1819 return -ENXIO;
1820 1820
1821 res->start += pdata->reg_offset;
1822 res->end += pdata->reg_offset;
1823 res = request_mem_region(res->start, resource_size(res), pdev->name); 1821 res = request_mem_region(res->start, resource_size(res), pdev->name);
1824 if (res == NULL) 1822 if (res == NULL)
1825 return -EBUSY; 1823 return -EBUSY;
@@ -1843,7 +1841,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1843 host->dma_ch = -1; 1841 host->dma_ch = -1;
1844 host->irq = irq; 1842 host->irq = irq;
1845 host->slot_id = 0; 1843 host->slot_id = 0;
1846 host->mapbase = res->start; 1844 host->mapbase = res->start + pdata->reg_offset;
1847 host->base = ioremap(host->mapbase, SZ_4K); 1845 host->base = ioremap(host->mapbase, SZ_4K);
1848 host->power_mode = MMC_POWER_OFF; 1846 host->power_mode = MMC_POWER_OFF;
1849 host->next_data.cookie = 1; 1847 host->next_data.cookie = 1;
@@ -1875,8 +1873,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1875 goto err1; 1873 goto err1;
1876 } 1874 }
1877 1875
1878 omap_hsmmc_context_save(host);
1879
1880 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { 1876 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
1881 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n"); 1877 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n");
1882 mmc->caps2 |= MMC_CAP2_NO_MULTI_READ; 1878 mmc->caps2 |= MMC_CAP2_NO_MULTI_READ;
@@ -1887,6 +1883,8 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1887 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY); 1883 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY);
1888 pm_runtime_use_autosuspend(host->dev); 1884 pm_runtime_use_autosuspend(host->dev);
1889 1885
1886 omap_hsmmc_context_save(host);
1887
1890 if (cpu_is_omap2430()) { 1888 if (cpu_is_omap2430()) {
1891 host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck"); 1889 host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
1892 /* 1890 /*
@@ -2018,8 +2016,7 @@ err_reg:
2018err_irq_cd_init: 2016err_irq_cd_init:
2019 free_irq(host->irq, host); 2017 free_irq(host->irq, host);
2020err_irq: 2018err_irq:
2021 pm_runtime_mark_last_busy(host->dev); 2019 pm_runtime_put_sync(host->dev);
2022 pm_runtime_put_autosuspend(host->dev);
2023 pm_runtime_disable(host->dev); 2020 pm_runtime_disable(host->dev);
2024 clk_put(host->fclk); 2021 clk_put(host->fclk);
2025 if (host->got_dbclk) { 2022 if (host->got_dbclk) {
@@ -2037,35 +2034,33 @@ err:
2037 return ret; 2034 return ret;
2038} 2035}
2039 2036
2040static int omap_hsmmc_remove(struct platform_device *pdev) 2037static int __devexit omap_hsmmc_remove(struct platform_device *pdev)
2041{ 2038{
2042 struct omap_hsmmc_host *host = platform_get_drvdata(pdev); 2039 struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
2043 struct resource *res; 2040 struct resource *res;
2044 2041
2045 if (host) { 2042 pm_runtime_get_sync(host->dev);
2046 pm_runtime_get_sync(host->dev); 2043 mmc_remove_host(host->mmc);
2047 mmc_remove_host(host->mmc); 2044 if (host->use_reg)
2048 if (host->use_reg) 2045 omap_hsmmc_reg_put(host);
2049 omap_hsmmc_reg_put(host); 2046 if (host->pdata->cleanup)
2050 if (host->pdata->cleanup) 2047 host->pdata->cleanup(&pdev->dev);
2051 host->pdata->cleanup(&pdev->dev); 2048 free_irq(host->irq, host);
2052 free_irq(host->irq, host); 2049 if (mmc_slot(host).card_detect_irq)
2053 if (mmc_slot(host).card_detect_irq) 2050 free_irq(mmc_slot(host).card_detect_irq, host);
2054 free_irq(mmc_slot(host).card_detect_irq, host);
2055
2056 pm_runtime_put_sync(host->dev);
2057 pm_runtime_disable(host->dev);
2058 clk_put(host->fclk);
2059 if (host->got_dbclk) {
2060 clk_disable(host->dbclk);
2061 clk_put(host->dbclk);
2062 }
2063 2051
2064 mmc_free_host(host->mmc); 2052 pm_runtime_put_sync(host->dev);
2065 iounmap(host->base); 2053 pm_runtime_disable(host->dev);
2066 omap_hsmmc_gpio_free(pdev->dev.platform_data); 2054 clk_put(host->fclk);
2055 if (host->got_dbclk) {
2056 clk_disable(host->dbclk);
2057 clk_put(host->dbclk);
2067 } 2058 }
2068 2059
2060 mmc_free_host(host->mmc);
2061 iounmap(host->base);
2062 omap_hsmmc_gpio_free(pdev->dev.platform_data);
2063
2069 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2064 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2070 if (res) 2065 if (res)
2071 release_mem_region(res->start, resource_size(res)); 2066 release_mem_region(res->start, resource_size(res));
@@ -2078,49 +2073,45 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
2078static int omap_hsmmc_suspend(struct device *dev) 2073static int omap_hsmmc_suspend(struct device *dev)
2079{ 2074{
2080 int ret = 0; 2075 int ret = 0;
2081 struct platform_device *pdev = to_platform_device(dev); 2076 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
2082 struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
2083 2077
2084 if (host && host->suspended) 2078 if (!host)
2085 return 0; 2079 return 0;
2086 2080
2087 if (host) { 2081 if (host && host->suspended)
2088 pm_runtime_get_sync(host->dev); 2082 return 0;
2089 host->suspended = 1;
2090 if (host->pdata->suspend) {
2091 ret = host->pdata->suspend(&pdev->dev,
2092 host->slot_id);
2093 if (ret) {
2094 dev_dbg(mmc_dev(host->mmc),
2095 "Unable to handle MMC board"
2096 " level suspend\n");
2097 host->suspended = 0;
2098 return ret;
2099 }
2100 }
2101 ret = mmc_suspend_host(host->mmc);
2102 2083
2084 pm_runtime_get_sync(host->dev);
2085 host->suspended = 1;
2086 if (host->pdata->suspend) {
2087 ret = host->pdata->suspend(dev, host->slot_id);
2103 if (ret) { 2088 if (ret) {
2089 dev_dbg(dev, "Unable to handle MMC board"
2090 " level suspend\n");
2104 host->suspended = 0; 2091 host->suspended = 0;
2105 if (host->pdata->resume) { 2092 return ret;
2106 ret = host->pdata->resume(&pdev->dev,
2107 host->slot_id);
2108 if (ret)
2109 dev_dbg(mmc_dev(host->mmc),
2110 "Unmask interrupt failed\n");
2111 }
2112 goto err;
2113 } 2093 }
2094 }
2095 ret = mmc_suspend_host(host->mmc);
2114 2096
2115 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { 2097 if (ret) {
2116 omap_hsmmc_disable_irq(host); 2098 host->suspended = 0;
2117 OMAP_HSMMC_WRITE(host->base, HCTL, 2099 if (host->pdata->resume) {
2118 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); 2100 ret = host->pdata->resume(dev, host->slot_id);
2101 if (ret)
2102 dev_dbg(dev, "Unmask interrupt failed\n");
2119 } 2103 }
2120 if (host->got_dbclk) 2104 goto err;
2121 clk_disable(host->dbclk); 2105 }
2122 2106
2107 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) {
2108 omap_hsmmc_disable_irq(host);
2109 OMAP_HSMMC_WRITE(host->base, HCTL,
2110 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
2123 } 2111 }
2112
2113 if (host->got_dbclk)
2114 clk_disable(host->dbclk);
2124err: 2115err:
2125 pm_runtime_put_sync(host->dev); 2116 pm_runtime_put_sync(host->dev);
2126 return ret; 2117 return ret;
@@ -2130,38 +2121,37 @@ err:
2130static int omap_hsmmc_resume(struct device *dev) 2121static int omap_hsmmc_resume(struct device *dev)
2131{ 2122{
2132 int ret = 0; 2123 int ret = 0;
2133 struct platform_device *pdev = to_platform_device(dev); 2124 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
2134 struct omap_hsmmc_host *host = platform_get_drvdata(pdev); 2125
2126 if (!host)
2127 return 0;
2135 2128
2136 if (host && !host->suspended) 2129 if (host && !host->suspended)
2137 return 0; 2130 return 0;
2138 2131
2139 if (host) { 2132 pm_runtime_get_sync(host->dev);
2140 pm_runtime_get_sync(host->dev);
2141 2133
2142 if (host->got_dbclk) 2134 if (host->got_dbclk)
2143 clk_enable(host->dbclk); 2135 clk_enable(host->dbclk);
2144 2136
2145 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) 2137 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
2146 omap_hsmmc_conf_bus_power(host); 2138 omap_hsmmc_conf_bus_power(host);
2147 2139
2148 if (host->pdata->resume) { 2140 if (host->pdata->resume) {
2149 ret = host->pdata->resume(&pdev->dev, host->slot_id); 2141 ret = host->pdata->resume(dev, host->slot_id);
2150 if (ret) 2142 if (ret)
2151 dev_dbg(mmc_dev(host->mmc), 2143 dev_dbg(dev, "Unmask interrupt failed\n");
2152 "Unmask interrupt failed\n"); 2144 }
2153 }
2154 2145
2155 omap_hsmmc_protect_card(host); 2146 omap_hsmmc_protect_card(host);
2156 2147
2157 /* Notify the core to resume the host */ 2148 /* Notify the core to resume the host */
2158 ret = mmc_resume_host(host->mmc); 2149 ret = mmc_resume_host(host->mmc);
2159 if (ret == 0) 2150 if (ret == 0)
2160 host->suspended = 0; 2151 host->suspended = 0;
2161 2152
2162 pm_runtime_mark_last_busy(host->dev); 2153 pm_runtime_mark_last_busy(host->dev);
2163 pm_runtime_put_autosuspend(host->dev); 2154 pm_runtime_put_autosuspend(host->dev);
2164 }
2165 2155
2166 return ret; 2156 return ret;
2167 2157
@@ -2178,7 +2168,7 @@ static int omap_hsmmc_runtime_suspend(struct device *dev)
2178 2168
2179 host = platform_get_drvdata(to_platform_device(dev)); 2169 host = platform_get_drvdata(to_platform_device(dev));
2180 omap_hsmmc_context_save(host); 2170 omap_hsmmc_context_save(host);
2181 dev_dbg(mmc_dev(host->mmc), "disabled\n"); 2171 dev_dbg(dev, "disabled\n");
2182 2172
2183 return 0; 2173 return 0;
2184} 2174}
@@ -2189,7 +2179,7 @@ static int omap_hsmmc_runtime_resume(struct device *dev)
2189 2179
2190 host = platform_get_drvdata(to_platform_device(dev)); 2180 host = platform_get_drvdata(to_platform_device(dev));
2191 omap_hsmmc_context_restore(host); 2181 omap_hsmmc_context_restore(host);
2192 dev_dbg(mmc_dev(host->mmc), "enabled\n"); 2182 dev_dbg(dev, "enabled\n");
2193 2183
2194 return 0; 2184 return 0;
2195} 2185}
@@ -2202,7 +2192,8 @@ static struct dev_pm_ops omap_hsmmc_dev_pm_ops = {
2202}; 2192};
2203 2193
2204static struct platform_driver omap_hsmmc_driver = { 2194static struct platform_driver omap_hsmmc_driver = {
2205 .remove = omap_hsmmc_remove, 2195 .probe = omap_hsmmc_probe,
2196 .remove = __devexit_p(omap_hsmmc_remove),
2206 .driver = { 2197 .driver = {
2207 .name = DRIVER_NAME, 2198 .name = DRIVER_NAME,
2208 .owner = THIS_MODULE, 2199 .owner = THIS_MODULE,
@@ -2211,21 +2202,7 @@ static struct platform_driver omap_hsmmc_driver = {
2211 }, 2202 },
2212}; 2203};
2213 2204
2214static int __init omap_hsmmc_init(void) 2205module_platform_driver(omap_hsmmc_driver);
2215{
2216 /* Register the MMC driver */
2217 return platform_driver_probe(&omap_hsmmc_driver, omap_hsmmc_probe);
2218}
2219
2220static void __exit omap_hsmmc_cleanup(void)
2221{
2222 /* Unregister MMC driver */
2223 platform_driver_unregister(&omap_hsmmc_driver);
2224}
2225
2226module_init(omap_hsmmc_init);
2227module_exit(omap_hsmmc_cleanup);
2228
2229MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver"); 2206MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver");
2230MODULE_LICENSE("GPL"); 2207MODULE_LICENSE("GPL");
2231MODULE_ALIAS("platform:" DRIVER_NAME); 2208MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index 46fd1fd1b605..177f697b5835 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/module.h>
23#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
24 25
25#include "sdhci-pltfm.h" 26#include "sdhci-pltfm.h"
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index fbbebe251e01..69ef0beae104 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -1418,8 +1418,6 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev,
1418 1418
1419 slots = chip->num_slots; /* Quirk may have changed this */ 1419 slots = chip->num_slots; /* Quirk may have changed this */
1420 1420
1421 pci_enable_msi(pdev);
1422
1423 for (i = 0; i < slots; i++) { 1421 for (i = 0; i < slots; i++) {
1424 slot = sdhci_pci_probe_slot(pdev, chip, first_bar, i); 1422 slot = sdhci_pci_probe_slot(pdev, chip, first_bar, i);
1425 if (IS_ERR(slot)) { 1423 if (IS_ERR(slot)) {
@@ -1438,8 +1436,6 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev,
1438 return 0; 1436 return 0;
1439 1437
1440free: 1438free:
1441 pci_disable_msi(pdev);
1442
1443 pci_set_drvdata(pdev, NULL); 1439 pci_set_drvdata(pdev, NULL);
1444 kfree(chip); 1440 kfree(chip);
1445 1441
@@ -1462,8 +1458,6 @@ static void __devexit sdhci_pci_remove(struct pci_dev *pdev)
1462 for (i = 0; i < chip->num_slots; i++) 1458 for (i = 0; i < chip->num_slots; i++)
1463 sdhci_pci_remove_slot(chip->slots[i]); 1459 sdhci_pci_remove_slot(chip->slots[i]);
1464 1460
1465 pci_disable_msi(pdev);
1466
1467 pci_set_drvdata(pdev, NULL); 1461 pci_set_drvdata(pdev, NULL);
1468 kfree(chip); 1462 kfree(chip);
1469 } 1463 }
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index b19e7d435f8d..55a164fcaa15 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -20,6 +20,10 @@
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/of.h>
24#include <linux/of_gpio.h>
25#include <linux/pm.h>
26#include <linux/pm_runtime.h>
23 27
24#include <linux/mmc/host.h> 28#include <linux/mmc/host.h>
25 29
@@ -53,6 +57,18 @@ struct sdhci_s3c {
53 struct clk *clk_bus[MAX_BUS_CLK]; 57 struct clk *clk_bus[MAX_BUS_CLK];
54}; 58};
55 59
60/**
61 * struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data
62 * @sdhci_quirks: sdhci host specific quirks.
63 *
64 * Specifies platform specific configuration of sdhci controller.
65 * Note: A structure for driver specific platform data is used for future
66 * expansion of its usage.
67 */
68struct sdhci_s3c_drv_data {
69 unsigned int sdhci_quirks;
70};
71
56static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host) 72static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
57{ 73{
58 return sdhci_priv(host); 74 return sdhci_priv(host);
@@ -132,10 +148,10 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
132 return UINT_MAX; 148 return UINT_MAX;
133 149
134 /* 150 /*
135 * Clock divider's step is different as 1 from that of host controller 151 * If controller uses a non-standard clock division, find the best clock
136 * when 'clk_type' is S3C_SDHCI_CLK_DIV_EXTERNAL. 152 * speed possible with selected clock source and skip the division.
137 */ 153 */
138 if (ourhost->pdata->clk_type) { 154 if (ourhost->host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
139 rate = clk_round_rate(clksrc, wanted); 155 rate = clk_round_rate(clksrc, wanted);
140 return wanted - rate; 156 return wanted - rate;
141 } 157 }
@@ -272,6 +288,8 @@ static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
272static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock) 288static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
273{ 289{
274 struct sdhci_s3c *ourhost = to_s3c(host); 290 struct sdhci_s3c *ourhost = to_s3c(host);
291 unsigned long timeout;
292 u16 clk = 0;
275 293
276 /* don't bother if the clock is going off */ 294 /* don't bother if the clock is going off */
277 if (clock == 0) 295 if (clock == 0)
@@ -282,6 +300,25 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
282 clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock); 300 clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
283 301
284 host->clock = clock; 302 host->clock = clock;
303
304 clk = SDHCI_CLOCK_INT_EN;
305 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
306
307 /* Wait max 20 ms */
308 timeout = 20;
309 while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
310 & SDHCI_CLOCK_INT_STABLE)) {
311 if (timeout == 0) {
312 printk(KERN_ERR "%s: Internal clock never "
313 "stabilised.\n", mmc_hostname(host->mmc));
314 return;
315 }
316 timeout--;
317 mdelay(1);
318 }
319
320 clk |= SDHCI_CLOCK_CARD_EN;
321 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
285} 322}
286 323
287/** 324/**
@@ -382,16 +419,24 @@ static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc)
382 } 419 }
383} 420}
384 421
422static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
423 struct platform_device *pdev)
424{
425 return (struct sdhci_s3c_drv_data *)
426 platform_get_device_id(pdev)->driver_data;
427}
428
385static int __devinit sdhci_s3c_probe(struct platform_device *pdev) 429static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
386{ 430{
387 struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data; 431 struct s3c_sdhci_platdata *pdata;
432 struct sdhci_s3c_drv_data *drv_data;
388 struct device *dev = &pdev->dev; 433 struct device *dev = &pdev->dev;
389 struct sdhci_host *host; 434 struct sdhci_host *host;
390 struct sdhci_s3c *sc; 435 struct sdhci_s3c *sc;
391 struct resource *res; 436 struct resource *res;
392 int ret, irq, ptr, clks; 437 int ret, irq, ptr, clks;
393 438
394 if (!pdata) { 439 if (!pdev->dev.platform_data) {
395 dev_err(dev, "no device data specified\n"); 440 dev_err(dev, "no device data specified\n");
396 return -ENOENT; 441 return -ENOENT;
397 } 442 }
@@ -402,18 +447,20 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
402 return irq; 447 return irq;
403 } 448 }
404 449
405 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
406 if (!res) {
407 dev_err(dev, "no memory specified\n");
408 return -ENOENT;
409 }
410
411 host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c)); 450 host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c));
412 if (IS_ERR(host)) { 451 if (IS_ERR(host)) {
413 dev_err(dev, "sdhci_alloc_host() failed\n"); 452 dev_err(dev, "sdhci_alloc_host() failed\n");
414 return PTR_ERR(host); 453 return PTR_ERR(host);
415 } 454 }
416 455
456 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
457 if (!pdata) {
458 ret = -ENOMEM;
459 goto err_io_clk;
460 }
461 memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata));
462
463 drv_data = sdhci_s3c_get_driver_data(pdev);
417 sc = sdhci_priv(host); 464 sc = sdhci_priv(host);
418 465
419 sc->host = host; 466 sc->host = host;
@@ -464,15 +511,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
464 goto err_no_busclks; 511 goto err_no_busclks;
465 } 512 }
466 513
467 sc->ioarea = request_mem_region(res->start, resource_size(res), 514 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
468 mmc_hostname(host->mmc)); 515 host->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
469 if (!sc->ioarea) {
470 dev_err(dev, "failed to reserve register area\n");
471 ret = -ENXIO;
472 goto err_req_regs;
473 }
474
475 host->ioaddr = ioremap_nocache(res->start, resource_size(res));
476 if (!host->ioaddr) { 516 if (!host->ioaddr) {
477 dev_err(dev, "failed to map registers\n"); 517 dev_err(dev, "failed to map registers\n");
478 ret = -ENXIO; 518 ret = -ENXIO;
@@ -491,6 +531,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
491 /* Setup quirks for the controller */ 531 /* Setup quirks for the controller */
492 host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC; 532 host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC;
493 host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT; 533 host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
534 if (drv_data)
535 host->quirks |= drv_data->sdhci_quirks;
494 536
495#ifndef CONFIG_MMC_SDHCI_S3C_DMA 537#ifndef CONFIG_MMC_SDHCI_S3C_DMA
496 538
@@ -518,6 +560,14 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
518 if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT) 560 if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
519 host->mmc->caps = MMC_CAP_NONREMOVABLE; 561 host->mmc->caps = MMC_CAP_NONREMOVABLE;
520 562
563 switch (pdata->max_width) {
564 case 8:
565 host->mmc->caps |= MMC_CAP_8_BIT_DATA;
566 case 4:
567 host->mmc->caps |= MMC_CAP_4_BIT_DATA;
568 break;
569 }
570
521 if (pdata->pm_caps) 571 if (pdata->pm_caps)
522 host->mmc->pm_caps |= pdata->pm_caps; 572 host->mmc->pm_caps |= pdata->pm_caps;
523 573
@@ -531,7 +581,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
531 * If controller does not have internal clock divider, 581 * If controller does not have internal clock divider,
532 * we can use overriding functions instead of default. 582 * we can use overriding functions instead of default.
533 */ 583 */
534 if (pdata->clk_type) { 584 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
535 sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock; 585 sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
536 sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock; 586 sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
537 sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock; 587 sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
@@ -544,10 +594,17 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
544 if (pdata->host_caps2) 594 if (pdata->host_caps2)
545 host->mmc->caps2 |= pdata->host_caps2; 595 host->mmc->caps2 |= pdata->host_caps2;
546 596
597 pm_runtime_enable(&pdev->dev);
598 pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
599 pm_runtime_use_autosuspend(&pdev->dev);
600 pm_suspend_ignore_children(&pdev->dev, 1);
601
547 ret = sdhci_add_host(host); 602 ret = sdhci_add_host(host);
548 if (ret) { 603 if (ret) {
549 dev_err(dev, "sdhci_add_host() failed\n"); 604 dev_err(dev, "sdhci_add_host() failed\n");
550 goto err_add_host; 605 pm_runtime_forbid(&pdev->dev);
606 pm_runtime_get_noresume(&pdev->dev);
607 goto err_req_regs;
551 } 608 }
552 609
553 /* The following two methods of card detection might call 610 /* The following two methods of card detection might call
@@ -561,10 +618,6 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
561 618
562 return 0; 619 return 0;
563 620
564 err_add_host:
565 release_resource(sc->ioarea);
566 kfree(sc->ioarea);
567
568 err_req_regs: 621 err_req_regs:
569 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { 622 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
570 if (sc->clk_bus[ptr]) { 623 if (sc->clk_bus[ptr]) {
@@ -601,6 +654,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
601 654
602 sdhci_remove_host(host, 1); 655 sdhci_remove_host(host, 1);
603 656
657 pm_runtime_disable(&pdev->dev);
658
604 for (ptr = 0; ptr < 3; ptr++) { 659 for (ptr = 0; ptr < 3; ptr++) {
605 if (sc->clk_bus[ptr]) { 660 if (sc->clk_bus[ptr]) {
606 clk_disable(sc->clk_bus[ptr]); 661 clk_disable(sc->clk_bus[ptr]);
@@ -610,18 +665,13 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
610 clk_disable(sc->clk_io); 665 clk_disable(sc->clk_io);
611 clk_put(sc->clk_io); 666 clk_put(sc->clk_io);
612 667
613 iounmap(host->ioaddr);
614 release_resource(sc->ioarea);
615 kfree(sc->ioarea);
616
617 sdhci_free_host(host); 668 sdhci_free_host(host);
618 platform_set_drvdata(pdev, NULL); 669 platform_set_drvdata(pdev, NULL);
619 670
620 return 0; 671 return 0;
621} 672}
622 673
623#ifdef CONFIG_PM 674#ifdef CONFIG_PM_SLEEP
624
625static int sdhci_s3c_suspend(struct device *dev) 675static int sdhci_s3c_suspend(struct device *dev)
626{ 676{
627 struct sdhci_host *host = dev_get_drvdata(dev); 677 struct sdhci_host *host = dev_get_drvdata(dev);
@@ -635,10 +685,29 @@ static int sdhci_s3c_resume(struct device *dev)
635 685
636 return sdhci_resume_host(host); 686 return sdhci_resume_host(host);
637} 687}
688#endif
689
690#ifdef CONFIG_PM_RUNTIME
691static int sdhci_s3c_runtime_suspend(struct device *dev)
692{
693 struct sdhci_host *host = dev_get_drvdata(dev);
694
695 return sdhci_runtime_suspend_host(host);
696}
638 697
698static int sdhci_s3c_runtime_resume(struct device *dev)
699{
700 struct sdhci_host *host = dev_get_drvdata(dev);
701
702 return sdhci_runtime_resume_host(host);
703}
704#endif
705
706#ifdef CONFIG_PM
639static const struct dev_pm_ops sdhci_s3c_pmops = { 707static const struct dev_pm_ops sdhci_s3c_pmops = {
640 .suspend = sdhci_s3c_suspend, 708 SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
641 .resume = sdhci_s3c_resume, 709 SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
710 NULL)
642}; 711};
643 712
644#define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops) 713#define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)
@@ -647,9 +716,31 @@ static const struct dev_pm_ops sdhci_s3c_pmops = {
647#define SDHCI_S3C_PMOPS NULL 716#define SDHCI_S3C_PMOPS NULL
648#endif 717#endif
649 718
719#if defined(CONFIG_CPU_EXYNOS4210) || defined(CONFIG_SOC_EXYNOS4212)
720static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
721 .sdhci_quirks = SDHCI_QUIRK_NONSTANDARD_CLOCK,
722};
723#define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)&exynos4_sdhci_drv_data)
724#else
725#define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)NULL)
726#endif
727
728static struct platform_device_id sdhci_s3c_driver_ids[] = {
729 {
730 .name = "s3c-sdhci",
731 .driver_data = (kernel_ulong_t)NULL,
732 }, {
733 .name = "exynos4-sdhci",
734 .driver_data = EXYNOS4_SDHCI_DRV_DATA,
735 },
736 { }
737};
738MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);
739
650static struct platform_driver sdhci_s3c_driver = { 740static struct platform_driver sdhci_s3c_driver = {
651 .probe = sdhci_s3c_probe, 741 .probe = sdhci_s3c_probe,
652 .remove = __devexit_p(sdhci_s3c_remove), 742 .remove = __devexit_p(sdhci_s3c_remove),
743 .id_table = sdhci_s3c_driver_ids,
653 .driver = { 744 .driver = {
654 .owner = THIS_MODULE, 745 .owner = THIS_MODULE,
655 .name = "s3c-sdhci", 746 .name = "s3c-sdhci",
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 8262cadfdab7..9aa77f3f04a8 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2782,8 +2782,9 @@ int sdhci_add_host(struct sdhci_host *host)
2782 mmc_card_is_removable(mmc)) 2782 mmc_card_is_removable(mmc))
2783 mmc->caps |= MMC_CAP_NEEDS_POLL; 2783 mmc->caps |= MMC_CAP_NEEDS_POLL;
2784 2784
2785 /* UHS-I mode(s) supported by the host controller. */ 2785 /* Any UHS-I mode in caps implies SDR12 and SDR25 support. */
2786 if (host->version >= SDHCI_SPEC_300) 2786 if (caps[1] & (SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
2787 SDHCI_SUPPORT_DDR50))
2787 mmc->caps |= MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25; 2788 mmc->caps |= MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25;
2788 2789
2789 /* SDR104 supports also implies SDR50 support */ 2790 /* SDR104 supports also implies SDR50 support */
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index aafaf0b6eb1c..724b35e85a26 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -454,7 +454,8 @@ static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk)
454 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_SUP_PCLK); 454 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_SUP_PCLK);
455 else 455 else
456 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR & 456 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR &
457 ((fls(host->clk / clk) - 1) << 16)); 457 ((fls(DIV_ROUND_UP(host->clk,
458 clk) - 1) - 1) << 16));
458 459
459 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_ENABLE); 460 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_ENABLE);
460} 461}
@@ -1297,14 +1298,8 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
1297 spin_lock_init(&host->lock); 1298 spin_lock_init(&host->lock);
1298 1299
1299 mmc->ops = &sh_mmcif_ops; 1300 mmc->ops = &sh_mmcif_ops;
1300 mmc->f_max = host->clk; 1301 mmc->f_max = host->clk / 2;
1301 /* close to 400KHz */ 1302 mmc->f_min = host->clk / 512;
1302 if (mmc->f_max < 51200000)
1303 mmc->f_min = mmc->f_max / 128;
1304 else if (mmc->f_max < 102400000)
1305 mmc->f_min = mmc->f_max / 256;
1306 else
1307 mmc->f_min = mmc->f_max / 512;
1308 if (pd->ocr) 1303 if (pd->ocr)
1309 mmc->ocr_avail = pd->ocr; 1304 mmc->ocr_avail = pd->ocr;
1310 mmc->caps = MMC_CAP_MMC_HIGHSPEED; 1305 mmc->caps = MMC_CAP_MMC_HIGHSPEED;
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index e2cdebf40840..61af9bb560ab 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -386,19 +386,11 @@ out:
386 return count; 386 return count;
387} 387}
388 388
389static int default_open(struct inode *inode, struct file *file)
390{
391 if (inode->i_private)
392 file->private_data = inode->i_private;
393
394 return 0;
395}
396
397/* File operations for all UBI debugfs files */ 389/* File operations for all UBI debugfs files */
398static const struct file_operations dfs_fops = { 390static const struct file_operations dfs_fops = {
399 .read = dfs_file_read, 391 .read = dfs_file_read,
400 .write = dfs_file_write, 392 .write = dfs_file_write,
401 .open = default_open, 393 .open = simple_open,
402 .llseek = no_llseek, 394 .llseek = no_llseek,
403 .owner = THIS_MODULE, 395 .owner = THIS_MODULE,
404}; 396};
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 0c76186bb9e7..62d2409bb293 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -891,9 +891,15 @@ static void bond_do_fail_over_mac(struct bonding *bond,
891 891
892 switch (bond->params.fail_over_mac) { 892 switch (bond->params.fail_over_mac) {
893 case BOND_FOM_ACTIVE: 893 case BOND_FOM_ACTIVE:
894 if (new_active) 894 if (new_active) {
895 memcpy(bond->dev->dev_addr, new_active->dev->dev_addr, 895 memcpy(bond->dev->dev_addr, new_active->dev->dev_addr,
896 new_active->dev->addr_len); 896 new_active->dev->addr_len);
897 write_unlock_bh(&bond->curr_slave_lock);
898 read_unlock(&bond->lock);
899 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev);
900 read_lock(&bond->lock);
901 write_lock_bh(&bond->curr_slave_lock);
902 }
897 break; 903 break;
898 case BOND_FOM_FOLLOW: 904 case BOND_FOM_FOLLOW:
899 /* 905 /*
@@ -2028,6 +2034,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
2028 write_unlock_bh(&bond->lock); 2034 write_unlock_bh(&bond->lock);
2029 unblock_netpoll_tx(); 2035 unblock_netpoll_tx();
2030 2036
2037 if (bond->slave_cnt == 0)
2038 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev);
2039
2031 bond_compute_features(bond); 2040 bond_compute_features(bond);
2032 if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) && 2041 if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) &&
2033 (old_features & NETIF_F_VLAN_CHALLENGED)) 2042 (old_features & NETIF_F_VLAN_CHALLENGED))
@@ -3001,7 +3010,11 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
3001 trans_start + delta_in_ticks)) || 3010 trans_start + delta_in_ticks)) ||
3002 bond->curr_active_slave != slave) { 3011 bond->curr_active_slave != slave) {
3003 slave->link = BOND_LINK_UP; 3012 slave->link = BOND_LINK_UP;
3004 bond->current_arp_slave = NULL; 3013 if (bond->current_arp_slave) {
3014 bond_set_slave_inactive_flags(
3015 bond->current_arp_slave);
3016 bond->current_arp_slave = NULL;
3017 }
3005 3018
3006 pr_info("%s: link status definitely up for interface %s.\n", 3019 pr_info("%s: link status definitely up for interface %s.\n",
3007 bond->dev->name, slave->dev->name); 3020 bond->dev->name, slave->dev->name);
@@ -3695,17 +3708,52 @@ static void bond_set_multicast_list(struct net_device *bond_dev)
3695 read_unlock(&bond->lock); 3708 read_unlock(&bond->lock);
3696} 3709}
3697 3710
3698static int bond_neigh_setup(struct net_device *dev, struct neigh_parms *parms) 3711static int bond_neigh_init(struct neighbour *n)
3699{ 3712{
3700 struct bonding *bond = netdev_priv(dev); 3713 struct bonding *bond = netdev_priv(n->dev);
3701 struct slave *slave = bond->first_slave; 3714 struct slave *slave = bond->first_slave;
3715 const struct net_device_ops *slave_ops;
3716 struct neigh_parms parms;
3717 int ret;
3718
3719 if (!slave)
3720 return 0;
3721
3722 slave_ops = slave->dev->netdev_ops;
3723
3724 if (!slave_ops->ndo_neigh_setup)
3725 return 0;
3726
3727 parms.neigh_setup = NULL;
3728 parms.neigh_cleanup = NULL;
3729 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms);
3730 if (ret)
3731 return ret;
3732
3733 /*
3734 * Assign slave's neigh_cleanup to neighbour in case cleanup is called
3735 * after the last slave has been detached. Assumes that all slaves
3736 * utilize the same neigh_cleanup (true at this writing as only user
3737 * is ipoib).
3738 */
3739 n->parms->neigh_cleanup = parms.neigh_cleanup;
3740
3741 if (!parms.neigh_setup)
3742 return 0;
3743
3744 return parms.neigh_setup(n);
3745}
3746
3747/*
3748 * The bonding ndo_neigh_setup is called at init time beofre any
3749 * slave exists. So we must declare proxy setup function which will
3750 * be used at run time to resolve the actual slave neigh param setup.
3751 */
3752static int bond_neigh_setup(struct net_device *dev,
3753 struct neigh_parms *parms)
3754{
3755 parms->neigh_setup = bond_neigh_init;
3702 3756
3703 if (slave) {
3704 const struct net_device_ops *slave_ops
3705 = slave->dev->netdev_ops;
3706 if (slave_ops->ndo_neigh_setup)
3707 return slave_ops->ndo_neigh_setup(slave->dev, parms);
3708 }
3709 return 0; 3757 return 0;
3710} 3758}
3711 3759
diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index 96391c36fa74..b71ce9bf0afb 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -127,12 +127,6 @@ static inline void dev_debugfs_rem(struct cfspi *cfspi)
127 debugfs_remove(cfspi->dbgfs_dir); 127 debugfs_remove(cfspi->dbgfs_dir);
128} 128}
129 129
130static int dbgfs_open(struct inode *inode, struct file *file)
131{
132 file->private_data = inode->i_private;
133 return 0;
134}
135
136static ssize_t dbgfs_state(struct file *file, char __user *user_buf, 130static ssize_t dbgfs_state(struct file *file, char __user *user_buf,
137 size_t count, loff_t *ppos) 131 size_t count, loff_t *ppos)
138{ 132{
@@ -243,13 +237,13 @@ static ssize_t dbgfs_frame(struct file *file, char __user *user_buf,
243} 237}
244 238
245static const struct file_operations dbgfs_state_fops = { 239static const struct file_operations dbgfs_state_fops = {
246 .open = dbgfs_open, 240 .open = simple_open,
247 .read = dbgfs_state, 241 .read = dbgfs_state,
248 .owner = THIS_MODULE 242 .owner = THIS_MODULE
249}; 243};
250 244
251static const struct file_operations dbgfs_frame_fops = { 245static const struct file_operations dbgfs_frame_fops = {
252 .open = dbgfs_open, 246 .open = simple_open,
253 .read = dbgfs_frame, 247 .read = dbgfs_frame,
254 .owner = THIS_MODULE 248 .owner = THIS_MODULE
255}; 249};
diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index a59cf961a436..f219d38acf58 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -125,6 +125,7 @@
125#include <linux/if.h> 125#include <linux/if.h>
126#include <linux/if_arp.h> 126#include <linux/if_arp.h>
127#include <linux/if_eql.h> 127#include <linux/if_eql.h>
128#include <linux/pkt_sched.h>
128 129
129#include <asm/uaccess.h> 130#include <asm/uaccess.h>
130 131
@@ -143,7 +144,7 @@ static void eql_timer(unsigned long param)
143 equalizer_t *eql = (equalizer_t *) param; 144 equalizer_t *eql = (equalizer_t *) param;
144 struct list_head *this, *tmp, *head; 145 struct list_head *this, *tmp, *head;
145 146
146 spin_lock_bh(&eql->queue.lock); 147 spin_lock(&eql->queue.lock);
147 head = &eql->queue.all_slaves; 148 head = &eql->queue.all_slaves;
148 list_for_each_safe(this, tmp, head) { 149 list_for_each_safe(this, tmp, head) {
149 slave_t *slave = list_entry(this, slave_t, list); 150 slave_t *slave = list_entry(this, slave_t, list);
@@ -157,7 +158,7 @@ static void eql_timer(unsigned long param)
157 } 158 }
158 159
159 } 160 }
160 spin_unlock_bh(&eql->queue.lock); 161 spin_unlock(&eql->queue.lock);
161 162
162 eql->timer.expires = jiffies + EQL_DEFAULT_RESCHED_IVAL; 163 eql->timer.expires = jiffies + EQL_DEFAULT_RESCHED_IVAL;
163 add_timer(&eql->timer); 164 add_timer(&eql->timer);
@@ -341,7 +342,7 @@ static netdev_tx_t eql_slave_xmit(struct sk_buff *skb, struct net_device *dev)
341 struct net_device *slave_dev = slave->dev; 342 struct net_device *slave_dev = slave->dev;
342 343
343 skb->dev = slave_dev; 344 skb->dev = slave_dev;
344 skb->priority = 1; 345 skb->priority = TC_PRIO_FILLER;
345 slave->bytes_queued += skb->len; 346 slave->bytes_queued += skb->len;
346 dev_queue_xmit(skb); 347 dev_queue_xmit(skb);
347 dev->stats.tx_packets++; 348 dev->stats.tx_packets++;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index e37161f19250..2c9ee552dffc 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1173,6 +1173,13 @@ enum {
1173}; 1173};
1174 1174
1175 1175
1176struct bnx2x_prev_path_list {
1177 u8 bus;
1178 u8 slot;
1179 u8 path;
1180 struct list_head list;
1181};
1182
1176struct bnx2x { 1183struct bnx2x {
1177 /* Fields used in the tx and intr/napi performance paths 1184 /* Fields used in the tx and intr/napi performance paths
1178 * are grouped together in the beginning of the structure 1185 * are grouped together in the beginning of the structure
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index f1f3ca65667a..4b054812713a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1721,6 +1721,29 @@ static void bnx2x_squeeze_objects(struct bnx2x *bp)
1721 } while (0) 1721 } while (0)
1722#endif 1722#endif
1723 1723
1724bool bnx2x_test_firmware_version(struct bnx2x *bp, bool is_err)
1725{
1726 /* build FW version dword */
1727 u32 my_fw = (BCM_5710_FW_MAJOR_VERSION) +
1728 (BCM_5710_FW_MINOR_VERSION << 8) +
1729 (BCM_5710_FW_REVISION_VERSION << 16) +
1730 (BCM_5710_FW_ENGINEERING_VERSION << 24);
1731
1732 /* read loaded FW from chip */
1733 u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM);
1734
1735 DP(NETIF_MSG_IFUP, "loaded fw %x, my fw %x\n", loaded_fw, my_fw);
1736
1737 if (loaded_fw != my_fw) {
1738 if (is_err)
1739 BNX2X_ERR("bnx2x with FW %x was already loaded, which mismatches my %x FW. aborting\n",
1740 loaded_fw, my_fw);
1741 return false;
1742 }
1743
1744 return true;
1745}
1746
1724/* must be called with rtnl_lock */ 1747/* must be called with rtnl_lock */
1725int bnx2x_nic_load(struct bnx2x *bp, int load_mode) 1748int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1726{ 1749{
@@ -1815,23 +1838,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1815 } 1838 }
1816 if (load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP && 1839 if (load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP &&
1817 load_code != FW_MSG_CODE_DRV_LOAD_COMMON) { 1840 load_code != FW_MSG_CODE_DRV_LOAD_COMMON) {
1818 /* build FW version dword */
1819 u32 my_fw = (BCM_5710_FW_MAJOR_VERSION) +
1820 (BCM_5710_FW_MINOR_VERSION << 8) +
1821 (BCM_5710_FW_REVISION_VERSION << 16) +
1822 (BCM_5710_FW_ENGINEERING_VERSION << 24);
1823
1824 /* read loaded FW from chip */
1825 u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM);
1826
1827 DP(BNX2X_MSG_SP, "loaded fw %x, my fw %x",
1828 loaded_fw, my_fw);
1829
1830 /* abort nic load if version mismatch */ 1841 /* abort nic load if version mismatch */
1831 if (my_fw != loaded_fw) { 1842 if (!bnx2x_test_firmware_version(bp, true)) {
1832 BNX2X_ERR("bnx2x with FW %x already loaded, "
1833 "which mismatches my %x FW. aborting",
1834 loaded_fw, my_fw);
1835 rc = -EBUSY; 1843 rc = -EBUSY;
1836 LOAD_ERROR_EXIT(bp, load_error2); 1844 LOAD_ERROR_EXIT(bp, load_error2);
1837 } 1845 }
@@ -1866,7 +1874,6 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1866 * bnx2x_periodic_task(). 1874 * bnx2x_periodic_task().
1867 */ 1875 */
1868 smp_mb(); 1876 smp_mb();
1869 queue_delayed_work(bnx2x_wq, &bp->period_task, 0);
1870 } else 1877 } else
1871 bp->port.pmf = 0; 1878 bp->port.pmf = 0;
1872 1879
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 8b163388659a..5c27454d2ec2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -431,6 +431,9 @@ void bnx2x_panic_dump(struct bnx2x *bp);
431 431
432void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl); 432void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl);
433 433
434/* validate currect fw is loaded */
435bool bnx2x_test_firmware_version(struct bnx2x *bp, bool is_err);
436
434/* dev_close main block */ 437/* dev_close main block */
435int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode); 438int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode);
436 439
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h
index cd6dfa9eaa3a..b9b263323436 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h
@@ -25,31 +25,31 @@
25 (IRO[149].base + ((funcId) * IRO[149].m1)) 25 (IRO[149].base + ((funcId) * IRO[149].m1))
26#define CSTORM_IGU_MODE_OFFSET (IRO[157].base) 26#define CSTORM_IGU_MODE_OFFSET (IRO[157].base)
27#define CSTORM_ISCSI_CQ_SIZE_OFFSET(pfId) \ 27#define CSTORM_ISCSI_CQ_SIZE_OFFSET(pfId) \
28 (IRO[315].base + ((pfId) * IRO[315].m1))
29#define CSTORM_ISCSI_CQ_SQN_SIZE_OFFSET(pfId) \
30 (IRO[316].base + ((pfId) * IRO[316].m1)) 28 (IRO[316].base + ((pfId) * IRO[316].m1))
29#define CSTORM_ISCSI_CQ_SQN_SIZE_OFFSET(pfId) \
30 (IRO[317].base + ((pfId) * IRO[317].m1))
31#define CSTORM_ISCSI_EQ_CONS_OFFSET(pfId, iscsiEqId) \ 31#define CSTORM_ISCSI_EQ_CONS_OFFSET(pfId, iscsiEqId) \
32 (IRO[308].base + ((pfId) * IRO[308].m1) + ((iscsiEqId) * IRO[308].m2)) 32 (IRO[309].base + ((pfId) * IRO[309].m1) + ((iscsiEqId) * IRO[309].m2))
33#define CSTORM_ISCSI_EQ_NEXT_EQE_ADDR_OFFSET(pfId, iscsiEqId) \ 33#define CSTORM_ISCSI_EQ_NEXT_EQE_ADDR_OFFSET(pfId, iscsiEqId) \
34 (IRO[310].base + ((pfId) * IRO[310].m1) + ((iscsiEqId) * IRO[310].m2)) 34 (IRO[311].base + ((pfId) * IRO[311].m1) + ((iscsiEqId) * IRO[311].m2))
35#define CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_OFFSET(pfId, iscsiEqId) \ 35#define CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_OFFSET(pfId, iscsiEqId) \
36 (IRO[309].base + ((pfId) * IRO[309].m1) + ((iscsiEqId) * IRO[309].m2)) 36 (IRO[310].base + ((pfId) * IRO[310].m1) + ((iscsiEqId) * IRO[310].m2))
37#define CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_VALID_OFFSET(pfId, iscsiEqId) \ 37#define CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_VALID_OFFSET(pfId, iscsiEqId) \
38 (IRO[311].base + ((pfId) * IRO[311].m1) + ((iscsiEqId) * IRO[311].m2)) 38 (IRO[312].base + ((pfId) * IRO[312].m1) + ((iscsiEqId) * IRO[312].m2))
39#define CSTORM_ISCSI_EQ_PROD_OFFSET(pfId, iscsiEqId) \ 39#define CSTORM_ISCSI_EQ_PROD_OFFSET(pfId, iscsiEqId) \
40 (IRO[307].base + ((pfId) * IRO[307].m1) + ((iscsiEqId) * IRO[307].m2)) 40 (IRO[308].base + ((pfId) * IRO[308].m1) + ((iscsiEqId) * IRO[308].m2))
41#define CSTORM_ISCSI_EQ_SB_INDEX_OFFSET(pfId, iscsiEqId) \ 41#define CSTORM_ISCSI_EQ_SB_INDEX_OFFSET(pfId, iscsiEqId) \
42 (IRO[313].base + ((pfId) * IRO[313].m1) + ((iscsiEqId) * IRO[313].m2)) 42 (IRO[314].base + ((pfId) * IRO[314].m1) + ((iscsiEqId) * IRO[314].m2))
43#define CSTORM_ISCSI_EQ_SB_NUM_OFFSET(pfId, iscsiEqId) \ 43#define CSTORM_ISCSI_EQ_SB_NUM_OFFSET(pfId, iscsiEqId) \
44 (IRO[312].base + ((pfId) * IRO[312].m1) + ((iscsiEqId) * IRO[312].m2)) 44 (IRO[313].base + ((pfId) * IRO[313].m1) + ((iscsiEqId) * IRO[313].m2))
45#define CSTORM_ISCSI_HQ_SIZE_OFFSET(pfId) \ 45#define CSTORM_ISCSI_HQ_SIZE_OFFSET(pfId) \
46 (IRO[314].base + ((pfId) * IRO[314].m1)) 46 (IRO[315].base + ((pfId) * IRO[315].m1))
47#define CSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfId) \ 47#define CSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfId) \
48 (IRO[306].base + ((pfId) * IRO[306].m1)) 48 (IRO[307].base + ((pfId) * IRO[307].m1))
49#define CSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfId) \ 49#define CSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfId) \
50 (IRO[305].base + ((pfId) * IRO[305].m1)) 50 (IRO[306].base + ((pfId) * IRO[306].m1))
51#define CSTORM_ISCSI_PAGE_SIZE_OFFSET(pfId) \ 51#define CSTORM_ISCSI_PAGE_SIZE_OFFSET(pfId) \
52 (IRO[304].base + ((pfId) * IRO[304].m1)) 52 (IRO[305].base + ((pfId) * IRO[305].m1))
53#define CSTORM_RECORD_SLOW_PATH_OFFSET(funcId) \ 53#define CSTORM_RECORD_SLOW_PATH_OFFSET(funcId) \
54 (IRO[151].base + ((funcId) * IRO[151].m1)) 54 (IRO[151].base + ((funcId) * IRO[151].m1))
55#define CSTORM_SP_STATUS_BLOCK_DATA_OFFSET(pfId) \ 55#define CSTORM_SP_STATUS_BLOCK_DATA_OFFSET(pfId) \
@@ -96,37 +96,37 @@
96#define TSTORM_FUNC_EN_OFFSET(funcId) \ 96#define TSTORM_FUNC_EN_OFFSET(funcId) \
97 (IRO[103].base + ((funcId) * IRO[103].m1)) 97 (IRO[103].base + ((funcId) * IRO[103].m1))
98#define TSTORM_ISCSI_ERROR_BITMAP_OFFSET(pfId) \ 98#define TSTORM_ISCSI_ERROR_BITMAP_OFFSET(pfId) \
99 (IRO[271].base + ((pfId) * IRO[271].m1))
100#define TSTORM_ISCSI_L2_ISCSI_OOO_CID_TABLE_OFFSET(pfId) \
101 (IRO[272].base + ((pfId) * IRO[272].m1)) 99 (IRO[272].base + ((pfId) * IRO[272].m1))
102#define TSTORM_ISCSI_L2_ISCSI_OOO_CLIENT_ID_TABLE_OFFSET(pfId) \ 100#define TSTORM_ISCSI_L2_ISCSI_OOO_CID_TABLE_OFFSET(pfId) \
103 (IRO[273].base + ((pfId) * IRO[273].m1)) 101 (IRO[273].base + ((pfId) * IRO[273].m1))
104#define TSTORM_ISCSI_L2_ISCSI_OOO_PROD_OFFSET(pfId) \ 102#define TSTORM_ISCSI_L2_ISCSI_OOO_CLIENT_ID_TABLE_OFFSET(pfId) \
105 (IRO[274].base + ((pfId) * IRO[274].m1)) 103 (IRO[274].base + ((pfId) * IRO[274].m1))
104#define TSTORM_ISCSI_L2_ISCSI_OOO_PROD_OFFSET(pfId) \
105 (IRO[275].base + ((pfId) * IRO[275].m1))
106#define TSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfId) \ 106#define TSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfId) \
107 (IRO[270].base + ((pfId) * IRO[270].m1)) 107 (IRO[271].base + ((pfId) * IRO[271].m1))
108#define TSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfId) \ 108#define TSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfId) \
109 (IRO[269].base + ((pfId) * IRO[269].m1)) 109 (IRO[270].base + ((pfId) * IRO[270].m1))
110#define TSTORM_ISCSI_PAGE_SIZE_OFFSET(pfId) \ 110#define TSTORM_ISCSI_PAGE_SIZE_OFFSET(pfId) \
111 (IRO[268].base + ((pfId) * IRO[268].m1)) 111 (IRO[269].base + ((pfId) * IRO[269].m1))
112#define TSTORM_ISCSI_RQ_SIZE_OFFSET(pfId) \ 112#define TSTORM_ISCSI_RQ_SIZE_OFFSET(pfId) \
113 (IRO[267].base + ((pfId) * IRO[267].m1)) 113 (IRO[268].base + ((pfId) * IRO[268].m1))
114#define TSTORM_ISCSI_TCP_LOCAL_ADV_WND_OFFSET(pfId) \ 114#define TSTORM_ISCSI_TCP_LOCAL_ADV_WND_OFFSET(pfId) \
115 (IRO[276].base + ((pfId) * IRO[276].m1)) 115 (IRO[277].base + ((pfId) * IRO[277].m1))
116#define TSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(pfId) \ 116#define TSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(pfId) \
117 (IRO[263].base + ((pfId) * IRO[263].m1))
118#define TSTORM_ISCSI_TCP_VARS_LSB_LOCAL_MAC_ADDR_OFFSET(pfId) \
119 (IRO[264].base + ((pfId) * IRO[264].m1)) 117 (IRO[264].base + ((pfId) * IRO[264].m1))
120#define TSTORM_ISCSI_TCP_VARS_MID_LOCAL_MAC_ADDR_OFFSET(pfId) \ 118#define TSTORM_ISCSI_TCP_VARS_LSB_LOCAL_MAC_ADDR_OFFSET(pfId) \
121 (IRO[265].base + ((pfId) * IRO[265].m1)) 119 (IRO[265].base + ((pfId) * IRO[265].m1))
122#define TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(pfId) \ 120#define TSTORM_ISCSI_TCP_VARS_MID_LOCAL_MAC_ADDR_OFFSET(pfId) \
123 (IRO[266].base + ((pfId) * IRO[266].m1)) 121 (IRO[266].base + ((pfId) * IRO[266].m1))
122#define TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(pfId) \
123 (IRO[267].base + ((pfId) * IRO[267].m1))
124#define TSTORM_MAC_FILTER_CONFIG_OFFSET(pfId) \ 124#define TSTORM_MAC_FILTER_CONFIG_OFFSET(pfId) \
125 (IRO[202].base + ((pfId) * IRO[202].m1)) 125 (IRO[202].base + ((pfId) * IRO[202].m1))
126#define TSTORM_RECORD_SLOW_PATH_OFFSET(funcId) \ 126#define TSTORM_RECORD_SLOW_PATH_OFFSET(funcId) \
127 (IRO[105].base + ((funcId) * IRO[105].m1)) 127 (IRO[105].base + ((funcId) * IRO[105].m1))
128#define TSTORM_TCP_MAX_CWND_OFFSET(pfId) \ 128#define TSTORM_TCP_MAX_CWND_OFFSET(pfId) \
129 (IRO[216].base + ((pfId) * IRO[216].m1)) 129 (IRO[217].base + ((pfId) * IRO[217].m1))
130#define TSTORM_VF_TO_PF_OFFSET(funcId) \ 130#define TSTORM_VF_TO_PF_OFFSET(funcId) \
131 (IRO[104].base + ((funcId) * IRO[104].m1)) 131 (IRO[104].base + ((funcId) * IRO[104].m1))
132#define USTORM_AGG_DATA_OFFSET (IRO[206].base) 132#define USTORM_AGG_DATA_OFFSET (IRO[206].base)
@@ -140,29 +140,29 @@
140#define USTORM_ETH_PAUSE_ENABLED_OFFSET(portId) \ 140#define USTORM_ETH_PAUSE_ENABLED_OFFSET(portId) \
141 (IRO[183].base + ((portId) * IRO[183].m1)) 141 (IRO[183].base + ((portId) * IRO[183].m1))
142#define USTORM_FCOE_EQ_PROD_OFFSET(pfId) \ 142#define USTORM_FCOE_EQ_PROD_OFFSET(pfId) \
143 (IRO[317].base + ((pfId) * IRO[317].m1)) 143 (IRO[318].base + ((pfId) * IRO[318].m1))
144#define USTORM_FUNC_EN_OFFSET(funcId) \ 144#define USTORM_FUNC_EN_OFFSET(funcId) \
145 (IRO[178].base + ((funcId) * IRO[178].m1)) 145 (IRO[178].base + ((funcId) * IRO[178].m1))
146#define USTORM_ISCSI_CQ_SIZE_OFFSET(pfId) \ 146#define USTORM_ISCSI_CQ_SIZE_OFFSET(pfId) \
147 (IRO[281].base + ((pfId) * IRO[281].m1))
148#define USTORM_ISCSI_CQ_SQN_SIZE_OFFSET(pfId) \
149 (IRO[282].base + ((pfId) * IRO[282].m1)) 147 (IRO[282].base + ((pfId) * IRO[282].m1))
148#define USTORM_ISCSI_CQ_SQN_SIZE_OFFSET(pfId) \
149 (IRO[283].base + ((pfId) * IRO[283].m1))
150#define USTORM_ISCSI_ERROR_BITMAP_OFFSET(pfId) \ 150#define USTORM_ISCSI_ERROR_BITMAP_OFFSET(pfId) \
151 (IRO[286].base + ((pfId) * IRO[286].m1)) 151 (IRO[287].base + ((pfId) * IRO[287].m1))
152#define USTORM_ISCSI_GLOBAL_BUF_PHYS_ADDR_OFFSET(pfId) \ 152#define USTORM_ISCSI_GLOBAL_BUF_PHYS_ADDR_OFFSET(pfId) \
153 (IRO[283].base + ((pfId) * IRO[283].m1)) 153 (IRO[284].base + ((pfId) * IRO[284].m1))
154#define USTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfId) \ 154#define USTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfId) \
155 (IRO[279].base + ((pfId) * IRO[279].m1)) 155 (IRO[280].base + ((pfId) * IRO[280].m1))
156#define USTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfId) \ 156#define USTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfId) \
157 (IRO[278].base + ((pfId) * IRO[278].m1)) 157 (IRO[279].base + ((pfId) * IRO[279].m1))
158#define USTORM_ISCSI_PAGE_SIZE_OFFSET(pfId) \ 158#define USTORM_ISCSI_PAGE_SIZE_OFFSET(pfId) \
159 (IRO[277].base + ((pfId) * IRO[277].m1)) 159 (IRO[278].base + ((pfId) * IRO[278].m1))
160#define USTORM_ISCSI_R2TQ_SIZE_OFFSET(pfId) \ 160#define USTORM_ISCSI_R2TQ_SIZE_OFFSET(pfId) \
161 (IRO[280].base + ((pfId) * IRO[280].m1)) 161 (IRO[281].base + ((pfId) * IRO[281].m1))
162#define USTORM_ISCSI_RQ_BUFFER_SIZE_OFFSET(pfId) \ 162#define USTORM_ISCSI_RQ_BUFFER_SIZE_OFFSET(pfId) \
163 (IRO[284].base + ((pfId) * IRO[284].m1))
164#define USTORM_ISCSI_RQ_SIZE_OFFSET(pfId) \
165 (IRO[285].base + ((pfId) * IRO[285].m1)) 163 (IRO[285].base + ((pfId) * IRO[285].m1))
164#define USTORM_ISCSI_RQ_SIZE_OFFSET(pfId) \
165 (IRO[286].base + ((pfId) * IRO[286].m1))
166#define USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(pfId) \ 166#define USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(pfId) \
167 (IRO[182].base + ((pfId) * IRO[182].m1)) 167 (IRO[182].base + ((pfId) * IRO[182].m1))
168#define USTORM_RECORD_SLOW_PATH_OFFSET(funcId) \ 168#define USTORM_RECORD_SLOW_PATH_OFFSET(funcId) \
@@ -188,39 +188,39 @@
188#define XSTORM_FUNC_EN_OFFSET(funcId) \ 188#define XSTORM_FUNC_EN_OFFSET(funcId) \
189 (IRO[47].base + ((funcId) * IRO[47].m1)) 189 (IRO[47].base + ((funcId) * IRO[47].m1))
190#define XSTORM_ISCSI_HQ_SIZE_OFFSET(pfId) \ 190#define XSTORM_ISCSI_HQ_SIZE_OFFSET(pfId) \
191 (IRO[294].base + ((pfId) * IRO[294].m1)) 191 (IRO[295].base + ((pfId) * IRO[295].m1))
192#define XSTORM_ISCSI_LOCAL_MAC_ADDR0_OFFSET(pfId) \ 192#define XSTORM_ISCSI_LOCAL_MAC_ADDR0_OFFSET(pfId) \
193 (IRO[297].base + ((pfId) * IRO[297].m1))
194#define XSTORM_ISCSI_LOCAL_MAC_ADDR1_OFFSET(pfId) \
195 (IRO[298].base + ((pfId) * IRO[298].m1)) 193 (IRO[298].base + ((pfId) * IRO[298].m1))
196#define XSTORM_ISCSI_LOCAL_MAC_ADDR2_OFFSET(pfId) \ 194#define XSTORM_ISCSI_LOCAL_MAC_ADDR1_OFFSET(pfId) \
197 (IRO[299].base + ((pfId) * IRO[299].m1)) 195 (IRO[299].base + ((pfId) * IRO[299].m1))
198#define XSTORM_ISCSI_LOCAL_MAC_ADDR3_OFFSET(pfId) \ 196#define XSTORM_ISCSI_LOCAL_MAC_ADDR2_OFFSET(pfId) \
199 (IRO[300].base + ((pfId) * IRO[300].m1)) 197 (IRO[300].base + ((pfId) * IRO[300].m1))
200#define XSTORM_ISCSI_LOCAL_MAC_ADDR4_OFFSET(pfId) \ 198#define XSTORM_ISCSI_LOCAL_MAC_ADDR3_OFFSET(pfId) \
201 (IRO[301].base + ((pfId) * IRO[301].m1)) 199 (IRO[301].base + ((pfId) * IRO[301].m1))
202#define XSTORM_ISCSI_LOCAL_MAC_ADDR5_OFFSET(pfId) \ 200#define XSTORM_ISCSI_LOCAL_MAC_ADDR4_OFFSET(pfId) \
203 (IRO[302].base + ((pfId) * IRO[302].m1)) 201 (IRO[302].base + ((pfId) * IRO[302].m1))
204#define XSTORM_ISCSI_LOCAL_VLAN_OFFSET(pfId) \ 202#define XSTORM_ISCSI_LOCAL_MAC_ADDR5_OFFSET(pfId) \
205 (IRO[303].base + ((pfId) * IRO[303].m1)) 203 (IRO[303].base + ((pfId) * IRO[303].m1))
204#define XSTORM_ISCSI_LOCAL_VLAN_OFFSET(pfId) \
205 (IRO[304].base + ((pfId) * IRO[304].m1))
206#define XSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfId) \ 206#define XSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfId) \
207 (IRO[293].base + ((pfId) * IRO[293].m1)) 207 (IRO[294].base + ((pfId) * IRO[294].m1))
208#define XSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfId) \ 208#define XSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfId) \
209 (IRO[292].base + ((pfId) * IRO[292].m1)) 209 (IRO[293].base + ((pfId) * IRO[293].m1))
210#define XSTORM_ISCSI_PAGE_SIZE_OFFSET(pfId) \ 210#define XSTORM_ISCSI_PAGE_SIZE_OFFSET(pfId) \
211 (IRO[291].base + ((pfId) * IRO[291].m1)) 211 (IRO[292].base + ((pfId) * IRO[292].m1))
212#define XSTORM_ISCSI_R2TQ_SIZE_OFFSET(pfId) \ 212#define XSTORM_ISCSI_R2TQ_SIZE_OFFSET(pfId) \
213 (IRO[296].base + ((pfId) * IRO[296].m1)) 213 (IRO[297].base + ((pfId) * IRO[297].m1))
214#define XSTORM_ISCSI_SQ_SIZE_OFFSET(pfId) \ 214#define XSTORM_ISCSI_SQ_SIZE_OFFSET(pfId) \
215 (IRO[295].base + ((pfId) * IRO[295].m1)) 215 (IRO[296].base + ((pfId) * IRO[296].m1))
216#define XSTORM_ISCSI_TCP_VARS_ADV_WND_SCL_OFFSET(pfId) \ 216#define XSTORM_ISCSI_TCP_VARS_ADV_WND_SCL_OFFSET(pfId) \
217 (IRO[290].base + ((pfId) * IRO[290].m1)) 217 (IRO[291].base + ((pfId) * IRO[291].m1))
218#define XSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(pfId) \ 218#define XSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(pfId) \
219 (IRO[289].base + ((pfId) * IRO[289].m1)) 219 (IRO[290].base + ((pfId) * IRO[290].m1))
220#define XSTORM_ISCSI_TCP_VARS_TOS_OFFSET(pfId) \ 220#define XSTORM_ISCSI_TCP_VARS_TOS_OFFSET(pfId) \
221 (IRO[288].base + ((pfId) * IRO[288].m1)) 221 (IRO[289].base + ((pfId) * IRO[289].m1))
222#define XSTORM_ISCSI_TCP_VARS_TTL_OFFSET(pfId) \ 222#define XSTORM_ISCSI_TCP_VARS_TTL_OFFSET(pfId) \
223 (IRO[287].base + ((pfId) * IRO[287].m1)) 223 (IRO[288].base + ((pfId) * IRO[288].m1))
224#define XSTORM_RATE_SHAPING_PER_VN_VARS_OFFSET(pfId) \ 224#define XSTORM_RATE_SHAPING_PER_VN_VARS_OFFSET(pfId) \
225 (IRO[44].base + ((pfId) * IRO[44].m1)) 225 (IRO[44].base + ((pfId) * IRO[44].m1))
226#define XSTORM_RECORD_SLOW_PATH_OFFSET(funcId) \ 226#define XSTORM_RECORD_SLOW_PATH_OFFSET(funcId) \
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index 5d71b7d43237..dbff5915b81a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -1251,6 +1251,9 @@ struct drv_func_mb {
1251 1251
1252 #define DRV_MSG_CODE_LINK_STATUS_CHANGED 0x01000000 1252 #define DRV_MSG_CODE_LINK_STATUS_CHANGED 0x01000000
1253 1253
1254 #define DRV_MSG_CODE_INITIATE_FLR 0x02000000
1255 #define REQ_BC_VER_4_INITIATE_FLR 0x00070213
1256
1254 #define BIOS_MSG_CODE_LIC_CHALLENGE 0xff010000 1257 #define BIOS_MSG_CODE_LIC_CHALLENGE 0xff010000
1255 #define BIOS_MSG_CODE_LIC_RESPONSE 0xff020000 1258 #define BIOS_MSG_CODE_LIC_RESPONSE 0xff020000
1256 #define BIOS_MSG_CODE_VIRT_MAC_PRIM 0xff030000 1259 #define BIOS_MSG_CODE_VIRT_MAC_PRIM 0xff030000
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
index beb4cdbdb6e1..ad95324dc042 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
@@ -35,7 +35,6 @@
35#define ETH_MAX_PACKET_SIZE 1500 35#define ETH_MAX_PACKET_SIZE 1500
36#define ETH_MAX_JUMBO_PACKET_SIZE 9600 36#define ETH_MAX_JUMBO_PACKET_SIZE 9600
37#define MDIO_ACCESS_TIMEOUT 1000 37#define MDIO_ACCESS_TIMEOUT 1000
38#define BMAC_CONTROL_RX_ENABLE 2
39#define WC_LANE_MAX 4 38#define WC_LANE_MAX 4
40#define I2C_SWITCH_WIDTH 2 39#define I2C_SWITCH_WIDTH 2
41#define I2C_BSC0 0 40#define I2C_BSC0 0
@@ -1372,7 +1371,14 @@ static void bnx2x_update_pfc_xmac(struct link_params *params,
1372 pfc1_val |= XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN | 1371 pfc1_val |= XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN |
1373 XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN | 1372 XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN |
1374 XMAC_PFC_CTRL_HI_REG_RX_PFC_EN | 1373 XMAC_PFC_CTRL_HI_REG_RX_PFC_EN |
1375 XMAC_PFC_CTRL_HI_REG_TX_PFC_EN; 1374 XMAC_PFC_CTRL_HI_REG_TX_PFC_EN |
1375 XMAC_PFC_CTRL_HI_REG_FORCE_PFC_XON;
1376 /* Write pause and PFC registers */
1377 REG_WR(bp, xmac_base + XMAC_REG_PAUSE_CTRL, pause_val);
1378 REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL, pfc0_val);
1379 REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, pfc1_val);
1380 pfc1_val &= ~XMAC_PFC_CTRL_HI_REG_FORCE_PFC_XON;
1381
1376 } 1382 }
1377 1383
1378 /* Write pause and PFC registers */ 1384 /* Write pause and PFC registers */
@@ -3649,6 +3655,33 @@ static void bnx2x_ext_phy_update_adv_fc(struct bnx2x_phy *phy,
3649 if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) { 3655 if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) {
3650 bnx2x_cl22_read(bp, phy, 0x4, &ld_pause); 3656 bnx2x_cl22_read(bp, phy, 0x4, &ld_pause);
3651 bnx2x_cl22_read(bp, phy, 0x5, &lp_pause); 3657 bnx2x_cl22_read(bp, phy, 0x5, &lp_pause);
3658 } else if (CHIP_IS_E3(bp) &&
3659 SINGLE_MEDIA_DIRECT(params)) {
3660 u8 lane = bnx2x_get_warpcore_lane(phy, params);
3661 u16 gp_status, gp_mask;
3662 bnx2x_cl45_read(bp, phy,
3663 MDIO_AN_DEVAD, MDIO_WC_REG_GP2_STATUS_GP_2_4,
3664 &gp_status);
3665 gp_mask = (MDIO_WC_REG_GP2_STATUS_GP_2_4_CL73_AN_CMPL |
3666 MDIO_WC_REG_GP2_STATUS_GP_2_4_CL37_LP_AN_CAP) <<
3667 lane;
3668 if ((gp_status & gp_mask) == gp_mask) {
3669 bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD,
3670 MDIO_AN_REG_ADV_PAUSE, &ld_pause);
3671 bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD,
3672 MDIO_AN_REG_LP_AUTO_NEG, &lp_pause);
3673 } else {
3674 bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD,
3675 MDIO_AN_REG_CL37_FC_LD, &ld_pause);
3676 bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD,
3677 MDIO_AN_REG_CL37_FC_LP, &lp_pause);
3678 ld_pause = ((ld_pause &
3679 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH)
3680 << 3);
3681 lp_pause = ((lp_pause &
3682 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH)
3683 << 3);
3684 }
3652 } else { 3685 } else {
3653 bnx2x_cl45_read(bp, phy, 3686 bnx2x_cl45_read(bp, phy,
3654 MDIO_AN_DEVAD, 3687 MDIO_AN_DEVAD,
@@ -3699,7 +3732,23 @@ static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy,
3699 u16 val16 = 0, lane, bam37 = 0; 3732 u16 val16 = 0, lane, bam37 = 0;
3700 struct bnx2x *bp = params->bp; 3733 struct bnx2x *bp = params->bp;
3701 DP(NETIF_MSG_LINK, "Enable Auto Negotiation for KR\n"); 3734 DP(NETIF_MSG_LINK, "Enable Auto Negotiation for KR\n");
3702 3735 /* Set to default registers that may be overriden by 10G force */
3736 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3737 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7);
3738 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
3739 MDIO_WC_REG_PAR_DET_10G_CTRL, 0);
3740 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3741 MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 0);
3742 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3743 MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0xff);
3744 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3745 MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0x5555);
3746 bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD,
3747 MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0x0);
3748 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3749 MDIO_WC_REG_RX66_CONTROL, 0x7415);
3750 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3751 MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x6190);
3703 /* Disable Autoneg: re-enable it after adv is done. */ 3752 /* Disable Autoneg: re-enable it after adv is done. */
3704 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, 3753 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
3705 MDIO_WC_REG_IEEE0BLK_MIICNTL, 0); 3754 MDIO_WC_REG_IEEE0BLK_MIICNTL, 0);
@@ -3945,13 +3994,13 @@ static void bnx2x_warpcore_set_10G_XFI(struct bnx2x_phy *phy,
3945 3994
3946 } else { 3995 } else {
3947 misc1_val |= 0x9; 3996 misc1_val |= 0x9;
3948 tap_val = ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | 3997 tap_val = ((0x0f << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) |
3949 (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | 3998 (0x2b << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) |
3950 (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); 3999 (0x02 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET));
3951 tx_driver_val = 4000 tx_driver_val =
3952 ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | 4001 ((0x03 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) |
3953 (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | 4002 (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) |
3954 (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); 4003 (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET));
3955 } 4004 }
3956 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, 4005 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3957 MDIO_WC_REG_SERDESDIGITAL_MISC1, misc1_val); 4006 MDIO_WC_REG_SERDESDIGITAL_MISC1, misc1_val);
@@ -4369,7 +4418,7 @@ static void bnx2x_warpcore_config_init(struct bnx2x_phy *phy,
4369 switch (serdes_net_if) { 4418 switch (serdes_net_if) {
4370 case PORT_HW_CFG_NET_SERDES_IF_KR: 4419 case PORT_HW_CFG_NET_SERDES_IF_KR:
4371 /* Enable KR Auto Neg */ 4420 /* Enable KR Auto Neg */
4372 if (params->loopback_mode == LOOPBACK_NONE) 4421 if (params->loopback_mode != LOOPBACK_EXT)
4373 bnx2x_warpcore_enable_AN_KR(phy, params, vars); 4422 bnx2x_warpcore_enable_AN_KR(phy, params, vars);
4374 else { 4423 else {
4375 DP(NETIF_MSG_LINK, "Setting KR 10G-Force\n"); 4424 DP(NETIF_MSG_LINK, "Setting KR 10G-Force\n");
@@ -6167,12 +6216,14 @@ int bnx2x_set_led(struct link_params *params,
6167 6216
6168 tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); 6217 tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
6169 if (params->phy[EXT_PHY1].type == 6218 if (params->phy[EXT_PHY1].type ==
6170 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) 6219 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE)
6171 EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp & 0xfff1); 6220 tmp &= ~(EMAC_LED_1000MB_OVERRIDE |
6172 else { 6221 EMAC_LED_100MB_OVERRIDE |
6173 EMAC_WR(bp, EMAC_REG_EMAC_LED, 6222 EMAC_LED_10MB_OVERRIDE);
6174 (tmp | EMAC_LED_OVERRIDE)); 6223 else
6175 } 6224 tmp |= EMAC_LED_OVERRIDE;
6225
6226 EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp);
6176 break; 6227 break;
6177 6228
6178 case LED_MODE_OPER: 6229 case LED_MODE_OPER:
@@ -6227,10 +6278,15 @@ int bnx2x_set_led(struct link_params *params,
6227 hw_led_mode); 6278 hw_led_mode);
6228 } else if ((params->phy[EXT_PHY1].type == 6279 } else if ((params->phy[EXT_PHY1].type ==
6229 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) && 6280 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) &&
6230 (mode != LED_MODE_OPER)) { 6281 (mode == LED_MODE_ON)) {
6231 REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); 6282 REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0);
6232 tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); 6283 tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
6233 EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp | 0x3); 6284 EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp |
6285 EMAC_LED_OVERRIDE | EMAC_LED_1000MB_OVERRIDE);
6286 /* Break here; otherwise, it'll disable the
6287 * intended override.
6288 */
6289 break;
6234 } else 6290 } else
6235 REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 6291 REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4,
6236 hw_led_mode); 6292 hw_led_mode);
@@ -6245,13 +6301,9 @@ int bnx2x_set_led(struct link_params *params,
6245 LED_BLINK_RATE_VAL_E1X_E2); 6301 LED_BLINK_RATE_VAL_E1X_E2);
6246 REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 + 6302 REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 +
6247 port*4, 1); 6303 port*4, 1);
6248 if ((params->phy[EXT_PHY1].type != 6304 tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
6249 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) && 6305 EMAC_WR(bp, EMAC_REG_EMAC_LED,
6250 (mode != LED_MODE_OPER)) { 6306 (tmp & (~EMAC_LED_OVERRIDE)));
6251 tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
6252 EMAC_WR(bp, EMAC_REG_EMAC_LED,
6253 (tmp & (~EMAC_LED_OVERRIDE)));
6254 }
6255 6307
6256 if (CHIP_IS_E1(bp) && 6308 if (CHIP_IS_E1(bp) &&
6257 ((speed == SPEED_2500) || 6309 ((speed == SPEED_2500) ||
@@ -6844,6 +6896,12 @@ int bnx2x_link_update(struct link_params *params, struct link_vars *vars)
6844 SINGLE_MEDIA_DIRECT(params)) && 6896 SINGLE_MEDIA_DIRECT(params)) &&
6845 (phy_vars[active_external_phy].fault_detected == 0)); 6897 (phy_vars[active_external_phy].fault_detected == 0));
6846 6898
6899 /* Update the PFC configuration in case it was changed */
6900 if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED)
6901 vars->link_status |= LINK_STATUS_PFC_ENABLED;
6902 else
6903 vars->link_status &= ~LINK_STATUS_PFC_ENABLED;
6904
6847 if (vars->link_up) 6905 if (vars->link_up)
6848 rc = bnx2x_update_link_up(params, vars, link_10g_plus); 6906 rc = bnx2x_update_link_up(params, vars, link_10g_plus);
6849 else 6907 else
@@ -8031,7 +8089,9 @@ static int bnx2x_verify_sfp_module(struct bnx2x_phy *phy,
8031 netdev_err(bp->dev, "Warning: Unqualified SFP+ module detected," 8089 netdev_err(bp->dev, "Warning: Unqualified SFP+ module detected,"
8032 " Port %d from %s part number %s\n", 8090 " Port %d from %s part number %s\n",
8033 params->port, vendor_name, vendor_pn); 8091 params->port, vendor_name, vendor_pn);
8034 phy->flags |= FLAGS_SFP_NOT_APPROVED; 8092 if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) !=
8093 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_WARNING_MSG)
8094 phy->flags |= FLAGS_SFP_NOT_APPROVED;
8035 return -EINVAL; 8095 return -EINVAL;
8036} 8096}
8037 8097
@@ -9091,6 +9151,12 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy,
9091 tmp2 &= 0xFFEF; 9151 tmp2 &= 0xFFEF;
9092 bnx2x_cl45_write(bp, phy, 9152 bnx2x_cl45_write(bp, phy,
9093 MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, tmp2); 9153 MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, tmp2);
9154 bnx2x_cl45_read(bp, phy,
9155 MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER,
9156 &tmp2);
9157 bnx2x_cl45_write(bp, phy,
9158 MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER,
9159 (tmp2 & 0x7fff));
9094 } 9160 }
9095 9161
9096 return 0; 9162 return 0;
@@ -9271,12 +9337,11 @@ static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy,
9271 MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, 9337 MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL,
9272 ((1<<5) | (1<<2))); 9338 ((1<<5) | (1<<2)));
9273 } 9339 }
9274 DP(NETIF_MSG_LINK, "Enabling 8727 TX laser if SFP is approved\n"); 9340
9275 bnx2x_8727_specific_func(phy, params, ENABLE_TX); 9341 if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) {
9276 /* If transmitter is disabled, ignore false link up indication */ 9342 DP(NETIF_MSG_LINK, "Enabling 8727 TX laser\n");
9277 bnx2x_cl45_read(bp, phy, 9343 bnx2x_sfp_set_transmitter(params, phy, 1);
9278 MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &val1); 9344 } else {
9279 if (val1 & (1<<15)) {
9280 DP(NETIF_MSG_LINK, "Tx is disabled\n"); 9345 DP(NETIF_MSG_LINK, "Tx is disabled\n");
9281 return 0; 9346 return 0;
9282 } 9347 }
@@ -9370,8 +9435,7 @@ static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy,
9370 9435
9371 if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { 9436 if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) {
9372 bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, 0x400f, &fw_ver1); 9437 bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, 0x400f, &fw_ver1);
9373 bnx2x_save_spirom_version(bp, port, 9438 bnx2x_save_spirom_version(bp, port, fw_ver1 & 0xfff,
9374 ((fw_ver1 & 0xf000)>>5) | (fw_ver1 & 0x7f),
9375 phy->ver_addr); 9439 phy->ver_addr);
9376 } else { 9440 } else {
9377 /* For 32-bit registers in 848xx, access via MDIO2ARM i/f. */ 9441 /* For 32-bit registers in 848xx, access via MDIO2ARM i/f. */
@@ -9794,6 +9858,15 @@ static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy,
9794 other_shmem_base_addr)); 9858 other_shmem_base_addr));
9795 9859
9796 u32 shmem_base_path[2]; 9860 u32 shmem_base_path[2];
9861
9862 /* Work around for 84833 LED failure inside RESET status */
9863 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
9864 MDIO_AN_REG_8481_LEGACY_MII_CTRL,
9865 MDIO_AN_REG_8481_MII_CTRL_FORCE_1G);
9866 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
9867 MDIO_AN_REG_8481_1G_100T_EXT_CTRL,
9868 MIDO_AN_REG_8481_EXT_CTRL_FORCE_LEDS_OFF);
9869
9797 shmem_base_path[0] = params->shmem_base; 9870 shmem_base_path[0] = params->shmem_base;
9798 shmem_base_path[1] = other_shmem_base_addr; 9871 shmem_base_path[1] = other_shmem_base_addr;
9799 9872
@@ -10104,7 +10177,7 @@ static void bnx2x_848x3_link_reset(struct bnx2x_phy *phy,
10104 u8 port; 10177 u8 port;
10105 u16 val16; 10178 u16 val16;
10106 10179
10107 if (!(CHIP_IS_E1(bp))) 10180 if (!(CHIP_IS_E1x(bp)))
10108 port = BP_PATH(bp); 10181 port = BP_PATH(bp);
10109 else 10182 else
10110 port = params->port; 10183 port = params->port;
@@ -10131,7 +10204,7 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy,
10131 u16 val; 10204 u16 val;
10132 u8 port; 10205 u8 port;
10133 10206
10134 if (!(CHIP_IS_E1(bp))) 10207 if (!(CHIP_IS_E1x(bp)))
10135 port = BP_PATH(bp); 10208 port = BP_PATH(bp);
10136 else 10209 else
10137 port = params->port; 10210 port = params->port;
@@ -12050,6 +12123,9 @@ int bnx2x_phy_init(struct link_params *params, struct link_vars *vars)
12050 12123
12051 bnx2x_emac_init(params, vars); 12124 bnx2x_emac_init(params, vars);
12052 12125
12126 if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED)
12127 vars->link_status |= LINK_STATUS_PFC_ENABLED;
12128
12053 if (params->num_phys == 0) { 12129 if (params->num_phys == 0) {
12054 DP(NETIF_MSG_LINK, "No phy found for initialization !!\n"); 12130 DP(NETIF_MSG_LINK, "No phy found for initialization !!\n");
12055 return -EINVAL; 12131 return -EINVAL;
@@ -12129,10 +12205,10 @@ int bnx2x_link_reset(struct link_params *params, struct link_vars *vars,
12129 * Hold it as vars low 12205 * Hold it as vars low
12130 */ 12206 */
12131 /* clear link led */ 12207 /* clear link led */
12208 bnx2x_set_mdio_clk(bp, params->chip_id, port);
12132 bnx2x_set_led(params, vars, LED_MODE_OFF, 0); 12209 bnx2x_set_led(params, vars, LED_MODE_OFF, 0);
12133 12210
12134 if (reset_ext_phy) { 12211 if (reset_ext_phy) {
12135 bnx2x_set_mdio_clk(bp, params->chip_id, port);
12136 for (phy_index = EXT_PHY1; phy_index < params->num_phys; 12212 for (phy_index = EXT_PHY1; phy_index < params->num_phys;
12137 phy_index++) { 12213 phy_index++) {
12138 if (params->phy[phy_index].link_reset) { 12214 if (params->phy[phy_index].link_reset) {
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
index 7ba557a610da..763535ee4832 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
@@ -89,6 +89,8 @@
89#define PFC_BRB_FULL_LB_XON_THRESHOLD 250 89#define PFC_BRB_FULL_LB_XON_THRESHOLD 250
90 90
91#define MAXVAL(a, b) (((a) > (b)) ? (a) : (b)) 91#define MAXVAL(a, b) (((a) > (b)) ? (a) : (b))
92
93#define BMAC_CONTROL_RX_ENABLE 2
92/***********************************************************/ 94/***********************************************************/
93/* Structs */ 95/* Structs */
94/***********************************************************/ 96/***********************************************************/
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index f7f9aa807264..e077d2508727 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -52,6 +52,7 @@
52#include <linux/prefetch.h> 52#include <linux/prefetch.h>
53#include <linux/zlib.h> 53#include <linux/zlib.h>
54#include <linux/io.h> 54#include <linux/io.h>
55#include <linux/semaphore.h>
55#include <linux/stringify.h> 56#include <linux/stringify.h>
56#include <linux/vmalloc.h> 57#include <linux/vmalloc.h>
57 58
@@ -211,6 +212,10 @@ static DEFINE_PCI_DEVICE_TABLE(bnx2x_pci_tbl) = {
211 212
212MODULE_DEVICE_TABLE(pci, bnx2x_pci_tbl); 213MODULE_DEVICE_TABLE(pci, bnx2x_pci_tbl);
213 214
215/* Global resources for unloading a previously loaded device */
216#define BNX2X_PREV_WAIT_NEEDED 1
217static DEFINE_SEMAPHORE(bnx2x_prev_sem);
218static LIST_HEAD(bnx2x_prev_list);
214/**************************************************************************** 219/****************************************************************************
215* General service functions 220* General service functions
216****************************************************************************/ 221****************************************************************************/
@@ -8812,109 +8817,371 @@ static inline void bnx2x_undi_int_disable(struct bnx2x *bp)
8812 bnx2x_undi_int_disable_e1h(bp); 8817 bnx2x_undi_int_disable_e1h(bp);
8813} 8818}
8814 8819
8815static void __devinit bnx2x_undi_unload(struct bnx2x *bp) 8820static void __devinit bnx2x_prev_unload_close_mac(struct bnx2x *bp)
8816{ 8821{
8817 u32 val; 8822 u32 val, base_addr, offset, mask, reset_reg;
8823 bool mac_stopped = false;
8824 u8 port = BP_PORT(bp);
8818 8825
8819 /* possibly another driver is trying to reset the chip */ 8826 reset_reg = REG_RD(bp, MISC_REG_RESET_REG_2);
8820 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RESET);
8821 8827
8822 /* check if doorbell queue is reset */ 8828 if (!CHIP_IS_E3(bp)) {
8823 if (REG_RD(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET) 8829 val = REG_RD(bp, NIG_REG_BMAC0_REGS_OUT_EN + port * 4);
8824 & MISC_REGISTERS_RESET_REG_1_RST_DORQ) { 8830 mask = MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port;
8831 if ((mask & reset_reg) && val) {
8832 u32 wb_data[2];
8833 BNX2X_DEV_INFO("Disable bmac Rx\n");
8834 base_addr = BP_PORT(bp) ? NIG_REG_INGRESS_BMAC1_MEM
8835 : NIG_REG_INGRESS_BMAC0_MEM;
8836 offset = CHIP_IS_E2(bp) ? BIGMAC2_REGISTER_BMAC_CONTROL
8837 : BIGMAC_REGISTER_BMAC_CONTROL;
8825 8838
8826 /* 8839 /*
8827 * Check if it is the UNDI driver 8840 * use rd/wr since we cannot use dmae. This is safe
8841 * since MCP won't access the bus due to the request
8842 * to unload, and no function on the path can be
8843 * loaded at this time.
8844 */
8845 wb_data[0] = REG_RD(bp, base_addr + offset);
8846 wb_data[1] = REG_RD(bp, base_addr + offset + 0x4);
8847 wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE;
8848 REG_WR(bp, base_addr + offset, wb_data[0]);
8849 REG_WR(bp, base_addr + offset + 0x4, wb_data[1]);
8850
8851 }
8852 BNX2X_DEV_INFO("Disable emac Rx\n");
8853 REG_WR(bp, NIG_REG_NIG_EMAC0_EN + BP_PORT(bp)*4, 0);
8854
8855 mac_stopped = true;
8856 } else {
8857 if (reset_reg & MISC_REGISTERS_RESET_REG_2_XMAC) {
8858 BNX2X_DEV_INFO("Disable xmac Rx\n");
8859 base_addr = BP_PORT(bp) ? GRCBASE_XMAC1 : GRCBASE_XMAC0;
8860 val = REG_RD(bp, base_addr + XMAC_REG_PFC_CTRL_HI);
8861 REG_WR(bp, base_addr + XMAC_REG_PFC_CTRL_HI,
8862 val & ~(1 << 1));
8863 REG_WR(bp, base_addr + XMAC_REG_PFC_CTRL_HI,
8864 val | (1 << 1));
8865 REG_WR(bp, base_addr + XMAC_REG_CTRL, 0);
8866 mac_stopped = true;
8867 }
8868 mask = MISC_REGISTERS_RESET_REG_2_UMAC0 << port;
8869 if (mask & reset_reg) {
8870 BNX2X_DEV_INFO("Disable umac Rx\n");
8871 base_addr = BP_PORT(bp) ? GRCBASE_UMAC1 : GRCBASE_UMAC0;
8872 REG_WR(bp, base_addr + UMAC_REG_COMMAND_CONFIG, 0);
8873 mac_stopped = true;
8874 }
8875 }
8876
8877 if (mac_stopped)
8878 msleep(20);
8879
8880}
8881
8882#define BNX2X_PREV_UNDI_PROD_ADDR(p) (BAR_TSTRORM_INTMEM + 0x1508 + ((p) << 4))
8883#define BNX2X_PREV_UNDI_RCQ(val) ((val) & 0xffff)
8884#define BNX2X_PREV_UNDI_BD(val) ((val) >> 16 & 0xffff)
8885#define BNX2X_PREV_UNDI_PROD(rcq, bd) ((bd) << 16 | (rcq))
8886
8887static void __devinit bnx2x_prev_unload_undi_inc(struct bnx2x *bp, u8 port,
8888 u8 inc)
8889{
8890 u16 rcq, bd;
8891 u32 tmp_reg = REG_RD(bp, BNX2X_PREV_UNDI_PROD_ADDR(port));
8892
8893 rcq = BNX2X_PREV_UNDI_RCQ(tmp_reg) + inc;
8894 bd = BNX2X_PREV_UNDI_BD(tmp_reg) + inc;
8895
8896 tmp_reg = BNX2X_PREV_UNDI_PROD(rcq, bd);
8897 REG_WR(bp, BNX2X_PREV_UNDI_PROD_ADDR(port), tmp_reg);
8898
8899 BNX2X_DEV_INFO("UNDI producer [%d] rings bd -> 0x%04x, rcq -> 0x%04x\n",
8900 port, bd, rcq);
8901}
8902
8903static int __devinit bnx2x_prev_mcp_done(struct bnx2x *bp)
8904{
8905 u32 rc = bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE, 0);
8906 if (!rc) {
8907 BNX2X_ERR("MCP response failure, aborting\n");
8908 return -EBUSY;
8909 }
8910
8911 return 0;
8912}
8913
8914static bool __devinit bnx2x_prev_is_path_marked(struct bnx2x *bp)
8915{
8916 struct bnx2x_prev_path_list *tmp_list;
8917 int rc = false;
8918
8919 if (down_trylock(&bnx2x_prev_sem))
8920 return false;
8921
8922 list_for_each_entry(tmp_list, &bnx2x_prev_list, list) {
8923 if (PCI_SLOT(bp->pdev->devfn) == tmp_list->slot &&
8924 bp->pdev->bus->number == tmp_list->bus &&
8925 BP_PATH(bp) == tmp_list->path) {
8926 rc = true;
8927 BNX2X_DEV_INFO("Path %d was already cleaned from previous drivers\n",
8928 BP_PATH(bp));
8929 break;
8930 }
8931 }
8932
8933 up(&bnx2x_prev_sem);
8934
8935 return rc;
8936}
8937
8938static int __devinit bnx2x_prev_mark_path(struct bnx2x *bp)
8939{
8940 struct bnx2x_prev_path_list *tmp_list;
8941 int rc;
8942
8943 tmp_list = (struct bnx2x_prev_path_list *)
8944 kmalloc(sizeof(struct bnx2x_prev_path_list), GFP_KERNEL);
8945 if (!tmp_list) {
8946 BNX2X_ERR("Failed to allocate 'bnx2x_prev_path_list'\n");
8947 return -ENOMEM;
8948 }
8949
8950 tmp_list->bus = bp->pdev->bus->number;
8951 tmp_list->slot = PCI_SLOT(bp->pdev->devfn);
8952 tmp_list->path = BP_PATH(bp);
8953
8954 rc = down_interruptible(&bnx2x_prev_sem);
8955 if (rc) {
8956 BNX2X_ERR("Received %d when tried to take lock\n", rc);
8957 kfree(tmp_list);
8958 } else {
8959 BNX2X_DEV_INFO("Marked path [%d] - finished previous unload\n",
8960 BP_PATH(bp));
8961 list_add(&tmp_list->list, &bnx2x_prev_list);
8962 up(&bnx2x_prev_sem);
8963 }
8964
8965 return rc;
8966}
8967
8968static bool __devinit bnx2x_can_flr(struct bnx2x *bp)
8969{
8970 int pos;
8971 u32 cap;
8972 struct pci_dev *dev = bp->pdev;
8973
8974 pos = pci_pcie_cap(dev);
8975 if (!pos)
8976 return false;
8977
8978 pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP, &cap);
8979 if (!(cap & PCI_EXP_DEVCAP_FLR))
8980 return false;
8981
8982 return true;
8983}
8984
8985static int __devinit bnx2x_do_flr(struct bnx2x *bp)
8986{
8987 int i, pos;
8988 u16 status;
8989 struct pci_dev *dev = bp->pdev;
8990
8991 /* probe the capability first */
8992 if (bnx2x_can_flr(bp))
8993 return -ENOTTY;
8994
8995 pos = pci_pcie_cap(dev);
8996 if (!pos)
8997 return -ENOTTY;
8998
8999 /* Wait for Transaction Pending bit clean */
9000 for (i = 0; i < 4; i++) {
9001 if (i)
9002 msleep((1 << (i - 1)) * 100);
9003
9004 pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status);
9005 if (!(status & PCI_EXP_DEVSTA_TRPND))
9006 goto clear;
9007 }
9008
9009 dev_err(&dev->dev,
9010 "transaction is not cleared; proceeding with reset anyway\n");
9011
9012clear:
9013 if (bp->common.bc_ver < REQ_BC_VER_4_INITIATE_FLR) {
9014 BNX2X_ERR("FLR not supported by BC_VER: 0x%x\n",
9015 bp->common.bc_ver);
9016 return -EINVAL;
9017 }
9018
9019 bnx2x_fw_command(bp, DRV_MSG_CODE_INITIATE_FLR, 0);
9020
9021 return 0;
9022}
9023
9024static int __devinit bnx2x_prev_unload_uncommon(struct bnx2x *bp)
9025{
9026 int rc;
9027
9028 BNX2X_DEV_INFO("Uncommon unload Flow\n");
9029
9030 /* Test if previous unload process was already finished for this path */
9031 if (bnx2x_prev_is_path_marked(bp))
9032 return bnx2x_prev_mcp_done(bp);
9033
9034 /* If function has FLR capabilities, and existing FW version matches
9035 * the one required, then FLR will be sufficient to clean any residue
9036 * left by previous driver
9037 */
9038 if (bnx2x_test_firmware_version(bp, false) && bnx2x_can_flr(bp))
9039 return bnx2x_do_flr(bp);
9040
9041 /* Close the MCP request, return failure*/
9042 rc = bnx2x_prev_mcp_done(bp);
9043 if (!rc)
9044 rc = BNX2X_PREV_WAIT_NEEDED;
9045
9046 return rc;
9047}
9048
9049static int __devinit bnx2x_prev_unload_common(struct bnx2x *bp)
9050{
9051 u32 reset_reg, tmp_reg = 0, rc;
9052 /* It is possible a previous function received 'common' answer,
9053 * but hasn't loaded yet, therefore creating a scenario of
9054 * multiple functions receiving 'common' on the same path.
9055 */
9056 BNX2X_DEV_INFO("Common unload Flow\n");
9057
9058 if (bnx2x_prev_is_path_marked(bp))
9059 return bnx2x_prev_mcp_done(bp);
9060
9061 reset_reg = REG_RD(bp, MISC_REG_RESET_REG_1);
9062
9063 /* Reset should be performed after BRB is emptied */
9064 if (reset_reg & MISC_REGISTERS_RESET_REG_1_RST_BRB1) {
9065 u32 timer_count = 1000;
9066 bool prev_undi = false;
9067
9068 /* Close the MAC Rx to prevent BRB from filling up */
9069 bnx2x_prev_unload_close_mac(bp);
9070
9071 /* Check if the UNDI driver was previously loaded
8828 * UNDI driver initializes CID offset for normal bell to 0x7 9072 * UNDI driver initializes CID offset for normal bell to 0x7
8829 */ 9073 */
8830 val = REG_RD(bp, DORQ_REG_NORM_CID_OFST); 9074 reset_reg = REG_RD(bp, MISC_REG_RESET_REG_1);
8831 if (val == 0x7) { 9075 if (reset_reg & MISC_REGISTERS_RESET_REG_1_RST_DORQ) {
8832 u32 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS; 9076 tmp_reg = REG_RD(bp, DORQ_REG_NORM_CID_OFST);
8833 /* save our pf_num */ 9077 if (tmp_reg == 0x7) {
8834 int orig_pf_num = bp->pf_num; 9078 BNX2X_DEV_INFO("UNDI previously loaded\n");
8835 int port; 9079 prev_undi = true;
8836 u32 swap_en, swap_val, value; 9080 /* clear the UNDI indication */
8837 9081 REG_WR(bp, DORQ_REG_NORM_CID_OFST, 0);
8838 /* clear the UNDI indication */
8839 REG_WR(bp, DORQ_REG_NORM_CID_OFST, 0);
8840
8841 BNX2X_DEV_INFO("UNDI is active! reset device\n");
8842
8843 /* try unload UNDI on port 0 */
8844 bp->pf_num = 0;
8845 bp->fw_seq =
8846 (SHMEM_RD(bp, func_mb[bp->pf_num].drv_mb_header) &
8847 DRV_MSG_SEQ_NUMBER_MASK);
8848 reset_code = bnx2x_fw_command(bp, reset_code, 0);
8849
8850 /* if UNDI is loaded on the other port */
8851 if (reset_code != FW_MSG_CODE_DRV_UNLOAD_COMMON) {
8852
8853 /* send "DONE" for previous unload */
8854 bnx2x_fw_command(bp,
8855 DRV_MSG_CODE_UNLOAD_DONE, 0);
8856
8857 /* unload UNDI on port 1 */
8858 bp->pf_num = 1;
8859 bp->fw_seq =
8860 (SHMEM_RD(bp, func_mb[bp->pf_num].drv_mb_header) &
8861 DRV_MSG_SEQ_NUMBER_MASK);
8862 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS;
8863
8864 bnx2x_fw_command(bp, reset_code, 0);
8865 } 9082 }
9083 }
9084 /* wait until BRB is empty */
9085 tmp_reg = REG_RD(bp, BRB1_REG_NUM_OF_FULL_BLOCKS);
9086 while (timer_count) {
9087 u32 prev_brb = tmp_reg;
8866 9088
8867 bnx2x_undi_int_disable(bp); 9089 tmp_reg = REG_RD(bp, BRB1_REG_NUM_OF_FULL_BLOCKS);
8868 port = BP_PORT(bp); 9090 if (!tmp_reg)
8869 9091 break;
8870 /* close input traffic and wait for it */
8871 /* Do not rcv packets to BRB */
8872 REG_WR(bp, (port ? NIG_REG_LLH1_BRB1_DRV_MASK :
8873 NIG_REG_LLH0_BRB1_DRV_MASK), 0x0);
8874 /* Do not direct rcv packets that are not for MCP to
8875 * the BRB */
8876 REG_WR(bp, (port ? NIG_REG_LLH1_BRB1_NOT_MCP :
8877 NIG_REG_LLH0_BRB1_NOT_MCP), 0x0);
8878 /* clear AEU */
8879 REG_WR(bp, (port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 :
8880 MISC_REG_AEU_MASK_ATTN_FUNC_0), 0);
8881 msleep(10);
8882
8883 /* save NIG port swap info */
8884 swap_val = REG_RD(bp, NIG_REG_PORT_SWAP);
8885 swap_en = REG_RD(bp, NIG_REG_STRAP_OVERRIDE);
8886 /* reset device */
8887 REG_WR(bp,
8888 GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR,
8889 0xd3ffffff);
8890
8891 value = 0x1400;
8892 if (CHIP_IS_E3(bp)) {
8893 value |= MISC_REGISTERS_RESET_REG_2_MSTAT0;
8894 value |= MISC_REGISTERS_RESET_REG_2_MSTAT1;
8895 }
8896 9092
8897 REG_WR(bp, 9093 BNX2X_DEV_INFO("BRB still has 0x%08x\n", tmp_reg);
8898 GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR,
8899 value);
8900 9094
8901 /* take the NIG out of reset and restore swap values */ 9095 /* reset timer as long as BRB actually gets emptied */
8902 REG_WR(bp, 9096 if (prev_brb > tmp_reg)
8903 GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 9097 timer_count = 1000;
8904 MISC_REGISTERS_RESET_REG_1_RST_NIG); 9098 else
8905 REG_WR(bp, NIG_REG_PORT_SWAP, swap_val); 9099 timer_count--;
8906 REG_WR(bp, NIG_REG_STRAP_OVERRIDE, swap_en);
8907 9100
8908 /* send unload done to the MCP */ 9101 /* If UNDI resides in memory, manually increment it */
8909 bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE, 0); 9102 if (prev_undi)
9103 bnx2x_prev_unload_undi_inc(bp, BP_PORT(bp), 1);
8910 9104
8911 /* restore our func and fw_seq */ 9105 udelay(10);
8912 bp->pf_num = orig_pf_num;
8913 } 9106 }
9107
9108 if (!timer_count)
9109 BNX2X_ERR("Failed to empty BRB, hope for the best\n");
9110
8914 } 9111 }
8915 9112
8916 /* now it's safe to release the lock */ 9113 /* No packets are in the pipeline, path is ready for reset */
8917 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RESET); 9114 bnx2x_reset_common(bp);
9115
9116 rc = bnx2x_prev_mark_path(bp);
9117 if (rc) {
9118 bnx2x_prev_mcp_done(bp);
9119 return rc;
9120 }
9121
9122 return bnx2x_prev_mcp_done(bp);
9123}
9124
9125static int __devinit bnx2x_prev_unload(struct bnx2x *bp)
9126{
9127 int time_counter = 10;
9128 u32 rc, fw, hw_lock_reg, hw_lock_val;
9129 BNX2X_DEV_INFO("Entering Previous Unload Flow\n");
9130
9131 /* Release previously held locks */
9132 hw_lock_reg = (BP_FUNC(bp) <= 5) ?
9133 (MISC_REG_DRIVER_CONTROL_1 + BP_FUNC(bp) * 8) :
9134 (MISC_REG_DRIVER_CONTROL_7 + (BP_FUNC(bp) - 6) * 8);
9135
9136 hw_lock_val = (REG_RD(bp, hw_lock_reg));
9137 if (hw_lock_val) {
9138 if (hw_lock_val & HW_LOCK_RESOURCE_NVRAM) {
9139 BNX2X_DEV_INFO("Release Previously held NVRAM lock\n");
9140 REG_WR(bp, MCP_REG_MCPR_NVM_SW_ARB,
9141 (MCPR_NVM_SW_ARB_ARB_REQ_CLR1 << BP_PORT(bp)));
9142 }
9143
9144 BNX2X_DEV_INFO("Release Previously held hw lock\n");
9145 REG_WR(bp, hw_lock_reg, 0xffffffff);
9146 } else
9147 BNX2X_DEV_INFO("No need to release hw/nvram locks\n");
9148
9149 if (MCPR_ACCESS_LOCK_LOCK & REG_RD(bp, MCP_REG_MCPR_ACCESS_LOCK)) {
9150 BNX2X_DEV_INFO("Release previously held alr\n");
9151 REG_WR(bp, MCP_REG_MCPR_ACCESS_LOCK, 0);
9152 }
9153
9154
9155 do {
9156 /* Lock MCP using an unload request */
9157 fw = bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS, 0);
9158 if (!fw) {
9159 BNX2X_ERR("MCP response failure, aborting\n");
9160 rc = -EBUSY;
9161 break;
9162 }
9163
9164 if (fw == FW_MSG_CODE_DRV_UNLOAD_COMMON) {
9165 rc = bnx2x_prev_unload_common(bp);
9166 break;
9167 }
9168
9169 /* non-common reply from MCP night require looping */
9170 rc = bnx2x_prev_unload_uncommon(bp);
9171 if (rc != BNX2X_PREV_WAIT_NEEDED)
9172 break;
9173
9174 msleep(20);
9175 } while (--time_counter);
9176
9177 if (!time_counter || rc) {
9178 BNX2X_ERR("Failed unloading previous driver, aborting\n");
9179 rc = -EBUSY;
9180 }
9181
9182 BNX2X_DEV_INFO("Finished Previous Unload Flow [%d]\n", rc);
9183
9184 return rc;
8918} 9185}
8919 9186
8920static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp) 9187static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
@@ -10100,8 +10367,16 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
10100 func = BP_FUNC(bp); 10367 func = BP_FUNC(bp);
10101 10368
10102 /* need to reset chip if undi was active */ 10369 /* need to reset chip if undi was active */
10103 if (!BP_NOMCP(bp)) 10370 if (!BP_NOMCP(bp)) {
10104 bnx2x_undi_unload(bp); 10371 /* init fw_seq */
10372 bp->fw_seq =
10373 SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) &
10374 DRV_MSG_SEQ_NUMBER_MASK;
10375 BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq);
10376
10377 bnx2x_prev_unload(bp);
10378 }
10379
10105 10380
10106 if (CHIP_REV_IS_FPGA(bp)) 10381 if (CHIP_REV_IS_FPGA(bp))
10107 dev_err(&bp->pdev->dev, "FPGA detected\n"); 10382 dev_err(&bp->pdev->dev, "FPGA detected\n");
@@ -11431,9 +11706,18 @@ static int __init bnx2x_init(void)
11431 11706
11432static void __exit bnx2x_cleanup(void) 11707static void __exit bnx2x_cleanup(void)
11433{ 11708{
11709 struct list_head *pos, *q;
11434 pci_unregister_driver(&bnx2x_pci_driver); 11710 pci_unregister_driver(&bnx2x_pci_driver);
11435 11711
11436 destroy_workqueue(bnx2x_wq); 11712 destroy_workqueue(bnx2x_wq);
11713
11714 /* Free globablly allocated resources */
11715 list_for_each_safe(pos, q, &bnx2x_prev_list) {
11716 struct bnx2x_prev_path_list *tmp =
11717 list_entry(pos, struct bnx2x_prev_path_list, list);
11718 list_del(pos);
11719 kfree(tmp);
11720 }
11437} 11721}
11438 11722
11439void bnx2x_notify_link_changed(struct bnx2x *bp) 11723void bnx2x_notify_link_changed(struct bnx2x *bp)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
index fd7fb4581849..c25803b9c0ca 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
@@ -987,6 +987,7 @@
987 * clear; 1 = set. Data valid only in addresses 0-4. all the rest are zero. */ 987 * clear; 1 = set. Data valid only in addresses 0-4. all the rest are zero. */
988#define IGU_REG_WRITE_DONE_PENDING 0x130480 988#define IGU_REG_WRITE_DONE_PENDING 0x130480
989#define MCP_A_REG_MCPR_SCRATCH 0x3a0000 989#define MCP_A_REG_MCPR_SCRATCH 0x3a0000
990#define MCP_REG_MCPR_ACCESS_LOCK 0x8009c
990#define MCP_REG_MCPR_CPU_PROGRAM_COUNTER 0x8501c 991#define MCP_REG_MCPR_CPU_PROGRAM_COUNTER 0x8501c
991#define MCP_REG_MCPR_GP_INPUTS 0x800c0 992#define MCP_REG_MCPR_GP_INPUTS 0x800c0
992#define MCP_REG_MCPR_GP_OENABLE 0x800c8 993#define MCP_REG_MCPR_GP_OENABLE 0x800c8
@@ -1686,6 +1687,7 @@
1686 [10] rst_dbg; [11] rst_misc_core; [12] rst_dbue (UART); [13] 1687 [10] rst_dbg; [11] rst_misc_core; [12] rst_dbue (UART); [13]
1687 Pci_resetmdio_n; [14] rst_emac0_hard_core; [15] rst_emac1_hard_core; 16] 1688 Pci_resetmdio_n; [14] rst_emac0_hard_core; [15] rst_emac1_hard_core; 16]
1688 rst_pxp_rq_rd_wr; 31:17] reserved */ 1689 rst_pxp_rq_rd_wr; 31:17] reserved */
1690#define MISC_REG_RESET_REG_1 0xa580
1689#define MISC_REG_RESET_REG_2 0xa590 1691#define MISC_REG_RESET_REG_2 0xa590
1690/* [RW 20] 20 bit GRC address where the scratch-pad of the MCP that is 1692/* [RW 20] 20 bit GRC address where the scratch-pad of the MCP that is
1691 shared with the driver resides */ 1693 shared with the driver resides */
@@ -5352,6 +5354,7 @@
5352#define XMAC_CTRL_REG_TX_EN (0x1<<0) 5354#define XMAC_CTRL_REG_TX_EN (0x1<<0)
5353#define XMAC_PAUSE_CTRL_REG_RX_PAUSE_EN (0x1<<18) 5355#define XMAC_PAUSE_CTRL_REG_RX_PAUSE_EN (0x1<<18)
5354#define XMAC_PAUSE_CTRL_REG_TX_PAUSE_EN (0x1<<17) 5356#define XMAC_PAUSE_CTRL_REG_TX_PAUSE_EN (0x1<<17)
5357#define XMAC_PFC_CTRL_HI_REG_FORCE_PFC_XON (0x1<<1)
5355#define XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN (0x1<<0) 5358#define XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN (0x1<<0)
5356#define XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN (0x1<<3) 5359#define XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN (0x1<<3)
5357#define XMAC_PFC_CTRL_HI_REG_RX_PFC_EN (0x1<<4) 5360#define XMAC_PFC_CTRL_HI_REG_RX_PFC_EN (0x1<<4)
@@ -5606,6 +5609,7 @@
5606/* [RC 32] Parity register #0 read clear */ 5609/* [RC 32] Parity register #0 read clear */
5607#define XSEM_REG_XSEM_PRTY_STS_CLR_0 0x280128 5610#define XSEM_REG_XSEM_PRTY_STS_CLR_0 0x280128
5608#define XSEM_REG_XSEM_PRTY_STS_CLR_1 0x280138 5611#define XSEM_REG_XSEM_PRTY_STS_CLR_1 0x280138
5612#define MCPR_ACCESS_LOCK_LOCK (1L<<31)
5609#define MCPR_NVM_ACCESS_ENABLE_EN (1L<<0) 5613#define MCPR_NVM_ACCESS_ENABLE_EN (1L<<0)
5610#define MCPR_NVM_ACCESS_ENABLE_WR_EN (1L<<1) 5614#define MCPR_NVM_ACCESS_ENABLE_WR_EN (1L<<1)
5611#define MCPR_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0) 5615#define MCPR_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0)
@@ -5732,6 +5736,7 @@
5732#define MISC_REGISTERS_GPIO_PORT_SHIFT 4 5736#define MISC_REGISTERS_GPIO_PORT_SHIFT 4
5733#define MISC_REGISTERS_GPIO_SET_POS 8 5737#define MISC_REGISTERS_GPIO_SET_POS 8
5734#define MISC_REGISTERS_RESET_REG_1_CLEAR 0x588 5738#define MISC_REGISTERS_RESET_REG_1_CLEAR 0x588
5739#define MISC_REGISTERS_RESET_REG_1_RST_BRB1 (0x1<<0)
5735#define MISC_REGISTERS_RESET_REG_1_RST_DORQ (0x1<<19) 5740#define MISC_REGISTERS_RESET_REG_1_RST_DORQ (0x1<<19)
5736#define MISC_REGISTERS_RESET_REG_1_RST_HC (0x1<<29) 5741#define MISC_REGISTERS_RESET_REG_1_RST_HC (0x1<<29)
5737#define MISC_REGISTERS_RESET_REG_1_RST_NIG (0x1<<7) 5742#define MISC_REGISTERS_RESET_REG_1_RST_NIG (0x1<<7)
@@ -6816,10 +6821,13 @@ Theotherbitsarereservedandshouldbezero*/
6816 6821
6817#define MDIO_AN_REG_8481_10GBASE_T_AN_CTRL 0x0020 6822#define MDIO_AN_REG_8481_10GBASE_T_AN_CTRL 0x0020
6818#define MDIO_AN_REG_8481_LEGACY_MII_CTRL 0xffe0 6823#define MDIO_AN_REG_8481_LEGACY_MII_CTRL 0xffe0
6824#define MDIO_AN_REG_8481_MII_CTRL_FORCE_1G 0x40
6819#define MDIO_AN_REG_8481_LEGACY_MII_STATUS 0xffe1 6825#define MDIO_AN_REG_8481_LEGACY_MII_STATUS 0xffe1
6820#define MDIO_AN_REG_8481_LEGACY_AN_ADV 0xffe4 6826#define MDIO_AN_REG_8481_LEGACY_AN_ADV 0xffe4
6821#define MDIO_AN_REG_8481_LEGACY_AN_EXPANSION 0xffe6 6827#define MDIO_AN_REG_8481_LEGACY_AN_EXPANSION 0xffe6
6822#define MDIO_AN_REG_8481_1000T_CTRL 0xffe9 6828#define MDIO_AN_REG_8481_1000T_CTRL 0xffe9
6829#define MDIO_AN_REG_8481_1G_100T_EXT_CTRL 0xfff0
6830#define MIDO_AN_REG_8481_EXT_CTRL_FORCE_LEDS_OFF 0x0008
6823#define MDIO_AN_REG_8481_EXPANSION_REG_RD_RW 0xfff5 6831#define MDIO_AN_REG_8481_EXPANSION_REG_RD_RW 0xfff5
6824#define MDIO_AN_REG_8481_EXPANSION_REG_ACCESS 0xfff7 6832#define MDIO_AN_REG_8481_EXPANSION_REG_ACCESS 0xfff7
6825#define MDIO_AN_REG_8481_AUX_CTRL 0xfff8 6833#define MDIO_AN_REG_8481_AUX_CTRL 0xfff8
@@ -6939,6 +6947,10 @@ Theotherbitsarereservedandshouldbezero*/
6939#define MDIO_WC_REG_GP2_STATUS_GP_2_2 0x81d2 6947#define MDIO_WC_REG_GP2_STATUS_GP_2_2 0x81d2
6940#define MDIO_WC_REG_GP2_STATUS_GP_2_3 0x81d3 6948#define MDIO_WC_REG_GP2_STATUS_GP_2_3 0x81d3
6941#define MDIO_WC_REG_GP2_STATUS_GP_2_4 0x81d4 6949#define MDIO_WC_REG_GP2_STATUS_GP_2_4 0x81d4
6950#define MDIO_WC_REG_GP2_STATUS_GP_2_4_CL73_AN_CMPL 0x1000
6951#define MDIO_WC_REG_GP2_STATUS_GP_2_4_CL37_AN_CMPL 0x0100
6952#define MDIO_WC_REG_GP2_STATUS_GP_2_4_CL37_LP_AN_CAP 0x0010
6953#define MDIO_WC_REG_GP2_STATUS_GP_2_4_CL37_AN_CAP 0x1
6942#define MDIO_WC_REG_UC_INFO_B0_DEAD_TRAP 0x81EE 6954#define MDIO_WC_REG_UC_INFO_B0_DEAD_TRAP 0x81EE
6943#define MDIO_WC_REG_UC_INFO_B1_VERSION 0x81F0 6955#define MDIO_WC_REG_UC_INFO_B1_VERSION 0x81F0
6944#define MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE 0x81F2 6956#define MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE 0x81F2
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index 3f52fadee3ed..513573321625 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -3847,7 +3847,7 @@ static bool bnx2x_credit_pool_get_entry(
3847 continue; 3847 continue;
3848 3848
3849 /* If we've got here we are going to find a free entry */ 3849 /* If we've got here we are going to find a free entry */
3850 for (idx = vec * BNX2X_POOL_VEC_SIZE, i = 0; 3850 for (idx = vec * BIT_VEC64_ELEM_SZ, i = 0;
3851 i < BIT_VEC64_ELEM_SZ; idx++, i++) 3851 i < BIT_VEC64_ELEM_SZ; idx++, i++)
3852 3852
3853 if (BIT_VEC64_TEST_BIT(o->pool_mirror, idx)) { 3853 if (BIT_VEC64_TEST_BIT(o->pool_mirror, idx)) {
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 4e4bb3875868..062ac333fde6 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -2778,7 +2778,9 @@ static void tg3_power_down_phy(struct tg3 *tp, bool do_low_power)
2778 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 2778 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
2779 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 || 2779 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
2780 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 && 2780 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 &&
2781 (tp->phy_flags & TG3_PHYFLG_MII_SERDES))) 2781 (tp->phy_flags & TG3_PHYFLG_MII_SERDES)) ||
2782 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 &&
2783 !tp->pci_fn))
2782 return; 2784 return;
2783 2785
2784 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX || 2786 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 05ff076af06d..b126b98065a9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2000,13 +2000,6 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
2000/* 2000/*
2001 * debugfs support 2001 * debugfs support
2002 */ 2002 */
2003
2004static int mem_open(struct inode *inode, struct file *file)
2005{
2006 file->private_data = inode->i_private;
2007 return 0;
2008}
2009
2010static ssize_t mem_read(struct file *file, char __user *buf, size_t count, 2003static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
2011 loff_t *ppos) 2004 loff_t *ppos)
2012{ 2005{
@@ -2050,7 +2043,7 @@ static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
2050 2043
2051static const struct file_operations mem_debugfs_fops = { 2044static const struct file_operations mem_debugfs_fops = {
2052 .owner = THIS_MODULE, 2045 .owner = THIS_MODULE,
2053 .open = mem_open, 2046 .open = simple_open,
2054 .read = mem_read, 2047 .read = mem_read,
2055 .llseek = default_llseek, 2048 .llseek = default_llseek,
2056}; 2049};
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 9eb815941df5..f7f0bf5d037b 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -356,13 +356,13 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev)
356 356
357 if (prop) 357 if (prop)
358 tbiaddr = *prop; 358 tbiaddr = *prop;
359 }
360 359
361 if (tbiaddr == -1) { 360 if (tbiaddr == -1) {
362 err = -EBUSY; 361 err = -EBUSY;
363 goto err_free_irqs; 362 goto err_free_irqs;
364 } else { 363 } else {
365 out_be32(tbipa, tbiaddr); 364 out_be32(tbipa, tbiaddr);
365 }
366 } 366 }
367 367
368 err = of_mdiobus_register(new_bus, np); 368 err = of_mdiobus_register(new_bus, np);
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 4e3cd2f8debb..17a46e76123f 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3945,6 +3945,8 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3945 } 3945 }
3946 3946
3947 if (max_speed == SPEED_1000) { 3947 if (max_speed == SPEED_1000) {
3948 unsigned int snums = qe_get_num_of_snums();
3949
3948 /* configure muram FIFOs for gigabit operation */ 3950 /* configure muram FIFOs for gigabit operation */
3949 ug_info->uf_info.urfs = UCC_GETH_URFS_GIGA_INIT; 3951 ug_info->uf_info.urfs = UCC_GETH_URFS_GIGA_INIT;
3950 ug_info->uf_info.urfet = UCC_GETH_URFET_GIGA_INIT; 3952 ug_info->uf_info.urfet = UCC_GETH_URFET_GIGA_INIT;
@@ -3954,11 +3956,11 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3954 ug_info->uf_info.utftt = UCC_GETH_UTFTT_GIGA_INIT; 3956 ug_info->uf_info.utftt = UCC_GETH_UTFTT_GIGA_INIT;
3955 ug_info->numThreadsTx = UCC_GETH_NUM_OF_THREADS_4; 3957 ug_info->numThreadsTx = UCC_GETH_NUM_OF_THREADS_4;
3956 3958
3957 /* If QE's snum number is 46 which means we need to support 3959 /* If QE's snum number is 46/76 which means we need to support
3958 * 4 UECs at 1000Base-T simultaneously, we need to allocate 3960 * 4 UECs at 1000Base-T simultaneously, we need to allocate
3959 * more Threads to Rx. 3961 * more Threads to Rx.
3960 */ 3962 */
3961 if (qe_get_num_of_snums() == 46) 3963 if ((snums == 76) || (snums == 46))
3962 ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_6; 3964 ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_6;
3963 else 3965 else
3964 ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_4; 3966 ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_4;
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 0e9aec8f6917..4348b6fd44fa 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -164,6 +164,8 @@ static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
164static bool e1000_vlan_used(struct e1000_adapter *adapter); 164static bool e1000_vlan_used(struct e1000_adapter *adapter);
165static void e1000_vlan_mode(struct net_device *netdev, 165static void e1000_vlan_mode(struct net_device *netdev,
166 netdev_features_t features); 166 netdev_features_t features);
167static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
168 bool filter_on);
167static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid); 169static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
168static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid); 170static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
169static void e1000_restore_vlan(struct e1000_adapter *adapter); 171static void e1000_restore_vlan(struct e1000_adapter *adapter);
@@ -215,7 +217,8 @@ MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
215MODULE_LICENSE("GPL"); 217MODULE_LICENSE("GPL");
216MODULE_VERSION(DRV_VERSION); 218MODULE_VERSION(DRV_VERSION);
217 219
218static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE; 220#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
221static int debug = -1;
219module_param(debug, int, 0); 222module_param(debug, int, 0);
220MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 223MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
221 224
@@ -979,7 +982,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
979 adapter = netdev_priv(netdev); 982 adapter = netdev_priv(netdev);
980 adapter->netdev = netdev; 983 adapter->netdev = netdev;
981 adapter->pdev = pdev; 984 adapter->pdev = pdev;
982 adapter->msg_enable = (1 << debug) - 1; 985 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
983 adapter->bars = bars; 986 adapter->bars = bars;
984 adapter->need_ioport = need_ioport; 987 adapter->need_ioport = need_ioport;
985 988
@@ -1214,7 +1217,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1214 if (err) 1217 if (err)
1215 goto err_register; 1218 goto err_register;
1216 1219
1217 e1000_vlan_mode(netdev, netdev->features); 1220 e1000_vlan_filter_on_off(adapter, false);
1218 1221
1219 /* print bus type/speed/width info */ 1222 /* print bus type/speed/width info */
1220 e_info(probe, "(PCI%s:%dMHz:%d-bit) %pM\n", 1223 e_info(probe, "(PCI%s:%dMHz:%d-bit) %pM\n",
@@ -4770,6 +4773,22 @@ static bool e1000_vlan_used(struct e1000_adapter *adapter)
4770 return false; 4773 return false;
4771} 4774}
4772 4775
4776static void __e1000_vlan_mode(struct e1000_adapter *adapter,
4777 netdev_features_t features)
4778{
4779 struct e1000_hw *hw = &adapter->hw;
4780 u32 ctrl;
4781
4782 ctrl = er32(CTRL);
4783 if (features & NETIF_F_HW_VLAN_RX) {
4784 /* enable VLAN tag insert/strip */
4785 ctrl |= E1000_CTRL_VME;
4786 } else {
4787 /* disable VLAN tag insert/strip */
4788 ctrl &= ~E1000_CTRL_VME;
4789 }
4790 ew32(CTRL, ctrl);
4791}
4773static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter, 4792static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
4774 bool filter_on) 4793 bool filter_on)
4775{ 4794{
@@ -4779,6 +4798,7 @@ static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
4779 if (!test_bit(__E1000_DOWN, &adapter->flags)) 4798 if (!test_bit(__E1000_DOWN, &adapter->flags))
4780 e1000_irq_disable(adapter); 4799 e1000_irq_disable(adapter);
4781 4800
4801 __e1000_vlan_mode(adapter, adapter->netdev->features);
4782 if (filter_on) { 4802 if (filter_on) {
4783 /* enable VLAN receive filtering */ 4803 /* enable VLAN receive filtering */
4784 rctl = er32(RCTL); 4804 rctl = er32(RCTL);
@@ -4799,24 +4819,14 @@ static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
4799} 4819}
4800 4820
4801static void e1000_vlan_mode(struct net_device *netdev, 4821static void e1000_vlan_mode(struct net_device *netdev,
4802 netdev_features_t features) 4822 netdev_features_t features)
4803{ 4823{
4804 struct e1000_adapter *adapter = netdev_priv(netdev); 4824 struct e1000_adapter *adapter = netdev_priv(netdev);
4805 struct e1000_hw *hw = &adapter->hw;
4806 u32 ctrl;
4807 4825
4808 if (!test_bit(__E1000_DOWN, &adapter->flags)) 4826 if (!test_bit(__E1000_DOWN, &adapter->flags))
4809 e1000_irq_disable(adapter); 4827 e1000_irq_disable(adapter);
4810 4828
4811 ctrl = er32(CTRL); 4829 __e1000_vlan_mode(adapter, features);
4812 if (features & NETIF_F_HW_VLAN_RX) {
4813 /* enable VLAN tag insert/strip */
4814 ctrl |= E1000_CTRL_VME;
4815 } else {
4816 /* disable VLAN tag insert/strip */
4817 ctrl &= ~E1000_CTRL_VME;
4818 }
4819 ew32(CTRL, ctrl);
4820 4830
4821 if (!test_bit(__E1000_DOWN, &adapter->flags)) 4831 if (!test_bit(__E1000_DOWN, &adapter->flags))
4822 e1000_irq_enable(adapter); 4832 e1000_irq_enable(adapter);
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index 86cdd4793992..b83897f76ee3 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -161,6 +161,12 @@ struct e1000_info;
161/* Time to wait before putting the device into D3 if there's no link (in ms). */ 161/* Time to wait before putting the device into D3 if there's no link (in ms). */
162#define LINK_TIMEOUT 100 162#define LINK_TIMEOUT 100
163 163
164/*
165 * Count for polling __E1000_RESET condition every 10-20msec.
166 * Experimentation has shown the reset can take approximately 210msec.
167 */
168#define E1000_CHECK_RESET_COUNT 25
169
164#define DEFAULT_RDTR 0 170#define DEFAULT_RDTR 0
165#define DEFAULT_RADV 8 171#define DEFAULT_RADV 8
166#define BURST_RDTR 0x20 172#define BURST_RDTR 0x20
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 7152eb11b7b9..19ab2154802c 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -60,6 +60,11 @@
60char e1000e_driver_name[] = "e1000e"; 60char e1000e_driver_name[] = "e1000e";
61const char e1000e_driver_version[] = DRV_VERSION; 61const char e1000e_driver_version[] = DRV_VERSION;
62 62
63#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
64static int debug = -1;
65module_param(debug, int, 0);
66MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
67
63static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state); 68static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
64 69
65static const struct e1000_info *e1000_info_tbl[] = { 70static const struct e1000_info *e1000_info_tbl[] = {
@@ -1054,6 +1059,13 @@ static void e1000_print_hw_hang(struct work_struct *work)
1054 ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD); 1059 ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
1055 /* execute the writes immediately */ 1060 /* execute the writes immediately */
1056 e1e_flush(); 1061 e1e_flush();
1062 /*
1063 * Due to rare timing issues, write to TIDV again to ensure
1064 * the write is successful
1065 */
1066 ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
1067 /* execute the writes immediately */
1068 e1e_flush();
1057 adapter->tx_hang_recheck = true; 1069 adapter->tx_hang_recheck = true;
1058 return; 1070 return;
1059 } 1071 }
@@ -3611,6 +3623,16 @@ static void e1000e_flush_descriptors(struct e1000_adapter *adapter)
3611 3623
3612 /* execute the writes immediately */ 3624 /* execute the writes immediately */
3613 e1e_flush(); 3625 e1e_flush();
3626
3627 /*
3628 * due to rare timing issues, write to TIDV/RDTR again to ensure the
3629 * write is successful
3630 */
3631 ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
3632 ew32(RDTR, adapter->rx_int_delay | E1000_RDTR_FPD);
3633
3634 /* execute the writes immediately */
3635 e1e_flush();
3614} 3636}
3615 3637
3616static void e1000e_update_stats(struct e1000_adapter *adapter); 3638static void e1000e_update_stats(struct e1000_adapter *adapter);
@@ -3963,6 +3985,10 @@ static int e1000_close(struct net_device *netdev)
3963{ 3985{
3964 struct e1000_adapter *adapter = netdev_priv(netdev); 3986 struct e1000_adapter *adapter = netdev_priv(netdev);
3965 struct pci_dev *pdev = adapter->pdev; 3987 struct pci_dev *pdev = adapter->pdev;
3988 int count = E1000_CHECK_RESET_COUNT;
3989
3990 while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
3991 usleep_range(10000, 20000);
3966 3992
3967 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state)); 3993 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
3968 3994
@@ -5467,6 +5493,11 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
5467 netif_device_detach(netdev); 5493 netif_device_detach(netdev);
5468 5494
5469 if (netif_running(netdev)) { 5495 if (netif_running(netdev)) {
5496 int count = E1000_CHECK_RESET_COUNT;
5497
5498 while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
5499 usleep_range(10000, 20000);
5500
5470 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state)); 5501 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
5471 e1000e_down(adapter); 5502 e1000e_down(adapter);
5472 e1000_free_irq(adapter); 5503 e1000_free_irq(adapter);
@@ -6172,7 +6203,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
6172 adapter->hw.adapter = adapter; 6203 adapter->hw.adapter = adapter;
6173 adapter->hw.mac.type = ei->mac; 6204 adapter->hw.mac.type = ei->mac;
6174 adapter->max_hw_frame_size = ei->max_hw_frame_size; 6205 adapter->max_hw_frame_size = ei->max_hw_frame_size;
6175 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; 6206 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
6176 6207
6177 mmio_start = pci_resource_start(pdev, 0); 6208 mmio_start = pci_resource_start(pdev, 0);
6178 mmio_len = pci_resource_len(pdev, 0); 6209 mmio_len = pci_resource_len(pdev, 0);
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index c4902411d749..5ec31598ee47 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -238,6 +238,11 @@ MODULE_DESCRIPTION("Intel(R) Gigabit Ethernet Network Driver");
238MODULE_LICENSE("GPL"); 238MODULE_LICENSE("GPL");
239MODULE_VERSION(DRV_VERSION); 239MODULE_VERSION(DRV_VERSION);
240 240
241#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
242static int debug = -1;
243module_param(debug, int, 0);
244MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
245
241struct igb_reg_info { 246struct igb_reg_info {
242 u32 ofs; 247 u32 ofs;
243 char *name; 248 char *name;
@@ -1893,7 +1898,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
1893 adapter->pdev = pdev; 1898 adapter->pdev = pdev;
1894 hw = &adapter->hw; 1899 hw = &adapter->hw;
1895 hw->back = adapter; 1900 hw->back = adapter;
1896 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE; 1901 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
1897 1902
1898 mmio_start = pci_resource_start(pdev, 0); 1903 mmio_start = pci_resource_start(pdev, 0);
1899 mmio_len = pci_resource_len(pdev, 0); 1904 mmio_len = pci_resource_len(pdev, 0);
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index 217c143686d2..d61ca2a732f0 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -55,6 +55,11 @@ static const char igbvf_driver_string[] =
55static const char igbvf_copyright[] = 55static const char igbvf_copyright[] =
56 "Copyright (c) 2009 - 2012 Intel Corporation."; 56 "Copyright (c) 2009 - 2012 Intel Corporation.";
57 57
58#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
59static int debug = -1;
60module_param(debug, int, 0);
61MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
62
58static int igbvf_poll(struct napi_struct *napi, int budget); 63static int igbvf_poll(struct napi_struct *napi, int budget);
59static void igbvf_reset(struct igbvf_adapter *); 64static void igbvf_reset(struct igbvf_adapter *);
60static void igbvf_set_interrupt_capability(struct igbvf_adapter *); 65static void igbvf_set_interrupt_capability(struct igbvf_adapter *);
@@ -2649,7 +2654,7 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
2649 adapter->flags = ei->flags; 2654 adapter->flags = ei->flags;
2650 adapter->hw.back = adapter; 2655 adapter->hw.back = adapter;
2651 adapter->hw.mac.type = ei->mac; 2656 adapter->hw.mac.type = ei->mac;
2652 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; 2657 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
2653 2658
2654 /* PCI config space info */ 2659 /* PCI config space info */
2655 2660
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index 82aaa792cbf3..5fce363d810a 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -134,8 +134,8 @@ MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver");
134MODULE_LICENSE("GPL"); 134MODULE_LICENSE("GPL");
135MODULE_VERSION(DRV_VERSION); 135MODULE_VERSION(DRV_VERSION);
136 136
137#define DEFAULT_DEBUG_LEVEL_SHIFT 3 137#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
138static int debug = DEFAULT_DEBUG_LEVEL_SHIFT; 138static int debug = -1;
139module_param(debug, int, 0); 139module_param(debug, int, 0);
140MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 140MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
141 141
@@ -442,7 +442,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
442 adapter->netdev = netdev; 442 adapter->netdev = netdev;
443 adapter->pdev = pdev; 443 adapter->pdev = pdev;
444 adapter->hw.back = adapter; 444 adapter->hw.back = adapter;
445 adapter->msg_enable = netif_msg_init(debug, DEFAULT_DEBUG_LEVEL_SHIFT); 445 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
446 446
447 adapter->hw.hw_addr = pci_ioremap_bar(pdev, BAR_0); 447 adapter->hw.hw_addr = pci_ioremap_bar(pdev, BAR_0);
448 if (!adapter->hw.hw_addr) { 448 if (!adapter->hw.hw_addr) {
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 80e26ff30ebf..74e192107f9a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -544,7 +544,7 @@ struct ixgbe_fdir_filter {
544 u16 action; 544 u16 action;
545}; 545};
546 546
547enum ixbge_state_t { 547enum ixgbe_state_t {
548 __IXGBE_TESTING, 548 __IXGBE_TESTING,
549 __IXGBE_RESETTING, 549 __IXGBE_RESETTING,
550 __IXGBE_DOWN, 550 __IXGBE_DOWN,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c
index dde65f951400..652e4b09546d 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c
@@ -44,62 +44,94 @@
44#define DCB_NO_HW_CHG 1 /* DCB configuration did not change */ 44#define DCB_NO_HW_CHG 1 /* DCB configuration did not change */
45#define DCB_HW_CHG 2 /* DCB configuration changed, no reset */ 45#define DCB_HW_CHG 2 /* DCB configuration changed, no reset */
46 46
47int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config *src_dcb_cfg, 47int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config *scfg,
48 struct ixgbe_dcb_config *dst_dcb_cfg, int tc_max) 48 struct ixgbe_dcb_config *dcfg, int tc_max)
49{ 49{
50 struct tc_configuration *src_tc_cfg = NULL; 50 struct tc_configuration *src = NULL;
51 struct tc_configuration *dst_tc_cfg = NULL; 51 struct tc_configuration *dst = NULL;
52 int i; 52 int i, j;
53 int tx = DCB_TX_CONFIG;
54 int rx = DCB_RX_CONFIG;
55 int changes = 0;
53 56
54 if (!src_dcb_cfg || !dst_dcb_cfg) 57 if (!scfg || !dcfg)
55 return -EINVAL; 58 return changes;
56 59
57 for (i = DCB_PG_ATTR_TC_0; i < tc_max + DCB_PG_ATTR_TC_0; i++) { 60 for (i = DCB_PG_ATTR_TC_0; i < tc_max + DCB_PG_ATTR_TC_0; i++) {
58 src_tc_cfg = &src_dcb_cfg->tc_config[i - DCB_PG_ATTR_TC_0]; 61 src = &scfg->tc_config[i - DCB_PG_ATTR_TC_0];
59 dst_tc_cfg = &dst_dcb_cfg->tc_config[i - DCB_PG_ATTR_TC_0]; 62 dst = &dcfg->tc_config[i - DCB_PG_ATTR_TC_0];
60 63
61 dst_tc_cfg->path[DCB_TX_CONFIG].prio_type = 64 if (dst->path[tx].prio_type != src->path[tx].prio_type) {
62 src_tc_cfg->path[DCB_TX_CONFIG].prio_type; 65 dst->path[tx].prio_type = src->path[tx].prio_type;
66 changes |= BIT_PG_TX;
67 }
63 68
64 dst_tc_cfg->path[DCB_TX_CONFIG].bwg_id = 69 if (dst->path[tx].bwg_id != src->path[tx].bwg_id) {
65 src_tc_cfg->path[DCB_TX_CONFIG].bwg_id; 70 dst->path[tx].bwg_id = src->path[tx].bwg_id;
71 changes |= BIT_PG_TX;
72 }
66 73
67 dst_tc_cfg->path[DCB_TX_CONFIG].bwg_percent = 74 if (dst->path[tx].bwg_percent != src->path[tx].bwg_percent) {
68 src_tc_cfg->path[DCB_TX_CONFIG].bwg_percent; 75 dst->path[tx].bwg_percent = src->path[tx].bwg_percent;
76 changes |= BIT_PG_TX;
77 }
69 78
70 dst_tc_cfg->path[DCB_TX_CONFIG].up_to_tc_bitmap = 79 if (dst->path[tx].up_to_tc_bitmap !=
71 src_tc_cfg->path[DCB_TX_CONFIG].up_to_tc_bitmap; 80 src->path[tx].up_to_tc_bitmap) {
81 dst->path[tx].up_to_tc_bitmap =
82 src->path[tx].up_to_tc_bitmap;
83 changes |= (BIT_PG_TX | BIT_PFC | BIT_APP_UPCHG);
84 }
72 85
73 dst_tc_cfg->path[DCB_RX_CONFIG].prio_type = 86 if (dst->path[rx].prio_type != src->path[rx].prio_type) {
74 src_tc_cfg->path[DCB_RX_CONFIG].prio_type; 87 dst->path[rx].prio_type = src->path[rx].prio_type;
88 changes |= BIT_PG_RX;
89 }
75 90
76 dst_tc_cfg->path[DCB_RX_CONFIG].bwg_id = 91 if (dst->path[rx].bwg_id != src->path[rx].bwg_id) {
77 src_tc_cfg->path[DCB_RX_CONFIG].bwg_id; 92 dst->path[rx].bwg_id = src->path[rx].bwg_id;
93 changes |= BIT_PG_RX;
94 }
78 95
79 dst_tc_cfg->path[DCB_RX_CONFIG].bwg_percent = 96 if (dst->path[rx].bwg_percent != src->path[rx].bwg_percent) {
80 src_tc_cfg->path[DCB_RX_CONFIG].bwg_percent; 97 dst->path[rx].bwg_percent = src->path[rx].bwg_percent;
98 changes |= BIT_PG_RX;
99 }
81 100
82 dst_tc_cfg->path[DCB_RX_CONFIG].up_to_tc_bitmap = 101 if (dst->path[rx].up_to_tc_bitmap !=
83 src_tc_cfg->path[DCB_RX_CONFIG].up_to_tc_bitmap; 102 src->path[rx].up_to_tc_bitmap) {
103 dst->path[rx].up_to_tc_bitmap =
104 src->path[rx].up_to_tc_bitmap;
105 changes |= (BIT_PG_RX | BIT_PFC | BIT_APP_UPCHG);
106 }
84 } 107 }
85 108
86 for (i = DCB_PG_ATTR_BW_ID_0; i < DCB_PG_ATTR_BW_ID_MAX; i++) { 109 for (i = DCB_PG_ATTR_BW_ID_0; i < DCB_PG_ATTR_BW_ID_MAX; i++) {
87 dst_dcb_cfg->bw_percentage[DCB_TX_CONFIG] 110 j = i - DCB_PG_ATTR_BW_ID_0;
88 [i-DCB_PG_ATTR_BW_ID_0] = src_dcb_cfg->bw_percentage 111 if (dcfg->bw_percentage[tx][j] != scfg->bw_percentage[tx][j]) {
89 [DCB_TX_CONFIG][i-DCB_PG_ATTR_BW_ID_0]; 112 dcfg->bw_percentage[tx][j] = scfg->bw_percentage[tx][j];
90 dst_dcb_cfg->bw_percentage[DCB_RX_CONFIG] 113 changes |= BIT_PG_TX;
91 [i-DCB_PG_ATTR_BW_ID_0] = src_dcb_cfg->bw_percentage 114 }
92 [DCB_RX_CONFIG][i-DCB_PG_ATTR_BW_ID_0]; 115 if (dcfg->bw_percentage[rx][j] != scfg->bw_percentage[rx][j]) {
116 dcfg->bw_percentage[rx][j] = scfg->bw_percentage[rx][j];
117 changes |= BIT_PG_RX;
118 }
93 } 119 }
94 120
95 for (i = DCB_PFC_UP_ATTR_0; i < DCB_PFC_UP_ATTR_MAX; i++) { 121 for (i = DCB_PFC_UP_ATTR_0; i < DCB_PFC_UP_ATTR_MAX; i++) {
96 dst_dcb_cfg->tc_config[i - DCB_PFC_UP_ATTR_0].dcb_pfc = 122 j = i - DCB_PFC_UP_ATTR_0;
97 src_dcb_cfg->tc_config[i - DCB_PFC_UP_ATTR_0].dcb_pfc; 123 if (dcfg->tc_config[j].dcb_pfc != scfg->tc_config[j].dcb_pfc) {
124 dcfg->tc_config[j].dcb_pfc = scfg->tc_config[j].dcb_pfc;
125 changes |= BIT_PFC;
126 }
98 } 127 }
99 128
100 dst_dcb_cfg->pfc_mode_enable = src_dcb_cfg->pfc_mode_enable; 129 if (dcfg->pfc_mode_enable != scfg->pfc_mode_enable) {
130 dcfg->pfc_mode_enable = scfg->pfc_mode_enable;
131 changes |= BIT_PFC;
132 }
101 133
102 return 0; 134 return changes;
103} 135}
104 136
105static u8 ixgbe_dcbnl_get_state(struct net_device *netdev) 137static u8 ixgbe_dcbnl_get_state(struct net_device *netdev)
@@ -179,20 +211,6 @@ static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
179 if (up_map != DCB_ATTR_VALUE_UNDEFINED) 211 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
180 adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap = 212 adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap =
181 up_map; 213 up_map;
182
183 if ((adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type !=
184 adapter->dcb_cfg.tc_config[tc].path[0].prio_type) ||
185 (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id !=
186 adapter->dcb_cfg.tc_config[tc].path[0].bwg_id) ||
187 (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent !=
188 adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent) ||
189 (adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap !=
190 adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap))
191 adapter->dcb_set_bitmap |= BIT_PG_TX;
192
193 if (adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap !=
194 adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap)
195 adapter->dcb_set_bitmap |= BIT_PFC | BIT_APP_UPCHG;
196} 214}
197 215
198static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id, 216static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
@@ -201,10 +219,6 @@ static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
201 struct ixgbe_adapter *adapter = netdev_priv(netdev); 219 struct ixgbe_adapter *adapter = netdev_priv(netdev);
202 220
203 adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct; 221 adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct;
204
205 if (adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] !=
206 adapter->dcb_cfg.bw_percentage[0][bwg_id])
207 adapter->dcb_set_bitmap |= BIT_PG_TX;
208} 222}
209 223
210static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc, 224static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
@@ -223,20 +237,6 @@ static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
223 if (up_map != DCB_ATTR_VALUE_UNDEFINED) 237 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
224 adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap = 238 adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap =
225 up_map; 239 up_map;
226
227 if ((adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type !=
228 adapter->dcb_cfg.tc_config[tc].path[1].prio_type) ||
229 (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id !=
230 adapter->dcb_cfg.tc_config[tc].path[1].bwg_id) ||
231 (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent !=
232 adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent) ||
233 (adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap !=
234 adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap))
235 adapter->dcb_set_bitmap |= BIT_PG_RX;
236
237 if (adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap !=
238 adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap)
239 adapter->dcb_set_bitmap |= BIT_PFC;
240} 240}
241 241
242static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id, 242static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
@@ -245,10 +245,6 @@ static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
245 struct ixgbe_adapter *adapter = netdev_priv(netdev); 245 struct ixgbe_adapter *adapter = netdev_priv(netdev);
246 246
247 adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct; 247 adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct;
248
249 if (adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] !=
250 adapter->dcb_cfg.bw_percentage[1][bwg_id])
251 adapter->dcb_set_bitmap |= BIT_PG_RX;
252} 248}
253 249
254static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc, 250static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc,
@@ -298,10 +294,8 @@ static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,
298 294
299 adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting; 295 adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting;
300 if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc != 296 if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc !=
301 adapter->dcb_cfg.tc_config[priority].dcb_pfc) { 297 adapter->dcb_cfg.tc_config[priority].dcb_pfc)
302 adapter->dcb_set_bitmap |= BIT_PFC;
303 adapter->temp_dcb_cfg.pfc_mode_enable = true; 298 adapter->temp_dcb_cfg.pfc_mode_enable = true;
304 }
305} 299}
306 300
307static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority, 301static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority,
@@ -336,7 +330,8 @@ static void ixgbe_dcbnl_devreset(struct net_device *dev)
336static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) 330static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
337{ 331{
338 struct ixgbe_adapter *adapter = netdev_priv(netdev); 332 struct ixgbe_adapter *adapter = netdev_priv(netdev);
339 int ret, i; 333 int ret = DCB_NO_HW_CHG;
334 int i;
340#ifdef IXGBE_FCOE 335#ifdef IXGBE_FCOE
341 struct dcb_app app = { 336 struct dcb_app app = {
342 .selector = DCB_APP_IDTYPE_ETHTYPE, 337 .selector = DCB_APP_IDTYPE_ETHTYPE,
@@ -355,12 +350,13 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
355 350
356 /* Fail command if not in CEE mode */ 351 /* Fail command if not in CEE mode */
357 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) 352 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
358 return 1; 353 return ret;
359 354
360 ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, 355 adapter->dcb_set_bitmap |= ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg,
361 MAX_TRAFFIC_CLASS); 356 &adapter->dcb_cfg,
362 if (ret) 357 MAX_TRAFFIC_CLASS);
363 return DCB_NO_HW_CHG; 358 if (!adapter->dcb_set_bitmap)
359 return ret;
364 360
365 if (adapter->dcb_cfg.pfc_mode_enable) { 361 if (adapter->dcb_cfg.pfc_mode_enable) {
366 switch (adapter->hw.mac.type) { 362 switch (adapter->hw.mac.type) {
@@ -420,6 +416,8 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
420 416
421 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) 417 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
422 netdev_set_prio_tc_map(netdev, i, prio_tc[i]); 418 netdev_set_prio_tc_map(netdev, i, prio_tc[i]);
419
420 ret = DCB_HW_CHG_RST;
423 } 421 }
424 422
425 if (adapter->dcb_set_bitmap & BIT_PFC) { 423 if (adapter->dcb_set_bitmap & BIT_PFC) {
@@ -430,7 +428,8 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
430 DCB_TX_CONFIG, prio_tc); 428 DCB_TX_CONFIG, prio_tc);
431 ixgbe_dcb_unpack_pfc(&adapter->dcb_cfg, &pfc_en); 429 ixgbe_dcb_unpack_pfc(&adapter->dcb_cfg, &pfc_en);
432 ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc_en, prio_tc); 430 ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc_en, prio_tc);
433 ret = DCB_HW_CHG; 431 if (ret != DCB_HW_CHG_RST)
432 ret = DCB_HW_CHG;
434 } 433 }
435 434
436 if (adapter->dcb_cfg.pfc_mode_enable) 435 if (adapter->dcb_cfg.pfc_mode_enable)
@@ -531,9 +530,6 @@ static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
531 struct ixgbe_adapter *adapter = netdev_priv(netdev); 530 struct ixgbe_adapter *adapter = netdev_priv(netdev);
532 531
533 adapter->temp_dcb_cfg.pfc_mode_enable = state; 532 adapter->temp_dcb_cfg.pfc_mode_enable = state;
534 if (adapter->temp_dcb_cfg.pfc_mode_enable !=
535 adapter->dcb_cfg.pfc_mode_enable)
536 adapter->dcb_set_bitmap |= BIT_PFC;
537} 533}
538 534
539/** 535/**
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 398fc223cab9..3e26b1f9ac75 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -63,8 +63,8 @@ static char ixgbe_default_device_descr[] =
63 "Intel(R) 10 Gigabit Network Connection"; 63 "Intel(R) 10 Gigabit Network Connection";
64#endif 64#endif
65#define MAJ 3 65#define MAJ 3
66#define MIN 6 66#define MIN 8
67#define BUILD 7 67#define BUILD 21
68#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \ 68#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \
69 __stringify(BUILD) "-k" 69 __stringify(BUILD) "-k"
70const char ixgbe_driver_version[] = DRV_VERSION; 70const char ixgbe_driver_version[] = DRV_VERSION;
@@ -141,13 +141,16 @@ module_param(allow_unsupported_sfp, uint, 0);
141MODULE_PARM_DESC(allow_unsupported_sfp, 141MODULE_PARM_DESC(allow_unsupported_sfp,
142 "Allow unsupported and untested SFP+ modules on 82599-based adapters"); 142 "Allow unsupported and untested SFP+ modules on 82599-based adapters");
143 143
144#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
145static int debug = -1;
146module_param(debug, int, 0);
147MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
148
144MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); 149MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
145MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver"); 150MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver");
146MODULE_LICENSE("GPL"); 151MODULE_LICENSE("GPL");
147MODULE_VERSION(DRV_VERSION); 152MODULE_VERSION(DRV_VERSION);
148 153
149#define DEFAULT_DEBUG_LEVEL_SHIFT 3
150
151static void ixgbe_service_event_schedule(struct ixgbe_adapter *adapter) 154static void ixgbe_service_event_schedule(struct ixgbe_adapter *adapter)
152{ 155{
153 if (!test_bit(__IXGBE_DOWN, &adapter->state) && 156 if (!test_bit(__IXGBE_DOWN, &adapter->state) &&
@@ -6834,7 +6837,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6834 adapter->pdev = pdev; 6837 adapter->pdev = pdev;
6835 hw = &adapter->hw; 6838 hw = &adapter->hw;
6836 hw->back = adapter; 6839 hw->back = adapter;
6837 adapter->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1; 6840 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
6838 6841
6839 hw->hw_addr = ioremap(pci_resource_start(pdev, 0), 6842 hw->hw_addr = ioremap(pci_resource_start(pdev, 0),
6840 pci_resource_len(pdev, 0)); 6843 pci_resource_len(pdev, 0));
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 581c65976bb4..307611ae831d 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -91,7 +91,10 @@ MODULE_DESCRIPTION("Intel(R) 82599 Virtual Function Driver");
91MODULE_LICENSE("GPL"); 91MODULE_LICENSE("GPL");
92MODULE_VERSION(DRV_VERSION); 92MODULE_VERSION(DRV_VERSION);
93 93
94#define DEFAULT_DEBUG_LEVEL_SHIFT 3 94#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
95static int debug = -1;
96module_param(debug, int, 0);
97MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
95 98
96/* forward decls */ 99/* forward decls */
97static void ixgbevf_set_itr_msix(struct ixgbevf_q_vector *q_vector); 100static void ixgbevf_set_itr_msix(struct ixgbevf_q_vector *q_vector);
@@ -3367,7 +3370,7 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
3367 adapter->pdev = pdev; 3370 adapter->pdev = pdev;
3368 hw = &adapter->hw; 3371 hw = &adapter->hw;
3369 hw->back = adapter; 3372 hw->back = adapter;
3370 adapter->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1; 3373 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
3371 3374
3372 /* 3375 /*
3373 * call save state here in standalone driver because it relies on 3376 * call save state here in standalone driver because it relies on
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 423a1a2a702e..c9b504e2dfc3 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -1767,13 +1767,14 @@ static int sky2_open(struct net_device *dev)
1767 1767
1768 sky2_hw_up(sky2); 1768 sky2_hw_up(sky2);
1769 1769
1770 /* Enable interrupts from phy/mac for port */
1771 imask = sky2_read32(hw, B0_IMSK);
1772
1770 if (hw->chip_id == CHIP_ID_YUKON_OPT || 1773 if (hw->chip_id == CHIP_ID_YUKON_OPT ||
1771 hw->chip_id == CHIP_ID_YUKON_PRM || 1774 hw->chip_id == CHIP_ID_YUKON_PRM ||
1772 hw->chip_id == CHIP_ID_YUKON_OP_2) 1775 hw->chip_id == CHIP_ID_YUKON_OP_2)
1773 imask |= Y2_IS_PHY_QLNK; /* enable PHY Quick Link */ 1776 imask |= Y2_IS_PHY_QLNK; /* enable PHY Quick Link */
1774 1777
1775 /* Enable interrupts from phy/mac for port */
1776 imask = sky2_read32(hw, B0_IMSK);
1777 imask |= portirq_msk[port]; 1778 imask |= portirq_msk[port];
1778 sky2_write32(hw, B0_IMSK, imask); 1779 sky2_write32(hw, B0_IMSK, imask);
1779 sky2_read32(hw, B0_IMSK); 1780 sky2_read32(hw, B0_IMSK);
@@ -2468,6 +2469,17 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
2468 return err; 2469 return err;
2469} 2470}
2470 2471
2472static inline bool needs_copy(const struct rx_ring_info *re,
2473 unsigned length)
2474{
2475#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2476 /* Some architectures need the IP header to be aligned */
2477 if (!IS_ALIGNED(re->data_addr + ETH_HLEN, sizeof(u32)))
2478 return true;
2479#endif
2480 return length < copybreak;
2481}
2482
2471/* For small just reuse existing skb for next receive */ 2483/* For small just reuse existing skb for next receive */
2472static struct sk_buff *receive_copy(struct sky2_port *sky2, 2484static struct sk_buff *receive_copy(struct sky2_port *sky2,
2473 const struct rx_ring_info *re, 2485 const struct rx_ring_info *re,
@@ -2598,7 +2610,7 @@ static struct sk_buff *sky2_receive(struct net_device *dev,
2598 goto error; 2610 goto error;
2599 2611
2600okay: 2612okay:
2601 if (length < copybreak) 2613 if (needs_copy(re, length))
2602 skb = receive_copy(sky2, re, length); 2614 skb = receive_copy(sky2, re, length);
2603 else 2615 else
2604 skb = receive_new(sky2, re, length); 2616 skb = receive_new(sky2, re, length);
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 9e2b911a1230..d69fee41f24a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -83,8 +83,9 @@
83 83
84#define MLX4_EN_WATCHDOG_TIMEOUT (15 * HZ) 84#define MLX4_EN_WATCHDOG_TIMEOUT (15 * HZ)
85 85
86#define MLX4_EN_ALLOC_ORDER 2 86/* Use the maximum between 16384 and a single page */
87#define MLX4_EN_ALLOC_SIZE (PAGE_SIZE << MLX4_EN_ALLOC_ORDER) 87#define MLX4_EN_ALLOC_SIZE PAGE_ALIGN(16384)
88#define MLX4_EN_ALLOC_ORDER get_order(MLX4_EN_ALLOC_SIZE)
88 89
89#define MLX4_EN_MAX_LRO_DESCRIPTORS 32 90#define MLX4_EN_MAX_LRO_DESCRIPTORS 32
90 91
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 69444247c20b..6dfc26d85e47 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1441,7 +1441,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
1441 } 1441 }
1442#endif 1442#endif
1443 if (!is_valid_ether_addr(ndev->dev_addr)) 1443 if (!is_valid_ether_addr(ndev->dev_addr))
1444 dev_hw_addr_random(ndev, ndev->dev_addr); 1444 eth_hw_addr_random(ndev);
1445 1445
1446 /* Reset the ethernet controller */ 1446 /* Reset the ethernet controller */
1447 __lpc_eth_reset(pldat); 1447 __lpc_eth_reset(pldat);
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 7b23554f80b6..f54509377efa 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -5810,7 +5810,10 @@ static void __rtl8169_resume(struct net_device *dev)
5810 5810
5811 rtl_pll_power_up(tp); 5811 rtl_pll_power_up(tp);
5812 5812
5813 rtl_lock_work(tp);
5814 napi_enable(&tp->napi);
5813 set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); 5815 set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
5816 rtl_unlock_work(tp);
5814 5817
5815 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); 5818 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
5816} 5819}
diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig
index 9755b49bbefb..3fb2355af37e 100644
--- a/drivers/net/ethernet/renesas/Kconfig
+++ b/drivers/net/ethernet/renesas/Kconfig
@@ -7,7 +7,8 @@ config SH_ETH
7 depends on SUPERH && \ 7 depends on SUPERH && \
8 (CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712 || \ 8 (CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712 || \
9 CPU_SUBTYPE_SH7763 || CPU_SUBTYPE_SH7619 || \ 9 CPU_SUBTYPE_SH7763 || CPU_SUBTYPE_SH7619 || \
10 CPU_SUBTYPE_SH7724 || CPU_SUBTYPE_SH7757) 10 CPU_SUBTYPE_SH7724 || CPU_SUBTYPE_SH7734 || \
11 CPU_SUBTYPE_SH7757)
11 select CRC32 12 select CRC32
12 select NET_CORE 13 select NET_CORE
13 select MII 14 select MII
@@ -16,4 +17,4 @@ config SH_ETH
16 ---help--- 17 ---help---
17 Renesas SuperH Ethernet device driver. 18 Renesas SuperH Ethernet device driver.
18 This driver supporting CPUs are: 19 This driver supporting CPUs are:
19 - SH7710, SH7712, SH7763, SH7619, SH7724, and SH7757. 20 - SH7619, SH7710, SH7712, SH7724, SH7734, SH7763 and SH7757.
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 8615961c1287..d63e09b29a96 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * SuperH Ethernet device driver 2 * SuperH Ethernet device driver
3 * 3 *
4 * Copyright (C) 2006-2008 Nobuhiro Iwamatsu 4 * Copyright (C) 2006-2012 Nobuhiro Iwamatsu
5 * Copyright (C) 2008-2009 Renesas Solutions Corp. 5 * Copyright (C) 2008-2012 Renesas Solutions Corp.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License, 8 * under the terms and conditions of the GNU General Public License,
@@ -38,6 +38,7 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/ethtool.h> 39#include <linux/ethtool.h>
40#include <linux/if_vlan.h> 40#include <linux/if_vlan.h>
41#include <linux/clk.h>
41#include <linux/sh_eth.h> 42#include <linux/sh_eth.h>
42 43
43#include "sh_eth.h" 44#include "sh_eth.h"
@@ -279,8 +280,9 @@ static struct sh_eth_cpu_data *sh_eth_get_cpu_data(struct sh_eth_private *mdp)
279 return &sh_eth_my_cpu_data; 280 return &sh_eth_my_cpu_data;
280} 281}
281 282
282#elif defined(CONFIG_CPU_SUBTYPE_SH7763) 283#elif defined(CONFIG_CPU_SUBTYPE_SH7734) || defined(CONFIG_CPU_SUBTYPE_SH7763)
283#define SH_ETH_HAS_TSU 1 284#define SH_ETH_HAS_TSU 1
285static void sh_eth_reset_hw_crc(struct net_device *ndev);
284static void sh_eth_chip_reset(struct net_device *ndev) 286static void sh_eth_chip_reset(struct net_device *ndev)
285{ 287{
286 struct sh_eth_private *mdp = netdev_priv(ndev); 288 struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -314,6 +316,9 @@ static void sh_eth_reset(struct net_device *ndev)
314 sh_eth_write(ndev, 0x0, RDFAR); 316 sh_eth_write(ndev, 0x0, RDFAR);
315 sh_eth_write(ndev, 0x0, RDFXR); 317 sh_eth_write(ndev, 0x0, RDFXR);
316 sh_eth_write(ndev, 0x0, RDFFR); 318 sh_eth_write(ndev, 0x0, RDFFR);
319
320 /* Reset HW CRC register */
321 sh_eth_reset_hw_crc(ndev);
317} 322}
318 323
319static void sh_eth_set_duplex(struct net_device *ndev) 324static void sh_eth_set_duplex(struct net_device *ndev)
@@ -370,8 +375,17 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
370 .no_trimd = 1, 375 .no_trimd = 1,
371 .no_ade = 1, 376 .no_ade = 1,
372 .tsu = 1, 377 .tsu = 1,
378#if defined(CONFIG_CPU_SUBTYPE_SH7734)
379 .hw_crc = 1,
380#endif
373}; 381};
374 382
383static void sh_eth_reset_hw_crc(struct net_device *ndev)
384{
385 if (sh_eth_my_cpu_data.hw_crc)
386 sh_eth_write(ndev, 0x0, CSMR);
387}
388
375#elif defined(CONFIG_CPU_SUBTYPE_SH7619) 389#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
376#define SH_ETH_RESET_DEFAULT 1 390#define SH_ETH_RESET_DEFAULT 1
377static struct sh_eth_cpu_data sh_eth_my_cpu_data = { 391static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
@@ -790,7 +804,7 @@ static int sh_eth_dev_init(struct net_device *ndev)
790 /* all sh_eth int mask */ 804 /* all sh_eth int mask */
791 sh_eth_write(ndev, 0, EESIPR); 805 sh_eth_write(ndev, 0, EESIPR);
792 806
793#if defined(__LITTLE_ENDIAN__) 807#if defined(__LITTLE_ENDIAN)
794 if (mdp->cd->hw_swap) 808 if (mdp->cd->hw_swap)
795 sh_eth_write(ndev, EDMR_EL, EDMR); 809 sh_eth_write(ndev, EDMR_EL, EDMR);
796 else 810 else
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
index 57dc26261116..0fa14afce23d 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * SuperH Ethernet device driver 2 * SuperH Ethernet device driver
3 * 3 *
4 * Copyright (C) 2006-2008 Nobuhiro Iwamatsu 4 * Copyright (C) 2006-2012 Nobuhiro Iwamatsu
5 * Copyright (C) 2008-2011 Renesas Solutions Corp. 5 * Copyright (C) 2008-2012 Renesas Solutions Corp.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License, 8 * under the terms and conditions of the GNU General Public License,
@@ -98,6 +98,8 @@ enum {
98 CEECR, 98 CEECR,
99 MAFCR, 99 MAFCR,
100 RTRATE, 100 RTRATE,
101 CSMR,
102 RMII_MII,
101 103
102 /* TSU Absolute address */ 104 /* TSU Absolute address */
103 ARSTR, 105 ARSTR,
@@ -172,6 +174,7 @@ static const u16 sh_eth_offset_gigabit[SH_ETH_MAX_REGISTER_OFFSET] = {
172 [RMCR] = 0x0458, 174 [RMCR] = 0x0458,
173 [RPADIR] = 0x0460, 175 [RPADIR] = 0x0460,
174 [FCFTR] = 0x0468, 176 [FCFTR] = 0x0468,
177 [CSMR] = 0x04E4,
175 178
176 [ECMR] = 0x0500, 179 [ECMR] = 0x0500,
177 [ECSR] = 0x0510, 180 [ECSR] = 0x0510,
@@ -200,6 +203,7 @@ static const u16 sh_eth_offset_gigabit[SH_ETH_MAX_REGISTER_OFFSET] = {
200 [CERCR] = 0x0768, 203 [CERCR] = 0x0768,
201 [CEECR] = 0x0770, 204 [CEECR] = 0x0770,
202 [MAFCR] = 0x0778, 205 [MAFCR] = 0x0778,
206 [RMII_MII] = 0x0790,
203 207
204 [ARSTR] = 0x0000, 208 [ARSTR] = 0x0000,
205 [TSU_CTRST] = 0x0004, 209 [TSU_CTRST] = 0x0004,
@@ -377,7 +381,7 @@ static const u16 sh_eth_offset_fast_sh3_sh2[SH_ETH_MAX_REGISTER_OFFSET] = {
377/* 381/*
378 * Register's bits 382 * Register's bits
379 */ 383 */
380#ifdef CONFIG_CPU_SUBTYPE_SH7763 384#if defined(CONFIG_CPU_SUBTYPE_SH7734) || defined(CONFIG_CPU_SUBTYPE_SH7763)
381/* EDSR */ 385/* EDSR */
382enum EDSR_BIT { 386enum EDSR_BIT {
383 EDSR_ENT = 0x01, EDSR_ENR = 0x02, 387 EDSR_ENT = 0x01, EDSR_ENR = 0x02,
@@ -689,7 +693,7 @@ enum TSU_FWSLC_BIT {
689 */ 693 */
690struct sh_eth_txdesc { 694struct sh_eth_txdesc {
691 u32 status; /* TD0 */ 695 u32 status; /* TD0 */
692#if defined(CONFIG_CPU_LITTLE_ENDIAN) 696#if defined(__LITTLE_ENDIAN)
693 u16 pad0; /* TD1 */ 697 u16 pad0; /* TD1 */
694 u16 buffer_length; /* TD1 */ 698 u16 buffer_length; /* TD1 */
695#else 699#else
@@ -706,7 +710,7 @@ struct sh_eth_txdesc {
706 */ 710 */
707struct sh_eth_rxdesc { 711struct sh_eth_rxdesc {
708 u32 status; /* RD0 */ 712 u32 status; /* RD0 */
709#if defined(CONFIG_CPU_LITTLE_ENDIAN) 713#if defined(__LITTLE_ENDIAN)
710 u16 frame_length; /* RD1 */ 714 u16 frame_length; /* RD1 */
711 u16 buffer_length; /* RD1 */ 715 u16 buffer_length; /* RD1 */
712#else 716#else
@@ -751,6 +755,7 @@ struct sh_eth_cpu_data {
751 unsigned rpadir:1; /* E-DMAC have RPADIR */ 755 unsigned rpadir:1; /* E-DMAC have RPADIR */
752 unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */ 756 unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */
753 unsigned no_ade:1; /* E-DMAC DO NOT have ADE bit in EESR */ 757 unsigned no_ade:1; /* E-DMAC DO NOT have ADE bit in EESR */
758 unsigned hw_crc:1; /* E-DMAC have CSMR */
754}; 759};
755 760
756struct sh_eth_private { 761struct sh_eth_private {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index e85ffbd54830..48d56da62f08 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1737,10 +1737,12 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
1737 struct mac_device_info *mac; 1737 struct mac_device_info *mac;
1738 1738
1739 /* Identify the MAC HW device */ 1739 /* Identify the MAC HW device */
1740 if (priv->plat->has_gmac) 1740 if (priv->plat->has_gmac) {
1741 priv->dev->priv_flags |= IFF_UNICAST_FLT;
1741 mac = dwmac1000_setup(priv->ioaddr); 1742 mac = dwmac1000_setup(priv->ioaddr);
1742 else 1743 } else {
1743 mac = dwmac100_setup(priv->ioaddr); 1744 mac = dwmac100_setup(priv->ioaddr);
1745 }
1744 if (!mac) 1746 if (!mac)
1745 return -ENOMEM; 1747 return -ENOMEM;
1746 1748
diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c
index 261356c2dc99..3d501ec7fad7 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -342,6 +342,21 @@ inline int __netio_fastio1(u32 fastio_index, u32 arg0)
342} 342}
343 343
344 344
345static void tile_net_return_credit(struct tile_net_cpu *info)
346{
347 struct tile_netio_queue *queue = &info->queue;
348 netio_queue_user_impl_t *qup = &queue->__user_part;
349
350 /* Return four credits after every fourth packet. */
351 if (--qup->__receive_credit_remaining == 0) {
352 u32 interval = qup->__receive_credit_interval;
353 qup->__receive_credit_remaining = interval;
354 __netio_fastio_return_credits(qup->__fastio_index, interval);
355 }
356}
357
358
359
345/* 360/*
346 * Provide a linux buffer to LIPP. 361 * Provide a linux buffer to LIPP.
347 */ 362 */
@@ -433,7 +448,7 @@ static bool tile_net_provide_needed_buffer(struct tile_net_cpu *info,
433 struct sk_buff **skb_ptr; 448 struct sk_buff **skb_ptr;
434 449
435 /* Request 96 extra bytes for alignment purposes. */ 450 /* Request 96 extra bytes for alignment purposes. */
436 skb = netdev_alloc_skb(info->napi->dev, len + padding); 451 skb = netdev_alloc_skb(info->napi.dev, len + padding);
437 if (skb == NULL) 452 if (skb == NULL)
438 return false; 453 return false;
439 454
@@ -864,19 +879,11 @@ static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
864 879
865 stats->rx_packets++; 880 stats->rx_packets++;
866 stats->rx_bytes += len; 881 stats->rx_bytes += len;
867
868 if (small)
869 info->num_needed_small_buffers++;
870 else
871 info->num_needed_large_buffers++;
872 } 882 }
873 883
874 /* Return four credits after every fourth packet. */ 884 /* ISSUE: It would be nice to defer this until the packet has */
875 if (--qup->__receive_credit_remaining == 0) { 885 /* actually been processed. */
876 u32 interval = qup->__receive_credit_interval; 886 tile_net_return_credit(info);
877 qup->__receive_credit_remaining = interval;
878 __netio_fastio_return_credits(qup->__fastio_index, interval);
879 }
880 887
881 /* Consume this packet. */ 888 /* Consume this packet. */
882 qup->__packet_receive_read = index2; 889 qup->__packet_receive_read = index2;
@@ -1543,7 +1550,7 @@ static int tile_net_drain_lipp_buffers(struct tile_net_priv *priv)
1543 1550
1544 /* Drain all the LIPP buffers. */ 1551 /* Drain all the LIPP buffers. */
1545 while (true) { 1552 while (true) {
1546 int buffer; 1553 unsigned int buffer;
1547 1554
1548 /* NOTE: This should never fail. */ 1555 /* NOTE: This should never fail. */
1549 if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&buffer, 1556 if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&buffer,
@@ -1707,7 +1714,7 @@ static unsigned int tile_net_tx_frags(lepp_frag_t *frags,
1707 if (!hash_default) { 1714 if (!hash_default) {
1708 void *va = pfn_to_kaddr(pfn) + f->page_offset; 1715 void *va = pfn_to_kaddr(pfn) + f->page_offset;
1709 BUG_ON(PageHighMem(skb_frag_page(f))); 1716 BUG_ON(PageHighMem(skb_frag_page(f)));
1710 finv_buffer_remote(va, f->size, 0); 1717 finv_buffer_remote(va, skb_frag_size(f), 0);
1711 } 1718 }
1712 1719
1713 cpa = ((phys_addr_t)pfn << PAGE_SHIFT) + f->page_offset; 1720 cpa = ((phys_addr_t)pfn << PAGE_SHIFT) + f->page_offset;
@@ -1735,8 +1742,8 @@ static unsigned int tile_net_tx_frags(lepp_frag_t *frags,
1735 * Sometimes, if "sendfile()" requires copying, we will be called with 1742 * Sometimes, if "sendfile()" requires copying, we will be called with
1736 * "data" containing the header and payload, with "frags" being empty. 1743 * "data" containing the header and payload, with "frags" being empty.
1737 * 1744 *
1738 * In theory, "sh->nr_frags" could be 3, but in practice, it seems 1745 * Sometimes, for example when using NFS over TCP, a single segment can
1739 * that this will never actually happen. 1746 * span 3 fragments, which must be handled carefully in LEPP.
1740 * 1747 *
1741 * See "emulate_large_send_offload()" for some reference code, which 1748 * See "emulate_large_send_offload()" for some reference code, which
1742 * does not handle checksumming. 1749 * does not handle checksumming.
@@ -1844,10 +1851,8 @@ static int tile_net_tx_tso(struct sk_buff *skb, struct net_device *dev)
1844 1851
1845 spin_lock_irqsave(&priv->eq_lock, irqflags); 1852 spin_lock_irqsave(&priv->eq_lock, irqflags);
1846 1853
1847 /* 1854 /* Handle completions if needed to make room. */
1848 * Handle completions if needed to make room. 1855 /* NOTE: Return NETDEV_TX_BUSY if there is still no room. */
1849 * HACK: Spin until there is sufficient room.
1850 */
1851 if (lepp_num_free_comp_slots(eq) == 0) { 1856 if (lepp_num_free_comp_slots(eq) == 0) {
1852 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0); 1857 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0);
1853 if (nolds == 0) { 1858 if (nolds == 0) {
@@ -1861,6 +1866,7 @@ busy:
1861 cmd_tail = eq->cmd_tail; 1866 cmd_tail = eq->cmd_tail;
1862 1867
1863 /* Prepare to advance, detecting full queue. */ 1868 /* Prepare to advance, detecting full queue. */
1869 /* NOTE: Return NETDEV_TX_BUSY if the queue is full. */
1864 cmd_next = cmd_tail + cmd_size; 1870 cmd_next = cmd_tail + cmd_size;
1865 if (cmd_tail < cmd_head && cmd_next >= cmd_head) 1871 if (cmd_tail < cmd_head && cmd_next >= cmd_head)
1866 goto busy; 1872 goto busy;
@@ -2023,10 +2029,8 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
2023 2029
2024 spin_lock_irqsave(&priv->eq_lock, irqflags); 2030 spin_lock_irqsave(&priv->eq_lock, irqflags);
2025 2031
2026 /* 2032 /* Handle completions if needed to make room. */
2027 * Handle completions if needed to make room. 2033 /* NOTE: Return NETDEV_TX_BUSY if there is still no room. */
2028 * HACK: Spin until there is sufficient room.
2029 */
2030 if (lepp_num_free_comp_slots(eq) == 0) { 2034 if (lepp_num_free_comp_slots(eq) == 0) {
2031 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0); 2035 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0);
2032 if (nolds == 0) { 2036 if (nolds == 0) {
@@ -2040,6 +2044,7 @@ busy:
2040 cmd_tail = eq->cmd_tail; 2044 cmd_tail = eq->cmd_tail;
2041 2045
2042 /* Copy the commands, or fail. */ 2046 /* Copy the commands, or fail. */
2047 /* NOTE: Return NETDEV_TX_BUSY if the queue is full. */
2043 for (i = 0; i < num_frags; i++) { 2048 for (i = 0; i < num_frags; i++) {
2044 2049
2045 /* Prepare to advance, detecting full queue. */ 2050 /* Prepare to advance, detecting full queue. */
@@ -2261,6 +2266,23 @@ static int tile_net_get_mac(struct net_device *dev)
2261 return 0; 2266 return 0;
2262} 2267}
2263 2268
2269
2270#ifdef CONFIG_NET_POLL_CONTROLLER
2271/*
2272 * Polling 'interrupt' - used by things like netconsole to send skbs
2273 * without having to re-enable interrupts. It's not called while
2274 * the interrupt routine is executing.
2275 */
2276static void tile_net_netpoll(struct net_device *dev)
2277{
2278 struct tile_net_priv *priv = netdev_priv(dev);
2279 disable_percpu_irq(priv->intr_id);
2280 tile_net_handle_ingress_interrupt(priv->intr_id, dev);
2281 enable_percpu_irq(priv->intr_id, 0);
2282}
2283#endif
2284
2285
2264static const struct net_device_ops tile_net_ops = { 2286static const struct net_device_ops tile_net_ops = {
2265 .ndo_open = tile_net_open, 2287 .ndo_open = tile_net_open,
2266 .ndo_stop = tile_net_stop, 2288 .ndo_stop = tile_net_stop,
@@ -2269,7 +2291,10 @@ static const struct net_device_ops tile_net_ops = {
2269 .ndo_get_stats = tile_net_get_stats, 2291 .ndo_get_stats = tile_net_get_stats,
2270 .ndo_change_mtu = tile_net_change_mtu, 2292 .ndo_change_mtu = tile_net_change_mtu,
2271 .ndo_tx_timeout = tile_net_tx_timeout, 2293 .ndo_tx_timeout = tile_net_tx_timeout,
2272 .ndo_set_mac_address = tile_net_set_mac_address 2294 .ndo_set_mac_address = tile_net_set_mac_address,
2295#ifdef CONFIG_NET_POLL_CONTROLLER
2296 .ndo_poll_controller = tile_net_netpoll,
2297#endif
2273}; 2298};
2274 2299
2275 2300
@@ -2409,7 +2434,7 @@ static void tile_net_cleanup(void)
2409 */ 2434 */
2410static int tile_net_init_module(void) 2435static int tile_net_init_module(void)
2411{ 2436{
2412 pr_info("Tilera IPP Net Driver\n"); 2437 pr_info("Tilera Network Driver\n");
2413 2438
2414 tile_net_devs[0] = tile_net_dev_init("xgbe0"); 2439 tile_net_devs[0] = tile_net_dev_init("xgbe0");
2415 tile_net_devs[1] = tile_net_dev_init("xgbe1"); 2440 tile_net_devs[1] = tile_net_dev_init("xgbe1");
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 39b8cf3dafcd..fcfa01f7ceb6 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -503,30 +503,32 @@ static int rhine_vlan_rx_add_vid(struct net_device *dev, unsigned short vid);
503static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid); 503static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid);
504static void rhine_restart_tx(struct net_device *dev); 504static void rhine_restart_tx(struct net_device *dev);
505 505
506static void rhine_wait_bit(struct rhine_private *rp, u8 reg, u8 mask, bool high) 506static void rhine_wait_bit(struct rhine_private *rp, u8 reg, u8 mask, bool low)
507{ 507{
508 void __iomem *ioaddr = rp->base; 508 void __iomem *ioaddr = rp->base;
509 int i; 509 int i;
510 510
511 for (i = 0; i < 1024; i++) { 511 for (i = 0; i < 1024; i++) {
512 if (high ^ !!(ioread8(ioaddr + reg) & mask)) 512 bool has_mask_bits = !!(ioread8(ioaddr + reg) & mask);
513
514 if (low ^ has_mask_bits)
513 break; 515 break;
514 udelay(10); 516 udelay(10);
515 } 517 }
516 if (i > 64) { 518 if (i > 64) {
517 netif_dbg(rp, hw, rp->dev, "%s bit wait (%02x/%02x) cycle " 519 netif_dbg(rp, hw, rp->dev, "%s bit wait (%02x/%02x) cycle "
518 "count: %04d\n", high ? "high" : "low", reg, mask, i); 520 "count: %04d\n", low ? "low" : "high", reg, mask, i);
519 } 521 }
520} 522}
521 523
522static void rhine_wait_bit_high(struct rhine_private *rp, u8 reg, u8 mask) 524static void rhine_wait_bit_high(struct rhine_private *rp, u8 reg, u8 mask)
523{ 525{
524 rhine_wait_bit(rp, reg, mask, true); 526 rhine_wait_bit(rp, reg, mask, false);
525} 527}
526 528
527static void rhine_wait_bit_low(struct rhine_private *rp, u8 reg, u8 mask) 529static void rhine_wait_bit_low(struct rhine_private *rp, u8 reg, u8 mask)
528{ 530{
529 rhine_wait_bit(rp, reg, mask, false); 531 rhine_wait_bit(rp, reg, mask, true);
530} 532}
531 533
532static u32 rhine_get_events(struct rhine_private *rp) 534static u32 rhine_get_events(struct rhine_private *rp)
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index a0d1913a58d3..e25067552b20 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -147,7 +147,7 @@ static void sa1100_irda_dma_start(struct sa1100_buf *buf,
147 struct dma_async_tx_descriptor *desc; 147 struct dma_async_tx_descriptor *desc;
148 struct dma_chan *chan = buf->chan; 148 struct dma_chan *chan = buf->chan;
149 149
150 desc = chan->device->device_prep_slave_sg(chan, &buf->sg, 1, dir, 150 desc = dmaengine_prep_slave_sg(chan, &buf->sg, 1, dir,
151 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 151 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
152 if (desc) { 152 if (desc) {
153 desc->callback = cb; 153 desc->callback = cb;
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index 0856e1b7a849..f08c85acf761 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -162,7 +162,8 @@ static int ip101a_g_config_init(struct phy_device *phydev)
162 /* Enable Auto Power Saving mode */ 162 /* Enable Auto Power Saving mode */
163 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 163 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
164 c |= IP101A_G_APS_ON; 164 c |= IP101A_G_APS_ON;
165 return c; 165
166 return phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c);
166} 167}
167 168
168static int ip175c_read_status(struct phy_device *phydev) 169static int ip175c_read_status(struct phy_device *phydev)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 159da2905fe9..33f8c51968b6 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -235,7 +235,7 @@ struct ppp_net {
235/* Prototypes. */ 235/* Prototypes. */
236static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf, 236static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
237 struct file *file, unsigned int cmd, unsigned long arg); 237 struct file *file, unsigned int cmd, unsigned long arg);
238static void ppp_xmit_process(struct ppp *ppp); 238static int ppp_xmit_process(struct ppp *ppp);
239static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb); 239static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
240static void ppp_push(struct ppp *ppp); 240static void ppp_push(struct ppp *ppp);
241static void ppp_channel_push(struct channel *pch); 241static void ppp_channel_push(struct channel *pch);
@@ -968,9 +968,9 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
968 proto = npindex_to_proto[npi]; 968 proto = npindex_to_proto[npi];
969 put_unaligned_be16(proto, pp); 969 put_unaligned_be16(proto, pp);
970 970
971 netif_stop_queue(dev);
972 skb_queue_tail(&ppp->file.xq, skb); 971 skb_queue_tail(&ppp->file.xq, skb);
973 ppp_xmit_process(ppp); 972 if (!ppp_xmit_process(ppp))
973 netif_stop_queue(dev);
974 return NETDEV_TX_OK; 974 return NETDEV_TX_OK;
975 975
976 outf: 976 outf:
@@ -1048,10 +1048,11 @@ static void ppp_setup(struct net_device *dev)
1048 * Called to do any work queued up on the transmit side 1048 * Called to do any work queued up on the transmit side
1049 * that can now be done. 1049 * that can now be done.
1050 */ 1050 */
1051static void 1051static int
1052ppp_xmit_process(struct ppp *ppp) 1052ppp_xmit_process(struct ppp *ppp)
1053{ 1053{
1054 struct sk_buff *skb; 1054 struct sk_buff *skb;
1055 int ret = 0;
1055 1056
1056 ppp_xmit_lock(ppp); 1057 ppp_xmit_lock(ppp);
1057 if (!ppp->closing) { 1058 if (!ppp->closing) {
@@ -1061,10 +1062,13 @@ ppp_xmit_process(struct ppp *ppp)
1061 ppp_send_frame(ppp, skb); 1062 ppp_send_frame(ppp, skb);
1062 /* If there's no work left to do, tell the core net 1063 /* If there's no work left to do, tell the core net
1063 code that we can accept some more. */ 1064 code that we can accept some more. */
1064 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq)) 1065 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq)) {
1065 netif_wake_queue(ppp->dev); 1066 netif_wake_queue(ppp->dev);
1067 ret = 1;
1068 }
1066 } 1069 }
1067 ppp_xmit_unlock(ppp); 1070 ppp_xmit_unlock(ppp);
1071 return ret;
1068} 1072}
1069 1073
1070static inline struct sk_buff * 1074static inline struct sk_buff *
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index a57f05726b57..91d25888a1b9 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -375,8 +375,8 @@ static void rionet_remove(struct rio_dev *rdev)
375 struct net_device *ndev = rio_get_drvdata(rdev); 375 struct net_device *ndev = rio_get_drvdata(rdev);
376 struct rionet_peer *peer, *tmp; 376 struct rionet_peer *peer, *tmp;
377 377
378 free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ? 378 free_pages((unsigned long)rionet_active, get_order(sizeof(void *) *
379 __fls(sizeof(void *)) + 4 : 0); 379 RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size)));
380 unregister_netdev(ndev); 380 unregister_netdev(ndev);
381 free_netdev(ndev); 381 free_netdev(ndev);
382 382
@@ -432,15 +432,16 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
432 int rc = 0; 432 int rc = 0;
433 struct rionet_private *rnet; 433 struct rionet_private *rnet;
434 u16 device_id; 434 u16 device_id;
435 const size_t rionet_active_bytes = sizeof(void *) *
436 RIO_MAX_ROUTE_ENTRIES(mport->sys_size);
435 437
436 rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL, 438 rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
437 mport->sys_size ? __fls(sizeof(void *)) + 4 : 0); 439 get_order(rionet_active_bytes));
438 if (!rionet_active) { 440 if (!rionet_active) {
439 rc = -ENOMEM; 441 rc = -ENOMEM;
440 goto out; 442 goto out;
441 } 443 }
442 memset((void *)rionet_active, 0, sizeof(void *) * 444 memset((void *)rionet_active, 0, rionet_active_bytes);
443 RIO_MAX_ROUTE_ENTRIES(mport->sys_size));
444 445
445 /* Set up private area */ 446 /* Set up private area */
446 rnet = netdev_priv(ndev); 447 rnet = netdev_priv(ndev);
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 3886b30ed373..3e41b00c6806 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -165,13 +165,13 @@ static void rx_complete(struct urb *req)
165 memcpy(skb_put(skb, 1), page_address(page), 1); 165 memcpy(skb_put(skb, 1), page_address(page), 1);
166 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, 166 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
167 page, 1, req->actual_length, 167 page, 1, req->actual_length,
168 req->actual_length); 168 PAGE_SIZE);
169 page = NULL; 169 page = NULL;
170 } 170 }
171 } else { 171 } else {
172 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, 172 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
173 page, 0, req->actual_length, 173 page, 0, req->actual_length,
174 req->actual_length); 174 PAGE_SIZE);
175 page = NULL; 175 page = NULL;
176 } 176 }
177 if (req->actual_length < PAGE_SIZE) 177 if (req->actual_length < PAGE_SIZE)
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index 439690be519f..685a4e22c768 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -93,6 +93,7 @@ static int eem_bind(struct usbnet *dev, struct usb_interface *intf)
93 /* no jumbogram (16K) support for now */ 93 /* no jumbogram (16K) support for now */
94 94
95 dev->net->hard_header_len += EEM_HEAD + ETH_FCS_LEN; 95 dev->net->hard_header_len += EEM_HEAD + ETH_FCS_LEN;
96 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
96 97
97 return 0; 98 return 0;
98} 99}
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 6dda2fe5b15b..d363b31053da 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -85,32 +85,6 @@
85#define INT_CRERR_CNT 0x06 85#define INT_CRERR_CNT 0x06
86#define INT_COL_CNT 0x07 86#define INT_COL_CNT 0x07
87 87
88/* Transmit status register errors */
89#define TSR_ECOL (1<<5)
90#define TSR_LCOL (1<<4)
91#define TSR_LOSS_CRS (1<<3)
92#define TSR_JBR (1<<2)
93#define TSR_ERRORS (TSR_ECOL | TSR_LCOL | TSR_LOSS_CRS | TSR_JBR)
94/* Receive status register errors */
95#define RSR_CRC (1<<2)
96#define RSR_FAE (1<<1)
97#define RSR_ERRORS (RSR_CRC | RSR_FAE)
98
99/* Media status register definitions */
100#define MSR_DUPLEX (1<<4)
101#define MSR_SPEED (1<<3)
102#define MSR_LINK (1<<2)
103
104/* Interrupt pipe data */
105#define INT_TSR 0x00
106#define INT_RSR 0x01
107#define INT_MSR 0x02
108#define INT_WAKSR 0x03
109#define INT_TXOK_CNT 0x04
110#define INT_RXLOST_CNT 0x05
111#define INT_CRERR_CNT 0x06
112#define INT_COL_CNT 0x07
113
114 88
115#define RTL8150_MTU 1540 89#define RTL8150_MTU 1540
116#define RTL8150_TX_TIMEOUT (HZ) 90#define RTL8150_TX_TIMEOUT (HZ)
diff --git a/drivers/net/usb/zaurus.c b/drivers/net/usb/zaurus.c
index c3197ce0e2ad..34db195fb8b0 100644
--- a/drivers/net/usb/zaurus.c
+++ b/drivers/net/usb/zaurus.c
@@ -337,6 +337,11 @@ static const struct usb_device_id products [] = {
337 .driver_info = ZAURUS_PXA_INFO, 337 .driver_info = ZAURUS_PXA_INFO,
338}, 338},
339{ 339{
340 /* Motorola Rokr E6 */
341 USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x6027, USB_CLASS_COMM,
342 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
343 .driver_info = (unsigned long) &bogus_mdlm_info,
344}, {
340 /* Motorola MOTOMAGX phones */ 345 /* Motorola MOTOMAGX phones */
341 USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x6425, USB_CLASS_COMM, 346 USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x6425, USB_CLASS_COMM,
342 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 347 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 019da012669f..4de2760c5937 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -625,12 +625,13 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
625 625
626 /* This can happen with OOM and indirect buffers. */ 626 /* This can happen with OOM and indirect buffers. */
627 if (unlikely(capacity < 0)) { 627 if (unlikely(capacity < 0)) {
628 if (net_ratelimit()) { 628 if (likely(capacity == -ENOMEM)) {
629 if (likely(capacity == -ENOMEM)) { 629 if (net_ratelimit()) {
630 dev_warn(&dev->dev, 630 dev_warn(&dev->dev,
631 "TX queue failure: out of memory\n"); 631 "TX queue failure: out of memory\n");
632 } else { 632 } else {
633 dev->stats.tx_fifo_errors++; 633 dev->stats.tx_fifo_errors++;
634 if (net_ratelimit())
634 dev_warn(&dev->dev, 635 dev_warn(&dev->dev,
635 "Unexpected TX queue failure: %d\n", 636 "Unexpected TX queue failure: %d\n",
636 capacity); 637 capacity);
diff --git a/drivers/net/wimax/i2400m/debugfs.c b/drivers/net/wimax/i2400m/debugfs.c
index 129ba36bd04d..4b66ab1d0e5c 100644
--- a/drivers/net/wimax/i2400m/debugfs.c
+++ b/drivers/net/wimax/i2400m/debugfs.c
@@ -53,17 +53,6 @@ struct dentry *debugfs_create_netdev_queue_stopped(
53 &fops_netdev_queue_stopped); 53 &fops_netdev_queue_stopped);
54} 54}
55 55
56
57/*
58 * inode->i_private has the @data argument to debugfs_create_file()
59 */
60static
61int i2400m_stats_open(struct inode *inode, struct file *filp)
62{
63 filp->private_data = inode->i_private;
64 return 0;
65}
66
67/* 56/*
68 * We don't allow partial reads of this file, as then the reader would 57 * We don't allow partial reads of this file, as then the reader would
69 * get weirdly confused data as it is updated. 58 * get weirdly confused data as it is updated.
@@ -117,7 +106,7 @@ ssize_t i2400m_rx_stats_write(struct file *filp, const char __user *buffer,
117static 106static
118const struct file_operations i2400m_rx_stats_fops = { 107const struct file_operations i2400m_rx_stats_fops = {
119 .owner = THIS_MODULE, 108 .owner = THIS_MODULE,
120 .open = i2400m_stats_open, 109 .open = simple_open,
121 .read = i2400m_rx_stats_read, 110 .read = i2400m_rx_stats_read,
122 .write = i2400m_rx_stats_write, 111 .write = i2400m_rx_stats_write,
123 .llseek = default_llseek, 112 .llseek = default_llseek,
@@ -170,7 +159,7 @@ ssize_t i2400m_tx_stats_write(struct file *filp, const char __user *buffer,
170static 159static
171const struct file_operations i2400m_tx_stats_fops = { 160const struct file_operations i2400m_tx_stats_fops = {
172 .owner = THIS_MODULE, 161 .owner = THIS_MODULE,
173 .open = i2400m_stats_open, 162 .open = simple_open,
174 .read = i2400m_tx_stats_read, 163 .read = i2400m_tx_stats_read,
175 .write = i2400m_tx_stats_write, 164 .write = i2400m_tx_stats_write,
176 .llseek = default_llseek, 165 .llseek = default_llseek,
diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
index 63e4b709efa9..1d76ae855f07 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -597,7 +597,8 @@ static void i2400m_get_drvinfo(struct net_device *net_dev,
597 struct i2400m *i2400m = net_dev_to_i2400m(net_dev); 597 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
598 598
599 strncpy(info->driver, KBUILD_MODNAME, sizeof(info->driver) - 1); 599 strncpy(info->driver, KBUILD_MODNAME, sizeof(info->driver) - 1);
600 strncpy(info->fw_version, i2400m->fw_name, sizeof(info->fw_version) - 1); 600 strncpy(info->fw_version,
601 i2400m->fw_name ? : "", sizeof(info->fw_version) - 1);
601 if (net_dev->dev.parent) 602 if (net_dev->dev.parent)
602 strncpy(info->bus_info, dev_name(net_dev->dev.parent), 603 strncpy(info->bus_info, dev_name(net_dev->dev.parent),
603 sizeof(info->bus_info) - 1); 604 sizeof(info->bus_info) - 1);
diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index 2c1b8b687646..29b1e033a10b 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -339,6 +339,23 @@ int i2400mu_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
339 return result; 339 return result;
340} 340}
341 341
342static void i2400mu_get_drvinfo(struct net_device *net_dev,
343 struct ethtool_drvinfo *info)
344{
345 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
346 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
347 struct usb_device *udev = i2400mu->usb_dev;
348
349 strncpy(info->driver, KBUILD_MODNAME, sizeof(info->driver) - 1);
350 strncpy(info->fw_version,
351 i2400m->fw_name ? : "", sizeof(info->fw_version) - 1);
352 usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
353}
354
355static const struct ethtool_ops i2400mu_ethtool_ops = {
356 .get_drvinfo = i2400mu_get_drvinfo,
357 .get_link = ethtool_op_get_link,
358};
342 359
343static 360static
344void i2400mu_netdev_setup(struct net_device *net_dev) 361void i2400mu_netdev_setup(struct net_device *net_dev)
@@ -347,6 +364,7 @@ void i2400mu_netdev_setup(struct net_device *net_dev)
347 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m); 364 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
348 i2400mu_init(i2400mu); 365 i2400mu_init(i2400mu);
349 i2400m_netdev_setup(net_dev); 366 i2400m_netdev_setup(net_dev);
367 net_dev->ethtool_ops = &i2400mu_ethtool_ops;
350} 368}
351 369
352 370
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 8c5ce8b0c734..e5e8f45d86ac 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -71,13 +71,6 @@ static unsigned int ath5k_debug;
71module_param_named(debug, ath5k_debug, uint, 0); 71module_param_named(debug, ath5k_debug, uint, 0);
72 72
73 73
74static int ath5k_debugfs_open(struct inode *inode, struct file *file)
75{
76 file->private_data = inode->i_private;
77 return 0;
78}
79
80
81/* debugfs: registers */ 74/* debugfs: registers */
82 75
83struct reg { 76struct reg {
@@ -265,7 +258,7 @@ static ssize_t write_file_beacon(struct file *file,
265static const struct file_operations fops_beacon = { 258static const struct file_operations fops_beacon = {
266 .read = read_file_beacon, 259 .read = read_file_beacon,
267 .write = write_file_beacon, 260 .write = write_file_beacon,
268 .open = ath5k_debugfs_open, 261 .open = simple_open,
269 .owner = THIS_MODULE, 262 .owner = THIS_MODULE,
270 .llseek = default_llseek, 263 .llseek = default_llseek,
271}; 264};
@@ -285,7 +278,7 @@ static ssize_t write_file_reset(struct file *file,
285 278
286static const struct file_operations fops_reset = { 279static const struct file_operations fops_reset = {
287 .write = write_file_reset, 280 .write = write_file_reset,
288 .open = ath5k_debugfs_open, 281 .open = simple_open,
289 .owner = THIS_MODULE, 282 .owner = THIS_MODULE,
290 .llseek = noop_llseek, 283 .llseek = noop_llseek,
291}; 284};
@@ -365,7 +358,7 @@ static ssize_t write_file_debug(struct file *file,
365static const struct file_operations fops_debug = { 358static const struct file_operations fops_debug = {
366 .read = read_file_debug, 359 .read = read_file_debug,
367 .write = write_file_debug, 360 .write = write_file_debug,
368 .open = ath5k_debugfs_open, 361 .open = simple_open,
369 .owner = THIS_MODULE, 362 .owner = THIS_MODULE,
370 .llseek = default_llseek, 363 .llseek = default_llseek,
371}; 364};
@@ -477,7 +470,7 @@ static ssize_t write_file_antenna(struct file *file,
477static const struct file_operations fops_antenna = { 470static const struct file_operations fops_antenna = {
478 .read = read_file_antenna, 471 .read = read_file_antenna,
479 .write = write_file_antenna, 472 .write = write_file_antenna,
480 .open = ath5k_debugfs_open, 473 .open = simple_open,
481 .owner = THIS_MODULE, 474 .owner = THIS_MODULE,
482 .llseek = default_llseek, 475 .llseek = default_llseek,
483}; 476};
@@ -532,7 +525,7 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
532 525
533static const struct file_operations fops_misc = { 526static const struct file_operations fops_misc = {
534 .read = read_file_misc, 527 .read = read_file_misc,
535 .open = ath5k_debugfs_open, 528 .open = simple_open,
536 .owner = THIS_MODULE, 529 .owner = THIS_MODULE,
537}; 530};
538 531
@@ -647,7 +640,7 @@ static ssize_t write_file_frameerrors(struct file *file,
647static const struct file_operations fops_frameerrors = { 640static const struct file_operations fops_frameerrors = {
648 .read = read_file_frameerrors, 641 .read = read_file_frameerrors,
649 .write = write_file_frameerrors, 642 .write = write_file_frameerrors,
650 .open = ath5k_debugfs_open, 643 .open = simple_open,
651 .owner = THIS_MODULE, 644 .owner = THIS_MODULE,
652 .llseek = default_llseek, 645 .llseek = default_llseek,
653}; 646};
@@ -810,7 +803,7 @@ static ssize_t write_file_ani(struct file *file,
810static const struct file_operations fops_ani = { 803static const struct file_operations fops_ani = {
811 .read = read_file_ani, 804 .read = read_file_ani,
812 .write = write_file_ani, 805 .write = write_file_ani,
813 .open = ath5k_debugfs_open, 806 .open = simple_open,
814 .owner = THIS_MODULE, 807 .owner = THIS_MODULE,
815 .llseek = default_llseek, 808 .llseek = default_llseek,
816}; 809};
@@ -881,7 +874,7 @@ static ssize_t write_file_queue(struct file *file,
881static const struct file_operations fops_queue = { 874static const struct file_operations fops_queue = {
882 .read = read_file_queue, 875 .read = read_file_queue,
883 .write = write_file_queue, 876 .write = write_file_queue,
884 .open = ath5k_debugfs_open, 877 .open = simple_open,
885 .owner = THIS_MODULE, 878 .owner = THIS_MODULE,
886 .llseek = default_llseek, 879 .llseek = default_llseek,
887}; 880};
diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
index 552adb3f80d0..d01403a263ff 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.c
+++ b/drivers/net/wireless/ath/ath6kl/debug.c
@@ -217,12 +217,6 @@ void dump_cred_dist_stats(struct htc_target *target)
217 target->credit_info->cur_free_credits); 217 target->credit_info->cur_free_credits);
218} 218}
219 219
220static int ath6kl_debugfs_open(struct inode *inode, struct file *file)
221{
222 file->private_data = inode->i_private;
223 return 0;
224}
225
226void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war) 220void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war)
227{ 221{
228 switch (war) { 222 switch (war) {
@@ -263,7 +257,7 @@ static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
263 257
264static const struct file_operations fops_war_stats = { 258static const struct file_operations fops_war_stats = {
265 .read = read_file_war_stats, 259 .read = read_file_war_stats,
266 .open = ath6kl_debugfs_open, 260 .open = simple_open,
267 .owner = THIS_MODULE, 261 .owner = THIS_MODULE,
268 .llseek = default_llseek, 262 .llseek = default_llseek,
269}; 263};
@@ -488,7 +482,7 @@ static ssize_t ath6kl_fwlog_mask_write(struct file *file,
488} 482}
489 483
490static const struct file_operations fops_fwlog_mask = { 484static const struct file_operations fops_fwlog_mask = {
491 .open = ath6kl_debugfs_open, 485 .open = simple_open,
492 .read = ath6kl_fwlog_mask_read, 486 .read = ath6kl_fwlog_mask_read,
493 .write = ath6kl_fwlog_mask_write, 487 .write = ath6kl_fwlog_mask_write,
494 .owner = THIS_MODULE, 488 .owner = THIS_MODULE,
@@ -634,7 +628,7 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
634 628
635static const struct file_operations fops_tgt_stats = { 629static const struct file_operations fops_tgt_stats = {
636 .read = read_file_tgt_stats, 630 .read = read_file_tgt_stats,
637 .open = ath6kl_debugfs_open, 631 .open = simple_open,
638 .owner = THIS_MODULE, 632 .owner = THIS_MODULE,
639 .llseek = default_llseek, 633 .llseek = default_llseek,
640}; 634};
@@ -699,7 +693,7 @@ static ssize_t read_file_credit_dist_stats(struct file *file,
699 693
700static const struct file_operations fops_credit_dist_stats = { 694static const struct file_operations fops_credit_dist_stats = {
701 .read = read_file_credit_dist_stats, 695 .read = read_file_credit_dist_stats,
702 .open = ath6kl_debugfs_open, 696 .open = simple_open,
703 .owner = THIS_MODULE, 697 .owner = THIS_MODULE,
704 .llseek = default_llseek, 698 .llseek = default_llseek,
705}; 699};
@@ -802,7 +796,7 @@ static ssize_t ath6kl_endpoint_stats_write(struct file *file,
802} 796}
803 797
804static const struct file_operations fops_endpoint_stats = { 798static const struct file_operations fops_endpoint_stats = {
805 .open = ath6kl_debugfs_open, 799 .open = simple_open,
806 .read = ath6kl_endpoint_stats_read, 800 .read = ath6kl_endpoint_stats_read,
807 .write = ath6kl_endpoint_stats_write, 801 .write = ath6kl_endpoint_stats_write,
808 .owner = THIS_MODULE, 802 .owner = THIS_MODULE,
@@ -875,7 +869,7 @@ static ssize_t ath6kl_regread_write(struct file *file,
875static const struct file_operations fops_diag_reg_read = { 869static const struct file_operations fops_diag_reg_read = {
876 .read = ath6kl_regread_read, 870 .read = ath6kl_regread_read,
877 .write = ath6kl_regread_write, 871 .write = ath6kl_regread_write,
878 .open = ath6kl_debugfs_open, 872 .open = simple_open,
879 .owner = THIS_MODULE, 873 .owner = THIS_MODULE,
880 .llseek = default_llseek, 874 .llseek = default_llseek,
881}; 875};
@@ -999,7 +993,7 @@ static ssize_t ath6kl_lrssi_roam_read(struct file *file,
999static const struct file_operations fops_lrssi_roam_threshold = { 993static const struct file_operations fops_lrssi_roam_threshold = {
1000 .read = ath6kl_lrssi_roam_read, 994 .read = ath6kl_lrssi_roam_read,
1001 .write = ath6kl_lrssi_roam_write, 995 .write = ath6kl_lrssi_roam_write,
1002 .open = ath6kl_debugfs_open, 996 .open = simple_open,
1003 .owner = THIS_MODULE, 997 .owner = THIS_MODULE,
1004 .llseek = default_llseek, 998 .llseek = default_llseek,
1005}; 999};
@@ -1061,7 +1055,7 @@ static ssize_t ath6kl_regwrite_write(struct file *file,
1061static const struct file_operations fops_diag_reg_write = { 1055static const struct file_operations fops_diag_reg_write = {
1062 .read = ath6kl_regwrite_read, 1056 .read = ath6kl_regwrite_read,
1063 .write = ath6kl_regwrite_write, 1057 .write = ath6kl_regwrite_write,
1064 .open = ath6kl_debugfs_open, 1058 .open = simple_open,
1065 .owner = THIS_MODULE, 1059 .owner = THIS_MODULE,
1066 .llseek = default_llseek, 1060 .llseek = default_llseek,
1067}; 1061};
@@ -1166,7 +1160,7 @@ static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
1166 1160
1167static const struct file_operations fops_roam_table = { 1161static const struct file_operations fops_roam_table = {
1168 .read = ath6kl_roam_table_read, 1162 .read = ath6kl_roam_table_read,
1169 .open = ath6kl_debugfs_open, 1163 .open = simple_open,
1170 .owner = THIS_MODULE, 1164 .owner = THIS_MODULE,
1171 .llseek = default_llseek, 1165 .llseek = default_llseek,
1172}; 1166};
@@ -1204,7 +1198,7 @@ static ssize_t ath6kl_force_roam_write(struct file *file,
1204 1198
1205static const struct file_operations fops_force_roam = { 1199static const struct file_operations fops_force_roam = {
1206 .write = ath6kl_force_roam_write, 1200 .write = ath6kl_force_roam_write,
1207 .open = ath6kl_debugfs_open, 1201 .open = simple_open,
1208 .owner = THIS_MODULE, 1202 .owner = THIS_MODULE,
1209 .llseek = default_llseek, 1203 .llseek = default_llseek,
1210}; 1204};
@@ -1244,7 +1238,7 @@ static ssize_t ath6kl_roam_mode_write(struct file *file,
1244 1238
1245static const struct file_operations fops_roam_mode = { 1239static const struct file_operations fops_roam_mode = {
1246 .write = ath6kl_roam_mode_write, 1240 .write = ath6kl_roam_mode_write,
1247 .open = ath6kl_debugfs_open, 1241 .open = simple_open,
1248 .owner = THIS_MODULE, 1242 .owner = THIS_MODULE,
1249 .llseek = default_llseek, 1243 .llseek = default_llseek,
1250}; 1244};
@@ -1286,7 +1280,7 @@ static ssize_t ath6kl_keepalive_write(struct file *file,
1286} 1280}
1287 1281
1288static const struct file_operations fops_keepalive = { 1282static const struct file_operations fops_keepalive = {
1289 .open = ath6kl_debugfs_open, 1283 .open = simple_open,
1290 .read = ath6kl_keepalive_read, 1284 .read = ath6kl_keepalive_read,
1291 .write = ath6kl_keepalive_write, 1285 .write = ath6kl_keepalive_write,
1292 .owner = THIS_MODULE, 1286 .owner = THIS_MODULE,
@@ -1331,7 +1325,7 @@ static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
1331} 1325}
1332 1326
1333static const struct file_operations fops_disconnect_timeout = { 1327static const struct file_operations fops_disconnect_timeout = {
1334 .open = ath6kl_debugfs_open, 1328 .open = simple_open,
1335 .read = ath6kl_disconnect_timeout_read, 1329 .read = ath6kl_disconnect_timeout_read,
1336 .write = ath6kl_disconnect_timeout_write, 1330 .write = ath6kl_disconnect_timeout_write,
1337 .owner = THIS_MODULE, 1331 .owner = THIS_MODULE,
@@ -1512,7 +1506,7 @@ static ssize_t ath6kl_create_qos_write(struct file *file,
1512 1506
1513static const struct file_operations fops_create_qos = { 1507static const struct file_operations fops_create_qos = {
1514 .write = ath6kl_create_qos_write, 1508 .write = ath6kl_create_qos_write,
1515 .open = ath6kl_debugfs_open, 1509 .open = simple_open,
1516 .owner = THIS_MODULE, 1510 .owner = THIS_MODULE,
1517 .llseek = default_llseek, 1511 .llseek = default_llseek,
1518}; 1512};
@@ -1560,7 +1554,7 @@ static ssize_t ath6kl_delete_qos_write(struct file *file,
1560 1554
1561static const struct file_operations fops_delete_qos = { 1555static const struct file_operations fops_delete_qos = {
1562 .write = ath6kl_delete_qos_write, 1556 .write = ath6kl_delete_qos_write,
1563 .open = ath6kl_debugfs_open, 1557 .open = simple_open,
1564 .owner = THIS_MODULE, 1558 .owner = THIS_MODULE,
1565 .llseek = default_llseek, 1559 .llseek = default_llseek,
1566}; 1560};
@@ -1593,7 +1587,7 @@ static ssize_t ath6kl_bgscan_int_write(struct file *file,
1593 1587
1594static const struct file_operations fops_bgscan_int = { 1588static const struct file_operations fops_bgscan_int = {
1595 .write = ath6kl_bgscan_int_write, 1589 .write = ath6kl_bgscan_int_write,
1596 .open = ath6kl_debugfs_open, 1590 .open = simple_open,
1597 .owner = THIS_MODULE, 1591 .owner = THIS_MODULE,
1598 .llseek = default_llseek, 1592 .llseek = default_llseek,
1599}; 1593};
@@ -1651,7 +1645,7 @@ static ssize_t ath6kl_listen_int_read(struct file *file,
1651static const struct file_operations fops_listen_int = { 1645static const struct file_operations fops_listen_int = {
1652 .read = ath6kl_listen_int_read, 1646 .read = ath6kl_listen_int_read,
1653 .write = ath6kl_listen_int_write, 1647 .write = ath6kl_listen_int_write,
1654 .open = ath6kl_debugfs_open, 1648 .open = simple_open,
1655 .owner = THIS_MODULE, 1649 .owner = THIS_MODULE,
1656 .llseek = default_llseek, 1650 .llseek = default_llseek,
1657}; 1651};
@@ -1711,7 +1705,7 @@ static ssize_t ath6kl_power_params_write(struct file *file,
1711 1705
1712static const struct file_operations fops_power_params = { 1706static const struct file_operations fops_power_params = {
1713 .write = ath6kl_power_params_write, 1707 .write = ath6kl_power_params_write,
1714 .open = ath6kl_debugfs_open, 1708 .open = simple_open,
1715 .owner = THIS_MODULE, 1709 .owner = THIS_MODULE,
1716 .llseek = default_llseek, 1710 .llseek = default_llseek,
1717}; 1711};
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 2f4b48e6fb03..e5cceb077574 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -20,7 +20,6 @@
20 20
21/* Common calibration code */ 21/* Common calibration code */
22 22
23#define ATH9K_NF_TOO_HIGH -60
24 23
25static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer) 24static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)
26{ 25{
@@ -346,10 +345,10 @@ static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
346 "NF calibrated [%s] [chain %d] is %d\n", 345 "NF calibrated [%s] [chain %d] is %d\n",
347 (i >= 3 ? "ext" : "ctl"), i % 3, nf[i]); 346 (i >= 3 ? "ext" : "ctl"), i % 3, nf[i]);
348 347
349 if (nf[i] > ATH9K_NF_TOO_HIGH) { 348 if (nf[i] > limit->max) {
350 ath_dbg(common, CALIBRATE, 349 ath_dbg(common, CALIBRATE,
351 "NF[%d] (%d) > MAX (%d), correcting to MAX\n", 350 "NF[%d] (%d) > MAX (%d), correcting to MAX\n",
352 i, nf[i], ATH9K_NF_TOO_HIGH); 351 i, nf[i], limit->max);
353 nf[i] = limit->max; 352 nf[i] = limit->max;
354 } else if (nf[i] < limit->min) { 353 } else if (nf[i] < limit->min) {
355 ath_dbg(common, CALIBRATE, 354 ath_dbg(common, CALIBRATE,
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 35d1c8e91d1c..ff47b32ecaf4 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -26,11 +26,6 @@
26#define REG_READ_D(_ah, _reg) \ 26#define REG_READ_D(_ah, _reg) \
27 ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) 27 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
28 28
29static int ath9k_debugfs_open(struct inode *inode, struct file *file)
30{
31 file->private_data = inode->i_private;
32 return 0;
33}
34 29
35static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, 30static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
36 size_t count, loff_t *ppos) 31 size_t count, loff_t *ppos)
@@ -83,7 +78,7 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
83static const struct file_operations fops_debug = { 78static const struct file_operations fops_debug = {
84 .read = read_file_debug, 79 .read = read_file_debug,
85 .write = write_file_debug, 80 .write = write_file_debug,
86 .open = ath9k_debugfs_open, 81 .open = simple_open,
87 .owner = THIS_MODULE, 82 .owner = THIS_MODULE,
88 .llseek = default_llseek, 83 .llseek = default_llseek,
89}; 84};
@@ -129,7 +124,7 @@ static ssize_t write_file_tx_chainmask(struct file *file, const char __user *use
129static const struct file_operations fops_tx_chainmask = { 124static const struct file_operations fops_tx_chainmask = {
130 .read = read_file_tx_chainmask, 125 .read = read_file_tx_chainmask,
131 .write = write_file_tx_chainmask, 126 .write = write_file_tx_chainmask,
132 .open = ath9k_debugfs_open, 127 .open = simple_open,
133 .owner = THIS_MODULE, 128 .owner = THIS_MODULE,
134 .llseek = default_llseek, 129 .llseek = default_llseek,
135}; 130};
@@ -172,7 +167,7 @@ static ssize_t write_file_rx_chainmask(struct file *file, const char __user *use
172static const struct file_operations fops_rx_chainmask = { 167static const struct file_operations fops_rx_chainmask = {
173 .read = read_file_rx_chainmask, 168 .read = read_file_rx_chainmask,
174 .write = write_file_rx_chainmask, 169 .write = write_file_rx_chainmask,
175 .open = ath9k_debugfs_open, 170 .open = simple_open,
176 .owner = THIS_MODULE, 171 .owner = THIS_MODULE,
177 .llseek = default_llseek, 172 .llseek = default_llseek,
178}; 173};
@@ -223,7 +218,7 @@ static ssize_t write_file_disable_ani(struct file *file,
223static const struct file_operations fops_disable_ani = { 218static const struct file_operations fops_disable_ani = {
224 .read = read_file_disable_ani, 219 .read = read_file_disable_ani,
225 .write = write_file_disable_ani, 220 .write = write_file_disable_ani,
226 .open = ath9k_debugfs_open, 221 .open = simple_open,
227 .owner = THIS_MODULE, 222 .owner = THIS_MODULE,
228 .llseek = default_llseek, 223 .llseek = default_llseek,
229}; 224};
@@ -324,7 +319,7 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
324 319
325static const struct file_operations fops_dma = { 320static const struct file_operations fops_dma = {
326 .read = read_file_dma, 321 .read = read_file_dma,
327 .open = ath9k_debugfs_open, 322 .open = simple_open,
328 .owner = THIS_MODULE, 323 .owner = THIS_MODULE,
329 .llseek = default_llseek, 324 .llseek = default_llseek,
330}; 325};
@@ -446,7 +441,7 @@ static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
446 441
447static const struct file_operations fops_interrupt = { 442static const struct file_operations fops_interrupt = {
448 .read = read_file_interrupt, 443 .read = read_file_interrupt,
449 .open = ath9k_debugfs_open, 444 .open = simple_open,
450 .owner = THIS_MODULE, 445 .owner = THIS_MODULE,
451 .llseek = default_llseek, 446 .llseek = default_llseek,
452}; 447};
@@ -852,28 +847,28 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
852 847
853static const struct file_operations fops_xmit = { 848static const struct file_operations fops_xmit = {
854 .read = read_file_xmit, 849 .read = read_file_xmit,
855 .open = ath9k_debugfs_open, 850 .open = simple_open,
856 .owner = THIS_MODULE, 851 .owner = THIS_MODULE,
857 .llseek = default_llseek, 852 .llseek = default_llseek,
858}; 853};
859 854
860static const struct file_operations fops_stations = { 855static const struct file_operations fops_stations = {
861 .read = read_file_stations, 856 .read = read_file_stations,
862 .open = ath9k_debugfs_open, 857 .open = simple_open,
863 .owner = THIS_MODULE, 858 .owner = THIS_MODULE,
864 .llseek = default_llseek, 859 .llseek = default_llseek,
865}; 860};
866 861
867static const struct file_operations fops_misc = { 862static const struct file_operations fops_misc = {
868 .read = read_file_misc, 863 .read = read_file_misc,
869 .open = ath9k_debugfs_open, 864 .open = simple_open,
870 .owner = THIS_MODULE, 865 .owner = THIS_MODULE,
871 .llseek = default_llseek, 866 .llseek = default_llseek,
872}; 867};
873 868
874static const struct file_operations fops_reset = { 869static const struct file_operations fops_reset = {
875 .read = read_file_reset, 870 .read = read_file_reset,
876 .open = ath9k_debugfs_open, 871 .open = simple_open,
877 .owner = THIS_MODULE, 872 .owner = THIS_MODULE,
878 .llseek = default_llseek, 873 .llseek = default_llseek,
879}; 874};
@@ -1016,7 +1011,7 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
1016 1011
1017static const struct file_operations fops_recv = { 1012static const struct file_operations fops_recv = {
1018 .read = read_file_recv, 1013 .read = read_file_recv,
1019 .open = ath9k_debugfs_open, 1014 .open = simple_open,
1020 .owner = THIS_MODULE, 1015 .owner = THIS_MODULE,
1021 .llseek = default_llseek, 1016 .llseek = default_llseek,
1022}; 1017};
@@ -1055,7 +1050,7 @@ static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
1055static const struct file_operations fops_regidx = { 1050static const struct file_operations fops_regidx = {
1056 .read = read_file_regidx, 1051 .read = read_file_regidx,
1057 .write = write_file_regidx, 1052 .write = write_file_regidx,
1058 .open = ath9k_debugfs_open, 1053 .open = simple_open,
1059 .owner = THIS_MODULE, 1054 .owner = THIS_MODULE,
1060 .llseek = default_llseek, 1055 .llseek = default_llseek,
1061}; 1056};
@@ -1102,7 +1097,7 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
1102static const struct file_operations fops_regval = { 1097static const struct file_operations fops_regval = {
1103 .read = read_file_regval, 1098 .read = read_file_regval,
1104 .write = write_file_regval, 1099 .write = write_file_regval,
1105 .open = ath9k_debugfs_open, 1100 .open = simple_open,
1106 .owner = THIS_MODULE, 1101 .owner = THIS_MODULE,
1107 .llseek = default_llseek, 1102 .llseek = default_llseek,
1108}; 1103};
@@ -1191,7 +1186,7 @@ static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
1191 1186
1192static const struct file_operations fops_dump_nfcal = { 1187static const struct file_operations fops_dump_nfcal = {
1193 .read = read_file_dump_nfcal, 1188 .read = read_file_dump_nfcal,
1194 .open = ath9k_debugfs_open, 1189 .open = simple_open,
1195 .owner = THIS_MODULE, 1190 .owner = THIS_MODULE,
1196 .llseek = default_llseek, 1191 .llseek = default_llseek,
1197}; 1192};
@@ -1219,7 +1214,7 @@ static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
1219 1214
1220static const struct file_operations fops_base_eeprom = { 1215static const struct file_operations fops_base_eeprom = {
1221 .read = read_file_base_eeprom, 1216 .read = read_file_base_eeprom,
1222 .open = ath9k_debugfs_open, 1217 .open = simple_open,
1223 .owner = THIS_MODULE, 1218 .owner = THIS_MODULE,
1224 .llseek = default_llseek, 1219 .llseek = default_llseek,
1225}; 1220};
@@ -1247,7 +1242,7 @@ static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
1247 1242
1248static const struct file_operations fops_modal_eeprom = { 1243static const struct file_operations fops_modal_eeprom = {
1249 .read = read_file_modal_eeprom, 1244 .read = read_file_modal_eeprom,
1250 .open = ath9k_debugfs_open, 1245 .open = simple_open,
1251 .owner = THIS_MODULE, 1246 .owner = THIS_MODULE,
1252 .llseek = default_llseek, 1247 .llseek = default_llseek,
1253}; 1248};
diff --git a/drivers/net/wireless/ath/ath9k/dfs_debug.c b/drivers/net/wireless/ath/ath9k/dfs_debug.c
index 106d031d834a..4364c103ed33 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_debug.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_debug.c
@@ -60,16 +60,9 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
60 return retval; 60 return retval;
61} 61}
62 62
63static int ath9k_dfs_debugfs_open(struct inode *inode, struct file *file)
64{
65 file->private_data = inode->i_private;
66
67 return 0;
68}
69
70static const struct file_operations fops_dfs_stats = { 63static const struct file_operations fops_dfs_stats = {
71 .read = read_file_dfs, 64 .read = read_file_dfs,
72 .open = ath9k_dfs_debugfs_open, 65 .open = simple_open,
73 .owner = THIS_MODULE, 66 .owner = THIS_MODULE,
74 .llseek = default_llseek, 67 .llseek = default_llseek,
75}; 68};
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
index d3ff33c71aa5..3035deb7a0cd 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
@@ -16,12 +16,6 @@
16 16
17#include "htc.h" 17#include "htc.h"
18 18
19static int ath9k_debugfs_open(struct inode *inode, struct file *file)
20{
21 file->private_data = inode->i_private;
22 return 0;
23}
24
25static ssize_t read_file_tgt_int_stats(struct file *file, char __user *user_buf, 19static ssize_t read_file_tgt_int_stats(struct file *file, char __user *user_buf,
26 size_t count, loff_t *ppos) 20 size_t count, loff_t *ppos)
27{ 21{
@@ -75,7 +69,7 @@ static ssize_t read_file_tgt_int_stats(struct file *file, char __user *user_buf,
75 69
76static const struct file_operations fops_tgt_int_stats = { 70static const struct file_operations fops_tgt_int_stats = {
77 .read = read_file_tgt_int_stats, 71 .read = read_file_tgt_int_stats,
78 .open = ath9k_debugfs_open, 72 .open = simple_open,
79 .owner = THIS_MODULE, 73 .owner = THIS_MODULE,
80 .llseek = default_llseek, 74 .llseek = default_llseek,
81}; 75};
@@ -145,7 +139,7 @@ static ssize_t read_file_tgt_tx_stats(struct file *file, char __user *user_buf,
145 139
146static const struct file_operations fops_tgt_tx_stats = { 140static const struct file_operations fops_tgt_tx_stats = {
147 .read = read_file_tgt_tx_stats, 141 .read = read_file_tgt_tx_stats,
148 .open = ath9k_debugfs_open, 142 .open = simple_open,
149 .owner = THIS_MODULE, 143 .owner = THIS_MODULE,
150 .llseek = default_llseek, 144 .llseek = default_llseek,
151}; 145};
@@ -191,7 +185,7 @@ static ssize_t read_file_tgt_rx_stats(struct file *file, char __user *user_buf,
191 185
192static const struct file_operations fops_tgt_rx_stats = { 186static const struct file_operations fops_tgt_rx_stats = {
193 .read = read_file_tgt_rx_stats, 187 .read = read_file_tgt_rx_stats,
194 .open = ath9k_debugfs_open, 188 .open = simple_open,
195 .owner = THIS_MODULE, 189 .owner = THIS_MODULE,
196 .llseek = default_llseek, 190 .llseek = default_llseek,
197}; 191};
@@ -243,7 +237,7 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
243 237
244static const struct file_operations fops_xmit = { 238static const struct file_operations fops_xmit = {
245 .read = read_file_xmit, 239 .read = read_file_xmit,
246 .open = ath9k_debugfs_open, 240 .open = simple_open,
247 .owner = THIS_MODULE, 241 .owner = THIS_MODULE,
248 .llseek = default_llseek, 242 .llseek = default_llseek,
249}; 243};
@@ -364,7 +358,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
364 358
365static const struct file_operations fops_recv = { 359static const struct file_operations fops_recv = {
366 .read = read_file_recv, 360 .read = read_file_recv,
367 .open = ath9k_debugfs_open, 361 .open = simple_open,
368 .owner = THIS_MODULE, 362 .owner = THIS_MODULE,
369 .llseek = default_llseek, 363 .llseek = default_llseek,
370}; 364};
@@ -399,7 +393,7 @@ static ssize_t read_file_slot(struct file *file, char __user *user_buf,
399 393
400static const struct file_operations fops_slot = { 394static const struct file_operations fops_slot = {
401 .read = read_file_slot, 395 .read = read_file_slot,
402 .open = ath9k_debugfs_open, 396 .open = simple_open,
403 .owner = THIS_MODULE, 397 .owner = THIS_MODULE,
404 .llseek = default_llseek, 398 .llseek = default_llseek,
405}; 399};
@@ -446,7 +440,7 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf,
446 440
447static const struct file_operations fops_queue = { 441static const struct file_operations fops_queue = {
448 .read = read_file_queue, 442 .read = read_file_queue,
449 .open = ath9k_debugfs_open, 443 .open = simple_open,
450 .owner = THIS_MODULE, 444 .owner = THIS_MODULE,
451 .llseek = default_llseek, 445 .llseek = default_llseek,
452}; 446};
@@ -487,7 +481,7 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
487static const struct file_operations fops_debug = { 481static const struct file_operations fops_debug = {
488 .read = read_file_debug, 482 .read = read_file_debug,
489 .write = write_file_debug, 483 .write = write_file_debug,
490 .open = ath9k_debugfs_open, 484 .open = simple_open,
491 .owner = THIS_MODULE, 485 .owner = THIS_MODULE,
492 .llseek = default_llseek, 486 .llseek = default_llseek,
493}; 487};
@@ -636,7 +630,7 @@ static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
636 630
637static const struct file_operations fops_base_eeprom = { 631static const struct file_operations fops_base_eeprom = {
638 .read = read_file_base_eeprom, 632 .read = read_file_base_eeprom,
639 .open = ath9k_debugfs_open, 633 .open = simple_open,
640 .owner = THIS_MODULE, 634 .owner = THIS_MODULE,
641 .llseek = default_llseek, 635 .llseek = default_llseek,
642}; 636};
@@ -917,7 +911,7 @@ static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
917 911
918static const struct file_operations fops_modal_eeprom = { 912static const struct file_operations fops_modal_eeprom = {
919 .read = read_file_modal_eeprom, 913 .read = read_file_modal_eeprom,
920 .open = ath9k_debugfs_open, 914 .open = simple_open,
921 .owner = THIS_MODULE, 915 .owner = THIS_MODULE,
922 .llseek = default_llseek, 916 .llseek = default_llseek,
923}; 917};
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 60159f4ee532..cb006458fc4b 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -680,7 +680,7 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
680 hw->queues = 4; 680 hw->queues = 4;
681 hw->max_rates = 4; 681 hw->max_rates = 4;
682 hw->channel_change_time = 5000; 682 hw->channel_change_time = 5000;
683 hw->max_listen_interval = 10; 683 hw->max_listen_interval = 1;
684 hw->max_rate_tries = 10; 684 hw->max_rate_tries = 10;
685 hw->sta_data_size = sizeof(struct ath_node); 685 hw->sta_data_size = sizeof(struct ath_node);
686 hw->vif_data_size = sizeof(struct ath_vif); 686 hw->vif_data_size = sizeof(struct ath_vif);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 38794850f005..215eb2536b1e 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -640,7 +640,7 @@ static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
640 an->sta = sta; 640 an->sta = sta;
641 an->vif = vif; 641 an->vif = vif;
642 642
643 if (sta->ht_cap.ht_supported) { 643 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
644 ath_tx_node_init(sc, an); 644 ath_tx_node_init(sc, an);
645 an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + 645 an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
646 sta->ht_cap.ampdu_factor); 646 sta->ht_cap.ampdu_factor);
@@ -659,7 +659,7 @@ static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
659 an->sta = NULL; 659 an->sta = NULL;
660#endif 660#endif
661 661
662 if (sta->ht_cap.ht_supported) 662 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
663 ath_tx_node_cleanup(sc, an); 663 ath_tx_node_cleanup(sc, an);
664} 664}
665 665
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 4f848493fece..08bb45532701 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -1480,12 +1480,6 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
1480 1480
1481#ifdef CONFIG_ATH9K_DEBUGFS 1481#ifdef CONFIG_ATH9K_DEBUGFS
1482 1482
1483static int ath9k_debugfs_open(struct inode *inode, struct file *file)
1484{
1485 file->private_data = inode->i_private;
1486 return 0;
1487}
1488
1489static ssize_t read_file_rcstat(struct file *file, char __user *user_buf, 1483static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
1490 size_t count, loff_t *ppos) 1484 size_t count, loff_t *ppos)
1491{ 1485{
@@ -1553,7 +1547,7 @@ static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
1553 1547
1554static const struct file_operations fops_rcstat = { 1548static const struct file_operations fops_rcstat = {
1555 .read = read_file_rcstat, 1549 .read = read_file_rcstat,
1556 .open = ath9k_debugfs_open, 1550 .open = simple_open,
1557 .owner = THIS_MODULE 1551 .owner = THIS_MODULE
1558}; 1552};
1559 1553
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index f4ae3ba994a8..1c4583c7ff7c 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1913,13 +1913,13 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1913 if (sc->rx.frag) { 1913 if (sc->rx.frag) {
1914 int space = skb->len - skb_tailroom(hdr_skb); 1914 int space = skb->len - skb_tailroom(hdr_skb);
1915 1915
1916 sc->rx.frag = NULL;
1917
1918 if (pskb_expand_head(hdr_skb, 0, space, GFP_ATOMIC) < 0) { 1916 if (pskb_expand_head(hdr_skb, 0, space, GFP_ATOMIC) < 0) {
1919 dev_kfree_skb(skb); 1917 dev_kfree_skb(skb);
1920 goto requeue_drop_frag; 1918 goto requeue_drop_frag;
1921 } 1919 }
1922 1920
1921 sc->rx.frag = NULL;
1922
1923 skb_copy_from_linear_data(skb, skb_put(hdr_skb, skb->len), 1923 skb_copy_from_linear_data(skb, skb_put(hdr_skb, skb->len),
1924 skb->len); 1924 skb->len);
1925 dev_kfree_skb_any(skb); 1925 dev_kfree_skb_any(skb);
diff --git a/drivers/net/wireless/ath/carl9170/debug.c b/drivers/net/wireless/ath/carl9170/debug.c
index 3c164226687f..93fe6003a493 100644
--- a/drivers/net/wireless/ath/carl9170/debug.c
+++ b/drivers/net/wireless/ath/carl9170/debug.c
@@ -48,11 +48,6 @@
48#define ADD(buf, off, max, fmt, args...) \ 48#define ADD(buf, off, max, fmt, args...) \
49 off += snprintf(&buf[off], max - off, fmt, ##args); 49 off += snprintf(&buf[off], max - off, fmt, ##args);
50 50
51static int carl9170_debugfs_open(struct inode *inode, struct file *file)
52{
53 file->private_data = inode->i_private;
54 return 0;
55}
56 51
57struct carl9170_debugfs_fops { 52struct carl9170_debugfs_fops {
58 unsigned int read_bufsize; 53 unsigned int read_bufsize;
@@ -178,7 +173,7 @@ static const struct carl9170_debugfs_fops carl_debugfs_##name ##_ops = {\
178 .attr = _attr, \ 173 .attr = _attr, \
179 .req_dev_state = _dstate, \ 174 .req_dev_state = _dstate, \
180 .fops = { \ 175 .fops = { \
181 .open = carl9170_debugfs_open, \ 176 .open = simple_open, \
182 .read = carl9170_debugfs_read, \ 177 .read = carl9170_debugfs_read, \
183 .write = carl9170_debugfs_write, \ 178 .write = carl9170_debugfs_write, \
184 .owner = THIS_MODULE \ 179 .owner = THIS_MODULE \
diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index e751fdee89b2..e807bd930647 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -500,12 +500,6 @@ out:
500 500
501#undef fappend 501#undef fappend
502 502
503static int b43_debugfs_open(struct inode *inode, struct file *file)
504{
505 file->private_data = inode->i_private;
506 return 0;
507}
508
509static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf, 503static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
510 size_t count, loff_t *ppos) 504 size_t count, loff_t *ppos)
511{ 505{
@@ -624,7 +618,7 @@ out_unlock:
624 .read = _read, \ 618 .read = _read, \
625 .write = _write, \ 619 .write = _write, \
626 .fops = { \ 620 .fops = { \
627 .open = b43_debugfs_open, \ 621 .open = simple_open, \
628 .read = b43_debugfs_read, \ 622 .read = b43_debugfs_read, \
629 .write = b43_debugfs_write, \ 623 .write = b43_debugfs_write, \
630 .llseek = generic_file_llseek, \ 624 .llseek = generic_file_llseek, \
diff --git a/drivers/net/wireless/b43legacy/debugfs.c b/drivers/net/wireless/b43legacy/debugfs.c
index 5e28ad0d6d17..1965edb765a2 100644
--- a/drivers/net/wireless/b43legacy/debugfs.c
+++ b/drivers/net/wireless/b43legacy/debugfs.c
@@ -197,12 +197,6 @@ static int restart_write_file(struct b43legacy_wldev *dev, const char *buf, size
197 197
198#undef fappend 198#undef fappend
199 199
200static int b43legacy_debugfs_open(struct inode *inode, struct file *file)
201{
202 file->private_data = inode->i_private;
203 return 0;
204}
205
206static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf, 200static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
207 size_t count, loff_t *ppos) 201 size_t count, loff_t *ppos)
208{ 202{
@@ -331,7 +325,7 @@ out_unlock:
331 .read = _read, \ 325 .read = _read, \
332 .write = _write, \ 326 .write = _write, \
333 .fops = { \ 327 .fops = { \
334 .open = b43legacy_debugfs_open, \ 328 .open = simple_open, \
335 .read = b43legacy_debugfs_read, \ 329 .read = b43legacy_debugfs_read, \
336 .write = b43legacy_debugfs_write, \ 330 .write = b43legacy_debugfs_write, \
337 .llseek = generic_file_llseek, \ 331 .llseek = generic_file_llseek, \
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 4fcdac63a300..2b022571a859 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -11507,9 +11507,9 @@ static int ipw_wdev_init(struct net_device *dev)
11507 rc = -ENOMEM; 11507 rc = -ENOMEM;
11508 goto out; 11508 goto out;
11509 } 11509 }
11510 /* translate geo->bg to a_band.channels */ 11510 /* translate geo->a to a_band.channels */
11511 for (i = 0; i < geo->a_channels; i++) { 11511 for (i = 0; i < geo->a_channels; i++) {
11512 a_band->channels[i].band = IEEE80211_BAND_2GHZ; 11512 a_band->channels[i].band = IEEE80211_BAND_5GHZ;
11513 a_band->channels[i].center_freq = geo->a[i].freq; 11513 a_band->channels[i].center_freq = geo->a[i].freq;
11514 a_band->channels[i].hw_value = geo->a[i].channel; 11514 a_band->channels[i].hw_value = geo->a[i].channel;
11515 a_band->channels[i].max_power = geo->a[i].max_power; 11515 a_band->channels[i].max_power = geo->a[i].max_power;
diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
index 0c1209390169..faec40467208 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -2673,8 +2673,6 @@ il3945_bg_restart(struct work_struct *data)
2673 2673
2674 if (test_and_clear_bit(S_FW_ERROR, &il->status)) { 2674 if (test_and_clear_bit(S_FW_ERROR, &il->status)) {
2675 mutex_lock(&il->mutex); 2675 mutex_lock(&il->mutex);
2676 /* FIXME: vif can be dereferenced */
2677 il->vif = NULL;
2678 il->is_open = 0; 2676 il->is_open = 0;
2679 mutex_unlock(&il->mutex); 2677 mutex_unlock(&il->mutex);
2680 il3945_down(il); 2678 il3945_down(il);
diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c
index 70bee1a4d876..4b10157d8686 100644
--- a/drivers/net/wireless/iwlegacy/3945-rs.c
+++ b/drivers/net/wireless/iwlegacy/3945-rs.c
@@ -821,12 +821,6 @@ out:
821} 821}
822 822
823#ifdef CONFIG_MAC80211_DEBUGFS 823#ifdef CONFIG_MAC80211_DEBUGFS
824static int
825il3945_open_file_generic(struct inode *inode, struct file *file)
826{
827 file->private_data = inode->i_private;
828 return 0;
829}
830 824
831static ssize_t 825static ssize_t
832il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, 826il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
@@ -862,7 +856,7 @@ il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
862 856
863static const struct file_operations rs_sta_dbgfs_stats_table_ops = { 857static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
864 .read = il3945_sta_dbgfs_stats_table_read, 858 .read = il3945_sta_dbgfs_stats_table_read,
865 .open = il3945_open_file_generic, 859 .open = simple_open,
866 .llseek = default_llseek, 860 .llseek = default_llseek,
867}; 861};
868 862
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index 17f1c6853182..c46275a92565 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -5652,8 +5652,6 @@ il4965_bg_restart(struct work_struct *data)
5652 5652
5653 if (test_and_clear_bit(S_FW_ERROR, &il->status)) { 5653 if (test_and_clear_bit(S_FW_ERROR, &il->status)) {
5654 mutex_lock(&il->mutex); 5654 mutex_lock(&il->mutex);
5655 /* FIXME: do we dereference vif without mutex locked ? */
5656 il->vif = NULL;
5657 il->is_open = 0; 5655 il->is_open = 0;
5658 5656
5659 __il4965_down(il); 5657 __il4965_down(il);
diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c
index d7e2856e41d3..11ab1247fae1 100644
--- a/drivers/net/wireless/iwlegacy/4965-rs.c
+++ b/drivers/net/wireless/iwlegacy/4965-rs.c
@@ -2518,12 +2518,6 @@ il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, void *il_sta)
2518} 2518}
2519 2519
2520#ifdef CONFIG_MAC80211_DEBUGFS 2520#ifdef CONFIG_MAC80211_DEBUGFS
2521static int
2522il4965_open_file_generic(struct inode *inode, struct file *file)
2523{
2524 file->private_data = inode->i_private;
2525 return 0;
2526}
2527 2521
2528static void 2522static void
2529il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) 2523il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx)
@@ -2695,7 +2689,7 @@ il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf,
2695static const struct file_operations rs_sta_dbgfs_scale_table_ops = { 2689static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
2696 .write = il4965_rs_sta_dbgfs_scale_table_write, 2690 .write = il4965_rs_sta_dbgfs_scale_table_write,
2697 .read = il4965_rs_sta_dbgfs_scale_table_read, 2691 .read = il4965_rs_sta_dbgfs_scale_table_read,
2698 .open = il4965_open_file_generic, 2692 .open = simple_open,
2699 .llseek = default_llseek, 2693 .llseek = default_llseek,
2700}; 2694};
2701 2695
@@ -2740,7 +2734,7 @@ il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
2740 2734
2741static const struct file_operations rs_sta_dbgfs_stats_table_ops = { 2735static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
2742 .read = il4965_rs_sta_dbgfs_stats_table_read, 2736 .read = il4965_rs_sta_dbgfs_stats_table_read,
2743 .open = il4965_open_file_generic, 2737 .open = simple_open,
2744 .llseek = default_llseek, 2738 .llseek = default_llseek,
2745}; 2739};
2746 2740
@@ -2768,7 +2762,7 @@ il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file,
2768 2762
2769static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { 2763static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
2770 .read = il4965_rs_sta_dbgfs_rate_scale_data_read, 2764 .read = il4965_rs_sta_dbgfs_rate_scale_data_read,
2771 .open = il4965_open_file_generic, 2765 .open = simple_open,
2772 .llseek = default_llseek, 2766 .llseek = default_llseek,
2773}; 2767};
2774 2768
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index e5ac04739bcc..eaf249452e51 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -4508,6 +4508,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
4508{ 4508{
4509 struct il_priv *il = hw->priv; 4509 struct il_priv *il = hw->priv;
4510 int err; 4510 int err;
4511 bool reset;
4511 4512
4512 mutex_lock(&il->mutex); 4513 mutex_lock(&il->mutex);
4513 D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); 4514 D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr);
@@ -4518,7 +4519,12 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
4518 goto out; 4519 goto out;
4519 } 4520 }
4520 4521
4521 if (il->vif) { 4522 /*
4523 * We do not support multiple virtual interfaces, but on hardware reset
4524 * we have to add the same interface again.
4525 */
4526 reset = (il->vif == vif);
4527 if (il->vif && !reset) {
4522 err = -EOPNOTSUPP; 4528 err = -EOPNOTSUPP;
4523 goto out; 4529 goto out;
4524 } 4530 }
@@ -4528,8 +4534,11 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
4528 4534
4529 err = il_set_mode(il); 4535 err = il_set_mode(il);
4530 if (err) { 4536 if (err) {
4531 il->vif = NULL; 4537 IL_WARN("Fail to set mode %d\n", vif->type);
4532 il->iw_mode = NL80211_IFTYPE_STATION; 4538 if (!reset) {
4539 il->vif = NULL;
4540 il->iw_mode = NL80211_IFTYPE_STATION;
4541 }
4533 } 4542 }
4534 4543
4535out: 4544out:
@@ -5279,9 +5288,9 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5279 D_MAC80211("BSSID %pM\n", bss_conf->bssid); 5288 D_MAC80211("BSSID %pM\n", bss_conf->bssid);
5280 5289
5281 /* 5290 /*
5282 * If there is currently a HW scan going on in the 5291 * If there is currently a HW scan going on in the background,
5283 * background then we need to cancel it else the RXON 5292 * then we need to cancel it, otherwise sometimes we are not
5284 * below/in post_associate will fail. 5293 * able to authenticate (FIXME: why ?)
5285 */ 5294 */
5286 if (il_scan_cancel_timeout(il, 100)) { 5295 if (il_scan_cancel_timeout(il, 100)) {
5287 D_MAC80211("leave - scan abort failed\n"); 5296 D_MAC80211("leave - scan abort failed\n");
@@ -5290,14 +5299,10 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5290 } 5299 }
5291 5300
5292 /* mac80211 only sets assoc when in STATION mode */ 5301 /* mac80211 only sets assoc when in STATION mode */
5293 if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { 5302 memcpy(il->staging.bssid_addr, bss_conf->bssid, ETH_ALEN);
5294 memcpy(il->staging.bssid_addr, bss_conf->bssid,
5295 ETH_ALEN);
5296 5303
5297 /* currently needed in a few places */ 5304 /* FIXME: currently needed in a few places */
5298 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); 5305 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN);
5299 } else
5300 il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
5301 } 5306 }
5302 5307
5303 /* 5308 /*
diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c
index 229849150aac..eff26501d60a 100644
--- a/drivers/net/wireless/iwlegacy/debug.c
+++ b/drivers/net/wireless/iwlegacy/debug.c
@@ -160,18 +160,12 @@ static ssize_t il_dbgfs_##name##_write(struct file *file, \
160 const char __user *user_buf, \ 160 const char __user *user_buf, \
161 size_t count, loff_t *ppos); 161 size_t count, loff_t *ppos);
162 162
163static int
164il_dbgfs_open_file_generic(struct inode *inode, struct file *file)
165{
166 file->private_data = inode->i_private;
167 return 0;
168}
169 163
170#define DEBUGFS_READ_FILE_OPS(name) \ 164#define DEBUGFS_READ_FILE_OPS(name) \
171 DEBUGFS_READ_FUNC(name); \ 165 DEBUGFS_READ_FUNC(name); \
172static const struct file_operations il_dbgfs_##name##_ops = { \ 166static const struct file_operations il_dbgfs_##name##_ops = { \
173 .read = il_dbgfs_##name##_read, \ 167 .read = il_dbgfs_##name##_read, \
174 .open = il_dbgfs_open_file_generic, \ 168 .open = simple_open, \
175 .llseek = generic_file_llseek, \ 169 .llseek = generic_file_llseek, \
176}; 170};
177 171
@@ -179,7 +173,7 @@ static const struct file_operations il_dbgfs_##name##_ops = { \
179 DEBUGFS_WRITE_FUNC(name); \ 173 DEBUGFS_WRITE_FUNC(name); \
180static const struct file_operations il_dbgfs_##name##_ops = { \ 174static const struct file_operations il_dbgfs_##name##_ops = { \
181 .write = il_dbgfs_##name##_write, \ 175 .write = il_dbgfs_##name##_write, \
182 .open = il_dbgfs_open_file_generic, \ 176 .open = simple_open, \
183 .llseek = generic_file_llseek, \ 177 .llseek = generic_file_llseek, \
184}; 178};
185 179
@@ -189,7 +183,7 @@ static const struct file_operations il_dbgfs_##name##_ops = { \
189static const struct file_operations il_dbgfs_##name##_ops = { \ 183static const struct file_operations il_dbgfs_##name##_ops = { \
190 .write = il_dbgfs_##name##_write, \ 184 .write = il_dbgfs_##name##_write, \
191 .read = il_dbgfs_##name##_read, \ 185 .read = il_dbgfs_##name##_read, \
192 .open = il_dbgfs_open_file_generic, \ 186 .open = simple_open, \
193 .llseek = generic_file_llseek, \ 187 .llseek = generic_file_llseek, \
194}; 188};
195 189
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 53f8c51cfcdb..7e590b349dd7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -3083,11 +3083,6 @@ static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
3083} 3083}
3084 3084
3085#ifdef CONFIG_MAC80211_DEBUGFS 3085#ifdef CONFIG_MAC80211_DEBUGFS
3086static int open_file_generic(struct inode *inode, struct file *file)
3087{
3088 file->private_data = inode->i_private;
3089 return 0;
3090}
3091static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, 3086static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta,
3092 u32 *rate_n_flags, int index) 3087 u32 *rate_n_flags, int index)
3093{ 3088{
@@ -3226,7 +3221,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
3226static const struct file_operations rs_sta_dbgfs_scale_table_ops = { 3221static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
3227 .write = rs_sta_dbgfs_scale_table_write, 3222 .write = rs_sta_dbgfs_scale_table_write,
3228 .read = rs_sta_dbgfs_scale_table_read, 3223 .read = rs_sta_dbgfs_scale_table_read,
3229 .open = open_file_generic, 3224 .open = simple_open,
3230 .llseek = default_llseek, 3225 .llseek = default_llseek,
3231}; 3226};
3232static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file, 3227static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
@@ -3269,7 +3264,7 @@ static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
3269 3264
3270static const struct file_operations rs_sta_dbgfs_stats_table_ops = { 3265static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
3271 .read = rs_sta_dbgfs_stats_table_read, 3266 .read = rs_sta_dbgfs_stats_table_read,
3272 .open = open_file_generic, 3267 .open = simple_open,
3273 .llseek = default_llseek, 3268 .llseek = default_llseek,
3274}; 3269};
3275 3270
@@ -3295,7 +3290,7 @@ static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
3295 3290
3296static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { 3291static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
3297 .read = rs_sta_dbgfs_rate_scale_data_read, 3292 .read = rs_sta_dbgfs_rate_scale_data_read,
3298 .open = open_file_generic, 3293 .open = simple_open,
3299 .llseek = default_llseek, 3294 .llseek = default_llseek,
3300}; 3295};
3301 3296
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index b7b1c04f2fba..2bbaebd99ad4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -84,17 +84,11 @@ static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
84 size_t count, loff_t *ppos); 84 size_t count, loff_t *ppos);
85 85
86 86
87static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
88{
89 file->private_data = inode->i_private;
90 return 0;
91}
92
93#define DEBUGFS_READ_FILE_OPS(name) \ 87#define DEBUGFS_READ_FILE_OPS(name) \
94 DEBUGFS_READ_FUNC(name); \ 88 DEBUGFS_READ_FUNC(name); \
95static const struct file_operations iwl_dbgfs_##name##_ops = { \ 89static const struct file_operations iwl_dbgfs_##name##_ops = { \
96 .read = iwl_dbgfs_##name##_read, \ 90 .read = iwl_dbgfs_##name##_read, \
97 .open = iwl_dbgfs_open_file_generic, \ 91 .open = simple_open, \
98 .llseek = generic_file_llseek, \ 92 .llseek = generic_file_llseek, \
99}; 93};
100 94
@@ -102,7 +96,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
102 DEBUGFS_WRITE_FUNC(name); \ 96 DEBUGFS_WRITE_FUNC(name); \
103static const struct file_operations iwl_dbgfs_##name##_ops = { \ 97static const struct file_operations iwl_dbgfs_##name##_ops = { \
104 .write = iwl_dbgfs_##name##_write, \ 98 .write = iwl_dbgfs_##name##_write, \
105 .open = iwl_dbgfs_open_file_generic, \ 99 .open = simple_open, \
106 .llseek = generic_file_llseek, \ 100 .llseek = generic_file_llseek, \
107}; 101};
108 102
@@ -113,7 +107,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
113static const struct file_operations iwl_dbgfs_##name##_ops = { \ 107static const struct file_operations iwl_dbgfs_##name##_ops = { \
114 .write = iwl_dbgfs_##name##_write, \ 108 .write = iwl_dbgfs_##name##_write, \
115 .read = iwl_dbgfs_##name##_read, \ 109 .read = iwl_dbgfs_##name##_read, \
116 .open = iwl_dbgfs_open_file_generic, \ 110 .open = simple_open, \
117 .llseek = generic_file_llseek, \ 111 .llseek = generic_file_llseek, \
118}; 112};
119 113
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
index b4f796c82e1e..4d7b30d3e648 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -1898,17 +1898,11 @@ static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
1898 size_t count, loff_t *ppos); 1898 size_t count, loff_t *ppos);
1899 1899
1900 1900
1901static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
1902{
1903 file->private_data = inode->i_private;
1904 return 0;
1905}
1906
1907#define DEBUGFS_READ_FILE_OPS(name) \ 1901#define DEBUGFS_READ_FILE_OPS(name) \
1908 DEBUGFS_READ_FUNC(name); \ 1902 DEBUGFS_READ_FUNC(name); \
1909static const struct file_operations iwl_dbgfs_##name##_ops = { \ 1903static const struct file_operations iwl_dbgfs_##name##_ops = { \
1910 .read = iwl_dbgfs_##name##_read, \ 1904 .read = iwl_dbgfs_##name##_read, \
1911 .open = iwl_dbgfs_open_file_generic, \ 1905 .open = simple_open, \
1912 .llseek = generic_file_llseek, \ 1906 .llseek = generic_file_llseek, \
1913}; 1907};
1914 1908
@@ -1916,7 +1910,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
1916 DEBUGFS_WRITE_FUNC(name); \ 1910 DEBUGFS_WRITE_FUNC(name); \
1917static const struct file_operations iwl_dbgfs_##name##_ops = { \ 1911static const struct file_operations iwl_dbgfs_##name##_ops = { \
1918 .write = iwl_dbgfs_##name##_write, \ 1912 .write = iwl_dbgfs_##name##_write, \
1919 .open = iwl_dbgfs_open_file_generic, \ 1913 .open = simple_open, \
1920 .llseek = generic_file_llseek, \ 1914 .llseek = generic_file_llseek, \
1921}; 1915};
1922 1916
@@ -1926,7 +1920,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
1926static const struct file_operations iwl_dbgfs_##name##_ops = { \ 1920static const struct file_operations iwl_dbgfs_##name##_ops = { \
1927 .write = iwl_dbgfs_##name##_write, \ 1921 .write = iwl_dbgfs_##name##_write, \
1928 .read = iwl_dbgfs_##name##_read, \ 1922 .read = iwl_dbgfs_##name##_read, \
1929 .open = iwl_dbgfs_open_file_generic, \ 1923 .open = simple_open, \
1930 .llseek = generic_file_llseek, \ 1924 .llseek = generic_file_llseek, \
1931}; 1925};
1932 1926
diff --git a/drivers/net/wireless/iwmc3200wifi/debugfs.c b/drivers/net/wireless/iwmc3200wifi/debugfs.c
index 87eef5773a02..b6199d124bb9 100644
--- a/drivers/net/wireless/iwmc3200wifi/debugfs.c
+++ b/drivers/net/wireless/iwmc3200wifi/debugfs.c
@@ -99,12 +99,6 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_iwm_dbg_modules,
99 iwm_debugfs_u32_read, iwm_debugfs_dbg_modules_write, 99 iwm_debugfs_u32_read, iwm_debugfs_dbg_modules_write,
100 "%llu\n"); 100 "%llu\n");
101 101
102static int iwm_generic_open(struct inode *inode, struct file *filp)
103{
104 filp->private_data = inode->i_private;
105 return 0;
106}
107
108 102
109static ssize_t iwm_debugfs_txq_read(struct file *filp, char __user *buffer, 103static ssize_t iwm_debugfs_txq_read(struct file *filp, char __user *buffer,
110 size_t count, loff_t *ppos) 104 size_t count, loff_t *ppos)
@@ -401,28 +395,28 @@ out:
401 395
402static const struct file_operations iwm_debugfs_txq_fops = { 396static const struct file_operations iwm_debugfs_txq_fops = {
403 .owner = THIS_MODULE, 397 .owner = THIS_MODULE,
404 .open = iwm_generic_open, 398 .open = simple_open,
405 .read = iwm_debugfs_txq_read, 399 .read = iwm_debugfs_txq_read,
406 .llseek = default_llseek, 400 .llseek = default_llseek,
407}; 401};
408 402
409static const struct file_operations iwm_debugfs_tx_credit_fops = { 403static const struct file_operations iwm_debugfs_tx_credit_fops = {
410 .owner = THIS_MODULE, 404 .owner = THIS_MODULE,
411 .open = iwm_generic_open, 405 .open = simple_open,
412 .read = iwm_debugfs_tx_credit_read, 406 .read = iwm_debugfs_tx_credit_read,
413 .llseek = default_llseek, 407 .llseek = default_llseek,
414}; 408};
415 409
416static const struct file_operations iwm_debugfs_rx_ticket_fops = { 410static const struct file_operations iwm_debugfs_rx_ticket_fops = {
417 .owner = THIS_MODULE, 411 .owner = THIS_MODULE,
418 .open = iwm_generic_open, 412 .open = simple_open,
419 .read = iwm_debugfs_rx_ticket_read, 413 .read = iwm_debugfs_rx_ticket_read,
420 .llseek = default_llseek, 414 .llseek = default_llseek,
421}; 415};
422 416
423static const struct file_operations iwm_debugfs_fw_err_fops = { 417static const struct file_operations iwm_debugfs_fw_err_fops = {
424 .owner = THIS_MODULE, 418 .owner = THIS_MODULE,
425 .open = iwm_generic_open, 419 .open = simple_open,
426 .read = iwm_debugfs_fw_err_read, 420 .read = iwm_debugfs_fw_err_read,
427 .llseek = default_llseek, 421 .llseek = default_llseek,
428}; 422};
diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.c b/drivers/net/wireless/iwmc3200wifi/sdio.c
index 764b40dd24ad..0042f204b07f 100644
--- a/drivers/net/wireless/iwmc3200wifi/sdio.c
+++ b/drivers/net/wireless/iwmc3200wifi/sdio.c
@@ -264,13 +264,6 @@ static int if_sdio_send_chunk(struct iwm_priv *iwm, u8 *buf, int count)
264 return ret; 264 return ret;
265} 265}
266 266
267/* debugfs hooks */
268static int iwm_debugfs_sdio_open(struct inode *inode, struct file *filp)
269{
270 filp->private_data = inode->i_private;
271 return 0;
272}
273
274static ssize_t iwm_debugfs_sdio_read(struct file *filp, char __user *buffer, 267static ssize_t iwm_debugfs_sdio_read(struct file *filp, char __user *buffer,
275 size_t count, loff_t *ppos) 268 size_t count, loff_t *ppos)
276{ 269{
@@ -363,7 +356,7 @@ err:
363 356
364static const struct file_operations iwm_debugfs_sdio_fops = { 357static const struct file_operations iwm_debugfs_sdio_fops = {
365 .owner = THIS_MODULE, 358 .owner = THIS_MODULE,
366 .open = iwm_debugfs_sdio_open, 359 .open = simple_open,
367 .read = iwm_debugfs_sdio_read, 360 .read = iwm_debugfs_sdio_read,
368 .llseek = default_llseek, 361 .llseek = default_llseek,
369}; 362};
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index c192671610fc..a06cc283e23d 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -21,12 +21,6 @@ static char *szStates[] = {
21static void lbs_debug_init(struct lbs_private *priv); 21static void lbs_debug_init(struct lbs_private *priv);
22#endif 22#endif
23 23
24static int open_file_generic(struct inode *inode, struct file *file)
25{
26 file->private_data = inode->i_private;
27 return 0;
28}
29
30static ssize_t write_file_dummy(struct file *file, const char __user *buf, 24static ssize_t write_file_dummy(struct file *file, const char __user *buf,
31 size_t count, loff_t *ppos) 25 size_t count, loff_t *ppos)
32{ 26{
@@ -696,7 +690,7 @@ out_unlock:
696 690
697#define FOPS(fread, fwrite) { \ 691#define FOPS(fread, fwrite) { \
698 .owner = THIS_MODULE, \ 692 .owner = THIS_MODULE, \
699 .open = open_file_generic, \ 693 .open = simple_open, \
700 .read = (fread), \ 694 .read = (fread), \
701 .write = (fwrite), \ 695 .write = (fwrite), \
702 .llseek = generic_file_llseek, \ 696 .llseek = generic_file_llseek, \
@@ -962,7 +956,7 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
962 956
963static const struct file_operations lbs_debug_fops = { 957static const struct file_operations lbs_debug_fops = {
964 .owner = THIS_MODULE, 958 .owner = THIS_MODULE,
965 .open = open_file_generic, 959 .open = simple_open,
966 .write = lbs_debugfs_write, 960 .write = lbs_debugfs_write,
967 .read = lbs_debugfs_read, 961 .read = lbs_debugfs_read,
968 .llseek = default_llseek, 962 .llseek = default_llseek,
diff --git a/drivers/net/wireless/mwifiex/debugfs.c b/drivers/net/wireless/mwifiex/debugfs.c
index d26a78b6b3c4..1a845074c52a 100644
--- a/drivers/net/wireless/mwifiex/debugfs.c
+++ b/drivers/net/wireless/mwifiex/debugfs.c
@@ -140,18 +140,6 @@ static struct mwifiex_debug_data items[] = {
140static int num_of_items = ARRAY_SIZE(items); 140static int num_of_items = ARRAY_SIZE(items);
141 141
142/* 142/*
143 * Generic proc file open handler.
144 *
145 * This function is called every time a file is accessed for read or write.
146 */
147static int
148mwifiex_open_generic(struct inode *inode, struct file *file)
149{
150 file->private_data = inode->i_private;
151 return 0;
152}
153
154/*
155 * Proc info file read handler. 143 * Proc info file read handler.
156 * 144 *
157 * This function is called when the 'info' file is opened for reading. 145 * This function is called when the 'info' file is opened for reading.
@@ -676,19 +664,19 @@ done:
676static const struct file_operations mwifiex_dfs_##name##_fops = { \ 664static const struct file_operations mwifiex_dfs_##name##_fops = { \
677 .read = mwifiex_##name##_read, \ 665 .read = mwifiex_##name##_read, \
678 .write = mwifiex_##name##_write, \ 666 .write = mwifiex_##name##_write, \
679 .open = mwifiex_open_generic, \ 667 .open = simple_open, \
680}; 668};
681 669
682#define MWIFIEX_DFS_FILE_READ_OPS(name) \ 670#define MWIFIEX_DFS_FILE_READ_OPS(name) \
683static const struct file_operations mwifiex_dfs_##name##_fops = { \ 671static const struct file_operations mwifiex_dfs_##name##_fops = { \
684 .read = mwifiex_##name##_read, \ 672 .read = mwifiex_##name##_read, \
685 .open = mwifiex_open_generic, \ 673 .open = simple_open, \
686}; 674};
687 675
688#define MWIFIEX_DFS_FILE_WRITE_OPS(name) \ 676#define MWIFIEX_DFS_FILE_WRITE_OPS(name) \
689static const struct file_operations mwifiex_dfs_##name##_fops = { \ 677static const struct file_operations mwifiex_dfs_##name##_fops = { \
690 .write = mwifiex_##name##_write, \ 678 .write = mwifiex_##name##_write, \
691 .open = mwifiex_open_generic, \ 679 .open = simple_open, \
692}; 680};
693 681
694 682
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index dd6c64ac406e..88e3ad2d1db8 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -1336,6 +1336,10 @@ static void qbuf_scan(struct orinoco_private *priv, void *buf,
1336 unsigned long flags; 1336 unsigned long flags;
1337 1337
1338 sd = kmalloc(sizeof(*sd), GFP_ATOMIC); 1338 sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
1339 if (!sd) {
1340 printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
1341 return;
1342 }
1339 sd->buf = buf; 1343 sd->buf = buf;
1340 sd->len = len; 1344 sd->len = len;
1341 sd->type = type; 1345 sd->type = type;
@@ -1353,6 +1357,10 @@ static void qabort_scan(struct orinoco_private *priv)
1353 unsigned long flags; 1357 unsigned long flags;
1354 1358
1355 sd = kmalloc(sizeof(*sd), GFP_ATOMIC); 1359 sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
1360 if (!sd) {
1361 printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
1362 return;
1363 }
1356 sd->len = -1; /* Abort */ 1364 sd->len = -1; /* Abort */
1357 1365
1358 spin_lock_irqsave(&priv->scan_lock, flags); 1366 spin_lock_irqsave(&priv->scan_lock, flags);
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index cd490abced91..001735f7a661 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -163,7 +163,13 @@ static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
163 163
164 /* Reschedule urb to read TX status again instantly */ 164 /* Reschedule urb to read TX status again instantly */
165 return true; 165 return true;
166 } else if (rt2800usb_txstatus_pending(rt2x00dev)) { 166 }
167
168 /* Check if there is any entry that timedout waiting on TX status */
169 if (rt2800usb_txstatus_timeout(rt2x00dev))
170 queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
171
172 if (rt2800usb_txstatus_pending(rt2x00dev)) {
167 /* Read register after 250 us */ 173 /* Read register after 250 us */
168 hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 250000), 174 hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 250000),
169 HRTIMER_MODE_REL); 175 HRTIMER_MODE_REL);
@@ -178,7 +184,7 @@ stop_reading:
178 * here again if status reading is needed. 184 * here again if status reading is needed.
179 */ 185 */
180 if (rt2800usb_txstatus_pending(rt2x00dev) && 186 if (rt2800usb_txstatus_pending(rt2x00dev) &&
181 test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags)) 187 !test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags))
182 return true; 188 return true;
183 else 189 else
184 return false; 190 return false;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
index 1eec3a06d1f3..4c016241f340 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
@@ -1893,7 +1893,7 @@ void rtl92c_phy_set_io(struct ieee80211_hw *hw)
1893 break; 1893 break;
1894 case IO_CMD_PAUSE_DM_BY_SCAN: 1894 case IO_CMD_PAUSE_DM_BY_SCAN:
1895 rtlphy->initgain_backup.xaagccore1 = dm_digtable.cur_igvalue; 1895 rtlphy->initgain_backup.xaagccore1 = dm_digtable.cur_igvalue;
1896 dm_digtable.cur_igvalue = 0x17; 1896 dm_digtable.cur_igvalue = 0x37;
1897 rtl92c_dm_write_dig(hw); 1897 rtl92c_dm_write_dig(hw);
1898 break; 1898 break;
1899 default: 1899 default:
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
index 34591eeb8376..28fc5fb8057b 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
@@ -3077,7 +3077,7 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw)
3077 break; 3077 break;
3078 case IO_CMD_PAUSE_DM_BY_SCAN: 3078 case IO_CMD_PAUSE_DM_BY_SCAN:
3079 rtlphy->initgain_backup.xaagccore1 = de_digtable.cur_igvalue; 3079 rtlphy->initgain_backup.xaagccore1 = de_digtable.cur_igvalue;
3080 de_digtable.cur_igvalue = 0x17; 3080 de_digtable.cur_igvalue = 0x37;
3081 rtl92d_dm_write_dig(hw); 3081 rtl92d_dm_write_dig(hw);
3082 break; 3082 break;
3083 default: 3083 default:
diff --git a/drivers/net/wireless/wl1251/debugfs.c b/drivers/net/wireless/wl1251/debugfs.c
index 6c274007d200..448da1f8c22f 100644
--- a/drivers/net/wireless/wl1251/debugfs.c
+++ b/drivers/net/wireless/wl1251/debugfs.c
@@ -47,7 +47,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \
47 \ 47 \
48static const struct file_operations name## _ops = { \ 48static const struct file_operations name## _ops = { \
49 .read = name## _read, \ 49 .read = name## _read, \
50 .open = wl1251_open_file_generic, \ 50 .open = simple_open, \
51 .llseek = generic_file_llseek, \ 51 .llseek = generic_file_llseek, \
52}; 52};
53 53
@@ -84,7 +84,7 @@ static ssize_t sub## _ ##name## _read(struct file *file, \
84 \ 84 \
85static const struct file_operations sub## _ ##name## _ops = { \ 85static const struct file_operations sub## _ ##name## _ops = { \
86 .read = sub## _ ##name## _read, \ 86 .read = sub## _ ##name## _read, \
87 .open = wl1251_open_file_generic, \ 87 .open = simple_open, \
88 .llseek = generic_file_llseek, \ 88 .llseek = generic_file_llseek, \
89}; 89};
90 90
@@ -117,12 +117,6 @@ out:
117 mutex_unlock(&wl->mutex); 117 mutex_unlock(&wl->mutex);
118} 118}
119 119
120static int wl1251_open_file_generic(struct inode *inode, struct file *file)
121{
122 file->private_data = inode->i_private;
123 return 0;
124}
125
126DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u"); 120DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u");
127 121
128DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u"); 122DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u");
@@ -235,7 +229,7 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
235 229
236static const struct file_operations tx_queue_len_ops = { 230static const struct file_operations tx_queue_len_ops = {
237 .read = tx_queue_len_read, 231 .read = tx_queue_len_read,
238 .open = wl1251_open_file_generic, 232 .open = simple_open,
239 .llseek = generic_file_llseek, 233 .llseek = generic_file_llseek,
240}; 234};
241 235
@@ -257,7 +251,7 @@ static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
257 251
258static const struct file_operations tx_queue_status_ops = { 252static const struct file_operations tx_queue_status_ops = {
259 .read = tx_queue_status_read, 253 .read = tx_queue_status_read,
260 .open = wl1251_open_file_generic, 254 .open = simple_open,
261 .llseek = generic_file_llseek, 255 .llseek = generic_file_llseek,
262}; 256};
263 257
diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c
index e1cf72765965..564d49575c94 100644
--- a/drivers/net/wireless/wl12xx/debugfs.c
+++ b/drivers/net/wireless/wl12xx/debugfs.c
@@ -63,7 +63,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \
63 \ 63 \
64static const struct file_operations name## _ops = { \ 64static const struct file_operations name## _ops = { \
65 .read = name## _read, \ 65 .read = name## _read, \
66 .open = wl1271_open_file_generic, \ 66 .open = simple_open, \
67 .llseek = generic_file_llseek, \ 67 .llseek = generic_file_llseek, \
68}; 68};
69 69
@@ -96,7 +96,7 @@ static ssize_t sub## _ ##name## _read(struct file *file, \
96 \ 96 \
97static const struct file_operations sub## _ ##name## _ops = { \ 97static const struct file_operations sub## _ ##name## _ops = { \
98 .read = sub## _ ##name## _read, \ 98 .read = sub## _ ##name## _read, \
99 .open = wl1271_open_file_generic, \ 99 .open = simple_open, \
100 .llseek = generic_file_llseek, \ 100 .llseek = generic_file_llseek, \
101}; 101};
102 102
@@ -126,12 +126,6 @@ out:
126 mutex_unlock(&wl->mutex); 126 mutex_unlock(&wl->mutex);
127} 127}
128 128
129static int wl1271_open_file_generic(struct inode *inode, struct file *file)
130{
131 file->private_data = inode->i_private;
132 return 0;
133}
134
135DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u"); 129DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u");
136 130
137DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u"); 131DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u");
@@ -243,7 +237,7 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
243 237
244static const struct file_operations tx_queue_len_ops = { 238static const struct file_operations tx_queue_len_ops = {
245 .read = tx_queue_len_read, 239 .read = tx_queue_len_read,
246 .open = wl1271_open_file_generic, 240 .open = simple_open,
247 .llseek = default_llseek, 241 .llseek = default_llseek,
248}; 242};
249 243
@@ -289,7 +283,7 @@ static ssize_t gpio_power_write(struct file *file,
289static const struct file_operations gpio_power_ops = { 283static const struct file_operations gpio_power_ops = {
290 .read = gpio_power_read, 284 .read = gpio_power_read,
291 .write = gpio_power_write, 285 .write = gpio_power_write,
292 .open = wl1271_open_file_generic, 286 .open = simple_open,
293 .llseek = default_llseek, 287 .llseek = default_llseek,
294}; 288};
295 289
@@ -308,7 +302,7 @@ static ssize_t start_recovery_write(struct file *file,
308 302
309static const struct file_operations start_recovery_ops = { 303static const struct file_operations start_recovery_ops = {
310 .write = start_recovery_write, 304 .write = start_recovery_write,
311 .open = wl1271_open_file_generic, 305 .open = simple_open,
312 .llseek = default_llseek, 306 .llseek = default_llseek,
313}; 307};
314 308
@@ -372,7 +366,7 @@ out:
372static const struct file_operations dynamic_ps_timeout_ops = { 366static const struct file_operations dynamic_ps_timeout_ops = {
373 .read = dynamic_ps_timeout_read, 367 .read = dynamic_ps_timeout_read,
374 .write = dynamic_ps_timeout_write, 368 .write = dynamic_ps_timeout_write,
375 .open = wl1271_open_file_generic, 369 .open = simple_open,
376 .llseek = default_llseek, 370 .llseek = default_llseek,
377}; 371};
378 372
@@ -441,7 +435,7 @@ out:
441static const struct file_operations forced_ps_ops = { 435static const struct file_operations forced_ps_ops = {
442 .read = forced_ps_read, 436 .read = forced_ps_read,
443 .write = forced_ps_write, 437 .write = forced_ps_write,
444 .open = wl1271_open_file_generic, 438 .open = simple_open,
445 .llseek = default_llseek, 439 .llseek = default_llseek,
446}; 440};
447 441
@@ -483,7 +477,7 @@ static ssize_t split_scan_timeout_write(struct file *file,
483static const struct file_operations split_scan_timeout_ops = { 477static const struct file_operations split_scan_timeout_ops = {
484 .read = split_scan_timeout_read, 478 .read = split_scan_timeout_read,
485 .write = split_scan_timeout_write, 479 .write = split_scan_timeout_write,
486 .open = wl1271_open_file_generic, 480 .open = simple_open,
487 .llseek = default_llseek, 481 .llseek = default_llseek,
488}; 482};
489 483
@@ -566,7 +560,7 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
566 560
567static const struct file_operations driver_state_ops = { 561static const struct file_operations driver_state_ops = {
568 .read = driver_state_read, 562 .read = driver_state_read,
569 .open = wl1271_open_file_generic, 563 .open = simple_open,
570 .llseek = default_llseek, 564 .llseek = default_llseek,
571}; 565};
572 566
@@ -675,7 +669,7 @@ static ssize_t vifs_state_read(struct file *file, char __user *user_buf,
675 669
676static const struct file_operations vifs_state_ops = { 670static const struct file_operations vifs_state_ops = {
677 .read = vifs_state_read, 671 .read = vifs_state_read,
678 .open = wl1271_open_file_generic, 672 .open = simple_open,
679 .llseek = default_llseek, 673 .llseek = default_llseek,
680}; 674};
681 675
@@ -733,7 +727,7 @@ static ssize_t dtim_interval_write(struct file *file,
733static const struct file_operations dtim_interval_ops = { 727static const struct file_operations dtim_interval_ops = {
734 .read = dtim_interval_read, 728 .read = dtim_interval_read,
735 .write = dtim_interval_write, 729 .write = dtim_interval_write,
736 .open = wl1271_open_file_generic, 730 .open = simple_open,
737 .llseek = default_llseek, 731 .llseek = default_llseek,
738}; 732};
739 733
@@ -791,7 +785,7 @@ static ssize_t suspend_dtim_interval_write(struct file *file,
791static const struct file_operations suspend_dtim_interval_ops = { 785static const struct file_operations suspend_dtim_interval_ops = {
792 .read = suspend_dtim_interval_read, 786 .read = suspend_dtim_interval_read,
793 .write = suspend_dtim_interval_write, 787 .write = suspend_dtim_interval_write,
794 .open = wl1271_open_file_generic, 788 .open = simple_open,
795 .llseek = default_llseek, 789 .llseek = default_llseek,
796}; 790};
797 791
@@ -849,7 +843,7 @@ static ssize_t beacon_interval_write(struct file *file,
849static const struct file_operations beacon_interval_ops = { 843static const struct file_operations beacon_interval_ops = {
850 .read = beacon_interval_read, 844 .read = beacon_interval_read,
851 .write = beacon_interval_write, 845 .write = beacon_interval_write,
852 .open = wl1271_open_file_generic, 846 .open = simple_open,
853 .llseek = default_llseek, 847 .llseek = default_llseek,
854}; 848};
855 849
@@ -904,7 +898,7 @@ static ssize_t rx_streaming_interval_read(struct file *file,
904static const struct file_operations rx_streaming_interval_ops = { 898static const struct file_operations rx_streaming_interval_ops = {
905 .read = rx_streaming_interval_read, 899 .read = rx_streaming_interval_read,
906 .write = rx_streaming_interval_write, 900 .write = rx_streaming_interval_write,
907 .open = wl1271_open_file_generic, 901 .open = simple_open,
908 .llseek = default_llseek, 902 .llseek = default_llseek,
909}; 903};
910 904
@@ -959,7 +953,7 @@ static ssize_t rx_streaming_always_read(struct file *file,
959static const struct file_operations rx_streaming_always_ops = { 953static const struct file_operations rx_streaming_always_ops = {
960 .read = rx_streaming_always_read, 954 .read = rx_streaming_always_read,
961 .write = rx_streaming_always_write, 955 .write = rx_streaming_always_write,
962 .open = wl1271_open_file_generic, 956 .open = simple_open,
963 .llseek = default_llseek, 957 .llseek = default_llseek,
964}; 958};
965 959
@@ -1003,7 +997,7 @@ out:
1003 997
1004static const struct file_operations beacon_filtering_ops = { 998static const struct file_operations beacon_filtering_ops = {
1005 .write = beacon_filtering_write, 999 .write = beacon_filtering_write,
1006 .open = wl1271_open_file_generic, 1000 .open = simple_open,
1007 .llseek = default_llseek, 1001 .llseek = default_llseek,
1008}; 1002};
1009 1003
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 663b32c2e931..0ebbb1906c30 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1965,7 +1965,7 @@ static int __init netif_init(void)
1965 if (xen_initial_domain()) 1965 if (xen_initial_domain())
1966 return 0; 1966 return 0;
1967 1967
1968 if (!xen_platform_pci_unplug) 1968 if (xen_hvm_domain() && !xen_platform_pci_unplug)
1969 return -ENODEV; 1969 return -ENODEV;
1970 1970
1971 printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n"); 1971 printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n");
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index ee8fd037bb53..849357c1045c 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -117,25 +117,17 @@ static ssize_t ulong_write_file(struct file *file, char const __user *buf, size_
117} 117}
118 118
119 119
120static int default_open(struct inode *inode, struct file *filp)
121{
122 if (inode->i_private)
123 filp->private_data = inode->i_private;
124 return 0;
125}
126
127
128static const struct file_operations ulong_fops = { 120static const struct file_operations ulong_fops = {
129 .read = ulong_read_file, 121 .read = ulong_read_file,
130 .write = ulong_write_file, 122 .write = ulong_write_file,
131 .open = default_open, 123 .open = simple_open,
132 .llseek = default_llseek, 124 .llseek = default_llseek,
133}; 125};
134 126
135 127
136static const struct file_operations ulong_ro_fops = { 128static const struct file_operations ulong_ro_fops = {
137 .read = ulong_read_file, 129 .read = ulong_read_file,
138 .open = default_open, 130 .open = simple_open,
139 .llseek = default_llseek, 131 .llseek = default_llseek,
140}; 132};
141 133
@@ -187,7 +179,7 @@ static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t coun
187 179
188static const struct file_operations atomic_ro_fops = { 180static const struct file_operations atomic_ro_fops = {
189 .read = atomic_read_file, 181 .read = atomic_read_file,
190 .open = default_open, 182 .open = simple_open,
191 .llseek = default_llseek, 183 .llseek = default_llseek,
192}; 184};
193 185
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index fd00ff02ab4d..d6cc62cb4cf7 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -290,6 +290,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev,
290 } else { 290 } else {
291 printk(KERN_DEBUG "enable msix get value %x\n", 291 printk(KERN_DEBUG "enable msix get value %x\n",
292 op.value); 292 op.value);
293 err = op.value;
293 } 294 }
294 } else { 295 } else {
295 dev_err(&dev->dev, "enable msix get err %x\n", err); 296 dev_err(&dev->dev, "enable msix get err %x\n", err);
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 17499a55113d..53969af17558 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -138,9 +138,10 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev)
138 rdesc->type = REGULATOR_VOLTAGE; 138 rdesc->type = REGULATOR_VOLTAGE;
139 rdesc->owner = THIS_MODULE; 139 rdesc->owner = THIS_MODULE;
140 sreg->mfd = anatopmfd; 140 sreg->mfd = anatopmfd;
141 ret = of_property_read_u32(np, "reg", &sreg->control_reg); 141 ret = of_property_read_u32(np, "anatop-reg-offset",
142 &sreg->control_reg);
142 if (ret) { 143 if (ret) {
143 dev_err(dev, "no reg property set\n"); 144 dev_err(dev, "no anatop-reg-offset property set\n");
144 goto anatop_probe_end; 145 goto anatop_probe_end;
145 } 146 }
146 ret = of_property_read_u32(np, "anatop-vol-bit-width", 147 ret = of_property_read_u32(np, "anatop-vol-bit-width",
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c056abd7562a..e70dd382a009 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2992,14 +2992,14 @@ void regulator_unregister(struct regulator_dev *rdev)
2992 if (rdev == NULL) 2992 if (rdev == NULL)
2993 return; 2993 return;
2994 2994
2995 if (rdev->supply)
2996 regulator_put(rdev->supply);
2995 mutex_lock(&regulator_list_mutex); 2997 mutex_lock(&regulator_list_mutex);
2996 debugfs_remove_recursive(rdev->debugfs); 2998 debugfs_remove_recursive(rdev->debugfs);
2997 flush_work_sync(&rdev->disable_work.work); 2999 flush_work_sync(&rdev->disable_work.work);
2998 WARN_ON(rdev->open_count); 3000 WARN_ON(rdev->open_count);
2999 unset_regulator_supplies(rdev); 3001 unset_regulator_supplies(rdev);
3000 list_del(&rdev->list); 3002 list_del(&rdev->list);
3001 if (rdev->supply)
3002 regulator_put(rdev->supply);
3003 kfree(rdev->constraints); 3003 kfree(rdev->constraints);
3004 device_unregister(&rdev->dev); 3004 device_unregister(&rdev->dev);
3005 mutex_unlock(&regulator_list_mutex); 3005 mutex_unlock(&regulator_list_mutex);
diff --git a/drivers/regulator/fixed-helper.c b/drivers/regulator/fixed-helper.c
index 30d0a15b8949..cacd33c9d042 100644
--- a/drivers/regulator/fixed-helper.c
+++ b/drivers/regulator/fixed-helper.c
@@ -18,7 +18,6 @@ static void regulator_fixed_release(struct device *dev)
18 18
19/** 19/**
20 * regulator_register_fixed - register a no-op fixed regulator 20 * regulator_register_fixed - register a no-op fixed regulator
21 * @name: supply name
22 * @id: platform device id 21 * @id: platform device id
23 * @supplies: consumers for this regulator 22 * @supplies: consumers for this regulator
24 * @num_supplies: number of consumers 23 * @num_supplies: number of consumers
@@ -32,7 +31,7 @@ struct platform_device *regulator_register_fixed(int id,
32 if (!data) 31 if (!data)
33 return NULL; 32 return NULL;
34 33
35 data->cfg.supply_name = "dummy"; 34 data->cfg.supply_name = "fixed-dummy";
36 data->cfg.microvolts = 0; 35 data->cfg.microvolts = 0;
37 data->cfg.gpio = -EINVAL; 36 data->cfg.gpio = -EINVAL;
38 data->cfg.enabled_at_boot = 1; 37 data->cfg.enabled_at_boot = 1;
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
index e8cfc99dd8f0..845aa2263b8a 100644
--- a/drivers/regulator/mc13892-regulator.c
+++ b/drivers/regulator/mc13892-regulator.c
@@ -552,7 +552,7 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
552 mc13xxx_lock(mc13892); 552 mc13xxx_lock(mc13892);
553 ret = mc13xxx_reg_read(mc13892, MC13892_REVISION, &val); 553 ret = mc13xxx_reg_read(mc13892, MC13892_REVISION, &val);
554 if (ret) 554 if (ret)
555 goto err_free; 555 goto err_unlock;
556 556
557 /* enable switch auto mode */ 557 /* enable switch auto mode */
558 if ((val & 0x0000FFFF) == 0x45d0) { 558 if ((val & 0x0000FFFF) == 0x45d0) {
@@ -562,7 +562,7 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
562 MC13892_SWITCHERS4_SW1MODE_AUTO | 562 MC13892_SWITCHERS4_SW1MODE_AUTO |
563 MC13892_SWITCHERS4_SW2MODE_AUTO); 563 MC13892_SWITCHERS4_SW2MODE_AUTO);
564 if (ret) 564 if (ret)
565 goto err_free; 565 goto err_unlock;
566 566
567 ret = mc13xxx_reg_rmw(mc13892, MC13892_SWITCHERS5, 567 ret = mc13xxx_reg_rmw(mc13892, MC13892_SWITCHERS5,
568 MC13892_SWITCHERS5_SW3MODE_M | 568 MC13892_SWITCHERS5_SW3MODE_M |
@@ -570,7 +570,7 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
570 MC13892_SWITCHERS5_SW3MODE_AUTO | 570 MC13892_SWITCHERS5_SW3MODE_AUTO |
571 MC13892_SWITCHERS5_SW4MODE_AUTO); 571 MC13892_SWITCHERS5_SW4MODE_AUTO);
572 if (ret) 572 if (ret)
573 goto err_free; 573 goto err_unlock;
574 } 574 }
575 mc13xxx_unlock(mc13892); 575 mc13xxx_unlock(mc13892);
576 576
@@ -612,10 +612,10 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
612err: 612err:
613 while (--i >= 0) 613 while (--i >= 0)
614 regulator_unregister(priv->regulators[i]); 614 regulator_unregister(priv->regulators[i]);
615 return ret;
615 616
616err_free: 617err_unlock:
617 mc13xxx_unlock(mc13892); 618 mc13xxx_unlock(mc13892);
618
619 return ret; 619 return ret;
620} 620}
621 621
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 58447db15de1..4ca2db059004 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -311,8 +311,7 @@ static int s5m8767_set_voltage(struct regulator_dev *rdev,
311 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 311 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
312 const struct s5m_voltage_desc *desc; 312 const struct s5m_voltage_desc *desc;
313 int reg_id = rdev_get_id(rdev); 313 int reg_id = rdev_get_id(rdev);
314 int reg, mask, ret; 314 int sel, reg, mask, ret;
315 int i;
316 u8 val; 315 u8 val;
317 316
318 switch (reg_id) { 317 switch (reg_id) {
@@ -333,19 +332,20 @@ static int s5m8767_set_voltage(struct regulator_dev *rdev,
333 332
334 desc = reg_voltage_map[reg_id]; 333 desc = reg_voltage_map[reg_id];
335 334
336 i = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV); 335 sel = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV);
337 if (i < 0) 336 if (sel < 0)
338 return i; 337 return sel;
339 338
340 ret = s5m8767_get_voltage_register(rdev, &reg); 339 ret = s5m8767_get_voltage_register(rdev, &reg);
341 if (ret) 340 if (ret)
342 return ret; 341 return ret;
343 342
344 s5m_reg_read(s5m8767->iodev, reg, &val); 343 s5m_reg_read(s5m8767->iodev, reg, &val);
345 val = val & mask; 344 val &= ~mask;
345 val |= sel;
346 346
347 ret = s5m_reg_write(s5m8767->iodev, reg, val); 347 ret = s5m_reg_write(s5m8767->iodev, reg, val);
348 *selector = i; 348 *selector = sel;
349 349
350 return ret; 350 return ret;
351} 351}
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 29b615ce3aff..cfc1f16f7771 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -79,6 +79,11 @@ static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev,
79 unsigned selector) 79 unsigned selector)
80{ 80{
81 struct tps6586x_regulator *info = rdev_get_drvdata(rdev); 81 struct tps6586x_regulator *info = rdev_get_drvdata(rdev);
82 int rid = rdev_get_id(rdev);
83
84 /* LDO0 has minimal voltage 1.2V rather than 1.25V */
85 if ((rid == TPS6586X_ID_LDO_0) && (selector == 0))
86 return (info->voltages[0] - 50) * 1000;
82 87
83 return info->voltages[selector] * 1000; 88 return info->voltages[selector] * 1000;
84} 89}
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 4904a40b0d46..ff810e787eac 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -380,13 +380,15 @@ static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
380 int i; 380 int i;
381 381
382 for (i = 0; i < ARRAY_SIZE(wm831x_dcdc_ilim); i++) { 382 for (i = 0; i < ARRAY_SIZE(wm831x_dcdc_ilim); i++) {
383 if (max_uA <= wm831x_dcdc_ilim[i]) 383 if ((min_uA <= wm831x_dcdc_ilim[i]) &&
384 (wm831x_dcdc_ilim[i] <= max_uA))
384 break; 385 break;
385 } 386 }
386 if (i == ARRAY_SIZE(wm831x_dcdc_ilim)) 387 if (i == ARRAY_SIZE(wm831x_dcdc_ilim))
387 return -EINVAL; 388 return -EINVAL;
388 389
389 return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK, i); 390 return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK,
391 i << WM831X_DC1_HC_THR_SHIFT);
390} 392}
391 393
392static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev) 394static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
@@ -400,7 +402,8 @@ static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
400 if (val < 0) 402 if (val < 0)
401 return val; 403 return val;
402 404
403 return wm831x_dcdc_ilim[val & WM831X_DC1_HC_THR_MASK]; 405 val = (val & WM831X_DC1_HC_THR_MASK) >> WM831X_DC1_HC_THR_SHIFT;
406 return wm831x_dcdc_ilim[val];
404} 407}
405 408
406static struct regulator_ops wm831x_buckv_ops = { 409static struct regulator_ops wm831x_buckv_ops = {
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 634aac3f2d5f..b414e09c5620 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -101,7 +101,7 @@ static int wm831x_isink_set_current(struct regulator_dev *rdev,
101 101
102 for (i = 0; i < ARRAY_SIZE(wm831x_isinkv_values); i++) { 102 for (i = 0; i < ARRAY_SIZE(wm831x_isinkv_values); i++) {
103 int val = wm831x_isinkv_values[i]; 103 int val = wm831x_isinkv_values[i];
104 if (min_uA >= val && val <= max_uA) { 104 if (min_uA <= val && val <= max_uA) {
105 ret = wm831x_set_bits(wm831x, isink->reg, 105 ret = wm831x_set_bits(wm831x, isink->reg,
106 WM831X_CS1_ISEL_MASK, i); 106 WM831X_CS1_ISEL_MASK, i);
107 return ret; 107 return ret;
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index f1e4ab0f9fda..641e9f6499d1 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -506,22 +506,19 @@ static int wm831x_aldo_set_mode(struct regulator_dev *rdev,
506{ 506{
507 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); 507 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
508 struct wm831x *wm831x = ldo->wm831x; 508 struct wm831x *wm831x = ldo->wm831x;
509 int ctrl_reg = ldo->base + WM831X_LDO_CONTROL;
510 int on_reg = ldo->base + WM831X_LDO_ON_CONTROL; 509 int on_reg = ldo->base + WM831X_LDO_ON_CONTROL;
511 int ret; 510 int ret;
512 511
513 512
514 switch (mode) { 513 switch (mode) {
515 case REGULATOR_MODE_NORMAL: 514 case REGULATOR_MODE_NORMAL:
516 ret = wm831x_set_bits(wm831x, on_reg, 515 ret = wm831x_set_bits(wm831x, on_reg, WM831X_LDO7_ON_MODE, 0);
517 WM831X_LDO7_ON_MODE, 0);
518 if (ret < 0) 516 if (ret < 0)
519 return ret; 517 return ret;
520 break; 518 break;
521 519
522 case REGULATOR_MODE_IDLE: 520 case REGULATOR_MODE_IDLE:
523 ret = wm831x_set_bits(wm831x, ctrl_reg, 521 ret = wm831x_set_bits(wm831x, on_reg, WM831X_LDO7_ON_MODE,
524 WM831X_LDO7_ON_MODE,
525 WM831X_LDO7_ON_MODE); 522 WM831X_LDO7_ON_MODE);
526 if (ret < 0) 523 if (ret < 0)
527 return ret; 524 return ret;
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index ab1e183a74b5..05ecfb872319 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -99,7 +99,7 @@ static int get_isink_val(int min_uA, int max_uA, u16 *setting)
99{ 99{
100 int i; 100 int i;
101 101
102 for (i = ARRAY_SIZE(isink_cur) - 1; i >= 0; i--) { 102 for (i = 0; i < ARRAY_SIZE(isink_cur); i++) {
103 if (min_uA <= isink_cur[i] && max_uA >= isink_cur[i]) { 103 if (min_uA <= isink_cur[i] && max_uA >= isink_cur[i]) {
104 *setting = i; 104 *setting = i;
105 return 0; 105 return 0;
@@ -186,7 +186,7 @@ static int wm8350_isink_get_current(struct regulator_dev *rdev)
186 return 0; 186 return 0;
187 } 187 }
188 188
189 return DIV_ROUND_CLOSEST(isink_cur[val], 100); 189 return isink_cur[val];
190} 190}
191 191
192/* turn on ISINK followed by DCDC */ 192/* turn on ISINK followed by DCDC */
@@ -495,25 +495,25 @@ static int wm8350_dcdc_set_suspend_enable(struct regulator_dev *rdev)
495 val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER) 495 val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER)
496 & ~WM8350_DCDC_HIB_MODE_MASK; 496 & ~WM8350_DCDC_HIB_MODE_MASK;
497 wm8350_reg_write(wm8350, WM8350_DCDC1_LOW_POWER, 497 wm8350_reg_write(wm8350, WM8350_DCDC1_LOW_POWER,
498 wm8350->pmic.dcdc1_hib_mode); 498 val | wm8350->pmic.dcdc1_hib_mode);
499 break; 499 break;
500 case WM8350_DCDC_3: 500 case WM8350_DCDC_3:
501 val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER) 501 val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER)
502 & ~WM8350_DCDC_HIB_MODE_MASK; 502 & ~WM8350_DCDC_HIB_MODE_MASK;
503 wm8350_reg_write(wm8350, WM8350_DCDC3_LOW_POWER, 503 wm8350_reg_write(wm8350, WM8350_DCDC3_LOW_POWER,
504 wm8350->pmic.dcdc3_hib_mode); 504 val | wm8350->pmic.dcdc3_hib_mode);
505 break; 505 break;
506 case WM8350_DCDC_4: 506 case WM8350_DCDC_4:
507 val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER) 507 val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER)
508 & ~WM8350_DCDC_HIB_MODE_MASK; 508 & ~WM8350_DCDC_HIB_MODE_MASK;
509 wm8350_reg_write(wm8350, WM8350_DCDC4_LOW_POWER, 509 wm8350_reg_write(wm8350, WM8350_DCDC4_LOW_POWER,
510 wm8350->pmic.dcdc4_hib_mode); 510 val | wm8350->pmic.dcdc4_hib_mode);
511 break; 511 break;
512 case WM8350_DCDC_6: 512 case WM8350_DCDC_6:
513 val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER) 513 val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER)
514 & ~WM8350_DCDC_HIB_MODE_MASK; 514 & ~WM8350_DCDC_HIB_MODE_MASK;
515 wm8350_reg_write(wm8350, WM8350_DCDC6_LOW_POWER, 515 wm8350_reg_write(wm8350, WM8350_DCDC6_LOW_POWER,
516 wm8350->pmic.dcdc6_hib_mode); 516 val | wm8350->pmic.dcdc6_hib_mode);
517 break; 517 break;
518 case WM8350_DCDC_2: 518 case WM8350_DCDC_2:
519 case WM8350_DCDC_5: 519 case WM8350_DCDC_5:
@@ -535,25 +535,25 @@ static int wm8350_dcdc_set_suspend_disable(struct regulator_dev *rdev)
535 val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER); 535 val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER);
536 wm8350->pmic.dcdc1_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; 536 wm8350->pmic.dcdc1_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
537 wm8350_reg_write(wm8350, WM8350_DCDC1_LOW_POWER, 537 wm8350_reg_write(wm8350, WM8350_DCDC1_LOW_POWER,
538 WM8350_DCDC_HIB_MODE_DIS); 538 val | WM8350_DCDC_HIB_MODE_DIS);
539 break; 539 break;
540 case WM8350_DCDC_3: 540 case WM8350_DCDC_3:
541 val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER); 541 val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER);
542 wm8350->pmic.dcdc3_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; 542 wm8350->pmic.dcdc3_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
543 wm8350_reg_write(wm8350, WM8350_DCDC3_LOW_POWER, 543 wm8350_reg_write(wm8350, WM8350_DCDC3_LOW_POWER,
544 WM8350_DCDC_HIB_MODE_DIS); 544 val | WM8350_DCDC_HIB_MODE_DIS);
545 break; 545 break;
546 case WM8350_DCDC_4: 546 case WM8350_DCDC_4:
547 val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER); 547 val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER);
548 wm8350->pmic.dcdc4_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; 548 wm8350->pmic.dcdc4_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
549 wm8350_reg_write(wm8350, WM8350_DCDC4_LOW_POWER, 549 wm8350_reg_write(wm8350, WM8350_DCDC4_LOW_POWER,
550 WM8350_DCDC_HIB_MODE_DIS); 550 val | WM8350_DCDC_HIB_MODE_DIS);
551 break; 551 break;
552 case WM8350_DCDC_6: 552 case WM8350_DCDC_6:
553 val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER); 553 val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER);
554 wm8350->pmic.dcdc6_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; 554 wm8350->pmic.dcdc6_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
555 wm8350_reg_write(wm8350, WM8350_DCDC6_LOW_POWER, 555 wm8350_reg_write(wm8350, WM8350_DCDC6_LOW_POWER,
556 WM8350_DCDC_HIB_MODE_DIS); 556 val | WM8350_DCDC_HIB_MODE_DIS);
557 break; 557 break;
558 case WM8350_DCDC_2: 558 case WM8350_DCDC_2:
559 case WM8350_DCDC_5: 559 case WM8350_DCDC_5:
@@ -575,13 +575,13 @@ static int wm8350_dcdc25_set_suspend_enable(struct regulator_dev *rdev)
575 val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL) 575 val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL)
576 & ~WM8350_DC2_HIB_MODE_MASK; 576 & ~WM8350_DC2_HIB_MODE_MASK;
577 wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val | 577 wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val |
578 WM8350_DC2_HIB_MODE_ACTIVE); 578 (WM8350_DC2_HIB_MODE_ACTIVE << WM8350_DC2_HIB_MODE_SHIFT));
579 break; 579 break;
580 case WM8350_DCDC_5: 580 case WM8350_DCDC_5:
581 val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL) 581 val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL)
582 & ~WM8350_DC2_HIB_MODE_MASK; 582 & ~WM8350_DC5_HIB_MODE_MASK;
583 wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val | 583 wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val |
584 WM8350_DC5_HIB_MODE_ACTIVE); 584 (WM8350_DC5_HIB_MODE_ACTIVE << WM8350_DC5_HIB_MODE_SHIFT));
585 break; 585 break;
586 default: 586 default:
587 return -EINVAL; 587 return -EINVAL;
@@ -600,13 +600,13 @@ static int wm8350_dcdc25_set_suspend_disable(struct regulator_dev *rdev)
600 val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL) 600 val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL)
601 & ~WM8350_DC2_HIB_MODE_MASK; 601 & ~WM8350_DC2_HIB_MODE_MASK;
602 wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val | 602 wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val |
603 WM8350_DC2_HIB_MODE_DISABLE); 603 (WM8350_DC2_HIB_MODE_DISABLE << WM8350_DC2_HIB_MODE_SHIFT));
604 break; 604 break;
605 case WM8350_DCDC_5: 605 case WM8350_DCDC_5:
606 val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL) 606 val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL)
607 & ~WM8350_DC2_HIB_MODE_MASK; 607 & ~WM8350_DC5_HIB_MODE_MASK;
608 wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val | 608 wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val |
609 WM8350_DC2_HIB_MODE_DISABLE); 609 (WM8350_DC5_HIB_MODE_DISABLE << WM8350_DC5_HIB_MODE_SHIFT));
610 break; 610 break;
611 default: 611 default:
612 return -EINVAL; 612 return -EINVAL;
@@ -749,7 +749,7 @@ static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev)
749 749
750 /* all LDOs have same mV bits */ 750 /* all LDOs have same mV bits */
751 val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_HIB_MODE_MASK; 751 val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_HIB_MODE_MASK;
752 wm8350_reg_write(wm8350, volt_reg, WM8350_LDO1_HIB_MODE_DIS); 752 wm8350_reg_write(wm8350, volt_reg, val | WM8350_LDO1_HIB_MODE_DIS);
753 return 0; 753 return 0;
754} 754}
755 755
diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c
index 70277a530133..85d31a69e117 100644
--- a/drivers/remoteproc/remoteproc_debugfs.c
+++ b/drivers/remoteproc/remoteproc_debugfs.c
@@ -50,16 +50,9 @@ static ssize_t rproc_trace_read(struct file *filp, char __user *userbuf,
50 return simple_read_from_buffer(userbuf, count, ppos, trace->va, len); 50 return simple_read_from_buffer(userbuf, count, ppos, trace->va, len);
51} 51}
52 52
53static int rproc_open_generic(struct inode *inode, struct file *file)
54{
55 file->private_data = inode->i_private;
56
57 return 0;
58}
59
60static const struct file_operations trace_rproc_ops = { 53static const struct file_operations trace_rproc_ops = {
61 .read = rproc_trace_read, 54 .read = rproc_trace_read,
62 .open = rproc_open_generic, 55 .open = simple_open,
63 .llseek = generic_file_llseek, 56 .llseek = generic_file_llseek,
64}; 57};
65 58
@@ -94,7 +87,7 @@ static ssize_t rproc_state_read(struct file *filp, char __user *userbuf,
94 87
95static const struct file_operations rproc_state_ops = { 88static const struct file_operations rproc_state_ops = {
96 .read = rproc_state_read, 89 .read = rproc_state_read,
97 .open = rproc_open_generic, 90 .open = simple_open,
98 .llseek = generic_file_llseek, 91 .llseek = generic_file_llseek,
99}; 92};
100 93
@@ -114,7 +107,7 @@ static ssize_t rproc_name_read(struct file *filp, char __user *userbuf,
114 107
115static const struct file_operations rproc_name_ops = { 108static const struct file_operations rproc_name_ops = {
116 .read = rproc_name_read, 109 .read = rproc_name_read,
117 .open = rproc_open_generic, 110 .open = simple_open,
118 .llseek = generic_file_llseek, 111 .llseek = generic_file_llseek,
119}; 112};
120 113
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
index afee0e8ae714..feddefc42109 100644
--- a/drivers/rtc/rtc-88pm860x.c
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -72,9 +72,9 @@ static int pm860x_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
72 struct pm860x_rtc_info *info = dev_get_drvdata(dev); 72 struct pm860x_rtc_info *info = dev_get_drvdata(dev);
73 73
74 if (enabled) 74 if (enabled)
75 pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM, ALARM); 75 pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM_EN, ALARM_EN);
76 else 76 else
77 pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM, 0); 77 pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM_EN, 0);
78 return 0; 78 return 0;
79} 79}
80 80
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 5bdf2eecb178..af04b0d6688d 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -997,13 +997,6 @@ lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf,
997 return nbytes; 997 return nbytes;
998} 998}
999 999
1000static int
1001lpfc_debugfs_dif_err_open(struct inode *inode, struct file *file)
1002{
1003 file->private_data = inode->i_private;
1004 return 0;
1005}
1006
1007static ssize_t 1000static ssize_t
1008lpfc_debugfs_dif_err_read(struct file *file, char __user *buf, 1001lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
1009 size_t nbytes, loff_t *ppos) 1002 size_t nbytes, loff_t *ppos)
@@ -3541,7 +3534,7 @@ static const struct file_operations lpfc_debugfs_op_dumpDif = {
3541#undef lpfc_debugfs_op_dif_err 3534#undef lpfc_debugfs_op_dif_err
3542static const struct file_operations lpfc_debugfs_op_dif_err = { 3535static const struct file_operations lpfc_debugfs_op_dif_err = {
3543 .owner = THIS_MODULE, 3536 .owner = THIS_MODULE,
3544 .open = lpfc_debugfs_dif_err_open, 3537 .open = simple_open,
3545 .llseek = lpfc_debugfs_lseek, 3538 .llseek = lpfc_debugfs_lseek,
3546 .read = lpfc_debugfs_dif_err_read, 3539 .read = lpfc_debugfs_dif_err_read,
3547 .write = lpfc_debugfs_dif_err_write, 3540 .write = lpfc_debugfs_dif_err_write,
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 082458d73ce9..d1a495f64e2d 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -63,12 +63,6 @@ struct chip_data {
63}; 63};
64 64
65#ifdef CONFIG_DEBUG_FS 65#ifdef CONFIG_DEBUG_FS
66static int spi_show_regs_open(struct inode *inode, struct file *file)
67{
68 file->private_data = inode->i_private;
69 return 0;
70}
71
72#define SPI_REGS_BUFSIZE 1024 66#define SPI_REGS_BUFSIZE 1024
73static ssize_t spi_show_regs(struct file *file, char __user *user_buf, 67static ssize_t spi_show_regs(struct file *file, char __user *user_buf,
74 size_t count, loff_t *ppos) 68 size_t count, loff_t *ppos)
@@ -128,7 +122,7 @@ static ssize_t spi_show_regs(struct file *file, char __user *user_buf,
128 122
129static const struct file_operations mrst_spi_regs_ops = { 123static const struct file_operations mrst_spi_regs_ops = {
130 .owner = THIS_MODULE, 124 .owner = THIS_MODULE,
131 .open = spi_show_regs_open, 125 .open = simple_open,
132 .read = spi_show_regs, 126 .read = spi_show_regs,
133 .llseek = default_llseek, 127 .llseek = default_llseek,
134}; 128};
diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
index 830657908db8..c5eb3c33c3db 100644
--- a/drivers/target/tcm_fc/tcm_fc.h
+++ b/drivers/target/tcm_fc/tcm_fc.h
@@ -122,6 +122,7 @@ struct ft_cmd {
122 /* Local sense buffer */ 122 /* Local sense buffer */
123 unsigned char ft_sense_buffer[TRANSPORT_SENSE_BUFFER]; 123 unsigned char ft_sense_buffer[TRANSPORT_SENSE_BUFFER];
124 u32 was_ddp_setup:1; /* Set only if ddp is setup */ 124 u32 was_ddp_setup:1; /* Set only if ddp is setup */
125 u32 aborted:1; /* Set if aborted by reset or timeout */
125 struct scatterlist *sg; /* Set only if DDP is setup */ 126 struct scatterlist *sg; /* Set only if DDP is setup */
126 u32 sg_cnt; /* No. of item in scatterlist */ 127 u32 sg_cnt; /* No. of item in scatterlist */
127}; 128};
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index 62dec9715ce5..a375f257aabc 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -121,6 +121,8 @@ int ft_queue_status(struct se_cmd *se_cmd)
121 struct fc_exch *ep; 121 struct fc_exch *ep;
122 size_t len; 122 size_t len;
123 123
124 if (cmd->aborted)
125 return 0;
124 ft_dump_cmd(cmd, __func__); 126 ft_dump_cmd(cmd, __func__);
125 ep = fc_seq_exch(cmd->seq); 127 ep = fc_seq_exch(cmd->seq);
126 lport = ep->lp; 128 lport = ep->lp;
@@ -187,6 +189,8 @@ int ft_write_pending(struct se_cmd *se_cmd)
187 189
188 ft_dump_cmd(cmd, __func__); 190 ft_dump_cmd(cmd, __func__);
189 191
192 if (cmd->aborted)
193 return 0;
190 ep = fc_seq_exch(cmd->seq); 194 ep = fc_seq_exch(cmd->seq);
191 lport = ep->lp; 195 lport = ep->lp;
192 fp = fc_frame_alloc(lport, sizeof(*txrdy)); 196 fp = fc_frame_alloc(lport, sizeof(*txrdy));
@@ -252,10 +256,10 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
252 struct ft_cmd *cmd = arg; 256 struct ft_cmd *cmd = arg;
253 struct fc_frame_header *fh; 257 struct fc_frame_header *fh;
254 258
255 if (IS_ERR(fp)) { 259 if (unlikely(IS_ERR(fp))) {
256 /* XXX need to find cmd if queued */ 260 /* XXX need to find cmd if queued */
257 cmd->seq = NULL; 261 cmd->seq = NULL;
258 transport_generic_free_cmd(&cmd->se_cmd, 0); 262 cmd->aborted = true;
259 return; 263 return;
260 } 264 }
261 265
@@ -399,6 +403,8 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd)
399 struct se_tmr_req *tmr = se_cmd->se_tmr_req; 403 struct se_tmr_req *tmr = se_cmd->se_tmr_req;
400 enum fcp_resp_rsp_codes code; 404 enum fcp_resp_rsp_codes code;
401 405
406 if (cmd->aborted)
407 return 0;
402 switch (tmr->response) { 408 switch (tmr->response) {
403 case TMR_FUNCTION_COMPLETE: 409 case TMR_FUNCTION_COMPLETE:
404 code = FCP_TMF_CMPL; 410 code = FCP_TMF_CMPL;
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index f357039349ba..2948dc944619 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -300,6 +300,7 @@ static struct se_portal_group *ft_add_tpg(
300{ 300{
301 struct ft_lport_acl *lacl; 301 struct ft_lport_acl *lacl;
302 struct ft_tpg *tpg; 302 struct ft_tpg *tpg;
303 struct workqueue_struct *wq;
303 unsigned long index; 304 unsigned long index;
304 int ret; 305 int ret;
305 306
@@ -321,18 +322,20 @@ static struct se_portal_group *ft_add_tpg(
321 tpg->lport_acl = lacl; 322 tpg->lport_acl = lacl;
322 INIT_LIST_HEAD(&tpg->lun_list); 323 INIT_LIST_HEAD(&tpg->lun_list);
323 324
324 ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg, 325 wq = alloc_workqueue("tcm_fc", 0, 1);
325 tpg, TRANSPORT_TPG_TYPE_NORMAL); 326 if (!wq) {
326 if (ret < 0) {
327 kfree(tpg); 327 kfree(tpg);
328 return NULL; 328 return NULL;
329 } 329 }
330 330
331 tpg->workqueue = alloc_workqueue("tcm_fc", 0, 1); 331 ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg,
332 if (!tpg->workqueue) { 332 tpg, TRANSPORT_TPG_TYPE_NORMAL);
333 if (ret < 0) {
334 destroy_workqueue(wq);
333 kfree(tpg); 335 kfree(tpg);
334 return NULL; 336 return NULL;
335 } 337 }
338 tpg->workqueue = wq;
336 339
337 mutex_lock(&ft_lport_lock); 340 mutex_lock(&ft_lport_lock);
338 list_add_tail(&tpg->list, &lacl->tpg_list); 341 list_add_tail(&tpg->list, &lacl->tpg_list);
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
index 2b693eefac55..dc7c0db26e20 100644
--- a/drivers/target/tcm_fc/tfc_io.c
+++ b/drivers/target/tcm_fc/tfc_io.c
@@ -81,6 +81,8 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
81 void *from; 81 void *from;
82 void *to = NULL; 82 void *to = NULL;
83 83
84 if (cmd->aborted)
85 return 0;
84 ep = fc_seq_exch(cmd->seq); 86 ep = fc_seq_exch(cmd->seq);
85 lport = ep->lp; 87 lport = ep->lp;
86 cmd->seq = lport->tt.seq_start_next(cmd->seq); 88 cmd->seq = lport->tt.seq_start_next(cmd->seq);
diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c
index a9234ba8f8d5..c4b50af46c44 100644
--- a/drivers/tty/serial/mfd.c
+++ b/drivers/tty/serial/mfd.c
@@ -127,11 +127,6 @@ static inline void serial_out(struct uart_hsu_port *up, int offset, int value)
127 127
128#define HSU_REGS_BUFSIZE 1024 128#define HSU_REGS_BUFSIZE 1024
129 129
130static int hsu_show_regs_open(struct inode *inode, struct file *file)
131{
132 file->private_data = inode->i_private;
133 return 0;
134}
135 130
136static ssize_t port_show_regs(struct file *file, char __user *user_buf, 131static ssize_t port_show_regs(struct file *file, char __user *user_buf,
137 size_t count, loff_t *ppos) 132 size_t count, loff_t *ppos)
@@ -231,14 +226,14 @@ static ssize_t dma_show_regs(struct file *file, char __user *user_buf,
231 226
232static const struct file_operations port_regs_ops = { 227static const struct file_operations port_regs_ops = {
233 .owner = THIS_MODULE, 228 .owner = THIS_MODULE,
234 .open = hsu_show_regs_open, 229 .open = simple_open,
235 .read = port_show_regs, 230 .read = port_show_regs,
236 .llseek = default_llseek, 231 .llseek = default_llseek,
237}; 232};
238 233
239static const struct file_operations dma_regs_ops = { 234static const struct file_operations dma_regs_ops = {
240 .owner = THIS_MODULE, 235 .owner = THIS_MODULE,
241 .open = hsu_show_regs_open, 236 .open = simple_open,
242 .read = dma_show_regs, 237 .read = dma_show_regs,
243 .llseek = default_llseek, 238 .llseek = default_llseek,
244}; 239};
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index e825460478be..08b9962b8fda 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -304,11 +304,7 @@ static const int trigger_level_1[4] = { 1, 1, 1, 1 };
304#ifdef CONFIG_DEBUG_FS 304#ifdef CONFIG_DEBUG_FS
305 305
306#define PCH_REGS_BUFSIZE 1024 306#define PCH_REGS_BUFSIZE 1024
307static int pch_show_regs_open(struct inode *inode, struct file *file) 307
308{
309 file->private_data = inode->i_private;
310 return 0;
311}
312 308
313static ssize_t port_show_regs(struct file *file, char __user *user_buf, 309static ssize_t port_show_regs(struct file *file, char __user *user_buf,
314 size_t count, loff_t *ppos) 310 size_t count, loff_t *ppos)
@@ -362,7 +358,7 @@ static ssize_t port_show_regs(struct file *file, char __user *user_buf,
362 358
363static const struct file_operations port_regs_ops = { 359static const struct file_operations port_regs_ops = {
364 .owner = THIS_MODULE, 360 .owner = THIS_MODULE,
365 .open = pch_show_regs_open, 361 .open = simple_open,
366 .read = port_show_regs, 362 .read = port_show_regs,
367 .llseek = default_llseek, 363 .llseek = default_llseek,
368}; 364};
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index b3b70b0bf85b..babd9470982b 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -1581,7 +1581,7 @@ static int __init sunzilog_init(void)
1581 if (err) 1581 if (err)
1582 goto out_unregister_uart; 1582 goto out_unregister_uart;
1583 1583
1584 if (!zilog_irq) { 1584 if (zilog_irq) {
1585 struct uart_sunzilog_port *up = sunzilog_irq_chain; 1585 struct uart_sunzilog_port *up = sunzilog_irq_chain;
1586 err = request_irq(zilog_irq, sunzilog_interrupt, IRQF_SHARED, 1586 err = request_irq(zilog_irq, sunzilog_interrupt, IRQF_SHARED,
1587 "zs", sunzilog_irq_chain); 1587 "zs", sunzilog_irq_chain);
@@ -1622,7 +1622,7 @@ static void __exit sunzilog_exit(void)
1622{ 1622{
1623 platform_driver_unregister(&zs_driver); 1623 platform_driver_unregister(&zs_driver);
1624 1624
1625 if (!zilog_irq) { 1625 if (zilog_irq) {
1626 struct uart_sunzilog_port *up = sunzilog_irq_chain; 1626 struct uart_sunzilog_port *up = sunzilog_irq_chain;
1627 1627
1628 /* Disable Interrupts */ 1628 /* Disable Interrupts */
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 136e86faa1e1..05728894a88c 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -327,7 +327,7 @@ static void send_sig_all(int sig)
327 if (is_global_init(p)) 327 if (is_global_init(p))
328 continue; 328 continue;
329 329
330 force_sig(sig, p); 330 do_send_sig_info(sig, SEND_SIG_FORCED, p, true);
331 } 331 }
332 read_unlock(&tasklist_lock); 332 read_unlock(&tasklist_lock);
333} 333}
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index cefa0c8b5b6a..d2b9af59cba9 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -428,18 +428,10 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
428 return retval; 428 return retval;
429} 429}
430 430
431static int default_open (struct inode *inode, struct file *file)
432{
433 if (inode->i_private)
434 file->private_data = inode->i_private;
435
436 return 0;
437}
438
439static const struct file_operations default_file_operations = { 431static const struct file_operations default_file_operations = {
440 .read = default_read_file, 432 .read = default_read_file,
441 .write = default_write_file, 433 .write = default_write_file,
442 .open = default_open, 434 .open = simple_open,
443 .llseek = default_file_lseek, 435 .llseek = default_file_lseek,
444}; 436};
445 437
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 85a5cebe96b3..965a6293206a 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -345,7 +345,7 @@ static void pn_rx_complete(struct usb_ep *ep, struct usb_request *req)
345 } 345 }
346 346
347 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 347 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
348 skb->len <= 1, req->actual, req->actual); 348 skb->len <= 1, req->actual, PAGE_SIZE);
349 page = NULL; 349 page = NULL;
350 350
351 if (req->actual < req->length) { /* Last fragment */ 351 if (req->actual < req->length) { /* Last fragment */
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 19f318ababa2..cf14c95a6700 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/of.h>
16#include <linux/of_platform.h> 17#include <linux/of_platform.h>
17 18
18/* interface and function clocks */ 19/* interface and function clocks */
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index fd9109d7eb0e..680e1a31fb87 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -352,7 +352,6 @@ static int debug_async_open(struct inode *, struct file *);
352static int debug_periodic_open(struct inode *, struct file *); 352static int debug_periodic_open(struct inode *, struct file *);
353static int debug_registers_open(struct inode *, struct file *); 353static int debug_registers_open(struct inode *, struct file *);
354static int debug_async_open(struct inode *, struct file *); 354static int debug_async_open(struct inode *, struct file *);
355static int debug_lpm_open(struct inode *, struct file *);
356static ssize_t debug_lpm_read(struct file *file, char __user *user_buf, 355static ssize_t debug_lpm_read(struct file *file, char __user *user_buf,
357 size_t count, loff_t *ppos); 356 size_t count, loff_t *ppos);
358static ssize_t debug_lpm_write(struct file *file, const char __user *buffer, 357static ssize_t debug_lpm_write(struct file *file, const char __user *buffer,
@@ -385,7 +384,7 @@ static const struct file_operations debug_registers_fops = {
385}; 384};
386static const struct file_operations debug_lpm_fops = { 385static const struct file_operations debug_lpm_fops = {
387 .owner = THIS_MODULE, 386 .owner = THIS_MODULE,
388 .open = debug_lpm_open, 387 .open = simple_open,
389 .read = debug_lpm_read, 388 .read = debug_lpm_read,
390 .write = debug_lpm_write, 389 .write = debug_lpm_write,
391 .release = debug_lpm_close, 390 .release = debug_lpm_close,
@@ -970,12 +969,6 @@ static int debug_registers_open(struct inode *inode, struct file *file)
970 return file->private_data ? 0 : -ENOMEM; 969 return file->private_data ? 0 : -ENOMEM;
971} 970}
972 971
973static int debug_lpm_open(struct inode *inode, struct file *file)
974{
975 file->private_data = inode->i_private;
976 return 0;
977}
978
979static int debug_lpm_close(struct inode *inode, struct file *file) 972static int debug_lpm_close(struct inode *inode, struct file *file)
980{ 973{
981 return 0; 974 return 0;
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index db8963f5fbce..09f597ad6e00 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -27,6 +27,10 @@
27#error "CONFIG_ARCH_AT91 must be defined." 27#error "CONFIG_ARCH_AT91 must be defined."
28#endif 28#endif
29 29
30#define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
31#define at91_for_each_port(index) \
32 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)
33
30/* interface and function clocks; sometimes also an AHB clock */ 34/* interface and function clocks; sometimes also an AHB clock */
31static struct clk *iclk, *fclk, *hclk; 35static struct clk *iclk, *fclk, *hclk;
32static int clocked; 36static int clocked;
@@ -240,26 +244,26 @@ ohci_at91_start (struct usb_hcd *hcd)
240 244
241static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable) 245static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable)
242{ 246{
243 if (port < 0 || port >= 2) 247 if (!valid_port(port))
244 return; 248 return;
245 249
246 if (!gpio_is_valid(pdata->vbus_pin[port])) 250 if (!gpio_is_valid(pdata->vbus_pin[port]))
247 return; 251 return;
248 252
249 gpio_set_value(pdata->vbus_pin[port], 253 gpio_set_value(pdata->vbus_pin[port],
250 !pdata->vbus_pin_active_low[port] ^ enable); 254 pdata->vbus_pin_active_low[port] ^ enable);
251} 255}
252 256
253static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) 257static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
254{ 258{
255 if (port < 0 || port >= 2) 259 if (!valid_port(port))
256 return -EINVAL; 260 return -EINVAL;
257 261
258 if (!gpio_is_valid(pdata->vbus_pin[port])) 262 if (!gpio_is_valid(pdata->vbus_pin[port]))
259 return -EINVAL; 263 return -EINVAL;
260 264
261 return gpio_get_value(pdata->vbus_pin[port]) ^ 265 return gpio_get_value(pdata->vbus_pin[port]) ^
262 !pdata->vbus_pin_active_low[port]; 266 pdata->vbus_pin_active_low[port];
263} 267}
264 268
265/* 269/*
@@ -271,9 +275,9 @@ static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf)
271 int length = ohci_hub_status_data(hcd, buf); 275 int length = ohci_hub_status_data(hcd, buf);
272 int port; 276 int port;
273 277
274 for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { 278 at91_for_each_port(port) {
275 if (pdata->overcurrent_changed[port]) { 279 if (pdata->overcurrent_changed[port]) {
276 if (! length) 280 if (!length)
277 length = 1; 281 length = 1;
278 buf[0] |= 1 << (port + 1); 282 buf[0] |= 1 << (port + 1);
279 } 283 }
@@ -297,11 +301,17 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
297 "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n", 301 "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n",
298 hcd, typeReq, wValue, wIndex, buf, wLength); 302 hcd, typeReq, wValue, wIndex, buf, wLength);
299 303
304 wIndex--;
305
300 switch (typeReq) { 306 switch (typeReq) {
301 case SetPortFeature: 307 case SetPortFeature:
302 if (wValue == USB_PORT_FEAT_POWER) { 308 if (wValue == USB_PORT_FEAT_POWER) {
303 dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n"); 309 dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n");
304 ohci_at91_usb_set_power(pdata, wIndex - 1, 1); 310 if (valid_port(wIndex)) {
311 ohci_at91_usb_set_power(pdata, wIndex, 1);
312 ret = 0;
313 }
314
305 goto out; 315 goto out;
306 } 316 }
307 break; 317 break;
@@ -312,9 +322,9 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
312 dev_dbg(hcd->self.controller, 322 dev_dbg(hcd->self.controller,
313 "ClearPortFeature: C_OVER_CURRENT\n"); 323 "ClearPortFeature: C_OVER_CURRENT\n");
314 324
315 if (wIndex == 1 || wIndex == 2) { 325 if (valid_port(wIndex)) {
316 pdata->overcurrent_changed[wIndex-1] = 0; 326 pdata->overcurrent_changed[wIndex] = 0;
317 pdata->overcurrent_status[wIndex-1] = 0; 327 pdata->overcurrent_status[wIndex] = 0;
318 } 328 }
319 329
320 goto out; 330 goto out;
@@ -323,9 +333,8 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
323 dev_dbg(hcd->self.controller, 333 dev_dbg(hcd->self.controller,
324 "ClearPortFeature: OVER_CURRENT\n"); 334 "ClearPortFeature: OVER_CURRENT\n");
325 335
326 if (wIndex == 1 || wIndex == 2) { 336 if (valid_port(wIndex))
327 pdata->overcurrent_status[wIndex-1] = 0; 337 pdata->overcurrent_status[wIndex] = 0;
328 }
329 338
330 goto out; 339 goto out;
331 340
@@ -333,15 +342,15 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
333 dev_dbg(hcd->self.controller, 342 dev_dbg(hcd->self.controller,
334 "ClearPortFeature: POWER\n"); 343 "ClearPortFeature: POWER\n");
335 344
336 if (wIndex == 1 || wIndex == 2) { 345 if (valid_port(wIndex)) {
337 ohci_at91_usb_set_power(pdata, wIndex - 1, 0); 346 ohci_at91_usb_set_power(pdata, wIndex, 0);
338 return 0; 347 return 0;
339 } 348 }
340 } 349 }
341 break; 350 break;
342 } 351 }
343 352
344 ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); 353 ret = ohci_hub_control(hcd, typeReq, wValue, wIndex + 1, buf, wLength);
345 if (ret) 354 if (ret)
346 goto out; 355 goto out;
347 356
@@ -377,18 +386,15 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
377 386
378 dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex); 387 dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex);
379 388
380 if (wIndex == 1 || wIndex == 2) { 389 if (valid_port(wIndex)) {
381 if (! ohci_at91_usb_get_power(pdata, wIndex-1)) { 390 if (!ohci_at91_usb_get_power(pdata, wIndex))
382 *data &= ~cpu_to_le32(RH_PS_PPS); 391 *data &= ~cpu_to_le32(RH_PS_PPS);
383 }
384 392
385 if (pdata->overcurrent_changed[wIndex-1]) { 393 if (pdata->overcurrent_changed[wIndex])
386 *data |= cpu_to_le32(RH_PS_OCIC); 394 *data |= cpu_to_le32(RH_PS_OCIC);
387 }
388 395
389 if (pdata->overcurrent_status[wIndex-1]) { 396 if (pdata->overcurrent_status[wIndex])
390 *data |= cpu_to_le32(RH_PS_POCI); 397 *data |= cpu_to_le32(RH_PS_POCI);
391 }
392 } 398 }
393 } 399 }
394 400
@@ -450,14 +456,14 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
450 456
451 /* From the GPIO notifying the over-current situation, find 457 /* From the GPIO notifying the over-current situation, find
452 * out the corresponding port */ 458 * out the corresponding port */
453 for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { 459 at91_for_each_port(port) {
454 if (gpio_to_irq(pdata->overcurrent_pin[port]) == irq) { 460 if (gpio_to_irq(pdata->overcurrent_pin[port]) == irq) {
455 gpio = pdata->overcurrent_pin[port]; 461 gpio = pdata->overcurrent_pin[port];
456 break; 462 break;
457 } 463 }
458 } 464 }
459 465
460 if (port == ARRAY_SIZE(pdata->overcurrent_pin)) { 466 if (port == AT91_MAX_USBH_PORTS) {
461 dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n"); 467 dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n");
462 return IRQ_HANDLED; 468 return IRQ_HANDLED;
463 } 469 }
@@ -467,7 +473,7 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
467 /* When notified of an over-current situation, disable power 473 /* When notified of an over-current situation, disable power
468 on the corresponding port, and mark this port in 474 on the corresponding port, and mark this port in
469 over-current. */ 475 over-current. */
470 if (! val) { 476 if (!val) {
471 ohci_at91_usb_set_power(pdata, port, 0); 477 ohci_at91_usb_set_power(pdata, port, 0);
472 pdata->overcurrent_status[port] = 1; 478 pdata->overcurrent_status[port] = 1;
473 pdata->overcurrent_changed[port] = 1; 479 pdata->overcurrent_changed[port] = 1;
@@ -492,7 +498,7 @@ static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32);
492static int __devinit ohci_at91_of_init(struct platform_device *pdev) 498static int __devinit ohci_at91_of_init(struct platform_device *pdev)
493{ 499{
494 struct device_node *np = pdev->dev.of_node; 500 struct device_node *np = pdev->dev.of_node;
495 int i, ret, gpio; 501 int i, gpio;
496 enum of_gpio_flags flags; 502 enum of_gpio_flags flags;
497 struct at91_usbh_data *pdata; 503 struct at91_usbh_data *pdata;
498 u32 ports; 504 u32 ports;
@@ -514,48 +520,17 @@ static int __devinit ohci_at91_of_init(struct platform_device *pdev)
514 if (!of_property_read_u32(np, "num-ports", &ports)) 520 if (!of_property_read_u32(np, "num-ports", &ports))
515 pdata->ports = ports; 521 pdata->ports = ports;
516 522
517 for (i = 0; i < 2; i++) { 523 at91_for_each_port(i) {
518 gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags); 524 gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags);
519 pdata->vbus_pin[i] = gpio; 525 pdata->vbus_pin[i] = gpio;
520 if (!gpio_is_valid(gpio)) 526 if (!gpio_is_valid(gpio))
521 continue; 527 continue;
522 pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW; 528 pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW;
523 ret = gpio_request(gpio, "ohci_vbus");
524 if (ret) {
525 dev_warn(&pdev->dev, "can't request vbus gpio %d", gpio);
526 continue;
527 }
528 ret = gpio_direction_output(gpio, !(flags & OF_GPIO_ACTIVE_LOW) ^ 1);
529 if (ret)
530 dev_warn(&pdev->dev, "can't put vbus gpio %d as output %d",
531 !(flags & OF_GPIO_ACTIVE_LOW) ^ 1, gpio);
532 } 529 }
533 530
534 for (i = 0; i < 2; i++) { 531 at91_for_each_port(i)
535 gpio = of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags); 532 pdata->overcurrent_pin[i] =
536 pdata->overcurrent_pin[i] = gpio; 533 of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags);
537 if (!gpio_is_valid(gpio))
538 continue;
539 ret = gpio_request(gpio, "ohci_overcurrent");
540 if (ret) {
541 dev_err(&pdev->dev, "can't request overcurrent gpio %d", gpio);
542 continue;
543 }
544
545 ret = gpio_direction_input(gpio);
546 if (ret) {
547 dev_err(&pdev->dev, "can't configure overcurrent gpio %d as input", gpio);
548 continue;
549 }
550
551 ret = request_irq(gpio_to_irq(gpio),
552 ohci_hcd_at91_overcurrent_irq,
553 IRQF_SHARED, "ohci_overcurrent", pdev);
554 if (ret) {
555 gpio_free(gpio);
556 dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n");
557 }
558 }
559 534
560 pdev->dev.platform_data = pdata; 535 pdev->dev.platform_data = pdata;
561 536
@@ -574,35 +549,69 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
574{ 549{
575 struct at91_usbh_data *pdata; 550 struct at91_usbh_data *pdata;
576 int i; 551 int i;
552 int gpio;
553 int ret;
577 554
578 i = ohci_at91_of_init(pdev); 555 ret = ohci_at91_of_init(pdev);
579 556 if (ret)
580 if (i) 557 return ret;
581 return i;
582 558
583 pdata = pdev->dev.platform_data; 559 pdata = pdev->dev.platform_data;
584 560
585 if (pdata) { 561 if (pdata) {
586 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { 562 at91_for_each_port(i) {
587 if (!gpio_is_valid(pdata->vbus_pin[i])) 563 if (!gpio_is_valid(pdata->vbus_pin[i]))
588 continue; 564 continue;
589 gpio_request(pdata->vbus_pin[i], "ohci_vbus"); 565 gpio = pdata->vbus_pin[i];
566
567 ret = gpio_request(gpio, "ohci_vbus");
568 if (ret) {
569 dev_err(&pdev->dev,
570 "can't request vbus gpio %d\n", gpio);
571 continue;
572 }
573 ret = gpio_direction_output(gpio,
574 !pdata->vbus_pin_active_low[i]);
575 if (ret) {
576 dev_err(&pdev->dev,
577 "can't put vbus gpio %d as output %d\n",
578 gpio, !pdata->vbus_pin_active_low[i]);
579 gpio_free(gpio);
580 continue;
581 }
582
590 ohci_at91_usb_set_power(pdata, i, 1); 583 ohci_at91_usb_set_power(pdata, i, 1);
591 } 584 }
592 585
593 for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { 586 at91_for_each_port(i) {
594 int ret;
595
596 if (!gpio_is_valid(pdata->overcurrent_pin[i])) 587 if (!gpio_is_valid(pdata->overcurrent_pin[i]))
597 continue; 588 continue;
598 gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); 589 gpio = pdata->overcurrent_pin[i];
590
591 ret = gpio_request(gpio, "ohci_overcurrent");
592 if (ret) {
593 dev_err(&pdev->dev,
594 "can't request overcurrent gpio %d\n",
595 gpio);
596 continue;
597 }
598
599 ret = gpio_direction_input(gpio);
600 if (ret) {
601 dev_err(&pdev->dev,
602 "can't configure overcurrent gpio %d as input\n",
603 gpio);
604 gpio_free(gpio);
605 continue;
606 }
599 607
600 ret = request_irq(gpio_to_irq(pdata->overcurrent_pin[i]), 608 ret = request_irq(gpio_to_irq(gpio),
601 ohci_hcd_at91_overcurrent_irq, 609 ohci_hcd_at91_overcurrent_irq,
602 IRQF_SHARED, "ohci_overcurrent", pdev); 610 IRQF_SHARED, "ohci_overcurrent", pdev);
603 if (ret) { 611 if (ret) {
604 gpio_free(pdata->overcurrent_pin[i]); 612 gpio_free(gpio);
605 dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n"); 613 dev_err(&pdev->dev,
614 "can't get gpio IRQ for overcurrent\n");
606 } 615 }
607 } 616 }
608 } 617 }
@@ -617,14 +626,14 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
617 int i; 626 int i;
618 627
619 if (pdata) { 628 if (pdata) {
620 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { 629 at91_for_each_port(i) {
621 if (!gpio_is_valid(pdata->vbus_pin[i])) 630 if (!gpio_is_valid(pdata->vbus_pin[i]))
622 continue; 631 continue;
623 ohci_at91_usb_set_power(pdata, i, 0); 632 ohci_at91_usb_set_power(pdata, i, 0);
624 gpio_free(pdata->vbus_pin[i]); 633 gpio_free(pdata->vbus_pin[i]);
625 } 634 }
626 635
627 for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { 636 at91_for_each_port(i) {
628 if (!gpio_is_valid(pdata->overcurrent_pin[i])) 637 if (!gpio_is_valid(pdata->overcurrent_pin[i]))
629 continue; 638 continue;
630 free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); 639 free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev);
diff --git a/drivers/uwb/uwb-debug.c b/drivers/uwb/uwb-debug.c
index 2eecec0c13c9..6ec45beb7af5 100644
--- a/drivers/uwb/uwb-debug.c
+++ b/drivers/uwb/uwb-debug.c
@@ -159,13 +159,6 @@ static int cmd_ie_rm(struct uwb_rc *rc, struct uwb_dbg_cmd_ie *ie_to_rm)
159 return uwb_rc_ie_rm(rc, ie_to_rm->data[0]); 159 return uwb_rc_ie_rm(rc, ie_to_rm->data[0]);
160} 160}
161 161
162static int command_open(struct inode *inode, struct file *file)
163{
164 file->private_data = inode->i_private;
165
166 return 0;
167}
168
169static ssize_t command_write(struct file *file, const char __user *buf, 162static ssize_t command_write(struct file *file, const char __user *buf,
170 size_t len, loff_t *off) 163 size_t len, loff_t *off)
171{ 164{
@@ -206,7 +199,7 @@ static ssize_t command_write(struct file *file, const char __user *buf,
206} 199}
207 200
208static const struct file_operations command_fops = { 201static const struct file_operations command_fops = {
209 .open = command_open, 202 .open = simple_open,
210 .write = command_write, 203 .write = command_write,
211 .read = NULL, 204 .read = NULL,
212 .llseek = no_llseek, 205 .llseek = no_llseek,
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 7ed9991fa747..af16884491ed 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -245,6 +245,12 @@ config BACKLIGHT_DA903X
245 If you have a LCD backlight connected to the WLED output of DA9030 245 If you have a LCD backlight connected to the WLED output of DA9030
246 or DA9034 WLED output, say Y here to enable this driver. 246 or DA9034 WLED output, say Y here to enable this driver.
247 247
248config BACKLIGHT_DA9052
249 tristate "Dialog DA9052/DA9053 WLED"
250 depends on PMIC_DA9052
251 help
252 Enable the Backlight Driver for DA9052-BC and DA9053-AA/Bx PMICs.
253
248config BACKLIGHT_MAX8925 254config BACKLIGHT_MAX8925
249 tristate "Backlight driver for MAX8925" 255 tristate "Backlight driver for MAX8925"
250 depends on MFD_MAX8925 256 depends on MFD_MAX8925
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 8071eb656147..36855ae887d6 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
29obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o 29obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
30obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o 30obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
31obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o 31obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o
32obj-$(CONFIG_BACKLIGHT_DA9052) += da9052_bl.o
32obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o 33obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o
33obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o 34obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o
34obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o 35obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o
diff --git a/drivers/video/backlight/da9052_bl.c b/drivers/video/backlight/da9052_bl.c
new file mode 100644
index 000000000000..b628d68f5162
--- /dev/null
+++ b/drivers/video/backlight/da9052_bl.c
@@ -0,0 +1,187 @@
1/*
2 * Backlight Driver for Dialog DA9052 PMICs
3 *
4 * Copyright(c) 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: David Dajun Chen <dchen@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */
14
15#include <linux/backlight.h>
16#include <linux/delay.h>
17#include <linux/fb.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20
21#include <linux/mfd/da9052/da9052.h>
22#include <linux/mfd/da9052/reg.h>
23
24#define DA9052_MAX_BRIGHTNESS 0xFF
25
26enum {
27 DA9052_WLEDS_OFF,
28 DA9052_WLEDS_ON,
29};
30
31enum {
32 DA9052_TYPE_WLED1,
33 DA9052_TYPE_WLED2,
34 DA9052_TYPE_WLED3,
35};
36
37static unsigned char wled_bank[] = {
38 DA9052_LED1_CONF_REG,
39 DA9052_LED2_CONF_REG,
40 DA9052_LED3_CONF_REG,
41};
42
43struct da9052_bl {
44 struct da9052 *da9052;
45 uint brightness;
46 uint state;
47 uint led_reg;
48};
49
50static int da9052_adjust_wled_brightness(struct da9052_bl *wleds)
51{
52 unsigned char boost_en;
53 unsigned char i_sink;
54 int ret;
55
56 boost_en = 0x3F;
57 i_sink = 0xFF;
58 if (wleds->state == DA9052_WLEDS_OFF) {
59 boost_en = 0x00;
60 i_sink = 0x00;
61 }
62
63 ret = da9052_reg_write(wleds->da9052, DA9052_BOOST_REG, boost_en);
64 if (ret < 0)
65 return ret;
66
67 ret = da9052_reg_write(wleds->da9052, DA9052_LED_CONT_REG, i_sink);
68 if (ret < 0)
69 return ret;
70
71 ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg], 0x0);
72 if (ret < 0)
73 return ret;
74
75 msleep(10);
76
77 if (wleds->brightness) {
78 ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg],
79 wleds->brightness);
80 if (ret < 0)
81 return ret;
82 }
83
84 return 0;
85}
86
87static int da9052_backlight_update_status(struct backlight_device *bl)
88{
89 int brightness = bl->props.brightness;
90 struct da9052_bl *wleds = bl_get_data(bl);
91
92 wleds->brightness = brightness;
93 wleds->state = DA9052_WLEDS_ON;
94
95 return da9052_adjust_wled_brightness(wleds);
96}
97
98static int da9052_backlight_get_brightness(struct backlight_device *bl)
99{
100 struct da9052_bl *wleds = bl_get_data(bl);
101
102 return wleds->brightness;
103}
104
105static const struct backlight_ops da9052_backlight_ops = {
106 .update_status = da9052_backlight_update_status,
107 .get_brightness = da9052_backlight_get_brightness,
108};
109
110static int da9052_backlight_probe(struct platform_device *pdev)
111{
112 struct backlight_device *bl;
113 struct backlight_properties props;
114 struct da9052_bl *wleds;
115
116 wleds = devm_kzalloc(&pdev->dev, sizeof(struct da9052_bl), GFP_KERNEL);
117 if (!wleds)
118 return -ENOMEM;
119
120 wleds->da9052 = dev_get_drvdata(pdev->dev.parent);
121 wleds->brightness = 0;
122 wleds->led_reg = platform_get_device_id(pdev)->driver_data;
123 wleds->state = DA9052_WLEDS_OFF;
124
125 props.type = BACKLIGHT_RAW;
126 props.max_brightness = DA9052_MAX_BRIGHTNESS;
127
128 bl = backlight_device_register(pdev->name, wleds->da9052->dev, wleds,
129 &da9052_backlight_ops, &props);
130 if (IS_ERR(bl)) {
131 dev_err(&pdev->dev, "Failed to register backlight\n");
132 devm_kfree(&pdev->dev, wleds);
133 return PTR_ERR(bl);
134 }
135
136 bl->props.max_brightness = DA9052_MAX_BRIGHTNESS;
137 bl->props.brightness = 0;
138 platform_set_drvdata(pdev, bl);
139
140 return da9052_adjust_wled_brightness(wleds);
141}
142
143static int da9052_backlight_remove(struct platform_device *pdev)
144{
145 struct backlight_device *bl = platform_get_drvdata(pdev);
146 struct da9052_bl *wleds = bl_get_data(bl);
147
148 wleds->brightness = 0;
149 wleds->state = DA9052_WLEDS_OFF;
150 da9052_adjust_wled_brightness(wleds);
151 backlight_device_unregister(bl);
152 devm_kfree(&pdev->dev, wleds);
153
154 return 0;
155}
156
157static struct platform_device_id da9052_wled_ids[] = {
158 {
159 .name = "da9052-wled1",
160 .driver_data = DA9052_TYPE_WLED1,
161 },
162 {
163 .name = "da9052-wled2",
164 .driver_data = DA9052_TYPE_WLED2,
165 },
166 {
167 .name = "da9052-wled3",
168 .driver_data = DA9052_TYPE_WLED3,
169 },
170};
171
172static struct platform_driver da9052_wled_driver = {
173 .probe = da9052_backlight_probe,
174 .remove = da9052_backlight_remove,
175 .id_table = da9052_wled_ids,
176 .driver = {
177 .name = "da9052-wled",
178 .owner = THIS_MODULE,
179 },
180};
181
182module_platform_driver(da9052_wled_driver);
183
184MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
185MODULE_DESCRIPTION("Backlight driver for DA9052 PMIC");
186MODULE_LICENSE("GPL");
187MODULE_ALIAS("platform:da9052-backlight");
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
index be20b5cbe26c..3a6d5419e3e3 100644
--- a/drivers/video/backlight/locomolcd.c
+++ b/drivers/video/backlight/locomolcd.c
@@ -229,14 +229,7 @@ static struct locomo_driver poodle_lcd_driver = {
229 229
230static int __init locomolcd_init(void) 230static int __init locomolcd_init(void)
231{ 231{
232 int ret = locomo_driver_register(&poodle_lcd_driver); 232 return locomo_driver_register(&poodle_lcd_driver);
233 if (ret)
234 return ret;
235
236#ifdef CONFIG_SA1100_COLLIE
237 sa1100fb_lcd_power = locomolcd_power;
238#endif
239 return 0;
240} 233}
241 234
242static void __exit locomolcd_exit(void) 235static void __exit locomolcd_exit(void)
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 19e6a2041371..1afb4fba11b4 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -204,7 +204,8 @@ error:
204 204
205void * 205void *
206xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size, 206xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
207 dma_addr_t *dma_handle, gfp_t flags) 207 dma_addr_t *dma_handle, gfp_t flags,
208 struct dma_attrs *attrs)
208{ 209{
209 void *ret; 210 void *ret;
210 int order = get_order(size); 211 int order = get_order(size);
@@ -253,7 +254,7 @@ EXPORT_SYMBOL_GPL(xen_swiotlb_alloc_coherent);
253 254
254void 255void
255xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, 256xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
256 dma_addr_t dev_addr) 257 dma_addr_t dev_addr, struct dma_attrs *attrs)
257{ 258{
258 int order = get_order(size); 259 int order = get_order(size);
259 phys_addr_t phys; 260 phys_addr_t phys;
diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c
index 63616d7453e6..97f5d264c31e 100644
--- a/drivers/xen/xen-pciback/pciback_ops.c
+++ b/drivers/xen/xen-pciback/pciback_ops.c
@@ -234,7 +234,7 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
234 if (dev_data) 234 if (dev_data)
235 dev_data->ack_intr = 0; 235 dev_data->ack_intr = 0;
236 236
237 return result; 237 return result > 0 ? 0 : result;
238} 238}
239 239
240static 240static