__shost_for_each_device(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __shost_for_each_device (9) β€” Kernel API Manual, bestie edition πŸŽ€

okay so like. welcome to the kernel API manual, specifically the page for __shost_for_each_device β€” and yes the double underscore is part of the name, it's giving "i'm the internal one, don't @ me" energy πŸ’€

✨ NAME ✨

__shost_for_each_device β€” iterate over all devices of a host (UNLOCKED) πŸ”“πŸ‘‘

✨ SYNOPSIS ✨

__shost_for_each_device (sdev , shost );

🫢 ARGUMENTS 🫢

  • sdev β€” the struct scsi_device you're using as a cursor, like your little finger on the page tracking where you are πŸ“–
  • shost β€” the struct scsi_host you're iterating over, the main character of this whole thing πŸ‘‘

🌸 DESCRIPTION 🌸

So this is an iterator that hands you every device attached to shost, one at a time. Cute, right? But β€” and this is the important part, bestie β€” it does _not_ take a reference on the scsi_device. not even a little one. so the whole loop has to be protected by shost->host_lock. like, the entire thing. no cap. πŸ™ˆ

⚠️ NOTE ⚠️

The only reason to use this one is because you need to access the device list in interrupt context. that's it. that's the whole vibe. otherwise you really want to use shost_for_each_device instead β€” it's right there, it does the reference stuff for you, it's the iconic choice πŸ’…βœ¨

fr fr: if you're not in interrupt context, you're just making extra work for yourself for no reason 😭

πŸ¦‹ SEE ALSO πŸ¦‹

go read those next, iykyk πŸ’œ


mwah πŸ’‹ this page lives in ./include/scsi, going out in October 2026 β€” that's the date and the source, bestie, and yes i remembered them both, you're welcome 🫢✨🌈

πŸ“¦ where this page comes from