static int __init ramips_eth_probe(struct net_device *dev) { struct raeth_priv *priv = netdev_priv(dev); int err; BUG_ON(!priv->plat->reset_fe); priv->plat->reset_fe(); net_srandom(jiffies); memcpy(dev->dev_addr, priv->plat->mac, ETH_ALEN); ether_setup(dev); dev->mtu = 1500; dev->watchdog_timeo = TX_TIMEOUT; spin_lock_init(&priv->page_lock); spin_lock_init(&priv->phy_lock); err = ramips_mdio_init(priv); if (err) return err; err = ramips_phy_connect(priv); if (err) goto err_mdio_cleanup; return 0; err_mdio_cleanup: ramips_mdio_cleanup(priv); return err; }
static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh, u32 pid) { struct in_device *in_dev = ifa->ifa_dev; struct in_ifaddr *ifa1, **ifap, **last_primary; ASSERT_RTNL(); if (!ifa->ifa_local) { inet_free_ifa(ifa); return 0; } ifa->ifa_flags &= ~IFA_F_SECONDARY; last_primary = &in_dev->ifa_list; for (ifap = &in_dev->ifa_list; (ifa1 = *ifap) != NULL; ifap = &ifa1->ifa_next) { if (!(ifa1->ifa_flags & IFA_F_SECONDARY) && ifa->ifa_scope <= ifa1->ifa_scope) last_primary = &ifa1->ifa_next; if (ifa1->ifa_mask == ifa->ifa_mask && inet_ifa_match(ifa1->ifa_address, ifa)) { if (ifa1->ifa_local == ifa->ifa_local) { inet_free_ifa(ifa); return -EEXIST; } if (ifa1->ifa_scope != ifa->ifa_scope) { inet_free_ifa(ifa); return -EINVAL; } ifa->ifa_flags |= IFA_F_SECONDARY; } trace_mark(net_insert_ifa_ipv4, "label %s address #4u%lu", ifa->ifa_label, (unsigned long)ifa->ifa_address); } if (!(ifa->ifa_flags & IFA_F_SECONDARY)) { net_srandom(ifa->ifa_local); ifap = last_primary; } ifa->ifa_next = *ifap; *ifap = ifa; /* Send message first, then call notifier. Notifier will trigger FIB update, so that listeners of netlink will know about new ifaddr */ rtmsg_ifa(RTM_NEWADDR, ifa, nlh, pid); blocking_notifier_call_chain(&inetaddr_chain, NETDEV_UP, ifa); return 0; }
static int inet_insert_ifa(struct in_ifaddr *ifa) { struct in_device *in_dev = ifa->ifa_dev; struct in_ifaddr *ifa1, **ifap, **last_primary; ASSERT_RTNL(); if (!ifa->ifa_local) { inet_free_ifa(ifa); return 0; } ifa->ifa_flags &= ~IFA_F_SECONDARY; last_primary = &in_dev->ifa_list; for (ifap = &in_dev->ifa_list; (ifa1 = *ifap) != NULL; ifap = &ifa1->ifa_next) { if (!(ifa1->ifa_flags & IFA_F_SECONDARY) && ifa->ifa_scope <= ifa1->ifa_scope) last_primary = &ifa1->ifa_next; if (ifa1->ifa_mask == ifa->ifa_mask && inet_ifa_match(ifa1->ifa_address, ifa)) { if (ifa1->ifa_local == ifa->ifa_local) { inet_free_ifa(ifa); return -EEXIST; } if (ifa1->ifa_scope != ifa->ifa_scope) { inet_free_ifa(ifa); return -EINVAL; } ifa->ifa_flags |= IFA_F_SECONDARY; } } if (!(ifa->ifa_flags & IFA_F_SECONDARY)) { net_srandom(ifa->ifa_local); ifap = last_primary; } ifa->ifa_next = *ifap; write_lock_bh(&in_dev->lock); *ifap = ifa; write_unlock_bh(&in_dev->lock); /* Send message first, then call notifier. Notifier will trigger FIB update, so that listeners of netlink will know about new ifaddr */ rtmsg_ifa(RTM_NEWADDR, ifa); notifier_call_chain(&inetaddr_chain, NETDEV_UP, ifa); return 0; }
static int __init ramips_eth_probe(struct net_device *dev) { struct raeth_priv *priv = netdev_priv(dev); BUG_ON(!priv->plat->reset_fe); priv->plat->reset_fe(); net_srandom(jiffies); memcpy(dev->dev_addr, priv->plat->mac, ETH_ALEN); ether_setup(dev); dev->mtu = 1500; dev->watchdog_timeo = TX_TIMEOUT; spin_lock_init(&priv->page_lock); return 0; }
static int __init ramips_eth_probe(struct net_device *dev) { struct raeth_priv *priv = netdev_priv(dev); struct sockaddr addr; BUG_ON(!priv->plat->reset_fe); priv->plat->reset_fe(); net_srandom(jiffies); memcpy(addr.sa_data, priv->plat->mac, 6); ramips_eth_set_mac_addr(dev, &addr); ether_setup(dev); dev->open = ramips_eth_open; dev->stop = ramips_eth_stop; dev->hard_start_xmit = ramips_eth_hard_start_xmit; dev->set_mac_address = ramips_eth_set_mac_addr; dev->mtu = 1500; dev->tx_timeout = ramips_eth_timeout; dev->watchdog_timeo = TX_TIMEOUT; spin_lock_init(&priv->page_lock); return 0; }