aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2014-10-14 02:24:01 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-10-20 18:44:54 -0400
commit7a73e60e398a61612651d503aef9c81260d33918 (patch)
treefec2e3776da0868b9f8f5e5928c1ca140fa38839
parentd3090b6a6cfa6c7a762d6c13340170ca072b2b81 (diff)
ACPI / EC: Cleanup coding style.
This patch cleans up the following coding style issues that are detected by scripts/checkpatch.pl: ERROR: code indent should use tabs where possible ERROR: "foo * bar" should be "foo *bar" WARNING: Missing a blank line after declarations WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable WARNING: void function return statements are not generally useful WARNING: else is not generally useful after a break or return WARNING: break is not useful after a goto or return WARNING: braces {} are not necessary for single statement blocks WARNING: line over 80 characters WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt No functional changes. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/ec.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index d0247d38d96f..3d304ff7f095 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -128,12 +128,13 @@ static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */
128static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ 128static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
129 129
130/* -------------------------------------------------------------------------- 130/* --------------------------------------------------------------------------
131 Transaction Management 131 * Transaction Management
132 -------------------------------------------------------------------------- */ 132 * -------------------------------------------------------------------------- */
133 133
134static inline u8 acpi_ec_read_status(struct acpi_ec *ec) 134static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
135{ 135{
136 u8 x = inb(ec->command_addr); 136 u8 x = inb(ec->command_addr);
137
137 pr_debug("EC_SC(R) = 0x%2.2x " 138 pr_debug("EC_SC(R) = 0x%2.2x "
138 "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n", 139 "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n",
139 x, 140 x,
@@ -148,6 +149,7 @@ static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
148static inline u8 acpi_ec_read_data(struct acpi_ec *ec) 149static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
149{ 150{
150 u8 x = inb(ec->data_addr); 151 u8 x = inb(ec->data_addr);
152
151 pr_debug("EC_DATA(R) = 0x%2.2x\n", x); 153 pr_debug("EC_DATA(R) = 0x%2.2x\n", x);
152 return x; 154 return x;
153} 155}
@@ -189,6 +191,7 @@ static int ec_transaction_completed(struct acpi_ec *ec)
189{ 191{
190 unsigned long flags; 192 unsigned long flags;
191 int ret = 0; 193 int ret = 0;
194
192 spin_lock_irqsave(&ec->lock, flags); 195 spin_lock_irqsave(&ec->lock, flags);
193 if (ec->curr && (ec->curr->flags & ACPI_EC_COMMAND_COMPLETE)) 196 if (ec->curr && (ec->curr->flags & ACPI_EC_COMMAND_COMPLETE))
194 ret = 1; 197 ret = 1;
@@ -288,6 +291,7 @@ static int ec_poll(struct acpi_ec *ec)
288{ 291{
289 unsigned long flags; 292 unsigned long flags;
290 int repeat = 5; /* number of command restarts */ 293 int repeat = 5; /* number of command restarts */
294
291 while (repeat--) { 295 while (repeat--) {
292 unsigned long delay = jiffies + 296 unsigned long delay = jiffies +
293 msecs_to_jiffies(ec_delay); 297 msecs_to_jiffies(ec_delay);
@@ -320,6 +324,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
320{ 324{
321 unsigned long tmp; 325 unsigned long tmp;
322 int ret = 0; 326 int ret = 0;
327
323 if (EC_FLAGS_MSI) 328 if (EC_FLAGS_MSI)
324 udelay(ACPI_EC_MSI_UDELAY); 329 udelay(ACPI_EC_MSI_UDELAY);
325 /* start transaction */ 330 /* start transaction */
@@ -347,6 +352,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
347{ 352{
348 int status; 353 int status;
349 u32 glk; 354 u32 glk;
355
350 if (!ec || (!t) || (t->wlen && !t->wdata) || (t->rlen && !t->rdata)) 356 if (!ec || (!t) || (t->wlen && !t->wdata) || (t->rlen && !t->rdata))
351 return -EINVAL; 357 return -EINVAL;
352 if (t->rdata) 358 if (t->rdata)
@@ -410,7 +416,7 @@ static int acpi_ec_burst_disable(struct acpi_ec *ec)
410 acpi_ec_transaction(ec, &t) : 0; 416 acpi_ec_transaction(ec, &t) : 0;
411} 417}
412 418
413static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) 419static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data)
414{ 420{
415 int result; 421 int result;
416 u8 d; 422 u8 d;
@@ -446,10 +452,9 @@ int ec_read(u8 addr, u8 *val)
446 if (!err) { 452 if (!err) {
447 *val = temp_data; 453 *val = temp_data;
448 return 0; 454 return 0;
449 } else 455 }
450 return err; 456 return err;
451} 457}
452
453EXPORT_SYMBOL(ec_read); 458EXPORT_SYMBOL(ec_read);
454 459
455int ec_write(u8 addr, u8 val) 460int ec_write(u8 addr, u8 val)
@@ -463,22 +468,21 @@ int ec_write(u8 addr, u8 val)
463 468
464 return err; 469 return err;
465} 470}
466
467EXPORT_SYMBOL(ec_write); 471EXPORT_SYMBOL(ec_write);
468 472
469int ec_transaction(u8 command, 473int ec_transaction(u8 command,
470 const u8 * wdata, unsigned wdata_len, 474 const u8 *wdata, unsigned wdata_len,
471 u8 * rdata, unsigned rdata_len) 475 u8 *rdata, unsigned rdata_len)
472{ 476{
473 struct transaction t = {.command = command, 477 struct transaction t = {.command = command,
474 .wdata = wdata, .rdata = rdata, 478 .wdata = wdata, .rdata = rdata,
475 .wlen = wdata_len, .rlen = rdata_len}; 479 .wlen = wdata_len, .rlen = rdata_len};
480
476 if (!first_ec) 481 if (!first_ec)
477 return -ENODEV; 482 return -ENODEV;
478 483
479 return acpi_ec_transaction(first_ec, &t); 484 return acpi_ec_transaction(first_ec, &t);
480} 485}
481
482EXPORT_SYMBOL(ec_transaction); 486EXPORT_SYMBOL(ec_transaction);
483 487
484/* Get the handle to the EC device */ 488/* Get the handle to the EC device */
@@ -488,7 +492,6 @@ acpi_handle ec_get_handle(void)
488 return NULL; 492 return NULL;
489 return first_ec->handle; 493 return first_ec->handle;
490} 494}
491
492EXPORT_SYMBOL(ec_get_handle); 495EXPORT_SYMBOL(ec_get_handle);
493 496
494/* 497/*
@@ -552,13 +555,14 @@ void acpi_ec_unblock_transactions_early(void)
552 clear_bit(EC_FLAGS_BLOCKED, &first_ec->flags); 555 clear_bit(EC_FLAGS_BLOCKED, &first_ec->flags);
553} 556}
554 557
555static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data) 558static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 *data)
556{ 559{
557 int result; 560 int result;
558 u8 d; 561 u8 d;
559 struct transaction t = {.command = ACPI_EC_COMMAND_QUERY, 562 struct transaction t = {.command = ACPI_EC_COMMAND_QUERY,
560 .wdata = NULL, .rdata = &d, 563 .wdata = NULL, .rdata = &d,
561 .wlen = 0, .rlen = 1}; 564 .wlen = 0, .rlen = 1};
565
562 if (!ec || !data) 566 if (!ec || !data)
563 return -EINVAL; 567 return -EINVAL;
564 /* 568 /*
@@ -584,6 +588,7 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
584{ 588{
585 struct acpi_ec_query_handler *handler = 589 struct acpi_ec_query_handler *handler =
586 kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL); 590 kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
591
587 if (!handler) 592 if (!handler)
588 return -ENOMEM; 593 return -ENOMEM;
589 594
@@ -596,12 +601,12 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
596 mutex_unlock(&ec->mutex); 601 mutex_unlock(&ec->mutex);
597 return 0; 602 return 0;
598} 603}
599
600EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler); 604EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
601 605
602void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) 606void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
603{ 607{
604 struct acpi_ec_query_handler *handler, *tmp; 608 struct acpi_ec_query_handler *handler, *tmp;
609
605 mutex_lock(&ec->mutex); 610 mutex_lock(&ec->mutex);
606 list_for_each_entry_safe(handler, tmp, &ec->list, node) { 611 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
607 if (query_bit == handler->query_bit) { 612 if (query_bit == handler->query_bit) {
@@ -611,12 +616,12 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
611 } 616 }
612 mutex_unlock(&ec->mutex); 617 mutex_unlock(&ec->mutex);
613} 618}
614
615EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler); 619EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
616 620
617static void acpi_ec_run(void *cxt) 621static void acpi_ec_run(void *cxt)
618{ 622{
619 struct acpi_ec_query_handler *handler = cxt; 623 struct acpi_ec_query_handler *handler = cxt;
624
620 if (!handler) 625 if (!handler)
621 return; 626 return;
622 pr_debug("##### Query(0x%02x) started #####\n", handler->query_bit); 627 pr_debug("##### Query(0x%02x) started #####\n", handler->query_bit);
@@ -660,6 +665,7 @@ static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data)
660static void acpi_ec_gpe_query(void *ec_cxt) 665static void acpi_ec_gpe_query(void *ec_cxt)
661{ 666{
662 struct acpi_ec *ec = ec_cxt; 667 struct acpi_ec *ec = ec_cxt;
668
663 if (!ec) 669 if (!ec)
664 return; 670 return;
665 mutex_lock(&ec->mutex); 671 mutex_lock(&ec->mutex);
@@ -694,8 +700,8 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device,
694} 700}
695 701
696/* -------------------------------------------------------------------------- 702/* --------------------------------------------------------------------------
697 Address Space Management 703 * Address Space Management
698 -------------------------------------------------------------------------- */ 704 * -------------------------------------------------------------------------- */
699 705
700static acpi_status 706static acpi_status
701acpi_ec_space_handler(u32 function, acpi_physical_address address, 707acpi_ec_space_handler(u32 function, acpi_physical_address address,
@@ -726,27 +732,26 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
726 switch (result) { 732 switch (result) {
727 case -EINVAL: 733 case -EINVAL:
728 return AE_BAD_PARAMETER; 734 return AE_BAD_PARAMETER;
729 break;
730 case -ENODEV: 735 case -ENODEV:
731 return AE_NOT_FOUND; 736 return AE_NOT_FOUND;
732 break;
733 case -ETIME: 737 case -ETIME:
734 return AE_TIME; 738 return AE_TIME;
735 break;
736 default: 739 default:
737 return AE_OK; 740 return AE_OK;
738 } 741 }
739} 742}
740 743
741/* -------------------------------------------------------------------------- 744/* --------------------------------------------------------------------------
742 Driver Interface 745 * Driver Interface
743 -------------------------------------------------------------------------- */ 746 * -------------------------------------------------------------------------- */
747
744static acpi_status 748static acpi_status
745ec_parse_io_ports(struct acpi_resource *resource, void *context); 749ec_parse_io_ports(struct acpi_resource *resource, void *context);
746 750
747static struct acpi_ec *make_acpi_ec(void) 751static struct acpi_ec *make_acpi_ec(void)
748{ 752{
749 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); 753 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
754
750 if (!ec) 755 if (!ec)
751 return NULL; 756 return NULL;
752 ec->flags = 1 << EC_FLAGS_QUERY_PENDING; 757 ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
@@ -769,9 +774,8 @@ acpi_ec_register_query_methods(acpi_handle handle, u32 level,
769 774
770 status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer); 775 status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
771 776
772 if (ACPI_SUCCESS(status) && sscanf(node_name, "_Q%x", &value) == 1) { 777 if (ACPI_SUCCESS(status) && sscanf(node_name, "_Q%x", &value) == 1)
773 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL); 778 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
774 }
775 return AE_OK; 779 return AE_OK;
776} 780}
777 781
@@ -780,7 +784,6 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
780{ 784{
781 acpi_status status; 785 acpi_status status;
782 unsigned long long tmp = 0; 786 unsigned long long tmp = 0;
783
784 struct acpi_ec *ec = context; 787 struct acpi_ec *ec = context;
785 788
786 /* clear addr values, ec_parse_io_ports depend on it */ 789 /* clear addr values, ec_parse_io_ports depend on it */
@@ -808,6 +811,7 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
808static int ec_install_handlers(struct acpi_ec *ec) 811static int ec_install_handlers(struct acpi_ec *ec)
809{ 812{
810 acpi_status status; 813 acpi_status status;
814
811 if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags)) 815 if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
812 return 0; 816 return 0;
813 status = acpi_install_gpe_handler(NULL, ec->gpe, 817 status = acpi_install_gpe_handler(NULL, ec->gpe,
@@ -1105,7 +1109,8 @@ int __init acpi_ec_ecdt_probe(void)
1105 boot_ec->data_addr = ecdt_ptr->data.address; 1109 boot_ec->data_addr = ecdt_ptr->data.address;
1106 boot_ec->gpe = ecdt_ptr->gpe; 1110 boot_ec->gpe = ecdt_ptr->gpe;
1107 boot_ec->handle = ACPI_ROOT_OBJECT; 1111 boot_ec->handle = ACPI_ROOT_OBJECT;
1108 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); 1112 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id,
1113 &boot_ec->handle);
1109 /* Don't trust ECDT, which comes from ASUSTek */ 1114 /* Don't trust ECDT, which comes from ASUSTek */
1110 if (!EC_FLAGS_VALIDATE_ECDT) 1115 if (!EC_FLAGS_VALIDATE_ECDT)
1111 goto install; 1116 goto install;
@@ -1189,6 +1194,5 @@ static void __exit acpi_ec_exit(void)
1189{ 1194{
1190 1195
1191 acpi_bus_unregister_driver(&acpi_ec_driver); 1196 acpi_bus_unregister_driver(&acpi_ec_driver);
1192 return;
1193} 1197}
1194#endif /* 0 */ 1198#endif /* 0 */