starget_for_each_device(9)
π 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:
scsi_finish_command(9)scsi_change_queue_depth(9)scsi_track_queue_full(9)scsi_vpd_inquiry(9)scsi_get_vpd_page(9)scsi_get_vpd_buf(9)scsi_attach_vpd(9)scsi_report_opcode(9)scsi_cdl_check(9)scsi_cdl_enable(9)scsi_device_get(9)scsi_device_put(9)__starget_for_each_device(9)__scsi_device_lookup_by_target(9)scsi_device_lookup_by_target(9)__scsi_device_lookup(9)scsi_device_lookup(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms