浏览代码

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 <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Geert Uytterhoeven 7 年之前
父节点
当前提交
ab104615e0
共有 1 个文件被更改,包括 10 次插入25 次删除
  1. 10 25
      drivers/net/ethernet/renesas/ravb_main.c

+ 10 - 25
drivers/net/ethernet/renesas/ravb_main.c

@@ -1354,20 +1354,15 @@ static void ravb_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
 {
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 	struct ravb_private *priv = netdev_priv(ndev);
 
 
-	wol->supported = 0;
-	wol->wolopts = 0;
-
-	if (priv->clk) {
-		wol->supported = WAKE_MAGIC;
-		wol->wolopts = priv->wol_enabled ? WAKE_MAGIC : 0;
-	}
+	wol->supported = WAKE_MAGIC;
+	wol->wolopts = priv->wol_enabled ? WAKE_MAGIC : 0;
 }
 }
 
 
 static int ravb_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
 static int ravb_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
 {
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 	struct ravb_private *priv = netdev_priv(ndev);
 
 
-	if (!priv->clk || wol->wolopts & ~WAKE_MAGIC)
+	if (wol->wolopts & ~WAKE_MAGIC)
 		return -EOPNOTSUPP;
 		return -EOPNOTSUPP;
 
 
 	priv->wol_enabled = !!(wol->wolopts & WAKE_MAGIC);
 	priv->wol_enabled = !!(wol->wolopts & WAKE_MAGIC);
@@ -1962,22 +1957,12 @@ MODULE_DEVICE_TABLE(of, ravb_match_table);
 
 
 static int ravb_set_gti(struct net_device *ndev)
 static int ravb_set_gti(struct net_device *ndev)
 {
 {
-
+	struct ravb_private *priv = netdev_priv(ndev);
 	struct device *dev = ndev->dev.parent;
 	struct device *dev = ndev->dev.parent;
-	struct device_node *np = dev->of_node;
 	unsigned long rate;
 	unsigned long rate;
-	struct clk *clk;
 	uint64_t inc;
 	uint64_t inc;
 
 
-	clk = of_clk_get(np, 0);
-	if (IS_ERR(clk)) {
-		dev_err(dev, "could not get clock\n");
-		return PTR_ERR(clk);
-	}
-
-	rate = clk_get_rate(clk);
-	clk_put(clk);
-
+	rate = clk_get_rate(priv->clk);
 	if (!rate)
 	if (!rate)
 		return -EINVAL;
 		return -EINVAL;
 
 
@@ -2126,10 +2111,11 @@ static int ravb_probe(struct platform_device *pdev)
 
 
 	priv->chip_id = chip_id;
 	priv->chip_id = chip_id;
 
 
-	/* Get clock, if not found that's OK but Wake-On-Lan is unavailable */
 	priv->clk = devm_clk_get(&pdev->dev, NULL);
 	priv->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(priv->clk))
-		priv->clk = NULL;
+	if (IS_ERR(priv->clk)) {
+		error = PTR_ERR(priv->clk);
+		goto out_release;
+	}
 
 
 	/* Set function */
 	/* Set function */
 	ndev->netdev_ops = &ravb_netdev_ops;
 	ndev->netdev_ops = &ravb_netdev_ops;
@@ -2197,8 +2183,7 @@ static int ravb_probe(struct platform_device *pdev)
 	if (error)
 	if (error)
 		goto out_napi_del;
 		goto out_napi_del;
 
 
-	if (priv->clk)
-		device_set_wakeup_capable(&pdev->dev, 1);
+	device_set_wakeup_capable(&pdev->dev, 1);
 
 
 	/* Print device information */
 	/* Print device information */
 	netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n",
 	netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n",