aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 23:21:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 23:21:54 -0400
commit2481bc75283ea10e75d5fb1a8b42af363fc4b45c (patch)
tree42dd659a23041a08955aceebab859b616164c2f6 /drivers/acpi
parent8691c130fae136bb2b7d0554422a2dff4c6ac169 (diff)
parent518b4e272d99dcb13699b229ea480bc845c141f6 (diff)
Merge tag 'pm+acpi-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management and ACPI updates from Rafael Wysocki: "These are mostly fixes and cleanups all over, although there are a few items that sort of fall into the new feature category. First off, we have new callbacks for PM domains that should help us to handle some issues related to device initialization in a better way. There also is some consolidation in the unified device properties API area allowing us to use that inferface for accessing data coming from platform initialization code in addition to firmware-provided data. We have some new device/CPU IDs in a few drivers, support for new chips and a new cpufreq driver too. Specifics: - Generic PM domains support update including new PM domain callbacks to handle device initialization better (Russell King, Rafael J Wysocki, Kevin Hilman) - Unified device properties API update including a new mechanism for accessing data provided by platform initialization code (Rafael J Wysocki, Adrian Hunter) - ARM cpuidle update including ARM32/ARM64 handling consolidation (Daniel Lezcano) - intel_idle update including support for the Silvermont Core in the Baytrail SOC and for the Airmont Core in the Cherrytrail and Braswell SOCs (Len Brown, Mathias Krause) - New cpufreq driver for Hisilicon ACPU (Leo Yan) - intel_pstate update including support for the Knights Landing chip (Dasaratharaman Chandramouli, Kristen Carlson Accardi) - QorIQ cpufreq driver update (Tang Yuantian, Arnd Bergmann) - powernv cpufreq driver update (Shilpasri G Bhat) - devfreq update including Tegra support changes (Tomeu Vizoso, MyungJoo Ham, Chanwoo Choi) - powercap RAPL (Running-Average Power Limit) driver update including support for Intel Broadwell server chips (Jacob Pan, Mathias Krause) - ACPI device enumeration update related to the handling of the special PRP0001 device ID allowing DT-style 'compatible' property to be used for ACPI device identification (Rafael J Wysocki) - ACPI EC driver update including limited _DEP support (Lan Tianyu, Lv Zheng) - ACPI backlight driver update including a new mechanism to allow native backlight handling to be forced on non-Windows 8 systems and a new quirk for Lenovo Ideapad Z570 (Aaron Lu, Hans de Goede) - New Windows Vista compatibility quirk for Sony VGN-SR19XN (Chen Yu) - Assorted ACPI fixes and cleanups (Aaron Lu, Martin Kepplinger, Masanari Iida, Mika Westerberg, Nan Li, Rafael J Wysocki) - Fixes related to suspend-to-idle for the iTCO watchdog driver and the ACPI core system suspend/resume code (Rafael J Wysocki, Chen Yu) - PM tracing support for the suspend phase of system suspend/resume transitions (Zhonghui Fu) - Configurable delay for the system suspend/resume testing facility (Brian Norris) - PNP subsystem cleanups (Peter Huewe, Rafael J Wysocki)" * tag 'pm+acpi-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (74 commits) ACPI / scan: Fix NULL pointer dereference in acpi_companion_match() ACPI / scan: Rework modalias creation when "compatible" is present intel_idle: mark cpu id array as __initconst powercap / RAPL: mark rapl_ids array as __initconst powercap / RAPL: add ID for Broadwell server intel_pstate: Knights Landing support intel_pstate: remove MSR test cpufreq: fix qoriq uniprocessor build ACPI / scan: Take the PRP0001 position in the list of IDs into account ACPI / scan: Simplify acpi_match_device() ACPI / scan: Generalize of_compatible matching device property: Introduce firmware node type for platform data device property: Make it possible to use secondary firmware nodes PM / watchdog: iTCO: stop watchdog during system suspend cpufreq: hisilicon: add acpu driver ACPI / EC: Call acpi_walk_dep_device_list() after installing EC opregion handler cpufreq: powernv: Report cpu frequency throttling intel_idle: Add support for the Airmont Core in the Cherrytrail and Braswell SOCs intel_idle: Update support for Silvermont Core in Baytrail SOC PM / devfreq: tegra: Register governor on module init ...
Diffstat (limited to 'drivers/acpi')
-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.c394
-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
13 files changed, 371 insertions, 233 deletions
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 672263a3832c..63d43677f644 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -531,8 +531,8 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
531 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && 531 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
532 (s16)(battery->rate_now) < 0) { 532 (s16)(battery->rate_now) < 0) {
533 battery->rate_now = abs((s16)battery->rate_now); 533 battery->rate_now = abs((s16)battery->rate_now);
534 printk_once(KERN_WARNING FW_BUG "battery: (dis)charge rate" 534 printk_once(KERN_WARNING FW_BUG
535 " invalid.\n"); 535 "battery: (dis)charge rate invalid.\n");
536 } 536 }
537 537
538 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) 538 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..69bc0d888c01 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;
168 }
169 modalias[len] = '\0';
170 return len;
171}
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;
185 } 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;
186 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,129 @@ 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; 250 struct mutex *physical_node_lock;
215 251
216 adev = ACPI_COMPANION(dev); 252 adev = ACPI_COMPANION(dev);
217 if (!adev) 253 if (!adev)
218 return false; 254 return NULL;
219 255
220 if (list_empty(&adev->pnp.ids)) 256 if (list_empty(&adev->pnp.ids))
221 return false; 257 return NULL;
222 258
223 mutex_lock(&adev->physical_node_lock); 259 physical_node_lock = &adev->physical_node_lock;
260 mutex_lock(physical_node_lock);
224 if (list_empty(&adev->physical_node_list)) { 261 if (list_empty(&adev->physical_node_list)) {
225 ret = false; 262 adev = NULL;
226 } else { 263 } else {
227 const struct acpi_device_physical_node *node; 264 const struct acpi_device_physical_node *node;
228 265
229 node = list_first_entry(&adev->physical_node_list, 266 node = list_first_entry(&adev->physical_node_list,
230 struct acpi_device_physical_node, node); 267 struct acpi_device_physical_node, node);
231 ret = node->dev == dev; 268 if (node->dev != dev)
269 adev = NULL;
232 } 270 }
233 mutex_unlock(&adev->physical_node_lock); 271 mutex_unlock(physical_node_lock);
234 272
235 return ret; 273 return adev;
236} 274}
237 275
238/* 276static int __acpi_device_uevent_modalias(struct acpi_device *adev,
239 * Creates uevent modalias field for ACPI enumerated devices. 277 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{ 278{
246 int len; 279 int len;
247 280
248 if (!acpi_companion_match(dev)) 281 if (!adev)
249 return -ENODEV; 282 return -ENODEV;
250 283
284 if (list_empty(&adev->pnp.ids))
285 return 0;
286
251 if (add_uevent_var(env, "MODALIAS=")) 287 if (add_uevent_var(env, "MODALIAS="))
252 return -ENOMEM; 288 return -ENOMEM;
253 len = create_modalias(ACPI_COMPANION(dev), &env->buf[env->buflen - 1], 289
254 sizeof(env->buf) - env->buflen); 290 len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
255 if (len <= 0) 291 sizeof(env->buf) - env->buflen);
292 if (len < 0)
293 return len;
294
295 env->buflen += len;
296 if (!adev->data.of_compatible)
297 return 0;
298
299 if (len > 0 && add_uevent_var(env, "MODALIAS="))
300 return -ENOMEM;
301
302 len = create_of_modalias(adev, &env->buf[env->buflen - 1],
303 sizeof(env->buf) - env->buflen);
304 if (len < 0)
256 return len; 305 return len;
306
257 env->buflen += len; 307 env->buflen += len;
308
258 return 0; 309 return 0;
259} 310}
260EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
261 311
262/* 312/*
263 * Creates modalias sysfs attribute for ACPI enumerated devices. 313 * Creates uevent modalias field for ACPI enumerated devices.
264 * Because the other buses does not support ACPI HIDs & CIDs. 314 * Because the other buses does not support ACPI HIDs & CIDs.
265 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get: 315 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
266 * "acpi:IBM0001:ACPI0001" 316 * "acpi:IBM0001:ACPI0001"
267 */ 317 */
268int acpi_device_modalias(struct device *dev, char *buf, int size) 318int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
269{ 319{
270 int len; 320 return __acpi_device_uevent_modalias(acpi_companion_match(dev), env);
321}
322EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
271 323
272 if (!acpi_companion_match(dev)) 324static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
325{
326 int len, count;
327
328 if (!adev)
273 return -ENODEV; 329 return -ENODEV;
274 330
275 len = create_modalias(ACPI_COMPANION(dev), buf, size -1); 331 if (list_empty(&adev->pnp.ids))
276 if (len <= 0) 332 return 0;
333
334 len = create_pnp_modalias(adev, buf, size - 1);
335 if (len < 0) {
336 return len;
337 } else if (len > 0) {
338 buf[len++] = '\n';
339 size -= len;
340 }
341 if (!adev->data.of_compatible)
277 return len; 342 return len;
278 buf[len++] = '\n'; 343
344 count = create_of_modalias(adev, buf + len, size - 1);
345 if (count < 0) {
346 return count;
347 } else if (count > 0) {
348 len += count;
349 buf[len++] = '\n';
350 }
351
279 return len; 352 return len;
280} 353}
354
355/*
356 * Creates modalias sysfs attribute for ACPI enumerated devices.
357 * Because the other buses does not support ACPI HIDs & CIDs.
358 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
359 * "acpi:IBM0001:ACPI0001"
360 */
361int acpi_device_modalias(struct device *dev, char *buf, int size)
362{
363 return __acpi_device_modalias(acpi_companion_match(dev), buf, size);
364}
281EXPORT_SYMBOL_GPL(acpi_device_modalias); 365EXPORT_SYMBOL_GPL(acpi_device_modalias);
282 366
283static ssize_t 367static ssize_t
284acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { 368acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
285 struct acpi_device *acpi_dev = to_acpi_device(dev); 369 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} 370}
294static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); 371static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
295 372
@@ -894,8 +971,51 @@ static void acpi_device_remove_files(struct acpi_device *dev)
894 ACPI Bus operations 971 ACPI Bus operations
895 -------------------------------------------------------------------------- */ 972 -------------------------------------------------------------------------- */
896 973
974/**
975 * acpi_of_match_device - Match device object using the "compatible" property.
976 * @adev: ACPI device object to match.
977 * @of_match_table: List of device IDs to match against.
978 *
979 * If @dev has an ACPI companion which has the special PRP0001 device ID in its
980 * list of identifiers and a _DSD object with the "compatible" property, use
981 * that property to match against the given list of identifiers.
982 */
983static bool acpi_of_match_device(struct acpi_device *adev,
984 const struct of_device_id *of_match_table)
985{
986 const union acpi_object *of_compatible, *obj;
987 int i, nval;
988
989 if (!adev)
990 return false;
991
992 of_compatible = adev->data.of_compatible;
993 if (!of_match_table || !of_compatible)
994 return false;
995
996 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
997 nval = of_compatible->package.count;
998 obj = of_compatible->package.elements;
999 } else { /* Must be ACPI_TYPE_STRING. */
1000 nval = 1;
1001 obj = of_compatible;
1002 }
1003 /* Now we can look for the driver DT compatible strings */
1004 for (i = 0; i < nval; i++, obj++) {
1005 const struct of_device_id *id;
1006
1007 for (id = of_match_table; id->compatible[0]; id++)
1008 if (!strcasecmp(obj->string.pointer, id->compatible))
1009 return true;
1010 }
1011
1012 return false;
1013}
1014
897static const struct acpi_device_id *__acpi_match_device( 1015static const struct acpi_device_id *__acpi_match_device(
898 struct acpi_device *device, const struct acpi_device_id *ids) 1016 struct acpi_device *device,
1017 const struct acpi_device_id *ids,
1018 const struct of_device_id *of_ids)
899{ 1019{
900 const struct acpi_device_id *id; 1020 const struct acpi_device_id *id;
901 struct acpi_hardware_id *hwid; 1021 struct acpi_hardware_id *hwid;
@@ -904,14 +1024,27 @@ static const struct acpi_device_id *__acpi_match_device(
904 * If the device is not present, it is unnecessary to load device 1024 * If the device is not present, it is unnecessary to load device
905 * driver for it. 1025 * driver for it.
906 */ 1026 */
907 if (!device->status.present) 1027 if (!device || !device->status.present)
908 return NULL; 1028 return NULL;
909 1029
910 for (id = ids; id->id[0]; id++) 1030 list_for_each_entry(hwid, &device->pnp.ids, list) {
911 list_for_each_entry(hwid, &device->pnp.ids, list) 1031 /* First, check the ACPI/PNP IDs provided by the caller. */
1032 for (id = ids; id->id[0]; id++)
912 if (!strcmp((char *) id->id, hwid->id)) 1033 if (!strcmp((char *) id->id, hwid->id))
913 return id; 1034 return id;
914 1035
1036 /*
1037 * Next, check the special "PRP0001" ID and try to match the
1038 * "compatible" property if found.
1039 *
1040 * The id returned by the below is not valid, but the only
1041 * caller passing non-NULL of_ids here is only interested in
1042 * whether or not the return value is NULL.
1043 */
1044 if (!strcmp("PRP0001", hwid->id)
1045 && acpi_of_match_device(device, of_ids))
1046 return id;
1047 }
915 return NULL; 1048 return NULL;
916} 1049}
917 1050
@@ -929,68 +1062,26 @@ static const struct acpi_device_id *__acpi_match_device(
929const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, 1062const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
930 const struct device *dev) 1063 const struct device *dev)
931{ 1064{
932 struct acpi_device *adev; 1065 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} 1066}
943EXPORT_SYMBOL_GPL(acpi_match_device); 1067EXPORT_SYMBOL_GPL(acpi_match_device);
944 1068
945int acpi_match_device_ids(struct acpi_device *device, 1069int acpi_match_device_ids(struct acpi_device *device,
946 const struct acpi_device_id *ids) 1070 const struct acpi_device_id *ids)
947{ 1071{
948 return __acpi_match_device(device, ids) ? 0 : -ENOENT; 1072 return __acpi_match_device(device, ids, NULL) ? 0 : -ENOENT;
949} 1073}
950EXPORT_SYMBOL(acpi_match_device_ids); 1074EXPORT_SYMBOL(acpi_match_device_ids);
951 1075
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, 1076bool acpi_driver_match_device(struct device *dev,
988 const struct device_driver *drv) 1077 const struct device_driver *drv)
989{ 1078{
990 if (!drv->acpi_match_table) 1079 if (!drv->acpi_match_table)
991 return acpi_of_driver_match_device(dev, drv); 1080 return acpi_of_match_device(ACPI_COMPANION(dev),
1081 drv->of_match_table);
992 1082
993 return !!acpi_match_device(drv->acpi_match_table, dev); 1083 return !!__acpi_match_device(acpi_companion_match(dev),
1084 drv->acpi_match_table, drv->of_match_table);
994} 1085}
995EXPORT_SYMBOL_GPL(acpi_driver_match_device); 1086EXPORT_SYMBOL_GPL(acpi_driver_match_device);
996 1087
@@ -1031,20 +1122,7 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
1031 1122
1032static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) 1123static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
1033{ 1124{
1034 struct acpi_device *acpi_dev = to_acpi_device(dev); 1125 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} 1126}
1049 1127
1050static void acpi_device_notify(acpi_handle handle, u32 event, void *data) 1128static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
@@ -1062,10 +1140,10 @@ static void acpi_device_notify_fixed(void *data)
1062 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); 1140 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
1063} 1141}
1064 1142
1065static acpi_status acpi_device_fixed_event(void *data) 1143static u32 acpi_device_fixed_event(void *data)
1066{ 1144{
1067 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data); 1145 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
1068 return AE_OK; 1146 return ACPI_INTERRUPT_HANDLED;
1069} 1147}
1070 1148
1071static int acpi_device_install_notify_handler(struct acpi_device *device) 1149static 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