aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/osl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/osl.c')
-rw-r--r--drivers/acpi/osl.c90
1 files changed, 24 insertions, 66 deletions
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index eedb05c6dc7b..b7d1514cd199 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -36,7 +36,6 @@
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/workqueue.h> 37#include <linux/workqueue.h>
38#include <linux/nmi.h> 38#include <linux/nmi.h>
39#include <linux/kthread.h>
40#include <acpi/acpi.h> 39#include <acpi/acpi.h>
41#include <asm/io.h> 40#include <asm/io.h>
42#include <acpi/acpi_bus.h> 41#include <acpi/acpi_bus.h>
@@ -136,16 +135,6 @@ void acpi_os_vprintf(const char *fmt, va_list args)
136#endif 135#endif
137} 136}
138 137
139
140extern int acpi_in_resume;
141void *acpi_os_allocate(acpi_size size)
142{
143 if (acpi_in_resume)
144 return kmalloc(size, GFP_ATOMIC);
145 else
146 return kmalloc(size, GFP_KERNEL);
147}
148
149acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) 138acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
150{ 139{
151 if (efi_enabled) { 140 if (efi_enabled) {
@@ -593,16 +582,6 @@ static void acpi_os_execute_deferred(void *context)
593 return; 582 return;
594} 583}
595 584
596static int acpi_os_execute_thread(void *context)
597{
598 struct acpi_os_dpc *dpc = (struct acpi_os_dpc *)context;
599 if (dpc) {
600 dpc->function(dpc->context);
601 kfree(dpc);
602 }
603 do_exit(0);
604}
605
606/******************************************************************************* 585/*******************************************************************************
607 * 586 *
608 * FUNCTION: acpi_os_execute 587 * FUNCTION: acpi_os_execute
@@ -624,10 +603,16 @@ acpi_status acpi_os_execute(acpi_execute_type type,
624 acpi_status status = AE_OK; 603 acpi_status status = AE_OK;
625 struct acpi_os_dpc *dpc; 604 struct acpi_os_dpc *dpc;
626 struct work_struct *task; 605 struct work_struct *task;
627 struct task_struct *p; 606
607 ACPI_FUNCTION_TRACE("os_queue_for_execution");
608
609 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
610 "Scheduling function [%p(%p)] for deferred execution.\n",
611 function, context));
628 612
629 if (!function) 613 if (!function)
630 return AE_BAD_PARAMETER; 614 return_ACPI_STATUS(AE_BAD_PARAMETER);
615
631 /* 616 /*
632 * Allocate/initialize DPC structure. Note that this memory will be 617 * Allocate/initialize DPC structure. Note that this memory will be
633 * freed by the callee. The kernel handles the tq_struct list in a 618 * freed by the callee. The kernel handles the tq_struct list in a
@@ -638,34 +623,27 @@ acpi_status acpi_os_execute(acpi_execute_type type,
638 * We can save time and code by allocating the DPC and tq_structs 623 * We can save time and code by allocating the DPC and tq_structs
639 * from the same memory. 624 * from the same memory.
640 */ 625 */
641 if (type == OSL_NOTIFY_HANDLER) { 626
642 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_KERNEL); 627 dpc =
643 } else { 628 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
644 dpc = kmalloc(sizeof(struct acpi_os_dpc) + 629 GFP_ATOMIC);
645 sizeof(struct work_struct), GFP_ATOMIC);
646 }
647 if (!dpc) 630 if (!dpc)
648 return AE_NO_MEMORY; 631 return_ACPI_STATUS(AE_NO_MEMORY);
632
649 dpc->function = function; 633 dpc->function = function;
650 dpc->context = context; 634 dpc->context = context;
651 635
652 if (type == OSL_NOTIFY_HANDLER) { 636 task = (void *)(dpc + 1);
653 p = kthread_create(acpi_os_execute_thread, dpc, "kacpid_notify"); 637 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
654 if (!IS_ERR(p)) { 638
655 wake_up_process(p); 639 if (!queue_work(kacpid_wq, task)) {
656 } else { 640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
657 status = AE_NO_MEMORY; 641 "Call to queue_work() failed.\n"));
658 kfree(dpc); 642 kfree(dpc);
659 } 643 status = AE_ERROR;
660 } else {
661 task = (void *)(dpc + 1);
662 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
663 if (!queue_work(kacpid_wq, task)) {
664 status = AE_ERROR;
665 kfree(dpc);
666 }
667 } 644 }
668 return status; 645
646 return_ACPI_STATUS(status);
669} 647}
670 648
671EXPORT_SYMBOL(acpi_os_execute); 649EXPORT_SYMBOL(acpi_os_execute);
@@ -1115,26 +1093,6 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1115 return (AE_OK); 1093 return (AE_OK);
1116} 1094}
1117 1095
1118/*******************************************************************************
1119 *
1120 * FUNCTION: acpi_os_acquire_object
1121 *
1122 * PARAMETERS: Cache - Handle to cache object
1123 * ReturnObject - Where the object is returned
1124 *
1125 * RETURN: Status
1126 *
1127 * DESCRIPTION: Return a zero-filled object.
1128 *
1129 ******************************************************************************/
1130
1131void *acpi_os_acquire_object(acpi_cache_t * cache)
1132{
1133 void *object = kmem_cache_zalloc(cache, GFP_KERNEL);
1134 WARN_ON(!object);
1135 return object;
1136}
1137
1138/****************************************************************************** 1096/******************************************************************************
1139 * 1097 *
1140 * FUNCTION: acpi_os_validate_interface 1098 * FUNCTION: acpi_os_validate_interface