aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2010-07-15 13:05:39 +0000
committerGabor Juhos <juhosg@openwrt.org>2010-07-15 13:05:39 +0000
commitd2d1fc5eb6e72bb22285f930fe7fe8634691c066 (patch)
tree6bfe4add55f43520c7c95da6cb403e05b5653ad4 /target/linux/generic/files/drivers/net/phy/rtl8366rb.c
parentcf551c6259810ac1c07102a41c4f1d8dcb9bfdb8 (diff)
downloadmaster-187ad058-d2d1fc5eb6e72bb22285f930fe7fe8634691c066.tar.gz
master-187ad058-d2d1fc5eb6e72bb22285f930fe7fe8634691c066.tar.bz2
master-187ad058-d2d1fc5eb6e72bb22285f930fe7fe8634691c066.zip
generic: rtl8366: add is_vlan_valid function to smi_ops
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22201 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy/rtl8366rb.c')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366rb.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
index b6d3f9805f..2efde1df3f 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
@@ -552,6 +552,14 @@ static int rtl8366rb_set_mc_index(struct rtl8366_smi *smi, int port, int index)
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,
@@ -708,7 +716,7 @@ static int rtl8366rb_sw_get_vlan_info(struct switch_dev *dev,
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));
@@ -800,7 +808,7 @@ static int rtl8366rb_sw_get_vlan_ports(struct switch_dev *dev,
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);
@@ -829,7 +837,7 @@ static int rtl8366rb_sw_set_vlan_ports(struct switch_dev *dev,
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];
@@ -1071,6 +1079,7 @@ static struct rtl8366_smi_ops rtl8366rb_smi_ops = {
.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)