--- zzzz-none-000/linux-3.10.107/drivers/acpi/acpica/exregion.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/acpi/acpica/exregion.c 2021-02-04 17:41:59.000000000 +0000 @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2015, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,22 +88,27 @@ switch (bit_width) { case 8: + length = 1; break; case 16: + length = 2; break; case 32: + length = 4; break; case 64: + length = 8; break; default: + ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u", bit_width)); return_ACPI_STATUS(AE_AML_OPERAND_VALUE); @@ -160,8 +165,8 @@ * one page, which is similar to the original code that used a 4k * maximum window. */ - page_boundary_map_length = - ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address; + page_boundary_map_length = (acpi_size) + (ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address); if (page_boundary_map_length == 0) { page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE; } @@ -172,12 +177,13 @@ /* Create a new mapping starting at the address given */ - mem_info->mapped_logical_address = acpi_os_map_memory((acpi_physical_address) address, map_length); + mem_info->mapped_logical_address = + acpi_os_map_memory(address, map_length); if (!mem_info->mapped_logical_address) { ACPI_ERROR((AE_INFO, "Could not map memory at 0x%8.8X%8.8X, size %u", ACPI_FORMAT_UINT64(address), - (u32) map_length)); + (u32)map_length)); mem_info->mapped_length = 0; return_ACPI_STATUS(AE_NO_MEMORY); } @@ -213,23 +219,29 @@ *value = 0; switch (bit_width) { case 8: - *value = (u64) ACPI_GET8(logical_addr_ptr); + + *value = (u64)ACPI_GET8(logical_addr_ptr); break; case 16: - *value = (u64) ACPI_GET16(logical_addr_ptr); + + *value = (u64)ACPI_GET16(logical_addr_ptr); break; case 32: - *value = (u64) ACPI_GET32(logical_addr_ptr); + + *value = (u64)ACPI_GET32(logical_addr_ptr); break; case 64: - *value = (u64) ACPI_GET64(logical_addr_ptr); + + *value = (u64)ACPI_GET64(logical_addr_ptr); break; default: + /* bit_width was already validated */ + break; } break; @@ -238,28 +250,35 @@ switch (bit_width) { case 8: + ACPI_SET8(logical_addr_ptr, *value); break; case 16: + ACPI_SET16(logical_addr_ptr, *value); break; case 32: + ACPI_SET32(logical_addr_ptr, *value); break; case 64: + ACPI_SET64(logical_addr_ptr, *value); break; default: + /* bit_width was already validated */ + break; } break; default: + status = AE_BAD_PARAMETER; break; } @@ -318,6 +337,7 @@ break; default: + status = AE_BAD_PARAMETER; break; } @@ -379,6 +399,7 @@ switch (function) { case ACPI_READ: + *value = 0; status = acpi_os_read_pci_configuration(pci_id, pci_register, value, bit_width); break; @@ -496,15 +517,14 @@ switch (function) { case ACPI_READ: - ACPI_MEMCPY(ACPI_CAST_PTR(char, value), - ACPI_PHYSADDR_TO_PTR(address), - ACPI_DIV_8(bit_width)); + memcpy(ACPI_CAST_PTR(char, value), + ACPI_PHYSADDR_TO_PTR(address), ACPI_DIV_8(bit_width)); break; case ACPI_WRITE: - ACPI_MEMCPY(ACPI_PHYSADDR_TO_PTR(address), - ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width)); + memcpy(ACPI_PHYSADDR_TO_PTR(address), + ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width)); break; default: