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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1239795145-27558-7-git-send-email-s.hauer@pengutronix.de>
Date:	Wed, 15 Apr 2009 13:32:19 +0200
From:	Sascha Hauer <s.hauer@...gutronix.de>
To:	netdev@...r.kernel.org
Cc:	Greg Ungerer <gerg@...pgear.com>,
	Sascha Hauer <s.hauer@...gutronix.de>
Subject: [PATCH 06/12] fec: refactor set_multicast_list() to make it more readable

Signed-off-by: Sascha Hauer <s.hauer@...gutronix.de>
---
 drivers/net/fec.c |   99 +++++++++++++++++++++++++++-------------------------
 1 files changed, 51 insertions(+), 48 deletions(-)

diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index ab8e66b..b72df48 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1518,57 +1518,60 @@ static void set_multicast_list(struct net_device *dev)
 		tmp = readl(fep->hwp + FEC_R_CNTRL);
 		tmp |= 0x8;
 		writel(tmp, fep->hwp + FEC_R_CNTRL);
-	} else {
-		tmp = readl(fep->hwp + FEC_R_CNTRL);
-		tmp &= ~0x8;
-		writel(tmp, fep->hwp + FEC_R_CNTRL);
+		return;
+	}
 
-		if (dev->flags & IFF_ALLMULTI) {
-			/* Catch all multicast addresses, so set the
-			 * filter to all 1's
-			 */
-			writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-			writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-		} else {
-			/* Clear filter and add the addresses in hash register
-			 */
-			writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-			writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-
-			dmi = dev->mc_list;
-
-			for (j = 0; j < dev->mc_count; j++, dmi = dmi->next) {
-				/* Only support group multicast for now */
-				if (!(dmi->dmi_addr[0] & 1))
-					continue;
-
-				/* calculate crc32 value of mac address */
-				crc = 0xffffffff;
-
-				for (i = 0; i < dmi->dmi_addrlen; i++) {
-					data = dmi->dmi_addr[i];
-					for (bit = 0; bit < 8; bit++, data >>= 1) {
-						crc = (crc >> 1) ^
-						(((crc ^ data) & 1) ? CRC32_POLY : 0);
-					}
-				}
-
-				/* only upper 6 bits (HASH_BITS) are used
-				 * which point to specific bit in he hash registers
-				 */
-				hash = (crc >> (32 - HASH_BITS)) & 0x3f;
-
-				if (hash > 31) {
-					tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-					tmp |= 1 << (hash - 32);
-					writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-				} else {
-					tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-					tmp |= 1 << hash;
-					writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-				}
+	tmp = readl(fep->hwp + FEC_R_CNTRL);
+	tmp &= ~0x8;
+	writel(tmp, fep->hwp + FEC_R_CNTRL);
+
+	if (dev->flags & IFF_ALLMULTI) {
+		/* Catch all multicast addresses, so set the
+		 * filter to all 1's
+		 */
+		writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+		writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+
+		return;
+	}
+
+	/* Clear filter and add the addresses in hash register
+	 */
+	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+
+	dmi = dev->mc_list;
+
+	for (j = 0; j < dev->mc_count; j++, dmi = dmi->next) {
+		/* Only support group multicast for now */
+		if (!(dmi->dmi_addr[0] & 1))
+			continue;
+
+		/* calculate crc32 value of mac address */
+		crc = 0xffffffff;
+
+		for (i = 0; i < dmi->dmi_addrlen; i++) {
+			data = dmi->dmi_addr[i];
+			for (bit = 0; bit < 8; bit++, data >>= 1) {
+				crc = (crc >> 1) ^
+				(((crc ^ data) & 1) ? CRC32_POLY : 0);
 			}
 		}
+
+		/* only upper 6 bits (HASH_BITS) are used
+		 * which point to specific bit in he hash registers
+		 */
+		hash = (crc >> (32 - HASH_BITS)) & 0x3f;
+
+		if (hash > 31) {
+			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+			tmp |= 1 << (hash - 32);
+			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+		} else {
+			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+			tmp |= 1 << hash;
+			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+		}
 	}
 }
 
-- 
1.6.2.1

--
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