Skip to content

Commit ab10461

Browse files
geertudavem330
authored andcommitted
ravb: Consolidate clock handling
The module clock is used for two purposes: - Wake-on-LAN (WoL), which is optional, - gPTP Timer Increment (GTI) configuration, which is mandatory. As the clock is needed for GTI configuration anyway, WoL is always available. Hence remove duplication and repeated obtaining of the clock by making GTI use the stored clock for WoL use. Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Niklas Söderlund <[email protected]> Reviewed-by: Sergei Shtylyov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c669b5c commit ab10461

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,20 +1354,15 @@ static void ravb_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
13541354
{
13551355
struct ravb_private *priv = netdev_priv(ndev);
13561356

1357-
wol->supported = 0;
1358-
wol->wolopts = 0;
1359-
1360-
if (priv->clk) {
1361-
wol->supported = WAKE_MAGIC;
1362-
wol->wolopts = priv->wol_enabled ? WAKE_MAGIC : 0;
1363-
}
1357+
wol->supported = WAKE_MAGIC;
1358+
wol->wolopts = priv->wol_enabled ? WAKE_MAGIC : 0;
13641359
}
13651360

13661361
static int ravb_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
13671362
{
13681363
struct ravb_private *priv = netdev_priv(ndev);
13691364

1370-
if (!priv->clk || wol->wolopts & ~WAKE_MAGIC)
1365+
if (wol->wolopts & ~WAKE_MAGIC)
13711366
return -EOPNOTSUPP;
13721367

13731368
priv->wol_enabled = !!(wol->wolopts & WAKE_MAGIC);
@@ -1962,22 +1957,12 @@ MODULE_DEVICE_TABLE(of, ravb_match_table);
19621957

19631958
static int ravb_set_gti(struct net_device *ndev)
19641959
{
1965-
1960+
struct ravb_private *priv = netdev_priv(ndev);
19661961
struct device *dev = ndev->dev.parent;
1967-
struct device_node *np = dev->of_node;
19681962
unsigned long rate;
1969-
struct clk *clk;
19701963
uint64_t inc;
19711964

1972-
clk = of_clk_get(np, 0);
1973-
if (IS_ERR(clk)) {
1974-
dev_err(dev, "could not get clock\n");
1975-
return PTR_ERR(clk);
1976-
}
1977-
1978-
rate = clk_get_rate(clk);
1979-
clk_put(clk);
1980-
1965+
rate = clk_get_rate(priv->clk);
19811966
if (!rate)
19821967
return -EINVAL;
19831968

@@ -2126,10 +2111,11 @@ static int ravb_probe(struct platform_device *pdev)
21262111

21272112
priv->chip_id = chip_id;
21282113

2129-
/* Get clock, if not found that's OK but Wake-On-Lan is unavailable */
21302114
priv->clk = devm_clk_get(&pdev->dev, NULL);
2131-
if (IS_ERR(priv->clk))
2132-
priv->clk = NULL;
2115+
if (IS_ERR(priv->clk)) {
2116+
error = PTR_ERR(priv->clk);
2117+
goto out_release;
2118+
}
21332119

21342120
/* Set function */
21352121
ndev->netdev_ops = &ravb_netdev_ops;
@@ -2197,8 +2183,7 @@ static int ravb_probe(struct platform_device *pdev)
21972183
if (error)
21982184
goto out_napi_del;
21992185

2200-
if (priv->clk)
2201-
device_set_wakeup_capable(&pdev->dev, 1);
2186+
device_set_wakeup_capable(&pdev->dev, 1);
22022187

22032188
/* Print device information */
22042189
netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n",

0 commit comments

Comments
 (0)