[U-Boot] [PATCH v3 5/9] net: tsec: Common handling of MAC station address for DM_ETH

Vladimir Oltean olteanv at gmail.com
Thu Jul 18 21:29:57 UTC 2019


In tsec_init, the MAC address is retrieved from 2 different structures
depending on whether DM_ETH is enabled or not.

But since the field name is the same inside both structures, we can
conditionally define the structure of the correct type and simplify the
assignments.

Signed-off-by: Vladimir Oltean <olteanv at gmail.com>
Acked-by: Joe Hershberger <joe.hershberger at ni.com>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---
Changes from v2:

None.

Changes from v1:

None.

 drivers/net/tsec.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 1e20fe4cd246..f6278817330d 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -560,6 +560,8 @@ static int tsec_init(struct udevice *dev)
 	struct tsec_private *priv = (struct tsec_private *)dev->priv;
 #ifdef CONFIG_DM_ETH
 	struct eth_pdata *pdata = dev_get_platdata(dev);
+#else
+	struct eth_device *pdata = dev;
 #endif
 	struct tsec __iomem *regs = priv->regs;
 	u32 tempval;
@@ -580,21 +582,12 @@ static int tsec_init(struct udevice *dev)
 	 * order (BE), MACnADDR1 is set to 0xCDAB7856 and
 	 * MACnADDR2 is set to 0x34120000.
 	 */
-#ifndef CONFIG_DM_ETH
-	tempval = (dev->enetaddr[5] << 24) | (dev->enetaddr[4] << 16) |
-		  (dev->enetaddr[3] << 8)  |  dev->enetaddr[2];
-#else
 	tempval = (pdata->enetaddr[5] << 24) | (pdata->enetaddr[4] << 16) |
 		  (pdata->enetaddr[3] << 8)  |  pdata->enetaddr[2];
-#endif
 
 	out_be32(&regs->macstnaddr1, tempval);
 
-#ifndef CONFIG_DM_ETH
-	tempval = (dev->enetaddr[1] << 24) | (dev->enetaddr[0] << 16);
-#else
 	tempval = (pdata->enetaddr[1] << 24) | (pdata->enetaddr[0] << 16);
-#endif
 
 	out_be32(&regs->macstnaddr2, tempval);
 
-- 
2.17.1



More information about the U-Boot mailing list