net: stmmac: anarion: cleanups
Subsystems (4)
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.
.../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 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 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 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->dev, plat_dat, &stmmac_res); }static const struct of_device_id anarion_dwmac_match[] = {
Signature · 1 line
2.30.2
PATCH 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->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,
Signature · 1 line
2.30.2
Re: [PATCH net-next 1/4] net: stmmac: anarion: clean up anarion_config_dt() error handling
In reply to Russell King (Oracle)Quoted 6 lines · Russell King (Oracle)
When enabled, print a user friendly description of the error when failing to
ioremap()the control resource, and useERR_CAST()when propagating the error. This allows us to get rid of the "err" local variable inanarion_config_dt().Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 2/4] net: stmmac: anarion: clean up interface parsing
In reply to Russell King (Oracle)Quoted 7 lines · 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 thephy_interface_mode_is_rgmii()helper, and print the English version of the PHY interface mode on error.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 3/4] net: stmmac: anarion: use stmmac_pltfr_probe()
In reply to Russell King (Oracle)Quoted 6 lines · Russell King (Oracle)
Rather than open-coding the call to
anarion_gmac_init()and thenstmmac_dvr_probe(), omitting the cleanup of callinganarion_gmac_exit(), usestmmac_pltfr_probe()which will handle this for us.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe()
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Convert anarion to use
devm_stmmac_pltfr_probe()which allows the removal of an explicit call tostmmac_pltfr_remove().Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe()
Quoted 7 lines · Andrew Lunn
Quoted 4 lines · Russell King (Oracle)
Convert anarion to use
devm_stmmac_pltfr_probe()which allows the removal of an explicit call tostmmac_pltfr_remove().Signed-off-by Russell King (Oracle) <[email protected]>Reviewed-by Andrew Lunn <[email protected]>
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?
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!
Re: [PATCH net-next 4/4] net: stmmac: anarion: use devm_stmmac_pltfr_probe()
Quoted 4 lines
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