Skip to content

Commit 7d5d307

Browse files
ffainellidavem330
authored andcommitted
net: bcmgenet: Remove checks on clock handles
Instead of multiplying the number of checks for IS_ERR(priv->clk), simply NULLify the 'struct clk' pointer which is something the Linux common clock framework perfectly deals with and does early return for each and every single clk_* API functions. Having every single function check for !IS_ERR(priv->clk) is both redundant and error prone, as it turns out, we were doing it for the main GENET clock: priv->clk, but not for the Wake-on-LAN or EEE clock, so let's just be consistent here. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Petri Gynther <pgynther@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b3e6b82 commit 7d5d307

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,8 +2625,7 @@ static int bcmgenet_open(struct net_device *dev)
26252625
netif_dbg(priv, ifup, dev, "bcmgenet_open\n");
26262626

26272627
/* Turn on the clock */
2628-
if (!IS_ERR(priv->clk))
2629-
clk_prepare_enable(priv->clk);
2628+
clk_prepare_enable(priv->clk);
26302629

26312630
/* If this is an internal GPHY, power it back on now, before UniMAC is
26322631
* brought out of reset as absolutely no UniMAC activity is allowed
@@ -2703,8 +2702,7 @@ static int bcmgenet_open(struct net_device *dev)
27032702
err_fini_dma:
27042703
bcmgenet_fini_dma(priv);
27052704
err_clk_disable:
2706-
if (!IS_ERR(priv->clk))
2707-
clk_disable_unprepare(priv->clk);
2705+
clk_disable_unprepare(priv->clk);
27082706
return ret;
27092707
}
27102708

@@ -2761,8 +2759,7 @@ static int bcmgenet_close(struct net_device *dev)
27612759
if (priv->internal_phy)
27622760
ret = bcmgenet_power_down(priv, GENET_POWER_PASSIVE);
27632761

2764-
if (!IS_ERR(priv->clk))
2765-
clk_disable_unprepare(priv->clk);
2762+
clk_disable_unprepare(priv->clk);
27662763

27672764
return ret;
27682765
}
@@ -3215,11 +3212,12 @@ static int bcmgenet_probe(struct platform_device *pdev)
32153212
priv->version = pd->genet_version;
32163213

32173214
priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
3218-
if (IS_ERR(priv->clk))
3215+
if (IS_ERR(priv->clk)) {
32193216
dev_warn(&priv->pdev->dev, "failed to get enet clock\n");
3217+
priv->clk = NULL;
3218+
}
32203219

3221-
if (!IS_ERR(priv->clk))
3222-
clk_prepare_enable(priv->clk);
3220+
clk_prepare_enable(priv->clk);
32233221

32243222
bcmgenet_set_hw_params(priv);
32253223

@@ -3230,8 +3228,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
32303228
INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task);
32313229

32323230
priv->clk_wol = devm_clk_get(&priv->pdev->dev, "enet-wol");
3233-
if (IS_ERR(priv->clk_wol))
3231+
if (IS_ERR(priv->clk_wol)) {
32343232
dev_warn(&priv->pdev->dev, "failed to get enet-wol clock\n");
3233+
priv->clk_wol = NULL;
3234+
}
32353235

32363236
priv->clk_eee = devm_clk_get(&priv->pdev->dev, "enet-eee");
32373237
if (IS_ERR(priv->clk_eee)) {
@@ -3257,8 +3257,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
32573257
netif_carrier_off(dev);
32583258

32593259
/* Turn off the main clock, WOL clock is handled separately */
3260-
if (!IS_ERR(priv->clk))
3261-
clk_disable_unprepare(priv->clk);
3260+
clk_disable_unprepare(priv->clk);
32623261

32633262
err = register_netdev(dev);
32643263
if (err)
@@ -3267,8 +3266,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
32673266
return err;
32683267

32693268
err_clk_disable:
3270-
if (!IS_ERR(priv->clk))
3271-
clk_disable_unprepare(priv->clk);
3269+
clk_disable_unprepare(priv->clk);
32723270
err:
32733271
free_netdev(dev);
32743272
return err;

0 commit comments

Comments
 (0)