devm_ioremap_resource(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 devm_ioremap_resource(9) β€” Kernel API Manual 🌸

ok so bestie, let me tell you about devm_ioremap_resource(9) β€” it's in the Kernel API Manual and it's literally the "check it, claim it, map it" combo platter. πŸ’…


✨ NAME ✨

devm_ioremap_resource β€” check, request region, and ioremap resource

Like, all three things. In one function. She's efficient.


✨ SYNOPSIS ✨

void __iomem * devm_ioremap_resource (struct device *dev , const struct
       resource *res );

✨ ARGUMENTS ✨

  • dev β€” the generic device that's handling the resource for you 🫢
  • res β€” the resource being handled, the actual thing you're working with

✨ DESCRIPTION ✨

okay so here's the vibe: it checks that a resource is a valid memory region, requests the memory region, and ioremaps it. That's the whole arc. 🌈

And the iconic part? All operations are managed and will be undone on driver detach. So you don't have to clean up after yourself β€” devm's got you. Periodt.

Usage example, literally from the source:

res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(pdev->dev, res); if (IS_ERR(base)) return PTR_ERR(base);

no cap, that IS_ERR check is not optional, bestie. do not skip her. πŸ’€


✨ RETURN ✨

a pointer to the remapped memory, or an ERR_PTR encoded error code on failure. so check it with IS_ERR before you go doing main character things with it πŸ‘‘


✨ SEE ALSO ✨

Kernel file ./lib/devres.c β€” and the whole friend group:


πŸŽ€ that's the whole page, you ate that. go forth and map responsibly.

ok bye ily, this came from ./lib, October 2026 version, and yes the footer really does say devm_ioremap_resource(9) again β€” she's consistent πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from