net: mvpp2: Put fwnode in error case during ->probe()
Subsystems (3)
PATCH 1/4 net: mvpp2: Put fwnode in error case during ->probe()
In each iteration fwnode_for_each_available_child_node() bumps a reference counting of a loop variable followed by dropping in on a next iteration,
Since in error case the loop is broken, we have to drop a reference count by ourselves. Do it for port_fwnode in error case during ->probe().
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -0
@@ -7552,6 +7552,8 @@ static int mvpp2_probe(struct platform_device *pdev)return 0 ; err_port_probe: +fwnode_handle_put (port_fwnode); + i =0 ;fwnode_for_each_available_child_node (fwnode, port_fwnode) {if (priv->port_list[i])
Signature · 1 line
2.31.1
PATCH 2/4 net: mvpp2: Use device_get_match_data() helper
From: Andy Shevchenko <[email protected]>
Use the device_get_match_data() helper instead of open coding.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -11
@@ -7311,7 +7311,6 @@ static int mvpp2_get_sram(struct platform_device *pdev,static int mvpp2_probe (struct platform_device *pdev) { -const struct acpi_device_id *acpi_id;struct fwnode_handle *fwnode = pdev->dev.fwnode;struct fwnode_handle *port_fwnode;struct mvpp2 *priv;
@@ -7324,16 +7323,7 @@ static int mvpp2_probe(struct platform_device *pdev)if (!priv)return -ENOMEM ; -if (has_acpi_companion (&pdev->dev)) { - acpi_id =acpi_match_device (pdev->dev.driver->acpi_match_table, - &pdev->dev); -if (!acpi_id) -return -EINVAL ; - priv->hw_version = (unsigned long )acpi_id->driver_data; - }else { - priv->hw_version = - (unsigned long )of_device_get_match_data (&pdev->dev); - } + priv->hw_version = (unsigned long )device_get_match_data (&pdev->dev);/* multi queue mode isn't supported on PPV2.1, fallback to single * mode
Signature · 1 line
2.31.1
PATCH 3/4 net: mvpp2: Use devm_clk_get_optional()
In reply to Andy ShevchenkoFrom: Andy Shevchenko <[email protected]>
Replace open coded variants of devm_clk_get_optional().
--- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +15 -19
@@ -7435,28 +7435,27 @@ static int mvpp2_probe(struct platform_device *pdev)if (err <0 ) goto err_gop_clk; - priv->mg_core_clk =devm_clk_get (&pdev->dev,"mg_core_clk" ); + priv->mg_core_clk =devm_clk_get_optional (&pdev->dev,"mg_core_clk" );if (IS_ERR (priv->mg_core_clk)) { - priv->mg_core_clk =NULL ; - }else { - err =clk_prepare_enable (priv->mg_core_clk); -if (err <0 ) - goto err_mg_clk; + err =PTR_ERR (priv->mg_core_clk); + goto err_mg_clk; } + + err =clk_prepare_enable (priv->mg_core_clk); +if (err <0 ) + goto err_mg_clk; } - priv->axi_clk =devm_clk_get (&pdev->dev,"axi_clk" ); + priv->axi_clk =devm_clk_get_optional (&pdev->dev,"axi_clk" );if (IS_ERR (priv->axi_clk)) { err =PTR_ERR (priv->axi_clk); -if (err == -EPROBE_DEFER ) - goto err_mg_core_clk; - priv->axi_clk =NULL ; - }else { - err =clk_prepare_enable (priv->axi_clk); -if (err <0 ) - goto err_mg_core_clk; + goto err_mg_core_clk; } + err =clk_prepare_enable (priv->axi_clk); +if (err <0 ) + goto err_mg_core_clk; +/* Get system's tclk rate */ priv->tclk =clk_get_rate (priv->pp_clk); } else if (device_property_read_u32(&pdev->dev, "clock-frequency",
@@ -7552,13 +7551,10 @@ static int mvpp2_probe(struct platform_device *pdev) } err_axi_clk:clk_disable_unprepare (priv->axi_clk); - err_mg_core_clk: -if (priv->hw_version >=MVPP22 ) -clk_disable_unprepare (priv->mg_core_clk); +clk_disable_unprepare (priv->mg_core_clk); err_mg_clk: -if (priv->hw_version >=MVPP22 ) -clk_disable_unprepare (priv->mg_clk); +clk_disable_unprepare (priv->mg_clk); err_gop_clk:clk_disable_unprepare (priv->gop_clk); err_pp_clk:
Signature · 1 line
2.31.1
PATCH 4/4 net: mvpp2: Unshadow error code of device_property_read_u32()
In reply to Andy Shevchenkodevice_property_read_u32() may return different error codes. Propagate it to the caller.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +6 -4
@@ -7458,10 +7458,12 @@ static int mvpp2_probe(struct platform_device *pdev)/* Get system's tclk rate */ priv->tclk =clk_get_rate (priv->pp_clk); - }else if (device_property_read_u32 (&pdev->dev,"clock-frequency" , - &priv->tclk)) { -dev_err (&pdev->dev,"missing clock-frequency value\n" ); -return -EINVAL ; + }else { + err =device_property_read_u32 (&pdev->dev,"clock-frequency" , &priv->tclk); +if (err) { +dev_err (&pdev->dev,"missing clock-frequency value\n" ); +return err; + } }if (priv->hw_version >=MVPP22 ) {
Signature · 1 line
2.31.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 11 lines · On Mon, 10 May 2021 12:58:05 +0300 you wrote:
In each iteration
fwnode_for_each_available_child_node()bumps a reference counting of a loop variable followed by dropping in on a next iteration,Since in error case the loop is broken, we have to drop a reference count by ourselves. Do it for
port_fwnodein error case during ->probe().Fixes 248122212f68 ("net: mvpp2: use device_*/fwnode_* APIs instead of of_*")Cc Marcin Wojtas <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>[...]
Here is the summary with links:
- [net-next,v1,1/4] net: mvpp2: Put fwnode in error case during ->probe()
https://git.kernel.org/netdev/net-next/c/71f0891c84df - [net-next,v1,2/4] net: mvpp2: Use device_get_match_data() helper https://git.kernel.org/netdev/net-next/c/692b82c57f71 - [net-next,v1,3/4] net: mvpp2: Use devm_clk_get_optional() https://git.kernel.org/netdev/net-next/c/cf3399b731d3 - [net-next,v1,4/4] net: mvpp2: Unshadow error code of device_property_read_u32() https://git.kernel.org/netdev/net-next/c/584525554fd6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html