struct phylink_pcs *rtpcs_create(struct device *dev, struct device_node *np, int port);
-int rtl83xx_port_get_stp_state(struct rtl838x_switch_priv *priv, int port)
+int rtldsa_port_get_stp_state(struct rtl838x_switch_priv *priv, int port)
{
+ u32 table[4];
u32 msti = 0;
- u32 port_state[4];
- int index, bit;
- int pos = port;
- int n = priv->port_width << 1;
+ int state;
- /* Ports above or equal CPU port can never be configured */
if (port >= priv->cpu_port)
- return -1;
+ return -EINVAL;
mutex_lock(&priv->reg_mutex);
-
- /* For the RTL839x and following, the bits are left-aligned in the 64/128 bit field */
- if (priv->family_id == RTL8390_FAMILY_ID)
- pos += 12;
- if (priv->family_id == RTL9300_FAMILY_ID)
- pos += 3;
- if (priv->family_id == RTL9310_FAMILY_ID)
- pos += 8;
-
- index = n - (pos >> 4) - 1;
- bit = (pos << 1) % 32;
-
- priv->r->stp_get(priv, msti, port, port_state);
-
+ state = priv->r->stp_get(priv, msti, port, table);
mutex_unlock(&priv->reg_mutex);
- return (port_state[index] >> bit) & 3;
+ return state;
}
static struct table_reg rtl838x_tbl_regs[] = {
{
struct rtl838x_port *p = filp->private_data;
struct dsa_switch *ds = p->dp->ds;
- int value = rtl83xx_port_get_stp_state(ds->priv, p->dp->index);
+ int state = rtldsa_port_get_stp_state(ds->priv, p->dp->index);
- if (value < 0)
- return -EINVAL;
+ if (state < 0)
+ return state;
- return rtl838x_common_read(buffer, count, ppos, (u32)value);
+ return rtl838x_common_read(buffer, count, ppos, (u32)state);
}
static ssize_t stp_state_write(struct file *filp, const char __user *buffer,
void rtl83xx_fast_age(struct dsa_switch *ds, int port);
int rtl83xx_packet_cntr_alloc(struct rtl838x_switch_priv *priv);
-int rtl83xx_port_get_stp_state(struct rtl838x_switch_priv *priv, int port);
+int rtldsa_port_get_stp_state(struct rtl838x_switch_priv *priv, int port);
int rtl83xx_port_is_under(const struct net_device *dev, struct rtl838x_switch_priv *priv);
void rtl83xx_port_stp_state_set(struct dsa_switch *ds, int port, u8 state);
int rtl83xx_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data);