From: Sascha Hauer <s.hauer@pengutronix.de>
To: netdev@vger.kernel.org
Cc: Greg Ungerer <gerg@snapgear.com>, Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 06/12] fec: refactor set_multicast_list() to make it more readable
Date: Wed, 15 Apr 2009 13:32:19 +0200 [thread overview]
Message-ID: <1239795145-27558-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1239795145-27558-6-git-send-email-s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.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
next prev parent reply other threads:[~2009-04-15 11:33 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-15 11:32 [PATCH] FEC driver: patches for -next Sascha Hauer
2009-04-15 11:32 ` [PATCH 01/12] fec: remove unused ifdef Sascha Hauer
2009-04-15 11:32 ` [PATCH 02/12] fec: switch to writel/readl Sascha Hauer
2009-04-15 11:32 ` [PATCH 03/12] fec: do not typedef struct types Sascha Hauer
2009-04-15 11:32 ` [PATCH 04/12] fec: remove unnecessary cast Sascha Hauer
2009-04-15 11:32 ` [PATCH 05/12] fec: Codingstyle cleanups Sascha Hauer
2009-04-15 11:32 ` Sascha Hauer [this message]
2009-04-15 11:32 ` [PATCH 07/12] fec: refactor init function Sascha Hauer
2009-04-15 11:32 ` [PATCH 08/12] fec: align receive packets Sascha Hauer
2009-04-15 11:32 ` [PATCH 09/12] fec: remove debugging printks Sascha Hauer
2009-04-15 11:32 ` [PATCH 10/12] fec: switch to net_device_ops Sascha Hauer
2009-04-15 11:32 ` [PATCH 11/12] FEC Buffer rework Sascha Hauer
2009-04-15 11:32 ` [PATCH 12/12] fec: call fec_restart() in fec_open() Sascha Hauer
2009-04-16 9:38 ` David Miller
2009-04-16 9:38 ` [PATCH 11/12] FEC Buffer rework David Miller
2009-04-17 10:07 ` Greg Ungerer
2009-04-17 10:12 ` Sascha Hauer
2009-04-16 9:37 ` [PATCH 10/12] fec: switch to net_device_ops David Miller
2009-04-16 9:37 ` [PATCH 09/12] fec: remove debugging printks David Miller
2009-04-16 9:37 ` [PATCH 08/12] fec: align receive packets David Miller
2009-04-16 9:37 ` [PATCH 07/12] fec: refactor init function David Miller
2009-04-16 9:37 ` [PATCH 06/12] fec: refactor set_multicast_list() to make it more readable David Miller
2009-04-16 9:36 ` [PATCH 05/12] fec: Codingstyle cleanups David Miller
2009-04-16 9:36 ` [PATCH 04/12] fec: remove unnecessary cast David Miller
2009-04-16 9:36 ` [PATCH 03/12] fec: do not typedef struct types David Miller
2009-04-15 13:11 ` [PATCH 02/12] fec: switch to writel/readl Sascha Hauer
2009-04-16 9:36 ` David Miller
2009-04-15 12:12 ` [PATCH] FEC driver: patches for -next Greg Ungerer
2009-04-15 12:55 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1239795145-27558-7-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=gerg@snapgear.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).