mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
efi: Move efi_mem_type() to common code
This follows efi_mem_attributes(), as it's similarly generic. Drop
__weak from that one though (and don't introduce it for efi_mem_type()
in the first place) to make clear that other overrides to these
functions are really not intended.
Signed-off-by: Jan Beulich <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Matt Fleming <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
[ Resolved conflict with: f99afd08a4: (efi: Update efi_mem_type() to return an error rather than 0) ]
Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
68ee51cb77
commit
23f0571c9f
2 changed files with 31 additions and 25 deletions
|
|
@ -810,6 +810,11 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
|
|||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* IA64 has a funky EFI memory map that doesn't work the same way as
|
||||
* other architectures.
|
||||
*/
|
||||
#ifndef CONFIG_IA64
|
||||
/*
|
||||
* efi_mem_attributes - lookup memmap attributes for physical address
|
||||
* @phys_addr: the physical address to lookup
|
||||
|
|
@ -817,13 +822,8 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
|
|||
* Search in the EFI memory map for the region covering
|
||||
* @phys_addr. Returns the EFI memory attributes if the region
|
||||
* was found in the memory map, 0 otherwise.
|
||||
*
|
||||
* Despite being marked __weak, most architectures should *not*
|
||||
* override this function. It is __weak solely for the benefit
|
||||
* of ia64 which has a funky EFI memory map that doesn't work
|
||||
* the same way as other architectures.
|
||||
*/
|
||||
u64 __weak efi_mem_attributes(unsigned long phys_addr)
|
||||
u64 efi_mem_attributes(unsigned long phys_addr)
|
||||
{
|
||||
efi_memory_desc_t *md;
|
||||
|
||||
|
|
@ -839,6 +839,31 @@ u64 __weak efi_mem_attributes(unsigned long phys_addr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* efi_mem_type - lookup memmap type for physical address
|
||||
* @phys_addr: the physical address to lookup
|
||||
*
|
||||
* Search in the EFI memory map for the region covering @phys_addr.
|
||||
* Returns the EFI memory type if the region was found in the memory
|
||||
* map, EFI_RESERVED_TYPE (zero) otherwise.
|
||||
*/
|
||||
int efi_mem_type(unsigned long phys_addr)
|
||||
{
|
||||
const efi_memory_desc_t *md;
|
||||
|
||||
if (!efi_enabled(EFI_MEMMAP))
|
||||
return -ENOTSUPP;
|
||||
|
||||
for_each_efi_memory_desc(md) {
|
||||
if ((md->phys_addr <= phys_addr) &&
|
||||
(phys_addr < (md->phys_addr +
|
||||
(md->num_pages << EFI_PAGE_SHIFT))))
|
||||
return md->type;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int efi_status_to_err(efi_status_t status)
|
||||
{
|
||||
int err;
|
||||
|
|
|
|||
Loading…
Reference in a new issue