diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-08-07 14:07:57 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-08-07 14:07:57 -0400 |
commit | 82df9c8bebeff610705f30315f3903cbcb3aa58b (patch) | |
tree | 0d54eac4e7b46876111256caf169b22627441453 /drivers/of | |
parent | 19583ca584d6f574384e17fe7613dfaeadcdc4a6 (diff) | |
parent | ccbf62d8a284cf181ac28c8e8407dd077d90dd4b (diff) | |
download | talos-op-linux-82df9c8bebeff610705f30315f3903cbcb3aa58b.tar.gz talos-op-linux-82df9c8bebeff610705f30315f3903cbcb3aa58b.zip |
Merge commit 'ccbf62d8a284cf181ac28c8e8407dd077d90dd4b' into for-next
backmerge to avoid kernel/acct.c conflict
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/address.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/of/address.c b/drivers/of/address.c index 5edfcb0da37d..e3718250d66e 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -702,6 +702,42 @@ void __iomem *of_iomap(struct device_node *np, int index) } EXPORT_SYMBOL(of_iomap); +/* + * of_io_request_and_map - Requests a resource and maps the memory mapped IO + * for a given device_node + * @device: the device whose io range will be mapped + * @index: index of the io range + * @name: name of the resource + * + * Returns a pointer to the requested and mapped memory or an ERR_PTR() encoded + * error code on failure. Usage example: + * + * base = of_io_request_and_map(node, 0, "foo"); + * if (IS_ERR(base)) + * return PTR_ERR(base); + */ +void __iomem *of_io_request_and_map(struct device_node *np, int index, + char *name) +{ + struct resource res; + void __iomem *mem; + + if (of_address_to_resource(np, index, &res)) + return IOMEM_ERR_PTR(-EINVAL); + + if (!request_mem_region(res.start, resource_size(&res), name)) + return IOMEM_ERR_PTR(-EBUSY); + + mem = ioremap(res.start, resource_size(&res)); + if (!mem) { + release_mem_region(res.start, resource_size(&res)); + return IOMEM_ERR_PTR(-ENOMEM); + } + + return mem; +} +EXPORT_SYMBOL(of_io_request_and_map); + /** * of_dma_get_range - Get DMA range info * @np: device node to get DMA range info |