]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge branches 'acpi-init' and 'acpi-hotplug'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 17 Jan 2014 00:57:26 +0000 (01:57 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 17 Jan 2014 00:57:26 +0000 (01:57 +0100)
* acpi-init:
  ACPI / init: Run acpi_early_init() before timekeeping_init()

* acpi-hotplug:
  ACPI / memhotplug: add parameter to disable memory hotplug

179 files changed:
Documentation/acpi/namespace.txt
Documentation/kernel-parameters.txt
arch/arm/mach-exynos/cpuidle.c
arch/ia64/hp/common/aml_nfw.c
arch/ia64/kernel/acpi.c
arch/powerpc/platforms/pseries/processor_idle.c
arch/x86/kernel/acpi/boot.c
arch/x86/kernel/apic/apic_flat_64.c
arch/x86/kernel/apic/io_apic.c
arch/x86/pci/mmconfig-shared.c
arch/x86/pci/mmconfig_32.c
arch/x86/platform/olpc/olpc-xo15-sci.c
drivers/acpi/ac.c
drivers/acpi/acpi_extlog.c
drivers/acpi/acpi_memhotplug.c
drivers/acpi/acpi_pad.c
drivers/acpi/acpi_processor.c
drivers/acpi/acpica/acdebug.h
drivers/acpi/acpica/acevents.h
drivers/acpi/acpica/acglobal.h
drivers/acpi/acpica/aclocal.h
drivers/acpi/acpica/dsfield.c
drivers/acpi/acpica/dsutils.c
drivers/acpi/acpica/dswload.c
drivers/acpi/acpica/evgpeblk.c
drivers/acpi/acpica/evgpeutil.c
drivers/acpi/acpica/exresnte.c
drivers/acpi/acpica/nsxfeval.c
drivers/acpi/acpica/psopinfo.c
drivers/acpi/acpica/tbfadt.c
drivers/acpi/acpica/tbutils.c
drivers/acpi/acpica/utaddress.c
drivers/acpi/acpica/utalloc.c
drivers/acpi/acpica/utcache.c
drivers/acpi/acpica/utdebug.c
drivers/acpi/acpica/utglobal.c
drivers/acpi/acpica/utxfinit.c
drivers/acpi/apei/apei-base.c
drivers/acpi/apei/apei-internal.h
drivers/acpi/apei/einj.c
drivers/acpi/apei/ghes.c
drivers/acpi/battery.c
drivers/acpi/blacklist.c
drivers/acpi/bus.c
drivers/acpi/button.c
drivers/acpi/container.c
drivers/acpi/custom_method.c
drivers/acpi/debugfs.c
drivers/acpi/device_pm.c
drivers/acpi/dock.c
drivers/acpi/ec.c
drivers/acpi/ec_sys.c
drivers/acpi/event.c
drivers/acpi/fan.c
drivers/acpi/glue.c
drivers/acpi/hed.c
drivers/acpi/internal.h
drivers/acpi/numa.c
drivers/acpi/nvs.c
drivers/acpi/osl.c
drivers/acpi/pci_irq.c
drivers/acpi/pci_link.c
drivers/acpi/pci_root.c
drivers/acpi/pci_slot.c
drivers/acpi/power.c
drivers/acpi/proc.c
drivers/acpi/processor_core.c
drivers/acpi/processor_driver.c
drivers/acpi/processor_idle.c
drivers/acpi/processor_perflib.c
drivers/acpi/processor_thermal.c
drivers/acpi/processor_throttling.c
drivers/acpi/sbshc.c
drivers/acpi/scan.c
drivers/acpi/sleep.c
drivers/acpi/sysfs.c
drivers/acpi/tables.c
drivers/acpi/thermal.c
drivers/acpi/utils.c
drivers/acpi/video.c
drivers/acpi/video_detect.c
drivers/acpi/wakeup.c
drivers/ata/libata-acpi.c
drivers/ata/pata_acpi.c
drivers/base/Makefile
drivers/base/base.h
drivers/base/container.c [new file with mode: 0644]
drivers/base/init.c
drivers/base/power/clock_ops.c
drivers/base/power/generic_ops.c
drivers/char/apm-emulation.c
drivers/char/hpet.c
drivers/char/tpm/tpm_acpi.c
drivers/char/tpm/tpm_ppi.c
drivers/firmware/Kconfig
drivers/gpu/drm/gma500/opregion.c
drivers/gpu/drm/i915/Makefile
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_acpi.c
drivers/gpu/drm/i915/intel_opregion.c
drivers/gpu/drm/nouveau/core/subdev/mxm/base.c
drivers/gpu/drm/nouveau/nouveau_acpi.c
drivers/gpu/drm/radeon/radeon_acpi.c
drivers/hid/i2c-hid/i2c-hid.c
drivers/hv/vmbus_drv.c
drivers/hwmon/acpi_power_meter.c
drivers/hwmon/asus_atk0110.c
drivers/ide/ide-acpi.c
drivers/idle/intel_idle.c
drivers/input/misc/atlas_btns.c
drivers/iommu/amd_iommu_init.c
drivers/iommu/intel_irq_remapping.c
drivers/mmc/core/sdio_bus.c
drivers/pci/hotplug/acpiphp_glue.c
drivers/pci/hotplug/acpiphp_ibm.c
drivers/pci/hotplug/pciehp.h
drivers/pci/ioapic.c
drivers/pci/pci-acpi.c
drivers/pci/pci-label.c
drivers/platform/x86/acer-wmi.c
drivers/platform/x86/asus-laptop.c
drivers/platform/x86/asus-wmi.c
drivers/platform/x86/classmate-laptop.c
drivers/platform/x86/dell-wmi-aio.c
drivers/platform/x86/dell-wmi.c
drivers/platform/x86/eeepc-laptop.c
drivers/platform/x86/eeepc-wmi.c
drivers/platform/x86/hp_accel.c
drivers/platform/x86/ideapad-laptop.c
drivers/platform/x86/intel-rst.c
drivers/platform/x86/intel-smartconnect.c
drivers/platform/x86/intel_menlow.c
drivers/platform/x86/intel_oaktrail.c
drivers/platform/x86/mxm-wmi.c
drivers/platform/x86/panasonic-laptop.c
drivers/platform/x86/pvpanic.c
drivers/platform/x86/samsung-q10.c
drivers/platform/x86/sony-laptop.c
drivers/platform/x86/tc1100-wmi.c
drivers/platform/x86/thinkpad_acpi.c
drivers/platform/x86/toshiba_acpi.c
drivers/platform/x86/toshiba_bluetooth.c
drivers/platform/x86/wmi.c
drivers/platform/x86/xo15-ebook.c
drivers/pnp/card.c
drivers/pnp/pnpacpi/core.c
drivers/pnp/pnpacpi/pnpacpi.h
drivers/pnp/pnpbios/core.c
drivers/pnp/resource.c
drivers/sfi/sfi_acpi.c
drivers/staging/quickstart/quickstart.c
drivers/usb/core/usb-acpi.c
drivers/xen/xen-acpi-cpuhotplug.c
drivers/xen/xen-acpi-memhotplug.c
drivers/xen/xen-acpi-pad.c
drivers/xen/xen-acpi-processor.c
include/acpi/acpi_bus.h
include/acpi/acpi_drivers.h
include/acpi/acpi_io.h [moved from include/linux/acpi_io.h with 94% similarity]
include/acpi/acpixf.h
include/acpi/actbl.h
include/acpi/actbl1.h
include/acpi/actbl2.h
include/acpi/actbl3.h
include/acpi/actypes.h
include/acpi/platform/acenv.h
include/acpi/platform/aclinux.h
include/linux/acpi.h
include/linux/container.h [new file with mode: 0644]
include/linux/ide.h
include/linux/iscsi_ibft.h
include/linux/pci_hotplug.h
include/linux/pm.h
include/linux/pm_runtime.h
include/linux/sfi_acpi.h
include/linux/tboot.h
include/uapi/linux/apm_bios.h
kernel/power/hibernate.c
tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c

index 260f6a3661faff625aabda6bc3dc6ba9eda84012..1860cb3865c6b26474a2d07d3944a9858a9f07c6 100644 (file)
@@ -235,10 +235,6 @@ Wysocki <rafael.j.wysocki@intel.com>.
       named object's type in the second column).  In that case the object's
       directory in sysfs will contain the 'path' attribute whose value is
       the full path to the node from the namespace root.
-      struct acpi_device objects are created for the ACPI namespace nodes
-      whose _STA control methods return PRESENT or FUNCTIONING.  The power
-      resource nodes or nodes without _STA are assumed to be both PRESENT
-      and FUNCTIONING.
    F:
       The struct acpi_device object is created for a fixed hardware
       feature (as indicated by the fixed feature flag's name in the second
@@ -340,7 +336,7 @@ Wysocki <rafael.j.wysocki@intel.com>.
      | +-------------+-------+----------------+
      |   |
      |   | +- - - - - - - +- - - - - - +- - - - - - - -+
-     |   +-| PNP0C0D:00 | \_SB_.LID0 | acpi:PNP0C0D: |
+     |   +-| PNP0C0D:00 | \_SB_.LID0 | acpi:PNP0C0D: |
      |   | +- - - - - - - +- - - - - - +- - - - - - - -+
      |   |
      |   | +------------+------------+-----------------------+
@@ -390,6 +386,3 @@ Wysocki <rafael.j.wysocki@intel.com>.
             attribute (as described earlier in this document).
    NOTE: N/A indicates the device object does not have the 'path' or the
          'modalias' attribute.
-   NOTE: The PNP0C0D device listed above is highlighted (marked by "*")
-         to indicate it will be created only when its _STA methods return
-         PRESENT or FUNCTIONING.
index b9e9bd85429801efa537bc1ea85f773fc92099f8..620122946c5b16f72e5fd6bd1920574f79ad65ac 100644 (file)
@@ -343,6 +343,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
                        no: ACPI OperationRegions are not marked as reserved,
                        no further checks are performed.
 
+       acpi_no_memhotplug [ACPI] Disable memory hotplug.  Useful for kdump
+                          kernels.
+
        add_efi_memmap  [EFI; X86] Include EFI memory map in
                        kernel's map of available physical RAM.
 
index ddbfe8709fe7fe4bd43fb5f2ea3301ba1e304b63..8e0eb2ef8c41a37481aa45b6924279ade8259ba9 100644 (file)
@@ -151,8 +151,8 @@ static int exynos4_enter_lowpower(struct cpuidle_device *dev,
 {
        int new_index = index;
 
-       /* This mode only can be entered when other core's are offline */
-       if (num_online_cpus() > 1)
+       /* AFTR can only be entered when cores other than CPU0 are offline */
+       if (num_online_cpus() > 1 || dev->cpu != 0)
                new_index = drv->safe_state_index;
 
        if (new_index == 0)
@@ -214,10 +214,6 @@ static int exynos_cpuidle_probe(struct platform_device *pdev)
                device = &per_cpu(exynos4_cpuidle_device, cpu_id);
                device->cpu = cpu_id;
 
-               /* Support IDLE only */
-               if (cpu_id != 0)
-                       device->state_count = 1;
-
                ret = cpuidle_register_device(device);
                if (ret) {
                        dev_err(&pdev->dev, "failed to register cpuidle device\n");
index 916ffe770bcf5691c0e2b6744a40f0d45c81d487..84715fcbba0875ed7e689ec761c2e4a2184477bd 100644 (file)
@@ -23,8 +23,7 @@
  */
 
 #include <linux/module.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <asm/sal.h>
 
 MODULE_AUTHOR("Bjorn Helgaas <bjorn.helgaas@hp.com>");
index 59d52e3aef125b79b67afdaf1fcffd2b892367ff..28dc6ba6690adf3910eec80135f76d44c1c4e98e 100644 (file)
@@ -61,7 +61,6 @@
 
 #define PREFIX                 "ACPI: "
 
-u32 acpi_rsdt_forced;
 unsigned int acpi_cpei_override;
 unsigned int acpi_cpei_phys_cpuid;
 
index a166e38bd683d3b1266922b380fda6e3da595ad8..94134a5aecaac80ce2869826ce11c7ccd1703578 100644 (file)
@@ -28,7 +28,6 @@ struct cpuidle_driver pseries_idle_driver = {
 #define MAX_IDLE_STATE_COUNT   2
 
 static int max_idle_state = MAX_IDLE_STATE_COUNT - 1;
-static struct cpuidle_device __percpu *pseries_cpuidle_devices;
 static struct cpuidle_state *cpuidle_state_table;
 
 static inline void idle_loop_prolog(unsigned long *in_purr)
@@ -191,7 +190,7 @@ static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n,
 {
        int hotcpu = (unsigned long)hcpu;
        struct cpuidle_device *dev =
-                       per_cpu_ptr(pseries_cpuidle_devices, hotcpu);
+                       per_cpu_ptr(cpuidle_devices, hotcpu);
 
        if (dev && cpuidle_get_driver()) {
                switch (action) {
@@ -248,50 +247,6 @@ static int pseries_cpuidle_driver_init(void)
        return 0;
 }
 
-/* pseries_idle_devices_uninit(void)
- * unregister cpuidle devices and de-allocate memory
- */
-static void pseries_idle_devices_uninit(void)
-{
-       int i;
-       struct cpuidle_device *dev;
-
-       for_each_possible_cpu(i) {
-               dev = per_cpu_ptr(pseries_cpuidle_devices, i);
-               cpuidle_unregister_device(dev);
-       }
-
-       free_percpu(pseries_cpuidle_devices);
-       return;
-}
-
-/* pseries_idle_devices_init()
- * allocate, initialize and register cpuidle device
- */
-static int pseries_idle_devices_init(void)
-{
-       int i;
-       struct cpuidle_driver *drv = &pseries_idle_driver;
-       struct cpuidle_device *dev;
-
-       pseries_cpuidle_devices = alloc_percpu(struct cpuidle_device);
-       if (pseries_cpuidle_devices == NULL)
-               return -ENOMEM;
-
-       for_each_possible_cpu(i) {
-               dev = per_cpu_ptr(pseries_cpuidle_devices, i);
-               dev->state_count = drv->state_count;
-               dev->cpu = i;
-               if (cpuidle_register_device(dev)) {
-                       printk(KERN_DEBUG \
-                               "cpuidle_register_device %d failed!\n", i);
-                       return -EIO;
-               }
-       }
-
-       return 0;
-}
-
 /*
  * pseries_idle_probe()
  * Choose state table for shared versus dedicated partition
@@ -327,19 +282,12 @@ static int __init pseries_processor_idle_init(void)
                return retval;
 
        pseries_cpuidle_driver_init();
-       retval = cpuidle_register_driver(&pseries_idle_driver);
+       retval = cpuidle_register(&pseries_idle_driver, NULL);
        if (retval) {
                printk(KERN_DEBUG "Registration of pseries driver failed.\n");
                return retval;
        }
 
-       retval = pseries_idle_devices_init();
-       if (retval) {
-               pseries_idle_devices_uninit();
-               cpuidle_unregister_driver(&pseries_idle_driver);
-               return retval;
-       }
-
        register_cpu_notifier(&setup_hotplug_notifier);
        printk(KERN_DEBUG "pseries_idle_driver registered\n");
 
@@ -350,8 +298,7 @@ static void __exit pseries_processor_idle_exit(void)
 {
 
        unregister_cpu_notifier(&setup_hotplug_notifier);
-       pseries_idle_devices_uninit();
-       cpuidle_unregister_driver(&pseries_idle_driver);
+       cpuidle_unregister(&pseries_idle_driver);
 
        return;
 }
index 6c0b43bd024bb5890230ca45c61b3de082b611ef..0b0b91b83d515f7331f47e4d6dd3ce8057400402 100644 (file)
@@ -46,7 +46,6 @@
 
 #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
 static int __initdata acpi_force = 0;
-u32 acpi_rsdt_forced;
 int acpi_disabled;
 EXPORT_SYMBOL(acpi_disabled);
 
@@ -1564,7 +1563,7 @@ static int __init parse_acpi(char *arg)
        }
        /* acpi=rsdt use RSDT instead of XSDT */
        else if (strcmp(arg, "rsdt") == 0) {
-               acpi_rsdt_forced = 1;
+               acpi_gbl_do_not_use_xsdt = TRUE;
        }
        /* "acpi=noirq" disables ACPI interrupt routing */
        else if (strcmp(arg, "noirq") == 0) {
index 00c77cf78e9e1839973923076053fdf92d75a54e..ccbf857d1d558461eb59139784faa2d0f43cabc9 100644 (file)
@@ -21,9 +21,7 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 
-#ifdef CONFIG_ACPI
-#include <acpi/acpi_bus.h>
-#endif
+#include <linux/acpi.h>
 
 static struct apic apic_physflat;
 static struct apic apic_flat;
index e63a5bd2a78f55de2c356b665751558a73bc18da..4d67a7531d4558c6016c9a6e1f16dc07b97205c2 100644 (file)
@@ -37,9 +37,6 @@
 #include <linux/kthread.h>
 #include <linux/jiffies.h>     /* time_after() */
 #include <linux/slab.h>
-#ifdef CONFIG_ACPI
-#include <acpi/acpi_bus.h>
-#endif
 #include <linux/bootmem.h>
 #include <linux/dmar.h>
 #include <linux/hpet.h>
index 082e88129712b4eb9e2027852c890a02ff31a1c7..248642f4bab7140c6ee7e80862b46b0c76fdc42f 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <linux/pci.h>
 #include <linux/init.h>
-#include <linux/acpi.h>
 #include <linux/sfi_acpi.h>
 #include <linux/bitmap.h>
 #include <linux/dmi.h>
index 5c90975cdf0f8242db167fa9c471c1ea2bf3e512..43984bc1665a917303ae574b27345138cc9560b6 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/rcupdate.h>
 #include <asm/e820.h>
 #include <asm/pci_x86.h>
-#include <acpi/acpi.h>
 
 /* Assume systems with more busses have correct MCFG */
 #define mmcfg_virt_addr ((void __iomem *) fix_to_virt(FIX_PCIE_MCFG))
index 649a12befba92f399895b947cc779e0269ac750d..08e350e757dcd189c29e06d4d0b199a2cd920b9f 100644 (file)
@@ -15,8 +15,7 @@
 #include <linux/power_supply.h>
 #include <linux/olpc-ec.h>
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <asm/olpc.h>
 
 #define DRV_NAME                       "olpc-xo15-sci"
index 3c2e4aa529c479e92090c8862deaadcf0a8645e5..e7515aa43d6bd62c3ec0e33fb6781d2a9f2f27a7 100644 (file)
@@ -32,8 +32,7 @@
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/power_supply.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 #define PREFIX "ACPI: "
 
index a6869e110ce5650a86b6f666bc28347031c16275..94166680b3a39f96cb0dcd4e98c5011bf3b8df4f 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <linux/module.h>
 #include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
 #include <linux/cper.h>
 #include <linux/ratelimit.h>
 #include <asm/cpu.h>
 #define EXT_ELOG_ENTRY_MASK    GENMASK_ULL(51, 0) /* elog entry address mask */
 
 #define EXTLOG_DSM_REV         0x0
-#define        EXTLOG_FN_QUERY         0x0
 #define        EXTLOG_FN_ADDR          0x1
 
 #define FLAG_OS_OPTIN          BIT(0)
-#define EXTLOG_QUERY_L1_EXIST  BIT(1)
 #define ELOG_ENTRY_VALID       (1ULL<<63)
 #define ELOG_ENTRY_LEN         0x1000
 
@@ -43,7 +40,7 @@ struct extlog_l1_head {
        u8  rev1[12];
 };
 
-static u8 extlog_dsm_uuid[] = "663E35AF-CC10-41A4-88EA-5470AF055295";
+static u8 extlog_dsm_uuid[] __initdata = "663E35AF-CC10-41A4-88EA-5470AF055295";
 
 /* L1 table related physical address */
 static u64 elog_base;
@@ -153,62 +150,27 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
        return NOTIFY_DONE;
 }
 
-static int extlog_get_dsm(acpi_handle handle, int rev, int func, u64 *ret)
+static bool __init extlog_get_l1addr(void)
 {
-       struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
-       struct acpi_object_list input;
-       union acpi_object params[4], *obj;
        u8 uuid[16];
-       int i;
+       acpi_handle handle;
+       union acpi_object *obj;
 
        acpi_str_to_uuid(extlog_dsm_uuid, uuid);
-       input.count = 4;
-       input.pointer = params;
-       params[0].type = ACPI_TYPE_BUFFER;
-       params[0].buffer.length = 16;
-       params[0].buffer.pointer = uuid;
-       params[1].type = ACPI_TYPE_INTEGER;
-       params[1].integer.value = rev;
-       params[2].type = ACPI_TYPE_INTEGER;
-       params[2].integer.value = func;
-       params[3].type = ACPI_TYPE_PACKAGE;
-       params[3].package.count = 0;
-       params[3].package.elements = NULL;
-
-       if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DSM", &input, &buf)))
-               return -1;
-
-       *ret = 0;
-       obj = (union acpi_object *)buf.pointer;
-       if (obj->type == ACPI_TYPE_INTEGER) {
-               *ret = obj->integer.value;
-       } else if (obj->type == ACPI_TYPE_BUFFER) {
-               if (obj->buffer.length <= 8) {
-                       for (i = 0; i < obj->buffer.length; i++)
-                               *ret |= (obj->buffer.pointer[i] << (i * 8));
-               }
-       }
-       kfree(buf.pointer);
-
-       return 0;
-}
-
-static bool extlog_get_l1addr(void)
-{
-       acpi_handle handle;
-       u64 ret;
 
        if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
                return false;
-
-       if (extlog_get_dsm(handle, EXTLOG_DSM_REV, EXTLOG_FN_QUERY, &ret) ||
-           !(ret & EXTLOG_QUERY_L1_EXIST))
+       if (!acpi_check_dsm(handle, uuid, EXTLOG_DSM_REV, 1 << EXTLOG_FN_ADDR))
                return false;
-
-       if (extlog_get_dsm(handle, EXTLOG_DSM_REV, EXTLOG_FN_ADDR, &ret))
+       obj = acpi_evaluate_dsm_typed(handle, uuid, EXTLOG_DSM_REV,
+                                     EXTLOG_FN_ADDR, NULL, ACPI_TYPE_INTEGER);
+       if (!obj) {
                return false;
+       } else {
+               l1_dirbase = obj->integer.value;
+               ACPI_FREE(obj);
+       }
 
-       l1_dirbase = ret;
        /* Spec says L1 directory must be 4K aligned, bail out if it isn't */
        if (l1_dirbase & ((1 << 12) - 1)) {
                pr_warn(FW_BUG "L1 Directory is invalid at physical %llx\n",
index 551dad712ffec451364a08c01487a1987c10d7db..b67be85ff0fca23da57acae0892641c503e2abb4 100644 (file)
@@ -180,14 +180,14 @@ static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info)
 
 static int acpi_bind_memblk(struct memory_block *mem, void *arg)
 {
-       return acpi_bind_one(&mem->dev, (acpi_handle)arg);
+       return acpi_bind_one(&mem->dev, arg);
 }
 
 static int acpi_bind_memory_blocks(struct acpi_memory_info *info,
-                                  acpi_handle handle)
+                                  struct acpi_device *adev)
 {
        return walk_memory_range(acpi_meminfo_start_pfn(info),
-                                acpi_meminfo_end_pfn(info), (void *)handle,
+                                acpi_meminfo_end_pfn(info), adev,
                                 acpi_bind_memblk);
 }
 
@@ -197,8 +197,7 @@ static int acpi_unbind_memblk(struct memory_block *mem, void *arg)
        return 0;
 }
 
-static void acpi_unbind_memory_blocks(struct acpi_memory_info *info,
-                                     acpi_handle handle)
+static void acpi_unbind_memory_blocks(struct acpi_memory_info *info)
 {
        walk_memory_range(acpi_meminfo_start_pfn(info),
                          acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk);
@@ -242,9 +241,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
                if (result && result != -EEXIST)
                        continue;
 
-               result = acpi_bind_memory_blocks(info, handle);
+               result = acpi_bind_memory_blocks(info, mem_device->device);
                if (result) {
-                       acpi_unbind_memory_blocks(info, handle);
+                       acpi_unbind_memory_blocks(info);
                        return -ENODEV;
                }
 
@@ -285,7 +284,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
                if (nid == NUMA_NO_NODE)
                        nid = memory_add_physaddr_to_nid(info->start_addr);
 
-               acpi_unbind_memory_blocks(info, handle);
+               acpi_unbind_memory_blocks(info);
                remove_memory(nid, info->start_addr, info->length);
                list_del(&info->list);
                kfree(info);
@@ -361,7 +360,19 @@ static void acpi_memory_device_remove(struct acpi_device *device)
        acpi_memory_device_free(mem_device);
 }
 
+static bool __initdata acpi_no_memhotplug;
+
 void __init acpi_memory_hotplug_init(void)
 {
+       if (acpi_no_memhotplug)
+               return;
+
        acpi_scan_add_handler_with_hotplug(&memory_device_handler, "memory");
 }
+
+static int __init disable_acpi_memory_hotplug(char *str)
+{
+       acpi_no_memhotplug = true;
+       return 1;
+}
+__setup("acpi_no_memhotplug", disable_acpi_memory_hotplug);
index fc6008fbce35bd99f390d15af6e7471b1ca0438a..65610c0e7243d3d9cd4f8e5d757ca9d602b94816 100644 (file)
@@ -28,8 +28,7 @@
 #include <linux/cpu.h>
 #include <linux/clockchips.h>
 #include <linux/slab.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <asm/mwait.h>
 
 #define ACPI_PROCESSOR_AGGREGATOR_CLASS        "acpi_pad"
index 3c1d6b0c09a4b7d1eeeb9347a7c743d1c7487988..c9311be29a64991ee56563c5c2262e541302ebd7 100644 (file)
@@ -212,7 +212,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
        union acpi_object object = { 0 };
        struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
        struct acpi_processor *pr = acpi_driver_data(device);
-       int cpu_index, device_declaration = 0;
+       int apic_id, cpu_index, device_declaration = 0;
        acpi_status status = AE_OK;
        static int cpu0_initialized;
        unsigned long long value;
@@ -258,18 +258,21 @@ static int acpi_processor_get_info(struct acpi_device *device)
                device_declaration = 1;
                pr->acpi_id = value;
        }
-       pr->apic_id = acpi_get_apicid(pr->handle, device_declaration,
-                                       pr->acpi_id);
-       cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
 
-       /* Handle UP system running SMP kernel, with no LAPIC in MADT */
-       if (!cpu0_initialized && (cpu_index == -1) &&
-           (num_online_cpus() == 1)) {
-               cpu_index = 0;
+       apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
+       if (apic_id < 0) {
+               acpi_handle_err(pr->handle, "failed to get CPU APIC ID.\n");
+               return -ENODEV;
        }
+       pr->apic_id = apic_id;
 
-       cpu0_initialized = 1;
-
+       cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
+       if (!cpu0_initialized) {
+               cpu0_initialized = 1;
+               /* Handle UP system running SMP kernel, with no LAPIC in MADT */
+               if ((cpu_index == -1) && (num_online_cpus() == 1))
+                       cpu_index = 0;
+       }
        pr->id = cpu_index;
 
        /*
@@ -282,6 +285,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
                if (ret)
                        return ret;
        }
+
        /*
         * On some boxes several processors use the same processor bus id.
         * But they are located in different scope. For example:
@@ -395,7 +399,7 @@ static int acpi_processor_add(struct acpi_device *device,
                goto err;
        }
 
-       result = acpi_bind_one(dev, pr->handle);
+       result = acpi_bind_one(dev, device);
        if (result)
                goto err;
 
index a9fd0b872062a6d22d279db3f126e2dd734868e6..2bf3ca2b8a7a653f16fa97264e95063abd1fa3e0 100644 (file)
@@ -113,7 +113,6 @@ void acpi_db_display_handlers(void);
 ACPI_HW_DEPENDENT_RETURN_VOID(void
                              acpi_db_generate_gpe(char *gpe_arg,
                                                   char *block_arg))
-
 ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void))
 
 /*
index 41abe552c7a3c61709a42cdd2bedc794a309c538..0fb0adf435d667593c29b2f0785cb5a5c3a35e8c 100644 (file)
@@ -71,9 +71,8 @@ acpi_status acpi_ev_init_global_lock_handler(void);
 
 ACPI_HW_DEPENDENT_RETURN_OK(acpi_status
                            acpi_ev_acquire_global_lock(u16 timeout))
-
 ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void))
- acpi_status acpi_ev_remove_global_lock_handler(void);
+acpi_status acpi_ev_remove_global_lock_handler(void);
 
 /*
  * evgpe - Low-level GPE support
@@ -133,7 +132,7 @@ acpi_status acpi_ev_gpe_initialize(void);
 ACPI_HW_DEPENDENT_RETURN_VOID(void
                              acpi_ev_update_gpes(acpi_owner_id table_owner_id))
 
- acpi_status
+acpi_status
 acpi_ev_match_gpe_method(acpi_handle obj_handle,
                         u32 level, void *context, void **return_value);
 
@@ -149,7 +148,9 @@ acpi_status
 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
                       struct acpi_gpe_block_info *gpe_block, void *context);
 
-struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number);
+acpi_status
+acpi_ev_get_gpe_xrupt_block(u32 interrupt_number,
+                           struct acpi_gpe_xrupt_info **gpe_xrupt_block);
 
 acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt);
 
index e9f1fc7f99c708618bb95fda1c64175f34808fdc..24db8e153bf0e83770573ccc70608b51ea90ddaa 100644 (file)
@@ -118,6 +118,24 @@ bool ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
  */
 u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE);
 
+/*
+ * Optionally ignore an XSDT if present and use the RSDT instead.
+ * Although the ACPI specification requires that an XSDT be used instead
+ * of the RSDT, the XSDT has been found to be corrupt or ill-formed on
+ * some machines. Default behavior is to use the XSDT if present.
+ */
+u8 ACPI_INIT_GLOBAL(acpi_gbl_do_not_use_xsdt, FALSE);
+
+/*
+ * Optionally use 32-bit FADT addresses if and when there is a conflict
+ * (address mismatch) between the 32-bit and 64-bit versions of the
+ * address. Although ACPICA adheres to the ACPI specification which
+ * requires the use of the corresponding 64-bit address if it is non-zero,
+ * some machines have been found to have a corrupted non-zero 64-bit
+ * address. Default is FALSE, do not favor the 32-bit addresses.
+ */
+u8 ACPI_INIT_GLOBAL(acpi_gbl_use32_bit_fadt_addresses, FALSE);
+
 /*
  * Optionally truncate I/O addresses to 16 bits. Provides compatibility
  * with other ACPI implementations. NOTE: During ACPICA initialization,
@@ -482,6 +500,18 @@ ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
 
 #endif                         /* ACPI_DEBUGGER */
 
+/*****************************************************************************
+ *
+ * Application globals
+ *
+ ****************************************************************************/
+
+#ifdef ACPI_APPLICATION
+
+ACPI_FILE ACPI_INIT_GLOBAL(acpi_gbl_debug_file, NULL);
+
+#endif                         /* ACPI_APPLICATION */
+
 /*****************************************************************************
  *
  * Info/help support
index 53ed1a8ba4f0f26ca367180204a12666c3231546..d95ca5449aceb119361c2e83b441de76097b3306 100644 (file)
@@ -1038,15 +1038,16 @@ struct acpi_external_list {
        struct acpi_external_list *next;
        u32 value;
        u16 length;
+       u16 flags;
        u8 type;
-       u8 flags;
-       u8 resolved;
-       u8 emitted;
 };
 
 /* Values for Flags field above */
 
-#define ACPI_IPATH_ALLOCATED    0x01
+#define ACPI_EXT_RESOLVED_REFERENCE         0x01       /* Object was resolved during cross ref */
+#define ACPI_EXT_ORIGIN_FROM_FILE           0x02       /* External came from a file */
+#define ACPI_EXT_INTERNAL_PATH_ALLOCATED    0x04       /* Deallocate internal path on completion */
+#define ACPI_EXT_EXTERNAL_EMITTED           0x08       /* External() statement has been emitted */
 
 struct acpi_external_file {
        char *path;
index 2d4c07322576c9697ccd8389e822e3e27564fd67..e7a57c554e84f9d0f60c0bb558df4e288d495894 100644 (file)
@@ -105,7 +105,7 @@ acpi_ds_create_external_region(acpi_status lookup_status,
         * operation_region not found. Generate an External for it, and
         * insert the name into the namespace.
         */
-       acpi_dm_add_to_external_list(op, path, ACPI_TYPE_REGION, 0);
+       acpi_dm_add_op_to_external_list(op, path, ACPI_TYPE_REGION, 0, 0);
        status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION,
                                ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
                                walk_state, node);
index ade44e49deb4b554f78ff49884d010633c507047..d7f53fb2979ab9a602f11af4a9a1478e60f59c3d 100644 (file)
@@ -727,27 +727,26 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,
                index++;
        }
 
-       index--;
+       ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
+                         "NumOperands %d, ArgCount %d, Index %d\n",
+                         walk_state->num_operands, arg_count, index));
 
-       /* It is the appropriate order to get objects from the Result stack */
+       /* Create the interpreter arguments, in reverse order */
 
+       index--;
        for (i = 0; i < arg_count; i++) {
                arg = arguments[index];
-
-               /* Force the filling of the operand stack in inverse order */
-
-               walk_state->operand_index = (u8) index;
+               walk_state->operand_index = (u8)index;
 
                status = acpi_ds_create_operand(walk_state, arg, index);
                if (ACPI_FAILURE(status)) {
                        goto cleanup;
                }
 
-               index--;
-
                ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
-                                 "Arg #%u (%p) done, Arg1=%p\n", index, arg,
-                                 first_arg));
+                                 "Created Arg #%u (%p) %u args total\n",
+                                 index, arg, arg_count));
+               index--;
        }
 
        return_ACPI_STATUS(status);
index 95e681a36f9c28d820b40f55d211426ae4b2de92..2dbe109727c84c0b8d26029d479937ac3155b303 100644 (file)
@@ -181,8 +181,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                         * Target of Scope() not found. Generate an External for it, and
                         * insert the name into the namespace.
                         */
-                       acpi_dm_add_to_external_list(op, path, ACPI_TYPE_DEVICE,
-                                                    0);
+                       acpi_dm_add_op_to_external_list(op, path,
+                                                       ACPI_TYPE_DEVICE, 0, 0);
                        status =
                            acpi_ns_lookup(walk_state->scope_info, path,
                                           object_type, ACPI_IMODE_LOAD_PASS1,
index a9e76bc4ad97f9b6e5e8a8cf67dce7d2beeb8068..a31e549e64cc7a95b77b516596b3f86a3aeae3fb 100644 (file)
@@ -87,9 +87,9 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
                return_ACPI_STATUS(status);
        }
 
-       gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number);
-       if (!gpe_xrupt_block) {
-               status = AE_NO_MEMORY;
+       status =
+           acpi_ev_get_gpe_xrupt_block(interrupt_number, &gpe_xrupt_block);
+       if (ACPI_FAILURE(status)) {
                goto unlock_and_exit;
        }
 
@@ -112,7 +112,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
        acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
 
 unlock_and_exit:
-       status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
+       (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
        return_ACPI_STATUS(status);
 }
 
index d3f5e1e2a2b14ba699fb78309c7c23e5f0949fab..4d764e847a08a7174202166ae5e360e0b2d2b811 100644 (file)
@@ -197,8 +197,9 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
  * FUNCTION:    acpi_ev_get_gpe_xrupt_block
  *
  * PARAMETERS:  interrupt_number            - Interrupt for a GPE block
+ *              gpe_xrupt_block             - Where the block is returned
  *
- * RETURN:      A GPE interrupt block
+ * RETURN:      Status
  *
  * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
  *              block per unique interrupt level used for GPEs. Should be
@@ -207,7 +208,9 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
  *
  ******************************************************************************/
 
-struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
+acpi_status
+acpi_ev_get_gpe_xrupt_block(u32 interrupt_number,
+                           struct acpi_gpe_xrupt_info ** gpe_xrupt_block)
 {
        struct acpi_gpe_xrupt_info *next_gpe_xrupt;
        struct acpi_gpe_xrupt_info *gpe_xrupt;
@@ -221,7 +224,8 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
        next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
        while (next_gpe_xrupt) {
                if (next_gpe_xrupt->interrupt_number == interrupt_number) {
-                       return_PTR(next_gpe_xrupt);
+                       *gpe_xrupt_block = next_gpe_xrupt;
+                       return_ACPI_STATUS(AE_OK);
                }
 
                next_gpe_xrupt = next_gpe_xrupt->next;
@@ -231,7 +235,7 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
 
        gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info));
        if (!gpe_xrupt) {
-               return_PTR(NULL);
+               return_ACPI_STATUS(AE_NO_MEMORY);
        }
 
        gpe_xrupt->interrupt_number = interrupt_number;
@@ -250,6 +254,7 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
        } else {
                acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
        }
