* [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size
@ 2026-06-08 4:56 Rosen Penev
2026-06-09 8:04 ` Kurt Kanzenbach
2026-06-15 19:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Rosen Penev @ 2026-06-08 4:56 UTC (permalink / raw)
To: netdev
Cc: Kurt Kanzenbach, Andrew Lunn, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, open list
One fewer allocation for the priv struct.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/dsa/hirschmann/hellcreek.c | 14 +++++---------
drivers/net/dsa/hirschmann/hellcreek.h | 2 +-
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c
index b369c1cc89e8..2c6cabf61143 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.c
+++ b/drivers/net/dsa/hirschmann/hellcreek.c
@@ -1932,29 +1932,25 @@ static const struct dsa_switch_ops hellcreek_ds_ops = {
static int hellcreek_probe(struct platform_device *pdev)
{
+ const struct hellcreek_platform_data *data;
struct device *dev = &pdev->dev;
struct hellcreek *hellcreek;
struct resource *res;
int ret, i;
- hellcreek = devm_kzalloc(dev, sizeof(*hellcreek), GFP_KERNEL);
+ data = of_device_get_match_data(dev);
+ hellcreek = devm_kzalloc(dev, struct_size(hellcreek, ports, data->num_ports), GFP_KERNEL);
if (!hellcreek)
return -ENOMEM;
+ hellcreek->pdata = data;
+
hellcreek->vidmbrcfg = devm_kcalloc(dev, VLAN_N_VID,
sizeof(*hellcreek->vidmbrcfg),
GFP_KERNEL);
if (!hellcreek->vidmbrcfg)
return -ENOMEM;
- hellcreek->pdata = of_device_get_match_data(dev);
-
- hellcreek->ports = devm_kcalloc(dev, hellcreek->pdata->num_ports,
- sizeof(*hellcreek->ports),
- GFP_KERNEL);
- if (!hellcreek->ports)
- return -ENOMEM;
-
for (i = 0; i < hellcreek->pdata->num_ports; ++i) {
struct hellcreek_port *port = &hellcreek->ports[i];
diff --git a/drivers/net/dsa/hirschmann/hellcreek.h b/drivers/net/dsa/hirschmann/hellcreek.h
index bebf0d3ff330..851822adb09e 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.h
+++ b/drivers/net/dsa/hirschmann/hellcreek.h
@@ -280,7 +280,6 @@ struct hellcreek {
struct dsa_switch *ds;
struct ptp_clock *ptp_clock;
struct ptp_clock_info ptp_clock_info;
- struct hellcreek_port *ports;
struct delayed_work overflow_work;
struct led_classdev led_is_gm;
struct led_classdev led_sync_good;
@@ -297,6 +296,7 @@ struct hellcreek {
u64 last_ts; /* Used for overflow detection */
u16 status_out; /* ptp.status_out shadow */
size_t fdb_entries;
+ struct hellcreek_port ports[];
};
/* A Qbv schedule can only started up to 8 seconds in the future. If the delta
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size
2026-06-08 4:56 [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size Rosen Penev
@ 2026-06-09 8:04 ` Kurt Kanzenbach
2026-06-15 8:40 ` Kurt Kanzenbach
2026-06-15 19:50 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Kurt Kanzenbach @ 2026-06-09 8:04 UTC (permalink / raw)
To: Rosen Penev, netdev
Cc: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
[-- Attachment #1: Type: text/plain, Size: 283 bytes --]
On Sun Jun 07 2026, Rosen Penev wrote:
> One fewer allocation for the priv struct.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
It looks correct, but i'm currently out of office. I'll test it next
week on hardware.
Thanks,
Kurt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size
2026-06-09 8:04 ` Kurt Kanzenbach
@ 2026-06-15 8:40 ` Kurt Kanzenbach
0 siblings, 0 replies; 4+ messages in thread
From: Kurt Kanzenbach @ 2026-06-15 8:40 UTC (permalink / raw)
To: Rosen Penev, netdev
Cc: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
[-- Attachment #1: Type: text/plain, Size: 371 bytes --]
On Tue Jun 09 2026, Kurt Kanzenbach wrote:
> On Sun Jun 07 2026, Rosen Penev wrote:
>> One fewer allocation for the priv struct.
>>
>> Signed-off-by: Rosen Penev <rosenp@gmail.com>
>
> Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
>
> It looks correct, but i'm currently out of office. I'll test it next
> week on hardware.
Tested on hardware. No issues found. Thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size
2026-06-08 4:56 [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size Rosen Penev
2026-06-09 8:04 ` Kurt Kanzenbach
@ 2026-06-15 19:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-15 19:50 UTC (permalink / raw)
To: Rosen Penev
Cc: netdev, kurt, andrew, olteanv, davem, edumazet, kuba, pabeni,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 7 Jun 2026 21:56:40 -0700 you wrote:
> One fewer allocation for the priv struct.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/net/dsa/hirschmann/hellcreek.c | 14 +++++---------
> drivers/net/dsa/hirschmann/hellcreek.h | 2 +-
> 2 files changed, 6 insertions(+), 10 deletions(-)
Here is the summary with links:
- net: dsa: hellcreek: replace kcalloc with struct_size
https://git.kernel.org/netdev/net-next/c/e3d202a1ed7c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-15 19:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08 4:56 [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size Rosen Penev
2026-06-09 8:04 ` Kurt Kanzenbach
2026-06-15 8:40 ` Kurt Kanzenbach
2026-06-15 19:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox