diff mbox series

[PATCHv2,net-next] net: ag71xx: add missing reset_control_put

Message ID 20240823200433.7542-1-rosenp@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [PATCHv2,net-next] net: ag71xx: add missing reset_control_put | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: chris.snook@gmail.com p.zabel@pengutronix.de
netdev/build_clang success Errors and warnings before: 7 this patch: 7
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: 7 this patch: 7
netdev/checkpatch warning WARNING: Possible repeated word: 'of'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-25--21-00 (tests: 714)

Commit Message

Rosen Penev Aug. 23, 2024, 8:04 p.m. UTC
The original downstream driver used devm instead of of. The latter
requires reset_control_put to be called in all return paths.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 v2: don't call after ag71xx_mdio_probe. Already done.
 drivers/net/ethernet/atheros/ag71xx.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Oleksij Rempel Aug. 24, 2024, 4:48 a.m. UTC | #1
Hi Rosen,

On Fri, Aug 23, 2024 at 01:04:18PM -0700, Rosen Penev wrote:
> The original downstream driver used devm instead of of. The latter
> requires reset_control_put to be called in all return paths.

At the moment of upstreaming this code, the original driver used
of_reset_control_get_exclusive() and was fixed by f92bbdcc93 ("ath79:
ag71xx-mdio: get reset control using devm api")

Why not port the original fix?
 
Regards,
Oleksij
Rosen Penev Aug. 24, 2024, 5:23 a.m. UTC | #2
On Fri, Aug 23, 2024 at 9:48 PM Oleksij Rempel <o.rempel@pengutronix.de> wrote:
>
> Hi Rosen,
>
> On Fri, Aug 23, 2024 at 01:04:18PM -0700, Rosen Penev wrote:
> > The original downstream driver used devm instead of of. The latter
> > requires reset_control_put to be called in all return paths.
>
> At the moment of upstreaming this code, the original driver used
> of_reset_control_get_exclusive() and was fixed by f92bbdcc93 ("ath79:
> ag71xx-mdio: get reset control using devm api")
>
> Why not port the original fix?
On further review, this looks safe to do. Will submit tomorrow.
>
> Regards,
> Oleksij
> --
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
diff mbox series

Patch

diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index 89cd001b385f..7fbe95108067 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -722,8 +722,10 @@  static int ag71xx_mdio_probe(struct ag71xx *ag)
 	mnp = of_get_child_by_name(np, "mdio");
 	err = devm_of_mdiobus_register(dev, mii_bus, mnp);
 	of_node_put(mnp);
-	if (err)
+	if (err) {
+		reset_control_put(ag->mdio_reset);
 		return err;
+	}
 
 	return 0;
 }
@@ -1924,12 +1926,14 @@  static int ag71xx_probe(struct platform_device *pdev)
 	err = ag71xx_phylink_setup(ag);
 	if (err) {
 		netif_err(ag, probe, ndev, "failed to setup phylink (%d)\n", err);
+		reset_control_put(ag->mdio_reset);
 		return err;
 	}
 
 	err = devm_register_netdev(&pdev->dev, ndev);
 	if (err) {
 		netif_err(ag, probe, ndev, "unable to register net device\n");
+		reset_control_put(ag->mdio_reset);
 		platform_set_drvdata(pdev, NULL);
 		return err;
 	}
@@ -1941,6 +1945,14 @@  static int ag71xx_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static void ag71xx_remove(struct platform_device *pdev)
+{
+	struct net_device *ndev = platform_get_drvdata(pdev);
+	struct ag71xx *ag = ag = netdev_priv(ndev);
+
+	reset_control_put(ag->mdio_reset);
+}
+
 static const u32 ar71xx_fifo_ar7100[] = {
 	0x0fff0000, 0x00001fff, 0x00780fff,
 };
@@ -2025,6 +2037,7 @@  static const struct of_device_id ag71xx_match[] = {
 
 static struct platform_driver ag71xx_driver = {
 	.probe		= ag71xx_probe,
+	.remove_new	= ag71xx_remove,
 	.driver = {
 		.name	= "ag71xx",
 		.of_match_table = ag71xx_match,