+
        acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
 
        /* Install new interrupt handler if not SCI_INT */
@@ -259,14 +264,15 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
                                                           acpi_ev_gpe_xrupt_handler,
                                                           gpe_xrupt);
                if (ACPI_FAILURE(status)) {
-                       ACPI_ERROR((AE_INFO,
-                                   "Could not install GPE interrupt handler at level 0x%X",
-                                   interrupt_number));
-                       return_PTR(NULL);
+                       ACPI_EXCEPTION((AE_INFO, status,
+                                       "Could not install GPE interrupt handler at level 0x%X",
+                                       interrupt_number));
+                       return_ACPI_STATUS(status);
                }
        }
 
-       return_PTR(gpe_xrupt);
+       *gpe_xrupt_block = gpe_xrupt;
+       return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
index acd34f5993131d573aa6bcdf6046e7dd34afad12..7ca6925a87cad08adea5abad1d1ec43dcf974d49 100644 (file)
@@ -124,7 +124,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
        }
 
        if (!source_desc) {
-               ACPI_ERROR((AE_INFO, "No object attached to node %p", node));
+               ACPI_ERROR((AE_INFO, "No object attached to node [%4.4s] %p",
+                           node->name.ascii, node));
                return_ACPI_STATUS(AE_AML_NO_OPERAND);
        }
 
index e973e311f856597fcb9474ea9f7eabaa0a76b1da..1f0c28ba50df353de078c6ae47f70cbee05f025f 100644 (file)
@@ -84,7 +84,7 @@ acpi_evaluate_object_typed(acpi_handle handle,
                           acpi_object_type return_type)
 {
        acpi_status status;
-       u8 must_free = FALSE;
+       u8 free_buffer_on_error = FALSE;
 
        ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed);
 
@@ -95,14 +95,13 @@ acpi_evaluate_object_typed(acpi_handle handle,
        }
 
        if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
-               must_free = TRUE;
+               free_buffer_on_error = TRUE;
        }
 
        /* Evaluate the object */
 
-       status =
-           acpi_evaluate_object(handle, pathname, external_params,
-                                return_buffer);
+       status = acpi_evaluate_object(handle, pathname,
+                                     external_params, return_buffer);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
        }
@@ -135,11 +134,15 @@ acpi_evaluate_object_typed(acpi_handle handle,
                                           pointer)->type),
                    acpi_ut_get_type_name(return_type)));
 
-       if (must_free) {
-
-               /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
-
-               ACPI_FREE_BUFFER(*return_buffer);
+       if (free_buffer_on_error) {
+               /*
+                * Free a buffer created via ACPI_ALLOCATE_BUFFER.
+                * Note: We use acpi_os_free here because acpi_os_allocate was used
+                * to allocate the buffer. This purposefully bypasses the
+                * (optionally enabled) allocation tracking mechanism since we
+                * only want to track internal allocations.
+                */
+               acpi_os_free(return_buffer->pointer);
                return_buffer->pointer = NULL;
        }
 
index 9ba5301e57516ea83450809f29c38e9cd2a09421..b0c9787dbe6194971f62f39e7c419ee1c389226e 100644 (file)
@@ -71,6 +71,10 @@ static const u8 acpi_gbl_argument_count[] =
 
 const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
 {
+#ifdef ACPI_DEBUG_OUTPUT
+       const char *opcode_name = "Unknown AML opcode";
+#endif
+
        ACPI_FUNCTION_NAME(ps_get_opcode_info);
 
        /*
@@ -92,11 +96,54 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
                return (&acpi_gbl_aml_op_info
                        [acpi_gbl_long_op_index[(u8)opcode]]);
        }
+#if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT
+#include "asldefine.h"
+
+       switch (opcode) {
+       case AML_RAW_DATA_BYTE:
+               opcode_name = "-Raw Data Byte-";
+               break;
+
+       case AML_RAW_DATA_WORD:
+               opcode_name = "-Raw Data Word-";
+               break;
+
+       case AML_RAW_DATA_DWORD:
+               opcode_name = "-Raw Data Dword-";
+               break;
+
+       case AML_RAW_DATA_QWORD:
+               opcode_name = "-Raw Data Qword-";
+               break;
+
+       case AML_RAW_DATA_BUFFER:
+               opcode_name = "-Raw Data Buffer-";
+               break;
+
+       case AML_RAW_DATA_CHAIN:
+               opcode_name = "-Raw Data Buffer Chain-";
+               break;
+
+       case AML_PACKAGE_LENGTH:
+               opcode_name = "-Package Length-";
+               break;
+
+       case AML_UNASSIGNED_OPCODE:
+               opcode_name = "-Unassigned Opcode-";
+               break;
+
+       case AML_DEFAULT_ARG_OP:
+               opcode_name = "-Default Arg-";
+               break;
+
+       default:
+               break;
+       }
+#endif
 
        /* Unknown AML opcode */
 
-       ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
-                         "Unknown AML opcode [%4.4X]\n", opcode));
+       ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%4.4X]\n", opcode_name, opcode));
 
        return (&acpi_gbl_aml_op_info[_UNK]);
 }
index 9d99f21896935873cd868f68a767f7f074370ec6..8f89263ac47e28cfecce4304a16b79406ba5c71f 100644 (file)
@@ -56,10 +56,11 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
 
 static void acpi_tb_convert_fadt(void);
 
-static void acpi_tb_validate_fadt(void);
-
 static void acpi_tb_setup_fadt_registers(void);
 
+static u64
+acpi_tb_select_address(char *register_name, u32 address32, u64 address64);
+
 /* Table for conversion of FADT to common internal format and FADT validation */
 
 typedef struct acpi_fadt_info {
@@ -175,6 +176,7 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
  *              space_id            - ACPI Space ID for this register
  *              byte_width          - Width of this register
  *              address             - Address of the register
+ *              register_name       - ASCII name of the ACPI register
  *
  * RETURN:      None
  *
@@ -218,6 +220,68 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
        generic_address->access_width = 0;      /* Access width ANY */
 }
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_select_address
+ *
+ * PARAMETERS:  register_name       - ASCII name of the ACPI register
+ *              address32           - 32-bit address of the register
+ *              address64           - 64-bit address of the register
+ *
+ * RETURN:      The resolved 64-bit address
+ *
+ * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within
+ *              the FADT. Used for the FACS and DSDT addresses.
+ *
+ * NOTES:
+ *
+ * Check for FACS and DSDT address mismatches. An address mismatch between
+ * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
+ * DSDT/X_DSDT) could be a corrupted address field or it might indicate
+ * the presence of two FACS or two DSDT tables.
+ *
+ * November 2013:
+ * By default, as per the ACPICA specification, a valid 64-bit address is
+ * used regardless of the value of the 32-bit address. However, this
+ * behavior can be overridden via the acpi_gbl_use32_bit_fadt_addresses flag.
+ *
+ ******************************************************************************/
+
+static u64
+acpi_tb_select_address(char *register_name, u32 address32, u64 address64)
+{
+
+       if (!address64) {
+
+               /* 64-bit address is zero, use 32-bit address */
+
+               return ((u64)address32);
+       }
+
+       if (address32 && (address64 != (u64)address32)) {
+
+               /* Address mismatch between 32-bit and 64-bit versions */
+
+               ACPI_BIOS_WARNING((AE_INFO,
+                                  "32/64X %s address mismatch in FADT: "
+                                  "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
+                                  register_name, address32,
+                                  ACPI_FORMAT_UINT64(address64),
+                                  acpi_gbl_use32_bit_fadt_addresses ? 32 :
+                                  64));
+
+               /* 32-bit address override */
+
+               if (acpi_gbl_use32_bit_fadt_addresses) {
+                       return ((u64)address32);
+               }
+       }
+
+       /* Default is to use the 64-bit address */
+
+       return (address64);
+}
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_tb_parse_fadt
@@ -331,10 +395,6 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
 
        acpi_tb_convert_fadt();
 
-       /* Validate FADT values now, before we make any changes */
-
-       acpi_tb_validate_fadt();
-
        /* Initialize the global ACPI register structures */
 
        acpi_tb_setup_fadt_registers();
@@ -344,65 +404,54 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
  *
  * FUNCTION:    acpi_tb_convert_fadt
  *
- * PARAMETERS:  None, uses acpi_gbl_FADT
+ * PARAMETERS:  none - acpi_gbl_FADT is used.
  *
  * RETURN:      None
  *
  * DESCRIPTION: Converts all versions of the FADT to a common internal format.
- *              Expand 32-bit addresses to 64-bit as necessary.
+ *              Expand 32-bit addresses to 64-bit as necessary. Also validate
+ *              important fields within the FADT.
  *
- * NOTE:        acpi_gbl_FADT must be of size (struct acpi_table_fadt),
- *              and must contain a copy of the actual FADT.
+ * NOTE:        acpi_gbl_FADT must be of size (struct acpi_table_fadt), and must
+ *              contain a copy of the actual BIOS-provided FADT.
  *
  * Notes on 64-bit register addresses:
  *
  * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
  * fields of the FADT for all ACPI register addresses.
  *
- * The 64-bit "X" fields are optional extensions to the original 32-bit FADT
+ * The 64-bit X fields are optional extensions to the original 32-bit FADT
  * V1.0 fields. Even if they are present in the FADT, they are optional and
  * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
- * 32-bit V1.0 fields if the corresponding X field is zero.
+ * 32-bit V1.0 fields to the 64-bit X fields if the the 64-bit X field is
+ * originally zero.
  *
- * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the
- * corresponding "X" fields in the internal FADT.
+ * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address
+ * fields are expanded to the corresponding 64-bit X fields in the internal
+ * common FADT.
  *
  * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
- * to the corresponding 64-bit X fields. For compatibility with other ACPI
- * implementations, we ignore the 64-bit field if the 32-bit field is valid,
- * regardless of whether the host OS is 32-bit or 64-bit.
+ * to the corresponding 64-bit X fields, if the 64-bit field is originally
+ * zero. Adhering to the ACPI specification, we completely ignore the 32-bit
+ * field if the 64-bit field is valid, regardless of whether the host OS is
+ * 32-bit or 64-bit.
+ *
+ * Possible additional checks:
+ *  (acpi_gbl_FADT.pm1_event_length >= 4)
+ *  (acpi_gbl_FADT.pm1_control_length >= 2)
+ *  (acpi_gbl_FADT.pm_timer_length >= 4)
+ *  Gpe block lengths must be multiple of 2
  *
  ******************************************************************************/
 
 static void acpi_tb_convert_fadt(void)
 {
+       char *name;
        struct acpi_generic_address *address64;
        u32 address32;
+       u8 length;
        u32 i;
 
-       /*
-        * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
-        * Later code will always use the X 64-bit field. Also, check for an
-        * address mismatch between the 32-bit and 64-bit address fields
-        * (FIRMWARE_CTRL/X_FIRMWARE_CTRL, DSDT/X_DSDT) which would indicate
-        * the presence of two FACS or two DSDT tables.
-        */
-       if (!acpi_gbl_FADT.Xfacs) {
-               acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
-       } else if (acpi_gbl_FADT.facs &&
-                  (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
-               ACPI_WARNING((AE_INFO,
-                   "32/64 FACS address mismatch in FADT - two FACS tables!"));
-       }
-
-       if (!acpi_gbl_FADT.Xdsdt) {
-               acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
-       } else if (acpi_gbl_FADT.dsdt &&
-                  (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
-               ACPI_WARNING((AE_INFO,
-                   "32/64 DSDT address mismatch in FADT - two DSDT tables!"));
-       }
-
        /*
         * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
         * should be zero are indeed zero. This will workaround BIOSs that
@@ -421,119 +470,24 @@ static void acpi_tb_convert_fadt(void)
                acpi_gbl_FADT.boot_flags = 0;
        }
 
-       /* Update the local FADT table header length */
-
-       acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
-
        /*
-        * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
-        * generic address structures as necessary. Later code will always use
-        * the 64-bit address structures.
-        *
-        * March 2009:
-        * We now always use the 32-bit address if it is valid (non-null). This
-        * is not in accordance with the ACPI specification which states that
-        * the 64-bit address supersedes the 32-bit version, but we do this for
-        * compatibility with other ACPI implementations. Most notably, in the
-        * case where both the 32 and 64 versions are non-null, we use the 32-bit
-        * version. This is the only address that is guaranteed to have been
-        * tested by the BIOS manufacturer.
+        * Now we can update the local FADT length to the length of the
+        * current FADT version as defined by the ACPI specification.
+        * Thus, we will have a common FADT internally.
         */
-       for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
-               address32 = *ACPI_ADD_PTR(u32,
-                                         &acpi_gbl_FADT,
-                                         fadt_info_table[i].address32);
-
-               address64 = ACPI_ADD_PTR(struct acpi_generic_address,
-                                        &acpi_gbl_FADT,
-                                        fadt_info_table[i].address64);
-
-               /*
-                * If both 32- and 64-bit addresses are valid (non-zero),
-                * they must match.
-                */
-               if (address64->address && address32 &&
-                   (address64->address != (u64)address32)) {
-                       ACPI_BIOS_ERROR((AE_INFO,
-                                        "32/64X address mismatch in FADT/%s: "
-                                        "0x%8.8X/0x%8.8X%8.8X, using 32",
-                                        fadt_info_table[i].name, address32,
-                                        ACPI_FORMAT_UINT64(address64->
-                                                           address)));
-               }
-
-               /* Always use 32-bit address if it is valid (non-null) */
-
-               if (address32) {
-                       /*
-                        * Copy the 32-bit address to the 64-bit GAS structure. The
-                        * Space ID is always I/O for 32-bit legacy address fields
-                       */
-                       acpi_tb_init_generic_address(address64,
-                                                    ACPI_ADR_SPACE_SYSTEM_IO,
-                                                    *ACPI_ADD_PTR(u8,
-                                                                  &acpi_gbl_FADT,
-                                                                  fadt_info_table
-                                                                  [i].length),
-                                                    (u64) address32,
-                                                    fadt_info_table[i].name);
-               }
-       }
-}
-
-/*******************************************************************************
- *
- * FUNCTION:    acpi_tb_validate_fadt
- *
- * PARAMETERS:  table           - Pointer to the FADT to be validated
- *
- * RETURN:      None
- *
- * DESCRIPTION: Validate various important fields within the FADT. If a problem
- *              is found, issue a message, but no status is returned.
- *              Used by both the table manager and the disassembler.
- *
- * Possible additional checks:
- * (acpi_gbl_FADT.pm1_event_length >= 4)
- * (acpi_gbl_FADT.pm1_control_length >= 2)
- * (acpi_gbl_FADT.pm_timer_length >= 4)
- * Gpe block lengths must be multiple of 2
- *
- ******************************************************************************/
-
-static void acpi_tb_validate_fadt(void)
-{
-       char *name;
-       struct acpi_generic_address *address64;
-       u8 length;
-       u32 i;
+       acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
 
        /*
-        * Check for FACS and DSDT address mismatches. An address mismatch between
-        * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
-        * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
+        * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
+        * Later ACPICA code will always use the X 64-bit field.
         */
-       if (acpi_gbl_FADT.facs &&
-           (acpi_gbl_FADT.Xfacs != (u64)acpi_gbl_FADT.facs)) {
-               ACPI_BIOS_WARNING((AE_INFO,
-                                  "32/64X FACS address mismatch in FADT - "
-                                  "0x%8.8X/0x%8.8X%8.8X, using 32",
-                                  acpi_gbl_FADT.facs,
-                                  ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs)));
-
-               acpi_gbl_FADT.Xfacs = (u64)acpi_gbl_FADT.facs;
-       }
-
-       if (acpi_gbl_FADT.dsdt &&
-           (acpi_gbl_FADT.Xdsdt != (u64)acpi_gbl_FADT.dsdt)) {
-               ACPI_BIOS_WARNING((AE_INFO,
-                                  "32/64X DSDT address mismatch in FADT - "
-                                  "0x%8.8X/0x%8.8X%8.8X, using 32",
-                                  acpi_gbl_FADT.dsdt,
-                                  ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
+       acpi_gbl_FADT.Xfacs = acpi_tb_select_address("FACS",
+                                                    acpi_gbl_FADT.facs,
+                                                    acpi_gbl_FADT.Xfacs);
 
-               acpi_gbl_FADT.Xdsdt = (u64)acpi_gbl_FADT.dsdt;
-       }
+       acpi_gbl_FADT.Xdsdt = acpi_tb_select_address("DSDT",
+                                                    acpi_gbl_FADT.dsdt,
+                                                    acpi_gbl_FADT.Xdsdt);
 
        /* If Hardware Reduced flag is set, we are all done */
 
@@ -545,17 +499,94 @@ static void acpi_tb_validate_fadt(void)
 
        for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
                /*
-                * Generate pointer to the 64-bit address, get the register
-                * length (width) and the register name
+                * Get the 32-bit and 64-bit addresses, as well as the register
+                * length and register name.
                 */
+               address32 = *ACPI_ADD_PTR(u32,
+                                         &acpi_gbl_FADT,
+                                         fadt_info_table[i].address32);
+
                address64 = ACPI_ADD_PTR(struct acpi_generic_address,
                                         &acpi_gbl_FADT,
                                         fadt_info_table[i].address64);
-               length =
-                   *ACPI_ADD_PTR(u8, &acpi_gbl_FADT,
-                                 fadt_info_table[i].length);
+
+               length = *ACPI_ADD_PTR(u8,
+                                      &acpi_gbl_FADT,
+                                      fadt_info_table[i].length);
+
                name = fadt_info_table[i].name;
 
+               /*
+                * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
+                * generic address structures as necessary. Later code will always use
+                * the 64-bit address structures.
+                *
+                * November 2013:
+                * Now always use the 64-bit address if it is valid (non-zero), in
+                * accordance with the ACPI specification which states that a 64-bit
+                * address supersedes the 32-bit version. This behavior can be
+                * overridden by the acpi_gbl_use32_bit_fadt_addresses flag.
+                *
+                * During 64-bit address construction and verification,
+                * these cases are handled:
+                *
+                * Address32 zero, Address64 [don't care]   - Use Address64
+                *
+                * Address32 non-zero, Address64 zero       - Copy/use Address32
+                * Address32 non-zero == Address64 non-zero - Use Address64
+                * Address32 non-zero != Address64 non-zero - Warning, use Address64
+                *
+                * Override: if acpi_gbl_use32_bit_fadt_addresses is TRUE, and:
+                * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32
+                *
+                * Note: space_id is always I/O for 32-bit legacy address fields
+                */
+               if (address32) {
+                       if (!address64->address) {
+
+                               /* 64-bit address is zero, use 32-bit address */
+
+                               acpi_tb_init_generic_address(address64,
+                                                            ACPI_ADR_SPACE_SYSTEM_IO,
+                                                            *ACPI_ADD_PTR(u8,
+                                                                          &acpi_gbl_FADT,
+                                                                          fadt_info_table
+                                                                          [i].
+                                                                          length),
+                                                            (u64)address32,
+                                                            name);
+                       } else if (address64->address != (u64)address32) {
+
+                               /* Address mismatch */
+
+                               ACPI_BIOS_WARNING((AE_INFO,
+                                                  "32/64X address mismatch in FADT/%s: "
+                                                  "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
+                                                  name, address32,
+                                                  ACPI_FORMAT_UINT64
+                                                  (address64->address),
+                                                  acpi_gbl_use32_bit_fadt_addresses
+                                                  ? 32 : 64));
+
+                               if (acpi_gbl_use32_bit_fadt_addresses) {
+
+                                       /* 32-bit address override */
+
+                                       acpi_tb_init_generic_address(address64,
+                                                                    ACPI_ADR_SPACE_SYSTEM_IO,
+                                                                    *ACPI_ADD_PTR
+                                                                    (u8,
+                                                                     &acpi_gbl_FADT,
+                                                                     fadt_info_table
+                                                                     [i].
+                                                                     length),
+                                                                    (u64)
+                                                                    address32,
+                                                                    name);
+                               }
+                       }
+               }
+
                /*
                 * For each extended field, check for length mismatch between the
                 * legacy length field and the corresponding 64-bit X length field.
index 3d6bb83aa7e75559ceb2a87688c273036f48bad8..6412d3c301cb62d480b9c753a0dbbf2b7af612f3 100644 (file)
 ACPI_MODULE_NAME("tbutils")
 
 /* Local prototypes */
+static acpi_status acpi_tb_validate_xsdt(acpi_physical_address address);
+
 static acpi_physical_address
 acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size);
 
-/*******************************************************************************
- *
- * FUNCTION:    acpi_tb_check_xsdt
- *
- * PARAMETERS:  address                    - Pointer to the XSDT
- *
- * RETURN:      status
- *             AE_OK - XSDT is okay
- *             AE_NO_MEMORY - can't map XSDT
- *             AE_INVALID_TABLE_LENGTH - invalid table length
- *             AE_NULL_ENTRY - XSDT has NULL entry
- *
- * DESCRIPTION: validate XSDT
-******************************************************************************/
-
-static acpi_status
-acpi_tb_check_xsdt(acpi_physical_address address)
-{
-       struct acpi_table_header *table;
-       u32 length;
-       u64 xsdt_entry_address;
-       u8 *table_entry;
-       u32 table_count;
-       int i;
-
-       table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
-       if (!table)
-               return AE_NO_MEMORY;
-
-       length = table->length;
-       acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
-       if (length < sizeof(struct acpi_table_header))
-               return AE_INVALID_TABLE_LENGTH;
-
-       table = acpi_os_map_memory(address, length);
-       if (!table)
-               return AE_NO_MEMORY;
-
-       /* Calculate the number of tables described in XSDT */
-       table_count =
-               (u32) ((table->length -
-               sizeof(struct acpi_table_header)) / sizeof(u64));
-       table_entry =
-               ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
-       for (i = 0; i < table_count; i++) {
-               ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry);
-               if (!xsdt_entry_address) {
-                       /* XSDT has NULL entry */
-                       break;
-               }
-               table_entry += sizeof(u64);
-       }
-       acpi_os_unmap_memory(table, length);
-
-       if (i < table_count)
-               return AE_NULL_ENTRY;
-       else
-               return AE_OK;
-}
-
 #if (!ACPI_REDUCED_HARDWARE)
 /*******************************************************************************
  *
@@ -383,7 +325,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
         * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
         * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
         */
-       if (table_entry_size == sizeof(u32)) {
+       if (table_entry_size == ACPI_RSDT_ENTRY_SIZE) {
                /*
                 * 32-bit platform, RSDT: Return 32-bit table entry
                 * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
@@ -413,6 +355,87 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
        }
 }
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_validate_xsdt
+ *
+ * PARAMETERS:  address             - Physical address of the XSDT (from RSDP)
+ *
+ * RETURN:      Status. AE_OK if the table appears to be valid.
+ *
+ * DESCRIPTION: Validate an XSDT to ensure that it is of minimum size and does
+ *              not contain any NULL entries. A problem that is seen in the
+ *              field is that the XSDT exists, but is actually useless because
+ *              of one or more (or all) NULL entries.
+ *
+ ******************************************************************************/
+
+static acpi_status acpi_tb_validate_xsdt(acpi_physical_address xsdt_address)
+{
+       struct acpi_table_header *table;
+       u8 *next_entry;
+       acpi_physical_address address;
+       u32 length;
+       u32 entry_count;
+       acpi_status status;
+       u32 i;
+
+       /* Get the XSDT length */
+
+       table =
+           acpi_os_map_memory(xsdt_address, sizeof(struct acpi_table_header));
+       if (!table) {
+               return (AE_NO_MEMORY);
+       }
+
+       length = table->length;
+       acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
+
+       /*
+        * Minimum XSDT length is the size of the standard ACPI header
+        * plus one physical address entry
+        */
+       if (length < (sizeof(struct acpi_table_header) + ACPI_XSDT_ENTRY_SIZE)) {
+               return (AE_INVALID_TABLE_LENGTH);
+       }
+
+       /* Map the entire XSDT */
+
+       table = acpi_os_map_memory(xsdt_address, length);
+       if (!table) {
+               return (AE_NO_MEMORY);
+       }
+
+       /* Get the number of entries and pointer to first entry */
+
+       status = AE_OK;
+       next_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));
+       entry_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
+                           ACPI_XSDT_ENTRY_SIZE);
+
+       /* Validate each entry (physical address) within the XSDT */
+
+       for (i = 0; i < entry_count; i++) {
+               address =
+                   acpi_tb_get_root_table_entry(next_entry,
+                                                ACPI_XSDT_ENTRY_SIZE);
+               if (!address) {
+
+                       /* Detected a NULL entry, XSDT is invalid */
+
+                       status = AE_NULL_ENTRY;
+                       break;
+               }
+
+               next_entry += ACPI_XSDT_ENTRY_SIZE;
+       }
+
+       /* Unmap table */
+
+       acpi_os_unmap_memory(table, length);
+       return (status);
+}
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_tb_parse_root_table
@@ -438,16 +461,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
        u32 table_count;
        struct acpi_table_header *table;
        acpi_physical_address address;
-       acpi_physical_address uninitialized_var(rsdt_address);
        u32 length;
        u8 *table_entry;
        acpi_status status;
 
        ACPI_FUNCTION_TRACE(tb_parse_root_table);
 
-       /*
-        * Map the entire RSDP and extract the address of the RSDT or XSDT
-        */
+       /* Map the entire RSDP and extract the address of the RSDT or XSDT */
+
        rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));
        if (!rsdp) {
                return_ACPI_STATUS(AE_NO_MEMORY);
@@ -457,24 +478,22 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
                                   ACPI_CAST_PTR(struct acpi_table_header,
                                                 rsdp));
 
-       /* Differentiate between RSDT and XSDT root tables */
+       /* Use XSDT if present and not overridden. Otherwise, use RSDT */
 
-       if (rsdp->revision > 1 && rsdp->xsdt_physical_address
-                       && !acpi_rsdt_forced) {
+       if ((rsdp->revision > 1) &&
+           rsdp->xsdt_physical_address && !acpi_gbl_do_not_use_xsdt) {
                /*
-                * Root table is an XSDT (64-bit physical addresses). We must use the
-                * XSDT if the revision is > 1 and the XSDT pointer is present, as per
-                * the ACPI specification.
+                * RSDP contains an XSDT (64-bit physical addresses). We must use
+                * the XSDT if the revision is > 1 and the XSDT pointer is present,
+                * as per the ACPI specification.
                 */
                address = (acpi_physical_address) rsdp->xsdt_physical_address;
-               table_entry_size = sizeof(u64);
-               rsdt_address = (acpi_physical_address)
-                                       rsdp->rsdt_physical_address;
+               table_entry_size = ACPI_XSDT_ENTRY_SIZE;
        } else {
                /* Root table is an RSDT (32-bit physical addresses) */
 
                address = (acpi_physical_address) rsdp->rsdt_physical_address;
-               table_entry_size = sizeof(u32);
+               table_entry_size = ACPI_RSDT_ENTRY_SIZE;
        }
 
        /*
@@ -483,15 +502,25 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
         */
        acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));
 
-       if (table_entry_size == sizeof(u64)) {
-               if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) {
-                       /* XSDT has NULL entry, RSDT is used */
-                       address = rsdt_address;
-                       table_entry_size = sizeof(u32);
-                       ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, "
-                                       "using RSDT"));
+       /*
+        * If it is present and used, validate the XSDT for access/size
+        * and ensure that all table entries are at least non-NULL
+        */
+       if (table_entry_size == ACPI_XSDT_ENTRY_SIZE) {
+               status = acpi_tb_validate_xsdt(address);
+               if (ACPI_FAILURE(status)) {
+                       ACPI_BIOS_WARNING((AE_INFO,
+                                          "XSDT is invalid (%s), using RSDT",
+                                          acpi_format_exception(status)));
+
+                       /* Fall back to the RSDT */
+
+                       address =
+                           (acpi_physical_address) rsdp->rsdt_physical_address;
+                       table_entry_size = ACPI_RSDT_ENTRY_SIZE;
                }
        }
+
        /* Map the RSDT/XSDT table header to get the full table length */
 
        table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
@@ -501,12 +530,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
 
        acpi_tb_print_table_header(address, table);
 
-       /* Get the length of the full table, verify length and map entire table */
-
+       /*
+        * Validate length of the table, and map entire table.
+        * Minimum length table must contain at least one entry.
+        */
        length = table->length;
        acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
 
-       if (length < sizeof(struct acpi_table_header)) {
+       if (length < (sizeof(struct acpi_table_header) + table_entry_size)) {
                ACPI_BIOS_ERROR((AE_INFO,
                                 "Invalid table length 0x%X in RSDT/XSDT",
                                 length));
@@ -526,22 +557,21 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
                return_ACPI_STATUS(status);
        }
 
-       /* Calculate the number of tables described in the root table */
+       /* Get the number of entries and pointer to first entry */
 
        table_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
                            table_entry_size);
+       table_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));
+
        /*
         * First two entries in the table array are reserved for the DSDT
         * and FACS, which are not actually present in the RSDT/XSDT - they
         * come from the FADT
         */
-       table_entry =
-           ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
        acpi_gbl_root_table_list.current_table_count = 2;
 
