aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorDavid Bauer <mail@david-bauer.net>2018-10-22 02:35:36 +0200
committerKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>2018-11-23 21:45:51 +0000
commit6680fab9474a8a2d66d5ef86e2c392abe0d2c62d (patch)
tree18dd961cd1880f471d43d3643c616ef88845ccb4 /target/linux
parent53020ed4b981d8d48394842d0aff1a0d0497cc1c (diff)
downloadupstream-6680fab9474a8a2d66d5ef86e2c392abe0d2c62d.tar.gz
upstream-6680fab9474a8a2d66d5ef86e2c392abe0d2c62d.tar.bz2
upstream-6680fab9474a8a2d66d5ef86e2c392abe0d2c62d.zip
kernel: b53: register switch on probe
Currently, the b53 MDIO switch driver registers the switch on config-init and not on device probe. Because of this, the switch gets added every time the associated interface comes up. This commit fixes this behavior by registering the switch on device probe. Compile- and run-tested on OCEDO Koala. Signed-off-by: David Bauer <mail@david-bauer.net>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c b/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c
index 75bb4d941c..5934befc9e 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c
@@ -273,55 +273,54 @@ static struct b53_io_ops b53_mdio_ops = {
static int b53_phy_probe(struct phy_device *phydev)
{
- struct b53_device dev;
+ struct b53_device *dev;
int ret;
/* allow the generic phy driver to take over */
if (phydev->mdio.addr != B53_PSEUDO_PHY && phydev->mdio.addr != 0)
return -ENODEV;
- dev.current_page = 0xff;
- dev.priv = phydev->mdio.bus;
- dev.ops = &b53_mdio_ops;
- dev.pdata = NULL;
- mutex_init(&dev.reg_mutex);
+ dev = b53_switch_alloc(&phydev->mdio.dev, &b53_mdio_ops, phydev->mdio.bus);
+ if (!dev)
+ return -ENOMEM;
- ret = b53_switch_detect(&dev);
+ dev->current_page = 0xff;
+ dev->priv = phydev->mdio.bus;
+ dev->ops = &b53_mdio_ops;
+ dev->pdata = NULL;
+ mutex_init(&dev->reg_mutex);
+
+ ret = b53_switch_detect(dev);
if (ret)
return ret;
- if (is5325(&dev) || is5365(&dev))
+ if (is5325(dev) || is5365(dev))
phydev->supported = SUPPORTED_100baseT_Full;
else
phydev->supported = SUPPORTED_1000baseT_Full;
phydev->advertising = phydev->supported;
+ ret = b53_switch_register(dev);
+ if (ret) {
+ dev_err(dev->dev, "failed to register switch: %i\n", ret);
+ return ret;
+ }
+
+ phydev->priv = dev;
+
return 0;
}
static int b53_phy_config_init(struct phy_device *phydev)
{
- struct b53_device *dev;
- int ret;
-
- dev = b53_switch_alloc(&phydev->mdio.dev, &b53_mdio_ops, phydev->mdio.bus);
- if (!dev)
- return -ENOMEM;
+ struct b53_device *dev = phydev->priv;
/* we don't use page 0xff, so force a page set */
dev->current_page = 0xff;
/* force the ethX as alias */
dev->sw_dev.alias = phydev->attached_dev->name;
- ret = b53_switch_register(dev);
- if (ret) {
- dev_err(dev->dev, "failed to register switch: %i\n", ret);
- return ret;
- }
-
- phydev->priv = dev;
-
return 0;
}