drivers/scsi/snic/snic_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/scsi/snic/snic_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/snic/snic_debugfs.c- Extension
.c- Size
- 12764 bytes
- Lines
- 441
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/errno.hlinux/debugfs.hsnic.h
Detected Declarations
function snic_debugfs_initfunction snic_debugfs_termfunction snic_reset_stats_openfunction snic_reset_stats_readfunction snic_reset_stats_writefunction snic_reset_stats_releasefunction snic_stats_showfunction snic_stats_debugfs_initfunction snic_stats_debugfs_removefunction snic_trc_seq_startfunction snic_trc_seq_nextfunction snic_trc_seq_stopfunction snic_trc_debugfs_initfunction snic_trc_debugfs_term
Annotated Snippet
static const struct file_operations snic_reset_stats_fops = {
.owner = THIS_MODULE,
.open = snic_reset_stats_open,
.read = snic_reset_stats_read,
.write = snic_reset_stats_write,
.release = snic_reset_stats_release,
};
/*
* snic_stats_init - Initialize stats struct and create stats file
* per snic
*
* Description:
* When debugfs is cofigured this routine sets up the stats file per snic
* It will create file stats and reset_stats under statistics/host# directory
* to log per snic stats
*/
void snic_stats_debugfs_init(struct snic *snic)
{
char name[16];
snprintf(name, sizeof(name), "host%d", snic->shost->host_no);
snic->stats_host = debugfs_create_dir(name, snic_glob->stats_root);
snic->stats_file = debugfs_create_file("stats", S_IFREG|S_IRUGO,
snic->stats_host, snic,
&snic_stats_fops);
snic->reset_stats_file = debugfs_create_file("reset_stats",
S_IFREG|S_IRUGO|S_IWUSR,
snic->stats_host, snic,
&snic_reset_stats_fops);
}
/*
* snic_stats_debugfs_remove - Tear down debugfs infrastructure of stats
*
* Description:
* When Debufs is configured this routine removes debugfs file system
* elements that are specific to to snic stats
*/
void
snic_stats_debugfs_remove(struct snic *snic)
{
debugfs_remove(snic->stats_file);
snic->stats_file = NULL;
debugfs_remove(snic->reset_stats_file);
snic->reset_stats_file = NULL;
debugfs_remove(snic->stats_host);
snic->stats_host = NULL;
}
/* Trace Facility related API */
static void *
snic_trc_seq_start(struct seq_file *sfp, loff_t *pos)
{
return &snic_glob->trc;
}
static void *
snic_trc_seq_next(struct seq_file *sfp, void *data, loff_t *pos)
{
return NULL;
}
static void
snic_trc_seq_stop(struct seq_file *sfp, void *data)
{
}
#define SNIC_TRC_PBLEN 256
static int
snic_trc_seq_show(struct seq_file *sfp, void *data)
{
char buf[SNIC_TRC_PBLEN];
if (snic_get_trc_data(buf, SNIC_TRC_PBLEN) > 0)
seq_printf(sfp, "%s\n", buf);
return 0;
}
static const struct seq_operations snic_trc_sops = {
.start = snic_trc_seq_start,
.next = snic_trc_seq_next,
.stop = snic_trc_seq_stop,
.show = snic_trc_seq_show,
Annotation
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/debugfs.h`, `snic.h`.
- Detected declarations: `function snic_debugfs_init`, `function snic_debugfs_term`, `function snic_reset_stats_open`, `function snic_reset_stats_read`, `function snic_reset_stats_write`, `function snic_reset_stats_release`, `function snic_stats_show`, `function snic_stats_debugfs_init`, `function snic_stats_debugfs_remove`, `function snic_trc_seq_start`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.