aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/events
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/events')
-rw-r--r--drivers/acpi/events/evevent.c168
-rw-r--r--drivers/acpi/events/evgpe.c428
-rw-r--r--drivers/acpi/events/evgpeblk.c756
-rw-r--r--drivers/acpi/events/evmisc.c294
-rw-r--r--drivers/acpi/events/evregion.c582
-rw-r--r--drivers/acpi/events/evrgnini.c311
-rw-r--r--drivers/acpi/events/evsci.c77
-rw-r--r--drivers/acpi/events/evxface.c446
-rw-r--r--drivers/acpi/events/evxfevnt.c463
-rw-r--r--drivers/acpi/events/evxfregn.c114
10 files changed, 1657 insertions, 1982 deletions
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c
index dd3a72a869f4..842d1e3fb37b 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/events/evevent.c
@@ -45,18 +45,12 @@
45#include <acpi/acevents.h> 45#include <acpi/acevents.h>
46 46
47#define _COMPONENT ACPI_EVENTS 47#define _COMPONENT ACPI_EVENTS
48 ACPI_MODULE_NAME ("evevent") 48ACPI_MODULE_NAME("evevent")
49 49
50/* Local prototypes */ 50/* Local prototypes */
51static acpi_status acpi_ev_fixed_event_initialize(void);
51 52
52static acpi_status 53static u32 acpi_ev_fixed_event_dispatch(u32 event);
53acpi_ev_fixed_event_initialize (
54 void);
55
56static u32
57acpi_ev_fixed_event_dispatch (
58 u32 event);
59
60 54
61/******************************************************************************* 55/*******************************************************************************
62 * 56 *
@@ -70,21 +64,17 @@ acpi_ev_fixed_event_dispatch (
70 * 64 *
71 ******************************************************************************/ 65 ******************************************************************************/
72 66
73acpi_status 67acpi_status acpi_ev_initialize_events(void)
74acpi_ev_initialize_events (
75 void)
76{ 68{
77 acpi_status status; 69 acpi_status status;
78
79
80 ACPI_FUNCTION_TRACE ("ev_initialize_events");
81 70
71 ACPI_FUNCTION_TRACE("ev_initialize_events");
82 72
83 /* Make sure we have ACPI tables */ 73 /* Make sure we have ACPI tables */
84 74
85 if (!acpi_gbl_DSDT) { 75 if (!acpi_gbl_DSDT) {
86 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No ACPI tables present!\n")); 76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No ACPI tables present!\n"));
87 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 77 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
88 } 78 }
89 79
90 /* 80 /*
@@ -92,26 +82,22 @@ acpi_ev_initialize_events (
92 * enabling SCIs to prevent interrupts from occurring before the handlers are 82 * enabling SCIs to prevent interrupts from occurring before the handlers are
93 * installed. 83 * installed.
94 */ 84 */
95 status = acpi_ev_fixed_event_initialize (); 85 status = acpi_ev_fixed_event_initialize();
96 if (ACPI_FAILURE (status)) { 86 if (ACPI_FAILURE(status)) {
97 ACPI_REPORT_ERROR (( 87 ACPI_REPORT_ERROR(("Unable to initialize fixed events, %s\n",
98 "Unable to initialize fixed events, %s\n", 88 acpi_format_exception(status)));
99 acpi_format_exception (status))); 89 return_ACPI_STATUS(status);
100 return_ACPI_STATUS (status);
101 } 90 }
102 91
103 status = acpi_ev_gpe_initialize (); 92 status = acpi_ev_gpe_initialize();
104 if (ACPI_FAILURE (status)) { 93 if (ACPI_FAILURE(status)) {
105 ACPI_REPORT_ERROR (( 94 ACPI_REPORT_ERROR(("Unable to initialize general purpose events, %s\n", acpi_format_exception(status)));
106 "Unable to initialize general purpose events, %s\n", 95 return_ACPI_STATUS(status);
107 acpi_format_exception (status)));
108 return_ACPI_STATUS (status);
109 } 96 }
110 97
111 return_ACPI_STATUS (status); 98 return_ACPI_STATUS(status);
112} 99}
113 100
114
115/******************************************************************************* 101/*******************************************************************************
116 * 102 *
117 * FUNCTION: acpi_ev_install_xrupt_handlers 103 * FUNCTION: acpi_ev_install_xrupt_handlers
@@ -124,41 +110,32 @@ acpi_ev_initialize_events (
124 * 110 *
125 ******************************************************************************/ 111 ******************************************************************************/
126 112
127acpi_status 113acpi_status acpi_ev_install_xrupt_handlers(void)
128acpi_ev_install_xrupt_handlers (
129 void)
130{ 114{
131 acpi_status status; 115 acpi_status status;
132
133
134 ACPI_FUNCTION_TRACE ("ev_install_xrupt_handlers");
135 116
117 ACPI_FUNCTION_TRACE("ev_install_xrupt_handlers");
136 118
137 /* Install the SCI handler */ 119 /* Install the SCI handler */
138 120
139 status = acpi_ev_install_sci_handler (); 121 status = acpi_ev_install_sci_handler();
140 if (ACPI_FAILURE (status)) { 122 if (ACPI_FAILURE(status)) {
141 ACPI_REPORT_ERROR (( 123 ACPI_REPORT_ERROR(("Unable to install System Control Interrupt Handler, %s\n", acpi_format_exception(status)));
142 "Unable to install System Control Interrupt Handler, %s\n", 124 return_ACPI_STATUS(status);
143 acpi_format_exception (status)));
144 return_ACPI_STATUS (status);
145 } 125 }
146 126
147 /* Install the handler for the Global Lock */ 127 /* Install the handler for the Global Lock */
148 128
149 status = acpi_ev_init_global_lock_handler (); 129 status = acpi_ev_init_global_lock_handler();
150 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
151 ACPI_REPORT_ERROR (( 131 ACPI_REPORT_ERROR(("Unable to initialize Global Lock handler, %s\n", acpi_format_exception(status)));
152 "Unable to initialize Global Lock handler, %s\n", 132 return_ACPI_STATUS(status);
153 acpi_format_exception (status)));
154 return_ACPI_STATUS (status);
155 } 133 }
156 134
157 acpi_gbl_events_initialized = TRUE; 135 acpi_gbl_events_initialized = TRUE;
158 return_ACPI_STATUS (status); 136 return_ACPI_STATUS(status);
159} 137}
160 138
161
162/******************************************************************************* 139/*******************************************************************************
163 * 140 *
164 * FUNCTION: acpi_ev_fixed_event_initialize 141 * FUNCTION: acpi_ev_fixed_event_initialize
@@ -171,13 +148,10 @@ acpi_ev_install_xrupt_handlers (
171 * 148 *
172 ******************************************************************************/ 149 ******************************************************************************/
173 150
174static acpi_status 151static acpi_status acpi_ev_fixed_event_initialize(void)
175acpi_ev_fixed_event_initialize (
176 void)
177{ 152{
178 acpi_native_uint i; 153 acpi_native_uint i;
179 acpi_status status; 154 acpi_status status;
180
181 155
182 /* 156 /*
183 * Initialize the structure that keeps track of fixed event handlers 157 * Initialize the structure that keeps track of fixed event handlers
@@ -190,10 +164,11 @@ acpi_ev_fixed_event_initialize (
190 /* Enable the fixed event */ 164 /* Enable the fixed event */
191 165
192 if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) { 166 if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
193 status = acpi_set_register ( 167 status =
194 acpi_gbl_fixed_event_info[i].enable_register_id, 168 acpi_set_register(acpi_gbl_fixed_event_info[i].
195 0, ACPI_MTX_LOCK); 169 enable_register_id, 0,
196 if (ACPI_FAILURE (status)) { 170 ACPI_MTX_LOCK);
171 if (ACPI_FAILURE(status)) {
197 return (status); 172 return (status);
198 } 173 }
199 } 174 }
@@ -202,7 +177,6 @@ acpi_ev_fixed_event_initialize (
202 return (AE_OK); 177 return (AE_OK);
203} 178}
204 179
205
206/******************************************************************************* 180/*******************************************************************************
207 * 181 *
208 * FUNCTION: acpi_ev_fixed_event_detect 182 * FUNCTION: acpi_ev_fixed_event_detect
@@ -215,31 +189,27 @@ acpi_ev_fixed_event_initialize (
215 * 189 *
216 ******************************************************************************/ 190 ******************************************************************************/
217 191
218u32 192u32 acpi_ev_fixed_event_detect(void)
219acpi_ev_fixed_event_detect (
220 void)
221{ 193{
222 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 194 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
223 u32 fixed_status; 195 u32 fixed_status;
224 u32 fixed_enable; 196 u32 fixed_enable;
225 acpi_native_uint i; 197 acpi_native_uint i;
226
227
228 ACPI_FUNCTION_NAME ("ev_fixed_event_detect");
229 198
199 ACPI_FUNCTION_NAME("ev_fixed_event_detect");
230 200
231 /* 201 /*
232 * Read the fixed feature status and enable registers, as all the cases 202 * Read the fixed feature status and enable registers, as all the cases
233 * depend on their values. Ignore errors here. 203 * depend on their values. Ignore errors here.
234 */ 204 */
235 (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, 205 (void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
236 &fixed_status); 206 ACPI_REGISTER_PM1_STATUS, &fixed_status);
237 (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, 207 (void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
238 &fixed_enable); 208 ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
239 209
240 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, 210 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
241 "Fixed Event Block: Enable %08X Status %08X\n", 211 "Fixed Event Block: Enable %08X Status %08X\n",
242 fixed_enable, fixed_status)); 212 fixed_enable, fixed_status));
243 213
244 /* 214 /*
245 * Check for all possible Fixed Events and dispatch those that are active 215 * Check for all possible Fixed Events and dispatch those that are active
@@ -247,18 +217,19 @@ acpi_ev_fixed_event_detect (
247 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 217 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
248 /* Both the status and enable bits must be on for this event */ 218 /* Both the status and enable bits must be on for this event */
249 219
250 if ((fixed_status & acpi_gbl_fixed_event_info[i].status_bit_mask) && 220 if ((fixed_status & acpi_gbl_fixed_event_info[i].
251 (fixed_enable & acpi_gbl_fixed_event_info[i].enable_bit_mask)) { 221 status_bit_mask)
222 && (fixed_enable & acpi_gbl_fixed_event_info[i].
223 enable_bit_mask)) {
252 /* Found an active (signalled) event */ 224 /* Found an active (signalled) event */
253 225
254 int_status |= acpi_ev_fixed_event_dispatch ((u32) i); 226 int_status |= acpi_ev_fixed_event_dispatch((u32) i);
255 } 227 }
256 } 228 }
257 229
258 return (int_status); 230 return (int_status);
259} 231}
260 232
261
262/******************************************************************************* 233/*******************************************************************************
263 * 234 *
264 * FUNCTION: acpi_ev_fixed_event_dispatch 235 * FUNCTION: acpi_ev_fixed_event_dispatch
@@ -272,39 +243,32 @@ acpi_ev_fixed_event_detect (
272 * 243 *
273 ******************************************************************************/ 244 ******************************************************************************/
274 245
275static u32 246static u32 acpi_ev_fixed_event_dispatch(u32 event)
276acpi_ev_fixed_event_dispatch (
277 u32 event)
278{ 247{
279 248
280 249 ACPI_FUNCTION_ENTRY();
281 ACPI_FUNCTION_ENTRY ();
282
283 250
284 /* Clear the status bit */ 251 /* Clear the status bit */
285 252
286 (void) acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id, 253 (void)acpi_set_register(acpi_gbl_fixed_event_info[event].
287 1, ACPI_MTX_DO_NOT_LOCK); 254 status_register_id, 1, ACPI_MTX_DO_NOT_LOCK);
288 255
289 /* 256 /*
290 * Make sure we've got a handler. If not, report an error. 257 * Make sure we've got a handler. If not, report an error.
291 * The event is disabled to prevent further interrupts. 258 * The event is disabled to prevent further interrupts.
292 */ 259 */
293 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { 260 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) {
294 (void) acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, 261 (void)acpi_set_register(acpi_gbl_fixed_event_info[event].
295 0, ACPI_MTX_DO_NOT_LOCK); 262 enable_register_id, 0,
263 ACPI_MTX_DO_NOT_LOCK);
296 264
297 ACPI_REPORT_ERROR ( 265 ACPI_REPORT_ERROR(("No installed handler for fixed event [%08X]\n", event));
298 ("No installed handler for fixed event [%08X]\n",
299 event));
300 266
301 return (ACPI_INTERRUPT_NOT_HANDLED); 267 return (ACPI_INTERRUPT_NOT_HANDLED);
302 } 268 }
303 269
304 /* Invoke the Fixed Event handler */ 270 /* Invoke the Fixed Event handler */
305 271
306 return ((acpi_gbl_fixed_event_handlers[event].handler)( 272 return ((acpi_gbl_fixed_event_handlers[event].
307 acpi_gbl_fixed_event_handlers[event].context)); 273 handler) (acpi_gbl_fixed_event_handlers[event].context));
308} 274}
309
310
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index ede834df4f69..b2f232df13d8 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -46,14 +46,10 @@
46#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
47 47
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evgpe") 49ACPI_MODULE_NAME("evgpe")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52 52static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
53static void ACPI_SYSTEM_XFACE
54acpi_ev_asynch_execute_gpe_method (
55 void *context);
56
57 53
58/******************************************************************************* 54/*******************************************************************************
59 * 55 *
@@ -69,15 +65,11 @@ acpi_ev_asynch_execute_gpe_method (
69 ******************************************************************************/ 65 ******************************************************************************/
70 66
71acpi_status 67acpi_status
72acpi_ev_set_gpe_type ( 68acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type)
73 struct acpi_gpe_event_info *gpe_event_info,
74 u8 type)
75{ 69{
76 acpi_status status; 70 acpi_status status;
77
78
79 ACPI_FUNCTION_TRACE ("ev_set_gpe_type");
80 71
72 ACPI_FUNCTION_TRACE("ev_set_gpe_type");
81 73
82 /* Validate type and update register enable masks */ 74 /* Validate type and update register enable masks */
83 75
@@ -88,21 +80,20 @@ acpi_ev_set_gpe_type (
88 break; 80 break;
89 81
90 default: 82 default:
91 return_ACPI_STATUS (AE_BAD_PARAMETER); 83 return_ACPI_STATUS(AE_BAD_PARAMETER);
92 } 84 }
93 85
94 /* Disable the GPE if currently enabled */ 86 /* Disable the GPE if currently enabled */
95 87
96 status = acpi_ev_disable_gpe (gpe_event_info); 88 status = acpi_ev_disable_gpe(gpe_event_info);
97 89
98 /* Type was validated above */ 90 /* Type was validated above */
99 91
100 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ 92 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */
101 gpe_event_info->flags |= type; /* Insert type */ 93 gpe_event_info->flags |= type; /* Insert type */
102 return_ACPI_STATUS (status); 94 return_ACPI_STATUS(status);
103} 95}
104 96
105
106/******************************************************************************* 97/*******************************************************************************
107 * 98 *
108 * FUNCTION: acpi_ev_update_gpe_enable_masks 99 * FUNCTION: acpi_ev_update_gpe_enable_masks
@@ -118,57 +109,55 @@ acpi_ev_set_gpe_type (
118 ******************************************************************************/ 109 ******************************************************************************/
119 110
120acpi_status 111acpi_status
121acpi_ev_update_gpe_enable_masks ( 112acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
122 struct acpi_gpe_event_info *gpe_event_info, 113 u8 type)
123 u8 type)
124{ 114{
125 struct acpi_gpe_register_info *gpe_register_info; 115 struct acpi_gpe_register_info *gpe_register_info;
126 u8 register_bit; 116 u8 register_bit;
127
128
129 ACPI_FUNCTION_TRACE ("ev_update_gpe_enable_masks");
130 117
118 ACPI_FUNCTION_TRACE("ev_update_gpe_enable_masks");
131 119
132 gpe_register_info = gpe_event_info->register_info; 120 gpe_register_info = gpe_event_info->register_info;
133 if (!gpe_register_info) { 121 if (!gpe_register_info) {
134 return_ACPI_STATUS (AE_NOT_EXIST); 122 return_ACPI_STATUS(AE_NOT_EXIST);
135 } 123 }
136 register_bit = gpe_event_info->register_bit; 124 register_bit = gpe_event_info->register_bit;
137 125
138 /* 1) Disable case. Simply clear all enable bits */ 126 /* 1) Disable case. Simply clear all enable bits */
139 127
140 if (type == ACPI_GPE_DISABLE) { 128 if (type == ACPI_GPE_DISABLE) {
141 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit); 129 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
142 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit); 130 register_bit);
143 return_ACPI_STATUS (AE_OK); 131 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
132 return_ACPI_STATUS(AE_OK);
144 } 133 }
145 134
146 /* 2) Enable case. Set/Clear the appropriate enable bits */ 135 /* 2) Enable case. Set/Clear the appropriate enable bits */
147 136
148 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 137 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
149 case ACPI_GPE_TYPE_WAKE: 138 case ACPI_GPE_TYPE_WAKE:
150 ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit); 139 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
151 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit); 140 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
152 break; 141 break;
153 142
154 case ACPI_GPE_TYPE_RUNTIME: 143 case ACPI_GPE_TYPE_RUNTIME:
155 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit); 144 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
156 ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit); 145 register_bit);
146 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
157 break; 147 break;
158 148
159 case ACPI_GPE_TYPE_WAKE_RUN: 149 case ACPI_GPE_TYPE_WAKE_RUN:
160 ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit); 150 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
161 ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit); 151 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
162 break; 152 break;
163 153
164 default: 154 default:
165 return_ACPI_STATUS (AE_BAD_PARAMETER); 155 return_ACPI_STATUS(AE_BAD_PARAMETER);
166 } 156 }
167 157
168 return_ACPI_STATUS (AE_OK); 158 return_ACPI_STATUS(AE_OK);
169} 159}
170 160
171
172/******************************************************************************* 161/*******************************************************************************
173 * 162 *
174 * FUNCTION: acpi_ev_enable_gpe 163 * FUNCTION: acpi_ev_enable_gpe
@@ -184,21 +173,19 @@ acpi_ev_update_gpe_enable_masks (
184 ******************************************************************************/ 173 ******************************************************************************/
185 174
186acpi_status 175acpi_status
187acpi_ev_enable_gpe ( 176acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
188 struct acpi_gpe_event_info *gpe_event_info, 177 u8 write_to_hardware)
189 u8 write_to_hardware)
190{ 178{
191 acpi_status status; 179 acpi_status status;
192
193
194 ACPI_FUNCTION_TRACE ("ev_enable_gpe");
195 180
181 ACPI_FUNCTION_TRACE("ev_enable_gpe");
196 182
197 /* Make sure HW enable masks are updated */ 183 /* Make sure HW enable masks are updated */
198 184
199 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_ENABLE); 185 status =
200 if (ACPI_FAILURE (status)) { 186 acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_ENABLE);
201 return_ACPI_STATUS (status); 187 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS(status);
202 } 189 }
203 190
204 /* Mark wake-enabled or HW enable, or both */ 191 /* Mark wake-enabled or HW enable, or both */
@@ -206,41 +193,40 @@ acpi_ev_enable_gpe (
206 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 193 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
207 case ACPI_GPE_TYPE_WAKE: 194 case ACPI_GPE_TYPE_WAKE:
208 195
209 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 196 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
210 break; 197 break;
211 198
212 case ACPI_GPE_TYPE_WAKE_RUN: 199 case ACPI_GPE_TYPE_WAKE_RUN:
213 200
214 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 201 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
215 202
216 /*lint -fallthrough */ 203 /*lint -fallthrough */
217 204
218 case ACPI_GPE_TYPE_RUNTIME: 205 case ACPI_GPE_TYPE_RUNTIME:
219 206
220 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); 207 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
221 208
222 if (write_to_hardware) { 209 if (write_to_hardware) {
223 /* Clear the GPE (of stale events), then enable it */ 210 /* Clear the GPE (of stale events), then enable it */
224 211
225 status = acpi_hw_clear_gpe (gpe_event_info); 212 status = acpi_hw_clear_gpe(gpe_event_info);
226 if (ACPI_FAILURE (status)) { 213 if (ACPI_FAILURE(status)) {
227 return_ACPI_STATUS (status); 214 return_ACPI_STATUS(status);
228 } 215 }
229 216
230 /* Enable the requested runtime GPE */ 217 /* Enable the requested runtime GPE */
231 218
232 status = acpi_hw_write_gpe_enable_reg (gpe_event_info); 219 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
233 } 220 }
234 break; 221 break;
235 222
236 default: 223 default:
237 return_ACPI_STATUS (AE_BAD_PARAMETER); 224 return_ACPI_STATUS(AE_BAD_PARAMETER);
238 } 225 }
239 226
240 return_ACPI_STATUS (AE_OK); 227 return_ACPI_STATUS(AE_OK);
241} 228}
242 229
243
244/******************************************************************************* 230/*******************************************************************************
245 * 231 *
246 * FUNCTION: acpi_ev_disable_gpe 232 * FUNCTION: acpi_ev_disable_gpe
@@ -253,36 +239,33 @@ acpi_ev_enable_gpe (
253 * 239 *
254 ******************************************************************************/ 240 ******************************************************************************/
255 241
256acpi_status 242acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
257acpi_ev_disable_gpe (
258 struct acpi_gpe_event_info *gpe_event_info)
259{ 243{
260 acpi_status status; 244 acpi_status status;
261
262
263 ACPI_FUNCTION_TRACE ("ev_disable_gpe");
264 245
246 ACPI_FUNCTION_TRACE("ev_disable_gpe");
265 247
266 if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) { 248 if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) {
267 return_ACPI_STATUS (AE_OK); 249 return_ACPI_STATUS(AE_OK);
268 } 250 }
269 251
270 /* Make sure HW enable masks are updated */ 252 /* Make sure HW enable masks are updated */
271 253
272 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE); 254 status =
273 if (ACPI_FAILURE (status)) { 255 acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_DISABLE);
274 return_ACPI_STATUS (status); 256 if (ACPI_FAILURE(status)) {
257 return_ACPI_STATUS(status);
275 } 258 }
276 259
277 /* Mark wake-disabled or HW disable, or both */ 260 /* Mark wake-disabled or HW disable, or both */
278 261
279 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 262 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
280 case ACPI_GPE_TYPE_WAKE: 263 case ACPI_GPE_TYPE_WAKE:
281 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 264 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
282 break; 265 break;
283 266
284 case ACPI_GPE_TYPE_WAKE_RUN: 267 case ACPI_GPE_TYPE_WAKE_RUN:
285 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); 268 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
286 269
287 /*lint -fallthrough */ 270 /*lint -fallthrough */
288 271
@@ -290,18 +273,17 @@ acpi_ev_disable_gpe (
290 273
291 /* Disable the requested runtime GPE */ 274 /* Disable the requested runtime GPE */
292 275
293 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); 276 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
294 status = acpi_hw_write_gpe_enable_reg (gpe_event_info); 277 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
295 break; 278 break;
296 279
297 default: 280 default:
298 return_ACPI_STATUS (AE_BAD_PARAMETER); 281 return_ACPI_STATUS(AE_BAD_PARAMETER);
299 } 282 }
300 283
301 return_ACPI_STATUS (AE_OK); 284 return_ACPI_STATUS(AE_OK);
302} 285}
303 286
304
305/******************************************************************************* 287/*******************************************************************************
306 * 288 *
307 * FUNCTION: acpi_ev_get_gpe_event_info 289 * FUNCTION: acpi_ev_get_gpe_event_info
@@ -319,18 +301,14 @@ acpi_ev_disable_gpe (
319 * 301 *
320 ******************************************************************************/ 302 ******************************************************************************/
321 303
322struct acpi_gpe_event_info * 304struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
323acpi_ev_get_gpe_event_info ( 305 u32 gpe_number)
324 acpi_handle gpe_device,
325 u32 gpe_number)
326{ 306{
327 union acpi_operand_object *obj_desc; 307 union acpi_operand_object *obj_desc;
328 struct acpi_gpe_block_info *gpe_block; 308 struct acpi_gpe_block_info *gpe_block;
329 acpi_native_uint i; 309 acpi_native_uint i;
330
331
332 ACPI_FUNCTION_ENTRY ();
333 310
311 ACPI_FUNCTION_ENTRY();
334 312
335 /* A NULL gpe_block means use the FADT-defined GPE block(s) */ 313 /* A NULL gpe_block means use the FADT-defined GPE block(s) */
336 314
@@ -340,11 +318,14 @@ acpi_ev_get_gpe_event_info (
340 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { 318 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
341 gpe_block = acpi_gbl_gpe_fadt_blocks[i]; 319 gpe_block = acpi_gbl_gpe_fadt_blocks[i];
342 if (gpe_block) { 320 if (gpe_block) {
343 if ((gpe_number >= gpe_block->block_base_number) && 321 if ((gpe_number >= gpe_block->block_base_number)
344 (gpe_number < gpe_block->block_base_number + 322 && (gpe_number <
345 (gpe_block->register_count * 8))) { 323 gpe_block->block_base_number +
346 return (&gpe_block->event_info[gpe_number - 324 (gpe_block->register_count * 8))) {
347 gpe_block->block_base_number]); 325 return (&gpe_block->
326 event_info[gpe_number -
327 gpe_block->
328 block_base_number]);
348 } 329 }
349 } 330 }
350 } 331 }
@@ -356,23 +337,25 @@ acpi_ev_get_gpe_event_info (
356 337
357 /* A Non-NULL gpe_device means this is a GPE Block Device */ 338 /* A Non-NULL gpe_device means this is a GPE Block Device */
358 339
359 obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device); 340 obj_desc =
360 if (!obj_desc || 341 acpi_ns_get_attached_object((struct acpi_namespace_node *)
361 !obj_desc->device.gpe_block) { 342 gpe_device);
343 if (!obj_desc || !obj_desc->device.gpe_block) {
362 return (NULL); 344 return (NULL);
363 } 345 }
364 346
365 gpe_block = obj_desc->device.gpe_block; 347 gpe_block = obj_desc->device.gpe_block;
366 348
367 if ((gpe_number >= gpe_block->block_base_number) && 349 if ((gpe_number >= gpe_block->block_base_number) &&
368 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { 350 (gpe_number <
369 return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]); 351 gpe_block->block_base_number + (gpe_block->register_count * 8))) {
352 return (&gpe_block->
353 event_info[gpe_number - gpe_block->block_base_number]);
370 } 354 }
371 355
372 return (NULL); 356 return (NULL);
373} 357}
374 358
375
376/******************************************************************************* 359/*******************************************************************************
377 * 360 *
378 * FUNCTION: acpi_ev_gpe_detect 361 * FUNCTION: acpi_ev_gpe_detect
@@ -387,23 +370,20 @@ acpi_ev_get_gpe_event_info (
387 * 370 *
388 ******************************************************************************/ 371 ******************************************************************************/
389 372
390u32 373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
391acpi_ev_gpe_detect (
392 struct acpi_gpe_xrupt_info *gpe_xrupt_list)
393{ 374{
394 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 375 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
395 u8 enabled_status_byte; 376 u8 enabled_status_byte;
396 struct acpi_gpe_register_info *gpe_register_info; 377 struct acpi_gpe_register_info *gpe_register_info;
397 u32 status_reg; 378 u32 status_reg;
398 u32 enable_reg; 379 u32 enable_reg;
399 u32 flags; 380 u32 flags;
400 acpi_status status; 381 acpi_status status;
401 struct acpi_gpe_block_info *gpe_block; 382 struct acpi_gpe_block_info *gpe_block;
402 acpi_native_uint i; 383 acpi_native_uint i;
403 acpi_native_uint j; 384 acpi_native_uint j;
404 385
405 386 ACPI_FUNCTION_NAME("ev_gpe_detect");
406 ACPI_FUNCTION_NAME ("ev_gpe_detect");
407 387
408 /* Check for the case where there are no GPEs */ 388 /* Check for the case where there are no GPEs */
409 389
@@ -413,7 +393,7 @@ acpi_ev_gpe_detect (
413 393
414 /* Examine all GPE blocks attached to this interrupt level */ 394 /* Examine all GPE blocks attached to this interrupt level */
415 395
416 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 396 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
417 gpe_block = gpe_xrupt_list->gpe_block_list_head; 397 gpe_block = gpe_xrupt_list->gpe_block_list_head;
418 while (gpe_block) { 398 while (gpe_block) {
419 /* 399 /*
@@ -428,23 +408,30 @@ acpi_ev_gpe_detect (
428 408
429 /* Read the Status Register */ 409 /* Read the Status Register */
430 410
431 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &status_reg, 411 status =
432 &gpe_register_info->status_address); 412 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
433 if (ACPI_FAILURE (status)) { 413 &status_reg,
414 &gpe_register_info->
415 status_address);
416 if (ACPI_FAILURE(status)) {
434 goto unlock_and_exit; 417 goto unlock_and_exit;
435 } 418 }
436 419
437 /* Read the Enable Register */ 420 /* Read the Enable Register */
438 421
439 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &enable_reg, 422 status =
440 &gpe_register_info->enable_address); 423 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
441 if (ACPI_FAILURE (status)) { 424 &enable_reg,
425 &gpe_register_info->
426 enable_address);
427 if (ACPI_FAILURE(status)) {
442 goto unlock_and_exit; 428 goto unlock_and_exit;
443 } 429 }
444 430
445 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, 431 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
446 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", 432 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
447 gpe_register_info->base_gpe_number, status_reg, enable_reg)); 433 gpe_register_info->base_gpe_number,
434 status_reg, enable_reg));
448 435
449 /* Check if there is anything active at all in this register */ 436 /* Check if there is anything active at all in this register */
450 437
@@ -460,14 +447,21 @@ acpi_ev_gpe_detect (
460 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 447 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
461 /* Examine one GPE bit */ 448 /* Examine one GPE bit */
462 449
463 if (enabled_status_byte & acpi_gbl_decode_to8bit[j]) { 450 if (enabled_status_byte &
451 acpi_gbl_decode_to8bit[j]) {
464 /* 452 /*
465 * Found an active GPE. Dispatch the event to a handler 453 * Found an active GPE. Dispatch the event to a handler
466 * or method. 454 * or method.
467 */ 455 */
468 int_status |= acpi_ev_gpe_dispatch ( 456 int_status |=
469 &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j], 457 acpi_ev_gpe_dispatch(&gpe_block->
470 (u32) j + gpe_register_info->base_gpe_number); 458 event_info[(i *
459 ACPI_GPE_REGISTER_WIDTH)
460 +
461 j],
462 (u32) j +
463 gpe_register_info->
464 base_gpe_number);
471 } 465 }
472 } 466 }
473 } 467 }
@@ -475,13 +469,12 @@ acpi_ev_gpe_detect (
475 gpe_block = gpe_block->next; 469 gpe_block = gpe_block->next;
476 } 470 }
477 471
478unlock_and_exit: 472 unlock_and_exit:
479 473
480 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 474 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
481 return (int_status); 475 return (int_status);
482} 476}
483 477
484
485/******************************************************************************* 478/*******************************************************************************
486 * 479 *
487 * FUNCTION: acpi_ev_asynch_execute_gpe_method 480 * FUNCTION: acpi_ev_asynch_execute_gpe_method
@@ -498,45 +491,41 @@ unlock_and_exit:
498 * 491 *
499 ******************************************************************************/ 492 ******************************************************************************/
500 493
501static void ACPI_SYSTEM_XFACE 494static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
502acpi_ev_asynch_execute_gpe_method (
503 void *context)
504{ 495{
505 struct acpi_gpe_event_info *gpe_event_info = (void *) context; 496 struct acpi_gpe_event_info *gpe_event_info = (void *)context;
506 u32 gpe_number = 0; 497 u32 gpe_number = 0;
507 acpi_status status; 498 acpi_status status;
508 struct acpi_gpe_event_info local_gpe_event_info; 499 struct acpi_gpe_event_info local_gpe_event_info;
509 struct acpi_parameter_info info; 500 struct acpi_parameter_info info;
510
511 501
512 ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method"); 502 ACPI_FUNCTION_TRACE("ev_asynch_execute_gpe_method");
513 503
514 504 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
515 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 505 if (ACPI_FAILURE(status)) {
516 if (ACPI_FAILURE (status)) {
517 return_VOID; 506 return_VOID;
518 } 507 }
519 508
520 /* Must revalidate the gpe_number/gpe_block */ 509 /* Must revalidate the gpe_number/gpe_block */
521 510
522 if (!acpi_ev_valid_gpe_event (gpe_event_info)) { 511 if (!acpi_ev_valid_gpe_event(gpe_event_info)) {
523 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 512 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
524 return_VOID; 513 return_VOID;
525 } 514 }
526 515
527 /* Set the GPE flags for return to enabled state */ 516 /* Set the GPE flags for return to enabled state */
528 517
529 (void) acpi_ev_enable_gpe (gpe_event_info, FALSE); 518 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE);
530 519
531 /* 520 /*
532 * Take a snapshot of the GPE info for this level - we copy the 521 * Take a snapshot of the GPE info for this level - we copy the
533 * info to prevent a race condition with remove_handler/remove_block. 522 * info to prevent a race condition with remove_handler/remove_block.
534 */ 523 */
535 ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info, 524 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info,
536 sizeof (struct acpi_gpe_event_info)); 525 sizeof(struct acpi_gpe_event_info));
537 526
538 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 527 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
539 if (ACPI_FAILURE (status)) { 528 if (ACPI_FAILURE(status)) {
540 return_VOID; 529 return_VOID;
541 } 530 }
542 531
@@ -545,44 +534,40 @@ acpi_ev_asynch_execute_gpe_method (
545 * time to avoid race with ev_gpe_install_handler 534 * time to avoid race with ev_gpe_install_handler
546 */ 535 */
547 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == 536 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
548 ACPI_GPE_DISPATCH_METHOD) { 537 ACPI_GPE_DISPATCH_METHOD) {
549 /* 538 /*
550 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx 539 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
551 * control method that corresponds to this GPE 540 * control method that corresponds to this GPE
552 */ 541 */
553 info.node = local_gpe_event_info.dispatch.method_node; 542 info.node = local_gpe_event_info.dispatch.method_node;
554 info.parameters = ACPI_CAST_PTR (union acpi_operand_object *, gpe_event_info); 543 info.parameters =
544 ACPI_CAST_PTR(union acpi_operand_object *, gpe_event_info);
555 info.parameter_type = ACPI_PARAM_GPE; 545 info.parameter_type = ACPI_PARAM_GPE;
556 546
557 status = acpi_ns_evaluate_by_handle (&info); 547 status = acpi_ns_evaluate_by_handle(&info);
558 if (ACPI_FAILURE (status)) { 548 if (ACPI_FAILURE(status)) {
559 ACPI_REPORT_ERROR (( 549 ACPI_REPORT_ERROR(("%s while evaluating method [%4.4s] for GPE[%2X]\n", acpi_format_exception(status), acpi_ut_get_node_name(local_gpe_event_info.dispatch.method_node), gpe_number));
560 "%s while evaluating method [%4.4s] for GPE[%2X]\n",
561 acpi_format_exception (status),
562 acpi_ut_get_node_name (local_gpe_event_info.dispatch.method_node),
563 gpe_number));
564 } 550 }
565 } 551 }
566 552
567 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) == 553 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
568 ACPI_GPE_LEVEL_TRIGGERED) { 554 ACPI_GPE_LEVEL_TRIGGERED) {
569 /* 555 /*
570 * GPE is level-triggered, we clear the GPE status bit after 556 * GPE is level-triggered, we clear the GPE status bit after
571 * handling the event. 557 * handling the event.
572 */ 558 */
573 status = acpi_hw_clear_gpe (&local_gpe_event_info); 559 status = acpi_hw_clear_gpe(&local_gpe_event_info);
574 if (ACPI_FAILURE (status)) { 560 if (ACPI_FAILURE(status)) {
575 return_VOID; 561 return_VOID;
576 } 562 }
577 } 563 }
578 564
579 /* Enable this GPE */ 565 /* Enable this GPE */
580 566
581 (void) acpi_hw_write_gpe_enable_reg (&local_gpe_event_info); 567 (void)acpi_hw_write_gpe_enable_reg(&local_gpe_event_info);
582 return_VOID; 568 return_VOID;
583} 569}
584 570
585
586/******************************************************************************* 571/*******************************************************************************
587 * 572 *
588 * FUNCTION: acpi_ev_gpe_dispatch 573 * FUNCTION: acpi_ev_gpe_dispatch
@@ -600,38 +585,31 @@ acpi_ev_asynch_execute_gpe_method (
600 ******************************************************************************/ 585 ******************************************************************************/
601 586
602u32 587u32
603acpi_ev_gpe_dispatch ( 588acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
604 struct acpi_gpe_event_info *gpe_event_info,
605 u32 gpe_number)
606{ 589{
607 acpi_status status; 590 acpi_status status;
608
609
610 ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
611 591
592 ACPI_FUNCTION_TRACE("ev_gpe_dispatch");
612 593
613 /* 594 /*
614 * If edge-triggered, clear the GPE status bit now. Note that 595 * If edge-triggered, clear the GPE status bit now. Note that
615 * level-triggered events are cleared after the GPE is serviced. 596 * level-triggered events are cleared after the GPE is serviced.
616 */ 597 */
617 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 598 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
618 ACPI_GPE_EDGE_TRIGGERED) { 599 ACPI_GPE_EDGE_TRIGGERED) {
619 status = acpi_hw_clear_gpe (gpe_event_info); 600 status = acpi_hw_clear_gpe(gpe_event_info);
620 if (ACPI_FAILURE (status)) { 601 if (ACPI_FAILURE(status)) {
621 ACPI_REPORT_ERROR (( 602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
622 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 603 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
623 acpi_format_exception (status), gpe_number));
624 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
625 } 604 }
626 } 605 }
627 606
628 /* Save current system state */ 607 /* Save current system state */
629 608
630 if (acpi_gbl_system_awake_and_running) { 609 if (acpi_gbl_system_awake_and_running) {
631 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING); 610 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
632 } 611 } else {
633 else { 612 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
634 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
635 } 613 }
636 614
637 /* 615 /*
@@ -648,19 +626,19 @@ acpi_ev_gpe_dispatch (
648 * Invoke the installed handler (at interrupt level) 626 * Invoke the installed handler (at interrupt level)
649 * Ignore return status for now. TBD: leave GPE disabled on error? 627 * Ignore return status for now. TBD: leave GPE disabled on error?
650 */ 628 */
651 (void) gpe_event_info->dispatch.handler->address ( 629 (void)gpe_event_info->dispatch.handler->address(gpe_event_info->
652 gpe_event_info->dispatch.handler->context); 630 dispatch.
631 handler->
632 context);
653 633
654 /* It is now safe to clear level-triggered events. */ 634 /* It is now safe to clear level-triggered events. */
655 635
656 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 636 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
657 ACPI_GPE_LEVEL_TRIGGERED) { 637 ACPI_GPE_LEVEL_TRIGGERED) {
658 status = acpi_hw_clear_gpe (gpe_event_info); 638 status = acpi_hw_clear_gpe(gpe_event_info);
659 if (ACPI_FAILURE (status)) { 639 if (ACPI_FAILURE(status)) {
660 ACPI_REPORT_ERROR (( 640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
661 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 641 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
662 acpi_format_exception (status), gpe_number));
663 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
664 } 642 }
665 } 643 }
666 break; 644 break;
@@ -671,24 +649,21 @@ acpi_ev_gpe_dispatch (
671 * Disable GPE, so it doesn't keep firing before the method has a 649 * Disable GPE, so it doesn't keep firing before the method has a
672 * chance to run. 650 * chance to run.
673 */ 651 */
674 status = acpi_ev_disable_gpe (gpe_event_info); 652 status = acpi_ev_disable_gpe(gpe_event_info);
675 if (ACPI_FAILURE (status)) { 653 if (ACPI_FAILURE(status)) {
676 ACPI_REPORT_ERROR (( 654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
677 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", 655 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
678 acpi_format_exception (status), gpe_number));
679 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
680 } 656 }
681 657
682 /* 658 /*
683 * Execute the method associated with the GPE 659 * Execute the method associated with the GPE
684 * NOTE: Level-triggered GPEs are cleared after the method completes. 660 * NOTE: Level-triggered GPEs are cleared after the method completes.
685 */ 661 */
686 status = acpi_os_queue_for_execution (OSD_PRIORITY_GPE, 662 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
687 acpi_ev_asynch_execute_gpe_method, gpe_event_info); 663 acpi_ev_asynch_execute_gpe_method,
688 if (ACPI_FAILURE (status)) { 664 gpe_event_info);
689 ACPI_REPORT_ERROR (( 665 if (ACPI_FAILURE(status)) {
690 "acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", 666 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number));
691 acpi_format_exception (status), gpe_number));
692 } 667 }
693 break; 668 break;
694 669
@@ -696,28 +671,23 @@ acpi_ev_gpe_dispatch (
696 671
697 /* No handler or method to run! */ 672 /* No handler or method to run! */
698 673
699 ACPI_REPORT_ERROR (( 674 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number));
700 "acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n",
701 gpe_number));
702 675
703 /* 676 /*
704 * Disable the GPE. The GPE will remain disabled until the ACPI 677 * Disable the GPE. The GPE will remain disabled until the ACPI
705 * Core Subsystem is restarted, or a handler is installed. 678 * Core Subsystem is restarted, or a handler is installed.
706 */ 679 */
707 status = acpi_ev_disable_gpe (gpe_event_info); 680 status = acpi_ev_disable_gpe(gpe_event_info);
708 if (ACPI_FAILURE (status)) { 681 if (ACPI_FAILURE(status)) {
709 ACPI_REPORT_ERROR (( 682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
710 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", 683 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
711 acpi_format_exception (status), gpe_number));
712 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
713 } 684 }
714 break; 685 break;
715 } 686 }
716 687
717 return_VALUE (ACPI_INTERRUPT_HANDLED); 688 return_VALUE(ACPI_INTERRUPT_HANDLED);
718} 689}
719 690
720
721#ifdef ACPI_GPE_NOTIFY_CHECK 691#ifdef ACPI_GPE_NOTIFY_CHECK
722/******************************************************************************* 692/*******************************************************************************
723 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED 693 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
@@ -736,35 +706,29 @@ acpi_ev_gpe_dispatch (
736 ******************************************************************************/ 706 ******************************************************************************/
737 707
738acpi_status 708acpi_status
739acpi_ev_check_for_wake_only_gpe ( 709acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info)
740 struct acpi_gpe_event_info *gpe_event_info)
741{ 710{
742 acpi_status status; 711 acpi_status status;
743 712
713 ACPI_FUNCTION_TRACE("ev_check_for_wake_only_gpe");
744 714
745 ACPI_FUNCTION_TRACE ("ev_check_for_wake_only_gpe"); 715 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
746 716 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) { /* System state at GPE time */
747
748 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
749 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ {
750 /* This must be a wake-only GPE, disable it */ 717 /* This must be a wake-only GPE, disable it */
751 718
752 status = acpi_ev_disable_gpe (gpe_event_info); 719 status = acpi_ev_disable_gpe(gpe_event_info);
753 720
754 /* Set GPE to wake-only. Do not change wake disabled/enabled status */ 721 /* Set GPE to wake-only. Do not change wake disabled/enabled status */
755 722
756 acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE); 723 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
757 724
758 ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n", 725 ACPI_REPORT_INFO(("GPE %p was updated from wake/run to wake-only\n", gpe_event_info));
759 gpe_event_info));
760 726
761 /* This was a wake-only GPE */ 727 /* This was a wake-only GPE */
762 728
763 return_ACPI_STATUS (AE_WAKE_ONLY_GPE); 729 return_ACPI_STATUS(AE_WAKE_ONLY_GPE);
764 } 730 }
765 731
766 return_ACPI_STATUS (AE_OK); 732 return_ACPI_STATUS(AE_OK);
767} 733}
768#endif 734#endif
769
770
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index dfc54692b127..b312eb33c43e 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -46,41 +46,29 @@
46#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
47 47
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evgpeblk") 49ACPI_MODULE_NAME("evgpeblk")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52
53static acpi_status 52static acpi_status
54acpi_ev_save_method_info ( 53acpi_ev_save_method_info(acpi_handle obj_handle,
55 acpi_handle obj_handle, 54 u32 level, void *obj_desc, void **return_value);
56 u32 level,
57 void *obj_desc,
58 void **return_value);
59 55
60static acpi_status 56static acpi_status
61acpi_ev_match_prw_and_gpe ( 57acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
62 acpi_handle obj_handle, 58 u32 level, void *info, void **return_value);
63 u32 level,
64 void *info,
65 void **return_value);
66 59
67static struct acpi_gpe_xrupt_info * 60static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
68acpi_ev_get_gpe_xrupt_block ( 61 interrupt_number);
69 u32 interrupt_number);
70 62
71static acpi_status 63static acpi_status
72acpi_ev_delete_gpe_xrupt ( 64acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt);
73 struct acpi_gpe_xrupt_info *gpe_xrupt);
74 65
75static acpi_status 66static acpi_status
76acpi_ev_install_gpe_block ( 67acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
77 struct acpi_gpe_block_info *gpe_block, 68 u32 interrupt_number);
78 u32 interrupt_number);
79 69
80static acpi_status 70static acpi_status
81acpi_ev_create_gpe_info_blocks ( 71acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block);
82 struct acpi_gpe_block_info *gpe_block);
83
84 72
85/******************************************************************************* 73/*******************************************************************************
86 * 74 *
@@ -96,16 +84,12 @@ acpi_ev_create_gpe_info_blocks (
96 * 84 *
97 ******************************************************************************/ 85 ******************************************************************************/
98 86
99u8 87u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
100acpi_ev_valid_gpe_event (
101 struct acpi_gpe_event_info *gpe_event_info)
102{ 88{
103 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 89 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
104 struct acpi_gpe_block_info *gpe_block; 90 struct acpi_gpe_block_info *gpe_block;
105
106
107 ACPI_FUNCTION_ENTRY ();
108 91
92 ACPI_FUNCTION_ENTRY();
109 93
110 /* No need for spin lock since we are not changing any list elements */ 94 /* No need for spin lock since we are not changing any list elements */
111 95
@@ -119,7 +103,10 @@ acpi_ev_valid_gpe_event (
119 103
120 while (gpe_block) { 104 while (gpe_block) {
121 if ((&gpe_block->event_info[0] <= gpe_event_info) && 105 if ((&gpe_block->event_info[0] <= gpe_event_info) &&
122 (&gpe_block->event_info[((acpi_size) gpe_block->register_count) * 8] > gpe_event_info)) { 106 (&gpe_block->
107 event_info[((acpi_size) gpe_block->
108 register_count) * 8] >
109 gpe_event_info)) {
123 return (TRUE); 110 return (TRUE);
124 } 111 }
125 112
@@ -132,7 +119,6 @@ acpi_ev_valid_gpe_event (
132 return (FALSE); 119 return (FALSE);
133} 120}
134 121
135
136/******************************************************************************* 122/*******************************************************************************
137 * 123 *
138 * FUNCTION: acpi_ev_walk_gpe_list 124 * FUNCTION: acpi_ev_walk_gpe_list
@@ -145,20 +131,16 @@ acpi_ev_valid_gpe_event (
145 * 131 *
146 ******************************************************************************/ 132 ******************************************************************************/
147 133
148acpi_status 134acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback)
149acpi_ev_walk_gpe_list (
150 ACPI_GPE_CALLBACK gpe_walk_callback)
151{ 135{
152 struct acpi_gpe_block_info *gpe_block; 136 struct acpi_gpe_block_info *gpe_block;
153 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 137 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
154 acpi_status status = AE_OK; 138 acpi_status status = AE_OK;
155 u32 flags; 139 u32 flags;
156
157 140
158 ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); 141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list");
159 142
160 143 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
161 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
162 144
163 /* Walk the interrupt level descriptor list */ 145 /* Walk the interrupt level descriptor list */
164 146
@@ -170,8 +152,8 @@ acpi_ev_walk_gpe_list (
170 while (gpe_block) { 152 while (gpe_block) {
171 /* One callback per GPE block */ 153 /* One callback per GPE block */
172 154
173 status = gpe_walk_callback (gpe_xrupt_info, gpe_block); 155 status = gpe_walk_callback(gpe_xrupt_info, gpe_block);
174 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
175 goto unlock_and_exit; 157 goto unlock_and_exit;
176 } 158 }
177 159
@@ -181,12 +163,11 @@ acpi_ev_walk_gpe_list (
181 gpe_xrupt_info = gpe_xrupt_info->next; 163 gpe_xrupt_info = gpe_xrupt_info->next;
182 } 164 }
183 165
184unlock_and_exit: 166 unlock_and_exit:
185 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 167 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
186 return_ACPI_STATUS (status); 168 return_ACPI_STATUS(status);
187} 169}
188 170
189
190/******************************************************************************* 171/*******************************************************************************
191 * 172 *
192 * FUNCTION: acpi_ev_delete_gpe_handlers 173 * FUNCTION: acpi_ev_delete_gpe_handlers
@@ -202,17 +183,14 @@ unlock_and_exit:
202 ******************************************************************************/ 183 ******************************************************************************/
203 184
204acpi_status 185acpi_status
205acpi_ev_delete_gpe_handlers ( 186acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
206 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 187 struct acpi_gpe_block_info *gpe_block)
207 struct acpi_gpe_block_info *gpe_block)
208{ 188{
209 struct acpi_gpe_event_info *gpe_event_info; 189 struct acpi_gpe_event_info *gpe_event_info;
210 acpi_native_uint i; 190 acpi_native_uint i;
211 acpi_native_uint j; 191 acpi_native_uint j;
212
213
214 ACPI_FUNCTION_TRACE ("ev_delete_gpe_handlers");
215 192
193 ACPI_FUNCTION_TRACE("ev_delete_gpe_handlers");
216 194
217 /* Examine each GPE Register within the block */ 195 /* Examine each GPE Register within the block */
218 196
@@ -220,21 +198,23 @@ acpi_ev_delete_gpe_handlers (
220 /* Now look at the individual GPEs in this byte register */ 198 /* Now look at the individual GPEs in this byte register */
221 199
222 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 200 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
223 gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; 201 gpe_event_info =
202 &gpe_block->
203 event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j];
224 204
225 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 205 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
226 ACPI_GPE_DISPATCH_HANDLER) { 206 ACPI_GPE_DISPATCH_HANDLER) {
227 ACPI_MEM_FREE (gpe_event_info->dispatch.handler); 207 ACPI_MEM_FREE(gpe_event_info->dispatch.handler);
228 gpe_event_info->dispatch.handler = NULL; 208 gpe_event_info->dispatch.handler = NULL;
229 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; 209 gpe_event_info->flags &=
210 ~ACPI_GPE_DISPATCH_MASK;
230 } 211 }
231 } 212 }
232 } 213 }
233 214
234 return_ACPI_STATUS (AE_OK); 215 return_ACPI_STATUS(AE_OK);
235} 216}
236 217
237
238/******************************************************************************* 218/*******************************************************************************
239 * 219 *
240 * FUNCTION: acpi_ev_save_method_info 220 * FUNCTION: acpi_ev_save_method_info
@@ -258,30 +238,26 @@ acpi_ev_delete_gpe_handlers (
258 ******************************************************************************/ 238 ******************************************************************************/
259 239
260static acpi_status 240static acpi_status
261acpi_ev_save_method_info ( 241acpi_ev_save_method_info(acpi_handle obj_handle,
262 acpi_handle obj_handle, 242 u32 level, void *obj_desc, void **return_value)
263 u32 level,
264 void *obj_desc,
265 void **return_value)
266{ 243{
267 struct acpi_gpe_block_info *gpe_block = (void *) obj_desc; 244 struct acpi_gpe_block_info *gpe_block = (void *)obj_desc;
268 struct acpi_gpe_event_info *gpe_event_info; 245 struct acpi_gpe_event_info *gpe_event_info;
269 u32 gpe_number; 246 u32 gpe_number;
270 char name[ACPI_NAME_SIZE + 1]; 247 char name[ACPI_NAME_SIZE + 1];
271 u8 type; 248 u8 type;
272 acpi_status status; 249 acpi_status status;
273
274
275 ACPI_FUNCTION_TRACE ("ev_save_method_info");
276 250
251 ACPI_FUNCTION_TRACE("ev_save_method_info");
277 252
278 /* 253 /*
279 * _Lxx and _Exx GPE method support 254 * _Lxx and _Exx GPE method support
280 * 255 *
281 * 1) Extract the name from the object and convert to a string 256 * 1) Extract the name from the object and convert to a string
282 */ 257 */
283 ACPI_MOVE_32_TO_32 (name, 258 ACPI_MOVE_32_TO_32(name,
284 &((struct acpi_namespace_node *) obj_handle)->name.integer); 259 &((struct acpi_namespace_node *)obj_handle)->name.
260 integer);
285 name[ACPI_NAME_SIZE] = 0; 261 name[ACPI_NAME_SIZE] = 0;
286 262
287 /* 263 /*
@@ -303,34 +279,36 @@ acpi_ev_save_method_info (
303 default: 279 default:
304 /* Unknown method type, just ignore it! */ 280 /* Unknown method type, just ignore it! */
305 281
306 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 282 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
307 "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", 283 "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n",
308 name)); 284 name));
309 return_ACPI_STATUS (AE_OK); 285 return_ACPI_STATUS(AE_OK);
310 } 286 }
311 287
312 /* Convert the last two characters of the name to the GPE Number */ 288 /* Convert the last two characters of the name to the GPE Number */
313 289
314 gpe_number = ACPI_STRTOUL (&name[2], NULL, 16); 290 gpe_number = ACPI_STRTOUL(&name[2], NULL, 16);
315 if (gpe_number == ACPI_UINT32_MAX) { 291 if (gpe_number == ACPI_UINT32_MAX) {
316 /* Conversion failed; invalid method, just ignore it */ 292 /* Conversion failed; invalid method, just ignore it */
317 293
318 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 294 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
319 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", 295 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n",
320 name)); 296 name));
321 return_ACPI_STATUS (AE_OK); 297 return_ACPI_STATUS(AE_OK);
322 } 298 }
323 299
324 /* Ensure that we have a valid GPE number for this GPE block */ 300 /* Ensure that we have a valid GPE number for this GPE block */
325 301
326 if ((gpe_number < gpe_block->block_base_number) || 302 if ((gpe_number < gpe_block->block_base_number) ||
327 (gpe_number >= (gpe_block->block_base_number + (gpe_block->register_count * 8)))) { 303 (gpe_number >=
304 (gpe_block->block_base_number +
305 (gpe_block->register_count * 8)))) {
328 /* 306 /*
329 * Not valid for this GPE block, just ignore it 307 * Not valid for this GPE block, just ignore it
330 * However, it may be valid for a different GPE block, since GPE0 and GPE1 308 * However, it may be valid for a different GPE block, since GPE0 and GPE1
331 * methods both appear under \_GPE. 309 * methods both appear under \_GPE.
332 */ 310 */
333 return_ACPI_STATUS (AE_OK); 311 return_ACPI_STATUS(AE_OK);
334 } 312 }
335 313
336 /* 314 /*
@@ -338,24 +316,25 @@ acpi_ev_save_method_info (
338 * for use during dispatch of this GPE. Default type is RUNTIME, although 316 * for use during dispatch of this GPE. Default type is RUNTIME, although
339 * this may change when the _PRW methods are executed later. 317 * this may change when the _PRW methods are executed later.
340 */ 318 */
341 gpe_event_info = &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 319 gpe_event_info =
320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
342 321
343 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | 322 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD |
344 ACPI_GPE_TYPE_RUNTIME); 323 ACPI_GPE_TYPE_RUNTIME);
345 324
346 gpe_event_info->dispatch.method_node = (struct acpi_namespace_node *) obj_handle; 325 gpe_event_info->dispatch.method_node =
326 (struct acpi_namespace_node *)obj_handle;
347 327
348 /* Update enable mask, but don't enable the HW GPE as of yet */ 328 /* Update enable mask, but don't enable the HW GPE as of yet */
349 329
350 status = acpi_ev_enable_gpe (gpe_event_info, FALSE); 330 status = acpi_ev_enable_gpe(gpe_event_info, FALSE);
351 331
352 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, 332 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
353 "Registered GPE method %s as GPE number 0x%.2X\n", 333 "Registered GPE method %s as GPE number 0x%.2X\n",
354 name, gpe_number)); 334 name, gpe_number));
355 return_ACPI_STATUS (status); 335 return_ACPI_STATUS(status);
356} 336}
357 337
358
359/******************************************************************************* 338/*******************************************************************************
360 * 339 *
361 * FUNCTION: acpi_ev_match_prw_and_gpe 340 * FUNCTION: acpi_ev_match_prw_and_gpe
@@ -372,34 +351,29 @@ acpi_ev_save_method_info (
372 ******************************************************************************/ 351 ******************************************************************************/
373 352
374static acpi_status 353static acpi_status
375acpi_ev_match_prw_and_gpe ( 354acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
376 acpi_handle obj_handle, 355 u32 level, void *info, void **return_value)
377 u32 level,
378 void *info,
379 void **return_value)
380{ 356{
381 struct acpi_gpe_walk_info *gpe_info = (void *) info; 357 struct acpi_gpe_walk_info *gpe_info = (void *)info;
382 struct acpi_namespace_node *gpe_device; 358 struct acpi_namespace_node *gpe_device;
383 struct acpi_gpe_block_info *gpe_block; 359 struct acpi_gpe_block_info *gpe_block;
384 struct acpi_namespace_node *target_gpe_device; 360 struct acpi_namespace_node *target_gpe_device;
385 struct acpi_gpe_event_info *gpe_event_info; 361 struct acpi_gpe_event_info *gpe_event_info;
386 union acpi_operand_object *pkg_desc; 362 union acpi_operand_object *pkg_desc;
387 union acpi_operand_object *obj_desc; 363 union acpi_operand_object *obj_desc;
388 u32 gpe_number; 364 u32 gpe_number;
389 acpi_status status; 365 acpi_status status;
390 366
391 367 ACPI_FUNCTION_TRACE("ev_match_prw_and_gpe");
392 ACPI_FUNCTION_TRACE ("ev_match_prw_and_gpe");
393
394 368
395 /* Check for a _PRW method under this device */ 369 /* Check for a _PRW method under this device */
396 370
397 status = acpi_ut_evaluate_object (obj_handle, METHOD_NAME__PRW, 371 status = acpi_ut_evaluate_object(obj_handle, METHOD_NAME__PRW,
398 ACPI_BTYPE_PACKAGE, &pkg_desc); 372 ACPI_BTYPE_PACKAGE, &pkg_desc);
399 if (ACPI_FAILURE (status)) { 373 if (ACPI_FAILURE(status)) {
400 /* Ignore all errors from _PRW, we don't want to abort the subsystem */ 374 /* Ignore all errors from _PRW, we don't want to abort the subsystem */
401 375
402 return_ACPI_STATUS (AE_OK); 376 return_ACPI_STATUS(AE_OK);
403 } 377 }
404 378
405 /* The returned _PRW package must have at least two elements */ 379 /* The returned _PRW package must have at least two elements */
@@ -419,7 +393,7 @@ acpi_ev_match_prw_and_gpe (
419 */ 393 */
420 obj_desc = pkg_desc->package.elements[0]; 394 obj_desc = pkg_desc->package.elements[0];
421 395
422 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 396 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
423 /* Use FADT-defined GPE device (from definition of _PRW) */ 397 /* Use FADT-defined GPE device (from definition of _PRW) */
424 398
425 target_gpe_device = acpi_gbl_fadt_gpe_device; 399 target_gpe_device = acpi_gbl_fadt_gpe_device;
@@ -427,22 +401,23 @@ acpi_ev_match_prw_and_gpe (
427 /* Integer is the GPE number in the FADT described GPE blocks */ 401 /* Integer is the GPE number in the FADT described GPE blocks */
428 402
429 gpe_number = (u32) obj_desc->integer.value; 403 gpe_number = (u32) obj_desc->integer.value;
430 } 404 } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
431 else if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) {
432 /* Package contains a GPE reference and GPE number within a GPE block */ 405 /* Package contains a GPE reference and GPE number within a GPE block */
433 406
434 if ((obj_desc->package.count < 2) || 407 if ((obj_desc->package.count < 2) ||
435 (ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[0]) != ACPI_TYPE_LOCAL_REFERENCE) || 408 (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[0]) !=
436 (ACPI_GET_OBJECT_TYPE (obj_desc->package.elements[1]) != ACPI_TYPE_INTEGER)) { 409 ACPI_TYPE_LOCAL_REFERENCE)
410 || (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[1]) !=
411 ACPI_TYPE_INTEGER)) {
437 goto cleanup; 412 goto cleanup;
438 } 413 }
439 414
440 /* Get GPE block reference and decode */ 415 /* Get GPE block reference and decode */
441 416
442 target_gpe_device = obj_desc->package.elements[0]->reference.node; 417 target_gpe_device =
418 obj_desc->package.elements[0]->reference.node;
443 gpe_number = (u32) obj_desc->package.elements[1]->integer.value; 419 gpe_number = (u32) obj_desc->package.elements[1]->integer.value;
444 } 420 } else {
445 else {
446 /* Unknown type, just ignore it */ 421 /* Unknown type, just ignore it */
447 422
448 goto cleanup; 423 goto cleanup;
@@ -457,26 +432,32 @@ acpi_ev_match_prw_and_gpe (
457 * associated with the GPE device. 432 * associated with the GPE device.
458 */ 433 */
459 if ((gpe_device == target_gpe_device) && 434 if ((gpe_device == target_gpe_device) &&
460 (gpe_number >= gpe_block->block_base_number) && 435 (gpe_number >= gpe_block->block_base_number) &&
461 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { 436 (gpe_number <
462 gpe_event_info = &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 437 gpe_block->block_base_number + (gpe_block->register_count * 8))) {
438 gpe_event_info =
439 &gpe_block->event_info[gpe_number -
440 gpe_block->block_base_number];
463 441
464 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ 442 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */
465 443
466 gpe_event_info->flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); 444 gpe_event_info->flags &=
467 status = acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE); 445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
468 if (ACPI_FAILURE (status)) { 446 status =
447 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
448 if (ACPI_FAILURE(status)) {
469 goto cleanup; 449 goto cleanup;
470 } 450 }
471 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE); 451 status =
452 acpi_ev_update_gpe_enable_masks(gpe_event_info,
453 ACPI_GPE_DISABLE);
472 } 454 }
473 455
474cleanup: 456 cleanup:
475 acpi_ut_remove_reference (pkg_desc); 457 acpi_ut_remove_reference(pkg_desc);
476 return_ACPI_STATUS (AE_OK); 458 return_ACPI_STATUS(AE_OK);
477} 459}
478 460
479
480/******************************************************************************* 461/*******************************************************************************
481 * 462 *
482 * FUNCTION: acpi_ev_get_gpe_xrupt_block 463 * FUNCTION: acpi_ev_get_gpe_xrupt_block
@@ -492,25 +473,22 @@ cleanup:
492 * 473 *
493 ******************************************************************************/ 474 ******************************************************************************/
494 475
495static struct acpi_gpe_xrupt_info * 476static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
496acpi_ev_get_gpe_xrupt_block ( 477 interrupt_number)
497 u32 interrupt_number)
498{ 478{
499 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 479 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
500 struct acpi_gpe_xrupt_info *gpe_xrupt; 480 struct acpi_gpe_xrupt_info *gpe_xrupt;
501 acpi_status status; 481 acpi_status status;
502 u32 flags; 482 u32 flags;
503
504
505 ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block");
506 483
484 ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block");
507 485
508 /* No need for lock since we are not changing any list elements here */ 486 /* No need for lock since we are not changing any list elements here */
509 487
510 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; 488 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
511 while (next_gpe_xrupt) { 489 while (next_gpe_xrupt) {
512 if (next_gpe_xrupt->interrupt_number == interrupt_number) { 490 if (next_gpe_xrupt->interrupt_number == interrupt_number) {
513 return_PTR (next_gpe_xrupt); 491 return_PTR(next_gpe_xrupt);
514 } 492 }
515 493
516 next_gpe_xrupt = next_gpe_xrupt->next; 494 next_gpe_xrupt = next_gpe_xrupt->next;
@@ -518,16 +496,16 @@ acpi_ev_get_gpe_xrupt_block (
518 496
519 /* Not found, must allocate a new xrupt descriptor */ 497 /* Not found, must allocate a new xrupt descriptor */
520 498
521 gpe_xrupt = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_xrupt_info)); 499 gpe_xrupt = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_xrupt_info));
522 if (!gpe_xrupt) { 500 if (!gpe_xrupt) {
523 return_PTR (NULL); 501 return_PTR(NULL);
524 } 502 }
525 503
526 gpe_xrupt->interrupt_number = interrupt_number; 504 gpe_xrupt->interrupt_number = interrupt_number;
527 505
528 /* Install new interrupt descriptor with spin lock */ 506 /* Install new interrupt descriptor with spin lock */
529 507
530 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 508 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
531 if (acpi_gbl_gpe_xrupt_list_head) { 509 if (acpi_gbl_gpe_xrupt_list_head) {
532 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; 510 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
533 while (next_gpe_xrupt->next) { 511 while (next_gpe_xrupt->next) {
@@ -536,29 +514,28 @@ acpi_ev_get_gpe_xrupt_block (
536 514
537 next_gpe_xrupt->next = gpe_xrupt; 515 next_gpe_xrupt->next = gpe_xrupt;
538 gpe_xrupt->previous = next_gpe_xrupt; 516 gpe_xrupt->previous = next_gpe_xrupt;
539 } 517 } else {
540 else {
541 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; 518 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
542 } 519 }
543 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 520 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
544 521
545 /* Install new interrupt handler if not SCI_INT */ 522 /* Install new interrupt handler if not SCI_INT */
546 523
547 if (interrupt_number != acpi_gbl_FADT->sci_int) { 524 if (interrupt_number != acpi_gbl_FADT->sci_int) {
548 status = acpi_os_install_interrupt_handler (interrupt_number, 525 status = acpi_os_install_interrupt_handler(interrupt_number,
549 acpi_ev_gpe_xrupt_handler, gpe_xrupt); 526 acpi_ev_gpe_xrupt_handler,
550 if (ACPI_FAILURE (status)) { 527 gpe_xrupt);
551 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 528 if (ACPI_FAILURE(status)) {
552 "Could not install GPE interrupt handler at level 0x%X\n", 529 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
553 interrupt_number)); 530 "Could not install GPE interrupt handler at level 0x%X\n",
554 return_PTR (NULL); 531 interrupt_number));
532 return_PTR(NULL);
555 } 533 }
556 } 534 }
557 535
558 return_PTR (gpe_xrupt); 536 return_PTR(gpe_xrupt);
559} 537}
560 538
561
562/******************************************************************************* 539/*******************************************************************************
563 * 540 *
564 * FUNCTION: acpi_ev_delete_gpe_xrupt 541 * FUNCTION: acpi_ev_delete_gpe_xrupt
@@ -573,34 +550,31 @@ acpi_ev_get_gpe_xrupt_block (
573 ******************************************************************************/ 550 ******************************************************************************/
574 551
575static acpi_status 552static acpi_status
576acpi_ev_delete_gpe_xrupt ( 553acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
577 struct acpi_gpe_xrupt_info *gpe_xrupt)
578{ 554{
579 acpi_status status; 555 acpi_status status;
580 u32 flags; 556 u32 flags;
581
582
583 ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt");
584 557
558 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt");
585 559
586 /* We never want to remove the SCI interrupt handler */ 560 /* We never want to remove the SCI interrupt handler */
587 561
588 if (gpe_xrupt->interrupt_number == acpi_gbl_FADT->sci_int) { 562 if (gpe_xrupt->interrupt_number == acpi_gbl_FADT->sci_int) {
589 gpe_xrupt->gpe_block_list_head = NULL; 563 gpe_xrupt->gpe_block_list_head = NULL;
590 return_ACPI_STATUS (AE_OK); 564 return_ACPI_STATUS(AE_OK);
591 } 565 }
592 566
593 /* Disable this interrupt */ 567 /* Disable this interrupt */
594 568
595 status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_number, 569 status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number,
596 acpi_ev_gpe_xrupt_handler); 570 acpi_ev_gpe_xrupt_handler);
597 if (ACPI_FAILURE (status)) { 571 if (ACPI_FAILURE(status)) {
598 return_ACPI_STATUS (status); 572 return_ACPI_STATUS(status);
599 } 573 }
600 574
601 /* Unlink the interrupt block with lock */ 575 /* Unlink the interrupt block with lock */
602 576
603 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 577 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
604 if (gpe_xrupt->previous) { 578 if (gpe_xrupt->previous) {
605 gpe_xrupt->previous->next = gpe_xrupt->next; 579 gpe_xrupt->previous->next = gpe_xrupt->next;
606 } 580 }
@@ -608,15 +582,14 @@ acpi_ev_delete_gpe_xrupt (
608 if (gpe_xrupt->next) { 582 if (gpe_xrupt->next) {
609 gpe_xrupt->next->previous = gpe_xrupt->previous; 583 gpe_xrupt->next->previous = gpe_xrupt->previous;
610 } 584 }
611 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 585 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
612 586
613 /* Free the block */ 587 /* Free the block */
614 588
615 ACPI_MEM_FREE (gpe_xrupt); 589 ACPI_MEM_FREE(gpe_xrupt);
616 return_ACPI_STATUS (AE_OK); 590 return_ACPI_STATUS(AE_OK);
617} 591}
618 592
619
620/******************************************************************************* 593/*******************************************************************************
621 * 594 *
622 * FUNCTION: acpi_ev_install_gpe_block 595 * FUNCTION: acpi_ev_install_gpe_block
@@ -631,25 +604,22 @@ acpi_ev_delete_gpe_xrupt (
631 ******************************************************************************/ 604 ******************************************************************************/
632 605
633static acpi_status 606static acpi_status
634acpi_ev_install_gpe_block ( 607acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
635 struct acpi_gpe_block_info *gpe_block, 608 u32 interrupt_number)
636 u32 interrupt_number)
637{ 609{
638 struct acpi_gpe_block_info *next_gpe_block; 610 struct acpi_gpe_block_info *next_gpe_block;
639 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 611 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
640 acpi_status status; 612 acpi_status status;
641 u32 flags; 613 u32 flags;
642 614
615 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
643 616
644 ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); 617 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
645 618 if (ACPI_FAILURE(status)) {
646 619 return_ACPI_STATUS(status);
647 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
648 if (ACPI_FAILURE (status)) {
649 return_ACPI_STATUS (status);
650 } 620 }
651 621
652 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_number); 622 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number);
653 if (!gpe_xrupt_block) { 623 if (!gpe_xrupt_block) {
654 status = AE_NO_MEMORY; 624 status = AE_NO_MEMORY;
655 goto unlock_and_exit; 625 goto unlock_and_exit;
@@ -657,7 +627,7 @@ acpi_ev_install_gpe_block (
657 627
658 /* Install the new block at the end of the list with lock */ 628 /* Install the new block at the end of the list with lock */
659 629
660 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 630 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
661 if (gpe_xrupt_block->gpe_block_list_head) { 631 if (gpe_xrupt_block->gpe_block_list_head) {
662 next_gpe_block = gpe_xrupt_block->gpe_block_list_head; 632 next_gpe_block = gpe_xrupt_block->gpe_block_list_head;
663 while (next_gpe_block->next) { 633 while (next_gpe_block->next) {
@@ -666,20 +636,18 @@ acpi_ev_install_gpe_block (
666 636
667 next_gpe_block->next = gpe_block; 637 next_gpe_block->next = gpe_block;
668 gpe_block->previous = next_gpe_block; 638 gpe_block->previous = next_gpe_block;
669 } 639 } else {
670 else {
671 gpe_xrupt_block->gpe_block_list_head = gpe_block; 640 gpe_xrupt_block->gpe_block_list_head = gpe_block;
672 } 641 }
673 642
674 gpe_block->xrupt_block = gpe_xrupt_block; 643 gpe_block->xrupt_block = gpe_xrupt_block;
675 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 644 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
676 645
677unlock_and_exit: 646 unlock_and_exit:
678 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 647 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
679 return_ACPI_STATUS (status); 648 return_ACPI_STATUS(status);
680} 649}
681 650
682
683/******************************************************************************* 651/*******************************************************************************
684 * 652 *
685 * FUNCTION: acpi_ev_delete_gpe_block 653 * FUNCTION: acpi_ev_delete_gpe_block
@@ -692,63 +660,57 @@ unlock_and_exit:
692 * 660 *
693 ******************************************************************************/ 661 ******************************************************************************/
694 662
695acpi_status 663acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
696acpi_ev_delete_gpe_block (
697 struct acpi_gpe_block_info *gpe_block)
698{ 664{
699 acpi_status status; 665 acpi_status status;
700 u32 flags; 666 u32 flags;
701
702
703 ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
704 667
668 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
705 669
706 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 670 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
707 if (ACPI_FAILURE (status)) { 671 if (ACPI_FAILURE(status)) {
708 return_ACPI_STATUS (status); 672 return_ACPI_STATUS(status);
709 } 673 }
710 674
711 /* Disable all GPEs in this block */ 675 /* Disable all GPEs in this block */
712 676
713 status = acpi_hw_disable_gpe_block (gpe_block->xrupt_block, gpe_block); 677 status = acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block);
714 678
715 if (!gpe_block->previous && !gpe_block->next) { 679 if (!gpe_block->previous && !gpe_block->next) {
716 /* This is the last gpe_block on this interrupt */ 680 /* This is the last gpe_block on this interrupt */
717 681
718 status = acpi_ev_delete_gpe_xrupt (gpe_block->xrupt_block); 682 status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block);
719 if (ACPI_FAILURE (status)) { 683 if (ACPI_FAILURE(status)) {
720 goto unlock_and_exit; 684 goto unlock_and_exit;
721 } 685 }
722 } 686 } else {
723 else {
724 /* Remove the block on this interrupt with lock */ 687 /* Remove the block on this interrupt with lock */
725 688
726 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 689 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
727 if (gpe_block->previous) { 690 if (gpe_block->previous) {
728 gpe_block->previous->next = gpe_block->next; 691 gpe_block->previous->next = gpe_block->next;
729 } 692 } else {
730 else { 693 gpe_block->xrupt_block->gpe_block_list_head =
731 gpe_block->xrupt_block->gpe_block_list_head = gpe_block->next; 694 gpe_block->next;
732 } 695 }
733 696
734 if (gpe_block->next) { 697 if (gpe_block->next) {
735 gpe_block->next->previous = gpe_block->previous; 698 gpe_block->next->previous = gpe_block->previous;
736 } 699 }
737 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 700 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
738 } 701 }
739 702
740 /* Free the gpe_block */ 703 /* Free the gpe_block */
741 704
742 ACPI_MEM_FREE (gpe_block->register_info); 705 ACPI_MEM_FREE(gpe_block->register_info);
743 ACPI_MEM_FREE (gpe_block->event_info); 706 ACPI_MEM_FREE(gpe_block->event_info);
744 ACPI_MEM_FREE (gpe_block); 707 ACPI_MEM_FREE(gpe_block);
745 708
746unlock_and_exit: 709 unlock_and_exit:
747 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 710 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
748 return_ACPI_STATUS (status); 711 return_ACPI_STATUS(status);
749} 712}
750 713
751
752/******************************************************************************* 714/*******************************************************************************
753 * 715 *
754 * FUNCTION: acpi_ev_create_gpe_info_blocks 716 * FUNCTION: acpi_ev_create_gpe_info_blocks
@@ -762,43 +724,41 @@ unlock_and_exit:
762 ******************************************************************************/ 724 ******************************************************************************/
763 725
764static acpi_status 726static acpi_status
765acpi_ev_create_gpe_info_blocks ( 727acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
766 struct acpi_gpe_block_info *gpe_block)
767{ 728{
768 struct acpi_gpe_register_info *gpe_register_info = NULL; 729 struct acpi_gpe_register_info *gpe_register_info = NULL;
769 struct acpi_gpe_event_info *gpe_event_info = NULL; 730 struct acpi_gpe_event_info *gpe_event_info = NULL;
770 struct acpi_gpe_event_info *this_event; 731 struct acpi_gpe_event_info *this_event;
771 struct acpi_gpe_register_info *this_register; 732 struct acpi_gpe_register_info *this_register;
772 acpi_native_uint i; 733 acpi_native_uint i;
773 acpi_native_uint j; 734 acpi_native_uint j;
774 acpi_status status; 735 acpi_status status;
775
776
777 ACPI_FUNCTION_TRACE ("ev_create_gpe_info_blocks");
778 736
737 ACPI_FUNCTION_TRACE("ev_create_gpe_info_blocks");
779 738
780 /* Allocate the GPE register information block */ 739 /* Allocate the GPE register information block */
781 740
782 gpe_register_info = ACPI_MEM_CALLOCATE ( 741 gpe_register_info = ACPI_MEM_CALLOCATE((acpi_size) gpe_block->
783 (acpi_size) gpe_block->register_count * 742 register_count *
784 sizeof (struct acpi_gpe_register_info)); 743 sizeof(struct
744 acpi_gpe_register_info));
785 if (!gpe_register_info) { 745 if (!gpe_register_info) {
786 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 746 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
787 "Could not allocate the gpe_register_info table\n")); 747 "Could not allocate the gpe_register_info table\n"));
788 return_ACPI_STATUS (AE_NO_MEMORY); 748 return_ACPI_STATUS(AE_NO_MEMORY);
789 } 749 }
790 750
791 /* 751 /*
792 * Allocate the GPE event_info block. There are eight distinct GPEs 752 * Allocate the GPE event_info block. There are eight distinct GPEs
793 * per register. Initialization to zeros is sufficient. 753 * per register. Initialization to zeros is sufficient.
794 */ 754 */
795 gpe_event_info = ACPI_MEM_CALLOCATE ( 755 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block->
796 ((acpi_size) gpe_block->register_count * 756 register_count *
797 ACPI_GPE_REGISTER_WIDTH) * 757 ACPI_GPE_REGISTER_WIDTH) *
798 sizeof (struct acpi_gpe_event_info)); 758 sizeof(struct acpi_gpe_event_info));
799 if (!gpe_event_info) { 759 if (!gpe_event_info) {
800 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 760 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
801 "Could not allocate the gpe_event_info table\n")); 761 "Could not allocate the gpe_event_info table\n"));
802 status = AE_NO_MEMORY; 762 status = AE_NO_MEMORY;
803 goto error_exit; 763 goto error_exit;
804 } 764 }
@@ -806,7 +766,7 @@ acpi_ev_create_gpe_info_blocks (
806 /* Save the new Info arrays in the GPE block */ 766 /* Save the new Info arrays in the GPE block */
807 767
808 gpe_block->register_info = gpe_register_info; 768 gpe_block->register_info = gpe_register_info;
809 gpe_block->event_info = gpe_event_info; 769 gpe_block->event_info = gpe_event_info;
810 770
811 /* 771 /*
812 * Initialize the GPE Register and Event structures. A goal of these 772 * Initialize the GPE Register and Event structures. A goal of these
@@ -815,29 +775,34 @@ acpi_ev_create_gpe_info_blocks (
815 * and the enable registers occupy the second half. 775 * and the enable registers occupy the second half.
816 */ 776 */
817 this_register = gpe_register_info; 777 this_register = gpe_register_info;
818 this_event = gpe_event_info; 778 this_event = gpe_event_info;
819 779
820 for (i = 0; i < gpe_block->register_count; i++) { 780 for (i = 0; i < gpe_block->register_count; i++) {
821 /* Init the register_info for this GPE register (8 GPEs) */ 781 /* Init the register_info for this GPE register (8 GPEs) */
822 782
823 this_register->base_gpe_number = (u8) (gpe_block->block_base_number + 783 this_register->base_gpe_number =
824 (i * ACPI_GPE_REGISTER_WIDTH)); 784 (u8) (gpe_block->block_base_number +
825 785 (i * ACPI_GPE_REGISTER_WIDTH));
826 ACPI_STORE_ADDRESS (this_register->status_address.address, 786
827 (gpe_block->block_address.address 787 ACPI_STORE_ADDRESS(this_register->status_address.address,
828 + i)); 788 (gpe_block->block_address.address + i));
829 789
830 ACPI_STORE_ADDRESS (this_register->enable_address.address, 790 ACPI_STORE_ADDRESS(this_register->enable_address.address,
831 (gpe_block->block_address.address 791 (gpe_block->block_address.address
832 + i 792 + i + gpe_block->register_count));
833 + gpe_block->register_count)); 793
834 794 this_register->status_address.address_space_id =
835 this_register->status_address.address_space_id = gpe_block->block_address.address_space_id; 795 gpe_block->block_address.address_space_id;
836 this_register->enable_address.address_space_id = gpe_block->block_address.address_space_id; 796 this_register->enable_address.address_space_id =
837 this_register->status_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH; 797 gpe_block->block_address.address_space_id;
838 this_register->enable_address.register_bit_width = ACPI_GPE_REGISTER_WIDTH; 798 this_register->status_address.register_bit_width =
839 this_register->status_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH; 799 ACPI_GPE_REGISTER_WIDTH;
840 this_register->enable_address.register_bit_offset = ACPI_GPE_REGISTER_WIDTH; 800 this_register->enable_address.register_bit_width =
801 ACPI_GPE_REGISTER_WIDTH;
802 this_register->status_address.register_bit_offset =
803 ACPI_GPE_REGISTER_WIDTH;
804 this_register->enable_address.register_bit_offset =
805 ACPI_GPE_REGISTER_WIDTH;
841 806
842 /* Init the event_info for each GPE within this register */ 807 /* Init the event_info for each GPE within this register */
843 808
@@ -852,36 +817,36 @@ acpi_ev_create_gpe_info_blocks (
852 * are cleared by writing a '1', while enable registers are cleared 817 * are cleared by writing a '1', while enable registers are cleared
853 * by writing a '0'. 818 * by writing a '0'.
854 */ 819 */
855 status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0x00, 820 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
856 &this_register->enable_address); 821 &this_register->
857 if (ACPI_FAILURE (status)) { 822 enable_address);
823 if (ACPI_FAILURE(status)) {
858 goto error_exit; 824 goto error_exit;
859 } 825 }
860 826
861 status = acpi_hw_low_level_write (ACPI_GPE_REGISTER_WIDTH, 0xFF, 827 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
862 &this_register->status_address); 828 &this_register->
863 if (ACPI_FAILURE (status)) { 829 status_address);
830 if (ACPI_FAILURE(status)) {
864 goto error_exit; 831 goto error_exit;
865 } 832 }
866 833
867 this_register++; 834 this_register++;
868 } 835 }
869 836
870 return_ACPI_STATUS (AE_OK); 837 return_ACPI_STATUS(AE_OK);
871
872 838
873error_exit: 839 error_exit:
874 if (gpe_register_info) { 840 if (gpe_register_info) {
875 ACPI_MEM_FREE (gpe_register_info); 841 ACPI_MEM_FREE(gpe_register_info);
876 } 842 }
877 if (gpe_event_info) { 843 if (gpe_event_info) {
878 ACPI_MEM_FREE (gpe_event_info); 844 ACPI_MEM_FREE(gpe_event_info);
879 } 845 }
880 846
881 return_ACPI_STATUS (status); 847 return_ACPI_STATUS(status);
882} 848}
883 849
884
885/******************************************************************************* 850/*******************************************************************************
886 * 851 *
887 * FUNCTION: acpi_ev_create_gpe_block 852 * FUNCTION: acpi_ev_create_gpe_block
@@ -900,68 +865,66 @@ error_exit:
900 ******************************************************************************/ 865 ******************************************************************************/
901 866
902acpi_status 867acpi_status
903acpi_ev_create_gpe_block ( 868acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
904 struct acpi_namespace_node *gpe_device, 869 struct acpi_generic_address *gpe_block_address,
905 struct acpi_generic_address *gpe_block_address, 870 u32 register_count,
906 u32 register_count, 871 u8 gpe_block_base_number,
907 u8 gpe_block_base_number, 872 u32 interrupt_number,
908 u32 interrupt_number, 873 struct acpi_gpe_block_info **return_gpe_block)
909 struct acpi_gpe_block_info **return_gpe_block)
910{ 874{
911 struct acpi_gpe_block_info *gpe_block; 875 struct acpi_gpe_block_info *gpe_block;
912 struct acpi_gpe_event_info *gpe_event_info; 876 struct acpi_gpe_event_info *gpe_event_info;
913 acpi_native_uint i; 877 acpi_native_uint i;
914 acpi_native_uint j; 878 acpi_native_uint j;
915 u32 wake_gpe_count; 879 u32 wake_gpe_count;
916 u32 gpe_enabled_count; 880 u32 gpe_enabled_count;
917 acpi_status status; 881 acpi_status status;
918 struct acpi_gpe_walk_info gpe_info; 882 struct acpi_gpe_walk_info gpe_info;
919
920
921 ACPI_FUNCTION_TRACE ("ev_create_gpe_block");
922 883
884 ACPI_FUNCTION_TRACE("ev_create_gpe_block");
923 885
924 if (!register_count) { 886 if (!register_count) {
925 return_ACPI_STATUS (AE_OK); 887 return_ACPI_STATUS(AE_OK);
926 } 888 }
927 889
928 /* Allocate a new GPE block */ 890 /* Allocate a new GPE block */
929 891
930 gpe_block = ACPI_MEM_CALLOCATE (sizeof (struct acpi_gpe_block_info)); 892 gpe_block = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_block_info));
931 if (!gpe_block) { 893 if (!gpe_block) {
932 return_ACPI_STATUS (AE_NO_MEMORY); 894 return_ACPI_STATUS(AE_NO_MEMORY);
933 } 895 }
934 896
935 /* Initialize the new GPE block */ 897 /* Initialize the new GPE block */
936 898
937 gpe_block->register_count = register_count; 899 gpe_block->register_count = register_count;
938 gpe_block->block_base_number = gpe_block_base_number; 900 gpe_block->block_base_number = gpe_block_base_number;
939 gpe_block->node = gpe_device; 901 gpe_block->node = gpe_device;
940 902
941 ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address, 903 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
942 sizeof (struct acpi_generic_address)); 904 sizeof(struct acpi_generic_address));
943 905
944 /* Create the register_info and event_info sub-structures */ 906 /* Create the register_info and event_info sub-structures */
945 907
946 status = acpi_ev_create_gpe_info_blocks (gpe_block); 908 status = acpi_ev_create_gpe_info_blocks(gpe_block);
947 if (ACPI_FAILURE (status)) { 909 if (ACPI_FAILURE(status)) {
948 ACPI_MEM_FREE (gpe_block); 910 ACPI_MEM_FREE(gpe_block);
949 return_ACPI_STATUS (status); 911 return_ACPI_STATUS(status);
950 } 912 }
951 913
952 /* Install the new block in the global list(s) */ 914 /* Install the new block in the global list(s) */
953 915
954 status = acpi_ev_install_gpe_block (gpe_block, interrupt_number); 916 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
955 if (ACPI_FAILURE (status)) { 917 if (ACPI_FAILURE(status)) {
956 ACPI_MEM_FREE (gpe_block); 918 ACPI_MEM_FREE(gpe_block);
957 return_ACPI_STATUS (status); 919 return_ACPI_STATUS(status);
958 } 920 }
959 921
960 /* Find all GPE methods (_Lxx, _Exx) for this block */ 922 /* Find all GPE methods (_Lxx, _Exx) for this block */
961 923
962 status = acpi_ns_walk_namespace (ACPI_TYPE_METHOD, gpe_device, 924 status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device,
963 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, acpi_ev_save_method_info, 925 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
964 gpe_block, NULL); 926 acpi_ev_save_method_info, gpe_block,
927 NULL);
965 928
966 /* 929 /*
967 * Runtime option: Should Wake GPEs be enabled at runtime? The default 930 * Runtime option: Should Wake GPEs be enabled at runtime? The default
@@ -977,9 +940,11 @@ acpi_ev_create_gpe_block (
977 gpe_info.gpe_block = gpe_block; 940 gpe_info.gpe_block = gpe_block;
978 gpe_info.gpe_device = gpe_device; 941 gpe_info.gpe_device = gpe_device;
979 942
980 status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 943 status =
981 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, acpi_ev_match_prw_and_gpe, 944 acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
982 &gpe_info, NULL); 945 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
946 acpi_ev_match_prw_and_gpe, &gpe_info,
947 NULL);
983 } 948 }
984 949
985 /* 950 /*
@@ -994,10 +959,14 @@ acpi_ev_create_gpe_block (
994 for (j = 0; j < 8; j++) { 959 for (j = 0; j < 8; j++) {
995 /* Get the info block for this particular GPE */ 960 /* Get the info block for this particular GPE */
996 961
997 gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; 962 gpe_event_info =
963 &gpe_block->
964 event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j];
998 965
999 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) && 966 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
1000 (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { 967 ACPI_GPE_DISPATCH_METHOD)
968 && (gpe_event_info->
969 flags & ACPI_GPE_TYPE_RUNTIME)) {
1001 gpe_enabled_count++; 970 gpe_enabled_count++;
1002 } 971 }
1003 972
@@ -1009,22 +978,22 @@ acpi_ev_create_gpe_block (
1009 978
1010 /* Dump info about this GPE block */ 979 /* Dump info about this GPE block */
1011 980
1012 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 981 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1013 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", 982 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
1014 (u32) gpe_block->block_base_number, 983 (u32) gpe_block->block_base_number,
1015 (u32) (gpe_block->block_base_number + 984 (u32) (gpe_block->block_base_number +
1016 ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)), 985 ((gpe_block->register_count *
1017 gpe_device->name.ascii, 986 ACPI_GPE_REGISTER_WIDTH) - 1)),
1018 gpe_block->register_count, 987 gpe_device->name.ascii, gpe_block->register_count,
1019 interrupt_number)); 988 interrupt_number));
1020 989
1021 /* Enable all valid GPEs found above */ 990 /* Enable all valid GPEs found above */
1022 991
1023 status = acpi_hw_enable_runtime_gpe_block (NULL, gpe_block); 992 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
1024 993
1025 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 994 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1026 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 995 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
1027 wake_gpe_count, gpe_enabled_count)); 996 wake_gpe_count, gpe_enabled_count));
1028 997
1029 /* Return the new block */ 998 /* Return the new block */
1030 999
@@ -1032,10 +1001,9 @@ acpi_ev_create_gpe_block (
1032 (*return_gpe_block) = gpe_block; 1001 (*return_gpe_block) = gpe_block;
1033 } 1002 }
1034 1003
1035 return_ACPI_STATUS (AE_OK); 1004 return_ACPI_STATUS(AE_OK);
1036} 1005}
1037 1006
1038
1039/******************************************************************************* 1007/*******************************************************************************
1040 * 1008 *
1041 * FUNCTION: acpi_ev_gpe_initialize 1009 * FUNCTION: acpi_ev_gpe_initialize
@@ -1048,22 +1016,18 @@ acpi_ev_create_gpe_block (
1048 * 1016 *
1049 ******************************************************************************/ 1017 ******************************************************************************/
1050 1018
1051acpi_status 1019acpi_status acpi_ev_gpe_initialize(void)
1052acpi_ev_gpe_initialize (
1053 void)
1054{ 1020{
1055 u32 register_count0 = 0; 1021 u32 register_count0 = 0;
1056 u32 register_count1 = 0; 1022 u32 register_count1 = 0;
1057 u32 gpe_number_max = 0; 1023 u32 gpe_number_max = 0;
1058 acpi_status status; 1024 acpi_status status;
1059 1025
1026 ACPI_FUNCTION_TRACE("ev_gpe_initialize");
1060 1027
1061 ACPI_FUNCTION_TRACE ("ev_gpe_initialize"); 1028 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
1062 1029 if (ACPI_FAILURE(status)) {
1063 1030 return_ACPI_STATUS(status);
1064 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
1065 if (ACPI_FAILURE (status)) {
1066 return_ACPI_STATUS (status);
1067 } 1031 }
1068 1032
1069 /* 1033 /*
@@ -1091,29 +1055,29 @@ acpi_ev_gpe_initialize (
1091 * If EITHER the register length OR the block address are zero, then that 1055 * If EITHER the register length OR the block address are zero, then that
1092 * particular block is not supported. 1056 * particular block is not supported.
1093 */ 1057 */
1094 if (acpi_gbl_FADT->gpe0_blk_len && 1058 if (acpi_gbl_FADT->gpe0_blk_len && acpi_gbl_FADT->xgpe0_blk.address) {
1095 acpi_gbl_FADT->xgpe0_blk.address) {
1096 /* GPE block 0 exists (has both length and address > 0) */ 1059 /* GPE block 0 exists (has both length and address > 0) */
1097 1060
1098 register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2); 1061 register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2);
1099 1062
1100 gpe_number_max = (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; 1063 gpe_number_max =
1064 (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1;
1101 1065
1102 /* Install GPE Block 0 */ 1066 /* Install GPE Block 0 */
1103 1067
1104 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, 1068 status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
1105 &acpi_gbl_FADT->xgpe0_blk, register_count0, 0, 1069 &acpi_gbl_FADT->xgpe0_blk,
1106 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[0]); 1070 register_count0, 0,
1071 acpi_gbl_FADT->sci_int,
1072 &acpi_gbl_gpe_fadt_blocks[0]);
1107 1073
1108 if (ACPI_FAILURE (status)) { 1074 if (ACPI_FAILURE(status)) {
1109 ACPI_REPORT_ERROR (( 1075 ACPI_REPORT_ERROR(("Could not create GPE Block 0, %s\n",
1110 "Could not create GPE Block 0, %s\n", 1076 acpi_format_exception(status)));
1111 acpi_format_exception (status)));
1112 } 1077 }
1113 } 1078 }
1114 1079
1115 if (acpi_gbl_FADT->gpe1_blk_len && 1080 if (acpi_gbl_FADT->gpe1_blk_len && acpi_gbl_FADT->xgpe1_blk.address) {
1116 acpi_gbl_FADT->xgpe1_blk.address) {
1117 /* GPE block 1 exists (has both length and address > 0) */ 1081 /* GPE block 1 exists (has both length and address > 0) */
1118 1082
1119 register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2); 1083 register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2);
@@ -1121,29 +1085,26 @@ acpi_ev_gpe_initialize (
1121 /* Check for GPE0/GPE1 overlap (if both banks exist) */ 1085 /* Check for GPE0/GPE1 overlap (if both banks exist) */
1122 1086
1123 if ((register_count0) && 1087 if ((register_count0) &&
1124 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) { 1088 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) {
1125 ACPI_REPORT_ERROR (( 1089 ACPI_REPORT_ERROR(("GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n", gpe_number_max, acpi_gbl_FADT->gpe1_base, acpi_gbl_FADT->gpe1_base + ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
1126 "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n",
1127 gpe_number_max, acpi_gbl_FADT->gpe1_base,
1128 acpi_gbl_FADT->gpe1_base +
1129 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
1130 1090
1131 /* Ignore GPE1 block by setting the register count to zero */ 1091 /* Ignore GPE1 block by setting the register count to zero */
1132 1092
1133 register_count1 = 0; 1093 register_count1 = 0;
1134 } 1094 } else {
1135 else {
1136 /* Install GPE Block 1 */ 1095 /* Install GPE Block 1 */
1137 1096
1138 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, 1097 status =
1139 &acpi_gbl_FADT->xgpe1_blk, register_count1, 1098 acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
1140 acpi_gbl_FADT->gpe1_base, 1099 &acpi_gbl_FADT->xgpe1_blk,
1141 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[1]); 1100 register_count1,
1142 1101 acpi_gbl_FADT->gpe1_base,
1143 if (ACPI_FAILURE (status)) { 1102 acpi_gbl_FADT->sci_int,
1144 ACPI_REPORT_ERROR (( 1103 &acpi_gbl_gpe_fadt_blocks
1145 "Could not create GPE Block 1, %s\n", 1104 [1]);
1146 acpi_format_exception (status))); 1105
1106 if (ACPI_FAILURE(status)) {
1107 ACPI_REPORT_ERROR(("Could not create GPE Block 1, %s\n", acpi_format_exception(status)));
1147 } 1108 }
1148 1109
1149 /* 1110 /*
@@ -1151,7 +1112,7 @@ acpi_ev_gpe_initialize (
1151 * space. However, GPE0 always starts at GPE number zero. 1112 * space. However, GPE0 always starts at GPE number zero.
1152 */ 1113 */
1153 gpe_number_max = acpi_gbl_FADT->gpe1_base + 1114 gpe_number_max = acpi_gbl_FADT->gpe1_base +
1154 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); 1115 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
1155 } 1116 }
1156 } 1117 }
1157 1118
@@ -1160,8 +1121,8 @@ acpi_ev_gpe_initialize (
1160 if ((register_count0 + register_count1) == 0) { 1121 if ((register_count0 + register_count1) == 0) {
1161 /* GPEs are not required by ACPI, this is OK */ 1122 /* GPEs are not required by ACPI, this is OK */
1162 1123
1163 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 1124 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1164 "There are no GPE blocks defined in the FADT\n")); 1125 "There are no GPE blocks defined in the FADT\n"));
1165 status = AE_OK; 1126 status = AE_OK;
1166 goto cleanup; 1127 goto cleanup;
1167 } 1128 }
@@ -1169,15 +1130,12 @@ acpi_ev_gpe_initialize (
1169 /* Check for Max GPE number out-of-range */ 1130 /* Check for Max GPE number out-of-range */
1170 1131
1171 if (gpe_number_max > ACPI_GPE_MAX) { 1132 if (gpe_number_max > ACPI_GPE_MAX) {
1172 ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n", 1133 ACPI_REPORT_ERROR(("Maximum GPE number from FADT is too large: 0x%X\n", gpe_number_max));
1173 gpe_number_max));
1174 status = AE_BAD_VALUE; 1134 status = AE_BAD_VALUE;
1175 goto cleanup; 1135 goto cleanup;
1176 } 1136 }
1177 1137
1178cleanup: 1138 cleanup:
1179 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 1139 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
1180 return_ACPI_STATUS (AE_OK); 1140 return_ACPI_STATUS(AE_OK);
1181} 1141}
1182
1183
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 3df3ada4b9e7..7e57b8470f55 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -47,12 +47,10 @@
47#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evmisc") 50ACPI_MODULE_NAME("evmisc")
51
52 51
53#ifdef ACPI_DEBUG_OUTPUT 52#ifdef ACPI_DEBUG_OUTPUT
54static const char *acpi_notify_value_names[] = 53static const char *acpi_notify_value_names[] = {
55{
56 "Bus Check", 54 "Bus Check",
57 "Device Check", 55 "Device Check",
58 "Device Wake", 56 "Device Wake",
@@ -66,18 +64,11 @@ static const char *acpi_notify_value_names[] =
66 64
67/* Local prototypes */ 65/* Local prototypes */
68 66
69static void ACPI_SYSTEM_XFACE 67static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
70acpi_ev_notify_dispatch (
71 void *context);
72
73static void ACPI_SYSTEM_XFACE
74acpi_ev_global_lock_thread (
75 void *context);
76 68
77static u32 69static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context);
78acpi_ev_global_lock_handler (
79 void *context);
80 70
71static u32 acpi_ev_global_lock_handler(void *context);
81 72
82/******************************************************************************* 73/*******************************************************************************
83 * 74 *
@@ -93,9 +84,7 @@ acpi_ev_global_lock_handler (
93 * 84 *
94 ******************************************************************************/ 85 ******************************************************************************/
95 86
96u8 87u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node)
97acpi_ev_is_notify_object (
98 struct acpi_namespace_node *node)
99{ 88{
100 switch (node->type) { 89 switch (node->type) {
101 case ACPI_TYPE_DEVICE: 90 case ACPI_TYPE_DEVICE:
@@ -112,7 +101,6 @@ acpi_ev_is_notify_object (
112 } 101 }
113} 102}
114 103
115
116/******************************************************************************* 104/*******************************************************************************
117 * 105 *
118 * FUNCTION: acpi_ev_queue_notify_request 106 * FUNCTION: acpi_ev_queue_notify_request
@@ -128,18 +116,15 @@ acpi_ev_is_notify_object (
128 ******************************************************************************/ 116 ******************************************************************************/
129 117
130acpi_status 118acpi_status
131acpi_ev_queue_notify_request ( 119acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
132 struct acpi_namespace_node *node, 120 u32 notify_value)
133 u32 notify_value)
134{ 121{
135 union acpi_operand_object *obj_desc; 122 union acpi_operand_object *obj_desc;
136 union acpi_operand_object *handler_obj = NULL; 123 union acpi_operand_object *handler_obj = NULL;
137 union acpi_generic_state *notify_info; 124 union acpi_generic_state *notify_info;
138 acpi_status status = AE_OK; 125 acpi_status status = AE_OK;
139
140
141 ACPI_FUNCTION_NAME ("ev_queue_notify_request");
142 126
127 ACPI_FUNCTION_NAME("ev_queue_notify_request");
143 128
144 /* 129 /*
145 * For value 3 (Ejection Request), some device method may need to be run. 130 * For value 3 (Ejection Request), some device method may need to be run.
@@ -148,22 +133,22 @@ acpi_ev_queue_notify_request (
148 * For value 0x80 (Status Change) on the power button or sleep button, 133 * For value 0x80 (Status Change) on the power button or sleep button,
149 * initiate soft-off or sleep operation? 134 * initiate soft-off or sleep operation?
150 */ 135 */
151 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 136 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
152 "Dispatching Notify(%X) on node %p\n", notify_value, node)); 137 "Dispatching Notify(%X) on node %p\n", notify_value,
138 node));
153 139
154 if (notify_value <= 7) { 140 if (notify_value <= 7) {
155 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n", 141 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notify value: %s\n",
156 acpi_notify_value_names[notify_value])); 142 acpi_notify_value_names[notify_value]));
157 } 143 } else {
158 else { 144 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
159 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 145 "Notify value: 0x%2.2X **Device Specific**\n",
160 "Notify value: 0x%2.2X **Device Specific**\n", 146 notify_value));
161 notify_value));
162 } 147 }
163 148
164 /* Get the notify object attached to the NS Node */ 149 /* Get the notify object attached to the NS Node */
165 150
166 obj_desc = acpi_ns_get_attached_object (node); 151 obj_desc = acpi_ns_get_attached_object(node);
167 if (obj_desc) { 152 if (obj_desc) {
168 /* We have the notify object, Get the right handler */ 153 /* We have the notify object, Get the right handler */
169 154
@@ -174,10 +159,11 @@ acpi_ev_queue_notify_request (
174 case ACPI_TYPE_POWER: 159 case ACPI_TYPE_POWER:
175 160
176 if (notify_value <= ACPI_MAX_SYS_NOTIFY) { 161 if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
177 handler_obj = obj_desc->common_notify.system_notify; 162 handler_obj =
178 } 163 obj_desc->common_notify.system_notify;
179 else { 164 } else {
180 handler_obj = obj_desc->common_notify.device_notify; 165 handler_obj =
166 obj_desc->common_notify.device_notify;
181 } 167 }
182 break; 168 break;
183 169
@@ -189,23 +175,25 @@ acpi_ev_queue_notify_request (
189 175
190 /* If there is any handler to run, schedule the dispatcher */ 176 /* If there is any handler to run, schedule the dispatcher */
191 177
192 if ((acpi_gbl_system_notify.handler && (notify_value <= ACPI_MAX_SYS_NOTIFY)) || 178 if ((acpi_gbl_system_notify.handler
193 (acpi_gbl_device_notify.handler && (notify_value > ACPI_MAX_SYS_NOTIFY)) || 179 && (notify_value <= ACPI_MAX_SYS_NOTIFY))
194 handler_obj) { 180 || (acpi_gbl_device_notify.handler
195 notify_info = acpi_ut_create_generic_state (); 181 && (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) {
182 notify_info = acpi_ut_create_generic_state();
196 if (!notify_info) { 183 if (!notify_info) {
197 return (AE_NO_MEMORY); 184 return (AE_NO_MEMORY);
198 } 185 }
199 186
200 notify_info->common.data_type = ACPI_DESC_TYPE_STATE_NOTIFY; 187 notify_info->common.data_type = ACPI_DESC_TYPE_STATE_NOTIFY;
201 notify_info->notify.node = node; 188 notify_info->notify.node = node;
202 notify_info->notify.value = (u16) notify_value; 189 notify_info->notify.value = (u16) notify_value;
203 notify_info->notify.handler_obj = handler_obj; 190 notify_info->notify.handler_obj = handler_obj;
204 191
205 status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, 192 status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH,
206 acpi_ev_notify_dispatch, notify_info); 193 acpi_ev_notify_dispatch,
207 if (ACPI_FAILURE (status)) { 194 notify_info);
208 acpi_ut_delete_generic_state (notify_info); 195 if (ACPI_FAILURE(status)) {
196 acpi_ut_delete_generic_state(notify_info);
209 } 197 }
210 } 198 }
211 199
@@ -214,15 +202,15 @@ acpi_ev_queue_notify_request (
214 * There is no per-device notify handler for this device. 202 * There is no per-device notify handler for this device.
215 * This may or may not be a problem. 203 * This may or may not be a problem.
216 */ 204 */
217 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 205 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
218 "No notify handler for Notify(%4.4s, %X) node %p\n", 206 "No notify handler for Notify(%4.4s, %X) node %p\n",
219 acpi_ut_get_node_name (node), notify_value, node)); 207 acpi_ut_get_node_name(node), notify_value,
208 node));
220 } 209 }
221 210
222 return (status); 211 return (status);
223} 212}
224 213
225
226/******************************************************************************* 214/*******************************************************************************
227 * 215 *
228 * FUNCTION: acpi_ev_notify_dispatch 216 * FUNCTION: acpi_ev_notify_dispatch
@@ -236,18 +224,15 @@ acpi_ev_queue_notify_request (
236 * 224 *
237 ******************************************************************************/ 225 ******************************************************************************/
238 226
239static void ACPI_SYSTEM_XFACE 227static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
240acpi_ev_notify_dispatch (
241 void *context)
242{ 228{
243 union acpi_generic_state *notify_info = (union acpi_generic_state *) context; 229 union acpi_generic_state *notify_info =
244 acpi_notify_handler global_handler = NULL; 230 (union acpi_generic_state *)context;
245 void *global_context = NULL; 231 acpi_notify_handler global_handler = NULL;
246 union acpi_operand_object *handler_obj; 232 void *global_context = NULL;
247 233 union acpi_operand_object *handler_obj;
248
249 ACPI_FUNCTION_ENTRY ();
250 234
235 ACPI_FUNCTION_ENTRY();
251 236
252 /* 237 /*
253 * We will invoke a global notify handler if installed. 238 * We will invoke a global notify handler if installed.
@@ -261,8 +246,7 @@ acpi_ev_notify_dispatch (
261 global_handler = acpi_gbl_system_notify.handler; 246 global_handler = acpi_gbl_system_notify.handler;
262 global_context = acpi_gbl_system_notify.context; 247 global_context = acpi_gbl_system_notify.context;
263 } 248 }
264 } 249 } else {
265 else {
266 /* Global driver notification handler */ 250 /* Global driver notification handler */
267 251
268 if (acpi_gbl_device_notify.handler) { 252 if (acpi_gbl_device_notify.handler) {
@@ -274,25 +258,24 @@ acpi_ev_notify_dispatch (
274 /* Invoke the system handler first, if present */ 258 /* Invoke the system handler first, if present */
275 259
276 if (global_handler) { 260 if (global_handler) {
277 global_handler (notify_info->notify.node, notify_info->notify.value, 261 global_handler(notify_info->notify.node,
278 global_context); 262 notify_info->notify.value, global_context);
279 } 263 }
280 264
281 /* Now invoke the per-device handler, if present */ 265 /* Now invoke the per-device handler, if present */
282 266
283 handler_obj = notify_info->notify.handler_obj; 267 handler_obj = notify_info->notify.handler_obj;
284 if (handler_obj) { 268 if (handler_obj) {
285 handler_obj->notify.handler (notify_info->notify.node, 269 handler_obj->notify.handler(notify_info->notify.node,
286 notify_info->notify.value, 270 notify_info->notify.value,
287 handler_obj->notify.context); 271 handler_obj->notify.context);
288 } 272 }
289 273
290 /* All done with the info object */ 274 /* All done with the info object */
291 275
292 acpi_ut_delete_generic_state (notify_info); 276 acpi_ut_delete_generic_state(notify_info);
293} 277}
294 278
295
296/******************************************************************************* 279/*******************************************************************************
297 * 280 *
298 * FUNCTION: acpi_ev_global_lock_thread 281 * FUNCTION: acpi_ev_global_lock_thread
@@ -307,27 +290,24 @@ acpi_ev_notify_dispatch (
307 * 290 *
308 ******************************************************************************/ 291 ******************************************************************************/
309 292
310static void ACPI_SYSTEM_XFACE 293static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context)
311acpi_ev_global_lock_thread (
312 void *context)
313{ 294{
314 acpi_status status; 295 acpi_status status;
315
316 296
317 /* Signal threads that are waiting for the lock */ 297 /* Signal threads that are waiting for the lock */
318 298
319 if (acpi_gbl_global_lock_thread_count) { 299 if (acpi_gbl_global_lock_thread_count) {
320 /* Send sufficient units to the semaphore */ 300 /* Send sufficient units to the semaphore */
321 301
322 status = acpi_os_signal_semaphore (acpi_gbl_global_lock_semaphore, 302 status =
323 acpi_gbl_global_lock_thread_count); 303 acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore,
324 if (ACPI_FAILURE (status)) { 304 acpi_gbl_global_lock_thread_count);
325 ACPI_REPORT_ERROR (("Could not signal Global Lock semaphore\n")); 305 if (ACPI_FAILURE(status)) {
306 ACPI_REPORT_ERROR(("Could not signal Global Lock semaphore\n"));
326 } 307 }
327 } 308 }
328} 309}
329 310
330
331/******************************************************************************* 311/*******************************************************************************
332 * 312 *
333 * FUNCTION: acpi_ev_global_lock_handler 313 * FUNCTION: acpi_ev_global_lock_handler
@@ -342,20 +322,17 @@ acpi_ev_global_lock_thread (
342 * 322 *
343 ******************************************************************************/ 323 ******************************************************************************/
344 324
345static u32 325static u32 acpi_ev_global_lock_handler(void *context)
346acpi_ev_global_lock_handler (
347 void *context)
348{ 326{
349 u8 acquired = FALSE; 327 u8 acquired = FALSE;
350 acpi_status status; 328 acpi_status status;
351
352 329
353 /* 330 /*
354 * Attempt to get the lock 331 * Attempt to get the lock
355 * If we don't get it now, it will be marked pending and we will 332 * If we don't get it now, it will be marked pending and we will
356 * take another interrupt when it becomes free. 333 * take another interrupt when it becomes free.
357 */ 334 */
358 ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired); 335 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired);
359 if (acquired) { 336 if (acquired) {
360 /* Got the lock, now wake all threads waiting for it */ 337 /* Got the lock, now wake all threads waiting for it */
361 338
@@ -363,11 +340,11 @@ acpi_ev_global_lock_handler (
363 340
364 /* Run the Global Lock thread which will signal all waiting threads */ 341 /* Run the Global Lock thread which will signal all waiting threads */
365 342
366 status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH, 343 status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH,
367 acpi_ev_global_lock_thread, context); 344 acpi_ev_global_lock_thread,
368 if (ACPI_FAILURE (status)) { 345 context);
369 ACPI_REPORT_ERROR (("Could not queue Global Lock thread, %s\n", 346 if (ACPI_FAILURE(status)) {
370 acpi_format_exception (status))); 347 ACPI_REPORT_ERROR(("Could not queue Global Lock thread, %s\n", acpi_format_exception(status)));
371 348
372 return (ACPI_INTERRUPT_NOT_HANDLED); 349 return (ACPI_INTERRUPT_NOT_HANDLED);
373 } 350 }
@@ -376,7 +353,6 @@ acpi_ev_global_lock_handler (
376 return (ACPI_INTERRUPT_HANDLED); 353 return (ACPI_INTERRUPT_HANDLED);
377} 354}
378 355
379
380/******************************************************************************* 356/*******************************************************************************
381 * 357 *
382 * FUNCTION: acpi_ev_init_global_lock_handler 358 * FUNCTION: acpi_ev_init_global_lock_handler
@@ -389,19 +365,16 @@ acpi_ev_global_lock_handler (
389 * 365 *
390 ******************************************************************************/ 366 ******************************************************************************/
391 367
392acpi_status 368acpi_status acpi_ev_init_global_lock_handler(void)
393acpi_ev_init_global_lock_handler (
394 void)
395{ 369{
396 acpi_status status; 370 acpi_status status;
397
398
399 ACPI_FUNCTION_TRACE ("ev_init_global_lock_handler");
400 371
372 ACPI_FUNCTION_TRACE("ev_init_global_lock_handler");
401 373
402 acpi_gbl_global_lock_present = TRUE; 374 acpi_gbl_global_lock_present = TRUE;
403 status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL, 375 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
404 acpi_ev_global_lock_handler, NULL); 376 acpi_ev_global_lock_handler,
377 NULL);
405 378
406 /* 379 /*
407 * If the global lock does not exist on this platform, the attempt 380 * If the global lock does not exist on this platform, the attempt
@@ -411,17 +384,15 @@ acpi_ev_init_global_lock_handler (
411 * with an error. 384 * with an error.
412 */ 385 */
413 if (status == AE_NO_HARDWARE_RESPONSE) { 386 if (status == AE_NO_HARDWARE_RESPONSE) {
414 ACPI_REPORT_ERROR (( 387 ACPI_REPORT_ERROR(("No response from Global Lock hardware, disabling lock\n"));
415 "No response from Global Lock hardware, disabling lock\n"));
416 388
417 acpi_gbl_global_lock_present = FALSE; 389 acpi_gbl_global_lock_present = FALSE;
418 status = AE_OK; 390 status = AE_OK;
419 } 391 }
420 392
421 return_ACPI_STATUS (status); 393 return_ACPI_STATUS(status);
422} 394}
423 395
424
425/****************************************************************************** 396/******************************************************************************
426 * 397 *
427 * FUNCTION: acpi_ev_acquire_global_lock 398 * FUNCTION: acpi_ev_acquire_global_lock
@@ -434,22 +405,18 @@ acpi_ev_init_global_lock_handler (
434 * 405 *
435 *****************************************************************************/ 406 *****************************************************************************/
436 407
437acpi_status 408acpi_status acpi_ev_acquire_global_lock(u16 timeout)
438acpi_ev_acquire_global_lock (
439 u16 timeout)
440{ 409{
441 acpi_status status = AE_OK; 410 acpi_status status = AE_OK;
442 u8 acquired = FALSE; 411 u8 acquired = FALSE;
443
444
445 ACPI_FUNCTION_TRACE ("ev_acquire_global_lock");
446 412
413 ACPI_FUNCTION_TRACE("ev_acquire_global_lock");
447 414
448#ifndef ACPI_APPLICATION 415#ifndef ACPI_APPLICATION
449 /* Make sure that we actually have a global lock */ 416 /* Make sure that we actually have a global lock */
450 417
451 if (!acpi_gbl_global_lock_present) { 418 if (!acpi_gbl_global_lock_present) {
452 return_ACPI_STATUS (AE_NO_GLOBAL_LOCK); 419 return_ACPI_STATUS(AE_NO_GLOBAL_LOCK);
453 } 420 }
454#endif 421#endif
455 422
@@ -462,37 +429,37 @@ acpi_ev_acquire_global_lock (
462 * we are done 429 * we are done
463 */ 430 */
464 if (acpi_gbl_global_lock_acquired) { 431 if (acpi_gbl_global_lock_acquired) {
465 return_ACPI_STATUS (AE_OK); 432 return_ACPI_STATUS(AE_OK);
466 } 433 }
467 434
468 /* We must acquire the actual hardware lock */ 435 /* We must acquire the actual hardware lock */
469 436
470 ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired); 437 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired);
471 if (acquired) { 438 if (acquired) {
472 /* We got the lock */ 439 /* We got the lock */
473 440
474 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n")); 441 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
442 "Acquired the HW Global Lock\n"));
475 443
476 acpi_gbl_global_lock_acquired = TRUE; 444 acpi_gbl_global_lock_acquired = TRUE;
477 return_ACPI_STATUS (AE_OK); 445 return_ACPI_STATUS(AE_OK);
478 } 446 }
479 447
480 /* 448 /*
481 * Did not get the lock. The pending bit was set above, and we must now 449 * Did not get the lock. The pending bit was set above, and we must now
482 * wait until we get the global lock released interrupt. 450 * wait until we get the global lock released interrupt.
483 */ 451 */
484 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n")); 452 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n"));
485 453
486 /* 454 /*
487 * Acquire the global lock semaphore first. 455 * Acquire the global lock semaphore first.
488 * Since this wait will block, we must release the interpreter 456 * Since this wait will block, we must release the interpreter
489 */ 457 */
490 status = acpi_ex_system_wait_semaphore (acpi_gbl_global_lock_semaphore, 458 status = acpi_ex_system_wait_semaphore(acpi_gbl_global_lock_semaphore,
491 timeout); 459 timeout);
492 return_ACPI_STATUS (status); 460 return_ACPI_STATUS(status);
493} 461}
494 462
495
496/******************************************************************************* 463/*******************************************************************************
497 * 464 *
498 * FUNCTION: acpi_ev_release_global_lock 465 * FUNCTION: acpi_ev_release_global_lock
@@ -505,21 +472,16 @@ acpi_ev_acquire_global_lock (
505 * 472 *
506 ******************************************************************************/ 473 ******************************************************************************/
507 474
508acpi_status 475acpi_status acpi_ev_release_global_lock(void)
509acpi_ev_release_global_lock (
510 void)
511{ 476{
512 u8 pending = FALSE; 477 u8 pending = FALSE;
513 acpi_status status = AE_OK; 478 acpi_status status = AE_OK;
514
515
516 ACPI_FUNCTION_TRACE ("ev_release_global_lock");
517 479
480 ACPI_FUNCTION_TRACE("ev_release_global_lock");
518 481
519 if (!acpi_gbl_global_lock_thread_count) { 482 if (!acpi_gbl_global_lock_thread_count) {
520 ACPI_REPORT_WARNING(( 483 ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));
521 "Cannot release HW Global Lock, it has not been acquired\n")); 484 return_ACPI_STATUS(AE_NOT_ACQUIRED);
522 return_ACPI_STATUS (AE_NOT_ACQUIRED);
523 } 485 }
524 486
525 /* One fewer thread has the global lock */ 487 /* One fewer thread has the global lock */
@@ -528,14 +490,14 @@ acpi_ev_release_global_lock (
528 if (acpi_gbl_global_lock_thread_count) { 490 if (acpi_gbl_global_lock_thread_count) {
529 /* There are still some threads holding the lock, cannot release */ 491 /* There are still some threads holding the lock, cannot release */
530 492
531 return_ACPI_STATUS (AE_OK); 493 return_ACPI_STATUS(AE_OK);
532 } 494 }
533 495
534 /* 496 /*
535 * No more threads holding lock, we can do the actual hardware 497 * No more threads holding lock, we can do the actual hardware
536 * release 498 * release
537 */ 499 */
538 ACPI_RELEASE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, pending); 500 ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, pending);
539 acpi_gbl_global_lock_acquired = FALSE; 501 acpi_gbl_global_lock_acquired = FALSE;
540 502
541 /* 503 /*
@@ -543,14 +505,13 @@ acpi_ev_release_global_lock (
543 * register 505 * register
544 */ 506 */
545 if (pending) { 507 if (pending) {
546 status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 508 status = acpi_set_register(ACPI_BITREG_GLOBAL_LOCK_RELEASE,
547 1, ACPI_MTX_LOCK); 509 1, ACPI_MTX_LOCK);
548 } 510 }
549 511
550 return_ACPI_STATUS (status); 512 return_ACPI_STATUS(status);
551} 513}
552 514
553
554/****************************************************************************** 515/******************************************************************************
555 * 516 *
556 * FUNCTION: acpi_ev_terminate 517 * FUNCTION: acpi_ev_terminate
@@ -563,16 +524,12 @@ acpi_ev_release_global_lock (
563 * 524 *
564 ******************************************************************************/ 525 ******************************************************************************/
565 526
566void 527void acpi_ev_terminate(void)
567acpi_ev_terminate (
568 void)
569{ 528{
570 acpi_native_uint i; 529 acpi_native_uint i;
571 acpi_status status; 530 acpi_status status;
572
573
574 ACPI_FUNCTION_TRACE ("ev_terminate");
575 531
532 ACPI_FUNCTION_TRACE("ev_terminate");
576 533
577 if (acpi_gbl_events_initialized) { 534 if (acpi_gbl_events_initialized) {
578 /* 535 /*
@@ -583,38 +540,39 @@ acpi_ev_terminate (
583 /* Disable all fixed events */ 540 /* Disable all fixed events */
584 541
585 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 542 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
586 status = acpi_disable_event ((u32) i, 0); 543 status = acpi_disable_event((u32) i, 0);
587 if (ACPI_FAILURE (status)) { 544 if (ACPI_FAILURE(status)) {
588 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
589 "Could not disable fixed event %d\n", (u32) i)); 546 "Could not disable fixed event %d\n",
547 (u32) i));
590 } 548 }
591 } 549 }
592 550
593 /* Disable all GPEs in all GPE blocks */ 551 /* Disable all GPEs in all GPE blocks */
594 552
595 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); 553 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block);
596 554
597 /* Remove SCI handler */ 555 /* Remove SCI handler */
598 556
599 status = acpi_ev_remove_sci_handler (); 557 status = acpi_ev_remove_sci_handler();
600 if (ACPI_FAILURE(status)) { 558 if (ACPI_FAILURE(status)) {
601 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 559 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
602 "Could not remove SCI handler\n")); 560 "Could not remove SCI handler\n"));
603 } 561 }
604 } 562 }
605 563
606 /* Deallocate all handler objects installed within GPE info structs */ 564 /* Deallocate all handler objects installed within GPE info structs */
607 565
608 status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers); 566 status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers);
609 567
610 /* Return to original mode if necessary */ 568 /* Return to original mode if necessary */
611 569
612 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) { 570 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {
613 status = acpi_disable (); 571 status = acpi_disable();
614 if (ACPI_FAILURE (status)) { 572 if (ACPI_FAILURE(status)) {
615 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_disable failed\n")); 573 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
574 "acpi_disable failed\n"));
616 } 575 }
617 } 576 }
618 return_VOID; 577 return_VOID;
619} 578}
620
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index a1d7276c5742..84fad082d80d 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -41,39 +41,30 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acevents.h> 45#include <acpi/acevents.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49 48
50#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evregion") 50ACPI_MODULE_NAME("evregion")
52
53#define ACPI_NUM_DEFAULT_SPACES 4 51#define ACPI_NUM_DEFAULT_SPACES 4
54 52static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
55static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { 53 ACPI_ADR_SPACE_SYSTEM_MEMORY,
56 ACPI_ADR_SPACE_SYSTEM_MEMORY, 54 ACPI_ADR_SPACE_SYSTEM_IO,
57 ACPI_ADR_SPACE_SYSTEM_IO, 55 ACPI_ADR_SPACE_PCI_CONFIG,
58 ACPI_ADR_SPACE_PCI_CONFIG, 56 ACPI_ADR_SPACE_DATA_TABLE
59 ACPI_ADR_SPACE_DATA_TABLE}; 57};
60 58
61/* Local prototypes */ 59/* Local prototypes */
62 60
63static acpi_status 61static acpi_status
64acpi_ev_reg_run ( 62acpi_ev_reg_run(acpi_handle obj_handle,
65 acpi_handle obj_handle, 63 u32 level, void *context, void **return_value);
66 u32 level,
67 void *context,
68 void **return_value);
69 64
70static acpi_status 65static acpi_status
71acpi_ev_install_handler ( 66acpi_ev_install_handler(acpi_handle obj_handle,
72 acpi_handle obj_handle, 67 u32 level, void *context, void **return_value);
73 u32 level,
74 void *context,
75 void **return_value);
76
77 68
78/******************************************************************************* 69/*******************************************************************************
79 * 70 *
@@ -87,19 +78,16 @@ acpi_ev_install_handler (
87 * 78 *
88 ******************************************************************************/ 79 ******************************************************************************/
89 80
90acpi_status 81acpi_status acpi_ev_install_region_handlers(void)
91acpi_ev_install_region_handlers ( 82{
92 void) { 83 acpi_status status;
93 acpi_status status; 84 acpi_native_uint i;
94 acpi_native_uint i;
95
96
97 ACPI_FUNCTION_TRACE ("ev_install_region_handlers");
98 85
86 ACPI_FUNCTION_TRACE("ev_install_region_handlers");
99 87
100 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 88 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
101 if (ACPI_FAILURE (status)) { 89 if (ACPI_FAILURE(status)) {
102 return_ACPI_STATUS (status); 90 return_ACPI_STATUS(status);
103 } 91 }
104 92
105 /* 93 /*
@@ -121,9 +109,11 @@ acpi_ev_install_region_handlers (
121 * Similar for AE_SAME_HANDLER. 109 * Similar for AE_SAME_HANDLER.
122 */ 110 */
123 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { 111 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
124 status = acpi_ev_install_space_handler (acpi_gbl_root_node, 112 status = acpi_ev_install_space_handler(acpi_gbl_root_node,
125 acpi_gbl_default_address_spaces[i], 113 acpi_gbl_default_address_spaces
126 ACPI_DEFAULT_HANDLER, NULL, NULL); 114 [i],
115 ACPI_DEFAULT_HANDLER,
116 NULL, NULL);
127 switch (status) { 117 switch (status) {
128 case AE_OK: 118 case AE_OK:
129 case AE_SAME_HANDLER: 119 case AE_SAME_HANDLER:
@@ -140,12 +130,11 @@ acpi_ev_install_region_handlers (
140 } 130 }
141 } 131 }
142 132
143unlock_and_exit: 133 unlock_and_exit:
144 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 134 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
145 return_ACPI_STATUS (status); 135 return_ACPI_STATUS(status);
146} 136}
147 137
148
149/******************************************************************************* 138/*******************************************************************************
150 * 139 *
151 * FUNCTION: acpi_ev_initialize_op_regions 140 * FUNCTION: acpi_ev_initialize_op_regions
@@ -159,20 +148,16 @@ unlock_and_exit:
159 * 148 *
160 ******************************************************************************/ 149 ******************************************************************************/
161 150
162acpi_status 151acpi_status acpi_ev_initialize_op_regions(void)
163acpi_ev_initialize_op_regions (
164 void)
165{ 152{
166 acpi_status status; 153 acpi_status status;
167 acpi_native_uint i; 154 acpi_native_uint i;
168
169 155
170 ACPI_FUNCTION_TRACE ("ev_initialize_op_regions"); 156 ACPI_FUNCTION_TRACE("ev_initialize_op_regions");
171 157
172 158 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
173 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 159 if (ACPI_FAILURE(status)) {
174 if (ACPI_FAILURE (status)) { 160 return_ACPI_STATUS(status);
175 return_ACPI_STATUS (status);
176 } 161 }
177 162
178 /* 163 /*
@@ -182,15 +167,15 @@ acpi_ev_initialize_op_regions (
182 /* TBD: Make sure handler is the DEFAULT handler, otherwise 167 /* TBD: Make sure handler is the DEFAULT handler, otherwise
183 * _REG will have already been run. 168 * _REG will have already been run.
184 */ 169 */
185 status = acpi_ev_execute_reg_methods (acpi_gbl_root_node, 170 status = acpi_ev_execute_reg_methods(acpi_gbl_root_node,
186 acpi_gbl_default_address_spaces[i]); 171 acpi_gbl_default_address_spaces
172 [i]);
187 } 173 }
188 174
189 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 175 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
190 return_ACPI_STATUS (status); 176 return_ACPI_STATUS(status);
191} 177}
192 178
193
194/******************************************************************************* 179/*******************************************************************************
195 * 180 *
196 * FUNCTION: acpi_ev_execute_reg_method 181 * FUNCTION: acpi_ev_execute_reg_method
@@ -205,26 +190,22 @@ acpi_ev_initialize_op_regions (
205 ******************************************************************************/ 190 ******************************************************************************/
206 191
207acpi_status 192acpi_status
208acpi_ev_execute_reg_method ( 193acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
209 union acpi_operand_object *region_obj,
210 u32 function)
211{ 194{
212 struct acpi_parameter_info info; 195 struct acpi_parameter_info info;
213 union acpi_operand_object *params[3]; 196 union acpi_operand_object *params[3];
214 union acpi_operand_object *region_obj2; 197 union acpi_operand_object *region_obj2;
215 acpi_status status; 198 acpi_status status;
216
217 199
218 ACPI_FUNCTION_TRACE ("ev_execute_reg_method"); 200 ACPI_FUNCTION_TRACE("ev_execute_reg_method");
219 201
220 202 region_obj2 = acpi_ns_get_secondary_object(region_obj);
221 region_obj2 = acpi_ns_get_secondary_object (region_obj);
222 if (!region_obj2) { 203 if (!region_obj2) {
223 return_ACPI_STATUS (AE_NOT_EXIST); 204 return_ACPI_STATUS(AE_NOT_EXIST);
224 } 205 }
225 206
226 if (region_obj2->extra.method_REG == NULL) { 207 if (region_obj2->extra.method_REG == NULL) {
227 return_ACPI_STATUS (AE_OK); 208 return_ACPI_STATUS(AE_OK);
228 } 209 }
229 210
230 /* 211 /*
@@ -237,12 +218,12 @@ acpi_ev_execute_reg_method (
237 * 0 for disconnecting the handler 218 * 0 for disconnecting the handler
238 * Passed as a parameter 219 * Passed as a parameter
239 */ 220 */
240 params[0] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 221 params[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
241 if (!params[0]) { 222 if (!params[0]) {
242 return_ACPI_STATUS (AE_NO_MEMORY); 223 return_ACPI_STATUS(AE_NO_MEMORY);
243 } 224 }
244 225
245 params[1] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 226 params[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
246 if (!params[1]) { 227 if (!params[1]) {
247 status = AE_NO_MEMORY; 228 status = AE_NO_MEMORY;
248 goto cleanup; 229 goto cleanup;
@@ -260,19 +241,18 @@ acpi_ev_execute_reg_method (
260 241
261 /* Execute the method, no return value */ 242 /* Execute the method, no return value */
262 243
263 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname ( 244 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
264 ACPI_TYPE_METHOD, info.node, NULL)); 245 (ACPI_TYPE_METHOD, info.node, NULL));
265 status = acpi_ns_evaluate_by_handle (&info); 246 status = acpi_ns_evaluate_by_handle(&info);
266 247
267 acpi_ut_remove_reference (params[1]); 248 acpi_ut_remove_reference(params[1]);
268 249
269cleanup: 250 cleanup:
270 acpi_ut_remove_reference (params[0]); 251 acpi_ut_remove_reference(params[0]);
271 252
272 return_ACPI_STATUS (status); 253 return_ACPI_STATUS(status);
273} 254}
274 255
275
276/******************************************************************************* 256/*******************************************************************************
277 * 257 *
278 * FUNCTION: acpi_ev_address_space_dispatch 258 * FUNCTION: acpi_ev_address_space_dispatch
@@ -291,40 +271,38 @@ cleanup:
291 ******************************************************************************/ 271 ******************************************************************************/
292 272
293acpi_status 273acpi_status
294acpi_ev_address_space_dispatch ( 274acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
295 union acpi_operand_object *region_obj, 275 u32 function,
296 u32 function, 276 acpi_physical_address address,
297 acpi_physical_address address, 277 u32 bit_width, void *value)
298 u32 bit_width,
299 void *value)
300{ 278{
301 acpi_status status; 279 acpi_status status;
302 acpi_status status2; 280 acpi_status status2;
303 acpi_adr_space_handler handler; 281 acpi_adr_space_handler handler;
304 acpi_adr_space_setup region_setup; 282 acpi_adr_space_setup region_setup;
305 union acpi_operand_object *handler_desc; 283 union acpi_operand_object *handler_desc;
306 union acpi_operand_object *region_obj2; 284 union acpi_operand_object *region_obj2;
307 void *region_context = NULL; 285 void *region_context = NULL;
308 286
287 ACPI_FUNCTION_TRACE("ev_address_space_dispatch");
309 288
310 ACPI_FUNCTION_TRACE ("ev_address_space_dispatch"); 289 region_obj2 = acpi_ns_get_secondary_object(region_obj);
311
312
313 region_obj2 = acpi_ns_get_secondary_object (region_obj);
314 if (!region_obj2) { 290 if (!region_obj2) {
315 return_ACPI_STATUS (AE_NOT_EXIST); 291 return_ACPI_STATUS(AE_NOT_EXIST);
316 } 292 }
317 293
318 /* Ensure that there is a handler associated with this region */ 294 /* Ensure that there is a handler associated with this region */
319 295
320 handler_desc = region_obj->region.handler; 296 handler_desc = region_obj->region.handler;
321 if (!handler_desc) { 297 if (!handler_desc) {
322 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
323 "No handler for Region [%4.4s] (%p) [%s]\n", 299 "No handler for Region [%4.4s] (%p) [%s]\n",
324 acpi_ut_get_node_name (region_obj->region.node), 300 acpi_ut_get_node_name(region_obj->region.
325 region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); 301 node), region_obj,
326 302 acpi_ut_get_region_name(region_obj->region.
327 return_ACPI_STATUS (AE_NOT_EXIST); 303 space_id)));
304
305 return_ACPI_STATUS(AE_NOT_EXIST);
328 } 306 }
329 307
330 /* 308 /*
@@ -339,10 +317,13 @@ acpi_ev_address_space_dispatch (
339 if (!region_setup) { 317 if (!region_setup) {
340 /* No initialization routine, exit with error */ 318 /* No initialization routine, exit with error */
341 319
342 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 320 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
343 "No init routine for region(%p) [%s]\n", 321 "No init routine for region(%p) [%s]\n",
344 region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); 322 region_obj,
345 return_ACPI_STATUS (AE_NOT_EXIST); 323 acpi_ut_get_region_name(region_obj->
324 region.
325 space_id)));
326 return_ACPI_STATUS(AE_NOT_EXIST);
346 } 327 }
347 328
348 /* 329 /*
@@ -350,25 +331,29 @@ acpi_ev_address_space_dispatch (
350 * setup will potentially execute control methods 331 * setup will potentially execute control methods
351 * (e.g., _REG method for this region) 332 * (e.g., _REG method for this region)
352 */ 333 */
353 acpi_ex_exit_interpreter (); 334 acpi_ex_exit_interpreter();
354 335
355 status = region_setup (region_obj, ACPI_REGION_ACTIVATE, 336 status = region_setup(region_obj, ACPI_REGION_ACTIVATE,
356 handler_desc->address_space.context, &region_context); 337 handler_desc->address_space.context,
338 &region_context);
357 339
358 /* Re-enter the interpreter */ 340 /* Re-enter the interpreter */
359 341
360 status2 = acpi_ex_enter_interpreter (); 342 status2 = acpi_ex_enter_interpreter();
361 if (ACPI_FAILURE (status2)) { 343 if (ACPI_FAILURE(status2)) {
362 return_ACPI_STATUS (status2); 344 return_ACPI_STATUS(status2);
363 } 345 }
364 346
365 /* Check for failure of the Region Setup */ 347 /* Check for failure of the Region Setup */
366 348
367 if (ACPI_FAILURE (status)) { 349 if (ACPI_FAILURE(status)) {
368 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n", 350 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
369 acpi_format_exception (status), 351 "Region Init: %s [%s]\n",
370 acpi_ut_get_region_name (region_obj->region.space_id))); 352 acpi_format_exception(status),
371 return_ACPI_STATUS (status); 353 acpi_ut_get_region_name(region_obj->
354 region.
355 space_id)));
356 return_ACPI_STATUS(status);
372 } 357 }
373 358
374 /* 359 /*
@@ -380,14 +365,14 @@ acpi_ev_address_space_dispatch (
380 if (region_obj2->extra.region_context) { 365 if (region_obj2->extra.region_context) {
381 /* The handler for this region was already installed */ 366 /* The handler for this region was already installed */
382 367
383 ACPI_MEM_FREE (region_context); 368 ACPI_MEM_FREE(region_context);
384 } 369 } else {
385 else {
386 /* 370 /*
387 * Save the returned context for use in all accesses to 371 * Save the returned context for use in all accesses to
388 * this particular region 372 * this particular region
389 */ 373 */
390 region_obj2->extra.region_context = region_context; 374 region_obj2->extra.region_context =
375 region_context;
391 } 376 }
392 } 377 }
393 } 378 }
@@ -396,13 +381,16 @@ acpi_ev_address_space_dispatch (
396 381
397 handler = handler_desc->address_space.handler; 382 handler = handler_desc->address_space.handler;
398 383
399 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 384 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
400 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", 385 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
401 &region_obj->region.handler->address_space, handler, 386 &region_obj->region.handler->address_space, handler,
402 ACPI_FORMAT_UINT64 (address), 387 ACPI_FORMAT_UINT64(address),
403 acpi_ut_get_region_name (region_obj->region.space_id))); 388 acpi_ut_get_region_name(region_obj->region.
389 space_id)));
404 390
405 if (!(handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { 391 if (!
392 (handler_desc->address_space.
393 hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
406 /* 394 /*
407 * For handlers other than the default (supplied) handlers, we must 395 * For handlers other than the default (supplied) handlers, we must
408 * exit the interpreter because the handler *might* block -- we don't 396 * exit the interpreter because the handler *might* block -- we don't
@@ -413,31 +401,33 @@ acpi_ev_address_space_dispatch (
413 401
414 /* Call the handler */ 402 /* Call the handler */
415 403
416 status = handler (function, address, bit_width, value, 404 status = handler(function, address, bit_width, value,
417 handler_desc->address_space.context, 405 handler_desc->address_space.context,
418 region_obj2->extra.region_context); 406 region_obj2->extra.region_context);
419 407
420 if (ACPI_FAILURE (status)) { 408 if (ACPI_FAILURE(status)) {
421 ACPI_REPORT_ERROR (("Handler for [%s] returned %s\n", 409 ACPI_REPORT_ERROR(("Handler for [%s] returned %s\n",
422 acpi_ut_get_region_name (region_obj->region.space_id), 410 acpi_ut_get_region_name(region_obj->region.
423 acpi_format_exception (status))); 411 space_id),
412 acpi_format_exception(status)));
424 } 413 }
425 414
426 if (!(handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { 415 if (!
416 (handler_desc->address_space.
417 hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
427 /* 418 /*
428 * We just returned from a non-default handler, we must re-enter the 419 * We just returned from a non-default handler, we must re-enter the
429 * interpreter 420 * interpreter
430 */ 421 */
431 status2 = acpi_ex_enter_interpreter (); 422 status2 = acpi_ex_enter_interpreter();
432 if (ACPI_FAILURE (status2)) { 423 if (ACPI_FAILURE(status2)) {
433 return_ACPI_STATUS (status2); 424 return_ACPI_STATUS(status2);
434 } 425 }
435 } 426 }
436 427
437 return_ACPI_STATUS (status); 428 return_ACPI_STATUS(status);
438} 429}
439 430
440
441/******************************************************************************* 431/*******************************************************************************
442 * 432 *
443 * FUNCTION: acpi_ev_detach_region 433 * FUNCTION: acpi_ev_detach_region
@@ -453,23 +443,20 @@ acpi_ev_address_space_dispatch (
453 ******************************************************************************/ 443 ******************************************************************************/
454 444
455void 445void
456acpi_ev_detach_region( 446acpi_ev_detach_region(union acpi_operand_object *region_obj,
457 union acpi_operand_object *region_obj, 447 u8 acpi_ns_is_locked)
458 u8 acpi_ns_is_locked)
459{ 448{
460 union acpi_operand_object *handler_obj; 449 union acpi_operand_object *handler_obj;
461 union acpi_operand_object *obj_desc; 450 union acpi_operand_object *obj_desc;
462 union acpi_operand_object **last_obj_ptr; 451 union acpi_operand_object **last_obj_ptr;
463 acpi_adr_space_setup region_setup; 452 acpi_adr_space_setup region_setup;
464 void **region_context; 453 void **region_context;
465 union acpi_operand_object *region_obj2; 454 union acpi_operand_object *region_obj2;
466 acpi_status status; 455 acpi_status status;
467
468
469 ACPI_FUNCTION_TRACE ("ev_detach_region");
470 456
457 ACPI_FUNCTION_TRACE("ev_detach_region");
471 458
472 region_obj2 = acpi_ns_get_secondary_object (region_obj); 459 region_obj2 = acpi_ns_get_secondary_object(region_obj);
473 if (!region_obj2) { 460 if (!region_obj2) {
474 return_VOID; 461 return_VOID;
475 } 462 }
@@ -493,34 +480,39 @@ acpi_ev_detach_region(
493 /* Is this the correct Region? */ 480 /* Is this the correct Region? */
494 481
495 if (obj_desc == region_obj) { 482 if (obj_desc == region_obj) {
496 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 483 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
497 "Removing Region %p from address handler %p\n", 484 "Removing Region %p from address handler %p\n",
498 region_obj, handler_obj)); 485 region_obj, handler_obj));
499 486
500 /* This is it, remove it from the handler's list */ 487 /* This is it, remove it from the handler's list */
501 488
502 *last_obj_ptr = obj_desc->region.next; 489 *last_obj_ptr = obj_desc->region.next;
503 obj_desc->region.next = NULL; /* Must clear field */ 490 obj_desc->region.next = NULL; /* Must clear field */
504 491
505 if (acpi_ns_is_locked) { 492 if (acpi_ns_is_locked) {
506 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 493 status =
507 if (ACPI_FAILURE (status)) { 494 acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
495 if (ACPI_FAILURE(status)) {
508 return_VOID; 496 return_VOID;
509 } 497 }
510 } 498 }
511 499
512 /* Now stop region accesses by executing the _REG method */ 500 /* Now stop region accesses by executing the _REG method */
513 501
514 status = acpi_ev_execute_reg_method (region_obj, 0); 502 status = acpi_ev_execute_reg_method(region_obj, 0);
515 if (ACPI_FAILURE (status)) { 503 if (ACPI_FAILURE(status)) {
516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region _REG, [%s]\n", 504 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
517 acpi_format_exception (status), 505 "%s from region _REG, [%s]\n",
518 acpi_ut_get_region_name (region_obj->region.space_id))); 506 acpi_format_exception(status),
507 acpi_ut_get_region_name
508 (region_obj->region.
509 space_id)));
519 } 510 }
520 511
521 if (acpi_ns_is_locked) { 512 if (acpi_ns_is_locked) {
522 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 513 status =
523 if (ACPI_FAILURE (status)) { 514 acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
515 if (ACPI_FAILURE(status)) {
524 return_VOID; 516 return_VOID;
525 } 517 }
526 } 518 }
@@ -528,15 +520,20 @@ acpi_ev_detach_region(
528 /* Call the setup handler with the deactivate notification */ 520 /* Call the setup handler with the deactivate notification */
529 521
530 region_setup = handler_obj->address_space.setup; 522 region_setup = handler_obj->address_space.setup;
531 status = region_setup (region_obj, ACPI_REGION_DEACTIVATE, 523 status =
532 handler_obj->address_space.context, region_context); 524 region_setup(region_obj, ACPI_REGION_DEACTIVATE,
525 handler_obj->address_space.context,
526 region_context);
533 527
534 /* Init routine may fail, Just ignore errors */ 528 /* Init routine may fail, Just ignore errors */
535 529
536 if (ACPI_FAILURE (status)) { 530 if (ACPI_FAILURE(status)) {
537 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region init, [%s]\n", 531 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
538 acpi_format_exception (status), 532 "%s from region init, [%s]\n",
539 acpi_ut_get_region_name (region_obj->region.space_id))); 533 acpi_format_exception(status),
534 acpi_ut_get_region_name
535 (region_obj->region.
536 space_id)));
540 } 537 }
541 538
542 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); 539 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
@@ -552,7 +549,7 @@ acpi_ev_detach_region(
552 * this better be the region's handler 549 * this better be the region's handler
553 */ 550 */
554 region_obj->region.handler = NULL; 551 region_obj->region.handler = NULL;
555 acpi_ut_remove_reference (handler_obj); 552 acpi_ut_remove_reference(handler_obj);
556 553
557 return_VOID; 554 return_VOID;
558 } 555 }
@@ -565,14 +562,13 @@ acpi_ev_detach_region(
565 562
566 /* If we get here, the region was not in the handler's region list */ 563 /* If we get here, the region was not in the handler's region list */
567 564
568 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 565 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
569 "Cannot remove region %p from address handler %p\n", 566 "Cannot remove region %p from address handler %p\n",
570 region_obj, handler_obj)); 567 region_obj, handler_obj));
571 568
572 return_VOID; 569 return_VOID;
573} 570}
574 571
575
576/******************************************************************************* 572/*******************************************************************************
577 * 573 *
578 * FUNCTION: acpi_ev_attach_region 574 * FUNCTION: acpi_ev_attach_region
@@ -589,20 +585,19 @@ acpi_ev_detach_region(
589 ******************************************************************************/ 585 ******************************************************************************/
590 586
591acpi_status 587acpi_status
592acpi_ev_attach_region ( 588acpi_ev_attach_region(union acpi_operand_object *handler_obj,
593 union acpi_operand_object *handler_obj, 589 union acpi_operand_object *region_obj,
594 union acpi_operand_object *region_obj, 590 u8 acpi_ns_is_locked)
595 u8 acpi_ns_is_locked)
596{ 591{
597 592
598 ACPI_FUNCTION_TRACE ("ev_attach_region"); 593 ACPI_FUNCTION_TRACE("ev_attach_region");
599
600 594
601 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 595 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
602 "Adding Region [%4.4s] %p to address handler %p [%s]\n", 596 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
603 acpi_ut_get_node_name (region_obj->region.node), 597 acpi_ut_get_node_name(region_obj->region.node),
604 region_obj, handler_obj, 598 region_obj, handler_obj,
605 acpi_ut_get_region_name (region_obj->region.space_id))); 599 acpi_ut_get_region_name(region_obj->region.
600 space_id)));
606 601
607 /* Link this region to the front of the handler's list */ 602 /* Link this region to the front of the handler's list */
608 603
@@ -612,16 +607,15 @@ acpi_ev_attach_region (
612 /* Install the region's handler */ 607 /* Install the region's handler */
613 608
614 if (region_obj->region.handler) { 609 if (region_obj->region.handler) {
615 return_ACPI_STATUS (AE_ALREADY_EXISTS); 610 return_ACPI_STATUS(AE_ALREADY_EXISTS);
616 } 611 }
617 612
618 region_obj->region.handler = handler_obj; 613 region_obj->region.handler = handler_obj;
619 acpi_ut_add_reference (handler_obj); 614 acpi_ut_add_reference(handler_obj);
620 615
621 return_ACPI_STATUS (AE_OK); 616 return_ACPI_STATUS(AE_OK);
622} 617}
623 618
624
625/******************************************************************************* 619/*******************************************************************************
626 * 620 *
627 * FUNCTION: acpi_ev_install_handler 621 * FUNCTION: acpi_ev_install_handler
@@ -640,23 +634,18 @@ acpi_ev_attach_region (
640 ******************************************************************************/ 634 ******************************************************************************/
641 635
642static acpi_status 636static acpi_status
643acpi_ev_install_handler ( 637acpi_ev_install_handler(acpi_handle obj_handle,
644 acpi_handle obj_handle, 638 u32 level, void *context, void **return_value)
645 u32 level,
646 void *context,
647 void **return_value)
648{ 639{
649 union acpi_operand_object *handler_obj; 640 union acpi_operand_object *handler_obj;
650 union acpi_operand_object *next_handler_obj; 641 union acpi_operand_object *next_handler_obj;
651 union acpi_operand_object *obj_desc; 642 union acpi_operand_object *obj_desc;
652 struct acpi_namespace_node *node; 643 struct acpi_namespace_node *node;
653 acpi_status status; 644 acpi_status status;
654 645
646 ACPI_FUNCTION_NAME("ev_install_handler");
655 647
656 ACPI_FUNCTION_NAME ("ev_install_handler"); 648 handler_obj = (union acpi_operand_object *)context;
657
658
659 handler_obj = (union acpi_operand_object *) context;
660 649
661 /* Parameter validation */ 650 /* Parameter validation */
662 651
@@ -666,7 +655,7 @@ acpi_ev_install_handler (
666 655
667 /* Convert and validate the device handle */ 656 /* Convert and validate the device handle */
668 657
669 node = acpi_ns_map_handle_to_node (obj_handle); 658 node = acpi_ns_map_handle_to_node(obj_handle);
670 if (!node) { 659 if (!node) {
671 return (AE_BAD_PARAMETER); 660 return (AE_BAD_PARAMETER);
672 } 661 }
@@ -676,14 +665,13 @@ acpi_ev_install_handler (
676 * that are allowed to have address space handlers 665 * that are allowed to have address space handlers
677 */ 666 */
678 if ((node->type != ACPI_TYPE_DEVICE) && 667 if ((node->type != ACPI_TYPE_DEVICE) &&
679 (node->type != ACPI_TYPE_REGION) && 668 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
680 (node != acpi_gbl_root_node)) {
681 return (AE_OK); 669 return (AE_OK);
682 } 670 }
683 671
684 /* Check for an existing internal object */ 672 /* Check for an existing internal object */
685 673
686 obj_desc = acpi_ns_get_attached_object (node); 674 obj_desc = acpi_ns_get_attached_object(node);
687 if (!obj_desc) { 675 if (!obj_desc) {
688 /* No object, just exit */ 676 /* No object, just exit */
689 677
@@ -692,18 +680,22 @@ acpi_ev_install_handler (
692 680
693 /* Devices are handled different than regions */ 681 /* Devices are handled different than regions */
694 682
695 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_DEVICE) { 683 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) {
696 /* Check if this Device already has a handler for this address space */ 684 /* Check if this Device already has a handler for this address space */
697 685
698 next_handler_obj = obj_desc->device.handler; 686 next_handler_obj = obj_desc->device.handler;
699 while (next_handler_obj) { 687 while (next_handler_obj) {
700 /* Found a handler, is it for the same address space? */ 688 /* Found a handler, is it for the same address space? */
701 689
702 if (next_handler_obj->address_space.space_id == handler_obj->address_space.space_id) { 690 if (next_handler_obj->address_space.space_id ==
703 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 691 handler_obj->address_space.space_id) {
704 "Found handler for region [%s] in device %p(%p) handler %p\n", 692 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
705 acpi_ut_get_region_name (handler_obj->address_space.space_id), 693 "Found handler for region [%s] in device %p(%p) handler %p\n",
706 obj_desc, next_handler_obj, handler_obj)); 694 acpi_ut_get_region_name
695 (handler_obj->address_space.
696 space_id), obj_desc,
697 next_handler_obj,
698 handler_obj));
707 699
708 /* 700 /*
709 * Since the object we found it on was a device, then it 701 * Since the object we found it on was a device, then it
@@ -744,15 +736,14 @@ acpi_ev_install_handler (
744 * 736 *
745 * First disconnect region for any previous handler (if any) 737 * First disconnect region for any previous handler (if any)
746 */ 738 */
747 acpi_ev_detach_region (obj_desc, FALSE); 739 acpi_ev_detach_region(obj_desc, FALSE);
748 740
749 /* Connect the region to the new handler */ 741 /* Connect the region to the new handler */
750 742
751 status = acpi_ev_attach_region (handler_obj, obj_desc, FALSE); 743 status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE);
752 return (status); 744 return (status);
753} 745}
754 746
755
756/******************************************************************************* 747/*******************************************************************************
757 * 748 *
758 * FUNCTION: acpi_ev_install_space_handler 749 * FUNCTION: acpi_ev_install_space_handler
@@ -771,32 +762,27 @@ acpi_ev_install_handler (
771 ******************************************************************************/ 762 ******************************************************************************/
772 763
773acpi_status 764acpi_status
774acpi_ev_install_space_handler ( 765acpi_ev_install_space_handler(struct acpi_namespace_node * node,
775 struct acpi_namespace_node *node, 766 acpi_adr_space_type space_id,
776 acpi_adr_space_type space_id, 767 acpi_adr_space_handler handler,
777 acpi_adr_space_handler handler, 768 acpi_adr_space_setup setup, void *context)
778 acpi_adr_space_setup setup,
779 void *context)
780{ 769{
781 union acpi_operand_object *obj_desc; 770 union acpi_operand_object *obj_desc;
782 union acpi_operand_object *handler_obj; 771 union acpi_operand_object *handler_obj;
783 acpi_status status; 772 acpi_status status;
784 acpi_object_type type; 773 acpi_object_type type;
785 u16 flags = 0; 774 u16 flags = 0;
786
787
788 ACPI_FUNCTION_TRACE ("ev_install_space_handler");
789 775
776 ACPI_FUNCTION_TRACE("ev_install_space_handler");
790 777
791 /* 778 /*
792 * This registration is valid for only the types below 779 * This registration is valid for only the types below
793 * and the root. This is where the default handlers 780 * and the root. This is where the default handlers
794 * get placed. 781 * get placed.
795 */ 782 */
796 if ((node->type != ACPI_TYPE_DEVICE) && 783 if ((node->type != ACPI_TYPE_DEVICE) &&
797 (node->type != ACPI_TYPE_PROCESSOR) && 784 (node->type != ACPI_TYPE_PROCESSOR) &&
798 (node->type != ACPI_TYPE_THERMAL) && 785 (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) {
799 (node != acpi_gbl_root_node)) {
800 status = AE_BAD_PARAMETER; 786 status = AE_BAD_PARAMETER;
801 goto unlock_and_exit; 787 goto unlock_and_exit;
802 } 788 }
@@ -807,32 +793,32 @@ acpi_ev_install_space_handler (
807 switch (space_id) { 793 switch (space_id) {
808 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 794 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
809 handler = acpi_ex_system_memory_space_handler; 795 handler = acpi_ex_system_memory_space_handler;
810 setup = acpi_ev_system_memory_region_setup; 796 setup = acpi_ev_system_memory_region_setup;
811 break; 797 break;
812 798
813 case ACPI_ADR_SPACE_SYSTEM_IO: 799 case ACPI_ADR_SPACE_SYSTEM_IO:
814 handler = acpi_ex_system_io_space_handler; 800 handler = acpi_ex_system_io_space_handler;
815 setup = acpi_ev_io_space_region_setup; 801 setup = acpi_ev_io_space_region_setup;
816 break; 802 break;
817 803
818 case ACPI_ADR_SPACE_PCI_CONFIG: 804 case ACPI_ADR_SPACE_PCI_CONFIG:
819 handler = acpi_ex_pci_config_space_handler; 805 handler = acpi_ex_pci_config_space_handler;
820 setup = acpi_ev_pci_config_region_setup; 806 setup = acpi_ev_pci_config_region_setup;
821 break; 807 break;
822 808
823 case ACPI_ADR_SPACE_CMOS: 809 case ACPI_ADR_SPACE_CMOS:
824 handler = acpi_ex_cmos_space_handler; 810 handler = acpi_ex_cmos_space_handler;
825 setup = acpi_ev_cmos_region_setup; 811 setup = acpi_ev_cmos_region_setup;
826 break; 812 break;
827 813
828 case ACPI_ADR_SPACE_PCI_BAR_TARGET: 814 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
829 handler = acpi_ex_pci_bar_space_handler; 815 handler = acpi_ex_pci_bar_space_handler;
830 setup = acpi_ev_pci_bar_region_setup; 816 setup = acpi_ev_pci_bar_region_setup;
831 break; 817 break;
832 818
833 case ACPI_ADR_SPACE_DATA_TABLE: 819 case ACPI_ADR_SPACE_DATA_TABLE:
834 handler = acpi_ex_data_table_space_handler; 820 handler = acpi_ex_data_table_space_handler;
835 setup = NULL; 821 setup = NULL;
836 break; 822 break;
837 823
838 default: 824 default:
@@ -849,7 +835,7 @@ acpi_ev_install_space_handler (
849 835
850 /* Check for an existing internal object */ 836 /* Check for an existing internal object */
851 837
852 obj_desc = acpi_ns_get_attached_object (node); 838 obj_desc = acpi_ns_get_attached_object(node);
853 if (obj_desc) { 839 if (obj_desc) {
854 /* 840 /*
855 * The attached device object already exists. 841 * The attached device object already exists.
@@ -863,7 +849,8 @@ acpi_ev_install_space_handler (
863 /* Same space_id indicates a handler already installed */ 849 /* Same space_id indicates a handler already installed */
864 850
865 if (handler_obj->address_space.space_id == space_id) { 851 if (handler_obj->address_space.space_id == space_id) {
866 if (handler_obj->address_space.handler == handler) { 852 if (handler_obj->address_space.handler ==
853 handler) {
867 /* 854 /*
868 * It is (relatively) OK to attempt to install the SAME 855 * It is (relatively) OK to attempt to install the SAME
869 * handler twice. This can easily happen 856 * handler twice. This can easily happen
@@ -871,8 +858,7 @@ acpi_ev_install_space_handler (
871 */ 858 */
872 status = AE_SAME_HANDLER; 859 status = AE_SAME_HANDLER;
873 goto unlock_and_exit; 860 goto unlock_and_exit;
874 } 861 } else {
875 else {
876 /* A handler is already installed */ 862 /* A handler is already installed */
877 863
878 status = AE_ALREADY_EXISTS; 864 status = AE_ALREADY_EXISTS;
@@ -884,21 +870,20 @@ acpi_ev_install_space_handler (
884 870
885 handler_obj = handler_obj->address_space.next; 871 handler_obj = handler_obj->address_space.next;
886 } 872 }
887 } 873 } else {
888 else { 874 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
889 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 875 "Creating object on Device %p while installing handler\n",
890 "Creating object on Device %p while installing handler\n", node)); 876 node));
891 877
892 /* obj_desc does not exist, create one */ 878 /* obj_desc does not exist, create one */
893 879
894 if (node->type == ACPI_TYPE_ANY) { 880 if (node->type == ACPI_TYPE_ANY) {
895 type = ACPI_TYPE_DEVICE; 881 type = ACPI_TYPE_DEVICE;
896 } 882 } else {
897 else {
898 type = node->type; 883 type = node->type;
899 } 884 }
900 885
901 obj_desc = acpi_ut_create_internal_object (type); 886 obj_desc = acpi_ut_create_internal_object(type);
902 if (!obj_desc) { 887 if (!obj_desc) {
903 status = AE_NO_MEMORY; 888 status = AE_NO_MEMORY;
904 goto unlock_and_exit; 889 goto unlock_and_exit;
@@ -910,21 +895,21 @@ acpi_ev_install_space_handler (
910 895
911 /* Attach the new object to the Node */ 896 /* Attach the new object to the Node */
912 897
913 status = acpi_ns_attach_object (node, obj_desc, type); 898 status = acpi_ns_attach_object(node, obj_desc, type);
914 899
915 /* Remove local reference to the object */ 900 /* Remove local reference to the object */
916 901
917 acpi_ut_remove_reference (obj_desc); 902 acpi_ut_remove_reference(obj_desc);
918 903
919 if (ACPI_FAILURE (status)) { 904 if (ACPI_FAILURE(status)) {
920 goto unlock_and_exit; 905 goto unlock_and_exit;
921 } 906 }
922 } 907 }
923 908
924 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 909 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
925 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", 910 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
926 acpi_ut_get_region_name (space_id), space_id, 911 acpi_ut_get_region_name(space_id), space_id,
927 acpi_ut_get_node_name (node), node, obj_desc)); 912 acpi_ut_get_node_name(node), node, obj_desc));
928 913
929 /* 914 /*
930 * Install the handler 915 * Install the handler
@@ -933,7 +918,8 @@ acpi_ev_install_space_handler (
933 * Just allocate the object for the handler and link it 918 * Just allocate the object for the handler and link it
934 * into the list. 919 * into the list.
935 */ 920 */
936 handler_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); 921 handler_obj =
922 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
937 if (!handler_obj) { 923 if (!handler_obj) {
938 status = AE_NO_MEMORY; 924 status = AE_NO_MEMORY;
939 goto unlock_and_exit; 925 goto unlock_and_exit;
@@ -941,17 +927,17 @@ acpi_ev_install_space_handler (
941 927
942 /* Init handler obj */ 928 /* Init handler obj */
943 929
944 handler_obj->address_space.space_id = (u8) space_id; 930 handler_obj->address_space.space_id = (u8) space_id;
945 handler_obj->address_space.hflags = flags; 931 handler_obj->address_space.hflags = flags;
946 handler_obj->address_space.region_list = NULL; 932 handler_obj->address_space.region_list = NULL;
947 handler_obj->address_space.node = node; 933 handler_obj->address_space.node = node;
948 handler_obj->address_space.handler = handler; 934 handler_obj->address_space.handler = handler;
949 handler_obj->address_space.context = context; 935 handler_obj->address_space.context = context;
950 handler_obj->address_space.setup = setup; 936 handler_obj->address_space.setup = setup;
951 937
952 /* Install at head of Device.address_space list */ 938 /* Install at head of Device.address_space list */
953 939
954 handler_obj->address_space.next = obj_desc->device.handler; 940 handler_obj->address_space.next = obj_desc->device.handler;
955 941
956 /* 942 /*
957 * The Device object is the first reference on the handler_obj. 943 * The Device object is the first reference on the handler_obj.
@@ -971,15 +957,15 @@ acpi_ev_install_space_handler (
971 * In either case, back up and search down the remainder 957 * In either case, back up and search down the remainder
972 * of the branch 958 * of the branch
973 */ 959 */
974 status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, 960 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
975 ACPI_NS_WALK_UNLOCK, acpi_ev_install_handler, 961 ACPI_NS_WALK_UNLOCK,
976 handler_obj, NULL); 962 acpi_ev_install_handler, handler_obj,
963 NULL);
977 964
978unlock_and_exit: 965 unlock_and_exit:
979 return_ACPI_STATUS (status); 966 return_ACPI_STATUS(status);
980} 967}
981 968
982
983/******************************************************************************* 969/*******************************************************************************
984 * 970 *
985 * FUNCTION: acpi_ev_execute_reg_methods 971 * FUNCTION: acpi_ev_execute_reg_methods
@@ -995,15 +981,12 @@ unlock_and_exit:
995 ******************************************************************************/ 981 ******************************************************************************/
996 982
997acpi_status 983acpi_status
998acpi_ev_execute_reg_methods ( 984acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
999 struct acpi_namespace_node *node, 985 acpi_adr_space_type space_id)
1000 acpi_adr_space_type space_id)
1001{ 986{
1002 acpi_status status; 987 acpi_status status;
1003
1004
1005 ACPI_FUNCTION_TRACE ("ev_execute_reg_methods");
1006 988
989 ACPI_FUNCTION_TRACE("ev_execute_reg_methods");
1007 990
1008 /* 991 /*
1009 * Run all _REG methods for all Operation Regions for this 992 * Run all _REG methods for all Operation Regions for this
@@ -1012,14 +995,13 @@ acpi_ev_execute_reg_methods (
1012 * must be installed for all regions of this Space ID before we 995 * must be installed for all regions of this Space ID before we
1013 * can run any _REG methods) 996 * can run any _REG methods)
1014 */ 997 */
1015 status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, 998 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
1016 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, 999 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
1017 &space_id, NULL); 1000 &space_id, NULL);
1018 1001
1019 return_ACPI_STATUS (status); 1002 return_ACPI_STATUS(status);
1020} 1003}
1021 1004
1022
1023/******************************************************************************* 1005/*******************************************************************************
1024 * 1006 *
1025 * FUNCTION: acpi_ev_reg_run 1007 * FUNCTION: acpi_ev_reg_run
@@ -1031,23 +1013,19 @@ acpi_ev_execute_reg_methods (
1031 ******************************************************************************/ 1013 ******************************************************************************/
1032 1014
1033static acpi_status 1015static acpi_status
1034acpi_ev_reg_run ( 1016acpi_ev_reg_run(acpi_handle obj_handle,
1035 acpi_handle obj_handle, 1017 u32 level, void *context, void **return_value)
1036 u32 level,
1037 void *context,
1038 void **return_value)
1039{ 1018{
1040 union acpi_operand_object *obj_desc; 1019 union acpi_operand_object *obj_desc;
1041 struct acpi_namespace_node *node; 1020 struct acpi_namespace_node *node;
1042 acpi_adr_space_type space_id; 1021 acpi_adr_space_type space_id;
1043 acpi_status status; 1022 acpi_status status;
1044 1023
1045 1024 space_id = *ACPI_CAST_PTR(acpi_adr_space_type, context);
1046 space_id = *ACPI_CAST_PTR (acpi_adr_space_type, context);
1047 1025
1048 /* Convert and validate the device handle */ 1026 /* Convert and validate the device handle */
1049 1027
1050 node = acpi_ns_map_handle_to_node (obj_handle); 1028 node = acpi_ns_map_handle_to_node(obj_handle);
1051 if (!node) { 1029 if (!node) {
1052 return (AE_BAD_PARAMETER); 1030 return (AE_BAD_PARAMETER);
1053 } 1031 }
@@ -1056,14 +1034,13 @@ acpi_ev_reg_run (
1056 * We only care about regions.and objects 1034 * We only care about regions.and objects
1057 * that are allowed to have address space handlers 1035 * that are allowed to have address space handlers
1058 */ 1036 */
1059 if ((node->type != ACPI_TYPE_REGION) && 1037 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
1060 (node != acpi_gbl_root_node)) {
1061 return (AE_OK); 1038 return (AE_OK);
1062 } 1039 }
1063 1040
1064 /* Check for an existing internal object */ 1041 /* Check for an existing internal object */
1065 1042
1066 obj_desc = acpi_ns_get_attached_object (node); 1043 obj_desc = acpi_ns_get_attached_object(node);
1067 if (!obj_desc) { 1044 if (!obj_desc) {
1068 /* No object, just exit */ 1045 /* No object, just exit */
1069 1046
@@ -1080,7 +1057,6 @@ acpi_ev_reg_run (
1080 return (AE_OK); 1057 return (AE_OK);
1081 } 1058 }
1082 1059
1083 status = acpi_ev_execute_reg_method (obj_desc, 1); 1060 status = acpi_ev_execute_reg_method(obj_desc, 1);
1084 return (status); 1061 return (status);
1085} 1062}
1086
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index f2d53af97610..a1bd2da27c45 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -41,14 +41,12 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acevents.h> 45#include <acpi/acevents.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evrgnini") 49ACPI_MODULE_NAME("evrgnini")
51
52 50
53/******************************************************************************* 51/*******************************************************************************
54 * 52 *
@@ -64,34 +62,31 @@
64 * DESCRIPTION: Setup a system_memory operation region 62 * DESCRIPTION: Setup a system_memory operation region
65 * 63 *
66 ******************************************************************************/ 64 ******************************************************************************/
67
68acpi_status 65acpi_status
69acpi_ev_system_memory_region_setup ( 66acpi_ev_system_memory_region_setup(acpi_handle handle,
70 acpi_handle handle, 67 u32 function,
71 u32 function, 68 void *handler_context, void **region_context)
72 void *handler_context,
73 void **region_context)
74{ 69{
75 union acpi_operand_object *region_desc = (union acpi_operand_object *) handle; 70 union acpi_operand_object *region_desc =
76 struct acpi_mem_space_context *local_region_context; 71 (union acpi_operand_object *)handle;
77 72 struct acpi_mem_space_context *local_region_context;
78
79 ACPI_FUNCTION_TRACE ("ev_system_memory_region_setup");
80 73
74 ACPI_FUNCTION_TRACE("ev_system_memory_region_setup");
81 75
82 if (function == ACPI_REGION_DEACTIVATE) { 76 if (function == ACPI_REGION_DEACTIVATE) {
83 if (*region_context) { 77 if (*region_context) {
84 ACPI_MEM_FREE (*region_context); 78 ACPI_MEM_FREE(*region_context);
85 *region_context = NULL; 79 *region_context = NULL;
86 } 80 }
87 return_ACPI_STATUS (AE_OK); 81 return_ACPI_STATUS(AE_OK);
88 } 82 }
89 83
90 /* Create a new context */ 84 /* Create a new context */
91 85
92 local_region_context = ACPI_MEM_CALLOCATE (sizeof (struct acpi_mem_space_context)); 86 local_region_context =
87 ACPI_MEM_CALLOCATE(sizeof(struct acpi_mem_space_context));
93 if (!(local_region_context)) { 88 if (!(local_region_context)) {
94 return_ACPI_STATUS (AE_NO_MEMORY); 89 return_ACPI_STATUS(AE_NO_MEMORY);
95 } 90 }
96 91
97 /* Save the region length and address for use in the handler */ 92 /* Save the region length and address for use in the handler */
@@ -100,10 +95,9 @@ acpi_ev_system_memory_region_setup (
100 local_region_context->address = region_desc->region.address; 95 local_region_context->address = region_desc->region.address;
101 96
102 *region_context = local_region_context; 97 *region_context = local_region_context;
103 return_ACPI_STATUS (AE_OK); 98 return_ACPI_STATUS(AE_OK);
104} 99}
105 100
106
107/******************************************************************************* 101/*******************************************************************************
108 * 102 *
109 * FUNCTION: acpi_ev_io_space_region_setup 103 * FUNCTION: acpi_ev_io_space_region_setup
@@ -120,26 +114,21 @@ acpi_ev_system_memory_region_setup (
120 ******************************************************************************/ 114 ******************************************************************************/
121 115
122acpi_status 116acpi_status
123acpi_ev_io_space_region_setup ( 117acpi_ev_io_space_region_setup(acpi_handle handle,
124 acpi_handle handle, 118 u32 function,
125 u32 function, 119 void *handler_context, void **region_context)
126 void *handler_context,
127 void **region_context)
128{ 120{
129 ACPI_FUNCTION_TRACE ("ev_io_space_region_setup"); 121 ACPI_FUNCTION_TRACE("ev_io_space_region_setup");
130
131 122
132 if (function == ACPI_REGION_DEACTIVATE) { 123 if (function == ACPI_REGION_DEACTIVATE) {
133 *region_context = NULL; 124 *region_context = NULL;
134 } 125 } else {
135 else {
136 *region_context = handler_context; 126 *region_context = handler_context;
137 } 127 }
138 128
139 return_ACPI_STATUS (AE_OK); 129 return_ACPI_STATUS(AE_OK);
140} 130}
141 131
142
143/******************************************************************************* 132/*******************************************************************************
144 * 133 *
145 * FUNCTION: acpi_ev_pci_config_region_setup 134 * FUNCTION: acpi_ev_pci_config_region_setup
@@ -158,24 +147,21 @@ acpi_ev_io_space_region_setup (
158 ******************************************************************************/ 147 ******************************************************************************/
159 148
160acpi_status 149acpi_status
161acpi_ev_pci_config_region_setup ( 150acpi_ev_pci_config_region_setup(acpi_handle handle,
162 acpi_handle handle, 151 u32 function,
163 u32 function, 152 void *handler_context, void **region_context)
164 void *handler_context,
165 void **region_context)
166{ 153{
167 acpi_status status = AE_OK; 154 acpi_status status = AE_OK;
168 acpi_integer pci_value; 155 acpi_integer pci_value;
169 struct acpi_pci_id *pci_id = *region_context; 156 struct acpi_pci_id *pci_id = *region_context;
170 union acpi_operand_object *handler_obj; 157 union acpi_operand_object *handler_obj;
171 struct acpi_namespace_node *parent_node; 158 struct acpi_namespace_node *parent_node;
172 struct acpi_namespace_node *pci_root_node; 159 struct acpi_namespace_node *pci_root_node;
173 union acpi_operand_object *region_obj = (union acpi_operand_object *) handle; 160 union acpi_operand_object *region_obj =
174 struct acpi_device_id object_hID; 161 (union acpi_operand_object *)handle;
175 162 struct acpi_device_id object_hID;
176 163
177 ACPI_FUNCTION_TRACE ("ev_pci_config_region_setup"); 164 ACPI_FUNCTION_TRACE("ev_pci_config_region_setup");
178
179 165
180 handler_obj = region_obj->region.handler; 166 handler_obj = region_obj->region.handler;
181 if (!handler_obj) { 167 if (!handler_obj) {
@@ -183,20 +169,21 @@ acpi_ev_pci_config_region_setup (
183 * No installed handler. This shouldn't happen because the dispatch 169 * No installed handler. This shouldn't happen because the dispatch
184 * routine checks before we get here, but we check again just in case. 170 * routine checks before we get here, but we check again just in case.
185 */ 171 */
186 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 172 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
187 "Attempting to init a region %p, with no handler\n", region_obj)); 173 "Attempting to init a region %p, with no handler\n",
188 return_ACPI_STATUS (AE_NOT_EXIST); 174 region_obj));
175 return_ACPI_STATUS(AE_NOT_EXIST);
189 } 176 }
190 177
191 *region_context = NULL; 178 *region_context = NULL;
192 if (function == ACPI_REGION_DEACTIVATE) { 179 if (function == ACPI_REGION_DEACTIVATE) {
193 if (pci_id) { 180 if (pci_id) {
194 ACPI_MEM_FREE (pci_id); 181 ACPI_MEM_FREE(pci_id);
195 } 182 }
196 return_ACPI_STATUS (status); 183 return_ACPI_STATUS(status);
197 } 184 }
198 185
199 parent_node = acpi_ns_get_parent_node (region_obj->region.node); 186 parent_node = acpi_ns_get_parent_node(region_obj->region.node);
200 187
201 /* 188 /*
202 * Get the _SEG and _BBN values from the device upon which the handler 189 * Get the _SEG and _BBN values from the device upon which the handler
@@ -216,22 +203,28 @@ acpi_ev_pci_config_region_setup (
216 203
217 pci_root_node = parent_node; 204 pci_root_node = parent_node;
218 while (pci_root_node != acpi_gbl_root_node) { 205 while (pci_root_node != acpi_gbl_root_node) {
219 status = acpi_ut_execute_HID (pci_root_node, &object_hID); 206 status =
220 if (ACPI_SUCCESS (status)) { 207 acpi_ut_execute_HID(pci_root_node, &object_hID);
208 if (ACPI_SUCCESS(status)) {
221 /* 209 /*
222 * Got a valid _HID string, check if this is a PCI root. 210 * Got a valid _HID string, check if this is a PCI root.
223 * New for ACPI 3.0: check for a PCI Express root also. 211 * New for ACPI 3.0: check for a PCI Express root also.
224 */ 212 */
225 if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING, 213 if (!
226 sizeof (PCI_ROOT_HID_STRING)) || 214 (ACPI_STRNCMP
227 !(ACPI_STRNCMP (object_hID.value, PCI_EXPRESS_ROOT_HID_STRING, 215 (object_hID.value, PCI_ROOT_HID_STRING,
228 sizeof (PCI_EXPRESS_ROOT_HID_STRING))))) { 216 sizeof(PCI_ROOT_HID_STRING))
217 ||
218 !(ACPI_STRNCMP
219 (object_hID.value,
220 PCI_EXPRESS_ROOT_HID_STRING,
221 sizeof(PCI_EXPRESS_ROOT_HID_STRING)))))
222 {
229 /* Install a handler for this PCI root bridge */ 223 /* Install a handler for this PCI root bridge */
230 224
231 status = acpi_install_address_space_handler ((acpi_handle) pci_root_node, 225 status =
232 ACPI_ADR_SPACE_PCI_CONFIG, 226 acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL);
233 ACPI_DEFAULT_HANDLER, NULL, NULL); 227 if (ACPI_FAILURE(status)) {
234 if (ACPI_FAILURE (status)) {
235 if (status == AE_SAME_HANDLER) { 228 if (status == AE_SAME_HANDLER) {
236 /* 229 /*
237 * It is OK if the handler is already installed on the root 230 * It is OK if the handler is already installed on the root
@@ -239,23 +232,19 @@ acpi_ev_pci_config_region_setup (
239 * new PCI_Config operation region, however. 232 * new PCI_Config operation region, however.
240 */ 233 */
241 status = AE_OK; 234 status = AE_OK;
242 } 235 } else {
243 else { 236 ACPI_REPORT_ERROR(("Could not install pci_config handler for Root Bridge %4.4s, %s\n", acpi_ut_get_node_name(pci_root_node), acpi_format_exception(status)));
244 ACPI_REPORT_ERROR ((
245 "Could not install pci_config handler for Root Bridge %4.4s, %s\n",
246 acpi_ut_get_node_name (pci_root_node), acpi_format_exception (status)));
247 } 237 }
248 } 238 }
249 break; 239 break;
250 } 240 }
251 } 241 }
252 242
253 pci_root_node = acpi_ns_get_parent_node (pci_root_node); 243 pci_root_node = acpi_ns_get_parent_node(pci_root_node);
254 } 244 }
255 245
256 /* PCI root bridge not found, use namespace root node */ 246 /* PCI root bridge not found, use namespace root node */
257 } 247 } else {
258 else {
259 pci_root_node = handler_obj->address_space.node; 248 pci_root_node = handler_obj->address_space.node;
260 } 249 }
261 250
@@ -264,14 +253,14 @@ acpi_ev_pci_config_region_setup (
264 * (install_address_space_handler could have initialized it) 253 * (install_address_space_handler could have initialized it)
265 */ 254 */
266 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { 255 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
267 return_ACPI_STATUS (AE_OK); 256 return_ACPI_STATUS(AE_OK);
268 } 257 }
269 258
270 /* Region is still not initialized. Create a new context */ 259 /* Region is still not initialized. Create a new context */
271 260
272 pci_id = ACPI_MEM_CALLOCATE (sizeof (struct acpi_pci_id)); 261 pci_id = ACPI_MEM_CALLOCATE(sizeof(struct acpi_pci_id));
273 if (!pci_id) { 262 if (!pci_id) {
274 return_ACPI_STATUS (AE_NO_MEMORY); 263 return_ACPI_STATUS(AE_NO_MEMORY);
275 } 264 }
276 265
277 /* 266 /*
@@ -283,40 +272,45 @@ acpi_ev_pci_config_region_setup (
283 * Get the PCI device and function numbers from the _ADR object 272 * Get the PCI device and function numbers from the _ADR object
284 * contained in the parent's scope. 273 * contained in the parent's scope.
285 */ 274 */
286 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, parent_node, &pci_value); 275 status =
276 acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, parent_node,
277 &pci_value);
287 278
288 /* 279 /*
289 * The default is zero, and since the allocation above zeroed 280 * The default is zero, and since the allocation above zeroed
290 * the data, just do nothing on failure. 281 * the data, just do nothing on failure.
291 */ 282 */
292 if (ACPI_SUCCESS (status)) { 283 if (ACPI_SUCCESS(status)) {
293 pci_id->device = ACPI_HIWORD (ACPI_LODWORD (pci_value)); 284 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value));
294 pci_id->function = ACPI_LOWORD (ACPI_LODWORD (pci_value)); 285 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value));
295 } 286 }
296 287
297 /* The PCI segment number comes from the _SEG method */ 288 /* The PCI segment number comes from the _SEG method */
298 289
299 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__SEG, pci_root_node, &pci_value); 290 status =
300 if (ACPI_SUCCESS (status)) { 291 acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node,
301 pci_id->segment = ACPI_LOWORD (pci_value); 292 &pci_value);
293 if (ACPI_SUCCESS(status)) {
294 pci_id->segment = ACPI_LOWORD(pci_value);
302 } 295 }
303 296
304 /* The PCI bus number comes from the _BBN method */ 297 /* The PCI bus number comes from the _BBN method */
305 298
306 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__BBN, pci_root_node, &pci_value); 299 status =
307 if (ACPI_SUCCESS (status)) { 300 acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node,
308 pci_id->bus = ACPI_LOWORD (pci_value); 301 &pci_value);
302 if (ACPI_SUCCESS(status)) {
303 pci_id->bus = ACPI_LOWORD(pci_value);
309 } 304 }
310 305
311 /* Complete this device's pci_id */ 306 /* Complete this device's pci_id */
312 307
313 acpi_os_derive_pci_id (pci_root_node, region_obj->region.node, &pci_id); 308 acpi_os_derive_pci_id(pci_root_node, region_obj->region.node, &pci_id);
314 309
315 *region_context = pci_id; 310 *region_context = pci_id;
316 return_ACPI_STATUS (AE_OK); 311 return_ACPI_STATUS(AE_OK);
317} 312}
318 313
319
320/******************************************************************************* 314/*******************************************************************************
321 * 315 *
322 * FUNCTION: acpi_ev_pci_bar_region_setup 316 * FUNCTION: acpi_ev_pci_bar_region_setup
@@ -335,19 +329,15 @@ acpi_ev_pci_config_region_setup (
335 ******************************************************************************/ 329 ******************************************************************************/
336 330
337acpi_status 331acpi_status
338acpi_ev_pci_bar_region_setup ( 332acpi_ev_pci_bar_region_setup(acpi_handle handle,
339 acpi_handle handle, 333 u32 function,
340 u32 function, 334 void *handler_context, void **region_context)
341 void *handler_context,
342 void **region_context)
343{ 335{
344 ACPI_FUNCTION_TRACE ("ev_pci_bar_region_setup"); 336 ACPI_FUNCTION_TRACE("ev_pci_bar_region_setup");
345
346 337
347 return_ACPI_STATUS (AE_OK); 338 return_ACPI_STATUS(AE_OK);
348} 339}
349 340
350
351/******************************************************************************* 341/*******************************************************************************
352 * 342 *
353 * FUNCTION: acpi_ev_cmos_region_setup 343 * FUNCTION: acpi_ev_cmos_region_setup
@@ -366,19 +356,15 @@ acpi_ev_pci_bar_region_setup (
366 ******************************************************************************/ 356 ******************************************************************************/
367 357
368acpi_status 358acpi_status
369acpi_ev_cmos_region_setup ( 359acpi_ev_cmos_region_setup(acpi_handle handle,
370 acpi_handle handle, 360 u32 function,
371 u32 function, 361 void *handler_context, void **region_context)
372 void *handler_context,
373 void **region_context)
374{ 362{
375 ACPI_FUNCTION_TRACE ("ev_cmos_region_setup"); 363 ACPI_FUNCTION_TRACE("ev_cmos_region_setup");
376
377 364
378 return_ACPI_STATUS (AE_OK); 365 return_ACPI_STATUS(AE_OK);
379} 366}
380 367
381
382/******************************************************************************* 368/*******************************************************************************
383 * 369 *
384 * FUNCTION: acpi_ev_default_region_setup 370 * FUNCTION: acpi_ev_default_region_setup
@@ -395,26 +381,21 @@ acpi_ev_cmos_region_setup (
395 ******************************************************************************/ 381 ******************************************************************************/
396 382
397acpi_status 383acpi_status
398acpi_ev_default_region_setup ( 384acpi_ev_default_region_setup(acpi_handle handle,
399 acpi_handle handle, 385 u32 function,
400 u32 function, 386 void *handler_context, void **region_context)
401 void *handler_context,
402 void **region_context)
403{ 387{
404 ACPI_FUNCTION_TRACE ("ev_default_region_setup"); 388 ACPI_FUNCTION_TRACE("ev_default_region_setup");
405
406 389
407 if (function == ACPI_REGION_DEACTIVATE) { 390 if (function == ACPI_REGION_DEACTIVATE) {
408 *region_context = NULL; 391 *region_context = NULL;
409 } 392 } else {
410 else {
411 *region_context = handler_context; 393 *region_context = handler_context;
412 } 394 }
413 395
414 return_ACPI_STATUS (AE_OK); 396 return_ACPI_STATUS(AE_OK);
415} 397}
416 398
417
418/******************************************************************************* 399/*******************************************************************************
419 * 400 *
420 * FUNCTION: acpi_ev_initialize_region 401 * FUNCTION: acpi_ev_initialize_region
@@ -438,37 +419,34 @@ acpi_ev_default_region_setup (
438 ******************************************************************************/ 419 ******************************************************************************/
439 420
440acpi_status 421acpi_status
441acpi_ev_initialize_region ( 422acpi_ev_initialize_region(union acpi_operand_object *region_obj,
442 union acpi_operand_object *region_obj, 423 u8 acpi_ns_locked)
443 u8 acpi_ns_locked)
444{ 424{
445 union acpi_operand_object *handler_obj; 425 union acpi_operand_object *handler_obj;
446 union acpi_operand_object *obj_desc; 426 union acpi_operand_object *obj_desc;
447 acpi_adr_space_type space_id; 427 acpi_adr_space_type space_id;
448 struct acpi_namespace_node *node; 428 struct acpi_namespace_node *node;
449 acpi_status status; 429 acpi_status status;
450 struct acpi_namespace_node *method_node; 430 struct acpi_namespace_node *method_node;
451 acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG; 431 acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
452 union acpi_operand_object *region_obj2; 432 union acpi_operand_object *region_obj2;
453
454
455 ACPI_FUNCTION_TRACE_U32 ("ev_initialize_region", acpi_ns_locked);
456 433
434 ACPI_FUNCTION_TRACE_U32("ev_initialize_region", acpi_ns_locked);
457 435
458 if (!region_obj) { 436 if (!region_obj) {
459 return_ACPI_STATUS (AE_BAD_PARAMETER); 437 return_ACPI_STATUS(AE_BAD_PARAMETER);
460 } 438 }
461 439
462 if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) { 440 if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) {
463 return_ACPI_STATUS (AE_OK); 441 return_ACPI_STATUS(AE_OK);
464 } 442 }
465 443
466 region_obj2 = acpi_ns_get_secondary_object (region_obj); 444 region_obj2 = acpi_ns_get_secondary_object(region_obj);
467 if (!region_obj2) { 445 if (!region_obj2) {
468 return_ACPI_STATUS (AE_NOT_EXIST); 446 return_ACPI_STATUS(AE_NOT_EXIST);
469 } 447 }
470 448
471 node = acpi_ns_get_parent_node (region_obj->region.node); 449 node = acpi_ns_get_parent_node(region_obj->region.node);
472 space_id = region_obj->region.space_id; 450 space_id = region_obj->region.space_id;
473 451
474 /* Setup defaults */ 452 /* Setup defaults */
@@ -480,9 +458,9 @@ acpi_ev_initialize_region (
480 458
481 /* Find any "_REG" method associated with this region definition */ 459 /* Find any "_REG" method associated with this region definition */
482 460
483 status = acpi_ns_search_node (*reg_name_ptr, node, 461 status = acpi_ns_search_node(*reg_name_ptr, node,
484 ACPI_TYPE_METHOD, &method_node); 462 ACPI_TYPE_METHOD, &method_node);
485 if (ACPI_SUCCESS (status)) { 463 if (ACPI_SUCCESS(status)) {
486 /* 464 /*
487 * The _REG method is optional and there can be only one per region 465 * The _REG method is optional and there can be only one per region
488 * definition. This will be executed when the handler is attached 466 * definition. This will be executed when the handler is attached
@@ -499,7 +477,7 @@ acpi_ev_initialize_region (
499 /* Check to see if a handler exists */ 477 /* Check to see if a handler exists */
500 478
501 handler_obj = NULL; 479 handler_obj = NULL;
502 obj_desc = acpi_ns_get_attached_object (node); 480 obj_desc = acpi_ns_get_attached_object(node);
503 if (obj_desc) { 481 if (obj_desc) {
504 /* Can only be a handler if the object exists */ 482 /* Can only be a handler if the object exists */
505 483
@@ -527,37 +505,50 @@ acpi_ev_initialize_region (
527 while (handler_obj) { 505 while (handler_obj) {
528 /* Is this handler of the correct type? */ 506 /* Is this handler of the correct type? */
529 507
530 if (handler_obj->address_space.space_id == space_id) { 508 if (handler_obj->address_space.space_id ==
509 space_id) {
531 /* Found correct handler */ 510 /* Found correct handler */
532 511
533 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 512 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
534 "Found handler %p for region %p in obj %p\n", 513 "Found handler %p for region %p in obj %p\n",
535 handler_obj, region_obj, obj_desc)); 514 handler_obj,
515 region_obj,
516 obj_desc));
536 517
537 status = acpi_ev_attach_region (handler_obj, region_obj, 518 status =
538 acpi_ns_locked); 519 acpi_ev_attach_region(handler_obj,
520 region_obj,
521 acpi_ns_locked);
539 522
540 /* 523 /*
541 * Tell all users that this region is usable by running the _REG 524 * Tell all users that this region is usable by running the _REG
542 * method 525 * method
543 */ 526 */
544 if (acpi_ns_locked) { 527 if (acpi_ns_locked) {
545 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 528 status =
546 if (ACPI_FAILURE (status)) { 529 acpi_ut_release_mutex
547 return_ACPI_STATUS (status); 530 (ACPI_MTX_NAMESPACE);
531 if (ACPI_FAILURE(status)) {
532 return_ACPI_STATUS
533 (status);
548 } 534 }
549 } 535 }
550 536
551 status = acpi_ev_execute_reg_method (region_obj, 1); 537 status =
538 acpi_ev_execute_reg_method
539 (region_obj, 1);
552 540
553 if (acpi_ns_locked) { 541 if (acpi_ns_locked) {
554 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 542 status =
555 if (ACPI_FAILURE (status)) { 543 acpi_ut_acquire_mutex
556 return_ACPI_STATUS (status); 544 (ACPI_MTX_NAMESPACE);
545 if (ACPI_FAILURE(status)) {
546 return_ACPI_STATUS
547 (status);
557 } 548 }
558 } 549 }
559 550
560 return_ACPI_STATUS (AE_OK); 551 return_ACPI_STATUS(AE_OK);
561 } 552 }
562 553
563 /* Try next handler in the list */ 554 /* Try next handler in the list */
@@ -570,15 +561,15 @@ acpi_ev_initialize_region (
570 * This node does not have the handler we need; 561 * This node does not have the handler we need;
571 * Pop up one level 562 * Pop up one level
572 */ 563 */
573 node = acpi_ns_get_parent_node (node); 564 node = acpi_ns_get_parent_node(node);
574 } 565 }
575 566
576 /* If we get here, there is no handler for this region */ 567 /* If we get here, there is no handler for this region */
577 568
578 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 569 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
579 "No handler for region_type %s(%X) (region_obj %p)\n", 570 "No handler for region_type %s(%X) (region_obj %p)\n",
580 acpi_ut_get_region_name (space_id), space_id, region_obj)); 571 acpi_ut_get_region_name(space_id), space_id,
572 region_obj));
581 573
582 return_ACPI_STATUS (AE_NOT_EXIST); 574 return_ACPI_STATUS(AE_NOT_EXIST);
583} 575}
584
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c
index f3123c26ae98..141835977002 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/events/evsci.c
@@ -45,16 +45,11 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acevents.h> 46#include <acpi/acevents.h>
47 47
48
49#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evsci") 49ACPI_MODULE_NAME("evsci")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53 52static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context);
54static u32 ACPI_SYSTEM_XFACE
55acpi_ev_sci_xrupt_handler (
56 void *context);
57
58 53
59/******************************************************************************* 54/*******************************************************************************
60 * 55 *
@@ -69,17 +64,13 @@ acpi_ev_sci_xrupt_handler (
69 * 64 *
70 ******************************************************************************/ 65 ******************************************************************************/
71 66
72static u32 ACPI_SYSTEM_XFACE 67static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
73acpi_ev_sci_xrupt_handler (
74 void *context)
75{ 68{
76 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; 69 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
77 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; 70 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
78
79 71
80 ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler"); 72 ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler");
81 73
82
83 /* 74 /*
84 * We are guaranteed by the ACPI CA initialization/shutdown code that 75 * We are guaranteed by the ACPI CA initialization/shutdown code that
85 * if this interrupt handler is installed, ACPI is enabled. 76 * if this interrupt handler is installed, ACPI is enabled.
@@ -89,18 +80,17 @@ acpi_ev_sci_xrupt_handler (
89 * Fixed Events: 80 * Fixed Events:
90 * Check for and dispatch any Fixed Events that have occurred 81 * Check for and dispatch any Fixed Events that have occurred
91 */ 82 */
92 interrupt_handled |= acpi_ev_fixed_event_detect (); 83 interrupt_handled |= acpi_ev_fixed_event_detect();
93 84
94 /* 85 /*
95 * General Purpose Events: 86 * General Purpose Events:
96 * Check for and dispatch any GPEs that have occurred 87 * Check for and dispatch any GPEs that have occurred
97 */ 88 */
98 interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list); 89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
99 90
100 return_VALUE (interrupt_handled); 91 return_VALUE(interrupt_handled);
101} 92}
102 93
103
104/******************************************************************************* 94/*******************************************************************************
105 * 95 *
106 * FUNCTION: acpi_ev_gpe_xrupt_handler 96 * FUNCTION: acpi_ev_gpe_xrupt_handler
@@ -113,17 +103,13 @@ acpi_ev_sci_xrupt_handler (
113 * 103 *
114 ******************************************************************************/ 104 ******************************************************************************/
115 105
116u32 ACPI_SYSTEM_XFACE 106u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
117acpi_ev_gpe_xrupt_handler (
118 void *context)
119{ 107{
120 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; 108 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
121 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; 109 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
122
123 110
124 ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler"); 111 ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler");
125 112
126
127 /* 113 /*
128 * We are guaranteed by the ACPI CA initialization/shutdown code that 114 * We are guaranteed by the ACPI CA initialization/shutdown code that
129 * if this interrupt handler is installed, ACPI is enabled. 115 * if this interrupt handler is installed, ACPI is enabled.
@@ -133,12 +119,11 @@ acpi_ev_gpe_xrupt_handler (
133 * GPEs: 119 * GPEs:
134 * Check for and dispatch any GPEs that have occurred 120 * Check for and dispatch any GPEs that have occurred
135 */ 121 */
136 interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list); 122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
137 123
138 return_VALUE (interrupt_handled); 124 return_VALUE(interrupt_handled);
139} 125}
140 126
141
142/****************************************************************************** 127/******************************************************************************
143 * 128 *
144 * FUNCTION: acpi_ev_install_sci_handler 129 * FUNCTION: acpi_ev_install_sci_handler
@@ -151,22 +136,18 @@ acpi_ev_gpe_xrupt_handler (
151 * 136 *
152 ******************************************************************************/ 137 ******************************************************************************/
153 138
154u32 139u32 acpi_ev_install_sci_handler(void)
155acpi_ev_install_sci_handler (
156 void)
157{ 140{
158 u32 status = AE_OK; 141 u32 status = AE_OK;
159
160 142
161 ACPI_FUNCTION_TRACE ("ev_install_sci_handler"); 143 ACPI_FUNCTION_TRACE("ev_install_sci_handler");
162 144
163 145 status = acpi_os_install_interrupt_handler((u32) acpi_gbl_FADT->sci_int,
164 status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, 146 acpi_ev_sci_xrupt_handler,
165 acpi_ev_sci_xrupt_handler, acpi_gbl_gpe_xrupt_list_head); 147 acpi_gbl_gpe_xrupt_list_head);
166 return_ACPI_STATUS (status); 148 return_ACPI_STATUS(status);
167} 149}
168 150
169
170/****************************************************************************** 151/******************************************************************************
171 * 152 *
172 * FUNCTION: acpi_ev_remove_sci_handler 153 * FUNCTION: acpi_ev_remove_sci_handler
@@ -186,22 +167,16 @@ acpi_ev_install_sci_handler (
186 * 167 *
187 ******************************************************************************/ 168 ******************************************************************************/
188 169
189acpi_status 170acpi_status acpi_ev_remove_sci_handler(void)
190acpi_ev_remove_sci_handler (
191 void)
192{ 171{
193 acpi_status status; 172 acpi_status status;
194
195
196 ACPI_FUNCTION_TRACE ("ev_remove_sci_handler");
197 173
174 ACPI_FUNCTION_TRACE("ev_remove_sci_handler");
198 175
199 /* Just let the OS remove the handler and disable the level */ 176 /* Just let the OS remove the handler and disable the level */
200 177
201 status = acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int, 178 status = acpi_os_remove_interrupt_handler((u32) acpi_gbl_FADT->sci_int,
202 acpi_ev_sci_xrupt_handler); 179 acpi_ev_sci_xrupt_handler);
203 180
204 return_ACPI_STATUS (status); 181 return_ACPI_STATUS(status);
205} 182}
206
207
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 4c1c25e316a8..43b33d19cdf9 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -49,8 +49,7 @@
49#include <acpi/acinterp.h> 49#include <acpi/acinterp.h>
50 50
51#define _COMPONENT ACPI_EVENTS 51#define _COMPONENT ACPI_EVENTS
52 ACPI_MODULE_NAME ("evxface") 52ACPI_MODULE_NAME("evxface")
53
54 53
55/******************************************************************************* 54/*******************************************************************************
56 * 55 *
@@ -64,21 +63,16 @@
64 * DESCRIPTION: Saves the pointer to the handler function 63 * DESCRIPTION: Saves the pointer to the handler function
65 * 64 *
66 ******************************************************************************/ 65 ******************************************************************************/
67
68#ifdef ACPI_FUTURE_USAGE 66#ifdef ACPI_FUTURE_USAGE
69acpi_status 67acpi_status acpi_install_exception_handler(acpi_exception_handler handler)
70acpi_install_exception_handler (
71 acpi_exception_handler handler)
72{ 68{
73 acpi_status status; 69 acpi_status status;
74
75 70
76 ACPI_FUNCTION_TRACE ("acpi_install_exception_handler"); 71 ACPI_FUNCTION_TRACE("acpi_install_exception_handler");
77 72
78 73 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
79 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 74 if (ACPI_FAILURE(status)) {
80 if (ACPI_FAILURE (status)) { 75 return_ACPI_STATUS(status);
81 return_ACPI_STATUS (status);
82 } 76 }
83 77
84 /* Don't allow two handlers. */ 78 /* Don't allow two handlers. */
@@ -92,12 +86,11 @@ acpi_install_exception_handler (
92 86
93 acpi_gbl_exception_handler = handler; 87 acpi_gbl_exception_handler = handler;
94 88
95cleanup: 89 cleanup:
96 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 90 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
97 return_ACPI_STATUS (status); 91 return_ACPI_STATUS(status);
98} 92}
99#endif /* ACPI_FUTURE_USAGE */ 93#endif /* ACPI_FUTURE_USAGE */
100
101 94
102/******************************************************************************* 95/*******************************************************************************
103 * 96 *
@@ -116,26 +109,22 @@ cleanup:
116 ******************************************************************************/ 109 ******************************************************************************/
117 110
118acpi_status 111acpi_status
119acpi_install_fixed_event_handler ( 112acpi_install_fixed_event_handler(u32 event,
120 u32 event, 113 acpi_event_handler handler, void *context)
121 acpi_event_handler handler,
122 void *context)
123{ 114{
124 acpi_status status; 115 acpi_status status;
125
126
127 ACPI_FUNCTION_TRACE ("acpi_install_fixed_event_handler");
128 116
117 ACPI_FUNCTION_TRACE("acpi_install_fixed_event_handler");
129 118
130 /* Parameter validation */ 119 /* Parameter validation */
131 120
132 if (event > ACPI_EVENT_MAX) { 121 if (event > ACPI_EVENT_MAX) {
133 return_ACPI_STATUS (AE_BAD_PARAMETER); 122 return_ACPI_STATUS(AE_BAD_PARAMETER);
134 } 123 }
135 124
136 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 125 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
137 if (ACPI_FAILURE (status)) { 126 if (ACPI_FAILURE(status)) {
138 return_ACPI_STATUS (status); 127 return_ACPI_STATUS(status);
139 } 128 }
140 129
141 /* Don't allow two handlers. */ 130 /* Don't allow two handlers. */
@@ -150,29 +139,29 @@ acpi_install_fixed_event_handler (
150 acpi_gbl_fixed_event_handlers[event].handler = handler; 139 acpi_gbl_fixed_event_handlers[event].handler = handler;
151 acpi_gbl_fixed_event_handlers[event].context = context; 140 acpi_gbl_fixed_event_handlers[event].context = context;
152 141
153 status = acpi_clear_event (event); 142 status = acpi_clear_event(event);
154 if (ACPI_SUCCESS(status)) 143 if (ACPI_SUCCESS(status))
155 status = acpi_enable_event (event, 0); 144 status = acpi_enable_event(event, 0);
156 if (ACPI_FAILURE (status)) { 145 if (ACPI_FAILURE(status)) {
157 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n")); 146 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
147 "Could not enable fixed event.\n"));
158 148
159 /* Remove the handler */ 149 /* Remove the handler */
160 150
161 acpi_gbl_fixed_event_handlers[event].handler = NULL; 151 acpi_gbl_fixed_event_handlers[event].handler = NULL;
162 acpi_gbl_fixed_event_handlers[event].context = NULL; 152 acpi_gbl_fixed_event_handlers[event].context = NULL;
163 } 153 } else {
164 else { 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
165 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 155 "Enabled fixed event %X, Handler=%p\n", event,
166 "Enabled fixed event %X, Handler=%p\n", event, handler)); 156 handler));
167 } 157 }
168 158
169 159 cleanup:
170cleanup: 160 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
171 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 161 return_ACPI_STATUS(status);
172 return_ACPI_STATUS (status);
173} 162}
174EXPORT_SYMBOL(acpi_install_fixed_event_handler);
175 163
164EXPORT_SYMBOL(acpi_install_fixed_event_handler);
176 165
177/******************************************************************************* 166/*******************************************************************************
178 * 167 *
@@ -188,49 +177,45 @@ EXPORT_SYMBOL(acpi_install_fixed_event_handler);
188 ******************************************************************************/ 177 ******************************************************************************/
189 178
190acpi_status 179acpi_status
191acpi_remove_fixed_event_handler ( 180acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
192 u32 event,
193 acpi_event_handler handler)
194{ 181{
195 acpi_status status = AE_OK; 182 acpi_status status = AE_OK;
196
197
198 ACPI_FUNCTION_TRACE ("acpi_remove_fixed_event_handler");
199 183
184 ACPI_FUNCTION_TRACE("acpi_remove_fixed_event_handler");
200 185
201 /* Parameter validation */ 186 /* Parameter validation */
202 187
203 if (event > ACPI_EVENT_MAX) { 188 if (event > ACPI_EVENT_MAX) {
204 return_ACPI_STATUS (AE_BAD_PARAMETER); 189 return_ACPI_STATUS(AE_BAD_PARAMETER);
205 } 190 }
206 191
207 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 192 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
208 if (ACPI_FAILURE (status)) { 193 if (ACPI_FAILURE(status)) {
209 return_ACPI_STATUS (status); 194 return_ACPI_STATUS(status);
210 } 195 }
211 196
212 /* Disable the event before removing the handler */ 197 /* Disable the event before removing the handler */
213 198
214 status = acpi_disable_event (event, 0); 199 status = acpi_disable_event(event, 0);
215 200
216 /* Always Remove the handler */ 201 /* Always Remove the handler */
217 202
218 acpi_gbl_fixed_event_handlers[event].handler = NULL; 203 acpi_gbl_fixed_event_handlers[event].handler = NULL;
219 acpi_gbl_fixed_event_handlers[event].context = NULL; 204 acpi_gbl_fixed_event_handlers[event].context = NULL;
220 205
221 if (ACPI_FAILURE (status)) { 206 if (ACPI_FAILURE(status)) {
222 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, 207 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
223 "Could not write to fixed event enable register.\n")); 208 "Could not write to fixed event enable register.\n"));
224 } 209 } else {
225 else { 210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X.\n",
226 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", event)); 211 event));
227 } 212 }
228 213
229 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 214 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
230 return_ACPI_STATUS (status); 215 return_ACPI_STATUS(status);
231} 216}
232EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
233 217
218EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
234 219
235/******************************************************************************* 220/*******************************************************************************
236 * 221 *
@@ -251,37 +236,32 @@ EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
251 ******************************************************************************/ 236 ******************************************************************************/
252 237
253acpi_status 238acpi_status
254acpi_install_notify_handler ( 239acpi_install_notify_handler(acpi_handle device,
255 acpi_handle device, 240 u32 handler_type,
256 u32 handler_type, 241 acpi_notify_handler handler, void *context)
257 acpi_notify_handler handler,
258 void *context)
259{ 242{
260 union acpi_operand_object *obj_desc; 243 union acpi_operand_object *obj_desc;
261 union acpi_operand_object *notify_obj; 244 union acpi_operand_object *notify_obj;
262 struct acpi_namespace_node *node; 245 struct acpi_namespace_node *node;
263 acpi_status status; 246 acpi_status status;
264
265
266 ACPI_FUNCTION_TRACE ("acpi_install_notify_handler");
267 247
248 ACPI_FUNCTION_TRACE("acpi_install_notify_handler");
268 249
269 /* Parameter validation */ 250 /* Parameter validation */
270 251
271 if ((!device) || 252 if ((!device) ||
272 (!handler) || 253 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
273 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 254 return_ACPI_STATUS(AE_BAD_PARAMETER);
274 return_ACPI_STATUS (AE_BAD_PARAMETER);
275 } 255 }
276 256
277 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 257 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
278 if (ACPI_FAILURE (status)) { 258 if (ACPI_FAILURE(status)) {
279 return_ACPI_STATUS (status); 259 return_ACPI_STATUS(status);
280 } 260 }
281 261
282 /* Convert and validate the device handle */ 262 /* Convert and validate the device handle */
283 263
284 node = acpi_ns_map_handle_to_node (device); 264 node = acpi_ns_map_handle_to_node(device);
285 if (!node) { 265 if (!node) {
286 status = AE_BAD_PARAMETER; 266 status = AE_BAD_PARAMETER;
287 goto unlock_and_exit; 267 goto unlock_and_exit;
@@ -297,21 +277,21 @@ acpi_install_notify_handler (
297 /* Make sure the handler is not already installed */ 277 /* Make sure the handler is not already installed */
298 278
299 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 279 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
300 acpi_gbl_system_notify.handler) || 280 acpi_gbl_system_notify.handler) ||
301 ((handler_type & ACPI_DEVICE_NOTIFY) && 281 ((handler_type & ACPI_DEVICE_NOTIFY) &&
302 acpi_gbl_device_notify.handler)) { 282 acpi_gbl_device_notify.handler)) {
303 status = AE_ALREADY_EXISTS; 283 status = AE_ALREADY_EXISTS;
304 goto unlock_and_exit; 284 goto unlock_and_exit;
305 } 285 }
306 286
307 if (handler_type & ACPI_SYSTEM_NOTIFY) { 287 if (handler_type & ACPI_SYSTEM_NOTIFY) {
308 acpi_gbl_system_notify.node = node; 288 acpi_gbl_system_notify.node = node;
309 acpi_gbl_system_notify.handler = handler; 289 acpi_gbl_system_notify.handler = handler;
310 acpi_gbl_system_notify.context = context; 290 acpi_gbl_system_notify.context = context;
311 } 291 }
312 292
313 if (handler_type & ACPI_DEVICE_NOTIFY) { 293 if (handler_type & ACPI_DEVICE_NOTIFY) {
314 acpi_gbl_device_notify.node = node; 294 acpi_gbl_device_notify.node = node;
315 acpi_gbl_device_notify.handler = handler; 295 acpi_gbl_device_notify.handler = handler;
316 acpi_gbl_device_notify.context = context; 296 acpi_gbl_device_notify.context = context;
317 } 297 }
@@ -327,29 +307,28 @@ acpi_install_notify_handler (
327 else { 307 else {
328 /* Notifies allowed on this object? */ 308 /* Notifies allowed on this object? */
329 309
330 if (!acpi_ev_is_notify_object (node)) { 310 if (!acpi_ev_is_notify_object(node)) {
331 status = AE_TYPE; 311 status = AE_TYPE;
332 goto unlock_and_exit; 312 goto unlock_and_exit;
333 } 313 }
334 314
335 /* Check for an existing internal object */ 315 /* Check for an existing internal object */
336 316
337 obj_desc = acpi_ns_get_attached_object (node); 317 obj_desc = acpi_ns_get_attached_object(node);
338 if (obj_desc) { 318 if (obj_desc) {
339 /* Object exists - make sure there's no handler */ 319 /* Object exists - make sure there's no handler */
340 320
341 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 321 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
342 obj_desc->common_notify.system_notify) || 322 obj_desc->common_notify.system_notify) ||
343 ((handler_type & ACPI_DEVICE_NOTIFY) && 323 ((handler_type & ACPI_DEVICE_NOTIFY) &&
344 obj_desc->common_notify.device_notify)) { 324 obj_desc->common_notify.device_notify)) {
345 status = AE_ALREADY_EXISTS; 325 status = AE_ALREADY_EXISTS;
346 goto unlock_and_exit; 326 goto unlock_and_exit;
347 } 327 }
348 } 328 } else {
349 else {
350 /* Create a new object */ 329 /* Create a new object */
351 330
352 obj_desc = acpi_ut_create_internal_object (node->type); 331 obj_desc = acpi_ut_create_internal_object(node->type);
353 if (!obj_desc) { 332 if (!obj_desc) {
354 status = AE_NO_MEMORY; 333 status = AE_NO_MEMORY;
355 goto unlock_and_exit; 334 goto unlock_and_exit;
@@ -357,25 +336,27 @@ acpi_install_notify_handler (
357 336
358 /* Attach new object to the Node */ 337 /* Attach new object to the Node */
359 338
360 status = acpi_ns_attach_object (device, obj_desc, node->type); 339 status =
340 acpi_ns_attach_object(device, obj_desc, node->type);
361 341
362 /* Remove local reference to the object */ 342 /* Remove local reference to the object */
363 343
364 acpi_ut_remove_reference (obj_desc); 344 acpi_ut_remove_reference(obj_desc);
365 if (ACPI_FAILURE (status)) { 345 if (ACPI_FAILURE(status)) {
366 goto unlock_and_exit; 346 goto unlock_and_exit;
367 } 347 }
368 } 348 }
369 349
370 /* Install the handler */ 350 /* Install the handler */
371 351
372 notify_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_NOTIFY); 352 notify_obj =
353 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_NOTIFY);
373 if (!notify_obj) { 354 if (!notify_obj) {
374 status = AE_NO_MEMORY; 355 status = AE_NO_MEMORY;
375 goto unlock_and_exit; 356 goto unlock_and_exit;
376 } 357 }
377 358
378 notify_obj->notify.node = node; 359 notify_obj->notify.node = node;
379 notify_obj->notify.handler = handler; 360 notify_obj->notify.handler = handler;
380 notify_obj->notify.context = context; 361 notify_obj->notify.context = context;
381 362
@@ -390,17 +371,16 @@ acpi_install_notify_handler (
390 if (handler_type == ACPI_ALL_NOTIFY) { 371 if (handler_type == ACPI_ALL_NOTIFY) {
391 /* Extra ref if installed in both */ 372 /* Extra ref if installed in both */
392 373
393 acpi_ut_add_reference (notify_obj); 374 acpi_ut_add_reference(notify_obj);
394 } 375 }
395 } 376 }
396 377
397 378 unlock_and_exit:
398unlock_and_exit: 379 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
399 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 380 return_ACPI_STATUS(status);
400 return_ACPI_STATUS (status);
401} 381}
402EXPORT_SYMBOL(acpi_install_notify_handler);
403 382
383EXPORT_SYMBOL(acpi_install_notify_handler);
404 384
405/******************************************************************************* 385/*******************************************************************************
406 * 386 *
@@ -420,36 +400,31 @@ EXPORT_SYMBOL(acpi_install_notify_handler);
420 ******************************************************************************/ 400 ******************************************************************************/
421 401
422acpi_status 402acpi_status
423acpi_remove_notify_handler ( 403acpi_remove_notify_handler(acpi_handle device,
424 acpi_handle device, 404 u32 handler_type, acpi_notify_handler handler)
425 u32 handler_type,
426 acpi_notify_handler handler)
427{ 405{
428 union acpi_operand_object *notify_obj; 406 union acpi_operand_object *notify_obj;
429 union acpi_operand_object *obj_desc; 407 union acpi_operand_object *obj_desc;
430 struct acpi_namespace_node *node; 408 struct acpi_namespace_node *node;
431 acpi_status status; 409 acpi_status status;
432
433
434 ACPI_FUNCTION_TRACE ("acpi_remove_notify_handler");
435 410
411 ACPI_FUNCTION_TRACE("acpi_remove_notify_handler");
436 412
437 /* Parameter validation */ 413 /* Parameter validation */
438 414
439 if ((!device) || 415 if ((!device) ||
440 (!handler) || 416 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
441 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 417 return_ACPI_STATUS(AE_BAD_PARAMETER);
442 return_ACPI_STATUS (AE_BAD_PARAMETER);
443 } 418 }
444 419
445 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 420 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
446 if (ACPI_FAILURE (status)) { 421 if (ACPI_FAILURE(status)) {
447 return_ACPI_STATUS (status); 422 return_ACPI_STATUS(status);
448 } 423 }
449 424
450 /* Convert and validate the device handle */ 425 /* Convert and validate the device handle */
451 426
452 node = acpi_ns_map_handle_to_node (device); 427 node = acpi_ns_map_handle_to_node(device);
453 if (!node) { 428 if (!node) {
454 status = AE_BAD_PARAMETER; 429 status = AE_BAD_PARAMETER;
455 goto unlock_and_exit; 430 goto unlock_and_exit;
@@ -458,34 +433,34 @@ acpi_remove_notify_handler (
458 /* Root Object */ 433 /* Root Object */
459 434
460 if (device == ACPI_ROOT_OBJECT) { 435 if (device == ACPI_ROOT_OBJECT) {
461 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 436 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
462 "Removing notify handler for ROOT object.\n")); 437 "Removing notify handler for ROOT object.\n"));
463 438
464 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 439 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
465 !acpi_gbl_system_notify.handler) || 440 !acpi_gbl_system_notify.handler) ||
466 ((handler_type & ACPI_DEVICE_NOTIFY) && 441 ((handler_type & ACPI_DEVICE_NOTIFY) &&
467 !acpi_gbl_device_notify.handler)) { 442 !acpi_gbl_device_notify.handler)) {
468 status = AE_NOT_EXIST; 443 status = AE_NOT_EXIST;
469 goto unlock_and_exit; 444 goto unlock_and_exit;
470 } 445 }
471 446
472 /* Make sure all deferred tasks are completed */ 447 /* Make sure all deferred tasks are completed */
473 448
474 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 449 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
475 acpi_os_wait_events_complete(NULL); 450 acpi_os_wait_events_complete(NULL);
476 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 451 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
477 if (ACPI_FAILURE (status)) { 452 if (ACPI_FAILURE(status)) {
478 return_ACPI_STATUS (status); 453 return_ACPI_STATUS(status);
479 } 454 }
480 455
481 if (handler_type & ACPI_SYSTEM_NOTIFY) { 456 if (handler_type & ACPI_SYSTEM_NOTIFY) {
482 acpi_gbl_system_notify.node = NULL; 457 acpi_gbl_system_notify.node = NULL;
483 acpi_gbl_system_notify.handler = NULL; 458 acpi_gbl_system_notify.handler = NULL;
484 acpi_gbl_system_notify.context = NULL; 459 acpi_gbl_system_notify.context = NULL;
485 } 460 }
486 461
487 if (handler_type & ACPI_DEVICE_NOTIFY) { 462 if (handler_type & ACPI_DEVICE_NOTIFY) {
488 acpi_gbl_device_notify.node = NULL; 463 acpi_gbl_device_notify.node = NULL;
489 acpi_gbl_device_notify.handler = NULL; 464 acpi_gbl_device_notify.handler = NULL;
490 acpi_gbl_device_notify.context = NULL; 465 acpi_gbl_device_notify.context = NULL;
491 } 466 }
@@ -496,14 +471,14 @@ acpi_remove_notify_handler (
496 else { 471 else {
497 /* Notifies allowed on this object? */ 472 /* Notifies allowed on this object? */
498 473
499 if (!acpi_ev_is_notify_object (node)) { 474 if (!acpi_ev_is_notify_object(node)) {
500 status = AE_TYPE; 475 status = AE_TYPE;
501 goto unlock_and_exit; 476 goto unlock_and_exit;
502 } 477 }
503 478
504 /* Check for an existing internal object */ 479 /* Check for an existing internal object */
505 480
506 obj_desc = acpi_ns_get_attached_object (node); 481 obj_desc = acpi_ns_get_attached_object(node);
507 if (!obj_desc) { 482 if (!obj_desc) {
508 status = AE_NOT_EXIST; 483 status = AE_NOT_EXIST;
509 goto unlock_and_exit; 484 goto unlock_and_exit;
@@ -514,53 +489,52 @@ acpi_remove_notify_handler (
514 if (handler_type & ACPI_SYSTEM_NOTIFY) { 489 if (handler_type & ACPI_SYSTEM_NOTIFY) {
515 notify_obj = obj_desc->common_notify.system_notify; 490 notify_obj = obj_desc->common_notify.system_notify;
516 if ((!notify_obj) || 491 if ((!notify_obj) ||
517 (notify_obj->notify.handler != handler)) { 492 (notify_obj->notify.handler != handler)) {
518 status = AE_BAD_PARAMETER; 493 status = AE_BAD_PARAMETER;
519 goto unlock_and_exit; 494 goto unlock_and_exit;
520 } 495 }
521 /* Make sure all deferred tasks are completed */ 496 /* Make sure all deferred tasks are completed */
522 497
523 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 498 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
524 acpi_os_wait_events_complete(NULL); 499 acpi_os_wait_events_complete(NULL);
525 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 500 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
526 if (ACPI_FAILURE (status)) { 501 if (ACPI_FAILURE(status)) {
527 return_ACPI_STATUS (status); 502 return_ACPI_STATUS(status);
528 } 503 }
529 504
530 /* Remove the handler */ 505 /* Remove the handler */
531 obj_desc->common_notify.system_notify = NULL; 506 obj_desc->common_notify.system_notify = NULL;
532 acpi_ut_remove_reference (notify_obj); 507 acpi_ut_remove_reference(notify_obj);
533 } 508 }
534 509
535 if (handler_type & ACPI_DEVICE_NOTIFY) { 510 if (handler_type & ACPI_DEVICE_NOTIFY) {
536 notify_obj = obj_desc->common_notify.device_notify; 511 notify_obj = obj_desc->common_notify.device_notify;
537 if ((!notify_obj) || 512 if ((!notify_obj) ||
538 (notify_obj->notify.handler != handler)) { 513 (notify_obj->notify.handler != handler)) {
539 status = AE_BAD_PARAMETER; 514 status = AE_BAD_PARAMETER;
540 goto unlock_and_exit; 515 goto unlock_and_exit;
541 } 516 }
542 /* Make sure all deferred tasks are completed */ 517 /* Make sure all deferred tasks are completed */
543 518
544 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 519 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
545 acpi_os_wait_events_complete(NULL); 520 acpi_os_wait_events_complete(NULL);
546 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 521 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
547 if (ACPI_FAILURE (status)) { 522 if (ACPI_FAILURE(status)) {
548 return_ACPI_STATUS (status); 523 return_ACPI_STATUS(status);
549 } 524 }
550 525
551 /* Remove the handler */ 526 /* Remove the handler */
552 obj_desc->common_notify.device_notify = NULL; 527 obj_desc->common_notify.device_notify = NULL;
553 acpi_ut_remove_reference (notify_obj); 528 acpi_ut_remove_reference(notify_obj);
554 } 529 }
555 } 530 }
556 531
557 532 unlock_and_exit:
558unlock_and_exit: 533 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
559 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 534 return_ACPI_STATUS(status);
560 return_ACPI_STATUS (status);
561} 535}
562EXPORT_SYMBOL(acpi_remove_notify_handler);
563 536
537EXPORT_SYMBOL(acpi_remove_notify_handler);
564 538
565/******************************************************************************* 539/*******************************************************************************
566 * 540 *
@@ -581,36 +555,31 @@ EXPORT_SYMBOL(acpi_remove_notify_handler);
581 ******************************************************************************/ 555 ******************************************************************************/
582 556
583acpi_status 557acpi_status
584acpi_install_gpe_handler ( 558acpi_install_gpe_handler(acpi_handle gpe_device,
585 acpi_handle gpe_device, 559 u32 gpe_number,
586 u32 gpe_number, 560 u32 type, acpi_event_handler address, void *context)
587 u32 type,
588 acpi_event_handler address,
589 void *context)
590{ 561{
591 struct acpi_gpe_event_info *gpe_event_info; 562 struct acpi_gpe_event_info *gpe_event_info;
592 struct acpi_handler_info *handler; 563 struct acpi_handler_info *handler;
593 acpi_status status; 564 acpi_status status;
594 u32 flags; 565 u32 flags;
595
596
597 ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
598 566
567 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler");
599 568
600 /* Parameter validation */ 569 /* Parameter validation */
601 570
602 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { 571 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
603 return_ACPI_STATUS (AE_BAD_PARAMETER); 572 return_ACPI_STATUS(AE_BAD_PARAMETER);
604 } 573 }
605 574
606 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 575 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
607 if (ACPI_FAILURE (status)) { 576 if (ACPI_FAILURE(status)) {
608 return_ACPI_STATUS (status); 577 return_ACPI_STATUS(status);
609 } 578 }
610 579
611 /* Ensure that we have a valid GPE number */ 580 /* Ensure that we have a valid GPE number */
612 581
613 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 582 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
614 if (!gpe_event_info) { 583 if (!gpe_event_info) {
615 status = AE_BAD_PARAMETER; 584 status = AE_BAD_PARAMETER;
616 goto unlock_and_exit; 585 goto unlock_and_exit;
@@ -618,49 +587,49 @@ acpi_install_gpe_handler (
618 587
619 /* Make sure that there isn't a handler there already */ 588 /* Make sure that there isn't a handler there already */
620 589
621 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { 590 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
591 ACPI_GPE_DISPATCH_HANDLER) {
622 status = AE_ALREADY_EXISTS; 592 status = AE_ALREADY_EXISTS;
623 goto unlock_and_exit; 593 goto unlock_and_exit;
624 } 594 }
625 595
626 /* Allocate and init handler object */ 596 /* Allocate and init handler object */
627 597
628 handler = ACPI_MEM_CALLOCATE (sizeof (struct acpi_handler_info)); 598 handler = ACPI_MEM_CALLOCATE(sizeof(struct acpi_handler_info));
629 if (!handler) { 599 if (!handler) {
630 status = AE_NO_MEMORY; 600 status = AE_NO_MEMORY;
631 goto unlock_and_exit; 601 goto unlock_and_exit;
632 } 602 }
633 603
634 handler->address = address; 604 handler->address = address;
635 handler->context = context; 605 handler->context = context;
636 handler->method_node = gpe_event_info->dispatch.method_node; 606 handler->method_node = gpe_event_info->dispatch.method_node;
637 607
638 /* Disable the GPE before installing the handler */ 608 /* Disable the GPE before installing the handler */
639 609
640 status = acpi_ev_disable_gpe (gpe_event_info); 610 status = acpi_ev_disable_gpe(gpe_event_info);
641 if (ACPI_FAILURE (status)) { 611 if (ACPI_FAILURE(status)) {
642 goto unlock_and_exit; 612 goto unlock_and_exit;
643 } 613 }
644 614
645 /* Install the handler */ 615 /* Install the handler */
646 616
647 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 617 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
648 gpe_event_info->dispatch.handler = handler; 618 gpe_event_info->dispatch.handler = handler;
649 619
650 /* Setup up dispatch flags to indicate handler (vs. method) */ 620 /* Setup up dispatch flags to indicate handler (vs. method) */
651 621
652 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ 622 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */
653 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); 623 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
654 624
655 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 625 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
656
657 626
658unlock_and_exit: 627 unlock_and_exit:
659 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 628 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
660 return_ACPI_STATUS (status); 629 return_ACPI_STATUS(status);
661} 630}
662EXPORT_SYMBOL(acpi_install_gpe_handler);
663 631
632EXPORT_SYMBOL(acpi_install_gpe_handler);
664 633
665/******************************************************************************* 634/*******************************************************************************
666 * 635 *
@@ -678,34 +647,30 @@ EXPORT_SYMBOL(acpi_install_gpe_handler);
678 ******************************************************************************/ 647 ******************************************************************************/
679 648
680acpi_status 649acpi_status
681acpi_remove_gpe_handler ( 650acpi_remove_gpe_handler(acpi_handle gpe_device,
682 acpi_handle gpe_device, 651 u32 gpe_number, acpi_event_handler address)
683 u32 gpe_number,
684 acpi_event_handler address)
685{ 652{
686 struct acpi_gpe_event_info *gpe_event_info; 653 struct acpi_gpe_event_info *gpe_event_info;
687 struct acpi_handler_info *handler; 654 struct acpi_handler_info *handler;
688 acpi_status status; 655 acpi_status status;
689 u32 flags; 656 u32 flags;
690
691
692 ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
693 657
658 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler");
694 659
695 /* Parameter validation */ 660 /* Parameter validation */
696 661
697 if (!address) { 662 if (!address) {
698 return_ACPI_STATUS (AE_BAD_PARAMETER); 663 return_ACPI_STATUS(AE_BAD_PARAMETER);
699 } 664 }
700 665
701 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 666 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
702 if (ACPI_FAILURE (status)) { 667 if (ACPI_FAILURE(status)) {
703 return_ACPI_STATUS (status); 668 return_ACPI_STATUS(status);
704 } 669 }
705 670
706 /* Ensure that we have a valid GPE number */ 671 /* Ensure that we have a valid GPE number */
707 672
708 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 673 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
709 if (!gpe_event_info) { 674 if (!gpe_event_info) {
710 status = AE_BAD_PARAMETER; 675 status = AE_BAD_PARAMETER;
711 goto unlock_and_exit; 676 goto unlock_and_exit;
@@ -713,7 +678,8 @@ acpi_remove_gpe_handler (
713 678
714 /* Make sure that a handler is indeed installed */ 679 /* Make sure that a handler is indeed installed */
715 680
716 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER) { 681 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) !=
682 ACPI_GPE_DISPATCH_HANDLER) {
717 status = AE_NOT_EXIST; 683 status = AE_NOT_EXIST;
718 goto unlock_and_exit; 684 goto unlock_and_exit;
719 } 685 }
@@ -727,45 +693,44 @@ acpi_remove_gpe_handler (
727 693
728 /* Disable the GPE before removing the handler */ 694 /* Disable the GPE before removing the handler */
729 695
730 status = acpi_ev_disable_gpe (gpe_event_info); 696 status = acpi_ev_disable_gpe(gpe_event_info);
731 if (ACPI_FAILURE (status)) { 697 if (ACPI_FAILURE(status)) {
732 goto unlock_and_exit; 698 goto unlock_and_exit;
733 } 699 }
734 700
735 /* Make sure all deferred tasks are completed */ 701 /* Make sure all deferred tasks are completed */
736 702
737 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 703 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
738 acpi_os_wait_events_complete(NULL); 704 acpi_os_wait_events_complete(NULL);
739 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 705 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
740 if (ACPI_FAILURE (status)) { 706 if (ACPI_FAILURE(status)) {
741 return_ACPI_STATUS (status); 707 return_ACPI_STATUS(status);
742 } 708 }
743 709
744 /* Remove the handler */ 710 /* Remove the handler */
745 711
746 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 712 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
747 handler = gpe_event_info->dispatch.handler; 713 handler = gpe_event_info->dispatch.handler;
748 714
749 /* Restore Method node (if any), set dispatch flags */ 715 /* Restore Method node (if any), set dispatch flags */
750 716
751 gpe_event_info->dispatch.method_node = handler->method_node; 717 gpe_event_info->dispatch.method_node = handler->method_node;
752 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ 718 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */
753 if (handler->method_node) { 719 if (handler->method_node) {
754 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; 720 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD;
755 } 721 }
756 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 722 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
757 723
758 /* Now we can free the handler object */ 724 /* Now we can free the handler object */
759 725
760 ACPI_MEM_FREE (handler); 726 ACPI_MEM_FREE(handler);
761 727
762 728 unlock_and_exit:
763unlock_and_exit: 729 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
764 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 730 return_ACPI_STATUS(status);
765 return_ACPI_STATUS (status);
766} 731}
767EXPORT_SYMBOL(acpi_remove_gpe_handler);
768 732
733EXPORT_SYMBOL(acpi_remove_gpe_handler);
769 734
770/******************************************************************************* 735/*******************************************************************************
771 * 736 *
@@ -781,35 +746,31 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler);
781 * 746 *
782 ******************************************************************************/ 747 ******************************************************************************/
783 748
784acpi_status 749acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle)
785acpi_acquire_global_lock (
786 u16 timeout,
787 u32 *handle)
788{ 750{
789 acpi_status status; 751 acpi_status status;
790
791 752
792 if (!handle) { 753 if (!handle) {
793 return (AE_BAD_PARAMETER); 754 return (AE_BAD_PARAMETER);
794 } 755 }
795 756
796 status = acpi_ex_enter_interpreter (); 757 status = acpi_ex_enter_interpreter();
797 if (ACPI_FAILURE (status)) { 758 if (ACPI_FAILURE(status)) {
798 return (status); 759 return (status);
799 } 760 }
800 761
801 status = acpi_ev_acquire_global_lock (timeout); 762 status = acpi_ev_acquire_global_lock(timeout);
802 acpi_ex_exit_interpreter (); 763 acpi_ex_exit_interpreter();
803 764
804 if (ACPI_SUCCESS (status)) { 765 if (ACPI_SUCCESS(status)) {
805 acpi_gbl_global_lock_handle++; 766 acpi_gbl_global_lock_handle++;
806 *handle = acpi_gbl_global_lock_handle; 767 *handle = acpi_gbl_global_lock_handle;
807 } 768 }
808 769
809 return (status); 770 return (status);
810} 771}
811EXPORT_SYMBOL(acpi_acquire_global_lock);
812 772
773EXPORT_SYMBOL(acpi_acquire_global_lock);
813 774
814/******************************************************************************* 775/*******************************************************************************
815 * 776 *
@@ -823,19 +784,16 @@ EXPORT_SYMBOL(acpi_acquire_global_lock);
823 * 784 *
824 ******************************************************************************/ 785 ******************************************************************************/
825 786
826acpi_status 787acpi_status acpi_release_global_lock(u32 handle)
827acpi_release_global_lock (
828 u32 handle)
829{ 788{
830 acpi_status status; 789 acpi_status status;
831
832 790
833 if (handle != acpi_gbl_global_lock_handle) { 791 if (handle != acpi_gbl_global_lock_handle) {
834 return (AE_NOT_ACQUIRED); 792 return (AE_NOT_ACQUIRED);
835 } 793 }
836 794
837 status = acpi_ev_release_global_lock (); 795 status = acpi_ev_release_global_lock();
838 return (status); 796 return (status);
839} 797}
840EXPORT_SYMBOL(acpi_release_global_lock);
841 798
799EXPORT_SYMBOL(acpi_release_global_lock);
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index c5f74d7b64d8..887ff9f28a0d 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/events/evxfevnt.c
@@ -48,8 +48,7 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49 49
50#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evxfevnt") 51ACPI_MODULE_NAME("evxfevnt")
52
53 52
54/******************************************************************************* 53/*******************************************************************************
55 * 54 *
@@ -62,44 +61,39 @@
62 * DESCRIPTION: Transfers the system into ACPI mode. 61 * DESCRIPTION: Transfers the system into ACPI mode.
63 * 62 *
64 ******************************************************************************/ 63 ******************************************************************************/
65 64acpi_status acpi_enable(void)
66acpi_status
67acpi_enable (
68 void)
69{ 65{
70 acpi_status status = AE_OK; 66 acpi_status status = AE_OK;
71
72 67
73 ACPI_FUNCTION_TRACE ("acpi_enable"); 68 ACPI_FUNCTION_TRACE("acpi_enable");
74 69
75 70 /* Make sure we have the FADT */
76 /* Make sure we have the FADT*/
77 71
78 if (!acpi_gbl_FADT) { 72 if (!acpi_gbl_FADT) {
79 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n")); 73 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
80 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 74 "No FADT information present!\n"));
75 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
81 } 76 }
82 77
83 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { 78 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
84 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); 79 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
85 } 80 "System is already in ACPI mode\n"));
86 else { 81 } else {
87 /* Transition to ACPI mode */ 82 /* Transition to ACPI mode */
88 83
89 status = acpi_hw_set_mode (ACPI_SYS_MODE_ACPI); 84 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
90 if (ACPI_FAILURE (status)) { 85 if (ACPI_FAILURE(status)) {
91 ACPI_REPORT_ERROR (("Could not transition to ACPI mode.\n")); 86 ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n"));
92 return_ACPI_STATUS (status); 87 return_ACPI_STATUS(status);
93 } 88 }
94 89
95 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 90 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
96 "Transition to ACPI mode successful\n")); 91 "Transition to ACPI mode successful\n"));
97 } 92 }
98 93
99 return_ACPI_STATUS (status); 94 return_ACPI_STATUS(status);
100} 95}
101 96
102
103/******************************************************************************* 97/*******************************************************************************
104 * 98 *
105 * FUNCTION: acpi_disable 99 * FUNCTION: acpi_disable
@@ -112,43 +106,38 @@ acpi_enable (
112 * 106 *
113 ******************************************************************************/ 107 ******************************************************************************/
114 108
115acpi_status 109acpi_status acpi_disable(void)
116acpi_disable (
117 void)
118{ 110{
119 acpi_status status = AE_OK; 111 acpi_status status = AE_OK;
120
121
122 ACPI_FUNCTION_TRACE ("acpi_disable");
123 112
113 ACPI_FUNCTION_TRACE("acpi_disable");
124 114
125 if (!acpi_gbl_FADT) { 115 if (!acpi_gbl_FADT) {
126 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n")); 116 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
127 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 117 "No FADT information present!\n"));
118 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
128 } 119 }
129 120
130 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { 121 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
131 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 122 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
132 "System is already in legacy (non-ACPI) mode\n")); 123 "System is already in legacy (non-ACPI) mode\n"));
133 } 124 } else {
134 else {
135 /* Transition to LEGACY mode */ 125 /* Transition to LEGACY mode */
136 126
137 status = acpi_hw_set_mode (ACPI_SYS_MODE_LEGACY); 127 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
138 128
139 if (ACPI_FAILURE (status)) { 129 if (ACPI_FAILURE(status)) {
140 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 130 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
141 "Could not exit ACPI mode to legacy mode")); 131 "Could not exit ACPI mode to legacy mode"));
142 return_ACPI_STATUS (status); 132 return_ACPI_STATUS(status);
143 } 133 }
144 134
145 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); 135 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
146 } 136 }
147 137
148 return_ACPI_STATUS (status); 138 return_ACPI_STATUS(status);
149} 139}
150 140
151
152/******************************************************************************* 141/*******************************************************************************
153 * 142 *
154 * FUNCTION: acpi_enable_event 143 * FUNCTION: acpi_enable_event
@@ -162,52 +151,50 @@ acpi_disable (
162 * 151 *
163 ******************************************************************************/ 152 ******************************************************************************/
164 153
165acpi_status 154acpi_status acpi_enable_event(u32 event, u32 flags)
166acpi_enable_event (
167 u32 event,
168 u32 flags)
169{ 155{
170 acpi_status status = AE_OK; 156 acpi_status status = AE_OK;
171 u32 value; 157 u32 value;
172
173
174 ACPI_FUNCTION_TRACE ("acpi_enable_event");
175 158
159 ACPI_FUNCTION_TRACE("acpi_enable_event");
176 160
177 /* Decode the Fixed Event */ 161 /* Decode the Fixed Event */
178 162
179 if (event > ACPI_EVENT_MAX) { 163 if (event > ACPI_EVENT_MAX) {
180 return_ACPI_STATUS (AE_BAD_PARAMETER); 164 return_ACPI_STATUS(AE_BAD_PARAMETER);
181 } 165 }
182 166
183 /* 167 /*
184 * Enable the requested fixed event (by writing a one to the 168 * Enable the requested fixed event (by writing a one to the
185 * enable register bit) 169 * enable register bit)
186 */ 170 */
187 status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, 171 status =
188 1, ACPI_MTX_LOCK); 172 acpi_set_register(acpi_gbl_fixed_event_info[event].
189 if (ACPI_FAILURE (status)) { 173 enable_register_id, 1, ACPI_MTX_LOCK);
190 return_ACPI_STATUS (status); 174 if (ACPI_FAILURE(status)) {
175 return_ACPI_STATUS(status);
191 } 176 }
192 177
193 /* Make sure that the hardware responded */ 178 /* Make sure that the hardware responded */
194 179
195 status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id, 180 status =
196 &value, ACPI_MTX_LOCK); 181 acpi_get_register(acpi_gbl_fixed_event_info[event].
197 if (ACPI_FAILURE (status)) { 182 enable_register_id, &value, ACPI_MTX_LOCK);
198 return_ACPI_STATUS (status); 183 if (ACPI_FAILURE(status)) {
184 return_ACPI_STATUS(status);
199 } 185 }
200 186
201 if (value != 1) { 187 if (value != 1) {
202 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 188 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
203 "Could not enable %s event\n", acpi_ut_get_event_name (event))); 189 "Could not enable %s event\n",
204 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); 190 acpi_ut_get_event_name(event)));
191 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
205 } 192 }
206 193
207 return_ACPI_STATUS (status); 194 return_ACPI_STATUS(status);
208} 195}
209EXPORT_SYMBOL(acpi_enable_event);
210 196
197EXPORT_SYMBOL(acpi_enable_event);
211 198
212/******************************************************************************* 199/*******************************************************************************
213 * 200 *
@@ -223,40 +210,34 @@ EXPORT_SYMBOL(acpi_enable_event);
223 * 210 *
224 ******************************************************************************/ 211 ******************************************************************************/
225 212
226acpi_status 213acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
227acpi_set_gpe_type (
228 acpi_handle gpe_device,
229 u32 gpe_number,
230 u8 type)
231{ 214{
232 acpi_status status = AE_OK; 215 acpi_status status = AE_OK;
233 struct acpi_gpe_event_info *gpe_event_info; 216 struct acpi_gpe_event_info *gpe_event_info;
234
235
236 ACPI_FUNCTION_TRACE ("acpi_set_gpe_type");
237 217
218 ACPI_FUNCTION_TRACE("acpi_set_gpe_type");
238 219
239 /* Ensure that we have a valid GPE number */ 220 /* Ensure that we have a valid GPE number */
240 221
241 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 222 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
242 if (!gpe_event_info) { 223 if (!gpe_event_info) {
243 status = AE_BAD_PARAMETER; 224 status = AE_BAD_PARAMETER;
244 goto unlock_and_exit; 225 goto unlock_and_exit;
245 } 226 }
246 227
247 if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) { 228 if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
248 return_ACPI_STATUS (AE_OK); 229 return_ACPI_STATUS(AE_OK);
249 } 230 }
250 231
251 /* Set the new type (will disable GPE if currently enabled) */ 232 /* Set the new type (will disable GPE if currently enabled) */
252 233
253 status = acpi_ev_set_gpe_type (gpe_event_info, type); 234 status = acpi_ev_set_gpe_type(gpe_event_info, type);
254 235
255unlock_and_exit: 236 unlock_and_exit:
256 return_ACPI_STATUS (status); 237 return_ACPI_STATUS(status);
257} 238}
258EXPORT_SYMBOL(acpi_set_gpe_type);
259 239
240EXPORT_SYMBOL(acpi_set_gpe_type);
260 241
261/******************************************************************************* 242/*******************************************************************************
262 * 243 *
@@ -273,31 +254,25 @@ EXPORT_SYMBOL(acpi_set_gpe_type);
273 * 254 *
274 ******************************************************************************/ 255 ******************************************************************************/
275 256
276acpi_status 257acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
277acpi_enable_gpe (
278 acpi_handle gpe_device,
279 u32 gpe_number,
280 u32 flags)
281{ 258{
282 acpi_status status = AE_OK; 259 acpi_status status = AE_OK;
283 struct acpi_gpe_event_info *gpe_event_info; 260 struct acpi_gpe_event_info *gpe_event_info;
284
285
286 ACPI_FUNCTION_TRACE ("acpi_enable_gpe");
287 261
262 ACPI_FUNCTION_TRACE("acpi_enable_gpe");
288 263
289 /* Use semaphore lock if not executing at interrupt level */ 264 /* Use semaphore lock if not executing at interrupt level */
290 265
291 if (flags & ACPI_NOT_ISR) { 266 if (flags & ACPI_NOT_ISR) {
292 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 267 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
293 if (ACPI_FAILURE (status)) { 268 if (ACPI_FAILURE(status)) {
294 return_ACPI_STATUS (status); 269 return_ACPI_STATUS(status);
295 } 270 }
296 } 271 }
297 272
298 /* Ensure that we have a valid GPE number */ 273 /* Ensure that we have a valid GPE number */
299 274
300 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 275 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
301 if (!gpe_event_info) { 276 if (!gpe_event_info) {
302 status = AE_BAD_PARAMETER; 277 status = AE_BAD_PARAMETER;
303 goto unlock_and_exit; 278 goto unlock_and_exit;
@@ -305,16 +280,16 @@ acpi_enable_gpe (
305 280
306 /* Perform the enable */ 281 /* Perform the enable */
307 282
308 status = acpi_ev_enable_gpe (gpe_event_info, TRUE); 283 status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
309 284
310unlock_and_exit: 285 unlock_and_exit:
311 if (flags & ACPI_NOT_ISR) { 286 if (flags & ACPI_NOT_ISR) {
312 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 287 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
313 } 288 }
314 return_ACPI_STATUS (status); 289 return_ACPI_STATUS(status);
315} 290}
316EXPORT_SYMBOL(acpi_enable_gpe);
317 291
292EXPORT_SYMBOL(acpi_enable_gpe);
318 293
319/******************************************************************************* 294/*******************************************************************************
320 * 295 *
@@ -331,46 +306,39 @@ EXPORT_SYMBOL(acpi_enable_gpe);
331 * 306 *
332 ******************************************************************************/ 307 ******************************************************************************/
333 308
334acpi_status 309acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
335acpi_disable_gpe (
336 acpi_handle gpe_device,
337 u32 gpe_number,
338 u32 flags)
339{ 310{
340 acpi_status status = AE_OK; 311 acpi_status status = AE_OK;
341 struct acpi_gpe_event_info *gpe_event_info; 312 struct acpi_gpe_event_info *gpe_event_info;
342
343
344 ACPI_FUNCTION_TRACE ("acpi_disable_gpe");
345 313
314 ACPI_FUNCTION_TRACE("acpi_disable_gpe");
346 315
347 /* Use semaphore lock if not executing at interrupt level */ 316 /* Use semaphore lock if not executing at interrupt level */
348 317
349 if (flags & ACPI_NOT_ISR) { 318 if (flags & ACPI_NOT_ISR) {
350 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 319 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
351 if (ACPI_FAILURE (status)) { 320 if (ACPI_FAILURE(status)) {
352 return_ACPI_STATUS (status); 321 return_ACPI_STATUS(status);
353 } 322 }
354 } 323 }
355 324
356 /* Ensure that we have a valid GPE number */ 325 /* Ensure that we have a valid GPE number */
357 326
358 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 327 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
359 if (!gpe_event_info) { 328 if (!gpe_event_info) {
360 status = AE_BAD_PARAMETER; 329 status = AE_BAD_PARAMETER;
361 goto unlock_and_exit; 330 goto unlock_and_exit;
362 } 331 }
363 332
364 status = acpi_ev_disable_gpe (gpe_event_info); 333 status = acpi_ev_disable_gpe(gpe_event_info);
365 334
366unlock_and_exit: 335 unlock_and_exit:
367 if (flags & ACPI_NOT_ISR) { 336 if (flags & ACPI_NOT_ISR) {
368 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 337 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
369 } 338 }
370 return_ACPI_STATUS (status); 339 return_ACPI_STATUS(status);
371} 340}
372 341
373
374/******************************************************************************* 342/*******************************************************************************
375 * 343 *
376 * FUNCTION: acpi_disable_event 344 * FUNCTION: acpi_disable_event
@@ -384,50 +352,48 @@ unlock_and_exit:
384 * 352 *
385 ******************************************************************************/ 353 ******************************************************************************/
386 354
387acpi_status 355acpi_status acpi_disable_event(u32 event, u32 flags)
388acpi_disable_event (
389 u32 event,
390 u32 flags)
391{ 356{
392 acpi_status status = AE_OK; 357 acpi_status status = AE_OK;
393 u32 value; 358 u32 value;
394
395
396 ACPI_FUNCTION_TRACE ("acpi_disable_event");
397 359
360 ACPI_FUNCTION_TRACE("acpi_disable_event");
398 361
399 /* Decode the Fixed Event */ 362 /* Decode the Fixed Event */
400 363
401 if (event > ACPI_EVENT_MAX) { 364 if (event > ACPI_EVENT_MAX) {
402 return_ACPI_STATUS (AE_BAD_PARAMETER); 365 return_ACPI_STATUS(AE_BAD_PARAMETER);
403 } 366 }
404 367
405 /* 368 /*
406 * Disable the requested fixed event (by writing a zero to the 369 * Disable the requested fixed event (by writing a zero to the
407 * enable register bit) 370 * enable register bit)
408 */ 371 */
409 status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id, 372 status =
410 0, ACPI_MTX_LOCK); 373 acpi_set_register(acpi_gbl_fixed_event_info[event].
411 if (ACPI_FAILURE (status)) { 374 enable_register_id, 0, ACPI_MTX_LOCK);
412 return_ACPI_STATUS (status); 375 if (ACPI_FAILURE(status)) {
376 return_ACPI_STATUS(status);
413 } 377 }
414 378
415 status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id, 379 status =
416 &value, ACPI_MTX_LOCK); 380 acpi_get_register(acpi_gbl_fixed_event_info[event].
417 if (ACPI_FAILURE (status)) { 381 enable_register_id, &value, ACPI_MTX_LOCK);
418 return_ACPI_STATUS (status); 382 if (ACPI_FAILURE(status)) {
383 return_ACPI_STATUS(status);
419 } 384 }
420 385
421 if (value != 0) { 386 if (value != 0) {
422 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 387 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
423 "Could not disable %s events\n", acpi_ut_get_event_name (event))); 388 "Could not disable %s events\n",
424 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); 389 acpi_ut_get_event_name(event)));
390 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
425 } 391 }
426 392
427 return_ACPI_STATUS (status); 393 return_ACPI_STATUS(status);
428} 394}
429EXPORT_SYMBOL(acpi_disable_event);
430 395
396EXPORT_SYMBOL(acpi_disable_event);
431 397
432/******************************************************************************* 398/*******************************************************************************
433 * 399 *
@@ -441,33 +407,30 @@ EXPORT_SYMBOL(acpi_disable_event);
441 * 407 *
442 ******************************************************************************/ 408 ******************************************************************************/
443 409
444acpi_status 410acpi_status acpi_clear_event(u32 event)
445acpi_clear_event (
446 u32 event)
447{ 411{
448 acpi_status status = AE_OK; 412 acpi_status status = AE_OK;
449
450
451 ACPI_FUNCTION_TRACE ("acpi_clear_event");
452 413
414 ACPI_FUNCTION_TRACE("acpi_clear_event");
453 415
454 /* Decode the Fixed Event */ 416 /* Decode the Fixed Event */
455 417
456 if (event > ACPI_EVENT_MAX) { 418 if (event > ACPI_EVENT_MAX) {
457 return_ACPI_STATUS (AE_BAD_PARAMETER); 419 return_ACPI_STATUS(AE_BAD_PARAMETER);
458 } 420 }
459 421
460 /* 422 /*
461 * Clear the requested fixed event (By writing a one to the 423 * Clear the requested fixed event (By writing a one to the
462 * status register bit) 424 * status register bit)
463 */ 425 */
464 status = acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id, 426 status =
465 1, ACPI_MTX_LOCK); 427 acpi_set_register(acpi_gbl_fixed_event_info[event].
428 status_register_id, 1, ACPI_MTX_LOCK);
466 429
467 return_ACPI_STATUS (status); 430 return_ACPI_STATUS(status);
468} 431}
469EXPORT_SYMBOL(acpi_clear_event);
470 432
433EXPORT_SYMBOL(acpi_clear_event);
471 434
472/******************************************************************************* 435/*******************************************************************************
473 * 436 *
@@ -483,46 +446,39 @@ EXPORT_SYMBOL(acpi_clear_event);
483 * 446 *
484 ******************************************************************************/ 447 ******************************************************************************/
485 448
486acpi_status 449acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
487acpi_clear_gpe (
488 acpi_handle gpe_device,
489 u32 gpe_number,
490 u32 flags)
491{ 450{
492 acpi_status status = AE_OK; 451 acpi_status status = AE_OK;
493 struct acpi_gpe_event_info *gpe_event_info; 452 struct acpi_gpe_event_info *gpe_event_info;
494
495
496 ACPI_FUNCTION_TRACE ("acpi_clear_gpe");
497 453
454 ACPI_FUNCTION_TRACE("acpi_clear_gpe");
498 455
499 /* Use semaphore lock if not executing at interrupt level */ 456 /* Use semaphore lock if not executing at interrupt level */
500 457
501 if (flags & ACPI_NOT_ISR) { 458 if (flags & ACPI_NOT_ISR) {
502 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 459 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
503 if (ACPI_FAILURE (status)) { 460 if (ACPI_FAILURE(status)) {
504 return_ACPI_STATUS (status); 461 return_ACPI_STATUS(status);
505 } 462 }
506 } 463 }
507 464
508 /* Ensure that we have a valid GPE number */ 465 /* Ensure that we have a valid GPE number */
509 466
510 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 467 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
511 if (!gpe_event_info) { 468 if (!gpe_event_info) {
512 status = AE_BAD_PARAMETER; 469 status = AE_BAD_PARAMETER;
513 goto unlock_and_exit; 470 goto unlock_and_exit;
514 } 471 }
515 472
516 status = acpi_hw_clear_gpe (gpe_event_info); 473 status = acpi_hw_clear_gpe(gpe_event_info);
517 474
518unlock_and_exit: 475 unlock_and_exit:
519 if (flags & ACPI_NOT_ISR) { 476 if (flags & ACPI_NOT_ISR) {
520 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 477 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
521 } 478 }
522 return_ACPI_STATUS (status); 479 return_ACPI_STATUS(status);
523} 480}
524 481
525
526#ifdef ACPI_FUTURE_USAGE 482#ifdef ACPI_FUTURE_USAGE
527/******************************************************************************* 483/*******************************************************************************
528 * 484 *
@@ -538,36 +494,31 @@ unlock_and_exit:
538 * 494 *
539 ******************************************************************************/ 495 ******************************************************************************/
540 496
541acpi_status 497acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
542acpi_get_event_status (
543 u32 event,
544 acpi_event_status *event_status)
545{ 498{
546 acpi_status status = AE_OK; 499 acpi_status status = AE_OK;
547
548
549 ACPI_FUNCTION_TRACE ("acpi_get_event_status");
550 500
501 ACPI_FUNCTION_TRACE("acpi_get_event_status");
551 502
552 if (!event_status) { 503 if (!event_status) {
553 return_ACPI_STATUS (AE_BAD_PARAMETER); 504 return_ACPI_STATUS(AE_BAD_PARAMETER);
554 } 505 }
555 506
556 /* Decode the Fixed Event */ 507 /* Decode the Fixed Event */
557 508
558 if (event > ACPI_EVENT_MAX) { 509 if (event > ACPI_EVENT_MAX) {
559 return_ACPI_STATUS (AE_BAD_PARAMETER); 510 return_ACPI_STATUS(AE_BAD_PARAMETER);
560 } 511 }
561 512
562 /* Get the status of the requested fixed event */ 513 /* Get the status of the requested fixed event */
563 514
564 status = acpi_get_register (acpi_gbl_fixed_event_info[event].status_register_id, 515 status =
565 event_status, ACPI_MTX_LOCK); 516 acpi_get_register(acpi_gbl_fixed_event_info[event].
517 status_register_id, event_status, ACPI_MTX_LOCK);
566 518
567 return_ACPI_STATUS (status); 519 return_ACPI_STATUS(status);
568} 520}
569 521
570
571/******************************************************************************* 522/*******************************************************************************
572 * 523 *
573 * FUNCTION: acpi_get_gpe_status 524 * FUNCTION: acpi_get_gpe_status
@@ -585,31 +536,26 @@ acpi_get_event_status (
585 ******************************************************************************/ 536 ******************************************************************************/
586 537
587acpi_status 538acpi_status
588acpi_get_gpe_status ( 539acpi_get_gpe_status(acpi_handle gpe_device,
589 acpi_handle gpe_device, 540 u32 gpe_number, u32 flags, acpi_event_status * event_status)
590 u32 gpe_number,
591 u32 flags,
592 acpi_event_status *event_status)
593{ 541{
594 acpi_status status = AE_OK; 542 acpi_status status = AE_OK;
595 struct acpi_gpe_event_info *gpe_event_info; 543 struct acpi_gpe_event_info *gpe_event_info;
596
597
598 ACPI_FUNCTION_TRACE ("acpi_get_gpe_status");
599 544
545 ACPI_FUNCTION_TRACE("acpi_get_gpe_status");
600 546
601 /* Use semaphore lock if not executing at interrupt level */ 547 /* Use semaphore lock if not executing at interrupt level */
602 548
603 if (flags & ACPI_NOT_ISR) { 549 if (flags & ACPI_NOT_ISR) {
604 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 550 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
605 if (ACPI_FAILURE (status)) { 551 if (ACPI_FAILURE(status)) {
606 return_ACPI_STATUS (status); 552 return_ACPI_STATUS(status);
607 } 553 }
608 } 554 }
609 555
610 /* Ensure that we have a valid GPE number */ 556 /* Ensure that we have a valid GPE number */
611 557
612 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 558 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
613 if (!gpe_event_info) { 559 if (!gpe_event_info) {
614 status = AE_BAD_PARAMETER; 560 status = AE_BAD_PARAMETER;
615 goto unlock_and_exit; 561 goto unlock_and_exit;
@@ -617,16 +563,15 @@ acpi_get_gpe_status (
617 563
618 /* Obtain status on the requested GPE number */ 564 /* Obtain status on the requested GPE number */
619 565
620 status = acpi_hw_get_gpe_status (gpe_event_info, event_status); 566 status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
621 567
622unlock_and_exit: 568 unlock_and_exit:
623 if (flags & ACPI_NOT_ISR) { 569 if (flags & ACPI_NOT_ISR) {
624 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 570 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
625 } 571 }
626 return_ACPI_STATUS (status); 572 return_ACPI_STATUS(status);
627} 573}
628#endif /* ACPI_FUTURE_USAGE */ 574#endif /* ACPI_FUTURE_USAGE */
629
630 575
631/******************************************************************************* 576/*******************************************************************************
632 * 577 *
@@ -644,33 +589,27 @@ unlock_and_exit:
644 ******************************************************************************/ 589 ******************************************************************************/
645 590
646acpi_status 591acpi_status
647acpi_install_gpe_block ( 592acpi_install_gpe_block(acpi_handle gpe_device,
648 acpi_handle gpe_device, 593 struct acpi_generic_address *gpe_block_address,
649 struct acpi_generic_address *gpe_block_address, 594 u32 register_count, u32 interrupt_number)
650 u32 register_count,
651 u32 interrupt_number)
652{ 595{
653 acpi_status status; 596 acpi_status status;
654 union acpi_operand_object *obj_desc; 597 union acpi_operand_object *obj_desc;
655 struct acpi_namespace_node *node; 598 struct acpi_namespace_node *node;
656 struct acpi_gpe_block_info *gpe_block; 599 struct acpi_gpe_block_info *gpe_block;
657
658 600
659 ACPI_FUNCTION_TRACE ("acpi_install_gpe_block"); 601 ACPI_FUNCTION_TRACE("acpi_install_gpe_block");
660 602
661 603 if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
662 if ((!gpe_device) || 604 return_ACPI_STATUS(AE_BAD_PARAMETER);
663 (!gpe_block_address) ||
664 (!register_count)) {
665 return_ACPI_STATUS (AE_BAD_PARAMETER);
666 } 605 }
667 606
668 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 607 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
669 if (ACPI_FAILURE (status)) { 608 if (ACPI_FAILURE(status)) {
670 return (status); 609 return (status);
671 } 610 }
672 611
673 node = acpi_ns_map_handle_to_node (gpe_device); 612 node = acpi_ns_map_handle_to_node(gpe_device);
674 if (!node) { 613 if (!node) {
675 status = AE_BAD_PARAMETER; 614 status = AE_BAD_PARAMETER;
676 goto unlock_and_exit; 615 goto unlock_and_exit;
@@ -680,31 +619,33 @@ acpi_install_gpe_block (
680 * For user-installed GPE Block Devices, the gpe_block_base_number 619 * For user-installed GPE Block Devices, the gpe_block_base_number
681 * is always zero 620 * is always zero
682 */ 621 */
683 status = acpi_ev_create_gpe_block (node, gpe_block_address, register_count, 622 status =
684 0, interrupt_number, &gpe_block); 623 acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
685 if (ACPI_FAILURE (status)) { 624 interrupt_number, &gpe_block);
625 if (ACPI_FAILURE(status)) {
686 goto unlock_and_exit; 626 goto unlock_and_exit;
687 } 627 }
688 628
689 /* Get the device_object attached to the node */ 629 /* Get the device_object attached to the node */
690 630
691 obj_desc = acpi_ns_get_attached_object (node); 631 obj_desc = acpi_ns_get_attached_object(node);
692 if (!obj_desc) { 632 if (!obj_desc) {
693 /* No object, create a new one */ 633 /* No object, create a new one */
694 634
695 obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_DEVICE); 635 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
696 if (!obj_desc) { 636 if (!obj_desc) {
697 status = AE_NO_MEMORY; 637 status = AE_NO_MEMORY;
698 goto unlock_and_exit; 638 goto unlock_and_exit;
699 } 639 }
700 640
701 status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_DEVICE); 641 status =
642 acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
702 643
703 /* Remove local reference to the object */ 644 /* Remove local reference to the object */
704 645
705 acpi_ut_remove_reference (obj_desc); 646 acpi_ut_remove_reference(obj_desc);
706 647
707 if (ACPI_FAILURE (status)) { 648 if (ACPI_FAILURE(status)) {
708 goto unlock_and_exit; 649 goto unlock_and_exit;
709 } 650 }
710 } 651 }
@@ -713,13 +654,12 @@ acpi_install_gpe_block (
713 654
714 obj_desc->device.gpe_block = gpe_block; 655 obj_desc->device.gpe_block = gpe_block;
715 656
716 657 unlock_and_exit:
717unlock_and_exit: 658 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
718 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 659 return_ACPI_STATUS(status);
719 return_ACPI_STATUS (status);
720} 660}
721EXPORT_SYMBOL(acpi_install_gpe_block);
722 661
662EXPORT_SYMBOL(acpi_install_gpe_block);
723 663
724/******************************************************************************* 664/*******************************************************************************
725 * 665 *
@@ -733,28 +673,24 @@ EXPORT_SYMBOL(acpi_install_gpe_block);
733 * 673 *
734 ******************************************************************************/ 674 ******************************************************************************/
735 675
736acpi_status 676acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
737acpi_remove_gpe_block (
738 acpi_handle gpe_device)
739{ 677{
740 union acpi_operand_object *obj_desc; 678 union acpi_operand_object *obj_desc;
741 acpi_status status; 679 acpi_status status;
742 struct acpi_namespace_node *node; 680 struct acpi_namespace_node *node;
743
744
745 ACPI_FUNCTION_TRACE ("acpi_remove_gpe_block");
746 681
682 ACPI_FUNCTION_TRACE("acpi_remove_gpe_block");
747 683
748 if (!gpe_device) { 684 if (!gpe_device) {
749 return_ACPI_STATUS (AE_BAD_PARAMETER); 685 return_ACPI_STATUS(AE_BAD_PARAMETER);
750 } 686 }
751 687
752 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 688 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
753 if (ACPI_FAILURE (status)) { 689 if (ACPI_FAILURE(status)) {
754 return (status); 690 return (status);
755 } 691 }
756 692
757 node = acpi_ns_map_handle_to_node (gpe_device); 693 node = acpi_ns_map_handle_to_node(gpe_device);
758 if (!node) { 694 if (!node) {
759 status = AE_BAD_PARAMETER; 695 status = AE_BAD_PARAMETER;
760 goto unlock_and_exit; 696 goto unlock_and_exit;
@@ -762,22 +698,21 @@ acpi_remove_gpe_block (
762 698
763 /* Get the device_object attached to the node */ 699 /* Get the device_object attached to the node */
764 700
765 obj_desc = acpi_ns_get_attached_object (node); 701 obj_desc = acpi_ns_get_attached_object(node);
766 if (!obj_desc || 702 if (!obj_desc || !obj_desc->device.gpe_block) {
767 !obj_desc->device.gpe_block) { 703 return_ACPI_STATUS(AE_NULL_OBJECT);
768 return_ACPI_STATUS (AE_NULL_OBJECT);
769 } 704 }
770 705
771 /* Delete the GPE block (but not the device_object) */ 706 /* Delete the GPE block (but not the device_object) */
772 707
773 status = acpi_ev_delete_gpe_block (obj_desc->device.gpe_block); 708 status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
774 if (ACPI_SUCCESS (status)) { 709 if (ACPI_SUCCESS(status)) {
775 obj_desc->device.gpe_block = NULL; 710 obj_desc->device.gpe_block = NULL;
776 } 711 }
777 712
778unlock_and_exit: 713 unlock_and_exit:
779 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 714 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
780 return_ACPI_STATUS (status); 715 return_ACPI_STATUS(status);
781} 716}
782 717
783EXPORT_SYMBOL(acpi_remove_gpe_block); 718EXPORT_SYMBOL(acpi_remove_gpe_block);
diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c
index d058587b3427..6f28ea2db5ba 100644
--- a/drivers/acpi/events/evxfregn.c
+++ b/drivers/acpi/events/evxfregn.c
@@ -49,8 +49,7 @@
49#include <acpi/acevents.h> 49#include <acpi/acevents.h>
50 50
51#define _COMPONENT ACPI_EVENTS 51#define _COMPONENT ACPI_EVENTS
52 ACPI_MODULE_NAME ("evxfregn") 52ACPI_MODULE_NAME("evxfregn")
53
54 53
55/******************************************************************************* 54/*******************************************************************************
56 * 55 *
@@ -67,36 +66,31 @@
67 * DESCRIPTION: Install a handler for all op_regions of a given space_id. 66 * DESCRIPTION: Install a handler for all op_regions of a given space_id.
68 * 67 *
69 ******************************************************************************/ 68 ******************************************************************************/
70
71acpi_status 69acpi_status
72acpi_install_address_space_handler ( 70acpi_install_address_space_handler(acpi_handle device,
73 acpi_handle device, 71 acpi_adr_space_type space_id,
74 acpi_adr_space_type space_id, 72 acpi_adr_space_handler handler,
75 acpi_adr_space_handler handler, 73 acpi_adr_space_setup setup, void *context)
76 acpi_adr_space_setup setup,
77 void *context)
78{ 74{
79 struct acpi_namespace_node *node; 75 struct acpi_namespace_node *node;
80 acpi_status status; 76 acpi_status status;
81
82
83 ACPI_FUNCTION_TRACE ("acpi_install_address_space_handler");
84 77
78 ACPI_FUNCTION_TRACE("acpi_install_address_space_handler");
85 79
86 /* Parameter validation */ 80 /* Parameter validation */
87 81
88 if (!device) { 82 if (!device) {
89 return_ACPI_STATUS (AE_BAD_PARAMETER); 83 return_ACPI_STATUS(AE_BAD_PARAMETER);
90 } 84 }
91 85
92 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 86 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
93 if (ACPI_FAILURE (status)) { 87 if (ACPI_FAILURE(status)) {
94 return_ACPI_STATUS (status); 88 return_ACPI_STATUS(status);
95 } 89 }
96 90
97 /* Convert and validate the device handle */ 91 /* Convert and validate the device handle */
98 92
99 node = acpi_ns_map_handle_to_node (device); 93 node = acpi_ns_map_handle_to_node(device);
100 if (!node) { 94 if (!node) {
101 status = AE_BAD_PARAMETER; 95 status = AE_BAD_PARAMETER;
102 goto unlock_and_exit; 96 goto unlock_and_exit;
@@ -104,21 +98,23 @@ acpi_install_address_space_handler (
104 98
105 /* Install the handler for all Regions for this Space ID */ 99 /* Install the handler for all Regions for this Space ID */
106 100
107 status = acpi_ev_install_space_handler (node, space_id, handler, setup, context); 101 status =
108 if (ACPI_FAILURE (status)) { 102 acpi_ev_install_space_handler(node, space_id, handler, setup,
103 context);
104 if (ACPI_FAILURE(status)) {
109 goto unlock_and_exit; 105 goto unlock_and_exit;
110 } 106 }
111 107
112 /* Run all _REG methods for this address space */ 108 /* Run all _REG methods for this address space */
113 109
114 status = acpi_ev_execute_reg_methods (node, space_id); 110 status = acpi_ev_execute_reg_methods(node, space_id);
115 111
116unlock_and_exit: 112 unlock_and_exit:
117 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 113 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
118 return_ACPI_STATUS (status); 114 return_ACPI_STATUS(status);
119} 115}
120EXPORT_SYMBOL(acpi_install_address_space_handler);
121 116
117EXPORT_SYMBOL(acpi_install_address_space_handler);
122 118
123/******************************************************************************* 119/*******************************************************************************
124 * 120 *
@@ -135,36 +131,33 @@ EXPORT_SYMBOL(acpi_install_address_space_handler);
135 ******************************************************************************/ 131 ******************************************************************************/
136 132
137acpi_status 133acpi_status
138acpi_remove_address_space_handler ( 134acpi_remove_address_space_handler(acpi_handle device,
139 acpi_handle device, 135 acpi_adr_space_type space_id,
140 acpi_adr_space_type space_id, 136 acpi_adr_space_handler handler)
141 acpi_adr_space_handler handler)
142{ 137{
143 union acpi_operand_object *obj_desc; 138 union acpi_operand_object *obj_desc;
144 union acpi_operand_object *handler_obj; 139 union acpi_operand_object *handler_obj;
145 union acpi_operand_object *region_obj; 140 union acpi_operand_object *region_obj;
146 union acpi_operand_object **last_obj_ptr; 141 union acpi_operand_object **last_obj_ptr;
147 struct acpi_namespace_node *node; 142 struct acpi_namespace_node *node;
148 acpi_status status; 143 acpi_status status;
149
150
151 ACPI_FUNCTION_TRACE ("acpi_remove_address_space_handler");
152 144
145 ACPI_FUNCTION_TRACE("acpi_remove_address_space_handler");
153 146
154 /* Parameter validation */ 147 /* Parameter validation */
155 148
156 if (!device) { 149 if (!device) {
157 return_ACPI_STATUS (AE_BAD_PARAMETER); 150 return_ACPI_STATUS(AE_BAD_PARAMETER);
158 } 151 }
159 152
160 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 153 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
161 if (ACPI_FAILURE (status)) { 154 if (ACPI_FAILURE(status)) {
162 return_ACPI_STATUS (status); 155 return_ACPI_STATUS(status);
163 } 156 }
164 157
165 /* Convert and validate the device handle */ 158 /* Convert and validate the device handle */
166 159
167 node = acpi_ns_map_handle_to_node (device); 160 node = acpi_ns_map_handle_to_node(device);
168 if (!node) { 161 if (!node) {
169 status = AE_BAD_PARAMETER; 162 status = AE_BAD_PARAMETER;
170 goto unlock_and_exit; 163 goto unlock_and_exit;
@@ -172,7 +165,7 @@ acpi_remove_address_space_handler (
172 165
173 /* Make sure the internal object exists */ 166 /* Make sure the internal object exists */
174 167
175 obj_desc = acpi_ns_get_attached_object (node); 168 obj_desc = acpi_ns_get_attached_object(node);
176 if (!obj_desc) { 169 if (!obj_desc) {
177 status = AE_NOT_EXIST; 170 status = AE_NOT_EXIST;
178 goto unlock_and_exit; 171 goto unlock_and_exit;
@@ -188,10 +181,11 @@ acpi_remove_address_space_handler (
188 if (handler_obj->address_space.space_id == space_id) { 181 if (handler_obj->address_space.space_id == space_id) {
189 /* Matched space_id, first dereference this in the Regions */ 182 /* Matched space_id, first dereference this in the Regions */
190 183
191 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 184 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
192 "Removing address handler %p(%p) for region %s on Device %p(%p)\n", 185 "Removing address handler %p(%p) for region %s on Device %p(%p)\n",
193 handler_obj, handler, acpi_ut_get_region_name (space_id), 186 handler_obj, handler,
194 node, obj_desc)); 187 acpi_ut_get_region_name(space_id),
188 node, obj_desc));
195 189
196 region_obj = handler_obj->address_space.region_list; 190 region_obj = handler_obj->address_space.region_list;
197 191
@@ -205,13 +199,14 @@ acpi_remove_address_space_handler (
205 * The region is just inaccessible as indicated to 199 * The region is just inaccessible as indicated to
206 * the _REG method 200 * the _REG method
207 */ 201 */
208 acpi_ev_detach_region (region_obj, TRUE); 202 acpi_ev_detach_region(region_obj, TRUE);
209 203
210 /* 204 /*
211 * Walk the list: Just grab the head because the 205 * Walk the list: Just grab the head because the
212 * detach_region removed the previous head. 206 * detach_region removed the previous head.
213 */ 207 */
214 region_obj = handler_obj->address_space.region_list; 208 region_obj =
209 handler_obj->address_space.region_list;
215 210
216 } 211 }
217 212
@@ -221,7 +216,7 @@ acpi_remove_address_space_handler (
221 216
222 /* Now we can delete the handler object */ 217 /* Now we can delete the handler object */
223 218
224 acpi_ut_remove_reference (handler_obj); 219 acpi_ut_remove_reference(handler_obj);
225 goto unlock_and_exit; 220 goto unlock_and_exit;
226 } 221 }
227 222
@@ -233,15 +228,16 @@ acpi_remove_address_space_handler (
233 228
234 /* The handler does not exist */ 229 /* The handler does not exist */
235 230
236 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, 231 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
237 "Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n", 232 "Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n",
238 handler, acpi_ut_get_region_name (space_id), space_id, node, obj_desc)); 233 handler, acpi_ut_get_region_name(space_id), space_id,
234 node, obj_desc));
239 235
240 status = AE_NOT_EXIST; 236 status = AE_NOT_EXIST;
241 237
242unlock_and_exit: 238 unlock_and_exit:
243 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 239 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
244 return_ACPI_STATUS (status); 240 return_ACPI_STATUS(status);
245} 241}
246EXPORT_SYMBOL(acpi_remove_address_space_handler);
247 242
243EXPORT_SYMBOL(acpi_remove_address_space_handler);