aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2012-12-19 00:38:24 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-10 06:36:19 -0500
commit57bf6aefc2b9c89b89bb3fca54725ceea797bb63 (patch)
tree359d9e7f1ec3203cf3f8d25eaeec5d6c2f9f549b
parent2f3faaba5922d3763f3e9398a2b00dc7239e2d27 (diff)
ACPICA: Enhance the ACPI_GETx and ACPI_SETx macros.
Improve the implementation of the macros. Change the SETx macros to the style of (destination, source). Also add ACPI_CASTx companion macros. Lv Zheng. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/acpica/acmacros.h20
-rw-r--r--drivers/acpi/acpica/exregion.c8
-rw-r--r--drivers/acpi/acpica/rsmisc.c71
3 files changed, 54 insertions, 45 deletions
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 1fa91f1d8994..3ba11d23cba0 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -49,14 +49,18 @@
49 * get into potential aligment issues -- see the STORE macros below. 49 * get into potential aligment issues -- see the STORE macros below.
50 * Use with care. 50 * Use with care.
51 */ 51 */
52#define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr) 52#define ACPI_CAST8(ptr) ACPI_CAST_PTR (u8, (ptr))
53#define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr) 53#define ACPI_CAST16(ptr) ACPI_CAST_PTR (u16, (ptr))
54#define ACPI_GET32(ptr) *ACPI_CAST_PTR (u32, ptr) 54#define ACPI_CAST32(ptr) ACPI_CAST_PTR (u32, (ptr))
55#define ACPI_GET64(ptr) *ACPI_CAST_PTR (u64, ptr) 55#define ACPI_CAST64(ptr) ACPI_CAST_PTR (u64, (ptr))
56#define ACPI_SET8(ptr) *ACPI_CAST_PTR (u8, ptr) 56#define ACPI_GET8(ptr) (*ACPI_CAST8 (ptr))
57#define ACPI_SET16(ptr) *ACPI_CAST_PTR (u16, ptr) 57#define ACPI_GET16(ptr) (*ACPI_CAST16 (ptr))
58#define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr) 58#define ACPI_GET32(ptr) (*ACPI_CAST32 (ptr))
59#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) 59#define ACPI_GET64(ptr) (*ACPI_CAST64 (ptr))
60#define ACPI_SET8(ptr, val) (*ACPI_CAST8 (ptr) = (u8) (val))
61#define ACPI_SET16(ptr, val) (*ACPI_CAST16 (ptr) = (u16) (val))
62#define ACPI_SET32(ptr, val) (*ACPI_CAST32 (ptr) = (u32) (val))
63#define ACPI_SET64(ptr, val) (*ACPI_CAST64 (ptr) = (u64) (val))
60 64
61/* 65/*
62 * printf() format helpers 66 * printf() format helpers
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 06a49245f410..28d3cd975490 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -239,19 +239,19 @@ acpi_ex_system_memory_space_handler(u32 function,
239 239
240 switch (bit_width) { 240 switch (bit_width) {
241 case 8: 241 case 8:
242 ACPI_SET8(logical_addr_ptr) = (u8)*value; 242 ACPI_SET8(logical_addr_ptr, *value);
243 break; 243 break;
244 244
245 case 16: 245 case 16:
246 ACPI_SET16(logical_addr_ptr) = (u16)*value; 246 ACPI_SET16(logical_addr_ptr, *value);
247 break; 247 break;
248 248
249 case 32: 249 case 32:
250 ACPI_SET32(logical_addr_ptr) = (u32)*value; 250 ACPI_SET32(logical_addr_ptr, *value);
251 break; 251 break;
252 252
253 case 64: 253 case 64:
254 ACPI_SET64(logical_addr_ptr) = (u64)*value; 254 ACPI_SET64(logical_addr_ptr, *value);
255 break; 255 break;
256 256
257 default: 257 default:
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index 3d0e15cd1276..7b094ebff1db 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -136,30 +136,30 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
136 /* 136 /*
137 * Mask and shift the flag bit 137 * Mask and shift the flag bit
138 */ 138 */
139 ACPI_SET8(destination) = (u8) 139 ACPI_SET8(destination,
140 ((ACPI_GET8(source) >> info->value) & 0x01); 140 ((ACPI_GET8(source) >> info->value) & 0x01));
141 break; 141 break;
142 142
143 case ACPI_RSC_2BITFLAG: 143 case ACPI_RSC_2BITFLAG:
144 /* 144 /*
145 * Mask and shift the flag bits 145 * Mask and shift the flag bits
146 */ 146 */
147 ACPI_SET8(destination) = (u8) 147 ACPI_SET8(destination,
148 ((ACPI_GET8(source) >> info->value) & 0x03); 148 ((ACPI_GET8(source) >> info->value) & 0x03));
149 break; 149 break;
150 150
151 case ACPI_RSC_3BITFLAG: 151 case ACPI_RSC_3BITFLAG:
152 /* 152 /*
153 * Mask and shift the flag bits 153 * Mask and shift the flag bits
154 */ 154 */
155 ACPI_SET8(destination) = (u8) 155 ACPI_SET8(destination,
156 ((ACPI_GET8(source) >> info->value) & 0x07); 156 ((ACPI_GET8(source) >> info->value) & 0x07));
157 break; 157 break;
158 158
159 case ACPI_RSC_COUNT: 159 case ACPI_RSC_COUNT:
160 160
161 item_count = ACPI_GET8(source); 161 item_count = ACPI_GET8(source);
162 ACPI_SET8(destination) = (u8)item_count; 162 ACPI_SET8(destination, item_count);
163 163
164 resource->length = resource->length + 164 resource->length = resource->length +
165 (info->value * (item_count - 1)); 165 (info->value * (item_count - 1));
@@ -168,7 +168,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
168 case ACPI_RSC_COUNT16: 168 case ACPI_RSC_COUNT16:
169 169
170 item_count = aml_resource_length; 170 item_count = aml_resource_length;
171 ACPI_SET16(destination) = item_count; 171 ACPI_SET16(destination, item_count);
172 172
173 resource->length = resource->length + 173 resource->length = resource->length +
174 (info->value * (item_count - 1)); 174 (info->value * (item_count - 1));
@@ -181,13 +181,13 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
181 181
182 resource->length = resource->length + item_count; 182 resource->length = resource->length + item_count;
183 item_count = item_count / 2; 183 item_count = item_count / 2;
184 ACPI_SET16(destination) = item_count; 184 ACPI_SET16(destination, item_count);
185 break; 185 break;
186 186
187 case ACPI_RSC_COUNT_GPIO_VEN: 187 case ACPI_RSC_COUNT_GPIO_VEN:
188 188
189 item_count = ACPI_GET8(source); 189 item_count = ACPI_GET8(source);
190 ACPI_SET8(destination) = (u8)item_count; 190 ACPI_SET8(destination, item_count);
191 191
192 resource->length = resource->length + 192 resource->length = resource->length +
193 (info->value * item_count); 193 (info->value * item_count);
@@ -216,7 +216,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
216 } 216 }
217 217
218 resource->length = resource->length + item_count; 218 resource->length = resource->length + item_count;
219 ACPI_SET16(destination) = item_count; 219 ACPI_SET16(destination, item_count);
220 break; 220 break;
221 221
222 case ACPI_RSC_COUNT_SERIAL_VEN: 222 case ACPI_RSC_COUNT_SERIAL_VEN:
@@ -224,7 +224,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
224 item_count = ACPI_GET16(source) - info->value; 224 item_count = ACPI_GET16(source) - info->value;
225 225
226 resource->length = resource->length + item_count; 226 resource->length = resource->length + item_count;
227 ACPI_SET16(destination) = item_count; 227 ACPI_SET16(destination, item_count);
228 break; 228 break;
229 229
230 case ACPI_RSC_COUNT_SERIAL_RES: 230 case ACPI_RSC_COUNT_SERIAL_RES:
@@ -234,7 +234,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
234 - ACPI_GET16(source) - info->value; 234 - ACPI_GET16(source) - info->value;
235 235
236 resource->length = resource->length + item_count; 236 resource->length = resource->length + item_count;
237 ACPI_SET16(destination) = item_count; 237 ACPI_SET16(destination, item_count);
238 break; 238 break;
239 239
240 case ACPI_RSC_LENGTH: 240 case ACPI_RSC_LENGTH:
@@ -385,7 +385,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
385 } 385 }
386 386
387 target = ACPI_ADD_PTR(char, resource, info->value); 387 target = ACPI_ADD_PTR(char, resource, info->value);
388 ACPI_SET8(target) = (u8)item_count; 388 ACPI_SET8(target, item_count);
389 break; 389 break;
390 390
391 case ACPI_RSC_BITMASK16: 391 case ACPI_RSC_BITMASK16:
@@ -401,7 +401,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
401 } 401 }
402 402
403 target = ACPI_ADD_PTR(char, resource, info->value); 403 target = ACPI_ADD_PTR(char, resource, info->value);
404 ACPI_SET8(target) = (u8)item_count; 404 ACPI_SET8(target, item_count);
405 break; 405 break;
406 406
407 case ACPI_RSC_EXIT_NE: 407 case ACPI_RSC_EXIT_NE:
@@ -514,37 +514,40 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
514 /* 514 /*
515 * Clear the flag byte 515 * Clear the flag byte
516 */ 516 */
517 ACPI_SET8(destination) = 0; 517 ACPI_SET8(destination, 0);
518 break; 518 break;
519 519
520 case ACPI_RSC_1BITFLAG: 520 case ACPI_RSC_1BITFLAG:
521 /* 521 /*
522 * Mask and shift the flag bit 522 * Mask and shift the flag bit
523 */ 523 */
524 ACPI_SET8(destination) |= (u8) 524 ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
525 ((ACPI_GET8(source) & 0x01) << info->value); 525 ((ACPI_GET8(source) & 0x01) << info->
526 value));
526 break; 527 break;
527 528
528 case ACPI_RSC_2BITFLAG: 529 case ACPI_RSC_2BITFLAG:
529 /* 530 /*
530 * Mask and shift the flag bits 531 * Mask and shift the flag bits
531 */ 532 */
532 ACPI_SET8(destination) |= (u8) 533 ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
533 ((ACPI_GET8(source) & 0x03) << info->value); 534 ((ACPI_GET8(source) & 0x03) << info->
535 value));
534 break; 536 break;
535 537
536 case ACPI_RSC_3BITFLAG: 538 case ACPI_RSC_3BITFLAG:
537 /* 539 /*
538 * Mask and shift the flag bits 540 * Mask and shift the flag bits
539 */ 541 */
540 ACPI_SET8(destination) |= (u8) 542 ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
541 ((ACPI_GET8(source) & 0x07) << info->value); 543 ((ACPI_GET8(source) & 0x07) << info->
544 value));
542 break; 545 break;
543 546
544 case ACPI_RSC_COUNT: 547 case ACPI_RSC_COUNT:
545 548
546 item_count = ACPI_GET8(source); 549 item_count = ACPI_GET8(source);
547 ACPI_SET8(destination) = (u8)item_count; 550 ACPI_SET8(destination, item_count);
548 551
549 aml_length = 552 aml_length =
550 (u16) (aml_length + 553 (u16) (aml_length +
@@ -561,18 +564,18 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
561 case ACPI_RSC_COUNT_GPIO_PIN: 564 case ACPI_RSC_COUNT_GPIO_PIN:
562 565
563 item_count = ACPI_GET16(source); 566 item_count = ACPI_GET16(source);
564 ACPI_SET16(destination) = (u16)aml_length; 567 ACPI_SET16(destination, aml_length);
565 568
566 aml_length = (u16)(aml_length + item_count * 2); 569 aml_length = (u16)(aml_length + item_count * 2);
567 target = ACPI_ADD_PTR(void, aml, info->value); 570 target = ACPI_ADD_PTR(void, aml, info->value);
568 ACPI_SET16(target) = (u16)aml_length; 571 ACPI_SET16(target, aml_length);
569 acpi_rs_set_resource_length(aml_length, aml); 572 acpi_rs_set_resource_length(aml_length, aml);
570 break; 573 break;
571 574
572 case ACPI_RSC_COUNT_GPIO_VEN: 575 case ACPI_RSC_COUNT_GPIO_VEN:
573 576
574 item_count = ACPI_GET16(source); 577 item_count = ACPI_GET16(source);
575 ACPI_SET16(destination) = (u16)item_count; 578 ACPI_SET16(destination, item_count);
576 579
577 aml_length = 580 aml_length =
578 (u16)(aml_length + (info->value * item_count)); 581 (u16)(aml_length + (info->value * item_count));
@@ -584,7 +587,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
584 /* Set resource source string length */ 587 /* Set resource source string length */
585 588
586 item_count = ACPI_GET16(source); 589 item_count = ACPI_GET16(source);
587 ACPI_SET16(destination) = (u16)aml_length; 590 ACPI_SET16(destination, aml_length);
588 591
589 /* Compute offset for the Vendor Data */ 592 /* Compute offset for the Vendor Data */
590 593
@@ -594,7 +597,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
594 /* Set vendor offset only if there is vendor data */ 597 /* Set vendor offset only if there is vendor data */
595 598
596 if (resource->data.gpio.vendor_length) { 599 if (resource->data.gpio.vendor_length) {
597 ACPI_SET16(target) = (u16)aml_length; 600 ACPI_SET16(target, aml_length);
598 } 601 }
599 602
600 acpi_rs_set_resource_length(aml_length, aml); 603 acpi_rs_set_resource_length(aml_length, aml);
@@ -603,7 +606,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
603 case ACPI_RSC_COUNT_SERIAL_VEN: 606 case ACPI_RSC_COUNT_SERIAL_VEN:
604 607
605 item_count = ACPI_GET16(source); 608 item_count = ACPI_GET16(source);
606 ACPI_SET16(destination) = item_count + info->value; 609 ACPI_SET16(destination, item_count + info->value);
607 aml_length = (u16)(aml_length + item_count); 610 aml_length = (u16)(aml_length + item_count);
608 acpi_rs_set_resource_length(aml_length, aml); 611 acpi_rs_set_resource_length(aml_length, aml);
609 break; 612 break;
@@ -707,10 +710,12 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
707 /* 710 /*
708 * 8-bit encoded bitmask (DMA macro) 711 * 8-bit encoded bitmask (DMA macro)
709 */ 712 */
710 ACPI_SET8(destination) = (u8) 713 ACPI_SET8(destination,
711 acpi_rs_encode_bitmask(source, 714 acpi_rs_encode_bitmask(source,
712 *ACPI_ADD_PTR(u8, resource, 715 *ACPI_ADD_PTR(u8,
713 info->value)); 716 resource,
717 info->
718 value)));
714 break; 719 break;
715 720
716 case ACPI_RSC_BITMASK16: 721 case ACPI_RSC_BITMASK16: