From: Rosen Penev <rosenp@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: Don Brace <don.brace@microchip.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
storagedev@microchip.com (open list:HEWLETT-PACKARD SMART ARRAY
RAID DRIVER (hpsa)), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] scsi: hpsa: kzalloc + kcalloc to kzalloc_flex
Date: Thu, 19 Mar 2026 21:18:02 -0700 [thread overview]
Message-ID: <20260320041802.47611-1-rosenp@gmail.com> (raw)
Simplifies allocation and freeing the struct.
Removed hpda_free_ctlr_info as it's now just a single kfree.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/scsi/hpsa.c | 17 +++--------------
drivers/scsi/hpsa.h | 2 +-
2 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a1b116cd4723..608c45f4f749 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -8621,25 +8621,14 @@ static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h,
return wq;
}
-static void hpda_free_ctlr_info(struct ctlr_info *h)
-{
- kfree(h->reply_map);
- kfree(h);
-}
-
static struct ctlr_info *hpda_alloc_ctlr_info(void)
{
struct ctlr_info *h;
- h = kzalloc_obj(*h);
+ h = kzalloc_flex(*h, reply_map, nr_cpu_ids, GFP_KERNEL);
if (!h)
return NULL;
- h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL);
- if (!h->reply_map) {
- kfree(h);
- return NULL;
- }
return h;
}
@@ -8909,7 +8898,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
destroy_workqueue(h->monitor_ctlr_wq);
h->monitor_ctlr_wq = NULL;
}
- hpda_free_ctlr_info(h);
+ kfree(h);
return rc;
}
@@ -9093,7 +9082,7 @@ static void hpsa_remove_one(struct pci_dev *pdev)
free_percpu(h->lockup_detected); /* init_one 2 */
h->lockup_detected = NULL; /* init_one 2 */
- hpda_free_ctlr_info(h); /* init_one 1 */
+ kfree(h); /* init_one 1 */
}
static int __maybe_unused hpsa_suspend(
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 99b0750850b2..935c2e1a840d 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -162,7 +162,6 @@ struct bmic_controller_parameters {
#pragma pack()
struct ctlr_info {
- unsigned int *reply_map;
int ctlr;
char devname[8];
char *product_name;
@@ -311,6 +310,7 @@ struct ctlr_info {
u8 reset_in_progress;
struct hpsa_sas_node *sas_host;
spinlock_t reset_lock;
+ unsigned int reply_map[];
};
struct offline_device_entry {
--
2.53.0
reply other threads:[~2026-03-20 4:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260320041802.47611-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=don.brace@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=storagedev@microchip.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