linear_range...ector_within(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… linear_range_get_selector_within β€” the manual, but make it make sense

okay bestie, this one's a Kernel API Manual page and it's lowkey tiny but it's important, so let's get into it 🫢


✨ NAME ✨

linear_range_get_selector_within β€” literally returns the linear range selector for a value. that's the whole job. icon behaviour fr πŸ’…


🌸 SYNOPSIS 🌸

void linear_range_get_selector_within (const struct linear_range *r ,
                                       unsigned int val ,
                                       unsigned int *selector );

no cap, that's the exact signature β€” copy it character for character or it's not gonna compile, and we don't do that here πŸ™ˆ


πŸŽ€ ARGUMENTS πŸŽ€

  • r β€” pointer to the linear range where the selector is being looked up from. it's giving "the map, not the destination" πŸ—ΊοΈ
  • val β€” the value we're hunting a selector for. the main character of this whole operation ngl ✨
  • selector β€” the address where the found selector value gets updated. yes, it writes through a pointer. yes, that's the vibe πŸ”₯

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's what's happening 🧚

This one returns the selector whose range value is the closest match for the input value you handed it. A value counts as matching if it is equal to or lower than the given value β€” like the closest thing that doesn't overshoot 🎯

But β€” and this is the plot twist β€” if the given value is higher than the maximum value, it returns the maximum selector instead. highkey important, don't forget it πŸ’€

selector is an out-param, bestie. it's the address where the found selector value gets updated, so make sure it points somewhere real before you call this 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./lib/linear_ranges.c, plus the whole friend group:

all of them, together, slaying in ./lib 🌈


and that's the page, bestie πŸ’– it lives in ./lib, it's dated October 2026, and it's filed under the Kernel API Manual β€” periodt, go read the source, iykyk πŸŽ€β­

πŸ“¦ where this page comes from