diff options
Diffstat (limited to 'drivers/acpi/resources/rsmisc.c')
-rw-r--r-- | drivers/acpi/resources/rsmisc.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index 16ad3bfbee2..e1b5aa2af9a 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c | |||
@@ -104,8 +104,9 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
104 | * Source is the external AML byte stream buffer, | 104 | * Source is the external AML byte stream buffer, |
105 | * destination is the internal resource descriptor | 105 | * destination is the internal resource descriptor |
106 | */ | 106 | */ |
107 | source = ((u8 *) aml) + info->aml_offset; | 107 | source = ACPI_ADD_PTR(void, aml, info->aml_offset); |
108 | destination = ((u8 *) resource) + info->resource_offset; | 108 | destination = |
109 | ACPI_ADD_PTR(void, resource, info->resource_offset); | ||
109 | 110 | ||
110 | switch (info->opcode) { | 111 | switch (info->opcode) { |
111 | case ACPI_RSC_INITGET: | 112 | case ACPI_RSC_INITGET: |
@@ -129,22 +130,22 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
129 | /* | 130 | /* |
130 | * Mask and shift the flag bit | 131 | * Mask and shift the flag bit |
131 | */ | 132 | */ |
132 | *((u8 *) destination) = (u8) | 133 | ACPI_SET8(destination) = (u8) |
133 | ((*((u8 *) source) >> info->value) & 0x01); | 134 | ((ACPI_GET8(source) >> info->value) & 0x01); |
134 | break; | 135 | break; |
135 | 136 | ||
136 | case ACPI_RSC_2BITFLAG: | 137 | case ACPI_RSC_2BITFLAG: |
137 | /* | 138 | /* |
138 | * Mask and shift the flag bits | 139 | * Mask and shift the flag bits |
139 | */ | 140 | */ |
140 | *((u8 *) destination) = (u8) | 141 | ACPI_SET8(destination) = (u8) |
141 | ((*((u8 *) source) >> info->value) & 0x03); | 142 | ((ACPI_GET8(source) >> info->value) & 0x03); |
142 | break; | 143 | break; |
143 | 144 | ||
144 | case ACPI_RSC_COUNT: | 145 | case ACPI_RSC_COUNT: |
145 | 146 | ||
146 | item_count = *((u8 *) source); | 147 | item_count = ACPI_GET8(source); |
147 | *((u8 *) destination) = (u8) item_count; | 148 | ACPI_SET8(destination) = (u8) item_count; |
148 | 149 | ||
149 | resource->length = resource->length + | 150 | resource->length = resource->length + |
150 | (info->value * (item_count - 1)); | 151 | (info->value * (item_count - 1)); |
@@ -153,7 +154,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
153 | case ACPI_RSC_COUNT16: | 154 | case ACPI_RSC_COUNT16: |
154 | 155 | ||
155 | item_count = aml_resource_length; | 156 | item_count = aml_resource_length; |
156 | *((u16 *) destination) = item_count; | 157 | ACPI_SET16(destination) = item_count; |
157 | 158 | ||
158 | resource->length = resource->length + | 159 | resource->length = resource->length + |
159 | (info->value * (item_count - 1)); | 160 | (info->value * (item_count - 1)); |
@@ -186,9 +187,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
186 | 187 | ||
187 | case ACPI_RSC_DATA8: | 188 | case ACPI_RSC_DATA8: |
188 | 189 | ||
189 | target = ((char *)resource) + info->value; | 190 | target = ACPI_ADD_PTR(char, resource, info->value); |
190 | ACPI_MEMCPY(destination, source, | 191 | ACPI_MEMCPY(destination, source, ACPI_GET16(target)); |
191 | *(ACPI_CAST_PTR(u16, target))); | ||
192 | break; | 192 | break; |
193 | 193 | ||
194 | case ACPI_RSC_ADDRESS: | 194 | case ACPI_RSC_ADDRESS: |
@@ -217,8 +217,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
217 | * complicated case used by the Interrupt() macro | 217 | * complicated case used by the Interrupt() macro |
218 | */ | 218 | */ |
219 | target = | 219 | target = |
220 | ((char *)resource) + info->aml_offset + | 220 | ACPI_ADD_PTR(char, resource, |
221 | (item_count * 4); | 221 | info->aml_offset + (item_count * 4)); |
222 | 222 | ||
223 | resource->length += | 223 | resource->length += |
224 | acpi_rs_get_resource_source(aml_resource_length, | 224 | acpi_rs_get_resource_source(aml_resource_length, |
@@ -230,15 +230,14 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
230 | * 8-bit encoded bitmask (DMA macro) | 230 | * 8-bit encoded bitmask (DMA macro) |
231 | */ | 231 | */ |
232 | item_count = | 232 | item_count = |
233 | acpi_rs_decode_bitmask(*((u8 *) source), | 233 | acpi_rs_decode_bitmask(ACPI_GET8(source), |
234 | destination); | 234 | destination); |
235 | if (item_count) { | 235 | if (item_count) { |
236 | resource->length += | 236 | resource->length += (item_count - 1); |
237 | resource->length + (item_count - 1); | ||
238 | } | 237 | } |
239 | 238 | ||
240 | target = ((char *)resource) + info->value; | 239 | target = ACPI_ADD_PTR(char, resource, info->value); |
241 | *((u8 *) target) = (u8) item_count; | 240 | ACPI_SET8(target) = (u8) item_count; |
242 | break; | 241 | break; |
243 | 242 | ||
244 | case ACPI_RSC_BITMASK16: | 243 | case ACPI_RSC_BITMASK16: |
@@ -250,12 +249,11 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
250 | item_count = | 249 | item_count = |
251 | acpi_rs_decode_bitmask(temp16, destination); | 250 | acpi_rs_decode_bitmask(temp16, destination); |
252 | if (item_count) { | 251 | if (item_count) { |
253 | resource->length = | 252 | resource->length += (item_count - 1); |
254 | resource->length + (item_count - 1); | ||
255 | } | 253 | } |
256 | 254 | ||
257 | target = ((char *)resource) + info->value; | 255 | target = ACPI_ADD_PTR(char, resource, info->value); |
258 | *((u8 *) target) = (u8) item_count; | 256 | ACPI_SET8(target) = (u8) item_count; |
259 | break; | 257 | break; |
260 | 258 | ||
261 | case ACPI_RSC_EXIT_NE: | 259 | case ACPI_RSC_EXIT_NE: |
@@ -270,7 +268,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
270 | break; | 268 | break; |
271 | 269 | ||
272 | case ACPI_RSC_COMPARE_VALUE: | 270 | case ACPI_RSC_COMPARE_VALUE: |
273 | if (*((u8 *) source) != info->value) { | 271 | if (ACPI_GET8(source) != info->value) { |
274 | goto exit; | 272 | goto exit; |
275 | } | 273 | } |
276 | break; | 274 | break; |
@@ -349,8 +347,8 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, | |||
349 | * Source is the internal resource descriptor, | 347 | * Source is the internal resource descriptor, |
350 | * destination is the external AML byte stream buffer | 348 | * destination is the external AML byte stream buffer |
351 | */ | 349 | */ |
352 | source = ((u8 *) resource) + info->resource_offset; | 350 | source = ACPI_ADD_PTR(void, resource, info->resource_offset); |
353 | destination = ((u8 *) aml) + info->aml_offset; | 351 | destination = ACPI_ADD_PTR(void, aml, info->aml_offset); |
354 | 352 | ||
355 | switch (info->opcode) { | 353 | switch (info->opcode) { |
356 | case ACPI_RSC_INITSET: | 354 | case ACPI_RSC_INITSET: |
@@ -368,37 +366,38 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, | |||
368 | /* | 366 | /* |
369 | * Clear the flag byte | 367 | * Clear the flag byte |
370 | */ | 368 | */ |
371 | *((u8 *) destination) = 0; | 369 | ACPI_SET8(destination) = 0; |
372 | break; | 370 | break; |
373 | 371 | ||
374 | case ACPI_RSC_1BITFLAG: | 372 | case ACPI_RSC_1BITFLAG: |
375 | /* | 373 | /* |
376 | * Mask and shift the flag bit | 374 | * Mask and shift the flag bit |
377 | */ | 375 | */ |
378 | *((u8 *) destination) |= (u8) | 376 | ACPI_SET8(destination) |= (u8) |
379 | ((*((u8 *) source) & 0x01) << info->value); | 377 | ((ACPI_GET8(source) & 0x01) << info->value); |
380 | break; | 378 | break; |
381 | 379 | ||
382 | case ACPI_RSC_2BITFLAG: | 380 | case ACPI_RSC_2BITFLAG: |
383 | /* | 381 | /* |
384 | * Mask and shift the flag bits | 382 | * Mask and shift the flag bits |
385 | */ | 383 | */ |
386 | *((u8 *) destination) |= (u8) | 384 | ACPI_SET8(destination) |= (u8) |
387 | ((*((u8 *) source) & 0x03) << info->value); | 385 | ((ACPI_GET8(source) & 0x03) << info->value); |
388 | break; | 386 | break; |
389 | 387 | ||
390 | case ACPI_RSC_COUNT: | 388 | case ACPI_RSC_COUNT: |
391 | 389 | ||
392 | item_count = *((u8 *) source); | 390 | item_count = ACPI_GET8(source); |
393 | *((u8 *) destination) = (u8) item_count; | 391 | ACPI_SET8(destination) = (u8) item_count; |
394 | 392 | ||
395 | aml_length = (u16) (aml_length + | 393 | aml_length = |
396 | (info->value * (item_count - 1))); | 394 | (u16) (aml_length + |
395 | (info->value * (item_count - 1))); | ||
397 | break; | 396 | break; |
398 | 397 | ||
399 | case ACPI_RSC_COUNT16: | 398 | case ACPI_RSC_COUNT16: |
400 | 399 | ||
401 | item_count = *((u16 *) source); | 400 | item_count = ACPI_GET16(source); |
402 | aml_length = (u16) (aml_length + item_count); | 401 | aml_length = (u16) (aml_length + item_count); |
403 | acpi_rs_set_resource_length(aml_length, aml); | 402 | acpi_rs_set_resource_length(aml_length, aml); |
404 | break; | 403 | break; |
@@ -453,20 +452,21 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, | |||
453 | /* | 452 | /* |
454 | * 8-bit encoded bitmask (DMA macro) | 453 | * 8-bit encoded bitmask (DMA macro) |
455 | */ | 454 | */ |
456 | *((u8 *) destination) = (u8) | 455 | ACPI_SET8(destination) = (u8) |
457 | acpi_rs_encode_bitmask(source, | 456 | acpi_rs_encode_bitmask(source, |
458 | *(((u8 *) resource) + | 457 | *ACPI_ADD_PTR(u8, resource, |
459 | info->value)); | 458 | info->value)); |
460 | break; | 459 | break; |
461 | 460 | ||
462 | case ACPI_RSC_BITMASK16: | 461 | case ACPI_RSC_BITMASK16: |
463 | /* | 462 | /* |
464 | * 16-bit encoded bitmask (IRQ macro) | 463 | * 16-bit encoded bitmask (IRQ macro) |
465 | */ | 464 | */ |
466 | temp16 = | 465 | temp16 = acpi_rs_encode_bitmask(source, |
467 | acpi_rs_encode_bitmask(source, | 466 | *ACPI_ADD_PTR(u8, |
468 | *(((u8 *) resource) + | 467 | resource, |
469 | info->value)); | 468 | info-> |
469 | value)); | ||
470 | ACPI_MOVE_16_TO_16(destination, &temp16); | 470 | ACPI_MOVE_16_TO_16(destination, &temp16); |
471 | break; | 471 | break; |
472 | 472 | ||
@@ -485,9 +485,9 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, | |||
485 | */ | 485 | */ |
486 | switch (COMPARE_OPCODE(info)) { | 486 | switch (COMPARE_OPCODE(info)) { |
487 | case ACPI_RSC_COMPARE_VALUE: | 487 | case ACPI_RSC_COMPARE_VALUE: |
488 | if (* | 488 | |
489 | ((u8 *) (((u8 *) resource) + | 489 | if (*ACPI_ADD_PTR(u8, resource, |
490 | COMPARE_TARGET(info))) != | 490 | COMPARE_TARGET(info)) != |
491 | COMPARE_VALUE(info)) { | 491 | COMPARE_VALUE(info)) { |
492 | goto exit; | 492 | goto exit; |
493 | } | 493 | } |