aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources/rscalc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/resources/rscalc.c')
-rw-r--r--drivers/acpi/resources/rscalc.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index d170dee07ce9..c29d3a447278 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -52,7 +52,7 @@ ACPI_MODULE_NAME("rscalc")
52/* Local prototypes */ 52/* Local prototypes */
53static u8 acpi_rs_count_set_bits(u16 bit_field); 53static u8 acpi_rs_count_set_bits(u16 bit_field);
54 54
55static acpi_size 55static acpi_rs_length
56acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); 56acpi_rs_struct_option_length(struct acpi_resource_source *resource_source);
57 57
58static u32 58static u32
@@ -100,7 +100,7 @@ static u8 acpi_rs_count_set_bits(u16 bit_field)
100 * 100 *
101 ******************************************************************************/ 101 ******************************************************************************/
102 102
103static acpi_size 103static acpi_rs_length
104acpi_rs_struct_option_length(struct acpi_resource_source *resource_source) 104acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
105{ 105{
106 ACPI_FUNCTION_ENTRY(); 106 ACPI_FUNCTION_ENTRY();
@@ -111,7 +111,7 @@ acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
111 * resource_source_index (1). 111 * resource_source_index (1).
112 */ 112 */
113 if (resource_source->string_ptr) { 113 if (resource_source->string_ptr) {
114 return ((acpi_size) resource_source->string_length + 1); 114 return ((acpi_rs_length) (resource_source->string_length + 1));
115 } 115 }
116 116
117 return (0); 117 return (0);
@@ -184,7 +184,7 @@ acpi_status
184acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) 184acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
185{ 185{
186 acpi_size aml_size_needed = 0; 186 acpi_size aml_size_needed = 0;
187 acpi_size segment_size; 187 acpi_rs_length total_size;
188 188
189 ACPI_FUNCTION_TRACE("rs_get_aml_length"); 189 ACPI_FUNCTION_TRACE("rs_get_aml_length");
190 190
@@ -199,7 +199,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
199 199
200 /* Get the base size of the (external stream) resource descriptor */ 200 /* Get the base size of the (external stream) resource descriptor */
201 201
202 segment_size = acpi_gbl_aml_resource_sizes[resource->type]; 202 total_size = acpi_gbl_aml_resource_sizes[resource->type];
203 203
204 /* 204 /*
205 * Augment the base size for descriptors with optional and/or 205 * Augment the base size for descriptors with optional and/or
@@ -216,13 +216,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
216 if (resource->data.vendor.byte_length > 7) { 216 if (resource->data.vendor.byte_length > 7) {
217 /* Base size of a Large resource descriptor */ 217 /* Base size of a Large resource descriptor */
218 218
219 segment_size = 219 total_size =
220 sizeof(struct aml_resource_large_header); 220 sizeof(struct aml_resource_large_header);
221 } 221 }
222 222
223 /* Add the size of the vendor-specific data */ 223 /* Add the size of the vendor-specific data */
224 224
225 segment_size += resource->data.vendor.byte_length; 225 total_size = (acpi_rs_length)
226 (total_size + resource->data.vendor.byte_length);
226 break; 227 break;
227 228
228 case ACPI_RESOURCE_TYPE_END_TAG: 229 case ACPI_RESOURCE_TYPE_END_TAG:
@@ -230,7 +231,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
230 * End Tag: 231 * End Tag:
231 * We are done -- return the accumulated total size. 232 * We are done -- return the accumulated total size.
232 */ 233 */
233 *size_needed = aml_size_needed + segment_size; 234 *size_needed = aml_size_needed + total_size;
234 235
235 /* Normal exit */ 236 /* Normal exit */
236 237
@@ -241,10 +242,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
241 * 16-Bit Address Resource: 242 * 16-Bit Address Resource:
242 * Add the size of the optional resource_source info 243 * Add the size of the optional resource_source info
243 */ 244 */
244 segment_size += 245 total_size = (acpi_rs_length)
245 acpi_rs_struct_option_length(&resource->data. 246 (total_size +
246 address16. 247 acpi_rs_struct_option_length(&resource->data.
247 resource_source); 248 address16.
249 resource_source));
248 break; 250 break;
249 251
250 case ACPI_RESOURCE_TYPE_ADDRESS32: 252 case ACPI_RESOURCE_TYPE_ADDRESS32:
@@ -252,10 +254,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
252 * 32-Bit Address Resource: 254 * 32-Bit Address Resource:
253 * Add the size of the optional resource_source info 255 * Add the size of the optional resource_source info
254 */ 256 */
255 segment_size += 257 total_size = (acpi_rs_length)
256 acpi_rs_struct_option_length(&resource->data. 258 (total_size +
257 address32. 259 acpi_rs_struct_option_length(&resource->data.
258 resource_source); 260 address32.
261 resource_source));
259 break; 262 break;
260 263
261 case ACPI_RESOURCE_TYPE_ADDRESS64: 264 case ACPI_RESOURCE_TYPE_ADDRESS64:
@@ -263,10 +266,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
263 * 64-Bit Address Resource: 266 * 64-Bit Address Resource:
264 * Add the size of the optional resource_source info 267 * Add the size of the optional resource_source info
265 */ 268 */
266 segment_size += 269 total_size = (acpi_rs_length)
267 acpi_rs_struct_option_length(&resource->data. 270 (total_size +
268 address64. 271 acpi_rs_struct_option_length(&resource->data.
269 resource_source); 272 address64.
273 resource_source));
270 break; 274 break;
271 275
272 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 276 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
@@ -275,16 +279,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
275 * Add the size of each additional optional interrupt beyond the 279 * Add the size of each additional optional interrupt beyond the
276 * required 1 (4 bytes for each u32 interrupt number) 280 * required 1 (4 bytes for each u32 interrupt number)
277 */ 281 */
278 segment_size += (((acpi_size) 282 total_size = (acpi_rs_length)
279 resource->data.extended_irq. 283 (total_size +
280 interrupt_count - 1) * 4); 284 ((resource->data.extended_irq.interrupt_count -
281 285 1) * 4) +
282 /* Add the size of the optional resource_source info */ 286 /* Add the size of the optional resource_source info */
283 287 acpi_rs_struct_option_length(&resource->data.
284 segment_size += 288 extended_irq.
285 acpi_rs_struct_option_length(&resource->data. 289 resource_source));
286 extended_irq.
287 resource_source);
288 break; 290 break;
289 291
290 default: 292 default:
@@ -293,7 +295,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
293 295
294 /* Update the total */ 296 /* Update the total */
295 297
296 aml_size_needed += segment_size; 298 aml_size_needed += total_size;
297 299
298 /* Point to the next object */ 300 /* Point to the next object */
299 301
@@ -341,7 +343,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
341 while (bytes_parsed < aml_buffer_length) { 343 while (bytes_parsed < aml_buffer_length) {
342 /* The next byte in the stream is the resource descriptor type */ 344 /* The next byte in the stream is the resource descriptor type */
343 345
344 resource_type = acpi_rs_get_resource_type(*aml_buffer); 346 resource_type = acpi_ut_get_resource_type(aml_buffer);
345 347
346 /* Get the base stream size and structure sizes for the descriptor */ 348 /* Get the base stream size and structure sizes for the descriptor */
347 349
@@ -352,10 +354,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
352 354
353 /* Get the Length field from the input resource descriptor */ 355 /* Get the Length field from the input resource descriptor */
354 356
355 resource_length = 357 resource_length = acpi_ut_get_resource_length(aml_buffer);
356 acpi_rs_get_resource_length(ACPI_CAST_PTR
357 (union aml_resource,
358 aml_buffer));
359 358
360 /* Augment the size for descriptors with optional fields */ 359 /* Augment the size for descriptors with optional fields */
361 360