Commit 31472429 authored by Lukas Wunner's avatar Lukas Wunner Committed by David S. Miller

usbnet: smsc95xx: Clean up nopm handling

The LAN95xx driver has just been amended to auto-detect whether the
_nopm variant of usbnet_read_cmd() / usbnet_write_cmd() shall be used.

Drop all the now unnecessary open coding of that distinction.
Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7b960c96
...@@ -78,8 +78,8 @@ static bool turbo_mode = true; ...@@ -78,8 +78,8 @@ static bool turbo_mode = true;
module_param(turbo_mode, bool, 0644); module_param(turbo_mode, bool, 0644);
MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index,
u32 *data, int in_pm) u32 *data)
{ {
struct smsc95xx_priv *pdata = dev->driver_priv; struct smsc95xx_priv *pdata = dev->driver_priv;
u32 buf; u32 buf;
...@@ -109,8 +109,8 @@ static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, ...@@ -109,8 +109,8 @@ static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,
return ret; return ret;
} }
static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index,
u32 data, int in_pm) u32 data)
{ {
struct smsc95xx_priv *pdata = dev->driver_priv; struct smsc95xx_priv *pdata = dev->driver_priv;
u32 buf; u32 buf;
...@@ -137,41 +137,16 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, ...@@ -137,41 +137,16 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index,
return ret; return ret;
} }
static int __must_check smsc95xx_read_reg_nopm(struct usbnet *dev, u32 index,
u32 *data)
{
return __smsc95xx_read_reg(dev, index, data, 1);
}
static int __must_check smsc95xx_write_reg_nopm(struct usbnet *dev, u32 index,
u32 data)
{
return __smsc95xx_write_reg(dev, index, data, 1);
}
static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index,
u32 *data)
{
return __smsc95xx_read_reg(dev, index, data, 0);
}
static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index,
u32 data)
{
return __smsc95xx_write_reg(dev, index, data, 0);
}
/* Loop until the read is completed with timeout /* Loop until the read is completed with timeout
* called with phy_mutex held */ * called with phy_mutex held */
static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev, static int __must_check smsc95xx_phy_wait_not_busy(struct usbnet *dev)
int in_pm)
{ {
unsigned long start_time = jiffies; unsigned long start_time = jiffies;
u32 val; u32 val;
int ret; int ret;
do { do {
ret = __smsc95xx_read_reg(dev, MII_ADDR, &val, in_pm); ret = smsc95xx_read_reg(dev, MII_ADDR, &val);
if (ret < 0) { if (ret < 0) {
/* Ignore -ENODEV error during disconnect() */ /* Ignore -ENODEV error during disconnect() */
if (ret == -ENODEV) if (ret == -ENODEV)
...@@ -192,8 +167,7 @@ static u32 mii_address_cmd(int phy_id, int idx, u16 op) ...@@ -192,8 +167,7 @@ static u32 mii_address_cmd(int phy_id, int idx, u16 op)
return (phy_id & 0x1f) << 11 | (idx & 0x1f) << 6 | op; return (phy_id & 0x1f) << 11 | (idx & 0x1f) << 6 | op;
} }
static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx, static int smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx)
int in_pm)
{ {
u32 val, addr; u32 val, addr;
int ret; int ret;
...@@ -201,7 +175,7 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx, ...@@ -201,7 +175,7 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx,
mutex_lock(&dev->phy_mutex); mutex_lock(&dev->phy_mutex);
/* confirm MII not busy */ /* confirm MII not busy */
ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); ret = smsc95xx_phy_wait_not_busy(dev);
if (ret < 0) { if (ret < 0) {
netdev_warn(dev->net, "%s: MII is busy\n", __func__); netdev_warn(dev->net, "%s: MII is busy\n", __func__);
goto done; goto done;
...@@ -209,20 +183,20 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx, ...@@ -209,20 +183,20 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx,
/* set the address, index & direction (read from PHY) */ /* set the address, index & direction (read from PHY) */
addr = mii_address_cmd(phy_id, idx, MII_READ_ | MII_BUSY_); addr = mii_address_cmd(phy_id, idx, MII_READ_ | MII_BUSY_);
ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); ret = smsc95xx_write_reg(dev, MII_ADDR, addr);
if (ret < 0) { if (ret < 0) {
if (ret != -ENODEV) if (ret != -ENODEV)
netdev_warn(dev->net, "Error writing MII_ADDR\n"); netdev_warn(dev->net, "Error writing MII_ADDR\n");
goto done; goto done;
} }
ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); ret = smsc95xx_phy_wait_not_busy(dev);
if (ret < 0) { if (ret < 0) {
netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx); netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx);
goto done; goto done;
} }
ret = __smsc95xx_read_reg(dev, MII_DATA, &val, in_pm); ret = smsc95xx_read_reg(dev, MII_DATA, &val);
if (ret < 0) { if (ret < 0) {
if (ret != -ENODEV) if (ret != -ENODEV)
netdev_warn(dev->net, "Error reading MII_DATA\n"); netdev_warn(dev->net, "Error reading MII_DATA\n");
...@@ -240,8 +214,8 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx, ...@@ -240,8 +214,8 @@ static int __smsc95xx_mdio_read(struct usbnet *dev, int phy_id, int idx,
return ret; return ret;
} }
static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id, static void smsc95xx_mdio_write(struct usbnet *dev, int phy_id, int idx,
int idx, int regval, int in_pm) int regval)
{ {
u32 val, addr; u32 val, addr;
int ret; int ret;
...@@ -249,14 +223,14 @@ static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id, ...@@ -249,14 +223,14 @@ static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id,
mutex_lock(&dev->phy_mutex); mutex_lock(&dev->phy_mutex);
/* confirm MII not busy */ /* confirm MII not busy */
ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); ret = smsc95xx_phy_wait_not_busy(dev);
if (ret < 0) { if (ret < 0) {
netdev_warn(dev->net, "%s: MII is busy\n", __func__); netdev_warn(dev->net, "%s: MII is busy\n", __func__);
goto done; goto done;
} }
val = regval; val = regval;
ret = __smsc95xx_write_reg(dev, MII_DATA, val, in_pm); ret = smsc95xx_write_reg(dev, MII_DATA, val);
if (ret < 0) { if (ret < 0) {
if (ret != -ENODEV) if (ret != -ENODEV)
netdev_warn(dev->net, "Error writing MII_DATA\n"); netdev_warn(dev->net, "Error writing MII_DATA\n");
...@@ -265,14 +239,14 @@ static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id, ...@@ -265,14 +239,14 @@ static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id,
/* set the address, index & direction (write to PHY) */ /* set the address, index & direction (write to PHY) */
addr = mii_address_cmd(phy_id, idx, MII_WRITE_ | MII_BUSY_); addr = mii_address_cmd(phy_id, idx, MII_WRITE_ | MII_BUSY_);
ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); ret = smsc95xx_write_reg(dev, MII_ADDR, addr);
if (ret < 0) { if (ret < 0) {
if (ret != -ENODEV) if (ret != -ENODEV)
netdev_warn(dev->net, "Error writing MII_ADDR\n"); netdev_warn(dev->net, "Error writing MII_ADDR\n");
goto done; goto done;
} }
ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); ret = smsc95xx_phy_wait_not_busy(dev);
if (ret < 0) { if (ret < 0) {
netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx); netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx);
goto done; goto done;
...@@ -282,25 +256,11 @@ static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id, ...@@ -282,25 +256,11 @@ static void __smsc95xx_mdio_write(struct usbnet *dev, int phy_id,
mutex_unlock(&dev->phy_mutex); mutex_unlock(&dev->phy_mutex);
} }
static int smsc95xx_mdio_read_nopm(struct usbnet *dev, int idx)
{
struct smsc95xx_priv *pdata = dev->driver_priv;
return __smsc95xx_mdio_read(dev, pdata->phydev->mdio.addr, idx, 1);
}
static void smsc95xx_mdio_write_nopm(struct usbnet *dev, int idx, int regval)
{
struct smsc95xx_priv *pdata = dev->driver_priv;
__smsc95xx_mdio_write(dev, pdata->phydev->mdio.addr, idx, regval, 1);
}
static int smsc95xx_mdiobus_read(struct mii_bus *bus, int phy_id, int idx) static int smsc95xx_mdiobus_read(struct mii_bus *bus, int phy_id, int idx)
{ {
struct usbnet *dev = bus->priv; struct usbnet *dev = bus->priv;
return __smsc95xx_mdio_read(dev, phy_id, idx, 0); return smsc95xx_mdio_read(dev, phy_id, idx);
} }
static int smsc95xx_mdiobus_write(struct mii_bus *bus, int phy_id, int idx, static int smsc95xx_mdiobus_write(struct mii_bus *bus, int phy_id, int idx,
...@@ -308,7 +268,7 @@ static int smsc95xx_mdiobus_write(struct mii_bus *bus, int phy_id, int idx, ...@@ -308,7 +268,7 @@ static int smsc95xx_mdiobus_write(struct mii_bus *bus, int phy_id, int idx,
{ {
struct usbnet *dev = bus->priv; struct usbnet *dev = bus->priv;
__smsc95xx_mdio_write(dev, phy_id, idx, regval, 0); smsc95xx_mdio_write(dev, phy_id, idx, regval);
return 0; return 0;
} }
...@@ -868,7 +828,7 @@ static int smsc95xx_start_tx_path(struct usbnet *dev) ...@@ -868,7 +828,7 @@ static int smsc95xx_start_tx_path(struct usbnet *dev)
} }
/* Starts the Receive path */ /* Starts the Receive path */
static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) static int smsc95xx_start_rx_path(struct usbnet *dev)
{ {
struct smsc95xx_priv *pdata = dev->driver_priv; struct smsc95xx_priv *pdata = dev->driver_priv;
unsigned long flags; unsigned long flags;
...@@ -877,7 +837,7 @@ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) ...@@ -877,7 +837,7 @@ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm)
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);
return __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr, in_pm); return smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr);
} }
static int smsc95xx_reset(struct usbnet *dev) static int smsc95xx_reset(struct usbnet *dev)
...@@ -1060,7 +1020,7 @@ static int smsc95xx_reset(struct usbnet *dev) ...@@ -1060,7 +1020,7 @@ static int smsc95xx_reset(struct usbnet *dev)
return ret; return ret;
} }
ret = smsc95xx_start_rx_path(dev, 0); ret = smsc95xx_start_rx_path(dev);
if (ret < 0) { if (ret < 0) {
netdev_warn(dev->net, "Failed to start RX path\n"); netdev_warn(dev->net, "Failed to start RX path\n");
return ret; return ret;
...@@ -1294,16 +1254,17 @@ static u32 smsc_crc(const u8 *buffer, size_t len, int filter) ...@@ -1294,16 +1254,17 @@ static u32 smsc_crc(const u8 *buffer, size_t len, int filter)
return crc << ((filter % 2) * 16); return crc << ((filter % 2) * 16);
} }
static int smsc95xx_link_ok_nopm(struct usbnet *dev) static int smsc95xx_link_ok(struct usbnet *dev)
{ {
struct smsc95xx_priv *pdata = dev->driver_priv;
int ret; int ret;
/* 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, MII_BMSR); ret = smsc95xx_mdio_read(dev, pdata->phydev->mdio.addr, MII_BMSR);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = smsc95xx_mdio_read_nopm(dev, MII_BMSR); ret = smsc95xx_mdio_read(dev, pdata->phydev->mdio.addr, MII_BMSR);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1316,14 +1277,14 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) ...@@ -1316,14 +1277,14 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev)
u32 val; u32 val;
int ret; int ret;
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
if (ret < 0) if (ret < 0)
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(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1335,12 +1296,12 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) ...@@ -1335,12 +1296,12 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev)
if (pdata->wolopts & WAKE_PHY) if (pdata->wolopts & WAKE_PHY)
val |= PM_CTL_WUPS_ED_; val |= PM_CTL_WUPS_ED_;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
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(dev, PM_CTRL, &val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1352,34 +1313,34 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) ...@@ -1352,34 +1313,34 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev)
static int smsc95xx_enter_suspend1(struct usbnet *dev) static int smsc95xx_enter_suspend1(struct usbnet *dev)
{ {
struct smsc95xx_priv *pdata = dev->driver_priv; struct smsc95xx_priv *pdata = dev->driver_priv;
int ret, phy_id = pdata->phydev->mdio.addr;
u32 val; u32 val;
int ret;
/* reconfigure link pulse detection timing for /* reconfigure link pulse detection timing for
* compatibility with non-standard link partners * compatibility with non-standard link partners
*/ */
if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) if (pdata->features & FEATURE_PHY_NLP_CROSSOVER)
smsc95xx_mdio_write_nopm(dev, PHY_EDPD_CONFIG, smsc95xx_mdio_write(dev, phy_id, PHY_EDPD_CONFIG,
PHY_EDPD_CONFIG_DEFAULT); PHY_EDPD_CONFIG_DEFAULT);
/* enable energy detect power-down mode */ /* enable energy detect power-down mode */
ret = smsc95xx_mdio_read_nopm(dev, PHY_MODE_CTRL_STS); ret = smsc95xx_mdio_read(dev, phy_id, PHY_MODE_CTRL_STS);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret |= MODE_CTRL_STS_EDPWRDOWN_; ret |= MODE_CTRL_STS_EDPWRDOWN_;
smsc95xx_mdio_write_nopm(dev, PHY_MODE_CTRL_STS, ret); smsc95xx_mdio_write(dev, phy_id, PHY_MODE_CTRL_STS, ret);
/* enter SUSPEND1 mode */ /* enter SUSPEND1 mode */
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
if (ret < 0) if (ret < 0)
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(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1387,7 +1348,7 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) ...@@ -1387,7 +1348,7 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev)
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(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1402,14 +1363,14 @@ static int smsc95xx_enter_suspend2(struct usbnet *dev) ...@@ -1402,14 +1363,14 @@ static int smsc95xx_enter_suspend2(struct usbnet *dev)
u32 val; u32 val;
int ret; int ret;
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
if (ret < 0) if (ret < 0)
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(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1424,7 +1385,7 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev) ...@@ -1424,7 +1385,7 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev)
u32 val; u32 val;
int ret; int ret;
ret = smsc95xx_read_reg_nopm(dev, RX_FIFO_INF, &val); ret = smsc95xx_read_reg(dev, RX_FIFO_INF, &val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1433,14 +1394,14 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev) ...@@ -1433,14 +1394,14 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev)
return -EBUSY; return -EBUSY;
} }
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
if (ret < 0) if (ret < 0)
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_3 | PM_CTL_RES_CLR_WKP_STS; val |= PM_CTL_SUS_MODE_3 | PM_CTL_RES_CLR_WKP_STS;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1448,7 +1409,7 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev) ...@@ -1448,7 +1409,7 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev)
val &= ~PM_CTL_WUPS_; val &= ~PM_CTL_WUPS_;
val |= PM_CTL_WUPS_WOL_; val |= PM_CTL_WUPS_WOL_;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1507,8 +1468,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1507,8 +1468,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
pdata->suspend_flags = 0; pdata->suspend_flags = 0;
} }
/* determine if link is up using only _nopm functions */ link_up = smsc95xx_link_ok(dev);
link_up = smsc95xx_link_ok_nopm(dev);
if (message.event == PM_EVENT_AUTO_SUSPEND && if (message.event == PM_EVENT_AUTO_SUSPEND &&
(pdata->features & FEATURE_REMOTE_WAKEUP)) { (pdata->features & FEATURE_REMOTE_WAKEUP)) {
...@@ -1525,23 +1485,23 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1525,23 +1485,23 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
netdev_info(dev->net, "entering SUSPEND2 mode\n"); netdev_info(dev->net, "entering SUSPEND2 mode\n");
/* 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(dev, WUCSR, &val);
if (ret < 0) if (ret < 0)
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(dev, WUCSR, val);
if (ret < 0) if (ret < 0)
goto done; goto done;
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
if (ret < 0) if (ret < 0)
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(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
goto done; goto done;
...@@ -1632,7 +1592,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1632,7 +1592,7 @@ 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(dev, WUFF, filter_mask[i]);
if (ret < 0) { if (ret < 0) {
kfree(filter_mask); kfree(filter_mask);
goto done; goto done;
...@@ -1641,50 +1601,50 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1641,50 +1601,50 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
kfree(filter_mask); kfree(filter_mask);
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(dev, WUFF, command[i]);
if (ret < 0) if (ret < 0)
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(dev, WUFF, offset[i]);
if (ret < 0) if (ret < 0)
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(dev, WUFF, crc[i]);
if (ret < 0) if (ret < 0)
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(dev, WUCSR, &val);
if (ret < 0) if (ret < 0)
goto done; goto done;
val |= WUCSR_WUFR_; val |= WUCSR_WUFR_;
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg(dev, WUCSR, val);
if (ret < 0) if (ret < 0)
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(dev, WUCSR, &val);
if (ret < 0) if (ret < 0)
goto done; goto done;
val |= WUCSR_MPR_; val |= WUCSR_MPR_;
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg(dev, WUCSR, val);
if (ret < 0) if (ret < 0)
goto done; goto done;
} }
/* enable/disable wakeup sources */ /* enable/disable wakeup sources */
ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ret = smsc95xx_read_reg(dev, WUCSR, &val);
if (ret < 0) if (ret < 0)
goto done; goto done;
...@@ -1704,12 +1664,12 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1704,12 +1664,12 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
val &= ~WUCSR_MPEN_; val &= ~WUCSR_MPEN_;
} }
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg(dev, WUCSR, val);
if (ret < 0) if (ret < 0)
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(dev, PM_CTRL, &val);
if (ret < 0) if (ret < 0)
goto done; goto done;
...@@ -1719,12 +1679,12 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -1719,12 +1679,12 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
if (pdata->wolopts & WAKE_PHY) if (pdata->wolopts & WAKE_PHY)
val |= PM_CTL_ED_EN_; val |= PM_CTL_ED_EN_;
ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ret = smsc95xx_write_reg(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
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);
/* some wol options are enabled, so enter SUSPEND0 */ /* some wol options are enabled, so enter SUSPEND0 */
netdev_info(dev->net, "entering SUSPEND0 mode\n"); netdev_info(dev->net, "entering SUSPEND0 mode\n");
...@@ -1763,25 +1723,25 @@ static int smsc95xx_resume(struct usb_interface *intf) ...@@ -1763,25 +1723,25 @@ static int smsc95xx_resume(struct usb_interface *intf)
if (suspend_flags & SUSPEND_ALLMODES) { if (suspend_flags & SUSPEND_ALLMODES) {
/* clear wake-up sources */ /* clear wake-up sources */
ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ret = smsc95xx_read_reg(dev, WUCSR, &val);
if (ret < 0) if (ret < 0)
goto done; goto done;
val &= ~(WUCSR_WAKE_EN_ | WUCSR_MPEN_); val &= ~(WUCSR_WAKE_EN_ | WUCSR_MPEN_);
ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ret = smsc95xx_write_reg(dev, WUCSR, val);
if (ret < 0) if (ret < 0)
goto done; goto done;
/* clear wake-up status */ /* clear wake-up status */
ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
if (ret < 0) if (ret < 0)
goto done; goto done;
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(dev, PM_CTRL, val);
if (ret < 0) if (ret < 0)
goto done; goto done;
} }
......
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