Commit 189b0d93 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: dsa: Move port device node into port structure

Move the port device node structure into the port structure, from the
chip data. This information is needed in the next step of implementing
the new binding.

The chip data structure is used while parsing the whole old binding,
before the individual switch structures exist. With the new bindings,
this is reversed, the switches exist first, and the interconnections
between the switches is derived from the individual switch
bindings. Thus this chip data structure becomes unneeded.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
eviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c8b09808
...@@ -121,6 +121,7 @@ struct dsa_switch_tree { ...@@ -121,6 +121,7 @@ struct dsa_switch_tree {
struct dsa_port { struct dsa_port {
struct net_device *netdev; struct net_device *netdev;
struct device_node *dn;
}; };
struct dsa_switch { struct dsa_switch {
......
...@@ -182,7 +182,6 @@ __ATTRIBUTE_GROUPS(dsa_hwmon); ...@@ -182,7 +182,6 @@ __ATTRIBUTE_GROUPS(dsa_hwmon);
/* basic switch operations **************************************************/ /* basic switch operations **************************************************/
static int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct net_device *master) static int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct net_device *master)
{ {
struct dsa_chip_data *cd = ds->cd;
struct device_node *port_dn; struct device_node *port_dn;
struct phy_device *phydev; struct phy_device *phydev;
int ret, port, mode; int ret, port, mode;
...@@ -191,7 +190,7 @@ static int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct net_device *master) ...@@ -191,7 +190,7 @@ static int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct net_device *master)
if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
continue; continue;
port_dn = cd->port_dn[port]; port_dn = ds->ports[port].dn;
if (of_phy_is_fixed_link(port_dn)) { if (of_phy_is_fixed_link(port_dn)) {
ret = of_phy_register_fixed_link(port_dn); ret = of_phy_register_fixed_link(port_dn);
if (ret) { if (ret) {
...@@ -325,6 +324,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -325,6 +324,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
* Create network devices for physical switch ports. * Create network devices for physical switch ports.
*/ */
for (i = 0; i < DSA_MAX_PORTS; i++) { for (i = 0; i < DSA_MAX_PORTS; i++) {
ds->ports[i].dn = cd->port_dn[i];
if (!(ds->enabled_port_mask & (1 << i))) if (!(ds->enabled_port_mask & (1 << i)))
continue; continue;
...@@ -424,7 +425,6 @@ static void dsa_switch_destroy(struct dsa_switch *ds) ...@@ -424,7 +425,6 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
{ {
struct device_node *port_dn; struct device_node *port_dn;
struct phy_device *phydev; struct phy_device *phydev;
struct dsa_chip_data *cd = ds->cd;
int port; int port;
#ifdef CONFIG_NET_DSA_HWMON #ifdef CONFIG_NET_DSA_HWMON
...@@ -445,7 +445,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds) ...@@ -445,7 +445,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
/* Remove any fixed link PHYs */ /* Remove any fixed link PHYs */
for (port = 0; port < DSA_MAX_PORTS; port++) { for (port = 0; port < DSA_MAX_PORTS; port++) {
port_dn = cd->port_dn[port]; port_dn = ds->ports[port].dn;
if (of_phy_is_fixed_link(port_dn)) { if (of_phy_is_fixed_link(port_dn)) {
phydev = of_phy_find_device(port_dn); phydev = of_phy_find_device(port_dn);
if (phydev) { if (phydev) {
......
...@@ -998,13 +998,12 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, ...@@ -998,13 +998,12 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
struct net_device *slave_dev) struct net_device *slave_dev)
{ {
struct dsa_switch *ds = p->parent; struct dsa_switch *ds = p->parent;
struct dsa_chip_data *cd = ds->cd;
struct device_node *phy_dn, *port_dn; struct device_node *phy_dn, *port_dn;
bool phy_is_fixed = false; bool phy_is_fixed = false;
u32 phy_flags = 0; u32 phy_flags = 0;
int mode, ret; int mode, ret;
port_dn = cd->port_dn[p->port]; port_dn = ds->ports[p->port].dn;
mode = of_get_phy_mode(port_dn); mode = of_get_phy_mode(port_dn);
if (mode < 0) if (mode < 0)
mode = PHY_INTERFACE_MODE_NA; mode = PHY_INTERFACE_MODE_NA;
...@@ -1146,7 +1145,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, ...@@ -1146,7 +1145,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
NULL); NULL);
SET_NETDEV_DEV(slave_dev, parent); SET_NETDEV_DEV(slave_dev, parent);
slave_dev->dev.of_node = ds->cd->port_dn[port]; slave_dev->dev.of_node = ds->ports[port].dn;
slave_dev->vlan_features = master->vlan_features; slave_dev->vlan_features = master->vlan_features;
p = netdev_priv(slave_dev); p = netdev_priv(slave_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment