summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities/utcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utilities/utcache.c')
-rw-r--r--drivers/acpi/utilities/utcache.c149
1 files changed, 63 insertions, 86 deletions
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
index c0df0585c683..93d48681d276 100644
--- a/drivers/acpi/utilities/utcache.c
+++ b/drivers/acpi/utilities/utcache.c
@@ -41,12 +41,10 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
-
#include <acpi/acpi.h>
#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utcache")
-
+ACPI_MODULE_NAME("utcache")
#ifdef ACPI_USE_LOCAL_CACHE
/*******************************************************************************
@@ -63,19 +61,14 @@
* DESCRIPTION: Create a cache object
*
******************************************************************************/
-
acpi_status
-acpi_os_create_cache (
- char *cache_name,
- u16 object_size,
- u16 max_depth,
- struct acpi_memory_list **return_cache)
+acpi_os_create_cache(char *cache_name,
+ u16 object_size,
+ u16 max_depth, struct acpi_memory_list **return_cache)
{
- struct acpi_memory_list *cache;
-
-
- ACPI_FUNCTION_ENTRY ();
+ struct acpi_memory_list *cache;
+ ACPI_FUNCTION_ENTRY();
if (!cache_name || !return_cache || (object_size < 16)) {
return (AE_BAD_PARAMETER);
@@ -83,24 +76,23 @@ acpi_os_create_cache (
/* Create the cache object */
- cache = acpi_os_allocate (sizeof (struct acpi_memory_list));
+ cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
if (!cache) {
return (AE_NO_MEMORY);
}
/* Populate the cache object and return it */
- ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list));
+ ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
cache->link_offset = 8;
- cache->list_name = cache_name;
+ cache->list_name = cache_name;
cache->object_size = object_size;
- cache->max_depth = max_depth;
+ cache->max_depth = max_depth;
*return_cache = cache;
return (AE_OK);
}
-
/*******************************************************************************
*
* FUNCTION: acpi_os_purge_cache
@@ -113,15 +105,11 @@ acpi_os_create_cache (
*
******************************************************************************/
-acpi_status
-acpi_os_purge_cache (
- struct acpi_memory_list *cache)
+acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
{
- char *next;
-
-
- ACPI_FUNCTION_ENTRY ();
+ char *next;
+ ACPI_FUNCTION_ENTRY();
if (!cache) {
return (AE_BAD_PARAMETER);
@@ -132,9 +120,11 @@ acpi_os_purge_cache (
while (cache->list_head) {
/* Delete and unlink one cached state object */
- next = *(ACPI_CAST_INDIRECT_PTR (char,
- &(((char *) cache->list_head)[cache->link_offset])));
- ACPI_MEM_FREE (cache->list_head);
+ next = *(ACPI_CAST_INDIRECT_PTR(char,
+ &(((char *)cache->
+ list_head)[cache->
+ link_offset])));
+ ACPI_MEM_FREE(cache->list_head);
cache->list_head = next;
cache->current_depth--;
@@ -143,7 +133,6 @@ acpi_os_purge_cache (
return (AE_OK);
}
-
/*******************************************************************************
*
* FUNCTION: acpi_os_delete_cache
@@ -157,30 +146,25 @@ acpi_os_purge_cache (
*
******************************************************************************/
-acpi_status
-acpi_os_delete_cache (
- struct acpi_memory_list *cache)
+acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache)
{
- acpi_status status;
-
+ acpi_status status;
- ACPI_FUNCTION_ENTRY ();
+ ACPI_FUNCTION_ENTRY();
+ /* Purge all objects in the cache */
- /* Purge all objects in the cache */
-
- status = acpi_os_purge_cache (cache);
- if (ACPI_FAILURE (status)) {
+ status = acpi_os_purge_cache(cache);
+ if (ACPI_FAILURE(status)) {
return (status);
}
/* Now we can delete the cache object */
- acpi_os_free (cache);
+ acpi_os_free(cache);
return (AE_OK);
}
-
/*******************************************************************************
*
* FUNCTION: acpi_os_release_object
@@ -196,15 +180,11 @@ acpi_os_delete_cache (
******************************************************************************/
acpi_status
-acpi_os_release_object (
- struct acpi_memory_list *cache,
- void *object)
+acpi_os_release_object(struct acpi_memory_list * cache, void *object)
{
- acpi_status status;
-
-
- ACPI_FUNCTION_ENTRY ();
+ acpi_status status;
+ ACPI_FUNCTION_ENTRY();
if (!cache || !object) {
return (AE_BAD_PARAMETER);
@@ -213,37 +193,38 @@ acpi_os_release_object (
/* If cache is full, just free this object */
if (cache->current_depth >= cache->max_depth) {
- ACPI_MEM_FREE (object);
- ACPI_MEM_TRACKING (cache->total_freed++);
+ ACPI_MEM_FREE(object);
+ ACPI_MEM_TRACKING(cache->total_freed++);
}
/* Otherwise put this object back into the cache */
else {
- status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (status)) {
+ status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
+ if (ACPI_FAILURE(status)) {
return (status);
}
/* Mark the object as cached */
- ACPI_MEMSET (object, 0xCA, cache->object_size);
- ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED);
+ ACPI_MEMSET(object, 0xCA, cache->object_size);
+ ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED);
/* Put the object at the head of the cache list */
- * (ACPI_CAST_INDIRECT_PTR (char,
- &(((char *) object)[cache->link_offset]))) = cache->list_head;
+ *(ACPI_CAST_INDIRECT_PTR(char,
+ &(((char *)object)[cache->
+ link_offset]))) =
+ cache->list_head;
cache->list_head = object;
cache->current_depth++;
- (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
+ (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
}
return (AE_OK);
}
-
/*******************************************************************************
*
* FUNCTION: acpi_os_acquire_object
@@ -257,27 +238,23 @@ acpi_os_release_object (
*
******************************************************************************/
-void *
-acpi_os_acquire_object (
- struct acpi_memory_list *cache)
+void *acpi_os_acquire_object(struct acpi_memory_list *cache)
{
- acpi_status status;
- void *object;
-
-
- ACPI_FUNCTION_NAME ("os_acquire_object");
+ acpi_status status;
+ void *object;
+ ACPI_FUNCTION_NAME("os_acquire_object");
if (!cache) {
return (NULL);
}
- status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (status)) {
+ status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
+ if (ACPI_FAILURE(status)) {
return (NULL);
}
- ACPI_MEM_TRACKING (cache->requests++);
+ ACPI_MEM_TRACKING(cache->requests++);
/* Check the cache first */
@@ -285,37 +262,39 @@ acpi_os_acquire_object (
/* There is an object available, use it */
object = cache->list_head;
- cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char,
- &(((char *) object)[cache->link_offset])));
+ cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char,
+ &(((char *)
+ object)[cache->
+ link_offset])));
cache->current_depth--;
- ACPI_MEM_TRACKING (cache->hits++);
- ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Object %p from %s cache\n", object, cache->list_name)));
+ ACPI_MEM_TRACKING(cache->hits++);
+ ACPI_MEM_TRACKING(ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
+ "Object %p from %s cache\n",
+ object, cache->list_name)));
- status = acpi_ut_release_mutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (status)) {
+ status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
+ if (ACPI_FAILURE(status)) {
return (NULL);
}
/* Clear (zero) the previously used Object */
- ACPI_MEMSET (object, 0, cache->object_size);
- }
- else {
+ ACPI_MEMSET(object, 0, cache->object_size);
+ } else {
/* The cache is empty, create a new object */
- ACPI_MEM_TRACKING (cache->total_allocated++);
+ ACPI_MEM_TRACKING(cache->total_allocated++);
/* Avoid deadlock with ACPI_MEM_CALLOCATE */
- status = acpi_ut_release_mutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (status)) {
+ status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
+ if (ACPI_FAILURE(status)) {
return (NULL);
}
- object = ACPI_MEM_CALLOCATE (cache->object_size);
+ object = ACPI_MEM_CALLOCATE(cache->object_size);
if (!object) {
return (NULL);
}
@@ -323,6 +302,4 @@ acpi_os_acquire_object (
return (object);
}
-#endif /* ACPI_USE_LOCAL_CACHE */
-
-
+#endif /* ACPI_USE_LOCAL_CACHE */