[U-Boot,2/8] net: phy: dp83867: move static initialization to .probe()
diff mbox series

Message ID 20191118210447.7433-3-grygorii.strashko@ti.com
State Accepted
Commit ee622f03ccb8108482c58b15e0126f5b97a2b062
Delegated to: Joe Hershberger
Headers show
Series
  • net: phy: dp83867: ti: sync with linux kernel and
Related show

Commit Message

Grygorii Strashko Nov. 18, 2019, 9:04 p.m. UTC
Move static, one-time initialization to .probe() callback.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/phy/dp83867.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

Comments

Joe Hershberger Nov. 19, 2019, 9:39 p.m. UTC | #1
On Mon, Nov 18, 2019 at 3:08 PM Grygorii Strashko
<grygorii.strashko@ti.com> wrote:
>
> Move static, one-time initialization to .probe() callback.
>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

Patch
diff mbox series

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 7509936465..8dc2163342 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -204,18 +204,11 @@  static int dp83867_config(struct phy_device *phydev)
 	unsigned int val, delay, cfg2;
 	int ret, bs;
 
-	if (!phydev->priv) {
-		dp83867 = kzalloc(sizeof(*dp83867), GFP_KERNEL);
-		if (!dp83867)
-			return -ENOMEM;
+	dp83867 = (struct dp83867_private *)phydev->priv;
 
-		phydev->priv = dp83867;
-		ret = dp83867_of_init(phydev);
-		if (ret)
-			goto err_out;
-	} else {
-		dp83867 = (struct dp83867_private *)phydev->priv;
-	}
+	ret = dp83867_of_init(phydev);
+	if (ret)
+		return ret;
 
 	/* Restart the PHY.  */
 	val = phy_read(phydev, MDIO_DEVAD_NONE, DP83867_CTRL);
@@ -324,15 +317,27 @@  static int dp83867_config(struct phy_device *phydev)
 	return 0;
 
 err_out:
-	kfree(dp83867);
 	return ret;
 }
 
+static int dp83867_probe(struct phy_device *phydev)
+{
+	struct dp83867_private *dp83867;
+
+	dp83867 = kzalloc(sizeof(*dp83867), GFP_KERNEL);
+	if (!dp83867)
+		return -ENOMEM;
+
+	phydev->priv = dp83867;
+	return 0;
+}
+
 static struct phy_driver DP83867_driver = {
 	.name = "TI DP83867",
 	.uid = 0x2000a231,
 	.mask = 0xfffffff0,
 	.features = PHY_GBIT_FEATURES,
+	.probe = dp83867_probe,
 	.config = &dp83867_config,
 	.startup = &genphy_startup,
 	.shutdown = &genphy_shutdown,