netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling
  2025-04-12 14:17 [PATCH net-next 0/4] net: stmmac: anarion: cleanups Russell King (Oracle)
@ 2025-04-12 14:16 ` Russell King (Oracle)
  2025-04-13 21:08   ` Andrew Lunn
  2025-04-12 14:17 ` [PATCH net-next 2/4] net: stmmac: anarion: clean up interface parsing Russell King (Oracle)
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Russell King (Oracle) @ 2025-04-12 14:16 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

When enabled, print a user friendly description of the error when
failing to ioremap() the control resource, and use ERR_CAST() when
propagating the error. This allows us to get rid of the "err" local
variable in anarion_config_dt().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
index 37fe7c288878..232aae752690 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
@@ -65,13 +65,12 @@ anarion_config_dt(struct platform_device *pdev,
 {
 	struct anarion_gmac *gmac;
 	void __iomem *ctl_block;
-	int err;
 
 	ctl_block = devm_platform_ioremap_resource(pdev, 1);
 	if (IS_ERR(ctl_block)) {
-		err = PTR_ERR(ctl_block);
-		dev_err(&pdev->dev, "Cannot get reset region (%d)!\n", err);
-		return ERR_PTR(err);
+		dev_err(&pdev->dev, "Cannot get reset region (%pe)!\n",
+			ctl_block);
+		return ERR_CAST(ctl_block);
 	}
 
 	gmac = devm_kzalloc(&pdev->dev, sizeof(*gmac), GFP_KERNEL);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 2/4] net: stmmac: anarion: clean up interface parsing
  2025-04-12 14:17 [PATCH net-next 0/4] net: stmmac: anarion: cleanups Russell King (Oracle)
  2025-04-12 14:16 ` [PATCH net-next 1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling Russell King (Oracle)
@ 2025-04-12 14:17 ` Russell King (Oracle)
  2025-04-13 21:09   ` Andrew Lunn
  2025-04-12 14:17 ` [PATCH net-next 3/4] net: stmmac: anarion: use stmmac_pltfr_probe() Russell King (Oracle)
  2025-04-12 14:17 ` [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe() Russell King (Oracle)
  3 siblings, 1 reply; 11+ messages in thread
From: Russell King (Oracle) @ 2025-04-12 14:17 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

anarion_config_dt() used a switch statement to check for the RGMII
modes, complete with an unnecessary "fallthrough", and also printed
the numerical value of the PHY interface mode on error. Clean this
up using the phy_interface_mode_is_rgmii() helper, and print the
English version of the PHY interface mode on error.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-anarion.c    | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
index 232aae752690..941ea724c643 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
@@ -79,17 +79,11 @@ anarion_config_dt(struct platform_device *pdev,
 
 	gmac->ctl_block = ctl_block;
 
-	switch (plat_dat->phy_interface) {
-	case PHY_INTERFACE_MODE_RGMII:
-		fallthrough;
-	case PHY_INTERFACE_MODE_RGMII_ID:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
+	if (phy_interface_mode_is_rgmii(plat_dat->phy_interface)) {
 		gmac->phy_intf_sel = GMAC_CONFIG_INTF_RGMII;
-		break;
-	default:
-		dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n",
-			plat_dat->phy_interface);
+	} else {
+		dev_err(&pdev->dev, "Unsupported phy-mode (%s)\n",
+			phy_modes(plat_dat->phy_interface));
 		return ERR_PTR(-ENOTSUPP);
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 3/4] net: stmmac: anarion: use stmmac_pltfr_probe()
  2025-04-12 14:17 [PATCH net-next 0/4] net: stmmac: anarion: cleanups Russell King (Oracle)
  2025-04-12 14:16 ` [PATCH net-next 1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling Russell King (Oracle)
  2025-04-12 14:17 ` [PATCH net-next 2/4] net: stmmac: anarion: clean up interface parsing Russell King (Oracle)
@ 2025-04-12 14:17 ` Russell King (Oracle)
  2025-04-13 21:10   ` Andrew Lunn
  2025-04-12 14:17 ` [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe() Russell King (Oracle)
  3 siblings, 1 reply; 11+ messages in thread
From: Russell King (Oracle) @ 2025-04-12 14:17 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

Rather than open-coding the call to anarion_gmac_init() and then
stmmac_dvr_probe(), omitting the cleanup of calling
anarion_gmac_exit(), use stmmac_pltfr_probe() which will handle this
for us.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
index 941ea724c643..8bbedf32d512 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
@@ -111,10 +111,9 @@ static int anarion_dwmac_probe(struct platform_device *pdev)
 
 	plat_dat->init = anarion_gmac_init;
 	plat_dat->exit = anarion_gmac_exit;
-	anarion_gmac_init(pdev, gmac);
 	plat_dat->bsp_priv = gmac;
 
-	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+	return stmmac_pltfr_probe(&pdev->dev, plat_dat, &stmmac_res);
 }
 
 static const struct of_device_id anarion_dwmac_match[] = {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe()
  2025-04-12 14:17 [PATCH net-next 0/4] net: stmmac: anarion: cleanups Russell King (Oracle)
                   ` (2 preceding siblings ...)
  2025-04-12 14:17 ` [PATCH net-next 3/4] net: stmmac: anarion: use stmmac_pltfr_probe() Russell King (Oracle)
@ 2025-04-12 14:17 ` Russell King (Oracle)
  2025-04-13 21:10   ` Andrew Lunn
  3 siblings, 1 reply; 11+ messages in thread
From: Russell King (Oracle) @ 2025-04-12 14:17 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

Convert anarion to use devm_stmmac_pltfr_probe() which allows the
removal of an explicit call to stmmac_pltfr_remove().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
index 8bbedf32d512..84072c8ed741 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
@@ -113,7 +113,7 @@ static int anarion_dwmac_probe(struct platform_device *pdev)
 	plat_dat->exit = anarion_gmac_exit;
 	plat_dat->bsp_priv = gmac;
 
-	return stmmac_pltfr_probe(&pdev->dev, plat_dat, &stmmac_res);
+	return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
 }
 
 static const struct of_device_id anarion_dwmac_match[] = {
@@ -124,7 +124,6 @@ MODULE_DEVICE_TABLE(of, anarion_dwmac_match);
 
 static struct platform_driver anarion_dwmac_driver = {
 	.probe  = anarion_dwmac_probe,
-	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "anarion-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 0/4] net: stmmac: anarion: cleanups
@ 2025-04-12 14:17 Russell King (Oracle)
  2025-04-12 14:16 ` [PATCH net-next 1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling Russell King (Oracle)
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Russell King (Oracle) @ 2025-04-12 14:17 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

A series of cleanups to the anarion glue driver.

Clean up anarion_config_dt() error handling, printing a human readable
error rather than the numeric errno, and use ERR_CAST().

Using a switch statement with incorrect "fallthrough;" for RGMII vs
non-RGMII is unnecessary when we have phy_interface_mode_is_rgmii().
Convert to use the helper.

Use stmmac_pltfr_probe() rahter than open-coding the call to the
init function (which stmmac_pltfr_probe() will do for us.)

Finally, convert to use devm_stmmac_pltfr_probe() which allows the
removal of the .remove initialiser in the driver structure.

 .../net/ethernet/stmicro/stmmac/dwmac-anarion.c    | 25 +++++++---------------
 1 file changed, 8 insertions(+), 17 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling
  2025-04-12 14:16 ` [PATCH net-next 1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling Russell King (Oracle)
@ 2025-04-13 21:08   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2025-04-13 21:08 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Sat, Apr 12, 2025 at 03:16:57PM +0100, Russell King (Oracle) wrote:
> When enabled, print a user friendly description of the error when
> failing to ioremap() the control resource, and use ERR_CAST() when
> propagating the error. This allows us to get rid of the "err" local
> variable in anarion_config_dt().
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/4] net: stmmac: anarion: clean up interface parsing
  2025-04-12 14:17 ` [PATCH net-next 2/4] net: stmmac: anarion: clean up interface parsing Russell King (Oracle)
@ 2025-04-13 21:09   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2025-04-13 21:09 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Sat, Apr 12, 2025 at 03:17:02PM +0100, Russell King (Oracle) wrote:
> anarion_config_dt() used a switch statement to check for the RGMII
> modes, complete with an unnecessary "fallthrough", and also printed
> the numerical value of the PHY interface mode on error. Clean this
> up using the phy_interface_mode_is_rgmii() helper, and print the
> English version of the PHY interface mode on error.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 3/4] net: stmmac: anarion: use stmmac_pltfr_probe()
  2025-04-12 14:17 ` [PATCH net-next 3/4] net: stmmac: anarion: use stmmac_pltfr_probe() Russell King (Oracle)
@ 2025-04-13 21:10   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2025-04-13 21:10 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Sat, Apr 12, 2025 at 03:17:07PM +0100, Russell King (Oracle) wrote:
> Rather than open-coding the call to anarion_gmac_init() and then
> stmmac_dvr_probe(), omitting the cleanup of calling
> anarion_gmac_exit(), use stmmac_pltfr_probe() which will handle this
> for us.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe()
  2025-04-12 14:17 ` [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe() Russell King (Oracle)
@ 2025-04-13 21:10   ` Andrew Lunn
  2025-04-13 22:40     ` Russell King (Oracle)
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Lunn @ 2025-04-13 21:10 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Sat, Apr 12, 2025 at 03:17:12PM +0100, Russell King (Oracle) wrote:
> Convert anarion to use devm_stmmac_pltfr_probe() which allows the
> removal of an explicit call to stmmac_pltfr_remove().
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe()
  2025-04-13 21:10   ` Andrew Lunn
@ 2025-04-13 22:40     ` Russell King (Oracle)
  2025-04-13 22:48       ` Andrew Lunn
  0 siblings, 1 reply; 11+ messages in thread
From: Russell King (Oracle) @ 2025-04-13 22:40 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

On Sun, Apr 13, 2025 at 11:10:24PM +0200, Andrew Lunn wrote:
> On Sat, Apr 12, 2025 at 03:17:12PM +0100, Russell King (Oracle) wrote:
> > Convert anarion to use devm_stmmac_pltfr_probe() which allows the
> > removal of an explicit call to stmmac_pltfr_remove().
> > 
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks - but nipa found an error in the patch - s/&pdev->dev/pdev/
with the new call. Ditto for "net: stmmac: anarion: use
stmmac_pltfr_probe()" so I'll be sending a v2 for both. Do you
want me to keep your r-b with that change for both patches?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe()
  2025-04-13 22:40     ` Russell King (Oracle)
@ 2025-04-13 22:48       ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2025-04-13 22:48 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Paolo Abeni

> Thanks - but nipa found an error in the patch - s/&pdev->dev/pdev/
> with the new call. Ditto for "net: stmmac: anarion: use
> stmmac_pltfr_probe()" so I'll be sending a v2 for both. Do you
> want me to keep your r-b with that change for both patches?

Yes, keep them. The basic idea looks correct, even if you made a minor
error.

	Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-04-13 22:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-12 14:17 [PATCH net-next 0/4] net: stmmac: anarion: cleanups Russell King (Oracle)
2025-04-12 14:16 ` [PATCH net-next 1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling Russell King (Oracle)
2025-04-13 21:08   ` Andrew Lunn
2025-04-12 14:17 ` [PATCH net-next 2/4] net: stmmac: anarion: clean up interface parsing Russell King (Oracle)
2025-04-13 21:09   ` Andrew Lunn
2025-04-12 14:17 ` [PATCH net-next 3/4] net: stmmac: anarion: use stmmac_pltfr_probe() Russell King (Oracle)
2025-04-13 21:10   ` Andrew Lunn
2025-04-12 14:17 ` [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe() Russell King (Oracle)
2025-04-13 21:10   ` Andrew Lunn
2025-04-13 22:40     ` Russell King (Oracle)
2025-04-13 22:48       ` Andrew Lunn

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).