aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/osl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/osl.c')
-rw-r--r--drivers/acpi/osl.c54
1 files changed, 11 insertions, 43 deletions
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index fc8a3bce6cbb..13b5fd5854a8 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -180,22 +180,14 @@ acpi_status
180acpi_os_map_memory(acpi_physical_address phys, acpi_size size, 180acpi_os_map_memory(acpi_physical_address phys, acpi_size size,
181 void __iomem ** virt) 181 void __iomem ** virt)
182{ 182{
183 if (efi_enabled) { 183 if (phys > ULONG_MAX) {
184 if (EFI_MEMORY_WB & efi_mem_attributes(phys)) { 184 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
185 *virt = (void __iomem *)phys_to_virt(phys); 185 return AE_BAD_PARAMETER;
186 } else {
187 *virt = ioremap(phys, size);
188 }
189 } else {
190 if (phys > ULONG_MAX) {
191 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
192 return AE_BAD_PARAMETER;
193 }
194 /*
195 * ioremap checks to ensure this is in reserved space
196 */
197 *virt = ioremap((unsigned long)phys, size);
198 } 186 }
187 /*
188 * ioremap checks to ensure this is in reserved space
189 */
190 *virt = ioremap((unsigned long)phys, size);
199 191
200 if (!*virt) 192 if (!*virt)
201 return AE_NO_MEMORY; 193 return AE_NO_MEMORY;
@@ -407,18 +399,8 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
407{ 399{
408 u32 dummy; 400 u32 dummy;
409 void __iomem *virt_addr; 401 void __iomem *virt_addr;
410 int iomem = 0;
411 402
412 if (efi_enabled) { 403 virt_addr = ioremap(phys_addr, width);
413 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
414 /* HACK ALERT! We can use readb/w/l on real memory too.. */
415 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
416 } else {
417 iomem = 1;
418 virt_addr = ioremap(phys_addr, width);
419 }
420 } else
421 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
422 if (!value) 404 if (!value)
423 value = &dummy; 405 value = &dummy;
424 406
@@ -436,10 +418,7 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
436 BUG(); 418 BUG();
437 } 419 }
438 420
439 if (efi_enabled) { 421 iounmap(virt_addr);
440 if (iomem)
441 iounmap(virt_addr);
442 }
443 422
444 return AE_OK; 423 return AE_OK;
445} 424}
@@ -448,18 +427,8 @@ acpi_status
448acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) 427acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
449{ 428{
450 void __iomem *virt_addr; 429 void __iomem *virt_addr;
451 int iomem = 0;
452 430
453 if (efi_enabled) { 431 virt_addr = ioremap(phys_addr, width);
454 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
455 /* HACK ALERT! We can use writeb/w/l on real memory too */
456 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
457 } else {
458 iomem = 1;
459 virt_addr = ioremap(phys_addr, width);
460 }
461 } else
462 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
463 432
464 switch (width) { 433 switch (width) {
465 case 8: 434 case 8:
@@ -475,8 +444,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
475 BUG(); 444 BUG();
476 } 445 }
477 446
478 if (iomem) 447 iounmap(virt_addr);
479 iounmap(virt_addr);
480 448
481 return AE_OK; 449 return AE_OK;
482} 450}