[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160427230729.GH29024@lunn.ch>
Date: Thu, 28 Apr 2016 01:07:29 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Vivien Didelot <vivien.didelot@...oirfairelinux.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel@...oirfairelinux.com,
"David S. Miller" <davem@...emloft.net>,
Florian Fainelli <f.fainelli@...il.com>,
Jiri Pirko <jiri@...nulli.us>
Subject: Re: [RFC 01/20] net: dsa: introduce a dsa_port structure
> @@ -230,6 +231,13 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
> for (i = 0; i < DSA_MAX_PORTS; i++) {
> char *name;
>
> + dp[i] = devm_kzalloc(parent, sizeof(*dp), GFP_KERNEL);
> + if (dp[i] == NULL)
> + return -ENOMEM;
You are not saving anything here by dynamically allocating the memory,
since you do it for all ports. So just make it a member of ds with
size DSA_MAX_PORTS. I would then call this array structure ports.
Humm, i also think keeping it in dsa_slave_priv is wrong, if you have
defined the structure in the global include/net/dsa.h. dsa_switch is a
better place for it.
Andrew
Powered by blists - more mailing lists