starget_for_each_device(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… starget_for_each_device β€” from the Kernel API Manual, bestie ✨

okay so picture this: you're in the Kernel API Manual, section 9, and today's main character is starget_for_each_device. say hi πŸ‘‹


🌸 NAME 🌸

starget_for_each_device β€” the little helper that walks all the devices of a target. yes, all of them. bestie behaviour fr fr 🫢


✨ SYNOPSIS ✨

void starget_for_each_device (struct scsi_target *starget , void *data ,
void (*fn)(struct scsi_device *, void *) );

πŸŽ€ ARGUMENTS πŸŽ€

  • starget β€” the target whose devices we wanna iterate over. she's the one holding the whole group chat together πŸ’…
  • data β€” opaque stuff that gets passed to every single function call. no questions asked, it's opaque, we don't look inside πŸ™ˆ
  • fn β€” the function to call on each device. she gets called once per device, one at a time, very demure ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

So this one traverses over each device of starget β€” like scrolling through the timeline, one device at a time πŸ’«

⚠️ okay this part is IMPORTANT, no cap: the devices have a reference that must be released by scsi_host_put when breaking out of the loop. if you dip out early and forget to release it, that reference is just… sitting there. not slay. 😭

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./drivers/scsi/scsi.c and honestly the whole friend group:


okay that's the whole page, you ate that πŸ“ stay hydrated, release your references, and remember: this iconic lil page lives in ./drivers/scsi, dated October 2026 β€” the future is now and she's serving kernel documentation πŸ’œβœ¨

πŸ“¦ where this page comes from