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.

Dependency Surface

Detected Declarations

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

Implementation Notes