Skip to content

Commit

Permalink
efi: create memory map iteration helper
Browse files Browse the repository at this point in the history
There are a lot of places in the kernel which iterate through an
EFI memory map. Most of these places use essentially the same
for-loop code. This patch adds a for_each_efi_memory_desc()
helper to clean up all of the existing duplicate code and avoid
more in the future.

Signed-off-by: Mark Salter <[email protected]>
Signed-off-by: Leif Lindholm <[email protected]>
Signed-off-by: Matt Fleming <[email protected]>
  • Loading branch information
mosalter authored and Matt Fleming committed Apr 14, 2014
1 parent 9403e46 commit e885cd8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/linux/efi.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,12 @@ extern int efi_set_rtc_mmss(const struct timespec *now);
extern void efi_reserve_boot_services(void);
extern struct efi_memory_map memmap;

/* Iterate through an efi_memory_map */
#define for_each_efi_memory_desc(m, md) \
for ((md) = (m)->map; \
(md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \
(md) = (void *)(md) + (m)->desc_size)

/**
* efi_range_is_wc - check the WC bit on an address range
* @start: starting kvirt address
Expand Down

0 comments on commit e885cd8

Please sign in to comment.