aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/acpi_cmos_rtc.c92
-rw-r--r--drivers/acpi/acpi_lpss.c125
-rw-r--r--drivers/acpi/acpi_memhotplug.c63
-rw-r--r--drivers/acpi/acpi_processor.c494
-rw-r--r--drivers/acpi/acpica/Makefile4
-rw-r--r--drivers/acpi/acpica/acglobal.h6
-rw-r--r--drivers/acpi/acpica/aclocal.h30
-rw-r--r--drivers/acpi/acpica/acmacros.h10
-rw-r--r--drivers/acpi/acpica/acnamesp.h43
-rw-r--r--drivers/acpi/acpica/acpredef.h4
-rw-r--r--drivers/acpi/acpica/acstruct.h40
-rw-r--r--drivers/acpi/acpica/acutils.h50
-rw-r--r--drivers/acpi/acpica/dscontrol.c4
-rw-r--r--drivers/acpi/acpica/dsfield.c4
-rw-r--r--drivers/acpi/acpica/dsinit.c1
-rw-r--r--drivers/acpi/acpica/dsmthdat.c2
-rw-r--r--drivers/acpi/acpica/dsobject.c3
-rw-r--r--drivers/acpi/acpica/dsopcode.c1
-rw-r--r--drivers/acpi/acpica/dsutils.c5
-rw-r--r--drivers/acpi/acpica/dswexec.c3
-rw-r--r--drivers/acpi/acpica/dswload.c7
-rw-r--r--drivers/acpi/acpica/dswload2.c4
-rw-r--r--drivers/acpi/acpica/evglock.c1
-rw-r--r--drivers/acpi/acpica/evgpe.c7
-rw-r--r--drivers/acpi/acpica/evgpeblk.c2
-rw-r--r--drivers/acpi/acpica/evgpeinit.c3
-rw-r--r--drivers/acpi/acpica/evhandler.c7
-rw-r--r--drivers/acpi/acpica/evmisc.c3
-rw-r--r--drivers/acpi/acpica/evregion.c63
-rw-r--r--drivers/acpi/acpica/evrgnini.c2
-rw-r--r--drivers/acpi/acpica/evxfgpe.c3
-rw-r--r--drivers/acpi/acpica/evxfregn.c1
-rw-r--r--drivers/acpi/acpica/exconfig.c3
-rw-r--r--drivers/acpi/acpica/exconvrt.c13
-rw-r--r--drivers/acpi/acpica/excreate.c3
-rw-r--r--drivers/acpi/acpica/exdebug.c2
-rw-r--r--drivers/acpi/acpica/exdump.c2
-rw-r--r--drivers/acpi/acpica/exfield.c4
-rw-r--r--drivers/acpi/acpica/exfldio.c2
-rw-r--r--drivers/acpi/acpica/exmisc.c12
-rw-r--r--drivers/acpi/acpica/exoparg1.c16
-rw-r--r--drivers/acpi/acpica/exoparg2.c1
-rw-r--r--drivers/acpi/acpica/exoparg3.c1
-rw-r--r--drivers/acpi/acpica/exoparg6.c5
-rw-r--r--drivers/acpi/acpica/exprep.c7
-rw-r--r--drivers/acpi/acpica/exregion.c27
-rw-r--r--drivers/acpi/acpica/exresnte.c1
-rw-r--r--drivers/acpi/acpica/exresolv.c6
-rw-r--r--drivers/acpi/acpica/exresop.c9
-rw-r--r--drivers/acpi/acpica/exstore.c4
-rw-r--r--drivers/acpi/acpica/exstoren.c4
-rw-r--r--drivers/acpi/acpica/hwacpi.c2
-rw-r--r--drivers/acpi/acpica/hwgpe.c3
-rw-r--r--drivers/acpi/acpica/hwregs.c4
-rw-r--r--drivers/acpi/acpica/hwxface.c9
-rw-r--r--drivers/acpi/acpica/hwxfsleep.c12
-rw-r--r--drivers/acpi/acpica/nsaccess.c1
-rw-r--r--drivers/acpi/acpica/nsarguments.c294
-rw-r--r--drivers/acpi/acpica/nsconvert.c3
-rw-r--r--drivers/acpi/acpica/nsdump.c10
-rw-r--r--drivers/acpi/acpica/nseval.c247
-rw-r--r--drivers/acpi/acpica/nsinit.c16
-rw-r--r--drivers/acpi/acpica/nspredef.c216
-rw-r--r--drivers/acpi/acpica/nsprepkg.c81
-rw-r--r--drivers/acpi/acpica/nsrepair.c51
-rw-r--r--drivers/acpi/acpica/nsrepair2.c358
-rw-r--r--drivers/acpi/acpica/nsutils.c3
-rw-r--r--drivers/acpi/acpica/nsxfeval.c163
-rw-r--r--drivers/acpi/acpica/psargs.c4
-rw-r--r--drivers/acpi/acpica/psloop.c2
-rw-r--r--drivers/acpi/acpica/psobject.c1
-rw-r--r--drivers/acpi/acpica/psparse.c3
-rw-r--r--drivers/acpi/acpica/pstree.c2
-rw-r--r--drivers/acpi/acpica/psxface.c14
-rw-r--r--drivers/acpi/acpica/rscalc.c7
-rw-r--r--drivers/acpi/acpica/rscreate.c27
-rw-r--r--drivers/acpi/acpica/rsdump.c10
-rw-r--r--drivers/acpi/acpica/rsmisc.c3
-rw-r--r--drivers/acpi/acpica/rsutils.c7
-rw-r--r--drivers/acpi/acpica/rsxface.c1
-rw-r--r--drivers/acpi/acpica/tbinstal.c7
-rw-r--r--drivers/acpi/acpica/tbprint.c237
-rw-r--r--drivers/acpi/acpica/tbutils.c191
-rw-r--r--drivers/acpi/acpica/tbxfload.c25
-rw-r--r--drivers/acpi/acpica/utbuffer.c201
-rw-r--r--drivers/acpi/acpica/utcopy.c11
-rw-r--r--drivers/acpi/acpica/utdebug.c148
-rw-r--r--drivers/acpi/acpica/utdelete.c3
-rw-r--r--drivers/acpi/acpica/uterror.c289
-rw-r--r--drivers/acpi/acpica/uteval.c9
-rw-r--r--drivers/acpi/acpica/utexcep.c1
-rw-r--r--drivers/acpi/acpica/utids.c3
-rw-r--r--drivers/acpi/acpica/utmisc.c2
-rw-r--r--drivers/acpi/acpica/utobject.c5
-rw-r--r--drivers/acpi/acpica/utpredef.c16
-rw-r--r--drivers/acpi/acpica/utstring.c19
-rw-r--r--drivers/acpi/acpica/uttrack.c8
-rw-r--r--drivers/acpi/acpica/utxferror.c234
-rw-r--r--drivers/acpi/apei/einj.c39
-rw-r--r--drivers/acpi/apei/erst.c65
-rw-r--r--drivers/acpi/apei/ghes.c10
-rw-r--r--drivers/acpi/battery.c18
-rw-r--r--drivers/acpi/bus.c17
-rw-r--r--drivers/acpi/device_pm.c193
-rw-r--r--drivers/acpi/dock.c7
-rw-r--r--drivers/acpi/ec.c4
-rw-r--r--drivers/acpi/ec_sys.c18
-rw-r--r--drivers/acpi/fan.c2
-rw-r--r--drivers/acpi/glue.c12
-rw-r--r--drivers/acpi/internal.h19
-rw-r--r--drivers/acpi/osl.c27
-rw-r--r--drivers/acpi/pci_root.c101
-rw-r--r--drivers/acpi/power.c4
-rw-r--r--drivers/acpi/processor_core.c8
-rw-r--r--drivers/acpi/processor_driver.c816
-rw-r--r--drivers/acpi/processor_idle.c10
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--drivers/acpi/scan.c219
-rw-r--r--drivers/acpi/sleep.c2
-rw-r--r--drivers/acpi/sysfs.c34
-rw-r--r--drivers/acpi/video.c34
-rw-r--r--drivers/acpi/video_detect.c8
123 files changed, 3518 insertions, 2327 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 536562c626a2..81dbeb83bb45 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -34,6 +34,7 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o
34acpi-y += bus.o glue.o 34acpi-y += bus.o glue.o
35acpi-y += scan.o 35acpi-y += scan.o
36acpi-y += resource.o 36acpi-y += resource.o
37acpi-y += acpi_processor.o
37acpi-y += processor_core.o 38acpi-y += processor_core.o
38acpi-y += ec.o 39acpi-y += ec.o
39acpi-$(CONFIG_ACPI_DOCK) += dock.o 40acpi-$(CONFIG_ACPI_DOCK) += dock.o
@@ -43,6 +44,7 @@ acpi-y += acpi_platform.o
43acpi-y += power.o 44acpi-y += power.o
44acpi-y += event.o 45acpi-y += event.o
45acpi-y += sysfs.o 46acpi-y += sysfs.o
47acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
46acpi-$(CONFIG_DEBUG_FS) += debugfs.o 48acpi-$(CONFIG_DEBUG_FS) += debugfs.o
47acpi-$(CONFIG_ACPI_NUMA) += numa.o 49acpi-$(CONFIG_ACPI_NUMA) += numa.o
48acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o 50acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
diff --git a/drivers/acpi/acpi_cmos_rtc.c b/drivers/acpi/acpi_cmos_rtc.c
new file mode 100644
index 000000000000..84190ed89c04
--- /dev/null
+++ b/drivers/acpi/acpi_cmos_rtc.c
@@ -0,0 +1,92 @@
1/*
2 * ACPI support for CMOS RTC Address Space access
3 *
4 * Copyright (C) 2013, Intel Corporation
5 * Authors: Lan Tianyu <tianyu.lan@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/acpi.h>
13#include <linux/device.h>
14#include <linux/err.h>
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <asm-generic/rtc.h>
18
19#include "internal.h"
20
21#define PREFIX "ACPI: "
22
23ACPI_MODULE_NAME("cmos rtc");
24
25static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
26 { "PNP0B00" },
27 { "PNP0B01" },
28 { "PNP0B02" },
29 {}
30};
31
32static acpi_status
33acpi_cmos_rtc_space_handler(u32 function, acpi_physical_address address,
34 u32 bits, u64 *value64,
35 void *handler_context, void *region_context)
36{
37 int i;
38 u8 *value = (u8 *)&value64;
39
40 if (address > 0xff || !value64)
41 return AE_BAD_PARAMETER;
42
43 if (function != ACPI_WRITE && function != ACPI_READ)
44 return AE_BAD_PARAMETER;
45
46 spin_lock_irq(&rtc_lock);
47
48 for (i = 0; i < DIV_ROUND_UP(bits, 8); ++i, ++address, ++value)
49 if (function == ACPI_READ)
50 *value = CMOS_READ(address);
51 else
52 CMOS_WRITE(*value, address);
53
54 spin_unlock_irq(&rtc_lock);
55
56 return AE_OK;
57}
58
59static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,
60 const struct acpi_device_id *id)
61{
62 acpi_status status;
63
64 status = acpi_install_address_space_handler(adev->handle,
65 ACPI_ADR_SPACE_CMOS,
66 &acpi_cmos_rtc_space_handler,
67 NULL, NULL);
68 if (ACPI_FAILURE(status)) {
69 pr_err(PREFIX "Error installing CMOS-RTC region handler\n");
70 return -ENODEV;
71 }
72
73 return 0;
74}
75
76static void acpi_remove_cmos_rtc_space_handler(struct acpi_device *adev)
77{
78 if (ACPI_FAILURE(acpi_remove_address_space_handler(adev->handle,
79 ACPI_ADR_SPACE_CMOS, &acpi_cmos_rtc_space_handler)))
80 pr_err(PREFIX "Error removing CMOS-RTC region handler\n");
81}
82
83static struct acpi_scan_handler cmos_rtc_handler = {
84 .ids = acpi_cmos_rtc_ids,
85 .attach = acpi_install_cmos_rtc_space_handler,
86 .detach = acpi_remove_cmos_rtc_space_handler,
87};
88
89void __init acpi_cmos_rtc_init(void)
90{
91 acpi_scan_add_handler(&cmos_rtc_handler);
92}
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index cab13f2fc28e..6a382188fa20 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -32,12 +32,26 @@ ACPI_MODULE_NAME("acpi_lpss");
32#define LPSS_GENERAL_LTR_MODE_SW BIT(2) 32#define LPSS_GENERAL_LTR_MODE_SW BIT(2)
33#define LPSS_SW_LTR 0x10 33#define LPSS_SW_LTR 0x10
34#define LPSS_AUTO_LTR 0x14 34#define LPSS_AUTO_LTR 0x14
35#define LPSS_TX_INT 0x20
36#define LPSS_TX_INT_MASK BIT(1)
37
38struct lpss_shared_clock {
39 const char *name;
40 unsigned long rate;
41 struct clk *clk;
42};
43
44struct lpss_private_data;
35 45
36struct lpss_device_desc { 46struct lpss_device_desc {
37 bool clk_required; 47 bool clk_required;
38 const char *clkdev_name; 48 const char *clkdev_name;
39 bool ltr_required; 49 bool ltr_required;
40 unsigned int prv_offset; 50 unsigned int prv_offset;
51 size_t prv_size_override;
52 bool clk_gate;
53 struct lpss_shared_clock *shared_clock;
54 void (*setup)(struct lpss_private_data *pdata);
41}; 55};
42 56
43static struct lpss_device_desc lpss_dma_desc = { 57static struct lpss_device_desc lpss_dma_desc = {
@@ -52,17 +66,76 @@ struct lpss_private_data {
52 const struct lpss_device_desc *dev_desc; 66 const struct lpss_device_desc *dev_desc;
53}; 67};
54 68
69static void lpss_uart_setup(struct lpss_private_data *pdata)
70{
71 unsigned int tx_int_offset = pdata->dev_desc->prv_offset + LPSS_TX_INT;
72 u32 reg;
73
74 reg = readl(pdata->mmio_base + tx_int_offset);
75 writel(reg | LPSS_TX_INT_MASK, pdata->mmio_base + tx_int_offset);
76}
77
55static struct lpss_device_desc lpt_dev_desc = { 78static struct lpss_device_desc lpt_dev_desc = {
56 .clk_required = true, 79 .clk_required = true,
57 .prv_offset = 0x800, 80 .prv_offset = 0x800,
58 .ltr_required = true, 81 .ltr_required = true,
82 .clk_gate = true,
83};
84
85static struct lpss_device_desc lpt_uart_dev_desc = {
86 .clk_required = true,
87 .prv_offset = 0x800,
88 .ltr_required = true,
89 .clk_gate = true,
90 .setup = lpss_uart_setup,
59}; 91};
60 92
61static struct lpss_device_desc lpt_sdio_dev_desc = { 93static struct lpss_device_desc lpt_sdio_dev_desc = {
62 .prv_offset = 0x1000, 94 .prv_offset = 0x1000,
95 .prv_size_override = 0x1018,
63 .ltr_required = true, 96 .ltr_required = true,
64}; 97};
65 98
99static struct lpss_shared_clock uart_clock = {
100 .name = "uart_clk",
101 .rate = 44236800,
102};
103
104static struct lpss_device_desc byt_uart_dev_desc = {
105 .clk_required = true,
106 .prv_offset = 0x800,
107 .clk_gate = true,
108 .shared_clock = &uart_clock,
109 .setup = lpss_uart_setup,
110};
111
112static struct lpss_shared_clock spi_clock = {
113 .name = "spi_clk",
114 .rate = 50000000,
115};
116
117static struct lpss_device_desc byt_spi_dev_desc = {
118 .clk_required = true,
119 .prv_offset = 0x400,
120 .clk_gate = true,
121 .shared_clock = &spi_clock,
122};
123
124static struct lpss_device_desc byt_sdio_dev_desc = {
125 .clk_required = true,
126};
127
128static struct lpss_shared_clock i2c_clock = {
129 .name = "i2c_clk",
130 .rate = 100000000,
131};
132
133static struct lpss_device_desc byt_i2c_dev_desc = {
134 .clk_required = true,
135 .prv_offset = 0x800,
136 .shared_clock = &i2c_clock,
137};
138
66static const struct acpi_device_id acpi_lpss_device_ids[] = { 139static const struct acpi_device_id acpi_lpss_device_ids[] = {
67 /* Generic LPSS devices */ 140 /* Generic LPSS devices */
68 { "INTL9C60", (unsigned long)&lpss_dma_desc }, 141 { "INTL9C60", (unsigned long)&lpss_dma_desc },
@@ -72,11 +145,18 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
72 { "INT33C1", (unsigned long)&lpt_dev_desc }, 145 { "INT33C1", (unsigned long)&lpt_dev_desc },
73 { "INT33C2", (unsigned long)&lpt_dev_desc }, 146 { "INT33C2", (unsigned long)&lpt_dev_desc },
74 { "INT33C3", (unsigned long)&lpt_dev_desc }, 147 { "INT33C3", (unsigned long)&lpt_dev_desc },
75 { "INT33C4", (unsigned long)&lpt_dev_desc }, 148 { "INT33C4", (unsigned long)&lpt_uart_dev_desc },
76 { "INT33C5", (unsigned long)&lpt_dev_desc }, 149 { "INT33C5", (unsigned long)&lpt_uart_dev_desc },
77 { "INT33C6", (unsigned long)&lpt_sdio_dev_desc }, 150 { "INT33C6", (unsigned long)&lpt_sdio_dev_desc },
78 { "INT33C7", }, 151 { "INT33C7", },
79 152
153 /* BayTrail LPSS devices */
154 { "80860F0A", (unsigned long)&byt_uart_dev_desc },
155 { "80860F0E", (unsigned long)&byt_spi_dev_desc },
156 { "80860F14", (unsigned long)&byt_sdio_dev_desc },
157 { "80860F41", (unsigned long)&byt_i2c_dev_desc },
158 { "INT33B2", },
159
80 { } 160 { }
81}; 161};
82 162
@@ -98,7 +178,10 @@ static int register_device_clock(struct acpi_device *adev,
98 struct lpss_private_data *pdata) 178 struct lpss_private_data *pdata)
99{ 179{
100 const struct lpss_device_desc *dev_desc = pdata->dev_desc; 180 const struct lpss_device_desc *dev_desc = pdata->dev_desc;
181 struct lpss_shared_clock *shared_clock = dev_desc->shared_clock;
182 struct clk *clk = ERR_PTR(-ENODEV);
101 struct lpss_clk_data *clk_data; 183 struct lpss_clk_data *clk_data;
184 const char *parent;
102 185
103 if (!lpss_clk_dev) 186 if (!lpss_clk_dev)
104 lpt_register_clock_device(); 187 lpt_register_clock_device();
@@ -117,14 +200,30 @@ static int register_device_clock(struct acpi_device *adev,
117 || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE) 200 || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
118 return -ENODATA; 201 return -ENODATA;
119 202
120 pdata->clk = clk_register_gate(NULL, dev_name(&adev->dev), 203 parent = clk_data->name;
121 clk_data->name, 0, 204
122 pdata->mmio_base + dev_desc->prv_offset, 205 if (shared_clock) {
123 0, 0, NULL); 206 clk = shared_clock->clk;
124 if (IS_ERR(pdata->clk)) 207 if (!clk) {
125 return PTR_ERR(pdata->clk); 208 clk = clk_register_fixed_rate(NULL, shared_clock->name,
209 "lpss_clk", 0,
210 shared_clock->rate);
211 shared_clock->clk = clk;
212 }
213 parent = shared_clock->name;
214 }
215
216 if (dev_desc->clk_gate) {
217 clk = clk_register_gate(NULL, dev_name(&adev->dev), parent, 0,
218 pdata->mmio_base + dev_desc->prv_offset,
219 0, 0, NULL);
220 pdata->clk = clk;
221 }
126 222
127 clk_register_clkdev(pdata->clk, NULL, dev_name(&adev->dev)); 223 if (IS_ERR(clk))
224 return PTR_ERR(clk);
225
226 clk_register_clkdev(clk, NULL, dev_name(&adev->dev));
128 return 0; 227 return 0;
129} 228}
130 229
@@ -152,7 +251,10 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
152 251
153 list_for_each_entry(rentry, &resource_list, node) 252 list_for_each_entry(rentry, &resource_list, node)
154 if (resource_type(&rentry->res) == IORESOURCE_MEM) { 253 if (resource_type(&rentry->res) == IORESOURCE_MEM) {
155 pdata->mmio_size = resource_size(&rentry->res); 254 if (dev_desc->prv_size_override)
255 pdata->mmio_size = dev_desc->prv_size_override;
256 else
257 pdata->mmio_size = resource_size(&rentry->res);
156 pdata->mmio_base = ioremap(rentry->res.start, 258 pdata->mmio_base = ioremap(rentry->res.start,
157 pdata->mmio_size); 259 pdata->mmio_size);
158 pdata->dev_desc = dev_desc; 260 pdata->dev_desc = dev_desc;
@@ -182,6 +284,9 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
182 goto err_out; 284 goto err_out;
183 } 285 }
184 286
287 if (dev_desc->setup)
288 dev_desc->setup(pdata);
289
185 adev->driver_data = pdata; 290 adev->driver_data = pdata;
186 ret = acpi_create_platform_device(adev, id); 291 ret = acpi_create_platform_device(adev, id);
187 if (ret > 0) 292 if (ret > 0)
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 5e6301e94920..999adb5499c7 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <linux/memory.h>
31#include <linux/memory_hotplug.h> 32#include <linux/memory_hotplug.h>
32 33
33#include "internal.h" 34#include "internal.h"
@@ -166,13 +167,50 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
166 return 0; 167 return 0;
167} 168}
168 169
170static unsigned long acpi_meminfo_start_pfn(struct acpi_memory_info *info)
171{
172 return PFN_DOWN(info->start_addr);
173}
174
175static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info)
176{
177 return PFN_UP(info->start_addr + info->length-1);
178}
179
180static int acpi_bind_memblk(struct memory_block *mem, void *arg)
181{
182 return acpi_bind_one(&mem->dev, (acpi_handle)arg);
183}
184
185static int acpi_bind_memory_blocks(struct acpi_memory_info *info,
186 acpi_handle handle)
187{
188 return walk_memory_range(acpi_meminfo_start_pfn(info),
189 acpi_meminfo_end_pfn(info), (void *)handle,
190 acpi_bind_memblk);
191}
192
193static int acpi_unbind_memblk(struct memory_block *mem, void *arg)
194{
195 acpi_unbind_one(&mem->dev);
196 return 0;
197}
198
199static void acpi_unbind_memory_blocks(struct acpi_memory_info *info,
200 acpi_handle handle)
201{
202 walk_memory_range(acpi_meminfo_start_pfn(info),
203 acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk);
204}
205
169static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) 206static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
170{ 207{
208 acpi_handle handle = mem_device->device->handle;
171 int result, num_enabled = 0; 209 int result, num_enabled = 0;
172 struct acpi_memory_info *info; 210 struct acpi_memory_info *info;
173 int node; 211 int node;
174 212
175 node = acpi_get_node(mem_device->device->handle); 213 node = acpi_get_node(handle);
176 /* 214 /*
177 * Tell the VM there is more memory here... 215 * Tell the VM there is more memory here...
178 * Note: Assume that this function returns zero on success 216 * Note: Assume that this function returns zero on success
@@ -203,6 +241,12 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
203 if (result && result != -EEXIST) 241 if (result && result != -EEXIST)
204 continue; 242 continue;
205 243
244 result = acpi_bind_memory_blocks(info, handle);
245 if (result) {
246 acpi_unbind_memory_blocks(info, handle);
247 return -ENODEV;
248 }
249
206 info->enabled = 1; 250 info->enabled = 1;
207 251
208 /* 252 /*
@@ -227,12 +271,11 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
227 return 0; 271 return 0;
228} 272}
229 273
230static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device) 274static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
231{ 275{
232 int result = 0, nid; 276 acpi_handle handle = mem_device->device->handle;
233 struct acpi_memory_info *info, *n; 277 struct acpi_memory_info *info, *n;
234 278 int nid = acpi_get_node(handle);
235 nid = acpi_get_node(mem_device->device->handle);
236 279
237 list_for_each_entry_safe(info, n, &mem_device->res_list, list) { 280 list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
238 if (!info->enabled) 281 if (!info->enabled)
@@ -240,15 +283,12 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
240 283
241 if (nid < 0) 284 if (nid < 0)
242 nid = memory_add_physaddr_to_nid(info->start_addr); 285 nid = memory_add_physaddr_to_nid(info->start_addr);
243 result = remove_memory(nid, info->start_addr, info->length);
244 if (result)
245 return result;
246 286
287 acpi_unbind_memory_blocks(info, handle);
288 remove_memory(nid, info->start_addr, info->length);
247 list_del(&info->list); 289 list_del(&info->list);
248 kfree(info); 290 kfree(info);
249 } 291 }
250
251 return result;
252} 292}
253 293
254static void acpi_memory_device_free(struct acpi_memory_device *mem_device) 294static void acpi_memory_device_free(struct acpi_memory_device *mem_device)
@@ -283,6 +323,7 @@ static int acpi_memory_device_add(struct acpi_device *device,
283 /* Get the range from the _CRS */ 323 /* Get the range from the _CRS */
284 result = acpi_memory_get_device_resources(mem_device); 324 result = acpi_memory_get_device_resources(mem_device);
285 if (result) { 325 if (result) {
326 device->driver_data = NULL;
286 kfree(mem_device); 327 kfree(mem_device);
287 return result; 328 return result;
288 } 329 }
@@ -300,7 +341,7 @@ static int acpi_memory_device_add(struct acpi_device *device,
300 if (result) { 341 if (result) {
301 dev_err(&device->dev, "acpi_memory_enable_device() error\n"); 342 dev_err(&device->dev, "acpi_memory_enable_device() error\n");
302 acpi_memory_device_free(mem_device); 343 acpi_memory_device_free(mem_device);
303 return -ENODEV; 344 return result;
304 } 345 }
305 346
306 dev_dbg(&device->dev, "Memory device configured by ACPI\n"); 347 dev_dbg(&device->dev, "Memory device configured by ACPI\n");
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
new file mode 100644
index 000000000000..fd6c51cc3acb
--- /dev/null
+++ b/drivers/acpi/acpi_processor.c
@@ -0,0 +1,494 @@
1/*
2 * acpi_processor.c - ACPI processor enumeration support
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * Copyright (C) 2013, Intel Corporation
9 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published
13 * by the Free Software Foundation.
14 */
15
16#include <linux/acpi.h>
17#include <linux/device.h>
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/pci.h>
21
22#include <acpi/processor.h>
23
24#include <asm/cpu.h>
25
26#include "internal.h"
27
28#define _COMPONENT ACPI_PROCESSOR_COMPONENT
29
30ACPI_MODULE_NAME("processor");
31
32DEFINE_PER_CPU(struct acpi_processor *, processors);
33EXPORT_PER_CPU_SYMBOL(processors);
34
35/* --------------------------------------------------------------------------
36 Errata Handling
37 -------------------------------------------------------------------------- */
38
39struct acpi_processor_errata errata __read_mostly;
40EXPORT_SYMBOL_GPL(errata);
41
42static int acpi_processor_errata_piix4(struct pci_dev *dev)
43{
44 u8 value1 = 0;
45 u8 value2 = 0;
46
47
48 if (!dev)
49 return -EINVAL;
50
51 /*
52 * Note that 'dev' references the PIIX4 ACPI Controller.
53 */
54
55 switch (dev->revision) {
56 case 0:
57 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n"));
58 break;
59 case 1:
60 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n"));
61 break;
62 case 2:
63 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n"));
64 break;
65 case 3:
66 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n"));
67 break;
68 default:
69 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n"));
70 break;
71 }
72
73 switch (dev->revision) {
74
75 case 0: /* PIIX4 A-step */
76 case 1: /* PIIX4 B-step */
77 /*
78 * See specification changes #13 ("Manual Throttle Duty Cycle")
79 * and #14 ("Enabling and Disabling Manual Throttle"), plus
80 * erratum #5 ("STPCLK# Deassertion Time") from the January
81 * 2002 PIIX4 specification update. Applies to only older
82 * PIIX4 models.
83 */
84 errata.piix4.throttle = 1;
85
86 case 2: /* PIIX4E */
87 case 3: /* PIIX4M */
88 /*
89 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA
90 * Livelock") from the January 2002 PIIX4 specification update.
91 * Applies to all PIIX4 models.
92 */
93
94 /*
95 * BM-IDE
96 * ------
97 * Find the PIIX4 IDE Controller and get the Bus Master IDE
98 * Status register address. We'll use this later to read
99 * each IDE controller's DMA status to make sure we catch all
100 * DMA activity.
101 */
102 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
103 PCI_DEVICE_ID_INTEL_82371AB,
104 PCI_ANY_ID, PCI_ANY_ID, NULL);
105 if (dev) {
106 errata.piix4.bmisx = pci_resource_start(dev, 4);
107 pci_dev_put(dev);
108 }
109
110 /*
111 * Type-F DMA
112 * ----------
113 * Find the PIIX4 ISA Controller and read the Motherboard
114 * DMA controller's status to see if Type-F (Fast) DMA mode
115 * is enabled (bit 7) on either channel. Note that we'll
116 * disable C3 support if this is enabled, as some legacy
117 * devices won't operate well if fast DMA is disabled.
118 */
119 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
120 PCI_DEVICE_ID_INTEL_82371AB_0,
121 PCI_ANY_ID, PCI_ANY_ID, NULL);
122 if (dev) {
123 pci_read_config_byte(dev, 0x76, &value1);
124 pci_read_config_byte(dev, 0x77, &value2);
125 if ((value1 & 0x80) || (value2 & 0x80))
126 errata.piix4.fdma = 1;
127 pci_dev_put(dev);
128 }
129
130 break;
131 }
132
133 if (errata.piix4.bmisx)
134 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
135 "Bus master activity detection (BM-IDE) erratum enabled\n"));
136 if (errata.piix4.fdma)
137 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
138 "Type-F DMA livelock erratum (C3 disabled)\n"));
139
140 return 0;
141}
142
143static int acpi_processor_errata(struct acpi_processor *pr)
144{
145 int result = 0;
146 struct pci_dev *dev = NULL;
147
148
149 if (!pr)
150 return -EINVAL;
151
152 /*
153 * PIIX4
154 */
155 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
156 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
157 PCI_ANY_ID, NULL);
158 if (dev) {
159 result = acpi_processor_errata_piix4(dev);
160 pci_dev_put(dev);
161 }
162
163 return result;
164}
165
166/* --------------------------------------------------------------------------
167 Initialization
168 -------------------------------------------------------------------------- */
169
170#ifdef CONFIG_ACPI_HOTPLUG_CPU
171static int acpi_processor_hotadd_init(struct acpi_processor *pr)
172{
173 unsigned long long sta;
174 acpi_status status;
175 int ret;
176
177 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
178 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
179 return -ENODEV;
180
181 ret = acpi_map_lsapic(pr->handle, &pr->id);
182 if (ret)
183 return ret;
184
185 ret = arch_register_cpu(pr->id);
186 if (ret) {
187 acpi_unmap_lsapic(pr->id);
188 return ret;
189 }
190
191 /*
192 * CPU got hot-added, but cpu_data is not initialized yet. Set a flag
193 * to delay cpu_idle/throttling initialization and do it when the CPU
194 * gets online for the first time.
195 */
196 pr_info("CPU%d has been hot-added\n", pr->id);
197 pr->flags.need_hotplug_init = 1;
198 return 0;
199}
200#else
201static inline int acpi_processor_hotadd_init(struct acpi_processor *pr)
202{
203 return -ENODEV;
204}
205#endif /* CONFIG_ACPI_HOTPLUG_CPU */
206
207static int acpi_processor_get_info(struct acpi_device *device)
208{
209 union acpi_object object = { 0 };
210 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
211 struct acpi_processor *pr = acpi_driver_data(device);
212 int cpu_index, device_declaration = 0;
213 acpi_status status = AE_OK;
214 static int cpu0_initialized;
215
216 if (num_online_cpus() > 1)
217 errata.smp = TRUE;
218
219 acpi_processor_errata(pr);
220
221 /*
222 * Check to see if we have bus mastering arbitration control. This
223 * is required for proper C3 usage (to maintain cache coherency).
224 */
225 if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) {
226 pr->flags.bm_control = 1;
227 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
228 "Bus mastering arbitration control present\n"));
229 } else
230 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
231 "No bus mastering arbitration control\n"));
232
233 if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) {
234 /* Declared with "Processor" statement; match ProcessorID */
235 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
236 if (ACPI_FAILURE(status)) {
237 dev_err(&device->dev,
238 "Failed to evaluate processor object (0x%x)\n",
239 status);
240 return -ENODEV;
241 }
242
243 /*
244 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
245 * >>> 'acpi_get_processor_id(acpi_id, &id)' in
246 * arch/xxx/acpi.c
247 */
248 pr->acpi_id = object.processor.proc_id;
249 } else {
250 /*
251 * Declared with "Device" statement; match _UID.
252 * Note that we don't handle string _UIDs yet.
253 */
254 unsigned long long value;
255 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
256 NULL, &value);
257 if (ACPI_FAILURE(status)) {
258 dev_err(&device->dev,
259 "Failed to evaluate processor _UID (0x%x)\n",
260 status);
261 return -ENODEV;
262 }
263 device_declaration = 1;
264 pr->acpi_id = value;
265 }
266 cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id);
267
268 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
269 if (!cpu0_initialized && (cpu_index == -1) &&
270 (num_online_cpus() == 1)) {
271 cpu_index = 0;
272 }
273
274 cpu0_initialized = 1;
275
276 pr->id = cpu_index;
277
278 /*
279 * Extra Processor objects may be enumerated on MP systems with
280 * less than the max # of CPUs. They should be ignored _iff
281 * they are physically not present.
282 */
283 if (pr->id == -1) {
284 int ret = acpi_processor_hotadd_init(pr);
285 if (ret)
286 return ret;
287 }
288 /*
289 * On some boxes several processors use the same processor bus id.
290 * But they are located in different scope. For example:
291 * \_SB.SCK0.CPU0
292 * \_SB.SCK1.CPU0
293 * Rename the processor device bus id. And the new bus id will be
294 * generated as the following format:
295 * CPU+CPU ID.
296 */
297 sprintf(acpi_device_bid(device), "CPU%X", pr->id);
298 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
299 pr->acpi_id));
300
301 if (!object.processor.pblk_address)
302 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
303 else if (object.processor.pblk_length != 6)
304 dev_err(&device->dev, "Invalid PBLK length [%d]\n",
305 object.processor.pblk_length);
306 else {
307 pr->throttling.address = object.processor.pblk_address;
308 pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset;
309 pr->throttling.duty_width = acpi_gbl_FADT.duty_width;
310
311 pr->pblk = object.processor.pblk_address;
312
313 /*
314 * We don't care about error returns - we just try to mark
315 * these reserved so that nobody else is confused into thinking
316 * that this region might be unused..
317 *
318 * (In particular, allocating the IO range for Cardbus)
319 */
320 request_region(pr->throttling.address, 6, "ACPI CPU throttle");
321 }
322
323 /*
324 * If ACPI describes a slot number for this CPU, we can use it to
325 * ensure we get the right value in the "physical id" field
326 * of /proc/cpuinfo
327 */
328 status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer);
329 if (ACPI_SUCCESS(status))
330 arch_fix_phys_package_id(pr->id, object.integer.value);
331
332 return 0;
333}
334
335/*
336 * Do not put anything in here which needs the core to be online.
337 * For example MSR access or setting up things which check for cpuinfo_x86
338 * (cpu_data(cpu)) values, like CPU feature flags, family, model, etc.
339 * Such things have to be put in and set up by the processor driver's .probe().
340 */
341static DEFINE_PER_CPU(void *, processor_device_array);
342
343static int acpi_processor_add(struct acpi_device *device,
344 const struct acpi_device_id *id)
345{
346 struct acpi_processor *pr;
347 struct device *dev;
348 int result = 0;
349
350 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
351 if (!pr)
352 return -ENOMEM;
353
354 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
355 result = -ENOMEM;
356 goto err_free_pr;
357 }
358
359 pr->handle = device->handle;
360 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
361 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
362 device->driver_data = pr;
363
364 result = acpi_processor_get_info(device);
365 if (result) /* Processor is not physically present or unavailable */
366 return 0;
367
368#ifdef CONFIG_SMP
369 if (pr->id >= setup_max_cpus && pr->id != 0)
370 return 0;
371#endif
372
373 BUG_ON(pr->id >= nr_cpu_ids);
374
375 /*
376 * Buggy BIOS check.
377 * ACPI id of processors can be reported wrongly by the BIOS.
378 * Don't trust it blindly
379 */
380 if (per_cpu(processor_device_array, pr->id) != NULL &&
381 per_cpu(processor_device_array, pr->id) != device) {
382 dev_warn(&device->dev,
383 "BIOS reported wrong ACPI id %d for the processor\n",
384 pr->id);
385 /* Give up, but do not abort the namespace scan. */
386 goto err;
387 }
388 /*
389 * processor_device_array is not cleared on errors to allow buggy BIOS
390 * checks.
391 */
392 per_cpu(processor_device_array, pr->id) = device;
393 per_cpu(processors, pr->id) = pr;
394
395 dev = get_cpu_device(pr->id);
396 if (!dev) {
397 result = -ENODEV;
398 goto err;
399 }
400
401 result = acpi_bind_one(dev, pr->handle);
402 if (result)
403 goto err;
404
405 pr->dev = dev;
406 dev->offline = pr->flags.need_hotplug_init;
407
408 /* Trigger the processor driver's .probe() if present. */
409 if (device_attach(dev) >= 0)
410 return 1;
411
412 dev_err(dev, "Processor driver could not be attached\n");
413 acpi_unbind_one(dev);
414
415 err:
416 free_cpumask_var(pr->throttling.shared_cpu_map);
417 device->driver_data = NULL;
418 per_cpu(processors, pr->id) = NULL;
419 err_free_pr:
420 kfree(pr);
421 return result;
422}
423
424#ifdef CONFIG_ACPI_HOTPLUG_CPU
425/* --------------------------------------------------------------------------
426 Removal
427 -------------------------------------------------------------------------- */
428
429static void acpi_processor_remove(struct acpi_device *device)
430{
431 struct acpi_processor *pr;
432
433 if (!device || !acpi_driver_data(device))
434 return;
435
436 pr = acpi_driver_data(device);
437 if (pr->id >= nr_cpu_ids)
438 goto out;
439
440 /*
441 * The only reason why we ever get here is CPU hot-removal. The CPU is
442 * already offline and the ACPI device removal locking prevents it from
443 * being put back online at this point.
444 *
445 * Unbind the driver from the processor device and detach it from the
446 * ACPI companion object.
447 */
448 device_release_driver(pr->dev);
449 acpi_unbind_one(pr->dev);
450
451 /* Clean up. */
452 per_cpu(processor_device_array, pr->id) = NULL;
453 per_cpu(processors, pr->id) = NULL;
454 try_offline_node(cpu_to_node(pr->id));
455
456 /* Remove the CPU. */
457 get_online_cpus();
458 arch_unregister_cpu(pr->id);
459 acpi_unmap_lsapic(pr->id);
460 put_online_cpus();
461
462 out:
463 free_cpumask_var(pr->throttling.shared_cpu_map);
464 kfree(pr);
465}
466#endif /* CONFIG_ACPI_HOTPLUG_CPU */
467
468/*
469 * The following ACPI IDs are known to be suitable for representing as
470 * processor devices.
471 */
472static const struct acpi_device_id processor_device_ids[] = {
473
474 { ACPI_PROCESSOR_OBJECT_HID, },
475 { ACPI_PROCESSOR_DEVICE_HID, },
476
477 { }
478};
479
480static struct acpi_scan_handler __refdata processor_handler = {
481 .ids = processor_device_ids,
482 .attach = acpi_processor_add,
483#ifdef CONFIG_ACPI_HOTPLUG_CPU
484 .detach = acpi_processor_remove,
485#endif
486 .hotplug = {
487 .enabled = true,
488 },
489};
490
491void __init acpi_processor_init(void)
492{
493 acpi_scan_add_handler_with_hotplug(&processor_handler, "processor");
494}
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 7ddf29eca9f5..438304086ff1 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -83,6 +83,7 @@ acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o
83acpi-y += \ 83acpi-y += \
84 nsaccess.o \ 84 nsaccess.o \
85 nsalloc.o \ 85 nsalloc.o \
86 nsarguments.o \
86 nsconvert.o \ 87 nsconvert.o \
87 nsdump.o \ 88 nsdump.o \
88 nseval.o \ 89 nseval.o \
@@ -137,6 +138,7 @@ acpi-y += \
137 tbfadt.o \ 138 tbfadt.o \
138 tbfind.o \ 139 tbfind.o \
139 tbinstal.o \ 140 tbinstal.o \
141 tbprint.o \
140 tbutils.o \ 142 tbutils.o \
141 tbxface.o \ 143 tbxface.o \
142 tbxfload.o \ 144 tbxfload.o \
@@ -145,11 +147,13 @@ acpi-y += \
145acpi-y += \ 147acpi-y += \
146 utaddress.o \ 148 utaddress.o \
147 utalloc.o \ 149 utalloc.o \
150 utbuffer.o \
148 utcopy.o \ 151 utcopy.o \
149 utexcep.o \ 152 utexcep.o \
150 utdebug.o \ 153 utdebug.o \
151 utdecode.o \ 154 utdecode.o \
152 utdelete.o \ 155 utdelete.o \
156 uterror.o \
153 uteval.o \ 157 uteval.o \
154 utglobal.o \ 158 utglobal.o \
155 utids.o \ 159 utids.o \
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 07160928ca25..b8d38117a20c 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -132,6 +132,12 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_truncate_io_addresses, FALSE);
132 */ 132 */
133u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_auto_repair, FALSE); 133u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_auto_repair, FALSE);
134 134
135/*
136 * Optionally do not load any SSDTs from the RSDT/XSDT during initialization.
137 * This can be useful for debugging ACPI problems on some machines.
138 */
139u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_ssdt_table_load, FALSE);
140
135/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */ 141/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */
136 142
137struct acpi_table_fadt acpi_gbl_FADT; 143struct acpi_table_fadt acpi_gbl_FADT;
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index d5bfbd331bfd..d4a4901637cd 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -362,23 +362,6 @@ union acpi_predefined_info {
362 362
363#pragma pack() 363#pragma pack()
364 364
365/* Data block used during object validation */
366
367struct acpi_predefined_data {
368 char *pathname;
369 const union acpi_predefined_info *predefined;
370 union acpi_operand_object *parent_package;
371 struct acpi_namespace_node *node;
372 u32 flags;
373 u32 return_btype;
374 u8 node_flags;
375};
376
377/* Defines for Flags field above */
378
379#define ACPI_OBJECT_REPAIRED 1
380#define ACPI_OBJECT_WRAPPED 2
381
382/* Return object auto-repair info */ 365/* Return object auto-repair info */
383 366
384typedef acpi_status(*acpi_object_converter) (union acpi_operand_object 367typedef acpi_status(*acpi_object_converter) (union acpi_operand_object
@@ -948,19 +931,6 @@ struct acpi_bit_register_info {
948 931
949/* Structs and definitions for _OSI support and I/O port validation */ 932/* Structs and definitions for _OSI support and I/O port validation */
950 933
951#define ACPI_OSI_WIN_2000 0x01
952#define ACPI_OSI_WIN_XP 0x02
953#define ACPI_OSI_WIN_XP_SP1 0x03
954#define ACPI_OSI_WINSRV_2003 0x04
955#define ACPI_OSI_WIN_XP_SP2 0x05
956#define ACPI_OSI_WINSRV_2003_SP1 0x06
957#define ACPI_OSI_WIN_VISTA 0x07
958#define ACPI_OSI_WINSRV_2008 0x08
959#define ACPI_OSI_WIN_VISTA_SP1 0x09
960#define ACPI_OSI_WIN_VISTA_SP2 0x0A
961#define ACPI_OSI_WIN_7 0x0B
962#define ACPI_OSI_WIN_8 0x0C
963
964#define ACPI_ALWAYS_ILLEGAL 0x00 934#define ACPI_ALWAYS_ILLEGAL 0x00
965 935
966struct acpi_interface_info { 936struct acpi_interface_info {
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 53666bd9193d..530a2f8c1252 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -374,10 +374,11 @@
374 * the plist contains a set of parens to allow variable-length lists. 374 * the plist contains a set of parens to allow variable-length lists.
375 * These macros are used for both the debug and non-debug versions of the code. 375 * These macros are used for both the debug and non-debug versions of the code.
376 */ 376 */
377#define ACPI_ERROR_NAMESPACE(s, e) acpi_ut_namespace_error (AE_INFO, s, e); 377#define ACPI_ERROR_NAMESPACE(s, e) acpi_ut_namespace_error (AE_INFO, s, e);
378#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ut_method_error (AE_INFO, s, n, p, e); 378#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ut_method_error (AE_INFO, s, n, p, e);
379#define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist 379#define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist
380#define ACPI_INFO_PREDEFINED(plist) acpi_ut_predefined_info plist 380#define ACPI_INFO_PREDEFINED(plist) acpi_ut_predefined_info plist
381#define ACPI_BIOS_ERROR_PREDEFINED(plist) acpi_ut_predefined_bios_error plist
381 382
382#else 383#else
383 384
@@ -387,6 +388,7 @@
387#define ACPI_ERROR_METHOD(s, n, p, e) 388#define ACPI_ERROR_METHOD(s, n, p, e)
388#define ACPI_WARN_PREDEFINED(plist) 389#define ACPI_WARN_PREDEFINED(plist)
389#define ACPI_INFO_PREDEFINED(plist) 390#define ACPI_INFO_PREDEFINED(plist)
391#define ACPI_BIOS_ERROR_PREDEFINED(plist)
390 392
391#endif /* ACPI_NO_ERROR_MESSAGES */ 393#endif /* ACPI_NO_ERROR_MESSAGES */
392 394
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index d2e491876bc0..b83dc32a5ae0 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -223,22 +223,33 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info);
223void acpi_ns_exec_module_code_list(void); 223void acpi_ns_exec_module_code_list(void);
224 224
225/* 225/*
226 * nspredef - Support for predefined/reserved names 226 * nsarguments - Argument count/type checking for predefined/reserved names
227 */ 227 */
228acpi_status 228void
229acpi_ns_check_predefined_names(struct acpi_namespace_node *node, 229acpi_ns_check_argument_count(char *pathname,
230 u32 user_param_count, 230 struct acpi_namespace_node *node,
231 acpi_status return_status, 231 u32 user_param_count,
232 union acpi_operand_object **return_object); 232 const union acpi_predefined_info *info);
233 233
234void 234void
235acpi_ns_check_parameter_count(char *pathname, 235acpi_ns_check_acpi_compliance(char *pathname,
236 struct acpi_namespace_node *node, 236 struct acpi_namespace_node *node,
237 u32 user_param_count, 237 const union acpi_predefined_info *predefined);
238 const union acpi_predefined_info *info); 238
239void acpi_ns_check_argument_types(struct acpi_evaluate_info *info);
240
241/*
242 * nspredef - Return value checking for predefined/reserved names
243 */
244acpi_status
245acpi_ns_check_return_value(struct acpi_namespace_node *node,
246 struct acpi_evaluate_info *info,
247 u32 user_param_count,
248 acpi_status return_status,
249 union acpi_operand_object **return_object);
239 250
240acpi_status 251acpi_status
241acpi_ns_check_object_type(struct acpi_predefined_data *data, 252acpi_ns_check_object_type(struct acpi_evaluate_info *info,
242 union acpi_operand_object **return_object_ptr, 253 union acpi_operand_object **return_object_ptr,
243 u32 expected_btypes, u32 package_index); 254 u32 expected_btypes, u32 package_index);
244 255
@@ -246,7 +257,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
246 * nsprepkg - Validation of predefined name packages 257 * nsprepkg - Validation of predefined name packages
247 */ 258 */
248acpi_status 259acpi_status
249acpi_ns_check_package(struct acpi_predefined_data *data, 260acpi_ns_check_package(struct acpi_evaluate_info *info,
250 union acpi_operand_object **return_object_ptr); 261 union acpi_operand_object **return_object_ptr);
251 262
252/* 263/*
@@ -308,24 +319,24 @@ acpi_ns_get_attached_data(struct acpi_namespace_node *node,
308 * predefined methods/objects 319 * predefined methods/objects
309 */ 320 */
310acpi_status 321acpi_status
311acpi_ns_simple_repair(struct acpi_predefined_data *data, 322acpi_ns_simple_repair(struct acpi_evaluate_info *info,
312 u32 expected_btypes, 323 u32 expected_btypes,
313 u32 package_index, 324 u32 package_index,
314 union acpi_operand_object **return_object_ptr); 325 union acpi_operand_object **return_object_ptr);
315 326
316acpi_status 327acpi_status
317acpi_ns_wrap_with_package(struct acpi_predefined_data *data, 328acpi_ns_wrap_with_package(struct acpi_evaluate_info *info,
318 union acpi_operand_object *original_object, 329 union acpi_operand_object *original_object,
319 union acpi_operand_object **obj_desc_ptr); 330 union acpi_operand_object **obj_desc_ptr);
320 331
321acpi_status 332acpi_status
322acpi_ns_repair_null_element(struct acpi_predefined_data *data, 333acpi_ns_repair_null_element(struct acpi_evaluate_info *info,
323 u32 expected_btypes, 334 u32 expected_btypes,
324 u32 package_index, 335 u32 package_index,
325 union acpi_operand_object **return_object_ptr); 336 union acpi_operand_object **return_object_ptr);
326 337
327void 338void
328acpi_ns_remove_null_elements(struct acpi_predefined_data *data, 339acpi_ns_remove_null_elements(struct acpi_evaluate_info *info,
329 u8 package_type, 340 u8 package_type,
330 union acpi_operand_object *obj_desc); 341 union acpi_operand_object *obj_desc);
331 342
@@ -334,7 +345,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
334 * predefined methods/objects 345 * predefined methods/objects
335 */ 346 */
336acpi_status 347acpi_status
337acpi_ns_complex_repairs(struct acpi_predefined_data *data, 348acpi_ns_complex_repairs(struct acpi_evaluate_info *info,
338 struct acpi_namespace_node *node, 349 struct acpi_namespace_node *node,
339 acpi_status validate_status, 350 acpi_status validate_status,
340 union acpi_operand_object **return_object_ptr); 351 union acpi_operand_object **return_object_ptr);
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index b22b70944fd6..f600aded7261 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -128,8 +128,8 @@ enum acpi_return_package_types {
128#define ARG_COUNT_IS_MINIMUM 0x8000 128#define ARG_COUNT_IS_MINIMUM 0x8000
129#define METHOD_MAX_ARG_TYPE ACPI_TYPE_PACKAGE 129#define METHOD_MAX_ARG_TYPE ACPI_TYPE_PACKAGE
130 130
131#define METHOD_GET_COUNT(arg_list) (arg_list & METHOD_ARG_MASK) 131#define METHOD_GET_ARG_COUNT(arg_list) ((arg_list) & METHOD_ARG_MASK)
132#define METHOD_GET_NEXT_ARG(arg_list) (arg_list >> METHOD_ARG_BIT_WIDTH) 132#define METHOD_GET_NEXT_TYPE(arg_list) (((arg_list) >>= METHOD_ARG_BIT_WIDTH) & METHOD_ARG_MASK)
133 133
134/* Macros used to build the predefined info table */ 134/* Macros used to build the predefined info table */
135 135
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 7896d85876ca..fc83c0a5ca70 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -178,25 +178,41 @@ union acpi_aml_operands {
178}; 178};
179 179
180/* 180/*
181 * Structure used to pass object evaluation parameters. 181 * Structure used to pass object evaluation information and parameters.
182 * Purpose is to reduce CPU stack use. 182 * Purpose is to reduce CPU stack use.
183 */ 183 */
184struct acpi_evaluate_info { 184struct acpi_evaluate_info {
185 struct acpi_namespace_node *prefix_node; 185 /* The first 3 elements are passed by the caller to acpi_ns_evaluate */
186 char *pathname; 186
187 union acpi_operand_object *obj_desc; 187 struct acpi_namespace_node *prefix_node; /* Input: starting node */
188 union acpi_operand_object **parameters; 188 char *relative_pathname; /* Input: path relative to prefix_node */
189 struct acpi_namespace_node *resolved_node; 189 union acpi_operand_object **parameters; /* Input: argument list */
190 union acpi_operand_object *return_object; 190
191 u8 param_count; 191 struct acpi_namespace_node *node; /* Resolved node (prefix_node:relative_pathname) */
192 u8 pass_number; 192 union acpi_operand_object *obj_desc; /* Object attached to the resolved node */
193 u8 return_object_type; 193 char *full_pathname; /* Full pathname of the resolved node */
194 u8 flags; 194
195 const union acpi_predefined_info *predefined; /* Used if Node is a predefined name */
196 union acpi_operand_object *return_object; /* Object returned from the evaluation */
197 union acpi_operand_object *parent_package; /* Used if return object is a Package */
198
199 u32 return_flags; /* Used for return value analysis */
200 u32 return_btype; /* Bitmapped type of the returned object */
201 u16 param_count; /* Count of the input argument list */
202 u8 pass_number; /* Parser pass number */
203 u8 return_object_type; /* Object type of the returned object */
204 u8 node_flags; /* Same as Node->Flags */
205 u8 flags; /* General flags */
195}; 206};
196 207
197/* Values for Flags above */ 208/* Values for Flags above */
198 209
199#define ACPI_IGNORE_RETURN_VALUE 1 210#define ACPI_IGNORE_RETURN_VALUE 1
211
212/* Defines for return_flags field above */
213
214#define ACPI_OBJECT_REPAIRED 1
215#define ACPI_OBJECT_WRAPPED 2
200 216
201/* Info used by acpi_ns_initialize_devices */ 217/* Info used by acpi_ns_initialize_devices */
202 218
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 202f4f12d3e2..3c76edea6803 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -87,6 +87,48 @@ extern const char *acpi_gbl_fc_decode[];
87extern const char *acpi_gbl_pt_decode[]; 87extern const char *acpi_gbl_pt_decode[];
88#endif 88#endif
89 89
90/*
91 * For the iASL compiler case, the output is redirected to stderr so that
92 * any of the various ACPI errors and warnings do not appear in the output
93 * files, for either the compiler or disassembler portions of the tool.
94 */
95#ifdef ACPI_ASL_COMPILER
96
97#include <stdio.h>
98extern FILE *acpi_gbl_output_file;
99
100#define ACPI_MSG_REDIRECT_BEGIN \
101 FILE *output_file = acpi_gbl_output_file; \
102 acpi_os_redirect_output (stderr);
103
104#define ACPI_MSG_REDIRECT_END \
105 acpi_os_redirect_output (output_file);
106
107#else
108/*
109 * non-iASL case - no redirection, nothing to do
110 */
111#define ACPI_MSG_REDIRECT_BEGIN
112#define ACPI_MSG_REDIRECT_END
113#endif
114
115/*
116 * Common error message prefixes
117 */
118#define ACPI_MSG_ERROR "ACPI Error: "
119#define ACPI_MSG_EXCEPTION "ACPI Exception: "
120#define ACPI_MSG_WARNING "ACPI Warning: "
121#define ACPI_MSG_INFO "ACPI: "
122
123#define ACPI_MSG_BIOS_ERROR "ACPI BIOS Error (bug): "
124#define ACPI_MSG_BIOS_WARNING "ACPI BIOS Warning (bug): "
125
126/*
127 * Common message suffix
128 */
129#define ACPI_MSG_SUFFIX \
130 acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number)
131
90/* Types for Resource descriptor entries */ 132/* Types for Resource descriptor entries */
91 133
92#define ACPI_INVALID_RESOURCE 0 134#define ACPI_INVALID_RESOURCE 0
@@ -578,7 +620,7 @@ void acpi_ut_print_string(char *string, u8 max_length);
578 620
579void ut_convert_backslashes(char *pathname); 621void ut_convert_backslashes(char *pathname);
580 622
581u8 acpi_ut_valid_acpi_name(u32 name); 623u8 acpi_ut_valid_acpi_name(char *name);
582 624
583u8 acpi_ut_valid_acpi_char(char character, u32 position); 625u8 acpi_ut_valid_acpi_char(char character, u32 position);
584 626
@@ -670,6 +712,12 @@ acpi_ut_predefined_info(const char *module_name,
670 u32 line_number, 712 u32 line_number,
671 char *pathname, u8 node_flags, const char *format, ...); 713 char *pathname, u8 node_flags, const char *format, ...);
672 714
715void ACPI_INTERNAL_VAR_XFACE
716acpi_ut_predefined_bios_error(const char *module_name,
717 u32 line_number,
718 char *pathname,
719 u8 node_flags, const char *format, ...);
720
673void 721void
674acpi_ut_namespace_error(const char *module_name, 722acpi_ut_namespace_error(const char *module_name,
675 u32 line_number, 723 u32 line_number,
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c
index 7ea0f162f11c..eb56b66444b5 100644
--- a/drivers/acpi/acpica/dscontrol.c
+++ b/drivers/acpi/acpica/dscontrol.c
@@ -78,7 +78,6 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
78 78
79 switch (op->common.aml_opcode) { 79 switch (op->common.aml_opcode) {
80 case AML_WHILE_OP: 80 case AML_WHILE_OP:
81
82 /* 81 /*
83 * If this is an additional iteration of a while loop, continue. 82 * If this is an additional iteration of a while loop, continue.
84 * There is no need to allocate a new control state. 83 * There is no need to allocate a new control state.
@@ -99,7 +98,6 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
99 /*lint -fallthrough */ 98 /*lint -fallthrough */
100 99
101 case AML_IF_OP: 100 case AML_IF_OP:
102
103 /* 101 /*
104 * IF/WHILE: Create a new control state to manage these 102 * IF/WHILE: Create a new control state to manage these
105 * constructs. We need to manage these as a stack, in order 103 * constructs. We need to manage these as a stack, in order
@@ -142,6 +140,7 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
142 break; 140 break;
143 141
144 default: 142 default:
143
145 break; 144 break;
146 } 145 }
147 146
@@ -344,6 +343,7 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
344 case AML_NOOP_OP: 343 case AML_NOOP_OP:
345 344
346 /* Just do nothing! */ 345 /* Just do nothing! */
346
347 break; 347 break;
348 348
349 case AML_BREAK_POINT_OP: 349 case AML_BREAK_POINT_OP:
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index feadeed1012d..d4bfe7b7f90a 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -563,21 +563,25 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
563 */ 563 */
564 switch (walk_state->opcode) { 564 switch (walk_state->opcode) {
565 case AML_FIELD_OP: 565 case AML_FIELD_OP:
566
566 arg = acpi_ps_get_arg(op, 2); 567 arg = acpi_ps_get_arg(op, 2);
567 type = ACPI_TYPE_LOCAL_REGION_FIELD; 568 type = ACPI_TYPE_LOCAL_REGION_FIELD;
568 break; 569 break;
569 570
570 case AML_BANK_FIELD_OP: 571 case AML_BANK_FIELD_OP:
572
571 arg = acpi_ps_get_arg(op, 4); 573 arg = acpi_ps_get_arg(op, 4);
572 type = ACPI_TYPE_LOCAL_BANK_FIELD; 574 type = ACPI_TYPE_LOCAL_BANK_FIELD;
573 break; 575 break;
574 576
575 case AML_INDEX_FIELD_OP: 577 case AML_INDEX_FIELD_OP:
578
576 arg = acpi_ps_get_arg(op, 3); 579 arg = acpi_ps_get_arg(op, 3);
577 type = ACPI_TYPE_LOCAL_INDEX_FIELD; 580 type = ACPI_TYPE_LOCAL_INDEX_FIELD;
578 break; 581 break;
579 582
580 default: 583 default:
584
581 return_ACPI_STATUS(AE_BAD_PARAMETER); 585 return_ACPI_STATUS(AE_BAD_PARAMETER);
582 } 586 }
583 587
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index bc8e63f7784b..14424200d246 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -127,6 +127,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
127 break; 127 break;
128 128
129 default: 129 default:
130
130 break; 131 break;
131 } 132 }
132 133
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index 3da80460ce38..c4b0b3657237 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -285,6 +285,7 @@ acpi_ds_method_data_get_node(u8 type,
285 break; 285 break;
286 286
287 default: 287 default:
288
288 ACPI_ERROR((AE_INFO, "Type %u is invalid", type)); 289 ACPI_ERROR((AE_INFO, "Type %u is invalid", type));
289 return_ACPI_STATUS(AE_TYPE); 290 return_ACPI_STATUS(AE_TYPE);
290 } 291 }
@@ -428,7 +429,6 @@ acpi_ds_method_data_get_value(u8 type,
428 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); 429 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
429 430
430 case ACPI_REFCLASS_LOCAL: 431 case ACPI_REFCLASS_LOCAL:
431
432 /* 432 /*
433 * No error message for this case, will be trapped again later to 433 * No error message for this case, will be trapped again later to
434 * detect and ignore cases of Store(local_x,local_x) 434 * detect and ignore cases of Store(local_x,local_x)
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index e20e9f84eee8..63f0d220ca3d 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -648,7 +648,6 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
648 648
649 switch (obj_desc->common.type) { 649 switch (obj_desc->common.type) {
650 case ACPI_TYPE_BUFFER: 650 case ACPI_TYPE_BUFFER:
651
652 /* 651 /*
653 * Defer evaluation of Buffer term_arg operand 652 * Defer evaluation of Buffer term_arg operand
654 */ 653 */
@@ -660,7 +659,6 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
660 break; 659 break;
661 660
662 case ACPI_TYPE_PACKAGE: 661 case ACPI_TYPE_PACKAGE:
663
664 /* 662 /*
665 * Defer evaluation of Package term_arg operand 663 * Defer evaluation of Package term_arg operand
666 */ 664 */
@@ -741,6 +739,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
741 break; 739 break;
742 740
743 default: 741 default:
742
744 ACPI_ERROR((AE_INFO, "Unknown Integer type 0x%X", 743 ACPI_ERROR((AE_INFO, "Unknown Integer type 0x%X",
745 op_info->type)); 744 op_info->type));
746 status = AE_AML_OPERAND_TYPE; 745 status = AE_AML_OPERAND_TYPE;
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index ee6367b8eaf7..1fc1ff114f26 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -636,6 +636,7 @@ acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
636 break; 636 break;
637 637
638 default: 638 default:
639
639 return_ACPI_STATUS(AE_AML_BAD_OPCODE); 640 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
640 } 641 }
641 642
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index 99778997c35a..c666fc014987 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -240,7 +240,6 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
240 240
241 case AML_IF_OP: 241 case AML_IF_OP:
242 case AML_WHILE_OP: 242 case AML_WHILE_OP:
243
244 /* 243 /*
245 * If we are executing the predicate AND this is the predicate op, 244 * If we are executing the predicate AND this is the predicate op,
246 * we will use the return value 245 * we will use the return value
@@ -254,7 +253,9 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
254 break; 253 break;
255 254
256 default: 255 default:
256
257 /* Ignore other control opcodes */ 257 /* Ignore other control opcodes */
258
258 break; 259 break;
259 } 260 }
260 261
@@ -263,7 +264,6 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
263 goto result_not_used; 264 goto result_not_used;
264 265
265 case AML_CLASS_CREATE: 266 case AML_CLASS_CREATE:
266
267 /* 267 /*
268 * These opcodes allow term_arg(s) as operands and therefore 268 * These opcodes allow term_arg(s) as operands and therefore
269 * the operands can be method calls. The result is used. 269 * the operands can be method calls. The result is used.
@@ -292,7 +292,6 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
292 goto result_not_used; 292 goto result_not_used;
293 293
294 default: 294 default:
295
296 /* 295 /*
297 * In all other cases. the parent will actually use the return 296 * In all other cases. the parent will actually use the return
298 * object, so keep it. 297 * object, so keep it.
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index e2199a947470..151d924817e1 100644
--- a/drivers/acpi/acpica/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -327,6 +327,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
327 break; 327 break;
328 328
329 default: 329 default:
330
330 break; 331 break;
331 } 332 }
332 333
@@ -488,7 +489,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
488 break; 489 break;
489 490
490 case AML_TYPE_METHOD_CALL: 491 case AML_TYPE_METHOD_CALL:
491
492 /* 492 /*
493 * If the method is referenced from within a package 493 * If the method is referenced from within a package
494 * declaration, it is not a invocation of the method, just 494 * declaration, it is not a invocation of the method, just
@@ -582,7 +582,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
582 582
583 switch (op->common.parent->common.aml_opcode) { 583 switch (op->common.parent->common.aml_opcode) {
584 case AML_NAME_OP: 584 case AML_NAME_OP:
585
586 /* 585 /*
587 * Put the Node on the object stack (Contains the ACPI Name 586 * Put the Node on the object stack (Contains the ACPI Name
588 * of this object) 587 * of this object)
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 6e17c0e24e63..95e681a36f9c 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -74,6 +74,7 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number)
74 74
75 switch (pass_number) { 75 switch (pass_number) {
76 case 1: 76 case 1:
77
77 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | 78 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
78 ACPI_PARSE_DELETE_TREE; 79 ACPI_PARSE_DELETE_TREE;
79 walk_state->descending_callback = acpi_ds_load1_begin_op; 80 walk_state->descending_callback = acpi_ds_load1_begin_op;
@@ -81,6 +82,7 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number)
81 break; 82 break;
82 83
83 case 2: 84 case 2:
85
84 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | 86 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
85 ACPI_PARSE_DELETE_TREE; 87 ACPI_PARSE_DELETE_TREE;
86 walk_state->descending_callback = acpi_ds_load2_begin_op; 88 walk_state->descending_callback = acpi_ds_load2_begin_op;
@@ -88,6 +90,7 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number)
88 break; 90 break;
89 91
90 case 3: 92 case 3:
93
91#ifndef ACPI_NO_METHOD_EXECUTION 94#ifndef ACPI_NO_METHOD_EXECUTION
92 walk_state->parse_flags |= ACPI_PARSE_EXECUTE | 95 walk_state->parse_flags |= ACPI_PARSE_EXECUTE |
93 ACPI_PARSE_DELETE_TREE; 96 ACPI_PARSE_DELETE_TREE;
@@ -97,6 +100,7 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number)
97 break; 100 break;
98 101
99 default: 102 default:
103
100 return (AE_BAD_PARAMETER); 104 return (AE_BAD_PARAMETER);
101 } 105 }
102 106
@@ -161,7 +165,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
161 165
162 switch (walk_state->opcode) { 166 switch (walk_state->opcode) {
163 case AML_SCOPE_OP: 167 case AML_SCOPE_OP:
164
165 /* 168 /*
166 * The target name of the Scope() operator must exist at this point so 169 * The target name of the Scope() operator must exist at this point so
167 * that we can actually open the scope to enter new names underneath it. 170 * that we can actually open the scope to enter new names underneath it.
@@ -210,7 +213,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
210 case ACPI_TYPE_INTEGER: 213 case ACPI_TYPE_INTEGER:
211 case ACPI_TYPE_STRING: 214 case ACPI_TYPE_STRING:
212 case ACPI_TYPE_BUFFER: 215 case ACPI_TYPE_BUFFER:
213
214 /* 216 /*
215 * These types we will allow, but we will change the type. 217 * These types we will allow, but we will change the type.
216 * This enables some existing code of the form: 218 * This enables some existing code of the form:
@@ -232,7 +234,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
232 break; 234 break;
233 235
234 case ACPI_TYPE_METHOD: 236 case ACPI_TYPE_METHOD:
235
236 /* 237 /*
237 * Allow scope change to root during execution of module-level 238 * Allow scope change to root during execution of module-level
238 * code. Root is typed METHOD during this time. 239 * code. Root is typed METHOD during this time.
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
index 4407ff2377d5..b1f8f4725c23 100644
--- a/drivers/acpi/acpica/dswload2.c
+++ b/drivers/acpi/acpica/dswload2.c
@@ -509,6 +509,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
509 break; 509 break;
510 510
511 default: 511 default:
512
512 /* All NAMED_FIELD opcodes must be handled above */ 513 /* All NAMED_FIELD opcodes must be handled above */
513 break; 514 break;
514 } 515 }
@@ -548,6 +549,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
548 break; 549 break;
549 550
550 default: 551 default:
552
551 /* Unknown opcode */ 553 /* Unknown opcode */
552 554
553 status = AE_OK; 555 status = AE_OK;
@@ -674,6 +676,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
674#endif /* ACPI_NO_METHOD_EXECUTION */ 676#endif /* ACPI_NO_METHOD_EXECUTION */
675 677
676 default: 678 default:
679
677 /* All NAMED_COMPLEX opcodes must be handled above */ 680 /* All NAMED_COMPLEX opcodes must be handled above */
678 break; 681 break;
679 } 682 }
@@ -721,6 +724,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
721 break; 724 break;
722 725
723 default: 726 default:
727
724 break; 728 break;
725 } 729 }
726 730
diff --git a/drivers/acpi/acpica/evglock.c b/drivers/acpi/acpica/evglock.c
index a621481c6cf2..fdb0a76e40a3 100644
--- a/drivers/acpi/acpica/evglock.c
+++ b/drivers/acpi/acpica/evglock.c
@@ -128,6 +128,7 @@ acpi_status acpi_ev_remove_global_lock_handler(void)
128 status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL, 128 status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL,
129 acpi_ev_global_lock_handler); 129 acpi_ev_global_lock_handler);
130 130
131 acpi_os_delete_lock(acpi_gbl_global_lock_pending_lock);
131 return_ACPI_STATUS(status); 132 return_ACPI_STATUS(status);
132} 133}
133 134
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index a493b528f8f9..c8a1f7d5931f 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -529,7 +529,6 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
529 529
530 switch (local_gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) { 530 switch (local_gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) {
531 case ACPI_GPE_DISPATCH_NOTIFY: 531 case ACPI_GPE_DISPATCH_NOTIFY:
532
533 /* 532 /*
534 * Implicit notify. 533 * Implicit notify.
535 * Dispatch a DEVICE_WAKE notify to the appropriate handler. 534 * Dispatch a DEVICE_WAKE notify to the appropriate handler.
@@ -579,11 +578,11 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
579 (local_gpe_event_info->dispatch. 578 (local_gpe_event_info->dispatch.
580 method_node))); 579 method_node)));
581 } 580 }
582
583 break; 581 break;
584 582
585 default: 583 default:
586 return_VOID; /* Should never happen */ 584
585 return_VOID; /* Should never happen */
587 } 586 }
588 587
589 /* Defer enabling of GPE until all notify handlers are done */ 588 /* Defer enabling of GPE until all notify handlers are done */
@@ -755,7 +754,6 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
755 754
756 case ACPI_GPE_DISPATCH_METHOD: 755 case ACPI_GPE_DISPATCH_METHOD:
757 case ACPI_GPE_DISPATCH_NOTIFY: 756 case ACPI_GPE_DISPATCH_NOTIFY:
758
759 /* 757 /*
760 * Execute the method associated with the GPE 758 * Execute the method associated with the GPE
761 * NOTE: Level-triggered GPEs are cleared after the method completes. 759 * NOTE: Level-triggered GPEs are cleared after the method completes.
@@ -771,7 +769,6 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
771 break; 769 break;
772 770
773 default: 771 default:
774
775 /* 772 /*
776 * No handler or method to run! 773 * No handler or method to run!
777 * 03/2010: This case should no longer be possible. We will not allow 774 * 03/2010: This case should no longer be possible. We will not allow
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index a2d688bbac02..c1aa1eda26c3 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -382,6 +382,8 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
382 382
383 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); 383 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
384 if (ACPI_FAILURE(status)) { 384 if (ACPI_FAILURE(status)) {
385 ACPI_FREE(gpe_block->register_info);
386 ACPI_FREE(gpe_block->event_info);
385 ACPI_FREE(gpe_block); 387 ACPI_FREE(gpe_block);
386 return_ACPI_STATUS(status); 388 return_ACPI_STATUS(status);
387 } 389 }
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index 72b8f6b3f4ca..9037f17c9608 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -363,14 +363,17 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
363 */ 363 */
364 switch (name[1]) { 364 switch (name[1]) {
365 case 'L': 365 case 'L':
366
366 type = ACPI_GPE_LEVEL_TRIGGERED; 367 type = ACPI_GPE_LEVEL_TRIGGERED;
367 break; 368 break;
368 369
369 case 'E': 370 case 'E':
371
370 type = ACPI_GPE_EDGE_TRIGGERED; 372 type = ACPI_GPE_EDGE_TRIGGERED;
371 break; 373 break;
372 374
373 default: 375 default:
376
374 /* Unknown method type, just ignore it */ 377 /* Unknown method type, just ignore it */
375 378
376 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, 379 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c
index d4f83112c2e2..068af96134b8 100644
--- a/drivers/acpi/acpica/evhandler.c
+++ b/drivers/acpi/acpica/evhandler.c
@@ -354,36 +354,43 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
354 354
355 switch (space_id) { 355 switch (space_id) {
356 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 356 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
357
357 handler = acpi_ex_system_memory_space_handler; 358 handler = acpi_ex_system_memory_space_handler;
358 setup = acpi_ev_system_memory_region_setup; 359 setup = acpi_ev_system_memory_region_setup;
359 break; 360 break;
360 361
361 case ACPI_ADR_SPACE_SYSTEM_IO: 362 case ACPI_ADR_SPACE_SYSTEM_IO:
363
362 handler = acpi_ex_system_io_space_handler; 364 handler = acpi_ex_system_io_space_handler;
363 setup = acpi_ev_io_space_region_setup; 365 setup = acpi_ev_io_space_region_setup;
364 break; 366 break;
365 367
366 case ACPI_ADR_SPACE_PCI_CONFIG: 368 case ACPI_ADR_SPACE_PCI_CONFIG:
369
367 handler = acpi_ex_pci_config_space_handler; 370 handler = acpi_ex_pci_config_space_handler;
368 setup = acpi_ev_pci_config_region_setup; 371 setup = acpi_ev_pci_config_region_setup;
369 break; 372 break;
370 373
371 case ACPI_ADR_SPACE_CMOS: 374 case ACPI_ADR_SPACE_CMOS:
375
372 handler = acpi_ex_cmos_space_handler; 376 handler = acpi_ex_cmos_space_handler;
373 setup = acpi_ev_cmos_region_setup; 377 setup = acpi_ev_cmos_region_setup;
374 break; 378 break;
375 379
376 case ACPI_ADR_SPACE_PCI_BAR_TARGET: 380 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
381
377 handler = acpi_ex_pci_bar_space_handler; 382 handler = acpi_ex_pci_bar_space_handler;
378 setup = acpi_ev_pci_bar_region_setup; 383 setup = acpi_ev_pci_bar_region_setup;
379 break; 384 break;
380 385
381 case ACPI_ADR_SPACE_DATA_TABLE: 386 case ACPI_ADR_SPACE_DATA_TABLE:
387
382 handler = acpi_ex_data_table_space_handler; 388 handler = acpi_ex_data_table_space_handler;
383 setup = NULL; 389 setup = NULL;
384 break; 390 break;
385 391
386 default: 392 default:
393
387 status = AE_BAD_PARAMETER; 394 status = AE_BAD_PARAMETER;
388 goto unlock_and_exit; 395 goto unlock_and_exit;
389 } 396 }
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index c986b2336b81..1b111ef74903 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -78,6 +78,7 @@ u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node)
78 return (TRUE); 78 return (TRUE);
79 79
80 default: 80 default:
81
81 return (FALSE); 82 return (FALSE);
82 } 83 }
83} 84}
@@ -275,6 +276,8 @@ void acpi_ev_terminate(void)
275 ACPI_ERROR((AE_INFO, 276 ACPI_ERROR((AE_INFO,
276 "Could not remove Global Lock handler")); 277 "Could not remove Global Lock handler"));
277 } 278 }
279
280 acpi_gbl_events_initialized = FALSE;
278 } 281 }
279 282
280 /* Deallocate all handler objects installed within GPE info structs */ 283 /* Deallocate all handler objects installed within GPE info structs */
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 6555e350fc1f..cea14d6fc76c 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -54,7 +54,8 @@ extern u8 acpi_gbl_default_address_spaces[];
54 54
55/* Local prototypes */ 55/* Local prototypes */
56 56
57static void acpi_ev_orphan_ec_reg_method(void); 57static void
58acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node);
58 59
59static acpi_status 60static acpi_status
60acpi_ev_reg_run(acpi_handle obj_handle, 61acpi_ev_reg_run(acpi_handle obj_handle,
@@ -532,7 +533,7 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
532 } 533 }
533 534
534 info->prefix_node = region_obj2->extra.method_REG; 535 info->prefix_node = region_obj2->extra.method_REG;
535 info->pathname = NULL; 536 info->relative_pathname = NULL;
536 info->parameters = args; 537 info->parameters = args;
537 info->flags = ACPI_IGNORE_RETURN_VALUE; 538 info->flags = ACPI_IGNORE_RETURN_VALUE;
538 539
@@ -612,7 +613,7 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
612 /* Special case for EC: handle "orphan" _REG methods with no region */ 613 /* Special case for EC: handle "orphan" _REG methods with no region */
613 614
614 if (space_id == ACPI_ADR_SPACE_EC) { 615 if (space_id == ACPI_ADR_SPACE_EC) {
615 acpi_ev_orphan_ec_reg_method(); 616 acpi_ev_orphan_ec_reg_method(node);
616 } 617 }
617 618
618 return_ACPI_STATUS(status); 619 return_ACPI_STATUS(status);
@@ -681,7 +682,7 @@ acpi_ev_reg_run(acpi_handle obj_handle,
681 * 682 *
682 * FUNCTION: acpi_ev_orphan_ec_reg_method 683 * FUNCTION: acpi_ev_orphan_ec_reg_method
683 * 684 *
684 * PARAMETERS: None 685 * PARAMETERS: ec_device_node - Namespace node for an EC device
685 * 686 *
686 * RETURN: None 687 * RETURN: None
687 * 688 *
@@ -693,37 +694,27 @@ acpi_ev_reg_run(acpi_handle obj_handle,
693 * detected by providing a _REG method object underneath the 694 * detected by providing a _REG method object underneath the
694 * Embedded Controller device." 695 * Embedded Controller device."
695 * 696 *
696 * To quickly access the EC device, we use the EC_ID that appears 697 * To quickly access the EC device, we use the ec_device_node used
697 * within the ECDT. Otherwise, we would need to perform a time- 698 * during EC handler installation. Otherwise, we would need to
698 * consuming namespace walk, executing _HID methods to find the 699 * perform a time consuming namespace walk, executing _HID
699 * EC device. 700 * methods to find the EC device.
701 *
702 * MUTEX: Assumes the namespace is locked
700 * 703 *
701 ******************************************************************************/ 704 ******************************************************************************/
702 705
703static void acpi_ev_orphan_ec_reg_method(void) 706static void
707acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node)
704{ 708{
705 struct acpi_table_ecdt *table; 709 acpi_handle reg_method;
710 struct acpi_namespace_node *next_node;
706 acpi_status status; 711 acpi_status status;
707 struct acpi_object_list args; 712 struct acpi_object_list args;
708 union acpi_object objects[2]; 713 union acpi_object objects[2];
709 struct acpi_namespace_node *ec_device_node;
710 struct acpi_namespace_node *reg_method;
711 struct acpi_namespace_node *next_node;
712 714
713 ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method); 715 ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
714 716
715 /* Get the ECDT (if present in system) */ 717 if (!ec_device_node) {
716
717 status = acpi_get_table(ACPI_SIG_ECDT, 0,
718 ACPI_CAST_INDIRECT_PTR(struct acpi_table_header,
719 &table));
720 if (ACPI_FAILURE(status)) {
721 return_VOID;
722 }
723
724 /* We need a valid EC_ID string */
725
726 if (!(*table->id)) {
727 return_VOID; 718 return_VOID;
728 } 719 }
729 720
@@ -731,22 +722,11 @@ static void acpi_ev_orphan_ec_reg_method(void)
731 722
732 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 723 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
733 724
734 /* Get a handle to the EC device referenced in the ECDT */
735
736 status = acpi_get_handle(NULL,
737 ACPI_CAST_PTR(char, table->id),
738 ACPI_CAST_PTR(acpi_handle, &ec_device_node));
739 if (ACPI_FAILURE(status)) {
740 goto exit;
741 }
742
743 /* Get a handle to a _REG method immediately under the EC device */ 725 /* Get a handle to a _REG method immediately under the EC device */
744 726
745 status = acpi_get_handle(ec_device_node, 727 status = acpi_get_handle(ec_device_node, METHOD_NAME__REG, &reg_method);
746 METHOD_NAME__REG, ACPI_CAST_PTR(acpi_handle,
747 &reg_method));
748 if (ACPI_FAILURE(status)) { 728 if (ACPI_FAILURE(status)) {
749 goto exit; 729 goto exit; /* There is no _REG method present */
750 } 730 }
751 731
752 /* 732 /*
@@ -754,19 +734,20 @@ static void acpi_ev_orphan_ec_reg_method(void)
754 * this scope with the Embedded Controller space ID. Otherwise, it 734 * this scope with the Embedded Controller space ID. Otherwise, it
755 * will already have been executed. Note, this allows for Regions 735 * will already have been executed. Note, this allows for Regions
756 * with other space IDs to be present; but the code below will then 736 * with other space IDs to be present; but the code below will then
757 * execute the _REG method with the EC space ID argument. 737 * execute the _REG method with the embedded_control space_ID argument.
758 */ 738 */
759 next_node = acpi_ns_get_next_node(ec_device_node, NULL); 739 next_node = acpi_ns_get_next_node(ec_device_node, NULL);
760 while (next_node) { 740 while (next_node) {
761 if ((next_node->type == ACPI_TYPE_REGION) && 741 if ((next_node->type == ACPI_TYPE_REGION) &&
762 (next_node->object) && 742 (next_node->object) &&
763 (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) { 743 (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) {
764 goto exit; /* Do not execute _REG */ 744 goto exit; /* Do not execute the _REG */
765 } 745 }
746
766 next_node = acpi_ns_get_next_node(ec_device_node, next_node); 747 next_node = acpi_ns_get_next_node(ec_device_node, next_node);
767 } 748 }
768 749
769 /* Evaluate the _REG(EC,Connect) method */ 750 /* Evaluate the _REG(embedded_control,Connect) method */
770 751
771 args.count = 2; 752 args.count = 2;
772 args.pointer = objects; 753 args.pointer = objects;
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 3bb616794b3b..8354c4f7f10c 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -596,7 +596,9 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
596 break; 596 break;
597 597
598 default: 598 default:
599
599 /* Ignore other objects */ 600 /* Ignore other objects */
601
600 break; 602 break;
601 } 603 }
602 604
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index aff4cc261211..7662f1a42ff6 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -366,16 +366,19 @@ acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action)
366 366
367 switch (action) { 367 switch (action) {
368 case ACPI_GPE_ENABLE: 368 case ACPI_GPE_ENABLE:
369
369 ACPI_SET_BIT(gpe_register_info->enable_for_wake, 370 ACPI_SET_BIT(gpe_register_info->enable_for_wake,
370 (u8)register_bit); 371 (u8)register_bit);
371 break; 372 break;
372 373
373 case ACPI_GPE_DISABLE: 374 case ACPI_GPE_DISABLE:
375
374 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, 376 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
375 (u8)register_bit); 377 (u8)register_bit);
376 break; 378 break;
377 379
378 default: 380 default:
381
379 ACPI_ERROR((AE_INFO, "%u, Invalid action", action)); 382 ACPI_ERROR((AE_INFO, "%u, Invalid action", action));
380 status = AE_BAD_PARAMETER; 383 status = AE_BAD_PARAMETER;
381 break; 384 break;
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index 96c9e5f355ae..80cecf838591 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -139,6 +139,7 @@ acpi_install_address_space_handler(acpi_handle device,
139 break; 139 break;
140 140
141 default: 141 default:
142
142 break; 143 break;
143 } 144 }
144 145
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index d93b70be60ad..06d216c8d43a 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -480,6 +480,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
480 break; 480 break;
481 481
482 default: 482 default:
483
483 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 484 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
484 } 485 }
485 486
@@ -588,7 +589,7 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
588 (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) || 589 (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
589 (ddb_handle->common.type != ACPI_TYPE_LOCAL_REFERENCE) || 590 (ddb_handle->common.type != ACPI_TYPE_LOCAL_REFERENCE) ||
590 (!(ddb_handle->common.flags & AOPOBJ_DATA_VALID))) { 591 (!(ddb_handle->common.flags & AOPOBJ_DATA_VALID))) {
591 return_ACPI_STATUS(AE_BAD_PARAMETER); 592 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
592 } 593 }
593 594
594 /* Get the table index from the ddb_handle */ 595 /* Get the table index from the ddb_handle */
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index d2b9613bbf01..69e4a8cc9b71 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -99,6 +99,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
99 break; 99 break;
100 100
101 default: 101 default:
102
102 return_ACPI_STATUS(AE_TYPE); 103 return_ACPI_STATUS(AE_TYPE);
103 } 104 }
104 105
@@ -117,7 +118,6 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
117 118
118 switch (obj_desc->common.type) { 119 switch (obj_desc->common.type) {
119 case ACPI_TYPE_STRING: 120 case ACPI_TYPE_STRING:
120
121 /* 121 /*
122 * Convert string to an integer - for most cases, the string must be 122 * Convert string to an integer - for most cases, the string must be
123 * hexadecimal as per the ACPI specification. The only exception (as 123 * hexadecimal as per the ACPI specification. The only exception (as
@@ -161,6 +161,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
161 default: 161 default:
162 162
163 /* No other types can get here */ 163 /* No other types can get here */
164
164 break; 165 break;
165 } 166 }
166 167
@@ -213,7 +214,6 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
213 return_ACPI_STATUS(AE_OK); 214 return_ACPI_STATUS(AE_OK);
214 215
215 case ACPI_TYPE_INTEGER: 216 case ACPI_TYPE_INTEGER:
216
217 /* 217 /*
218 * Create a new Buffer object. 218 * Create a new Buffer object.
219 * Need enough space for one integer 219 * Need enough space for one integer
@@ -233,7 +233,6 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
233 break; 233 break;
234 234
235 case ACPI_TYPE_STRING: 235 case ACPI_TYPE_STRING:
236
237 /* 236 /*
238 * Create a new Buffer object 237 * Create a new Buffer object
239 * Size will be the string length 238 * Size will be the string length
@@ -258,6 +257,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
258 break; 257 break;
259 258
260 default: 259 default:
260
261 return_ACPI_STATUS(AE_TYPE); 261 return_ACPI_STATUS(AE_TYPE);
262 } 262 }
263 263
@@ -304,15 +304,18 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
304 304
305 switch (data_width) { 305 switch (data_width) {
306 case 1: 306 case 1:
307
307 decimal_length = ACPI_MAX8_DECIMAL_DIGITS; 308 decimal_length = ACPI_MAX8_DECIMAL_DIGITS;
308 break; 309 break;
309 310
310 case 4: 311 case 4:
312
311 decimal_length = ACPI_MAX32_DECIMAL_DIGITS; 313 decimal_length = ACPI_MAX32_DECIMAL_DIGITS;
312 break; 314 break;
313 315
314 case 8: 316 case 8:
315 default: 317 default:
318
316 decimal_length = ACPI_MAX64_DECIMAL_DIGITS; 319 decimal_length = ACPI_MAX64_DECIMAL_DIGITS;
317 break; 320 break;
318 } 321 }
@@ -546,6 +549,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
546 break; 549 break;
547 550
548 default: 551 default:
552
549 return_ACPI_STATUS(AE_TYPE); 553 return_ACPI_STATUS(AE_TYPE);
550 } 554 }
551 555
@@ -599,6 +603,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
599 break; 603 break;
600 604
601 default: 605 default:
606
602 /* No conversion allowed for these types */ 607 /* No conversion allowed for these types */
603 608
604 if (destination_type != source_desc->common.type) { 609 if (destination_type != source_desc->common.type) {
@@ -649,6 +654,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
649 break; 654 break;
650 655
651 default: 656 default:
657
652 ACPI_ERROR((AE_INFO, 658 ACPI_ERROR((AE_INFO,
653 "Bad destination type during conversion: 0x%X", 659 "Bad destination type during conversion: 0x%X",
654 destination_type)); 660 destination_type));
@@ -664,6 +670,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
664 break; 670 break;
665 671
666 default: 672 default:
673
667 ACPI_ERROR((AE_INFO, 674 ACPI_ERROR((AE_INFO,
668 "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s", 675 "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
669 GET_CURRENT_ARG_TYPE(walk_state->op_info-> 676 GET_CURRENT_ARG_TYPE(walk_state->op_info->
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index 26a13f67977e..269e81d86ef4 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -103,7 +103,6 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
103 case ACPI_TYPE_BUFFER: 103 case ACPI_TYPE_BUFFER:
104 case ACPI_TYPE_PACKAGE: 104 case ACPI_TYPE_PACKAGE:
105 case ACPI_TYPE_BUFFER_FIELD: 105 case ACPI_TYPE_BUFFER_FIELD:
106
107 /* 106 /*
108 * These types open a new scope, so we need the NS node in order to access 107 * These types open a new scope, so we need the NS node in order to access
109 * any children. 108 * any children.
@@ -113,7 +112,6 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
113 case ACPI_TYPE_PROCESSOR: 112 case ACPI_TYPE_PROCESSOR:
114 case ACPI_TYPE_THERMAL: 113 case ACPI_TYPE_THERMAL:
115 case ACPI_TYPE_LOCAL_SCOPE: 114 case ACPI_TYPE_LOCAL_SCOPE:
116
117 /* 115 /*
118 * The new alias has the type ALIAS and points to the original 116 * The new alias has the type ALIAS and points to the original
119 * NS node, not the object itself. 117 * NS node, not the object itself.
@@ -124,7 +122,6 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
124 break; 122 break;
125 123
126 case ACPI_TYPE_METHOD: 124 case ACPI_TYPE_METHOD:
127
128 /* 125 /*
129 * Control method aliases need to be differentiated 126 * Control method aliases need to be differentiated
130 */ 127 */
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c
index 7eb853cd279f..81c72a4ecd82 100644
--- a/drivers/acpi/acpica/exdebug.c
+++ b/drivers/acpi/acpica/exdebug.c
@@ -193,6 +193,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
193 return_VOID; 193 return_VOID;
194 194
195 default: 195 default:
196
196 break; 197 break;
197 } 198 }
198 199
@@ -226,6 +227,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
226 break; 227 break;
227 228
228 default: 229 default:
230
229 acpi_ex_do_debug_object((source_desc-> 231 acpi_ex_do_debug_object((source_desc->
230 reference. 232 reference.
231 node)->object, 233 node)->object,
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index e5a3c249f7fa..c740f24e3101 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -357,6 +357,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
357 357
358 switch (info->opcode) { 358 switch (info->opcode) {
359 case ACPI_EXD_INIT: 359 case ACPI_EXD_INIT:
360
360 break; 361 break;
361 362
362 case ACPI_EXD_TYPE: 363 case ACPI_EXD_TYPE:
@@ -718,6 +719,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
718 break; 719 break;
719 720
720 default: 721 default:
722
721 /* Unknown Type */ 723 /* Unknown Type */
722 724
723 acpi_os_printf("Unknown Type %X\n", obj_desc->common.type); 725 acpi_os_printf("Unknown Type %X\n", obj_desc->common.type);
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index 7d4bae71e8c6..c2a65aaf29af 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -331,21 +331,25 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
331 331
332 switch (source_desc->common.type) { 332 switch (source_desc->common.type) {
333 case ACPI_TYPE_INTEGER: 333 case ACPI_TYPE_INTEGER:
334
334 buffer = &source_desc->integer.value; 335 buffer = &source_desc->integer.value;
335 length = sizeof(source_desc->integer.value); 336 length = sizeof(source_desc->integer.value);
336 break; 337 break;
337 338
338 case ACPI_TYPE_BUFFER: 339 case ACPI_TYPE_BUFFER:
340
339 buffer = source_desc->buffer.pointer; 341 buffer = source_desc->buffer.pointer;
340 length = source_desc->buffer.length; 342 length = source_desc->buffer.length;
341 break; 343 break;
342 344
343 case ACPI_TYPE_STRING: 345 case ACPI_TYPE_STRING:
346
344 buffer = source_desc->string.pointer; 347 buffer = source_desc->string.pointer;
345 length = source_desc->string.length; 348 length = source_desc->string.length;
346 break; 349 break;
347 350
348 default: 351 default:
352
349 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 353 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
350 } 354 }
351 355
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index c84ee956fa4c..7e0afe72487e 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -446,7 +446,6 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
446 break; 446 break;
447 447
448 case ACPI_TYPE_LOCAL_BANK_FIELD: 448 case ACPI_TYPE_LOCAL_BANK_FIELD:
449
450 /* 449 /*
451 * Ensure that the bank_value is not beyond the capacity of 450 * Ensure that the bank_value is not beyond the capacity of
452 * the register 451 * the register
@@ -488,7 +487,6 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
488 break; 487 break;
489 488
490 case ACPI_TYPE_LOCAL_INDEX_FIELD: 489 case ACPI_TYPE_LOCAL_INDEX_FIELD:
491
492 /* 490 /*
493 * Ensure that the index_value is not beyond the capacity of 491 * Ensure that the index_value is not beyond the capacity of
494 * the register 492 * the register
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 72a2a13b6d36..00bf29877574 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -105,7 +105,6 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
105 break; 105 break;
106 106
107 case ACPI_DESC_TYPE_NAMED: 107 case ACPI_DESC_TYPE_NAMED:
108
109 /* 108 /*
110 * A named reference that has already been resolved to a Node 109 * A named reference that has already been resolved to a Node
111 */ 110 */
@@ -261,20 +260,24 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
261 */ 260 */
262 switch (operand0->common.type) { 261 switch (operand0->common.type) {
263 case ACPI_TYPE_INTEGER: 262 case ACPI_TYPE_INTEGER:
263
264 status = 264 status =
265 acpi_ex_convert_to_integer(operand1, &local_operand1, 16); 265 acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
266 break; 266 break;
267 267
268 case ACPI_TYPE_STRING: 268 case ACPI_TYPE_STRING:
269
269 status = acpi_ex_convert_to_string(operand1, &local_operand1, 270 status = acpi_ex_convert_to_string(operand1, &local_operand1,
270 ACPI_IMPLICIT_CONVERT_HEX); 271 ACPI_IMPLICIT_CONVERT_HEX);
271 break; 272 break;
272 273
273 case ACPI_TYPE_BUFFER: 274 case ACPI_TYPE_BUFFER:
275
274 status = acpi_ex_convert_to_buffer(operand1, &local_operand1); 276 status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
275 break; 277 break;
276 278
277 default: 279 default:
280
278 ACPI_ERROR((AE_INFO, "Invalid object type: 0x%X", 281 ACPI_ERROR((AE_INFO, "Invalid object type: 0x%X",
279 operand0->common.type)); 282 operand0->common.type));
280 status = AE_AML_INTERNAL; 283 status = AE_AML_INTERNAL;
@@ -519,6 +522,7 @@ acpi_ex_do_logical_numeric_op(u16 opcode,
519 break; 522 break;
520 523
521 default: 524 default:
525
522 status = AE_AML_INTERNAL; 526 status = AE_AML_INTERNAL;
523 break; 527 break;
524 } 528 }
@@ -580,20 +584,24 @@ acpi_ex_do_logical_op(u16 opcode,
580 */ 584 */
581 switch (operand0->common.type) { 585 switch (operand0->common.type) {
582 case ACPI_TYPE_INTEGER: 586 case ACPI_TYPE_INTEGER:
587
583 status = 588 status =
584 acpi_ex_convert_to_integer(operand1, &local_operand1, 16); 589 acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
585 break; 590 break;
586 591
587 case ACPI_TYPE_STRING: 592 case ACPI_TYPE_STRING:
593
588 status = acpi_ex_convert_to_string(operand1, &local_operand1, 594 status = acpi_ex_convert_to_string(operand1, &local_operand1,
589 ACPI_IMPLICIT_CONVERT_HEX); 595 ACPI_IMPLICIT_CONVERT_HEX);
590 break; 596 break;
591 597
592 case ACPI_TYPE_BUFFER: 598 case ACPI_TYPE_BUFFER:
599
593 status = acpi_ex_convert_to_buffer(operand1, &local_operand1); 600 status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
594 break; 601 break;
595 602
596 default: 603 default:
604
597 status = AE_AML_INTERNAL; 605 status = AE_AML_INTERNAL;
598 break; 606 break;
599 } 607 }
@@ -636,6 +644,7 @@ acpi_ex_do_logical_op(u16 opcode,
636 break; 644 break;
637 645
638 default: 646 default:
647
639 status = AE_AML_INTERNAL; 648 status = AE_AML_INTERNAL;
640 break; 649 break;
641 } 650 }
@@ -703,6 +712,7 @@ acpi_ex_do_logical_op(u16 opcode,
703 break; 712 break;
704 713
705 default: 714 default:
715
706 status = AE_AML_INTERNAL; 716 status = AE_AML_INTERNAL;
707 break; 717 break;
708 } 718 }
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index b60c877f5906..814b4a3d656a 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -327,7 +327,6 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
327 break; 327 break;
328 328
329 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */ 329 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
330
331 /* 330 /*
332 * The 64-bit ACPI integer can hold 16 4-bit BCD characters 331 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
333 * (if table is 32-bit, integer can hold 8 BCD characters) 332 * (if table is 32-bit, integer can hold 8 BCD characters)
@@ -407,7 +406,6 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
407 break; 406 break;
408 407
409 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */ 408 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
410
411 /* 409 /*
412 * This op is a little strange because the internal return value is 410 * This op is a little strange because the internal return value is
413 * different than the return value stored in the result descriptor 411 * different than the return value stored in the result descriptor
@@ -442,13 +440,14 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
442 goto cleanup; 440 goto cleanup;
443 441
444 default: 442 default:
443
445 /* No other opcodes get here */ 444 /* No other opcodes get here */
445
446 break; 446 break;
447 } 447 }
448 break; 448 break;
449 449
450 case AML_STORE_OP: /* Store (Source, Target) */ 450 case AML_STORE_OP: /* Store (Source, Target) */
451
452 /* 451 /*
453 * A store operand is typically a number, string, buffer or lvalue 452 * A store operand is typically a number, string, buffer or lvalue
454 * Be careful about deleting the source object, 453 * Be careful about deleting the source object,
@@ -615,7 +614,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
615 614
616 case AML_DECREMENT_OP: /* Decrement (Operand) */ 615 case AML_DECREMENT_OP: /* Decrement (Operand) */
617 case AML_INCREMENT_OP: /* Increment (Operand) */ 616 case AML_INCREMENT_OP: /* Increment (Operand) */
618
619 /* 617 /*
620 * Create a new integer. Can't just get the base integer and 618 * Create a new integer. Can't just get the base integer and
621 * increment it because it may be an Arg or Field. 619 * increment it because it may be an Arg or Field.
@@ -682,7 +680,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
682 break; 680 break;
683 681
684 case AML_TYPE_OP: /* object_type (source_object) */ 682 case AML_TYPE_OP: /* object_type (source_object) */
685
686 /* 683 /*
687 * Note: The operand is not resolved at this point because we want to 684 * Note: The operand is not resolved at this point because we want to
688 * get the associated object, not its value. For example, we don't 685 * get the associated object, not its value. For example, we don't
@@ -709,7 +706,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
709 break; 706 break;
710 707
711 case AML_SIZE_OF_OP: /* size_of (source_object) */ 708 case AML_SIZE_OF_OP: /* size_of (source_object) */
712
713 /* 709 /*
714 * Note: The operand is not resolved at this point because we want to 710 * Note: The operand is not resolved at this point because we want to
715 * get the associated object, not its value. 711 * get the associated object, not its value.
@@ -735,10 +731,12 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
735 */ 731 */
736 switch (type) { 732 switch (type) {
737 case ACPI_TYPE_INTEGER: 733 case ACPI_TYPE_INTEGER:
734
738 value = acpi_gbl_integer_byte_width; 735 value = acpi_gbl_integer_byte_width;
739 break; 736 break;
740 737
741 case ACPI_TYPE_STRING: 738 case ACPI_TYPE_STRING:
739
742 value = temp_desc->string.length; 740 value = temp_desc->string.length;
743 break; 741 break;
744 742
@@ -759,6 +757,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
759 break; 757 break;
760 758
761 default: 759 default:
760
762 ACPI_ERROR((AE_INFO, 761 ACPI_ERROR((AE_INFO,
763 "Operand must be Buffer/Integer/String/Package - found type %s", 762 "Operand must be Buffer/Integer/String/Package - found type %s",
764 acpi_ut_get_type_name(type))); 763 acpi_ut_get_type_name(type)));
@@ -860,9 +859,11 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
860 break; 859 break;
861 860
862 case ACPI_TYPE_STRING: 861 case ACPI_TYPE_STRING:
862
863 break; 863 break;
864 864
865 default: 865 default:
866
866 status = AE_AML_OPERAND_TYPE; 867 status = AE_AML_OPERAND_TYPE;
867 goto cleanup; 868 goto cleanup;
868 } 869 }
@@ -923,7 +924,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
923 */ 924 */
924 switch (operand[0]->reference.class) { 925 switch (operand[0]->reference.class) {
925 case ACPI_REFCLASS_INDEX: 926 case ACPI_REFCLASS_INDEX:
926
927 /* 927 /*
928 * The target type for the Index operator must be 928 * The target type for the Index operator must be
929 * either a Buffer or a Package 929 * either a Buffer or a Package
@@ -956,7 +956,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
956 break; 956 break;
957 957
958 case ACPI_TYPE_PACKAGE: 958 case ACPI_TYPE_PACKAGE:
959
960 /* 959 /*
961 * Return the referenced element of the package. We must 960 * Return the referenced element of the package. We must
962 * add another reference to the referenced object, however. 961 * add another reference to the referenced object, however.
@@ -999,6 +998,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
999 break; 998 break;
1000 999
1001 default: 1000 default:
1001
1002 ACPI_ERROR((AE_INFO, 1002 ACPI_ERROR((AE_INFO,
1003 "Unknown class in reference(%p) - 0x%2.2X", 1003 "Unknown class in reference(%p) - 0x%2.2X",
1004 operand[0], 1004 operand[0],
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index b0838a4ea53e..d5088f7030c7 100644
--- a/drivers/acpi/acpica/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -304,7 +304,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
304 break; 304 break;
305 305
306 case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */ 306 case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
307
308 /* 307 /*
309 * Input object is guaranteed to be a buffer at this point (it may have 308 * Input object is guaranteed to be a buffer at this point (it may have
310 * been converted.) Copy the raw buffer data to a new object of 309 * been converted.) Copy the raw buffer data to a new object of
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 2d7491f3126e..37656f12f204 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -155,7 +155,6 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
155 155
156 switch (walk_state->opcode) { 156 switch (walk_state->opcode) {
157 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ 157 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
158
159 /* 158 /*
160 * Create the return object. The Source operand is guaranteed to be 159 * Create the return object. The Source operand is guaranteed to be
161 * either a String or a Buffer, so just use its type. 160 * either a String or a Buffer, so just use its type.
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index b76b97002dff..879b6cd8319c 100644
--- a/drivers/acpi/acpica/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -119,7 +119,6 @@ acpi_ex_do_match(u32 match_op,
119 break; 119 break;
120 120
121 case MATCH_MEQ: 121 case MATCH_MEQ:
122
123 /* 122 /*
124 * True if equal: (P[i] == M) 123 * True if equal: (P[i] == M)
125 * Change to: (M == P[i]) 124 * Change to: (M == P[i])
@@ -133,7 +132,6 @@ acpi_ex_do_match(u32 match_op,
133 break; 132 break;
134 133
135 case MATCH_MLE: 134 case MATCH_MLE:
136
137 /* 135 /*
138 * True if less than or equal: (P[i] <= M) (P[i] not_greater than M) 136 * True if less than or equal: (P[i] <= M) (P[i] not_greater than M)
139 * Change to: (M >= P[i]) (M not_less than P[i]) 137 * Change to: (M >= P[i]) (M not_less than P[i])
@@ -148,7 +146,6 @@ acpi_ex_do_match(u32 match_op,
148 break; 146 break;
149 147
150 case MATCH_MLT: 148 case MATCH_MLT:
151
152 /* 149 /*
153 * True if less than: (P[i] < M) 150 * True if less than: (P[i] < M)
154 * Change to: (M > P[i]) 151 * Change to: (M > P[i])
@@ -162,7 +159,6 @@ acpi_ex_do_match(u32 match_op,
162 break; 159 break;
163 160
164 case MATCH_MGE: 161 case MATCH_MGE:
165
166 /* 162 /*
167 * True if greater than or equal: (P[i] >= M) (P[i] not_less than M) 163 * True if greater than or equal: (P[i] >= M) (P[i] not_less than M)
168 * Change to: (M <= P[i]) (M not_greater than P[i]) 164 * Change to: (M <= P[i]) (M not_greater than P[i])
@@ -177,7 +173,6 @@ acpi_ex_do_match(u32 match_op,
177 break; 173 break;
178 174
179 case MATCH_MGT: 175 case MATCH_MGT:
180
181 /* 176 /*
182 * True if greater than: (P[i] > M) 177 * True if greater than: (P[i] > M)
183 * Change to: (M < P[i]) 178 * Change to: (M < P[i])
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index 6b728aef2dca..5a588611ab48 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -253,26 +253,31 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
253 253
254 case AML_FIELD_ACCESS_BYTE: 254 case AML_FIELD_ACCESS_BYTE:
255 case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ 255 case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */
256
256 byte_alignment = 1; 257 byte_alignment = 1;
257 bit_length = 8; 258 bit_length = 8;
258 break; 259 break;
259 260
260 case AML_FIELD_ACCESS_WORD: 261 case AML_FIELD_ACCESS_WORD:
262
261 byte_alignment = 2; 263 byte_alignment = 2;
262 bit_length = 16; 264 bit_length = 16;
263 break; 265 break;
264 266
265 case AML_FIELD_ACCESS_DWORD: 267 case AML_FIELD_ACCESS_DWORD:
268
266 byte_alignment = 4; 269 byte_alignment = 4;
267 bit_length = 32; 270 bit_length = 32;
268 break; 271 break;
269 272
270 case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ 273 case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
274
271 byte_alignment = 8; 275 byte_alignment = 8;
272 bit_length = 64; 276 bit_length = 64;
273 break; 277 break;
274 278
275 default: 279 default:
280
276 /* Invalid field access type */ 281 /* Invalid field access type */
277 282
278 ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access)); 283 ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access));
@@ -598,7 +603,9 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
598 break; 603 break;
599 604
600 default: 605 default:
606
601 /* No other types should get here */ 607 /* No other types should get here */
608
602 break; 609 break;
603 } 610 }
604 611
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 182abaf045e1..303429bb4d5d 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -88,22 +88,27 @@ acpi_ex_system_memory_space_handler(u32 function,
88 88
89 switch (bit_width) { 89 switch (bit_width) {
90 case 8: 90 case 8:
91
91 length = 1; 92 length = 1;
92 break; 93 break;
93 94
94 case 16: 95 case 16:
96
95 length = 2; 97 length = 2;
96 break; 98 break;
97 99
98 case 32: 100 case 32:
101
99 length = 4; 102 length = 4;
100 break; 103 break;
101 104
102 case 64: 105 case 64:
106
103 length = 8; 107 length = 8;
104 break; 108 break;
105 109
106 default: 110 default:
111
107 ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u", 112 ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u",
108 bit_width)); 113 bit_width));
109 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 114 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
@@ -214,23 +219,29 @@ acpi_ex_system_memory_space_handler(u32 function,
214 *value = 0; 219 *value = 0;
215 switch (bit_width) { 220 switch (bit_width) {
216 case 8: 221 case 8:
217 *value = (u64) ACPI_GET8(logical_addr_ptr); 222
223 *value = (u64)ACPI_GET8(logical_addr_ptr);
218 break; 224 break;
219 225
220 case 16: 226 case 16:
221 *value = (u64) ACPI_GET16(logical_addr_ptr); 227
228 *value = (u64)ACPI_GET16(logical_addr_ptr);
222 break; 229 break;
223 230
224 case 32: 231 case 32:
225 *value = (u64) ACPI_GET32(logical_addr_ptr); 232
233 *value = (u64)ACPI_GET32(logical_addr_ptr);
226 break; 234 break;
227 235
228 case 64: 236 case 64:
229 *value = (u64) ACPI_GET64(logical_addr_ptr); 237
238 *value = (u64)ACPI_GET64(logical_addr_ptr);
230 break; 239 break;
231 240
232 default: 241 default:
242
233 /* bit_width was already validated */ 243 /* bit_width was already validated */
244
234 break; 245 break;
235 } 246 }
236 break; 247 break;
@@ -239,28 +250,35 @@ acpi_ex_system_memory_space_handler(u32 function,
239 250
240 switch (bit_width) { 251 switch (bit_width) {
241 case 8: 252 case 8:
253
242 ACPI_SET8(logical_addr_ptr, *value); 254 ACPI_SET8(logical_addr_ptr, *value);
243 break; 255 break;
244 256
245 case 16: 257 case 16:
258
246 ACPI_SET16(logical_addr_ptr, *value); 259 ACPI_SET16(logical_addr_ptr, *value);
247 break; 260 break;
248 261
249 case 32: 262 case 32:
263
250 ACPI_SET32(logical_addr_ptr, *value); 264 ACPI_SET32(logical_addr_ptr, *value);
251 break; 265 break;
252 266
253 case 64: 267 case 64:
268
254 ACPI_SET64(logical_addr_ptr, *value); 269 ACPI_SET64(logical_addr_ptr, *value);
255 break; 270 break;
256 271
257 default: 272 default:
273
258 /* bit_width was already validated */ 274 /* bit_width was already validated */
275
259 break; 276 break;
260 } 277 }
261 break; 278 break;
262 279
263 default: 280 default:
281
264 status = AE_BAD_PARAMETER; 282 status = AE_BAD_PARAMETER;
265 break; 283 break;
266 } 284 }
@@ -320,6 +338,7 @@ acpi_ex_system_io_space_handler(u32 function,
320 break; 338 break;
321 339
322 default: 340 default:
341
323 status = AE_BAD_PARAMETER; 342 status = AE_BAD_PARAMETER;
324 break; 343 break;
325 } 344 }
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 8565b6bd12bb..acd34f599313 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -248,6 +248,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
248 break; 248 break;
249 249
250 default: 250 default:
251
251 /* No named references are allowed here */ 252 /* No named references are allowed here */
252 253
253 ACPI_ERROR((AE_INFO, 254 ACPI_ERROR((AE_INFO,
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index e4f9dfbb2a13..ac04278ad28f 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -156,7 +156,6 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
156 switch (ref_type) { 156 switch (ref_type) {
157 case ACPI_REFCLASS_LOCAL: 157 case ACPI_REFCLASS_LOCAL:
158 case ACPI_REFCLASS_ARG: 158 case ACPI_REFCLASS_ARG:
159
160 /* 159 /*
161 * Get the local from the method's state info 160 * Get the local from the method's state info
162 * Note: this increments the local's object reference count 161 * Note: this increments the local's object reference count
@@ -309,6 +308,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
309 break; 308 break;
310 309
311 default: 310 default:
311
312 break; 312 break;
313 } 313 }
314 314
@@ -348,10 +348,12 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
348 348
349 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { 349 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
350 case ACPI_DESC_TYPE_OPERAND: 350 case ACPI_DESC_TYPE_OPERAND:
351
351 type = obj_desc->common.type; 352 type = obj_desc->common.type;
352 break; 353 break;
353 354
354 case ACPI_DESC_TYPE_NAMED: 355 case ACPI_DESC_TYPE_NAMED:
356
355 type = ((struct acpi_namespace_node *)obj_desc)->type; 357 type = ((struct acpi_namespace_node *)obj_desc)->type;
356 obj_desc = 358 obj_desc =
357 acpi_ns_get_attached_object((struct acpi_namespace_node *) 359 acpi_ns_get_attached_object((struct acpi_namespace_node *)
@@ -538,7 +540,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
538 break; 540 break;
539 541
540 default: 542 default:
543
541 /* No change to Type required */ 544 /* No change to Type required */
545
542 break; 546 break;
543 } 547 }
544 548
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index 9fb9f5e9a4da..00e5af7129c1 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -307,7 +307,6 @@ acpi_ex_resolve_operands(u16 opcode,
307 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ 307 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
308 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ 308 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
309 case ARGI_SIMPLE_TARGET: /* Name, Local, or arg - no implicit conversion */ 309 case ARGI_SIMPLE_TARGET: /* Name, Local, or arg - no implicit conversion */
310
311 /* 310 /*
312 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE 311 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
313 * A Namespace Node is OK as-is 312 * A Namespace Node is OK as-is
@@ -326,7 +325,6 @@ acpi_ex_resolve_operands(u16 opcode,
326 goto next_operand; 325 goto next_operand;
327 326
328 case ARGI_DATAREFOBJ: /* Store operator only */ 327 case ARGI_DATAREFOBJ: /* Store operator only */
329
330 /* 328 /*
331 * We don't want to resolve index_op reference objects during 329 * We don't want to resolve index_op reference objects during
332 * a store because this would be an implicit de_ref_of operation. 330 * a store because this would be an implicit de_ref_of operation.
@@ -343,7 +341,9 @@ acpi_ex_resolve_operands(u16 opcode,
343 break; 341 break;
344 342
345 default: 343 default:
344
346 /* All cases covered above */ 345 /* All cases covered above */
346
347 break; 347 break;
348 } 348 }
349 349
@@ -433,7 +433,6 @@ acpi_ex_resolve_operands(u16 opcode,
433 goto next_operand; 433 goto next_operand;
434 434
435 case ARGI_BUFFER: 435 case ARGI_BUFFER:
436
437 /* 436 /*
438 * Need an operand of type ACPI_TYPE_BUFFER, 437 * Need an operand of type ACPI_TYPE_BUFFER,
439 * But we can implicitly convert from a STRING or INTEGER 438 * But we can implicitly convert from a STRING or INTEGER
@@ -459,7 +458,6 @@ acpi_ex_resolve_operands(u16 opcode,
459 goto next_operand; 458 goto next_operand;
460 459
461 case ARGI_STRING: 460 case ARGI_STRING:
462
463 /* 461 /*
464 * Need an operand of type ACPI_TYPE_STRING, 462 * Need an operand of type ACPI_TYPE_STRING,
465 * But we can implicitly convert from a BUFFER or INTEGER 463 * But we can implicitly convert from a BUFFER or INTEGER
@@ -562,6 +560,7 @@ acpi_ex_resolve_operands(u16 opcode,
562 break; 560 break;
563 561
564 default: 562 default:
563
565 ACPI_ERROR((AE_INFO, 564 ACPI_ERROR((AE_INFO,
566 "Needed [Buffer/String/Package/Reference], found [%s] %p", 565 "Needed [Buffer/String/Package/Reference], found [%s] %p",
567 acpi_ut_get_object_type_name 566 acpi_ut_get_object_type_name
@@ -584,6 +583,7 @@ acpi_ex_resolve_operands(u16 opcode,
584 break; 583 break;
585 584
586 default: 585 default:
586
587 ACPI_ERROR((AE_INFO, 587 ACPI_ERROR((AE_INFO,
588 "Needed [Buffer/String/Package], found [%s] %p", 588 "Needed [Buffer/String/Package], found [%s] %p",
589 acpi_ut_get_object_type_name 589 acpi_ut_get_object_type_name
@@ -605,6 +605,7 @@ acpi_ex_resolve_operands(u16 opcode,
605 break; 605 break;
606 606
607 default: 607 default:
608
608 ACPI_ERROR((AE_INFO, 609 ACPI_ERROR((AE_INFO,
609 "Needed [Region/Buffer], found [%s] %p", 610 "Needed [Region/Buffer], found [%s] %p",
610 acpi_ut_get_object_type_name 611 acpi_ut_get_object_type_name
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 93c6049c2d75..2bdba6f7d762 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -114,6 +114,7 @@ acpi_ex_store(union acpi_operand_object *source_desc,
114 114
115 switch (dest_desc->common.type) { 115 switch (dest_desc->common.type) {
116 case ACPI_TYPE_LOCAL_REFERENCE: 116 case ACPI_TYPE_LOCAL_REFERENCE:
117
117 break; 118 break;
118 119
119 case ACPI_TYPE_INTEGER: 120 case ACPI_TYPE_INTEGER:
@@ -178,7 +179,6 @@ acpi_ex_store(union acpi_operand_object *source_desc,
178 break; 179 break;
179 180
180 case ACPI_REFCLASS_DEBUG: 181 case ACPI_REFCLASS_DEBUG:
181
182 /* 182 /*
183 * Storing to the Debug object causes the value stored to be 183 * Storing to the Debug object causes the value stored to be
184 * displayed and otherwise has no effect -- see ACPI Specification 184 * displayed and otherwise has no effect -- see ACPI Specification
@@ -291,7 +291,6 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
291 break; 291 break;
292 292
293 case ACPI_TYPE_BUFFER_FIELD: 293 case ACPI_TYPE_BUFFER_FIELD:
294
295 /* 294 /*
296 * Store into a Buffer or String (not actually a real buffer_field) 295 * Store into a Buffer or String (not actually a real buffer_field)
297 * at a location defined by an Index. 296 * at a location defined by an Index.
@@ -447,7 +446,6 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
447 case ACPI_TYPE_INTEGER: 446 case ACPI_TYPE_INTEGER:
448 case ACPI_TYPE_STRING: 447 case ACPI_TYPE_STRING:
449 case ACPI_TYPE_BUFFER: 448 case ACPI_TYPE_BUFFER:
450
451 /* 449 /*
452 * These target types are all of type Integer/String/Buffer, and 450 * These target types are all of type Integer/String/Buffer, and
453 * therefore support implicit conversion before the store. 451 * therefore support implicit conversion before the store.
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index 1cefe777068e..20d809d90c5b 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -85,11 +85,9 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
85 * These cases all require only Integers or values that 85 * These cases all require only Integers or values that
86 * can be converted to Integers (Strings or Buffers) 86 * can be converted to Integers (Strings or Buffers)
87 */ 87 */
88
89 case ACPI_TYPE_INTEGER: 88 case ACPI_TYPE_INTEGER:
90 case ACPI_TYPE_STRING: 89 case ACPI_TYPE_STRING:
91 case ACPI_TYPE_BUFFER: 90 case ACPI_TYPE_BUFFER:
92
93 /* 91 /*
94 * Stores into a Field/Region or into a Integer/Buffer/String 92 * Stores into a Field/Region or into a Integer/Buffer/String
95 * are all essentially the same. This case handles the 93 * are all essentially the same. This case handles the
@@ -133,7 +131,6 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
133 131
134 case ACPI_TYPE_LOCAL_ALIAS: 132 case ACPI_TYPE_LOCAL_ALIAS:
135 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 133 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
136
137 /* 134 /*
138 * All aliases should have been resolved earlier, during the 135 * All aliases should have been resolved earlier, during the
139 * operand resolution phase. 136 * operand resolution phase.
@@ -144,7 +141,6 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
144 141
145 case ACPI_TYPE_PACKAGE: 142 case ACPI_TYPE_PACKAGE:
146 default: 143 default:
147
148 /* 144 /*
149 * All other types than Alias and the various Fields come here, 145 * All other types than Alias and the various Fields come here,
150 * including the untyped case - ACPI_TYPE_ANY. 146 * including the untyped case - ACPI_TYPE_ANY.
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 579c3a53ac87..3d36df828f52 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -108,7 +108,6 @@ acpi_status acpi_hw_set_mode(u32 mode)
108 break; 108 break;
109 109
110 case ACPI_SYS_MODE_LEGACY: 110 case ACPI_SYS_MODE_LEGACY:
111
112 /* 111 /*
113 * BIOS should clear all fixed status bits and restore fixed event 112 * BIOS should clear all fixed status bits and restore fixed event
114 * enable bits to default 113 * enable bits to default
@@ -120,6 +119,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
120 break; 119 break;
121 120
122 default: 121 default:
122
123 return_ACPI_STATUS(AE_BAD_PARAMETER); 123 return_ACPI_STATUS(AE_BAD_PARAMETER);
124 } 124 }
125 125
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 20d02e93c990..96540506058f 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -127,14 +127,17 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
127 /*lint -fallthrough */ 127 /*lint -fallthrough */
128 128
129 case ACPI_GPE_ENABLE: 129 case ACPI_GPE_ENABLE:
130
130 ACPI_SET_BIT(enable_mask, register_bit); 131 ACPI_SET_BIT(enable_mask, register_bit);
131 break; 132 break;
132 133
133 case ACPI_GPE_DISABLE: 134 case ACPI_GPE_DISABLE:
135
134 ACPI_CLEAR_BIT(enable_mask, register_bit); 136 ACPI_CLEAR_BIT(enable_mask, register_bit);
135 break; 137 break;
136 138
137 default: 139 default:
140
138 ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u", action)); 141 ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u", action));
139 return (AE_BAD_PARAMETER); 142 return (AE_BAD_PARAMETER);
140 } 143 }
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 083d6551f0e2..8d2e866be15f 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -419,6 +419,7 @@ acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value)
419 break; 419 break;
420 420
421 default: 421 default:
422
422 ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id)); 423 ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id));
423 status = AE_BAD_PARAMETER; 424 status = AE_BAD_PARAMETER;
424 break; 425 break;
@@ -491,7 +492,6 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
491 break; 492 break;
492 493
493 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ 494 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
494
495 /* 495 /*
496 * Perform a read first to preserve certain bits (per ACPI spec) 496 * Perform a read first to preserve certain bits (per ACPI spec)
497 * Note: This includes SCI_EN, we never want to change this bit 497 * Note: This includes SCI_EN, we never want to change this bit
@@ -520,7 +520,6 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
520 break; 520 break;
521 521
522 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 522 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
523
524 /* 523 /*
525 * For control registers, all reserved bits must be preserved, 524 * For control registers, all reserved bits must be preserved,
526 * as per the ACPI spec. 525 * as per the ACPI spec.
@@ -555,6 +554,7 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
555 break; 554 break;
556 555
557 default: 556 default:
557
558 ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id)); 558 ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id));
559 status = AE_BAD_PARAMETER; 559 status = AE_BAD_PARAMETER;
560 break; 560 break;
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 04c2e16f2c0a..5ee7a814cd92 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -495,7 +495,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
495 * Evaluate the \_Sx namespace object containing the register values 495 * Evaluate the \_Sx namespace object containing the register values
496 * for this state 496 * for this state
497 */ 497 */
498 info->pathname = 498 info->relative_pathname =
499 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); 499 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
500 status = acpi_ns_evaluate(info); 500 status = acpi_ns_evaluate(info);
501 if (ACPI_FAILURE(status)) { 501 if (ACPI_FAILURE(status)) {
@@ -506,7 +506,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
506 506
507 if (!info->return_object) { 507 if (!info->return_object) {
508 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", 508 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]",
509 info->pathname)); 509 info->relative_pathname));
510 status = AE_AML_NO_RETURN_VALUE; 510 status = AE_AML_NO_RETURN_VALUE;
511 goto cleanup; 511 goto cleanup;
512 } 512 }
@@ -528,10 +528,12 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
528 elements = info->return_object->package.elements; 528 elements = info->return_object->package.elements;
529 switch (info->return_object->package.count) { 529 switch (info->return_object->package.count) {
530 case 0: 530 case 0:
531
531 status = AE_AML_PACKAGE_LIMIT; 532 status = AE_AML_PACKAGE_LIMIT;
532 break; 533 break;
533 534
534 case 1: 535 case 1:
536
535 if (elements[0]->common.type != ACPI_TYPE_INTEGER) { 537 if (elements[0]->common.type != ACPI_TYPE_INTEGER) {
536 status = AE_AML_OPERAND_TYPE; 538 status = AE_AML_OPERAND_TYPE;
537 break; 539 break;
@@ -545,6 +547,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
545 547
546 case 2: 548 case 2:
547 default: 549 default:
550
548 if ((elements[0]->common.type != ACPI_TYPE_INTEGER) || 551 if ((elements[0]->common.type != ACPI_TYPE_INTEGER) ||
549 (elements[1]->common.type != ACPI_TYPE_INTEGER)) { 552 (elements[1]->common.type != ACPI_TYPE_INTEGER)) {
550 status = AE_AML_OPERAND_TYPE; 553 status = AE_AML_OPERAND_TYPE;
@@ -565,7 +568,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
565 if (ACPI_FAILURE(status)) { 568 if (ACPI_FAILURE(status)) {
566 ACPI_EXCEPTION((AE_INFO, status, 569 ACPI_EXCEPTION((AE_INFO, status,
567 "While evaluating Sleep State [%s]", 570 "While evaluating Sleep State [%s]",
568 info->pathname)); 571 info->relative_pathname));
569 } 572 }
570 573
571 ACPI_FREE(info); 574 ACPI_FREE(info);
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
index 35eebdac0f9d..f2e669db8b65 100644
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -240,12 +240,14 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id)
240 &acpi_sleep_dispatch[function_id]; 240 &acpi_sleep_dispatch[function_id];
241 241
242#if (!ACPI_REDUCED_HARDWARE) 242#if (!ACPI_REDUCED_HARDWARE)
243
244 /* 243 /*
245 * If the Hardware Reduced flag is set (from the FADT), we must 244 * If the Hardware Reduced flag is set (from the FADT), we must
246 * use the extended sleep registers 245 * use the extended sleep registers (FADT). Note: As per the ACPI
246 * specification, these extended registers are to be used for HW-reduced
247 * platforms only. They are not general-purpose replacements for the
248 * legacy PM register sleep support.
247 */ 249 */
248 if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) { 250 if (acpi_gbl_reduced_hardware) {
249 status = sleep_functions->extended_function(sleep_state); 251 status = sleep_functions->extended_function(sleep_state);
250 } else { 252 } else {
251 /* Legacy sleep */ 253 /* Legacy sleep */
@@ -314,20 +316,24 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
314 316
315 switch (sleep_state) { 317 switch (sleep_state) {
316 case ACPI_STATE_S0: 318 case ACPI_STATE_S0:
319
317 sst_value = ACPI_SST_WORKING; 320 sst_value = ACPI_SST_WORKING;
318 break; 321 break;
319 322
320 case ACPI_STATE_S1: 323 case ACPI_STATE_S1:
321 case ACPI_STATE_S2: 324 case ACPI_STATE_S2:
322 case ACPI_STATE_S3: 325 case ACPI_STATE_S3:
326
323 sst_value = ACPI_SST_SLEEPING; 327 sst_value = ACPI_SST_SLEEPING;
324 break; 328 break;
325 329
326 case ACPI_STATE_S4: 330 case ACPI_STATE_S4:
331
327 sst_value = ACPI_SST_SLEEP_CONTEXT; 332 sst_value = ACPI_SST_SLEEP_CONTEXT;
328 break; 333 break;
329 334
330 default: 335 default:
336
331 sst_value = ACPI_SST_INDICATOR_OFF; /* Default is off */ 337 sst_value = ACPI_SST_INDICATOR_OFF; /* Default is off */
332 break; 338 break;
333 } 339 }
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index 8769cf83b044..c5316e5bd4ab 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -151,6 +151,7 @@ acpi_status acpi_ns_root_initialize(void)
151 */ 151 */
152 switch (init_val->type) { 152 switch (init_val->type) {
153 case ACPI_TYPE_METHOD: 153 case ACPI_TYPE_METHOD:
154
154 obj_desc->method.param_count = 155 obj_desc->method.param_count =
155 (u8) ACPI_TO_INTEGER(val); 156 (u8) ACPI_TO_INTEGER(val);
156 obj_desc->common.flags |= AOPOBJ_DATA_VALID; 157 obj_desc->common.flags |= AOPOBJ_DATA_VALID;
diff --git a/drivers/acpi/acpica/nsarguments.c b/drivers/acpi/acpica/nsarguments.c
new file mode 100644
index 000000000000..74b24c82707e
--- /dev/null
+++ b/drivers/acpi/acpica/nsarguments.c
@@ -0,0 +1,294 @@
1/******************************************************************************
2 *
3 * Module Name: nsarguments - Validation of args for ACPI predefined methods
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acnamesp.h"
47#include "acpredef.h"
48
49#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsarguments")
51
52/*******************************************************************************
53 *
54 * FUNCTION: acpi_ns_check_argument_types
55 *
56 * PARAMETERS: info - Method execution information block
57 *
58 * RETURN: None
59 *
60 * DESCRIPTION: Check the incoming argument count and all argument types
61 * against the argument type list for a predefined name.
62 *
63 ******************************************************************************/
64void acpi_ns_check_argument_types(struct acpi_evaluate_info *info)
65{
66 u16 arg_type_list;
67 u8 arg_count;
68 u8 arg_type;
69 u8 user_arg_type;
70 u32 i;
71
72 /* If not a predefined name, cannot typecheck args */
73
74 if (!info->predefined) {
75 return;
76 }
77
78 arg_type_list = info->predefined->info.argument_list;
79 arg_count = METHOD_GET_ARG_COUNT(arg_type_list);
80
81 /* Typecheck all arguments */
82
83 for (i = 0; ((i < arg_count) && (i < info->param_count)); i++) {
84 arg_type = METHOD_GET_NEXT_TYPE(arg_type_list);
85 user_arg_type = info->parameters[i]->common.type;
86
87 if (user_arg_type != arg_type) {
88 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
89 ACPI_WARN_ALWAYS,
90 "Argument #%u type mismatch - "
91 "Found [%s], ACPI requires [%s]",
92 (i + 1),
93 acpi_ut_get_type_name
94 (user_arg_type),
95 acpi_ut_get_type_name(arg_type)));
96 }
97 }
98}
99
100/*******************************************************************************
101 *
102 * FUNCTION: acpi_ns_check_acpi_compliance
103 *
104 * PARAMETERS: pathname - Full pathname to the node (for error msgs)
105 * node - Namespace node for the method/object
106 * predefined - Pointer to entry in predefined name table
107 *
108 * RETURN: None
109 *
110 * DESCRIPTION: Check that the declared parameter count (in ASL/AML) for a
111 * predefined name is what is expected (matches what is defined in
112 * the ACPI specification for this predefined name.)
113 *
114 ******************************************************************************/
115
116void
117acpi_ns_check_acpi_compliance(char *pathname,
118 struct acpi_namespace_node *node,
119 const union acpi_predefined_info *predefined)
120{
121 u32 aml_param_count;
122 u32 required_param_count;
123
124 if (!predefined) {
125 return;
126 }
127
128 /* Get the ACPI-required arg count from the predefined info table */
129
130 required_param_count =
131 METHOD_GET_ARG_COUNT(predefined->info.argument_list);
132
133 /*
134 * If this object is not a control method, we can check if the ACPI
135 * spec requires that it be a method.
136 */
137 if (node->type != ACPI_TYPE_METHOD) {
138 if (required_param_count > 0) {
139
140 /* Object requires args, must be implemented as a method */
141
142 ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname,
143 ACPI_WARN_ALWAYS,
144 "Object (%s) must be a control method with %u arguments",
145 acpi_ut_get_type_name(node->
146 type),
147 required_param_count));
148 } else if (!required_param_count
149 && !predefined->info.expected_btypes) {
150
151 /* Object requires no args and no return value, must be a method */
152
153 ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname,
154 ACPI_WARN_ALWAYS,
155 "Object (%s) must be a control method "
156 "with no arguments and no return value",
157 acpi_ut_get_type_name(node->
158 type)));
159 }
160
161 return;
162 }
163
164 /*
165 * This is a control method.
166 * Check that the ASL/AML-defined parameter count for this method
167 * matches the ACPI-required parameter count
168 *
169 * Some methods are allowed to have a "minimum" number of args (_SCP)
170 * because their definition in ACPI has changed over time.
171 *
172 * Note: These are BIOS errors in the declaration of the object
173 */
174 aml_param_count = node->object->method.param_count;
175
176 if (aml_param_count < required_param_count) {
177 ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS,
178 "Insufficient arguments - "
179 "ASL declared %u, ACPI requires %u",
180 aml_param_count,
181 required_param_count));
182 } else if ((aml_param_count > required_param_count)
183 && !(predefined->info.
184 argument_list & ARG_COUNT_IS_MINIMUM)) {
185 ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS,
186 "Excess arguments - "
187 "ASL declared %u, ACPI requires %u",
188 aml_param_count,
189 required_param_count));
190 }
191}
192
193/*******************************************************************************
194 *
195 * FUNCTION: acpi_ns_check_argument_count
196 *
197 * PARAMETERS: pathname - Full pathname to the node (for error msgs)
198 * node - Namespace node for the method/object
199 * user_param_count - Number of args passed in by the caller
200 * predefined - Pointer to entry in predefined name table
201 *
202 * RETURN: None
203 *
204 * DESCRIPTION: Check that incoming argument count matches the declared
205 * parameter count (in the ASL/AML) for an object.
206 *
207 ******************************************************************************/
208
209void
210acpi_ns_check_argument_count(char *pathname,
211 struct acpi_namespace_node *node,
212 u32 user_param_count,
213 const union acpi_predefined_info *predefined)
214{
215 u32 aml_param_count;
216 u32 required_param_count;
217
218 if (!predefined) {
219 /*
220 * Not a predefined name. Check the incoming user argument count
221 * against the count that is specified in the method/object.
222 */
223 if (node->type != ACPI_TYPE_METHOD) {
224 if (user_param_count) {
225 ACPI_INFO_PREDEFINED((AE_INFO, pathname,
226 ACPI_WARN_ALWAYS,
227 "%u arguments were passed to a non-method ACPI object (%s)",
228 user_param_count,
229 acpi_ut_get_type_name
230 (node->type)));
231 }
232
233 return;
234 }
235
236 /*
237 * This is a control method. Check the parameter count.
238 * We can only check the incoming argument count against the
239 * argument count declared for the method in the ASL/AML.
240 *
241 * Emit a message if too few or too many arguments have been passed
242 * by the caller.
243 *
244 * Note: Too many arguments will not cause the method to
245 * fail. However, the method will fail if there are too few
246 * arguments and the method attempts to use one of the missing ones.
247 */
248 aml_param_count = node->object->method.param_count;
249
250 if (user_param_count < aml_param_count) {
251 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
252 ACPI_WARN_ALWAYS,
253 "Insufficient arguments - "
254 "Caller passed %u, method requires %u",
255 user_param_count,
256 aml_param_count));
257 } else if (user_param_count > aml_param_count) {
258 ACPI_INFO_PREDEFINED((AE_INFO, pathname,
259 ACPI_WARN_ALWAYS,
260 "Excess arguments - "
261 "Caller passed %u, method requires %u",
262 user_param_count,
263 aml_param_count));
264 }
265
266 return;
267 }
268
269 /*
270 * This is a predefined name. Validate the user-supplied parameter
271 * count against the ACPI specification. We don't validate against
272 * the method itself because what is important here is that the
273 * caller is in conformance with the spec. (The arg count for the
274 * method was checked against the ACPI spec earlier.)
275 *
276 * Some methods are allowed to have a "minimum" number of args (_SCP)
277 * because their definition in ACPI has changed over time.
278 */
279 required_param_count =
280 METHOD_GET_ARG_COUNT(predefined->info.argument_list);
281
282 if (user_param_count < required_param_count) {
283 ACPI_WARN_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS,
284 "Insufficient arguments - "
285 "Caller passed %u, ACPI requires %u",
286 user_param_count, required_param_count));
287 } else if ((user_param_count > required_param_count) &&
288 !(predefined->info.argument_list & ARG_COUNT_IS_MINIMUM)) {
289 ACPI_INFO_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS,
290 "Excess arguments - "
291 "Caller passed %u, ACPI requires %u",
292 user_param_count, required_param_count));
293 }
294}
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c
index 8f79a9d2d50e..acd2964c2690 100644
--- a/drivers/acpi/acpica/nsconvert.c
+++ b/drivers/acpi/acpica/nsconvert.c
@@ -103,6 +103,7 @@ acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
103 break; 103 break;
104 104
105 default: 105 default:
106
106 return (AE_AML_OPERAND_TYPE); 107 return (AE_AML_OPERAND_TYPE);
107 } 108 }
108 109
@@ -191,6 +192,7 @@ acpi_ns_convert_to_string(union acpi_operand_object *original_object,
191 break; 192 break;
192 193
193 default: 194 default:
195
194 return (AE_AML_OPERAND_TYPE); 196 return (AE_AML_OPERAND_TYPE);
195 } 197 }
196 198
@@ -294,6 +296,7 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
294 break; 296 break;
295 297
296 default: 298 default:
299
297 return (AE_AML_OPERAND_TYPE); 300 return (AE_AML_OPERAND_TYPE);
298 } 301 }
299 302
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index ce6e97326205..7418c77fde8c 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -244,10 +244,12 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
244 case ACPI_TYPE_BUFFER: 244 case ACPI_TYPE_BUFFER:
245 case ACPI_TYPE_STRING: 245 case ACPI_TYPE_STRING:
246 case ACPI_TYPE_METHOD: 246 case ACPI_TYPE_METHOD:
247
247 acpi_os_printf("<No attached object>"); 248 acpi_os_printf("<No attached object>");
248 break; 249 break;
249 250
250 default: 251 default:
252
251 break; 253 break;
252 } 254 }
253 255
@@ -433,6 +435,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
433 break; 435 break;
434 436
435 default: 437 default:
438
436 break; 439 break;
437 } 440 }
438 break; 441 break;
@@ -567,32 +570,39 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
567 goto cleanup; 570 goto cleanup;
568 571
569 case ACPI_TYPE_BUFFER_FIELD: 572 case ACPI_TYPE_BUFFER_FIELD:
573
570 obj_desc = 574 obj_desc =
571 (union acpi_operand_object *)obj_desc->buffer_field. 575 (union acpi_operand_object *)obj_desc->buffer_field.
572 buffer_obj; 576 buffer_obj;
573 break; 577 break;
574 578
575 case ACPI_TYPE_PACKAGE: 579 case ACPI_TYPE_PACKAGE:
580
576 obj_desc = (void *)obj_desc->package.elements; 581 obj_desc = (void *)obj_desc->package.elements;
577 break; 582 break;
578 583
579 case ACPI_TYPE_METHOD: 584 case ACPI_TYPE_METHOD:
585
580 obj_desc = (void *)obj_desc->method.aml_start; 586 obj_desc = (void *)obj_desc->method.aml_start;
581 break; 587 break;
582 588
583 case ACPI_TYPE_LOCAL_REGION_FIELD: 589 case ACPI_TYPE_LOCAL_REGION_FIELD:
590
584 obj_desc = (void *)obj_desc->field.region_obj; 591 obj_desc = (void *)obj_desc->field.region_obj;
585 break; 592 break;
586 593
587 case ACPI_TYPE_LOCAL_BANK_FIELD: 594 case ACPI_TYPE_LOCAL_BANK_FIELD:
595
588 obj_desc = (void *)obj_desc->bank_field.region_obj; 596 obj_desc = (void *)obj_desc->bank_field.region_obj;
589 break; 597 break;
590 598
591 case ACPI_TYPE_LOCAL_INDEX_FIELD: 599 case ACPI_TYPE_LOCAL_INDEX_FIELD:
600
592 obj_desc = (void *)obj_desc->index_field.index_obj; 601 obj_desc = (void *)obj_desc->index_field.index_obj;
593 break; 602 break;
594 603
595 default: 604 default:
605
596 goto cleanup; 606 goto cleanup;
597 } 607 }
598 608
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index b61db69d5675..18108bc2e51c 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -61,7 +61,7 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
61 * 61 *
62 * PARAMETERS: info - Evaluation info block, contains: 62 * PARAMETERS: info - Evaluation info block, contains:
63 * prefix_node - Prefix or Method/Object Node to execute 63 * prefix_node - Prefix or Method/Object Node to execute
64 * pathname - Name of method to execute, If NULL, the 64 * relative_path - Name of method to execute, If NULL, the
65 * Node is the object to execute 65 * Node is the object to execute
66 * parameters - List of parameters to pass to the method, 66 * parameters - List of parameters to pass to the method,
67 * terminated by NULL. Params itself may be 67 * terminated by NULL. Params itself may be
@@ -82,10 +82,9 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
82 * 82 *
83 ******************************************************************************/ 83 ******************************************************************************/
84 84
85acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) 85acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info)
86{ 86{
87 acpi_status status; 87 acpi_status status;
88 struct acpi_namespace_node *node;
89 88
90 ACPI_FUNCTION_TRACE(ns_evaluate); 89 ACPI_FUNCTION_TRACE(ns_evaluate);
91 90
@@ -93,83 +92,138 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
93 return_ACPI_STATUS(AE_BAD_PARAMETER); 92 return_ACPI_STATUS(AE_BAD_PARAMETER);
94 } 93 }
95 94
96 /* Initialize the return value to an invalid object */ 95 if (!info->node) {
97
98 info->return_object = NULL;
99 info->param_count = 0;
100
101 if (!info->resolved_node) {
102 /* 96 /*
103 * Get the actual namespace node for the target object if we need to. 97 * Get the actual namespace node for the target object if we
104 * Handles these cases: 98 * need to. Handles these cases:
105 * 99 *
106 * 1) Null node, Pathname (absolute path) 100 * 1) Null node, valid pathname from root (absolute path)
107 * 2) Node, Pathname (path relative to Node) 101 * 2) Node and valid pathname (path relative to Node)
108 * 3) Node, Null Pathname 102 * 3) Node, Null pathname
109 */ 103 */
110 status = acpi_ns_get_node(info->prefix_node, info->pathname, 104 status =
111 ACPI_NS_NO_UPSEARCH, 105 acpi_ns_get_node(info->prefix_node, info->relative_pathname,
112 &info->resolved_node); 106 ACPI_NS_NO_UPSEARCH, &info->node);
113 if (ACPI_FAILURE(status)) { 107 if (ACPI_FAILURE(status)) {
114 return_ACPI_STATUS(status); 108 return_ACPI_STATUS(status);
115 } 109 }
116 } 110 }
117 111
118 /* 112 /*
119 * For a method alias, we must grab the actual method node so that proper 113 * For a method alias, we must grab the actual method node so that
120 * scoping context will be established before execution. 114 * proper scoping context will be established before execution.
121 */ 115 */
122 if (acpi_ns_get_type(info->resolved_node) == 116 if (acpi_ns_get_type(info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) {
123 ACPI_TYPE_LOCAL_METHOD_ALIAS) { 117 info->node =
124 info->resolved_node =
125 ACPI_CAST_PTR(struct acpi_namespace_node, 118 ACPI_CAST_PTR(struct acpi_namespace_node,
126 info->resolved_node->object); 119 info->node->object);
120 }
121
122 /* Complete the info block initialization */
123
124 info->return_object = NULL;
125 info->node_flags = info->node->flags;
126 info->obj_desc = acpi_ns_get_attached_object(info->node);
127
128 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
129 info->relative_pathname, info->node,
130 acpi_ns_get_attached_object(info->node)));
131
132 /* Get info if we have a predefined name (_HID, etc.) */
133
134 info->predefined =
135 acpi_ut_match_predefined_method(info->node->name.ascii);
136
137 /* Get the full pathname to the object, for use in warning messages */
138
139 info->full_pathname = acpi_ns_get_external_pathname(info->node);
140 if (!info->full_pathname) {
141 return_ACPI_STATUS(AE_NO_MEMORY);
127 } 142 }
128 143
129 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n", info->pathname, 144 /* Count the number of arguments being passed in */
130 info->resolved_node, 145
131 acpi_ns_get_attached_object(info->resolved_node))); 146 info->param_count = 0;
147 if (info->parameters) {
148 while (info->parameters[info->param_count]) {
149 info->param_count++;
150 }
151
152 /* Warn on impossible argument count */
153
154 if (info->param_count > ACPI_METHOD_NUM_ARGS) {
155 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
156 ACPI_WARN_ALWAYS,
157 "Excess arguments (%u) - using only %u",
158 info->param_count,
159 ACPI_METHOD_NUM_ARGS));
160
161 info->param_count = ACPI_METHOD_NUM_ARGS;
162 }
163 }
164
165 /*
166 * For predefined names: Check that the declared argument count
167 * matches the ACPI spec -- otherwise this is a BIOS error.
168 */
169 acpi_ns_check_acpi_compliance(info->full_pathname, info->node,
170 info->predefined);
171
172 /*
173 * For all names: Check that the incoming argument count for
174 * this method/object matches the actual ASL/AML definition.
175 */
176 acpi_ns_check_argument_count(info->full_pathname, info->node,
177 info->param_count, info->predefined);
132 178
133 node = info->resolved_node; 179 /* For predefined names: Typecheck all incoming arguments */
180
181 acpi_ns_check_argument_types(info);
134 182
135 /* 183 /*
136 * Two major cases here: 184 * Three major evaluation cases:
137 * 185 *
138 * 1) The object is a control method -- execute it 186 * 1) Object types that cannot be evaluated by definition
139 * 2) The object is not a method -- just return it's current value 187 * 2) The object is a control method -- execute it
188 * 3) The object is not a method -- just return it's current value
140 */ 189 */
141 if (acpi_ns_get_type(info->resolved_node) == ACPI_TYPE_METHOD) { 190 switch (acpi_ns_get_type(info->node)) {
191 case ACPI_TYPE_DEVICE:
192 case ACPI_TYPE_EVENT:
193 case ACPI_TYPE_MUTEX:
194 case ACPI_TYPE_REGION:
195 case ACPI_TYPE_THERMAL:
196 case ACPI_TYPE_LOCAL_SCOPE:
197 /*
198 * 1) Disallow evaluation of certain object types. For these,
199 * object evaluation is undefined and not supported.
200 */
201 ACPI_ERROR((AE_INFO,
202 "%s: Evaluation of object type [%s] is not supported",
203 info->full_pathname,
204 acpi_ut_get_type_name(info->node->type)));
205
206 status = AE_TYPE;
207 goto cleanup;
208
209 case ACPI_TYPE_METHOD:
142 /* 210 /*
143 * 1) Object is a control method - execute it 211 * 2) Object is a control method - execute it
144 */ 212 */
145 213
146 /* Verify that there is a method object associated with this node */ 214 /* Verify that there is a method object associated with this node */
147 215
148 info->obj_desc =
149 acpi_ns_get_attached_object(info->resolved_node);
150 if (!info->obj_desc) { 216 if (!info->obj_desc) {
151 ACPI_ERROR((AE_INFO, 217 ACPI_ERROR((AE_INFO,
152 "Control method has no attached sub-object")); 218 "%s: Method has no attached sub-object",
153 return_ACPI_STATUS(AE_NULL_OBJECT); 219 info->full_pathname));
220 status = AE_NULL_OBJECT;
221 goto cleanup;
154 } 222 }
155 223
156 /* Count the number of arguments being passed to the method */
157
158 if (info->parameters) {
159 while (info->parameters[info->param_count]) {
160 if (info->param_count > ACPI_METHOD_MAX_ARG) {
161 return_ACPI_STATUS(AE_LIMIT);
162 }
163 info->param_count++;
164 }
165 }
166
167
168 ACPI_DUMP_PATHNAME(info->resolved_node, "ACPI: Execute Method",
169 ACPI_LV_INFO, _COMPONENT);
170
171 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 224 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
172 "Method at AML address %p Length %X\n", 225 "**** Execute method [%s] at AML address %p length %X\n",
226 info->full_pathname,
173 info->obj_desc->method.aml_start + 1, 227 info->obj_desc->method.aml_start + 1,
174 info->obj_desc->method.aml_length - 1)); 228 info->obj_desc->method.aml_length - 1));
175 229
@@ -184,81 +238,61 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
184 acpi_ex_enter_interpreter(); 238 acpi_ex_enter_interpreter();
185 status = acpi_ps_execute_method(info); 239 status = acpi_ps_execute_method(info);
186 acpi_ex_exit_interpreter(); 240 acpi_ex_exit_interpreter();
187 } else { 241 break;
242
243 default:
188 /* 244 /*
189 * 2) Object is not a method, return its current value 245 * 3) All other non-method objects -- get the current object value
190 *
191 * Disallow certain object types. For these, "evaluation" is undefined.
192 */ 246 */
193 switch (info->resolved_node->type) {
194 case ACPI_TYPE_DEVICE:
195 case ACPI_TYPE_EVENT:
196 case ACPI_TYPE_MUTEX:
197 case ACPI_TYPE_REGION:
198 case ACPI_TYPE_THERMAL:
199 case ACPI_TYPE_LOCAL_SCOPE:
200
201 ACPI_ERROR((AE_INFO,
202 "[%4.4s] Evaluation of object type [%s] is not supported",
203 info->resolved_node->name.ascii,
204 acpi_ut_get_type_name(info->resolved_node->
205 type)));
206
207 return_ACPI_STATUS(AE_TYPE);
208
209 default:
210 break;
211 }
212 247
213 /* 248 /*
214 * Objects require additional resolution steps (e.g., the Node may be 249 * Some objects require additional resolution steps (e.g., the Node
215 * a field that must be read, etc.) -- we can't just grab the object 250 * may be a field that must be read, etc.) -- we can't just grab
216 * out of the node. 251 * the object out of the node.
217 * 252 *
218 * Use resolve_node_to_value() to get the associated value. 253 * Use resolve_node_to_value() to get the associated value.
219 * 254 *
220 * NOTE: we can get away with passing in NULL for a walk state because 255 * NOTE: we can get away with passing in NULL for a walk state because
221 * resolved_node is guaranteed to not be a reference to either a method 256 * the Node is guaranteed to not be a reference to either a method
222 * local or a method argument (because this interface is never called 257 * local or a method argument (because this interface is never called
223 * from a running method.) 258 * from a running method.)
224 * 259 *
225 * Even though we do not directly invoke the interpreter for object 260 * Even though we do not directly invoke the interpreter for object
226 * resolution, we must lock it because we could access an opregion. 261 * resolution, we must lock it because we could access an op_region.
227 * The opregion access code assumes that the interpreter is locked. 262 * The op_region access code assumes that the interpreter is locked.
228 */ 263 */
229 acpi_ex_enter_interpreter(); 264 acpi_ex_enter_interpreter();
230 265
231 /* Function has a strange interface */ 266 /* TBD: resolve_node_to_value has a strange interface, fix */
267
268 info->return_object =
269 ACPI_CAST_PTR(union acpi_operand_object, info->node);
232 270
233 status = 271 status =
234 acpi_ex_resolve_node_to_value(&info->resolved_node, NULL); 272 acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
273 (struct acpi_namespace_node,
274 &info->return_object), NULL);
235 acpi_ex_exit_interpreter(); 275 acpi_ex_exit_interpreter();
236 276
237 /* 277 if (ACPI_FAILURE(status)) {
238 * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed 278 goto cleanup;
239 * in resolved_node.
240 */
241 if (ACPI_SUCCESS(status)) {
242 status = AE_CTRL_RETURN_VALUE;
243 info->return_object =
244 ACPI_CAST_PTR(union acpi_operand_object,
245 info->resolved_node);
246
247 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
248 "Returning object %p [%s]\n",
249 info->return_object,
250 acpi_ut_get_object_type_name(info->
251 return_object)));
252 } 279 }
280
281 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Returned object %p [%s]\n",
282 info->return_object,
283 acpi_ut_get_object_type_name(info->
284 return_object)));
285
286 status = AE_CTRL_RETURN_VALUE; /* Always has a "return value" */
287 break;
253 } 288 }
254 289
255 /* 290 /*
256 * Check input argument count against the ASL-defined count for a method. 291 * For predefined names, check the return value against the ACPI
257 * Also check predefined names: argument count and return value against 292 * specification. Some incorrect return value types are repaired.
258 * the ACPI specification. Some incorrect return value types are repaired.
259 */ 293 */
260 (void)acpi_ns_check_predefined_names(node, info->param_count, 294 (void)acpi_ns_check_return_value(info->node, info, info->param_count,
261 status, &info->return_object); 295 status, &info->return_object);
262 296
263 /* Check if there is a return value that must be dealt with */ 297 /* Check if there is a return value that must be dealt with */
264 298
@@ -278,12 +312,15 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
278 312
279 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 313 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
280 "*** Completed evaluation of object %s ***\n", 314 "*** Completed evaluation of object %s ***\n",
281 info->pathname)); 315 info->relative_pathname));
282 316
317 cleanup:
283 /* 318 /*
284 * Namespace was unlocked by the handling acpi_ns* function, so we 319 * Namespace was unlocked by the handling acpi_ns* function, so we
285 * just return 320 * just free the pathname and return
286 */ 321 */
322 ACPI_FREE(info->full_pathname);
323 info->full_pathname = NULL;
287 return_ACPI_STATUS(status); 324 return_ACPI_STATUS(status);
288} 325}
289 326
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 46f0f83417a1..dd2ceae3f717 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -176,7 +176,7 @@ acpi_status acpi_ns_initialize_devices(void)
176 * part of the ACPI specification. 176 * part of the ACPI specification.
177 */ 177 */
178 info.evaluate_info->prefix_node = acpi_gbl_root_node; 178 info.evaluate_info->prefix_node = acpi_gbl_root_node;
179 info.evaluate_info->pathname = METHOD_NAME__INI; 179 info.evaluate_info->relative_pathname = METHOD_NAME__INI;
180 info.evaluate_info->parameters = NULL; 180 info.evaluate_info->parameters = NULL;
181 info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE; 181 info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE;
182 182
@@ -266,28 +266,34 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
266 266
267 switch (type) { 267 switch (type) {
268 case ACPI_TYPE_REGION: 268 case ACPI_TYPE_REGION:
269
269 info->op_region_count++; 270 info->op_region_count++;
270 break; 271 break;
271 272
272 case ACPI_TYPE_BUFFER_FIELD: 273 case ACPI_TYPE_BUFFER_FIELD:
274
273 info->field_count++; 275 info->field_count++;
274 break; 276 break;
275 277
276 case ACPI_TYPE_LOCAL_BANK_FIELD: 278 case ACPI_TYPE_LOCAL_BANK_FIELD:
279
277 info->field_count++; 280 info->field_count++;
278 break; 281 break;
279 282
280 case ACPI_TYPE_BUFFER: 283 case ACPI_TYPE_BUFFER:
284
281 info->buffer_count++; 285 info->buffer_count++;
282 break; 286 break;
283 287
284 case ACPI_TYPE_PACKAGE: 288 case ACPI_TYPE_PACKAGE:
289
285 info->package_count++; 290 info->package_count++;
286 break; 291 break;
287 292
288 default: 293 default:
289 294
290 /* No init required, just exit now */ 295 /* No init required, just exit now */
296
291 return (AE_OK); 297 return (AE_OK);
292 } 298 }
293 299
@@ -337,7 +343,9 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
337 break; 343 break;
338 344
339 default: 345 default:
346
340 /* No other types can get here */ 347 /* No other types can get here */
348
341 break; 349 break;
342 } 350 }
343 351
@@ -416,6 +424,7 @@ acpi_ns_find_ini_methods(acpi_handle obj_handle,
416 break; 424 break;
417 425
418 default: 426 default:
427
419 break; 428 break;
420 } 429 }
421 430
@@ -560,7 +569,7 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
560 569
561 ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info)); 570 ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info));
562 info->prefix_node = device_node; 571 info->prefix_node = device_node;
563 info->pathname = METHOD_NAME__INI; 572 info->relative_pathname = METHOD_NAME__INI;
564 info->parameters = NULL; 573 info->parameters = NULL;
565 info->flags = ACPI_IGNORE_RETURN_VALUE; 574 info->flags = ACPI_IGNORE_RETURN_VALUE;
566 575
@@ -574,8 +583,7 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
574 583
575 /* Ignore error and move on to next device */ 584 /* Ignore error and move on to next device */
576 585
577 char *scope_name = 586 char *scope_name = acpi_ns_get_external_pathname(info->node);
578 acpi_ns_get_external_pathname(info->resolved_node);
579 587
580 ACPI_EXCEPTION((AE_INFO, status, "during %s._INI execution", 588 ACPI_EXCEPTION((AE_INFO, status, "during %s._INI execution",
581 scope_name)); 589 scope_name));
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 8a52916148cb..24b71a01bf93 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -61,28 +61,29 @@ ACPI_MODULE_NAME("nspredef")
61 * There are several areas that are validated: 61 * There are several areas that are validated:
62 * 62 *
63 * 1) The number of input arguments as defined by the method/object in the 63 * 1) The number of input arguments as defined by the method/object in the
64 * ASL is validated against the ACPI specification. 64 * ASL is validated against the ACPI specification.
65 * 2) The type of the return object (if any) is validated against the ACPI 65 * 2) The type of the return object (if any) is validated against the ACPI
66 * specification. 66 * specification.
67 * 3) For returned package objects, the count of package elements is 67 * 3) For returned package objects, the count of package elements is
68 * validated, as well as the type of each package element. Nested 68 * validated, as well as the type of each package element. Nested
69 * packages are supported. 69 * packages are supported.
70 * 70 *
71 * For any problems found, a warning message is issued. 71 * For any problems found, a warning message is issued.
72 * 72 *
73 ******************************************************************************/ 73 ******************************************************************************/
74/* Local prototypes */ 74/* Local prototypes */
75static acpi_status 75static acpi_status
76acpi_ns_check_reference(struct acpi_predefined_data *data, 76acpi_ns_check_reference(struct acpi_evaluate_info *info,
77 union acpi_operand_object *return_object); 77 union acpi_operand_object *return_object);
78 78
79static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); 79static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object);
80 80
81/******************************************************************************* 81/*******************************************************************************
82 * 82 *
83 * FUNCTION: acpi_ns_check_predefined_names 83 * FUNCTION: acpi_ns_check_return_value
84 * 84 *
85 * PARAMETERS: node - Namespace node for the method/object 85 * PARAMETERS: node - Namespace node for the method/object
86 * info - Method execution information block
86 * user_param_count - Number of parameters actually passed 87 * user_param_count - Number of parameters actually passed
87 * return_status - Status from the object evaluation 88 * return_status - Status from the object evaluation
88 * return_object_ptr - Pointer to the object returned from the 89 * return_object_ptr - Pointer to the object returned from the
@@ -90,44 +91,25 @@ static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object);
90 * 91 *
91 * RETURN: Status 92 * RETURN: Status
92 * 93 *
93 * DESCRIPTION: Check an ACPI name for a match in the predefined name list. 94 * DESCRIPTION: Check the value returned from a predefined name.
94 * 95 *
95 ******************************************************************************/ 96 ******************************************************************************/
96 97
97acpi_status 98acpi_status
98acpi_ns_check_predefined_names(struct acpi_namespace_node *node, 99acpi_ns_check_return_value(struct acpi_namespace_node *node,
99 u32 user_param_count, 100 struct acpi_evaluate_info *info,
100 acpi_status return_status, 101 u32 user_param_count,
101 union acpi_operand_object **return_object_ptr) 102 acpi_status return_status,
103 union acpi_operand_object **return_object_ptr)
102{ 104{
103 acpi_status status = AE_OK; 105 acpi_status status;
104 const union acpi_predefined_info *predefined; 106 const union acpi_predefined_info *predefined;
105 char *pathname;
106 struct acpi_predefined_data *data;
107
108 /* Match the name for this method/object against the predefined list */
109
110 predefined = acpi_ut_match_predefined_method(node->name.ascii);
111
112 /* Get the full pathname to the object, for use in warning messages */
113
114 pathname = acpi_ns_get_external_pathname(node);
115 if (!pathname) {
116 return (AE_OK); /* Could not get pathname, ignore */
117 }
118
119 /*
120 * Check that the parameter count for this method matches the ASL
121 * definition. For predefined names, ensure that both the caller and
122 * the method itself are in accordance with the ACPI specification.
123 */
124 acpi_ns_check_parameter_count(pathname, node, user_param_count,
125 predefined);
126 107
127 /* If not a predefined name, we cannot validate the return object */ 108 /* If not a predefined name, we cannot validate the return object */
128 109
110 predefined = info->predefined;
129 if (!predefined) { 111 if (!predefined) {
130 goto cleanup; 112 return (AE_OK);
131 } 113 }
132 114
133 /* 115 /*
@@ -135,7 +117,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
135 * validate the return object 117 * validate the return object
136 */ 118 */
137 if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) { 119 if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) {
138 goto cleanup; 120 return (AE_OK);
139 } 121 }
140 122
141 /* 123 /*
@@ -154,25 +136,14 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
154 if (acpi_gbl_disable_auto_repair || 136 if (acpi_gbl_disable_auto_repair ||
155 (!predefined->info.expected_btypes) || 137 (!predefined->info.expected_btypes) ||
156 (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) { 138 (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) {
157 goto cleanup; 139 return (AE_OK);
158 }
159
160 /* Create the parameter data block for object validation */
161
162 data = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_predefined_data));
163 if (!data) {
164 goto cleanup;
165 } 140 }
166 data->predefined = predefined;
167 data->node = node;
168 data->node_flags = node->flags;
169 data->pathname = pathname;
170 141
171 /* 142 /*
172 * Check that the type of the main return object is what is expected 143 * Check that the type of the main return object is what is expected
173 * for this predefined name 144 * for this predefined name
174 */ 145 */
175 status = acpi_ns_check_object_type(data, return_object_ptr, 146 status = acpi_ns_check_object_type(info, return_object_ptr,
176 predefined->info.expected_btypes, 147 predefined->info.expected_btypes,
177 ACPI_NOT_PACKAGE_ELEMENT); 148 ACPI_NOT_PACKAGE_ELEMENT);
178 if (ACPI_FAILURE(status)) { 149 if (ACPI_FAILURE(status)) {
@@ -184,10 +155,16 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
184 * Note: Package may have been newly created by call above. 155 * Note: Package may have been newly created by call above.
185 */ 156 */
186 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { 157 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) {
187 data->parent_package = *return_object_ptr; 158 info->parent_package = *return_object_ptr;
188 status = acpi_ns_check_package(data, return_object_ptr); 159 status = acpi_ns_check_package(info, return_object_ptr);
189 if (ACPI_FAILURE(status)) { 160 if (ACPI_FAILURE(status)) {
190 goto exit; 161
162 /* We might be able to fix some errors */
163
164 if ((status != AE_AML_OPERAND_TYPE) &&
165 (status != AE_AML_OPERAND_VALUE)) {
166 goto exit;
167 }
191 } 168 }
192 } 169 }
193 170
@@ -199,7 +176,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
199 * performed on a per-name basis, i.e., the code is specific to 176 * performed on a per-name basis, i.e., the code is specific to
200 * particular predefined names. 177 * particular predefined names.
201 */ 178 */
202 status = acpi_ns_complex_repairs(data, node, status, return_object_ptr); 179 status = acpi_ns_complex_repairs(info, node, status, return_object_ptr);
203 180
204exit: 181exit:
205 /* 182 /*
@@ -207,112 +184,18 @@ exit:
207 * or more objects, mark the parent node to suppress further warning 184 * or more objects, mark the parent node to suppress further warning
208 * messages during the next evaluation of the same method/object. 185 * messages during the next evaluation of the same method/object.
209 */ 186 */
210 if (ACPI_FAILURE(status) || (data->flags & ACPI_OBJECT_REPAIRED)) { 187 if (ACPI_FAILURE(status) || (info->return_flags & ACPI_OBJECT_REPAIRED)) {
211 node->flags |= ANOBJ_EVALUATED; 188 node->flags |= ANOBJ_EVALUATED;
212 } 189 }
213 ACPI_FREE(data);
214 190
215cleanup:
216 ACPI_FREE(pathname);
217 return (status); 191 return (status);
218} 192}
219 193
220/******************************************************************************* 194/*******************************************************************************
221 * 195 *
222 * FUNCTION: acpi_ns_check_parameter_count
223 *
224 * PARAMETERS: pathname - Full pathname to the node (for error msgs)
225 * node - Namespace node for the method/object
226 * user_param_count - Number of args passed in by the caller
227 * predefined - Pointer to entry in predefined name table
228 *
229 * RETURN: None
230 *
231 * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a
232 * predefined name is what is expected (i.e., what is defined in
233 * the ACPI specification for this predefined name.)
234 *
235 ******************************************************************************/
236
237void
238acpi_ns_check_parameter_count(char *pathname,
239 struct acpi_namespace_node *node,
240 u32 user_param_count,
241 const union acpi_predefined_info *predefined)
242{
243 u32 param_count;
244 u32 required_params_current;
245 u32 required_params_old;
246
247 /* Methods have 0-7 parameters. All other types have zero. */
248
249 param_count = 0;
250 if (node->type == ACPI_TYPE_METHOD) {
251 param_count = node->object->method.param_count;
252 }
253
254 if (!predefined) {
255 /*
256 * Check the parameter count for non-predefined methods/objects.
257 *
258 * Warning if too few or too many arguments have been passed by the
259 * caller. An incorrect number of arguments may not cause the method
260 * to fail. However, the method will fail if there are too few
261 * arguments and the method attempts to use one of the missing ones.
262 */
263 if (user_param_count < param_count) {
264 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
265 ACPI_WARN_ALWAYS,
266 "Insufficient arguments - needs %u, found %u",
267 param_count, user_param_count));
268 } else if (user_param_count > param_count) {
269 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
270 ACPI_WARN_ALWAYS,
271 "Excess arguments - needs %u, found %u",
272 param_count, user_param_count));
273 }
274 return;
275 }
276
277 /*
278 * Validate the user-supplied parameter count.
279 * Allow two different legal argument counts (_SCP, etc.)
280 */
281 required_params_current =
282 predefined->info.argument_list & METHOD_ARG_MASK;
283 required_params_old =
284 predefined->info.argument_list >> METHOD_ARG_BIT_WIDTH;
285
286 if (user_param_count != ACPI_UINT32_MAX) {
287 if ((user_param_count != required_params_current) &&
288 (user_param_count != required_params_old)) {
289 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
290 ACPI_WARN_ALWAYS,
291 "Parameter count mismatch - "
292 "caller passed %u, ACPI requires %u",
293 user_param_count,
294 required_params_current));
295 }
296 }
297
298 /*
299 * Check that the ASL-defined parameter count is what is expected for
300 * this predefined name (parameter count as defined by the ACPI
301 * specification)
302 */
303 if ((param_count != required_params_current) &&
304 (param_count != required_params_old)) {
305 ACPI_WARN_PREDEFINED((AE_INFO, pathname, node->flags,
306 "Parameter count mismatch - ASL declared %u, ACPI requires %u",
307 param_count, required_params_current));
308 }
309}
310
311/*******************************************************************************
312 *
313 * FUNCTION: acpi_ns_check_object_type 196 * FUNCTION: acpi_ns_check_object_type
314 * 197 *
315 * PARAMETERS: data - Pointer to validation data structure 198 * PARAMETERS: info - Method execution information block
316 * return_object_ptr - Pointer to the object returned from the 199 * return_object_ptr - Pointer to the object returned from the
317 * evaluation of a method or object 200 * evaluation of a method or object
318 * expected_btypes - Bitmap of expected return type(s) 201 * expected_btypes - Bitmap of expected return type(s)
@@ -328,7 +211,7 @@ acpi_ns_check_parameter_count(char *pathname,
328 ******************************************************************************/ 211 ******************************************************************************/
329 212
330acpi_status 213acpi_status
331acpi_ns_check_object_type(struct acpi_predefined_data *data, 214acpi_ns_check_object_type(struct acpi_evaluate_info *info,
332 union acpi_operand_object **return_object_ptr, 215 union acpi_operand_object **return_object_ptr,
333 u32 expected_btypes, u32 package_index) 216 u32 expected_btypes, u32 package_index)
334{ 217{
@@ -340,7 +223,8 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
340 223
341 if (return_object && 224 if (return_object &&
342 ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { 225 ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) {
343 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 226 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
227 info->node_flags,
344 "Invalid return type - Found a Namespace node [%4.4s] type %s", 228 "Invalid return type - Found a Namespace node [%4.4s] type %s",
345 return_object->node.name.ascii, 229 return_object->node.name.ascii,
346 acpi_ut_get_type_name(return_object->node. 230 acpi_ut_get_type_name(return_object->node.
@@ -356,8 +240,8 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
356 * from all of the predefined names (including elements of returned 240 * from all of the predefined names (including elements of returned
357 * packages) 241 * packages)
358 */ 242 */
359 data->return_btype = acpi_ns_get_bitmapped_type(return_object); 243 info->return_btype = acpi_ns_get_bitmapped_type(return_object);
360 if (data->return_btype == ACPI_RTYPE_ANY) { 244 if (info->return_btype == ACPI_RTYPE_ANY) {
361 245
362 /* Not one of the supported objects, must be incorrect */ 246 /* Not one of the supported objects, must be incorrect */
363 goto type_error_exit; 247 goto type_error_exit;
@@ -365,16 +249,18 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
365 249
366 /* For reference objects, check that the reference type is correct */ 250 /* For reference objects, check that the reference type is correct */
367 251
368 if ((data->return_btype & expected_btypes) == ACPI_RTYPE_REFERENCE) { 252 if ((info->return_btype & expected_btypes) == ACPI_RTYPE_REFERENCE) {
369 status = acpi_ns_check_reference(data, return_object); 253 status = acpi_ns_check_reference(info, return_object);
370 return (status); 254 return (status);
371 } 255 }
372 256
373 /* Attempt simple repair of the returned object if necessary */ 257 /* Attempt simple repair of the returned object if necessary */
374 258
375 status = acpi_ns_simple_repair(data, expected_btypes, 259 status = acpi_ns_simple_repair(info, expected_btypes,
376 package_index, return_object_ptr); 260 package_index, return_object_ptr);
377 return (status); 261 if (ACPI_SUCCESS(status)) {
262 return (AE_OK); /* Successful repair */
263 }
378 264
379 type_error_exit: 265 type_error_exit:
380 266
@@ -383,12 +269,14 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
383 acpi_ut_get_expected_return_types(type_buffer, expected_btypes); 269 acpi_ut_get_expected_return_types(type_buffer, expected_btypes);
384 270
385 if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { 271 if (package_index == ACPI_NOT_PACKAGE_ELEMENT) {
386 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 272 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
273 info->node_flags,
387 "Return type mismatch - found %s, expected %s", 274 "Return type mismatch - found %s, expected %s",
388 acpi_ut_get_object_type_name 275 acpi_ut_get_object_type_name
389 (return_object), type_buffer)); 276 (return_object), type_buffer));
390 } else { 277 } else {
391 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 278 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
279 info->node_flags,
392 "Return Package type mismatch at index %u - " 280 "Return Package type mismatch at index %u - "
393 "found %s, expected %s", package_index, 281 "found %s, expected %s", package_index,
394 acpi_ut_get_object_type_name 282 acpi_ut_get_object_type_name
@@ -402,7 +290,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
402 * 290 *
403 * FUNCTION: acpi_ns_check_reference 291 * FUNCTION: acpi_ns_check_reference
404 * 292 *
405 * PARAMETERS: data - Pointer to validation data structure 293 * PARAMETERS: info - Method execution information block
406 * return_object - Object returned from the evaluation of a 294 * return_object - Object returned from the evaluation of a
407 * method or object 295 * method or object
408 * 296 *
@@ -415,7 +303,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
415 ******************************************************************************/ 303 ******************************************************************************/
416 304
417static acpi_status 305static acpi_status
418acpi_ns_check_reference(struct acpi_predefined_data *data, 306acpi_ns_check_reference(struct acpi_evaluate_info *info,
419 union acpi_operand_object *return_object) 307 union acpi_operand_object *return_object)
420{ 308{
421 309
@@ -428,7 +316,7 @@ acpi_ns_check_reference(struct acpi_predefined_data *data,
428 return (AE_OK); 316 return (AE_OK);
429 } 317 }
430 318
431 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 319 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags,
432 "Return type mismatch - unexpected reference object type [%s] %2.2X", 320 "Return type mismatch - unexpected reference object type [%s] %2.2X",
433 acpi_ut_get_reference_name(return_object), 321 acpi_ut_get_reference_name(return_object),
434 return_object->reference.class)); 322 return_object->reference.class));
@@ -462,26 +350,32 @@ static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object)
462 350
463 switch (return_object->common.type) { 351 switch (return_object->common.type) {
464 case ACPI_TYPE_INTEGER: 352 case ACPI_TYPE_INTEGER:
353
465 return_btype = ACPI_RTYPE_INTEGER; 354 return_btype = ACPI_RTYPE_INTEGER;
466 break; 355 break;
467 356
468 case ACPI_TYPE_BUFFER: 357 case ACPI_TYPE_BUFFER:
358
469 return_btype = ACPI_RTYPE_BUFFER; 359 return_btype = ACPI_RTYPE_BUFFER;
470 break; 360 break;
471 361
472 case ACPI_TYPE_STRING: 362 case ACPI_TYPE_STRING:
363
473 return_btype = ACPI_RTYPE_STRING; 364 return_btype = ACPI_RTYPE_STRING;
474 break; 365 break;
475 366
476 case ACPI_TYPE_PACKAGE: 367 case ACPI_TYPE_PACKAGE:
368
477 return_btype = ACPI_RTYPE_PACKAGE; 369 return_btype = ACPI_RTYPE_PACKAGE;
478 break; 370 break;
479 371
480 case ACPI_TYPE_LOCAL_REFERENCE: 372 case ACPI_TYPE_LOCAL_REFERENCE:
373
481 return_btype = ACPI_RTYPE_REFERENCE; 374 return_btype = ACPI_RTYPE_REFERENCE;
482 break; 375 break;
483 376
484 default: 377 default:
378
485 /* Not one of the supported objects, must be incorrect */ 379 /* Not one of the supported objects, must be incorrect */
486 380
487 return_btype = ACPI_RTYPE_ANY; 381 return_btype = ACPI_RTYPE_ANY;
diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c
index 77cdd539de16..6d55cef7916c 100644
--- a/drivers/acpi/acpica/nsprepkg.c
+++ b/drivers/acpi/acpica/nsprepkg.c
@@ -51,12 +51,12 @@ ACPI_MODULE_NAME("nsprepkg")
51 51
52/* Local prototypes */ 52/* Local prototypes */
53static acpi_status 53static acpi_status
54acpi_ns_check_package_list(struct acpi_predefined_data *data, 54acpi_ns_check_package_list(struct acpi_evaluate_info *info,
55 const union acpi_predefined_info *package, 55 const union acpi_predefined_info *package,
56 union acpi_operand_object **elements, u32 count); 56 union acpi_operand_object **elements, u32 count);
57 57
58static acpi_status 58static acpi_status
59acpi_ns_check_package_elements(struct acpi_predefined_data *data, 59acpi_ns_check_package_elements(struct acpi_evaluate_info *info,
60 union acpi_operand_object **elements, 60 union acpi_operand_object **elements,
61 u8 type1, 61 u8 type1,
62 u32 count1, 62 u32 count1,
@@ -66,7 +66,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data,
66 * 66 *
67 * FUNCTION: acpi_ns_check_package 67 * FUNCTION: acpi_ns_check_package
68 * 68 *
69 * PARAMETERS: data - Pointer to validation data structure 69 * PARAMETERS: info - Method execution information block
70 * return_object_ptr - Pointer to the object returned from the 70 * return_object_ptr - Pointer to the object returned from the
71 * evaluation of a method or object 71 * evaluation of a method or object
72 * 72 *
@@ -78,7 +78,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data,
78 ******************************************************************************/ 78 ******************************************************************************/
79 79
80acpi_status 80acpi_status
81acpi_ns_check_package(struct acpi_predefined_data *data, 81acpi_ns_check_package(struct acpi_evaluate_info *info,
82 union acpi_operand_object **return_object_ptr) 82 union acpi_operand_object **return_object_ptr)
83{ 83{
84 union acpi_operand_object *return_object = *return_object_ptr; 84 union acpi_operand_object *return_object = *return_object_ptr;
@@ -93,18 +93,18 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
93 93
94 /* The package info for this name is in the next table entry */ 94 /* The package info for this name is in the next table entry */
95 95
96 package = data->predefined + 1; 96 package = info->predefined + 1;
97 97
98 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 98 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
99 "%s Validating return Package of Type %X, Count %X\n", 99 "%s Validating return Package of Type %X, Count %X\n",
100 data->pathname, package->ret_info.type, 100 info->full_pathname, package->ret_info.type,
101 return_object->package.count)); 101 return_object->package.count));
102 102
103 /* 103 /*
104 * For variable-length Packages, we can safely remove all embedded 104 * For variable-length Packages, we can safely remove all embedded
105 * and trailing NULL package elements 105 * and trailing NULL package elements
106 */ 106 */
107 acpi_ns_remove_null_elements(data, package->ret_info.type, 107 acpi_ns_remove_null_elements(info, package->ret_info.type,
108 return_object); 108 return_object);
109 109
110 /* Extract package count and elements array */ 110 /* Extract package count and elements array */
@@ -121,7 +121,8 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
121 return (AE_OK); 121 return (AE_OK);
122 } 122 }
123 123
124 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 124 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
125 info->node_flags,
125 "Return Package has no elements (empty)")); 126 "Return Package has no elements (empty)"));
126 127
127 return (AE_AML_OPERAND_VALUE); 128 return (AE_AML_OPERAND_VALUE);
@@ -135,7 +136,6 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
135 */ 136 */
136 switch (package->ret_info.type) { 137 switch (package->ret_info.type) {
137 case ACPI_PTYPE1_FIXED: 138 case ACPI_PTYPE1_FIXED:
138
139 /* 139 /*
140 * The package count is fixed and there are no sub-packages 140 * The package count is fixed and there are no sub-packages
141 * 141 *
@@ -150,13 +150,13 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
150 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 150 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
151 "%s: Return Package is larger than needed - " 151 "%s: Return Package is larger than needed - "
152 "found %u, expected %u\n", 152 "found %u, expected %u\n",
153 data->pathname, count, 153 info->full_pathname, count,
154 expected_count)); 154 expected_count));
155 } 155 }
156 156
157 /* Validate all elements of the returned package */ 157 /* Validate all elements of the returned package */
158 158
159 status = acpi_ns_check_package_elements(data, elements, 159 status = acpi_ns_check_package_elements(info, elements,
160 package->ret_info. 160 package->ret_info.
161 object_type1, 161 object_type1,
162 package->ret_info. 162 package->ret_info.
@@ -168,13 +168,12 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
168 break; 168 break;
169 169
170 case ACPI_PTYPE1_VAR: 170 case ACPI_PTYPE1_VAR:
171
172 /* 171 /*
173 * The package count is variable, there are no sub-packages, and all 172 * The package count is variable, there are no sub-packages, and all
174 * elements must be of the same type 173 * elements must be of the same type
175 */ 174 */
176 for (i = 0; i < count; i++) { 175 for (i = 0; i < count; i++) {
177 status = acpi_ns_check_object_type(data, elements, 176 status = acpi_ns_check_object_type(info, elements,
178 package->ret_info. 177 package->ret_info.
179 object_type1, i); 178 object_type1, i);
180 if (ACPI_FAILURE(status)) { 179 if (ACPI_FAILURE(status)) {
@@ -185,7 +184,6 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
185 break; 184 break;
186 185
187 case ACPI_PTYPE1_OPTION: 186 case ACPI_PTYPE1_OPTION:
188
189 /* 187 /*
190 * The package count is variable, there are no sub-packages. There are 188 * The package count is variable, there are no sub-packages. There are
191 * a fixed number of required elements, and a variable number of 189 * a fixed number of required elements, and a variable number of
@@ -206,7 +204,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
206 /* These are the required package elements (0, 1, or 2) */ 204 /* These are the required package elements (0, 1, or 2) */
207 205
208 status = 206 status =
209 acpi_ns_check_object_type(data, elements, 207 acpi_ns_check_object_type(info, elements,
210 package-> 208 package->
211 ret_info3. 209 ret_info3.
212 object_type[i], 210 object_type[i],
@@ -218,7 +216,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
218 /* These are the optional package elements */ 216 /* These are the optional package elements */
219 217
220 status = 218 status =
221 acpi_ns_check_object_type(data, elements, 219 acpi_ns_check_object_type(info, elements,
222 package-> 220 package->
223 ret_info3. 221 ret_info3.
224 tail_object_type, 222 tail_object_type,
@@ -235,7 +233,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
235 233
236 /* First element is the (Integer) revision */ 234 /* First element is the (Integer) revision */
237 235
238 status = acpi_ns_check_object_type(data, elements, 236 status = acpi_ns_check_object_type(info, elements,
239 ACPI_RTYPE_INTEGER, 0); 237 ACPI_RTYPE_INTEGER, 0);
240 if (ACPI_FAILURE(status)) { 238 if (ACPI_FAILURE(status)) {
241 return (status); 239 return (status);
@@ -247,14 +245,14 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
247 /* Examine the sub-packages */ 245 /* Examine the sub-packages */
248 246
249 status = 247 status =
250 acpi_ns_check_package_list(data, package, elements, count); 248 acpi_ns_check_package_list(info, package, elements, count);
251 break; 249 break;
252 250
253 case ACPI_PTYPE2_PKG_COUNT: 251 case ACPI_PTYPE2_PKG_COUNT:
254 252
255 /* First element is the (Integer) count of sub-packages to follow */ 253 /* First element is the (Integer) count of sub-packages to follow */
256 254
257 status = acpi_ns_check_object_type(data, elements, 255 status = acpi_ns_check_object_type(info, elements,
258 ACPI_RTYPE_INTEGER, 0); 256 ACPI_RTYPE_INTEGER, 0);
259 if (ACPI_FAILURE(status)) { 257 if (ACPI_FAILURE(status)) {
260 return (status); 258 return (status);
@@ -275,7 +273,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
275 /* Examine the sub-packages */ 273 /* Examine the sub-packages */
276 274
277 status = 275 status =
278 acpi_ns_check_package_list(data, package, elements, count); 276 acpi_ns_check_package_list(info, package, elements, count);
279 break; 277 break;
280 278
281 case ACPI_PTYPE2: 279 case ACPI_PTYPE2:
@@ -283,7 +281,6 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
283 case ACPI_PTYPE2_MIN: 281 case ACPI_PTYPE2_MIN:
284 case ACPI_PTYPE2_COUNT: 282 case ACPI_PTYPE2_COUNT:
285 case ACPI_PTYPE2_FIX_VAR: 283 case ACPI_PTYPE2_FIX_VAR:
286
287 /* 284 /*
288 * These types all return a single Package that consists of a 285 * These types all return a single Package that consists of a
289 * variable number of sub-Packages. 286 * variable number of sub-Packages.
@@ -300,7 +297,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
300 /* Create the new outer package and populate it */ 297 /* Create the new outer package and populate it */
301 298
302 status = 299 status =
303 acpi_ns_wrap_with_package(data, return_object, 300 acpi_ns_wrap_with_package(info, return_object,
304 return_object_ptr); 301 return_object_ptr);
305 if (ACPI_FAILURE(status)) { 302 if (ACPI_FAILURE(status)) {
306 return (status); 303 return (status);
@@ -316,14 +313,15 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
316 /* Examine the sub-packages */ 313 /* Examine the sub-packages */
317 314
318 status = 315 status =
319 acpi_ns_check_package_list(data, package, elements, count); 316 acpi_ns_check_package_list(info, package, elements, count);
320 break; 317 break;
321 318
322 default: 319 default:
323 320
324 /* Should not get here if predefined info table is correct */ 321 /* Should not get here if predefined info table is correct */
325 322
326 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 323 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
324 info->node_flags,
327 "Invalid internal return type in table entry: %X", 325 "Invalid internal return type in table entry: %X",
328 package->ret_info.type)); 326 package->ret_info.type));
329 327
@@ -336,7 +334,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
336 334
337 /* Error exit for the case with an incorrect package count */ 335 /* Error exit for the case with an incorrect package count */
338 336
339 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 337 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags,
340 "Return Package is too small - found %u elements, expected %u", 338 "Return Package is too small - found %u elements, expected %u",
341 count, expected_count)); 339 count, expected_count));
342 340
@@ -347,7 +345,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
347 * 345 *
348 * FUNCTION: acpi_ns_check_package_list 346 * FUNCTION: acpi_ns_check_package_list
349 * 347 *
350 * PARAMETERS: data - Pointer to validation data structure 348 * PARAMETERS: info - Method execution information block
351 * package - Pointer to package-specific info for method 349 * package - Pointer to package-specific info for method
352 * elements - Element list of parent package. All elements 350 * elements - Element list of parent package. All elements
353 * of this list should be of type Package. 351 * of this list should be of type Package.
@@ -360,7 +358,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
360 ******************************************************************************/ 358 ******************************************************************************/
361 359
362static acpi_status 360static acpi_status
363acpi_ns_check_package_list(struct acpi_predefined_data *data, 361acpi_ns_check_package_list(struct acpi_evaluate_info *info,
364 const union acpi_predefined_info *package, 362 const union acpi_predefined_info *package,
365 union acpi_operand_object **elements, u32 count) 363 union acpi_operand_object **elements, u32 count)
366{ 364{
@@ -381,11 +379,11 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
381 for (i = 0; i < count; i++) { 379 for (i = 0; i < count; i++) {
382 sub_package = *elements; 380 sub_package = *elements;
383 sub_elements = sub_package->package.elements; 381 sub_elements = sub_package->package.elements;
384 data->parent_package = sub_package; 382 info->parent_package = sub_package;
385 383
386 /* Each sub-object must be of type Package */ 384 /* Each sub-object must be of type Package */
387 385
388 status = acpi_ns_check_object_type(data, &sub_package, 386 status = acpi_ns_check_object_type(info, &sub_package,
389 ACPI_RTYPE_PACKAGE, i); 387 ACPI_RTYPE_PACKAGE, i);
390 if (ACPI_FAILURE(status)) { 388 if (ACPI_FAILURE(status)) {
391 return (status); 389 return (status);
@@ -393,7 +391,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
393 391
394 /* Examine the different types of expected sub-packages */ 392 /* Examine the different types of expected sub-packages */
395 393
396 data->parent_package = sub_package; 394 info->parent_package = sub_package;
397 switch (package->ret_info.type) { 395 switch (package->ret_info.type) {
398 case ACPI_PTYPE2: 396 case ACPI_PTYPE2:
399 case ACPI_PTYPE2_PKG_COUNT: 397 case ACPI_PTYPE2_PKG_COUNT:
@@ -408,7 +406,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
408 } 406 }
409 407
410 status = 408 status =
411 acpi_ns_check_package_elements(data, sub_elements, 409 acpi_ns_check_package_elements(info, sub_elements,
412 package->ret_info. 410 package->ret_info.
413 object_type1, 411 object_type1,
414 package->ret_info. 412 package->ret_info.
@@ -434,7 +432,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
434 } 432 }
435 433
436 status = 434 status =
437 acpi_ns_check_package_elements(data, sub_elements, 435 acpi_ns_check_package_elements(info, sub_elements,
438 package->ret_info. 436 package->ret_info.
439 object_type1, 437 object_type1,
440 package->ret_info. 438 package->ret_info.
@@ -463,7 +461,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
463 461
464 for (j = 0; j < expected_count; j++) { 462 for (j = 0; j < expected_count; j++) {
465 status = 463 status =
466 acpi_ns_check_object_type(data, 464 acpi_ns_check_object_type(info,
467 &sub_elements[j], 465 &sub_elements[j],
468 package-> 466 package->
469 ret_info2. 467 ret_info2.
@@ -487,7 +485,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
487 /* Check the type of each sub-package element */ 485 /* Check the type of each sub-package element */
488 486
489 status = 487 status =
490 acpi_ns_check_package_elements(data, sub_elements, 488 acpi_ns_check_package_elements(info, sub_elements,
491 package->ret_info. 489 package->ret_info.
492 object_type1, 490 object_type1,
493 sub_package->package. 491 sub_package->package.
@@ -498,12 +496,11 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
498 break; 496 break;
499 497
500 case ACPI_PTYPE2_COUNT: 498 case ACPI_PTYPE2_COUNT:
501
502 /* 499 /*
503 * First element is the (Integer) count of elements, including 500 * First element is the (Integer) count of elements, including
504 * the count field (the ACPI name is num_elements) 501 * the count field (the ACPI name is num_elements)
505 */ 502 */
506 status = acpi_ns_check_object_type(data, sub_elements, 503 status = acpi_ns_check_object_type(info, sub_elements,
507 ACPI_RTYPE_INTEGER, 504 ACPI_RTYPE_INTEGER,
508 0); 505 0);
509 if (ACPI_FAILURE(status)) { 506 if (ACPI_FAILURE(status)) {
@@ -537,7 +534,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
537 /* Check the type of each sub-package element */ 534 /* Check the type of each sub-package element */
538 535
539 status = 536 status =
540 acpi_ns_check_package_elements(data, 537 acpi_ns_check_package_elements(info,
541 (sub_elements + 1), 538 (sub_elements + 1),
542 package->ret_info. 539 package->ret_info.
543 object_type1, 540 object_type1,
@@ -562,7 +559,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
562 559
563 /* The sub-package count was smaller than required */ 560 /* The sub-package count was smaller than required */
564 561
565 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 562 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags,
566 "Return Sub-Package[%u] is too small - found %u elements, expected %u", 563 "Return Sub-Package[%u] is too small - found %u elements, expected %u",
567 i, sub_package->package.count, expected_count)); 564 i, sub_package->package.count, expected_count));
568 565
@@ -573,7 +570,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
573 * 570 *
574 * FUNCTION: acpi_ns_check_package_elements 571 * FUNCTION: acpi_ns_check_package_elements
575 * 572 *
576 * PARAMETERS: data - Pointer to validation data structure 573 * PARAMETERS: info - Method execution information block
577 * elements - Pointer to the package elements array 574 * elements - Pointer to the package elements array
578 * type1 - Object type for first group 575 * type1 - Object type for first group
579 * count1 - Count for first group 576 * count1 - Count for first group
@@ -589,7 +586,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
589 ******************************************************************************/ 586 ******************************************************************************/
590 587
591static acpi_status 588static acpi_status
592acpi_ns_check_package_elements(struct acpi_predefined_data *data, 589acpi_ns_check_package_elements(struct acpi_evaluate_info *info,
593 union acpi_operand_object **elements, 590 union acpi_operand_object **elements,
594 u8 type1, 591 u8 type1,
595 u32 count1, 592 u32 count1,
@@ -605,7 +602,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data,
605 * The second group can have a count of zero. 602 * The second group can have a count of zero.
606 */ 603 */
607 for (i = 0; i < count1; i++) { 604 for (i = 0; i < count1; i++) {
608 status = acpi_ns_check_object_type(data, this_element, 605 status = acpi_ns_check_object_type(info, this_element,
609 type1, i + start_index); 606 type1, i + start_index);
610 if (ACPI_FAILURE(status)) { 607 if (ACPI_FAILURE(status)) {
611 return (status); 608 return (status);
@@ -614,7 +611,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data,
614 } 611 }
615 612
616 for (i = 0; i < count2; i++) { 613 for (i = 0; i < count2; i++) {
617 status = acpi_ns_check_object_type(data, this_element, 614 status = acpi_ns_check_object_type(info, this_element,
618 type2, 615 type2,
619 (i + count1 + start_index)); 616 (i + count1 + start_index));
620 if (ACPI_FAILURE(status)) { 617 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index 18f02e4ece01..f8e71ea60319 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -130,7 +130,7 @@ static const struct acpi_simple_repair_info acpi_object_repair_info[] = {
130 * 130 *
131 * FUNCTION: acpi_ns_simple_repair 131 * FUNCTION: acpi_ns_simple_repair
132 * 132 *
133 * PARAMETERS: data - Pointer to validation data structure 133 * PARAMETERS: info - Method execution information block
134 * expected_btypes - Object types expected 134 * expected_btypes - Object types expected
135 * package_index - Index of object within parent package (if 135 * package_index - Index of object within parent package (if
136 * applicable - ACPI_NOT_PACKAGE_ELEMENT 136 * applicable - ACPI_NOT_PACKAGE_ELEMENT
@@ -146,7 +146,7 @@ static const struct acpi_simple_repair_info acpi_object_repair_info[] = {
146 ******************************************************************************/ 146 ******************************************************************************/
147 147
148acpi_status 148acpi_status
149acpi_ns_simple_repair(struct acpi_predefined_data *data, 149acpi_ns_simple_repair(struct acpi_evaluate_info *info,
150 u32 expected_btypes, 150 u32 expected_btypes,
151 u32 package_index, 151 u32 package_index,
152 union acpi_operand_object **return_object_ptr) 152 union acpi_operand_object **return_object_ptr)
@@ -162,12 +162,12 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data,
162 * Special repairs for certain names that are in the repair table. 162 * Special repairs for certain names that are in the repair table.
163 * Check if this name is in the list of repairable names. 163 * Check if this name is in the list of repairable names.
164 */ 164 */
165 predefined = acpi_ns_match_simple_repair(data->node, 165 predefined = acpi_ns_match_simple_repair(info->node,
166 data->return_btype, 166 info->return_btype,
167 package_index); 167 package_index);
168 if (predefined) { 168 if (predefined) {
169 if (!return_object) { 169 if (!return_object) {
170 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, 170 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
171 ACPI_WARN_ALWAYS, 171 ACPI_WARN_ALWAYS,
172 "Missing expected return value")); 172 "Missing expected return value"));
173 } 173 }
@@ -191,7 +191,7 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data,
191 * Do not perform simple object repair unless the return type is not 191 * Do not perform simple object repair unless the return type is not
192 * expected. 192 * expected.
193 */ 193 */
194 if (data->return_btype & expected_btypes) { 194 if (info->return_btype & expected_btypes) {
195 return (AE_OK); 195 return (AE_OK);
196 } 196 }
197 197
@@ -211,7 +211,7 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data,
211 */ 211 */
212 if (!return_object) { 212 if (!return_object) {
213 if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) { 213 if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) {
214 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, 214 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
215 ACPI_WARN_ALWAYS, 215 ACPI_WARN_ALWAYS,
216 "Missing expected return value")); 216 "Missing expected return value"));
217 217
@@ -247,14 +247,14 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data,
247 * for correct contents (expected object type or types). 247 * for correct contents (expected object type or types).
248 */ 248 */
249 status = 249 status =
250 acpi_ns_wrap_with_package(data, return_object, &new_object); 250 acpi_ns_wrap_with_package(info, return_object, &new_object);
251 if (ACPI_SUCCESS(status)) { 251 if (ACPI_SUCCESS(status)) {
252 /* 252 /*
253 * The original object just had its reference count 253 * The original object just had its reference count
254 * incremented for being inserted into the new package. 254 * incremented for being inserted into the new package.
255 */ 255 */
256 *return_object_ptr = new_object; /* New Package object */ 256 *return_object_ptr = new_object; /* New Package object */
257 data->flags |= ACPI_OBJECT_REPAIRED; 257 info->return_flags |= ACPI_OBJECT_REPAIRED;
258 return (AE_OK); 258 return (AE_OK);
259 } 259 }
260 } 260 }
@@ -277,7 +277,7 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data,
277 * package object as part of the repair, we don't need to 277 * package object as part of the repair, we don't need to
278 * change the reference count. 278 * change the reference count.
279 */ 279 */
280 if (!(data->flags & ACPI_OBJECT_WRAPPED)) { 280 if (!(info->return_flags & ACPI_OBJECT_WRAPPED)) {
281 new_object->common.reference_count = 281 new_object->common.reference_count =
282 return_object->common.reference_count; 282 return_object->common.reference_count;
283 283
@@ -288,14 +288,14 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data,
288 288
289 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 289 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
290 "%s: Converted %s to expected %s at Package index %u\n", 290 "%s: Converted %s to expected %s at Package index %u\n",
291 data->pathname, 291 info->full_pathname,
292 acpi_ut_get_object_type_name(return_object), 292 acpi_ut_get_object_type_name(return_object),
293 acpi_ut_get_object_type_name(new_object), 293 acpi_ut_get_object_type_name(new_object),
294 package_index)); 294 package_index));
295 } else { 295 } else {
296 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 296 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
297 "%s: Converted %s to expected %s\n", 297 "%s: Converted %s to expected %s\n",
298 data->pathname, 298 info->full_pathname,
299 acpi_ut_get_object_type_name(return_object), 299 acpi_ut_get_object_type_name(return_object),
300 acpi_ut_get_object_type_name(new_object))); 300 acpi_ut_get_object_type_name(new_object)));
301 } 301 }
@@ -304,7 +304,7 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data,
304 304
305 acpi_ut_remove_reference(return_object); 305 acpi_ut_remove_reference(return_object);
306 *return_object_ptr = new_object; 306 *return_object_ptr = new_object;
307 data->flags |= ACPI_OBJECT_REPAIRED; 307 info->return_flags |= ACPI_OBJECT_REPAIRED;
308 return (AE_OK); 308 return (AE_OK);
309} 309}
310 310
@@ -359,7 +359,7 @@ static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct
359 * 359 *
360 * FUNCTION: acpi_ns_repair_null_element 360 * FUNCTION: acpi_ns_repair_null_element
361 * 361 *
362 * PARAMETERS: data - Pointer to validation data structure 362 * PARAMETERS: info - Method execution information block
363 * expected_btypes - Object types expected 363 * expected_btypes - Object types expected
364 * package_index - Index of object within parent package (if 364 * package_index - Index of object within parent package (if
365 * applicable - ACPI_NOT_PACKAGE_ELEMENT 365 * applicable - ACPI_NOT_PACKAGE_ELEMENT
@@ -374,7 +374,7 @@ static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct
374 ******************************************************************************/ 374 ******************************************************************************/
375 375
376acpi_status 376acpi_status
377acpi_ns_repair_null_element(struct acpi_predefined_data *data, 377acpi_ns_repair_null_element(struct acpi_evaluate_info * info,
378 u32 expected_btypes, 378 u32 expected_btypes,
379 u32 package_index, 379 u32 package_index,
380 union acpi_operand_object **return_object_ptr) 380 union acpi_operand_object **return_object_ptr)
@@ -424,16 +424,16 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data,
424 /* Set the reference count according to the parent Package object */ 424 /* Set the reference count according to the parent Package object */
425 425
426 new_object->common.reference_count = 426 new_object->common.reference_count =
427 data->parent_package->common.reference_count; 427 info->parent_package->common.reference_count;
428 428
429 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 429 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
430 "%s: Converted NULL package element to expected %s at index %u\n", 430 "%s: Converted NULL package element to expected %s at index %u\n",
431 data->pathname, 431 info->full_pathname,
432 acpi_ut_get_object_type_name(new_object), 432 acpi_ut_get_object_type_name(new_object),
433 package_index)); 433 package_index));
434 434
435 *return_object_ptr = new_object; 435 *return_object_ptr = new_object;
436 data->flags |= ACPI_OBJECT_REPAIRED; 436 info->return_flags |= ACPI_OBJECT_REPAIRED;
437 return (AE_OK); 437 return (AE_OK);
438} 438}
439 439
@@ -441,7 +441,7 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data,
441 * 441 *
442 * FUNCTION: acpi_ns_remove_null_elements 442 * FUNCTION: acpi_ns_remove_null_elements
443 * 443 *
444 * PARAMETERS: data - Pointer to validation data structure 444 * PARAMETERS: info - Method execution information block
445 * package_type - An acpi_return_package_types value 445 * package_type - An acpi_return_package_types value
446 * obj_desc - A Package object 446 * obj_desc - A Package object
447 * 447 *
@@ -454,7 +454,7 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data,
454 *****************************************************************************/ 454 *****************************************************************************/
455 455
456void 456void
457acpi_ns_remove_null_elements(struct acpi_predefined_data *data, 457acpi_ns_remove_null_elements(struct acpi_evaluate_info *info,
458 u8 package_type, 458 u8 package_type,
459 union acpi_operand_object *obj_desc) 459 union acpi_operand_object *obj_desc)
460{ 460{
@@ -480,6 +480,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
480 case ACPI_PTYPE2_MIN: 480 case ACPI_PTYPE2_MIN:
481 case ACPI_PTYPE2_REV_FIXED: 481 case ACPI_PTYPE2_REV_FIXED:
482 case ACPI_PTYPE2_FIX_VAR: 482 case ACPI_PTYPE2_FIX_VAR:
483
483 break; 484 break;
484 485
485 default: 486 default:
@@ -511,7 +512,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
511 if (new_count < count) { 512 if (new_count < count) {
512 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 513 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
513 "%s: Found and removed %u NULL elements\n", 514 "%s: Found and removed %u NULL elements\n",
514 data->pathname, (count - new_count))); 515 info->full_pathname, (count - new_count)));
515 516
516 /* NULL terminate list and update the package count */ 517 /* NULL terminate list and update the package count */
517 518
@@ -524,7 +525,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
524 * 525 *
525 * FUNCTION: acpi_ns_wrap_with_package 526 * FUNCTION: acpi_ns_wrap_with_package
526 * 527 *
527 * PARAMETERS: data - Pointer to validation data structure 528 * PARAMETERS: info - Method execution information block
528 * original_object - Pointer to the object to repair. 529 * original_object - Pointer to the object to repair.
529 * obj_desc_ptr - The new package object is returned here 530 * obj_desc_ptr - The new package object is returned here
530 * 531 *
@@ -545,7 +546,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
545 ******************************************************************************/ 546 ******************************************************************************/
546 547
547acpi_status 548acpi_status
548acpi_ns_wrap_with_package(struct acpi_predefined_data *data, 549acpi_ns_wrap_with_package(struct acpi_evaluate_info *info,
549 union acpi_operand_object *original_object, 550 union acpi_operand_object *original_object,
550 union acpi_operand_object **obj_desc_ptr) 551 union acpi_operand_object **obj_desc_ptr)
551{ 552{
@@ -566,12 +567,12 @@ acpi_ns_wrap_with_package(struct acpi_predefined_data *data,
566 567
567 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 568 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
568 "%s: Wrapped %s with expected Package object\n", 569 "%s: Wrapped %s with expected Package object\n",
569 data->pathname, 570 info->full_pathname,
570 acpi_ut_get_object_type_name(original_object))); 571 acpi_ut_get_object_type_name(original_object)));
571 572
572 /* Return the new object in the object pointer */ 573 /* Return the new object in the object pointer */
573 574
574 *obj_desc_ptr = pkg_obj_desc; 575 *obj_desc_ptr = pkg_obj_desc;
575 data->flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED; 576 info->return_flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
576 return (AE_OK); 577 return (AE_OK);
577} 578}
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 149e9b9c2c1b..c84603ee83ae 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -54,7 +54,7 @@ ACPI_MODULE_NAME("nsrepair2")
54 * be repaired on a per-name basis. 54 * be repaired on a per-name basis.
55 */ 55 */
56typedef 56typedef
57acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data, 57acpi_status(*acpi_repair_function) (struct acpi_evaluate_info * info,
58 union acpi_operand_object 58 union acpi_operand_object
59 **return_object_ptr); 59 **return_object_ptr);
60 60
@@ -71,45 +71,57 @@ static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct
71 *node); 71 *node);
72 72
73static acpi_status 73static acpi_status
74acpi_ns_repair_ALR(struct acpi_predefined_data *data, 74acpi_ns_repair_ALR(struct acpi_evaluate_info *info,
75 union acpi_operand_object **return_object_ptr); 75 union acpi_operand_object **return_object_ptr);
76 76
77static acpi_status 77static acpi_status
78acpi_ns_repair_CID(struct acpi_predefined_data *data, 78acpi_ns_repair_CID(struct acpi_evaluate_info *info,
79 union acpi_operand_object **return_object_ptr); 79 union acpi_operand_object **return_object_ptr);
80 80
81static acpi_status 81static acpi_status
82acpi_ns_repair_FDE(struct acpi_predefined_data *data, 82acpi_ns_repair_CST(struct acpi_evaluate_info *info,
83 union acpi_operand_object **return_object_ptr); 83 union acpi_operand_object **return_object_ptr);
84 84
85static acpi_status 85static acpi_status
86acpi_ns_repair_HID(struct acpi_predefined_data *data, 86acpi_ns_repair_FDE(struct acpi_evaluate_info *info,
87 union acpi_operand_object **return_object_ptr); 87 union acpi_operand_object **return_object_ptr);
88 88
89static acpi_status 89static acpi_status
90acpi_ns_repair_PSS(struct acpi_predefined_data *data, 90acpi_ns_repair_HID(struct acpi_evaluate_info *info,
91 union acpi_operand_object **return_object_ptr); 91 union acpi_operand_object **return_object_ptr);
92 92
93static acpi_status 93static acpi_status
94acpi_ns_repair_TSS(struct acpi_predefined_data *data, 94acpi_ns_repair_PRT(struct acpi_evaluate_info *info,
95 union acpi_operand_object **return_object_ptr); 95 union acpi_operand_object **return_object_ptr);
96 96
97static acpi_status 97static acpi_status
98acpi_ns_check_sorted_list(struct acpi_predefined_data *data, 98acpi_ns_repair_PSS(struct acpi_evaluate_info *info,
99 union acpi_operand_object **return_object_ptr);
100
101static acpi_status
102acpi_ns_repair_TSS(struct acpi_evaluate_info *info,
103 union acpi_operand_object **return_object_ptr);
104
105static acpi_status
106acpi_ns_check_sorted_list(struct acpi_evaluate_info *info,
99 union acpi_operand_object *return_object, 107 union acpi_operand_object *return_object,
108 u32 start_index,
100 u32 expected_count, 109 u32 expected_count,
101 u32 sort_index, 110 u32 sort_index,
102 u8 sort_direction, char *sort_key_name); 111 u8 sort_direction, char *sort_key_name);
103 112
104static void
105acpi_ns_sort_list(union acpi_operand_object **elements,
106 u32 count, u32 index, u8 sort_direction);
107
108/* Values for sort_direction above */ 113/* Values for sort_direction above */
109 114
110#define ACPI_SORT_ASCENDING 0 115#define ACPI_SORT_ASCENDING 0
111#define ACPI_SORT_DESCENDING 1 116#define ACPI_SORT_DESCENDING 1
112 117
118static void
119acpi_ns_remove_element(union acpi_operand_object *obj_desc, u32 index);
120
121static void
122acpi_ns_sort_list(union acpi_operand_object **elements,
123 u32 count, u32 index, u8 sort_direction);
124
113/* 125/*
114 * This table contains the names of the predefined methods for which we can 126 * This table contains the names of the predefined methods for which we can
115 * perform more complex repairs. 127 * perform more complex repairs.
@@ -118,9 +130,11 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
118 * 130 *
119 * _ALR: Sort the list ascending by ambient_illuminance 131 * _ALR: Sort the list ascending by ambient_illuminance
120 * _CID: Strings: uppercase all, remove any leading asterisk 132 * _CID: Strings: uppercase all, remove any leading asterisk
133 * _CST: Sort the list ascending by C state type
121 * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs 134 * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs
122 * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs 135 * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
123 * _HID: Strings: uppercase all, remove any leading asterisk 136 * _HID: Strings: uppercase all, remove any leading asterisk
137 * _PRT: Fix reversed source_name and source_index
124 * _PSS: Sort the list descending by Power 138 * _PSS: Sort the list descending by Power
125 * _TSS: Sort the list descending by Power 139 * _TSS: Sort the list descending by Power
126 * 140 *
@@ -134,9 +148,11 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
134static const struct acpi_repair_info acpi_ns_repairable_names[] = { 148static const struct acpi_repair_info acpi_ns_repairable_names[] = {
135 {"_ALR", acpi_ns_repair_ALR}, 149 {"_ALR", acpi_ns_repair_ALR},
136 {"_CID", acpi_ns_repair_CID}, 150 {"_CID", acpi_ns_repair_CID},
151 {"_CST", acpi_ns_repair_CST},
137 {"_FDE", acpi_ns_repair_FDE}, 152 {"_FDE", acpi_ns_repair_FDE},
138 {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */ 153 {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */
139 {"_HID", acpi_ns_repair_HID}, 154 {"_HID", acpi_ns_repair_HID},
155 {"_PRT", acpi_ns_repair_PRT},
140 {"_PSS", acpi_ns_repair_PSS}, 156 {"_PSS", acpi_ns_repair_PSS},
141 {"_TSS", acpi_ns_repair_TSS}, 157 {"_TSS", acpi_ns_repair_TSS},
142 {{0, 0, 0, 0}, NULL} /* Table terminator */ 158 {{0, 0, 0, 0}, NULL} /* Table terminator */
@@ -150,7 +166,7 @@ static const struct acpi_repair_info acpi_ns_repairable_names[] = {
150 * 166 *
151 * FUNCTION: acpi_ns_complex_repairs 167 * FUNCTION: acpi_ns_complex_repairs
152 * 168 *
153 * PARAMETERS: data - Pointer to validation data structure 169 * PARAMETERS: info - Method execution information block
154 * node - Namespace node for the method/object 170 * node - Namespace node for the method/object
155 * validate_status - Original status of earlier validation 171 * validate_status - Original status of earlier validation
156 * return_object_ptr - Pointer to the object returned from the 172 * return_object_ptr - Pointer to the object returned from the
@@ -165,7 +181,7 @@ static const struct acpi_repair_info acpi_ns_repairable_names[] = {
165 *****************************************************************************/ 181 *****************************************************************************/
166 182
167acpi_status 183acpi_status
168acpi_ns_complex_repairs(struct acpi_predefined_data *data, 184acpi_ns_complex_repairs(struct acpi_evaluate_info *info,
169 struct acpi_namespace_node *node, 185 struct acpi_namespace_node *node,
170 acpi_status validate_status, 186 acpi_status validate_status,
171 union acpi_operand_object **return_object_ptr) 187 union acpi_operand_object **return_object_ptr)
@@ -180,7 +196,7 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
180 return (validate_status); 196 return (validate_status);
181 } 197 }
182 198
183 status = predefined->repair_function(data, return_object_ptr); 199 status = predefined->repair_function(info, return_object_ptr);
184 return (status); 200 return (status);
185} 201}
186 202
@@ -219,7 +235,7 @@ static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct
219 * 235 *
220 * FUNCTION: acpi_ns_repair_ALR 236 * FUNCTION: acpi_ns_repair_ALR
221 * 237 *
222 * PARAMETERS: data - Pointer to validation data structure 238 * PARAMETERS: info - Method execution information block
223 * return_object_ptr - Pointer to the object returned from the 239 * return_object_ptr - Pointer to the object returned from the
224 * evaluation of a method or object 240 * evaluation of a method or object
225 * 241 *
@@ -231,13 +247,13 @@ static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct
231 *****************************************************************************/ 247 *****************************************************************************/
232 248
233static acpi_status 249static acpi_status
234acpi_ns_repair_ALR(struct acpi_predefined_data *data, 250acpi_ns_repair_ALR(struct acpi_evaluate_info *info,
235 union acpi_operand_object **return_object_ptr) 251 union acpi_operand_object **return_object_ptr)
236{ 252{
237 union acpi_operand_object *return_object = *return_object_ptr; 253 union acpi_operand_object *return_object = *return_object_ptr;
238 acpi_status status; 254 acpi_status status;
239 255
240 status = acpi_ns_check_sorted_list(data, return_object, 2, 1, 256 status = acpi_ns_check_sorted_list(info, return_object, 0, 2, 1,
241 ACPI_SORT_ASCENDING, 257 ACPI_SORT_ASCENDING,
242 "AmbientIlluminance"); 258 "AmbientIlluminance");
243 259
@@ -248,7 +264,7 @@ acpi_ns_repair_ALR(struct acpi_predefined_data *data,
248 * 264 *
249 * FUNCTION: acpi_ns_repair_FDE 265 * FUNCTION: acpi_ns_repair_FDE
250 * 266 *
251 * PARAMETERS: data - Pointer to validation data structure 267 * PARAMETERS: info - Method execution information block
252 * return_object_ptr - Pointer to the object returned from the 268 * return_object_ptr - Pointer to the object returned from the
253 * evaluation of a method or object 269 * evaluation of a method or object
254 * 270 *
@@ -262,7 +278,7 @@ acpi_ns_repair_ALR(struct acpi_predefined_data *data,
262 *****************************************************************************/ 278 *****************************************************************************/
263 279
264static acpi_status 280static acpi_status
265acpi_ns_repair_FDE(struct acpi_predefined_data *data, 281acpi_ns_repair_FDE(struct acpi_evaluate_info *info,
266 union acpi_operand_object **return_object_ptr) 282 union acpi_operand_object **return_object_ptr)
267{ 283{
268 union acpi_operand_object *return_object = *return_object_ptr; 284 union acpi_operand_object *return_object = *return_object_ptr;
@@ -285,8 +301,8 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data,
285 /* We can only repair if we have exactly 5 BYTEs */ 301 /* We can only repair if we have exactly 5 BYTEs */
286 302
287 if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) { 303 if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) {
288 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, 304 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
289 data->node_flags, 305 info->node_flags,
290 "Incorrect return buffer length %u, expected %u", 306 "Incorrect return buffer length %u, expected %u",
291 return_object->buffer.length, 307 return_object->buffer.length,
292 ACPI_FDE_DWORD_BUFFER_SIZE)); 308 ACPI_FDE_DWORD_BUFFER_SIZE));
@@ -316,10 +332,11 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data,
316 332
317 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 333 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
318 "%s Expanded Byte Buffer to expected DWord Buffer\n", 334 "%s Expanded Byte Buffer to expected DWord Buffer\n",
319 data->pathname)); 335 info->full_pathname));
320 break; 336 break;
321 337
322 default: 338 default:
339
323 return (AE_AML_OPERAND_TYPE); 340 return (AE_AML_OPERAND_TYPE);
324 } 341 }
325 342
@@ -328,7 +345,7 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data,
328 acpi_ut_remove_reference(return_object); 345 acpi_ut_remove_reference(return_object);
329 *return_object_ptr = buffer_object; 346 *return_object_ptr = buffer_object;
330 347
331 data->flags |= ACPI_OBJECT_REPAIRED; 348 info->return_flags |= ACPI_OBJECT_REPAIRED;
332 return (AE_OK); 349 return (AE_OK);
333} 350}
334 351
@@ -336,7 +353,7 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data,
336 * 353 *
337 * FUNCTION: acpi_ns_repair_CID 354 * FUNCTION: acpi_ns_repair_CID
338 * 355 *
339 * PARAMETERS: data - Pointer to validation data structure 356 * PARAMETERS: info - Method execution information block
340 * return_object_ptr - Pointer to the object returned from the 357 * return_object_ptr - Pointer to the object returned from the
341 * evaluation of a method or object 358 * evaluation of a method or object
342 * 359 *
@@ -349,7 +366,7 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data,
349 *****************************************************************************/ 366 *****************************************************************************/
350 367
351static acpi_status 368static acpi_status
352acpi_ns_repair_CID(struct acpi_predefined_data *data, 369acpi_ns_repair_CID(struct acpi_evaluate_info *info,
353 union acpi_operand_object **return_object_ptr) 370 union acpi_operand_object **return_object_ptr)
354{ 371{
355 acpi_status status; 372 acpi_status status;
@@ -362,7 +379,7 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data,
362 /* Check for _CID as a simple string */ 379 /* Check for _CID as a simple string */
363 380
364 if (return_object->common.type == ACPI_TYPE_STRING) { 381 if (return_object->common.type == ACPI_TYPE_STRING) {
365 status = acpi_ns_repair_HID(data, return_object_ptr); 382 status = acpi_ns_repair_HID(info, return_object_ptr);
366 return (status); 383 return (status);
367 } 384 }
368 385
@@ -379,7 +396,7 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data,
379 original_element = *element_ptr; 396 original_element = *element_ptr;
380 original_ref_count = original_element->common.reference_count; 397 original_ref_count = original_element->common.reference_count;
381 398
382 status = acpi_ns_repair_HID(data, element_ptr); 399 status = acpi_ns_repair_HID(info, element_ptr);
383 if (ACPI_FAILURE(status)) { 400 if (ACPI_FAILURE(status)) {
384 return (status); 401 return (status);
385 } 402 }
@@ -404,9 +421,95 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data,
404 421
405/****************************************************************************** 422/******************************************************************************
406 * 423 *
424 * FUNCTION: acpi_ns_repair_CST
425 *
426 * PARAMETERS: info - Method execution information block
427 * return_object_ptr - Pointer to the object returned from the
428 * evaluation of a method or object
429 *
430 * RETURN: Status. AE_OK if object is OK or was repaired successfully
431 *
432 * DESCRIPTION: Repair for the _CST object:
433 * 1. Sort the list ascending by C state type
434 * 2. Ensure type cannot be zero
435 * 3. A sub-package count of zero means _CST is meaningless
436 * 4. Count must match the number of C state sub-packages
437 *
438 *****************************************************************************/
439
440static acpi_status
441acpi_ns_repair_CST(struct acpi_evaluate_info *info,
442 union acpi_operand_object **return_object_ptr)
443{
444 union acpi_operand_object *return_object = *return_object_ptr;
445 union acpi_operand_object **outer_elements;
446 u32 outer_element_count;
447 union acpi_operand_object *obj_desc;
448 acpi_status status;
449 u8 removing;
450 u32 i;
451
452 ACPI_FUNCTION_NAME(ns_repair_CST);
453
454 /*
455 * Check if the C-state type values are proportional.
456 */
457 outer_element_count = return_object->package.count - 1;
458 i = 0;
459 while (i < outer_element_count) {
460 outer_elements = &return_object->package.elements[i + 1];
461 removing = FALSE;
462
463 if ((*outer_elements)->package.count == 0) {
464 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
465 info->node_flags,
466 "SubPackage[%u] - removing entry due to zero count",
467 i));
468 removing = TRUE;
469 goto remove_element;
470 }
471
472 obj_desc = (*outer_elements)->package.elements[1]; /* Index1 = Type */
473 if ((u32)obj_desc->integer.value == 0) {
474 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
475 info->node_flags,
476 "SubPackage[%u] - removing entry due to invalid Type(0)",
477 i));
478 removing = TRUE;
479 }
480
481 remove_element:
482 if (removing) {
483 acpi_ns_remove_element(return_object, i + 1);
484 outer_element_count--;
485 } else {
486 i++;
487 }
488 }
489
490 /* Update top-level package count, Type "Integer" checked elsewhere */
491
492 obj_desc = return_object->package.elements[0];
493 obj_desc->integer.value = outer_element_count;
494
495 /*
496 * Entries (subpackages) in the _CST Package must be sorted by the
497 * C-state type, in ascending order.
498 */
499 status = acpi_ns_check_sorted_list(info, return_object, 1, 4, 1,
500 ACPI_SORT_ASCENDING, "C-State Type");
501 if (ACPI_FAILURE(status)) {
502 return (status);
503 }
504
505 return (AE_OK);
506}
507
508/******************************************************************************
509 *
407 * FUNCTION: acpi_ns_repair_HID 510 * FUNCTION: acpi_ns_repair_HID
408 * 511 *
409 * PARAMETERS: data - Pointer to validation data structure 512 * PARAMETERS: info - Method execution information block
410 * return_object_ptr - Pointer to the object returned from the 513 * return_object_ptr - Pointer to the object returned from the
411 * evaluation of a method or object 514 * evaluation of a method or object
412 * 515 *
@@ -418,7 +521,7 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data,
418 *****************************************************************************/ 521 *****************************************************************************/
419 522
420static acpi_status 523static acpi_status
421acpi_ns_repair_HID(struct acpi_predefined_data *data, 524acpi_ns_repair_HID(struct acpi_evaluate_info *info,
422 union acpi_operand_object **return_object_ptr) 525 union acpi_operand_object **return_object_ptr)
423{ 526{
424 union acpi_operand_object *return_object = *return_object_ptr; 527 union acpi_operand_object *return_object = *return_object_ptr;
@@ -435,12 +538,13 @@ acpi_ns_repair_HID(struct acpi_predefined_data *data,
435 } 538 }
436 539
437 if (return_object->string.length == 0) { 540 if (return_object->string.length == 0) {
438 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 541 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
542 info->node_flags,
439 "Invalid zero-length _HID or _CID string")); 543 "Invalid zero-length _HID or _CID string"));
440 544
441 /* Return AE_OK anyway, let driver handle it */ 545 /* Return AE_OK anyway, let driver handle it */
442 546
443 data->flags |= ACPI_OBJECT_REPAIRED; 547 info->return_flags |= ACPI_OBJECT_REPAIRED;
444 return (AE_OK); 548 return (AE_OK);
445 } 549 }
446 550
@@ -464,7 +568,7 @@ acpi_ns_repair_HID(struct acpi_predefined_data *data,
464 568
465 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 569 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
466 "%s: Removed invalid leading asterisk\n", 570 "%s: Removed invalid leading asterisk\n",
467 data->pathname)); 571 info->full_pathname));
468 } 572 }
469 573
470 /* 574 /*
@@ -486,53 +590,69 @@ acpi_ns_repair_HID(struct acpi_predefined_data *data,
486 590
487/****************************************************************************** 591/******************************************************************************
488 * 592 *
489 * FUNCTION: acpi_ns_repair_TSS 593 * FUNCTION: acpi_ns_repair_PRT
490 * 594 *
491 * PARAMETERS: data - Pointer to validation data structure 595 * PARAMETERS: info - Method execution information block
492 * return_object_ptr - Pointer to the object returned from the 596 * return_object_ptr - Pointer to the object returned from the
493 * evaluation of a method or object 597 * evaluation of a method or object
494 * 598 *
495 * RETURN: Status. AE_OK if object is OK or was repaired successfully 599 * RETURN: Status. AE_OK if object is OK or was repaired successfully
496 * 600 *
497 * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list 601 * DESCRIPTION: Repair for the _PRT object. If necessary, fix reversed
498 * descending by the power dissipation values. 602 * source_name and source_index field, a common BIOS bug.
499 * 603 *
500 *****************************************************************************/ 604 *****************************************************************************/
501 605
502static acpi_status 606static acpi_status
503acpi_ns_repair_TSS(struct acpi_predefined_data *data, 607acpi_ns_repair_PRT(struct acpi_evaluate_info *info,
504 union acpi_operand_object **return_object_ptr) 608 union acpi_operand_object **return_object_ptr)
505{ 609{
506 union acpi_operand_object *return_object = *return_object_ptr; 610 union acpi_operand_object *package_object = *return_object_ptr;
507 acpi_status status; 611 union acpi_operand_object **top_object_list;
508 struct acpi_namespace_node *node; 612 union acpi_operand_object **sub_object_list;
613 union acpi_operand_object *obj_desc;
614 u32 element_count;
615 u32 index;
509 616
510 /* 617 /* Each element in the _PRT package is a subpackage */
511 * We can only sort the _TSS return package if there is no _PSS in the
512 * same scope. This is because if _PSS is present, the ACPI specification
513 * dictates that the _TSS Power Dissipation field is to be ignored, and
514 * therefore some BIOSs leave garbage values in the _TSS Power field(s).
515 * In this case, it is best to just return the _TSS package as-is.
516 * (May, 2011)
517 */
518 status =
519 acpi_ns_get_node(data->node, "^_PSS", ACPI_NS_NO_UPSEARCH, &node);
520 if (ACPI_SUCCESS(status)) {
521 return (AE_OK);
522 }
523 618
524 status = acpi_ns_check_sorted_list(data, return_object, 5, 1, 619 top_object_list = package_object->package.elements;
525 ACPI_SORT_DESCENDING, 620 element_count = package_object->package.count;
526 "PowerDissipation");
527 621
528 return (status); 622 for (index = 0; index < element_count; index++) {
623 sub_object_list = (*top_object_list)->package.elements;
624
625 /*
626 * If the BIOS has erroneously reversed the _PRT source_name (index 2)
627 * and the source_index (index 3), fix it. _PRT is important enough to
628 * workaround this BIOS error. This also provides compatibility with
629 * other ACPI implementations.
630 */
631 obj_desc = sub_object_list[3];
632 if (!obj_desc || (obj_desc->common.type != ACPI_TYPE_INTEGER)) {
633 sub_object_list[3] = sub_object_list[2];
634 sub_object_list[2] = obj_desc;
635 info->return_flags |= ACPI_OBJECT_REPAIRED;
636
637 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
638 info->node_flags,
639 "PRT[%X]: Fixed reversed SourceName and SourceIndex",
640 index));
641 }
642
643 /* Point to the next union acpi_operand_object in the top level package */
644
645 top_object_list++;
646 }
647
648 return (AE_OK);
529} 649}
530 650
531/****************************************************************************** 651/******************************************************************************
532 * 652 *
533 * FUNCTION: acpi_ns_repair_PSS 653 * FUNCTION: acpi_ns_repair_PSS
534 * 654 *
535 * PARAMETERS: data - Pointer to validation data structure 655 * PARAMETERS: info - Method execution information block
536 * return_object_ptr - Pointer to the object returned from the 656 * return_object_ptr - Pointer to the object returned from the
537 * evaluation of a method or object 657 * evaluation of a method or object
538 * 658 *
@@ -546,7 +666,7 @@ acpi_ns_repair_TSS(struct acpi_predefined_data *data,
546 *****************************************************************************/ 666 *****************************************************************************/
547 667
548static acpi_status 668static acpi_status
549acpi_ns_repair_PSS(struct acpi_predefined_data *data, 669acpi_ns_repair_PSS(struct acpi_evaluate_info *info,
550 union acpi_operand_object **return_object_ptr) 670 union acpi_operand_object **return_object_ptr)
551{ 671{
552 union acpi_operand_object *return_object = *return_object_ptr; 672 union acpi_operand_object *return_object = *return_object_ptr;
@@ -564,7 +684,7 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data,
564 * incorrectly sorted, sort it. We sort by cpu_frequency, since this 684 * incorrectly sorted, sort it. We sort by cpu_frequency, since this
565 * should be proportional to the power. 685 * should be proportional to the power.
566 */ 686 */
567 status = acpi_ns_check_sorted_list(data, return_object, 6, 0, 687 status = acpi_ns_check_sorted_list(info, return_object, 0, 6, 0,
568 ACPI_SORT_DESCENDING, 688 ACPI_SORT_DESCENDING,
569 "CpuFrequency"); 689 "CpuFrequency");
570 if (ACPI_FAILURE(status)) { 690 if (ACPI_FAILURE(status)) {
@@ -584,8 +704,8 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data,
584 obj_desc = elements[1]; /* Index1 = power_dissipation */ 704 obj_desc = elements[1]; /* Index1 = power_dissipation */
585 705
586 if ((u32) obj_desc->integer.value > previous_value) { 706 if ((u32) obj_desc->integer.value > previous_value) {
587 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, 707 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
588 data->node_flags, 708 info->node_flags,
589 "SubPackage[%u,%u] - suspicious power dissipation values", 709 "SubPackage[%u,%u] - suspicious power dissipation values",
590 i - 1, i)); 710 i - 1, i));
591 } 711 }
@@ -599,10 +719,55 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data,
599 719
600/****************************************************************************** 720/******************************************************************************
601 * 721 *
722 * FUNCTION: acpi_ns_repair_TSS
723 *
724 * PARAMETERS: info - Method execution information block
725 * return_object_ptr - Pointer to the object returned from the
726 * evaluation of a method or object
727 *
728 * RETURN: Status. AE_OK if object is OK or was repaired successfully
729 *
730 * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list
731 * descending by the power dissipation values.
732 *
733 *****************************************************************************/
734
735static acpi_status
736acpi_ns_repair_TSS(struct acpi_evaluate_info *info,
737 union acpi_operand_object **return_object_ptr)
738{
739 union acpi_operand_object *return_object = *return_object_ptr;
740 acpi_status status;
741 struct acpi_namespace_node *node;
742
743 /*
744 * We can only sort the _TSS return package if there is no _PSS in the
745 * same scope. This is because if _PSS is present, the ACPI specification
746 * dictates that the _TSS Power Dissipation field is to be ignored, and
747 * therefore some BIOSs leave garbage values in the _TSS Power field(s).
748 * In this case, it is best to just return the _TSS package as-is.
749 * (May, 2011)
750 */
751 status = acpi_ns_get_node(info->node, "^_PSS",
752 ACPI_NS_NO_UPSEARCH, &node);
753 if (ACPI_SUCCESS(status)) {
754 return (AE_OK);
755 }
756
757 status = acpi_ns_check_sorted_list(info, return_object, 0, 5, 1,
758 ACPI_SORT_DESCENDING,
759 "PowerDissipation");
760
761 return (status);
762}
763
764/******************************************************************************
765 *
602 * FUNCTION: acpi_ns_check_sorted_list 766 * FUNCTION: acpi_ns_check_sorted_list
603 * 767 *
604 * PARAMETERS: data - Pointer to validation data structure 768 * PARAMETERS: info - Method execution information block
605 * return_object - Pointer to the top-level returned object 769 * return_object - Pointer to the top-level returned object
770 * start_index - Index of the first sub-package
606 * expected_count - Minimum length of each sub-package 771 * expected_count - Minimum length of each sub-package
607 * sort_index - Sub-package entry to sort on 772 * sort_index - Sub-package entry to sort on
608 * sort_direction - Ascending or descending 773 * sort_direction - Ascending or descending
@@ -617,8 +782,9 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data,
617 *****************************************************************************/ 782 *****************************************************************************/
618 783
619static acpi_status 784static acpi_status
620acpi_ns_check_sorted_list(struct acpi_predefined_data *data, 785acpi_ns_check_sorted_list(struct acpi_evaluate_info *info,
621 union acpi_operand_object *return_object, 786 union acpi_operand_object *return_object,
787 u32 start_index,
622 u32 expected_count, 788 u32 expected_count,
623 u32 sort_index, 789 u32 sort_index,
624 u8 sort_direction, char *sort_key_name) 790 u8 sort_direction, char *sort_key_name)
@@ -643,12 +809,14 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
643 * Any NULL elements should have been removed by earlier call 809 * Any NULL elements should have been removed by earlier call
644 * to acpi_ns_remove_null_elements. 810 * to acpi_ns_remove_null_elements.
645 */ 811 */
646 outer_elements = return_object->package.elements;
647 outer_element_count = return_object->package.count; 812 outer_element_count = return_object->package.count;
648 if (!outer_element_count) { 813 if (!outer_element_count || start_index >= outer_element_count) {
649 return (AE_AML_PACKAGE_LIMIT); 814 return (AE_AML_PACKAGE_LIMIT);
650 } 815 }
651 816
817 outer_elements = &return_object->package.elements[start_index];
818 outer_element_count -= start_index;
819
652 previous_value = 0; 820 previous_value = 0;
653 if (sort_direction == ACPI_SORT_DESCENDING) { 821 if (sort_direction == ACPI_SORT_DESCENDING) {
654 previous_value = ACPI_UINT32_MAX; 822 previous_value = ACPI_UINT32_MAX;
@@ -685,15 +853,16 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
685 (obj_desc->integer.value < previous_value)) || 853 (obj_desc->integer.value < previous_value)) ||
686 ((sort_direction == ACPI_SORT_DESCENDING) && 854 ((sort_direction == ACPI_SORT_DESCENDING) &&
687 (obj_desc->integer.value > previous_value))) { 855 (obj_desc->integer.value > previous_value))) {
688 acpi_ns_sort_list(return_object->package.elements, 856 acpi_ns_sort_list(&return_object->package.
857 elements[start_index],
689 outer_element_count, sort_index, 858 outer_element_count, sort_index,
690 sort_direction); 859 sort_direction);
691 860
692 data->flags |= ACPI_OBJECT_REPAIRED; 861 info->return_flags |= ACPI_OBJECT_REPAIRED;
693 862
694 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 863 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
695 "%s: Repaired unsorted list - now sorted by %s\n", 864 "%s: Repaired unsorted list - now sorted by %s\n",
696 data->pathname, sort_key_name)); 865 info->full_pathname, sort_key_name));
697 return (AE_OK); 866 return (AE_OK);
698 } 867 }
699 868
@@ -752,3 +921,52 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
752 } 921 }
753 } 922 }
754} 923}
924
925/******************************************************************************
926 *
927 * FUNCTION: acpi_ns_remove_element
928 *
929 * PARAMETERS: obj_desc - Package object element list
930 * index - Index of element to remove
931 *
932 * RETURN: None
933 *
934 * DESCRIPTION: Remove the requested element of a package and delete it.
935 *
936 *****************************************************************************/
937
938static void
939acpi_ns_remove_element(union acpi_operand_object *obj_desc, u32 index)
940{
941 union acpi_operand_object **source;
942 union acpi_operand_object **dest;
943 u32 count;
944 u32 new_count;
945 u32 i;
946
947 ACPI_FUNCTION_NAME(ns_remove_element);
948
949 count = obj_desc->package.count;
950 new_count = count - 1;
951
952 source = obj_desc->package.elements;
953 dest = source;
954
955 /* Examine all elements of the package object, remove matched index */
956
957 for (i = 0; i < count; i++) {
958 if (i == index) {
959 acpi_ut_remove_reference(*source); /* Remove one ref for being in pkg */
960 acpi_ut_remove_reference(*source);
961 } else {
962 *dest = *source;
963 dest++;
964 }
965 source++;
966 }
967
968 /* NULL terminate list and update the package count */
969
970 *dest = NULL;
971 obj_desc->package.count = new_count;
972}
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index 2808586fad30..08c0b5beec88 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -419,10 +419,12 @@ acpi_ns_externalize_name(u32 internal_name_length,
419 419
420 switch (internal_name[0]) { 420 switch (internal_name[0]) {
421 case AML_ROOT_PREFIX: 421 case AML_ROOT_PREFIX:
422
422 prefix_length = 1; 423 prefix_length = 1;
423 break; 424 break;
424 425
425 case AML_PARENT_PREFIX: 426 case AML_PARENT_PREFIX:
427
426 for (i = 0; i < internal_name_length; i++) { 428 for (i = 0; i < internal_name_length; i++) {
427 if (ACPI_IS_PARENT_PREFIX(internal_name[i])) { 429 if (ACPI_IS_PARENT_PREFIX(internal_name[i])) {
428 prefix_length = i + 1; 430 prefix_length = i + 1;
@@ -438,6 +440,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
438 break; 440 break;
439 441
440 default: 442 default:
443
441 break; 444 break;
442 } 445 }
443 446
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index fc69949151bb..f553cfdb71dd 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -187,8 +187,6 @@ acpi_evaluate_object(acpi_handle handle,
187 return_ACPI_STATUS(AE_NO_MEMORY); 187 return_ACPI_STATUS(AE_NO_MEMORY);
188 } 188 }
189 189
190 info->pathname = pathname;
191
192 /* Convert and validate the device handle */ 190 /* Convert and validate the device handle */
193 191
194 info->prefix_node = acpi_ns_validate_handle(handle); 192 info->prefix_node = acpi_ns_validate_handle(handle);
@@ -198,17 +196,64 @@ acpi_evaluate_object(acpi_handle handle,
198 } 196 }
199 197
200 /* 198 /*
201 * If there are parameters to be passed to a control method, the external 199 * Get the actual namespace node for the target object.
202 * objects must all be converted to internal objects 200 * Handles these cases:
201 *
202 * 1) Null node, valid pathname from root (absolute path)
203 * 2) Node and valid pathname (path relative to Node)
204 * 3) Node, Null pathname
205 */
206 if ((pathname) && (ACPI_IS_ROOT_PREFIX(pathname[0]))) {
207
208 /* The path is fully qualified, just evaluate by name */
209
210 info->prefix_node = NULL;
211 } else if (!handle) {
212 /*
213 * A handle is optional iff a fully qualified pathname is specified.
214 * Since we've already handled fully qualified names above, this is
215 * an error.
216 */
217 if (!pathname) {
218 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
219 "Both Handle and Pathname are NULL"));
220 } else {
221 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
222 "Null Handle with relative pathname [%s]",
223 pathname));
224 }
225
226 status = AE_BAD_PARAMETER;
227 goto cleanup;
228 }
229
230 info->relative_pathname = pathname;
231
232 /*
233 * Convert all external objects passed as arguments to the
234 * internal version(s).
203 */ 235 */
204 if (external_params && external_params->count) { 236 if (external_params && external_params->count) {
237 info->param_count = (u16)external_params->count;
238
239 /* Warn on impossible argument count */
240
241 if (info->param_count > ACPI_METHOD_NUM_ARGS) {
242 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
243 ACPI_WARN_ALWAYS,
244 "Excess arguments (%u) - using only %u",
245 info->param_count,
246 ACPI_METHOD_NUM_ARGS));
247
248 info->param_count = ACPI_METHOD_NUM_ARGS;
249 }
250
205 /* 251 /*
206 * Allocate a new parameter block for the internal objects 252 * Allocate a new parameter block for the internal objects
207 * Add 1 to count to allow for null terminated internal list 253 * Add 1 to count to allow for null terminated internal list
208 */ 254 */
209 info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size) 255 info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size) info->
210 external_params-> 256 param_count +
211 count +
212 1) * sizeof(void *)); 257 1) * sizeof(void *));
213 if (!info->parameters) { 258 if (!info->parameters) {
214 status = AE_NO_MEMORY; 259 status = AE_NO_MEMORY;
@@ -217,7 +262,7 @@ acpi_evaluate_object(acpi_handle handle,
217 262
218 /* Convert each external object in the list to an internal object */ 263 /* Convert each external object in the list to an internal object */
219 264
220 for (i = 0; i < external_params->count; i++) { 265 for (i = 0; i < info->param_count; i++) {
221 status = 266 status =
222 acpi_ut_copy_eobject_to_iobject(&external_params-> 267 acpi_ut_copy_eobject_to_iobject(&external_params->
223 pointer[i], 268 pointer[i],
@@ -227,43 +272,96 @@ acpi_evaluate_object(acpi_handle handle,
227 goto cleanup; 272 goto cleanup;
228 } 273 }
229 } 274 }
230 info->parameters[external_params->count] = NULL; 275
276 info->parameters[info->param_count] = NULL;
231 } 277 }
232 278
279#if 0
280
233 /* 281 /*
234 * Three major cases: 282 * Begin incoming argument count analysis. Check for too few args
235 * 1) Fully qualified pathname 283 * and too many args.
236 * 2) No handle, not fully qualified pathname (error)
237 * 3) Valid handle
238 */ 284 */
239 if ((pathname) && (ACPI_IS_ROOT_PREFIX(pathname[0]))) {
240 285
241 /* The path is fully qualified, just evaluate by name */ 286 switch (acpi_ns_get_type(info->node)) {
287 case ACPI_TYPE_METHOD:
288
289 /* Check incoming argument count against the method definition */
290
291 if (info->obj_desc->method.param_count > info->param_count) {
292 ACPI_ERROR((AE_INFO,
293 "Insufficient arguments (%u) - %u are required",
294 info->param_count,
295 info->obj_desc->method.param_count));
296
297 status = AE_MISSING_ARGUMENTS;
298 goto cleanup;
299 }
300
301 else if (info->obj_desc->method.param_count < info->param_count) {
302 ACPI_WARNING((AE_INFO,
303 "Excess arguments (%u) - only %u are required",
304 info->param_count,
305 info->obj_desc->method.param_count));
306
307 /* Just pass the required number of arguments */
308
309 info->param_count = info->obj_desc->method.param_count;
310 }
242 311
243 info->prefix_node = NULL;
244 status = acpi_ns_evaluate(info);
245 } else if (!handle) {
246 /* 312 /*
247 * A handle is optional iff a fully qualified pathname is specified. 313 * Any incoming external objects to be passed as arguments to the
248 * Since we've already handled fully qualified names above, this is 314 * method must be converted to internal objects
249 * an error
250 */ 315 */
251 if (!pathname) { 316 if (info->param_count) {
252 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 317 /*
253 "Both Handle and Pathname are NULL")); 318 * Allocate a new parameter block for the internal objects
254 } else { 319 * Add 1 to count to allow for null terminated internal list
255 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 320 */
256 "Null Handle with relative pathname [%s]", 321 info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size)
257 pathname)); 322 info->
323 param_count +
324 1) *
325 sizeof(void *));
326 if (!info->parameters) {
327 status = AE_NO_MEMORY;
328 goto cleanup;
329 }
330
331 /* Convert each external object in the list to an internal object */
332
333 for (i = 0; i < info->param_count; i++) {
334 status =
335 acpi_ut_copy_eobject_to_iobject
336 (&external_params->pointer[i],
337 &info->parameters[i]);
338 if (ACPI_FAILURE(status)) {
339 goto cleanup;
340 }
341 }
342
343 info->parameters[info->param_count] = NULL;
258 } 344 }
345 break;
259 346
260 status = AE_BAD_PARAMETER; 347 default:
261 } else { 348
262 /* We have a namespace a node and a possible relative path */ 349 /* Warn if arguments passed to an object that is not a method */
263 350
264 status = acpi_ns_evaluate(info); 351 if (info->param_count) {
352 ACPI_WARNING((AE_INFO,
353 "%u arguments were passed to a non-method ACPI object",
354 info->param_count));
355 }
356 break;
265 } 357 }
266 358
359#endif
360
361 /* Now we can evaluate the object */
362
363 status = acpi_ns_evaluate(info);
364
267 /* 365 /*
268 * If we are expecting a return value, and all went well above, 366 * If we are expecting a return value, and all went well above,
269 * copy the return value to an external object. 367 * copy the return value to an external object.
@@ -413,6 +511,7 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
413 break; 511 break;
414 512
415 default: 513 default:
514
416 return; 515 return;
417 } 516 }
418 517
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index 9f25a3d4e992..91a5a69db80c 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -629,24 +629,28 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
629 629
630 switch (opcode) { 630 switch (opcode) {
631 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ 631 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
632
632 buffer_length = 633 buffer_length =
633 ACPI_GET8(parser_state->aml); 634 ACPI_GET8(parser_state->aml);
634 parser_state->aml += 1; 635 parser_state->aml += 1;
635 break; 636 break;
636 637
637 case AML_WORD_OP: /* AML_WORDDATA_ARG */ 638 case AML_WORD_OP: /* AML_WORDDATA_ARG */
639
638 buffer_length = 640 buffer_length =
639 ACPI_GET16(parser_state->aml); 641 ACPI_GET16(parser_state->aml);
640 parser_state->aml += 2; 642 parser_state->aml += 2;
641 break; 643 break;
642 644
643 case AML_DWORD_OP: /* AML_DWORDATA_ARG */ 645 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
646
644 buffer_length = 647 buffer_length =
645 ACPI_GET32(parser_state->aml); 648 ACPI_GET32(parser_state->aml);
646 parser_state->aml += 4; 649 parser_state->aml += 4;
647 break; 650 break;
648 651
649 default: 652 default:
653
650 buffer_length = 0; 654 buffer_length = 0;
651 break; 655 break;
652 } 656 }
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index 63c455447481..065b44ae538f 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -164,7 +164,6 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
164 case AML_IF_OP: 164 case AML_IF_OP:
165 case AML_ELSE_OP: 165 case AML_ELSE_OP:
166 case AML_WHILE_OP: 166 case AML_WHILE_OP:
167
168 /* 167 /*
169 * Currently supported module-level opcodes are: 168 * Currently supported module-level opcodes are:
170 * IF/ELSE/WHILE. These appear to be the most common, 169 * IF/ELSE/WHILE. These appear to be the most common,
@@ -289,6 +288,7 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
289 default: 288 default:
290 289
291 /* No action for all other opcodes */ 290 /* No action for all other opcodes */
291
292 break; 292 break;
293 } 293 }
294 294
diff --git a/drivers/acpi/acpica/psobject.c b/drivers/acpi/acpica/psobject.c
index 12c4028002b1..95dc608a66a8 100644
--- a/drivers/acpi/acpica/psobject.c
+++ b/drivers/acpi/acpica/psobject.c
@@ -402,6 +402,7 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state,
402 402
403 switch (status) { 403 switch (status) {
404 case AE_OK: 404 case AE_OK:
405
405 break; 406 break;
406 407
407 case AE_CTRL_TRANSFER: 408 case AE_CTRL_TRANSFER:
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c
index abc4c48b2edd..86198a9139b5 100644
--- a/drivers/acpi/acpica/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -176,10 +176,10 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
176 176
177 switch (parent_info->class) { 177 switch (parent_info->class) {
178 case AML_CLASS_CONTROL: 178 case AML_CLASS_CONTROL:
179
179 break; 180 break;
180 181
181 case AML_CLASS_CREATE: 182 case AML_CLASS_CREATE:
182
183 /* 183 /*
184 * These opcodes contain term_arg operands. The current 184 * These opcodes contain term_arg operands. The current
185 * op must be replaced by a placeholder return op 185 * op must be replaced by a placeholder return op
@@ -192,7 +192,6 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
192 break; 192 break;
193 193
194 case AML_CLASS_NAMED_OBJECT: 194 case AML_CLASS_NAMED_OBJECT:
195
196 /* 195 /*
197 * These opcodes contain term_arg operands. The current 196 * These opcodes contain term_arg operands. The current
198 * op must be replaced by a placeholder return op 197 * op must be replaced by a placeholder return op
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c
index c1934bf04f0a..877dc0de8df3 100644
--- a/drivers/acpi/acpica/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -308,7 +308,9 @@ union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op)
308 break; 308 break;
309 309
310 default: 310 default:
311
311 /* All others have no children */ 312 /* All others have no children */
313
312 break; 314 break;
313 } 315 }
314 316
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index f68254268965..11b99ab20bb3 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -125,7 +125,7 @@ static void acpi_ps_start_trace(struct acpi_evaluate_info *info)
125 } 125 }
126 126
127 if ((!acpi_gbl_trace_method_name) || 127 if ((!acpi_gbl_trace_method_name) ||
128 (acpi_gbl_trace_method_name != info->resolved_node->name.integer)) { 128 (acpi_gbl_trace_method_name != info->node->name.integer)) {
129 goto exit; 129 goto exit;
130 } 130 }
131 131
@@ -170,7 +170,7 @@ static void acpi_ps_stop_trace(struct acpi_evaluate_info *info)
170 } 170 }
171 171
172 if ((!acpi_gbl_trace_method_name) || 172 if ((!acpi_gbl_trace_method_name) ||
173 (acpi_gbl_trace_method_name != info->resolved_node->name.integer)) { 173 (acpi_gbl_trace_method_name != info->node->name.integer)) {
174 goto exit; 174 goto exit;
175 } 175 }
176 176
@@ -226,15 +226,14 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
226 226
227 /* Validate the Info and method Node */ 227 /* Validate the Info and method Node */
228 228
229 if (!info || !info->resolved_node) { 229 if (!info || !info->node) {
230 return_ACPI_STATUS(AE_NULL_ENTRY); 230 return_ACPI_STATUS(AE_NULL_ENTRY);
231 } 231 }
232 232
233 /* Init for new method, wait on concurrency semaphore */ 233 /* Init for new method, wait on concurrency semaphore */
234 234
235 status = 235 status =
236 acpi_ds_begin_method_execution(info->resolved_node, info->obj_desc, 236 acpi_ds_begin_method_execution(info->node, info->obj_desc, NULL);
237 NULL);
238 if (ACPI_FAILURE(status)) { 237 if (ACPI_FAILURE(status)) {
239 return_ACPI_STATUS(status); 238 return_ACPI_STATUS(status);
240 } 239 }
@@ -253,8 +252,7 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
253 */ 252 */
254 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 253 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
255 "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", 254 "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
256 info->resolved_node->name.ascii, info->resolved_node, 255 info->node->name.ascii, info->node, info->obj_desc));
257 info->obj_desc));
258 256
259 /* Create and init a Root Node */ 257 /* Create and init a Root Node */
260 258
@@ -275,7 +273,7 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
275 goto cleanup; 273 goto cleanup;
276 } 274 }
277 275
278 status = acpi_ds_init_aml_walk(walk_state, op, info->resolved_node, 276 status = acpi_ds_init_aml_walk(walk_state, op, info->node,
279 info->obj_desc->method.aml_start, 277 info->obj_desc->method.aml_start,
280 info->obj_desc->method.aml_length, info, 278 info->obj_desc->method.aml_length, info,
281 info->pass_number); 279 info->pass_number);
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 72077fa1eea5..b62a0f4f4f9b 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -352,6 +352,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
352 break; 352 break;
353 353
354 default: 354 default:
355
355 break; 356 break;
356 } 357 }
357 358
@@ -539,6 +540,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
539 break; 540 break;
540 541
541 default: 542 default:
543
542 break; 544 break;
543 } 545 }
544 546
@@ -650,8 +652,9 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
650 652
651 name_found = FALSE; 653 name_found = FALSE;
652 654
653 for (table_index = 0; table_index < 4 && !name_found; 655 for (table_index = 0;
654 table_index++) { 656 table_index < package_element->package.count
657 && !name_found; table_index++) {
655 if (*sub_object_list && /* Null object allowed */ 658 if (*sub_object_list && /* Null object allowed */
656 ((ACPI_TYPE_STRING == 659 ((ACPI_TYPE_STRING ==
657 (*sub_object_list)->common.type) || 660 (*sub_object_list)->common.type) ||
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index f8b55b426c9d..65f3e1c5b598 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -273,17 +273,6 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
273 */ 273 */
274 user_prt->length = (sizeof(struct acpi_pci_routing_table) - 4); 274 user_prt->length = (sizeof(struct acpi_pci_routing_table) - 4);
275 275
276 /* Each element of the top-level package must also be a package */
277
278 if ((*top_object_list)->common.type != ACPI_TYPE_PACKAGE) {
279 ACPI_ERROR((AE_INFO,
280 "(PRT[%u]) Need sub-package, found %s",
281 index,
282 acpi_ut_get_object_type_name
283 (*top_object_list)));
284 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
285 }
286
287 /* Each sub-package must be of length 4 */ 276 /* Each sub-package must be of length 4 */
288 277
289 if ((*top_object_list)->package.count != 4) { 278 if ((*top_object_list)->package.count != 4) {
@@ -327,22 +316,6 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
327 user_prt->pin = (u32) obj_desc->integer.value; 316 user_prt->pin = (u32) obj_desc->integer.value;
328 317
329 /* 318 /*
330 * If the BIOS has erroneously reversed the _PRT source_name (index 2)
331 * and the source_index (index 3), fix it. _PRT is important enough to
332 * workaround this BIOS error. This also provides compatibility with
333 * other ACPI implementations.
334 */
335 obj_desc = sub_object_list[3];
336 if (!obj_desc || (obj_desc->common.type != ACPI_TYPE_INTEGER)) {
337 sub_object_list[3] = sub_object_list[2];
338 sub_object_list[2] = obj_desc;
339
340 ACPI_WARNING((AE_INFO,
341 "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed",
342 index));
343 }
344
345 /*
346 * 3) Third subobject: Dereference the PRT.source_name 319 * 3) Third subobject: Dereference the PRT.source_name
347 * The name may be unresolved (slack mode), so allow a null object 320 * The name may be unresolved (slack mode), so allow a null object
348 */ 321 */
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index b5fc0db2e87b..8a2d4986b0aa 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -120,17 +120,20 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
120 /* Strings */ 120 /* Strings */
121 121
122 case ACPI_RSD_LITERAL: 122 case ACPI_RSD_LITERAL:
123
123 acpi_rs_out_string(name, 124 acpi_rs_out_string(name,
124 ACPI_CAST_PTR(char, table->pointer)); 125 ACPI_CAST_PTR(char, table->pointer));
125 break; 126 break;
126 127
127 case ACPI_RSD_STRING: 128 case ACPI_RSD_STRING:
129
128 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target)); 130 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
129 break; 131 break;
130 132
131 /* Data items, 8/16/32/64 bit */ 133 /* Data items, 8/16/32/64 bit */
132 134
133 case ACPI_RSD_UINT8: 135 case ACPI_RSD_UINT8:
136
134 if (table->pointer) { 137 if (table->pointer) {
135 acpi_rs_out_string(name, ACPI_CAST_PTR(char, 138 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
136 table-> 139 table->
@@ -142,20 +145,24 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
142 break; 145 break;
143 146
144 case ACPI_RSD_UINT16: 147 case ACPI_RSD_UINT16:
148
145 acpi_rs_out_integer16(name, ACPI_GET16(target)); 149 acpi_rs_out_integer16(name, ACPI_GET16(target));
146 break; 150 break;
147 151
148 case ACPI_RSD_UINT32: 152 case ACPI_RSD_UINT32:
153
149 acpi_rs_out_integer32(name, ACPI_GET32(target)); 154 acpi_rs_out_integer32(name, ACPI_GET32(target));
150 break; 155 break;
151 156
152 case ACPI_RSD_UINT64: 157 case ACPI_RSD_UINT64:
158
153 acpi_rs_out_integer64(name, ACPI_GET64(target)); 159 acpi_rs_out_integer64(name, ACPI_GET64(target));
154 break; 160 break;
155 161
156 /* Flags: 1-bit and 2-bit flags supported */ 162 /* Flags: 1-bit and 2-bit flags supported */
157 163
158 case ACPI_RSD_1BITFLAG: 164 case ACPI_RSD_1BITFLAG:
165
159 acpi_rs_out_string(name, ACPI_CAST_PTR(char, 166 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
160 table-> 167 table->
161 pointer[*target & 168 pointer[*target &
@@ -163,6 +170,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
163 break; 170 break;
164 171
165 case ACPI_RSD_2BITFLAG: 172 case ACPI_RSD_2BITFLAG:
173
166 acpi_rs_out_string(name, ACPI_CAST_PTR(char, 174 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
167 table-> 175 table->
168 pointer[*target & 176 pointer[*target &
@@ -170,6 +178,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
170 break; 178 break;
171 179
172 case ACPI_RSD_3BITFLAG: 180 case ACPI_RSD_3BITFLAG:
181
173 acpi_rs_out_string(name, ACPI_CAST_PTR(char, 182 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
174 table-> 183 table->
175 pointer[*target & 184 pointer[*target &
@@ -258,6 +267,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
258 break; 267 break;
259 268
260 default: 269 default:
270
261 acpi_os_printf("**** Invalid table opcode [%X] ****\n", 271 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
262 table->opcode); 272 table->opcode);
263 return; 273 return;
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index d5bf05a96096..80d12994e0d0 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -194,7 +194,6 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
194 break; 194 break;
195 195
196 case ACPI_RSC_COUNT_GPIO_RES: 196 case ACPI_RSC_COUNT_GPIO_RES:
197
198 /* 197 /*
199 * Vendor data is optional (length/offset may both be zero) 198 * Vendor data is optional (length/offset may both be zero)
200 * Examine vendor data length field first 199 * Examine vendor data length field first
@@ -410,12 +409,14 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
410 */ 409 */
411 switch (info->resource_offset) { 410 switch (info->resource_offset) {
412 case ACPI_RSC_COMPARE_AML_LENGTH: 411 case ACPI_RSC_COMPARE_AML_LENGTH:
412
413 if (aml_resource_length != info->value) { 413 if (aml_resource_length != info->value) {
414 goto exit; 414 goto exit;
415 } 415 }
416 break; 416 break;
417 417
418 case ACPI_RSC_COMPARE_VALUE: 418 case ACPI_RSC_COMPARE_VALUE:
419
419 if (ACPI_GET8(source) != info->value) { 420 if (ACPI_GET8(source) != info->value) {
420 goto exit; 421 goto exit;
421 } 422 }
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index a44953c6f75d..480b6b40c5ea 100644
--- a/drivers/acpi/acpica/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -147,6 +147,7 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
147 case ACPI_RSC_MOVE_GPIO_RES: 147 case ACPI_RSC_MOVE_GPIO_RES:
148 case ACPI_RSC_MOVE_SERIAL_VEN: 148 case ACPI_RSC_MOVE_SERIAL_VEN:
149 case ACPI_RSC_MOVE_SERIAL_RES: 149 case ACPI_RSC_MOVE_SERIAL_RES:
150
150 ACPI_MEMCPY(destination, source, item_count); 151 ACPI_MEMCPY(destination, source, item_count);
151 return; 152 return;
152 153
@@ -157,21 +158,25 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
157 */ 158 */
158 case ACPI_RSC_MOVE16: 159 case ACPI_RSC_MOVE16:
159 case ACPI_RSC_MOVE_GPIO_PIN: 160 case ACPI_RSC_MOVE_GPIO_PIN:
161
160 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i], 162 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
161 &ACPI_CAST_PTR(u16, source)[i]); 163 &ACPI_CAST_PTR(u16, source)[i]);
162 break; 164 break;
163 165
164 case ACPI_RSC_MOVE32: 166 case ACPI_RSC_MOVE32:
167
165 ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i], 168 ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
166 &ACPI_CAST_PTR(u32, source)[i]); 169 &ACPI_CAST_PTR(u32, source)[i]);
167 break; 170 break;
168 171
169 case ACPI_RSC_MOVE64: 172 case ACPI_RSC_MOVE64:
173
170 ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i], 174 ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
171 &ACPI_CAST_PTR(u64, source)[i]); 175 &ACPI_CAST_PTR(u64, source)[i]);
172 break; 176 break;
173 177
174 default: 178 default:
179
175 return; 180 return;
176 } 181 }
177 } 182 }
@@ -736,7 +741,7 @@ acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
736 } 741 }
737 742
738 info->prefix_node = node; 743 info->prefix_node = node;
739 info->pathname = METHOD_NAME__SRS; 744 info->relative_pathname = METHOD_NAME__SRS;
740 info->parameters = args; 745 info->parameters = args;
741 info->flags = ACPI_IGNORE_RETURN_VALUE; 746 info->flags = ACPI_IGNORE_RETURN_VALUE;
742 747
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index c0e5d2d3ce67..94e3517554f9 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -402,6 +402,7 @@ acpi_resource_to_address64(struct acpi_resource *resource,
402 break; 402 break;
403 403
404 default: 404 default:
405
405 return (AE_BAD_PARAMETER); 406 return (AE_BAD_PARAMETER);
406 } 407 }
407 408
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index e57cd38004e3..42a13c0d7015 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -141,8 +141,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
141 ACPI_BIOS_ERROR((AE_INFO, 141 ACPI_BIOS_ERROR((AE_INFO,
142 "Table has invalid signature [%4.4s] (0x%8.8X), " 142 "Table has invalid signature [%4.4s] (0x%8.8X), "
143 "must be SSDT or OEMx", 143 "must be SSDT or OEMx",
144 acpi_ut_valid_acpi_name(*(u32 *)table_desc-> 144 acpi_ut_valid_acpi_name(table_desc->pointer->
145 pointer->
146 signature) ? 145 signature) ?
147 table_desc->pointer->signature : "????", 146 table_desc->pointer->signature : "????",
148 *(u32 *)table_desc->pointer->signature)); 147 *(u32 *)table_desc->pointer->signature));
@@ -471,15 +470,19 @@ void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
471 } 470 }
472 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { 471 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
473 case ACPI_TABLE_ORIGIN_MAPPED: 472 case ACPI_TABLE_ORIGIN_MAPPED:
473
474 acpi_os_unmap_memory(table_desc->pointer, table_desc->length); 474 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
475 break; 475 break;
476
476 case ACPI_TABLE_ORIGIN_ALLOCATED: 477 case ACPI_TABLE_ORIGIN_ALLOCATED:
478
477 ACPI_FREE(table_desc->pointer); 479 ACPI_FREE(table_desc->pointer);
478 break; 480 break;
479 481
480 /* Not mapped or allocated, there is nothing we can do */ 482 /* Not mapped or allocated, there is nothing we can do */
481 483
482 default: 484 default:
485
483 return; 486 return;
484 } 487 }
485 488
diff --git a/drivers/acpi/acpica/tbprint.c b/drivers/acpi/acpica/tbprint.c
new file mode 100644
index 000000000000..dc963f823d2c
--- /dev/null
+++ b/drivers/acpi/acpica/tbprint.c
@@ -0,0 +1,237 @@
1/******************************************************************************
2 *
3 * Module Name: tbprint - Table output utilities
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "actables.h"
47
48#define _COMPONENT ACPI_TABLES
49ACPI_MODULE_NAME("tbprint")
50
51/* Local prototypes */
52static void acpi_tb_fix_string(char *string, acpi_size length);
53
54static void
55acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
56 struct acpi_table_header *header);
57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_tb_fix_string
61 *
62 * PARAMETERS: string - String to be repaired
63 * length - Maximum length
64 *
65 * RETURN: None
66 *
67 * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
68 * with a question mark '?'.
69 *
70 ******************************************************************************/
71
72static void acpi_tb_fix_string(char *string, acpi_size length)
73{
74
75 while (length && *string) {
76 if (!ACPI_IS_PRINT(*string)) {
77 *string = '?';
78 }
79 string++;
80 length--;
81 }
82}
83
84/*******************************************************************************
85 *
86 * FUNCTION: acpi_tb_cleanup_table_header
87 *
88 * PARAMETERS: out_header - Where the cleaned header is returned
89 * header - Input ACPI table header
90 *
91 * RETURN: Returns the cleaned header in out_header
92 *
93 * DESCRIPTION: Copy the table header and ensure that all "string" fields in
94 * the header consist of printable characters.
95 *
96 ******************************************************************************/
97
98static void
99acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
100 struct acpi_table_header *header)
101{
102
103 ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header));
104
105 acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE);
106 acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE);
107 acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
108 acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE);
109}
110
111/*******************************************************************************
112 *
113 * FUNCTION: acpi_tb_print_table_header
114 *
115 * PARAMETERS: address - Table physical address
116 * header - Table header
117 *
118 * RETURN: None
119 *
120 * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
121 *
122 ******************************************************************************/
123
124void
125acpi_tb_print_table_header(acpi_physical_address address,
126 struct acpi_table_header *header)
127{
128 struct acpi_table_header local_header;
129
130 /*
131 * The reason that the Address is cast to a void pointer is so that we
132 * can use %p which will work properly on both 32-bit and 64-bit hosts.
133 */
134 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
135
136 /* FACS only has signature and length fields */
137
138 ACPI_INFO((AE_INFO, "%4.4s %p %05X",
139 header->signature, ACPI_CAST_PTR(void, address),
140 header->length));
141 } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) {
142
143 /* RSDP has no common fields */
144
145 ACPI_MEMCPY(local_header.oem_id,
146 ACPI_CAST_PTR(struct acpi_table_rsdp,
147 header)->oem_id, ACPI_OEM_ID_SIZE);
148 acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);
149
150 ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)",
151 ACPI_CAST_PTR(void, address),
152 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
153 revision >
154 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
155 header)->length : 20,
156 ACPI_CAST_PTR(struct acpi_table_rsdp,
157 header)->revision,
158 local_header.oem_id));
159 } else {
160 /* Standard ACPI table with full common header */
161
162 acpi_tb_cleanup_table_header(&local_header, header);
163
164 ACPI_INFO((AE_INFO,
165 "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)",
166 local_header.signature, ACPI_CAST_PTR(void, address),
167 local_header.length, local_header.revision,
168 local_header.oem_id, local_header.oem_table_id,
169 local_header.oem_revision,
170 local_header.asl_compiler_id,
171 local_header.asl_compiler_revision));
172 }
173}
174
175/*******************************************************************************
176 *
177 * FUNCTION: acpi_tb_validate_checksum
178 *
179 * PARAMETERS: table - ACPI table to verify
180 * length - Length of entire table
181 *
182 * RETURN: Status
183 *
184 * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
185 * exception on bad checksum.
186 *
187 ******************************************************************************/
188
189acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
190{
191 u8 checksum;
192
193 /* Compute the checksum on the table */
194
195 checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
196
197 /* Checksum ok? (should be zero) */
198
199 if (checksum) {
200 ACPI_BIOS_WARNING((AE_INFO,
201 "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
202 "should be 0x%2.2X",
203 table->signature, table->checksum,
204 (u8)(table->checksum - checksum)));
205
206#if (ACPI_CHECKSUM_ABORT)
207 return (AE_BAD_CHECKSUM);
208#endif
209 }
210
211 return (AE_OK);
212}
213
214/*******************************************************************************
215 *
216 * FUNCTION: acpi_tb_checksum
217 *
218 * PARAMETERS: buffer - Pointer to memory region to be checked
219 * length - Length of this memory region
220 *
221 * RETURN: Checksum (u8)
222 *
223 * DESCRIPTION: Calculates circular checksum of memory region.
224 *
225 ******************************************************************************/
226
227u8 acpi_tb_checksum(u8 *buffer, u32 length)
228{
229 u8 sum = 0;
230 u8 *end = buffer + length;
231
232 while (buffer < end) {
233 sum = (u8)(sum + *(buffer++));
234 }
235
236 return (sum);
237}
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index ce3d5db39a9c..bffdfc7b8322 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: tbutils - table utilities 3 * Module Name: tbutils - ACPI Table utilities
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -49,12 +49,6 @@
49ACPI_MODULE_NAME("tbutils") 49ACPI_MODULE_NAME("tbutils")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52static void acpi_tb_fix_string(char *string, acpi_size length);
53
54static void
55acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
56 struct acpi_table_header *header);
57
58static acpi_physical_address 52static acpi_physical_address
59acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); 53acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size);
60 54
@@ -176,189 +170,6 @@ u8 acpi_tb_tables_loaded(void)
176 170
177/******************************************************************************* 171/*******************************************************************************
178 * 172 *
179 * FUNCTION: acpi_tb_fix_string
180 *
181 * PARAMETERS: string - String to be repaired
182 * length - Maximum length
183 *
184 * RETURN: None
185 *
186 * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
187 * with a question mark '?'.
188 *
189 ******************************************************************************/
190
191static void acpi_tb_fix_string(char *string, acpi_size length)
192{
193
194 while (length && *string) {
195 if (!ACPI_IS_PRINT(*string)) {
196 *string = '?';
197 }
198 string++;
199 length--;
200 }
201}
202
203/*******************************************************************************
204 *
205 * FUNCTION: acpi_tb_cleanup_table_header
206 *
207 * PARAMETERS: out_header - Where the cleaned header is returned
208 * header - Input ACPI table header
209 *
210 * RETURN: Returns the cleaned header in out_header
211 *
212 * DESCRIPTION: Copy the table header and ensure that all "string" fields in
213 * the header consist of printable characters.
214 *
215 ******************************************************************************/
216
217static void
218acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
219 struct acpi_table_header *header)
220{
221
222 ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header));
223
224 acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE);
225 acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE);
226 acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
227 acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE);
228}
229
230/*******************************************************************************
231 *
232 * FUNCTION: acpi_tb_print_table_header
233 *
234 * PARAMETERS: address - Table physical address
235 * header - Table header
236 *
237 * RETURN: None
238 *
239 * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
240 *
241 ******************************************************************************/
242
243void
244acpi_tb_print_table_header(acpi_physical_address address,
245 struct acpi_table_header *header)
246{
247 struct acpi_table_header local_header;
248
249 /*
250 * The reason that the Address is cast to a void pointer is so that we
251 * can use %p which will work properly on both 32-bit and 64-bit hosts.
252 */
253 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
254
255 /* FACS only has signature and length fields */
256
257 ACPI_INFO((AE_INFO, "%4.4s %p %05X",
258 header->signature, ACPI_CAST_PTR(void, address),
259 header->length));
260 } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) {
261
262 /* RSDP has no common fields */
263
264 ACPI_MEMCPY(local_header.oem_id,
265 ACPI_CAST_PTR(struct acpi_table_rsdp,
266 header)->oem_id, ACPI_OEM_ID_SIZE);
267 acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);
268
269 ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)",
270 ACPI_CAST_PTR (void, address),
271 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
272 revision >
273 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
274 header)->length : 20,
275 ACPI_CAST_PTR(struct acpi_table_rsdp,
276 header)->revision,
277 local_header.oem_id));
278 } else {
279 /* Standard ACPI table with full common header */
280
281 acpi_tb_cleanup_table_header(&local_header, header);
282
283 ACPI_INFO((AE_INFO,
284 "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)",
285 local_header.signature, ACPI_CAST_PTR(void, address),
286 local_header.length, local_header.revision,
287 local_header.oem_id, local_header.oem_table_id,
288 local_header.oem_revision,
289 local_header.asl_compiler_id,
290 local_header.asl_compiler_revision));
291
292 }
293}
294
295/*******************************************************************************
296 *
297 * FUNCTION: acpi_tb_validate_checksum
298 *
299 * PARAMETERS: table - ACPI table to verify
300 * length - Length of entire table
301 *
302 * RETURN: Status
303 *
304 * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
305 * exception on bad checksum.
306 *
307 ******************************************************************************/
308
309acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
310{
311 u8 checksum;
312
313 /* Compute the checksum on the table */
314
315 checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
316
317 /* Checksum ok? (should be zero) */
318
319 if (checksum) {
320 ACPI_BIOS_WARNING((AE_INFO,
321 "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
322 "should be 0x%2.2X",
323 table->signature, table->checksum,
324 (u8)(table->checksum - checksum)));
325
326#if (ACPI_CHECKSUM_ABORT)
327
328 return (AE_BAD_CHECKSUM);
329#endif
330 }
331
332 return (AE_OK);
333}
334
335/*******************************************************************************
336 *
337 * FUNCTION: acpi_tb_checksum
338 *
339 * PARAMETERS: buffer - Pointer to memory region to be checked
340 * length - Length of this memory region
341 *
342 * RETURN: Checksum (u8)
343 *
344 * DESCRIPTION: Calculates circular checksum of memory region.
345 *
346 ******************************************************************************/
347
348u8 acpi_tb_checksum(u8 *buffer, u32 length)
349{
350 u8 sum = 0;
351 u8 *end = buffer + length;
352
353 while (buffer < end) {
354 sum = (u8) (sum + *(buffer++));
355 }
356
357 return (sum);
358}
359
360/*******************************************************************************
361 *
362 * FUNCTION: acpi_tb_check_dsdt_header 173 * FUNCTION: acpi_tb_check_dsdt_header
363 * 174 *
364 * PARAMETERS: None 175 * PARAMETERS: None
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index 67e046ec8f0a..0ba9e328d5d7 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -53,8 +53,6 @@ ACPI_MODULE_NAME("tbxfload")
53/* Local prototypes */ 53/* Local prototypes */
54static acpi_status acpi_tb_load_namespace(void); 54static acpi_status acpi_tb_load_namespace(void);
55 55
56static int no_auto_ssdt;
57
58/******************************************************************************* 56/*******************************************************************************
59 * 57 *
60 * FUNCTION: acpi_load_tables 58 * FUNCTION: acpi_load_tables
@@ -180,8 +178,16 @@ static acpi_status acpi_tb_load_namespace(void)
180 continue; 178 continue;
181 } 179 }
182 180
183 if (no_auto_ssdt) { 181 /*
184 printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n"); 182 * Optionally do not load any SSDTs from the RSDT/XSDT. This can
183 * be useful for debugging ACPI problems on some machines.
184 */
185 if (acpi_gbl_disable_ssdt_table_load) {
186 ACPI_INFO((AE_INFO, "Ignoring %4.4s at %p",
187 acpi_gbl_root_table_list.tables[i].signature.
188 ascii, ACPI_CAST_PTR(void,
189 acpi_gbl_root_table_list.
190 tables[i].address)));
185 continue; 191 continue;
186 } 192 }
187 193
@@ -376,14 +382,3 @@ acpi_status acpi_unload_parent_table(acpi_handle object)
376} 382}
377 383
378ACPI_EXPORT_SYMBOL(acpi_unload_parent_table) 384ACPI_EXPORT_SYMBOL(acpi_unload_parent_table)
379
380static int __init acpi_no_auto_ssdt_setup(char *s) {
381
382 printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n");
383
384 no_auto_ssdt = 1;
385
386 return 1;
387}
388
389__setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);
diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c
new file mode 100644
index 000000000000..11fde93be120
--- /dev/null
+++ b/drivers/acpi/acpica/utbuffer.c
@@ -0,0 +1,201 @@
1/******************************************************************************
2 *
3 * Module Name: utbuffer - Buffer dump routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utbuffer")
49
50/*******************************************************************************
51 *
52 * FUNCTION: acpi_ut_dump_buffer
53 *
54 * PARAMETERS: buffer - Buffer to dump
55 * count - Amount to dump, in bytes
56 * display - BYTE, WORD, DWORD, or QWORD display:
57 * DB_BYTE_DISPLAY
58 * DB_WORD_DISPLAY
59 * DB_DWORD_DISPLAY
60 * DB_QWORD_DISPLAY
61 * base_offset - Beginning buffer offset (display only)
62 *
63 * RETURN: None
64 *
65 * DESCRIPTION: Generic dump buffer in both hex and ascii.
66 *
67 ******************************************************************************/
68void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset)
69{
70 u32 i = 0;
71 u32 j;
72 u32 temp32;
73 u8 buf_char;
74
75 if (!buffer) {
76 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
77 return;
78 }
79
80 if ((count < 4) || (count & 0x01)) {
81 display = DB_BYTE_DISPLAY;
82 }
83
84 /* Nasty little dump buffer routine! */
85
86 while (i < count) {
87
88 /* Print current offset */
89
90 acpi_os_printf("%6.4X: ", (base_offset + i));
91
92 /* Print 16 hex chars */
93
94 for (j = 0; j < 16;) {
95 if (i + j >= count) {
96
97 /* Dump fill spaces */
98
99 acpi_os_printf("%*s", ((display * 2) + 1), " ");
100 j += display;
101 continue;
102 }
103
104 switch (display) {
105 case DB_BYTE_DISPLAY:
106 default: /* Default is BYTE display */
107
108 acpi_os_printf("%02X ",
109 buffer[(acpi_size) i + j]);
110 break;
111
112 case DB_WORD_DISPLAY:
113
114 ACPI_MOVE_16_TO_32(&temp32,
115 &buffer[(acpi_size) i + j]);
116 acpi_os_printf("%04X ", temp32);
117 break;
118
119 case DB_DWORD_DISPLAY:
120
121 ACPI_MOVE_32_TO_32(&temp32,
122 &buffer[(acpi_size) i + j]);
123 acpi_os_printf("%08X ", temp32);
124 break;
125
126 case DB_QWORD_DISPLAY:
127
128 ACPI_MOVE_32_TO_32(&temp32,
129 &buffer[(acpi_size) i + j]);
130 acpi_os_printf("%08X", temp32);
131
132 ACPI_MOVE_32_TO_32(&temp32,
133 &buffer[(acpi_size) i + j +
134 4]);
135 acpi_os_printf("%08X ", temp32);
136 break;
137 }
138
139 j += display;
140 }
141
142 /*
143 * Print the ASCII equivalent characters but watch out for the bad
144 * unprintable ones (printable chars are 0x20 through 0x7E)
145 */
146 acpi_os_printf(" ");
147 for (j = 0; j < 16; j++) {
148 if (i + j >= count) {
149 acpi_os_printf("\n");
150 return;
151 }
152
153 buf_char = buffer[(acpi_size) i + j];
154 if (ACPI_IS_PRINT(buf_char)) {
155 acpi_os_printf("%c", buf_char);
156 } else {
157 acpi_os_printf(".");
158 }
159 }
160
161 /* Done with that line. */
162
163 acpi_os_printf("\n");
164 i += 16;
165 }
166
167 return;
168}
169
170/*******************************************************************************
171 *
172 * FUNCTION: acpi_ut_debug_dump_buffer
173 *
174 * PARAMETERS: buffer - Buffer to dump
175 * count - Amount to dump, in bytes
176 * display - BYTE, WORD, DWORD, or QWORD display:
177 * DB_BYTE_DISPLAY
178 * DB_WORD_DISPLAY
179 * DB_DWORD_DISPLAY
180 * DB_QWORD_DISPLAY
181 * component_ID - Caller's component ID
182 *
183 * RETURN: None
184 *
185 * DESCRIPTION: Generic dump buffer in both hex and ascii.
186 *
187 ******************************************************************************/
188
189void
190acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
191{
192
193 /* Only dump the buffer if tracing is enabled */
194
195 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
196 (component_id & acpi_dbg_layer))) {
197 return;
198 }
199
200 acpi_ut_dump_buffer(buffer, count, display, 0);
201}
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index e4c9291fc0a3..1731c27c36a6 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -178,7 +178,6 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
178 178
179 switch (internal_object->reference.class) { 179 switch (internal_object->reference.class) {
180 case ACPI_REFCLASS_NAME: 180 case ACPI_REFCLASS_NAME:
181
182 /* 181 /*
183 * For namepath, return the object handle ("reference") 182 * For namepath, return the object handle ("reference")
184 * We are referring to the namespace node 183 * We are referring to the namespace node
@@ -264,7 +263,6 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type,
264 263
265 switch (object_type) { 264 switch (object_type) {
266 case ACPI_COPY_TYPE_SIMPLE: 265 case ACPI_COPY_TYPE_SIMPLE:
267
268 /* 266 /*
269 * This is a simple or null object 267 * This is a simple or null object
270 */ 268 */
@@ -278,7 +276,6 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type,
278 break; 276 break;
279 277
280 case ACPI_COPY_TYPE_PACKAGE: 278 case ACPI_COPY_TYPE_PACKAGE:
281
282 /* 279 /*
283 * Build the package object 280 * Build the package object
284 */ 281 */
@@ -304,6 +301,7 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type,
304 break; 301 break;
305 302
306 default: 303 default:
304
307 return (AE_BAD_PARAMETER); 305 return (AE_BAD_PARAMETER);
308 } 306 }
309 307
@@ -481,6 +479,7 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
481 return_ACPI_STATUS(AE_OK); 479 return_ACPI_STATUS(AE_OK);
482 480
483 default: 481 default:
482
484 /* All other types are not supported */ 483 /* All other types are not supported */
485 484
486 ACPI_ERROR((AE_INFO, 485 ACPI_ERROR((AE_INFO,
@@ -544,7 +543,9 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
544 break; 543 break;
545 544
546 default: 545 default:
546
547 /* Other types can't get here */ 547 /* Other types can't get here */
548
548 break; 549 break;
549 } 550 }
550 551
@@ -800,7 +801,9 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
800 break; 801 break;
801 802
802 default: 803 default:
804
803 /* Nothing to do for other simple objects */ 805 /* Nothing to do for other simple objects */
806
804 break; 807 break;
805 } 808 }
806 809
@@ -868,7 +871,6 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type,
868 break; 871 break;
869 872
870 case ACPI_COPY_TYPE_PACKAGE: 873 case ACPI_COPY_TYPE_PACKAGE:
871
872 /* 874 /*
873 * This object is a package - go down another nesting level 875 * This object is a package - go down another nesting level
874 * Create and build the package object 876 * Create and build the package object
@@ -891,6 +893,7 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type,
891 break; 893 break;
892 894
893 default: 895 default:
896
894 return (AE_BAD_PARAMETER); 897 return (AE_BAD_PARAMETER);
895 } 898 }
896 899
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index c57d9cc07ba9..5796e11a0671 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: utdebug - Debug print routines 3 * Module Name: utdebug - Debug print/trace routines
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -543,149 +543,3 @@ acpi_ut_ptr_exit(u32 line_number,
543} 543}
544 544
545#endif 545#endif
546
547/*******************************************************************************
548 *
549 * FUNCTION: acpi_ut_dump_buffer
550 *
551 * PARAMETERS: buffer - Buffer to dump
552 * count - Amount to dump, in bytes
553 * display - BYTE, WORD, DWORD, or QWORD display
554 * offset - Beginning buffer offset (display only)
555 *
556 * RETURN: None
557 *
558 * DESCRIPTION: Generic dump buffer in both hex and ascii.
559 *
560 ******************************************************************************/
561
562void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset)
563{
564 u32 i = 0;
565 u32 j;
566 u32 temp32;
567 u8 buf_char;
568
569 if (!buffer) {
570 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
571 return;
572 }
573
574 if ((count < 4) || (count & 0x01)) {
575 display = DB_BYTE_DISPLAY;
576 }
577
578 /* Nasty little dump buffer routine! */
579
580 while (i < count) {
581
582 /* Print current offset */
583
584 acpi_os_printf("%6.4X: ", (base_offset + i));
585
586 /* Print 16 hex chars */
587
588 for (j = 0; j < 16;) {
589 if (i + j >= count) {
590
591 /* Dump fill spaces */
592
593 acpi_os_printf("%*s", ((display * 2) + 1), " ");
594 j += display;
595 continue;
596 }
597
598 switch (display) {
599 case DB_BYTE_DISPLAY:
600 default: /* Default is BYTE display */
601
602 acpi_os_printf("%02X ",
603 buffer[(acpi_size) i + j]);
604 break;
605
606 case DB_WORD_DISPLAY:
607
608 ACPI_MOVE_16_TO_32(&temp32,
609 &buffer[(acpi_size) i + j]);
610 acpi_os_printf("%04X ", temp32);
611 break;
612
613 case DB_DWORD_DISPLAY:
614
615 ACPI_MOVE_32_TO_32(&temp32,
616 &buffer[(acpi_size) i + j]);
617 acpi_os_printf("%08X ", temp32);
618 break;
619
620 case DB_QWORD_DISPLAY:
621
622 ACPI_MOVE_32_TO_32(&temp32,
623 &buffer[(acpi_size) i + j]);
624 acpi_os_printf("%08X", temp32);
625
626 ACPI_MOVE_32_TO_32(&temp32,
627 &buffer[(acpi_size) i + j +
628 4]);
629 acpi_os_printf("%08X ", temp32);
630 break;
631 }
632
633 j += display;
634 }
635
636 /*
637 * Print the ASCII equivalent characters but watch out for the bad
638 * unprintable ones (printable chars are 0x20 through 0x7E)
639 */
640 acpi_os_printf(" ");
641 for (j = 0; j < 16; j++) {
642 if (i + j >= count) {
643 acpi_os_printf("\n");
644 return;
645 }
646
647 buf_char = buffer[(acpi_size) i + j];
648 if (ACPI_IS_PRINT(buf_char)) {
649 acpi_os_printf("%c", buf_char);
650 } else {
651 acpi_os_printf(".");
652 }
653 }
654
655 /* Done with that line. */
656
657 acpi_os_printf("\n");
658 i += 16;
659 }
660
661 return;
662}
663
664/*******************************************************************************
665 *
666 * FUNCTION: acpi_ut_debug_dump_buffer
667 *
668 * PARAMETERS: buffer - Buffer to dump
669 * count - Amount to dump, in bytes
670 * display - BYTE, WORD, DWORD, or QWORD display
671 * component_ID - Caller's component ID
672 *
673 * RETURN: None
674 *
675 * DESCRIPTION: Generic dump buffer in both hex and ascii.
676 *
677 ******************************************************************************/
678
679void
680acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
681{
682
683 /* Only dump the buffer if tracing is enabled */
684
685 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
686 (component_id & acpi_dbg_layer))) {
687 return;
688 }
689
690 acpi_ut_dump_buffer(buffer, count, display, 0);
691}
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index 29b930250b6f..d6b33f29d327 100644
--- a/drivers/acpi/acpica/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -303,6 +303,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
303 break; 303 break;
304 304
305 default: 305 default:
306
306 break; 307 break;
307 } 308 }
308 309
@@ -508,7 +509,6 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
508 case ACPI_TYPE_PROCESSOR: 509 case ACPI_TYPE_PROCESSOR:
509 case ACPI_TYPE_POWER: 510 case ACPI_TYPE_POWER:
510 case ACPI_TYPE_THERMAL: 511 case ACPI_TYPE_THERMAL:
511
512 /* 512 /*
513 * Update the notify objects for these types (if present) 513 * Update the notify objects for these types (if present)
514 * Two lists, system and device notify handlers. 514 * Two lists, system and device notify handlers.
@@ -623,6 +623,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
623 623
624 case ACPI_TYPE_REGION: 624 case ACPI_TYPE_REGION:
625 default: 625 default:
626
626 break; /* No subobjects for all other types */ 627 break; /* No subobjects for all other types */
627 } 628 }
628 629
diff --git a/drivers/acpi/acpica/uterror.c b/drivers/acpi/acpica/uterror.c
new file mode 100644
index 000000000000..154fdcaa5830
--- /dev/null
+++ b/drivers/acpi/acpica/uterror.c
@@ -0,0 +1,289 @@
1/*******************************************************************************
2 *
3 * Module Name: uterror - Various internal error/warning output functions
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acnamesp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("uterror")
50
51/*
52 * This module contains internal error functions that may
53 * be configured out.
54 */
55#if !defined (ACPI_NO_ERROR_MESSAGES)
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ut_predefined_warning
59 *
60 * PARAMETERS: module_name - Caller's module name (for error output)
61 * line_number - Caller's line number (for error output)
62 * pathname - Full pathname to the node
63 * node_flags - From Namespace node for the method/object
64 * format - Printf format string + additional args
65 *
66 * RETURN: None
67 *
68 * DESCRIPTION: Warnings for the predefined validation module. Messages are
69 * only emitted the first time a problem with a particular
70 * method/object is detected. This prevents a flood of error
71 * messages for methods that are repeatedly evaluated.
72 *
73 ******************************************************************************/
74void ACPI_INTERNAL_VAR_XFACE
75acpi_ut_predefined_warning(const char *module_name,
76 u32 line_number,
77 char *pathname,
78 u8 node_flags, const char *format, ...)
79{
80 va_list arg_list;
81
82 /*
83 * Warning messages for this method/object will be disabled after the
84 * first time a validation fails or an object is successfully repaired.
85 */
86 if (node_flags & ANOBJ_EVALUATED) {
87 return;
88 }
89
90 acpi_os_printf(ACPI_MSG_WARNING "%s: ", pathname);
91
92 va_start(arg_list, format);
93 acpi_os_vprintf(format, arg_list);
94 ACPI_MSG_SUFFIX;
95 va_end(arg_list);
96}
97
98/*******************************************************************************
99 *
100 * FUNCTION: acpi_ut_predefined_info
101 *
102 * PARAMETERS: module_name - Caller's module name (for error output)
103 * line_number - Caller's line number (for error output)
104 * pathname - Full pathname to the node
105 * node_flags - From Namespace node for the method/object
106 * format - Printf format string + additional args
107 *
108 * RETURN: None
109 *
110 * DESCRIPTION: Info messages for the predefined validation module. Messages
111 * are only emitted the first time a problem with a particular
112 * method/object is detected. This prevents a flood of
113 * messages for methods that are repeatedly evaluated.
114 *
115 ******************************************************************************/
116
117void ACPI_INTERNAL_VAR_XFACE
118acpi_ut_predefined_info(const char *module_name,
119 u32 line_number,
120 char *pathname, u8 node_flags, const char *format, ...)
121{
122 va_list arg_list;
123
124 /*
125 * Warning messages for this method/object will be disabled after the
126 * first time a validation fails or an object is successfully repaired.
127 */
128 if (node_flags & ANOBJ_EVALUATED) {
129 return;
130 }
131
132 acpi_os_printf(ACPI_MSG_INFO "%s: ", pathname);
133
134 va_start(arg_list, format);
135 acpi_os_vprintf(format, arg_list);
136 ACPI_MSG_SUFFIX;
137 va_end(arg_list);
138}
139
140/*******************************************************************************
141 *
142 * FUNCTION: acpi_ut_predefined_bios_error
143 *
144 * PARAMETERS: module_name - Caller's module name (for error output)
145 * line_number - Caller's line number (for error output)
146 * pathname - Full pathname to the node
147 * node_flags - From Namespace node for the method/object
148 * format - Printf format string + additional args
149 *
150 * RETURN: None
151 *
152 * DESCRIPTION: BIOS error message for predefined names. Messages
153 * are only emitted the first time a problem with a particular
154 * method/object is detected. This prevents a flood of
155 * messages for methods that are repeatedly evaluated.
156 *
157 ******************************************************************************/
158
159void ACPI_INTERNAL_VAR_XFACE
160acpi_ut_predefined_bios_error(const char *module_name,
161 u32 line_number,
162 char *pathname,
163 u8 node_flags, const char *format, ...)
164{
165 va_list arg_list;
166
167 /*
168 * Warning messages for this method/object will be disabled after the
169 * first time a validation fails or an object is successfully repaired.
170 */
171 if (node_flags & ANOBJ_EVALUATED) {
172 return;
173 }
174
175 acpi_os_printf(ACPI_MSG_BIOS_ERROR "%s: ", pathname);
176
177 va_start(arg_list, format);
178 acpi_os_vprintf(format, arg_list);
179 ACPI_MSG_SUFFIX;
180 va_end(arg_list);
181}
182
183/*******************************************************************************
184 *
185 * FUNCTION: acpi_ut_namespace_error
186 *
187 * PARAMETERS: module_name - Caller's module name (for error output)
188 * line_number - Caller's line number (for error output)
189 * internal_name - Name or path of the namespace node
190 * lookup_status - Exception code from NS lookup
191 *
192 * RETURN: None
193 *
194 * DESCRIPTION: Print error message with the full pathname for the NS node.
195 *
196 ******************************************************************************/
197
198void
199acpi_ut_namespace_error(const char *module_name,
200 u32 line_number,
201 const char *internal_name, acpi_status lookup_status)
202{
203 acpi_status status;
204 u32 bad_name;
205 char *name = NULL;
206
207 ACPI_MSG_REDIRECT_BEGIN;
208 acpi_os_printf(ACPI_MSG_ERROR);
209
210 if (lookup_status == AE_BAD_CHARACTER) {
211
212 /* There is a non-ascii character in the name */
213
214 ACPI_MOVE_32_TO_32(&bad_name,
215 ACPI_CAST_PTR(u32, internal_name));
216 acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name);
217 } else {
218 /* Convert path to external format */
219
220 status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
221 internal_name, NULL, &name);
222
223 /* Print target name */
224
225 if (ACPI_SUCCESS(status)) {
226 acpi_os_printf("[%s]", name);
227 } else {
228 acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
229 }
230
231 if (name) {
232 ACPI_FREE(name);
233 }
234 }
235
236 acpi_os_printf(" Namespace lookup failure, %s",
237 acpi_format_exception(lookup_status));
238
239 ACPI_MSG_SUFFIX;
240 ACPI_MSG_REDIRECT_END;
241}
242
243/*******************************************************************************
244 *
245 * FUNCTION: acpi_ut_method_error
246 *
247 * PARAMETERS: module_name - Caller's module name (for error output)
248 * line_number - Caller's line number (for error output)
249 * message - Error message to use on failure
250 * prefix_node - Prefix relative to the path
251 * path - Path to the node (optional)
252 * method_status - Execution status
253 *
254 * RETURN: None
255 *
256 * DESCRIPTION: Print error message with the full pathname for the method.
257 *
258 ******************************************************************************/
259
260void
261acpi_ut_method_error(const char *module_name,
262 u32 line_number,
263 const char *message,
264 struct acpi_namespace_node *prefix_node,
265 const char *path, acpi_status method_status)
266{
267 acpi_status status;
268 struct acpi_namespace_node *node = prefix_node;
269
270 ACPI_MSG_REDIRECT_BEGIN;
271 acpi_os_printf(ACPI_MSG_ERROR);
272
273 if (path) {
274 status =
275 acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH,
276 &node);
277 if (ACPI_FAILURE(status)) {
278 acpi_os_printf("[Could not get node by pathname]");
279 }
280 }
281
282 acpi_ns_print_node_pathname(node, message);
283 acpi_os_printf(", %s", acpi_format_exception(method_status));
284
285 ACPI_MSG_SUFFIX;
286 ACPI_MSG_REDIRECT_END;
287}
288
289#endif /* ACPI_NO_ERROR_MESSAGES */
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index c3f3a7e7bdc7..ee83adb97b1e 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -68,7 +68,7 @@ ACPI_MODULE_NAME("uteval")
68 ******************************************************************************/ 68 ******************************************************************************/
69 69
70acpi_status 70acpi_status
71acpi_ut_evaluate_object(struct acpi_namespace_node * prefix_node, 71acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
72 char *path, 72 char *path,
73 u32 expected_return_btypes, 73 u32 expected_return_btypes,
74 union acpi_operand_object **return_desc) 74 union acpi_operand_object **return_desc)
@@ -87,7 +87,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node * prefix_node,
87 } 87 }
88 88
89 info->prefix_node = prefix_node; 89 info->prefix_node = prefix_node;
90 info->pathname = path; 90 info->relative_pathname = path;
91 91
92 /* Evaluate the object/method */ 92 /* Evaluate the object/method */
93 93
@@ -123,22 +123,27 @@ acpi_ut_evaluate_object(struct acpi_namespace_node * prefix_node,
123 123
124 switch ((info->return_object)->common.type) { 124 switch ((info->return_object)->common.type) {
125 case ACPI_TYPE_INTEGER: 125 case ACPI_TYPE_INTEGER:
126
126 return_btype = ACPI_BTYPE_INTEGER; 127 return_btype = ACPI_BTYPE_INTEGER;
127 break; 128 break;
128 129
129 case ACPI_TYPE_BUFFER: 130 case ACPI_TYPE_BUFFER:
131
130 return_btype = ACPI_BTYPE_BUFFER; 132 return_btype = ACPI_BTYPE_BUFFER;
131 break; 133 break;
132 134
133 case ACPI_TYPE_STRING: 135 case ACPI_TYPE_STRING:
136
134 return_btype = ACPI_BTYPE_STRING; 137 return_btype = ACPI_BTYPE_STRING;
135 break; 138 break;
136 139
137 case ACPI_TYPE_PACKAGE: 140 case ACPI_TYPE_PACKAGE:
141
138 return_btype = ACPI_BTYPE_PACKAGE; 142 return_btype = ACPI_BTYPE_PACKAGE;
139 break; 143 break;
140 144
141 default: 145 default:
146
142 return_btype = 0; 147 return_btype = 0;
143 break; 148 break;
144 } 149 }
diff --git a/drivers/acpi/acpica/utexcep.c b/drivers/acpi/acpica/utexcep.c
index b543a144941a..ff6d9e8aa842 100644
--- a/drivers/acpi/acpica/utexcep.c
+++ b/drivers/acpi/acpica/utexcep.c
@@ -146,6 +146,7 @@ const struct acpi_exception_info *acpi_ut_validate_exception(acpi_status status)
146 break; 146 break;
147 147
148 default: 148 default:
149
149 break; 150 break;
150 } 151 }
151 152
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
index 43a170a74a61..fa69071db418 100644
--- a/drivers/acpi/acpica/utids.c
+++ b/drivers/acpi/acpica/utids.c
@@ -341,14 +341,17 @@ acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
341 341
342 switch (cid_objects[i]->common.type) { 342 switch (cid_objects[i]->common.type) {
343 case ACPI_TYPE_INTEGER: 343 case ACPI_TYPE_INTEGER:
344
344 string_area_size += ACPI_EISAID_STRING_SIZE; 345 string_area_size += ACPI_EISAID_STRING_SIZE;
345 break; 346 break;
346 347
347 case ACPI_TYPE_STRING: 348 case ACPI_TYPE_STRING:
349
348 string_area_size += cid_objects[i]->string.length + 1; 350 string_area_size += cid_objects[i]->string.length + 1;
349 break; 351 break;
350 352
351 default: 353 default:
354
352 status = AE_TYPE; 355 status = AE_TYPE;
353 goto cleanup; 356 goto cleanup;
354 } 357 }
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 785fdd07ae56..02f9101b65e4 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -382,10 +382,12 @@ acpi_ut_display_init_pathname(u8 type,
382 382
383 switch (type) { 383 switch (type) {
384 case ACPI_TYPE_METHOD: 384 case ACPI_TYPE_METHOD:
385
385 acpi_os_printf("Executing "); 386 acpi_os_printf("Executing ");
386 break; 387 break;
387 388
388 default: 389 default:
390
389 acpi_os_printf("Initializing "); 391 acpi_os_printf("Initializing ");
390 break; 392 break;
391 } 393 }
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index 1099f5c069f8..aa61f66ee861 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -129,6 +129,7 @@ union acpi_operand_object *acpi_ut_create_internal_object_dbg(const char
129 break; 129 break;
130 130
131 default: 131 default:
132
132 /* All others have no secondary object */ 133 /* All others have no secondary object */
133 break; 134 break;
134 } 135 }
@@ -353,6 +354,7 @@ u8 acpi_ut_valid_internal_object(void *object)
353 return (TRUE); 354 return (TRUE);
354 355
355 default: 356 default:
357
356 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 358 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
357 "%p is not not an ACPI operand obj [%s]\n", 359 "%p is not not an ACPI operand obj [%s]\n",
358 object, acpi_ut_get_descriptor_name(object))); 360 object, acpi_ut_get_descriptor_name(object)));
@@ -509,7 +511,6 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
509 511
510 switch (internal_object->reference.class) { 512 switch (internal_object->reference.class) {
511 case ACPI_REFCLASS_NAME: 513 case ACPI_REFCLASS_NAME:
512
513 /* 514 /*
514 * Get the actual length of the full pathname to this object. 515 * Get the actual length of the full pathname to this object.
515 * The reference will be converted to the pathname to the object 516 * The reference will be converted to the pathname to the object
@@ -525,7 +526,6 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
525 break; 526 break;
526 527
527 default: 528 default:
528
529 /* 529 /*
530 * No other reference opcodes are supported. 530 * No other reference opcodes are supported.
531 * Notably, Locals and Args are not supported, but this may be 531 * Notably, Locals and Args are not supported, but this may be
@@ -585,7 +585,6 @@ acpi_ut_get_element_length(u8 object_type,
585 585
586 switch (object_type) { 586 switch (object_type) {
587 case ACPI_COPY_TYPE_SIMPLE: 587 case ACPI_COPY_TYPE_SIMPLE:
588
589 /* 588 /*
590 * Simple object - just get the size (Null object/entry is handled 589 * Simple object - just get the size (Null object/entry is handled
591 * here also) and sum it into the running package length 590 * here also) and sum it into the running package length
diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
index 29459479148f..2b1ce4cd3207 100644
--- a/drivers/acpi/acpica/utpredef.c
+++ b/drivers/acpi/acpica/utpredef.c
@@ -147,6 +147,11 @@ void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes)
147 u32 i; 147 u32 i;
148 u32 j; 148 u32 j;
149 149
150 if (!expected_btypes) {
151 ACPI_STRCPY(buffer, "NONE");
152 return;
153 }
154
150 j = 1; 155 j = 1;
151 buffer[0] = 0; 156 buffer[0] = 0;
152 this_rtype = ACPI_RTYPE_INTEGER; 157 this_rtype = ACPI_RTYPE_INTEGER;
@@ -328,9 +333,7 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
328 333
329 /* First field in the types list is the count of args to follow */ 334 /* First field in the types list is the count of args to follow */
330 335
331 arg_count = (argument_types & METHOD_ARG_MASK); 336 arg_count = METHOD_GET_ARG_COUNT(argument_types);
332 argument_types >>= METHOD_ARG_BIT_WIDTH;
333
334 if (arg_count > METHOD_PREDEF_ARGS_MAX) { 337 if (arg_count > METHOD_PREDEF_ARGS_MAX) {
335 printf("**** Invalid argument count (%u) " 338 printf("**** Invalid argument count (%u) "
336 "in predefined info structure\n", arg_count); 339 "in predefined info structure\n", arg_count);
@@ -340,7 +343,8 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
340 /* Get each argument from the list, convert to ascii, store to buffer */ 343 /* Get each argument from the list, convert to ascii, store to buffer */
341 344
342 for (i = 0; i < arg_count; i++) { 345 for (i = 0; i < arg_count; i++) {
343 this_argument_type = (argument_types & METHOD_ARG_MASK); 346 this_argument_type = METHOD_GET_NEXT_TYPE(argument_types);
347
344 if (!this_argument_type 348 if (!this_argument_type
345 || (this_argument_type > METHOD_MAX_ARG_TYPE)) { 349 || (this_argument_type > METHOD_MAX_ARG_TYPE)) {
346 printf("**** Invalid argument type (%u) " 350 printf("**** Invalid argument type (%u) "
@@ -351,10 +355,6 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
351 355
352 strcat(buffer, 356 strcat(buffer,
353 ut_external_type_names[this_argument_type] + sub_index); 357 ut_external_type_names[this_argument_type] + sub_index);
354
355 /* Shift to next argument type field */
356
357 argument_types >>= METHOD_ARG_BIT_WIDTH;
358 sub_index = 0; 358 sub_index = 0;
359 } 359 }
360 360
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c
index b3e36a81aa4d..c53759b76a3f 100644
--- a/drivers/acpi/acpica/utstring.c
+++ b/drivers/acpi/acpica/utstring.c
@@ -186,10 +186,13 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
186 switch (base) { 186 switch (base) {
187 case ACPI_ANY_BASE: 187 case ACPI_ANY_BASE:
188 case 16: 188 case 16:
189
189 break; 190 break;
190 191
191 default: 192 default:
193
192 /* Invalid Base */ 194 /* Invalid Base */
195
193 return_ACPI_STATUS(AE_BAD_PARAMETER); 196 return_ACPI_STATUS(AE_BAD_PARAMETER);
194 } 197 }
195 198
@@ -355,36 +358,44 @@ void acpi_ut_print_string(char *string, u8 max_length)
355 358
356 switch (string[i]) { 359 switch (string[i]) {
357 case 0x07: 360 case 0x07:
361
358 acpi_os_printf("\\a"); /* BELL */ 362 acpi_os_printf("\\a"); /* BELL */
359 break; 363 break;
360 364
361 case 0x08: 365 case 0x08:
366
362 acpi_os_printf("\\b"); /* BACKSPACE */ 367 acpi_os_printf("\\b"); /* BACKSPACE */
363 break; 368 break;
364 369
365 case 0x0C: 370 case 0x0C:
371
366 acpi_os_printf("\\f"); /* FORMFEED */ 372 acpi_os_printf("\\f"); /* FORMFEED */
367 break; 373 break;
368 374
369 case 0x0A: 375 case 0x0A:
376
370 acpi_os_printf("\\n"); /* LINEFEED */ 377 acpi_os_printf("\\n"); /* LINEFEED */
371 break; 378 break;
372 379
373 case 0x0D: 380 case 0x0D:
381
374 acpi_os_printf("\\r"); /* CARRIAGE RETURN */ 382 acpi_os_printf("\\r"); /* CARRIAGE RETURN */
375 break; 383 break;
376 384
377 case 0x09: 385 case 0x09:
386
378 acpi_os_printf("\\t"); /* HORIZONTAL TAB */ 387 acpi_os_printf("\\t"); /* HORIZONTAL TAB */
379 break; 388 break;
380 389
381 case 0x0B: 390 case 0x0B:
391
382 acpi_os_printf("\\v"); /* VERTICAL TAB */ 392 acpi_os_printf("\\v"); /* VERTICAL TAB */
383 break; 393 break;
384 394
385 case '\'': /* Single Quote */ 395 case '\'': /* Single Quote */
386 case '\"': /* Double Quote */ 396 case '\"': /* Double Quote */
387 case '\\': /* Backslash */ 397 case '\\': /* Backslash */
398
388 acpi_os_printf("\\%c", (int)string[i]); 399 acpi_os_printf("\\%c", (int)string[i]);
389 break; 400 break;
390 401
@@ -451,7 +462,8 @@ u8 acpi_ut_valid_acpi_char(char character, u32 position)
451 * 462 *
452 * FUNCTION: acpi_ut_valid_acpi_name 463 * FUNCTION: acpi_ut_valid_acpi_name
453 * 464 *
454 * PARAMETERS: name - The name to be examined 465 * PARAMETERS: name - The name to be examined. Does not have to
466 * be NULL terminated string.
455 * 467 *
456 * RETURN: TRUE if the name is valid, FALSE otherwise 468 * RETURN: TRUE if the name is valid, FALSE otherwise
457 * 469 *
@@ -462,15 +474,14 @@ u8 acpi_ut_valid_acpi_char(char character, u32 position)
462 * 474 *
463 ******************************************************************************/ 475 ******************************************************************************/
464 476
465u8 acpi_ut_valid_acpi_name(u32 name) 477u8 acpi_ut_valid_acpi_name(char *name)
466{ 478{
467 u32 i; 479 u32 i;
468 480
469 ACPI_FUNCTION_ENTRY(); 481 ACPI_FUNCTION_ENTRY();
470 482
471 for (i = 0; i < ACPI_NAME_SIZE; i++) { 483 for (i = 0; i < ACPI_NAME_SIZE; i++) {
472 if (!acpi_ut_valid_acpi_char 484 if (!acpi_ut_valid_acpi_char(name[i], i)) {
473 ((ACPI_CAST_PTR(char, &name))[i], i)) {
474 return (FALSE); 485 return (FALSE);
475 } 486 }
476 } 487 }
diff --git a/drivers/acpi/acpica/uttrack.c b/drivers/acpi/acpica/uttrack.c
index 62774c7b76a8..160f13f4aab5 100644
--- a/drivers/acpi/acpica/uttrack.c
+++ b/drivers/acpi/acpica/uttrack.c
@@ -603,6 +603,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
603 switch (ACPI_GET_DESCRIPTOR_TYPE 603 switch (ACPI_GET_DESCRIPTOR_TYPE
604 (descriptor)) { 604 (descriptor)) {
605 case ACPI_DESC_TYPE_OPERAND: 605 case ACPI_DESC_TYPE_OPERAND:
606
606 if (element->size == 607 if (element->size ==
607 sizeof(union 608 sizeof(union
608 acpi_operand_object)) 609 acpi_operand_object))
@@ -613,6 +614,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
613 break; 614 break;
614 615
615 case ACPI_DESC_TYPE_PARSER: 616 case ACPI_DESC_TYPE_PARSER:
617
616 if (element->size == 618 if (element->size ==
617 sizeof(union 619 sizeof(union
618 acpi_parse_object)) { 620 acpi_parse_object)) {
@@ -622,6 +624,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
622 break; 624 break;
623 625
624 case ACPI_DESC_TYPE_NAMED: 626 case ACPI_DESC_TYPE_NAMED:
627
625 if (element->size == 628 if (element->size ==
626 sizeof(struct 629 sizeof(struct
627 acpi_namespace_node)) 630 acpi_namespace_node))
@@ -632,6 +635,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
632 break; 635 break;
633 636
634 default: 637 default:
638
635 break; 639 break;
636 } 640 }
637 641
@@ -639,6 +643,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
639 643
640 switch (descriptor_type) { 644 switch (descriptor_type) {
641 case ACPI_DESC_TYPE_OPERAND: 645 case ACPI_DESC_TYPE_OPERAND:
646
642 acpi_os_printf 647 acpi_os_printf
643 ("%12.12s RefCount 0x%04X\n", 648 ("%12.12s RefCount 0x%04X\n",
644 acpi_ut_get_type_name 649 acpi_ut_get_type_name
@@ -649,6 +654,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
649 break; 654 break;
650 655
651 case ACPI_DESC_TYPE_PARSER: 656 case ACPI_DESC_TYPE_PARSER:
657
652 acpi_os_printf 658 acpi_os_printf
653 ("AmlOpcode 0x%04hX\n", 659 ("AmlOpcode 0x%04hX\n",
654 descriptor->op.asl. 660 descriptor->op.asl.
@@ -656,6 +662,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
656 break; 662 break;
657 663
658 case ACPI_DESC_TYPE_NAMED: 664 case ACPI_DESC_TYPE_NAMED:
665
659 acpi_os_printf("%4.4s\n", 666 acpi_os_printf("%4.4s\n",
660 acpi_ut_get_node_name 667 acpi_ut_get_node_name
661 (&descriptor-> 668 (&descriptor->
@@ -663,6 +670,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
663 break; 670 break;
664 671
665 default: 672 default:
673
666 acpi_os_printf("\n"); 674 acpi_os_printf("\n");
667 break; 675 break;
668 } 676 }
diff --git a/drivers/acpi/acpica/utxferror.c b/drivers/acpi/acpica/utxferror.c
index 976b6c734fce..e966a2e47b76 100644
--- a/drivers/acpi/acpica/utxferror.c
+++ b/drivers/acpi/acpica/utxferror.c
@@ -44,7 +44,6 @@
44#include <linux/export.h> 44#include <linux/export.h>
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h"
48 47
49#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utxferror") 49ACPI_MODULE_NAME("utxferror")
@@ -52,43 +51,7 @@ ACPI_MODULE_NAME("utxferror")
52/* 51/*
53 * This module is used for the in-kernel ACPICA as well as the ACPICA 52 * This module is used for the in-kernel ACPICA as well as the ACPICA
54 * tools/applications. 53 * tools/applications.
55 *
56 * For the iASL compiler case, the output is redirected to stderr so that
57 * any of the various ACPI errors and warnings do not appear in the output
58 * files, for either the compiler or disassembler portions of the tool.
59 */ 54 */
60#ifdef ACPI_ASL_COMPILER
61#include <stdio.h>
62extern FILE *acpi_gbl_output_file;
63
64#define ACPI_MSG_REDIRECT_BEGIN \
65 FILE *output_file = acpi_gbl_output_file; \
66 acpi_os_redirect_output (stderr);
67
68#define ACPI_MSG_REDIRECT_END \
69 acpi_os_redirect_output (output_file);
70
71#else
72/*
73 * non-iASL case - no redirection, nothing to do
74 */
75#define ACPI_MSG_REDIRECT_BEGIN
76#define ACPI_MSG_REDIRECT_END
77#endif
78/*
79 * Common message prefixes
80 */
81#define ACPI_MSG_ERROR "ACPI Error: "
82#define ACPI_MSG_EXCEPTION "ACPI Exception: "
83#define ACPI_MSG_WARNING "ACPI Warning: "
84#define ACPI_MSG_INFO "ACPI: "
85#define ACPI_MSG_BIOS_ERROR "ACPI BIOS Bug: Error: "
86#define ACPI_MSG_BIOS_WARNING "ACPI BIOS Bug: Warning: "
87/*
88 * Common message suffix
89 */
90#define ACPI_MSG_SUFFIX \
91 acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number)
92/******************************************************************************* 55/*******************************************************************************
93 * 56 *
94 * FUNCTION: acpi_error 57 * FUNCTION: acpi_error
@@ -285,200 +248,3 @@ acpi_bios_warning(const char *module_name,
285} 248}
286 249
287ACPI_EXPORT_SYMBOL(acpi_bios_warning) 250ACPI_EXPORT_SYMBOL(acpi_bios_warning)
288
289/*
290 * The remainder of this module contains internal error functions that may
291 * be configured out.
292 */
293#if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
294/*******************************************************************************
295 *
296 * FUNCTION: acpi_ut_predefined_warning
297 *
298 * PARAMETERS: module_name - Caller's module name (for error output)
299 * line_number - Caller's line number (for error output)
300 * pathname - Full pathname to the node
301 * node_flags - From Namespace node for the method/object
302 * format - Printf format string + additional args
303 *
304 * RETURN: None
305 *
306 * DESCRIPTION: Warnings for the predefined validation module. Messages are
307 * only emitted the first time a problem with a particular
308 * method/object is detected. This prevents a flood of error
309 * messages for methods that are repeatedly evaluated.
310 *
311 ******************************************************************************/
312void ACPI_INTERNAL_VAR_XFACE
313acpi_ut_predefined_warning(const char *module_name,
314 u32 line_number,
315 char *pathname,
316 u8 node_flags, const char *format, ...)
317{
318 va_list arg_list;
319
320 /*
321 * Warning messages for this method/object will be disabled after the
322 * first time a validation fails or an object is successfully repaired.
323 */
324 if (node_flags & ANOBJ_EVALUATED) {
325 return;
326 }
327
328 acpi_os_printf(ACPI_MSG_WARNING "For %s: ", pathname);
329
330 va_start(arg_list, format);
331 acpi_os_vprintf(format, arg_list);
332 ACPI_MSG_SUFFIX;
333 va_end(arg_list);
334}
335
336/*******************************************************************************
337 *
338 * FUNCTION: acpi_ut_predefined_info
339 *
340 * PARAMETERS: module_name - Caller's module name (for error output)
341 * line_number - Caller's line number (for error output)
342 * pathname - Full pathname to the node
343 * node_flags - From Namespace node for the method/object
344 * format - Printf format string + additional args
345 *
346 * RETURN: None
347 *
348 * DESCRIPTION: Info messages for the predefined validation module. Messages
349 * are only emitted the first time a problem with a particular
350 * method/object is detected. This prevents a flood of
351 * messages for methods that are repeatedly evaluated.
352 *
353 ******************************************************************************/
354
355void ACPI_INTERNAL_VAR_XFACE
356acpi_ut_predefined_info(const char *module_name,
357 u32 line_number,
358 char *pathname, u8 node_flags, const char *format, ...)
359{
360 va_list arg_list;
361
362 /*
363 * Warning messages for this method/object will be disabled after the
364 * first time a validation fails or an object is successfully repaired.
365 */
366 if (node_flags & ANOBJ_EVALUATED) {
367 return;
368 }
369
370 acpi_os_printf(ACPI_MSG_INFO "For %s: ", pathname);
371
372 va_start(arg_list, format);
373 acpi_os_vprintf(format, arg_list);
374 ACPI_MSG_SUFFIX;
375 va_end(arg_list);
376}
377
378/*******************************************************************************
379 *
380 * FUNCTION: acpi_ut_namespace_error
381 *
382 * PARAMETERS: module_name - Caller's module name (for error output)
383 * line_number - Caller's line number (for error output)
384 * internal_name - Name or path of the namespace node
385 * lookup_status - Exception code from NS lookup
386 *
387 * RETURN: None
388 *
389 * DESCRIPTION: Print error message with the full pathname for the NS node.
390 *
391 ******************************************************************************/
392
393void
394acpi_ut_namespace_error(const char *module_name,
395 u32 line_number,
396 const char *internal_name, acpi_status lookup_status)
397{
398 acpi_status status;
399 u32 bad_name;
400 char *name = NULL;
401
402 ACPI_MSG_REDIRECT_BEGIN;
403 acpi_os_printf(ACPI_MSG_ERROR);
404
405 if (lookup_status == AE_BAD_CHARACTER) {
406
407 /* There is a non-ascii character in the name */
408
409 ACPI_MOVE_32_TO_32(&bad_name,
410 ACPI_CAST_PTR(u32, internal_name));
411 acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name);
412 } else {
413 /* Convert path to external format */
414
415 status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
416 internal_name, NULL, &name);
417
418 /* Print target name */
419
420 if (ACPI_SUCCESS(status)) {
421 acpi_os_printf("[%s]", name);
422 } else {
423 acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
424 }
425
426 if (name) {
427 ACPI_FREE(name);
428 }
429 }
430
431 acpi_os_printf(" Namespace lookup failure, %s",
432 acpi_format_exception(lookup_status));
433
434 ACPI_MSG_SUFFIX;
435 ACPI_MSG_REDIRECT_END;
436}
437
438/*******************************************************************************
439 *
440 * FUNCTION: acpi_ut_method_error
441 *
442 * PARAMETERS: module_name - Caller's module name (for error output)
443 * line_number - Caller's line number (for error output)
444 * message - Error message to use on failure
445 * prefix_node - Prefix relative to the path
446 * path - Path to the node (optional)
447 * method_status - Execution status
448 *
449 * RETURN: None
450 *
451 * DESCRIPTION: Print error message with the full pathname for the method.
452 *
453 ******************************************************************************/
454
455void
456acpi_ut_method_error(const char *module_name,
457 u32 line_number,
458 const char *message,
459 struct acpi_namespace_node *prefix_node,
460 const char *path, acpi_status method_status)
461{
462 acpi_status status;
463 struct acpi_namespace_node *node = prefix_node;
464
465 ACPI_MSG_REDIRECT_BEGIN;
466 acpi_os_printf(ACPI_MSG_ERROR);
467
468 if (path) {
469 status =
470 acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH,
471 &node);
472 if (ACPI_FAILURE(status)) {
473 acpi_os_printf("[Could not get node by pathname]");
474 }
475 }
476
477 acpi_ns_print_node_pathname(node, message);
478 acpi_os_printf(", %s", acpi_format_exception(method_status));
479
480 ACPI_MSG_SUFFIX;
481 ACPI_MSG_REDIRECT_END;
482}
483
484#endif /* ACPI_NO_ERROR_MESSAGES */
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index 8d457b55c55a..fb57d03e698b 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -32,6 +32,7 @@
32#include <linux/seq_file.h> 32#include <linux/seq_file.h>
33#include <linux/nmi.h> 33#include <linux/nmi.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/mm.h>
35#include <acpi/acpi.h> 36#include <acpi/acpi.h>
36 37
37#include "apei-internal.h" 38#include "apei-internal.h"
@@ -41,6 +42,10 @@
41#define SPIN_UNIT 100 /* 100ns */ 42#define SPIN_UNIT 100 /* 100ns */
42/* Firmware should respond within 1 milliseconds */ 43/* Firmware should respond within 1 milliseconds */
43#define FIRMWARE_TIMEOUT (1 * NSEC_PER_MSEC) 44#define FIRMWARE_TIMEOUT (1 * NSEC_PER_MSEC)
45#define ACPI5_VENDOR_BIT BIT(31)
46#define MEM_ERROR_MASK (ACPI_EINJ_MEMORY_CORRECTABLE | \
47 ACPI_EINJ_MEMORY_UNCORRECTABLE | \
48 ACPI_EINJ_MEMORY_FATAL)
44 49
45/* 50/*
46 * ACPI version 5 provides a SET_ERROR_TYPE_WITH_ADDRESS action. 51 * ACPI version 5 provides a SET_ERROR_TYPE_WITH_ADDRESS action.
@@ -367,7 +372,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
367 * This will cause resource conflict with regular memory. So 372 * This will cause resource conflict with regular memory. So
368 * remove it from trigger table resources. 373 * remove it from trigger table resources.
369 */ 374 */
370 if ((param_extension || acpi5) && (type & 0x0038) && param2) { 375 if ((param_extension || acpi5) && (type & MEM_ERROR_MASK) && param2) {
371 struct apei_resources addr_resources; 376 struct apei_resources addr_resources;
372 apei_resources_init(&addr_resources); 377 apei_resources_init(&addr_resources);
373 trigger_param_region = einj_get_trigger_parameter_region( 378 trigger_param_region = einj_get_trigger_parameter_region(
@@ -427,7 +432,7 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2)
427 struct set_error_type_with_address *v5param = einj_param; 432 struct set_error_type_with_address *v5param = einj_param;
428 433
429 v5param->type = type; 434 v5param->type = type;
430 if (type & 0x80000000) { 435 if (type & ACPI5_VENDOR_BIT) {
431 switch (vendor_flags) { 436 switch (vendor_flags) {
432 case SETWA_FLAGS_APICID: 437 case SETWA_FLAGS_APICID:
433 v5param->apicid = param1; 438 v5param->apicid = param1;
@@ -512,7 +517,34 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2)
512static int einj_error_inject(u32 type, u64 param1, u64 param2) 517static int einj_error_inject(u32 type, u64 param1, u64 param2)
513{ 518{
514 int rc; 519 int rc;
520 unsigned long pfn;
515 521
522 /*
523 * We need extra sanity checks for memory errors.
524 * Other types leap directly to injection.
525 */
526
527 /* ensure param1/param2 existed */
528 if (!(param_extension || acpi5))
529 goto inject;
530
531 /* ensure injection is memory related */
532 if (type & ACPI5_VENDOR_BIT) {
533 if (vendor_flags != SETWA_FLAGS_MEM)
534 goto inject;
535 } else if (!(type & MEM_ERROR_MASK))
536 goto inject;
537
538 /*
539 * Disallow crazy address masks that give BIOS leeway to pick
540 * injection address almost anywhere. Insist on page or
541 * better granularity and that target address is normal RAM.
542 */
543 pfn = PFN_DOWN(param1 & param2);
544 if (!page_is_ram(pfn) || ((param2 & PAGE_MASK) != PAGE_MASK))
545 return -EINVAL;
546
547inject:
516 mutex_lock(&einj_mutex); 548 mutex_lock(&einj_mutex);
517 rc = __einj_error_inject(type, param1, param2); 549 rc = __einj_error_inject(type, param1, param2);
518 mutex_unlock(&einj_mutex); 550 mutex_unlock(&einj_mutex);
@@ -590,7 +622,7 @@ static int error_type_set(void *data, u64 val)
590 * Vendor defined types have 0x80000000 bit set, and 622 * Vendor defined types have 0x80000000 bit set, and
591 * are not enumerated by ACPI_EINJ_GET_ERROR_TYPE 623 * are not enumerated by ACPI_EINJ_GET_ERROR_TYPE
592 */ 624 */
593 vendor = val & 0x80000000; 625 vendor = val & ACPI5_VENDOR_BIT;
594 tval = val & 0x7fffffff; 626 tval = val & 0x7fffffff;
595 627
596 /* Only one error type can be specified */ 628 /* Only one error type can be specified */
@@ -694,6 +726,7 @@ static int __init einj_init(void)
694 if (rc) 726 if (rc)
695 goto err_release; 727 goto err_release;
696 728
729 rc = -ENOMEM;
697 einj_param = einj_get_parameter_address(); 730 einj_param = einj_get_parameter_address();
698 if ((param_extension || acpi5) && einj_param) { 731 if ((param_extension || acpi5) && einj_param) {
699 fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR, 732 fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR,
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
index 6d894bfd8b8f..40ffcdafbc6f 100644
--- a/drivers/acpi/apei/erst.c
+++ b/drivers/acpi/apei/erst.c
@@ -39,7 +39,8 @@
39 39
40#include "apei-internal.h" 40#include "apei-internal.h"
41 41
42#define ERST_PFX "ERST: " 42#undef pr_fmt
43#define pr_fmt(fmt) "ERST: " fmt
43 44
44/* ERST command status */ 45/* ERST command status */
45#define ERST_STATUS_SUCCESS 0x0 46#define ERST_STATUS_SUCCESS 0x0
@@ -109,8 +110,7 @@ static inline int erst_errno(int command_status)
109static int erst_timedout(u64 *t, u64 spin_unit) 110static int erst_timedout(u64 *t, u64 spin_unit)
110{ 111{
111 if ((s64)*t < spin_unit) { 112 if ((s64)*t < spin_unit) {
112 pr_warning(FW_WARN ERST_PFX 113 pr_warn(FW_WARN "Firmware does not respond in time.\n");
113 "Firmware does not respond in time\n");
114 return 1; 114 return 1;
115 } 115 }
116 *t -= spin_unit; 116 *t -= spin_unit;
@@ -186,8 +186,8 @@ static int erst_exec_stall(struct apei_exec_context *ctx,
186 186
187 if (ctx->value > FIRMWARE_MAX_STALL) { 187 if (ctx->value > FIRMWARE_MAX_STALL) {
188 if (!in_nmi()) 188 if (!in_nmi())
189 pr_warning(FW_WARN ERST_PFX 189 pr_warn(FW_WARN
190 "Too long stall time for stall instruction: %llx.\n", 190 "Too long stall time for stall instruction: 0x%llx.\n",
191 ctx->value); 191 ctx->value);
192 stall_time = FIRMWARE_MAX_STALL; 192 stall_time = FIRMWARE_MAX_STALL;
193 } else 193 } else
@@ -206,8 +206,8 @@ static int erst_exec_stall_while_true(struct apei_exec_context *ctx,
206 206
207 if (ctx->var1 > FIRMWARE_MAX_STALL) { 207 if (ctx->var1 > FIRMWARE_MAX_STALL) {
208 if (!in_nmi()) 208 if (!in_nmi())
209 pr_warning(FW_WARN ERST_PFX 209 pr_warn(FW_WARN
210 "Too long stall time for stall while true instruction: %llx.\n", 210 "Too long stall time for stall while true instruction: 0x%llx.\n",
211 ctx->var1); 211 ctx->var1);
212 stall_time = FIRMWARE_MAX_STALL; 212 stall_time = FIRMWARE_MAX_STALL;
213 } else 213 } else
@@ -271,8 +271,7 @@ static int erst_exec_move_data(struct apei_exec_context *ctx,
271 271
272 /* ioremap does not work in interrupt context */ 272 /* ioremap does not work in interrupt context */
273 if (in_interrupt()) { 273 if (in_interrupt()) {
274 pr_warning(ERST_PFX 274 pr_warn("MOVE_DATA can not be used in interrupt context.\n");
275 "MOVE_DATA can not be used in interrupt context");
276 return -EBUSY; 275 return -EBUSY;
277 } 276 }
278 277
@@ -522,8 +521,7 @@ retry:
522 ERST_RECORD_ID_CACHE_SIZE_MAX); 521 ERST_RECORD_ID_CACHE_SIZE_MAX);
523 if (new_size <= erst_record_id_cache.size) { 522 if (new_size <= erst_record_id_cache.size) {
524 if (printk_ratelimit()) 523 if (printk_ratelimit())
525 pr_warning(FW_WARN ERST_PFX 524 pr_warn(FW_WARN "too many record IDs!\n");
526 "too many record ID!\n");
527 return 0; 525 return 0;
528 } 526 }
529 alloc_size = new_size * sizeof(entries[0]); 527 alloc_size = new_size * sizeof(entries[0]);
@@ -759,8 +757,7 @@ static int __erst_clear_from_storage(u64 record_id)
759static void pr_unimpl_nvram(void) 757static void pr_unimpl_nvram(void)
760{ 758{
761 if (printk_ratelimit()) 759 if (printk_ratelimit())
762 pr_warning(ERST_PFX 760 pr_warn("NVRAM ERST Log Address Range not implemented yet.\n");
763 "NVRAM ERST Log Address Range is not implemented yet\n");
764} 761}
765 762
766static int __erst_write_to_nvram(const struct cper_record_header *record) 763static int __erst_write_to_nvram(const struct cper_record_header *record)
@@ -935,7 +932,7 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,
935 struct timespec *time, char **buf, 932 struct timespec *time, char **buf,
936 struct pstore_info *psi); 933 struct pstore_info *psi);
937static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason, 934static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
938 u64 *id, unsigned int part, int count, 935 u64 *id, unsigned int part, int count, size_t hsize,
939 size_t size, struct pstore_info *psi); 936 size_t size, struct pstore_info *psi);
940static int erst_clearer(enum pstore_type_id type, u64 id, int count, 937static int erst_clearer(enum pstore_type_id type, u64 id, int count,
941 struct timespec time, struct pstore_info *psi); 938 struct timespec time, struct pstore_info *psi);
@@ -1055,7 +1052,7 @@ out:
1055} 1052}
1056 1053
1057static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason, 1054static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
1058 u64 *id, unsigned int part, int count, 1055 u64 *id, unsigned int part, int count, size_t hsize,
1059 size_t size, struct pstore_info *psi) 1056 size_t size, struct pstore_info *psi)
1060{ 1057{
1061 struct cper_pstore_record *rcd = (struct cper_pstore_record *) 1058 struct cper_pstore_record *rcd = (struct cper_pstore_record *)
@@ -1120,7 +1117,7 @@ static int __init erst_init(void)
1120 goto err; 1117 goto err;
1121 1118
1122 if (erst_disable) { 1119 if (erst_disable) {
1123 pr_info(ERST_PFX 1120 pr_info(
1124 "Error Record Serialization Table (ERST) support is disabled.\n"); 1121 "Error Record Serialization Table (ERST) support is disabled.\n");
1125 goto err; 1122 goto err;
1126 } 1123 }
@@ -1131,14 +1128,14 @@ static int __init erst_init(void)
1131 goto err; 1128 goto err;
1132 else if (ACPI_FAILURE(status)) { 1129 else if (ACPI_FAILURE(status)) {
1133 const char *msg = acpi_format_exception(status); 1130 const char *msg = acpi_format_exception(status);
1134 pr_err(ERST_PFX "Failed to get table, %s\n", msg); 1131 pr_err("Failed to get table, %s\n", msg);
1135 rc = -EINVAL; 1132 rc = -EINVAL;
1136 goto err; 1133 goto err;
1137 } 1134 }
1138 1135
1139 rc = erst_check_table(erst_tab); 1136 rc = erst_check_table(erst_tab);
1140 if (rc) { 1137 if (rc) {
1141 pr_err(FW_BUG ERST_PFX "ERST table is invalid\n"); 1138 pr_err(FW_BUG "ERST table is invalid.\n");
1142 goto err; 1139 goto err;
1143 } 1140 }
1144 1141
@@ -1156,21 +1153,19 @@ static int __init erst_init(void)
1156 rc = erst_get_erange(&erst_erange); 1153 rc = erst_get_erange(&erst_erange);
1157 if (rc) { 1154 if (rc) {
1158 if (rc == -ENODEV) 1155 if (rc == -ENODEV)
1159 pr_info(ERST_PFX 1156 pr_info(
1160 "The corresponding hardware device or firmware implementation " 1157 "The corresponding hardware device or firmware implementation "
1161 "is not available.\n"); 1158 "is not available.\n");
1162 else 1159 else
1163 pr_err(ERST_PFX 1160 pr_err("Failed to get Error Log Address Range.\n");
1164 "Failed to get Error Log Address Range.\n");
1165 goto err_unmap_reg; 1161 goto err_unmap_reg;
1166 } 1162 }
1167 1163
1168 r = request_mem_region(erst_erange.base, erst_erange.size, "APEI ERST"); 1164 r = request_mem_region(erst_erange.base, erst_erange.size, "APEI ERST");
1169 if (!r) { 1165 if (!r) {
1170 pr_err(ERST_PFX 1166 pr_err("Can not request [mem %#010llx-%#010llx] for ERST.\n",
1171 "Can not request iomem region <0x%16llx-0x%16llx> for ERST.\n", 1167 (unsigned long long)erst_erange.base,
1172 (unsigned long long)erst_erange.base, 1168 (unsigned long long)erst_erange.base + erst_erange.size - 1);
1173 (unsigned long long)erst_erange.base + erst_erange.size);
1174 rc = -EIO; 1169 rc = -EIO;
1175 goto err_unmap_reg; 1170 goto err_unmap_reg;
1176 } 1171 }
@@ -1180,20 +1175,28 @@ static int __init erst_init(void)
1180 if (!erst_erange.vaddr) 1175 if (!erst_erange.vaddr)
1181 goto err_release_erange; 1176 goto err_release_erange;
1182 1177
1178 pr_info(
1179 "Error Record Serialization Table (ERST) support is initialized.\n");
1180
1183 buf = kmalloc(erst_erange.size, GFP_KERNEL); 1181 buf = kmalloc(erst_erange.size, GFP_KERNEL);
1184 spin_lock_init(&erst_info.buf_lock); 1182 spin_lock_init(&erst_info.buf_lock);
1185 if (buf) { 1183 if (buf) {
1186 erst_info.buf = buf + sizeof(struct cper_pstore_record); 1184 erst_info.buf = buf + sizeof(struct cper_pstore_record);
1187 erst_info.bufsize = erst_erange.size - 1185 erst_info.bufsize = erst_erange.size -
1188 sizeof(struct cper_pstore_record); 1186 sizeof(struct cper_pstore_record);
1189 if (pstore_register(&erst_info)) { 1187 rc = pstore_register(&erst_info);
1190 pr_info(ERST_PFX "Could not register with persistent store\n"); 1188 if (rc) {
1189 if (rc != -EPERM)
1190 pr_info(
1191 "Could not register with persistent store.\n");
1192 erst_info.buf = NULL;
1193 erst_info.bufsize = 0;
1191 kfree(buf); 1194 kfree(buf);
1192 } 1195 }
1193 } 1196 } else
1194 1197 pr_err(
1195 pr_info(ERST_PFX 1198 "Failed to allocate %lld bytes for persistent store error log.\n",
1196 "Error Record Serialization Table (ERST) support is initialized.\n"); 1199 erst_erange.size);
1197 1200
1198 return 0; 1201 return 0;
1199 1202
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index a8f362acc8ec..8ec37bbdd699 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -469,9 +469,19 @@ static void ghes_do_proc(struct ghes *ghes,
469 pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO) { 469 pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO) {
470 unsigned int devfn; 470 unsigned int devfn;
471 int aer_severity; 471 int aer_severity;
472
472 devfn = PCI_DEVFN(pcie_err->device_id.device, 473 devfn = PCI_DEVFN(pcie_err->device_id.device,
473 pcie_err->device_id.function); 474 pcie_err->device_id.function);
474 aer_severity = cper_severity_to_aer(sev); 475 aer_severity = cper_severity_to_aer(sev);
476
477 /*
478 * If firmware reset the component to contain
479 * the error, we must reinitialize it before
480 * use, so treat it as a fatal AER error.
481 */
482 if (gdata->flags & CPER_SEC_RESET)
483 aer_severity = AER_FATAL;
484
475 aer_recover_queue(pcie_err->device_id.segment, 485 aer_recover_queue(pcie_err->device_id.segment,
476 pcie_err->device_id.bus, 486 pcie_err->device_id.bus,
477 devfn, aer_severity, 487 devfn, aer_severity,
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index e7100459ac4a..082b4dd252a8 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -425,7 +425,7 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
425{ 425{
426 int result = -EFAULT; 426 int result = -EFAULT;
427 acpi_status status = 0; 427 acpi_status status = 0;
428 char *name = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)? 428 char *name = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags) ?
429 "_BIX" : "_BIF"; 429 "_BIX" : "_BIF";
430 430
431 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 431 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -661,11 +661,11 @@ static void find_battery(const struct dmi_header *dm, void *private)
661static void acpi_battery_quirks(struct acpi_battery *battery) 661static void acpi_battery_quirks(struct acpi_battery *battery)
662{ 662{
663 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)) 663 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags))
664 return ; 664 return;
665 665
666 if (battery->full_charge_capacity == 100 && 666 if (battery->full_charge_capacity == 100 &&
667 battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN && 667 battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN &&
668 battery->capacity_now >=0 && battery->capacity_now <= 100) { 668 battery->capacity_now >= 0 && battery->capacity_now <= 100) {
669 set_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags); 669 set_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags);
670 battery->full_charge_capacity = battery->design_capacity; 670 battery->full_charge_capacity = battery->design_capacity;
671 battery->capacity_now = (battery->capacity_now * 671 battery->capacity_now = (battery->capacity_now *
@@ -673,7 +673,7 @@ static void acpi_battery_quirks(struct acpi_battery *battery)
673 } 673 }
674 674
675 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags)) 675 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags))
676 return ; 676 return;
677 677
678 if (battery->power_unit && dmi_name_in_vendors("LENOVO")) { 678 if (battery->power_unit && dmi_name_in_vendors("LENOVO")) {
679 const char *s; 679 const char *s;
@@ -761,7 +761,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
761 goto end; 761 goto end;
762 762
763 seq_printf(seq, "present: %s\n", 763 seq_printf(seq, "present: %s\n",
764 acpi_battery_present(battery)?"yes":"no"); 764 acpi_battery_present(battery) ? "yes" : "no");
765 if (!acpi_battery_present(battery)) 765 if (!acpi_battery_present(battery))
766 goto end; 766 goto end;
767 if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) 767 if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
@@ -817,12 +817,12 @@ static int acpi_battery_print_state(struct seq_file *seq, int result)
817 goto end; 817 goto end;
818 818
819 seq_printf(seq, "present: %s\n", 819 seq_printf(seq, "present: %s\n",
820 acpi_battery_present(battery)?"yes":"no"); 820 acpi_battery_present(battery) ? "yes" : "no");
821 if (!acpi_battery_present(battery)) 821 if (!acpi_battery_present(battery))
822 goto end; 822 goto end;
823 823
824 seq_printf(seq, "capacity state: %s\n", 824 seq_printf(seq, "capacity state: %s\n",
825 (battery->state & 0x04)?"critical":"ok"); 825 (battery->state & 0x04) ? "critical" : "ok");
826 if ((battery->state & 0x01) && (battery->state & 0x02)) 826 if ((battery->state & 0x01) && (battery->state & 0x02))
827 seq_printf(seq, 827 seq_printf(seq,
828 "charging state: charging/discharging\n"); 828 "charging state: charging/discharging\n");
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 292de3cab9cc..a5bb33bab448 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -91,8 +91,7 @@ static struct dmi_system_id dsdt_dmi_table[] __initdata = {
91 91
92int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) 92int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
93{ 93{
94 acpi_status status = AE_OK; 94 acpi_status status;
95
96 95
97 if (!device) 96 if (!device)
98 return -EINVAL; 97 return -EINVAL;
@@ -162,7 +161,7 @@ EXPORT_SYMBOL(acpi_bus_private_data_handler);
162 161
163int acpi_bus_get_private_data(acpi_handle handle, void **data) 162int acpi_bus_get_private_data(acpi_handle handle, void **data)
164{ 163{
165 acpi_status status = AE_OK; 164 acpi_status status;
166 165
167 if (!*data) 166 if (!*data)
168 return -EINVAL; 167 return -EINVAL;
@@ -361,7 +360,7 @@ extern int event_is_open;
361int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id, u8 type, int data) 360int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id, u8 type, int data)
362{ 361{
363 struct acpi_bus_event *event; 362 struct acpi_bus_event *event;
364 unsigned long flags = 0; 363 unsigned long flags;
365 364
366 /* drop event on the floor if no one's listening */ 365 /* drop event on the floor if no one's listening */
367 if (!event_is_open) 366 if (!event_is_open)
@@ -400,7 +399,7 @@ EXPORT_SYMBOL(acpi_bus_generate_proc_event);
400 399
401int acpi_bus_receive_event(struct acpi_bus_event *event) 400int acpi_bus_receive_event(struct acpi_bus_event *event)
402{ 401{
403 unsigned long flags = 0; 402 unsigned long flags;
404 struct acpi_bus_event *entry = NULL; 403 struct acpi_bus_event *entry = NULL;
405 404
406 DECLARE_WAITQUEUE(wait, current); 405 DECLARE_WAITQUEUE(wait, current);
@@ -593,7 +592,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
593 592
594static int __init acpi_bus_init_irq(void) 593static int __init acpi_bus_init_irq(void)
595{ 594{
596 acpi_status status = AE_OK; 595 acpi_status status;
597 union acpi_object arg = { ACPI_TYPE_INTEGER }; 596 union acpi_object arg = { ACPI_TYPE_INTEGER };
598 struct acpi_object_list arg_list = { 1, &arg }; 597 struct acpi_object_list arg_list = { 1, &arg };
599 char *message = NULL; 598 char *message = NULL;
@@ -640,7 +639,7 @@ u8 acpi_gbl_permanent_mmap;
640 639
641void __init acpi_early_init(void) 640void __init acpi_early_init(void)
642{ 641{
643 acpi_status status = AE_OK; 642 acpi_status status;
644 643
645 if (acpi_disabled) 644 if (acpi_disabled)
646 return; 645 return;
@@ -714,8 +713,8 @@ void __init acpi_early_init(void)
714 713
715static int __init acpi_bus_init(void) 714static int __init acpi_bus_init(void)
716{ 715{
717 int result = 0; 716 int result;
718 acpi_status status = AE_OK; 717 acpi_status status;
719 extern acpi_status acpi_os_initialize1(void); 718 extern acpi_status acpi_os_initialize1(void);
720 719
721 acpi_os_initialize1(); 720 acpi_os_initialize1();
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 31c217a42839..4ab807dc8518 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -324,14 +324,27 @@ int acpi_bus_update_power(acpi_handle handle, int *state_p)
324 if (result) 324 if (result)
325 return result; 325 return result;
326 326
327 if (state == ACPI_STATE_UNKNOWN) 327 if (state == ACPI_STATE_UNKNOWN) {
328 state = ACPI_STATE_D0; 328 state = ACPI_STATE_D0;
329 329 result = acpi_device_set_power(device, state);
330 result = acpi_device_set_power(device, state); 330 if (result)
331 if (!result && state_p) 331 return result;
332 } else {
333 if (device->power.flags.power_resources) {
334 /*
335 * We don't need to really switch the state, bu we need
336 * to update the power resources' reference counters.
337 */
338 result = acpi_power_transition(device, state);
339 if (result)
340 return result;
341 }
342 device->power.state = state;
343 }
344 if (state_p)
332 *state_p = state; 345 *state_p = state;
333 346
334 return result; 347 return 0;
335} 348}
336EXPORT_SYMBOL_GPL(acpi_bus_update_power); 349EXPORT_SYMBOL_GPL(acpi_bus_update_power);
337 350
@@ -419,62 +432,73 @@ bool acpi_bus_can_wakeup(acpi_handle handle)
419EXPORT_SYMBOL(acpi_bus_can_wakeup); 432EXPORT_SYMBOL(acpi_bus_can_wakeup);
420 433
421/** 434/**
422 * acpi_device_power_state - Get preferred power state of ACPI device. 435 * acpi_dev_pm_get_state - Get preferred power state of ACPI device.
423 * @dev: Device whose preferred target power state to return. 436 * @dev: Device whose preferred target power state to return.
424 * @adev: ACPI device node corresponding to @dev. 437 * @adev: ACPI device node corresponding to @dev.
425 * @target_state: System state to match the resultant device state. 438 * @target_state: System state to match the resultant device state.
426 * @d_max_in: Deepest low-power state to take into consideration. 439 * @d_min_p: Location to store the highest power state available to the device.
427 * @d_min_p: Location to store the upper limit of the allowed states range. 440 * @d_max_p: Location to store the lowest power state available to the device.
428 * Return value: Preferred power state of the device on success, -ENODEV
429 * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure
430 * 441 *
431 * Find the lowest power (highest number) ACPI device power state that the 442 * Find the lowest power (highest number) and highest power (lowest number) ACPI
432 * device can be in while the system is in the state represented by 443 * device power states that the device can be in while the system is in the
433 * @target_state. If @d_min_p is set, the highest power (lowest number) device 444 * state represented by @target_state. Store the integer numbers representing
434 * power state that @dev can be in for the given system sleep state is stored 445 * those stats in the memory locations pointed to by @d_max_p and @d_min_p,
435 * at the location pointed to by it. 446 * respectively.
436 * 447 *
437 * Callers must ensure that @dev and @adev are valid pointers and that @adev 448 * Callers must ensure that @dev and @adev are valid pointers and that @adev
438 * actually corresponds to @dev before using this function. 449 * actually corresponds to @dev before using this function.
450 *
451 * Returns 0 on success or -ENODATA when one of the ACPI methods fails or
452 * returns a value that doesn't make sense. The memory locations pointed to by
453 * @d_max_p and @d_min_p are only modified on success.
439 */ 454 */
440int acpi_device_power_state(struct device *dev, struct acpi_device *adev, 455static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,
441 u32 target_state, int d_max_in, int *d_min_p) 456 u32 target_state, int *d_min_p, int *d_max_p)
442{ 457{
443 char acpi_method[] = "_SxD"; 458 char method[] = { '_', 'S', '0' + target_state, 'D', '\0' };
444 unsigned long long d_min, d_max; 459 acpi_handle handle = adev->handle;
460 unsigned long long ret;
461 int d_min, d_max;
445 bool wakeup = false; 462 bool wakeup = false;
463 acpi_status status;
446 464
447 if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3)
448 return -EINVAL;
449
450 if (d_max_in > ACPI_STATE_D3_HOT) {
451 enum pm_qos_flags_status stat;
452
453 stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF);
454 if (stat == PM_QOS_FLAGS_ALL)
455 d_max_in = ACPI_STATE_D3_HOT;
456 }
457
458 acpi_method[2] = '0' + target_state;
459 /* 465 /*
460 * If the sleep state is S0, the lowest limit from ACPI is D3, 466 * If the system state is S0, the lowest power state the device can be
461 * but if the device has _S0W, we will use the value from _S0W 467 * in is D3cold, unless the device has _S0W and is supposed to signal
462 * as the lowest limit from ACPI. Finally, we will constrain 468 * wakeup, in which case the return value of _S0W has to be used as the
463 * the lowest limit with the specified one. 469 * lowest power state available to the device.
464 */ 470 */
465 d_min = ACPI_STATE_D0; 471 d_min = ACPI_STATE_D0;
466 d_max = ACPI_STATE_D3; 472 d_max = ACPI_STATE_D3_COLD;
467 473
468 /* 474 /*
469 * If present, _SxD methods return the minimum D-state (highest power 475 * If present, _SxD methods return the minimum D-state (highest power
470 * state) we can use for the corresponding S-states. Otherwise, the 476 * state) we can use for the corresponding S-states. Otherwise, the
471 * minimum D-state is D0 (ACPI 3.x). 477 * minimum D-state is D0 (ACPI 3.x).
472 *
473 * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
474 * provided -- that's our fault recovery, we ignore retval.
475 */ 478 */
476 if (target_state > ACPI_STATE_S0) { 479 if (target_state > ACPI_STATE_S0) {
477 acpi_evaluate_integer(adev->handle, acpi_method, NULL, &d_min); 480 /*
481 * We rely on acpi_evaluate_integer() not clobbering the integer
482 * provided if AE_NOT_FOUND is returned.
483 */
484 ret = d_min;
485 status = acpi_evaluate_integer(handle, method, NULL, &ret);
486 if ((ACPI_FAILURE(status) && status != AE_NOT_FOUND)
487 || ret > ACPI_STATE_D3_COLD)
488 return -ENODATA;
489
490 /*
491 * We need to handle legacy systems where D3hot and D3cold are
492 * the same and 3 is returned in both cases, so fall back to
493 * D3cold if D3hot is not a valid state.
494 */
495 if (!adev->power.states[ret].flags.valid) {
496 if (ret == ACPI_STATE_D3_HOT)
497 ret = ACPI_STATE_D3_COLD;
498 else
499 return -ENODATA;
500 }
501 d_min = ret;
478 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid 502 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid
479 && adev->wakeup.sleep_state >= target_state; 503 && adev->wakeup.sleep_state >= target_state;
480 } else if (dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) != 504 } else if (dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) !=
@@ -490,38 +514,30 @@ int acpi_device_power_state(struct device *dev, struct acpi_device *adev,
490 * can wake the system. _S0W may be valid, too. 514 * can wake the system. _S0W may be valid, too.
491 */ 515 */
492 if (wakeup) { 516 if (wakeup) {
493 acpi_status status; 517 method[3] = 'W';
494 518 status = acpi_evaluate_integer(handle, method, NULL, &ret);
495 acpi_method[3] = 'W'; 519 if (status == AE_NOT_FOUND) {
496 status = acpi_evaluate_integer(adev->handle, acpi_method, NULL, 520 if (target_state > ACPI_STATE_S0)
497 &d_max);
498 if (ACPI_FAILURE(status)) {
499 if (target_state != ACPI_STATE_S0 ||
500 status != AE_NOT_FOUND)
501 d_max = d_min; 521 d_max = d_min;
502 } else if (d_max < d_min) { 522 } else if (ACPI_SUCCESS(status) && ret <= ACPI_STATE_D3_COLD) {
503 /* Warn the user of the broken DSDT */ 523 /* Fall back to D3cold if ret is not a valid state. */
504 printk(KERN_WARNING "ACPI: Wrong value from %s\n", 524 if (!adev->power.states[ret].flags.valid)
505 acpi_method); 525 ret = ACPI_STATE_D3_COLD;
506 /* Sanitize it */ 526
507 d_min = d_max; 527 d_max = ret > d_min ? ret : d_min;
528 } else {
529 return -ENODATA;
508 } 530 }
509 } 531 }
510 532
511 if (d_max_in < d_min)
512 return -EINVAL;
513 if (d_min_p) 533 if (d_min_p)
514 *d_min_p = d_min; 534 *d_min_p = d_min;
515 /* constrain d_max with specified lowest limit (max number) */ 535
516 if (d_max > d_max_in) { 536 if (d_max_p)
517 for (d_max = d_max_in; d_max > d_min; d_max--) { 537 *d_max_p = d_max;
518 if (adev->power.states[d_max].flags.valid) 538
519 break; 539 return 0;
520 }
521 }
522 return d_max;
523} 540}
524EXPORT_SYMBOL_GPL(acpi_device_power_state);
525 541
526/** 542/**
527 * acpi_pm_device_sleep_state - Get preferred power state of ACPI device. 543 * acpi_pm_device_sleep_state - Get preferred power state of ACPI device.
@@ -529,7 +545,8 @@ EXPORT_SYMBOL_GPL(acpi_device_power_state);
529 * @d_min_p: Location to store the upper limit of the allowed states range. 545 * @d_min_p: Location to store the upper limit of the allowed states range.
530 * @d_max_in: Deepest low-power state to take into consideration. 546 * @d_max_in: Deepest low-power state to take into consideration.
531 * Return value: Preferred power state of the device on success, -ENODEV 547 * Return value: Preferred power state of the device on success, -ENODEV
532 * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure 548 * if there's no 'struct acpi_device' for @dev, -EINVAL if @d_max_in is
549 * incorrect, or -ENODATA on ACPI method failure.
533 * 550 *
534 * The caller must ensure that @dev is valid before using this function. 551 * The caller must ensure that @dev is valid before using this function.
535 */ 552 */
@@ -537,14 +554,43 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
537{ 554{
538 acpi_handle handle = DEVICE_ACPI_HANDLE(dev); 555 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
539 struct acpi_device *adev; 556 struct acpi_device *adev;
557 int ret, d_min, d_max;
558
559 if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3_COLD)
560 return -EINVAL;
561
562 if (d_max_in > ACPI_STATE_D3_HOT) {
563 enum pm_qos_flags_status stat;
564
565 stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF);
566 if (stat == PM_QOS_FLAGS_ALL)
567 d_max_in = ACPI_STATE_D3_HOT;
568 }
540 569
541 if (!handle || acpi_bus_get_device(handle, &adev)) { 570 if (!handle || acpi_bus_get_device(handle, &adev)) {
542 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); 571 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
543 return -ENODEV; 572 return -ENODEV;
544 } 573 }
545 574
546 return acpi_device_power_state(dev, adev, acpi_target_system_state(), 575 ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(),
547 d_max_in, d_min_p); 576 &d_min, &d_max);
577 if (ret)
578 return ret;
579
580 if (d_max_in < d_min)
581 return -EINVAL;
582
583 if (d_max > d_max_in) {
584 for (d_max = d_max_in; d_max > d_min; d_max--) {
585 if (adev->power.states[d_max].flags.valid)
586 break;
587 }
588 }
589
590 if (d_min_p)
591 *d_min_p = d_min;
592
593 return d_max;
548} 594}
549EXPORT_SYMBOL(acpi_pm_device_sleep_state); 595EXPORT_SYMBOL(acpi_pm_device_sleep_state);
550 596
@@ -695,17 +741,13 @@ struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
695static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, 741static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev,
696 u32 system_state) 742 u32 system_state)
697{ 743{
698 int power_state; 744 int ret, state;
699 745
700 if (!acpi_device_power_manageable(adev)) 746 if (!acpi_device_power_manageable(adev))
701 return 0; 747 return 0;
702 748
703 power_state = acpi_device_power_state(dev, adev, system_state, 749 ret = acpi_dev_pm_get_state(dev, adev, system_state, NULL, &state);
704 ACPI_STATE_D3, NULL); 750 return ret ? ret : acpi_device_set_power(adev, state);
705 if (power_state < ACPI_STATE_D0 || power_state > ACPI_STATE_D3)
706 return -EIO;
707
708 return acpi_device_set_power(adev, power_state);
709} 751}
710 752
711/** 753/**
@@ -908,7 +950,6 @@ static struct dev_pm_domain acpi_general_pm_domain = {
908#ifdef CONFIG_PM_RUNTIME 950#ifdef CONFIG_PM_RUNTIME
909 .runtime_suspend = acpi_subsys_runtime_suspend, 951 .runtime_suspend = acpi_subsys_runtime_suspend,
910 .runtime_resume = acpi_subsys_runtime_resume, 952 .runtime_resume = acpi_subsys_runtime_resume,
911 .runtime_idle = pm_generic_runtime_idle,
912#endif 953#endif
913#ifdef CONFIG_PM_SLEEP 954#ifdef CONFIG_PM_SLEEP
914 .prepare = acpi_subsys_prepare, 955 .prepare = acpi_subsys_prepare,
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 14de9f46972e..826560753389 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -1064,10 +1064,10 @@ find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
1064 return AE_OK; 1064 return AE_OK;
1065} 1065}
1066 1066
1067int __init acpi_dock_init(void) 1067void __init acpi_dock_init(void)
1068{ 1068{
1069 if (acpi_disabled) 1069 if (acpi_disabled)
1070 return 0; 1070 return;
1071 1071
1072 /* look for dock stations and bays */ 1072 /* look for dock stations and bays */
1073 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1073 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
@@ -1075,11 +1075,10 @@ int __init acpi_dock_init(void)
1075 1075
1076 if (!dock_station_count) { 1076 if (!dock_station_count) {
1077 pr_info(PREFIX "No dock devices found.\n"); 1077 pr_info(PREFIX "No dock devices found.\n");
1078 return 0; 1078 return;
1079 } 1079 }
1080 1080
1081 register_acpi_bus_notifier(&dock_acpi_notifier); 1081 register_acpi_bus_notifier(&dock_acpi_notifier);
1082 pr_info(PREFIX "%s: %d docks/bays found\n", 1082 pr_info(PREFIX "%s: %d docks/bays found\n",
1083 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count); 1083 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);
1084 return 0;
1085} 1084}
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index edc00818c803..80403c1a89f8 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -983,6 +983,10 @@ static struct dmi_system_id __initdata ec_dmi_table[] = {
983 ec_enlarge_storm_threshold, "CLEVO hardware", { 983 ec_enlarge_storm_threshold, "CLEVO hardware", {
984 DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."), 984 DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
985 DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL}, 985 DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL},
986 {
987 ec_skip_dsdt_scan, "HP Folio 13", {
988 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
989 DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13"),}, NULL},
986 {}, 990 {},
987}; 991};
988 992
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index 7586544fddb4..4e7b798900f2 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -12,6 +12,7 @@
12#include <linux/acpi.h> 12#include <linux/acpi.h>
13#include <linux/debugfs.h> 13#include <linux/debugfs.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/uaccess.h>
15#include "internal.h" 16#include "internal.h"
16 17
17MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>"); 18MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
@@ -34,7 +35,6 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
34 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private; 35 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
35 */ 36 */
36 unsigned int size = EC_SPACE_SIZE; 37 unsigned int size = EC_SPACE_SIZE;
37 u8 *data = (u8 *) buf;
38 loff_t init_off = *off; 38 loff_t init_off = *off;
39 int err = 0; 39 int err = 0;
40 40
@@ -47,9 +47,15 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
47 size = count; 47 size = count;
48 48
49 while (size) { 49 while (size) {
50 err = ec_read(*off, &data[*off - init_off]); 50 u8 byte_read;
51 err = ec_read(*off, &byte_read);
51 if (err) 52 if (err)
52 return err; 53 return err;
54 if (put_user(byte_read, buf + *off - init_off)) {
55 if (*off - init_off)
56 return *off - init_off; /* partial read */
57 return -EFAULT;
58 }
53 *off += 1; 59 *off += 1;
54 size--; 60 size--;
55 } 61 }
@@ -65,7 +71,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
65 71
66 unsigned int size = count; 72 unsigned int size = count;
67 loff_t init_off = *off; 73 loff_t init_off = *off;
68 u8 *data = (u8 *) buf;
69 int err = 0; 74 int err = 0;
70 75
71 if (*off >= EC_SPACE_SIZE) 76 if (*off >= EC_SPACE_SIZE)
@@ -76,7 +81,12 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
76 } 81 }
77 82
78 while (size) { 83 while (size) {
79 u8 byte_write = data[*off - init_off]; 84 u8 byte_write;
85 if (get_user(byte_write, buf + *off - init_off)) {
86 if (*off - init_off)
87 return *off - init_off; /* partial write */
88 return -EFAULT;
89 }
80 err = ec_write(*off, byte_write); 90 err = ec_write(*off, byte_write);
81 if (err) 91 if (err)
82 return err; 92 return err;
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 8d1c0105e113..5b02a0aa540c 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -84,7 +84,7 @@ static int fan_get_cur_state(struct thermal_cooling_device *cdev, unsigned long
84{ 84{
85 struct acpi_device *device = cdev->devdata; 85 struct acpi_device *device = cdev->devdata;
86 int result; 86 int result;
87 int acpi_state; 87 int acpi_state = ACPI_STATE_D0;
88 88
89 if (!device) 89 if (!device)
90 return -EINVAL; 90 return -EINVAL;
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 40a84cc6740c..f68095756fb7 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -81,13 +81,15 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
81static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used, 81static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used,
82 void *addr_p, void **ret_p) 82 void *addr_p, void **ret_p)
83{ 83{
84 unsigned long long addr; 84 unsigned long long addr, sta;
85 acpi_status status; 85 acpi_status status;
86 86
87 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr); 87 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
88 if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) { 88 if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) {
89 *ret_p = handle; 89 *ret_p = handle;
90 return AE_CTRL_TERMINATE; 90 status = acpi_bus_get_status_handle(handle, &sta);
91 if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_ENABLED))
92 return AE_CTRL_TERMINATE;
91 } 93 }
92 return AE_OK; 94 return AE_OK;
93} 95}
@@ -105,7 +107,7 @@ acpi_handle acpi_get_child(acpi_handle parent, u64 address)
105} 107}
106EXPORT_SYMBOL(acpi_get_child); 108EXPORT_SYMBOL(acpi_get_child);
107 109
108static int acpi_bind_one(struct device *dev, acpi_handle handle) 110int acpi_bind_one(struct device *dev, acpi_handle handle)
109{ 111{
110 struct acpi_device *acpi_dev; 112 struct acpi_device *acpi_dev;
111 acpi_status status; 113 acpi_status status;
@@ -188,8 +190,9 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
188 kfree(physical_node); 190 kfree(physical_node);
189 goto err; 191 goto err;
190} 192}
193EXPORT_SYMBOL_GPL(acpi_bind_one);
191 194
192static int acpi_unbind_one(struct device *dev) 195int acpi_unbind_one(struct device *dev)
193{ 196{
194 struct acpi_device_physical_node *entry; 197 struct acpi_device_physical_node *entry;
195 struct acpi_device *acpi_dev; 198 struct acpi_device *acpi_dev;
@@ -238,6 +241,7 @@ err:
238 dev_err(dev, "Oops, 'acpi_handle' corrupt\n"); 241 dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
239 return -EINVAL; 242 return -EINVAL;
240} 243}
244EXPORT_SYMBOL_GPL(acpi_unbind_one);
241 245
242static int acpi_platform_notify(struct device *dev) 246static int acpi_platform_notify(struct device *dev)
243{ 247{
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index c610a76d92c4..5da44e81dd4d 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -33,6 +33,7 @@ static inline void acpi_pci_slot_init(void) { }
33void acpi_pci_root_init(void); 33void acpi_pci_root_init(void);
34void acpi_pci_link_init(void); 34void acpi_pci_link_init(void);
35void acpi_pci_root_hp_init(void); 35void acpi_pci_root_hp_init(void);
36void acpi_processor_init(void);
36void acpi_platform_init(void); 37void acpi_platform_init(void);
37int acpi_sysfs_init(void); 38int acpi_sysfs_init(void);
38#ifdef CONFIG_ACPI_CONTAINER 39#ifdef CONFIG_ACPI_CONTAINER
@@ -50,6 +51,13 @@ void acpi_memory_hotplug_init(void);
50#else 51#else
51static inline void acpi_memory_hotplug_init(void) {} 52static inline void acpi_memory_hotplug_init(void) {}
52#endif 53#endif
54#ifdef CONFIG_X86
55void acpi_cmos_rtc_init(void);
56#else
57static inline void acpi_cmos_rtc_init(void) {}
58#endif
59
60extern bool acpi_force_hot_remove;
53 61
54void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, 62void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
55 const char *name); 63 const char *name);
@@ -81,6 +89,8 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
81 int type, unsigned long long sta); 89 int type, unsigned long long sta);
82void acpi_device_add_finalize(struct acpi_device *device); 90void acpi_device_add_finalize(struct acpi_device *device);
83void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); 91void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
92int acpi_bind_one(struct device *dev, acpi_handle handle);
93int acpi_unbind_one(struct device *dev);
84 94
85/* -------------------------------------------------------------------------- 95/* --------------------------------------------------------------------------
86 Power Resource 96 Power Resource
@@ -154,4 +164,13 @@ struct platform_device;
154int acpi_create_platform_device(struct acpi_device *adev, 164int acpi_create_platform_device(struct acpi_device *adev,
155 const struct acpi_device_id *id); 165 const struct acpi_device_id *id);
156 166
167/*--------------------------------------------------------------------------
168 Video
169 -------------------------------------------------------------------------- */
170#if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)
171bool acpi_video_backlight_quirks(void);
172#else
173static inline bool acpi_video_backlight_quirks(void) { return false; }
174#endif
175
157#endif /* _ACPI_INTERNAL_H_ */ 176#endif /* _ACPI_INTERNAL_H_ */
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index e72186340fec..6ab2c3505520 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -835,19 +835,9 @@ void acpi_os_stall(u32 us)
835 */ 835 */
836u64 acpi_os_get_timer(void) 836u64 acpi_os_get_timer(void)
837{ 837{
838 static u64 t; 838 u64 time_ns = ktime_to_ns(ktime_get());
839 839 do_div(time_ns, 100);
840#ifdef CONFIG_HPET 840 return time_ns;
841 /* TBD: use HPET if available */
842#endif
843
844#ifdef CONFIG_X86_PM_TIMER
845 /* TBD: default to PM timer if HPET was not available */
846#endif
847 if (!t)
848 printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
849
850 return ++t;
851} 841}
852 842
853acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) 843acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
@@ -1715,6 +1705,17 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1715} 1705}
1716#endif 1706#endif
1717 1707
1708static int __init acpi_no_auto_ssdt_setup(char *s)
1709{
1710 printk(KERN_NOTICE PREFIX "SSDT auto-load disabled\n");
1711
1712 acpi_gbl_disable_ssdt_table_load = TRUE;
1713
1714 return 1;
1715}
1716
1717__setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);
1718
1718acpi_status __init acpi_os_initialize(void) 1719acpi_status __init acpi_os_initialize(void)
1719{ 1720{
1720 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block); 1721 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index e427dc516c76..5917839321b8 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -65,10 +65,6 @@ static struct acpi_scan_handler pci_root_handler = {
65 .detach = acpi_pci_root_remove, 65 .detach = acpi_pci_root_remove,
66}; 66};
67 67
68/* Lock to protect both acpi_pci_roots lists */
69static DEFINE_MUTEX(acpi_pci_root_lock);
70static LIST_HEAD(acpi_pci_roots);
71
72static DEFINE_MUTEX(osc_lock); 68static DEFINE_MUTEX(osc_lock);
73 69
74/** 70/**
@@ -100,13 +96,12 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
100{ 96{
101 struct resource *res = data; 97 struct resource *res = data;
102 struct acpi_resource_address64 address; 98 struct acpi_resource_address64 address;
99 acpi_status status;
103 100
104 if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && 101 status = acpi_resource_to_address64(resource, &address);
105 resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 && 102 if (ACPI_FAILURE(status))
106 resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
107 return AE_OK; 103 return AE_OK;
108 104
109 acpi_resource_to_address64(resource, &address);
110 if ((address.address_length > 0) && 105 if ((address.address_length > 0) &&
111 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) { 106 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) {
112 res->start = address.minimum; 107 res->start = address.minimum;
@@ -382,23 +377,24 @@ static int acpi_pci_root_add(struct acpi_device *device,
382 int result; 377 int result;
383 struct acpi_pci_root *root; 378 struct acpi_pci_root *root;
384 u32 flags, base_flags; 379 u32 flags, base_flags;
380 acpi_handle handle = device->handle;
385 381
386 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 382 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
387 if (!root) 383 if (!root)
388 return -ENOMEM; 384 return -ENOMEM;
389 385
390 segment = 0; 386 segment = 0;
391 status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL, 387 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL,
392 &segment); 388 &segment);
393 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 389 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
394 printk(KERN_ERR PREFIX "can't evaluate _SEG\n"); 390 dev_err(&device->dev, "can't evaluate _SEG\n");
395 result = -ENODEV; 391 result = -ENODEV;
396 goto end; 392 goto end;
397 } 393 }
398 394
399 /* Check _CRS first, then _BBN. If no _BBN, default to zero. */ 395 /* Check _CRS first, then _BBN. If no _BBN, default to zero. */
400 root->secondary.flags = IORESOURCE_BUS; 396 root->secondary.flags = IORESOURCE_BUS;
401 status = try_get_root_bridge_busnr(device->handle, &root->secondary); 397 status = try_get_root_bridge_busnr(handle, &root->secondary);
402 if (ACPI_FAILURE(status)) { 398 if (ACPI_FAILURE(status)) {
403 /* 399 /*
404 * We need both the start and end of the downstream bus range 400 * We need both the start and end of the downstream bus range
@@ -407,33 +403,32 @@ static int acpi_pci_root_add(struct acpi_device *device,
407 * can do is assume [_BBN-0xFF] or [0-0xFF]. 403 * can do is assume [_BBN-0xFF] or [0-0xFF].
408 */ 404 */
409 root->secondary.end = 0xFF; 405 root->secondary.end = 0xFF;
410 printk(KERN_WARNING FW_BUG PREFIX 406 dev_warn(&device->dev,
411 "no secondary bus range in _CRS\n"); 407 FW_BUG "no secondary bus range in _CRS\n");
412 status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, 408 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN,
413 NULL, &bus); 409 NULL, &bus);
414 if (ACPI_SUCCESS(status)) 410 if (ACPI_SUCCESS(status))
415 root->secondary.start = bus; 411 root->secondary.start = bus;
416 else if (status == AE_NOT_FOUND) 412 else if (status == AE_NOT_FOUND)
417 root->secondary.start = 0; 413 root->secondary.start = 0;
418 else { 414 else {
419 printk(KERN_ERR PREFIX "can't evaluate _BBN\n"); 415 dev_err(&device->dev, "can't evaluate _BBN\n");
420 result = -ENODEV; 416 result = -ENODEV;
421 goto end; 417 goto end;
422 } 418 }
423 } 419 }
424 420
425 INIT_LIST_HEAD(&root->node);
426 root->device = device; 421 root->device = device;
427 root->segment = segment & 0xFFFF; 422 root->segment = segment & 0xFFFF;
428 strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); 423 strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
429 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); 424 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
430 device->driver_data = root; 425 device->driver_data = root;
431 426
432 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", 427 pr_info(PREFIX "%s [%s] (domain %04x %pR)\n",
433 acpi_device_name(device), acpi_device_bid(device), 428 acpi_device_name(device), acpi_device_bid(device),
434 root->segment, &root->secondary); 429 root->segment, &root->secondary);
435 430
436 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle); 431 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle);
437 432
438 /* 433 /*
439 * All supported architectures that use ACPI have support for 434 * All supported architectures that use ACPI have support for
@@ -446,10 +441,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
446 * TBD: Need PCI interface for enumeration/configuration of roots. 441 * TBD: Need PCI interface for enumeration/configuration of roots.
447 */ 442 */
448 443
449 mutex_lock(&acpi_pci_root_lock);
450 list_add_tail(&root->node, &acpi_pci_roots);
451 mutex_unlock(&acpi_pci_root_lock);
452
453 /* 444 /*
454 * Scan the Root Bridge 445 * Scan the Root Bridge
455 * -------------------- 446 * --------------------
@@ -459,11 +450,11 @@ static int acpi_pci_root_add(struct acpi_device *device,
459 */ 450 */
460 root->bus = pci_acpi_scan_root(root); 451 root->bus = pci_acpi_scan_root(root);
461 if (!root->bus) { 452 if (!root->bus) {
462 printk(KERN_ERR PREFIX 453 dev_err(&device->dev,
463 "Bus %04x:%02x not present in PCI namespace\n", 454 "Bus %04x:%02x not present in PCI namespace\n",
464 root->segment, (unsigned int)root->secondary.start); 455 root->segment, (unsigned int)root->secondary.start);
465 result = -ENODEV; 456 result = -ENODEV;
466 goto out_del_root; 457 goto end;
467 } 458 }
468 459
469 /* Indicate support for various _OSC capabilities. */ 460 /* Indicate support for various _OSC capabilities. */
@@ -502,7 +493,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
502 dev_info(&device->dev, 493 dev_info(&device->dev,
503 "Requesting ACPI _OSC control (0x%02x)\n", flags); 494 "Requesting ACPI _OSC control (0x%02x)\n", flags);
504 495
505 status = acpi_pci_osc_control_set(device->handle, &flags, 496 status = acpi_pci_osc_control_set(handle, &flags,
506 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); 497 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
507 if (ACPI_SUCCESS(status)) { 498 if (ACPI_SUCCESS(status)) {
508 dev_info(&device->dev, 499 dev_info(&device->dev,
@@ -519,8 +510,8 @@ static int acpi_pci_root_add(struct acpi_device *device,
519 "ACPI _OSC request failed (%s), " 510 "ACPI _OSC request failed (%s), "
520 "returned control mask: 0x%02x\n", 511 "returned control mask: 0x%02x\n",
521 acpi_format_exception(status), flags); 512 acpi_format_exception(status), flags);
522 pr_info("ACPI _OSC control for PCIe not granted, " 513 dev_info(&device->dev,
523 "disabling ASPM\n"); 514 "ACPI _OSC control for PCIe not granted, disabling ASPM\n");
524 pcie_no_aspm(); 515 pcie_no_aspm();
525 } 516 }
526 } else { 517 } else {
@@ -536,20 +527,14 @@ static int acpi_pci_root_add(struct acpi_device *device,
536 if (system_state != SYSTEM_BOOTING) { 527 if (system_state != SYSTEM_BOOTING) {
537 pcibios_resource_survey_bus(root->bus); 528 pcibios_resource_survey_bus(root->bus);
538 pci_assign_unassigned_bus_resources(root->bus); 529 pci_assign_unassigned_bus_resources(root->bus);
539 }
540 530
541 /* need to after hot-added ioapic is registered */ 531 /* need to after hot-added ioapic is registered */
542 if (system_state != SYSTEM_BOOTING)
543 pci_enable_bridges(root->bus); 532 pci_enable_bridges(root->bus);
533 }
544 534
545 pci_bus_add_devices(root->bus); 535 pci_bus_add_devices(root->bus);
546 return 1; 536 return 1;
547 537
548out_del_root:
549 mutex_lock(&acpi_pci_root_lock);
550 list_del(&root->node);
551 mutex_unlock(&acpi_pci_root_lock);
552
553end: 538end:
554 kfree(root); 539 kfree(root);
555 return result; 540 return result;
@@ -566,9 +551,6 @@ static void acpi_pci_root_remove(struct acpi_device *device)
566 551
567 pci_remove_root_bus(root->bus); 552 pci_remove_root_bus(root->bus);
568 553
569 mutex_lock(&acpi_pci_root_lock);
570 list_del(&root->node);
571 mutex_unlock(&acpi_pci_root_lock);
572 kfree(root); 554 kfree(root);
573} 555}
574 556
@@ -588,12 +570,13 @@ static void handle_root_bridge_insertion(acpi_handle handle)
588 struct acpi_device *device; 570 struct acpi_device *device;
589 571
590 if (!acpi_bus_get_device(handle, &device)) { 572 if (!acpi_bus_get_device(handle, &device)) {
591 printk(KERN_DEBUG "acpi device exists...\n"); 573 dev_printk(KERN_DEBUG, &device->dev,
574 "acpi device already exists; ignoring notify\n");
592 return; 575 return;
593 } 576 }
594 577
595 if (acpi_bus_scan(handle)) 578 if (acpi_bus_scan(handle))
596 printk(KERN_ERR "cannot add bridge to acpi list\n"); 579 acpi_handle_err(handle, "cannot add bridge to acpi list\n");
597} 580}
598 581
599static void handle_root_bridge_removal(struct acpi_device *device) 582static void handle_root_bridge_removal(struct acpi_device *device)
@@ -622,7 +605,6 @@ static void handle_root_bridge_removal(struct acpi_device *device)
622static void _handle_hotplug_event_root(struct work_struct *work) 605static void _handle_hotplug_event_root(struct work_struct *work)
623{ 606{
624 struct acpi_pci_root *root; 607 struct acpi_pci_root *root;
625 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER };
626 struct acpi_hp_work *hp_work; 608 struct acpi_hp_work *hp_work;
627 acpi_handle handle; 609 acpi_handle handle;
628 u32 type; 610 u32 type;
@@ -634,13 +616,12 @@ static void _handle_hotplug_event_root(struct work_struct *work)
634 acpi_scan_lock_acquire(); 616 acpi_scan_lock_acquire();
635 617
636 root = acpi_pci_find_root(handle); 618 root = acpi_pci_find_root(handle);
637 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
638 619
639 switch (type) { 620 switch (type) {
640 case ACPI_NOTIFY_BUS_CHECK: 621 case ACPI_NOTIFY_BUS_CHECK:
641 /* bus enumerate */ 622 /* bus enumerate */
642 printk(KERN_DEBUG "%s: Bus check notify on %s\n", __func__, 623 acpi_handle_printk(KERN_DEBUG, handle,
643 (char *)buffer.pointer); 624 "Bus check notify on %s\n", __func__);
644 if (root) 625 if (root)
645 acpiphp_check_host_bridge(handle); 626 acpiphp_check_host_bridge(handle);
646 else 627 else
@@ -650,28 +631,28 @@ static void _handle_hotplug_event_root(struct work_struct *work)
650 631
651 case ACPI_NOTIFY_DEVICE_CHECK: 632 case ACPI_NOTIFY_DEVICE_CHECK:
652 /* device check */ 633 /* device check */
653 printk(KERN_DEBUG "%s: Device check notify on %s\n", __func__, 634 acpi_handle_printk(KERN_DEBUG, handle,
654 (char *)buffer.pointer); 635 "Device check notify on %s\n", __func__);
655 if (!root) 636 if (!root)
656 handle_root_bridge_insertion(handle); 637 handle_root_bridge_insertion(handle);
657 break; 638 break;
658 639
659 case ACPI_NOTIFY_EJECT_REQUEST: 640 case ACPI_NOTIFY_EJECT_REQUEST:
660 /* request device eject */ 641 /* request device eject */
661 printk(KERN_DEBUG "%s: Device eject notify on %s\n", __func__, 642 acpi_handle_printk(KERN_DEBUG, handle,
662 (char *)buffer.pointer); 643 "Device eject notify on %s\n", __func__);
663 if (root) 644 if (root)
664 handle_root_bridge_removal(root->device); 645 handle_root_bridge_removal(root->device);
665 break; 646 break;
666 default: 647 default:
667 printk(KERN_WARNING "notify_handler: unknown event type 0x%x for %s\n", 648 acpi_handle_warn(handle,
668 type, (char *)buffer.pointer); 649 "notify_handler: unknown event type 0x%x\n",
650 type);
669 break; 651 break;
670 } 652 }
671 653
672 acpi_scan_lock_release(); 654 acpi_scan_lock_release();
673 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ 655 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */
674 kfree(buffer.pointer);
675} 656}
676 657
677static void handle_hotplug_event_root(acpi_handle handle, u32 type, 658static void handle_hotplug_event_root(acpi_handle handle, u32 type,
@@ -685,9 +666,6 @@ static acpi_status __init
685find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) 666find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
686{ 667{
687 acpi_status status; 668 acpi_status status;
688 char objname[64];
689 struct acpi_buffer buffer = { .length = sizeof(objname),
690 .pointer = objname };
691 int *count = (int *)context; 669 int *count = (int *)context;
692 670
693 if (!acpi_is_root_bridge(handle)) 671 if (!acpi_is_root_bridge(handle))
@@ -695,16 +673,15 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
695 673
696 (*count)++; 674 (*count)++;
697 675
698 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
699
700 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 676 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
701 handle_hotplug_event_root, NULL); 677 handle_hotplug_event_root, NULL);
702 if (ACPI_FAILURE(status)) 678 if (ACPI_FAILURE(status))
703 printk(KERN_DEBUG "acpi root: %s notify handler is not installed, exit status: %u\n", 679 acpi_handle_printk(KERN_DEBUG, handle,
704 objname, (unsigned int)status); 680 "notify handler is not installed, exit status: %u\n",
681 (unsigned int)status);
705 else 682 else
706 printk(KERN_DEBUG "acpi root: %s notify handler is installed\n", 683 acpi_handle_printk(KERN_DEBUG, handle,
707 objname); 684 "notify handler is installed\n");
708 685
709 return AE_OK; 686 return AE_OK;
710} 687}
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 288bb270f8ed..5c28c894c0fc 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -279,7 +279,7 @@ static int acpi_power_on_unlocked(struct acpi_power_resource *resource)
279 279
280 if (resource->ref_count++) { 280 if (resource->ref_count++) {
281 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 281 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
282 "Power resource [%s] already on", 282 "Power resource [%s] already on\n",
283 resource->name)); 283 resource->name));
284 } else { 284 } else {
285 result = __acpi_power_on(resource); 285 result = __acpi_power_on(resource);
@@ -325,7 +325,7 @@ static int acpi_power_off_unlocked(struct acpi_power_resource *resource)
325 325
326 if (!resource->ref_count) { 326 if (!resource->ref_count) {
327 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 327 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
328 "Power resource [%s] already off", 328 "Power resource [%s] already off\n",
329 resource->name)); 329 resource->name));
330 return 0; 330 return 0;
331 } 331 }
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 164d49569aeb..a5e9f4a5b281 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -253,7 +253,7 @@ static bool __init processor_physically_present(acpi_handle handle)
253 return true; 253 return true;
254} 254}
255 255
256static void __cpuinit acpi_set_pdc_bits(u32 *buf) 256static void acpi_set_pdc_bits(u32 *buf)
257{ 257{
258 buf[0] = ACPI_PDC_REVISION_ID; 258 buf[0] = ACPI_PDC_REVISION_ID;
259 buf[1] = 1; 259 buf[1] = 1;
@@ -265,7 +265,7 @@ static void __cpuinit acpi_set_pdc_bits(u32 *buf)
265 arch_acpi_set_pdc_bits(buf); 265 arch_acpi_set_pdc_bits(buf);
266} 266}
267 267
268static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void) 268static struct acpi_object_list *acpi_processor_alloc_pdc(void)
269{ 269{
270 struct acpi_object_list *obj_list; 270 struct acpi_object_list *obj_list;
271 union acpi_object *obj; 271 union acpi_object *obj;
@@ -308,7 +308,7 @@ static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void)
308 * _PDC is required for a BIOS-OS handshake for most of the newer 308 * _PDC is required for a BIOS-OS handshake for most of the newer
309 * ACPI processor features. 309 * ACPI processor features.
310 */ 310 */
311static int __cpuinit 311static int
312acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) 312acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
313{ 313{
314 acpi_status status = AE_OK; 314 acpi_status status = AE_OK;
@@ -336,7 +336,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
336 return status; 336 return status;
337} 337}
338 338
339void __cpuinit acpi_processor_set_pdc(acpi_handle handle) 339void acpi_processor_set_pdc(acpi_handle handle)
340{ 340{
341 struct acpi_object_list *obj_list; 341 struct acpi_object_list *obj_list;
342 342
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index c266cdc11784..870eaf5fa547 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -1,11 +1,13 @@
1/* 1/*
2 * acpi_processor.c - ACPI Processor Driver ($Revision: 71 $) 2 * processor_driver.c - ACPI Processor Driver
3 * 3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> 6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * - Added processor hotplug support 8 * - Added processor hotplug support
9 * Copyright (C) 2013, Intel Corporation
10 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
9 * 11 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 * 13 *
@@ -24,55 +26,26 @@
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 * 27 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 28 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 * TBD:
28 * 1. Make # power states dynamic.
29 * 2. Support duty_cycle values that span bit 4.
30 * 3. Optimize by having scheduler determine business instead of
31 * having us try to calculate it here.
32 * 4. Need C1 timing -- must modify kernel (IRQ handler) to get this.
33 */ 29 */
34 30
35#include <linux/kernel.h> 31#include <linux/kernel.h>
36#include <linux/module.h> 32#include <linux/module.h>
37#include <linux/init.h> 33#include <linux/init.h>
38#include <linux/types.h>
39#include <linux/pci.h>
40#include <linux/pm.h>
41#include <linux/cpufreq.h> 34#include <linux/cpufreq.h>
42#include <linux/cpu.h> 35#include <linux/cpu.h>
43#include <linux/dmi.h>
44#include <linux/moduleparam.h>
45#include <linux/cpuidle.h> 36#include <linux/cpuidle.h>
46#include <linux/slab.h> 37#include <linux/slab.h>
47#include <linux/acpi.h> 38#include <linux/acpi.h>
48#include <linux/memory_hotplug.h> 39
49
50#include <asm/io.h>
51#include <asm/cpu.h>
52#include <asm/delay.h>
53#include <asm/uaccess.h>
54#include <asm/processor.h>
55#include <asm/smp.h>
56#include <asm/acpi.h>
57
58#include <acpi/acpi_bus.h>
59#include <acpi/acpi_drivers.h>
60#include <acpi/processor.h> 40#include <acpi/processor.h>
61 41
42#include "internal.h"
43
62#define PREFIX "ACPI: " 44#define PREFIX "ACPI: "
63 45
64#define ACPI_PROCESSOR_CLASS "processor"
65#define ACPI_PROCESSOR_DEVICE_NAME "Processor"
66#define ACPI_PROCESSOR_FILE_INFO "info"
67#define ACPI_PROCESSOR_FILE_THROTTLING "throttling"
68#define ACPI_PROCESSOR_FILE_LIMIT "limit"
69#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 46#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
70#define ACPI_PROCESSOR_NOTIFY_POWER 0x81 47#define ACPI_PROCESSOR_NOTIFY_POWER 0x81
71#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 48#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
72#define ACPI_PROCESSOR_DEVICE_HID "ACPI0007"
73
74#define ACPI_PROCESSOR_LIMIT_USER 0
75#define ACPI_PROCESSOR_LIMIT_THERMAL 1
76 49
77#define _COMPONENT ACPI_PROCESSOR_COMPONENT 50#define _COMPONENT ACPI_PROCESSOR_COMPONENT
78ACPI_MODULE_NAME("processor_driver"); 51ACPI_MODULE_NAME("processor_driver");
@@ -81,12 +54,8 @@ MODULE_AUTHOR("Paul Diefenbaugh");
81MODULE_DESCRIPTION("ACPI Processor Driver"); 54MODULE_DESCRIPTION("ACPI Processor Driver");
82MODULE_LICENSE("GPL"); 55MODULE_LICENSE("GPL");
83 56
84static int acpi_processor_add(struct acpi_device *device); 57static int acpi_processor_start(struct device *dev);
85static int acpi_processor_remove(struct acpi_device *device); 58static int acpi_processor_stop(struct device *dev);
86static void acpi_processor_notify(struct acpi_device *device, u32 event);
87static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr);
88static int acpi_processor_handle_eject(struct acpi_processor *pr);
89static int acpi_processor_start(struct acpi_processor *pr);
90 59
91static const struct acpi_device_id processor_device_ids[] = { 60static const struct acpi_device_id processor_device_ids[] = {
92 {ACPI_PROCESSOR_OBJECT_HID, 0}, 61 {ACPI_PROCESSOR_OBJECT_HID, 0},
@@ -95,295 +64,24 @@ static const struct acpi_device_id processor_device_ids[] = {
95}; 64};
96MODULE_DEVICE_TABLE(acpi, processor_device_ids); 65MODULE_DEVICE_TABLE(acpi, processor_device_ids);
97 66
98static struct acpi_driver acpi_processor_driver = { 67static struct device_driver acpi_processor_driver = {
99 .name = "processor", 68 .name = "processor",
100 .class = ACPI_PROCESSOR_CLASS, 69 .bus = &cpu_subsys,
101 .ids = processor_device_ids, 70 .acpi_match_table = processor_device_ids,
102 .ops = { 71 .probe = acpi_processor_start,
103 .add = acpi_processor_add, 72 .remove = acpi_processor_stop,
104 .remove = acpi_processor_remove,
105 .notify = acpi_processor_notify,
106 },
107}; 73};
108 74
109#define INSTALL_NOTIFY_HANDLER 1 75static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
110#define UNINSTALL_NOTIFY_HANDLER 2
111
112DEFINE_PER_CPU(struct acpi_processor *, processors);
113EXPORT_PER_CPU_SYMBOL(processors);
114
115struct acpi_processor_errata errata __read_mostly;
116
117/* --------------------------------------------------------------------------
118 Errata Handling
119 -------------------------------------------------------------------------- */
120
121static int acpi_processor_errata_piix4(struct pci_dev *dev)
122{
123 u8 value1 = 0;
124 u8 value2 = 0;
125
126
127 if (!dev)
128 return -EINVAL;
129
130 /*
131 * Note that 'dev' references the PIIX4 ACPI Controller.
132 */
133
134 switch (dev->revision) {
135 case 0:
136 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n"));
137 break;
138 case 1:
139 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n"));
140 break;
141 case 2:
142 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n"));
143 break;
144 case 3:
145 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n"));
146 break;
147 default:
148 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n"));
149 break;
150 }
151
152 switch (dev->revision) {
153
154 case 0: /* PIIX4 A-step */
155 case 1: /* PIIX4 B-step */
156 /*
157 * See specification changes #13 ("Manual Throttle Duty Cycle")
158 * and #14 ("Enabling and Disabling Manual Throttle"), plus
159 * erratum #5 ("STPCLK# Deassertion Time") from the January
160 * 2002 PIIX4 specification update. Applies to only older
161 * PIIX4 models.
162 */
163 errata.piix4.throttle = 1;
164
165 case 2: /* PIIX4E */
166 case 3: /* PIIX4M */
167 /*
168 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA
169 * Livelock") from the January 2002 PIIX4 specification update.
170 * Applies to all PIIX4 models.
171 */
172
173 /*
174 * BM-IDE
175 * ------
176 * Find the PIIX4 IDE Controller and get the Bus Master IDE
177 * Status register address. We'll use this later to read
178 * each IDE controller's DMA status to make sure we catch all
179 * DMA activity.
180 */
181 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
182 PCI_DEVICE_ID_INTEL_82371AB,
183 PCI_ANY_ID, PCI_ANY_ID, NULL);
184 if (dev) {
185 errata.piix4.bmisx = pci_resource_start(dev, 4);
186 pci_dev_put(dev);
187 }
188
189 /*
190 * Type-F DMA
191 * ----------
192 * Find the PIIX4 ISA Controller and read the Motherboard
193 * DMA controller's status to see if Type-F (Fast) DMA mode
194 * is enabled (bit 7) on either channel. Note that we'll
195 * disable C3 support if this is enabled, as some legacy
196 * devices won't operate well if fast DMA is disabled.
197 */
198 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
199 PCI_DEVICE_ID_INTEL_82371AB_0,
200 PCI_ANY_ID, PCI_ANY_ID, NULL);
201 if (dev) {
202 pci_read_config_byte(dev, 0x76, &value1);
203 pci_read_config_byte(dev, 0x77, &value2);
204 if ((value1 & 0x80) || (value2 & 0x80))
205 errata.piix4.fdma = 1;
206 pci_dev_put(dev);
207 }
208
209 break;
210 }
211
212 if (errata.piix4.bmisx)
213 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
214 "Bus master activity detection (BM-IDE) erratum enabled\n"));
215 if (errata.piix4.fdma)
216 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
217 "Type-F DMA livelock erratum (C3 disabled)\n"));
218
219 return 0;
220}
221
222static int acpi_processor_errata(struct acpi_processor *pr)
223{ 76{
224 int result = 0; 77 struct acpi_device *device = data;
225 struct pci_dev *dev = NULL;
226
227
228 if (!pr)
229 return -EINVAL;
230
231 /*
232 * PIIX4
233 */
234 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
235 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
236 PCI_ANY_ID, NULL);
237 if (dev) {
238 result = acpi_processor_errata_piix4(dev);
239 pci_dev_put(dev);
240 }
241
242 return result;
243}
244
245/* --------------------------------------------------------------------------
246 Driver Interface
247 -------------------------------------------------------------------------- */
248
249static int acpi_processor_get_info(struct acpi_device *device)
250{
251 acpi_status status = 0;
252 union acpi_object object = { 0 };
253 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
254 struct acpi_processor *pr; 78 struct acpi_processor *pr;
255 int cpu_index, device_declaration = 0;
256 static int cpu0_initialized;
257
258 pr = acpi_driver_data(device);
259 if (!pr)
260 return -EINVAL;
261
262 if (num_online_cpus() > 1)
263 errata.smp = TRUE;
264
265 acpi_processor_errata(pr);
266
267 /*
268 * Check to see if we have bus mastering arbitration control. This
269 * is required for proper C3 usage (to maintain cache coherency).
270 */
271 if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) {
272 pr->flags.bm_control = 1;
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
274 "Bus mastering arbitration control present\n"));
275 } else
276 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
277 "No bus mastering arbitration control\n"));
278
279 if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) {
280 /* Declared with "Processor" statement; match ProcessorID */
281 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
282 if (ACPI_FAILURE(status)) {
283 dev_err(&device->dev,
284 "Failed to evaluate processor object (0x%x)\n",
285 status);
286 return -ENODEV;
287 }
288
289 /*
290 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
291 * >>> 'acpi_get_processor_id(acpi_id, &id)' in
292 * arch/xxx/acpi.c
293 */
294 pr->acpi_id = object.processor.proc_id;
295 } else {
296 /*
297 * Declared with "Device" statement; match _UID.
298 * Note that we don't handle string _UIDs yet.
299 */
300 unsigned long long value;
301 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
302 NULL, &value);
303 if (ACPI_FAILURE(status)) {
304 dev_err(&device->dev,
305 "Failed to evaluate processor _UID (0x%x)\n",
306 status);
307 return -ENODEV;
308 }
309 device_declaration = 1;
310 pr->acpi_id = value;
311 }
312 cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id);
313
314 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
315 if (!cpu0_initialized && (cpu_index == -1) &&
316 (num_online_cpus() == 1)) {
317 cpu_index = 0;
318 }
319
320 cpu0_initialized = 1;
321
322 pr->id = cpu_index;
323
324 /*
325 * Extra Processor objects may be enumerated on MP systems with
326 * less than the max # of CPUs. They should be ignored _iff
327 * they are physically not present.
328 */
329 if (pr->id == -1) {
330 if (ACPI_FAILURE(acpi_processor_hotadd_init(pr)))
331 return -ENODEV;
332 }
333 /*
334 * On some boxes several processors use the same processor bus id.
335 * But they are located in different scope. For example:
336 * \_SB.SCK0.CPU0
337 * \_SB.SCK1.CPU0
338 * Rename the processor device bus id. And the new bus id will be
339 * generated as the following format:
340 * CPU+CPU ID.
341 */
342 sprintf(acpi_device_bid(device), "CPU%X", pr->id);
343 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
344 pr->acpi_id));
345
346 if (!object.processor.pblk_address)
347 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
348 else if (object.processor.pblk_length != 6)
349 dev_err(&device->dev, "Invalid PBLK length [%d]\n",
350 object.processor.pblk_length);
351 else {
352 pr->throttling.address = object.processor.pblk_address;
353 pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset;
354 pr->throttling.duty_width = acpi_gbl_FADT.duty_width;
355
356 pr->pblk = object.processor.pblk_address;
357
358 /*
359 * We don't care about error returns - we just try to mark
360 * these reserved so that nobody else is confused into thinking
361 * that this region might be unused..
362 *
363 * (In particular, allocating the IO range for Cardbus)
364 */
365 request_region(pr->throttling.address, 6, "ACPI CPU throttle");
366 }
367
368 /*
369 * If ACPI describes a slot number for this CPU, we can use it
370 * ensure we get the right value in the "physical id" field
371 * of /proc/cpuinfo
372 */
373 status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer);
374 if (ACPI_SUCCESS(status))
375 arch_fix_phys_package_id(pr->id, object.integer.value);
376
377 return 0;
378}
379
380static DEFINE_PER_CPU(void *, processor_device_array);
381
382static void acpi_processor_notify(struct acpi_device *device, u32 event)
383{
384 struct acpi_processor *pr = acpi_driver_data(device);
385 int saved; 79 int saved;
386 80
81 if (device->handle != handle)
82 return;
83
84 pr = acpi_driver_data(device);
387 if (!pr) 85 if (!pr)
388 return; 86 return;
389 87
@@ -420,55 +118,62 @@ static void acpi_processor_notify(struct acpi_device *device, u32 event)
420 return; 118 return;
421} 119}
422 120
121static int __acpi_processor_start(struct acpi_device *device);
122
423static int acpi_cpu_soft_notify(struct notifier_block *nfb, 123static int acpi_cpu_soft_notify(struct notifier_block *nfb,
424 unsigned long action, void *hcpu) 124 unsigned long action, void *hcpu)
425{ 125{
426 unsigned int cpu = (unsigned long)hcpu; 126 unsigned int cpu = (unsigned long)hcpu;
427 struct acpi_processor *pr = per_cpu(processors, cpu); 127 struct acpi_processor *pr = per_cpu(processors, cpu);
128 struct acpi_device *device;
129
130 if (!pr || acpi_bus_get_device(pr->handle, &device))
131 return NOTIFY_DONE;
428 132
429 if (action == CPU_ONLINE && pr) { 133 if (action == CPU_ONLINE) {
430 /* CPU got physically hotplugged and onlined the first time: 134 /*
431 * Initialize missing things 135 * CPU got physically hotplugged and onlined for the first time:
136 * Initialize missing things.
432 */ 137 */
433 if (pr->flags.need_hotplug_init) { 138 if (pr->flags.need_hotplug_init) {
139 int ret;
140
434 pr_info("Will online and init hotplugged CPU: %d\n", 141 pr_info("Will online and init hotplugged CPU: %d\n",
435 pr->id); 142 pr->id);
436 WARN(acpi_processor_start(pr), "Failed to start CPU:"
437 " %d\n", pr->id);
438 pr->flags.need_hotplug_init = 0; 143 pr->flags.need_hotplug_init = 0;
439 /* Normal CPU soft online event */ 144 ret = __acpi_processor_start(device);
145 WARN(ret, "Failed to start CPU: %d\n", pr->id);
440 } else { 146 } else {
147 /* Normal CPU soft online event. */
441 acpi_processor_ppc_has_changed(pr, 0); 148 acpi_processor_ppc_has_changed(pr, 0);
442 acpi_processor_hotplug(pr); 149 acpi_processor_hotplug(pr);
443 acpi_processor_reevaluate_tstate(pr, action); 150 acpi_processor_reevaluate_tstate(pr, action);
444 acpi_processor_tstate_has_changed(pr); 151 acpi_processor_tstate_has_changed(pr);
445 } 152 }
446 } 153 } else if (action == CPU_DEAD) {
447 if (action == CPU_DEAD && pr) { 154 /* Invalidate flag.throttling after the CPU is offline. */
448 /* invalidate the flag.throttling after one CPU is offline */
449 acpi_processor_reevaluate_tstate(pr, action); 155 acpi_processor_reevaluate_tstate(pr, action);
450 } 156 }
451 return NOTIFY_OK; 157 return NOTIFY_OK;
452} 158}
453 159
454static struct notifier_block acpi_cpu_notifier = 160static struct notifier_block __refdata acpi_cpu_notifier =
455{ 161{
456 .notifier_call = acpi_cpu_soft_notify, 162 .notifier_call = acpi_cpu_soft_notify,
457}; 163};
458 164
459/* 165static int __acpi_processor_start(struct acpi_device *device)
460 * acpi_processor_start() is called by the cpu_hotplug_notifier func:
461 * acpi_cpu_soft_notify(). Getting it __cpuinit{data} is difficult, the
462 * root cause seem to be that acpi_processor_uninstall_hotplug_notify()
463 * is in the module_exit (__exit) func. Allowing acpi_processor_start()
464 * to not be in __cpuinit section, but being called from __cpuinit funcs
465 * via __ref looks like the right thing to do here.
466 */
467static __ref int acpi_processor_start(struct acpi_processor *pr)
468{ 166{
469 struct acpi_device *device = per_cpu(processor_device_array, pr->id); 167 struct acpi_processor *pr = acpi_driver_data(device);
168 acpi_status status;
470 int result = 0; 169 int result = 0;
471 170
171 if (!pr)
172 return -ENODEV;
173
174 if (pr->flags.need_hotplug_init)
175 return 0;
176
472#ifdef CONFIG_CPU_FREQ 177#ifdef CONFIG_CPU_FREQ
473 acpi_processor_ppc_has_changed(pr, 0); 178 acpi_processor_ppc_has_changed(pr, 0);
474 acpi_processor_load_module(pr); 179 acpi_processor_load_module(pr);
@@ -506,462 +211,95 @@ static __ref int acpi_processor_start(struct acpi_processor *pr)
506 goto err_remove_sysfs_thermal; 211 goto err_remove_sysfs_thermal;
507 } 212 }
508 213
509 return 0; 214 status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
215 acpi_processor_notify, device);
216 if (ACPI_SUCCESS(status))
217 return 0;
510 218
511err_remove_sysfs_thermal: 219 sysfs_remove_link(&pr->cdev->device.kobj, "device");
220 err_remove_sysfs_thermal:
512 sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); 221 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
513err_thermal_unregister: 222 err_thermal_unregister:
514 thermal_cooling_device_unregister(pr->cdev); 223 thermal_cooling_device_unregister(pr->cdev);
515err_power_exit: 224 err_power_exit:
516 acpi_processor_power_exit(pr); 225 acpi_processor_power_exit(pr);
517
518 return result; 226 return result;
519} 227}
520 228
521/* 229static int acpi_processor_start(struct device *dev)
522 * Do not put anything in here which needs the core to be online.
523 * For example MSR access or setting up things which check for cpuinfo_x86
524 * (cpu_data(cpu)) values, like CPU feature flags, family, model, etc.
525 * Such things have to be put in and set up above in acpi_processor_start()
526 */
527static int __cpuinit acpi_processor_add(struct acpi_device *device)
528{ 230{
529 struct acpi_processor *pr = NULL; 231 struct acpi_device *device;
530 int result = 0;
531 struct device *dev;
532
533 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
534 if (!pr)
535 return -ENOMEM;
536
537 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
538 result = -ENOMEM;
539 goto err_free_pr;
540 }
541
542 pr->handle = device->handle;
543 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
544 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
545 device->driver_data = pr;
546
547 result = acpi_processor_get_info(device);
548 if (result) {
549 /* Processor is physically not present */
550 return 0;
551 }
552 232
553#ifdef CONFIG_SMP 233 if (acpi_bus_get_device(ACPI_HANDLE(dev), &device))
554 if (pr->id >= setup_max_cpus && pr->id != 0) 234 return -ENODEV;
555 return 0;
556#endif
557
558 BUG_ON(pr->id >= nr_cpu_ids);
559
560 /*
561 * Buggy BIOS check
562 * ACPI id of processors can be reported wrongly by the BIOS.
563 * Don't trust it blindly
564 */
565 if (per_cpu(processor_device_array, pr->id) != NULL &&
566 per_cpu(processor_device_array, pr->id) != device) {
567 dev_warn(&device->dev,
568 "BIOS reported wrong ACPI id %d for the processor\n",
569 pr->id);
570 result = -ENODEV;
571 goto err_free_cpumask;
572 }
573 per_cpu(processor_device_array, pr->id) = device;
574 235
575 per_cpu(processors, pr->id) = pr; 236 return __acpi_processor_start(device);
576
577 dev = get_cpu_device(pr->id);
578 if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) {
579 result = -EFAULT;
580 goto err_clear_processor;
581 }
582
583 /*
584 * Do not start hotplugged CPUs now, but when they
585 * are onlined the first time
586 */
587 if (pr->flags.need_hotplug_init)
588 return 0;
589
590 result = acpi_processor_start(pr);
591 if (result)
592 goto err_remove_sysfs;
593
594 return 0;
595
596err_remove_sysfs:
597 sysfs_remove_link(&device->dev.kobj, "sysdev");
598err_clear_processor:
599 /*
600 * processor_device_array is not cleared to allow checks for buggy BIOS
601 */
602 per_cpu(processors, pr->id) = NULL;
603err_free_cpumask:
604 free_cpumask_var(pr->throttling.shared_cpu_map);
605err_free_pr:
606 kfree(pr);
607 return result;
608} 237}
609 238
610static int acpi_processor_remove(struct acpi_device *device) 239static int acpi_processor_stop(struct device *dev)
611{ 240{
612 struct acpi_processor *pr = NULL; 241 struct acpi_device *device;
242 struct acpi_processor *pr;
613 243
244 if (acpi_bus_get_device(ACPI_HANDLE(dev), &device))
245 return 0;
614 246
615 if (!device || !acpi_driver_data(device)) 247 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
616 return -EINVAL; 248 acpi_processor_notify);
617 249
618 pr = acpi_driver_data(device); 250 pr = acpi_driver_data(device);
619 251 if (!pr)
620 if (pr->id >= nr_cpu_ids) 252 return 0;
621 goto free;
622
623 if (device->removal_type == ACPI_BUS_REMOVAL_EJECT) {
624 if (acpi_processor_handle_eject(pr))
625 return -EINVAL;
626 }
627 253
628 acpi_processor_power_exit(pr); 254 acpi_processor_power_exit(pr);
629 255
630 sysfs_remove_link(&device->dev.kobj, "sysdev");
631
632 if (pr->cdev) { 256 if (pr->cdev) {
633 sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); 257 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
634 sysfs_remove_link(&pr->cdev->device.kobj, "device"); 258 sysfs_remove_link(&pr->cdev->device.kobj, "device");
635 thermal_cooling_device_unregister(pr->cdev); 259 thermal_cooling_device_unregister(pr->cdev);
636 pr->cdev = NULL; 260 pr->cdev = NULL;
637 } 261 }
638
639 per_cpu(processors, pr->id) = NULL;
640 per_cpu(processor_device_array, pr->id) = NULL;
641 try_offline_node(cpu_to_node(pr->id));
642
643free:
644 free_cpumask_var(pr->throttling.shared_cpu_map);
645 kfree(pr);
646
647 return 0; 262 return 0;
648} 263}
649 264
650#ifdef CONFIG_ACPI_HOTPLUG_CPU
651/****************************************************************************
652 * Acpi processor hotplug support *
653 ****************************************************************************/
654
655static int is_processor_present(acpi_handle handle)
656{
657 acpi_status status;
658 unsigned long long sta = 0;
659
660
661 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
662
663 if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT))
664 return 1;
665
666 /*
667 * _STA is mandatory for a processor that supports hot plug
668 */
669 if (status == AE_NOT_FOUND)
670 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
671 "Processor does not support hot plug\n"));
672 else
673 ACPI_EXCEPTION((AE_INFO, status,
674 "Processor Device is not present"));
675 return 0;
676}
677
678static void acpi_processor_hotplug_notify(acpi_handle handle,
679 u32 event, void *data)
680{
681 struct acpi_device *device = NULL;
682 struct acpi_eject_event *ej_event = NULL;
683 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
684 acpi_status status;
685 int result;
686
687 acpi_scan_lock_acquire();
688
689 switch (event) {
690 case ACPI_NOTIFY_BUS_CHECK:
691 case ACPI_NOTIFY_DEVICE_CHECK:
692 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
693 "Processor driver received %s event\n",
694 (event == ACPI_NOTIFY_BUS_CHECK) ?
695 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"));
696
697 if (!is_processor_present(handle))
698 break;
699
700 if (!acpi_bus_get_device(handle, &device))
701 break;
702
703 result = acpi_bus_scan(handle);
704 if (result) {
705 acpi_handle_err(handle, "Unable to add the device\n");
706 break;
707 }
708 result = acpi_bus_get_device(handle, &device);
709 if (result) {
710 acpi_handle_err(handle, "Missing device object\n");
711 break;
712 }
713 ost_code = ACPI_OST_SC_SUCCESS;
714 break;
715
716 case ACPI_NOTIFY_EJECT_REQUEST:
717 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
718 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
719
720 if (acpi_bus_get_device(handle, &device)) {
721 acpi_handle_err(handle,
722 "Device don't exist, dropping EJECT\n");
723 break;
724 }
725 if (!acpi_driver_data(device)) {
726 acpi_handle_err(handle,
727 "Driver data is NULL, dropping EJECT\n");
728 break;
729 }
730
731 ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL);
732 if (!ej_event) {
733 acpi_handle_err(handle, "No memory, dropping EJECT\n");
734 break;
735 }
736
737 get_device(&device->dev);
738 ej_event->device = device;
739 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
740 /* The eject is carried out asynchronously. */
741 status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
742 ej_event);
743 if (ACPI_FAILURE(status)) {
744 put_device(&device->dev);
745 kfree(ej_event);
746 break;
747 }
748 goto out;
749
750 default:
751 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
752 "Unsupported event [0x%x]\n", event));
753
754 /* non-hotplug event; possibly handled by other handler */
755 goto out;
756 }
757
758 /* Inform firmware that the hotplug operation has completed */
759 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL);
760
761 out:
762 acpi_scan_lock_release();
763}
764
765static acpi_status is_processor_device(acpi_handle handle)
766{
767 struct acpi_device_info *info;
768 char *hid;
769 acpi_status status;
770
771 status = acpi_get_object_info(handle, &info);
772 if (ACPI_FAILURE(status))
773 return status;
774
775 if (info->type == ACPI_TYPE_PROCESSOR) {
776 kfree(info);
777 return AE_OK; /* found a processor object */
778 }
779
780 if (!(info->valid & ACPI_VALID_HID)) {
781 kfree(info);
782 return AE_ERROR;
783 }
784
785 hid = info->hardware_id.string;
786 if ((hid == NULL) || strcmp(hid, ACPI_PROCESSOR_DEVICE_HID)) {
787 kfree(info);
788 return AE_ERROR;
789 }
790
791 kfree(info);
792 return AE_OK; /* found a processor device object */
793}
794
795static acpi_status
796processor_walk_namespace_cb(acpi_handle handle,
797 u32 lvl, void *context, void **rv)
798{
799 acpi_status status;
800 int *action = context;
801
802 status = is_processor_device(handle);
803 if (ACPI_FAILURE(status))
804 return AE_OK; /* not a processor; continue to walk */
805
806 switch (*action) {
807 case INSTALL_NOTIFY_HANDLER:
808 acpi_install_notify_handler(handle,
809 ACPI_SYSTEM_NOTIFY,
810 acpi_processor_hotplug_notify,
811 NULL);
812 break;
813 case UNINSTALL_NOTIFY_HANDLER:
814 acpi_remove_notify_handler(handle,
815 ACPI_SYSTEM_NOTIFY,
816 acpi_processor_hotplug_notify);
817 break;
818 default:
819 break;
820 }
821
822 /* found a processor; skip walking underneath */
823 return AE_CTRL_DEPTH;
824}
825
826static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr)
827{
828 acpi_handle handle = pr->handle;
829
830 if (!is_processor_present(handle)) {
831 return AE_ERROR;
832 }
833
834 if (acpi_map_lsapic(handle, &pr->id))
835 return AE_ERROR;
836
837 if (arch_register_cpu(pr->id)) {
838 acpi_unmap_lsapic(pr->id);
839 return AE_ERROR;
840 }
841
842 /* CPU got hot-plugged, but cpu_data is not initialized yet
843 * Set flag to delay cpu_idle/throttling initialization
844 * in:
845 * acpi_processor_add()
846 * acpi_processor_get_info()
847 * and do it when the CPU gets online the first time
848 * TBD: Cleanup above functions and try to do this more elegant.
849 */
850 pr_info("CPU %d got hotplugged\n", pr->id);
851 pr->flags.need_hotplug_init = 1;
852
853 return AE_OK;
854}
855
856static int acpi_processor_handle_eject(struct acpi_processor *pr)
857{
858 if (cpu_online(pr->id))
859 cpu_down(pr->id);
860
861 get_online_cpus();
862 /*
863 * The cpu might become online again at this point. So we check whether
864 * the cpu has been onlined or not. If the cpu became online, it means
865 * that someone wants to use the cpu. So acpi_processor_handle_eject()
866 * returns -EAGAIN.
867 */
868 if (unlikely(cpu_online(pr->id))) {
869 put_online_cpus();
870 pr_warn("Failed to remove CPU %d, because other task "
871 "brought the CPU back online\n", pr->id);
872 return -EAGAIN;
873 }
874 arch_unregister_cpu(pr->id);
875 acpi_unmap_lsapic(pr->id);
876 put_online_cpus();
877 return (0);
878}
879#else
880static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr)
881{
882 return AE_ERROR;
883}
884static int acpi_processor_handle_eject(struct acpi_processor *pr)
885{
886 return (-EINVAL);
887}
888#endif
889
890static
891void acpi_processor_install_hotplug_notify(void)
892{
893#ifdef CONFIG_ACPI_HOTPLUG_CPU
894 int action = INSTALL_NOTIFY_HANDLER;
895 acpi_walk_namespace(ACPI_TYPE_ANY,
896 ACPI_ROOT_OBJECT,
897 ACPI_UINT32_MAX,
898 processor_walk_namespace_cb, NULL, &action, NULL);
899#endif
900 register_hotcpu_notifier(&acpi_cpu_notifier);
901}
902
903static
904void acpi_processor_uninstall_hotplug_notify(void)
905{
906#ifdef CONFIG_ACPI_HOTPLUG_CPU
907 int action = UNINSTALL_NOTIFY_HANDLER;
908 acpi_walk_namespace(ACPI_TYPE_ANY,
909 ACPI_ROOT_OBJECT,
910 ACPI_UINT32_MAX,
911 processor_walk_namespace_cb, NULL, &action, NULL);
912#endif
913 unregister_hotcpu_notifier(&acpi_cpu_notifier);
914}
915
916/* 265/*
917 * We keep the driver loaded even when ACPI is not running. 266 * We keep the driver loaded even when ACPI is not running.
918 * This is needed for the powernow-k8 driver, that works even without 267 * This is needed for the powernow-k8 driver, that works even without
919 * ACPI, but needs symbols from this driver 268 * ACPI, but needs symbols from this driver
920 */ 269 */
921 270
922static int __init acpi_processor_init(void) 271static int __init acpi_processor_driver_init(void)
923{ 272{
924 int result = 0; 273 int result = 0;
925 274
926 if (acpi_disabled) 275 if (acpi_disabled)
927 return 0; 276 return 0;
928 277
929 result = acpi_bus_register_driver(&acpi_processor_driver); 278 result = driver_register(&acpi_processor_driver);
930 if (result < 0) 279 if (result < 0)
931 return result; 280 return result;
932 281
933 acpi_processor_syscore_init(); 282 acpi_processor_syscore_init();
934 283 register_hotcpu_notifier(&acpi_cpu_notifier);
935 acpi_processor_install_hotplug_notify();
936
937 acpi_thermal_cpufreq_init(); 284 acpi_thermal_cpufreq_init();
938
939 acpi_processor_ppc_init(); 285 acpi_processor_ppc_init();
940
941 acpi_processor_throttling_init(); 286 acpi_processor_throttling_init();
942
943 return 0; 287 return 0;
944} 288}
945 289
946static void __exit acpi_processor_exit(void) 290static void __exit acpi_processor_driver_exit(void)
947{ 291{
948 if (acpi_disabled) 292 if (acpi_disabled)
949 return; 293 return;
950 294
951 acpi_processor_ppc_exit(); 295 acpi_processor_ppc_exit();
952
953 acpi_thermal_cpufreq_exit(); 296 acpi_thermal_cpufreq_exit();
954 297 unregister_hotcpu_notifier(&acpi_cpu_notifier);
955 acpi_processor_uninstall_hotplug_notify();
956
957 acpi_processor_syscore_exit(); 298 acpi_processor_syscore_exit();
958 299 driver_unregister(&acpi_processor_driver);
959 acpi_bus_unregister_driver(&acpi_processor_driver);
960
961 return;
962} 300}
963 301
964module_init(acpi_processor_init); 302module_init(acpi_processor_driver_init);
965module_exit(acpi_processor_exit); 303module_exit(acpi_processor_driver_exit);
966 304
967MODULE_ALIAS("processor"); 305MODULE_ALIAS("processor");
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index eb133c77aadb..f98dd00b51a9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -96,9 +96,7 @@ static int set_max_cstate(const struct dmi_system_id *id)
96 return 0; 96 return 0;
97} 97}
98 98
99/* Actually this shouldn't be __cpuinitdata, would be better to fix the 99static struct dmi_system_id processor_power_dmi_table[] = {
100 callers to only run once -AK */
101static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
102 { set_max_cstate, "Clevo 5600D", { 100 { set_max_cstate, "Clevo 5600D", {
103 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), 101 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
104 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")}, 102 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")},
@@ -214,13 +212,13 @@ static void lapic_timer_state_broadcast(struct acpi_processor *pr,
214#ifdef CONFIG_PM_SLEEP 212#ifdef CONFIG_PM_SLEEP
215static u32 saved_bm_rld; 213static u32 saved_bm_rld;
216 214
217int acpi_processor_suspend(void) 215static int acpi_processor_suspend(void)
218{ 216{
219 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld); 217 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld);
220 return 0; 218 return 0;
221} 219}
222 220
223void acpi_processor_resume(void) 221static void acpi_processor_resume(void)
224{ 222{
225 u32 resumed_bm_rld; 223 u32 resumed_bm_rld;
226 224
@@ -1165,7 +1163,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1165 1163
1166static int acpi_processor_registered; 1164static int acpi_processor_registered;
1167 1165
1168int __cpuinit acpi_processor_power_init(struct acpi_processor *pr) 1166int acpi_processor_power_init(struct acpi_processor *pr)
1169{ 1167{
1170 acpi_status status = 0; 1168 acpi_status status = 0;
1171 int retval; 1169 int retval;
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index e854582f29a6..1e9732d809bf 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -639,7 +639,7 @@ end:
639int acpi_processor_preregister_performance( 639int acpi_processor_preregister_performance(
640 struct acpi_processor_performance __percpu *performance) 640 struct acpi_processor_performance __percpu *performance)
641{ 641{
642 int count, count_target; 642 int count_target;
643 int retval = 0; 643 int retval = 0;
644 unsigned int i, j; 644 unsigned int i, j;
645 cpumask_var_t covered_cpus; 645 cpumask_var_t covered_cpus;
@@ -711,7 +711,6 @@ int acpi_processor_preregister_performance(
711 711
712 /* Validate the Domain info */ 712 /* Validate the Domain info */
713 count_target = pdomain->num_processors; 713 count_target = pdomain->num_processors;
714 count = 1;
715 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL) 714 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
716 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; 715 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
717 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) 716 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL)
@@ -745,7 +744,6 @@ int acpi_processor_preregister_performance(
745 744
746 cpumask_set_cpu(j, covered_cpus); 745 cpumask_set_cpu(j, covered_cpus);
747 cpumask_set_cpu(j, pr->performance->shared_cpu_map); 746 cpumask_set_cpu(j, pr->performance->shared_cpu_map);
748 count++;
749 } 747 }
750 748
751 for_each_possible_cpu(j) { 749 for_each_possible_cpu(j) {
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 27da63061e11..8a46c924effd 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -27,9 +27,14 @@ extern struct acpi_device *acpi_root;
27 27
28#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) 28#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
29 29
30/*
31 * If set, devices will be hot-removed even if they cannot be put offline
32 * gracefully (from the kernel's standpoint).
33 */
34bool acpi_force_hot_remove;
35
30static const char *dummy_hid = "device"; 36static const char *dummy_hid = "device";
31 37
32static LIST_HEAD(acpi_device_list);
33static LIST_HEAD(acpi_bus_id_list); 38static LIST_HEAD(acpi_bus_id_list);
34static DEFINE_MUTEX(acpi_scan_lock); 39static DEFINE_MUTEX(acpi_scan_lock);
35static LIST_HEAD(acpi_scan_handlers_list); 40static LIST_HEAD(acpi_scan_handlers_list);
@@ -120,12 +125,78 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha
120} 125}
121static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); 126static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
122 127
128static acpi_status acpi_bus_offline_companions(acpi_handle handle, u32 lvl,
129 void *data, void **ret_p)
130{
131 struct acpi_device *device = NULL;
132 struct acpi_device_physical_node *pn;
133 bool second_pass = (bool)data;
134 acpi_status status = AE_OK;
135
136 if (acpi_bus_get_device(handle, &device))
137 return AE_OK;
138
139 mutex_lock(&device->physical_node_lock);
140
141 list_for_each_entry(pn, &device->physical_node_list, node) {
142 int ret;
143
144 if (second_pass) {
145 /* Skip devices offlined by the first pass. */
146 if (pn->put_online)
147 continue;
148 } else {
149 pn->put_online = false;
150 }
151 ret = device_offline(pn->dev);
152 if (acpi_force_hot_remove)
153 continue;
154
155 if (ret >= 0) {
156 pn->put_online = !ret;
157 } else {
158 *ret_p = pn->dev;
159 if (second_pass) {
160 status = AE_ERROR;
161 break;
162 }
163 }
164 }
165
166 mutex_unlock(&device->physical_node_lock);
167
168 return status;
169}
170
171static acpi_status acpi_bus_online_companions(acpi_handle handle, u32 lvl,
172 void *data, void **ret_p)
173{
174 struct acpi_device *device = NULL;
175 struct acpi_device_physical_node *pn;
176
177 if (acpi_bus_get_device(handle, &device))
178 return AE_OK;
179
180 mutex_lock(&device->physical_node_lock);
181
182 list_for_each_entry(pn, &device->physical_node_list, node)
183 if (pn->put_online) {
184 device_online(pn->dev);
185 pn->put_online = false;
186 }
187
188 mutex_unlock(&device->physical_node_lock);
189
190 return AE_OK;
191}
192
123static int acpi_scan_hot_remove(struct acpi_device *device) 193static int acpi_scan_hot_remove(struct acpi_device *device)
124{ 194{
125 acpi_handle handle = device->handle; 195 acpi_handle handle = device->handle;
126 acpi_handle not_used; 196 acpi_handle not_used;
127 struct acpi_object_list arg_list; 197 struct acpi_object_list arg_list;
128 union acpi_object arg; 198 union acpi_object arg;
199 struct device *errdev;
129 acpi_status status; 200 acpi_status status;
130 unsigned long long sta; 201 unsigned long long sta;
131 202
@@ -136,10 +207,53 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
136 return -EINVAL; 207 return -EINVAL;
137 } 208 }
138 209
210 lock_device_hotplug();
211
212 /*
213 * Carry out two passes here and ignore errors in the first pass,
214 * because if the devices in question are memory blocks and
215 * CONFIG_MEMCG is set, one of the blocks may hold data structures
216 * that the other blocks depend on, but it is not known in advance which
217 * block holds them.
218 *
219 * If the first pass is successful, the second one isn't needed, though.
220 */
221 errdev = NULL;
222 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
223 NULL, acpi_bus_offline_companions,
224 (void *)false, (void **)&errdev);
225 acpi_bus_offline_companions(handle, 0, (void *)false, (void **)&errdev);
226 if (errdev) {
227 errdev = NULL;
228 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
229 NULL, acpi_bus_offline_companions,
230 (void *)true , (void **)&errdev);
231 if (!errdev || acpi_force_hot_remove)
232 acpi_bus_offline_companions(handle, 0, (void *)true,
233 (void **)&errdev);
234
235 if (errdev && !acpi_force_hot_remove) {
236 dev_warn(errdev, "Offline failed.\n");
237 acpi_bus_online_companions(handle, 0, NULL, NULL);
238 acpi_walk_namespace(ACPI_TYPE_ANY, handle,
239 ACPI_UINT32_MAX,
240 acpi_bus_online_companions, NULL,
241 NULL, NULL);
242
243 unlock_device_hotplug();
244
245 put_device(&device->dev);
246 return -EBUSY;
247 }
248 }
249
139 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 250 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
140 "Hot-removing device %s...\n", dev_name(&device->dev))); 251 "Hot-removing device %s...\n", dev_name(&device->dev)));
141 252
142 acpi_bus_trim(device); 253 acpi_bus_trim(device);
254
255 unlock_device_hotplug();
256
143 /* Device node has been unregistered. */ 257 /* Device node has been unregistered. */
144 put_device(&device->dev); 258 put_device(&device->dev);
145 device = NULL; 259 device = NULL;
@@ -236,11 +350,14 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
236 int error; 350 int error;
237 351
238 mutex_lock(&acpi_scan_lock); 352 mutex_lock(&acpi_scan_lock);
353 lock_device_hotplug();
239 354
240 acpi_bus_get_device(handle, &device); 355 if (ost_source != ACPI_NOTIFY_BUS_CHECK) {
241 if (device) { 356 acpi_bus_get_device(handle, &device);
242 dev_warn(&device->dev, "Attempt to re-insert\n"); 357 if (device) {
243 goto out; 358 dev_warn(&device->dev, "Attempt to re-insert\n");
359 goto out;
360 }
244 } 361 }
245 acpi_evaluate_hotplug_ost(handle, ost_source, 362 acpi_evaluate_hotplug_ost(handle, ost_source,
246 ACPI_OST_SC_INSERT_IN_PROGRESS, NULL); 363 ACPI_OST_SC_INSERT_IN_PROGRESS, NULL);
@@ -259,6 +376,7 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
259 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); 376 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
260 377
261 out: 378 out:
379 unlock_device_hotplug();
262 acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); 380 acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL);
263 mutex_unlock(&acpi_scan_lock); 381 mutex_unlock(&acpi_scan_lock);
264} 382}
@@ -816,32 +934,43 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
816 acpi_device_notify); 934 acpi_device_notify);
817} 935}
818 936
819static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); 937static int acpi_device_probe(struct device *dev)
820static int acpi_device_probe(struct device * dev)
821{ 938{
822 struct acpi_device *acpi_dev = to_acpi_device(dev); 939 struct acpi_device *acpi_dev = to_acpi_device(dev);
823 struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); 940 struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
824 int ret; 941 int ret;
825 942
826 ret = acpi_bus_driver_init(acpi_dev, acpi_drv); 943 if (acpi_dev->handler)
827 if (!ret) { 944 return -EINVAL;
828 if (acpi_drv->ops.notify) {
829 ret = acpi_device_install_notify_handler(acpi_dev);
830 if (ret) {
831 if (acpi_drv->ops.remove)
832 acpi_drv->ops.remove(acpi_dev);
833 acpi_dev->driver = NULL;
834 acpi_dev->driver_data = NULL;
835 return ret;
836 }
837 }
838 945
839 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 946 if (!acpi_drv->ops.add)
840 "Found driver [%s] for device [%s]\n", 947 return -ENOSYS;
841 acpi_drv->name, acpi_dev->pnp.bus_id)); 948
842 get_device(dev); 949 ret = acpi_drv->ops.add(acpi_dev);
950 if (ret)
951 return ret;
952
953 acpi_dev->driver = acpi_drv;
954 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
955 "Driver [%s] successfully bound to device [%s]\n",
956 acpi_drv->name, acpi_dev->pnp.bus_id));
957
958 if (acpi_drv->ops.notify) {
959 ret = acpi_device_install_notify_handler(acpi_dev);
960 if (ret) {
961 if (acpi_drv->ops.remove)
962 acpi_drv->ops.remove(acpi_dev);
963
964 acpi_dev->driver = NULL;
965 acpi_dev->driver_data = NULL;
966 return ret;
967 }
843 } 968 }
844 return ret; 969
970 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
971 acpi_drv->name, acpi_dev->pnp.bus_id));
972 get_device(dev);
973 return 0;
845} 974}
846 975
847static int acpi_device_remove(struct device * dev) 976static int acpi_device_remove(struct device * dev)
@@ -952,7 +1081,6 @@ int acpi_device_add(struct acpi_device *device,
952 printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", 1081 printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n",
953 dev_name(&device->dev)); 1082 dev_name(&device->dev));
954 1083
955 device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
956 return 0; 1084 return 0;
957 1085
958 err: 1086 err:
@@ -998,41 +1126,6 @@ static void acpi_device_unregister(struct acpi_device *device)
998 Driver Management 1126 Driver Management
999 -------------------------------------------------------------------------- */ 1127 -------------------------------------------------------------------------- */
1000/** 1128/**
1001 * acpi_bus_driver_init - add a device to a driver
1002 * @device: the device to add and initialize
1003 * @driver: driver for the device
1004 *
1005 * Used to initialize a device via its device driver. Called whenever a
1006 * driver is bound to a device. Invokes the driver's add() ops.
1007 */
1008static int
1009acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
1010{
1011 int result = 0;
1012
1013 if (!device || !driver)
1014 return -EINVAL;
1015
1016 if (!driver->ops.add)
1017 return -ENOSYS;
1018
1019 result = driver->ops.add(device);
1020 if (result)
1021 return result;
1022
1023 device->driver = driver;
1024
1025 /*
1026 * TBD - Configuration Management: Assign resources to device based
1027 * upon possible configuration and currently allocated resources.
1028 */
1029
1030 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1031 "Driver successfully bound to device\n"));
1032 return 0;
1033}
1034
1035/**
1036 * acpi_bus_register_driver - register a driver with the ACPI bus 1129 * acpi_bus_register_driver - register a driver with the ACPI bus
1037 * @driver: driver being registered 1130 * @driver: driver being registered
1038 * 1131 *
@@ -1890,6 +1983,9 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1890 if (acpi_bus_get_device(handle, &device)) 1983 if (acpi_bus_get_device(handle, &device))
1891 return AE_CTRL_DEPTH; 1984 return AE_CTRL_DEPTH;
1892 1985
1986 if (device->handler)
1987 return AE_OK;
1988
1893 ret = acpi_scan_attach_handler(device); 1989 ret = acpi_scan_attach_handler(device);
1894 if (ret) 1990 if (ret)
1895 return ret > 0 ? AE_OK : AE_CTRL_DEPTH; 1991 return ret > 0 ? AE_OK : AE_CTRL_DEPTH;
@@ -1939,7 +2035,6 @@ static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
1939 if (!acpi_bus_get_device(handle, &device)) { 2035 if (!acpi_bus_get_device(handle, &device)) {
1940 struct acpi_scan_handler *dev_handler = device->handler; 2036 struct acpi_scan_handler *dev_handler = device->handler;
1941 2037
1942 device->removal_type = ACPI_BUS_REMOVAL_EJECT;
1943 if (dev_handler) { 2038 if (dev_handler) {
1944 if (dev_handler->detach) 2039 if (dev_handler->detach)
1945 dev_handler->detach(device); 2040 dev_handler->detach(device);
@@ -2038,8 +2133,10 @@ int __init acpi_scan_init(void)
2038 2133
2039 acpi_pci_root_init(); 2134 acpi_pci_root_init();
2040 acpi_pci_link_init(); 2135 acpi_pci_link_init();
2136 acpi_processor_init();
2041 acpi_platform_init(); 2137 acpi_platform_init();
2042 acpi_lpss_init(); 2138 acpi_lpss_init();
2139 acpi_cmos_rtc_init();
2043 acpi_container_init(); 2140 acpi_container_init();
2044 acpi_memory_hotplug_init(); 2141 acpi_memory_hotplug_init();
2045 acpi_dock_init(); 2142 acpi_dock_init();
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 9c1a435d10e6..187ab61889e6 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -494,6 +494,8 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
494 break; 494 break;
495 495
496 case ACPI_STATE_S3: 496 case ACPI_STATE_S3:
497 if (!acpi_suspend_lowlevel)
498 return -ENOSYS;
497 error = acpi_suspend_lowlevel(); 499 error = acpi_suspend_lowlevel();
498 if (error) 500 if (error)
499 return error; 501 return error;
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index fcae5fa2e1b3..05306a59aedc 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -677,10 +677,9 @@ void acpi_irq_stats_init(void)
677 else 677 else
678 sprintf(buffer, "bug%02X", i); 678 sprintf(buffer, "bug%02X", i);
679 679
680 name = kzalloc(strlen(buffer) + 1, GFP_KERNEL); 680 name = kstrdup(buffer, GFP_KERNEL);
681 if (name == NULL) 681 if (name == NULL)
682 goto fail; 682 goto fail;
683 strncpy(name, buffer, strlen(buffer) + 1);
684 683
685 sysfs_attr_init(&counter_attrs[i].attr); 684 sysfs_attr_init(&counter_attrs[i].attr);
686 counter_attrs[i].attr.name = name; 685 counter_attrs[i].attr.name = name;
@@ -780,6 +779,33 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
780 pr_err(PREFIX "Unable to add hotplug profile '%s'\n", name); 779 pr_err(PREFIX "Unable to add hotplug profile '%s'\n", name);
781} 780}
782 781
782static ssize_t force_remove_show(struct kobject *kobj,
783 struct kobj_attribute *attr, char *buf)
784{
785 return sprintf(buf, "%d\n", !!acpi_force_hot_remove);
786}
787
788static ssize_t force_remove_store(struct kobject *kobj,
789 struct kobj_attribute *attr,
790 const char *buf, size_t size)
791{
792 bool val;
793 int ret;
794
795 ret = strtobool(buf, &val);
796 if (ret < 0)
797 return ret;
798
799 lock_device_hotplug();
800 acpi_force_hot_remove = val;
801 unlock_device_hotplug();
802 return size;
803}
804
805static const struct kobj_attribute force_remove_attr =
806 __ATTR(force_remove, S_IRUGO | S_IWUSR, force_remove_show,
807 force_remove_store);
808
783int __init acpi_sysfs_init(void) 809int __init acpi_sysfs_init(void)
784{ 810{
785 int result; 811 int result;
@@ -789,6 +815,10 @@ int __init acpi_sysfs_init(void)
789 return result; 815 return result;
790 816
791 hotplug_kobj = kobject_create_and_add("hotplug", acpi_kobj); 817 hotplug_kobj = kobject_create_and_add("hotplug", acpi_kobj);
818 result = sysfs_create_file(hotplug_kobj, &force_remove_attr.attr);
819 if (result)
820 return result;
821
792 result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); 822 result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr);
793 return result; 823 return result;
794} 824}
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 440eadf2d32c..0ec434d2586d 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -44,6 +44,8 @@
44#include <linux/suspend.h> 44#include <linux/suspend.h>
45#include <acpi/video.h> 45#include <acpi/video.h>
46 46
47#include "internal.h"
48
47#define PREFIX "ACPI: " 49#define PREFIX "ACPI: "
48 50
49#define ACPI_VIDEO_BUS_NAME "Video Bus" 51#define ACPI_VIDEO_BUS_NAME "Video Bus"
@@ -450,6 +452,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
450 }, 452 },
451 { 453 {
452 .callback = video_ignore_initial_backlight, 454 .callback = video_ignore_initial_backlight,
455 .ident = "Fujitsu E753",
456 .matches = {
457 DMI_MATCH(DMI_BOARD_VENDOR, "FUJITSU"),
458 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E753"),
459 },
460 },
461 {
462 .callback = video_ignore_initial_backlight,
453 .ident = "HP Pavilion dm4", 463 .ident = "HP Pavilion dm4",
454 .matches = { 464 .matches = {
455 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 465 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
@@ -898,6 +908,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
898 device->cap._DDC = 1; 908 device->cap._DDC = 1;
899 } 909 }
900 910
911 if (acpi_video_init_brightness(device))
912 return;
913
901 if (acpi_video_backlight_support()) { 914 if (acpi_video_backlight_support()) {
902 struct backlight_properties props; 915 struct backlight_properties props;
903 struct pci_dev *pdev; 916 struct pci_dev *pdev;
@@ -907,9 +920,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
907 static int count = 0; 920 static int count = 0;
908 char *name; 921 char *name;
909 922
910 result = acpi_video_init_brightness(device);
911 if (result)
912 return;
913 name = kasprintf(GFP_KERNEL, "acpi_video%d", count); 923 name = kasprintf(GFP_KERNEL, "acpi_video%d", count);
914 if (!name) 924 if (!name)
915 return; 925 return;
@@ -969,6 +979,11 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
969 if (result) 979 if (result)
970 printk(KERN_ERR PREFIX "Create sysfs link\n"); 980 printk(KERN_ERR PREFIX "Create sysfs link\n");
971 981
982 } else {
983 /* Remove the brightness object. */
984 kfree(device->brightness->levels);
985 kfree(device->brightness);
986 device->brightness = NULL;
972 } 987 }
973} 988}
974 989
@@ -1532,14 +1547,20 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1532 1547
1533/* acpi_video interface */ 1548/* acpi_video interface */
1534 1549
1550/*
1551 * Win8 requires setting bit2 of _DOS to let firmware know it shouldn't
1552 * preform any automatic brightness change on receiving a notification.
1553 */
1535static int acpi_video_bus_start_devices(struct acpi_video_bus *video) 1554static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
1536{ 1555{
1537 return acpi_video_bus_DOS(video, 0, 0); 1556 return acpi_video_bus_DOS(video, 0,
1557 acpi_video_backlight_quirks() ? 1 : 0);
1538} 1558}
1539 1559
1540static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) 1560static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1541{ 1561{
1542 return acpi_video_bus_DOS(video, 0, 1); 1562 return acpi_video_bus_DOS(video, 0,
1563 acpi_video_backlight_quirks() ? 0 : 1);
1543} 1564}
1544 1565
1545static void acpi_video_bus_notify(struct acpi_device *device, u32 event) 1566static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
@@ -1722,9 +1743,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
1722 int error; 1743 int error;
1723 acpi_status status; 1744 acpi_status status;
1724 1745
1725 if (device->handler)
1726 return -EINVAL;
1727
1728 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, 1746 status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
1729 device->parent->handle, 1, 1747 device->parent->handle, 1,
1730 acpi_video_bus_match, NULL, 1748 acpi_video_bus_match, NULL,
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index e6bd910bc6ed..c3397748ba46 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -38,6 +38,8 @@
38#include <linux/dmi.h> 38#include <linux/dmi.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40 40
41#include "internal.h"
42
41#define PREFIX "ACPI: " 43#define PREFIX "ACPI: "
42 44
43ACPI_MODULE_NAME("video"); 45ACPI_MODULE_NAME("video");
@@ -234,6 +236,12 @@ static void acpi_video_caps_check(void)
234 acpi_video_get_capabilities(NULL); 236 acpi_video_get_capabilities(NULL);
235} 237}
236 238
239bool acpi_video_backlight_quirks(void)
240{
241 return acpi_gbl_osi_data >= ACPI_OSI_WIN_8;
242}
243EXPORT_SYMBOL(acpi_video_backlight_quirks);
244
237/* Promote the vendor interface instead of the generic video module. 245/* Promote the vendor interface instead of the generic video module.
238 * This function allow DMI blacklists to be implemented by externals 246 * This function allow DMI blacklists to be implemented by externals
239 * platform drivers instead of putting a big blacklist in video_detect.c 247 * platform drivers instead of putting a big blacklist in video_detect.c