[PATCH 2/3] net: eqos: imx: move common stuff to probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



eqos_init_imx() currently is i.MX8 specific, but some stuff can be used
by i.MX9 as well. Move that to probe().

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/net/designware_imx.c | 50 ++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/drivers/net/designware_imx.c b/drivers/net/designware_imx.c
index 00164fa7c7..13bca42c25 100644
--- a/drivers/net/designware_imx.c
+++ b/drivers/net/designware_imx.c
@@ -115,11 +115,6 @@ static int eqos_init_imx(struct device *dev, struct eqos *eqos)
 	struct eqos_imx_priv *priv = eqos->priv;
 	int ret;
 
-	priv->dev = dev;
-
-	if (of_get_property(np, "snps,rmii_refclk_ext", NULL))
-		priv->rmii_refclk_ext = true;
-
 	if (of_device_is_compatible(np, "nxp,imx8mp-dwmac-eqos")) {
 		priv->intf_regmap = syscon_regmap_lookup_by_phandle(np, "intf_mode");
 		if (IS_ERR(priv->intf_regmap))
@@ -132,22 +127,6 @@ static int eqos_init_imx(struct device *dev, struct eqos *eqos)
 		}
 	}
 
-	priv->num_clks = ARRAY_SIZE(imx_clks);
-	priv->clks = xmalloc(priv->num_clks * sizeof(*priv->clks));
-	memcpy(priv->clks, imx_clks, sizeof imx_clks);
-
-	ret = clk_bulk_get(dev, priv->num_clks, priv->clks);
-	if (ret) {
-		dev_err(dev, "Failed to get clks: %s\n", strerror(-ret));
-		return ret;
-	}
-
-	ret = clk_bulk_enable(priv->num_clks, priv->clks);
-	if (ret) {
-		dev_err(dev, "Failed to enable clks: %s\n", strerror(-ret));
-		return ret;
-	}
-
 	eqos_imx_set_interface_mode(eqos);
 
 	return 0;
@@ -166,7 +145,34 @@ static struct eqos_ops imx_ops = {
 
 static int eqos_probe_imx(struct device *dev)
 {
-	return eqos_probe(dev, &imx_ops, xzalloc(sizeof(struct eqos_imx_priv)));
+	struct device_node *np = dev->device_node;
+	struct eqos_imx_priv *priv;
+	int ret;
+
+	priv = xzalloc(sizeof(*priv));
+
+	priv->dev = dev;
+
+	if (of_get_property(np, "snps,rmii_refclk_ext", NULL))
+		priv->rmii_refclk_ext = true;
+
+	priv->num_clks = ARRAY_SIZE(imx_clks);
+	priv->clks = xmalloc(priv->num_clks * sizeof(*priv->clks));
+	memcpy(priv->clks, imx_clks, sizeof imx_clks);
+
+	ret = clk_bulk_get(dev, priv->num_clks, priv->clks);
+	if (ret) {
+		dev_err(dev, "Failed to get clks: %s\n", strerror(-ret));
+		return ret;
+	}
+
+	ret = clk_bulk_enable(priv->num_clks, priv->clks);
+	if (ret) {
+		dev_err(dev, "Failed to enable clks: %s\n", strerror(-ret));
+		return ret;
+	}
+
+	return eqos_probe(dev, &imx_ops, priv);
 }
 
 static void eqos_remove_imx(struct device *dev)
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux