drivers/scsi/mpt3sas/mpt3sas_debugfs.c

Source file repositories/reference/linux-study-clean/drivers/scsi/mpt3sas/mpt3sas_debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/mpt3sas/mpt3sas_debugfs.c
Extension
.c
Size
3731 bytes
Lines
158
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 mpt3sas_debugfs_iocdump_fops = {
	.owner		= THIS_MODULE,
	.open           = _debugfs_iocdump_open,
	.read           = _debugfs_iocdump_read,
	.release        = _debugfs_iocdump_release,
};

/*
 * mpt3sas_init_debugfs :	Create debugfs root for mpt3sas driver
 */
void mpt3sas_init_debugfs(void)
{
	mpt3sas_debugfs_root = debugfs_create_dir("mpt3sas", NULL);
	if (!mpt3sas_debugfs_root)
		pr_info("mpt3sas: Cannot create debugfs root\n");
}

/*
 * mpt3sas_exit_debugfs :	Remove debugfs root for mpt3sas driver
 */
void mpt3sas_exit_debugfs(void)
{
	debugfs_remove_recursive(mpt3sas_debugfs_root);
}

/*
 * mpt3sas_setup_debugfs :	Setup debugfs per HBA adapter
 * ioc:				MPT3SAS_ADAPTER object
 */
void
mpt3sas_setup_debugfs(struct MPT3SAS_ADAPTER *ioc)
{
	char name[64];

	snprintf(name, sizeof(name), "scsi_host%d", ioc->shost->host_no);
	if (!ioc->debugfs_root) {
		ioc->debugfs_root =
		    debugfs_create_dir(name, mpt3sas_debugfs_root);
		if (!ioc->debugfs_root) {
			dev_err(&ioc->pdev->dev,
			    "Cannot create per adapter debugfs directory\n");
			return;
		}
	}

	snprintf(name, sizeof(name), "ioc_dump");
	ioc->ioc_dump =	debugfs_create_file(name, 0444,
	    ioc->debugfs_root, ioc, &mpt3sas_debugfs_iocdump_fops);
	if (!ioc->ioc_dump) {
		dev_err(&ioc->pdev->dev,
		    "Cannot create ioc_dump debugfs file\n");
		debugfs_remove(ioc->debugfs_root);
		return;
	}

	snprintf(name, sizeof(name), "host_recovery");
	debugfs_create_u8(name, 0444, ioc->debugfs_root, &ioc->shost_recovery);

}

/*
 * mpt3sas_destroy_debugfs :	Destroy debugfs per HBA adapter
 * @ioc:	MPT3SAS_ADAPTER object
 */
void mpt3sas_destroy_debugfs(struct MPT3SAS_ADAPTER *ioc)
{
	debugfs_remove_recursive(ioc->debugfs_root);
}

Annotation

Implementation Notes