In file fs_enet-main.c in function fs_ioctl the phy_mii_ioctl can be
issued only to the phydev associated with the FEC. If I have several
PHYs and only one associated to the FEC I cannot access all the PHYs. I
have a patch to overcome this limitation, is it interesting or not
useful?
=20
I need this patch because I have instantiated a virtual "Fixed PHY" and
I have associated it to my FEC, anyway I would like to access registers
of my physical PHY.
=20
Bye.
On Aug 22, 2007, at 03:56, DI BACCO ANTONIO - technolabs wrote:
In file fs_enet-main.c in function fs_ioctl the phy_mii_ioctl can be
issued only to the phydev associated with the FEC. If I have several
PHYs and only one associated to the FEC I cannot access all the
PHYs. I
have a patch to overcome this limitation, is it interesting or not
useful?
I need this patch because I have instantiated a virtual "Fixed PHY"
and
I have associated it to my FEC, anyway I would like to access
registers
of my physical PHY.
I'd certainly be interested in seeing it.
Andy
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;
}