aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/memblock.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-07-12 05:15:59 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2011-07-14 14:47:47 -0400
commit35fd0808d7d8d001cd72f112e3bca84664b596a3 (patch)
treed4e21e003e182bc4824a74fd850ac3869380b53b /include/linux/memblock.h
parentab5d140b9eafae402aa3e673a63c5ef6164a9dd2 (diff)
memblock: Implement for_each_free_mem_range()
Implement for_each_free_mem_range() which iterates over free memory areas according to memblock (memory && !reserved). This will be used to simplify memblock users. Signed-off-by: Tejun Heo <tj@kernel.org> Link: http://lkml.kernel.org/r/1310462166-31469-7-git-send-email-tj@kernel.org Cc: Yinghai Lu <yinghai@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'include/linux/memblock.h')
-rw-r--r--include/linux/memblock.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index c36a55d3c1c2..31def584cceb 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -61,6 +61,26 @@ extern long memblock_remove(phys_addr_t base, phys_addr_t size);
61extern long memblock_free(phys_addr_t base, phys_addr_t size); 61extern long memblock_free(phys_addr_t base, phys_addr_t size);
62extern long memblock_reserve(phys_addr_t base, phys_addr_t size); 62extern long memblock_reserve(phys_addr_t base, phys_addr_t size);
63 63
64extern void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start,
65 phys_addr_t *out_end, int *out_nid);
66
67/**
68 * for_each_free_mem_range - iterate through free memblock areas
69 * @i: u64 used as loop variable
70 * @nid: node selector, %MAX_NUMNODES for all nodes
71 * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
72 * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
73 * @p_nid: ptr to int for nid of the range, can be %NULL
74 *
75 * Walks over free (memory && !reserved) areas of memblock. Available as
76 * soon as memblock is initialized.
77 */
78#define for_each_free_mem_range(i, nid, p_start, p_end, p_nid) \
79 for (i = 0, \
80 __next_free_mem_range(&i, nid, p_start, p_end, p_nid); \
81 i != (u64)ULLONG_MAX; \
82 __next_free_mem_range(&i, nid, p_start, p_end, p_nid))
83
64#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP 84#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
65extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid); 85extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid);
66 86