-       /*
-        * Initialize the root table array from the RSDT/XSDT
-        */
+       /* Initialize the root table array from the RSDT/XSDT */
+
        for (i = 0; i < table_count; i++) {
                if (acpi_gbl_root_table_list.current_table_count >=
                    acpi_gbl_root_table_list.max_table_count) {
@@ -584,7 +614,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
                acpi_tb_install_table(acpi_gbl_root_table_list.tables[i].
                                      address, NULL, i);
 
-               /* Special case for FADT - get the DSDT and FACS */
+               /* Special case for FADT - validate it then get the DSDT and FACS */
 
                if (ACPI_COMPARE_NAME
                    (&acpi_gbl_root_table_list.tables[i].signature,
index e0a2e2779c2ed8f8877310e07e6379e8efad0faf..2c2b6ae5dfc4ab1fb3dbd20adc670f7214a4a7ed 100644 (file)
@@ -224,10 +224,11 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
 
        while (range_info) {
                /*
-                * Check if the requested Address/Length overlaps this address_range.
-                * Four cases to consider:
+                * Check if the requested address/length overlaps this
+                * address range. There are four cases to consider:
                 *
-                * 1) Input address/length is contained completely in the address range
+                * 1) Input address/length is contained completely in the
+                *    address range
                 * 2) Input address/length overlaps range at the range start
                 * 3) Input address/length overlaps range at the range end
                 * 4) Input address/length completely encompasses the range
@@ -244,11 +245,17 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
                                                                  region_node);
 
                                ACPI_WARNING((AE_INFO,
-                                             "0x%p-0x%p %s conflicts with Region %s %d",
+                                             "%s range 0x%p-0x%p conflicts with OpRegion 0x%p-0x%p (%s)",
+                                             acpi_ut_get_region_name(space_id),
                                              ACPI_CAST_PTR(void, address),
                                              ACPI_CAST_PTR(void, end_address),
-                                             acpi_ut_get_region_name(space_id),
-                                             pathname, overlap_count));
+                                             ACPI_CAST_PTR(void,
+                                                           range_info->
+                                                           start_address),
+                                             ACPI_CAST_PTR(void,
+                                                           range_info->
+                                                           end_address),
+                                             pathname));
                                ACPI_FREE(pathname);
                        }
                }
index 814267f52715a406540cebe3fad946cca5f652bc..1851762fc5b522371cbde01980956457ed91c37d 100644 (file)
@@ -302,9 +302,13 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
                return (AE_BUFFER_OVERFLOW);
 
        case ACPI_ALLOCATE_BUFFER:
-
-               /* Allocate a new buffer */
-
+               /*
+                * Allocate a new buffer. We directectly call acpi_os_allocate here to
+                * purposefully bypass the (optionally enabled) internal allocation
+                * tracking mechanism since we only want to track internal
+                * allocations. Note: The caller should use acpi_os_free to free this
+                * buffer created via ACPI_ALLOCATE_BUFFER.
+                */
                buffer->pointer = acpi_os_allocate(required_length);
                break;
 
index 366bfec4b77027405635d1a10d99053d981a42d0..cacd2fd9e665592ac64241be9fc6f4afd2cdc100 100644 (file)
@@ -248,12 +248,12 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
        ACPI_FUNCTION_NAME(os_acquire_object);
 
        if (!cache) {
-               return (NULL);
+               return_PTR(NULL);
        }
 
        status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
        if (ACPI_FAILURE(status)) {
-               return (NULL);
+               return_PTR(NULL);
        }
 
        ACPI_MEM_TRACKING(cache->requests++);
@@ -276,7 +276,7 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
 
                status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
                if (ACPI_FAILURE(status)) {
-                       return (NULL);
+                       return_PTR(NULL);
                }
 
                /* Clear (zero) the previously used Object */
@@ -299,15 +299,15 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
 
                status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
                if (ACPI_FAILURE(status)) {
-                       return (NULL);
+                       return_PTR(NULL);
                }
 
                object = ACPI_ALLOCATE_ZEROED(cache->object_size);
                if (!object) {
-                       return (NULL);
+                       return_PTR(NULL);
                }
        }
 
-       return (object);
+       return_PTR(object);
 }
 #endif                         /* ACPI_USE_LOCAL_CACHE */
index 03ae8affe48f097b1aae7346edd25a165f23186a..d971c8631263b3dd8f0b9ec05269122b78c24391 100644 (file)
@@ -194,9 +194,9 @@ acpi_debug_print(u32 requested_debug_level,
         */
        acpi_os_printf("%9s-%04ld ", module_name, line_number);
 
-#ifdef ACPI_EXEC_APP
+#ifdef ACPI_APPLICATION
        /*
-        * For acpi_exec only, emit the thread ID and nesting level.
+        * For acpi_exec/iASL only, emit the thread ID and nesting level.
         * Note: nesting level is really only useful during a single-thread
         * execution. Otherwise, multiple threads will keep resetting the
         * level.
index 81f9a958445189b84cad67f491fb5b5c466a9559..030cb0dc673c881dadcb6f62980869e985c16d61 100644 (file)
@@ -388,11 +388,7 @@ acpi_status acpi_ut_init_globals(void)
 /* Public globals */
 
 ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
-
 ACPI_EXPORT_SYMBOL(acpi_dbg_level)
-
 ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
-
 ACPI_EXPORT_SYMBOL(acpi_gpe_count)
-
 ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)
index 75efea0539c1d224376fbf079c4f22e672a633ff..246ef68681f4a4c866bcc28388cf3d383b819b32 100644 (file)
@@ -122,8 +122,16 @@ acpi_status __init acpi_initialize_subsystem(void)
 
        /* If configured, initialize the AML debugger */
 
-       ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
-       return_ACPI_STATUS(status);
+#ifdef ACPI_DEBUGGER
+       status = acpi_db_initialize();
+       if (ACPI_FAILURE(status)) {
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "During Debugger initialization"));
+               return_ACPI_STATUS(status);
+       }
+#endif
+
+       return_ACPI_STATUS(AE_OK);
 }
 
 ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)
index 6d2c49b86b7fa82434bdb0b2ce1906c95dce00ca..0760b75f79cc0a6c9c75ab627197f98c55eed268 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/acpi.h>
-#include <linux/acpi_io.h>
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/kref.h>
index 21ba34a73883d4cad91406659bbe27f80b788bdb..e5bcd919d4e6922d9fc7b87d42d949adb07826cf 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <linux/cper.h>
 #include <linux/acpi.h>
-#include <linux/acpi_io.h>
 
 struct apei_exec_context;
 
index fb57d03e698bd3b7ae2d4194d69dc3478ca09025..ca0c6d7ec0d4181cfdd3fa9b91547a84cd545e2f 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/nmi.h>
 #include <linux/delay.h>
 #include <linux/mm.h>
-#include <acpi/acpi.h>
 
 #include "apei-internal.h"
 
index a30bc313787be65523797da950f3982e13844c35..694c486a12ed1589456d897cd18218595800ecf3 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/acpi.h>
-#include <linux/acpi_io.h>
 #include <linux/io.h>
 #include <linux/interrupt.h>
 #include <linux/timer.h>
index 5876a49dfd386a4653325d99fcc69aa8452b12e1..470e7542bf31a3c2d571385e9b418de0a28eb140 100644 (file)
@@ -36,8 +36,7 @@
 #include <linux/suspend.h>
 #include <asm/unaligned.h>
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <linux/power_supply.h>
 
 #define PREFIX "ACPI: "
index 078c4f7fe2dd97c42d3e13ea11ebde804e3ae4f0..10e4964d051a9c295e6185db1cfebe20b0ce5a9d 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
 #include <linux/dmi.h>
 
 #include "internal.h"
@@ -323,6 +322,56 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
                     DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"),
                },
        },
+       {
+       .callback = dmi_disable_osi_win8,
+       .ident = "HP ProBook 2013 models",
+       .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP ProBook "),
+                    DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
+               },
+       },
+       {
+       .callback = dmi_disable_osi_win8,
+       .ident = "HP EliteBook 2013 models",
+       .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook "),
+                    DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
+               },
+       },
+       {
+       .callback = dmi_disable_osi_win8,
+       .ident = "HP ZBook 14",
+       .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 14"),
+               },
+       },
+       {
+       .callback = dmi_disable_osi_win8,
+       .ident = "HP ZBook 15",
+       .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 15"),
+               },
+       },
+       {
+       .callback = dmi_disable_osi_win8,
+       .ident = "HP ZBook 17",
+       .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 17"),
+               },
+       },
+       {
+       .callback = dmi_disable_osi_win8,
+       .ident = "HP EliteBook 8780w",
+       .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8780w"),
+               },
+       },
 
        /*
         * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
index 0710004055c809f3059cde2337373503666fd96f..384da5ab595573a0daf9faf22fa3815889fadcb8 100644 (file)
@@ -37,8 +37,6 @@
 #include <asm/mpspec.h>
 #endif
 #include <linux/pci.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
 #include <acpi/apei.h>
 #include <linux/dmi.h>
 #include <linux/suspend.h>
@@ -52,9 +50,6 @@ struct acpi_device *acpi_root;
 struct proc_dir_entry *acpi_root_dir;
 EXPORT_SYMBOL(acpi_root_dir);
 
-#define STRUCT_TO_INT(s)       (*((int*)&s))
-
-
 #ifdef CONFIG_X86
 static int set_copy_dsdt(const struct dmi_system_id *id)
 {
@@ -115,18 +110,16 @@ int acpi_bus_get_status(struct acpi_device *device)
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
-       STRUCT_TO_INT(device->status) = (int) sta;
+       acpi_set_device_status(device, sta);
 
        if (device->status.functional && !device->status.present) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
                       "functional but not present;\n",
-                       device->pnp.bus_id,
-                       (u32) STRUCT_TO_INT(device->status)));
+                       device->pnp.bus_id, (u32)sta));
        }
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
-                         device->pnp.bus_id,
-                         (u32) STRUCT_TO_INT(device->status)));
+                         device->pnp.bus_id, (u32)sta));
        return 0;
 }
 EXPORT_SYMBOL(acpi_bus_get_status);
@@ -339,58 +332,6 @@ static void acpi_bus_osc_support(void)
                              Notification Handling
    -------------------------------------------------------------------------- */
 
-static void acpi_bus_check_device(acpi_handle handle)
-{
-       struct acpi_device *device;
-       acpi_status status;
-       struct acpi_device_status old_status;
-
-       if (acpi_bus_get_device(handle, &device))
-               return;
-       if (!device)
-               return;
-
-       old_status = device->status;
-
-       /*
-        * Make sure this device's parent is present before we go about
-        * messing with the device.
-        */
-       if (device->parent && !device->parent->status.present) {
-               device->status = device->parent->status;
-               return;
-       }
-
-       status = acpi_bus_get_status(device);
-       if (ACPI_FAILURE(status))
-               return;
-
-       if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
-               return;
-
-       /*
-        * Device Insertion/Removal
-        */
-       if ((device->status.present) && !(old_status.present)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
-               /* TBD: Handle device insertion */
-       } else if (!(device->status.present) && (old_status.present)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
-               /* TBD: Handle device removal */
-       }
-}
-
-static void acpi_bus_check_scope(acpi_handle handle)
-{
-       /* Status Change? */
-       acpi_bus_check_device(handle);
-
-       /*
-        * TBD: Enumerate child devices within this device's scope and
-        *       run acpi_bus_check_device()'s on them.
-        */
-}
-
 /**
  * acpi_bus_notify
  * ---------------
@@ -407,19 +348,11 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
        switch (type) {
 
        case ACPI_NOTIFY_BUS_CHECK:
-               acpi_bus_check_scope(handle);
-               /*
-                * TBD: We'll need to outsource certain events to non-ACPI
-                *      drivers via the device manager (device.c).
-                */
+               /* TBD */
                break;
 
        case ACPI_NOTIFY_DEVICE_CHECK:
-               acpi_bus_check_device(handle);
-               /*
-                * TBD: We'll need to outsource certain events to non-ACPI
-                *      drivers via the device manager (device.c).
-                */
+               /* TBD */
                break;
 
        case ACPI_NOTIFY_DEVICE_WAKE:
index c971929d75c20090b69afda2ab65b073bc95b140..11c11f6b8fa1453a4a28c3931f0cf8618750fecc 100644 (file)
@@ -31,8 +31,7 @@
 #include <linux/seq_file.h>
 #include <linux/input.h>
 #include <linux/slab.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <acpi/button.h>
 
 #define PREFIX "ACPI: "
@@ -101,7 +100,6 @@ struct acpi_button {
        struct input_dev *input;
        char phys[32];                  /* for input device */
        unsigned long pushed;
-       bool wakeup_enabled;
 };
 
 static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier);
@@ -407,16 +405,6 @@ static int acpi_button_add(struct acpi_device *device)
                lid_device = device;
        }
 
-       if (device->wakeup.flags.valid) {
-               /* Button's GPE is run-wake GPE */
-               acpi_enable_gpe(device->wakeup.gpe_device,
-                               device->wakeup.gpe_number);
-               if (!device_may_wakeup(&device->dev)) {
-                       device_set_wakeup_enable(&device->dev, true);
-                       button->wakeup_enabled = true;
-               }
-       }
-
        printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device));
        return 0;
 
@@ -433,13 +421,6 @@ static int acpi_button_remove(struct acpi_device *device)
 {
        struct acpi_button *button = acpi_driver_data(device);
 
-       if (device->wakeup.flags.valid) {
-               acpi_disable_gpe(device->wakeup.gpe_device,
-                               device->wakeup.gpe_number);
-               if (button->wakeup_enabled)
-                       device_set_wakeup_enable(&device->dev, false);
-       }
-
        acpi_button_remove_fs(device);
        input_unregister_device(button->input);
        kfree(button);
index e2315166765501b479259269ea5888d44042868b..0b6ae6eb5c4a8f3dad1a40ec4c2f9f6928322b09 100644 (file)
@@ -27,8 +27,7 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 #include <linux/acpi.h>
-
-#include "internal.h"
+#include <linux/container.h>
 
 #include "internal.h"
 
@@ -44,19 +43,65 @@ static const struct acpi_device_id container_device_ids[] = {
        {"", 0},
 };
 
-static int container_device_attach(struct acpi_device *device,
+static int acpi_container_offline(struct container_dev *cdev)
+{
+       struct acpi_device *adev = ACPI_COMPANION(&cdev->dev);
+       struct acpi_device *child;
+
+       /* Check all of the dependent devices' physical companions. */
+       list_for_each_entry(child, &adev->children, node)
+               if (!acpi_scan_is_offline(child, false))
+                       return -EBUSY;
+
+       return 0;
+}
+
+static void acpi_container_release(struct device *dev)
+{
+       kfree(to_container_dev(dev));
+}
+
+static int container_device_attach(struct acpi_device *adev,
                                   const struct acpi_device_id *not_used)
 {
-       /* This is necessary for container hotplug to work. */
+       struct container_dev *cdev;
+       struct device *dev;
+       int ret;
+
+       cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
+       if (!cdev)
+               return -ENOMEM;
+
+       cdev->offline = acpi_container_offline;
+       dev = &cdev->dev;
+       dev->bus = &container_subsys;
+       dev_set_name(dev, "%s", dev_name(&adev->dev));
+       ACPI_COMPANION_SET(dev, adev);
+       dev->release = acpi_container_release;
+       ret = device_register(dev);
+       if (ret)
+               return ret;
+
+       adev->driver_data = dev;
        return 1;
 }
 
+static void container_device_detach(struct acpi_device *adev)
+{
+       struct device *dev = acpi_driver_data(adev);
+
+       adev->driver_data = NULL;
+       if (dev)
+               device_unregister(dev);
+}
+
 static struct acpi_scan_handler container_handler = {
        .ids = container_device_ids,
        .attach = container_device_attach,
+       .detach = container_device_detach,
        .hotplug = {
                .enabled = true,
-               .mode = AHM_CONTAINER,
+               .demand_offline = true,
        },
 };
 
index 12b62f2cdb3f0ad507748e9280a961eb1d7667b3..c68e72414a67a9b00231b095335945d5cdd2f31e 100644 (file)
@@ -7,7 +7,7 @@
 #include <linux/kernel.h>
 #include <linux/uaccess.h>
 #include <linux/debugfs.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 #include "internal.h"
 
index b55d6a20dc0eda9a78419f29bb8eb229cc157930..6b1919f6bd8212248f8a7399c21f73b1303a254e 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/export.h>
 #include <linux/init.h>
 #include <linux/debugfs.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 #define _COMPONENT             ACPI_SYSTEM_COMPONENT
 ACPI_MODULE_NAME("debugfs");
index b3480cf7db1a1d1eba0e8d884cb456f92b76b660..d49f1e46470370908d72b6efb7677d70f80ded98 100644 (file)
@@ -256,6 +256,8 @@ int acpi_bus_init_power(struct acpi_device *device)
                return -EINVAL;
 
        device->power.state = ACPI_STATE_UNKNOWN;
+       if (!acpi_device_is_present(device))
+               return 0;
 
        result = acpi_device_get_power(device, &state);
        if (result)
@@ -302,15 +304,18 @@ int acpi_device_fix_up_power(struct acpi_device *device)
        return ret;
 }
 
-int acpi_bus_update_power(acpi_handle handle, int *state_p)
+int acpi_device_update_power(struct acpi_device *device, int *state_p)
 {
-       struct acpi_device *device;
        int state;
        int result;
 
-       result = acpi_bus_get_device(handle, &device);
-       if (result)
+       if (device->power.state == ACPI_STATE_UNKNOWN) {
+               result = acpi_bus_init_power(device);
+               if (!result && state_p)
+                       *state_p = device->power.state;
+
                return result;
+       }
 
        result = acpi_device_get_power(device, &state);
        if (result)
@@ -338,6 +343,15 @@ int acpi_bus_update_power(acpi_handle handle, int *state_p)
 
        return 0;
 }
+
+int acpi_bus_update_power(acpi_handle handle, int *state_p)
+{
+       struct acpi_device *device;
+       int result;
+
+       result = acpi_bus_get_device(handle, &device);
+       return result ? result : acpi_device_update_power(device, state_p);
+}
 EXPORT_SYMBOL_GPL(acpi_bus_update_power);
 
 bool acpi_bus_power_manageable(acpi_handle handle)
index dcd73ccb514c601df4efdee7043f2a7cffeb718e..c431c88faaffa1f46f4d1e1b4de042f3314a2b9f 100644 (file)
@@ -32,8 +32,8 @@
 #include <linux/jiffies.h>
 #include <linux/stddef.h>
 #include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+
+#include "internal.h"
 
 #define PREFIX "ACPI: "
 
@@ -323,14 +323,11 @@ static int dock_present(struct dock_station *ds)
  */
 static void dock_create_acpi_device(acpi_handle handle)
 {
-       struct acpi_device *device;
+       struct acpi_device *device = NULL;
        int ret;
 
-       if (acpi_bus_get_device(handle, &device)) {
-               /*
-                * no device created for this object,
-                * so we should create one.
-                */
+       acpi_bus_get_device(handle, &device);
+       if (!acpi_device_enumerated(device)) {
                ret = acpi_bus_scan(handle);
                if (ret)
                        pr_debug("error adding bus, %x\n", -ret);
@@ -898,9 +895,6 @@ find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
 
 void __init acpi_dock_init(void)
 {
-       if (acpi_disabled)
-               return;
-
        /* look for dock stations and bays */
        acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
                ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL);
index ba5b56db9d27c7fafa3b19c6d1f5d2549308aea6..959d41acc108a847308773f754fdb4fff3b1fd26 100644 (file)
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
-#include <asm/io.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <linux/dmi.h>
+#include <asm/io.h>
 
 #include "internal.h"
 
@@ -91,10 +90,6 @@ static unsigned int ec_storm_threshold  __read_mostly = 8;
 module_param(ec_storm_threshold, uint, 0644);
 MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm");
 
-/* If we find an EC via the ECDT, we need to keep a ptr to its context */
-/* External interfaces use first EC only, so remember */
-typedef int (*acpi_ec_query_func) (void *data);
-
 struct acpi_ec_query_handler {
        struct list_head node;
        acpi_ec_query_func func;
@@ -387,27 +382,6 @@ static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
        return acpi_ec_transaction(ec, &t);
 }
 
-/*
- * Externally callable EC access functions. For now, assume 1 EC only
- */
-int ec_burst_enable(void)
-{
-       if (!first_ec)
-               return -ENODEV;
-       return acpi_ec_burst_enable(first_ec);
-}
-
-EXPORT_SYMBOL(ec_burst_enable);
-
-int ec_burst_disable(void)
-{
-       if (!first_ec)
-               return -ENODEV;
-       return acpi_ec_burst_disable(first_ec);
-}
-
-EXPORT_SYMBOL(ec_burst_disable);
-
 int ec_read(u8 addr, u8 *val)
 {
        int err;
@@ -779,9 +753,9 @@ static int ec_install_handlers(struct acpi_ec *ec)
                        pr_err("Fail in evaluating the _REG object"
                                " of EC device. Broken bios is suspected.\n");
                } else {
+                       acpi_disable_gpe(NULL, ec->gpe);
                        acpi_remove_gpe_handler(NULL, ec->gpe,
                                &acpi_ec_gpe_handler);
-                       acpi_disable_gpe(NULL, ec->gpe);
                        return -ENODEV;
                }
        }
index 4e7b798900f21df7bf60c75d2132e2ad86e89e38..b4c216bab22b8a8836c2833e8f58eaf35d2f7311 100644 (file)
@@ -105,7 +105,7 @@ static const struct file_operations acpi_ec_io_ops = {
        .llseek = default_llseek,
 };
 
-int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
+static int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
 {
        struct dentry *dev_dir;
        char name[64];
index cae3b387b867a99ab7013cfc2b731b2125abc961..ef2d730734dcca90a9690e48021d1d9a1d925791 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/gfp.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
 
index ba3da88cee45a20479df62023ee560aa422dff22..1fb62900f32a9c57d329fd3e5480bc0dc7c305b8 100644 (file)
@@ -29,8 +29,7 @@
 #include <linux/types.h>
 #include <asm/uaccess.h>
 #include <linux/thermal.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 #define PREFIX "ACPI: "
 
index a22a295edb692347f16066bff26d145973ab2523..0c789224d40d4da34aa3c7f1a9314bb12ba7b459 100644 (file)
@@ -37,7 +37,7 @@ int register_acpi_bus_type(struct acpi_bus_type *type)
 {
        if (acpi_disabled)
                return -ENODEV;
-       if (type && type->match && type->find_device) {
+       if (type && type->match && type->find_companion) {
                down_write(&bus_type_sem);
                list_add_tail(&type->list, &bus_type_list);
                up_write(&bus_type_sem);
@@ -82,109 +82,74 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
 #define FIND_CHILD_MIN_SCORE   1
 #define FIND_CHILD_MAX_SCORE   2
 
-static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used,
-                                 void *not_used, void **ret_p)
-{
-       struct acpi_device *adev = NULL;
-
-       acpi_bus_get_device(handle, &adev);
-       if (adev) {
-               *ret_p = handle;
-               return AE_CTRL_TERMINATE;
-       }
-       return AE_OK;
-}
-
-static int do_find_child_checks(acpi_handle handle, bool is_bridge)
+static int find_child_checks(struct acpi_device *adev, bool check_children)
 {
        bool sta_present = true;
        unsigned long long sta;
        acpi_status status;
 
-       status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
+       status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
        if (status == AE_NOT_FOUND)
                sta_present = false;
        else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
                return -ENODEV;
 
-       if (is_bridge) {
-               void *test = NULL;
+       if (check_children && list_empty(&adev->children))
+               return -ENODEV;
 
-               /* Check if this object has at least one child device. */
-               acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
-                                   acpi_dev_present, NULL, NULL, &test);
-               if (!test)
-                       return -ENODEV;
-       }
        return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
 }
 
-struct find_child_context {
-       u64 addr;
-       bool is_bridge;
-       acpi_handle ret;
-       int ret_score;
-};
-
-static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used,
-                                void *data, void **not_used)
-{
-       struct find_child_context *context = data;
-       unsigned long long addr;
-       acpi_status status;
-       int score;
-
-       status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
-       if (ACPI_FAILURE(status) || addr != context->addr)
-               return AE_OK;
-
-       if (!context->ret) {
-               /* This is the first matching object.  Save its handle. */
-               context->ret = handle;
-               return AE_OK;
-       }
-       /*
-        * There is more than one matching object with the same _ADR value.
-        * That really is unexpected, so we are kind of beyond the scope of the
-        * spec here.  We have to choose which one to return, though.
-        *
-        * First, check if the previously found object is good enough and return
-        * its handle if so.  Second, check the same for the object that we've
-        * just found.
-        */
-       if (!context->ret_score) {
-               score = do_find_child_checks(context->ret, context->is_bridge);
-               if (score == FIND_CHILD_MAX_SCORE)
-                       return AE_CTRL_TERMINATE;
-               else
-                       context->ret_score = score;
-       }
-       score = do_find_child_checks(handle, context->is_bridge);
-       if (score == FIND_CHILD_MAX_SCORE) {
-               context->ret = handle;
-               return AE_CTRL_TERMINATE;
-       } else if (score > context->ret_score) {
-               context->ret = handle;
-               context->ret_score = score;
-       }
-       return AE_OK;
-}
-
-acpi_handle acpi_find_child(acpi_handle parent, u64 addr, bool is_bridge)
+struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
+                                          u64 address, bool check_children)
 {
-       if (parent) {
-               struct find_child_context context = {
-                       .addr = addr,
-                       .is_bridge = is_bridge,
-               };
-
-               acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, do_find_child,
-                                   NULL, &context, NULL);
-               return context.ret;
+       struct acpi_device *adev, *ret = NULL;
+       int ret_score = 0;
+
+       if (!parent)
+               return NULL;
+
+       list_for_each_entry(adev, &parent->children, node) {
+               unsigned long long addr;
+               acpi_status status;
+               int score;
+
+               status = acpi_evaluate_integer(adev->handle, METHOD_NAME__ADR,
+                                              NULL, &addr);
+               if (ACPI_FAILURE(status) || addr != address)
+                       continue;
+
+               if (!ret) {
+                       /* This is the first matching object.  Save it. */
+                       ret = adev;
+                       continue;
+               }
+               /*
+                * There is more than one matching device object with the same
+                * _ADR value.  That really is unexpected, so we are kind of
+                * beyond the scope of the spec here.  We have to choose which
+                * one to return, though.
+                *
+                * First, check if the previously found object is good enough
+                * and return it if so.  Second, do the same for the object that
+                * we've just found.
+                */
+               if (!ret_score) {
+                       ret_score = find_child_checks(ret, check_children);
+                       if (ret_score == FIND_CHILD_MAX_SCORE)
+                               return ret;
+               }
+               score = find_child_checks(adev, check_children);
+               if (score == FIND_CHILD_MAX_SCORE) {
+                       return adev;
+               } else if (score > ret_score) {
+                       ret = adev;
+                       ret_score = score;
+               }
        }
-       return NULL;
+       return ret;
 }
-EXPORT_SYMBOL_GPL(acpi_find_child);
+EXPORT_SYMBOL_GPL(acpi_find_child_device);
 
 static void acpi_physnode_link_name(char *buf, unsigned int node_id)
 {
@@ -195,9 +160,8 @@ static void acpi_physnode_link_name(char *buf, unsigned int node_id)
                strcpy(buf, PHYSICAL_NODE_STRING);
 }
 
-int acpi_bind_one(struct device *dev, acpi_handle handle)
+int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
 {
-       struct acpi_device *acpi_dev = NULL;
        struct acpi_device_physical_node *physical_node, *pn;
        char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
        struct list_head *physnode_list;
@@ -205,14 +169,12 @@ int acpi_bind_one(struct device *dev, acpi_handle handle)
        int retval = -EINVAL;
 
        if (ACPI_COMPANION(dev)) {
-               if (handle) {
+               if (acpi_dev) {
                        dev_warn(dev, "ACPI companion already set\n");
                        return -EINVAL;
                } else {
                        acpi_dev = ACPI_COMPANION(dev);
                }
-       } else {
-               acpi_bus_get_device(handle, &acpi_dev);
        }
        if (!acpi_dev)
                return -EINVAL;
@@ -322,29 +284,22 @@ int acpi_unbind_one(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(acpi_unbind_one);
 
-void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr)
-{
-       struct acpi_device *adev;
-
-       if (!acpi_bus_get_device(acpi_get_child(parent, addr), &adev))
-               ACPI_COMPANION_SET(dev, adev);
-}
-EXPORT_SYMBOL_GPL(acpi_preset_companion);
-
 static int acpi_platform_notify(struct device *dev)
 {
        struct acpi_bus_type *type = acpi_get_bus_type(dev);
-       acpi_handle handle;
        int ret;
 
        ret = acpi_bind_one(dev, NULL);
        if (ret && type) {
-               ret = type->find_device(dev, &handle);
-               if (ret) {
+               struct acpi_device *adev;
+
+               adev = type->find_companion(dev);
+               if (!adev) {
                        DBG("Unable to get handle for %s\n", dev_name(dev));
+                       ret = -ENODEV;
                        goto out;
                }
-               ret = acpi_bind_one(dev, handle);
+               ret = acpi_bind_one(dev, adev);
                if (ret)
                        goto out;
        }
index 13b1d39d7cdf57c463534c3a29cfd797e22abfe0..aafe3ca829c28b4a22a8f2a708df6d69093349e9 100644 (file)
@@ -25,8 +25,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
 #include <acpi/hed.h>
 
 static struct acpi_device_id acpi_hed_ids[] = {
index a29739c0ba790af9c967efc29ef6907bf06b63d6..dedbb2d802f1a87bd5a3c288067124514cad9824 100644 (file)
@@ -28,7 +28,6 @@ int init_acpi_device_notify(void);
 int acpi_scan_init(void);
 void acpi_pci_root_init(void);
 void acpi_pci_link_init(void);
-void acpi_pci_root_hp_init(void);
 void acpi_processor_init(void);
 void acpi_platform_init(void);
 int acpi_sysfs_init(void);
@@ -73,6 +72,9 @@ void acpi_lpss_init(void);
 static inline void acpi_lpss_init(void) {}
 #endif
 
+bool acpi_queue_hotplug_work(struct work_struct *work);
+bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
+
 /* --------------------------------------------------------------------------
                      Device Node Initialization / Removal
    -------------------------------------------------------------------------- */
@@ -85,9 +87,9 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
                             int type, unsigned long long sta);
 void acpi_device_add_finalize(struct acpi_device *device);
 void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
-int acpi_bind_one(struct device *dev, acpi_handle handle);
+int acpi_bind_one(struct device *dev, struct acpi_device *adev);
 int acpi_unbind_one(struct device *dev);
-void acpi_bus_device_eject(void *data, u32 ost_src);
+bool acpi_device_is_present(struct acpi_device *adev);
 
 /* --------------------------------------------------------------------------
                                   Power Resource
@@ -105,6 +107,8 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
 int acpi_power_on_resources(struct acpi_device *device, int state);
 int acpi_power_transition(struct acpi_device *device, int state);
 
+int acpi_device_update_power(struct acpi_device *device, int *state_p);
+
 int acpi_wakeup_device_init(void);
 void acpi_early_processor_set_pdc(void);
 
@@ -127,12 +131,21 @@ struct acpi_ec {
 
 extern struct acpi_ec *first_ec;
 
+/* If we find an EC via the ECDT, we need to keep a ptr to its context */
+/* External interfaces use first EC only, so remember */
+typedef int (*acpi_ec_query_func) (void *data);
+
 int acpi_ec_init(void);
 int acpi_ec_ecdt_probe(void);
 int acpi_boot_ec_enable(void);
 void acpi_ec_block_transactions(void);
 void acpi_ec_unblock_transactions(void);
 void acpi_ec_unblock_transactions_early(void);
+int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
+                             acpi_handle handle, acpi_ec_query_func func,
+                             void *data);
+void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
+
 
 /*--------------------------------------------------------------------------
                                   Suspend/Resume
index a2343a1d9e0b1a0e77f3b7a7caf6676499c5f989..9e6816ef280ab7a5def6586cfabd3f60b7cd0ccb 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/errno.h>
 #include <linux/acpi.h>
 #include <linux/numa.h>
-#include <acpi/acpi_bus.h>
 
 #define PREFIX "ACPI: "
 
index 386a9fe497b451d0da6ebed2bc4b6f1a2dacda71..de4fe03873c53e1f89203692dc78d5b703220df7 100644 (file)
@@ -12,7 +12,8 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
-#include <linux/acpi_io.h>
+
+#include "internal.h"
 
 /* ACPI NVS regions, APEI may use it */
 
index 54a20ff4b864d90881cf41be6fbebd33de1c32a9..fc1aa7909690c3ef148930a4a96080d2bcaaa155 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/workqueue.h>
 #include <linux/nmi.h>
 #include <linux/acpi.h>
-#include <linux/acpi_io.h>
 #include <linux/efi.h>
 #include <linux/ioport.h>
 #include <linux/list.h>
@@ -49,9 +48,6 @@
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
-#include <acpi/acpi.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/processor.h>
 #include "internal.h"
 
 #define _COMPONENT             ACPI_OS_SERVICES
@@ -544,7 +540,7 @@ static u64 acpi_tables_addr;
 static int all_tables_size;
 
 /* Copied from acpica/tbutils.c:acpi_tb_checksum() */
-u8 __init acpi_table_checksum(u8 *buffer, u32 length)
+static u8 __init acpi_table_checksum(u8 *buffer, u32 length)
 {
        u8 sum = 0;
        u8 *end = buffer + length;
@@ -1215,6 +1211,10 @@ acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src)
        return AE_OK;
 }
 
+bool acpi_queue_hotplug_work(struct work_struct *work)
+{
+       return queue_work(kacpi_hotplug_wq, work);
+}
 
 acpi_status
 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
@@ -1282,7 +1282,7 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
                jiffies = MAX_SCHEDULE_TIMEOUT;
        else
                jiffies = msecs_to_jiffies(timeout);
-       
+
        ret = down_timeout(sem, jiffies);
        if (ret)
                status = AE_TIME;
@@ -1794,7 +1794,7 @@ acpi_status __init acpi_os_initialize1(void)
 {
        kacpid_wq = alloc_workqueue("kacpid", 0, 1);
        kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1);
-       kacpi_hotplug_wq = alloc_workqueue("kacpi_hotplug", 0, 1);
+       kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0);
        BUG_ON(!kacpid_wq);
        BUG_ON(!kacpi_notify_wq);
        BUG_ON(!kacpi_hotplug_wq);
index 41c5e1b799ef938ff1eed92e4cf48a7c7677f8bd..52d45ea2bc4f63efcfb7e8912b087b1a568d49cc 100644 (file)
@@ -37,8 +37,6 @@
 #include <linux/pci.h>
 #include <linux/acpi.h>
 #include <linux/slab.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
 
 #define PREFIX "ACPI: "
 
index 2652a614deebe8062c71bb4e3c7f26fe8d315a45..9418c7a1f78665b32c980f815e789f152e973cb5 100644 (file)
@@ -39,9 +39,9 @@
 #include <linux/pci.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <linux/acpi.h>
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include "internal.h"
 
 #define PREFIX "ACPI: "
 
index 20360e480bd8d81c0070cc25b5cd2cddd05d0447..afafee56cf8be2b7d1dfe5d2de91180ba30a370c 100644 (file)
@@ -35,9 +35,7 @@
 #include <linux/pci-aspm.h>
 #include <linux/acpi.h>
 #include <linux/slab.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/apei.h>
+#include <acpi/apei.h> /* for acpi_hest_init() */
 
 #include "internal.h"
 
@@ -51,6 +49,12 @@ static int acpi_pci_root_add(struct acpi_device *device,
                             const struct acpi_device_id *not_used);
 static void acpi_pci_root_remove(struct acpi_device *device);
 
+static int acpi_pci_root_scan_dependent(struct acpi_device *adev)
+{
+       acpiphp_check_host_bridge(adev->handle);
+       return 0;
+}
+
 #define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \
                                | OSC_PCI_ASPM_SUPPORT \
                                | OSC_PCI_CLOCK_PM_SUPPORT \
@@ -66,7 +70,8 @@ static struct acpi_scan_handler pci_root_handler = {
        .attach = acpi_pci_root_add,
        .detach = acpi_pci_root_remove,
        .hotplug = {
-               .ignore = true,
+               .enabled = true,
+               .scan_dependent = acpi_pci_root_scan_dependent,
        },
 };
 
@@ -624,116 +629,9 @@ static void acpi_pci_root_remove(struct acpi_device *device)
 void __init acpi_pci_root_init(void)
 {
        acpi_hest_init();
-
-       if (!acpi_pci_disabled) {
-               pci_acpi_crs_quirks();
-               acpi_scan_add_handler(&pci_root_handler);
-       }
-}
-/* Support root bridge hotplug */
-
-static void handle_root_bridge_insertion(acpi_handle handle)
-{
-       struct acpi_device *device;
-
-       if (!acpi_bus_get_device(handle, &device)) {
-               dev_printk(KERN_DEBUG, &device->dev,
-                          "acpi device already exists; ignoring notify\n");
+       if (acpi_pci_disabled)
                return;
-       }
-
-       if (acpi_bus_scan(handle))
-               acpi_handle_err(handle, "cannot add bridge to acpi list\n");
-}
-
-static void hotplug_event_root(void *data, u32 type)
-{
-       acpi_handle handle = data;
-       struct acpi_pci_root *root;
-
-       acpi_scan_lock_acquire();
-
-       root = acpi_pci_find_root(handle);
-
-       switch (type) {
-       case ACPI_NOTIFY_BUS_CHECK:
-               /* bus enumerate */
-               acpi_handle_printk(KERN_DEBUG, handle,
-                                  "Bus check notify on %s\n", __func__);
-               if (root)
-                       acpiphp_check_host_bridge(handle);
-               else
-                       handle_root_bridge_insertion(handle);
-
-               break;
-
-       case ACPI_NOTIFY_DEVICE_CHECK:
-               /* device check */
-               acpi_handle_printk(KERN_DEBUG, handle,
-                                  "Device check notify on %s\n", __func__);
-               if (!root)
-                       handle_root_bridge_insertion(handle);
-               break;
-
-       case ACPI_NOTIFY_EJECT_REQUEST:
-               /* request device eject */
-               acpi_handle_printk(KERN_DEBUG, handle,
-                                  "Device eject notify on %s\n", __func__);
-               if (!root)
-                       break;
-
-               get_device(&root->device->dev);
-
-               acpi_scan_lock_release();
-
-               acpi_bus_device_eject(root->device, ACPI_NOTIFY_EJECT_REQUEST);
-               return;
-       default:
-               acpi_handle_warn(handle,
-                                "notify_handler: unknown event type 0x%x\n",
-                                type);
-               break;
-       }
-
-       acpi_scan_lock_release();
-}
-
-static void handle_hotplug_event_root(acpi_handle handle, u32 type,
-                                       void *context)
-{
-       acpi_hotplug_execute(hotplug_event_root, handle, type);
-}
-
-static acpi_status __init
-find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
-{
-       acpi_status status;
-       int *count = (int *)context;
-
-       if (!acpi_is_root_bridge(handle))
-               return AE_OK;
-
-       (*count)++;
-
-       status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
-                                       handle_hotplug_event_root, NULL);
-       if (ACPI_FAILURE(status))
-               acpi_handle_printk(KERN_DEBUG, handle,
-                       "notify handler is not installed, exit status: %u\n",
-                        (unsigned int)status);
-       else
-               acpi_handle_printk(KERN_DEBUG, handle,
-                                  "notify handler is installed\n");
-
-       return AE_OK;
-}
-
-void __init acpi_pci_root_hp_init(void)
-{
-       int num = 0;
-
-       acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-               ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL);
 
-       printk(KERN_DEBUG "Found %d acpi root devices\n", num);
+       pci_acpi_crs_quirks();
+       acpi_scan_add_handler_with_hotplug(&pci_root_handler, "pci_root");
 }
index d678a180ca2aa20cfac20d32460400dc0f05951f..139d9e4793703d0c2e2c88fd7166c89076a1eeee 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/pci.h>
 #include <linux/acpi.h>
 #include <linux/dmi.h>
+#include <linux/pci-acpi.h>
 
 static bool debug;
 static int check_sta_before_sun;
index c2ad391d8041ecb6a354e2df07b9d813d817a744..ad7da686e6e6f8d9745a4edf866e174b99b08538 100644 (file)
@@ -42,8 +42,7 @@
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
 #include <linux/sysfs.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include "sleep.h"
 #include "internal.h"
 
index 6a5b152ad4d070511d08d74439155fa17a83ed8a..50fe34ffe932fbdc9b1e9166c551fb025754853e 100644 (file)
@@ -3,12 +3,11 @@
 #include <linux/export.h>
 #include <linux/suspend.h>
 #include <linux/bcd.h>
+#include <linux/acpi.h>
 #include <asm/uaccess.h>
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-
 #include "sleep.h"
+#include "internal.h"
 
 #define _COMPONENT             ACPI_SYSTEM_COMPONENT
 
index b3171f30b319c1244007e686a0b516833443191d..34e7b3c6a08de157c6c962bd0643ddb67176bd5e 100644 (file)
@@ -10,8 +10,7 @@
 #include <linux/export.h>
 #include <linux/dmi.h>
 #include <linux/slab.h>
-
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <acpi/processor.h>
 
 #include "internal.h"
index 146ab7e2b81d71949908ce43754e7b08bcaee022..c1c35623550fd723e74a63d5abfaea1ef724e3ab 100644 (file)
@@ -224,9 +224,9 @@ static int __acpi_processor_start(struct acpi_device *device)
 
 static int acpi_processor_start(struct device *dev)
 {
-       struct acpi_device *device;
+       struct acpi_device *device = ACPI_COMPANION(dev);
 
-       if (acpi_bus_get_device(ACPI_HANDLE(dev), &device))
+       if (!device)
                return -ENODEV;
 
        return __acpi_processor_start(device);
@@ -234,10 +234,10 @@ static int acpi_processor_start(struct device *dev)
 
 static int acpi_processor_stop(struct device *dev)
 {
-       struct acpi_device *device;
+       struct acpi_device *device = ACPI_COMPANION(dev);
        struct acpi_processor *pr;
 
-       if (acpi_bus_get_device(ACPI_HANDLE(dev), &device))
+       if (!device)
                return 0;
 
        acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
index 644516d9bde6cf18a824d29c3ae1730de30fd1a6..1fc455b8ce17b8211a59660bce381959a6c76067 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/clockchips.h>
 #include <linux/cpuidle.h>
 #include <linux/syscore_ops.h>
+#include <acpi/processor.h>
 
 /*
  * Include the apic definitions for x86 to have the APIC timer related defines
@@ -46,9 +47,6 @@
 #include <asm/apic.h>
 #endif
 
-#include <acpi/acpi_bus.h>
-#include <acpi/processor.h>
-
 #define PREFIX "ACPI: "
 
 #define ACPI_PROCESSOR_CLASS            "processor"
@@ -213,7 +211,7 @@ static int acpi_processor_suspend(void)
 
 static void acpi_processor_resume(void)
 {
-       u32 resumed_bm_rld;
+       u32 resumed_bm_rld = 0;
 
        acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld);
        if (resumed_bm_rld == saved_bm_rld)
@@ -598,7 +596,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
                case ACPI_STATE_C2:
                        if (!cx->address)
                                break;
-                       cx->valid = 1; 
+                       cx->valid = 1;
                        break;
 
                case ACPI_STATE_C3:
@@ -785,6 +783,13 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
        if (unlikely(!pr))
                return -EINVAL;
 
+#ifdef CONFIG_HOTPLUG_CPU
+       if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
+           !pr->flags.has_cst &&
+           !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
+               return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START);
+#endif
+
        if (cx->entry_method == ACPI_CSTATE_FFH) {
                if (current_set_polling_and_test())
                        return -EINVAL;
@@ -831,6 +836,13 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
        if (unlikely(!pr))
                return -EINVAL;
 
+#ifdef CONFIG_HOTPLUG_CPU
+       if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
+           !pr->flags.has_cst &&
+           !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
+               return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START);
+#endif
+
        if (!cx->bm_sts_skip && acpi_idle_bm_check()) {
                if (drv->safe_state_index >= 0) {
                        return drv->states[drv->safe_state_index].enter(dev,
@@ -932,12 +944,6 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
                if (!cx->valid)
                        continue;
 
-#ifdef CONFIG_HOTPLUG_CPU
-               if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
-                   !pr->flags.has_cst &&
-                   !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
-                       continue;
-#endif
                per_cpu(acpi_cstate[count], dev->cpu) = cx;
 
                count++;
@@ -945,8 +951,6 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
                        break;
        }
 
-       dev->state_count = count;
-
        if (!count)
                return -EINVAL;
 
@@ -987,13 +991,6 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
                if (!cx->valid)
                        continue;
 
-#ifdef CONFIG_HOTPLUG_CPU
-               if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
-                   !pr->flags.has_cst &&
-                   !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
-                       continue;
-#endif
-
                state = &drv->states[count];
                snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i);
                strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
index 60a7c28fc1674cc21bc38802fed869dc7daf0608..ff90054f04fdb88e15e1279b23b43d78884596f9 100644 (file)
 #include <linux/init.h>
 #include <linux/cpufreq.h>
 #include <linux/slab.h>
-
+#include <linux/acpi.h>
+#include <acpi/processor.h>
 #ifdef CONFIG_X86
 #include <asm/cpufeature.h>
 #endif
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/processor.h>
-
 #define PREFIX "ACPI: "
 
 #define ACPI_PROCESSOR_CLASS           "processor"
index d1d2e7fb5b30778f26d46ce6e72eecb03350ddfc..e003663b2f8e5346d8862f336e604c8c6bf35035 100644 (file)
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/cpufreq.h>
-
-#include <asm/uaccess.h>
-
-#include <acpi/acpi_bus.h>
+#include <linux/acpi.h>
 #include <acpi/processor.h>
-#include <acpi/acpi_drivers.h>
+#include <asm/uaccess.h>
 
 #define PREFIX "ACPI: "
 
@@ -186,14 +183,14 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
 
 #endif
 
-/* thermal coolign device callbacks */
+/* thermal cooling device callbacks */
 static int acpi_processor_max_state(struct acpi_processor *pr)
 {
        int max_state = 0;
 
        /*
         * There exists four states according to
-        * cpufreq_thermal_reduction_ptg. 0, 1, 2, 3
+        * cpufreq_thermal_reduction_pctg. 0, 1, 2, 3
         */
        max_state += cpufreq_get_max_state(pr->id);
        if (pr->flags.throttling)
index e7dd2c1fee79b4a097f9b3249a9b0bdaeaa2592a..28baa05b8018dd6c6e6e1db93c1a5ceed74d4d74 100644 (file)
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/cpufreq.h>
-
+#include <linux/acpi.h>
+#include <acpi/processor.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/processor.h>
-
 #define PREFIX "ACPI: "
 
 #define ACPI_PROCESSOR_CLASS            "processor"
index b78bc605837e19a8f7461f48a59cdc90d64f5128..26e5b50605230e2e34a46d8118486fb1ba2eb939 100644 (file)
@@ -8,8 +8,7 @@
  * the Free Software Foundation version 2.
  */
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <linux/wait.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
index fd39459926b1564c2faa3d367a4dbbf05aa60031..c0f57ff150244d309b84891f6c5425027e7ee8ee 100644 (file)
 #include <linux/dmi.h>
 #include <linux/nls.h>
 
-#include <acpi/acpi_drivers.h>
+#include <asm/pgtable.h>
 
 #include "internal.h"
 
 #define _COMPONENT             ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME("scan");
-#define STRUCT_TO_INT(s)       (*((int*)&s))
 extern struct acpi_device *acpi_root;
 
 #define ACPI_BUS_CLASS                 "system_bus"
@@ -27,6 +26,8 @@ extern struct acpi_device *acpi_root;
 
 #define ACPI_IS_ROOT_DEVICE(device)    (!(device)->parent)
 
+#define INVALID_ACPI_HANDLE    ((acpi_handle)empty_zero_page)
+
 /*
  * If set, devices will be hot-removed even if they cannot be put offline
  * gracefully (from the kernel's standpoint).
@@ -125,6 +126,26 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha
 }
 static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
 
+bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent)
+{
+       struct acpi_device_physical_node *pn;
+       bool offline = true;
+
+       mutex_lock(&adev->physical_node_lock);
+
+       list_for_each_entry(pn, &adev->physical_node_list, node)
+               if (device_supports_offline(pn->dev) && !pn->dev->offline) {
+                       if (uevent)
+                               kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE);
+
+                       offline = false;
+                       break;
+               }
+
+       mutex_unlock(&adev->physical_node_lock);
+       return offline;
+}
+
 static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
                                    void **ret_p)
 {
@@ -195,19 +216,11 @@ static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data,
        return AE_OK;
 }
 
-static int acpi_scan_hot_remove(struct acpi_device *device)
+static int acpi_scan_try_to_offline(struct acpi_device *device)
 {
        acpi_handle handle = device->handle;
-       struct device *errdev;
+       struct device *errdev = NULL;
        acpi_status status;
-       unsigned long long sta;
-
-       /* If there is no handle, the device node has been unregistered. */
-       if (!handle) {
-               dev_dbg(&device->dev, "ACPI handle missing\n");
-               put_device(&device->dev);
-               return -EINVAL;
-       }
 
        /*
         * Carry out two passes here and ignore errors in the first pass,
@@ -218,7 +231,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
         *
         * If the first pass is successful, the second one isn't needed, though.
         */
-       errdev = NULL;
        status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
                                     NULL, acpi_bus_offline, (void *)false,
                                     (void **)&errdev);
@@ -226,7 +238,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
                dev_warn(errdev, "Offline disabled.\n");
                acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
                                    acpi_bus_online, NULL, NULL, NULL);
-               put_device(&device->dev);
                return -EPERM;
        }
        acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev);
@@ -245,20 +256,32 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
                        acpi_walk_namespace(ACPI_TYPE_ANY, handle,
                                            ACPI_UINT32_MAX, acpi_bus_online,
                                            NULL, NULL, NULL);
-                       put_device(&device->dev);
                        return -EBUSY;
                }
        }
