From 78378454e7978ea3b4128822880677e6efa9ddef Mon Sep 17 00:00:00 2001
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: Mon, 6 Jan 2020 14:31:22 +0200
Subject: [PATCH] Revert "enetc: export enetc_mdio definitionns to
 include/linux/fsl"

This reverts commit f8d80c003b76f397696bf887ebbd37a78781c050.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/freescale/enetc/enetc_mdio.c  | 18 +---------
 drivers/net/ethernet/freescale/enetc/enetc_mdio.h  | 12 +++++++
 .../net/ethernet/freescale/enetc/enetc_pci_mdio.c  | 41 +++++++++-------------
 include/linux/fsl/enetc_mdio.h                     | 21 -----------
 4 files changed, 30 insertions(+), 62 deletions(-)
 create mode 100644 drivers/net/ethernet/freescale/enetc/enetc_mdio.h
 delete mode 100644 include/linux/fsl/enetc_mdio.h

--- a/drivers/net/ethernet/freescale/enetc/enetc_mdio.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_mdio.c
@@ -1,13 +1,13 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
 /* Copyright 2019 NXP */
 
-#include <linux/fsl/enetc_mdio.h>
 #include <linux/mdio.h>
 #include <linux/of_mdio.h>
 #include <linux/iopoll.h>
 #include <linux/of.h>
 
 #include "enetc_pf.h"
+#include "enetc_mdio.h"
 
 #define	ENETC_MDIO_CFG	0x0	/* MDIO configuration and status */
 #define	ENETC_MDIO_CTL	0x4	/* MDIO control */
@@ -99,7 +99,6 @@ int enetc_mdio_write(struct mii_bus *bus
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(enetc_mdio_write);
 
 int enetc_mdio_read(struct mii_bus *bus, int phy_id, int regnum)
 {
@@ -155,21 +154,6 @@ int enetc_mdio_read(struct mii_bus *bus,
 
 	return value;
 }
-EXPORT_SYMBOL_GPL(enetc_mdio_read);
-
-struct enetc_hw *enetc_hw_alloc(struct device *dev, void __iomem *port_regs)
-{
-	struct enetc_hw *hw;
-
-	hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
-	if (!hw)
-		return ERR_PTR(-ENOMEM);
-
-	hw->port = port_regs;
-
-	return hw;
-}
-EXPORT_SYMBOL_GPL(enetc_hw_alloc);
 
 int enetc_mdio_probe(struct enetc_pf *pf)
 {
--- /dev/null
+++ b/drivers/net/ethernet/freescale/enetc/enetc_mdio.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+/* Copyright 2019 NXP */
+
+#include <linux/phy.h>
+
+struct enetc_mdio_priv {
+	struct enetc_hw *hw;
+	int mdio_base;
+};
+
+int enetc_mdio_write(struct mii_bus *bus, int phy_id, int regnum, u16 value);
+int enetc_mdio_read(struct mii_bus *bus, int phy_id, int regnum);
--- a/drivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
 /* Copyright 2019 NXP */
-#include <linux/fsl/enetc_mdio.h>
 #include <linux/of_mdio.h>
 #include "enetc_pf.h"
+#include "enetc_mdio.h"
 
 #define ENETC_MDIO_DEV_ID	0xee01
 #define ENETC_MDIO_DEV_NAME	"FSL PCIe IE Central MDIO"
@@ -14,29 +14,17 @@ static int enetc_pci_mdio_probe(struct p
 {
 	struct enetc_mdio_priv *mdio_priv;
 	struct device *dev = &pdev->dev;
-	void __iomem *port_regs;
 	struct enetc_hw *hw;
 	struct mii_bus *bus;
 	int err;
 
-	port_regs = pci_iomap(pdev, 0, 0);
-	if (!port_regs) {
-		dev_err(dev, "iomap failed\n");
-		err = -ENXIO;
-		goto err_ioremap;
-	}
-
-	hw = enetc_hw_alloc(dev, port_regs);
-	if (IS_ERR(enetc_hw_alloc)) {
-		err = PTR_ERR(hw);
-		goto err_hw_alloc;
-	}
+	hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
+	if (!hw)
+		return -ENOMEM;
 
 	bus = devm_mdiobus_alloc_size(dev, sizeof(*mdio_priv));
-	if (!bus) {
-		err = -ENOMEM;
-		goto err_mdiobus_alloc;
-	}
+	if (!bus)
+		return -ENOMEM;
 
 	bus->name = ENETC_MDIO_BUS_NAME;
 	bus->read = enetc_mdio_read;
@@ -51,7 +39,7 @@ static int enetc_pci_mdio_probe(struct p
 	err = pci_enable_device_mem(pdev);
 	if (err) {
 		dev_err(dev, "device enable failed\n");
-		goto err_pci_enable;
+		return err;
 	}
 
 	err = pci_request_region(pdev, 0, KBUILD_MODNAME);
@@ -60,6 +48,13 @@ static int enetc_pci_mdio_probe(struct p
 		goto err_pci_mem_reg;
 	}
 
+	hw->port = pci_iomap(pdev, 0, 0);
+	if (!hw->port) {
+		err = -ENXIO;
+		dev_err(dev, "iomap failed\n");
+		goto err_ioremap;
+	}
+
 	err = of_mdiobus_register(bus, dev->of_node);
 	if (err)
 		goto err_mdiobus_reg;
@@ -69,14 +64,12 @@ static int enetc_pci_mdio_probe(struct p
 	return 0;
 
 err_mdiobus_reg:
+	iounmap(mdio_priv->hw->port);
+err_ioremap:
 	pci_release_mem_regions(pdev);
 err_pci_mem_reg:
 	pci_disable_device(pdev);
-err_pci_enable:
-err_mdiobus_alloc:
-	iounmap(port_regs);
-err_hw_alloc:
-err_ioremap:
+
 	return err;
 }
 
--- a/include/linux/fsl/enetc_mdio.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
-/* Copyright 2019 NXP */
-
-#include <linux/phy.h>
-
-/* PCS registers */
-#define ENETC_PCS_LINK_TIMER1		0x12
-#define ENETC_PCS_LINK_TIMER1_VAL	0x06a0
-#define ENETC_PCS_LINK_TIMER2		0x13
-#define ENETC_PCS_LINK_TIMER2_VAL	0x0003
-#define ENETC_PCS_IF_MODE		0x14
-#define ENETC_PCS_IF_MODE_SGMII_AN	0x0003
-
-struct enetc_mdio_priv {
-	struct enetc_hw *hw;
-	int mdio_base;
-};
-
-int enetc_mdio_write(struct mii_bus *bus, int phy_id, int regnum, u16 value);
-int enetc_mdio_read(struct mii_bus *bus, int phy_id, int regnum);
-struct enetc_hw *enetc_hw_alloc(struct device *dev, void __iomem *port_regs);
