BUS_RELEASE_RESOURCE(9)
π BUS_RELEASE_RESOURCE(9) π
okay so bestie, welcome to the Kernel Developer's Manual entry for bus_release_resource β yes it's a real manpage, yes it's giving β¨responsible cleanup eraβ¨, and yes you're gonna slay it.
πΈ 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, int type, int rid,
struct resource *r);
like. look at that signature. gorgeous. no notes. π«Ά
π DESCRIPTION π
So what this bad boy does is free a resource that was allocated by bus_alloc_resource(9). that's literally it. that's the whole vibe. it's the goodbye text after the situationship.
β οΈ BUT β and this is the important part, no cap β the resource must not be in use on release. like, call the appropriate function before you let it go (for example, bus_teardown_intr(9) if it's an IRQ). don't be out here releasing stuff mid-use, it's not the move, it's giving chaos. π
Now let's break down the args, bestie:
devβ the device that owns the resource. it's their resource. their name is on it. πtypeβ the type of resource you're releasing. it must be the same type you allocated it as before, don't switch up on it. checkbus_alloc_resource(9)for the valid types if you need a refresher. πridβ the resource ID of the resource. and listen, theridvalue must be the exact same one thatbus_alloc_resource(9)handed you back. same. one. no substitutions. π«rβ the pointer tostruct resource, aka the resource itself, the one and only, returned bybus_alloc_resource(9). hold onto it and give it back exactly as received. π
π RETURN VALUES π
EINVALgets returned if the devicedevhas no parent. yep. no parent, no dice.0otherwise. clean. iconic. a little win. β¨
π¨ and heads up: the kernel will PANIC if it cannot release the resource. not a vibe check you want to fail. panic = bad. be careful. ππ
π EXAMPLES π
here's the whole little routine, verbatim, because we do not gatekeep:
/* deactivate IRQ */
bus_teardown_intr(dev, foosoftc->irqres, foosoftc->irqid);
/* release IRQ resource */
bus_release_resource(dev, SYS_RES_IRQ, foosoftc->irqid,
foosoftc->irqres);
/* release I/O port resource */
bus_release_resource(dev, SYS_RES_IOPORT, foosoftc->portid,
foosoftc->portres);
see how it tears down the intr first? that's the whole point bestie. deactivate, then release. order matters. periodt. π
π SEE ALSO π
(the group chat, basically. read the whole thread. iykyk. π¦)
π«Ά AUTHORS π«Ά
This manual page was written by Alexander Langer <alex@big.endian.de>. absolute legend behavior. we thank them. πΈ
and that's the page, bestie β go release your resources responsibly, keep your rids matching, and never panic the kernel πβ¨ππ¦
Debian Β· May 18, 2000 Β· BUS_RELEASE_RESOURCE(9) β mwah, signing off π
β
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2000 Alexander Langer
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms