Skip to content

Commit

Permalink
smsc75xx: add explicit test that device is READY
Browse files Browse the repository at this point in the history
This patch adds an explicit test that the READY bit is set on
the device when attempting to initialize it.

If this bit is clear then the device hasn't succesfully started
all its clocks, and this patch helps make the resulting logged
error more helpful.

Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Steve Glendinning authored and David S. Miller committed Sep 28, 2012
1 parent e0e474a commit 8762cec
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions drivers/net/usb/smsc75xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,26 @@ static int smsc75xx_set_features(struct net_device *netdev,
return 0;
}

static int smsc75xx_wait_ready(struct usbnet *dev)
{
int timeout = 0;

do {
u32 buf;
int ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
check_warn_return(ret, "Failed to read PMT_CTL: %d", ret);

if (buf & PMT_CTL_DEV_RDY)
return 0;

msleep(10);
timeout++;
} while (timeout < 100);

netdev_warn(dev->net, "timeout waiting for device ready");
return -EIO;
}

static int smsc75xx_reset(struct usbnet *dev)
{
struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
Expand All @@ -764,6 +784,9 @@ static int smsc75xx_reset(struct usbnet *dev)

netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset");

ret = smsc75xx_wait_ready(dev);
check_warn_return(ret, "device not ready in smsc75xx_reset");

ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
check_warn_return(ret, "Failed to read HW_CFG: %d", ret);

Expand Down

0 comments on commit 8762cec

Please sign in to comment.