MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_phy_find_by_mask

Function rt_phy_find_by_mask

components/drivers/phy/phy.c:426–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426struct rt_phy_device *rt_phy_find_by_mask(struct mii_bus *bus, unsigned int phy_mask)
427{
428 struct rt_phy_device *phy;
429 unsigned int mask = phy_mask;
430 unsigned int addr;
431 if (bus->reset)
432 {
433 bus->reset(bus);
434
435 rt_thread_mdelay(15);
436 }
437
438 while (mask)
439 {
440 /*
441 *Whichever bit of the mask is the 1,
442 *which bit is the addr as the array subscript to search
443 *such as mask = 1110 ,this loop will search for subscript
444 *1,2,3,if the array subscript is not null then return it,
445 *if the array subscript is null then continue to search
446 */
447 addr = __rt_ffs(mask) - 1;
448
449 if (bus->phymap[addr])
450 return bus->phymap[addr];
451
452 mask &= ~(1U << addr);
453 }
454 /*ifcan't find phy device, create a new phy device*/
455 phy = rt_phydev_create_by_mask(bus, phy_mask);
456
457 return phy;
458
459}
460
461/**
462 * @brief get phy device by given mii bus, node and address

Callers 1

rt_phy_get_deviceFunction · 0.85

Calls 3

rt_thread_mdelayFunction · 0.85
rt_phydev_create_by_maskFunction · 0.85
__rt_ffsFunction · 0.50

Tested by

no test coverage detected