diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-24 08:00:13 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-24 08:00:13 +0200 |
commit | 670d198b61ebfb4c9b13e50dccbd904a62ae593c (patch) | |
tree | 0040734e652345bef45c345c6fc354f664755da8 /lib | |
parent | bce5c2ea350f5a57353295534faba00b28cadf14 (diff) | |
parent | 0a213777d1dd879092225a7aa847b6e9b3a1c267 (diff) | |
download | linux-670d198b61ebfb4c9b13e50dccbd904a62ae593c.tar.gz linux-670d198b61ebfb4c9b13e50dccbd904a62ae593c.tar.bz2 linux-670d198b61ebfb4c9b13e50dccbd904a62ae593c.zip |
Merge tag 'fsi-updates-2018-07-24' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/linux-fsi into char-misc-testing
Ben writes:
This adds support for offloading the FSI low level bitbanging to the
ColdFire coprocessor of the Aspeed SoCs. All the pre-requisites have
already been merged, this is the final piece in the puzzle.
This branch also pull gpio/ib-aspeed which is a topic branch already
in gpio/for-next (and thus in next) whic contains pre-requisites.
Finally, there's also a bug fix to the sbefifo driver for some
inconsistent use of a mutex in the error handling code.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/devres.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/devres.c b/lib/devres.c index 5bec1120b392..faccf1a037d0 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -4,6 +4,7 @@ #include <linux/io.h> #include <linux/gfp.h> #include <linux/export.h> +#include <linux/of_address.h> enum devm_ioremap_type { DEVM_IOREMAP = 0, @@ -162,6 +163,41 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res) } EXPORT_SYMBOL(devm_ioremap_resource); +/* + * devm_of_iomap - Requests a resource and maps the memory mapped IO + * for a given device_node managed by a given device + * + * Checks that a resource is a valid memory region, requests the memory + * region and ioremaps it. All operations are managed and will be undone + * on driver detach of the device. + * + * This is to be used when a device requests/maps resources described + * by other device tree nodes (children or otherwise). + * + * @dev: The device "managing" the resource + * @node: The device-tree node where the resource resides + * @index: index of the MMIO range in the "reg" property + * @size: Returns the size of the resource (pass NULL if not needed) + * Returns a pointer to the requested and mapped memory or an ERR_PTR() encoded + * error code on failure. Usage example: + * + * base = devm_of_iomap(&pdev->dev, node, 0, NULL); + * if (IS_ERR(base)) + * return PTR_ERR(base); + */ +void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index, + resource_size_t *size) +{ + struct resource res; + + if (of_address_to_resource(node, index, &res)) + return IOMEM_ERR_PTR(-EINVAL); + if (size) + *size = resource_size(&res); + return devm_ioremap_resource(dev, &res); +} +EXPORT_SYMBOL(devm_of_iomap); + #ifdef CONFIG_HAS_IOPORT_MAP /* * Generic iomap devres |