> @@ -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

Reply via email to