Skip to content

Commit

Permalink
net/usb/r815x: avoid to call mdio functions for runtime-suspended device
Browse files Browse the repository at this point in the history
Don't replace the usb_control_msg() with usbnet_{read,write}_cmd()
which couldn't be called inside suspend/resume callback. Keep the
basic functions unlimited. Instead, using usb_autopm_get_interface()
and usb_autopm_put_interface() in r815x_mdio_{read,write}().

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
hayeswang authored and David S. Miller committed Jul 31, 2013
1 parent b2f4737 commit b771721
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion drivers/net/usb/r815x.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,18 @@ static int ocp_reg_write(struct usbnet *dev, u16 addr, u16 data)
static int r815x_mdio_read(struct net_device *netdev, int phy_id, int reg)
{
struct usbnet *dev = netdev_priv(netdev);
int ret;

if (phy_id != R815x_PHY_ID)
return -EINVAL;

return ocp_reg_read(dev, BASE_MII + reg * 2);
if (usb_autopm_get_interface(dev->intf) < 0)
return -ENODEV;

ret = ocp_reg_read(dev, BASE_MII + reg * 2);

usb_autopm_put_interface(dev->intf);
return ret;
}

static
Expand All @@ -141,7 +148,12 @@ void r815x_mdio_write(struct net_device *netdev, int phy_id, int reg, int val)
if (phy_id != R815x_PHY_ID)
return;

if (usb_autopm_get_interface(dev->intf) < 0)
return;

ocp_reg_write(dev, BASE_MII + reg * 2, val);

usb_autopm_put_interface(dev->intf);
}

static int r8153_bind(struct usbnet *dev, struct usb_interface *intf)
Expand Down

0 comments on commit b771721

Please sign in to comment.