net: stmmac: anarion: cleanups
Subsystems (4)
v2 cover net: stmmac: anarion: cleanups
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.
Not tested on hardware.
v2: fix build error, add Andrew's r-bs.
.../net/ethernet/stmicro/stmmac/dwmac-anarion.c | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH v2 1/4 net: stmmac: anarion: clean up anarion_config_dt() error handling
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().
--- drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c +3 -4
@@ -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 );
Signature · 1 line
2.30.2
PATCH v2 2/4 net: stmmac: anarion: clean up interface parsing
In reply to Russell King (Oracle)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.
--- .../net/ethernet/stmicro/stmmac/dwmac-anarion.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c +4 -10
@@ -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 ); }
Signature · 1 line
2.30.2
PATCH v2 3/4 net: stmmac: anarion: use stmmac_pltfr_probe()
In reply to Russell King (Oracle)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.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c +1 -2
@@ -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, plat_dat, &stmmac_res); }static const struct of_device_id anarion_dwmac_match[] = {
Signature · 1 line
2.30.2
PATCH v2 4/4 net: stmmac: anarion: use devm_stmmac_pltfr_probe()
In reply to Russell King (Oracle)Convert anarion to use devm_stmmac_pltfr_probe() which allows the removal of an explicit call to stmmac_pltfr_remove().
--- drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c +1 -2
@@ -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, 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,
Signature · 1 line
2.30.2
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Mon, 14 Apr 2025 10:05:56 +0100 you wrote:
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 useERR_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.[...]
Here is the summary with links:
- [net-next,v2,1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling
https://git.kernel.org/netdev/net-next/c/c30a45a7e072 - [net-next,v2,2/4] net: stmmac: anarion: clean up interface parsing https://git.kernel.org/netdev/net-next/c/a55ec9c811aa - [net-next,v2,3/4] net: stmmac: anarion: use stmmac_pltfr_probe() https://git.kernel.org/netdev/net-next/c/5956527e26ff - [net-next,v2,4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe() https://git.kernel.org/netdev/net-next/c/a1afabef915c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html