lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191125215115.12981-3-ajayg@nvidia.com>
Date:   Mon, 25 Nov 2019 13:51:15 -0800
From:   Ajay Gupta <ajaykuee@...il.com>
To:     davem@...emloft.net
Cc:     netdev@...r.kernel.org, treding@...dia.com,
        Ajay Gupta <ajayg@...dia.com>
Subject: [PATCH 2/2] net: stmmac: dwc-qos: avoid clk and reset for acpi device

From: Ajay Gupta <ajayg@...dia.com>

There are no clocks or resets referenced by Tegra ACPI device
so don't access clocks or resets interface with ACPI device.

Clocks and resets for ACPI devices will be handled via ACPI
interface.

Signed-off-by: Ajay Gupta <ajayg@...dia.com>
---
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 122 ++++++++++--------
 1 file changed, 67 insertions(+), 55 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index f87306b3cdae..70e8c41f7761 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -272,6 +272,7 @@ static void *tegra_eqos_probe(struct platform_device *pdev,
 			      struct stmmac_resources *res)
 {
 	struct tegra_eqos *eqos;
+	struct device *dev = &pdev->dev;
 	int err;
 
 	eqos = devm_kzalloc(&pdev->dev, sizeof(*eqos), GFP_KERNEL);
@@ -283,77 +284,88 @@ static void *tegra_eqos_probe(struct platform_device *pdev,
 	eqos->dev = &pdev->dev;
 	eqos->regs = res->addr;
 
-	eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus");
-	if (IS_ERR(eqos->clk_master)) {
-		err = PTR_ERR(eqos->clk_master);
-		goto error;
-	}
+	if (is_of_node(dev->fwnode)) {
+		eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus");
+		if (IS_ERR(eqos->clk_master)) {
+			err = PTR_ERR(eqos->clk_master);
+			goto error;
+		}
 
-	err = clk_prepare_enable(eqos->clk_master);
-	if (err < 0)
-		goto error;
+		err = clk_prepare_enable(eqos->clk_master);
+		if (err < 0)
+			goto error;
 
-	eqos->clk_slave = devm_clk_get(&pdev->dev, "slave_bus");
-	if (IS_ERR(eqos->clk_slave)) {
-		err = PTR_ERR(eqos->clk_slave);
-		goto disable_master;
-	}
+		eqos->clk_slave = devm_clk_get(&pdev->dev, "slave_bus");
+		if (IS_ERR(eqos->clk_slave)) {
+			err = PTR_ERR(eqos->clk_slave);
+			goto disable_master;
+		}
 
-	data->stmmac_clk = eqos->clk_slave;
+		data->stmmac_clk = eqos->clk_slave;
 
-	err = clk_prepare_enable(eqos->clk_slave);
-	if (err < 0)
-		goto disable_master;
+		err = clk_prepare_enable(eqos->clk_slave);
+		if (err < 0)
+			goto disable_master;
 
-	eqos->clk_rx = devm_clk_get(&pdev->dev, "rx");
-	if (IS_ERR(eqos->clk_rx)) {
-		err = PTR_ERR(eqos->clk_rx);
-		goto disable_slave;
-	}
+		eqos->clk_rx = devm_clk_get(&pdev->dev, "rx");
+		if (IS_ERR(eqos->clk_rx)) {
+			err = PTR_ERR(eqos->clk_rx);
+			goto disable_slave;
+		}
 
-	err = clk_prepare_enable(eqos->clk_rx);
-	if (err < 0)
-		goto disable_slave;
+		err = clk_prepare_enable(eqos->clk_rx);
+		if (err < 0)
+			goto disable_slave;
 
-	eqos->clk_tx = devm_clk_get(&pdev->dev, "tx");
-	if (IS_ERR(eqos->clk_tx)) {
-		err = PTR_ERR(eqos->clk_tx);
-		goto disable_rx;
-	}
+		eqos->clk_tx = devm_clk_get(&pdev->dev, "tx");
+		if (IS_ERR(eqos->clk_tx)) {
+			err = PTR_ERR(eqos->clk_tx);
+			goto disable_rx;
+		}
 
-	err = clk_prepare_enable(eqos->clk_tx);
-	if (err < 0)
-		goto disable_rx;
+		err = clk_prepare_enable(eqos->clk_tx);
+		if (err < 0)
+			goto disable_rx;
 
-	eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH);
-	if (IS_ERR(eqos->reset)) {
-		err = PTR_ERR(eqos->reset);
-		goto disable_tx;
-	}
+		eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset",
+					     GPIOD_OUT_HIGH);
+		if (IS_ERR(eqos->reset)) {
+			err = PTR_ERR(eqos->reset);
+			goto disable_tx;
+		}
 
-	usleep_range(2000, 4000);
-	gpiod_set_value(eqos->reset, 0);
+		usleep_range(2000, 4000);
+		gpiod_set_value(eqos->reset, 0);
 
-	/* MDIO bus was already reset just above */
-	data->mdio_bus_data->needs_reset = false;
+		/* MDIO bus was already reset just above */
+		data->mdio_bus_data->needs_reset = false;
 
-	eqos->rst = devm_reset_control_get(&pdev->dev, "eqos");
-	if (IS_ERR(eqos->rst)) {
-		err = PTR_ERR(eqos->rst);
-		goto reset_phy;
-	}
+		eqos->rst = devm_reset_control_get(&pdev->dev, "eqos");
+		if (IS_ERR(eqos->rst)) {
+			err = PTR_ERR(eqos->rst);
+			goto reset_phy;
+		}
 
-	err = reset_control_assert(eqos->rst);
-	if (err < 0)
-		goto reset_phy;
+		err = reset_control_assert(eqos->rst);
+		if (err < 0)
+			goto reset_phy;
 
-	usleep_range(2000, 4000);
+		usleep_range(2000, 4000);
 
-	err = reset_control_deassert(eqos->rst);
-	if (err < 0)
-		goto reset_phy;
+		err = reset_control_deassert(eqos->rst);
+		if (err < 0)
+			goto reset_phy;
 
-	usleep_range(2000, 4000);
+		usleep_range(2000, 4000);
+	} else {
+		/* set clk and reset handle to NULL for non DT device */
+		eqos->clk_master = NULL;
+		eqos->clk_slave = NULL;
+		data->stmmac_clk = NULL;
+		eqos->clk_rx = NULL;
+		eqos->clk_tx = NULL;
+		eqos->reset = NULL;
+	}
 
 	data->fix_mac_speed = tegra_eqos_fix_speed;
 	data->init = tegra_eqos_init;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