drivers/scsi/megaraid/megaraid_sas_debugfs.c

Source file repositories/reference/linux-study-clean/drivers/scsi/megaraid/megaraid_sas_debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/megaraid/megaraid_sas_debugfs.c
Extension
.c
Size
4594 bytes
Lines
180
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 megasas_debugfs_raidmap_fops = {
	.owner		= THIS_MODULE,
	.open           = megasas_debugfs_raidmap_open,
	.read           = megasas_debugfs_read,
	.release        = megasas_debugfs_release,
};

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

/*
 * megasas_exit_debugfs :	Remove debugfs root for megaraid_sas driver
 */
void megasas_exit_debugfs(void)
{
	debugfs_remove_recursive(megasas_debugfs_root);
}

/*
 * megasas_setup_debugfs :	Setup debugfs per Fusion adapter
 * instance:				Soft instance of adapter
 */
void
megasas_setup_debugfs(struct megasas_instance *instance)
{
	char name[64];
	struct fusion_context *fusion;

	fusion = instance->ctrl_context;

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

		snprintf(name, sizeof(name), "raidmap_dump");
		instance->raidmap_dump =
			debugfs_create_file(name, S_IRUGO,
					    instance->debugfs_root, instance,
					    &megasas_debugfs_raidmap_fops);
		if (!instance->raidmap_dump) {
			dev_err(&instance->pdev->dev,
				"Cannot create raidmap debugfs file\n");
			debugfs_remove(instance->debugfs_root);
			return;
		}
	}

}

/*
 * megasas_destroy_debugfs :	Destroy debugfs per Fusion adapter
 * instance:					Soft instance of adapter
 */
void megasas_destroy_debugfs(struct megasas_instance *instance)
{
	debugfs_remove_recursive(instance->debugfs_root);
}

#else
void megasas_init_debugfs(void)
{
}
void megasas_exit_debugfs(void)
{
}
void megasas_setup_debugfs(struct megasas_instance *instance)
{
}
void megasas_destroy_debugfs(struct megasas_instance *instance)
{
}
#endif /*CONFIG_DEBUG_FS*/

Annotation

Implementation Notes