aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/processor_driver.c7
-rw-r--r--drivers/base/Makefile2
-rw-r--r--drivers/base/core.c17
-rw-r--r--drivers/base/sys.c383
-rw-r--r--drivers/block/rbd.c7
-rw-r--r--drivers/dma/at_hdmac.c4
-rw-r--r--drivers/dma/at_hdmac_regs.h17
-rw-r--r--drivers/dma/dmatest.c2
-rw-r--r--drivers/dma/imx-sdma.c6
-rw-r--r--drivers/dma/shdma.c3
-rw-r--r--drivers/firewire/ohci.c6
-rw-r--r--drivers/gpio/gpio-lpc32xx.c2
-rw-r--r--drivers/gpio/gpio-ml-ioh.c1
-rw-r--r--drivers/gpio/gpio-pch.c1
-rw-r--r--drivers/gpio/gpio-samsung.c23
-rw-r--r--drivers/gpu/drm/drm_gem.c2
-rw-r--r--drivers/gpu/drm/i810/i810_dma.c17
-rw-r--r--drivers/gpu/drm/i810/i810_drv.c1
-rw-r--r--drivers/gpu/drm/i810/i810_drv.h6
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.h5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c10
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c23
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_mxm.c9
-rw-r--r--drivers/gpu/drm/nouveau/nv50_pm.c4
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c4
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c18
-rw-r--r--drivers/gpu/drm/radeon/r600_blit_kms.c35
-rw-r--r--drivers/gpu/drm/radeon/radeon_atpx_handler.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c2
-rw-r--r--drivers/hid/hid-hyperv.c1
-rw-r--r--drivers/hid/hid-wacom.c7
-rw-r--r--drivers/hid/hid-wiimote-core.c4
-rw-r--r--drivers/hid/usbhid/hiddev.c4
-rw-r--r--drivers/hwmon/f71805f.c10
-rw-r--r--drivers/hwmon/sht15.c3
-rw-r--r--drivers/hwmon/w83627ehf.c29
-rw-r--r--drivers/infiniband/core/ucma.c5
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c1
-rw-r--r--drivers/infiniband/core/verbs.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c2
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c7
-rw-r--r--drivers/infiniband/hw/nes/nes.c2
-rw-r--r--drivers/infiniband/hw/nes/nes.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c10
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_context.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c2
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_mgt.c2
-rw-r--r--drivers/infiniband/hw/nes/nes_mgt.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_nic.c2
-rw-r--r--drivers/infiniband/hw/nes/nes_user.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_utils.c2
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c6
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.h2
-rw-r--r--drivers/infiniband/hw/qib/qib_iba6120.c2
-rw-r--r--drivers/infiniband/hw/qib/qib_pcie.c2
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.c17
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.h1
-rw-r--r--drivers/input/evdev.c2
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c4
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h7
-rw-r--r--drivers/input/serio/serio_raw.c15
-rw-r--r--drivers/iommu/amd_iommu.c3
-rw-r--r--drivers/iommu/msm_iommu.c7
-rw-r--r--drivers/leds/leds-lm3530.c4
-rw-r--r--drivers/md/dm-raid.c12
-rw-r--r--drivers/md/md.c5
-rw-r--r--drivers/mfd/twl6040-core.c128
-rw-r--r--drivers/misc/lkdtm.c6
-rw-r--r--drivers/mtd/mtdcore.c2
-rw-r--r--drivers/mtd/nand/atmel_nand.c45
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-lib.c18
-rw-r--r--drivers/mtd/nand/nand_base.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c4
-rw-r--r--drivers/net/xen-netfront.c2
-rw-r--r--drivers/pcmcia/ds.c4
-rw-r--r--drivers/pinctrl/core.c50
-rw-r--r--drivers/pinctrl/core.h3
-rw-r--r--drivers/pinctrl/pinconf.c6
-rw-r--r--drivers/pinctrl/pinconf.h4
-rw-r--r--drivers/pinctrl/pinmux.c81
-rw-r--r--drivers/pinctrl/pinmux.h4
-rw-r--r--drivers/regulator/of_regulator.c2
-rw-r--r--drivers/s390/block/dasd.c6
-rw-r--r--drivers/s390/block/dasd_alias.c64
-rw-r--r--drivers/s390/block/dasd_eckd.c63
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/spi/spi-topcliff-pch.c6
-rw-r--r--drivers/staging/media/go7007/go7007-usb.c1
-rw-r--r--drivers/target/iscsi/iscsi_target.c39
-rw-r--r--drivers/target/iscsi/iscsi_target_configfs.c1
-rw-r--r--drivers/target/iscsi/iscsi_target_core.h6
-rw-r--r--drivers/target/iscsi/iscsi_target_erl1.c4
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c39
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c11
-rw-r--r--drivers/target/target_core_alua.c8
-rw-r--r--drivers/target/target_core_cdb.c51
-rw-r--r--drivers/target/target_core_configfs.c12
-rw-r--r--drivers/target/target_core_device.c28
-rw-r--r--drivers/target/target_core_fabric_configfs.c4
-rw-r--r--drivers/target/target_core_iblock.c11
-rw-r--r--drivers/target/target_core_internal.h2
-rw-r--r--drivers/target/target_core_pr.c43
-rw-r--r--drivers/target/target_core_pscsi.c4
-rw-r--r--drivers/target/target_core_tpg.c3
-rw-r--r--drivers/target/target_core_transport.c124
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c9
-rw-r--r--drivers/tty/serial/8250/8250.c (renamed from drivers/tty/serial/8250.c)0
-rw-r--r--drivers/tty/serial/8250/8250.h (renamed from drivers/tty/serial/8250.h)0
-rw-r--r--drivers/tty/serial/8250/8250_accent.c (renamed from drivers/tty/serial/8250_accent.c)0
-rw-r--r--drivers/tty/serial/8250/8250_acorn.c (renamed from drivers/tty/serial/8250_acorn.c)0
-rw-r--r--drivers/tty/serial/8250/8250_boca.c (renamed from drivers/tty/serial/8250_boca.c)0
-rw-r--r--drivers/tty/serial/8250/8250_dw.c (renamed from drivers/tty/serial/8250_dw.c)0
-rw-r--r--drivers/tty/serial/8250/8250_early.c (renamed from drivers/tty/serial/8250_early.c)0
-rw-r--r--drivers/tty/serial/8250/8250_exar_st16c554.c (renamed from drivers/tty/serial/8250_exar_st16c554.c)0
-rw-r--r--drivers/tty/serial/8250/8250_fourport.c (renamed from drivers/tty/serial/8250_fourport.c)0
-rw-r--r--drivers/tty/serial/8250/8250_fsl.c (renamed from drivers/tty/serial/8250_fsl.c)0
-rw-r--r--drivers/tty/serial/8250/8250_gsc.c (renamed from drivers/tty/serial/8250_gsc.c)0
-rw-r--r--drivers/tty/serial/8250/8250_hp300.c (renamed from drivers/tty/serial/8250_hp300.c)0
-rw-r--r--drivers/tty/serial/8250/8250_hub6.c (renamed from drivers/tty/serial/8250_hub6.c)0
-rw-r--r--drivers/tty/serial/8250/8250_mca.c (renamed from drivers/tty/serial/8250_mca.c)0
-rw-r--r--drivers/tty/serial/8250/8250_pci.c (renamed from drivers/tty/serial/8250_pci.c)0
-rw-r--r--drivers/tty/serial/8250/8250_pnp.c (renamed from drivers/tty/serial/8250_pnp.c)0
-rw-r--r--drivers/tty/serial/8250/Kconfig280
-rw-r--r--drivers/tty/serial/8250/Makefile20
-rw-r--r--drivers/tty/serial/8250/m32r_sio.c (renamed from drivers/tty/serial/m32r_sio.c)0
-rw-r--r--drivers/tty/serial/8250/m32r_sio.h (renamed from drivers/tty/serial/m32r_sio.h)0
-rw-r--r--drivers/tty/serial/8250/m32r_sio_reg.h (renamed from drivers/tty/serial/m32r_sio_reg.h)0
-rw-r--r--drivers/tty/serial/8250/serial_cs.c (renamed from drivers/tty/serial/serial_cs.c)0
-rw-r--r--drivers/tty/serial/Kconfig283
-rw-r--r--drivers/tty/serial/Makefile20
-rw-r--r--drivers/tty/serial/amba-pl011.c30
-rw-r--r--drivers/tty/serial/jsm/jsm_driver.c1
-rw-r--r--drivers/tty/serial/max3107-aava.c344
-rw-r--r--drivers/tty/serial/omap-serial.c4
-rw-r--r--drivers/tty/serial/serial_core.c6
-rw-r--r--drivers/tty/tty_port.c12
-rw-r--r--drivers/tty/vt/vt_ioctl.c1
-rw-r--r--drivers/usb/class/cdc-wdm.c59
-rw-r--r--drivers/usb/dwc3/ep0.c15
-rw-r--r--drivers/usb/dwc3/gadget.c2
-rw-r--r--drivers/usb/gadget/composite.c7
-rw-r--r--drivers/usb/gadget/epautoconf.c2
-rw-r--r--drivers/usb/gadget/f_mass_storage.c10
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c4
-rw-r--r--drivers/usb/gadget/langwell_udc.c107
-rw-r--r--drivers/usb/gadget/langwell_udc.h1
-rw-r--r--drivers/usb/gadget/storage_common.c6
-rw-r--r--drivers/usb/host/ehci-fsl.c2
-rw-r--r--drivers/usb/host/ehci-pci.c6
-rw-r--r--drivers/usb/host/ohci-dbg.c12
-rw-r--r--drivers/usb/host/ohci-pci.c4
-rw-r--r--drivers/usb/host/xhci-ring.c6
-rw-r--r--drivers/usb/misc/emi26.c3
-rw-r--r--drivers/usb/misc/emi62.c3
-rw-r--r--drivers/usb/misc/usbsevseg.c2
-rw-r--r--drivers/usb/musb/davinci.c3
-rw-r--r--drivers/usb/musb/musb_core.c5
-rw-r--r--drivers/usb/musb/omap2430.c4
-rw-r--r--drivers/usb/otg/Kconfig18
-rw-r--r--drivers/usb/otg/Makefile1
-rw-r--r--drivers/usb/otg/langwell_otg.c2347
-rw-r--r--drivers/usb/otg/mv_otg.c2
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c2
-rw-r--r--drivers/usb/serial/cp210x.c105
-rw-r--r--drivers/usb/serial/ftdi_sio.c14
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h19
-rw-r--r--drivers/usb/serial/io_ti.c10
-rw-r--r--drivers/usb/serial/kobil_sct.c2
-rw-r--r--drivers/usb/serial/option.c5
-rw-r--r--drivers/usb/serial/qcaux.c7
-rw-r--r--drivers/usb/storage/realtek_cr.c2
-rw-r--r--drivers/usb/usb-skeleton.c18
-rw-r--r--drivers/usb/wusbcore/Kconfig2
-rw-r--r--drivers/video/atmel_lcdfb.c2
-rw-r--r--drivers/video/fsl-diu-fb.c4
-rw-r--r--drivers/video/intelfb/intelfbdrv.c1
-rw-r--r--drivers/video/omap2/dss/dispc.c2
-rw-r--r--drivers/video/omap2/dss/dsi.c2
-rw-r--r--drivers/video/omap2/dss/dss.c2
-rw-r--r--drivers/video/omap2/dss/hdmi.c5
-rw-r--r--drivers/video/omap2/dss/rfbi.c2
-rw-r--r--drivers/video/omap2/dss/ti_hdmi.h4
-rw-r--r--drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c68
-rw-r--r--drivers/video/omap2/dss/venc.c2
-rw-r--r--drivers/virtio/virtio_ring.c8
-rw-r--r--drivers/watchdog/dw_wdt.c6
-rw-r--r--drivers/watchdog/iTCO_wdt.c35
-rw-r--r--drivers/watchdog/imx2_wdt.c11
-rw-r--r--drivers/watchdog/nuc900_wdt.c5
-rw-r--r--drivers/watchdog/omap_wdt.c2
-rw-r--r--drivers/watchdog/pnx4008_wdt.c2
-rw-r--r--drivers/watchdog/stmp3xxx_wdt.c2
-rw-r--r--drivers/watchdog/via_wdt.c6
-rw-r--r--drivers/watchdog/wafer5823wdt.c4
-rw-r--r--drivers/watchdog/wm8350_wdt.c4
-rw-r--r--drivers/xen/grant-table.c7
202 files changed, 1539 insertions, 4193 deletions
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 2b805d7ef317..8ae05ce18500 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -586,13 +586,6 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
586 if (pr->flags.need_hotplug_init) 586 if (pr->flags.need_hotplug_init)
587 return 0; 587 return 0;
588 588
589 /*
590 * Do not start hotplugged CPUs now, but when they
591 * are onlined the first time
592 */
593 if (pr->flags.need_hotplug_init)
594 return 0;
595
596 result = acpi_processor_start(pr); 589 result = acpi_processor_start(pr);
597 if (result) 590 if (result)
598 goto err_remove_sysfs; 591 goto err_remove_sysfs;
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 2c8272dd93c4..610f9997a403 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -1,6 +1,6 @@
1# Makefile for the Linux device tree 1# Makefile for the Linux device tree
2 2
3obj-y := core.o sys.o bus.o dd.o syscore.o \ 3obj-y := core.o bus.o dd.o syscore.o \
4 driver.o class.o platform.o \ 4 driver.o class.o platform.o \
5 cpu.o firmware.o init.o map.o devres.o \ 5 cpu.o firmware.o init.o map.o devres.o \
6 attribute_container.o transport_class.o \ 6 attribute_container.o transport_class.o \
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 4a67cc0c8b37..74dda4f697f9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -632,6 +632,11 @@ static void klist_children_put(struct klist_node *n)
632 * may be used for reference counting of @dev after calling this 632 * may be used for reference counting of @dev after calling this
633 * function. 633 * function.
634 * 634 *
635 * All fields in @dev must be initialized by the caller to 0, except
636 * for those explicitly set to some other value. The simplest
637 * approach is to use kzalloc() to allocate the structure containing
638 * @dev.
639 *
635 * NOTE: Use put_device() to give up your reference instead of freeing 640 * NOTE: Use put_device() to give up your reference instead of freeing
636 * @dev directly once you have called this function. 641 * @dev directly once you have called this function.
637 */ 642 */
@@ -930,6 +935,13 @@ int device_private_init(struct device *dev)
930 * to the global and sibling lists for the device, then 935 * to the global and sibling lists for the device, then
931 * adds it to the other relevant subsystems of the driver model. 936 * adds it to the other relevant subsystems of the driver model.
932 * 937 *
938 * Do not call this routine or device_register() more than once for
939 * any device structure. The driver model core is not designed to work
940 * with devices that get unregistered and then spring back to life.
941 * (Among other things, it's very hard to guarantee that all references
942 * to the previous incarnation of @dev have been dropped.) Allocate
943 * and register a fresh new struct device instead.
944 *
933 * NOTE: _Never_ directly free @dev after calling this function, even 945 * NOTE: _Never_ directly free @dev after calling this function, even
934 * if it returned an error! Always use put_device() to give up your 946 * if it returned an error! Always use put_device() to give up your
935 * reference instead. 947 * reference instead.
@@ -1022,7 +1034,7 @@ int device_add(struct device *dev)
1022 device_pm_add(dev); 1034 device_pm_add(dev);
1023 1035
1024 /* Notify clients of device addition. This call must come 1036 /* Notify clients of device addition. This call must come
1025 * after dpm_sysf_add() and before kobject_uevent(). 1037 * after dpm_sysfs_add() and before kobject_uevent().
1026 */ 1038 */
1027 if (dev->bus) 1039 if (dev->bus)
1028 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 1040 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
@@ -1090,6 +1102,9 @@ name_error:
1090 * have a clearly defined need to use and refcount the device 1102 * have a clearly defined need to use and refcount the device
1091 * before it is added to the hierarchy. 1103 * before it is added to the hierarchy.
1092 * 1104 *
1105 * For more information, see the kerneldoc for device_initialize()
1106 * and device_add().
1107 *
1093 * NOTE: _Never_ directly free @dev after calling this function, even 1108 * NOTE: _Never_ directly free @dev after calling this function, even
1094 * if it returned an error! Always use put_device() to give up the 1109 * if it returned an error! Always use put_device() to give up the
1095 * reference initialized in this function instead. 1110 * reference initialized in this function instead.
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
deleted file mode 100644
index 409f5ce78829..000000000000
--- a/drivers/base/sys.c
+++ /dev/null
@@ -1,383 +0,0 @@
1/*
2 * sys.c - pseudo-bus for system 'devices' (cpus, PICs, timers, etc)
3 *
4 * Copyright (c) 2002-3 Patrick Mochel
5 * 2002-3 Open Source Development Lab
6 *
7 * This file is released under the GPLv2
8 *
9 * This exports a 'system' bus type.
10 * By default, a 'sys' bus gets added to the root of the system. There will
11 * always be core system devices. Devices can use sysdev_register() to
12 * add themselves as children of the system bus.
13 */
14
15#include <linux/sysdev.h>
16#include <linux/err.h>
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/string.h>
21#include <linux/pm.h>
22#include <linux/device.h>
23#include <linux/mutex.h>
24#include <linux/interrupt.h>
25
26#include "base.h"
27
28#define to_sysdev(k) container_of(k, struct sys_device, kobj)
29#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr)
30
31
32static ssize_t
33sysdev_show(struct kobject *kobj, struct attribute *attr, char *buffer)
34{
35 struct sys_device *sysdev = to_sysdev(kobj);
36 struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr);
37
38 if (sysdev_attr->show)
39 return sysdev_attr->show(sysdev, sysdev_attr, buffer);
40 return -EIO;
41}
42
43
44static ssize_t
45sysdev_store(struct kobject *kobj, struct attribute *attr,
46 const char *buffer, size_t count)
47{
48 struct sys_device *sysdev = to_sysdev(kobj);
49 struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr);
50
51 if (sysdev_attr->store)
52 return sysdev_attr->store(sysdev, sysdev_attr, buffer, count);
53 return -EIO;
54}
55
56static const struct sysfs_ops sysfs_ops = {
57 .show = sysdev_show,
58 .store = sysdev_store,
59};
60
61static struct kobj_type ktype_sysdev = {
62 .sysfs_ops = &sysfs_ops,
63};
64
65
66int sysdev_create_file(struct sys_device *s, struct sysdev_attribute *a)
67{
68 return sysfs_create_file(&s->kobj, &a->attr);
69}
70
71
72void sysdev_remove_file(struct sys_device *s, struct sysdev_attribute *a)
73{
74 sysfs_remove_file(&s->kobj, &a->attr);
75}
76
77EXPORT_SYMBOL_GPL(sysdev_create_file);
78EXPORT_SYMBOL_GPL(sysdev_remove_file);
79
80#define to_sysdev_class(k) container_of(k, struct sysdev_class, kset.kobj)
81#define to_sysdev_class_attr(a) container_of(a, \
82 struct sysdev_class_attribute, attr)
83
84static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr,
85 char *buffer)
86{
87 struct sysdev_class *class = to_sysdev_class(kobj);
88 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
89
90 if (class_attr->show)
91 return class_attr->show(class, class_attr, buffer);
92 return -EIO;
93}
94
95static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
96 const char *buffer, size_t count)
97{
98 struct sysdev_class *class = to_sysdev_class(kobj);
99 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
100
101 if (class_attr->store)
102 return class_attr->store(class, class_attr, buffer, count);
103 return -EIO;
104}
105
106static const struct sysfs_ops sysfs_class_ops = {
107 .show = sysdev_class_show,
108 .store = sysdev_class_store,
109};
110
111static struct kobj_type ktype_sysdev_class = {
112 .sysfs_ops = &sysfs_class_ops,
113};
114
115int sysdev_class_create_file(struct sysdev_class *c,
116 struct sysdev_class_attribute *a)
117{
118 return sysfs_create_file(&c->kset.kobj, &a->attr);
119}
120EXPORT_SYMBOL_GPL(sysdev_class_create_file);
121
122void sysdev_class_remove_file(struct sysdev_class *c,
123 struct sysdev_class_attribute *a)
124{
125 sysfs_remove_file(&c->kset.kobj, &a->attr);
126}
127EXPORT_SYMBOL_GPL(sysdev_class_remove_file);
128
129extern struct kset *system_kset;
130
131int sysdev_class_register(struct sysdev_class *cls)
132{
133 int retval;
134
135 pr_debug("Registering sysdev class '%s'\n", cls->name);
136
137 INIT_LIST_HEAD(&cls->drivers);
138 memset(&cls->kset.kobj, 0x00, sizeof(struct kobject));
139 cls->kset.kobj.parent = &system_kset->kobj;
140 cls->kset.kobj.ktype = &ktype_sysdev_class;
141 cls->kset.kobj.kset = system_kset;
142
143 retval = kobject_set_name(&cls->kset.kobj, "%s", cls->name);
144 if (retval)
145 return retval;
146
147 retval = kset_register(&cls->kset);
148 if (!retval && cls->attrs)
149 retval = sysfs_create_files(&cls->kset.kobj,
150 (const struct attribute **)cls->attrs);
151 return retval;
152}
153
154void sysdev_class_unregister(struct sysdev_class *cls)
155{
156 pr_debug("Unregistering sysdev class '%s'\n",
157 kobject_name(&cls->kset.kobj));
158 if (cls->attrs)
159 sysfs_remove_files(&cls->kset.kobj,
160 (const struct attribute **)cls->attrs);
161 kset_unregister(&cls->kset);
162}
163
164EXPORT_SYMBOL_GPL(sysdev_class_register);
165EXPORT_SYMBOL_GPL(sysdev_class_unregister);
166
167static DEFINE_MUTEX(sysdev_drivers_lock);
168
169/*
170 * @dev != NULL means that we're unwinding because some drv->add()
171 * failed for some reason. You need to grab sysdev_drivers_lock before
172 * calling this.
173 */
174static void __sysdev_driver_remove(struct sysdev_class *cls,
175 struct sysdev_driver *drv,
176 struct sys_device *from_dev)
177{
178 struct sys_device *dev = from_dev;
179
180 list_del_init(&drv->entry);
181 if (!cls)
182 return;
183
184 if (!drv->remove)
185 goto kset_put;
186
187 if (dev)
188 list_for_each_entry_continue_reverse(dev, &cls->kset.list,
189 kobj.entry)
190 drv->remove(dev);
191 else
192 list_for_each_entry(dev, &cls->kset.list, kobj.entry)
193 drv->remove(dev);
194
195kset_put:
196 kset_put(&cls->kset);
197}
198
199/**
200 * sysdev_driver_register - Register auxiliary driver
201 * @cls: Device class driver belongs to.
202 * @drv: Driver.
203 *
204 * @drv is inserted into @cls->drivers to be
205 * called on each operation on devices of that class. The refcount
206 * of @cls is incremented.
207 */
208int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
209{
210 struct sys_device *dev = NULL;
211 int err = 0;
212
213 if (!cls) {
214 WARN(1, KERN_WARNING "sysdev: invalid class passed to %s!\n",
215 __func__);
216 return -EINVAL;
217 }
218
219 /* Check whether this driver has already been added to a class. */
220 if (drv->entry.next && !list_empty(&drv->entry))
221 WARN(1, KERN_WARNING "sysdev: class %s: driver (%p) has already"
222 " been registered to a class, something is wrong, but "
223 "will forge on!\n", cls->name, drv);
224
225 mutex_lock(&sysdev_drivers_lock);
226 if (cls && kset_get(&cls->kset)) {
227 list_add_tail(&drv->entry, &cls->drivers);
228
229 /* If devices of this class already exist, tell the driver */
230 if (drv->add) {
231 list_for_each_entry(dev, &cls->kset.list, kobj.entry) {
232 err = drv->add(dev);
233 if (err)
234 goto unwind;
235 }
236 }
237 } else {
238 err = -EINVAL;
239 WARN(1, KERN_ERR "%s: invalid device class\n", __func__);
240 }
241
242 goto unlock;
243
244unwind:
245 __sysdev_driver_remove(cls, drv, dev);
246
247unlock:
248 mutex_unlock(&sysdev_drivers_lock);
249 return err;
250}
251
252/**
253 * sysdev_driver_unregister - Remove an auxiliary driver.
254 * @cls: Class driver belongs to.
255 * @drv: Driver.
256 */
257void sysdev_driver_unregister(struct sysdev_class *cls,
258 struct sysdev_driver *drv)
259{
260 mutex_lock(&sysdev_drivers_lock);
261 __sysdev_driver_remove(cls, drv, NULL);
262 mutex_unlock(&sysdev_drivers_lock);
263}
264EXPORT_SYMBOL_GPL(sysdev_driver_register);
265EXPORT_SYMBOL_GPL(sysdev_driver_unregister);
266
267/**
268 * sysdev_register - add a system device to the tree
269 * @sysdev: device in question
270 *
271 */
272int sysdev_register(struct sys_device *sysdev)
273{
274 int error;
275 struct sysdev_class *cls = sysdev->cls;
276
277 if (!cls)
278 return -EINVAL;
279
280 pr_debug("Registering sys device of class '%s'\n",
281 kobject_name(&cls->kset.kobj));
282
283 /* initialize the kobject to 0, in case it had previously been used */
284 memset(&sysdev->kobj, 0x00, sizeof(struct kobject));
285
286 /* Make sure the kset is set */
287 sysdev->kobj.kset = &cls->kset;
288
289 /* Register the object */
290 error = kobject_init_and_add(&sysdev->kobj, &ktype_sysdev, NULL,
291 "%s%d", kobject_name(&cls->kset.kobj),
292 sysdev->id);
293
294 if (!error) {
295 struct sysdev_driver *drv;
296
297 pr_debug("Registering sys device '%s'\n",
298 kobject_name(&sysdev->kobj));
299
300 mutex_lock(&sysdev_drivers_lock);
301 /* Generic notification is implicit, because it's that
302 * code that should have called us.
303 */
304
305 /* Notify class auxiliary drivers */
306 list_for_each_entry(drv, &cls->drivers, entry) {
307 if (drv->add)
308 drv->add(sysdev);
309 }
310 mutex_unlock(&sysdev_drivers_lock);
311 kobject_uevent(&sysdev->kobj, KOBJ_ADD);
312 }
313
314 return error;
315}
316
317void sysdev_unregister(struct sys_device *sysdev)
318{
319 struct sysdev_driver *drv;
320
321 mutex_lock(&sysdev_drivers_lock);
322 list_for_each_entry(drv, &sysdev->cls->drivers, entry) {
323 if (drv->remove)
324 drv->remove(sysdev);
325 }
326 mutex_unlock(&sysdev_drivers_lock);
327
328 kobject_put(&sysdev->kobj);
329}
330
331EXPORT_SYMBOL_GPL(sysdev_register);
332EXPORT_SYMBOL_GPL(sysdev_unregister);
333
334#define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr)
335
336ssize_t sysdev_store_ulong(struct sys_device *sysdev,
337 struct sysdev_attribute *attr,
338 const char *buf, size_t size)
339{
340 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
341 char *end;
342 unsigned long new = simple_strtoul(buf, &end, 0);
343 if (end == buf)
344 return -EINVAL;
345 *(unsigned long *)(ea->var) = new;
346 /* Always return full write size even if we didn't consume all */
347 return size;
348}
349EXPORT_SYMBOL_GPL(sysdev_store_ulong);
350
351ssize_t sysdev_show_ulong(struct sys_device *sysdev,
352 struct sysdev_attribute *attr,
353 char *buf)
354{
355 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
356 return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var));
357}
358EXPORT_SYMBOL_GPL(sysdev_show_ulong);
359
360ssize_t sysdev_store_int(struct sys_device *sysdev,
361 struct sysdev_attribute *attr,
362 const char *buf, size_t size)
363{
364 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
365 char *end;
366 long new = simple_strtol(buf, &end, 0);
367 if (end == buf || new > INT_MAX || new < INT_MIN)
368 return -EINVAL;
369 *(int *)(ea->var) = new;
370 /* Always return full write size even if we didn't consume all */
371 return size;
372}
373EXPORT_SYMBOL_GPL(sysdev_store_int);
374
375ssize_t sysdev_show_int(struct sys_device *sysdev,
376 struct sysdev_attribute *attr,
377 char *buf)
378{
379 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
380 return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var));
381}
382EXPORT_SYMBOL_GPL(sysdev_show_int);
383
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 3fd31dec8c9c..a6278e7e61a0 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -380,6 +380,7 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr,
380 rbdc = __rbd_client_find(opt); 380 rbdc = __rbd_client_find(opt);
381 if (rbdc) { 381 if (rbdc) {
382 ceph_destroy_options(opt); 382 ceph_destroy_options(opt);
383 kfree(rbd_opts);
383 384
384 /* using an existing client */ 385 /* using an existing client */
385 kref_get(&rbdc->kref); 386 kref_get(&rbdc->kref);
@@ -406,15 +407,15 @@ done_err:
406 407
407/* 408/*
408 * Destroy ceph client 409 * Destroy ceph client
410 *
411 * Caller must hold node_lock.
409 */ 412 */
410static void rbd_client_release(struct kref *kref) 413static void rbd_client_release(struct kref *kref)
411{ 414{
412 struct rbd_client *rbdc = container_of(kref, struct rbd_client, kref); 415 struct rbd_client *rbdc = container_of(kref, struct rbd_client, kref);
413 416
414 dout("rbd_release_client %p\n", rbdc); 417 dout("rbd_release_client %p\n", rbdc);
415 spin_lock(&node_lock);
416 list_del(&rbdc->node); 418 list_del(&rbdc->node);
417 spin_unlock(&node_lock);
418 419
419 ceph_destroy_client(rbdc->client); 420 ceph_destroy_client(rbdc->client);
420 kfree(rbdc->rbd_opts); 421 kfree(rbdc->rbd_opts);
@@ -427,7 +428,9 @@ static void rbd_client_release(struct kref *kref)
427 */ 428 */
428static void rbd_put_client(struct rbd_device *rbd_dev) 429static void rbd_put_client(struct rbd_device *rbd_dev)
429{ 430{
431 spin_lock(&node_lock);
430 kref_put(&rbd_dev->rbd_client->kref, rbd_client_release); 432 kref_put(&rbd_dev->rbd_client->kref, rbd_client_release);
433 spin_unlock(&node_lock);
431 rbd_dev->rbd_client = NULL; 434 rbd_dev->rbd_client = NULL;
432 rbd_dev->client = NULL; 435 rbd_dev->client = NULL;
433} 436}
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 97f87b29b9f3..f4aed5fc2cb6 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -1343,7 +1343,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
1343 1343
1344 tasklet_init(&atchan->tasklet, atc_tasklet, 1344 tasklet_init(&atchan->tasklet, atc_tasklet,
1345 (unsigned long)atchan); 1345 (unsigned long)atchan);
1346 atc_enable_irq(atchan); 1346 atc_enable_chan_irq(atdma, i);
1347 } 1347 }
1348 1348
1349 /* set base routines */ 1349 /* set base routines */
@@ -1410,7 +1410,7 @@ static int __exit at_dma_remove(struct platform_device *pdev)
1410 struct at_dma_chan *atchan = to_at_dma_chan(chan); 1410 struct at_dma_chan *atchan = to_at_dma_chan(chan);
1411 1411
1412 /* Disable interrupts */ 1412 /* Disable interrupts */
1413 atc_disable_irq(atchan); 1413 atc_disable_chan_irq(atdma, chan->chan_id);
1414 tasklet_disable(&atchan->tasklet); 1414 tasklet_disable(&atchan->tasklet);
1415 1415
1416 tasklet_kill(&atchan->tasklet); 1416 tasklet_kill(&atchan->tasklet);
diff --git a/drivers/dma/at_hdmac_regs.h b/drivers/dma/at_hdmac_regs.h
index dcaedfc181cf..a8d3277d60b5 100644
--- a/drivers/dma/at_hdmac_regs.h
+++ b/drivers/dma/at_hdmac_regs.h
@@ -327,28 +327,27 @@ static void atc_dump_lli(struct at_dma_chan *atchan, struct at_lli *lli)
327} 327}
328 328
329 329
330static void atc_setup_irq(struct at_dma_chan *atchan, int on) 330static void atc_setup_irq(struct at_dma *atdma, int chan_id, int on)
331{ 331{
332 struct at_dma *atdma = to_at_dma(atchan->chan_common.device); 332 u32 ebci;
333 u32 ebci;
334 333
335 /* enable interrupts on buffer transfer completion & error */ 334 /* enable interrupts on buffer transfer completion & error */
336 ebci = AT_DMA_BTC(atchan->chan_common.chan_id) 335 ebci = AT_DMA_BTC(chan_id)
337 | AT_DMA_ERR(atchan->chan_common.chan_id); 336 | AT_DMA_ERR(chan_id);
338 if (on) 337 if (on)
339 dma_writel(atdma, EBCIER, ebci); 338 dma_writel(atdma, EBCIER, ebci);
340 else 339 else
341 dma_writel(atdma, EBCIDR, ebci); 340 dma_writel(atdma, EBCIDR, ebci);
342} 341}
343 342
344static inline void atc_enable_irq(struct at_dma_chan *atchan) 343static void atc_enable_chan_irq(struct at_dma *atdma, int chan_id)
345{ 344{
346 atc_setup_irq(atchan, 1); 345 atc_setup_irq(atdma, chan_id, 1);
347} 346}
348 347
349static inline void atc_disable_irq(struct at_dma_chan *atchan) 348static void atc_disable_chan_irq(struct at_dma *atdma, int chan_id)
350{ 349{
351 atc_setup_irq(atchan, 0); 350 atc_setup_irq(atdma, chan_id, 0);
352} 351}
353 352
354 353
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 2b8661b54eaf..24225f0fdcd8 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -599,7 +599,7 @@ static int dmatest_add_channel(struct dma_chan *chan)
599 } 599 }
600 if (dma_has_cap(DMA_PQ, dma_dev->cap_mask)) { 600 if (dma_has_cap(DMA_PQ, dma_dev->cap_mask)) {
601 cnt = dmatest_add_threads(dtc, DMA_PQ); 601 cnt = dmatest_add_threads(dtc, DMA_PQ);
602 thread_count += cnt > 0 ?: 0; 602 thread_count += cnt > 0 ? cnt : 0;
603 } 603 }
604 604
605 pr_info("dmatest: Started %u threads using %s\n", 605 pr_info("dmatest: Started %u threads using %s\n",
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index a8af379680c1..8bc5acf36ee5 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1102,11 +1102,13 @@ static int sdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
1102 case DMA_SLAVE_CONFIG: 1102 case DMA_SLAVE_CONFIG:
1103 if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) { 1103 if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
1104 sdmac->per_address = dmaengine_cfg->src_addr; 1104 sdmac->per_address = dmaengine_cfg->src_addr;
1105 sdmac->watermark_level = dmaengine_cfg->src_maxburst; 1105 sdmac->watermark_level = dmaengine_cfg->src_maxburst *
1106 dmaengine_cfg->src_addr_width;
1106 sdmac->word_size = dmaengine_cfg->src_addr_width; 1107 sdmac->word_size = dmaengine_cfg->src_addr_width;
1107 } else { 1108 } else {
1108 sdmac->per_address = dmaengine_cfg->dst_addr; 1109 sdmac->per_address = dmaengine_cfg->dst_addr;
1109 sdmac->watermark_level = dmaengine_cfg->dst_maxburst; 1110 sdmac->watermark_level = dmaengine_cfg->dst_maxburst *
1111 dmaengine_cfg->dst_addr_width;
1110 sdmac->word_size = dmaengine_cfg->dst_addr_width; 1112 sdmac->word_size = dmaengine_cfg->dst_addr_width;
1111 } 1113 }
1112 sdmac->direction = dmaengine_cfg->direction; 1114 sdmac->direction = dmaengine_cfg->direction;
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index 54043cd831c8..812fd76e9c18 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -1262,7 +1262,8 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
1262 1262
1263 INIT_LIST_HEAD(&shdev->common.channels); 1263 INIT_LIST_HEAD(&shdev->common.channels);
1264 1264
1265 dma_cap_set(DMA_MEMCPY, shdev->common.cap_mask); 1265 if (!pdata->slave_only)
1266 dma_cap_set(DMA_MEMCPY, shdev->common.cap_mask);
1266 if (pdata->slave && pdata->slave_num) 1267 if (pdata->slave && pdata->slave_num)
1267 dma_cap_set(DMA_SLAVE, shdev->common.cap_mask); 1268 dma_cap_set(DMA_SLAVE, shdev->common.cap_mask);
1268 1269
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 6628feaa7622..7f5f0da726da 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -263,6 +263,7 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
263static char ohci_driver_name[] = KBUILD_MODNAME; 263static char ohci_driver_name[] = KBUILD_MODNAME;
264 264
265#define PCI_DEVICE_ID_AGERE_FW643 0x5901 265#define PCI_DEVICE_ID_AGERE_FW643 0x5901
266#define PCI_DEVICE_ID_CREATIVE_SB1394 0x4001
266#define PCI_DEVICE_ID_JMICRON_JMB38X_FW 0x2380 267#define PCI_DEVICE_ID_JMICRON_JMB38X_FW 0x2380
267#define PCI_DEVICE_ID_TI_TSB12LV22 0x8009 268#define PCI_DEVICE_ID_TI_TSB12LV22 0x8009
268#define PCI_DEVICE_ID_TI_TSB12LV26 0x8020 269#define PCI_DEVICE_ID_TI_TSB12LV26 0x8020
@@ -289,6 +290,9 @@ static const struct {
289 {PCI_VENDOR_ID_ATT, PCI_DEVICE_ID_AGERE_FW643, 6, 290 {PCI_VENDOR_ID_ATT, PCI_DEVICE_ID_AGERE_FW643, 6,
290 QUIRK_NO_MSI}, 291 QUIRK_NO_MSI},
291 292
293 {PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_SB1394, PCI_ANY_ID,
294 QUIRK_RESET_PACKET},
295
292 {PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB38X_FW, PCI_ANY_ID, 296 {PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB38X_FW, PCI_ANY_ID,
293 QUIRK_NO_MSI}, 297 QUIRK_NO_MSI},
294 298
@@ -299,7 +303,7 @@ static const struct {
299 QUIRK_NO_MSI}, 303 QUIRK_NO_MSI},
300 304
301 {PCI_VENDOR_ID_RICOH, PCI_ANY_ID, PCI_ANY_ID, 305 {PCI_VENDOR_ID_RICOH, PCI_ANY_ID, PCI_ANY_ID,
302 QUIRK_CYCLE_TIMER}, 306 QUIRK_CYCLE_TIMER | QUIRK_NO_MSI},
303 307
304 {PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TSB12LV22, PCI_ANY_ID, 308 {PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TSB12LV22, PCI_ANY_ID,
305 QUIRK_CYCLE_TIMER | QUIRK_RESET_PACKET | QUIRK_NO_1394A}, 309 QUIRK_CYCLE_TIMER | QUIRK_RESET_PACKET | QUIRK_NO_1394A},
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index 5b6948081f8f..ddfacc5ce56d 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -96,7 +96,7 @@ static const char *gpio_p2_names[LPC32XX_GPIO_P2_MAX] = {
96}; 96};
97 97
98static const char *gpio_p3_names[LPC32XX_GPIO_P3_MAX] = { 98static const char *gpio_p3_names[LPC32XX_GPIO_P3_MAX] = {
99 "gpi000", "gpio01", "gpio02", "gpio03", 99 "gpio00", "gpio01", "gpio02", "gpio03",
100 "gpio04", "gpio05" 100 "gpio04", "gpio05"
101}; 101};
102 102
diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index 03d6dd5dcb77..f0febe5b8221 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -448,6 +448,7 @@ static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
448 chip->reg = chip->base; 448 chip->reg = chip->base;
449 chip->ch = i; 449 chip->ch = i;
450 mutex_init(&chip->lock); 450 mutex_init(&chip->lock);
451 spin_lock_init(&chip->spinlock);
451 ioh_gpio_setup(chip, num_ports[i]); 452 ioh_gpio_setup(chip, num_ports[i]);
452 ret = gpiochip_add(&chip->gpio); 453 ret = gpiochip_add(&chip->gpio);
453 if (ret) { 454 if (ret) {
diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c
index 68fa55e86eb1..e8729cc2ba2b 100644
--- a/drivers/gpio/gpio-pch.c
+++ b/drivers/gpio/gpio-pch.c
@@ -392,6 +392,7 @@ static int __devinit pch_gpio_probe(struct pci_dev *pdev,
392 chip->reg = chip->base; 392 chip->reg = chip->base;
393 pci_set_drvdata(pdev, chip); 393 pci_set_drvdata(pdev, chip);
394 mutex_init(&chip->lock); 394 mutex_init(&chip->lock);
395 spin_lock_init(&chip->spinlock);
395 pch_gpio_setup(chip); 396 pch_gpio_setup(chip);
396 ret = gpiochip_add(&chip->gpio); 397 ret = gpiochip_add(&chip->gpio);
397 if (ret) { 398 if (ret) {
diff --git a/drivers/gpio/gpio-samsung.c b/drivers/gpio/gpio-samsung.c
index a7661773c052..0a79a1167a25 100644
--- a/drivers/gpio/gpio-samsung.c
+++ b/drivers/gpio/gpio-samsung.c
@@ -2387,27 +2387,30 @@ static struct samsung_gpio_chip exynos4_gpios_3[] = {
2387}; 2387};
2388 2388
2389#if defined(CONFIG_ARCH_EXYNOS4) && defined(CONFIG_OF) 2389#if defined(CONFIG_ARCH_EXYNOS4) && defined(CONFIG_OF)
2390static int exynos4_gpio_xlate(struct gpio_chip *gc, struct device_node *np, 2390static int exynos4_gpio_xlate(struct gpio_chip *gc,
2391 const void *gpio_spec, u32 *flags) 2391 const struct of_phandle_args *gpiospec, u32 *flags)
2392{ 2392{
2393 const __be32 *gpio = gpio_spec; 2393 unsigned int pin;
2394 const u32 n = be32_to_cpup(gpio);
2395 unsigned int pin = gc->base + be32_to_cpu(gpio[0]);
2396 2394
2397 if (WARN_ON(gc->of_gpio_n_cells < 4)) 2395 if (WARN_ON(gc->of_gpio_n_cells < 4))
2398 return -EINVAL; 2396 return -EINVAL;
2399 2397
2400 if (n > gc->ngpio) 2398 if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
2401 return -EINVAL; 2399 return -EINVAL;
2402 2400
2403 if (s3c_gpio_cfgpin(pin, S3C_GPIO_SFN(be32_to_cpu(gpio[1])))) 2401 if (gpiospec->args[0] > gc->ngpio)
2402 return -EINVAL;
2403
2404 pin = gc->base + gpiospec->args[0];
2405
2406 if (s3c_gpio_cfgpin(pin, S3C_GPIO_SFN(gpiospec->args[1])))
2404 pr_warn("gpio_xlate: failed to set pin function\n"); 2407 pr_warn("gpio_xlate: failed to set pin function\n");
2405 if (s3c_gpio_setpull(pin, be32_to_cpu(gpio[2]))) 2408 if (s3c_gpio_setpull(pin, gpiospec->args[2]))
2406 pr_warn("gpio_xlate: failed to set pin pull up/down\n"); 2409 pr_warn("gpio_xlate: failed to set pin pull up/down\n");
2407 if (s5p_gpio_set_drvstr(pin, be32_to_cpu(gpio[3]))) 2410 if (s5p_gpio_set_drvstr(pin, gpiospec->args[3]))
2408 pr_warn("gpio_xlate: failed to set pin drive strength\n"); 2411 pr_warn("gpio_xlate: failed to set pin drive strength\n");
2409 2412
2410 return n; 2413 return gpiospec->args[0];
2411} 2414}
2412 2415
2413static const struct of_device_id exynos4_gpio_dt_match[] __initdata = { 2416static const struct of_device_id exynos4_gpio_dt_match[] __initdata = {
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 396e60ce8114..f8625e290728 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -140,7 +140,7 @@ int drm_gem_object_init(struct drm_device *dev,
140 obj->dev = dev; 140 obj->dev = dev;
141 obj->filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); 141 obj->filp = shmem_file_setup("drm mm object", size, VM_NORESERVE);
142 if (IS_ERR(obj->filp)) 142 if (IS_ERR(obj->filp))
143 return -ENOMEM; 143 return PTR_ERR(obj->filp);
144 144
145 kref_init(&obj->refcount); 145 kref_init(&obj->refcount);
146 atomic_set(&obj->handle_count, 0); 146 atomic_set(&obj->handle_count, 0);
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index f7c17b239833..7f4b4e10246e 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -886,7 +886,7 @@ static int i810_flush_queue(struct drm_device *dev)
886} 886}
887 887
888/* Must be called with the lock held */ 888/* Must be called with the lock held */
889void i810_driver_reclaim_buffers(struct drm_device *dev, 889static void i810_reclaim_buffers(struct drm_device *dev,
890 struct drm_file *file_priv) 890 struct drm_file *file_priv)
891{ 891{
892 struct drm_device_dma *dma = dev->dma; 892 struct drm_device_dma *dma = dev->dma;
@@ -1223,17 +1223,12 @@ void i810_driver_preclose(struct drm_device *dev, struct drm_file *file_priv)
1223 if (dev_priv->page_flipping) 1223 if (dev_priv->page_flipping)
1224 i810_do_cleanup_pageflip(dev); 1224 i810_do_cleanup_pageflip(dev);
1225 } 1225 }
1226}
1226 1227
1227 if (file_priv->master && file_priv->master->lock.hw_lock) { 1228void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
1228 drm_idlelock_take(&file_priv->master->lock); 1229 struct drm_file *file_priv)
1229 i810_driver_reclaim_buffers(dev, file_priv); 1230{
1230 drm_idlelock_release(&file_priv->master->lock); 1231 i810_reclaim_buffers(dev, file_priv);
1231 } else {
1232 /* master disappeared, clean up stuff anyway and hope nothing
1233 * goes wrong */
1234 i810_driver_reclaim_buffers(dev, file_priv);
1235 }
1236
1237} 1232}
1238 1233
1239int i810_driver_dma_quiescent(struct drm_device *dev) 1234int i810_driver_dma_quiescent(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 053f1ee58393..ec12f7dc717a 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -63,6 +63,7 @@ static struct drm_driver driver = {
63 .lastclose = i810_driver_lastclose, 63 .lastclose = i810_driver_lastclose,
64 .preclose = i810_driver_preclose, 64 .preclose = i810_driver_preclose,
65 .device_is_agp = i810_driver_device_is_agp, 65 .device_is_agp = i810_driver_device_is_agp,
66 .reclaim_buffers_locked = i810_driver_reclaim_buffers_locked,
66 .dma_quiescent = i810_driver_dma_quiescent, 67 .dma_quiescent = i810_driver_dma_quiescent,
67 .ioctls = i810_ioctls, 68 .ioctls = i810_ioctls,
68 .fops = &i810_driver_fops, 69 .fops = &i810_driver_fops,
diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
index 6e0acad9e0f5..c9339f481795 100644
--- a/drivers/gpu/drm/i810/i810_drv.h
+++ b/drivers/gpu/drm/i810/i810_drv.h
@@ -116,12 +116,14 @@ typedef struct drm_i810_private {
116 116
117 /* i810_dma.c */ 117 /* i810_dma.c */
118extern int i810_driver_dma_quiescent(struct drm_device *dev); 118extern int i810_driver_dma_quiescent(struct drm_device *dev);
119void i810_driver_reclaim_buffers(struct drm_device *dev, 119extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
120 struct drm_file *file_priv); 120 struct drm_file *file_priv);
121extern int i810_driver_load(struct drm_device *, unsigned long flags); 121extern int i810_driver_load(struct drm_device *, unsigned long flags);
122extern void i810_driver_lastclose(struct drm_device *dev); 122extern void i810_driver_lastclose(struct drm_device *dev);
123extern void i810_driver_preclose(struct drm_device *dev, 123extern void i810_driver_preclose(struct drm_device *dev,
124 struct drm_file *file_priv); 124 struct drm_file *file_priv);
125extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
126 struct drm_file *file_priv);
125extern int i810_driver_device_is_agp(struct drm_device *dev); 127extern int i810_driver_device_is_agp(struct drm_device *dev);
126 128
127extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 129extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.h b/drivers/gpu/drm/nouveau/nouveau_bios.h
index 1e382ad5a2b8..a37c31e358aa 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.h
@@ -54,9 +54,10 @@ struct bit_entry {
54int bit_table(struct drm_device *, u8 id, struct bit_entry *); 54int bit_table(struct drm_device *, u8 id, struct bit_entry *);
55 55
56enum dcb_gpio_tag { 56enum dcb_gpio_tag {
57 DCB_GPIO_TVDAC0 = 0xc, 57 DCB_GPIO_PANEL_POWER = 0x01,
58 DCB_GPIO_TVDAC0 = 0x0c,
58 DCB_GPIO_TVDAC1 = 0x2d, 59 DCB_GPIO_TVDAC1 = 0x2d,
59 DCB_GPIO_PWM_FAN = 0x9, 60 DCB_GPIO_PWM_FAN = 0x09,
60 DCB_GPIO_FAN_SENSE = 0x3d, 61 DCB_GPIO_FAN_SENSE = 0x3d,
61 DCB_GPIO_UNUSED = 0xff 62 DCB_GPIO_UNUSED = 0xff
62}; 63};
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 3cb52bc52b21..795a9e3c990a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -219,6 +219,16 @@ nouveau_display_init(struct drm_device *dev)
219 if (ret) 219 if (ret)
220 return ret; 220 return ret;
221 221
222 /* power on internal panel if it's not already. the init tables of
223 * some vbios default this to off for some reason, causing the
224 * panel to not work after resume
225 */
226 if (nouveau_gpio_func_get(dev, DCB_GPIO_PANEL_POWER) == 0) {
227 nouveau_gpio_func_set(dev, DCB_GPIO_PANEL_POWER, true);
228 msleep(300);
229 }
230
231 /* enable polling for external displays */
222 drm_kms_helper_poll_enable(dev); 232 drm_kms_helper_poll_enable(dev);
223 233
224 /* enable hotplug interrupts */ 234 /* enable hotplug interrupts */
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index e4a7cfe7898d..81d7962e7252 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -124,7 +124,7 @@ MODULE_PARM_DESC(ctxfw, "Use external HUB/GPC ucode (fermi)\n");
124int nouveau_ctxfw; 124int nouveau_ctxfw;
125module_param_named(ctxfw, nouveau_ctxfw, int, 0400); 125module_param_named(ctxfw, nouveau_ctxfw, int, 0400);
126 126
127MODULE_PARM_DESC(ctxfw, "Santise DCB table according to MXM-SIS\n"); 127MODULE_PARM_DESC(mxmdcb, "Santise DCB table according to MXM-SIS\n");
128int nouveau_mxmdcb = 1; 128int nouveau_mxmdcb = 1;
129module_param_named(mxmdcb, nouveau_mxmdcb, int, 0400); 129module_param_named(mxmdcb, nouveau_mxmdcb, int, 0400);
130 130
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 5f0bc57fdaab..7ce3fde40743 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -380,6 +380,25 @@ retry:
380} 380}
381 381
382static int 382static int
383validate_sync(struct nouveau_channel *chan, struct nouveau_bo *nvbo)
384{
385 struct nouveau_fence *fence = NULL;
386 int ret = 0;
387
388 spin_lock(&nvbo->bo.bdev->fence_lock);
389 if (nvbo->bo.sync_obj)
390 fence = nouveau_fence_ref(nvbo->bo.sync_obj);
391 spin_unlock(&nvbo->bo.bdev->fence_lock);
392
393 if (fence) {
394 ret = nouveau_fence_sync(fence, chan);
395 nouveau_fence_unref(&fence);
396 }
397
398 return ret;
399}
400
401static int
383validate_list(struct nouveau_channel *chan, struct list_head *list, 402validate_list(struct nouveau_channel *chan, struct list_head *list,
384 struct drm_nouveau_gem_pushbuf_bo *pbbo, uint64_t user_pbbo_ptr) 403 struct drm_nouveau_gem_pushbuf_bo *pbbo, uint64_t user_pbbo_ptr)
385{ 404{
@@ -393,7 +412,7 @@ validate_list(struct nouveau_channel *chan, struct list_head *list,
393 list_for_each_entry(nvbo, list, entry) { 412 list_for_each_entry(nvbo, list, entry) {
394 struct drm_nouveau_gem_pushbuf_bo *b = &pbbo[nvbo->pbbo_index]; 413 struct drm_nouveau_gem_pushbuf_bo *b = &pbbo[nvbo->pbbo_index];
395 414
396 ret = nouveau_fence_sync(nvbo->bo.sync_obj, chan); 415 ret = validate_sync(chan, nvbo);
397 if (unlikely(ret)) { 416 if (unlikely(ret)) {
398 NV_ERROR(dev, "fail pre-validate sync\n"); 417 NV_ERROR(dev, "fail pre-validate sync\n");
399 return ret; 418 return ret;
@@ -416,7 +435,7 @@ validate_list(struct nouveau_channel *chan, struct list_head *list,
416 return ret; 435 return ret;
417 } 436 }
418 437
419 ret = nouveau_fence_sync(nvbo->bo.sync_obj, chan); 438 ret = validate_sync(chan, nvbo);
420 if (unlikely(ret)) { 439 if (unlikely(ret)) {
421 NV_ERROR(dev, "fail post-validate sync\n"); 440 NV_ERROR(dev, "fail post-validate sync\n");
422 return ret; 441 return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_mxm.c b/drivers/gpu/drm/nouveau/nouveau_mxm.c
index 8bccddf4eff0..e5a64f0f4cb7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mxm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mxm.c
@@ -656,7 +656,16 @@ nouveau_mxm_init(struct drm_device *dev)
656 656
657 if (mxm_shadow(dev, mxm[0])) { 657 if (mxm_shadow(dev, mxm[0])) {
658 MXM_MSG(dev, "failed to locate valid SIS\n"); 658 MXM_MSG(dev, "failed to locate valid SIS\n");
659#if 0
660 /* we should, perhaps, fall back to some kind of limited
661 * mode here if the x86 vbios hasn't already done the
662 * work for us (so we prevent loading with completely
663 * whacked vbios tables).
664 */
659 return -EINVAL; 665 return -EINVAL;
666#else
667 return 0;
668#endif
660 } 669 }
661 670
662 MXM_MSG(dev, "MXMS Version %d.%d\n", 671 MXM_MSG(dev, "MXMS Version %d.%d\n",
diff --git a/drivers/gpu/drm/nouveau/nv50_pm.c b/drivers/gpu/drm/nouveau/nv50_pm.c
index 03937212e9d8..ec5481dfcd82 100644
--- a/drivers/gpu/drm/nouveau/nv50_pm.c
+++ b/drivers/gpu/drm/nouveau/nv50_pm.c
@@ -495,9 +495,9 @@ nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl)
495 struct drm_nouveau_private *dev_priv = dev->dev_private; 495 struct drm_nouveau_private *dev_priv = dev->dev_private;
496 struct nv50_pm_state *info; 496 struct nv50_pm_state *info;
497 struct pll_lims pll; 497 struct pll_lims pll;
498 int ret = -EINVAL; 498 int clk, ret = -EINVAL;
499 int N, M, P1, P2; 499 int N, M, P1, P2;
500 u32 clk, out; 500 u32 out;
501 501
502 if (dev_priv->chipset == 0xaa || 502 if (dev_priv->chipset == 0xaa ||
503 dev_priv->chipset == 0xac) 503 dev_priv->chipset == 0xac)
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 891935271d34..742f17f009a9 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1184,7 +1184,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
1184 WREG32(EVERGREEN_GRPH_ENABLE + radeon_crtc->crtc_offset, 1); 1184 WREG32(EVERGREEN_GRPH_ENABLE + radeon_crtc->crtc_offset, 1);
1185 1185
1186 WREG32(EVERGREEN_DESKTOP_HEIGHT + radeon_crtc->crtc_offset, 1186 WREG32(EVERGREEN_DESKTOP_HEIGHT + radeon_crtc->crtc_offset,
1187 crtc->mode.vdisplay); 1187 target_fb->height);
1188 x &= ~3; 1188 x &= ~3;
1189 y &= ~1; 1189 y &= ~1;
1190 WREG32(EVERGREEN_VIEWPORT_START + radeon_crtc->crtc_offset, 1190 WREG32(EVERGREEN_VIEWPORT_START + radeon_crtc->crtc_offset,
@@ -1353,7 +1353,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1353 WREG32(AVIVO_D1GRPH_ENABLE + radeon_crtc->crtc_offset, 1); 1353 WREG32(AVIVO_D1GRPH_ENABLE + radeon_crtc->crtc_offset, 1);
1354 1354
1355 WREG32(AVIVO_D1MODE_DESKTOP_HEIGHT + radeon_crtc->crtc_offset, 1355 WREG32(AVIVO_D1MODE_DESKTOP_HEIGHT + radeon_crtc->crtc_offset,
1356 crtc->mode.vdisplay); 1356 target_fb->height);
1357 x &= ~3; 1357 x &= ~3;
1358 y &= ~1; 1358 y &= ~1;
1359 WREG32(AVIVO_D1MODE_VIEWPORT_START + radeon_crtc->crtc_offset, 1359 WREG32(AVIVO_D1MODE_VIEWPORT_START + radeon_crtc->crtc_offset,
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index a71557ce01dc..552b436451fd 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -564,9 +564,21 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
564 ENCODER_OBJECT_ID_NUTMEG) 564 ENCODER_OBJECT_ID_NUTMEG)
565 panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE; 565 panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
566 else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) == 566 else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) ==
567 ENCODER_OBJECT_ID_TRAVIS) 567 ENCODER_OBJECT_ID_TRAVIS) {
568 panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; 568 u8 id[6];
569 else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 569 int i;
570 for (i = 0; i < 6; i++)
571 id[i] = radeon_read_dpcd_reg(radeon_connector, 0x503 + i);
572 if (id[0] == 0x73 &&
573 id[1] == 0x69 &&
574 id[2] == 0x76 &&
575 id[3] == 0x61 &&
576 id[4] == 0x72 &&
577 id[5] == 0x54)
578 panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
579 else
580 panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
581 } else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
570 u8 tmp = radeon_read_dpcd_reg(radeon_connector, DP_EDP_CONFIGURATION_CAP); 582 u8 tmp = radeon_read_dpcd_reg(radeon_connector, DP_EDP_CONFIGURATION_CAP);
571 if (tmp & 1) 583 if (tmp & 1)
572 panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; 584 panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c
index d996f4381130..accc032c103f 100644
--- a/drivers/gpu/drm/radeon/r600_blit_kms.c
+++ b/drivers/gpu/drm/radeon/r600_blit_kms.c
@@ -468,27 +468,42 @@ set_default_state(struct radeon_device *rdev)
468 radeon_ring_write(ring, sq_stack_resource_mgmt_2); 468 radeon_ring_write(ring, sq_stack_resource_mgmt_2);
469} 469}
470 470
471#define I2F_MAX_BITS 15
472#define I2F_MAX_INPUT ((1 << I2F_MAX_BITS) - 1)
473#define I2F_SHIFT (24 - I2F_MAX_BITS)
474
475/*
476 * Converts unsigned integer into 32-bit IEEE floating point representation.
477 * Conversion is not universal and only works for the range from 0
478 * to 2^I2F_MAX_BITS-1. Currently we only use it with inputs between
479 * 0 and 16384 (inclusive), so I2F_MAX_BITS=15 is enough. If necessary,
480 * I2F_MAX_BITS can be increased, but that will add to the loop iterations
481 * and slow us down. Conversion is done by shifting the input and counting
482 * down until the first 1 reaches bit position 23. The resulting counter
483 * and the shifted input are, respectively, the exponent and the fraction.
484 * The sign is always zero.
485 */
471static uint32_t i2f(uint32_t input) 486static uint32_t i2f(uint32_t input)
472{ 487{
473 u32 result, i, exponent, fraction; 488 u32 result, i, exponent, fraction;
474 489
475 if ((input & 0x3fff) == 0) 490 WARN_ON_ONCE(input > I2F_MAX_INPUT);
476 result = 0; /* 0 is a special case */ 491
492 if ((input & I2F_MAX_INPUT) == 0)
493 result = 0;
477 else { 494 else {
478 exponent = 140; /* exponent biased by 127; */ 495 exponent = 126 + I2F_MAX_BITS;
479 fraction = (input & 0x3fff) << 10; /* cheat and only 496 fraction = (input & I2F_MAX_INPUT) << I2F_SHIFT;
480 handle numbers below 2^^15 */ 497
481 for (i = 0; i < 14; i++) { 498 for (i = 0; i < I2F_MAX_BITS; i++) {
482 if (fraction & 0x800000) 499 if (fraction & 0x800000)
483 break; 500 break;
484 else { 501 else {
485 fraction = fraction << 1; /* keep 502 fraction = fraction << 1;
486 shifting left until top bit = 1 */
487 exponent = exponent - 1; 503 exponent = exponent - 1;
488 } 504 }
489 } 505 }
490 result = exponent << 23 | (fraction & 0x7fffff); /* mask 506 result = exponent << 23 | (fraction & 0x7fffff);
491 off top bit; assumed 1 */
492 } 507 }
493 return result; 508 return result;
494} 509}
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 13ac63ba6075..98724fcb0088 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -59,8 +59,9 @@ static int radeon_atrm_call(acpi_handle atrm_handle, uint8_t *bios,
59 59
60 obj = (union acpi_object *)buffer.pointer; 60 obj = (union acpi_object *)buffer.pointer;
61 memcpy(bios+offset, obj->buffer.pointer, obj->buffer.length); 61 memcpy(bios+offset, obj->buffer.pointer, obj->buffer.length);
62 len = obj->buffer.length;
62 kfree(buffer.pointer); 63 kfree(buffer.pointer);
63 return obj->buffer.length; 64 return len;
64} 65}
65 66
66bool radeon_atrm_supported(struct pci_dev *pdev) 67bool radeon_atrm_supported(struct pci_dev *pdev)
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index cec51a5b69dd..49f7cb7e226b 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -883,6 +883,8 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
883 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 883 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
884 return 0; 884 return 0;
885 885
886 drm_kms_helper_poll_disable(dev);
887
886 /* turn off display hw */ 888 /* turn off display hw */
887 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 889 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
888 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 890 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
@@ -972,6 +974,8 @@ int radeon_resume_kms(struct drm_device *dev)
972 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 974 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
973 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); 975 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
974 } 976 }
977
978 drm_kms_helper_poll_enable(dev);
975 return 0; 979 return 0;
976} 980}
977 981
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 7bb1b079f480..98a8ad680109 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -897,6 +897,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
897 i2c->rec = *rec; 897 i2c->rec = *rec;
898 i2c->adapter.owner = THIS_MODULE; 898 i2c->adapter.owner = THIS_MODULE;
899 i2c->adapter.class = I2C_CLASS_DDC; 899 i2c->adapter.class = I2C_CLASS_DDC;
900 i2c->adapter.dev.parent = &dev->pdev->dev;
900 i2c->dev = dev; 901 i2c->dev = dev;
901 i2c_set_adapdata(&i2c->adapter, i2c); 902 i2c_set_adapdata(&i2c->adapter, i2c);
902 if (rec->mm_i2c || 903 if (rec->mm_i2c ||
@@ -957,6 +958,7 @@ struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
957 i2c->rec = *rec; 958 i2c->rec = *rec;
958 i2c->adapter.owner = THIS_MODULE; 959 i2c->adapter.owner = THIS_MODULE;
959 i2c->adapter.class = I2C_CLASS_DDC; 960 i2c->adapter.class = I2C_CLASS_DDC;
961 i2c->adapter.dev.parent = &dev->pdev->dev;
960 i2c->dev = dev; 962 i2c->dev = dev;
961 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), 963 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
962 "Radeon aux bus %s", name); 964 "Radeon aux bus %s", name);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 0af6ebdf205d..b66ef0e3cde1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -378,7 +378,7 @@ int vmw_framebuffer_create_handle(struct drm_framebuffer *fb,
378 unsigned int *handle) 378 unsigned int *handle)
379{ 379{
380 if (handle) 380 if (handle)
381 handle = 0; 381 *handle = 0;
382 382
383 return 0; 383 return 0;
384} 384}
diff --git a/drivers/hid/hid-hyperv.c b/drivers/hid/hid-hyperv.c
index 0c33ae9cf0f0..406632472c1b 100644
--- a/drivers/hid/hid-hyperv.c
+++ b/drivers/hid/hid-hyperv.c
@@ -548,6 +548,7 @@ static int mousevsc_remove(struct hv_device *dev)
548 struct mousevsc_dev *input_dev = hv_get_drvdata(dev); 548 struct mousevsc_dev *input_dev = hv_get_drvdata(dev);
549 549
550 vmbus_close(dev->channel); 550 vmbus_close(dev->channel);
551 hid_hw_stop(input_dev->hid_device);
551 hid_destroy_device(input_dev->hid_device); 552 hid_destroy_device(input_dev->hid_device);
552 mousevsc_free_device(input_dev); 553 mousevsc_free_device(input_dev);
553 554
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index b47e58b52d9f..acab74cde727 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -531,7 +531,6 @@ static int wacom_probe(struct hid_device *hdev,
531 wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; 531 wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
532 wdata->battery.use_for_apm = 0; 532 wdata->battery.use_for_apm = 0;
533 533
534 power_supply_powers(&wdata->battery, &hdev->dev);
535 534
536 ret = power_supply_register(&hdev->dev, &wdata->battery); 535 ret = power_supply_register(&hdev->dev, &wdata->battery);
537 if (ret) { 536 if (ret) {
@@ -540,6 +539,8 @@ static int wacom_probe(struct hid_device *hdev,
540 goto err_battery; 539 goto err_battery;
541 } 540 }
542 541
542 power_supply_powers(&wdata->battery, &hdev->dev);
543
543 wdata->ac.properties = wacom_ac_props; 544 wdata->ac.properties = wacom_ac_props;
544 wdata->ac.num_properties = ARRAY_SIZE(wacom_ac_props); 545 wdata->ac.num_properties = ARRAY_SIZE(wacom_ac_props);
545 wdata->ac.get_property = wacom_ac_get_property; 546 wdata->ac.get_property = wacom_ac_get_property;
@@ -547,14 +548,14 @@ static int wacom_probe(struct hid_device *hdev,
547 wdata->ac.type = POWER_SUPPLY_TYPE_MAINS; 548 wdata->ac.type = POWER_SUPPLY_TYPE_MAINS;
548 wdata->ac.use_for_apm = 0; 549 wdata->ac.use_for_apm = 0;
549 550
550 power_supply_powers(&wdata->battery, &hdev->dev);
551
552 ret = power_supply_register(&hdev->dev, &wdata->ac); 551 ret = power_supply_register(&hdev->dev, &wdata->ac);
553 if (ret) { 552 if (ret) {
554 hid_warn(hdev, 553 hid_warn(hdev,
555 "can't create ac battery attribute, err: %d\n", ret); 554 "can't create ac battery attribute, err: %d\n", ret);
556 goto err_ac; 555 goto err_ac;
557 } 556 }
557
558 power_supply_powers(&wdata->ac, &hdev->dev);
558#endif 559#endif
559 return 0; 560 return 0;
560 561
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index fc253b472f9d..cac3589b1ed5 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -1226,14 +1226,14 @@ static int wiimote_hid_probe(struct hid_device *hdev,
1226 wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; 1226 wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
1227 wdata->battery.use_for_apm = 0; 1227 wdata->battery.use_for_apm = 0;
1228 1228
1229 power_supply_powers(&wdata->battery, &hdev->dev);
1230
1231 ret = power_supply_register(&wdata->hdev->dev, &wdata->battery); 1229 ret = power_supply_register(&wdata->hdev->dev, &wdata->battery);
1232 if (ret) { 1230 if (ret) {
1233 hid_err(hdev, "Cannot register battery device\n"); 1231 hid_err(hdev, "Cannot register battery device\n");
1234 goto err_battery; 1232 goto err_battery;
1235 } 1233 }
1236 1234
1235 power_supply_powers(&wdata->battery, &hdev->dev);
1236
1237 ret = wiimote_leds_create(wdata); 1237 ret = wiimote_leds_create(wdata);
1238 if (ret) 1238 if (ret)
1239 goto err_free; 1239 goto err_free;
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 7c297d305d5d..b1ec0e2aeb57 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -922,11 +922,11 @@ void hiddev_disconnect(struct hid_device *hid)
922 struct hiddev *hiddev = hid->hiddev; 922 struct hiddev *hiddev = hid->hiddev;
923 struct usbhid_device *usbhid = hid->driver_data; 923 struct usbhid_device *usbhid = hid->driver_data;
924 924
925 usb_deregister_dev(usbhid->intf, &hiddev_class);
926
925 mutex_lock(&hiddev->existancelock); 927 mutex_lock(&hiddev->existancelock);
926 hiddev->exist = 0; 928 hiddev->exist = 0;
927 929
928 usb_deregister_dev(usbhid->intf, &hiddev_class);
929
930 if (hiddev->open) { 930 if (hiddev->open) {
931 mutex_unlock(&hiddev->existancelock); 931 mutex_unlock(&hiddev->existancelock);
932 usbhid_close(hiddev->hid); 932 usbhid_close(hiddev->hid);
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index 92f949767ece..6dbfd3e516e4 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -283,11 +283,11 @@ static inline long temp_from_reg(u8 reg)
283 283
284static inline u8 temp_to_reg(long val) 284static inline u8 temp_to_reg(long val)
285{ 285{
286 if (val < 0) 286 if (val <= 0)
287 val = 0; 287 return 0;
288 else if (val > 1000 * 0xff) 288 if (val >= 1000 * 0xff)
289 val = 0xff; 289 return 0xff;
290 return ((val + 500) / 1000); 290 return (val + 500) / 1000;
291} 291}
292 292
293/* 293/*
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index 6ddeae049058..91fdd1fe18b0 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -883,7 +883,7 @@ static int sht15_invalidate_voltage(struct notifier_block *nb,
883 883
884static int __devinit sht15_probe(struct platform_device *pdev) 884static int __devinit sht15_probe(struct platform_device *pdev)
885{ 885{
886 int ret = 0; 886 int ret;
887 struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL); 887 struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL);
888 u8 status = 0; 888 u8 status = 0;
889 889
@@ -901,6 +901,7 @@ static int __devinit sht15_probe(struct platform_device *pdev)
901 init_waitqueue_head(&data->wait_queue); 901 init_waitqueue_head(&data->wait_queue);
902 902
903 if (pdev->dev.platform_data == NULL) { 903 if (pdev->dev.platform_data == NULL) {
904 ret = -EINVAL;
904 dev_err(&pdev->dev, "no platform data supplied\n"); 905 dev_err(&pdev->dev, "no platform data supplied\n");
905 goto err_free_data; 906 goto err_free_data;
906 } 907 }
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 0e0af0445222..4d383e7e051d 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1319,6 +1319,7 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
1319{ 1319{
1320 struct w83627ehf_data *data = dev_get_drvdata(dev); 1320 struct w83627ehf_data *data = dev_get_drvdata(dev);
1321 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 1321 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1322 struct w83627ehf_sio_data *sio_data = dev->platform_data;
1322 int nr = sensor_attr->index; 1323 int nr = sensor_attr->index;
1323 unsigned long val; 1324 unsigned long val;
1324 int err; 1325 int err;
@@ -1330,6 +1331,11 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
1330 1331
1331 if (val > 1) 1332 if (val > 1)
1332 return -EINVAL; 1333 return -EINVAL;
1334
1335 /* On NCT67766F, DC mode is only supported for pwm1 */
1336 if (sio_data->kind == nct6776 && nr && val != 1)
1337 return -EINVAL;
1338
1333 mutex_lock(&data->update_lock); 1339 mutex_lock(&data->update_lock);
1334 reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]); 1340 reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]);
1335 data->pwm_mode[nr] = val; 1341 data->pwm_mode[nr] = val;
@@ -1914,9 +1920,26 @@ w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data,
1914 fan4min = 0; 1920 fan4min = 0;
1915 fan5pin = 0; 1921 fan5pin = 0;
1916 } else if (sio_data->kind == nct6776) { 1922 } else if (sio_data->kind == nct6776) {
1917 fan3pin = !(superio_inb(sio_data->sioreg, 0x24) & 0x40); 1923 bool gpok = superio_inb(sio_data->sioreg, 0x27) & 0x80;
1918 fan4pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x01); 1924
1919 fan5pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x02); 1925 superio_select(sio_data->sioreg, W83627EHF_LD_HWM);
1926 regval = superio_inb(sio_data->sioreg, SIO_REG_ENABLE);
1927
1928 if (regval & 0x80)
1929 fan3pin = gpok;
1930 else
1931 fan3pin = !(superio_inb(sio_data->sioreg, 0x24) & 0x40);
1932
1933 if (regval & 0x40)
1934 fan4pin = gpok;
1935 else
1936 fan4pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x01);
1937
1938 if (regval & 0x20)
1939 fan5pin = gpok;
1940 else
1941 fan5pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x02);
1942
1920 fan4min = fan4pin; 1943 fan4min = fan4pin;
1921 } else if (sio_data->kind == w83667hg || sio_data->kind == w83667hg_b) { 1944 } else if (sio_data->kind == w83667hg || sio_data->kind == w83667hg_b) {
1922 fan3pin = 1; 1945 fan3pin = 1;
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index b37b0c02a7b9..5034a87cc72d 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -808,9 +808,12 @@ static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
808 return PTR_ERR(ctx); 808 return PTR_ERR(ctx);
809 809
810 if (cmd.conn_param.valid) { 810 if (cmd.conn_param.valid) {
811 ctx->uid = cmd.uid;
812 ucma_copy_conn_param(&conn_param, &cmd.conn_param); 811 ucma_copy_conn_param(&conn_param, &cmd.conn_param);
812 mutex_lock(&file->mut);
813 ret = rdma_accept(ctx->cm_id, &conn_param); 813 ret = rdma_accept(ctx->cm_id, &conn_param);
814 if (!ret)
815 ctx->uid = cmd.uid;
816 mutex_unlock(&file->mut);
814 } else 817 } else
815 ret = rdma_accept(ctx->cm_id, NULL); 818 ret = rdma_accept(ctx->cm_id, NULL);
816 819
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index b930da4c0c63..4d27e4c3fe34 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1485,6 +1485,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
1485 qp->event_handler = attr.event_handler; 1485 qp->event_handler = attr.event_handler;
1486 qp->qp_context = attr.qp_context; 1486 qp->qp_context = attr.qp_context;
1487 qp->qp_type = attr.qp_type; 1487 qp->qp_type = attr.qp_type;
1488 atomic_set(&qp->usecnt, 0);
1488 atomic_inc(&pd->usecnt); 1489 atomic_inc(&pd->usecnt);
1489 atomic_inc(&attr.send_cq->usecnt); 1490 atomic_inc(&attr.send_cq->usecnt);
1490 if (attr.recv_cq) 1491 if (attr.recv_cq)
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 602b1bd723a9..575b78045aaf 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -421,6 +421,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
421 qp->uobject = NULL; 421 qp->uobject = NULL;
422 qp->qp_type = qp_init_attr->qp_type; 422 qp->qp_type = qp_init_attr->qp_type;
423 423
424 atomic_set(&qp->usecnt, 0);
424 if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) { 425 if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) {
425 qp->event_handler = __ib_shared_qp_event_handler; 426 qp->event_handler = __ib_shared_qp_event_handler;
426 qp->qp_context = qp; 427 qp->qp_context = qp;
@@ -430,7 +431,6 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
430 qp->xrcd = qp_init_attr->xrcd; 431 qp->xrcd = qp_init_attr->xrcd;
431 atomic_inc(&qp_init_attr->xrcd->usecnt); 432 atomic_inc(&qp_init_attr->xrcd->usecnt);
432 INIT_LIST_HEAD(&qp->open_list); 433 INIT_LIST_HEAD(&qp->open_list);
433 atomic_set(&qp->usecnt, 0);
434 434
435 real_qp = qp; 435 real_qp = qp;
436 qp = __ib_open_qp(real_qp, qp_init_attr->event_handler, 436 qp = __ib_open_qp(real_qp, qp_init_attr->event_handler,
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index b7d4216db3c3..a4de9d58e9b4 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -89,7 +89,7 @@ static int create_file(const char *name, umode_t mode,
89 error = ipathfs_mknod(parent->d_inode, *dentry, 89 error = ipathfs_mknod(parent->d_inode, *dentry,
90 mode, fops, data); 90 mode, fops, data);
91 else 91 else
92 error = PTR_ERR(dentry); 92 error = PTR_ERR(*dentry);
93 mutex_unlock(&parent->d_inode->i_mutex); 93 mutex_unlock(&parent->d_inode->i_mutex);
94 94
95 return error; 95 return error;
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 95c94d8f0254..259b0670b51c 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -257,12 +257,9 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
257 return IB_MAD_RESULT_SUCCESS; 257 return IB_MAD_RESULT_SUCCESS;
258 258
259 /* 259 /*
260 * Don't process SMInfo queries or vendor-specific 260 * Don't process SMInfo queries -- the SMA can't handle them.
261 * MADs -- the SMA can't handle them.
262 */ 261 */
263 if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO || 262 if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO)
264 ((in_mad->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==
265 IB_SMP_ATTR_VENDOR_MASK))
266 return IB_MAD_RESULT_SUCCESS; 263 return IB_MAD_RESULT_SUCCESS;
267 } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT || 264 } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
268 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS1 || 265 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS1 ||
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 7013da5e9eda..7140199f562e 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved. 3 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 568b4f11380a..c438e4691b3c 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved. 3 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 425065b36b8c..a4972abedef1 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -233,6 +233,7 @@ static int send_mpa_reject(struct nes_cm_node *cm_node)
233 u8 *start_ptr = &start_addr; 233 u8 *start_ptr = &start_addr;
234 u8 **start_buff = &start_ptr; 234 u8 **start_buff = &start_ptr;
235 u16 buff_len = 0; 235 u16 buff_len = 0;
236 struct ietf_mpa_v1 *mpa_frame;
236 237
237 skb = dev_alloc_skb(MAX_CM_BUFFER); 238 skb = dev_alloc_skb(MAX_CM_BUFFER);
238 if (!skb) { 239 if (!skb) {
@@ -242,6 +243,8 @@ static int send_mpa_reject(struct nes_cm_node *cm_node)
242 243
243 /* send an MPA reject frame */ 244 /* send an MPA reject frame */
244 cm_build_mpa_frame(cm_node, start_buff, &buff_len, NULL, MPA_KEY_REPLY); 245 cm_build_mpa_frame(cm_node, start_buff, &buff_len, NULL, MPA_KEY_REPLY);
246 mpa_frame = (struct ietf_mpa_v1 *)*start_buff;
247 mpa_frame->flags |= IETF_MPA_FLAGS_REJECT;
245 form_cm_frame(skb, cm_node, NULL, 0, *start_buff, buff_len, SET_ACK | SET_FIN); 248 form_cm_frame(skb, cm_node, NULL, 0, *start_buff, buff_len, SET_ACK | SET_FIN);
246 249
247 cm_node->state = NES_CM_STATE_FIN_WAIT1; 250 cm_node->state = NES_CM_STATE_FIN_WAIT1;
@@ -1360,8 +1363,7 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
1360 if (!memcmp(nesadapter->arp_table[arpindex].mac_addr, 1363 if (!memcmp(nesadapter->arp_table[arpindex].mac_addr,
1361 neigh->ha, ETH_ALEN)) { 1364 neigh->ha, ETH_ALEN)) {
1362 /* Mac address same as in nes_arp_table */ 1365 /* Mac address same as in nes_arp_table */
1363 ip_rt_put(rt); 1366 goto out;
1364 return rc;
1365 } 1367 }
1366 1368
1367 nes_manage_arp_cache(nesvnic->netdev, 1369 nes_manage_arp_cache(nesvnic->netdev,
@@ -1377,6 +1379,8 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
1377 neigh_event_send(neigh, NULL); 1379 neigh_event_send(neigh, NULL);
1378 } 1380 }
1379 } 1381 }
1382
1383out:
1380 rcu_read_unlock(); 1384 rcu_read_unlock();
1381 ip_rt_put(rt); 1385 ip_rt_put(rt);
1382 return rc; 1386 return rc;
diff --git a/drivers/infiniband/hw/nes/nes_cm.h b/drivers/infiniband/hw/nes/nes_cm.h
index bdfa1fbb35fc..4646e6666087 100644
--- a/drivers/infiniband/hw/nes/nes_cm.h
+++ b/drivers/infiniband/hw/nes/nes_cm.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/nes/nes_context.h b/drivers/infiniband/hw/nes/nes_context.h
index b4393a16099d..a69eef16d72d 100644
--- a/drivers/infiniband/hw/nes/nes_context.h
+++ b/drivers/infiniband/hw/nes/nes_context.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 055f4b545df0..d42c9f435b1b 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
index 0b590e152c6a..d748e4b31b8d 100644
--- a/drivers/infiniband/hw/nes/nes_hw.h
+++ b/drivers/infiniband/hw/nes/nes_hw.h
@@ -1,5 +1,5 @@
1/* 1/*
2* Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2* Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3* 3*
4* This software is available to you under a choice of one of two 4* This software is available to you under a choice of one of two
5* licenses. You may choose to be licensed under the terms of the GNU 5* licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
index b3b2a240c6e9..3ba7be369452 100644
--- a/drivers/infiniband/hw/nes/nes_mgt.c
+++ b/drivers/infiniband/hw/nes/nes_mgt.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel-NE, Inc. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel-NE, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/nes/nes_mgt.h b/drivers/infiniband/hw/nes/nes_mgt.h
index 8c8af254555a..4f7f701c4a81 100644
--- a/drivers/infiniband/hw/nes/nes_mgt.h
+++ b/drivers/infiniband/hw/nes/nes_mgt.h
@@ -1,5 +1,5 @@
1/* 1/*
2* Copyright (c) 2010 Intel-NE, Inc. All rights reserved. 2* Copyright (c) 2006 - 2011 Intel-NE, Inc. All rights reserved.
3* 3*
4* This software is available to you under a choice of one of two 4* This software is available to you under a choice of one of two
5* licenses. You may choose to be licensed under the terms of the GNU 5* licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index 4b3fa711a247..f3a3ecf8d09e 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/nes/nes_user.h b/drivers/infiniband/hw/nes/nes_user.h
index 71e133ab209b..4926de744488 100644
--- a/drivers/infiniband/hw/nes/nes_user.h
+++ b/drivers/infiniband/hw/nes/nes_user.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * Copyright (c) 2005 Topspin Communications. All rights reserved. 3 * Copyright (c) 2005 Topspin Communications. All rights reserved.
4 * Copyright (c) 2005 Cisco Systems. All rights reserved. 4 * Copyright (c) 2005 Cisco Systems. All rights reserved.
5 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved. 5 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index 8b4c2ff54888..e98f4fc0b768 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 5095bc41c6cc..0927b5cc65d3 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -3428,6 +3428,8 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
3428 NES_IWARP_SQ_FMR_WQE_LENGTH_LOW_IDX, 3428 NES_IWARP_SQ_FMR_WQE_LENGTH_LOW_IDX,
3429 ib_wr->wr.fast_reg.length); 3429 ib_wr->wr.fast_reg.length);
3430 set_wqe_32bit_value(wqe->wqe_words, 3430 set_wqe_32bit_value(wqe->wqe_words,
3431 NES_IWARP_SQ_FMR_WQE_LENGTH_HIGH_IDX, 0);
3432 set_wqe_32bit_value(wqe->wqe_words,
3431 NES_IWARP_SQ_FMR_WQE_MR_STAG_IDX, 3433 NES_IWARP_SQ_FMR_WQE_MR_STAG_IDX,
3432 ib_wr->wr.fast_reg.rkey); 3434 ib_wr->wr.fast_reg.rkey);
3433 /* Set page size: */ 3435 /* Set page size: */
@@ -3724,7 +3726,7 @@ static int nes_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry)
3724 entry->opcode = IB_WC_SEND; 3726 entry->opcode = IB_WC_SEND;
3725 break; 3727 break;
3726 case NES_IWARP_SQ_OP_LOCINV: 3728 case NES_IWARP_SQ_OP_LOCINV:
3727 entry->opcode = IB_WR_LOCAL_INV; 3729 entry->opcode = IB_WC_LOCAL_INV;
3728 break; 3730 break;
3729 case NES_IWARP_SQ_OP_FAST_REG: 3731 case NES_IWARP_SQ_OP_FAST_REG:
3730 entry->opcode = IB_WC_FAST_REG_MR; 3732 entry->opcode = IB_WC_FAST_REG_MR;
diff --git a/drivers/infiniband/hw/nes/nes_verbs.h b/drivers/infiniband/hw/nes/nes_verbs.h
index fe6b6e92fa90..0eff7c44d76b 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.h
+++ b/drivers/infiniband/hw/nes/nes_verbs.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 - 2011 Intel Corporation. All rights reserved.
3 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved. 3 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c
index 4f18e2d332df..d0c64d514813 100644
--- a/drivers/infiniband/hw/qib/qib_iba6120.c
+++ b/drivers/infiniband/hw/qib/qib_iba6120.c
@@ -2105,7 +2105,7 @@ static void alloc_dummy_hdrq(struct qib_devdata *dd)
2105 dd->cspec->dummy_hdrq = dma_alloc_coherent(&dd->pcidev->dev, 2105 dd->cspec->dummy_hdrq = dma_alloc_coherent(&dd->pcidev->dev,
2106 dd->rcd[0]->rcvhdrq_size, 2106 dd->rcd[0]->rcvhdrq_size,
2107 &dd->cspec->dummy_hdrq_phys, 2107 &dd->cspec->dummy_hdrq_phys,
2108 GFP_KERNEL | __GFP_COMP); 2108 GFP_ATOMIC | __GFP_COMP);
2109 if (!dd->cspec->dummy_hdrq) { 2109 if (!dd->cspec->dummy_hdrq) {
2110 qib_devinfo(dd->pcidev, "Couldn't allocate dummy hdrq\n"); 2110 qib_devinfo(dd->pcidev, "Couldn't allocate dummy hdrq\n");
2111 /* fallback to just 0'ing */ 2111 /* fallback to just 0'ing */
diff --git a/drivers/infiniband/hw/qib/qib_pcie.c b/drivers/infiniband/hw/qib/qib_pcie.c
index f695061d688e..0fde788e1100 100644
--- a/drivers/infiniband/hw/qib/qib_pcie.c
+++ b/drivers/infiniband/hw/qib/qib_pcie.c
@@ -560,7 +560,7 @@ static int qib_tune_pcie_coalesce(struct qib_devdata *dd)
560 * BIOS may not set PCIe bus-utilization parameters for best performance. 560 * BIOS may not set PCIe bus-utilization parameters for best performance.
561 * Check and optionally adjust them to maximize our throughput. 561 * Check and optionally adjust them to maximize our throughput.
562 */ 562 */
563static int qib_pcie_caps = 0x51; 563static int qib_pcie_caps;
564module_param_named(pcie_caps, qib_pcie_caps, int, S_IRUGO); 564module_param_named(pcie_caps, qib_pcie_caps, int, S_IRUGO);
565MODULE_PARM_DESC(pcie_caps, "Max PCIe tuning: Payload (0..3), ReadReq (4..7)"); 565MODULE_PARM_DESC(pcie_caps, "Max PCIe tuning: Payload (0..3), ReadReq (4..7)");
566 566
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index cd5d05e22a77..2b73d43cd691 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -69,8 +69,8 @@ MODULE_LICENSE("Dual BSD/GPL");
69 */ 69 */
70 70
71static u64 srpt_service_guid; 71static u64 srpt_service_guid;
72static spinlock_t srpt_dev_lock; /* Protects srpt_dev_list. */ 72static DEFINE_SPINLOCK(srpt_dev_lock); /* Protects srpt_dev_list. */
73static struct list_head srpt_dev_list; /* List of srpt_device structures. */ 73static LIST_HEAD(srpt_dev_list); /* List of srpt_device structures. */
74 74
75static unsigned srp_max_req_size = DEFAULT_MAX_REQ_SIZE; 75static unsigned srp_max_req_size = DEFAULT_MAX_REQ_SIZE;
76module_param(srp_max_req_size, int, 0444); 76module_param(srp_max_req_size, int, 0444);
@@ -687,6 +687,7 @@ err:
687 while (--i >= 0) 687 while (--i >= 0)
688 srpt_free_ioctx(sdev, ring[i], dma_size, dir); 688 srpt_free_ioctx(sdev, ring[i], dma_size, dir);
689 kfree(ring); 689 kfree(ring);
690 ring = NULL;
690out: 691out:
691 return ring; 692 return ring;
692} 693}
@@ -2595,7 +2596,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
2595 } 2596 }
2596 2597
2597 ch->sess = transport_init_session(); 2598 ch->sess = transport_init_session();
2598 if (!ch->sess) { 2599 if (IS_ERR(ch->sess)) {
2599 rej->reason = __constant_cpu_to_be32( 2600 rej->reason = __constant_cpu_to_be32(
2600 SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES); 2601 SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
2601 pr_debug("Failed to create session\n"); 2602 pr_debug("Failed to create session\n");
@@ -3264,8 +3265,7 @@ static void srpt_add_one(struct ib_device *device)
3264 for (i = 0; i < sdev->srq_size; ++i) 3265 for (i = 0; i < sdev->srq_size; ++i)
3265 srpt_post_recv(sdev, sdev->ioctx_ring[i]); 3266 srpt_post_recv(sdev, sdev->ioctx_ring[i]);
3266 3267
3267 WARN_ON(sdev->device->phys_port_cnt 3268 WARN_ON(sdev->device->phys_port_cnt > ARRAY_SIZE(sdev->port));
3268 > sizeof(sdev->port)/sizeof(sdev->port[0]));
3269 3269
3270 for (i = 1; i <= sdev->device->phys_port_cnt; i++) { 3270 for (i = 1; i <= sdev->device->phys_port_cnt; i++) {
3271 sport = &sdev->port[i - 1]; 3271 sport = &sdev->port[i - 1];
@@ -4010,13 +4010,10 @@ static int __init srpt_init_module(void)
4010 goto out; 4010 goto out;
4011 } 4011 }
4012 4012
4013 spin_lock_init(&srpt_dev_lock);
4014 INIT_LIST_HEAD(&srpt_dev_list);
4015
4016 ret = -ENODEV;
4017 srpt_target = target_fabric_configfs_init(THIS_MODULE, "srpt"); 4013 srpt_target = target_fabric_configfs_init(THIS_MODULE, "srpt");
4018 if (!srpt_target) { 4014 if (IS_ERR(srpt_target)) {
4019 printk(KERN_ERR "couldn't register\n"); 4015 printk(KERN_ERR "couldn't register\n");
4016 ret = PTR_ERR(srpt_target);
4020 goto out; 4017 goto out;
4021 } 4018 }
4022 4019
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h
index b4b4bbcd7f16..61e52b830816 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -35,7 +35,6 @@
35#ifndef IB_SRPT_H 35#ifndef IB_SRPT_H
36#define IB_SRPT_H 36#define IB_SRPT_H
37 37
38#include <linux/version.h>
39#include <linux/types.h> 38#include <linux/types.h>
40#include <linux/list.h> 39#include <linux/list.h>
41#include <linux/wait.h> 40#include <linux/wait.h>
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 76457d50bc34..afc166fcc3d9 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -386,7 +386,7 @@ static ssize_t evdev_read(struct file *file, char __user *buffer,
386 struct evdev_client *client = file->private_data; 386 struct evdev_client *client = file->private_data;
387 struct evdev *evdev = client->evdev; 387 struct evdev *evdev = client->evdev;
388 struct input_event event; 388 struct input_event event;
389 int retval; 389 int retval = 0;
390 390
391 if (count < input_event_size()) 391 if (count < input_event_size())
392 return -EINVAL; 392 return -EINVAL;
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index a588578037eb..67bec14e8b96 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -34,7 +34,6 @@
34#include <linux/i2c/twl.h> 34#include <linux/i2c/twl.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36 36
37
38/* 37/*
39 * The TWL4030 family chips include a keypad controller that supports 38 * The TWL4030 family chips include a keypad controller that supports
40 * up to an 8x8 switch matrix. The controller can issue system wakeup 39 * up to an 8x8 switch matrix. The controller can issue system wakeup
@@ -302,7 +301,7 @@ static int __devinit twl4030_kp_program(struct twl4030_keypad *kp)
302 if (twl4030_kpwrite_u8(kp, i, KEYP_DEB) < 0) 301 if (twl4030_kpwrite_u8(kp, i, KEYP_DEB) < 0)
303 return -EIO; 302 return -EIO;
304 303
305 /* Set timeout period to 100 ms */ 304 /* Set timeout period to 200 ms */
306 i = KEYP_PERIOD_US(200000, PTV_PRESCALER); 305 i = KEYP_PERIOD_US(200000, PTV_PRESCALER);
307 if (twl4030_kpwrite_u8(kp, (i & 0xFF), KEYP_TIMEOUT_L) < 0) 306 if (twl4030_kpwrite_u8(kp, (i & 0xFF), KEYP_TIMEOUT_L) < 0)
308 return -EIO; 307 return -EIO;
@@ -466,4 +465,3 @@ MODULE_AUTHOR("Texas Instruments");
466MODULE_DESCRIPTION("TWL4030 Keypad Driver"); 465MODULE_DESCRIPTION("TWL4030 Keypad Driver");
467MODULE_LICENSE("GPL"); 466MODULE_LICENSE("GPL");
468MODULE_ALIAS("platform:twl4030_keypad"); 467MODULE_ALIAS("platform:twl4030_keypad");
469
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index b4cfc6c8be89..5ec774d6c82b 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -512,6 +512,13 @@ static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = {
512 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"), 512 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"),
513 }, 513 },
514 }, 514 },
515 {
516 /* Lenovo Ideapad U455 */
517 .matches = {
518 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
519 DMI_MATCH(DMI_PRODUCT_NAME, "20046"),
520 },
521 },
515 { } 522 { }
516}; 523};
517 524
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 8250299fd64f..4494233d331a 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -164,7 +164,8 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer,
164 struct serio_raw_client *client = file->private_data; 164 struct serio_raw_client *client = file->private_data;
165 struct serio_raw *serio_raw = client->serio_raw; 165 struct serio_raw *serio_raw = client->serio_raw;
166 char uninitialized_var(c); 166 char uninitialized_var(c);
167 ssize_t retval = 0; 167 ssize_t read = 0;
168 int retval;
168 169
169 if (serio_raw->dead) 170 if (serio_raw->dead)
170 return -ENODEV; 171 return -ENODEV;
@@ -180,13 +181,15 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer,
180 if (serio_raw->dead) 181 if (serio_raw->dead)
181 return -ENODEV; 182 return -ENODEV;
182 183
183 while (retval < count && serio_raw_fetch_byte(serio_raw, &c)) { 184 while (read < count && serio_raw_fetch_byte(serio_raw, &c)) {
184 if (put_user(c, buffer++)) 185 if (put_user(c, buffer++)) {
185 return -EFAULT; 186 retval = -EFAULT;
186 retval++; 187 break;
188 }
189 read++;
187 } 190 }
188 191
189 return retval; 192 return read ?: retval;
190} 193}
191 194
192static ssize_t serio_raw_write(struct file *file, const char __user *buffer, 195static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index cce1f03b8895..f75e0608be5b 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2863,6 +2863,9 @@ static unsigned device_dma_ops_init(void)
2863 2863
2864 for_each_pci_dev(pdev) { 2864 for_each_pci_dev(pdev) {
2865 if (!check_device(&pdev->dev)) { 2865 if (!check_device(&pdev->dev)) {
2866
2867 iommu_ignore_device(&pdev->dev);
2868
2866 unhandled += 1; 2869 unhandled += 1;
2867 continue; 2870 continue;
2868 } 2871 }
diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 08a90b88e40d..cee307e86606 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -482,23 +482,19 @@ static size_t msm_iommu_unmap(struct iommu_domain *domain, unsigned long va,
482 482
483 priv = domain->priv; 483 priv = domain->priv;
484 484
485 if (!priv) { 485 if (!priv)
486 ret = -ENODEV;
487 goto fail; 486 goto fail;
488 }
489 487
490 fl_table = priv->pgtable; 488 fl_table = priv->pgtable;
491 489
492 if (len != SZ_16M && len != SZ_1M && 490 if (len != SZ_16M && len != SZ_1M &&
493 len != SZ_64K && len != SZ_4K) { 491 len != SZ_64K && len != SZ_4K) {
494 pr_debug("Bad length: %d\n", len); 492 pr_debug("Bad length: %d\n", len);
495 ret = -EINVAL;
496 goto fail; 493 goto fail;
497 } 494 }
498 495
499 if (!fl_table) { 496 if (!fl_table) {
500 pr_debug("Null page table\n"); 497 pr_debug("Null page table\n");
501 ret = -EINVAL;
502 goto fail; 498 goto fail;
503 } 499 }
504 500
@@ -507,7 +503,6 @@ static size_t msm_iommu_unmap(struct iommu_domain *domain, unsigned long va,
507 503
508 if (*fl_pte == 0) { 504 if (*fl_pte == 0) {
509 pr_debug("First level PTE is 0\n"); 505 pr_debug("First level PTE is 0\n");
510 ret = -ENODEV;
511 goto fail; 506 goto fail;
512 } 507 }
513 508
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
index 45e6878d7374..e59c166a0ce2 100644
--- a/drivers/leds/leds-lm3530.c
+++ b/drivers/leds/leds-lm3530.c
@@ -164,8 +164,8 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
164 164
165 if (drvdata->mode == LM3530_BL_MODE_ALS) { 165 if (drvdata->mode == LM3530_BL_MODE_ALS) {
166 if (pltfm->als_vmax == 0) { 166 if (pltfm->als_vmax == 0) {
167 pltfm->als_vmin = als_vmin = 0; 167 pltfm->als_vmin = 0;
168 pltfm->als_vmin = als_vmax = LM3530_ALS_WINDOW_mV; 168 pltfm->als_vmax = LM3530_ALS_WINDOW_mV;
169 } 169 }
170 170
171 als_vmin = pltfm->als_vmin; 171 als_vmin = pltfm->als_vmin;
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index c2907d836e4e..86cb7e5d83d5 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -56,7 +56,8 @@ struct raid_dev {
56struct raid_set { 56struct raid_set {
57 struct dm_target *ti; 57 struct dm_target *ti;
58 58
59 uint64_t print_flags; 59 uint32_t bitmap_loaded;
60 uint32_t print_flags;
60 61
61 struct mddev md; 62 struct mddev md;
62 struct raid_type *raid_type; 63 struct raid_type *raid_type;
@@ -1085,7 +1086,7 @@ static int raid_status(struct dm_target *ti, status_type_t type,
1085 raid_param_cnt += 2; 1086 raid_param_cnt += 2;
1086 } 1087 }
1087 1088
1088 raid_param_cnt += (hweight64(rs->print_flags & ~DMPF_REBUILD) * 2); 1089 raid_param_cnt += (hweight32(rs->print_flags & ~DMPF_REBUILD) * 2);
1089 if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC)) 1090 if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC))
1090 raid_param_cnt--; 1091 raid_param_cnt--;
1091 1092
@@ -1197,7 +1198,12 @@ static void raid_resume(struct dm_target *ti)
1197{ 1198{
1198 struct raid_set *rs = ti->private; 1199 struct raid_set *rs = ti->private;
1199 1200
1200 bitmap_load(&rs->md); 1201 if (!rs->bitmap_loaded) {
1202 bitmap_load(&rs->md);
1203 rs->bitmap_loaded = 1;
1204 } else
1205 md_wakeup_thread(rs->md.thread);
1206
1201 mddev_resume(&rs->md); 1207 mddev_resume(&rs->md);
1202} 1208}
1203 1209
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9417ae2fa0bb..ce88755baf4a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7333,7 +7333,8 @@ void md_do_sync(struct mddev *mddev)
7333 printk(KERN_INFO 7333 printk(KERN_INFO
7334 "md: checkpointing %s of %s.\n", 7334 "md: checkpointing %s of %s.\n",
7335 desc, mdname(mddev)); 7335 desc, mdname(mddev));
7336 mddev->recovery_cp = mddev->curr_resync; 7336 mddev->recovery_cp =
7337 mddev->curr_resync_completed;
7337 } 7338 }
7338 } else 7339 } else
7339 mddev->recovery_cp = MaxSector; 7340 mddev->recovery_cp = MaxSector;
@@ -7351,9 +7352,9 @@ void md_do_sync(struct mddev *mddev)
7351 rcu_read_unlock(); 7352 rcu_read_unlock();
7352 } 7353 }
7353 } 7354 }
7355 skip:
7354 set_bit(MD_CHANGE_DEVS, &mddev->flags); 7356 set_bit(MD_CHANGE_DEVS, &mddev->flags);
7355 7357
7356 skip:
7357 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) { 7358 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {
7358 /* We completed so min/max setting can be forgotten if used. */ 7359 /* We completed so min/max setting can be forgotten if used. */
7359 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) 7360 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index dda86293dc9f..b2d8e512d3cb 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -282,6 +282,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
282 /* Default PLL configuration after power up */ 282 /* Default PLL configuration after power up */
283 twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL; 283 twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;
284 twl6040->sysclk = 19200000; 284 twl6040->sysclk = 19200000;
285 twl6040->mclk = 32768;
285 } else { 286 } else {
286 /* already powered-down */ 287 /* already powered-down */
287 if (!twl6040->power_count) { 288 if (!twl6040->power_count) {
@@ -305,6 +306,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
305 twl6040_power_down(twl6040); 306 twl6040_power_down(twl6040);
306 } 307 }
307 twl6040->sysclk = 0; 308 twl6040->sysclk = 0;
309 twl6040->mclk = 0;
308 } 310 }
309 311
310out: 312out:
@@ -324,23 +326,38 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
324 hppllctl = twl6040_reg_read(twl6040, TWL6040_REG_HPPLLCTL); 326 hppllctl = twl6040_reg_read(twl6040, TWL6040_REG_HPPLLCTL);
325 lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL); 327 lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL);
326 328
329 /* Force full reconfiguration when switching between PLL */
330 if (pll_id != twl6040->pll) {
331 twl6040->sysclk = 0;
332 twl6040->mclk = 0;
333 }
334
327 switch (pll_id) { 335 switch (pll_id) {
328 case TWL6040_SYSCLK_SEL_LPPLL: 336 case TWL6040_SYSCLK_SEL_LPPLL:
329 /* low-power PLL divider */ 337 /* low-power PLL divider */
330 switch (freq_out) { 338 /* Change the sysclk configuration only if it has been canged */
331 case 17640000: 339 if (twl6040->sysclk != freq_out) {
332 lppllctl |= TWL6040_LPLLFIN; 340 switch (freq_out) {
333 break; 341 case 17640000:
334 case 19200000: 342 lppllctl |= TWL6040_LPLLFIN;
335 lppllctl &= ~TWL6040_LPLLFIN; 343 break;
336 break; 344 case 19200000:
337 default: 345 lppllctl &= ~TWL6040_LPLLFIN;
338 dev_err(twl6040->dev, 346 break;
339 "freq_out %d not supported\n", freq_out); 347 default:
340 ret = -EINVAL; 348 dev_err(twl6040->dev,
341 goto pll_out; 349 "freq_out %d not supported\n",
350 freq_out);
351 ret = -EINVAL;
352 goto pll_out;
353 }
354 twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL,
355 lppllctl);
342 } 356 }
343 twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); 357
358 /* The PLL in use has not been change, we can exit */
359 if (twl6040->pll == pll_id)
360 break;
344 361
345 switch (freq_in) { 362 switch (freq_in) {
346 case 32768: 363 case 32768:
@@ -371,48 +388,56 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
371 goto pll_out; 388 goto pll_out;
372 } 389 }
373 390
374 hppllctl &= ~TWL6040_MCLK_MSK; 391 if (twl6040->mclk != freq_in) {
392 hppllctl &= ~TWL6040_MCLK_MSK;
393
394 switch (freq_in) {
395 case 12000000:
396 /* PLL enabled, active mode */
397 hppllctl |= TWL6040_MCLK_12000KHZ |
398 TWL6040_HPLLENA;
399 break;
400 case 19200000:
401 /*
402 * PLL disabled
403 * (enable PLL if MCLK jitter quality
404 * doesn't meet specification)
405 */
406 hppllctl |= TWL6040_MCLK_19200KHZ;
407 break;
408 case 26000000:
409 /* PLL enabled, active mode */
410 hppllctl |= TWL6040_MCLK_26000KHZ |
411 TWL6040_HPLLENA;
412 break;
413 case 38400000:
414 /* PLL enabled, active mode */
415 hppllctl |= TWL6040_MCLK_38400KHZ |
416 TWL6040_HPLLENA;
417 break;
418 default:
419 dev_err(twl6040->dev,
420 "freq_in %d not supported\n", freq_in);
421 ret = -EINVAL;
422 goto pll_out;
423 }
375 424
376 switch (freq_in) {
377 case 12000000:
378 /* PLL enabled, active mode */
379 hppllctl |= TWL6040_MCLK_12000KHZ |
380 TWL6040_HPLLENA;
381 break;
382 case 19200000:
383 /* 425 /*
384 * PLL disabled 426 * enable clock slicer to ensure input waveform is
385 * (enable PLL if MCLK jitter quality 427 * square
386 * doesn't meet specification)
387 */ 428 */
388 hppllctl |= TWL6040_MCLK_19200KHZ; 429 hppllctl |= TWL6040_HPLLSQRENA;
389 break;
390 case 26000000:
391 /* PLL enabled, active mode */
392 hppllctl |= TWL6040_MCLK_26000KHZ |
393 TWL6040_HPLLENA;
394 break;
395 case 38400000:
396 /* PLL enabled, active mode */
397 hppllctl |= TWL6040_MCLK_38400KHZ |
398 TWL6040_HPLLENA;
399 break;
400 default:
401 dev_err(twl6040->dev,
402 "freq_in %d not supported\n", freq_in);
403 ret = -EINVAL;
404 goto pll_out;
405 }
406 430
407 /* enable clock slicer to ensure input waveform is square */ 431 twl6040_reg_write(twl6040, TWL6040_REG_HPPLLCTL,
408 hppllctl |= TWL6040_HPLLSQRENA; 432 hppllctl);
409 433 usleep_range(500, 700);
410 twl6040_reg_write(twl6040, TWL6040_REG_HPPLLCTL, hppllctl); 434 lppllctl |= TWL6040_HPLLSEL;
411 usleep_range(500, 700); 435 twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL,
412 lppllctl |= TWL6040_HPLLSEL; 436 lppllctl);
413 twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); 437 lppllctl &= ~TWL6040_LPLLENA;
414 lppllctl &= ~TWL6040_LPLLENA; 438 twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL,
415 twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); 439 lppllctl);
440 }
416 break; 441 break;
417 default: 442 default:
418 dev_err(twl6040->dev, "unknown pll id %d\n", pll_id); 443 dev_err(twl6040->dev, "unknown pll id %d\n", pll_id);
@@ -421,6 +446,7 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
421 } 446 }
422 447
423 twl6040->sysclk = freq_out; 448 twl6040->sysclk = freq_out;
449 twl6040->mclk = freq_in;
424 twl6040->pll = pll_id; 450 twl6040->pll = pll_id;
425 451
426pll_out: 452pll_out:
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 150cd7061b80..28adefe70f96 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -354,6 +354,7 @@ static void lkdtm_do_action(enum ctype which)
354static void lkdtm_handler(void) 354static void lkdtm_handler(void)
355{ 355{
356 unsigned long flags; 356 unsigned long flags;
357 bool do_it = false;
357 358
358 spin_lock_irqsave(&count_lock, flags); 359 spin_lock_irqsave(&count_lock, flags);
359 count--; 360 count--;
@@ -361,10 +362,13 @@ static void lkdtm_handler(void)
361 cp_name_to_str(cpoint), cp_type_to_str(cptype), count); 362 cp_name_to_str(cpoint), cp_type_to_str(cptype), count);
362 363
363 if (count == 0) { 364 if (count == 0) {
364 lkdtm_do_action(cptype); 365 do_it = true;
365 count = cpoint_count; 366 count = cpoint_count;
366 } 367 }
367 spin_unlock_irqrestore(&count_lock, flags); 368 spin_unlock_irqrestore(&count_lock, flags);
369
370 if (do_it)
371 lkdtm_do_action(cptype);
368} 372}
369 373
370static int lkdtm_register_cpoint(enum cname which) 374static int lkdtm_register_cpoint(enum cname which)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 6ae9ca01388b..9a9ce71a71fc 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -119,7 +119,7 @@ static int mtd_cls_suspend(struct device *dev, pm_message_t state)
119{ 119{
120 struct mtd_info *mtd = dev_get_drvdata(dev); 120 struct mtd_info *mtd = dev_get_drvdata(dev);
121 121
122 return mtd_suspend(mtd); 122 return mtd ? mtd_suspend(mtd) : 0;
123} 123}
124 124
125static int mtd_cls_resume(struct device *dev) 125static int mtd_cls_resume(struct device *dev)
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 4dd056e2e16a..35b4fb55dbd6 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -161,6 +161,37 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
161 !!host->board->rdy_pin_active_low; 161 !!host->board->rdy_pin_active_low;
162} 162}
163 163
164/*
165 * Minimal-overhead PIO for data access.
166 */
167static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len)
168{
169 struct nand_chip *nand_chip = mtd->priv;
170
171 __raw_readsb(nand_chip->IO_ADDR_R, buf, len);
172}
173
174static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
175{
176 struct nand_chip *nand_chip = mtd->priv;
177
178 __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2);
179}
180
181static void atmel_write_buf8(struct mtd_info *mtd, const u8 *buf, int len)
182{
183 struct nand_chip *nand_chip = mtd->priv;
184
185 __raw_writesb(nand_chip->IO_ADDR_W, buf, len);
186}
187
188static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
189{
190 struct nand_chip *nand_chip = mtd->priv;
191
192 __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2);
193}
194
164static void dma_complete_func(void *completion) 195static void dma_complete_func(void *completion)
165{ 196{
166 complete(completion); 197 complete(completion);
@@ -235,27 +266,33 @@ err_buf:
235static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) 266static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
236{ 267{
237 struct nand_chip *chip = mtd->priv; 268 struct nand_chip *chip = mtd->priv;
269 struct atmel_nand_host *host = chip->priv;
238 270
239 if (use_dma && len > mtd->oobsize) 271 if (use_dma && len > mtd->oobsize)
240 /* only use DMA for bigger than oob size: better performances */ 272 /* only use DMA for bigger than oob size: better performances */
241 if (atmel_nand_dma_op(mtd, buf, len, 1) == 0) 273 if (atmel_nand_dma_op(mtd, buf, len, 1) == 0)
242 return; 274 return;
243 275
244 /* if no DMA operation possible, use PIO */ 276 if (host->board->bus_width_16)
245 memcpy_fromio(buf, chip->IO_ADDR_R, len); 277 atmel_read_buf16(mtd, buf, len);
278 else
279 atmel_read_buf8(mtd, buf, len);
246} 280}
247 281
248static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) 282static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
249{ 283{
250 struct nand_chip *chip = mtd->priv; 284 struct nand_chip *chip = mtd->priv;
285 struct atmel_nand_host *host = chip->priv;
251 286
252 if (use_dma && len > mtd->oobsize) 287 if (use_dma && len > mtd->oobsize)
253 /* only use DMA for bigger than oob size: better performances */ 288 /* only use DMA for bigger than oob size: better performances */
254 if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0) 289 if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0)
255 return; 290 return;
256 291
257 /* if no DMA operation possible, use PIO */ 292 if (host->board->bus_width_16)
258 memcpy_toio(chip->IO_ADDR_W, buf, len); 293 atmel_write_buf16(mtd, buf, len);
294 else
295 atmel_write_buf8(mtd, buf, len);
259} 296}
260 297
261/* 298/*
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
index 7f680420bfab..7db6555ed3ba 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
@@ -69,17 +69,19 @@ static int clear_poll_bit(void __iomem *addr, u32 mask)
69 * [1] enable the module. 69 * [1] enable the module.
70 * [2] reset the module. 70 * [2] reset the module.
71 * 71 *
72 * In most of the cases, it's ok. But there is a hardware bug in the BCH block. 72 * In most of the cases, it's ok.
73 * But in MX23, there is a hardware bug in the BCH block (see erratum #2847).
73 * If you try to soft reset the BCH block, it becomes unusable until 74 * If you try to soft reset the BCH block, it becomes unusable until
74 * the next hard reset. This case occurs in the NAND boot mode. When the board 75 * the next hard reset. This case occurs in the NAND boot mode. When the board
75 * boots by NAND, the ROM of the chip will initialize the BCH blocks itself. 76 * boots by NAND, the ROM of the chip will initialize the BCH blocks itself.
76 * So If the driver tries to reset the BCH again, the BCH will not work anymore. 77 * So If the driver tries to reset the BCH again, the BCH will not work anymore.
77 * You will see a DMA timeout in this case. 78 * You will see a DMA timeout in this case. The bug has been fixed
79 * in the following chips, such as MX28.
78 * 80 *
79 * To avoid this bug, just add a new parameter `just_enable` for 81 * To avoid this bug, just add a new parameter `just_enable` for
80 * the mxs_reset_block(), and rewrite it here. 82 * the mxs_reset_block(), and rewrite it here.
81 */ 83 */
82int gpmi_reset_block(void __iomem *reset_addr, bool just_enable) 84static int gpmi_reset_block(void __iomem *reset_addr, bool just_enable)
83{ 85{
84 int ret; 86 int ret;
85 int timeout = 0x400; 87 int timeout = 0x400;
@@ -206,7 +208,15 @@ int bch_set_geometry(struct gpmi_nand_data *this)
206 if (ret) 208 if (ret)
207 goto err_out; 209 goto err_out;
208 210
209 ret = gpmi_reset_block(r->bch_regs, true); 211 /*
212 * Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this
213 * chip, otherwise it will lock up. So we skip resetting BCH on the MX23.
214 * On the other hand, the MX28 needs the reset, because one case has been
215 * seen where the BCH produced ECC errors constantly after 10000
216 * consecutive reboots. The latter case has not been seen on the MX23 yet,
217 * still we don't know if it could happen there as well.
218 */
219 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MX23(this));
210 if (ret) 220 if (ret)
211 goto err_out; 221 goto err_out;
212 222
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 35b4565050f1..8a393f9e6027 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2588,7 +2588,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
2588 instr->state = MTD_ERASING; 2588 instr->state = MTD_ERASING;
2589 2589
2590 while (len) { 2590 while (len) {
2591 /* Heck if we have a bad block, we do not erase bad blocks! */ 2591 /* Check if we have a bad block, we do not erase bad blocks! */
2592 if (nand_block_checkbad(mtd, ((loff_t) page) << 2592 if (nand_block_checkbad(mtd, ((loff_t) page) <<
2593 chip->page_shift, 0, allowbbt)) { 2593 chip->page_shift, 0, allowbbt)) {
2594 pr_warn("%s: attempt to erase a bad block at page 0x%08x\n", 2594 pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
index 752493f00406..65d1f05007be 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
@@ -972,11 +972,11 @@ void iwl_irq_tasklet(struct iwl_trans *trans)
972 } 972 }
973#endif 973#endif
974 974
975 spin_unlock_irqrestore(&trans->shrd->lock, flags);
976
977 /* saved interrupt in inta variable now we can reset trans_pcie->inta */ 975 /* saved interrupt in inta variable now we can reset trans_pcie->inta */
978 trans_pcie->inta = 0; 976 trans_pcie->inta = 0;
979 977
978 spin_unlock_irqrestore(&trans->shrd->lock, flags);
979
980 /* Now service all interrupt bits discovered above. */ 980 /* Now service all interrupt bits discovered above. */
981 if (inta & CSR_INT_BIT_HW_ERR) { 981 if (inta & CSR_INT_BIT_HW_ERR) {
982 IWL_ERR(trans, "Hardware error detected. Restarting.\n"); 982 IWL_ERR(trans, "Hardware error detected. Restarting.\n");
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index fa679057630f..698b905058dd 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -68,7 +68,7 @@ struct netfront_cb {
68 68
69#define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE) 69#define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE)
70#define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE) 70#define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE)
71#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256) 71#define TX_MAX_TARGET min_t(int, NET_TX_RING_SIZE, 256)
72 72
73struct netfront_stats { 73struct netfront_stats {
74 u64 rx_packets; 74 u64 rx_packets;
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 749c2a16012c..1932029de48d 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1269,10 +1269,8 @@ static int pcmcia_bus_add(struct pcmcia_socket *skt)
1269 1269
1270static int pcmcia_bus_early_resume(struct pcmcia_socket *skt) 1270static int pcmcia_bus_early_resume(struct pcmcia_socket *skt)
1271{ 1271{
1272 if (!verify_cis_cache(skt)) { 1272 if (!verify_cis_cache(skt))
1273 pcmcia_put_socket(skt);
1274 return 0; 1273 return 0;
1275 }
1276 1274
1277 dev_dbg(&skt->dev, "cis mismatch - different card\n"); 1275 dev_dbg(&skt->dev, "cis mismatch - different card\n");
1278 1276
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 569bdb3ef104..8fe15cf15ac8 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -510,10 +510,12 @@ static struct dentry *debugfs_root;
510 510
511static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) 511static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
512{ 512{
513 static struct dentry *device_root; 513 struct dentry *device_root;
514 514
515 device_root = debugfs_create_dir(dev_name(pctldev->dev), 515 device_root = debugfs_create_dir(dev_name(pctldev->dev),
516 debugfs_root); 516 debugfs_root);
517 pctldev->device_root = device_root;
518
517 if (IS_ERR(device_root) || !device_root) { 519 if (IS_ERR(device_root) || !device_root) {
518 pr_warn("failed to create debugfs directory for %s\n", 520 pr_warn("failed to create debugfs directory for %s\n",
519 dev_name(pctldev->dev)); 521 dev_name(pctldev->dev));
@@ -529,6 +531,11 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
529 pinconf_init_device_debugfs(device_root, pctldev); 531 pinconf_init_device_debugfs(device_root, pctldev);
530} 532}
531 533
534static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
535{
536 debugfs_remove_recursive(pctldev->device_root);
537}
538
532static void pinctrl_init_debugfs(void) 539static void pinctrl_init_debugfs(void)
533{ 540{
534 debugfs_root = debugfs_create_dir("pinctrl", NULL); 541 debugfs_root = debugfs_create_dir("pinctrl", NULL);
@@ -553,6 +560,10 @@ static void pinctrl_init_debugfs(void)
553{ 560{
554} 561}
555 562
563static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
564{
565}
566
556#endif 567#endif
557 568
558/** 569/**
@@ -572,40 +583,40 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
572 if (pctldesc->name == NULL) 583 if (pctldesc->name == NULL)
573 return NULL; 584 return NULL;
574 585
586 pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL);
587 if (pctldev == NULL)
588 return NULL;
589
590 /* Initialize pin control device struct */
591 pctldev->owner = pctldesc->owner;
592 pctldev->desc = pctldesc;
593 pctldev->driver_data = driver_data;
594 INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
595 spin_lock_init(&pctldev->pin_desc_tree_lock);
596 INIT_LIST_HEAD(&pctldev->gpio_ranges);
597 mutex_init(&pctldev->gpio_ranges_lock);
598 pctldev->dev = dev;
599
575 /* If we're implementing pinmuxing, check the ops for sanity */ 600 /* If we're implementing pinmuxing, check the ops for sanity */
576 if (pctldesc->pmxops) { 601 if (pctldesc->pmxops) {
577 ret = pinmux_check_ops(pctldesc->pmxops); 602 ret = pinmux_check_ops(pctldev);
578 if (ret) { 603 if (ret) {
579 pr_err("%s pinmux ops lacks necessary functions\n", 604 pr_err("%s pinmux ops lacks necessary functions\n",
580 pctldesc->name); 605 pctldesc->name);
581 return NULL; 606 goto out_err;
582 } 607 }
583 } 608 }
584 609
585 /* If we're implementing pinconfig, check the ops for sanity */ 610 /* If we're implementing pinconfig, check the ops for sanity */
586 if (pctldesc->confops) { 611 if (pctldesc->confops) {
587 ret = pinconf_check_ops(pctldesc->confops); 612 ret = pinconf_check_ops(pctldev);
588 if (ret) { 613 if (ret) {
589 pr_err("%s pin config ops lacks necessary functions\n", 614 pr_err("%s pin config ops lacks necessary functions\n",
590 pctldesc->name); 615 pctldesc->name);
591 return NULL; 616 goto out_err;
592 } 617 }
593 } 618 }
594 619
595 pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL);
596 if (pctldev == NULL)
597 return NULL;
598
599 /* Initialize pin control device struct */
600 pctldev->owner = pctldesc->owner;
601 pctldev->desc = pctldesc;
602 pctldev->driver_data = driver_data;
603 INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
604 spin_lock_init(&pctldev->pin_desc_tree_lock);
605 INIT_LIST_HEAD(&pctldev->gpio_ranges);
606 mutex_init(&pctldev->gpio_ranges_lock);
607 pctldev->dev = dev;
608
609 /* Register all the pins */ 620 /* Register all the pins */
610 pr_debug("try to register %d pins on %s...\n", 621 pr_debug("try to register %d pins on %s...\n",
611 pctldesc->npins, pctldesc->name); 622 pctldesc->npins, pctldesc->name);
@@ -641,6 +652,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
641 if (pctldev == NULL) 652 if (pctldev == NULL)
642 return; 653 return;
643 654
655 pinctrl_remove_device_debugfs(pctldev);
644 pinmux_unhog_maps(pctldev); 656 pinmux_unhog_maps(pctldev);
645 /* TODO: check that no pinmuxes are still active? */ 657 /* TODO: check that no pinmuxes are still active? */
646 mutex_lock(&pinctrldev_list_mutex); 658 mutex_lock(&pinctrldev_list_mutex);
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 177a3310547f..cfa86da6b4b1 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -41,6 +41,9 @@ struct pinctrl_dev {
41 struct device *dev; 41 struct device *dev;
42 struct module *owner; 42 struct module *owner;
43 void *driver_data; 43 void *driver_data;
44#ifdef CONFIG_DEBUG_FS
45 struct dentry *device_root;
46#endif
44#ifdef CONFIG_PINMUX 47#ifdef CONFIG_PINMUX
45 struct mutex pinmux_hogs_lock; 48 struct mutex pinmux_hogs_lock;
46 struct list_head pinmux_hogs; 49 struct list_head pinmux_hogs;
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index 1259872b0a1d..9fb75456824c 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -205,8 +205,10 @@ int pin_config_group_set(const char *dev_name, const char *pin_group,
205} 205}
206EXPORT_SYMBOL(pin_config_group_set); 206EXPORT_SYMBOL(pin_config_group_set);
207 207
208int pinconf_check_ops(const struct pinconf_ops *ops) 208int pinconf_check_ops(struct pinctrl_dev *pctldev)
209{ 209{
210 const struct pinconf_ops *ops = pctldev->desc->confops;
211
210 /* We must be able to read out pin status */ 212 /* We must be able to read out pin status */
211 if (!ops->pin_config_get && !ops->pin_config_group_get) 213 if (!ops->pin_config_get && !ops->pin_config_group_get)
212 return -EINVAL; 214 return -EINVAL;
@@ -236,7 +238,7 @@ static int pinconf_pins_show(struct seq_file *s, void *what)
236 seq_puts(s, "Format: pin (name): pinmux setting array\n"); 238 seq_puts(s, "Format: pin (name): pinmux setting array\n");
237 239
238 /* The pin number can be retrived from the pin controller descriptor */ 240 /* The pin number can be retrived from the pin controller descriptor */
239 for (i = 0; pin < pctldev->desc->npins; i++) { 241 for (i = 0; i < pctldev->desc->npins; i++) {
240 struct pin_desc *desc; 242 struct pin_desc *desc;
241 243
242 pin = pctldev->desc->pins[i].number; 244 pin = pctldev->desc->pins[i].number;
diff --git a/drivers/pinctrl/pinconf.h b/drivers/pinctrl/pinconf.h
index e7dc6165032a..006b77fa737e 100644
--- a/drivers/pinctrl/pinconf.h
+++ b/drivers/pinctrl/pinconf.h
@@ -13,7 +13,7 @@
13 13
14#ifdef CONFIG_PINCONF 14#ifdef CONFIG_PINCONF
15 15
16int pinconf_check_ops(const struct pinconf_ops *ops); 16int pinconf_check_ops(struct pinctrl_dev *pctldev);
17void pinconf_init_device_debugfs(struct dentry *devroot, 17void pinconf_init_device_debugfs(struct dentry *devroot,
18 struct pinctrl_dev *pctldev); 18 struct pinctrl_dev *pctldev);
19int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin, 19int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
@@ -23,7 +23,7 @@ int pin_config_set_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
23 23
24#else 24#else
25 25
26static inline int pinconf_check_ops(const struct pinconf_ops *ops) 26static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
27{ 27{
28 return 0; 28 return 0;
29} 29}
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index a76a348321bb..7c3193f7a044 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -53,11 +53,6 @@ struct pinmux_group {
53 * @dev: the device using this pinmux 53 * @dev: the device using this pinmux
54 * @usecount: the number of active users of this mux setting, used to keep 54 * @usecount: the number of active users of this mux setting, used to keep
55 * track of nested use cases 55 * track of nested use cases
56 * @pins: an array of discrete physical pins used in this mapping, taken
57 * from the global pin enumeration space (copied from pinmux map)
58 * @num_pins: the number of pins in this mapping array, i.e. the number of
59 * elements in .pins so we can iterate over that array (copied from
60 * pinmux map)
61 * @pctldev: pin control device handling this pinmux 56 * @pctldev: pin control device handling this pinmux
62 * @func_selector: the function selector for the pinmux device handling 57 * @func_selector: the function selector for the pinmux device handling
63 * this pinmux 58 * this pinmux
@@ -152,8 +147,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
152 status = 0; 147 status = 0;
153 148
154 if (status) 149 if (status)
155 dev_err(pctldev->dev, "->request on device %s failed " 150 dev_err(pctldev->dev, "->request on device %s failed for pin %d\n",
156 "for pin %d\n",
157 pctldev->desc->name, pin); 151 pctldev->desc->name, pin);
158out_free_pin: 152out_free_pin:
159 if (status) { 153 if (status) {
@@ -355,21 +349,20 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
355 /* First sanity check the new mapping */ 349 /* First sanity check the new mapping */
356 for (i = 0; i < num_maps; i++) { 350 for (i = 0; i < num_maps; i++) {
357 if (!maps[i].name) { 351 if (!maps[i].name) {
358 pr_err("failed to register map %d: " 352 pr_err("failed to register map %d: no map name given\n",
359 "no map name given\n", i); 353 i);
360 return -EINVAL; 354 return -EINVAL;
361 } 355 }
362 356
363 if (!maps[i].ctrl_dev && !maps[i].ctrl_dev_name) { 357 if (!maps[i].ctrl_dev && !maps[i].ctrl_dev_name) {
364 pr_err("failed to register map %s (%d): " 358 pr_err("failed to register map %s (%d): no pin control device given\n",
365 "no pin control device given\n",
366 maps[i].name, i); 359 maps[i].name, i);
367 return -EINVAL; 360 return -EINVAL;
368 } 361 }
369 362
370 if (!maps[i].function) { 363 if (!maps[i].function) {
371 pr_err("failed to register map %s (%d): " 364 pr_err("failed to register map %s (%d): no function ID given\n",
372 "no function ID given\n", maps[i].name, i); 365 maps[i].name, i);
373 return -EINVAL; 366 return -EINVAL;
374 } 367 }
375 368
@@ -411,7 +404,7 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
411} 404}
412 405
413/** 406/**
414 * acquire_pins() - acquire all the pins for a certain funcion on a pinmux 407 * acquire_pins() - acquire all the pins for a certain function on a pinmux
415 * @pctldev: the device to take the pins on 408 * @pctldev: the device to take the pins on
416 * @func_selector: the function selector to acquire the pins for 409 * @func_selector: the function selector to acquire the pins for
417 * @group_selector: the group selector containing the pins to acquire 410 * @group_selector: the group selector containing the pins to acquire
@@ -442,8 +435,7 @@ static int acquire_pins(struct pinctrl_dev *pctldev,
442 ret = pin_request(pctldev, pins[i], func, NULL); 435 ret = pin_request(pctldev, pins[i], func, NULL);
443 if (ret) { 436 if (ret) {
444 dev_err(pctldev->dev, 437 dev_err(pctldev->dev,
445 "could not get pin %d for function %s " 438 "could not get pin %d for function %s on device %s - conflicting mux mappings?\n",
446 "on device %s - conflicting mux mappings?\n",
447 pins[i], func ? : "(undefined)", 439 pins[i], func ? : "(undefined)",
448 pinctrl_dev_get_name(pctldev)); 440 pinctrl_dev_get_name(pctldev));
449 /* On error release all taken pins */ 441 /* On error release all taken pins */
@@ -458,7 +450,7 @@ static int acquire_pins(struct pinctrl_dev *pctldev,
458 450
459/** 451/**
460 * release_pins() - release pins taken by earlier acquirement 452 * release_pins() - release pins taken by earlier acquirement
461 * @pctldev: the device to free the pinx on 453 * @pctldev: the device to free the pins on
462 * @group_selector: the group selector containing the pins to free 454 * @group_selector: the group selector containing the pins to free
463 */ 455 */
464static void release_pins(struct pinctrl_dev *pctldev, 456static void release_pins(struct pinctrl_dev *pctldev,
@@ -473,8 +465,7 @@ static void release_pins(struct pinctrl_dev *pctldev,
473 ret = pctlops->get_group_pins(pctldev, group_selector, 465 ret = pctlops->get_group_pins(pctldev, group_selector,
474 &pins, &num_pins); 466 &pins, &num_pins);
475 if (ret) { 467 if (ret) {
476 dev_err(pctldev->dev, "could not get pins to release for " 468 dev_err(pctldev->dev, "could not get pins to release for group selector %d\n",
477 "group selector %d\n",
478 group_selector); 469 group_selector);
479 return; 470 return;
480 } 471 }
@@ -526,8 +517,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
526 ret = pinctrl_get_group_selector(pctldev, groups[0]); 517 ret = pinctrl_get_group_selector(pctldev, groups[0]);
527 if (ret < 0) { 518 if (ret < 0) {
528 dev_err(pctldev->dev, 519 dev_err(pctldev->dev,
529 "function %s wants group %s but the pin " 520 "function %s wants group %s but the pin controller does not seem to have that group\n",
530 "controller does not seem to have that group\n",
531 pmxops->get_function_name(pctldev, func_selector), 521 pmxops->get_function_name(pctldev, func_selector),
532 groups[0]); 522 groups[0]);
533 return ret; 523 return ret;
@@ -535,8 +525,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
535 525
536 if (num_groups > 1) 526 if (num_groups > 1)
537 dev_dbg(pctldev->dev, 527 dev_dbg(pctldev->dev,
538 "function %s support more than one group, " 528 "function %s support more than one group, default-selecting first group %s (%d)\n",
539 "default-selecting first group %s (%d)\n",
540 pmxops->get_function_name(pctldev, func_selector), 529 pmxops->get_function_name(pctldev, func_selector),
541 groups[0], 530 groups[0],
542 ret); 531 ret);
@@ -628,10 +617,8 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
628 617
629 if (pmx->pctldev && pmx->pctldev != pctldev) { 618 if (pmx->pctldev && pmx->pctldev != pctldev) {
630 dev_err(pctldev->dev, 619 dev_err(pctldev->dev,
631 "different pin control devices given for device %s, " 620 "different pin control devices given for device %s, function %s\n",
632 "function %s\n", 621 devname, map->function);
633 devname,
634 map->function);
635 return -EINVAL; 622 return -EINVAL;
636 } 623 }
637 pmx->dev = dev; 624 pmx->dev = dev;
@@ -695,7 +682,6 @@ static void pinmux_free_groups(struct pinmux *pmx)
695 */ 682 */
696struct pinmux *pinmux_get(struct device *dev, const char *name) 683struct pinmux *pinmux_get(struct device *dev, const char *name)
697{ 684{
698
699 struct pinmux_map const *map = NULL; 685 struct pinmux_map const *map = NULL;
700 struct pinctrl_dev *pctldev = NULL; 686 struct pinctrl_dev *pctldev = NULL;
701 const char *devname = NULL; 687 const char *devname = NULL;
@@ -745,8 +731,7 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
745 else if (map->ctrl_dev_name) 731 else if (map->ctrl_dev_name)
746 devname = map->ctrl_dev_name; 732 devname = map->ctrl_dev_name;
747 733
748 pr_warning("could not find a pinctrl device for pinmux " 734 pr_warning("could not find a pinctrl device for pinmux function %s, fishy, they shall all have one\n",
749 "function %s, fishy, they shall all have one\n",
750 map->function); 735 map->function);
751 pr_warning("given pinctrl device name: %s", 736 pr_warning("given pinctrl device name: %s",
752 devname ? devname : "UNDEFINED"); 737 devname ? devname : "UNDEFINED");
@@ -904,8 +889,11 @@ void pinmux_disable(struct pinmux *pmx)
904} 889}
905EXPORT_SYMBOL_GPL(pinmux_disable); 890EXPORT_SYMBOL_GPL(pinmux_disable);
906 891
907int pinmux_check_ops(const struct pinmux_ops *ops) 892int pinmux_check_ops(struct pinctrl_dev *pctldev)
908{ 893{
894 const struct pinmux_ops *ops = pctldev->desc->pmxops;
895 unsigned selector = 0;
896
909 /* Check that we implement required operations */ 897 /* Check that we implement required operations */
910 if (!ops->list_functions || 898 if (!ops->list_functions ||
911 !ops->get_function_name || 899 !ops->get_function_name ||
@@ -914,6 +902,18 @@ int pinmux_check_ops(const struct pinmux_ops *ops)
914 !ops->disable) 902 !ops->disable)
915 return -EINVAL; 903 return -EINVAL;
916 904
905 /* Check that all functions registered have names */
906 while (ops->list_functions(pctldev, selector) >= 0) {
907 const char *fname = ops->get_function_name(pctldev,
908 selector);
909 if (!fname) {
910 pr_err("pinmux ops has no name for function%u\n",
911 selector);
912 return -EINVAL;
913 }
914 selector++;
915 }
916
917 return 0; 917 return 0;
918} 918}
919 919
@@ -932,8 +932,8 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
932 * without any problems, so then we can hog pinmuxes for 932 * without any problems, so then we can hog pinmuxes for
933 * all devices that just want a static pin mux at this point. 933 * all devices that just want a static pin mux at this point.
934 */ 934 */
935 dev_err(pctldev->dev, "map %s wants to hog a non-system " 935 dev_err(pctldev->dev, "map %s wants to hog a non-system pinmux, this is not going to work\n",
936 "pinmux, this is not going to work\n", map->name); 936 map->name);
937 return -EINVAL; 937 return -EINVAL;
938 } 938 }
939 939
@@ -993,9 +993,12 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
993 for (i = 0; i < pinmux_maps_num; i++) { 993 for (i = 0; i < pinmux_maps_num; i++) {
994 struct pinmux_map const *map = &pinmux_maps[i]; 994 struct pinmux_map const *map = &pinmux_maps[i];
995 995
996 if (((map->ctrl_dev == dev) || 996 if (!map->hog_on_boot)
997 !strcmp(map->ctrl_dev_name, devname)) && 997 continue;
998 map->hog_on_boot) { 998
999 if ((map->ctrl_dev == dev) ||
1000 (map->ctrl_dev_name &&
1001 !strcmp(map->ctrl_dev_name, devname))) {
999 /* OK time to hog! */ 1002 /* OK time to hog! */
1000 ret = pinmux_hog_map(pctldev, map); 1003 ret = pinmux_hog_map(pctldev, map);
1001 if (ret) 1004 if (ret)
@@ -1122,13 +1125,15 @@ static int pinmux_show(struct seq_file *s, void *what)
1122 1125
1123 seq_printf(s, "device: %s function: %s (%u),", 1126 seq_printf(s, "device: %s function: %s (%u),",
1124 pinctrl_dev_get_name(pmx->pctldev), 1127 pinctrl_dev_get_name(pmx->pctldev),
1125 pmxops->get_function_name(pctldev, pmx->func_selector), 1128 pmxops->get_function_name(pctldev,
1129 pmx->func_selector),
1126 pmx->func_selector); 1130 pmx->func_selector);
1127 1131
1128 seq_printf(s, " groups: ["); 1132 seq_printf(s, " groups: [");
1129 list_for_each_entry(grp, &pmx->groups, node) { 1133 list_for_each_entry(grp, &pmx->groups, node) {
1130 seq_printf(s, " %s (%u)", 1134 seq_printf(s, " %s (%u)",
1131 pctlops->get_group_name(pctldev, grp->group_selector), 1135 pctlops->get_group_name(pctldev,
1136 grp->group_selector),
1132 grp->group_selector); 1137 grp->group_selector);
1133 } 1138 }
1134 seq_printf(s, " ]"); 1139 seq_printf(s, " ]");
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index 844500b3331b..97f52223fbc2 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -12,7 +12,7 @@
12 */ 12 */
13#ifdef CONFIG_PINMUX 13#ifdef CONFIG_PINMUX
14 14
15int pinmux_check_ops(const struct pinmux_ops *ops); 15int pinmux_check_ops(struct pinctrl_dev *pctldev);
16void pinmux_init_device_debugfs(struct dentry *devroot, 16void pinmux_init_device_debugfs(struct dentry *devroot,
17 struct pinctrl_dev *pctldev); 17 struct pinctrl_dev *pctldev);
18void pinmux_init_debugfs(struct dentry *subsys_root); 18void pinmux_init_debugfs(struct dentry *subsys_root);
@@ -21,7 +21,7 @@ void pinmux_unhog_maps(struct pinctrl_dev *pctldev);
21 21
22#else 22#else
23 23
24static inline int pinmux_check_ops(const struct pinmux_ops *ops) 24static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
25{ 25{
26 return 0; 26 return 0;
27} 27}
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index f1651eb69648..679734d26a16 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -35,7 +35,7 @@ static void of_get_regulation_constraints(struct device_node *np,
35 if (constraints->min_uV != constraints->max_uV) 35 if (constraints->min_uV != constraints->max_uV)
36 constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE; 36 constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
37 /* Only one voltage? Then make sure it's set. */ 37 /* Only one voltage? Then make sure it's set. */
38 if (constraints->min_uV == constraints->max_uV) 38 if (min_uV && max_uV && constraints->min_uV == constraints->max_uV)
39 constraints->apply_uV = true; 39 constraints->apply_uV = true;
40 40
41 uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL); 41 uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL);
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index eef27a197c00..110137e7ec81 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -3261,6 +3261,12 @@ void dasd_generic_path_event(struct ccw_device *cdev, int *path_event)
3261 device->path_data.tbvpm |= eventlpm; 3261 device->path_data.tbvpm |= eventlpm;
3262 dasd_schedule_device_bh(device); 3262 dasd_schedule_device_bh(device);
3263 } 3263 }
3264 if (path_event[chp] & PE_PATHGROUP_ESTABLISHED) {
3265 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
3266 "Pathgroup re-established\n");
3267 if (device->discipline->kick_validate)
3268 device->discipline->kick_validate(device);
3269 }
3264 } 3270 }
3265 dasd_put_device(device); 3271 dasd_put_device(device);
3266} 3272}
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 553b3c5abb0a..b3beed5434e4 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -189,14 +189,12 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
189 unsigned long flags; 189 unsigned long flags;
190 struct alias_server *server, *newserver; 190 struct alias_server *server, *newserver;
191 struct alias_lcu *lcu, *newlcu; 191 struct alias_lcu *lcu, *newlcu;
192 int is_lcu_known;
193 struct dasd_uid uid; 192 struct dasd_uid uid;
194 193
195 private = (struct dasd_eckd_private *) device->private; 194 private = (struct dasd_eckd_private *) device->private;
196 195
197 device->discipline->get_uid(device, &uid); 196 device->discipline->get_uid(device, &uid);
198 spin_lock_irqsave(&aliastree.lock, flags); 197 spin_lock_irqsave(&aliastree.lock, flags);
199 is_lcu_known = 1;
200 server = _find_server(&uid); 198 server = _find_server(&uid);
201 if (!server) { 199 if (!server) {
202 spin_unlock_irqrestore(&aliastree.lock, flags); 200 spin_unlock_irqrestore(&aliastree.lock, flags);
@@ -208,7 +206,6 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
208 if (!server) { 206 if (!server) {
209 list_add(&newserver->server, &aliastree.serverlist); 207 list_add(&newserver->server, &aliastree.serverlist);
210 server = newserver; 208 server = newserver;
211 is_lcu_known = 0;
212 } else { 209 } else {
213 /* someone was faster */ 210 /* someone was faster */
214 _free_server(newserver); 211 _free_server(newserver);
@@ -226,12 +223,10 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
226 if (!lcu) { 223 if (!lcu) {
227 list_add(&newlcu->lcu, &server->lculist); 224 list_add(&newlcu->lcu, &server->lculist);
228 lcu = newlcu; 225 lcu = newlcu;
229 is_lcu_known = 0;
230 } else { 226 } else {
231 /* someone was faster */ 227 /* someone was faster */
232 _free_lcu(newlcu); 228 _free_lcu(newlcu);
233 } 229 }
234 is_lcu_known = 0;
235 } 230 }
236 spin_lock(&lcu->lock); 231 spin_lock(&lcu->lock);
237 list_add(&device->alias_list, &lcu->inactive_devices); 232 list_add(&device->alias_list, &lcu->inactive_devices);
@@ -239,64 +234,7 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
239 spin_unlock(&lcu->lock); 234 spin_unlock(&lcu->lock);
240 spin_unlock_irqrestore(&aliastree.lock, flags); 235 spin_unlock_irqrestore(&aliastree.lock, flags);
241 236
242 return is_lcu_known; 237 return 0;
243}
244
245/*
246 * The first device to be registered on an LCU will have to do
247 * some additional setup steps to configure that LCU on the
248 * storage server. All further devices should wait with their
249 * initialization until the first device is done.
250 * To synchronize this work, the first device will call
251 * dasd_alias_lcu_setup_complete when it is done, and all
252 * other devices will wait for it with dasd_alias_wait_for_lcu_setup.
253 */
254void dasd_alias_lcu_setup_complete(struct dasd_device *device)
255{
256 unsigned long flags;
257 struct alias_server *server;
258 struct alias_lcu *lcu;
259 struct dasd_uid uid;
260
261 device->discipline->get_uid(device, &uid);
262 lcu = NULL;
263 spin_lock_irqsave(&aliastree.lock, flags);
264 server = _find_server(&uid);
265 if (server)
266 lcu = _find_lcu(server, &uid);
267 spin_unlock_irqrestore(&aliastree.lock, flags);
268 if (!lcu) {
269 DBF_EVENT_DEVID(DBF_ERR, device->cdev,
270 "could not find lcu for %04x %02x",
271 uid.ssid, uid.real_unit_addr);
272 WARN_ON(1);
273 return;
274 }
275 complete_all(&lcu->lcu_setup);
276}
277
278void dasd_alias_wait_for_lcu_setup(struct dasd_device *device)
279{
280 unsigned long flags;
281 struct alias_server *server;
282 struct alias_lcu *lcu;
283 struct dasd_uid uid;
284
285 device->discipline->get_uid(device, &uid);
286 lcu = NULL;
287 spin_lock_irqsave(&aliastree.lock, flags);
288 server = _find_server(&uid);
289 if (server)
290 lcu = _find_lcu(server, &uid);
291 spin_unlock_irqrestore(&aliastree.lock, flags);
292 if (!lcu) {
293 DBF_EVENT_DEVID(DBF_ERR, device->cdev,
294 "could not find lcu for %04x %02x",
295 uid.ssid, uid.real_unit_addr);
296 WARN_ON(1);
297 return;
298 }
299 wait_for_completion(&lcu->lcu_setup);
300} 238}
301 239
302/* 240/*
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index bbcd5e9206ee..70880be26015 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1534,6 +1534,10 @@ static void dasd_eckd_validate_server(struct dasd_device *device)
1534 struct dasd_eckd_private *private; 1534 struct dasd_eckd_private *private;
1535 int enable_pav; 1535 int enable_pav;
1536 1536
1537 private = (struct dasd_eckd_private *) device->private;
1538 if (private->uid.type == UA_BASE_PAV_ALIAS ||
1539 private->uid.type == UA_HYPER_PAV_ALIAS)
1540 return;
1537 if (dasd_nopav || MACHINE_IS_VM) 1541 if (dasd_nopav || MACHINE_IS_VM)
1538 enable_pav = 0; 1542 enable_pav = 0;
1539 else 1543 else
@@ -1542,11 +1546,28 @@ static void dasd_eckd_validate_server(struct dasd_device *device)
1542 1546
1543 /* may be requested feature is not available on server, 1547 /* may be requested feature is not available on server,
1544 * therefore just report error and go ahead */ 1548 * therefore just report error and go ahead */
1545 private = (struct dasd_eckd_private *) device->private;
1546 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x " 1549 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x "
1547 "returned rc=%d", private->uid.ssid, rc); 1550 "returned rc=%d", private->uid.ssid, rc);
1548} 1551}
1549 1552
1553/*
1554 * worker to do a validate server in case of a lost pathgroup
1555 */
1556static void dasd_eckd_do_validate_server(struct work_struct *work)
1557{
1558 struct dasd_device *device = container_of(work, struct dasd_device,
1559 kick_validate);
1560 dasd_eckd_validate_server(device);
1561 dasd_put_device(device);
1562}
1563
1564static void dasd_eckd_kick_validate_server(struct dasd_device *device)
1565{
1566 dasd_get_device(device);
1567 /* queue call to do_validate_server to the kernel event daemon. */
1568 schedule_work(&device->kick_validate);
1569}
1570
1550static u32 get_fcx_max_data(struct dasd_device *device) 1571static u32 get_fcx_max_data(struct dasd_device *device)
1551{ 1572{
1552#if defined(CONFIG_64BIT) 1573#if defined(CONFIG_64BIT)
@@ -1588,10 +1609,13 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
1588 struct dasd_eckd_private *private; 1609 struct dasd_eckd_private *private;
1589 struct dasd_block *block; 1610 struct dasd_block *block;
1590 struct dasd_uid temp_uid; 1611 struct dasd_uid temp_uid;
1591 int is_known, rc, i; 1612 int rc, i;
1592 int readonly; 1613 int readonly;
1593 unsigned long value; 1614 unsigned long value;
1594 1615
1616 /* setup work queue for validate server*/
1617 INIT_WORK(&device->kick_validate, dasd_eckd_do_validate_server);
1618
1595 if (!ccw_device_is_pathgroup(device->cdev)) { 1619 if (!ccw_device_is_pathgroup(device->cdev)) {
1596 dev_warn(&device->cdev->dev, 1620 dev_warn(&device->cdev->dev,
1597 "A channel path group could not be established\n"); 1621 "A channel path group could not be established\n");
@@ -1651,22 +1675,12 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
1651 block->base = device; 1675 block->base = device;
1652 } 1676 }
1653 1677
1654 /* register lcu with alias handling, enable PAV if this is a new lcu */ 1678 /* register lcu with alias handling, enable PAV */
1655 is_known = dasd_alias_make_device_known_to_lcu(device); 1679 rc = dasd_alias_make_device_known_to_lcu(device);
1656 if (is_known < 0) { 1680 if (rc)
1657 rc = is_known;
1658 goto out_err2; 1681 goto out_err2;
1659 } 1682
1660 /* 1683 dasd_eckd_validate_server(device);
1661 * dasd_eckd_validate_server is done on the first device that
1662 * is found for an LCU. All later other devices have to wait
1663 * for it, so they will read the correct feature codes.
1664 */
1665 if (!is_known) {
1666 dasd_eckd_validate_server(device);
1667 dasd_alias_lcu_setup_complete(device);
1668 } else
1669 dasd_alias_wait_for_lcu_setup(device);
1670 1684
1671 /* device may report different configuration data after LCU setup */ 1685 /* device may report different configuration data after LCU setup */
1672 rc = dasd_eckd_read_conf(device); 1686 rc = dasd_eckd_read_conf(device);
@@ -4098,7 +4112,7 @@ static int dasd_eckd_restore_device(struct dasd_device *device)
4098{ 4112{
4099 struct dasd_eckd_private *private; 4113 struct dasd_eckd_private *private;
4100 struct dasd_eckd_characteristics temp_rdc_data; 4114 struct dasd_eckd_characteristics temp_rdc_data;
4101 int is_known, rc; 4115 int rc;
4102 struct dasd_uid temp_uid; 4116 struct dasd_uid temp_uid;
4103 unsigned long flags; 4117 unsigned long flags;
4104 4118
@@ -4121,14 +4135,10 @@ static int dasd_eckd_restore_device(struct dasd_device *device)
4121 goto out_err; 4135 goto out_err;
4122 4136
4123 /* register lcu with alias handling, enable PAV if this is a new lcu */ 4137 /* register lcu with alias handling, enable PAV if this is a new lcu */
4124 is_known = dasd_alias_make_device_known_to_lcu(device); 4138 rc = dasd_alias_make_device_known_to_lcu(device);
4125 if (is_known < 0) 4139 if (rc)
4126 return is_known; 4140 return rc;
4127 if (!is_known) { 4141 dasd_eckd_validate_server(device);
4128 dasd_eckd_validate_server(device);
4129 dasd_alias_lcu_setup_complete(device);
4130 } else
4131 dasd_alias_wait_for_lcu_setup(device);
4132 4142
4133 /* RE-Read Configuration Data */ 4143 /* RE-Read Configuration Data */
4134 rc = dasd_eckd_read_conf(device); 4144 rc = dasd_eckd_read_conf(device);
@@ -4270,6 +4280,7 @@ static struct dasd_discipline dasd_eckd_discipline = {
4270 .restore = dasd_eckd_restore_device, 4280 .restore = dasd_eckd_restore_device,
4271 .reload = dasd_eckd_reload_device, 4281 .reload = dasd_eckd_reload_device,
4272 .get_uid = dasd_eckd_get_uid, 4282 .get_uid = dasd_eckd_get_uid,
4283 .kick_validate = dasd_eckd_kick_validate_server,
4273}; 4284};
4274 4285
4275static int __init 4286static int __init
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index afe8c33422ed..33a6743ddc55 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -355,6 +355,7 @@ struct dasd_discipline {
355 int (*reload) (struct dasd_device *); 355 int (*reload) (struct dasd_device *);
356 356
357 int (*get_uid) (struct dasd_device *, struct dasd_uid *); 357 int (*get_uid) (struct dasd_device *, struct dasd_uid *);
358 void (*kick_validate) (struct dasd_device *);
358}; 359};
359 360
360extern struct dasd_discipline *dasd_diag_discipline_pointer; 361extern struct dasd_discipline *dasd_diag_discipline_pointer;
@@ -455,6 +456,7 @@ struct dasd_device {
455 struct work_struct kick_work; 456 struct work_struct kick_work;
456 struct work_struct restore_device; 457 struct work_struct restore_device;
457 struct work_struct reload_device; 458 struct work_struct reload_device;
459 struct work_struct kick_validate;
458 struct timer_list timer; 460 struct timer_list timer;
459 461
460 debug_info_t *debug_area; 462 debug_info_t *debug_area;
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 3f9a47ec67dc..8293658e7cf9 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -299,7 +299,7 @@ config SPI_S3C24XX_FIQ
299 299
300config SPI_S3C64XX 300config SPI_S3C64XX
301 tristate "Samsung S3C64XX series type SPI" 301 tristate "Samsung S3C64XX series type SPI"
302 depends on (ARCH_S3C64XX || ARCH_S5P64X0) 302 depends on (ARCH_S3C64XX || ARCH_S5P64X0 || ARCH_EXYNOS)
303 select S3C64XX_DMA if ARCH_S3C64XX 303 select S3C64XX_DMA if ARCH_S3C64XX
304 help 304 help
305 SPI driver for Samsung S3C64XX and newer SoCs. 305 SPI driver for Samsung S3C64XX and newer SoCs.
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 2a6429d8c363..10182eb50068 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -1720,7 +1720,7 @@ static int pch_spi_resume(struct pci_dev *pdev)
1720 1720
1721#endif 1721#endif
1722 1722
1723static struct pci_driver pch_spi_pcidev = { 1723static struct pci_driver pch_spi_pcidev_driver = {
1724 .name = "pch_spi", 1724 .name = "pch_spi",
1725 .id_table = pch_spi_pcidev_id, 1725 .id_table = pch_spi_pcidev_id,
1726 .probe = pch_spi_probe, 1726 .probe = pch_spi_probe,
@@ -1736,7 +1736,7 @@ static int __init pch_spi_init(void)
1736 if (ret) 1736 if (ret)
1737 return ret; 1737 return ret;
1738 1738
1739 ret = pci_register_driver(&pch_spi_pcidev); 1739 ret = pci_register_driver(&pch_spi_pcidev_driver);
1740 if (ret) 1740 if (ret)
1741 return ret; 1741 return ret;
1742 1742
@@ -1746,7 +1746,7 @@ module_init(pch_spi_init);
1746 1746
1747static void __exit pch_spi_exit(void) 1747static void __exit pch_spi_exit(void)
1748{ 1748{
1749 pci_unregister_driver(&pch_spi_pcidev); 1749 pci_unregister_driver(&pch_spi_pcidev_driver);
1750 platform_driver_unregister(&pch_spi_pd_driver); 1750 platform_driver_unregister(&pch_spi_pd_driver);
1751} 1751}
1752module_exit(pch_spi_exit); 1752module_exit(pch_spi_exit);
diff --git a/drivers/staging/media/go7007/go7007-usb.c b/drivers/staging/media/go7007/go7007-usb.c
index 70e006b50f29..5443e25086e9 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1279,3 +1279,4 @@ static struct usb_driver go7007_usb_driver = {
1279}; 1279};
1280 1280
1281module_usb_driver(go7007_usb_driver); 1281module_usb_driver(go7007_usb_driver);
1282MODULE_LICENSE("GPL v2");
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index ac44af165b27..44262908def5 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1061,7 +1061,7 @@ attach_cmd:
1061 if (ret < 0) 1061 if (ret < 0)
1062 return iscsit_add_reject_from_cmd( 1062 return iscsit_add_reject_from_cmd(
1063 ISCSI_REASON_BOOKMARK_NO_RESOURCES, 1063 ISCSI_REASON_BOOKMARK_NO_RESOURCES,
1064 1, 1, buf, cmd); 1064 1, 0, buf, cmd);
1065 /* 1065 /*
1066 * Check the CmdSN against ExpCmdSN/MaxCmdSN here if 1066 * Check the CmdSN against ExpCmdSN/MaxCmdSN here if
1067 * the Immediate Bit is not set, and no Immediate 1067 * the Immediate Bit is not set, and no Immediate
@@ -3164,6 +3164,30 @@ static int iscsit_send_task_mgt_rsp(
3164 return 0; 3164 return 0;
3165} 3165}
3166 3166
3167static bool iscsit_check_inaddr_any(struct iscsi_np *np)
3168{
3169 bool ret = false;
3170
3171 if (np->np_sockaddr.ss_family == AF_INET6) {
3172 const struct sockaddr_in6 sin6 = {
3173 .sin6_addr = IN6ADDR_ANY_INIT };
3174 struct sockaddr_in6 *sock_in6 =
3175 (struct sockaddr_in6 *)&np->np_sockaddr;
3176
3177 if (!memcmp(sock_in6->sin6_addr.s6_addr,
3178 sin6.sin6_addr.s6_addr, 16))
3179 ret = true;
3180 } else {
3181 struct sockaddr_in * sock_in =
3182 (struct sockaddr_in *)&np->np_sockaddr;
3183
3184 if (sock_in->sin_addr.s_addr == INADDR_ANY)
3185 ret = true;
3186 }
3187
3188 return ret;
3189}
3190
3167static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd) 3191static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
3168{ 3192{
3169 char *payload = NULL; 3193 char *payload = NULL;
@@ -3213,12 +3237,17 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
3213 spin_lock(&tpg->tpg_np_lock); 3237 spin_lock(&tpg->tpg_np_lock);
3214 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, 3238 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list,
3215 tpg_np_list) { 3239 tpg_np_list) {
3240 struct iscsi_np *np = tpg_np->tpg_np;
3241 bool inaddr_any = iscsit_check_inaddr_any(np);
3242
3216 len = sprintf(buf, "TargetAddress=" 3243 len = sprintf(buf, "TargetAddress="
3217 "%s%s%s:%hu,%hu", 3244 "%s%s%s:%hu,%hu",
3218 (tpg_np->tpg_np->np_sockaddr.ss_family == AF_INET6) ? 3245 (np->np_sockaddr.ss_family == AF_INET6) ?
3219 "[" : "", tpg_np->tpg_np->np_ip, 3246 "[" : "", (inaddr_any == false) ?
3220 (tpg_np->tpg_np->np_sockaddr.ss_family == AF_INET6) ? 3247 np->np_ip : conn->local_ip,
3221 "]" : "", tpg_np->tpg_np->np_port, 3248 (np->np_sockaddr.ss_family == AF_INET6) ?
3249 "]" : "", (inaddr_any == false) ?
3250 np->np_port : conn->local_port,
3222 tpg->tpgt); 3251 tpg->tpgt);
3223 len += 1; 3252 len += 1;
3224 3253
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index 3468caab47a2..6b35b37988ed 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/configfs.h> 22#include <linux/configfs.h>
23#include <linux/export.h> 23#include <linux/export.h>
24#include <linux/inet.h>
24#include <target/target_core_base.h> 25#include <target/target_core_base.h>
25#include <target/target_core_fabric.h> 26#include <target/target_core_fabric.h>
26#include <target/target_core_fabric_configfs.h> 27#include <target/target_core_fabric_configfs.h>
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h
index f1a02dad05a0..0ec3b77a0c27 100644
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -508,6 +508,7 @@ struct iscsi_conn {
508 u16 cid; 508 u16 cid;
509 /* Remote TCP Port */ 509 /* Remote TCP Port */
510 u16 login_port; 510 u16 login_port;
511 u16 local_port;
511 int net_size; 512 int net_size;
512 u32 auth_id; 513 u32 auth_id;
513#define CONNFLAG_SCTP_STRUCT_FILE 0x01 514#define CONNFLAG_SCTP_STRUCT_FILE 0x01
@@ -527,6 +528,7 @@ struct iscsi_conn {
527 unsigned char bad_hdr[ISCSI_HDR_LEN]; 528 unsigned char bad_hdr[ISCSI_HDR_LEN];
528#define IPV6_ADDRESS_SPACE 48 529#define IPV6_ADDRESS_SPACE 48
529 unsigned char login_ip[IPV6_ADDRESS_SPACE]; 530 unsigned char login_ip[IPV6_ADDRESS_SPACE];
531 unsigned char local_ip[IPV6_ADDRESS_SPACE];
530 int conn_usage_count; 532 int conn_usage_count;
531 int conn_waiting_on_uc; 533 int conn_waiting_on_uc;
532 atomic_t check_immediate_queue; 534 atomic_t check_immediate_queue;
@@ -561,8 +563,8 @@ struct iscsi_conn {
561 struct hash_desc conn_tx_hash; 563 struct hash_desc conn_tx_hash;
562 /* Used for scheduling TX and RX connection kthreads */ 564 /* Used for scheduling TX and RX connection kthreads */
563 cpumask_var_t conn_cpumask; 565 cpumask_var_t conn_cpumask;
564 int conn_rx_reset_cpumask:1; 566 unsigned int conn_rx_reset_cpumask:1;
565 int conn_tx_reset_cpumask:1; 567 unsigned int conn_tx_reset_cpumask:1;
566 /* list_head of struct iscsi_cmd for this connection */ 568 /* list_head of struct iscsi_cmd for this connection */
567 struct list_head conn_cmd_list; 569 struct list_head conn_cmd_list;
568 struct list_head immed_queue_list; 570 struct list_head immed_queue_list;
diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c
index 255c0d67e898..27901e37c125 100644
--- a/drivers/target/iscsi/iscsi_target_erl1.c
+++ b/drivers/target/iscsi/iscsi_target_erl1.c
@@ -1238,7 +1238,7 @@ void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd)
1238{ 1238{
1239 struct iscsi_conn *conn = cmd->conn; 1239 struct iscsi_conn *conn = cmd->conn;
1240 struct iscsi_session *sess = conn->sess; 1240 struct iscsi_session *sess = conn->sess;
1241 struct iscsi_node_attrib *na = na = iscsit_tpg_get_node_attrib(sess); 1241 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
1242 1242
1243 spin_lock_bh(&cmd->dataout_timeout_lock); 1243 spin_lock_bh(&cmd->dataout_timeout_lock);
1244 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) { 1244 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) {
@@ -1261,7 +1261,7 @@ void iscsit_start_dataout_timer(
1261 struct iscsi_conn *conn) 1261 struct iscsi_conn *conn)
1262{ 1262{
1263 struct iscsi_session *sess = conn->sess; 1263 struct iscsi_session *sess = conn->sess;
1264 struct iscsi_node_attrib *na = na = iscsit_tpg_get_node_attrib(sess); 1264 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
1265 1265
1266 if (cmd->dataout_timer_flags & ISCSI_TF_RUNNING) 1266 if (cmd->dataout_timer_flags & ISCSI_TF_RUNNING)
1267 return; 1267 return;
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 373b0cc6abd8..38cb7ce8469e 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -615,8 +615,8 @@ static int iscsi_post_login_handler(
615 } 615 }
616 616
617 pr_debug("iSCSI Login successful on CID: %hu from %s to" 617 pr_debug("iSCSI Login successful on CID: %hu from %s to"
618 " %s:%hu,%hu\n", conn->cid, conn->login_ip, np->np_ip, 618 " %s:%hu,%hu\n", conn->cid, conn->login_ip,
619 np->np_port, tpg->tpgt); 619 conn->local_ip, conn->local_port, tpg->tpgt);
620 620
621 list_add_tail(&conn->conn_list, &sess->sess_conn_list); 621 list_add_tail(&conn->conn_list, &sess->sess_conn_list);
622 atomic_inc(&sess->nconn); 622 atomic_inc(&sess->nconn);
@@ -658,7 +658,8 @@ static int iscsi_post_login_handler(
658 sess->session_state = TARG_SESS_STATE_LOGGED_IN; 658 sess->session_state = TARG_SESS_STATE_LOGGED_IN;
659 659
660 pr_debug("iSCSI Login successful on CID: %hu from %s to %s:%hu,%hu\n", 660 pr_debug("iSCSI Login successful on CID: %hu from %s to %s:%hu,%hu\n",
661 conn->cid, conn->login_ip, np->np_ip, np->np_port, tpg->tpgt); 661 conn->cid, conn->login_ip, conn->local_ip, conn->local_port,
662 tpg->tpgt);
662 663
663 spin_lock_bh(&sess->conn_lock); 664 spin_lock_bh(&sess->conn_lock);
664 list_add_tail(&conn->conn_list, &sess->sess_conn_list); 665 list_add_tail(&conn->conn_list, &sess->sess_conn_list);
@@ -841,6 +842,14 @@ int iscsi_target_setup_login_socket(
841 goto fail; 842 goto fail;
842 } 843 }
843 844
845 ret = kernel_setsockopt(sock, IPPROTO_IP, IP_FREEBIND,
846 (char *)&opt, sizeof(opt));
847 if (ret < 0) {
848 pr_err("kernel_setsockopt() for IP_FREEBIND"
849 " failed\n");
850 goto fail;
851 }
852
844 ret = kernel_bind(sock, (struct sockaddr *)&np->np_sockaddr, len); 853 ret = kernel_bind(sock, (struct sockaddr *)&np->np_sockaddr, len);
845 if (ret < 0) { 854 if (ret < 0) {
846 pr_err("kernel_bind() failed: %d\n", ret); 855 pr_err("kernel_bind() failed: %d\n", ret);
@@ -1020,6 +1029,18 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
1020 snprintf(conn->login_ip, sizeof(conn->login_ip), "%pI6c", 1029 snprintf(conn->login_ip, sizeof(conn->login_ip), "%pI6c",
1021 &sock_in6.sin6_addr.in6_u); 1030 &sock_in6.sin6_addr.in6_u);
1022 conn->login_port = ntohs(sock_in6.sin6_port); 1031 conn->login_port = ntohs(sock_in6.sin6_port);
1032
1033 if (conn->sock->ops->getname(conn->sock,
1034 (struct sockaddr *)&sock_in6, &err, 0) < 0) {
1035 pr_err("sock_ops->getname() failed.\n");
1036 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
1037 ISCSI_LOGIN_STATUS_TARGET_ERROR);
1038 goto new_sess_out;
1039 }
1040 snprintf(conn->local_ip, sizeof(conn->local_ip), "%pI6c",
1041 &sock_in6.sin6_addr.in6_u);
1042 conn->local_port = ntohs(sock_in6.sin6_port);
1043
1023 } else { 1044 } else {
1024 memset(&sock_in, 0, sizeof(struct sockaddr_in)); 1045 memset(&sock_in, 0, sizeof(struct sockaddr_in));
1025 1046
@@ -1032,6 +1053,16 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
1032 } 1053 }
1033 sprintf(conn->login_ip, "%pI4", &sock_in.sin_addr.s_addr); 1054 sprintf(conn->login_ip, "%pI4", &sock_in.sin_addr.s_addr);
1034 conn->login_port = ntohs(sock_in.sin_port); 1055 conn->login_port = ntohs(sock_in.sin_port);
1056
1057 if (conn->sock->ops->getname(conn->sock,
1058 (struct sockaddr *)&sock_in, &err, 0) < 0) {
1059 pr_err("sock_ops->getname() failed.\n");
1060 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
1061 ISCSI_LOGIN_STATUS_TARGET_ERROR);
1062 goto new_sess_out;
1063 }
1064 sprintf(conn->local_ip, "%pI4", &sock_in.sin_addr.s_addr);
1065 conn->local_port = ntohs(sock_in.sin_port);
1035 } 1066 }
1036 1067
1037 conn->network_transport = np->np_network_transport; 1068 conn->network_transport = np->np_network_transport;
@@ -1039,7 +1070,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
1039 pr_debug("Received iSCSI login request from %s on %s Network" 1070 pr_debug("Received iSCSI login request from %s on %s Network"
1040 " Portal %s:%hu\n", conn->login_ip, 1071 " Portal %s:%hu\n", conn->login_ip,
1041 (conn->network_transport == ISCSI_TCP) ? "TCP" : "SCTP", 1072 (conn->network_transport == ISCSI_TCP) ? "TCP" : "SCTP",
1042 np->np_ip, np->np_port); 1073 conn->local_ip, conn->local_port);
1043 1074
1044 pr_debug("Moving to TARG_CONN_STATE_IN_LOGIN.\n"); 1075 pr_debug("Moving to TARG_CONN_STATE_IN_LOGIN.\n");
1045 conn->conn_state = TARG_CONN_STATE_IN_LOGIN; 1076 conn->conn_state = TARG_CONN_STATE_IN_LOGIN;
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index a05ca1c4f01c..11287e1ece13 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -849,6 +849,17 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd)
849 case ISCSI_OP_SCSI_TMFUNC: 849 case ISCSI_OP_SCSI_TMFUNC:
850 transport_generic_free_cmd(&cmd->se_cmd, 1); 850 transport_generic_free_cmd(&cmd->se_cmd, 1);
851 break; 851 break;
852 case ISCSI_OP_REJECT:
853 /*
854 * Handle special case for REJECT when iscsi_add_reject*() has
855 * overwritten the original iscsi_opcode assignment, and the
856 * associated cmd->se_cmd needs to be released.
857 */
858 if (cmd->se_cmd.se_tfo != NULL) {
859 transport_generic_free_cmd(&cmd->se_cmd, 1);
860 break;
861 }
862 /* Fall-through */
852 default: 863 default:
853 iscsit_release_cmd(cmd); 864 iscsit_release_cmd(cmd);
854 break; 865 break;
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 1b1edd14f4bf..01a2691dfb47 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -78,7 +78,7 @@ int target_emulate_report_target_port_groups(struct se_task *task)
78 return -EINVAL; 78 return -EINVAL;
79 } 79 }
80 80
81 buf = transport_kmap_first_data_page(cmd); 81 buf = transport_kmap_data_sg(cmd);
82 82
83 spin_lock(&su_dev->t10_alua.tg_pt_gps_lock); 83 spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
84 list_for_each_entry(tg_pt_gp, &su_dev->t10_alua.tg_pt_gps_list, 84 list_for_each_entry(tg_pt_gp, &su_dev->t10_alua.tg_pt_gps_list,
@@ -163,7 +163,7 @@ int target_emulate_report_target_port_groups(struct se_task *task)
163 buf[2] = ((rd_len >> 8) & 0xff); 163 buf[2] = ((rd_len >> 8) & 0xff);
164 buf[3] = (rd_len & 0xff); 164 buf[3] = (rd_len & 0xff);
165 165
166 transport_kunmap_first_data_page(cmd); 166 transport_kunmap_data_sg(cmd);
167 167
168 task->task_scsi_status = GOOD; 168 task->task_scsi_status = GOOD;
169 transport_complete_task(task, 1); 169 transport_complete_task(task, 1);
@@ -194,7 +194,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
194 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 194 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
195 return -EINVAL; 195 return -EINVAL;
196 } 196 }
197 buf = transport_kmap_first_data_page(cmd); 197 buf = transport_kmap_data_sg(cmd);
198 198
199 /* 199 /*
200 * Determine if explict ALUA via SET_TARGET_PORT_GROUPS is allowed 200 * Determine if explict ALUA via SET_TARGET_PORT_GROUPS is allowed
@@ -351,7 +351,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
351 } 351 }
352 352
353out: 353out:
354 transport_kunmap_first_data_page(cmd); 354 transport_kunmap_data_sg(cmd);
355 task->task_scsi_status = GOOD; 355 task->task_scsi_status = GOOD;
356 transport_complete_task(task, 1); 356 transport_complete_task(task, 1);
357 return 0; 357 return 0;
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
index 2f2235edefff..f3d71fa88a28 100644
--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -83,7 +83,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
83 return -EINVAL; 83 return -EINVAL;
84 } 84 }
85 85
86 buf = transport_kmap_first_data_page(cmd); 86 buf = transport_kmap_data_sg(cmd);
87 87
88 if (dev == tpg->tpg_virt_lun0.lun_se_dev) { 88 if (dev == tpg->tpg_virt_lun0.lun_se_dev) {
89 buf[0] = 0x3f; /* Not connected */ 89 buf[0] = 0x3f; /* Not connected */
@@ -134,7 +134,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
134 buf[4] = 31; /* Set additional length to 31 */ 134 buf[4] = 31; /* Set additional length to 31 */
135 135
136out: 136out:
137 transport_kunmap_first_data_page(cmd); 137 transport_kunmap_data_sg(cmd);
138 return 0; 138 return 0;
139} 139}
140 140
@@ -698,6 +698,13 @@ int target_emulate_inquiry(struct se_task *task)
698 int p, ret; 698 int p, ret;
699 699
700 if (!(cdb[1] & 0x1)) { 700 if (!(cdb[1] & 0x1)) {
701 if (cdb[2]) {
702 pr_err("INQUIRY with EVPD==0 but PAGE CODE=%02x\n",
703 cdb[2]);
704 cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD;
705 return -EINVAL;
706 }
707
701 ret = target_emulate_inquiry_std(cmd); 708 ret = target_emulate_inquiry_std(cmd);
702 goto out; 709 goto out;
703 } 710 }
@@ -716,7 +723,7 @@ int target_emulate_inquiry(struct se_task *task)
716 return -EINVAL; 723 return -EINVAL;
717 } 724 }
718 725
719 buf = transport_kmap_first_data_page(cmd); 726 buf = transport_kmap_data_sg(cmd);
720 727
721 buf[0] = dev->transport->get_device_type(dev); 728 buf[0] = dev->transport->get_device_type(dev);
722 729
@@ -729,11 +736,11 @@ int target_emulate_inquiry(struct se_task *task)
729 } 736 }
730 737
731 pr_err("Unknown VPD Code: 0x%02x\n", cdb[2]); 738 pr_err("Unknown VPD Code: 0x%02x\n", cdb[2]);
732 cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; 739 cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD;
733 ret = -EINVAL; 740 ret = -EINVAL;
734 741
735out_unmap: 742out_unmap:
736 transport_kunmap_first_data_page(cmd); 743 transport_kunmap_data_sg(cmd);
737out: 744out:
738 if (!ret) { 745 if (!ret) {
739 task->task_scsi_status = GOOD; 746 task->task_scsi_status = GOOD;
@@ -755,7 +762,7 @@ int target_emulate_readcapacity(struct se_task *task)
755 else 762 else
756 blocks = (u32)blocks_long; 763 blocks = (u32)blocks_long;
757 764
758 buf = transport_kmap_first_data_page(cmd); 765 buf = transport_kmap_data_sg(cmd);
759 766
760 buf[0] = (blocks >> 24) & 0xff; 767 buf[0] = (blocks >> 24) & 0xff;
761 buf[1] = (blocks >> 16) & 0xff; 768 buf[1] = (blocks >> 16) & 0xff;
@@ -771,7 +778,7 @@ int target_emulate_readcapacity(struct se_task *task)
771 if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws) 778 if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws)
772 put_unaligned_be32(0xFFFFFFFF, &buf[0]); 779 put_unaligned_be32(0xFFFFFFFF, &buf[0]);
773 780
774 transport_kunmap_first_data_page(cmd); 781 transport_kunmap_data_sg(cmd);
775 782
776 task->task_scsi_status = GOOD; 783 task->task_scsi_status = GOOD;
777 transport_complete_task(task, 1); 784 transport_complete_task(task, 1);
@@ -785,7 +792,7 @@ int target_emulate_readcapacity_16(struct se_task *task)
785 unsigned char *buf; 792 unsigned char *buf;
786 unsigned long long blocks = dev->transport->get_blocks(dev); 793 unsigned long long blocks = dev->transport->get_blocks(dev);
787 794
788 buf = transport_kmap_first_data_page(cmd); 795 buf = transport_kmap_data_sg(cmd);
789 796
790 buf[0] = (blocks >> 56) & 0xff; 797 buf[0] = (blocks >> 56) & 0xff;
791 buf[1] = (blocks >> 48) & 0xff; 798 buf[1] = (blocks >> 48) & 0xff;
@@ -806,7 +813,7 @@ int target_emulate_readcapacity_16(struct se_task *task)
806 if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws) 813 if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws)
807 buf[14] = 0x80; 814 buf[14] = 0x80;
808 815
809 transport_kunmap_first_data_page(cmd); 816 transport_kunmap_data_sg(cmd);
810 817
811 task->task_scsi_status = GOOD; 818 task->task_scsi_status = GOOD;
812 transport_complete_task(task, 1); 819 transport_complete_task(task, 1);
@@ -1019,9 +1026,9 @@ int target_emulate_modesense(struct se_task *task)
1019 offset = cmd->data_length; 1026 offset = cmd->data_length;
1020 } 1027 }
1021 1028
1022 rbuf = transport_kmap_first_data_page(cmd); 1029 rbuf = transport_kmap_data_sg(cmd);
1023 memcpy(rbuf, buf, offset); 1030 memcpy(rbuf, buf, offset);
1024 transport_kunmap_first_data_page(cmd); 1031 transport_kunmap_data_sg(cmd);
1025 1032
1026 task->task_scsi_status = GOOD; 1033 task->task_scsi_status = GOOD;
1027 transport_complete_task(task, 1); 1034 transport_complete_task(task, 1);
@@ -1043,7 +1050,7 @@ int target_emulate_request_sense(struct se_task *task)
1043 return -ENOSYS; 1050 return -ENOSYS;
1044 } 1051 }
1045 1052
1046 buf = transport_kmap_first_data_page(cmd); 1053 buf = transport_kmap_data_sg(cmd);
1047 1054
1048 if (!core_scsi3_ua_clear_for_request_sense(cmd, &ua_asc, &ua_ascq)) { 1055 if (!core_scsi3_ua_clear_for_request_sense(cmd, &ua_asc, &ua_ascq)) {
1049 /* 1056 /*
@@ -1051,11 +1058,8 @@ int target_emulate_request_sense(struct se_task *task)
1051 */ 1058 */
1052 buf[0] = 0x70; 1059 buf[0] = 0x70;
1053 buf[SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; 1060 buf[SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION;
1054 /* 1061
1055 * Make sure request data length is enough for additional 1062 if (cmd->data_length < 18) {
1056 * sense data.
1057 */
1058 if (cmd->data_length <= 18) {
1059 buf[7] = 0x00; 1063 buf[7] = 0x00;
1060 err = -EINVAL; 1064 err = -EINVAL;
1061 goto end; 1065 goto end;
@@ -1072,11 +1076,8 @@ int target_emulate_request_sense(struct se_task *task)
1072 */ 1076 */
1073 buf[0] = 0x70; 1077 buf[0] = 0x70;
1074 buf[SPC_SENSE_KEY_OFFSET] = NO_SENSE; 1078 buf[SPC_SENSE_KEY_OFFSET] = NO_SENSE;
1075 /* 1079
1076 * Make sure request data length is enough for additional 1080 if (cmd->data_length < 18) {
1077 * sense data.
1078 */
1079 if (cmd->data_length <= 18) {
1080 buf[7] = 0x00; 1081 buf[7] = 0x00;
1081 err = -EINVAL; 1082 err = -EINVAL;
1082 goto end; 1083 goto end;
@@ -1089,7 +1090,7 @@ int target_emulate_request_sense(struct se_task *task)
1089 } 1090 }
1090 1091
1091end: 1092end:
1092 transport_kunmap_first_data_page(cmd); 1093 transport_kunmap_data_sg(cmd);
1093 task->task_scsi_status = GOOD; 1094 task->task_scsi_status = GOOD;
1094 transport_complete_task(task, 1); 1095 transport_complete_task(task, 1);
1095 return 0; 1096 return 0;
@@ -1123,7 +1124,7 @@ int target_emulate_unmap(struct se_task *task)
1123 dl = get_unaligned_be16(&cdb[0]); 1124 dl = get_unaligned_be16(&cdb[0]);
1124 bd_dl = get_unaligned_be16(&cdb[2]); 1125 bd_dl = get_unaligned_be16(&cdb[2]);
1125 1126
1126 buf = transport_kmap_first_data_page(cmd); 1127 buf = transport_kmap_data_sg(cmd);
1127 1128
1128 ptr = &buf[offset]; 1129 ptr = &buf[offset];
1129 pr_debug("UNMAP: Sub: %s Using dl: %hu bd_dl: %hu size: %hu" 1130 pr_debug("UNMAP: Sub: %s Using dl: %hu bd_dl: %hu size: %hu"
@@ -1147,7 +1148,7 @@ int target_emulate_unmap(struct se_task *task)
1147 } 1148 }
1148 1149
1149err: 1150err:
1150 transport_kunmap_first_data_page(cmd); 1151 transport_kunmap_data_sg(cmd);
1151 if (!ret) { 1152 if (!ret) {
1152 task->task_scsi_status = GOOD; 1153 task->task_scsi_status = GOOD;
1153 transport_complete_task(task, 1); 1154 transport_complete_task(task, 1);
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 0955bb8979fb..6e043eeb1db9 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1704,13 +1704,15 @@ static ssize_t target_core_store_dev_alias(
1704 return -EINVAL; 1704 return -EINVAL;
1705 } 1705 }
1706 1706
1707 se_dev->su_dev_flags |= SDF_USING_ALIAS;
1708 read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN, 1707 read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN,
1709 "%s", page); 1708 "%s", page);
1710 1709 if (!read_bytes)
1710 return -EINVAL;
1711 if (se_dev->se_dev_alias[read_bytes - 1] == '\n') 1711 if (se_dev->se_dev_alias[read_bytes - 1] == '\n')
1712 se_dev->se_dev_alias[read_bytes - 1] = '\0'; 1712 se_dev->se_dev_alias[read_bytes - 1] = '\0';
1713 1713
1714 se_dev->su_dev_flags |= SDF_USING_ALIAS;
1715
1714 pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n", 1716 pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n",
1715 config_item_name(&hba->hba_group.cg_item), 1717 config_item_name(&hba->hba_group.cg_item),
1716 config_item_name(&se_dev->se_dev_group.cg_item), 1718 config_item_name(&se_dev->se_dev_group.cg_item),
@@ -1753,13 +1755,15 @@ static ssize_t target_core_store_dev_udev_path(
1753 return -EINVAL; 1755 return -EINVAL;
1754 } 1756 }
1755 1757
1756 se_dev->su_dev_flags |= SDF_USING_UDEV_PATH;
1757 read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN, 1758 read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN,
1758 "%s", page); 1759 "%s", page);
1759 1760 if (!read_bytes)
1761 return -EINVAL;
1760 if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n') 1762 if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n')
1761 se_dev->se_dev_udev_path[read_bytes - 1] = '\0'; 1763 se_dev->se_dev_udev_path[read_bytes - 1] = '\0';
1762 1764
1765 se_dev->su_dev_flags |= SDF_USING_UDEV_PATH;
1766
1763 pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n", 1767 pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n",
1764 config_item_name(&hba->hba_group.cg_item), 1768 config_item_name(&hba->hba_group.cg_item),
1765 config_item_name(&se_dev->se_dev_group.cg_item), 1769 config_item_name(&se_dev->se_dev_group.cg_item),
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 0c5992f0d946..edbcabbf85f7 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -320,11 +320,12 @@ int core_free_device_list_for_node(
320void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd) 320void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd)
321{ 321{
322 struct se_dev_entry *deve; 322 struct se_dev_entry *deve;
323 unsigned long flags;
323 324
324 spin_lock_irq(&se_nacl->device_list_lock); 325 spin_lock_irqsave(&se_nacl->device_list_lock, flags);
325 deve = &se_nacl->device_list[se_cmd->orig_fe_lun]; 326 deve = &se_nacl->device_list[se_cmd->orig_fe_lun];
326 deve->deve_cmds--; 327 deve->deve_cmds--;
327 spin_unlock_irq(&se_nacl->device_list_lock); 328 spin_unlock_irqrestore(&se_nacl->device_list_lock, flags);
328} 329}
329 330
330void core_update_device_list_access( 331void core_update_device_list_access(
@@ -656,7 +657,7 @@ int target_report_luns(struct se_task *se_task)
656 unsigned char *buf; 657 unsigned char *buf;
657 u32 cdb_offset = 0, lun_count = 0, offset = 8, i; 658 u32 cdb_offset = 0, lun_count = 0, offset = 8, i;
658 659
659 buf = transport_kmap_first_data_page(se_cmd); 660 buf = (unsigned char *) transport_kmap_data_sg(se_cmd);
660 661
661 /* 662 /*
662 * If no struct se_session pointer is present, this struct se_cmd is 663 * If no struct se_session pointer is present, this struct se_cmd is
@@ -694,7 +695,7 @@ int target_report_luns(struct se_task *se_task)
694 * See SPC3 r07, page 159. 695 * See SPC3 r07, page 159.
695 */ 696 */
696done: 697done:
697 transport_kunmap_first_data_page(se_cmd); 698 transport_kunmap_data_sg(se_cmd);
698 lun_count *= 8; 699 lun_count *= 8;
699 buf[0] = ((lun_count >> 24) & 0xff); 700 buf[0] = ((lun_count >> 24) & 0xff);
700 buf[1] = ((lun_count >> 16) & 0xff); 701 buf[1] = ((lun_count >> 16) & 0xff);
@@ -1294,24 +1295,26 @@ struct se_lun *core_dev_add_lun(
1294{ 1295{
1295 struct se_lun *lun_p; 1296 struct se_lun *lun_p;
1296 u32 lun_access = 0; 1297 u32 lun_access = 0;
1298 int rc;
1297 1299
1298 if (atomic_read(&dev->dev_access_obj.obj_access_count) != 0) { 1300 if (atomic_read(&dev->dev_access_obj.obj_access_count) != 0) {
1299 pr_err("Unable to export struct se_device while dev_access_obj: %d\n", 1301 pr_err("Unable to export struct se_device while dev_access_obj: %d\n",
1300 atomic_read(&dev->dev_access_obj.obj_access_count)); 1302 atomic_read(&dev->dev_access_obj.obj_access_count));
1301 return NULL; 1303 return ERR_PTR(-EACCES);
1302 } 1304 }
1303 1305
1304 lun_p = core_tpg_pre_addlun(tpg, lun); 1306 lun_p = core_tpg_pre_addlun(tpg, lun);
1305 if ((IS_ERR(lun_p)) || !lun_p) 1307 if (IS_ERR(lun_p))
1306 return NULL; 1308 return lun_p;
1307 1309
1308 if (dev->dev_flags & DF_READ_ONLY) 1310 if (dev->dev_flags & DF_READ_ONLY)
1309 lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; 1311 lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
1310 else 1312 else
1311 lun_access = TRANSPORT_LUNFLAGS_READ_WRITE; 1313 lun_access = TRANSPORT_LUNFLAGS_READ_WRITE;
1312 1314
1313 if (core_tpg_post_addlun(tpg, lun_p, lun_access, dev) < 0) 1315 rc = core_tpg_post_addlun(tpg, lun_p, lun_access, dev);
1314 return NULL; 1316 if (rc < 0)
1317 return ERR_PTR(rc);
1315 1318
1316 pr_debug("%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from" 1319 pr_debug("%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from"
1317 " CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(), 1320 " CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(),
@@ -1348,11 +1351,10 @@ int core_dev_del_lun(
1348 u32 unpacked_lun) 1351 u32 unpacked_lun)
1349{ 1352{
1350 struct se_lun *lun; 1353 struct se_lun *lun;
1351 int ret = 0;
1352 1354
1353 lun = core_tpg_pre_dellun(tpg, unpacked_lun, &ret); 1355 lun = core_tpg_pre_dellun(tpg, unpacked_lun);
1354 if (!lun) 1356 if (IS_ERR(lun))
1355 return ret; 1357 return PTR_ERR(lun);
1356 1358
1357 core_tpg_post_dellun(tpg, lun); 1359 core_tpg_post_dellun(tpg, lun);
1358 1360
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index 4f77cce22646..9a2ce11e1a6e 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -766,9 +766,9 @@ static int target_fabric_port_link(
766 766
767 lun_p = core_dev_add_lun(se_tpg, dev->se_hba, dev, 767 lun_p = core_dev_add_lun(se_tpg, dev->se_hba, dev,
768 lun->unpacked_lun); 768 lun->unpacked_lun);
769 if (IS_ERR(lun_p) || !lun_p) { 769 if (IS_ERR(lun_p)) {
770 pr_err("core_dev_add_lun() failed\n"); 770 pr_err("core_dev_add_lun() failed\n");
771 ret = -EINVAL; 771 ret = PTR_ERR(lun_p);
772 goto out; 772 goto out;
773 } 773 }
774 774
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index cc8e6b58ef20..8572eae62da7 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -129,7 +129,7 @@ static struct se_device *iblock_create_virtdevice(
129 /* 129 /*
130 * These settings need to be made tunable.. 130 * These settings need to be made tunable..
131 */ 131 */
132 ib_dev->ibd_bio_set = bioset_create(32, 64); 132 ib_dev->ibd_bio_set = bioset_create(32, 0);
133 if (!ib_dev->ibd_bio_set) { 133 if (!ib_dev->ibd_bio_set) {
134 pr_err("IBLOCK: Unable to create bioset()\n"); 134 pr_err("IBLOCK: Unable to create bioset()\n");
135 return ERR_PTR(-ENOMEM); 135 return ERR_PTR(-ENOMEM);
@@ -181,7 +181,7 @@ static struct se_device *iblock_create_virtdevice(
181 */ 181 */
182 dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count = 1; 182 dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count = 1;
183 dev->se_sub_dev->se_dev_attrib.unmap_granularity = 183 dev->se_sub_dev->se_dev_attrib.unmap_granularity =
184 q->limits.discard_granularity; 184 q->limits.discard_granularity >> 9;
185 dev->se_sub_dev->se_dev_attrib.unmap_granularity_alignment = 185 dev->se_sub_dev->se_dev_attrib.unmap_granularity_alignment =
186 q->limits.discard_alignment; 186 q->limits.discard_alignment;
187 187
@@ -488,6 +488,13 @@ iblock_get_bio(struct se_task *task, sector_t lba, u32 sg_num)
488 struct iblock_req *ib_req = IBLOCK_REQ(task); 488 struct iblock_req *ib_req = IBLOCK_REQ(task);
489 struct bio *bio; 489 struct bio *bio;
490 490
491 /*
492 * Only allocate as many vector entries as the bio code allows us to,
493 * we'll loop later on until we have handled the whole request.
494 */
495 if (sg_num > BIO_MAX_PAGES)
496 sg_num = BIO_MAX_PAGES;
497
491 bio = bio_alloc_bioset(GFP_NOIO, sg_num, ib_dev->ibd_bio_set); 498 bio = bio_alloc_bioset(GFP_NOIO, sg_num, ib_dev->ibd_bio_set);
492 if (!bio) { 499 if (!bio) {
493 pr_err("Unable to allocate memory for bio\n"); 500 pr_err("Unable to allocate memory for bio\n");
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 26f135e94f6e..45001364788a 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -90,7 +90,7 @@ void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *);
90struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32); 90struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32);
91int core_tpg_post_addlun(struct se_portal_group *, struct se_lun *, 91int core_tpg_post_addlun(struct se_portal_group *, struct se_lun *,
92 u32, void *); 92 u32, void *);
93struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32, int *); 93struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32 unpacked_lun);
94int core_tpg_post_dellun(struct se_portal_group *, struct se_lun *); 94int core_tpg_post_dellun(struct se_portal_group *, struct se_lun *);
95 95
96/* target_core_transport.c */ 96/* target_core_transport.c */
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 429ad7291664..b7c779389eea 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -478,6 +478,7 @@ static int core_scsi3_pr_seq_non_holder(
478 case READ_MEDIA_SERIAL_NUMBER: 478 case READ_MEDIA_SERIAL_NUMBER:
479 case REPORT_LUNS: 479 case REPORT_LUNS:
480 case REQUEST_SENSE: 480 case REQUEST_SENSE:
481 case PERSISTENT_RESERVE_IN:
481 ret = 0; /*/ Allowed CDBs */ 482 ret = 0; /*/ Allowed CDBs */
482 break; 483 break;
483 default: 484 default:
@@ -1534,7 +1535,7 @@ static int core_scsi3_decode_spec_i_port(
1534 tidh_new->dest_local_nexus = 1; 1535 tidh_new->dest_local_nexus = 1;
1535 list_add_tail(&tidh_new->dest_list, &tid_dest_list); 1536 list_add_tail(&tidh_new->dest_list, &tid_dest_list);
1536 1537
1537 buf = transport_kmap_first_data_page(cmd); 1538 buf = transport_kmap_data_sg(cmd);
1538 /* 1539 /*
1539 * For a PERSISTENT RESERVE OUT specify initiator ports payload, 1540 * For a PERSISTENT RESERVE OUT specify initiator ports payload,
1540 * first extract TransportID Parameter Data Length, and make sure 1541 * first extract TransportID Parameter Data Length, and make sure
@@ -1785,7 +1786,7 @@ static int core_scsi3_decode_spec_i_port(
1785 1786
1786 } 1787 }
1787 1788
1788 transport_kunmap_first_data_page(cmd); 1789 transport_kunmap_data_sg(cmd);
1789 1790
1790 /* 1791 /*
1791 * Go ahead and create a registrations from tid_dest_list for the 1792 * Go ahead and create a registrations from tid_dest_list for the
@@ -1833,7 +1834,7 @@ static int core_scsi3_decode_spec_i_port(
1833 1834
1834 return 0; 1835 return 0;
1835out: 1836out:
1836 transport_kunmap_first_data_page(cmd); 1837 transport_kunmap_data_sg(cmd);
1837 /* 1838 /*
1838 * For the failure case, release everything from tid_dest_list 1839 * For the failure case, release everything from tid_dest_list
1839 * including *dest_pr_reg and the configfs dependances.. 1840 * including *dest_pr_reg and the configfs dependances..
@@ -3120,7 +3121,7 @@ static int core_scsi3_pro_preempt(
3120 if (!calling_it_nexus) 3121 if (!calling_it_nexus)
3121 core_scsi3_ua_allocate(pr_reg_nacl, 3122 core_scsi3_ua_allocate(pr_reg_nacl,
3122 pr_res_mapped_lun, 0x2A, 3123 pr_res_mapped_lun, 0x2A,
3123 ASCQ_2AH_RESERVATIONS_PREEMPTED); 3124 ASCQ_2AH_REGISTRATIONS_PREEMPTED);
3124 } 3125 }
3125 spin_unlock(&pr_tmpl->registration_lock); 3126 spin_unlock(&pr_tmpl->registration_lock);
3126 /* 3127 /*
@@ -3233,7 +3234,7 @@ static int core_scsi3_pro_preempt(
3233 * additional sense code set to REGISTRATIONS PREEMPTED; 3234 * additional sense code set to REGISTRATIONS PREEMPTED;
3234 */ 3235 */
3235 core_scsi3_ua_allocate(pr_reg_nacl, pr_res_mapped_lun, 0x2A, 3236 core_scsi3_ua_allocate(pr_reg_nacl, pr_res_mapped_lun, 0x2A,
3236 ASCQ_2AH_RESERVATIONS_PREEMPTED); 3237 ASCQ_2AH_REGISTRATIONS_PREEMPTED);
3237 } 3238 }
3238 spin_unlock(&pr_tmpl->registration_lock); 3239 spin_unlock(&pr_tmpl->registration_lock);
3239 /* 3240 /*
@@ -3410,14 +3411,14 @@ static int core_scsi3_emulate_pro_register_and_move(
3410 * will be moved to for the TransportID containing SCSI initiator WWN 3411 * will be moved to for the TransportID containing SCSI initiator WWN
3411 * information. 3412 * information.
3412 */ 3413 */
3413 buf = transport_kmap_first_data_page(cmd); 3414 buf = transport_kmap_data_sg(cmd);
3414 rtpi = (buf[18] & 0xff) << 8; 3415 rtpi = (buf[18] & 0xff) << 8;
3415 rtpi |= buf[19] & 0xff; 3416 rtpi |= buf[19] & 0xff;
3416 tid_len = (buf[20] & 0xff) << 24; 3417 tid_len = (buf[20] & 0xff) << 24;
3417 tid_len |= (buf[21] & 0xff) << 16; 3418 tid_len |= (buf[21] & 0xff) << 16;
3418 tid_len |= (buf[22] & 0xff) << 8; 3419 tid_len |= (buf[22] & 0xff) << 8;
3419 tid_len |= buf[23] & 0xff; 3420 tid_len |= buf[23] & 0xff;
3420 transport_kunmap_first_data_page(cmd); 3421 transport_kunmap_data_sg(cmd);
3421 buf = NULL; 3422 buf = NULL;
3422 3423
3423 if ((tid_len + 24) != cmd->data_length) { 3424 if ((tid_len + 24) != cmd->data_length) {
@@ -3469,7 +3470,7 @@ static int core_scsi3_emulate_pro_register_and_move(
3469 return -EINVAL; 3470 return -EINVAL;
3470 } 3471 }
3471 3472
3472 buf = transport_kmap_first_data_page(cmd); 3473 buf = transport_kmap_data_sg(cmd);
3473 proto_ident = (buf[24] & 0x0f); 3474 proto_ident = (buf[24] & 0x0f);
3474#if 0 3475#if 0
3475 pr_debug("SPC-3 PR REGISTER_AND_MOVE: Extracted Protocol Identifier:" 3476 pr_debug("SPC-3 PR REGISTER_AND_MOVE: Extracted Protocol Identifier:"
@@ -3503,7 +3504,7 @@ static int core_scsi3_emulate_pro_register_and_move(
3503 goto out; 3504 goto out;
3504 } 3505 }
3505 3506
3506 transport_kunmap_first_data_page(cmd); 3507 transport_kunmap_data_sg(cmd);
3507 buf = NULL; 3508 buf = NULL;
3508 3509
3509 pr_debug("SPC-3 PR [%s] Extracted initiator %s identifier: %s" 3510 pr_debug("SPC-3 PR [%s] Extracted initiator %s identifier: %s"
@@ -3768,13 +3769,13 @@ after_iport_check:
3768 " REGISTER_AND_MOVE\n"); 3769 " REGISTER_AND_MOVE\n");
3769 } 3770 }
3770 3771
3771 transport_kunmap_first_data_page(cmd); 3772 transport_kunmap_data_sg(cmd);
3772 3773
3773 core_scsi3_put_pr_reg(dest_pr_reg); 3774 core_scsi3_put_pr_reg(dest_pr_reg);
3774 return 0; 3775 return 0;
3775out: 3776out:
3776 if (buf) 3777 if (buf)
3777 transport_kunmap_first_data_page(cmd); 3778 transport_kunmap_data_sg(cmd);
3778 if (dest_se_deve) 3779 if (dest_se_deve)
3779 core_scsi3_lunacl_undepend_item(dest_se_deve); 3780 core_scsi3_lunacl_undepend_item(dest_se_deve);
3780 if (dest_node_acl) 3781 if (dest_node_acl)
@@ -3848,7 +3849,7 @@ int target_scsi3_emulate_pr_out(struct se_task *task)
3848 scope = (cdb[2] & 0xf0); 3849 scope = (cdb[2] & 0xf0);
3849 type = (cdb[2] & 0x0f); 3850 type = (cdb[2] & 0x0f);
3850 3851
3851 buf = transport_kmap_first_data_page(cmd); 3852 buf = transport_kmap_data_sg(cmd);
3852 /* 3853 /*
3853 * From PERSISTENT_RESERVE_OUT parameter list (payload) 3854 * From PERSISTENT_RESERVE_OUT parameter list (payload)
3854 */ 3855 */
@@ -3866,7 +3867,7 @@ int target_scsi3_emulate_pr_out(struct se_task *task)
3866 aptpl = (buf[17] & 0x01); 3867 aptpl = (buf[17] & 0x01);
3867 unreg = (buf[17] & 0x02); 3868 unreg = (buf[17] & 0x02);
3868 } 3869 }
3869 transport_kunmap_first_data_page(cmd); 3870 transport_kunmap_data_sg(cmd);
3870 buf = NULL; 3871 buf = NULL;
3871 3872
3872 /* 3873 /*
@@ -3966,7 +3967,7 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
3966 return -EINVAL; 3967 return -EINVAL;
3967 } 3968 }
3968 3969
3969 buf = transport_kmap_first_data_page(cmd); 3970 buf = transport_kmap_data_sg(cmd);
3970 buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); 3971 buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff);
3971 buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); 3972 buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff);
3972 buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff); 3973 buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff);
@@ -4000,7 +4001,7 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
4000 buf[6] = ((add_len >> 8) & 0xff); 4001 buf[6] = ((add_len >> 8) & 0xff);
4001 buf[7] = (add_len & 0xff); 4002 buf[7] = (add_len & 0xff);
4002 4003
4003 transport_kunmap_first_data_page(cmd); 4004 transport_kunmap_data_sg(cmd);
4004 4005
4005 return 0; 4006 return 0;
4006} 4007}
@@ -4026,7 +4027,7 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd)
4026 return -EINVAL; 4027 return -EINVAL;
4027 } 4028 }
4028 4029
4029 buf = transport_kmap_first_data_page(cmd); 4030 buf = transport_kmap_data_sg(cmd);
4030 buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); 4031 buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff);
4031 buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); 4032 buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff);
4032 buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff); 4033 buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff);
@@ -4085,7 +4086,7 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd)
4085 4086
4086err: 4087err:
4087 spin_unlock(&se_dev->dev_reservation_lock); 4088 spin_unlock(&se_dev->dev_reservation_lock);
4088 transport_kunmap_first_data_page(cmd); 4089 transport_kunmap_data_sg(cmd);
4089 4090
4090 return 0; 4091 return 0;
4091} 4092}
@@ -4109,7 +4110,7 @@ static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
4109 return -EINVAL; 4110 return -EINVAL;
4110 } 4111 }
4111 4112
4112 buf = transport_kmap_first_data_page(cmd); 4113 buf = transport_kmap_data_sg(cmd);
4113 4114
4114 buf[0] = ((add_len << 8) & 0xff); 4115 buf[0] = ((add_len << 8) & 0xff);
4115 buf[1] = (add_len & 0xff); 4116 buf[1] = (add_len & 0xff);
@@ -4141,7 +4142,7 @@ static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
4141 buf[4] |= 0x02; /* PR_TYPE_WRITE_EXCLUSIVE */ 4142 buf[4] |= 0x02; /* PR_TYPE_WRITE_EXCLUSIVE */
4142 buf[5] |= 0x01; /* PR_TYPE_EXCLUSIVE_ACCESS_ALLREG */ 4143 buf[5] |= 0x01; /* PR_TYPE_EXCLUSIVE_ACCESS_ALLREG */
4143 4144
4144 transport_kunmap_first_data_page(cmd); 4145 transport_kunmap_data_sg(cmd);
4145 4146
4146 return 0; 4147 return 0;
4147} 4148}
@@ -4171,7 +4172,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
4171 return -EINVAL; 4172 return -EINVAL;
4172 } 4173 }
4173 4174
4174 buf = transport_kmap_first_data_page(cmd); 4175 buf = transport_kmap_data_sg(cmd);
4175 4176
4176 buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); 4177 buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff);
4177 buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); 4178 buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff);
@@ -4292,7 +4293,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
4292 buf[6] = ((add_len >> 8) & 0xff); 4293 buf[6] = ((add_len >> 8) & 0xff);
4293 buf[7] = (add_len & 0xff); 4294 buf[7] = (add_len & 0xff);
4294 4295
4295 transport_kunmap_first_data_page(cmd); 4296 transport_kunmap_data_sg(cmd);
4296 4297
4297 return 0; 4298 return 0;
4298} 4299}
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index d35467d42e12..8d4def30e9e8 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -693,7 +693,7 @@ static int pscsi_transport_complete(struct se_task *task)
693 693
694 if (task->task_se_cmd->se_deve->lun_flags & 694 if (task->task_se_cmd->se_deve->lun_flags &
695 TRANSPORT_LUNFLAGS_READ_ONLY) { 695 TRANSPORT_LUNFLAGS_READ_ONLY) {
696 unsigned char *buf = transport_kmap_first_data_page(task->task_se_cmd); 696 unsigned char *buf = transport_kmap_data_sg(task->task_se_cmd);
697 697
698 if (cdb[0] == MODE_SENSE_10) { 698 if (cdb[0] == MODE_SENSE_10) {
699 if (!(buf[3] & 0x80)) 699 if (!(buf[3] & 0x80))
@@ -703,7 +703,7 @@ static int pscsi_transport_complete(struct se_task *task)
703 buf[2] |= 0x80; 703 buf[2] |= 0x80;
704 } 704 }
705 705
706 transport_kunmap_first_data_page(task->task_se_cmd); 706 transport_kunmap_data_sg(task->task_se_cmd);
707 } 707 }
708 } 708 }
709after_mode_sense: 709after_mode_sense:
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index b7668029bb31..06336ecd872d 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -807,8 +807,7 @@ static void core_tpg_shutdown_lun(
807 807
808struct se_lun *core_tpg_pre_dellun( 808struct se_lun *core_tpg_pre_dellun(
809 struct se_portal_group *tpg, 809 struct se_portal_group *tpg,
810 u32 unpacked_lun, 810 u32 unpacked_lun)
811 int *ret)
812{ 811{
813 struct se_lun *lun; 812 struct se_lun *lun;
814 813
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index d3ddd1361949..58cea07b12fb 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1255,32 +1255,34 @@ static void core_setup_task_attr_emulation(struct se_device *dev)
1255static void scsi_dump_inquiry(struct se_device *dev) 1255static void scsi_dump_inquiry(struct se_device *dev)
1256{ 1256{
1257 struct t10_wwn *wwn = &dev->se_sub_dev->t10_wwn; 1257 struct t10_wwn *wwn = &dev->se_sub_dev->t10_wwn;
1258 char buf[17];
1258 int i, device_type; 1259 int i, device_type;
1259 /* 1260 /*
1260 * Print Linux/SCSI style INQUIRY formatting to the kernel ring buffer 1261 * Print Linux/SCSI style INQUIRY formatting to the kernel ring buffer
1261 */ 1262 */
1262 pr_debug(" Vendor: ");
1263 for (i = 0; i < 8; i++) 1263 for (i = 0; i < 8; i++)
1264 if (wwn->vendor[i] >= 0x20) 1264 if (wwn->vendor[i] >= 0x20)
1265 pr_debug("%c", wwn->vendor[i]); 1265 buf[i] = wwn->vendor[i];
1266 else 1266 else
1267 pr_debug(" "); 1267 buf[i] = ' ';
1268 buf[i] = '\0';
1269 pr_debug(" Vendor: %s\n", buf);
1268 1270
1269 pr_debug(" Model: ");
1270 for (i = 0; i < 16; i++) 1271 for (i = 0; i < 16; i++)
1271 if (wwn->model[i] >= 0x20) 1272 if (wwn->model[i] >= 0x20)
1272 pr_debug("%c", wwn->model[i]); 1273 buf[i] = wwn->model[i];
1273 else 1274 else
1274 pr_debug(" "); 1275 buf[i] = ' ';
1276 buf[i] = '\0';
1277 pr_debug(" Model: %s\n", buf);
1275 1278
1276 pr_debug(" Revision: ");
1277 for (i = 0; i < 4; i++) 1279 for (i = 0; i < 4; i++)
1278 if (wwn->revision[i] >= 0x20) 1280 if (wwn->revision[i] >= 0x20)
1279 pr_debug("%c", wwn->revision[i]); 1281 buf[i] = wwn->revision[i];
1280 else 1282 else
1281 pr_debug(" "); 1283 buf[i] = ' ';
1282 1284 buf[i] = '\0';
1283 pr_debug("\n"); 1285 pr_debug(" Revision: %s\n", buf);
1284 1286
1285 device_type = dev->transport->get_device_type(dev); 1287 device_type = dev->transport->get_device_type(dev);
1286 pr_debug(" Type: %s ", scsi_device_type(device_type)); 1288 pr_debug(" Type: %s ", scsi_device_type(device_type));
@@ -1655,7 +1657,7 @@ EXPORT_SYMBOL(transport_handle_cdb_direct);
1655 * This may only be called from process context, and also currently 1657 * This may only be called from process context, and also currently
1656 * assumes internal allocation of fabric payload buffer by target-core. 1658 * assumes internal allocation of fabric payload buffer by target-core.
1657 **/ 1659 **/
1658int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, 1660void target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
1659 unsigned char *cdb, unsigned char *sense, u32 unpacked_lun, 1661 unsigned char *cdb, unsigned char *sense, u32 unpacked_lun,
1660 u32 data_length, int task_attr, int data_dir, int flags) 1662 u32 data_length, int task_attr, int data_dir, int flags)
1661{ 1663{
@@ -1688,15 +1690,21 @@ int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
1688 /* 1690 /*
1689 * Locate se_lun pointer and attach it to struct se_cmd 1691 * Locate se_lun pointer and attach it to struct se_cmd
1690 */ 1692 */
1691 if (transport_lookup_cmd_lun(se_cmd, unpacked_lun) < 0) 1693 if (transport_lookup_cmd_lun(se_cmd, unpacked_lun) < 0) {
1692 goto out_check_cond; 1694 transport_send_check_condition_and_sense(se_cmd,
1695 se_cmd->scsi_sense_reason, 0);
1696 target_put_sess_cmd(se_sess, se_cmd);
1697 return;
1698 }
1693 /* 1699 /*
1694 * Sanitize CDBs via transport_generic_cmd_sequencer() and 1700 * Sanitize CDBs via transport_generic_cmd_sequencer() and
1695 * allocate the necessary tasks to complete the received CDB+data 1701 * allocate the necessary tasks to complete the received CDB+data
1696 */ 1702 */
1697 rc = transport_generic_allocate_tasks(se_cmd, cdb); 1703 rc = transport_generic_allocate_tasks(se_cmd, cdb);
1698 if (rc != 0) 1704 if (rc != 0) {
1699 goto out_check_cond; 1705 transport_generic_request_failure(se_cmd);
1706 return;
1707 }
1700 /* 1708 /*
1701 * Dispatch se_cmd descriptor to se_lun->lun_se_dev backend 1709 * Dispatch se_cmd descriptor to se_lun->lun_se_dev backend
1702 * for immediate execution of READs, otherwise wait for 1710 * for immediate execution of READs, otherwise wait for
@@ -1704,12 +1712,7 @@ int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
1704 * when fabric has filled the incoming buffer. 1712 * when fabric has filled the incoming buffer.
1705 */ 1713 */
1706 transport_handle_cdb_direct(se_cmd); 1714 transport_handle_cdb_direct(se_cmd);
1707 return 0; 1715 return;
1708
1709out_check_cond:
1710 transport_send_check_condition_and_sense(se_cmd,
1711 se_cmd->scsi_sense_reason, 0);
1712 return 0;
1713} 1716}
1714EXPORT_SYMBOL(target_submit_cmd); 1717EXPORT_SYMBOL(target_submit_cmd);
1715 1718
@@ -2694,7 +2697,7 @@ static int transport_generic_cmd_sequencer(
2694 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; 2697 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
2695 2698
2696 if (target_check_write_same_discard(&cdb[10], dev) < 0) 2699 if (target_check_write_same_discard(&cdb[10], dev) < 0)
2697 goto out_invalid_cdb_field; 2700 goto out_unsupported_cdb;
2698 if (!passthrough) 2701 if (!passthrough)
2699 cmd->execute_task = target_emulate_write_same; 2702 cmd->execute_task = target_emulate_write_same;
2700 break; 2703 break;
@@ -2977,7 +2980,7 @@ static int transport_generic_cmd_sequencer(
2977 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; 2980 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
2978 2981
2979 if (target_check_write_same_discard(&cdb[1], dev) < 0) 2982 if (target_check_write_same_discard(&cdb[1], dev) < 0)
2980 goto out_invalid_cdb_field; 2983 goto out_unsupported_cdb;
2981 if (!passthrough) 2984 if (!passthrough)
2982 cmd->execute_task = target_emulate_write_same; 2985 cmd->execute_task = target_emulate_write_same;
2983 break; 2986 break;
@@ -3000,7 +3003,7 @@ static int transport_generic_cmd_sequencer(
3000 * of byte 1 bit 3 UNMAP instead of original reserved field 3003 * of byte 1 bit 3 UNMAP instead of original reserved field
3001 */ 3004 */
3002 if (target_check_write_same_discard(&cdb[1], dev) < 0) 3005 if (target_check_write_same_discard(&cdb[1], dev) < 0)
3003 goto out_invalid_cdb_field; 3006 goto out_unsupported_cdb;
3004 if (!passthrough) 3007 if (!passthrough)
3005 cmd->execute_task = target_emulate_write_same; 3008 cmd->execute_task = target_emulate_write_same;
3006 break; 3009 break;
@@ -3082,11 +3085,6 @@ static int transport_generic_cmd_sequencer(
3082 (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB))) 3085 (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)))
3083 goto out_unsupported_cdb; 3086 goto out_unsupported_cdb;
3084 3087
3085 /* Let's limit control cdbs to a page, for simplicity's sake. */
3086 if ((cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) &&
3087 size > PAGE_SIZE)
3088 goto out_invalid_cdb_field;
3089
3090 transport_set_supported_SAM_opcode(cmd); 3088 transport_set_supported_SAM_opcode(cmd);
3091 return ret; 3089 return ret;
3092 3090
@@ -3490,9 +3488,11 @@ int transport_generic_map_mem_to_cmd(
3490} 3488}
3491EXPORT_SYMBOL(transport_generic_map_mem_to_cmd); 3489EXPORT_SYMBOL(transport_generic_map_mem_to_cmd);
3492 3490
3493void *transport_kmap_first_data_page(struct se_cmd *cmd) 3491void *transport_kmap_data_sg(struct se_cmd *cmd)
3494{ 3492{
3495 struct scatterlist *sg = cmd->t_data_sg; 3493 struct scatterlist *sg = cmd->t_data_sg;
3494 struct page **pages;
3495 int i;
3496 3496
3497 BUG_ON(!sg); 3497 BUG_ON(!sg);
3498 /* 3498 /*
@@ -3500,15 +3500,41 @@ void *transport_kmap_first_data_page(struct se_cmd *cmd)
3500 * tcm_loop who may be using a contig buffer from the SCSI midlayer for 3500 * tcm_loop who may be using a contig buffer from the SCSI midlayer for
3501 * control CDBs passed as SGLs via transport_generic_map_mem_to_cmd() 3501 * control CDBs passed as SGLs via transport_generic_map_mem_to_cmd()
3502 */ 3502 */
3503 return kmap(sg_page(sg)) + sg->offset; 3503 if (!cmd->t_data_nents)
3504 return NULL;
3505 else if (cmd->t_data_nents == 1)
3506 return kmap(sg_page(sg)) + sg->offset;
3507
3508 /* >1 page. use vmap */
3509 pages = kmalloc(sizeof(*pages) * cmd->t_data_nents, GFP_KERNEL);
3510 if (!pages)
3511 return NULL;
3512
3513 /* convert sg[] to pages[] */
3514 for_each_sg(cmd->t_data_sg, sg, cmd->t_data_nents, i) {
3515 pages[i] = sg_page(sg);
3516 }
3517
3518 cmd->t_data_vmap = vmap(pages, cmd->t_data_nents, VM_MAP, PAGE_KERNEL);
3519 kfree(pages);
3520 if (!cmd->t_data_vmap)
3521 return NULL;
3522
3523 return cmd->t_data_vmap + cmd->t_data_sg[0].offset;
3504} 3524}
3505EXPORT_SYMBOL(transport_kmap_first_data_page); 3525EXPORT_SYMBOL(transport_kmap_data_sg);
3506 3526
3507void transport_kunmap_first_data_page(struct se_cmd *cmd) 3527void transport_kunmap_data_sg(struct se_cmd *cmd)
3508{ 3528{
3509 kunmap(sg_page(cmd->t_data_sg)); 3529 if (!cmd->t_data_nents)
3530 return;
3531 else if (cmd->t_data_nents == 1)
3532 kunmap(sg_page(cmd->t_data_sg));
3533
3534 vunmap(cmd->t_data_vmap);
3535 cmd->t_data_vmap = NULL;
3510} 3536}
3511EXPORT_SYMBOL(transport_kunmap_first_data_page); 3537EXPORT_SYMBOL(transport_kunmap_data_sg);
3512 3538
3513static int 3539static int
3514transport_generic_get_mem(struct se_cmd *cmd) 3540transport_generic_get_mem(struct se_cmd *cmd)
@@ -3516,6 +3542,7 @@ transport_generic_get_mem(struct se_cmd *cmd)
3516 u32 length = cmd->data_length; 3542 u32 length = cmd->data_length;
3517 unsigned int nents; 3543 unsigned int nents;
3518 struct page *page; 3544 struct page *page;
3545 gfp_t zero_flag;
3519 int i = 0; 3546 int i = 0;
3520 3547
3521 nents = DIV_ROUND_UP(length, PAGE_SIZE); 3548 nents = DIV_ROUND_UP(length, PAGE_SIZE);
@@ -3526,9 +3553,11 @@ transport_generic_get_mem(struct se_cmd *cmd)
3526 cmd->t_data_nents = nents; 3553 cmd->t_data_nents = nents;
3527 sg_init_table(cmd->t_data_sg, nents); 3554 sg_init_table(cmd->t_data_sg, nents);
3528 3555
3556 zero_flag = cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB ? 0 : __GFP_ZERO;
3557
3529 while (length) { 3558 while (length) {
3530 u32 page_len = min_t(u32, length, PAGE_SIZE); 3559 u32 page_len = min_t(u32, length, PAGE_SIZE);
3531 page = alloc_page(GFP_KERNEL | __GFP_ZERO); 3560 page = alloc_page(GFP_KERNEL | zero_flag);
3532 if (!page) 3561 if (!page)
3533 goto out; 3562 goto out;
3534 3563
@@ -3756,6 +3785,11 @@ transport_allocate_control_task(struct se_cmd *cmd)
3756 struct se_task *task; 3785 struct se_task *task;
3757 unsigned long flags; 3786 unsigned long flags;
3758 3787
3788 /* Workaround for handling zero-length control CDBs */
3789 if ((cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) &&
3790 !cmd->data_length)
3791 return 0;
3792
3759 task = transport_generic_get_task(cmd, cmd->data_direction); 3793 task = transport_generic_get_task(cmd, cmd->data_direction);
3760 if (!task) 3794 if (!task)
3761 return -ENOMEM; 3795 return -ENOMEM;
@@ -3827,6 +3861,14 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
3827 else if (!task_cdbs && (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)) { 3861 else if (!task_cdbs && (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)) {
3828 cmd->t_state = TRANSPORT_COMPLETE; 3862 cmd->t_state = TRANSPORT_COMPLETE;
3829 atomic_set(&cmd->t_transport_active, 1); 3863 atomic_set(&cmd->t_transport_active, 1);
3864
3865 if (cmd->t_task_cdb[0] == REQUEST_SENSE) {
3866 u8 ua_asc = 0, ua_ascq = 0;
3867
3868 core_scsi3_ua_clear_for_request_sense(cmd,
3869 &ua_asc, &ua_ascq);
3870 }
3871
3830 INIT_WORK(&cmd->work, target_complete_ok_work); 3872 INIT_WORK(&cmd->work, target_complete_ok_work);
3831 queue_work(target_completion_wq, &cmd->work); 3873 queue_work(target_completion_wq, &cmd->work);
3832 return 0; 3874 return 0;
@@ -4448,8 +4490,8 @@ int transport_send_check_condition_and_sense(
4448 /* CURRENT ERROR */ 4490 /* CURRENT ERROR */
4449 buffer[offset] = 0x70; 4491 buffer[offset] = 0x70;
4450 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; 4492 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4451 /* ABORTED COMMAND */ 4493 /* ILLEGAL REQUEST */
4452 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4494 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
4453 /* INVALID FIELD IN CDB */ 4495 /* INVALID FIELD IN CDB */
4454 buffer[offset+SPC_ASC_KEY_OFFSET] = 0x24; 4496 buffer[offset+SPC_ASC_KEY_OFFSET] = 0x24;
4455 break; 4497 break;
@@ -4457,8 +4499,8 @@ int transport_send_check_condition_and_sense(
4457 /* CURRENT ERROR */ 4499 /* CURRENT ERROR */
4458 buffer[offset] = 0x70; 4500 buffer[offset] = 0x70;
4459 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; 4501 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4460 /* ABORTED COMMAND */ 4502 /* ILLEGAL REQUEST */
4461 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4503 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
4462 /* INVALID FIELD IN PARAMETER LIST */ 4504 /* INVALID FIELD IN PARAMETER LIST */
4463 buffer[offset+SPC_ASC_KEY_OFFSET] = 0x26; 4505 buffer[offset+SPC_ASC_KEY_OFFSET] = 0x26;
4464 break; 4506 break;
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index addc18f727ea..9e7e26c74c79 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -540,7 +540,6 @@ static void ft_send_work(struct work_struct *work)
540 int data_dir = 0; 540 int data_dir = 0;
541 u32 data_len; 541 u32 data_len;
542 int task_attr; 542 int task_attr;
543 int ret;
544 543
545 fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); 544 fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp));
546 if (!fcp) 545 if (!fcp)
@@ -603,14 +602,10 @@ static void ft_send_work(struct work_struct *work)
603 * Use a single se_cmd->cmd_kref as we expect to release se_cmd 602 * Use a single se_cmd->cmd_kref as we expect to release se_cmd
604 * directly from ft_check_stop_free callback in response path. 603 * directly from ft_check_stop_free callback in response path.
605 */ 604 */
606 ret = target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, cmd->cdb, 605 target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, cmd->cdb,
607 &cmd->ft_sense_buffer[0], cmd->lun, data_len, 606 &cmd->ft_sense_buffer[0], cmd->lun, data_len,
608 task_attr, data_dir, 0); 607 task_attr, data_dir, 0);
609 pr_debug("r_ctl %x alloc target_submit_cmd %d\n", fh->fh_r_ctl, ret); 608 pr_debug("r_ctl %x alloc target_submit_cmd\n", fh->fh_r_ctl);
610 if (ret < 0) {
611 ft_dump_cmd(cmd, __func__);
612 return;
613 }
614 return; 609 return;
615 610
616err: 611err:
diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250/8250.c
index 9f50c4e3c2be..9f50c4e3c2be 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250/8250.c
diff --git a/drivers/tty/serial/8250.h b/drivers/tty/serial/8250/8250.h
index ae027be57e25..ae027be57e25 100644
--- a/drivers/tty/serial/8250.h
+++ b/drivers/tty/serial/8250/8250.h
diff --git a/drivers/tty/serial/8250_accent.c b/drivers/tty/serial/8250/8250_accent.c
index 34b51c651192..34b51c651192 100644
--- a/drivers/tty/serial/8250_accent.c
+++ b/drivers/tty/serial/8250/8250_accent.c
diff --git a/drivers/tty/serial/8250_acorn.c b/drivers/tty/serial/8250/8250_acorn.c
index b0ce8c56f1a4..b0ce8c56f1a4 100644
--- a/drivers/tty/serial/8250_acorn.c
+++ b/drivers/tty/serial/8250/8250_acorn.c
diff --git a/drivers/tty/serial/8250_boca.c b/drivers/tty/serial/8250/8250_boca.c
index d125dc107985..d125dc107985 100644
--- a/drivers/tty/serial/8250_boca.c
+++ b/drivers/tty/serial/8250/8250_boca.c
diff --git a/drivers/tty/serial/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index f574eef3075f..f574eef3075f 100644
--- a/drivers/tty/serial/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
diff --git a/drivers/tty/serial/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index eaafb98debed..eaafb98debed 100644
--- a/drivers/tty/serial/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
diff --git a/drivers/tty/serial/8250_exar_st16c554.c b/drivers/tty/serial/8250/8250_exar_st16c554.c
index bf53aabf9b5e..bf53aabf9b5e 100644
--- a/drivers/tty/serial/8250_exar_st16c554.c
+++ b/drivers/tty/serial/8250/8250_exar_st16c554.c
diff --git a/drivers/tty/serial/8250_fourport.c b/drivers/tty/serial/8250/8250_fourport.c
index be1582609626..be1582609626 100644
--- a/drivers/tty/serial/8250_fourport.c
+++ b/drivers/tty/serial/8250/8250_fourport.c
diff --git a/drivers/tty/serial/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c
index f4d3c47b88e8..f4d3c47b88e8 100644
--- a/drivers/tty/serial/8250_fsl.c
+++ b/drivers/tty/serial/8250/8250_fsl.c
diff --git a/drivers/tty/serial/8250_gsc.c b/drivers/tty/serial/8250/8250_gsc.c
index d8c0ffbfa6e3..d8c0ffbfa6e3 100644
--- a/drivers/tty/serial/8250_gsc.c
+++ b/drivers/tty/serial/8250/8250_gsc.c
diff --git a/drivers/tty/serial/8250_hp300.c b/drivers/tty/serial/8250/8250_hp300.c
index c13438c93012..c13438c93012 100644
--- a/drivers/tty/serial/8250_hp300.c
+++ b/drivers/tty/serial/8250/8250_hp300.c
diff --git a/drivers/tty/serial/8250_hub6.c b/drivers/tty/serial/8250/8250_hub6.c
index a5c778e83de0..a5c778e83de0 100644
--- a/drivers/tty/serial/8250_hub6.c
+++ b/drivers/tty/serial/8250/8250_hub6.c
diff --git a/drivers/tty/serial/8250_mca.c b/drivers/tty/serial/8250/8250_mca.c
index d20abf04541e..d20abf04541e 100644
--- a/drivers/tty/serial/8250_mca.c
+++ b/drivers/tty/serial/8250/8250_mca.c
diff --git a/drivers/tty/serial/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index da2b0b0a183f..da2b0b0a183f 100644
--- a/drivers/tty/serial/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
diff --git a/drivers/tty/serial/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c
index a2f236510ff1..a2f236510ff1 100644
--- a/drivers/tty/serial/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
new file mode 100644
index 000000000000..591f8018e7dd
--- /dev/null
+++ b/drivers/tty/serial/8250/Kconfig
@@ -0,0 +1,280 @@
1#
2# The 8250/16550 serial drivers. You shouldn't be in this list unless
3# you somehow have an implicit or explicit dependency on SERIAL_8250.
4#
5
6config SERIAL_8250
7 tristate "8250/16550 and compatible serial support"
8 select SERIAL_CORE
9 ---help---
10 This selects whether you want to include the driver for the standard
11 serial ports. The standard answer is Y. People who might say N
12 here are those that are setting up dedicated Ethernet WWW/FTP
13 servers, or users that have one of the various bus mice instead of a
14 serial mouse and don't intend to use their machine's standard serial
15 port for anything. (Note that the Cyclades and Stallion multi
16 serial port drivers do not need this driver built in for them to
17 work.)
18
19 To compile this driver as a module, choose M here: the
20 module will be called 8250.
21 [WARNING: Do not compile this driver as a module if you are using
22 non-standard serial ports, since the configuration information will
23 be lost when the driver is unloaded. This limitation may be lifted
24 in the future.]
25
26 BTW1: If you have a mouseman serial mouse which is not recognized by
27 the X window system, try running gpm first.
28
29 BTW2: If you intend to use a software modem (also called Winmodem)
30 under Linux, forget it. These modems are crippled and require
31 proprietary drivers which are only available under Windows.
32
33 Most people will say Y or M here, so that they can use serial mice,
34 modems and similar devices connecting to the standard serial ports.
35
36config SERIAL_8250_CONSOLE
37 bool "Console on 8250/16550 and compatible serial port"
38 depends on SERIAL_8250=y
39 select SERIAL_CORE_CONSOLE
40 ---help---
41 If you say Y here, it will be possible to use a serial port as the
42 system console (the system console is the device which receives all
43 kernel messages and warnings and which allows logins in single user
44 mode). This could be useful if some terminal or printer is connected
45 to that serial port.
46
47 Even if you say Y here, the currently visible virtual console
48 (/dev/tty0) will still be used as the system console by default, but
49 you can alter that using a kernel command line option such as
50 "console=ttyS1". (Try "man bootparam" or see the documentation of
51 your boot loader (grub or lilo or loadlin) about how to pass options
52 to the kernel at boot time.)
53
54 If you don't have a VGA card installed and you say Y here, the
55 kernel will automatically use the first serial line, /dev/ttyS0, as
56 system console.
57
58 You can set that using a kernel command line option such as
59 "console=uart8250,io,0x3f8,9600n8"
60 "console=uart8250,mmio,0xff5e0000,115200n8".
61 and it will switch to normal serial console when the corresponding
62 port is ready.
63 "earlycon=uart8250,io,0x3f8,9600n8"
64 "earlycon=uart8250,mmio,0xff5e0000,115200n8".
65 it will not only setup early console.
66
67 If unsure, say N.
68
69config FIX_EARLYCON_MEM
70 bool
71 depends on X86
72 default y
73
74config SERIAL_8250_GSC
75 tristate
76 depends on SERIAL_8250 && GSC
77 default SERIAL_8250
78
79config SERIAL_8250_PCI
80 tristate "8250/16550 PCI device support" if EXPERT
81 depends on SERIAL_8250 && PCI
82 default SERIAL_8250
83 help
84 This builds standard PCI serial support. You may be able to
85 disable this feature if you only need legacy serial support.
86 Saves about 9K.
87
88config SERIAL_8250_PNP
89 tristate "8250/16550 PNP device support" if EXPERT
90 depends on SERIAL_8250 && PNP
91 default SERIAL_8250
92 help
93 This builds standard PNP serial support. You may be able to
94 disable this feature if you only need legacy serial support.
95
96config SERIAL_8250_HP300
97 tristate
98 depends on SERIAL_8250 && HP300
99 default SERIAL_8250
100
101config SERIAL_8250_CS
102 tristate "8250/16550 PCMCIA device support"
103 depends on PCMCIA && SERIAL_8250
104 ---help---
105 Say Y here to enable support for 16-bit PCMCIA serial devices,
106 including serial port cards, modems, and the modem functions of
107 multi-function Ethernet/modem cards. (PCMCIA- or PC-cards are
108 credit-card size devices often used with laptops.)
109
110 To compile this driver as a module, choose M here: the
111 module will be called serial_cs.
112
113 If unsure, say N.
114
115config SERIAL_8250_NR_UARTS
116 int "Maximum number of 8250/16550 serial ports"
117 depends on SERIAL_8250
118 default "4"
119 help
120 Set this to the number of serial ports you want the driver
121 to support. This includes any ports discovered via ACPI or
122 PCI enumeration and any ports that may be added at run-time
123 via hot-plug, or any ISA multi-port serial cards.
124
125config SERIAL_8250_RUNTIME_UARTS
126 int "Number of 8250/16550 serial ports to register at runtime"
127 depends on SERIAL_8250
128 range 0 SERIAL_8250_NR_UARTS
129 default "4"
130 help
131 Set this to the maximum number of serial ports you want
132 the kernel to register at boot time. This can be overridden
133 with the module parameter "nr_uarts", or boot-time parameter
134 8250.nr_uarts
135
136config SERIAL_8250_EXTENDED
137 bool "Extended 8250/16550 serial driver options"
138 depends on SERIAL_8250
139 help
140 If you wish to use any non-standard features of the standard "dumb"
141 driver, say Y here. This includes HUB6 support, shared serial
142 interrupts, special multiport support, support for more than the
143 four COM 1/2/3/4 boards, etc.
144
145 Note that the answer to this question won't directly affect the
146 kernel: saying N will just cause the configurator to skip all
147 the questions about serial driver options. If unsure, say N.
148
149config SERIAL_8250_MANY_PORTS
150 bool "Support more than 4 legacy serial ports"
151 depends on SERIAL_8250_EXTENDED && !IA64
152 help
153 Say Y here if you have dumb serial boards other than the four
154 standard COM 1/2/3/4 ports. This may happen if you have an AST
155 FourPort, Accent Async, Boca (read the Boca mini-HOWTO, available
156 from <http://www.tldp.org/docs.html#howto>), or other custom
157 serial port hardware which acts similar to standard serial port
158 hardware. If you only use the standard COM 1/2/3/4 ports, you can
159 say N here to save some memory. You can also say Y if you have an
160 "intelligent" multiport card such as Cyclades, Digiboards, etc.
161
162#
163# Multi-port serial cards
164#
165
166config SERIAL_8250_FOURPORT
167 tristate "Support Fourport cards"
168 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
169 help
170 Say Y here if you have an AST FourPort serial board.
171
172 To compile this driver as a module, choose M here: the module
173 will be called 8250_fourport.
174
175config SERIAL_8250_ACCENT
176 tristate "Support Accent cards"
177 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
178 help
179 Say Y here if you have an Accent Async serial board.
180
181 To compile this driver as a module, choose M here: the module
182 will be called 8250_accent.
183
184config SERIAL_8250_BOCA
185 tristate "Support Boca cards"
186 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
187 help
188 Say Y here if you have a Boca serial board. Please read the Boca
189 mini-HOWTO, available from <http://www.tldp.org/docs.html#howto>
190
191 To compile this driver as a module, choose M here: the module
192 will be called 8250_boca.
193
194config SERIAL_8250_EXAR_ST16C554
195 tristate "Support Exar ST16C554/554D Quad UART"
196 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
197 help
198 The Uplogix Envoy TU301 uses this Exar Quad UART. If you are
199 tinkering with your Envoy TU301, or have a machine with this UART,
200 say Y here.
201
202 To compile this driver as a module, choose M here: the module
203 will be called 8250_exar_st16c554.
204
205config SERIAL_8250_HUB6
206 tristate "Support Hub6 cards"
207 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
208 help
209 Say Y here if you have a HUB6 serial board.
210
211 To compile this driver as a module, choose M here: the module
212 will be called 8250_hub6.
213
214#
215# Misc. options/drivers.
216#
217
218config SERIAL_8250_SHARE_IRQ
219 bool "Support for sharing serial interrupts"
220 depends on SERIAL_8250_EXTENDED
221 help
222 Some serial boards have hardware support which allows multiple dumb
223 serial ports on the same board to share a single IRQ. To enable
224 support for this in the serial driver, say Y here.
225
226config SERIAL_8250_DETECT_IRQ
227 bool "Autodetect IRQ on standard ports (unsafe)"
228 depends on SERIAL_8250_EXTENDED
229 help
230 Say Y here if you want the kernel to try to guess which IRQ
231 to use for your serial port.
232
233 This is considered unsafe; it is far better to configure the IRQ in
234 a boot script using the setserial command.
235
236 If unsure, say N.
237
238config SERIAL_8250_RSA
239 bool "Support RSA serial ports"
240 depends on SERIAL_8250_EXTENDED
241 help
242 ::: To be written :::
243
244config SERIAL_8250_MCA
245 tristate "Support 8250-type ports on MCA buses"
246 depends on SERIAL_8250 != n && MCA
247 help
248 Say Y here if you have a MCA serial ports.
249
250 To compile this driver as a module, choose M here: the module
251 will be called 8250_mca.
252
253config SERIAL_8250_ACORN
254 tristate "Acorn expansion card serial port support"
255 depends on ARCH_ACORN && SERIAL_8250
256 help
257 If you have an Atomwide Serial card or Serial Port card for an Acorn
258 system, say Y to this option. The driver can handle 1, 2, or 3 port
259 cards. If unsure, say N.
260
261config SERIAL_8250_RM9K
262 bool "Support for MIPS RM9xxx integrated serial port"
263 depends on SERIAL_8250 != n && SERIAL_RM9000
264 select SERIAL_8250_SHARE_IRQ
265 help
266 Selecting this option will add support for the integrated serial
267 port hardware found on MIPS RM9122 and similar processors.
268 If unsure, say N.
269
270config SERIAL_8250_FSL
271 bool
272 depends on SERIAL_8250_CONSOLE && PPC_UDBG_16550
273 default PPC
274
275config SERIAL_8250_DW
276 tristate "Support for Synopsys DesignWare 8250 quirks"
277 depends on SERIAL_8250 && OF
278 help
279 Selecting this option will enable handling of the extra features
280 present in the Synopsys DesignWare APB UART.
diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile
new file mode 100644
index 000000000000..867bba738908
--- /dev/null
+++ b/drivers/tty/serial/8250/Makefile
@@ -0,0 +1,20 @@
1#
2# Makefile for the 8250 serial device drivers.
3#
4
5obj-$(CONFIG_SERIAL_8250) += 8250.o
6obj-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o
7obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o
8obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o
9obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o
10obj-$(CONFIG_SERIAL_8250_CS) += serial_cs.o
11obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o
12obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
13obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
14obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
15obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
16obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
17obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
18obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
19obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o
20obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/8250/m32r_sio.c
index 94a6792bf97b..94a6792bf97b 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/8250/m32r_sio.c
diff --git a/drivers/tty/serial/m32r_sio.h b/drivers/tty/serial/8250/m32r_sio.h
index e9b7e11793b1..e9b7e11793b1 100644
--- a/drivers/tty/serial/m32r_sio.h
+++ b/drivers/tty/serial/8250/m32r_sio.h
diff --git a/drivers/tty/serial/m32r_sio_reg.h b/drivers/tty/serial/8250/m32r_sio_reg.h
index 4671473793e3..4671473793e3 100644
--- a/drivers/tty/serial/m32r_sio_reg.h
+++ b/drivers/tty/serial/8250/m32r_sio_reg.h
diff --git a/drivers/tty/serial/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
index 86090605a84e..86090605a84e 100644
--- a/drivers/tty/serial/serial_cs.c
+++ b/drivers/tty/serial/8250/serial_cs.c
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index aca2386c5ef1..2de99248dfae 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -5,279 +5,7 @@
5menu "Serial drivers" 5menu "Serial drivers"
6 depends on HAS_IOMEM 6 depends on HAS_IOMEM
7 7
8# 8source "drivers/tty/serial/8250/Kconfig"
9# The new 8250/16550 serial drivers
10config SERIAL_8250
11 tristate "8250/16550 and compatible serial support"
12 select SERIAL_CORE
13 ---help---
14 This selects whether you want to include the driver for the standard
15 serial ports. The standard answer is Y. People who might say N
16 here are those that are setting up dedicated Ethernet WWW/FTP
17 servers, or users that have one of the various bus mice instead of a
18 serial mouse and don't intend to use their machine's standard serial
19 port for anything. (Note that the Cyclades and Stallion multi
20 serial port drivers do not need this driver built in for them to
21 work.)
22
23 To compile this driver as a module, choose M here: the
24 module will be called 8250.
25 [WARNING: Do not compile this driver as a module if you are using
26 non-standard serial ports, since the configuration information will
27 be lost when the driver is unloaded. This limitation may be lifted
28 in the future.]
29
30 BTW1: If you have a mouseman serial mouse which is not recognized by
31 the X window system, try running gpm first.
32
33 BTW2: If you intend to use a software modem (also called Winmodem)
34 under Linux, forget it. These modems are crippled and require
35 proprietary drivers which are only available under Windows.
36
37 Most people will say Y or M here, so that they can use serial mice,
38 modems and similar devices connecting to the standard serial ports.
39
40config SERIAL_8250_CONSOLE
41 bool "Console on 8250/16550 and compatible serial port"
42 depends on SERIAL_8250=y
43 select SERIAL_CORE_CONSOLE
44 ---help---
45 If you say Y here, it will be possible to use a serial port as the
46 system console (the system console is the device which receives all
47 kernel messages and warnings and which allows logins in single user
48 mode). This could be useful if some terminal or printer is connected
49 to that serial port.
50
51 Even if you say Y here, the currently visible virtual console
52 (/dev/tty0) will still be used as the system console by default, but
53 you can alter that using a kernel command line option such as
54 "console=ttyS1". (Try "man bootparam" or see the documentation of
55 your boot loader (grub or lilo or loadlin) about how to pass options
56 to the kernel at boot time.)
57
58 If you don't have a VGA card installed and you say Y here, the
59 kernel will automatically use the first serial line, /dev/ttyS0, as
60 system console.
61
62 You can set that using a kernel command line option such as
63 "console=uart8250,io,0x3f8,9600n8"
64 "console=uart8250,mmio,0xff5e0000,115200n8".
65 and it will switch to normal serial console when the corresponding
66 port is ready.
67 "earlycon=uart8250,io,0x3f8,9600n8"
68 "earlycon=uart8250,mmio,0xff5e0000,115200n8".
69 it will not only setup early console.
70
71 If unsure, say N.
72
73config FIX_EARLYCON_MEM
74 bool
75 depends on X86
76 default y
77
78config SERIAL_8250_GSC
79 tristate
80 depends on SERIAL_8250 && GSC
81 default SERIAL_8250
82
83config SERIAL_8250_PCI
84 tristate "8250/16550 PCI device support" if EXPERT
85 depends on SERIAL_8250 && PCI
86 default SERIAL_8250
87 help
88 This builds standard PCI serial support. You may be able to
89 disable this feature if you only need legacy serial support.
90 Saves about 9K.
91
92config SERIAL_8250_PNP
93 tristate "8250/16550 PNP device support" if EXPERT
94 depends on SERIAL_8250 && PNP
95 default SERIAL_8250
96 help
97 This builds standard PNP serial support. You may be able to
98 disable this feature if you only need legacy serial support.
99
100config SERIAL_8250_FSL
101 bool
102 depends on SERIAL_8250_CONSOLE && PPC_UDBG_16550
103 default PPC
104
105config SERIAL_8250_HP300
106 tristate
107 depends on SERIAL_8250 && HP300
108 default SERIAL_8250
109
110config SERIAL_8250_CS
111 tristate "8250/16550 PCMCIA device support"
112 depends on PCMCIA && SERIAL_8250
113 ---help---
114 Say Y here to enable support for 16-bit PCMCIA serial devices,
115 including serial port cards, modems, and the modem functions of
116 multi-function Ethernet/modem cards. (PCMCIA- or PC-cards are
117 credit-card size devices often used with laptops.)
118
119 To compile this driver as a module, choose M here: the
120 module will be called serial_cs.
121
122 If unsure, say N.
123
124config SERIAL_8250_NR_UARTS
125 int "Maximum number of 8250/16550 serial ports"
126 depends on SERIAL_8250
127 default "4"
128 help
129 Set this to the number of serial ports you want the driver
130 to support. This includes any ports discovered via ACPI or
131 PCI enumeration and any ports that may be added at run-time
132 via hot-plug, or any ISA multi-port serial cards.
133
134config SERIAL_8250_RUNTIME_UARTS
135 int "Number of 8250/16550 serial ports to register at runtime"
136 depends on SERIAL_8250
137 range 0 SERIAL_8250_NR_UARTS
138 default "4"
139 help
140 Set this to the maximum number of serial ports you want
141 the kernel to register at boot time. This can be overridden
142 with the module parameter "nr_uarts", or boot-time parameter
143 8250.nr_uarts
144
145config SERIAL_8250_EXTENDED
146 bool "Extended 8250/16550 serial driver options"
147 depends on SERIAL_8250
148 help
149 If you wish to use any non-standard features of the standard "dumb"
150 driver, say Y here. This includes HUB6 support, shared serial
151 interrupts, special multiport support, support for more than the
152 four COM 1/2/3/4 boards, etc.
153
154 Note that the answer to this question won't directly affect the
155 kernel: saying N will just cause the configurator to skip all
156 the questions about serial driver options. If unsure, say N.
157
158config SERIAL_8250_MANY_PORTS
159 bool "Support more than 4 legacy serial ports"
160 depends on SERIAL_8250_EXTENDED && !IA64
161 help
162 Say Y here if you have dumb serial boards other than the four
163 standard COM 1/2/3/4 ports. This may happen if you have an AST
164 FourPort, Accent Async, Boca (read the Boca mini-HOWTO, available
165 from <http://www.tldp.org/docs.html#howto>), or other custom
166 serial port hardware which acts similar to standard serial port
167 hardware. If you only use the standard COM 1/2/3/4 ports, you can
168 say N here to save some memory. You can also say Y if you have an
169 "intelligent" multiport card such as Cyclades, Digiboards, etc.
170
171#
172# Multi-port serial cards
173#
174
175config SERIAL_8250_FOURPORT
176 tristate "Support Fourport cards"
177 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
178 help
179 Say Y here if you have an AST FourPort serial board.
180
181 To compile this driver as a module, choose M here: the module
182 will be called 8250_fourport.
183
184config SERIAL_8250_ACCENT
185 tristate "Support Accent cards"
186 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
187 help
188 Say Y here if you have an Accent Async serial board.
189
190 To compile this driver as a module, choose M here: the module
191 will be called 8250_accent.
192
193config SERIAL_8250_BOCA
194 tristate "Support Boca cards"
195 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
196 help
197 Say Y here if you have a Boca serial board. Please read the Boca
198 mini-HOWTO, available from <http://www.tldp.org/docs.html#howto>
199
200 To compile this driver as a module, choose M here: the module
201 will be called 8250_boca.
202
203config SERIAL_8250_EXAR_ST16C554
204 tristate "Support Exar ST16C554/554D Quad UART"
205 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
206 help
207 The Uplogix Envoy TU301 uses this Exar Quad UART. If you are
208 tinkering with your Envoy TU301, or have a machine with this UART,
209 say Y here.
210
211 To compile this driver as a module, choose M here: the module
212 will be called 8250_exar_st16c554.
213
214config SERIAL_8250_HUB6
215 tristate "Support Hub6 cards"
216 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
217 help
218 Say Y here if you have a HUB6 serial board.
219
220 To compile this driver as a module, choose M here: the module
221 will be called 8250_hub6.
222
223config SERIAL_8250_SHARE_IRQ
224 bool "Support for sharing serial interrupts"
225 depends on SERIAL_8250_EXTENDED
226 help
227 Some serial boards have hardware support which allows multiple dumb
228 serial ports on the same board to share a single IRQ. To enable
229 support for this in the serial driver, say Y here.
230
231config SERIAL_8250_DETECT_IRQ
232 bool "Autodetect IRQ on standard ports (unsafe)"
233 depends on SERIAL_8250_EXTENDED
234 help
235 Say Y here if you want the kernel to try to guess which IRQ
236 to use for your serial port.
237
238 This is considered unsafe; it is far better to configure the IRQ in
239 a boot script using the setserial command.
240
241 If unsure, say N.
242
243config SERIAL_8250_RSA
244 bool "Support RSA serial ports"
245 depends on SERIAL_8250_EXTENDED
246 help
247 ::: To be written :::
248
249config SERIAL_8250_MCA
250 tristate "Support 8250-type ports on MCA buses"
251 depends on SERIAL_8250 != n && MCA
252 help
253 Say Y here if you have a MCA serial ports.
254
255 To compile this driver as a module, choose M here: the module
256 will be called 8250_mca.
257
258config SERIAL_8250_ACORN
259 tristate "Acorn expansion card serial port support"
260 depends on ARCH_ACORN && SERIAL_8250
261 help
262 If you have an Atomwide Serial card or Serial Port card for an Acorn
263 system, say Y to this option. The driver can handle 1, 2, or 3 port
264 cards. If unsure, say N.
265
266config SERIAL_8250_RM9K
267 bool "Support for MIPS RM9xxx integrated serial port"
268 depends on SERIAL_8250 != n && SERIAL_RM9000
269 select SERIAL_8250_SHARE_IRQ
270 help
271 Selecting this option will add support for the integrated serial
272 port hardware found on MIPS RM9122 and similar processors.
273 If unsure, say N.
274
275config SERIAL_8250_DW
276 tristate "Support for Synopsys DesignWare 8250 quirks"
277 depends on SERIAL_8250 && OF
278 help
279 Selecting this option will enable handling of the extra features
280 present in the Synopsys DesignWare APB UART.
281 9
282comment "Non-8250 serial port support" 10comment "Non-8250 serial port support"
283 11
@@ -536,15 +264,6 @@ config SERIAL_MAX3107
536 help 264 help
537 MAX3107 chip support 265 MAX3107 chip support
538 266
539config SERIAL_MAX3107_AAVA
540 tristate "MAX3107 AAVA platform support"
541 depends on X86_MRST && SERIAL_MAX3107 && GPIOLIB
542 select SERIAL_CORE
543 help
544 Support for the MAX3107 chip configuration found on the AAVA
545 platform. Includes the extra initialisation and GPIO support
546 neded for this device.
547
548config SERIAL_DZ 267config SERIAL_DZ
549 bool "DECstation DZ serial driver" 268 bool "DECstation DZ serial driver"
550 depends on MACH_DECSTATION && 32BIT 269 depends on MACH_DECSTATION && 32BIT
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index f5b01f2ce525..fef32e10c851 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -14,22 +14,9 @@ obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o
14obj-$(CONFIG_SERIAL_SUNSU) += sunsu.o 14obj-$(CONFIG_SERIAL_SUNSU) += sunsu.o
15obj-$(CONFIG_SERIAL_SUNSAB) += sunsab.o 15obj-$(CONFIG_SERIAL_SUNSAB) += sunsab.o
16 16
17obj-$(CONFIG_SERIAL_8250) += 8250.o 17# Now bring in any enabled 8250/16450/16550 type drivers.
18obj-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o 18obj-$(CONFIG_SERIAL_8250) += 8250/
19obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o 19
20obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o
21obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o
22obj-$(CONFIG_SERIAL_8250_CS) += serial_cs.o
23obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o
24obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
25obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
26obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
27obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
28obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
29obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
30obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
31obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o
32obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o
33obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o 20obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
34obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o 21obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
35obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o 22obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
@@ -42,7 +29,6 @@ obj-$(CONFIG_SERIAL_BFIN_SPORT) += bfin_sport_uart.o
42obj-$(CONFIG_SERIAL_SAMSUNG) += samsung.o 29obj-$(CONFIG_SERIAL_SAMSUNG) += samsung.o
43obj-$(CONFIG_SERIAL_MAX3100) += max3100.o 30obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
44obj-$(CONFIG_SERIAL_MAX3107) += max3107.o 31obj-$(CONFIG_SERIAL_MAX3107) += max3107.o
45obj-$(CONFIG_SERIAL_MAX3107_AAVA) += max3107-aava.o
46obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o 32obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
47obj-$(CONFIG_SERIAL_MUX) += mux.o 33obj-$(CONFIG_SERIAL_MUX) += mux.o
48obj-$(CONFIG_SERIAL_68328) += 68328serial.o 34obj-$(CONFIG_SERIAL_68328) += 68328serial.o
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 9ae024025ff3..6800f5f26241 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -159,6 +159,7 @@ struct uart_amba_port {
159 unsigned int fifosize; /* vendor-specific */ 159 unsigned int fifosize; /* vendor-specific */
160 unsigned int lcrh_tx; /* vendor-specific */ 160 unsigned int lcrh_tx; /* vendor-specific */
161 unsigned int lcrh_rx; /* vendor-specific */ 161 unsigned int lcrh_rx; /* vendor-specific */
162 unsigned int old_cr; /* state during shutdown */
162 bool autorts; 163 bool autorts;
163 char type[12]; 164 char type[12];
164 bool interrupt_may_hang; /* vendor-specific */ 165 bool interrupt_may_hang; /* vendor-specific */
@@ -1411,7 +1412,9 @@ static int pl011_startup(struct uart_port *port)
1411 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY) 1412 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY)
1412 barrier(); 1413 barrier();
1413 1414
1414 cr = UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE; 1415 /* restore RTS and DTR */
1416 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR);
1417 cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE;
1415 writew(cr, uap->port.membase + UART011_CR); 1418 writew(cr, uap->port.membase + UART011_CR);
1416 1419
1417 /* Clear pending error interrupts */ 1420 /* Clear pending error interrupts */
@@ -1469,6 +1472,7 @@ static void pl011_shutdown_channel(struct uart_amba_port *uap,
1469static void pl011_shutdown(struct uart_port *port) 1472static void pl011_shutdown(struct uart_port *port)
1470{ 1473{
1471 struct uart_amba_port *uap = (struct uart_amba_port *)port; 1474 struct uart_amba_port *uap = (struct uart_amba_port *)port;
1475 unsigned int cr;
1472 1476
1473 /* 1477 /*
1474 * disable all interrupts 1478 * disable all interrupts
@@ -1488,9 +1492,16 @@ static void pl011_shutdown(struct uart_port *port)
1488 1492
1489 /* 1493 /*
1490 * disable the port 1494 * disable the port
1495 * disable the port. It should not disable RTS and DTR.
1496 * Also RTS and DTR state should be preserved to restore
1497 * it during startup().
1491 */ 1498 */
1492 uap->autorts = false; 1499 uap->autorts = false;
1493 writew(UART01x_CR_UARTEN | UART011_CR_TXE, uap->port.membase + UART011_CR); 1500 cr = readw(uap->port.membase + UART011_CR);
1501 uap->old_cr = cr;
1502 cr &= UART011_CR_RTS | UART011_CR_DTR;
1503 cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
1504 writew(cr, uap->port.membase + UART011_CR);
1494 1505
1495 /* 1506 /*
1496 * disable break condition and fifos 1507 * disable break condition and fifos
@@ -1740,9 +1751,19 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
1740{ 1751{
1741 struct uart_amba_port *uap = amba_ports[co->index]; 1752 struct uart_amba_port *uap = amba_ports[co->index];
1742 unsigned int status, old_cr, new_cr; 1753 unsigned int status, old_cr, new_cr;
1754 unsigned long flags;
1755 int locked = 1;
1743 1756
1744 clk_enable(uap->clk); 1757 clk_enable(uap->clk);
1745 1758
1759 local_irq_save(flags);
1760 if (uap->port.sysrq)
1761 locked = 0;
1762 else if (oops_in_progress)
1763 locked = spin_trylock(&uap->port.lock);
1764 else
1765 spin_lock(&uap->port.lock);
1766
1746 /* 1767 /*
1747 * First save the CR then disable the interrupts 1768 * First save the CR then disable the interrupts
1748 */ 1769 */
@@ -1762,6 +1783,10 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
1762 } while (status & UART01x_FR_BUSY); 1783 } while (status & UART01x_FR_BUSY);
1763 writew(old_cr, uap->port.membase + UART011_CR); 1784 writew(old_cr, uap->port.membase + UART011_CR);
1764 1785
1786 if (locked)
1787 spin_unlock(&uap->port.lock);
1788 local_irq_restore(flags);
1789
1765 clk_disable(uap->clk); 1790 clk_disable(uap->clk);
1766} 1791}
1767 1792
@@ -1905,6 +1930,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1905 uap->vendor = vendor; 1930 uap->vendor = vendor;
1906 uap->lcrh_rx = vendor->lcrh_rx; 1931 uap->lcrh_rx = vendor->lcrh_rx;
1907 uap->lcrh_tx = vendor->lcrh_tx; 1932 uap->lcrh_tx = vendor->lcrh_tx;
1933 uap->old_cr = 0;
1908 uap->fifosize = vendor->fifosize; 1934 uap->fifosize = vendor->fifosize;
1909 uap->interrupt_may_hang = vendor->interrupt_may_hang; 1935 uap->interrupt_may_hang = vendor->interrupt_may_hang;
1910 uap->port.dev = &dev->dev; 1936 uap->port.dev = &dev->dev;
diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
index 7c867a046c97..7545fe1b9925 100644
--- a/drivers/tty/serial/jsm/jsm_driver.c
+++ b/drivers/tty/serial/jsm/jsm_driver.c
@@ -251,6 +251,7 @@ static void jsm_io_resume(struct pci_dev *pdev)
251 struct jsm_board *brd = pci_get_drvdata(pdev); 251 struct jsm_board *brd = pci_get_drvdata(pdev);
252 252
253 pci_restore_state(pdev); 253 pci_restore_state(pdev);
254 pci_save_state(pdev);
254 255
255 jsm_uart_port_init(brd); 256 jsm_uart_port_init(brd);
256} 257}
diff --git a/drivers/tty/serial/max3107-aava.c b/drivers/tty/serial/max3107-aava.c
deleted file mode 100644
index aae772a71de6..000000000000
--- a/drivers/tty/serial/max3107-aava.c
+++ /dev/null
@@ -1,344 +0,0 @@
1/*
2 * max3107.c - spi uart protocol driver for Maxim 3107
3 * Based on max3100.c
4 * by Christian Pellegrin <chripell@evolware.org>
5 * and max3110.c
6 * by Feng Tang <feng.tang@intel.com>
7 *
8 * Copyright (C) Aavamobile 2009
9 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 *
28 */
29
30#include <linux/delay.h>
31#include <linux/device.h>
32#include <linux/serial_core.h>
33#include <linux/serial.h>
34#include <linux/spi/spi.h>
35#include <linux/freezer.h>
36#include <linux/platform_device.h>
37#include <linux/gpio.h>
38#include <linux/sfi.h>
39#include <linux/module.h>
40#include <asm/mrst.h>
41#include "max3107.h"
42
43/* GPIO direction to input function */
44static int max3107_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
45{
46 struct max3107_port *s = container_of(chip, struct max3107_port, chip);
47 u16 buf[1]; /* Buffer for SPI transfer */
48
49 if (offset >= MAX3107_GPIO_COUNT) {
50 dev_err(&s->spi->dev, "Invalid GPIO\n");
51 return -EINVAL;
52 }
53
54 /* Read current GPIO configuration register */
55 buf[0] = MAX3107_GPIOCFG_REG;
56 /* Perform SPI transfer */
57 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 2)) {
58 dev_err(&s->spi->dev, "SPI transfer GPIO read failed\n");
59 return -EIO;
60 }
61 buf[0] &= MAX3107_SPI_RX_DATA_MASK;
62
63 /* Set GPIO to input */
64 buf[0] &= ~(0x0001 << offset);
65
66 /* Write new GPIO configuration register value */
67 buf[0] |= (MAX3107_WRITE_BIT | MAX3107_GPIOCFG_REG);
68 /* Perform SPI transfer */
69 if (max3107_rw(s, (u8 *)buf, NULL, 2)) {
70 dev_err(&s->spi->dev, "SPI transfer GPIO write failed\n");
71 return -EIO;
72 }
73 return 0;
74}
75
76/* GPIO direction to output function */
77static int max3107_gpio_direction_out(struct gpio_chip *chip, unsigned offset,
78 int value)
79{
80 struct max3107_port *s = container_of(chip, struct max3107_port, chip);
81 u16 buf[2]; /* Buffer for SPI transfers */
82
83 if (offset >= MAX3107_GPIO_COUNT) {
84 dev_err(&s->spi->dev, "Invalid GPIO\n");
85 return -EINVAL;
86 }
87
88 /* Read current GPIO configuration and data registers */
89 buf[0] = MAX3107_GPIOCFG_REG;
90 buf[1] = MAX3107_GPIODATA_REG;
91 /* Perform SPI transfer */
92 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 4)) {
93 dev_err(&s->spi->dev, "SPI transfer gpio failed\n");
94 return -EIO;
95 }
96 buf[0] &= MAX3107_SPI_RX_DATA_MASK;
97 buf[1] &= MAX3107_SPI_RX_DATA_MASK;
98
99 /* Set GPIO to output */
100 buf[0] |= (0x0001 << offset);
101 /* Set value */
102 if (value)
103 buf[1] |= (0x0001 << offset);
104 else
105 buf[1] &= ~(0x0001 << offset);
106
107 /* Write new GPIO configuration and data register values */
108 buf[0] |= (MAX3107_WRITE_BIT | MAX3107_GPIOCFG_REG);
109 buf[1] |= (MAX3107_WRITE_BIT | MAX3107_GPIODATA_REG);
110 /* Perform SPI transfer */
111 if (max3107_rw(s, (u8 *)buf, NULL, 4)) {
112 dev_err(&s->spi->dev,
113 "SPI transfer for GPIO conf data w failed\n");
114 return -EIO;
115 }
116 return 0;
117}
118
119/* GPIO value query function */
120static int max3107_gpio_get(struct gpio_chip *chip, unsigned offset)
121{
122 struct max3107_port *s = container_of(chip, struct max3107_port, chip);
123 u16 buf[1]; /* Buffer for SPI transfer */
124
125 if (offset >= MAX3107_GPIO_COUNT) {
126 dev_err(&s->spi->dev, "Invalid GPIO\n");
127 return -EINVAL;
128 }
129
130 /* Read current GPIO data register */
131 buf[0] = MAX3107_GPIODATA_REG;
132 /* Perform SPI transfer */
133 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 2)) {
134 dev_err(&s->spi->dev, "SPI transfer GPIO data r failed\n");
135 return -EIO;
136 }
137 buf[0] &= MAX3107_SPI_RX_DATA_MASK;
138
139 /* Return value */
140 return buf[0] & (0x0001 << offset);
141}
142
143/* GPIO value set function */
144static void max3107_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
145{
146 struct max3107_port *s = container_of(chip, struct max3107_port, chip);
147 u16 buf[2]; /* Buffer for SPI transfers */
148
149 if (offset >= MAX3107_GPIO_COUNT) {
150 dev_err(&s->spi->dev, "Invalid GPIO\n");
151 return;
152 }
153
154 /* Read current GPIO configuration registers*/
155 buf[0] = MAX3107_GPIODATA_REG;
156 buf[1] = MAX3107_GPIOCFG_REG;
157 /* Perform SPI transfer */
158 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 4)) {
159 dev_err(&s->spi->dev,
160 "SPI transfer for GPIO data and config read failed\n");
161 return;
162 }
163 buf[0] &= MAX3107_SPI_RX_DATA_MASK;
164 buf[1] &= MAX3107_SPI_RX_DATA_MASK;
165
166 if (!(buf[1] & (0x0001 << offset))) {
167 /* Configured as input, can't set value */
168 dev_warn(&s->spi->dev,
169 "Trying to set value for input GPIO\n");
170 return;
171 }
172
173 /* Set value */
174 if (value)
175 buf[0] |= (0x0001 << offset);
176 else
177 buf[0] &= ~(0x0001 << offset);
178
179 /* Write new GPIO data register value */
180 buf[0] |= (MAX3107_WRITE_BIT | MAX3107_GPIODATA_REG);
181 /* Perform SPI transfer */
182 if (max3107_rw(s, (u8 *)buf, NULL, 2))
183 dev_err(&s->spi->dev, "SPI transfer GPIO data w failed\n");
184}
185
186/* GPIO chip data */
187static struct gpio_chip max3107_gpio_chip = {
188 .owner = THIS_MODULE,
189 .direction_input = max3107_gpio_direction_in,
190 .direction_output = max3107_gpio_direction_out,
191 .get = max3107_gpio_get,
192 .set = max3107_gpio_set,
193 .can_sleep = 1,
194 .base = MAX3107_GPIO_BASE,
195 .ngpio = MAX3107_GPIO_COUNT,
196};
197
198/**
199 * max3107_aava_reset - reset on AAVA systems
200 * @spi: The SPI device we are probing
201 *
202 * Reset the device ready for probing.
203 */
204
205static int max3107_aava_reset(struct spi_device *spi)
206{
207 /* Reset the chip */
208 if (gpio_request(MAX3107_RESET_GPIO, "max3107")) {
209 pr_err("Requesting RESET GPIO failed\n");
210 return -EIO;
211 }
212 if (gpio_direction_output(MAX3107_RESET_GPIO, 0)) {
213 pr_err("Setting RESET GPIO to 0 failed\n");
214 gpio_free(MAX3107_RESET_GPIO);
215 return -EIO;
216 }
217 msleep(MAX3107_RESET_DELAY);
218 if (gpio_direction_output(MAX3107_RESET_GPIO, 1)) {
219 pr_err("Setting RESET GPIO to 1 failed\n");
220 gpio_free(MAX3107_RESET_GPIO);
221 return -EIO;
222 }
223 gpio_free(MAX3107_RESET_GPIO);
224 msleep(MAX3107_WAKEUP_DELAY);
225 return 0;
226}
227
228static int max3107_aava_configure(struct max3107_port *s)
229{
230 int retval;
231
232 /* Initialize GPIO chip data */
233 s->chip = max3107_gpio_chip;
234 s->chip.label = s->spi->modalias;
235 s->chip.dev = &s->spi->dev;
236
237 /* Add GPIO chip */
238 retval = gpiochip_add(&s->chip);
239 if (retval) {
240 dev_err(&s->spi->dev, "Adding GPIO chip failed\n");
241 return retval;
242 }
243
244 /* Temporary fix for EV2 boot problems, set modem reset to 0 */
245 max3107_gpio_direction_out(&s->chip, 3, 0);
246 return 0;
247}
248
249#if 0
250/* This will get enabled once we have the board stuff merged for this
251 specific case */
252
253static const struct baud_table brg13_ext[] = {
254 { 300, MAX3107_BRG13_B300 },
255 { 600, MAX3107_BRG13_B600 },
256 { 1200, MAX3107_BRG13_B1200 },
257 { 2400, MAX3107_BRG13_B2400 },
258 { 4800, MAX3107_BRG13_B4800 },
259 { 9600, MAX3107_BRG13_B9600 },
260 { 19200, MAX3107_BRG13_B19200 },
261 { 57600, MAX3107_BRG13_B57600 },
262 { 115200, MAX3107_BRG13_B115200 },
263 { 230400, MAX3107_BRG13_B230400 },
264 { 460800, MAX3107_BRG13_B460800 },
265 { 921600, MAX3107_BRG13_B921600 },
266 { 0, 0 }
267};
268
269static void max3107_aava_init(struct max3107_port *s)
270{
271 /*override for AAVA SC specific*/
272 if (mrst_platform_id() == MRST_PLATFORM_AAVA_SC) {
273 if (get_koski_build_id() <= KOSKI_EV2)
274 if (s->ext_clk) {
275 s->brg_cfg = MAX3107_BRG13_B9600;
276 s->baud_tbl = (struct baud_table *)brg13_ext;
277 }
278 }
279}
280#endif
281
282static int __devexit max3107_aava_remove(struct spi_device *spi)
283{
284 struct max3107_port *s = dev_get_drvdata(&spi->dev);
285
286 /* Remove GPIO chip */
287 if (gpiochip_remove(&s->chip))
288 dev_warn(&spi->dev, "Removing GPIO chip failed\n");
289
290 /* Then do the default remove */
291 return max3107_remove(spi);
292}
293
294/* Platform data */
295static struct max3107_plat aava_plat_data = {
296 .loopback = 0,
297 .ext_clk = 1,
298/* .init = max3107_aava_init, */
299 .configure = max3107_aava_configure,
300 .hw_suspend = max3107_hw_susp,
301 .polled_mode = 0,
302 .poll_time = 0,
303};
304
305
306static int __devinit max3107_probe_aava(struct spi_device *spi)
307{
308 int err = max3107_aava_reset(spi);
309 if (err < 0)
310 return err;
311 return max3107_probe(spi, &aava_plat_data);
312}
313
314/* Spi driver data */
315static struct spi_driver max3107_driver = {
316 .driver = {
317 .name = "aava-max3107",
318 .owner = THIS_MODULE,
319 },
320 .probe = max3107_probe_aava,
321 .remove = __devexit_p(max3107_aava_remove),
322 .suspend = max3107_suspend,
323 .resume = max3107_resume,
324};
325
326/* Driver init function */
327static int __init max3107_init(void)
328{
329 return spi_register_driver(&max3107_driver);
330}
331
332/* Driver exit function */
333static void __exit max3107_exit(void)
334{
335 spi_unregister_driver(&max3107_driver);
336}
337
338module_init(max3107_init);
339module_exit(max3107_exit);
340
341MODULE_DESCRIPTION("MAX3107 driver");
342MODULE_AUTHOR("Aavamobile");
343MODULE_ALIAS("spi:aava-max3107");
344MODULE_LICENSE("GPL v2");
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index d192dcbb82f5..1c2426931484 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1160,7 +1160,7 @@ static struct uart_driver serial_omap_reg = {
1160 .cons = OMAP_CONSOLE, 1160 .cons = OMAP_CONSOLE,
1161}; 1161};
1162 1162
1163#ifdef CONFIG_SUSPEND 1163#ifdef CONFIG_PM_SLEEP
1164static int serial_omap_suspend(struct device *dev) 1164static int serial_omap_suspend(struct device *dev)
1165{ 1165{
1166 struct uart_omap_port *up = dev_get_drvdata(dev); 1166 struct uart_omap_port *up = dev_get_drvdata(dev);
@@ -1521,6 +1521,7 @@ static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1)
1521 } 1521 }
1522} 1522}
1523 1523
1524#ifdef CONFIG_PM_RUNTIME
1524static void serial_omap_restore_context(struct uart_omap_port *up) 1525static void serial_omap_restore_context(struct uart_omap_port *up)
1525{ 1526{
1526 if (up->errata & UART_ERRATA_i202_MDR1_ACCESS) 1527 if (up->errata & UART_ERRATA_i202_MDR1_ACCESS)
@@ -1550,7 +1551,6 @@ static void serial_omap_restore_context(struct uart_omap_port *up)
1550 serial_out(up, UART_OMAP_MDR1, up->mdr1); 1551 serial_out(up, UART_OMAP_MDR1, up->mdr1);
1551} 1552}
1552 1553
1553#ifdef CONFIG_PM_RUNTIME
1554static int serial_omap_runtime_suspend(struct device *dev) 1554static int serial_omap_runtime_suspend(struct device *dev)
1555{ 1555{
1556 struct uart_omap_port *up = dev_get_drvdata(dev); 1556 struct uart_omap_port *up = dev_get_drvdata(dev);
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index c7bf31a6a7e7..13056180adf5 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2348,11 +2348,11 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
2348 */ 2348 */
2349 tty_dev = tty_register_device(drv->tty_driver, uport->line, uport->dev); 2349 tty_dev = tty_register_device(drv->tty_driver, uport->line, uport->dev);
2350 if (likely(!IS_ERR(tty_dev))) { 2350 if (likely(!IS_ERR(tty_dev))) {
2351 device_init_wakeup(tty_dev, 1); 2351 device_set_wakeup_capable(tty_dev, 1);
2352 device_set_wakeup_enable(tty_dev, 0); 2352 } else {
2353 } else
2354 printk(KERN_ERR "Cannot register tty device on line %d\n", 2353 printk(KERN_ERR "Cannot register tty device on line %d\n",
2355 uport->line); 2354 uport->line);
2355 }
2356 2356
2357 /* 2357 /*
2358 * Ensure UPF_DEAD is not set. 2358 * Ensure UPF_DEAD is not set.
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index ef9dd628ba0b..bf6e238146ae 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -227,7 +227,6 @@ int tty_port_block_til_ready(struct tty_port *port,
227 int do_clocal = 0, retval; 227 int do_clocal = 0, retval;
228 unsigned long flags; 228 unsigned long flags;
229 DEFINE_WAIT(wait); 229 DEFINE_WAIT(wait);
230 int cd;
231 230
232 /* block if port is in the process of being closed */ 231 /* block if port is in the process of being closed */
233 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { 232 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
@@ -284,11 +283,14 @@ int tty_port_block_til_ready(struct tty_port *port,
284 retval = -ERESTARTSYS; 283 retval = -ERESTARTSYS;
285 break; 284 break;
286 } 285 }
287 /* Probe the carrier. For devices with no carrier detect this 286 /*
288 will always return true */ 287 * Probe the carrier. For devices with no carrier detect
289 cd = tty_port_carrier_raised(port); 288 * tty_port_carrier_raised will always return true.
289 * Never ask drivers if CLOCAL is set, this causes troubles
290 * on some hardware.
291 */
290 if (!(port->flags & ASYNC_CLOSING) && 292 if (!(port->flags & ASYNC_CLOSING) &&
291 (do_clocal || cd)) 293 (do_clocal || tty_port_carrier_raised(port)))
292 break; 294 break;
293 if (signal_pending(current)) { 295 if (signal_pending(current)) {
294 retval = -ERESTARTSYS; 296 retval = -ERESTARTSYS;
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index 5e096f43bcea..65447c5f91d7 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -1463,7 +1463,6 @@ compat_kdfontop_ioctl(struct compat_console_font_op __user *fontop,
1463 if (!perm && op->op != KD_FONT_OP_GET) 1463 if (!perm && op->op != KD_FONT_OP_GET)
1464 return -EPERM; 1464 return -EPERM;
1465 op->data = compat_ptr(((struct compat_console_font_op *)op)->data); 1465 op->data = compat_ptr(((struct compat_console_font_op *)op)->data);
1466 op->flags |= KD_FONT_FLAG_OLD;
1467 i = con_font_op(vc, op); 1466 i = con_font_op(vc, op);
1468 if (i) 1467 if (i)
1469 return i; 1468 return i;
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 1c50baff7725..d2b3cffca3f7 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -57,6 +57,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
57 57
58#define WDM_MAX 16 58#define WDM_MAX 16
59 59
60/* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */
61#define WDM_DEFAULT_BUFSIZE 256
60 62
61static DEFINE_MUTEX(wdm_mutex); 63static DEFINE_MUTEX(wdm_mutex);
62 64
@@ -88,7 +90,8 @@ struct wdm_device {
88 int count; 90 int count;
89 dma_addr_t shandle; 91 dma_addr_t shandle;
90 dma_addr_t ihandle; 92 dma_addr_t ihandle;
91 struct mutex lock; 93 struct mutex wlock;
94 struct mutex rlock;
92 wait_queue_head_t wait; 95 wait_queue_head_t wait;
93 struct work_struct rxwork; 96 struct work_struct rxwork;
94 int werr; 97 int werr;
@@ -323,7 +326,7 @@ static ssize_t wdm_write
323 } 326 }
324 327
325 /* concurrent writes and disconnect */ 328 /* concurrent writes and disconnect */
326 r = mutex_lock_interruptible(&desc->lock); 329 r = mutex_lock_interruptible(&desc->wlock);
327 rv = -ERESTARTSYS; 330 rv = -ERESTARTSYS;
328 if (r) { 331 if (r) {
329 kfree(buf); 332 kfree(buf);
@@ -386,7 +389,7 @@ static ssize_t wdm_write
386out: 389out:
387 usb_autopm_put_interface(desc->intf); 390 usb_autopm_put_interface(desc->intf);
388outnp: 391outnp:
389 mutex_unlock(&desc->lock); 392 mutex_unlock(&desc->wlock);
390outnl: 393outnl:
391 return rv < 0 ? rv : count; 394 return rv < 0 ? rv : count;
392} 395}
@@ -399,7 +402,7 @@ static ssize_t wdm_read
399 struct wdm_device *desc = file->private_data; 402 struct wdm_device *desc = file->private_data;
400 403
401 404
402 rv = mutex_lock_interruptible(&desc->lock); /*concurrent reads */ 405 rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
403 if (rv < 0) 406 if (rv < 0)
404 return -ERESTARTSYS; 407 return -ERESTARTSYS;
405 408
@@ -467,14 +470,16 @@ retry:
467 for (i = 0; i < desc->length - cntr; i++) 470 for (i = 0; i < desc->length - cntr; i++)
468 desc->ubuf[i] = desc->ubuf[i + cntr]; 471 desc->ubuf[i] = desc->ubuf[i + cntr];
469 472
473 spin_lock_irq(&desc->iuspin);
470 desc->length -= cntr; 474 desc->length -= cntr;
475 spin_unlock_irq(&desc->iuspin);
471 /* in case we had outstanding data */ 476 /* in case we had outstanding data */
472 if (!desc->length) 477 if (!desc->length)
473 clear_bit(WDM_READ, &desc->flags); 478 clear_bit(WDM_READ, &desc->flags);
474 rv = cntr; 479 rv = cntr;
475 480
476err: 481err:
477 mutex_unlock(&desc->lock); 482 mutex_unlock(&desc->rlock);
478 return rv; 483 return rv;
479} 484}
480 485
@@ -540,7 +545,8 @@ static int wdm_open(struct inode *inode, struct file *file)
540 } 545 }
541 intf->needs_remote_wakeup = 1; 546 intf->needs_remote_wakeup = 1;
542 547
543 mutex_lock(&desc->lock); 548 /* using write lock to protect desc->count */
549 mutex_lock(&desc->wlock);
544 if (!desc->count++) { 550 if (!desc->count++) {
545 desc->werr = 0; 551 desc->werr = 0;
546 desc->rerr = 0; 552 desc->rerr = 0;
@@ -553,7 +559,7 @@ static int wdm_open(struct inode *inode, struct file *file)
553 } else { 559 } else {
554 rv = 0; 560 rv = 0;
555 } 561 }
556 mutex_unlock(&desc->lock); 562 mutex_unlock(&desc->wlock);
557 usb_autopm_put_interface(desc->intf); 563 usb_autopm_put_interface(desc->intf);
558out: 564out:
559 mutex_unlock(&wdm_mutex); 565 mutex_unlock(&wdm_mutex);
@@ -565,9 +571,11 @@ static int wdm_release(struct inode *inode, struct file *file)
565 struct wdm_device *desc = file->private_data; 571 struct wdm_device *desc = file->private_data;
566 572
567 mutex_lock(&wdm_mutex); 573 mutex_lock(&wdm_mutex);
568 mutex_lock(&desc->lock); 574
575 /* using write lock to protect desc->count */
576 mutex_lock(&desc->wlock);
569 desc->count--; 577 desc->count--;
570 mutex_unlock(&desc->lock); 578 mutex_unlock(&desc->wlock);
571 579
572 if (!desc->count) { 580 if (!desc->count) {
573 dev_dbg(&desc->intf->dev, "wdm_release: cleanup"); 581 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
@@ -630,7 +638,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
630 struct usb_cdc_dmm_desc *dmhd; 638 struct usb_cdc_dmm_desc *dmhd;
631 u8 *buffer = intf->altsetting->extra; 639 u8 *buffer = intf->altsetting->extra;
632 int buflen = intf->altsetting->extralen; 640 int buflen = intf->altsetting->extralen;
633 u16 maxcom = 0; 641 u16 maxcom = WDM_DEFAULT_BUFSIZE;
634 642
635 if (!buffer) 643 if (!buffer)
636 goto out; 644 goto out;
@@ -665,7 +673,8 @@ next_desc:
665 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL); 673 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
666 if (!desc) 674 if (!desc)
667 goto out; 675 goto out;
668 mutex_init(&desc->lock); 676 mutex_init(&desc->rlock);
677 mutex_init(&desc->wlock);
669 spin_lock_init(&desc->iuspin); 678 spin_lock_init(&desc->iuspin);
670 init_waitqueue_head(&desc->wait); 679 init_waitqueue_head(&desc->wait);
671 desc->wMaxCommand = maxcom; 680 desc->wMaxCommand = maxcom;
@@ -716,7 +725,7 @@ next_desc:
716 goto err; 725 goto err;
717 726
718 desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf), 727 desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf),
719 desc->bMaxPacketSize0, 728 desc->wMaxCommand,
720 GFP_KERNEL, 729 GFP_KERNEL,
721 &desc->response->transfer_dma); 730 &desc->response->transfer_dma);
722 if (!desc->inbuf) 731 if (!desc->inbuf)
@@ -779,11 +788,13 @@ static void wdm_disconnect(struct usb_interface *intf)
779 /* to terminate pending flushes */ 788 /* to terminate pending flushes */
780 clear_bit(WDM_IN_USE, &desc->flags); 789 clear_bit(WDM_IN_USE, &desc->flags);
781 spin_unlock_irqrestore(&desc->iuspin, flags); 790 spin_unlock_irqrestore(&desc->iuspin, flags);
782 mutex_lock(&desc->lock); 791 wake_up_all(&desc->wait);
792 mutex_lock(&desc->rlock);
793 mutex_lock(&desc->wlock);
783 kill_urbs(desc); 794 kill_urbs(desc);
784 cancel_work_sync(&desc->rxwork); 795 cancel_work_sync(&desc->rxwork);
785 mutex_unlock(&desc->lock); 796 mutex_unlock(&desc->wlock);
786 wake_up_all(&desc->wait); 797 mutex_unlock(&desc->rlock);
787 if (!desc->count) 798 if (!desc->count)
788 cleanup(desc); 799 cleanup(desc);
789 mutex_unlock(&wdm_mutex); 800 mutex_unlock(&wdm_mutex);
@@ -798,8 +809,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
798 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor); 809 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
799 810
800 /* if this is an autosuspend the caller does the locking */ 811 /* if this is an autosuspend the caller does the locking */
801 if (!PMSG_IS_AUTO(message)) 812 if (!PMSG_IS_AUTO(message)) {
802 mutex_lock(&desc->lock); 813 mutex_lock(&desc->rlock);
814 mutex_lock(&desc->wlock);
815 }
803 spin_lock_irq(&desc->iuspin); 816 spin_lock_irq(&desc->iuspin);
804 817
805 if (PMSG_IS_AUTO(message) && 818 if (PMSG_IS_AUTO(message) &&
@@ -815,8 +828,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
815 kill_urbs(desc); 828 kill_urbs(desc);
816 cancel_work_sync(&desc->rxwork); 829 cancel_work_sync(&desc->rxwork);
817 } 830 }
818 if (!PMSG_IS_AUTO(message)) 831 if (!PMSG_IS_AUTO(message)) {
819 mutex_unlock(&desc->lock); 832 mutex_unlock(&desc->wlock);
833 mutex_unlock(&desc->rlock);
834 }
820 835
821 return rv; 836 return rv;
822} 837}
@@ -854,7 +869,8 @@ static int wdm_pre_reset(struct usb_interface *intf)
854{ 869{
855 struct wdm_device *desc = usb_get_intfdata(intf); 870 struct wdm_device *desc = usb_get_intfdata(intf);
856 871
857 mutex_lock(&desc->lock); 872 mutex_lock(&desc->rlock);
873 mutex_lock(&desc->wlock);
858 kill_urbs(desc); 874 kill_urbs(desc);
859 875
860 /* 876 /*
@@ -876,7 +892,8 @@ static int wdm_post_reset(struct usb_interface *intf)
876 int rv; 892 int rv;
877 893
878 rv = recover_from_urb_loss(desc); 894 rv = recover_from_urb_loss(desc);
879 mutex_unlock(&desc->lock); 895 mutex_unlock(&desc->wlock);
896 mutex_unlock(&desc->rlock);
880 return 0; 897 return 0;
881} 898}
882 899
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 2f51de57593a..c8df1dd967ef 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -126,7 +126,6 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
126 struct dwc3_request *req) 126 struct dwc3_request *req)
127{ 127{
128 struct dwc3 *dwc = dep->dwc; 128 struct dwc3 *dwc = dep->dwc;
129 u32 type;
130 int ret = 0; 129 int ret = 0;
131 130
132 req->request.actual = 0; 131 req->request.actual = 0;
@@ -149,20 +148,14 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
149 148
150 direction = !!(dep->flags & DWC3_EP0_DIR_IN); 149 direction = !!(dep->flags & DWC3_EP0_DIR_IN);
151 150
152 if (dwc->ep0state == EP0_STATUS_PHASE) { 151 if (dwc->ep0state != EP0_DATA_PHASE) {
153 type = dwc->three_stage_setup 152 dev_WARN(dwc->dev, "Unexpected pending request\n");
154 ? DWC3_TRBCTL_CONTROL_STATUS3
155 : DWC3_TRBCTL_CONTROL_STATUS2;
156 } else if (dwc->ep0state == EP0_DATA_PHASE) {
157 type = DWC3_TRBCTL_CONTROL_DATA;
158 } else {
159 /* should never happen */
160 WARN_ON(1);
161 return 0; 153 return 0;
162 } 154 }
163 155
164 ret = dwc3_ep0_start_trans(dwc, direction, 156 ret = dwc3_ep0_start_trans(dwc, direction,
165 req->request.dma, req->request.length, type); 157 req->request.dma, req->request.length,
158 DWC3_TRBCTL_CONTROL_DATA);
166 dep->flags &= ~(DWC3_EP_PENDING_REQUEST | 159 dep->flags &= ~(DWC3_EP_PENDING_REQUEST |
167 DWC3_EP0_DIR_IN); 160 DWC3_EP0_DIR_IN);
168 } else if (dwc->delayed_status) { 161 } else if (dwc->delayed_status) {
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a696bde53222..064b6e2cd411 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -101,7 +101,7 @@ void dwc3_unmap_buffer_from_dma(struct dwc3_request *req)
101 if (req->request.num_mapped_sgs) { 101 if (req->request.num_mapped_sgs) {
102 req->request.dma = DMA_ADDR_INVALID; 102 req->request.dma = DMA_ADDR_INVALID;
103 dma_unmap_sg(dwc->dev, req->request.sg, 103 dma_unmap_sg(dwc->dev, req->request.sg,
104 req->request.num_sgs, 104 req->request.num_mapped_sgs,
105 req->direction ? DMA_TO_DEVICE 105 req->direction ? DMA_TO_DEVICE
106 : DMA_FROM_DEVICE); 106 : DMA_FROM_DEVICE);
107 107
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a95de6a4a134..baaebf2830fc 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -175,13 +175,12 @@ ep_found:
175 _ep->comp_desc = comp_desc; 175 _ep->comp_desc = comp_desc;
176 if (g->speed == USB_SPEED_SUPER) { 176 if (g->speed == USB_SPEED_SUPER) {
177 switch (usb_endpoint_type(_ep->desc)) { 177 switch (usb_endpoint_type(_ep->desc)) {
178 case USB_ENDPOINT_XFER_BULK:
179 case USB_ENDPOINT_XFER_INT:
180 _ep->maxburst = comp_desc->bMaxBurst;
181 break;
182 case USB_ENDPOINT_XFER_ISOC: 178 case USB_ENDPOINT_XFER_ISOC:
183 /* mult: bits 1:0 of bmAttributes */ 179 /* mult: bits 1:0 of bmAttributes */
184 _ep->mult = comp_desc->bmAttributes & 0x3; 180 _ep->mult = comp_desc->bmAttributes & 0x3;
181 case USB_ENDPOINT_XFER_BULK:
182 case USB_ENDPOINT_XFER_INT:
183 _ep->maxburst = comp_desc->bMaxBurst;
185 break; 184 break;
186 default: 185 default:
187 /* Do nothing for control endpoints */ 186 /* Do nothing for control endpoints */
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 753aa0683ac1..e0e6375ef5dd 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -126,7 +126,7 @@ ep_matches (
126 * descriptor and see if the EP matches it 126 * descriptor and see if the EP matches it
127 */ 127 */
128 if (usb_endpoint_xfer_bulk(desc)) { 128 if (usb_endpoint_xfer_bulk(desc)) {
129 if (ep_comp) { 129 if (ep_comp && gadget->max_speed >= USB_SPEED_SUPER) {
130 num_req_streams = ep_comp->bmAttributes & 0x1f; 130 num_req_streams = ep_comp->bmAttributes & 0x1f;
131 if (num_req_streams > ep->max_streams) 131 if (num_req_streams > ep->max_streams)
132 return 0; 132 return 0;
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 6353eca1e852..ee8ceec01560 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -3123,15 +3123,15 @@ fsg_add(struct usb_composite_dev *cdev, struct usb_configuration *c,
3123 3123
3124struct fsg_module_parameters { 3124struct fsg_module_parameters {
3125 char *file[FSG_MAX_LUNS]; 3125 char *file[FSG_MAX_LUNS];
3126 int ro[FSG_MAX_LUNS]; 3126 bool ro[FSG_MAX_LUNS];
3127 int removable[FSG_MAX_LUNS]; 3127 bool removable[FSG_MAX_LUNS];
3128 int cdrom[FSG_MAX_LUNS]; 3128 bool cdrom[FSG_MAX_LUNS];
3129 int nofua[FSG_MAX_LUNS]; 3129 bool nofua[FSG_MAX_LUNS];
3130 3130
3131 unsigned int file_count, ro_count, removable_count, cdrom_count; 3131 unsigned int file_count, ro_count, removable_count, cdrom_count;
3132 unsigned int nofua_count; 3132 unsigned int nofua_count;
3133 unsigned int luns; /* nluns */ 3133 unsigned int luns; /* nluns */
3134 int stall; /* can_stall */ 3134 bool stall; /* can_stall */
3135}; 3135};
3136 3136
3137#define _FSG_MODULE_PARAM_ARRAY(prefix, params, name, type, desc) \ 3137#define _FSG_MODULE_PARAM_ARRAY(prefix, params, name, type, desc) \
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index d7ea6c076ce9..b04712f19f1e 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -1430,7 +1430,7 @@ static void setup_received_irq(struct fsl_udc *udc,
1430 int pipe = get_pipe_by_windex(wIndex); 1430 int pipe = get_pipe_by_windex(wIndex);
1431 struct fsl_ep *ep; 1431 struct fsl_ep *ep;
1432 1432
1433 if (wValue != 0 || wLength != 0 || pipe > udc->max_ep) 1433 if (wValue != 0 || wLength != 0 || pipe >= udc->max_ep)
1434 break; 1434 break;
1435 ep = get_ep_by_pipe(udc, pipe); 1435 ep = get_ep_by_pipe(udc, pipe);
1436 1436
@@ -1673,7 +1673,7 @@ static void dtd_complete_irq(struct fsl_udc *udc)
1673 if (!bit_pos) 1673 if (!bit_pos)
1674 return; 1674 return;
1675 1675
1676 for (i = 0; i < udc->max_ep * 2; i++) { 1676 for (i = 0; i < udc->max_ep; i++) {
1677 ep_num = i >> 1; 1677 ep_num = i >> 1;
1678 direction = i % 2; 1678 direction = i % 2;
1679 1679
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c
index fa0fcc11263f..e2293c1588ee 100644
--- a/drivers/usb/gadget/langwell_udc.c
+++ b/drivers/usb/gadget/langwell_udc.c
@@ -11,11 +11,6 @@
11/* #undef DEBUG */ 11/* #undef DEBUG */
12/* #undef VERBOSE_DEBUG */ 12/* #undef VERBOSE_DEBUG */
13 13
14#if defined(CONFIG_USB_LANGWELL_OTG)
15#define OTG_TRANSCEIVER
16#endif
17
18
19#include <linux/module.h> 14#include <linux/module.h>
20#include <linux/pci.h> 15#include <linux/pci.h>
21#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
@@ -1522,8 +1517,7 @@ static void langwell_udc_stop(struct langwell_udc *dev)
1522 1517
1523 1518
1524/* stop all USB activities */ 1519/* stop all USB activities */
1525static void stop_activity(struct langwell_udc *dev, 1520static void stop_activity(struct langwell_udc *dev)
1526 struct usb_gadget_driver *driver)
1527{ 1521{
1528 struct langwell_ep *ep; 1522 struct langwell_ep *ep;
1529 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); 1523 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
@@ -1535,9 +1529,9 @@ static void stop_activity(struct langwell_udc *dev,
1535 } 1529 }
1536 1530
1537 /* report disconnect; the driver is already quiesced */ 1531 /* report disconnect; the driver is already quiesced */
1538 if (driver) { 1532 if (dev->driver) {
1539 spin_unlock(&dev->lock); 1533 spin_unlock(&dev->lock);
1540 driver->disconnect(&dev->gadget); 1534 dev->driver->disconnect(&dev->gadget);
1541 spin_lock(&dev->lock); 1535 spin_lock(&dev->lock);
1542 } 1536 }
1543 1537
@@ -1925,11 +1919,10 @@ static int langwell_stop(struct usb_gadget *g,
1925 1919
1926 /* stop all usb activities */ 1920 /* stop all usb activities */
1927 dev->gadget.speed = USB_SPEED_UNKNOWN; 1921 dev->gadget.speed = USB_SPEED_UNKNOWN;
1928 stop_activity(dev, driver);
1929 spin_unlock_irqrestore(&dev->lock, flags);
1930
1931 dev->gadget.dev.driver = NULL; 1922 dev->gadget.dev.driver = NULL;
1932 dev->driver = NULL; 1923 dev->driver = NULL;
1924 stop_activity(dev);
1925 spin_unlock_irqrestore(&dev->lock, flags);
1933 1926
1934 device_remove_file(&dev->pdev->dev, &dev_attr_function); 1927 device_remove_file(&dev->pdev->dev, &dev_attr_function);
1935 1928
@@ -2315,13 +2308,9 @@ static void handle_setup_packet(struct langwell_udc *dev,
2315 2308
2316 if (!gadget_is_otg(&dev->gadget)) 2309 if (!gadget_is_otg(&dev->gadget))
2317 break; 2310 break;
2318 else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) { 2311 else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE)
2319 dev->gadget.b_hnp_enable = 1; 2312 dev->gadget.b_hnp_enable = 1;
2320#ifdef OTG_TRANSCEIVER 2313 else if (setup->bRequest == USB_DEVICE_A_HNP_SUPPORT)
2321 if (!dev->lotg->otg.default_a)
2322 dev->lotg->hsm.b_hnp_enable = 1;
2323#endif
2324 } else if (setup->bRequest == USB_DEVICE_A_HNP_SUPPORT)
2325 dev->gadget.a_hnp_support = 1; 2314 dev->gadget.a_hnp_support = 1;
2326 else if (setup->bRequest == 2315 else if (setup->bRequest ==
2327 USB_DEVICE_A_ALT_HNP_SUPPORT) 2316 USB_DEVICE_A_ALT_HNP_SUPPORT)
@@ -2733,7 +2722,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
2733 dev->bus_reset = 1; 2722 dev->bus_reset = 1;
2734 2723
2735 /* reset all the queues, stop all USB activities */ 2724 /* reset all the queues, stop all USB activities */
2736 stop_activity(dev, dev->driver); 2725 stop_activity(dev);
2737 dev->usb_state = USB_STATE_DEFAULT; 2726 dev->usb_state = USB_STATE_DEFAULT;
2738 } else { 2727 } else {
2739 dev_vdbg(&dev->pdev->dev, "device controller reset\n"); 2728 dev_vdbg(&dev->pdev->dev, "device controller reset\n");
@@ -2741,7 +2730,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
2741 langwell_udc_reset(dev); 2730 langwell_udc_reset(dev);
2742 2731
2743 /* reset all the queues, stop all USB activities */ 2732 /* reset all the queues, stop all USB activities */
2744 stop_activity(dev, dev->driver); 2733 stop_activity(dev);
2745 2734
2746 /* reset ep0 dQH and endptctrl */ 2735 /* reset ep0 dQH and endptctrl */
2747 ep0_reset(dev); 2736 ep0_reset(dev);
@@ -2752,12 +2741,6 @@ static void handle_usb_reset(struct langwell_udc *dev)
2752 dev->usb_state = USB_STATE_ATTACHED; 2741 dev->usb_state = USB_STATE_ATTACHED;
2753 } 2742 }
2754 2743
2755#ifdef OTG_TRANSCEIVER
2756 /* refer to USB OTG 6.6.2.3 b_hnp_en is cleared */
2757 if (!dev->lotg->otg.default_a)
2758 dev->lotg->hsm.b_hnp_enable = 0;
2759#endif
2760
2761 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); 2744 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2762} 2745}
2763 2746
@@ -2770,29 +2753,6 @@ static void handle_bus_suspend(struct langwell_udc *dev)
2770 dev->resume_state = dev->usb_state; 2753 dev->resume_state = dev->usb_state;
2771 dev->usb_state = USB_STATE_SUSPENDED; 2754 dev->usb_state = USB_STATE_SUSPENDED;
2772 2755
2773#ifdef OTG_TRANSCEIVER
2774 if (dev->lotg->otg.default_a) {
2775 if (dev->lotg->hsm.b_bus_suspend_vld == 1) {
2776 dev->lotg->hsm.b_bus_suspend = 1;
2777 /* notify transceiver the state changes */
2778 if (spin_trylock(&dev->lotg->wq_lock)) {
2779 langwell_update_transceiver();
2780 spin_unlock(&dev->lotg->wq_lock);
2781 }
2782 }
2783 dev->lotg->hsm.b_bus_suspend_vld++;
2784 } else {
2785 if (!dev->lotg->hsm.a_bus_suspend) {
2786 dev->lotg->hsm.a_bus_suspend = 1;
2787 /* notify transceiver the state changes */
2788 if (spin_trylock(&dev->lotg->wq_lock)) {
2789 langwell_update_transceiver();
2790 spin_unlock(&dev->lotg->wq_lock);
2791 }
2792 }
2793 }
2794#endif
2795
2796 /* report suspend to the driver */ 2756 /* report suspend to the driver */
2797 if (dev->driver) { 2757 if (dev->driver) {
2798 if (dev->driver->suspend) { 2758 if (dev->driver->suspend) {
@@ -2823,11 +2783,6 @@ static void handle_bus_resume(struct langwell_udc *dev)
2823 if (dev->pdev->device != 0x0829) 2783 if (dev->pdev->device != 0x0829)
2824 langwell_phy_low_power(dev, 0); 2784 langwell_phy_low_power(dev, 0);
2825 2785
2826#ifdef OTG_TRANSCEIVER
2827 if (dev->lotg->otg.default_a == 0)
2828 dev->lotg->hsm.a_bus_suspend = 0;
2829#endif
2830
2831 /* report resume to the driver */ 2786 /* report resume to the driver */
2832 if (dev->driver) { 2787 if (dev->driver) {
2833 if (dev->driver->resume) { 2788 if (dev->driver->resume) {
@@ -3020,7 +2975,6 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3020 2975
3021 dev->done = &done; 2976 dev->done = &done;
3022 2977
3023#ifndef OTG_TRANSCEIVER
3024 /* free dTD dma_pool and dQH */ 2978 /* free dTD dma_pool and dQH */
3025 if (dev->dtd_pool) 2979 if (dev->dtd_pool)
3026 dma_pool_destroy(dev->dtd_pool); 2980 dma_pool_destroy(dev->dtd_pool);
@@ -3032,7 +2986,6 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3032 /* release SRAM caching */ 2986 /* release SRAM caching */
3033 if (dev->has_sram && dev->got_sram) 2987 if (dev->has_sram && dev->got_sram)
3034 sram_deinit(dev); 2988 sram_deinit(dev);
3035#endif
3036 2989
3037 if (dev->status_req) { 2990 if (dev->status_req) {
3038 kfree(dev->status_req->req.buf); 2991 kfree(dev->status_req->req.buf);
@@ -3045,7 +2998,6 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3045 if (dev->got_irq) 2998 if (dev->got_irq)
3046 free_irq(pdev->irq, dev); 2999 free_irq(pdev->irq, dev);
3047 3000
3048#ifndef OTG_TRANSCEIVER
3049 if (dev->cap_regs) 3001 if (dev->cap_regs)
3050 iounmap(dev->cap_regs); 3002 iounmap(dev->cap_regs);
3051 3003
@@ -3055,13 +3007,6 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3055 3007
3056 if (dev->enabled) 3008 if (dev->enabled)
3057 pci_disable_device(pdev); 3009 pci_disable_device(pdev);
3058#else
3059 if (dev->transceiver) {
3060 otg_put_transceiver(dev->transceiver);
3061 dev->transceiver = NULL;
3062 dev->lotg = NULL;
3063 }
3064#endif
3065 3010
3066 dev->cap_regs = NULL; 3011 dev->cap_regs = NULL;
3067 3012
@@ -3072,9 +3017,7 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3072 device_remove_file(&pdev->dev, &dev_attr_langwell_udc); 3017 device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
3073 device_remove_file(&pdev->dev, &dev_attr_remote_wakeup); 3018 device_remove_file(&pdev->dev, &dev_attr_remote_wakeup);
3074 3019
3075#ifndef OTG_TRANSCEIVER
3076 pci_set_drvdata(pdev, NULL); 3020 pci_set_drvdata(pdev, NULL);
3077#endif
3078 3021
3079 /* free dev, wait for the release() finished */ 3022 /* free dev, wait for the release() finished */
3080 wait_for_completion(&done); 3023 wait_for_completion(&done);
@@ -3089,9 +3032,7 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3089 const struct pci_device_id *id) 3032 const struct pci_device_id *id)
3090{ 3033{
3091 struct langwell_udc *dev; 3034 struct langwell_udc *dev;
3092#ifndef OTG_TRANSCEIVER
3093 unsigned long resource, len; 3035 unsigned long resource, len;
3094#endif
3095 void __iomem *base = NULL; 3036 void __iomem *base = NULL;
3096 size_t size; 3037 size_t size;
3097 int retval; 3038 int retval;
@@ -3109,16 +3050,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3109 dev->pdev = pdev; 3050 dev->pdev = pdev;
3110 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); 3051 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
3111 3052
3112#ifdef OTG_TRANSCEIVER
3113 /* PCI device is already enabled by otg_transceiver driver */
3114 dev->enabled = 1;
3115
3116 /* mem region and register base */
3117 dev->region = 1;
3118 dev->transceiver = otg_get_transceiver();
3119 dev->lotg = otg_to_langwell(dev->transceiver);
3120 base = dev->lotg->regs;
3121#else
3122 pci_set_drvdata(pdev, dev); 3053 pci_set_drvdata(pdev, dev);
3123 3054
3124 /* now all the pci goodies ... */ 3055 /* now all the pci goodies ... */
@@ -3139,7 +3070,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3139 dev->region = 1; 3070 dev->region = 1;
3140 3071
3141 base = ioremap_nocache(resource, len); 3072 base = ioremap_nocache(resource, len);
3142#endif
3143 if (base == NULL) { 3073 if (base == NULL) {
3144 dev_err(&dev->pdev->dev, "can't map memory\n"); 3074 dev_err(&dev->pdev->dev, "can't map memory\n");
3145 retval = -EFAULT; 3075 retval = -EFAULT;
@@ -3163,7 +3093,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3163 dev->got_sram = 0; 3093 dev->got_sram = 0;
3164 dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram); 3094 dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram);
3165 3095
3166#ifndef OTG_TRANSCEIVER
3167 /* enable SRAM caching if detected */ 3096 /* enable SRAM caching if detected */
3168 if (dev->has_sram && !dev->got_sram) 3097 if (dev->has_sram && !dev->got_sram)
3169 sram_init(dev); 3098 sram_init(dev);
@@ -3182,7 +3111,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3182 goto error; 3111 goto error;
3183 } 3112 }
3184 dev->got_irq = 1; 3113 dev->got_irq = 1;
3185#endif
3186 3114
3187 /* set stopped bit */ 3115 /* set stopped bit */
3188 dev->stopped = 1; 3116 dev->stopped = 1;
@@ -3257,10 +3185,8 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3257 dev->remote_wakeup = 0; 3185 dev->remote_wakeup = 0;
3258 dev->dev_status = 1 << USB_DEVICE_SELF_POWERED; 3186 dev->dev_status = 1 << USB_DEVICE_SELF_POWERED;
3259 3187
3260#ifndef OTG_TRANSCEIVER
3261 /* reset device controller */ 3188 /* reset device controller */
3262 langwell_udc_reset(dev); 3189 langwell_udc_reset(dev);
3263#endif
3264 3190
3265 /* initialize gadget structure */ 3191 /* initialize gadget structure */
3266 dev->gadget.ops = &langwell_ops; /* usb_gadget_ops */ 3192 dev->gadget.ops = &langwell_ops; /* usb_gadget_ops */
@@ -3268,9 +3194,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3268 INIT_LIST_HEAD(&dev->gadget.ep_list); /* ep_list */ 3194 INIT_LIST_HEAD(&dev->gadget.ep_list); /* ep_list */
3269 dev->gadget.speed = USB_SPEED_UNKNOWN; /* speed */ 3195 dev->gadget.speed = USB_SPEED_UNKNOWN; /* speed */
3270 dev->gadget.max_speed = USB_SPEED_HIGH; /* support dual speed */ 3196 dev->gadget.max_speed = USB_SPEED_HIGH; /* support dual speed */
3271#ifdef OTG_TRANSCEIVER
3272 dev->gadget.is_otg = 1; /* support otg mode */
3273#endif
3274 3197
3275 /* the "gadget" abstracts/virtualizes the controller */ 3198 /* the "gadget" abstracts/virtualizes the controller */
3276 dev_set_name(&dev->gadget.dev, "gadget"); 3199 dev_set_name(&dev->gadget.dev, "gadget");
@@ -3282,10 +3205,8 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3282 /* controller endpoints reinit */ 3205 /* controller endpoints reinit */
3283 eps_reinit(dev); 3206 eps_reinit(dev);
3284 3207
3285#ifndef OTG_TRANSCEIVER
3286 /* reset ep0 dQH and endptctrl */ 3208 /* reset ep0 dQH and endptctrl */
3287 ep0_reset(dev); 3209 ep0_reset(dev);
3288#endif
3289 3210
3290 /* create dTD dma_pool resource */ 3211 /* create dTD dma_pool resource */
3291 dev->dtd_pool = dma_pool_create("langwell_dtd", 3212 dev->dtd_pool = dma_pool_create("langwell_dtd",
@@ -3367,7 +3288,7 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
3367 3288
3368 spin_lock_irq(&dev->lock); 3289 spin_lock_irq(&dev->lock);
3369 /* stop all usb activities */ 3290 /* stop all usb activities */
3370 stop_activity(dev, dev->driver); 3291 stop_activity(dev);
3371 spin_unlock_irq(&dev->lock); 3292 spin_unlock_irq(&dev->lock);
3372 3293
3373 /* free dTD dma_pool and dQH */ 3294 /* free dTD dma_pool and dQH */
@@ -3525,22 +3446,14 @@ static struct pci_driver langwell_pci_driver = {
3525 3446
3526static int __init init(void) 3447static int __init init(void)
3527{ 3448{
3528#ifdef OTG_TRANSCEIVER
3529 return langwell_register_peripheral(&langwell_pci_driver);
3530#else
3531 return pci_register_driver(&langwell_pci_driver); 3449 return pci_register_driver(&langwell_pci_driver);
3532#endif
3533} 3450}
3534module_init(init); 3451module_init(init);
3535 3452
3536 3453
3537static void __exit cleanup(void) 3454static void __exit cleanup(void)
3538{ 3455{
3539#ifdef OTG_TRANSCEIVER
3540 return langwell_unregister_peripheral(&langwell_pci_driver);
3541#else
3542 pci_unregister_driver(&langwell_pci_driver); 3456 pci_unregister_driver(&langwell_pci_driver);
3543#endif
3544} 3457}
3545module_exit(cleanup); 3458module_exit(cleanup);
3546 3459
diff --git a/drivers/usb/gadget/langwell_udc.h b/drivers/usb/gadget/langwell_udc.h
index ef79e242b7b0..d6e78accaffe 100644
--- a/drivers/usb/gadget/langwell_udc.h
+++ b/drivers/usb/gadget/langwell_udc.h
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#include <linux/usb/langwell_udc.h> 10#include <linux/usb/langwell_udc.h>
11#include <linux/usb/langwell_otg.h>
12 11
13/*-------------------------------------------------------------------------*/ 12/*-------------------------------------------------------------------------*/
14 13
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index c7f291a331df..85ea14e2545e 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -598,16 +598,16 @@ static __maybe_unused struct usb_ss_cap_descriptor fsg_ss_cap_desc = {
598 | USB_5GBPS_OPERATION), 598 | USB_5GBPS_OPERATION),
599 .bFunctionalitySupport = USB_LOW_SPEED_OPERATION, 599 .bFunctionalitySupport = USB_LOW_SPEED_OPERATION,
600 .bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT, 600 .bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT,
601 .bU2DevExitLat = USB_DEFAULT_U2_DEV_EXIT_LAT, 601 .bU2DevExitLat = cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT),
602}; 602};
603 603
604static __maybe_unused struct usb_bos_descriptor fsg_bos_desc = { 604static __maybe_unused struct usb_bos_descriptor fsg_bos_desc = {
605 .bLength = USB_DT_BOS_SIZE, 605 .bLength = USB_DT_BOS_SIZE,
606 .bDescriptorType = USB_DT_BOS, 606 .bDescriptorType = USB_DT_BOS,
607 607
608 .wTotalLength = USB_DT_BOS_SIZE 608 .wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE
609 + USB_DT_USB_EXT_CAP_SIZE 609 + USB_DT_USB_EXT_CAP_SIZE
610 + USB_DT_USB_SS_CAP_SIZE, 610 + USB_DT_USB_SS_CAP_SIZE),
611 611
612 .bNumDeviceCaps = 2, 612 .bNumDeviceCaps = 2,
613}; 613};
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index e90344a17631..b556a72264d1 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -125,7 +125,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
125 */ 125 */
126 if (pdata->init && pdata->init(pdev)) { 126 if (pdata->init && pdata->init(pdev)) {
127 retval = -ENODEV; 127 retval = -ENODEV;
128 goto err3; 128 goto err4;
129 } 129 }
130 130
131 /* Enable USB controller, 83xx or 8536 */ 131 /* Enable USB controller, 83xx or 8536 */
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index f4b627d343ac..01bb7241d6ef 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -276,6 +276,9 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
276 276
277 /* Serial Bus Release Number is at PCI 0x60 offset */ 277 /* Serial Bus Release Number is at PCI 0x60 offset */
278 pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 278 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
279 if (pdev->vendor == PCI_VENDOR_ID_STMICRO
280 && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST)
281 ehci->sbrn = 0x20; /* ConneXT has no sbrn register */
279 282
280 /* Keep this around for a while just in case some EHCI 283 /* Keep this around for a while just in case some EHCI
281 * implementation uses legacy PCI PM support. This test 284 * implementation uses legacy PCI PM support. This test
@@ -526,6 +529,9 @@ static const struct pci_device_id pci_ids [] = { {
526 /* handle any USB 2.0 EHCI controller */ 529 /* handle any USB 2.0 EHCI controller */
527 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), 530 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0),
528 .driver_data = (unsigned long) &ehci_pci_hc_driver, 531 .driver_data = (unsigned long) &ehci_pci_hc_driver,
532 }, {
533 PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST),
534 .driver_data = (unsigned long) &ehci_pci_hc_driver,
529 }, 535 },
530 { /* end: all zeroes */ } 536 { /* end: all zeroes */ }
531}; 537};
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 5179fcd73d8a..e4bcb62b930a 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -82,6 +82,14 @@ urb_print(struct urb * urb, char * str, int small, int status)
82 ohci_dbg(ohci,format, ## arg ); \ 82 ohci_dbg(ohci,format, ## arg ); \
83 } while (0); 83 } while (0);
84 84
85/* Version for use where "next" is the address of a local variable */
86#define ohci_dbg_nosw(ohci, next, size, format, arg...) \
87 do { \
88 unsigned s_len; \
89 s_len = scnprintf(*next, *size, format, ## arg); \
90 *size -= s_len; *next += s_len; \
91 } while (0);
92
85 93
86static void ohci_dump_intr_mask ( 94static void ohci_dump_intr_mask (
87 struct ohci_hcd *ohci, 95 struct ohci_hcd *ohci,
@@ -653,7 +661,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
653 661
654 /* dump driver info, then registers in spec order */ 662 /* dump driver info, then registers in spec order */
655 663
656 ohci_dbg_sw (ohci, &next, &size, 664 ohci_dbg_nosw(ohci, &next, &size,
657 "bus %s, device %s\n" 665 "bus %s, device %s\n"
658 "%s\n" 666 "%s\n"
659 "%s\n", 667 "%s\n",
@@ -672,7 +680,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
672 680
673 /* hcca */ 681 /* hcca */
674 if (ohci->hcca) 682 if (ohci->hcca)
675 ohci_dbg_sw (ohci, &next, &size, 683 ohci_dbg_nosw(ohci, &next, &size,
676 "hcca frame 0x%04x\n", ohci_frame_no(ohci)); 684 "hcca frame 0x%04x\n", ohci_frame_no(ohci));
677 685
678 /* other registers mostly affect frame timings */ 686 /* other registers mostly affect frame timings */
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 6109810cc2d3..1843bb68ac7c 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -397,6 +397,10 @@ static const struct pci_device_id pci_ids [] = { {
397 /* handle any USB OHCI controller */ 397 /* handle any USB OHCI controller */
398 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), 398 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0),
399 .driver_data = (unsigned long) &ohci_pci_hc_driver, 399 .driver_data = (unsigned long) &ohci_pci_hc_driver,
400 }, {
401 /* The device in the ConneXT I/O hub has no class reg */
402 PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_OHCI),
403 .driver_data = (unsigned long) &ohci_pci_hc_driver,
400 }, { /* end: all zeroes */ } 404 }, { /* end: all zeroes */ }
401}; 405};
402MODULE_DEVICE_TABLE (pci, pci_ids); 406MODULE_DEVICE_TABLE (pci, pci_ids);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index b90e1386418b..b62037bff688 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1204,6 +1204,7 @@ static void handle_vendor_event(struct xhci_hcd *xhci,
1204 * 1204 *
1205 * Returns a zero-based port number, which is suitable for indexing into each of 1205 * Returns a zero-based port number, which is suitable for indexing into each of
1206 * the split roothubs' port arrays and bus state arrays. 1206 * the split roothubs' port arrays and bus state arrays.
1207 * Add one to it in order to call xhci_find_slot_id_by_port.
1207 */ 1208 */
1208static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, 1209static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd,
1209 struct xhci_hcd *xhci, u32 port_id) 1210 struct xhci_hcd *xhci, u32 port_id)
@@ -1324,7 +1325,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1324 xhci_set_link_state(xhci, port_array, faked_port_index, 1325 xhci_set_link_state(xhci, port_array, faked_port_index,
1325 XDEV_U0); 1326 XDEV_U0);
1326 slot_id = xhci_find_slot_id_by_port(hcd, xhci, 1327 slot_id = xhci_find_slot_id_by_port(hcd, xhci,
1327 faked_port_index); 1328 faked_port_index + 1);
1328 if (!slot_id) { 1329 if (!slot_id) {
1329 xhci_dbg(xhci, "slot_id is zero\n"); 1330 xhci_dbg(xhci, "slot_id is zero\n");
1330 goto cleanup; 1331 goto cleanup;
@@ -3323,7 +3324,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3323 /* Check TD length */ 3324 /* Check TD length */
3324 if (running_total != td_len) { 3325 if (running_total != td_len) {
3325 xhci_err(xhci, "ISOC TD length unmatch\n"); 3326 xhci_err(xhci, "ISOC TD length unmatch\n");
3326 return -EINVAL; 3327 ret = -EINVAL;
3328 goto cleanup;
3327 } 3329 }
3328 } 3330 }
3329 3331
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index d9b6a0355443..da97dcec1f32 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -37,9 +37,6 @@ static int emi26_set_reset(struct usb_device *dev, unsigned char reset_bit);
37static int emi26_load_firmware (struct usb_device *dev); 37static int emi26_load_firmware (struct usb_device *dev);
38static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id); 38static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id);
39static void emi26_disconnect(struct usb_interface *intf); 39static void emi26_disconnect(struct usb_interface *intf);
40static int __init emi26_init (void);
41static void __exit emi26_exit (void);
42
43 40
44/* thanks to drivers/usb/serial/keyspan_pda.c code */ 41/* thanks to drivers/usb/serial/keyspan_pda.c code */
45static int emi26_writememory (struct usb_device *dev, int address, 42static int emi26_writememory (struct usb_device *dev, int address,
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index 9f39062ebb08..4e0f167a6c4e 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -46,9 +46,6 @@ static int emi62_set_reset(struct usb_device *dev, unsigned char reset_bit);
46static int emi62_load_firmware (struct usb_device *dev); 46static int emi62_load_firmware (struct usb_device *dev);
47static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id); 47static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id);
48static void emi62_disconnect(struct usb_interface *intf); 48static void emi62_disconnect(struct usb_interface *intf);
49static int __init emi62_init (void);
50static void __exit emi62_exit (void);
51
52 49
53/* thanks to drivers/usb/serial/keyspan_pda.c code */ 50/* thanks to drivers/usb/serial/keyspan_pda.c code */
54static int emi62_writememory(struct usb_device *dev, int address, 51static int emi62_writememory(struct usb_device *dev, int address,
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
index 107bf13b1cf1..b2d82b937392 100644
--- a/drivers/usb/misc/usbsevseg.c
+++ b/drivers/usb/misc/usbsevseg.c
@@ -24,7 +24,7 @@
24 24
25#define VENDOR_ID 0x0fc5 25#define VENDOR_ID 0x0fc5
26#define PRODUCT_ID 0x1227 26#define PRODUCT_ID 0x1227
27#define MAXLEN 6 27#define MAXLEN 8
28 28
29/* table of devices that work with this driver */ 29/* table of devices that work with this driver */
30static const struct usb_device_id id_table[] = { 30static const struct usb_device_id id_table[] = {
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index f9a3f62a83b5..7c569f51212a 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -33,9 +33,6 @@
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35 35
36#include <mach/hardware.h>
37#include <mach/memory.h>
38#include <asm/gpio.h>
39#include <mach/cputype.h> 36#include <mach/cputype.h>
40 37
41#include <asm/mach-types.h> 38#include <asm/mach-types.h>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 56cf0243979e..3d11cf64ebd1 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -981,6 +981,9 @@ static void musb_shutdown(struct platform_device *pdev)
981 unsigned long flags; 981 unsigned long flags;
982 982
983 pm_runtime_get_sync(musb->controller); 983 pm_runtime_get_sync(musb->controller);
984
985 musb_gadget_cleanup(musb);
986
984 spin_lock_irqsave(&musb->lock, flags); 987 spin_lock_irqsave(&musb->lock, flags);
985 musb_platform_disable(musb); 988 musb_platform_disable(musb);
986 musb_generic_disable(musb); 989 musb_generic_disable(musb);
@@ -1827,8 +1830,6 @@ static void musb_free(struct musb *musb)
1827 sysfs_remove_group(&musb->controller->kobj, &musb_attr_group); 1830 sysfs_remove_group(&musb->controller->kobj, &musb_attr_group);
1828#endif 1831#endif
1829 1832
1830 musb_gadget_cleanup(musb);
1831
1832 if (musb->nIrq >= 0) { 1833 if (musb->nIrq >= 0) {
1833 if (musb->irq_wake) 1834 if (musb->irq_wake)
1834 disable_irq_wake(musb->nIrq); 1835 disable_irq_wake(musb->nIrq);
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index c27bbbf32b52..df719eae3b03 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -222,7 +222,6 @@ static inline void omap2430_low_level_init(struct musb *musb)
222 musb_writel(musb->mregs, OTG_FORCESTDBY, l); 222 musb_writel(musb->mregs, OTG_FORCESTDBY, l);
223} 223}
224 224
225/* blocking notifier support */
226static int musb_otg_notifications(struct notifier_block *nb, 225static int musb_otg_notifications(struct notifier_block *nb,
227 unsigned long event, void *unused) 226 unsigned long event, void *unused)
228{ 227{
@@ -231,7 +230,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
231 musb->xceiv_event = event; 230 musb->xceiv_event = event;
232 schedule_work(&musb->otg_notifier_work); 231 schedule_work(&musb->otg_notifier_work);
233 232
234 return 0; 233 return NOTIFY_OK;
235} 234}
236 235
237static void musb_otg_notifier_work(struct work_struct *data_notifier_work) 236static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
@@ -386,6 +385,7 @@ static void omap2430_musb_disable(struct musb *musb)
386static int omap2430_musb_exit(struct musb *musb) 385static int omap2430_musb_exit(struct musb *musb)
387{ 386{
388 del_timer_sync(&musb_idle_timer); 387 del_timer_sync(&musb_idle_timer);
388 cancel_work_sync(&musb->otg_notifier_work);
389 389
390 omap2430_low_level_exit(musb); 390 omap2430_low_level_exit(musb);
391 otg_put_transceiver(musb->xceiv); 391 otg_put_transceiver(musb->xceiv);
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 2a25955881fc..76d629345418 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -86,20 +86,6 @@ config NOP_USB_XCEIV
86 built-in with usb ip or which are autonomous and doesn't require any 86 built-in with usb ip or which are autonomous and doesn't require any
87 phy programming such as ISP1x04 etc. 87 phy programming such as ISP1x04 etc.
88 88
89config USB_LANGWELL_OTG
90 tristate "Intel Langwell USB OTG dual-role support"
91 depends on USB && PCI && INTEL_SCU_IPC
92 select USB_OTG
93 select USB_OTG_UTILS
94 help
95 Say Y here if you want to build Intel Langwell USB OTG
96 transciever driver in kernel. This driver implements role
97 switch between EHCI host driver and Langwell USB OTG
98 client driver.
99
100 To compile this driver as a module, choose M here: the
101 module will be called langwell_otg.
102
103config USB_MSM_OTG 89config USB_MSM_OTG
104 tristate "OTG support for Qualcomm on-chip USB controller" 90 tristate "OTG support for Qualcomm on-chip USB controller"
105 depends on (USB || USB_GADGET) && ARCH_MSM 91 depends on (USB || USB_GADGET) && ARCH_MSM
@@ -124,7 +110,7 @@ config AB8500_USB
124 110
125config FSL_USB2_OTG 111config FSL_USB2_OTG
126 bool "Freescale USB OTG Transceiver Driver" 112 bool "Freescale USB OTG Transceiver Driver"
127 depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 113 depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 && USB_SUSPEND
128 select USB_OTG 114 select USB_OTG
129 select USB_OTG_UTILS 115 select USB_OTG_UTILS
130 help 116 help
@@ -132,7 +118,7 @@ config FSL_USB2_OTG
132 118
133config USB_MV_OTG 119config USB_MV_OTG
134 tristate "Marvell USB OTG support" 120 tristate "Marvell USB OTG support"
135 depends on USB_MV_UDC 121 depends on USB_MV_UDC && USB_SUSPEND
136 select USB_OTG 122 select USB_OTG
137 select USB_OTG_UTILS 123 select USB_OTG_UTILS
138 help 124 help
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index b2c5a9598637..41aa5098b139 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -13,7 +13,6 @@ obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o
13obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 13obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
14obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o 14obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o
15obj-$(CONFIG_TWL6030_USB) += twl6030-usb.o 15obj-$(CONFIG_TWL6030_USB) += twl6030-usb.o
16obj-$(CONFIG_USB_LANGWELL_OTG) += langwell_otg.o
17obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o 16obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o
18obj-$(CONFIG_USB_ULPI) += ulpi.o 17obj-$(CONFIG_USB_ULPI) += ulpi.o
19obj-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi_viewport.o 18obj-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi_viewport.o
diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
deleted file mode 100644
index f08f784086f7..000000000000
--- a/drivers/usb/otg/langwell_otg.c
+++ /dev/null
@@ -1,2347 +0,0 @@
1/*
2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008 - 2010, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19/* This driver helps to switch Langwell OTG controller function between host
20 * and peripheral. It works with EHCI driver and Langwell client controller
21 * driver together.
22 */
23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/pci.h>
26#include <linux/errno.h>
27#include <linux/interrupt.h>
28#include <linux/kernel.h>
29#include <linux/device.h>
30#include <linux/moduleparam.h>
31#include <linux/usb/ch9.h>
32#include <linux/usb/gadget.h>
33#include <linux/usb.h>
34#include <linux/usb/otg.h>
35#include <linux/usb/hcd.h>
36#include <linux/notifier.h>
37#include <linux/delay.h>
38#include <asm/intel_scu_ipc.h>
39
40#include <linux/usb/langwell_otg.h>
41
42#define DRIVER_DESC "Intel Langwell USB OTG transceiver driver"
43#define DRIVER_VERSION "July 10, 2010"
44
45MODULE_DESCRIPTION(DRIVER_DESC);
46MODULE_AUTHOR("Henry Yuan <hang.yuan@intel.com>, Hao Wu <hao.wu@intel.com>");
47MODULE_VERSION(DRIVER_VERSION);
48MODULE_LICENSE("GPL");
49
50static const char driver_name[] = "langwell_otg";
51
52static int langwell_otg_probe(struct pci_dev *pdev,
53 const struct pci_device_id *id);
54static void langwell_otg_remove(struct pci_dev *pdev);
55static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message);
56static int langwell_otg_resume(struct pci_dev *pdev);
57
58static int langwell_otg_set_host(struct otg_transceiver *otg,
59 struct usb_bus *host);
60static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
61 struct usb_gadget *gadget);
62static int langwell_otg_start_srp(struct otg_transceiver *otg);
63
64static const struct pci_device_id pci_ids[] = {{
65 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
66 .class_mask = ~0,
67 .vendor = 0x8086,
68 .device = 0x0811,
69 .subvendor = PCI_ANY_ID,
70 .subdevice = PCI_ANY_ID,
71}, { /* end: all zeroes */ }
72};
73
74static struct pci_driver otg_pci_driver = {
75 .name = (char *) driver_name,
76 .id_table = pci_ids,
77
78 .probe = langwell_otg_probe,
79 .remove = langwell_otg_remove,
80
81 .suspend = langwell_otg_suspend,
82 .resume = langwell_otg_resume,
83};
84
85/* HSM timers */
86static inline struct langwell_otg_timer *otg_timer_initializer
87(void (*function)(unsigned long), unsigned long expires, unsigned long data)
88{
89 struct langwell_otg_timer *timer;
90 timer = kmalloc(sizeof(struct langwell_otg_timer), GFP_KERNEL);
91 if (timer == NULL)
92 return timer;
93
94 timer->function = function;
95 timer->expires = expires;
96 timer->data = data;
97 return timer;
98}
99
100static struct langwell_otg_timer *a_wait_vrise_tmr, *a_aidl_bdis_tmr,
101 *b_se0_srp_tmr, *b_srp_init_tmr;
102
103static struct list_head active_timers;
104
105static struct langwell_otg *the_transceiver;
106
107/* host/client notify transceiver when event affects HNP state */
108void langwell_update_transceiver(void)
109{
110 struct langwell_otg *lnw = the_transceiver;
111
112 dev_dbg(lnw->dev, "transceiver is updated\n");
113
114 if (!lnw->qwork)
115 return ;
116
117 queue_work(lnw->qwork, &lnw->work);
118}
119EXPORT_SYMBOL(langwell_update_transceiver);
120
121static int langwell_otg_set_host(struct otg_transceiver *otg,
122 struct usb_bus *host)
123{
124 otg->host = host;
125
126 return 0;
127}
128
129static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
130 struct usb_gadget *gadget)
131{
132 otg->gadget = gadget;
133
134 return 0;
135}
136
137static int langwell_otg_set_power(struct otg_transceiver *otg,
138 unsigned mA)
139{
140 return 0;
141}
142
143/* A-device drives vbus, controlled through IPC commands */
144static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled)
145{
146 struct langwell_otg *lnw = the_transceiver;
147 u8 sub_id;
148
149 dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off");
150
151 if (enabled)
152 sub_id = 0x8; /* Turn on the VBus */
153 else
154 sub_id = 0x9; /* Turn off the VBus */
155
156 if (intel_scu_ipc_simple_command(0xef, sub_id)) {
157 dev_dbg(lnw->dev, "Failed to set Vbus via IPC commands\n");
158 return -EBUSY;
159 }
160
161 dev_dbg(lnw->dev, "%s --->\n", __func__);
162
163 return 0;
164}
165
166/* charge vbus or discharge vbus through a resistor to ground */
167static void langwell_otg_chrg_vbus(int on)
168{
169 struct langwell_otg *lnw = the_transceiver;
170 u32 val;
171
172 val = readl(lnw->iotg.base + CI_OTGSC);
173
174 if (on)
175 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VC,
176 lnw->iotg.base + CI_OTGSC);
177 else
178 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VD,
179 lnw->iotg.base + CI_OTGSC);
180}
181
182/* Start SRP */
183static int langwell_otg_start_srp(struct otg_transceiver *otg)
184{
185 struct langwell_otg *lnw = the_transceiver;
186 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
187 u32 val;
188
189 dev_dbg(lnw->dev, "%s --->\n", __func__);
190
191 val = readl(iotg->base + CI_OTGSC);
192
193 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HADP,
194 iotg->base + CI_OTGSC);
195
196 /* Check if the data plus is finished or not */
197 msleep(8);
198 val = readl(iotg->base + CI_OTGSC);
199 if (val & (OTGSC_HADP | OTGSC_DP))
200 dev_dbg(lnw->dev, "DataLine SRP Error\n");
201
202 /* Disable interrupt - b_sess_vld */
203 val = readl(iotg->base + CI_OTGSC);
204 val &= (~(OTGSC_BSVIE | OTGSC_BSEIE));
205 writel(val, iotg->base + CI_OTGSC);
206
207 /* Start VBus SRP, drive vbus to generate VBus pulse */
208 iotg->otg.set_vbus(&iotg->otg, true);
209 msleep(15);
210 iotg->otg.set_vbus(&iotg->otg, false);
211
212 /* Enable interrupt - b_sess_vld*/
213 val = readl(iotg->base + CI_OTGSC);
214 dev_dbg(lnw->dev, "after VBUS pulse otgsc = %x\n", val);
215
216 val |= (OTGSC_BSVIE | OTGSC_BSEIE);
217 writel(val, iotg->base + CI_OTGSC);
218
219 /* If Vbus is valid, then update the hsm */
220 if (val & OTGSC_BSV) {
221 dev_dbg(lnw->dev, "no b_sess_vld interrupt\n");
222
223 lnw->iotg.hsm.b_sess_vld = 1;
224 langwell_update_transceiver();
225 }
226
227 dev_dbg(lnw->dev, "%s <---\n", __func__);
228 return 0;
229}
230
231/* stop SOF via bus_suspend */
232static void langwell_otg_loc_sof(int on)
233{
234 struct langwell_otg *lnw = the_transceiver;
235 struct usb_hcd *hcd;
236 int err;
237
238 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "suspend" : "resume");
239
240 hcd = bus_to_hcd(lnw->iotg.otg.host);
241 if (on)
242 err = hcd->driver->bus_resume(hcd);
243 else
244 err = hcd->driver->bus_suspend(hcd);
245
246 if (err)
247 dev_dbg(lnw->dev, "Fail to resume/suspend USB bus - %d\n", err);
248
249 dev_dbg(lnw->dev, "%s <---\n", __func__);
250}
251
252static int langwell_otg_check_otgsc(void)
253{
254 struct langwell_otg *lnw = the_transceiver;
255 u32 otgsc, usbcfg;
256
257 dev_dbg(lnw->dev, "check sync OTGSC and USBCFG registers\n");
258
259 otgsc = readl(lnw->iotg.base + CI_OTGSC);
260 usbcfg = readl(lnw->usbcfg);
261
262 dev_dbg(lnw->dev, "OTGSC = %08x, USBCFG = %08x\n",
263 otgsc, usbcfg);
264 dev_dbg(lnw->dev, "OTGSC_AVV = %d\n", !!(otgsc & OTGSC_AVV));
265 dev_dbg(lnw->dev, "USBCFG.VBUSVAL = %d\n",
266 !!(usbcfg & USBCFG_VBUSVAL));
267 dev_dbg(lnw->dev, "OTGSC_ASV = %d\n", !!(otgsc & OTGSC_ASV));
268 dev_dbg(lnw->dev, "USBCFG.AVALID = %d\n",
269 !!(usbcfg & USBCFG_AVALID));
270 dev_dbg(lnw->dev, "OTGSC_BSV = %d\n", !!(otgsc & OTGSC_BSV));
271 dev_dbg(lnw->dev, "USBCFG.BVALID = %d\n",
272 !!(usbcfg & USBCFG_BVALID));
273 dev_dbg(lnw->dev, "OTGSC_BSE = %d\n", !!(otgsc & OTGSC_BSE));
274 dev_dbg(lnw->dev, "USBCFG.SESEND = %d\n",
275 !!(usbcfg & USBCFG_SESEND));
276
277 /* Check USBCFG VBusValid/AValid/BValid/SessEnd */
278 if (!!(otgsc & OTGSC_AVV) ^ !!(usbcfg & USBCFG_VBUSVAL)) {
279 dev_dbg(lnw->dev, "OTGSC.AVV != USBCFG.VBUSVAL\n");
280 goto err;
281 }
282 if (!!(otgsc & OTGSC_ASV) ^ !!(usbcfg & USBCFG_AVALID)) {
283 dev_dbg(lnw->dev, "OTGSC.ASV != USBCFG.AVALID\n");
284 goto err;
285 }
286 if (!!(otgsc & OTGSC_BSV) ^ !!(usbcfg & USBCFG_BVALID)) {
287 dev_dbg(lnw->dev, "OTGSC.BSV != USBCFG.BVALID\n");
288 goto err;
289 }
290 if (!!(otgsc & OTGSC_BSE) ^ !!(usbcfg & USBCFG_SESEND)) {
291 dev_dbg(lnw->dev, "OTGSC.BSE != USBCFG.SESSEN\n");
292 goto err;
293 }
294
295 dev_dbg(lnw->dev, "OTGSC and USBCFG are synced\n");
296
297 return 0;
298
299err:
300 dev_warn(lnw->dev, "OTGSC isn't equal to USBCFG\n");
301 return -EPIPE;
302}
303
304
305static void langwell_otg_phy_low_power(int on)
306{
307 struct langwell_otg *lnw = the_transceiver;
308 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
309 u8 val, phcd;
310 int retval;
311
312 dev_dbg(lnw->dev, "%s ---> %s mode\n",
313 __func__, on ? "Low power" : "Normal");
314
315 phcd = 0x40;
316
317 val = readb(iotg->base + CI_HOSTPC1 + 2);
318
319 if (on) {
320 /* Due to hardware issue, after set PHCD, sync will failed
321 * between USBCFG and OTGSC, so before set PHCD, check if
322 * sync is in process now. If the answer is "yes", then do
323 * not touch PHCD bit */
324 retval = langwell_otg_check_otgsc();
325 if (retval) {
326 dev_dbg(lnw->dev, "Skip PHCD programming..\n");
327 return ;
328 }
329
330 writeb(val | phcd, iotg->base + CI_HOSTPC1 + 2);
331 } else
332 writeb(val & ~phcd, iotg->base + CI_HOSTPC1 + 2);
333
334 dev_dbg(lnw->dev, "%s <--- done\n", __func__);
335}
336
337/* After drv vbus, add 5 ms delay to set PHCD */
338static void langwell_otg_phy_low_power_wait(int on)
339{
340 struct langwell_otg *lnw = the_transceiver;
341
342 dev_dbg(lnw->dev, "add 5ms delay before programing PHCD\n");
343
344 mdelay(5);
345 langwell_otg_phy_low_power(on);
346}
347
348/* Enable/Disable OTG interrupt */
349static void langwell_otg_intr(int on)
350{
351 struct langwell_otg *lnw = the_transceiver;
352 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
353 u32 val;
354
355 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
356
357 val = readl(iotg->base + CI_OTGSC);
358
359 /* OTGSC_INT_MASK doesn't contains 1msInt */
360 if (on) {
361 val = val | (OTGSC_INT_MASK);
362 writel(val, iotg->base + CI_OTGSC);
363 } else {
364 val = val & ~(OTGSC_INT_MASK);
365 writel(val, iotg->base + CI_OTGSC);
366 }
367
368 dev_dbg(lnw->dev, "%s <---\n", __func__);
369}
370
371/* set HAAR: Hardware Assist Auto-Reset */
372static void langwell_otg_HAAR(int on)
373{
374 struct langwell_otg *lnw = the_transceiver;
375 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
376 u32 val;
377
378 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
379
380 val = readl(iotg->base + CI_OTGSC);
381 if (on)
382 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HAAR,
383 iotg->base + CI_OTGSC);
384 else
385 writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HAAR,
386 iotg->base + CI_OTGSC);
387
388 dev_dbg(lnw->dev, "%s <---\n", __func__);
389}
390
391/* set HABA: Hardware Assist B-Disconnect to A-Connect */
392static void langwell_otg_HABA(int on)
393{
394 struct langwell_otg *lnw = the_transceiver;
395 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
396 u32 val;
397
398 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
399
400 val = readl(iotg->base + CI_OTGSC);
401 if (on)
402 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HABA,
403 iotg->base + CI_OTGSC);
404 else
405 writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HABA,
406 iotg->base + CI_OTGSC);
407
408 dev_dbg(lnw->dev, "%s <---\n", __func__);
409}
410
411static int langwell_otg_check_se0_srp(int on)
412{
413 struct langwell_otg *lnw = the_transceiver;
414 int delay_time = TB_SE0_SRP * 10;
415 u32 val;
416
417 dev_dbg(lnw->dev, "%s --->\n", __func__);
418
419 do {
420 udelay(100);
421 if (!delay_time--)
422 break;
423 val = readl(lnw->iotg.base + CI_PORTSC1);
424 val &= PORTSC_LS;
425 } while (!val);
426
427 dev_dbg(lnw->dev, "%s <---\n", __func__);
428 return val;
429}
430
431/* The timeout callback function to set time out bit */
432static void set_tmout(unsigned long indicator)
433{
434 *(int *)indicator = 1;
435}
436
437void langwell_otg_nsf_msg(unsigned long indicator)
438{
439 struct langwell_otg *lnw = the_transceiver;
440
441 switch (indicator) {
442 case 2:
443 case 4:
444 case 6:
445 case 7:
446 dev_warn(lnw->dev,
447 "OTG:NSF-%lu - deivce not responding\n", indicator);
448 break;
449 case 3:
450 dev_warn(lnw->dev,
451 "OTG:NSF-%lu - deivce not supported\n", indicator);
452 break;
453 default:
454 dev_warn(lnw->dev, "Do not have this kind of NSF\n");
455 break;
456 }
457}
458
459/* Initialize timers */
460static int langwell_otg_init_timers(struct otg_hsm *hsm)
461{
462 /* HSM used timers */
463 a_wait_vrise_tmr = otg_timer_initializer(&set_tmout, TA_WAIT_VRISE,
464 (unsigned long)&hsm->a_wait_vrise_tmout);
465 if (a_wait_vrise_tmr == NULL)
466 return -ENOMEM;
467 a_aidl_bdis_tmr = otg_timer_initializer(&set_tmout, TA_AIDL_BDIS,
468 (unsigned long)&hsm->a_aidl_bdis_tmout);
469 if (a_aidl_bdis_tmr == NULL)
470 return -ENOMEM;
471 b_se0_srp_tmr = otg_timer_initializer(&set_tmout, TB_SE0_SRP,
472 (unsigned long)&hsm->b_se0_srp);
473 if (b_se0_srp_tmr == NULL)
474 return -ENOMEM;
475 b_srp_init_tmr = otg_timer_initializer(&set_tmout, TB_SRP_INIT,
476 (unsigned long)&hsm->b_srp_init_tmout);
477 if (b_srp_init_tmr == NULL)
478 return -ENOMEM;
479
480 return 0;
481}
482
483/* Free timers */
484static void langwell_otg_free_timers(void)
485{
486 kfree(a_wait_vrise_tmr);
487 kfree(a_aidl_bdis_tmr);
488 kfree(b_se0_srp_tmr);
489 kfree(b_srp_init_tmr);
490}
491
492/* The timeout callback function to set time out bit */
493static void langwell_otg_timer_fn(unsigned long indicator)
494{
495 struct langwell_otg *lnw = the_transceiver;
496
497 *(int *)indicator = 1;
498
499 dev_dbg(lnw->dev, "kernel timer - timeout\n");
500
501 langwell_update_transceiver();
502}
503
504/* kernel timer used instead of HW based interrupt */
505static void langwell_otg_add_ktimer(enum langwell_otg_timer_type timers)
506{
507 struct langwell_otg *lnw = the_transceiver;
508 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
509 unsigned long j = jiffies;
510 unsigned long data, time;
511
512 switch (timers) {
513 case TA_WAIT_VRISE_TMR:
514 iotg->hsm.a_wait_vrise_tmout = 0;
515 data = (unsigned long)&iotg->hsm.a_wait_vrise_tmout;
516 time = TA_WAIT_VRISE;
517 break;
518 case TA_WAIT_BCON_TMR:
519 iotg->hsm.a_wait_bcon_tmout = 0;
520 data = (unsigned long)&iotg->hsm.a_wait_bcon_tmout;
521 time = TA_WAIT_BCON;
522 break;
523 case TA_AIDL_BDIS_TMR:
524 iotg->hsm.a_aidl_bdis_tmout = 0;
525 data = (unsigned long)&iotg->hsm.a_aidl_bdis_tmout;
526 time = TA_AIDL_BDIS;
527 break;
528 case TB_ASE0_BRST_TMR:
529 iotg->hsm.b_ase0_brst_tmout = 0;
530 data = (unsigned long)&iotg->hsm.b_ase0_brst_tmout;
531 time = TB_ASE0_BRST;
532 break;
533 case TB_SRP_INIT_TMR:
534 iotg->hsm.b_srp_init_tmout = 0;
535 data = (unsigned long)&iotg->hsm.b_srp_init_tmout;
536 time = TB_SRP_INIT;
537 break;
538 case TB_SRP_FAIL_TMR:
539 iotg->hsm.b_srp_fail_tmout = 0;
540 data = (unsigned long)&iotg->hsm.b_srp_fail_tmout;
541 time = TB_SRP_FAIL;
542 break;
543 case TB_BUS_SUSPEND_TMR:
544 iotg->hsm.b_bus_suspend_tmout = 0;
545 data = (unsigned long)&iotg->hsm.b_bus_suspend_tmout;
546 time = TB_BUS_SUSPEND;
547 break;
548 default:
549 dev_dbg(lnw->dev, "unknown timer, cannot enable it\n");
550 return;
551 }
552
553 lnw->hsm_timer.data = data;
554 lnw->hsm_timer.function = langwell_otg_timer_fn;
555 lnw->hsm_timer.expires = j + time * HZ / 1000; /* milliseconds */
556
557 add_timer(&lnw->hsm_timer);
558
559 dev_dbg(lnw->dev, "add timer successfully\n");
560}
561
562/* Add timer to timer list */
563static void langwell_otg_add_timer(void *gtimer)
564{
565 struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
566 struct langwell_otg_timer *tmp_timer;
567 struct intel_mid_otg_xceiv *iotg = &the_transceiver->iotg;
568 u32 val32;
569
570 /* Check if the timer is already in the active list,
571 * if so update timer count
572 */
573 list_for_each_entry(tmp_timer, &active_timers, list)
574 if (tmp_timer == timer) {
575 timer->count = timer->expires;
576 return;
577 }
578 timer->count = timer->expires;
579
580 if (list_empty(&active_timers)) {
581 val32 = readl(iotg->base + CI_OTGSC);
582 writel(val32 | OTGSC_1MSE, iotg->base + CI_OTGSC);
583 }
584
585 list_add_tail(&timer->list, &active_timers);
586}
587
588/* Remove timer from the timer list; clear timeout status */
589static void langwell_otg_del_timer(void *gtimer)
590{
591 struct langwell_otg *lnw = the_transceiver;
592 struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
593 struct langwell_otg_timer *tmp_timer, *del_tmp;
594 u32 val32;
595
596 list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list)
597 if (tmp_timer == timer)
598 list_del(&timer->list);
599
600 if (list_empty(&active_timers)) {
601 val32 = readl(lnw->iotg.base + CI_OTGSC);
602 writel(val32 & ~OTGSC_1MSE, lnw->iotg.base + CI_OTGSC);
603 }
604}
605
606/* Reduce timer count by 1, and find timeout conditions.*/
607static int langwell_otg_tick_timer(u32 *int_sts)
608{
609 struct langwell_otg *lnw = the_transceiver;
610 struct langwell_otg_timer *tmp_timer, *del_tmp;
611 int expired = 0;
612
613 list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list) {
614 tmp_timer->count--;
615 /* check if timer expires */
616 if (!tmp_timer->count) {
617 list_del(&tmp_timer->list);
618 tmp_timer->function(tmp_timer->data);
619 expired = 1;
620 }
621 }
622
623 if (list_empty(&active_timers)) {
624 dev_dbg(lnw->dev, "tick timer: disable 1ms int\n");
625 *int_sts = *int_sts & ~OTGSC_1MSE;
626 }
627 return expired;
628}
629
630static void reset_otg(void)
631{
632 struct langwell_otg *lnw = the_transceiver;
633 int delay_time = 1000;
634 u32 val;
635
636 dev_dbg(lnw->dev, "reseting OTG controller ...\n");
637 val = readl(lnw->iotg.base + CI_USBCMD);
638 writel(val | USBCMD_RST, lnw->iotg.base + CI_USBCMD);
639 do {
640 udelay(100);
641 if (!delay_time--)
642 dev_dbg(lnw->dev, "reset timeout\n");
643 val = readl(lnw->iotg.base + CI_USBCMD);
644 val &= USBCMD_RST;
645 } while (val != 0);
646 dev_dbg(lnw->dev, "reset done.\n");
647}
648
649static void set_host_mode(void)
650{
651 struct langwell_otg *lnw = the_transceiver;
652 u32 val;
653
654 reset_otg();
655 val = readl(lnw->iotg.base + CI_USBMODE);
656 val = (val & (~USBMODE_CM)) | USBMODE_HOST;
657 writel(val, lnw->iotg.base + CI_USBMODE);
658}
659
660static void set_client_mode(void)
661{
662 struct langwell_otg *lnw = the_transceiver;
663 u32 val;
664
665 reset_otg();
666 val = readl(lnw->iotg.base + CI_USBMODE);
667 val = (val & (~USBMODE_CM)) | USBMODE_DEVICE;
668 writel(val, lnw->iotg.base + CI_USBMODE);
669}
670
671static void init_hsm(void)
672{
673 struct langwell_otg *lnw = the_transceiver;
674 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
675 u32 val32;
676
677 /* read OTGSC after reset */
678 val32 = readl(lnw->iotg.base + CI_OTGSC);
679 dev_dbg(lnw->dev, "%s: OTGSC init value = 0x%x\n", __func__, val32);
680
681 /* set init state */
682 if (val32 & OTGSC_ID) {
683 iotg->hsm.id = 1;
684 iotg->otg.default_a = 0;
685 set_client_mode();
686 iotg->otg.state = OTG_STATE_B_IDLE;
687 } else {
688 iotg->hsm.id = 0;
689 iotg->otg.default_a = 1;
690 set_host_mode();
691 iotg->otg.state = OTG_STATE_A_IDLE;
692 }
693
694 /* set session indicator */
695 if (val32 & OTGSC_BSE)
696 iotg->hsm.b_sess_end = 1;
697 if (val32 & OTGSC_BSV)
698 iotg->hsm.b_sess_vld = 1;
699 if (val32 & OTGSC_ASV)
700 iotg->hsm.a_sess_vld = 1;
701 if (val32 & OTGSC_AVV)
702 iotg->hsm.a_vbus_vld = 1;
703
704 /* defautly power the bus */
705 iotg->hsm.a_bus_req = 1;
706 iotg->hsm.a_bus_drop = 0;
707 /* defautly don't request bus as B device */
708 iotg->hsm.b_bus_req = 0;
709 /* no system error */
710 iotg->hsm.a_clr_err = 0;
711
712 langwell_otg_phy_low_power_wait(1);
713}
714
715static void update_hsm(void)
716{
717 struct langwell_otg *lnw = the_transceiver;
718 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
719 u32 val32;
720
721 /* read OTGSC */
722 val32 = readl(lnw->iotg.base + CI_OTGSC);
723 dev_dbg(lnw->dev, "%s: OTGSC value = 0x%x\n", __func__, val32);
724
725 iotg->hsm.id = !!(val32 & OTGSC_ID);
726 iotg->hsm.b_sess_end = !!(val32 & OTGSC_BSE);
727 iotg->hsm.b_sess_vld = !!(val32 & OTGSC_BSV);
728 iotg->hsm.a_sess_vld = !!(val32 & OTGSC_ASV);
729 iotg->hsm.a_vbus_vld = !!(val32 & OTGSC_AVV);
730}
731
732static irqreturn_t otg_dummy_irq(int irq, void *_dev)
733{
734 struct langwell_otg *lnw = the_transceiver;
735 void __iomem *reg_base = _dev;
736 u32 val;
737 u32 int_mask = 0;
738
739 val = readl(reg_base + CI_USBMODE);
740 if ((val & USBMODE_CM) != USBMODE_DEVICE)
741 return IRQ_NONE;
742
743 val = readl(reg_base + CI_USBSTS);
744 int_mask = val & INTR_DUMMY_MASK;
745
746 if (int_mask == 0)
747 return IRQ_NONE;
748
749 /* clear hsm.b_conn here since host driver can't detect it
750 * otg_dummy_irq called means B-disconnect happened.
751 */
752 if (lnw->iotg.hsm.b_conn) {
753 lnw->iotg.hsm.b_conn = 0;
754 if (spin_trylock(&lnw->wq_lock)) {
755 langwell_update_transceiver();
756 spin_unlock(&lnw->wq_lock);
757 }
758 }
759
760 /* Clear interrupts */
761 writel(int_mask, reg_base + CI_USBSTS);
762 return IRQ_HANDLED;
763}
764
765static irqreturn_t otg_irq(int irq, void *_dev)
766{
767 struct langwell_otg *lnw = _dev;
768 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
769 u32 int_sts, int_en;
770 u32 int_mask = 0;
771 int flag = 0;
772
773 int_sts = readl(lnw->iotg.base + CI_OTGSC);
774 int_en = (int_sts & OTGSC_INTEN_MASK) >> 8;
775 int_mask = int_sts & int_en;
776 if (int_mask == 0)
777 return IRQ_NONE;
778
779 if (int_mask & OTGSC_IDIS) {
780 dev_dbg(lnw->dev, "%s: id change int\n", __func__);
781 iotg->hsm.id = (int_sts & OTGSC_ID) ? 1 : 0;
782 dev_dbg(lnw->dev, "id = %d\n", iotg->hsm.id);
783 flag = 1;
784 }
785 if (int_mask & OTGSC_DPIS) {
786 dev_dbg(lnw->dev, "%s: data pulse int\n", __func__);
787 iotg->hsm.a_srp_det = (int_sts & OTGSC_DPS) ? 1 : 0;
788 dev_dbg(lnw->dev, "data pulse = %d\n", iotg->hsm.a_srp_det);
789 flag = 1;
790 }
791 if (int_mask & OTGSC_BSEIS) {
792 dev_dbg(lnw->dev, "%s: b session end int\n", __func__);
793 iotg->hsm.b_sess_end = (int_sts & OTGSC_BSE) ? 1 : 0;
794 dev_dbg(lnw->dev, "b_sess_end = %d\n", iotg->hsm.b_sess_end);
795 flag = 1;
796 }
797 if (int_mask & OTGSC_BSVIS) {
798 dev_dbg(lnw->dev, "%s: b session valid int\n", __func__);
799 iotg->hsm.b_sess_vld = (int_sts & OTGSC_BSV) ? 1 : 0;
800 dev_dbg(lnw->dev, "b_sess_vld = %d\n", iotg->hsm.b_sess_end);
801 flag = 1;
802 }
803 if (int_mask & OTGSC_ASVIS) {
804 dev_dbg(lnw->dev, "%s: a session valid int\n", __func__);
805 iotg->hsm.a_sess_vld = (int_sts & OTGSC_ASV) ? 1 : 0;
806 dev_dbg(lnw->dev, "a_sess_vld = %d\n", iotg->hsm.a_sess_vld);
807 flag = 1;
808 }
809 if (int_mask & OTGSC_AVVIS) {
810 dev_dbg(lnw->dev, "%s: a vbus valid int\n", __func__);
811 iotg->hsm.a_vbus_vld = (int_sts & OTGSC_AVV) ? 1 : 0;
812 dev_dbg(lnw->dev, "a_vbus_vld = %d\n", iotg->hsm.a_vbus_vld);
813 flag = 1;
814 }
815
816 if (int_mask & OTGSC_1MSS) {
817 /* need to schedule otg_work if any timer is expired */
818 if (langwell_otg_tick_timer(&int_sts))
819 flag = 1;
820 }
821
822 writel((int_sts & ~OTGSC_INTSTS_MASK) | int_mask,
823 lnw->iotg.base + CI_OTGSC);
824 if (flag)
825 langwell_update_transceiver();
826
827 return IRQ_HANDLED;
828}
829
830static int langwell_otg_iotg_notify(struct notifier_block *nb,
831 unsigned long action, void *data)
832{
833 struct langwell_otg *lnw = the_transceiver;
834 struct intel_mid_otg_xceiv *iotg = data;
835 int flag = 0;
836
837 if (iotg == NULL)
838 return NOTIFY_BAD;
839
840 if (lnw == NULL)
841 return NOTIFY_BAD;
842
843 switch (action) {
844 case MID_OTG_NOTIFY_CONNECT:
845 dev_dbg(lnw->dev, "Lnw OTG Notify Connect Event\n");
846 if (iotg->otg.default_a == 1)
847 iotg->hsm.b_conn = 1;
848 else
849 iotg->hsm.a_conn = 1;
850 flag = 1;
851 break;
852 case MID_OTG_NOTIFY_DISCONN:
853 dev_dbg(lnw->dev, "Lnw OTG Notify Disconnect Event\n");
854 if (iotg->otg.default_a == 1)
855 iotg->hsm.b_conn = 0;
856 else
857 iotg->hsm.a_conn = 0;
858 flag = 1;
859 break;
860 case MID_OTG_NOTIFY_HSUSPEND:
861 dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus suspend Event\n");
862 if (iotg->otg.default_a == 1)
863 iotg->hsm.a_suspend_req = 1;
864 else
865 iotg->hsm.b_bus_req = 0;
866 flag = 1;
867 break;
868 case MID_OTG_NOTIFY_HRESUME:
869 dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus resume Event\n");
870 if (iotg->otg.default_a == 1)
871 iotg->hsm.b_bus_resume = 1;
872 flag = 1;
873 break;
874 case MID_OTG_NOTIFY_CSUSPEND:
875 dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus suspend Event\n");
876 if (iotg->otg.default_a == 1) {
877 if (iotg->hsm.b_bus_suspend_vld == 2) {
878 iotg->hsm.b_bus_suspend = 1;
879 iotg->hsm.b_bus_suspend_vld = 0;
880 flag = 1;
881 } else {
882 iotg->hsm.b_bus_suspend_vld++;
883 flag = 0;
884 }
885 } else {
886 if (iotg->hsm.a_bus_suspend == 0) {
887 iotg->hsm.a_bus_suspend = 1;
888 flag = 1;
889 }
890 }
891 break;
892 case MID_OTG_NOTIFY_CRESUME:
893 dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus resume Event\n");
894 if (iotg->otg.default_a == 0)
895 iotg->hsm.a_bus_suspend = 0;
896 flag = 0;
897 break;
898 case MID_OTG_NOTIFY_HOSTADD:
899 dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver Add\n");
900 flag = 1;
901 break;
902 case MID_OTG_NOTIFY_HOSTREMOVE:
903 dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver remove\n");
904 flag = 1;
905 break;
906 case MID_OTG_NOTIFY_CLIENTADD:
907 dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver Add\n");
908 flag = 1;
909 break;
910 case MID_OTG_NOTIFY_CLIENTREMOVE:
911 dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver remove\n");
912 flag = 1;
913 break;
914 default:
915 dev_dbg(lnw->dev, "Lnw OTG Nofity unknown notify message\n");
916 return NOTIFY_DONE;
917 }
918
919 if (flag)
920 langwell_update_transceiver();
921
922 return NOTIFY_OK;
923}
924
925static void langwell_otg_work(struct work_struct *work)
926{
927 struct langwell_otg *lnw;
928 struct intel_mid_otg_xceiv *iotg;
929 int retval;
930 struct pci_dev *pdev;
931
932 lnw = container_of(work, struct langwell_otg, work);
933 iotg = &lnw->iotg;
934 pdev = to_pci_dev(lnw->dev);
935
936 dev_dbg(lnw->dev, "%s: old state = %s\n", __func__,
937 otg_state_string(iotg->otg.state));
938
939 switch (iotg->otg.state) {
940 case OTG_STATE_UNDEFINED:
941 case OTG_STATE_B_IDLE:
942 if (!iotg->hsm.id) {
943 langwell_otg_del_timer(b_srp_init_tmr);
944 del_timer_sync(&lnw->hsm_timer);
945
946 iotg->otg.default_a = 1;
947 iotg->hsm.a_srp_det = 0;
948
949 langwell_otg_chrg_vbus(0);
950 set_host_mode();
951 langwell_otg_phy_low_power(1);
952
953 iotg->otg.state = OTG_STATE_A_IDLE;
954 langwell_update_transceiver();
955 } else if (iotg->hsm.b_sess_vld) {
956 langwell_otg_del_timer(b_srp_init_tmr);
957 del_timer_sync(&lnw->hsm_timer);
958 iotg->hsm.b_sess_end = 0;
959 iotg->hsm.a_bus_suspend = 0;
960 langwell_otg_chrg_vbus(0);
961
962 if (lnw->iotg.start_peripheral) {
963 lnw->iotg.start_peripheral(&lnw->iotg);
964 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
965 } else
966 dev_dbg(lnw->dev, "client driver not loaded\n");
967
968 } else if (iotg->hsm.b_srp_init_tmout) {
969 iotg->hsm.b_srp_init_tmout = 0;
970 dev_warn(lnw->dev, "SRP init timeout\n");
971 } else if (iotg->hsm.b_srp_fail_tmout) {
972 iotg->hsm.b_srp_fail_tmout = 0;
973 iotg->hsm.b_bus_req = 0;
974
975 /* No silence failure */
976 langwell_otg_nsf_msg(6);
977 } else if (iotg->hsm.b_bus_req && iotg->hsm.b_sess_end) {
978 del_timer_sync(&lnw->hsm_timer);
979 /* workaround for b_se0_srp detection */
980 retval = langwell_otg_check_se0_srp(0);
981 if (retval) {
982 iotg->hsm.b_bus_req = 0;
983 dev_dbg(lnw->dev, "LS isn't SE0, try later\n");
984 } else {
985 /* clear the PHCD before start srp */
986 langwell_otg_phy_low_power(0);
987
988 /* Start SRP */
989 langwell_otg_add_timer(b_srp_init_tmr);
990 iotg->otg.start_srp(&iotg->otg);
991 langwell_otg_del_timer(b_srp_init_tmr);
992 langwell_otg_add_ktimer(TB_SRP_FAIL_TMR);
993
994 /* reset PHY low power mode here */
995 langwell_otg_phy_low_power_wait(1);
996 }
997 }
998 break;
999 case OTG_STATE_B_SRP_INIT:
1000 if (!iotg->hsm.id) {
1001 iotg->otg.default_a = 1;
1002 iotg->hsm.a_srp_det = 0;
1003
1004 /* Turn off VBus */
1005 iotg->otg.set_vbus(&iotg->otg, false);
1006 langwell_otg_chrg_vbus(0);
1007 set_host_mode();
1008 langwell_otg_phy_low_power(1);
1009 iotg->otg.state = OTG_STATE_A_IDLE;
1010 langwell_update_transceiver();
1011 } else if (iotg->hsm.b_sess_vld) {
1012 langwell_otg_chrg_vbus(0);
1013 if (lnw->iotg.start_peripheral) {
1014 lnw->iotg.start_peripheral(&lnw->iotg);
1015 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1016 } else
1017 dev_dbg(lnw->dev, "client driver not loaded\n");
1018 }
1019 break;
1020 case OTG_STATE_B_PERIPHERAL:
1021 if (!iotg->hsm.id) {
1022 iotg->otg.default_a = 1;
1023 iotg->hsm.a_srp_det = 0;
1024
1025 langwell_otg_chrg_vbus(0);
1026
1027 if (lnw->iotg.stop_peripheral)
1028 lnw->iotg.stop_peripheral(&lnw->iotg);
1029 else
1030 dev_dbg(lnw->dev,
1031 "client driver has been removed.\n");
1032
1033 set_host_mode();
1034 langwell_otg_phy_low_power(1);
1035 iotg->otg.state = OTG_STATE_A_IDLE;
1036 langwell_update_transceiver();
1037 } else if (!iotg->hsm.b_sess_vld) {
1038 iotg->hsm.b_hnp_enable = 0;
1039
1040 if (lnw->iotg.stop_peripheral)
1041 lnw->iotg.stop_peripheral(&lnw->iotg);
1042 else
1043 dev_dbg(lnw->dev,
1044 "client driver has been removed.\n");
1045
1046 iotg->otg.state = OTG_STATE_B_IDLE;
1047 } else if (iotg->hsm.b_bus_req && iotg->otg.gadget &&
1048 iotg->otg.gadget->b_hnp_enable &&
1049 iotg->hsm.a_bus_suspend) {
1050
1051 if (lnw->iotg.stop_peripheral)
1052 lnw->iotg.stop_peripheral(&lnw->iotg);
1053 else
1054 dev_dbg(lnw->dev,
1055 "client driver has been removed.\n");
1056
1057 langwell_otg_HAAR(1);
1058 iotg->hsm.a_conn = 0;
1059
1060 if (lnw->iotg.start_host) {
1061 lnw->iotg.start_host(&lnw->iotg);
1062 iotg->otg.state = OTG_STATE_B_WAIT_ACON;
1063 } else
1064 dev_dbg(lnw->dev,
1065 "host driver not loaded.\n");
1066
1067 iotg->hsm.a_bus_resume = 0;
1068 langwell_otg_add_ktimer(TB_ASE0_BRST_TMR);
1069 }
1070 break;
1071
1072 case OTG_STATE_B_WAIT_ACON:
1073 if (!iotg->hsm.id) {
1074 /* delete hsm timer for b_ase0_brst_tmr */
1075 del_timer_sync(&lnw->hsm_timer);
1076
1077 iotg->otg.default_a = 1;
1078 iotg->hsm.a_srp_det = 0;
1079
1080 langwell_otg_chrg_vbus(0);
1081
1082 langwell_otg_HAAR(0);
1083 if (lnw->iotg.stop_host)
1084 lnw->iotg.stop_host(&lnw->iotg);
1085 else
1086 dev_dbg(lnw->dev,
1087 "host driver has been removed.\n");
1088
1089 set_host_mode();
1090 langwell_otg_phy_low_power(1);
1091 iotg->otg.state = OTG_STATE_A_IDLE;
1092 langwell_update_transceiver();
1093 } else if (!iotg->hsm.b_sess_vld) {
1094 /* delete hsm timer for b_ase0_brst_tmr */
1095 del_timer_sync(&lnw->hsm_timer);
1096
1097 iotg->hsm.b_hnp_enable = 0;
1098 iotg->hsm.b_bus_req = 0;
1099
1100 langwell_otg_chrg_vbus(0);
1101 langwell_otg_HAAR(0);
1102
1103 if (lnw->iotg.stop_host)
1104 lnw->iotg.stop_host(&lnw->iotg);
1105 else
1106 dev_dbg(lnw->dev,
1107 "host driver has been removed.\n");
1108
1109 set_client_mode();
1110 langwell_otg_phy_low_power(1);
1111 iotg->otg.state = OTG_STATE_B_IDLE;
1112 } else if (iotg->hsm.a_conn) {
1113 /* delete hsm timer for b_ase0_brst_tmr */
1114 del_timer_sync(&lnw->hsm_timer);
1115
1116 langwell_otg_HAAR(0);
1117 iotg->otg.state = OTG_STATE_B_HOST;
1118 langwell_update_transceiver();
1119 } else if (iotg->hsm.a_bus_resume ||
1120 iotg->hsm.b_ase0_brst_tmout) {
1121 /* delete hsm timer for b_ase0_brst_tmr */
1122 del_timer_sync(&lnw->hsm_timer);
1123
1124 langwell_otg_HAAR(0);
1125 langwell_otg_nsf_msg(7);
1126
1127 if (lnw->iotg.stop_host)
1128 lnw->iotg.stop_host(&lnw->iotg);
1129 else
1130 dev_dbg(lnw->dev,
1131 "host driver has been removed.\n");
1132
1133 iotg->hsm.a_bus_suspend = 0;
1134 iotg->hsm.b_bus_req = 0;
1135
1136 if (lnw->iotg.start_peripheral)
1137 lnw->iotg.start_peripheral(&lnw->iotg);
1138 else
1139 dev_dbg(lnw->dev,
1140 "client driver not loaded.\n");
1141
1142 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1143 }
1144 break;
1145
1146 case OTG_STATE_B_HOST:
1147 if (!iotg->hsm.id) {
1148 iotg->otg.default_a = 1;
1149 iotg->hsm.a_srp_det = 0;
1150
1151 langwell_otg_chrg_vbus(0);
1152
1153 if (lnw->iotg.stop_host)
1154 lnw->iotg.stop_host(&lnw->iotg);
1155 else
1156 dev_dbg(lnw->dev,
1157 "host driver has been removed.\n");
1158
1159 set_host_mode();
1160 langwell_otg_phy_low_power(1);
1161 iotg->otg.state = OTG_STATE_A_IDLE;
1162 langwell_update_transceiver();
1163 } else if (!iotg->hsm.b_sess_vld) {
1164 iotg->hsm.b_hnp_enable = 0;
1165 iotg->hsm.b_bus_req = 0;
1166
1167 langwell_otg_chrg_vbus(0);
1168 if (lnw->iotg.stop_host)
1169 lnw->iotg.stop_host(&lnw->iotg);
1170 else
1171 dev_dbg(lnw->dev,
1172 "host driver has been removed.\n");
1173
1174 set_client_mode();
1175 langwell_otg_phy_low_power(1);
1176 iotg->otg.state = OTG_STATE_B_IDLE;
1177 } else if ((!iotg->hsm.b_bus_req) ||
1178 (!iotg->hsm.a_conn)) {
1179 iotg->hsm.b_bus_req = 0;
1180 langwell_otg_loc_sof(0);
1181
1182 if (lnw->iotg.stop_host)
1183 lnw->iotg.stop_host(&lnw->iotg);
1184 else
1185 dev_dbg(lnw->dev,
1186 "host driver has been removed.\n");
1187
1188 iotg->hsm.a_bus_suspend = 0;
1189
1190 if (lnw->iotg.start_peripheral)
1191 lnw->iotg.start_peripheral(&lnw->iotg);
1192 else
1193 dev_dbg(lnw->dev,
1194 "client driver not loaded.\n");
1195
1196 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1197 }
1198 break;
1199
1200 case OTG_STATE_A_IDLE:
1201 iotg->otg.default_a = 1;
1202 if (iotg->hsm.id) {
1203 iotg->otg.default_a = 0;
1204 iotg->hsm.b_bus_req = 0;
1205 iotg->hsm.vbus_srp_up = 0;
1206
1207 langwell_otg_chrg_vbus(0);
1208 set_client_mode();
1209 langwell_otg_phy_low_power(1);
1210 iotg->otg.state = OTG_STATE_B_IDLE;
1211 langwell_update_transceiver();
1212 } else if (!iotg->hsm.a_bus_drop &&
1213 (iotg->hsm.a_srp_det || iotg->hsm.a_bus_req)) {
1214 langwell_otg_phy_low_power(0);
1215
1216 /* Turn on VBus */
1217 iotg->otg.set_vbus(&iotg->otg, true);
1218
1219 iotg->hsm.vbus_srp_up = 0;
1220 iotg->hsm.a_wait_vrise_tmout = 0;
1221 langwell_otg_add_timer(a_wait_vrise_tmr);
1222 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1223 langwell_update_transceiver();
1224 } else if (!iotg->hsm.a_bus_drop && iotg->hsm.a_sess_vld) {
1225 iotg->hsm.vbus_srp_up = 1;
1226 } else if (!iotg->hsm.a_sess_vld && iotg->hsm.vbus_srp_up) {
1227 msleep(10);
1228 langwell_otg_phy_low_power(0);
1229
1230 /* Turn on VBus */
1231 iotg->otg.set_vbus(&iotg->otg, true);
1232 iotg->hsm.a_srp_det = 1;
1233 iotg->hsm.vbus_srp_up = 0;
1234 iotg->hsm.a_wait_vrise_tmout = 0;
1235 langwell_otg_add_timer(a_wait_vrise_tmr);
1236 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1237 langwell_update_transceiver();
1238 } else if (!iotg->hsm.a_sess_vld &&
1239 !iotg->hsm.vbus_srp_up) {
1240 langwell_otg_phy_low_power(1);
1241 }
1242 break;
1243 case OTG_STATE_A_WAIT_VRISE:
1244 if (iotg->hsm.id) {
1245 langwell_otg_del_timer(a_wait_vrise_tmr);
1246 iotg->hsm.b_bus_req = 0;
1247 iotg->otg.default_a = 0;
1248
1249 /* Turn off VBus */
1250 iotg->otg.set_vbus(&iotg->otg, false);
1251 set_client_mode();
1252 langwell_otg_phy_low_power_wait(1);
1253 iotg->otg.state = OTG_STATE_B_IDLE;
1254 } else if (iotg->hsm.a_vbus_vld) {
1255 langwell_otg_del_timer(a_wait_vrise_tmr);
1256 iotg->hsm.b_conn = 0;
1257 if (lnw->iotg.start_host)
1258 lnw->iotg.start_host(&lnw->iotg);
1259 else {
1260 dev_dbg(lnw->dev, "host driver not loaded.\n");
1261 break;
1262 }
1263
1264 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1265 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1266 } else if (iotg->hsm.a_wait_vrise_tmout) {
1267 iotg->hsm.b_conn = 0;
1268 if (iotg->hsm.a_vbus_vld) {
1269 if (lnw->iotg.start_host)
1270 lnw->iotg.start_host(&lnw->iotg);
1271 else {
1272 dev_dbg(lnw->dev,
1273 "host driver not loaded.\n");
1274 break;
1275 }
1276 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1277 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1278 } else {
1279
1280 /* Turn off VBus */
1281 iotg->otg.set_vbus(&iotg->otg, false);
1282 langwell_otg_phy_low_power_wait(1);
1283 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1284 }
1285 }
1286 break;
1287 case OTG_STATE_A_WAIT_BCON:
1288 if (iotg->hsm.id) {
1289 /* delete hsm timer for a_wait_bcon_tmr */
1290 del_timer_sync(&lnw->hsm_timer);
1291
1292 iotg->otg.default_a = 0;
1293 iotg->hsm.b_bus_req = 0;
1294
1295 if (lnw->iotg.stop_host)
1296 lnw->iotg.stop_host(&lnw->iotg);
1297 else
1298 dev_dbg(lnw->dev,
1299 "host driver has been removed.\n");
1300
1301 /* Turn off VBus */
1302 iotg->otg.set_vbus(&iotg->otg, false);
1303 set_client_mode();
1304 langwell_otg_phy_low_power_wait(1);
1305 iotg->otg.state = OTG_STATE_B_IDLE;
1306 langwell_update_transceiver();
1307 } else if (!iotg->hsm.a_vbus_vld) {
1308 /* delete hsm timer for a_wait_bcon_tmr */
1309 del_timer_sync(&lnw->hsm_timer);
1310
1311 if (lnw->iotg.stop_host)
1312 lnw->iotg.stop_host(&lnw->iotg);
1313 else
1314 dev_dbg(lnw->dev,
1315 "host driver has been removed.\n");
1316
1317 /* Turn off VBus */
1318 iotg->otg.set_vbus(&iotg->otg, false);
1319 langwell_otg_phy_low_power_wait(1);
1320 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1321 } else if (iotg->hsm.a_bus_drop ||
1322 (iotg->hsm.a_wait_bcon_tmout &&
1323 !iotg->hsm.a_bus_req)) {
1324 /* delete hsm timer for a_wait_bcon_tmr */
1325 del_timer_sync(&lnw->hsm_timer);
1326
1327 if (lnw->iotg.stop_host)
1328 lnw->iotg.stop_host(&lnw->iotg);
1329 else
1330 dev_dbg(lnw->dev,
1331 "host driver has been removed.\n");
1332
1333 /* Turn off VBus */
1334 iotg->otg.set_vbus(&iotg->otg, false);
1335 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1336 } else if (iotg->hsm.b_conn) {
1337 /* delete hsm timer for a_wait_bcon_tmr */
1338 del_timer_sync(&lnw->hsm_timer);
1339
1340 iotg->hsm.a_suspend_req = 0;
1341 iotg->otg.state = OTG_STATE_A_HOST;
1342 if (iotg->hsm.a_srp_det && iotg->otg.host &&
1343 !iotg->otg.host->b_hnp_enable) {
1344 /* SRP capable peripheral-only device */
1345 iotg->hsm.a_bus_req = 1;
1346 iotg->hsm.a_srp_det = 0;
1347 } else if (!iotg->hsm.a_bus_req && iotg->otg.host &&
1348 iotg->otg.host->b_hnp_enable) {
1349 /* It is not safe enough to do a fast
1350 * transition from A_WAIT_BCON to
1351 * A_SUSPEND */
1352 msleep(10000);
1353 if (iotg->hsm.a_bus_req)
1354 break;
1355
1356 if (request_irq(pdev->irq,
1357 otg_dummy_irq, IRQF_SHARED,
1358 driver_name, iotg->base) != 0) {
1359 dev_dbg(lnw->dev,
1360 "request interrupt %d fail\n",
1361 pdev->irq);
1362 }
1363
1364 langwell_otg_HABA(1);
1365 iotg->hsm.b_bus_resume = 0;
1366 iotg->hsm.a_aidl_bdis_tmout = 0;
1367
1368 langwell_otg_loc_sof(0);
1369 /* clear PHCD to enable HW timer */
1370 langwell_otg_phy_low_power(0);
1371 langwell_otg_add_timer(a_aidl_bdis_tmr);
1372 iotg->otg.state = OTG_STATE_A_SUSPEND;
1373 } else if (!iotg->hsm.a_bus_req && iotg->otg.host &&
1374 !iotg->otg.host->b_hnp_enable) {
1375 if (lnw->iotg.stop_host)
1376 lnw->iotg.stop_host(&lnw->iotg);
1377 else
1378 dev_dbg(lnw->dev,
1379 "host driver removed.\n");
1380
1381 /* Turn off VBus */
1382 iotg->otg.set_vbus(&iotg->otg, false);
1383 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1384 }
1385 }
1386 break;
1387 case OTG_STATE_A_HOST:
1388 if (iotg->hsm.id) {
1389 iotg->otg.default_a = 0;
1390 iotg->hsm.b_bus_req = 0;
1391
1392 if (lnw->iotg.stop_host)
1393 lnw->iotg.stop_host(&lnw->iotg);
1394 else
1395 dev_dbg(lnw->dev,
1396 "host driver has been removed.\n");
1397
1398 /* Turn off VBus */
1399 iotg->otg.set_vbus(&iotg->otg, false);
1400 set_client_mode();
1401 langwell_otg_phy_low_power_wait(1);
1402 iotg->otg.state = OTG_STATE_B_IDLE;
1403 langwell_update_transceiver();
1404 } else if (iotg->hsm.a_bus_drop ||
1405 (iotg->otg.host &&
1406 !iotg->otg.host->b_hnp_enable &&
1407 !iotg->hsm.a_bus_req)) {
1408 if (lnw->iotg.stop_host)
1409 lnw->iotg.stop_host(&lnw->iotg);
1410 else
1411 dev_dbg(lnw->dev,
1412 "host driver has been removed.\n");
1413
1414 /* Turn off VBus */
1415 iotg->otg.set_vbus(&iotg->otg, false);
1416 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1417 } else if (!iotg->hsm.a_vbus_vld) {
1418 if (lnw->iotg.stop_host)
1419 lnw->iotg.stop_host(&lnw->iotg);
1420 else
1421 dev_dbg(lnw->dev,
1422 "host driver has been removed.\n");
1423
1424 /* Turn off VBus */
1425 iotg->otg.set_vbus(&iotg->otg, false);
1426 langwell_otg_phy_low_power_wait(1);
1427 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1428 } else if (iotg->otg.host &&
1429 iotg->otg.host->b_hnp_enable &&
1430 !iotg->hsm.a_bus_req) {
1431 /* Set HABA to enable hardware assistance to signal
1432 * A-connect after receiver B-disconnect. Hardware
1433 * will then set client mode and enable URE, SLE and
1434 * PCE after the assistance. otg_dummy_irq is used to
1435 * clean these ints when client driver is not resumed.
1436 */
1437 if (request_irq(pdev->irq, otg_dummy_irq, IRQF_SHARED,
1438 driver_name, iotg->base) != 0) {
1439 dev_dbg(lnw->dev,
1440 "request interrupt %d failed\n",
1441 pdev->irq);
1442 }
1443
1444 /* set HABA */
1445 langwell_otg_HABA(1);
1446 iotg->hsm.b_bus_resume = 0;
1447 iotg->hsm.a_aidl_bdis_tmout = 0;
1448 langwell_otg_loc_sof(0);
1449 /* clear PHCD to enable HW timer */
1450 langwell_otg_phy_low_power(0);
1451 langwell_otg_add_timer(a_aidl_bdis_tmr);
1452 iotg->otg.state = OTG_STATE_A_SUSPEND;
1453 } else if (!iotg->hsm.b_conn || !iotg->hsm.a_bus_req) {
1454 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1455 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1456 }
1457 break;
1458 case OTG_STATE_A_SUSPEND:
1459 if (iotg->hsm.id) {
1460 langwell_otg_del_timer(a_aidl_bdis_tmr);
1461 langwell_otg_HABA(0);
1462 free_irq(pdev->irq, iotg->base);
1463 iotg->otg.default_a = 0;
1464 iotg->hsm.b_bus_req = 0;
1465
1466 if (lnw->iotg.stop_host)
1467 lnw->iotg.stop_host(&lnw->iotg);
1468 else
1469 dev_dbg(lnw->dev,
1470 "host driver has been removed.\n");
1471
1472 /* Turn off VBus */
1473 iotg->otg.set_vbus(&iotg->otg, false);
1474 set_client_mode();
1475 langwell_otg_phy_low_power(1);
1476 iotg->otg.state = OTG_STATE_B_IDLE;
1477 langwell_update_transceiver();
1478 } else if (iotg->hsm.a_bus_req ||
1479 iotg->hsm.b_bus_resume) {
1480 langwell_otg_del_timer(a_aidl_bdis_tmr);
1481 langwell_otg_HABA(0);
1482 free_irq(pdev->irq, iotg->base);
1483 iotg->hsm.a_suspend_req = 0;
1484 langwell_otg_loc_sof(1);
1485 iotg->otg.state = OTG_STATE_A_HOST;
1486 } else if (iotg->hsm.a_aidl_bdis_tmout ||
1487 iotg->hsm.a_bus_drop) {
1488 langwell_otg_del_timer(a_aidl_bdis_tmr);
1489 langwell_otg_HABA(0);
1490 free_irq(pdev->irq, iotg->base);
1491 if (lnw->iotg.stop_host)
1492 lnw->iotg.stop_host(&lnw->iotg);
1493 else
1494 dev_dbg(lnw->dev,
1495 "host driver has been removed.\n");
1496
1497 /* Turn off VBus */
1498 iotg->otg.set_vbus(&iotg->otg, false);
1499 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1500 } else if (!iotg->hsm.b_conn && iotg->otg.host &&
1501 iotg->otg.host->b_hnp_enable) {
1502 langwell_otg_del_timer(a_aidl_bdis_tmr);
1503 langwell_otg_HABA(0);
1504 free_irq(pdev->irq, iotg->base);
1505
1506 if (lnw->iotg.stop_host)
1507 lnw->iotg.stop_host(&lnw->iotg);
1508 else
1509 dev_dbg(lnw->dev,
1510 "host driver has been removed.\n");
1511
1512 iotg->hsm.b_bus_suspend = 0;
1513 iotg->hsm.b_bus_suspend_vld = 0;
1514
1515 /* msleep(200); */
1516 if (lnw->iotg.start_peripheral)
1517 lnw->iotg.start_peripheral(&lnw->iotg);
1518 else
1519 dev_dbg(lnw->dev,
1520 "client driver not loaded.\n");
1521
1522 langwell_otg_add_ktimer(TB_BUS_SUSPEND_TMR);
1523 iotg->otg.state = OTG_STATE_A_PERIPHERAL;
1524 break;
1525 } else if (!iotg->hsm.a_vbus_vld) {
1526 langwell_otg_del_timer(a_aidl_bdis_tmr);
1527 langwell_otg_HABA(0);
1528 free_irq(pdev->irq, iotg->base);
1529 if (lnw->iotg.stop_host)
1530 lnw->iotg.stop_host(&lnw->iotg);
1531 else
1532 dev_dbg(lnw->dev,
1533 "host driver has been removed.\n");
1534
1535 /* Turn off VBus */
1536 iotg->otg.set_vbus(&iotg->otg, false);
1537 langwell_otg_phy_low_power_wait(1);
1538 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1539 }
1540 break;
1541 case OTG_STATE_A_PERIPHERAL:
1542 if (iotg->hsm.id) {
1543 /* delete hsm timer for b_bus_suspend_tmr */
1544 del_timer_sync(&lnw->hsm_timer);
1545 iotg->otg.default_a = 0;
1546 iotg->hsm.b_bus_req = 0;
1547 if (lnw->iotg.stop_peripheral)
1548 lnw->iotg.stop_peripheral(&lnw->iotg);
1549 else
1550 dev_dbg(lnw->dev,
1551 "client driver has been removed.\n");
1552
1553 /* Turn off VBus */
1554 iotg->otg.set_vbus(&iotg->otg, false);
1555 set_client_mode();
1556 langwell_otg_phy_low_power_wait(1);
1557 iotg->otg.state = OTG_STATE_B_IDLE;
1558 langwell_update_transceiver();
1559 } else if (!iotg->hsm.a_vbus_vld) {
1560 /* delete hsm timer for b_bus_suspend_tmr */
1561 del_timer_sync(&lnw->hsm_timer);
1562
1563 if (lnw->iotg.stop_peripheral)
1564 lnw->iotg.stop_peripheral(&lnw->iotg);
1565 else
1566 dev_dbg(lnw->dev,
1567 "client driver has been removed.\n");
1568
1569 /* Turn off VBus */
1570 iotg->otg.set_vbus(&iotg->otg, false);
1571 langwell_otg_phy_low_power_wait(1);
1572 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1573 } else if (iotg->hsm.a_bus_drop) {
1574 /* delete hsm timer for b_bus_suspend_tmr */
1575 del_timer_sync(&lnw->hsm_timer);
1576
1577 if (lnw->iotg.stop_peripheral)
1578 lnw->iotg.stop_peripheral(&lnw->iotg);
1579 else
1580 dev_dbg(lnw->dev,
1581 "client driver has been removed.\n");
1582
1583 /* Turn off VBus */
1584 iotg->otg.set_vbus(&iotg->otg, false);
1585 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1586 } else if (iotg->hsm.b_bus_suspend) {
1587 /* delete hsm timer for b_bus_suspend_tmr */
1588 del_timer_sync(&lnw->hsm_timer);
1589
1590 if (lnw->iotg.stop_peripheral)
1591 lnw->iotg.stop_peripheral(&lnw->iotg);
1592 else
1593 dev_dbg(lnw->dev,
1594 "client driver has been removed.\n");
1595
1596 if (lnw->iotg.start_host)
1597 lnw->iotg.start_host(&lnw->iotg);
1598 else
1599 dev_dbg(lnw->dev,
1600 "host driver not loaded.\n");
1601 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1602 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1603 } else if (iotg->hsm.b_bus_suspend_tmout) {
1604 u32 val;
1605 val = readl(lnw->iotg.base + CI_PORTSC1);
1606 if (!(val & PORTSC_SUSP))
1607 break;
1608
1609 if (lnw->iotg.stop_peripheral)
1610 lnw->iotg.stop_peripheral(&lnw->iotg);
1611 else
1612 dev_dbg(lnw->dev,
1613 "client driver has been removed.\n");
1614
1615 if (lnw->iotg.start_host)
1616 lnw->iotg.start_host(&lnw->iotg);
1617 else
1618 dev_dbg(lnw->dev,
1619 "host driver not loaded.\n");
1620 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1621 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1622 }
1623 break;
1624 case OTG_STATE_A_VBUS_ERR:
1625 if (iotg->hsm.id) {
1626 iotg->otg.default_a = 0;
1627 iotg->hsm.a_clr_err = 0;
1628 iotg->hsm.a_srp_det = 0;
1629 set_client_mode();
1630 langwell_otg_phy_low_power(1);
1631 iotg->otg.state = OTG_STATE_B_IDLE;
1632 langwell_update_transceiver();
1633 } else if (iotg->hsm.a_clr_err) {
1634 iotg->hsm.a_clr_err = 0;
1635 iotg->hsm.a_srp_det = 0;
1636 reset_otg();
1637 init_hsm();
1638 if (iotg->otg.state == OTG_STATE_A_IDLE)
1639 langwell_update_transceiver();
1640 } else {
1641 /* FW will clear PHCD bit when any VBus
1642 * event detected. Reset PHCD to 1 again */
1643 langwell_otg_phy_low_power(1);
1644 }
1645 break;
1646 case OTG_STATE_A_WAIT_VFALL:
1647 if (iotg->hsm.id) {
1648 iotg->otg.default_a = 0;
1649 set_client_mode();
1650 langwell_otg_phy_low_power(1);
1651 iotg->otg.state = OTG_STATE_B_IDLE;
1652 langwell_update_transceiver();
1653 } else if (iotg->hsm.a_bus_req) {
1654
1655 /* Turn on VBus */
1656 iotg->otg.set_vbus(&iotg->otg, true);
1657 iotg->hsm.a_wait_vrise_tmout = 0;
1658 langwell_otg_add_timer(a_wait_vrise_tmr);
1659 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1660 } else if (!iotg->hsm.a_sess_vld) {
1661 iotg->hsm.a_srp_det = 0;
1662 set_host_mode();
1663 langwell_otg_phy_low_power(1);
1664 iotg->otg.state = OTG_STATE_A_IDLE;
1665 }
1666 break;
1667 default:
1668 ;
1669 }
1670
1671 dev_dbg(lnw->dev, "%s: new state = %s\n", __func__,
1672 otg_state_string(iotg->otg.state));
1673}
1674
1675static ssize_t
1676show_registers(struct device *_dev, struct device_attribute *attr, char *buf)
1677{
1678 struct langwell_otg *lnw = the_transceiver;
1679 char *next;
1680 unsigned size, t;
1681
1682 next = buf;
1683 size = PAGE_SIZE;
1684
1685 t = scnprintf(next, size,
1686 "\n"
1687 "USBCMD = 0x%08x\n"
1688 "USBSTS = 0x%08x\n"
1689 "USBINTR = 0x%08x\n"
1690 "ASYNCLISTADDR = 0x%08x\n"
1691 "PORTSC1 = 0x%08x\n"
1692 "HOSTPC1 = 0x%08x\n"
1693 "OTGSC = 0x%08x\n"
1694 "USBMODE = 0x%08x\n",
1695 readl(lnw->iotg.base + 0x30),
1696 readl(lnw->iotg.base + 0x34),
1697 readl(lnw->iotg.base + 0x38),
1698 readl(lnw->iotg.base + 0x48),
1699 readl(lnw->iotg.base + 0x74),
1700 readl(lnw->iotg.base + 0xb4),
1701 readl(lnw->iotg.base + 0xf4),
1702 readl(lnw->iotg.base + 0xf8)
1703 );
1704 size -= t;
1705 next += t;
1706
1707 return PAGE_SIZE - size;
1708}
1709static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
1710
1711static ssize_t
1712show_hsm(struct device *_dev, struct device_attribute *attr, char *buf)
1713{
1714 struct langwell_otg *lnw = the_transceiver;
1715 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1716 char *next;
1717 unsigned size, t;
1718
1719 next = buf;
1720 size = PAGE_SIZE;
1721
1722 if (iotg->otg.host)
1723 iotg->hsm.a_set_b_hnp_en = iotg->otg.host->b_hnp_enable;
1724
1725 if (iotg->otg.gadget)
1726 iotg->hsm.b_hnp_enable = iotg->otg.gadget->b_hnp_enable;
1727
1728 t = scnprintf(next, size,
1729 "\n"
1730 "current state = %s\n"
1731 "a_bus_resume = \t%d\n"
1732 "a_bus_suspend = \t%d\n"
1733 "a_conn = \t%d\n"
1734 "a_sess_vld = \t%d\n"
1735 "a_srp_det = \t%d\n"
1736 "a_vbus_vld = \t%d\n"
1737 "b_bus_resume = \t%d\n"
1738 "b_bus_suspend = \t%d\n"
1739 "b_conn = \t%d\n"
1740 "b_se0_srp = \t%d\n"
1741 "b_sess_end = \t%d\n"
1742 "b_sess_vld = \t%d\n"
1743 "id = \t%d\n"
1744 "a_set_b_hnp_en = \t%d\n"
1745 "b_srp_done = \t%d\n"
1746 "b_hnp_enable = \t%d\n"
1747 "a_wait_vrise_tmout = \t%d\n"
1748 "a_wait_bcon_tmout = \t%d\n"
1749 "a_aidl_bdis_tmout = \t%d\n"
1750 "b_ase0_brst_tmout = \t%d\n"
1751 "a_bus_drop = \t%d\n"
1752 "a_bus_req = \t%d\n"
1753 "a_clr_err = \t%d\n"
1754 "a_suspend_req = \t%d\n"
1755 "b_bus_req = \t%d\n"
1756 "b_bus_suspend_tmout = \t%d\n"
1757 "b_bus_suspend_vld = \t%d\n",
1758 otg_state_string(iotg->otg.state),
1759 iotg->hsm.a_bus_resume,
1760 iotg->hsm.a_bus_suspend,
1761 iotg->hsm.a_conn,
1762 iotg->hsm.a_sess_vld,
1763 iotg->hsm.a_srp_det,
1764 iotg->hsm.a_vbus_vld,
1765 iotg->hsm.b_bus_resume,
1766 iotg->hsm.b_bus_suspend,
1767 iotg->hsm.b_conn,
1768 iotg->hsm.b_se0_srp,
1769 iotg->hsm.b_sess_end,
1770 iotg->hsm.b_sess_vld,
1771 iotg->hsm.id,
1772 iotg->hsm.a_set_b_hnp_en,
1773 iotg->hsm.b_srp_done,
1774 iotg->hsm.b_hnp_enable,
1775 iotg->hsm.a_wait_vrise_tmout,
1776 iotg->hsm.a_wait_bcon_tmout,
1777 iotg->hsm.a_aidl_bdis_tmout,
1778 iotg->hsm.b_ase0_brst_tmout,
1779 iotg->hsm.a_bus_drop,
1780 iotg->hsm.a_bus_req,
1781 iotg->hsm.a_clr_err,
1782 iotg->hsm.a_suspend_req,
1783 iotg->hsm.b_bus_req,
1784 iotg->hsm.b_bus_suspend_tmout,
1785 iotg->hsm.b_bus_suspend_vld
1786 );
1787 size -= t;
1788 next += t;
1789
1790 return PAGE_SIZE - size;
1791}
1792static DEVICE_ATTR(hsm, S_IRUGO, show_hsm, NULL);
1793
1794static ssize_t
1795get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
1796{
1797 struct langwell_otg *lnw = the_transceiver;
1798 char *next;
1799 unsigned size, t;
1800
1801 next = buf;
1802 size = PAGE_SIZE;
1803
1804 t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_req);
1805 size -= t;
1806 next += t;
1807
1808 return PAGE_SIZE - size;
1809}
1810
1811static ssize_t
1812set_a_bus_req(struct device *dev, struct device_attribute *attr,
1813 const char *buf, size_t count)
1814{
1815 struct langwell_otg *lnw = the_transceiver;
1816 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1817
1818 if (!iotg->otg.default_a)
1819 return -1;
1820 if (count > 2)
1821 return -1;
1822
1823 if (buf[0] == '0') {
1824 iotg->hsm.a_bus_req = 0;
1825 dev_dbg(lnw->dev, "User request: a_bus_req = 0\n");
1826 } else if (buf[0] == '1') {
1827 /* If a_bus_drop is TRUE, a_bus_req can't be set */
1828 if (iotg->hsm.a_bus_drop)
1829 return -1;
1830 iotg->hsm.a_bus_req = 1;
1831 dev_dbg(lnw->dev, "User request: a_bus_req = 1\n");
1832 }
1833 if (spin_trylock(&lnw->wq_lock)) {
1834 langwell_update_transceiver();
1835 spin_unlock(&lnw->wq_lock);
1836 }
1837 return count;
1838}
1839static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req);
1840
1841static ssize_t
1842get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
1843{
1844 struct langwell_otg *lnw = the_transceiver;
1845 char *next;
1846 unsigned size, t;
1847
1848 next = buf;
1849 size = PAGE_SIZE;
1850
1851 t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_drop);
1852 size -= t;
1853 next += t;
1854
1855 return PAGE_SIZE - size;
1856}
1857
1858static ssize_t
1859set_a_bus_drop(struct device *dev, struct device_attribute *attr,
1860 const char *buf, size_t count)
1861{
1862 struct langwell_otg *lnw = the_transceiver;
1863 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1864
1865 if (!iotg->otg.default_a)
1866 return -1;
1867 if (count > 2)
1868 return -1;
1869
1870 if (buf[0] == '0') {
1871 iotg->hsm.a_bus_drop = 0;
1872 dev_dbg(lnw->dev, "User request: a_bus_drop = 0\n");
1873 } else if (buf[0] == '1') {
1874 iotg->hsm.a_bus_drop = 1;
1875 iotg->hsm.a_bus_req = 0;
1876 dev_dbg(lnw->dev, "User request: a_bus_drop = 1\n");
1877 dev_dbg(lnw->dev, "User request: and a_bus_req = 0\n");
1878 }
1879 if (spin_trylock(&lnw->wq_lock)) {
1880 langwell_update_transceiver();
1881 spin_unlock(&lnw->wq_lock);
1882 }
1883 return count;
1884}
1885static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop, set_a_bus_drop);
1886
1887static ssize_t
1888get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
1889{
1890 struct langwell_otg *lnw = the_transceiver;
1891 char *next;
1892 unsigned size, t;
1893
1894 next = buf;
1895 size = PAGE_SIZE;
1896
1897 t = scnprintf(next, size, "%d", lnw->iotg.hsm.b_bus_req);
1898 size -= t;
1899 next += t;
1900
1901 return PAGE_SIZE - size;
1902}
1903
1904static ssize_t
1905set_b_bus_req(struct device *dev, struct device_attribute *attr,
1906 const char *buf, size_t count)
1907{
1908 struct langwell_otg *lnw = the_transceiver;
1909 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1910
1911 if (iotg->otg.default_a)
1912 return -1;
1913
1914 if (count > 2)
1915 return -1;
1916
1917 if (buf[0] == '0') {
1918 iotg->hsm.b_bus_req = 0;
1919 dev_dbg(lnw->dev, "User request: b_bus_req = 0\n");
1920 } else if (buf[0] == '1') {
1921 iotg->hsm.b_bus_req = 1;
1922 dev_dbg(lnw->dev, "User request: b_bus_req = 1\n");
1923 }
1924 if (spin_trylock(&lnw->wq_lock)) {
1925 langwell_update_transceiver();
1926 spin_unlock(&lnw->wq_lock);
1927 }
1928 return count;
1929}
1930static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req);
1931
1932static ssize_t
1933set_a_clr_err(struct device *dev, struct device_attribute *attr,
1934 const char *buf, size_t count)
1935{
1936 struct langwell_otg *lnw = the_transceiver;
1937 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1938
1939 if (!iotg->otg.default_a)
1940 return -1;
1941 if (count > 2)
1942 return -1;
1943
1944 if (buf[0] == '1') {
1945 iotg->hsm.a_clr_err = 1;
1946 dev_dbg(lnw->dev, "User request: a_clr_err = 1\n");
1947 }
1948 if (spin_trylock(&lnw->wq_lock)) {
1949 langwell_update_transceiver();
1950 spin_unlock(&lnw->wq_lock);
1951 }
1952 return count;
1953}
1954static DEVICE_ATTR(a_clr_err, S_IWUSR, NULL, set_a_clr_err);
1955
1956static struct attribute *inputs_attrs[] = {
1957 &dev_attr_a_bus_req.attr,
1958 &dev_attr_a_bus_drop.attr,
1959 &dev_attr_b_bus_req.attr,
1960 &dev_attr_a_clr_err.attr,
1961 NULL,
1962};
1963
1964static struct attribute_group debug_dev_attr_group = {
1965 .name = "inputs",
1966 .attrs = inputs_attrs,
1967};
1968
1969static int langwell_otg_probe(struct pci_dev *pdev,
1970 const struct pci_device_id *id)
1971{
1972 unsigned long resource, len;
1973 void __iomem *base = NULL;
1974 int retval;
1975 u32 val32;
1976 struct langwell_otg *lnw;
1977 char qname[] = "langwell_otg_queue";
1978
1979 retval = 0;
1980 dev_dbg(&pdev->dev, "\notg controller is detected.\n");
1981 if (pci_enable_device(pdev) < 0) {
1982 retval = -ENODEV;
1983 goto done;
1984 }
1985
1986 lnw = kzalloc(sizeof *lnw, GFP_KERNEL);
1987 if (lnw == NULL) {
1988 retval = -ENOMEM;
1989 goto done;
1990 }
1991 the_transceiver = lnw;
1992
1993 /* control register: BAR 0 */
1994 resource = pci_resource_start(pdev, 0);
1995 len = pci_resource_len(pdev, 0);
1996 if (!request_mem_region(resource, len, driver_name)) {
1997 retval = -EBUSY;
1998 goto err;
1999 }
2000 lnw->region = 1;
2001
2002 base = ioremap_nocache(resource, len);
2003 if (base == NULL) {
2004 retval = -EFAULT;
2005 goto err;
2006 }
2007 lnw->iotg.base = base;
2008
2009 if (!request_mem_region(USBCFG_ADDR, USBCFG_LEN, driver_name)) {
2010 retval = -EBUSY;
2011 goto err;
2012 }
2013 lnw->cfg_region = 1;
2014
2015 /* For the SCCB.USBCFG register */
2016 base = ioremap_nocache(USBCFG_ADDR, USBCFG_LEN);
2017 if (base == NULL) {
2018 retval = -EFAULT;
2019 goto err;
2020 }
2021 lnw->usbcfg = base;
2022
2023 if (!pdev->irq) {
2024 dev_dbg(&pdev->dev, "No IRQ.\n");
2025 retval = -ENODEV;
2026 goto err;
2027 }
2028
2029 lnw->qwork = create_singlethread_workqueue(qname);
2030 if (!lnw->qwork) {
2031 dev_dbg(&pdev->dev, "cannot create workqueue %s\n", qname);
2032 retval = -ENOMEM;
2033 goto err;
2034 }
2035 INIT_WORK(&lnw->work, langwell_otg_work);
2036
2037 /* OTG common part */
2038 lnw->dev = &pdev->dev;
2039 lnw->iotg.otg.dev = lnw->dev;
2040 lnw->iotg.otg.label = driver_name;
2041 lnw->iotg.otg.set_host = langwell_otg_set_host;
2042 lnw->iotg.otg.set_peripheral = langwell_otg_set_peripheral;
2043 lnw->iotg.otg.set_power = langwell_otg_set_power;
2044 lnw->iotg.otg.set_vbus = langwell_otg_set_vbus;
2045 lnw->iotg.otg.start_srp = langwell_otg_start_srp;
2046 lnw->iotg.otg.state = OTG_STATE_UNDEFINED;
2047
2048 if (otg_set_transceiver(&lnw->iotg.otg)) {
2049 dev_dbg(lnw->dev, "can't set transceiver\n");
2050 retval = -EBUSY;
2051 goto err;
2052 }
2053
2054 reset_otg();
2055 init_hsm();
2056
2057 spin_lock_init(&lnw->lock);
2058 spin_lock_init(&lnw->wq_lock);
2059 INIT_LIST_HEAD(&active_timers);
2060 retval = langwell_otg_init_timers(&lnw->iotg.hsm);
2061 if (retval) {
2062 dev_dbg(&pdev->dev, "Failed to init timers\n");
2063 goto err;
2064 }
2065
2066 init_timer(&lnw->hsm_timer);
2067 ATOMIC_INIT_NOTIFIER_HEAD(&lnw->iotg.iotg_notifier);
2068
2069 lnw->iotg_notifier.notifier_call = langwell_otg_iotg_notify;
2070
2071 retval = intel_mid_otg_register_notifier(&lnw->iotg,
2072 &lnw->iotg_notifier);
2073 if (retval) {
2074 dev_dbg(lnw->dev, "Failed to register notifier\n");
2075 goto err;
2076 }
2077
2078 if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
2079 driver_name, lnw) != 0) {
2080 dev_dbg(lnw->dev, "request interrupt %d failed\n", pdev->irq);
2081 retval = -EBUSY;
2082 goto err;
2083 }
2084
2085 /* enable OTGSC int */
2086 val32 = OTGSC_DPIE | OTGSC_BSEIE | OTGSC_BSVIE |
2087 OTGSC_ASVIE | OTGSC_AVVIE | OTGSC_IDIE | OTGSC_IDPU;
2088 writel(val32, lnw->iotg.base + CI_OTGSC);
2089
2090 retval = device_create_file(&pdev->dev, &dev_attr_registers);
2091 if (retval < 0) {
2092 dev_dbg(lnw->dev,
2093 "Can't register sysfs attribute: %d\n", retval);
2094 goto err;
2095 }
2096
2097 retval = device_create_file(&pdev->dev, &dev_attr_hsm);
2098 if (retval < 0) {
2099 dev_dbg(lnw->dev, "Can't hsm sysfs attribute: %d\n", retval);
2100 goto err;
2101 }
2102
2103 retval = sysfs_create_group(&pdev->dev.kobj, &debug_dev_attr_group);
2104 if (retval < 0) {
2105 dev_dbg(lnw->dev,
2106 "Can't register sysfs attr group: %d\n", retval);
2107 goto err;
2108 }
2109
2110 if (lnw->iotg.otg.state == OTG_STATE_A_IDLE)
2111 langwell_update_transceiver();
2112
2113 return 0;
2114
2115err:
2116 if (the_transceiver)
2117 langwell_otg_remove(pdev);
2118done:
2119 return retval;
2120}
2121
2122static void langwell_otg_remove(struct pci_dev *pdev)
2123{
2124 struct langwell_otg *lnw = the_transceiver;
2125
2126 if (lnw->qwork) {
2127 flush_workqueue(lnw->qwork);
2128 destroy_workqueue(lnw->qwork);
2129 }
2130 intel_mid_otg_unregister_notifier(&lnw->iotg, &lnw->iotg_notifier);
2131 langwell_otg_free_timers();
2132
2133 /* disable OTGSC interrupt as OTGSC doesn't change in reset */
2134 writel(0, lnw->iotg.base + CI_OTGSC);
2135
2136 if (pdev->irq)
2137 free_irq(pdev->irq, lnw);
2138 if (lnw->usbcfg)
2139 iounmap(lnw->usbcfg);
2140 if (lnw->cfg_region)
2141 release_mem_region(USBCFG_ADDR, USBCFG_LEN);
2142 if (lnw->iotg.base)
2143 iounmap(lnw->iotg.base);
2144 if (lnw->region)
2145 release_mem_region(pci_resource_start(pdev, 0),
2146 pci_resource_len(pdev, 0));
2147
2148 otg_set_transceiver(NULL);
2149 pci_disable_device(pdev);
2150 sysfs_remove_group(&pdev->dev.kobj, &debug_dev_attr_group);
2151 device_remove_file(&pdev->dev, &dev_attr_hsm);
2152 device_remove_file(&pdev->dev, &dev_attr_registers);
2153 kfree(lnw);
2154 lnw = NULL;
2155}
2156
2157static void transceiver_suspend(struct pci_dev *pdev)
2158{
2159 pci_save_state(pdev);
2160 pci_set_power_state(pdev, PCI_D3hot);
2161 langwell_otg_phy_low_power(1);
2162}
2163
2164static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
2165{
2166 struct langwell_otg *lnw = the_transceiver;
2167 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
2168 int ret = 0;
2169
2170 /* Disbale OTG interrupts */
2171 langwell_otg_intr(0);
2172
2173 if (pdev->irq)
2174 free_irq(pdev->irq, lnw);
2175
2176 /* Prevent more otg_work */
2177 flush_workqueue(lnw->qwork);
2178 destroy_workqueue(lnw->qwork);
2179 lnw->qwork = NULL;
2180
2181 /* start actions */
2182 switch (iotg->otg.state) {
2183 case OTG_STATE_A_WAIT_VFALL:
2184 iotg->otg.state = OTG_STATE_A_IDLE;
2185 case OTG_STATE_A_IDLE:
2186 case OTG_STATE_B_IDLE:
2187 case OTG_STATE_A_VBUS_ERR:
2188 transceiver_suspend(pdev);
2189 break;
2190 case OTG_STATE_A_WAIT_VRISE:
2191 langwell_otg_del_timer(a_wait_vrise_tmr);
2192 iotg->hsm.a_srp_det = 0;
2193
2194 /* Turn off VBus */
2195 iotg->otg.set_vbus(&iotg->otg, false);
2196 iotg->otg.state = OTG_STATE_A_IDLE;
2197 transceiver_suspend(pdev);
2198 break;
2199 case OTG_STATE_A_WAIT_BCON:
2200 del_timer_sync(&lnw->hsm_timer);
2201 if (lnw->iotg.stop_host)
2202 lnw->iotg.stop_host(&lnw->iotg);
2203 else
2204 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2205
2206 iotg->hsm.a_srp_det = 0;
2207
2208 /* Turn off VBus */
2209 iotg->otg.set_vbus(&iotg->otg, false);
2210 iotg->otg.state = OTG_STATE_A_IDLE;
2211 transceiver_suspend(pdev);
2212 break;
2213 case OTG_STATE_A_HOST:
2214 if (lnw->iotg.stop_host)
2215 lnw->iotg.stop_host(&lnw->iotg);
2216 else
2217 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2218
2219 iotg->hsm.a_srp_det = 0;
2220
2221 /* Turn off VBus */
2222 iotg->otg.set_vbus(&iotg->otg, false);
2223
2224 iotg->otg.state = OTG_STATE_A_IDLE;
2225 transceiver_suspend(pdev);
2226 break;
2227 case OTG_STATE_A_SUSPEND:
2228 langwell_otg_del_timer(a_aidl_bdis_tmr);
2229 langwell_otg_HABA(0);
2230 if (lnw->iotg.stop_host)
2231 lnw->iotg.stop_host(&lnw->iotg);
2232 else
2233 dev_dbg(lnw->dev, "host driver has been removed.\n");
2234 iotg->hsm.a_srp_det = 0;
2235
2236 /* Turn off VBus */
2237 iotg->otg.set_vbus(&iotg->otg, false);
2238 iotg->otg.state = OTG_STATE_A_IDLE;
2239 transceiver_suspend(pdev);
2240 break;
2241 case OTG_STATE_A_PERIPHERAL:
2242 del_timer_sync(&lnw->hsm_timer);
2243
2244 if (lnw->iotg.stop_peripheral)
2245 lnw->iotg.stop_peripheral(&lnw->iotg);
2246 else
2247 dev_dbg(&pdev->dev,
2248 "client driver has been removed.\n");
2249 iotg->hsm.a_srp_det = 0;
2250
2251 /* Turn off VBus */
2252 iotg->otg.set_vbus(&iotg->otg, false);
2253 iotg->otg.state = OTG_STATE_A_IDLE;
2254 transceiver_suspend(pdev);
2255 break;
2256 case OTG_STATE_B_HOST:
2257 if (lnw->iotg.stop_host)
2258 lnw->iotg.stop_host(&lnw->iotg);
2259 else
2260 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2261 iotg->hsm.b_bus_req = 0;
2262 iotg->otg.state = OTG_STATE_B_IDLE;
2263 transceiver_suspend(pdev);
2264 break;
2265 case OTG_STATE_B_PERIPHERAL:
2266 if (lnw->iotg.stop_peripheral)
2267 lnw->iotg.stop_peripheral(&lnw->iotg);
2268 else
2269 dev_dbg(&pdev->dev,
2270 "client driver has been removed.\n");
2271 iotg->otg.state = OTG_STATE_B_IDLE;
2272 transceiver_suspend(pdev);
2273 break;
2274 case OTG_STATE_B_WAIT_ACON:
2275 /* delete hsm timer for b_ase0_brst_tmr */
2276 del_timer_sync(&lnw->hsm_timer);
2277
2278 langwell_otg_HAAR(0);
2279
2280 if (lnw->iotg.stop_host)
2281 lnw->iotg.stop_host(&lnw->iotg);
2282 else
2283 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2284 iotg->hsm.b_bus_req = 0;
2285 iotg->otg.state = OTG_STATE_B_IDLE;
2286 transceiver_suspend(pdev);
2287 break;
2288 default:
2289 dev_dbg(lnw->dev, "error state before suspend\n");
2290 break;
2291 }
2292
2293 return ret;
2294}
2295
2296static void transceiver_resume(struct pci_dev *pdev)
2297{
2298 pci_restore_state(pdev);
2299 pci_set_power_state(pdev, PCI_D0);
2300}
2301
2302static int langwell_otg_resume(struct pci_dev *pdev)
2303{
2304 struct langwell_otg *lnw = the_transceiver;
2305 int ret = 0;
2306
2307 transceiver_resume(pdev);
2308
2309 lnw->qwork = create_singlethread_workqueue("langwell_otg_queue");
2310 if (!lnw->qwork) {
2311 dev_dbg(&pdev->dev, "cannot create langwell otg workqueuen");
2312 ret = -ENOMEM;
2313 goto error;
2314 }
2315
2316 if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
2317 driver_name, lnw) != 0) {
2318 dev_dbg(&pdev->dev, "request interrupt %d failed\n", pdev->irq);
2319 ret = -EBUSY;
2320 goto error;
2321 }
2322
2323 /* enable OTG interrupts */
2324 langwell_otg_intr(1);
2325
2326 update_hsm();
2327
2328 langwell_update_transceiver();
2329
2330 return ret;
2331error:
2332 langwell_otg_intr(0);
2333 transceiver_suspend(pdev);
2334 return ret;
2335}
2336
2337static int __init langwell_otg_init(void)
2338{
2339 return pci_register_driver(&otg_pci_driver);
2340}
2341module_init(langwell_otg_init);
2342
2343static void __exit langwell_otg_cleanup(void)
2344{
2345 pci_unregister_driver(&otg_pci_driver);
2346}
2347module_exit(langwell_otg_cleanup);
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index db0d4fcdc8e2..b5fbe1452ab0 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -202,6 +202,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg)
202 202
203static void mv_otg_start_host(struct mv_otg *mvotg, int on) 203static void mv_otg_start_host(struct mv_otg *mvotg, int on)
204{ 204{
205#ifdef CONFIG_USB
205 struct otg_transceiver *otg = &mvotg->otg; 206 struct otg_transceiver *otg = &mvotg->otg;
206 struct usb_hcd *hcd; 207 struct usb_hcd *hcd;
207 208
@@ -216,6 +217,7 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on)
216 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); 217 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
217 else 218 else
218 usb_remove_hcd(hcd); 219 usb_remove_hcd(hcd);
220#endif /* CONFIG_USB */
219} 221}
220 222
221static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on) 223static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 528691d5f3e2..7542aa94a462 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -425,7 +425,7 @@ static int usbhsg_recip_run_handle(struct usbhs_priv *priv,
425 struct usbhs_pipe *pipe; 425 struct usbhs_pipe *pipe;
426 int recip = ctrl->bRequestType & USB_RECIP_MASK; 426 int recip = ctrl->bRequestType & USB_RECIP_MASK;
427 int nth = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK; 427 int nth = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK;
428 int ret; 428 int ret = 0;
429 int (*func)(struct usbhs_priv *priv, struct usbhsg_uep *uep, 429 int (*func)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
430 struct usb_ctrlrequest *ctrl); 430 struct usb_ctrlrequest *ctrl);
431 char *msg; 431 char *msg;
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index fba1147ed916..8dbf51a43c45 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -39,6 +39,8 @@ static void cp210x_get_termios(struct tty_struct *,
39 struct usb_serial_port *port); 39 struct usb_serial_port *port);
40static void cp210x_get_termios_port(struct usb_serial_port *port, 40static void cp210x_get_termios_port(struct usb_serial_port *port,
41 unsigned int *cflagp, unsigned int *baudp); 41 unsigned int *cflagp, unsigned int *baudp);
42static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
43 struct ktermios *);
42static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *, 44static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
43 struct ktermios*); 45 struct ktermios*);
44static int cp210x_tiocmget(struct tty_struct *); 46static int cp210x_tiocmget(struct tty_struct *);
@@ -138,6 +140,7 @@ static const struct usb_device_id id_table[] = {
138 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ 140 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
139 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ 141 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
140 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ 142 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
143 { USB_DEVICE(0x3195, 0xF190) }, /* Link Instruments MSO-19 */
141 { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */ 144 { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
142 { } /* Terminating Entry */ 145 { } /* Terminating Entry */
143}; 146};
@@ -201,6 +204,8 @@ static struct usb_serial_driver cp210x_device = {
201#define CP210X_EMBED_EVENTS 0x15 204#define CP210X_EMBED_EVENTS 0x15
202#define CP210X_GET_EVENTSTATE 0x16 205#define CP210X_GET_EVENTSTATE 0x16
203#define CP210X_SET_CHARS 0x19 206#define CP210X_SET_CHARS 0x19
207#define CP210X_GET_BAUDRATE 0x1D
208#define CP210X_SET_BAUDRATE 0x1E
204 209
205/* CP210X_IFC_ENABLE */ 210/* CP210X_IFC_ENABLE */
206#define UART_ENABLE 0x0001 211#define UART_ENABLE 0x0001
@@ -360,8 +365,8 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port,
360 * Quantises the baud rate as per AN205 Table 1 365 * Quantises the baud rate as per AN205 Table 1
361 */ 366 */
362static unsigned int cp210x_quantise_baudrate(unsigned int baud) { 367static unsigned int cp210x_quantise_baudrate(unsigned int baud) {
363 if (baud <= 56) baud = 0; 368 if (baud <= 300)
364 else if (baud <= 300) baud = 300; 369 baud = 300;
365 else if (baud <= 600) baud = 600; 370 else if (baud <= 600) baud = 600;
366 else if (baud <= 1200) baud = 1200; 371 else if (baud <= 1200) baud = 1200;
367 else if (baud <= 1800) baud = 1800; 372 else if (baud <= 1800) baud = 1800;
@@ -389,10 +394,10 @@ static unsigned int cp210x_quantise_baudrate(unsigned int baud) {
389 else if (baud <= 491520) baud = 460800; 394 else if (baud <= 491520) baud = 460800;
390 else if (baud <= 567138) baud = 500000; 395 else if (baud <= 567138) baud = 500000;
391 else if (baud <= 670254) baud = 576000; 396 else if (baud <= 670254) baud = 576000;
392 else if (baud <= 1053257) baud = 921600; 397 else if (baud < 1000000)
393 else if (baud <= 1474560) baud = 1228800; 398 baud = 921600;
394 else if (baud <= 2457600) baud = 1843200; 399 else if (baud > 2000000)
395 else baud = 3686400; 400 baud = 2000000;
396 return baud; 401 return baud;
397} 402}
398 403
@@ -409,13 +414,14 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
409 return result; 414 return result;
410 } 415 }
411 416
412 result = usb_serial_generic_open(tty, port);
413 if (result)
414 return result;
415
416 /* Configure the termios structure */ 417 /* Configure the termios structure */
417 cp210x_get_termios(tty, port); 418 cp210x_get_termios(tty, port);
418 return 0; 419
420 /* The baud rate must be initialised on cp2104 */
421 if (tty)
422 cp210x_change_speed(tty, port, NULL);
423
424 return usb_serial_generic_open(tty, port);
419} 425}
420 426
421static void cp210x_close(struct usb_serial_port *port) 427static void cp210x_close(struct usb_serial_port *port)
@@ -467,10 +473,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
467 473
468 dbg("%s - port %d", __func__, port->number); 474 dbg("%s - port %d", __func__, port->number);
469 475
470 cp210x_get_config(port, CP210X_GET_BAUDDIV, &baud, 2); 476 cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4);
471 /* Convert to baudrate */
472 if (baud)
473 baud = cp210x_quantise_baudrate((BAUD_RATE_GEN_FREQ + baud/2)/ baud);
474 477
475 dbg("%s - baud rate = %d", __func__, baud); 478 dbg("%s - baud rate = %d", __func__, baud);
476 *baudp = baud; 479 *baudp = baud;
@@ -579,11 +582,64 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
579 *cflagp = cflag; 582 *cflagp = cflag;
580} 583}
581 584
585/*
586 * CP2101 supports the following baud rates:
587 *
588 * 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 28800,
589 * 38400, 56000, 57600, 115200, 128000, 230400, 460800, 921600
590 *
591 * CP2102 and CP2103 support the following additional rates:
592 *
593 * 4000, 16000, 51200, 64000, 76800, 153600, 250000, 256000, 500000,
594 * 576000
595 *
596 * The device will map a requested rate to a supported one, but the result
597 * of requests for rates greater than 1053257 is undefined (see AN205).
598 *
599 * CP2104, CP2105 and CP2110 support most rates up to 2M, 921k and 1M baud,
600 * respectively, with an error less than 1%. The actual rates are determined
601 * by
602 *
603 * div = round(freq / (2 x prescale x request))
604 * actual = freq / (2 x prescale x div)
605 *
606 * For CP2104 and CP2105 freq is 48Mhz and prescale is 4 for request <= 365bps
607 * or 1 otherwise.
608 * For CP2110 freq is 24Mhz and prescale is 4 for request <= 300bps or 1
609 * otherwise.
610 */
611static void cp210x_change_speed(struct tty_struct *tty,
612 struct usb_serial_port *port, struct ktermios *old_termios)
613{
614 u32 baud;
615
616 baud = tty->termios->c_ospeed;
617
618 /* This maps the requested rate to a rate valid on cp2102 or cp2103,
619 * or to an arbitrary rate in [1M,2M].
620 *
621 * NOTE: B0 is not implemented.
622 */
623 baud = cp210x_quantise_baudrate(baud);
624
625 dbg("%s - setting baud rate to %u", __func__, baud);
626 if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud,
627 sizeof(baud))) {
628 dev_warn(&port->dev, "failed to set baud rate to %u\n", baud);
629 if (old_termios)
630 baud = old_termios->c_ospeed;
631 else
632 baud = 9600;
633 }
634
635 tty_encode_baud_rate(tty, baud, baud);
636}
637
582static void cp210x_set_termios(struct tty_struct *tty, 638static void cp210x_set_termios(struct tty_struct *tty,
583 struct usb_serial_port *port, struct ktermios *old_termios) 639 struct usb_serial_port *port, struct ktermios *old_termios)
584{ 640{
585 unsigned int cflag, old_cflag; 641 unsigned int cflag, old_cflag;
586 unsigned int baud = 0, bits; 642 unsigned int bits;
587 unsigned int modem_ctl[4]; 643 unsigned int modem_ctl[4];
588 644
589 dbg("%s - port %d", __func__, port->number); 645 dbg("%s - port %d", __func__, port->number);
@@ -593,20 +649,9 @@ static void cp210x_set_termios(struct tty_struct *tty,
593 649
594 cflag = tty->termios->c_cflag; 650 cflag = tty->termios->c_cflag;
595 old_cflag = old_termios->c_cflag; 651 old_cflag = old_termios->c_cflag;
596 baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); 652
597 653 if (tty->termios->c_ospeed != old_termios->c_ospeed)
598 /* If the baud rate is to be updated*/ 654 cp210x_change_speed(tty, port, old_termios);
599 if (baud != tty_termios_baud_rate(old_termios) && baud != 0) {
600 dbg("%s - Setting baud rate to %d baud", __func__,
601 baud);
602 if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV,
603 ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) {
604 dbg("Baud rate requested not supported by device");
605 baud = tty_termios_baud_rate(old_termios);
606 }
607 }
608 /* Report back the resulting baud rate */
609 tty_encode_baud_rate(tty, baud, baud);
610 655
611 /* If the number of data bits is to be updated */ 656 /* If the number of data bits is to be updated */
612 if ((cflag & CSIZE) != (old_cflag & CSIZE)) { 657 if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 01b6404df395..ad654f8208ef 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -797,6 +797,7 @@ static struct usb_device_id id_table_combined [] = {
797 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 797 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
798 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), 798 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID),
799 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 799 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
800 { USB_DEVICE(HORNBY_VID, HORNBY_ELITE_PID) },
800 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, 801 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
801 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), 802 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
802 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 803 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
@@ -805,6 +806,8 @@ static struct usb_device_id id_table_combined [] = {
805 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) }, 806 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
806 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID), 807 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
807 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 808 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
809 { USB_DEVICE(FTDI_VID, TI_XDS100V2_PID),
810 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
808 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, 811 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
809 { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) }, 812 { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) },
810 { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) }, 813 { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) },
@@ -841,6 +844,7 @@ static struct usb_device_id id_table_combined [] = {
841 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 844 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
842 { USB_DEVICE(ST_VID, ST_STMCLT1030_PID), 845 { USB_DEVICE(ST_VID, ST_STMCLT1030_PID),
843 .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk }, 846 .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk },
847 { USB_DEVICE(FTDI_VID, FTDI_RF_R106) },
844 { }, /* Optional parameter entry */ 848 { }, /* Optional parameter entry */
845 { } /* Terminating entry */ 849 { } /* Terminating entry */
846}; 850};
@@ -1333,8 +1337,7 @@ static int set_serial_info(struct tty_struct *tty,
1333 goto check_and_exit; 1337 goto check_and_exit;
1334 } 1338 }
1335 1339
1336 if ((new_serial.baud_base != priv->baud_base) && 1340 if (new_serial.baud_base != priv->baud_base) {
1337 (new_serial.baud_base < 9600)) {
1338 mutex_unlock(&priv->cfg_lock); 1341 mutex_unlock(&priv->cfg_lock);
1339 return -EINVAL; 1342 return -EINVAL;
1340 } 1343 }
@@ -1824,6 +1827,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1824 1827
1825static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) 1828static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1826{ 1829{
1830 struct ktermios dummy;
1827 struct usb_device *dev = port->serial->dev; 1831 struct usb_device *dev = port->serial->dev;
1828 struct ftdi_private *priv = usb_get_serial_port_data(port); 1832 struct ftdi_private *priv = usb_get_serial_port_data(port);
1829 int result; 1833 int result;
@@ -1842,8 +1846,10 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1842 This is same behaviour as serial.c/rs_open() - Kuba */ 1846 This is same behaviour as serial.c/rs_open() - Kuba */
1843 1847
1844 /* ftdi_set_termios will send usb control messages */ 1848 /* ftdi_set_termios will send usb control messages */
1845 if (tty) 1849 if (tty) {
1846 ftdi_set_termios(tty, port, tty->termios); 1850 memset(&dummy, 0, sizeof(dummy));
1851 ftdi_set_termios(tty, port, &dummy);
1852 }
1847 1853
1848 /* Start reading from the device */ 1854 /* Start reading from the device */
1849 result = usb_serial_generic_open(tty, port); 1855 result = usb_serial_generic_open(tty, port);
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index df1d7da933ec..f994503df2dd 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -39,6 +39,13 @@
39/* www.candapter.com Ewert Energy Systems CANdapter device */ 39/* www.candapter.com Ewert Energy Systems CANdapter device */
40#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */ 40#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
41 41
42/*
43 * Texas Instruments XDS100v2 JTAG / BeagleBone A3
44 * http://processors.wiki.ti.com/index.php/XDS100
45 * http://beagleboard.org/bone
46 */
47#define TI_XDS100V2_PID 0xa6d0
48
42#define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */ 49#define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */
43 50
44/* US Interface Navigator (http://www.usinterface.com/) */ 51/* US Interface Navigator (http://www.usinterface.com/) */
@@ -525,6 +532,12 @@
525#define ADI_GNICEPLUS_PID 0xF001 532#define ADI_GNICEPLUS_PID 0xF001
526 533
527/* 534/*
535 * Hornby Elite
536 */
537#define HORNBY_VID 0x04D8
538#define HORNBY_ELITE_PID 0x000A
539
540/*
528 * RATOC REX-USB60F 541 * RATOC REX-USB60F
529 */ 542 */
530#define RATOC_VENDOR_ID 0x0584 543#define RATOC_VENDOR_ID 0x0584
@@ -1168,3 +1181,9 @@
1168 */ 1181 */
1169/* TagTracer MIFARE*/ 1182/* TagTracer MIFARE*/
1170#define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0 1183#define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0
1184
1185/*
1186 * Rainforest Automation
1187 */
1188/* ZigBee controller */
1189#define FTDI_RF_R106 0x8A28
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 65bf06aa591a..5818bfc3261e 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2657,15 +2657,7 @@ cleanup:
2657 2657
2658static void edge_disconnect(struct usb_serial *serial) 2658static void edge_disconnect(struct usb_serial *serial)
2659{ 2659{
2660 int i;
2661 struct edgeport_port *edge_port;
2662
2663 dbg("%s", __func__); 2660 dbg("%s", __func__);
2664
2665 for (i = 0; i < serial->num_ports; ++i) {
2666 edge_port = usb_get_serial_port_data(serial->port[i]);
2667 edge_remove_sysfs_attrs(edge_port->port);
2668 }
2669} 2661}
2670 2662
2671static void edge_release(struct usb_serial *serial) 2663static void edge_release(struct usb_serial *serial)
@@ -2744,6 +2736,7 @@ static struct usb_serial_driver edgeport_1port_device = {
2744 .disconnect = edge_disconnect, 2736 .disconnect = edge_disconnect,
2745 .release = edge_release, 2737 .release = edge_release,
2746 .port_probe = edge_create_sysfs_attrs, 2738 .port_probe = edge_create_sysfs_attrs,
2739 .port_remove = edge_remove_sysfs_attrs,
2747 .ioctl = edge_ioctl, 2740 .ioctl = edge_ioctl,
2748 .set_termios = edge_set_termios, 2741 .set_termios = edge_set_termios,
2749 .tiocmget = edge_tiocmget, 2742 .tiocmget = edge_tiocmget,
@@ -2775,6 +2768,7 @@ static struct usb_serial_driver edgeport_2port_device = {
2775 .disconnect = edge_disconnect, 2768 .disconnect = edge_disconnect,
2776 .release = edge_release, 2769 .release = edge_release,
2777 .port_probe = edge_create_sysfs_attrs, 2770 .port_probe = edge_create_sysfs_attrs,
2771 .port_remove = edge_remove_sysfs_attrs,
2778 .ioctl = edge_ioctl, 2772 .ioctl = edge_ioctl,
2779 .set_termios = edge_set_termios, 2773 .set_termios = edge_set_termios,
2780 .tiocmget = edge_tiocmget, 2774 .tiocmget = edge_tiocmget,
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 5d3beeeb5fd9..a92a3efb507b 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -38,7 +38,7 @@
38#include <linux/ioctl.h> 38#include <linux/ioctl.h>
39#include "kobil_sct.h" 39#include "kobil_sct.h"
40 40
41static int debug; 41static bool debug;
42 42
43/* Version Information */ 43/* Version Information */
44#define DRIVER_VERSION "21/05/2004" 44#define DRIVER_VERSION "21/05/2004"
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 420d9857394a..ea126a4490cd 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -480,6 +480,10 @@ static void option_instat_callback(struct urb *urb);
480#define ZD_VENDOR_ID 0x0685 480#define ZD_VENDOR_ID 0x0685
481#define ZD_PRODUCT_7000 0x7000 481#define ZD_PRODUCT_7000 0x7000
482 482
483/* LG products */
484#define LG_VENDOR_ID 0x1004
485#define LG_PRODUCT_L02C 0x618f
486
483/* some devices interfaces need special handling due to a number of reasons */ 487/* some devices interfaces need special handling due to a number of reasons */
484enum option_blacklist_reason { 488enum option_blacklist_reason {
485 OPTION_BLACKLIST_NONE = 0, 489 OPTION_BLACKLIST_NONE = 0,
@@ -1183,6 +1187,7 @@ static const struct usb_device_id option_ids[] = {
1183 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) }, 1187 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) },
1184 { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) }, 1188 { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) },
1185 { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) }, 1189 { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) },
1190 { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */
1186 { } /* Terminating entry */ 1191 { } /* Terminating entry */
1187}; 1192};
1188MODULE_DEVICE_TABLE(usb, option_ids); 1193MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
index 30b73e68a904..a34819884c1a 100644
--- a/drivers/usb/serial/qcaux.c
+++ b/drivers/usb/serial/qcaux.c
@@ -36,6 +36,7 @@
36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712 36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712
37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714 37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714
38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715
39#define PANTECH_PRODUCT_UML190_VZW 0x3716
39#define PANTECH_PRODUCT_UML290_VZW 0x3718 40#define PANTECH_PRODUCT_UML290_VZW 0x3718
40 41
41/* CMOTECH devices */ 42/* CMOTECH devices */
@@ -67,7 +68,11 @@ static struct usb_device_id id_table[] = {
67 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) }, 68 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) },
68 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) }, 69 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) },
69 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) }, 70 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) },
70 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, 71 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xff, 0xff) },
72 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xfe, 0xff) },
73 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfd, 0xff) }, /* NMEA */
74 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfe, 0xff) }, /* WMC */
75 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, /* DIAG */
71 { }, 76 { },
72}; 77};
73MODULE_DEVICE_TABLE(usb, id_table); 78MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 1f62723ef1a8..d32f72061c09 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -789,7 +789,7 @@ static void rts51x_suspend_timer_fn(unsigned long data)
789 rts51x_set_stat(chip, RTS51X_STAT_SS); 789 rts51x_set_stat(chip, RTS51X_STAT_SS);
790 /* ignore mass storage interface's children */ 790 /* ignore mass storage interface's children */
791 pm_suspend_ignore_children(&us->pusb_intf->dev, true); 791 pm_suspend_ignore_children(&us->pusb_intf->dev, true);
792 usb_autopm_put_interface(us->pusb_intf); 792 usb_autopm_put_interface_async(us->pusb_intf);
793 US_DEBUGP("%s: RTS51X_STAT_SS 01," 793 US_DEBUGP("%s: RTS51X_STAT_SS 01,"
794 "intf->pm_usage_cnt:%d, power.usage:%d\n", 794 "intf->pm_usage_cnt:%d, power.usage:%d\n",
795 __func__, 795 __func__,
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 8efeae24764f..b4a71679c933 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -27,8 +27,6 @@
27#define USB_SKEL_VENDOR_ID 0xfff0 27#define USB_SKEL_VENDOR_ID 0xfff0
28#define USB_SKEL_PRODUCT_ID 0xfff0 28#define USB_SKEL_PRODUCT_ID 0xfff0
29 29
30static DEFINE_MUTEX(skel_mutex);
31
32/* table of devices that work with this driver */ 30/* table of devices that work with this driver */
33static const struct usb_device_id skel_table[] = { 31static const struct usb_device_id skel_table[] = {
34 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 32 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
@@ -101,25 +99,18 @@ static int skel_open(struct inode *inode, struct file *file)
101 goto exit; 99 goto exit;
102 } 100 }
103 101
104 mutex_lock(&skel_mutex);
105 dev = usb_get_intfdata(interface); 102 dev = usb_get_intfdata(interface);
106 if (!dev) { 103 if (!dev) {
107 mutex_unlock(&skel_mutex);
108 retval = -ENODEV; 104 retval = -ENODEV;
109 goto exit; 105 goto exit;
110 } 106 }
111 107
112 /* increment our usage count for the device */ 108 /* increment our usage count for the device */
113 kref_get(&dev->kref); 109 kref_get(&dev->kref);
114 mutex_unlock(&skel_mutex);
115 110
116 /* lock the device to allow correctly handling errors 111 /* lock the device to allow correctly handling errors
117 * in resumption */ 112 * in resumption */
118 mutex_lock(&dev->io_mutex); 113 mutex_lock(&dev->io_mutex);
119 if (!dev->interface) {
120 retval = -ENODEV;
121 goto out_err;
122 }
123 114
124 retval = usb_autopm_get_interface(interface); 115 retval = usb_autopm_get_interface(interface);
125 if (retval) 116 if (retval)
@@ -127,11 +118,7 @@ static int skel_open(struct inode *inode, struct file *file)
127 118
128 /* save our object in the file's private structure */ 119 /* save our object in the file's private structure */
129 file->private_data = dev; 120 file->private_data = dev;
130
131out_err:
132 mutex_unlock(&dev->io_mutex); 121 mutex_unlock(&dev->io_mutex);
133 if (retval)
134 kref_put(&dev->kref, skel_delete);
135 122
136exit: 123exit:
137 return retval; 124 return retval;
@@ -611,6 +598,7 @@ static void skel_disconnect(struct usb_interface *interface)
611 int minor = interface->minor; 598 int minor = interface->minor;
612 599
613 dev = usb_get_intfdata(interface); 600 dev = usb_get_intfdata(interface);
601 usb_set_intfdata(interface, NULL);
614 602
615 /* give back our minor */ 603 /* give back our minor */
616 usb_deregister_dev(interface, &skel_class); 604 usb_deregister_dev(interface, &skel_class);
@@ -622,12 +610,8 @@ static void skel_disconnect(struct usb_interface *interface)
622 610
623 usb_kill_anchored_urbs(&dev->submitted); 611 usb_kill_anchored_urbs(&dev->submitted);
624 612
625 mutex_lock(&skel_mutex);
626 usb_set_intfdata(interface, NULL);
627
628 /* decrement our usage count */ 613 /* decrement our usage count */
629 kref_put(&dev->kref, skel_delete); 614 kref_put(&dev->kref, skel_delete);
630 mutex_unlock(&skel_mutex);
631 615
632 dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); 616 dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor);
633} 617}
diff --git a/drivers/usb/wusbcore/Kconfig b/drivers/usb/wusbcore/Kconfig
index 0ead8826ec79..f29fdd7f6d75 100644
--- a/drivers/usb/wusbcore/Kconfig
+++ b/drivers/usb/wusbcore/Kconfig
@@ -6,7 +6,7 @@ config USB_WUSB
6 depends on EXPERIMENTAL 6 depends on EXPERIMENTAL
7 depends on USB 7 depends on USB
8 depends on PCI 8 depends on PCI
9 select UWB 9 depends on UWB
10 select CRYPTO 10 select CRYPTO
11 select CRYPTO_BLKCIPHER 11 select CRYPTO_BLKCIPHER
12 select CRYPTO_CBC 12 select CRYPTO_CBC
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 0d7b20d4285d..e40c00f2c2ba 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -1108,7 +1108,7 @@ static int atmel_lcdfb_suspend(struct platform_device *pdev, pm_message_t mesg)
1108 */ 1108 */
1109 lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL); 1109 lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL);
1110 1110
1111 sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL); 1111 sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_CTR);
1112 lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, 0); 1112 lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, 0);
1113 if (sinfo->atmel_lcdfb_power_control) 1113 if (sinfo->atmel_lcdfb_power_control)
1114 sinfo->atmel_lcdfb_power_control(0); 1114 sinfo->atmel_lcdfb_power_control(0);
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index acf292bfba02..6af3f16754f0 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -1432,7 +1432,7 @@ static int fsl_diu_suspend(struct platform_device *ofdev, pm_message_t state)
1432 struct fsl_diu_data *data; 1432 struct fsl_diu_data *data;
1433 1433
1434 data = dev_get_drvdata(&ofdev->dev); 1434 data = dev_get_drvdata(&ofdev->dev);
1435 disable_lcdc(data->fsl_diu_info[0]); 1435 disable_lcdc(data->fsl_diu_info);
1436 1436
1437 return 0; 1437 return 0;
1438} 1438}
@@ -1442,7 +1442,7 @@ static int fsl_diu_resume(struct platform_device *ofdev)
1442 struct fsl_diu_data *data; 1442 struct fsl_diu_data *data;
1443 1443
1444 data = dev_get_drvdata(&ofdev->dev); 1444 data = dev_get_drvdata(&ofdev->dev);
1445 enable_lcdc(data->fsl_diu_info[0]); 1445 enable_lcdc(data->fsl_diu_info);
1446 1446
1447 return 0; 1447 return 0;
1448} 1448}
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index c6afa33a4532..02fd2263610c 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -529,7 +529,6 @@ static int __devinit intelfb_pci_register(struct pci_dev *pdev,
529 if (fb_alloc_cmap(&info->cmap, 256, 1) < 0) { 529 if (fb_alloc_cmap(&info->cmap, 256, 1) < 0) {
530 ERR_MSG("Could not allocate cmap for intelfb_info.\n"); 530 ERR_MSG("Could not allocate cmap for intelfb_info.\n");
531 goto err_out_cmap; 531 goto err_out_cmap;
532 return -ENODEV;
533 } 532 }
534 533
535 dinfo = info->par; 534 dinfo = info->par;
diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c
index a5ec7f37c185..e1626a1d5c45 100644
--- a/drivers/video/omap2/dss/dispc.c
+++ b/drivers/video/omap2/dss/dispc.c
@@ -401,7 +401,7 @@ void dispc_runtime_put(void)
401 401
402 DSSDBG("dispc_runtime_put\n"); 402 DSSDBG("dispc_runtime_put\n");
403 403
404 r = pm_runtime_put(&dispc.pdev->dev); 404 r = pm_runtime_put_sync(&dispc.pdev->dev);
405 WARN_ON(r < 0); 405 WARN_ON(r < 0);
406} 406}
407 407
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index d4d676c82c12..52f36ec1c8bb 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -1079,7 +1079,7 @@ void dsi_runtime_put(struct platform_device *dsidev)
1079 1079
1080 DSSDBG("dsi_runtime_put\n"); 1080 DSSDBG("dsi_runtime_put\n");
1081 1081
1082 r = pm_runtime_put(&dsi->pdev->dev); 1082 r = pm_runtime_put_sync(&dsi->pdev->dev);
1083 WARN_ON(r < 0); 1083 WARN_ON(r < 0);
1084} 1084}
1085 1085
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 17033457ee89..77c2b5a32b5d 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -720,7 +720,7 @@ void dss_runtime_put(void)
720 720
721 DSSDBG("dss_runtime_put\n"); 721 DSSDBG("dss_runtime_put\n");
722 722
723 r = pm_runtime_put(&dss.pdev->dev); 723 r = pm_runtime_put_sync(&dss.pdev->dev);
724 WARN_ON(r < 0); 724 WARN_ON(r < 0);
725} 725}
726 726
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index b4c270edb915..d7aa3b056529 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -176,7 +176,7 @@ static void hdmi_runtime_put(void)
176 176
177 DSSDBG("hdmi_runtime_put\n"); 177 DSSDBG("hdmi_runtime_put\n");
178 178
179 r = pm_runtime_put(&hdmi.pdev->dev); 179 r = pm_runtime_put_sync(&hdmi.pdev->dev);
180 WARN_ON(r < 0); 180 WARN_ON(r < 0);
181} 181}
182 182
@@ -497,6 +497,7 @@ bool omapdss_hdmi_detect(void)
497 497
498int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev) 498int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev)
499{ 499{
500 struct omap_dss_hdmi_data *priv = dssdev->data;
500 int r = 0; 501 int r = 0;
501 502
502 DSSDBG("ENTER hdmi_display_enable\n"); 503 DSSDBG("ENTER hdmi_display_enable\n");
@@ -509,6 +510,8 @@ int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev)
509 goto err0; 510 goto err0;
510 } 511 }
511 512
513 hdmi.ip_data.hpd_gpio = priv->hpd_gpio;
514
512 r = omap_dss_start_device(dssdev); 515 r = omap_dss_start_device(dssdev);
513 if (r) { 516 if (r) {
514 DSSERR("failed to start device\n"); 517 DSSERR("failed to start device\n");
diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c
index 814bb9500dca..55f398014f33 100644
--- a/drivers/video/omap2/dss/rfbi.c
+++ b/drivers/video/omap2/dss/rfbi.c
@@ -140,7 +140,7 @@ static void rfbi_runtime_put(void)
140 140
141 DSSDBG("rfbi_runtime_put\n"); 141 DSSDBG("rfbi_runtime_put\n");
142 142
143 r = pm_runtime_put(&rfbi.pdev->dev); 143 r = pm_runtime_put_sync(&rfbi.pdev->dev);
144 WARN_ON(r < 0); 144 WARN_ON(r < 0);
145} 145}
146 146
diff --git a/drivers/video/omap2/dss/ti_hdmi.h b/drivers/video/omap2/dss/ti_hdmi.h
index 7503f7f619a7..50dadba5070a 100644
--- a/drivers/video/omap2/dss/ti_hdmi.h
+++ b/drivers/video/omap2/dss/ti_hdmi.h
@@ -126,6 +126,10 @@ struct hdmi_ip_data {
126 const struct ti_hdmi_ip_ops *ops; 126 const struct ti_hdmi_ip_ops *ops;
127 struct hdmi_config cfg; 127 struct hdmi_config cfg;
128 struct hdmi_pll_info pll_data; 128 struct hdmi_pll_info pll_data;
129
130 /* ti_hdmi_4xxx_ip private data. These should be in a separate struct */
131 int hpd_gpio;
132 bool phy_tx_enabled;
129}; 133};
130int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data); 134int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data);
131void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data); 135void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data);
diff --git a/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c b/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c
index 9af81f18f163..2d72334ca3da 100644
--- a/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c
+++ b/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c
@@ -28,6 +28,7 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/seq_file.h> 30#include <linux/seq_file.h>
31#include <linux/gpio.h>
31 32
32#include "ti_hdmi_4xxx_ip.h" 33#include "ti_hdmi_4xxx_ip.h"
33#include "dss.h" 34#include "dss.h"
@@ -223,6 +224,49 @@ void ti_hdmi_4xxx_pll_disable(struct hdmi_ip_data *ip_data)
223 hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_ALLOFF); 224 hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_ALLOFF);
224} 225}
225 226
227static int hdmi_check_hpd_state(struct hdmi_ip_data *ip_data)
228{
229 unsigned long flags;
230 bool hpd;
231 int r;
232 /* this should be in ti_hdmi_4xxx_ip private data */
233 static DEFINE_SPINLOCK(phy_tx_lock);
234
235 spin_lock_irqsave(&phy_tx_lock, flags);
236
237 hpd = gpio_get_value(ip_data->hpd_gpio);
238
239 if (hpd == ip_data->phy_tx_enabled) {
240 spin_unlock_irqrestore(&phy_tx_lock, flags);
241 return 0;
242 }
243
244 if (hpd)
245 r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_TXON);
246 else
247 r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON);
248
249 if (r) {
250 DSSERR("Failed to %s PHY TX power\n",
251 hpd ? "enable" : "disable");
252 goto err;
253 }
254
255 ip_data->phy_tx_enabled = hpd;
256err:
257 spin_unlock_irqrestore(&phy_tx_lock, flags);
258 return r;
259}
260
261static irqreturn_t hpd_irq_handler(int irq, void *data)
262{
263 struct hdmi_ip_data *ip_data = data;
264
265 hdmi_check_hpd_state(ip_data);
266
267 return IRQ_HANDLED;
268}
269
226int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data) 270int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data)
227{ 271{
228 u16 r = 0; 272 u16 r = 0;
@@ -232,10 +276,6 @@ int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data)
232 if (r) 276 if (r)
233 return r; 277 return r;
234 278
235 r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_TXON);
236 if (r)
237 return r;
238
239 /* 279 /*
240 * Read address 0 in order to get the SCP reset done completed 280 * Read address 0 in order to get the SCP reset done completed
241 * Dummy access performed to make sure reset is done 281 * Dummy access performed to make sure reset is done
@@ -257,12 +297,32 @@ int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data)
257 /* Write to phy address 3 to change the polarity control */ 297 /* Write to phy address 3 to change the polarity control */
258 REG_FLD_MOD(phy_base, HDMI_TXPHY_PAD_CFG_CTRL, 0x1, 27, 27); 298 REG_FLD_MOD(phy_base, HDMI_TXPHY_PAD_CFG_CTRL, 0x1, 27, 27);
259 299
300 r = request_threaded_irq(gpio_to_irq(ip_data->hpd_gpio),
301 NULL, hpd_irq_handler,
302 IRQF_DISABLED | IRQF_TRIGGER_RISING |
303 IRQF_TRIGGER_FALLING, "hpd", ip_data);
304 if (r) {
305 DSSERR("HPD IRQ request failed\n");
306 hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
307 return r;
308 }
309
310 r = hdmi_check_hpd_state(ip_data);
311 if (r) {
312 free_irq(gpio_to_irq(ip_data->hpd_gpio), ip_data);
313 hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
314 return r;
315 }
316
260 return 0; 317 return 0;
261} 318}
262 319
263void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data) 320void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data)
264{ 321{
322 free_irq(gpio_to_irq(ip_data->hpd_gpio), ip_data);
323
265 hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF); 324 hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
325 ip_data->phy_tx_enabled = false;
266} 326}
267 327
268static int hdmi_core_ddc_init(struct hdmi_ip_data *ip_data) 328static int hdmi_core_ddc_init(struct hdmi_ip_data *ip_data)
diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index b3e9f9091581..5c3d0f901510 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -401,7 +401,7 @@ static void venc_runtime_put(void)
401 401
402 DSSDBG("venc_runtime_put\n"); 402 DSSDBG("venc_runtime_put\n");
403 403
404 r = pm_runtime_put(&venc.pdev->dev); 404 r = pm_runtime_put_sync(&venc.pdev->dev);
405 WARN_ON(r < 0); 405 WARN_ON(r < 0);
406} 406}
407 407
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 79e1b292c030..5aa43c3392a2 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -35,7 +35,7 @@
35#define virtio_rmb(vq) \ 35#define virtio_rmb(vq) \
36 do { if ((vq)->weak_barriers) smp_rmb(); else rmb(); } while(0) 36 do { if ((vq)->weak_barriers) smp_rmb(); else rmb(); } while(0)
37#define virtio_wmb(vq) \ 37#define virtio_wmb(vq) \
38 do { if ((vq)->weak_barriers) smp_rmb(); else rmb(); } while(0) 38 do { if ((vq)->weak_barriers) smp_wmb(); else wmb(); } while(0)
39#else 39#else
40/* We must force memory ordering even if guest is UP since host could be 40/* We must force memory ordering even if guest is UP since host could be
41 * running on another CPU, but SMP barriers are defined to barrier() in that 41 * running on another CPU, but SMP barriers are defined to barrier() in that
@@ -308,9 +308,9 @@ bool virtqueue_kick_prepare(struct virtqueue *_vq)
308 bool needs_kick; 308 bool needs_kick;
309 309
310 START_USE(vq); 310 START_USE(vq);
311 /* Descriptors and available array need to be set before we expose the 311 /* We need to expose available array entries before checking avail
312 * new available array entries. */ 312 * event. */
313 virtio_wmb(vq); 313 virtio_mb(vq);
314 314
315 old = vq->vring.avail->idx - vq->num_added; 315 old = vq->vring.avail->idx - vq->num_added;
316 new = vq->vring.avail->idx; 316 new = vq->vring.avail->idx;
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 1b0e3dd81c1a..63d7b58f1c7d 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -300,11 +300,7 @@ static int __devinit dw_wdt_drv_probe(struct platform_device *pdev)
300 if (!mem) 300 if (!mem)
301 return -EINVAL; 301 return -EINVAL;
302 302
303 if (!devm_request_mem_region(&pdev->dev, mem->start, resource_size(mem), 303 dw_wdt.regs = devm_request_and_ioremap(&pdev->dev, mem);
304 "dw_wdt"))
305 return -ENOMEM;
306
307 dw_wdt.regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
308 if (!dw_wdt.regs) 304 if (!dw_wdt.regs)
309 return -ENOMEM; 305 return -ENOMEM;
310 306
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 99796c5d913d..bdf401b240b5 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -36,6 +36,7 @@
36 * document number TBD : Patsburg (PBG) 36 * document number TBD : Patsburg (PBG)
37 * document number TBD : DH89xxCC 37 * document number TBD : DH89xxCC
38 * document number TBD : Panther Point 38 * document number TBD : Panther Point
39 * document number TBD : Lynx Point
39 */ 40 */
40 41
41/* 42/*
@@ -126,6 +127,7 @@ enum iTCO_chipsets {
126 TCO_PBG, /* Patsburg */ 127 TCO_PBG, /* Patsburg */
127 TCO_DH89XXCC, /* DH89xxCC */ 128 TCO_DH89XXCC, /* DH89xxCC */
128 TCO_PPT, /* Panther Point */ 129 TCO_PPT, /* Panther Point */
130 TCO_LPT, /* Lynx Point */
129}; 131};
130 132
131static struct { 133static struct {
@@ -189,6 +191,7 @@ static struct {
189 {"Patsburg", 2}, 191 {"Patsburg", 2},
190 {"DH89xxCC", 2}, 192 {"DH89xxCC", 2},
191 {"Panther Point", 2}, 193 {"Panther Point", 2},
194 {"Lynx Point", 2},
192 {NULL, 0} 195 {NULL, 0}
193}; 196};
194 197
@@ -331,6 +334,38 @@ static DEFINE_PCI_DEVICE_TABLE(iTCO_wdt_pci_tbl) = {
331 { PCI_VDEVICE(INTEL, 0x1e5d), TCO_PPT}, 334 { PCI_VDEVICE(INTEL, 0x1e5d), TCO_PPT},
332 { PCI_VDEVICE(INTEL, 0x1e5e), TCO_PPT}, 335 { PCI_VDEVICE(INTEL, 0x1e5e), TCO_PPT},
333 { PCI_VDEVICE(INTEL, 0x1e5f), TCO_PPT}, 336 { PCI_VDEVICE(INTEL, 0x1e5f), TCO_PPT},
337 { PCI_VDEVICE(INTEL, 0x8c40), TCO_LPT},
338 { PCI_VDEVICE(INTEL, 0x8c41), TCO_LPT},
339 { PCI_VDEVICE(INTEL, 0x8c42), TCO_LPT},
340 { PCI_VDEVICE(INTEL, 0x8c43), TCO_LPT},
341 { PCI_VDEVICE(INTEL, 0x8c44), TCO_LPT},
342 { PCI_VDEVICE(INTEL, 0x8c45), TCO_LPT},
343 { PCI_VDEVICE(INTEL, 0x8c46), TCO_LPT},
344 { PCI_VDEVICE(INTEL, 0x8c47), TCO_LPT},
345 { PCI_VDEVICE(INTEL, 0x8c48), TCO_LPT},
346 { PCI_VDEVICE(INTEL, 0x8c49), TCO_LPT},
347 { PCI_VDEVICE(INTEL, 0x8c4a), TCO_LPT},
348 { PCI_VDEVICE(INTEL, 0x8c4b), TCO_LPT},
349 { PCI_VDEVICE(INTEL, 0x8c4c), TCO_LPT},
350 { PCI_VDEVICE(INTEL, 0x8c4d), TCO_LPT},
351 { PCI_VDEVICE(INTEL, 0x8c4e), TCO_LPT},
352 { PCI_VDEVICE(INTEL, 0x8c4f), TCO_LPT},
353 { PCI_VDEVICE(INTEL, 0x8c50), TCO_LPT},
354 { PCI_VDEVICE(INTEL, 0x8c51), TCO_LPT},
355 { PCI_VDEVICE(INTEL, 0x8c52), TCO_LPT},
356 { PCI_VDEVICE(INTEL, 0x8c53), TCO_LPT},
357 { PCI_VDEVICE(INTEL, 0x8c54), TCO_LPT},
358 { PCI_VDEVICE(INTEL, 0x8c55), TCO_LPT},
359 { PCI_VDEVICE(INTEL, 0x8c56), TCO_LPT},
360 { PCI_VDEVICE(INTEL, 0x8c57), TCO_LPT},
361 { PCI_VDEVICE(INTEL, 0x8c58), TCO_LPT},
362 { PCI_VDEVICE(INTEL, 0x8c59), TCO_LPT},
363 { PCI_VDEVICE(INTEL, 0x8c5a), TCO_LPT},
364 { PCI_VDEVICE(INTEL, 0x8c5b), TCO_LPT},
365 { PCI_VDEVICE(INTEL, 0x8c5c), TCO_LPT},
366 { PCI_VDEVICE(INTEL, 0x8c5d), TCO_LPT},
367 { PCI_VDEVICE(INTEL, 0x8c5e), TCO_LPT},
368 { PCI_VDEVICE(INTEL, 0x8c5f), TCO_LPT},
334 { 0, }, /* End of list */ 369 { 0, }, /* End of list */
335}; 370};
336MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl); 371MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index b8ef2c6dca7c..c44c3334003a 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -247,7 +247,6 @@ static struct miscdevice imx2_wdt_miscdev = {
247static int __init imx2_wdt_probe(struct platform_device *pdev) 247static int __init imx2_wdt_probe(struct platform_device *pdev)
248{ 248{
249 int ret; 249 int ret;
250 int res_size;
251 struct resource *res; 250 struct resource *res;
252 251
253 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 252 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -256,15 +255,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
256 return -ENODEV; 255 return -ENODEV;
257 } 256 }
258 257
259 res_size = resource_size(res); 258 imx2_wdt.base = devm_request_and_ioremap(&pdev->dev, res);
260 if (!devm_request_mem_region(&pdev->dev, res->start, res_size,
261 res->name)) {
262 dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n",
263 res_size, res->start);
264 return -ENOMEM;
265 }
266
267 imx2_wdt.base = devm_ioremap_nocache(&pdev->dev, res->start, res_size);
268 if (!imx2_wdt.base) { 259 if (!imx2_wdt.base) {
269 dev_err(&pdev->dev, "ioremap failed\n"); 260 dev_err(&pdev->dev, "ioremap failed\n");
270 return -ENOMEM; 261 return -ENOMEM;
diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c
index 50359bad9177..529085b8b8fb 100644
--- a/drivers/watchdog/nuc900_wdt.c
+++ b/drivers/watchdog/nuc900_wdt.c
@@ -72,7 +72,7 @@ struct nuc900_wdt {
72}; 72};
73 73
74static unsigned long nuc900wdt_busy; 74static unsigned long nuc900wdt_busy;
75struct nuc900_wdt *nuc900_wdt; 75static struct nuc900_wdt *nuc900_wdt;
76 76
77static inline void nuc900_wdt_keepalive(void) 77static inline void nuc900_wdt_keepalive(void)
78{ 78{
@@ -287,7 +287,8 @@ static int __devinit nuc900wdt_probe(struct platform_device *pdev)
287 287
288 setup_timer(&nuc900_wdt->timer, nuc900_wdt_timer_ping, 0); 288 setup_timer(&nuc900_wdt->timer, nuc900_wdt_timer_ping, 0);
289 289
290 if (misc_register(&nuc900wdt_miscdev)) { 290 ret = misc_register(&nuc900wdt_miscdev);
291 if (ret) {
291 dev_err(&pdev->dev, "err register miscdev on minor=%d (%d)\n", 292 dev_err(&pdev->dev, "err register miscdev on minor=%d (%d)\n",
292 WATCHDOG_MINOR, ret); 293 WATCHDOG_MINOR, ret);
293 goto err_clk; 294 goto err_clk;
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 4b33e3fd726b..d19ff5145e82 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -339,6 +339,7 @@ static int __devinit omap_wdt_probe(struct platform_device *pdev)
339 return 0; 339 return 0;
340 340
341err_misc: 341err_misc:
342 pm_runtime_disable(wdev->dev);
342 platform_set_drvdata(pdev, NULL); 343 platform_set_drvdata(pdev, NULL);
343 iounmap(wdev->base); 344 iounmap(wdev->base);
344 345
@@ -371,6 +372,7 @@ static int __devexit omap_wdt_remove(struct platform_device *pdev)
371 struct omap_wdt_dev *wdev = platform_get_drvdata(pdev); 372 struct omap_wdt_dev *wdev = platform_get_drvdata(pdev);
372 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 373 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
373 374
375 pm_runtime_disable(wdev->dev);
374 if (!res) 376 if (!res)
375 return -ENOENT; 377 return -ENOENT;
376 378
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index bd143c9dd3e6..8e210aafdfd0 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -226,7 +226,7 @@ static long pnx4008_wdt_ioctl(struct file *file, unsigned int cmd,
226static int pnx4008_wdt_release(struct inode *inode, struct file *file) 226static int pnx4008_wdt_release(struct inode *inode, struct file *file)
227{ 227{
228 if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status)) 228 if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status))
229 printk(KERN_WARNING "WATCHDOG: Device closed unexpectdly\n"); 229 printk(KERN_WARNING "WATCHDOG: Device closed unexpectedly\n");
230 230
231 wdt_disable(); 231 wdt_disable();
232 clk_disable(wdt_clk); 232 clk_disable(wdt_clk);
diff --git a/drivers/watchdog/stmp3xxx_wdt.c b/drivers/watchdog/stmp3xxx_wdt.c
index 4c2a4e8698f9..e37d81178b9e 100644
--- a/drivers/watchdog/stmp3xxx_wdt.c
+++ b/drivers/watchdog/stmp3xxx_wdt.c
@@ -174,7 +174,7 @@ static int stmp3xxx_wdt_release(struct inode *inode, struct file *file)
174 if (!nowayout) { 174 if (!nowayout) {
175 if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status)) { 175 if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status)) {
176 wdt_ping(); 176 wdt_ping();
177 pr_debug("%s: Device closed unexpectdly\n", __func__); 177 pr_debug("%s: Device closed unexpectedly\n", __func__);
178 ret = -EINVAL; 178 ret = -EINVAL;
179 } else { 179 } else {
180 wdt_disable(); 180 wdt_disable();
diff --git a/drivers/watchdog/via_wdt.c b/drivers/watchdog/via_wdt.c
index 026b4bbfa0aa..8f07dd4bd94a 100644
--- a/drivers/watchdog/via_wdt.c
+++ b/drivers/watchdog/via_wdt.c
@@ -124,8 +124,6 @@ static int wdt_stop(struct watchdog_device *wdd)
124static int wdt_set_timeout(struct watchdog_device *wdd, 124static int wdt_set_timeout(struct watchdog_device *wdd,
125 unsigned int new_timeout) 125 unsigned int new_timeout)
126{ 126{
127 if (new_timeout < 1 || new_timeout > WDT_TIMEOUT_MAX)
128 return -EINVAL;
129 writel(new_timeout, wdt_mem + VIA_WDT_COUNT); 127 writel(new_timeout, wdt_mem + VIA_WDT_COUNT);
130 timeout = new_timeout; 128 timeout = new_timeout;
131 return 0; 129 return 0;
@@ -150,6 +148,8 @@ static const struct watchdog_ops wdt_ops = {
150static struct watchdog_device wdt_dev = { 148static struct watchdog_device wdt_dev = {
151 .info = &wdt_info, 149 .info = &wdt_info,
152 .ops = &wdt_ops, 150 .ops = &wdt_ops,
151 .min_timeout = 1,
152 .max_timeout = WDT_TIMEOUT_MAX,
153}; 153};
154 154
155static int __devinit wdt_probe(struct pci_dev *pdev, 155static int __devinit wdt_probe(struct pci_dev *pdev,
@@ -233,7 +233,7 @@ static void __devexit wdt_remove(struct pci_dev *pdev)
233 pci_disable_device(pdev); 233 pci_disable_device(pdev);
234} 234}
235 235
236DEFINE_PCI_DEVICE_TABLE(wdt_pci_table) = { 236static DEFINE_PCI_DEVICE_TABLE(wdt_pci_table) = {
237 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700) }, 237 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700) },
238 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800) }, 238 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800) },
239 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) }, 239 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
diff --git a/drivers/watchdog/wafer5823wdt.c b/drivers/watchdog/wafer5823wdt.c
index 42e940c23891..c3c3188c34d7 100644
--- a/drivers/watchdog/wafer5823wdt.c
+++ b/drivers/watchdog/wafer5823wdt.c
@@ -152,12 +152,12 @@ static long wafwdt_ioctl(struct file *file, unsigned int cmd,
152 return -EFAULT; 152 return -EFAULT;
153 153
154 if (options & WDIOS_DISABLECARD) { 154 if (options & WDIOS_DISABLECARD) {
155 wafwdt_start(); 155 wafwdt_stop();
156 retval = 0; 156 retval = 0;
157 } 157 }
158 158
159 if (options & WDIOS_ENABLECARD) { 159 if (options & WDIOS_ENABLECARD) {
160 wafwdt_stop(); 160 wafwdt_start();
161 retval = 0; 161 retval = 0;
162 } 162 }
163 163
diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c
index 909c78650d3e..5d7113c7e501 100644
--- a/drivers/watchdog/wm8350_wdt.c
+++ b/drivers/watchdog/wm8350_wdt.c
@@ -212,10 +212,10 @@ static long wm8350_wdt_ioctl(struct file *file, unsigned int cmd,
212 212
213 /* Setting both simultaneously means at least one must fail */ 213 /* Setting both simultaneously means at least one must fail */
214 if (options == WDIOS_DISABLECARD) 214 if (options == WDIOS_DISABLECARD)
215 ret = wm8350_wdt_start(wm8350); 215 ret = wm8350_wdt_stop(wm8350);
216 216
217 if (options == WDIOS_ENABLECARD) 217 if (options == WDIOS_ENABLECARD)
218 ret = wm8350_wdt_stop(wm8350); 218 ret = wm8350_wdt_start(wm8350);
219 break; 219 break;
220 } 220 }
221 221
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 1cd94daa71db..b4d4eac761db 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -948,9 +948,12 @@ static void gnttab_request_version(void)
948 int rc; 948 int rc;
949 struct gnttab_set_version gsv; 949 struct gnttab_set_version gsv;
950 950
951 gsv.version = 2; 951 if (xen_hvm_domain())
952 gsv.version = 1;
953 else
954 gsv.version = 2;
952 rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1); 955 rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1);
953 if (rc == 0) { 956 if (rc == 0 && gsv.version == 2) {
954 grant_table_version = 2; 957 grant_table_version = 2;
955 gnttab_interface = &gnttab_v2_ops; 958 gnttab_interface = &gnttab_v2_ops;
956 } else if (grant_table_version == 2) { 959 } else if (grant_table_version == 2) {