Skip to contentSkip to conversation

net: xilinx: axienet: Use common error handling code in axienet_mdio_write()

PATCH In review Markus Elfring 2 participants 3 messages Sep 20, 2024 – Sep 22, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: xilinx: axienet: Use common error handling code in axienet_mdio_write()

From: Markus Elfring <[email protected]>
Date: Fri, 20 Sep 2024 12:43:39 +0200
Subject: [PATCH] net: xilinx: axienet: Use common error handling code in axienet_mdio_write()

Add a label so that a bit of exception handling can be better reused at the end of this function implementation.

This issue was detected by using the Coccinelle software.

---
 drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c +4 -9
index 9ca2643c921e..0c7b931b2e66 100644
@@ -138,10 +138,8 @@ static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg,
 	axienet_mdio_mdc_enable(lp);
 
 	ret = axienet_mdio_wait_until_ready(lp);
-	if (ret < 0) {
-		axienet_mdio_mdc_disable(lp);
-		return ret;
-	}
+	if (ret < 0)
+		goto disable_mdc;
 
 	axienet_iow(lp, XAE_MDIO_MWD_OFFSET, (u32)val);
 	axienet_iow(lp, XAE_MDIO_MCR_OFFSET,
@@ -153,12 +151,9 @@ static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg,
 		     XAE_MDIO_MCR_OP_WRITE_MASK));
 
 	ret = axienet_mdio_wait_until_ready(lp);
-	if (ret < 0) {
-		axienet_mdio_mdc_disable(lp);
-		return ret;
-	}
+disable_mdc:
 	axienet_mdio_mdc_disable(lp);
-	return 0;
+	return ret;
 }
 
 /**

--
2.46.0

reviewer
#1 lore raw
Quoted 10 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 20 Sep 2024 12:43:39 +0200
Subject: [PATCH] net: xilinx: axienet: Use common error handling code in axienet_mdio_write()

Add a label so that a bit of exception handling can be better reused at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Hi Markus,

This change seems reasonable to me. However, I am assuming that as a non-bug-fix, this is targeted at net-next. And net-next is currently closed for the v6.12 merge window. Please consider reposting this patch once net-next reopens. That will occur after v6.12-rc1 has been released. Which I expect to be about a week from now.

Also, for networking patches please tag non-bug fixes for net-next (and bug fixes for net, being sure to include a Fixes tag).

Subject: [PATCH net-next] ...

Please see https://docs.kernel.org/process/maintainer-netdev.html

...

Quoted 1 line
drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c +0 -0

...

drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg, · line 159

Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c +0 -4
@@ -153,12 +151,9 @@ static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg,
 		     XAE_MDIO_MCR_OP_WRITE_MASK));
 
 	ret = axienet_mdio_wait_until_ready(lp);
-	if (ret < 0) {
-		axienet_mdio_mdc_disable(lp);
-		return ret;
-	}

Please add a blank line here.

Quoted 7 lines
drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c +2 -1
+disable_mdc:
 	axienet_mdio_mdc_disable(lp);
-	return 0;
+	return ret;
 }
 
 /**
Signature · 1 line
pw-bot: defer
#2 lore raw
Quoted 2 lines
Quoted 2 lines

Add a label so that a bit of exception handling can be better reused at the end of this function implementation.

…

Quoted 1 line

This change seems reasonable to me.

Thanks for this positive feedback.

Quoted 2 lines

However, I am assuming that as a
non-bug-fix,

Would you like to categorise my update suggestion as a correction for a coding style issue?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.11#n526

Quoted 3 lines

this is targeted at net-next. And net-next is currently
closed for the v6.12 merge window. Please consider reposting this patch once net-next reopens.

Will a patch resend really be needed for the proposed adjustment?

Can both development branches benefit from this refactoring?

Regards,
Markus