diff mbox series

[PATCHv3,net,2/2] net: asix: init mdiobus from one function

Message ID 20230308202159.2419227-2-grundler@chromium.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [PATCHv3,net,1/2] net: asix: fix modprobe "sysfs: cannot create duplicate filename" | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 20 this patch: 20
netdev/cc_maintainers warning 4 maintainers not CCed: linux@armlinux.org.uk edumazet@google.com pabeni@redhat.com linux-usb@vger.kernel.org
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 20 this patch: 20
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 53 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Grant Grundler March 8, 2023, 8:21 p.m. UTC
Make asix driver consistent with other drivers (e.g. tg3 and r8169) which
use mdiobus calls: setup and tear down be handled in one function each.

Signed-off-by: Grant Grundler <grundler@chromium.org>
---
 drivers/net/usb/asix_devices.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

V3: rebase against netdev/net.git
    add missing whitespace around "="

Comments

Jiri Pirko March 9, 2023, 11:20 a.m. UTC | #1
Wed, Mar 08, 2023 at 09:21:59PM CET, grundler@chromium.org wrote:
>Make asix driver consistent with other drivers (e.g. tg3 and r8169) which
>use mdiobus calls: setup and tear down be handled in one function each.
>
>Signed-off-by: Grant Grundler <grundler@chromium.org>

This is not fixing a bug. You should send it separatelly to net-next.
Grant Grundler March 9, 2023, 7:05 p.m. UTC | #2
On Thu, Mar 9, 2023 at 3:20 AM Jiri Pirko <jiri@resnulli.us> wrote:
>
> Wed, Mar 08, 2023 at 09:21:59PM CET, grundler@chromium.org wrote:
> >Make asix driver consistent with other drivers (e.g. tg3 and r8169) which
> >use mdiobus calls: setup and tear down be handled in one function each.
> >
> >Signed-off-by: Grant Grundler <grundler@chromium.org>
>
> This is not fixing a bug. You should send it separatelly to net-next.

Jiro,
Thanks for reviewing both patches. Agreed that it's not fixing a bug.

The patch depends on the previous patch. It wouldn't apply on a
different branch.

I hope the maintainers can apply both to net-next and only apply the
first to net branch.

cheers,
grant
Andrew Lunn March 9, 2023, 7:30 p.m. UTC | #3
> I hope the maintainers can apply both to net-next and only apply the
> first to net branch.

Hi Grant

Please take a look at
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

Please submit the first patch to net. Then wait a week for net to be
merged into net-next, and submit the second patch to net-next.

       Andrew
Grant Grundler March 9, 2023, 7:53 p.m. UTC | #4
On Thu, Mar 9, 2023 at 11:30 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> > I hope the maintainers can apply both to net-next and only apply the
> > first to net branch.
>
> Hi Grant
>
> Please take a look at
> https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
>
> Please submit the first patch to net. Then wait a week for net to be
> merged into net-next, and submit the second patch to net-next.

Thanks Andrew!
I read maintainer-netdev.html when Jakub pointed me at it a few days
ago. He also instructed me to use "net" but didn't specify for the
second patch - so I assumed both patches.

I'll follow your instructions and repost to net-next once the first
patch has been merged.

cheers,
grant

>
>        Andrew
Jakub Kicinski March 10, 2023, 6:16 a.m. UTC | #5
On Thu, 9 Mar 2023 11:53:54 -0800 Grant Grundler wrote:
> On Thu, Mar 9, 2023 at 11:30 AM Andrew Lunn <andrew@lunn.ch> wrote:
> > > I hope the maintainers can apply both to net-next and only apply the
> > > first to net branch.  
> >
> > Hi Grant
> >
> > Please take a look at
> > https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
> >
> > Please submit the first patch to net. Then wait a week for net to be
> > merged into net-next, and submit the second patch to net-next.  
> 
> Thanks Andrew!
> I read maintainer-netdev.html when Jakub pointed me at it a few days
> ago. He also instructed me to use "net" but didn't specify for the
> second patch - so I assumed both patches.

I did:

  Keep patch 2 locally for about a week (we merge fixes and cleanup
  branches once a week around Thu, and the two patches depend on each
  other).

https://lore.kernel.org/all/20230307164736.37ecb2f9@kernel.org/

But the process is a bit confusing. I'll take patch 1 in now, please
repost patch with net-next on/after Friday March 17th.
Jakub Kicinski March 10, 2023, 6:29 a.m. UTC | #6
On Thu, 9 Mar 2023 22:16:46 -0800 Jakub Kicinski wrote:
>  I'll take patch 1 in now,

Sorry, I need to take that back.

Don't the error paths in ax88772_bind() need to be updated to call
ax88772_mdio_unregister() now?
diff mbox series

Patch

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 538c84909913..9a1e54ef4ff0 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -663,7 +663,7 @@  static int asix_resume(struct usb_interface *intf)
 	return usbnet_resume(intf);
 }
 
-static int ax88772_init_mdio(struct usbnet *dev)
+static int ax88772_mdio_register(struct usbnet *dev)
 {
 	struct asix_common_private *priv = dev->driver_priv;
 	int ret;
@@ -683,10 +683,22 @@  static int ax88772_init_mdio(struct usbnet *dev)
 	ret = mdiobus_register(priv->mdio);
 	if (ret) {
 		netdev_err(dev->net, "Could not register MDIO bus (err %d)\n", ret);
-		mdiobus_free(priv->mdio);
-		priv->mdio = NULL;
+		goto mdio_register_err;
 	}
 
+	priv->phydev = mdiobus_get_phy(priv->mdio, priv->phy_addr);
+	if (!priv->phydev) {
+		netdev_err(dev->net, "Could not find PHY\n");
+		ret = -ENODEV;
+		goto mdio_phy_err;
+	}
+
+	return 0;
+
+mdio_phy_err:
+	mdiobus_unregister(priv->mdio);
+mdio_register_err:
+	mdiobus_free(priv->mdio);
 	return ret;
 }
 
@@ -701,13 +713,6 @@  static int ax88772_init_phy(struct usbnet *dev)
 	struct asix_common_private *priv = dev->driver_priv;
 	int ret;
 
-	priv->phydev = mdiobus_get_phy(priv->mdio, priv->phy_addr);
-	if (!priv->phydev) {
-		netdev_err(dev->net, "Could not find PHY\n");
-		ax88772_mdio_unregister(priv);
-		return -ENODEV;
-	}
-
 	ret = phylink_connect_phy(priv->phylink, priv->phydev);
 	if (ret) {
 		netdev_err(dev->net, "Could not connect PHY\n");
@@ -909,7 +914,7 @@  static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 	priv->presvd_phy_bmcr = 0;
 	priv->presvd_phy_advertise = 0;
 
-	ret = ax88772_init_mdio(dev);
+	ret = ax88772_mdio_register(dev);
 	if (ret)
 		return ret;