From: Rosen Penev <rosenp@gmail.com>
To: linux-stm32@st-md-mailman.stormreply.com
Cc: Thomas Gleixner <tglx@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
linux-kernel@vger.kernel.org (open list:IRQCHIP DRIVERS),
linux-arm-kernel@lists.infradead.org (moderated list:ARM/STM32
ARCHITECTURE)
Subject: [PATCH] irqchip/stm32-exti: Use kzalloc_flex
Date: Thu, 19 Mar 2026 21:04:43 -0700 [thread overview]
Message-ID: <20260320040443.46038-1-rosenp@gmail.com> (raw)
Simplifies allocations by using a flexible array member in these structs.
No need for a second kfree.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/irqchip/irq-stm32-exti.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
index 5fdf335acb46..144120cadfa0 100644
--- a/drivers/irqchip/irq-stm32-exti.c
+++ b/drivers/irqchip/irq-stm32-exti.c
@@ -45,8 +45,8 @@ struct stm32_exti_chip_data {
struct stm32_exti_host_data {
void __iomem *base;
struct device *dev;
- struct stm32_exti_chip_data *chips_data;
const struct stm32_exti_drv_data *drv_data;
+ struct stm32_exti_chip_data chips_data[];
};
static const struct stm32_exti_bank stm32f4xx_exti_b1 = {
@@ -269,26 +269,20 @@ stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd,
{
struct stm32_exti_host_data *host_data;
- host_data = kzalloc_obj(*host_data);
+ host_data = kzalloc_flex(*host_data, chips_data, dd->bank_nr);
if (!host_data)
return NULL;
host_data->drv_data = dd;
- host_data->chips_data = kzalloc_objs(struct stm32_exti_chip_data,
- dd->bank_nr);
- if (!host_data->chips_data)
- goto free_host_data;
host_data->base = of_iomap(node, 0);
if (!host_data->base) {
pr_err("%pOF: Unable to map registers\n", node);
- goto free_chips_data;
+ goto free_host_data;
}
return host_data;
-free_chips_data:
- kfree(host_data->chips_data);
free_host_data:
kfree(host_data);
@@ -389,7 +383,6 @@ static int __init stm32_exti_init(const struct stm32_exti_drv_data *drv_data,
irq_domain_remove(domain);
out_unmap:
iounmap(host_data->base);
- kfree(host_data->chips_data);
kfree(host_data);
return ret;
}
--
2.53.0
next reply other threads:[~2026-03-20 4:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 4:04 Rosen Penev [this message]
2026-03-20 9:04 ` [PATCH] irqchip/stm32-exti: Use kzalloc_flex Thomas Gleixner
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=20260320040443.46038-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=tglx@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.