Commit 2b8fd87a authored by Ansuel Smith's avatar Ansuel Smith Committed by David S. Miller

net: dsa: qca8k: drop port_sts from qca8k_priv

Port_sts is a thing of the past for this driver. It was something
present on the initial implementation of this driver and parts of the
original struct were dropped over time. Using an array of int to store if
a port is enabled or not to handle PM operation seems overkill. Switch
and use a simple u8 to store the port status where each bit correspond
to a port. (bit is set port is enabled, bit is not set, port is disabled)
Also add some comments to better describe why we need to track port
status.
Signed-off-by: default avatarAnsuel Smith <ansuelsmth@gmail.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 69fd0559
...@@ -2346,7 +2346,7 @@ qca8k_port_enable(struct dsa_switch *ds, int port, ...@@ -2346,7 +2346,7 @@ qca8k_port_enable(struct dsa_switch *ds, int port,
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
qca8k_port_set_status(priv, port, 1); qca8k_port_set_status(priv, port, 1);
priv->port_sts[port].enabled = 1; priv->port_enabled_map |= BIT(port);
if (dsa_is_user_port(ds, port)) if (dsa_is_user_port(ds, port))
phy_support_asym_pause(phy); phy_support_asym_pause(phy);
...@@ -2360,7 +2360,7 @@ qca8k_port_disable(struct dsa_switch *ds, int port) ...@@ -2360,7 +2360,7 @@ qca8k_port_disable(struct dsa_switch *ds, int port)
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
qca8k_port_set_status(priv, port, 0); qca8k_port_set_status(priv, port, 0);
priv->port_sts[port].enabled = 0; priv->port_enabled_map &= ~BIT(port);
} }
static int static int
...@@ -3235,13 +3235,16 @@ static void qca8k_sw_shutdown(struct mdio_device *mdiodev) ...@@ -3235,13 +3235,16 @@ static void qca8k_sw_shutdown(struct mdio_device *mdiodev)
static void static void
qca8k_set_pm(struct qca8k_priv *priv, int enable) qca8k_set_pm(struct qca8k_priv *priv, int enable)
{ {
int i; int port;
for (i = 0; i < QCA8K_NUM_PORTS; i++) { for (port = 0; port < QCA8K_NUM_PORTS; port++) {
if (!priv->port_sts[i].enabled) /* Do not enable on resume if the port was
* disabled before.
*/
if (!(priv->port_enabled_map & BIT(port)))
continue; continue;
qca8k_port_set_status(priv, i, enable); qca8k_port_set_status(priv, port, enable);
} }
} }
......
...@@ -324,10 +324,6 @@ enum qca8k_mid_cmd { ...@@ -324,10 +324,6 @@ enum qca8k_mid_cmd {
QCA8K_MIB_CAST = 3, QCA8K_MIB_CAST = 3,
}; };
struct ar8xxx_port_status {
int enabled;
};
struct qca8k_match_data { struct qca8k_match_data {
u8 id; u8 id;
bool reduced_package; bool reduced_package;
...@@ -388,11 +384,14 @@ struct qca8k_priv { ...@@ -388,11 +384,14 @@ struct qca8k_priv {
u8 mirror_rx; u8 mirror_rx;
u8 mirror_tx; u8 mirror_tx;
u8 lag_hash_mode; u8 lag_hash_mode;
/* Each bit correspond to a port. This switch can support a max of 7 port.
* Bit 1: port enabled. Bit 0: port disabled.
*/
u8 port_enabled_map;
bool legacy_phy_port_mapping; bool legacy_phy_port_mapping;
struct qca8k_ports_config ports_config; struct qca8k_ports_config ports_config;
struct regmap *regmap; struct regmap *regmap;
struct mii_bus *bus; struct mii_bus *bus;
struct ar8xxx_port_status port_sts[QCA8K_NUM_PORTS];
struct dsa_switch *ds; struct dsa_switch *ds;
struct mutex reg_mutex; struct mutex reg_mutex;
struct device *dev; struct device *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