aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/acpi/enumeration.txt26
-rw-r--r--Documentation/devicetree/bindings/thermal/rcar-thermal.txt2
-rw-r--r--Makefile2
-rw-r--r--arch/nios2/include/asm/thread_info.h4
-rw-r--r--arch/nios2/include/uapi/asm/ptrace.h9
-rw-r--r--arch/nios2/kernel/entry.S2
-rw-r--r--arch/nios2/kernel/signal.c2
-rw-r--r--arch/nios2/mm/cacheflush.c3
-rw-r--r--block/blk-mq.c4
-rw-r--r--drivers/acpi/acpi_platform.c2
-rw-r--r--drivers/acpi/battery.c4
-rw-r--r--drivers/acpi/blacklist.c8
-rw-r--r--drivers/acpi/dock.c2
-rw-r--r--drivers/acpi/ec.c123
-rw-r--r--drivers/acpi/glue.c4
-rw-r--r--drivers/acpi/pmic/intel_pmic_crc.c2
-rw-r--r--drivers/acpi/scan.c388
-rw-r--r--drivers/acpi/sleep.c17
-rw-r--r--drivers/acpi/sleep.h2
-rw-r--r--drivers/acpi/sysfs.c2
-rw-r--r--drivers/acpi/video.c36
-rw-r--r--drivers/acpi/video_detect.c8
-rw-r--r--drivers/ata/pata_isapnp.c14
-rw-r--r--drivers/base/core.c51
-rw-r--r--drivers/base/platform.c2
-rw-r--r--drivers/base/property.c198
-rw-r--r--drivers/char/ipmi/ipmi_powernv.c1
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c109
-rw-r--r--drivers/char/ipmi/ipmi_ssif.c8
-rw-r--r--drivers/char/tpm/tpm_infineon.c13
-rw-r--r--drivers/cpufreq/Kconfig8
-rw-r--r--drivers/cpufreq/Kconfig.arm9
-rw-r--r--drivers/cpufreq/Kconfig.powerpc9
-rw-r--r--drivers/cpufreq/Makefile3
-rw-r--r--drivers/cpufreq/hisi-acpu-cpufreq.c42
-rw-r--r--drivers/cpufreq/intel_pstate.c45
-rw-r--r--drivers/cpufreq/powernv-cpufreq.c47
-rw-r--r--drivers/cpufreq/qoriq-cpufreq.c (renamed from drivers/cpufreq/ppc-corenet-cpufreq.c)163
-rw-r--r--drivers/dma/cppi41.c9
-rw-r--r--drivers/dma/dmaengine.c3
-rw-r--r--drivers/gpio/gpiolib.h2
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c4
-rw-r--r--drivers/i2c/i2c-core.c4
-rw-r--r--drivers/ide/ide-pnp.c14
-rw-r--r--drivers/iommu/intel-iommu.c2
-rw-r--r--drivers/media/rc/ene_ir.c13
-rw-r--r--drivers/media/rc/fintek-cir.c13
-rw-r--r--drivers/media/rc/ite-cir.c13
-rw-r--r--drivers/media/rc/nuvoton-cir.c13
-rw-r--r--drivers/misc/enclosure.c11
-rw-r--r--drivers/net/sb1000.c15
-rw-r--r--drivers/platform/x86/apple-gmux.c14
-rw-r--r--drivers/pnp/base.h2
-rw-r--r--drivers/pnp/card.c25
-rw-r--r--drivers/pnp/core.c64
-rw-r--r--drivers/pnp/driver.c10
-rw-r--r--drivers/pnp/pnpacpi/core.c5
-rw-r--r--drivers/scsi/be2iscsi/be_main.c2
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/target/iscsi/iscsi_target.c11
-rw-r--r--drivers/target/target_core_device.c4
-rw-r--r--drivers/thermal/st/st_thermal.c2
-rw-r--r--drivers/thermal/st/st_thermal_memmap.c10
-rw-r--r--drivers/thermal/st/st_thermal_syscfg.c14
-rw-r--r--drivers/thermal/thermal_core.c6
-rw-r--r--drivers/tty/serial/8250/8250_fintek.c13
-rw-r--r--fs/aio.c20
-rw-r--r--fs/ocfs2/file.c17
-rw-r--r--include/acpi/acpi_bus.h4
-rw-r--r--include/linux/acpi.h15
-rw-r--r--include/linux/blk_types.h4
-rw-r--r--include/linux/device.h16
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/fwnode.h27
-rw-r--r--include/linux/i2c.h4
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/pnp.h12
-rw-r--r--include/linux/property.h44
-rw-r--r--mm/mremap.c10
-rw-r--r--sound/firewire/bebob/bebob_maudio.c8
-rw-r--r--sound/pci/hda/patch_realtek.c27
-rw-r--r--sound/soc/codecs/pcm512x.c19
-rw-r--r--sound/usb/mixer_quirks.c1
-rw-r--r--sound/usb/quirks.c9
84 files changed, 1249 insertions, 668 deletions
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt
index 9b121a569ab4..750401f91341 100644
--- a/Documentation/acpi/enumeration.txt
+++ b/Documentation/acpi/enumeration.txt
@@ -254,8 +254,13 @@ GPIO support
254~~~~~~~~~~~~ 254~~~~~~~~~~~~
255ACPI 5 introduced two new resources to describe GPIO connections: GpioIo 255ACPI 5 introduced two new resources to describe GPIO connections: GpioIo
256and GpioInt. These resources are used be used to pass GPIO numbers used by 256and GpioInt. These resources are used be used to pass GPIO numbers used by
257the device to the driver. For example: 257the device to the driver. ACPI 5.1 extended this with _DSD (Device
258Specific Data) which made it possible to name the GPIOs among other things.
258 259
260For example:
261
262Device (DEV)
263{
259 Method (_CRS, 0, NotSerialized) 264 Method (_CRS, 0, NotSerialized)
260 { 265 {
261 Name (SBUF, ResourceTemplate() 266 Name (SBUF, ResourceTemplate()
@@ -285,6 +290,18 @@ the device to the driver. For example:
285 Return (SBUF) 290 Return (SBUF)
286 } 291 }
287 292
293 // ACPI 5.1 _DSD used for naming the GPIOs
294 Name (_DSD, Package ()
295 {
296 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
297 Package ()
298 {
299 Package () {"power-gpios", Package() {^DEV, 0, 0, 0 }},
300 Package () {"irq-gpios", Package() {^DEV, 1, 0, 0 }},
301 }
302 })
303 ...
304
288These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" 305These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
289specifies the path to the controller. In order to use these GPIOs in Linux 306specifies the path to the controller. In order to use these GPIOs in Linux
290we need to translate them to the corresponding Linux GPIO descriptors. 307we need to translate them to the corresponding Linux GPIO descriptors.
@@ -300,11 +317,11 @@ a code like this:
300 317
301 struct gpio_desc *irq_desc, *power_desc; 318 struct gpio_desc *irq_desc, *power_desc;
302 319
303 irq_desc = gpiod_get_index(dev, NULL, 1); 320 irq_desc = gpiod_get(dev, "irq");
304 if (IS_ERR(irq_desc)) 321 if (IS_ERR(irq_desc))
305 /* handle error */ 322 /* handle error */
306 323
307 power_desc = gpiod_get_index(dev, NULL, 0); 324 power_desc = gpiod_get(dev, "power");
308 if (IS_ERR(power_desc)) 325 if (IS_ERR(power_desc))
309 /* handle error */ 326 /* handle error */
310 327
@@ -313,6 +330,9 @@ a code like this:
313There are also devm_* versions of these functions which release the 330There are also devm_* versions of these functions which release the
314descriptors once the device is released. 331descriptors once the device is released.
315 332
333See Documentation/acpi/gpio-properties.txt for more information about the
334_DSD binding related to GPIOs.
335
316MFD devices 336MFD devices
317~~~~~~~~~~~ 337~~~~~~~~~~~
318The MFD devices register their children as platform devices. For the child 338The MFD devices register their children as platform devices. For the child
diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
index 43404b197933..332e625f6ed0 100644
--- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
@@ -4,7 +4,7 @@ Required properties:
4- compatible : "renesas,thermal-<soctype>", "renesas,rcar-thermal" 4- compatible : "renesas,thermal-<soctype>", "renesas,rcar-thermal"
5 as fallback. 5 as fallback.
6 Examples with soctypes are: 6 Examples with soctypes are:
7 - "renesas,thermal-r8a73a4" (R-Mobile AP6) 7 - "renesas,thermal-r8a73a4" (R-Mobile APE6)
8 - "renesas,thermal-r8a7779" (R-Car H1) 8 - "renesas,thermal-r8a7779" (R-Car H1)
9 - "renesas,thermal-r8a7790" (R-Car H2) 9 - "renesas,thermal-r8a7790" (R-Car H2)
10 - "renesas,thermal-r8a7791" (R-Car M2-W) 10 - "renesas,thermal-r8a7791" (R-Car M2-W)
diff --git a/Makefile b/Makefile
index 54430f933b62..fbd43bfe4445 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 0 2PATCHLEVEL = 0
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc7 4EXTRAVERSION =
5NAME = Hurr durr I'ma sheep 5NAME = Hurr durr I'ma sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/nios2/include/asm/thread_info.h b/arch/nios2/include/asm/thread_info.h
index 1f266575beb5..a16e55cbd8ad 100644
--- a/arch/nios2/include/asm/thread_info.h
+++ b/arch/nios2/include/asm/thread_info.h
@@ -47,7 +47,6 @@ struct thread_info {
47 0-0x7FFFFFFF for user-thead 47 0-0x7FFFFFFF for user-thead
48 0-0xFFFFFFFF for kernel-thread 48 0-0xFFFFFFFF for kernel-thread
49 */ 49 */
50 struct restart_block restart_block;
51 struct pt_regs *regs; 50 struct pt_regs *regs;
52}; 51};
53 52
@@ -64,9 +63,6 @@ struct thread_info {
64 .cpu = 0, \ 63 .cpu = 0, \
65 .preempt_count = INIT_PREEMPT_COUNT, \ 64 .preempt_count = INIT_PREEMPT_COUNT, \
66 .addr_limit = KERNEL_DS, \ 65 .addr_limit = KERNEL_DS, \
67 .restart_block = { \
68 .fn = do_no_restart_syscall, \
69 }, \
70} 66}
71 67
72#define init_thread_info (init_thread_union.thread_info) 68#define init_thread_info (init_thread_union.thread_info)
diff --git a/arch/nios2/include/uapi/asm/ptrace.h b/arch/nios2/include/uapi/asm/ptrace.h
index 71a330597adf..eff00e67c0a2 100644
--- a/arch/nios2/include/uapi/asm/ptrace.h
+++ b/arch/nios2/include/uapi/asm/ptrace.h
@@ -60,12 +60,17 @@
60#define PTR_IPENDING 37 60#define PTR_IPENDING 37
61#define PTR_CPUID 38 61#define PTR_CPUID 38
62#define PTR_CTL6 39 62#define PTR_CTL6 39
63#define PTR_CTL7 40 63#define PTR_EXCEPTION 40
64#define PTR_PTEADDR 41 64#define PTR_PTEADDR 41
65#define PTR_TLBACC 42 65#define PTR_TLBACC 42
66#define PTR_TLBMISC 43 66#define PTR_TLBMISC 43
67#define PTR_ECCINJ 44
68#define PTR_BADADDR 45
69#define PTR_CONFIG 46
70#define PTR_MPUBASE 47
71#define PTR_MPUACC 48
67 72
68#define NUM_PTRACE_REG (PTR_TLBMISC + 1) 73#define NUM_PTRACE_REG (PTR_MPUACC + 1)
69 74
70/* User structures for general purpose registers. */ 75/* User structures for general purpose registers. */
71struct user_pt_regs { 76struct user_pt_regs {
diff --git a/arch/nios2/kernel/entry.S b/arch/nios2/kernel/entry.S
index 7729bd3f2e79..27b006c52e12 100644
--- a/arch/nios2/kernel/entry.S
+++ b/arch/nios2/kernel/entry.S
@@ -161,7 +161,7 @@ ENTRY(inthandler)
161 *********************************************************************** 161 ***********************************************************************
162 */ 162 */
163ENTRY(handle_trap) 163ENTRY(handle_trap)
164 ldw r24, -4(ea) /* instruction that caused the exception */ 164 ldwio r24, -4(ea) /* instruction that caused the exception */
165 srli r24, r24, 4 165 srli r24, r24, 4
166 andi r24, r24, 0x7c 166 andi r24, r24, 0x7c
167 movia r9,trap_table 167 movia r9,trap_table
diff --git a/arch/nios2/kernel/signal.c b/arch/nios2/kernel/signal.c
index dda41e4fe707..20662b0f6c9e 100644
--- a/arch/nios2/kernel/signal.c
+++ b/arch/nios2/kernel/signal.c
@@ -43,7 +43,7 @@ static inline int rt_restore_ucontext(struct pt_regs *regs,
43 int err; 43 int err;
44 44
45 /* Always make any pending restarted system calls return -EINTR */ 45 /* Always make any pending restarted system calls return -EINTR */
46 current_thread_info()->restart_block.fn = do_no_restart_syscall; 46 current->restart_block.fn = do_no_restart_syscall;
47 47
48 err = __get_user(temp, &uc->uc_mcontext.version); 48 err = __get_user(temp, &uc->uc_mcontext.version);
49 if (temp != MCONTEXT_VERSION) 49 if (temp != MCONTEXT_VERSION)
diff --git a/arch/nios2/mm/cacheflush.c b/arch/nios2/mm/cacheflush.c
index 2ae482b42669..796642932e2e 100644
--- a/arch/nios2/mm/cacheflush.c
+++ b/arch/nios2/mm/cacheflush.c
@@ -23,9 +23,6 @@ static void __flush_dcache(unsigned long start, unsigned long end)
23 end += (cpuinfo.dcache_line_size - 1); 23 end += (cpuinfo.dcache_line_size - 1);
24 end &= ~(cpuinfo.dcache_line_size - 1); 24 end &= ~(cpuinfo.dcache_line_size - 1);
25 25
26 if (end > start + cpuinfo.dcache_size)
27 end = start + cpuinfo.dcache_size;
28
29 for (addr = start; addr < end; addr += cpuinfo.dcache_line_size) { 26 for (addr = start; addr < end; addr += cpuinfo.dcache_line_size) {
30 __asm__ __volatile__ (" flushda 0(%0)\n" 27 __asm__ __volatile__ (" flushda 0(%0)\n"
31 : /* Outputs */ 28 : /* Outputs */
diff --git a/block/blk-mq.c b/block/blk-mq.c
index b7b8933ec241..33c428530193 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1457,7 +1457,7 @@ static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
1457 1457
1458 do { 1458 do {
1459 page = alloc_pages_node(set->numa_node, 1459 page = alloc_pages_node(set->numa_node,
1460 GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY, 1460 GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO,
1461 this_order); 1461 this_order);
1462 if (page) 1462 if (page)
1463 break; 1463 break;
@@ -1479,8 +1479,6 @@ static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
1479 left -= to_do * rq_size; 1479 left -= to_do * rq_size;
1480 for (j = 0; j < to_do; j++) { 1480 for (j = 0; j < to_do; j++) {
1481 tags->rqs[i] = p; 1481 tags->rqs[i] = p;
1482 tags->rqs[i]->atomic_flags = 0;
1483 tags->rqs[i]->cmd_flags = 0;
1484 if (set->ops->init_request) { 1482 if (set->ops->init_request) {
1485 if (set->ops->init_request(set->driver_data, 1483 if (set->ops->init_request(set->driver_data,
1486 tags->rqs[i], hctx_idx, i, 1484 tags->rqs[i], hctx_idx, i,
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 1284138e42ab..4bf75597f732 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -102,7 +102,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
102 pdevinfo.id = -1; 102 pdevinfo.id = -1;
103 pdevinfo.res = resources; 103 pdevinfo.res = resources;
104 pdevinfo.num_res = count; 104 pdevinfo.num_res = count;
105 pdevinfo.acpi_node.companion = adev; 105 pdevinfo.fwnode = acpi_fwnode_handle(adev);
106 pdevinfo.dma_mask = DMA_BIT_MASK(32); 106 pdevinfo.dma_mask = DMA_BIT_MASK(32);
107 pdev = platform_device_register_full(&pdevinfo); 107 pdev = platform_device_register_full(&pdevinfo);
108 if (IS_ERR(pdev)) 108 if (IS_ERR(pdev))
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index d98ba4355819..baebd1a9b811 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -530,8 +530,8 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
530 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && 530 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
531 (s16)(battery->rate_now) < 0) { 531 (s16)(battery->rate_now) < 0) {
532 battery->rate_now = abs((s16)battery->rate_now); 532 battery->rate_now = abs((s16)battery->rate_now);
533 printk_once(KERN_WARNING FW_BUG "battery: (dis)charge rate" 533 printk_once(KERN_WARNING FW_BUG
534 " invalid.\n"); 534 "battery: (dis)charge rate invalid.\n");
535 } 535 }
536 536
537 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) 537 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 9b693d54c743..1d1791935c31 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -215,6 +215,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
215 }, 215 },
216 { 216 {
217 .callback = dmi_disable_osi_vista, 217 .callback = dmi_disable_osi_vista,
218 .ident = "VGN-SR19XN",
219 .matches = {
220 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
221 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR19XN"),
222 },
223 },
224 {
225 .callback = dmi_disable_osi_vista,
218 .ident = "Toshiba Satellite L355", 226 .ident = "Toshiba Satellite L355",
219 .matches = { 227 .matches = {
220 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 228 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index d9339b442a4e..a688aa243f6c 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -615,7 +615,7 @@ void acpi_dock_add(struct acpi_device *adev)
615 memset(&pdevinfo, 0, sizeof(pdevinfo)); 615 memset(&pdevinfo, 0, sizeof(pdevinfo));
616 pdevinfo.name = "dock"; 616 pdevinfo.name = "dock";
617 pdevinfo.id = dock_station_count; 617 pdevinfo.id = dock_station_count;
618 pdevinfo.acpi_node.companion = adev; 618 pdevinfo.fwnode = acpi_fwnode_handle(adev);
619 pdevinfo.data = &ds; 619 pdevinfo.data = &ds;
620 pdevinfo.size_data = sizeof(ds); 620 pdevinfo.size_data = sizeof(ds);
621 dd = platform_device_register_full(&pdevinfo); 621 dd = platform_device_register_full(&pdevinfo);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index a8dd2f763382..220d6406c9e9 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -137,6 +137,50 @@ static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
137static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ 137static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */
138 138
139/* -------------------------------------------------------------------------- 139/* --------------------------------------------------------------------------
140 * Logging/Debugging
141 * -------------------------------------------------------------------------- */
142
143/*
144 * Splitters used by the developers to track the boundary of the EC
145 * handling processes.
146 */
147#ifdef DEBUG
148#define EC_DBG_SEP " "
149#define EC_DBG_DRV "+++++"
150#define EC_DBG_STM "====="
151#define EC_DBG_REQ "*****"
152#define EC_DBG_EVT "#####"
153#else
154#define EC_DBG_SEP ""
155#define EC_DBG_DRV
156#define EC_DBG_STM
157#define EC_DBG_REQ
158#define EC_DBG_EVT
159#endif
160
161#define ec_log_raw(fmt, ...) \
162 pr_info(fmt "\n", ##__VA_ARGS__)
163#define ec_dbg_raw(fmt, ...) \
164 pr_debug(fmt "\n", ##__VA_ARGS__)
165#define ec_log(filter, fmt, ...) \
166 ec_log_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__)
167#define ec_dbg(filter, fmt, ...) \
168 ec_dbg_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__)
169
170#define ec_log_drv(fmt, ...) \
171 ec_log(EC_DBG_DRV, fmt, ##__VA_ARGS__)
172#define ec_dbg_drv(fmt, ...) \
173 ec_dbg(EC_DBG_DRV, fmt, ##__VA_ARGS__)
174#define ec_dbg_stm(fmt, ...) \
175 ec_dbg(EC_DBG_STM, fmt, ##__VA_ARGS__)
176#define ec_dbg_req(fmt, ...) \
177 ec_dbg(EC_DBG_REQ, fmt, ##__VA_ARGS__)
178#define ec_dbg_evt(fmt, ...) \
179 ec_dbg(EC_DBG_EVT, fmt, ##__VA_ARGS__)
180#define ec_dbg_ref(ec, fmt, ...) \
181 ec_dbg_raw("%lu: " fmt, ec->reference_count, ## __VA_ARGS__)
182
183/* --------------------------------------------------------------------------
140 * Device Flags 184 * Device Flags
141 * -------------------------------------------------------------------------- */ 185 * -------------------------------------------------------------------------- */
142 186
@@ -159,14 +203,14 @@ static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
159{ 203{
160 u8 x = inb(ec->command_addr); 204 u8 x = inb(ec->command_addr);
161 205
162 pr_debug("EC_SC(R) = 0x%2.2x " 206 ec_dbg_raw("EC_SC(R) = 0x%2.2x "
163 "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n", 207 "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d",
164 x, 208 x,
165 !!(x & ACPI_EC_FLAG_SCI), 209 !!(x & ACPI_EC_FLAG_SCI),
166 !!(x & ACPI_EC_FLAG_BURST), 210 !!(x & ACPI_EC_FLAG_BURST),
167 !!(x & ACPI_EC_FLAG_CMD), 211 !!(x & ACPI_EC_FLAG_CMD),
168 !!(x & ACPI_EC_FLAG_IBF), 212 !!(x & ACPI_EC_FLAG_IBF),
169 !!(x & ACPI_EC_FLAG_OBF)); 213 !!(x & ACPI_EC_FLAG_OBF));
170 return x; 214 return x;
171} 215}
172 216
@@ -175,20 +219,20 @@ static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
175 u8 x = inb(ec->data_addr); 219 u8 x = inb(ec->data_addr);
176 220
177 ec->curr->timestamp = jiffies; 221 ec->curr->timestamp = jiffies;
178 pr_debug("EC_DATA(R) = 0x%2.2x\n", x); 222 ec_dbg_raw("EC_DATA(R) = 0x%2.2x", x);
179 return x; 223 return x;
180} 224}
181 225
182static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) 226static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
183{ 227{
184 pr_debug("EC_SC(W) = 0x%2.2x\n", command); 228 ec_dbg_raw("EC_SC(W) = 0x%2.2x", command);
185 outb(command, ec->command_addr); 229 outb(command, ec->command_addr);
186 ec->curr->timestamp = jiffies; 230 ec->curr->timestamp = jiffies;
187} 231}
188 232
189static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) 233static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
190{ 234{
191 pr_debug("EC_DATA(W) = 0x%2.2x\n", data); 235 ec_dbg_raw("EC_DATA(W) = 0x%2.2x", data);
192 outb(data, ec->data_addr); 236 outb(data, ec->data_addr);
193 ec->curr->timestamp = jiffies; 237 ec->curr->timestamp = jiffies;
194} 238}
@@ -240,7 +284,7 @@ static inline void acpi_ec_enable_gpe(struct acpi_ec *ec, bool open)
240 * software need to manually trigger a pseudo GPE event on 284 * software need to manually trigger a pseudo GPE event on
241 * EN=1 writes. 285 * EN=1 writes.
242 */ 286 */
243 pr_debug("***** Polling quirk *****\n"); 287 ec_dbg_raw("Polling quirk");
244 advance_transaction(ec); 288 advance_transaction(ec);
245 } 289 }
246} 290}
@@ -299,7 +343,7 @@ static void acpi_ec_set_storm(struct acpi_ec *ec, u8 flag)
299{ 343{
300 if (!test_bit(flag, &ec->flags)) { 344 if (!test_bit(flag, &ec->flags)) {
301 acpi_ec_disable_gpe(ec, false); 345 acpi_ec_disable_gpe(ec, false);
302 pr_debug("+++++ Polling enabled +++++\n"); 346 ec_dbg_drv("Polling enabled");
303 set_bit(flag, &ec->flags); 347 set_bit(flag, &ec->flags);
304 } 348 }
305} 349}
@@ -309,7 +353,7 @@ static void acpi_ec_clear_storm(struct acpi_ec *ec, u8 flag)
309 if (test_bit(flag, &ec->flags)) { 353 if (test_bit(flag, &ec->flags)) {
310 clear_bit(flag, &ec->flags); 354 clear_bit(flag, &ec->flags);
311 acpi_ec_enable_gpe(ec, false); 355 acpi_ec_enable_gpe(ec, false);
312 pr_debug("+++++ Polling disabled +++++\n"); 356 ec_dbg_drv("Polling disabled");
313 } 357 }
314} 358}
315 359
@@ -335,7 +379,7 @@ static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec)
335static void acpi_ec_submit_query(struct acpi_ec *ec) 379static void acpi_ec_submit_query(struct acpi_ec *ec)
336{ 380{
337 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { 381 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) {
338 pr_debug("***** Event started *****\n"); 382 ec_dbg_req("Event started");
339 schedule_work(&ec->work); 383 schedule_work(&ec->work);
340 } 384 }
341} 385}
@@ -344,7 +388,7 @@ static void acpi_ec_complete_query(struct acpi_ec *ec)
344{ 388{
345 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 389 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
346 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 390 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
347 pr_debug("***** Event stopped *****\n"); 391 ec_dbg_req("Event stopped");
348 } 392 }
349} 393}
350 394
@@ -366,8 +410,8 @@ static void advance_transaction(struct acpi_ec *ec)
366 u8 status; 410 u8 status;
367 bool wakeup = false; 411 bool wakeup = false;
368 412
369 pr_debug("===== %s (%d) =====\n", 413 ec_dbg_stm("%s (%d)", in_interrupt() ? "IRQ" : "TASK",
370 in_interrupt() ? "IRQ" : "TASK", smp_processor_id()); 414 smp_processor_id());
371 /* 415 /*
372 * By always clearing STS before handling all indications, we can 416 * By always clearing STS before handling all indications, we can
373 * ensure a hardware STS 0->1 change after this clearing can always 417 * ensure a hardware STS 0->1 change after this clearing can always
@@ -390,8 +434,8 @@ static void advance_transaction(struct acpi_ec *ec)
390 if (t->rlen == t->ri) { 434 if (t->rlen == t->ri) {
391 t->flags |= ACPI_EC_COMMAND_COMPLETE; 435 t->flags |= ACPI_EC_COMMAND_COMPLETE;
392 if (t->command == ACPI_EC_COMMAND_QUERY) 436 if (t->command == ACPI_EC_COMMAND_QUERY)
393 pr_debug("***** Command(%s) hardware completion *****\n", 437 ec_dbg_req("Command(%s) hardware completion",
394 acpi_ec_cmd_string(t->command)); 438 acpi_ec_cmd_string(t->command));
395 wakeup = true; 439 wakeup = true;
396 } 440 }
397 } else 441 } else
@@ -410,8 +454,8 @@ static void advance_transaction(struct acpi_ec *ec)
410 acpi_ec_complete_query(ec); 454 acpi_ec_complete_query(ec);
411 t->rdata[t->ri++] = 0x00; 455 t->rdata[t->ri++] = 0x00;
412 t->flags |= ACPI_EC_COMMAND_COMPLETE; 456 t->flags |= ACPI_EC_COMMAND_COMPLETE;
413 pr_debug("***** Command(%s) software completion *****\n", 457 ec_dbg_req("Command(%s) software completion",
414 acpi_ec_cmd_string(t->command)); 458 acpi_ec_cmd_string(t->command));
415 wakeup = true; 459 wakeup = true;
416 } else if ((status & ACPI_EC_FLAG_IBF) == 0) { 460 } else if ((status & ACPI_EC_FLAG_IBF) == 0) {
417 acpi_ec_write_cmd(ec, t->command); 461 acpi_ec_write_cmd(ec, t->command);
@@ -502,21 +546,21 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
502 ret = -EINVAL; 546 ret = -EINVAL;
503 goto unlock; 547 goto unlock;
504 } 548 }
549 ec_dbg_ref(ec, "Increase command");
505 /* following two actions should be kept atomic */ 550 /* following two actions should be kept atomic */
506 ec->curr = t; 551 ec->curr = t;
507 pr_debug("***** Command(%s) started *****\n", 552 ec_dbg_req("Command(%s) started", acpi_ec_cmd_string(t->command));
508 acpi_ec_cmd_string(t->command));
509 start_transaction(ec); 553 start_transaction(ec);
510 spin_unlock_irqrestore(&ec->lock, tmp); 554 spin_unlock_irqrestore(&ec->lock, tmp);
511 ret = ec_poll(ec); 555 ret = ec_poll(ec);
512 spin_lock_irqsave(&ec->lock, tmp); 556 spin_lock_irqsave(&ec->lock, tmp);
513 if (t->irq_count == ec_storm_threshold) 557 if (t->irq_count == ec_storm_threshold)
514 acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); 558 acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM);
515 pr_debug("***** Command(%s) stopped *****\n", 559 ec_dbg_req("Command(%s) stopped", acpi_ec_cmd_string(t->command));
516 acpi_ec_cmd_string(t->command));
517 ec->curr = NULL; 560 ec->curr = NULL;
518 /* Disable GPE for command processing (IBF=0/OBF=1) */ 561 /* Disable GPE for command processing (IBF=0/OBF=1) */
519 acpi_ec_complete_request(ec); 562 acpi_ec_complete_request(ec);
563 ec_dbg_ref(ec, "Decrease command");
520unlock: 564unlock:
521 spin_unlock_irqrestore(&ec->lock, tmp); 565 spin_unlock_irqrestore(&ec->lock, tmp);
522 return ret; 566 return ret;
@@ -676,11 +720,13 @@ static void acpi_ec_start(struct acpi_ec *ec, bool resuming)
676 720
677 spin_lock_irqsave(&ec->lock, flags); 721 spin_lock_irqsave(&ec->lock, flags);
678 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { 722 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) {
679 pr_debug("+++++ Starting EC +++++\n"); 723 ec_dbg_drv("Starting EC");
680 /* Enable GPE for event processing (SCI_EVT=1) */ 724 /* Enable GPE for event processing (SCI_EVT=1) */
681 if (!resuming) 725 if (!resuming) {
682 acpi_ec_submit_request(ec); 726 acpi_ec_submit_request(ec);
683 pr_debug("EC started\n"); 727 ec_dbg_ref(ec, "Increase driver");
728 }
729 ec_log_drv("EC started");
684 } 730 }
685 spin_unlock_irqrestore(&ec->lock, flags); 731 spin_unlock_irqrestore(&ec->lock, flags);
686} 732}
@@ -702,17 +748,19 @@ static void acpi_ec_stop(struct acpi_ec *ec, bool suspending)
702 748
703 spin_lock_irqsave(&ec->lock, flags); 749 spin_lock_irqsave(&ec->lock, flags);
704 if (acpi_ec_started(ec)) { 750 if (acpi_ec_started(ec)) {
705 pr_debug("+++++ Stopping EC +++++\n"); 751 ec_dbg_drv("Stopping EC");
706 set_bit(EC_FLAGS_STOPPED, &ec->flags); 752 set_bit(EC_FLAGS_STOPPED, &ec->flags);
707 spin_unlock_irqrestore(&ec->lock, flags); 753 spin_unlock_irqrestore(&ec->lock, flags);
708 wait_event(ec->wait, acpi_ec_stopped(ec)); 754 wait_event(ec->wait, acpi_ec_stopped(ec));
709 spin_lock_irqsave(&ec->lock, flags); 755 spin_lock_irqsave(&ec->lock, flags);
710 /* Disable GPE for event processing (SCI_EVT=1) */ 756 /* Disable GPE for event processing (SCI_EVT=1) */
711 if (!suspending) 757 if (!suspending) {
712 acpi_ec_complete_request(ec); 758 acpi_ec_complete_request(ec);
759 ec_dbg_ref(ec, "Decrease driver");
760 }
713 clear_bit(EC_FLAGS_STARTED, &ec->flags); 761 clear_bit(EC_FLAGS_STARTED, &ec->flags);
714 clear_bit(EC_FLAGS_STOPPED, &ec->flags); 762 clear_bit(EC_FLAGS_STOPPED, &ec->flags);
715 pr_debug("EC stopped\n"); 763 ec_log_drv("EC stopped");
716 } 764 }
717 spin_unlock_irqrestore(&ec->lock, flags); 765 spin_unlock_irqrestore(&ec->lock, flags);
718} 766}
@@ -824,12 +872,12 @@ static void acpi_ec_run(void *cxt)
824 872
825 if (!handler) 873 if (!handler)
826 return; 874 return;
827 pr_debug("##### Query(0x%02x) started #####\n", handler->query_bit); 875 ec_dbg_evt("Query(0x%02x) started", handler->query_bit);
828 if (handler->func) 876 if (handler->func)
829 handler->func(handler->data); 877 handler->func(handler->data);
830 else if (handler->handle) 878 else if (handler->handle)
831 acpi_evaluate_object(handler->handle, NULL, NULL, NULL); 879 acpi_evaluate_object(handler->handle, NULL, NULL, NULL);
832 pr_debug("##### Query(0x%02x) stopped #####\n", handler->query_bit); 880 ec_dbg_evt("Query(0x%02x) stopped", handler->query_bit);
833 acpi_ec_put_query_handler(handler); 881 acpi_ec_put_query_handler(handler);
834} 882}
835 883
@@ -861,8 +909,8 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
861 if (value == handler->query_bit) { 909 if (value == handler->query_bit) {
862 /* have custom handler for this bit */ 910 /* have custom handler for this bit */
863 handler = acpi_ec_get_query_handler(handler); 911 handler = acpi_ec_get_query_handler(handler);
864 pr_debug("##### Query(0x%02x) scheduled #####\n", 912 ec_dbg_evt("Query(0x%02x) scheduled",
865 handler->query_bit); 913 handler->query_bit);
866 status = acpi_os_execute((handler->func) ? 914 status = acpi_os_execute((handler->func) ?
867 OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, 915 OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER,
868 acpi_ec_run, handler); 916 acpi_ec_run, handler);
@@ -1099,6 +1147,9 @@ static int acpi_ec_add(struct acpi_device *device)
1099 1147
1100 ret = ec_install_handlers(ec); 1148 ret = ec_install_handlers(ec);
1101 1149
1150 /* Reprobe devices depending on the EC */
1151 acpi_walk_dep_device_list(ec->handle);
1152
1102 /* EC is fully operational, allow queries */ 1153 /* EC is fully operational, allow queries */
1103 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 1154 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
1104 1155
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index f774c65ecb8b..39c485b0c25c 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
168 unsigned int node_id; 168 unsigned int node_id;
169 int retval = -EINVAL; 169 int retval = -EINVAL;
170 170
171 if (ACPI_COMPANION(dev)) { 171 if (has_acpi_companion(dev)) {
172 if (acpi_dev) { 172 if (acpi_dev) {
173 dev_warn(dev, "ACPI companion already set\n"); 173 dev_warn(dev, "ACPI companion already set\n");
174 return -EINVAL; 174 return -EINVAL;
@@ -220,7 +220,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
220 list_add(&physical_node->node, physnode_list); 220 list_add(&physical_node->node, physnode_list);
221 acpi_dev->physical_node_count++; 221 acpi_dev->physical_node_count++;
222 222
223 if (!ACPI_COMPANION(dev)) 223 if (!has_acpi_companion(dev))
224 ACPI_COMPANION_SET(dev, acpi_dev); 224 ACPI_COMPANION_SET(dev, acpi_dev);
225 225
226 acpi_physnode_link_name(physical_node_name, node_id); 226 acpi_physnode_link_name(physical_node_name, node_id);
diff --git a/drivers/acpi/pmic/intel_pmic_crc.c b/drivers/acpi/pmic/intel_pmic_crc.c
index ef7d8ff95abe..42df46a86c25 100644
--- a/drivers/acpi/pmic/intel_pmic_crc.c
+++ b/drivers/acpi/pmic/intel_pmic_crc.c
@@ -207,5 +207,5 @@ static int __init intel_crc_pmic_opregion_driver_init(void)
207} 207}
208module_init(intel_crc_pmic_opregion_driver_init); 208module_init(intel_crc_pmic_opregion_driver_init);
209 209
210MODULE_DESCRIPTION("CrystalCove ACPI opration region driver"); 210MODULE_DESCRIPTION("CrystalCove ACPI operation region driver");
211MODULE_LICENSE("GPL"); 211MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index bbca7830e18a..d2e3c3e3f9c9 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -114,7 +114,12 @@ int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
114 return 0; 114 return 0;
115} 115}
116 116
117/* 117/**
118 * create_pnp_modalias - Create hid/cid(s) string for modalias and uevent
119 * @acpi_dev: ACPI device object.
120 * @modalias: Buffer to print into.
121 * @size: Size of the buffer.
122 *
118 * Creates hid/cid(s) string needed for modalias and uevent 123 * Creates hid/cid(s) string needed for modalias and uevent
119 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get: 124 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
120 * char *modalias: "acpi:IBM0001:ACPI0001" 125 * char *modalias: "acpi:IBM0001:ACPI0001"
@@ -122,68 +127,98 @@ int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
122 * -EINVAL: output error 127 * -EINVAL: output error
123 * -ENOMEM: output is truncated 128 * -ENOMEM: output is truncated
124*/ 129*/
125static int create_modalias(struct acpi_device *acpi_dev, char *modalias, 130static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
126 int size) 131 int size)
127{ 132{
128 int len; 133 int len;
129 int count; 134 int count;
130 struct acpi_hardware_id *id; 135 struct acpi_hardware_id *id;
131 136
132 if (list_empty(&acpi_dev->pnp.ids))
133 return 0;
134
135 /* 137 /*
136 * If the device has PRP0001 we expose DT compatible modalias 138 * Since we skip PRP0001 from the modalias below, 0 should be returned
137 * instead in form of of:NnameTCcompatible. 139 * if PRP0001 is the only ACPI/PNP ID in the device's list.
138 */ 140 */
139 if (acpi_dev->data.of_compatible) { 141 count = 0;
140 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER }; 142 list_for_each_entry(id, &acpi_dev->pnp.ids, list)
141 const union acpi_object *of_compatible, *obj; 143 if (strcmp(id->id, "PRP0001"))
142 int i, nval; 144 count++;
143 char *c;
144
145 acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
146 /* DT strings are all in lower case */
147 for (c = buf.pointer; *c != '\0'; c++)
148 *c = tolower(*c);
149
150 len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
151 ACPI_FREE(buf.pointer);
152
153 of_compatible = acpi_dev->data.of_compatible;
154 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
155 nval = of_compatible->package.count;
156 obj = of_compatible->package.elements;
157 } else { /* Must be ACPI_TYPE_STRING. */
158 nval = 1;
159 obj = of_compatible;
160 }
161 for (i = 0; i < nval; i++, obj++) {
162 count = snprintf(&modalias[len], size, "C%s",
163 obj->string.pointer);
164 if (count < 0)
165 return -EINVAL;
166 if (count >= size)
167 return -ENOMEM;
168
169 len += count;
170 size -= count;
171 }
172 } else {
173 len = snprintf(modalias, size, "acpi:");
174 size -= len;
175 145
176 list_for_each_entry(id, &acpi_dev->pnp.ids, list) { 146 if (!count)
177 count = snprintf(&modalias[len], size, "%s:", id->id); 147 return 0;
178 if (count < 0) 148
179 return -EINVAL; 149 len = snprintf(modalias, size, "acpi:");
180 if (count >= size) 150 if (len <= 0)
181 return -ENOMEM; 151 return len;
182 len += count; 152
183 size -= count; 153 size -= len;
184 } 154
155 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
156 if (!strcmp(id->id, "PRP0001"))
157 continue;
158
159 count = snprintf(&modalias[len], size, "%s:", id->id);
160 if (count < 0)
161 return -EINVAL;
162
163 if (count >= size)
164 return -ENOMEM;
165
166 len += count;
167 size -= count;
185 } 168 }
169 modalias[len] = '\0';
170 return len;
171}
186 172
173/**
174 * create_of_modalias - Creates DT compatible string for modalias and uevent
175 * @acpi_dev: ACPI device object.
176 * @modalias: Buffer to print into.
177 * @size: Size of the buffer.
178 *
179 * Expose DT compatible modalias as of:NnameTCcompatible. This function should
180 * only be called for devices having PRP0001 in their list of ACPI/PNP IDs.
181 */
182static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
183 int size)
184{
185 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
186 const union acpi_object *of_compatible, *obj;
187 int len, count;
188 int i, nval;
189 char *c;
190
191 acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
192 /* DT strings are all in lower case */
193 for (c = buf.pointer; *c != '\0'; c++)
194 *c = tolower(*c);
195
196 len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
197 ACPI_FREE(buf.pointer);
198
199 if (len <= 0)
200 return len;
201
202 of_compatible = acpi_dev->data.of_compatible;
203 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
204 nval = of_compatible->package.count;
205 obj = of_compatible->package.elements;
206 } else { /* Must be ACPI_TYPE_STRING. */
207 nval = 1;
208 obj = of_compatible;
209 }
210 for (i = 0; i < nval; i++, obj++) {
211 count = snprintf(&modalias[len], size, "C%s",
212 obj->string.pointer);
213 if (count < 0)
214 return -EINVAL;
215
216 if (count >= size)
217 return -ENOMEM;
218
219 len += count;
220 size -= count;
221 }
187 modalias[len] = '\0'; 222 modalias[len] = '\0';
188 return len; 223 return len;
189} 224}
@@ -194,7 +229,8 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
194 * 229 *
195 * Check if the given device has an ACPI companion and if that companion has 230 * Check if the given device has an ACPI companion and if that companion has
196 * a valid list of PNP IDs, and if the device is the first (primary) physical 231 * a valid list of PNP IDs, and if the device is the first (primary) physical
197 * device associated with it. 232 * device associated with it. Return the companion pointer if that's the case
233 * or NULL otherwise.
198 * 234 *
199 * If multiple physical devices are attached to a single ACPI companion, we need 235 * If multiple physical devices are attached to a single ACPI companion, we need
200 * to be careful. The usage scenario for this kind of relationship is that all 236 * to be careful. The usage scenario for this kind of relationship is that all
@@ -208,88 +244,127 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
208 * resources available from it but they will be matched normally using functions 244 * resources available from it but they will be matched normally using functions
209 * provided by their bus types (and analogously for their modalias). 245 * provided by their bus types (and analogously for their modalias).
210 */ 246 */
211static bool acpi_companion_match(const struct device *dev) 247static struct acpi_device *acpi_companion_match(const struct device *dev)
212{ 248{
213 struct acpi_device *adev; 249 struct acpi_device *adev;
214 bool ret;
215 250
216 adev = ACPI_COMPANION(dev); 251 adev = ACPI_COMPANION(dev);
217 if (!adev) 252 if (!adev)
218 return false; 253 return NULL;
219 254
220 if (list_empty(&adev->pnp.ids)) 255 if (list_empty(&adev->pnp.ids))
221 return false; 256 return NULL;
222 257
223 mutex_lock(&adev->physical_node_lock); 258 mutex_lock(&adev->physical_node_lock);
224 if (list_empty(&adev->physical_node_list)) { 259 if (list_empty(&adev->physical_node_list)) {
225 ret = false; 260 adev = NULL;
226 } else { 261 } else {
227 const struct acpi_device_physical_node *node; 262 const struct acpi_device_physical_node *node;
228 263
229 node = list_first_entry(&adev->physical_node_list, 264 node = list_first_entry(&adev->physical_node_list,
230 struct acpi_device_physical_node, node); 265 struct acpi_device_physical_node, node);
231 ret = node->dev == dev; 266 if (node->dev != dev)
267 adev = NULL;
232 } 268 }
233 mutex_unlock(&adev->physical_node_lock); 269 mutex_unlock(&adev->physical_node_lock);
234 270
235 return ret; 271 return adev;
236} 272}
237 273
238/* 274static int __acpi_device_uevent_modalias(struct acpi_device *adev,
239 * Creates uevent modalias field for ACPI enumerated devices. 275 struct kobj_uevent_env *env)
240 * Because the other buses does not support ACPI HIDs & CIDs.
241 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
242 * "acpi:IBM0001:ACPI0001"
243 */
244int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
245{ 276{
246 int len; 277 int len;
247 278
248 if (!acpi_companion_match(dev)) 279 if (!adev)
249 return -ENODEV; 280 return -ENODEV;
250 281
282 if (list_empty(&adev->pnp.ids))
283 return 0;
284
251 if (add_uevent_var(env, "MODALIAS=")) 285 if (add_uevent_var(env, "MODALIAS="))
252 return -ENOMEM; 286 return -ENOMEM;
253 len = create_modalias(ACPI_COMPANION(dev), &env->buf[env->buflen - 1], 287
254 sizeof(env->buf) - env->buflen); 288 len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
255 if (len <= 0) 289 sizeof(env->buf) - env->buflen);
290 if (len < 0)
291 return len;
292
293 env->buflen += len;
294 if (!adev->data.of_compatible)
295 return 0;
296
297 if (len > 0 && add_uevent_var(env, "MODALIAS="))
298 return -ENOMEM;
299
300 len = create_of_modalias(adev, &env->buf[env->buflen - 1],
301 sizeof(env->buf) - env->buflen);
302 if (len < 0)
256 return len; 303 return len;
304
257 env->buflen += len; 305 env->buflen += len;
306
258 return 0; 307 return 0;
259} 308}
260EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
261 309
262/* 310/*
263 * Creates modalias sysfs attribute for ACPI enumerated devices. 311 * Creates uevent modalias field for ACPI enumerated devices.
264 * Because the other buses does not support ACPI HIDs & CIDs. 312 * Because the other buses does not support ACPI HIDs & CIDs.
265 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get: 313 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
266 * "acpi:IBM0001:ACPI0001" 314 * "acpi:IBM0001:ACPI0001"
267 */ 315 */
268int acpi_device_modalias(struct device *dev, char *buf, int size) 316int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
269{ 317{
270 int len; 318 return __acpi_device_uevent_modalias(acpi_companion_match(dev), env);
319}
320EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
321
322static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
323{
324 int len, count;
271 325
272 if (!acpi_companion_match(dev)) 326 if (!adev)
273 return -ENODEV; 327 return -ENODEV;
274 328
275 len = create_modalias(ACPI_COMPANION(dev), buf, size -1); 329 if (list_empty(&adev->pnp.ids))
276 if (len <= 0) 330 return 0;
331
332 len = create_pnp_modalias(adev, buf, size - 1);
333 if (len < 0) {
334 return len;
335 } else if (len > 0) {
336 buf[len++] = '\n';
337 size -= len;
338 }
339 if (!adev->data.of_compatible)
277 return len; 340 return len;
278 buf[len++] = '\n'; 341
342 count = create_of_modalias(adev, buf + len, size - 1);
343 if (count < 0) {
344 return count;
345 } else if (count > 0) {
346 len += count;
347 buf[len++] = '\n';
348 }
349
279 return len; 350 return len;
280} 351}
352
353/*
354 * Creates modalias sysfs attribute for ACPI enumerated devices.
355 * Because the other buses does not support ACPI HIDs & CIDs.
356 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
357 * "acpi:IBM0001:ACPI0001"
358 */
359int acpi_device_modalias(struct device *dev, char *buf, int size)
360{
361 return __acpi_device_modalias(acpi_companion_match(dev), buf, size);
362}
281EXPORT_SYMBOL_GPL(acpi_device_modalias); 363EXPORT_SYMBOL_GPL(acpi_device_modalias);
282 364
283static ssize_t 365static ssize_t
284acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { 366acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
285 struct acpi_device *acpi_dev = to_acpi_device(dev); 367 return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
286 int len;
287
288 len = create_modalias(acpi_dev, buf, 1024);
289 if (len <= 0)
290 return len;
291 buf[len++] = '\n';
292 return len;
293} 368}
294static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); 369static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
295 370
@@ -894,8 +969,51 @@ static void acpi_device_remove_files(struct acpi_device *dev)
894 ACPI Bus operations 969 ACPI Bus operations
895 -------------------------------------------------------------------------- */ 970 -------------------------------------------------------------------------- */
896 971
972/**
973 * acpi_of_match_device - Match device object using the "compatible" property.
974 * @adev: ACPI device object to match.
975 * @of_match_table: List of device IDs to match against.
976 *
977 * If @dev has an ACPI companion which has the special PRP0001 device ID in its
978 * list of identifiers and a _DSD object with the "compatible" property, use
979 * that property to match against the given list of identifiers.
980 */
981static bool acpi_of_match_device(struct acpi_device *adev,
982 const struct of_device_id *of_match_table)
983{
984 const union acpi_object *of_compatible, *obj;
985 int i, nval;
986
987 if (!adev)
988 return false;
989
990 of_compatible = adev->data.of_compatible;
991 if (!of_match_table || !of_compatible)
992 return false;
993
994 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
995 nval = of_compatible->package.count;
996 obj = of_compatible->package.elements;
997 } else { /* Must be ACPI_TYPE_STRING. */
998 nval = 1;
999 obj = of_compatible;
1000 }
1001 /* Now we can look for the driver DT compatible strings */
1002 for (i = 0; i < nval; i++, obj++) {
1003 const struct of_device_id *id;
1004
1005 for (id = of_match_table; id->compatible[0]; id++)
1006 if (!strcasecmp(obj->string.pointer, id->compatible))
1007 return true;
1008 }
1009
1010 return false;
1011}
1012
897static const struct acpi_device_id *__acpi_match_device( 1013static const struct acpi_device_id *__acpi_match_device(
898 struct acpi_device *device, const struct acpi_device_id *ids) 1014 struct acpi_device *device,
1015 const struct acpi_device_id *ids,
1016 const struct of_device_id *of_ids)
899{ 1017{
900 const struct acpi_device_id *id; 1018 const struct acpi_device_id *id;
901 struct acpi_hardware_id *hwid; 1019 struct acpi_hardware_id *hwid;
@@ -904,14 +1022,27 @@ static const struct acpi_device_id *__acpi_match_device(
904 * If the device is not present, it is unnecessary to load device 1022 * If the device is not present, it is unnecessary to load device
905 * driver for it. 1023 * driver for it.
906 */ 1024 */
907 if (!device->status.present) 1025 if (!device || !device->status.present)
908 return NULL; 1026 return NULL;
909 1027
910 for (id = ids; id->id[0]; id++) 1028 list_for_each_entry(hwid, &device->pnp.ids, list) {
911 list_for_each_entry(hwid, &device->pnp.ids, list) 1029 /* First, check the ACPI/PNP IDs provided by the caller. */
1030 for (id = ids; id->id[0]; id++)
912 if (!strcmp((char *) id->id, hwid->id)) 1031 if (!strcmp((char *) id->id, hwid->id))
913 return id; 1032 return id;
914 1033
1034 /*
1035 * Next, check the special "PRP0001" ID and try to match the
1036 * "compatible" property if found.
1037 *
1038 * The id returned by the below is not valid, but the only
1039 * caller passing non-NULL of_ids here is only interested in
1040 * whether or not the return value is NULL.
1041 */
1042 if (!strcmp("PRP0001", hwid->id)
1043 && acpi_of_match_device(device, of_ids))
1044 return id;
1045 }
915 return NULL; 1046 return NULL;
916} 1047}
917 1048
@@ -929,68 +1060,26 @@ static const struct acpi_device_id *__acpi_match_device(
929const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, 1060const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
930 const struct device *dev) 1061 const struct device *dev)
931{ 1062{
932 struct acpi_device *adev; 1063 return __acpi_match_device(acpi_companion_match(dev), ids, NULL);
933 acpi_handle handle = ACPI_HANDLE(dev);
934
935 if (!ids || !handle || acpi_bus_get_device(handle, &adev))
936 return NULL;
937
938 if (!acpi_companion_match(dev))
939 return NULL;
940
941 return __acpi_match_device(adev, ids);
942} 1064}
943EXPORT_SYMBOL_GPL(acpi_match_device); 1065EXPORT_SYMBOL_GPL(acpi_match_device);
944 1066
945int acpi_match_device_ids(struct acpi_device *device, 1067int acpi_match_device_ids(struct acpi_device *device,
946 const struct acpi_device_id *ids) 1068 const struct acpi_device_id *ids)
947{ 1069{
948 return __acpi_match_device(device, ids) ? 0 : -ENOENT; 1070 return __acpi_match_device(device, ids, NULL) ? 0 : -ENOENT;
949} 1071}
950EXPORT_SYMBOL(acpi_match_device_ids); 1072EXPORT_SYMBOL(acpi_match_device_ids);
951 1073
952/* Performs match against special "PRP0001" shoehorn ACPI ID */
953static bool acpi_of_driver_match_device(struct device *dev,
954 const struct device_driver *drv)
955{
956 const union acpi_object *of_compatible, *obj;
957 struct acpi_device *adev;
958 int i, nval;
959
960 adev = ACPI_COMPANION(dev);
961 if (!adev)
962 return false;
963
964 of_compatible = adev->data.of_compatible;
965 if (!drv->of_match_table || !of_compatible)
966 return false;
967
968 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
969 nval = of_compatible->package.count;
970 obj = of_compatible->package.elements;
971 } else { /* Must be ACPI_TYPE_STRING. */
972 nval = 1;
973 obj = of_compatible;
974 }
975 /* Now we can look for the driver DT compatible strings */
976 for (i = 0; i < nval; i++, obj++) {
977 const struct of_device_id *id;
978
979 for (id = drv->of_match_table; id->compatible[0]; id++)
980 if (!strcasecmp(obj->string.pointer, id->compatible))
981 return true;
982 }
983
984 return false;
985}
986
987bool acpi_driver_match_device(struct device *dev, 1074bool acpi_driver_match_device(struct device *dev,
988 const struct device_driver *drv) 1075 const struct device_driver *drv)
989{ 1076{
990 if (!drv->acpi_match_table) 1077 if (!drv->acpi_match_table)
991 return acpi_of_driver_match_device(dev, drv); 1078 return acpi_of_match_device(ACPI_COMPANION(dev),
1079 drv->of_match_table);
992 1080
993 return !!acpi_match_device(drv->acpi_match_table, dev); 1081 return !!__acpi_match_device(acpi_companion_match(dev),
1082 drv->acpi_match_table, drv->of_match_table);
994} 1083}
995EXPORT_SYMBOL_GPL(acpi_driver_match_device); 1084EXPORT_SYMBOL_GPL(acpi_driver_match_device);
996 1085
@@ -1031,20 +1120,7 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
1031 1120
1032static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) 1121static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
1033{ 1122{
1034 struct acpi_device *acpi_dev = to_acpi_device(dev); 1123 return __acpi_device_uevent_modalias(to_acpi_device(dev), env);
1035 int len;
1036
1037 if (list_empty(&acpi_dev->pnp.ids))
1038 return 0;
1039
1040 if (add_uevent_var(env, "MODALIAS="))
1041 return -ENOMEM;
1042 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1],
1043 sizeof(env->buf) - env->buflen);
1044 if (len <= 0)
1045 return len;
1046 env->buflen += len;
1047 return 0;
1048} 1124}
1049 1125
1050static void acpi_device_notify(acpi_handle handle, u32 event, void *data) 1126static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
@@ -1062,10 +1138,10 @@ static void acpi_device_notify_fixed(void *data)
1062 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); 1138 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
1063} 1139}
1064 1140
1065static acpi_status acpi_device_fixed_event(void *data) 1141static u32 acpi_device_fixed_event(void *data)
1066{ 1142{
1067 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data); 1143 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
1068 return AE_OK; 1144 return ACPI_INTERRUPT_HANDLED;
1069} 1145}
1070 1146
1071static int acpi_device_install_notify_handler(struct acpi_device *device) 1147static int acpi_device_install_notify_handler(struct acpi_device *device)
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 7f251dd1a687..2f0d4db40a9e 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -629,6 +629,7 @@ static int acpi_freeze_begin(void)
629 629
630static int acpi_freeze_prepare(void) 630static int acpi_freeze_prepare(void)
631{ 631{
632 acpi_enable_wakeup_devices(ACPI_STATE_S0);
632 acpi_enable_all_wakeup_gpes(); 633 acpi_enable_all_wakeup_gpes();
633 acpi_os_wait_events_complete(); 634 acpi_os_wait_events_complete();
634 enable_irq_wake(acpi_gbl_FADT.sci_interrupt); 635 enable_irq_wake(acpi_gbl_FADT.sci_interrupt);
@@ -637,6 +638,7 @@ static int acpi_freeze_prepare(void)
637 638
638static void acpi_freeze_restore(void) 639static void acpi_freeze_restore(void)
639{ 640{
641 acpi_disable_wakeup_devices(ACPI_STATE_S0);
640 disable_irq_wake(acpi_gbl_FADT.sci_interrupt); 642 disable_irq_wake(acpi_gbl_FADT.sci_interrupt);
641 acpi_enable_all_runtime_gpes(); 643 acpi_enable_all_runtime_gpes();
642} 644}
@@ -806,21 +808,6 @@ static void acpi_sleep_hibernate_setup(void)
806static inline void acpi_sleep_hibernate_setup(void) {} 808static inline void acpi_sleep_hibernate_setup(void) {}
807#endif /* !CONFIG_HIBERNATION */ 809#endif /* !CONFIG_HIBERNATION */
808 810
809int acpi_suspend(u32 acpi_state)
810{
811 suspend_state_t states[] = {
812 [1] = PM_SUSPEND_STANDBY,
813 [3] = PM_SUSPEND_MEM,
814 [5] = PM_SUSPEND_MAX
815 };
816
817 if (acpi_state < 6 && states[acpi_state])
818 return pm_suspend(states[acpi_state]);
819 if (acpi_state == 4)
820 return hibernate();
821 return -EINVAL;
822}
823
824static void acpi_power_off_prepare(void) 811static void acpi_power_off_prepare(void)
825{ 812{
826 /* Prepare to power off the system */ 813 /* Prepare to power off the system */
diff --git a/drivers/acpi/sleep.h b/drivers/acpi/sleep.h
index 0143540a2519..c797ffa568d5 100644
--- a/drivers/acpi/sleep.h
+++ b/drivers/acpi/sleep.h
@@ -1,6 +1,4 @@
1 1
2extern int acpi_suspend(u32 state);
3
4extern void acpi_enable_wakeup_devices(u8 sleep_state); 2extern void acpi_enable_wakeup_devices(u8 sleep_state);
5extern void acpi_disable_wakeup_devices(u8 sleep_state); 3extern void acpi_disable_wakeup_devices(u8 sleep_state);
6 4
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 13e577c80201..0876d77b3206 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -527,7 +527,7 @@ static ssize_t counter_show(struct kobject *kobj,
527 acpi_irq_not_handled; 527 acpi_irq_not_handled;
528 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count = 528 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count =
529 acpi_gpe_count; 529 acpi_gpe_count;
530 size = sprintf(buf, "%8d", all_counters[index].count); 530 size = sprintf(buf, "%8u", all_counters[index].count);
531 531
532 /* "gpe_all" or "sci" */ 532 /* "gpe_all" or "sci" */
533 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS) 533 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 26eb70c8f518..cc79d3fedfb2 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -82,9 +82,15 @@ module_param(allow_duplicates, bool, 0644);
82 * For Windows 8 systems: used to decide if video module 82 * For Windows 8 systems: used to decide if video module
83 * should skip registering backlight interface of its own. 83 * should skip registering backlight interface of its own.
84 */ 84 */
85static int use_native_backlight_param = -1; 85enum {
86 NATIVE_BACKLIGHT_NOT_SET = -1,
87 NATIVE_BACKLIGHT_OFF,
88 NATIVE_BACKLIGHT_ON,
89};
90
91static int use_native_backlight_param = NATIVE_BACKLIGHT_NOT_SET;
86module_param_named(use_native_backlight, use_native_backlight_param, int, 0444); 92module_param_named(use_native_backlight, use_native_backlight_param, int, 0444);
87static bool use_native_backlight_dmi = true; 93static int use_native_backlight_dmi = NATIVE_BACKLIGHT_NOT_SET;
88 94
89static int register_count; 95static int register_count;
90static struct mutex video_list_lock; 96static struct mutex video_list_lock;
@@ -237,15 +243,16 @@ static void acpi_video_switch_brightness(struct work_struct *work);
237 243
238static bool acpi_video_use_native_backlight(void) 244static bool acpi_video_use_native_backlight(void)
239{ 245{
240 if (use_native_backlight_param != -1) 246 if (use_native_backlight_param != NATIVE_BACKLIGHT_NOT_SET)
241 return use_native_backlight_param; 247 return use_native_backlight_param;
242 else 248 else if (use_native_backlight_dmi != NATIVE_BACKLIGHT_NOT_SET)
243 return use_native_backlight_dmi; 249 return use_native_backlight_dmi;
250 return acpi_osi_is_win8();
244} 251}
245 252
246bool acpi_video_verify_backlight_support(void) 253bool acpi_video_verify_backlight_support(void)
247{ 254{
248 if (acpi_osi_is_win8() && acpi_video_use_native_backlight() && 255 if (acpi_video_use_native_backlight() &&
249 backlight_device_registered(BACKLIGHT_RAW)) 256 backlight_device_registered(BACKLIGHT_RAW))
250 return false; 257 return false;
251 return acpi_video_backlight_support(); 258 return acpi_video_backlight_support();
@@ -414,7 +421,13 @@ static int __init video_set_bqc_offset(const struct dmi_system_id *d)
414 421
415static int __init video_disable_native_backlight(const struct dmi_system_id *d) 422static int __init video_disable_native_backlight(const struct dmi_system_id *d)
416{ 423{
417 use_native_backlight_dmi = false; 424 use_native_backlight_dmi = NATIVE_BACKLIGHT_OFF;
425 return 0;
426}
427
428static int __init video_enable_native_backlight(const struct dmi_system_id *d)
429{
430 use_native_backlight_dmi = NATIVE_BACKLIGHT_ON;
418 return 0; 431 return 0;
419} 432}
420 433
@@ -559,6 +572,17 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
559 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"), 572 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"),
560 }, 573 },
561 }, 574 },
575
576 /* Non win8 machines which need native backlight nevertheless */
577 {
578 /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */
579 .callback = video_enable_native_backlight,
580 .ident = "Lenovo Ideapad Z570",
581 .matches = {
582 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
583 DMI_MATCH(DMI_PRODUCT_NAME, "102434U"),
584 },
585 },
562 {} 586 {}
563}; 587};
564 588
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 27c43499977a..c42feb2bacd0 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -174,14 +174,6 @@ static struct dmi_system_id video_detect_dmi_table[] = {
174 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"), 174 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"),
175 }, 175 },
176 }, 176 },
177 {
178 .callback = video_detect_force_vendor,
179 .ident = "Lenovo IdeaPad Z570",
180 .matches = {
181 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
182 DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"),
183 },
184 },
185 { }, 177 { },
186}; 178};
187 179
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index b33d1f99b3a4..994f168b54a8 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -128,20 +128,8 @@ static struct pnp_driver isapnp_driver = {
128 .remove = isapnp_remove_one, 128 .remove = isapnp_remove_one,
129}; 129};
130 130
131static int __init isapnp_init(void) 131module_pnp_driver(isapnp_driver);
132{
133 return pnp_register_driver(&isapnp_driver);
134}
135
136static void __exit isapnp_exit(void)
137{
138 pnp_unregister_driver(&isapnp_driver);
139}
140
141MODULE_AUTHOR("Alan Cox"); 132MODULE_AUTHOR("Alan Cox");
142MODULE_DESCRIPTION("low-level driver for ISA PnP ATA"); 133MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
143MODULE_LICENSE("GPL"); 134MODULE_LICENSE("GPL");
144MODULE_VERSION(DRV_VERSION); 135MODULE_VERSION(DRV_VERSION);
145
146module_init(isapnp_init);
147module_exit(isapnp_exit);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 07304a3b9ee2..c7e2a9a70865 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/fwnode.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/slab.h> 18#include <linux/slab.h>
@@ -2133,3 +2134,53 @@ define_dev_printk_level(dev_notice, KERN_NOTICE);
2133define_dev_printk_level(_dev_info, KERN_INFO); 2134define_dev_printk_level(_dev_info, KERN_INFO);
2134 2135
2135#endif 2136#endif
2137
2138static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
2139{
2140 return fwnode && !IS_ERR(fwnode->secondary);
2141}
2142
2143/**
2144 * set_primary_fwnode - Change the primary firmware node of a given device.
2145 * @dev: Device to handle.
2146 * @fwnode: New primary firmware node of the device.
2147 *
2148 * Set the device's firmware node pointer to @fwnode, but if a secondary
2149 * firmware node of the device is present, preserve it.
2150 */
2151void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
2152{
2153 if (fwnode) {
2154 struct fwnode_handle *fn = dev->fwnode;
2155
2156 if (fwnode_is_primary(fn))
2157 fn = fn->secondary;
2158
2159 fwnode->secondary = fn;
2160 dev->fwnode = fwnode;
2161 } else {
2162 dev->fwnode = fwnode_is_primary(dev->fwnode) ?
2163 dev->fwnode->secondary : NULL;
2164 }
2165}
2166EXPORT_SYMBOL_GPL(set_primary_fwnode);
2167
2168/**
2169 * set_secondary_fwnode - Change the secondary firmware node of a given device.
2170 * @dev: Device to handle.
2171 * @fwnode: New secondary firmware node of the device.
2172 *
2173 * If a primary firmware node of the device is present, set its secondary
2174 * pointer to @fwnode. Otherwise, set the device's firmware node pointer to
2175 * @fwnode.
2176 */
2177void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
2178{
2179 if (fwnode)
2180 fwnode->secondary = ERR_PTR(-ENODEV);
2181
2182 if (fwnode_is_primary(dev->fwnode))
2183 dev->fwnode->secondary = fwnode;
2184 else
2185 dev->fwnode = fwnode;
2186}
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9421fed40905..17f0204fabef 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -454,7 +454,7 @@ struct platform_device *platform_device_register_full(
454 goto err_alloc; 454 goto err_alloc;
455 455
456 pdev->dev.parent = pdevinfo->parent; 456 pdev->dev.parent = pdevinfo->parent;
457 ACPI_COMPANION_SET(&pdev->dev, pdevinfo->acpi_node.companion); 457 pdev->dev.fwnode = pdevinfo->fwnode;
458 458
459 if (pdevinfo->dma_mask) { 459 if (pdevinfo->dma_mask) {
460 /* 460 /*
diff --git a/drivers/base/property.c b/drivers/base/property.c
index c45845874d4f..6a3f7d8af341 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -10,10 +10,102 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#include <linux/property.h>
14#include <linux/export.h>
15#include <linux/acpi.h> 13#include <linux/acpi.h>
14#include <linux/export.h>
15#include <linux/kernel.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/property.h>
18
19/**
20 * device_add_property_set - Add a collection of properties to a device object.
21 * @dev: Device to add properties to.
22 * @pset: Collection of properties to add.
23 *
24 * Associate a collection of device properties represented by @pset with @dev
25 * as its secondary firmware node.
26 */
27void device_add_property_set(struct device *dev, struct property_set *pset)
28{
29 if (pset)
30 pset->fwnode.type = FWNODE_PDATA;
31
32 set_secondary_fwnode(dev, &pset->fwnode);
33}
34EXPORT_SYMBOL_GPL(device_add_property_set);
35
36static inline bool is_pset(struct fwnode_handle *fwnode)
37{
38 return fwnode && fwnode->type == FWNODE_PDATA;
39}
40
41static inline struct property_set *to_pset(struct fwnode_handle *fwnode)
42{
43 return is_pset(fwnode) ?
44 container_of(fwnode, struct property_set, fwnode) : NULL;
45}
46
47static struct property_entry *pset_prop_get(struct property_set *pset,
48 const char *name)
49{
50 struct property_entry *prop;
51
52 if (!pset || !pset->properties)
53 return NULL;
54
55 for (prop = pset->properties; prop->name; prop++)
56 if (!strcmp(name, prop->name))
57 return prop;
58
59 return NULL;
60}
61
62static int pset_prop_read_array(struct property_set *pset, const char *name,
63 enum dev_prop_type type, void *val, size_t nval)
64{
65 struct property_entry *prop;
66 unsigned int item_size;
67
68 prop = pset_prop_get(pset, name);
69 if (!prop)
70 return -ENODATA;
71
72 if (prop->type != type)
73 return -EPROTO;
74
75 if (!val)
76 return prop->nval;
77
78 if (prop->nval < nval)
79 return -EOVERFLOW;
80
81 switch (type) {
82 case DEV_PROP_U8:
83 item_size = sizeof(u8);
84 break;
85 case DEV_PROP_U16:
86 item_size = sizeof(u16);
87 break;
88 case DEV_PROP_U32:
89 item_size = sizeof(u32);
90 break;
91 case DEV_PROP_U64:
92 item_size = sizeof(u64);
93 break;
94 case DEV_PROP_STRING:
95 item_size = sizeof(const char *);
96 break;
97 default:
98 return -EINVAL;
99 }
100 memcpy(val, prop->value.raw_data, nval * item_size);
101 return 0;
102}
103
104static inline struct fwnode_handle *dev_fwnode(struct device *dev)
105{
106 return IS_ENABLED(CONFIG_OF) && dev->of_node ?
107 &dev->of_node->fwnode : dev->fwnode;
108}
17 109
18/** 110/**
19 * device_property_present - check if a property of a device is present 111 * device_property_present - check if a property of a device is present
@@ -24,10 +116,7 @@
24 */ 116 */
25bool device_property_present(struct device *dev, const char *propname) 117bool device_property_present(struct device *dev, const char *propname)
26{ 118{
27 if (IS_ENABLED(CONFIG_OF) && dev->of_node) 119 return fwnode_property_present(dev_fwnode(dev), propname);
28 return of_property_read_bool(dev->of_node, propname);
29
30 return !acpi_dev_prop_get(ACPI_COMPANION(dev), propname, NULL);
31} 120}
32EXPORT_SYMBOL_GPL(device_property_present); 121EXPORT_SYMBOL_GPL(device_property_present);
33 122
@@ -43,32 +132,22 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
43 else if (is_acpi_node(fwnode)) 132 else if (is_acpi_node(fwnode))
44 return !acpi_dev_prop_get(acpi_node(fwnode), propname, NULL); 133 return !acpi_dev_prop_get(acpi_node(fwnode), propname, NULL);
45 134
46 return false; 135 return !!pset_prop_get(to_pset(fwnode), propname);
47} 136}
48EXPORT_SYMBOL_GPL(fwnode_property_present); 137EXPORT_SYMBOL_GPL(fwnode_property_present);
49 138
50#define OF_DEV_PROP_READ_ARRAY(node, propname, type, val, nval) \
51 (val) ? of_property_read_##type##_array((node), (propname), (val), (nval)) \
52 : of_property_count_elems_of_size((node), (propname), sizeof(type))
53
54#define DEV_PROP_READ_ARRAY(_dev_, _propname_, _type_, _proptype_, _val_, _nval_) \
55 IS_ENABLED(CONFIG_OF) && _dev_->of_node ? \
56 (OF_DEV_PROP_READ_ARRAY(_dev_->of_node, _propname_, _type_, \
57 _val_, _nval_)) : \
58 acpi_dev_prop_read(ACPI_COMPANION(_dev_), _propname_, \
59 _proptype_, _val_, _nval_)
60
61/** 139/**
62 * device_property_read_u8_array - return a u8 array property of a device 140 * device_property_read_u8_array - return a u8 array property of a device
63 * @dev: Device to get the property of 141 * @dev: Device to get the property of
64 * @propname: Name of the property 142 * @propname: Name of the property
65 * @val: The values are stored here 143 * @val: The values are stored here or %NULL to return the number of values
66 * @nval: Size of the @val array 144 * @nval: Size of the @val array
67 * 145 *
68 * Function reads an array of u8 properties with @propname from the device 146 * Function reads an array of u8 properties with @propname from the device
69 * firmware description and stores them to @val if found. 147 * firmware description and stores them to @val if found.
70 * 148 *
71 * Return: %0 if the property was found (success), 149 * Return: number of values if @val was %NULL,
150 * %0 if the property was found (success),
72 * %-EINVAL if given arguments are not valid, 151 * %-EINVAL if given arguments are not valid,
73 * %-ENODATA if the property does not have a value, 152 * %-ENODATA if the property does not have a value,
74 * %-EPROTO if the property is not an array of numbers, 153 * %-EPROTO if the property is not an array of numbers,
@@ -77,7 +156,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_present);
77int device_property_read_u8_array(struct device *dev, const char *propname, 156int device_property_read_u8_array(struct device *dev, const char *propname,
78 u8 *val, size_t nval) 157 u8 *val, size_t nval)
79{ 158{
80 return DEV_PROP_READ_ARRAY(dev, propname, u8, DEV_PROP_U8, val, nval); 159 return fwnode_property_read_u8_array(dev_fwnode(dev), propname, val, nval);
81} 160}
82EXPORT_SYMBOL_GPL(device_property_read_u8_array); 161EXPORT_SYMBOL_GPL(device_property_read_u8_array);
83 162
@@ -85,13 +164,14 @@ EXPORT_SYMBOL_GPL(device_property_read_u8_array);
85 * device_property_read_u16_array - return a u16 array property of a device 164 * device_property_read_u16_array - return a u16 array property of a device
86 * @dev: Device to get the property of 165 * @dev: Device to get the property of
87 * @propname: Name of the property 166 * @propname: Name of the property
88 * @val: The values are stored here 167 * @val: The values are stored here or %NULL to return the number of values
89 * @nval: Size of the @val array 168 * @nval: Size of the @val array
90 * 169 *
91 * Function reads an array of u16 properties with @propname from the device 170 * Function reads an array of u16 properties with @propname from the device
92 * firmware description and stores them to @val if found. 171 * firmware description and stores them to @val if found.
93 * 172 *
94 * Return: %0 if the property was found (success), 173 * Return: number of values if @val was %NULL,
174 * %0 if the property was found (success),
95 * %-EINVAL if given arguments are not valid, 175 * %-EINVAL if given arguments are not valid,
96 * %-ENODATA if the property does not have a value, 176 * %-ENODATA if the property does not have a value,
97 * %-EPROTO if the property is not an array of numbers, 177 * %-EPROTO if the property is not an array of numbers,
@@ -100,7 +180,7 @@ EXPORT_SYMBOL_GPL(device_property_read_u8_array);
100int device_property_read_u16_array(struct device *dev, const char *propname, 180int device_property_read_u16_array(struct device *dev, const char *propname,
101 u16 *val, size_t nval) 181 u16 *val, size_t nval)
102{ 182{
103 return DEV_PROP_READ_ARRAY(dev, propname, u16, DEV_PROP_U16, val, nval); 183 return fwnode_property_read_u16_array(dev_fwnode(dev), propname, val, nval);
104} 184}
105EXPORT_SYMBOL_GPL(device_property_read_u16_array); 185EXPORT_SYMBOL_GPL(device_property_read_u16_array);
106 186
@@ -108,13 +188,14 @@ EXPORT_SYMBOL_GPL(device_property_read_u16_array);
108 * device_property_read_u32_array - return a u32 array property of a device 188 * device_property_read_u32_array - return a u32 array property of a device
109 * @dev: Device to get the property of 189 * @dev: Device to get the property of
110 * @propname: Name of the property 190 * @propname: Name of the property
111 * @val: The values are stored here 191 * @val: The values are stored here or %NULL to return the number of values
112 * @nval: Size of the @val array 192 * @nval: Size of the @val array
113 * 193 *
114 * Function reads an array of u32 properties with @propname from the device 194 * Function reads an array of u32 properties with @propname from the device
115 * firmware description and stores them to @val if found. 195 * firmware description and stores them to @val if found.
116 * 196 *
117 * Return: %0 if the property was found (success), 197 * Return: number of values if @val was %NULL,
198 * %0 if the property was found (success),
118 * %-EINVAL if given arguments are not valid, 199 * %-EINVAL if given arguments are not valid,
119 * %-ENODATA if the property does not have a value, 200 * %-ENODATA if the property does not have a value,
120 * %-EPROTO if the property is not an array of numbers, 201 * %-EPROTO if the property is not an array of numbers,
@@ -123,7 +204,7 @@ EXPORT_SYMBOL_GPL(device_property_read_u16_array);
123int device_property_read_u32_array(struct device *dev, const char *propname, 204int device_property_read_u32_array(struct device *dev, const char *propname,
124 u32 *val, size_t nval) 205 u32 *val, size_t nval)
125{ 206{
126 return DEV_PROP_READ_ARRAY(dev, propname, u32, DEV_PROP_U32, val, nval); 207 return fwnode_property_read_u32_array(dev_fwnode(dev), propname, val, nval);
127} 208}
128EXPORT_SYMBOL_GPL(device_property_read_u32_array); 209EXPORT_SYMBOL_GPL(device_property_read_u32_array);
129 210
@@ -131,13 +212,14 @@ EXPORT_SYMBOL_GPL(device_property_read_u32_array);
131 * device_property_read_u64_array - return a u64 array property of a device 212 * device_property_read_u64_array - return a u64 array property of a device
132 * @dev: Device to get the property of 213 * @dev: Device to get the property of
133 * @propname: Name of the property 214 * @propname: Name of the property
134 * @val: The values are stored here 215 * @val: The values are stored here or %NULL to return the number of values
135 * @nval: Size of the @val array 216 * @nval: Size of the @val array
136 * 217 *
137 * Function reads an array of u64 properties with @propname from the device 218 * Function reads an array of u64 properties with @propname from the device
138 * firmware description and stores them to @val if found. 219 * firmware description and stores them to @val if found.
139 * 220 *
140 * Return: %0 if the property was found (success), 221 * Return: number of values if @val was %NULL,
222 * %0 if the property was found (success),
141 * %-EINVAL if given arguments are not valid, 223 * %-EINVAL if given arguments are not valid,
142 * %-ENODATA if the property does not have a value, 224 * %-ENODATA if the property does not have a value,
143 * %-EPROTO if the property is not an array of numbers, 225 * %-EPROTO if the property is not an array of numbers,
@@ -146,7 +228,7 @@ EXPORT_SYMBOL_GPL(device_property_read_u32_array);
146int device_property_read_u64_array(struct device *dev, const char *propname, 228int device_property_read_u64_array(struct device *dev, const char *propname,
147 u64 *val, size_t nval) 229 u64 *val, size_t nval)
148{ 230{
149 return DEV_PROP_READ_ARRAY(dev, propname, u64, DEV_PROP_U64, val, nval); 231 return fwnode_property_read_u64_array(dev_fwnode(dev), propname, val, nval);
150} 232}
151EXPORT_SYMBOL_GPL(device_property_read_u64_array); 233EXPORT_SYMBOL_GPL(device_property_read_u64_array);
152 234
@@ -154,13 +236,14 @@ EXPORT_SYMBOL_GPL(device_property_read_u64_array);
154 * device_property_read_string_array - return a string array property of device 236 * device_property_read_string_array - return a string array property of device
155 * @dev: Device to get the property of 237 * @dev: Device to get the property of
156 * @propname: Name of the property 238 * @propname: Name of the property
157 * @val: The values are stored here 239 * @val: The values are stored here or %NULL to return the number of values
158 * @nval: Size of the @val array 240 * @nval: Size of the @val array
159 * 241 *
160 * Function reads an array of string properties with @propname from the device 242 * Function reads an array of string properties with @propname from the device
161 * firmware description and stores them to @val if found. 243 * firmware description and stores them to @val if found.
162 * 244 *
163 * Return: %0 if the property was found (success), 245 * Return: number of values if @val was %NULL,
246 * %0 if the property was found (success),
164 * %-EINVAL if given arguments are not valid, 247 * %-EINVAL if given arguments are not valid,
165 * %-ENODATA if the property does not have a value, 248 * %-ENODATA if the property does not have a value,
166 * %-EPROTO or %-EILSEQ if the property is not an array of strings, 249 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
@@ -169,10 +252,7 @@ EXPORT_SYMBOL_GPL(device_property_read_u64_array);
169int device_property_read_string_array(struct device *dev, const char *propname, 252int device_property_read_string_array(struct device *dev, const char *propname,
170 const char **val, size_t nval) 253 const char **val, size_t nval)
171{ 254{
172 return IS_ENABLED(CONFIG_OF) && dev->of_node ? 255 return fwnode_property_read_string_array(dev_fwnode(dev), propname, val, nval);
173 of_property_read_string_array(dev->of_node, propname, val, nval) :
174 acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
175 DEV_PROP_STRING, val, nval);
176} 256}
177EXPORT_SYMBOL_GPL(device_property_read_string_array); 257EXPORT_SYMBOL_GPL(device_property_read_string_array);
178 258
@@ -193,13 +273,14 @@ EXPORT_SYMBOL_GPL(device_property_read_string_array);
193int device_property_read_string(struct device *dev, const char *propname, 273int device_property_read_string(struct device *dev, const char *propname,
194 const char **val) 274 const char **val)
195{ 275{
196 return IS_ENABLED(CONFIG_OF) && dev->of_node ? 276 return fwnode_property_read_string(dev_fwnode(dev), propname, val);
197 of_property_read_string(dev->of_node, propname, val) :
198 acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
199 DEV_PROP_STRING, val, 1);
200} 277}
201EXPORT_SYMBOL_GPL(device_property_read_string); 278EXPORT_SYMBOL_GPL(device_property_read_string);
202 279
280#define OF_DEV_PROP_READ_ARRAY(node, propname, type, val, nval) \
281 (val) ? of_property_read_##type##_array((node), (propname), (val), (nval)) \
282 : of_property_count_elems_of_size((node), (propname), sizeof(type))
283
203#define FWNODE_PROP_READ_ARRAY(_fwnode_, _propname_, _type_, _proptype_, _val_, _nval_) \ 284#define FWNODE_PROP_READ_ARRAY(_fwnode_, _propname_, _type_, _proptype_, _val_, _nval_) \
204({ \ 285({ \
205 int _ret_; \ 286 int _ret_; \
@@ -210,7 +291,8 @@ EXPORT_SYMBOL_GPL(device_property_read_string);
210 _ret_ = acpi_dev_prop_read(acpi_node(_fwnode_), _propname_, \ 291 _ret_ = acpi_dev_prop_read(acpi_node(_fwnode_), _propname_, \
211 _proptype_, _val_, _nval_); \ 292 _proptype_, _val_, _nval_); \
212 else \ 293 else \
213 _ret_ = -ENXIO; \ 294 _ret_ = pset_prop_read_array(to_pset(_fwnode_), _propname_, \
295 _proptype_, _val_, _nval_); \
214 _ret_; \ 296 _ret_; \
215}) 297})
216 298
@@ -218,13 +300,14 @@ EXPORT_SYMBOL_GPL(device_property_read_string);
218 * fwnode_property_read_u8_array - return a u8 array property of firmware node 300 * fwnode_property_read_u8_array - return a u8 array property of firmware node
219 * @fwnode: Firmware node to get the property of 301 * @fwnode: Firmware node to get the property of
220 * @propname: Name of the property 302 * @propname: Name of the property
221 * @val: The values are stored here 303 * @val: The values are stored here or %NULL to return the number of values
222 * @nval: Size of the @val array 304 * @nval: Size of the @val array
223 * 305 *
224 * Read an array of u8 properties with @propname from @fwnode and stores them to 306 * Read an array of u8 properties with @propname from @fwnode and stores them to
225 * @val if found. 307 * @val if found.
226 * 308 *
227 * Return: %0 if the property was found (success), 309 * Return: number of values if @val was %NULL,
310 * %0 if the property was found (success),
228 * %-EINVAL if given arguments are not valid, 311 * %-EINVAL if given arguments are not valid,
229 * %-ENODATA if the property does not have a value, 312 * %-ENODATA if the property does not have a value,
230 * %-EPROTO if the property is not an array of numbers, 313 * %-EPROTO if the property is not an array of numbers,
@@ -243,13 +326,14 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u8_array);
243 * fwnode_property_read_u16_array - return a u16 array property of firmware node 326 * fwnode_property_read_u16_array - return a u16 array property of firmware node
244 * @fwnode: Firmware node to get the property of 327 * @fwnode: Firmware node to get the property of
245 * @propname: Name of the property 328 * @propname: Name of the property
246 * @val: The values are stored here 329 * @val: The values are stored here or %NULL to return the number of values
247 * @nval: Size of the @val array 330 * @nval: Size of the @val array
248 * 331 *
249 * Read an array of u16 properties with @propname from @fwnode and store them to 332 * Read an array of u16 properties with @propname from @fwnode and store them to
250 * @val if found. 333 * @val if found.
251 * 334 *
252 * Return: %0 if the property was found (success), 335 * Return: number of values if @val was %NULL,
336 * %0 if the property was found (success),
253 * %-EINVAL if given arguments are not valid, 337 * %-EINVAL if given arguments are not valid,
254 * %-ENODATA if the property does not have a value, 338 * %-ENODATA if the property does not have a value,
255 * %-EPROTO if the property is not an array of numbers, 339 * %-EPROTO if the property is not an array of numbers,
@@ -268,13 +352,14 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u16_array);
268 * fwnode_property_read_u32_array - return a u32 array property of firmware node 352 * fwnode_property_read_u32_array - return a u32 array property of firmware node
269 * @fwnode: Firmware node to get the property of 353 * @fwnode: Firmware node to get the property of
270 * @propname: Name of the property 354 * @propname: Name of the property
271 * @val: The values are stored here 355 * @val: The values are stored here or %NULL to return the number of values
272 * @nval: Size of the @val array 356 * @nval: Size of the @val array
273 * 357 *
274 * Read an array of u32 properties with @propname from @fwnode store them to 358 * Read an array of u32 properties with @propname from @fwnode store them to
275 * @val if found. 359 * @val if found.
276 * 360 *
277 * Return: %0 if the property was found (success), 361 * Return: number of values if @val was %NULL,
362 * %0 if the property was found (success),
278 * %-EINVAL if given arguments are not valid, 363 * %-EINVAL if given arguments are not valid,
279 * %-ENODATA if the property does not have a value, 364 * %-ENODATA if the property does not have a value,
280 * %-EPROTO if the property is not an array of numbers, 365 * %-EPROTO if the property is not an array of numbers,
@@ -293,13 +378,14 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u32_array);
293 * fwnode_property_read_u64_array - return a u64 array property firmware node 378 * fwnode_property_read_u64_array - return a u64 array property firmware node
294 * @fwnode: Firmware node to get the property of 379 * @fwnode: Firmware node to get the property of
295 * @propname: Name of the property 380 * @propname: Name of the property
296 * @val: The values are stored here 381 * @val: The values are stored here or %NULL to return the number of values
297 * @nval: Size of the @val array 382 * @nval: Size of the @val array
298 * 383 *
299 * Read an array of u64 properties with @propname from @fwnode and store them to 384 * Read an array of u64 properties with @propname from @fwnode and store them to
300 * @val if found. 385 * @val if found.
301 * 386 *
302 * Return: %0 if the property was found (success), 387 * Return: number of values if @val was %NULL,
388 * %0 if the property was found (success),
303 * %-EINVAL if given arguments are not valid, 389 * %-EINVAL if given arguments are not valid,
304 * %-ENODATA if the property does not have a value, 390 * %-ENODATA if the property does not have a value,
305 * %-EPROTO if the property is not an array of numbers, 391 * %-EPROTO if the property is not an array of numbers,
@@ -318,13 +404,14 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u64_array);
318 * fwnode_property_read_string_array - return string array property of a node 404 * fwnode_property_read_string_array - return string array property of a node
319 * @fwnode: Firmware node to get the property of 405 * @fwnode: Firmware node to get the property of
320 * @propname: Name of the property 406 * @propname: Name of the property
321 * @val: The values are stored here 407 * @val: The values are stored here or %NULL to return the number of values
322 * @nval: Size of the @val array 408 * @nval: Size of the @val array
323 * 409 *
324 * Read an string list property @propname from the given firmware node and store 410 * Read an string list property @propname from the given firmware node and store
325 * them to @val if found. 411 * them to @val if found.
326 * 412 *
327 * Return: %0 if the property was found (success), 413 * Return: number of values if @val was %NULL,
414 * %0 if the property was found (success),
328 * %-EINVAL if given arguments are not valid, 415 * %-EINVAL if given arguments are not valid,
329 * %-ENODATA if the property does not have a value, 416 * %-ENODATA if the property does not have a value,
330 * %-EPROTO if the property is not an array of strings, 417 * %-EPROTO if the property is not an array of strings,
@@ -336,13 +423,16 @@ int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
336 size_t nval) 423 size_t nval)
337{ 424{
338 if (is_of_node(fwnode)) 425 if (is_of_node(fwnode))
339 return of_property_read_string_array(of_node(fwnode), propname, 426 return val ?
340 val, nval); 427 of_property_read_string_array(of_node(fwnode), propname,
428 val, nval) :
429 of_property_count_strings(of_node(fwnode), propname);
341 else if (is_acpi_node(fwnode)) 430 else if (is_acpi_node(fwnode))
342 return acpi_dev_prop_read(acpi_node(fwnode), propname, 431 return acpi_dev_prop_read(acpi_node(fwnode), propname,
343 DEV_PROP_STRING, val, nval); 432 DEV_PROP_STRING, val, nval);
344 433
345 return -ENXIO; 434 return pset_prop_read_array(to_pset(fwnode), propname,
435 DEV_PROP_STRING, val, nval);
346} 436}
347EXPORT_SYMBOL_GPL(fwnode_property_read_string_array); 437EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);
348 438
diff --git a/drivers/char/ipmi/ipmi_powernv.c b/drivers/char/ipmi/ipmi_powernv.c
index 79524ed2a3cb..8753b0f6a317 100644
--- a/drivers/char/ipmi/ipmi_powernv.c
+++ b/drivers/char/ipmi/ipmi_powernv.c
@@ -125,6 +125,7 @@ static int ipmi_powernv_recv(struct ipmi_smi_powernv *smi)
125 spin_lock_irqsave(&smi->msg_lock, flags); 125 spin_lock_irqsave(&smi->msg_lock, flags);
126 126
127 if (!smi->cur_msg) { 127 if (!smi->cur_msg) {
128 spin_unlock_irqrestore(&smi->msg_lock, flags);
128 pr_warn("no current message?\n"); 129 pr_warn("no current message?\n");
129 return 0; 130 return 0;
130 } 131 }
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index f6646ed3047e..518585c1ce94 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -263,6 +263,11 @@ struct smi_info {
263 bool supports_event_msg_buff; 263 bool supports_event_msg_buff;
264 264
265 /* 265 /*
266 * Can we clear the global enables receive irq bit?
267 */
268 bool cannot_clear_recv_irq_bit;
269
270 /*
266 * Did we get an attention that we did not handle? 271 * Did we get an attention that we did not handle?
267 */ 272 */
268 bool got_attn; 273 bool got_attn;
@@ -461,6 +466,9 @@ static void smi_mod_timer(struct smi_info *smi_info, unsigned long new_val)
461 * allocate messages, we just leave them in the BMC and run the system 466 * allocate messages, we just leave them in the BMC and run the system
462 * polled until we can allocate some memory. Once we have some 467 * polled until we can allocate some memory. Once we have some
463 * memory, we will re-enable the interrupt. 468 * memory, we will re-enable the interrupt.
469 *
470 * Note that we cannot just use disable_irq(), since the interrupt may
471 * be shared.
464 */ 472 */
465static inline bool disable_si_irq(struct smi_info *smi_info) 473static inline bool disable_si_irq(struct smi_info *smi_info)
466{ 474{
@@ -549,20 +557,15 @@ static u8 current_global_enables(struct smi_info *smi_info, u8 base,
549 557
550 if (smi_info->supports_event_msg_buff) 558 if (smi_info->supports_event_msg_buff)
551 enables |= IPMI_BMC_EVT_MSG_BUFF; 559 enables |= IPMI_BMC_EVT_MSG_BUFF;
552 else
553 enables &= ~IPMI_BMC_EVT_MSG_BUFF;
554 560
555 if (smi_info->irq && !smi_info->interrupt_disabled) 561 if ((smi_info->irq && !smi_info->interrupt_disabled) ||
562 smi_info->cannot_clear_recv_irq_bit)
556 enables |= IPMI_BMC_RCV_MSG_INTR; 563 enables |= IPMI_BMC_RCV_MSG_INTR;
557 else
558 enables &= ~IPMI_BMC_RCV_MSG_INTR;
559 564
560 if (smi_info->supports_event_msg_buff && 565 if (smi_info->supports_event_msg_buff &&
561 smi_info->irq && !smi_info->interrupt_disabled) 566 smi_info->irq && !smi_info->interrupt_disabled)
562 567
563 enables |= IPMI_BMC_EVT_MSG_INTR; 568 enables |= IPMI_BMC_EVT_MSG_INTR;
564 else
565 enables &= ~IPMI_BMC_EVT_MSG_INTR;
566 569
567 *irq_on = enables & (IPMI_BMC_EVT_MSG_INTR | IPMI_BMC_RCV_MSG_INTR); 570 *irq_on = enables & (IPMI_BMC_EVT_MSG_INTR | IPMI_BMC_RCV_MSG_INTR);
568 571
@@ -2900,6 +2903,96 @@ static int try_get_dev_id(struct smi_info *smi_info)
2900 return rv; 2903 return rv;
2901} 2904}
2902 2905
2906/*
2907 * Some BMCs do not support clearing the receive irq bit in the global
2908 * enables (even if they don't support interrupts on the BMC). Check
2909 * for this and handle it properly.
2910 */
2911static void check_clr_rcv_irq(struct smi_info *smi_info)
2912{
2913 unsigned char msg[3];
2914 unsigned char *resp;
2915 unsigned long resp_len;
2916 int rv;
2917
2918 resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
2919 if (!resp) {
2920 printk(KERN_WARNING PFX "Out of memory allocating response for"
2921 " global enables command, cannot check recv irq bit"
2922 " handling.\n");
2923 return;
2924 }
2925
2926 msg[0] = IPMI_NETFN_APP_REQUEST << 2;
2927 msg[1] = IPMI_GET_BMC_GLOBAL_ENABLES_CMD;
2928 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2);
2929
2930 rv = wait_for_msg_done(smi_info);
2931 if (rv) {
2932 printk(KERN_WARNING PFX "Error getting response from get"
2933 " global enables command, cannot check recv irq bit"
2934 " handling.\n");
2935 goto out;
2936 }
2937
2938 resp_len = smi_info->handlers->get_result(smi_info->si_sm,
2939 resp, IPMI_MAX_MSG_LENGTH);
2940
2941 if (resp_len < 4 ||
2942 resp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 ||
2943 resp[1] != IPMI_GET_BMC_GLOBAL_ENABLES_CMD ||
2944 resp[2] != 0) {
2945 printk(KERN_WARNING PFX "Invalid return from get global"
2946 " enables command, cannot check recv irq bit"
2947 " handling.\n");
2948 rv = -EINVAL;
2949 goto out;
2950 }
2951
2952 if ((resp[3] & IPMI_BMC_RCV_MSG_INTR) == 0)
2953 /* Already clear, should work ok. */
2954 goto out;
2955
2956 msg[0] = IPMI_NETFN_APP_REQUEST << 2;
2957 msg[1] = IPMI_SET_BMC_GLOBAL_ENABLES_CMD;
2958 msg[2] = resp[3] & ~IPMI_BMC_RCV_MSG_INTR;
2959 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 3);
2960
2961 rv = wait_for_msg_done(smi_info);
2962 if (rv) {
2963 printk(KERN_WARNING PFX "Error getting response from set"
2964 " global enables command, cannot check recv irq bit"
2965 " handling.\n");
2966 goto out;
2967 }
2968
2969 resp_len = smi_info->handlers->get_result(smi_info->si_sm,
2970 resp, IPMI_MAX_MSG_LENGTH);
2971
2972 if (resp_len < 3 ||
2973 resp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 ||
2974 resp[1] != IPMI_SET_BMC_GLOBAL_ENABLES_CMD) {
2975 printk(KERN_WARNING PFX "Invalid return from get global"
2976 " enables command, cannot check recv irq bit"
2977 " handling.\n");
2978 rv = -EINVAL;
2979 goto out;
2980 }
2981
2982 if (resp[2] != 0) {
2983 /*
2984 * An error when setting the event buffer bit means
2985 * clearing the bit is not supported.
2986 */
2987 printk(KERN_WARNING PFX "The BMC does not support clearing"
2988 " the recv irq bit, compensating, but the BMC needs to"
2989 " be fixed.\n");
2990 smi_info->cannot_clear_recv_irq_bit = true;
2991 }
2992 out:
2993 kfree(resp);
2994}
2995
2903static int try_enable_event_buffer(struct smi_info *smi_info) 2996static int try_enable_event_buffer(struct smi_info *smi_info)
2904{ 2997{
2905 unsigned char msg[3]; 2998 unsigned char msg[3];
@@ -3395,6 +3488,8 @@ static int try_smi_init(struct smi_info *new_smi)
3395 goto out_err; 3488 goto out_err;
3396 } 3489 }
3397 3490
3491 check_clr_rcv_irq(new_smi);
3492
3398 setup_oem_data_handler(new_smi); 3493 setup_oem_data_handler(new_smi);
3399 setup_xaction_handlers(new_smi); 3494 setup_xaction_handlers(new_smi);
3400 3495
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index f6e378dac5f5..f40e3bd2c69c 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -468,11 +468,13 @@ static int ipmi_ssif_thread(void *data)
468 int result; 468 int result;
469 469
470 /* Wait for something to do */ 470 /* Wait for something to do */
471 wait_for_completion(&ssif_info->wake_thread); 471 result = wait_for_completion_interruptible(
472 init_completion(&ssif_info->wake_thread); 472 &ssif_info->wake_thread);
473
474 if (ssif_info->stopping) 473 if (ssif_info->stopping)
475 break; 474 break;
475 if (result == -ERESTARTSYS)
476 continue;
477 init_completion(&ssif_info->wake_thread);
476 478
477 if (ssif_info->i2c_read_write == I2C_SMBUS_WRITE) { 479 if (ssif_info->i2c_read_write == I2C_SMBUS_WRITE) {
478 result = i2c_smbus_write_block_data( 480 result = i2c_smbus_write_block_data(
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 6d492132ad2b..29ba520ac24d 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -637,18 +637,7 @@ static struct pnp_driver tpm_inf_pnp_driver = {
637 .remove = tpm_inf_pnp_remove 637 .remove = tpm_inf_pnp_remove
638}; 638};
639 639
640static int __init init_inf(void) 640module_pnp_driver(tpm_inf_pnp_driver);
641{
642 return pnp_register_driver(&tpm_inf_pnp_driver);
643}
644
645static void __exit cleanup_inf(void)
646{
647 pnp_unregister_driver(&tpm_inf_pnp_driver);
648}
649
650module_init(init_inf);
651module_exit(cleanup_inf);
652 641
653MODULE_AUTHOR("Marcel Selhorst <tpmdd@sirrix.com>"); 642MODULE_AUTHOR("Marcel Selhorst <tpmdd@sirrix.com>");
654MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); 643MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2");
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index a171fef2c2b6..659879a56dba 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -293,5 +293,13 @@ config SH_CPU_FREQ
293 If unsure, say N. 293 If unsure, say N.
294endif 294endif
295 295
296config QORIQ_CPUFREQ
297 tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
298 depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
299 select CLK_QORIQ
300 help
301 This adds the CPUFreq driver support for Freescale QorIQ SoCs
302 which are capable of changing the CPU's frequency dynamically.
303
296endif 304endif
297endmenu 305endmenu
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 1b06fc4640e2..4f3dbc8cf729 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -108,6 +108,15 @@ config ARM_HIGHBANK_CPUFREQ
108 108
109 If in doubt, say N. 109 If in doubt, say N.
110 110
111config ARM_HISI_ACPU_CPUFREQ
112 tristate "Hisilicon ACPU CPUfreq driver"
113 depends on ARCH_HISI && CPUFREQ_DT
114 select PM_OPP
115 help
116 This enables the hisilicon ACPU CPUfreq driver.
117
118 If in doubt, say N.
119
111config ARM_IMX6Q_CPUFREQ 120config ARM_IMX6Q_CPUFREQ
112 tristate "Freescale i.MX6 cpufreq support" 121 tristate "Freescale i.MX6 cpufreq support"
113 depends on ARCH_MXC 122 depends on ARCH_MXC
diff --git a/drivers/cpufreq/Kconfig.powerpc b/drivers/cpufreq/Kconfig.powerpc
index 7ea24413cee6..3a0595b41eab 100644
--- a/drivers/cpufreq/Kconfig.powerpc
+++ b/drivers/cpufreq/Kconfig.powerpc
@@ -23,15 +23,6 @@ config CPU_FREQ_MAPLE
23 This adds support for frequency switching on Maple 970FX 23 This adds support for frequency switching on Maple 970FX
24 Evaluation Board and compatible boards (IBM JS2x blades). 24 Evaluation Board and compatible boards (IBM JS2x blades).
25 25
26config PPC_CORENET_CPUFREQ
27 tristate "CPU frequency scaling driver for Freescale E500MC SoCs"
28 depends on PPC_E500MC && OF && COMMON_CLK
29 select CLK_QORIQ
30 help
31 This adds the CPUFreq driver support for Freescale e500mc,
32 e5500 and e6500 series SoCs which are capable of changing
33 the CPU's frequency dynamically.
34
35config CPU_FREQ_PMAC 26config CPU_FREQ_PMAC
36 bool "Support for Apple PowerBooks" 27 bool "Support for Apple PowerBooks"
37 depends on ADB_PMU && PPC32 28 depends on ADB_PMU && PPC32
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 82a1821471fd..cdce92ae2e8b 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -59,6 +59,7 @@ arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ) += exynos4x12-cpufreq.o
59arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o 59arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o
60obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o 60obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o
61obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o 61obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o
62obj-$(CONFIG_ARM_HISI_ACPU_CPUFREQ) += hisi-acpu-cpufreq.o
62obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o 63obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o
63obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o 64obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o
64obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o 65obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o
@@ -85,7 +86,7 @@ obj-$(CONFIG_CPU_FREQ_CBE) += ppc-cbe-cpufreq.o
85ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o 86ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o
86obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o 87obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o
87obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o 88obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o
88obj-$(CONFIG_PPC_CORENET_CPUFREQ) += ppc-corenet-cpufreq.o 89obj-$(CONFIG_QORIQ_CPUFREQ) += qoriq-cpufreq.o
89obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o 90obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o
90obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o 91obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o
91obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o 92obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o
diff --git a/drivers/cpufreq/hisi-acpu-cpufreq.c b/drivers/cpufreq/hisi-acpu-cpufreq.c
new file mode 100644
index 000000000000..026d5b2224de
--- /dev/null
+++ b/drivers/cpufreq/hisi-acpu-cpufreq.c
@@ -0,0 +1,42 @@
1/*
2 * Hisilicon Platforms Using ACPU CPUFreq Support
3 *
4 * Copyright (c) 2015 Hisilicon Limited.
5 * Copyright (c) 2015 Linaro Limited.
6 *
7 * Leo Yan <leo.yan@linaro.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
21#include <linux/err.h>
22#include <linux/init.h>
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/of.h>
26#include <linux/platform_device.h>
27
28static int __init hisi_acpu_cpufreq_driver_init(void)
29{
30 struct platform_device *pdev;
31
32 if (!of_machine_is_compatible("hisilicon,hi6220"))
33 return -ENODEV;
34
35 pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
36 return PTR_ERR_OR_ZERO(pdev);
37}
38module_init(hisi_acpu_cpufreq_driver_init);
39
40MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
41MODULE_DESCRIPTION("Hisilicon acpu cpufreq driver");
42MODULE_LICENSE("GPL v2");
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 872c5772c5d3..c5b81beccc8e 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -614,6 +614,19 @@ static void core_set_pstate(struct cpudata *cpudata, int pstate)
614 wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val); 614 wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val);
615} 615}
616 616
617static int knl_get_turbo_pstate(void)
618{
619 u64 value;
620 int nont, ret;
621
622 rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value);
623 nont = core_get_max_pstate();
624 ret = (((value) >> 8) & 0xFF);
625 if (ret <= nont)
626 ret = nont;
627 return ret;
628}
629
617static struct cpu_defaults core_params = { 630static struct cpu_defaults core_params = {
618 .pid_policy = { 631 .pid_policy = {
619 .sample_rate_ms = 10, 632 .sample_rate_ms = 10,
@@ -651,6 +664,23 @@ static struct cpu_defaults byt_params = {
651 }, 664 },
652}; 665};
653 666
667static struct cpu_defaults knl_params = {
668 .pid_policy = {
669 .sample_rate_ms = 10,
670 .deadband = 0,
671 .setpoint = 97,
672 .p_gain_pct = 20,
673 .d_gain_pct = 0,
674 .i_gain_pct = 0,
675 },
676 .funcs = {
677 .get_max = core_get_max_pstate,
678 .get_min = core_get_min_pstate,
679 .get_turbo = knl_get_turbo_pstate,
680 .set = core_set_pstate,
681 },
682};
683
654static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) 684static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
655{ 685{
656 int max_perf = cpu->pstate.turbo_pstate; 686 int max_perf = cpu->pstate.turbo_pstate;
@@ -865,6 +895,7 @@ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
865 ICPU(0x4e, core_params), 895 ICPU(0x4e, core_params),
866 ICPU(0x4f, core_params), 896 ICPU(0x4f, core_params),
867 ICPU(0x56, core_params), 897 ICPU(0x56, core_params),
898 ICPU(0x57, knl_params),
868 {} 899 {}
869}; 900};
870MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); 901MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids);
@@ -1024,25 +1055,11 @@ static unsigned int force_load;
1024 1055
1025static int intel_pstate_msrs_not_valid(void) 1056static int intel_pstate_msrs_not_valid(void)
1026{ 1057{
1027 /* Check that all the msr's we are using are valid. */
1028 u64 aperf, mperf, tmp;
1029
1030 rdmsrl(MSR_IA32_APERF, aperf);
1031 rdmsrl(MSR_IA32_MPERF, mperf);
1032
1033 if (!pstate_funcs.get_max() || 1058 if (!pstate_funcs.get_max() ||
1034 !pstate_funcs.get_min() || 1059 !pstate_funcs.get_min() ||
1035 !pstate_funcs.get_turbo()) 1060 !pstate_funcs.get_turbo())
1036 return -ENODEV; 1061 return -ENODEV;
1037 1062
1038 rdmsrl(MSR_IA32_APERF, tmp);
1039 if (!(tmp - aperf))
1040 return -ENODEV;
1041
1042 rdmsrl(MSR_IA32_MPERF, tmp);
1043 if (!(tmp - mperf))
1044 return -ENODEV;
1045
1046 return 0; 1063 return 0;
1047} 1064}
1048 1065
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 2dfd4fdb5a52..ebef0d8279c7 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -34,9 +34,13 @@
34#include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */ 34#include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */
35 35
36#define POWERNV_MAX_PSTATES 256 36#define POWERNV_MAX_PSTATES 256
37#define PMSR_PSAFE_ENABLE (1UL << 30)
38#define PMSR_SPR_EM_DISABLE (1UL << 31)
39#define PMSR_MAX(x) ((x >> 32) & 0xFF)
40#define PMSR_LP(x) ((x >> 48) & 0xFF)
37 41
38static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1]; 42static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
39static bool rebooting; 43static bool rebooting, throttled;
40 44
41/* 45/*
42 * Note: The set of pstates consists of contiguous integers, the 46 * Note: The set of pstates consists of contiguous integers, the
@@ -294,6 +298,44 @@ static inline unsigned int get_nominal_index(void)
294 return powernv_pstate_info.max - powernv_pstate_info.nominal; 298 return powernv_pstate_info.max - powernv_pstate_info.nominal;
295} 299}
296 300
301static void powernv_cpufreq_throttle_check(unsigned int cpu)
302{
303 unsigned long pmsr;
304 int pmsr_pmax, pmsr_lp;
305
306 pmsr = get_pmspr(SPRN_PMSR);
307
308 /* Check for Pmax Capping */
309 pmsr_pmax = (s8)PMSR_MAX(pmsr);
310 if (pmsr_pmax != powernv_pstate_info.max) {
311 throttled = true;
312 pr_info("CPU %d Pmax is reduced to %d\n", cpu, pmsr_pmax);
313 pr_info("Max allowed Pstate is capped\n");
314 }
315
316 /*
317 * Check for Psafe by reading LocalPstate
318 * or check if Psafe_mode_active is set in PMSR.
319 */
320 pmsr_lp = (s8)PMSR_LP(pmsr);
321 if ((pmsr_lp < powernv_pstate_info.min) ||
322 (pmsr & PMSR_PSAFE_ENABLE)) {
323 throttled = true;
324 pr_info("Pstate set to safe frequency\n");
325 }
326
327 /* Check if SPR_EM_DISABLE is set in PMSR */
328 if (pmsr & PMSR_SPR_EM_DISABLE) {
329 throttled = true;
330 pr_info("Frequency Control disabled from OS\n");
331 }
332
333 if (throttled) {
334 pr_info("PMSR = %16lx\n", pmsr);
335 pr_crit("CPU Frequency could be throttled\n");
336 }
337}
338
297/* 339/*
298 * powernv_cpufreq_target_index: Sets the frequency corresponding to 340 * powernv_cpufreq_target_index: Sets the frequency corresponding to
299 * the cpufreq table entry indexed by new_index on the cpus in the 341 * the cpufreq table entry indexed by new_index on the cpus in the
@@ -307,6 +349,9 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
307 if (unlikely(rebooting) && new_index != get_nominal_index()) 349 if (unlikely(rebooting) && new_index != get_nominal_index())
308 return 0; 350 return 0;
309 351
352 if (!throttled)
353 powernv_cpufreq_throttle_check(smp_processor_id());
354
310 freq_data.pstate_id = powernv_freqs[new_index].driver_data; 355 freq_data.pstate_id = powernv_freqs[new_index].driver_data;
311 356
312 /* 357 /*
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 7cb4b766cf94..88b21ae0d6b0 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/qoriq-cpufreq.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright 2013 Freescale Semiconductor, Inc. 2 * Copyright 2013 Freescale Semiconductor, Inc.
3 * 3 *
4 * CPU Frequency Scaling driver for Freescale PowerPC corenet SoCs. 4 * CPU Frequency Scaling driver for Freescale QorIQ SoCs.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -20,12 +20,13 @@
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <sysdev/fsl_soc.h>
24 23
24#if !defined(CONFIG_ARM)
25#include <asm/smp.h> /* for get_hard_smp_processor_id() in UP configs */ 25#include <asm/smp.h> /* for get_hard_smp_processor_id() in UP configs */
26#endif
26 27
27/** 28/**
28 * struct cpu_data - per CPU data struct 29 * struct cpu_data
29 * @parent: the parent node of cpu clock 30 * @parent: the parent node of cpu clock
30 * @table: frequency table 31 * @table: frequency table
31 */ 32 */
@@ -69,17 +70,78 @@ static const struct soc_data sdata[] = {
69static u32 min_cpufreq; 70static u32 min_cpufreq;
70static const u32 *fmask; 71static const u32 *fmask;
71 72
72static DEFINE_PER_CPU(struct cpu_data *, cpu_data); 73#if defined(CONFIG_ARM)
74static int get_cpu_physical_id(int cpu)
75{
76 return topology_core_id(cpu);
77}
78#else
79static int get_cpu_physical_id(int cpu)
80{
81 return get_hard_smp_processor_id(cpu);
82}
83#endif
73 84
74/* cpumask in a cluster */ 85static u32 get_bus_freq(void)
75static DEFINE_PER_CPU(cpumask_var_t, cpu_mask); 86{
87 struct device_node *soc;
88 u32 sysfreq;
89
90 soc = of_find_node_by_type(NULL, "soc");
91 if (!soc)
92 return 0;
93
94 if (of_property_read_u32(soc, "bus-frequency", &sysfreq))
95 sysfreq = 0;
76 96
77#ifndef CONFIG_SMP 97 of_node_put(soc);
78static inline const struct cpumask *cpu_core_mask(int cpu) 98
99 return sysfreq;
100}
101
102static struct device_node *cpu_to_clk_node(int cpu)
79{ 103{
80 return cpumask_of(0); 104 struct device_node *np, *clk_np;
105
106 if (!cpu_present(cpu))
107 return NULL;
108
109 np = of_get_cpu_node(cpu, NULL);
110 if (!np)
111 return NULL;
112
113 clk_np = of_parse_phandle(np, "clocks", 0);
114 if (!clk_np)
115 return NULL;
116
117 of_node_put(np);
118
119 return clk_np;
120}
121
122/* traverse cpu nodes to get cpu mask of sharing clock wire */
123static void set_affected_cpus(struct cpufreq_policy *policy)
124{
125 struct device_node *np, *clk_np;
126 struct cpumask *dstp = policy->cpus;
127 int i;
128
129 np = cpu_to_clk_node(policy->cpu);
130 if (!np)
131 return;
132
133 for_each_present_cpu(i) {
134 clk_np = cpu_to_clk_node(i);
135 if (!clk_np)
136 continue;
137
138 if (clk_np == np)
139 cpumask_set_cpu(i, dstp);
140
141 of_node_put(clk_np);
142 }
143 of_node_put(np);
81} 144}
82#endif
83 145
84/* reduce the duplicated frequencies in frequency table */ 146/* reduce the duplicated frequencies in frequency table */
85static void freq_table_redup(struct cpufreq_frequency_table *freq_table, 147static void freq_table_redup(struct cpufreq_frequency_table *freq_table,
@@ -107,6 +169,7 @@ static void freq_table_sort(struct cpufreq_frequency_table *freq_table,
107 int i, j, ind; 169 int i, j, ind;
108 unsigned int freq, max_freq; 170 unsigned int freq, max_freq;
109 struct cpufreq_frequency_table table; 171 struct cpufreq_frequency_table table;
172
110 for (i = 0; i < count - 1; i++) { 173 for (i = 0; i < count - 1; i++) {
111 max_freq = freq_table[i].frequency; 174 max_freq = freq_table[i].frequency;
112 ind = i; 175 ind = i;
@@ -131,7 +194,7 @@ static void freq_table_sort(struct cpufreq_frequency_table *freq_table,
131 } 194 }
132} 195}
133 196
134static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) 197static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy)
135{ 198{
136 struct device_node *np; 199 struct device_node *np;
137 int i, count, ret; 200 int i, count, ret;
@@ -147,10 +210,8 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
147 return -ENODEV; 210 return -ENODEV;
148 211
149 data = kzalloc(sizeof(*data), GFP_KERNEL); 212 data = kzalloc(sizeof(*data), GFP_KERNEL);
150 if (!data) { 213 if (!data)
151 pr_err("%s: no memory\n", __func__);
152 goto err_np; 214 goto err_np;
153 }
154 215
155 policy->clk = of_clk_get(np, 0); 216 policy->clk = of_clk_get(np, 0);
156 if (IS_ERR(policy->clk)) { 217 if (IS_ERR(policy->clk)) {
@@ -172,7 +233,7 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
172 } 233 }
173 234
174 if (fmask) 235 if (fmask)
175 mask = fmask[get_hard_smp_processor_id(cpu)]; 236 mask = fmask[get_cpu_physical_id(cpu)];
176 else 237 else
177 mask = 0x0; 238 mask = 0x0;
178 239
@@ -203,13 +264,12 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
203 data->table = table; 264 data->table = table;
204 265
205 /* update ->cpus if we have cluster, no harm if not */ 266 /* update ->cpus if we have cluster, no harm if not */
206 cpumask_copy(policy->cpus, per_cpu(cpu_mask, cpu)); 267 set_affected_cpus(policy);
207 for_each_cpu(i, per_cpu(cpu_mask, cpu)) 268 policy->driver_data = data;
208 per_cpu(cpu_data, i) = data;
209 269
210 /* Minimum transition latency is 12 platform clocks */ 270 /* Minimum transition latency is 12 platform clocks */
211 u64temp = 12ULL * NSEC_PER_SEC; 271 u64temp = 12ULL * NSEC_PER_SEC;
212 do_div(u64temp, fsl_get_sys_freq()); 272 do_div(u64temp, get_bus_freq());
213 policy->cpuinfo.transition_latency = u64temp + 1; 273 policy->cpuinfo.transition_latency = u64temp + 1;
214 274
215 of_node_put(np); 275 of_node_put(np);
@@ -221,7 +281,7 @@ err_nomem1:
221err_node: 281err_node:
222 of_node_put(data->parent); 282 of_node_put(data->parent);
223err_nomem2: 283err_nomem2:
224 per_cpu(cpu_data, cpu) = NULL; 284 policy->driver_data = NULL;
225 kfree(data); 285 kfree(data);
226err_np: 286err_np:
227 of_node_put(np); 287 of_node_put(np);
@@ -229,43 +289,40 @@ err_np:
229 return -ENODEV; 289 return -ENODEV;
230} 290}
231 291
232static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy) 292static int __exit qoriq_cpufreq_cpu_exit(struct cpufreq_policy *policy)
233{ 293{
234 struct cpu_data *data = per_cpu(cpu_data, policy->cpu); 294 struct cpu_data *data = policy->driver_data;
235 unsigned int cpu;
236 295
237 of_node_put(data->parent); 296 of_node_put(data->parent);
238 kfree(data->table); 297 kfree(data->table);
239 kfree(data); 298 kfree(data);
240 299 policy->driver_data = NULL;
241 for_each_cpu(cpu, per_cpu(cpu_mask, policy->cpu))
242 per_cpu(cpu_data, cpu) = NULL;
243 300
244 return 0; 301 return 0;
245} 302}
246 303
247static int corenet_cpufreq_target(struct cpufreq_policy *policy, 304static int qoriq_cpufreq_target(struct cpufreq_policy *policy,
248 unsigned int index) 305 unsigned int index)
249{ 306{
250 struct clk *parent; 307 struct clk *parent;
251 struct cpu_data *data = per_cpu(cpu_data, policy->cpu); 308 struct cpu_data *data = policy->driver_data;
252 309
253 parent = of_clk_get(data->parent, data->table[index].driver_data); 310 parent = of_clk_get(data->parent, data->table[index].driver_data);
254 return clk_set_parent(policy->clk, parent); 311 return clk_set_parent(policy->clk, parent);
255} 312}
256 313
257static struct cpufreq_driver ppc_corenet_cpufreq_driver = { 314static struct cpufreq_driver qoriq_cpufreq_driver = {
258 .name = "ppc_cpufreq", 315 .name = "qoriq_cpufreq",
259 .flags = CPUFREQ_CONST_LOOPS, 316 .flags = CPUFREQ_CONST_LOOPS,
260 .init = corenet_cpufreq_cpu_init, 317 .init = qoriq_cpufreq_cpu_init,
261 .exit = __exit_p(corenet_cpufreq_cpu_exit), 318 .exit = __exit_p(qoriq_cpufreq_cpu_exit),
262 .verify = cpufreq_generic_frequency_table_verify, 319 .verify = cpufreq_generic_frequency_table_verify,
263 .target_index = corenet_cpufreq_target, 320 .target_index = qoriq_cpufreq_target,
264 .get = cpufreq_generic_get, 321 .get = cpufreq_generic_get,
265 .attr = cpufreq_generic_attr, 322 .attr = cpufreq_generic_attr,
266}; 323};
267 324
268static const struct of_device_id node_matches[] __initdata = { 325static const struct of_device_id node_matches[] __initconst = {
269 { .compatible = "fsl,p2041-clockgen", .data = &sdata[0], }, 326 { .compatible = "fsl,p2041-clockgen", .data = &sdata[0], },
270 { .compatible = "fsl,p3041-clockgen", .data = &sdata[0], }, 327 { .compatible = "fsl,p3041-clockgen", .data = &sdata[0], },
271 { .compatible = "fsl,p5020-clockgen", .data = &sdata[1], }, 328 { .compatible = "fsl,p5020-clockgen", .data = &sdata[1], },
@@ -275,61 +332,43 @@ static const struct of_device_id node_matches[] __initdata = {
275 {} 332 {}
276}; 333};
277 334
278static int __init ppc_corenet_cpufreq_init(void) 335static int __init qoriq_cpufreq_init(void)
279{ 336{
280 int ret; 337 int ret;
281 struct device_node *np; 338 struct device_node *np;
282 const struct of_device_id *match; 339 const struct of_device_id *match;
283 const struct soc_data *data; 340 const struct soc_data *data;
284 unsigned int cpu;
285 341
286 np = of_find_matching_node(NULL, node_matches); 342 np = of_find_matching_node(NULL, node_matches);
287 if (!np) 343 if (!np)
288 return -ENODEV; 344 return -ENODEV;
289 345
290 for_each_possible_cpu(cpu) {
291 if (!alloc_cpumask_var(&per_cpu(cpu_mask, cpu), GFP_KERNEL))
292 goto err_mask;
293 cpumask_copy(per_cpu(cpu_mask, cpu), cpu_core_mask(cpu));
294 }
295
296 match = of_match_node(node_matches, np); 346 match = of_match_node(node_matches, np);
297 data = match->data; 347 data = match->data;
298 if (data) { 348 if (data) {
299 if (data->flag) 349 if (data->flag)
300 fmask = data->freq_mask; 350 fmask = data->freq_mask;
301 min_cpufreq = fsl_get_sys_freq(); 351 min_cpufreq = get_bus_freq();
302 } else { 352 } else {
303 min_cpufreq = fsl_get_sys_freq() / 2; 353 min_cpufreq = get_bus_freq() / 2;
304 } 354 }
305 355
306 of_node_put(np); 356 of_node_put(np);
307 357
308 ret = cpufreq_register_driver(&ppc_corenet_cpufreq_driver); 358 ret = cpufreq_register_driver(&qoriq_cpufreq_driver);
309 if (!ret) 359 if (!ret)
310 pr_info("Freescale PowerPC corenet CPU frequency scaling driver\n"); 360 pr_info("Freescale QorIQ CPU frequency scaling driver\n");
311 361
312 return ret; 362 return ret;
313
314err_mask:
315 for_each_possible_cpu(cpu)
316 free_cpumask_var(per_cpu(cpu_mask, cpu));
317
318 return -ENOMEM;
319} 363}
320module_init(ppc_corenet_cpufreq_init); 364module_init(qoriq_cpufreq_init);
321 365
322static void __exit ppc_corenet_cpufreq_exit(void) 366static void __exit qoriq_cpufreq_exit(void)
323{ 367{
324 unsigned int cpu; 368 cpufreq_unregister_driver(&qoriq_cpufreq_driver);
325
326 for_each_possible_cpu(cpu)
327 free_cpumask_var(per_cpu(cpu_mask, cpu));
328
329 cpufreq_unregister_driver(&ppc_corenet_cpufreq_driver);
330} 369}
331module_exit(ppc_corenet_cpufreq_exit); 370module_exit(qoriq_cpufreq_exit);
332 371
333MODULE_LICENSE("GPL"); 372MODULE_LICENSE("GPL");
334MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>"); 373MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>");
335MODULE_DESCRIPTION("cpufreq driver for Freescale e500mc series SoCs"); 374MODULE_DESCRIPTION("cpufreq driver for Freescale QorIQ series SoCs");
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 512cb8e2805e..ceedafbd23e0 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -903,6 +903,11 @@ static const struct cppi_glue_infos *get_glue_info(struct device *dev)
903 return of_id->data; 903 return of_id->data;
904} 904}
905 905
906#define CPPI41_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
907 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \
908 BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \
909 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES))
910
906static int cppi41_dma_probe(struct platform_device *pdev) 911static int cppi41_dma_probe(struct platform_device *pdev)
907{ 912{
908 struct cppi41_dd *cdd; 913 struct cppi41_dd *cdd;
@@ -926,6 +931,10 @@ static int cppi41_dma_probe(struct platform_device *pdev)
926 cdd->ddev.device_issue_pending = cppi41_dma_issue_pending; 931 cdd->ddev.device_issue_pending = cppi41_dma_issue_pending;
927 cdd->ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg; 932 cdd->ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg;
928 cdd->ddev.device_terminate_all = cppi41_stop_chan; 933 cdd->ddev.device_terminate_all = cppi41_stop_chan;
934 cdd->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
935 cdd->ddev.src_addr_widths = CPPI41_DMA_BUSWIDTHS;
936 cdd->ddev.dst_addr_widths = CPPI41_DMA_BUSWIDTHS;
937 cdd->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
929 cdd->ddev.dev = dev; 938 cdd->ddev.dev = dev;
930 INIT_LIST_HEAD(&cdd->ddev.channels); 939 INIT_LIST_HEAD(&cdd->ddev.channels);
931 cpp41_dma_info.dma_cap = cdd->ddev.cap_mask; 940 cpp41_dma_info.dma_cap = cdd->ddev.cap_mask;
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index f15712f2fec6..ac336a961dea 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -859,9 +859,6 @@ int dma_async_device_register(struct dma_device *device)
859 BUG_ON(!device->device_issue_pending); 859 BUG_ON(!device->device_issue_pending);
860 BUG_ON(!device->dev); 860 BUG_ON(!device->dev);
861 861
862 WARN(dma_has_cap(DMA_SLAVE, device->cap_mask) && !device->directions,
863 "this driver doesn't support generic slave capabilities reporting\n");
864
865 /* note: this only matters in the 862 /* note: this only matters in the
866 * CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH=n case 863 * CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH=n case
867 */ 864 */
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 550a5eafbd38..ab892be26dc2 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -17,6 +17,8 @@
17 17
18enum of_gpio_flags; 18enum of_gpio_flags;
19 19
20struct acpi_device;
21
20/** 22/**
21 * struct acpi_gpio_info - ACPI GPIO specific information 23 * struct acpi_gpio_info - ACPI GPIO specific information
22 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo 24 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index c270f5f9a8f9..538d6910b550 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -166,7 +166,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
166 /* fast mode by default because of legacy reasons */ 166 /* fast mode by default because of legacy reasons */
167 clk_freq = 400000; 167 clk_freq = 400000;
168 168
169 if (ACPI_COMPANION(&pdev->dev)) { 169 if (has_acpi_companion(&pdev->dev)) {
170 dw_i2c_acpi_configure(pdev); 170 dw_i2c_acpi_configure(pdev);
171 } else if (pdev->dev.of_node) { 171 } else if (pdev->dev.of_node) {
172 of_property_read_u32(pdev->dev.of_node, 172 of_property_read_u32(pdev->dev.of_node,
@@ -286,7 +286,7 @@ static int dw_i2c_remove(struct platform_device *pdev)
286 pm_runtime_put(&pdev->dev); 286 pm_runtime_put(&pdev->dev);
287 pm_runtime_disable(&pdev->dev); 287 pm_runtime_disable(&pdev->dev);
288 288
289 if (ACPI_COMPANION(&pdev->dev)) 289 if (has_acpi_companion(&pdev->dev))
290 dw_i2c_acpi_unconfigure(pdev); 290 dw_i2c_acpi_unconfigure(pdev);
291 291
292 return 0; 292 return 0;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index edf274cabe81..c87c31387e2d 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -133,7 +133,7 @@ static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level,
133 return AE_OK; 133 return AE_OK;
134 134
135 memset(&info, 0, sizeof(info)); 135 memset(&info, 0, sizeof(info));
136 info.acpi_node.companion = adev; 136 info.fwnode = acpi_fwnode_handle(adev);
137 info.irq = -1; 137 info.irq = -1;
138 138
139 INIT_LIST_HEAD(&resource_list); 139 INIT_LIST_HEAD(&resource_list);
@@ -971,7 +971,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
971 client->dev.bus = &i2c_bus_type; 971 client->dev.bus = &i2c_bus_type;
972 client->dev.type = &i2c_client_type; 972 client->dev.type = &i2c_client_type;
973 client->dev.of_node = info->of_node; 973 client->dev.of_node = info->of_node;
974 ACPI_COMPANION_SET(&client->dev, info->acpi_node.companion); 974 client->dev.fwnode = info->fwnode;
975 975
976 i2c_dev_set_name(adap, client); 976 i2c_dev_set_name(adap, client);
977 status = device_register(&client->dev); 977 status = device_register(&client->dev);
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index e5f3db831373..f5f2b62471da 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -96,17 +96,5 @@ static struct pnp_driver idepnp_driver = {
96 .remove = idepnp_remove, 96 .remove = idepnp_remove,
97}; 97};
98 98
99static int __init pnpide_init(void) 99module_pnp_driver(idepnp_driver);
100{
101 return pnp_register_driver(&idepnp_driver);
102}
103
104static void __exit pnpide_exit(void)
105{
106 pnp_unregister_driver(&idepnp_driver);
107}
108
109module_init(pnpide_init);
110module_exit(pnpide_exit);
111
112MODULE_LICENSE("GPL"); 100MODULE_LICENSE("GPL");
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 2d1e05bdbb53..4fc1f8a7f98e 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -684,7 +684,7 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
684 if (dev_is_pci(dev)) { 684 if (dev_is_pci(dev)) {
685 pdev = to_pci_dev(dev); 685 pdev = to_pci_dev(dev);
686 segment = pci_domain_nr(pdev->bus); 686 segment = pci_domain_nr(pdev->bus);
687 } else if (ACPI_COMPANION(dev)) 687 } else if (has_acpi_companion(dev))
688 dev = &ACPI_COMPANION(dev)->dev; 688 dev = &ACPI_COMPANION(dev)->dev;
689 689
690 rcu_read_lock(); 690 rcu_read_lock();
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index e80f2c6c5f1a..8d77e1c4a141 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -1195,16 +1195,6 @@ static struct pnp_driver ene_driver = {
1195 .shutdown = ene_shutdown, 1195 .shutdown = ene_shutdown,
1196}; 1196};
1197 1197
1198static int __init ene_init(void)
1199{
1200 return pnp_register_driver(&ene_driver);
1201}
1202
1203static void ene_exit(void)
1204{
1205 pnp_unregister_driver(&ene_driver);
1206}
1207
1208module_param(sample_period, int, S_IRUGO); 1198module_param(sample_period, int, S_IRUGO);
1209MODULE_PARM_DESC(sample_period, "Hardware sample period (50 us default)"); 1199MODULE_PARM_DESC(sample_period, "Hardware sample period (50 us default)");
1210 1200
@@ -1226,5 +1216,4 @@ MODULE_DESCRIPTION
1226MODULE_AUTHOR("Maxim Levitsky"); 1216MODULE_AUTHOR("Maxim Levitsky");
1227MODULE_LICENSE("GPL"); 1217MODULE_LICENSE("GPL");
1228 1218
1229module_init(ene_init); 1219module_pnp_driver(ene_driver);
1230module_exit(ene_exit);
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index b5167573240e..5c63c2ec6183 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -684,16 +684,6 @@ static struct pnp_driver fintek_driver = {
684 .shutdown = fintek_shutdown, 684 .shutdown = fintek_shutdown,
685}; 685};
686 686
687static int __init fintek_init(void)
688{
689 return pnp_register_driver(&fintek_driver);
690}
691
692static void __exit fintek_exit(void)
693{
694 pnp_unregister_driver(&fintek_driver);
695}
696
697module_param(debug, int, S_IRUGO | S_IWUSR); 687module_param(debug, int, S_IRUGO | S_IWUSR);
698MODULE_PARM_DESC(debug, "Enable debugging output"); 688MODULE_PARM_DESC(debug, "Enable debugging output");
699 689
@@ -703,5 +693,4 @@ MODULE_DESCRIPTION(FINTEK_DESCRIPTION " driver");
703MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>"); 693MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");
704MODULE_LICENSE("GPL"); 694MODULE_LICENSE("GPL");
705 695
706module_init(fintek_init); 696module_pnp_driver(fintek_driver);
707module_exit(fintek_exit);
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 56abf9120cc2..0f301903aa6f 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -1708,21 +1708,10 @@ static struct pnp_driver ite_driver = {
1708 .shutdown = ite_shutdown, 1708 .shutdown = ite_shutdown,
1709}; 1709};
1710 1710
1711static int __init ite_init(void)
1712{
1713 return pnp_register_driver(&ite_driver);
1714}
1715
1716static void __exit ite_exit(void)
1717{
1718 pnp_unregister_driver(&ite_driver);
1719}
1720
1721MODULE_DEVICE_TABLE(pnp, ite_ids); 1711MODULE_DEVICE_TABLE(pnp, ite_ids);
1722MODULE_DESCRIPTION("ITE Tech Inc. IT8712F/ITE8512F CIR driver"); 1712MODULE_DESCRIPTION("ITE Tech Inc. IT8712F/ITE8512F CIR driver");
1723 1713
1724MODULE_AUTHOR("Juan J. Garcia de Soria <skandalfo@gmail.com>"); 1714MODULE_AUTHOR("Juan J. Garcia de Soria <skandalfo@gmail.com>");
1725MODULE_LICENSE("GPL"); 1715MODULE_LICENSE("GPL");
1726 1716
1727module_init(ite_init); 1717module_pnp_driver(ite_driver);
1728module_exit(ite_exit);
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 9c2c8635ff33..85af7a869167 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -1219,16 +1219,6 @@ static struct pnp_driver nvt_driver = {
1219 .shutdown = nvt_shutdown, 1219 .shutdown = nvt_shutdown,
1220}; 1220};
1221 1221
1222static int __init nvt_init(void)
1223{
1224 return pnp_register_driver(&nvt_driver);
1225}
1226
1227static void __exit nvt_exit(void)
1228{
1229 pnp_unregister_driver(&nvt_driver);
1230}
1231
1232module_param(debug, int, S_IRUGO | S_IWUSR); 1222module_param(debug, int, S_IRUGO | S_IWUSR);
1233MODULE_PARM_DESC(debug, "Enable debugging output"); 1223MODULE_PARM_DESC(debug, "Enable debugging output");
1234 1224
@@ -1238,5 +1228,4 @@ MODULE_DESCRIPTION("Nuvoton W83667HG-A & W83677HG-I CIR driver");
1238MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>"); 1228MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");
1239MODULE_LICENSE("GPL"); 1229MODULE_LICENSE("GPL");
1240 1230
1241module_init(nvt_init); 1231module_pnp_driver(nvt_driver);
1242module_exit(nvt_exit);
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 38552a31304a..65fed7146e9b 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -202,16 +202,17 @@ static void enclosure_remove_links(struct enclosure_component *cdev)
202{ 202{
203 char name[ENCLOSURE_NAME_SIZE]; 203 char name[ENCLOSURE_NAME_SIZE];
204 204
205 enclosure_link_name(cdev, name);
206
205 /* 207 /*
206 * In odd circumstances, like multipath devices, something else may 208 * In odd circumstances, like multipath devices, something else may
207 * already have removed the links, so check for this condition first. 209 * already have removed the links, so check for this condition first.
208 */ 210 */
209 if (!cdev->dev->kobj.sd) 211 if (cdev->dev->kobj.sd)
210 return; 212 sysfs_remove_link(&cdev->dev->kobj, name);
211 213
212 enclosure_link_name(cdev, name); 214 if (cdev->cdev.kobj.sd)
213 sysfs_remove_link(&cdev->dev->kobj, name); 215 sysfs_remove_link(&cdev->cdev.kobj, "device");
214 sysfs_remove_link(&cdev->cdev.kobj, "device");
215} 216}
216 217
217static int enclosure_add_links(struct enclosure_component *cdev) 218static int enclosure_add_links(struct enclosure_component *cdev)
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index 66c2f1a01963..aad0b59d41e3 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -1175,17 +1175,4 @@ MODULE_AUTHOR("Franco Venturi <fventuri@mediaone.net>");
1175MODULE_DESCRIPTION("General Instruments SB1000 driver"); 1175MODULE_DESCRIPTION("General Instruments SB1000 driver");
1176MODULE_LICENSE("GPL"); 1176MODULE_LICENSE("GPL");
1177 1177
1178static int __init 1178module_pnp_driver(sb1000_driver);
1179sb1000_init(void)
1180{
1181 return pnp_register_driver(&sb1000_driver);
1182}
1183
1184static void __exit
1185sb1000_exit(void)
1186{
1187 pnp_unregister_driver(&sb1000_driver);
1188}
1189
1190module_init(sb1000_init);
1191module_exit(sb1000_exit);
diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index b9429fbf1cd8..66d6d22c239c 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -624,19 +624,7 @@ static struct pnp_driver gmux_pnp_driver = {
624 }, 624 },
625}; 625};
626 626
627static int __init apple_gmux_init(void) 627module_pnp_driver(gmux_pnp_driver);
628{
629 return pnp_register_driver(&gmux_pnp_driver);
630}
631
632static void __exit apple_gmux_exit(void)
633{
634 pnp_unregister_driver(&gmux_pnp_driver);
635}
636
637module_init(apple_gmux_init);
638module_exit(apple_gmux_exit);
639
640MODULE_AUTHOR("Seth Forshee <seth.forshee@canonical.com>"); 628MODULE_AUTHOR("Seth Forshee <seth.forshee@canonical.com>");
641MODULE_DESCRIPTION("Apple Gmux Driver"); 629MODULE_DESCRIPTION("Apple Gmux Driver");
642MODULE_LICENSE("GPL"); 630MODULE_LICENSE("GPL");
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index c8873b0ca551..3151fd164614 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -3,7 +3,7 @@
3 * Bjorn Helgaas <bjorn.helgaas@hp.com> 3 * Bjorn Helgaas <bjorn.helgaas@hp.com>
4 */ 4 */
5 5
6extern spinlock_t pnp_lock; 6extern struct mutex pnp_lock;
7extern const struct attribute_group *pnp_dev_groups[]; 7extern const struct attribute_group *pnp_dev_groups[];
8void *pnp_alloc(long size); 8void *pnp_alloc(long size);
9 9
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 874c236ac1a7..31ad9fc3f701 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/mutex.h>
8#include <linux/ctype.h> 9#include <linux/ctype.h>
9#include <linux/slab.h> 10#include <linux/slab.h>
10#include <linux/pnp.h> 11#include <linux/pnp.h>
@@ -244,10 +245,10 @@ int pnp_add_card(struct pnp_card *card)
244 } 245 }
245 246
246 pnp_interface_attach_card(card); 247 pnp_interface_attach_card(card);
247 spin_lock(&pnp_lock); 248 mutex_lock(&pnp_lock);
248 list_add_tail(&card->global_list, &pnp_cards); 249 list_add_tail(&card->global_list, &pnp_cards);
249 list_add_tail(&card->protocol_list, &card->protocol->cards); 250 list_add_tail(&card->protocol_list, &card->protocol->cards);
250 spin_unlock(&pnp_lock); 251 mutex_unlock(&pnp_lock);
251 252
252 /* we wait until now to add devices in order to ensure the drivers 253 /* we wait until now to add devices in order to ensure the drivers
253 * will be able to use all of the related devices on the card 254 * will be able to use all of the related devices on the card
@@ -276,10 +277,10 @@ void pnp_remove_card(struct pnp_card *card)
276 struct list_head *pos, *temp; 277 struct list_head *pos, *temp;
277 278
278 device_unregister(&card->dev); 279 device_unregister(&card->dev);
279 spin_lock(&pnp_lock); 280 mutex_lock(&pnp_lock);
280 list_del(&card->global_list); 281 list_del(&card->global_list);
281 list_del(&card->protocol_list); 282 list_del(&card->protocol_list);
282 spin_unlock(&pnp_lock); 283 mutex_unlock(&pnp_lock);
283 list_for_each_safe(pos, temp, &card->devices) { 284 list_for_each_safe(pos, temp, &card->devices) {
284 struct pnp_dev *dev = card_to_pnp_dev(pos); 285 struct pnp_dev *dev = card_to_pnp_dev(pos);
285 pnp_remove_card_device(dev); 286 pnp_remove_card_device(dev);
@@ -297,10 +298,10 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
297 dev->card_link = NULL; 298 dev->card_link = NULL;
298 dev_set_name(&dev->dev, "%02x:%02x.%02x", 299 dev_set_name(&dev->dev, "%02x:%02x.%02x",
299 dev->protocol->number, card->number, dev->number); 300 dev->protocol->number, card->number, dev->number);
300 spin_lock(&pnp_lock); 301 mutex_lock(&pnp_lock);
301 dev->card = card; 302 dev->card = card;
302 list_add_tail(&dev->card_list, &card->devices); 303 list_add_tail(&dev->card_list, &card->devices);
303 spin_unlock(&pnp_lock); 304 mutex_unlock(&pnp_lock);
304 return 0; 305 return 0;
305} 306}
306 307
@@ -310,10 +311,10 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
310 */ 311 */
311void pnp_remove_card_device(struct pnp_dev *dev) 312void pnp_remove_card_device(struct pnp_dev *dev)
312{ 313{
313 spin_lock(&pnp_lock); 314 mutex_lock(&pnp_lock);
314 dev->card = NULL; 315 dev->card = NULL;
315 list_del(&dev->card_list); 316 list_del(&dev->card_list);
316 spin_unlock(&pnp_lock); 317 mutex_unlock(&pnp_lock);
317 __pnp_remove_device(dev); 318 __pnp_remove_device(dev);
318} 319}
319 320
@@ -426,9 +427,9 @@ int pnp_register_card_driver(struct pnp_card_driver *drv)
426 if (error < 0) 427 if (error < 0)
427 return error; 428 return error;
428 429
429 spin_lock(&pnp_lock); 430 mutex_lock(&pnp_lock);
430 list_add_tail(&drv->global_list, &pnp_card_drivers); 431 list_add_tail(&drv->global_list, &pnp_card_drivers);
431 spin_unlock(&pnp_lock); 432 mutex_unlock(&pnp_lock);
432 433
433 list_for_each_safe(pos, temp, &pnp_cards) { 434 list_for_each_safe(pos, temp, &pnp_cards) {
434 struct pnp_card *card = 435 struct pnp_card *card =
@@ -444,9 +445,9 @@ int pnp_register_card_driver(struct pnp_card_driver *drv)
444 */ 445 */
445void pnp_unregister_card_driver(struct pnp_card_driver *drv) 446void pnp_unregister_card_driver(struct pnp_card_driver *drv)
446{ 447{
447 spin_lock(&pnp_lock); 448 mutex_lock(&pnp_lock);
448 list_del(&drv->global_list); 449 list_del(&drv->global_list);
449 spin_unlock(&pnp_lock); 450 mutex_unlock(&pnp_lock);
450 pnp_unregister_driver(&drv->link); 451 pnp_unregister_driver(&drv->link);
451} 452}
452 453
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index cb6ce42f8e77..b54620e53830 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -9,6 +9,7 @@
9#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/mutex.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/string.h> 14#include <linux/string.h>
14#include <linux/slab.h> 15#include <linux/slab.h>
@@ -19,7 +20,7 @@
19 20
20static LIST_HEAD(pnp_protocols); 21static LIST_HEAD(pnp_protocols);
21LIST_HEAD(pnp_global); 22LIST_HEAD(pnp_global);
22DEFINE_SPINLOCK(pnp_lock); 23DEFINE_MUTEX(pnp_lock);
23 24
24/* 25/*
25 * ACPI or PNPBIOS should tell us about all platform devices, so we can 26 * ACPI or PNPBIOS should tell us about all platform devices, so we can
@@ -41,6 +42,13 @@ void *pnp_alloc(long size)
41 return result; 42 return result;
42} 43}
43 44
45static void pnp_remove_protocol(struct pnp_protocol *protocol)
46{
47 mutex_lock(&pnp_lock);
48 list_del(&protocol->protocol_list);
49 mutex_unlock(&pnp_lock);
50}
51
44/** 52/**
45 * pnp_protocol_register - adds a pnp protocol to the pnp layer 53 * pnp_protocol_register - adds a pnp protocol to the pnp layer
46 * @protocol: pointer to the corresponding pnp_protocol structure 54 * @protocol: pointer to the corresponding pnp_protocol structure
@@ -49,13 +57,14 @@ void *pnp_alloc(long size)
49 */ 57 */
50int pnp_register_protocol(struct pnp_protocol *protocol) 58int pnp_register_protocol(struct pnp_protocol *protocol)
51{ 59{
52 int nodenum;
53 struct list_head *pos; 60 struct list_head *pos;
61 int nodenum, ret;
54 62
55 INIT_LIST_HEAD(&protocol->devices); 63 INIT_LIST_HEAD(&protocol->devices);
56 INIT_LIST_HEAD(&protocol->cards); 64 INIT_LIST_HEAD(&protocol->cards);
57 nodenum = 0; 65 nodenum = 0;
58 spin_lock(&pnp_lock); 66
67 mutex_lock(&pnp_lock);
59 68
60 /* assign the lowest unused number */ 69 /* assign the lowest unused number */
61 list_for_each(pos, &pnp_protocols) { 70 list_for_each(pos, &pnp_protocols) {
@@ -66,12 +75,18 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
66 } 75 }
67 } 76 }
68 77
69 list_add_tail(&protocol->protocol_list, &pnp_protocols);
70 spin_unlock(&pnp_lock);
71
72 protocol->number = nodenum; 78 protocol->number = nodenum;
73 dev_set_name(&protocol->dev, "pnp%d", nodenum); 79 dev_set_name(&protocol->dev, "pnp%d", nodenum);
74 return device_register(&protocol->dev); 80
81 list_add_tail(&protocol->protocol_list, &pnp_protocols);
82
83 mutex_unlock(&pnp_lock);
84
85 ret = device_register(&protocol->dev);
86 if (ret)
87 pnp_remove_protocol(protocol);
88
89 return ret;
75} 90}
76 91
77/** 92/**
@@ -80,9 +95,7 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
80 */ 95 */
81void pnp_unregister_protocol(struct pnp_protocol *protocol) 96void pnp_unregister_protocol(struct pnp_protocol *protocol)
82{ 97{
83 spin_lock(&pnp_lock); 98 pnp_remove_protocol(protocol);
84 list_del(&protocol->protocol_list);
85 spin_unlock(&pnp_lock);
86 device_unregister(&protocol->dev); 99 device_unregister(&protocol->dev);
87} 100}
88 101
@@ -157,18 +170,36 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id,
157 return dev; 170 return dev;
158} 171}
159 172
173static void pnp_delist_device(struct pnp_dev *dev)
174{
175 mutex_lock(&pnp_lock);
176 list_del(&dev->global_list);
177 list_del(&dev->protocol_list);
178 mutex_unlock(&pnp_lock);
179}
180
160int __pnp_add_device(struct pnp_dev *dev) 181int __pnp_add_device(struct pnp_dev *dev)
161{ 182{
183 int ret;
184
162 pnp_fixup_device(dev); 185 pnp_fixup_device(dev);
163 dev->status = PNP_READY; 186 dev->status = PNP_READY;
164 spin_lock(&pnp_lock); 187
188 mutex_lock(&pnp_lock);
189
165 list_add_tail(&dev->global_list, &pnp_global); 190 list_add_tail(&dev->global_list, &pnp_global);
166 list_add_tail(&dev->protocol_list, &dev->protocol->devices); 191 list_add_tail(&dev->protocol_list, &dev->protocol->devices);
167 spin_unlock(&pnp_lock); 192
168 if (dev->protocol->can_wakeup) 193 mutex_unlock(&pnp_lock);
194
195 ret = device_register(&dev->dev);
196 if (ret)
197 pnp_delist_device(dev);
198 else if (dev->protocol->can_wakeup)
169 device_set_wakeup_capable(&dev->dev, 199 device_set_wakeup_capable(&dev->dev,
170 dev->protocol->can_wakeup(dev)); 200 dev->protocol->can_wakeup(dev));
171 return device_register(&dev->dev); 201
202 return ret;
172} 203}
173 204
174/* 205/*
@@ -203,10 +234,7 @@ int pnp_add_device(struct pnp_dev *dev)
203 234
204void __pnp_remove_device(struct pnp_dev *dev) 235void __pnp_remove_device(struct pnp_dev *dev)
205{ 236{
206 spin_lock(&pnp_lock); 237 pnp_delist_device(dev);
207 list_del(&dev->global_list);
208 list_del(&dev->protocol_list);
209 spin_unlock(&pnp_lock);
210 device_unregister(&dev->dev); 238 device_unregister(&dev->dev);
211} 239}
212 240
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index 4e57d3370368..153a493b5413 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -58,22 +58,22 @@ static const struct pnp_device_id *match_device(struct pnp_driver *drv,
58 58
59int pnp_device_attach(struct pnp_dev *pnp_dev) 59int pnp_device_attach(struct pnp_dev *pnp_dev)
60{ 60{
61 spin_lock(&pnp_lock); 61 mutex_lock(&pnp_lock);
62 if (pnp_dev->status != PNP_READY) { 62 if (pnp_dev->status != PNP_READY) {
63 spin_unlock(&pnp_lock); 63 mutex_unlock(&pnp_lock);
64 return -EBUSY; 64 return -EBUSY;
65 } 65 }
66 pnp_dev->status = PNP_ATTACHED; 66 pnp_dev->status = PNP_ATTACHED;
67 spin_unlock(&pnp_lock); 67 mutex_unlock(&pnp_lock);
68 return 0; 68 return 0;
69} 69}
70 70
71void pnp_device_detach(struct pnp_dev *pnp_dev) 71void pnp_device_detach(struct pnp_dev *pnp_dev)
72{ 72{
73 spin_lock(&pnp_lock); 73 mutex_lock(&pnp_lock);
74 if (pnp_dev->status == PNP_ATTACHED) 74 if (pnp_dev->status == PNP_ATTACHED)
75 pnp_dev->status = PNP_READY; 75 pnp_dev->status = PNP_READY;
76 spin_unlock(&pnp_lock); 76 mutex_unlock(&pnp_lock);
77 pnp_disable_dev(pnp_dev); 77 pnp_disable_dev(pnp_dev);
78} 78}
79 79
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index d2b780aade89..5153d1d69aee 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -248,6 +248,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
248 if (!dev) 248 if (!dev)
249 return -ENOMEM; 249 return -ENOMEM;
250 250
251 ACPI_COMPANION_SET(&dev->dev, device);
251 dev->data = device; 252 dev->data = device;
252 /* .enabled means the device can decode the resources */ 253 /* .enabled means the device can decode the resources */
253 dev->active = device->status.enabled; 254 dev->active = device->status.enabled;
@@ -290,11 +291,9 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
290 return error; 291 return error;
291 } 292 }
292 293
293 error = acpi_bind_one(&dev->dev, device);
294
295 num++; 294 num++;
296 295
297 return error; 296 return 0;
298} 297}
299 298
300static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, 299static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index a7cc61837818..923a2b5a2439 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5734,9 +5734,9 @@ free_port:
5734hba_free: 5734hba_free:
5735 if (phba->msix_enabled) 5735 if (phba->msix_enabled)
5736 pci_disable_msix(phba->pcidev); 5736 pci_disable_msix(phba->pcidev);
5737 iscsi_host_remove(phba->shost);
5738 pci_dev_put(phba->pcidev); 5737 pci_dev_put(phba->pcidev);
5739 iscsi_host_free(phba->shost); 5738 iscsi_host_free(phba->shost);
5739 pci_set_drvdata(pcidev, NULL);
5740disable_pci: 5740disable_pci:
5741 pci_disable_device(pcidev); 5741 pci_disable_device(pcidev);
5742 return ret; 5742 return ret;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 54d7a6cbb98a..b1a263137a23 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1311,9 +1311,11 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
1311 "rejecting I/O to dead device\n"); 1311 "rejecting I/O to dead device\n");
1312 ret = BLKPREP_KILL; 1312 ret = BLKPREP_KILL;
1313 break; 1313 break;
1314 case SDEV_QUIESCE:
1315 case SDEV_BLOCK: 1314 case SDEV_BLOCK:
1316 case SDEV_CREATED_BLOCK: 1315 case SDEV_CREATED_BLOCK:
1316 ret = BLKPREP_DEFER;
1317 break;
1318 case SDEV_QUIESCE:
1317 /* 1319 /*
1318 * If the devices is blocked we defer normal commands. 1320 * If the devices is blocked we defer normal commands.
1319 */ 1321 */
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 2accb6e47beb..77d64251af40 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1181,7 +1181,7 @@ iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1181 * traditional iSCSI block I/O. 1181 * traditional iSCSI block I/O.
1182 */ 1182 */
1183 if (iscsit_allocate_iovecs(cmd) < 0) { 1183 if (iscsit_allocate_iovecs(cmd) < 0) {
1184 return iscsit_add_reject_cmd(cmd, 1184 return iscsit_reject_cmd(cmd,
1185 ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf); 1185 ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);
1186 } 1186 }
1187 immed_data = cmd->immediate_data; 1187 immed_data = cmd->immediate_data;
@@ -3468,6 +3468,7 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
3468 tpg_np_list) { 3468 tpg_np_list) {
3469 struct iscsi_np *np = tpg_np->tpg_np; 3469 struct iscsi_np *np = tpg_np->tpg_np;
3470 bool inaddr_any = iscsit_check_inaddr_any(np); 3470 bool inaddr_any = iscsit_check_inaddr_any(np);
3471 char *fmt_str;
3471 3472
3472 if (np->np_network_transport != network_transport) 3473 if (np->np_network_transport != network_transport)
3473 continue; 3474 continue;
@@ -3495,8 +3496,12 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
3495 } 3496 }
3496 } 3497 }
3497 3498
3498 len = sprintf(buf, "TargetAddress=" 3499 if (np->np_sockaddr.ss_family == AF_INET6)
3499 "%s:%hu,%hu", 3500 fmt_str = "TargetAddress=[%s]:%hu,%hu";
3501 else
3502 fmt_str = "TargetAddress=%s:%hu,%hu";
3503
3504 len = sprintf(buf, fmt_str,
3500 inaddr_any ? conn->local_ip : np->np_ip, 3505 inaddr_any ? conn->local_ip : np->np_ip,
3501 np->np_port, 3506 np->np_port,
3502 tpg->tpgt); 3507 tpg->tpgt);
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 79b4ec3ca2db..7faa6aef9a4d 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -781,8 +781,8 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag)
781 } 781 }
782 if (flag && 782 if (flag &&
783 dev->transport->get_write_cache) { 783 dev->transport->get_write_cache) {
784 pr_err("emulate_fua_write not supported for this device\n"); 784 pr_warn("emulate_fua_write not supported for this device, ignoring\n");
785 return -EINVAL; 785 return 0;
786 } 786 }
787 if (dev->export_count) { 787 if (dev->export_count) {
788 pr_err("emulate_fua_write cannot be changed with active" 788 pr_err("emulate_fua_write cannot be changed with active"
diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c
index d1ec5804c0bb..76c515dd802b 100644
--- a/drivers/thermal/st/st_thermal.c
+++ b/drivers/thermal/st/st_thermal.c
@@ -25,7 +25,7 @@
25 * Function to allocate regfields which are common 25 * Function to allocate regfields which are common
26 * between syscfg and memory mapped based sensors 26 * between syscfg and memory mapped based sensors
27 */ 27 */
28int st_thermal_alloc_regfields(struct st_thermal_sensor *sensor) 28static int st_thermal_alloc_regfields(struct st_thermal_sensor *sensor)
29{ 29{
30 struct device *dev = sensor->dev; 30 struct device *dev = sensor->dev;
31 struct regmap *regmap = sensor->regmap; 31 struct regmap *regmap = sensor->regmap;
diff --git a/drivers/thermal/st/st_thermal_memmap.c b/drivers/thermal/st/st_thermal_memmap.c
index 067bfcdb91d6..fc0c9e198710 100644
--- a/drivers/thermal/st/st_thermal_memmap.c
+++ b/drivers/thermal/st/st_thermal_memmap.c
@@ -157,7 +157,7 @@ static const struct st_thermal_sensor_ops st_mmap_sensor_ops = {
157}; 157};
158 158
159/* Compatible device data stih416 mpe thermal sensor */ 159/* Compatible device data stih416 mpe thermal sensor */
160const struct st_thermal_compat_data st_416mpe_cdata = { 160static const struct st_thermal_compat_data st_416mpe_cdata = {
161 .reg_fields = st_mmap_thermal_regfields, 161 .reg_fields = st_mmap_thermal_regfields,
162 .ops = &st_mmap_sensor_ops, 162 .ops = &st_mmap_sensor_ops,
163 .calibration_val = 14, 163 .calibration_val = 14,
@@ -166,7 +166,7 @@ const struct st_thermal_compat_data st_416mpe_cdata = {
166}; 166};
167 167
168/* Compatible device data stih407 thermal sensor */ 168/* Compatible device data stih407 thermal sensor */
169const struct st_thermal_compat_data st_407_cdata = { 169static const struct st_thermal_compat_data st_407_cdata = {
170 .reg_fields = st_mmap_thermal_regfields, 170 .reg_fields = st_mmap_thermal_regfields,
171 .ops = &st_mmap_sensor_ops, 171 .ops = &st_mmap_sensor_ops,
172 .calibration_val = 16, 172 .calibration_val = 16,
@@ -174,19 +174,19 @@ const struct st_thermal_compat_data st_407_cdata = {
174 .crit_temp = 120, 174 .crit_temp = 120,
175}; 175};
176 176
177static struct of_device_id st_mmap_thermal_of_match[] = { 177static const struct of_device_id st_mmap_thermal_of_match[] = {
178 { .compatible = "st,stih416-mpe-thermal", .data = &st_416mpe_cdata }, 178 { .compatible = "st,stih416-mpe-thermal", .data = &st_416mpe_cdata },
179 { .compatible = "st,stih407-thermal", .data = &st_407_cdata }, 179 { .compatible = "st,stih407-thermal", .data = &st_407_cdata },
180 { /* sentinel */ } 180 { /* sentinel */ }
181}; 181};
182MODULE_DEVICE_TABLE(of, st_mmap_thermal_of_match); 182MODULE_DEVICE_TABLE(of, st_mmap_thermal_of_match);
183 183
184int st_mmap_probe(struct platform_device *pdev) 184static int st_mmap_probe(struct platform_device *pdev)
185{ 185{
186 return st_thermal_register(pdev, st_mmap_thermal_of_match); 186 return st_thermal_register(pdev, st_mmap_thermal_of_match);
187} 187}
188 188
189int st_mmap_remove(struct platform_device *pdev) 189static int st_mmap_remove(struct platform_device *pdev)
190{ 190{
191 return st_thermal_unregister(pdev); 191 return st_thermal_unregister(pdev);
192} 192}
diff --git a/drivers/thermal/st/st_thermal_syscfg.c b/drivers/thermal/st/st_thermal_syscfg.c
index 26d36a242bb8..3df5b7890703 100644
--- a/drivers/thermal/st/st_thermal_syscfg.c
+++ b/drivers/thermal/st/st_thermal_syscfg.c
@@ -104,7 +104,7 @@ static const struct st_thermal_sensor_ops st_syscfg_sensor_ops = {
104}; 104};
105 105
106/* Compatible device data for stih415 sas thermal sensor */ 106/* Compatible device data for stih415 sas thermal sensor */
107const struct st_thermal_compat_data st_415sas_cdata = { 107static const struct st_thermal_compat_data st_415sas_cdata = {
108 .sys_compat = "st,stih415-front-syscfg", 108 .sys_compat = "st,stih415-front-syscfg",
109 .reg_fields = st_415sas_regfields, 109 .reg_fields = st_415sas_regfields,
110 .ops = &st_syscfg_sensor_ops, 110 .ops = &st_syscfg_sensor_ops,
@@ -114,7 +114,7 @@ const struct st_thermal_compat_data st_415sas_cdata = {
114}; 114};
115 115
116/* Compatible device data for stih415 mpe thermal sensor */ 116/* Compatible device data for stih415 mpe thermal sensor */
117const struct st_thermal_compat_data st_415mpe_cdata = { 117static const struct st_thermal_compat_data st_415mpe_cdata = {
118 .sys_compat = "st,stih415-system-syscfg", 118 .sys_compat = "st,stih415-system-syscfg",
119 .reg_fields = st_415mpe_regfields, 119 .reg_fields = st_415mpe_regfields,
120 .ops = &st_syscfg_sensor_ops, 120 .ops = &st_syscfg_sensor_ops,
@@ -124,7 +124,7 @@ const struct st_thermal_compat_data st_415mpe_cdata = {
124}; 124};
125 125
126/* Compatible device data for stih416 sas thermal sensor */ 126/* Compatible device data for stih416 sas thermal sensor */
127const struct st_thermal_compat_data st_416sas_cdata = { 127static const struct st_thermal_compat_data st_416sas_cdata = {
128 .sys_compat = "st,stih416-front-syscfg", 128 .sys_compat = "st,stih416-front-syscfg",
129 .reg_fields = st_416sas_regfields, 129 .reg_fields = st_416sas_regfields,
130 .ops = &st_syscfg_sensor_ops, 130 .ops = &st_syscfg_sensor_ops,
@@ -134,7 +134,7 @@ const struct st_thermal_compat_data st_416sas_cdata = {
134}; 134};
135 135
136/* Compatible device data for stid127 thermal sensor */ 136/* Compatible device data for stid127 thermal sensor */
137const struct st_thermal_compat_data st_127_cdata = { 137static const struct st_thermal_compat_data st_127_cdata = {
138 .sys_compat = "st,stid127-cpu-syscfg", 138 .sys_compat = "st,stid127-cpu-syscfg",
139 .reg_fields = st_127_regfields, 139 .reg_fields = st_127_regfields,
140 .ops = &st_syscfg_sensor_ops, 140 .ops = &st_syscfg_sensor_ops,
@@ -143,7 +143,7 @@ const struct st_thermal_compat_data st_127_cdata = {
143 .crit_temp = 120, 143 .crit_temp = 120,
144}; 144};
145 145
146static struct of_device_id st_syscfg_thermal_of_match[] = { 146static const struct of_device_id st_syscfg_thermal_of_match[] = {
147 { .compatible = "st,stih415-sas-thermal", .data = &st_415sas_cdata }, 147 { .compatible = "st,stih415-sas-thermal", .data = &st_415sas_cdata },
148 { .compatible = "st,stih415-mpe-thermal", .data = &st_415mpe_cdata }, 148 { .compatible = "st,stih415-mpe-thermal", .data = &st_415mpe_cdata },
149 { .compatible = "st,stih416-sas-thermal", .data = &st_416sas_cdata }, 149 { .compatible = "st,stih416-sas-thermal", .data = &st_416sas_cdata },
@@ -152,12 +152,12 @@ static struct of_device_id st_syscfg_thermal_of_match[] = {
152}; 152};
153MODULE_DEVICE_TABLE(of, st_syscfg_thermal_of_match); 153MODULE_DEVICE_TABLE(of, st_syscfg_thermal_of_match);
154 154
155int st_syscfg_probe(struct platform_device *pdev) 155static int st_syscfg_probe(struct platform_device *pdev)
156{ 156{
157 return st_thermal_register(pdev, st_syscfg_thermal_of_match); 157 return st_thermal_register(pdev, st_syscfg_thermal_of_match);
158} 158}
159 159
160int st_syscfg_remove(struct platform_device *pdev) 160static int st_syscfg_remove(struct platform_device *pdev)
161{ 161{
162 return st_thermal_unregister(pdev); 162 return st_thermal_unregister(pdev);
163} 163}
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 174d3bcf8bd7..4108db7e10c1 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -458,8 +458,10 @@ static void update_temperature(struct thermal_zone_device *tz)
458 458
459 ret = thermal_zone_get_temp(tz, &temp); 459 ret = thermal_zone_get_temp(tz, &temp);
460 if (ret) { 460 if (ret) {
461 dev_warn(&tz->device, "failed to read out thermal zone %d\n", 461 if (ret != -EAGAIN)
462 tz->id); 462 dev_warn(&tz->device,
463 "failed to read out thermal zone (%d)\n",
464 ret);
463 return; 465 return;
464 } 466 }
465 467
diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index 1e6899bc9429..5815e81b5fc6 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -234,18 +234,7 @@ static struct pnp_driver fintek_8250_driver = {
234 .id_table = fintek_dev_table, 234 .id_table = fintek_dev_table,
235}; 235};
236 236
237static int fintek_8250_init(void) 237module_pnp_driver(fintek_8250_driver);
238{
239 return pnp_register_driver(&fintek_8250_driver);
240}
241module_init(fintek_8250_init);
242
243static void fintek_8250_exit(void)
244{
245 pnp_unregister_driver(&fintek_8250_driver);
246}
247module_exit(fintek_8250_exit);
248
249MODULE_DESCRIPTION("Fintek F812164 module"); 238MODULE_DESCRIPTION("Fintek F812164 module");
250MODULE_AUTHOR("Ricardo Ribalda <ricardo.ribalda@gmail.com>"); 239MODULE_AUTHOR("Ricardo Ribalda <ricardo.ribalda@gmail.com>");
251MODULE_LICENSE("GPL"); 240MODULE_LICENSE("GPL");
diff --git a/fs/aio.c b/fs/aio.c
index f8e52a1854c1..a793f7023755 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -278,11 +278,11 @@ static int aio_ring_mmap(struct file *file, struct vm_area_struct *vma)
278 return 0; 278 return 0;
279} 279}
280 280
281static void aio_ring_remap(struct file *file, struct vm_area_struct *vma) 281static int aio_ring_remap(struct file *file, struct vm_area_struct *vma)
282{ 282{
283 struct mm_struct *mm = vma->vm_mm; 283 struct mm_struct *mm = vma->vm_mm;
284 struct kioctx_table *table; 284 struct kioctx_table *table;
285 int i; 285 int i, res = -EINVAL;
286 286
287 spin_lock(&mm->ioctx_lock); 287 spin_lock(&mm->ioctx_lock);
288 rcu_read_lock(); 288 rcu_read_lock();
@@ -292,13 +292,17 @@ static void aio_ring_remap(struct file *file, struct vm_area_struct *vma)
292 292
293 ctx = table->table[i]; 293 ctx = table->table[i];
294 if (ctx && ctx->aio_ring_file == file) { 294 if (ctx && ctx->aio_ring_file == file) {
295 ctx->user_id = ctx->mmap_base = vma->vm_start; 295 if (!atomic_read(&ctx->dead)) {
296 ctx->user_id = ctx->mmap_base = vma->vm_start;
297 res = 0;
298 }
296 break; 299 break;
297 } 300 }
298 } 301 }
299 302
300 rcu_read_unlock(); 303 rcu_read_unlock();
301 spin_unlock(&mm->ioctx_lock); 304 spin_unlock(&mm->ioctx_lock);
305 return res;
302} 306}
303 307
304static const struct file_operations aio_ring_fops = { 308static const struct file_operations aio_ring_fops = {
@@ -727,6 +731,9 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
727err_cleanup: 731err_cleanup:
728 aio_nr_sub(ctx->max_reqs); 732 aio_nr_sub(ctx->max_reqs);
729err_ctx: 733err_ctx:
734 atomic_set(&ctx->dead, 1);
735 if (ctx->mmap_size)
736 vm_munmap(ctx->mmap_base, ctx->mmap_size);
730 aio_free_ring(ctx); 737 aio_free_ring(ctx);
731err: 738err:
732 mutex_unlock(&ctx->ring_lock); 739 mutex_unlock(&ctx->ring_lock);
@@ -748,11 +755,12 @@ static int kill_ioctx(struct mm_struct *mm, struct kioctx *ctx,
748{ 755{
749 struct kioctx_table *table; 756 struct kioctx_table *table;
750 757
751 if (atomic_xchg(&ctx->dead, 1)) 758 spin_lock(&mm->ioctx_lock);
759 if (atomic_xchg(&ctx->dead, 1)) {
760 spin_unlock(&mm->ioctx_lock);
752 return -EINVAL; 761 return -EINVAL;
762 }
753 763
754
755 spin_lock(&mm->ioctx_lock);
756 table = rcu_dereference_raw(mm->ioctx_table); 764 table = rcu_dereference_raw(mm->ioctx_table);
757 WARN_ON(ctx != table->table[ctx->id]); 765 WARN_ON(ctx != table->table[ctx->id]);
758 table->table[ctx->id] = NULL; 766 table->table[ctx->id] = NULL;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 46e0d4e857c7..ba1790e52ff2 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2394,7 +2394,6 @@ relock:
2394 /* 2394 /*
2395 * for completing the rest of the request. 2395 * for completing the rest of the request.
2396 */ 2396 */
2397 *ppos += written;
2398 count -= written; 2397 count -= written;
2399 written_buffered = generic_perform_write(file, from, *ppos); 2398 written_buffered = generic_perform_write(file, from, *ppos);
2400 /* 2399 /*
@@ -2409,7 +2408,6 @@ relock:
2409 goto out_dio; 2408 goto out_dio;
2410 } 2409 }
2411 2410
2412 iocb->ki_pos = *ppos + written_buffered;
2413 /* We need to ensure that the page cache pages are written to 2411 /* We need to ensure that the page cache pages are written to
2414 * disk and invalidated to preserve the expected O_DIRECT 2412 * disk and invalidated to preserve the expected O_DIRECT
2415 * semantics. 2413 * semantics.
@@ -2418,6 +2416,7 @@ relock:
2418 ret = filemap_write_and_wait_range(file->f_mapping, *ppos, 2416 ret = filemap_write_and_wait_range(file->f_mapping, *ppos,
2419 endbyte); 2417 endbyte);
2420 if (ret == 0) { 2418 if (ret == 0) {
2419 iocb->ki_pos = *ppos + written_buffered;
2421 written += written_buffered; 2420 written += written_buffered;
2422 invalidate_mapping_pages(mapping, 2421 invalidate_mapping_pages(mapping,
2423 *ppos >> PAGE_CACHE_SHIFT, 2422 *ppos >> PAGE_CACHE_SHIFT,
@@ -2440,10 +2439,14 @@ out_dio:
2440 /* buffered aio wouldn't have proper lock coverage today */ 2439 /* buffered aio wouldn't have proper lock coverage today */
2441 BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT)); 2440 BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT));
2442 2441
2442 if (unlikely(written <= 0))
2443 goto no_sync;
2444
2443 if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) || 2445 if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) ||
2444 ((file->f_flags & O_DIRECT) && !direct_io)) { 2446 ((file->f_flags & O_DIRECT) && !direct_io)) {
2445 ret = filemap_fdatawrite_range(file->f_mapping, *ppos, 2447 ret = filemap_fdatawrite_range(file->f_mapping,
2446 *ppos + count - 1); 2448 iocb->ki_pos - written,
2449 iocb->ki_pos - 1);
2447 if (ret < 0) 2450 if (ret < 0)
2448 written = ret; 2451 written = ret;
2449 2452
@@ -2454,10 +2457,12 @@ out_dio:
2454 } 2457 }
2455 2458
2456 if (!ret) 2459 if (!ret)
2457 ret = filemap_fdatawait_range(file->f_mapping, *ppos, 2460 ret = filemap_fdatawait_range(file->f_mapping,
2458 *ppos + count - 1); 2461 iocb->ki_pos - written,
2462 iocb->ki_pos - 1);
2459 } 2463 }
2460 2464
2465no_sync:
2461 /* 2466 /*
2462 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io 2467 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
2463 * function pointer which is called when o_direct io completes so that 2468 * function pointer which is called when o_direct io completes so that
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 61e32ec1fc4d..8de4fa90e8c4 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -252,6 +252,7 @@ struct acpi_device_pnp {
252#define acpi_device_bid(d) ((d)->pnp.bus_id) 252#define acpi_device_bid(d) ((d)->pnp.bus_id)
253#define acpi_device_adr(d) ((d)->pnp.bus_address) 253#define acpi_device_adr(d) ((d)->pnp.bus_address)
254const char *acpi_device_hid(struct acpi_device *device); 254const char *acpi_device_hid(struct acpi_device *device);
255#define acpi_device_uid(d) ((d)->pnp.unique_id)
255#define acpi_device_name(d) ((d)->pnp.device_name) 256#define acpi_device_name(d) ((d)->pnp.device_name)
256#define acpi_device_class(d) ((d)->pnp.device_class) 257#define acpi_device_class(d) ((d)->pnp.device_class)
257 258
@@ -386,7 +387,8 @@ static inline bool is_acpi_node(struct fwnode_handle *fwnode)
386 387
387static inline struct acpi_device *acpi_node(struct fwnode_handle *fwnode) 388static inline struct acpi_device *acpi_node(struct fwnode_handle *fwnode)
388{ 389{
389 return fwnode ? container_of(fwnode, struct acpi_device, fwnode) : NULL; 390 return is_acpi_node(fwnode) ?
391 container_of(fwnode, struct acpi_device, fwnode) : NULL;
390} 392}
391 393
392static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev) 394static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 24c7aa8b1d20..dd12127f171c 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -53,10 +53,16 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
53 return adev ? adev->handle : NULL; 53 return adev ? adev->handle : NULL;
54} 54}
55 55
56#define ACPI_COMPANION(dev) ((dev)->acpi_node.companion) 56#define ACPI_COMPANION(dev) acpi_node((dev)->fwnode)
57#define ACPI_COMPANION_SET(dev, adev) ACPI_COMPANION(dev) = (adev) 57#define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \
58 acpi_fwnode_handle(adev) : NULL)
58#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) 59#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
59 60
61static inline bool has_acpi_companion(struct device *dev)
62{
63 return is_acpi_node(dev->fwnode);
64}
65
60static inline void acpi_preset_companion(struct device *dev, 66static inline void acpi_preset_companion(struct device *dev,
61 struct acpi_device *parent, u64 addr) 67 struct acpi_device *parent, u64 addr)
62{ 68{
@@ -471,6 +477,11 @@ static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
471 return NULL; 477 return NULL;
472} 478}
473 479
480static inline bool has_acpi_companion(struct device *dev)
481{
482 return false;
483}
484
474static inline const char *acpi_dev_name(struct acpi_device *adev) 485static inline const char *acpi_dev_name(struct acpi_device *adev)
475{ 486{
476 return NULL; 487 return NULL;
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index c294e3e25e37..a1b25e35ea5f 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -181,7 +181,9 @@ enum rq_flag_bits {
181 __REQ_ELVPRIV, /* elevator private data attached */ 181 __REQ_ELVPRIV, /* elevator private data attached */
182 __REQ_FAILED, /* set if the request failed */ 182 __REQ_FAILED, /* set if the request failed */
183 __REQ_QUIET, /* don't worry about errors */ 183 __REQ_QUIET, /* don't worry about errors */
184 __REQ_PREEMPT, /* set for "ide_preempt" requests */ 184 __REQ_PREEMPT, /* set for "ide_preempt" requests and also
185 for requests for which the SCSI "quiesce"
186 state must be ignored. */
185 __REQ_ALLOCED, /* request came from our alloc pool */ 187 __REQ_ALLOCED, /* request came from our alloc pool */
186 __REQ_COPY_USER, /* contains copies of user pages */ 188 __REQ_COPY_USER, /* contains copies of user pages */
187 __REQ_FLUSH_SEQ, /* request for flush sequence */ 189 __REQ_FLUSH_SEQ, /* request for flush sequence */
diff --git a/include/linux/device.h b/include/linux/device.h
index 0eb8ee2dc6d1..324d02add7b4 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -38,6 +38,7 @@ struct class;
38struct subsys_private; 38struct subsys_private;
39struct bus_type; 39struct bus_type;
40struct device_node; 40struct device_node;
41struct fwnode_handle;
41struct iommu_ops; 42struct iommu_ops;
42struct iommu_group; 43struct iommu_group;
43 44
@@ -650,14 +651,6 @@ struct device_dma_parameters {
650 unsigned long segment_boundary_mask; 651 unsigned long segment_boundary_mask;
651}; 652};
652 653
653struct acpi_device;
654
655struct acpi_dev_node {
656#ifdef CONFIG_ACPI
657 struct acpi_device *companion;
658#endif
659};
660
661/** 654/**
662 * struct device - The basic device structure 655 * struct device - The basic device structure
663 * @parent: The device's "parent" device, the device to which it is attached. 656 * @parent: The device's "parent" device, the device to which it is attached.
@@ -703,7 +696,7 @@ struct acpi_dev_node {
703 * @cma_area: Contiguous memory area for dma allocations 696 * @cma_area: Contiguous memory area for dma allocations
704 * @archdata: For arch-specific additions. 697 * @archdata: For arch-specific additions.
705 * @of_node: Associated device tree node. 698 * @of_node: Associated device tree node.
706 * @acpi_node: Associated ACPI device node. 699 * @fwnode: Associated device node supplied by platform firmware.
707 * @devt: For creating the sysfs "dev". 700 * @devt: For creating the sysfs "dev".
708 * @id: device instance 701 * @id: device instance
709 * @devres_lock: Spinlock to protect the resource of the device. 702 * @devres_lock: Spinlock to protect the resource of the device.
@@ -779,7 +772,7 @@ struct device {
779 struct dev_archdata archdata; 772 struct dev_archdata archdata;
780 773
781 struct device_node *of_node; /* associated device tree node */ 774 struct device_node *of_node; /* associated device tree node */
782 struct acpi_dev_node acpi_node; /* associated ACPI device node */ 775 struct fwnode_handle *fwnode; /* firmware device node */
783 776
784 dev_t devt; /* dev_t, creates the sysfs "dev" */ 777 dev_t devt; /* dev_t, creates the sysfs "dev" */
785 u32 id; /* device instance */ 778 u32 id; /* device instance */
@@ -947,6 +940,9 @@ extern void unlock_device_hotplug(void);
947extern int lock_device_hotplug_sysfs(void); 940extern int lock_device_hotplug_sysfs(void);
948extern int device_offline(struct device *dev); 941extern int device_offline(struct device *dev);
949extern int device_online(struct device *dev); 942extern int device_online(struct device *dev);
943extern void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
944extern void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
945
950/* 946/*
951 * Root device objects for grouping under /sys/devices 947 * Root device objects for grouping under /sys/devices
952 */ 948 */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f4131e8ead74..52cc4492cb3a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1549,7 +1549,7 @@ struct file_operations {
1549 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1549 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
1550 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1550 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
1551 int (*mmap) (struct file *, struct vm_area_struct *); 1551 int (*mmap) (struct file *, struct vm_area_struct *);
1552 void (*mremap)(struct file *, struct vm_area_struct *); 1552 int (*mremap)(struct file *, struct vm_area_struct *);
1553 int (*open) (struct inode *, struct file *); 1553 int (*open) (struct inode *, struct file *);
1554 int (*flush) (struct file *, fl_owner_t id); 1554 int (*flush) (struct file *, fl_owner_t id);
1555 int (*release) (struct inode *, struct file *); 1555 int (*release) (struct inode *, struct file *);
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
new file mode 100644
index 000000000000..0408545bce42
--- /dev/null
+++ b/include/linux/fwnode.h
@@ -0,0 +1,27 @@
1/*
2 * fwnode.h - Firmware device node object handle type definition.
3 *
4 * Copyright (C) 2015, Intel Corporation
5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _LINUX_FWNODE_H_
13#define _LINUX_FWNODE_H_
14
15enum fwnode_type {
16 FWNODE_INVALID = 0,
17 FWNODE_OF,
18 FWNODE_ACPI,
19 FWNODE_PDATA,
20};
21
22struct fwnode_handle {
23 enum fwnode_type type;
24 struct fwnode_handle *secondary;
25};
26
27#endif
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index f17da50402a4..6d89575361a8 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -278,7 +278,7 @@ static inline int i2c_slave_event(struct i2c_client *client,
278 * @platform_data: stored in i2c_client.dev.platform_data 278 * @platform_data: stored in i2c_client.dev.platform_data
279 * @archdata: copied into i2c_client.dev.archdata 279 * @archdata: copied into i2c_client.dev.archdata
280 * @of_node: pointer to OpenFirmware device node 280 * @of_node: pointer to OpenFirmware device node
281 * @acpi_node: ACPI device node 281 * @fwnode: device node supplied by the platform firmware
282 * @irq: stored in i2c_client.irq 282 * @irq: stored in i2c_client.irq
283 * 283 *
284 * I2C doesn't actually support hardware probing, although controllers and 284 * I2C doesn't actually support hardware probing, although controllers and
@@ -299,7 +299,7 @@ struct i2c_board_info {
299 void *platform_data; 299 void *platform_data;
300 struct dev_archdata *archdata; 300 struct dev_archdata *archdata;
301 struct device_node *of_node; 301 struct device_node *of_node;
302 struct acpi_dev_node acpi_node; 302 struct fwnode_handle *fwnode;
303 int irq; 303 int irq;
304}; 304};
305 305
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index ae4882ca4a64..58f1e75ba105 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -59,7 +59,7 @@ extern int platform_add_devices(struct platform_device **, int);
59 59
60struct platform_device_info { 60struct platform_device_info {
61 struct device *parent; 61 struct device *parent;
62 struct acpi_dev_node acpi_node; 62 struct fwnode_handle *fwnode;
63 63
64 const char *name; 64 const char *name;
65 int id; 65 int id;
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index 6512e9cbc6d5..5df733b8f704 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -510,4 +510,16 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
510 510
511#endif /* CONFIG_PNP */ 511#endif /* CONFIG_PNP */
512 512
513/**
514 * module_pnp_driver() - Helper macro for registering a PnP driver
515 * @__pnp_driver: pnp_driver struct
516 *
517 * Helper macro for PnP drivers which do not do anything special in module
518 * init/exit. This eliminates a lot of boilerplate. Each module may only
519 * use this macro once, and calling it replaces module_init() and module_exit()
520 */
521#define module_pnp_driver(__pnp_driver) \
522 module_driver(__pnp_driver, pnp_register_driver, \
523 pnp_unregister_driver)
524
513#endif /* _LINUX_PNP_H */ 525#endif /* _LINUX_PNP_H */
diff --git a/include/linux/property.h b/include/linux/property.h
index a6a3d98bd7e9..de8bdf417a35 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -13,6 +13,7 @@
13#ifndef _LINUX_PROPERTY_H_ 13#ifndef _LINUX_PROPERTY_H_
14#define _LINUX_PROPERTY_H_ 14#define _LINUX_PROPERTY_H_
15 15
16#include <linux/fwnode.h>
16#include <linux/types.h> 17#include <linux/types.h>
17 18
18struct device; 19struct device;
@@ -40,16 +41,6 @@ int device_property_read_string_array(struct device *dev, const char *propname,
40int device_property_read_string(struct device *dev, const char *propname, 41int device_property_read_string(struct device *dev, const char *propname,
41 const char **val); 42 const char **val);
42 43
43enum fwnode_type {
44 FWNODE_INVALID = 0,
45 FWNODE_OF,
46 FWNODE_ACPI,
47};
48
49struct fwnode_handle {
50 enum fwnode_type type;
51};
52
53bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname); 44bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname);
54int fwnode_property_read_u8_array(struct fwnode_handle *fwnode, 45int fwnode_property_read_u8_array(struct fwnode_handle *fwnode,
55 const char *propname, u8 *val, 46 const char *propname, u8 *val,
@@ -140,4 +131,37 @@ static inline int fwnode_property_read_u64(struct fwnode_handle *fwnode,
140 return fwnode_property_read_u64_array(fwnode, propname, val, 1); 131 return fwnode_property_read_u64_array(fwnode, propname, val, 1);
141} 132}
142 133
134/**
135 * struct property_entry - "Built-in" device property representation.
136 * @name: Name of the property.
137 * @type: Type of the property.
138 * @nval: Number of items of type @type making up the value.
139 * @value: Value of the property (an array of @nval items of type @type).
140 */
141struct property_entry {
142 const char *name;
143 enum dev_prop_type type;
144 size_t nval;
145 union {
146 void *raw_data;
147 u8 *u8_data;
148 u16 *u16_data;
149 u32 *u32_data;
150 u64 *u64_data;
151 const char **str;
152 } value;
153};
154
155/**
156 * struct property_set - Collection of "built-in" device properties.
157 * @fwnode: Handle to be pointed to by the fwnode field of struct device.
158 * @properties: Array of properties terminated with a null entry.
159 */
160struct property_set {
161 struct fwnode_handle fwnode;
162 struct property_entry *properties;
163};
164
165void device_add_property_set(struct device *dev, struct property_set *pset);
166
143#endif /* _LINUX_PROPERTY_H_ */ 167#endif /* _LINUX_PROPERTY_H_ */
diff --git a/mm/mremap.c b/mm/mremap.c
index 57dadc025c64..2dc44b1cb1df 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -286,8 +286,14 @@ static unsigned long move_vma(struct vm_area_struct *vma,
286 old_len = new_len; 286 old_len = new_len;
287 old_addr = new_addr; 287 old_addr = new_addr;
288 new_addr = -ENOMEM; 288 new_addr = -ENOMEM;
289 } else if (vma->vm_file && vma->vm_file->f_op->mremap) 289 } else if (vma->vm_file && vma->vm_file->f_op->mremap) {
290 vma->vm_file->f_op->mremap(vma->vm_file, new_vma); 290 err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
291 if (err < 0) {
292 move_page_tables(new_vma, new_addr, vma, old_addr,
293 moved_len, true);
294 return err;
295 }
296 }
291 297
292 /* Conceal VM_ACCOUNT so old reservation is not undone */ 298 /* Conceal VM_ACCOUNT so old reservation is not undone */
293 if (vm_flags & VM_ACCOUNT) { 299 if (vm_flags & VM_ACCOUNT) {
diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c
index a422aaa3bb0c..9ee25a63f684 100644
--- a/sound/firewire/bebob/bebob_maudio.c
+++ b/sound/firewire/bebob/bebob_maudio.c
@@ -96,10 +96,10 @@ int snd_bebob_maudio_load_firmware(struct fw_unit *unit)
96 struct fw_device *device = fw_parent_device(unit); 96 struct fw_device *device = fw_parent_device(unit);
97 int err, rcode; 97 int err, rcode;
98 u64 date; 98 u64 date;
99 __be32 cues[3] = { 99 __le32 cues[3] = {
100 MAUDIO_BOOTLOADER_CUE1, 100 cpu_to_le32(MAUDIO_BOOTLOADER_CUE1),
101 MAUDIO_BOOTLOADER_CUE2, 101 cpu_to_le32(MAUDIO_BOOTLOADER_CUE2),
102 MAUDIO_BOOTLOADER_CUE3 102 cpu_to_le32(MAUDIO_BOOTLOADER_CUE3)
103 }; 103 };
104 104
105 /* check date of software used to build */ 105 /* check date of software used to build */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 74382137b9f5..f9d12c0a7e5a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2912,6 +2912,8 @@ static void alc283_init(struct hda_codec *codec)
2912 2912
2913 if (!hp_pin) 2913 if (!hp_pin)
2914 return; 2914 return;
2915
2916 msleep(30);
2915 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); 2917 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2916 2918
2917 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */ 2919 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
@@ -3607,6 +3609,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
3607 3609
3608 switch (codec->vendor_id) { 3610 switch (codec->vendor_id) {
3609 case 0x10ec0255: 3611 case 0x10ec0255:
3612 case 0x10ec0256:
3610 alc_process_coef_fw(codec, coef0255); 3613 alc_process_coef_fw(codec, coef0255);
3611 break; 3614 break;
3612 case 0x10ec0233: 3615 case 0x10ec0233:
@@ -3662,6 +3665,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3662 3665
3663 switch (codec->vendor_id) { 3666 switch (codec->vendor_id) {
3664 case 0x10ec0255: 3667 case 0x10ec0255:
3668 case 0x10ec0256:
3665 alc_write_coef_idx(codec, 0x45, 0xc489); 3669 alc_write_coef_idx(codec, 0x45, 0xc489);
3666 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 3670 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3667 alc_process_coef_fw(codec, coef0255); 3671 alc_process_coef_fw(codec, coef0255);
@@ -3731,6 +3735,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
3731 3735
3732 switch (codec->vendor_id) { 3736 switch (codec->vendor_id) {
3733 case 0x10ec0255: 3737 case 0x10ec0255:
3738 case 0x10ec0256:
3734 alc_process_coef_fw(codec, coef0255); 3739 alc_process_coef_fw(codec, coef0255);
3735 break; 3740 break;
3736 case 0x10ec0233: 3741 case 0x10ec0233:
@@ -3785,6 +3790,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
3785 3790
3786 switch (codec->vendor_id) { 3791 switch (codec->vendor_id) {
3787 case 0x10ec0255: 3792 case 0x10ec0255:
3793 case 0x10ec0256:
3788 alc_process_coef_fw(codec, coef0255); 3794 alc_process_coef_fw(codec, coef0255);
3789 break; 3795 break;
3790 case 0x10ec0233: 3796 case 0x10ec0233:
@@ -3839,6 +3845,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
3839 3845
3840 switch (codec->vendor_id) { 3846 switch (codec->vendor_id) {
3841 case 0x10ec0255: 3847 case 0x10ec0255:
3848 case 0x10ec0256:
3842 alc_process_coef_fw(codec, coef0255); 3849 alc_process_coef_fw(codec, coef0255);
3843 break; 3850 break;
3844 case 0x10ec0233: 3851 case 0x10ec0233:
@@ -3884,6 +3891,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
3884 3891
3885 switch (codec->vendor_id) { 3892 switch (codec->vendor_id) {
3886 case 0x10ec0255: 3893 case 0x10ec0255:
3894 case 0x10ec0256:
3887 alc_process_coef_fw(codec, coef0255); 3895 alc_process_coef_fw(codec, coef0255);
3888 msleep(300); 3896 msleep(300);
3889 val = alc_read_coef_idx(codec, 0x46); 3897 val = alc_read_coef_idx(codec, 0x46);
@@ -4364,6 +4372,7 @@ enum {
4364 ALC269_FIXUP_QUANTA_MUTE, 4372 ALC269_FIXUP_QUANTA_MUTE,
4365 ALC269_FIXUP_LIFEBOOK, 4373 ALC269_FIXUP_LIFEBOOK,
4366 ALC269_FIXUP_LIFEBOOK_EXTMIC, 4374 ALC269_FIXUP_LIFEBOOK_EXTMIC,
4375 ALC269_FIXUP_LIFEBOOK_HP_PIN,
4367 ALC269_FIXUP_AMIC, 4376 ALC269_FIXUP_AMIC,
4368 ALC269_FIXUP_DMIC, 4377 ALC269_FIXUP_DMIC,
4369 ALC269VB_FIXUP_AMIC, 4378 ALC269VB_FIXUP_AMIC,
@@ -4517,6 +4526,13 @@ static const struct hda_fixup alc269_fixups[] = {
4517 { } 4526 { }
4518 }, 4527 },
4519 }, 4528 },
4529 [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
4530 .type = HDA_FIXUP_PINS,
4531 .v.pins = (const struct hda_pintbl[]) {
4532 { 0x21, 0x0221102f }, /* HP out */
4533 { }
4534 },
4535 },
4520 [ALC269_FIXUP_AMIC] = { 4536 [ALC269_FIXUP_AMIC] = {
4521 .type = HDA_FIXUP_PINS, 4537 .type = HDA_FIXUP_PINS,
4522 .v.pins = (const struct hda_pintbl[]) { 4538 .v.pins = (const struct hda_pintbl[]) {
@@ -5010,6 +5026,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5010 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), 5026 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5011 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX), 5027 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
5012 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), 5028 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
5029 SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
5013 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), 5030 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
5014 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), 5031 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
5015 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC), 5032 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC),
@@ -5217,6 +5234,16 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
5217 {0x17, 0x40000000}, 5234 {0x17, 0x40000000},
5218 {0x1d, 0x40700001}, 5235 {0x1d, 0x40700001},
5219 {0x21, 0x02211050}), 5236 {0x21, 0x02211050}),
5237 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5238 {0x12, 0x90a60140},
5239 {0x13, 0x40000000},
5240 {0x14, 0x90170110},
5241 {0x19, 0x411111f0},
5242 {0x1a, 0x411111f0},
5243 {0x1b, 0x411111f0},
5244 {0x1d, 0x40700001},
5245 {0x1e, 0x411111f0},
5246 {0x21, 0x02211020}),
5220 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, 5247 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
5221 {0x12, 0x90a60130}, 5248 {0x12, 0x90a60130},
5222 {0x13, 0x40000000}, 5249 {0x13, 0x40000000},
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 9974f201a08f..474cae82a874 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -1156,25 +1156,6 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream,
1156 ret, pcm512x->pll_out); 1156 ret, pcm512x->pll_out);
1157 return ret; 1157 return ret;
1158 } 1158 }
1159
1160 gpio = PCM512x_G1OE << (4 - 1);
1161 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN,
1162 gpio, gpio);
1163 if (ret != 0) {
1164 dev_err(codec->dev, "Failed to enable gpio %d: %d\n",
1165 4, ret);
1166 return ret;
1167 }
1168
1169 gpio = PCM512x_GPIO_OUTPUT_1 + 4 - 1;
1170 ret = regmap_update_bits(pcm512x->regmap, gpio,
1171 PCM512x_GxSL, PCM512x_GxSL_PLLLK);
1172 if (ret != 0) {
1173 dev_err(codec->dev,
1174 "Failed to output pll lock on %d: %d\n",
1175 ret, 4);
1176 return ret;
1177 }
1178 } 1159 }
1179 1160
1180 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, 1161 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE,
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index dc9df007d3e3..337c317ead6f 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -192,6 +192,7 @@ static const struct rc_config {
192 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */ 192 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
193 { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */ 193 { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
194 { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ 194 { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
195 { USB_ID(0x041e, 0x3237), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
195 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ 196 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
196}; 197};
197 198
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 753a47de8459..9a28365126f9 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1113,8 +1113,13 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
1113 1113
1114bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) 1114bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
1115{ 1115{
1116 /* MS Lifecam HD-5000 doesn't support reading the sample rate. */ 1116 /* devices which do not support reading the sample rate. */
1117 return chip->usb_id == USB_ID(0x045E, 0x076D); 1117 switch (chip->usb_id) {
1118 case USB_ID(0x045E, 0x076D): /* MS Lifecam HD-5000 */
1119 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
1120 return true;
1121 }
1122 return false;
1118} 1123}
1119 1124
1120/* Marantz/Denon USB DACs need a vendor cmd to switch 1125/* Marantz/Denon USB DACs need a vendor cmd to switch