drivers/scsi/scsi_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/scsi/scsi_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/scsi_sysfs.c- Extension
.c- Size
- 45166 bytes
- Lines
- 1733
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/slab.hlinux/init.hlinux/blkdev.hlinux/device.hlinux/pm_runtime.hlinux/bsg.hscsi/scsi.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_tcq.hscsi/scsi_dh.hscsi/scsi_transport.hscsi/scsi_driver.hscsi/scsi_devinfo.hscsi_priv.hscsi_logging.hscsi_devinfo_tbl.c
Detected Declarations
function check_setfunction scsi_scanfunction store_scanfunction store_shost_statefunction show_shost_statefunction show_shost_modefunction show_shost_supported_modefunction show_shost_active_modefunction check_reset_typefunction store_host_resetfunction show_shost_eh_deadlinefunction store_shost_eh_deadlinefunction show_host_busyfunction show_use_blk_mqfunction show_nr_hw_queuesfunction scsi_device_cls_releasefunction scsi_device_dev_releasefunction list_for_each_safefunction scsi_bus_matchfunction scsi_bus_ueventfunction scsi_bus_probefunction scsi_bus_removefunction scsi_bus_shutdownfunction scsi_sysfs_registerfunction scsi_sysfs_unregisterfunction sdev_show_device_busyfunction sdev_show_device_blockedfunction sdev_show_timeoutfunction sdev_store_timeoutfunction sdev_show_eh_timeoutfunction sdev_store_eh_timeoutfunction store_rescan_fieldfunction sdev_store_deletefunction store_state_fieldfunction show_state_fieldfunction show_queue_type_fieldfunction store_queue_type_fieldfunction show_inquiryfunction show_iostat_counterbitsfunction sdev_show_modaliasfunction sdev_store_queue_depthfunction sdev_show_wwidfunction sdev_show_serialfunction sdev_show_blacklistfunction sdev_show_dh_statefunction sdev_store_dh_statefunction sdev_show_access_statefunction sdev_show_preferred_path
Annotated Snippet
static int scsi_bus_match(struct device *dev, const struct device_driver *gendrv)
{
struct scsi_device *sdp;
if (dev->type != &scsi_dev_type)
return 0;
sdp = to_scsi_device(dev);
if (sdp->no_uld_attach)
return 0;
return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
}
static int scsi_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct scsi_device *sdev;
if (dev->type != &scsi_dev_type)
return 0;
sdev = to_scsi_device(dev);
add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
return 0;
}
static int scsi_bus_probe(struct device *dev)
{
struct scsi_device *sdp = to_scsi_device(dev);
struct scsi_driver *drv = to_scsi_driver(dev->driver);
if (drv->probe)
return drv->probe(sdp);
else
return 0;
}
static void scsi_bus_remove(struct device *dev)
{
struct scsi_device *sdp = to_scsi_device(dev);
struct scsi_driver *drv = to_scsi_driver(dev->driver);
if (drv->remove)
drv->remove(sdp);
}
static void scsi_bus_shutdown(struct device *dev)
{
struct scsi_device *sdp = to_scsi_device(dev);
struct scsi_driver *drv;
if (!dev->driver)
return;
drv = to_scsi_driver(dev->driver);
if (drv->shutdown)
drv->shutdown(sdp);
}
const struct bus_type scsi_bus_type = {
.name = "scsi",
.match = scsi_bus_match,
.uevent = scsi_bus_uevent,
.probe = scsi_bus_probe,
.remove = scsi_bus_remove,
.shutdown = scsi_bus_shutdown,
#ifdef CONFIG_PM
.pm = &scsi_bus_pm_ops,
#endif
};
int scsi_sysfs_register(void)
{
int error;
error = bus_register(&scsi_bus_type);
if (!error) {
error = class_register(&sdev_class);
if (error)
bus_unregister(&scsi_bus_type);
}
return error;
}
void scsi_sysfs_unregister(void)
{
class_unregister(&sdev_class);
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/init.h`, `linux/blkdev.h`, `linux/device.h`, `linux/pm_runtime.h`, `linux/bsg.h`, `scsi/scsi.h`.
- Detected declarations: `function check_set`, `function scsi_scan`, `function store_scan`, `function store_shost_state`, `function show_shost_state`, `function show_shost_mode`, `function show_shost_supported_mode`, `function show_shost_active_mode`, `function check_reset_type`, `function store_host_reset`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.