aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/mv643xx_eth.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-09-09 20:40:56 -0400
committerDavid S. Miller <davem@davemloft.net>2015-09-15 15:49:11 -0400
commit8b711d6db5c78a6d1969fb0fccb93daa7df53762 (patch)
treeecc9bb2d084a7048f3fd3374c931acc1066e44a4 /drivers/net/ethernet/marvell/mv643xx_eth.c
parent29feb66a9afbe69d3aeb2550f2e0ea20d4782ead (diff)
mv643xx_eth: Neaten mv643xx_eth_program_multicast_filter
The code around the allocation and loops are a bit obfuscated. Neaten it by using: o kcalloc with decimal count and sizeof(u32) o Decimal loop indexing and i++ not i += 4 o A promiscuous block using a similar style to the multicast block o Remove unnecessary variables Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell/mv643xx_eth.c')
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 960169efe636..c78ae1868097 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1845,29 +1845,19 @@ static void mv643xx_eth_program_multicast_filter(struct net_device *dev)
1845 struct netdev_hw_addr *ha; 1845 struct netdev_hw_addr *ha;
1846 int i; 1846 int i;
1847 1847
1848 if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) { 1848 if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI))
1849 int port_num; 1849 goto promiscuous;
1850 u32 accept;
1851 1850
1852oom: 1851 /* Allocate both mc_spec and mc_other tables */
1853 port_num = mp->port_num; 1852 mc_spec = kcalloc(128, sizeof(u32), GFP_ATOMIC);
1854 accept = 0x01010101; 1853 if (!mc_spec)
1855 for (i = 0; i < 0x100; i += 4) { 1854 goto promiscuous;
1856 wrl(mp, SPECIAL_MCAST_TABLE(port_num) + i, accept); 1855 mc_other = &mc_spec[64];
1857 wrl(mp, OTHER_MCAST_TABLE(port_num) + i, accept);
1858 }
1859 return;
1860 }
1861
1862 mc_spec = kzalloc(0x200, GFP_ATOMIC);
1863 if (mc_spec == NULL)
1864 goto oom;
1865 mc_other = mc_spec + (0x100 >> 2);
1866 1856
1867 netdev_for_each_mc_addr(ha, dev) { 1857 netdev_for_each_mc_addr(ha, dev) {
1868 u8 *a = ha->addr; 1858 u8 *a = ha->addr;
1869 u32 *table; 1859 u32 *table;
1870 int entry; 1860 u8 entry;
1871 1861
1872 if (memcmp(a, "\x01\x00\x5e\x00\x00", 5) == 0) { 1862 if (memcmp(a, "\x01\x00\x5e\x00\x00", 5) == 0) {
1873 table = mc_spec; 1863 table = mc_spec;
@@ -1880,12 +1870,23 @@ oom:
1880 table[entry >> 2] |= 1 << (8 * (entry & 3)); 1870 table[entry >> 2] |= 1 << (8 * (entry & 3));
1881 } 1871 }
1882 1872
1883 for (i = 0; i < 0x100; i += 4) { 1873 for (i = 0; i < 64; i++) {
1884 wrl(mp, SPECIAL_MCAST_TABLE(mp->port_num) + i, mc_spec[i >> 2]); 1874 wrl(mp, SPECIAL_MCAST_TABLE(mp->port_num) + i * sizeof(u32),
1885 wrl(mp, OTHER_MCAST_TABLE(mp->port_num) + i, mc_other[i >> 2]); 1875 mc_spec[i]);
1876 wrl(mp, OTHER_MCAST_TABLE(mp->port_num) + i * sizeof(u32),
1877 mc_other[i]);
1886 } 1878 }
1887 1879
1888 kfree(mc_spec); 1880 kfree(mc_spec);
1881 return;
1882
1883promiscuous:
1884 for (i = 0; i < 64; i++) {
1885 wrl(mp, SPECIAL_MCAST_TABLE(mp->port_num) + i * sizeof(u32),
1886 0x01010101u);
1887 wrl(mp, OTHER_MCAST_TABLE(mp->port_num) + i * sizeof(u32),
1888 0x01010101u);
1889 }
1889} 1890}
1890 1891
1891static void mv643xx_eth_set_rx_mode(struct net_device *dev) 1892static void mv643xx_eth_set_rx_mode(struct net_device *dev)