diff options
author | Jiri Pirko <jpirko@redhat.com> | 2010-02-19 03:48:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-19 16:15:50 -0500 |
commit | 91fea5858418127ad33e0060f726c62be0047eaf (patch) | |
tree | 3630384b91fe22565ac4eadc7dddd0d7720bf958 /drivers | |
parent | 2f1eb65f366b81aa3c22c31e6e8db26168777ec5 (diff) |
net/pcmcia: convert to use netdev_for_each_mc_addr
removed fill_multicast_tbl function in smc91c92_cs and do the work inline
rewritten set_addresses function in xirc2ps_cs. This was kinda headache.
Simulated the original and new functions and they bahave the same.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/pcmcia/axnet_cs.c | 7 | ||||
-rw-r--r-- | drivers/net/pcmcia/fmvj18x_cs.c | 6 | ||||
-rw-r--r-- | drivers/net/pcmcia/nmclan_cs.c | 6 | ||||
-rw-r--r-- | drivers/net/pcmcia/smc91c92_cs.c | 33 | ||||
-rw-r--r-- | drivers/net/pcmcia/xirc2ps_cs.c | 84 |
5 files changed, 67 insertions, 69 deletions
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 2ee57bd52a01..d90e0fcdbce1 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -1625,8 +1625,7 @@ static inline void make_mc_bits(u8 *bits, struct net_device *dev) | |||
1625 | struct dev_mc_list *dmi; | 1625 | struct dev_mc_list *dmi; |
1626 | u32 crc; | 1626 | u32 crc; |
1627 | 1627 | ||
1628 | for (dmi=dev->mc_list; dmi; dmi=dmi->next) { | 1628 | netdev_for_each_mc_addr(dmi, dev) { |
1629 | |||
1630 | crc = ether_crc(ETH_ALEN, dmi->dmi_addr); | 1629 | crc = ether_crc(ETH_ALEN, dmi->dmi_addr); |
1631 | /* | 1630 | /* |
1632 | * The 8390 uses the 6 most significant bits of the | 1631 | * The 8390 uses the 6 most significant bits of the |
@@ -1652,7 +1651,7 @@ static void do_set_multicast_list(struct net_device *dev) | |||
1652 | 1651 | ||
1653 | if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) { | 1652 | if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) { |
1654 | memset(ei_local->mcfilter, 0, 8); | 1653 | memset(ei_local->mcfilter, 0, 8); |
1655 | if (dev->mc_list) | 1654 | if (!netdev_mc_empty(dev)) |
1656 | make_mc_bits(ei_local->mcfilter, dev); | 1655 | make_mc_bits(ei_local->mcfilter, dev); |
1657 | } else { | 1656 | } else { |
1658 | /* set to accept-all */ | 1657 | /* set to accept-all */ |
@@ -1668,7 +1667,7 @@ static void do_set_multicast_list(struct net_device *dev) | |||
1668 | 1667 | ||
1669 | if(dev->flags&IFF_PROMISC) | 1668 | if(dev->flags&IFF_PROMISC) |
1670 | outb_p(E8390_RXCONFIG | 0x58, e8390_base + EN0_RXCR); | 1669 | outb_p(E8390_RXCONFIG | 0x58, e8390_base + EN0_RXCR); |
1671 | else if(dev->flags&IFF_ALLMULTI || dev->mc_list) | 1670 | else if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) |
1672 | outb_p(E8390_RXCONFIG | 0x48, e8390_base + EN0_RXCR); | 1671 | outb_p(E8390_RXCONFIG | 0x48, e8390_base + EN0_RXCR); |
1673 | else | 1672 | else |
1674 | outb_p(E8390_RXCONFIG | 0x40, e8390_base + EN0_RXCR); | 1673 | outb_p(E8390_RXCONFIG | 0x40, e8390_base + EN0_RXCR); |
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 3d573ed5f7c5..b9dc80b9d04a 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c | |||
@@ -1199,10 +1199,8 @@ static void set_rx_mode(struct net_device *dev) | |||
1199 | struct dev_mc_list *mclist; | 1199 | struct dev_mc_list *mclist; |
1200 | 1200 | ||
1201 | memset(mc_filter, 0, sizeof(mc_filter)); | 1201 | memset(mc_filter, 0, sizeof(mc_filter)); |
1202 | for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev); | 1202 | netdev_for_each_mc_addr(mclist, dev) { |
1203 | i++, mclist = mclist->next) { | 1203 | unsigned int bit = ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26; |
1204 | unsigned int bit = | ||
1205 | ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26; | ||
1206 | mc_filter[bit >> 3] |= (1 << (bit & 7)); | 1204 | mc_filter[bit >> 3] |= (1 << (bit & 7)); |
1207 | } | 1205 | } |
1208 | outb(2, ioaddr + RX_MODE); /* Use normal mode. */ | 1206 | outb(2, ioaddr + RX_MODE); /* Use normal mode. */ |
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index c42a31a97fa3..c717b143f11a 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c | |||
@@ -1475,8 +1475,7 @@ static void set_multicast_list(struct net_device *dev) | |||
1475 | { | 1475 | { |
1476 | mace_private *lp = netdev_priv(dev); | 1476 | mace_private *lp = netdev_priv(dev); |
1477 | int adr[ETHER_ADDR_LEN] = {0}; /* Ethernet address */ | 1477 | int adr[ETHER_ADDR_LEN] = {0}; /* Ethernet address */ |
1478 | int i; | 1478 | struct dev_mc_list *dmi; |
1479 | struct dev_mc_list *dmi = dev->mc_list; | ||
1480 | 1479 | ||
1481 | #ifdef PCMCIA_DEBUG | 1480 | #ifdef PCMCIA_DEBUG |
1482 | { | 1481 | { |
@@ -1496,9 +1495,8 @@ static void set_multicast_list(struct net_device *dev) | |||
1496 | if (num_addrs > 0) { | 1495 | if (num_addrs > 0) { |
1497 | /* Calculate multicast logical address filter */ | 1496 | /* Calculate multicast logical address filter */ |
1498 | memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN); | 1497 | memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN); |
1499 | for (i = 0; i < netdev_mc_count(dev); i++) { | 1498 | netdev_for_each_mc_addr(dmi, dev) { |
1500 | memcpy(adr, dmi->dmi_addr, ETHER_ADDR_LEN); | 1499 | memcpy(adr, dmi->dmi_addr, ETHER_ADDR_LEN); |
1501 | dmi = dmi->next; | ||
1502 | BuildLAF(lp->multicast_ladrf, adr); | 1500 | BuildLAF(lp->multicast_ladrf, adr); |
1503 | } | 1501 | } |
1504 | } | 1502 | } |
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index d2e86b8887c8..d29c22a80a06 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -1595,27 +1595,6 @@ static void smc_rx(struct net_device *dev) | |||
1595 | 1595 | ||
1596 | /*====================================================================== | 1596 | /*====================================================================== |
1597 | 1597 | ||
1598 | Calculate values for the hardware multicast filter hash table. | ||
1599 | |||
1600 | ======================================================================*/ | ||
1601 | |||
1602 | static void fill_multicast_tbl(int count, struct dev_mc_list *addrs, | ||
1603 | u_char *multicast_table) | ||
1604 | { | ||
1605 | struct dev_mc_list *mc_addr; | ||
1606 | |||
1607 | for (mc_addr = addrs; mc_addr && count-- > 0; mc_addr = mc_addr->next) { | ||
1608 | u_int position = ether_crc(6, mc_addr->dmi_addr); | ||
1609 | #ifndef final_version /* Verify multicast address. */ | ||
1610 | if ((mc_addr->dmi_addr[0] & 1) == 0) | ||
1611 | continue; | ||
1612 | #endif | ||
1613 | multicast_table[position >> 29] |= 1 << ((position >> 26) & 7); | ||
1614 | } | ||
1615 | } | ||
1616 | |||
1617 | /*====================================================================== | ||
1618 | |||
1619 | Set the receive mode. | 1598 | Set the receive mode. |
1620 | 1599 | ||
1621 | This routine is used by both the protocol level to notify us of | 1600 | This routine is used by both the protocol level to notify us of |
@@ -1639,8 +1618,16 @@ static void set_rx_mode(struct net_device *dev) | |||
1639 | rx_cfg_setting = RxStripCRC | RxEnable | RxAllMulti; | 1618 | rx_cfg_setting = RxStripCRC | RxEnable | RxAllMulti; |
1640 | else { | 1619 | else { |
1641 | if (!netdev_mc_empty(dev)) { | 1620 | if (!netdev_mc_empty(dev)) { |
1642 | fill_multicast_tbl(netdev_mc_count(dev), dev->mc_list, | 1621 | struct dev_mc_list *mc_addr; |
1643 | (u_char *)multicast_table); | 1622 | |
1623 | netdev_for_each_mc_addr(mc_addr, dev) { | ||
1624 | u_int position = ether_crc(6, mc_addr->dmi_addr); | ||
1625 | #ifndef final_version /* Verify multicast address. */ | ||
1626 | if ((mc_addr->dmi_addr[0] & 1) == 0) | ||
1627 | continue; | ||
1628 | #endif | ||
1629 | multicast_table[position >> 29] |= 1 << ((position >> 26) & 7); | ||
1630 | } | ||
1644 | } | 1631 | } |
1645 | rx_cfg_setting = RxStripCRC | RxEnable; | 1632 | rx_cfg_setting = RxStripCRC | RxEnable; |
1646 | } | 1633 | } |
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index 4ace18a71152..4d1802e457be 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -1364,47 +1364,63 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1364 | return NETDEV_TX_OK; | 1364 | return NETDEV_TX_OK; |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | struct set_address_info { | ||
1368 | int reg_nr; | ||
1369 | int page_nr; | ||
1370 | int mohawk; | ||
1371 | unsigned int ioaddr; | ||
1372 | }; | ||
1373 | |||
1374 | static void set_address(struct set_address_info *sa_info, char *addr) | ||
1375 | { | ||
1376 | unsigned int ioaddr = sa_info->ioaddr; | ||
1377 | int i; | ||
1378 | |||
1379 | for (i = 0; i < 6; i++) { | ||
1380 | if (sa_info->reg_nr > 15) { | ||
1381 | sa_info->reg_nr = 8; | ||
1382 | sa_info->page_nr++; | ||
1383 | SelectPage(sa_info->page_nr); | ||
1384 | } | ||
1385 | if (sa_info->mohawk) | ||
1386 | PutByte(sa_info->reg_nr++, addr[5 - i]); | ||
1387 | else | ||
1388 | PutByte(sa_info->reg_nr++, addr[i]); | ||
1389 | } | ||
1390 | } | ||
1391 | |||
1367 | /**************** | 1392 | /**************** |
1368 | * Set all addresses: This first one is the individual address, | 1393 | * Set all addresses: This first one is the individual address, |
1369 | * the next 9 addresses are taken from the multicast list and | 1394 | * the next 9 addresses are taken from the multicast list and |
1370 | * the rest is filled with the individual address. | 1395 | * the rest is filled with the individual address. |
1371 | */ | 1396 | */ |
1372 | static void | 1397 | static void set_addresses(struct net_device *dev) |
1373 | set_addresses(struct net_device *dev) | ||
1374 | { | 1398 | { |
1375 | unsigned int ioaddr = dev->base_addr; | 1399 | unsigned int ioaddr = dev->base_addr; |
1376 | local_info_t *lp = netdev_priv(dev); | 1400 | local_info_t *lp = netdev_priv(dev); |
1377 | struct dev_mc_list *dmi = dev->mc_list; | 1401 | struct dev_mc_list *dmi; |
1378 | unsigned char *addr; | 1402 | struct set_address_info sa_info; |
1379 | int i,j,k,n; | 1403 | int i; |
1380 | |||
1381 | SelectPage(k=0x50); | ||
1382 | for (i=0,j=8,n=0; ; i++, j++) { | ||
1383 | if (i > 5) { | ||
1384 | if (++n > 9) | ||
1385 | break; | ||
1386 | i = 0; | ||
1387 | if (n > 1 && n <= netdev_mc_count(dev) && dmi) { | ||
1388 | dmi = dmi->next; | ||
1389 | } | ||
1390 | } | ||
1391 | if (j > 15) { | ||
1392 | j = 8; | ||
1393 | k++; | ||
1394 | SelectPage(k); | ||
1395 | } | ||
1396 | |||
1397 | if (n && n <= netdev_mc_count(dev) && dmi) | ||
1398 | addr = dmi->dmi_addr; | ||
1399 | else | ||
1400 | addr = dev->dev_addr; | ||
1401 | 1404 | ||
1402 | if (lp->mohawk) | 1405 | /* |
1403 | PutByte(j, addr[5-i]); | 1406 | * Setup the info structure so that by first set_address call it will do |
1404 | else | 1407 | * SelectPage with the right page number. Hence these ones here. |
1405 | PutByte(j, addr[i]); | 1408 | */ |
1406 | } | 1409 | sa_info.reg_nr = 15 + 1; |
1407 | SelectPage(0); | 1410 | sa_info.page_nr = 0x50 - 1; |
1411 | sa_info.mohawk = lp->mohawk; | ||
1412 | sa_info.ioaddr = ioaddr; | ||
1413 | |||
1414 | set_address(&sa_info, dev->dev_addr); | ||
1415 | i = 0; | ||
1416 | netdev_for_each_mc_addr(dmi, dev) { | ||
1417 | if (i++ == 9) | ||
1418 | break; | ||
1419 | set_address(&sa_info, dmi->dmi_addr); | ||
1420 | } | ||
1421 | while (i++ < 9) | ||
1422 | set_address(&sa_info, dev->dev_addr); | ||
1423 | SelectPage(0); | ||
1408 | } | 1424 | } |
1409 | 1425 | ||
1410 | /**************** | 1426 | /**************** |