+       return 0;
+}
+
+static int acpi_scan_hot_remove(struct acpi_device *device)
+{
+       acpi_handle handle = device->handle;
+       unsigned long long sta;
+       acpi_status status;
+
+       if (device->handler->hotplug.demand_offline && !acpi_force_hot_remove) {
+               if (!acpi_scan_is_offline(device, true))
+                       return -EBUSY;
+       } else {
+               int error = acpi_scan_try_to_offline(device);
+               if (error)
+                       return error;
+       }
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                "Hot-removing device %s...\n", dev_name(&device->dev)));
 
        acpi_bus_trim(device);
 
-       /* Device node has been unregistered. */
-       put_device(&device->dev);
-       device = NULL;
-
        acpi_evaluate_lck(handle, 0);
        /*
         * TBD: _EJD support.
@@ -285,115 +308,127 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
        return 0;
 }
 
-void acpi_bus_device_eject(void *data, u32 ost_src)
+static int acpi_scan_device_not_present(struct acpi_device *adev)
 {
-       struct acpi_device *device = data;
-       acpi_handle handle = device->handle;
-       u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
-       int error;
+       if (!acpi_device_enumerated(adev)) {
+               dev_warn(&adev->dev, "Still not present\n");
+               return -EALREADY;
+       }
+       acpi_bus_trim(adev);
+       return 0;
+}
 
-       lock_device_hotplug();
-       mutex_lock(&acpi_scan_lock);
+static int acpi_scan_device_check(struct acpi_device *adev)
+{
+       int error;
 
-       if (ost_src == ACPI_NOTIFY_EJECT_REQUEST)
-               acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST,
-                                         ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
+       acpi_bus_get_status(adev);
+       if (adev->status.present || adev->status.functional) {
+               /*
+                * This function is only called for device objects for which
+                * matching scan handlers exist.  The only situation in which
+                * the scan handler is not attached to this device object yet
+                * is when the device has just appeared (either it wasn't
+                * present at all before or it was removed and then added
+                * again).
+                */
+               if (adev->handler) {
+                       dev_warn(&adev->dev, "Already enumerated\n");
+                       return -EALREADY;
+               }
+               error = acpi_bus_scan(adev->handle);
+               if (error) {
+                       dev_warn(&adev->dev, "Namespace scan failure\n");
+                       return error;
+               }
+               if (!adev->handler) {
+                       dev_warn(&adev->dev, "Enumeration failure\n");
+                       error = -ENODEV;
+               }
+       } else {
+               error = acpi_scan_device_not_present(adev);
+       }
+       return error;
+}
 
-       if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER)
-               kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
+static int acpi_scan_bus_check(struct acpi_device *adev)
+{
+       struct acpi_scan_handler *handler = adev->handler;
+       struct acpi_device *child;
+       int error;
 
-       error = acpi_scan_hot_remove(device);
-       if (error == -EPERM) {
-               goto err_support;
-       } else if (error) {
-               goto err_out;
+       acpi_bus_get_status(adev);
+       if (!(adev->status.present || adev->status.functional)) {
+               acpi_scan_device_not_present(adev);
+               return 0;
        }
+       if (handler && handler->hotplug.scan_dependent)
+               return handler->hotplug.scan_dependent(adev);
 
- out:
-       mutex_unlock(&acpi_scan_lock);
-       unlock_device_hotplug();
-       return;
-
- err_support:
-       ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
- err_out:
-       acpi_evaluate_hotplug_ost(handle, ost_src, ost_code, NULL);
-       goto out;
+       error = acpi_bus_scan(adev->handle);
+       if (error) {
+               dev_warn(&adev->dev, "Namespace scan failure\n");
+               return error;
+       }
+       list_for_each_entry(child, &adev->children, node) {
+               error = acpi_scan_bus_check(child);
+               if (error)
+                       return error;
+       }
+       return 0;
 }
 
-static void acpi_scan_bus_device_check(void *data, u32 ost_source)
+static void acpi_device_hotplug(void *data, u32 src)
 {
-       acpi_handle handle = data;
-       struct acpi_device *device = NULL;
        u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
+       struct acpi_device *adev = data;
        int error;
 
        lock_device_hotplug();
        mutex_lock(&acpi_scan_lock);
 
-       if (ost_source != ACPI_NOTIFY_BUS_CHECK) {
-               acpi_bus_get_device(handle, &device);
-               if (device) {
-                       dev_warn(&device->dev, "Attempt to re-insert\n");
-                       goto out;
-               }
-       }
-       error = acpi_bus_scan(handle);
-       if (error) {
-               acpi_handle_warn(handle, "Namespace scan failure\n");
-               goto out;
-       }
-       error = acpi_bus_get_device(handle, &device);
-       if (error) {
-               acpi_handle_warn(handle, "Missing device node object\n");
+       /*
+        * The device object's ACPI handle cannot become invalid as long as we
+        * are holding acpi_scan_lock, but it may have become invalid before
+        * that lock was acquired.
+        */
+       if (adev->handle == INVALID_ACPI_HANDLE)
                goto out;
-       }
-       ost_code = ACPI_OST_SC_SUCCESS;
-       if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER)
-               kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
-
- out:
-       acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL);
-       mutex_unlock(&acpi_scan_lock);
-       unlock_device_hotplug();
-}
-
-static void acpi_hotplug_unsupported(acpi_handle handle, u32 type)
-{
-       u32 ost_status;
 
-       switch (type) {
+       switch (src) {
        case ACPI_NOTIFY_BUS_CHECK:
-               acpi_handle_debug(handle,
-                       "ACPI_NOTIFY_BUS_CHECK event: unsupported\n");
-               ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED;
+               error = acpi_scan_bus_check(adev);
                break;
        case ACPI_NOTIFY_DEVICE_CHECK:
-               acpi_handle_debug(handle,
-                       "ACPI_NOTIFY_DEVICE_CHECK event: unsupported\n");
-               ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED;
+               error = acpi_scan_device_check(adev);
                break;
        case ACPI_NOTIFY_EJECT_REQUEST:
-               acpi_handle_debug(handle,
-                       "ACPI_NOTIFY_EJECT_REQUEST event: unsupported\n");
-               ost_status = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
+       case ACPI_OST_EC_OSPM_EJECT:
+               error = acpi_scan_hot_remove(adev);
                break;
        default:
-               /* non-hotplug event; possibly handled by other handler */
-               return;
+               error = -EINVAL;
+               break;
        }
+       if (!error)
+               ost_code = ACPI_OST_SC_SUCCESS;
 
-       acpi_evaluate_hotplug_ost(handle, type, ost_status, NULL);
+ out:
+       acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL);
+       put_device(&adev->dev);
+       mutex_unlock(&acpi_scan_lock);
+       unlock_device_hotplug();
 }
 
 static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
 {
+       u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
        struct acpi_scan_handler *handler = data;
        struct acpi_device *adev;
        acpi_status status;
 
-       if (!handler->hotplug.enabled)
-               return acpi_hotplug_unsupported(handle, type);
+       if (acpi_bus_get_device(handle, &adev))
+               goto err_out;
 
        switch (type) {
        case ACPI_NOTIFY_BUS_CHECK:
@@ -404,27 +439,27 @@ static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
                break;
        case ACPI_NOTIFY_EJECT_REQUEST:
                acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
-               if (acpi_bus_get_device(handle, &adev))
+               if (!handler->hotplug.enabled) {
+                       acpi_handle_err(handle, "Eject disabled\n");
+                       ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
                        goto err_out;
-
-               get_device(&adev->dev);
-               status = acpi_hotplug_execute(acpi_bus_device_eject, adev, type);
-               if (ACPI_SUCCESS(status))
-                       return;
-
-               put_device(&adev->dev);
-               goto err_out;
+               }
+               acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST,
+                                         ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
+               break;
        default:
                /* non-hotplug event; possibly handled by other handler */
                return;
        }
-       status = acpi_hotplug_execute(acpi_scan_bus_device_check, handle, type);
+       get_device(&adev->dev);
+       status = acpi_hotplug_execute(acpi_device_hotplug, adev, type);
        if (ACPI_SUCCESS(status))
                return;
 
+       put_device(&adev->dev);
+
  err_out:
-       acpi_evaluate_hotplug_ost(handle, type,
-                                 ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
+       acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
 }
 
 static ssize_t real_power_state_show(struct device *dev,
@@ -475,7 +510,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
        acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
                                  ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
        get_device(&acpi_device->dev);
-       status = acpi_hotplug_execute(acpi_bus_device_eject, acpi_device,
+       status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device,
                                      ACPI_OST_EC_OSPM_EJECT);
        if (ACPI_SUCCESS(status))
                return count;
@@ -567,6 +602,20 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
 
+static ssize_t status_show(struct device *dev, struct device_attribute *attr,
+                               char *buf) {
+       struct acpi_device *acpi_dev = to_acpi_device(dev);
+       acpi_status status;
+       unsigned long long sta;
+
+       status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
+       if (ACPI_FAILURE(status))
+               return -ENODEV;
+
+       return sprintf(buf, "%llu\n", sta);
+}
+static DEVICE_ATTR_RO(status);
+
 static int acpi_device_setup_files(struct acpi_device *dev)
 {
        struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
@@ -622,6 +671,12 @@ static int acpi_device_setup_files(struct acpi_device *dev)
                dev->pnp.sun = (unsigned long)-1;
        }
 
+       if (acpi_has_method(dev->handle, "_STA")) {
+               result = device_create_file(&dev->dev, &dev_attr_status);
+               if (result)
+                       goto end;
+       }
+
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
          * hot-removal function from userland.
@@ -677,6 +732,8 @@ static void acpi_device_remove_files(struct acpi_device *dev)
                device_remove_file(&dev->dev, &dev_attr_adr);
        device_remove_file(&dev->dev, &dev_attr_modalias);
        device_remove_file(&dev->dev, &dev_attr_hid);
+       if (acpi_has_method(dev->handle, "_STA"))
+               device_remove_file(&dev->dev, &dev_attr_status);
        if (dev->handle)
                device_remove_file(&dev->dev, &dev_attr_path);
 }
@@ -907,9 +964,91 @@ struct bus_type acpi_bus_type = {
        .uevent         = acpi_device_uevent,
 };
 
-static void acpi_bus_data_handler(acpi_handle handle, void *context)
+static void acpi_device_del(struct acpi_device *device)
 {
-       /* Intentionally empty. */
+       mutex_lock(&acpi_device_lock);
+       if (device->parent)
+               list_del(&device->node);
+
+       list_del(&device->wakeup_list);
+       mutex_unlock(&acpi_device_lock);
+
+       acpi_power_add_remove_device(device, false);
+       acpi_device_remove_files(device);
+       if (device->remove)
+               device->remove(device);
+
+       device_del(&device->dev);
+}
+
+static LIST_HEAD(acpi_device_del_list);
+static DEFINE_MUTEX(acpi_device_del_lock);
+
+static void acpi_device_del_work_fn(struct work_struct *work_not_used)
+{
+       for (;;) {
+               struct acpi_device *adev;
+
+               mutex_lock(&acpi_device_del_lock);
+
+               if (list_empty(&acpi_device_del_list)) {
+                       mutex_unlock(&acpi_device_del_lock);
+                       break;
+               }
+               adev = list_first_entry(&acpi_device_del_list,
+                                       struct acpi_device, del_list);
+               list_del(&adev->del_list);
+
+               mutex_unlock(&acpi_device_del_lock);
+
+               acpi_device_del(adev);
+               /*
+                * Drop references to all power resources that might have been
+                * used by the device.
+                */
+               acpi_power_transition(adev, ACPI_STATE_D3_COLD);
+               put_device(&adev->dev);
+       }
+}
+
+/**
+ * acpi_scan_drop_device - Drop an ACPI device object.
+ * @handle: Handle of an ACPI namespace node, not used.
+ * @context: Address of the ACPI device object to drop.
+ *
+ * This is invoked by acpi_ns_delete_node() during the removal of the ACPI
+ * namespace node the device object pointed to by @context is attached to.
+ *
+ * The unregistration is carried out asynchronously to avoid running
+ * acpi_device_del() under the ACPICA's namespace mutex and the list is used to
+ * ensure the correct ordering (the device objects must be unregistered in the
+ * same order in which the corresponding namespace nodes are deleted).
+ */
+static void acpi_scan_drop_device(acpi_handle handle, void *context)
+{
+       static DECLARE_WORK(work, acpi_device_del_work_fn);
+       struct acpi_device *adev = context;
+
+       mutex_lock(&acpi_device_del_lock);
+
+       /*
+        * Use the ACPI hotplug workqueue which is ordered, so this work item
+        * won't run after any hotplug work items submitted subsequently.  That
+        * prevents attempts to register device objects identical to those being
+        * deleted from happening concurrently (such attempts result from
+        * hotplug events handled via the ACPI hotplug workqueue).  It also will
+        * run after all of the work items submitted previosuly, which helps
+        * those work items to ensure that they are not accessing stale device
+        * objects.
+        */
+       if (list_empty(&acpi_device_del_list))
+               acpi_queue_hotplug_work(&work);
+
+       list_add_tail(&adev->del_list, &acpi_device_del_list);
+       /* Make acpi_ns_validate_handle() return NULL for this handle. */
+       adev->handle = INVALID_ACPI_HANDLE;
+
+       mutex_unlock(&acpi_device_del_lock);
 }
 
 int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
@@ -919,7 +1058,7 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
        if (!device)
                return -EINVAL;
 
-       status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
+       status = acpi_get_data(handle, acpi_scan_drop_device, (void **)device);
        if (ACPI_FAILURE(status) || !*device) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
                                  handle));
