diff options
author | Len Brown <len.brown@intel.com> | 2005-08-05 00:44:28 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2005-08-05 00:45:14 -0400 |
commit | 4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch) | |
tree | 5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/utilities/utcache.c | |
parent | c65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff) |
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/utilities/utcache.c')
-rw-r--r-- | drivers/acpi/utilities/utcache.c | 149 |
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 @@ | |||
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 | 45 | ||
47 | #define _COMPONENT ACPI_UTILITIES | 46 | #define _COMPONENT ACPI_UTILITIES |
48 | ACPI_MODULE_NAME ("utcache") | 47 | ACPI_MODULE_NAME("utcache") |
49 | |||
50 | 48 | ||
51 | #ifdef ACPI_USE_LOCAL_CACHE | 49 | #ifdef ACPI_USE_LOCAL_CACHE |
52 | /******************************************************************************* | 50 | /******************************************************************************* |
@@ -63,19 +61,14 @@ | |||
63 | * DESCRIPTION: Create a cache object | 61 | * DESCRIPTION: Create a cache object |
64 | * | 62 | * |
65 | ******************************************************************************/ | 63 | ******************************************************************************/ |
66 | |||
67 | acpi_status | 64 | acpi_status |
68 | acpi_os_create_cache ( | 65 | acpi_os_create_cache(char *cache_name, |
69 | char *cache_name, | 66 | u16 object_size, |
70 | u16 object_size, | 67 | u16 max_depth, struct acpi_memory_list **return_cache) |
71 | u16 max_depth, | ||
72 | struct acpi_memory_list **return_cache) | ||
73 | { | 68 | { |
74 | struct acpi_memory_list *cache; | 69 | struct acpi_memory_list *cache; |
75 | |||
76 | |||
77 | ACPI_FUNCTION_ENTRY (); | ||
78 | 70 | ||
71 | ACPI_FUNCTION_ENTRY(); | ||
79 | 72 | ||
80 | if (!cache_name || !return_cache || (object_size < 16)) { | 73 | if (!cache_name || !return_cache || (object_size < 16)) { |
81 | return (AE_BAD_PARAMETER); | 74 | return (AE_BAD_PARAMETER); |
@@ -83,24 +76,23 @@ acpi_os_create_cache ( | |||
83 | 76 | ||
84 | /* Create the cache object */ | 77 | /* Create the cache object */ |
85 | 78 | ||
86 | cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); | 79 | cache = acpi_os_allocate(sizeof(struct acpi_memory_list)); |
87 | if (!cache) { | 80 | if (!cache) { |
88 | return (AE_NO_MEMORY); | 81 | return (AE_NO_MEMORY); |
89 | } | 82 | } |
90 | 83 | ||
91 | /* Populate the cache object and return it */ | 84 | /* Populate the cache object and return it */ |
92 | 85 | ||
93 | ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); | 86 | ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list)); |
94 | cache->link_offset = 8; | 87 | cache->link_offset = 8; |
95 | cache->list_name = cache_name; | 88 | cache->list_name = cache_name; |
96 | cache->object_size = object_size; | 89 | cache->object_size = object_size; |
97 | cache->max_depth = max_depth; | 90 | cache->max_depth = max_depth; |
98 | 91 | ||
99 | *return_cache = cache; | 92 | *return_cache = cache; |
100 | return (AE_OK); | 93 | return (AE_OK); |
101 | } | 94 | } |
102 | 95 | ||
103 | |||
104 | /******************************************************************************* | 96 | /******************************************************************************* |
105 | * | 97 | * |
106 | * FUNCTION: acpi_os_purge_cache | 98 | * FUNCTION: acpi_os_purge_cache |
@@ -113,15 +105,11 @@ acpi_os_create_cache ( | |||
113 | * | 105 | * |
114 | ******************************************************************************/ | 106 | ******************************************************************************/ |
115 | 107 | ||
116 | acpi_status | 108 | acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) |
117 | acpi_os_purge_cache ( | ||
118 | struct acpi_memory_list *cache) | ||
119 | { | 109 | { |
120 | char *next; | 110 | char *next; |
121 | |||
122 | |||
123 | ACPI_FUNCTION_ENTRY (); | ||
124 | 111 | ||
112 | ACPI_FUNCTION_ENTRY(); | ||
125 | 113 | ||
126 | if (!cache) { | 114 | if (!cache) { |
127 | return (AE_BAD_PARAMETER); | 115 | return (AE_BAD_PARAMETER); |
@@ -132,9 +120,11 @@ acpi_os_purge_cache ( | |||
132 | while (cache->list_head) { | 120 | while (cache->list_head) { |
133 | /* Delete and unlink one cached state object */ | 121 | /* Delete and unlink one cached state object */ |
134 | 122 | ||
135 | next = *(ACPI_CAST_INDIRECT_PTR (char, | 123 | next = *(ACPI_CAST_INDIRECT_PTR(char, |
136 | &(((char *) cache->list_head)[cache->link_offset]))); | 124 | &(((char *)cache-> |
137 | ACPI_MEM_FREE (cache->list_head); | 125 | list_head)[cache-> |
126 | link_offset]))); | ||
127 | ACPI_MEM_FREE(cache->list_head); | ||
138 | 128 | ||
139 | cache->list_head = next; | 129 | cache->list_head = next; |
140 | cache->current_depth--; | 130 | cache->current_depth--; |
@@ -143,7 +133,6 @@ acpi_os_purge_cache ( | |||
143 | return (AE_OK); | 133 | return (AE_OK); |
144 | } | 134 | } |
145 | 135 | ||
146 | |||
147 | /******************************************************************************* | 136 | /******************************************************************************* |
148 | * | 137 | * |
149 | * FUNCTION: acpi_os_delete_cache | 138 | * FUNCTION: acpi_os_delete_cache |
@@ -157,30 +146,25 @@ acpi_os_purge_cache ( | |||
157 | * | 146 | * |
158 | ******************************************************************************/ | 147 | ******************************************************************************/ |
159 | 148 | ||
160 | acpi_status | 149 | acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache) |
161 | acpi_os_delete_cache ( | ||
162 | struct acpi_memory_list *cache) | ||
163 | { | 150 | { |
164 | acpi_status status; | 151 | acpi_status status; |
165 | |||
166 | 152 | ||
167 | ACPI_FUNCTION_ENTRY (); | 153 | ACPI_FUNCTION_ENTRY(); |
168 | 154 | ||
155 | /* Purge all objects in the cache */ | ||
169 | 156 | ||
170 | /* Purge all objects in the cache */ | 157 | status = acpi_os_purge_cache(cache); |
171 | 158 | if (ACPI_FAILURE(status)) { | |
172 | status = acpi_os_purge_cache (cache); | ||
173 | if (ACPI_FAILURE (status)) { | ||
174 | return (status); | 159 | return (status); |
175 | } | 160 | } |
176 | 161 | ||
177 | /* Now we can delete the cache object */ | 162 | /* Now we can delete the cache object */ |
178 | 163 | ||
179 | acpi_os_free (cache); | 164 | acpi_os_free(cache); |
180 | return (AE_OK); | 165 | return (AE_OK); |
181 | } | 166 | } |
182 | 167 | ||
183 | |||
184 | /******************************************************************************* | 168 | /******************************************************************************* |
185 | * | 169 | * |
186 | * FUNCTION: acpi_os_release_object | 170 | * FUNCTION: acpi_os_release_object |
@@ -196,15 +180,11 @@ acpi_os_delete_cache ( | |||
196 | ******************************************************************************/ | 180 | ******************************************************************************/ |
197 | 181 | ||
198 | acpi_status | 182 | acpi_status |
199 | acpi_os_release_object ( | 183 | acpi_os_release_object(struct acpi_memory_list * cache, void *object) |
200 | struct acpi_memory_list *cache, | ||
201 | void *object) | ||
202 | { | 184 | { |
203 | acpi_status status; | 185 | acpi_status status; |
204 | |||
205 | |||
206 | ACPI_FUNCTION_ENTRY (); | ||
207 | 186 | ||
187 | ACPI_FUNCTION_ENTRY(); | ||
208 | 188 | ||
209 | if (!cache || !object) { | 189 | if (!cache || !object) { |
210 | return (AE_BAD_PARAMETER); | 190 | return (AE_BAD_PARAMETER); |
@@ -213,37 +193,38 @@ acpi_os_release_object ( | |||
213 | /* If cache is full, just free this object */ | 193 | /* If cache is full, just free this object */ |
214 | 194 | ||
215 | if (cache->current_depth >= cache->max_depth) { | 195 | if (cache->current_depth >= cache->max_depth) { |
216 | ACPI_MEM_FREE (object); | 196 | ACPI_MEM_FREE(object); |
217 | ACPI_MEM_TRACKING (cache->total_freed++); | 197 | ACPI_MEM_TRACKING(cache->total_freed++); |
218 | } | 198 | } |
219 | 199 | ||
220 | /* Otherwise put this object back into the cache */ | 200 | /* Otherwise put this object back into the cache */ |
221 | 201 | ||
222 | else { | 202 | else { |
223 | status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); | 203 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); |
224 | if (ACPI_FAILURE (status)) { | 204 | if (ACPI_FAILURE(status)) { |
225 | return (status); | 205 | return (status); |
226 | } | 206 | } |
227 | 207 | ||
228 | /* Mark the object as cached */ | 208 | /* Mark the object as cached */ |
229 | 209 | ||
230 | ACPI_MEMSET (object, 0xCA, cache->object_size); | 210 | ACPI_MEMSET(object, 0xCA, cache->object_size); |
231 | ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); | 211 | ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED); |
232 | 212 | ||
233 | /* Put the object at the head of the cache list */ | 213 | /* Put the object at the head of the cache list */ |
234 | 214 | ||
235 | * (ACPI_CAST_INDIRECT_PTR (char, | 215 | *(ACPI_CAST_INDIRECT_PTR(char, |
236 | &(((char *) object)[cache->link_offset]))) = cache->list_head; | 216 | &(((char *)object)[cache-> |
217 | link_offset]))) = | ||
218 | cache->list_head; | ||
237 | cache->list_head = object; | 219 | cache->list_head = object; |
238 | cache->current_depth++; | 220 | cache->current_depth++; |
239 | 221 | ||
240 | (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); | 222 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); |
241 | } | 223 | } |
242 | 224 | ||
243 | return (AE_OK); | 225 | return (AE_OK); |
244 | } | 226 | } |
245 | 227 | ||
246 | |||
247 | /******************************************************************************* | 228 | /******************************************************************************* |
248 | * | 229 | * |
249 | * FUNCTION: acpi_os_acquire_object | 230 | * FUNCTION: acpi_os_acquire_object |
@@ -257,27 +238,23 @@ acpi_os_release_object ( | |||
257 | * | 238 | * |
258 | ******************************************************************************/ | 239 | ******************************************************************************/ |
259 | 240 | ||
260 | void * | 241 | void *acpi_os_acquire_object(struct acpi_memory_list *cache) |
261 | acpi_os_acquire_object ( | ||
262 | struct acpi_memory_list *cache) | ||
263 | { | 242 | { |
264 | acpi_status status; | 243 | acpi_status status; |
265 | void *object; | 244 | void *object; |
266 | |||
267 | |||
268 | ACPI_FUNCTION_NAME ("os_acquire_object"); | ||
269 | 245 | ||
246 | ACPI_FUNCTION_NAME("os_acquire_object"); | ||
270 | 247 | ||
271 | if (!cache) { | 248 | if (!cache) { |
272 | return (NULL); | 249 | return (NULL); |
273 | } | 250 | } |
274 | 251 | ||
275 | status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); | 252 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); |
276 | if (ACPI_FAILURE (status)) { | 253 | if (ACPI_FAILURE(status)) { |
277 | return (NULL); | 254 | return (NULL); |
278 | } | 255 | } |
279 | 256 | ||
280 | ACPI_MEM_TRACKING (cache->requests++); | 257 | ACPI_MEM_TRACKING(cache->requests++); |
281 | 258 | ||
282 | /* Check the cache first */ | 259 | /* Check the cache first */ |
283 | 260 | ||
@@ -285,37 +262,39 @@ acpi_os_acquire_object ( | |||
285 | /* There is an object available, use it */ | 262 | /* There is an object available, use it */ |
286 | 263 | ||
287 | object = cache->list_head; | 264 | object = cache->list_head; |
288 | cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char, | 265 | cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char, |
289 | &(((char *) object)[cache->link_offset]))); | 266 | &(((char *) |
267 | object)[cache-> | ||
268 | link_offset]))); | ||
290 | 269 | ||
291 | cache->current_depth--; | 270 | cache->current_depth--; |
292 | 271 | ||
293 | ACPI_MEM_TRACKING (cache->hits++); | 272 | ACPI_MEM_TRACKING(cache->hits++); |
294 | ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | 273 | ACPI_MEM_TRACKING(ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
295 | "Object %p from %s cache\n", object, cache->list_name))); | 274 | "Object %p from %s cache\n", |
275 | object, cache->list_name))); | ||
296 | 276 | ||
297 | status = acpi_ut_release_mutex (ACPI_MTX_CACHES); | 277 | status = acpi_ut_release_mutex(ACPI_MTX_CACHES); |
298 | if (ACPI_FAILURE (status)) { | 278 | if (ACPI_FAILURE(status)) { |
299 | return (NULL); | 279 | return (NULL); |
300 | } | 280 | } |
301 | 281 | ||
302 | /* Clear (zero) the previously used Object */ | 282 | /* Clear (zero) the previously used Object */ |
303 | 283 | ||
304 | ACPI_MEMSET (object, 0, cache->object_size); | 284 | ACPI_MEMSET(object, 0, cache->object_size); |
305 | } | 285 | } else { |
306 | else { | ||
307 | /* The cache is empty, create a new object */ | 286 | /* The cache is empty, create a new object */ |
308 | 287 | ||
309 | ACPI_MEM_TRACKING (cache->total_allocated++); | 288 | ACPI_MEM_TRACKING(cache->total_allocated++); |
310 | 289 | ||
311 | /* Avoid deadlock with ACPI_MEM_CALLOCATE */ | 290 | /* Avoid deadlock with ACPI_MEM_CALLOCATE */ |
312 | 291 | ||
313 | status = acpi_ut_release_mutex (ACPI_MTX_CACHES); | 292 | status = acpi_ut_release_mutex(ACPI_MTX_CACHES); |
314 | if (ACPI_FAILURE (status)) { | 293 | if (ACPI_FAILURE(status)) { |
315 | return (NULL); | 294 | return (NULL); |
316 | } | 295 | } |
317 | 296 | ||
318 | object = ACPI_MEM_CALLOCATE (cache->object_size); | 297 | object = ACPI_MEM_CALLOCATE(cache->object_size); |
319 | if (!object) { | 298 | if (!object) { |
320 | return (NULL); | 299 | return (NULL); |
321 | } | 300 | } |
@@ -323,6 +302,4 @@ acpi_os_acquire_object ( | |||
323 | 302 | ||
324 | return (object); | 303 | return (object); |
325 | } | 304 | } |
326 | #endif /* ACPI_USE_LOCAL_CACHE */ | 305 | #endif /* ACPI_USE_LOCAL_CACHE */ |
327 | |||
328 | |||