BUS_RELEASE_RESOURCE(9)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1, nixpkgs unstable

πŸ’… BUS_RELEASE_RESOURCE(9) πŸ’…

Okay bestie, welcome to the Kernel Developer's Manual β€” this is the bus_release_resource page and honestly it's giving "cleanup era" ✨ like you allocated a thing and now you're being a responsible main character and giving it back. No cap, this one's short and sweet.


🌸 NAME 🌸

bus_release_resource β€” release resources on a bus 🫢


✨ SYNOPSIS ✨

#include <sys/param.h>
#include <sys/bus.h>

#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>

int
bus_release_resource(device_t dev, struct resource *r);

Like, include all of these, okay? All five. Not four. Not "ehh I'll skip machine/resource.h". All of them πŸ’€


πŸ¦‹ DESCRIPTION πŸ¦‹

So what this does is it frees a resource that was allocated by bus_alloc_resource(9). Basically the reverse of allocation, the un-slay, the "we're done here" πŸ’–

⚠️ Okay important, bestie: the resource must not be in use when you release it. Like, call an appropriate function first before you do this β€” for example bus_teardown_intr(9) for IRQs. Do not skip this step, I'm literally begging πŸ™ˆ
  • dev β€” the device that owns the resource πŸ‘‘
  • r β€” the pointer to struct resource, like, the resource itself, returned by bus_alloc_resource(9) 🌟

πŸ”₯ RETURN VALUES πŸ”₯

  • EINVAL gets returned if the device dev has no parent 😭
  • 0 otherwise, we love a success story πŸ’š
πŸ’€ And heads up: the kernel will panic if it cannot release the resource. So yeah. Not a drill. Fr fr.

πŸŽ€ EXAMPLES πŸŽ€

        /* deactivate IRQ */
        bus_teardown_intr(dev, foosoftc->irqres, foosoftc->irqid);

        /* release IRQ resource */
        bus_release_resource(dev, foosoftc->irqres);

        /* release I/O port resource */
        bus_release_resource(dev, foosoftc->portres);

See how the teardown comes before the release? That's the whole vibe check right there ✨ teardown first, then release, every single time πŸ‘


🌈 SEE ALSO 🌈

Go read those too, they're the supporting cast and they ate πŸ’…


πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Alexander Langer <alex@big.endian.de>. Iconic of him, honestly 🫢


And that's the page, bestie!! This dropped as part of Debian, dated March 13, 2024 β€” and the header up top and that footer down here both say BUS_RELEASE_RESOURCE(9) so you always know where you are πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from