aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/greth.c
diff options
context:
space:
mode:
authorkirjanov@gmail.com <kirjanov@gmail.com>2010-02-19 00:00:52 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-19 16:15:51 -0500
commit6e03718c852a7b2ce756e37ae340f4ebfec2f6f3 (patch)
tree757de27224214a865b55983ee79c7ba3301c777f /drivers/net/greth.c
parent91fea5858418127ad33e0060f726c62be0047eaf (diff)
greth: some driver cleanups
On Fri, Feb 19, 2010 at 13:51 +0100, Jiri Pirko wrote: > > <snip> > >>@@ -1031,7 +1029,7 @@ static void greth_set_multicast_list(struct net_device *dev) > >> return; > >> } > >> > >>- if (dev->mc_count == 0) { > >>+ if (!netdev_mc_count(dev)) { > also please use netdev_mc_empty() here. Some driver cleanups: * convert to use phy_find_first/phy_direct_connect * convert to use netdev_mc_* helpers * fixed missing validate_addr hook * removed netdev_priv castings Signed-off-by: Denis Kirjanov <kirjanov@gmail.com> Reviewed-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/greth.c')
-rw-r--r--drivers/net/greth.c49
1 files changed, 18 insertions, 31 deletions
diff --git a/drivers/net/greth.c b/drivers/net/greth.c
index 457da1c2383c..d2032339f6de 100644
--- a/drivers/net/greth.c
+++ b/drivers/net/greth.c
@@ -965,7 +965,7 @@ static int greth_set_mac_add(struct net_device *dev, void *p)
965 struct greth_private *greth; 965 struct greth_private *greth;
966 struct greth_regs *regs; 966 struct greth_regs *regs;
967 967
968 greth = (struct greth_private *) netdev_priv(dev); 968 greth = netdev_priv(dev);
969 regs = (struct greth_regs *) greth->regs; 969 regs = (struct greth_regs *) greth->regs;
970 970
971 if (!is_valid_ether_addr(addr->sa_data)) 971 if (!is_valid_ether_addr(addr->sa_data))
@@ -988,20 +988,14 @@ static u32 greth_hash_get_index(__u8 *addr)
988static void greth_set_hash_filter(struct net_device *dev) 988static void greth_set_hash_filter(struct net_device *dev)
989{ 989{
990 struct dev_mc_list *curr; 990 struct dev_mc_list *curr;
991 struct greth_private *greth = (struct greth_private *) netdev_priv(dev); 991 struct greth_private *greth = netdev_priv(dev);
992 struct greth_regs *regs = (struct greth_regs *) greth->regs; 992 struct greth_regs *regs = (struct greth_regs *) greth->regs;
993 u32 mc_filter[2]; 993 u32 mc_filter[2];
994 unsigned int i, bitnr; 994 unsigned int bitnr;
995 995
996 mc_filter[0] = mc_filter[1] = 0; 996 mc_filter[0] = mc_filter[1] = 0;
997 997
998 curr = dev->mc_list; 998 netdev_for_each_mc_addr(curr, dev) {
999
1000 for (i = 0; i < dev->mc_count; i++, curr = curr->next) {
1001
1002 if (!curr)
1003 break; /* unexpected end of list */
1004
1005 bitnr = greth_hash_get_index(curr->dmi_addr); 999 bitnr = greth_hash_get_index(curr->dmi_addr);
1006 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31); 1000 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
1007 } 1001 }
@@ -1031,7 +1025,7 @@ static void greth_set_multicast_list(struct net_device *dev)
1031 return; 1025 return;
1032 } 1026 }
1033 1027
1034 if (dev->mc_count == 0) { 1028 if (netdev_mc_empty(dev)) {
1035 cfg &= ~GRETH_CTRL_MCEN; 1029 cfg &= ~GRETH_CTRL_MCEN;
1036 GRETH_REGSAVE(regs->control, cfg); 1030 GRETH_REGSAVE(regs->control, cfg);
1037 return; 1031 return;
@@ -1160,6 +1154,7 @@ static struct net_device_ops greth_netdev_ops = {
1160 .ndo_stop = greth_close, 1154 .ndo_stop = greth_close,
1161 .ndo_start_xmit = greth_start_xmit, 1155 .ndo_start_xmit = greth_start_xmit,
1162 .ndo_set_mac_address = greth_set_mac_add, 1156 .ndo_set_mac_address = greth_set_mac_add,
1157 .ndo_validate_addr = eth_validate_addr,
1163}; 1158};
1164 1159
1165static inline int wait_for_mdio(struct greth_private *greth) 1160static inline int wait_for_mdio(struct greth_private *greth)
@@ -1275,28 +1270,26 @@ static int greth_mdio_probe(struct net_device *dev)
1275{ 1270{
1276 struct greth_private *greth = netdev_priv(dev); 1271 struct greth_private *greth = netdev_priv(dev);
1277 struct phy_device *phy = NULL; 1272 struct phy_device *phy = NULL;
1278 u32 interface; 1273 int ret;
1279 int i;
1280 1274
1281 /* Find the first PHY */ 1275 /* Find the first PHY */
1282 for (i = 0; i < PHY_MAX_ADDR; i++) { 1276 phy = phy_find_first(greth->mdio);
1283 if (greth->mdio->phy_map[i]) { 1277
1284 phy = greth->mdio->phy_map[i];
1285 break;
1286 }
1287 }
1288 if (!phy) { 1278 if (!phy) {
1289 if (netif_msg_probe(greth)) 1279 if (netif_msg_probe(greth))
1290 dev_err(&dev->dev, "no PHY found\n"); 1280 dev_err(&dev->dev, "no PHY found\n");
1291 return -ENXIO; 1281 return -ENXIO;
1292 } 1282 }
1293 1283
1294 if (greth->gbit_mac) 1284 ret = phy_connect_direct(dev, phy, &greth_link_change,
1295 interface = PHY_INTERFACE_MODE_GMII; 1285 0, greth->gbit_mac ?
1296 else 1286 PHY_INTERFACE_MODE_GMII :
1297 interface = PHY_INTERFACE_MODE_MII; 1287 PHY_INTERFACE_MODE_MII);
1298 1288 if (ret) {
1299 phy = phy_connect(dev, dev_name(&phy->dev), &greth_link_change, 0, interface); 1289 if (netif_msg_ifup(greth))
1290 dev_err(&dev->dev, "could not attach to PHY\n");
1291 return ret;
1292 }
1300 1293
1301 if (greth->gbit_mac) 1294 if (greth->gbit_mac)
1302 phy->supported &= PHY_GBIT_FEATURES; 1295 phy->supported &= PHY_GBIT_FEATURES;
@@ -1305,12 +1298,6 @@ static int greth_mdio_probe(struct net_device *dev)
1305 1298
1306 phy->advertising = phy->supported; 1299 phy->advertising = phy->supported;
1307 1300
1308 if (IS_ERR(phy)) {
1309 if (netif_msg_ifup(greth))
1310 dev_err(&dev->dev, "could not attach to PHY\n");
1311 return PTR_ERR(phy);
1312 }
1313
1314 greth->link = 0; 1301 greth->link = 0;
1315 greth->speed = 0; 1302 greth->speed = 0;
1316 greth->duplex = -1; 1303 greth->duplex = -1;