Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0536cd9 authored by Shaohui Xie's avatar Shaohui Xie Committed by David S. Miller
Browse files

net/mdio: fix mdio_bus_match for c45 PHY



We store c45 PHY's id information in c45_ids, so it should be used to
check the matching between PHY driver and PHY device for c45 PHY.

Signed-off-by: default avatarShaohui Xie <Shaohui.Xie@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8bf4ada2
Loading
Loading
Loading
Loading
+17 −2
Original line number Original line Diff line number Diff line
@@ -421,6 +421,8 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv)
{
{
	struct phy_device *phydev = to_phy_device(dev);
	struct phy_device *phydev = to_phy_device(dev);
	struct phy_driver *phydrv = to_phy_driver(drv);
	struct phy_driver *phydrv = to_phy_driver(drv);
	const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids);
	int i;


	if (of_driver_match_device(dev, drv))
	if (of_driver_match_device(dev, drv))
		return 1;
		return 1;
@@ -428,9 +430,22 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv)
	if (phydrv->match_phy_device)
	if (phydrv->match_phy_device)
		return phydrv->match_phy_device(phydev);
		return phydrv->match_phy_device(phydev);


	if (phydev->is_c45) {
		for (i = 1; i < num_ids; i++) {
			if (!(phydev->c45_ids.devices_in_package & (1 << i)))
				continue;

			if ((phydrv->phy_id & phydrv->phy_id_mask) ==
			    (phydev->c45_ids.device_ids[i] &
			     phydrv->phy_id_mask))
				return 1;
		}
		return 0;
	} else {
		return (phydrv->phy_id & phydrv->phy_id_mask) ==
		return (phydrv->phy_id & phydrv->phy_id_mask) ==
			(phydev->phy_id & phydrv->phy_id_mask);
			(phydev->phy_id & phydrv->phy_id_mask);
	}
	}
}


#ifdef CONFIG_PM
#ifdef CONFIG_PM