提交 6ed74236 编写于 作者: A Andrew Lunn 提交者: David S. Miller

of: of_mdio: Ensure mdio device is a PHY

of_phy_find_device() is used to find the phy device associated with a
device node. It is expected the node is for a PHY device, but in fact
it could of been probed as a generic MDIO device. Ensure the device is
a PHY before returning it.

Fixes: a9049e0c ("mdio: Add support for mdio drivers.")
Reported-by: NAaro Koskinen <aaro.koskinen@nokia.com>
Reported-by: NOlof Johansson <olof@lixom.net>
Signed-off-by: NAndrew Lunn <andrew@lunn.ch>
Tested-by: NAaro Koskinen <aaro.koskinen@nokia.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 bd7c5e31
......@@ -256,11 +256,19 @@ static int of_phy_match(struct device *dev, void *phy_np)
struct phy_device *of_phy_find_device(struct device_node *phy_np)
{
struct device *d;
struct mdio_device *mdiodev;
if (!phy_np)
return NULL;
d = bus_find_device(&mdio_bus_type, NULL, phy_np, of_phy_match);
return d ? to_phy_device(d) : NULL;
if (d) {
mdiodev = to_mdio_device(d);
if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
return to_phy_device(d);
}
return NULL;
}
EXPORT_SYMBOL(of_phy_find_device);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册