devm_pci_remap_cfg_resource(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ devm_pci_remap_cfg_resource(9) πŸŽ€

okay bestie, so this is a page from the Kernel API Manual β€” yes, that manual β€” and it's about devm_pci_remap_cfg_resource, which lowkey does a whole little glow-up routine on a PCI config-space resource. stay with me, it's actually iconic πŸ’…


✨ NAME ✨

devm_pci_remap_cfg_resource β€” check, request region and ioremap cfg resource

no cap, that's the whole vibe: check it, request it, map it. three steps, one function, main character energy πŸ”₯


🌸 SYNOPSIS 🌸

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

it gives you back a void __iomem * β€” literally a pointer into mapped memory β€” or an error code dressed up as one. we'll get to that 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dev β€” the generic device that's handling the resource for you. it's the responsible adult in this situation, fr fr.
  • res β€” the configuration space resource to be handled. this is the thing getting checked, requested, and mapped ✨

πŸ’– DESCRIPTION πŸ’–

okay so here's what happens, and it's kind of a lot (affectionate):

it checks that a resource is a valid memory region, then requests the memory region, and then ioremaps it using the pci_remap_cfgspace API β€” which is the whole point, because that API makes sure the proper PCI configuration space memory attributes are guaranteed. like, that's its entire job and it ate πŸ‘‘

and the best part? all operations are managed and will be undone on driver detach. you don't have to clean up after yourself. the devm machinery handles it. no leaks, no mess, no 3am debugging. we love a self-cleaning function 🌈

it returns a pointer to the remapped memory, or an IOMEM_ERR_PTR encoded error code on failure. so yeah β€” check it with IS_ERR(), bestie, always πŸ’€

usage example, straight from the source, keep it exact:

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

see how it grabs the resource, maps it, and then immediately vibe-checks the result with IS_ERR(base) before returning PTR_ERR(base)? that's the pattern. memorize it. iykyk πŸ’œ


⭐ SEE ALSO ⭐

like, that's the whole friend group right there 🫢 go read them too, they're all serving πŸ“


and that's the page!! mwah πŸ’‹ this lil gem lives in ./drivers/pci and it's dated October 2026 β€” so yeah, fresh off the press, and the title of the whole thing is devm_pci_remap_cfg_resource(9) in case you forgot already (no shade, it's a long name). go map some config space, bestie πŸŒΈπŸ§šβ€β™€οΈπŸ’–

πŸ“¦ where this page comes from