* [07/19] usbnet: smsc95xx: Split the reset function
@ 2019-01-03 1:10 Marek Vasut
0 siblings, 0 replies; 2+ messages in thread
From: Marek Vasut @ 2019-01-03 1:10 UTC (permalink / raw)
To: netdev
Cc: Marek Vasut, David S . Miller, Nisar Sayed, Woojung Huh,
Andrew Lunn, Florian Fainelli, linux-usb
The smsc95xx_reset() is called either during bind or later during
the driver operation. However, the MII structure can be populated
only once, when the smsc95xx_reset() is called from the drivers
bind function.
Split the reset function to allow filling the MII structure only
once. This is done in preparation of phydev conversion, where the
code will connect to PHY between those two halves of the reset
function.
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 | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 551d05eb258e..e40cde490a42 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -944,14 +944,6 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
{
int bmcr, ret, timeout = 0;
- /* Initialize MII structure */
- dev->mii.dev = dev->net;
- dev->mii.mdio_read = smsc95xx_mdio_read;
- dev->mii.mdio_write = smsc95xx_mdio_write;
- dev->mii.phy_id_mask = 0x1f;
- dev->mii.reg_num_mask = 0x1f;
- dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID;
-
/* reset phy and wait for reset to complete */
smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
@@ -985,7 +977,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
return 0;
}
-static int smsc95xx_reset(struct usbnet *dev)
+static int smsc95xx_reset_pre(struct usbnet *dev)
{
struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
u32 read_buf, write_buf, burst_cap;
@@ -1165,6 +1157,13 @@ static int smsc95xx_reset(struct usbnet *dev)
}
smsc95xx_set_multicast(dev->net);
+ return 0;
+}
+
+static int smsc95xx_reset_post(struct usbnet *dev)
+{
+ u32 read_buf;
+ int ret;
ret = smsc95xx_phy_initialize(dev);
if (ret < 0) {
@@ -1199,6 +1198,25 @@ static int smsc95xx_reset(struct usbnet *dev)
return 0;
}
+static int smsc95xx_reset(struct usbnet *dev)
+{
+ int ret;
+
+ ret = smsc95xx_reset_pre(dev);
+ if (ret)
+ return ret;
+
+ /* Initialize MII structure */
+ dev->mii.dev = dev->net;
+ dev->mii.mdio_read = smsc95xx_mdio_read;
+ dev->mii.mdio_write = smsc95xx_mdio_write;
+ dev->mii.phy_id_mask = 0x1f;
+ dev->mii.reg_num_mask = 0x1f;
+ dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID;
+
+ return smsc95xx_reset_post(dev);
+}
+
static const struct net_device_ops smsc95xx_netdev_ops = {
.ndo_open = usbnet_open,
.ndo_stop = usbnet_stop,
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [07/19] usbnet: smsc95xx: Split the reset function
@ 2019-01-07 11:05 Oliver Neukum
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Neukum @ 2019-01-07 11:05 UTC (permalink / raw)
To: Marek Vasut, netdev
Cc: David S . Miller, Florian Fainelli, Andrew Lunn, Nisar Sayed,
Woojung Huh, linux-usb
On Do, 2019-01-03 at 02:10 +0100, Marek Vasut wrote:
> The smsc95xx_reset() is called either during bind or later during
> the driver operation. However, the MII structure can be populated
> only once, when the smsc95xx_reset() is called from the drivers
> bind function.
>
> Split the reset function to allow filling the MII structure only
> once. This is done in preparation of phydev conversion, where the
> code will connect to PHY between those two halves of the reset
> function.
>
> 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 | 36 +++++++++++++++++++++++++++---------
> 1 file changed, 27 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
> index 551d05eb258e..e40cde490a42 100644
> --- a/drivers/net/usb/smsc95xx.c
> +++ b/drivers/net/usb/smsc95xx.c
> @@ -944,14 +944,6 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
> {
> int bmcr, ret, timeout = 0;
>
> - /* Initialize MII structure */
> - dev->mii.dev = dev->net;
> - dev->mii.mdio_read = smsc95xx_mdio_read;
> - dev->mii.mdio_write = smsc95xx_mdio_write;
> - dev->mii.phy_id_mask = 0x1f;
> - dev->mii.reg_num_mask = 0x1f;
> - dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID;
> -
> /* reset phy and wait for reset to complete */
> smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
>
> @@ -985,7 +977,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
> return 0;
> }
>
> -static int smsc95xx_reset(struct usbnet *dev)
> +static int smsc95xx_reset_pre(struct usbnet *dev)
Hi,
may I request that you choose different names? These names suggest a
connection with the pre_reset() and post_reset() methods of a USB
driver.
Regards
Oliver
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-07 11:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-07 11:05 [07/19] usbnet: smsc95xx: Split the reset function Oliver Neukum
-- strict thread matches above, loose matches on Subject: below --
2019-01-03 1:10 Marek Vasut
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).