Only one phy can be accessed through ioctls to a socket (patch available)

DI BACCO ANTONIO - technolabs Antonio.DiBacco at technolabs.it
Sat Aug 25 01:56:03 EST 2007


> I'd certainly be interested in seeing it.

There is not much to see, only few lines in phy_device.c:

/* get_existing_phy_device:
 *
 * description: returns a phy device with the given address
 * if it exists
 */
static int phy_compare_addr(struct device *dev, void *data)
{
        return (*((int*)data) == to_phy_device(dev)->addr) ? 1 : 0;
}
struct phy_device * get_existing_phy_device(int addr)
{
        struct bus_type *bus = &mdio_bus_type;
        struct phy_device *phydev;

        struct device *d;

        /* Search the list of PHY devices on the mdio bus for the
         * PHY with the requested name */
        d = bus_find_device(bus, NULL, (void *) &addr,
phy_compare_addr);

        if (d)
    {
                phydev = to_phy_device(d);
        return phydev;
        }

        return NULL;

}
EXPORT_SYMBOL(get_existing_phy_device);


And a small change in fs_enet-main.c :


static int fs_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
        struct fs_enet_private *fep = netdev_priv(dev);
        struct mii_ioctl_data *mii = (struct mii_ioctl_data
*)&rq->ifr_data;
    struct phy_device* phydev = fep->phydev;
        unsigned long flags;
        int rc;

        if (!netif_running(dev) && (phydev->addr == mii->phy_id))
                return -EINVAL;

    if ((phydev->addr != mii->phy_id))
    {
      struct phy_device* d;

      if ((d = get_existing_phy_device(mii->phy_id)) != NULL)
        phydev = d;
      else
        return -ENODEV;
    }

        spin_lock_irqsave(&fep->lock, flags);
        rc = phy_mii_ioctl(phydev, mii, cmd);
        spin_unlock_irqrestore(&fep->lock, flags);
        return rc;
}


More information about the Linuxppc-embedded mailing list