From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Cc: Kurt Kanzenbach <kurt@linutronix.de>,
Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size
Date: Sun, 7 Jun 2026 21:56:40 -0700 [thread overview]
Message-ID: <20260608045640.5172-1-rosenp@gmail.com> (raw)
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
next reply other threads:[~2026-06-08 4:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 4:56 Rosen Penev [this message]
2026-06-09 8:04 ` [PATCH] net: dsa: hellcreek: replace kcalloc with struct_size Kurt Kanzenbach
2026-06-15 8:40 ` Kurt Kanzenbach
2026-06-15 19:50 ` patchwork-bot+netdevbpf
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=20260608045640.5172-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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 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.