@@ -939,7 +1078,7 @@ int acpi_device_add(struct acpi_device *device,
        if (device->handle) {
                acpi_status status;
 
-               status = acpi_attach_data(device->handle, acpi_bus_data_handler,
+               status = acpi_attach_data(device->handle, acpi_scan_drop_device,
                                          device);
                if (ACPI_FAILURE(status)) {
                        acpi_handle_err(device->handle,
@@ -957,6 +1096,7 @@ int acpi_device_add(struct acpi_device *device,
        INIT_LIST_HEAD(&device->node);
        INIT_LIST_HEAD(&device->wakeup_list);
        INIT_LIST_HEAD(&device->physical_node_list);
+       INIT_LIST_HEAD(&device->del_list);
        mutex_init(&device->physical_node_lock);
 
        new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
@@ -1020,37 +1160,10 @@ int acpi_device_add(struct acpi_device *device,
        mutex_unlock(&acpi_device_lock);
 
  err_detach:
-       acpi_detach_data(device->handle, acpi_bus_data_handler);
+       acpi_detach_data(device->handle, acpi_scan_drop_device);
        return result;
 }
 
-static void acpi_device_unregister(struct acpi_device *device)
-{
-       mutex_lock(&acpi_device_lock);
-       if (device->parent)
-               list_del(&device->node);
-
-       list_del(&device->wakeup_list);
-       mutex_unlock(&acpi_device_lock);
-
-       acpi_detach_data(device->handle, acpi_bus_data_handler);
-
-       acpi_power_add_remove_device(device, false);
-       acpi_device_remove_files(device);
-       if (device->remove)
-               device->remove(device);
-
-       device_del(&device->dev);
-       /*
-        * Transition the device to D3cold to drop the reference counts of all
-        * power resources the device depends on and turn off the ones that have
-        * no more references.
-        */
-       acpi_device_set_power(device, ACPI_STATE_D3_COLD);
-       device->handle = NULL;
-       put_device(&device->dev);
-}
-
 /* --------------------------------------------------------------------------
                                  Driver Management
    -------------------------------------------------------------------------- */
@@ -1624,11 +1737,13 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
        device->device_type = type;
        device->handle = handle;
        device->parent = acpi_bus_get_parent(handle);
-       STRUCT_TO_INT(device->status) = sta;
+       acpi_set_device_status(device, sta);
        acpi_device_get_busid(device);
        acpi_set_pnp_ids(handle, &device->pnp, type);
        acpi_bus_get_flags(device);
        device->flags.match_driver = false;
+       device->flags.initialized = true;
+       device->flags.visited = false;
        device_initialize(&device->dev);
        dev_set_uevent_suppress(&device->dev, true);
 }
@@ -1713,6 +1828,15 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
        return 0;
 }
 
+bool acpi_device_is_present(struct acpi_device *adev)
+{
+       if (adev->status.present || adev->status.functional)
+               return true;
+
+       adev->flags.initialized = false;
+       return false;
+}
+
 static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
                                       char *idstr,
                                       const struct acpi_device_id **matchid)
@@ -1772,7 +1896,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type)
         */
        list_for_each_entry(hwid, &pnp.ids, list) {
                handler = acpi_scan_match_handler(hwid->id, NULL);
-               if (handler && !handler->hotplug.ignore) {
+               if (handler) {
                        acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
                                        acpi_hotplug_notify_cb, handler);
                        break;
@@ -1806,18 +1930,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
 
        acpi_scan_init_hotplug(handle, type);
 
-       if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
-           !(sta & ACPI_STA_DEVICE_FUNCTIONING)) {
-               struct acpi_device_wakeup wakeup;
-
-               if (acpi_has_method(handle, "_PRW")) {
-                       acpi_bus_extract_wakeup_device_power_package(handle,
-                                                                    &wakeup);
-                       acpi_power_resources_list_free(&wakeup.resources);
-               }
-               return AE_CTRL_DEPTH;
-       }
-
        acpi_add_single_object(&device, handle, type, sta);
        if (!device)
                return AE_CTRL_DEPTH;
@@ -1852,36 +1964,40 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
        return ret;
 }
 
-static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
-                                         void *not_used, void **ret_not_used)
+static void acpi_bus_attach(struct acpi_device *device)
 {
-       struct acpi_device *device;
-       unsigned long long sta_not_used;
+       struct acpi_device *child;
        int ret;
 
-       /*
-        * Ignore errors ignored by acpi_bus_check_add() to avoid terminating
-        * namespace walks prematurely.
-        */
-       if (acpi_bus_type_and_status(handle, &ret, &sta_not_used))
-               return AE_OK;
-
-       if (acpi_bus_get_device(handle, &device))
-               return AE_CTRL_DEPTH;
-
+       acpi_bus_get_status(device);
+       /* Skip devices that are not present. */
+       if (!acpi_device_is_present(device)) {
+               device->flags.visited = false;
+               return;
+       }
        if (device->handler)
-               return AE_OK;
+               goto ok;
 
+       if (!device->flags.initialized) {
+               acpi_bus_update_power(device, NULL);
+               device->flags.initialized = true;
+       }
+       device->flags.visited = false;
        ret = acpi_scan_attach_handler(device);
        if (ret < 0)
-               return AE_CTRL_DEPTH;
+               return;
 
        device->flags.match_driver = true;
-       if (ret > 0)
-               return AE_OK;
+       if (!ret) {
+               ret = device_attach(&device->dev);
+               if (ret < 0)
+                       return;
+       }
+       device->flags.visited = true;
 
-       ret = device_attach(&device->dev);
-       return ret >= 0 ? AE_OK : AE_CTRL_DEPTH;
+ ok:
+       list_for_each_entry(child, &device->children, node)
+               acpi_bus_attach(child);
 }
 
 /**
@@ -1901,75 +2017,48 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
 int acpi_bus_scan(acpi_handle handle)
 {
        void *device = NULL;
-       int error = 0;
 
        if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
                acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
                                    acpi_bus_check_add, NULL, NULL, &device);
 
-       if (!device)
-               error = -ENODEV;
-       else if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
-               acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
-                                   acpi_bus_device_attach, NULL, NULL, NULL);
-
-       return error;
-}
-EXPORT_SYMBOL(acpi_bus_scan);
-
-static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
-                                         void *not_used, void **ret_not_used)
-{
-       struct acpi_device *device = NULL;
-
-       if (!acpi_bus_get_device(handle, &device)) {
-               struct acpi_scan_handler *dev_handler = device->handler;
-
-               if (dev_handler) {
-                       if (dev_handler->detach)
-                               dev_handler->detach(device);
-
-                       device->handler = NULL;
-               } else {
-                       device_release_driver(&device->dev);
-               }
+       if (device) {
+               acpi_bus_attach(device);
+               return 0;
        }
-       return AE_OK;
-}
-
-static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
-                                  void *not_used, void **ret_not_used)
-{
-       struct acpi_device *device = NULL;
-
-       if (!acpi_bus_get_device(handle, &device))
-               acpi_device_unregister(device);
-
-       return AE_OK;
+       return -ENODEV;
 }
+EXPORT_SYMBOL(acpi_bus_scan);
 
 /**
- * acpi_bus_trim - Remove ACPI device node and all of its descendants
- * @start: Root of the ACPI device nodes subtree to remove.
+ * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
+ * @adev: Root of the ACPI namespace scope to walk.
  *
  * Must be called under acpi_scan_lock.
  */
-void acpi_bus_trim(struct acpi_device *start)
+void acpi_bus_trim(struct acpi_device *adev)
 {
+       struct acpi_scan_handler *handler = adev->handler;
+       struct acpi_device *child;
+
+       list_for_each_entry_reverse(child, &adev->children, node)
+               acpi_bus_trim(child);
+
+       if (handler) {
+               if (handler->detach)
+                       handler->detach(adev);
+
+               adev->handler = NULL;
+       } else {
+               device_release_driver(&adev->dev);
+       }
        /*
-        * Execute acpi_bus_device_detach() as a post-order callback to detach
-        * all ACPI drivers from the device nodes being removed.
-        */
-       acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
-                           acpi_bus_device_detach, NULL, NULL);
-       acpi_bus_device_detach(start->handle, 0, NULL, NULL);
-       /*
-        * Execute acpi_bus_remove() as a post-order callback to remove device
-        * nodes in the given namespace scope.
+        * Most likely, the device is going away, so put it into D3cold before
+        * that.
         */
-       acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
-                           acpi_bus_remove, NULL, NULL);
-       acpi_bus_remove(start->handle, 0, NULL, NULL);
+       acpi_device_set_power(adev, ACPI_STATE_D3_COLD);
+       adev->flags.initialized = false;
+       adev->flags.visited = false;
 }
 EXPORT_SYMBOL_GPL(acpi_bus_trim);
 
@@ -2047,14 +2136,14 @@ int __init acpi_scan_init(void)
 
        result = acpi_bus_scan_fixed();
        if (result) {
-               acpi_device_unregister(acpi_root);
+               acpi_detach_data(acpi_root->handle, acpi_scan_drop_device);
+               acpi_device_del(acpi_root);
+               put_device(&acpi_root->dev);
                goto out;
        }
 
        acpi_update_all_gpes();
 
-       acpi_pci_root_hp_init();
-
  out:
        mutex_unlock(&acpi_scan_lock);
        return result;
index 721e949e606edff0e2b62dc1e4d12e201bbbad4d..b718806657cdac29d9ccb3a1cad3fe6528865176 100644 (file)
 #include <linux/reboot.h>
 #include <linux/acpi.h>
 #include <linux/module.h>
-
 #include <asm/io.h>
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-
 #include "internal.h"
 #include "sleep.h"
 
@@ -670,11 +666,8 @@ static void acpi_hibernation_leave(void)
        /* Reprogram control registers */
        acpi_leave_sleep_state_prep(ACPI_STATE_S4);
        /* Check the hardware signature */
-       if (facs && s4_hardware_signature != facs->hardware_signature) {
-               printk(KERN_EMERG "ACPI: Hardware changed while hibernated, "
-                       "cannot resume!\n");
-               panic("ACPI S4 hardware signature mismatch");
-       }
+       if (facs && s4_hardware_signature != facs->hardware_signature)
+               pr_crit("ACPI: Hardware changed while hibernated, success doubtful!\n");
        /* Restore the NVS memory area */
        suspend_nvs_restore();
        /* Allow EC transactions to happen. */
@@ -806,9 +799,6 @@ int __init acpi_sleep_init(void)
        char *pos = supported;
        int i;
 
-       if (acpi_disabled)
-               return 0;
-
        acpi_sleep_dmi_check();
 
        sleep_states[ACPI_STATE_S0] = 1;
index 6dbc3ca45223a1ba30f995f016ecd965dd4861f7..443dc9366052f623b14b6ce278a2bafff81e15ac 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 #include "internal.h"
 
index d67a1fe07f0ed60fc8f6aef61bde04bbbcb84e76..5837f857ac2e82aff69a5d9bf7e619ace323d946 100644 (file)
@@ -278,12 +278,13 @@ acpi_table_parse_madt(enum acpi_madt_type id,
 
 /**
  * acpi_table_parse - find table with @id, run @handler on it
- *
  * @id: table id to find
  * @handler: handler to run
  *
  * Scan the ACPI System Descriptor Table (STD) for a table matching @id,
- * run @handler on it.  Return 0 if table found, return on if not.
+ * run @handler on it.
+ *
+ * Return 0 if table found, -errno if not.
  */
 int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
 {
@@ -293,7 +294,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
        if (acpi_disabled)
                return -ENODEV;
 
-       if (!handler)
+       if (!id || !handler)
                return -EINVAL;
 
        if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
@@ -306,7 +307,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
                early_acpi_os_unmap_memory(table, tbl_size);
                return 0;
        } else
-               return 1;
+               return -ENODEV;
 }
 
 /* 
@@ -351,7 +352,7 @@ int __init acpi_table_init(void)
 
        status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
        if (ACPI_FAILURE(status))
-               return 1;
+               return -EINVAL;
 
        check_multiple_madt();
        return 0;
index 0d9f46b5ae6d100a64ca3c3410ab23ac2af361fe..8349a555b92b8aa6d6584f9c2c5c9ccf7a27737f 100644 (file)
 #include <linux/kmod.h>
 #include <linux/reboot.h>
 #include <linux/device.h>
-#include <asm/uaccess.h>
 #include <linux/thermal.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
+#include <asm/uaccess.h>
 
 #define PREFIX "ACPI: "
 
@@ -862,7 +861,7 @@ acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
        return acpi_thermal_cooling_device_cb(thermal, cdev, false);
 }
 
-static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
+static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
        .bind = acpi_thermal_bind_cooling_device,
        .unbind = acpi_thermal_unbind_cooling_device,
        .get_temp = thermal_get_temp,
index 6d408bfbbb1d0c66dbef28d02137dbda0777d9f4..0347a37eb4389dcbd5c497ca6833e867618acbf5 100644 (file)
@@ -30,8 +30,6 @@
 #include <linux/types.h>
 #include <linux/hardirq.h>
 #include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
 
 #include "internal.h"
 
@@ -574,3 +572,100 @@ acpi_status acpi_evaluate_lck(acpi_handle handle, int lock)
 
        return status;
 }
+
+/**
+ * acpi_evaluate_dsm - evaluate device's _DSM method
+ * @handle: ACPI device handle
+ * @uuid: UUID of requested functions, should be 16 bytes
+ * @rev: revision number of requested function
+ * @func: requested function number
+ * @argv4: the function specific parameter
+ *
+ * Evaluate device's _DSM method with specified UUID, revision id and
+ * function number. Caller needs to free the returned object.
+ *
+ * Though ACPI defines the fourth parameter for _DSM should be a package,
+ * some old BIOSes do expect a buffer or an integer etc.
+ */
+union acpi_object *
+acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid, int rev, int func,
+                 union acpi_object *argv4)
+{
+       acpi_status ret;
+       struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
+       union acpi_object params[4];
+       struct acpi_object_list input = {
+               .count = 4,
+               .pointer = params,
+       };
+
+       params[0].type = ACPI_TYPE_BUFFER;
+       params[0].buffer.length = 16;
+       params[0].buffer.pointer = (char *)uuid;
+       params[1].type = ACPI_TYPE_INTEGER;
+       params[1].integer.value = rev;
+       params[2].type = ACPI_TYPE_INTEGER;
+       params[2].integer.value = func;
+       if (argv4) {
+               params[3] = *argv4;
+       } else {
+               params[3].type = ACPI_TYPE_PACKAGE;
+               params[3].package.count = 0;
+               params[3].package.elements = NULL;
+       }
+
+       ret = acpi_evaluate_object(handle, "_DSM", &input, &buf);
+       if (ACPI_SUCCESS(ret))
+               return (union acpi_object *)buf.pointer;
+
+       if (ret != AE_NOT_FOUND)
+               acpi_handle_warn(handle,
+                               "failed to evaluate _DSM (0x%x)\n", ret);
+
+       return NULL;
+}
+EXPORT_SYMBOL(acpi_evaluate_dsm);
+
+/**
+ * acpi_check_dsm - check if _DSM method supports requested functions.
+ * @handle: ACPI device handle
+ * @uuid: UUID of requested functions, should be 16 bytes at least
+ * @rev: revision number of requested functions
+ * @funcs: bitmap of requested functions
+ * @exclude: excluding special value, used to support i915 and nouveau
+ *
+ * Evaluate device's _DSM method to check whether it supports requested
+ * functions. Currently only support 64 functions at maximum, should be
+ * enough for now.
+ */
+bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs)
+{
+       int i;
+       u64 mask = 0;
+       union acpi_object *obj;
+
+       if (funcs == 0)
+               return false;
+
+       obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
+       if (!obj)
+               return false;
+
+       /* For compatibility, old BIOSes may return an integer */
+       if (obj->type == ACPI_TYPE_INTEGER)
+               mask = obj->integer.value;
+       else if (obj->type == ACPI_TYPE_BUFFER)
+               for (i = 0; i < obj->buffer.length && i < 8; i++)
+                       mask |= (((u8)obj->buffer.pointer[i]) << (i * 8));
+       ACPI_FREE(obj);
+
+       /*
+        * Bit 0 indicates whether there's support for any functions other than
+        * function 0 for the specified UUID and revision.
+        */
+       if ((mask & 0x1) && (mask & funcs) == funcs)
+               return true;
+
+       return false;
+}
+EXPORT_SYMBOL(acpi_check_dsm);
index 995e91bcb97b7b4d5f21d585de1f5a7e46bd9ebd..b727d105046d234ae8ef2a5669e53e61b82e7123 100644 (file)
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
 #include <linux/slab.h>
-#include <asm/uaccess.h>
 #include <linux/dmi.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
 #include <linux/suspend.h>
+#include <linux/acpi.h>
 #include <acpi/video.h>
+#include <asm/uaccess.h>
 
 #include "internal.h"
 
index 84875fd4c74f9fbd100106ea3615ffcde2daf6cf..f0447d3daf2c433fce6ad97a981c378a2d8c38ae 100644 (file)
@@ -50,7 +50,7 @@ static bool acpi_video_caps_checked;
 
 static acpi_status
 acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
-                         void **retyurn_value)
+                         void **return_value)
 {
        long *cap = context;
 
index 7bfbe40bc43bcb5e736c4c77788d4b7d577de160..1638401ab282ef2dc554fff498ebaba8babf8daf 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <linux/init.h>
 #include <linux/acpi.h>
-#include <acpi/acpi_drivers.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 
index 4372cfa883c9c36cf2624f88186ef3e0e7b27d31..9e69a5308693de59abd5c596244033af43f7b3a8 100644 (file)
@@ -20,8 +20,6 @@
 #include <scsi/scsi_device.h>
 #include "libata.h"
 
-#include <acpi/acpi_bus.h>
-
 unsigned int ata_acpi_gtf_filter = ATA_ACPI_FILTER_DEFAULT;
 module_param_named(acpi_gtf_filter, ata_acpi_gtf_filter, int, 0644);
 MODULE_PARM_DESC(acpi_gtf_filter, "filter mask for ACPI _GTF commands, set to filter out (0x1=set xfermode, 0x2=lock/freeze lock, 0x4=DIPM, 0x8=FPDMA non-zero offset, 0x10=FPDMA DMA Setup FIS auto-activate)");
@@ -180,12 +178,12 @@ static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
 /* bind acpi handle to pata port */
 void ata_acpi_bind_port(struct ata_port *ap)
 {
-       acpi_handle host_handle = ACPI_HANDLE(ap->host->dev);
+       struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
 
-       if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_handle)
+       if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_companion)
                return;
 
-       acpi_preset_companion(&ap->tdev, host_handle, ap->port_no);
+       acpi_preset_companion(&ap->tdev, host_companion, ap->port_no);
 
        if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
                ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
@@ -198,17 +196,17 @@ void ata_acpi_bind_port(struct ata_port *ap)
 void ata_acpi_bind_dev(struct ata_device *dev)
 {
        struct ata_port *ap = dev->link->ap;
-       acpi_handle port_handle = ACPI_HANDLE(&ap->tdev);
-       acpi_handle host_handle = ACPI_HANDLE(ap->host->dev);
-       acpi_handle parent_handle;
+       struct acpi_device *port_companion = ACPI_COMPANION(&ap->tdev);
+       struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
+       struct acpi_device *parent;
        u64 adr;
 
        /*
-        * For both sata/pata devices, host handle is required.
-        * For pata device, port handle is also required.
+        * For both sata/pata devices, host companion device is required.
+        * For pata device, port companion device is also required.
         */
-       if (libata_noacpi || !host_handle ||
-                       (!(ap->flags & ATA_FLAG_ACPI_SATA) && !port_handle))
+       if (libata_noacpi || !host_companion ||
+                       (!(ap->flags & ATA_FLAG_ACPI_SATA) && !port_companion))
                return;
 
        if (ap->flags & ATA_FLAG_ACPI_SATA) {
@@ -216,13 +214,13 @@ void ata_acpi_bind_dev(struct ata_device *dev)
                        adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
                else
                        adr = SATA_ADR(ap->port_no, dev->link->pmp);
-               parent_handle = host_handle;
+               parent = host_companion;
        } else {
                adr = dev->devno;
-               parent_handle = port_handle;
+               parent = port_companion;
        }
 
-       acpi_preset_companion(&dev->tdev, parent_handle, adr);
+       acpi_preset_companion(&dev->tdev, parent, adr);
 
        register_hotplug_dock_device(ata_dev_acpi_handle(dev),
                                     &ata_acpi_dev_dock_ops, dev, NULL, NULL);
index 73212c9c6d5bfb90b1193dddb2f30135b9edd9a9..62c9ac80c6e96ed1f0a4421fb22b7ee3629ae2e9 100644 (file)
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/gfp.h>
-#include <scsi/scsi_host.h>
-#include <acpi/acpi_bus.h>
-
+#include <linux/acpi.h>
 #include <linux/libata.h>
 #include <linux/ata.h>
+#include <scsi/scsi_host.h>
 
 #define DRV_NAME       "pata_acpi"
 #define DRV_VERSION    "0.2.3"
index 94e8a80e87f87e545638f257ead04c56f73f088b..d08c9d3b1d3747edcaa1d36fb8d206b0105226ec 100644 (file)
@@ -4,7 +4,7 @@ obj-y                   := core.o bus.o dd.o syscore.o \
                           driver.o class.o platform.o \
                           cpu.o firmware.o init.o map.o devres.o \
                           attribute_container.o transport_class.o \
-                          topology.o
+                          topology.o container.o
 obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
 obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
 obj-y                  += power/
index 2cbc6774f4cdb904868ee1f0344753c0e1f5dcd8..24f424249d9b517089b82c2436042751eec3aa42 100644 (file)
@@ -100,6 +100,7 @@ static inline int hypervisor_init(void) { return 0; }
 #endif
 extern int platform_bus_init(void);
 extern void cpu_dev_init(void);
+extern void container_dev_init(void);
 
 struct kobject *virtual_device_parent(struct device *dev);
 
diff --git a/drivers/base/container.c b/drivers/base/container.c
new file mode 100644 (file)
index 0000000..ecbfbe2
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * System bus type for containers.
+ *
+ * Copyright (C) 2013, Intel Corporation
+ * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/container.h>
+
+#include "base.h"
+
+#define CONTAINER_BUS_NAME     "container"
+
+static int trivial_online(struct device *dev)
+{
+       return 0;
+}
+
+static int container_offline(struct device *dev)
+{
+       struct container_dev *cdev = to_container_dev(dev);
+
+       return cdev->offline ? cdev->offline(cdev) : 0;
+}
+
+struct bus_type container_subsys = {
+       .name = CONTAINER_BUS_NAME,
+       .dev_name = CONTAINER_BUS_NAME,
+       .online = trivial_online,
+       .offline = container_offline,
+};
+
+void __init container_dev_init(void)
+{
+       int ret;
+
+       ret = subsys_system_register(&container_subsys, NULL);
+       if (ret)
+               pr_err("%s() failed: %d\n", __func__, ret);
+}
index c16f0b808a174e75f2df8da9da6008f56f45557c..da033d3bab3c69d14e55d63c4286632905120ae2 100644 (file)
@@ -33,4 +33,5 @@ void __init driver_init(void)
        platform_bus_init();
        cpu_dev_init();
        memory_dev_init();
+       container_dev_init();
 }
index 9d8fde709390e853909ba52aec823167882da2ae..e870bbe9ec4e674d91fb3bede6e4105fd25ccd6a 100644 (file)
@@ -32,6 +32,21 @@ struct pm_clock_entry {
        enum pce_status status;
 };
 
+/**
+ * pm_clk_enable - Enable a clock, reporting any errors
+ * @dev: The device for the given clock
+ * @clk: The clock being enabled.
+ */
+static inline int __pm_clk_enable(struct device *dev, struct clk *clk)
+{
+       int ret = clk_enable(clk);
+       if (ret)
+               dev_err(dev, "%s: failed to enable clk %p, error %d\n",
+                       __func__, clk, ret);
+
+       return ret;
+}
+
 /**
  * pm_clk_acquire - Acquire a device clock.
  * @dev: Device whose clock is to be acquired.
@@ -43,6 +58,7 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
        if (IS_ERR(ce->clk)) {
                ce->status = PCE_STATUS_ERROR;
        } else {
+               clk_prepare(ce->clk);
                ce->status = PCE_STATUS_ACQUIRED;
                dev_dbg(dev, "Clock %s managed by runtime PM.\n", ce->con_id);
        }
@@ -99,10 +115,12 @@ static void __pm_clk_remove(struct pm_clock_entry *ce)
 
        if (ce->status < PCE_STATUS_ERROR) {
                if (ce->status == PCE_STATUS_ENABLED)
-                       clk_disable_unprepare(ce->clk);
+                       clk_disable(ce->clk);
 
-               if (ce->status >= PCE_STATUS_ACQUIRED)
+               if (ce->status >= PCE_STATUS_ACQUIRED) {
+                       clk_unprepare(ce->clk);
                        clk_put(ce->clk);
+               }
        }
 
        kfree(ce->con_id);
@@ -249,6 +267,7 @@ int pm_clk_resume(struct device *dev)
        struct pm_subsys_data *psd = dev_to_psd(dev);
        struct pm_clock_entry *ce;
        unsigned long flags;
+       int ret;
 
        dev_dbg(dev, "%s()\n", __func__);
 
@@ -259,8 +278,9 @@ int pm_clk_resume(struct device *dev)
 
        list_for_each_entry(ce, &psd->clock_list, node) {
                if (ce->status < PCE_STATUS_ERROR) {
-                       clk_enable(ce->clk);
-                       ce->status = PCE_STATUS_ENABLED;
+                       ret = __pm_clk_enable(dev, ce->clk);
+                       if (!ret)
+                               ce->status = PCE_STATUS_ENABLED;
                }
        }
 
@@ -376,7 +396,7 @@ int pm_clk_resume(struct device *dev)
        spin_lock_irqsave(&psd->lock, flags);
 
        list_for_each_entry(ce, &psd->clock_list, node)
-               clk_enable(ce->clk);
+               __pm_clk_enable(dev, ce->clk);
 
        spin_unlock_irqrestore(&psd->lock, flags);
 
index 5ee030a864f9266bb6c8ea18dd897e736fd2727c..a2e55bfdf572dae86b0b5e0c14c4f0fa5523b865 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/export.h>
 
-#ifdef CONFIG_PM_RUNTIME
+#ifdef CONFIG_PM
 /**
  * pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems.
  * @dev: Device to suspend.
@@ -48,7 +48,7 @@ int pm_generic_runtime_resume(struct device *dev)
        return ret;
 }
 EXPORT_SYMBOL_GPL(pm_generic_runtime_resume);
-#endif /* CONFIG_PM_RUNTIME */
+#endif /* CONFIG_PM */
 
 #ifdef CONFIG_PM_SLEEP
 /**
index 46118f8459484a35c3a709c12a28512fd56820af..dd9dfa15e9d13364b1ce2ea65de957bdd21a6ee4 100644 (file)
@@ -531,6 +531,7 @@ static int apm_suspend_notifier(struct notifier_block *nb,
 {
        struct apm_user *as;
        int err;
+       unsigned long apm_event;
 
        /* short-cut emergency suspends */
        if (atomic_read(&userspace_notification_inhibit))
@@ -538,6 +539,9 @@ static int apm_suspend_notifier(struct notifier_block *nb,
 
        switch (event) {
        case PM_SUSPEND_PREPARE:
+       case PM_HIBERNATION_PREPARE:
+               apm_event = (event == PM_SUSPEND_PREPARE) ?
+                       APM_USER_SUSPEND : APM_USER_HIBERNATION;
                /*
                 * Queue an event to all "writer" users that we want
                 * to suspend and need their ack.
@@ -550,7 +554,7 @@ static int apm_suspend_notifier(struct notifier_block *nb,
                            as->writer && as->suser) {
                                as->suspend_state = SUSPEND_PENDING;
                                atomic_inc(&suspend_acks_pending);
-                               queue_add_event(&as->queue, APM_USER_SUSPEND);
+                               queue_add_event(&as->queue, apm_event);
                        }
                }
 
@@ -601,11 +605,14 @@ static int apm_suspend_notifier(struct notifier_block *nb,
                return notifier_from_errno(err);
 
        case PM_POST_SUSPEND:
+       case PM_POST_HIBERNATION:
+               apm_event = (event == PM_POST_SUSPEND) ?
+                       APM_NORMAL_RESUME : APM_HIBERNATION_RESUME;
                /*
                 * Anyone on the APM queues will think we're still suspended.
                 * Send a message so everyone knows we're now awake again.
                 */
-               queue_event(APM_NORMAL_RESUME);
+               queue_event(apm_event);
 
                /*
                 * Finally, wake up anyone who is sleeping on the suspend.
index 5d9c31dfc905eac973f167d4f77d1c8b628de0b0..d5d4cd82b9f7dac435af267806ff541777f3ebdb 100644 (file)
 #include <linux/uaccess.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-
+#include <linux/acpi.h>
+#include <linux/hpet.h>
 #include <asm/current.h>
 #include <asm/irq.h>
 #include <asm/div64.h>
 
-#include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
-#include <linux/hpet.h>
-
 /*
  * The High Precision Event Timer driver.
  * This driver is closely modelled after the rtc.c driver.
index 64420b3396a294ccd56c2b6e727b1aaa0459a34b..b9a57fa4b710301d3844cf9ea9b659830b871d0f 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/security.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <acpi/acpi.h>
+#include <linux/acpi.h>
 
 #include "tpm.h"
 #include "tpm_eventlog.h"
index e1f3337a0cf9f7d7fa223a86e84282765d915108..b3ea223585bdeac64de19606f96b21b280c96210 100644 (file)
@@ -1,16 +1,6 @@
 #include <linux/acpi.h>
-#include <acpi/acpi_drivers.h>
 #include "tpm.h"
 
-static const u8 tpm_ppi_uuid[] = {
-       0xA6, 0xFA, 0xDD, 0x3D,
-       0x1B, 0x36,
-       0xB4, 0x4E,
-       0xA4, 0x24,
-       0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53
-};
-static char *tpm_device_name = "TPM";
-
 #define TPM_PPI_REVISION_ID    1
 #define TPM_PPI_FN_VERSION     1
 #define TPM_PPI_FN_SUBREQ      2
@@ -24,250 +14,178 @@ static char *tpm_device_name = "TPM";
 #define PPI_VS_REQ_END         255
 #define PPI_VERSION_LEN                3
 
+static const u8 tpm_ppi_uuid[] = {
+       0xA6, 0xFA, 0xDD, 0x3D,
+       0x1B, 0x36,
+       0xB4, 0x4E,
+       0xA4, 0x24,
+       0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53
+};
+
+static char tpm_ppi_version[PPI_VERSION_LEN + 1];
+static acpi_handle tpm_ppi_handle;
+
 static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context,
                                void **return_value)
 {
-       acpi_status status = AE_OK;
-       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       union acpi_object *obj;
 
-       if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer))) {
-               if (strstr(buffer.pointer, context) != NULL) {
-                       *return_value = handle;
-                       status = AE_CTRL_TERMINATE;
-               }
-               kfree(buffer.pointer);
+       if (!acpi_check_dsm(handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
+                           1 << TPM_PPI_FN_VERSION))
+               return AE_OK;
+
+       /* Cache version string */
+       obj = acpi_evaluate_dsm_typed(handle, tpm_ppi_uuid,
+                                     TPM_PPI_REVISION_ID, TPM_PPI_FN_VERSION,
+                                     NULL, ACPI_TYPE_STRING);
+       if (obj) {
+               strlcpy(tpm_ppi_version, obj->string.pointer,
+                       PPI_VERSION_LEN + 1);
+               ACPI_FREE(obj);
        }
 
-       return status;
+       *return_value = handle;
+
+       return AE_CTRL_TERMINATE;
 }
 
-static inline void ppi_assign_params(union acpi_object params[4],
-                                    u64 function_num)
+static inline union acpi_object *
+tpm_eval_dsm(int func, acpi_object_type type, union acpi_object *argv4)
 {
-       params[0].type = ACPI_TYPE_BUFFER;
-       params[0].buffer.length = sizeof(tpm_ppi_uuid);
-       params[0].buffer.pointer = (char *)tpm_ppi_uuid;
-       params[1].type = ACPI_TYPE_INTEGER;
-       params[1].integer.value = TPM_PPI_REVISION_ID;
-       params[2].type = ACPI_TYPE_INTEGER;
-       params[2].integer.value = function_num;
-       params[3].type = ACPI_TYPE_PACKAGE;
-       params[3].package.count = 0;
-       params[3].package.elements = NULL;
+       BUG_ON(!tpm_ppi_handle);
+       return acpi_evaluate_dsm_typed(tpm_ppi_handle, tpm_ppi_uuid,
+                                      TPM_PPI_REVISION_ID, func, argv4, type);
 }
 
 static ssize_t tpm_show_ppi_version(struct device *dev,
                                    struct device_attribute *attr, char *buf)
 {
-       acpi_handle handle;
-       acpi_status status;
-       struct acpi_object_list input;
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       union acpi_object params[4];
-       union acpi_object *obj;
-
-       input.count = 4;
-       ppi_assign_params(params, TPM_PPI_FN_VERSION);
-       input.pointer = params;
-       status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-                                    ACPI_UINT32_MAX, ppi_callback, NULL,
-                                    tpm_device_name, &handle);
-       if (ACPI_FAILURE(status))
-               return -ENXIO;
-
-       status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
-                                        ACPI_TYPE_STRING);
-       if (ACPI_FAILURE(status))
-               return -ENOMEM;
-       obj = (union acpi_object *)output.pointer;
-       status = scnprintf(buf, PAGE_SIZE, "%s\n", obj->string.pointer);
-       kfree(output.pointer);
-       return status;
+       return scnprintf(buf, PAGE_SIZE, "%s\n", tpm_ppi_version);
 }
 
 static ssize_t tpm_show_ppi_request(struct device *dev,
                                    struct device_attribute *attr, char *buf)
 {
-       acpi_handle handle;
-       acpi_status status;
-       struct acpi_object_list input;
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       union acpi_object params[4];
-       union acpi_object *ret_obj;
-
-       input.count = 4;
-       ppi_assign_params(params, TPM_PPI_FN_GETREQ);
-       input.pointer = params;
-       status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-                                    ACPI_UINT32_MAX, ppi_callback, NULL,
-                                    tpm_device_name, &handle);
-       if (ACPI_FAILURE(status))
+       ssize_t size = -EINVAL;
+       union acpi_object *obj;
+
+       obj = tpm_eval_dsm(TPM_PPI_FN_GETREQ, ACPI_TYPE_PACKAGE, NULL);
+       if (!obj)
                return -ENXIO;
 
-       status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
-                                           ACPI_TYPE_PACKAGE);
-       if (ACPI_FAILURE(status))
-               return -ENOMEM;
        /*
         * output.pointer should be of package type, including two integers.
         * The first is function return code, 0 means success and 1 means
         * error. The second is pending TPM operation requested by the OS, 0
         * means none and >0 means operation value.
         */
