device_for_e...reverse_from(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… device_for_e...reverse_from(9)

okay so this is a page from the Kernel API Manual and we're about to get into device_for_each_child_reverse_from β€” yes the name is a whole mouthful, yes it's iconic, let's go πŸŽ€


✨ NAME ✨

device_for_each_child_reverse_from β€” the device child iterator, but make it reversed πŸ’« (it walks the child list backwards, bestie).


🌸 SYNOPSIS 🌸

int device_for_each_child_reverse_from (struct device *parent , struct
device *from , void *data , device_iter_t fn );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • parent β€” the parent struct device. like, the mom friend of the group chat πŸ‘‘
  • from β€” optional starting point in the child list. optional!! so you can just pass NULL and vibe ✨
  • data β€” data for the callback. it gets handed straight to fn, no questions asked 🫢
  • fn β€” the function to be called for each device. your little callback bestie πŸ’–

πŸ’œ DESCRIPTION πŸ’œ

So what this does: it iterates over parent's child devices, starting at from, and calls fn for each one, passing it data. lowkey simple, highkey useful 😌

Heads up! This helper is identical to device_for_each_child_reverse when from is NULL. no cap, literally the same behaviour in that case.

fn is checked each iteration. If it returns anything other than 0, the iteration stops and that value gets returned to the caller of device_for_each_child_reverse_from β€” so your callback's return value is the escape hatch, fr fr πŸ’€ (also yes, the original sentence stops there mid-thought, we do not fix the kernel docs, we respect them πŸ™ˆ).


🌈 SEE ALSO 🌈

Kernel file ./drivers/base/core.c, plus honestly a whole friend group of functions:


okay that's the whole thing, go iterate backwards and slay πŸ’…βœ¨

source ./drivers/base πŸŽ€ dated October 2026 🌸 mwah, bye bestie πŸ«ΆπŸ’–

πŸ“¦ where this page comes from