RE: Only one phy can be accessed through ioctls to a socket (patch available)
From: DI BACCO ANTONIO - technolabs <hidden>
Date: 2007-08-24 15:56:06
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) =3D=3D to_phy_device(dev)->addr) ? 1 : 0;
}
struct phy_device * get_existing_phy_device(int addr)
{
struct bus_type *bus =3D &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 =3D bus_find_device(bus, NULL, (void *) &addr,
phy_compare_addr);
if (d)
{
phydev =3D 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 =3D netdev_priv(dev);
struct mii_ioctl_data *mii =3D (struct mii_ioctl_data
*)&rq->ifr_data;
struct phy_device* phydev =3D fep->phydev;
unsigned long flags;
int rc;
if (!netif_running(dev) && (phydev->addr =3D=3D mii->phy_id))
return -EINVAL;
if ((phydev->addr !=3D mii->phy_id))
{
struct phy_device* d;
if ((d =3D get_existing_phy_device(mii->phy_id)) !=3D NULL)
phydev =3D d;
else
return -ENODEV;
}
spin_lock_irqsave(&fep->lock, flags);
rc =3D phy_mii_ioctl(phydev, mii, cmd);
spin_unlock_irqrestore(&fep->lock, flags);
return rc;
}