BUS_ADJUST_RESOURCE(9)
π
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]β thedevdevice does not have a parent device. no parent, no adjustment, sorry bestie π[EINVAL]β therresource 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 ofr. 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
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2011 Hudson River Trading LLC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms