*/
bool vlan_filtering;
- /* Dynamically allocated ports, keep last */
size_t num_ports;
- struct dsa_port ports[];
};
static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
struct dsa_switch_tree *dst = ds->dst;
struct dsa_port *dp;
- dp = &ds->ports[index];
+ list_for_each_entry(dp, &dst->ports, list)
+ if (dp->ds == ds && dp->index == index)
+ return dp;
+
+ dp = kzalloc(sizeof(*dp), GFP_KERNEL);
+ if (!dp)
+ return NULL;
dp->ds = ds;
dp->index = index;
{
struct dsa_switch *ds;
- ds = devm_kzalloc(dev, struct_size(ds, ports, n), GFP_KERNEL);
+ ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
if (!ds)
return NULL;
{
struct dsa_switch_tree *dst = ds->dst;
unsigned int index = ds->index;
+ struct dsa_port *dp, *next;
+
+ list_for_each_entry_safe(dp, next, &dst->ports, list) {
+ list_del(&dp->list);
+ kfree(dp);
+ }
dsa_tree_remove_switch(dst, index);
}