From: Philip Prindeville <philipp@xxxxxxxxxxxxxxxxxxxxx> Add support for finding the end-boundary of an E820 region given an address falling in one such region. This is precursory functionality for Coreboot loader support. Signed-off-by: Philip Prindeville <philipp@xxxxxxxxxxxxxxxxxxxxx> Reviewed-by: Ed Wildgoose <ed@xxxxxxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Andres Salomon <dilinger@xxxxxxxxxx> Cc: Nathan Williams <nathan@xxxxxxxxxxxxxxx> Cc: Guy Ellis <guy@xxxxxxxxxxxxxxx> Cc: David Woodhouse <dwmw2@xxxxxxxxxxxxx> Cc: Patrick Georgi <patrick.georgi@xxxxxxxxxxx> Cc: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@xxxxxxx> Cc: linux-geode@xxxxxxxxxxxxxxxxxxx Cc: linux-mm@xxxxxxxxx --- include/linux/ioport.h | 1 + kernel/resource.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 9d57a71..962d5a5 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -223,6 +223,7 @@ extern struct resource * __devm_request_region(struct device *dev, extern void __devm_release_region(struct device *dev, struct resource *parent, resource_size_t start, resource_size_t n); extern int iomem_map_sanity_check(resource_size_t addr, unsigned long size); +extern resource_size_t iomem_map_find_boundary(resource_size_t addr, int *mapped); extern int iomem_is_exclusive(u64 addr); extern int diff --git a/kernel/resource.c b/kernel/resource.c index 7640b3a..58e4fce 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -1057,6 +1057,35 @@ static int __init reserve_setup(char *str) __setup("reserve=", reserve_setup); /* + * Find the upper boundary for the region that this address falls in, and + * whether it's currently mapped or not. + */ + +resource_size_t iomem_map_find_boundary(resource_size_t addr, int *mapped) +{ + struct resource *p = &iomem_resource; + resource_size_t upper = 0; + loff_t l; + + read_lock(&resource_lock); + for (p = p->child; p ; p = r_next(NULL, p, &l)) { + if (p->start > addr) + continue; + if (p->end < addr) + continue; + upper = p->end; + *mapped = ((p->flags & IORESOURCE_BUSY) != 0); + break; + } + read_unlock(&resource_lock); + + return upper; +} + +EXPORT_SYMBOL(iomem_map_find_boundary); + + +/* * Check if the requested addr and size spans more than any slot in the * iomem resource tree. */ -- 1.7.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>