aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ec.c
diff options
context:
space:
mode:
authorAlexey Starikovskiy <alexey.y.starikovskiy@intel.com>2006-12-07 10:42:17 -0500
committerLen Brown <len.brown@intel.com>2006-12-08 02:56:09 -0500
commit6ccedb10e39c34a4cb68f6c8dae67ecdd3e0b138 (patch)
tree803f7366f7235125e89d9d4537e4d943cb097e7a /drivers/acpi/ec.c
parent3261ff4db3a33ac7e1b9ed98e905663845cadbc6 (diff)
ACPI: ec: Lindent once again
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r--drivers/acpi/ec.c171
1 files changed, 76 insertions, 95 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e05bb148754c..d713f769b72d 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -45,36 +45,33 @@ ACPI_MODULE_NAME("acpi_ec")
45#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" 45#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver"
46#define ACPI_EC_DEVICE_NAME "Embedded Controller" 46#define ACPI_EC_DEVICE_NAME "Embedded Controller"
47#define ACPI_EC_FILE_INFO "info" 47#define ACPI_EC_FILE_INFO "info"
48
49#undef PREFIX 48#undef PREFIX
50#define PREFIX "ACPI: EC: " 49#define PREFIX "ACPI: EC: "
51
52/* EC status register */ 50/* EC status register */
53#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ 51#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
54#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ 52#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
55#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ 53#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
56#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ 54#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
57
58/* EC commands */ 55/* EC commands */
59enum ec_command { 56enum ec_command {
60 ACPI_EC_COMMAND_READ = 0x80, 57 ACPI_EC_COMMAND_READ = 0x80,
61 ACPI_EC_COMMAND_WRITE = 0x81, 58 ACPI_EC_COMMAND_WRITE = 0x81,
62 ACPI_EC_BURST_ENABLE = 0x82, 59 ACPI_EC_BURST_ENABLE = 0x82,
63 ACPI_EC_BURST_DISABLE = 0x83, 60 ACPI_EC_BURST_DISABLE = 0x83,
64 ACPI_EC_COMMAND_QUERY = 0x84, 61 ACPI_EC_COMMAND_QUERY = 0x84,
65}; 62};
66/* EC events */ 63/* EC events */
67enum ec_event { 64enum ec_event {
68 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ 65 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
69 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ 66 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
70}; 67};
71 68
72#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ 69#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
73#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 70#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
74 71
75static enum ec_mode { 72static enum ec_mode {
76 EC_INTR = 1, /* Output buffer full */ 73 EC_INTR = 1, /* Output buffer full */
77 EC_POLL, /* Input buffer empty */ 74 EC_POLL, /* Input buffer empty */
78} acpi_ec_mode = EC_INTR; 75} acpi_ec_mode = EC_INTR;
79 76
80static int acpi_ec_remove(struct acpi_device *device, int type); 77static int acpi_ec_remove(struct acpi_device *device, int type);
@@ -167,7 +164,7 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event)
167 } else { 164 } else {
168 printk(KERN_ERR PREFIX "acpi_ec_wait timeout," 165 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
169 " status = %d, expect_event = %d\n", 166 " status = %d, expect_event = %d\n",
170 acpi_ec_read_status(ec), event); 167 acpi_ec_read_status(ec), event);
171 } 168 }
172 } 169 }
173 170
@@ -184,7 +181,6 @@ int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
184 u8 tmp = 0; 181 u8 tmp = 0;
185 u8 status = 0; 182 u8 status = 0;
186 183
187
188 status = acpi_ec_read_status(ec); 184 status = acpi_ec_read_status(ec);
189 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { 185 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
190 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 186 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
@@ -200,7 +196,7 @@ int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
200 196
201 atomic_set(&ec->leaving_burst, 0); 197 atomic_set(&ec->leaving_burst, 0);
202 return 0; 198 return 0;
203 end: 199 end:
204 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode")); 200 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
205 return -1; 201 return -1;
206} 202}
@@ -209,26 +205,25 @@ int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
209{ 205{
210 u8 status = 0; 206 u8 status = 0;
211 207
212
213 status = acpi_ec_read_status(ec); 208 status = acpi_ec_read_status(ec);
214 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ 209 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) {
215 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 210 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
216 if(status) 211 if (status)
217 goto end; 212 goto end;
218 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE); 213 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
219 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 214 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
220 } 215 }
221 atomic_set(&ec->leaving_burst, 1); 216 atomic_set(&ec->leaving_burst, 1);
222 return 0; 217 return 0;
223 end: 218 end:
224 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode")); 219 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
225 return -1; 220 return -1;
226} 221}
227#endif /* ACPI_FUTURE_USAGE */ 222#endif /* ACPI_FUTURE_USAGE */
228 223
229static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, 224static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
230 const u8 *wdata, unsigned wdata_len, 225 const u8 * wdata, unsigned wdata_len,
231 u8 *rdata, unsigned rdata_len) 226 u8 * rdata, unsigned rdata_len)
232{ 227{
233 int result = 0; 228 int result = 0;
234 229
@@ -237,8 +232,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
237 for (; wdata_len > 0; --wdata_len) { 232 for (; wdata_len > 0; --wdata_len) {
238 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 233 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
239 if (result) { 234 if (result) {
240 printk(KERN_ERR PREFIX "write_cmd timeout, command = %d\n", 235 printk(KERN_ERR PREFIX
241 command); 236 "write_cmd timeout, command = %d\n", command);
242 goto end; 237 goto end;
243 } 238 }
244 acpi_ec_write_data(ec, *(wdata++)); 239 acpi_ec_write_data(ec, *(wdata++));
@@ -247,8 +242,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
247 if (!rdata_len) { 242 if (!rdata_len) {
248 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 243 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
249 if (result) { 244 if (result) {
250 printk(KERN_ERR PREFIX "finish-write timeout, command = %d\n", 245 printk(KERN_ERR PREFIX
251 command); 246 "finish-write timeout, command = %d\n", command);
252 goto end; 247 goto end;
253 } 248 }
254 } else if (command == ACPI_EC_COMMAND_QUERY) { 249 } else if (command == ACPI_EC_COMMAND_QUERY) {
@@ -259,7 +254,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
259 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1); 254 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
260 if (result) { 255 if (result) {
261 printk(KERN_ERR PREFIX "read timeout, command = %d\n", 256 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
262 command); 257 command);
263 goto end; 258 goto end;
264 } 259 }
265 260
@@ -270,8 +265,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
270} 265}
271 266
272static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, 267static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
273 const u8 *wdata, unsigned wdata_len, 268 const u8 * wdata, unsigned wdata_len,
274 u8 *rdata, unsigned rdata_len) 269 u8 * rdata, unsigned rdata_len)
275{ 270{
276 int status; 271 int status;
277 u32 glk; 272 u32 glk;
@@ -279,8 +274,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
279 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata)) 274 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
280 return -EINVAL; 275 return -EINVAL;
281 276
282 if (rdata) 277 if (rdata)
283 memset(rdata, 0, rdata_len); 278 memset(rdata, 0, rdata_len);
284 279
285 mutex_lock(&ec->lock); 280 mutex_lock(&ec->lock);
286 if (ec->global_lock) { 281 if (ec->global_lock) {
@@ -294,15 +289,16 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
294 289
295 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 290 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
296 if (status) { 291 if (status) {
297 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n"); 292 printk(KERN_DEBUG PREFIX
293 "input buffer is not empty, aborting transaction\n");
298 goto end; 294 goto end;
299 } 295 }
300 296
301 status = acpi_ec_transaction_unlocked(ec, command, 297 status = acpi_ec_transaction_unlocked(ec, command,
302 wdata, wdata_len, 298 wdata, wdata_len,
303 rdata, rdata_len); 299 rdata, rdata_len);
304 300
305end: 301 end:
306 302
307 if (ec->global_lock) 303 if (ec->global_lock)
308 acpi_release_global_lock(glk); 304 acpi_release_global_lock(glk);
@@ -311,7 +307,7 @@ end:
311 return status; 307 return status;
312} 308}
313 309
314static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data) 310static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
315{ 311{
316 int result; 312 int result;
317 u8 d; 313 u8 d;
@@ -324,15 +320,15 @@ static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data)
324 320
325static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) 321static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
326{ 322{
327 u8 wdata[2] = { address, data }; 323 u8 wdata[2] = { address, data };
328 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE, 324 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
329 wdata, 2, NULL, 0); 325 wdata, 2, NULL, 0);
330} 326}
331 327
332/* 328/*
333 * Externally callable EC access functions. For now, assume 1 EC only 329 * Externally callable EC access functions. For now, assume 1 EC only
334 */ 330 */
335int ec_read(u8 addr, u8 *val) 331int ec_read(u8 addr, u8 * val)
336{ 332{
337 struct acpi_ec *ec; 333 struct acpi_ec *ec;
338 int err; 334 int err;
@@ -372,8 +368,8 @@ int ec_write(u8 addr, u8 val)
372EXPORT_SYMBOL(ec_write); 368EXPORT_SYMBOL(ec_write);
373 369
374extern int ec_transaction(u8 command, 370extern int ec_transaction(u8 command,
375 const u8 *wdata, unsigned wdata_len, 371 const u8 * wdata, unsigned wdata_len,
376 u8 *rdata, unsigned rdata_len) 372 u8 * rdata, unsigned rdata_len)
377{ 373{
378 struct acpi_ec *ec; 374 struct acpi_ec *ec;
379 375
@@ -388,29 +384,29 @@ extern int ec_transaction(u8 command,
388 384
389EXPORT_SYMBOL(ec_transaction); 385EXPORT_SYMBOL(ec_transaction);
390 386
391static int acpi_ec_query(struct acpi_ec *ec, u8 *data) 387static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
392{ 388{
393 int result; 389 int result;
394 u8 d; 390 u8 d;
395 391
396 if (!ec || !data) 392 if (!ec || !data)
397 return -EINVAL; 393 return -EINVAL;
398 394
399 /* 395 /*
400 * Query the EC to find out which _Qxx method we need to evaluate. 396 * Query the EC to find out which _Qxx method we need to evaluate.
401 * Note that successful completion of the query causes the ACPI_EC_SCI 397 * Note that successful completion of the query causes the ACPI_EC_SCI
402 * bit to be cleared (and thus clearing the interrupt source). 398 * bit to be cleared (and thus clearing the interrupt source).
403 */ 399 */
404 400
405 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1); 401 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
406 if (result) 402 if (result)
407 return result; 403 return result;
408 404
409 if (!d) 405 if (!d)
410 return -ENODATA; 406 return -ENODATA;
411 407
412 *data = d; 408 *data = d;
413 return 0; 409 return 0;
414} 410}
415 411
416/* -------------------------------------------------------------------------- 412/* --------------------------------------------------------------------------
@@ -439,7 +435,6 @@ static u32 acpi_ec_gpe_handler(void *data)
439 u8 value; 435 u8 value;
440 struct acpi_ec *ec = (struct acpi_ec *)data; 436 struct acpi_ec *ec = (struct acpi_ec *)data;
441 437
442
443 if (acpi_ec_mode == EC_INTR) { 438 if (acpi_ec_mode == EC_INTR) {
444 wake_up(&ec->wait); 439 wake_up(&ec->wait);
445 } 440 }
@@ -447,7 +442,9 @@ static u32 acpi_ec_gpe_handler(void *data)
447 value = acpi_ec_read_status(ec); 442 value = acpi_ec_read_status(ec);
448 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) { 443 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
449 atomic_set(&ec->query_pending, 1); 444 atomic_set(&ec->query_pending, 1);
450 status = acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec); 445 status =
446 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query,
447 ec);
451 } 448 }
452 449
453 return status == AE_OK ? 450 return status == AE_OK ?
@@ -485,7 +482,6 @@ acpi_ec_space_handler(u32 function,
485 acpi_integer f_v = 0; 482 acpi_integer f_v = 0;
486 int i = 0; 483 int i = 0;
487 484
488
489 if ((address > 0xFF) || !value || !handler_context) 485 if ((address > 0xFF) || !value || !handler_context)
490 return AE_BAD_PARAMETER; 486 return AE_BAD_PARAMETER;
491 487
@@ -499,7 +495,7 @@ acpi_ec_space_handler(u32 function,
499 switch (function) { 495 switch (function) {
500 case ACPI_READ: 496 case ACPI_READ:
501 temp = 0; 497 temp = 0;
502 result = acpi_ec_read(ec, (u8) address, (u8 *) &temp); 498 result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
503 break; 499 break;
504 case ACPI_WRITE: 500 case ACPI_WRITE:
505 result = acpi_ec_write(ec, (u8) address, (u8) temp); 501 result = acpi_ec_write(ec, (u8) address, (u8) temp);
@@ -552,15 +548,12 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset)
552{ 548{
553 struct acpi_ec *ec = (struct acpi_ec *)seq->private; 549 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
554 550
555
556 if (!ec) 551 if (!ec)
557 goto end; 552 goto end;
558 553
559 seq_printf(seq, "gpe: 0x%02x\n", 554 seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe);
560 (u32) ec->gpe);
561 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 555 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
562 (u32) ec->command_addr, 556 (u32) ec->command_addr, (u32) ec->data_addr);
563 (u32) ec->data_addr);
564 seq_printf(seq, "use global lock: %s\n", 557 seq_printf(seq, "use global lock: %s\n",
565 ec->global_lock ? "yes" : "no"); 558 ec->global_lock ? "yes" : "no");
566 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 559 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
@@ -586,7 +579,6 @@ static int acpi_ec_add_fs(struct acpi_device *device)
586{ 579{
587 struct proc_dir_entry *entry = NULL; 580 struct proc_dir_entry *entry = NULL;
588 581
589
590 if (!acpi_device_dir(device)) { 582 if (!acpi_device_dir(device)) {
591 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 583 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
592 acpi_ec_dir); 584 acpi_ec_dir);
@@ -629,7 +621,6 @@ static int acpi_ec_add(struct acpi_device *device)
629 acpi_status status = AE_OK; 621 acpi_status status = AE_OK;
630 struct acpi_ec *ec = NULL; 622 struct acpi_ec *ec = NULL;
631 623
632
633 if (!device) 624 if (!device)
634 return -EINVAL; 625 return -EINVAL;
635 626
@@ -651,8 +642,7 @@ static int acpi_ec_add(struct acpi_device *device)
651 acpi_driver_data(device) = ec; 642 acpi_driver_data(device) = ec;
652 643
653 /* Use the global lock for all EC transactions? */ 644 /* Use the global lock for all EC transactions? */
654 acpi_evaluate_integer(ec->handle, "_GLK", NULL, 645 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock);
655 &ec->global_lock);
656 646
657 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: 647 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
658 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ 648 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
@@ -669,11 +659,10 @@ static int acpi_ec_add(struct acpi_device *device)
669 659
670 /* Get GPE bit assignment (EC events). */ 660 /* Get GPE bit assignment (EC events). */
671 /* TODO: Add support for _GPE returning a package */ 661 /* TODO: Add support for _GPE returning a package */
672 status = 662 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe);
673 acpi_evaluate_integer(ec->handle, "_GPE", NULL,
674 &ec->gpe);
675 if (ACPI_FAILURE(status)) { 663 if (ACPI_FAILURE(status)) {
676 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment")); 664 ACPI_EXCEPTION((AE_INFO, status,
665 "Obtaining GPE bit assignment"));
677 result = -ENODEV; 666 result = -ENODEV;
678 goto end; 667 goto end;
679 } 668 }
@@ -683,13 +672,13 @@ static int acpi_ec_add(struct acpi_device *device)
683 goto end; 672 goto end;
684 673
685 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.", 674 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
686 acpi_device_name(device), acpi_device_bid(device), 675 acpi_device_name(device), acpi_device_bid(device),
687 (u32) ec->gpe)); 676 (u32) ec->gpe));
688 677
689 if (!first_ec) 678 if (!first_ec)
690 first_ec = device; 679 first_ec = device;
691 680
692 end: 681 end:
693 if (result) 682 if (result)
694 kfree(ec); 683 kfree(ec);
695 684
@@ -700,7 +689,6 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
700{ 689{
701 struct acpi_ec *ec = NULL; 690 struct acpi_ec *ec = NULL;
702 691
703
704 if (!device) 692 if (!device)
705 return -EINVAL; 693 return -EINVAL;
706 694
@@ -743,7 +731,6 @@ static int acpi_ec_start(struct acpi_device *device)
743 acpi_status status = AE_OK; 731 acpi_status status = AE_OK;
744 struct acpi_ec *ec = NULL; 732 struct acpi_ec *ec = NULL;
745 733
746
747 if (!device) 734 if (!device)
748 return -EINVAL; 735 return -EINVAL;
749 736
@@ -783,8 +770,7 @@ static int acpi_ec_start(struct acpi_device *device)
783 &acpi_ec_space_handler, 770 &acpi_ec_space_handler,
784 &acpi_ec_space_setup, ec); 771 &acpi_ec_space_setup, ec);
785 if (ACPI_FAILURE(status)) { 772 if (ACPI_FAILURE(status)) {
786 acpi_remove_gpe_handler(NULL, ec->gpe, 773 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
787 &acpi_ec_gpe_handler);
788 return -ENODEV; 774 return -ENODEV;
789 } 775 }
790 776
@@ -796,7 +782,6 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
796 acpi_status status = AE_OK; 782 acpi_status status = AE_OK;
797 struct acpi_ec *ec = NULL; 783 struct acpi_ec *ec = NULL;
798 784
799
800 if (!device) 785 if (!device)
801 return -EINVAL; 786 return -EINVAL;
802 787
@@ -808,9 +793,7 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
808 if (ACPI_FAILURE(status)) 793 if (ACPI_FAILURE(status))
809 return -ENODEV; 794 return -ENODEV;
810 795
811 status = 796 status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
812 acpi_remove_gpe_handler(NULL, ec->gpe,
813 &acpi_ec_gpe_handler);
814 if (ACPI_FAILURE(status)) 797 if (ACPI_FAILURE(status))
815 return -ENODEV; 798 return -ENODEV;
816 799
@@ -835,16 +818,15 @@ acpi_fake_ecdt_callback(acpi_handle handle,
835 ec_ecdt->uid = -1; 818 ec_ecdt->uid = -1;
836 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid); 819 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
837 820
838 status = 821 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe);
839 acpi_evaluate_integer(handle, "_GPE", NULL,
840 &ec_ecdt->gpe);
841 if (ACPI_FAILURE(status)) 822 if (ACPI_FAILURE(status))
842 return status; 823 return status;
843 ec_ecdt->global_lock = TRUE; 824 ec_ecdt->global_lock = TRUE;
844 ec_ecdt->handle = handle; 825 ec_ecdt->handle = handle;
845 826
846 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx", 827 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
847 ec_ecdt->gpe, ec_ecdt->command_addr, ec_ecdt->data_addr)); 828 ec_ecdt->gpe, ec_ecdt->command_addr,
829 ec_ecdt->data_addr));
848 830
849 return AE_CTRL_TERMINATE; 831 return AE_CTRL_TERMINATE;
850} 832}
@@ -883,7 +865,7 @@ static int __init acpi_ec_fake_ecdt(void)
883 goto error; 865 goto error;
884 } 866 }
885 return 0; 867 return 0;
886 error: 868 error:
887 return ret; 869 return ret;
888} 870}
889 871
@@ -919,14 +901,13 @@ static int __init acpi_ec_get_real_ecdt(void)
919 ec_ecdt->global_lock = TRUE; 901 ec_ecdt->global_lock = TRUE;
920 ec_ecdt->uid = ecdt_ptr->uid; 902 ec_ecdt->uid = ecdt_ptr->uid;
921 903
922 status = 904 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
923 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
924 if (ACPI_FAILURE(status)) { 905 if (ACPI_FAILURE(status)) {
925 goto error; 906 goto error;
926 } 907 }
927 908
928 return 0; 909 return 0;
929 error: 910 error:
930 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT")); 911 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
931 kfree(ec_ecdt); 912 kfree(ec_ecdt);
932 ec_ecdt = NULL; 913 ec_ecdt = NULL;
@@ -986,7 +967,6 @@ static int __init acpi_ec_init(void)
986{ 967{
987 int result = 0; 968 int result = 0;
988 969
989
990 if (acpi_disabled) 970 if (acpi_disabled)
991 return 0; 971 return 0;
992 972
@@ -1039,7 +1019,8 @@ static int __init acpi_ec_set_intr_mode(char *str)
1039 acpi_ec_mode = EC_POLL; 1019 acpi_ec_mode = EC_POLL;
1040 } 1020 }
1041 acpi_ec_driver.ops.add = acpi_ec_add; 1021 acpi_ec_driver.ops.add = acpi_ec_add;
1042 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling")); 1022 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n",
1023 intr ? "interrupt" : "polling"));
1043 1024
1044 return 1; 1025 return 1;
1045} 1026}