-       ret_obj = ((union acpi_object *)output.pointer)->package.elements;
-       if (ret_obj->type == ACPI_TYPE_INTEGER) {
-               if (ret_obj->integer.value) {
-                       status = -EFAULT;
-                       goto cleanup;
-               }
-               ret_obj++;
-               if (ret_obj->type == ACPI_TYPE_INTEGER)
-                       status = scnprintf(buf, PAGE_SIZE, "%llu\n",
-                                          ret_obj->integer.value);
+       if (obj->package.count == 2 &&
+           obj->package.elements[0].type == ACPI_TYPE_INTEGER &&
+           obj->package.elements[1].type == ACPI_TYPE_INTEGER) {
+               if (obj->package.elements[0].integer.value)
+                       size = -EFAULT;
                else
-                       status = -EINVAL;
-       } else {
-               status = -EINVAL;
+                       size = scnprintf(buf, PAGE_SIZE, "%llu\n",
+                                obj->package.elements[1].integer.value);
        }
-cleanup:
-       kfree(output.pointer);
-       return status;
+
+       ACPI_FREE(obj);
+
+       return size;
 }
 
 static ssize_t tpm_store_ppi_request(struct device *dev,
                                     struct device_attribute *attr,
                                     const char *buf, size_t count)
 {
-       char version[PPI_VERSION_LEN + 1];
-       acpi_handle handle;
-       acpi_status status;
-       struct acpi_object_list input;
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       union acpi_object params[4];
-       union acpi_object obj;
        u32 req;
        u64 ret;
+       int func = TPM_PPI_FN_SUBREQ;
+       union acpi_object *obj, tmp;
+       union acpi_object argv4 = ACPI_INIT_DSM_ARGV4(1, &tmp);
 
-       input.count = 4;
-       ppi_assign_params(params, TPM_PPI_FN_VERSION);
-       input.pointer = params;
-       status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-                                    ACPI_UINT32_MAX, ppi_callback, NULL,
-                                    tpm_device_name, &handle);
-       if (ACPI_FAILURE(status))
-               return -ENXIO;
-
-       status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
-                                           ACPI_TYPE_STRING);
-       if (ACPI_FAILURE(status))
-               return -ENOMEM;
-       strlcpy(version,
-               ((union acpi_object *)output.pointer)->string.pointer,
-               PPI_VERSION_LEN + 1);
-       kfree(output.pointer);
-       output.length = ACPI_ALLOCATE_BUFFER;
-       output.pointer = NULL;
        /*
         * the function to submit TPM operation request to pre-os environment
         * is updated with function index from SUBREQ to SUBREQ2 since PPI
         * version 1.1
         */
-       if (strcmp(version, "1.1") == -1)
-               params[2].integer.value = TPM_PPI_FN_SUBREQ;
-       else
-               params[2].integer.value = TPM_PPI_FN_SUBREQ2;
+       if (acpi_check_dsm(tpm_ppi_handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
+                          1 << TPM_PPI_FN_SUBREQ2))
+               func = TPM_PPI_FN_SUBREQ2;
+
        /*
         * PPI spec defines params[3].type as ACPI_TYPE_PACKAGE. Some BIOS
         * accept buffer/string/integer type, but some BIOS accept buffer/
         * string/package type. For PPI version 1.0 and 1.1, use buffer type
         * for compatibility, and use package type since 1.2 according to spec.
         */
-       if (strcmp(version, "1.2") == -1) {
-               params[3].type = ACPI_TYPE_BUFFER;
-               params[3].buffer.length = sizeof(req);
-               sscanf(buf, "%d", &req);
-               params[3].buffer.pointer = (char *)&req;
+       if (strcmp(tpm_ppi_version, "1.2") < 0) {
+               if (sscanf(buf, "%d", &req) != 1)
+                       return -EINVAL;
+               argv4.type = ACPI_TYPE_BUFFER;
+               argv4.buffer.length = sizeof(req);
+               argv4.buffer.pointer = (u8 *)&req;
+       } else {
+               tmp.type = ACPI_TYPE_INTEGER;
+               if (sscanf(buf, "%llu", &tmp.integer.value) != 1)
+                       return -EINVAL;
+       }
+
+       obj = tpm_eval_dsm(func, ACPI_TYPE_INTEGER, &argv4);
+       if (!obj) {
+               return -ENXIO;
        } else {
-               params[3].package.count = 1;
-               obj.type = ACPI_TYPE_INTEGER;
-               sscanf(buf, "%llu", &obj.integer.value);
-               params[3].package.elements = &obj;
+               ret = obj->integer.value;
+               ACPI_FREE(obj);
        }
 
-       status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
-                                           ACPI_TYPE_INTEGER);
-       if (ACPI_FAILURE(status))
-               return -ENOMEM;
-       ret = ((union acpi_object *)output.pointer)->integer.value;
        if (ret == 0)
-               status = (acpi_status)count;
-       else if (ret == 1)
-               status = -EPERM;
-       else
-               status = -EFAULT;
-       kfree(output.pointer);
-       return status;
+               return (acpi_status)count;
+
+       return (ret == 1) ? -EPERM : -EFAULT;
 }
 
 static ssize_t tpm_show_ppi_transition_action(struct device *dev,
                                              struct device_attribute *attr,
                                              char *buf)
 {
-       char version[PPI_VERSION_LEN + 1];
-       acpi_handle handle;
-       acpi_status status;
-       struct acpi_object_list input;
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       union acpi_object params[4];
        u32 ret;
-       char *info[] = {
+       acpi_status status;
+       union acpi_object *obj = NULL;
+       union acpi_object tmp = {
+               .buffer.type = ACPI_TYPE_BUFFER,
+               .buffer.length = 0,
+               .buffer.pointer = NULL
+       };
+
+       static char *info[] = {
                "None",
                "Shutdown",
                "Reboot",
                "OS Vendor-specific",
                "Error",
        };
-       input.count = 4;
-       ppi_assign_params(params, TPM_PPI_FN_VERSION);
-       input.pointer = params;
-       status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-                                    ACPI_UINT32_MAX, ppi_callback, NULL,
-                                    tpm_device_name, &handle);
-       if (ACPI_FAILURE(status))
-               return -ENXIO;
 
-       status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
-                                           ACPI_TYPE_STRING);
-       if (ACPI_FAILURE(status))
-               return -ENOMEM;
-       strlcpy(version,
-               ((union acpi_object *)output.pointer)->string.pointer,
-               PPI_VERSION_LEN + 1);
        /*
         * PPI spec defines params[3].type as empty package, but some platforms
         * (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for
         * compatibility, define params[3].type as buffer, if PPI version < 1.2
         */
-       if (strcmp(version, "1.2") == -1) {
-               params[3].type = ACPI_TYPE_BUFFER;
-               params[3].buffer.length =  0;
-               params[3].buffer.pointer = NULL;
+       if (strcmp(tpm_ppi_version, "1.2") < 0)
+               obj = &tmp;
+       obj = tpm_eval_dsm(TPM_PPI_FN_GETACT, ACPI_TYPE_INTEGER, obj);
+       if (!obj) {
+               return -ENXIO;
+       } else {
+               ret = obj->integer.value;
+               ACPI_FREE(obj);
        }
-       params[2].integer.value = TPM_PPI_FN_GETACT;
-       kfree(output.pointer);
-       output.length = ACPI_ALLOCATE_BUFFER;
-       output.pointer = NULL;
-       status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
-                                           ACPI_TYPE_INTEGER);
-       if (ACPI_FAILURE(status))
-               return -ENOMEM;
-       ret = ((union acpi_object *)output.pointer)->integer.value;
+
        if (ret < ARRAY_SIZE(info) - 1)
                status = scnprintf(buf, PAGE_SIZE, "%d: %s\n", ret, info[ret]);
        else
                status = scnprintf(buf, PAGE_SIZE, "%d: %s\n", ret,
                                   info[ARRAY_SIZE(info)-1]);
-       kfree(output.pointer);
        return status;
 }
 
@@ -275,27 +193,14 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
                                     struct device_attribute *attr,
                                     char *buf)
 {
-       acpi_handle handle;
-       acpi_status status;
-       struct acpi_object_list input;
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       union acpi_object params[4];
-       union acpi_object *ret_obj;
-       u64 req;
-
-       input.count = 4;
-       ppi_assign_params(params, TPM_PPI_FN_GETRSP);
-       input.pointer = params;
-       status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-                                    ACPI_UINT32_MAX, ppi_callback, NULL,
-                                    tpm_device_name, &handle);
-       if (ACPI_FAILURE(status))
+       acpi_status status = -EINVAL;
+       union acpi_object *obj, *ret_obj;
+       u64 req, res;
+
+       obj = tpm_eval_dsm(TPM_PPI_FN_GETRSP, ACPI_TYPE_PACKAGE, NULL);
+       if (!obj)
                return -ENXIO;
 
-       status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
-                                           ACPI_TYPE_PACKAGE);
-       if (ACPI_FAILURE(status))
-               return -ENOMEM;
        /*
         * parameter output.pointer should be of package type, including
         * 3 integers. The first means function return code, the second means
@@ -303,115 +208,82 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
         * the most recent TPM operation request. Only if the first is 0, and
         * the second integer is not 0, the response makes sense.
         */
-       ret_obj = ((union acpi_object *)output.pointer)->package.elements;
-       if (ret_obj->type != ACPI_TYPE_INTEGER) {
-               status = -EINVAL;
+       ret_obj = obj->package.elements;
+       if (obj->package.count < 3 ||
+           ret_obj[0].type != ACPI_TYPE_INTEGER ||
+           ret_obj[1].type != ACPI_TYPE_INTEGER ||
+           ret_obj[2].type != ACPI_TYPE_INTEGER)
                goto cleanup;
-       }
-       if (ret_obj->integer.value) {
+
+       if (ret_obj[0].integer.value) {
                status = -EFAULT;
                goto cleanup;
        }
-       ret_obj++;
-       if (ret_obj->type != ACPI_TYPE_INTEGER) {
-               status = -EINVAL;
-               goto cleanup;
-       }
-       if (ret_obj->integer.value) {
-               req = ret_obj->integer.value;
-               ret_obj++;
-               if (ret_obj->type != ACPI_TYPE_INTEGER) {
-                       status = -EINVAL;
-                       goto cleanup;
-               }
-               if (ret_obj->integer.value == 0)
+
+       req = ret_obj[1].integer.value;
+       res = ret_obj[2].integer.value;
+       if (req) {
+               if (res == 0)
                        status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req,
                                           "0: Success");
-               else if (ret_obj->integer.value == 0xFFFFFFF0)
+               else if (res == 0xFFFFFFF0)
                        status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req,
                                           "0xFFFFFFF0: User Abort");
-               else if (ret_obj->integer.value == 0xFFFFFFF1)
+               else if (res == 0xFFFFFFF1)
                        status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req,
                                           "0xFFFFFFF1: BIOS Failure");
-               else if (ret_obj->integer.value >= 1 &&
-                        ret_obj->integer.value <= 0x00000FFF)
+               else if (res >= 1 && res <= 0x00000FFF)
                        status = scnprintf(buf, PAGE_SIZE, "%llu %llu: %s\n",
-                                          req, ret_obj->integer.value,
-                                          "Corresponding TPM error");
+                                          req, res, "Corresponding TPM error");
                else
                        status = scnprintf(buf, PAGE_SIZE, "%llu %llu: %s\n",
-                                          req, ret_obj->integer.value,
-                                          "Error");
+                                          req, res, "Error");
        } else {
                status = scnprintf(buf, PAGE_SIZE, "%llu: %s\n",
-                                  ret_obj->integer.value, "No Recent Request");
+                                  req, "No Recent Request");
        }
+
 cleanup:
-       kfree(output.pointer);
+       ACPI_FREE(obj);
        return status;
 }
 
 static ssize_t show_ppi_operations(char *buf, u32 start, u32 end)
 {
-       char *str = buf;
-       char version[PPI_VERSION_LEN + 1];
-       acpi_handle handle;
-       acpi_status status;
-       struct acpi_object_list input;
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       union acpi_object params[4];
-       union acpi_object obj;
        int i;
        u32 ret;
-       char *info[] = {
+       char *str = buf;
+       union acpi_object *obj, tmp;
+       union acpi_object argv = ACPI_INIT_DSM_ARGV4(1, &tmp);
+
+       static char *info[] = {
                "Not implemented",
                "BIOS only",
                "Blocked for OS by BIOS",
                "User required",
                "User not required",
        };
-       input.count = 4;
-       ppi_assign_params(params, TPM_PPI_FN_VERSION);
-       input.pointer = params;
-       status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-                                    ACPI_UINT32_MAX, ppi_callback, NULL,
-                                    tpm_device_name, &handle);
-       if (ACPI_FAILURE(status))
-               return -ENXIO;
 
-       status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
-                                        ACPI_TYPE_STRING);
-       if (ACPI_FAILURE(status))
-               return -ENOMEM;
-
-       strlcpy(version,
-               ((union acpi_object *)output.pointer)->string.pointer,
-               PPI_VERSION_LEN + 1);
-       kfree(output.pointer);
-       output.length = ACPI_ALLOCATE_BUFFER;
-       output.pointer = NULL;
-       if (strcmp(version, "1.2") == -1)
+       if (!acpi_check_dsm(tpm_ppi_handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
+                           1 << TPM_PPI_FN_GETOPR))
                return -EPERM;
 
-       params[2].integer.value = TPM_PPI_FN_GETOPR;
-       params[3].package.count = 1;
-       obj.type = ACPI_TYPE_INTEGER;
-       params[3].package.elements = &obj;
+       tmp.integer.type = ACPI_TYPE_INTEGER;
        for (i = start; i <= end; i++) {
-               obj.integer.value = i;
-               status = acpi_evaluate_object_typed(handle, "_DSM",
-                        &input, &output, ACPI_TYPE_INTEGER);
-               if (ACPI_FAILURE(status))
+               tmp.integer.value = i;
+               obj = tpm_eval_dsm(TPM_PPI_FN_GETOPR, ACPI_TYPE_INTEGER, &argv);
+               if (!obj) {
                        return -ENOMEM;
+               } else {
+                       ret = obj->integer.value;
+                       ACPI_FREE(obj);
+               }
 
-               ret = ((union acpi_object *)output.pointer)->integer.value;
                if (ret > 0 && ret < ARRAY_SIZE(info))
                        str += scnprintf(str, PAGE_SIZE, "%d %d: %s\n",
                                         i, ret, info[ret]);
-               kfree(output.pointer);
-               output.length = ACPI_ALLOCATE_BUFFER;
-               output.pointer = NULL;
        }
+
        return str - buf;
 }
 
@@ -453,6 +325,12 @@ static struct attribute_group ppi_attr_grp = {
 
 int tpm_add_ppi(struct kobject *parent)
 {
+       /* Cache TPM ACPI handle and version string */
+       acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+                           ppi_callback, NULL, NULL, &tpm_ppi_handle);
+       if (tpm_ppi_handle == NULL)
+               return -ENODEV;
+
        return sysfs_create_group(parent, &ppi_attr_grp);
 }
 
index 074787281c9471c48eb6104e29d06e2cb03df51e..a6ef6acaa1c80b0e781b7f8b71310e7093e71648 100644 (file)
@@ -110,7 +110,7 @@ config DMI_SYSFS
 
 config ISCSI_IBFT_FIND
        bool "iSCSI Boot Firmware Table Attributes"
-       depends on X86
+       depends on X86 && ACPI
        default n
        help
          This option enables the kernel to find the region of memory
index ad0d6de938f3654aae0ccef2f02ba2d4abb6a1ef..13ec6283bf597481e83089226ed13dfc35fbc37f 100644 (file)
@@ -22,7 +22,6 @@
  *
  */
 #include <linux/acpi.h>
-#include <linux/acpi_io.h>
 #include "psb_drv.h"
 #include "psb_intel_reg.h"
 
index 41838eaa799c5afcb7510bae31118099d4d848a3..d4ae48b04cf2b127630e309192cce4c05509cbf4 100644 (file)
@@ -38,7 +38,6 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o \
          intel_ringbuffer.o \
          intel_overlay.o \
          intel_sprite.o \
-         intel_opregion.o \
          intel_sideband.o \
          intel_uncore.o \
          dvo_ch7xxx.o \
@@ -51,7 +50,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o \
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
 
-i915-$(CONFIG_ACPI)    += intel_acpi.o
+i915-$(CONFIG_ACPI)    += intel_acpi.o intel_opregion.o
 
 i915-$(CONFIG_DRM_I915_FBDEV) += intel_fbdev.o
 
index 90fcccba17b00da4a91ea2556b53a81e877356f0..1caa5e34fbe3d55825cd5b4340fbeb6575de4fa7 100644 (file)
@@ -2339,8 +2339,8 @@ extern void intel_i2c_reset(struct drm_device *dev);
 
 /* intel_opregion.c */
 struct intel_encoder;
-extern int intel_opregion_setup(struct drm_device *dev);
 #ifdef CONFIG_ACPI
+extern int intel_opregion_setup(struct drm_device *dev);
 extern void intel_opregion_init(struct drm_device *dev);
 extern void intel_opregion_fini(struct drm_device *dev);
 extern void intel_opregion_asle_intr(struct drm_device *dev);
@@ -2349,6 +2349,7 @@ extern int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 extern int intel_opregion_notify_adapter(struct drm_device *dev,
                                         pci_power_t state);
 #else
+static inline int intel_opregion_setup(struct drm_device *dev) { return 0; }
 static inline void intel_opregion_init(struct drm_device *dev) { return; }
 static inline void intel_opregion_fini(struct drm_device *dev) { return; }
 static inline void intel_opregion_asle_intr(struct drm_device *dev) { return; }
index dfff0907f70e53643093c3f6aa8d9258ab8dc5d5..d96eee1ae9c560bb1559c5e911e2a84ced425051 100644 (file)
@@ -6,14 +6,10 @@
 #include <linux/pci.h>
 #include <linux/acpi.h>
 #include <linux/vga_switcheroo.h>
-#include <acpi/acpi_drivers.h>
-
 #include <drm/drmP.h>
 #include "i915_drv.h"
 
 #define INTEL_DSM_REVISION_ID 1 /* For Calpella anyway... */
-
-#define INTEL_DSM_FN_SUPPORTED_FUNCTIONS 0 /* No args */
 #define INTEL_DSM_FN_PLATFORM_MUX_INFO 1 /* No args */
 
 static struct intel_dsm_priv {
@@ -28,61 +24,6 @@ static const u8 intel_dsm_guid[] = {
        0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c
 };
 
-static int intel_dsm(acpi_handle handle, int func)
-{
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       struct acpi_object_list input;
-       union acpi_object params[4];
-       union acpi_object *obj;
-       u32 result;
-       int ret = 0;
-
-       input.count = 4;
-       input.pointer = params;
-       params[0].type = ACPI_TYPE_BUFFER;
-       params[0].buffer.length = sizeof(intel_dsm_guid);
-       params[0].buffer.pointer = (char *)intel_dsm_guid;
-       params[1].type = ACPI_TYPE_INTEGER;
-       params[1].integer.value = INTEL_DSM_REVISION_ID;
-       params[2].type = ACPI_TYPE_INTEGER;
-       params[2].integer.value = func;
-       params[3].type = ACPI_TYPE_PACKAGE;
-       params[3].package.count = 0;
-       params[3].package.elements = NULL;
-
-       ret = acpi_evaluate_object(handle, "_DSM", &input, &output);
-       if (ret) {
-               DRM_DEBUG_DRIVER("failed to evaluate _DSM: %d\n", ret);
-               return ret;
-       }
-
-       obj = (union acpi_object *)output.pointer;
-
-       result = 0;
-       switch (obj->type) {
-       case ACPI_TYPE_INTEGER:
-               result = obj->integer.value;
-               break;
-
-       case ACPI_TYPE_BUFFER:
-               if (obj->buffer.length == 4) {
-                       result = (obj->buffer.pointer[0] |
-                               (obj->buffer.pointer[1] <<  8) |
-                               (obj->buffer.pointer[2] << 16) |
-                               (obj->buffer.pointer[3] << 24));
-                       break;
-               }
-       default:
-               ret = -EINVAL;
-               break;
-       }
-       if (result == 0x80000002)
-               ret = -ENODEV;
-
-       kfree(output.pointer);
-       return ret;
-}
-
 static char *intel_dsm_port_name(u8 id)
 {
        switch (id) {
@@ -137,83 +78,56 @@ static char *intel_dsm_mux_type(u8 type)
 
 static void intel_dsm_platform_mux_info(void)
 {
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       struct acpi_object_list input;
-       union acpi_object params[4];
-       union acpi_object *pkg;
-       int i, ret;
-
-       input.count = 4;
-       input.pointer = params;
-       params[0].type = ACPI_TYPE_BUFFER;
-       params[0].buffer.length = sizeof(intel_dsm_guid);
-       params[0].buffer.pointer = (char *)intel_dsm_guid;
-       params[1].type = ACPI_TYPE_INTEGER;
-       params[1].integer.value = INTEL_DSM_REVISION_ID;
-       params[2].type = ACPI_TYPE_INTEGER;
-       params[2].integer.value = INTEL_DSM_FN_PLATFORM_MUX_INFO;
-       params[3].type = ACPI_TYPE_PACKAGE;
-       params[3].package.count = 0;
-       params[3].package.elements = NULL;
-
-       ret = acpi_evaluate_object(intel_dsm_priv.dhandle, "_DSM", &input,
-                                  &output);
-       if (ret) {
-               DRM_DEBUG_DRIVER("failed to evaluate _DSM: %d\n", ret);
-               goto out;
+       int i;
+       union acpi_object *pkg, *connector_count;
+
+       pkg = acpi_evaluate_dsm_typed(intel_dsm_priv.dhandle, intel_dsm_guid,
+                       INTEL_DSM_REVISION_ID, INTEL_DSM_FN_PLATFORM_MUX_INFO,
+                       NULL, ACPI_TYPE_PACKAGE);
+       if (!pkg) {
+               DRM_DEBUG_DRIVER("failed to evaluate _DSM\n");
+               return;
        }
 
-       pkg = (union acpi_object *)output.pointer;
-
-       if (pkg->type == ACPI_TYPE_PACKAGE) {
-               union acpi_object *connector_count = &pkg->package.elements[0];
-               DRM_DEBUG_DRIVER("MUX info connectors: %lld\n",
-                         (unsigned long long)connector_count->integer.value);
-               for (i = 1; i < pkg->package.count; i++) {
-                       union acpi_object *obj = &pkg->package.elements[i];
-                       union acpi_object *connector_id =
-                               &obj->package.elements[0];
-                       union acpi_object *info = &obj->package.elements[1];
-                       DRM_DEBUG_DRIVER("Connector id: 0x%016llx\n",
-                                 (unsigned long long)connector_id->integer.value);
-                       DRM_DEBUG_DRIVER("  port id: %s\n",
-                              intel_dsm_port_name(info->buffer.pointer[0]));
-                       DRM_DEBUG_DRIVER("  display mux info: %s\n",
-                              intel_dsm_mux_type(info->buffer.pointer[1]));
-                       DRM_DEBUG_DRIVER("  aux/dc mux info: %s\n",
-                              intel_dsm_mux_type(info->buffer.pointer[2]));
-                       DRM_DEBUG_DRIVER("  hpd mux info: %s\n",
-                              intel_dsm_mux_type(info->buffer.pointer[3]));
-               }
+       connector_count = &pkg->package.elements[0];
+       DRM_DEBUG_DRIVER("MUX info connectors: %lld\n",
+                 (unsigned long long)connector_count->integer.value);
+       for (i = 1; i < pkg->package.count; i++) {
+               union acpi_object *obj = &pkg->package.elements[i];
+               union acpi_object *connector_id = &obj->package.elements[0];
+               union acpi_object *info = &obj->package.elements[1];
+               DRM_DEBUG_DRIVER("Connector id: 0x%016llx\n",
+                         (unsigned long long)connector_id->integer.value);
+               DRM_DEBUG_DRIVER("  port id: %s\n",
+                      intel_dsm_port_name(info->buffer.pointer[0]));
+               DRM_DEBUG_DRIVER("  display mux info: %s\n",
+                      intel_dsm_mux_type(info->buffer.pointer[1]));
+               DRM_DEBUG_DRIVER("  aux/dc mux info: %s\n",
+                      intel_dsm_mux_type(info->buffer.pointer[2]));
+               DRM_DEBUG_DRIVER("  hpd mux info: %s\n",
+                      intel_dsm_mux_type(info->buffer.pointer[3]));
        }
 
-out:
-       kfree(output.pointer);
+       ACPI_FREE(pkg);
 }
 
 static bool intel_dsm_pci_probe(struct pci_dev *pdev)
 {
        acpi_handle dhandle;
-       int ret;
 
        dhandle = ACPI_HANDLE(&pdev->dev);
        if (!dhandle)
                return false;
 
-       if (!acpi_has_method(dhandle, "_DSM")) {
+       if (!acpi_check_dsm(dhandle, intel_dsm_guid, INTEL_DSM_REVISION_ID,
+                           1 << INTEL_DSM_FN_PLATFORM_MUX_INFO)) {
                DRM_DEBUG_KMS("no _DSM method for intel device\n");
                return false;
        }
 
-       ret = intel_dsm(dhandle, INTEL_DSM_FN_SUPPORTED_FUNCTIONS);
-       if (ret < 0) {
-               DRM_DEBUG_KMS("failed to get supported _DSM functions\n");
-               return false;
-       }
-
        intel_dsm_priv.dhandle = dhandle;
-
        intel_dsm_platform_mux_info();
+
        return true;
 }
 
index 6d69a9bad86545c6a8cfc8e8ff86480d462c2132..9a8804bee5cdfd08276592672d35d83e564fc9ef 100644 (file)
@@ -28,7 +28,6 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/acpi.h>
-#include <linux/acpi_io.h>
 #include <acpi/video.h>
 
 #include <drm/drmP.h>
index 129120473f6c67bb0d90fcc366e3f140c558f79d..13c5af88a6019d8b1e976dbe8c2e919b9ec8f6fc 100644 (file)
@@ -87,55 +87,39 @@ mxm_shadow_dsm(struct nouveau_mxm *mxm, u8 version)
                0xB8, 0x9C, 0x79, 0xB6, 0x2F, 0xD5, 0x56, 0x65
        };
        u32 mxms_args[] = { 0x00000000 };
-       union acpi_object args[4] = {
-               /* _DSM MUID */
-               { .buffer.type = 3,
-                 .buffer.length = sizeof(muid),
-                 .buffer.pointer = muid,
-               },
-               /* spec says this can be zero to mean "highest revision", but
-                * of course there's at least one bios out there which fails
-                * unless you pass in exactly the version it supports..
-                */
-               { .integer.type = ACPI_TYPE_INTEGER,
-                 .integer.value = (version & 0xf0) << 4 | (version & 0x0f),
-               },
-               /* MXMS function */
-               { .integer.type = ACPI_TYPE_INTEGER,
-                 .integer.value = 0x00000010,
-               },
-               /* Pointer to MXMS arguments */
-               { .buffer.type = ACPI_TYPE_BUFFER,
-                 .buffer.length = sizeof(mxms_args),
-                 .buffer.pointer = (char *)mxms_args,
-               },
+       union acpi_object argv4 = {
+               .buffer.type = ACPI_TYPE_BUFFER,
+               .buffer.length = sizeof(mxms_args),
+               .buffer.pointer = (char *)mxms_args,
        };
-       struct acpi_object_list list = { ARRAY_SIZE(args), args };
-       struct acpi_buffer retn = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *obj;
        acpi_handle handle;
-       int ret;
+       int rev;
 
        handle = ACPI_HANDLE(&device->pdev->dev);
        if (!handle)
                return false;
 
-       ret = acpi_evaluate_object(handle, "_DSM", &list, &retn);
-       if (ret) {
-               nv_debug(mxm, "DSM MXMS failed: %d\n", ret);
+       /*
+        * spec says this can be zero to mean "highest revision", but
+        * of course there's at least one bios out there which fails
+        * unless you pass in exactly the version it supports..
+        */
+       rev = (version & 0xf0) << 4 | (version & 0x0f);
+       obj = acpi_evaluate_dsm(handle, muid, rev, 0x00000010, &argv4);
+       if (!obj) {
+               nv_debug(mxm, "DSM MXMS failed\n");
                return false;
        }
 
-       obj = retn.pointer;
        if (obj->type == ACPI_TYPE_BUFFER) {
                mxm->mxms = kmemdup(obj->buffer.pointer,
                                         obj->buffer.length, GFP_KERNEL);
-       } else
-       if (obj->type == ACPI_TYPE_INTEGER) {
+       } else if (obj->type == ACPI_TYPE_INTEGER) {
                nv_debug(mxm, "DSM MXMS returned 0x%llx\n", obj->integer.value);
        }
 
-       kfree(obj);
+       ACPI_FREE(obj);
        return mxm->mxms != NULL;
 }
 #endif
index ba0183fb84f3b871a4815552021174e870f780e8..3c149617cfcbaabb49a0253fd405fe52930bc0af 100644 (file)
@@ -1,15 +1,10 @@
 #include <linux/pci.h>
 #include <linux/acpi.h>
 #include <linux/slab.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/video.h>
-#include <acpi/acpi.h>
 #include <linux/mxm-wmi.h>
-
 #include <linux/vga_switcheroo.h>
-
 #include <drm/drm_edid.h>
+#include <acpi/video.h>
 
 #include "nouveau_drm.h"
 #include "nouveau_acpi.h"
@@ -78,124 +73,66 @@ static const char nouveau_op_dsm_muid[] = {
 
 static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result)
 {
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       struct acpi_object_list input;
-       union acpi_object params[4];
+       int i;
        union acpi_object *obj;
-       int i, err;
        char args_buff[4];
+       union acpi_object argv4 = {
+               .buffer.type = ACPI_TYPE_BUFFER,
+               .buffer.length = 4,
+               .buffer.pointer = args_buff
+       };
 
-       input.count = 4;
-       input.pointer = params;
-       params[0].type = ACPI_TYPE_BUFFER;
-       params[0].buffer.length = sizeof(nouveau_op_dsm_muid);
-       params[0].buffer.pointer = (char *)nouveau_op_dsm_muid;
-       params[1].type = ACPI_TYPE_INTEGER;
-       params[1].integer.value = 0x00000100;
-       params[2].type = ACPI_TYPE_INTEGER;
-       params[2].integer.value = func;
-       params[3].type = ACPI_TYPE_BUFFER;
-       params[3].buffer.length = 4;
        /* ACPI is little endian, AABBCCDD becomes {DD,CC,BB,AA} */
        for (i = 0; i < 4; i++)
                args_buff[i] = (arg >> i * 8) & 0xFF;
-       params[3].buffer.pointer = args_buff;
-
-       err = acpi_evaluate_object(handle, "_DSM", &input, &output);
-       if (err) {
-               printk(KERN_INFO "failed to evaluate _DSM: %d\n", err);
-               return err;
-       }
-
-       obj = (union acpi_object *)output.pointer;
 
-       if (obj->type == ACPI_TYPE_INTEGER)
-               if (obj->integer.value == 0x80000002) {
-                       return -ENODEV;
-               }
-
-       if (obj->type == ACPI_TYPE_BUFFER) {
-               if (obj->buffer.length == 4 && result) {
-                       *result = 0;
+       *result = 0;
+       obj = acpi_evaluate_dsm_typed(handle, nouveau_op_dsm_muid, 0x00000100,
+                                     func, &argv4, ACPI_TYPE_BUFFER);
+       if (!obj) {
+               acpi_handle_info(handle, "failed to evaluate _DSM\n");
+               return AE_ERROR;
+       } else {
+               if (obj->buffer.length == 4) {
                        *result |= obj->buffer.pointer[0];
                        *result |= (obj->buffer.pointer[1] << 8);
                        *result |= (obj->buffer.pointer[2] << 16);
                        *result |= (obj->buffer.pointer[3] << 24);
                }
+               ACPI_FREE(obj);
        }
 
-       kfree(output.pointer);
        return 0;
 }
 
-static int nouveau_dsm(acpi_handle handle, int func, int arg, uint32_t *result)
+static int nouveau_dsm(acpi_handle handle, int func, int arg)
 {
-       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-       struct acpi_object_list input;
-       union acpi_object params[4];
+       int ret = 0;
        union acpi_object *obj;
-       int err;
-
-       input.count = 4;
-       input.pointer = params;
-       params[0].type = ACPI_TYPE_BUFFER;
-       params[0].buffer.length = sizeof(nouveau_dsm_muid);
-       params[0].buffer.pointer = (char *)nouveau_dsm_muid;
-       params[1].type = ACPI_TYPE_INTEGER;
-       params[1].integer.value = 0x00000102;
-       params[2].type = ACPI_TYPE_INTEGER;
-       params[2].integer.value = func;
-       params[3].type = ACPI_TYPE_INTEGER;
-       params[3].integer.value = arg;
-
-       err = acpi_evaluate_object(handle, "_DSM", &input, &output);
-       if (err) {
-               printk(KERN_INFO "failed to evaluate _DSM: %d\n", err);
-               return err;
-       }
-
-       obj = (union acpi_object *)output.pointer;
-
-       if (obj->type == ACPI_TYPE_INTEGER)
+       union acpi_object argv4 = {
+               .integer.type = ACPI_TYPE_INTEGER,
+               .integer.value = arg,
+       };
+
+       obj = acpi_evaluate_dsm_typed(handle, nouveau_dsm_muid, 0x00000102,
+                                     func, &argv4, ACPI_TYPE_INTEGER);
+       if (!obj) {
+               acpi_handle_info(handle, "failed to evaluate _DSM\n");
+               return AE_ERROR;
+       } else {
                if (obj->integer.value == 0x80000002)
-                       return -ENODEV;
-
-       if (obj->type == ACPI_TYPE_BUFFER) {
-               if (obj->buffer.length == 4 && result) {
-                       *result = 0;
-                       *result |= obj->buffer.pointer[0];
-                       *result |= (obj->buffer.pointer[1] << 8);
-                       *result |= (obj->buffer.pointer[2] << 16);
-                       *result |= (obj->buffer.pointer[3] << 24);
-               }
+                       ret = -ENODEV;
+               ACPI_FREE(obj);
        }
 
-       kfree(output.pointer);
-       return 0;
-}
-
-/* Returns 1 if a DSM function is usable and 0 otherwise */
-static int nouveau_test_dsm(acpi_handle test_handle,
-       int (*dsm_func)(acpi_handle, int, int, uint32_t *),
-       int sfnc)
-{
-       u32 result = 0;
-
-       /* Function 0 returns a Buffer containing available functions. The args
-        * parameter is ignored for function 0, so just put 0 in it */
-       if (dsm_func(test_handle, 0, 0, &result))
-               return 0;
-
-       /* ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported. If
-        * the n-th bit is enabled, function n is supported */
-       return result & 1 && result & (1 << sfnc);
+       return ret;
 }
 
 static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id)
 {
        mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0);
        mxm_wmi_call_mxds(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0);
-       return nouveau_dsm(handle, NOUVEAU_DSM_LED, mux_id, NULL);
+       return nouveau_dsm(handle, NOUVEAU_DSM_LED, mux_id);
 }
 
 static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state)
@@ -205,7 +142,7 @@ static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switchero
                arg = NOUVEAU_DSM_POWER_SPEED;
        else
                arg = NOUVEAU_DSM_POWER_STAMINA;
-       nouveau_dsm(handle, NOUVEAU_DSM_POWER, arg, NULL);
+       nouveau_dsm(handle, NOUVEAU_DSM_POWER, arg);
        return 0;
 }
 
@@ -265,11 +202,12 @@ static int nouveau_dsm_pci_probe(struct pci_dev *pdev)
                nouveau_dsm_priv.other_handle = dhandle;
                return false;
        }
-       if (nouveau_test_dsm(dhandle, nouveau_dsm, NOUVEAU_DSM_POWER))
+       if (acpi_check_dsm(dhandle, nouveau_dsm_muid, 0x00000102,
+                          1 << NOUVEAU_DSM_POWER))
                retval |= NOUVEAU_DSM_HAS_MUX;
 
-       if (nouveau_test_dsm(dhandle, nouveau_optimus_dsm,
-               NOUVEAU_DSM_OPTIMUS_CAPS))
+       if (acpi_check_dsm(dhandle, nouveau_op_dsm_muid, 0x00000100,
+                          1 << NOUVEAU_DSM_OPTIMUS_CAPS))
                retval |= NOUVEAU_DSM_HAS_OPT;
 
        if (retval & NOUVEAU_DSM_HAS_OPT) {
index 98a9074b306b640644f576e928d4e28701495bb4..77e9d07c55b6701cbdb0a55bcbc9b68954e5c0d7 100644 (file)
 #include <linux/acpi.h>
 #include <linux/slab.h>
 #include <linux/power_supply.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/acpi_bus.h>
+#include <linux/vga_switcheroo.h>
 #include <acpi/video.h>
-
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include "radeon.h"
 #include "radeon_acpi.h"
 #include "atom.h"
 
-#include <linux/vga_switcheroo.h>
-
 #define ACPI_AC_CLASS           "ac_adapter"
 
 extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev);
index 5f7e55f4b7f052e29f754f78cabe8dd6a4593fb4..d22668f7d9821c613c29b7836da21110a2aed555 100644 (file)
@@ -850,37 +850,23 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
                0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45,
                0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE,
        };
-       union acpi_object params[4];
-       struct acpi_object_list input;
+       union acpi_object *obj;
        struct acpi_device *adev;
-       unsigned long long value;
        acpi_handle handle;
 
        handle = ACPI_HANDLE(&client->dev);
        if (!handle || acpi_bus_get_device(handle, &adev))
                return -ENODEV;
 
-       input.count = ARRAY_SIZE(params);
-       input.pointer = params;
-
-       params[0].type = ACPI_TYPE_BUFFER;
-       params[0].buffer.length = sizeof(i2c_hid_guid);
-       params[0].buffer.pointer = i2c_hid_guid;
-       params[1].type = ACPI_TYPE_INTEGER;
-       params[1].integer.value = 1;
-       params[2].type = ACPI_TYPE_INTEGER;
-       params[2].integer.value = 1; /* HID function */
-       params[3].type = ACPI_TYPE_PACKAGE;
-       params[3].package.count = 0;
-       params[3].package.elements = NULL;
-
-       if (ACPI_FAILURE(acpi_evaluate_integer(handle, "_DSM", &input,
-                                                               &value))) {
+       obj = acpi_evaluate_dsm_typed(handle, i2c_hid_guid, 1, 1, NULL,
+                                     ACPI_TYPE_INTEGER);
+       if (!obj) {
                dev_err(&client->dev, "device _DSM execution failed\n");
                return -ENODEV;
        }
 
-       pdata->hid_descriptor_address = value;
+       pdata->hid_descriptor_address = obj->integer.value;
+       ACPI_FREE(obj);
 
        return 0;
 }
index 48aad4faea068e88cbe61976aa3444d9c8a80a58..077bb1bdac34ef4ed87c65c7bf0d204fd42001b4 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/sysctl.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
 #include <linux/completion.h>
 #include <linux/hyperv.h>
 #include <linux/kernel_stat.h>
@@ -39,7 +38,6 @@
 #include <asm/mshyperv.h>
 #include "hyperv_vmbus.h"
 
-
 static struct acpi_device  *hv_acpi_dev;
 
 static struct tasklet_struct msg_dpc;
index 6a34f7f48eb9172272a25d4467bf1a190f7dc1e3..579bdf93be433b54a23fa8827badd7ace8dbb762 100644 (file)
@@ -30,8 +30,7 @@
 #include <linux/sched.h>
 #include <linux/time.h>
 #include <linux/err.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/acpi_bus.h>
+#include <linux/acpi.h>
 
 #define ACPI_POWER_METER_NAME          "power_meter"
 ACPI_MODULE_NAME(ACPI_POWER_METER_NAME);
index dafc63c6932dfa47001a0269fc283984c16c321e..ae208f61219804cbac02bc850582c1ad7cfc5f84 100644 (file)
 #include <linux/dmi.h>
 #include <linux/jiffies.h>
 #include <linux/err.h>
-
-#include <acpi/acpi.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/acpi_bus.h>
-
+#include <linux/acpi.h>
 
 #define ATK_HID "ATK0110"
 
index d9e1f7ccfe6f086df549160a88ca191e52fca32f..b6940992a6ff95c699eddb8c7e2fb484a2f16ed3 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <acpi/acpi.h>
 #include <linux/ide.h>
 #include <linux/pci.h>
 #include <linux/dmi.h>
@@ -98,6 +97,17 @@ bool ide_port_acpi(ide_hwif_t *hwif)
        return ide_noacpi == 0 && hwif->acpidata;
 }
 
+static acpi_handle acpi_get_child(acpi_handle handle, u64 addr)
+{
+       struct acpi_device *adev;
+
+       if (!handle || acpi_bus_get_device(handle, &adev))
+               return NULL;
+
+       adev = acpi_find_child_device(adev, addr, false);
+       return adev ? adev->handle : NULL;
+}
+
 /**
  * ide_get_dev_handle - finds acpi_handle and PCI device.function
  * @dev: device to locate
index 797ed29a36ea7969765e90641d15f3a66e982db3..282186e532909fbfdbc79274b73226fe92eca577 100644 (file)
@@ -644,39 +644,10 @@ static int __init intel_idle_cpuidle_driver_init(void)
  */
 static int intel_idle_cpu_init(int cpu)
 {
-       int cstate;
        struct cpuidle_device *dev;
 
        dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
 
-       dev->state_count = 1;
-
-       for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
-               int num_substates, mwait_hint, mwait_cstate, mwait_substate;
-
-               if (cpuidle_state_table[cstate].enter == NULL)
-                       break;
-
-               if (cstate + 1 > max_cstate) {
-                       printk(PREFIX "max_cstate %d reached\n", max_cstate);
-                       break;
-               }
-
-               mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
-               mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint);
-               mwait_substate = MWAIT_HINT2SUBSTATE(mwait_hint);
-
-               /* does the state exist in CPUID.MWAIT? */
-               num_substates = (mwait_substates >> ((mwait_cstate + 1) * 4))
-                                       & MWAIT_SUBSTATE_MASK;
-
-               /* if sub-state in table is not enumerated by CPUID */
-               if ((mwait_substate + 1) > num_substates)
-                       continue;
-
-               dev->state_count += 1;
-       }
-
        dev->cpu = cpu;
 
        if (cpuidle_register_device(dev)) {
@@ -688,6 +659,9 @@ static int intel_idle_cpu_init(int cpu)
        if (icpu->auto_demotion_disable_flags)
                smp_call_function_single(cpu, auto_demotion_disable, NULL, 1);
 
+       if (icpu->disable_promotion_to_c1e)
+               smp_call_function_single(cpu, c1e_promotion_disable, NULL, 1);
+
        return 0;
 }
 
index 5d4402365a5207258dbd9b4b7d68f18489fa1598..d781b5e520655f074071fb6fc6f9a6e9390086bd 100644 (file)
@@ -28,8 +28,8 @@
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/types.h>
+#include <linux/acpi.h>
 #include <asm/uaccess.h>
-#include <acpi/acpi_drivers.h>
 
 #define ACPI_ATLAS_NAME                "Atlas ACPI"
 #define ACPI_ATLAS_CLASS       "Atlas"
index 8f798be6e398d98ccacc5ba85f3f5b76c4096683..28b4bea7c1094d79a483ee5256c21a91d3829396 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/msi.h>
 #include <linux/amd-iommu.h>
 #include <linux/export.h>
-#include <acpi/acpi.h>
 #include <asm/pci-direct.h>
 #include <asm/iommu.h>
 #include <asm/gart.h>
index bab10b1002fbf04bae1fe8e2b36cbb6f280dea51..0cb7528b30a134416b4343b08a458f80dcb6aecf 100644 (file)
@@ -6,11 +6,11 @@
 #include <linux/hpet.h>
 #include <linux/pci.h>
 #include <linux/irq.h>
+#include <linux/intel-iommu.h>
+#include <linux/acpi.h>
 #include <asm/io_apic.h>
 #include <asm/smp.h>
 #include <asm/cpu.h>
-#include <linux/intel-iommu.h>
-#include <acpi/acpi.h>
 #include <asm/irq_remapping.h>
 #include <asm/pci-direct.h>
 #include <asm/msidef.h>
index 157b570ba343e4648b796e7330e7b75bc052d00a..92d1ba8e8153ab9849ab51037804747cd37df7f1 100644 (file)
@@ -308,7 +308,7 @@ static void sdio_acpi_set_handle(struct sdio_func *func)
        struct mmc_host *host = func->card->host;
        u64 addr = (host->slotno << 16) | func->num;
 
-       acpi_preset_companion(&func->dev, ACPI_HANDLE(host->parent), addr);
+       acpi_preset_companion(&func->dev, ACPI_COMPANION(host->parent), addr);
 }
 #else
 static inline void sdio_acpi_set_handle(struct sdio_func *func) {}
