##这里主要是匹配
总线匹配
struct bus_type mdio_bus_type = {
.name = "mdio_bus",
.match = mdio_bus_match,
.pm = MDIO_BUS_PM_OPS,
.dev_attrs = mdio_dev_attrs,
};
从上面的结构体可以看出,linux中有多种总线类型.估计是从来匹配的.
例如platform的
struct bus_type platform_bus_type = {
.name = “platform”,
.dev_attrs = platform_dev_attrs,
.match = platform_match,
.uevent = platform_uevent,
.pm = PLATFORM_PM_OPS_PTR,
};
可以看出和猜想一致
接下来看一下我们关心的匹配的总线
/**
* mdio_bus_match - determine if given PHY driver supports the given PHY device
* @dev: target PHY device
* @drv: given PHY driver
*
* Description: Given a PHY device, and a PHY driver, return 1 if
* the driver supports the device. Otherwise, return 0.
*/
static int mdio_bus_match(struct device *dev, struct device_driver *drv)
{
struct phy_device *phydev = to_phy_device(dev);
struct phy_driver *phydrv = to_phy_driver(drv);
if (of_driver_match_device(dev, drv))
return 1;
if (phydrv->match_phy_device)
return phydrv->match_phy_device(phydev);
return ((phydrv->phy_id & phydrv->phy_id_mask) ==
(phydev->phy_id & phydrv->phy_id_mask));
}
可以看出来是根据是根据phy_id & phy_id_mask 是否想等来确定的.
那这个函数是谁调用的呢?应该是内核里面的核心吧.找不到
可以看到,最后一句里面的东西
关于driver端
是struct phy_driver 中的 struct device_driver driver;(后来被填充了)
关于device段