mirror of https://gitee.com/openkylin/linux.git
bgmac: use phy_mii_ioctl in ioctl handler
This works pretty much the same way, so avoid duplicating the code. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5322dbf00a
commit
69c588529d
|
@ -1198,27 +1198,11 @@ static int bgmac_set_mac_address(struct net_device *net_dev, void *addr)
|
||||||
static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
|
static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
|
||||||
{
|
{
|
||||||
struct bgmac *bgmac = netdev_priv(net_dev);
|
struct bgmac *bgmac = netdev_priv(net_dev);
|
||||||
struct mii_ioctl_data *data = if_mii(ifr);
|
|
||||||
|
|
||||||
switch (cmd) {
|
if (!netif_running(net_dev))
|
||||||
case SIOCGMIIPHY:
|
return -EINVAL;
|
||||||
data->phy_id = bgmac->phyaddr;
|
|
||||||
/* fallthru */
|
return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
|
||||||
case SIOCGMIIREG:
|
|
||||||
if (!netif_running(net_dev))
|
|
||||||
return -EAGAIN;
|
|
||||||
data->val_out = bgmac_phy_read(bgmac, data->phy_id,
|
|
||||||
data->reg_num & 0x1f);
|
|
||||||
return 0;
|
|
||||||
case SIOCSMIIREG:
|
|
||||||
if (!netif_running(net_dev))
|
|
||||||
return -EAGAIN;
|
|
||||||
bgmac_phy_write(bgmac, data->phy_id, data->reg_num & 0x1f,
|
|
||||||
data->val_in);
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct net_device_ops bgmac_netdev_ops = {
|
static const struct net_device_ops bgmac_netdev_ops = {
|
||||||
|
|
Loading…
Reference in New Issue