index e86439283a5d1911933eed185e22a50146093968..4f0c40d405fc17fe387b21737945f08f9a071718 100644 (file)
@@ -491,7 +491,7 @@ static void acpiphp_bus_add(acpi_handle handle)
 
        acpi_bus_scan(handle);
        acpi_bus_get_device(handle, &adev);
-       if (adev)
+       if (acpi_device_enumerated(adev))
                acpi_device_set_power(adev, ACPI_STATE_D0);
 }
 
index ecfac7e72d91ae29a3ec8a5b6e8d159d0f7b7178..8dcccffd6e216b8529da5530019fe557e0f61ff1 100644 (file)
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <acpi/acpi_bus.h>
 #include <linux/sysfs.h>
 #include <linux/kobject.h>
-#include <asm/uaccess.h>
 #include <linux/moduleparam.h>
 #include <linux/pci.h>
+#include <asm/uaccess.h>
 
 #include "acpiphp.h"
 #include "../pci.h"
index 21e865ded1dce01fde77bb29312e2a653be6b4fa..24e147cae667e33dd46346dddeb994e96e868f4e 100644 (file)
@@ -163,8 +163,6 @@ static inline const char *slot_name(struct slot *slot)
 }
 
 #ifdef CONFIG_ACPI
-#include <acpi/acpi.h>
-#include <acpi/acpi_bus.h>
 #include <linux/pci-acpi.h>
 
 void __init pciehp_acpi_slot_detection_init(void);
index 50ce6809829836c38d4aedfa58aeb642b126d9df..2122b2bf006f37576d5bb2e3a22190c5ccacba00 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/module.h>
 #include <linux/acpi.h>
 #include <linux/slab.h>
-#include <acpi/acpi_bus.h>
 
 struct ioapic {
        acpi_handle     handle;
index f7ebdba14bde9bc1c7e3dd702bc6e47506067ff5..733a8222b13fcd9b554812beba2b0c7541bbe201 100644 (file)
@@ -12,9 +12,6 @@
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <linux/pci-aspm.h>
-#include <acpi/acpi.h>
-#include <acpi/acpi_bus.h>
-
 #include <linux/pci-acpi.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_qos.h>
@@ -306,10 +303,10 @@ void acpi_pci_remove_bus(struct pci_bus *bus)
 }
 
 /* ACPI bus type */
-static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
+static struct acpi_device *acpi_pci_find_companion(struct device *dev)
 {
        struct pci_dev *pci_dev = to_pci_dev(dev);
-       bool is_bridge;
+       bool check_children;
        u64 addr;
 
        /*
@@ -317,14 +314,12 @@ static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
         * is set only after acpi_pci_find_device() has been called for the
         * given device.
         */
-       is_bridge = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
+       check_children = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
                        || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
        /* Please ref to ACPI spec for the syntax of _ADR */
        addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
-       *handle = acpi_find_child(ACPI_HANDLE(dev->parent), addr, is_bridge);
-       if (!*handle)
-               return -ENODEV;
-       return 0;
+       return acpi_find_child_device(ACPI_COMPANION(dev->parent), addr,
+                                     check_children);
 }
 
 static void pci_acpi_setup(struct device *dev)
@@ -367,7 +362,7 @@ static bool pci_acpi_bus_match(struct device *dev)
 static struct acpi_bus_type acpi_pci_bus = {
        .name = "PCI",
        .match = pci_acpi_bus_match,
-       .find_device = acpi_pci_find_device,
+       .find_companion = acpi_pci_find_companion,
        .setup = pci_acpi_setup,
        .cleanup = pci_acpi_cleanup,
 };
index d51f45aa669e5ff9184daab1df72776e8165aa84..d2d1ceccad4b58c156fd9506987e313fa3b0bd3a 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/nls.h>
 #include <linux/acpi.h>
 #include <linux/pci-acpi.h>
-#include <acpi/acpi_bus.h>
 #include "pci.h"
 
 #define        DEVICE_LABEL_DSM        0x07
@@ -187,7 +186,6 @@ static const char device_label_dsm_uuid[] = {
 };
 
 enum acpi_attr_enum {
-       ACPI_ATTR_NONE = 0,
        ACPI_ATTR_LABEL_SHOW,
        ACPI_ATTR_INDEX_SHOW,
 };
@@ -195,84 +193,61 @@ enum acpi_attr_enum {
 static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
 {
        int len;
-       len = utf16s_to_utf8s((const wchar_t *)obj->
-                             package.elements[1].string.pointer,
-                             obj->package.elements[1].string.length,
+       len = utf16s_to_utf8s((const wchar_t *)obj->string.pointer,
+                             obj->string.length,
                              UTF16_LITTLE_ENDIAN,
                              buf, PAGE_SIZE);
        buf[len] = '\n';
 }
 
 static int
-dsm_get_label(acpi_handle handle, int func,
-             struct acpi_buffer *output,
-             char *buf, enum acpi_attr_enum attribute)
+dsm_get_label(struct device *dev, char *buf, enum acpi_attr_enum attr)
 {
-       struct acpi_object_list input;
-       union acpi_object params[4];
-       union acpi_object *obj;
-       int len = 0;
-
-       int err;
-
-       input.count = 4;
-       input.pointer = params;
-       params[0].type = ACPI_TYPE_BUFFER;
-       params[0].buffer.length = sizeof(device_label_dsm_uuid);
-       params[0].buffer.pointer = (char *)device_label_dsm_uuid;
-       params[1].type = ACPI_TYPE_INTEGER;
-       params[1].integer.value = 0x02;
-       params[2].type = ACPI_TYPE_INTEGER;
-       params[2].integer.value = func;
-       params[3].type = ACPI_TYPE_PACKAGE;
-       params[3].package.count = 0;
-       params[3].package.elements = NULL;
-
-       err = acpi_evaluate_object(handle, "_DSM", &input, output);
-       if (err)
+       acpi_handle handle;
+       union acpi_object *obj, *tmp;
+       int len = -1;
+
+       handle = ACPI_HANDLE(dev);
+       if (!handle)
                return -1;
 
-       obj = (union acpi_object *)output->pointer;
-
-       switch (obj->type) {
-       case ACPI_TYPE_PACKAGE:
-               if (obj->package.count != 2)
-                       break;
-               len = obj->package.elements[0].integer.value;
-               if (buf) {
-                       if (attribute == ACPI_ATTR_INDEX_SHOW)
-                               scnprintf(buf, PAGE_SIZE, "%llu\n",
-                               obj->package.elements[0].integer.value);
-                       else if (attribute == ACPI_ATTR_LABEL_SHOW)
-                               dsm_label_utf16s_to_utf8s(obj, buf);
-                       kfree(output->pointer);
-                       return strlen(buf);
-               }
-               kfree(output->pointer);
-               return len;
-       break;
-       default:
-               kfree(output->pointer);
+       obj = acpi_evaluate_dsm(handle, device_label_dsm_uuid, 0x2,
+                               DEVICE_LABEL_DSM, NULL);
+       if (!obj)
+               return -1;
+
+       tmp = obj->package.elements;
+       if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
+           tmp[0].type == ACPI_TYPE_INTEGER &&
+           tmp[1].type == ACPI_TYPE_STRING) {
+               /*
+                * The second string element is optional even when
+                * this _DSM is implemented; when not implemented,
+                * this entry must return a null string.
+                */
+               if (attr == ACPI_ATTR_INDEX_SHOW)
+                       scnprintf(buf, PAGE_SIZE, "%llu\n", tmp->integer.value);
+               else if (attr == ACPI_ATTR_LABEL_SHOW)
+                       dsm_label_utf16s_to_utf8s(tmp + 1, buf);
+               len = strlen(buf) > 0 ? strlen(buf) : -1;
        }
-       return -1;
+
+       ACPI_FREE(obj);
+
+       return len;
 }
 
 static bool
 device_has_dsm(struct device *dev)
 {
        acpi_handle handle;
-       struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
 
        handle = ACPI_HANDLE(dev);
-
        if (!handle)
-               return FALSE;
+               return false;
 
-       if (dsm_get_label(handle, DEVICE_LABEL_DSM, &output, NULL,
-                         ACPI_ATTR_NONE) > 0)
-               return TRUE;
-
-       return FALSE;
+       return !!acpi_check_dsm(handle, device_label_dsm_uuid, 0x2,
+                               1 << DEVICE_LABEL_DSM);
 }
 
 static umode_t
@@ -291,44 +266,13 @@ acpi_index_string_exist(struct kobject *kobj, struct attribute *attr, int n)
 static ssize_t
 acpilabel_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
-       acpi_handle handle;
-       int length;
-
-       handle = ACPI_HANDLE(dev);
-
-       if (!handle)
-               return -1;
-
-       length = dsm_get_label(handle, DEVICE_LABEL_DSM,
-                              &output, buf, ACPI_ATTR_LABEL_SHOW);
-
-       if (length < 1)
-               return -1;
-
-       return length;
+       return dsm_get_label(dev, buf, ACPI_ATTR_LABEL_SHOW);
 }
 
 static ssize_t
 acpiindex_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
-       acpi_handle handle;
-       int length;
-
-       handle = ACPI_HANDLE(dev);
-
-       if (!handle)
-               return -1;
-
-       length = dsm_get_label(handle, DEVICE_LABEL_DSM,
-                              &output, buf, ACPI_ATTR_INDEX_SHOW);
-
-       if (length < 0)
-               return -1;
-
-       return length;
-
+       return dsm_get_label(dev, buf, ACPI_ATTR_INDEX_SHOW);
 }
 
 static struct device_attribute acpi_attr_label = {
index c9076bdaf2c18fc9a34c3d3f906cd333971f57e5..c91f69b39db4b8c637d5182eb5f8f85aed1bf79b 100644 (file)
@@ -41,8 +41,6 @@
 #include <linux/slab.h>
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
-
-#include <acpi/acpi_drivers.h>
 #include <acpi/video.h>
 
 MODULE_AUTHOR("Carlos Corbacho");
index 594323a926cf0b8c62c4accfd88d297fe0caa567..7f4dc6f51f8afdf9df7984818585e10bf2047280 100644 (file)
@@ -53,8 +53,7 @@
 #include <linux/rfkill.h>
 #include <linux/slab.h>
 #include <linux/dmi.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/acpi_bus.h>
+#include <linux/acpi.h>
 
 #define ASUS_LAPTOP_VERSION    "0.42"
 
index 19c313b056c334c771e678b05146ee7676e7edac..df7ecb9ecd9d7c95b66cdbc79f4f17bfaf4bf49c 100644 (file)
@@ -45,8 +45,7 @@
 #include <linux/seq_file.h>
 #include <linux/platform_device.h>
 #include <linux/thermal.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <acpi/video.h>
 
 #include "asus-wmi.h"
index 6dfa8d3b4eec22dfd826e6d7de7cc811d565340b..70d355a9ae2cc2f7cdc2efb04941a2c76688139f 100644 (file)
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <linux/backlight.h>
 #include <linux/input.h>
 #include <linux/rfkill.h>
 
 MODULE_LICENSE("GPL");
 
-
 struct cmpc_accel {
        int sensitivity;
        int g_select;
index bcf8cc6b5537cca1a1c3ad016d700ca3f30104a4..dbc97a33bbc8ea2cbd61590590f533c13680a3a4 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/types.h>
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
-#include <acpi/acpi_drivers.h>
 #include <linux/acpi.h>
 #include <linux/string.h>
 
index 60e0900bc117995e6373bfb5bedfcc1c8aac2aed..390e8e33d5e31b77d67c7d7a1a8c659ead20e791 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/types.h>
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
-#include <acpi/acpi_drivers.h>
 #include <linux/acpi.h>
 #include <linux/string.h>
 #include <linux/dmi.h>
index dec68e7a99c79482f5f7cf4eb78b98bd0e2cd58d..bcde1ea02dd36ecb7024292cf03187edeab1fdd6 100644 (file)
@@ -28,8 +28,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/slab.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/acpi_bus.h>
+#include <linux/acpi.h>
 #include <linux/uaccess.h>
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
index af67e6e56ebbf3165d6c315daf6e88b155328d8f..6112933f627834cc1c4561feb68a3edc28492e5e 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/input/sparse-keymap.h>
 #include <linux/dmi.h>
 #include <linux/fb.h>
-#include <acpi/acpi_bus.h>
+#include <linux/acpi.h>
 
 #include "asus-wmi.h"
 
index a8e43cf70fac96309d7b689265b7c2b6ba2a19db..aff4d0670edfec733e131c0137fd82f70e0d2206 100644 (file)
@@ -36,7 +36,7 @@
 #include <linux/uaccess.h>
 #include <linux/leds.h>
 #include <linux/atomic.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include "../../misc/lis3lv02d/lis3lv02d.h"
 
 #define DRIVER_NAME     "hp_accel"
index 19ec95147f6925d1de52e99886f7efc6a10dff7a..6dd060a0bb65293d47a2d02669a62785403b8ae0 100644 (file)
@@ -26,8 +26,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <linux/rfkill.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
index a2083a9e5662d660fd95cbb297815aa0570c8268..d45bca34bf1b3bc935f5dc9b729fd87219cf4825 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 MODULE_LICENSE("GPL");
 
index 1838400dc0360615f799fac64a82b51f7efb9c17..04cf5dffdfd9152436719e69955df00afe30e144 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 MODULE_LICENSE("GPL");
 
index 11244f8703c402c876fb34b0e107383781661416..e8b46d2c468c963b37f338534b40aad814ac8792 100644 (file)
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/pm.h>
-
 #include <linux/thermal.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 MODULE_AUTHOR("Thomas Sujith");
 MODULE_AUTHOR("Zhang Rui");
index f6f18cde0f11c70f035e88c1da80f96506e0b3ab..4bc96041678573ec89eed8cf8c0e185f7e53d864 100644 (file)
@@ -50,9 +50,6 @@
 #include <linux/platform_device.h>
 #include <linux/dmi.h>
 #include <linux/rfkill.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-
 
 #define DRIVER_NAME    "intel_oaktrail"
 #define DRIVER_VERSION "0.4ac1"
index 0aea63b3729a4481ece3bc5d1c8dfb041fe0f2bc..3c59c0a3ee0f0f2d57a895f853d6915c37d39822 100644 (file)
@@ -20,8 +20,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 MODULE_AUTHOR("Dave Airlie");
 MODULE_DESCRIPTION("MXM WMI Driver");
index 3008fd20572e96a2d93823c4d15db27592fed2e2..609d38779b2680175660557b1093fa1026c91aad 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/uaccess.h>
 #include <linux/slab.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
 
-
 #ifndef ACPI_HOTKEY_COMPONENT
 #define ACPI_HOTKEY_COMPONENT  0x10000000
 #endif
index 47ae0c47d4b5ccf67749cc110f86788e7c74753f..c9f6e511daa639f9656f6e96de7603be944e934b 100644 (file)
@@ -24,8 +24,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>");
 MODULE_DESCRIPTION("pvpanic device driver");
index cae7098e9b0d70adf271eb9c31a1e833919a54b1..5413f62d2e6136b62327abdd0d32c8f000b3c531 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/backlight.h>
 #include <linux/dmi.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 #define SAMSUNGQ10_BL_MAX_INTENSITY 7
 
index fb233ae7bb0e3e8374691818cfe61125e66371a5..563e4f595f836c1d1ad966688d61c33e4a8d33d5 100644 (file)
@@ -61,9 +61,6 @@
 #include <linux/workqueue.h>
 #include <linux/acpi.h>
 #include <linux/slab.h>
-#include <acpi/acpi_drivers.h>
-#include <acpi/acpi_bus.h>
-#include <asm/uaccess.h>
 #include <linux/sonypi.h>
 #include <linux/sony-laptop.h>
 #include <linux/rfkill.h>
@@ -71,6 +68,7 @@
 #include <linux/poll.h>
 #include <linux/miscdevice.h>
 #endif
+#include <asm/uaccess.h>
 
 #define dprintk(fmt, ...)                      \
 do {                                           \
index 9b93fdb61ed7c03733ead31aaa7f0ef632a6bd00..6a6ea28a7e51df054ff2f514fde39d7d9f10b264 100644 (file)
@@ -32,9 +32,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
-#include <acpi/acpi.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <linux/platform_device.h>
 
 #define GUID "C364AC71-36DB-495A-8494-B439D472A505"
index 58b0274d24cc2968e35e6a9cdad75b1533c35e2d..defb6afc1409cc7fff0863d6829c5c26478b6a4a 100644 (file)
@@ -61,7 +61,6 @@
 #include <linux/freezer.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
-
 #include <linux/nvram.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/input.h>
 #include <linux/leds.h>
 #include <linux/rfkill.h>
-#include <asm/uaccess.h>
-
 #include <linux/dmi.h>
 #include <linux/jiffies.h>
 #include <linux/workqueue.h>
-
+#include <linux/acpi.h>
+#include <linux/pci_ids.h>
+#include <linux/thinkpad_acpi.h>
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/initval.h>
-
-#include <acpi/acpi_drivers.h>
-
-#include <linux/pci_ids.h>
-
-#include <linux/thinkpad_acpi.h>
+#include <asm/uaccess.h>
 
 /* ThinkPad CMOS commands */
 #define TP_CMOS_VOLUME_DOWN    0
index 7fce391818d30a183962b7888a8bfd275b10423c..7ad1ed091f9225fc572a1b70fde9ecf622d06ad1 100644 (file)
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/i8042.h>
-
+#include <linux/acpi.h>
 #include <asm/uaccess.h>
 
-#include <acpi/acpi_drivers.h>
-
 MODULE_AUTHOR("John Belmonte");
 MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver");
 MODULE_LICENSE("GPL");
index 74dd01ae343b01f5f5a9827c5ec02f11ceee61b5..2cb1ea62b4a7f9ac7b268adadb251105be279923 100644 (file)
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@gmail.com>");
 MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver");
 MODULE_LICENSE("GPL");
 
-
 static int toshiba_bt_rfkill_add(struct acpi_device *device);
 static int toshiba_bt_rfkill_remove(struct acpi_device *device);
 static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
index c2e7b2657aeb31bf5ab50a4f8a8821e2ad53f696..43d13295e63d53a50b62dae995d3a63b7e112a3a 100644 (file)
@@ -37,8 +37,6 @@
 #include <linux/acpi.h>
 #include <linux/slab.h>
 #include <linux/module.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
 
 ACPI_MODULE_NAME("wmi");
 MODULE_AUTHOR("Carlos Corbacho");
index 4b1377bd59446a50405e00414418adf9ac8f8381..49cbccec6e2de1ecffa260348c3582e609ba1507 100644 (file)
@@ -18,8 +18,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/input.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 
 #define MODULE_NAME "xo15-ebook"
 
index bc00693d0c79fbf8981f65f2494c12ae7a365555..874c236ac1a7abd4a3200008ce8242f759f67c2f 100644 (file)
@@ -239,6 +239,7 @@ int pnp_add_card(struct pnp_card *card)
        error = device_register(&card->dev);
        if (error) {
                dev_err(&card->dev, "could not register (err=%d)\n", error);
+               put_device(&card->dev);
                return error;
        }
 
index 14655a0f0431b35bd9a0988b669c510a162155e3..9f611cbbc294ea8c5ae84023e132e02152e36f85 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/pnp.h>
 #include <linux/slab.h>
 #include <linux/mod_devicetable.h>
-#include <acpi/acpi_bus.h>
 
 #include "../base.h"
 #include "pnpacpi.h"
@@ -242,6 +241,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
        struct pnp_dev *dev;
        char *pnpid;
        struct acpi_hardware_id *id;
+       int error;
 
        /* Skip devices that are already bound */
        if (device->physical_node_count)
@@ -300,10 +300,16 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
        /* clear out the damaged flags */
        if (!dev->active)
                pnp_init_resources(dev);
-       pnp_add_device(dev);
+
+       error = pnp_add_device(dev);
+       if (error) {
+               put_device(&dev->dev);
+               return error;
+       }
+
        num++;
 
-       return AE_OK;
+       return 0;
 }
 
 static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
@@ -329,20 +335,15 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp)
            && compare_pnp_id(pnp->id, acpi_device_hid(acpi));
 }
 
-static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle)
+static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev)
 {
-       struct device *adev;
-       struct acpi_device *acpi;
-
-       adev = bus_find_device(&acpi_bus_type, NULL,
-                              to_pnp_dev(dev), acpi_pnp_match);
-       if (!adev)
-               return -ENODEV;
+       dev = bus_find_device(&acpi_bus_type, NULL, to_pnp_dev(dev),
+                             acpi_pnp_match);
+       if (!dev)
+               return NULL;
 
-       acpi = to_acpi_device(adev);
-       *handle = acpi->handle;
-       put_device(adev);
-       return 0;
+       put_device(dev);
+       return to_acpi_device(dev);
 }
 
 /* complete initialization of a PNPACPI device includes having
@@ -356,7 +357,7 @@ static bool acpi_pnp_bus_match(struct device *dev)
 static struct acpi_bus_type __initdata acpi_pnp_bus = {
        .name        = "PNP",
        .match       = acpi_pnp_bus_match,
-       .find_device = acpi_pnp_find_device,
+       .find_companion = acpi_pnp_find_companion,
 };
 
 int pnpacpi_disabled __initdata;
index 3e60225b0227b2d6ff8f0c2ad863f195256c4b2e..051ef9699777519951c2c87b2e39c6dc5b69d27c 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef ACPI_PNP_H
 #define ACPI_PNP_H
 
-#include <acpi/acpi_bus.h>
 #include <linux/acpi.h>
 #include <linux/pnp.h>
 
index 9b86a01af6318ab14aba86d55a34f6db6033ed49..074569e77d22ef09784aca56d63714fbf051afcc 100644 (file)
@@ -312,18 +312,19 @@ static int __init insert_device(struct pnp_bios_node *node)
        struct list_head *pos;
        struct pnp_dev *dev;
        char id[8];
+       int error;
 
        /* check if the device is already added */
        list_for_each(pos, &pnpbios_protocol.devices) {
                dev = list_entry(pos, struct pnp_dev, protocol_list);
                if (dev->number == node->handle)
-                       return -1;
+                       return -EEXIST;
        }
 
        pnp_eisa_id_to_string(node->eisa_id & PNP_EISA_ID_MASK, id);
        dev = pnp_alloc_dev(&pnpbios_protocol, node->handle, id);
        if (!dev)
