aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/Kconfig19
-rw-r--r--drivers/acpi/Makefile8
-rw-r--r--drivers/acpi/ac.c4
-rw-r--r--drivers/acpi/acpi_ipmi.c4
-rw-r--r--drivers/acpi/acpi_memhotplug.c5
-rw-r--r--drivers/acpi/acpi_pad.c4
-rw-r--r--drivers/acpi/acpi_processor.c2
-rw-r--r--drivers/acpi/acpi_video.c4
-rw-r--r--drivers/acpi/apei/apei-base.c4
-rw-r--r--drivers/acpi/apei/einj.c4
-rw-r--r--drivers/acpi/apei/erst-dbg.c4
-rw-r--r--drivers/acpi/apei/erst.c4
-rw-r--r--drivers/acpi/apei/ghes.c4
-rw-r--r--drivers/acpi/apei/hest.c4
-rw-r--r--drivers/acpi/battery.c4
-rw-r--r--drivers/acpi/blacklist.c4
-rw-r--r--drivers/acpi/bus.c386
-rw-r--r--drivers/acpi/button.c4
-rw-r--r--drivers/acpi/cm_sbs.c4
-rw-r--r--drivers/acpi/container.c4
-rw-r--r--drivers/acpi/debugfs.c2
-rw-r--r--drivers/acpi/device_pm.c4
-rw-r--r--drivers/acpi/device_sysfs.c521
-rw-r--r--drivers/acpi/dock.c4
-rw-r--r--drivers/acpi/ec.c4
-rw-r--r--drivers/acpi/fan.c4
-rw-r--r--drivers/acpi/hed.c4
-rw-r--r--drivers/acpi/internal.h14
-rw-r--r--drivers/acpi/numa.c4
-rw-r--r--drivers/acpi/osl.c4
-rw-r--r--drivers/acpi/pci_irq.c4
-rw-r--r--drivers/acpi/pci_link.c4
-rw-r--r--drivers/acpi/pci_root.c4
-rw-r--r--drivers/acpi/pci_slot.c4
-rw-r--r--drivers/acpi/power.c4
-rw-r--r--drivers/acpi/processor_driver.c92
-rw-r--r--drivers/acpi/processor_idle.c4
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--drivers/acpi/processor_thermal.c4
-rw-r--r--drivers/acpi/processor_throttling.c4
-rw-r--r--drivers/acpi/resource.c4
-rw-r--r--drivers/acpi/sbs.c4
-rw-r--r--drivers/acpi/scan.c859
-rw-r--r--drivers/acpi/tables.c4
-rw-r--r--drivers/acpi/thermal.c4
-rw-r--r--drivers/acpi/utils.c4
-rw-r--r--drivers/mailbox/Kconfig1
-rw-r--r--drivers/mailbox/pcc.c8
-rw-r--r--include/acpi/acpi_bus.h4
-rw-r--r--include/acpi/acpi_drivers.h4
-rw-r--r--include/acpi/processor.h54
-rw-r--r--include/linux/acpi.h4
52 files changed, 1050 insertions, 1077 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 114cf48085ab..54e9729f9634 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -189,17 +189,24 @@ config ACPI_DOCK
189 This driver supports ACPI-controlled docking stations and removable 189 This driver supports ACPI-controlled docking stations and removable
190 drive bays such as the IBM Ultrabay and the Dell Module Bay. 190 drive bays such as the IBM Ultrabay and the Dell Module Bay.
191 191
192config ACPI_PROCESSOR 192config ACPI_CPU_FREQ_PSS
193 tristate "Processor" 193 bool
194 select THERMAL 194 select THERMAL
195
196config ACPI_PROCESSOR_IDLE
197 bool
195 select CPU_IDLE 198 select CPU_IDLE
199
200config ACPI_PROCESSOR
201 tristate "Processor"
196 depends on X86 || IA64 202 depends on X86 || IA64
203 select ACPI_PROCESSOR_IDLE
204 select ACPI_CPU_FREQ_PSS
197 default y 205 default y
198 help 206 help
199 This driver installs ACPI as the idle handler for Linux and uses 207 This driver adds support for the ACPI Processor package. It is required
200 ACPI C2 and C3 processor states to save power on systems that 208 by several flavors of cpufreq performance-state, thermal, throttling and
201 support it. It is required by several flavors of cpufreq 209 idle drivers.
202 performance-state drivers.
203 210
204 To compile this driver as a module, choose M here: 211 To compile this driver as a module, choose M here:
205 the module will be called processor. 212 the module will be called processor.
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 8321430d7f24..b5e7cd8a9c71 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -24,7 +24,7 @@ acpi-y += nvs.o
24# Power management related files 24# Power management related files
25acpi-y += wakeup.o 25acpi-y += wakeup.o
26acpi-$(CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT) += sleep.o 26acpi-$(CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT) += sleep.o
27acpi-y += device_pm.o 27acpi-y += device_sysfs.o device_pm.o
28acpi-$(CONFIG_ACPI_SLEEP) += proc.o 28acpi-$(CONFIG_ACPI_SLEEP) += proc.o
29 29
30 30
@@ -80,8 +80,10 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
80obj-$(CONFIG_ACPI_BGRT) += bgrt.o 80obj-$(CONFIG_ACPI_BGRT) += bgrt.o
81 81
82# processor has its own "processor." module_param namespace 82# processor has its own "processor." module_param namespace
83processor-y := processor_driver.o processor_throttling.o 83processor-y := processor_driver.o
84processor-y += processor_idle.o processor_thermal.o 84processor-$(CONFIG_ACPI_PROCESSOR_IDLE) += processor_idle.o
85processor-$(CONFIG_ACPI_CPU_FREQ_PSS) += processor_throttling.o \
86 processor_thermal.o
85processor-$(CONFIG_CPU_FREQ) += processor_perflib.o 87processor-$(CONFIG_CPU_FREQ) += processor_perflib.o
86 88
87obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o 89obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 9b5354a2cd08..f71b756b05c4 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */ 20 */
25 21
diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index ac0f52f6df2b..f77956c3fd45 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 20 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 */ 21 */
26 22
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index ee28f4d15625..6b0d3ef7309c 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -16,11 +16,6 @@
16 * NON INFRINGEMENT. See the GNU General Public License for more 16 * NON INFRINGEMENT. See the GNU General Public License for more
17 * details. 17 * details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 *
24 * ACPI based HotPlug driver that supports Memory Hotplug 19 * ACPI based HotPlug driver that supports Memory Hotplug
25 * This driver fields notifications from firmware for memory add 20 * This driver fields notifications from firmware for memory add
26 * and remove operations and alerts the VM of the affected memory 21 * and remove operations and alerts the VM of the affected memory
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 00b39802d7ec..ae307ff36acb 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -12,10 +12,6 @@
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details. 13 * more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */ 15 */
20 16
21#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 92a5f738e370..985b8a83184e 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -485,7 +485,7 @@ static const struct acpi_device_id processor_device_ids[] = {
485 { } 485 { }
486}; 486};
487 487
488static struct acpi_scan_handler __refdata processor_handler = { 488static struct acpi_scan_handler processor_handler = {
489 .ids = processor_device_ids, 489 .ids = processor_device_ids,
490 .attach = acpi_processor_add, 490 .attach = acpi_processor_add,
491#ifdef CONFIG_ACPI_HOTPLUG_CPU 491#ifdef CONFIG_ACPI_HOTPLUG_CPU
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 8c2fe2f2f9fd..5778e8e4313a 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 20 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 */ 21 */
26 22
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index a85ac07f3da3..a2c8d7adb6eb 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -24,10 +24,6 @@
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details. 26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 */ 27 */
32 28
33#include <linux/kernel.h> 29#include <linux/kernel.h>
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index a095d4f858da..0431883653be 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 21 */
26 22
27#include <linux/kernel.h> 23#include <linux/kernel.h>
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 04ab5c9d3ced..6330f557a2c8 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -17,10 +17,6 @@
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */ 20 */
25 21
26#include <linux/kernel.h> 22#include <linux/kernel.h>
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
index 3670bbab57a3..6682c5daf742 100644
--- a/drivers/acpi/apei/erst.c
+++ b/drivers/acpi/apei/erst.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 21 */
26 22
27#include <linux/kernel.h> 23#include <linux/kernel.h>
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 2bfd53cbfe80..23981ac1c6c2 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -23,10 +23,6 @@
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details. 25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 */ 26 */
31 27
32#include <linux/kernel.h> 28#include <linux/kernel.h>
diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index 06e9b411a0a2..20b3fcf4007c 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */ 24 */
29 25
30#include <linux/kernel.h> 26#include <linux/kernel.h>
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b3628cc01a53..b719ab3090bb 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -18,10 +18,6 @@
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details. 19 * General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 *
25 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 21 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 */ 22 */
27 23
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 278dc4be992a..96809cd99ace 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details. 21 * General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 *
27 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 */ 24 */
29 25
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 513e7230e3d0..54a2e66ce236 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 16 * General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 19 */
24 20
@@ -423,6 +419,384 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
423 acpi_evaluate_ost(handle, type, ost_code, NULL); 419 acpi_evaluate_ost(handle, type, ost_code, NULL);
424} 420}
425 421
422static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
423{
424 struct acpi_device *device = data;
425
426 device->driver->ops.notify(device, event);
427}
428
429static void acpi_device_notify_fixed(void *data)
430{
431 struct acpi_device *device = data;
432
433 /* Fixed hardware devices have no handles */
434 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
435}
436
437static u32 acpi_device_fixed_event(void *data)
438{
439 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
440 return ACPI_INTERRUPT_HANDLED;
441}
442
443static int acpi_device_install_notify_handler(struct acpi_device *device)
444{
445 acpi_status status;
446
447 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
448 status =
449 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
450 acpi_device_fixed_event,
451 device);
452 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
453 status =
454 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
455 acpi_device_fixed_event,
456 device);
457 else
458 status = acpi_install_notify_handler(device->handle,
459 ACPI_DEVICE_NOTIFY,
460 acpi_device_notify,
461 device);
462
463 if (ACPI_FAILURE(status))
464 return -EINVAL;
465 return 0;
466}
467
468static void acpi_device_remove_notify_handler(struct acpi_device *device)
469{
470 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
471 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
472 acpi_device_fixed_event);
473 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
474 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
475 acpi_device_fixed_event);
476 else
477 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
478 acpi_device_notify);
479}
480
481/* --------------------------------------------------------------------------
482 Device Matching
483 -------------------------------------------------------------------------- */
484
485/*
486 * acpi_companion_match() - Can we match via ACPI companion device
487 * @dev: Device in question
488 *
489 * Check if the given device has an ACPI companion and if that companion has
490 * a valid list of PNP IDs, and if the device is the first (primary) physical
491 * device associated with it. Return the companion pointer if that's the case
492 * or NULL otherwise.
493 *
494 * If multiple physical devices are attached to a single ACPI companion, we need
495 * to be careful. The usage scenario for this kind of relationship is that all
496 * of the physical devices in question use resources provided by the ACPI
497 * companion. A typical case is an MFD device where all the sub-devices share
498 * the parent's ACPI companion. In such cases we can only allow the primary
499 * (first) physical device to be matched with the help of the companion's PNP
500 * IDs.
501 *
502 * Additional physical devices sharing the ACPI companion can still use
503 * resources available from it but they will be matched normally using functions
504 * provided by their bus types (and analogously for their modalias).
505 */
506struct acpi_device *acpi_companion_match(const struct device *dev)
507{
508 struct acpi_device *adev;
509 struct mutex *physical_node_lock;
510
511 adev = ACPI_COMPANION(dev);
512 if (!adev)
513 return NULL;
514
515 if (list_empty(&adev->pnp.ids))
516 return NULL;
517
518 physical_node_lock = &adev->physical_node_lock;
519 mutex_lock(physical_node_lock);
520 if (list_empty(&adev->physical_node_list)) {
521 adev = NULL;
522 } else {
523 const struct acpi_device_physical_node *node;
524
525 node = list_first_entry(&adev->physical_node_list,
526 struct acpi_device_physical_node, node);
527 if (node->dev != dev)
528 adev = NULL;
529 }
530 mutex_unlock(physical_node_lock);
531
532 return adev;
533}
534
535/**
536 * acpi_of_match_device - Match device object using the "compatible" property.
537 * @adev: ACPI device object to match.
538 * @of_match_table: List of device IDs to match against.
539 *
540 * If @dev has an ACPI companion which has ACPI_DT_NAMESPACE_HID in its list of
541 * identifiers and a _DSD object with the "compatible" property, use that
542 * property to match against the given list of identifiers.
543 */
544static bool acpi_of_match_device(struct acpi_device *adev,
545 const struct of_device_id *of_match_table)
546{
547 const union acpi_object *of_compatible, *obj;
548 int i, nval;
549
550 if (!adev)
551 return false;
552
553 of_compatible = adev->data.of_compatible;
554 if (!of_match_table || !of_compatible)
555 return false;
556
557 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
558 nval = of_compatible->package.count;
559 obj = of_compatible->package.elements;
560 } else { /* Must be ACPI_TYPE_STRING. */
561 nval = 1;
562 obj = of_compatible;
563 }
564 /* Now we can look for the driver DT compatible strings */
565 for (i = 0; i < nval; i++, obj++) {
566 const struct of_device_id *id;
567
568 for (id = of_match_table; id->compatible[0]; id++)
569 if (!strcasecmp(obj->string.pointer, id->compatible))
570 return true;
571 }
572
573 return false;
574}
575
576static bool __acpi_match_device_cls(const struct acpi_device_id *id,
577 struct acpi_hardware_id *hwid)
578{
579 int i, msk, byte_shift;
580 char buf[3];
581
582 if (!id->cls)
583 return false;
584
585 /* Apply class-code bitmask, before checking each class-code byte */
586 for (i = 1; i <= 3; i++) {
587 byte_shift = 8 * (3 - i);
588 msk = (id->cls_msk >> byte_shift) & 0xFF;
589 if (!msk)
590 continue;
591
592 sprintf(buf, "%02x", (id->cls >> byte_shift) & msk);
593 if (strncmp(buf, &hwid->id[(i - 1) * 2], 2))
594 return false;
595 }
596 return true;
597}
598
599static const struct acpi_device_id *__acpi_match_device(
600 struct acpi_device *device,
601 const struct acpi_device_id *ids,
602 const struct of_device_id *of_ids)
603{
604 const struct acpi_device_id *id;
605 struct acpi_hardware_id *hwid;
606
607 /*
608 * If the device is not present, it is unnecessary to load device
609 * driver for it.
610 */
611 if (!device || !device->status.present)
612 return NULL;
613
614 list_for_each_entry(hwid, &device->pnp.ids, list) {
615 /* First, check the ACPI/PNP IDs provided by the caller. */
616 for (id = ids; id->id[0] || id->cls; id++) {
617 if (id->id[0] && !strcmp((char *) id->id, hwid->id))
618 return id;
619 else if (id->cls && __acpi_match_device_cls(id, hwid))
620 return id;
621 }
622
623 /*
624 * Next, check ACPI_DT_NAMESPACE_HID and try to match the
625 * "compatible" property if found.
626 *
627 * The id returned by the below is not valid, but the only
628 * caller passing non-NULL of_ids here is only interested in
629 * whether or not the return value is NULL.
630 */
631 if (!strcmp(ACPI_DT_NAMESPACE_HID, hwid->id)
632 && acpi_of_match_device(device, of_ids))
633 return id;
634 }
635 return NULL;
636}
637
638/**
639 * acpi_match_device - Match a struct device against a given list of ACPI IDs
640 * @ids: Array of struct acpi_device_id object to match against.
641 * @dev: The device structure to match.
642 *
643 * Check if @dev has a valid ACPI handle and if there is a struct acpi_device
644 * object for that handle and use that object to match against a given list of
645 * device IDs.
646 *
647 * Return a pointer to the first matching ID on success or %NULL on failure.
648 */
649const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
650 const struct device *dev)
651{
652 return __acpi_match_device(acpi_companion_match(dev), ids, NULL);
653}
654EXPORT_SYMBOL_GPL(acpi_match_device);
655
656int acpi_match_device_ids(struct acpi_device *device,
657 const struct acpi_device_id *ids)
658{
659 return __acpi_match_device(device, ids, NULL) ? 0 : -ENOENT;
660}
661EXPORT_SYMBOL(acpi_match_device_ids);
662
663bool acpi_driver_match_device(struct device *dev,
664 const struct device_driver *drv)
665{
666 if (!drv->acpi_match_table)
667 return acpi_of_match_device(ACPI_COMPANION(dev),
668 drv->of_match_table);
669
670 return !!__acpi_match_device(acpi_companion_match(dev),
671 drv->acpi_match_table, drv->of_match_table);
672}
673EXPORT_SYMBOL_GPL(acpi_driver_match_device);
674
675/* --------------------------------------------------------------------------
676 ACPI Driver Management
677 -------------------------------------------------------------------------- */
678
679/**
680 * acpi_bus_register_driver - register a driver with the ACPI bus
681 * @driver: driver being registered
682 *
683 * Registers a driver with the ACPI bus. Searches the namespace for all
684 * devices that match the driver's criteria and binds. Returns zero for
685 * success or a negative error status for failure.
686 */
687int acpi_bus_register_driver(struct acpi_driver *driver)
688{
689 int ret;
690
691 if (acpi_disabled)
692 return -ENODEV;
693 driver->drv.name = driver->name;
694 driver->drv.bus = &acpi_bus_type;
695 driver->drv.owner = driver->owner;
696
697 ret = driver_register(&driver->drv);
698 return ret;
699}
700
701EXPORT_SYMBOL(acpi_bus_register_driver);
702
703/**
704 * acpi_bus_unregister_driver - unregisters a driver with the ACPI bus
705 * @driver: driver to unregister
706 *
707 * Unregisters a driver with the ACPI bus. Searches the namespace for all
708 * devices that match the driver's criteria and unbinds.
709 */
710void acpi_bus_unregister_driver(struct acpi_driver *driver)
711{
712 driver_unregister(&driver->drv);
713}
714
715EXPORT_SYMBOL(acpi_bus_unregister_driver);
716
717/* --------------------------------------------------------------------------
718 ACPI Bus operations
719 -------------------------------------------------------------------------- */
720
721static int acpi_bus_match(struct device *dev, struct device_driver *drv)
722{
723 struct acpi_device *acpi_dev = to_acpi_device(dev);
724 struct acpi_driver *acpi_drv = to_acpi_driver(drv);
725
726 return acpi_dev->flags.match_driver
727 && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
728}
729
730static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
731{
732 return __acpi_device_uevent_modalias(to_acpi_device(dev), env);
733}
734
735static int acpi_device_probe(struct device *dev)
736{
737 struct acpi_device *acpi_dev = to_acpi_device(dev);
738 struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
739 int ret;
740
741 if (acpi_dev->handler && !acpi_is_pnp_device(acpi_dev))
742 return -EINVAL;
743
744 if (!acpi_drv->ops.add)
745 return -ENOSYS;
746
747 ret = acpi_drv->ops.add(acpi_dev);
748 if (ret)
749 return ret;
750
751 acpi_dev->driver = acpi_drv;
752 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
753 "Driver [%s] successfully bound to device [%s]\n",
754 acpi_drv->name, acpi_dev->pnp.bus_id));
755
756 if (acpi_drv->ops.notify) {
757 ret = acpi_device_install_notify_handler(acpi_dev);
758 if (ret) {
759 if (acpi_drv->ops.remove)
760 acpi_drv->ops.remove(acpi_dev);
761
762 acpi_dev->driver = NULL;
763 acpi_dev->driver_data = NULL;
764 return ret;
765 }
766 }
767
768 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
769 acpi_drv->name, acpi_dev->pnp.bus_id));
770 get_device(dev);
771 return 0;
772}
773
774static int acpi_device_remove(struct device * dev)
775{
776 struct acpi_device *acpi_dev = to_acpi_device(dev);
777 struct acpi_driver *acpi_drv = acpi_dev->driver;
778
779 if (acpi_drv) {
780 if (acpi_drv->ops.notify)
781 acpi_device_remove_notify_handler(acpi_dev);
782 if (acpi_drv->ops.remove)
783 acpi_drv->ops.remove(acpi_dev);
784 }
785 acpi_dev->driver = NULL;
786 acpi_dev->driver_data = NULL;
787
788 put_device(dev);
789 return 0;
790}
791
792struct bus_type acpi_bus_type = {
793 .name = "acpi",
794 .match = acpi_bus_match,
795 .probe = acpi_device_probe,
796 .remove = acpi_device_remove,
797 .uevent = acpi_device_uevent,
798};
799
426/* -------------------------------------------------------------------------- 800/* --------------------------------------------------------------------------
427 Initialization/Cleanup 801 Initialization/Cleanup
428 -------------------------------------------------------------------------- */ 802 -------------------------------------------------------------------------- */
@@ -661,7 +1035,9 @@ static int __init acpi_bus_init(void)
661 */ 1035 */
662 acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL); 1036 acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
663 1037
664 return 0; 1038 result = bus_register(&acpi_bus_type);
1039 if (!result)
1040 return 0;
665 1041
666 /* Mimic structured exception handling */ 1042 /* Mimic structured exception handling */
667 error1: 1043 error1:
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 6d5d1832a588..5c3b0918d5fd 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */ 20 */
25 21
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c
index 6c9ee68e46fb..d0918d421f90 100644
--- a/drivers/acpi/cm_sbs.c
+++ b/drivers/acpi/cm_sbs.c
@@ -11,10 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details. 12 * General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */ 15 */
20 16
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index c8ead9f97375..12c240903c18 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details. 21 * General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 *
27 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 */ 24 */
29#include <linux/acpi.h> 25#include <linux/acpi.h>
diff --git a/drivers/acpi/debugfs.c b/drivers/acpi/debugfs.c
index 6b1919f6bd82..68bb305b977f 100644
--- a/drivers/acpi/debugfs.c
+++ b/drivers/acpi/debugfs.c
@@ -7,6 +7,8 @@
7#include <linux/debugfs.h> 7#include <linux/debugfs.h>
8#include <linux/acpi.h> 8#include <linux/acpi.h>
9 9
10#include "internal.h"
11
10#define _COMPONENT ACPI_SYSTEM_COMPONENT 12#define _COMPONENT ACPI_SYSTEM_COMPONENT
11ACPI_MODULE_NAME("debugfs"); 13ACPI_MODULE_NAME("debugfs");
12 14
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 88dbbb115285..da0867899d10 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 16 * General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 19 */
24 20
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
new file mode 100644
index 000000000000..4ab4582e586b
--- /dev/null
+++ b/drivers/acpi/device_sysfs.c
@@ -0,0 +1,521 @@
1/*
2 * drivers/acpi/device_sysfs.c - ACPI device sysfs attributes and modalias.
3 *
4 * Copyright (C) 2015, Intel Corp.
5 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */
21
22#include <linux/acpi.h>
23#include <linux/device.h>
24#include <linux/export.h>
25#include <linux/nls.h>
26
27#include "internal.h"
28
29/**
30 * create_pnp_modalias - Create hid/cid(s) string for modalias and uevent
31 * @acpi_dev: ACPI device object.
32 * @modalias: Buffer to print into.
33 * @size: Size of the buffer.
34 *
35 * Creates hid/cid(s) string needed for modalias and uevent
36 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
37 * char *modalias: "acpi:IBM0001:ACPI0001"
38 * Return: 0: no _HID and no _CID
39 * -EINVAL: output error
40 * -ENOMEM: output is truncated
41*/
42static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
43 int size)
44{
45 int len;
46 int count;
47 struct acpi_hardware_id *id;
48
49 /*
50 * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should
51 * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the
52 * device's list.
53 */
54 count = 0;
55 list_for_each_entry(id, &acpi_dev->pnp.ids, list)
56 if (strcmp(id->id, ACPI_DT_NAMESPACE_HID))
57 count++;
58
59 if (!count)
60 return 0;
61
62 len = snprintf(modalias, size, "acpi:");
63 if (len <= 0)
64 return len;
65
66 size -= len;
67
68 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
69 if (!strcmp(id->id, ACPI_DT_NAMESPACE_HID))
70 continue;
71
72 count = snprintf(&modalias[len], size, "%s:", id->id);
73 if (count < 0)
74 return -EINVAL;
75
76 if (count >= size)
77 return -ENOMEM;
78
79 len += count;
80 size -= count;
81 }
82 modalias[len] = '\0';
83 return len;
84}
85
86/**
87 * create_of_modalias - Creates DT compatible string for modalias and uevent
88 * @acpi_dev: ACPI device object.
89 * @modalias: Buffer to print into.
90 * @size: Size of the buffer.
91 *
92 * Expose DT compatible modalias as of:NnameTCcompatible. This function should
93 * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of
94 * ACPI/PNP IDs.
95 */
96static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
97 int size)
98{
99 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
100 const union acpi_object *of_compatible, *obj;
101 int len, count;
102 int i, nval;
103 char *c;
104
105 acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
106 /* DT strings are all in lower case */
107 for (c = buf.pointer; *c != '\0'; c++)
108 *c = tolower(*c);
109
110 len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
111 ACPI_FREE(buf.pointer);
112
113 if (len <= 0)
114 return len;
115
116 of_compatible = acpi_dev->data.of_compatible;
117 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
118 nval = of_compatible->package.count;
119 obj = of_compatible->package.elements;
120 } else { /* Must be ACPI_TYPE_STRING. */
121 nval = 1;
122 obj = of_compatible;
123 }
124 for (i = 0; i < nval; i++, obj++) {
125 count = snprintf(&modalias[len], size, "C%s",
126 obj->string.pointer);
127 if (count < 0)
128 return -EINVAL;
129
130 if (count >= size)
131 return -ENOMEM;
132
133 len += count;
134 size -= count;
135 }
136 modalias[len] = '\0';
137 return len;
138}
139
140int __acpi_device_uevent_modalias(struct acpi_device *adev,
141 struct kobj_uevent_env *env)
142{
143 int len;
144
145 if (!adev)
146 return -ENODEV;
147
148 if (list_empty(&adev->pnp.ids))
149 return 0;
150
151 if (add_uevent_var(env, "MODALIAS="))
152 return -ENOMEM;
153
154 len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
155 sizeof(env->buf) - env->buflen);
156 if (len < 0)
157 return len;
158
159 env->buflen += len;
160 if (!adev->data.of_compatible)
161 return 0;
162
163 if (len > 0 && add_uevent_var(env, "MODALIAS="))
164 return -ENOMEM;
165
166 len = create_of_modalias(adev, &env->buf[env->buflen - 1],
167 sizeof(env->buf) - env->buflen);
168 if (len < 0)
169 return len;
170
171 env->buflen += len;
172
173 return 0;
174}
175
176/**
177 * acpi_device_uevent_modalias - uevent modalias for ACPI-enumerated devices.
178 *
179 * Create the uevent modalias field for ACPI-enumerated devices.
180 *
181 * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with
182 * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001".
183 */
184int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
185{
186 return __acpi_device_uevent_modalias(acpi_companion_match(dev), env);
187}
188EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
189
190static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
191{
192 int len, count;
193
194 if (!adev)
195 return -ENODEV;
196
197 if (list_empty(&adev->pnp.ids))
198 return 0;
199
200 len = create_pnp_modalias(adev, buf, size - 1);
201 if (len < 0) {
202 return len;
203 } else if (len > 0) {
204 buf[len++] = '\n';
205 size -= len;
206 }
207 if (!adev->data.of_compatible)
208 return len;
209
210 count = create_of_modalias(adev, buf + len, size - 1);
211 if (count < 0) {
212 return count;
213 } else if (count > 0) {
214 len += count;
215 buf[len++] = '\n';
216 }
217
218 return len;
219}
220
221/**
222 * acpi_device_modalias - modalias sysfs attribute for ACPI-enumerated devices.
223 *
224 * Create the modalias sysfs attribute for ACPI-enumerated devices.
225 *
226 * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with
227 * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001".
228 */
229int acpi_device_modalias(struct device *dev, char *buf, int size)
230{
231 return __acpi_device_modalias(acpi_companion_match(dev), buf, size);
232}
233EXPORT_SYMBOL_GPL(acpi_device_modalias);
234
235static ssize_t
236acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
237 return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
238}
239static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
240
241static ssize_t real_power_state_show(struct device *dev,
242 struct device_attribute *attr, char *buf)
243{
244 struct acpi_device *adev = to_acpi_device(dev);
245 int state;
246 int ret;
247
248 ret = acpi_device_get_power(adev, &state);
249 if (ret)
250 return ret;
251
252 return sprintf(buf, "%s\n", acpi_power_state_string(state));
253}
254
255static DEVICE_ATTR(real_power_state, 0444, real_power_state_show, NULL);
256
257static ssize_t power_state_show(struct device *dev,
258 struct device_attribute *attr, char *buf)
259{
260 struct acpi_device *adev = to_acpi_device(dev);
261
262 return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state));
263}
264
265static DEVICE_ATTR(power_state, 0444, power_state_show, NULL);
266
267static ssize_t
268acpi_eject_store(struct device *d, struct device_attribute *attr,
269 const char *buf, size_t count)
270{
271 struct acpi_device *acpi_device = to_acpi_device(d);
272 acpi_object_type not_used;
273 acpi_status status;
274
275 if (!count || buf[0] != '1')
276 return -EINVAL;
277
278 if ((!acpi_device->handler || !acpi_device->handler->hotplug.enabled)
279 && !acpi_device->driver)
280 return -ENODEV;
281
282 status = acpi_get_type(acpi_device->handle, &not_used);
283 if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
284 return -ENODEV;
285
286 get_device(&acpi_device->dev);
287 status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT);
288 if (ACPI_SUCCESS(status))
289 return count;
290
291 put_device(&acpi_device->dev);
292 acpi_evaluate_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
293 ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
294 return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
295}
296
297static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
298
299static ssize_t
300acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) {
301 struct acpi_device *acpi_dev = to_acpi_device(dev);
302
303 return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
304}
305static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
306
307static ssize_t acpi_device_uid_show(struct device *dev,
308 struct device_attribute *attr, char *buf)
309{
310 struct acpi_device *acpi_dev = to_acpi_device(dev);
311
312 return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
313}
314static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
315
316static ssize_t acpi_device_adr_show(struct device *dev,
317 struct device_attribute *attr, char *buf)
318{
319 struct acpi_device *acpi_dev = to_acpi_device(dev);
320
321 return sprintf(buf, "0x%08x\n",
322 (unsigned int)(acpi_dev->pnp.bus_address));
323}
324static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL);
325
326static ssize_t
327acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) {
328 struct acpi_device *acpi_dev = to_acpi_device(dev);
329 struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
330 int result;
331
332 result = acpi_get_name(acpi_dev->handle, ACPI_FULL_PATHNAME, &path);
333 if (result)
334 goto end;
335
336 result = sprintf(buf, "%s\n", (char*)path.pointer);
337 kfree(path.pointer);
338end:
339 return result;
340}
341static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
342
343/* sysfs file that shows description text from the ACPI _STR method */
344static ssize_t description_show(struct device *dev,
345 struct device_attribute *attr,
346 char *buf) {
347 struct acpi_device *acpi_dev = to_acpi_device(dev);
348 int result;
349
350 if (acpi_dev->pnp.str_obj == NULL)
351 return 0;
352
353 /*
354 * The _STR object contains a Unicode identifier for a device.
355 * We need to convert to utf-8 so it can be displayed.
356 */
357 result = utf16s_to_utf8s(
358 (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
359 acpi_dev->pnp.str_obj->buffer.length,
360 UTF16_LITTLE_ENDIAN, buf,
361 PAGE_SIZE);
362
363 buf[result++] = '\n';
364
365 return result;
366}
367static DEVICE_ATTR(description, 0444, description_show, NULL);
368
369static ssize_t
370acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
371 char *buf) {
372 struct acpi_device *acpi_dev = to_acpi_device(dev);
373 acpi_status status;
374 unsigned long long sun;
375
376 status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun);
377 if (ACPI_FAILURE(status))
378 return -ENODEV;
379
380 return sprintf(buf, "%llu\n", sun);
381}
382static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
383
384static ssize_t status_show(struct device *dev, struct device_attribute *attr,
385 char *buf) {
386 struct acpi_device *acpi_dev = to_acpi_device(dev);
387 acpi_status status;
388 unsigned long long sta;
389
390 status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
391 if (ACPI_FAILURE(status))
392 return -ENODEV;
393
394 return sprintf(buf, "%llu\n", sta);
395}
396static DEVICE_ATTR_RO(status);
397
398/**
399 * acpi_device_setup_files - Create sysfs attributes of an ACPI device.
400 * @dev: ACPI device object.
401 */
402int acpi_device_setup_files(struct acpi_device *dev)
403{
404 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
405 acpi_status status;
406 int result = 0;
407
408 /*
409 * Devices gotten from FADT don't have a "path" attribute
410 */
411 if (dev->handle) {
412 result = device_create_file(&dev->dev, &dev_attr_path);
413 if (result)
414 goto end;
415 }
416
417 if (!list_empty(&dev->pnp.ids)) {
418 result = device_create_file(&dev->dev, &dev_attr_hid);
419 if (result)
420 goto end;
421
422 result = device_create_file(&dev->dev, &dev_attr_modalias);
423 if (result)
424 goto end;
425 }
426
427 /*
428 * If device has _STR, 'description' file is created
429 */
430 if (acpi_has_method(dev->handle, "_STR")) {
431 status = acpi_evaluate_object(dev->handle, "_STR",
432 NULL, &buffer);
433 if (ACPI_FAILURE(status))
434 buffer.pointer = NULL;
435 dev->pnp.str_obj = buffer.pointer;
436 result = device_create_file(&dev->dev, &dev_attr_description);
437 if (result)
438 goto end;
439 }
440
441 if (dev->pnp.type.bus_address)
442 result = device_create_file(&dev->dev, &dev_attr_adr);
443 if (dev->pnp.unique_id)
444 result = device_create_file(&dev->dev, &dev_attr_uid);
445
446 if (acpi_has_method(dev->handle, "_SUN")) {
447 result = device_create_file(&dev->dev, &dev_attr_sun);
448 if (result)
449 goto end;
450 }
451
452 if (acpi_has_method(dev->handle, "_STA")) {
453 result = device_create_file(&dev->dev, &dev_attr_status);
454 if (result)
455 goto end;
456 }
457
458 /*
459 * If device has _EJ0, 'eject' file is created that is used to trigger
460 * hot-removal function from userland.
461 */
462 if (acpi_has_method(dev->handle, "_EJ0")) {
463 result = device_create_file(&dev->dev, &dev_attr_eject);
464 if (result)
465 return result;
466 }
467
468 if (dev->flags.power_manageable) {
469 result = device_create_file(&dev->dev, &dev_attr_power_state);
470 if (result)
471 return result;
472
473 if (dev->power.flags.power_resources)
474 result = device_create_file(&dev->dev,
475 &dev_attr_real_power_state);
476 }
477
478end:
479 return result;
480}
481
482/**
483 * acpi_device_remove_files - Remove sysfs attributes of an ACPI device.
484 * @dev: ACPI device object.
485 */
486void acpi_device_remove_files(struct acpi_device *dev)
487{
488 if (dev->flags.power_manageable) {
489 device_remove_file(&dev->dev, &dev_attr_power_state);
490 if (dev->power.flags.power_resources)
491 device_remove_file(&dev->dev,
492 &dev_attr_real_power_state);
493 }
494
495 /*
496 * If device has _STR, remove 'description' file
497 */
498 if (acpi_has_method(dev->handle, "_STR")) {
499 kfree(dev->pnp.str_obj);
500 device_remove_file(&dev->dev, &dev_attr_description);
501 }
502 /*
503 * If device has _EJ0, remove 'eject' file.
504 */
505 if (acpi_has_method(dev->handle, "_EJ0"))
506 device_remove_file(&dev->dev, &dev_attr_eject);
507
508 if (acpi_has_method(dev->handle, "_SUN"))
509 device_remove_file(&dev->dev, &dev_attr_sun);
510
511 if (dev->pnp.unique_id)
512 device_remove_file(&dev->dev, &dev_attr_uid);
513 if (dev->pnp.type.bus_address)
514 device_remove_file(&dev->dev, &dev_attr_adr);
515 device_remove_file(&dev->dev, &dev_attr_modalias);
516 device_remove_file(&dev->dev, &dev_attr_hid);
517 if (acpi_has_method(dev->handle, "_STA"))
518 device_remove_file(&dev->dev, &dev_attr_status);
519 if (dev->handle)
520 device_remove_file(&dev->dev, &dev_attr_path);
521}
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index a688aa243f6c..e8e128dede29 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 20 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 */ 21 */
26 22
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 9d4761d2f6b7..990446629935 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -22,10 +22,6 @@
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details. 23 * General Public License for more details.
24 * 24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 *
29 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 */ 26 */
31 27
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index bea0bbaafa97..e297a480e135 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */ 20 */
25 21
diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c
index a322710b5ba4..5c67a6d8f803 100644
--- a/drivers/acpi/hed.c
+++ b/drivers/acpi/hed.c
@@ -15,10 +15,6 @@
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 18 */
23 19
24#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 4683a96932b9..2c195cd5ab1b 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -13,9 +13,6 @@
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details. 14 * more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 */ 16 */
20 17
21#ifndef _ACPI_INTERNAL_H_ 18#ifndef _ACPI_INTERNAL_H_
@@ -70,7 +67,7 @@ void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val);
70 67
71#ifdef CONFIG_DEBUG_FS 68#ifdef CONFIG_DEBUG_FS
72extern struct dentry *acpi_debugfs_dir; 69extern struct dentry *acpi_debugfs_dir;
73int acpi_debugfs_init(void); 70void acpi_debugfs_init(void);
74#else 71#else
75static inline void acpi_debugfs_init(void) { return; } 72static inline void acpi_debugfs_init(void) { return; }
76#endif 73#endif
@@ -93,12 +90,21 @@ int acpi_device_add(struct acpi_device *device,
93 void (*release)(struct device *)); 90 void (*release)(struct device *));
94void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, 91void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
95 int type, unsigned long long sta); 92 int type, unsigned long long sta);
93int acpi_device_setup_files(struct acpi_device *dev);
94void acpi_device_remove_files(struct acpi_device *dev);
96void acpi_device_add_finalize(struct acpi_device *device); 95void acpi_device_add_finalize(struct acpi_device *device);
97void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); 96void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
98bool acpi_device_is_present(struct acpi_device *adev); 97bool acpi_device_is_present(struct acpi_device *adev);
99bool acpi_device_is_battery(struct acpi_device *adev); 98bool acpi_device_is_battery(struct acpi_device *adev);
100 99
101/* -------------------------------------------------------------------------- 100/* --------------------------------------------------------------------------
101 Device Matching and Notification
102 -------------------------------------------------------------------------- */
103struct acpi_device *acpi_companion_match(const struct device *dev);
104int __acpi_device_uevent_modalias(struct acpi_device *adev,
105 struct kobj_uevent_env *env);
106
107/* --------------------------------------------------------------------------
102 Power Resource 108 Power Resource
103 -------------------------------------------------------------------------- */ 109 -------------------------------------------------------------------------- */
104int acpi_power_init(void); 110int acpi_power_init(void);
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index acaa3b4ea504..72b6e9ef0ae9 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 * 19 *
24 */ 20 */
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 6341cb523dc4..21c1e7156bfe 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -19,10 +19,6 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 * 23 *
28 */ 24 */
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 304eccb0ae5c..25fff35df82c 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -19,10 +19,6 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details. 20 * General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 */ 23 */
28 24
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index cfd7581cc19f..2f5f84ced85f 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 20 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 * 21 *
26 * TBD: 22 * TBD:
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 1b5569c092c6..393706a5261b 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */ 20 */
25 21
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index 139d9e479370..7188e53b6b7c 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -20,10 +20,6 @@
20 * WITHOUT ANY WARRANTY; without even the implied warranty of 20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details. 22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
27 */ 23 */
28 24
29#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 93eac53b5110..45b47f2c9f03 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */ 20 */
25 21
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index d9f71581b79b..51e658f21e95 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details. 22 * General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 *
28 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 */ 25 */
30 26
@@ -159,38 +155,28 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
159 return NOTIFY_OK; 155 return NOTIFY_OK;
160} 156}
161 157
162static struct notifier_block __refdata acpi_cpu_notifier = { 158static struct notifier_block acpi_cpu_notifier = {
163 .notifier_call = acpi_cpu_soft_notify, 159 .notifier_call = acpi_cpu_soft_notify,
164}; 160};
165 161
166static int __acpi_processor_start(struct acpi_device *device) 162#ifdef CONFIG_ACPI_CPU_FREQ_PSS
163static int acpi_pss_perf_init(struct acpi_processor *pr,
164 struct acpi_device *device)
167{ 165{
168 struct acpi_processor *pr = acpi_driver_data(device);
169 acpi_status status;
170 int result = 0; 166 int result = 0;
171 167
172 if (!pr)
173 return -ENODEV;
174
175 if (pr->flags.need_hotplug_init)
176 return 0;
177
178#ifdef CONFIG_CPU_FREQ
179 acpi_processor_ppc_has_changed(pr, 0); 168 acpi_processor_ppc_has_changed(pr, 0);
180#endif 169
181 acpi_processor_get_throttling_info(pr); 170 acpi_processor_get_throttling_info(pr);
182 171
183 if (pr->flags.throttling) 172 if (pr->flags.throttling)
184 pr->flags.limit = 1; 173 pr->flags.limit = 1;
185 174
186 if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
187 acpi_processor_power_init(pr);
188
189 pr->cdev = thermal_cooling_device_register("Processor", device, 175 pr->cdev = thermal_cooling_device_register("Processor", device,
190 &processor_cooling_ops); 176 &processor_cooling_ops);
191 if (IS_ERR(pr->cdev)) { 177 if (IS_ERR(pr->cdev)) {
192 result = PTR_ERR(pr->cdev); 178 result = PTR_ERR(pr->cdev);
193 goto err_power_exit; 179 return result;
194 } 180 }
195 181
196 dev_dbg(&device->dev, "registered as cooling_device%d\n", 182 dev_dbg(&device->dev, "registered as cooling_device%d\n",
@@ -204,6 +190,7 @@ static int __acpi_processor_start(struct acpi_device *device)
204 "Failed to create sysfs link 'thermal_cooling'\n"); 190 "Failed to create sysfs link 'thermal_cooling'\n");
205 goto err_thermal_unregister; 191 goto err_thermal_unregister;
206 } 192 }
193
207 result = sysfs_create_link(&pr->cdev->device.kobj, 194 result = sysfs_create_link(&pr->cdev->device.kobj,
208 &device->dev.kobj, 195 &device->dev.kobj,
209 "device"); 196 "device");
@@ -213,17 +200,61 @@ static int __acpi_processor_start(struct acpi_device *device)
213 goto err_remove_sysfs_thermal; 200 goto err_remove_sysfs_thermal;
214 } 201 }
215 202
216 status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
217 acpi_processor_notify, device);
218 if (ACPI_SUCCESS(status))
219 return 0;
220
221 sysfs_remove_link(&pr->cdev->device.kobj, "device"); 203 sysfs_remove_link(&pr->cdev->device.kobj, "device");
222 err_remove_sysfs_thermal: 204 err_remove_sysfs_thermal:
223 sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); 205 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
224 err_thermal_unregister: 206 err_thermal_unregister:
225 thermal_cooling_device_unregister(pr->cdev); 207 thermal_cooling_device_unregister(pr->cdev);
226 err_power_exit: 208
209 return result;
210}
211
212static void acpi_pss_perf_exit(struct acpi_processor *pr,
213 struct acpi_device *device)
214{
215 if (pr->cdev) {
216 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
217 sysfs_remove_link(&pr->cdev->device.kobj, "device");
218 thermal_cooling_device_unregister(pr->cdev);
219 pr->cdev = NULL;
220 }
221}
222#else
223static inline int acpi_pss_perf_init(struct acpi_processor *pr,
224 struct acpi_device *device)
225{
226 return 0;
227}
228
229static inline void acpi_pss_perf_exit(struct acpi_processor *pr,
230 struct acpi_device *device) {}
231#endif /* CONFIG_ACPI_CPU_FREQ_PSS */
232
233static int __acpi_processor_start(struct acpi_device *device)
234{
235 struct acpi_processor *pr = acpi_driver_data(device);
236 acpi_status status;
237 int result = 0;
238
239 if (!pr)
240 return -ENODEV;
241
242 if (pr->flags.need_hotplug_init)
243 return 0;
244
245 if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
246 acpi_processor_power_init(pr);
247
248 result = acpi_pss_perf_init(pr, device);
249 if (result)
250 goto err_power_exit;
251
252 status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
253 acpi_processor_notify, device);
254 if (ACPI_SUCCESS(status))
255 return 0;
256
257err_power_exit:
227 acpi_processor_power_exit(pr); 258 acpi_processor_power_exit(pr);
228 return result; 259 return result;
229} 260}
@@ -252,15 +283,10 @@ static int acpi_processor_stop(struct device *dev)
252 pr = acpi_driver_data(device); 283 pr = acpi_driver_data(device);
253 if (!pr) 284 if (!pr)
254 return 0; 285 return 0;
255
256 acpi_processor_power_exit(pr); 286 acpi_processor_power_exit(pr);
257 287
258 if (pr->cdev) { 288 acpi_pss_perf_exit(pr, device);
259 sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); 289
260 sysfs_remove_link(&pr->cdev->device.kobj, "device");
261 thermal_cooling_device_unregister(pr->cdev);
262 pr->cdev = NULL;
263 }
264 return 0; 290 return 0;
265} 291}
266 292
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index d540f42c9232..175c86bee3a9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -21,10 +21,6 @@
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details. 22 * General Public License for more details.
23 * 23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 *
28 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 */ 25 */
30 26
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index cfc8aba72f86..53cfe8ba9799 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -20,10 +20,6 @@
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details. 21 * General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 *
27 */ 23 */
28 24
29#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index e003663b2f8e..1fed84a092c2 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -19,10 +19,6 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details. 20 * General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 */ 23 */
28 24
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 84243c32e29c..f170d746336d 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -19,10 +19,6 @@
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details. 20 * General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 */ 23 */
28 24
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index f1c966e05078..15d22db05054 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 16 * General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 19 */
24 20
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 01504c819e8f..cb3dedb1beae 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -17,10 +17,6 @@
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. 18 * General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 20 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 */ 21 */
26 22
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index ec256352f423..2fe5a37c385c 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -115,263 +115,6 @@ int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
115 return 0; 115 return 0;
116} 116}
117 117
118/**
119 * create_pnp_modalias - Create hid/cid(s) string for modalias and uevent
120 * @acpi_dev: ACPI device object.
121 * @modalias: Buffer to print into.
122 * @size: Size of the buffer.
123 *
124 * Creates hid/cid(s) string needed for modalias and uevent
125 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
126 * char *modalias: "acpi:IBM0001:ACPI0001"
127 * Return: 0: no _HID and no _CID
128 * -EINVAL: output error
129 * -ENOMEM: output is truncated
130*/
131static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
132 int size)
133{
134 int len;
135 int count;
136 struct acpi_hardware_id *id;
137
138 /*
139 * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should
140 * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the
141 * device's list.
142 */
143 count = 0;
144 list_for_each_entry(id, &acpi_dev->pnp.ids, list)
145 if (strcmp(id->id, ACPI_DT_NAMESPACE_HID))
146 count++;
147
148 if (!count)
149 return 0;
150
151 len = snprintf(modalias, size, "acpi:");
152 if (len <= 0)
153 return len;
154
155 size -= len;
156
157 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
158 if (!strcmp(id->id, ACPI_DT_NAMESPACE_HID))
159 continue;
160
161 count = snprintf(&modalias[len], size, "%s:", id->id);
162 if (count < 0)
163 return -EINVAL;
164
165 if (count >= size)
166 return -ENOMEM;
167
168 len += count;
169 size -= count;
170 }
171 modalias[len] = '\0';
172 return len;
173}
174
175/**
176 * create_of_modalias - Creates DT compatible string for modalias and uevent
177 * @acpi_dev: ACPI device object.
178 * @modalias: Buffer to print into.
179 * @size: Size of the buffer.
180 *
181 * Expose DT compatible modalias as of:NnameTCcompatible. This function should
182 * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of
183 * ACPI/PNP IDs.
184 */
185static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
186 int size)
187{
188 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
189 const union acpi_object *of_compatible, *obj;
190 int len, count;
191 int i, nval;
192 char *c;
193
194 acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
195 /* DT strings are all in lower case */
196 for (c = buf.pointer; *c != '\0'; c++)
197 *c = tolower(*c);
198
199 len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
200 ACPI_FREE(buf.pointer);
201
202 if (len <= 0)
203 return len;
204
205 of_compatible = acpi_dev->data.of_compatible;
206 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
207 nval = of_compatible->package.count;
208 obj = of_compatible->package.elements;
209 } else { /* Must be ACPI_TYPE_STRING. */
210 nval = 1;
211 obj = of_compatible;
212 }
213 for (i = 0; i < nval; i++, obj++) {
214 count = snprintf(&modalias[len], size, "C%s",
215 obj->string.pointer);
216 if (count < 0)
217 return -EINVAL;
218
219 if (count >= size)
220 return -ENOMEM;
221
222 len += count;
223 size -= count;
224 }
225 modalias[len] = '\0';
226 return len;
227}
228
229/*
230 * acpi_companion_match() - Can we match via ACPI companion device
231 * @dev: Device in question
232 *
233 * Check if the given device has an ACPI companion and if that companion has
234 * a valid list of PNP IDs, and if the device is the first (primary) physical
235 * device associated with it. Return the companion pointer if that's the case
236 * or NULL otherwise.
237 *
238 * If multiple physical devices are attached to a single ACPI companion, we need
239 * to be careful. The usage scenario for this kind of relationship is that all
240 * of the physical devices in question use resources provided by the ACPI
241 * companion. A typical case is an MFD device where all the sub-devices share
242 * the parent's ACPI companion. In such cases we can only allow the primary
243 * (first) physical device to be matched with the help of the companion's PNP
244 * IDs.
245 *
246 * Additional physical devices sharing the ACPI companion can still use
247 * resources available from it but they will be matched normally using functions
248 * provided by their bus types (and analogously for their modalias).
249 */
250static struct acpi_device *acpi_companion_match(const struct device *dev)
251{
252 struct acpi_device *adev;
253 struct mutex *physical_node_lock;
254
255 adev = ACPI_COMPANION(dev);
256 if (!adev)
257 return NULL;
258
259 if (list_empty(&adev->pnp.ids))
260 return NULL;
261
262 physical_node_lock = &adev->physical_node_lock;
263 mutex_lock(physical_node_lock);
264 if (list_empty(&adev->physical_node_list)) {
265 adev = NULL;
266 } else {
267 const struct acpi_device_physical_node *node;
268
269 node = list_first_entry(&adev->physical_node_list,
270 struct acpi_device_physical_node, node);
271 if (node->dev != dev)
272 adev = NULL;
273 }
274 mutex_unlock(physical_node_lock);
275
276 return adev;
277}
278
279static int __acpi_device_uevent_modalias(struct acpi_device *adev,
280 struct kobj_uevent_env *env)
281{
282 int len;
283
284 if (!adev)
285 return -ENODEV;
286
287 if (list_empty(&adev->pnp.ids))
288 return 0;
289
290 if (add_uevent_var(env, "MODALIAS="))
291 return -ENOMEM;
292
293 len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
294 sizeof(env->buf) - env->buflen);
295 if (len < 0)
296 return len;
297
298 env->buflen += len;
299 if (!adev->data.of_compatible)
300 return 0;
301
302 if (len > 0 && add_uevent_var(env, "MODALIAS="))
303 return -ENOMEM;
304
305 len = create_of_modalias(adev, &env->buf[env->buflen - 1],
306 sizeof(env->buf) - env->buflen);
307 if (len < 0)
308 return len;
309
310 env->buflen += len;
311
312 return 0;
313}
314
315/*
316 * Creates uevent modalias field for ACPI enumerated devices.
317 * Because the other buses does not support ACPI HIDs & CIDs.
318 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
319 * "acpi:IBM0001:ACPI0001"
320 */
321int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
322{
323 return __acpi_device_uevent_modalias(acpi_companion_match(dev), env);
324}
325EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
326
327static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
328{
329 int len, count;
330
331 if (!adev)
332 return -ENODEV;
333
334 if (list_empty(&adev->pnp.ids))
335 return 0;
336
337 len = create_pnp_modalias(adev, buf, size - 1);
338 if (len < 0) {
339 return len;
340 } else if (len > 0) {
341 buf[len++] = '\n';
342 size -= len;
343 }
344 if (!adev->data.of_compatible)
345 return len;
346
347 count = create_of_modalias(adev, buf + len, size - 1);
348 if (count < 0) {
349 return count;
350 } else if (count > 0) {
351 len += count;
352 buf[len++] = '\n';
353 }
354
355 return len;
356}
357
358/*
359 * Creates modalias sysfs attribute for ACPI enumerated devices.
360 * Because the other buses does not support ACPI HIDs & CIDs.
361 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
362 * "acpi:IBM0001:ACPI0001"
363 */
364int acpi_device_modalias(struct device *dev, char *buf, int size)
365{
366 return __acpi_device_modalias(acpi_companion_match(dev), buf, size);
367}
368EXPORT_SYMBOL_GPL(acpi_device_modalias);
369
370static ssize_t
371acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
372 return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
373}
374static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
375 118
376bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) 119bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent)
377{ 120{
@@ -701,423 +444,6 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src)
701 unlock_device_hotplug(); 444 unlock_device_hotplug();
702} 445}
703 446
704static ssize_t real_power_state_show(struct device *dev,
705 struct device_attribute *attr, char *buf)
706{
707 struct acpi_device *adev = to_acpi_device(dev);
708 int state;
709 int ret;
710
711 ret = acpi_device_get_power(adev, &state);
712 if (ret)
713 return ret;
714
715 return sprintf(buf, "%s\n", acpi_power_state_string(state));
716}
717
718static DEVICE_ATTR(real_power_state, 0444, real_power_state_show, NULL);
719
720static ssize_t power_state_show(struct device *dev,
721 struct device_attribute *attr, char *buf)
722{
723 struct acpi_device *adev = to_acpi_device(dev);
724
725 return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state));
726}
727
728static DEVICE_ATTR(power_state, 0444, power_state_show, NULL);
729
730static ssize_t
731acpi_eject_store(struct device *d, struct device_attribute *attr,
732 const char *buf, size_t count)
733{
734 struct acpi_device *acpi_device = to_acpi_device(d);
735 acpi_object_type not_used;
736 acpi_status status;
737
738 if (!count || buf[0] != '1')
739 return -EINVAL;
740
741 if ((!acpi_device->handler || !acpi_device->handler->hotplug.enabled)
742 && !acpi_device->driver)
743 return -ENODEV;
744
745 status = acpi_get_type(acpi_device->handle, &not_used);
746 if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
747 return -ENODEV;
748
749 get_device(&acpi_device->dev);
750 status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT);
751 if (ACPI_SUCCESS(status))
752 return count;
753
754 put_device(&acpi_device->dev);
755 acpi_evaluate_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
756 ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
757 return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
758}
759
760static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
761
762static ssize_t
763acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) {
764 struct acpi_device *acpi_dev = to_acpi_device(dev);
765
766 return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
767}
768static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
769
770static ssize_t acpi_device_uid_show(struct device *dev,
771 struct device_attribute *attr, char *buf)
772{
773 struct acpi_device *acpi_dev = to_acpi_device(dev);
774
775 return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
776}
777static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
778
779static ssize_t acpi_device_adr_show(struct device *dev,
780 struct device_attribute *attr, char *buf)
781{
782 struct acpi_device *acpi_dev = to_acpi_device(dev);
783
784 return sprintf(buf, "0x%08x\n",
785 (unsigned int)(acpi_dev->pnp.bus_address));
786}
787static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL);
788
789static ssize_t
790acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) {
791 struct acpi_device *acpi_dev = to_acpi_device(dev);
792 struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
793 int result;
794
795 result = acpi_get_name(acpi_dev->handle, ACPI_FULL_PATHNAME, &path);
796 if (result)
797 goto end;
798
799 result = sprintf(buf, "%s\n", (char*)path.pointer);
800 kfree(path.pointer);
801end:
802 return result;
803}
804static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
805
806/* sysfs file that shows description text from the ACPI _STR method */
807static ssize_t description_show(struct device *dev,
808 struct device_attribute *attr,
809 char *buf) {
810 struct acpi_device *acpi_dev = to_acpi_device(dev);
811 int result;
812
813 if (acpi_dev->pnp.str_obj == NULL)
814 return 0;
815
816 /*
817 * The _STR object contains a Unicode identifier for a device.
818 * We need to convert to utf-8 so it can be displayed.
819 */
820 result = utf16s_to_utf8s(
821 (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
822 acpi_dev->pnp.str_obj->buffer.length,
823 UTF16_LITTLE_ENDIAN, buf,
824 PAGE_SIZE);
825
826 buf[result++] = '\n';
827
828 return result;
829}
830static DEVICE_ATTR(description, 0444, description_show, NULL);
831
832static ssize_t
833acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
834 char *buf) {
835 struct acpi_device *acpi_dev = to_acpi_device(dev);
836 acpi_status status;
837 unsigned long long sun;
838
839 status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun);
840 if (ACPI_FAILURE(status))
841 return -ENODEV;
842
843 return sprintf(buf, "%llu\n", sun);
844}
845static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
846
847static ssize_t status_show(struct device *dev, struct device_attribute *attr,
848 char *buf) {
849 struct acpi_device *acpi_dev = to_acpi_device(dev);
850 acpi_status status;
851 unsigned long long sta;
852
853 status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
854 if (ACPI_FAILURE(status))
855 return -ENODEV;
856
857 return sprintf(buf, "%llu\n", sta);
858}
859static DEVICE_ATTR_RO(status);
860
861static int acpi_device_setup_files(struct acpi_device *dev)
862{
863 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
864 acpi_status status;
865 int result = 0;
866
867 /*
868 * Devices gotten from FADT don't have a "path" attribute
869 */
870 if (dev->handle) {
871 result = device_create_file(&dev->dev, &dev_attr_path);
872 if (result)
873 goto end;
874 }
875
876 if (!list_empty(&dev->pnp.ids)) {
877 result = device_create_file(&dev->dev, &dev_attr_hid);
878 if (result)
879 goto end;
880
881 result = device_create_file(&dev->dev, &dev_attr_modalias);
882 if (result)
883 goto end;
884 }
885
886 /*
887 * If device has _STR, 'description' file is created
888 */
889 if (acpi_has_method(dev->handle, "_STR")) {
890 status = acpi_evaluate_object(dev->handle, "_STR",
891 NULL, &buffer);
892 if (ACPI_FAILURE(status))
893 buffer.pointer = NULL;
894 dev->pnp.str_obj = buffer.pointer;
895 result = device_create_file(&dev->dev, &dev_attr_description);
896 if (result)
897 goto end;
898 }
899
900 if (dev->pnp.type.bus_address)
901 result = device_create_file(&dev->dev, &dev_attr_adr);
902 if (dev->pnp.unique_id)
903 result = device_create_file(&dev->dev, &dev_attr_uid);
904
905 if (acpi_has_method(dev->handle, "_SUN")) {
906 result = device_create_file(&dev->dev, &dev_attr_sun);
907 if (result)
908 goto end;
909 }
910
911 if (acpi_has_method(dev->handle, "_STA")) {
912 result = device_create_file(&dev->dev, &dev_attr_status);
913 if (result)
914 goto end;
915 }
916
917 /*
918 * If device has _EJ0, 'eject' file is created that is used to trigger
919 * hot-removal function from userland.
920 */
921 if (acpi_has_method(dev->handle, "_EJ0")) {
922 result = device_create_file(&dev->dev, &dev_attr_eject);
923 if (result)
924 return result;
925 }
926
927 if (dev->flags.power_manageable) {
928 result = device_create_file(&dev->dev, &dev_attr_power_state);
929 if (result)
930 return result;
931
932 if (dev->power.flags.power_resources)
933 result = device_create_file(&dev->dev,
934 &dev_attr_real_power_state);
935 }
936
937end:
938 return result;
939}
940
941static void acpi_device_remove_files(struct acpi_device *dev)
942{
943 if (dev->flags.power_manageable) {
944 device_remove_file(&dev->dev, &dev_attr_power_state);
945 if (dev->power.flags.power_resources)
946 device_remove_file(&dev->dev,
947 &dev_attr_real_power_state);
948 }
949
950 /*
951 * If device has _STR, remove 'description' file
952 */
953 if (acpi_has_method(dev->handle, "_STR")) {
954 kfree(dev->pnp.str_obj);
955 device_remove_file(&dev->dev, &dev_attr_description);
956 }
957 /*
958 * If device has _EJ0, remove 'eject' file.
959 */
960 if (acpi_has_method(dev->handle, "_EJ0"))
961 device_remove_file(&dev->dev, &dev_attr_eject);
962
963 if (acpi_has_method(dev->handle, "_SUN"))
964 device_remove_file(&dev->dev, &dev_attr_sun);
965
966 if (dev->pnp.unique_id)
967 device_remove_file(&dev->dev, &dev_attr_uid);
968 if (dev->pnp.type.bus_address)
969 device_remove_file(&dev->dev, &dev_attr_adr);
970 device_remove_file(&dev->dev, &dev_attr_modalias);
971 device_remove_file(&dev->dev, &dev_attr_hid);
972 if (acpi_has_method(dev->handle, "_STA"))
973 device_remove_file(&dev->dev, &dev_attr_status);
974 if (dev->handle)
975 device_remove_file(&dev->dev, &dev_attr_path);
976}
977/* --------------------------------------------------------------------------
978 ACPI Bus operations
979 -------------------------------------------------------------------------- */
980
981/**
982 * acpi_of_match_device - Match device object using the "compatible" property.
983 * @adev: ACPI device object to match.
984 * @of_match_table: List of device IDs to match against.
985 *
986 * If @dev has an ACPI companion which has ACPI_DT_NAMESPACE_HID in its list of
987 * identifiers and a _DSD object with the "compatible" property, use that
988 * property to match against the given list of identifiers.
989 */
990static bool acpi_of_match_device(struct acpi_device *adev,
991 const struct of_device_id *of_match_table)
992{
993 const union acpi_object *of_compatible, *obj;
994 int i, nval;
995
996 if (!adev)
997 return false;
998
999 of_compatible = adev->data.of_compatible;
1000 if (!of_match_table || !of_compatible)
1001 return false;
1002
1003 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
1004 nval = of_compatible->package.count;
1005 obj = of_compatible->package.elements;
1006 } else { /* Must be ACPI_TYPE_STRING. */
1007 nval = 1;
1008 obj = of_compatible;
1009 }
1010 /* Now we can look for the driver DT compatible strings */
1011 for (i = 0; i < nval; i++, obj++) {
1012 const struct of_device_id *id;
1013
1014 for (id = of_match_table; id->compatible[0]; id++)
1015 if (!strcasecmp(obj->string.pointer, id->compatible))
1016 return true;
1017 }
1018
1019 return false;
1020}
1021
1022static bool __acpi_match_device_cls(const struct acpi_device_id *id,
1023 struct acpi_hardware_id *hwid)
1024{
1025 int i, msk, byte_shift;
1026 char buf[3];
1027
1028 if (!id->cls)
1029 return false;
1030
1031 /* Apply class-code bitmask, before checking each class-code byte */
1032 for (i = 1; i <= 3; i++) {
1033 byte_shift = 8 * (3 - i);
1034 msk = (id->cls_msk >> byte_shift) & 0xFF;
1035 if (!msk)
1036 continue;
1037
1038 sprintf(buf, "%02x", (id->cls >> byte_shift) & msk);
1039 if (strncmp(buf, &hwid->id[(i - 1) * 2], 2))
1040 return false;
1041 }
1042 return true;
1043}
1044
1045static const struct acpi_device_id *__acpi_match_device(
1046 struct acpi_device *device,
1047 const struct acpi_device_id *ids,
1048 const struct of_device_id *of_ids)
1049{
1050 const struct acpi_device_id *id;
1051 struct acpi_hardware_id *hwid;
1052
1053 /*
1054 * If the device is not present, it is unnecessary to load device
1055 * driver for it.
1056 */
1057 if (!device || !device->status.present)
1058 return NULL;
1059
1060 list_for_each_entry(hwid, &device->pnp.ids, list) {
1061 /* First, check the ACPI/PNP IDs provided by the caller. */
1062 for (id = ids; id->id[0] || id->cls; id++) {
1063 if (id->id[0] && !strcmp((char *) id->id, hwid->id))
1064 return id;
1065 else if (id->cls && __acpi_match_device_cls(id, hwid))
1066 return id;
1067 }
1068
1069 /*
1070 * Next, check ACPI_DT_NAMESPACE_HID and try to match the
1071 * "compatible" property if found.
1072 *
1073 * The id returned by the below is not valid, but the only
1074 * caller passing non-NULL of_ids here is only interested in
1075 * whether or not the return value is NULL.
1076 */
1077 if (!strcmp(ACPI_DT_NAMESPACE_HID, hwid->id)
1078 && acpi_of_match_device(device, of_ids))
1079 return id;
1080 }
1081 return NULL;
1082}
1083
1084/**
1085 * acpi_match_device - Match a struct device against a given list of ACPI IDs
1086 * @ids: Array of struct acpi_device_id object to match against.
1087 * @dev: The device structure to match.
1088 *
1089 * Check if @dev has a valid ACPI handle and if there is a struct acpi_device
1090 * object for that handle and use that object to match against a given list of
1091 * device IDs.
1092 *
1093 * Return a pointer to the first matching ID on success or %NULL on failure.
1094 */
1095const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
1096 const struct device *dev)
1097{
1098 return __acpi_match_device(acpi_companion_match(dev), ids, NULL);
1099}
1100EXPORT_SYMBOL_GPL(acpi_match_device);
1101
1102int acpi_match_device_ids(struct acpi_device *device,
1103 const struct acpi_device_id *ids)
1104{
1105 return __acpi_match_device(device, ids, NULL) ? 0 : -ENOENT;
1106}
1107EXPORT_SYMBOL(acpi_match_device_ids);
1108
1109bool acpi_driver_match_device(struct device *dev,
1110 const struct device_driver *drv)
1111{
1112 if (!drv->acpi_match_table)
1113 return acpi_of_match_device(ACPI_COMPANION(dev),
1114 drv->of_match_table);
1115
1116 return !!__acpi_match_device(acpi_companion_match(dev),
1117 drv->acpi_match_table, drv->of_match_table);
1118}
1119EXPORT_SYMBOL_GPL(acpi_driver_match_device);
1120
1121static void acpi_free_power_resources_lists(struct acpi_device *device) 447static void acpi_free_power_resources_lists(struct acpi_device *device)
1122{ 448{
1123 int i; 449 int i;
@@ -1144,144 +470,6 @@ static void acpi_device_release(struct device *dev)
1144 kfree(acpi_dev); 470 kfree(acpi_dev);
1145} 471}
1146 472
1147static int acpi_bus_match(struct device *dev, struct device_driver *drv)
1148{
1149 struct acpi_device *acpi_dev = to_acpi_device(dev);
1150 struct acpi_driver *acpi_drv = to_acpi_driver(drv);
1151
1152 return acpi_dev->flags.match_driver
1153 && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
1154}
1155
1156static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
1157{
1158 return __acpi_device_uevent_modalias(to_acpi_device(dev), env);
1159}
1160
1161static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
1162{
1163 struct acpi_device *device = data;
1164
1165 device->driver->ops.notify(device, event);
1166}
1167
1168static void acpi_device_notify_fixed(void *data)
1169{
1170 struct acpi_device *device = data;
1171
1172 /* Fixed hardware devices have no handles */
1173 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
1174}
1175
1176static u32 acpi_device_fixed_event(void *data)
1177{
1178 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
1179 return ACPI_INTERRUPT_HANDLED;
1180}
1181
1182static int acpi_device_install_notify_handler(struct acpi_device *device)
1183{
1184 acpi_status status;
1185
1186 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
1187 status =
1188 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
1189 acpi_device_fixed_event,
1190 device);
1191 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
1192 status =
1193 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
1194 acpi_device_fixed_event,
1195 device);
1196 else
1197 status = acpi_install_notify_handler(device->handle,
1198 ACPI_DEVICE_NOTIFY,
1199 acpi_device_notify,
1200 device);
1201
1202 if (ACPI_FAILURE(status))
1203 return -EINVAL;
1204 return 0;
1205}
1206
1207static void acpi_device_remove_notify_handler(struct acpi_device *device)
1208{
1209 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
1210 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
1211 acpi_device_fixed_event);
1212 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
1213 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
1214 acpi_device_fixed_event);
1215 else
1216 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
1217 acpi_device_notify);
1218}
1219
1220static int acpi_device_probe(struct device *dev)
1221{
1222 struct acpi_device *acpi_dev = to_acpi_device(dev);
1223 struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
1224 int ret;
1225
1226 if (acpi_dev->handler && !acpi_is_pnp_device(acpi_dev))
1227 return -EINVAL;
1228
1229 if (!acpi_drv->ops.add)
1230 return -ENOSYS;
1231
1232 ret = acpi_drv->ops.add(acpi_dev);
1233 if (ret)
1234 return ret;
1235
1236 acpi_dev->driver = acpi_drv;
1237 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1238 "Driver [%s] successfully bound to device [%s]\n",
1239 acpi_drv->name, acpi_dev->pnp.bus_id));
1240
1241 if (acpi_drv->ops.notify) {
1242 ret = acpi_device_install_notify_handler(acpi_dev);
1243 if (ret) {
1244 if (acpi_drv->ops.remove)
1245 acpi_drv->ops.remove(acpi_dev);
1246
1247 acpi_dev->driver = NULL;
1248 acpi_dev->driver_data = NULL;
1249 return ret;
1250 }
1251 }
1252
1253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
1254 acpi_drv->name, acpi_dev->pnp.bus_id));
1255 get_device(dev);
1256 return 0;
1257}
1258
1259static int acpi_device_remove(struct device * dev)
1260{
1261 struct acpi_device *acpi_dev = to_acpi_device(dev);
1262 struct acpi_driver *acpi_drv = acpi_dev->driver;
1263
1264 if (acpi_drv) {
1265 if (acpi_drv->ops.notify)
1266 acpi_device_remove_notify_handler(acpi_dev);
1267 if (acpi_drv->ops.remove)
1268 acpi_drv->ops.remove(acpi_dev);
1269 }
1270 acpi_dev->driver = NULL;
1271 acpi_dev->driver_data = NULL;
1272
1273 put_device(dev);
1274 return 0;
1275}
1276
1277struct bus_type acpi_bus_type = {
1278 .name = "acpi",
1279 .match = acpi_bus_match,
1280 .probe = acpi_device_probe,
1281 .remove = acpi_device_remove,
1282 .uevent = acpi_device_uevent,
1283};
1284
1285static void acpi_device_del(struct acpi_device *device) 473static void acpi_device_del(struct acpi_device *device)
1286{ 474{
1287 mutex_lock(&acpi_device_lock); 475 mutex_lock(&acpi_device_lock);
@@ -1529,47 +717,6 @@ struct acpi_device *acpi_get_next_child(struct device *dev,
1529} 717}
1530 718
1531/* -------------------------------------------------------------------------- 719/* --------------------------------------------------------------------------
1532 Driver Management
1533 -------------------------------------------------------------------------- */
1534/**
1535 * acpi_bus_register_driver - register a driver with the ACPI bus
1536 * @driver: driver being registered
1537 *
1538 * Registers a driver with the ACPI bus. Searches the namespace for all
1539 * devices that match the driver's criteria and binds. Returns zero for
1540 * success or a negative error status for failure.
1541 */
1542int acpi_bus_register_driver(struct acpi_driver *driver)
1543{
1544 int ret;
1545
1546 if (acpi_disabled)
1547 return -ENODEV;
1548 driver->drv.name = driver->name;
1549 driver->drv.bus = &acpi_bus_type;
1550 driver->drv.owner = driver->owner;
1551
1552 ret = driver_register(&driver->drv);
1553 return ret;
1554}
1555
1556EXPORT_SYMBOL(acpi_bus_register_driver);
1557
1558/**
1559 * acpi_bus_unregister_driver - unregisters a driver with the ACPI bus
1560 * @driver: driver to unregister
1561 *
1562 * Unregisters a driver with the ACPI bus. Searches the namespace for all
1563 * devices that match the driver's criteria and unbinds.
1564 */
1565void acpi_bus_unregister_driver(struct acpi_driver *driver)
1566{
1567 driver_unregister(&driver->drv);
1568}
1569
1570EXPORT_SYMBOL(acpi_bus_unregister_driver);
1571
1572/* --------------------------------------------------------------------------
1573 Device Enumeration 720 Device Enumeration
1574 -------------------------------------------------------------------------- */ 721 -------------------------------------------------------------------------- */
1575static struct acpi_device *acpi_bus_get_parent(acpi_handle handle) 722static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
@@ -2744,12 +1891,6 @@ int __init acpi_scan_init(void)
2744{ 1891{
2745 int result; 1892 int result;
2746 1893
2747 result = bus_register(&acpi_bus_type);
2748 if (result) {
2749 /* We don't want to quit even if we failed to add suspend/resume */
2750 printk(KERN_ERR PREFIX "Could not register bus type\n");
2751 }
2752
2753 acpi_pci_root_init(); 1894 acpi_pci_root_init();
2754 acpi_pci_link_init(); 1895 acpi_pci_link_init();
2755 acpi_processor_init(); 1896 acpi_processor_init();
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 2e19189da0ee..17a6fa01a338 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 * 19 *
24 */ 20 */
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 6d4e44ea74ac..fc28b9f5aa84 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 * 20 *
25 * This driver fully implements the ACPI thermal policy as described in the 21 * This driver fully implements the ACPI thermal policy as described in the
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 67c548ad3764..475c9079bf85 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */ 20 */
25 21
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index e269f084497d..bbec5009cdc2 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -46,6 +46,7 @@ config OMAP_MBOX_KFIFO_SIZE
46config PCC 46config PCC
47 bool "Platform Communication Channel Driver" 47 bool "Platform Communication Channel Driver"
48 depends on ACPI 48 depends on ACPI
49 default n
49 help 50 help
50 ACPI 5.0+ spec defines a generic mode of communication 51 ACPI 5.0+ spec defines a generic mode of communication
51 between the OS and a platform such as the BMC. This medium 52 between the OS and a platform such as the BMC. This medium
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 26d121d1d501..68885a82e704 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -352,4 +352,10 @@ static int __init pcc_init(void)
352 352
353 return 0; 353 return 0;
354} 354}
355device_initcall(pcc_init); 355
356/*
357 * Make PCC init postcore so that users of this mailbox
358 * such as the ACPI Processor driver have it available
359 * at their init.
360 */
361postcore_initcall(pcc_init);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 83061cac719b..5ba8fb64f664 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */ 20 */
25 21
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index ea6428b7dacb..29c691265b49 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -16,10 +16,6 @@
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */ 20 */
25 21
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 4188a4d3b597..2c4e7a9c1725 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -318,6 +318,7 @@ int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
318void acpi_processor_set_pdc(acpi_handle handle); 318void acpi_processor_set_pdc(acpi_handle handle);
319 319
320/* in processor_throttling.c */ 320/* in processor_throttling.c */
321#ifdef CONFIG_ACPI_CPU_FREQ_PSS
321int acpi_processor_tstate_has_changed(struct acpi_processor *pr); 322int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
322int acpi_processor_get_throttling_info(struct acpi_processor *pr); 323int acpi_processor_get_throttling_info(struct acpi_processor *pr);
323extern int acpi_processor_set_throttling(struct acpi_processor *pr, 324extern int acpi_processor_set_throttling(struct acpi_processor *pr,
@@ -330,14 +331,59 @@ extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
330 unsigned long action); 331 unsigned long action);
331extern const struct file_operations acpi_processor_throttling_fops; 332extern const struct file_operations acpi_processor_throttling_fops;
332extern void acpi_processor_throttling_init(void); 333extern void acpi_processor_throttling_init(void);
334#else
335static inline int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
336{
337 return 0;
338}
339
340static inline int acpi_processor_get_throttling_info(struct acpi_processor *pr)
341{
342 return -ENODEV;
343}
344
345static inline int acpi_processor_set_throttling(struct acpi_processor *pr,
346 int state, bool force)
347{
348 return -ENODEV;
349}
350
351static inline void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
352 unsigned long action) {}
353
354static inline void acpi_processor_throttling_init(void) {}
355#endif /* CONFIG_ACPI_CPU_FREQ_PSS */
356
333/* in processor_idle.c */ 357/* in processor_idle.c */
358extern struct cpuidle_driver acpi_idle_driver;
359#ifdef CONFIG_ACPI_PROCESSOR_IDLE
334int acpi_processor_power_init(struct acpi_processor *pr); 360int acpi_processor_power_init(struct acpi_processor *pr);
335int acpi_processor_power_exit(struct acpi_processor *pr); 361int acpi_processor_power_exit(struct acpi_processor *pr);
336int acpi_processor_cst_has_changed(struct acpi_processor *pr); 362int acpi_processor_cst_has_changed(struct acpi_processor *pr);
337int acpi_processor_hotplug(struct acpi_processor *pr); 363int acpi_processor_hotplug(struct acpi_processor *pr);
338extern struct cpuidle_driver acpi_idle_driver; 364#else
365static inline int acpi_processor_power_init(struct acpi_processor *pr)
366{
367 return -ENODEV;
368}
339 369
340#ifdef CONFIG_PM_SLEEP 370static inline int acpi_processor_power_exit(struct acpi_processor *pr)
371{
372 return -ENODEV;
373}
374
375static inline int acpi_processor_cst_has_changed(struct acpi_processor *pr)
376{
377 return -ENODEV;
378}
379
380static inline int acpi_processor_hotplug(struct acpi_processor *pr)
381{
382 return -ENODEV;
383}
384#endif /* CONFIG_ACPI_PROCESSOR_IDLE */
385
386#if defined(CONFIG_PM_SLEEP) & defined(CONFIG_ACPI_PROCESSOR_IDLE)
341void acpi_processor_syscore_init(void); 387void acpi_processor_syscore_init(void);
342void acpi_processor_syscore_exit(void); 388void acpi_processor_syscore_exit(void);
343#else 389#else
@@ -348,7 +394,7 @@ static inline void acpi_processor_syscore_exit(void) {}
348/* in processor_thermal.c */ 394/* in processor_thermal.c */
349int acpi_processor_get_limit_info(struct acpi_processor *pr); 395int acpi_processor_get_limit_info(struct acpi_processor *pr);
350extern const struct thermal_cooling_device_ops processor_cooling_ops; 396extern const struct thermal_cooling_device_ops processor_cooling_ops;
351#ifdef CONFIG_CPU_FREQ 397#if defined(CONFIG_ACPI_CPU_FREQ_PSS) & defined(CONFIG_CPU_FREQ)
352void acpi_thermal_cpufreq_init(void); 398void acpi_thermal_cpufreq_init(void);
353void acpi_thermal_cpufreq_exit(void); 399void acpi_thermal_cpufreq_exit(void);
354#else 400#else
@@ -360,6 +406,6 @@ static inline void acpi_thermal_cpufreq_exit(void)
360{ 406{
361 return; 407 return;
362} 408}
363#endif 409#endif /* CONFIG_ACPI_CPU_FREQ_PSS */
364 410
365#endif 411#endif
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index d2445fa9999f..01e6770d8e27 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -15,10 +15,6 @@
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 19 */
24 20