[PATCH] PPC4xx compatible ioctl for PHY control
Wolfgang Ocker
weo at reccoware.de
Wed Aug 27 04:22:58 EST 2008
From: Wolfgang Ocker <weo at reccoware.de>
Made PHY access in ioctl() for newemac driver compatible to other devices.
- Allow specification of PHY address in mii_ioctl_data->phy_id
- Use mii_ioctl_data structure
Signed-off-by: Wolfgang Ocker <weo at reccoware.de>
---
--- linux-2.6.26.3/drivers/net/ibm_newemac/core.c.mdio 2008-08-20 20:11:37.000000000 +0200
+++ linux-2.6.26.3/drivers/net/ibm_newemac/core.c 2008-08-24 18:25:49.000000000 +0200
@@ -2172,28 +2172,31 @@
static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
{
struct emac_instance *dev = netdev_priv(ndev);
- uint16_t *data = (uint16_t *) & rq->ifr_ifru;
+ struct mii_ioctl_data *data = if_mii(rq);
+ int r;
DBG(dev, "ioctl %08x" NL, cmd);
- if (dev->phy.address < 0)
+ if (data->phy_id & ~0x1f)
return -EOPNOTSUPP;
switch (cmd) {
case SIOCGMIIPHY:
case SIOCDEVPRIVATE:
- data[0] = dev->phy.address;
+ data->phy_id = dev->phy.address;
/* Fall through */
case SIOCGMIIREG:
case SIOCDEVPRIVATE + 1:
- data[3] = emac_mdio_read(ndev, dev->phy.address, data[1]);
+ r = emac_mdio_read(ndev, data->phy_id, data->reg_num);
+ if (r < 0)
+ r = 0xffff;
+ data->val_out = r;
return 0;
-
case SIOCSMIIREG:
case SIOCDEVPRIVATE + 2:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- emac_mdio_write(ndev, dev->phy.address, data[1], data[2]);
+ emac_mdio_write(ndev, data->phy_id, data->reg_num, data->val_in);
return 0;
default:
return -EOPNOTSUPP;
More information about the Linuxppc-dev
mailing list