From: Lei Chen <lei.chen@smartx.com>
To: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com,
shivasharan.srikanteshwara@broadcom.com,
chandrakanth.patil@broadcom.com
Cc: megaraidlinux.pdl@broadcom.com,
James.Bottomley@HansenPartnership.com, mkp@kernel.org,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
lei.chen@smartx.com
Subject: [PATCH v2] scsi: megaraid_sas: Simplify debugfs setup
Date: Thu, 8 Oct 2026 10:34:24 +0800 [thread overview]
Message-ID: <20261008023424.468757-1-lei.chen@smartx.com> (raw)
In-Reply-To: <20261007141753.416672-1-lei.chen@smartx.com>
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.
Leave any successfully created directory for the existing teardown path
to remove, even if creating raidmap_dump fails.
The setup function is called only once per instance from probe, so create
the per-adapter directory without checking whether it already exists.
Signed-off-by: Lei Chen <lei.chen@smartx.com>
---
Changes in v2:
- Remove debugfs error checks and logging instead of adding
IS_ERR_OR_NULL() checks, following review feedback.
- Leave directory cleanup to the existing teardown path.
- Remove the redundant directory existence check, since setup is called
only once per instance from probe.
- Reframe the patch as a cleanup and drop the Fixes tag.
Link to v1:
https://lore.kernel.org/all/20261007141753.416672-1-lei.chen@smartx.com/
drivers/scsi/megaraid/megaraid_sas_debugfs.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/megaraid/megaraid_sas_debugfs.c b/drivers/scsi/megaraid/megaraid_sas_debugfs.c
index 81698cd83f5a..2fdb4c6bd3d9 100644
--- a/drivers/scsi/megaraid/megaraid_sas_debugfs.c
+++ b/drivers/scsi/megaraid/megaraid_sas_debugfs.c
@@ -102,8 +102,6 @@ static const struct file_operations megasas_debugfs_raidmap_fops = {
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");
}
/*
@@ -129,27 +127,14 @@ megasas_setup_debugfs(struct megasas_instance *instance)
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;
- }
- }
+ instance->debugfs_root =
+ debugfs_create_dir(name, megasas_debugfs_root);
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;
- }
}
}
--
2.43.0
prev parent reply other threads:[~2026-10-08 2:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 14:17 [PATCH] scsi: megaraid_sas: Fix debugfs setup error handling Lei Chen
2026-10-08 2:34 ` Lei Chen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261008023424.468757-1-lei.chen@smartx.com \
--to=lei.chen@smartx.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=chandrakanth.patil@broadcom.com \
--cc=kashyap.desai@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=megaraidlinux.pdl@broadcom.com \
--cc=mkp@kernel.org \
--cc=shivasharan.srikanteshwara@broadcom.com \
--cc=sumit.saxena@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®