__sg_next(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ __sg_next β€” the kernel API manual, bestie edition ✨

okay so this page is from the Kernel API Manual, section 9 (kernel internals, iykyk). it's called __sg_next and honestly? she's a tiny little function with main character energy. let's get into it πŸ’…


🌸 NAME 🌸

__sg_next β€” return the next scatterlist entry in a list

like, literally what it says on the tin. you give her one scatterlist entry, she hands you the next one. no cap. πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

struct scatterlist * __sg_next (struct scatterlist *sg );

that's the whole signature, bestie β€” one arg in, one pointer out, and it returns a struct scatterlist *. periodt.


πŸ’– ARGUMENTS πŸ’–

  • sg β€” the current sg entry. like, the one you're standing on right now. she needs to know where you are before she can tell you where you're going 🫢

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the whole vibe check, and it's genuinely so simple:

  • if the entry you passed in is the last one, she returns NULL. that's it. no next entry, no drama, just NULL 😭
  • otherwise, she steps to the next element in the array β€” that's sg+1, literally just the next one, the way that pointer arithmetic ate πŸ’€
  • then: if that next thing is a chain pointer, she follows it. (chains are how sg lists get longer than the array, iykyk πŸ”—)
  • otherwise (no chain pointer, just a regular entry), she just returns the pointer to the current element.

so to recap the flow: last? β†’ NULL. chain pointer? β†’ follow it πŸ‘‘. anything else? β†’ hand back the pointer and keep it moving ✨


⭐ SEE ALSO ⭐

the kernel file that lives here is:

./drivers/gpu/drm/i915/i915_scatterlist.h

and the whole friend group she runs with:

go say hi to them too, they're all in the same friend group πŸ§šπŸ’œ


and that's the page!! little sign-off moment 🌈 β€” this one's from ./drivers/gpu/drm/i915, dated October 2026, and it's the __sg_next(9) page. mwah πŸ’‹ go read a scatterlist or something, ily πŸ“

πŸ“¦ where this page comes from