mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 00:21:17 +00:00
net: dsa: Remove dynamic allocate of routing table
With a maximum of four switches, the size of the routing table is the same as the pointer to it. Removing it makes the code simpler. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
189b0d93ec
commit
4a7704ffa8
3 changed files with 5 additions and 19 deletions
|
@ -3024,8 +3024,7 @@ static int mv88e6xxx_setup_global(struct mv88e6xxx_priv_state *ps)
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
int nexthop = 0x1f;
|
int nexthop = 0x1f;
|
||||||
|
|
||||||
if (ps->ds->cd->rtable &&
|
if (i != ps->ds->index && i < ps->ds->dst->pd->nr_chips)
|
||||||
i != ps->ds->index && i < ps->ds->dst->pd->nr_chips)
|
|
||||||
nexthop = ps->ds->cd->rtable[i] & 0x1f;
|
nexthop = ps->ds->cd->rtable[i] & 0x1f;
|
||||||
|
|
||||||
err = _mv88e6xxx_reg_write(
|
err = _mv88e6xxx_reg_write(
|
||||||
|
|
|
@ -58,12 +58,11 @@ struct dsa_chip_data {
|
||||||
struct device_node *port_dn[DSA_MAX_PORTS];
|
struct device_node *port_dn[DSA_MAX_PORTS];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An array (with nr_chips elements) of which element [a]
|
* An array of which element [a] indicates which port on this
|
||||||
* indicates which port on this switch should be used to
|
* switch should be used to send packets to that are destined
|
||||||
* send packets to that are destined for switch a. Can be
|
* for switch a. Can be NULL if there is only one switch chip.
|
||||||
* NULL if there is only one switch chip.
|
|
||||||
*/
|
*/
|
||||||
s8 *rtable;
|
s8 rtable[DSA_MAX_SWITCHES];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dsa_platform_data {
|
struct dsa_platform_data {
|
||||||
|
|
|
@ -587,17 +587,6 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
|
||||||
if (link_sw_addr >= pd->nr_chips)
|
if (link_sw_addr >= pd->nr_chips)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* First time routing table allocation */
|
|
||||||
if (!cd->rtable) {
|
|
||||||
cd->rtable = kmalloc_array(pd->nr_chips, sizeof(s8),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!cd->rtable)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
/* default to no valid uplink/downlink */
|
|
||||||
memset(cd->rtable, -1, pd->nr_chips * sizeof(s8));
|
|
||||||
}
|
|
||||||
|
|
||||||
cd->rtable[link_sw_addr] = port_index;
|
cd->rtable[link_sw_addr] = port_index;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -639,7 +628,6 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
|
||||||
kfree(pd->chip[i].port_names[port_index]);
|
kfree(pd->chip[i].port_names[port_index]);
|
||||||
port_index++;
|
port_index++;
|
||||||
}
|
}
|
||||||
kfree(pd->chip[i].rtable);
|
|
||||||
|
|
||||||
/* Drop our reference to the MDIO bus device */
|
/* Drop our reference to the MDIO bus device */
|
||||||
if (pd->chip[i].host_dev)
|
if (pd->chip[i].host_dev)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue