Skip to content

Commit 27dfe90

Browse files
Ryceancurrykuba-moo
authored andcommitted
net: bcmasp: fix double disable of clk
Switch to devm_clk_get_optional() so we can manage the clock ourselves. We dynamically control the clocks depending on the state of the interface for power savings. The default state is clock disabled, so unbinding the driver causes a double disable. Fixes: 490cb41 ("net: bcmasp: Add support for ASP2.0 Ethernet controller") Signed-off-by: Justin Chen <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent cbfa5be commit 27dfe90

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

  • drivers/net/ethernet/broadcom/asp2

drivers/net/ethernet/broadcom/asp2/bcmasp.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ static int bcmasp_probe(struct platform_device *pdev)
12491249
if (priv->irq <= 0)
12501250
return -EINVAL;
12511251

1252-
priv->clk = devm_clk_get_optional_enabled(dev, "sw_asp");
1252+
priv->clk = devm_clk_get_optional(dev, "sw_asp");
12531253
if (IS_ERR(priv->clk))
12541254
return dev_err_probe(dev, PTR_ERR(priv->clk),
12551255
"failed to request clock\n");
@@ -1277,6 +1277,10 @@ static int bcmasp_probe(struct platform_device *pdev)
12771277

12781278
bcmasp_set_pdata(priv, pdata);
12791279

1280+
ret = clk_prepare_enable(priv->clk);
1281+
if (ret)
1282+
return dev_err_probe(dev, ret, "failed to start clock\n");
1283+
12801284
/* Enable all clocks to ensure successful probing */
12811285
bcmasp_core_clock_set(priv, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE, 0);
12821286

@@ -1288,8 +1292,10 @@ static int bcmasp_probe(struct platform_device *pdev)
12881292

12891293
ret = devm_request_irq(&pdev->dev, priv->irq, bcmasp_isr, 0,
12901294
pdev->name, priv);
1291-
if (ret)
1292-
return dev_err_probe(dev, ret, "failed to request ASP interrupt: %d", ret);
1295+
if (ret) {
1296+
dev_err(dev, "Failed to request ASP interrupt: %d", ret);
1297+
goto err_clock_disable;
1298+
}
12931299

12941300
/* Register mdio child nodes */
12951301
of_platform_populate(dev->of_node, bcmasp_mdio_of_match, NULL, dev);
@@ -1301,13 +1307,17 @@ static int bcmasp_probe(struct platform_device *pdev)
13011307

13021308
priv->mda_filters = devm_kcalloc(dev, priv->num_mda_filters,
13031309
sizeof(*priv->mda_filters), GFP_KERNEL);
1304-
if (!priv->mda_filters)
1305-
return -ENOMEM;
1310+
if (!priv->mda_filters) {
1311+
ret = -ENOMEM;
1312+
goto err_clock_disable;
1313+
}
13061314

13071315
priv->net_filters = devm_kcalloc(dev, priv->num_net_filters,
13081316
sizeof(*priv->net_filters), GFP_KERNEL);
1309-
if (!priv->net_filters)
1310-
return -ENOMEM;
1317+
if (!priv->net_filters) {
1318+
ret = -ENOMEM;
1319+
goto err_clock_disable;
1320+
}
13111321

13121322
bcmasp_core_init_filters(priv);
13131323

@@ -1316,7 +1326,8 @@ static int bcmasp_probe(struct platform_device *pdev)
13161326
ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
13171327
if (!ports_node) {
13181328
dev_warn(dev, "No ports found\n");
1319-
return -EINVAL;
1329+
ret = -EINVAL;
1330+
goto err_clock_disable;
13201331
}
13211332

13221333
i = 0;
@@ -1338,8 +1349,6 @@ static int bcmasp_probe(struct platform_device *pdev)
13381349
*/
13391350
bcmasp_core_clock_set(priv, 0, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE);
13401351

1341-
clk_disable_unprepare(priv->clk);
1342-
13431352
/* Now do the registration of the network ports which will take care
13441353
* of managing the clock properly.
13451354
*/
@@ -1352,12 +1361,16 @@ static int bcmasp_probe(struct platform_device *pdev)
13521361
count++;
13531362
}
13541363

1364+
clk_disable_unprepare(priv->clk);
1365+
13551366
dev_info(dev, "Initialized %d port(s)\n", count);
13561367

13571368
return ret;
13581369

13591370
err_cleanup:
13601371
bcmasp_remove_intfs(priv);
1372+
err_clock_disable:
1373+
clk_disable_unprepare(priv->clk);
13611374

13621375
return ret;
13631376
}

0 commit comments

Comments
 (0)