[PATCH v2] scsi: mpt3sas: Simplify debugfs setup
From: Lei Chen
Date: Wed Oct 07 2026 - 22:34:58 EST
The debugfs creation helpers return error pointers on failure, so the
existing NULL checks do not handle creation failures. There is no need
to add error handling here: debugfs accepts error pointers as parents
and debugfs_remove_recursive() safely handles error pointers and NULL.
Remove the ineffective checks, error messages and file-creation rollback.
Allow host_recovery creation to proceed independently of ioc_dump, and
leave any successfully created entries for the existing teardown path
to remove.
The setup function is called only once per adapter from probe, so create
the per-adapter directory without checking whether it already exists.
Signed-off-by: Lei Chen <lei.chen@xxxxxxxxxx>
---
Changes in v2:
- Remove debugfs error checks and logging instead of adding
IS_ERR_OR_NULL() checks.
- Leave debugfs cleanup to the existing teardown path.
- Allow host_recovery creation to proceed independently of ioc_dump.
- Remove the redundant directory existence check, since setup is called
only once per adapter from probe.
- Reframe the patch as a cleanup and drop the Fixes tag.
Link to v1:
https://lore.kernel.org/all/20261007141951.417155-1-lei.chen@xxxxxxxxxx/
drivers/scsi/mpt3sas/mpt3sas_debugfs.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_debugfs.c b/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
index 183391f6b8d1..0e37473abbf6 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
@@ -99,8 +99,6 @@ static const struct file_operations mpt3sas_debugfs_iocdump_fops = {
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");
}
/*
@@ -121,25 +119,12 @@ 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;
- }
- }
+ ioc->debugfs_root =
+ debugfs_create_dir(name, mpt3sas_debugfs_root);
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);
--
2.43.0