From: Rosen Penev <rosenp@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Jassi Brar <jassisinghbrar@gmail.com>,
Heiko Stuebner <heiko@sntech.de>,
linux-arm-kernel@lists.infradead.org (moderated
list:ARM/Rockchip SoC support),
linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC
support)
Subject: [PATCH] mailbox: rockchip: kzalloc + kcalloc to kzalloc
Date: Tue, 10 Mar 2026 17:37:44 -0700 [thread overview]
Message-ID: <20260311003744.32099-1-rosenp@gmail.com> (raw)
Use a flexible array member to reduce allocations.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/mailbox/rockchip-mailbox.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/mailbox/rockchip-mailbox.c b/drivers/mailbox/rockchip-mailbox.c
index 4d966cb2ed03..a1a7dee64356 100644
--- a/drivers/mailbox/rockchip-mailbox.c
+++ b/drivers/mailbox/rockchip-mailbox.c
@@ -46,7 +46,7 @@ struct rockchip_mbox {
/* The maximum size of buf for each channel */
u32 buf_size;
- struct rockchip_mbox_chan *chans;
+ struct rockchip_mbox_chan chans[];
};
static int rockchip_mbox_send_data(struct mbox_chan *chan, void *data)
@@ -173,15 +173,10 @@ static int rockchip_mbox_probe(struct platform_device *pdev)
drv_data = (const struct rockchip_mbox_data *) device_get_match_data(&pdev->dev);
- mb = devm_kzalloc(&pdev->dev, sizeof(*mb), GFP_KERNEL);
+ mb = devm_kzalloc(&pdev->dev, struct_size(mb, chans, drv_data->num_chans), GFP_KERNEL);
if (!mb)
return -ENOMEM;
- mb->chans = devm_kcalloc(&pdev->dev, drv_data->num_chans,
- sizeof(*mb->chans), GFP_KERNEL);
- if (!mb->chans)
- return -ENOMEM;
-
mb->mbox.chans = devm_kcalloc(&pdev->dev, drv_data->num_chans,
sizeof(*mb->mbox.chans), GFP_KERNEL);
if (!mb->mbox.chans)
--
2.53.0
next reply other threads:[~2026-03-11 0:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 0:37 Rosen Penev [this message]
2026-03-29 16:28 ` [PATCH] mailbox: rockchip: kzalloc + kcalloc to kzalloc Jassi Brar
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=20260311003744.32099-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=heiko@sntech.de \
--cc=jassisinghbrar@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox