int (*set_mc_index)(struct rtl8366_smi *smi, int port, int index);
int (*get_mib_counter)(struct rtl8366_smi *smi, int counter,
int port, unsigned long long *val);
+ int (*is_vlan_valid)(struct rtl8366_smi *smi, unsigned vlan);
};
struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent);
RTL8366RB_PORT_VLAN_CTRL_SHIFT(port));
}
+static int rtl8366rb_is_vlan_valid(struct rtl8366_smi *smi, unsigned vlan)
+{
+ if (vlan == 0 || vlan >= RTL8366RB_NUM_VLANS)
+ return 0;
+
+ return 1;
+}
+
static int rtl8366rb_vlan_set_vlan(struct rtl8366_smi *smi, int enable)
{
return rtl8366_smi_rmwr(smi, RTL8366RB_SGCR, RTL8366RB_SGCR_EN_VLAN,
char *buf = smi->buf;
int err;
- if (val->port_vlan == 0 || val->port_vlan >= RTL8366RB_NUM_VLANS)
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
return -EINVAL;
memset(buf, '\0', sizeof(smi->buf));
struct rtl8366_vlan_4k vlan4k;
int i;
- if (val->port_vlan == 0 || val->port_vlan >= RTL8366RB_NUM_VLANS)
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
return -EINVAL;
rtl8366rb_get_vlan_4k(smi, val->port_vlan, &vlan4k);
u32 untag = 0;
int i;
- if (val->port_vlan == 0 || val->port_vlan >= RTL8366RB_NUM_VLANS)
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
return -EINVAL;
port = &val->value.ports[0];
.get_mc_index = rtl8366rb_get_mc_index,
.set_mc_index = rtl8366rb_set_mc_index,
.get_mib_counter = rtl8366rb_get_mib_counter,
+ .is_vlan_valid = rtl8366rb_is_vlan_valid,
};
static int __init rtl8366rb_probe(struct platform_device *pdev)
1, (enable) ? 1 : 0);
}
+static int rtl8366s_is_vlan_valid(struct rtl8366_smi *smi, unsigned vlan)
+{
+ if (vlan == 0 || vlan >= RTL8366S_NUM_VLANS)
+ return 0;
+
+ return 1;
+}
+
static int rtl8366s_sw_reset_mibs(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
char *buf = smi->buf;
int err;
- if (val->port_vlan == 0 || val->port_vlan >= RTL8366S_NUM_VLANS)
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
return -EINVAL;
memset(buf, '\0', sizeof(smi->buf));
struct rtl8366_vlan_4k vlan4k;
int i;
- if (val->port_vlan == 0 || val->port_vlan >= RTL8366S_NUM_VLANS)
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
return -EINVAL;
rtl8366s_get_vlan_4k(smi, val->port_vlan, &vlan4k);
u32 untag = 0;
int i;
- if (val->port_vlan == 0 || val->port_vlan >= RTL8366S_NUM_VLANS)
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
return -EINVAL;
port = &val->value.ports[0];
.get_mc_index = rtl8366s_get_mc_index,
.set_mc_index = rtl8366s_set_mc_index,
.get_mib_counter = rtl8366_get_mib_counter,
+ .is_vlan_valid = rtl8366s_is_vlan_valid,
};
static int __init rtl8366s_probe(struct platform_device *pdev)