BUS_ADJUST_RESOURCE(9)

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

πŸ’… BUS_ADJUST_RESOURCE β€” the Debian bus manpage, bestie edition πŸŽ€

okay so picture this: you're a driver, you've already gotten a resource from your parent bus, and now you need to tweak the range of it. that's literally what this page is about. it's bus_adjust_resource from the Debian Kernel Developer's Manual, and we're gonna get into it πŸ’–


✨ NAME ✨

bus_adjust_resource β€” adjust a resource that you allocated from a parent bus πŸ› οΈ

🌸 SYNOPSIS 🌸

ok so first you gotta pull in all the headers, no skipping, they're all right here:

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

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

int
bus_adjust_resource(device_t dev, struct resource *r, rman_res_t start,
    rman_res_t end);

that's the whole signature, character for character, don't come for me 🫢

πŸ’œ DESCRIPTION πŸ’œ

so this function is how you ask the parent bus to adjust the resource range that's assigned to an already-allocated resource. lowkey iconic of it.

the resource r should have been allocated by a previous call to bus_alloc_resource(9) β€” like, it has to already exist, you can't just conjure it. and the new resource range must overlap the existing range of r. that's not optional, that's the whole vibe check.

⚠️ okay important: bus_adjust_resource() does not check any of the constraints from the original allocation request β€” not alignment, not boundary restrictions, none of it. nope. ngl that's on you. it is the caller's responsibility to enforce any such requirements, so don't be out here blaming the function when it doesn't babysit your alignment πŸ’€

πŸ”₯ RETURN VALUES πŸ”₯

bus_adjust_resource() returns zero on success, or an error code on failure. simple as that, periodt ✨

πŸ¦‹ EXAMPLES πŸ¦‹

here's the moment you've been waiting for β€” growing an existing memory resource by 4096 bytes πŸ’…

struct resource *res;
int error;

error = bus_adjust_resource(dev, res, rman_get_start(res),
    rman_get_end(res) + 0x1000);

look at that. 0x1000. that's 4096. we love a hex moment πŸ“

😭 ERRORS 😭

bus_adjust_resource() will fail (like, it will simply not slay) if:

  • [EINVAL] β€” the dev device does not have a parent device. no parent, no adjustment, sorry bestie πŸ™ˆ
  • [EINVAL] β€” the r resource is a shared resource. shared resources don't get this treatment, nope 🚫
  • [EINVAL] β€” the new address range does not overlap with the existing address range of r. remember, overlap is mandatory, i said what i said πŸ’…
  • [EBUSY] β€” the new address range conflicts with another allocated resource. someone else's got that spot, back off 😀

🌈 SEE ALSO 🌈

go read these too, iykyk, they're all part of the same friend group 🫢✨


and that's the page!! source/version is Debian, dated March 13, 2024, and the manual name is BUS_ADJUST_RESOURCE(9) β€” mwah, 10/10, no notes, go adjust some resources responsibly bestie πŸ’–πŸŽ€πŸ‘‘

πŸ“¦ where this page comes from