Skip to content

Commit 7ae731a

Browse files
Dan Carpentergregkh
authored andcommitted
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 <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/20200609104642.GA43074@mwanda Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 35bd8c0 commit 7ae731a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/devres.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ void __iomem *devm_ioremap_resource_wc(struct device *dev,
213213
* base = devm_of_iomap(&pdev->dev, node, 0, NULL);
214214
* if (IS_ERR(base))
215215
* return PTR_ERR(base);
216+
*
217+
* Please Note: This is not a one-to-one replacement for of_iomap() because the
218+
* of_iomap() function does not track whether the region is already mapped. If
219+
* two drivers try to map the same memory, the of_iomap() function will succeed
220+
* but the the devm_of_iomap() function will return -EBUSY.
221+
*
216222
*/
217223
void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index,
218224
resource_size_t *size)

0 commit comments

Comments
 (0)