Commit 6e924822 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Greg Kroah-Hartman

lib: devres: prepare devm_ioremap_resource() for more variants

We want to add the write-combined variant of devm_ioremap_resource().
Let's first implement __devm_ioremap_resource() which takes
an additional argument type. The types are the same as for
__devm_ioremap(). The existing devm_ioremap_resource() now simply
calls __devm_ioremap_resource() with regular DEVM_IOREMAP type.
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20191022084318.22256-3-brgl@bgdev.plSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4154abca
...@@ -114,25 +114,9 @@ void devm_iounmap(struct device *dev, void __iomem *addr) ...@@ -114,25 +114,9 @@ void devm_iounmap(struct device *dev, void __iomem *addr)
} }
EXPORT_SYMBOL(devm_iounmap); EXPORT_SYMBOL(devm_iounmap);
/** static void __iomem *
* devm_ioremap_resource() - check, request region, and ioremap resource __devm_ioremap_resource(struct device *dev, const struct resource *res,
* @dev: generic device to handle the resource for enum devm_ioremap_type type)
* @res: resource to be handled
*
* 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.
*
* Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
* on failure. Usage example:
*
* res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
* base = devm_ioremap_resource(&pdev->dev, res);
* if (IS_ERR(base))
* return PTR_ERR(base);
*/
void __iomem *devm_ioremap_resource(struct device *dev,
const struct resource *res)
{ {
resource_size_t size; resource_size_t size;
void __iomem *dest_ptr; void __iomem *dest_ptr;
...@@ -151,7 +135,7 @@ void __iomem *devm_ioremap_resource(struct device *dev, ...@@ -151,7 +135,7 @@ void __iomem *devm_ioremap_resource(struct device *dev,
return IOMEM_ERR_PTR(-EBUSY); return IOMEM_ERR_PTR(-EBUSY);
} }
dest_ptr = devm_ioremap(dev, res->start, size); dest_ptr = __devm_ioremap(dev, res->start, size, type);
if (!dest_ptr) { if (!dest_ptr) {
dev_err(dev, "ioremap failed for resource %pR\n", res); dev_err(dev, "ioremap failed for resource %pR\n", res);
devm_release_mem_region(dev, res->start, size); devm_release_mem_region(dev, res->start, size);
...@@ -160,6 +144,29 @@ void __iomem *devm_ioremap_resource(struct device *dev, ...@@ -160,6 +144,29 @@ void __iomem *devm_ioremap_resource(struct device *dev,
return dest_ptr; return dest_ptr;
} }
/**
* devm_ioremap_resource() - check, request region, and ioremap resource
* @dev: generic device to handle the resource for
* @res: resource to be handled
*
* 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.
*
* Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
* on failure. Usage example:
*
* res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
* base = devm_ioremap_resource(&pdev->dev, res);
* if (IS_ERR(base))
* return PTR_ERR(base);
*/
void __iomem *devm_ioremap_resource(struct device *dev,
const struct resource *res)
{
return __devm_ioremap_resource(dev, res, DEVM_IOREMAP);
}
EXPORT_SYMBOL(devm_ioremap_resource); EXPORT_SYMBOL(devm_ioremap_resource);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment