* @brief create phy device by mask * * @param bus MII bus pointer * @param phy_mask the mask which phy addr corresponding will be set 1 * @param devad dev addr if be set to zero it means c22 mode,else it means c45 mode * * @return if create success return the phy device pointer,if create fail return NULL */
| 358 | * @return if create success return the phy device pointer,if create fail return NULL |
| 359 | */ |
| 360 | static struct rt_phy_device *create_phy_by_mask(struct mii_bus *bus, unsigned int phy_mask,int devad) |
| 361 | { |
| 362 | rt_uint32_t id = 0xffffffff; |
| 363 | rt_bool_t is_c45; |
| 364 | |
| 365 | while (phy_mask) |
| 366 | { |
| 367 | int addr = __rt_ffs(phy_mask) - 1; |
| 368 | int r = get_phy_id(bus, addr, devad, &id); |
| 369 | |
| 370 | if (r == 0 && id == 0) |
| 371 | { |
| 372 | phy_mask &= ~(1 << addr); |
| 373 | continue; |
| 374 | } |
| 375 | |
| 376 | if (r == 0 && (id & 0x1fffffff) != 0x1fffffff) |
| 377 | { |
| 378 | is_c45 = (devad == RT_MDIO_DEVAD_NONE) ? RT_FALSE : RT_TRUE; |
| 379 | return rt_phy_device_create(bus, addr, id, is_c45); |
| 380 | } |
| 381 | |
| 382 | } |
| 383 | return RT_NULL; |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * @brief create phy device by mask |
no test coverage detected