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

Function create_phy_by_mask

components/drivers/phy/phy.c:360–384  ·  view source on GitHub ↗

* @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 */

Source from the content-addressed store, hash-verified

358 * @return if create success return the phy device pointer,if create fail return NULL
359 */
360static 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

Callers 1

rt_phydev_create_by_maskFunction · 0.70

Calls 3

rt_phy_device_createFunction · 0.85
get_phy_idFunction · 0.70
__rt_ffsFunction · 0.50

Tested by

no test coverage detected