Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Florian Fainelli and committed by
David S. Miller
7d5d3075 b3e6b82a

+12 -14
+12 -14
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 2625 2625 netif_dbg(priv, ifup, dev, "bcmgenet_open\n"); 2626 2626 2627 2627 /* Turn on the clock */ 2628 - if (!IS_ERR(priv->clk)) 2629 - clk_prepare_enable(priv->clk); 2628 + clk_prepare_enable(priv->clk); 2630 2629 2631 2630 /* If this is an internal GPHY, power it back on now, before UniMAC is 2632 2631 * brought out of reset as absolutely no UniMAC activity is allowed ··· 2702 2703 err_fini_dma: 2703 2704 bcmgenet_fini_dma(priv); 2704 2705 err_clk_disable: 2705 - if (!IS_ERR(priv->clk)) 2706 - clk_disable_unprepare(priv->clk); 2706 + clk_disable_unprepare(priv->clk); 2707 2707 return ret; 2708 2708 } 2709 2709 ··· 2759 2761 if (priv->internal_phy) 2760 2762 ret = bcmgenet_power_down(priv, GENET_POWER_PASSIVE); 2761 2763 2762 - if (!IS_ERR(priv->clk)) 2763 - clk_disable_unprepare(priv->clk); 2764 + clk_disable_unprepare(priv->clk); 2764 2765 2765 2766 return ret; 2766 2767 } ··· 3212 3215 priv->version = pd->genet_version; 3213 3216 3214 3217 priv->clk = devm_clk_get(&priv->pdev->dev, "enet"); 3215 - if (IS_ERR(priv->clk)) 3218 + if (IS_ERR(priv->clk)) { 3216 3219 dev_warn(&priv->pdev->dev, "failed to get enet clock\n"); 3220 + priv->clk = NULL; 3221 + } 3217 3222 3218 - if (!IS_ERR(priv->clk)) 3219 - clk_prepare_enable(priv->clk); 3223 + clk_prepare_enable(priv->clk); 3220 3224 3221 3225 bcmgenet_set_hw_params(priv); 3222 3226 ··· 3228 3230 INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task); 3229 3231 3230 3232 priv->clk_wol = devm_clk_get(&priv->pdev->dev, "enet-wol"); 3231 - if (IS_ERR(priv->clk_wol)) 3233 + if (IS_ERR(priv->clk_wol)) { 3232 3234 dev_warn(&priv->pdev->dev, "failed to get enet-wol clock\n"); 3235 + priv->clk_wol = NULL; 3236 + } 3233 3237 3234 3238 priv->clk_eee = devm_clk_get(&priv->pdev->dev, "enet-eee"); 3235 3239 if (IS_ERR(priv->clk_eee)) { ··· 3257 3257 netif_carrier_off(dev); 3258 3258 3259 3259 /* 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); 3262 3261 3263 3262 err = register_netdev(dev); 3264 3263 if (err) ··· 3266 3267 return err; 3267 3268 3268 3269 err_clk_disable: 3269 - if (!IS_ERR(priv->clk)) 3270 - clk_disable_unprepare(priv->clk); 3270 + clk_disable_unprepare(priv->clk); 3271 3271 err: 3272 3272 free_netdev(dev); 3273 3273 return err;