-               return -1;
+               return -ENOMEM;
 
        pnpbios_parse_data_stream(dev, node);
        dev->active = pnp_is_active(dev);
@@ -342,7 +343,12 @@ static int __init insert_device(struct pnp_bios_node *node)
        if (!dev->active)
                pnp_init_resources(dev);
 
-       pnp_add_device(dev);
+       error = pnp_add_device(dev);
+       if (error) {
+               put_device(&dev->dev);
+               return error;
+       }
+
        pnpbios_interface_attach_device(node);
 
        return 0;
index d95e101ffb439ebec5cc11772305d99578db772d..bacddd102ae9558bee539cf70d1fe6f4e5503ee4 100644 (file)
@@ -31,7 +31,7 @@ static int pnp_reserve_mem[16] = {[0 ... 15] = -1 };  /* reserve (don't use) some
  * option registration
  */
 
-struct pnp_option *pnp_build_option(struct pnp_dev *dev, unsigned long type,
+static struct pnp_option *pnp_build_option(struct pnp_dev *dev, unsigned long type,
                                    unsigned int option_flags)
 {
        struct pnp_option *option;
index f5b4ca581541539f8336aaec73c286de1f0773fb..d277b36eb389b1396b67718bf4ea5a54711828a1 100644 (file)
@@ -60,9 +60,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/kernel.h>
-#include <acpi/acpi.h>
-
-#include <linux/sfi.h>
+#include <linux/sfi_acpi.h>
 #include "sfi_core.h"
 
 /*
index 9f6ebdb23740596f530e9ab5d52194ca3c9c438e..a85c3d68c462b1a14b8a517445521a6df61bf64e 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
 
index 4e243c37f17f50ab197582a3ee5d4662e933d368..f0155a39aaa3b686f1b392c7d59781a8f76fda5d 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/acpi.h>
 #include <linux/pci.h>
 #include <linux/usb/hcd.h>
-#include <acpi/acpi_bus.h>
 
 #include "usb.h"
 
@@ -127,7 +126,7 @@ out:
        return ret;
 }
 
-static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
+static struct acpi_device *usb_acpi_find_companion(struct device *dev)
 {
        struct usb_device *udev;
        acpi_handle *parent_handle;
@@ -169,16 +168,15 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
                                break;
                        }
 
-                       return -ENODEV;
+                       return NULL;
                }
 
                /* root hub's parent is the usb hcd. */
-               parent_handle = ACPI_HANDLE(dev->parent);
-               *handle = acpi_get_child(parent_handle, udev->portnum);
-               if (!*handle)
-                       return -ENODEV;
-               return 0;
+               return acpi_find_child_device(ACPI_COMPANION(dev->parent),
+                                             udev->portnum, false);
        } else if (is_usb_port(dev)) {
+               struct acpi_device *adev = NULL;
+
                sscanf(dev_name(dev), "port%d", &port_num);
                /* Get the struct usb_device point of port's hub */
                udev = to_usb_device(dev->parent->parent);
@@ -194,26 +192,27 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
 
                        raw_port_num = usb_hcd_find_raw_port_number(hcd,
                                port_num);
-                       *handle = acpi_get_child(ACPI_HANDLE(&udev->dev),
-                               raw_port_num);
-                       if (!*handle)
-                               return -ENODEV;
+                       adev = acpi_find_child_device(ACPI_COMPANION(&udev->dev),
+                                                     raw_port_num, false);
+                       if (!adev)
+                               return NULL;
                } else {
                        parent_handle =
                                usb_get_hub_port_acpi_handle(udev->parent,
                                udev->portnum);
                        if (!parent_handle)
-                               return -ENODEV;
+                               return NULL;
 
-                       *handle = acpi_get_child(parent_handle, port_num);
-                       if (!*handle)
-                               return -ENODEV;
+                       acpi_bus_get_device(parent_handle, &adev);
+                       adev = acpi_find_child_device(adev, port_num, false);
+                       if (!adev)
+                               return NULL;
                }
-               usb_acpi_check_port_connect_type(udev, *handle, port_num);
-       } else
-               return -ENODEV;
+               usb_acpi_check_port_connect_type(udev, adev->handle, port_num);
+               return adev;
+       }
 
-       return 0;
+       return NULL;
 }
 
 static bool usb_acpi_bus_match(struct device *dev)
@@ -224,7 +223,7 @@ static bool usb_acpi_bus_match(struct device *dev)
 static struct acpi_bus_type usb_acpi_bus = {
        .name = "USB",
        .match = usb_acpi_bus_match,
-       .find_device = usb_acpi_find_device,
+       .find_companion = usb_acpi_find_companion,
 };
 
 int usb_acpi_register(void)
index 8dae6c13063af5df3846d0c3a700876fe23eefe0..80875fb770ed931681c75db5aa4209c15acfc7a7 100644 (file)
 #include <linux/cpu.h>
 #include <linux/acpi.h>
 #include <linux/uaccess.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
 #include <acpi/processor.h>
-
 #include <xen/acpi.h>
 #include <xen/interface/platform.h>
 #include <asm/xen/hypercall.h>
@@ -269,7 +266,8 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
                if (!is_processor_present(handle))
                        break;
 
-               if (!acpi_bus_get_device(handle, &device))
+               acpi_bus_get_device(handle, &device);
+               if (acpi_device_enumerated(device))
                        break;
 
                result = acpi_bus_scan(handle);
@@ -277,8 +275,9 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
                        pr_err(PREFIX "Unable to add the device\n");
                        break;
                }
-               result = acpi_bus_get_device(handle, &device);
-               if (result) {
+               device = NULL;
+               acpi_bus_get_device(handle, &device);
+               if (!acpi_device_enumerated(device)) {
                        pr_err(PREFIX "Missing device object\n");
                        break;
                }
index 9083f1e474f801c07c1531551fa971b5e0e21b38..f8d18626969a48819ae5810f1d424dc4eacf3f31 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/acpi.h>
-#include <acpi/acpi_drivers.h>
 #include <xen/acpi.h>
 #include <xen/interface/platform.h>
 #include <asm/xen/hypercall.h>
@@ -169,7 +168,7 @@ static int acpi_memory_get_device(acpi_handle handle,
        acpi_scan_lock_acquire();
 
        acpi_bus_get_device(handle, &device);
-       if (device)
+       if (acpi_device_enumerated(device))
                goto end;
 
        /*
@@ -182,8 +181,9 @@ static int acpi_memory_get_device(acpi_handle handle,
                result = -EINVAL;
                goto out;
        }
-       result = acpi_bus_get_device(handle, &device);
-       if (result) {
+       device = NULL;
+       acpi_bus_get_device(handle, &device);
+       if (!acpi_device_enumerated(device)) {
                pr_warn(PREFIX "Missing device object\n");
                result = -EINVAL;
                goto out;
index 59708fdd068bdfed83976dab53a823115efeda29..40c4bc06b5fa0929af0b9b8ffddd9d59e6bcbc36 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/types.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-#include <asm/xen/hypercall.h>
+#include <linux/acpi.h>
 #include <xen/interface/version.h>
 #include <xen/xen-ops.h>
+#include <asm/xen/hypercall.h>
 
 #define ACPI_PROCESSOR_AGGREGATOR_CLASS        "acpi_pad"
 #define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
index 13bc6c31c060bfc9821eb23eb467873b720c6f13..7231859119f1f126ac89e606ecc7c96c1a6a55c3 100644 (file)
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/syscore_ops.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
+#include <linux/acpi.h>
 #include <acpi/processor.h>
-
 #include <xen/xen.h>
 #include <xen/interface/platform.h>
 #include <asm/xen/hypercall.h>
index ddabed1f51c22227df9fdc1a7d050ca3b395b470..8256eb4ad0579be822efd37e22193fa4fdffefdb 100644 (file)
@@ -28,8 +28,6 @@
 
 #include <linux/device.h>
 
-#include <acpi/acpi.h>
-
 /* TBD: Make dynamic */
 #define ACPI_MAX_HANDLES       10
 struct acpi_handle_list {
@@ -66,6 +64,32 @@ bool acpi_ata_match(acpi_handle handle);
 bool acpi_bay_match(acpi_handle handle);
 bool acpi_dock_match(acpi_handle handle);
 
+bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs);
+union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid,
+                       int rev, int func, union acpi_object *argv4);
+
+static inline union acpi_object *
+acpi_evaluate_dsm_typed(acpi_handle handle, const u8 *uuid, int rev, int func,
+                       union acpi_object *argv4, acpi_object_type type)
+{
+       union acpi_object *obj;
+
+       obj = acpi_evaluate_dsm(handle, uuid, rev, func, argv4);
+       if (obj && obj->type != type) {
+               ACPI_FREE(obj);
+               obj = NULL;
+       }
+
+       return obj;
+}
+
+#define        ACPI_INIT_DSM_ARGV4(cnt, eles)                  \
+       {                                               \
+         .package.type = ACPI_TYPE_PACKAGE,            \
+         .package.count = (cnt),                       \
+         .package.elements = (eles)                    \
+       }
+
 #ifdef CONFIG_ACPI
 
 #include <linux/proc_fs.h>
@@ -91,17 +115,11 @@ struct acpi_device;
  * -----------------
  */
 
-enum acpi_hotplug_mode {
-       AHM_GENERIC = 0,
-       AHM_CONTAINER,
-       AHM_COUNT
-};
-
 struct acpi_hotplug_profile {
        struct kobject kobj;
+       int (*scan_dependent)(struct acpi_device *adev);
        bool enabled:1;
-       bool ignore:1;
-       enum acpi_hotplug_mode mode;
+       bool demand_offline:1;
 };
 
 static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
@@ -169,8 +187,10 @@ struct acpi_device_flags {
        u32 ejectable:1;
        u32 power_manageable:1;
        u32 match_driver:1;
+       u32 initialized:1;
+       u32 visited:1;
        u32 no_hotplug:1;
-       u32 reserved:26;
+       u32 reserved:24;
 };
 
 /* File System */
@@ -300,6 +320,7 @@ struct acpi_device {
        struct list_head children;
        struct list_head node;
        struct list_head wakeup_list;
+       struct list_head del_list;
        struct acpi_device_status status;
        struct acpi_device_flags flags;
        struct acpi_device_pnp pnp;
@@ -325,6 +346,11 @@ static inline void *acpi_driver_data(struct acpi_device *d)
 #define to_acpi_device(d)      container_of(d, struct acpi_device, dev)
 #define to_acpi_driver(d)      container_of(d, struct acpi_driver, drv)
 
+static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta)
+{
+       *((u32 *)&adev->status) = sta;
+}
+
 /* acpi_device.dev.bus == &acpi_bus_type */
 extern struct bus_type acpi_bus_type;
 
@@ -387,6 +413,11 @@ int acpi_match_device_ids(struct acpi_device *device,
 int acpi_create_dir(struct acpi_device *);
 void acpi_remove_dir(struct acpi_device *);
 
+static inline bool acpi_device_enumerated(struct acpi_device *adev)
+{
+       return adev && adev->flags.initialized && adev->flags.visited;
+}
+
 typedef void (*acpi_hp_callback)(void *data, u32 src);
 
 acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src);
@@ -410,7 +441,7 @@ struct acpi_bus_type {
        struct list_head list;
        const char *name;
        bool (*match)(struct device *dev);
-       int (*find_device) (struct device *, acpi_handle *);
+       struct acpi_device * (*find_companion)(struct device *);
        void (*setup)(struct device *);
        void (*cleanup)(struct device *);
 };
@@ -429,12 +460,9 @@ struct acpi_pci_root {
 };
 
 /* helper */
-acpi_handle acpi_find_child(acpi_handle, u64, bool);
-static inline acpi_handle acpi_get_child(acpi_handle handle, u64 addr)
-{
-       return acpi_find_child(handle, addr, false);
-}
-void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr);
+
+struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
+                                          u64 address, bool check_children);
 int acpi_is_root_bridge(acpi_handle);
 struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
 
index 1cedfcb1bd8878ff7466e4ab6d9285e3a811a90a..b124fdb260469bfa07dbc14fa511cb7dbd0240e2 100644 (file)
@@ -26,9 +26,6 @@
 #ifndef __ACPI_DRIVERS_H__
 #define __ACPI_DRIVERS_H__
 
-#include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
-
 #define ACPI_MAX_STRING                        80
 
 /*
similarity index 94%
rename from include/linux/acpi_io.h
rename to include/acpi/acpi_io.h
index b0ffa219993ec2be82a01854718d5e1269ef05bb..2be858018c7f449cc7ca258eedb5e3785d6d7099 100644 (file)
@@ -2,7 +2,6 @@
 #define _ACPI_IO_H_
 
 #include <linux/io.h>
-#include <acpi/acpi.h>
 
 static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
                                            acpi_size size)
index 4278aba9650381c932a687ca871a47f874b6aa1e..d2f16f14b419c26ba08b976e4ab8ba5b7a510915 100644 (file)
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20131115
+#define ACPI_CA_VERSION                 0x20131218
 
 #include <acpi/acconfig.h>
 #include <acpi/actypes.h>
@@ -54,7 +54,6 @@
 #include <acpi/acbuffer.h>
 
 extern u8 acpi_gbl_permanent_mmap;
-extern u32 acpi_rsdt_forced;
 
 /*
  * Globals that are publically available
@@ -72,17 +71,19 @@ extern u32 acpi_dbg_layer;
 
 /* ACPICA runtime options */
 
-extern u8 acpi_gbl_enable_interpreter_slack;
 extern u8 acpi_gbl_all_methods_serialized;
-extern u8 acpi_gbl_create_osi_method;
-extern u8 acpi_gbl_use_default_register_widths;
-extern acpi_name acpi_gbl_trace_method_name;
-extern u32 acpi_gbl_trace_flags;
-extern bool acpi_gbl_enable_aml_debug_object;
 extern u8 acpi_gbl_copy_dsdt_locally;
-extern u8 acpi_gbl_truncate_io_addresses;
+extern u8 acpi_gbl_create_osi_method;
 extern u8 acpi_gbl_disable_auto_repair;
 extern u8 acpi_gbl_disable_ssdt_table_load;
+extern u8 acpi_gbl_do_not_use_xsdt;
+extern bool acpi_gbl_enable_aml_debug_object;
+extern u8 acpi_gbl_enable_interpreter_slack;
+extern u32 acpi_gbl_trace_flags;
+extern acpi_name acpi_gbl_trace_method_name;
+extern u8 acpi_gbl_truncate_io_addresses;
+extern u8 acpi_gbl_use32_bit_fadt_addresses;
+extern u8 acpi_gbl_use_default_register_widths;
 
 /*
  * Hardware-reduced prototypes. All interfaces that use these macros will
@@ -130,10 +131,9 @@ acpi_status __init acpi_terminate(void);
  * Miscellaneous global interfaces
  */
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void))
 #ifdef ACPI_FUTURE_USAGE
- acpi_status acpi_subsystem_status(void);
+acpi_status acpi_subsystem_status(void);
 #endif
 
 #ifdef ACPI_FUTURE_USAGE
@@ -278,16 +278,13 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                acpi_install_sci_handler(acpi_sci_handler
                                                         address,
                                                         void *context))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_remove_sci_handler(acpi_sci_handler
                                                         address))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_install_global_event_handler
                                 (acpi_gbl_event_handler handler,
                                  void *context))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_install_fixed_event_handler(u32
                                                                  acpi_event,
@@ -295,12 +292,10 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                                                  handler,
                                                                  void
                                                                  *context))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_remove_fixed_event_handler(u32 acpi_event,
                                                                 acpi_event_handler
                                                                 handler))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_install_gpe_handler(acpi_handle
                                                          gpe_device,
@@ -309,15 +304,14 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                                          acpi_gpe_handler
                                                          address,
                                                          void *context))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_remove_gpe_handler(acpi_handle gpe_device,
                                                         u32 gpe_number,
                                                         acpi_gpe_handler
                                                         address))
 acpi_status acpi_install_notify_handler(acpi_handle device, u32 handler_type,
-                                       acpi_notify_handler handler,
-                                       void *context);
+                                        acpi_notify_handler handler,
+                                        void *context);
 
 acpi_status
 acpi_remove_notify_handler(acpi_handle device,
@@ -366,7 +360,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
 
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                acpi_disable_event(u32 event, u32 flags))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_clear_event(u32 event))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
@@ -404,20 +397,16 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                                        parent_device,
                                                        acpi_handle gpe_device,
                                                        u32 gpe_number))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_set_gpe_wake_mask(acpi_handle gpe_device,
                                                        u32 gpe_number,
                                                        u8 action))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_get_gpe_status(acpi_handle gpe_device,
                                                     u32 gpe_number,
                                                     acpi_event_status
                                                     *event_status))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
@@ -431,7 +420,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                                       *gpe_block_address,
                                                       u32 register_count,
                                                       u32 interrupt_number))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                 acpi_remove_gpe_block(acpi_handle gpe_device))
 
@@ -532,7 +520,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
 #ifdef ACPI_FUTURE_USAGE
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                acpi_get_timer_resolution(u32 *resolution))
-
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_get_timer(u32 *ticks))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
index 94970880126f151a74c00de146a58d2a6aad6c59..325aeae1fa9964a8a6512e72082637eca2f75898 100644 (file)
@@ -182,6 +182,9 @@ struct acpi_table_xsdt {
        u64 table_offset_entry[1];      /* Array of pointers to ACPI tables */
 };
 
+#define ACPI_RSDT_ENTRY_SIZE        (sizeof (u32))
+#define ACPI_XSDT_ENTRY_SIZE        (sizeof (u64))
+
 /*******************************************************************************
  *
  * FACS - Firmware ACPI Control Structure (FACS)
index 556c83ee6b42f3fafc419755f47062cde2212412..4ec8c194bfe55334fa5076401da04db5a0fa259b 100644 (file)
@@ -457,7 +457,7 @@ struct acpi_hest_aer_common {
        u8 enabled;
        u32 records_to_preallocate;
        u32 max_sections_per_record;
-       u32 bus;
+       u32 bus;                /* Bus and Segment numbers */
        u16 device;
        u16 function;
        u16 device_control;
@@ -473,6 +473,14 @@ struct acpi_hest_aer_common {
 #define ACPI_HEST_FIRMWARE_FIRST        (1)
 #define ACPI_HEST_GLOBAL                (1<<1)
 
+/*
+ * Macros to access the bus/segment numbers in Bus field above:
+ *  Bus number is encoded in bits 7:0
+ *  Segment number is encoded in bits 23:8
+ */
+#define ACPI_HEST_BUS(bus)              ((bus) & 0xFF)
+#define ACPI_HEST_SEGMENT(bus)          (((bus) >> 8) & 0xFFFF)
+
 /* Hardware Error Notification */
 
 struct acpi_hest_notify {
index 40f7ed115452aa7c537a8288579a7b974434b601..094a906a0e98320747042890dcc98eb4dbf470d0 100644 (file)
@@ -327,6 +327,11 @@ struct acpi_table_dbg2 {
        u32 info_count;
 };
 
+struct acpi_dbg2_header {
+       u32 info_offset;
+       u32 info_count;
+};
+
 /* Debug Device Information Subtable */
 
 struct acpi_dbg2_device {
index e2c0931a3d675092f0757a98e61c3ecb75e15f0b..01c2a9013e402bbc8af785372b90165284d7f065 100644 (file)
@@ -374,16 +374,22 @@ struct acpi_mpst_shared {
 struct acpi_table_pcct {
        struct acpi_table_header header;        /* Common ACPI table header */
        u32 flags;
-       u32 latency;
-       u32 reserved;
+       u64 reserved;
 };
 
 /* Values for Flags field above */
 
 #define ACPI_PCCT_DOORBELL              1
 
+/* Values for subtable type in struct acpi_subtable_header */
+
+enum acpi_pcct_type {
+       ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0,
+       ACPI_PCCT_TYPE_RESERVED = 1     /* 1 and greater are reserved */
+};
+
 /*
- * PCCT subtables
+ * PCCT Subtables, correspond to Type in struct acpi_subtable_header
  */
 
 /* 0: Generic Communications Subspace */
@@ -396,6 +402,9 @@ struct acpi_pcct_subspace {
        struct acpi_generic_address doorbell_register;
        u64 preserve_mask;
        u64 write_mask;
+       u32 latency;
+       u32 max_access_rate;
+       u16 min_turnaround_time;
 };
 
 /*
index 809b1a0fee7fd916d2204020b8392a05bc51e172..68a3ada689c900b90b26af4ec61377cd8405472f 100644 (file)
@@ -928,22 +928,14 @@ struct acpi_object_list {
  * Miscellaneous common Data Structures used by the interfaces
  */
 #define ACPI_NO_BUFFER              0
-#define ACPI_ALLOCATE_BUFFER        (acpi_size) (-1)
-#define ACPI_ALLOCATE_LOCAL_BUFFER  (acpi_size) (-2)
+#define ACPI_ALLOCATE_BUFFER        (acpi_size) (-1)   /* Let ACPICA allocate buffer */
+#define ACPI_ALLOCATE_LOCAL_BUFFER  (acpi_size) (-2)   /* For internal use only (enables tracking) */
 
 struct acpi_buffer {
        acpi_size length;       /* Length in bytes of the buffer */
        void *pointer;          /* pointer to buffer */
 };
 
-/*
- * Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_BUFFER.
- * Note: We use acpi_os_free here because acpi_os_allocate was used to allocate
- * the buffer. This purposefully bypasses the internal allocation tracking
- * mechanism (if it is enabled).
- */
-#define ACPI_FREE_BUFFER(b)         acpi_os_free((b).pointer)
-
 /*
  * name_type for acpi_get_name
  */
index 974d3ef7c1413d42be45b974487ca062e2cfdcc4..b402eb67af83fd5496669eec6e8ed6fe2d168f58 100644 (file)
 #endif
 
 /*
- * acpi_bin/acpi_dump/acpi_src/acpi_xtract configuration. All single
+ * acpi_bin/acpi_dump/acpi_src/acpi_xtract/Example configuration. All single
  * threaded, with no debug output.
  */
-#if (defined ACPI_BIN_APP)   || \
-       (defined ACPI_DUMP_APP)  || \
-       (defined ACPI_SRC_APP)   || \
-       (defined ACPI_XTRACT_APP)
+#if (defined ACPI_BIN_APP)      || \
+       (defined ACPI_DUMP_APP)     || \
+       (defined ACPI_SRC_APP)      || \
+       (defined ACPI_XTRACT_APP)   || \
+       (defined ACPI_EXAMPLE_APP)
 #define ACPI_APPLICATION
 #define ACPI_SINGLE_THREADED
 #endif
@@ -394,4 +395,13 @@ typedef char *va_list;
 
 #endif                         /* ACPI_USE_SYSTEM_CLIBRARY */
 
+#ifndef ACPI_FILE
+#ifdef ACPI_APPLICATION
+#include <stdio.h>
+#define ACPI_FILE              FILE *
+#else
+#define ACPI_FILE              void *
+#endif                         /* ACPI_APPLICATION */
+#endif                         /* ACPI_FILE */
+
 #endif                         /* __ACENV_H__ */
index 28f4f4dba0b667c5ee10001199ee87e02dd887ae..008aa287c7a9f3184bcd554058471aaf07e882a2 100644 (file)
@@ -239,10 +239,6 @@ void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
  */
 void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
 
-void acpi_os_gpe_count(u32 gpe_number);
-
-void acpi_os_fixed_event_count(u32 fixed_event_number);
-
 #endif                         /* __KERNEL__ */
 
 #endif                         /* __ACLINUX_H__ */
index d9099b15b4726404343308a39e5e55d39a16aa05..3e3247d95fd9ad7297c7b689b2a50ec1bb8c156c 100644 (file)
@@ -42,6 +42,7 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_numa.h>
+#include <acpi/acpi_io.h>
 #include <asm/acpi.h>
 
 static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
@@ -53,6 +54,12 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
 #define ACPI_COMPANION_SET(dev, adev)  ACPI_COMPANION(dev) = (adev)
 #define ACPI_HANDLE(dev)               acpi_device_handle(ACPI_COMPANION(dev))
 
+static inline void acpi_preset_companion(struct device *dev,
+                                        struct acpi_device *parent, u64 addr)
+{
+       ACPI_COMPANION_SET(dev, acpi_find_child_device(parent, addr, NULL));
+}
+
 static inline const char *acpi_dev_name(struct acpi_device *adev)
 {
        return dev_name(&adev->dev);
@@ -460,7 +467,7 @@ struct acpi_table_header;
 static inline int acpi_table_parse(char *id,
                                int (*handler)(struct acpi_table_header *))
 {
-       return -1;
+       return -ENODEV;
 }
 
 static inline int acpi_nvs_register(__u64 start, __u64 size)
diff --git a/include/linux/container.h b/include/linux/container.h
new file mode 100644 (file)
index 0000000..3c03e6f
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Definitions for container bus type.
+ *
+ * Copyright (C) 2013, Intel Corporation
+ * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/device.h>
+
+/* drivers/base/power/container.c */
+extern struct bus_type container_subsys;
+
+struct container_dev {
+       struct device dev;
+       int (*offline)(struct container_dev *cdev);
+};
+
+static inline struct container_dev *to_container_dev(struct device *dev)
+{
+       return container_of(dev, struct container_dev, dev);
+}
index 46a14229a162cf2bc5cc5e5b096c10c120766d8d..93b5ca754b5b4c4931aa2b3f66cf246312cedbd8 100644 (file)
 #include <linux/completion.h>
 #include <linux/pm.h>
 #include <linux/mutex.h>
-#ifdef CONFIG_BLK_DEV_IDEACPI
-#include <acpi/acpi.h>
-#endif
-#include <asm/byteorder.h>
-#include <asm/io.h>
-
 /* for request_sense */
 #include <linux/cdrom.h>
+#include <asm/byteorder.h>
+#include <asm/io.h>
 
 #if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300)
 # define SUPPORT_VLB_SYNC 0
index 8ba7e5b9d62cb466f60cced5c8340261acf9fc4f..605cc5c333d968f7ff2074cd9ab6d21d6b9bbc7e 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef ISCSI_IBFT_H
 #define ISCSI_IBFT_H
 
-#include <acpi/acpi.h>
+#include <linux/acpi.h>
 
 /*
  * Logical location of iSCSI Boot Format Table.
index a2e2f1d17e164c00b190d6515ec90950ef288e17..5f2e559af6b0a7a6ea07247ab405ea48407d4e72 100644 (file)
@@ -175,8 +175,7 @@ struct hotplug_params {
 };
 
 #ifdef CONFIG_ACPI
-#include <acpi/acpi.h>
-#include <acpi/acpi_bus.h>
+#include <linux/acpi.h>
 int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp);
 int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags);
 int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
index a224c7f5c377e796969a6d96b684d96b7779c9b5..8c6583a53a0608a796c543d196d52270cbe8ac4d 100644 (file)
@@ -311,6 +311,18 @@ struct dev_pm_ops {
 #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
 #endif
 
+#ifdef CONFIG_PM_SLEEP
+#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+       .suspend_late = suspend_fn, \
+       .resume_early = resume_fn, \
+       .freeze_late = suspend_fn, \
+       .thaw_early = resume_fn, \
+       .poweroff_late = suspend_fn, \
+       .restore_early = resume_fn,
+#else
+#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
+#endif
+
 #ifdef CONFIG_PM_RUNTIME
 #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
        .runtime_suspend = suspend_fn, \
@@ -320,6 +332,15 @@ struct dev_pm_ops {
 #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
 #endif
 
+#ifdef CONFIG_PM
+#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
+       .runtime_suspend = suspend_fn, \
+       .runtime_resume = resume_fn, \
+       .runtime_idle = idle_fn,
+#else
+#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
+#endif
+
 /*
  * Use this if you want to use the same suspend and resume callbacks for suspend
  * to RAM and hibernation.
index 6fa7cea25da9afde1ffac4668c30f85d711a0fc0..16c9a62fa1c0f0650edcdc5d258a0cca6a7b8ad9 100644 (file)
                                            usage_count */
 #define RPM_AUTO               0x08    /* Use autosuspend_delay */
 
+#ifdef CONFIG_PM
+extern int pm_generic_runtime_suspend(struct device *dev);
+extern int pm_generic_runtime_resume(struct device *dev);
+#else
+static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
+static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
+#endif
+
 #ifdef CONFIG_PM_RUNTIME
 
 extern struct workqueue_struct *pm_wq;
@@ -37,8 +45,6 @@ extern void pm_runtime_enable(struct device *dev);
 extern void __pm_runtime_disable(struct device *dev, bool check_resume);
 extern void pm_runtime_allow(struct device *dev);
 extern void pm_runtime_forbid(struct device *dev);
-extern int pm_generic_runtime_suspend(struct device *dev);
-extern int pm_generic_runtime_resume(struct device *dev);
 extern void pm_runtime_no_callbacks(struct device *dev);
 extern void pm_runtime_irq_safe(struct device *dev);
 extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
@@ -142,8 +148,6 @@ static inline bool pm_runtime_active(struct device *dev) { return true; }
 static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
 static inline bool pm_runtime_enabled(struct device *dev) { return false; }
 
-static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
-static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
 static inline void pm_runtime_no_callbacks(struct device *dev) {}
 static inline void pm_runtime_irq_safe(struct device *dev) {}
 
index 631af63af42ddbaaabf6f8debcda035821cc71dc..4723bbfa1c2643fe004d36b5b44367644ea524d9 100644 (file)
 #ifndef _LINUX_SFI_ACPI_H
 #define _LINUX_SFI_ACPI_H
 
+#include <linux/acpi.h>
+#include <linux/sfi.h>
+
 #ifdef CONFIG_SFI
-#include <acpi/acpi.h>         /* struct acpi_table_header */
+#include <acpi/acpi.h> /* FIXME: inclusion should be removed */
 
 extern int sfi_acpi_table_parse(char *signature, char *oem_id,
                                char *oem_table_id,
index c75128bed5fa39116952fd148ff01374993b8f44..9a54b331f938fcfc02d66a22873b8d735369d8ad 100644 (file)
@@ -34,7 +34,7 @@ enum {
 };
 
 #ifdef CONFIG_INTEL_TXT
-#include <acpi/acpi.h>
+#include <linux/acpi.h>
 /* used to communicate between tboot and the launched kernel */
 
 #define TB_KEY_SIZE             64   /* 512 bits */
index 724f409adae025fffb464c43638a024da030be96..df79bca1b8987474aadc7f389d2f39b2068665c0 100644 (file)
@@ -67,6 +67,8 @@ struct apm_bios_info {
 #define APM_USER_SUSPEND       0x000a
 #define APM_STANDBY_RESUME     0x000b
 #define APM_CAPABILITY_CHANGE  0x000c
+#define APM_USER_HIBERNATION   0x000d
+#define APM_HIBERNATION_RESUME 0x000e
 
 /*
  * Error codes
index 0121dab83f43d82ddfb620f7423d6c9728f8b01b..37170d4dd9a61d1ad1171d106c61af8d59393f85 100644 (file)
@@ -82,6 +82,7 @@ void hibernation_set_ops(const struct platform_hibernation_ops *ops)
 
        unlock_system_sleep();
 }
+EXPORT_SYMBOL_GPL(hibernation_set_ops);
 
 static bool entering_platform_hibernation;
 
@@ -293,10 +294,10 @@ static int create_image(int platform_mode)
                        error);
        /* Restore control flow magically appears here */
        restore_processor_state();
-       if (!in_suspend) {
+       if (!in_suspend)
                events_check_enabled = false;
-               platform_leave(platform_mode);
-       }
+
+       platform_leave(platform_mode);
 
  Power_up:
        syscore_resume();
index 66cace601e5721cf920c89f3b365c75f6695ce67..0f10b81e3322694df614bf23a0b1824d415b34ce 100644 (file)
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-
+#include <linux/acpi.h>
 #include <asm/io.h>
 
-#include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-
 static int pm_tmr_ioport = 0;
 
 /*helper function to safely read acpi pm timesource*/