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]
Date:	Mon, 21 Mar 2011 17:37:34 +0100
From:	Lothar Waßmann <LW@...O-electronics.de>
To:	netdev@...r.kernel.org
Cc:	<u.kleine-koenig@...gutronix.de>,
	Shawn Guo <shawn.guo@...escale.com>,
	Lothar Waßmann <LW@...O-electronics.de>
Subject: [PATCH 2/4] drivers/net/fec: Use constants instead of magic numbers

- No functional change.

Signed-off-by: Lothar Waßmann <LW@...O-electronics.de>
---
 drivers/net/fec.c |   29 +++++++++++++++--------------
 drivers/net/fec.h |   15 +++++++++++++++
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index f00ee7f..2436db8 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -341,10 +341,10 @@ fec_restart(struct net_device *ndev, int duplex)
 				platform_get_device_id(fep->pdev);
 	int i;
 	u32 temp_mac[2];
-	u32 rcntl = OPT_FRAME_SIZE | 0x04;
+	u32 rcntl = OPT_FRAME_SIZE | FEC_R_CNTRL_MII_MODE;
 
 	/* Whack a reset.  We should wait for this. */
-	writel(1, fep->hwp + FEC_ECNTRL);
+	writel(FEC_ECNTRL_RESET, fep->hwp + FEC_ECNTRL);
 	udelay(10);
 
 	/*
@@ -391,10 +391,10 @@ fec_restart(struct net_device *ndev, int duplex)
 	/* Enable MII mode */
 	if (duplex) {
 		/* FD enable */
-		writel(0x04, fep->hwp + FEC_X_CNTRL);
+		writel(FEC_X_CNTRL_FDEN, fep->hwp + FEC_X_CNTRL);
 	} else {
 		/* No Rcv on Xmit */
-		rcntl |= 0x02;
+		rcntl |= FEC_R_CNTRL_DRT;
 		writel(0x0, fep->hwp + FEC_X_CNTRL);
 	}
 
@@ -409,19 +409,19 @@ fec_restart(struct net_device *ndev, int duplex)
 	 */
 	if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) {
 		/* Enable flow control and length check */
-		rcntl |= 0x40000000 | 0x00000020;
+		rcntl |= FEC_R_CNTRL_NO_LEN_CHK | FEC_R_CNTRL_FCE;
 
 		/* MII or RMII */
 		if (fep->phy_interface == PHY_INTERFACE_MODE_RMII)
-			rcntl |= (1 << 8);
+			rcntl |= FEC_R_CNTRL_RMII_MODE;
 		else
-			rcntl &= ~(1 << 8);
+			rcntl &= ~FEC_R_CNTRL_RMII_MODE;
 
 		/* 10M or 100M */
 		if (fep->phy_dev && fep->phy_dev->speed == SPEED_100)
-			rcntl &= ~(1 << 9);
+			rcntl &= ~FEC_R_CNTRL_RMII_10T;
 		else
-			rcntl |= (1 << 9);
+			rcntl |= FEC_R_CNTRL_RMII_10T;
 
 	} else {
 #ifdef FEC_MIIGSK_ENR
@@ -445,7 +445,7 @@ fec_restart(struct net_device *ndev, int duplex)
 	writel(rcntl, fep->hwp + FEC_R_CNTRL);
 
 	/* And last, enable the transmit and receive processing */
-	writel(2, fep->hwp + FEC_ECNTRL);
+	writel(FEC_ECNTRL_ETHER_EN, fep->hwp + FEC_ECNTRL);
 	writel(0, fep->hwp + FEC_R_DES_ACTIVE);
 
 	/* Enable interrupts we wish to service */
@@ -459,14 +459,15 @@ fec_stop(struct net_device *ndev)
 
 	/* We cannot expect a graceful transmit stop without link !!! */
 	if (fep->link) {
-		writel(1, fep->hwp + FEC_X_CNTRL); /* Graceful transmit stop */
+		/* Graceful transmit stop */
+		writel(FEC_X_CNTRL_GTS, fep->hwp + FEC_X_CNTRL);
 		udelay(10);
 		if (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_GRA))
 			printk("fec_stop : Graceful transmit stop did not complete !\n");
 	}
 
 	/* Whack a reset.  We should wait for this. */
-	writel(1, fep->hwp + FEC_ECNTRL);
+	writel(FEC_ECNTRL_RESET, fep->hwp + FEC_ECNTRL);
 	udelay(10);
 	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
 	writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
@@ -1198,13 +1199,13 @@ static void set_multicast_list(struct net_device *ndev)
 
 	if (ndev->flags & IFF_PROMISC) {
 		tmp = readl(fep->hwp + FEC_R_CNTRL);
-		tmp |= 0x8;
+		tmp |= FEC_R_CNTRL_PROM;
 		writel(tmp, fep->hwp + FEC_R_CNTRL);
 		return;
 	}
 
 	tmp = readl(fep->hwp + FEC_R_CNTRL);
-	tmp &= ~0x8;
+	tmp &= ~FEC_R_CNTRL_PROM;
 	writel(tmp, fep->hwp + FEC_R_CNTRL);
 
 	if (ndev->flags & IFF_ALLMULTI) {
diff --git a/drivers/net/fec.h b/drivers/net/fec.h
index 8697556..68f4049 100644
--- a/drivers/net/fec.h
+++ b/drivers/net/fec.h
@@ -144,5 +144,20 @@ struct bufdesc {
 #define BD_ENET_TX_STATS	((ushort)0x03ff)	/* All status bits */
 
 
+/* register bit assignments */
+#define FEC_ECNTRL_ETHER_EN		(1 << 1)
+#define FEC_ECNTRL_RESET		(1 << 0)
+
+#define FEC_X_CNTRL_GTS			(1 << 0)
+#define FEC_X_CNTRL_FDEN		(1 << 2)
+
+#define FEC_R_CNTRL_DRT			(1 << 1)
+#define FEC_R_CNTRL_MII_MODE		(1 << 2)
+#define FEC_R_CNTRL_PROM		(1 << 3)
+#define FEC_R_CNTRL_FCE			(1 << 5)
+#define FEC_R_CNTRL_RMII_MODE		(1 << 8)
+#define FEC_R_CNTRL_RMII_10T		(1 << 9)
+#define FEC_R_CNTRL_NO_LEN_CHK		(1 << 30)
+
 /****************************************************************************/
 #endif /* FEC_H */
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