scsi_add_device(9)
π scsi_add_device β a Kernel API Manual moment
okay so bestie, this one's scsi_add_device(9) from the Kernel API Manual and honestly? it's giving "small function, big consequences." let's get into it π«Ά
β¨ NAME β¨
scsi_add_device β creates a new SCSI (LU) instance. that's it, that's the whole vibe. it makes a device appear β¨
πΈ SYNOPSIS πΈ
int scsi_add_device (struct Scsi_Host *host , uint channel , uint target
, u64 lun );
literally four args, no cap. hand it a host, a channel, a target and a lun and it'll go off and do its thing π«
π ARGUMENTS π
hostβ theScsi_Hostinstance where the device is located. like, where does this thing even live, that's the host πchannelβ the target channel number. and ngl, it's rarely other than0πtargetβ the target id number, iconic little identifier, we love her πlunβ the LUN of the target device. yes,u64. yes, she's big π
π¦ DESCRIPTION π¦
Probe for a specific LUN and add it if found. that's the entire job description and she ate π₯
β NOTES β
okay this part MATTERS so listen up bestie, no skimming π
This call is usually performed internally during a SCSI bus scan when an HBA is added (i.e. scsi_scan_host). so it's mostly a behind-the-scenes girly doing her work without being asked π
so it should only be called if the HBA becomes aware of a new SCSI device (LU) after scsi_scan_host has completed. like, don't jump the queue, the scan has to finish first, periodt β
and if it's successful, this call can lead to sdev_init and sdev_configure callbacks into the LLD. so your callbacks are gonna get pinged, be ready for it π
lowkey important: this is not a "call it whenever" function. timing is everything, fr fr πΈ
π RETURN π
0on success (slay π )- negative error code on failure (the π path)
π§ SEE ALSO π§
Kernel file ./drivers/scsi/scsi_scan.c is the home base for all of these besties, so go say hi:
scsi_complete_async_scans(9)scsi_unlock_floptical(9)scsi_alloc_sdev(9)scsi_target_reap_ref_release(9)scsi_alloc_target(9)scsi_target_reap(9)scsi_sanitize_inquiry_string(9)scsi_probe_lun(9)scsi_add_lun(9)scsi_inq_str(9)scsi_probe_and_add_lun(9)scsi_sequential_lun_scan(9)scsi_report_lun_scan(9)scsi_scan_target(9)scsi_prep_async_scan(9)scsi_finish_async_scan(9)scsi_scan_host(9)scsi_get_pseudo_sdev(9)
that's a whole group chat of scan-related functions and they're all linked, iykyk π«
okay that's the page π it lives over in ./drivers/scsi, dated October 2026, and it's part of the Kernel API Manual (so yes, scsi_add_device(9) is the name-and-section combo, going in the header where it belongs). mwah, go add some devices responsibly πβ¨π¦
π¦ 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