net: mv643xx: devm fixes
Subsystems (3)
cover net: mv643xx: devm fixes
Small simplification and a fix for a seemingly wrong function usage.
Rosen Penev (2):
net: mv643xx: use devm_platform_ioremap_resource
net: mv643xx: fix wrong devm_clk_get usage
drivers/net/ethernet/marvell/mv643xx_eth.c | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 deletions(-)
Signature · 1 line
2.46.2
PATCH 1/2 net: mv643xx: use devm_platform_ioremap_resource
This combines multiple steps in one function.
--- drivers/net/ethernet/marvell/mv643xx_eth.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +3 -8
@@ -2839,25 +2839,20 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)struct mv643xx_eth_shared_platform_data *pd;struct mv643xx_eth_shared_private *msp;const struct mbus_dram_target_info *dram; -struct resource *res;int ret;if (!mv643xx_eth_version_printed++)pr_notice ("MV-643xx 10/100/1000 ethernet driver version %s\n" , mv643xx_eth_driver_version); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (res ==NULL ) -return -EINVAL ; - msp =devm_kzalloc (&pdev->dev,sizeof (*msp),GFP_KERNEL );if (msp ==NULL )return -ENOMEM ;platform_set_drvdata (pdev, msp); - msp->base =devm_ioremap (&pdev->dev, res->start,resource_size (res)); -if (msp->base ==NULL ) -return -ENOMEM ; + msp->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (msp->base)) +return PTR_ERR (msp->base); msp->clk =devm_clk_get (&pdev->dev,NULL );if (!IS_ERR (msp->clk))
Signature · 1 line
2.46.2
Re: [PATCH net-next 1/2] net: mv643xx: use devm_platform_ioremap_resource
Quoted 3 lines · Rosen Penev
This combines multiple steps in one function.
Signed-off-by Rosen Penev <[email protected]>
Andrew
PATCH 2/2 net: mv643xx: fix wrong devm_clk_get usage
In reply to Rosen PenevThis clock should be optional. In addition, PTR_ERR can be -EPROBE_DEFER in which case it should return.
devm_clk_get_optional_enabled also allows removing explicit clock enable and disable calls.
--- drivers/net/ethernet/marvell/mv643xx_eth.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +4 -13
@@ -2854,9 +2854,9 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)if (IS_ERR (msp->base))return PTR_ERR (msp->base); - msp->clk =devm_clk_get (&pdev->dev,NULL ); -if (!IS_ERR (msp->clk)) -clk_prepare_enable (msp->clk); + msp->clk =devm_clk_get_optional_enabled (&pdev->dev,NULL ); +if (IS_ERR (msp->clk)) +return PTR_ERR (msp->clk);/* * (Re-)program MBUS remapping windows if we are asked to.
@@ -2867,7 +2867,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) ret =mv643xx_eth_shared_of_probe (pdev);if (ret) - goto err_put_clk; +return ret; pd =dev_get_platdata (&pdev->dev); msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
@@ -2875,20 +2875,11 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)infer_hw_params (msp);return 0 ; - -err_put_clk: -if (!IS_ERR (msp->clk)) -clk_disable_unprepare (msp->clk); -return ret; }static void mv643xx_eth_shared_remove (struct platform_device *pdev) { -struct mv643xx_eth_shared_private *msp =platform_get_drvdata (pdev); -mv643xx_eth_shared_of_remove (); -if (!IS_ERR (msp->clk)) -clk_disable_unprepare (msp->clk); }static struct platform_driver mv643xx_eth_shared_driver = {
Signature · 1 line
2.46.2
Re: [PATCH net-next 2/2] net: mv643xx: fix wrong devm_clk_get usage
Quoted 5 lines · Rosen Penev
This clock should be optional. In addition,
PTR_ERRcan be -EPROBE_DEFER in which case it should return.
devm_clk_get_optional_enabledalso allows removing explicit clock enable and disable calls.
mv643xx_eth was one of the early drivers to get converted to common clock framework, and then devm. Some of the niceties of _optional, and _enable did not exist back then. So the logic may seem a bit odd nowadays.
Andrew
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 8 lines · On Mon, 30 Sep 2024 13:29:49 -0700 you wrote:
Small simplification and a fix for a seemingly wrong function usage.
Rosen Penev (2):
net: mv643xx: usedevm_platform_ioremap_resource
net: mv643xx: fix wrongdevm_clk_getusagedrivers/net/ethernet/marvell/mv643xx_eth.c | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 deletions(-)
Here is the summary with links:
- [net-next,1/2] net: mv643xx: use devm_platform_ioremap_resource
https://git.kernel.org/netdev/net-next/c/4d77e88ab42f - [net-next,2/2] net: mv643xx: fix wrong devm_clk_get usage https://git.kernel.org/netdev/net-next/c/50c3a7fbaa10
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html