diff options
Diffstat (limited to 'drivers/acpi/resources/rsxface.c')
-rw-r--r-- | drivers/acpi/resources/rsxface.c | 395 |
1 files changed, 221 insertions, 174 deletions
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 88b67077aeeb..1999e2ab7daa 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c | |||
@@ -41,10 +41,9 @@ | |||
41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #include <linux/module.h> | ||
45 | |||
46 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
47 | #include <acpi/acresrc.h> | 45 | #include <acpi/acresrc.h> |
46 | #include <acpi/acnamesp.h> | ||
48 | 47 | ||
49 | #define _COMPONENT ACPI_RESOURCES | 48 | #define _COMPONENT ACPI_RESOURCES |
50 | ACPI_MODULE_NAME("rsxface") | 49 | ACPI_MODULE_NAME("rsxface") |
@@ -68,312 +67,262 @@ ACPI_MODULE_NAME("rsxface") | |||
68 | static acpi_status | 67 | static acpi_status |
69 | acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context); | 68 | acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context); |
70 | 69 | ||
70 | static acpi_status | ||
71 | acpi_rs_validate_parameters(acpi_handle device_handle, | ||
72 | struct acpi_buffer *buffer, | ||
73 | struct acpi_namespace_node **return_node); | ||
74 | |||
71 | /******************************************************************************* | 75 | /******************************************************************************* |
72 | * | 76 | * |
73 | * FUNCTION: acpi_get_irq_routing_table | 77 | * FUNCTION: acpi_rs_validate_parameters |
74 | * | 78 | * |
75 | * PARAMETERS: device_handle - a handle to the Bus device we are querying | 79 | * PARAMETERS: device_handle - Handle to a device |
76 | * ret_buffer - a pointer to a buffer to receive the | 80 | * Buffer - Pointer to a data buffer |
77 | * current resources for the device | 81 | * return_node - Pointer to where the device node is returned |
78 | * | 82 | * |
79 | * RETURN: Status | 83 | * RETURN: Status |
80 | * | 84 | * |
81 | * DESCRIPTION: This function is called to get the IRQ routing table for a | 85 | * DESCRIPTION: Common parameter validation for resource interfaces |
82 | * specific bus. The caller must first acquire a handle for the | ||
83 | * desired bus. The routine table is placed in the buffer pointed | ||
84 | * to by the ret_buffer variable parameter. | ||
85 | * | ||
86 | * If the function fails an appropriate status will be returned | ||
87 | * and the value of ret_buffer is undefined. | ||
88 | * | ||
89 | * This function attempts to execute the _PRT method contained in | ||
90 | * the object indicated by the passed device_handle. | ||
91 | * | 86 | * |
92 | ******************************************************************************/ | 87 | ******************************************************************************/ |
93 | 88 | ||
94 | acpi_status | 89 | static acpi_status |
95 | acpi_get_irq_routing_table(acpi_handle device_handle, | 90 | acpi_rs_validate_parameters(acpi_handle device_handle, |
96 | struct acpi_buffer *ret_buffer) | 91 | struct acpi_buffer *buffer, |
92 | struct acpi_namespace_node **return_node) | ||
97 | { | 93 | { |
98 | acpi_status status; | 94 | acpi_status status; |
95 | struct acpi_namespace_node *node; | ||
99 | 96 | ||
100 | ACPI_FUNCTION_TRACE("acpi_get_irq_routing_table "); | 97 | ACPI_FUNCTION_TRACE(rs_validate_parameters); |
101 | 98 | ||
102 | /* | 99 | /* |
103 | * Must have a valid handle and buffer, So we have to have a handle | 100 | * Must have a valid handle to an ACPI device |
104 | * and a return buffer structure, and if there is a non-zero buffer length | ||
105 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
106 | * we'll be returning the needed buffer size, so keep going. | ||
107 | */ | 101 | */ |
108 | if (!device_handle) { | 102 | if (!device_handle) { |
109 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 103 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
110 | } | 104 | } |
111 | 105 | ||
112 | status = acpi_ut_validate_buffer(ret_buffer); | 106 | node = acpi_ns_map_handle_to_node(device_handle); |
107 | if (!node) { | ||
108 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
109 | } | ||
110 | |||
111 | if (node->type != ACPI_TYPE_DEVICE) { | ||
112 | return_ACPI_STATUS(AE_TYPE); | ||
113 | } | ||
114 | |||
115 | /* | ||
116 | * Validate the user buffer object | ||
117 | * | ||
118 | * if there is a non-zero buffer length we also need a valid pointer in | ||
119 | * the buffer. If it's a zero buffer length, we'll be returning the | ||
120 | * needed buffer size (later), so keep going. | ||
121 | */ | ||
122 | status = acpi_ut_validate_buffer(buffer); | ||
113 | if (ACPI_FAILURE(status)) { | 123 | if (ACPI_FAILURE(status)) { |
114 | return_ACPI_STATUS(status); | 124 | return_ACPI_STATUS(status); |
115 | } | 125 | } |
116 | 126 | ||
117 | status = acpi_rs_get_prt_method_data(device_handle, ret_buffer); | 127 | *return_node = node; |
118 | return_ACPI_STATUS(status); | 128 | return_ACPI_STATUS(AE_OK); |
119 | } | 129 | } |
120 | 130 | ||
121 | /******************************************************************************* | 131 | /******************************************************************************* |
122 | * | 132 | * |
123 | * FUNCTION: acpi_get_current_resources | 133 | * FUNCTION: acpi_get_irq_routing_table |
124 | * | 134 | * |
125 | * PARAMETERS: device_handle - a handle to the device object for the | 135 | * PARAMETERS: device_handle - Handle to the Bus device we are querying |
126 | * device we are querying | 136 | * ret_buffer - Pointer to a buffer to receive the |
127 | * ret_buffer - a pointer to a buffer to receive the | ||
128 | * current resources for the device | 137 | * current resources for the device |
129 | * | 138 | * |
130 | * RETURN: Status | 139 | * RETURN: Status |
131 | * | 140 | * |
132 | * DESCRIPTION: This function is called to get the current resources for a | 141 | * DESCRIPTION: This function is called to get the IRQ routing table for a |
133 | * specific device. The caller must first acquire a handle for | 142 | * specific bus. The caller must first acquire a handle for the |
134 | * the desired device. The resource data is placed in the buffer | 143 | * desired bus. The routine table is placed in the buffer pointed |
135 | * pointed to by the ret_buffer variable parameter. | 144 | * to by the ret_buffer variable parameter. |
136 | * | 145 | * |
137 | * If the function fails an appropriate status will be returned | 146 | * If the function fails an appropriate status will be returned |
138 | * and the value of ret_buffer is undefined. | 147 | * and the value of ret_buffer is undefined. |
139 | * | 148 | * |
140 | * This function attempts to execute the _CRS method contained in | 149 | * This function attempts to execute the _PRT method contained in |
141 | * the object indicated by the passed device_handle. | 150 | * the object indicated by the passed device_handle. |
142 | * | 151 | * |
143 | ******************************************************************************/ | 152 | ******************************************************************************/ |
144 | 153 | ||
145 | acpi_status | 154 | acpi_status |
146 | acpi_get_current_resources(acpi_handle device_handle, | 155 | acpi_get_irq_routing_table(acpi_handle device_handle, |
147 | struct acpi_buffer *ret_buffer) | 156 | struct acpi_buffer *ret_buffer) |
148 | { | 157 | { |
149 | acpi_status status; | 158 | acpi_status status; |
159 | struct acpi_namespace_node *node; | ||
150 | 160 | ||
151 | ACPI_FUNCTION_TRACE("acpi_get_current_resources"); | 161 | ACPI_FUNCTION_TRACE(acpi_get_irq_routing_table); |
152 | 162 | ||
153 | /* | 163 | /* Validate parameters then dispatch to internal routine */ |
154 | * Must have a valid handle and buffer, So we have to have a handle | ||
155 | * and a return buffer structure, and if there is a non-zero buffer length | ||
156 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
157 | * we'll be returning the needed buffer size, so keep going. | ||
158 | */ | ||
159 | if (!device_handle) { | ||
160 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
161 | } | ||
162 | 164 | ||
163 | status = acpi_ut_validate_buffer(ret_buffer); | 165 | status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node); |
164 | if (ACPI_FAILURE(status)) { | 166 | if (ACPI_FAILURE(status)) { |
165 | return_ACPI_STATUS(status); | 167 | return_ACPI_STATUS(status); |
166 | } | 168 | } |
167 | 169 | ||
168 | status = acpi_rs_get_crs_method_data(device_handle, ret_buffer); | 170 | status = acpi_rs_get_prt_method_data(node, ret_buffer); |
169 | return_ACPI_STATUS(status); | 171 | return_ACPI_STATUS(status); |
170 | } | 172 | } |
171 | 173 | ||
172 | EXPORT_SYMBOL(acpi_get_current_resources); | 174 | ACPI_EXPORT_SYMBOL(acpi_get_irq_routing_table) |
173 | 175 | ||
174 | /******************************************************************************* | 176 | /******************************************************************************* |
175 | * | 177 | * |
176 | * FUNCTION: acpi_get_possible_resources | 178 | * FUNCTION: acpi_get_current_resources |
177 | * | 179 | * |
178 | * PARAMETERS: device_handle - a handle to the device object for the | 180 | * PARAMETERS: device_handle - Handle to the device object for the |
179 | * device we are querying | 181 | * device we are querying |
180 | * ret_buffer - a pointer to a buffer to receive the | 182 | * ret_buffer - Pointer to a buffer to receive the |
181 | * resources for the device | 183 | * current resources for the device |
182 | * | 184 | * |
183 | * RETURN: Status | 185 | * RETURN: Status |
184 | * | 186 | * |
185 | * DESCRIPTION: This function is called to get a list of the possible resources | 187 | * DESCRIPTION: This function is called to get the current resources for a |
186 | * for a specific device. The caller must first acquire a handle | 188 | * specific device. The caller must first acquire a handle for |
187 | * for the desired device. The resource data is placed in the | 189 | * the desired device. The resource data is placed in the buffer |
188 | * buffer pointed to by the ret_buffer variable. | 190 | * pointed to by the ret_buffer variable parameter. |
189 | * | 191 | * |
190 | * If the function fails an appropriate status will be returned | 192 | * If the function fails an appropriate status will be returned |
191 | * and the value of ret_buffer is undefined. | 193 | * and the value of ret_buffer is undefined. |
192 | * | 194 | * |
195 | * This function attempts to execute the _CRS method contained in | ||
196 | * the object indicated by the passed device_handle. | ||
197 | * | ||
193 | ******************************************************************************/ | 198 | ******************************************************************************/ |
194 | |||
195 | #ifdef ACPI_FUTURE_USAGE | ||
196 | acpi_status | 199 | acpi_status |
197 | acpi_get_possible_resources(acpi_handle device_handle, | 200 | acpi_get_current_resources(acpi_handle device_handle, |
198 | struct acpi_buffer *ret_buffer) | 201 | struct acpi_buffer *ret_buffer) |
199 | { | 202 | { |
200 | acpi_status status; | 203 | acpi_status status; |
204 | struct acpi_namespace_node *node; | ||
201 | 205 | ||
202 | ACPI_FUNCTION_TRACE("acpi_get_possible_resources"); | 206 | ACPI_FUNCTION_TRACE(acpi_get_current_resources); |
203 | 207 | ||
204 | /* | 208 | /* Validate parameters then dispatch to internal routine */ |
205 | * Must have a valid handle and buffer, So we have to have a handle | ||
206 | * and a return buffer structure, and if there is a non-zero buffer length | ||
207 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
208 | * we'll be returning the needed buffer size, so keep going. | ||
209 | */ | ||
210 | if (!device_handle) { | ||
211 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
212 | } | ||
213 | 209 | ||
214 | status = acpi_ut_validate_buffer(ret_buffer); | 210 | status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node); |
215 | if (ACPI_FAILURE(status)) { | 211 | if (ACPI_FAILURE(status)) { |
216 | return_ACPI_STATUS(status); | 212 | return_ACPI_STATUS(status); |
217 | } | 213 | } |
218 | 214 | ||
219 | status = acpi_rs_get_prs_method_data(device_handle, ret_buffer); | 215 | status = acpi_rs_get_crs_method_data(node, ret_buffer); |
220 | return_ACPI_STATUS(status); | 216 | return_ACPI_STATUS(status); |
221 | } | 217 | } |
222 | 218 | ||
223 | EXPORT_SYMBOL(acpi_get_possible_resources); | 219 | ACPI_EXPORT_SYMBOL(acpi_get_current_resources) |
224 | #endif /* ACPI_FUTURE_USAGE */ | ||
225 | 220 | ||
221 | #ifdef ACPI_FUTURE_USAGE | ||
226 | /******************************************************************************* | 222 | /******************************************************************************* |
227 | * | 223 | * |
228 | * FUNCTION: acpi_walk_resources | 224 | * FUNCTION: acpi_get_possible_resources |
229 | * | 225 | * |
230 | * PARAMETERS: device_handle - Handle to the device object for the | 226 | * PARAMETERS: device_handle - Handle to the device object for the |
231 | * device we are querying | 227 | * device we are querying |
232 | * Name - Method name of the resources we want | 228 | * ret_buffer - Pointer to a buffer to receive the |
233 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) | 229 | * resources for the device |
234 | * user_function - Called for each resource | ||
235 | * Context - Passed to user_function | ||
236 | * | 230 | * |
237 | * RETURN: Status | 231 | * RETURN: Status |
238 | * | 232 | * |
239 | * DESCRIPTION: Retrieves the current or possible resource list for the | 233 | * DESCRIPTION: This function is called to get a list of the possible resources |
240 | * specified device. The user_function is called once for | 234 | * for a specific device. The caller must first acquire a handle |
241 | * each resource in the list. | 235 | * for the desired device. The resource data is placed in the |
236 | * buffer pointed to by the ret_buffer variable. | ||
237 | * | ||
238 | * If the function fails an appropriate status will be returned | ||
239 | * and the value of ret_buffer is undefined. | ||
242 | * | 240 | * |
243 | ******************************************************************************/ | 241 | ******************************************************************************/ |
244 | |||
245 | acpi_status | 242 | acpi_status |
246 | acpi_walk_resources(acpi_handle device_handle, | 243 | acpi_get_possible_resources(acpi_handle device_handle, |
247 | char *name, | 244 | struct acpi_buffer *ret_buffer) |
248 | ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) | ||
249 | { | 245 | { |
250 | acpi_status status; | 246 | acpi_status status; |
251 | struct acpi_buffer buffer; | 247 | struct acpi_namespace_node *node; |
252 | struct acpi_resource *resource; | ||
253 | struct acpi_resource *resource_end; | ||
254 | |||
255 | ACPI_FUNCTION_TRACE("acpi_walk_resources"); | ||
256 | |||
257 | /* Parameter validation */ | ||
258 | 248 | ||
259 | if (!device_handle || !user_function || !name || | 249 | ACPI_FUNCTION_TRACE(acpi_get_possible_resources); |
260 | (ACPI_STRNCMP(name, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) && | ||
261 | ACPI_STRNCMP(name, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) { | ||
262 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
263 | } | ||
264 | 250 | ||
265 | /* Get the _CRS or _PRS resource list */ | 251 | /* Validate parameters then dispatch to internal routine */ |
266 | 252 | ||
267 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | 253 | status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node); |
268 | status = acpi_rs_get_method_data(device_handle, name, &buffer); | ||
269 | if (ACPI_FAILURE(status)) { | 254 | if (ACPI_FAILURE(status)) { |
270 | return_ACPI_STATUS(status); | 255 | return_ACPI_STATUS(status); |
271 | } | 256 | } |
272 | 257 | ||
273 | /* Buffer now contains the resource list */ | 258 | status = acpi_rs_get_prs_method_data(node, ret_buffer); |
274 | |||
275 | resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); | ||
276 | resource_end = | ||
277 | ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); | ||
278 | |||
279 | /* Walk the resource list until the end_tag is found (or buffer end) */ | ||
280 | |||
281 | while (resource < resource_end) { | ||
282 | /* Sanity check the resource */ | ||
283 | |||
284 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { | ||
285 | status = AE_AML_INVALID_RESOURCE_TYPE; | ||
286 | break; | ||
287 | } | ||
288 | |||
289 | /* Invoke the user function, abort on any error returned */ | ||
290 | |||
291 | status = user_function(resource, context); | ||
292 | if (ACPI_FAILURE(status)) { | ||
293 | if (status == AE_CTRL_TERMINATE) { | ||
294 | /* This is an OK termination by the user function */ | ||
295 | |||
296 | status = AE_OK; | ||
297 | } | ||
298 | break; | ||
299 | } | ||
300 | |||
301 | /* end_tag indicates end-of-list */ | ||
302 | |||
303 | if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { | ||
304 | break; | ||
305 | } | ||
306 | |||
307 | /* Get the next resource descriptor */ | ||
308 | |||
309 | resource = | ||
310 | ACPI_ADD_PTR(struct acpi_resource, resource, | ||
311 | resource->length); | ||
312 | } | ||
313 | |||
314 | ACPI_MEM_FREE(buffer.pointer); | ||
315 | return_ACPI_STATUS(status); | 259 | return_ACPI_STATUS(status); |
316 | } | 260 | } |
317 | 261 | ||
318 | EXPORT_SYMBOL(acpi_walk_resources); | 262 | ACPI_EXPORT_SYMBOL(acpi_get_possible_resources) |
263 | #endif /* ACPI_FUTURE_USAGE */ | ||
319 | 264 | ||
320 | /******************************************************************************* | 265 | /******************************************************************************* |
321 | * | 266 | * |
322 | * FUNCTION: acpi_set_current_resources | 267 | * FUNCTION: acpi_set_current_resources |
323 | * | 268 | * |
324 | * PARAMETERS: device_handle - a handle to the device object for the | 269 | * PARAMETERS: device_handle - Handle to the device object for the |
325 | * device we are changing the resources of | 270 | * device we are setting resources |
326 | * in_buffer - a pointer to a buffer containing the | 271 | * in_buffer - Pointer to a buffer containing the |
327 | * resources to be set for the device | 272 | * resources to be set for the device |
328 | * | 273 | * |
329 | * RETURN: Status | 274 | * RETURN: Status |
330 | * | 275 | * |
331 | * DESCRIPTION: This function is called to set the current resources for a | 276 | * DESCRIPTION: This function is called to set the current resources for a |
332 | * specific device. The caller must first acquire a handle for | 277 | * specific device. The caller must first acquire a handle for |
333 | * the desired device. The resource data is passed to the routine | 278 | * the desired device. The resource data is passed to the routine |
334 | * the buffer pointed to by the in_buffer variable. | 279 | * the buffer pointed to by the in_buffer variable. |
335 | * | 280 | * |
336 | ******************************************************************************/ | 281 | ******************************************************************************/ |
337 | |||
338 | acpi_status | 282 | acpi_status |
339 | acpi_set_current_resources(acpi_handle device_handle, | 283 | acpi_set_current_resources(acpi_handle device_handle, |
340 | struct acpi_buffer *in_buffer) | 284 | struct acpi_buffer *in_buffer) |
341 | { | 285 | { |
342 | acpi_status status; | 286 | acpi_status status; |
287 | struct acpi_namespace_node *node; | ||
343 | 288 | ||
344 | ACPI_FUNCTION_TRACE("acpi_set_current_resources"); | 289 | ACPI_FUNCTION_TRACE(acpi_set_current_resources); |
345 | 290 | ||
346 | /* Must have a valid handle and buffer */ | 291 | /* Validate the buffer, don't allow zero length */ |
347 | 292 | ||
348 | if ((!device_handle) || | 293 | if ((!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) { |
349 | (!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) { | ||
350 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 294 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
351 | } | 295 | } |
352 | 296 | ||
353 | status = acpi_rs_set_srs_method_data(device_handle, in_buffer); | 297 | /* Validate parameters then dispatch to internal routine */ |
298 | |||
299 | status = acpi_rs_validate_parameters(device_handle, in_buffer, &node); | ||
300 | if (ACPI_FAILURE(status)) { | ||
301 | return_ACPI_STATUS(status); | ||
302 | } | ||
303 | |||
304 | status = acpi_rs_set_srs_method_data(node, in_buffer); | ||
354 | return_ACPI_STATUS(status); | 305 | return_ACPI_STATUS(status); |
355 | } | 306 | } |
356 | 307 | ||
357 | EXPORT_SYMBOL(acpi_set_current_resources); | 308 | ACPI_EXPORT_SYMBOL(acpi_set_current_resources) |
358 | 309 | ||
359 | /****************************************************************************** | 310 | /****************************************************************************** |
360 | * | 311 | * |
361 | * FUNCTION: acpi_resource_to_address64 | 312 | * FUNCTION: acpi_resource_to_address64 |
362 | * | 313 | * |
363 | * PARAMETERS: Resource - Pointer to a resource | 314 | * PARAMETERS: Resource - Pointer to a resource |
364 | * Out - Pointer to the users's return | 315 | * Out - Pointer to the users's return buffer |
365 | * buffer (a struct | 316 | * (a struct acpi_resource_address64) |
366 | * struct acpi_resource_address64) | ||
367 | * | 317 | * |
368 | * RETURN: Status | 318 | * RETURN: Status |
369 | * | 319 | * |
370 | * DESCRIPTION: If the resource is an address16, address32, or address64, | 320 | * DESCRIPTION: If the resource is an address16, address32, or address64, |
371 | * copy it to the address64 return buffer. This saves the | 321 | * copy it to the address64 return buffer. This saves the |
372 | * caller from having to duplicate code for different-sized | 322 | * caller from having to duplicate code for different-sized |
373 | * addresses. | 323 | * addresses. |
374 | * | 324 | * |
375 | ******************************************************************************/ | 325 | ******************************************************************************/ |
376 | |||
377 | acpi_status | 326 | acpi_status |
378 | acpi_resource_to_address64(struct acpi_resource *resource, | 327 | acpi_resource_to_address64(struct acpi_resource *resource, |
379 | struct acpi_resource_address64 *out) | 328 | struct acpi_resource_address64 *out) |
@@ -415,18 +364,18 @@ acpi_resource_to_address64(struct acpi_resource *resource, | |||
415 | return (AE_OK); | 364 | return (AE_OK); |
416 | } | 365 | } |
417 | 366 | ||
418 | EXPORT_SYMBOL(acpi_resource_to_address64); | 367 | ACPI_EXPORT_SYMBOL(acpi_resource_to_address64) |
419 | 368 | ||
420 | /******************************************************************************* | 369 | /******************************************************************************* |
421 | * | 370 | * |
422 | * FUNCTION: acpi_get_vendor_resource | 371 | * FUNCTION: acpi_get_vendor_resource |
423 | * | 372 | * |
424 | * PARAMETERS: device_handle - Handle for the parent device object | 373 | * PARAMETERS: device_handle - Handle for the parent device object |
425 | * Name - Method name for the parent resource | 374 | * Name - Method name for the parent resource |
426 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) | 375 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) |
427 | * Uuid - Pointer to the UUID to be matched. | 376 | * Uuid - Pointer to the UUID to be matched. |
428 | * includes both subtype and 16-byte UUID | 377 | * includes both subtype and 16-byte UUID |
429 | * ret_buffer - Where the vendor resource is returned | 378 | * ret_buffer - Where the vendor resource is returned |
430 | * | 379 | * |
431 | * RETURN: Status | 380 | * RETURN: Status |
432 | * | 381 | * |
@@ -435,7 +384,6 @@ EXPORT_SYMBOL(acpi_resource_to_address64); | |||
435 | * UUID subtype. Returns a struct acpi_resource of type Vendor. | 384 | * UUID subtype. Returns a struct acpi_resource of type Vendor. |
436 | * | 385 | * |
437 | ******************************************************************************/ | 386 | ******************************************************************************/ |
438 | |||
439 | acpi_status | 387 | acpi_status |
440 | acpi_get_vendor_resource(acpi_handle device_handle, | 388 | acpi_get_vendor_resource(acpi_handle device_handle, |
441 | char *name, | 389 | char *name, |
@@ -467,18 +415,19 @@ acpi_get_vendor_resource(acpi_handle device_handle, | |||
467 | return (info.status); | 415 | return (info.status); |
468 | } | 416 | } |
469 | 417 | ||
418 | ACPI_EXPORT_SYMBOL(acpi_get_vendor_resource) | ||
419 | |||
470 | /******************************************************************************* | 420 | /******************************************************************************* |
471 | * | 421 | * |
472 | * FUNCTION: acpi_rs_match_vendor_resource | 422 | * FUNCTION: acpi_rs_match_vendor_resource |
473 | * | 423 | * |
474 | * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK | 424 | * PARAMETERS: acpi_walk_resource_callback |
475 | * | 425 | * |
476 | * RETURN: Status | 426 | * RETURN: Status |
477 | * | 427 | * |
478 | * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID | 428 | * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID |
479 | * | 429 | * |
480 | ******************************************************************************/ | 430 | ******************************************************************************/ |
481 | |||
482 | static acpi_status | 431 | static acpi_status |
483 | acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) | 432 | acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) |
484 | { | 433 | { |
@@ -526,3 +475,101 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) | |||
526 | info->status = AE_OK; | 475 | info->status = AE_OK; |
527 | return (AE_CTRL_TERMINATE); | 476 | return (AE_CTRL_TERMINATE); |
528 | } | 477 | } |
478 | |||
479 | ACPI_EXPORT_SYMBOL(acpi_rs_match_vendor_resource) | ||
480 | |||
481 | /******************************************************************************* | ||
482 | * | ||
483 | * FUNCTION: acpi_walk_resources | ||
484 | * | ||
485 | * PARAMETERS: device_handle - Handle to the device object for the | ||
486 | * device we are querying | ||
487 | * Name - Method name of the resources we want | ||
488 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) | ||
489 | * user_function - Called for each resource | ||
490 | * Context - Passed to user_function | ||
491 | * | ||
492 | * RETURN: Status | ||
493 | * | ||
494 | * DESCRIPTION: Retrieves the current or possible resource list for the | ||
495 | * specified device. The user_function is called once for | ||
496 | * each resource in the list. | ||
497 | * | ||
498 | ******************************************************************************/ | ||
499 | |||
500 | acpi_status | ||
501 | acpi_walk_resources(acpi_handle device_handle, | ||
502 | char *name, | ||
503 | acpi_walk_resource_callback user_function, void *context) | ||
504 | { | ||
505 | acpi_status status; | ||
506 | struct acpi_buffer buffer; | ||
507 | struct acpi_resource *resource; | ||
508 | struct acpi_resource *resource_end; | ||
509 | |||
510 | ACPI_FUNCTION_TRACE(acpi_walk_resources); | ||
511 | |||
512 | /* Parameter validation */ | ||
513 | |||
514 | if (!device_handle || !user_function || !name || | ||
515 | (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) && | ||
516 | !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS))) { | ||
517 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
518 | } | ||
519 | |||
520 | /* Get the _CRS or _PRS resource list */ | ||
521 | |||
522 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
523 | status = acpi_rs_get_method_data(device_handle, name, &buffer); | ||
524 | if (ACPI_FAILURE(status)) { | ||
525 | return_ACPI_STATUS(status); | ||
526 | } | ||
527 | |||
528 | /* Buffer now contains the resource list */ | ||
529 | |||
530 | resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); | ||
531 | resource_end = | ||
532 | ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); | ||
533 | |||
534 | /* Walk the resource list until the end_tag is found (or buffer end) */ | ||
535 | |||
536 | while (resource < resource_end) { | ||
537 | |||
538 | /* Sanity check the resource */ | ||
539 | |||
540 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { | ||
541 | status = AE_AML_INVALID_RESOURCE_TYPE; | ||
542 | break; | ||
543 | } | ||
544 | |||
545 | /* Invoke the user function, abort on any error returned */ | ||
546 | |||
547 | status = user_function(resource, context); | ||
548 | if (ACPI_FAILURE(status)) { | ||
549 | if (status == AE_CTRL_TERMINATE) { | ||
550 | |||
551 | /* This is an OK termination by the user function */ | ||
552 | |||
553 | status = AE_OK; | ||
554 | } | ||
555 | break; | ||
556 | } | ||
557 | |||
558 | /* end_tag indicates end-of-list */ | ||
559 | |||
560 | if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { | ||
561 | break; | ||
562 | } | ||
563 | |||
564 | /* Get the next resource descriptor */ | ||
565 | |||
566 | resource = | ||
567 | ACPI_ADD_PTR(struct acpi_resource, resource, | ||
568 | resource->length); | ||
569 | } | ||
570 | |||
571 | ACPI_FREE(buffer.pointer); | ||
572 | return_ACPI_STATUS(status); | ||
573 | } | ||
574 | |||
575 | ACPI_EXPORT_SYMBOL(acpi_walk_resources) | ||