On 12 December 2015 at 07:54, John Crispin <blo...@openwrt.org> wrote: > Hi Rafał, > > in addition to the comment i made last night, i found another possible > issue. see below. > > On 11/12/2015 14:48, Rafał Miłecki wrote: >> Some switches can force link speed for a port. Let's add API that will >> allow driver to export this feature. >> >> Signed-off-by: Rafał Miłecki <zaj...@gmail.com> >> --- >> .../linux/generic/files/drivers/net/phy/swconfig.c | 29 >> ++++++++++++++++++++++ >> target/linux/generic/files/include/linux/switch.h | 2 ++ >> 2 files changed, 31 insertions(+) >> >> diff --git a/target/linux/generic/files/drivers/net/phy/swconfig.c >> b/target/linux/generic/files/drivers/net/phy/swconfig.c >> index 6bb3be1..58d6cf5 100644 >> --- a/target/linux/generic/files/drivers/net/phy/swconfig.c >> +++ b/target/linux/generic/files/drivers/net/phy/swconfig.c >> @@ -187,6 +187,34 @@ swconfig_get_link(struct switch_dev *dev, const struct >> switch_attr *attr, >> } >> >> static int >> +swconfig_set_link(struct switch_dev *dev, const struct switch_attr *attr, >> + struct switch_val *val) >> +{ >> + enum switch_port_speed speed; >> + const char *s = val->value.s; >> + int len; >> + >> + if (val->port_vlan >= dev->ports) >> + return -EINVAL; >> + >> + if (!dev->ops->set_port_link) >> + return -EOPNOTSUPP; >> + >> + len = strchrnul(s, ' ') - s; >> + if (!strncmp(s, "10", len)) { >> + speed = SWITCH_PORT_SPEED_10; >> + } else if (!strncmp(s, "100", len)) { >> + speed = SWITCH_PORT_SPEED_100; >> + } else if (!strncmp(s, "1000", len)) { >> + speed = SWITCH_PORT_SPEED_1000; >> + } else { >> + speed = SWITCH_PORT_SPEED_UNKNOWN; >> + } >> + >> + return dev->ops->set_port_link(dev, val->port_vlan, speed); > > this makes the assumption, that all drivers always add the > set_port_link() callback and uses it unconditionally. i am impartial on > how this is solved in detail as long as some kind of check is added
You had to miss if (!dev->ops->set_port_link) part :) -- Rafał _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel