Commit e360a8b4 authored by Steve Glendinning's avatar Steve Glendinning Committed by David S. Miller

smsc95xx: eliminate duplicate warnings on io failure

The register read/write functions already log a warning if
an access fails, so this patch removes the additional warnings
logged by callers that don't add any more information.

This patch makes the resulting driver smaller by not containing
as many warning strings.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarSteve Glendinning <steve.glendinning@shawell.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 912df262
...@@ -513,10 +513,8 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, ...@@ -513,10 +513,8 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex,
u32 flow, afc_cfg = 0; u32 flow, afc_cfg = 0;
int ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg); int ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading AFC_CFG\n");
return ret; return ret;
}
if (duplex == DUPLEX_FULL) { if (duplex == DUPLEX_FULL) {
u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
...@@ -541,16 +539,10 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, ...@@ -541,16 +539,10 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex,
} }
ret = smsc95xx_write_reg(dev, FLOW, flow); ret = smsc95xx_write_reg(dev, FLOW, flow);
if (ret < 0) {
netdev_warn(dev->net, "Error writing FLOW\n");
return ret;
}
ret = smsc95xx_write_reg(dev, AFC_CFG, afc_cfg);
if (ret < 0) if (ret < 0)
netdev_warn(dev->net, "Error writing AFC_CFG\n");
return ret; return ret;
return smsc95xx_write_reg(dev, AFC_CFG, afc_cfg);
} }
static int smsc95xx_link_reset(struct usbnet *dev) static int smsc95xx_link_reset(struct usbnet *dev)
...@@ -564,16 +556,12 @@ static int smsc95xx_link_reset(struct usbnet *dev) ...@@ -564,16 +556,12 @@ static int smsc95xx_link_reset(struct usbnet *dev)
/* clear interrupt status */ /* clear interrupt status */
ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PHY_INT_SRC\n");
return ret; return ret;
}
ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_); ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing INT_STS\n");
return ret; return ret;
}
mii_check_media(mii, 1, 1); mii_check_media(mii, 1, 1);
mii_ethtool_gset(&dev->mii, &ecmd); mii_ethtool_gset(&dev->mii, &ecmd);
...@@ -595,10 +583,8 @@ static int smsc95xx_link_reset(struct usbnet *dev) ...@@ -595,10 +583,8 @@ static int smsc95xx_link_reset(struct usbnet *dev)
spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); spin_unlock_irqrestore(&pdata->mac_cr_lock, flags);
ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing MAC_CR\n");
return ret; return ret;
}
ret = smsc95xx_phy_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); ret = smsc95xx_phy_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv);
if (ret < 0) if (ret < 0)
...@@ -638,10 +624,8 @@ static int smsc95xx_set_features(struct net_device *netdev, ...@@ -638,10 +624,8 @@ static int smsc95xx_set_features(struct net_device *netdev,
int ret; int ret;
ret = smsc95xx_read_reg(dev, COE_CR, &read_buf); ret = smsc95xx_read_reg(dev, COE_CR, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read COE_CR: %d\n", ret);
return ret; return ret;
}
if (features & NETIF_F_HW_CSUM) if (features & NETIF_F_HW_CSUM)
read_buf |= Tx_COE_EN_; read_buf |= Tx_COE_EN_;
...@@ -654,10 +638,8 @@ static int smsc95xx_set_features(struct net_device *netdev, ...@@ -654,10 +638,8 @@ static int smsc95xx_set_features(struct net_device *netdev,
read_buf &= ~Rx_COE_EN_; read_buf &= ~Rx_COE_EN_;
ret = smsc95xx_write_reg(dev, COE_CR, read_buf); ret = smsc95xx_write_reg(dev, COE_CR, read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write COE_CR: %d\n", ret);
return ret; return ret;
}
netif_dbg(dev, hw, dev->net, "COE_CR = 0x%08x\n", read_buf); netif_dbg(dev, hw, dev->net, "COE_CR = 0x%08x\n", read_buf);
return 0; return 0;
...@@ -800,16 +782,10 @@ static int smsc95xx_set_mac_address(struct usbnet *dev) ...@@ -800,16 +782,10 @@ static int smsc95xx_set_mac_address(struct usbnet *dev)
int ret; int ret;
ret = smsc95xx_write_reg(dev, ADDRL, addr_lo); ret = smsc95xx_write_reg(dev, ADDRL, addr_lo);
if (ret < 0) {
netdev_warn(dev->net, "Failed to write ADDRL: %d\n", ret);
return ret;
}
ret = smsc95xx_write_reg(dev, ADDRH, addr_hi);
if (ret < 0) if (ret < 0)
netdev_warn(dev->net, "Failed to write ADDRH: %d\n", ret);
return ret; return ret;
return smsc95xx_write_reg(dev, ADDRH, addr_hi);
} }
/* starts the TX path */ /* starts the TX path */
...@@ -825,17 +801,11 @@ static int smsc95xx_start_tx_path(struct usbnet *dev) ...@@ -825,17 +801,11 @@ static int smsc95xx_start_tx_path(struct usbnet *dev)
spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); spin_unlock_irqrestore(&pdata->mac_cr_lock, flags);
ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write MAC_CR: %d\n", ret);
return ret; return ret;
}
/* Enable Tx at SCSRs */ /* Enable Tx at SCSRs */
ret = smsc95xx_write_reg(dev, TX_CFG, TX_CFG_ON_); return smsc95xx_write_reg(dev, TX_CFG, TX_CFG_ON_);
if (ret < 0)
netdev_warn(dev->net, "Failed to write TX_CFG: %d\n", ret);
return ret;
} }
/* Starts the Receive path */ /* Starts the Receive path */
...@@ -843,17 +813,12 @@ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) ...@@ -843,17 +813,12 @@ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm)
{ {
struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
unsigned long flags; unsigned long flags;
int ret;
spin_lock_irqsave(&pdata->mac_cr_lock, flags); spin_lock_irqsave(&pdata->mac_cr_lock, flags);
pdata->mac_cr |= MAC_CR_RXEN_; pdata->mac_cr |= MAC_CR_RXEN_;
spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); spin_unlock_irqrestore(&pdata->mac_cr_lock, flags);
ret = __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr, in_pm); return __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr, in_pm);
if (ret < 0)
netdev_warn(dev->net, "Failed to write MAC_CR: %d\n", ret);
return ret;
} }
static int smsc95xx_phy_initialize(struct usbnet *dev) static int smsc95xx_phy_initialize(struct usbnet *dev)
...@@ -910,19 +875,15 @@ static int smsc95xx_reset(struct usbnet *dev) ...@@ -910,19 +875,15 @@ static int smsc95xx_reset(struct usbnet *dev)
netif_dbg(dev, ifup, dev->net, "entering smsc95xx_reset\n"); netif_dbg(dev, ifup, dev->net, "entering smsc95xx_reset\n");
ret = smsc95xx_write_reg(dev, HW_CFG, HW_CFG_LRST_); ret = smsc95xx_write_reg(dev, HW_CFG, HW_CFG_LRST_);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write HW_CFG_LRST_ bit in HW_CFG\n");
return ret; return ret;
}
timeout = 0; timeout = 0;
do { do {
msleep(10); msleep(10);
ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
return ret; return ret;
}
timeout++; timeout++;
} while ((read_buf & HW_CFG_LRST_) && (timeout < 100)); } while ((read_buf & HW_CFG_LRST_) && (timeout < 100));
...@@ -932,19 +893,15 @@ static int smsc95xx_reset(struct usbnet *dev) ...@@ -932,19 +893,15 @@ static int smsc95xx_reset(struct usbnet *dev)
} }
ret = smsc95xx_write_reg(dev, PM_CTRL, PM_CTL_PHY_RST_); ret = smsc95xx_write_reg(dev, PM_CTRL, PM_CTL_PHY_RST_);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write PM_CTRL: %d\n", ret);
return ret; return ret;
}
timeout = 0; timeout = 0;
do { do {
msleep(10); msleep(10);
ret = smsc95xx_read_reg(dev, PM_CTRL, &read_buf); ret = smsc95xx_read_reg(dev, PM_CTRL, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read PM_CTRL: %d\n", ret);
return ret; return ret;
}
timeout++; timeout++;
} while ((read_buf & PM_CTL_PHY_RST_) && (timeout < 100)); } while ((read_buf & PM_CTL_PHY_RST_) && (timeout < 100));
...@@ -961,10 +918,8 @@ static int smsc95xx_reset(struct usbnet *dev) ...@@ -961,10 +918,8 @@ static int smsc95xx_reset(struct usbnet *dev)
dev->net->dev_addr); dev->net->dev_addr);
ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
return ret; return ret;
}
netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n", netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n",
read_buf); read_buf);
...@@ -972,16 +927,12 @@ static int smsc95xx_reset(struct usbnet *dev) ...@@ -972,16 +927,12 @@ static int smsc95xx_reset(struct usbnet *dev)
read_buf |= HW_CFG_BIR_; read_buf |= HW_CFG_BIR_;
ret = smsc95xx_write_reg(dev, HW_CFG, read_buf); ret = smsc95xx_write_reg(dev, HW_CFG, read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write HW_CFG_BIR_ bit in HW_CFG\n");
return ret; return ret;
}
ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
return ret; return ret;
}
netif_dbg(dev, ifup, dev->net, netif_dbg(dev, ifup, dev->net,
"Read Value from HW_CFG after writing HW_CFG_BIR_: 0x%08x\n", "Read Value from HW_CFG after writing HW_CFG_BIR_: 0x%08x\n",
...@@ -1002,42 +953,32 @@ static int smsc95xx_reset(struct usbnet *dev) ...@@ -1002,42 +953,32 @@ static int smsc95xx_reset(struct usbnet *dev)
(ulong)dev->rx_urb_size); (ulong)dev->rx_urb_size);
ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap); ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write BURST_CAP: %d\n", ret);
return ret; return ret;
}
ret = smsc95xx_read_reg(dev, BURST_CAP, &read_buf); ret = smsc95xx_read_reg(dev, BURST_CAP, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read BURST_CAP: %d\n", ret);
return ret; return ret;
}
netif_dbg(dev, ifup, dev->net, netif_dbg(dev, ifup, dev->net,
"Read Value from BURST_CAP after writing: 0x%08x\n", "Read Value from BURST_CAP after writing: 0x%08x\n",
read_buf); read_buf);
ret = smsc95xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY); ret = smsc95xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write BULK_IN_DLY: %d\n", ret);
return ret; return ret;
}
ret = smsc95xx_read_reg(dev, BULK_IN_DLY, &read_buf); ret = smsc95xx_read_reg(dev, BULK_IN_DLY, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read BULK_IN_DLY: %d\n", ret);
return ret; return ret;
}
netif_dbg(dev, ifup, dev->net, netif_dbg(dev, ifup, dev->net,
"Read Value from BULK_IN_DLY after writing: 0x%08x\n", "Read Value from BULK_IN_DLY after writing: 0x%08x\n",
read_buf); read_buf);
ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
return ret; return ret;
}
netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG: 0x%08x\n", netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG: 0x%08x\n",
read_buf); read_buf);
...@@ -1051,69 +992,51 @@ static int smsc95xx_reset(struct usbnet *dev) ...@@ -1051,69 +992,51 @@ static int smsc95xx_reset(struct usbnet *dev)
read_buf |= NET_IP_ALIGN << 9; read_buf |= NET_IP_ALIGN << 9;
ret = smsc95xx_write_reg(dev, HW_CFG, read_buf); ret = smsc95xx_write_reg(dev, HW_CFG, read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret);
return ret; return ret;
}
ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
return ret; return ret;
}
netif_dbg(dev, ifup, dev->net, netif_dbg(dev, ifup, dev->net,
"Read Value from HW_CFG after writing: 0x%08x\n", read_buf); "Read Value from HW_CFG after writing: 0x%08x\n", read_buf);
ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_); ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write INT_STS: %d\n", ret);
return ret; return ret;
}
ret = smsc95xx_read_reg(dev, ID_REV, &read_buf); ret = smsc95xx_read_reg(dev, ID_REV, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read ID_REV: %d\n", ret);
return ret; return ret;
}
netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", read_buf); netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", read_buf);
/* Configure GPIO pins as LED outputs */ /* Configure GPIO pins as LED outputs */
write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED | write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED |
LED_GPIO_CFG_FDX_LED; LED_GPIO_CFG_FDX_LED;
ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf); ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write LED_GPIO_CFG: %d\n", ret);
return ret; return ret;
}
/* Init Tx */ /* Init Tx */
ret = smsc95xx_write_reg(dev, FLOW, 0); ret = smsc95xx_write_reg(dev, FLOW, 0);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write FLOW: %d\n", ret);
return ret; return ret;
}
ret = smsc95xx_write_reg(dev, AFC_CFG, AFC_CFG_DEFAULT); ret = smsc95xx_write_reg(dev, AFC_CFG, AFC_CFG_DEFAULT);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write AFC_CFG: %d\n", ret);
return ret; return ret;
}
/* Don't need mac_cr_lock during initialisation */ /* Don't need mac_cr_lock during initialisation */
ret = smsc95xx_read_reg(dev, MAC_CR, &pdata->mac_cr); ret = smsc95xx_read_reg(dev, MAC_CR, &pdata->mac_cr);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read MAC_CR: %d\n", ret);
return ret; return ret;
}
/* Init Rx */ /* Init Rx */
/* Set Vlan */ /* Set Vlan */
ret = smsc95xx_write_reg(dev, VLAN1, (u32)ETH_P_8021Q); ret = smsc95xx_write_reg(dev, VLAN1, (u32)ETH_P_8021Q);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write VLAN1: %d\n", ret);
return ret; return ret;
}
/* Enable or disable checksum offload engines */ /* Enable or disable checksum offload engines */
ret = smsc95xx_set_features(dev->net, dev->net->features); ret = smsc95xx_set_features(dev->net, dev->net->features);
...@@ -1131,19 +1054,15 @@ static int smsc95xx_reset(struct usbnet *dev) ...@@ -1131,19 +1054,15 @@ static int smsc95xx_reset(struct usbnet *dev)
} }
ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf); ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read INT_EP_CTL: %d\n", ret);
return ret; return ret;
}
/* enable PHY interrupts */ /* enable PHY interrupts */
read_buf |= INT_EP_CTL_PHY_INT_; read_buf |= INT_EP_CTL_PHY_INT_;
ret = smsc95xx_write_reg(dev, INT_EP_CTL, read_buf); ret = smsc95xx_write_reg(dev, INT_EP_CTL, read_buf);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to write INT_EP_CTL: %d\n", ret);
return ret; return ret;
}
ret = smsc95xx_start_tx_path(dev); ret = smsc95xx_start_tx_path(dev);
if (ret < 0) { if (ret < 0) {
...@@ -1213,10 +1132,8 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) ...@@ -1213,10 +1132,8 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
/* detect device revision as different features may be available */ /* detect device revision as different features may be available */
ret = smsc95xx_read_reg(dev, ID_REV, &val); ret = smsc95xx_read_reg(dev, ID_REV, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Failed to read ID_REV: %d\n", ret);
return ret; return ret;
}
val >>= 16; val >>= 16;
if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9530_) || if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9530_) ||
...@@ -1261,17 +1178,13 @@ static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) ...@@ -1261,17 +1178,13 @@ static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask)
/* read to clear */ /* read to clear */
ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC); ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PHY_INT_SRC\n");
return ret; return ret;
}
/* enable interrupt source */ /* enable interrupt source */
ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK); ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PHY_INT_MASK\n");
return ret; return ret;
}
ret |= mask; ret |= mask;
...@@ -1287,16 +1200,12 @@ static int smsc95xx_link_ok_nopm(struct usbnet *dev) ...@@ -1287,16 +1200,12 @@ static int smsc95xx_link_ok_nopm(struct usbnet *dev)
/* first, a dummy read, needed to latch some MII phys */ /* first, a dummy read, needed to latch some MII phys */
ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading MII_BMSR\n");
return ret; return ret;
}
ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading MII_BMSR\n");
return ret; return ret;
}
return !!(ret & BMSR_LSTATUS); return !!(ret & BMSR_LSTATUS);
} }
...@@ -1308,19 +1217,15 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) ...@@ -1308,19 +1217,15 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev)
int ret; int ret;
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PM_CTRL\n");
return ret; return ret;
}
val &= (~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_)); val &= (~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_));
val |= PM_CTL_SUS_MODE_0; val |= PM_CTL_SUS_MODE_0;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing PM_CTRL\n");
return ret; return ret;
}
/* clear wol status */ /* clear wol status */
val &= ~PM_CTL_WUPS_; val &= ~PM_CTL_WUPS_;
...@@ -1331,15 +1236,11 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) ...@@ -1331,15 +1236,11 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev)
val |= PM_CTL_WUPS_ED_; val |= PM_CTL_WUPS_ED_;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing PM_CTRL\n");
return ret; return ret;
}
/* read back PM_CTRL */ /* read back PM_CTRL */
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val);
if (ret < 0)
netdev_warn(dev->net, "Error reading PM_CTRL\n");
return ret; return ret;
} }
...@@ -1360,10 +1261,8 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) ...@@ -1360,10 +1261,8 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev)
/* enable energy detect power-down mode */ /* enable energy detect power-down mode */
ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS); ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PHY_MODE_CTRL_STS\n");
return ret; return ret;
}
ret |= MODE_CTRL_STS_EDPWRDOWN_; ret |= MODE_CTRL_STS_EDPWRDOWN_;
...@@ -1371,27 +1270,21 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) ...@@ -1371,27 +1270,21 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev)
/* enter SUSPEND1 mode */ /* enter SUSPEND1 mode */
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PM_CTRL\n");
return ret; return ret;
}
val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_);
val |= PM_CTL_SUS_MODE_1; val |= PM_CTL_SUS_MODE_1;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing PM_CTRL\n");
return ret; return ret;
}
/* clear wol status, enable energy detection */ /* clear wol status, enable energy detection */
val &= ~PM_CTL_WUPS_; val &= ~PM_CTL_WUPS_;
val |= (PM_CTL_WUPS_ED_ | PM_CTL_ED_EN_); val |= (PM_CTL_WUPS_ED_ | PM_CTL_ED_EN_);
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val);
if (ret < 0)
netdev_warn(dev->net, "Error writing PM_CTRL\n");
return ret; return ret;
} }
...@@ -1402,17 +1295,13 @@ static int smsc95xx_enter_suspend2(struct usbnet *dev) ...@@ -1402,17 +1295,13 @@ static int smsc95xx_enter_suspend2(struct usbnet *dev)
int ret; int ret;
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PM_CTRL\n");
return ret; return ret;
}
val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_);
val |= PM_CTL_SUS_MODE_2; val |= PM_CTL_SUS_MODE_2;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val);
if (ret < 0)
netdev_warn(dev->net, "Error writing PM_CTRL\n");
return ret; return ret;
} }
...@@ -1442,32 +1331,24 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1442,32 +1331,24 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
/* disable energy detect (link up) & wake up events */ /* disable energy detect (link up) & wake up events */
ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading WUCSR\n");
goto done; goto done;
}
val &= ~(WUCSR_MPEN_ | WUCSR_WAKE_EN_); val &= ~(WUCSR_MPEN_ | WUCSR_WAKE_EN_);
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg_nopm(dev, WUCSR, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing WUCSR\n");
goto done; goto done;
}
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PM_CTRL\n");
goto done; goto done;
}
val &= ~(PM_CTL_ED_EN_ | PM_CTL_WOL_EN_); val &= ~(PM_CTL_ED_EN_ | PM_CTL_WOL_EN_);
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing PM_CTRL\n");
goto done; goto done;
}
ret = smsc95xx_enter_suspend2(dev); ret = smsc95xx_enter_suspend2(dev);
goto done; goto done;
...@@ -1565,7 +1446,6 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1565,7 +1446,6 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
for (i = 0; i < (wuff_filter_count * 4); i++) { for (i = 0; i < (wuff_filter_count * 4); i++) {
ret = smsc95xx_write_reg_nopm(dev, WUFF, filter_mask[i]); ret = smsc95xx_write_reg_nopm(dev, WUFF, filter_mask[i]);
if (ret < 0) { if (ret < 0) {
netdev_warn(dev->net, "Error writing WUFF\n");
kfree(filter_mask); kfree(filter_mask);
goto done; goto done;
} }
...@@ -1574,67 +1454,51 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1574,67 +1454,51 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
for (i = 0; i < (wuff_filter_count / 4); i++) { for (i = 0; i < (wuff_filter_count / 4); i++) {
ret = smsc95xx_write_reg_nopm(dev, WUFF, command[i]); ret = smsc95xx_write_reg_nopm(dev, WUFF, command[i]);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing WUFF\n");
goto done; goto done;
} }
}
for (i = 0; i < (wuff_filter_count / 4); i++) { for (i = 0; i < (wuff_filter_count / 4); i++) {
ret = smsc95xx_write_reg_nopm(dev, WUFF, offset[i]); ret = smsc95xx_write_reg_nopm(dev, WUFF, offset[i]);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing WUFF\n");
goto done; goto done;
} }
}
for (i = 0; i < (wuff_filter_count / 2); i++) { for (i = 0; i < (wuff_filter_count / 2); i++) {
ret = smsc95xx_write_reg_nopm(dev, WUFF, crc[i]); ret = smsc95xx_write_reg_nopm(dev, WUFF, crc[i]);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing WUFF\n");
goto done; goto done;
} }
}
/* clear any pending pattern match packet status */ /* clear any pending pattern match packet status */
ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading WUCSR\n");
goto done; goto done;
}
val |= WUCSR_WUFR_; val |= WUCSR_WUFR_;
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg_nopm(dev, WUCSR, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing WUCSR\n");
goto done; goto done;
} }
}
if (pdata->wolopts & WAKE_MAGIC) { if (pdata->wolopts & WAKE_MAGIC) {
/* clear any pending magic packet status */ /* clear any pending magic packet status */
ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading WUCSR\n");
goto done; goto done;
}
val |= WUCSR_MPR_; val |= WUCSR_MPR_;
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg_nopm(dev, WUCSR, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing WUCSR\n");
goto done; goto done;
} }
}
/* enable/disable wakeup sources */ /* enable/disable wakeup sources */
ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading WUCSR\n");
goto done; goto done;
}
if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) {
netdev_info(dev->net, "enabling pattern match wakeup\n"); netdev_info(dev->net, "enabling pattern match wakeup\n");
...@@ -1653,17 +1517,13 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1653,17 +1517,13 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
} }
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg_nopm(dev, WUCSR, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing WUCSR\n");
goto done; goto done;
}
/* enable wol wakeup source */ /* enable wol wakeup source */
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PM_CTRL\n");
goto done; goto done;
}
val |= PM_CTL_WOL_EN_; val |= PM_CTL_WOL_EN_;
...@@ -1672,10 +1532,8 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1672,10 +1532,8 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
val |= PM_CTL_ED_EN_; val |= PM_CTL_ED_EN_;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing PM_CTRL\n");
goto done; goto done;
}
/* enable receiver to enable frame reception */ /* enable receiver to enable frame reception */
smsc95xx_start_rx_path(dev, 1); smsc95xx_start_rx_path(dev, 1);
...@@ -1702,35 +1560,27 @@ static int smsc95xx_resume(struct usb_interface *intf) ...@@ -1702,35 +1560,27 @@ static int smsc95xx_resume(struct usb_interface *intf)
if (pdata->wolopts) { if (pdata->wolopts) {
/* clear wake-up sources */ /* clear wake-up sources */
ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading WUCSR\n");
return ret; return ret;
}
val &= ~(WUCSR_WAKE_EN_ | WUCSR_MPEN_); val &= ~(WUCSR_WAKE_EN_ | WUCSR_MPEN_);
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg_nopm(dev, WUCSR, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing WUCSR\n");
return ret; return ret;
}
/* clear wake-up status */ /* clear wake-up status */
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error reading PM_CTRL\n");
return ret; return ret;
}
val &= ~PM_CTL_WOL_EN_; val &= ~PM_CTL_WOL_EN_;
val |= PM_CTL_WUPS_; val |= PM_CTL_WUPS_;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val);
if (ret < 0) { if (ret < 0)
netdev_warn(dev->net, "Error writing PM_CTRL\n");
return ret; return ret;
} }
}
ret = usbnet_resume(intf); ret = usbnet_resume(intf);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment