diff options
Diffstat (limited to 'drivers/acpi')
82 files changed, 3409 insertions, 2185 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index da49b006bcc5..b0243fd55ac0 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -42,7 +42,7 @@ if ACPI | |||
42 | 42 | ||
43 | config ACPI_SLEEP | 43 | config ACPI_SLEEP |
44 | bool | 44 | bool |
45 | depends on PM_SLEEP | 45 | depends on SUSPEND || HIBERNATION |
46 | default y | 46 | default y |
47 | 47 | ||
48 | config ACPI_PROCFS | 48 | config ACPI_PROCFS |
@@ -157,18 +157,11 @@ config ACPI_FAN | |||
157 | applications to perform basic fan control (on, off, status). | 157 | applications to perform basic fan control (on, off, status). |
158 | 158 | ||
159 | config ACPI_DOCK | 159 | config ACPI_DOCK |
160 | tristate "Dock" | 160 | bool "Dock" |
161 | depends on EXPERIMENTAL | 161 | depends on EXPERIMENTAL |
162 | help | 162 | help |
163 | This driver adds support for ACPI controlled docking stations | 163 | This driver adds support for ACPI controlled docking stations and removable |
164 | 164 | drive bays such as the IBM ultrabay or the Dell Module Bay. | |
165 | config ACPI_BAY | ||
166 | tristate "Removable Drive Bay (EXPERIMENTAL)" | ||
167 | depends on EXPERIMENTAL | ||
168 | depends on ACPI_DOCK | ||
169 | help | ||
170 | This driver adds support for ACPI controlled removable drive | ||
171 | bays such as the IBM ultrabay or the Dell Module Bay. | ||
172 | 165 | ||
173 | config ACPI_PROCESSOR | 166 | config ACPI_PROCESSOR |
174 | tristate "Processor" | 167 | tristate "Processor" |
@@ -319,9 +312,13 @@ config ACPI_DEBUG | |||
319 | bool "Debug Statements" | 312 | bool "Debug Statements" |
320 | default n | 313 | default n |
321 | help | 314 | help |
322 | The ACPI driver can optionally report errors with a great deal | 315 | The ACPI subsystem can produce debug output. Saying Y enables this |
323 | of verbosity. Saying Y enables these statements. This will increase | 316 | output and increases the kernel size by around 50K. |
324 | your kernel size by around 50K. | 317 | |
318 | Use the acpi.debug_layer and acpi.debug_level kernel command-line | ||
319 | parameters documented in Documentation/acpi/debug.txt and | ||
320 | Documentation/kernel-parameters.txt to control the type and | ||
321 | amount of debug output. | ||
325 | 322 | ||
326 | config ACPI_DEBUG_FUNC_TRACE | 323 | config ACPI_DEBUG_FUNC_TRACE |
327 | bool "Additionally enable ACPI function tracing" | 324 | bool "Additionally enable ACPI function tracing" |
@@ -331,14 +328,6 @@ config ACPI_DEBUG_FUNC_TRACE | |||
331 | ACPI Debug Statements slow down ACPI processing. Function trace | 328 | ACPI Debug Statements slow down ACPI processing. Function trace |
332 | is about half of the penalty and is rarely useful. | 329 | is about half of the penalty and is rarely useful. |
333 | 330 | ||
334 | config ACPI_EC | ||
335 | bool | ||
336 | default y | ||
337 | help | ||
338 | This driver is required on some systems for the proper operation of | ||
339 | the battery and thermal drivers. If you are compiling for a | ||
340 | mobile system, say Y. | ||
341 | |||
342 | config ACPI_PCI_SLOT | 331 | config ACPI_PCI_SLOT |
343 | tristate "PCI slot detection driver" | 332 | tristate "PCI slot detection driver" |
344 | default n | 333 | default n |
@@ -348,10 +337,6 @@ config ACPI_PCI_SLOT | |||
348 | help you correlate PCI bus addresses with the physical geography | 337 | help you correlate PCI bus addresses with the physical geography |
349 | of your slots. If you are unsure, say N. | 338 | of your slots. If you are unsure, say N. |
350 | 339 | ||
351 | config ACPI_POWER | ||
352 | bool | ||
353 | default y | ||
354 | |||
355 | config ACPI_SYSTEM | 340 | config ACPI_SYSTEM |
356 | bool | 341 | bool |
357 | default y | 342 | default y |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 52a4cd4b81d0..3c0c93300f12 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -39,20 +39,23 @@ obj-y += sleep/ | |||
39 | obj-y += bus.o glue.o | 39 | obj-y += bus.o glue.o |
40 | obj-y += scan.o | 40 | obj-y += scan.o |
41 | # Keep EC driver first. Initialization of others depend on it. | 41 | # Keep EC driver first. Initialization of others depend on it. |
42 | obj-$(CONFIG_ACPI_EC) += ec.o | 42 | obj-y += ec.o |
43 | obj-$(CONFIG_ACPI_AC) += ac.o | 43 | obj-$(CONFIG_ACPI_AC) += ac.o |
44 | obj-$(CONFIG_ACPI_BATTERY) += battery.o | 44 | obj-$(CONFIG_ACPI_BATTERY) += battery.o |
45 | obj-$(CONFIG_ACPI_BUTTON) += button.o | 45 | obj-$(CONFIG_ACPI_BUTTON) += button.o |
46 | obj-$(CONFIG_ACPI_FAN) += fan.o | 46 | obj-$(CONFIG_ACPI_FAN) += fan.o |
47 | obj-$(CONFIG_ACPI_DOCK) += dock.o | 47 | obj-$(CONFIG_ACPI_DOCK) += dock.o |
48 | obj-$(CONFIG_ACPI_BAY) += bay.o | ||
49 | obj-$(CONFIG_ACPI_VIDEO) += video.o | 48 | obj-$(CONFIG_ACPI_VIDEO) += video.o |
49 | ifdef CONFIG_ACPI_VIDEO | ||
50 | obj-y += video_detect.o | ||
51 | endif | ||
52 | |||
50 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 53 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o |
51 | obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o | 54 | obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o |
52 | obj-$(CONFIG_ACPI_POWER) += power.o | ||
53 | obj-$(CONFIG_ACPI_PROCESSOR) += processor.o | 55 | obj-$(CONFIG_ACPI_PROCESSOR) += processor.o |
54 | obj-$(CONFIG_ACPI_CONTAINER) += container.o | 56 | obj-$(CONFIG_ACPI_CONTAINER) += container.o |
55 | obj-$(CONFIG_ACPI_THERMAL) += thermal.o | 57 | obj-$(CONFIG_ACPI_THERMAL) += thermal.o |
58 | obj-y += power.o | ||
56 | obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o | 59 | obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o |
57 | obj-$(CONFIG_ACPI_DEBUG) += debug.o | 60 | obj-$(CONFIG_ACPI_DEBUG) += debug.o |
58 | obj-$(CONFIG_ACPI_NUMA) += numa.o | 61 | obj-$(CONFIG_ACPI_NUMA) += numa.o |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 831883b7d6c9..9b917dac7732 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <acpi/acpi_bus.h> | 37 | #include <acpi/acpi_bus.h> |
38 | #include <acpi/acpi_drivers.h> | 38 | #include <acpi/acpi_drivers.h> |
39 | 39 | ||
40 | #define ACPI_AC_COMPONENT 0x00020000 | ||
41 | #define ACPI_AC_CLASS "ac_adapter" | 40 | #define ACPI_AC_CLASS "ac_adapter" |
42 | #define ACPI_AC_DEVICE_NAME "AC Adapter" | 41 | #define ACPI_AC_DEVICE_NAME "AC Adapter" |
43 | #define ACPI_AC_FILE_STATE "state" | 42 | #define ACPI_AC_FILE_STATE "state" |
@@ -85,7 +84,7 @@ struct acpi_ac { | |||
85 | struct power_supply charger; | 84 | struct power_supply charger; |
86 | #endif | 85 | #endif |
87 | struct acpi_device * device; | 86 | struct acpi_device * device; |
88 | unsigned long state; | 87 | unsigned long long state; |
89 | }; | 88 | }; |
90 | 89 | ||
91 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); | 90 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); |
@@ -242,7 +241,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) | |||
242 | acpi_ac_get_state(ac); | 241 | acpi_ac_get_state(ac); |
243 | acpi_bus_generate_proc_event(device, event, (u32) ac->state); | 242 | acpi_bus_generate_proc_event(device, event, (u32) ac->state); |
244 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 243 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
245 | device->dev.bus_id, event, | 244 | dev_name(&device->dev), event, |
246 | (u32) ac->state); | 245 | (u32) ac->state); |
247 | #ifdef CONFIG_ACPI_SYSFS_POWER | 246 | #ifdef CONFIG_ACPI_SYSFS_POWER |
248 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); | 247 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); |
@@ -269,7 +268,7 @@ static int acpi_ac_add(struct acpi_device *device) | |||
269 | ac->device = device; | 268 | ac->device = device; |
270 | strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); | 269 | strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); |
271 | strcpy(acpi_device_class(device), ACPI_AC_CLASS); | 270 | strcpy(acpi_device_class(device), ACPI_AC_CLASS); |
272 | acpi_driver_data(device) = ac; | 271 | device->driver_data = ac; |
273 | 272 | ||
274 | result = acpi_ac_get_state(ac); | 273 | result = acpi_ac_get_state(ac); |
275 | if (result) | 274 | if (result) |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 5f1127ad5a95..63a17b55b39b 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/memory_hotplug.h> | 32 | #include <linux/memory_hotplug.h> |
33 | #include <acpi/acpi_drivers.h> | 33 | #include <acpi/acpi_drivers.h> |
34 | 34 | ||
35 | #define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL | ||
36 | #define ACPI_MEMORY_DEVICE_CLASS "memory" | 35 | #define ACPI_MEMORY_DEVICE_CLASS "memory" |
37 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" | 36 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" |
38 | #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device" | 37 | #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device" |
@@ -194,8 +193,7 @@ acpi_memory_get_device(acpi_handle handle, | |||
194 | 193 | ||
195 | static int acpi_memory_check_device(struct acpi_memory_device *mem_device) | 194 | static int acpi_memory_check_device(struct acpi_memory_device *mem_device) |
196 | { | 195 | { |
197 | unsigned long current_status; | 196 | unsigned long long current_status; |
198 | |||
199 | 197 | ||
200 | /* Get device present/absent information from the _STA */ | 198 | /* Get device present/absent information from the _STA */ |
201 | if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle, "_STA", | 199 | if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle, "_STA", |
@@ -264,7 +262,7 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) | |||
264 | acpi_status status; | 262 | acpi_status status; |
265 | struct acpi_object_list arg_list; | 263 | struct acpi_object_list arg_list; |
266 | union acpi_object arg; | 264 | union acpi_object arg; |
267 | unsigned long current_status; | 265 | unsigned long long current_status; |
268 | 266 | ||
269 | 267 | ||
270 | /* Issue the _EJ0 command */ | 268 | /* Issue the _EJ0 command */ |
@@ -403,7 +401,7 @@ static int acpi_memory_device_add(struct acpi_device *device) | |||
403 | mem_device->device = device; | 401 | mem_device->device = device; |
404 | sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME); | 402 | sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME); |
405 | sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS); | 403 | sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS); |
406 | acpi_driver_data(device) = mem_device; | 404 | device->driver_data = mem_device; |
407 | 405 | ||
408 | /* Get the range from the _CRS */ | 406 | /* Get the range from the _CRS */ |
409 | result = acpi_memory_get_device_resources(mem_device); | 407 | result = acpi_memory_get_device_resources(mem_device); |
@@ -454,8 +452,8 @@ static int acpi_memory_device_start (struct acpi_device *device) | |||
454 | /* call add_memory func */ | 452 | /* call add_memory func */ |
455 | result = acpi_memory_enable_device(mem_device); | 453 | result = acpi_memory_enable_device(mem_device); |
456 | if (result) | 454 | if (result) |
457 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 455 | printk(KERN_ERR PREFIX |
458 | "Error in acpi_memory_enable_device\n")); | 456 | "Error in acpi_memory_enable_device\n"); |
459 | } | 457 | } |
460 | return result; | 458 | return result; |
461 | } | 459 | } |
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index d3d0886d637f..1e74988c7b2d 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c | |||
@@ -42,7 +42,7 @@ | |||
42 | 42 | ||
43 | #define ASUS_ACPI_VERSION "0.30" | 43 | #define ASUS_ACPI_VERSION "0.30" |
44 | 44 | ||
45 | #define PROC_ASUS "asus" //the directory | 45 | #define PROC_ASUS "asus" /* The directory */ |
46 | #define PROC_MLED "mled" | 46 | #define PROC_MLED "mled" |
47 | #define PROC_WLED "wled" | 47 | #define PROC_WLED "wled" |
48 | #define PROC_TLED "tled" | 48 | #define PROC_TLED "tled" |
@@ -66,10 +66,10 @@ | |||
66 | /* | 66 | /* |
67 | * Flags for hotk status | 67 | * Flags for hotk status |
68 | */ | 68 | */ |
69 | #define MLED_ON 0x01 //mail LED | 69 | #define MLED_ON 0x01 /* Mail LED */ |
70 | #define WLED_ON 0x02 //wireless LED | 70 | #define WLED_ON 0x02 /* Wireless LED */ |
71 | #define TLED_ON 0x04 //touchpad LED | 71 | #define TLED_ON 0x04 /* Touchpad LED */ |
72 | #define BT_ON 0x08 //internal Bluetooth | 72 | #define BT_ON 0x08 /* Internal Bluetooth */ |
73 | 73 | ||
74 | MODULE_AUTHOR("Julien Lerouge, Karol Kozimor"); | 74 | MODULE_AUTHOR("Julien Lerouge, Karol Kozimor"); |
75 | MODULE_DESCRIPTION(ACPI_HOTK_NAME); | 75 | MODULE_DESCRIPTION(ACPI_HOTK_NAME); |
@@ -82,28 +82,28 @@ MODULE_PARM_DESC(asus_uid, "UID for entries in /proc/acpi/asus"); | |||
82 | module_param(asus_gid, uint, 0); | 82 | module_param(asus_gid, uint, 0); |
83 | MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus"); | 83 | MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus"); |
84 | 84 | ||
85 | /* For each model, all features implemented, | 85 | /* For each model, all features implemented, |
86 | * those marked with R are relative to HOTK, A for absolute */ | 86 | * those marked with R are relative to HOTK, A for absolute */ |
87 | struct model_data { | 87 | struct model_data { |
88 | char *name; //name of the laptop________________A | 88 | char *name; /* name of the laptop________________A */ |
89 | char *mt_mled; //method to handle mled_____________R | 89 | char *mt_mled; /* method to handle mled_____________R */ |
90 | char *mled_status; //node to handle mled reading_______A | 90 | char *mled_status; /* node to handle mled reading_______A */ |
91 | char *mt_wled; //method to handle wled_____________R | 91 | char *mt_wled; /* method to handle wled_____________R */ |
92 | char *wled_status; //node to handle wled reading_______A | 92 | char *wled_status; /* node to handle wled reading_______A */ |
93 | char *mt_tled; //method to handle tled_____________R | 93 | char *mt_tled; /* method to handle tled_____________R */ |
94 | char *tled_status; //node to handle tled reading_______A | 94 | char *tled_status; /* node to handle tled reading_______A */ |
95 | char *mt_ledd; //method to handle LED display______R | 95 | char *mt_ledd; /* method to handle LED display______R */ |
96 | char *mt_bt_switch; //method to switch Bluetooth on/off_R | 96 | char *mt_bt_switch; /* method to switch Bluetooth on/off_R */ |
97 | char *bt_status; //no model currently supports this__? | 97 | char *bt_status; /* no model currently supports this__? */ |
98 | char *mt_lcd_switch; //method to turn LCD on/off_________A | 98 | char *mt_lcd_switch; /* method to turn LCD on/off_________A */ |
99 | char *lcd_status; //node to read LCD panel state______A | 99 | char *lcd_status; /* node to read LCD panel state______A */ |
100 | char *brightness_up; //method to set brightness up_______A | 100 | char *brightness_up; /* method to set brightness up_______A */ |
101 | char *brightness_down; //guess what ?______________________A | 101 | char *brightness_down; /* method to set brightness down ____A */ |
102 | char *brightness_set; //method to set absolute brightness_R | 102 | char *brightness_set; /* method to set absolute brightness_R */ |
103 | char *brightness_get; //method to get absolute brightness_R | 103 | char *brightness_get; /* method to get absolute brightness_R */ |
104 | char *brightness_status; //node to get brightness____________A | 104 | char *brightness_status;/* node to get brightness____________A */ |
105 | char *display_set; //method to set video output________R | 105 | char *display_set; /* method to set video output________R */ |
106 | char *display_get; //method to get video output________R | 106 | char *display_get; /* method to get video output________R */ |
107 | }; | 107 | }; |
108 | 108 | ||
109 | /* | 109 | /* |
@@ -111,41 +111,41 @@ struct model_data { | |||
111 | * about the hotk device | 111 | * about the hotk device |
112 | */ | 112 | */ |
113 | struct asus_hotk { | 113 | struct asus_hotk { |
114 | struct acpi_device *device; //the device we are in | 114 | struct acpi_device *device; /* the device we are in */ |
115 | acpi_handle handle; //the handle of the hotk device | 115 | acpi_handle handle; /* the handle of the hotk device */ |
116 | char status; //status of the hotk, for LEDs, ... | 116 | char status; /* status of the hotk, for LEDs */ |
117 | u32 ledd_status; //status of the LED display | 117 | u32 ledd_status; /* status of the LED display */ |
118 | struct model_data *methods; //methods available on the laptop | 118 | struct model_data *methods; /* methods available on the laptop */ |
119 | u8 brightness; //brightness level | 119 | u8 brightness; /* brightness level */ |
120 | enum { | 120 | enum { |
121 | A1x = 0, //A1340D, A1300F | 121 | A1x = 0, /* A1340D, A1300F */ |
122 | A2x, //A2500H | 122 | A2x, /* A2500H */ |
123 | A4G, //A4700G | 123 | A4G, /* A4700G */ |
124 | D1x, //D1 | 124 | D1x, /* D1 */ |
125 | L2D, //L2000D | 125 | L2D, /* L2000D */ |
126 | L3C, //L3800C | 126 | L3C, /* L3800C */ |
127 | L3D, //L3400D | 127 | L3D, /* L3400D */ |
128 | L3H, //L3H, L2000E, L5D | 128 | L3H, /* L3H, L2000E, L5D */ |
129 | L4R, //L4500R | 129 | L4R, /* L4500R */ |
130 | L5x, //L5800C | 130 | L5x, /* L5800C */ |
131 | L8L, //L8400L | 131 | L8L, /* L8400L */ |
132 | M1A, //M1300A | 132 | M1A, /* M1300A */ |
133 | M2E, //M2400E, L4400L | 133 | M2E, /* M2400E, L4400L */ |
134 | M6N, //M6800N, W3400N | 134 | M6N, /* M6800N, W3400N */ |
135 | M6R, //M6700R, A3000G | 135 | M6R, /* M6700R, A3000G */ |
136 | P30, //Samsung P30 | 136 | P30, /* Samsung P30 */ |
137 | S1x, //S1300A, but also L1400B and M2400A (L84F) | 137 | S1x, /* S1300A, but also L1400B and M2400A (L84F) */ |
138 | S2x, //S200 (J1 reported), Victor MP-XP7210 | 138 | S2x, /* S200 (J1 reported), Victor MP-XP7210 */ |
139 | W1N, //W1000N | 139 | W1N, /* W1000N */ |
140 | W5A, //W5A | 140 | W5A, /* W5A */ |
141 | W3V, //W3030V | 141 | W3V, /* W3030V */ |
142 | xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N | 142 | xxN, /* M2400N, M3700N, M5200N, M6800N, |
143 | A4S, //Z81sp | 143 | S1300N, S5200N*/ |
144 | //(Centrino) | 144 | A4S, /* Z81sp */ |
145 | F3Sa, | 145 | F3Sa, /* (Centrino) */ |
146 | END_MODEL | 146 | END_MODEL |
147 | } model; //Models currently supported | 147 | } model; /* Models currently supported */ |
148 | u16 event_count[128]; //count for each event TODO make this better | 148 | u16 event_count[128]; /* Count for each event TODO make this better */ |
149 | }; | 149 | }; |
150 | 150 | ||
151 | /* Here we go */ | 151 | /* Here we go */ |
@@ -459,18 +459,18 @@ static struct acpi_driver asus_hotk_driver = { | |||
459 | }, | 459 | }, |
460 | }; | 460 | }; |
461 | 461 | ||
462 | /* | 462 | /* |
463 | * This function evaluates an ACPI method, given an int as parameter, the | 463 | * This function evaluates an ACPI method, given an int as parameter, the |
464 | * method is searched within the scope of the handle, can be NULL. The output | 464 | * method is searched within the scope of the handle, can be NULL. The output |
465 | * of the method is written is output, which can also be NULL | 465 | * of the method is written is output, which can also be NULL |
466 | * | 466 | * |
467 | * returns 1 if write is successful, 0 else. | 467 | * returns 1 if write is successful, 0 else. |
468 | */ | 468 | */ |
469 | static int write_acpi_int(acpi_handle handle, const char *method, int val, | 469 | static int write_acpi_int(acpi_handle handle, const char *method, int val, |
470 | struct acpi_buffer *output) | 470 | struct acpi_buffer *output) |
471 | { | 471 | { |
472 | struct acpi_object_list params; //list of input parameters (an int here) | 472 | struct acpi_object_list params; /* list of input parameters (int) */ |
473 | union acpi_object in_obj; //the only param we use | 473 | union acpi_object in_obj; /* the only param we use */ |
474 | acpi_status status; | 474 | acpi_status status; |
475 | 475 | ||
476 | params.count = 1; | 476 | params.count = 1; |
@@ -507,18 +507,18 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof, | |||
507 | { | 507 | { |
508 | int len = 0; | 508 | int len = 0; |
509 | int temp; | 509 | int temp; |
510 | char buf[16]; //enough for all info | 510 | char buf[16]; /* enough for all info */ |
511 | /* | 511 | /* |
512 | * We use the easy way, we don't care of off and count, so we don't set eof | 512 | * We use the easy way, we don't care of off and count, |
513 | * to 1 | 513 | * so we don't set eof to 1 |
514 | */ | 514 | */ |
515 | 515 | ||
516 | len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n"); | 516 | len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n"); |
517 | len += sprintf(page + len, "Model reference : %s\n", | 517 | len += sprintf(page + len, "Model reference : %s\n", |
518 | hotk->methods->name); | 518 | hotk->methods->name); |
519 | /* | 519 | /* |
520 | * The SFUN method probably allows the original driver to get the list | 520 | * The SFUN method probably allows the original driver to get the list |
521 | * of features supported by a given model. For now, 0x0100 or 0x0800 | 521 | * of features supported by a given model. For now, 0x0100 or 0x0800 |
522 | * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. | 522 | * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. |
523 | * The significance of others is yet to be found. | 523 | * The significance of others is yet to be found. |
524 | */ | 524 | */ |
@@ -528,7 +528,7 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof, | |||
528 | /* | 528 | /* |
529 | * Another value for userspace: the ASYM method returns 0x02 for | 529 | * Another value for userspace: the ASYM method returns 0x02 for |
530 | * battery low and 0x04 for battery critical, its readings tend to be | 530 | * battery low and 0x04 for battery critical, its readings tend to be |
531 | * more accurate than those provided by _BST. | 531 | * more accurate than those provided by _BST. |
532 | * Note: since not all the laptops provide this method, errors are | 532 | * Note: since not all the laptops provide this method, errors are |
533 | * silently ignored. | 533 | * silently ignored. |
534 | */ | 534 | */ |
@@ -579,7 +579,7 @@ static int read_led(const char *ledname, int ledmask) | |||
579 | return (hotk->status & ledmask) ? 1 : 0; | 579 | return (hotk->status & ledmask) ? 1 : 0; |
580 | } | 580 | } |
581 | 581 | ||
582 | static int parse_arg(const char __user * buf, unsigned long count, int *val) | 582 | static int parse_arg(const char __user *buf, unsigned long count, int *val) |
583 | { | 583 | { |
584 | char s[32]; | 584 | char s[32]; |
585 | if (!count) | 585 | if (!count) |
@@ -596,7 +596,7 @@ static int parse_arg(const char __user * buf, unsigned long count, int *val) | |||
596 | 596 | ||
597 | /* FIXME: kill extraneous args so it can be called independently */ | 597 | /* FIXME: kill extraneous args so it can be called independently */ |
598 | static int | 598 | static int |
599 | write_led(const char __user * buffer, unsigned long count, | 599 | write_led(const char __user *buffer, unsigned long count, |
600 | char *ledname, int ledmask, int invert) | 600 | char *ledname, int ledmask, int invert) |
601 | { | 601 | { |
602 | int rv, value; | 602 | int rv, value; |
@@ -631,7 +631,7 @@ proc_read_mled(char *page, char **start, off_t off, int count, int *eof, | |||
631 | } | 631 | } |
632 | 632 | ||
633 | static int | 633 | static int |
634 | proc_write_mled(struct file *file, const char __user * buffer, | 634 | proc_write_mled(struct file *file, const char __user *buffer, |
635 | unsigned long count, void *data) | 635 | unsigned long count, void *data) |
636 | { | 636 | { |
637 | return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1); | 637 | return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1); |
@@ -648,7 +648,7 @@ proc_read_ledd(char *page, char **start, off_t off, int count, int *eof, | |||
648 | } | 648 | } |
649 | 649 | ||
650 | static int | 650 | static int |
651 | proc_write_ledd(struct file *file, const char __user * buffer, | 651 | proc_write_ledd(struct file *file, const char __user *buffer, |
652 | unsigned long count, void *data) | 652 | unsigned long count, void *data) |
653 | { | 653 | { |
654 | int rv, value; | 654 | int rv, value; |
@@ -677,7 +677,7 @@ proc_read_wled(char *page, char **start, off_t off, int count, int *eof, | |||
677 | } | 677 | } |
678 | 678 | ||
679 | static int | 679 | static int |
680 | proc_write_wled(struct file *file, const char __user * buffer, | 680 | proc_write_wled(struct file *file, const char __user *buffer, |
681 | unsigned long count, void *data) | 681 | unsigned long count, void *data) |
682 | { | 682 | { |
683 | return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0); | 683 | return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0); |
@@ -694,10 +694,10 @@ proc_read_bluetooth(char *page, char **start, off_t off, int count, int *eof, | |||
694 | } | 694 | } |
695 | 695 | ||
696 | static int | 696 | static int |
697 | proc_write_bluetooth(struct file *file, const char __user * buffer, | 697 | proc_write_bluetooth(struct file *file, const char __user *buffer, |
698 | unsigned long count, void *data) | 698 | unsigned long count, void *data) |
699 | { | 699 | { |
700 | /* Note: mt_bt_switch controls both internal Bluetooth adapter's | 700 | /* Note: mt_bt_switch controls both internal Bluetooth adapter's |
701 | presence and its LED */ | 701 | presence and its LED */ |
702 | return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0); | 702 | return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0); |
703 | } | 703 | } |
@@ -714,7 +714,7 @@ proc_read_tled(char *page, char **start, off_t off, int count, int *eof, | |||
714 | } | 714 | } |
715 | 715 | ||
716 | static int | 716 | static int |
717 | proc_write_tled(struct file *file, const char __user * buffer, | 717 | proc_write_tled(struct file *file, const char __user *buffer, |
718 | unsigned long count, void *data) | 718 | unsigned long count, void *data) |
719 | { | 719 | { |
720 | return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0); | 720 | return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0); |
@@ -734,7 +734,7 @@ static int get_lcd_state(void) | |||
734 | 734 | ||
735 | input.count = 2; | 735 | input.count = 2; |
736 | input.pointer = mt_params; | 736 | input.pointer = mt_params; |
737 | /* Note: the following values are partly guessed up, but | 737 | /* Note: the following values are partly guessed up, but |
738 | otherwise they seem to work */ | 738 | otherwise they seem to work */ |
739 | mt_params[0].type = ACPI_TYPE_INTEGER; | 739 | mt_params[0].type = ACPI_TYPE_INTEGER; |
740 | mt_params[0].integer.value = 0x02; | 740 | mt_params[0].integer.value = 0x02; |
@@ -753,7 +753,7 @@ static int get_lcd_state(void) | |||
753 | /* That's what the AML code does */ | 753 | /* That's what the AML code does */ |
754 | lcd = out_obj.integer.value >> 8; | 754 | lcd = out_obj.integer.value >> 8; |
755 | } else if (hotk->model == F3Sa) { | 755 | } else if (hotk->model == F3Sa) { |
756 | unsigned long tmp; | 756 | unsigned long long tmp; |
757 | union acpi_object param; | 757 | union acpi_object param; |
758 | struct acpi_object_list input; | 758 | struct acpi_object_list input; |
759 | acpi_status status; | 759 | acpi_status status; |
@@ -796,12 +796,13 @@ static int set_lcd_state(int value) | |||
796 | acpi_evaluate_object(NULL, | 796 | acpi_evaluate_object(NULL, |
797 | hotk->methods->mt_lcd_switch, | 797 | hotk->methods->mt_lcd_switch, |
798 | NULL, NULL); | 798 | NULL, NULL); |
799 | } else { /* L3H and the like have to be handled differently */ | 799 | } else { |
800 | /* L3H and the like must be handled differently */ | ||
800 | if (!write_acpi_int | 801 | if (!write_acpi_int |
801 | (hotk->handle, hotk->methods->mt_lcd_switch, 0x07, | 802 | (hotk->handle, hotk->methods->mt_lcd_switch, 0x07, |
802 | NULL)) | 803 | NULL)) |
803 | status = AE_ERROR; | 804 | status = AE_ERROR; |
804 | /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress, | 805 | /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress, |
805 | the exact behaviour is simulated here */ | 806 | the exact behaviour is simulated here */ |
806 | } | 807 | } |
807 | if (ACPI_FAILURE(status)) | 808 | if (ACPI_FAILURE(status)) |
@@ -819,7 +820,7 @@ proc_read_lcd(char *page, char **start, off_t off, int count, int *eof, | |||
819 | } | 820 | } |
820 | 821 | ||
821 | static int | 822 | static int |
822 | proc_write_lcd(struct file *file, const char __user * buffer, | 823 | proc_write_lcd(struct file *file, const char __user *buffer, |
823 | unsigned long count, void *data) | 824 | unsigned long count, void *data) |
824 | { | 825 | { |
825 | int rv, value; | 826 | int rv, value; |
@@ -897,7 +898,7 @@ proc_read_brn(char *page, char **start, off_t off, int count, int *eof, | |||
897 | } | 898 | } |
898 | 899 | ||
899 | static int | 900 | static int |
900 | proc_write_brn(struct file *file, const char __user * buffer, | 901 | proc_write_brn(struct file *file, const char __user *buffer, |
901 | unsigned long count, void *data) | 902 | unsigned long count, void *data) |
902 | { | 903 | { |
903 | int rv, value; | 904 | int rv, value; |
@@ -921,7 +922,7 @@ static void set_display(int value) | |||
921 | } | 922 | } |
922 | 923 | ||
923 | /* | 924 | /* |
924 | * Now, *this* one could be more user-friendly, but so far, no-one has | 925 | * Now, *this* one could be more user-friendly, but so far, no-one has |
925 | * complained. The significance of bits is the same as in proc_write_disp() | 926 | * complained. The significance of bits is the same as in proc_write_disp() |
926 | */ | 927 | */ |
927 | static int | 928 | static int |
@@ -933,18 +934,18 @@ proc_read_disp(char *page, char **start, off_t off, int count, int *eof, | |||
933 | if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value)) | 934 | if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value)) |
934 | printk(KERN_WARNING | 935 | printk(KERN_WARNING |
935 | "Asus ACPI: Error reading display status\n"); | 936 | "Asus ACPI: Error reading display status\n"); |
936 | value &= 0x07; /* needed for some models, shouldn't hurt others */ | 937 | value &= 0x07; /* needed for some models, shouldn't hurt others */ |
937 | return sprintf(page, "%d\n", value); | 938 | return sprintf(page, "%d\n", value); |
938 | } | 939 | } |
939 | 940 | ||
940 | /* | 941 | /* |
941 | * Experimental support for display switching. As of now: 1 should activate | 942 | * Experimental support for display switching. As of now: 1 should activate |
942 | * the LCD output, 2 should do for CRT, and 4 for TV-Out. Any combination | 943 | * the LCD output, 2 should do for CRT, and 4 for TV-Out. Any combination |
943 | * (bitwise) of these will suffice. I never actually tested 3 displays hooked up | 944 | * (bitwise) of these will suffice. I never actually tested 3 displays hooked |
944 | * simultaneously, so be warned. See the acpi4asus README for more info. | 945 | * up simultaneously, so be warned. See the acpi4asus README for more info. |
945 | */ | 946 | */ |
946 | static int | 947 | static int |
947 | proc_write_disp(struct file *file, const char __user * buffer, | 948 | proc_write_disp(struct file *file, const char __user *buffer, |
948 | unsigned long count, void *data) | 949 | unsigned long count, void *data) |
949 | { | 950 | { |
950 | int rv, value; | 951 | int rv, value; |
@@ -957,12 +958,12 @@ proc_write_disp(struct file *file, const char __user * buffer, | |||
957 | 958 | ||
958 | typedef int (proc_readfunc) (char *page, char **start, off_t off, int count, | 959 | typedef int (proc_readfunc) (char *page, char **start, off_t off, int count, |
959 | int *eof, void *data); | 960 | int *eof, void *data); |
960 | typedef int (proc_writefunc) (struct file * file, const char __user * buffer, | 961 | typedef int (proc_writefunc) (struct file *file, const char __user *buffer, |
961 | unsigned long count, void *data); | 962 | unsigned long count, void *data); |
962 | 963 | ||
963 | static int | 964 | static int |
964 | asus_proc_add(char *name, proc_writefunc * writefunc, | 965 | asus_proc_add(char *name, proc_writefunc *writefunc, |
965 | proc_readfunc * readfunc, mode_t mode, | 966 | proc_readfunc *readfunc, mode_t mode, |
966 | struct acpi_device *device) | 967 | struct acpi_device *device) |
967 | { | 968 | { |
968 | struct proc_dir_entry *proc = | 969 | struct proc_dir_entry *proc = |
@@ -1040,9 +1041,9 @@ static int asus_hotk_add_fs(struct acpi_device *device) | |||
1040 | &proc_read_bluetooth, mode, device); | 1041 | &proc_read_bluetooth, mode, device); |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | /* | 1044 | /* |
1044 | * We need both read node and write method as LCD switch is also accessible | 1045 | * We need both read node and write method as LCD switch is also |
1045 | * from keyboard | 1046 | * accessible from the keyboard |
1046 | */ | 1047 | */ |
1047 | if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) { | 1048 | if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) { |
1048 | asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode, | 1049 | asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode, |
@@ -1096,11 +1097,10 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) | |||
1096 | if (!hotk) | 1097 | if (!hotk) |
1097 | return; | 1098 | return; |
1098 | 1099 | ||
1099 | if ((event & ~((u32) BR_UP)) < 16) { | 1100 | if ((event & ~((u32) BR_UP)) < 16) |
1100 | hotk->brightness = (event & ~((u32) BR_UP)); | 1101 | hotk->brightness = (event & ~((u32) BR_UP)); |
1101 | } else if ((event & ~((u32) BR_DOWN)) < 16) { | 1102 | else if ((event & ~((u32) BR_DOWN)) < 16) |
1102 | hotk->brightness = (event & ~((u32) BR_DOWN)); | 1103 | hotk->brightness = (event & ~((u32) BR_DOWN)); |
1103 | } | ||
1104 | 1104 | ||
1105 | acpi_bus_generate_proc_event(hotk->device, event, | 1105 | acpi_bus_generate_proc_event(hotk->device, event, |
1106 | hotk->event_count[event % 128]++); | 1106 | hotk->event_count[event % 128]++); |
@@ -1186,8 +1186,8 @@ static int asus_hotk_get_info(void) | |||
1186 | acpi_status status; | 1186 | acpi_status status; |
1187 | 1187 | ||
1188 | /* | 1188 | /* |
1189 | * Get DSDT headers early enough to allow for differentiating between | 1189 | * Get DSDT headers early enough to allow for differentiating between |
1190 | * models, but late enough to allow acpi_bus_register_driver() to fail | 1190 | * models, but late enough to allow acpi_bus_register_driver() to fail |
1191 | * before doing anything ACPI-specific. Should we encounter a machine, | 1191 | * before doing anything ACPI-specific. Should we encounter a machine, |
1192 | * which needs special handling (i.e. its hotkey device has a different | 1192 | * which needs special handling (i.e. its hotkey device has a different |
1193 | * HID), this bit will be moved. A global variable asus_info contains | 1193 | * HID), this bit will be moved. A global variable asus_info contains |
@@ -1212,8 +1212,8 @@ static int asus_hotk_get_info(void) | |||
1212 | 1212 | ||
1213 | /* | 1213 | /* |
1214 | * Try to match the object returned by INIT to the specific model. | 1214 | * Try to match the object returned by INIT to the specific model. |
1215 | * Handle every possible object (or the lack of thereof) the DSDT | 1215 | * Handle every possible object (or the lack of thereof) the DSDT |
1216 | * writers might throw at us. When in trouble, we pass NULL to | 1216 | * writers might throw at us. When in trouble, we pass NULL to |
1217 | * asus_model_match() and try something completely different. | 1217 | * asus_model_match() and try something completely different. |
1218 | */ | 1218 | */ |
1219 | if (buffer.pointer) { | 1219 | if (buffer.pointer) { |
@@ -1244,6 +1244,8 @@ static int asus_hotk_get_info(void) | |||
1244 | "default values\n", string); | 1244 | "default values\n", string); |
1245 | printk(KERN_NOTICE | 1245 | printk(KERN_NOTICE |
1246 | " send /proc/acpi/dsdt to the developers\n"); | 1246 | " send /proc/acpi/dsdt to the developers\n"); |
1247 | kfree(model); | ||
1248 | return -ENODEV; | ||
1247 | } | 1249 | } |
1248 | hotk->methods = &model_conf[hotk->model]; | 1250 | hotk->methods = &model_conf[hotk->model]; |
1249 | return AE_OK; | 1251 | return AE_OK; |
@@ -1254,7 +1256,7 @@ static int asus_hotk_get_info(void) | |||
1254 | /* Sort of per-model blacklist */ | 1256 | /* Sort of per-model blacklist */ |
1255 | if (strncmp(string, "L2B", 3) == 0) | 1257 | if (strncmp(string, "L2B", 3) == 0) |
1256 | hotk->methods->lcd_status = NULL; | 1258 | hotk->methods->lcd_status = NULL; |
1257 | /* L2B is similar enough to L3C to use its settings, with this only | 1259 | /* L2B is similar enough to L3C to use its settings, with this only |
1258 | exception */ | 1260 | exception */ |
1259 | else if (strncmp(string, "A3G", 3) == 0) | 1261 | else if (strncmp(string, "A3G", 3) == 0) |
1260 | hotk->methods->lcd_status = "\\BLFG"; | 1262 | hotk->methods->lcd_status = "\\BLFG"; |
@@ -1321,7 +1323,7 @@ static int asus_hotk_add(struct acpi_device *device) | |||
1321 | hotk->handle = device->handle; | 1323 | hotk->handle = device->handle; |
1322 | strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME); | 1324 | strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME); |
1323 | strcpy(acpi_device_class(device), ACPI_HOTK_CLASS); | 1325 | strcpy(acpi_device_class(device), ACPI_HOTK_CLASS); |
1324 | acpi_driver_data(device) = hotk; | 1326 | device->driver_data = hotk; |
1325 | hotk->device = device; | 1327 | hotk->device = device; |
1326 | 1328 | ||
1327 | result = asus_hotk_check(); | 1329 | result = asus_hotk_check(); |
@@ -1366,10 +1368,9 @@ static int asus_hotk_add(struct acpi_device *device) | |||
1366 | /* LED display is off by default */ | 1368 | /* LED display is off by default */ |
1367 | hotk->ledd_status = 0xFFF; | 1369 | hotk->ledd_status = 0xFFF; |
1368 | 1370 | ||
1369 | end: | 1371 | end: |
1370 | if (result) { | 1372 | if (result) |
1371 | kfree(hotk); | 1373 | kfree(hotk); |
1372 | } | ||
1373 | 1374 | ||
1374 | return result; | 1375 | return result; |
1375 | } | 1376 | } |
@@ -1394,8 +1395,8 @@ static int asus_hotk_remove(struct acpi_device *device, int type) | |||
1394 | } | 1395 | } |
1395 | 1396 | ||
1396 | static struct backlight_ops asus_backlight_data = { | 1397 | static struct backlight_ops asus_backlight_data = { |
1397 | .get_brightness = read_brightness, | 1398 | .get_brightness = read_brightness, |
1398 | .update_status = set_brightness_status, | 1399 | .update_status = set_brightness_status, |
1399 | }; | 1400 | }; |
1400 | 1401 | ||
1401 | static void asus_acpi_exit(void) | 1402 | static void asus_acpi_exit(void) |
@@ -1442,15 +1443,15 @@ static int __init asus_acpi_init(void) | |||
1442 | return -ENODEV; | 1443 | return -ENODEV; |
1443 | } | 1444 | } |
1444 | 1445 | ||
1445 | asus_backlight_device = backlight_device_register("asus",NULL,NULL, | 1446 | asus_backlight_device = backlight_device_register("asus", NULL, NULL, |
1446 | &asus_backlight_data); | 1447 | &asus_backlight_data); |
1447 | if (IS_ERR(asus_backlight_device)) { | 1448 | if (IS_ERR(asus_backlight_device)) { |
1448 | printk(KERN_ERR "Could not register asus backlight device\n"); | 1449 | printk(KERN_ERR "Could not register asus backlight device\n"); |
1449 | asus_backlight_device = NULL; | 1450 | asus_backlight_device = NULL; |
1450 | asus_acpi_exit(); | 1451 | asus_acpi_exit(); |
1451 | return -ENODEV; | 1452 | return -ENODEV; |
1452 | } | 1453 | } |
1453 | asus_backlight_device->props.max_brightness = 15; | 1454 | asus_backlight_device->props.max_brightness = 15; |
1454 | 1455 | ||
1455 | return 0; | 1456 | return 0; |
1456 | } | 1457 | } |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 70f7f60929ca..1423b0c0cd2e 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -46,7 +46,6 @@ | |||
46 | 46 | ||
47 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF | 47 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF |
48 | 48 | ||
49 | #define ACPI_BATTERY_COMPONENT 0x00040000 | ||
50 | #define ACPI_BATTERY_CLASS "battery" | 49 | #define ACPI_BATTERY_CLASS "battery" |
51 | #define ACPI_BATTERY_DEVICE_NAME "Battery" | 50 | #define ACPI_BATTERY_DEVICE_NAME "Battery" |
52 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 | 51 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 |
@@ -782,7 +781,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) | |||
782 | acpi_bus_generate_proc_event(device, event, | 781 | acpi_bus_generate_proc_event(device, event, |
783 | acpi_battery_present(battery)); | 782 | acpi_battery_present(battery)); |
784 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 783 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
785 | device->dev.bus_id, event, | 784 | dev_name(&device->dev), event, |
786 | acpi_battery_present(battery)); | 785 | acpi_battery_present(battery)); |
787 | #ifdef CONFIG_ACPI_SYSFS_POWER | 786 | #ifdef CONFIG_ACPI_SYSFS_POWER |
788 | /* acpi_batter_update could remove power_supply object */ | 787 | /* acpi_batter_update could remove power_supply object */ |
@@ -804,7 +803,7 @@ static int acpi_battery_add(struct acpi_device *device) | |||
804 | battery->device = device; | 803 | battery->device = device; |
805 | strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); | 804 | strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); |
806 | strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); | 805 | strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); |
807 | acpi_driver_data(device) = battery; | 806 | device->driver_data = battery; |
808 | mutex_init(&battery->lock); | 807 | mutex_init(&battery->lock); |
809 | acpi_battery_update(battery); | 808 | acpi_battery_update(battery); |
810 | #ifdef CONFIG_ACPI_PROCFS_POWER | 809 | #ifdef CONFIG_ACPI_PROCFS_POWER |
diff --git a/drivers/acpi/bay.c b/drivers/acpi/bay.c deleted file mode 100644 index 61b6c5beb2d3..000000000000 --- a/drivers/acpi/bay.c +++ /dev/null | |||
@@ -1,411 +0,0 @@ | |||
1 | /* | ||
2 | * bay.c - ACPI removable drive bay driver | ||
3 | * | ||
4 | * Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com> | ||
5 | * | ||
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
11 | * your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License along | ||
19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
21 | * | ||
22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
23 | */ | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/types.h> | ||
28 | #include <linux/notifier.h> | ||
29 | #include <acpi/acpi_bus.h> | ||
30 | #include <acpi/acpi_drivers.h> | ||
31 | #include <linux/seq_file.h> | ||
32 | #include <asm/uaccess.h> | ||
33 | #include <linux/platform_device.h> | ||
34 | |||
35 | ACPI_MODULE_NAME("bay"); | ||
36 | MODULE_AUTHOR("Kristen Carlson Accardi"); | ||
37 | MODULE_DESCRIPTION("ACPI Removable Drive Bay Driver"); | ||
38 | MODULE_LICENSE("GPL"); | ||
39 | #define ACPI_BAY_CLASS "bay" | ||
40 | #define ACPI_BAY_COMPONENT 0x10000000 | ||
41 | #define _COMPONENT ACPI_BAY_COMPONENT | ||
42 | #define bay_dprintk(h,s) {\ | ||
43 | char prefix[80] = {'\0'};\ | ||
44 | struct acpi_buffer buffer = {sizeof(prefix), prefix};\ | ||
45 | acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\ | ||
46 | printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); } | ||
47 | static void bay_notify(acpi_handle handle, u32 event, void *data); | ||
48 | |||
49 | static const struct acpi_device_id bay_device_ids[] = { | ||
50 | {"LNXIOBAY", 0}, | ||
51 | {"", 0}, | ||
52 | }; | ||
53 | MODULE_DEVICE_TABLE(acpi, bay_device_ids); | ||
54 | |||
55 | struct bay { | ||
56 | acpi_handle handle; | ||
57 | char *name; | ||
58 | struct list_head list; | ||
59 | struct platform_device *pdev; | ||
60 | }; | ||
61 | |||
62 | static LIST_HEAD(drive_bays); | ||
63 | |||
64 | |||
65 | /***************************************************************************** | ||
66 | * Drive Bay functions * | ||
67 | *****************************************************************************/ | ||
68 | /** | ||
69 | * is_ejectable - see if a device is ejectable | ||
70 | * @handle: acpi handle of the device | ||
71 | * | ||
72 | * If an acpi object has a _EJ0 method, then it is ejectable | ||
73 | */ | ||
74 | static int is_ejectable(acpi_handle handle) | ||
75 | { | ||
76 | acpi_status status; | ||
77 | acpi_handle tmp; | ||
78 | |||
79 | status = acpi_get_handle(handle, "_EJ0", &tmp); | ||
80 | if (ACPI_FAILURE(status)) | ||
81 | return 0; | ||
82 | return 1; | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * bay_present - see if the bay device is present | ||
87 | * @bay: the drive bay | ||
88 | * | ||
89 | * execute the _STA method. | ||
90 | */ | ||
91 | static int bay_present(struct bay *bay) | ||
92 | { | ||
93 | unsigned long sta; | ||
94 | acpi_status status; | ||
95 | |||
96 | if (bay) { | ||
97 | status = acpi_evaluate_integer(bay->handle, "_STA", NULL, &sta); | ||
98 | if (ACPI_SUCCESS(status) && sta) | ||
99 | return 1; | ||
100 | } | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * eject_device - respond to an eject request | ||
106 | * @handle - the device to eject | ||
107 | * | ||
108 | * Call this devices _EJ0 method. | ||
109 | */ | ||
110 | static void eject_device(acpi_handle handle) | ||
111 | { | ||
112 | struct acpi_object_list arg_list; | ||
113 | union acpi_object arg; | ||
114 | |||
115 | bay_dprintk(handle, "Ejecting device"); | ||
116 | |||
117 | arg_list.count = 1; | ||
118 | arg_list.pointer = &arg; | ||
119 | arg.type = ACPI_TYPE_INTEGER; | ||
120 | arg.integer.value = 1; | ||
121 | |||
122 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_EJ0", | ||
123 | &arg_list, NULL))) | ||
124 | pr_debug("Failed to evaluate _EJ0!\n"); | ||
125 | } | ||
126 | |||
127 | /* | ||
128 | * show_present - read method for "present" file in sysfs | ||
129 | */ | ||
130 | static ssize_t show_present(struct device *dev, | ||
131 | struct device_attribute *attr, char *buf) | ||
132 | { | ||
133 | struct bay *bay = dev_get_drvdata(dev); | ||
134 | return snprintf(buf, PAGE_SIZE, "%d\n", bay_present(bay)); | ||
135 | |||
136 | } | ||
137 | static DEVICE_ATTR(present, S_IRUGO, show_present, NULL); | ||
138 | |||
139 | /* | ||
140 | * write_eject - write method for "eject" file in sysfs | ||
141 | */ | ||
142 | static ssize_t write_eject(struct device *dev, struct device_attribute *attr, | ||
143 | const char *buf, size_t count) | ||
144 | { | ||
145 | struct bay *bay = dev_get_drvdata(dev); | ||
146 | |||
147 | if (!count) | ||
148 | return -EINVAL; | ||
149 | |||
150 | eject_device(bay->handle); | ||
151 | return count; | ||
152 | } | ||
153 | static DEVICE_ATTR(eject, S_IWUSR, NULL, write_eject); | ||
154 | |||
155 | /** | ||
156 | * is_ata - see if a device is an ata device | ||
157 | * @handle: acpi handle of the device | ||
158 | * | ||
159 | * If an acpi object has one of 4 ATA ACPI methods defined, | ||
160 | * then it is an ATA device | ||
161 | */ | ||
162 | static int is_ata(acpi_handle handle) | ||
163 | { | ||
164 | acpi_handle tmp; | ||
165 | |||
166 | if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) || | ||
167 | (ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) || | ||
168 | (ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) || | ||
169 | (ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp)))) | ||
170 | return 1; | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * parent_is_ata(acpi_handle handle) | ||
177 | * | ||
178 | */ | ||
179 | static int parent_is_ata(acpi_handle handle) | ||
180 | { | ||
181 | acpi_handle phandle; | ||
182 | |||
183 | if (acpi_get_parent(handle, &phandle)) | ||
184 | return 0; | ||
185 | |||
186 | return is_ata(phandle); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * is_ejectable_bay - see if a device is an ejectable drive bay | ||
191 | * @handle: acpi handle of the device | ||
192 | * | ||
193 | * If an acpi object is ejectable and has one of the ACPI ATA | ||
194 | * methods defined, then we can safely call it an ejectable | ||
195 | * drive bay | ||
196 | */ | ||
197 | static int is_ejectable_bay(acpi_handle handle) | ||
198 | { | ||
199 | if ((is_ata(handle) || parent_is_ata(handle)) && is_ejectable(handle)) | ||
200 | return 1; | ||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | #if 0 | ||
205 | /** | ||
206 | * eject_removable_drive - try to eject this drive | ||
207 | * @dev : the device structure of the drive | ||
208 | * | ||
209 | * If a device is a removable drive that requires an _EJ0 method | ||
210 | * to be executed in order to safely remove from the system, do | ||
211 | * it. ATM - always returns success | ||
212 | */ | ||
213 | int eject_removable_drive(struct device *dev) | ||
214 | { | ||
215 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | ||
216 | |||
217 | if (handle) { | ||
218 | bay_dprintk(handle, "Got device handle"); | ||
219 | if (is_ejectable_bay(handle)) | ||
220 | eject_device(handle); | ||
221 | } else { | ||
222 | printk("No acpi handle for device\n"); | ||
223 | } | ||
224 | |||
225 | /* should I return an error code? */ | ||
226 | return 0; | ||
227 | } | ||
228 | EXPORT_SYMBOL_GPL(eject_removable_drive); | ||
229 | #endif /* 0 */ | ||
230 | |||
231 | static int acpi_bay_add_fs(struct bay *bay) | ||
232 | { | ||
233 | int ret; | ||
234 | struct device *dev = &bay->pdev->dev; | ||
235 | |||
236 | ret = device_create_file(dev, &dev_attr_present); | ||
237 | if (ret) | ||
238 | goto add_fs_err; | ||
239 | ret = device_create_file(dev, &dev_attr_eject); | ||
240 | if (ret) { | ||
241 | device_remove_file(dev, &dev_attr_present); | ||
242 | goto add_fs_err; | ||
243 | } | ||
244 | return 0; | ||
245 | |||
246 | add_fs_err: | ||
247 | bay_dprintk(bay->handle, "Error adding sysfs files\n"); | ||
248 | return ret; | ||
249 | } | ||
250 | |||
251 | static void acpi_bay_remove_fs(struct bay *bay) | ||
252 | { | ||
253 | struct device *dev = &bay->pdev->dev; | ||
254 | |||
255 | /* cleanup sysfs */ | ||
256 | device_remove_file(dev, &dev_attr_present); | ||
257 | device_remove_file(dev, &dev_attr_eject); | ||
258 | } | ||
259 | |||
260 | static int bay_is_dock_device(acpi_handle handle) | ||
261 | { | ||
262 | acpi_handle parent; | ||
263 | |||
264 | acpi_get_parent(handle, &parent); | ||
265 | |||
266 | /* if the device or it's parent is dependent on the | ||
267 | * dock, then we are a dock device | ||
268 | */ | ||
269 | return (is_dock_device(handle) || is_dock_device(parent)); | ||
270 | } | ||
271 | |||
272 | static int bay_add(acpi_handle handle, int id) | ||
273 | { | ||
274 | acpi_status status; | ||
275 | struct bay *new_bay; | ||
276 | struct platform_device *pdev; | ||
277 | struct acpi_buffer nbuffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
278 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &nbuffer); | ||
279 | |||
280 | bay_dprintk(handle, "Adding notify handler"); | ||
281 | |||
282 | /* | ||
283 | * Initialize bay device structure | ||
284 | */ | ||
285 | new_bay = kzalloc(sizeof(*new_bay), GFP_ATOMIC); | ||
286 | INIT_LIST_HEAD(&new_bay->list); | ||
287 | new_bay->handle = handle; | ||
288 | new_bay->name = (char *)nbuffer.pointer; | ||
289 | |||
290 | /* initialize platform device stuff */ | ||
291 | pdev = platform_device_register_simple(ACPI_BAY_CLASS, id, NULL, 0); | ||
292 | if (IS_ERR(pdev)) { | ||
293 | printk(KERN_ERR PREFIX "Error registering bay device\n"); | ||
294 | goto bay_add_err; | ||
295 | } | ||
296 | new_bay->pdev = pdev; | ||
297 | platform_set_drvdata(pdev, new_bay); | ||
298 | |||
299 | /* | ||
300 | * we want the bay driver to be able to send uevents | ||
301 | */ | ||
302 | pdev->dev.uevent_suppress = 0; | ||
303 | |||
304 | /* register for events on this device */ | ||
305 | status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
306 | bay_notify, new_bay); | ||
307 | if (ACPI_FAILURE(status)) { | ||
308 | printk(KERN_INFO PREFIX "Error installing bay notify handler\n"); | ||
309 | platform_device_unregister(new_bay->pdev); | ||
310 | goto bay_add_err; | ||
311 | } | ||
312 | |||
313 | if (acpi_bay_add_fs(new_bay)) { | ||
314 | acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
315 | bay_notify); | ||
316 | platform_device_unregister(new_bay->pdev); | ||
317 | goto bay_add_err; | ||
318 | } | ||
319 | |||
320 | /* if we are on a dock station, we should register for dock | ||
321 | * notifications. | ||
322 | */ | ||
323 | if (bay_is_dock_device(handle)) { | ||
324 | bay_dprintk(handle, "Is dependent on dock\n"); | ||
325 | register_hotplug_dock_device(handle, bay_notify, new_bay); | ||
326 | } | ||
327 | list_add(&new_bay->list, &drive_bays); | ||
328 | printk(KERN_INFO PREFIX "Bay [%s] Added\n", new_bay->name); | ||
329 | return 0; | ||
330 | |||
331 | bay_add_err: | ||
332 | kfree(new_bay->name); | ||
333 | kfree(new_bay); | ||
334 | return -ENODEV; | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * bay_notify - act upon an acpi bay notification | ||
339 | * @handle: the bay handle | ||
340 | * @event: the acpi event | ||
341 | * @data: our driver data struct | ||
342 | * | ||
343 | */ | ||
344 | static void bay_notify(acpi_handle handle, u32 event, void *data) | ||
345 | { | ||
346 | struct bay *bay_dev = (struct bay *)data; | ||
347 | struct device *dev = &bay_dev->pdev->dev; | ||
348 | char event_string[12]; | ||
349 | char *envp[] = { event_string, NULL }; | ||
350 | |||
351 | bay_dprintk(handle, "Bay event"); | ||
352 | sprintf(event_string, "BAY_EVENT=%d", event); | ||
353 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); | ||
354 | } | ||
355 | |||
356 | static acpi_status | ||
357 | find_bay(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
358 | { | ||
359 | int *count = (int *)context; | ||
360 | |||
361 | /* | ||
362 | * there could be more than one ejectable bay. | ||
363 | * so, just return AE_OK always so that every object | ||
364 | * will be checked. | ||
365 | */ | ||
366 | if (is_ejectable_bay(handle)) { | ||
367 | bay_dprintk(handle, "found ejectable bay"); | ||
368 | if (!bay_add(handle, *count)) | ||
369 | (*count)++; | ||
370 | } | ||
371 | return AE_OK; | ||
372 | } | ||
373 | |||
374 | static int __init bay_init(void) | ||
375 | { | ||
376 | int bays = 0; | ||
377 | |||
378 | INIT_LIST_HEAD(&drive_bays); | ||
379 | |||
380 | if (acpi_disabled) | ||
381 | return -ENODEV; | ||
382 | |||
383 | /* look for dockable drive bays */ | ||
384 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
385 | ACPI_UINT32_MAX, find_bay, &bays, NULL); | ||
386 | |||
387 | if (!bays) | ||
388 | return -ENODEV; | ||
389 | |||
390 | return 0; | ||
391 | } | ||
392 | |||
393 | static void __exit bay_exit(void) | ||
394 | { | ||
395 | struct bay *bay, *tmp; | ||
396 | |||
397 | list_for_each_entry_safe(bay, tmp, &drive_bays, list) { | ||
398 | if (is_dock_device(bay->handle)) | ||
399 | unregister_hotplug_dock_device(bay->handle); | ||
400 | acpi_bay_remove_fs(bay); | ||
401 | acpi_remove_notify_handler(bay->handle, ACPI_SYSTEM_NOTIFY, | ||
402 | bay_notify); | ||
403 | platform_device_unregister(bay->pdev); | ||
404 | kfree(bay->name); | ||
405 | kfree(bay); | ||
406 | } | ||
407 | } | ||
408 | |||
409 | postcore_initcall(bay_init); | ||
410 | module_exit(bay_exit); | ||
411 | |||
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index ea92bac42c53..09c69806c1fc 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c | |||
@@ -176,16 +176,6 @@ static int __init dmi_enable_osi_linux(const struct dmi_system_id *d) | |||
176 | acpi_dmi_osi_linux(1, d); /* enable */ | 176 | acpi_dmi_osi_linux(1, d); /* enable */ |
177 | return 0; | 177 | return 0; |
178 | } | 178 | } |
179 | static int __init dmi_disable_osi_linux(const struct dmi_system_id *d) | ||
180 | { | ||
181 | acpi_dmi_osi_linux(0, d); /* disable */ | ||
182 | return 0; | ||
183 | } | ||
184 | static int __init dmi_unknown_osi_linux(const struct dmi_system_id *d) | ||
185 | { | ||
186 | acpi_dmi_osi_linux(-1, d); /* unknown */ | ||
187 | return 0; | ||
188 | } | ||
189 | static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) | 179 | static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) |
190 | { | 180 | { |
191 | printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); | 181 | printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); |
@@ -193,295 +183,21 @@ static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) | |||
193 | return 0; | 183 | return 0; |
194 | } | 184 | } |
195 | 185 | ||
196 | /* | ||
197 | * Most BIOS that invoke OSI(Linux) do nothing with it. | ||
198 | * But some cause Linux to break. | ||
199 | * Only a couple use it to make Linux run better. | ||
200 | * | ||
201 | * Thus, Linux should continue to disable OSI(Linux) by default, | ||
202 | * should continue to discourage BIOS writers from using it, and | ||
203 | * should whitelist the few existing systems that require it. | ||
204 | * | ||
205 | * If it appears clear a vendor isn't using OSI(Linux) | ||
206 | * for anything constructive, blacklist them by name to disable | ||
207 | * unnecessary dmesg warnings on all of their products. | ||
208 | */ | ||
209 | |||
210 | static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | 186 | static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { |
211 | /* | ||
212 | * Disable OSI(Linux) warnings on all "Acer, inc." | ||
213 | * | ||
214 | * _OSI(Linux) disables the latest Windows BIOS code: | ||
215 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3100"), | ||
216 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5050"), | ||
217 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"), | ||
218 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5580"), | ||
219 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 3010"), | ||
220 | * _OSI(Linux) effect unknown: | ||
221 | * DMI_MATCH(DMI_PRODUCT_NAME, "Ferrari 5000"), | ||
222 | */ | ||
223 | /* | ||
224 | * note that dmi_check_system() uses strstr() | ||
225 | * to match sub-strings rather than !strcmp(), | ||
226 | * so "Acer" below matches "Acer, inc." above. | ||
227 | */ | ||
228 | /* | ||
229 | * Disable OSI(Linux) warnings on all "Acer" | ||
230 | * | ||
231 | * _OSI(Linux) effect unknown: | ||
232 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"), | ||
233 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720Z"), | ||
234 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"), | ||
235 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"), | ||
236 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"), | ||
237 | * | ||
238 | * _OSI(Linux) is a NOP: | ||
239 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), | ||
240 | * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"), | ||
241 | */ | ||
242 | { | ||
243 | .callback = dmi_disable_osi_linux, | ||
244 | .ident = "Acer", | ||
245 | .matches = { | ||
246 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
247 | }, | ||
248 | }, | ||
249 | /* | ||
250 | * Disable OSI(Linux) warnings on all "Apple Computer, Inc." | ||
251 | * Disable OSI(Linux) warnings on all "Apple Inc." | ||
252 | * | ||
253 | * _OSI(Linux) confirmed to be a NOP: | ||
254 | * DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"), | ||
255 | * DMI_MATCH(DMI_PRODUCT_NAME, "MacBook2,1"), | ||
256 | * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2"), | ||
257 | * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"), | ||
258 | * _OSI(Linux) effect unknown: | ||
259 | * DMI_MATCH(DMI_PRODUCT_NAME, "MacPro2,1"), | ||
260 | * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro1,1"), | ||
261 | */ | ||
262 | { | ||
263 | .callback = dmi_disable_osi_linux, | ||
264 | .ident = "Apple", | ||
265 | .matches = { | ||
266 | DMI_MATCH(DMI_SYS_VENDOR, "Apple"), | ||
267 | }, | ||
268 | }, | ||
269 | /* | ||
270 | * Disable OSI(Linux) warnings on all "BenQ" | ||
271 | * | ||
272 | * _OSI(Linux) confirmed to be a NOP: | ||
273 | * DMI_MATCH(DMI_PRODUCT_NAME, "Joybook S31"), | ||
274 | */ | ||
275 | { | ||
276 | .callback = dmi_disable_osi_linux, | ||
277 | .ident = "BenQ", | ||
278 | .matches = { | ||
279 | DMI_MATCH(DMI_SYS_VENDOR, "BenQ"), | ||
280 | }, | ||
281 | }, | ||
282 | /* | ||
283 | * Disable OSI(Linux) warnings on all "Clevo Co." | ||
284 | * | ||
285 | * _OSI(Linux) confirmed to be a NOP: | ||
286 | * DMI_MATCH(DMI_PRODUCT_NAME, "M570RU"), | ||
287 | */ | ||
288 | { | ||
289 | .callback = dmi_disable_osi_linux, | ||
290 | .ident = "Clevo", | ||
291 | .matches = { | ||
292 | DMI_MATCH(DMI_SYS_VENDOR, "Clevo Co."), | ||
293 | }, | ||
294 | }, | ||
295 | /* | ||
296 | * Disable OSI(Linux) warnings on all "COMPAL" | ||
297 | * | ||
298 | * _OSI(Linux) confirmed to be a NOP: | ||
299 | * DMI_MATCH(DMI_BOARD_NAME, "HEL8X"), | ||
300 | * _OSI(Linux) unknown effect: | ||
301 | * DMI_MATCH(DMI_BOARD_NAME, "IFL91"), | ||
302 | */ | ||
303 | { | ||
304 | .callback = dmi_disable_osi_linux, | ||
305 | .ident = "Compal", | ||
306 | .matches = { | ||
307 | DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), | ||
308 | }, | ||
309 | }, | ||
310 | { /* OSI(Linux) touches USB, unknown side-effect */ | ||
311 | .callback = dmi_disable_osi_linux, | ||
312 | .ident = "Dell Dimension 5150", | ||
313 | .matches = { | ||
314 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
315 | DMI_MATCH(DMI_PRODUCT_NAME, "Dell DM051"), | ||
316 | }, | ||
317 | }, | ||
318 | { /* OSI(Linux) is a NOP */ | ||
319 | .callback = dmi_disable_osi_linux, | ||
320 | .ident = "Dell i1501", | ||
321 | .matches = { | ||
322 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
323 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1501"), | ||
324 | }, | ||
325 | }, | ||
326 | { /* OSI(Linux) effect unknown */ | ||
327 | .callback = dmi_unknown_osi_linux, | ||
328 | .ident = "Dell Latitude D830", | ||
329 | .matches = { | ||
330 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
331 | DMI_MATCH(DMI_PRODUCT_NAME, "Latitude D830"), | ||
332 | }, | ||
333 | }, | ||
334 | { /* OSI(Linux) effect unknown */ | ||
335 | .callback = dmi_unknown_osi_linux, | ||
336 | .ident = "Dell OptiPlex GX620", | ||
337 | .matches = { | ||
338 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
339 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"), | ||
340 | }, | ||
341 | }, | ||
342 | { /* OSI(Linux) causes some USB initialization to not run */ | ||
343 | .callback = dmi_unknown_osi_linux, | ||
344 | .ident = "Dell OptiPlex 755", | ||
345 | .matches = { | ||
346 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
347 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 755"), | ||
348 | }, | ||
349 | }, | ||
350 | { /* OSI(Linux) effect unknown */ | ||
351 | .callback = dmi_unknown_osi_linux, | ||
352 | .ident = "Dell PE 1900", | ||
353 | .matches = { | ||
354 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
355 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1900"), | ||
356 | }, | ||
357 | }, | ||
358 | { /* OSI(Linux) is a NOP */ | ||
359 | .callback = dmi_unknown_osi_linux, | ||
360 | .ident = "Dell PE 1950", | ||
361 | .matches = { | ||
362 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
363 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"), | ||
364 | }, | ||
365 | }, | ||
366 | { /* OSI(Linux) is a NOP */ | ||
367 | .callback = dmi_disable_osi_linux, | ||
368 | .ident = "Dell PE R200", | ||
369 | .matches = { | ||
370 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
371 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R200"), | ||
372 | }, | ||
373 | }, | ||
374 | { /* OSI(Linux) touches USB */ | ||
375 | .callback = dmi_disable_osi_linux, | ||
376 | .ident = "Dell PR 390", | ||
377 | .matches = { | ||
378 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
379 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"), | ||
380 | }, | ||
381 | }, | ||
382 | { /* OSI(Linux) touches USB */ | ||
383 | .callback = dmi_unknown_osi_linux, | ||
384 | .ident = "Dell PR 390", | ||
385 | .matches = { | ||
386 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
387 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 690"), | ||
388 | }, | ||
389 | }, | ||
390 | { /* OSI(Linux) unknown - ASL looks benign, but may effect dock/SMM */ | ||
391 | .callback = dmi_unknown_osi_linux, | ||
392 | .ident = "Dell PR M4300", | ||
393 | .matches = { | ||
394 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
395 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision M4300"), | ||
396 | }, | ||
397 | }, | ||
398 | { /* OSI(Linux) is a NOP */ | ||
399 | .callback = dmi_disable_osi_linux, | ||
400 | .ident = "Dell Vostro 1000", | ||
401 | .matches = { | ||
402 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
403 | DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1000"), | ||
404 | }, | ||
405 | }, | ||
406 | { /* OSI(Linux) effect unknown */ | ||
407 | .callback = dmi_unknown_osi_linux, | ||
408 | .ident = "Dell PE SC440", | ||
409 | .matches = { | ||
410 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
411 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge SC440"), | ||
412 | }, | ||
413 | }, | ||
414 | { /* OSI(Linux) effect unknown */ | ||
415 | .callback = dmi_unknown_osi_linux, | ||
416 | .ident = "Dialogue Flybook V5", | ||
417 | .matches = { | ||
418 | DMI_MATCH(DMI_SYS_VENDOR, "Dialogue Technology Corporation"), | ||
419 | DMI_MATCH(DMI_PRODUCT_NAME, "Flybook V5"), | ||
420 | }, | ||
421 | }, | ||
422 | /* | ||
423 | * Disable OSI(Linux) warnings on all "FUJITSU SIEMENS" | ||
424 | * | ||
425 | * _OSI(Linux) disables latest Windows BIOS code: | ||
426 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pa 2510"), | ||
427 | * _OSI(Linux) confirmed to be a NOP: | ||
428 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"), | ||
429 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"), | ||
430 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"), | ||
431 | * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), | ||
432 | * _OSI(Linux) unknown effect: | ||
433 | * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"), | ||
434 | * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"), | ||
435 | */ | ||
436 | { | ||
437 | .callback = dmi_disable_osi_linux, | ||
438 | .ident = "Fujitsu Siemens", | ||
439 | .matches = { | ||
440 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | ||
441 | }, | ||
442 | }, | ||
443 | { | 187 | { |
444 | .callback = dmi_disable_osi_vista, | 188 | .callback = dmi_disable_osi_vista, |
445 | .ident = "Fujitsu Siemens", | 189 | .ident = "Fujitsu Siemens", |
446 | .matches = { | 190 | .matches = { |
447 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | 191 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), |
448 | DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), | 192 | DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), |
449 | }, | 193 | }, |
450 | }, | 194 | }, |
195 | |||
451 | /* | 196 | /* |
452 | * Disable OSI(Linux) warnings on all "Hewlett-Packard" | 197 | * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. |
453 | * | 198 | * Linux ignores it, except for the machines enumerated below. |
454 | * _OSI(Linux) confirmed to be a NOP: | ||
455 | * .ident = "HP Pavilion tx 1000" | ||
456 | * DMI_MATCH(DMI_BOARD_NAME, "30BF"), | ||
457 | * .ident = "HP Pavilion dv2000" | ||
458 | * DMI_MATCH(DMI_BOARD_NAME, "30B5"), | ||
459 | * .ident = "HP Pavilion dv5000", | ||
460 | * DMI_MATCH(DMI_BOARD_NAME, "30A7"), | ||
461 | * .ident = "HP Pavilion dv6300 30BC", | ||
462 | * DMI_MATCH(DMI_BOARD_NAME, "30BC"), | ||
463 | * .ident = "HP Pavilion dv6000", | ||
464 | * DMI_MATCH(DMI_BOARD_NAME, "30B7"), | ||
465 | * DMI_MATCH(DMI_BOARD_NAME, "30B8"), | ||
466 | * .ident = "HP Pavilion dv9000", | ||
467 | * DMI_MATCH(DMI_BOARD_NAME, "30B9"), | ||
468 | * .ident = "HP Pavilion dv9500", | ||
469 | * DMI_MATCH(DMI_BOARD_NAME, "30CB"), | ||
470 | * .ident = "HP/Compaq Presario C500", | ||
471 | * DMI_MATCH(DMI_BOARD_NAME, "30C6"), | ||
472 | * .ident = "HP/Compaq Presario F500", | ||
473 | * DMI_MATCH(DMI_BOARD_NAME, "30D3"), | ||
474 | * _OSI(Linux) unknown effect: | ||
475 | * .ident = "HP Pavilion dv6500", | ||
476 | * DMI_MATCH(DMI_BOARD_NAME, "30D0"), | ||
477 | */ | 199 | */ |
478 | { | 200 | |
479 | .callback = dmi_disable_osi_linux, | ||
480 | .ident = "Hewlett-Packard", | ||
481 | .matches = { | ||
482 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
483 | }, | ||
484 | }, | ||
485 | /* | 201 | /* |
486 | * Lenovo has a mix of systems OSI(Linux) situations | 202 | * Lenovo has a mix of systems OSI(Linux) situations |
487 | * and thus we can not wildcard the vendor. | 203 | * and thus we can not wildcard the vendor. |
@@ -519,113 +235,6 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
519 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"), | 235 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"), |
520 | }, | 236 | }, |
521 | }, | 237 | }, |
522 | { | ||
523 | .callback = dmi_disable_osi_linux, | ||
524 | .ident = "Lenovo 3000 V100", | ||
525 | .matches = { | ||
526 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | ||
527 | DMI_MATCH(DMI_PRODUCT_VERSION, "LENOVO3000 V100"), | ||
528 | }, | ||
529 | }, | ||
530 | { | ||
531 | .callback = dmi_disable_osi_linux, | ||
532 | .ident = "Lenovo 3000 N100", | ||
533 | .matches = { | ||
534 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | ||
535 | DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"), | ||
536 | }, | ||
537 | }, | ||
538 | /* | ||
539 | * Disable OSI(Linux) warnings on all "LG Electronics" | ||
540 | * | ||
541 | * _OSI(Linux) confirmed to be a NOP: | ||
542 | * DMI_MATCH(DMI_PRODUCT_NAME, "P1-J150B"), | ||
543 | * with DMI_MATCH(DMI_BOARD_NAME, "ROCKY"), | ||
544 | * | ||
545 | * unknown: | ||
546 | * DMI_MATCH(DMI_PRODUCT_NAME, "S1-MDGDG"), | ||
547 | * with DMI_MATCH(DMI_BOARD_NAME, "ROCKY"), | ||
548 | */ | ||
549 | { | ||
550 | .callback = dmi_disable_osi_linux, | ||
551 | .ident = "LG", | ||
552 | .matches = { | ||
553 | DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"), | ||
554 | }, | ||
555 | }, | ||
556 | /* NEC - OSI(Linux) effect unknown */ | ||
557 | { | ||
558 | .callback = dmi_unknown_osi_linux, | ||
559 | .ident = "NEC VERSA M360", | ||
560 | .matches = { | ||
561 | DMI_MATCH(DMI_SYS_VENDOR, "NEC Computers SAS"), | ||
562 | DMI_MATCH(DMI_PRODUCT_NAME, "NEC VERSA M360"), | ||
563 | }, | ||
564 | }, | ||
565 | /* Panasonic */ | ||
566 | { | ||
567 | .callback = dmi_unknown_osi_linux, | ||
568 | .ident = "Panasonic", | ||
569 | .matches = { | ||
570 | DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"), | ||
571 | /* Toughbook CF-52 */ | ||
572 | DMI_MATCH(DMI_PRODUCT_NAME, "CF-52CCABVBG"), | ||
573 | }, | ||
574 | }, | ||
575 | /* | ||
576 | * Disable OSI(Linux) warnings on all "Samsung Electronics" | ||
577 | * | ||
578 | * OSI(Linux) disables PNP0C32 and other BIOS code for Windows: | ||
579 | * DMI_MATCH(DMI_PRODUCT_NAME, "R40P/R41P"), | ||
580 | * DMI_MATCH(DMI_PRODUCT_NAME, "R59P/R60P/R61P"), | ||
581 | */ | ||
582 | { | ||
583 | .callback = dmi_disable_osi_linux, | ||
584 | .ident = "Samsung", | ||
585 | .matches = { | ||
586 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), | ||
587 | }, | ||
588 | }, | ||
589 | /* | ||
590 | * Disable OSI(Linux) warnings on all "Sony Corporation" | ||
591 | * | ||
592 | * _OSI(Linux) is a NOP: | ||
593 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NR11S_S"), | ||
594 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"), | ||
595 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"), | ||
596 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"), | ||
597 | * _OSI(Linux) unknown effect: | ||
598 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"), | ||
599 | */ | ||
600 | { | ||
601 | .callback = dmi_disable_osi_linux, | ||
602 | .ident = "Sony", | ||
603 | .matches = { | ||
604 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
605 | }, | ||
606 | }, | ||
607 | /* | ||
608 | * Disable OSI(Linux) warnings on all "TOSHIBA" | ||
609 | * | ||
610 | * _OSI(Linux) breaks sound (bugzilla 7787): | ||
611 | * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P100"), | ||
612 | * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P105"), | ||
613 | * _OSI(Linux) is a NOP: | ||
614 | * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A100"), | ||
615 | * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A210"), | ||
616 | * _OSI(Linux) unknown effect: | ||
617 | * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A135"), | ||
618 | * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A200"), | ||
619 | * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P205"), | ||
620 | * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite U305"), | ||
621 | */ | ||
622 | { | ||
623 | .callback = dmi_disable_osi_linux, | ||
624 | .ident = "Toshiba", | ||
625 | .matches = { | ||
626 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), | ||
627 | }, | ||
628 | }, | ||
629 | {} | 238 | {} |
630 | }; | 239 | }; |
631 | 240 | ||
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index ccae305ee55d..7edf6d913c13 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -48,6 +48,23 @@ EXPORT_SYMBOL(acpi_root_dir); | |||
48 | 48 | ||
49 | #define STRUCT_TO_INT(s) (*((int*)&s)) | 49 | #define STRUCT_TO_INT(s) (*((int*)&s)) |
50 | 50 | ||
51 | static int set_power_nocheck(const struct dmi_system_id *id) | ||
52 | { | ||
53 | printk(KERN_NOTICE PREFIX "%s detected - " | ||
54 | "disable power check in power transistion\n", id->ident); | ||
55 | acpi_power_nocheck = 1; | ||
56 | return 0; | ||
57 | } | ||
58 | static struct dmi_system_id __cpuinitdata power_nocheck_dmi_table[] = { | ||
59 | { | ||
60 | set_power_nocheck, "HP Pavilion 05", { | ||
61 | DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), | ||
62 | DMI_MATCH(DMI_SYS_VENDOR, "HP Pavilion 05"), | ||
63 | DMI_MATCH(DMI_PRODUCT_VERSION, "2001211RE101GLEND") }, NULL}, | ||
64 | {}, | ||
65 | }; | ||
66 | |||
67 | |||
51 | /* -------------------------------------------------------------------------- | 68 | /* -------------------------------------------------------------------------- |
52 | Device Management | 69 | Device Management |
53 | -------------------------------------------------------------------------- */ | 70 | -------------------------------------------------------------------------- */ |
@@ -77,7 +94,7 @@ EXPORT_SYMBOL(acpi_bus_get_device); | |||
77 | int acpi_bus_get_status(struct acpi_device *device) | 94 | int acpi_bus_get_status(struct acpi_device *device) |
78 | { | 95 | { |
79 | acpi_status status = AE_OK; | 96 | acpi_status status = AE_OK; |
80 | unsigned long sta = 0; | 97 | unsigned long long sta = 0; |
81 | 98 | ||
82 | 99 | ||
83 | if (!device) | 100 | if (!device) |
@@ -95,21 +112,21 @@ int acpi_bus_get_status(struct acpi_device *device) | |||
95 | } | 112 | } |
96 | 113 | ||
97 | /* | 114 | /* |
98 | * Otherwise we assume the status of our parent (unless we don't | 115 | * According to ACPI spec some device can be present and functional |
99 | * have one, in which case status is implied). | 116 | * even if the parent is not present but functional. |
117 | * In such conditions the child device should not inherit the status | ||
118 | * from the parent. | ||
100 | */ | 119 | */ |
101 | else if (device->parent) | ||
102 | device->status = device->parent->status; | ||
103 | else | 120 | else |
104 | STRUCT_TO_INT(device->status) = | 121 | STRUCT_TO_INT(device->status) = |
105 | ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | | 122 | ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | |
106 | ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; | 123 | ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; |
107 | 124 | ||
108 | if (device->status.functional && !device->status.present) { | 125 | if (device->status.functional && !device->status.present) { |
109 | printk(KERN_WARNING PREFIX "Device [%s] status [%08x]: " | 126 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " |
110 | "functional but not present; setting present\n", | 127 | "functional but not present;\n", |
111 | device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status)); | 128 | device->pnp.bus_id, |
112 | device->status.present = 1; | 129 | (u32) STRUCT_TO_INT(device->status))); |
113 | } | 130 | } |
114 | 131 | ||
115 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", | 132 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", |
@@ -155,7 +172,7 @@ int acpi_bus_get_power(acpi_handle handle, int *state) | |||
155 | int result = 0; | 172 | int result = 0; |
156 | acpi_status status = 0; | 173 | acpi_status status = 0; |
157 | struct acpi_device *device = NULL; | 174 | struct acpi_device *device = NULL; |
158 | unsigned long psc = 0; | 175 | unsigned long long psc = 0; |
159 | 176 | ||
160 | 177 | ||
161 | result = acpi_bus_get_device(handle, &device); | 178 | result = acpi_bus_get_device(handle, &device); |
@@ -223,7 +240,19 @@ int acpi_bus_set_power(acpi_handle handle, int state) | |||
223 | /* | 240 | /* |
224 | * Get device's current power state | 241 | * Get device's current power state |
225 | */ | 242 | */ |
226 | acpi_bus_get_power(device->handle, &device->power.state); | 243 | if (!acpi_power_nocheck) { |
244 | /* | ||
245 | * Maybe the incorrect power state is returned on the bogus | ||
246 | * bios, which is different with the real power state. | ||
247 | * For example: the bios returns D0 state and the real power | ||
248 | * state is D3. OS expects to set the device to D0 state. In | ||
249 | * such case if OS uses the power state returned by the BIOS, | ||
250 | * the device can't be transisted to the correct power state. | ||
251 | * So if the acpi_power_nocheck is set, it is unnecessary to | ||
252 | * get the power state by calling acpi_bus_get_power. | ||
253 | */ | ||
254 | acpi_bus_get_power(device->handle, &device->power.state); | ||
255 | } | ||
227 | if ((state == device->power.state) && !device->flags.force_power_state) { | 256 | if ((state == device->power.state) && !device->flags.force_power_state) { |
228 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", | 257 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", |
229 | state)); | 258 | state)); |
@@ -496,6 +525,19 @@ static int acpi_bus_check_scope(struct acpi_device *device) | |||
496 | return 0; | 525 | return 0; |
497 | } | 526 | } |
498 | 527 | ||
528 | static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list); | ||
529 | int register_acpi_bus_notifier(struct notifier_block *nb) | ||
530 | { | ||
531 | return blocking_notifier_chain_register(&acpi_bus_notify_list, nb); | ||
532 | } | ||
533 | EXPORT_SYMBOL_GPL(register_acpi_bus_notifier); | ||
534 | |||
535 | void unregister_acpi_bus_notifier(struct notifier_block *nb) | ||
536 | { | ||
537 | blocking_notifier_chain_unregister(&acpi_bus_notify_list, nb); | ||
538 | } | ||
539 | EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier); | ||
540 | |||
499 | /** | 541 | /** |
500 | * acpi_bus_notify | 542 | * acpi_bus_notify |
501 | * --------------- | 543 | * --------------- |
@@ -506,6 +548,8 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) | |||
506 | int result = 0; | 548 | int result = 0; |
507 | struct acpi_device *device = NULL; | 549 | struct acpi_device *device = NULL; |
508 | 550 | ||
551 | blocking_notifier_call_chain(&acpi_bus_notify_list, | ||
552 | type, (void *)handle); | ||
509 | 553 | ||
510 | if (acpi_bus_get_device(handle, &device)) | 554 | if (acpi_bus_get_device(handle, &device)) |
511 | return; | 555 | return; |
@@ -644,6 +688,14 @@ void __init acpi_early_init(void) | |||
644 | if (acpi_disabled) | 688 | if (acpi_disabled) |
645 | return; | 689 | return; |
646 | 690 | ||
691 | /* | ||
692 | * ACPI CA initializes acpi_dbg_level to non-zero, which means | ||
693 | * we get debug output merely by turning on CONFIG_ACPI_DEBUG. | ||
694 | * Turn it off so we don't get output unless the user specifies | ||
695 | * acpi.debug_level. | ||
696 | */ | ||
697 | acpi_dbg_level = 0; | ||
698 | |||
647 | printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); | 699 | printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); |
648 | 700 | ||
649 | /* enable workarounds, unless strict ACPI spec. compliance */ | 701 | /* enable workarounds, unless strict ACPI spec. compliance */ |
@@ -730,7 +782,7 @@ static int __init acpi_bus_init(void) | |||
730 | "Unable to initialize ACPI OS objects\n"); | 782 | "Unable to initialize ACPI OS objects\n"); |
731 | goto error1; | 783 | goto error1; |
732 | } | 784 | } |
733 | #ifdef CONFIG_ACPI_EC | 785 | |
734 | /* | 786 | /* |
735 | * ACPI 2.0 requires the EC driver to be loaded and work before | 787 | * ACPI 2.0 requires the EC driver to be loaded and work before |
736 | * the EC device is found in the namespace (i.e. before acpi_initialize_objects() | 788 | * the EC device is found in the namespace (i.e. before acpi_initialize_objects() |
@@ -741,7 +793,6 @@ static int __init acpi_bus_init(void) | |||
741 | */ | 793 | */ |
742 | status = acpi_ec_ecdt_probe(); | 794 | status = acpi_ec_ecdt_probe(); |
743 | /* Ignore result. Not having an ECDT is not fatal. */ | 795 | /* Ignore result. Not having an ECDT is not fatal. */ |
744 | #endif | ||
745 | 796 | ||
746 | status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); | 797 | status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); |
747 | if (ACPI_FAILURE(status)) { | 798 | if (ACPI_FAILURE(status)) { |
@@ -749,6 +800,12 @@ static int __init acpi_bus_init(void) | |||
749 | goto error1; | 800 | goto error1; |
750 | } | 801 | } |
751 | 802 | ||
803 | /* | ||
804 | * Maybe EC region is required at bus_scan/acpi_get_devices. So it | ||
805 | * is necessary to enable it as early as possible. | ||
806 | */ | ||
807 | acpi_boot_ec_enable(); | ||
808 | |||
752 | printk(KERN_INFO PREFIX "Interpreter enabled\n"); | 809 | printk(KERN_INFO PREFIX "Interpreter enabled\n"); |
753 | 810 | ||
754 | /* Initialize sleep structures */ | 811 | /* Initialize sleep structures */ |
@@ -818,7 +875,11 @@ static int __init acpi_init(void) | |||
818 | } | 875 | } |
819 | } else | 876 | } else |
820 | disable_acpi(); | 877 | disable_acpi(); |
821 | 878 | /* | |
879 | * If the laptop falls into the DMI check table, the power state check | ||
880 | * will be disabled in the course of device power transistion. | ||
881 | */ | ||
882 | dmi_check_system(power_nocheck_dmi_table); | ||
822 | return result; | 883 | return result; |
823 | } | 884 | } |
824 | 885 | ||
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 1dfec413588c..171fd914f435 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <acpi/acpi_bus.h> | 33 | #include <acpi/acpi_bus.h> |
34 | #include <acpi/acpi_drivers.h> | 34 | #include <acpi/acpi_drivers.h> |
35 | 35 | ||
36 | #define ACPI_BUTTON_COMPONENT 0x00080000 | ||
37 | #define ACPI_BUTTON_CLASS "button" | 36 | #define ACPI_BUTTON_CLASS "button" |
38 | #define ACPI_BUTTON_FILE_INFO "info" | 37 | #define ACPI_BUTTON_FILE_INFO "info" |
39 | #define ACPI_BUTTON_FILE_STATE "state" | 38 | #define ACPI_BUTTON_FILE_STATE "state" |
@@ -145,7 +144,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) | |||
145 | { | 144 | { |
146 | struct acpi_button *button = seq->private; | 145 | struct acpi_button *button = seq->private; |
147 | acpi_status status; | 146 | acpi_status status; |
148 | unsigned long state; | 147 | unsigned long long state; |
149 | 148 | ||
150 | if (!button || !button->device) | 149 | if (!button || !button->device) |
151 | return 0; | 150 | return 0; |
@@ -253,7 +252,7 @@ static int acpi_button_remove_fs(struct acpi_device *device) | |||
253 | -------------------------------------------------------------------------- */ | 252 | -------------------------------------------------------------------------- */ |
254 | static int acpi_lid_send_state(struct acpi_button *button) | 253 | static int acpi_lid_send_state(struct acpi_button *button) |
255 | { | 254 | { |
256 | unsigned long state; | 255 | unsigned long long state; |
257 | acpi_status status; | 256 | acpi_status status; |
258 | 257 | ||
259 | status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, | 258 | status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, |
@@ -262,6 +261,7 @@ static int acpi_lid_send_state(struct acpi_button *button) | |||
262 | return -ENODEV; | 261 | return -ENODEV; |
263 | /* input layer checks if event is redundant */ | 262 | /* input layer checks if event is redundant */ |
264 | input_report_switch(button->input, SW_LID, !state); | 263 | input_report_switch(button->input, SW_LID, !state); |
264 | input_sync(button->input); | ||
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
267 | 267 | ||
@@ -285,8 +285,8 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) | |||
285 | input_report_key(input, keycode, 1); | 285 | input_report_key(input, keycode, 1); |
286 | input_sync(input); | 286 | input_sync(input); |
287 | input_report_key(input, keycode, 0); | 287 | input_report_key(input, keycode, 0); |
288 | input_sync(input); | ||
288 | } | 289 | } |
289 | input_sync(input); | ||
290 | 290 | ||
291 | acpi_bus_generate_proc_event(button->device, event, | 291 | acpi_bus_generate_proc_event(button->device, event, |
292 | ++button->pushed); | 292 | ++button->pushed); |
@@ -384,7 +384,7 @@ static int acpi_button_add(struct acpi_device *device) | |||
384 | return -ENOMEM; | 384 | return -ENOMEM; |
385 | 385 | ||
386 | button->device = device; | 386 | button->device = device; |
387 | acpi_driver_data(device) = button; | 387 | device->driver_data = button; |
388 | 388 | ||
389 | button->input = input = input_allocate_device(); | 389 | button->input = input = input_allocate_device(); |
390 | if (!input) { | 390 | if (!input) { |
@@ -478,7 +478,7 @@ static int acpi_button_add(struct acpi_device *device) | |||
478 | device->wakeup.gpe_number, | 478 | device->wakeup.gpe_number, |
479 | ACPI_GPE_TYPE_WAKE_RUN); | 479 | ACPI_GPE_TYPE_WAKE_RUN); |
480 | acpi_enable_gpe(device->wakeup.gpe_device, | 480 | acpi_enable_gpe(device->wakeup.gpe_device, |
481 | device->wakeup.gpe_number, ACPI_NOT_ISR); | 481 | device->wakeup.gpe_number); |
482 | device->wakeup.state.enabled = 1; | 482 | device->wakeup.state.enabled = 1; |
483 | } | 483 | } |
484 | 484 | ||
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c index f9db4f444bd0..307963bd1043 100644 --- a/drivers/acpi/cm_sbs.c +++ b/drivers/acpi/cm_sbs.c | |||
@@ -34,7 +34,6 @@ | |||
34 | ACPI_MODULE_NAME("cm_sbs"); | 34 | ACPI_MODULE_NAME("cm_sbs"); |
35 | #define ACPI_AC_CLASS "ac_adapter" | 35 | #define ACPI_AC_CLASS "ac_adapter" |
36 | #define ACPI_BATTERY_CLASS "battery" | 36 | #define ACPI_BATTERY_CLASS "battery" |
37 | #define ACPI_SBS_COMPONENT 0x00080000 | ||
38 | #define _COMPONENT ACPI_SBS_COMPONENT | 37 | #define _COMPONENT ACPI_SBS_COMPONENT |
39 | static struct proc_dir_entry *acpi_ac_dir; | 38 | static struct proc_dir_entry *acpi_ac_dir; |
40 | static struct proc_dir_entry *acpi_battery_dir; | 39 | static struct proc_dir_entry *acpi_battery_dir; |
@@ -52,8 +51,8 @@ struct proc_dir_entry *acpi_lock_ac_dir(void) | |||
52 | if (acpi_ac_dir) { | 51 | if (acpi_ac_dir) { |
53 | lock_ac_dir_cnt++; | 52 | lock_ac_dir_cnt++; |
54 | } else { | 53 | } else { |
55 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 54 | printk(KERN_ERR PREFIX |
56 | "Cannot create %s\n", ACPI_AC_CLASS)); | 55 | "Cannot create %s\n", ACPI_AC_CLASS); |
57 | } | 56 | } |
58 | mutex_unlock(&cm_sbs_mutex); | 57 | mutex_unlock(&cm_sbs_mutex); |
59 | return acpi_ac_dir; | 58 | return acpi_ac_dir; |
@@ -83,8 +82,8 @@ struct proc_dir_entry *acpi_lock_battery_dir(void) | |||
83 | if (acpi_battery_dir) { | 82 | if (acpi_battery_dir) { |
84 | lock_battery_dir_cnt++; | 83 | lock_battery_dir_cnt++; |
85 | } else { | 84 | } else { |
86 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 85 | printk(KERN_ERR PREFIX |
87 | "Cannot create %s\n", ACPI_BATTERY_CLASS)); | 86 | "Cannot create %s\n", ACPI_BATTERY_CLASS); |
88 | } | 87 | } |
89 | mutex_unlock(&cm_sbs_mutex); | 88 | mutex_unlock(&cm_sbs_mutex); |
90 | return acpi_battery_dir; | 89 | return acpi_battery_dir; |
@@ -105,9 +104,3 @@ void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param) | |||
105 | return; | 104 | return; |
106 | } | 105 | } |
107 | EXPORT_SYMBOL(acpi_unlock_battery_dir); | 106 | EXPORT_SYMBOL(acpi_unlock_battery_dir); |
108 | |||
109 | static int __init acpi_cm_sbs_init(void) | ||
110 | { | ||
111 | return 0; | ||
112 | } | ||
113 | subsys_initcall(acpi_cm_sbs_init); | ||
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 3c25ec7a1871..17020c12623c 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #define INSTALL_NOTIFY_HANDLER 1 | 41 | #define INSTALL_NOTIFY_HANDLER 1 |
42 | #define UNINSTALL_NOTIFY_HANDLER 2 | 42 | #define UNINSTALL_NOTIFY_HANDLER 2 |
43 | 43 | ||
44 | #define ACPI_CONTAINER_COMPONENT 0x01000000 | ||
45 | #define _COMPONENT ACPI_CONTAINER_COMPONENT | 44 | #define _COMPONENT ACPI_CONTAINER_COMPONENT |
46 | ACPI_MODULE_NAME("container"); | 45 | ACPI_MODULE_NAME("container"); |
47 | 46 | ||
@@ -76,7 +75,7 @@ static int is_device_present(acpi_handle handle) | |||
76 | { | 75 | { |
77 | acpi_handle temp; | 76 | acpi_handle temp; |
78 | acpi_status status; | 77 | acpi_status status; |
79 | unsigned long sta; | 78 | unsigned long long sta; |
80 | 79 | ||
81 | 80 | ||
82 | status = acpi_get_handle(handle, "_STA", &temp); | 81 | status = acpi_get_handle(handle, "_STA", &temp); |
@@ -108,7 +107,7 @@ static int acpi_container_add(struct acpi_device *device) | |||
108 | container->handle = device->handle; | 107 | container->handle = device->handle; |
109 | strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME); | 108 | strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME); |
110 | strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS); | 109 | strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS); |
111 | acpi_driver_data(device) = container; | 110 | device->driver_data = container; |
112 | 111 | ||
113 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", | 112 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", |
114 | acpi_device_name(device), acpi_device_bid(device))); | 113 | acpi_device_name(device), acpi_device_bid(device))); |
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index 6df564f4ca6e..c48396892008 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c | |||
@@ -44,11 +44,24 @@ static const struct acpi_dlayer acpi_debug_layers[] = { | |||
44 | ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER), | 44 | ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER), |
45 | ACPI_DEBUG_INIT(ACPI_COMPILER), | 45 | ACPI_DEBUG_INIT(ACPI_COMPILER), |
46 | ACPI_DEBUG_INIT(ACPI_TOOLS), | 46 | ACPI_DEBUG_INIT(ACPI_TOOLS), |
47 | |||
48 | ACPI_DEBUG_INIT(ACPI_BUS_COMPONENT), | ||
49 | ACPI_DEBUG_INIT(ACPI_AC_COMPONENT), | ||
50 | ACPI_DEBUG_INIT(ACPI_BATTERY_COMPONENT), | ||
51 | ACPI_DEBUG_INIT(ACPI_BUTTON_COMPONENT), | ||
52 | ACPI_DEBUG_INIT(ACPI_SBS_COMPONENT), | ||
53 | ACPI_DEBUG_INIT(ACPI_FAN_COMPONENT), | ||
54 | ACPI_DEBUG_INIT(ACPI_PCI_COMPONENT), | ||
55 | ACPI_DEBUG_INIT(ACPI_POWER_COMPONENT), | ||
56 | ACPI_DEBUG_INIT(ACPI_CONTAINER_COMPONENT), | ||
57 | ACPI_DEBUG_INIT(ACPI_SYSTEM_COMPONENT), | ||
58 | ACPI_DEBUG_INIT(ACPI_THERMAL_COMPONENT), | ||
59 | ACPI_DEBUG_INIT(ACPI_MEMORY_DEVICE_COMPONENT), | ||
60 | ACPI_DEBUG_INIT(ACPI_VIDEO_COMPONENT), | ||
61 | ACPI_DEBUG_INIT(ACPI_PROCESSOR_COMPONENT), | ||
47 | }; | 62 | }; |
48 | 63 | ||
49 | static const struct acpi_dlevel acpi_debug_levels[] = { | 64 | static const struct acpi_dlevel acpi_debug_levels[] = { |
50 | ACPI_DEBUG_INIT(ACPI_LV_ERROR), | ||
51 | ACPI_DEBUG_INIT(ACPI_LV_WARN), | ||
52 | ACPI_DEBUG_INIT(ACPI_LV_INIT), | 65 | ACPI_DEBUG_INIT(ACPI_LV_INIT), |
53 | ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT), | 66 | ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT), |
54 | ACPI_DEBUG_INIT(ACPI_LV_INFO), | 67 | ACPI_DEBUG_INIT(ACPI_LV_INFO), |
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 4613b9ca5792..279a5a60a0dd 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c | |||
@@ -103,6 +103,9 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state) | |||
103 | NULL); | 103 | NULL); |
104 | acpi_ex_enter_interpreter(); | 104 | acpi_ex_enter_interpreter(); |
105 | } | 105 | } |
106 | |||
107 | acpi_ds_clear_implicit_return(walk_state); | ||
108 | |||
106 | #ifdef ACPI_DISASSEMBLER | 109 | #ifdef ACPI_DISASSEMBLER |
107 | if (ACPI_FAILURE(status)) { | 110 | if (ACPI_FAILURE(status)) { |
108 | 111 | ||
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index 13c43eac35db..d03f81bd1bcb 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/acdispat.h> | 45 | #include <acpi/acdispat.h> |
46 | #include <acpi/amlcode.h> | ||
47 | #include <acpi/acnamesp.h> | 46 | #include <acpi/acnamesp.h> |
48 | #include <acpi/acinterp.h> | 47 | #include <acpi/acinterp.h> |
49 | 48 | ||
@@ -52,11 +51,11 @@ ACPI_MODULE_NAME("dsmthdat") | |||
52 | 51 | ||
53 | /* Local prototypes */ | 52 | /* Local prototypes */ |
54 | static void | 53 | static void |
55 | acpi_ds_method_data_delete_value(u16 opcode, | 54 | acpi_ds_method_data_delete_value(u8 type, |
56 | u32 index, struct acpi_walk_state *walk_state); | 55 | u32 index, struct acpi_walk_state *walk_state); |
57 | 56 | ||
58 | static acpi_status | 57 | static acpi_status |
59 | acpi_ds_method_data_set_value(u16 opcode, | 58 | acpi_ds_method_data_set_value(u8 type, |
60 | u32 index, | 59 | u32 index, |
61 | union acpi_operand_object *object, | 60 | union acpi_operand_object *object, |
62 | struct acpi_walk_state *walk_state); | 61 | struct acpi_walk_state *walk_state); |
@@ -216,7 +215,7 @@ acpi_ds_method_data_init_args(union acpi_operand_object **params, | |||
216 | * Store the argument in the method/walk descriptor. | 215 | * Store the argument in the method/walk descriptor. |
217 | * Do not copy the arg in order to implement call by reference | 216 | * Do not copy the arg in order to implement call by reference |
218 | */ | 217 | */ |
219 | status = acpi_ds_method_data_set_value(AML_ARG_OP, index, | 218 | status = acpi_ds_method_data_set_value(ACPI_REFCLASS_ARG, index, |
220 | params[index], | 219 | params[index], |
221 | walk_state); | 220 | walk_state); |
222 | if (ACPI_FAILURE(status)) { | 221 | if (ACPI_FAILURE(status)) { |
@@ -234,7 +233,8 @@ acpi_ds_method_data_init_args(union acpi_operand_object **params, | |||
234 | * | 233 | * |
235 | * FUNCTION: acpi_ds_method_data_get_node | 234 | * FUNCTION: acpi_ds_method_data_get_node |
236 | * | 235 | * |
237 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 236 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
237 | * ACPI_REFCLASS_ARG | ||
238 | * Index - Which Local or Arg whose type to get | 238 | * Index - Which Local or Arg whose type to get |
239 | * walk_state - Current walk state object | 239 | * walk_state - Current walk state object |
240 | * Node - Where the node is returned. | 240 | * Node - Where the node is returned. |
@@ -246,7 +246,7 @@ acpi_ds_method_data_init_args(union acpi_operand_object **params, | |||
246 | ******************************************************************************/ | 246 | ******************************************************************************/ |
247 | 247 | ||
248 | acpi_status | 248 | acpi_status |
249 | acpi_ds_method_data_get_node(u16 opcode, | 249 | acpi_ds_method_data_get_node(u8 type, |
250 | u32 index, | 250 | u32 index, |
251 | struct acpi_walk_state *walk_state, | 251 | struct acpi_walk_state *walk_state, |
252 | struct acpi_namespace_node **node) | 252 | struct acpi_namespace_node **node) |
@@ -256,8 +256,8 @@ acpi_ds_method_data_get_node(u16 opcode, | |||
256 | /* | 256 | /* |
257 | * Method Locals and Arguments are supported | 257 | * Method Locals and Arguments are supported |
258 | */ | 258 | */ |
259 | switch (opcode) { | 259 | switch (type) { |
260 | case AML_LOCAL_OP: | 260 | case ACPI_REFCLASS_LOCAL: |
261 | 261 | ||
262 | if (index > ACPI_METHOD_MAX_LOCAL) { | 262 | if (index > ACPI_METHOD_MAX_LOCAL) { |
263 | ACPI_ERROR((AE_INFO, | 263 | ACPI_ERROR((AE_INFO, |
@@ -271,7 +271,7 @@ acpi_ds_method_data_get_node(u16 opcode, | |||
271 | *node = &walk_state->local_variables[index]; | 271 | *node = &walk_state->local_variables[index]; |
272 | break; | 272 | break; |
273 | 273 | ||
274 | case AML_ARG_OP: | 274 | case ACPI_REFCLASS_ARG: |
275 | 275 | ||
276 | if (index > ACPI_METHOD_MAX_ARG) { | 276 | if (index > ACPI_METHOD_MAX_ARG) { |
277 | ACPI_ERROR((AE_INFO, | 277 | ACPI_ERROR((AE_INFO, |
@@ -286,8 +286,8 @@ acpi_ds_method_data_get_node(u16 opcode, | |||
286 | break; | 286 | break; |
287 | 287 | ||
288 | default: | 288 | default: |
289 | ACPI_ERROR((AE_INFO, "Opcode %d is invalid", opcode)); | 289 | ACPI_ERROR((AE_INFO, "Type %d is invalid", type)); |
290 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); | 290 | return_ACPI_STATUS(AE_TYPE); |
291 | } | 291 | } |
292 | 292 | ||
293 | return_ACPI_STATUS(AE_OK); | 293 | return_ACPI_STATUS(AE_OK); |
@@ -297,7 +297,8 @@ acpi_ds_method_data_get_node(u16 opcode, | |||
297 | * | 297 | * |
298 | * FUNCTION: acpi_ds_method_data_set_value | 298 | * FUNCTION: acpi_ds_method_data_set_value |
299 | * | 299 | * |
300 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 300 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
301 | * ACPI_REFCLASS_ARG | ||
301 | * Index - Which Local or Arg to get | 302 | * Index - Which Local or Arg to get |
302 | * Object - Object to be inserted into the stack entry | 303 | * Object - Object to be inserted into the stack entry |
303 | * walk_state - Current walk state object | 304 | * walk_state - Current walk state object |
@@ -310,7 +311,7 @@ acpi_ds_method_data_get_node(u16 opcode, | |||
310 | ******************************************************************************/ | 311 | ******************************************************************************/ |
311 | 312 | ||
312 | static acpi_status | 313 | static acpi_status |
313 | acpi_ds_method_data_set_value(u16 opcode, | 314 | acpi_ds_method_data_set_value(u8 type, |
314 | u32 index, | 315 | u32 index, |
315 | union acpi_operand_object *object, | 316 | union acpi_operand_object *object, |
316 | struct acpi_walk_state *walk_state) | 317 | struct acpi_walk_state *walk_state) |
@@ -321,13 +322,13 @@ acpi_ds_method_data_set_value(u16 opcode, | |||
321 | ACPI_FUNCTION_TRACE(ds_method_data_set_value); | 322 | ACPI_FUNCTION_TRACE(ds_method_data_set_value); |
322 | 323 | ||
323 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 324 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
324 | "NewObj %p Opcode %X, Refs=%d [%s]\n", object, | 325 | "NewObj %p Type %2.2X, Refs=%d [%s]\n", object, |
325 | opcode, object->common.reference_count, | 326 | type, object->common.reference_count, |
326 | acpi_ut_get_type_name(object->common.type))); | 327 | acpi_ut_get_type_name(object->common.type))); |
327 | 328 | ||
328 | /* Get the namespace node for the arg/local */ | 329 | /* Get the namespace node for the arg/local */ |
329 | 330 | ||
330 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); | 331 | status = acpi_ds_method_data_get_node(type, index, walk_state, &node); |
331 | if (ACPI_FAILURE(status)) { | 332 | if (ACPI_FAILURE(status)) { |
332 | return_ACPI_STATUS(status); | 333 | return_ACPI_STATUS(status); |
333 | } | 334 | } |
@@ -350,7 +351,8 @@ acpi_ds_method_data_set_value(u16 opcode, | |||
350 | * | 351 | * |
351 | * FUNCTION: acpi_ds_method_data_get_value | 352 | * FUNCTION: acpi_ds_method_data_get_value |
352 | * | 353 | * |
353 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 354 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
355 | * ACPI_REFCLASS_ARG | ||
354 | * Index - Which local_var or argument to get | 356 | * Index - Which local_var or argument to get |
355 | * walk_state - Current walk state object | 357 | * walk_state - Current walk state object |
356 | * dest_desc - Where Arg or Local value is returned | 358 | * dest_desc - Where Arg or Local value is returned |
@@ -363,7 +365,7 @@ acpi_ds_method_data_set_value(u16 opcode, | |||
363 | ******************************************************************************/ | 365 | ******************************************************************************/ |
364 | 366 | ||
365 | acpi_status | 367 | acpi_status |
366 | acpi_ds_method_data_get_value(u16 opcode, | 368 | acpi_ds_method_data_get_value(u8 type, |
367 | u32 index, | 369 | u32 index, |
368 | struct acpi_walk_state *walk_state, | 370 | struct acpi_walk_state *walk_state, |
369 | union acpi_operand_object **dest_desc) | 371 | union acpi_operand_object **dest_desc) |
@@ -383,7 +385,7 @@ acpi_ds_method_data_get_value(u16 opcode, | |||
383 | 385 | ||
384 | /* Get the namespace node for the arg/local */ | 386 | /* Get the namespace node for the arg/local */ |
385 | 387 | ||
386 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); | 388 | status = acpi_ds_method_data_get_node(type, index, walk_state, &node); |
387 | if (ACPI_FAILURE(status)) { | 389 | if (ACPI_FAILURE(status)) { |
388 | return_ACPI_STATUS(status); | 390 | return_ACPI_STATUS(status); |
389 | } | 391 | } |
@@ -419,8 +421,8 @@ acpi_ds_method_data_get_value(u16 opcode, | |||
419 | /* Otherwise, return the error */ | 421 | /* Otherwise, return the error */ |
420 | 422 | ||
421 | else | 423 | else |
422 | switch (opcode) { | 424 | switch (type) { |
423 | case AML_ARG_OP: | 425 | case ACPI_REFCLASS_ARG: |
424 | 426 | ||
425 | ACPI_ERROR((AE_INFO, | 427 | ACPI_ERROR((AE_INFO, |
426 | "Uninitialized Arg[%d] at node %p", | 428 | "Uninitialized Arg[%d] at node %p", |
@@ -428,7 +430,7 @@ acpi_ds_method_data_get_value(u16 opcode, | |||
428 | 430 | ||
429 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); | 431 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); |
430 | 432 | ||
431 | case AML_LOCAL_OP: | 433 | case ACPI_REFCLASS_LOCAL: |
432 | 434 | ||
433 | ACPI_ERROR((AE_INFO, | 435 | ACPI_ERROR((AE_INFO, |
434 | "Uninitialized Local[%d] at node %p", | 436 | "Uninitialized Local[%d] at node %p", |
@@ -437,9 +439,10 @@ acpi_ds_method_data_get_value(u16 opcode, | |||
437 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); | 439 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); |
438 | 440 | ||
439 | default: | 441 | default: |
442 | |||
440 | ACPI_ERROR((AE_INFO, | 443 | ACPI_ERROR((AE_INFO, |
441 | "Not a Arg/Local opcode: %X", | 444 | "Not a Arg/Local opcode: %X", |
442 | opcode)); | 445 | type)); |
443 | return_ACPI_STATUS(AE_AML_INTERNAL); | 446 | return_ACPI_STATUS(AE_AML_INTERNAL); |
444 | } | 447 | } |
445 | } | 448 | } |
@@ -458,7 +461,8 @@ acpi_ds_method_data_get_value(u16 opcode, | |||
458 | * | 461 | * |
459 | * FUNCTION: acpi_ds_method_data_delete_value | 462 | * FUNCTION: acpi_ds_method_data_delete_value |
460 | * | 463 | * |
461 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 464 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
465 | * ACPI_REFCLASS_ARG | ||
462 | * Index - Which local_var or argument to delete | 466 | * Index - Which local_var or argument to delete |
463 | * walk_state - Current walk state object | 467 | * walk_state - Current walk state object |
464 | * | 468 | * |
@@ -470,7 +474,7 @@ acpi_ds_method_data_get_value(u16 opcode, | |||
470 | ******************************************************************************/ | 474 | ******************************************************************************/ |
471 | 475 | ||
472 | static void | 476 | static void |
473 | acpi_ds_method_data_delete_value(u16 opcode, | 477 | acpi_ds_method_data_delete_value(u8 type, |
474 | u32 index, struct acpi_walk_state *walk_state) | 478 | u32 index, struct acpi_walk_state *walk_state) |
475 | { | 479 | { |
476 | acpi_status status; | 480 | acpi_status status; |
@@ -481,7 +485,7 @@ acpi_ds_method_data_delete_value(u16 opcode, | |||
481 | 485 | ||
482 | /* Get the namespace node for the arg/local */ | 486 | /* Get the namespace node for the arg/local */ |
483 | 487 | ||
484 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); | 488 | status = acpi_ds_method_data_get_node(type, index, walk_state, &node); |
485 | if (ACPI_FAILURE(status)) { | 489 | if (ACPI_FAILURE(status)) { |
486 | return_VOID; | 490 | return_VOID; |
487 | } | 491 | } |
@@ -514,7 +518,8 @@ acpi_ds_method_data_delete_value(u16 opcode, | |||
514 | * | 518 | * |
515 | * FUNCTION: acpi_ds_store_object_to_local | 519 | * FUNCTION: acpi_ds_store_object_to_local |
516 | * | 520 | * |
517 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 521 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
522 | * ACPI_REFCLASS_ARG | ||
518 | * Index - Which Local or Arg to set | 523 | * Index - Which Local or Arg to set |
519 | * obj_desc - Value to be stored | 524 | * obj_desc - Value to be stored |
520 | * walk_state - Current walk state | 525 | * walk_state - Current walk state |
@@ -528,7 +533,7 @@ acpi_ds_method_data_delete_value(u16 opcode, | |||
528 | ******************************************************************************/ | 533 | ******************************************************************************/ |
529 | 534 | ||
530 | acpi_status | 535 | acpi_status |
531 | acpi_ds_store_object_to_local(u16 opcode, | 536 | acpi_ds_store_object_to_local(u8 type, |
532 | u32 index, | 537 | u32 index, |
533 | union acpi_operand_object *obj_desc, | 538 | union acpi_operand_object *obj_desc, |
534 | struct acpi_walk_state *walk_state) | 539 | struct acpi_walk_state *walk_state) |
@@ -539,8 +544,8 @@ acpi_ds_store_object_to_local(u16 opcode, | |||
539 | union acpi_operand_object *new_obj_desc; | 544 | union acpi_operand_object *new_obj_desc; |
540 | 545 | ||
541 | ACPI_FUNCTION_TRACE(ds_store_object_to_local); | 546 | ACPI_FUNCTION_TRACE(ds_store_object_to_local); |
542 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", | 547 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n", |
543 | opcode, index, obj_desc)); | 548 | type, index, obj_desc)); |
544 | 549 | ||
545 | /* Parameter validation */ | 550 | /* Parameter validation */ |
546 | 551 | ||
@@ -550,7 +555,7 @@ acpi_ds_store_object_to_local(u16 opcode, | |||
550 | 555 | ||
551 | /* Get the namespace node for the arg/local */ | 556 | /* Get the namespace node for the arg/local */ |
552 | 557 | ||
553 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); | 558 | status = acpi_ds_method_data_get_node(type, index, walk_state, &node); |
554 | if (ACPI_FAILURE(status)) { | 559 | if (ACPI_FAILURE(status)) { |
555 | return_ACPI_STATUS(status); | 560 | return_ACPI_STATUS(status); |
556 | } | 561 | } |
@@ -602,7 +607,7 @@ acpi_ds_store_object_to_local(u16 opcode, | |||
602 | * | 607 | * |
603 | * Weird, but true. | 608 | * Weird, but true. |
604 | */ | 609 | */ |
605 | if (opcode == AML_ARG_OP) { | 610 | if (type == ACPI_REFCLASS_ARG) { |
606 | /* | 611 | /* |
607 | * If we have a valid reference object that came from ref_of(), | 612 | * If we have a valid reference object that came from ref_of(), |
608 | * do the indirect store | 613 | * do the indirect store |
@@ -611,8 +616,8 @@ acpi_ds_store_object_to_local(u16 opcode, | |||
611 | ACPI_DESC_TYPE_OPERAND) | 616 | ACPI_DESC_TYPE_OPERAND) |
612 | && (current_obj_desc->common.type == | 617 | && (current_obj_desc->common.type == |
613 | ACPI_TYPE_LOCAL_REFERENCE) | 618 | ACPI_TYPE_LOCAL_REFERENCE) |
614 | && (current_obj_desc->reference.opcode == | 619 | && (current_obj_desc->reference.class == |
615 | AML_REF_OF_OP)) { | 620 | ACPI_REFCLASS_REFOF)) { |
616 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 621 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
617 | "Arg (%p) is an ObjRef(Node), storing in node %p\n", | 622 | "Arg (%p) is an ObjRef(Node), storing in node %p\n", |
618 | new_obj_desc, | 623 | new_obj_desc, |
@@ -640,11 +645,9 @@ acpi_ds_store_object_to_local(u16 opcode, | |||
640 | } | 645 | } |
641 | } | 646 | } |
642 | 647 | ||
643 | /* | 648 | /* Delete the existing object before storing the new one */ |
644 | * Delete the existing object | 649 | |
645 | * before storing the new one | 650 | acpi_ds_method_data_delete_value(type, index, walk_state); |
646 | */ | ||
647 | acpi_ds_method_data_delete_value(opcode, index, walk_state); | ||
648 | } | 651 | } |
649 | 652 | ||
650 | /* | 653 | /* |
@@ -653,7 +656,7 @@ acpi_ds_store_object_to_local(u16 opcode, | |||
653 | * (increments the object reference count by one) | 656 | * (increments the object reference count by one) |
654 | */ | 657 | */ |
655 | status = | 658 | status = |
656 | acpi_ds_method_data_set_value(opcode, index, new_obj_desc, | 659 | acpi_ds_method_data_set_value(type, index, new_obj_desc, |
657 | walk_state); | 660 | walk_state); |
658 | 661 | ||
659 | /* Remove local reference if we copied the object above */ | 662 | /* Remove local reference if we copied the object above */ |
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index 0f2805899210..4f08e599d07e 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c | |||
@@ -731,54 +731,70 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, | |||
731 | switch (op_info->type) { | 731 | switch (op_info->type) { |
732 | case AML_TYPE_LOCAL_VARIABLE: | 732 | case AML_TYPE_LOCAL_VARIABLE: |
733 | 733 | ||
734 | /* Split the opcode into a base opcode + offset */ | 734 | /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */ |
735 | 735 | ||
736 | obj_desc->reference.opcode = AML_LOCAL_OP; | 736 | obj_desc->reference.value = opcode - AML_LOCAL_OP; |
737 | obj_desc->reference.offset = opcode - AML_LOCAL_OP; | 737 | obj_desc->reference.class = ACPI_REFCLASS_LOCAL; |
738 | 738 | ||
739 | #ifndef ACPI_NO_METHOD_EXECUTION | 739 | #ifndef ACPI_NO_METHOD_EXECUTION |
740 | status = acpi_ds_method_data_get_node(AML_LOCAL_OP, | 740 | status = |
741 | obj_desc-> | 741 | acpi_ds_method_data_get_node(ACPI_REFCLASS_LOCAL, |
742 | reference.offset, | 742 | obj_desc->reference. |
743 | walk_state, | 743 | value, walk_state, |
744 | (struct | 744 | ACPI_CAST_INDIRECT_PTR |
745 | acpi_namespace_node | 745 | (struct |
746 | **)&obj_desc-> | 746 | acpi_namespace_node, |
747 | reference.object); | 747 | &obj_desc->reference. |
748 | object)); | ||
748 | #endif | 749 | #endif |
749 | break; | 750 | break; |
750 | 751 | ||
751 | case AML_TYPE_METHOD_ARGUMENT: | 752 | case AML_TYPE_METHOD_ARGUMENT: |
752 | 753 | ||
753 | /* Split the opcode into a base opcode + offset */ | 754 | /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */ |
754 | 755 | ||
755 | obj_desc->reference.opcode = AML_ARG_OP; | 756 | obj_desc->reference.value = opcode - AML_ARG_OP; |
756 | obj_desc->reference.offset = opcode - AML_ARG_OP; | 757 | obj_desc->reference.class = ACPI_REFCLASS_ARG; |
757 | 758 | ||
758 | #ifndef ACPI_NO_METHOD_EXECUTION | 759 | #ifndef ACPI_NO_METHOD_EXECUTION |
759 | status = acpi_ds_method_data_get_node(AML_ARG_OP, | 760 | status = acpi_ds_method_data_get_node(ACPI_REFCLASS_ARG, |
760 | obj_desc-> | 761 | obj_desc-> |
761 | reference.offset, | 762 | reference.value, |
762 | walk_state, | 763 | walk_state, |
764 | ACPI_CAST_INDIRECT_PTR | ||
763 | (struct | 765 | (struct |
764 | acpi_namespace_node | 766 | acpi_namespace_node, |
765 | **)&obj_desc-> | 767 | &obj_desc-> |
766 | reference.object); | 768 | reference. |
769 | object)); | ||
767 | #endif | 770 | #endif |
768 | break; | 771 | break; |
769 | 772 | ||
770 | default: /* Other literals, etc.. */ | 773 | default: /* Object name or Debug object */ |
771 | 774 | ||
772 | if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { | 775 | switch (op->common.aml_opcode) { |
776 | case AML_INT_NAMEPATH_OP: | ||
773 | 777 | ||
774 | /* Node was saved in Op */ | 778 | /* Node was saved in Op */ |
775 | 779 | ||
776 | obj_desc->reference.node = op->common.node; | 780 | obj_desc->reference.node = op->common.node; |
777 | obj_desc->reference.object = | 781 | obj_desc->reference.object = |
778 | op->common.node->object; | 782 | op->common.node->object; |
779 | } | 783 | obj_desc->reference.class = ACPI_REFCLASS_NAME; |
784 | break; | ||
785 | |||
786 | case AML_DEBUG_OP: | ||
780 | 787 | ||
781 | obj_desc->reference.opcode = opcode; | 788 | obj_desc->reference.class = ACPI_REFCLASS_DEBUG; |
789 | break; | ||
790 | |||
791 | default: | ||
792 | |||
793 | ACPI_ERROR((AE_INFO, | ||
794 | "Unimplemented reference type for AML opcode: %4.4X", | ||
795 | opcode)); | ||
796 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | ||
797 | } | ||
782 | break; | 798 | break; |
783 | } | 799 | } |
784 | break; | 800 | break; |
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index 6a81c4400edf..69fae5905bb8 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c | |||
@@ -1330,7 +1330,7 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, | |||
1330 | (walk_state->results->results.obj_desc[0]) == | 1330 | (walk_state->results->results.obj_desc[0]) == |
1331 | ACPI_TYPE_LOCAL_REFERENCE) | 1331 | ACPI_TYPE_LOCAL_REFERENCE) |
1332 | && ((walk_state->results->results.obj_desc[0])-> | 1332 | && ((walk_state->results->results.obj_desc[0])-> |
1333 | reference.opcode != AML_INDEX_OP)) { | 1333 | reference.class != ACPI_REFCLASS_INDEX)) { |
1334 | status = | 1334 | status = |
1335 | acpi_ex_resolve_to_value(&walk_state-> | 1335 | acpi_ex_resolve_to_value(&walk_state-> |
1336 | results->results. | 1336 | results->results. |
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c index b5072fa9c920..396fe12078cd 100644 --- a/drivers/acpi/dispatcher/dswexec.c +++ b/drivers/acpi/dispatcher/dswexec.c | |||
@@ -166,6 +166,10 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, | |||
166 | status = AE_CTRL_FALSE; | 166 | status = AE_CTRL_FALSE; |
167 | } | 167 | } |
168 | 168 | ||
169 | /* Predicate can be used for an implicit return value */ | ||
170 | |||
171 | (void)acpi_ds_do_implicit_return(local_obj_desc, walk_state, TRUE); | ||
172 | |||
169 | cleanup: | 173 | cleanup: |
170 | 174 | ||
171 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", | 175 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", |
@@ -429,10 +433,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) | |||
429 | ACPI_TYPE_LOCAL_REFERENCE) | 433 | ACPI_TYPE_LOCAL_REFERENCE) |
430 | && (walk_state->operands[1]->common.type == | 434 | && (walk_state->operands[1]->common.type == |
431 | ACPI_TYPE_LOCAL_REFERENCE) | 435 | ACPI_TYPE_LOCAL_REFERENCE) |
432 | && (walk_state->operands[0]->reference.opcode == | 436 | && (walk_state->operands[0]->reference.class == |
433 | walk_state->operands[1]->reference.opcode) | 437 | walk_state->operands[1]->reference.class) |
434 | && (walk_state->operands[0]->reference.offset == | 438 | && (walk_state->operands[0]->reference.value == |
435 | walk_state->operands[1]->reference.offset)) { | 439 | walk_state->operands[1]->reference.value)) { |
436 | status = AE_OK; | 440 | status = AE_OK; |
437 | } else { | 441 | } else { |
438 | ACPI_EXCEPTION((AE_INFO, status, | 442 | ACPI_EXCEPTION((AE_INFO, status, |
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 7d2edf143f16..5b30b8d91d71 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
@@ -48,7 +48,6 @@ MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to " | |||
48 | " before undocking"); | 48 | " before undocking"); |
49 | 49 | ||
50 | static struct atomic_notifier_head dock_notifier_list; | 50 | static struct atomic_notifier_head dock_notifier_list; |
51 | static struct platform_device *dock_device; | ||
52 | static char dock_device_name[] = "dock"; | 51 | static char dock_device_name[] = "dock"; |
53 | 52 | ||
54 | static const struct acpi_device_id dock_device_ids[] = { | 53 | static const struct acpi_device_id dock_device_ids[] = { |
@@ -65,23 +64,29 @@ struct dock_station { | |||
65 | struct mutex hp_lock; | 64 | struct mutex hp_lock; |
66 | struct list_head dependent_devices; | 65 | struct list_head dependent_devices; |
67 | struct list_head hotplug_devices; | 66 | struct list_head hotplug_devices; |
67 | |||
68 | struct list_head sibiling; | ||
69 | struct platform_device *dock_device; | ||
68 | }; | 70 | }; |
71 | static LIST_HEAD(dock_stations); | ||
72 | static int dock_station_count; | ||
69 | 73 | ||
70 | struct dock_dependent_device { | 74 | struct dock_dependent_device { |
71 | struct list_head list; | 75 | struct list_head list; |
72 | struct list_head hotplug_list; | 76 | struct list_head hotplug_list; |
73 | acpi_handle handle; | 77 | acpi_handle handle; |
74 | acpi_notify_handler handler; | 78 | struct acpi_dock_ops *ops; |
75 | void *context; | 79 | void *context; |
76 | }; | 80 | }; |
77 | 81 | ||
78 | #define DOCK_DOCKING 0x00000001 | 82 | #define DOCK_DOCKING 0x00000001 |
79 | #define DOCK_UNDOCKING 0x00000002 | 83 | #define DOCK_UNDOCKING 0x00000002 |
84 | #define DOCK_IS_DOCK 0x00000010 | ||
85 | #define DOCK_IS_ATA 0x00000020 | ||
86 | #define DOCK_IS_BAT 0x00000040 | ||
80 | #define DOCK_EVENT 3 | 87 | #define DOCK_EVENT 3 |
81 | #define UNDOCK_EVENT 2 | 88 | #define UNDOCK_EVENT 2 |
82 | 89 | ||
83 | static struct dock_station *dock_station; | ||
84 | |||
85 | /***************************************************************************** | 90 | /***************************************************************************** |
86 | * Dock Dependent device functions * | 91 | * Dock Dependent device functions * |
87 | *****************************************************************************/ | 92 | *****************************************************************************/ |
@@ -199,6 +204,60 @@ static int is_dock(acpi_handle handle) | |||
199 | return 1; | 204 | return 1; |
200 | } | 205 | } |
201 | 206 | ||
207 | static int is_ejectable(acpi_handle handle) | ||
208 | { | ||
209 | acpi_status status; | ||
210 | acpi_handle tmp; | ||
211 | |||
212 | status = acpi_get_handle(handle, "_EJ0", &tmp); | ||
213 | if (ACPI_FAILURE(status)) | ||
214 | return 0; | ||
215 | return 1; | ||
216 | } | ||
217 | |||
218 | static int is_ata(acpi_handle handle) | ||
219 | { | ||
220 | acpi_handle tmp; | ||
221 | |||
222 | if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) || | ||
223 | (ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) || | ||
224 | (ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) || | ||
225 | (ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp)))) | ||
226 | return 1; | ||
227 | |||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static int is_battery(acpi_handle handle) | ||
232 | { | ||
233 | struct acpi_device_info *info; | ||
234 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
235 | int ret = 1; | ||
236 | |||
237 | if (!ACPI_SUCCESS(acpi_get_object_info(handle, &buffer))) | ||
238 | return 0; | ||
239 | info = buffer.pointer; | ||
240 | if (!(info->valid & ACPI_VALID_HID)) | ||
241 | ret = 0; | ||
242 | else | ||
243 | ret = !strcmp("PNP0C0A", info->hardware_id.value); | ||
244 | |||
245 | kfree(buffer.pointer); | ||
246 | return ret; | ||
247 | } | ||
248 | |||
249 | static int is_ejectable_bay(acpi_handle handle) | ||
250 | { | ||
251 | acpi_handle phandle; | ||
252 | if (!is_ejectable(handle)) | ||
253 | return 0; | ||
254 | if (is_battery(handle) || is_ata(handle)) | ||
255 | return 1; | ||
256 | if (!acpi_get_parent(handle, &phandle) && is_ata(phandle)) | ||
257 | return 1; | ||
258 | return 0; | ||
259 | } | ||
260 | |||
202 | /** | 261 | /** |
203 | * is_dock_device - see if a device is on a dock station | 262 | * is_dock_device - see if a device is on a dock station |
204 | * @handle: acpi handle of the device | 263 | * @handle: acpi handle of the device |
@@ -209,11 +268,17 @@ static int is_dock(acpi_handle handle) | |||
209 | */ | 268 | */ |
210 | int is_dock_device(acpi_handle handle) | 269 | int is_dock_device(acpi_handle handle) |
211 | { | 270 | { |
212 | if (!dock_station) | 271 | struct dock_station *dock_station; |
272 | |||
273 | if (!dock_station_count) | ||
213 | return 0; | 274 | return 0; |
214 | 275 | ||
215 | if (is_dock(handle) || find_dock_dependent_device(dock_station, handle)) | 276 | if (is_dock(handle)) |
216 | return 1; | 277 | return 1; |
278 | list_for_each_entry(dock_station, &dock_stations, sibiling) { | ||
279 | if (find_dock_dependent_device(dock_station, handle)) | ||
280 | return 1; | ||
281 | } | ||
217 | 282 | ||
218 | return 0; | 283 | return 0; |
219 | } | 284 | } |
@@ -229,7 +294,7 @@ EXPORT_SYMBOL_GPL(is_dock_device); | |||
229 | */ | 294 | */ |
230 | static int dock_present(struct dock_station *ds) | 295 | static int dock_present(struct dock_station *ds) |
231 | { | 296 | { |
232 | unsigned long sta; | 297 | unsigned long long sta; |
233 | acpi_status status; | 298 | acpi_status status; |
234 | 299 | ||
235 | if (ds) { | 300 | if (ds) { |
@@ -320,8 +385,8 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event) | |||
320 | * First call driver specific hotplug functions | 385 | * First call driver specific hotplug functions |
321 | */ | 386 | */ |
322 | list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) { | 387 | list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) { |
323 | if (dd->handler) | 388 | if (dd->ops && dd->ops->handler) |
324 | dd->handler(dd->handle, event, dd->context); | 389 | dd->ops->handler(dd->handle, event, dd->context); |
325 | } | 390 | } |
326 | 391 | ||
327 | /* | 392 | /* |
@@ -341,9 +406,10 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event) | |||
341 | 406 | ||
342 | static void dock_event(struct dock_station *ds, u32 event, int num) | 407 | static void dock_event(struct dock_station *ds, u32 event, int num) |
343 | { | 408 | { |
344 | struct device *dev = &dock_device->dev; | 409 | struct device *dev = &ds->dock_device->dev; |
345 | char event_string[13]; | 410 | char event_string[13]; |
346 | char *envp[] = { event_string, NULL }; | 411 | char *envp[] = { event_string, NULL }; |
412 | struct dock_dependent_device *dd; | ||
347 | 413 | ||
348 | if (num == UNDOCK_EVENT) | 414 | if (num == UNDOCK_EVENT) |
349 | sprintf(event_string, "EVENT=undock"); | 415 | sprintf(event_string, "EVENT=undock"); |
@@ -354,7 +420,14 @@ static void dock_event(struct dock_station *ds, u32 event, int num) | |||
354 | * Indicate that the status of the dock station has | 420 | * Indicate that the status of the dock station has |
355 | * changed. | 421 | * changed. |
356 | */ | 422 | */ |
357 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); | 423 | if (num == DOCK_EVENT) |
424 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); | ||
425 | |||
426 | list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) | ||
427 | if (dd->ops && dd->ops->uevent) | ||
428 | dd->ops->uevent(dd->handle, event, dd->context); | ||
429 | if (num != DOCK_EVENT) | ||
430 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); | ||
358 | } | 431 | } |
359 | 432 | ||
360 | /** | 433 | /** |
@@ -414,9 +487,10 @@ static void handle_dock(struct dock_station *ds, int dock) | |||
414 | arg.type = ACPI_TYPE_INTEGER; | 487 | arg.type = ACPI_TYPE_INTEGER; |
415 | arg.integer.value = dock; | 488 | arg.integer.value = dock; |
416 | status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); | 489 | status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); |
417 | if (ACPI_FAILURE(status)) | 490 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) |
418 | printk(KERN_ERR PREFIX "%s - failed to execute _DCK\n", | 491 | ACPI_EXCEPTION((AE_INFO, status, "%s - failed to execute" |
419 | (char *)name_buffer.pointer); | 492 | " _DCK\n", (char *)name_buffer.pointer)); |
493 | |||
420 | kfree(buffer.pointer); | 494 | kfree(buffer.pointer); |
421 | kfree(name_buffer.pointer); | 495 | kfree(name_buffer.pointer); |
422 | } | 496 | } |
@@ -452,6 +526,25 @@ static inline void complete_undock(struct dock_station *ds) | |||
452 | ds->flags &= ~(DOCK_UNDOCKING); | 526 | ds->flags &= ~(DOCK_UNDOCKING); |
453 | } | 527 | } |
454 | 528 | ||
529 | static void dock_lock(struct dock_station *ds, int lock) | ||
530 | { | ||
531 | struct acpi_object_list arg_list; | ||
532 | union acpi_object arg; | ||
533 | acpi_status status; | ||
534 | |||
535 | arg_list.count = 1; | ||
536 | arg_list.pointer = &arg; | ||
537 | arg.type = ACPI_TYPE_INTEGER; | ||
538 | arg.integer.value = !!lock; | ||
539 | status = acpi_evaluate_object(ds->handle, "_LCK", &arg_list, NULL); | ||
540 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
541 | if (lock) | ||
542 | printk(KERN_WARNING PREFIX "Locking device failed\n"); | ||
543 | else | ||
544 | printk(KERN_WARNING PREFIX "Unlocking device failed\n"); | ||
545 | } | ||
546 | } | ||
547 | |||
455 | /** | 548 | /** |
456 | * dock_in_progress - see if we are in the middle of handling a dock event | 549 | * dock_in_progress - see if we are in the middle of handling a dock event |
457 | * @ds: the dock station | 550 | * @ds: the dock station |
@@ -479,7 +572,7 @@ static int dock_in_progress(struct dock_station *ds) | |||
479 | */ | 572 | */ |
480 | int register_dock_notifier(struct notifier_block *nb) | 573 | int register_dock_notifier(struct notifier_block *nb) |
481 | { | 574 | { |
482 | if (!dock_station) | 575 | if (!dock_station_count) |
483 | return -ENODEV; | 576 | return -ENODEV; |
484 | 577 | ||
485 | return atomic_notifier_chain_register(&dock_notifier_list, nb); | 578 | return atomic_notifier_chain_register(&dock_notifier_list, nb); |
@@ -493,7 +586,7 @@ EXPORT_SYMBOL_GPL(register_dock_notifier); | |||
493 | */ | 586 | */ |
494 | void unregister_dock_notifier(struct notifier_block *nb) | 587 | void unregister_dock_notifier(struct notifier_block *nb) |
495 | { | 588 | { |
496 | if (!dock_station) | 589 | if (!dock_station_count) |
497 | return; | 590 | return; |
498 | 591 | ||
499 | atomic_notifier_chain_unregister(&dock_notifier_list, nb); | 592 | atomic_notifier_chain_unregister(&dock_notifier_list, nb); |
@@ -504,7 +597,7 @@ EXPORT_SYMBOL_GPL(unregister_dock_notifier); | |||
504 | /** | 597 | /** |
505 | * register_hotplug_dock_device - register a hotplug function | 598 | * register_hotplug_dock_device - register a hotplug function |
506 | * @handle: the handle of the device | 599 | * @handle: the handle of the device |
507 | * @handler: the acpi_notifier_handler to call after docking | 600 | * @ops: handlers to call after docking |
508 | * @context: device specific data | 601 | * @context: device specific data |
509 | * | 602 | * |
510 | * If a driver would like to perform a hotplug operation after a dock | 603 | * If a driver would like to perform a hotplug operation after a dock |
@@ -512,27 +605,36 @@ EXPORT_SYMBOL_GPL(unregister_dock_notifier); | |||
512 | * the dock driver after _DCK is executed. | 605 | * the dock driver after _DCK is executed. |
513 | */ | 606 | */ |
514 | int | 607 | int |
515 | register_hotplug_dock_device(acpi_handle handle, acpi_notify_handler handler, | 608 | register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops, |
516 | void *context) | 609 | void *context) |
517 | { | 610 | { |
518 | struct dock_dependent_device *dd; | 611 | struct dock_dependent_device *dd; |
612 | struct dock_station *dock_station; | ||
613 | int ret = -EINVAL; | ||
519 | 614 | ||
520 | if (!dock_station) | 615 | if (!dock_station_count) |
521 | return -ENODEV; | 616 | return -ENODEV; |
522 | 617 | ||
523 | /* | 618 | /* |
524 | * make sure this handle is for a device dependent on the dock, | 619 | * make sure this handle is for a device dependent on the dock, |
525 | * this would include the dock station itself | 620 | * this would include the dock station itself |
526 | */ | 621 | */ |
527 | dd = find_dock_dependent_device(dock_station, handle); | 622 | list_for_each_entry(dock_station, &dock_stations, sibiling) { |
528 | if (dd) { | 623 | /* |
529 | dd->handler = handler; | 624 | * An ATA bay can be in a dock and itself can be ejected |
530 | dd->context = context; | 625 | * seperately, so there are two 'dock stations' which need the |
531 | dock_add_hotplug_device(dock_station, dd); | 626 | * ops |
532 | return 0; | 627 | */ |
628 | dd = find_dock_dependent_device(dock_station, handle); | ||
629 | if (dd) { | ||
630 | dd->ops = ops; | ||
631 | dd->context = context; | ||
632 | dock_add_hotplug_device(dock_station, dd); | ||
633 | ret = 0; | ||
634 | } | ||
533 | } | 635 | } |
534 | 636 | ||
535 | return -EINVAL; | 637 | return ret; |
536 | } | 638 | } |
537 | 639 | ||
538 | EXPORT_SYMBOL_GPL(register_hotplug_dock_device); | 640 | EXPORT_SYMBOL_GPL(register_hotplug_dock_device); |
@@ -544,13 +646,16 @@ EXPORT_SYMBOL_GPL(register_hotplug_dock_device); | |||
544 | void unregister_hotplug_dock_device(acpi_handle handle) | 646 | void unregister_hotplug_dock_device(acpi_handle handle) |
545 | { | 647 | { |
546 | struct dock_dependent_device *dd; | 648 | struct dock_dependent_device *dd; |
649 | struct dock_station *dock_station; | ||
547 | 650 | ||
548 | if (!dock_station) | 651 | if (!dock_station_count) |
549 | return; | 652 | return; |
550 | 653 | ||
551 | dd = find_dock_dependent_device(dock_station, handle); | 654 | list_for_each_entry(dock_station, &dock_stations, sibiling) { |
552 | if (dd) | 655 | dd = find_dock_dependent_device(dock_station, handle); |
553 | dock_del_hotplug_device(dock_station, dd); | 656 | if (dd) |
657 | dock_del_hotplug_device(dock_station, dd); | ||
658 | } | ||
554 | } | 659 | } |
555 | 660 | ||
556 | EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); | 661 | EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); |
@@ -575,13 +680,9 @@ static int handle_eject_request(struct dock_station *ds, u32 event) | |||
575 | */ | 680 | */ |
576 | dock_event(ds, event, UNDOCK_EVENT); | 681 | dock_event(ds, event, UNDOCK_EVENT); |
577 | 682 | ||
578 | if (!dock_present(ds)) { | ||
579 | complete_undock(ds); | ||
580 | return -ENODEV; | ||
581 | } | ||
582 | |||
583 | hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); | 683 | hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); |
584 | undock(ds); | 684 | undock(ds); |
685 | dock_lock(ds, 0); | ||
585 | eject_dock(ds); | 686 | eject_dock(ds); |
586 | if (dock_present(ds)) { | 687 | if (dock_present(ds)) { |
587 | printk(KERN_ERR PREFIX "Unable to undock!\n"); | 688 | printk(KERN_ERR PREFIX "Unable to undock!\n"); |
@@ -604,14 +705,36 @@ static int handle_eject_request(struct dock_station *ds, u32 event) | |||
604 | static void dock_notify(acpi_handle handle, u32 event, void *data) | 705 | static void dock_notify(acpi_handle handle, u32 event, void *data) |
605 | { | 706 | { |
606 | struct dock_station *ds = data; | 707 | struct dock_station *ds = data; |
708 | struct acpi_device *tmp; | ||
709 | int surprise_removal = 0; | ||
710 | |||
711 | /* | ||
712 | * According to acpi spec 3.0a, if a DEVICE_CHECK notification | ||
713 | * is sent and _DCK is present, it is assumed to mean an undock | ||
714 | * request. | ||
715 | */ | ||
716 | if ((ds->flags & DOCK_IS_DOCK) && event == ACPI_NOTIFY_DEVICE_CHECK) | ||
717 | event = ACPI_NOTIFY_EJECT_REQUEST; | ||
607 | 718 | ||
719 | /* | ||
720 | * dock station: BUS_CHECK - docked or surprise removal | ||
721 | * DEVICE_CHECK - undocked | ||
722 | * other device: BUS_CHECK/DEVICE_CHECK - added or surprise removal | ||
723 | * | ||
724 | * To simplify event handling, dock dependent device handler always | ||
725 | * get ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and | ||
726 | * ACPI_NOTIFY_EJECT_REQUEST for removal | ||
727 | */ | ||
608 | switch (event) { | 728 | switch (event) { |
609 | case ACPI_NOTIFY_BUS_CHECK: | 729 | case ACPI_NOTIFY_BUS_CHECK: |
610 | if (!dock_in_progress(ds) && dock_present(ds)) { | 730 | case ACPI_NOTIFY_DEVICE_CHECK: |
731 | if (!dock_in_progress(ds) && acpi_bus_get_device(ds->handle, | ||
732 | &tmp)) { | ||
611 | begin_dock(ds); | 733 | begin_dock(ds); |
612 | dock(ds); | 734 | dock(ds); |
613 | if (!dock_present(ds)) { | 735 | if (!dock_present(ds)) { |
614 | printk(KERN_ERR PREFIX "Unable to dock!\n"); | 736 | printk(KERN_ERR PREFIX "Unable to dock!\n"); |
737 | complete_dock(ds); | ||
615 | break; | 738 | break; |
616 | } | 739 | } |
617 | atomic_notifier_call_chain(&dock_notifier_list, | 740 | atomic_notifier_call_chain(&dock_notifier_list, |
@@ -619,20 +742,19 @@ static void dock_notify(acpi_handle handle, u32 event, void *data) | |||
619 | hotplug_dock_devices(ds, event); | 742 | hotplug_dock_devices(ds, event); |
620 | complete_dock(ds); | 743 | complete_dock(ds); |
621 | dock_event(ds, event, DOCK_EVENT); | 744 | dock_event(ds, event, DOCK_EVENT); |
745 | dock_lock(ds, 1); | ||
746 | break; | ||
622 | } | 747 | } |
623 | break; | 748 | if (dock_present(ds) || dock_in_progress(ds)) |
624 | case ACPI_NOTIFY_DEVICE_CHECK: | 749 | break; |
625 | /* | 750 | /* This is a surprise removal */ |
626 | * According to acpi spec 3.0a, if a DEVICE_CHECK notification | 751 | surprise_removal = 1; |
627 | * is sent and _DCK is present, it is assumed to mean an | 752 | event = ACPI_NOTIFY_EJECT_REQUEST; |
628 | * undock request. This notify routine will only be called | 753 | /* Fall back */ |
629 | * for objects defining _DCK, so we will fall through to eject | ||
630 | * request here. However, we will pass an eject request through | ||
631 | * to the driver who wish to hotplug. | ||
632 | */ | ||
633 | case ACPI_NOTIFY_EJECT_REQUEST: | 754 | case ACPI_NOTIFY_EJECT_REQUEST: |
634 | begin_undock(ds); | 755 | begin_undock(ds); |
635 | if (immediate_undock) | 756 | if ((immediate_undock && !(ds->flags & DOCK_IS_ATA)) |
757 | || surprise_removal) | ||
636 | handle_eject_request(ds, event); | 758 | handle_eject_request(ds, event); |
637 | else | 759 | else |
638 | dock_event(ds, event, UNDOCK_EVENT); | 760 | dock_event(ds, event, UNDOCK_EVENT); |
@@ -642,6 +764,51 @@ static void dock_notify(acpi_handle handle, u32 event, void *data) | |||
642 | } | 764 | } |
643 | } | 765 | } |
644 | 766 | ||
767 | struct dock_data { | ||
768 | acpi_handle handle; | ||
769 | unsigned long event; | ||
770 | struct dock_station *ds; | ||
771 | }; | ||
772 | |||
773 | static void acpi_dock_deferred_cb(void *context) | ||
774 | { | ||
775 | struct dock_data *data = (struct dock_data *)context; | ||
776 | |||
777 | dock_notify(data->handle, data->event, data->ds); | ||
778 | kfree(data); | ||
779 | } | ||
780 | |||
781 | static int acpi_dock_notifier_call(struct notifier_block *this, | ||
782 | unsigned long event, void *data) | ||
783 | { | ||
784 | struct dock_station *dock_station; | ||
785 | acpi_handle handle = (acpi_handle)data; | ||
786 | |||
787 | if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK | ||
788 | && event != ACPI_NOTIFY_EJECT_REQUEST) | ||
789 | return 0; | ||
790 | list_for_each_entry(dock_station, &dock_stations, sibiling) { | ||
791 | if (dock_station->handle == handle) { | ||
792 | struct dock_data *dock_data; | ||
793 | |||
794 | dock_data = kmalloc(sizeof(*dock_data), GFP_KERNEL); | ||
795 | if (!dock_data) | ||
796 | return 0; | ||
797 | dock_data->handle = handle; | ||
798 | dock_data->event = event; | ||
799 | dock_data->ds = dock_station; | ||
800 | acpi_os_hotplug_execute(acpi_dock_deferred_cb, | ||
801 | dock_data); | ||
802 | return 0 ; | ||
803 | } | ||
804 | } | ||
805 | return 0; | ||
806 | } | ||
807 | |||
808 | static struct notifier_block dock_acpi_notifier = { | ||
809 | .notifier_call = acpi_dock_notifier_call, | ||
810 | }; | ||
811 | |||
645 | /** | 812 | /** |
646 | * find_dock_devices - find devices on the dock station | 813 | * find_dock_devices - find devices on the dock station |
647 | * @handle: the handle of the device we are examining | 814 | * @handle: the handle of the device we are examining |
@@ -688,6 +855,8 @@ fdd_out: | |||
688 | static ssize_t show_docked(struct device *dev, | 855 | static ssize_t show_docked(struct device *dev, |
689 | struct device_attribute *attr, char *buf) | 856 | struct device_attribute *attr, char *buf) |
690 | { | 857 | { |
858 | struct dock_station *dock_station = *((struct dock_station **) | ||
859 | dev->platform_data); | ||
691 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_present(dock_station)); | 860 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_present(dock_station)); |
692 | 861 | ||
693 | } | 862 | } |
@@ -699,6 +868,8 @@ static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); | |||
699 | static ssize_t show_flags(struct device *dev, | 868 | static ssize_t show_flags(struct device *dev, |
700 | struct device_attribute *attr, char *buf) | 869 | struct device_attribute *attr, char *buf) |
701 | { | 870 | { |
871 | struct dock_station *dock_station = *((struct dock_station **) | ||
872 | dev->platform_data); | ||
702 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); | 873 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); |
703 | 874 | ||
704 | } | 875 | } |
@@ -711,6 +882,8 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr, | |||
711 | const char *buf, size_t count) | 882 | const char *buf, size_t count) |
712 | { | 883 | { |
713 | int ret; | 884 | int ret; |
885 | struct dock_station *dock_station = *((struct dock_station **) | ||
886 | dev->platform_data); | ||
714 | 887 | ||
715 | if (!count) | 888 | if (!count) |
716 | return -EINVAL; | 889 | return -EINVAL; |
@@ -727,16 +900,38 @@ static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock); | |||
727 | static ssize_t show_dock_uid(struct device *dev, | 900 | static ssize_t show_dock_uid(struct device *dev, |
728 | struct device_attribute *attr, char *buf) | 901 | struct device_attribute *attr, char *buf) |
729 | { | 902 | { |
730 | unsigned long lbuf; | 903 | unsigned long long lbuf; |
904 | struct dock_station *dock_station = *((struct dock_station **) | ||
905 | dev->platform_data); | ||
731 | acpi_status status = acpi_evaluate_integer(dock_station->handle, | 906 | acpi_status status = acpi_evaluate_integer(dock_station->handle, |
732 | "_UID", NULL, &lbuf); | 907 | "_UID", NULL, &lbuf); |
733 | if (ACPI_FAILURE(status)) | 908 | if (ACPI_FAILURE(status)) |
734 | return 0; | 909 | return 0; |
735 | 910 | ||
736 | return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf); | 911 | return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf); |
737 | } | 912 | } |
738 | static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); | 913 | static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); |
739 | 914 | ||
915 | static ssize_t show_dock_type(struct device *dev, | ||
916 | struct device_attribute *attr, char *buf) | ||
917 | { | ||
918 | struct dock_station *dock_station = *((struct dock_station **) | ||
919 | dev->platform_data); | ||
920 | char *type; | ||
921 | |||
922 | if (dock_station->flags & DOCK_IS_DOCK) | ||
923 | type = "dock_station"; | ||
924 | else if (dock_station->flags & DOCK_IS_ATA) | ||
925 | type = "ata_bay"; | ||
926 | else if (dock_station->flags & DOCK_IS_BAT) | ||
927 | type = "battery_bay"; | ||
928 | else | ||
929 | type = "unknown"; | ||
930 | |||
931 | return snprintf(buf, PAGE_SIZE, "%s\n", type); | ||
932 | } | ||
933 | static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL); | ||
934 | |||
740 | /** | 935 | /** |
741 | * dock_add - add a new dock station | 936 | * dock_add - add a new dock station |
742 | * @handle: the dock station handle | 937 | * @handle: the dock station handle |
@@ -747,8 +942,9 @@ static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); | |||
747 | static int dock_add(acpi_handle handle) | 942 | static int dock_add(acpi_handle handle) |
748 | { | 943 | { |
749 | int ret; | 944 | int ret; |
750 | acpi_status status; | ||
751 | struct dock_dependent_device *dd; | 945 | struct dock_dependent_device *dd; |
946 | struct dock_station *dock_station; | ||
947 | struct platform_device *dock_device; | ||
752 | 948 | ||
753 | /* allocate & initialize the dock_station private data */ | 949 | /* allocate & initialize the dock_station private data */ |
754 | dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL); | 950 | dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL); |
@@ -758,22 +954,34 @@ static int dock_add(acpi_handle handle) | |||
758 | dock_station->last_dock_time = jiffies - HZ; | 954 | dock_station->last_dock_time = jiffies - HZ; |
759 | INIT_LIST_HEAD(&dock_station->dependent_devices); | 955 | INIT_LIST_HEAD(&dock_station->dependent_devices); |
760 | INIT_LIST_HEAD(&dock_station->hotplug_devices); | 956 | INIT_LIST_HEAD(&dock_station->hotplug_devices); |
957 | INIT_LIST_HEAD(&dock_station->sibiling); | ||
761 | spin_lock_init(&dock_station->dd_lock); | 958 | spin_lock_init(&dock_station->dd_lock); |
762 | mutex_init(&dock_station->hp_lock); | 959 | mutex_init(&dock_station->hp_lock); |
763 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); | 960 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); |
764 | 961 | ||
765 | /* initialize platform device stuff */ | 962 | /* initialize platform device stuff */ |
766 | dock_device = | 963 | dock_station->dock_device = |
767 | platform_device_register_simple(dock_device_name, 0, NULL, 0); | 964 | platform_device_register_simple(dock_device_name, |
965 | dock_station_count, NULL, 0); | ||
966 | dock_device = dock_station->dock_device; | ||
768 | if (IS_ERR(dock_device)) { | 967 | if (IS_ERR(dock_device)) { |
769 | kfree(dock_station); | 968 | kfree(dock_station); |
770 | dock_station = NULL; | 969 | dock_station = NULL; |
771 | return PTR_ERR(dock_device); | 970 | return PTR_ERR(dock_device); |
772 | } | 971 | } |
972 | platform_device_add_data(dock_device, &dock_station, | ||
973 | sizeof(struct dock_station *)); | ||
773 | 974 | ||
774 | /* we want the dock device to send uevents */ | 975 | /* we want the dock device to send uevents */ |
775 | dock_device->dev.uevent_suppress = 0; | 976 | dock_device->dev.uevent_suppress = 0; |
776 | 977 | ||
978 | if (is_dock(handle)) | ||
979 | dock_station->flags |= DOCK_IS_DOCK; | ||
980 | if (is_ata(handle)) | ||
981 | dock_station->flags |= DOCK_IS_ATA; | ||
982 | if (is_battery(handle)) | ||
983 | dock_station->flags |= DOCK_IS_BAT; | ||
984 | |||
777 | ret = device_create_file(&dock_device->dev, &dev_attr_docked); | 985 | ret = device_create_file(&dock_device->dev, &dev_attr_docked); |
778 | if (ret) { | 986 | if (ret) { |
779 | printk("Error %d adding sysfs file\n", ret); | 987 | printk("Error %d adding sysfs file\n", ret); |
@@ -812,6 +1020,9 @@ static int dock_add(acpi_handle handle) | |||
812 | dock_station = NULL; | 1020 | dock_station = NULL; |
813 | return ret; | 1021 | return ret; |
814 | } | 1022 | } |
1023 | ret = device_create_file(&dock_device->dev, &dev_attr_type); | ||
1024 | if (ret) | ||
1025 | printk(KERN_ERR"Error %d adding sysfs file\n", ret); | ||
815 | 1026 | ||
816 | /* Find dependent devices */ | 1027 | /* Find dependent devices */ |
817 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 1028 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
@@ -828,24 +1039,12 @@ static int dock_add(acpi_handle handle) | |||
828 | } | 1039 | } |
829 | add_dock_dependent_device(dock_station, dd); | 1040 | add_dock_dependent_device(dock_station, dd); |
830 | 1041 | ||
831 | /* register for dock events */ | 1042 | dock_station_count++; |
832 | status = acpi_install_notify_handler(dock_station->handle, | 1043 | list_add(&dock_station->sibiling, &dock_stations); |
833 | ACPI_SYSTEM_NOTIFY, | ||
834 | dock_notify, dock_station); | ||
835 | |||
836 | if (ACPI_FAILURE(status)) { | ||
837 | printk(KERN_ERR PREFIX "Error installing notify handler\n"); | ||
838 | ret = -ENODEV; | ||
839 | goto dock_add_err; | ||
840 | } | ||
841 | |||
842 | printk(KERN_INFO PREFIX "%s\n", ACPI_DOCK_DRIVER_DESCRIPTION); | ||
843 | |||
844 | return 0; | 1044 | return 0; |
845 | 1045 | ||
846 | dock_add_err: | ||
847 | kfree(dd); | ||
848 | dock_add_err_unregister: | 1046 | dock_add_err_unregister: |
1047 | device_remove_file(&dock_device->dev, &dev_attr_type); | ||
849 | device_remove_file(&dock_device->dev, &dev_attr_docked); | 1048 | device_remove_file(&dock_device->dev, &dev_attr_docked); |
850 | device_remove_file(&dock_device->dev, &dev_attr_undock); | 1049 | device_remove_file(&dock_device->dev, &dev_attr_undock); |
851 | device_remove_file(&dock_device->dev, &dev_attr_uid); | 1050 | device_remove_file(&dock_device->dev, &dev_attr_uid); |
@@ -859,12 +1058,12 @@ dock_add_err_unregister: | |||
859 | /** | 1058 | /** |
860 | * dock_remove - free up resources related to the dock station | 1059 | * dock_remove - free up resources related to the dock station |
861 | */ | 1060 | */ |
862 | static int dock_remove(void) | 1061 | static int dock_remove(struct dock_station *dock_station) |
863 | { | 1062 | { |
864 | struct dock_dependent_device *dd, *tmp; | 1063 | struct dock_dependent_device *dd, *tmp; |
865 | acpi_status status; | 1064 | struct platform_device *dock_device = dock_station->dock_device; |
866 | 1065 | ||
867 | if (!dock_station) | 1066 | if (!dock_station_count) |
868 | return 0; | 1067 | return 0; |
869 | 1068 | ||
870 | /* remove dependent devices */ | 1069 | /* remove dependent devices */ |
@@ -872,14 +1071,8 @@ static int dock_remove(void) | |||
872 | list) | 1071 | list) |
873 | kfree(dd); | 1072 | kfree(dd); |
874 | 1073 | ||
875 | /* remove dock notify handler */ | ||
876 | status = acpi_remove_notify_handler(dock_station->handle, | ||
877 | ACPI_SYSTEM_NOTIFY, | ||
878 | dock_notify); | ||
879 | if (ACPI_FAILURE(status)) | ||
880 | printk(KERN_ERR "Error removing notify handler\n"); | ||
881 | |||
882 | /* cleanup sysfs */ | 1074 | /* cleanup sysfs */ |
1075 | device_remove_file(&dock_device->dev, &dev_attr_type); | ||
883 | device_remove_file(&dock_device->dev, &dev_attr_docked); | 1076 | device_remove_file(&dock_device->dev, &dev_attr_docked); |
884 | device_remove_file(&dock_device->dev, &dev_attr_undock); | 1077 | device_remove_file(&dock_device->dev, &dev_attr_undock); |
885 | device_remove_file(&dock_device->dev, &dev_attr_uid); | 1078 | device_remove_file(&dock_device->dev, &dev_attr_uid); |
@@ -904,41 +1097,60 @@ static int dock_remove(void) | |||
904 | static acpi_status | 1097 | static acpi_status |
905 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) | 1098 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) |
906 | { | 1099 | { |
907 | int *count = context; | ||
908 | acpi_status status = AE_OK; | 1100 | acpi_status status = AE_OK; |
909 | 1101 | ||
910 | if (is_dock(handle)) { | 1102 | if (is_dock(handle)) { |
911 | if (dock_add(handle) >= 0) { | 1103 | if (dock_add(handle) >= 0) { |
912 | (*count)++; | ||
913 | status = AE_CTRL_TERMINATE; | 1104 | status = AE_CTRL_TERMINATE; |
914 | } | 1105 | } |
915 | } | 1106 | } |
916 | return status; | 1107 | return status; |
917 | } | 1108 | } |
918 | 1109 | ||
919 | static int __init dock_init(void) | 1110 | static acpi_status |
1111 | find_bay(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
920 | { | 1112 | { |
921 | int num = 0; | 1113 | /* If bay is a dock, it's already handled */ |
922 | 1114 | if (is_ejectable_bay(handle) && !is_dock(handle)) | |
923 | dock_station = NULL; | 1115 | dock_add(handle); |
1116 | return AE_OK; | ||
1117 | } | ||
924 | 1118 | ||
1119 | static int __init dock_init(void) | ||
1120 | { | ||
925 | if (acpi_disabled) | 1121 | if (acpi_disabled) |
926 | return 0; | 1122 | return 0; |
927 | 1123 | ||
928 | /* look for a dock station */ | 1124 | /* look for a dock station */ |
929 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 1125 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
930 | ACPI_UINT32_MAX, find_dock, &num, NULL); | 1126 | ACPI_UINT32_MAX, find_dock, NULL, NULL); |
931 | 1127 | ||
932 | if (!num) | 1128 | /* look for bay */ |
933 | printk(KERN_INFO "No dock devices found.\n"); | 1129 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
1130 | ACPI_UINT32_MAX, find_bay, NULL, NULL); | ||
1131 | if (!dock_station_count) { | ||
1132 | printk(KERN_INFO PREFIX "No dock devices found.\n"); | ||
1133 | return 0; | ||
1134 | } | ||
934 | 1135 | ||
1136 | register_acpi_bus_notifier(&dock_acpi_notifier); | ||
1137 | printk(KERN_INFO PREFIX "%s: %d docks/bays found\n", | ||
1138 | ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count); | ||
935 | return 0; | 1139 | return 0; |
936 | } | 1140 | } |
937 | 1141 | ||
938 | static void __exit dock_exit(void) | 1142 | static void __exit dock_exit(void) |
939 | { | 1143 | { |
940 | dock_remove(); | 1144 | struct dock_station *dock_station; |
1145 | |||
1146 | unregister_acpi_bus_notifier(&dock_acpi_notifier); | ||
1147 | list_for_each_entry(dock_station, &dock_stations, sibiling) | ||
1148 | dock_remove(dock_station); | ||
941 | } | 1149 | } |
942 | 1150 | ||
943 | postcore_initcall(dock_init); | 1151 | /* |
1152 | * Must be called before drivers of devices in dock, otherwise we can't know | ||
1153 | * which devices are in a dock | ||
1154 | */ | ||
1155 | subsys_initcall(dock_init); | ||
944 | module_exit(dock_exit); | 1156 | module_exit(dock_exit); |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 13593f9f2197..30f3ef236ecb 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * ec.c - ACPI Embedded Controller Driver (v2.0) | 2 | * ec.c - ACPI Embedded Controller Driver (v2.1) |
3 | * | 3 | * |
4 | * Copyright (C) 2006, 2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> | 4 | * Copyright (C) 2006-2008 Alexey Starikovskiy <astarikovskiy@suse.de> |
5 | * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com> | 5 | * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com> |
6 | * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> | 6 | * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> |
7 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | 7 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> |
@@ -26,7 +26,7 @@ | |||
26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | /* Uncomment next line to get verbose print outs*/ | 29 | /* Uncomment next line to get verbose printout */ |
30 | /* #define DEBUG */ | 30 | /* #define DEBUG */ |
31 | 31 | ||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/seq_file.h> | 38 | #include <linux/seq_file.h> |
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/list.h> | 40 | #include <linux/list.h> |
41 | #include <linux/spinlock.h> | ||
41 | #include <asm/io.h> | 42 | #include <asm/io.h> |
42 | #include <acpi/acpi_bus.h> | 43 | #include <acpi/acpi_bus.h> |
43 | #include <acpi/acpi_drivers.h> | 44 | #include <acpi/acpi_drivers.h> |
@@ -65,22 +66,21 @@ enum ec_command { | |||
65 | ACPI_EC_COMMAND_QUERY = 0x84, | 66 | ACPI_EC_COMMAND_QUERY = 0x84, |
66 | }; | 67 | }; |
67 | 68 | ||
68 | /* EC events */ | ||
69 | enum ec_event { | ||
70 | ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ | ||
71 | ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ | ||
72 | }; | ||
73 | |||
74 | #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ | 69 | #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ |
75 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ | 70 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ |
76 | #define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */ | 71 | #define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */ |
77 | 72 | ||
73 | #define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts | ||
74 | per one transaction */ | ||
75 | |||
78 | enum { | 76 | enum { |
79 | EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ | ||
80 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ | 77 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ |
81 | EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ | 78 | EC_FLAGS_GPE_MODE, /* Expect GPE to be sent |
79 | * for status change */ | ||
82 | EC_FLAGS_NO_GPE, /* Don't use GPE mode */ | 80 | EC_FLAGS_NO_GPE, /* Don't use GPE mode */ |
83 | EC_FLAGS_RESCHEDULE_POLL /* Re-schedule poll */ | 81 | EC_FLAGS_GPE_STORM, /* GPE storm detected */ |
82 | EC_FLAGS_HANDLERS_INSTALLED /* Handlers for GPE and | ||
83 | * OpReg are installed */ | ||
84 | }; | 84 | }; |
85 | 85 | ||
86 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | 86 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ |
@@ -95,6 +95,18 @@ struct acpi_ec_query_handler { | |||
95 | u8 query_bit; | 95 | u8 query_bit; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | struct transaction { | ||
99 | const u8 *wdata; | ||
100 | u8 *rdata; | ||
101 | unsigned short irq_count; | ||
102 | u8 command; | ||
103 | u8 wi; | ||
104 | u8 ri; | ||
105 | u8 wlen; | ||
106 | u8 rlen; | ||
107 | bool done; | ||
108 | }; | ||
109 | |||
98 | static struct acpi_ec { | 110 | static struct acpi_ec { |
99 | acpi_handle handle; | 111 | acpi_handle handle; |
100 | unsigned long gpe; | 112 | unsigned long gpe; |
@@ -105,9 +117,8 @@ static struct acpi_ec { | |||
105 | struct mutex lock; | 117 | struct mutex lock; |
106 | wait_queue_head_t wait; | 118 | wait_queue_head_t wait; |
107 | struct list_head list; | 119 | struct list_head list; |
108 | struct delayed_work work; | 120 | struct transaction *curr; |
109 | atomic_t irq_count; | 121 | spinlock_t curr_lock; |
110 | u8 handlers_installed; | ||
111 | } *boot_ec, *first_ec; | 122 | } *boot_ec, *first_ec; |
112 | 123 | ||
113 | /* | 124 | /* |
@@ -150,7 +161,7 @@ static inline u8 acpi_ec_read_data(struct acpi_ec *ec) | |||
150 | { | 161 | { |
151 | u8 x = inb(ec->data_addr); | 162 | u8 x = inb(ec->data_addr); |
152 | pr_debug(PREFIX "---> data = 0x%2.2x\n", x); | 163 | pr_debug(PREFIX "---> data = 0x%2.2x\n", x); |
153 | return inb(ec->data_addr); | 164 | return x; |
154 | } | 165 | } |
155 | 166 | ||
156 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) | 167 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) |
@@ -165,158 +176,193 @@ static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) | |||
165 | outb(data, ec->data_addr); | 176 | outb(data, ec->data_addr); |
166 | } | 177 | } |
167 | 178 | ||
168 | static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) | 179 | static int ec_transaction_done(struct acpi_ec *ec) |
169 | { | 180 | { |
170 | if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags)) | 181 | unsigned long flags; |
171 | return 0; | 182 | int ret = 0; |
172 | if (event == ACPI_EC_EVENT_OBF_1) { | 183 | spin_lock_irqsave(&ec->curr_lock, flags); |
173 | if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF) | 184 | if (!ec->curr || ec->curr->done) |
174 | return 1; | 185 | ret = 1; |
175 | } else if (event == ACPI_EC_EVENT_IBF_0) { | 186 | spin_unlock_irqrestore(&ec->curr_lock, flags); |
176 | if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)) | 187 | return ret; |
177 | return 1; | 188 | } |
178 | } | ||
179 | 189 | ||
180 | return 0; | 190 | static void start_transaction(struct acpi_ec *ec) |
191 | { | ||
192 | ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0; | ||
193 | ec->curr->done = false; | ||
194 | acpi_ec_write_cmd(ec, ec->curr->command); | ||
181 | } | 195 | } |
182 | 196 | ||
183 | static void ec_schedule_ec_poll(struct acpi_ec *ec) | 197 | static void gpe_transaction(struct acpi_ec *ec, u8 status) |
184 | { | 198 | { |
185 | if (test_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags)) | 199 | unsigned long flags; |
186 | schedule_delayed_work(&ec->work, | 200 | spin_lock_irqsave(&ec->curr_lock, flags); |
187 | msecs_to_jiffies(ACPI_EC_DELAY)); | 201 | if (!ec->curr) |
202 | goto unlock; | ||
203 | if (ec->curr->wlen > ec->curr->wi) { | ||
204 | if ((status & ACPI_EC_FLAG_IBF) == 0) | ||
205 | acpi_ec_write_data(ec, | ||
206 | ec->curr->wdata[ec->curr->wi++]); | ||
207 | else | ||
208 | goto err; | ||
209 | } else if (ec->curr->rlen > ec->curr->ri) { | ||
210 | if ((status & ACPI_EC_FLAG_OBF) == 1) { | ||
211 | ec->curr->rdata[ec->curr->ri++] = acpi_ec_read_data(ec); | ||
212 | if (ec->curr->rlen == ec->curr->ri) | ||
213 | ec->curr->done = true; | ||
214 | } else | ||
215 | goto err; | ||
216 | } else if (ec->curr->wlen == ec->curr->wi && | ||
217 | (status & ACPI_EC_FLAG_IBF) == 0) | ||
218 | ec->curr->done = true; | ||
219 | goto unlock; | ||
220 | err: | ||
221 | /* false interrupt, state didn't change */ | ||
222 | if (in_interrupt()) | ||
223 | ++ec->curr->irq_count; | ||
224 | unlock: | ||
225 | spin_unlock_irqrestore(&ec->curr_lock, flags); | ||
188 | } | 226 | } |
189 | 227 | ||
190 | static void ec_switch_to_poll_mode(struct acpi_ec *ec) | 228 | static int acpi_ec_wait(struct acpi_ec *ec) |
191 | { | 229 | { |
230 | if (wait_event_timeout(ec->wait, ec_transaction_done(ec), | ||
231 | msecs_to_jiffies(ACPI_EC_DELAY))) | ||
232 | return 0; | ||
233 | /* try restart command if we get any false interrupts */ | ||
234 | if (ec->curr->irq_count && | ||
235 | (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) { | ||
236 | pr_debug(PREFIX "controller reset, restart transaction\n"); | ||
237 | start_transaction(ec); | ||
238 | if (wait_event_timeout(ec->wait, ec_transaction_done(ec), | ||
239 | msecs_to_jiffies(ACPI_EC_DELAY))) | ||
240 | return 0; | ||
241 | } | ||
242 | /* missing GPEs, switch back to poll mode */ | ||
243 | if (printk_ratelimit()) | ||
244 | pr_info(PREFIX "missing confirmations, " | ||
245 | "switch off interrupt mode.\n"); | ||
192 | set_bit(EC_FLAGS_NO_GPE, &ec->flags); | 246 | set_bit(EC_FLAGS_NO_GPE, &ec->flags); |
193 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); | 247 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
194 | acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 248 | return 1; |
195 | set_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags); | ||
196 | } | 249 | } |
197 | 250 | ||
198 | static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) | 251 | static void acpi_ec_gpe_query(void *ec_cxt); |
252 | |||
253 | static int ec_check_sci(struct acpi_ec *ec, u8 state) | ||
199 | { | 254 | { |
200 | atomic_set(&ec->irq_count, 0); | 255 | if (state & ACPI_EC_FLAG_SCI) { |
201 | if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && | 256 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) |
202 | likely(!force_poll)) { | 257 | return acpi_os_execute(OSL_EC_BURST_HANDLER, |
203 | if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), | 258 | acpi_ec_gpe_query, ec); |
204 | msecs_to_jiffies(ACPI_EC_DELAY))) | 259 | } |
205 | return 0; | 260 | return 0; |
206 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | 261 | } |
207 | if (acpi_ec_check_status(ec, event)) { | 262 | |
208 | /* missing GPEs, switch back to poll mode */ | 263 | static int ec_poll(struct acpi_ec *ec) |
209 | if (printk_ratelimit()) | 264 | { |
210 | pr_info(PREFIX "missing confirmations, " | 265 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); |
211 | "switch off interrupt mode.\n"); | 266 | udelay(ACPI_EC_UDELAY); |
212 | ec_switch_to_poll_mode(ec); | 267 | while (time_before(jiffies, delay)) { |
213 | ec_schedule_ec_poll(ec); | 268 | gpe_transaction(ec, acpi_ec_read_status(ec)); |
214 | return 0; | 269 | udelay(ACPI_EC_UDELAY); |
215 | } | 270 | if (ec_transaction_done(ec)) |
216 | } else { | ||
217 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); | ||
218 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | ||
219 | while (time_before(jiffies, delay)) { | ||
220 | if (acpi_ec_check_status(ec, event)) | ||
221 | return 0; | ||
222 | msleep(1); | ||
223 | } | ||
224 | if (acpi_ec_check_status(ec,event)) | ||
225 | return 0; | 271 | return 0; |
226 | } | 272 | } |
227 | pr_err(PREFIX "acpi_ec_wait timeout, status = 0x%2.2x, event = %s\n", | ||
228 | acpi_ec_read_status(ec), | ||
229 | (event == ACPI_EC_EVENT_OBF_1) ? "\"b0=1\"" : "\"b1=0\""); | ||
230 | return -ETIME; | 273 | return -ETIME; |
231 | } | 274 | } |
232 | 275 | ||
233 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | 276 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, |
234 | const u8 * wdata, unsigned wdata_len, | 277 | struct transaction *t, |
235 | u8 * rdata, unsigned rdata_len, | ||
236 | int force_poll) | 278 | int force_poll) |
237 | { | 279 | { |
238 | int result = 0; | 280 | unsigned long tmp; |
239 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | 281 | int ret = 0; |
240 | pr_debug(PREFIX "transaction start\n"); | 282 | pr_debug(PREFIX "transaction start\n"); |
241 | acpi_ec_write_cmd(ec, command); | 283 | /* disable GPE during transaction if storm is detected */ |
242 | for (; wdata_len > 0; --wdata_len) { | 284 | if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { |
243 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); | 285 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
244 | if (result) { | 286 | acpi_disable_gpe(NULL, ec->gpe); |
245 | pr_err(PREFIX | ||
246 | "write_cmd timeout, command = %d\n", command); | ||
247 | goto end; | ||
248 | } | ||
249 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | ||
250 | acpi_ec_write_data(ec, *(wdata++)); | ||
251 | } | 287 | } |
252 | 288 | /* start transaction */ | |
253 | if (!rdata_len) { | 289 | spin_lock_irqsave(&ec->curr_lock, tmp); |
254 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); | 290 | /* following two actions should be kept atomic */ |
255 | if (result) { | 291 | ec->curr = t; |
256 | pr_err(PREFIX | 292 | start_transaction(ec); |
257 | "finish-write timeout, command = %d\n", command); | 293 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) |
258 | goto end; | ||
259 | } | ||
260 | } else if (command == ACPI_EC_COMMAND_QUERY) | ||
261 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); | 294 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
262 | 295 | spin_unlock_irqrestore(&ec->curr_lock, tmp); | |
263 | for (; rdata_len > 0; --rdata_len) { | 296 | /* if we selected poll mode or failed in GPE-mode do a poll loop */ |
264 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); | 297 | if (force_poll || |
265 | if (result) { | 298 | !test_bit(EC_FLAGS_GPE_MODE, &ec->flags) || |
266 | pr_err(PREFIX "read timeout, command = %d\n", command); | 299 | acpi_ec_wait(ec)) |
267 | goto end; | 300 | ret = ec_poll(ec); |
268 | } | ||
269 | /* Don't expect GPE after last read */ | ||
270 | if (rdata_len > 1) | ||
271 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | ||
272 | *(rdata++) = acpi_ec_read_data(ec); | ||
273 | } | ||
274 | end: | ||
275 | pr_debug(PREFIX "transaction end\n"); | 301 | pr_debug(PREFIX "transaction end\n"); |
276 | return result; | 302 | spin_lock_irqsave(&ec->curr_lock, tmp); |
303 | ec->curr = NULL; | ||
304 | spin_unlock_irqrestore(&ec->curr_lock, tmp); | ||
305 | if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { | ||
306 | /* check if we received SCI during transaction */ | ||
307 | ec_check_sci(ec, acpi_ec_read_status(ec)); | ||
308 | /* it is safe to enable GPE outside of transaction */ | ||
309 | acpi_enable_gpe(NULL, ec->gpe); | ||
310 | } else if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && | ||
311 | t->irq_count > ACPI_EC_STORM_THRESHOLD) { | ||
312 | pr_info(PREFIX "GPE storm detected, " | ||
313 | "transactions will use polling mode\n"); | ||
314 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); | ||
315 | } | ||
316 | return ret; | ||
317 | } | ||
318 | |||
319 | static int ec_check_ibf0(struct acpi_ec *ec) | ||
320 | { | ||
321 | u8 status = acpi_ec_read_status(ec); | ||
322 | return (status & ACPI_EC_FLAG_IBF) == 0; | ||
323 | } | ||
324 | |||
325 | static int ec_wait_ibf0(struct acpi_ec *ec) | ||
326 | { | ||
327 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); | ||
328 | /* interrupt wait manually if GPE mode is not active */ | ||
329 | unsigned long timeout = test_bit(EC_FLAGS_GPE_MODE, &ec->flags) ? | ||
330 | msecs_to_jiffies(ACPI_EC_DELAY) : msecs_to_jiffies(1); | ||
331 | while (time_before(jiffies, delay)) | ||
332 | if (wait_event_timeout(ec->wait, ec_check_ibf0(ec), timeout)) | ||
333 | return 0; | ||
334 | return -ETIME; | ||
277 | } | 335 | } |
278 | 336 | ||
279 | static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | 337 | static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t, |
280 | const u8 * wdata, unsigned wdata_len, | ||
281 | u8 * rdata, unsigned rdata_len, | ||
282 | int force_poll) | 338 | int force_poll) |
283 | { | 339 | { |
284 | int status; | 340 | int status; |
285 | u32 glk; | 341 | u32 glk; |
286 | 342 | if (!ec || (!t) || (t->wlen && !t->wdata) || (t->rlen && !t->rdata)) | |
287 | if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata)) | ||
288 | return -EINVAL; | 343 | return -EINVAL; |
289 | 344 | if (t->rdata) | |
290 | if (rdata) | 345 | memset(t->rdata, 0, t->rlen); |
291 | memset(rdata, 0, rdata_len); | ||
292 | |||
293 | mutex_lock(&ec->lock); | 346 | mutex_lock(&ec->lock); |
294 | if (ec->global_lock) { | 347 | if (ec->global_lock) { |
295 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); | 348 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); |
296 | if (ACPI_FAILURE(status)) { | 349 | if (ACPI_FAILURE(status)) { |
297 | mutex_unlock(&ec->lock); | 350 | status = -ENODEV; |
298 | return -ENODEV; | 351 | goto unlock; |
299 | } | 352 | } |
300 | } | 353 | } |
301 | 354 | if (ec_wait_ibf0(ec)) { | |
302 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); | ||
303 | if (status) { | ||
304 | pr_err(PREFIX "input buffer is not empty, " | 355 | pr_err(PREFIX "input buffer is not empty, " |
305 | "aborting transaction\n"); | 356 | "aborting transaction\n"); |
357 | status = -ETIME; | ||
306 | goto end; | 358 | goto end; |
307 | } | 359 | } |
308 | 360 | status = acpi_ec_transaction_unlocked(ec, t, force_poll); | |
309 | status = acpi_ec_transaction_unlocked(ec, command, | 361 | end: |
310 | wdata, wdata_len, | ||
311 | rdata, rdata_len, | ||
312 | force_poll); | ||
313 | |||
314 | end: | ||
315 | |||
316 | if (ec->global_lock) | 362 | if (ec->global_lock) |
317 | acpi_release_global_lock(glk); | 363 | acpi_release_global_lock(glk); |
364 | unlock: | ||
318 | mutex_unlock(&ec->lock); | 365 | mutex_unlock(&ec->lock); |
319 | |||
320 | return status; | 366 | return status; |
321 | } | 367 | } |
322 | 368 | ||
@@ -327,21 +373,32 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | |||
327 | int acpi_ec_burst_enable(struct acpi_ec *ec) | 373 | int acpi_ec_burst_enable(struct acpi_ec *ec) |
328 | { | 374 | { |
329 | u8 d; | 375 | u8 d; |
330 | return acpi_ec_transaction(ec, ACPI_EC_BURST_ENABLE, NULL, 0, &d, 1, 0); | 376 | struct transaction t = {.command = ACPI_EC_BURST_ENABLE, |
377 | .wdata = NULL, .rdata = &d, | ||
378 | .wlen = 0, .rlen = 1}; | ||
379 | |||
380 | return acpi_ec_transaction(ec, &t, 0); | ||
331 | } | 381 | } |
332 | 382 | ||
333 | int acpi_ec_burst_disable(struct acpi_ec *ec) | 383 | int acpi_ec_burst_disable(struct acpi_ec *ec) |
334 | { | 384 | { |
335 | return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0, 0); | 385 | struct transaction t = {.command = ACPI_EC_BURST_DISABLE, |
386 | .wdata = NULL, .rdata = NULL, | ||
387 | .wlen = 0, .rlen = 0}; | ||
388 | |||
389 | return (acpi_ec_read_status(ec) & ACPI_EC_FLAG_BURST) ? | ||
390 | acpi_ec_transaction(ec, &t, 0) : 0; | ||
336 | } | 391 | } |
337 | 392 | ||
338 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) | 393 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) |
339 | { | 394 | { |
340 | int result; | 395 | int result; |
341 | u8 d; | 396 | u8 d; |
397 | struct transaction t = {.command = ACPI_EC_COMMAND_READ, | ||
398 | .wdata = &address, .rdata = &d, | ||
399 | .wlen = 1, .rlen = 1}; | ||
342 | 400 | ||
343 | result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ, | 401 | result = acpi_ec_transaction(ec, &t, 0); |
344 | &address, 1, &d, 1, 0); | ||
345 | *data = d; | 402 | *data = d; |
346 | return result; | 403 | return result; |
347 | } | 404 | } |
@@ -349,8 +406,11 @@ static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) | |||
349 | static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) | 406 | static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) |
350 | { | 407 | { |
351 | u8 wdata[2] = { address, data }; | 408 | u8 wdata[2] = { address, data }; |
352 | return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE, | 409 | struct transaction t = {.command = ACPI_EC_COMMAND_WRITE, |
353 | wdata, 2, NULL, 0, 0); | 410 | .wdata = wdata, .rdata = NULL, |
411 | .wlen = 2, .rlen = 0}; | ||
412 | |||
413 | return acpi_ec_transaction(ec, &t, 0); | ||
354 | } | 414 | } |
355 | 415 | ||
356 | /* | 416 | /* |
@@ -412,12 +472,13 @@ int ec_transaction(u8 command, | |||
412 | u8 * rdata, unsigned rdata_len, | 472 | u8 * rdata, unsigned rdata_len, |
413 | int force_poll) | 473 | int force_poll) |
414 | { | 474 | { |
475 | struct transaction t = {.command = command, | ||
476 | .wdata = wdata, .rdata = rdata, | ||
477 | .wlen = wdata_len, .rlen = rdata_len}; | ||
415 | if (!first_ec) | 478 | if (!first_ec) |
416 | return -ENODEV; | 479 | return -ENODEV; |
417 | 480 | ||
418 | return acpi_ec_transaction(first_ec, command, wdata, | 481 | return acpi_ec_transaction(first_ec, &t, force_poll); |
419 | wdata_len, rdata, rdata_len, | ||
420 | force_poll); | ||
421 | } | 482 | } |
422 | 483 | ||
423 | EXPORT_SYMBOL(ec_transaction); | 484 | EXPORT_SYMBOL(ec_transaction); |
@@ -426,7 +487,9 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 * data) | |||
426 | { | 487 | { |
427 | int result; | 488 | int result; |
428 | u8 d; | 489 | u8 d; |
429 | 490 | struct transaction t = {.command = ACPI_EC_COMMAND_QUERY, | |
491 | .wdata = NULL, .rdata = &d, | ||
492 | .wlen = 0, .rlen = 1}; | ||
430 | if (!ec || !data) | 493 | if (!ec || !data) |
431 | return -EINVAL; | 494 | return -EINVAL; |
432 | 495 | ||
@@ -436,7 +499,7 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 * data) | |||
436 | * bit to be cleared (and thus clearing the interrupt source). | 499 | * bit to be cleared (and thus clearing the interrupt source). |
437 | */ | 500 | */ |
438 | 501 | ||
439 | result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1, 0); | 502 | result = acpi_ec_transaction(ec, &t, 0); |
440 | if (result) | 503 | if (result) |
441 | return result; | 504 | return result; |
442 | 505 | ||
@@ -513,46 +576,35 @@ static void acpi_ec_gpe_query(void *ec_cxt) | |||
513 | 576 | ||
514 | static u32 acpi_ec_gpe_handler(void *data) | 577 | static u32 acpi_ec_gpe_handler(void *data) |
515 | { | 578 | { |
516 | acpi_status status = AE_OK; | ||
517 | struct acpi_ec *ec = data; | 579 | struct acpi_ec *ec = data; |
518 | u8 state = acpi_ec_read_status(ec); | 580 | u8 status; |
519 | 581 | ||
520 | pr_debug(PREFIX "~~~> interrupt\n"); | 582 | pr_debug(PREFIX "~~~> interrupt\n"); |
521 | atomic_inc(&ec->irq_count); | 583 | status = acpi_ec_read_status(ec); |
522 | if (atomic_read(&ec->irq_count) > 5) { | 584 | |
523 | pr_err(PREFIX "GPE storm detected, disabling EC GPE\n"); | 585 | if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) { |
524 | ec_switch_to_poll_mode(ec); | 586 | gpe_transaction(ec, status); |
525 | goto end; | 587 | if (ec_transaction_done(ec) && |
588 | (status & ACPI_EC_FLAG_IBF) == 0) | ||
589 | wake_up(&ec->wait); | ||
526 | } | 590 | } |
527 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | ||
528 | if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) | ||
529 | wake_up(&ec->wait); | ||
530 | 591 | ||
531 | if (state & ACPI_EC_FLAG_SCI) { | 592 | ec_check_sci(ec, status); |
532 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) | 593 | if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && |
533 | status = acpi_os_execute(OSL_EC_BURST_HANDLER, | 594 | !test_bit(EC_FLAGS_NO_GPE, &ec->flags)) { |
534 | acpi_ec_gpe_query, ec); | ||
535 | } else if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && | ||
536 | !test_bit(EC_FLAGS_NO_GPE, &ec->flags) && | ||
537 | in_interrupt()) { | ||
538 | /* this is non-query, must be confirmation */ | 595 | /* this is non-query, must be confirmation */ |
539 | if (printk_ratelimit()) | 596 | if (!test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { |
540 | pr_info(PREFIX "non-query interrupt received," | 597 | if (printk_ratelimit()) |
598 | pr_info(PREFIX "non-query interrupt received," | ||
599 | " switching to interrupt mode\n"); | ||
600 | } else { | ||
601 | /* hush, STORM switches the mode every transaction */ | ||
602 | pr_debug(PREFIX "non-query interrupt received," | ||
541 | " switching to interrupt mode\n"); | 603 | " switching to interrupt mode\n"); |
604 | } | ||
542 | set_bit(EC_FLAGS_GPE_MODE, &ec->flags); | 605 | set_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
543 | clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags); | ||
544 | } | 606 | } |
545 | end: | 607 | return ACPI_INTERRUPT_HANDLED; |
546 | ec_schedule_ec_poll(ec); | ||
547 | return ACPI_SUCCESS(status) ? | ||
548 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | ||
549 | } | ||
550 | |||
551 | static void do_ec_poll(struct work_struct *work) | ||
552 | { | ||
553 | struct acpi_ec *ec = container_of(work, struct acpi_ec, work.work); | ||
554 | atomic_set(&ec->irq_count, 0); | ||
555 | (void)acpi_ec_gpe_handler(ec); | ||
556 | } | 608 | } |
557 | 609 | ||
558 | /* -------------------------------------------------------------------------- | 610 | /* -------------------------------------------------------------------------- |
@@ -696,8 +748,7 @@ static struct acpi_ec *make_acpi_ec(void) | |||
696 | mutex_init(&ec->lock); | 748 | mutex_init(&ec->lock); |
697 | init_waitqueue_head(&ec->wait); | 749 | init_waitqueue_head(&ec->wait); |
698 | INIT_LIST_HEAD(&ec->list); | 750 | INIT_LIST_HEAD(&ec->list); |
699 | INIT_DELAYED_WORK_DEFERRABLE(&ec->work, do_ec_poll); | 751 | spin_lock_init(&ec->curr_lock); |
700 | atomic_set(&ec->irq_count, 0); | ||
701 | return ec; | 752 | return ec; |
702 | } | 753 | } |
703 | 754 | ||
@@ -718,6 +769,7 @@ static acpi_status | |||
718 | ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) | 769 | ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) |
719 | { | 770 | { |
720 | acpi_status status; | 771 | acpi_status status; |
772 | unsigned long long tmp = 0; | ||
721 | 773 | ||
722 | struct acpi_ec *ec = context; | 774 | struct acpi_ec *ec = context; |
723 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 775 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
@@ -727,31 +779,27 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) | |||
727 | 779 | ||
728 | /* Get GPE bit assignment (EC events). */ | 780 | /* Get GPE bit assignment (EC events). */ |
729 | /* TODO: Add support for _GPE returning a package */ | 781 | /* TODO: Add support for _GPE returning a package */ |
730 | status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe); | 782 | status = acpi_evaluate_integer(handle, "_GPE", NULL, &tmp); |
731 | if (ACPI_FAILURE(status)) | 783 | if (ACPI_FAILURE(status)) |
732 | return status; | 784 | return status; |
785 | ec->gpe = tmp; | ||
733 | /* Use the global lock for all EC transactions? */ | 786 | /* Use the global lock for all EC transactions? */ |
734 | acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock); | 787 | tmp = 0; |
788 | acpi_evaluate_integer(handle, "_GLK", NULL, &tmp); | ||
789 | ec->global_lock = tmp; | ||
735 | ec->handle = handle; | 790 | ec->handle = handle; |
736 | return AE_CTRL_TERMINATE; | 791 | return AE_CTRL_TERMINATE; |
737 | } | 792 | } |
738 | 793 | ||
739 | static void ec_poll_stop(struct acpi_ec *ec) | ||
740 | { | ||
741 | clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags); | ||
742 | cancel_delayed_work(&ec->work); | ||
743 | } | ||
744 | |||
745 | static void ec_remove_handlers(struct acpi_ec *ec) | 794 | static void ec_remove_handlers(struct acpi_ec *ec) |
746 | { | 795 | { |
747 | ec_poll_stop(ec); | ||
748 | if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, | 796 | if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, |
749 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) | 797 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) |
750 | pr_err(PREFIX "failed to remove space handler\n"); | 798 | pr_err(PREFIX "failed to remove space handler\n"); |
751 | if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, | 799 | if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, |
752 | &acpi_ec_gpe_handler))) | 800 | &acpi_ec_gpe_handler))) |
753 | pr_err(PREFIX "failed to remove gpe handler\n"); | 801 | pr_err(PREFIX "failed to remove gpe handler\n"); |
754 | ec->handlers_installed = 0; | 802 | clear_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags); |
755 | } | 803 | } |
756 | 804 | ||
757 | static int acpi_ec_add(struct acpi_device *device) | 805 | static int acpi_ec_add(struct acpi_device *device) |
@@ -788,7 +836,7 @@ static int acpi_ec_add(struct acpi_device *device) | |||
788 | 836 | ||
789 | if (!first_ec) | 837 | if (!first_ec) |
790 | first_ec = ec; | 838 | first_ec = ec; |
791 | acpi_driver_data(device) = ec; | 839 | device->driver_data = ec; |
792 | acpi_ec_add_fs(device); | 840 | acpi_ec_add_fs(device); |
793 | pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", | 841 | pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", |
794 | ec->gpe, ec->command_addr, ec->data_addr); | 842 | ec->gpe, ec->command_addr, ec->data_addr); |
@@ -813,7 +861,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type) | |||
813 | } | 861 | } |
814 | mutex_unlock(&ec->lock); | 862 | mutex_unlock(&ec->lock); |
815 | acpi_ec_remove_fs(device); | 863 | acpi_ec_remove_fs(device); |
816 | acpi_driver_data(device) = NULL; | 864 | device->driver_data = NULL; |
817 | if (ec == first_ec) | 865 | if (ec == first_ec) |
818 | first_ec = NULL; | 866 | first_ec = NULL; |
819 | kfree(ec); | 867 | kfree(ec); |
@@ -846,27 +894,36 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context) | |||
846 | static int ec_install_handlers(struct acpi_ec *ec) | 894 | static int ec_install_handlers(struct acpi_ec *ec) |
847 | { | 895 | { |
848 | acpi_status status; | 896 | acpi_status status; |
849 | if (ec->handlers_installed) | 897 | if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags)) |
850 | return 0; | 898 | return 0; |
851 | status = acpi_install_gpe_handler(NULL, ec->gpe, | 899 | status = acpi_install_gpe_handler(NULL, ec->gpe, |
852 | ACPI_GPE_EDGE_TRIGGERED, | 900 | ACPI_GPE_EDGE_TRIGGERED, |
853 | &acpi_ec_gpe_handler, ec); | 901 | &acpi_ec_gpe_handler, ec); |
854 | if (ACPI_FAILURE(status)) | 902 | if (ACPI_FAILURE(status)) |
855 | return -ENODEV; | 903 | return -ENODEV; |
856 | |||
857 | acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); | 904 | acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); |
858 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 905 | acpi_enable_gpe(NULL, ec->gpe); |
859 | |||
860 | status = acpi_install_address_space_handler(ec->handle, | 906 | status = acpi_install_address_space_handler(ec->handle, |
861 | ACPI_ADR_SPACE_EC, | 907 | ACPI_ADR_SPACE_EC, |
862 | &acpi_ec_space_handler, | 908 | &acpi_ec_space_handler, |
863 | NULL, ec); | 909 | NULL, ec); |
864 | if (ACPI_FAILURE(status)) { | 910 | if (ACPI_FAILURE(status)) { |
865 | acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler); | 911 | if (status == AE_NOT_FOUND) { |
866 | return -ENODEV; | 912 | /* |
913 | * Maybe OS fails in evaluating the _REG object. | ||
914 | * The AE_NOT_FOUND error will be ignored and OS | ||
915 | * continue to initialize EC. | ||
916 | */ | ||
917 | printk(KERN_ERR "Fail in evaluating the _REG object" | ||
918 | " of EC device. Broken bios is suspected.\n"); | ||
919 | } else { | ||
920 | acpi_remove_gpe_handler(NULL, ec->gpe, | ||
921 | &acpi_ec_gpe_handler); | ||
922 | return -ENODEV; | ||
923 | } | ||
867 | } | 924 | } |
868 | 925 | ||
869 | ec->handlers_installed = 1; | 926 | set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags); |
870 | return 0; | 927 | return 0; |
871 | } | 928 | } |
872 | 929 | ||
@@ -887,7 +944,6 @@ static int acpi_ec_start(struct acpi_device *device) | |||
887 | 944 | ||
888 | /* EC is fully operational, allow queries */ | 945 | /* EC is fully operational, allow queries */ |
889 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); | 946 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
890 | ec_schedule_ec_poll(ec); | ||
891 | return ret; | 947 | return ret; |
892 | } | 948 | } |
893 | 949 | ||
@@ -906,7 +962,7 @@ static int acpi_ec_stop(struct acpi_device *device, int type) | |||
906 | 962 | ||
907 | int __init acpi_boot_ec_enable(void) | 963 | int __init acpi_boot_ec_enable(void) |
908 | { | 964 | { |
909 | if (!boot_ec || boot_ec->handlers_installed) | 965 | if (!boot_ec || test_bit(EC_FLAGS_HANDLERS_INSTALLED, &boot_ec->flags)) |
910 | return 0; | 966 | return 0; |
911 | if (!ec_install_handlers(boot_ec)) { | 967 | if (!ec_install_handlers(boot_ec)) { |
912 | first_ec = boot_ec; | 968 | first_ec = boot_ec; |
@@ -985,7 +1041,7 @@ static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state) | |||
985 | /* Stop using GPE */ | 1041 | /* Stop using GPE */ |
986 | set_bit(EC_FLAGS_NO_GPE, &ec->flags); | 1042 | set_bit(EC_FLAGS_NO_GPE, &ec->flags); |
987 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); | 1043 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
988 | acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 1044 | acpi_disable_gpe(NULL, ec->gpe); |
989 | return 0; | 1045 | return 0; |
990 | } | 1046 | } |
991 | 1047 | ||
@@ -994,7 +1050,7 @@ static int acpi_ec_resume(struct acpi_device *device) | |||
994 | struct acpi_ec *ec = acpi_driver_data(device); | 1050 | struct acpi_ec *ec = acpi_driver_data(device); |
995 | /* Enable use of GPE back */ | 1051 | /* Enable use of GPE back */ |
996 | clear_bit(EC_FLAGS_NO_GPE, &ec->flags); | 1052 | clear_bit(EC_FLAGS_NO_GPE, &ec->flags); |
997 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 1053 | acpi_enable_gpe(NULL, ec->gpe); |
998 | return 0; | 1054 | return 0; |
999 | } | 1055 | } |
1000 | 1056 | ||
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index c5e53aae86f7..f45c74fe745e 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c | |||
@@ -289,8 +289,6 @@ acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
289 | */ | 289 | */ |
290 | status = acpi_hw_low_disable_gpe(gpe_event_info); | 290 | status = acpi_hw_low_disable_gpe(gpe_event_info); |
291 | return_ACPI_STATUS(status); | 291 | return_ACPI_STATUS(status); |
292 | |||
293 | return_ACPI_STATUS(AE_OK); | ||
294 | } | 292 | } |
295 | 293 | ||
296 | /******************************************************************************* | 294 | /******************************************************************************* |
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index 73bfd6bf962f..41554f736b68 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c | |||
@@ -248,21 +248,15 @@ ACPI_EXPORT_SYMBOL(acpi_set_gpe_type) | |||
248 | * DESCRIPTION: Enable an ACPI event (general purpose) | 248 | * DESCRIPTION: Enable an ACPI event (general purpose) |
249 | * | 249 | * |
250 | ******************************************************************************/ | 250 | ******************************************************************************/ |
251 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | 251 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) |
252 | { | 252 | { |
253 | acpi_status status = AE_OK; | 253 | acpi_status status = AE_OK; |
254 | acpi_cpu_flags flags; | ||
254 | struct acpi_gpe_event_info *gpe_event_info; | 255 | struct acpi_gpe_event_info *gpe_event_info; |
255 | 256 | ||
256 | ACPI_FUNCTION_TRACE(acpi_enable_gpe); | 257 | ACPI_FUNCTION_TRACE(acpi_enable_gpe); |
257 | 258 | ||
258 | /* Use semaphore lock if not executing at interrupt level */ | 259 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
259 | |||
260 | if (flags & ACPI_NOT_ISR) { | ||
261 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
262 | if (ACPI_FAILURE(status)) { | ||
263 | return_ACPI_STATUS(status); | ||
264 | } | ||
265 | } | ||
266 | 260 | ||
267 | /* Ensure that we have a valid GPE number */ | 261 | /* Ensure that we have a valid GPE number */ |
268 | 262 | ||
@@ -277,9 +271,7 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | |||
277 | status = acpi_ev_enable_gpe(gpe_event_info, TRUE); | 271 | status = acpi_ev_enable_gpe(gpe_event_info, TRUE); |
278 | 272 | ||
279 | unlock_and_exit: | 273 | unlock_and_exit: |
280 | if (flags & ACPI_NOT_ISR) { | 274 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
281 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
282 | } | ||
283 | return_ACPI_STATUS(status); | 275 | return_ACPI_STATUS(status); |
284 | } | 276 | } |
285 | 277 | ||
@@ -299,22 +291,15 @@ ACPI_EXPORT_SYMBOL(acpi_enable_gpe) | |||
299 | * DESCRIPTION: Disable an ACPI event (general purpose) | 291 | * DESCRIPTION: Disable an ACPI event (general purpose) |
300 | * | 292 | * |
301 | ******************************************************************************/ | 293 | ******************************************************************************/ |
302 | acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | 294 | acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number) |
303 | { | 295 | { |
304 | acpi_status status = AE_OK; | 296 | acpi_status status = AE_OK; |
297 | acpi_cpu_flags flags; | ||
305 | struct acpi_gpe_event_info *gpe_event_info; | 298 | struct acpi_gpe_event_info *gpe_event_info; |
306 | 299 | ||
307 | ACPI_FUNCTION_TRACE(acpi_disable_gpe); | 300 | ACPI_FUNCTION_TRACE(acpi_disable_gpe); |
308 | 301 | ||
309 | /* Use semaphore lock if not executing at interrupt level */ | 302 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
310 | |||
311 | if (flags & ACPI_NOT_ISR) { | ||
312 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
313 | if (ACPI_FAILURE(status)) { | ||
314 | return_ACPI_STATUS(status); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | /* Ensure that we have a valid GPE number */ | 303 | /* Ensure that we have a valid GPE number */ |
319 | 304 | ||
320 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 305 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); |
@@ -325,10 +310,8 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | |||
325 | 310 | ||
326 | status = acpi_ev_disable_gpe(gpe_event_info); | 311 | status = acpi_ev_disable_gpe(gpe_event_info); |
327 | 312 | ||
328 | unlock_and_exit: | 313 | unlock_and_exit: |
329 | if (flags & ACPI_NOT_ISR) { | 314 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
330 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
331 | } | ||
332 | return_ACPI_STATUS(status); | 315 | return_ACPI_STATUS(status); |
333 | } | 316 | } |
334 | 317 | ||
@@ -521,6 +504,9 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) | |||
521 | if (value) | 504 | if (value) |
522 | *event_status |= ACPI_EVENT_FLAG_SET; | 505 | *event_status |= ACPI_EVENT_FLAG_SET; |
523 | 506 | ||
507 | if (acpi_gbl_fixed_event_handlers[event].handler) | ||
508 | *event_status |= ACPI_EVENT_FLAG_HANDLE; | ||
509 | |||
524 | return_ACPI_STATUS(status); | 510 | return_ACPI_STATUS(status); |
525 | } | 511 | } |
526 | 512 | ||
@@ -571,6 +557,9 @@ acpi_get_gpe_status(acpi_handle gpe_device, | |||
571 | 557 | ||
572 | status = acpi_hw_get_gpe_status(gpe_event_info, event_status); | 558 | status = acpi_hw_get_gpe_status(gpe_event_info, event_status); |
573 | 559 | ||
560 | if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) | ||
561 | *event_status |= ACPI_EVENT_FLAG_HANDLE; | ||
562 | |||
574 | unlock_and_exit: | 563 | unlock_and_exit: |
575 | if (flags & ACPI_NOT_ISR) { | 564 | if (flags & ACPI_NOT_ISR) { |
576 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 565 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index 8892b9824fae..74da6fa52ef1 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/acinterp.h> | 45 | #include <acpi/acinterp.h> |
46 | #include <acpi/amlcode.h> | ||
47 | #include <acpi/acnamesp.h> | 46 | #include <acpi/acnamesp.h> |
48 | #include <acpi/actables.h> | 47 | #include <acpi/actables.h> |
49 | #include <acpi/acdispat.h> | 48 | #include <acpi/acdispat.h> |
@@ -91,13 +90,12 @@ acpi_ex_add_table(u32 table_index, | |||
91 | 90 | ||
92 | /* Init the table handle */ | 91 | /* Init the table handle */ |
93 | 92 | ||
94 | obj_desc->reference.opcode = AML_LOAD_OP; | 93 | obj_desc->reference.class = ACPI_REFCLASS_TABLE; |
95 | *ddb_handle = obj_desc; | 94 | *ddb_handle = obj_desc; |
96 | 95 | ||
97 | /* Install the new table into the local data structures */ | 96 | /* Install the new table into the local data structures */ |
98 | 97 | ||
99 | obj_desc->reference.object = ACPI_CAST_PTR(void, | 98 | obj_desc->reference.value = table_index; |
100 | (unsigned long)table_index); | ||
101 | 99 | ||
102 | /* Add the table to the namespace */ | 100 | /* Add the table to the namespace */ |
103 | 101 | ||
@@ -280,6 +278,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, | |||
280 | struct acpi_walk_state *walk_state) | 278 | struct acpi_walk_state *walk_state) |
281 | { | 279 | { |
282 | union acpi_operand_object *ddb_handle; | 280 | union acpi_operand_object *ddb_handle; |
281 | struct acpi_table_header *table; | ||
283 | struct acpi_table_desc table_desc; | 282 | struct acpi_table_desc table_desc; |
284 | u32 table_index; | 283 | u32 table_index; |
285 | acpi_status status; | 284 | acpi_status status; |
@@ -294,9 +293,8 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, | |||
294 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { | 293 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
295 | case ACPI_TYPE_REGION: | 294 | case ACPI_TYPE_REGION: |
296 | 295 | ||
297 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Region %p %s\n", | 296 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
298 | obj_desc, | 297 | "Load table from Region %p\n", obj_desc)); |
299 | acpi_ut_get_object_type_name(obj_desc))); | ||
300 | 298 | ||
301 | /* Region must be system_memory (from ACPI spec) */ | 299 | /* Region must be system_memory (from ACPI spec) */ |
302 | 300 | ||
@@ -316,61 +314,112 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, | |||
316 | } | 314 | } |
317 | 315 | ||
318 | /* | 316 | /* |
319 | * We will simply map the memory region for the table. However, the | 317 | * Map the table header and get the actual table length. The region |
320 | * memory region is technically not guaranteed to remain stable and | 318 | * length is not guaranteed to be the same as the table length. |
321 | * we may eventually have to copy the table to a local buffer. | 319 | */ |
320 | table = acpi_os_map_memory(obj_desc->region.address, | ||
321 | sizeof(struct acpi_table_header)); | ||
322 | if (!table) { | ||
323 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
324 | } | ||
325 | |||
326 | length = table->length; | ||
327 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | ||
328 | |||
329 | /* Must have at least an ACPI table header */ | ||
330 | |||
331 | if (length < sizeof(struct acpi_table_header)) { | ||
332 | return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); | ||
333 | } | ||
334 | |||
335 | /* | ||
336 | * The memory region is not guaranteed to remain stable and we must | ||
337 | * copy the table to a local buffer. For example, the memory region | ||
338 | * is corrupted after suspend on some machines. Dynamically loaded | ||
339 | * tables are usually small, so this overhead is minimal. | ||
322 | */ | 340 | */ |
341 | |||
342 | /* Allocate a buffer for the table */ | ||
343 | |||
344 | table_desc.pointer = ACPI_ALLOCATE(length); | ||
345 | if (!table_desc.pointer) { | ||
346 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
347 | } | ||
348 | |||
349 | /* Map the entire table and copy it */ | ||
350 | |||
351 | table = acpi_os_map_memory(obj_desc->region.address, length); | ||
352 | if (!table) { | ||
353 | ACPI_FREE(table_desc.pointer); | ||
354 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
355 | } | ||
356 | |||
357 | ACPI_MEMCPY(table_desc.pointer, table, length); | ||
358 | acpi_os_unmap_memory(table, length); | ||
359 | |||
323 | table_desc.address = obj_desc->region.address; | 360 | table_desc.address = obj_desc->region.address; |
324 | table_desc.length = obj_desc->region.length; | ||
325 | table_desc.flags = ACPI_TABLE_ORIGIN_MAPPED; | ||
326 | break; | 361 | break; |
327 | 362 | ||
328 | case ACPI_TYPE_BUFFER: /* Buffer or resolved region_field */ | 363 | case ACPI_TYPE_BUFFER: /* Buffer or resolved region_field */ |
329 | 364 | ||
330 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 365 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
331 | "Load from Buffer or Field %p %s\n", obj_desc, | 366 | "Load table from Buffer or Field %p\n", |
332 | acpi_ut_get_object_type_name(obj_desc))); | 367 | obj_desc)); |
333 | |||
334 | length = obj_desc->buffer.length; | ||
335 | 368 | ||
336 | /* Must have at least an ACPI table header */ | 369 | /* Must have at least an ACPI table header */ |
337 | 370 | ||
338 | if (length < sizeof(struct acpi_table_header)) { | 371 | if (obj_desc->buffer.length < sizeof(struct acpi_table_header)) { |
339 | return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); | 372 | return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); |
340 | } | 373 | } |
341 | 374 | ||
342 | /* Validate checksum here. It won't get validated in tb_add_table */ | 375 | /* Get the actual table length from the table header */ |
343 | 376 | ||
344 | status = | 377 | table = |
345 | acpi_tb_verify_checksum(ACPI_CAST_PTR | 378 | ACPI_CAST_PTR(struct acpi_table_header, |
346 | (struct acpi_table_header, | 379 | obj_desc->buffer.pointer); |
347 | obj_desc->buffer.pointer), length); | 380 | length = table->length; |
348 | if (ACPI_FAILURE(status)) { | 381 | |
349 | return_ACPI_STATUS(status); | 382 | /* Table cannot extend beyond the buffer */ |
383 | |||
384 | if (length > obj_desc->buffer.length) { | ||
385 | return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); | ||
386 | } | ||
387 | if (length < sizeof(struct acpi_table_header)) { | ||
388 | return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); | ||
350 | } | 389 | } |
351 | 390 | ||
352 | /* | 391 | /* |
353 | * We need to copy the buffer since the original buffer could be | 392 | * Copy the table from the buffer because the buffer could be modified |
354 | * changed or deleted in the future | 393 | * or even deleted in the future |
355 | */ | 394 | */ |
356 | table_desc.pointer = ACPI_ALLOCATE(length); | 395 | table_desc.pointer = ACPI_ALLOCATE(length); |
357 | if (!table_desc.pointer) { | 396 | if (!table_desc.pointer) { |
358 | return_ACPI_STATUS(AE_NO_MEMORY); | 397 | return_ACPI_STATUS(AE_NO_MEMORY); |
359 | } | 398 | } |
360 | 399 | ||
361 | ACPI_MEMCPY(table_desc.pointer, obj_desc->buffer.pointer, | 400 | ACPI_MEMCPY(table_desc.pointer, table, length); |
362 | length); | 401 | table_desc.address = ACPI_TO_INTEGER(table_desc.pointer); |
363 | table_desc.length = length; | ||
364 | table_desc.flags = ACPI_TABLE_ORIGIN_ALLOCATED; | ||
365 | break; | 402 | break; |
366 | 403 | ||
367 | default: | 404 | default: |
368 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 405 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
369 | } | 406 | } |
370 | 407 | ||
371 | /* | 408 | /* Validate table checksum (will not get validated in tb_add_table) */ |
372 | * Install the new table into the local data structures | 409 | |
373 | */ | 410 | status = acpi_tb_verify_checksum(table_desc.pointer, length); |
411 | if (ACPI_FAILURE(status)) { | ||
412 | ACPI_FREE(table_desc.pointer); | ||
413 | return_ACPI_STATUS(status); | ||
414 | } | ||
415 | |||
416 | /* Complete the table descriptor */ | ||
417 | |||
418 | table_desc.length = length; | ||
419 | table_desc.flags = ACPI_TABLE_ORIGIN_ALLOCATED; | ||
420 | |||
421 | /* Install the new table into the local data structures */ | ||
422 | |||
374 | status = acpi_tb_add_table(&table_desc, &table_index); | 423 | status = acpi_tb_add_table(&table_desc, &table_index); |
375 | if (ACPI_FAILURE(status)) { | 424 | if (ACPI_FAILURE(status)) { |
376 | goto cleanup; | 425 | goto cleanup; |
@@ -379,7 +428,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, | |||
379 | /* | 428 | /* |
380 | * Add the table to the namespace. | 429 | * Add the table to the namespace. |
381 | * | 430 | * |
382 | * Note: We load the table objects relative to the root of the namespace. | 431 | * Note: Load the table objects relative to the root of the namespace. |
383 | * This appears to go against the ACPI specification, but we do it for | 432 | * This appears to go against the ACPI specification, but we do it for |
384 | * compatibility with other ACPI implementations. | 433 | * compatibility with other ACPI implementations. |
385 | */ | 434 | */ |
@@ -415,7 +464,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, | |||
415 | cleanup: | 464 | cleanup: |
416 | if (ACPI_FAILURE(status)) { | 465 | if (ACPI_FAILURE(status)) { |
417 | 466 | ||
418 | /* Delete allocated buffer or mapping */ | 467 | /* Delete allocated table buffer */ |
419 | 468 | ||
420 | acpi_tb_delete_table(&table_desc); | 469 | acpi_tb_delete_table(&table_desc); |
421 | } | 470 | } |
@@ -455,9 +504,9 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle) | |||
455 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 504 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
456 | } | 505 | } |
457 | 506 | ||
458 | /* Get the table index from the ddb_handle (acpi_size for 64-bit case) */ | 507 | /* Get the table index from the ddb_handle */ |
459 | 508 | ||
460 | table_index = (u32) (acpi_size) table_desc->reference.object; | 509 | table_index = table_desc->reference.value; |
461 | 510 | ||
462 | /* Invoke table handler if present */ | 511 | /* Invoke table handler if present */ |
463 | 512 | ||
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index 261d97516d9b..1d1f35adddde 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c | |||
@@ -57,7 +57,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer, | |||
57 | * | 57 | * |
58 | * FUNCTION: acpi_ex_convert_to_integer | 58 | * FUNCTION: acpi_ex_convert_to_integer |
59 | * | 59 | * |
60 | * PARAMETERS: obj_desc - Object to be converted. Must be an | 60 | * PARAMETERS: obj_desc - Object to be converted. Must be an |
61 | * Integer, Buffer, or String | 61 | * Integer, Buffer, or String |
62 | * result_desc - Where the new Integer object is returned | 62 | * result_desc - Where the new Integer object is returned |
63 | * Flags - Used for string conversion | 63 | * Flags - Used for string conversion |
@@ -103,7 +103,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, | |||
103 | } | 103 | } |
104 | 104 | ||
105 | /* | 105 | /* |
106 | * Convert the buffer/string to an integer. Note that both buffers and | 106 | * Convert the buffer/string to an integer. Note that both buffers and |
107 | * strings are treated as raw data - we don't convert ascii to hex for | 107 | * strings are treated as raw data - we don't convert ascii to hex for |
108 | * strings. | 108 | * strings. |
109 | * | 109 | * |
@@ -120,7 +120,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, | |||
120 | 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 |
124 | * of ACPI 3.0) is that the to_integer() operator allows both decimal | 124 | * of ACPI 3.0) is that the to_integer() operator allows both decimal |
125 | * and hexadecimal strings (hex prefixed with "0x"). | 125 | * and hexadecimal strings (hex prefixed with "0x"). |
126 | */ | 126 | */ |
@@ -159,6 +159,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, | |||
159 | break; | 159 | break; |
160 | 160 | ||
161 | default: | 161 | default: |
162 | |||
162 | /* No other types can get here */ | 163 | /* No other types can get here */ |
163 | break; | 164 | break; |
164 | } | 165 | } |
@@ -185,7 +186,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, | |||
185 | * | 186 | * |
186 | * FUNCTION: acpi_ex_convert_to_buffer | 187 | * FUNCTION: acpi_ex_convert_to_buffer |
187 | * | 188 | * |
188 | * PARAMETERS: obj_desc - Object to be converted. Must be an | 189 | * PARAMETERS: obj_desc - Object to be converted. Must be an |
189 | * Integer, Buffer, or String | 190 | * Integer, Buffer, or String |
190 | * result_desc - Where the new buffer object is returned | 191 | * result_desc - Where the new buffer object is returned |
191 | * | 192 | * |
@@ -365,7 +366,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer, | |||
365 | } | 366 | } |
366 | 367 | ||
367 | /* | 368 | /* |
368 | * Since leading zeros are supressed, we must check for the case where | 369 | * Since leading zeros are suppressed, we must check for the case where |
369 | * the integer equals 0 | 370 | * the integer equals 0 |
370 | * | 371 | * |
371 | * Finally, null terminate the string and return the length | 372 | * Finally, null terminate the string and return the length |
@@ -383,7 +384,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer, | |||
383 | * | 384 | * |
384 | * FUNCTION: acpi_ex_convert_to_string | 385 | * FUNCTION: acpi_ex_convert_to_string |
385 | * | 386 | * |
386 | * PARAMETERS: obj_desc - Object to be converted. Must be an | 387 | * PARAMETERS: obj_desc - Object to be converted. Must be an |
387 | * Integer, Buffer, or String | 388 | * Integer, Buffer, or String |
388 | * result_desc - Where the string object is returned | 389 | * result_desc - Where the string object is returned |
389 | * Type - String flags (base and conversion type) | 390 | * Type - String flags (base and conversion type) |
@@ -472,7 +473,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, | |||
472 | base = 10; | 473 | base = 10; |
473 | 474 | ||
474 | /* | 475 | /* |
475 | * Calculate the final string length. Individual string values | 476 | * Calculate the final string length. Individual string values |
476 | * are variable length (include separator for each) | 477 | * are variable length (include separator for each) |
477 | */ | 478 | */ |
478 | for (i = 0; i < obj_desc->buffer.length; i++) { | 479 | for (i = 0; i < obj_desc->buffer.length; i++) { |
@@ -511,9 +512,14 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, | |||
511 | /* | 512 | /* |
512 | * Create a new string object and string buffer | 513 | * Create a new string object and string buffer |
513 | * (-1 because of extra separator included in string_length from above) | 514 | * (-1 because of extra separator included in string_length from above) |
515 | * Allow creation of zero-length strings from zero-length buffers. | ||
514 | */ | 516 | */ |
517 | if (string_length) { | ||
518 | string_length--; | ||
519 | } | ||
520 | |||
515 | return_desc = acpi_ut_create_string_object((acpi_size) | 521 | return_desc = acpi_ut_create_string_object((acpi_size) |
516 | (string_length - 1)); | 522 | string_length); |
517 | if (!return_desc) { | 523 | if (!return_desc) { |
518 | return_ACPI_STATUS(AE_NO_MEMORY); | 524 | return_ACPI_STATUS(AE_NO_MEMORY); |
519 | } | 525 | } |
@@ -536,7 +542,9 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, | |||
536 | * Null terminate the string | 542 | * Null terminate the string |
537 | * (overwrites final comma/space from above) | 543 | * (overwrites final comma/space from above) |
538 | */ | 544 | */ |
539 | new_buf--; | 545 | if (obj_desc->buffer.length) { |
546 | new_buf--; | ||
547 | } | ||
540 | *new_buf = 0; | 548 | *new_buf = 0; |
541 | break; | 549 | break; |
542 | 550 | ||
@@ -617,7 +625,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, | |||
617 | case ACPI_TYPE_LOCAL_BANK_FIELD: | 625 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
618 | case ACPI_TYPE_LOCAL_INDEX_FIELD: | 626 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
619 | /* | 627 | /* |
620 | * These types require an Integer operand. We can convert | 628 | * These types require an Integer operand. We can convert |
621 | * a Buffer or a String to an Integer if necessary. | 629 | * a Buffer or a String to an Integer if necessary. |
622 | */ | 630 | */ |
623 | status = | 631 | status = |
@@ -627,7 +635,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, | |||
627 | 635 | ||
628 | case ACPI_TYPE_STRING: | 636 | case ACPI_TYPE_STRING: |
629 | /* | 637 | /* |
630 | * The operand must be a String. We can convert an | 638 | * The operand must be a String. We can convert an |
631 | * Integer or Buffer if necessary | 639 | * Integer or Buffer if necessary |
632 | */ | 640 | */ |
633 | status = | 641 | status = |
@@ -637,7 +645,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, | |||
637 | 645 | ||
638 | case ACPI_TYPE_BUFFER: | 646 | case ACPI_TYPE_BUFFER: |
639 | /* | 647 | /* |
640 | * The operand must be a Buffer. We can convert an | 648 | * The operand must be a Buffer. We can convert an |
641 | * Integer or String if necessary | 649 | * Integer or String if necessary |
642 | */ | 650 | */ |
643 | status = | 651 | status = |
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 2be2e2bf95bf..d087a7d28aa5 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <acpi/acinterp.h> | 45 | #include <acpi/acinterp.h> |
46 | #include <acpi/amlcode.h> | 46 | #include <acpi/amlcode.h> |
47 | #include <acpi/acnamesp.h> | 47 | #include <acpi/acnamesp.h> |
48 | #include <acpi/acparser.h> | ||
49 | 48 | ||
50 | #define _COMPONENT ACPI_EXECUTER | 49 | #define _COMPONENT ACPI_EXECUTER |
51 | ACPI_MODULE_NAME("exdump") | 50 | ACPI_MODULE_NAME("exdump") |
@@ -214,10 +213,11 @@ static struct acpi_exdump_info acpi_ex_dump_index_field[5] = { | |||
214 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"} | 213 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"} |
215 | }; | 214 | }; |
216 | 215 | ||
217 | static struct acpi_exdump_info acpi_ex_dump_reference[7] = { | 216 | static struct acpi_exdump_info acpi_ex_dump_reference[8] = { |
218 | {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL}, | 217 | {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL}, |
218 | {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.class), "Class"}, | ||
219 | {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"}, | 219 | {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"}, |
220 | {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.offset), "Offset"}, | 220 | {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.value), "Value"}, |
221 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"}, | 221 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"}, |
222 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"}, | 222 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"}, |
223 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"}, | 223 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"}, |
@@ -413,10 +413,10 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, | |||
413 | 413 | ||
414 | case ACPI_EXD_REFERENCE: | 414 | case ACPI_EXD_REFERENCE: |
415 | 415 | ||
416 | acpi_ex_out_string("Opcode", | 416 | acpi_ex_out_string("Class Name", |
417 | (acpi_ps_get_opcode_info | 417 | (char *) |
418 | (obj_desc->reference.opcode))-> | 418 | acpi_ut_get_reference_name |
419 | name); | 419 | (obj_desc)); |
420 | acpi_ex_dump_reference_obj(obj_desc); | 420 | acpi_ex_dump_reference_obj(obj_desc); |
421 | break; | 421 | break; |
422 | 422 | ||
@@ -494,40 +494,41 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) | |||
494 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { | 494 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
495 | case ACPI_TYPE_LOCAL_REFERENCE: | 495 | case ACPI_TYPE_LOCAL_REFERENCE: |
496 | 496 | ||
497 | switch (obj_desc->reference.opcode) { | 497 | acpi_os_printf("Reference: [%s] ", |
498 | case AML_DEBUG_OP: | 498 | acpi_ut_get_reference_name(obj_desc)); |
499 | |||
500 | switch (obj_desc->reference.class) { | ||
501 | case ACPI_REFCLASS_DEBUG: | ||
499 | 502 | ||
500 | acpi_os_printf("Reference: Debug\n"); | 503 | acpi_os_printf("\n"); |
501 | break; | 504 | break; |
502 | 505 | ||
503 | case AML_INDEX_OP: | 506 | case ACPI_REFCLASS_INDEX: |
504 | 507 | ||
505 | acpi_os_printf("Reference: Index %p\n", | 508 | acpi_os_printf("%p\n", obj_desc->reference.object); |
506 | obj_desc->reference.object); | ||
507 | break; | 509 | break; |
508 | 510 | ||
509 | case AML_LOAD_OP: | 511 | case ACPI_REFCLASS_TABLE: |
510 | 512 | ||
511 | acpi_os_printf("Reference: [DdbHandle] TableIndex %p\n", | 513 | acpi_os_printf("Table Index %X\n", |
512 | obj_desc->reference.object); | 514 | obj_desc->reference.value); |
513 | break; | 515 | break; |
514 | 516 | ||
515 | case AML_REF_OF_OP: | 517 | case ACPI_REFCLASS_REFOF: |
516 | 518 | ||
517 | acpi_os_printf("Reference: (RefOf) %p [%s]\n", | 519 | acpi_os_printf("%p [%s]\n", obj_desc->reference.object, |
518 | obj_desc->reference.object, | ||
519 | acpi_ut_get_type_name(((union | 520 | acpi_ut_get_type_name(((union |
520 | acpi_operand_object | 521 | acpi_operand_object |
521 | *)obj_desc-> | 522 | *) |
523 | obj_desc-> | ||
522 | reference. | 524 | reference. |
523 | object)->common. | 525 | object)->common. |
524 | type)); | 526 | type)); |
525 | break; | 527 | break; |
526 | 528 | ||
527 | case AML_ARG_OP: | 529 | case ACPI_REFCLASS_ARG: |
528 | 530 | ||
529 | acpi_os_printf("Reference: Arg%d", | 531 | acpi_os_printf("%X", obj_desc->reference.value); |
530 | obj_desc->reference.offset); | ||
531 | 532 | ||
532 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { | 533 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
533 | 534 | ||
@@ -542,10 +543,9 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) | |||
542 | acpi_os_printf("\n"); | 543 | acpi_os_printf("\n"); |
543 | break; | 544 | break; |
544 | 545 | ||
545 | case AML_LOCAL_OP: | 546 | case ACPI_REFCLASS_LOCAL: |
546 | 547 | ||
547 | acpi_os_printf("Reference: Local%d", | 548 | acpi_os_printf("%X", obj_desc->reference.value); |
548 | obj_desc->reference.offset); | ||
549 | 549 | ||
550 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { | 550 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
551 | 551 | ||
@@ -560,21 +560,16 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) | |||
560 | acpi_os_printf("\n"); | 560 | acpi_os_printf("\n"); |
561 | break; | 561 | break; |
562 | 562 | ||
563 | case AML_INT_NAMEPATH_OP: | 563 | case ACPI_REFCLASS_NAME: |
564 | 564 | ||
565 | acpi_os_printf("Reference: Namepath %X [%4.4s]\n", | 565 | acpi_os_printf("- [%4.4s]\n", |
566 | obj_desc->reference.node->name.integer, | ||
567 | obj_desc->reference.node->name.ascii); | 566 | obj_desc->reference.node->name.ascii); |
568 | break; | 567 | break; |
569 | 568 | ||
570 | default: | 569 | default: /* Unknown reference class */ |
571 | |||
572 | /* Unknown opcode */ | ||
573 | 570 | ||
574 | acpi_os_printf("Unknown Reference opcode=%X\n", | 571 | acpi_os_printf("%2.2X\n", obj_desc->reference.class); |
575 | obj_desc->reference.opcode); | ||
576 | break; | 572 | break; |
577 | |||
578 | } | 573 | } |
579 | break; | 574 | break; |
580 | 575 | ||
@@ -865,8 +860,8 @@ static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc) | |||
865 | 860 | ||
866 | ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; | 861 | ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; |
867 | 862 | ||
868 | if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { | 863 | if (obj_desc->reference.class == ACPI_REFCLASS_NAME) { |
869 | acpi_os_printf(" Named Object %p ", obj_desc->reference.node); | 864 | acpi_os_printf(" %p ", obj_desc->reference.node); |
870 | 865 | ||
871 | status = | 866 | status = |
872 | acpi_ns_handle_to_pathname(obj_desc->reference.node, | 867 | acpi_ns_handle_to_pathname(obj_desc->reference.node, |
@@ -882,14 +877,12 @@ static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc) | |||
882 | ACPI_DESC_TYPE_OPERAND) { | 877 | ACPI_DESC_TYPE_OPERAND) { |
883 | acpi_os_printf(" Target: %p", | 878 | acpi_os_printf(" Target: %p", |
884 | obj_desc->reference.object); | 879 | obj_desc->reference.object); |
885 | if (obj_desc->reference.opcode == AML_LOAD_OP) { | 880 | if (obj_desc->reference.class == ACPI_REFCLASS_TABLE) { |
886 | /* | 881 | acpi_os_printf(" Table Index: %X\n", |
887 | * For DDBHandle reference, | 882 | obj_desc->reference.value); |
888 | * obj_desc->Reference.Object is the table index | ||
889 | */ | ||
890 | acpi_os_printf(" [DDBHandle]\n"); | ||
891 | } else { | 883 | } else { |
892 | acpi_os_printf(" [%s]\n", | 884 | acpi_os_printf(" Target: %p [%s]\n", |
885 | obj_desc->reference.object, | ||
893 | acpi_ut_get_type_name(((union | 886 | acpi_ut_get_type_name(((union |
894 | acpi_operand_object | 887 | acpi_operand_object |
895 | *) | 888 | *) |
@@ -988,9 +981,9 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, | |||
988 | 981 | ||
989 | case ACPI_TYPE_LOCAL_REFERENCE: | 982 | case ACPI_TYPE_LOCAL_REFERENCE: |
990 | 983 | ||
991 | acpi_os_printf("[Object Reference] %s", | 984 | acpi_os_printf("[Object Reference] Type [%s] %2.2X", |
992 | (acpi_ps_get_opcode_info | 985 | acpi_ut_get_reference_name(obj_desc), |
993 | (obj_desc->reference.opcode))->name); | 986 | obj_desc->reference.class); |
994 | acpi_ex_dump_reference_obj(obj_desc); | 987 | acpi_ex_dump_reference_obj(obj_desc); |
995 | break; | 988 | break; |
996 | 989 | ||
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 731414a581a6..efb191340059 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c | |||
@@ -86,10 +86,10 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, | |||
86 | /* | 86 | /* |
87 | * Must be a reference to a Local or Arg | 87 | * Must be a reference to a Local or Arg |
88 | */ | 88 | */ |
89 | switch (obj_desc->reference.opcode) { | 89 | switch (obj_desc->reference.class) { |
90 | case AML_LOCAL_OP: | 90 | case ACPI_REFCLASS_LOCAL: |
91 | case AML_ARG_OP: | 91 | case ACPI_REFCLASS_ARG: |
92 | case AML_DEBUG_OP: | 92 | case ACPI_REFCLASS_DEBUG: |
93 | 93 | ||
94 | /* The referenced object is the pseudo-node for the local/arg */ | 94 | /* The referenced object is the pseudo-node for the local/arg */ |
95 | 95 | ||
@@ -98,8 +98,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, | |||
98 | 98 | ||
99 | default: | 99 | default: |
100 | 100 | ||
101 | ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X", | 101 | ACPI_ERROR((AE_INFO, "Unknown Reference Class %2.2X", |
102 | obj_desc->reference.opcode)); | 102 | obj_desc->reference.class)); |
103 | return_ACPI_STATUS(AE_AML_INTERNAL); | 103 | return_ACPI_STATUS(AE_AML_INTERNAL); |
104 | } | 104 | } |
105 | break; | 105 | break; |
@@ -127,7 +127,7 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, | |||
127 | return_ACPI_STATUS(AE_NO_MEMORY); | 127 | return_ACPI_STATUS(AE_NO_MEMORY); |
128 | } | 128 | } |
129 | 129 | ||
130 | reference_obj->reference.opcode = AML_REF_OF_OP; | 130 | reference_obj->reference.class = ACPI_REFCLASS_REFOF; |
131 | reference_obj->reference.object = referenced_obj; | 131 | reference_obj->reference.object = referenced_obj; |
132 | *return_desc = reference_obj; | 132 | *return_desc = reference_obj; |
133 | 133 | ||
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index 7c3bea575e02..f622f9eac8a1 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c | |||
@@ -825,16 +825,16 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
825 | * | 825 | * |
826 | * Must resolve/dereference the local/arg reference first | 826 | * Must resolve/dereference the local/arg reference first |
827 | */ | 827 | */ |
828 | switch (operand[0]->reference.opcode) { | 828 | switch (operand[0]->reference.class) { |
829 | case AML_LOCAL_OP: | 829 | case ACPI_REFCLASS_LOCAL: |
830 | case AML_ARG_OP: | 830 | case ACPI_REFCLASS_ARG: |
831 | 831 | ||
832 | /* Set Operand[0] to the value of the local/arg */ | 832 | /* Set Operand[0] to the value of the local/arg */ |
833 | 833 | ||
834 | status = | 834 | status = |
835 | acpi_ds_method_data_get_value | 835 | acpi_ds_method_data_get_value |
836 | (operand[0]->reference.opcode, | 836 | (operand[0]->reference.class, |
837 | operand[0]->reference.offset, | 837 | operand[0]->reference.value, |
838 | walk_state, &temp_desc); | 838 | walk_state, &temp_desc); |
839 | if (ACPI_FAILURE(status)) { | 839 | if (ACPI_FAILURE(status)) { |
840 | goto cleanup; | 840 | goto cleanup; |
@@ -848,7 +848,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
848 | operand[0] = temp_desc; | 848 | operand[0] = temp_desc; |
849 | break; | 849 | break; |
850 | 850 | ||
851 | case AML_REF_OF_OP: | 851 | case ACPI_REFCLASS_REFOF: |
852 | 852 | ||
853 | /* Get the object to which the reference refers */ | 853 | /* Get the object to which the reference refers */ |
854 | 854 | ||
@@ -928,8 +928,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
928 | * This must be a reference object produced by either the | 928 | * This must be a reference object produced by either the |
929 | * Index() or ref_of() operator | 929 | * Index() or ref_of() operator |
930 | */ | 930 | */ |
931 | switch (operand[0]->reference.opcode) { | 931 | switch (operand[0]->reference.class) { |
932 | case AML_INDEX_OP: | 932 | case ACPI_REFCLASS_INDEX: |
933 | 933 | ||
934 | /* | 934 | /* |
935 | * The target type for the Index operator must be | 935 | * The target type for the Index operator must be |
@@ -965,7 +965,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
965 | return_desc->integer.value = | 965 | return_desc->integer.value = |
966 | temp_desc->buffer. | 966 | temp_desc->buffer. |
967 | pointer[operand[0]->reference. | 967 | pointer[operand[0]->reference. |
968 | offset]; | 968 | value]; |
969 | break; | 969 | break; |
970 | 970 | ||
971 | case ACPI_TYPE_PACKAGE: | 971 | case ACPI_TYPE_PACKAGE: |
@@ -985,7 +985,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
985 | default: | 985 | default: |
986 | 986 | ||
987 | ACPI_ERROR((AE_INFO, | 987 | ACPI_ERROR((AE_INFO, |
988 | "Unknown Index TargetType %X in obj %p", | 988 | "Unknown Index TargetType %X in reference object %p", |
989 | operand[0]->reference. | 989 | operand[0]->reference. |
990 | target_type, operand[0])); | 990 | target_type, operand[0])); |
991 | status = AE_AML_OPERAND_TYPE; | 991 | status = AE_AML_OPERAND_TYPE; |
@@ -993,7 +993,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
993 | } | 993 | } |
994 | break; | 994 | break; |
995 | 995 | ||
996 | case AML_REF_OF_OP: | 996 | case ACPI_REFCLASS_REFOF: |
997 | 997 | ||
998 | return_desc = operand[0]->reference.object; | 998 | return_desc = operand[0]->reference.object; |
999 | 999 | ||
@@ -1013,9 +1013,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
1013 | 1013 | ||
1014 | default: | 1014 | default: |
1015 | ACPI_ERROR((AE_INFO, | 1015 | ACPI_ERROR((AE_INFO, |
1016 | "Unknown opcode in reference(%p) - %X", | 1016 | "Unknown class in reference(%p) - %2.2X", |
1017 | operand[0], | 1017 | operand[0], |
1018 | operand[0]->reference.opcode)); | 1018 | operand[0]->reference.class)); |
1019 | 1019 | ||
1020 | status = AE_TYPE; | 1020 | status = AE_TYPE; |
1021 | goto cleanup; | 1021 | goto cleanup; |
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c index 8e8bbb6ccebd..368def5dffce 100644 --- a/drivers/acpi/executer/exoparg2.c +++ b/drivers/acpi/executer/exoparg2.c | |||
@@ -391,8 +391,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
391 | /* Initialize the Index reference object */ | 391 | /* Initialize the Index reference object */ |
392 | 392 | ||
393 | index = operand[1]->integer.value; | 393 | index = operand[1]->integer.value; |
394 | return_desc->reference.offset = (u32) index; | 394 | return_desc->reference.value = (u32) index; |
395 | return_desc->reference.opcode = AML_INDEX_OP; | 395 | return_desc->reference.class = ACPI_REFCLASS_INDEX; |
396 | 396 | ||
397 | /* | 397 | /* |
398 | * At this point, the Source operand is a String, Buffer, or Package. | 398 | * At this point, the Source operand is a String, Buffer, or Package. |
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c index 5596f42c9676..423ad3635f3d 100644 --- a/drivers/acpi/executer/exresnte.c +++ b/drivers/acpi/executer/exresnte.c | |||
@@ -46,8 +46,6 @@ | |||
46 | #include <acpi/acdispat.h> | 46 | #include <acpi/acdispat.h> |
47 | #include <acpi/acinterp.h> | 47 | #include <acpi/acinterp.h> |
48 | #include <acpi/acnamesp.h> | 48 | #include <acpi/acnamesp.h> |
49 | #include <acpi/acparser.h> | ||
50 | #include <acpi/amlcode.h> | ||
51 | 49 | ||
52 | #define _COMPONENT ACPI_EXECUTER | 50 | #define _COMPONENT ACPI_EXECUTER |
53 | ACPI_MODULE_NAME("exresnte") | 51 | ACPI_MODULE_NAME("exresnte") |
@@ -238,10 +236,10 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, | |||
238 | 236 | ||
239 | case ACPI_TYPE_LOCAL_REFERENCE: | 237 | case ACPI_TYPE_LOCAL_REFERENCE: |
240 | 238 | ||
241 | switch (source_desc->reference.opcode) { | 239 | switch (source_desc->reference.class) { |
242 | case AML_LOAD_OP: /* This is a ddb_handle */ | 240 | case ACPI_REFCLASS_TABLE: /* This is a ddb_handle */ |
243 | case AML_REF_OF_OP: | 241 | case ACPI_REFCLASS_REFOF: |
244 | case AML_INDEX_OP: | 242 | case ACPI_REFCLASS_INDEX: |
245 | 243 | ||
246 | /* Return an additional reference to the object */ | 244 | /* Return an additional reference to the object */ |
247 | 245 | ||
@@ -253,10 +251,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, | |||
253 | /* No named references are allowed here */ | 251 | /* No named references are allowed here */ |
254 | 252 | ||
255 | ACPI_ERROR((AE_INFO, | 253 | ACPI_ERROR((AE_INFO, |
256 | "Unsupported Reference opcode %X (%s)", | 254 | "Unsupported Reference type %X", |
257 | source_desc->reference.opcode, | 255 | source_desc->reference.class)); |
258 | acpi_ps_get_opcode_name(source_desc-> | ||
259 | reference.opcode))); | ||
260 | 256 | ||
261 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 257 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
262 | } | 258 | } |
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c index b35f7c817acf..89571b92a522 100644 --- a/drivers/acpi/executer/exresolv.c +++ b/drivers/acpi/executer/exresolv.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #include <acpi/acdispat.h> | 47 | #include <acpi/acdispat.h> |
48 | #include <acpi/acinterp.h> | 48 | #include <acpi/acinterp.h> |
49 | #include <acpi/acnamesp.h> | 49 | #include <acpi/acnamesp.h> |
50 | #include <acpi/acparser.h> | ||
51 | 50 | ||
52 | #define _COMPONENT ACPI_EXECUTER | 51 | #define _COMPONENT ACPI_EXECUTER |
53 | ACPI_MODULE_NAME("exresolv") | 52 | ACPI_MODULE_NAME("exresolv") |
@@ -141,7 +140,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
141 | acpi_status status = AE_OK; | 140 | acpi_status status = AE_OK; |
142 | union acpi_operand_object *stack_desc; | 141 | union acpi_operand_object *stack_desc; |
143 | union acpi_operand_object *obj_desc = NULL; | 142 | union acpi_operand_object *obj_desc = NULL; |
144 | u16 opcode; | 143 | u8 ref_type; |
145 | 144 | ||
146 | ACPI_FUNCTION_TRACE(ex_resolve_object_to_value); | 145 | ACPI_FUNCTION_TRACE(ex_resolve_object_to_value); |
147 | 146 | ||
@@ -152,19 +151,19 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
152 | switch (ACPI_GET_OBJECT_TYPE(stack_desc)) { | 151 | switch (ACPI_GET_OBJECT_TYPE(stack_desc)) { |
153 | case ACPI_TYPE_LOCAL_REFERENCE: | 152 | case ACPI_TYPE_LOCAL_REFERENCE: |
154 | 153 | ||
155 | opcode = stack_desc->reference.opcode; | 154 | ref_type = stack_desc->reference.class; |
156 | 155 | ||
157 | switch (opcode) { | 156 | switch (ref_type) { |
158 | case AML_LOCAL_OP: | 157 | case ACPI_REFCLASS_LOCAL: |
159 | case AML_ARG_OP: | 158 | case ACPI_REFCLASS_ARG: |
160 | 159 | ||
161 | /* | 160 | /* |
162 | * Get the local from the method's state info | 161 | * Get the local from the method's state info |
163 | * Note: this increments the local's object reference count | 162 | * Note: this increments the local's object reference count |
164 | */ | 163 | */ |
165 | status = acpi_ds_method_data_get_value(opcode, | 164 | status = acpi_ds_method_data_get_value(ref_type, |
166 | stack_desc-> | 165 | stack_desc-> |
167 | reference.offset, | 166 | reference.value, |
168 | walk_state, | 167 | walk_state, |
169 | &obj_desc); | 168 | &obj_desc); |
170 | if (ACPI_FAILURE(status)) { | 169 | if (ACPI_FAILURE(status)) { |
@@ -173,7 +172,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
173 | 172 | ||
174 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 173 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
175 | "[Arg/Local %X] ValueObj is %p\n", | 174 | "[Arg/Local %X] ValueObj is %p\n", |
176 | stack_desc->reference.offset, | 175 | stack_desc->reference.value, |
177 | obj_desc)); | 176 | obj_desc)); |
178 | 177 | ||
179 | /* | 178 | /* |
@@ -184,7 +183,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
184 | *stack_ptr = obj_desc; | 183 | *stack_ptr = obj_desc; |
185 | break; | 184 | break; |
186 | 185 | ||
187 | case AML_INDEX_OP: | 186 | case ACPI_REFCLASS_INDEX: |
188 | 187 | ||
189 | switch (stack_desc->reference.target_type) { | 188 | switch (stack_desc->reference.target_type) { |
190 | case ACPI_TYPE_BUFFER_FIELD: | 189 | case ACPI_TYPE_BUFFER_FIELD: |
@@ -239,15 +238,15 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
239 | } | 238 | } |
240 | break; | 239 | break; |
241 | 240 | ||
242 | case AML_REF_OF_OP: | 241 | case ACPI_REFCLASS_REFOF: |
243 | case AML_DEBUG_OP: | 242 | case ACPI_REFCLASS_DEBUG: |
244 | case AML_LOAD_OP: | 243 | case ACPI_REFCLASS_TABLE: |
245 | 244 | ||
246 | /* Just leave the object as-is, do not dereference */ | 245 | /* Just leave the object as-is, do not dereference */ |
247 | 246 | ||
248 | break; | 247 | break; |
249 | 248 | ||
250 | case AML_INT_NAMEPATH_OP: /* Reference to a named object */ | 249 | case ACPI_REFCLASS_NAME: /* Reference to a named object */ |
251 | 250 | ||
252 | /* Dereference the name */ | 251 | /* Dereference the name */ |
253 | 252 | ||
@@ -273,8 +272,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
273 | default: | 272 | default: |
274 | 273 | ||
275 | ACPI_ERROR((AE_INFO, | 274 | ACPI_ERROR((AE_INFO, |
276 | "Unknown Reference opcode %X (%s) in %p", | 275 | "Unknown Reference type %X in %p", ref_type, |
277 | opcode, acpi_ps_get_opcode_name(opcode), | ||
278 | stack_desc)); | 276 | stack_desc)); |
279 | status = AE_AML_INTERNAL; | 277 | status = AE_AML_INTERNAL; |
280 | break; | 278 | break; |
@@ -388,13 +386,13 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, | |||
388 | * traversing the list of possibly many nested references. | 386 | * traversing the list of possibly many nested references. |
389 | */ | 387 | */ |
390 | while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { | 388 | while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { |
391 | switch (obj_desc->reference.opcode) { | 389 | switch (obj_desc->reference.class) { |
392 | case AML_REF_OF_OP: | 390 | case ACPI_REFCLASS_REFOF: |
393 | case AML_INT_NAMEPATH_OP: | 391 | case ACPI_REFCLASS_NAME: |
394 | 392 | ||
395 | /* Dereference the reference pointer */ | 393 | /* Dereference the reference pointer */ |
396 | 394 | ||
397 | if (obj_desc->reference.opcode == AML_REF_OF_OP) { | 395 | if (obj_desc->reference.class == ACPI_REFCLASS_REFOF) { |
398 | node = obj_desc->reference.object; | 396 | node = obj_desc->reference.object; |
399 | } else { /* AML_INT_NAMEPATH_OP */ | 397 | } else { /* AML_INT_NAMEPATH_OP */ |
400 | 398 | ||
@@ -429,7 +427,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, | |||
429 | } | 427 | } |
430 | break; | 428 | break; |
431 | 429 | ||
432 | case AML_INDEX_OP: | 430 | case ACPI_REFCLASS_INDEX: |
433 | 431 | ||
434 | /* Get the type of this reference (index into another object) */ | 432 | /* Get the type of this reference (index into another object) */ |
435 | 433 | ||
@@ -455,22 +453,22 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, | |||
455 | } | 453 | } |
456 | break; | 454 | break; |
457 | 455 | ||
458 | case AML_LOAD_OP: | 456 | case ACPI_REFCLASS_TABLE: |
459 | 457 | ||
460 | type = ACPI_TYPE_DDB_HANDLE; | 458 | type = ACPI_TYPE_DDB_HANDLE; |
461 | goto exit; | 459 | goto exit; |
462 | 460 | ||
463 | case AML_LOCAL_OP: | 461 | case ACPI_REFCLASS_LOCAL: |
464 | case AML_ARG_OP: | 462 | case ACPI_REFCLASS_ARG: |
465 | 463 | ||
466 | if (return_desc) { | 464 | if (return_desc) { |
467 | status = | 465 | status = |
468 | acpi_ds_method_data_get_value(obj_desc-> | 466 | acpi_ds_method_data_get_value(obj_desc-> |
469 | reference. | 467 | reference. |
470 | opcode, | 468 | class, |
471 | obj_desc-> | 469 | obj_desc-> |
472 | reference. | 470 | reference. |
473 | offset, | 471 | value, |
474 | walk_state, | 472 | walk_state, |
475 | &obj_desc); | 473 | &obj_desc); |
476 | if (ACPI_FAILURE(status)) { | 474 | if (ACPI_FAILURE(status)) { |
@@ -481,10 +479,10 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, | |||
481 | status = | 479 | status = |
482 | acpi_ds_method_data_get_node(obj_desc-> | 480 | acpi_ds_method_data_get_node(obj_desc-> |
483 | reference. | 481 | reference. |
484 | opcode, | 482 | class, |
485 | obj_desc-> | 483 | obj_desc-> |
486 | reference. | 484 | reference. |
487 | offset, | 485 | value, |
488 | walk_state, | 486 | walk_state, |
489 | &node); | 487 | &node); |
490 | if (ACPI_FAILURE(status)) { | 488 | if (ACPI_FAILURE(status)) { |
@@ -499,7 +497,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, | |||
499 | } | 497 | } |
500 | break; | 498 | break; |
501 | 499 | ||
502 | case AML_DEBUG_OP: | 500 | case ACPI_REFCLASS_DEBUG: |
503 | 501 | ||
504 | /* The Debug Object is of type "DebugObject" */ | 502 | /* The Debug Object is of type "DebugObject" */ |
505 | 503 | ||
@@ -509,8 +507,8 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, | |||
509 | default: | 507 | default: |
510 | 508 | ||
511 | ACPI_ERROR((AE_INFO, | 509 | ACPI_ERROR((AE_INFO, |
512 | "Unknown Reference subtype %X", | 510 | "Unknown Reference Class %2.2X", |
513 | obj_desc->reference.opcode)); | 511 | obj_desc->reference.class)); |
514 | return_ACPI_STATUS(AE_AML_INTERNAL); | 512 | return_ACPI_STATUS(AE_AML_INTERNAL); |
515 | } | 513 | } |
516 | } | 514 | } |
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index 54085f16ec28..0bb82593da72 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c | |||
@@ -225,41 +225,36 @@ acpi_ex_resolve_operands(u16 opcode, | |||
225 | 225 | ||
226 | if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { | 226 | if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { |
227 | 227 | ||
228 | /* Decode the Reference */ | 228 | /* Validate the Reference */ |
229 | 229 | ||
230 | op_info = acpi_ps_get_opcode_info(opcode); | 230 | switch (obj_desc->reference.class) { |
231 | if (op_info->class == AML_CLASS_UNKNOWN) { | 231 | case ACPI_REFCLASS_DEBUG: |
232 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); | ||
233 | } | ||
234 | 232 | ||
235 | switch (obj_desc->reference.opcode) { | ||
236 | case AML_DEBUG_OP: | ||
237 | target_op = AML_DEBUG_OP; | 233 | target_op = AML_DEBUG_OP; |
238 | 234 | ||
239 | /*lint -fallthrough */ | 235 | /*lint -fallthrough */ |
240 | 236 | ||
241 | case AML_INDEX_OP: | 237 | case ACPI_REFCLASS_ARG: |
242 | case AML_REF_OF_OP: | 238 | case ACPI_REFCLASS_LOCAL: |
243 | case AML_ARG_OP: | 239 | case ACPI_REFCLASS_INDEX: |
244 | case AML_LOCAL_OP: | 240 | case ACPI_REFCLASS_REFOF: |
245 | case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ | 241 | case ACPI_REFCLASS_TABLE: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ |
246 | case AML_INT_NAMEPATH_OP: /* Reference to a named object */ | 242 | case ACPI_REFCLASS_NAME: /* Reference to a named object */ |
247 | 243 | ||
248 | ACPI_DEBUG_ONLY_MEMBERS(ACPI_DEBUG_PRINT | 244 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
249 | ((ACPI_DB_EXEC, | 245 | "Operand is a Reference, Class [%s] %2.2X\n", |
250 | "Operand is a Reference, RefOpcode [%s]\n", | 246 | acpi_ut_get_reference_name |
251 | (acpi_ps_get_opcode_info | 247 | (obj_desc), |
252 | (obj_desc-> | 248 | obj_desc->reference. |
253 | reference. | 249 | class)); |
254 | opcode))-> | ||
255 | name))); | ||
256 | break; | 250 | break; |
257 | 251 | ||
258 | default: | 252 | default: |
253 | |||
259 | ACPI_ERROR((AE_INFO, | 254 | ACPI_ERROR((AE_INFO, |
260 | "Operand is a Reference, Unknown Reference Opcode: %X", | 255 | "Unknown Reference Class %2.2X in %p", |
261 | obj_desc->reference. | 256 | obj_desc->reference.class, |
262 | opcode)); | 257 | obj_desc)); |
263 | 258 | ||
264 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 259 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
265 | } | 260 | } |
@@ -270,8 +265,7 @@ acpi_ex_resolve_operands(u16 opcode, | |||
270 | 265 | ||
271 | /* Invalid descriptor */ | 266 | /* Invalid descriptor */ |
272 | 267 | ||
273 | ACPI_ERROR((AE_INFO, | 268 | ACPI_ERROR((AE_INFO, "Invalid descriptor %p [%s]", |
274 | "Invalid descriptor %p [%s]", | ||
275 | obj_desc, | 269 | obj_desc, |
276 | acpi_ut_get_descriptor_name(obj_desc))); | 270 | acpi_ut_get_descriptor_name(obj_desc))); |
277 | 271 | ||
@@ -343,7 +337,7 @@ acpi_ex_resolve_operands(u16 opcode, | |||
343 | if ((opcode == AML_STORE_OP) && | 337 | if ((opcode == AML_STORE_OP) && |
344 | (ACPI_GET_OBJECT_TYPE(*stack_ptr) == | 338 | (ACPI_GET_OBJECT_TYPE(*stack_ptr) == |
345 | ACPI_TYPE_LOCAL_REFERENCE) | 339 | ACPI_TYPE_LOCAL_REFERENCE) |
346 | && ((*stack_ptr)->reference.opcode == AML_INDEX_OP)) { | 340 | && ((*stack_ptr)->reference.class == ACPI_REFCLASS_INDEX)) { |
347 | goto next_operand; | 341 | goto next_operand; |
348 | } | 342 | } |
349 | break; | 343 | break; |
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c index 38b55e352495..3318df4cbd98 100644 --- a/drivers/acpi/executer/exstore.c +++ b/drivers/acpi/executer/exstore.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #include <acpi/acinterp.h> | 47 | #include <acpi/acinterp.h> |
48 | #include <acpi/amlcode.h> | 48 | #include <acpi/amlcode.h> |
49 | #include <acpi/acnamesp.h> | 49 | #include <acpi/acnamesp.h> |
50 | #include <acpi/acparser.h> | ||
51 | 50 | ||
52 | #define _COMPONENT ACPI_EXECUTER | 51 | #define _COMPONENT ACPI_EXECUTER |
53 | ACPI_MODULE_NAME("exstore") | 52 | ACPI_MODULE_NAME("exstore") |
@@ -179,22 +178,26 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | |||
179 | 178 | ||
180 | case ACPI_TYPE_LOCAL_REFERENCE: | 179 | case ACPI_TYPE_LOCAL_REFERENCE: |
181 | 180 | ||
182 | if (source_desc->reference.opcode == AML_INDEX_OP) { | 181 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s] ", |
183 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 182 | acpi_ut_get_reference_name(source_desc))); |
184 | "[%s, 0x%X]\n", | 183 | |
185 | acpi_ps_get_opcode_name | 184 | /* Decode the reference */ |
186 | (source_desc->reference.opcode), | 185 | |
187 | source_desc->reference.offset)); | 186 | switch (source_desc->reference.class) { |
188 | } else { | 187 | case ACPI_REFCLASS_INDEX: |
189 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s]", | 188 | |
190 | acpi_ps_get_opcode_name | 189 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%X\n", |
191 | (source_desc->reference.opcode))); | 190 | source_desc->reference.value)); |
192 | } | 191 | break; |
192 | |||
193 | case ACPI_REFCLASS_TABLE: | ||
193 | 194 | ||
194 | if (source_desc->reference.opcode == AML_LOAD_OP) { /* Load and load_table */ | ||
195 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 195 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, |
196 | " Table OwnerId %p\n", | 196 | "Table Index 0x%X\n", |
197 | source_desc->reference.object)); | 197 | source_desc->reference.value)); |
198 | break; | ||
199 | |||
200 | default: | ||
198 | break; | 201 | break; |
199 | } | 202 | } |
200 | 203 | ||
@@ -347,15 +350,15 @@ acpi_ex_store(union acpi_operand_object *source_desc, | |||
347 | } | 350 | } |
348 | 351 | ||
349 | /* | 352 | /* |
350 | * Examine the Reference opcode. These cases are handled: | 353 | * Examine the Reference class. These cases are handled: |
351 | * | 354 | * |
352 | * 1) Store to Name (Change the object associated with a name) | 355 | * 1) Store to Name (Change the object associated with a name) |
353 | * 2) Store to an indexed area of a Buffer or Package | 356 | * 2) Store to an indexed area of a Buffer or Package |
354 | * 3) Store to a Method Local or Arg | 357 | * 3) Store to a Method Local or Arg |
355 | * 4) Store to the debug object | 358 | * 4) Store to the debug object |
356 | */ | 359 | */ |
357 | switch (ref_desc->reference.opcode) { | 360 | switch (ref_desc->reference.class) { |
358 | case AML_REF_OF_OP: | 361 | case ACPI_REFCLASS_REFOF: |
359 | 362 | ||
360 | /* Storing an object into a Name "container" */ | 363 | /* Storing an object into a Name "container" */ |
361 | 364 | ||
@@ -365,7 +368,7 @@ acpi_ex_store(union acpi_operand_object *source_desc, | |||
365 | ACPI_IMPLICIT_CONVERSION); | 368 | ACPI_IMPLICIT_CONVERSION); |
366 | break; | 369 | break; |
367 | 370 | ||
368 | case AML_INDEX_OP: | 371 | case ACPI_REFCLASS_INDEX: |
369 | 372 | ||
370 | /* Storing to an Index (pointer into a packager or buffer) */ | 373 | /* Storing to an Index (pointer into a packager or buffer) */ |
371 | 374 | ||
@@ -374,18 +377,18 @@ acpi_ex_store(union acpi_operand_object *source_desc, | |||
374 | walk_state); | 377 | walk_state); |
375 | break; | 378 | break; |
376 | 379 | ||
377 | case AML_LOCAL_OP: | 380 | case ACPI_REFCLASS_LOCAL: |
378 | case AML_ARG_OP: | 381 | case ACPI_REFCLASS_ARG: |
379 | 382 | ||
380 | /* Store to a method local/arg */ | 383 | /* Store to a method local/arg */ |
381 | 384 | ||
382 | status = | 385 | status = |
383 | acpi_ds_store_object_to_local(ref_desc->reference.opcode, | 386 | acpi_ds_store_object_to_local(ref_desc->reference.class, |
384 | ref_desc->reference.offset, | 387 | ref_desc->reference.value, |
385 | source_desc, walk_state); | 388 | source_desc, walk_state); |
386 | break; | 389 | break; |
387 | 390 | ||
388 | case AML_DEBUG_OP: | 391 | case ACPI_REFCLASS_DEBUG: |
389 | 392 | ||
390 | /* | 393 | /* |
391 | * Storing to the Debug object causes the value stored to be | 394 | * Storing to the Debug object causes the value stored to be |
@@ -401,9 +404,9 @@ acpi_ex_store(union acpi_operand_object *source_desc, | |||
401 | 404 | ||
402 | default: | 405 | default: |
403 | 406 | ||
404 | ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X", | 407 | ACPI_ERROR((AE_INFO, "Unknown Reference Class %2.2X", |
405 | ref_desc->reference.opcode)); | 408 | ref_desc->reference.class)); |
406 | ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR); | 409 | ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_INFO); |
407 | 410 | ||
408 | status = AE_AML_INTERNAL; | 411 | status = AE_AML_INTERNAL; |
409 | break; | 412 | break; |
@@ -458,7 +461,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, | |||
458 | 461 | ||
459 | if (ACPI_GET_OBJECT_TYPE(source_desc) == | 462 | if (ACPI_GET_OBJECT_TYPE(source_desc) == |
460 | ACPI_TYPE_LOCAL_REFERENCE | 463 | ACPI_TYPE_LOCAL_REFERENCE |
461 | && source_desc->reference.opcode == AML_LOAD_OP) { | 464 | && source_desc->reference.class == ACPI_REFCLASS_TABLE) { |
462 | 465 | ||
463 | /* This is a DDBHandle, just add a reference to it */ | 466 | /* This is a DDBHandle, just add a reference to it */ |
464 | 467 | ||
@@ -553,7 +556,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, | |||
553 | 556 | ||
554 | /* Store the source value into the target buffer byte */ | 557 | /* Store the source value into the target buffer byte */ |
555 | 558 | ||
556 | obj_desc->buffer.pointer[index_desc->reference.offset] = value; | 559 | obj_desc->buffer.pointer[index_desc->reference.value] = value; |
557 | break; | 560 | break; |
558 | 561 | ||
559 | default: | 562 | default: |
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c index a6d2168b81f9..eef61a00803e 100644 --- a/drivers/acpi/executer/exstoren.c +++ b/drivers/acpi/executer/exstoren.c | |||
@@ -121,7 +121,8 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, | |||
121 | (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) && | 121 | (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) && |
122 | !((ACPI_GET_OBJECT_TYPE(source_desc) == | 122 | !((ACPI_GET_OBJECT_TYPE(source_desc) == |
123 | ACPI_TYPE_LOCAL_REFERENCE) | 123 | ACPI_TYPE_LOCAL_REFERENCE) |
124 | && (source_desc->reference.opcode == AML_LOAD_OP))) { | 124 | && (source_desc->reference.class == |
125 | ACPI_REFCLASS_TABLE))) { | ||
125 | 126 | ||
126 | /* Conversion successful but still not a valid type */ | 127 | /* Conversion successful but still not a valid type */ |
127 | 128 | ||
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 2655bc1b4eeb..eaaee1660bdf 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <acpi/acpi_bus.h> | 34 | #include <acpi/acpi_bus.h> |
35 | #include <acpi/acpi_drivers.h> | 35 | #include <acpi/acpi_drivers.h> |
36 | 36 | ||
37 | #define ACPI_FAN_COMPONENT 0x00200000 | ||
38 | #define ACPI_FAN_CLASS "fan" | 37 | #define ACPI_FAN_CLASS "fan" |
39 | #define ACPI_FAN_FILE_STATE "state" | 38 | #define ACPI_FAN_FILE_STATE "state" |
40 | 39 | ||
@@ -265,7 +264,7 @@ static int acpi_fan_add(struct acpi_device *device) | |||
265 | 264 | ||
266 | dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id); | 265 | dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id); |
267 | 266 | ||
268 | acpi_driver_data(device) = cdev; | 267 | device->driver_data = cdev; |
269 | result = sysfs_create_link(&device->dev.kobj, | 268 | result = sysfs_create_link(&device->dev.kobj, |
270 | &cdev->device.kobj, | 269 | &cdev->device.kobj, |
271 | "thermal_cooling"); | 270 | "thermal_cooling"); |
@@ -327,8 +326,8 @@ static int acpi_fan_resume(struct acpi_device *device) | |||
327 | 326 | ||
328 | result = acpi_bus_get_power(device->handle, &power_state); | 327 | result = acpi_bus_get_power(device->handle, &power_state); |
329 | if (result) { | 328 | if (result) { |
330 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 329 | printk(KERN_ERR PREFIX |
331 | "Error reading fan power state\n")); | 330 | "Error reading fan power state\n"); |
332 | return result; | 331 | return result; |
333 | } | 332 | } |
334 | 333 | ||
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 24649ada08df..adec3d15810a 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -140,6 +140,46 @@ struct device *acpi_get_physical_device(acpi_handle handle) | |||
140 | 140 | ||
141 | EXPORT_SYMBOL(acpi_get_physical_device); | 141 | EXPORT_SYMBOL(acpi_get_physical_device); |
142 | 142 | ||
143 | /* ToDo: When a PCI bridge is found, return the PCI device behind the bridge | ||
144 | * This should work in general, but did not on a Lenovo T61 for the | ||
145 | * graphics card. But this must be fixed when the PCI device is | ||
146 | * bound and the kernel device struct is attached to the acpi device | ||
147 | * Note: A success call will increase reference count by one | ||
148 | * Do call put_device(dev) on the returned device then | ||
149 | */ | ||
150 | struct device *acpi_get_physical_pci_device(acpi_handle handle) | ||
151 | { | ||
152 | struct device *dev; | ||
153 | long long device_id; | ||
154 | acpi_status status; | ||
155 | |||
156 | status = | ||
157 | acpi_evaluate_integer(handle, "_ADR", NULL, &device_id); | ||
158 | |||
159 | if (ACPI_FAILURE(status)) | ||
160 | return NULL; | ||
161 | |||
162 | /* We need to attempt to determine whether the _ADR refers to a | ||
163 | PCI device or not. There's no terribly good way to do this, | ||
164 | so the best we can hope for is to assume that there'll never | ||
165 | be a device in the host bridge */ | ||
166 | if (device_id >= 0x10000) { | ||
167 | /* It looks like a PCI device. Does it exist? */ | ||
168 | dev = acpi_get_physical_device(handle); | ||
169 | } else { | ||
170 | /* It doesn't look like a PCI device. Does its parent | ||
171 | exist? */ | ||
172 | acpi_handle phandle; | ||
173 | if (acpi_get_parent(handle, &phandle)) | ||
174 | return NULL; | ||
175 | dev = acpi_get_physical_device(phandle); | ||
176 | } | ||
177 | if (!dev) | ||
178 | return NULL; | ||
179 | return dev; | ||
180 | } | ||
181 | EXPORT_SYMBOL(acpi_get_physical_pci_device); | ||
182 | |||
143 | static int acpi_bind_one(struct device *dev, acpi_handle handle) | 183 | static int acpi_bind_one(struct device *dev, acpi_handle handle) |
144 | { | 184 | { |
145 | struct acpi_device *acpi_dev; | 185 | struct acpi_device *acpi_dev; |
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index dba3cfbe8cba..25dccdf179b9 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c | |||
@@ -78,19 +78,17 @@ acpi_set_firmware_waking_vector(acpi_physical_address physical_address) | |||
78 | return_ACPI_STATUS(status); | 78 | return_ACPI_STATUS(status); |
79 | } | 79 | } |
80 | 80 | ||
81 | /* Set the vector */ | 81 | /* |
82 | * According to the ACPI specification 2.0c and later, the 64-bit | ||
83 | * waking vector should be cleared and the 32-bit waking vector should | ||
84 | * be used, unless we want the wake-up code to be called by the BIOS in | ||
85 | * Protected Mode. Some systems (for example HP dv5-1004nr) are known | ||
86 | * to fail to resume if the 64-bit vector is used. | ||
87 | */ | ||
88 | if (facs->version >= 1) | ||
89 | facs->xfirmware_waking_vector = 0; | ||
82 | 90 | ||
83 | if ((facs->length < 32) || (!(facs->xfirmware_waking_vector))) { | 91 | facs->firmware_waking_vector = (u32)physical_address; |
84 | /* | ||
85 | * ACPI 1.0 FACS or short table or optional X_ field is zero | ||
86 | */ | ||
87 | facs->firmware_waking_vector = (u32) physical_address; | ||
88 | } else { | ||
89 | /* | ||
90 | * ACPI 2.0 FACS with valid X_ field | ||
91 | */ | ||
92 | facs->xfirmware_waking_vector = physical_address; | ||
93 | } | ||
94 | 92 | ||
95 | return_ACPI_STATUS(AE_OK); | 93 | return_ACPI_STATUS(AE_OK); |
96 | } | 94 | } |
@@ -134,20 +132,7 @@ acpi_get_firmware_waking_vector(acpi_physical_address * physical_address) | |||
134 | } | 132 | } |
135 | 133 | ||
136 | /* Get the vector */ | 134 | /* Get the vector */ |
137 | 135 | *physical_address = (acpi_physical_address)facs->firmware_waking_vector; | |
138 | if ((facs->length < 32) || (!(facs->xfirmware_waking_vector))) { | ||
139 | /* | ||
140 | * ACPI 1.0 FACS or short table or optional X_ field is zero | ||
141 | */ | ||
142 | *physical_address = | ||
143 | (acpi_physical_address) facs->firmware_waking_vector; | ||
144 | } else { | ||
145 | /* | ||
146 | * ACPI 2.0 FACS with valid X_ field | ||
147 | */ | ||
148 | *physical_address = | ||
149 | (acpi_physical_address) facs->xfirmware_waking_vector; | ||
150 | } | ||
151 | 136 | ||
152 | return_ACPI_STATUS(AE_OK); | 137 | return_ACPI_STATUS(AE_OK); |
153 | } | 138 | } |
@@ -627,6 +612,13 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state) | |||
627 | } | 612 | } |
628 | /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ | 613 | /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ |
629 | 614 | ||
615 | /* | ||
616 | * Some BIOSes assume that WAK_STS will be cleared on resume and use | ||
617 | * it to determine whether the system is rebooting or resuming. Clear | ||
618 | * it for compatibility. | ||
619 | */ | ||
620 | acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); | ||
621 | |||
630 | acpi_gbl_system_awake_and_running = TRUE; | 622 | acpi_gbl_system_awake_and_running = TRUE; |
631 | 623 | ||
632 | /* Enable power button */ | 624 | /* Enable power button */ |
diff --git a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile index 3f63d3640696..371a2daf837f 100644 --- a/drivers/acpi/namespace/Makefile +++ b/drivers/acpi/namespace/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \ | 5 | obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \ |
6 | nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \ | 6 | nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \ |
7 | nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \ | 7 | nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \ |
8 | nsparse.o | 8 | nsparse.o nspredef.o |
9 | 9 | ||
10 | obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o | 10 | obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o |
11 | 11 | ||
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index 0ab22004728a..cc0ae39440e4 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/acnamesp.h> | 45 | #include <acpi/acnamesp.h> |
46 | #include <acpi/acparser.h> | ||
47 | 46 | ||
48 | #define _COMPONENT ACPI_NAMESPACE | 47 | #define _COMPONENT ACPI_NAMESPACE |
49 | ACPI_MODULE_NAME("nsdump") | 48 | ACPI_MODULE_NAME("nsdump") |
@@ -334,9 +333,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, | |||
334 | case ACPI_TYPE_LOCAL_REFERENCE: | 333 | case ACPI_TYPE_LOCAL_REFERENCE: |
335 | 334 | ||
336 | acpi_os_printf("[%s]\n", | 335 | acpi_os_printf("[%s]\n", |
337 | acpi_ps_get_opcode_name(obj_desc-> | 336 | acpi_ut_get_reference_name(obj_desc)); |
338 | reference. | ||
339 | opcode)); | ||
340 | break; | 337 | break; |
341 | 338 | ||
342 | case ACPI_TYPE_BUFFER_FIELD: | 339 | case ACPI_TYPE_BUFFER_FIELD: |
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c index d369164e00b0..4cdf03ac2b46 100644 --- a/drivers/acpi/namespace/nseval.c +++ b/drivers/acpi/namespace/nseval.c | |||
@@ -78,6 +78,7 @@ ACPI_MODULE_NAME("nseval") | |||
78 | acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | 78 | acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) |
79 | { | 79 | { |
80 | acpi_status status; | 80 | acpi_status status; |
81 | struct acpi_namespace_node *node; | ||
81 | 82 | ||
82 | ACPI_FUNCTION_TRACE(ns_evaluate); | 83 | ACPI_FUNCTION_TRACE(ns_evaluate); |
83 | 84 | ||
@@ -117,6 +118,8 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | |||
117 | info->resolved_node, | 118 | info->resolved_node, |
118 | acpi_ns_get_attached_object(info->resolved_node))); | 119 | acpi_ns_get_attached_object(info->resolved_node))); |
119 | 120 | ||
121 | node = info->resolved_node; | ||
122 | |||
120 | /* | 123 | /* |
121 | * Two major cases here: | 124 | * Two major cases here: |
122 | * | 125 | * |
@@ -148,21 +151,22 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | |||
148 | info->param_count++; | 151 | info->param_count++; |
149 | } | 152 | } |
150 | 153 | ||
151 | /* Error if too few arguments were passed in */ | 154 | /* |
155 | * Warning if too few or too many arguments have been passed by the | ||
156 | * caller. We don't want to abort here with an error because an | ||
157 | * incorrect number of arguments may not cause the method to fail. | ||
158 | * However, the method will fail if there are too few arguments passed | ||
159 | * and the method attempts to use one of the missing ones. | ||
160 | */ | ||
152 | 161 | ||
153 | if (info->param_count < info->obj_desc->method.param_count) { | 162 | if (info->param_count < info->obj_desc->method.param_count) { |
154 | ACPI_ERROR((AE_INFO, | 163 | ACPI_WARNING((AE_INFO, |
155 | "Insufficient arguments - " | 164 | "Insufficient arguments - " |
156 | "method [%4.4s] needs %d, found %d", | 165 | "method [%4.4s] needs %d, found %d", |
157 | acpi_ut_get_node_name(info->resolved_node), | 166 | acpi_ut_get_node_name(info->resolved_node), |
158 | info->obj_desc->method.param_count, | 167 | info->obj_desc->method.param_count, |
159 | info->param_count)); | 168 | info->param_count)); |
160 | return_ACPI_STATUS(AE_MISSING_ARGUMENTS); | 169 | } else if (info->param_count > |
161 | } | ||
162 | |||
163 | /* Just a warning if too many arguments */ | ||
164 | |||
165 | else if (info->param_count > | ||
166 | info->obj_desc->method.param_count) { | 170 | info->obj_desc->method.param_count) { |
167 | ACPI_WARNING((AE_INFO, | 171 | ACPI_WARNING((AE_INFO, |
168 | "Excess arguments - " | 172 | "Excess arguments - " |
@@ -195,7 +199,28 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | |||
195 | } else { | 199 | } else { |
196 | /* | 200 | /* |
197 | * 2) Object is not a method, return its current value | 201 | * 2) Object is not a method, return its current value |
202 | * | ||
203 | * Disallow certain object types. For these, "evaluation" is undefined. | ||
198 | */ | 204 | */ |
205 | switch (info->resolved_node->type) { | ||
206 | case ACPI_TYPE_DEVICE: | ||
207 | case ACPI_TYPE_EVENT: | ||
208 | case ACPI_TYPE_MUTEX: | ||
209 | case ACPI_TYPE_REGION: | ||
210 | case ACPI_TYPE_THERMAL: | ||
211 | case ACPI_TYPE_LOCAL_SCOPE: | ||
212 | |||
213 | ACPI_ERROR((AE_INFO, | ||
214 | "[%4.4s] Evaluation of object type [%s] is not supported", | ||
215 | info->resolved_node->name.ascii, | ||
216 | acpi_ut_get_type_name(info->resolved_node-> | ||
217 | type))); | ||
218 | |||
219 | return_ACPI_STATUS(AE_TYPE); | ||
220 | |||
221 | default: | ||
222 | break; | ||
223 | } | ||
199 | 224 | ||
200 | /* | 225 | /* |
201 | * Objects require additional resolution steps (e.g., the Node may be | 226 | * Objects require additional resolution steps (e.g., the Node may be |
@@ -239,9 +264,35 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | |||
239 | } | 264 | } |
240 | } | 265 | } |
241 | 266 | ||
242 | /* | 267 | /* Validation of return values for ACPI-predefined methods and objects */ |
243 | * Check if there is a return value that must be dealt with | 268 | |
244 | */ | 269 | if ((status == AE_OK) || (status == AE_CTRL_RETURN_VALUE)) { |
270 | /* | ||
271 | * If this is the first evaluation, check the return value. This | ||
272 | * ensures that any warnings will only be emitted during the very | ||
273 | * first evaluation of the object. | ||
274 | */ | ||
275 | if (!(node->flags & ANOBJ_EVALUATED)) { | ||
276 | /* | ||
277 | * Check for a predefined ACPI name. If found, validate the | ||
278 | * returned object. | ||
279 | * | ||
280 | * Note: Ignore return status for now, emit warnings if there are | ||
281 | * problems with the returned object. May change later to abort | ||
282 | * the method on invalid return object. | ||
283 | */ | ||
284 | (void)acpi_ns_check_predefined_names(node, | ||
285 | info-> | ||
286 | return_object); | ||
287 | } | ||
288 | |||
289 | /* Mark the node as having been evaluated */ | ||
290 | |||
291 | node->flags |= ANOBJ_EVALUATED; | ||
292 | } | ||
293 | |||
294 | /* Check if there is a return value that must be dealt with */ | ||
295 | |||
245 | if (status == AE_CTRL_RETURN_VALUE) { | 296 | if (status == AE_CTRL_RETURN_VALUE) { |
246 | 297 | ||
247 | /* If caller does not want the return value, delete it */ | 298 | /* If caller does not want the return value, delete it */ |
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c index bd5773878009..42a39a7c96e9 100644 --- a/drivers/acpi/namespace/nsnames.c +++ b/drivers/acpi/namespace/nsnames.c | |||
@@ -115,7 +115,6 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node, | |||
115 | return (AE_OK); | 115 | return (AE_OK); |
116 | } | 116 | } |
117 | 117 | ||
118 | #ifdef ACPI_DEBUG_OUTPUT | ||
119 | /******************************************************************************* | 118 | /******************************************************************************* |
120 | * | 119 | * |
121 | * FUNCTION: acpi_ns_get_external_pathname | 120 | * FUNCTION: acpi_ns_get_external_pathname |
@@ -142,7 +141,7 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) | |||
142 | 141 | ||
143 | size = acpi_ns_get_pathname_length(node); | 142 | size = acpi_ns_get_pathname_length(node); |
144 | if (!size) { | 143 | if (!size) { |
145 | return (NULL); | 144 | return_PTR(NULL); |
146 | } | 145 | } |
147 | 146 | ||
148 | /* Allocate a buffer to be returned to caller */ | 147 | /* Allocate a buffer to be returned to caller */ |
@@ -157,12 +156,12 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) | |||
157 | 156 | ||
158 | status = acpi_ns_build_external_path(node, size, name_buffer); | 157 | status = acpi_ns_build_external_path(node, size, name_buffer); |
159 | if (ACPI_FAILURE(status)) { | 158 | if (ACPI_FAILURE(status)) { |
160 | return (NULL); | 159 | ACPI_FREE(name_buffer); |
160 | return_PTR(NULL); | ||
161 | } | 161 | } |
162 | 162 | ||
163 | return_PTR(name_buffer); | 163 | return_PTR(name_buffer); |
164 | } | 164 | } |
165 | #endif | ||
166 | 165 | ||
167 | /******************************************************************************* | 166 | /******************************************************************************* |
168 | * | 167 | * |
diff --git a/drivers/acpi/namespace/nspredef.c b/drivers/acpi/namespace/nspredef.c new file mode 100644 index 000000000000..0f17cf0898c9 --- /dev/null +++ b/drivers/acpi/namespace/nspredef.c | |||
@@ -0,0 +1,900 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: nspredef - Validation of ACPI predefined methods and objects | ||
4 | * $Revision: 1.1 $ | ||
5 | * | ||
6 | *****************************************************************************/ | ||
7 | |||
8 | /* | ||
9 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
10 | * All rights reserved. | ||
11 | * | ||
12 | * Redistribution and use in source and binary forms, with or without | ||
13 | * modification, are permitted provided that the following conditions | ||
14 | * are met: | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions, and the following disclaimer, | ||
17 | * without modification. | ||
18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
19 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
20 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
21 | * including a substantially similar Disclaimer requirement for further | ||
22 | * binary redistribution. | ||
23 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
24 | * of any contributors may be used to endorse or promote products derived | ||
25 | * from this software without specific prior written permission. | ||
26 | * | ||
27 | * Alternatively, this software may be distributed under the terms of the | ||
28 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
29 | * Software Foundation. | ||
30 | * | ||
31 | * NO WARRANTY | ||
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
42 | * POSSIBILITY OF SUCH DAMAGES. | ||
43 | */ | ||
44 | |||
45 | #include <acpi/acpi.h> | ||
46 | #include <acpi/acnamesp.h> | ||
47 | #include <acpi/acpredef.h> | ||
48 | |||
49 | #define _COMPONENT ACPI_NAMESPACE | ||
50 | ACPI_MODULE_NAME("nspredef") | ||
51 | |||
52 | /******************************************************************************* | ||
53 | * | ||
54 | * This module validates predefined ACPI objects that appear in the namespace, | ||
55 | * at the time they are evaluated (via acpi_evaluate_object). The purpose of this | ||
56 | * validation is to detect problems with BIOS-exposed predefined ACPI objects | ||
57 | * before the results are returned to the ACPI-related drivers. | ||
58 | * | ||
59 | * There are several areas that are validated: | ||
60 | * | ||
61 | * 1) The number of input arguments as defined by the method/object in the | ||
62 | * ASL is validated against the ACPI specification. | ||
63 | * 2) The type of the return object (if any) is validated against the ACPI | ||
64 | * specification. | ||
65 | * 3) For returned package objects, the count of package elements is | ||
66 | * validated, as well as the type of each package element. Nested | ||
67 | * packages are supported. | ||
68 | * | ||
69 | * For any problems found, a warning message is issued. | ||
70 | * | ||
71 | ******************************************************************************/ | ||
72 | /* Local prototypes */ | ||
73 | static acpi_status | ||
74 | acpi_ns_check_package(char *pathname, | ||
75 | union acpi_operand_object *return_object, | ||
76 | const union acpi_predefined_info *predefined); | ||
77 | |||
78 | static acpi_status | ||
79 | acpi_ns_check_package_elements(char *pathname, | ||
80 | union acpi_operand_object **elements, | ||
81 | u8 type1, u32 count1, u8 type2, u32 count2); | ||
82 | |||
83 | static acpi_status | ||
84 | acpi_ns_check_object_type(char *pathname, | ||
85 | union acpi_operand_object *return_object, | ||
86 | u32 expected_btypes, u32 package_index); | ||
87 | |||
88 | static acpi_status | ||
89 | acpi_ns_check_reference(char *pathname, | ||
90 | union acpi_operand_object *return_object); | ||
91 | |||
92 | /* | ||
93 | * Names for the types that can be returned by the predefined objects. | ||
94 | * Used for warning messages. Must be in the same order as the ACPI_RTYPEs | ||
95 | */ | ||
96 | static const char *acpi_rtype_names[] = { | ||
97 | "/Integer", | ||
98 | "/String", | ||
99 | "/Buffer", | ||
100 | "/Package", | ||
101 | "/Reference", | ||
102 | }; | ||
103 | |||
104 | #define ACPI_NOT_PACKAGE ACPI_UINT32_MAX | ||
105 | |||
106 | /******************************************************************************* | ||
107 | * | ||
108 | * FUNCTION: acpi_ns_check_predefined_names | ||
109 | * | ||
110 | * PARAMETERS: Node - Namespace node for the method/object | ||
111 | * return_object - Object returned from the evaluation of this | ||
112 | * method/object | ||
113 | * | ||
114 | * RETURN: Status | ||
115 | * | ||
116 | * DESCRIPTION: Check an ACPI name for a match in the predefined name list. | ||
117 | * | ||
118 | ******************************************************************************/ | ||
119 | |||
120 | acpi_status | ||
121 | acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | ||
122 | union acpi_operand_object *return_object) | ||
123 | { | ||
124 | acpi_status status = AE_OK; | ||
125 | const union acpi_predefined_info *predefined; | ||
126 | char *pathname; | ||
127 | |||
128 | /* Match the name for this method/object against the predefined list */ | ||
129 | |||
130 | predefined = acpi_ns_check_for_predefined_name(node); | ||
131 | if (!predefined) { | ||
132 | |||
133 | /* Name was not one of the predefined names */ | ||
134 | |||
135 | return (AE_OK); | ||
136 | } | ||
137 | |||
138 | /* Get the full pathname to the object, for use in error messages */ | ||
139 | |||
140 | pathname = acpi_ns_get_external_pathname(node); | ||
141 | if (!pathname) { | ||
142 | pathname = ACPI_CAST_PTR(char, predefined->info.name); | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | * Check that the parameter count for this method is in accordance | ||
147 | * with the ACPI specification. | ||
148 | */ | ||
149 | acpi_ns_check_parameter_count(pathname, node, predefined); | ||
150 | |||
151 | /* | ||
152 | * If there is no return value, check if we require a return value for | ||
153 | * this predefined name. Either one return value is expected, or none, | ||
154 | * for both methods and other objects. | ||
155 | * | ||
156 | * Exit now if there is no return object. Warning if one was expected. | ||
157 | */ | ||
158 | if (!return_object) { | ||
159 | if ((predefined->info.expected_btypes) && | ||
160 | (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) { | ||
161 | ACPI_ERROR((AE_INFO, | ||
162 | "%s: Missing expected return value", | ||
163 | pathname)); | ||
164 | |||
165 | status = AE_AML_NO_RETURN_VALUE; | ||
166 | } | ||
167 | goto exit; | ||
168 | } | ||
169 | |||
170 | /* | ||
171 | * We have a return value, but if one wasn't expected, just exit, this is | ||
172 | * not a problem | ||
173 | * | ||
174 | * For example, if "Implicit return value" is enabled, methods will | ||
175 | * always return a value | ||
176 | */ | ||
177 | if (!predefined->info.expected_btypes) { | ||
178 | goto exit; | ||
179 | } | ||
180 | |||
181 | /* | ||
182 | * Check that the type of the return object is what is expected for | ||
183 | * this predefined name | ||
184 | */ | ||
185 | status = acpi_ns_check_object_type(pathname, return_object, | ||
186 | predefined->info.expected_btypes, | ||
187 | ACPI_NOT_PACKAGE); | ||
188 | if (ACPI_FAILURE(status)) { | ||
189 | goto exit; | ||
190 | } | ||
191 | |||
192 | /* For returned Package objects, check the type of all sub-objects */ | ||
193 | |||
194 | if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) { | ||
195 | status = | ||
196 | acpi_ns_check_package(pathname, return_object, predefined); | ||
197 | } | ||
198 | |||
199 | exit: | ||
200 | if (pathname) { | ||
201 | ACPI_FREE(pathname); | ||
202 | } | ||
203 | |||
204 | return (status); | ||
205 | } | ||
206 | |||
207 | /******************************************************************************* | ||
208 | * | ||
209 | * FUNCTION: acpi_ns_check_parameter_count | ||
210 | * | ||
211 | * PARAMETERS: Pathname - Full pathname to the node (for error msgs) | ||
212 | * Node - Namespace node for the method/object | ||
213 | * Predefined - Pointer to entry in predefined name table | ||
214 | * | ||
215 | * RETURN: None | ||
216 | * | ||
217 | * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a | ||
218 | * predefined name is what is expected (i.e., what is defined in | ||
219 | * the ACPI specification for this predefined name.) | ||
220 | * | ||
221 | ******************************************************************************/ | ||
222 | |||
223 | void | ||
224 | acpi_ns_check_parameter_count(char *pathname, | ||
225 | struct acpi_namespace_node *node, | ||
226 | const union acpi_predefined_info *predefined) | ||
227 | { | ||
228 | u32 param_count; | ||
229 | u32 required_params_current; | ||
230 | u32 required_params_old; | ||
231 | |||
232 | /* | ||
233 | * Check that the ASL-defined parameter count is what is expected for | ||
234 | * this predefined name. | ||
235 | * | ||
236 | * Methods have 0-7 parameters. All other types have zero. | ||
237 | */ | ||
238 | param_count = 0; | ||
239 | if (node->type == ACPI_TYPE_METHOD) { | ||
240 | param_count = node->object->method.param_count; | ||
241 | } | ||
242 | |||
243 | /* Validate parameter count - allow two different legal counts (_SCP) */ | ||
244 | |||
245 | required_params_current = predefined->info.param_count & 0x0F; | ||
246 | required_params_old = predefined->info.param_count >> 4; | ||
247 | |||
248 | if ((param_count != required_params_current) && | ||
249 | (param_count != required_params_old)) { | ||
250 | ACPI_WARNING((AE_INFO, | ||
251 | "%s: Parameter count mismatch - ASL declared %d, expected %d", | ||
252 | pathname, param_count, required_params_current)); | ||
253 | } | ||
254 | } | ||
255 | |||
256 | /******************************************************************************* | ||
257 | * | ||
258 | * FUNCTION: acpi_ns_check_for_predefined_name | ||
259 | * | ||
260 | * PARAMETERS: Node - Namespace node for the method/object | ||
261 | * | ||
262 | * RETURN: Pointer to entry in predefined table. NULL indicates not found. | ||
263 | * | ||
264 | * DESCRIPTION: Check an object name against the predefined object list. | ||
265 | * | ||
266 | ******************************************************************************/ | ||
267 | |||
268 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct | ||
269 | acpi_namespace_node | ||
270 | *node) | ||
271 | { | ||
272 | const union acpi_predefined_info *this_name; | ||
273 | |||
274 | /* Quick check for a predefined name, first character must be underscore */ | ||
275 | |||
276 | if (node->name.ascii[0] != '_') { | ||
277 | return (NULL); | ||
278 | } | ||
279 | |||
280 | /* Search info table for a predefined method/object name */ | ||
281 | |||
282 | this_name = predefined_names; | ||
283 | while (this_name->info.name[0]) { | ||
284 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) { | ||
285 | |||
286 | /* Return pointer to this table entry */ | ||
287 | |||
288 | return (this_name); | ||
289 | } | ||
290 | |||
291 | /* | ||
292 | * Skip next entry in the table if this name returns a Package | ||
293 | * (next entry contains the package info) | ||
294 | */ | ||
295 | if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) { | ||
296 | this_name++; | ||
297 | } | ||
298 | |||
299 | this_name++; | ||
300 | } | ||
301 | |||
302 | return (NULL); | ||
303 | } | ||
304 | |||
305 | /******************************************************************************* | ||
306 | * | ||
307 | * FUNCTION: acpi_ns_check_package | ||
308 | * | ||
309 | * PARAMETERS: Pathname - Full pathname to the node (for error msgs) | ||
310 | * return_object - Object returned from the evaluation of a | ||
311 | * method or object | ||
312 | * Predefined - Pointer to entry in predefined name table | ||
313 | * | ||
314 | * RETURN: Status | ||
315 | * | ||
316 | * DESCRIPTION: Check a returned package object for the correct count and | ||
317 | * correct type of all sub-objects. | ||
318 | * | ||
319 | ******************************************************************************/ | ||
320 | |||
321 | static acpi_status | ||
322 | acpi_ns_check_package(char *pathname, | ||
323 | union acpi_operand_object *return_object, | ||
324 | const union acpi_predefined_info *predefined) | ||
325 | { | ||
326 | const union acpi_predefined_info *package; | ||
327 | union acpi_operand_object *sub_package; | ||
328 | union acpi_operand_object **elements; | ||
329 | union acpi_operand_object **sub_elements; | ||
330 | acpi_status status; | ||
331 | u32 expected_count; | ||
332 | u32 count; | ||
333 | u32 i; | ||
334 | u32 j; | ||
335 | |||
336 | ACPI_FUNCTION_NAME(ns_check_package); | ||
337 | |||
338 | /* The package info for this name is in the next table entry */ | ||
339 | |||
340 | package = predefined + 1; | ||
341 | |||
342 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, | ||
343 | "%s Validating return Package of Type %X, Count %X\n", | ||
344 | pathname, package->ret_info.type, | ||
345 | return_object->package.count)); | ||
346 | |||
347 | /* Extract package count and elements array */ | ||
348 | |||
349 | elements = return_object->package.elements; | ||
350 | count = return_object->package.count; | ||
351 | |||
352 | /* The package must have at least one element, else invalid */ | ||
353 | |||
354 | if (!count) { | ||
355 | ACPI_WARNING((AE_INFO, | ||
356 | "%s: Return Package has no elements (empty)", | ||
357 | pathname)); | ||
358 | |||
359 | return (AE_AML_OPERAND_VALUE); | ||
360 | } | ||
361 | |||
362 | /* | ||
363 | * Decode the type of the expected package contents | ||
364 | * | ||
365 | * PTYPE1 packages contain no subpackages | ||
366 | * PTYPE2 packages contain sub-packages | ||
367 | */ | ||
368 | switch (package->ret_info.type) { | ||
369 | case ACPI_PTYPE1_FIXED: | ||
370 | |||
371 | /* | ||
372 | * The package count is fixed and there are no sub-packages | ||
373 | * | ||
374 | * If package is too small, exit. | ||
375 | * If package is larger than expected, issue warning but continue | ||
376 | */ | ||
377 | expected_count = | ||
378 | package->ret_info.count1 + package->ret_info.count2; | ||
379 | if (count < expected_count) { | ||
380 | goto package_too_small; | ||
381 | } else if (count > expected_count) { | ||
382 | ACPI_WARNING((AE_INFO, | ||
383 | "%s: Return Package is larger than needed - " | ||
384 | "found %u, expected %u", pathname, count, | ||
385 | expected_count)); | ||
386 | } | ||
387 | |||
388 | /* Validate all elements of the returned package */ | ||
389 | |||
390 | status = acpi_ns_check_package_elements(pathname, elements, | ||
391 | package->ret_info. | ||
392 | object_type1, | ||
393 | package->ret_info. | ||
394 | count1, | ||
395 | package->ret_info. | ||
396 | object_type2, | ||
397 | package->ret_info. | ||
398 | count2); | ||
399 | if (ACPI_FAILURE(status)) { | ||
400 | return (status); | ||
401 | } | ||
402 | break; | ||
403 | |||
404 | case ACPI_PTYPE1_VAR: | ||
405 | |||
406 | /* | ||
407 | * The package count is variable, there are no sub-packages, and all | ||
408 | * elements must be of the same type | ||
409 | */ | ||
410 | for (i = 0; i < count; i++) { | ||
411 | status = acpi_ns_check_object_type(pathname, *elements, | ||
412 | package->ret_info. | ||
413 | object_type1, i); | ||
414 | if (ACPI_FAILURE(status)) { | ||
415 | return (status); | ||
416 | } | ||
417 | elements++; | ||
418 | } | ||
419 | break; | ||
420 | |||
421 | case ACPI_PTYPE1_OPTION: | ||
422 | |||
423 | /* | ||
424 | * The package count is variable, there are no sub-packages. There are | ||
425 | * a fixed number of required elements, and a variable number of | ||
426 | * optional elements. | ||
427 | * | ||
428 | * Check if package is at least as large as the minimum required | ||
429 | */ | ||
430 | expected_count = package->ret_info3.count; | ||
431 | if (count < expected_count) { | ||
432 | goto package_too_small; | ||
433 | } | ||
434 | |||
435 | /* Variable number of sub-objects */ | ||
436 | |||
437 | for (i = 0; i < count; i++) { | ||
438 | if (i < package->ret_info3.count) { | ||
439 | |||
440 | /* These are the required package elements (0, 1, or 2) */ | ||
441 | |||
442 | status = | ||
443 | acpi_ns_check_object_type(pathname, | ||
444 | *elements, | ||
445 | package-> | ||
446 | ret_info3. | ||
447 | object_type[i], | ||
448 | i); | ||
449 | if (ACPI_FAILURE(status)) { | ||
450 | return (status); | ||
451 | } | ||
452 | } else { | ||
453 | /* These are the optional package elements */ | ||
454 | |||
455 | status = | ||
456 | acpi_ns_check_object_type(pathname, | ||
457 | *elements, | ||
458 | package-> | ||
459 | ret_info3. | ||
460 | tail_object_type, | ||
461 | i); | ||
462 | if (ACPI_FAILURE(status)) { | ||
463 | return (status); | ||
464 | } | ||
465 | } | ||
466 | elements++; | ||
467 | } | ||
468 | break; | ||
469 | |||
470 | case ACPI_PTYPE2_PKG_COUNT: | ||
471 | |||
472 | /* First element is the (Integer) count of sub-packages to follow */ | ||
473 | |||
474 | status = acpi_ns_check_object_type(pathname, *elements, | ||
475 | ACPI_RTYPE_INTEGER, 0); | ||
476 | if (ACPI_FAILURE(status)) { | ||
477 | return (status); | ||
478 | } | ||
479 | |||
480 | /* | ||
481 | * Count cannot be larger than the parent package length, but allow it | ||
482 | * to be smaller. The >= accounts for the Integer above. | ||
483 | */ | ||
484 | expected_count = (u32) (*elements)->integer.value; | ||
485 | if (expected_count >= count) { | ||
486 | goto package_too_small; | ||
487 | } | ||
488 | |||
489 | count = expected_count; | ||
490 | elements++; | ||
491 | |||
492 | /* Now we can walk the sub-packages */ | ||
493 | |||
494 | /*lint -fallthrough */ | ||
495 | |||
496 | case ACPI_PTYPE2: | ||
497 | case ACPI_PTYPE2_FIXED: | ||
498 | case ACPI_PTYPE2_MIN: | ||
499 | case ACPI_PTYPE2_COUNT: | ||
500 | |||
501 | /* | ||
502 | * These types all return a single package that consists of a variable | ||
503 | * number of sub-packages | ||
504 | */ | ||
505 | for (i = 0; i < count; i++) { | ||
506 | sub_package = *elements; | ||
507 | sub_elements = sub_package->package.elements; | ||
508 | |||
509 | /* Each sub-object must be of type Package */ | ||
510 | |||
511 | status = | ||
512 | acpi_ns_check_object_type(pathname, sub_package, | ||
513 | ACPI_RTYPE_PACKAGE, i); | ||
514 | if (ACPI_FAILURE(status)) { | ||
515 | return (status); | ||
516 | } | ||
517 | |||
518 | /* Examine the different types of sub-packages */ | ||
519 | |||
520 | switch (package->ret_info.type) { | ||
521 | case ACPI_PTYPE2: | ||
522 | case ACPI_PTYPE2_PKG_COUNT: | ||
523 | |||
524 | /* Each subpackage has a fixed number of elements */ | ||
525 | |||
526 | expected_count = | ||
527 | package->ret_info.count1 + | ||
528 | package->ret_info.count2; | ||
529 | if (sub_package->package.count != | ||
530 | expected_count) { | ||
531 | count = sub_package->package.count; | ||
532 | goto package_too_small; | ||
533 | } | ||
534 | |||
535 | status = | ||
536 | acpi_ns_check_package_elements(pathname, | ||
537 | sub_elements, | ||
538 | package-> | ||
539 | ret_info. | ||
540 | object_type1, | ||
541 | package-> | ||
542 | ret_info. | ||
543 | count1, | ||
544 | package-> | ||
545 | ret_info. | ||
546 | object_type2, | ||
547 | package-> | ||
548 | ret_info. | ||
549 | count2); | ||
550 | if (ACPI_FAILURE(status)) { | ||
551 | return (status); | ||
552 | } | ||
553 | break; | ||
554 | |||
555 | case ACPI_PTYPE2_FIXED: | ||
556 | |||
557 | /* Each sub-package has a fixed length */ | ||
558 | |||
559 | expected_count = package->ret_info2.count; | ||
560 | if (sub_package->package.count < expected_count) { | ||
561 | count = sub_package->package.count; | ||
562 | goto package_too_small; | ||
563 | } | ||
564 | |||
565 | /* Check the type of each sub-package element */ | ||
566 | |||
567 | for (j = 0; j < expected_count; j++) { | ||
568 | status = | ||
569 | acpi_ns_check_object_type(pathname, | ||
570 | sub_elements | ||
571 | [j], | ||
572 | package-> | ||
573 | ret_info2. | ||
574 | object_type | ||
575 | [j], j); | ||
576 | if (ACPI_FAILURE(status)) { | ||
577 | return (status); | ||
578 | } | ||
579 | } | ||
580 | break; | ||
581 | |||
582 | case ACPI_PTYPE2_MIN: | ||
583 | |||
584 | /* Each sub-package has a variable but minimum length */ | ||
585 | |||
586 | expected_count = package->ret_info.count1; | ||
587 | if (sub_package->package.count < expected_count) { | ||
588 | count = sub_package->package.count; | ||
589 | goto package_too_small; | ||
590 | } | ||
591 | |||
592 | /* Check the type of each sub-package element */ | ||
593 | |||
594 | status = | ||
595 | acpi_ns_check_package_elements(pathname, | ||
596 | sub_elements, | ||
597 | package-> | ||
598 | ret_info. | ||
599 | object_type1, | ||
600 | sub_package-> | ||
601 | package. | ||
602 | count, 0, 0); | ||
603 | if (ACPI_FAILURE(status)) { | ||
604 | return (status); | ||
605 | } | ||
606 | break; | ||
607 | |||
608 | case ACPI_PTYPE2_COUNT: | ||
609 | |||
610 | /* First element is the (Integer) count of elements to follow */ | ||
611 | |||
612 | status = | ||
613 | acpi_ns_check_object_type(pathname, | ||
614 | *sub_elements, | ||
615 | ACPI_RTYPE_INTEGER, | ||
616 | 0); | ||
617 | if (ACPI_FAILURE(status)) { | ||
618 | return (status); | ||
619 | } | ||
620 | |||
621 | /* Make sure package is large enough for the Count */ | ||
622 | |||
623 | expected_count = | ||
624 | (u32) (*sub_elements)->integer.value; | ||
625 | if (sub_package->package.count < expected_count) { | ||
626 | count = sub_package->package.count; | ||
627 | goto package_too_small; | ||
628 | } | ||
629 | |||
630 | /* Check the type of each sub-package element */ | ||
631 | |||
632 | status = | ||
633 | acpi_ns_check_package_elements(pathname, | ||
634 | (sub_elements | ||
635 | + 1), | ||
636 | package-> | ||
637 | ret_info. | ||
638 | object_type1, | ||
639 | (expected_count | ||
640 | - 1), 0, 0); | ||
641 | if (ACPI_FAILURE(status)) { | ||
642 | return (status); | ||
643 | } | ||
644 | break; | ||
645 | |||
646 | default: | ||
647 | break; | ||
648 | } | ||
649 | |||
650 | elements++; | ||
651 | } | ||
652 | break; | ||
653 | |||
654 | default: | ||
655 | |||
656 | /* Should not get here if predefined info table is correct */ | ||
657 | |||
658 | ACPI_WARNING((AE_INFO, | ||
659 | "%s: Invalid internal return type in table entry: %X", | ||
660 | pathname, package->ret_info.type)); | ||
661 | |||
662 | return (AE_AML_INTERNAL); | ||
663 | } | ||
664 | |||
665 | return (AE_OK); | ||
666 | |||
667 | package_too_small: | ||
668 | |||
669 | /* Error exit for the case with an incorrect package count */ | ||
670 | |||
671 | ACPI_WARNING((AE_INFO, "%s: Return Package is too small - " | ||
672 | "found %u, expected %u", pathname, count, | ||
673 | expected_count)); | ||
674 | |||
675 | return (AE_AML_OPERAND_VALUE); | ||
676 | } | ||
677 | |||
678 | /******************************************************************************* | ||
679 | * | ||
680 | * FUNCTION: acpi_ns_check_package_elements | ||
681 | * | ||
682 | * PARAMETERS: Pathname - Full pathname to the node (for error msgs) | ||
683 | * Elements - Pointer to the package elements array | ||
684 | * Type1 - Object type for first group | ||
685 | * Count1 - Count for first group | ||
686 | * Type2 - Object type for second group | ||
687 | * Count2 - Count for second group | ||
688 | * | ||
689 | * RETURN: Status | ||
690 | * | ||
691 | * DESCRIPTION: Check that all elements of a package are of the correct object | ||
692 | * type. Supports up to two groups of different object types. | ||
693 | * | ||
694 | ******************************************************************************/ | ||
695 | |||
696 | static acpi_status | ||
697 | acpi_ns_check_package_elements(char *pathname, | ||
698 | union acpi_operand_object **elements, | ||
699 | u8 type1, u32 count1, u8 type2, u32 count2) | ||
700 | { | ||
701 | union acpi_operand_object **this_element = elements; | ||
702 | acpi_status status; | ||
703 | u32 i; | ||
704 | |||
705 | /* | ||
706 | * Up to two groups of package elements are supported by the data | ||
707 | * structure. All elements in each group must be of the same type. | ||
708 | * The second group can have a count of zero. | ||
709 | */ | ||
710 | for (i = 0; i < count1; i++) { | ||
711 | status = acpi_ns_check_object_type(pathname, *this_element, | ||
712 | type1, i); | ||
713 | if (ACPI_FAILURE(status)) { | ||
714 | return (status); | ||
715 | } | ||
716 | this_element++; | ||
717 | } | ||
718 | |||
719 | for (i = 0; i < count2; i++) { | ||
720 | status = acpi_ns_check_object_type(pathname, *this_element, | ||
721 | type2, (i + count1)); | ||
722 | if (ACPI_FAILURE(status)) { | ||
723 | return (status); | ||
724 | } | ||
725 | this_element++; | ||
726 | } | ||
727 | |||
728 | return (AE_OK); | ||
729 | } | ||
730 | |||
731 | /******************************************************************************* | ||
732 | * | ||
733 | * FUNCTION: acpi_ns_check_object_type | ||
734 | * | ||
735 | * PARAMETERS: Pathname - Full pathname to the node (for error msgs) | ||
736 | * return_object - Object return from the execution of this | ||
737 | * method/object | ||
738 | * expected_btypes - Bitmap of expected return type(s) | ||
739 | * package_index - Index of object within parent package (if | ||
740 | * applicable - ACPI_NOT_PACKAGE otherwise) | ||
741 | * | ||
742 | * RETURN: Status | ||
743 | * | ||
744 | * DESCRIPTION: Check the type of the return object against the expected object | ||
745 | * type(s). Use of Btype allows multiple expected object types. | ||
746 | * | ||
747 | ******************************************************************************/ | ||
748 | |||
749 | static acpi_status | ||
750 | acpi_ns_check_object_type(char *pathname, | ||
751 | union acpi_operand_object *return_object, | ||
752 | u32 expected_btypes, u32 package_index) | ||
753 | { | ||
754 | acpi_status status = AE_OK; | ||
755 | u32 return_btype; | ||
756 | char type_buffer[48]; /* Room for 5 types */ | ||
757 | u32 this_rtype; | ||
758 | u32 i; | ||
759 | u32 j; | ||
760 | |||
761 | /* | ||
762 | * If we get a NULL return_object here, it is a NULL package element, | ||
763 | * and this is always an error. | ||
764 | */ | ||
765 | if (!return_object) { | ||
766 | goto type_error_exit; | ||
767 | } | ||
768 | |||
769 | /* A Namespace node should not get here, but make sure */ | ||
770 | |||
771 | if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { | ||
772 | ACPI_WARNING((AE_INFO, | ||
773 | "%s: Invalid return type - Found a Namespace node [%4.4s] type %s", | ||
774 | pathname, return_object->node.name.ascii, | ||
775 | acpi_ut_get_type_name(return_object->node.type))); | ||
776 | return (AE_AML_OPERAND_TYPE); | ||
777 | } | ||
778 | |||
779 | /* | ||
780 | * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. | ||
781 | * The bitmapped type allows multiple possible return types. | ||
782 | * | ||
783 | * Note, the cases below must handle all of the possible types returned | ||
784 | * from all of the predefined names (including elements of returned | ||
785 | * packages) | ||
786 | */ | ||
787 | switch (ACPI_GET_OBJECT_TYPE(return_object)) { | ||
788 | case ACPI_TYPE_INTEGER: | ||
789 | return_btype = ACPI_RTYPE_INTEGER; | ||
790 | break; | ||
791 | |||
792 | case ACPI_TYPE_BUFFER: | ||
793 | return_btype = ACPI_RTYPE_BUFFER; | ||
794 | break; | ||
795 | |||
796 | case ACPI_TYPE_STRING: | ||
797 | return_btype = ACPI_RTYPE_STRING; | ||
798 | break; | ||
799 | |||
800 | case ACPI_TYPE_PACKAGE: | ||
801 | return_btype = ACPI_RTYPE_PACKAGE; | ||
802 | break; | ||
803 | |||
804 | case ACPI_TYPE_LOCAL_REFERENCE: | ||
805 | return_btype = ACPI_RTYPE_REFERENCE; | ||
806 | break; | ||
807 | |||
808 | default: | ||
809 | /* Not one of the supported objects, must be incorrect */ | ||
810 | |||
811 | goto type_error_exit; | ||
812 | } | ||
813 | |||
814 | /* Is the object one of the expected types? */ | ||
815 | |||
816 | if (!(return_btype & expected_btypes)) { | ||
817 | goto type_error_exit; | ||
818 | } | ||
819 | |||
820 | /* For reference objects, check that the reference type is correct */ | ||
821 | |||
822 | if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_LOCAL_REFERENCE) { | ||
823 | status = acpi_ns_check_reference(pathname, return_object); | ||
824 | } | ||
825 | |||
826 | return (status); | ||
827 | |||
828 | type_error_exit: | ||
829 | |||
830 | /* Create a string with all expected types for this predefined object */ | ||
831 | |||
832 | j = 1; | ||
833 | type_buffer[0] = 0; | ||
834 | this_rtype = ACPI_RTYPE_INTEGER; | ||
835 | |||
836 | for (i = 0; i < ACPI_NUM_RTYPES; i++) { | ||
837 | |||
838 | /* If one of the expected types, concatenate the name of this type */ | ||
839 | |||
840 | if (expected_btypes & this_rtype) { | ||
841 | ACPI_STRCAT(type_buffer, &acpi_rtype_names[i][j]); | ||
842 | j = 0; /* Use name separator from now on */ | ||
843 | } | ||
844 | this_rtype <<= 1; /* Next Rtype */ | ||
845 | } | ||
846 | |||
847 | if (package_index == ACPI_NOT_PACKAGE) { | ||
848 | ACPI_WARNING((AE_INFO, | ||
849 | "%s: Return type mismatch - found %s, expected %s", | ||
850 | pathname, | ||
851 | acpi_ut_get_object_type_name(return_object), | ||
852 | type_buffer)); | ||
853 | } else { | ||
854 | ACPI_WARNING((AE_INFO, | ||
855 | "%s: Return Package type mismatch at index %u - " | ||
856 | "found %s, expected %s", pathname, package_index, | ||
857 | acpi_ut_get_object_type_name(return_object), | ||
858 | type_buffer)); | ||
859 | } | ||
860 | |||
861 | return (AE_AML_OPERAND_TYPE); | ||
862 | } | ||
863 | |||
864 | /******************************************************************************* | ||
865 | * | ||
866 | * FUNCTION: acpi_ns_check_reference | ||
867 | * | ||
868 | * PARAMETERS: Pathname - Full pathname to the node (for error msgs) | ||
869 | * return_object - Object returned from the evaluation of a | ||
870 | * method or object | ||
871 | * | ||
872 | * RETURN: Status | ||
873 | * | ||
874 | * DESCRIPTION: Check a returned reference object for the correct reference | ||
875 | * type. The only reference type that can be returned from a | ||
876 | * predefined method is a named reference. All others are invalid. | ||
877 | * | ||
878 | ******************************************************************************/ | ||
879 | |||
880 | static acpi_status | ||
881 | acpi_ns_check_reference(char *pathname, | ||
882 | union acpi_operand_object *return_object) | ||
883 | { | ||
884 | |||
885 | /* | ||
886 | * Check the reference object for the correct reference type (opcode). | ||
887 | * The only type of reference that can be converted to an union acpi_object is | ||
888 | * a reference to a named object (reference class: NAME) | ||
889 | */ | ||
890 | if (return_object->reference.class == ACPI_REFCLASS_NAME) { | ||
891 | return (AE_OK); | ||
892 | } | ||
893 | |||
894 | ACPI_WARNING((AE_INFO, | ||
895 | "%s: Return type mismatch - unexpected reference object type [%s] %2.2X", | ||
896 | pathname, acpi_ut_get_reference_name(return_object), | ||
897 | return_object->reference.class)); | ||
898 | |||
899 | return (AE_AML_OPERAND_TYPE); | ||
900 | } | ||
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c index 8399276cba1e..a9a80bf811b3 100644 --- a/drivers/acpi/namespace/nssearch.c +++ b/drivers/acpi/namespace/nssearch.c | |||
@@ -331,7 +331,7 @@ acpi_ns_search_and_enter(u32 target_name, | |||
331 | "Found bad character(s) in name, repaired: [%4.4s]\n", | 331 | "Found bad character(s) in name, repaired: [%4.4s]\n", |
332 | ACPI_CAST_PTR(char, &target_name))); | 332 | ACPI_CAST_PTR(char, &target_name))); |
333 | } else { | 333 | } else { |
334 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 334 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
335 | "Found bad character(s) in name, repaired: [%4.4s]\n", | 335 | "Found bad character(s) in name, repaired: [%4.4s]\n", |
336 | ACPI_CAST_PTR(char, &target_name))); | 336 | ACPI_CAST_PTR(char, &target_name))); |
337 | } | 337 | } |
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index 38be5865d95d..a085cc39c055 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c | |||
@@ -48,6 +48,10 @@ | |||
48 | 48 | ||
49 | #define _COMPONENT ACPI_NAMESPACE | 49 | #define _COMPONENT ACPI_NAMESPACE |
50 | ACPI_MODULE_NAME("nsxfeval") | 50 | ACPI_MODULE_NAME("nsxfeval") |
51 | |||
52 | /* Local prototypes */ | ||
53 | static void acpi_ns_resolve_references(struct acpi_evaluate_info *info); | ||
54 | |||
51 | #ifdef ACPI_FUTURE_USAGE | 55 | #ifdef ACPI_FUTURE_USAGE |
52 | /******************************************************************************* | 56 | /******************************************************************************* |
53 | * | 57 | * |
@@ -69,6 +73,7 @@ ACPI_MODULE_NAME("nsxfeval") | |||
69 | * be valid (non-null) | 73 | * be valid (non-null) |
70 | * | 74 | * |
71 | ******************************************************************************/ | 75 | ******************************************************************************/ |
76 | |||
72 | acpi_status | 77 | acpi_status |
73 | acpi_evaluate_object_typed(acpi_handle handle, | 78 | acpi_evaluate_object_typed(acpi_handle handle, |
74 | acpi_string pathname, | 79 | acpi_string pathname, |
@@ -283,6 +288,10 @@ acpi_evaluate_object(acpi_handle handle, | |||
283 | 288 | ||
284 | if (ACPI_SUCCESS(status)) { | 289 | if (ACPI_SUCCESS(status)) { |
285 | 290 | ||
291 | /* Dereference Index and ref_of references */ | ||
292 | |||
293 | acpi_ns_resolve_references(info); | ||
294 | |||
286 | /* Get the size of the returned object */ | 295 | /* Get the size of the returned object */ |
287 | 296 | ||
288 | status = | 297 | status = |
@@ -352,6 +361,74 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object) | |||
352 | 361 | ||
353 | /******************************************************************************* | 362 | /******************************************************************************* |
354 | * | 363 | * |
364 | * FUNCTION: acpi_ns_resolve_references | ||
365 | * | ||
366 | * PARAMETERS: Info - Evaluation info block | ||
367 | * | ||
368 | * RETURN: Info->return_object is replaced with the dereferenced object | ||
369 | * | ||
370 | * DESCRIPTION: Dereference certain reference objects. Called before an | ||
371 | * internal return object is converted to an external union acpi_object. | ||
372 | * | ||
373 | * Performs an automatic dereference of Index and ref_of reference objects. | ||
374 | * These reference objects are not supported by the union acpi_object, so this is a | ||
375 | * last resort effort to return something useful. Also, provides compatibility | ||
376 | * with other ACPI implementations. | ||
377 | * | ||
378 | * NOTE: does not handle references within returned package objects or nested | ||
379 | * references, but this support could be added later if found to be necessary. | ||
380 | * | ||
381 | ******************************************************************************/ | ||
382 | static void acpi_ns_resolve_references(struct acpi_evaluate_info *info) | ||
383 | { | ||
384 | union acpi_operand_object *obj_desc = NULL; | ||
385 | struct acpi_namespace_node *node; | ||
386 | |||
387 | /* We are interested in reference objects only */ | ||
388 | |||
389 | if (ACPI_GET_OBJECT_TYPE(info->return_object) != | ||
390 | ACPI_TYPE_LOCAL_REFERENCE) { | ||
391 | return; | ||
392 | } | ||
393 | |||
394 | /* | ||
395 | * Two types of references are supported - those created by Index and | ||
396 | * ref_of operators. A name reference (AML_NAMEPATH_OP) can be converted | ||
397 | * to an union acpi_object, so it is not dereferenced here. A ddb_handle | ||
398 | * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to | ||
399 | * an union acpi_object. | ||
400 | */ | ||
401 | switch (info->return_object->reference.class) { | ||
402 | case ACPI_REFCLASS_INDEX: | ||
403 | |||
404 | obj_desc = *(info->return_object->reference.where); | ||
405 | break; | ||
406 | |||
407 | case ACPI_REFCLASS_REFOF: | ||
408 | |||
409 | node = info->return_object->reference.object; | ||
410 | if (node) { | ||
411 | obj_desc = node->object; | ||
412 | } | ||
413 | break; | ||
414 | |||
415 | default: | ||
416 | return; | ||
417 | } | ||
418 | |||
419 | /* Replace the existing reference object */ | ||
420 | |||
421 | if (obj_desc) { | ||
422 | acpi_ut_add_reference(obj_desc); | ||
423 | acpi_ut_remove_reference(info->return_object); | ||
424 | info->return_object = obj_desc; | ||
425 | } | ||
426 | |||
427 | return; | ||
428 | } | ||
429 | |||
430 | /******************************************************************************* | ||
431 | * | ||
355 | * FUNCTION: acpi_walk_namespace | 432 | * FUNCTION: acpi_walk_namespace |
356 | * | 433 | * |
357 | * PARAMETERS: Type - acpi_object_type to search for | 434 | * PARAMETERS: Type - acpi_object_type to search for |
@@ -379,6 +456,7 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object) | |||
379 | * function, etc. | 456 | * function, etc. |
380 | * | 457 | * |
381 | ******************************************************************************/ | 458 | ******************************************************************************/ |
459 | |||
382 | acpi_status | 460 | acpi_status |
383 | acpi_walk_namespace(acpi_object_type type, | 461 | acpi_walk_namespace(acpi_object_type type, |
384 | acpi_handle start_object, | 462 | acpi_handle start_object, |
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c index a287ed550f54..5efa4e7ddb0b 100644 --- a/drivers/acpi/namespace/nsxfname.c +++ b/drivers/acpi/namespace/nsxfname.c | |||
@@ -253,6 +253,7 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer) | |||
253 | node = acpi_ns_map_handle_to_node(handle); | 253 | node = acpi_ns_map_handle_to_node(handle); |
254 | if (!node) { | 254 | if (!node) { |
255 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 255 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
256 | status = AE_BAD_PARAMETER; | ||
256 | goto cleanup; | 257 | goto cleanup; |
257 | } | 258 | } |
258 | 259 | ||
@@ -264,6 +265,10 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer) | |||
264 | info->name = node->name.integer; | 265 | info->name = node->name.integer; |
265 | info->valid = 0; | 266 | info->valid = 0; |
266 | 267 | ||
268 | if (node->type == ACPI_TYPE_METHOD) { | ||
269 | info->param_count = node->object->method.param_count; | ||
270 | } | ||
271 | |||
267 | status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 272 | status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
268 | if (ACPI_FAILURE(status)) { | 273 | if (ACPI_FAILURE(status)) { |
269 | goto cleanup; | 274 | goto cleanup; |
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index cb9864e39bae..25ceae9191ef 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c | |||
@@ -258,7 +258,7 @@ int __init acpi_numa_init(void) | |||
258 | 258 | ||
259 | int acpi_get_pxm(acpi_handle h) | 259 | int acpi_get_pxm(acpi_handle h) |
260 | { | 260 | { |
261 | unsigned long pxm; | 261 | unsigned long long pxm; |
262 | acpi_status status; | 262 | acpi_status status; |
263 | acpi_handle handle; | 263 | acpi_handle handle; |
264 | acpi_handle phandle = h; | 264 | acpi_handle phandle = h; |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 235a1386888a..c8111424dcb8 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
36 | #include <linux/kmod.h> | 36 | #include <linux/kmod.h> |
37 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
38 | #include <linux/dmi.h> | ||
39 | #include <linux/workqueue.h> | 38 | #include <linux/workqueue.h> |
40 | #include <linux/nmi.h> | 39 | #include <linux/nmi.h> |
41 | #include <linux/acpi.h> | 40 | #include <linux/acpi.h> |
@@ -97,54 +96,44 @@ static DEFINE_SPINLOCK(acpi_res_lock); | |||
97 | static char osi_additional_string[OSI_STRING_LENGTH_MAX]; | 96 | static char osi_additional_string[OSI_STRING_LENGTH_MAX]; |
98 | 97 | ||
99 | /* | 98 | /* |
100 | * "Ode to _OSI(Linux)" | 99 | * The story of _OSI(Linux) |
101 | * | 100 | * |
102 | * osi_linux -- Control response to BIOS _OSI(Linux) query. | 101 | * From pre-history through Linux-2.6.22, |
102 | * Linux responded TRUE upon a BIOS OSI(Linux) query. | ||
103 | * | 103 | * |
104 | * As Linux evolves, the features that it supports change. | 104 | * Unfortunately, reference BIOS writers got wind of this |
105 | * So an OSI string such as "Linux" is not specific enough | 105 | * and put OSI(Linux) in their example code, quickly exposing |
106 | * to be useful across multiple versions of Linux. It | 106 | * this string as ill-conceived and opening the door to |
107 | * doesn't identify any particular feature, interface, | 107 | * an un-bounded number of BIOS incompatibilities. |
108 | * or even any particular version of Linux... | ||
109 | * | 108 | * |
110 | * Unfortunately, Linux-2.6.22 and earlier responded "yes" | 109 | * For example, OSI(Linux) was used on resume to re-POST a |
111 | * to a BIOS _OSI(Linux) query. When | 110 | * video card on one system, because Linux at that time |
112 | * a reference mobile BIOS started using it, its use | 111 | * could not do a speedy restore in its native driver. |
113 | * started to spread to many vendor platforms. | 112 | * But then upon gaining quick native restore capability, |
114 | * As it is not supportable, we need to halt that spread. | 113 | * Linux has no way to tell the BIOS to skip the time-consuming |
114 | * POST -- putting Linux at a permanent performance disadvantage. | ||
115 | * On another system, the BIOS writer used OSI(Linux) | ||
116 | * to infer native OS support for IPMI! On other systems, | ||
117 | * OSI(Linux) simply got in the way of Linux claiming to | ||
118 | * be compatible with other operating systems, exposing | ||
119 | * BIOS issues such as skipped device initialization. | ||
115 | * | 120 | * |
116 | * Today, most BIOS references to _OSI(Linux) are noise -- | 121 | * So "Linux" turned out to be a really poor chose of |
117 | * they have no functional effect and are just dead code | 122 | * OSI string, and from Linux-2.6.23 onward we respond FALSE. |
118 | * carried over from the reference BIOS. | ||
119 | * | ||
120 | * The next most common case is that _OSI(Linux) harms Linux, | ||
121 | * usually by causing the BIOS to follow paths that are | ||
122 | * not tested during Windows validation. | ||
123 | * | ||
124 | * Finally, there is a short list of platforms | ||
125 | * where OSI(Linux) benefits Linux. | ||
126 | * | ||
127 | * In Linux-2.6.23, OSI(Linux) is first disabled by default. | ||
128 | * DMI is used to disable the dmesg warning about OSI(Linux) | ||
129 | * on platforms where it is known to have no effect. | ||
130 | * But a dmesg warning remains for systems where | ||
131 | * we do not know if OSI(Linux) is good or bad for the system. | ||
132 | * DMI is also used to enable OSI(Linux) for the machines | ||
133 | * that are known to need it. | ||
134 | * | 123 | * |
135 | * BIOS writers should NOT query _OSI(Linux) on future systems. | 124 | * BIOS writers should NOT query _OSI(Linux) on future systems. |
136 | * It will be ignored by default, and to get Linux to | 125 | * Linux will complain on the console when it sees it, and return FALSE. |
137 | * not ignore it will require a kernel source update to | 126 | * To get Linux to return TRUE for your system will require |
138 | * add a DMI entry, or a boot-time "acpi_osi=Linux" invocation. | 127 | * a kernel source update to add a DMI entry, |
128 | * or boot with "acpi_osi=Linux" | ||
139 | */ | 129 | */ |
140 | #define OSI_LINUX_ENABLE 0 | ||
141 | 130 | ||
142 | static struct osi_linux { | 131 | static struct osi_linux { |
143 | unsigned int enable:1; | 132 | unsigned int enable:1; |
144 | unsigned int dmi:1; | 133 | unsigned int dmi:1; |
145 | unsigned int cmdline:1; | 134 | unsigned int cmdline:1; |
146 | unsigned int known:1; | 135 | unsigned int known:1; |
147 | } osi_linux = { OSI_LINUX_ENABLE, 0, 0, 0}; | 136 | } osi_linux = { 0, 0, 0, 0}; |
148 | 137 | ||
149 | static void __init acpi_request_region (struct acpi_generic_address *addr, | 138 | static void __init acpi_request_region (struct acpi_generic_address *addr, |
150 | unsigned int length, char *desc) | 139 | unsigned int length, char *desc) |
@@ -608,7 +597,7 @@ static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ | |||
608 | acpi_handle handle; | 597 | acpi_handle handle; |
609 | struct acpi_pci_id *pci_id = *id; | 598 | struct acpi_pci_id *pci_id = *id; |
610 | acpi_status status; | 599 | acpi_status status; |
611 | unsigned long temp; | 600 | unsigned long long temp; |
612 | acpi_object_type type; | 601 | acpi_object_type type; |
613 | 602 | ||
614 | acpi_get_parent(chandle, &handle); | 603 | acpi_get_parent(chandle, &handle); |
@@ -620,8 +609,7 @@ static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ | |||
620 | if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE)) | 609 | if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE)) |
621 | return; | 610 | return; |
622 | 611 | ||
623 | status = | 612 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, |
624 | acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, | ||
625 | &temp); | 613 | &temp); |
626 | if (ACPI_SUCCESS(status)) { | 614 | if (ACPI_SUCCESS(status)) { |
627 | u32 val; | 615 | u32 val; |
@@ -682,6 +670,22 @@ static void acpi_os_execute_deferred(struct work_struct *work) | |||
682 | return; | 670 | return; |
683 | } | 671 | } |
684 | 672 | ||
673 | static void acpi_os_execute_hp_deferred(struct work_struct *work) | ||
674 | { | ||
675 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); | ||
676 | if (!dpc) { | ||
677 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); | ||
678 | return; | ||
679 | } | ||
680 | |||
681 | acpi_os_wait_events_complete(NULL); | ||
682 | |||
683 | dpc->function(dpc->context); | ||
684 | kfree(dpc); | ||
685 | |||
686 | return; | ||
687 | } | ||
688 | |||
685 | /******************************************************************************* | 689 | /******************************************************************************* |
686 | * | 690 | * |
687 | * FUNCTION: acpi_os_execute | 691 | * FUNCTION: acpi_os_execute |
@@ -697,12 +701,13 @@ static void acpi_os_execute_deferred(struct work_struct *work) | |||
697 | * | 701 | * |
698 | ******************************************************************************/ | 702 | ******************************************************************************/ |
699 | 703 | ||
700 | acpi_status acpi_os_execute(acpi_execute_type type, | 704 | static acpi_status __acpi_os_execute(acpi_execute_type type, |
701 | acpi_osd_exec_callback function, void *context) | 705 | acpi_osd_exec_callback function, void *context, int hp) |
702 | { | 706 | { |
703 | acpi_status status = AE_OK; | 707 | acpi_status status = AE_OK; |
704 | struct acpi_os_dpc *dpc; | 708 | struct acpi_os_dpc *dpc; |
705 | struct workqueue_struct *queue; | 709 | struct workqueue_struct *queue; |
710 | int ret; | ||
706 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 711 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
707 | "Scheduling function [%p(%p)] for deferred execution.\n", | 712 | "Scheduling function [%p(%p)] for deferred execution.\n", |
708 | function, context)); | 713 | function, context)); |
@@ -726,19 +731,38 @@ acpi_status acpi_os_execute(acpi_execute_type type, | |||
726 | dpc->function = function; | 731 | dpc->function = function; |
727 | dpc->context = context; | 732 | dpc->context = context; |
728 | 733 | ||
729 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | 734 | if (!hp) { |
730 | queue = (type == OSL_NOTIFY_HANDLER) ? kacpi_notify_wq : kacpid_wq; | 735 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); |
731 | if (!queue_work(queue, &dpc->work)) { | 736 | queue = (type == OSL_NOTIFY_HANDLER) ? |
732 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 737 | kacpi_notify_wq : kacpid_wq; |
733 | "Call to queue_work() failed.\n")); | 738 | ret = queue_work(queue, &dpc->work); |
739 | } else { | ||
740 | INIT_WORK(&dpc->work, acpi_os_execute_hp_deferred); | ||
741 | ret = schedule_work(&dpc->work); | ||
742 | } | ||
743 | |||
744 | if (!ret) { | ||
745 | printk(KERN_ERR PREFIX | ||
746 | "Call to queue_work() failed.\n"); | ||
734 | status = AE_ERROR; | 747 | status = AE_ERROR; |
735 | kfree(dpc); | 748 | kfree(dpc); |
736 | } | 749 | } |
737 | return_ACPI_STATUS(status); | 750 | return_ACPI_STATUS(status); |
738 | } | 751 | } |
739 | 752 | ||
753 | acpi_status acpi_os_execute(acpi_execute_type type, | ||
754 | acpi_osd_exec_callback function, void *context) | ||
755 | { | ||
756 | return __acpi_os_execute(type, function, context, 0); | ||
757 | } | ||
740 | EXPORT_SYMBOL(acpi_os_execute); | 758 | EXPORT_SYMBOL(acpi_os_execute); |
741 | 759 | ||
760 | acpi_status acpi_os_hotplug_execute(acpi_osd_exec_callback function, | ||
761 | void *context) | ||
762 | { | ||
763 | return __acpi_os_execute(0, function, context, 1); | ||
764 | } | ||
765 | |||
742 | void acpi_os_wait_events_complete(void *context) | 766 | void acpi_os_wait_events_complete(void *context) |
743 | { | 767 | { |
744 | flush_workqueue(kacpid_wq); | 768 | flush_workqueue(kacpid_wq); |
@@ -1261,34 +1285,6 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) | |||
1261 | return (AE_OK); | 1285 | return (AE_OK); |
1262 | } | 1286 | } |
1263 | 1287 | ||
1264 | /** | ||
1265 | * acpi_dmi_dump - dump DMI slots needed for blacklist entry | ||
1266 | * | ||
1267 | * Returns 0 on success | ||
1268 | */ | ||
1269 | static int acpi_dmi_dump(void) | ||
1270 | { | ||
1271 | |||
1272 | if (!dmi_available) | ||
1273 | return -1; | ||
1274 | |||
1275 | printk(KERN_NOTICE PREFIX "DMI System Vendor: %s\n", | ||
1276 | dmi_get_system_info(DMI_SYS_VENDOR)); | ||
1277 | printk(KERN_NOTICE PREFIX "DMI Product Name: %s\n", | ||
1278 | dmi_get_system_info(DMI_PRODUCT_NAME)); | ||
1279 | printk(KERN_NOTICE PREFIX "DMI Product Version: %s\n", | ||
1280 | dmi_get_system_info(DMI_PRODUCT_VERSION)); | ||
1281 | printk(KERN_NOTICE PREFIX "DMI Board Name: %s\n", | ||
1282 | dmi_get_system_info(DMI_BOARD_NAME)); | ||
1283 | printk(KERN_NOTICE PREFIX "DMI BIOS Vendor: %s\n", | ||
1284 | dmi_get_system_info(DMI_BIOS_VENDOR)); | ||
1285 | printk(KERN_NOTICE PREFIX "DMI BIOS Date: %s\n", | ||
1286 | dmi_get_system_info(DMI_BIOS_DATE)); | ||
1287 | |||
1288 | return 0; | ||
1289 | } | ||
1290 | |||
1291 | |||
1292 | /****************************************************************************** | 1288 | /****************************************************************************** |
1293 | * | 1289 | * |
1294 | * FUNCTION: acpi_os_validate_interface | 1290 | * FUNCTION: acpi_os_validate_interface |
@@ -1315,21 +1311,6 @@ acpi_os_validate_interface (char *interface) | |||
1315 | osi_linux.cmdline ? " via cmdline" : | 1311 | osi_linux.cmdline ? " via cmdline" : |
1316 | osi_linux.dmi ? " via DMI" : ""); | 1312 | osi_linux.dmi ? " via DMI" : ""); |
1317 | 1313 | ||
1318 | if (!osi_linux.dmi) { | ||
1319 | if (acpi_dmi_dump()) | ||
1320 | printk(KERN_NOTICE PREFIX | ||
1321 | "[please extract dmidecode output]\n"); | ||
1322 | printk(KERN_NOTICE PREFIX | ||
1323 | "Please send DMI info above to " | ||
1324 | "linux-acpi@vger.kernel.org\n"); | ||
1325 | } | ||
1326 | if (!osi_linux.known && !osi_linux.cmdline) { | ||
1327 | printk(KERN_NOTICE PREFIX | ||
1328 | "If \"acpi_osi=%sLinux\" works better, " | ||
1329 | "please notify linux-acpi@vger.kernel.org\n", | ||
1330 | osi_linux.enable ? "!" : ""); | ||
1331 | } | ||
1332 | |||
1333 | if (osi_linux.enable) | 1314 | if (osi_linux.enable) |
1334 | return AE_OK; | 1315 | return AE_OK; |
1335 | } | 1316 | } |
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index c06238e55d98..4647039a0d8a 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c | |||
@@ -719,6 +719,8 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state, | |||
719 | *op = NULL; | 719 | *op = NULL; |
720 | } | 720 | } |
721 | 721 | ||
722 | ACPI_PREEMPTION_POINT(); | ||
723 | |||
722 | return_ACPI_STATUS(AE_OK); | 724 | return_ACPI_STATUS(AE_OK); |
723 | } | 725 | } |
724 | 726 | ||
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 15e1702e48d6..68e932f215ea 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c | |||
@@ -137,6 +137,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | |||
137 | union acpi_parse_object *next; | 137 | union acpi_parse_object *next; |
138 | const struct acpi_opcode_info *parent_info; | 138 | const struct acpi_opcode_info *parent_info; |
139 | union acpi_parse_object *replacement_op = NULL; | 139 | union acpi_parse_object *replacement_op = NULL; |
140 | acpi_status status = AE_OK; | ||
140 | 141 | ||
141 | ACPI_FUNCTION_TRACE_PTR(ps_complete_this_op, op); | 142 | ACPI_FUNCTION_TRACE_PTR(ps_complete_this_op, op); |
142 | 143 | ||
@@ -186,7 +187,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | |||
186 | replacement_op = | 187 | replacement_op = |
187 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); | 188 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); |
188 | if (!replacement_op) { | 189 | if (!replacement_op) { |
189 | goto allocate_error; | 190 | status = AE_NO_MEMORY; |
190 | } | 191 | } |
191 | break; | 192 | break; |
192 | 193 | ||
@@ -211,7 +212,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | |||
211 | replacement_op = | 212 | replacement_op = |
212 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); | 213 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); |
213 | if (!replacement_op) { | 214 | if (!replacement_op) { |
214 | goto allocate_error; | 215 | status = AE_NO_MEMORY; |
215 | } | 216 | } |
216 | } else | 217 | } else |
217 | if ((op->common.parent->common.aml_opcode == | 218 | if ((op->common.parent->common.aml_opcode == |
@@ -226,13 +227,13 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | |||
226 | acpi_ps_alloc_op(op->common. | 227 | acpi_ps_alloc_op(op->common. |
227 | aml_opcode); | 228 | aml_opcode); |
228 | if (!replacement_op) { | 229 | if (!replacement_op) { |
229 | goto allocate_error; | 230 | status = AE_NO_MEMORY; |
231 | } else { | ||
232 | replacement_op->named.data = | ||
233 | op->named.data; | ||
234 | replacement_op->named.length = | ||
235 | op->named.length; | ||
230 | } | 236 | } |
231 | |||
232 | replacement_op->named.data = | ||
233 | op->named.data; | ||
234 | replacement_op->named.length = | ||
235 | op->named.length; | ||
236 | } | 237 | } |
237 | } | 238 | } |
238 | break; | 239 | break; |
@@ -242,7 +243,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | |||
242 | replacement_op = | 243 | replacement_op = |
243 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); | 244 | acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); |
244 | if (!replacement_op) { | 245 | if (!replacement_op) { |
245 | goto allocate_error; | 246 | status = AE_NO_MEMORY; |
246 | } | 247 | } |
247 | } | 248 | } |
248 | 249 | ||
@@ -302,14 +303,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | |||
302 | /* Now we can actually delete the subtree rooted at Op */ | 303 | /* Now we can actually delete the subtree rooted at Op */ |
303 | 304 | ||
304 | acpi_ps_delete_parse_tree(op); | 305 | acpi_ps_delete_parse_tree(op); |
305 | return_ACPI_STATUS(AE_OK); | 306 | return_ACPI_STATUS(status); |
306 | |||
307 | allocate_error: | ||
308 | |||
309 | /* Always delete the subtree, even on error */ | ||
310 | |||
311 | acpi_ps_delete_parse_tree(op); | ||
312 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
313 | } | 307 | } |
314 | 308 | ||
315 | /******************************************************************************* | 309 | /******************************************************************************* |
@@ -641,10 +635,12 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) | |||
641 | ACPI_WALK_METHOD_RESTART; | 635 | ACPI_WALK_METHOD_RESTART; |
642 | } | 636 | } |
643 | } else { | 637 | } else { |
644 | /* On error, delete any return object */ | 638 | /* On error, delete any return object or implicit return */ |
645 | 639 | ||
646 | acpi_ut_remove_reference(previous_walk_state-> | 640 | acpi_ut_remove_reference(previous_walk_state-> |
647 | return_desc); | 641 | return_desc); |
642 | acpi_ds_clear_implicit_return | ||
643 | (previous_walk_state); | ||
648 | } | 644 | } |
649 | } | 645 | } |
650 | 646 | ||
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 11acaee14d66..bf79d83bdfbb 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
@@ -384,6 +384,27 @@ acpi_pci_free_irq(struct acpi_prt_entry *entry, | |||
384 | return irq; | 384 | return irq; |
385 | } | 385 | } |
386 | 386 | ||
387 | #ifdef CONFIG_X86_IO_APIC | ||
388 | extern int noioapicquirk; | ||
389 | |||
390 | static int bridge_has_boot_interrupt_variant(struct pci_bus *bus) | ||
391 | { | ||
392 | struct pci_bus *bus_it; | ||
393 | |||
394 | for (bus_it = bus ; bus_it ; bus_it = bus_it->parent) { | ||
395 | if (!bus_it->self) | ||
396 | return 0; | ||
397 | |||
398 | printk(KERN_INFO "vendor=%04x device=%04x\n", bus_it->self->vendor, | ||
399 | bus_it->self->device); | ||
400 | |||
401 | if (bus_it->self->irq_reroute_variant) | ||
402 | return bus_it->self->irq_reroute_variant; | ||
403 | } | ||
404 | return 0; | ||
405 | } | ||
406 | #endif /* CONFIG_X86_IO_APIC */ | ||
407 | |||
387 | /* | 408 | /* |
388 | * acpi_pci_irq_lookup | 409 | * acpi_pci_irq_lookup |
389 | * success: return IRQ >= 0 | 410 | * success: return IRQ >= 0 |
@@ -413,6 +434,41 @@ acpi_pci_irq_lookup(struct pci_bus *bus, | |||
413 | } | 434 | } |
414 | 435 | ||
415 | ret = func(entry, triggering, polarity, link); | 436 | ret = func(entry, triggering, polarity, link); |
437 | |||
438 | #ifdef CONFIG_X86_IO_APIC | ||
439 | /* | ||
440 | * Some chipsets (e.g. intel 6700PXH) generate a legacy INTx when the | ||
441 | * IRQ entry in the chipset's IO-APIC is masked (as, e.g. the RT kernel | ||
442 | * does during interrupt handling). When this INTx generation cannot be | ||
443 | * disabled, we reroute these interrupts to their legacy equivalent to | ||
444 | * get rid of spurious interrupts. | ||
445 | */ | ||
446 | if (!noioapicquirk) { | ||
447 | switch (bridge_has_boot_interrupt_variant(bus)) { | ||
448 | case 0: | ||
449 | /* no rerouting necessary */ | ||
450 | break; | ||
451 | |||
452 | case INTEL_IRQ_REROUTE_VARIANT: | ||
453 | /* | ||
454 | * Remap according to INTx routing table in 6700PXH | ||
455 | * specs, intel order number 302628-002, section | ||
456 | * 2.15.2. Other chipsets (80332, ...) have the same | ||
457 | * mapping and are handled here as well. | ||
458 | */ | ||
459 | printk(KERN_INFO "pci irq %d -> rerouted to legacy " | ||
460 | "irq %d\n", ret, (ret % 4) + 16); | ||
461 | ret = (ret % 4) + 16; | ||
462 | break; | ||
463 | |||
464 | default: | ||
465 | printk(KERN_INFO "not rerouting irq %d to legacy irq: " | ||
466 | "unknown mapping\n", ret); | ||
467 | break; | ||
468 | } | ||
469 | } | ||
470 | #endif /* CONFIG_X86_IO_APIC */ | ||
471 | |||
416 | return ret; | 472 | return ret; |
417 | } | 473 | } |
418 | 474 | ||
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index cf47805a7448..e52ad91ce2dc 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
@@ -531,7 +531,7 @@ int __init acpi_irq_penalty_init(void) | |||
531 | return 0; | 531 | return 0; |
532 | } | 532 | } |
533 | 533 | ||
534 | static int acpi_irq_balance; /* 0: static, 1: balance */ | 534 | static int acpi_irq_balance = -1; /* 0: static, 1: balance */ |
535 | 535 | ||
536 | static int acpi_pci_link_allocate(struct acpi_pci_link *link) | 536 | static int acpi_pci_link_allocate(struct acpi_pci_link *link) |
537 | { | 537 | { |
@@ -709,7 +709,7 @@ int acpi_pci_link_free_irq(acpi_handle handle) | |||
709 | acpi_device_bid(link->device))); | 709 | acpi_device_bid(link->device))); |
710 | 710 | ||
711 | if (link->refcnt == 0) { | 711 | if (link->refcnt == 0) { |
712 | acpi_ut_evaluate_object(link->device->handle, "_DIS", 0, NULL); | 712 | acpi_evaluate_object(link->device->handle, "_DIS", NULL, NULL); |
713 | } | 713 | } |
714 | mutex_unlock(&acpi_link_lock); | 714 | mutex_unlock(&acpi_link_lock); |
715 | return (link->irq.active); | 715 | return (link->irq.active); |
@@ -737,7 +737,7 @@ static int acpi_pci_link_add(struct acpi_device *device) | |||
737 | link->device = device; | 737 | link->device = device; |
738 | strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME); | 738 | strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME); |
739 | strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS); | 739 | strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS); |
740 | acpi_driver_data(device) = link; | 740 | device->driver_data = link; |
741 | 741 | ||
742 | mutex_lock(&acpi_link_lock); | 742 | mutex_lock(&acpi_link_lock); |
743 | result = acpi_pci_link_get_possible(link); | 743 | result = acpi_pci_link_get_possible(link); |
@@ -773,7 +773,7 @@ static int acpi_pci_link_add(struct acpi_device *device) | |||
773 | 773 | ||
774 | end: | 774 | end: |
775 | /* disable all links -- to be activated on use */ | 775 | /* disable all links -- to be activated on use */ |
776 | acpi_ut_evaluate_object(device->handle, "_DIS", 0, NULL); | 776 | acpi_evaluate_object(device->handle, "_DIS", NULL, NULL); |
777 | mutex_unlock(&acpi_link_lock); | 777 | mutex_unlock(&acpi_link_lock); |
778 | 778 | ||
779 | if (result) | 779 | if (result) |
@@ -950,10 +950,17 @@ device_initcall(irqrouter_init_sysfs); | |||
950 | 950 | ||
951 | static int __init acpi_pci_link_init(void) | 951 | static int __init acpi_pci_link_init(void) |
952 | { | 952 | { |
953 | |||
954 | if (acpi_noirq) | 953 | if (acpi_noirq) |
955 | return 0; | 954 | return 0; |
956 | 955 | ||
956 | if (acpi_irq_balance == -1) { | ||
957 | /* no command line switch: enable balancing in IOAPIC mode */ | ||
958 | if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) | ||
959 | acpi_irq_balance = 1; | ||
960 | else | ||
961 | acpi_irq_balance = 0; | ||
962 | } | ||
963 | |||
957 | acpi_link.count = 0; | 964 | acpi_link.count = 0; |
958 | INIT_LIST_HEAD(&acpi_link.entries); | 965 | INIT_LIST_HEAD(&acpi_link.entries); |
959 | 966 | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index c3fed31166b5..642554b1b60c 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -190,7 +190,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) | |||
190 | struct acpi_pci_root *root = NULL; | 190 | struct acpi_pci_root *root = NULL; |
191 | struct acpi_pci_root *tmp; | 191 | struct acpi_pci_root *tmp; |
192 | acpi_status status = AE_OK; | 192 | acpi_status status = AE_OK; |
193 | unsigned long value = 0; | 193 | unsigned long long value = 0; |
194 | acpi_handle handle = NULL; | 194 | acpi_handle handle = NULL; |
195 | struct acpi_device *child; | 195 | struct acpi_device *child; |
196 | 196 | ||
@@ -206,7 +206,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) | |||
206 | root->device = device; | 206 | root->device = device; |
207 | strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); | 207 | strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); |
208 | strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); | 208 | strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); |
209 | acpi_driver_data(device) = root; | 209 | device->driver_data = root; |
210 | 210 | ||
211 | device->ops.bind = acpi_pci_bind; | 211 | device->ops.bind = acpi_pci_bind; |
212 | 212 | ||
@@ -376,15 +376,9 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type) | |||
376 | 376 | ||
377 | static int __init acpi_pci_root_init(void) | 377 | static int __init acpi_pci_root_init(void) |
378 | { | 378 | { |
379 | |||
380 | if (acpi_pci_disabled) | 379 | if (acpi_pci_disabled) |
381 | return 0; | 380 | return 0; |
382 | 381 | ||
383 | /* DEBUG: | ||
384 | acpi_dbg_layer = ACPI_PCI_COMPONENT; | ||
385 | acpi_dbg_level = 0xFFFFFFFF; | ||
386 | */ | ||
387 | |||
388 | if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) | 382 | if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) |
389 | return -ENODEV; | 383 | return -ENODEV; |
390 | 384 | ||
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c index d5b4ef898879..cd1f4467be7b 100644 --- a/drivers/acpi/pci_slot.c +++ b/drivers/acpi/pci_slot.c | |||
@@ -76,10 +76,10 @@ static struct acpi_pci_driver acpi_pci_slot_driver = { | |||
76 | }; | 76 | }; |
77 | 77 | ||
78 | static int | 78 | static int |
79 | check_slot(acpi_handle handle, unsigned long *sun) | 79 | check_slot(acpi_handle handle, unsigned long long *sun) |
80 | { | 80 | { |
81 | int device = -1; | 81 | int device = -1; |
82 | unsigned long adr, sta; | 82 | unsigned long long adr, sta; |
83 | acpi_status status; | 83 | acpi_status status; |
84 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 84 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
85 | 85 | ||
@@ -132,7 +132,7 @@ static acpi_status | |||
132 | register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | 132 | register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) |
133 | { | 133 | { |
134 | int device; | 134 | int device; |
135 | unsigned long sun; | 135 | unsigned long long sun; |
136 | char name[SLOT_NAME_SIZE]; | 136 | char name[SLOT_NAME_SIZE]; |
137 | struct acpi_pci_slot *slot; | 137 | struct acpi_pci_slot *slot; |
138 | struct pci_slot *pci_slot; | 138 | struct pci_slot *pci_slot; |
@@ -150,7 +150,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
150 | } | 150 | } |
151 | 151 | ||
152 | snprintf(name, sizeof(name), "%u", (u32)sun); | 152 | snprintf(name, sizeof(name), "%u", (u32)sun); |
153 | pci_slot = pci_create_slot(pci_bus, device, name); | 153 | pci_slot = pci_create_slot(pci_bus, device, name, NULL); |
154 | if (IS_ERR(pci_slot)) { | 154 | if (IS_ERR(pci_slot)) { |
155 | err("pci_create_slot returned %ld\n", PTR_ERR(pci_slot)); | 155 | err("pci_create_slot returned %ld\n", PTR_ERR(pci_slot)); |
156 | kfree(slot); | 156 | kfree(slot); |
@@ -182,7 +182,7 @@ static acpi_status | |||
182 | walk_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | 182 | walk_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) |
183 | { | 183 | { |
184 | int device, function; | 184 | int device, function; |
185 | unsigned long adr; | 185 | unsigned long long adr; |
186 | acpi_status status; | 186 | acpi_status status; |
187 | acpi_handle dummy_handle; | 187 | acpi_handle dummy_handle; |
188 | acpi_walk_callback user_function; | 188 | acpi_walk_callback user_function; |
@@ -239,7 +239,7 @@ static int | |||
239 | walk_root_bridge(acpi_handle handle, acpi_walk_callback user_function) | 239 | walk_root_bridge(acpi_handle handle, acpi_walk_callback user_function) |
240 | { | 240 | { |
241 | int seg, bus; | 241 | int seg, bus; |
242 | unsigned long tmp; | 242 | unsigned long long tmp; |
243 | acpi_status status; | 243 | acpi_status status; |
244 | acpi_handle dummy_handle; | 244 | acpi_handle dummy_handle; |
245 | struct pci_bus *pci_bus; | 245 | struct pci_bus *pci_bus; |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 4ab21cb1c8c7..bb7d50dd2818 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -44,9 +44,8 @@ | |||
44 | #include <acpi/acpi_bus.h> | 44 | #include <acpi/acpi_bus.h> |
45 | #include <acpi/acpi_drivers.h> | 45 | #include <acpi/acpi_drivers.h> |
46 | 46 | ||
47 | #define _COMPONENT ACPI_POWER_COMPONENT | 47 | #define _COMPONENT ACPI_POWER_COMPONENT |
48 | ACPI_MODULE_NAME("power"); | 48 | ACPI_MODULE_NAME("power"); |
49 | #define ACPI_POWER_COMPONENT 0x00800000 | ||
50 | #define ACPI_POWER_CLASS "power_resource" | 49 | #define ACPI_POWER_CLASS "power_resource" |
51 | #define ACPI_POWER_DEVICE_NAME "Power Resource" | 50 | #define ACPI_POWER_DEVICE_NAME "Power Resource" |
52 | #define ACPI_POWER_FILE_INFO "info" | 51 | #define ACPI_POWER_FILE_INFO "info" |
@@ -54,6 +53,14 @@ ACPI_MODULE_NAME("power"); | |||
54 | #define ACPI_POWER_RESOURCE_STATE_OFF 0x00 | 53 | #define ACPI_POWER_RESOURCE_STATE_OFF 0x00 |
55 | #define ACPI_POWER_RESOURCE_STATE_ON 0x01 | 54 | #define ACPI_POWER_RESOURCE_STATE_ON 0x01 |
56 | #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF | 55 | #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF |
56 | |||
57 | #ifdef MODULE_PARAM_PREFIX | ||
58 | #undef MODULE_PARAM_PREFIX | ||
59 | #endif | ||
60 | #define MODULE_PARAM_PREFIX "acpi." | ||
61 | int acpi_power_nocheck; | ||
62 | module_param_named(power_nocheck, acpi_power_nocheck, bool, 000); | ||
63 | |||
57 | static int acpi_power_add(struct acpi_device *device); | 64 | static int acpi_power_add(struct acpi_device *device); |
58 | static int acpi_power_remove(struct acpi_device *device, int type); | 65 | static int acpi_power_remove(struct acpi_device *device, int type); |
59 | static int acpi_power_resume(struct acpi_device *device); | 66 | static int acpi_power_resume(struct acpi_device *device); |
@@ -128,16 +135,16 @@ acpi_power_get_context(acpi_handle handle, | |||
128 | return 0; | 135 | return 0; |
129 | } | 136 | } |
130 | 137 | ||
131 | static int acpi_power_get_state(struct acpi_power_resource *resource, int *state) | 138 | static int acpi_power_get_state(acpi_handle handle, int *state) |
132 | { | 139 | { |
133 | acpi_status status = AE_OK; | 140 | acpi_status status = AE_OK; |
134 | unsigned long sta = 0; | 141 | unsigned long long sta = 0; |
135 | 142 | ||
136 | 143 | ||
137 | if (!resource || !state) | 144 | if (!handle || !state) |
138 | return -EINVAL; | 145 | return -EINVAL; |
139 | 146 | ||
140 | status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta); | 147 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); |
141 | if (ACPI_FAILURE(status)) | 148 | if (ACPI_FAILURE(status)) |
142 | return -ENODEV; | 149 | return -ENODEV; |
143 | 150 | ||
@@ -145,7 +152,8 @@ static int acpi_power_get_state(struct acpi_power_resource *resource, int *state | |||
145 | ACPI_POWER_RESOURCE_STATE_OFF; | 152 | ACPI_POWER_RESOURCE_STATE_OFF; |
146 | 153 | ||
147 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", | 154 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", |
148 | resource->name, state ? "on" : "off")); | 155 | acpi_ut_get_node_name(handle), |
156 | *state ? "on" : "off")); | ||
149 | 157 | ||
150 | return 0; | 158 | return 0; |
151 | } | 159 | } |
@@ -153,7 +161,6 @@ static int acpi_power_get_state(struct acpi_power_resource *resource, int *state | |||
153 | static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) | 161 | static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) |
154 | { | 162 | { |
155 | int result = 0, state1; | 163 | int result = 0, state1; |
156 | struct acpi_power_resource *resource = NULL; | ||
157 | u32 i = 0; | 164 | u32 i = 0; |
158 | 165 | ||
159 | 166 | ||
@@ -161,12 +168,15 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) | |||
161 | return -EINVAL; | 168 | return -EINVAL; |
162 | 169 | ||
163 | /* The state of the list is 'on' IFF all resources are 'on'. */ | 170 | /* The state of the list is 'on' IFF all resources are 'on'. */ |
171 | /* */ | ||
164 | 172 | ||
165 | for (i = 0; i < list->count; i++) { | 173 | for (i = 0; i < list->count; i++) { |
166 | result = acpi_power_get_context(list->handles[i], &resource); | 174 | /* |
167 | if (result) | 175 | * The state of the power resource can be obtained by |
168 | return result; | 176 | * using the ACPI handle. In such case it is unnecessary to |
169 | result = acpi_power_get_state(resource, &state1); | 177 | * get the Power resource first and then get its state again. |
178 | */ | ||
179 | result = acpi_power_get_state(list->handles[i], &state1); | ||
170 | if (result) | 180 | if (result) |
171 | return result; | 181 | return result; |
172 | 182 | ||
@@ -226,12 +236,18 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev) | |||
226 | if (ACPI_FAILURE(status)) | 236 | if (ACPI_FAILURE(status)) |
227 | return -ENODEV; | 237 | return -ENODEV; |
228 | 238 | ||
229 | result = acpi_power_get_state(resource, &state); | 239 | if (!acpi_power_nocheck) { |
230 | if (result) | 240 | /* |
231 | return result; | 241 | * If acpi_power_nocheck is set, it is unnecessary to check |
232 | if (state != ACPI_POWER_RESOURCE_STATE_ON) | 242 | * the power state after power transition. |
233 | return -ENOEXEC; | 243 | */ |
234 | 244 | result = acpi_power_get_state(resource->device->handle, | |
245 | &state); | ||
246 | if (result) | ||
247 | return result; | ||
248 | if (state != ACPI_POWER_RESOURCE_STATE_ON) | ||
249 | return -ENOEXEC; | ||
250 | } | ||
235 | /* Update the power resource's _device_ power state */ | 251 | /* Update the power resource's _device_ power state */ |
236 | resource->device->power.state = ACPI_STATE_D0; | 252 | resource->device->power.state = ACPI_STATE_D0; |
237 | 253 | ||
@@ -277,11 +293,17 @@ static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev) | |||
277 | if (ACPI_FAILURE(status)) | 293 | if (ACPI_FAILURE(status)) |
278 | return -ENODEV; | 294 | return -ENODEV; |
279 | 295 | ||
280 | result = acpi_power_get_state(resource, &state); | 296 | if (!acpi_power_nocheck) { |
281 | if (result) | 297 | /* |
282 | return result; | 298 | * If acpi_power_nocheck is set, it is unnecessary to check |
283 | if (state != ACPI_POWER_RESOURCE_STATE_OFF) | 299 | * the power state after power transition. |
284 | return -ENOEXEC; | 300 | */ |
301 | result = acpi_power_get_state(handle, &state); | ||
302 | if (result) | ||
303 | return result; | ||
304 | if (state != ACPI_POWER_RESOURCE_STATE_OFF) | ||
305 | return -ENOEXEC; | ||
306 | } | ||
285 | 307 | ||
286 | /* Update the power resource's _device_ power state */ | 308 | /* Update the power resource's _device_ power state */ |
287 | resource->device->power.state = ACPI_STATE_D3; | 309 | resource->device->power.state = ACPI_STATE_D3; |
@@ -494,11 +516,6 @@ int acpi_power_transition(struct acpi_device *device, int state) | |||
494 | cl = &device->power.states[device->power.state].resources; | 516 | cl = &device->power.states[device->power.state].resources; |
495 | tl = &device->power.states[state].resources; | 517 | tl = &device->power.states[state].resources; |
496 | 518 | ||
497 | if (!cl->count && !tl->count) { | ||
498 | result = -ENODEV; | ||
499 | goto end; | ||
500 | } | ||
501 | |||
502 | /* TBD: Resources must be ordered. */ | 519 | /* TBD: Resources must be ordered. */ |
503 | 520 | ||
504 | /* | 521 | /* |
@@ -555,7 +572,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset) | |||
555 | if (!resource) | 572 | if (!resource) |
556 | goto end; | 573 | goto end; |
557 | 574 | ||
558 | result = acpi_power_get_state(resource, &state); | 575 | result = acpi_power_get_state(resource->device->handle, &state); |
559 | if (result) | 576 | if (result) |
560 | goto end; | 577 | goto end; |
561 | 578 | ||
@@ -657,7 +674,7 @@ static int acpi_power_add(struct acpi_device *device) | |||
657 | strcpy(resource->name, device->pnp.bus_id); | 674 | strcpy(resource->name, device->pnp.bus_id); |
658 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); | 675 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); |
659 | strcpy(acpi_device_class(device), ACPI_POWER_CLASS); | 676 | strcpy(acpi_device_class(device), ACPI_POWER_CLASS); |
660 | acpi_driver_data(device) = resource; | 677 | device->driver_data = resource; |
661 | 678 | ||
662 | /* Evalute the object to get the system level and resource order. */ | 679 | /* Evalute the object to get the system level and resource order. */ |
663 | status = acpi_evaluate_object(device->handle, NULL, NULL, &buffer); | 680 | status = acpi_evaluate_object(device->handle, NULL, NULL, &buffer); |
@@ -668,7 +685,7 @@ static int acpi_power_add(struct acpi_device *device) | |||
668 | resource->system_level = acpi_object.power_resource.system_level; | 685 | resource->system_level = acpi_object.power_resource.system_level; |
669 | resource->order = acpi_object.power_resource.resource_order; | 686 | resource->order = acpi_object.power_resource.resource_order; |
670 | 687 | ||
671 | result = acpi_power_get_state(resource, &state); | 688 | result = acpi_power_get_state(device->handle, &state); |
672 | if (result) | 689 | if (result) |
673 | goto end; | 690 | goto end; |
674 | 691 | ||
@@ -733,9 +750,9 @@ static int acpi_power_resume(struct acpi_device *device) | |||
733 | if (!device || !acpi_driver_data(device)) | 750 | if (!device || !acpi_driver_data(device)) |
734 | return -EINVAL; | 751 | return -EINVAL; |
735 | 752 | ||
736 | resource = (struct acpi_power_resource *)acpi_driver_data(device); | 753 | resource = acpi_driver_data(device); |
737 | 754 | ||
738 | result = acpi_power_get_state(resource, &state); | 755 | result = acpi_power_get_state(device->handle, &state); |
739 | if (result) | 756 | if (result) |
740 | return result; | 757 | return result; |
741 | 758 | ||
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index ee68ac54c0d4..34948362f41d 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #include <acpi/acpi_drivers.h> | 59 | #include <acpi/acpi_drivers.h> |
60 | #include <acpi/processor.h> | 60 | #include <acpi/processor.h> |
61 | 61 | ||
62 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
63 | #define ACPI_PROCESSOR_CLASS "processor" | 62 | #define ACPI_PROCESSOR_CLASS "processor" |
64 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" | 63 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" |
65 | #define ACPI_PROCESSOR_FILE_INFO "info" | 64 | #define ACPI_PROCESSOR_FILE_INFO "info" |
@@ -89,6 +88,7 @@ static int acpi_processor_handle_eject(struct acpi_processor *pr); | |||
89 | 88 | ||
90 | 89 | ||
91 | static const struct acpi_device_id processor_device_ids[] = { | 90 | static const struct acpi_device_id processor_device_ids[] = { |
91 | {ACPI_PROCESSOR_OBJECT_HID, 0}, | ||
92 | {ACPI_PROCESSOR_HID, 0}, | 92 | {ACPI_PROCESSOR_HID, 0}, |
93 | {"", 0}, | 93 | {"", 0}, |
94 | }; | 94 | }; |
@@ -409,7 +409,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device) | |||
409 | /* Use the acpiid in MADT to map cpus in case of SMP */ | 409 | /* Use the acpiid in MADT to map cpus in case of SMP */ |
410 | 410 | ||
411 | #ifndef CONFIG_SMP | 411 | #ifndef CONFIG_SMP |
412 | static int get_cpu_id(acpi_handle handle, u32 acpi_id) {return -1;} | 412 | static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) { return -1; } |
413 | #else | 413 | #else |
414 | 414 | ||
415 | static struct acpi_table_madt *madt; | 415 | static struct acpi_table_madt *madt; |
@@ -428,27 +428,35 @@ static int map_lapic_id(struct acpi_subtable_header *entry, | |||
428 | } | 428 | } |
429 | 429 | ||
430 | static int map_lsapic_id(struct acpi_subtable_header *entry, | 430 | static int map_lsapic_id(struct acpi_subtable_header *entry, |
431 | u32 acpi_id, int *apic_id) | 431 | int device_declaration, u32 acpi_id, int *apic_id) |
432 | { | 432 | { |
433 | struct acpi_madt_local_sapic *lsapic = | 433 | struct acpi_madt_local_sapic *lsapic = |
434 | (struct acpi_madt_local_sapic *)entry; | 434 | (struct acpi_madt_local_sapic *)entry; |
435 | u32 tmp = (lsapic->id << 8) | lsapic->eid; | ||
436 | |||
435 | /* Only check enabled APICs*/ | 437 | /* Only check enabled APICs*/ |
436 | if (lsapic->lapic_flags & ACPI_MADT_ENABLED) { | 438 | if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) |
437 | /* First check against id */ | 439 | return 0; |
438 | if (lsapic->processor_id == acpi_id) { | 440 | |
439 | *apic_id = (lsapic->id << 8) | lsapic->eid; | 441 | /* Device statement declaration type */ |
440 | return 1; | 442 | if (device_declaration) { |
441 | /* Check against optional uid */ | 443 | if (entry->length < 16) |
442 | } else if (entry->length >= 16 && | 444 | printk(KERN_ERR PREFIX |
443 | lsapic->uid == acpi_id) { | 445 | "Invalid LSAPIC with Device type processor (SAPIC ID %#x)\n", |
444 | *apic_id = lsapic->uid; | 446 | tmp); |
445 | return 1; | 447 | else if (lsapic->uid == acpi_id) |
446 | } | 448 | goto found; |
447 | } | 449 | /* Processor statement declaration type */ |
450 | } else if (lsapic->processor_id == acpi_id) | ||
451 | goto found; | ||
452 | |||
448 | return 0; | 453 | return 0; |
454 | found: | ||
455 | *apic_id = tmp; | ||
456 | return 1; | ||
449 | } | 457 | } |
450 | 458 | ||
451 | static int map_madt_entry(u32 acpi_id) | 459 | static int map_madt_entry(int type, u32 acpi_id) |
452 | { | 460 | { |
453 | unsigned long madt_end, entry; | 461 | unsigned long madt_end, entry; |
454 | int apic_id = -1; | 462 | int apic_id = -1; |
@@ -469,7 +477,7 @@ static int map_madt_entry(u32 acpi_id) | |||
469 | if (map_lapic_id(header, acpi_id, &apic_id)) | 477 | if (map_lapic_id(header, acpi_id, &apic_id)) |
470 | break; | 478 | break; |
471 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { | 479 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { |
472 | if (map_lsapic_id(header, acpi_id, &apic_id)) | 480 | if (map_lsapic_id(header, type, acpi_id, &apic_id)) |
473 | break; | 481 | break; |
474 | } | 482 | } |
475 | entry += header->length; | 483 | entry += header->length; |
@@ -477,7 +485,7 @@ static int map_madt_entry(u32 acpi_id) | |||
477 | return apic_id; | 485 | return apic_id; |
478 | } | 486 | } |
479 | 487 | ||
480 | static int map_mat_entry(acpi_handle handle, u32 acpi_id) | 488 | static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) |
481 | { | 489 | { |
482 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 490 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
483 | union acpi_object *obj; | 491 | union acpi_object *obj; |
@@ -500,7 +508,7 @@ static int map_mat_entry(acpi_handle handle, u32 acpi_id) | |||
500 | if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { | 508 | if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { |
501 | map_lapic_id(header, acpi_id, &apic_id); | 509 | map_lapic_id(header, acpi_id, &apic_id); |
502 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { | 510 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { |
503 | map_lsapic_id(header, acpi_id, &apic_id); | 511 | map_lsapic_id(header, type, acpi_id, &apic_id); |
504 | } | 512 | } |
505 | 513 | ||
506 | exit: | 514 | exit: |
@@ -509,14 +517,14 @@ exit: | |||
509 | return apic_id; | 517 | return apic_id; |
510 | } | 518 | } |
511 | 519 | ||
512 | static int get_cpu_id(acpi_handle handle, u32 acpi_id) | 520 | static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) |
513 | { | 521 | { |
514 | int i; | 522 | int i; |
515 | int apic_id = -1; | 523 | int apic_id = -1; |
516 | 524 | ||
517 | apic_id = map_mat_entry(handle, acpi_id); | 525 | apic_id = map_mat_entry(handle, type, acpi_id); |
518 | if (apic_id == -1) | 526 | if (apic_id == -1) |
519 | apic_id = map_madt_entry(acpi_id); | 527 | apic_id = map_madt_entry(type, acpi_id); |
520 | if (apic_id == -1) | 528 | if (apic_id == -1) |
521 | return apic_id; | 529 | return apic_id; |
522 | 530 | ||
@@ -532,15 +540,16 @@ static int get_cpu_id(acpi_handle handle, u32 acpi_id) | |||
532 | Driver Interface | 540 | Driver Interface |
533 | -------------------------------------------------------------------------- */ | 541 | -------------------------------------------------------------------------- */ |
534 | 542 | ||
535 | static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) | 543 | static int acpi_processor_get_info(struct acpi_device *device) |
536 | { | 544 | { |
537 | acpi_status status = 0; | 545 | acpi_status status = 0; |
538 | union acpi_object object = { 0 }; | 546 | union acpi_object object = { 0 }; |
539 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | 547 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; |
540 | int cpu_index; | 548 | struct acpi_processor *pr; |
549 | int cpu_index, device_declaration = 0; | ||
541 | static int cpu0_initialized; | 550 | static int cpu0_initialized; |
542 | 551 | ||
543 | 552 | pr = acpi_driver_data(device); | |
544 | if (!pr) | 553 | if (!pr) |
545 | return -EINVAL; | 554 | return -EINVAL; |
546 | 555 | ||
@@ -561,22 +570,23 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) | |||
561 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 570 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
562 | "No bus mastering arbitration control\n")); | 571 | "No bus mastering arbitration control\n")); |
563 | 572 | ||
564 | /* Check if it is a Device with HID and UID */ | 573 | if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_HID)) { |
565 | if (has_uid) { | 574 | /* |
566 | unsigned long value; | 575 | * Declared with "Device" statement; match _UID. |
576 | * Note that we don't handle string _UIDs yet. | ||
577 | */ | ||
578 | unsigned long long value; | ||
567 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, | 579 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, |
568 | NULL, &value); | 580 | NULL, &value); |
569 | if (ACPI_FAILURE(status)) { | 581 | if (ACPI_FAILURE(status)) { |
570 | printk(KERN_ERR PREFIX "Evaluating processor _UID\n"); | 582 | printk(KERN_ERR PREFIX |
583 | "Evaluating processor _UID [%#x]\n", status); | ||
571 | return -ENODEV; | 584 | return -ENODEV; |
572 | } | 585 | } |
586 | device_declaration = 1; | ||
573 | pr->acpi_id = value; | 587 | pr->acpi_id = value; |
574 | } else { | 588 | } else { |
575 | /* | 589 | /* Declared with "Processor" statement; match ProcessorID */ |
576 | * Evalute the processor object. Note that it is common on SMP to | ||
577 | * have the first (boot) processor with a valid PBLK address while | ||
578 | * all others have a NULL address. | ||
579 | */ | ||
580 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); | 590 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); |
581 | if (ACPI_FAILURE(status)) { | 591 | if (ACPI_FAILURE(status)) { |
582 | printk(KERN_ERR PREFIX "Evaluating processor object\n"); | 592 | printk(KERN_ERR PREFIX "Evaluating processor object\n"); |
@@ -584,12 +594,13 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) | |||
584 | } | 594 | } |
585 | 595 | ||
586 | /* | 596 | /* |
587 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. | 597 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. |
588 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c | 598 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in |
589 | */ | 599 | * arch/xxx/acpi.c |
600 | */ | ||
590 | pr->acpi_id = object.processor.proc_id; | 601 | pr->acpi_id = object.processor.proc_id; |
591 | } | 602 | } |
592 | cpu_index = get_cpu_id(pr->handle, pr->acpi_id); | 603 | cpu_index = get_cpu_id(pr->handle, device_declaration, pr->acpi_id); |
593 | 604 | ||
594 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | 605 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ |
595 | if (!cpu0_initialized && (cpu_index == -1) && | 606 | if (!cpu0_initialized && (cpu_index == -1) && |
@@ -661,7 +672,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) | |||
661 | 672 | ||
662 | pr = acpi_driver_data(device); | 673 | pr = acpi_driver_data(device); |
663 | 674 | ||
664 | result = acpi_processor_get_info(pr, device->flags.unique_id); | 675 | result = acpi_processor_get_info(device); |
665 | if (result) { | 676 | if (result) { |
666 | /* Processor is physically not present */ | 677 | /* Processor is physically not present */ |
667 | return 0; | 678 | return 0; |
@@ -761,20 +772,20 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) | |||
761 | acpi_bus_generate_proc_event(device, event, | 772 | acpi_bus_generate_proc_event(device, event, |
762 | pr->performance_platform_limit); | 773 | pr->performance_platform_limit); |
763 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 774 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
764 | device->dev.bus_id, event, | 775 | dev_name(&device->dev), event, |
765 | pr->performance_platform_limit); | 776 | pr->performance_platform_limit); |
766 | break; | 777 | break; |
767 | case ACPI_PROCESSOR_NOTIFY_POWER: | 778 | case ACPI_PROCESSOR_NOTIFY_POWER: |
768 | acpi_processor_cst_has_changed(pr); | 779 | acpi_processor_cst_has_changed(pr); |
769 | acpi_bus_generate_proc_event(device, event, 0); | 780 | acpi_bus_generate_proc_event(device, event, 0); |
770 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 781 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
771 | device->dev.bus_id, event, 0); | 782 | dev_name(&device->dev), event, 0); |
772 | break; | 783 | break; |
773 | case ACPI_PROCESSOR_NOTIFY_THROTTLING: | 784 | case ACPI_PROCESSOR_NOTIFY_THROTTLING: |
774 | acpi_processor_tstate_has_changed(pr); | 785 | acpi_processor_tstate_has_changed(pr); |
775 | acpi_bus_generate_proc_event(device, event, 0); | 786 | acpi_bus_generate_proc_event(device, event, 0); |
776 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 787 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
777 | device->dev.bus_id, event, 0); | 788 | dev_name(&device->dev), event, 0); |
778 | default: | 789 | default: |
779 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 790 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
780 | "Unsupported event [0x%x]\n", event)); | 791 | "Unsupported event [0x%x]\n", event)); |
@@ -818,7 +829,7 @@ static int acpi_processor_add(struct acpi_device *device) | |||
818 | pr->handle = device->handle; | 829 | pr->handle = device->handle; |
819 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | 830 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); |
820 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); | 831 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); |
821 | acpi_driver_data(device) = pr; | 832 | device->driver_data = pr; |
822 | 833 | ||
823 | return 0; | 834 | return 0; |
824 | } | 835 | } |
@@ -875,7 +886,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type) | |||
875 | static int is_processor_present(acpi_handle handle) | 886 | static int is_processor_present(acpi_handle handle) |
876 | { | 887 | { |
877 | acpi_status status; | 888 | acpi_status status; |
878 | unsigned long sta = 0; | 889 | unsigned long long sta = 0; |
879 | 890 | ||
880 | 891 | ||
881 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | 892 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index cf5b1b7b684f..5f8d746a9b81 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #include <acpi/processor.h> | 59 | #include <acpi/processor.h> |
60 | #include <asm/processor.h> | 60 | #include <asm/processor.h> |
61 | 61 | ||
62 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
63 | #define ACPI_PROCESSOR_CLASS "processor" | 62 | #define ACPI_PROCESSOR_CLASS "processor" |
64 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 63 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
65 | ACPI_MODULE_NAME("processor_idle"); | 64 | ACPI_MODULE_NAME("processor_idle"); |
@@ -1587,6 +1586,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
1587 | 1586 | ||
1588 | if (acpi_idle_bm_check()) { | 1587 | if (acpi_idle_bm_check()) { |
1589 | if (dev->safe_state) { | 1588 | if (dev->safe_state) { |
1589 | dev->last_state = dev->safe_state; | ||
1590 | return dev->safe_state->enter(dev, dev->safe_state); | 1590 | return dev->safe_state->enter(dev, dev->safe_state); |
1591 | } else { | 1591 | } else { |
1592 | local_irq_disable(); | 1592 | local_irq_disable(); |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 80c251ec6d2a..0d7b772bef50 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -39,10 +39,14 @@ | |||
39 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #ifdef CONFIG_X86 | ||
43 | #include <asm/cpufeature.h> | ||
44 | #endif | ||
45 | |||
42 | #include <acpi/acpi_bus.h> | 46 | #include <acpi/acpi_bus.h> |
47 | #include <acpi/acpi_drivers.h> | ||
43 | #include <acpi/processor.h> | 48 | #include <acpi/processor.h> |
44 | 49 | ||
45 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
46 | #define ACPI_PROCESSOR_CLASS "processor" | 50 | #define ACPI_PROCESSOR_CLASS "processor" |
47 | #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" | 51 | #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" |
48 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 52 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
@@ -126,7 +130,7 @@ static struct notifier_block acpi_ppc_notifier_block = { | |||
126 | static int acpi_processor_get_platform_limit(struct acpi_processor *pr) | 130 | static int acpi_processor_get_platform_limit(struct acpi_processor *pr) |
127 | { | 131 | { |
128 | acpi_status status = 0; | 132 | acpi_status status = 0; |
129 | unsigned long ppc = 0; | 133 | unsigned long long ppc = 0; |
130 | 134 | ||
131 | 135 | ||
132 | if (!pr) | 136 | if (!pr) |
@@ -334,7 +338,6 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr) | |||
334 | acpi_status status = AE_OK; | 338 | acpi_status status = AE_OK; |
335 | acpi_handle handle = NULL; | 339 | acpi_handle handle = NULL; |
336 | 340 | ||
337 | |||
338 | if (!pr || !pr->performance || !pr->handle) | 341 | if (!pr || !pr->performance || !pr->handle) |
339 | return -EINVAL; | 342 | return -EINVAL; |
340 | 343 | ||
@@ -347,13 +350,27 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr) | |||
347 | 350 | ||
348 | result = acpi_processor_get_performance_control(pr); | 351 | result = acpi_processor_get_performance_control(pr); |
349 | if (result) | 352 | if (result) |
350 | return result; | 353 | goto update_bios; |
351 | 354 | ||
352 | result = acpi_processor_get_performance_states(pr); | 355 | result = acpi_processor_get_performance_states(pr); |
353 | if (result) | 356 | if (result) |
354 | return result; | 357 | goto update_bios; |
355 | 358 | ||
356 | return 0; | 359 | return 0; |
360 | |||
361 | /* | ||
362 | * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that | ||
363 | * the BIOS is older than the CPU and does not know its frequencies | ||
364 | */ | ||
365 | update_bios: | ||
366 | #ifdef CONFIG_X86 | ||
367 | if (ACPI_SUCCESS(acpi_get_handle(pr->handle, "_PPC", &handle))){ | ||
368 | if(boot_cpu_has(X86_FEATURE_EST)) | ||
369 | printk(KERN_WARNING FW_BUG "BIOS needs update for CPU " | ||
370 | "frequency support\n"); | ||
371 | } | ||
372 | #endif | ||
373 | return result; | ||
357 | } | 374 | } |
358 | 375 | ||
359 | int acpi_processor_notify_smm(struct module *calling_module) | 376 | int acpi_processor_notify_smm(struct module *calling_module) |
@@ -524,13 +541,13 @@ static int acpi_processor_get_psd(struct acpi_processor *pr) | |||
524 | 541 | ||
525 | psd = buffer.pointer; | 542 | psd = buffer.pointer; |
526 | if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) { | 543 | if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) { |
527 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); | 544 | printk(KERN_ERR PREFIX "Invalid _PSD data\n"); |
528 | result = -EFAULT; | 545 | result = -EFAULT; |
529 | goto end; | 546 | goto end; |
530 | } | 547 | } |
531 | 548 | ||
532 | if (psd->package.count != 1) { | 549 | if (psd->package.count != 1) { |
533 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); | 550 | printk(KERN_ERR PREFIX "Invalid _PSD data\n"); |
534 | result = -EFAULT; | 551 | result = -EFAULT; |
535 | goto end; | 552 | goto end; |
536 | } | 553 | } |
@@ -543,19 +560,19 @@ static int acpi_processor_get_psd(struct acpi_processor *pr) | |||
543 | status = acpi_extract_package(&(psd->package.elements[0]), | 560 | status = acpi_extract_package(&(psd->package.elements[0]), |
544 | &format, &state); | 561 | &format, &state); |
545 | if (ACPI_FAILURE(status)) { | 562 | if (ACPI_FAILURE(status)) { |
546 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); | 563 | printk(KERN_ERR PREFIX "Invalid _PSD data\n"); |
547 | result = -EFAULT; | 564 | result = -EFAULT; |
548 | goto end; | 565 | goto end; |
549 | } | 566 | } |
550 | 567 | ||
551 | if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) { | 568 | if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) { |
552 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _PSD:num_entries\n")); | 569 | printk(KERN_ERR PREFIX "Unknown _PSD:num_entries\n"); |
553 | result = -EFAULT; | 570 | result = -EFAULT; |
554 | goto end; | 571 | goto end; |
555 | } | 572 | } |
556 | 573 | ||
557 | if (pdomain->revision != ACPI_PSD_REV0_REVISION) { | 574 | if (pdomain->revision != ACPI_PSD_REV0_REVISION) { |
558 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _PSD:revision\n")); | 575 | printk(KERN_ERR PREFIX "Unknown _PSD:revision\n"); |
559 | result = -EFAULT; | 576 | result = -EFAULT; |
560 | goto end; | 577 | goto end; |
561 | } | 578 | } |
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index ef34b18f95ca..b1eb376fae45 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <acpi/processor.h> | 40 | #include <acpi/processor.h> |
41 | #include <acpi/acpi_drivers.h> | 41 | #include <acpi/acpi_drivers.h> |
42 | 42 | ||
43 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
44 | #define ACPI_PROCESSOR_CLASS "processor" | 43 | #define ACPI_PROCESSOR_CLASS "processor" |
45 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 44 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
46 | ACPI_MODULE_NAME("processor_thermal"); | 45 | ACPI_MODULE_NAME("processor_thermal"); |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index a56fc6c4394b..a0c38c94a8a0 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -38,9 +38,9 @@ | |||
38 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
39 | 39 | ||
40 | #include <acpi/acpi_bus.h> | 40 | #include <acpi/acpi_bus.h> |
41 | #include <acpi/acpi_drivers.h> | ||
41 | #include <acpi/processor.h> | 42 | #include <acpi/processor.h> |
42 | 43 | ||
43 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
44 | #define ACPI_PROCESSOR_CLASS "processor" | 44 | #define ACPI_PROCESSOR_CLASS "processor" |
45 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 45 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
46 | ACPI_MODULE_NAME("processor_throttling"); | 46 | ACPI_MODULE_NAME("processor_throttling"); |
@@ -274,7 +274,7 @@ static int acpi_processor_throttling_notifier(unsigned long event, void *data) | |||
274 | static int acpi_processor_get_platform_limit(struct acpi_processor *pr) | 274 | static int acpi_processor_get_platform_limit(struct acpi_processor *pr) |
275 | { | 275 | { |
276 | acpi_status status = 0; | 276 | acpi_status status = 0; |
277 | unsigned long tpc = 0; | 277 | unsigned long long tpc = 0; |
278 | 278 | ||
279 | if (!pr) | 279 | if (!pr) |
280 | return -EINVAL; | 280 | return -EINVAL; |
@@ -528,13 +528,13 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr) | |||
528 | 528 | ||
529 | tsd = buffer.pointer; | 529 | tsd = buffer.pointer; |
530 | if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) { | 530 | if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) { |
531 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); | 531 | printk(KERN_ERR PREFIX "Invalid _TSD data\n"); |
532 | result = -EFAULT; | 532 | result = -EFAULT; |
533 | goto end; | 533 | goto end; |
534 | } | 534 | } |
535 | 535 | ||
536 | if (tsd->package.count != 1) { | 536 | if (tsd->package.count != 1) { |
537 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); | 537 | printk(KERN_ERR PREFIX "Invalid _TSD data\n"); |
538 | result = -EFAULT; | 538 | result = -EFAULT; |
539 | goto end; | 539 | goto end; |
540 | } | 540 | } |
@@ -547,19 +547,19 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr) | |||
547 | status = acpi_extract_package(&(tsd->package.elements[0]), | 547 | status = acpi_extract_package(&(tsd->package.elements[0]), |
548 | &format, &state); | 548 | &format, &state); |
549 | if (ACPI_FAILURE(status)) { | 549 | if (ACPI_FAILURE(status)) { |
550 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); | 550 | printk(KERN_ERR PREFIX "Invalid _TSD data\n"); |
551 | result = -EFAULT; | 551 | result = -EFAULT; |
552 | goto end; | 552 | goto end; |
553 | } | 553 | } |
554 | 554 | ||
555 | if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) { | 555 | if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) { |
556 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:num_entries\n")); | 556 | printk(KERN_ERR PREFIX "Unknown _TSD:num_entries\n"); |
557 | result = -EFAULT; | 557 | result = -EFAULT; |
558 | goto end; | 558 | goto end; |
559 | } | 559 | } |
560 | 560 | ||
561 | if (pdomain->revision != ACPI_TSD_REV0_REVISION) { | 561 | if (pdomain->revision != ACPI_TSD_REV0_REVISION) { |
562 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:revision\n")); | 562 | printk(KERN_ERR PREFIX "Unknown _TSD:revision\n"); |
563 | result = -EFAULT; | 563 | result = -EFAULT; |
564 | goto end; | 564 | goto end; |
565 | } | 565 | } |
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index d9063ea414e3..8eaaecf92009 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/acresrc.h> | 45 | #include <acpi/acresrc.h> |
46 | #include <acpi/amlcode.h> | ||
47 | #include <acpi/acnamesp.h> | 46 | #include <acpi/acnamesp.h> |
48 | 47 | ||
49 | #define _COMPONENT ACPI_RESOURCES | 48 | #define _COMPONENT ACPI_RESOURCES |
@@ -560,8 +559,8 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
560 | ACPI_GET_OBJECT_TYPE(*sub_object_list)) || | 559 | ACPI_GET_OBJECT_TYPE(*sub_object_list)) || |
561 | ((ACPI_TYPE_LOCAL_REFERENCE == | 560 | ((ACPI_TYPE_LOCAL_REFERENCE == |
562 | ACPI_GET_OBJECT_TYPE(*sub_object_list)) && | 561 | ACPI_GET_OBJECT_TYPE(*sub_object_list)) && |
563 | ((*sub_object_list)->reference.opcode == | 562 | ((*sub_object_list)->reference.class == |
564 | AML_INT_NAMEPATH_OP)))) { | 563 | ACPI_REFCLASS_NAME)))) { |
565 | name_found = TRUE; | 564 | name_found = TRUE; |
566 | } else { | 565 | } else { |
567 | /* Look at the next element */ | 566 | /* Look at the next element */ |
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 7804a8c40e7a..c0bbfa2c4193 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/acresrc.h> | 45 | #include <acpi/acresrc.h> |
46 | #include <acpi/amlcode.h> | ||
47 | #include <acpi/acnamesp.h> | 46 | #include <acpi/acnamesp.h> |
48 | 47 | ||
49 | #define _COMPONENT ACPI_RESOURCES | 48 | #define _COMPONENT ACPI_RESOURCES |
@@ -310,13 +309,12 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
310 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { | 309 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
311 | case ACPI_TYPE_LOCAL_REFERENCE: | 310 | case ACPI_TYPE_LOCAL_REFERENCE: |
312 | 311 | ||
313 | if (obj_desc->reference.opcode != | 312 | if (obj_desc->reference.class != |
314 | AML_INT_NAMEPATH_OP) { | 313 | ACPI_REFCLASS_NAME) { |
315 | ACPI_ERROR((AE_INFO, | 314 | ACPI_ERROR((AE_INFO, |
316 | "(PRT[%X].Source) Need name, found reference op %X", | 315 | "(PRT[%X].Source) Need name, found Reference Class %X", |
317 | index, | 316 | index, |
318 | obj_desc->reference. | 317 | obj_desc->reference.class)); |
319 | opcode)); | ||
320 | return_ACPI_STATUS(AE_BAD_DATA); | 318 | return_ACPI_STATUS(AE_BAD_DATA); |
321 | } | 319 | } |
322 | 320 | ||
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 7b011e7e29fe..6050ce481873 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -931,7 +931,7 @@ static int acpi_sbs_add(struct acpi_device *device) | |||
931 | sbs->device = device; | 931 | sbs->device = device; |
932 | strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME); | 932 | strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME); |
933 | strcpy(acpi_device_class(device), ACPI_SBS_CLASS); | 933 | strcpy(acpi_device_class(device), ACPI_SBS_CLASS); |
934 | acpi_driver_data(device) = sbs; | 934 | device->driver_data = sbs; |
935 | 935 | ||
936 | result = acpi_charger_add(sbs); | 936 | result = acpi_charger_add(sbs); |
937 | if (result) | 937 | if (result) |
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index a4e3767b8c64..e53e590252c0 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c | |||
@@ -258,7 +258,7 @@ extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, | |||
258 | static int acpi_smbus_hc_add(struct acpi_device *device) | 258 | static int acpi_smbus_hc_add(struct acpi_device *device) |
259 | { | 259 | { |
260 | int status; | 260 | int status; |
261 | unsigned long val; | 261 | unsigned long long val; |
262 | struct acpi_smb_hc *hc; | 262 | struct acpi_smb_hc *hc; |
263 | 263 | ||
264 | if (!device) | 264 | if (!device) |
@@ -282,7 +282,7 @@ static int acpi_smbus_hc_add(struct acpi_device *device) | |||
282 | hc->ec = acpi_driver_data(device->parent); | 282 | hc->ec = acpi_driver_data(device->parent); |
283 | hc->offset = (val >> 8) & 0xff; | 283 | hc->offset = (val >> 8) & 0xff; |
284 | hc->query_bit = val & 0xff; | 284 | hc->query_bit = val & 0xff; |
285 | acpi_driver_data(device) = hc; | 285 | device->driver_data = hc; |
286 | 286 | ||
287 | acpi_ec_add_query_handler(hc->ec, hc->query_bit, NULL, smbus_alarm, hc); | 287 | acpi_ec_add_query_handler(hc->ec, hc->query_bit, NULL, smbus_alarm, hc); |
288 | printk(KERN_INFO PREFIX "SBS HC: EC = 0x%p, offset = 0x%0x, query_bit = 0x%0x\n", | 288 | printk(KERN_INFO PREFIX "SBS HC: EC = 0x%p, offset = 0x%0x, query_bit = 0x%0x\n", |
@@ -303,7 +303,7 @@ static int acpi_smbus_hc_remove(struct acpi_device *device, int type) | |||
303 | hc = acpi_driver_data(device); | 303 | hc = acpi_driver_data(device); |
304 | acpi_ec_remove_query_handler(hc->ec, hc->query_bit); | 304 | acpi_ec_remove_query_handler(hc->ec, hc->query_bit); |
305 | kfree(hc); | 305 | kfree(hc); |
306 | acpi_driver_data(device) = NULL; | 306 | device->driver_data = NULL; |
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | 309 | ||
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index f6f52c1a2aba..39b7233c3485 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -109,20 +109,19 @@ static int acpi_bus_hot_remove_device(void *context) | |||
109 | return 0; | 109 | return 0; |
110 | 110 | ||
111 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 111 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
112 | "Hot-removing device %s...\n", device->dev.bus_id)); | 112 | "Hot-removing device %s...\n", dev_name(&device->dev))); |
113 | |||
114 | 113 | ||
115 | if (acpi_bus_trim(device, 1)) { | 114 | if (acpi_bus_trim(device, 1)) { |
116 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 115 | printk(KERN_ERR PREFIX |
117 | "Removing device failed\n")); | 116 | "Removing device failed\n"); |
118 | return -1; | 117 | return -1; |
119 | } | 118 | } |
120 | 119 | ||
121 | /* power off device */ | 120 | /* power off device */ |
122 | status = acpi_evaluate_object(handle, "_PS3", NULL, NULL); | 121 | status = acpi_evaluate_object(handle, "_PS3", NULL, NULL); |
123 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) | 122 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) |
124 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 123 | printk(KERN_WARNING PREFIX |
125 | "Power-off device failed\n")); | 124 | "Power-off device failed\n"); |
126 | 125 | ||
127 | if (device->flags.lockable) { | 126 | if (device->flags.lockable) { |
128 | arg_list.count = 1; | 127 | arg_list.count = 1; |
@@ -276,6 +275,13 @@ int acpi_match_device_ids(struct acpi_device *device, | |||
276 | { | 275 | { |
277 | const struct acpi_device_id *id; | 276 | const struct acpi_device_id *id; |
278 | 277 | ||
278 | /* | ||
279 | * If the device is not present, it is unnecessary to load device | ||
280 | * driver for it. | ||
281 | */ | ||
282 | if (!device->status.present) | ||
283 | return -ENODEV; | ||
284 | |||
279 | if (device->flags.hardware_id) { | 285 | if (device->flags.hardware_id) { |
280 | for (id = ids; id->id[0]; id++) { | 286 | for (id = ids; id->id[0]; id++) { |
281 | if (!strcmp((char*)id->id, device->pnp.hardware_id)) | 287 | if (!strcmp((char*)id->id, device->pnp.hardware_id)) |
@@ -384,7 +390,7 @@ static int acpi_device_remove(struct device * dev) | |||
384 | acpi_drv->ops.remove(acpi_dev, acpi_dev->removal_type); | 390 | acpi_drv->ops.remove(acpi_dev, acpi_dev->removal_type); |
385 | } | 391 | } |
386 | acpi_dev->driver = NULL; | 392 | acpi_dev->driver = NULL; |
387 | acpi_driver_data(dev) = NULL; | 393 | acpi_dev->driver_data = NULL; |
388 | 394 | ||
389 | put_device(dev); | 395 | put_device(dev); |
390 | return 0; | 396 | return 0; |
@@ -453,7 +459,7 @@ static int acpi_device_register(struct acpi_device *device, | |||
453 | acpi_device_bus_id->instance_no = 0; | 459 | acpi_device_bus_id->instance_no = 0; |
454 | list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); | 460 | list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); |
455 | } | 461 | } |
456 | sprintf(device->dev.bus_id, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); | 462 | dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); |
457 | 463 | ||
458 | if (device->parent) { | 464 | if (device->parent) { |
459 | list_add_tail(&device->node, &device->parent->children); | 465 | list_add_tail(&device->node, &device->parent->children); |
@@ -477,7 +483,8 @@ static int acpi_device_register(struct acpi_device *device, | |||
477 | 483 | ||
478 | result = acpi_device_setup_files(device); | 484 | result = acpi_device_setup_files(device); |
479 | if(result) | 485 | if(result) |
480 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error creating sysfs interface for device %s\n", device->dev.bus_id)); | 486 | printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", |
487 | dev_name(&device->dev)); | ||
481 | 488 | ||
482 | device->removal_type = ACPI_BUS_REMOVAL_NORMAL; | 489 | device->removal_type = ACPI_BUS_REMOVAL_NORMAL; |
483 | return 0; | 490 | return 0; |
@@ -537,7 +544,7 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) | |||
537 | result = driver->ops.add(device); | 544 | result = driver->ops.add(device); |
538 | if (result) { | 545 | if (result) { |
539 | device->driver = NULL; | 546 | device->driver = NULL; |
540 | acpi_driver_data(device) = NULL; | 547 | device->driver_data = NULL; |
541 | return result; | 548 | return result; |
542 | } | 549 | } |
543 | 550 | ||
@@ -807,6 +814,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device) | |||
807 | /* TBD: System wake support and resource requirements. */ | 814 | /* TBD: System wake support and resource requirements. */ |
808 | 815 | ||
809 | device->power.state = ACPI_STATE_UNKNOWN; | 816 | device->power.state = ACPI_STATE_UNKNOWN; |
817 | acpi_bus_get_power(device->handle, &(device->power.state)); | ||
810 | 818 | ||
811 | return 0; | 819 | return 0; |
812 | } | 820 | } |
@@ -901,36 +909,6 @@ static void acpi_device_get_busid(struct acpi_device *device, | |||
901 | } | 909 | } |
902 | } | 910 | } |
903 | 911 | ||
904 | static int | ||
905 | acpi_video_bus_match(struct acpi_device *device) | ||
906 | { | ||
907 | acpi_handle h_dummy; | ||
908 | |||
909 | if (!device) | ||
910 | return -EINVAL; | ||
911 | |||
912 | /* Since there is no HID, CID for ACPI Video drivers, we have | ||
913 | * to check well known required nodes for each feature we support. | ||
914 | */ | ||
915 | |||
916 | /* Does this device able to support video switching ? */ | ||
917 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) && | ||
918 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy))) | ||
919 | return 0; | ||
920 | |||
921 | /* Does this device able to retrieve a video ROM ? */ | ||
922 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy))) | ||
923 | return 0; | ||
924 | |||
925 | /* Does this device able to configure which video head to be POSTed ? */ | ||
926 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) && | ||
927 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) && | ||
928 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy))) | ||
929 | return 0; | ||
930 | |||
931 | return -ENODEV; | ||
932 | } | ||
933 | |||
934 | /* | 912 | /* |
935 | * acpi_bay_match - see if a device is an ejectable driver bay | 913 | * acpi_bay_match - see if a device is an ejectable driver bay |
936 | * | 914 | * |
@@ -1013,7 +991,7 @@ static void acpi_device_set_id(struct acpi_device *device, | |||
1013 | will get autoloaded and the device might still match | 991 | will get autoloaded and the device might still match |
1014 | against another driver. | 992 | against another driver. |
1015 | */ | 993 | */ |
1016 | if (ACPI_SUCCESS(acpi_video_bus_match(device))) | 994 | if (acpi_is_video_device(device)) |
1017 | cid_add = ACPI_VIDEO_HID; | 995 | cid_add = ACPI_VIDEO_HID; |
1018 | else if (ACPI_SUCCESS(acpi_bay_match(device))) | 996 | else if (ACPI_SUCCESS(acpi_bay_match(device))) |
1019 | cid_add = ACPI_BAY_HID; | 997 | cid_add = ACPI_BAY_HID; |
@@ -1025,7 +1003,7 @@ static void acpi_device_set_id(struct acpi_device *device, | |||
1025 | hid = ACPI_POWER_HID; | 1003 | hid = ACPI_POWER_HID; |
1026 | break; | 1004 | break; |
1027 | case ACPI_BUS_TYPE_PROCESSOR: | 1005 | case ACPI_BUS_TYPE_PROCESSOR: |
1028 | hid = ACPI_PROCESSOR_HID; | 1006 | hid = ACPI_PROCESSOR_OBJECT_HID; |
1029 | break; | 1007 | break; |
1030 | case ACPI_BUS_TYPE_SYSTEM: | 1008 | case ACPI_BUS_TYPE_SYSTEM: |
1031 | hid = ACPI_SYSTEM_HID; | 1009 | hid = ACPI_SYSTEM_HID; |
@@ -1153,20 +1131,6 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) | |||
1153 | } | 1131 | } |
1154 | 1132 | ||
1155 | static int | 1133 | static int |
1156 | acpi_is_child_device(struct acpi_device *device, | ||
1157 | int (*matcher)(struct acpi_device *)) | ||
1158 | { | ||
1159 | int result = -ENODEV; | ||
1160 | |||
1161 | do { | ||
1162 | if (ACPI_SUCCESS(matcher(device))) | ||
1163 | return AE_OK; | ||
1164 | } while ((device = device->parent)); | ||
1165 | |||
1166 | return result; | ||
1167 | } | ||
1168 | |||
1169 | static int | ||
1170 | acpi_add_single_object(struct acpi_device **child, | 1134 | acpi_add_single_object(struct acpi_device **child, |
1171 | struct acpi_device *parent, acpi_handle handle, int type, | 1135 | struct acpi_device *parent, acpi_handle handle, int type, |
1172 | struct acpi_bus_ops *ops) | 1136 | struct acpi_bus_ops *ops) |
@@ -1221,15 +1185,18 @@ acpi_add_single_object(struct acpi_device **child, | |||
1221 | result = -ENODEV; | 1185 | result = -ENODEV; |
1222 | goto end; | 1186 | goto end; |
1223 | } | 1187 | } |
1224 | if (!device->status.present) { | 1188 | /* |
1225 | /* Bay and dock should be handled even if absent */ | 1189 | * When the device is neither present nor functional, the |
1226 | if (!ACPI_SUCCESS( | 1190 | * device should not be added to Linux ACPI device tree. |
1227 | acpi_is_child_device(device, acpi_bay_match)) && | 1191 | * When the status of the device is not present but functinal, |
1228 | !ACPI_SUCCESS( | 1192 | * it should be added to Linux ACPI tree. For example : bay |
1229 | acpi_is_child_device(device, acpi_dock_match))) { | 1193 | * device , dock device. |
1230 | result = -ENODEV; | 1194 | * In such conditions it is unncessary to check whether it is |
1231 | goto end; | 1195 | * bay device or dock device. |
1232 | } | 1196 | */ |
1197 | if (!device->status.present && !device->status.functional) { | ||
1198 | result = -ENODEV; | ||
1199 | goto end; | ||
1233 | } | 1200 | } |
1234 | break; | 1201 | break; |
1235 | default: | 1202 | default: |
@@ -1252,6 +1219,16 @@ acpi_add_single_object(struct acpi_device **child, | |||
1252 | acpi_device_set_id(device, parent, handle, type); | 1219 | acpi_device_set_id(device, parent, handle, type); |
1253 | 1220 | ||
1254 | /* | 1221 | /* |
1222 | * The ACPI device is attached to acpi handle before getting | ||
1223 | * the power/wakeup/peformance flags. Otherwise OS can't get | ||
1224 | * the corresponding ACPI device by the acpi handle in the course | ||
1225 | * of getting the power/wakeup/performance flags. | ||
1226 | */ | ||
1227 | result = acpi_device_set_context(device, type); | ||
1228 | if (result) | ||
1229 | goto end; | ||
1230 | |||
1231 | /* | ||
1255 | * Power Management | 1232 | * Power Management |
1256 | * ---------------- | 1233 | * ---------------- |
1257 | */ | 1234 | */ |
@@ -1281,8 +1258,6 @@ acpi_add_single_object(struct acpi_device **child, | |||
1281 | goto end; | 1258 | goto end; |
1282 | } | 1259 | } |
1283 | 1260 | ||
1284 | if ((result = acpi_device_set_context(device, type))) | ||
1285 | goto end; | ||
1286 | 1261 | ||
1287 | result = acpi_device_register(device, parent); | 1262 | result = acpi_device_register(device, parent); |
1288 | 1263 | ||
@@ -1402,7 +1377,12 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) | |||
1402 | * TBD: Need notifications and other detection mechanisms | 1377 | * TBD: Need notifications and other detection mechanisms |
1403 | * in place before we can fully implement this. | 1378 | * in place before we can fully implement this. |
1404 | */ | 1379 | */ |
1405 | if (child->status.present) { | 1380 | /* |
1381 | * When the device is not present but functional, it is also | ||
1382 | * necessary to scan the children of this device. | ||
1383 | */ | ||
1384 | if (child->status.present || (!child->status.present && | ||
1385 | child->status.functional)) { | ||
1406 | status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, | 1386 | status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, |
1407 | NULL, NULL); | 1387 | NULL, NULL); |
1408 | if (ACPI_SUCCESS(status)) { | 1388 | if (ACPI_SUCCESS(status)) { |
@@ -1545,7 +1525,6 @@ static int acpi_bus_scan_fixed(struct acpi_device *root) | |||
1545 | return result; | 1525 | return result; |
1546 | } | 1526 | } |
1547 | 1527 | ||
1548 | int __init acpi_boot_ec_enable(void); | ||
1549 | 1528 | ||
1550 | static int __init acpi_scan_init(void) | 1529 | static int __init acpi_scan_init(void) |
1551 | { | 1530 | { |
@@ -1579,9 +1558,6 @@ static int __init acpi_scan_init(void) | |||
1579 | */ | 1558 | */ |
1580 | result = acpi_bus_scan_fixed(acpi_root); | 1559 | result = acpi_bus_scan_fixed(acpi_root); |
1581 | 1560 | ||
1582 | /* EC region might be needed at bus_scan, so enable it now */ | ||
1583 | acpi_boot_ec_enable(); | ||
1584 | |||
1585 | if (!result) | 1561 | if (!result) |
1586 | result = acpi_bus_scan(acpi_root, &ops); | 1562 | result = acpi_bus_scan(acpi_root, &ops); |
1587 | 1563 | ||
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index d13194a031bf..28a691cc625e 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/dmi.h> | 15 | #include <linux/dmi.h> |
16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
17 | #include <linux/suspend.h> | 17 | #include <linux/suspend.h> |
18 | #include <linux/reboot.h> | ||
18 | 19 | ||
19 | #include <asm/io.h> | 20 | #include <asm/io.h> |
20 | 21 | ||
@@ -24,6 +25,36 @@ | |||
24 | 25 | ||
25 | u8 sleep_states[ACPI_S_STATE_COUNT]; | 26 | u8 sleep_states[ACPI_S_STATE_COUNT]; |
26 | 27 | ||
28 | static void acpi_sleep_tts_switch(u32 acpi_state) | ||
29 | { | ||
30 | union acpi_object in_arg = { ACPI_TYPE_INTEGER }; | ||
31 | struct acpi_object_list arg_list = { 1, &in_arg }; | ||
32 | acpi_status status = AE_OK; | ||
33 | |||
34 | in_arg.integer.value = acpi_state; | ||
35 | status = acpi_evaluate_object(NULL, "\\_TTS", &arg_list, NULL); | ||
36 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
37 | /* | ||
38 | * OS can't evaluate the _TTS object correctly. Some warning | ||
39 | * message will be printed. But it won't break anything. | ||
40 | */ | ||
41 | printk(KERN_NOTICE "Failure in evaluating _TTS object\n"); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | static int tts_notify_reboot(struct notifier_block *this, | ||
46 | unsigned long code, void *x) | ||
47 | { | ||
48 | acpi_sleep_tts_switch(ACPI_STATE_S5); | ||
49 | return NOTIFY_DONE; | ||
50 | } | ||
51 | |||
52 | static struct notifier_block tts_notifier = { | ||
53 | .notifier_call = tts_notify_reboot, | ||
54 | .next = NULL, | ||
55 | .priority = 0, | ||
56 | }; | ||
57 | |||
27 | static int acpi_sleep_prepare(u32 acpi_state) | 58 | static int acpi_sleep_prepare(u32 acpi_state) |
28 | { | 59 | { |
29 | #ifdef CONFIG_ACPI_SLEEP | 60 | #ifdef CONFIG_ACPI_SLEEP |
@@ -45,9 +76,8 @@ static int acpi_sleep_prepare(u32 acpi_state) | |||
45 | return 0; | 76 | return 0; |
46 | } | 77 | } |
47 | 78 | ||
48 | #ifdef CONFIG_PM_SLEEP | 79 | #ifdef CONFIG_ACPI_SLEEP |
49 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; | 80 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; |
50 | |||
51 | /* | 81 | /* |
52 | * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the | 82 | * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the |
53 | * user to request that behavior by using the 'acpi_old_suspend_ordering' | 83 | * user to request that behavior by using the 'acpi_old_suspend_ordering' |
@@ -60,6 +90,18 @@ void __init acpi_old_suspend_ordering(void) | |||
60 | old_suspend_ordering = true; | 90 | old_suspend_ordering = true; |
61 | } | 91 | } |
62 | 92 | ||
93 | /* | ||
94 | * According to the ACPI specification the BIOS should make sure that ACPI is | ||
95 | * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still, | ||
96 | * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI | ||
97 | * on such systems during resume. Unfortunately that doesn't help in | ||
98 | * particularly pathological cases in which SCI_EN has to be set directly on | ||
99 | * resume, although the specification states very clearly that this flag is | ||
100 | * owned by the hardware. The set_sci_en_on_resume variable will be set in such | ||
101 | * cases. | ||
102 | */ | ||
103 | static bool set_sci_en_on_resume; | ||
104 | |||
63 | /** | 105 | /** |
64 | * acpi_pm_disable_gpes - Disable the GPEs. | 106 | * acpi_pm_disable_gpes - Disable the GPEs. |
65 | */ | 107 | */ |
@@ -131,8 +173,11 @@ static void acpi_pm_end(void) | |||
131 | * failing transition to a sleep state. | 173 | * failing transition to a sleep state. |
132 | */ | 174 | */ |
133 | acpi_target_sleep_state = ACPI_STATE_S0; | 175 | acpi_target_sleep_state = ACPI_STATE_S0; |
176 | acpi_sleep_tts_switch(acpi_target_sleep_state); | ||
134 | } | 177 | } |
135 | #endif /* CONFIG_PM_SLEEP */ | 178 | #else /* !CONFIG_ACPI_SLEEP */ |
179 | #define acpi_target_sleep_state ACPI_STATE_S0 | ||
180 | #endif /* CONFIG_ACPI_SLEEP */ | ||
136 | 181 | ||
137 | #ifdef CONFIG_SUSPEND | 182 | #ifdef CONFIG_SUSPEND |
138 | extern void do_suspend_lowlevel(void); | 183 | extern void do_suspend_lowlevel(void); |
@@ -155,6 +200,7 @@ static int acpi_suspend_begin(suspend_state_t pm_state) | |||
155 | 200 | ||
156 | if (sleep_states[acpi_state]) { | 201 | if (sleep_states[acpi_state]) { |
157 | acpi_target_sleep_state = acpi_state; | 202 | acpi_target_sleep_state = acpi_state; |
203 | acpi_sleep_tts_switch(acpi_target_sleep_state); | ||
158 | } else { | 204 | } else { |
159 | printk(KERN_ERR "ACPI does not support this state: %d\n", | 205 | printk(KERN_ERR "ACPI does not support this state: %d\n", |
160 | pm_state); | 206 | pm_state); |
@@ -200,6 +246,12 @@ static int acpi_suspend_enter(suspend_state_t pm_state) | |||
200 | break; | 246 | break; |
201 | } | 247 | } |
202 | 248 | ||
249 | /* If ACPI is not enabled by the BIOS, we need to enable it here. */ | ||
250 | if (set_sci_en_on_resume) | ||
251 | acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1); | ||
252 | else | ||
253 | acpi_enable(); | ||
254 | |||
203 | /* Reprogram control registers and execute _BFS */ | 255 | /* Reprogram control registers and execute _BFS */ |
204 | acpi_leave_sleep_state_prep(acpi_state); | 256 | acpi_leave_sleep_state_prep(acpi_state); |
205 | 257 | ||
@@ -287,6 +339,12 @@ static int __init init_old_suspend_ordering(const struct dmi_system_id *d) | |||
287 | return 0; | 339 | return 0; |
288 | } | 340 | } |
289 | 341 | ||
342 | static int __init init_set_sci_en_on_resume(const struct dmi_system_id *d) | ||
343 | { | ||
344 | set_sci_en_on_resume = true; | ||
345 | return 0; | ||
346 | } | ||
347 | |||
290 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { | 348 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { |
291 | { | 349 | { |
292 | .callback = init_old_suspend_ordering, | 350 | .callback = init_old_suspend_ordering, |
@@ -296,6 +354,30 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = { | |||
296 | DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"), | 354 | DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"), |
297 | }, | 355 | }, |
298 | }, | 356 | }, |
357 | { | ||
358 | .callback = init_old_suspend_ordering, | ||
359 | .ident = "HP xw4600 Workstation", | ||
360 | .matches = { | ||
361 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
362 | DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"), | ||
363 | }, | ||
364 | }, | ||
365 | { | ||
366 | .callback = init_set_sci_en_on_resume, | ||
367 | .ident = "Apple MacBook 1,1", | ||
368 | .matches = { | ||
369 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."), | ||
370 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"), | ||
371 | }, | ||
372 | }, | ||
373 | { | ||
374 | .callback = init_set_sci_en_on_resume, | ||
375 | .ident = "Apple MacMini 1,1", | ||
376 | .matches = { | ||
377 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."), | ||
378 | DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"), | ||
379 | }, | ||
380 | }, | ||
299 | {}, | 381 | {}, |
300 | }; | 382 | }; |
301 | #endif /* CONFIG_SUSPEND */ | 383 | #endif /* CONFIG_SUSPEND */ |
@@ -313,6 +395,7 @@ void __init acpi_no_s4_hw_signature(void) | |||
313 | static int acpi_hibernation_begin(void) | 395 | static int acpi_hibernation_begin(void) |
314 | { | 396 | { |
315 | acpi_target_sleep_state = ACPI_STATE_S4; | 397 | acpi_target_sleep_state = ACPI_STATE_S4; |
398 | acpi_sleep_tts_switch(acpi_target_sleep_state); | ||
316 | return 0; | 399 | return 0; |
317 | } | 400 | } |
318 | 401 | ||
@@ -376,7 +459,15 @@ static struct platform_hibernation_ops acpi_hibernation_ops = { | |||
376 | */ | 459 | */ |
377 | static int acpi_hibernation_begin_old(void) | 460 | static int acpi_hibernation_begin_old(void) |
378 | { | 461 | { |
379 | int error = acpi_sleep_prepare(ACPI_STATE_S4); | 462 | int error; |
463 | /* | ||
464 | * The _TTS object should always be evaluated before the _PTS object. | ||
465 | * When the old_suspended_ordering is true, the _PTS object is | ||
466 | * evaluated in the acpi_sleep_prepare. | ||
467 | */ | ||
468 | acpi_sleep_tts_switch(ACPI_STATE_S4); | ||
469 | |||
470 | error = acpi_sleep_prepare(ACPI_STATE_S4); | ||
380 | 471 | ||
381 | if (!error) | 472 | if (!error) |
382 | acpi_target_sleep_state = ACPI_STATE_S4; | 473 | acpi_target_sleep_state = ACPI_STATE_S4; |
@@ -444,7 +535,7 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p) | |||
444 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | 535 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); |
445 | struct acpi_device *adev; | 536 | struct acpi_device *adev; |
446 | char acpi_method[] = "_SxD"; | 537 | char acpi_method[] = "_SxD"; |
447 | unsigned long d_min, d_max; | 538 | unsigned long long d_min, d_max; |
448 | 539 | ||
449 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | 540 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { |
450 | printk(KERN_DEBUG "ACPI handle has no context!\n"); | 541 | printk(KERN_DEBUG "ACPI handle has no context!\n"); |
@@ -596,5 +687,10 @@ int __init acpi_sleep_init(void) | |||
596 | pm_power_off = acpi_power_off; | 687 | pm_power_off = acpi_power_off; |
597 | } | 688 | } |
598 | printk(")\n"); | 689 | printk(")\n"); |
690 | /* | ||
691 | * Register the tts_notifier to reboot notifier list so that the _TTS | ||
692 | * object can also be evaluated when the system enters S5. | ||
693 | */ | ||
694 | register_reboot_notifier(&tts_notifier); | ||
599 | return 0; | 695 | return 0; |
600 | } | 696 | } |
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 631ee2ee2ca0..4dbc2271acf5 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c | |||
@@ -367,7 +367,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) | |||
367 | if (ldev) | 367 | if (ldev) |
368 | seq_printf(seq, "%s:%s", | 368 | seq_printf(seq, "%s:%s", |
369 | ldev->bus ? ldev->bus->name : "no-bus", | 369 | ldev->bus ? ldev->bus->name : "no-bus", |
370 | ldev->bus_id); | 370 | dev_name(ldev)); |
371 | seq_printf(seq, "\n"); | 371 | seq_printf(seq, "\n"); |
372 | put_device(ldev); | 372 | put_device(ldev); |
373 | 373 | ||
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c index 38655eb132dc..dea4c23df764 100644 --- a/drivers/acpi/sleep/wakeup.c +++ b/drivers/acpi/sleep/wakeup.c | |||
@@ -88,7 +88,7 @@ void acpi_enable_wakeup_device(u8 sleep_state) | |||
88 | spin_unlock(&acpi_device_lock); | 88 | spin_unlock(&acpi_device_lock); |
89 | if (!dev->wakeup.flags.run_wake) | 89 | if (!dev->wakeup.flags.run_wake) |
90 | acpi_enable_gpe(dev->wakeup.gpe_device, | 90 | acpi_enable_gpe(dev->wakeup.gpe_device, |
91 | dev->wakeup.gpe_number, ACPI_ISR); | 91 | dev->wakeup.gpe_number); |
92 | spin_lock(&acpi_device_lock); | 92 | spin_lock(&acpi_device_lock); |
93 | } | 93 | } |
94 | spin_unlock(&acpi_device_lock); | 94 | spin_unlock(&acpi_device_lock); |
@@ -122,7 +122,7 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
122 | ACPI_GPE_TYPE_WAKE_RUN); | 122 | ACPI_GPE_TYPE_WAKE_RUN); |
123 | /* Re-enable it, since set_gpe_type will disable it */ | 123 | /* Re-enable it, since set_gpe_type will disable it */ |
124 | acpi_enable_gpe(dev->wakeup.gpe_device, | 124 | acpi_enable_gpe(dev->wakeup.gpe_device, |
125 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 125 | dev->wakeup.gpe_number); |
126 | spin_lock(&acpi_device_lock); | 126 | spin_lock(&acpi_device_lock); |
127 | } | 127 | } |
128 | continue; | 128 | continue; |
@@ -133,7 +133,7 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
133 | /* Never disable run-wake GPE */ | 133 | /* Never disable run-wake GPE */ |
134 | if (!dev->wakeup.flags.run_wake) { | 134 | if (!dev->wakeup.flags.run_wake) { |
135 | acpi_disable_gpe(dev->wakeup.gpe_device, | 135 | acpi_disable_gpe(dev->wakeup.gpe_device, |
136 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 136 | dev->wakeup.gpe_number); |
137 | acpi_clear_gpe(dev->wakeup.gpe_device, | 137 | acpi_clear_gpe(dev->wakeup.gpe_device, |
138 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 138 | dev->wakeup.gpe_number, ACPI_NOT_ISR); |
139 | } | 139 | } |
@@ -162,7 +162,7 @@ static int __init acpi_wakeup_device_init(void) | |||
162 | dev->wakeup.gpe_number, | 162 | dev->wakeup.gpe_number, |
163 | ACPI_GPE_TYPE_WAKE_RUN); | 163 | ACPI_GPE_TYPE_WAKE_RUN); |
164 | acpi_enable_gpe(dev->wakeup.gpe_device, | 164 | acpi_enable_gpe(dev->wakeup.gpe_device, |
165 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 165 | dev->wakeup.gpe_number); |
166 | dev->wakeup.state.enabled = 1; | 166 | dev->wakeup.state.enabled = 1; |
167 | spin_lock(&acpi_device_lock); | 167 | spin_lock(&acpi_device_lock); |
168 | } | 168 | } |
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 24e80fd927e2..6e4107f82403 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -78,9 +78,15 @@ static ssize_t acpi_table_show(struct kobject *kobj, | |||
78 | container_of(bin_attr, struct acpi_table_attr, attr); | 78 | container_of(bin_attr, struct acpi_table_attr, attr); |
79 | struct acpi_table_header *table_header = NULL; | 79 | struct acpi_table_header *table_header = NULL; |
80 | acpi_status status; | 80 | acpi_status status; |
81 | char name[ACPI_NAME_SIZE]; | ||
82 | |||
83 | if (strncmp(table_attr->name, "NULL", 4)) | ||
84 | memcpy(name, table_attr->name, ACPI_NAME_SIZE); | ||
85 | else | ||
86 | memcpy(name, "\0\0\0\0", 4); | ||
81 | 87 | ||
82 | status = | 88 | status = |
83 | acpi_get_table(table_attr->name, table_attr->instance, | 89 | acpi_get_table(name, table_attr->instance, |
84 | &table_header); | 90 | &table_header); |
85 | if (ACPI_FAILURE(status)) | 91 | if (ACPI_FAILURE(status)) |
86 | return -ENODEV; | 92 | return -ENODEV; |
@@ -95,21 +101,24 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr, | |||
95 | struct acpi_table_header *header = NULL; | 101 | struct acpi_table_header *header = NULL; |
96 | struct acpi_table_attr *attr = NULL; | 102 | struct acpi_table_attr *attr = NULL; |
97 | 103 | ||
98 | memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE); | 104 | if (table_header->signature[0] != '\0') |
105 | memcpy(table_attr->name, table_header->signature, | ||
106 | ACPI_NAME_SIZE); | ||
107 | else | ||
108 | memcpy(table_attr->name, "NULL", 4); | ||
99 | 109 | ||
100 | list_for_each_entry(attr, &acpi_table_attr_list, node) { | 110 | list_for_each_entry(attr, &acpi_table_attr_list, node) { |
101 | if (!memcmp(table_header->signature, attr->name, | 111 | if (!memcmp(table_attr->name, attr->name, ACPI_NAME_SIZE)) |
102 | ACPI_NAME_SIZE)) | ||
103 | if (table_attr->instance < attr->instance) | 112 | if (table_attr->instance < attr->instance) |
104 | table_attr->instance = attr->instance; | 113 | table_attr->instance = attr->instance; |
105 | } | 114 | } |
106 | table_attr->instance++; | 115 | table_attr->instance++; |
107 | 116 | ||
108 | if (table_attr->instance > 1 || (table_attr->instance == 1 && | 117 | if (table_attr->instance > 1 || (table_attr->instance == 1 && |
109 | !acpi_get_table(table_header-> | 118 | !acpi_get_table |
110 | signature, 2, | 119 | (table_header->signature, 2, &header))) |
111 | &header))) | 120 | sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", |
112 | sprintf(table_attr->name + 4, "%d", table_attr->instance); | 121 | table_attr->instance); |
113 | 122 | ||
114 | table_attr->attr.size = 0; | 123 | table_attr->attr.size = 0; |
115 | table_attr->attr.read = acpi_table_show; | 124 | table_attr->attr.read = acpi_table_show; |
@@ -167,7 +176,6 @@ static int acpi_system_sysfs_init(void) | |||
167 | #define COUNT_ERROR 2 /* other */ | 176 | #define COUNT_ERROR 2 /* other */ |
168 | #define NUM_COUNTERS_EXTRA 3 | 177 | #define NUM_COUNTERS_EXTRA 3 |
169 | 178 | ||
170 | #define ACPI_EVENT_VALID 0x01 | ||
171 | struct event_counter { | 179 | struct event_counter { |
172 | u32 count; | 180 | u32 count; |
173 | u32 flags; | 181 | u32 flags; |
@@ -312,12 +320,6 @@ static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle) | |||
312 | } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS)) | 320 | } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS)) |
313 | result = acpi_get_event_status(index - num_gpes, status); | 321 | result = acpi_get_event_status(index - num_gpes, status); |
314 | 322 | ||
315 | /* | ||
316 | * sleep/power button GPE/Fixed Event is enabled after acpi_system_init, | ||
317 | * check the status at runtime and mark it as valid once it's enabled | ||
318 | */ | ||
319 | if (!result && (*status & ACPI_EVENT_FLAG_ENABLED)) | ||
320 | all_counters[index].flags |= ACPI_EVENT_VALID; | ||
321 | end: | 323 | end: |
322 | return result; | 324 | return result; |
323 | } | 325 | } |
@@ -346,12 +348,14 @@ static ssize_t counter_show(struct kobject *kobj, | |||
346 | if (result) | 348 | if (result) |
347 | goto end; | 349 | goto end; |
348 | 350 | ||
349 | if (!(all_counters[index].flags & ACPI_EVENT_VALID)) | 351 | if (!(status & ACPI_EVENT_FLAG_HANDLE)) |
350 | size += sprintf(buf + size, " invalid"); | 352 | size += sprintf(buf + size, " invalid"); |
351 | else if (status & ACPI_EVENT_FLAG_ENABLED) | 353 | else if (status & ACPI_EVENT_FLAG_ENABLED) |
352 | size += sprintf(buf + size, " enable"); | 354 | size += sprintf(buf + size, " enabled"); |
355 | else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED) | ||
356 | size += sprintf(buf + size, " wake_enabled"); | ||
353 | else | 357 | else |
354 | size += sprintf(buf + size, " disable"); | 358 | size += sprintf(buf + size, " disabled"); |
355 | 359 | ||
356 | end: | 360 | end: |
357 | size += sprintf(buf + size, "\n"); | 361 | size += sprintf(buf + size, "\n"); |
@@ -385,19 +389,19 @@ static ssize_t counter_set(struct kobject *kobj, | |||
385 | if (result) | 389 | if (result) |
386 | goto end; | 390 | goto end; |
387 | 391 | ||
388 | if (!(all_counters[index].flags & ACPI_EVENT_VALID)) { | 392 | if (!(status & ACPI_EVENT_FLAG_HANDLE)) { |
389 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 393 | printk(KERN_WARNING PREFIX |
390 | "Can not change Invalid GPE/Fixed Event status\n")); | 394 | "Can not change Invalid GPE/Fixed Event status\n"); |
391 | return -EINVAL; | 395 | return -EINVAL; |
392 | } | 396 | } |
393 | 397 | ||
394 | if (index < num_gpes) { | 398 | if (index < num_gpes) { |
395 | if (!strcmp(buf, "disable\n") && | 399 | if (!strcmp(buf, "disable\n") && |
396 | (status & ACPI_EVENT_FLAG_ENABLED)) | 400 | (status & ACPI_EVENT_FLAG_ENABLED)) |
397 | result = acpi_disable_gpe(handle, index, ACPI_NOT_ISR); | 401 | result = acpi_disable_gpe(handle, index); |
398 | else if (!strcmp(buf, "enable\n") && | 402 | else if (!strcmp(buf, "enable\n") && |
399 | !(status & ACPI_EVENT_FLAG_ENABLED)) | 403 | !(status & ACPI_EVENT_FLAG_ENABLED)) |
400 | result = acpi_enable_gpe(handle, index, ACPI_NOT_ISR); | 404 | result = acpi_enable_gpe(handle, index); |
401 | else if (!strcmp(buf, "clear\n") && | 405 | else if (!strcmp(buf, "clear\n") && |
402 | (status & ACPI_EVENT_FLAG_SET)) | 406 | (status & ACPI_EVENT_FLAG_SET)) |
403 | result = acpi_clear_gpe(handle, index, ACPI_NOT_ISR); | 407 | result = acpi_clear_gpe(handle, index, ACPI_NOT_ISR); |
diff --git a/drivers/acpi/tables/tbfadt.c b/drivers/acpi/tables/tbfadt.c index a4a41ba2484b..2817158fb6a1 100644 --- a/drivers/acpi/tables/tbfadt.c +++ b/drivers/acpi/tables/tbfadt.c | |||
@@ -50,7 +50,7 @@ ACPI_MODULE_NAME("tbfadt") | |||
50 | /* Local prototypes */ | 50 | /* Local prototypes */ |
51 | static void inline | 51 | static void inline |
52 | acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | 52 | acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, |
53 | u8 bit_width, u64 address); | 53 | u8 byte_width, u64 address); |
54 | 54 | ||
55 | static void acpi_tb_convert_fadt(void); | 55 | static void acpi_tb_convert_fadt(void); |
56 | 56 | ||
@@ -111,7 +111,7 @@ static struct acpi_fadt_info fadt_info_table[] = { | |||
111 | * FUNCTION: acpi_tb_init_generic_address | 111 | * FUNCTION: acpi_tb_init_generic_address |
112 | * | 112 | * |
113 | * PARAMETERS: generic_address - GAS struct to be initialized | 113 | * PARAMETERS: generic_address - GAS struct to be initialized |
114 | * bit_width - Width of this register | 114 | * byte_width - Width of this register |
115 | * Address - Address of the register | 115 | * Address - Address of the register |
116 | * | 116 | * |
117 | * RETURN: None | 117 | * RETURN: None |
@@ -124,7 +124,7 @@ static struct acpi_fadt_info fadt_info_table[] = { | |||
124 | 124 | ||
125 | static void inline | 125 | static void inline |
126 | acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | 126 | acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, |
127 | u8 bit_width, u64 address) | 127 | u8 byte_width, u64 address) |
128 | { | 128 | { |
129 | 129 | ||
130 | /* | 130 | /* |
@@ -136,7 +136,7 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | |||
136 | /* All other fields are byte-wide */ | 136 | /* All other fields are byte-wide */ |
137 | 137 | ||
138 | generic_address->space_id = ACPI_ADR_SPACE_SYSTEM_IO; | 138 | generic_address->space_id = ACPI_ADR_SPACE_SYSTEM_IO; |
139 | generic_address->bit_width = bit_width; | 139 | generic_address->bit_width = byte_width << 3; |
140 | generic_address->bit_offset = 0; | 140 | generic_address->bit_offset = 0; |
141 | generic_address->access_width = 0; | 141 | generic_address->access_width = 0; |
142 | } | 142 | } |
@@ -304,7 +304,7 @@ static void acpi_tb_convert_fadt(void) | |||
304 | * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at | 304 | * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at |
305 | * offset 45, 55, 95, and the word located at offset 109, 110. | 305 | * offset 45, 55, 95, and the word located at offset 109, 110. |
306 | */ | 306 | */ |
307 | if (acpi_gbl_FADT.header.revision < 3) { | 307 | if (acpi_gbl_FADT.header.revision < FADT2_REVISION_ID) { |
308 | acpi_gbl_FADT.preferred_profile = 0; | 308 | acpi_gbl_FADT.preferred_profile = 0; |
309 | acpi_gbl_FADT.pstate_control = 0; | 309 | acpi_gbl_FADT.pstate_control = 0; |
310 | acpi_gbl_FADT.cst_control = 0; | 310 | acpi_gbl_FADT.cst_control = 0; |
@@ -342,9 +342,20 @@ static void acpi_tb_convert_fadt(void) | |||
342 | * useful to calculate them once, here. | 342 | * useful to calculate them once, here. |
343 | * | 343 | * |
344 | * The PM event blocks are split into two register blocks, first is the | 344 | * The PM event blocks are split into two register blocks, first is the |
345 | * PM Status Register block, followed immediately by the PM Enable Register | 345 | * PM Status Register block, followed immediately by the PM Enable |
346 | * block. Each is of length (pm1_event_length/2) | 346 | * Register block. Each is of length (xpm1x_event_block.bit_width/2). |
347 | * | ||
348 | * On various systems the v2 fields (and particularly the bit widths) | ||
349 | * cannot be relied upon, though. Hence resort to using the v1 length | ||
350 | * here (and warn about the inconsistency). | ||
347 | */ | 351 | */ |
352 | if (acpi_gbl_FADT.xpm1a_event_block.bit_width | ||
353 | != acpi_gbl_FADT.pm1_event_length * 8) | ||
354 | printk(KERN_WARNING "FADT: " | ||
355 | "X_PM1a_EVT_BLK.bit_width (%u) does not match" | ||
356 | " PM1_EVT_LEN (%u)\n", | ||
357 | acpi_gbl_FADT.xpm1a_event_block.bit_width, | ||
358 | acpi_gbl_FADT.pm1_event_length); | ||
348 | pm1_register_length = (u8) ACPI_DIV_2(acpi_gbl_FADT.pm1_event_length); | 359 | pm1_register_length = (u8) ACPI_DIV_2(acpi_gbl_FADT.pm1_event_length); |
349 | 360 | ||
350 | /* The PM1A register block is required */ | 361 | /* The PM1A register block is required */ |
@@ -360,13 +371,20 @@ static void acpi_tb_convert_fadt(void) | |||
360 | /* The PM1B register block is optional, ignore if not present */ | 371 | /* The PM1B register block is optional, ignore if not present */ |
361 | 372 | ||
362 | if (acpi_gbl_FADT.xpm1b_event_block.address) { | 373 | if (acpi_gbl_FADT.xpm1b_event_block.address) { |
374 | if (acpi_gbl_FADT.xpm1b_event_block.bit_width | ||
375 | != acpi_gbl_FADT.pm1_event_length * 8) | ||
376 | printk(KERN_WARNING "FADT: " | ||
377 | "X_PM1b_EVT_BLK.bit_width (%u) does not match" | ||
378 | " PM1_EVT_LEN (%u)\n", | ||
379 | acpi_gbl_FADT.xpm1b_event_block.bit_width, | ||
380 | acpi_gbl_FADT.pm1_event_length); | ||
363 | acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, | 381 | acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, |
364 | pm1_register_length, | 382 | pm1_register_length, |
365 | (acpi_gbl_FADT.xpm1b_event_block. | 383 | (acpi_gbl_FADT.xpm1b_event_block. |
366 | address + pm1_register_length)); | 384 | address + pm1_register_length)); |
367 | /* Don't forget to copy space_id of the GAS */ | 385 | /* Don't forget to copy space_id of the GAS */ |
368 | acpi_gbl_xpm1b_enable.space_id = | 386 | acpi_gbl_xpm1b_enable.space_id = |
369 | acpi_gbl_FADT.xpm1a_event_block.space_id; | 387 | acpi_gbl_FADT.xpm1b_event_block.space_id; |
370 | 388 | ||
371 | } | 389 | } |
372 | } | 390 | } |
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index b22185f55a16..18747ce8dd2f 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c | |||
@@ -110,7 +110,6 @@ acpi_status | |||
110 | acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) | 110 | acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) |
111 | { | 111 | { |
112 | u32 i; | 112 | u32 i; |
113 | u32 length; | ||
114 | acpi_status status = AE_OK; | 113 | acpi_status status = AE_OK; |
115 | 114 | ||
116 | ACPI_FUNCTION_TRACE(tb_add_table); | 115 | ACPI_FUNCTION_TRACE(tb_add_table); |
@@ -145,25 +144,64 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) | |||
145 | } | 144 | } |
146 | } | 145 | } |
147 | 146 | ||
148 | length = ACPI_MIN(table_desc->length, | 147 | /* |
149 | acpi_gbl_root_table_list.tables[i].length); | 148 | * Check for a table match on the entire table length, |
149 | * not just the header. | ||
150 | */ | ||
151 | if (table_desc->length != | ||
152 | acpi_gbl_root_table_list.tables[i].length) { | ||
153 | continue; | ||
154 | } | ||
155 | |||
150 | if (ACPI_MEMCMP(table_desc->pointer, | 156 | if (ACPI_MEMCMP(table_desc->pointer, |
151 | acpi_gbl_root_table_list.tables[i].pointer, | 157 | acpi_gbl_root_table_list.tables[i].pointer, |
152 | length)) { | 158 | acpi_gbl_root_table_list.tables[i].length)) { |
153 | continue; | 159 | continue; |
154 | } | 160 | } |
155 | 161 | ||
156 | /* Table is already registered */ | 162 | /* |
157 | 163 | * Note: the current mechanism does not unregister a table if it is | |
164 | * dynamically unloaded. The related namespace entries are deleted, | ||
165 | * but the table remains in the root table list. | ||
166 | * | ||
167 | * The assumption here is that the number of different tables that | ||
168 | * will be loaded is actually small, and there is minimal overhead | ||
169 | * in just keeping the table in case it is needed again. | ||
170 | * | ||
171 | * If this assumption changes in the future (perhaps on large | ||
172 | * machines with many table load/unload operations), tables will | ||
173 | * need to be unregistered when they are unloaded, and slots in the | ||
174 | * root table list should be reused when empty. | ||
175 | */ | ||
176 | |||
177 | /* | ||
178 | * Table is already registered. | ||
179 | * We can delete the table that was passed as a parameter. | ||
180 | */ | ||
158 | acpi_tb_delete_table(table_desc); | 181 | acpi_tb_delete_table(table_desc); |
159 | *table_index = i; | 182 | *table_index = i; |
160 | status = AE_ALREADY_EXISTS; | 183 | |
161 | goto release; | 184 | if (acpi_gbl_root_table_list.tables[i]. |
185 | flags & ACPI_TABLE_IS_LOADED) { | ||
186 | |||
187 | /* Table is still loaded, this is an error */ | ||
188 | |||
189 | status = AE_ALREADY_EXISTS; | ||
190 | goto release; | ||
191 | } else { | ||
192 | /* Table was unloaded, allow it to be reloaded */ | ||
193 | |||
194 | table_desc->pointer = | ||
195 | acpi_gbl_root_table_list.tables[i].pointer; | ||
196 | table_desc->address = | ||
197 | acpi_gbl_root_table_list.tables[i].address; | ||
198 | status = AE_OK; | ||
199 | goto print_header; | ||
200 | } | ||
162 | } | 201 | } |
163 | 202 | ||
164 | /* | 203 | /* Add the table to the global root table list */ |
165 | * Add the table to the global table list | 204 | |
166 | */ | ||
167 | status = acpi_tb_store_table(table_desc->address, table_desc->pointer, | 205 | status = acpi_tb_store_table(table_desc->address, table_desc->pointer, |
168 | table_desc->length, table_desc->flags, | 206 | table_desc->length, table_desc->flags, |
169 | table_index); | 207 | table_index); |
@@ -171,6 +209,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) | |||
171 | goto release; | 209 | goto release; |
172 | } | 210 | } |
173 | 211 | ||
212 | print_header: | ||
174 | acpi_tb_print_table_header(table_desc->address, table_desc->pointer); | 213 | acpi_tb_print_table_header(table_desc->address, table_desc->pointer); |
175 | 214 | ||
176 | release: | 215 | release: |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 912703691d36..073ff09218a9 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #include <acpi/acpi_bus.h> | 47 | #include <acpi/acpi_bus.h> |
48 | #include <acpi/acpi_drivers.h> | 48 | #include <acpi/acpi_drivers.h> |
49 | 49 | ||
50 | #define ACPI_THERMAL_COMPONENT 0x04000000 | ||
51 | #define ACPI_THERMAL_CLASS "thermal_zone" | 50 | #define ACPI_THERMAL_CLASS "thermal_zone" |
52 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" | 51 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" |
53 | #define ACPI_THERMAL_FILE_STATE "state" | 52 | #define ACPI_THERMAL_FILE_STATE "state" |
@@ -246,18 +245,18 @@ static const struct file_operations acpi_thermal_polling_fops = { | |||
246 | static int acpi_thermal_get_temperature(struct acpi_thermal *tz) | 245 | static int acpi_thermal_get_temperature(struct acpi_thermal *tz) |
247 | { | 246 | { |
248 | acpi_status status = AE_OK; | 247 | acpi_status status = AE_OK; |
249 | 248 | unsigned long long tmp; | |
250 | 249 | ||
251 | if (!tz) | 250 | if (!tz) |
252 | return -EINVAL; | 251 | return -EINVAL; |
253 | 252 | ||
254 | tz->last_temperature = tz->temperature; | 253 | tz->last_temperature = tz->temperature; |
255 | 254 | ||
256 | status = | 255 | status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); |
257 | acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tz->temperature); | ||
258 | if (ACPI_FAILURE(status)) | 256 | if (ACPI_FAILURE(status)) |
259 | return -ENODEV; | 257 | return -ENODEV; |
260 | 258 | ||
259 | tz->temperature = tmp; | ||
261 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", | 260 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", |
262 | tz->temperature)); | 261 | tz->temperature)); |
263 | 262 | ||
@@ -267,17 +266,16 @@ static int acpi_thermal_get_temperature(struct acpi_thermal *tz) | |||
267 | static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) | 266 | static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) |
268 | { | 267 | { |
269 | acpi_status status = AE_OK; | 268 | acpi_status status = AE_OK; |
270 | 269 | unsigned long long tmp; | |
271 | 270 | ||
272 | if (!tz) | 271 | if (!tz) |
273 | return -EINVAL; | 272 | return -EINVAL; |
274 | 273 | ||
275 | status = | 274 | status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); |
276 | acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, | ||
277 | &tz->polling_frequency); | ||
278 | if (ACPI_FAILURE(status)) | 275 | if (ACPI_FAILURE(status)) |
279 | return -ENODEV; | 276 | return -ENODEV; |
280 | 277 | ||
278 | tz->polling_frequency = tmp; | ||
281 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", | 279 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", |
282 | tz->polling_frequency)); | 280 | tz->polling_frequency)); |
283 | 281 | ||
@@ -356,6 +354,7 @@ do { \ | |||
356 | static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | 354 | static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) |
357 | { | 355 | { |
358 | acpi_status status = AE_OK; | 356 | acpi_status status = AE_OK; |
357 | unsigned long long tmp; | ||
359 | struct acpi_handle_list devices; | 358 | struct acpi_handle_list devices; |
360 | int valid = 0; | 359 | int valid = 0; |
361 | int i; | 360 | int i; |
@@ -363,7 +362,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
363 | /* Critical Shutdown (required) */ | 362 | /* Critical Shutdown (required) */ |
364 | if (flag & ACPI_TRIPS_CRITICAL) { | 363 | if (flag & ACPI_TRIPS_CRITICAL) { |
365 | status = acpi_evaluate_integer(tz->device->handle, | 364 | status = acpi_evaluate_integer(tz->device->handle, |
366 | "_CRT", NULL, &tz->trips.critical.temperature); | 365 | "_CRT", NULL, &tmp); |
366 | tz->trips.critical.temperature = tmp; | ||
367 | /* | 367 | /* |
368 | * Treat freezing temperatures as invalid as well; some | 368 | * Treat freezing temperatures as invalid as well; some |
369 | * BIOSes return really low values and cause reboots at startup. | 369 | * BIOSes return really low values and cause reboots at startup. |
@@ -388,10 +388,12 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
388 | } else if (crt > 0) { | 388 | } else if (crt > 0) { |
389 | unsigned long crt_k = CELSIUS_TO_KELVIN(crt); | 389 | unsigned long crt_k = CELSIUS_TO_KELVIN(crt); |
390 | /* | 390 | /* |
391 | * Allow override to lower critical threshold | 391 | * Allow override critical threshold |
392 | */ | 392 | */ |
393 | if (crt_k < tz->trips.critical.temperature) | 393 | if (crt_k > tz->trips.critical.temperature) |
394 | tz->trips.critical.temperature = crt_k; | 394 | printk(KERN_WARNING PREFIX |
395 | "Critical threshold %d C\n", crt); | ||
396 | tz->trips.critical.temperature = crt_k; | ||
395 | } | 397 | } |
396 | } | 398 | } |
397 | } | 399 | } |
@@ -399,12 +401,13 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
399 | /* Critical Sleep (optional) */ | 401 | /* Critical Sleep (optional) */ |
400 | if (flag & ACPI_TRIPS_HOT) { | 402 | if (flag & ACPI_TRIPS_HOT) { |
401 | status = acpi_evaluate_integer(tz->device->handle, | 403 | status = acpi_evaluate_integer(tz->device->handle, |
402 | "_HOT", NULL, &tz->trips.hot.temperature); | 404 | "_HOT", NULL, &tmp); |
403 | if (ACPI_FAILURE(status)) { | 405 | if (ACPI_FAILURE(status)) { |
404 | tz->trips.hot.flags.valid = 0; | 406 | tz->trips.hot.flags.valid = 0; |
405 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 407 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
406 | "No hot threshold\n")); | 408 | "No hot threshold\n")); |
407 | } else { | 409 | } else { |
410 | tz->trips.hot.temperature = tmp; | ||
408 | tz->trips.hot.flags.valid = 1; | 411 | tz->trips.hot.flags.valid = 1; |
409 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 412 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
410 | "Found hot threshold [%lu]\n", | 413 | "Found hot threshold [%lu]\n", |
@@ -418,33 +421,40 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
418 | if (psv == -1) { | 421 | if (psv == -1) { |
419 | status = AE_SUPPORT; | 422 | status = AE_SUPPORT; |
420 | } else if (psv > 0) { | 423 | } else if (psv > 0) { |
421 | tz->trips.passive.temperature = CELSIUS_TO_KELVIN(psv); | 424 | tmp = CELSIUS_TO_KELVIN(psv); |
422 | status = AE_OK; | 425 | status = AE_OK; |
423 | } else { | 426 | } else { |
424 | status = acpi_evaluate_integer(tz->device->handle, | 427 | status = acpi_evaluate_integer(tz->device->handle, |
425 | "_PSV", NULL, &tz->trips.passive.temperature); | 428 | "_PSV", NULL, &tmp); |
426 | } | 429 | } |
427 | 430 | ||
428 | if (ACPI_FAILURE(status)) | 431 | if (ACPI_FAILURE(status)) |
429 | tz->trips.passive.flags.valid = 0; | 432 | tz->trips.passive.flags.valid = 0; |
430 | else { | 433 | else { |
434 | tz->trips.passive.temperature = tmp; | ||
431 | tz->trips.passive.flags.valid = 1; | 435 | tz->trips.passive.flags.valid = 1; |
432 | if (flag == ACPI_TRIPS_INIT) { | 436 | if (flag == ACPI_TRIPS_INIT) { |
433 | status = acpi_evaluate_integer( | 437 | status = acpi_evaluate_integer( |
434 | tz->device->handle, "_TC1", | 438 | tz->device->handle, "_TC1", |
435 | NULL, &tz->trips.passive.tc1); | 439 | NULL, &tmp); |
436 | if (ACPI_FAILURE(status)) | 440 | if (ACPI_FAILURE(status)) |
437 | tz->trips.passive.flags.valid = 0; | 441 | tz->trips.passive.flags.valid = 0; |
442 | else | ||
443 | tz->trips.passive.tc1 = tmp; | ||
438 | status = acpi_evaluate_integer( | 444 | status = acpi_evaluate_integer( |
439 | tz->device->handle, "_TC2", | 445 | tz->device->handle, "_TC2", |
440 | NULL, &tz->trips.passive.tc2); | 446 | NULL, &tmp); |
441 | if (ACPI_FAILURE(status)) | 447 | if (ACPI_FAILURE(status)) |
442 | tz->trips.passive.flags.valid = 0; | 448 | tz->trips.passive.flags.valid = 0; |
449 | else | ||
450 | tz->trips.passive.tc2 = tmp; | ||
443 | status = acpi_evaluate_integer( | 451 | status = acpi_evaluate_integer( |
444 | tz->device->handle, "_TSP", | 452 | tz->device->handle, "_TSP", |
445 | NULL, &tz->trips.passive.tsp); | 453 | NULL, &tmp); |
446 | if (ACPI_FAILURE(status)) | 454 | if (ACPI_FAILURE(status)) |
447 | tz->trips.passive.flags.valid = 0; | 455 | tz->trips.passive.flags.valid = 0; |
456 | else | ||
457 | tz->trips.passive.tsp = tmp; | ||
448 | } | 458 | } |
449 | } | 459 | } |
450 | } | 460 | } |
@@ -479,7 +489,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
479 | 489 | ||
480 | if (flag & ACPI_TRIPS_ACTIVE) { | 490 | if (flag & ACPI_TRIPS_ACTIVE) { |
481 | status = acpi_evaluate_integer(tz->device->handle, | 491 | status = acpi_evaluate_integer(tz->device->handle, |
482 | name, NULL, &tz->trips.active[i].temperature); | 492 | name, NULL, &tmp); |
483 | if (ACPI_FAILURE(status)) { | 493 | if (ACPI_FAILURE(status)) { |
484 | tz->trips.active[i].flags.valid = 0; | 494 | tz->trips.active[i].flags.valid = 0; |
485 | if (i == 0) | 495 | if (i == 0) |
@@ -500,8 +510,10 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
500 | tz->trips.active[i - 2].temperature : | 510 | tz->trips.active[i - 2].temperature : |
501 | CELSIUS_TO_KELVIN(act)); | 511 | CELSIUS_TO_KELVIN(act)); |
502 | break; | 512 | break; |
503 | } else | 513 | } else { |
514 | tz->trips.active[i].temperature = tmp; | ||
504 | tz->trips.active[i].flags.valid = 1; | 515 | tz->trips.active[i].flags.valid = 1; |
516 | } | ||
505 | } | 517 | } |
506 | 518 | ||
507 | name[2] = 'L'; | 519 | name[2] = 'L'; |
@@ -563,7 +575,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) | |||
563 | acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, | 575 | acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, |
564 | tz->trips.critical.flags.enabled); | 576 | tz->trips.critical.flags.enabled); |
565 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, | 577 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, |
566 | tz->device->dev.bus_id, | 578 | dev_name(&tz->device->dev), |
567 | ACPI_THERMAL_NOTIFY_CRITICAL, | 579 | ACPI_THERMAL_NOTIFY_CRITICAL, |
568 | tz->trips.critical.flags.enabled); | 580 | tz->trips.critical.flags.enabled); |
569 | 581 | ||
@@ -592,7 +604,7 @@ static int acpi_thermal_hot(struct acpi_thermal *tz) | |||
592 | acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, | 604 | acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, |
593 | tz->trips.hot.flags.enabled); | 605 | tz->trips.hot.flags.enabled); |
594 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, | 606 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, |
595 | tz->device->dev.bus_id, | 607 | dev_name(&tz->device->dev), |
596 | ACPI_THERMAL_NOTIFY_HOT, | 608 | ACPI_THERMAL_NOTIFY_HOT, |
597 | tz->trips.hot.flags.enabled); | 609 | tz->trips.hot.flags.enabled); |
598 | 610 | ||
@@ -1213,8 +1225,8 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) | |||
1213 | acpi_bus_private_data_handler, | 1225 | acpi_bus_private_data_handler, |
1214 | tz->thermal_zone); | 1226 | tz->thermal_zone); |
1215 | if (ACPI_FAILURE(status)) { | 1227 | if (ACPI_FAILURE(status)) { |
1216 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1228 | printk(KERN_ERR PREFIX |
1217 | "Error attaching device data\n")); | 1229 | "Error attaching device data\n"); |
1218 | return -ENODEV; | 1230 | return -ENODEV; |
1219 | } | 1231 | } |
1220 | 1232 | ||
@@ -1579,14 +1591,14 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) | |||
1579 | acpi_thermal_check(tz); | 1591 | acpi_thermal_check(tz); |
1580 | acpi_bus_generate_proc_event(device, event, 0); | 1592 | acpi_bus_generate_proc_event(device, event, 0); |
1581 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 1593 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
1582 | device->dev.bus_id, event, 0); | 1594 | dev_name(&device->dev), event, 0); |
1583 | break; | 1595 | break; |
1584 | case ACPI_THERMAL_NOTIFY_DEVICES: | 1596 | case ACPI_THERMAL_NOTIFY_DEVICES: |
1585 | acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); | 1597 | acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); |
1586 | acpi_thermal_check(tz); | 1598 | acpi_thermal_check(tz); |
1587 | acpi_bus_generate_proc_event(device, event, 0); | 1599 | acpi_bus_generate_proc_event(device, event, 0); |
1588 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 1600 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
1589 | device->dev.bus_id, event, 0); | 1601 | dev_name(&device->dev), event, 0); |
1590 | break; | 1602 | break; |
1591 | default: | 1603 | default: |
1592 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 1604 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
@@ -1647,7 +1659,7 @@ static int acpi_thermal_add(struct acpi_device *device) | |||
1647 | strcpy(tz->name, device->pnp.bus_id); | 1659 | strcpy(tz->name, device->pnp.bus_id); |
1648 | strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); | 1660 | strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); |
1649 | strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); | 1661 | strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); |
1650 | acpi_driver_data(device) = tz; | 1662 | device->driver_data = tz; |
1651 | mutex_init(&tz->lock); | 1663 | mutex_init(&tz->lock); |
1652 | 1664 | ||
1653 | 1665 | ||
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c index 8a649f40d162..40e60fc2e596 100644 --- a/drivers/acpi/toshiba_acpi.c +++ b/drivers/acpi/toshiba_acpi.c | |||
@@ -371,6 +371,7 @@ static void bt_poll_rfkill(struct input_polled_dev *poll_dev) | |||
371 | RFKILL_STATE_HARD_BLOCKED); | 371 | RFKILL_STATE_HARD_BLOCKED); |
372 | input_report_switch(poll_dev->input, SW_RFKILL_ALL, | 372 | input_report_switch(poll_dev->input, SW_RFKILL_ALL, |
373 | new_rfk_state); | 373 | new_rfk_state); |
374 | input_sync(poll_dev->input); | ||
374 | } | 375 | } |
375 | } | 376 | } |
376 | 377 | ||
@@ -548,7 +549,7 @@ static unsigned long write_video(const char *buffer, unsigned long count) | |||
548 | 549 | ||
549 | hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result); | 550 | hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result); |
550 | if (hci_result == HCI_SUCCESS) { | 551 | if (hci_result == HCI_SUCCESS) { |
551 | int new_video_out = video_out; | 552 | unsigned int new_video_out = video_out; |
552 | if (lcd_out != -1) | 553 | if (lcd_out != -1) |
553 | _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out); | 554 | _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out); |
554 | if (crt_out != -1) | 555 | if (crt_out != -1) |
@@ -823,33 +824,36 @@ static int __init toshiba_acpi_init(void) | |||
823 | toshiba_acpi_exit(); | 824 | toshiba_acpi_exit(); |
824 | return -ENOMEM; | 825 | return -ENOMEM; |
825 | } | 826 | } |
826 | } | ||
827 | 827 | ||
828 | /* Register input device for kill switch */ | 828 | /* Register input device for kill switch */ |
829 | toshiba_acpi.poll_dev = input_allocate_polled_device(); | 829 | toshiba_acpi.poll_dev = input_allocate_polled_device(); |
830 | if (!toshiba_acpi.poll_dev) { | 830 | if (!toshiba_acpi.poll_dev) { |
831 | printk(MY_ERR "unable to allocate kill-switch input device\n"); | 831 | printk(MY_ERR |
832 | toshiba_acpi_exit(); | 832 | "unable to allocate kill-switch input device\n"); |
833 | return -ENOMEM; | 833 | toshiba_acpi_exit(); |
834 | } | 834 | return -ENOMEM; |
835 | toshiba_acpi.poll_dev->private = &toshiba_acpi; | 835 | } |
836 | toshiba_acpi.poll_dev->poll = bt_poll_rfkill; | 836 | toshiba_acpi.poll_dev->private = &toshiba_acpi; |
837 | toshiba_acpi.poll_dev->poll_interval = 1000; /* msecs */ | 837 | toshiba_acpi.poll_dev->poll = bt_poll_rfkill; |
838 | 838 | toshiba_acpi.poll_dev->poll_interval = 1000; /* msecs */ | |
839 | toshiba_acpi.poll_dev->input->name = toshiba_acpi.rfk_name; | 839 | |
840 | toshiba_acpi.poll_dev->input->id.bustype = BUS_HOST; | 840 | toshiba_acpi.poll_dev->input->name = toshiba_acpi.rfk_name; |
841 | toshiba_acpi.poll_dev->input->id.vendor = 0x0930; /* Toshiba USB ID */ | 841 | toshiba_acpi.poll_dev->input->id.bustype = BUS_HOST; |
842 | set_bit(EV_SW, toshiba_acpi.poll_dev->input->evbit); | 842 | /* Toshiba USB ID */ |
843 | set_bit(SW_RFKILL_ALL, toshiba_acpi.poll_dev->input->swbit); | 843 | toshiba_acpi.poll_dev->input->id.vendor = 0x0930; |
844 | input_report_switch(toshiba_acpi.poll_dev->input, SW_RFKILL_ALL, TRUE); | 844 | set_bit(EV_SW, toshiba_acpi.poll_dev->input->evbit); |
845 | 845 | set_bit(SW_RFKILL_ALL, toshiba_acpi.poll_dev->input->swbit); | |
846 | ret = input_register_polled_device(toshiba_acpi.poll_dev); | 846 | input_report_switch(toshiba_acpi.poll_dev->input, |
847 | if (ret) { | 847 | SW_RFKILL_ALL, TRUE); |
848 | printk(MY_ERR "unable to register kill-switch input device\n"); | 848 | input_sync(toshiba_acpi.poll_dev->input); |
849 | rfkill_free(toshiba_acpi.rfk_dev); | 849 | |
850 | toshiba_acpi.rfk_dev = NULL; | 850 | ret = input_register_polled_device(toshiba_acpi.poll_dev); |
851 | toshiba_acpi_exit(); | 851 | if (ret) { |
852 | return ret; | 852 | printk(MY_ERR |
853 | "unable to register kill-switch input device\n"); | ||
854 | toshiba_acpi_exit(); | ||
855 | return ret; | ||
856 | } | ||
853 | } | 857 | } |
854 | 858 | ||
855 | return 0; | 859 | return 0; |
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 7dcb67e0b215..241c535c1753 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c | |||
@@ -232,7 +232,7 @@ acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer) | |||
232 | * RETURN: Status | 232 | * RETURN: Status |
233 | * | 233 | * |
234 | * DESCRIPTION: Validate that the buffer is of the required length or | 234 | * DESCRIPTION: Validate that the buffer is of the required length or |
235 | * allocate a new buffer. Returned buffer is always zeroed. | 235 | * allocate a new buffer. Returned buffer is always zeroed. |
236 | * | 236 | * |
237 | ******************************************************************************/ | 237 | ******************************************************************************/ |
238 | 238 | ||
@@ -240,7 +240,7 @@ acpi_status | |||
240 | acpi_ut_initialize_buffer(struct acpi_buffer * buffer, | 240 | acpi_ut_initialize_buffer(struct acpi_buffer * buffer, |
241 | acpi_size required_length) | 241 | acpi_size required_length) |
242 | { | 242 | { |
243 | acpi_status status = AE_OK; | 243 | acpi_size input_buffer_length; |
244 | 244 | ||
245 | /* Parameter validation */ | 245 | /* Parameter validation */ |
246 | 246 | ||
@@ -248,55 +248,58 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer, | |||
248 | return (AE_BAD_PARAMETER); | 248 | return (AE_BAD_PARAMETER); |
249 | } | 249 | } |
250 | 250 | ||
251 | switch (buffer->length) { | 251 | /* |
252 | * Buffer->Length is used as both an input and output parameter. Get the | ||
253 | * input actual length and set the output required buffer length. | ||
254 | */ | ||
255 | input_buffer_length = buffer->length; | ||
256 | buffer->length = required_length; | ||
257 | |||
258 | /* | ||
259 | * The input buffer length contains the actual buffer length, or the type | ||
260 | * of buffer to be allocated by this routine. | ||
261 | */ | ||
262 | switch (input_buffer_length) { | ||
252 | case ACPI_NO_BUFFER: | 263 | case ACPI_NO_BUFFER: |
253 | 264 | ||
254 | /* Set the exception and returned the required length */ | 265 | /* Return the exception (and the required buffer length) */ |
255 | 266 | ||
256 | status = AE_BUFFER_OVERFLOW; | 267 | return (AE_BUFFER_OVERFLOW); |
257 | break; | ||
258 | 268 | ||
259 | case ACPI_ALLOCATE_BUFFER: | 269 | case ACPI_ALLOCATE_BUFFER: |
260 | 270 | ||
261 | /* Allocate a new buffer */ | 271 | /* Allocate a new buffer */ |
262 | 272 | ||
263 | buffer->pointer = acpi_os_allocate(required_length); | 273 | buffer->pointer = acpi_os_allocate(required_length); |
264 | if (!buffer->pointer) { | ||
265 | return (AE_NO_MEMORY); | ||
266 | } | ||
267 | |||
268 | /* Clear the buffer */ | ||
269 | |||
270 | ACPI_MEMSET(buffer->pointer, 0, required_length); | ||
271 | break; | 274 | break; |
272 | 275 | ||
273 | case ACPI_ALLOCATE_LOCAL_BUFFER: | 276 | case ACPI_ALLOCATE_LOCAL_BUFFER: |
274 | 277 | ||
275 | /* Allocate a new buffer with local interface to allow tracking */ | 278 | /* Allocate a new buffer with local interface to allow tracking */ |
276 | 279 | ||
277 | buffer->pointer = ACPI_ALLOCATE_ZEROED(required_length); | 280 | buffer->pointer = ACPI_ALLOCATE(required_length); |
278 | if (!buffer->pointer) { | ||
279 | return (AE_NO_MEMORY); | ||
280 | } | ||
281 | break; | 281 | break; |
282 | 282 | ||
283 | default: | 283 | default: |
284 | 284 | ||
285 | /* Existing buffer: Validate the size of the buffer */ | 285 | /* Existing buffer: Validate the size of the buffer */ |
286 | 286 | ||
287 | if (buffer->length < required_length) { | 287 | if (input_buffer_length < required_length) { |
288 | status = AE_BUFFER_OVERFLOW; | 288 | return (AE_BUFFER_OVERFLOW); |
289 | break; | ||
290 | } | 289 | } |
290 | break; | ||
291 | } | ||
291 | 292 | ||
292 | /* Clear the buffer */ | 293 | /* Validate allocation from above or input buffer pointer */ |
293 | 294 | ||
294 | ACPI_MEMSET(buffer->pointer, 0, required_length); | 295 | if (!buffer->pointer) { |
295 | break; | 296 | return (AE_NO_MEMORY); |
296 | } | 297 | } |
297 | 298 | ||
298 | buffer->length = required_length; | 299 | /* Have a valid buffer, clear it */ |
299 | return (status); | 300 | |
301 | ACPI_MEMSET(buffer->pointer, 0, required_length); | ||
302 | return (AE_OK); | ||
300 | } | 303 | } |
301 | 304 | ||
302 | #ifdef NOT_USED_BY_LINUX | 305 | #ifdef NOT_USED_BY_LINUX |
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 53499ac90988..5b2f7c27b705 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c | |||
@@ -42,7 +42,6 @@ | |||
42 | */ | 42 | */ |
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/amlcode.h> | ||
46 | #include <acpi/acnamesp.h> | 45 | #include <acpi/acnamesp.h> |
47 | 46 | ||
48 | 47 | ||
@@ -176,20 +175,24 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, | |||
176 | 175 | ||
177 | /* This is an object reference. */ | 176 | /* This is an object reference. */ |
178 | 177 | ||
179 | switch (internal_object->reference.opcode) { | 178 | switch (internal_object->reference.class) { |
180 | case AML_INT_NAMEPATH_OP: | 179 | case ACPI_REFCLASS_NAME: |
181 | |||
182 | /* For namepath, return the object handle ("reference") */ | ||
183 | |||
184 | default: | ||
185 | |||
186 | /* We are referring to the namespace node */ | ||
187 | 180 | ||
181 | /* | ||
182 | * For namepath, return the object handle ("reference") | ||
183 | * We are referring to the namespace node | ||
184 | */ | ||
188 | external_object->reference.handle = | 185 | external_object->reference.handle = |
189 | internal_object->reference.node; | 186 | internal_object->reference.node; |
190 | external_object->reference.actual_type = | 187 | external_object->reference.actual_type = |
191 | acpi_ns_get_type(internal_object->reference.node); | 188 | acpi_ns_get_type(internal_object->reference.node); |
192 | break; | 189 | break; |
190 | |||
191 | default: | ||
192 | |||
193 | /* All other reference types are unsupported */ | ||
194 | |||
195 | return_ACPI_STATUS(AE_TYPE); | ||
193 | } | 196 | } |
194 | break; | 197 | break; |
195 | 198 | ||
@@ -533,7 +536,7 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object, | |||
533 | 536 | ||
534 | /* TBD: should validate incoming handle */ | 537 | /* TBD: should validate incoming handle */ |
535 | 538 | ||
536 | internal_object->reference.opcode = AML_INT_NAMEPATH_OP; | 539 | internal_object->reference.class = ACPI_REFCLASS_NAME; |
537 | internal_object->reference.node = | 540 | internal_object->reference.node = |
538 | external_object->reference.handle; | 541 | external_object->reference.handle; |
539 | break; | 542 | break; |
@@ -743,11 +746,11 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, | |||
743 | * We copied the reference object, so we now must add a reference | 746 | * We copied the reference object, so we now must add a reference |
744 | * to the object pointed to by the reference | 747 | * to the object pointed to by the reference |
745 | * | 748 | * |
746 | * DDBHandle reference (from Load/load_table is a special reference, | 749 | * DDBHandle reference (from Load/load_table) is a special reference, |
747 | * it's Reference.Object is the table index, so does not need to | 750 | * it does not have a Reference.Object, so does not need to |
748 | * increase the reference count | 751 | * increase the reference count |
749 | */ | 752 | */ |
750 | if (source_desc->reference.opcode == AML_LOAD_OP) { | 753 | if (source_desc->reference.class == ACPI_REFCLASS_TABLE) { |
751 | break; | 754 | break; |
752 | } | 755 | } |
753 | 756 | ||
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index 42609d3a8aa9..d197c6b29e17 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <acpi/acinterp.h> | 45 | #include <acpi/acinterp.h> |
46 | #include <acpi/acnamesp.h> | 46 | #include <acpi/acnamesp.h> |
47 | #include <acpi/acevents.h> | 47 | #include <acpi/acevents.h> |
48 | #include <acpi/amlcode.h> | ||
49 | 48 | ||
50 | #define _COMPONENT ACPI_UTILITIES | 49 | #define _COMPONENT ACPI_UTILITIES |
51 | ACPI_MODULE_NAME("utdelete") | 50 | ACPI_MODULE_NAME("utdelete") |
@@ -548,8 +547,8 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) | |||
548 | * reference must track changes to the ref count of the index or | 547 | * reference must track changes to the ref count of the index or |
549 | * target object. | 548 | * target object. |
550 | */ | 549 | */ |
551 | if ((object->reference.opcode == AML_INDEX_OP) || | 550 | if ((object->reference.class == ACPI_REFCLASS_INDEX) || |
552 | (object->reference.opcode == AML_INT_NAMEPATH_OP)) { | 551 | (object->reference.class == ACPI_REFCLASS_NAME)) { |
553 | next_object = object->reference.object; | 552 | next_object = object->reference.object; |
554 | } | 553 | } |
555 | break; | 554 | break; |
@@ -586,6 +585,13 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) | |||
586 | ACPI_EXCEPTION((AE_INFO, status, | 585 | ACPI_EXCEPTION((AE_INFO, status, |
587 | "Could not update object reference count")); | 586 | "Could not update object reference count")); |
588 | 587 | ||
588 | /* Free any stacked Update State objects */ | ||
589 | |||
590 | while (state_list) { | ||
591 | state = acpi_ut_pop_generic_state(&state_list); | ||
592 | acpi_ut_delete_generic_state(state); | ||
593 | } | ||
594 | |||
589 | return_ACPI_STATUS(status); | 595 | return_ACPI_STATUS(status); |
590 | } | 596 | } |
591 | 597 | ||
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index a6e71b801d2d..670551b95e56 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c | |||
@@ -281,7 +281,6 @@ struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = { | |||
281 | /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, | 281 | /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, |
282 | ACPI_BITPOSITION_RT_CLOCK_ENABLE, | 282 | ACPI_BITPOSITION_RT_CLOCK_ENABLE, |
283 | ACPI_BITMASK_RT_CLOCK_ENABLE}, | 283 | ACPI_BITMASK_RT_CLOCK_ENABLE}, |
284 | /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, | ||
285 | /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, | 284 | /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, |
286 | ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, | 285 | ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, |
287 | ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, | 286 | ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, |
@@ -575,6 +574,47 @@ char *acpi_ut_get_descriptor_name(void *object) | |||
575 | 574 | ||
576 | } | 575 | } |
577 | 576 | ||
577 | /******************************************************************************* | ||
578 | * | ||
579 | * FUNCTION: acpi_ut_get_reference_name | ||
580 | * | ||
581 | * PARAMETERS: Object - An ACPI reference object | ||
582 | * | ||
583 | * RETURN: Pointer to a string | ||
584 | * | ||
585 | * DESCRIPTION: Decode a reference object sub-type to a string. | ||
586 | * | ||
587 | ******************************************************************************/ | ||
588 | |||
589 | /* Printable names of reference object sub-types */ | ||
590 | |||
591 | static const char *acpi_gbl_ref_class_names[] = { | ||
592 | /* 00 */ "Local", | ||
593 | /* 01 */ "Argument", | ||
594 | /* 02 */ "RefOf", | ||
595 | /* 03 */ "Index", | ||
596 | /* 04 */ "DdbHandle", | ||
597 | /* 05 */ "Named Object", | ||
598 | /* 06 */ "Debug" | ||
599 | }; | ||
600 | |||
601 | const char *acpi_ut_get_reference_name(union acpi_operand_object *object) | ||
602 | { | ||
603 | if (!object) | ||
604 | return "NULL Object"; | ||
605 | |||
606 | if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) | ||
607 | return "Not an Operand object"; | ||
608 | |||
609 | if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE) | ||
610 | return "Not a Reference object"; | ||
611 | |||
612 | if (object->reference.class > ACPI_REFCLASS_MAX) | ||
613 | return "Unknown Reference class"; | ||
614 | |||
615 | return acpi_gbl_ref_class_names[object->reference.class]; | ||
616 | } | ||
617 | |||
578 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | 618 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) |
579 | /* | 619 | /* |
580 | * Strings and procedures used for debug only | 620 | * Strings and procedures used for debug only |
@@ -677,14 +717,14 @@ u8 acpi_ut_valid_object_type(acpi_object_type type) | |||
677 | * | 717 | * |
678 | * PARAMETERS: None | 718 | * PARAMETERS: None |
679 | * | 719 | * |
680 | * RETURN: None | 720 | * RETURN: Status |
681 | * | 721 | * |
682 | * DESCRIPTION: Init library globals. All globals that require specific | 722 | * DESCRIPTION: Init library globals. All globals that require specific |
683 | * initialization should be initialized here! | 723 | * initialization should be initialized here! |
684 | * | 724 | * |
685 | ******************************************************************************/ | 725 | ******************************************************************************/ |
686 | 726 | ||
687 | void acpi_ut_init_globals(void) | 727 | acpi_status acpi_ut_init_globals(void) |
688 | { | 728 | { |
689 | acpi_status status; | 729 | acpi_status status; |
690 | u32 i; | 730 | u32 i; |
@@ -695,7 +735,7 @@ void acpi_ut_init_globals(void) | |||
695 | 735 | ||
696 | status = acpi_ut_create_caches(); | 736 | status = acpi_ut_create_caches(); |
697 | if (ACPI_FAILURE(status)) { | 737 | if (ACPI_FAILURE(status)) { |
698 | return; | 738 | return_ACPI_STATUS(status); |
699 | } | 739 | } |
700 | 740 | ||
701 | /* Mutex locked flags */ | 741 | /* Mutex locked flags */ |
@@ -772,8 +812,8 @@ void acpi_ut_init_globals(void) | |||
772 | acpi_gbl_display_final_mem_stats = FALSE; | 812 | acpi_gbl_display_final_mem_stats = FALSE; |
773 | #endif | 813 | #endif |
774 | 814 | ||
775 | return_VOID; | 815 | return_ACPI_STATUS(AE_OK); |
776 | } | 816 | } |
777 | 817 | ||
778 | ACPI_EXPORT_SYMBOL(acpi_dbg_level) | 818 | ACPI_EXPORT_SYMBOL(acpi_dbg_level) |
779 | ACPI_EXPORT_SYMBOL(acpi_dbg_layer) | 819 | ACPI_EXPORT_SYMBOL(acpi_dbg_layer) |
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index f34be6773556..9089a158a874 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c | |||
@@ -995,6 +995,15 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object, | |||
995 | state->pkg. | 995 | state->pkg. |
996 | this_target_obj, 0); | 996 | this_target_obj, 0); |
997 | if (!state) { | 997 | if (!state) { |
998 | |||
999 | /* Free any stacked Update State objects */ | ||
1000 | |||
1001 | while (state_list) { | ||
1002 | state = | ||
1003 | acpi_ut_pop_generic_state | ||
1004 | (&state_list); | ||
1005 | acpi_ut_delete_generic_state(state); | ||
1006 | } | ||
998 | return_ACPI_STATUS(AE_NO_MEMORY); | 1007 | return_ACPI_STATUS(AE_NO_MEMORY); |
999 | } | 1008 | } |
1000 | } | 1009 | } |
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c index 916eff399eb3..c354e7a42bcd 100644 --- a/drivers/acpi/utilities/utobject.c +++ b/drivers/acpi/utilities/utobject.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/acnamesp.h> | 45 | #include <acpi/acnamesp.h> |
46 | #include <acpi/amlcode.h> | ||
47 | 46 | ||
48 | #define _COMPONENT ACPI_UTILITIES | 47 | #define _COMPONENT ACPI_UTILITIES |
49 | ACPI_MODULE_NAME("utobject") | 48 | ACPI_MODULE_NAME("utobject") |
@@ -478,8 +477,8 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, | |||
478 | 477 | ||
479 | case ACPI_TYPE_LOCAL_REFERENCE: | 478 | case ACPI_TYPE_LOCAL_REFERENCE: |
480 | 479 | ||
481 | switch (internal_object->reference.opcode) { | 480 | switch (internal_object->reference.class) { |
482 | case AML_INT_NAMEPATH_OP: | 481 | case ACPI_REFCLASS_NAME: |
483 | 482 | ||
484 | /* | 483 | /* |
485 | * Get the actual length of the full pathname to this object. | 484 | * Get the actual length of the full pathname to this object. |
@@ -503,8 +502,10 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, | |||
503 | * required eventually. | 502 | * required eventually. |
504 | */ | 503 | */ |
505 | ACPI_ERROR((AE_INFO, | 504 | ACPI_ERROR((AE_INFO, |
506 | "Unsupported Reference opcode=%X in object %p", | 505 | "Cannot convert to external object - " |
507 | internal_object->reference.opcode, | 506 | "unsupported Reference Class [%s] %X in object %p", |
507 | acpi_ut_get_reference_name(internal_object), | ||
508 | internal_object->reference.class, | ||
508 | internal_object)); | 509 | internal_object)); |
509 | status = AE_TYPE; | 510 | status = AE_TYPE; |
510 | break; | 511 | break; |
@@ -513,7 +514,9 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, | |||
513 | 514 | ||
514 | default: | 515 | default: |
515 | 516 | ||
516 | ACPI_ERROR((AE_INFO, "Unsupported type=%X in object %p", | 517 | ACPI_ERROR((AE_INFO, "Cannot convert to external object - " |
518 | "unsupported type [%s] %X in object %p", | ||
519 | acpi_ut_get_object_type_name(internal_object), | ||
517 | ACPI_GET_OBJECT_TYPE(internal_object), | 520 | ACPI_GET_OBJECT_TYPE(internal_object), |
518 | internal_object)); | 521 | internal_object)); |
519 | status = AE_TYPE; | 522 | status = AE_TYPE; |
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index f8bdadf3c32f..c198a4d40583 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c | |||
@@ -81,7 +81,12 @@ acpi_status __init acpi_initialize_subsystem(void) | |||
81 | 81 | ||
82 | /* Initialize all globals used by the subsystem */ | 82 | /* Initialize all globals used by the subsystem */ |
83 | 83 | ||
84 | acpi_ut_init_globals(); | 84 | status = acpi_ut_init_globals(); |
85 | if (ACPI_FAILURE(status)) { | ||
86 | ACPI_EXCEPTION((AE_INFO, status, | ||
87 | "During initialization of globals")); | ||
88 | return_ACPI_STATUS(status); | ||
89 | } | ||
85 | 90 | ||
86 | /* Create the default mutex objects */ | 91 | /* Create the default mutex objects */ |
87 | 92 | ||
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 100926143818..f844941089bb 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -256,39 +256,31 @@ EXPORT_SYMBOL(acpi_extract_package); | |||
256 | acpi_status | 256 | acpi_status |
257 | acpi_evaluate_integer(acpi_handle handle, | 257 | acpi_evaluate_integer(acpi_handle handle, |
258 | acpi_string pathname, | 258 | acpi_string pathname, |
259 | struct acpi_object_list *arguments, unsigned long *data) | 259 | struct acpi_object_list *arguments, unsigned long long *data) |
260 | { | 260 | { |
261 | acpi_status status = AE_OK; | 261 | acpi_status status = AE_OK; |
262 | union acpi_object *element; | 262 | union acpi_object element; |
263 | struct acpi_buffer buffer = { 0, NULL }; | 263 | struct acpi_buffer buffer = { 0, NULL }; |
264 | 264 | ||
265 | |||
266 | if (!data) | 265 | if (!data) |
267 | return AE_BAD_PARAMETER; | 266 | return AE_BAD_PARAMETER; |
268 | 267 | ||
269 | element = kzalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL); | ||
270 | if (!element) | ||
271 | return AE_NO_MEMORY; | ||
272 | |||
273 | buffer.length = sizeof(union acpi_object); | 268 | buffer.length = sizeof(union acpi_object); |
274 | buffer.pointer = element; | 269 | buffer.pointer = &element; |
275 | status = acpi_evaluate_object(handle, pathname, arguments, &buffer); | 270 | status = acpi_evaluate_object(handle, pathname, arguments, &buffer); |
276 | if (ACPI_FAILURE(status)) { | 271 | if (ACPI_FAILURE(status)) { |
277 | acpi_util_eval_error(handle, pathname, status); | 272 | acpi_util_eval_error(handle, pathname, status); |
278 | kfree(element); | ||
279 | return status; | 273 | return status; |
280 | } | 274 | } |
281 | 275 | ||
282 | if (element->type != ACPI_TYPE_INTEGER) { | 276 | if (element.type != ACPI_TYPE_INTEGER) { |
283 | acpi_util_eval_error(handle, pathname, AE_BAD_DATA); | 277 | acpi_util_eval_error(handle, pathname, AE_BAD_DATA); |
284 | kfree(element); | ||
285 | return AE_BAD_DATA; | 278 | return AE_BAD_DATA; |
286 | } | 279 | } |
287 | 280 | ||
288 | *data = element->integer.value; | 281 | *data = element.integer.value; |
289 | kfree(element); | ||
290 | 282 | ||
291 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); | 283 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%llu]\n", *data)); |
292 | 284 | ||
293 | return AE_OK; | 285 | return AE_OK; |
294 | } | 286 | } |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index e8a51a1700f7..baa441929720 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <acpi/acpi_bus.h> | 41 | #include <acpi/acpi_bus.h> |
42 | #include <acpi/acpi_drivers.h> | 42 | #include <acpi/acpi_drivers.h> |
43 | 43 | ||
44 | #define ACPI_VIDEO_COMPONENT 0x08000000 | ||
45 | #define ACPI_VIDEO_CLASS "video" | 44 | #define ACPI_VIDEO_CLASS "video" |
46 | #define ACPI_VIDEO_BUS_NAME "Video Bus" | 45 | #define ACPI_VIDEO_BUS_NAME "Video Bus" |
47 | #define ACPI_VIDEO_DEVICE_NAME "Video Device" | 46 | #define ACPI_VIDEO_DEVICE_NAME "Video Device" |
@@ -291,20 +290,20 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, | |||
291 | int level); | 290 | int level); |
292 | static int acpi_video_device_lcd_get_level_current( | 291 | static int acpi_video_device_lcd_get_level_current( |
293 | struct acpi_video_device *device, | 292 | struct acpi_video_device *device, |
294 | unsigned long *level); | 293 | unsigned long long *level); |
295 | static int acpi_video_get_next_level(struct acpi_video_device *device, | 294 | static int acpi_video_get_next_level(struct acpi_video_device *device, |
296 | u32 level_current, u32 event); | 295 | u32 level_current, u32 event); |
297 | static void acpi_video_switch_brightness(struct acpi_video_device *device, | 296 | static void acpi_video_switch_brightness(struct acpi_video_device *device, |
298 | int event); | 297 | int event); |
299 | static int acpi_video_device_get_state(struct acpi_video_device *device, | 298 | static int acpi_video_device_get_state(struct acpi_video_device *device, |
300 | unsigned long *state); | 299 | unsigned long long *state); |
301 | static int acpi_video_output_get(struct output_device *od); | 300 | static int acpi_video_output_get(struct output_device *od); |
302 | static int acpi_video_device_set_state(struct acpi_video_device *device, int state); | 301 | static int acpi_video_device_set_state(struct acpi_video_device *device, int state); |
303 | 302 | ||
304 | /*backlight device sysfs support*/ | 303 | /*backlight device sysfs support*/ |
305 | static int acpi_video_get_brightness(struct backlight_device *bd) | 304 | static int acpi_video_get_brightness(struct backlight_device *bd) |
306 | { | 305 | { |
307 | unsigned long cur_level; | 306 | unsigned long long cur_level; |
308 | int i; | 307 | int i; |
309 | struct acpi_video_device *vd = | 308 | struct acpi_video_device *vd = |
310 | (struct acpi_video_device *)bl_get_data(bd); | 309 | (struct acpi_video_device *)bl_get_data(bd); |
@@ -336,7 +335,7 @@ static struct backlight_ops acpi_backlight_ops = { | |||
336 | /*video output device sysfs support*/ | 335 | /*video output device sysfs support*/ |
337 | static int acpi_video_output_get(struct output_device *od) | 336 | static int acpi_video_output_get(struct output_device *od) |
338 | { | 337 | { |
339 | unsigned long state; | 338 | unsigned long long state; |
340 | struct acpi_video_device *vd = | 339 | struct acpi_video_device *vd = |
341 | (struct acpi_video_device *)dev_get_drvdata(&od->dev); | 340 | (struct acpi_video_device *)dev_get_drvdata(&od->dev); |
342 | acpi_video_device_get_state(vd, &state); | 341 | acpi_video_device_get_state(vd, &state); |
@@ -370,7 +369,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cdev, char *buf) | |||
370 | { | 369 | { |
371 | struct acpi_device *device = cdev->devdata; | 370 | struct acpi_device *device = cdev->devdata; |
372 | struct acpi_video_device *video = acpi_driver_data(device); | 371 | struct acpi_video_device *video = acpi_driver_data(device); |
373 | unsigned long level; | 372 | unsigned long long level; |
374 | int state; | 373 | int state; |
375 | 374 | ||
376 | acpi_video_device_lcd_get_level_current(video, &level); | 375 | acpi_video_device_lcd_get_level_current(video, &level); |
@@ -410,7 +409,7 @@ static struct thermal_cooling_device_ops video_cooling_ops = { | |||
410 | /* device */ | 409 | /* device */ |
411 | 410 | ||
412 | static int | 411 | static int |
413 | acpi_video_device_query(struct acpi_video_device *device, unsigned long *state) | 412 | acpi_video_device_query(struct acpi_video_device *device, unsigned long long *state) |
414 | { | 413 | { |
415 | int status; | 414 | int status; |
416 | 415 | ||
@@ -421,7 +420,7 @@ acpi_video_device_query(struct acpi_video_device *device, unsigned long *state) | |||
421 | 420 | ||
422 | static int | 421 | static int |
423 | acpi_video_device_get_state(struct acpi_video_device *device, | 422 | acpi_video_device_get_state(struct acpi_video_device *device, |
424 | unsigned long *state) | 423 | unsigned long long *state) |
425 | { | 424 | { |
426 | int status; | 425 | int status; |
427 | 426 | ||
@@ -436,7 +435,7 @@ acpi_video_device_set_state(struct acpi_video_device *device, int state) | |||
436 | int status; | 435 | int status; |
437 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | 436 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; |
438 | struct acpi_object_list args = { 1, &arg0 }; | 437 | struct acpi_object_list args = { 1, &arg0 }; |
439 | unsigned long ret; | 438 | unsigned long long ret; |
440 | 439 | ||
441 | 440 | ||
442 | arg0.integer.value = state; | 441 | arg0.integer.value = state; |
@@ -495,7 +494,7 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) | |||
495 | 494 | ||
496 | static int | 495 | static int |
497 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | 496 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, |
498 | unsigned long *level) | 497 | unsigned long long *level) |
499 | { | 498 | { |
500 | if (device->cap._BQC) | 499 | if (device->cap._BQC) |
501 | return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, | 500 | return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, |
@@ -549,7 +548,7 @@ static int | |||
549 | acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option) | 548 | acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option) |
550 | { | 549 | { |
551 | int status; | 550 | int status; |
552 | unsigned long tmp; | 551 | unsigned long long tmp; |
553 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | 552 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; |
554 | struct acpi_object_list args = { 1, &arg0 }; | 553 | struct acpi_object_list args = { 1, &arg0 }; |
555 | 554 | ||
@@ -564,7 +563,7 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option) | |||
564 | } | 563 | } |
565 | 564 | ||
566 | static int | 565 | static int |
567 | acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id) | 566 | acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long long *id) |
568 | { | 567 | { |
569 | int status; | 568 | int status; |
570 | 569 | ||
@@ -575,7 +574,7 @@ acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id) | |||
575 | 574 | ||
576 | static int | 575 | static int |
577 | acpi_video_bus_POST_options(struct acpi_video_bus *video, | 576 | acpi_video_bus_POST_options(struct acpi_video_bus *video, |
578 | unsigned long *options) | 577 | unsigned long long *options) |
579 | { | 578 | { |
580 | int status; | 579 | int status; |
581 | 580 | ||
@@ -739,7 +738,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
739 | device->cap._DSS = 1; | 738 | device->cap._DSS = 1; |
740 | } | 739 | } |
741 | 740 | ||
742 | max_level = acpi_video_init_brightness(device); | 741 | if (acpi_video_backlight_support()) |
742 | max_level = acpi_video_init_brightness(device); | ||
743 | 743 | ||
744 | if (device->cap._BCL && device->cap._BCM && max_level > 0) { | 744 | if (device->cap._BCL && device->cap._BCM && max_level > 0) { |
745 | int result; | 745 | int result; |
@@ -785,18 +785,21 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
785 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | 785 | printk(KERN_ERR PREFIX "Create sysfs link\n"); |
786 | 786 | ||
787 | } | 787 | } |
788 | if (device->cap._DCS && device->cap._DSS){ | 788 | |
789 | static int count = 0; | 789 | if (acpi_video_display_switch_support()) { |
790 | char *name; | 790 | |
791 | name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); | 791 | if (device->cap._DCS && device->cap._DSS) { |
792 | if (!name) | 792 | static int count; |
793 | return; | 793 | char *name; |
794 | sprintf(name, "acpi_video%d", count++); | 794 | name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); |
795 | device->output_dev = video_output_register(name, | 795 | if (!name) |
796 | NULL, device, &acpi_output_properties); | 796 | return; |
797 | kfree(name); | 797 | sprintf(name, "acpi_video%d", count++); |
798 | device->output_dev = video_output_register(name, | ||
799 | NULL, device, &acpi_output_properties); | ||
800 | kfree(name); | ||
801 | } | ||
798 | } | 802 | } |
799 | return; | ||
800 | } | 803 | } |
801 | 804 | ||
802 | /* | 805 | /* |
@@ -842,11 +845,16 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video) | |||
842 | static int acpi_video_bus_check(struct acpi_video_bus *video) | 845 | static int acpi_video_bus_check(struct acpi_video_bus *video) |
843 | { | 846 | { |
844 | acpi_status status = -ENOENT; | 847 | acpi_status status = -ENOENT; |
845 | 848 | struct device *dev; | |
846 | 849 | ||
847 | if (!video) | 850 | if (!video) |
848 | return -EINVAL; | 851 | return -EINVAL; |
849 | 852 | ||
853 | dev = acpi_get_physical_pci_device(video->device->handle); | ||
854 | if (!dev) | ||
855 | return -ENODEV; | ||
856 | put_device(dev); | ||
857 | |||
850 | /* Since there is no HID, CID and so on for VGA driver, we have | 858 | /* Since there is no HID, CID and so on for VGA driver, we have |
851 | * to check well known required nodes. | 859 | * to check well known required nodes. |
852 | */ | 860 | */ |
@@ -918,7 +926,7 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) | |||
918 | { | 926 | { |
919 | int status; | 927 | int status; |
920 | struct acpi_video_device *dev = seq->private; | 928 | struct acpi_video_device *dev = seq->private; |
921 | unsigned long state; | 929 | unsigned long long state; |
922 | 930 | ||
923 | 931 | ||
924 | if (!dev) | 932 | if (!dev) |
@@ -927,14 +935,14 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) | |||
927 | status = acpi_video_device_get_state(dev, &state); | 935 | status = acpi_video_device_get_state(dev, &state); |
928 | seq_printf(seq, "state: "); | 936 | seq_printf(seq, "state: "); |
929 | if (ACPI_SUCCESS(status)) | 937 | if (ACPI_SUCCESS(status)) |
930 | seq_printf(seq, "0x%02lx\n", state); | 938 | seq_printf(seq, "0x%02llx\n", state); |
931 | else | 939 | else |
932 | seq_printf(seq, "<not supported>\n"); | 940 | seq_printf(seq, "<not supported>\n"); |
933 | 941 | ||
934 | status = acpi_video_device_query(dev, &state); | 942 | status = acpi_video_device_query(dev, &state); |
935 | seq_printf(seq, "query: "); | 943 | seq_printf(seq, "query: "); |
936 | if (ACPI_SUCCESS(status)) | 944 | if (ACPI_SUCCESS(status)) |
937 | seq_printf(seq, "0x%02lx\n", state); | 945 | seq_printf(seq, "0x%02llx\n", state); |
938 | else | 946 | else |
939 | seq_printf(seq, "<not supported>\n"); | 947 | seq_printf(seq, "<not supported>\n"); |
940 | 948 | ||
@@ -1217,7 +1225,7 @@ static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file) | |||
1217 | static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) | 1225 | static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) |
1218 | { | 1226 | { |
1219 | struct acpi_video_bus *video = seq->private; | 1227 | struct acpi_video_bus *video = seq->private; |
1220 | unsigned long options; | 1228 | unsigned long long options; |
1221 | int status; | 1229 | int status; |
1222 | 1230 | ||
1223 | 1231 | ||
@@ -1232,7 +1240,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) | |||
1232 | printk(KERN_WARNING PREFIX | 1240 | printk(KERN_WARNING PREFIX |
1233 | "This indicates a BIOS bug. Please contact the manufacturer.\n"); | 1241 | "This indicates a BIOS bug. Please contact the manufacturer.\n"); |
1234 | } | 1242 | } |
1235 | printk("%lx\n", options); | 1243 | printk("%llx\n", options); |
1236 | seq_printf(seq, "can POST: <integrated video>"); | 1244 | seq_printf(seq, "can POST: <integrated video>"); |
1237 | if (options & 2) | 1245 | if (options & 2) |
1238 | seq_printf(seq, " <PCI video>"); | 1246 | seq_printf(seq, " <PCI video>"); |
@@ -1256,7 +1264,7 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) | |||
1256 | { | 1264 | { |
1257 | struct acpi_video_bus *video = seq->private; | 1265 | struct acpi_video_bus *video = seq->private; |
1258 | int status; | 1266 | int status; |
1259 | unsigned long id; | 1267 | unsigned long long id; |
1260 | 1268 | ||
1261 | 1269 | ||
1262 | if (!video) | 1270 | if (!video) |
@@ -1303,7 +1311,7 @@ acpi_video_bus_write_POST(struct file *file, | |||
1303 | struct seq_file *m = file->private_data; | 1311 | struct seq_file *m = file->private_data; |
1304 | struct acpi_video_bus *video = m->private; | 1312 | struct acpi_video_bus *video = m->private; |
1305 | char str[12] = { 0 }; | 1313 | char str[12] = { 0 }; |
1306 | unsigned long opt, options; | 1314 | unsigned long long opt, options; |
1307 | 1315 | ||
1308 | 1316 | ||
1309 | if (!video || count + 1 > sizeof str) | 1317 | if (!video || count + 1 > sizeof str) |
@@ -1473,7 +1481,7 @@ static int | |||
1473 | acpi_video_bus_get_one_device(struct acpi_device *device, | 1481 | acpi_video_bus_get_one_device(struct acpi_device *device, |
1474 | struct acpi_video_bus *video) | 1482 | struct acpi_video_bus *video) |
1475 | { | 1483 | { |
1476 | unsigned long device_id; | 1484 | unsigned long long device_id; |
1477 | int status; | 1485 | int status; |
1478 | struct acpi_video_device *data; | 1486 | struct acpi_video_device *data; |
1479 | struct acpi_video_device_attrib* attribute; | 1487 | struct acpi_video_device_attrib* attribute; |
@@ -1491,7 +1499,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
1491 | 1499 | ||
1492 | strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME); | 1500 | strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME); |
1493 | strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); | 1501 | strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); |
1494 | acpi_driver_data(device) = data; | 1502 | device->driver_data = data; |
1495 | 1503 | ||
1496 | data->device_id = device_id; | 1504 | data->device_id = device_id; |
1497 | data->video = video; | 1505 | data->video = video; |
@@ -1530,8 +1538,8 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
1530 | acpi_video_device_notify, | 1538 | acpi_video_device_notify, |
1531 | data); | 1539 | data); |
1532 | if (ACPI_FAILURE(status)) { | 1540 | if (ACPI_FAILURE(status)) { |
1533 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1541 | printk(KERN_ERR PREFIX |
1534 | "Error installing notify handler\n")); | 1542 | "Error installing notify handler\n"); |
1535 | if(data->brightness) | 1543 | if(data->brightness) |
1536 | kfree(data->brightness->levels); | 1544 | kfree(data->brightness->levels); |
1537 | kfree(data->brightness); | 1545 | kfree(data->brightness); |
@@ -1724,7 +1732,7 @@ acpi_video_get_next_level(struct acpi_video_device *device, | |||
1724 | static void | 1732 | static void |
1725 | acpi_video_switch_brightness(struct acpi_video_device *device, int event) | 1733 | acpi_video_switch_brightness(struct acpi_video_device *device, int event) |
1726 | { | 1734 | { |
1727 | unsigned long level_current, level_next; | 1735 | unsigned long long level_current, level_next; |
1728 | if (!device->brightness) | 1736 | if (!device->brightness) |
1729 | return; | 1737 | return; |
1730 | acpi_video_device_lcd_get_level_current(device, &level_current); | 1738 | acpi_video_device_lcd_get_level_current(device, &level_current); |
@@ -1745,8 +1753,8 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video, | |||
1745 | 1753 | ||
1746 | status = acpi_video_bus_get_one_device(dev, video); | 1754 | status = acpi_video_bus_get_one_device(dev, video); |
1747 | if (ACPI_FAILURE(status)) { | 1755 | if (ACPI_FAILURE(status)) { |
1748 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 1756 | printk(KERN_WARNING PREFIX |
1749 | "Cant attach device")); | 1757 | "Cant attach device"); |
1750 | continue; | 1758 | continue; |
1751 | } | 1759 | } |
1752 | } | 1760 | } |
@@ -1982,7 +1990,7 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1982 | video->device = device; | 1990 | video->device = device; |
1983 | strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); | 1991 | strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); |
1984 | strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); | 1992 | strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); |
1985 | acpi_driver_data(device) = video; | 1993 | device->driver_data = video; |
1986 | 1994 | ||
1987 | acpi_video_bus_find_cap(video); | 1995 | acpi_video_bus_find_cap(video); |
1988 | error = acpi_video_bus_check(video); | 1996 | error = acpi_video_bus_check(video); |
@@ -2003,8 +2011,8 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
2003 | ACPI_DEVICE_NOTIFY, | 2011 | ACPI_DEVICE_NOTIFY, |
2004 | acpi_video_bus_notify, video); | 2012 | acpi_video_bus_notify, video); |
2005 | if (ACPI_FAILURE(status)) { | 2013 | if (ACPI_FAILURE(status)) { |
2006 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 2014 | printk(KERN_ERR PREFIX |
2007 | "Error installing notify handler\n")); | 2015 | "Error installing notify handler\n"); |
2008 | error = -ENODEV; | 2016 | error = -ENODEV; |
2009 | goto err_stop_video; | 2017 | goto err_stop_video; |
2010 | } | 2018 | } |
@@ -2058,7 +2066,7 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
2058 | acpi_video_bus_remove_fs(device); | 2066 | acpi_video_bus_remove_fs(device); |
2059 | err_free_video: | 2067 | err_free_video: |
2060 | kfree(video); | 2068 | kfree(video); |
2061 | acpi_driver_data(device) = NULL; | 2069 | device->driver_data = NULL; |
2062 | 2070 | ||
2063 | return error; | 2071 | return error; |
2064 | } | 2072 | } |
@@ -2094,12 +2102,6 @@ static int __init acpi_video_init(void) | |||
2094 | { | 2102 | { |
2095 | int result = 0; | 2103 | int result = 0; |
2096 | 2104 | ||
2097 | |||
2098 | /* | ||
2099 | acpi_dbg_level = 0xFFFFFFFF; | ||
2100 | acpi_dbg_layer = 0x08000000; | ||
2101 | */ | ||
2102 | |||
2103 | acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); | 2105 | acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); |
2104 | if (!acpi_video_dir) | 2106 | if (!acpi_video_dir) |
2105 | return -ENODEV; | 2107 | return -ENODEV; |
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c new file mode 100644 index 000000000000..f022eb6f5637 --- /dev/null +++ b/drivers/acpi/video_detect.c | |||
@@ -0,0 +1,267 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2008 SuSE Linux Products GmbH | ||
3 | * Thomas Renninger <trenn@suse.de> | ||
4 | * | ||
5 | * May be copied or modified under the terms of the GNU General Public License | ||
6 | * | ||
7 | * video_detect.c: | ||
8 | * Provides acpi_is_video_device() for early scanning of ACPI devices in scan.c | ||
9 | * There a Linux specific (Spec does not provide a HID for video devices) is | ||
10 | * assinged | ||
11 | * | ||
12 | * After PCI devices are glued with ACPI devices | ||
13 | * acpi_get_physical_pci_device() can be called to identify ACPI graphics | ||
14 | * devices for which a real graphics card is plugged in | ||
15 | * | ||
16 | * Now acpi_video_get_capabilities() can be called to check which | ||
17 | * capabilities the graphics cards plugged in support. The check for general | ||
18 | * video capabilities will be triggered by the first caller of | ||
19 | * acpi_video_get_capabilities(NULL); which will happen when the first | ||
20 | * backlight (or display output) switching supporting driver calls: | ||
21 | * acpi_video_backlight_support(); | ||
22 | * | ||
23 | * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B) | ||
24 | * are available, video.ko should be used to handle the device. | ||
25 | * | ||
26 | * Otherwise vendor specific drivers like thinkpad_acpi, asus_acpi, | ||
27 | * sony_acpi,... can take care about backlight brightness and display output | ||
28 | * switching. | ||
29 | * | ||
30 | * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) | ||
31 | * this file will not be compiled, acpi_video_get_capabilities() and | ||
32 | * acpi_video_backlight_support() will always return 0 and vendor specific | ||
33 | * drivers always can handle backlight. | ||
34 | * | ||
35 | */ | ||
36 | |||
37 | #include <linux/acpi.h> | ||
38 | #include <linux/dmi.h> | ||
39 | |||
40 | ACPI_MODULE_NAME("video"); | ||
41 | #define _COMPONENT ACPI_VIDEO_COMPONENT | ||
42 | |||
43 | static long acpi_video_support; | ||
44 | static bool acpi_video_caps_checked; | ||
45 | |||
46 | static acpi_status | ||
47 | acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, | ||
48 | void **retyurn_value) | ||
49 | { | ||
50 | long *cap = context; | ||
51 | acpi_handle h_dummy; | ||
52 | |||
53 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_BCM", &h_dummy)) && | ||
54 | ACPI_SUCCESS(acpi_get_handle(handle, "_BCL", &h_dummy))) { | ||
55 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight " | ||
56 | "support\n")); | ||
57 | *cap |= ACPI_VIDEO_BACKLIGHT; | ||
58 | /* We have backlight support, no need to scan further */ | ||
59 | return AE_CTRL_TERMINATE; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | /* Returns true if the device is a video device which can be handled by | ||
65 | * video.ko. | ||
66 | * The device will get a Linux specific CID added in scan.c to | ||
67 | * identify the device as an ACPI graphics device | ||
68 | * Be aware that the graphics device may not be physically present | ||
69 | * Use acpi_video_get_capabilities() to detect general ACPI video | ||
70 | * capabilities of present cards | ||
71 | */ | ||
72 | long acpi_is_video_device(struct acpi_device *device) | ||
73 | { | ||
74 | acpi_handle h_dummy; | ||
75 | long video_caps = 0; | ||
76 | |||
77 | if (!device) | ||
78 | return 0; | ||
79 | |||
80 | /* Does this device able to support video switching ? */ | ||
81 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) && | ||
82 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy))) | ||
83 | video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; | ||
84 | |||
85 | /* Does this device able to retrieve a video ROM ? */ | ||
86 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy))) | ||
87 | video_caps |= ACPI_VIDEO_ROM_AVAILABLE; | ||
88 | |||
89 | /* Does this device able to configure which video head to be POSTed ? */ | ||
90 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) && | ||
91 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) && | ||
92 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy))) | ||
93 | video_caps |= ACPI_VIDEO_DEVICE_POSTING; | ||
94 | |||
95 | /* Only check for backlight functionality if one of the above hit. */ | ||
96 | if (video_caps) | ||
97 | acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle, | ||
98 | ACPI_UINT32_MAX, acpi_backlight_cap_match, | ||
99 | &video_caps, NULL); | ||
100 | |||
101 | return video_caps; | ||
102 | } | ||
103 | EXPORT_SYMBOL(acpi_is_video_device); | ||
104 | |||
105 | static acpi_status | ||
106 | find_video(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
107 | { | ||
108 | long *cap = context; | ||
109 | struct device *dev; | ||
110 | struct acpi_device *acpi_dev; | ||
111 | |||
112 | const struct acpi_device_id video_ids[] = { | ||
113 | {ACPI_VIDEO_HID, 0}, | ||
114 | {"", 0}, | ||
115 | }; | ||
116 | if (acpi_bus_get_device(handle, &acpi_dev)) | ||
117 | return AE_OK; | ||
118 | |||
119 | if (!acpi_match_device_ids(acpi_dev, video_ids)) { | ||
120 | dev = acpi_get_physical_pci_device(handle); | ||
121 | if (!dev) | ||
122 | return AE_OK; | ||
123 | put_device(dev); | ||
124 | *cap |= acpi_is_video_device(acpi_dev); | ||
125 | } | ||
126 | return AE_OK; | ||
127 | } | ||
128 | |||
129 | /* | ||
130 | * Returns the video capabilities of a specific ACPI graphics device | ||
131 | * | ||
132 | * if NULL is passed as argument all ACPI devices are enumerated and | ||
133 | * all graphics capabilities of physically present devices are | ||
134 | * summerized and returned. This is cached and done only once. | ||
135 | */ | ||
136 | long acpi_video_get_capabilities(acpi_handle graphics_handle) | ||
137 | { | ||
138 | long caps = 0; | ||
139 | struct acpi_device *tmp_dev; | ||
140 | acpi_status status; | ||
141 | |||
142 | if (acpi_video_caps_checked && graphics_handle == NULL) | ||
143 | return acpi_video_support; | ||
144 | |||
145 | if (!graphics_handle) { | ||
146 | /* Only do the global walk through all graphics devices once */ | ||
147 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
148 | ACPI_UINT32_MAX, find_video, | ||
149 | &caps, NULL); | ||
150 | /* There might be boot param flags set already... */ | ||
151 | acpi_video_support |= caps; | ||
152 | acpi_video_caps_checked = 1; | ||
153 | /* Add blacklists here. Be careful to use the right *DMI* bits | ||
154 | * to still be able to override logic via boot params, e.g.: | ||
155 | * | ||
156 | * if (dmi_name_in_vendors("XY")) { | ||
157 | * acpi_video_support |= | ||
158 | * ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR; | ||
159 | * acpi_video_support |= | ||
160 | * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR; | ||
161 | *} | ||
162 | */ | ||
163 | } else { | ||
164 | status = acpi_bus_get_device(graphics_handle, &tmp_dev); | ||
165 | if (ACPI_FAILURE(status)) { | ||
166 | ACPI_EXCEPTION((AE_INFO, status, "Invalid device")); | ||
167 | return 0; | ||
168 | } | ||
169 | acpi_walk_namespace(ACPI_TYPE_DEVICE, graphics_handle, | ||
170 | ACPI_UINT32_MAX, find_video, | ||
171 | &caps, NULL); | ||
172 | } | ||
173 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "We have 0x%lX video support %s %s\n", | ||
174 | graphics_handle ? caps : acpi_video_support, | ||
175 | graphics_handle ? "on device " : "in general", | ||
176 | graphics_handle ? acpi_device_bid(tmp_dev) : "")); | ||
177 | return caps; | ||
178 | } | ||
179 | EXPORT_SYMBOL(acpi_video_get_capabilities); | ||
180 | |||
181 | /* Returns true if video.ko can do backlight switching */ | ||
182 | int acpi_video_backlight_support(void) | ||
183 | { | ||
184 | /* | ||
185 | * We must check whether the ACPI graphics device is physically plugged | ||
186 | * in. Therefore this must be called after binding PCI and ACPI devices | ||
187 | */ | ||
188 | if (!acpi_video_caps_checked) | ||
189 | acpi_video_get_capabilities(NULL); | ||
190 | |||
191 | /* First check for boot param -> highest prio */ | ||
192 | if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR) | ||
193 | return 0; | ||
194 | else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO) | ||
195 | return 1; | ||
196 | |||
197 | /* Then check for DMI blacklist -> second highest prio */ | ||
198 | if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VENDOR) | ||
199 | return 0; | ||
200 | else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VIDEO) | ||
201 | return 1; | ||
202 | |||
203 | /* Then go the default way */ | ||
204 | return acpi_video_support & ACPI_VIDEO_BACKLIGHT; | ||
205 | } | ||
206 | EXPORT_SYMBOL(acpi_video_backlight_support); | ||
207 | |||
208 | /* | ||
209 | * Returns true if video.ko can do display output switching. | ||
210 | * This does not work well/at all with binary graphics drivers | ||
211 | * which disable system io ranges and do it on their own. | ||
212 | */ | ||
213 | int acpi_video_display_switch_support(void) | ||
214 | { | ||
215 | if (!acpi_video_caps_checked) | ||
216 | acpi_video_get_capabilities(NULL); | ||
217 | |||
218 | if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR) | ||
219 | return 0; | ||
220 | else if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO) | ||
221 | return 1; | ||
222 | |||
223 | if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR) | ||
224 | return 0; | ||
225 | else if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO) | ||
226 | return 1; | ||
227 | |||
228 | return acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING; | ||
229 | } | ||
230 | EXPORT_SYMBOL(acpi_video_display_switch_support); | ||
231 | |||
232 | /* | ||
233 | * Use acpi_display_output=vendor/video or acpi_backlight=vendor/video | ||
234 | * To force that backlight or display output switching is processed by vendor | ||
235 | * specific acpi drivers or video.ko driver. | ||
236 | */ | ||
237 | int __init acpi_backlight(char *str) | ||
238 | { | ||
239 | if (str == NULL || *str == '\0') | ||
240 | return 1; | ||
241 | else { | ||
242 | if (!strcmp("vendor", str)) | ||
243 | acpi_video_support |= | ||
244 | ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR; | ||
245 | if (!strcmp("video", str)) | ||
246 | acpi_video_support |= | ||
247 | ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO; | ||
248 | } | ||
249 | return 1; | ||
250 | } | ||
251 | __setup("acpi_backlight=", acpi_backlight); | ||
252 | |||
253 | int __init acpi_display_output(char *str) | ||
254 | { | ||
255 | if (str == NULL || *str == '\0') | ||
256 | return 1; | ||
257 | else { | ||
258 | if (!strcmp("vendor", str)) | ||
259 | acpi_video_support |= | ||
260 | ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR; | ||
261 | if (!strcmp("video", str)) | ||
262 | acpi_video_support |= | ||
263 | ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO; | ||
264 | } | ||
265 | return 1; | ||
266 | } | ||
267 | __setup("acpi_display_output=", acpi_display_output); | ||
diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c index cfe2c833474d..8a8b377712c9 100644 --- a/drivers/acpi/wmi.c +++ b/drivers/acpi/wmi.c | |||
@@ -217,6 +217,35 @@ static bool find_guid(const char *guid_string, struct wmi_block **out) | |||
217 | return 0; | 217 | return 0; |
218 | } | 218 | } |
219 | 219 | ||
220 | static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) | ||
221 | { | ||
222 | struct guid_block *block = NULL; | ||
223 | char method[5]; | ||
224 | struct acpi_object_list input; | ||
225 | union acpi_object params[1]; | ||
226 | acpi_status status; | ||
227 | acpi_handle handle; | ||
228 | |||
229 | block = &wblock->gblock; | ||
230 | handle = wblock->handle; | ||
231 | |||
232 | if (!block) | ||
233 | return AE_NOT_EXIST; | ||
234 | |||
235 | input.count = 1; | ||
236 | input.pointer = params; | ||
237 | params[0].type = ACPI_TYPE_INTEGER; | ||
238 | params[0].integer.value = enable; | ||
239 | |||
240 | snprintf(method, 5, "WE%02X", block->notify_id); | ||
241 | status = acpi_evaluate_object(handle, method, &input, NULL); | ||
242 | |||
243 | if (status != AE_OK && status != AE_NOT_FOUND) | ||
244 | return status; | ||
245 | else | ||
246 | return AE_OK; | ||
247 | } | ||
248 | |||
220 | /* | 249 | /* |
221 | * Exported WMI functions | 250 | * Exported WMI functions |
222 | */ | 251 | */ |
@@ -242,7 +271,7 @@ u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out) | |||
242 | char method[4] = "WM"; | 271 | char method[4] = "WM"; |
243 | 272 | ||
244 | if (!find_guid(guid_string, &wblock)) | 273 | if (!find_guid(guid_string, &wblock)) |
245 | return AE_BAD_ADDRESS; | 274 | return AE_ERROR; |
246 | 275 | ||
247 | block = &wblock->gblock; | 276 | block = &wblock->gblock; |
248 | handle = wblock->handle; | 277 | handle = wblock->handle; |
@@ -304,7 +333,7 @@ struct acpi_buffer *out) | |||
304 | return AE_BAD_PARAMETER; | 333 | return AE_BAD_PARAMETER; |
305 | 334 | ||
306 | if (!find_guid(guid_string, &wblock)) | 335 | if (!find_guid(guid_string, &wblock)) |
307 | return AE_BAD_ADDRESS; | 336 | return AE_ERROR; |
308 | 337 | ||
309 | block = &wblock->gblock; | 338 | block = &wblock->gblock; |
310 | handle = wblock->handle; | 339 | handle = wblock->handle; |
@@ -314,7 +343,7 @@ struct acpi_buffer *out) | |||
314 | 343 | ||
315 | /* Check GUID is a data block */ | 344 | /* Check GUID is a data block */ |
316 | if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) | 345 | if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) |
317 | return AE_BAD_ADDRESS; | 346 | return AE_ERROR; |
318 | 347 | ||
319 | input.count = 1; | 348 | input.count = 1; |
320 | input.pointer = wq_params; | 349 | input.pointer = wq_params; |
@@ -385,7 +414,7 @@ const struct acpi_buffer *in) | |||
385 | return AE_BAD_DATA; | 414 | return AE_BAD_DATA; |
386 | 415 | ||
387 | if (!find_guid(guid_string, &wblock)) | 416 | if (!find_guid(guid_string, &wblock)) |
388 | return AE_BAD_ADDRESS; | 417 | return AE_ERROR; |
389 | 418 | ||
390 | block = &wblock->gblock; | 419 | block = &wblock->gblock; |
391 | handle = wblock->handle; | 420 | handle = wblock->handle; |
@@ -395,7 +424,7 @@ const struct acpi_buffer *in) | |||
395 | 424 | ||
396 | /* Check GUID is a data block */ | 425 | /* Check GUID is a data block */ |
397 | if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) | 426 | if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) |
398 | return AE_BAD_ADDRESS; | 427 | return AE_ERROR; |
399 | 428 | ||
400 | input.count = 2; | 429 | input.count = 2; |
401 | input.pointer = params; | 430 | input.pointer = params; |
@@ -427,6 +456,7 @@ acpi_status wmi_install_notify_handler(const char *guid, | |||
427 | wmi_notify_handler handler, void *data) | 456 | wmi_notify_handler handler, void *data) |
428 | { | 457 | { |
429 | struct wmi_block *block; | 458 | struct wmi_block *block; |
459 | acpi_status status; | ||
430 | 460 | ||
431 | if (!guid || !handler) | 461 | if (!guid || !handler) |
432 | return AE_BAD_PARAMETER; | 462 | return AE_BAD_PARAMETER; |
@@ -441,7 +471,9 @@ wmi_notify_handler handler, void *data) | |||
441 | block->handler = handler; | 471 | block->handler = handler; |
442 | block->handler_data = data; | 472 | block->handler_data = data; |
443 | 473 | ||
444 | return AE_OK; | 474 | status = wmi_method_enable(block, 1); |
475 | |||
476 | return status; | ||
445 | } | 477 | } |
446 | EXPORT_SYMBOL_GPL(wmi_install_notify_handler); | 478 | EXPORT_SYMBOL_GPL(wmi_install_notify_handler); |
447 | 479 | ||
@@ -453,6 +485,7 @@ EXPORT_SYMBOL_GPL(wmi_install_notify_handler); | |||
453 | acpi_status wmi_remove_notify_handler(const char *guid) | 485 | acpi_status wmi_remove_notify_handler(const char *guid) |
454 | { | 486 | { |
455 | struct wmi_block *block; | 487 | struct wmi_block *block; |
488 | acpi_status status; | ||
456 | 489 | ||
457 | if (!guid) | 490 | if (!guid) |
458 | return AE_BAD_PARAMETER; | 491 | return AE_BAD_PARAMETER; |
@@ -464,10 +497,12 @@ acpi_status wmi_remove_notify_handler(const char *guid) | |||
464 | if (!block->handler) | 497 | if (!block->handler) |
465 | return AE_NULL_ENTRY; | 498 | return AE_NULL_ENTRY; |
466 | 499 | ||
500 | status = wmi_method_enable(block, 0); | ||
501 | |||
467 | block->handler = NULL; | 502 | block->handler = NULL; |
468 | block->handler_data = NULL; | 503 | block->handler_data = NULL; |
469 | 504 | ||
470 | return AE_OK; | 505 | return status; |
471 | } | 506 | } |
472 | EXPORT_SYMBOL_GPL(wmi_remove_notify_handler); | 507 | EXPORT_SYMBOL_GPL(wmi_remove_notify_handler); |
473 | 508 | ||
@@ -625,7 +660,7 @@ static void acpi_wmi_notify(acpi_handle handle, u32 event, void *data) | |||
625 | wblock->handler(event, wblock->handler_data); | 660 | wblock->handler(event, wblock->handler_data); |
626 | 661 | ||
627 | acpi_bus_generate_netlink_event( | 662 | acpi_bus_generate_netlink_event( |
628 | device->pnp.device_class, device->dev.bus_id, | 663 | device->pnp.device_class, dev_name(&device->dev), |
629 | event, 0); | 664 | event, 0); |
630 | break; | 665 | break; |
631 | } | 666 | } |