mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
net: dsa: hellcreek: replace kcalloc with struct_size
One fewer allocation for the priv struct. Signed-off-by: Rosen Penev <rosenp@gmail.com> Acked-by: Kurt Kanzenbach <kurt@linutronix.de> Link: https://patch.msgid.link/20260608045640.5172-1-rosenp@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
75983f837d
commit
e3d202a1ed
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user