From: Marek Vasut <marex@denx.de>
To: netdev@vger.kernel.org
Cc: Marek Vasut <marex@denx.de>,
"David S . Miller" <davem@davemloft.net>,
Nisar Sayed <Nisar.Sayed@microchip.com>,
Woojung Huh <Woojung.Huh@microchip.com>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
linux-usb@vger.kernel.org
Subject: [PATCH 02/19] usbnet: smsc95xx: Stop propagation of in_pm
Date: Thu, 3 Jan 2019 02:10:23 +0100 [thread overview]
Message-ID: <20190103011040.25974-3-marex@denx.de> (raw)
In-Reply-To: <20190103011040.25974-1-marex@denx.de>
The information whether the SMSC95xx is in_pm or not can be derived from
the usbdev->suspend_count. First thing called in smsc95xx_suspend() is
usbnet_suspend(), which increments the usbdev->suspend_count and since
then the driver only calls _nopm() functions and functions with in_pm
set to 1. The smsc95xx_resume() does the inverse, it calls functions
with _nopm() suffix and with in_pm set to 1 until usbnet_resume(), which
sets the usbdev->suspend_count to 0.
Thus, this patch replaces all the in_pm variables used throughout the
driver with simple call to smsc95xx_in_pm(), which checks whether the
usbdev->suspend_count is zero or not.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Nisar Sayed <Nisar.Sayed@microchip.com>
Cc: Woojung Huh <Woojung.Huh@microchip.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-usb@vger.kernel.org
To: netdev@vger.kernel.org
---
drivers/net/usb/smsc95xx.c | 63 ++++++++++++++++++++------------------
1 file changed, 33 insertions(+), 30 deletions(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 772429c17ae1..c74183b51d5b 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -82,8 +82,13 @@ static bool turbo_mode = true;
module_param(turbo_mode, bool, 0644);
MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
+static int smsc95xx_in_pm(struct usbnet *dev)
+{
+ return dev->suspend_count != 0;
+}
+
static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,
- u32 *data, int in_pm)
+ u32 *data)
{
u32 buf;
int ret;
@@ -91,7 +96,7 @@ static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,
BUG_ON(!dev);
- if (!in_pm)
+ if (!smsc95xx_in_pm(dev))
fn = usbnet_read_cmd;
else
fn = usbnet_read_cmd_nopm;
@@ -112,7 +117,7 @@ static int __must_check __smsc95xx_read_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)
{
u32 buf;
int ret;
@@ -120,7 +125,7 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index,
BUG_ON(!dev);
- if (!in_pm)
+ if (!smsc95xx_in_pm(dev))
fn = usbnet_write_cmd;
else
fn = usbnet_write_cmd_nopm;
@@ -141,38 +146,37 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index,
static int __must_check smsc95xx_read_reg_nopm(struct usbnet *dev, u32 index,
u32 *data)
{
- return __smsc95xx_read_reg(dev, index, data, 1);
+ return __smsc95xx_read_reg(dev, index, data);
}
static int __must_check smsc95xx_write_reg_nopm(struct usbnet *dev, u32 index,
u32 data)
{
- return __smsc95xx_write_reg(dev, index, data, 1);
+ return __smsc95xx_write_reg(dev, index, data);
}
static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index,
u32 *data)
{
- return __smsc95xx_read_reg(dev, index, data, 0);
+ return __smsc95xx_read_reg(dev, index, data);
}
static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index,
u32 data)
{
- return __smsc95xx_write_reg(dev, index, data, 0);
+ return __smsc95xx_write_reg(dev, index, data);
}
/* Loop until the read is completed with timeout
* called with phy_mutex held */
-static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev,
- int in_pm)
+static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev)
{
unsigned long start_time = jiffies;
u32 val;
int ret;
do {
- ret = __smsc95xx_read_reg(dev, MII_ADDR, &val, in_pm);
+ ret = __smsc95xx_read_reg(dev, MII_ADDR, &val);
if (ret < 0) {
netdev_warn(dev->net, "Error reading MII_ACCESS\n");
return ret;
@@ -185,8 +189,7 @@ static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev,
return -EIO;
}
-static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx,
- int in_pm)
+static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx)
{
struct usbnet *dev = netdev_priv(netdev);
u32 val, addr;
@@ -195,7 +198,7 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx,
mutex_lock(&dev->phy_mutex);
/* confirm MII not busy */
- ret = __smsc95xx_phy_wait_not_busy(dev, in_pm);
+ ret = __smsc95xx_phy_wait_not_busy(dev);
if (ret < 0) {
netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_read\n");
goto done;
@@ -205,19 +208,19 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx,
phy_id &= dev->mii.phy_id_mask;
idx &= dev->mii.reg_num_mask;
addr = (phy_id << 11) | (idx << 6) | 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) {
netdev_warn(dev->net, "Error writing MII_ADDR\n");
goto done;
}
- ret = __smsc95xx_phy_wait_not_busy(dev, in_pm);
+ ret = __smsc95xx_phy_wait_not_busy(dev);
if (ret < 0) {
netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx);
goto done;
}
- ret = __smsc95xx_read_reg(dev, MII_DATA, &val, in_pm);
+ ret = __smsc95xx_read_reg(dev, MII_DATA, &val);
if (ret < 0) {
netdev_warn(dev->net, "Error reading MII_DATA\n");
goto done;
@@ -231,7 +234,7 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx,
}
static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id,
- int idx, int regval, int in_pm)
+ int idx, int regval)
{
struct usbnet *dev = netdev_priv(netdev);
u32 val, addr;
@@ -240,14 +243,14 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id,
mutex_lock(&dev->phy_mutex);
/* confirm MII not busy */
- ret = __smsc95xx_phy_wait_not_busy(dev, in_pm);
+ ret = __smsc95xx_phy_wait_not_busy(dev);
if (ret < 0) {
netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_write\n");
goto done;
}
val = regval;
- ret = __smsc95xx_write_reg(dev, MII_DATA, val, in_pm);
+ ret = __smsc95xx_write_reg(dev, MII_DATA, val);
if (ret < 0) {
netdev_warn(dev->net, "Error writing MII_DATA\n");
goto done;
@@ -257,13 +260,13 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id,
phy_id &= dev->mii.phy_id_mask;
idx &= dev->mii.reg_num_mask;
addr = (phy_id << 11) | (idx << 6) | 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) {
netdev_warn(dev->net, "Error writing MII_ADDR\n");
goto done;
}
- ret = __smsc95xx_phy_wait_not_busy(dev, in_pm);
+ ret = __smsc95xx_phy_wait_not_busy(dev);
if (ret < 0) {
netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx);
goto done;
@@ -276,24 +279,24 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id,
static int smsc95xx_mdio_read_nopm(struct net_device *netdev, int phy_id,
int idx)
{
- return __smsc95xx_mdio_read(netdev, phy_id, idx, 1);
+ return __smsc95xx_mdio_read(netdev, phy_id, idx);
}
static void smsc95xx_mdio_write_nopm(struct net_device *netdev, int phy_id,
int idx, int regval)
{
- __smsc95xx_mdio_write(netdev, phy_id, idx, regval, 1);
+ __smsc95xx_mdio_write(netdev, phy_id, idx, regval);
}
static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx)
{
- return __smsc95xx_mdio_read(netdev, phy_id, idx, 0);
+ return __smsc95xx_mdio_read(netdev, phy_id, idx);
}
static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx,
int regval)
{
- __smsc95xx_mdio_write(netdev, phy_id, idx, regval, 0);
+ __smsc95xx_mdio_write(netdev, phy_id, idx, regval);
}
static int __must_check smsc95xx_wait_eeprom(struct usbnet *dev)
@@ -972,7 +975,7 @@ static int smsc95xx_start_tx_path(struct usbnet *dev)
}
/* 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 = (struct smsc95xx_priv *)(dev->data[0]);
unsigned long flags;
@@ -981,7 +984,7 @@ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm)
pdata->mac_cr |= MAC_CR_RXEN_;
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_phy_initialize(struct usbnet *dev)
@@ -1233,7 +1236,7 @@ static int smsc95xx_reset(struct usbnet *dev)
return ret;
}
- ret = smsc95xx_start_rx_path(dev, 0);
+ ret = smsc95xx_start_rx_path(dev);
if (ret < 0) {
netdev_warn(dev->net, "Failed to start RX path\n");
return ret;
@@ -1833,7 +1836,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
goto done;
/* 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 */
netdev_info(dev->net, "entering SUSPEND0 mode\n");
--
2.19.2
next prev parent reply other threads:[~2019-01-03 1:11 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-03 1:10 [PATCH 00/19] usbnet: smsc95xx: Convert to phydev Marek Vasut
2019-01-03 1:10 ` [PATCH 01/19] usbnet: smsc95xx: Fix memory leak in smsc95xx_bind Marek Vasut
2019-01-03 1:10 ` Marek Vasut [this message]
2019-01-07 11:02 ` [PATCH 02/19] usbnet: smsc95xx: Stop propagation of in_pm Oliver Neukum
2019-01-07 11:50 ` Marek Vasut
2019-01-03 1:10 ` [PATCH 03/19] usbnet: smsc95xx: Remove smsc95xx_{read,write}_reg_nopm() Marek Vasut
2019-01-03 1:10 ` [PATCH 04/19] usbnet: smsc95xx: Remove __smsc95xx_{read,write}_reg() Marek Vasut
2019-01-03 1:10 ` [PATCH 05/19] usbnet: smsc95xx: Remove smsc95xx_{read,write}_nopm() Marek Vasut
2019-01-03 1:10 ` [PATCH 06/19] usbnet: smsc95xx: Remove __smsc95xx_mdio_{read,write}() Marek Vasut
2019-01-03 1:10 ` [PATCH 07/19] usbnet: smsc95xx: Split the reset function Marek Vasut
2019-01-07 11:05 ` Oliver Neukum
2019-01-03 1:10 ` [PATCH 08/19] usbnet: smsc95xx: Register MII bus Marek Vasut
2019-01-03 1:10 ` [PATCH 09/19] usbnet: smsc95xx: Connect to phydev Marek Vasut
2019-01-03 13:22 ` Andrew Lunn
2019-01-04 2:18 ` Marek Vasut
2019-01-03 1:10 ` [PATCH 10/19] usbnet: smsc95xx: Replace smsc95xx_mdio_read() with phy_read() Marek Vasut
2019-01-03 13:39 ` Andrew Lunn
2019-01-04 2:19 ` Marek Vasut
2019-01-04 13:24 ` Andrew Lunn
2019-01-04 14:58 ` Marek Vasut
2019-01-04 15:57 ` Andrew Lunn
2019-01-04 18:02 ` Heiner Kallweit
2019-01-03 1:10 ` [PATCH 11/19] usbnet: smsc95xx: Replace smsc95xx_mdio_write() with phy_write() Marek Vasut
2019-01-03 1:10 ` [PATCH 12/19] usbnet: smsc95xx: Replace ad-hoc PHY functions with generic ones Marek Vasut
2019-01-03 13:28 ` Andrew Lunn
2019-01-04 2:19 ` Marek Vasut
2019-01-03 1:10 ` [PATCH 13/19] usbnet: smsc95xx: Replace smsc95xx_link_ok_nopm() Marek Vasut
2019-01-03 1:10 ` [PATCH 14/19] usbnet: smsc95xx: Replace mii_nway_restart() Marek Vasut
2019-01-03 1:10 ` [PATCH 15/19] usbnet: smsc95xx: Replace mii_ethtool_gset() Marek Vasut
2019-01-03 1:10 ` [PATCH 16/19] usbnet: smsc95xx: Replace mii_check_media() Marek Vasut
2019-01-03 1:10 ` [PATCH 17/19] usbnet: smsc95xx: Replace generic_mii_ioctl() Marek Vasut
2019-01-03 1:10 ` [PATCH 18/19] usbnet: smsc95xx: Remove all of the carrier checking code Marek Vasut
2019-01-03 1:10 ` [PATCH 19/19] usbnet: smsc95xx: Use phy bit operations Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190103011040.25974-3-marex@denx.de \
--to=marex@denx.de \
--cc=Nisar.Sayed@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).