diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2020-06-09 13:46:42 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-10 15:15:55 +0300 |
commit | 7ae731a8441d70e5fb6144422a675bf1b2d6ace9 (patch) | |
tree | e6ab0a16c839a4caa2a3387ee469e4704b66a333 /lib/devres.c | |
parent | 35bd8c07db2ce8fd2834ef866240613a4ef982e7 (diff) | |
download | linux-7ae731a8441d70e5fb6144422a675bf1b2d6ace9.tar.xz |
lib: devres: add a comment about the devm_of_iomap() function
We recently introduced a bug when we tried to convert of_iomap() to
devm_of_iomap(). The problem was that there were two drivers mapping
the same io region. The first driver was using of_iomap() and the
second driver was using devm_of_iomap() and the kernel booted fine.
When we converted the first drive to use devm_of_iomap() then the second
driver failed with -EBUSY and the kernel couldn't boot.
Let's add a comment to prevent this sort of mistake in the future.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200609104642.GA43074@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/devres.c')
-rw-r--r-- | lib/devres.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/devres.c b/lib/devres.c index ca0d28727cce..ebb1573d9ae3 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -213,6 +213,12 @@ void __iomem *devm_ioremap_resource_wc(struct device *dev, * base = devm_of_iomap(&pdev->dev, node, 0, NULL); * if (IS_ERR(base)) * return PTR_ERR(base); + * + * Please Note: This is not a one-to-one replacement for of_iomap() because the + * of_iomap() function does not track whether the region is already mapped. If + * two drivers try to map the same memory, the of_iomap() function will succeed + * but the the devm_of_iomap() function will return -EBUSY. + * */ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index, resource_size_t *size) |