net: spread __net_init, __net_exit
[safe/jmp/linux-2.6] / drivers / net / pasemi_mac.c
index b027005..d44d4a2 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
+#include <linux/of_mdio.h>
 #include <linux/etherdevice.h>
 #include <asm/dma-mapping.h>
 #include <linux/in.h>
@@ -712,7 +713,7 @@ static inline void pasemi_mac_rx_error(const struct pasemi_mac *mac,
        rcmdsta = read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if));
        ccmdsta = read_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno));
 
-       printk(KERN_ERR "pasemi_mac: rx error. macrx %016lx, rx status %lx\n",
+       printk(KERN_ERR "pasemi_mac: rx error. macrx %016llx, rx status %llx\n",
                macrx, *chan->status);
 
        printk(KERN_ERR "pasemi_mac: rcmdsta %08x ccmdsta %08x\n",
@@ -730,8 +731,8 @@ static inline void pasemi_mac_tx_error(const struct pasemi_mac *mac,
 
        cmdsta = read_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno));
 
-       printk(KERN_ERR "pasemi_mac: tx error. mactx 0x%016lx, "\
-               "tx status 0x%016lx\n", mactx, *chan->status);
+       printk(KERN_ERR "pasemi_mac: tx error. mactx 0x%016llx, "\
+               "tx status 0x%016llx\n", mactx, *chan->status);
 
        printk(KERN_ERR "pasemi_mac: tcmdsta 0x%08x\n", cmdsta);
 }
@@ -954,7 +955,6 @@ static irqreturn_t pasemi_mac_rx_intr(int irq, void *data)
 {
        const struct pasemi_mac_rxring *rxring = data;
        struct pasemi_mac *mac = rxring->mac;
-       struct net_device *dev = mac->netdev;
        const struct pasemi_dmachan *chan = &rxring->chan;
        unsigned int reg;
 
@@ -971,7 +971,7 @@ static irqreturn_t pasemi_mac_rx_intr(int irq, void *data)
        if (*chan->status & PAS_STATUS_ERROR)
                reg |= PAS_IOB_DMA_RXCH_RESET_DINTC;
 
-       netif_rx_schedule(dev, &mac->napi);
+       napi_schedule(&mac->napi);
 
        write_iob_reg(PAS_IOB_DMA_RXCH_RESET(chan->chno), reg);
 
@@ -1011,7 +1011,7 @@ static irqreturn_t pasemi_mac_tx_intr(int irq, void *data)
 
        mod_timer(&txring->clean_timer, jiffies + (TX_CLEAN_INTERVAL)*2);
 
-       netif_rx_schedule(mac->netdev, &mac->napi);
+       napi_schedule(&mac->napi);
 
        if (reg)
                write_iob_reg(PAS_IOB_DMA_TXCH_RESET(chan->chno), reg);
@@ -1087,33 +1087,17 @@ static int pasemi_mac_phy_init(struct net_device *dev)
        struct pasemi_mac *mac = netdev_priv(dev);
        struct device_node *dn, *phy_dn;
        struct phy_device *phydev;
-       unsigned int phy_id;
-       const phandle *ph;
-       const unsigned int *prop;
-       struct resource r;
-       int ret;
 
        dn = pci_device_to_OF_node(mac->pdev);
-       ph = of_get_property(dn, "phy-handle", NULL);
-       if (!ph)
-               return -ENODEV;
-       phy_dn = of_find_node_by_phandle(*ph);
-
-       prop = of_get_property(phy_dn, "reg", NULL);
-       ret = of_address_to_resource(phy_dn->parent, 0, &r);
-       if (ret)
-               goto err;
-
-       phy_id = *prop;
-       snprintf(mac->phy_id, BUS_ID_SIZE, "%x:%02x", (int)r.start, phy_id);
-
+       phy_dn = of_parse_phandle(dn, "phy-handle", 0);
        of_node_put(phy_dn);
 
        mac->link = 0;
        mac->speed = 0;
        mac->duplex = -1;
 
-       phydev = phy_connect(dev, mac->phy_id, &pasemi_adjust_link, 0, PHY_INTERFACE_MODE_SGMII);
+       phydev = of_phy_connect(dev, phy_dn, &pasemi_adjust_link, 0,
+                               PHY_INTERFACE_MODE_SGMII);
 
        if (IS_ERR(phydev)) {
                printk(KERN_ERR "%s: Could not attach to phy\n", dev->name);
@@ -1123,10 +1107,6 @@ static int pasemi_mac_phy_init(struct net_device *dev)
        mac->phydev = phydev;
 
        return 0;
-
-err:
-       of_node_put(phy_dn);
-       return -ENODEV;
 }
 
 
@@ -1236,7 +1216,7 @@ static int pasemi_mac_open(struct net_device *dev)
        snprintf(mac->tx_irq_name, sizeof(mac->tx_irq_name), "%s tx",
                 dev->name);
 
-       ret = request_irq(mac->tx->chan.irq, &pasemi_mac_tx_intr, IRQF_DISABLED,
+       ret = request_irq(mac->tx->chan.irq, pasemi_mac_tx_intr, IRQF_DISABLED,
                          mac->tx_irq_name, mac->tx);
        if (ret) {
                dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n",
@@ -1247,7 +1227,7 @@ static int pasemi_mac_open(struct net_device *dev)
        snprintf(mac->rx_irq_name, sizeof(mac->rx_irq_name), "%s rx",
                 dev->name);
 
-       ret = request_irq(mac->rx->chan.irq, &pasemi_mac_rx_intr, IRQF_DISABLED,
+       ret = request_irq(mac->rx->chan.irq, pasemi_mac_rx_intr, IRQF_DISABLED,
                          mac->rx_irq_name, mac->rx);
        if (ret) {
                dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n",
@@ -1633,14 +1613,13 @@ static void pasemi_mac_set_rx_mode(struct net_device *dev)
 static int pasemi_mac_poll(struct napi_struct *napi, int budget)
 {
        struct pasemi_mac *mac = container_of(napi, struct pasemi_mac, napi);
-       struct net_device *dev = mac->netdev;
        int pkts;
 
        pasemi_mac_clean_tx(tx_ring(mac));
        pkts = pasemi_mac_clean_rx(rx_ring(mac), budget);
        if (pkts < budget) {
                /* all done, no more packets present */
-               netif_rx_complete(dev, napi);
+               napi_complete(napi);
 
                pasemi_mac_restart_rx_intr(mac);
                pasemi_mac_restart_tx_intr(mac);
@@ -1736,12 +1715,25 @@ out:
        return ret;
 }
 
+static const struct net_device_ops pasemi_netdev_ops = {
+       .ndo_open               = pasemi_mac_open,
+       .ndo_stop               = pasemi_mac_close,
+       .ndo_start_xmit         = pasemi_mac_start_tx,
+       .ndo_set_multicast_list = pasemi_mac_set_rx_mode,
+       .ndo_set_mac_address    = pasemi_mac_set_mac_addr,
+       .ndo_change_mtu         = pasemi_mac_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = pasemi_mac_netpoll,
+#endif
+};
+
 static int __devinit
 pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        struct net_device *dev;
        struct pasemi_mac *mac;
-       int err;
+       int err, ret;
 
        err = pci_enable_device(pdev);
        if (err)
@@ -1799,12 +1791,13 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
        memcpy(dev->dev_addr, mac->mac_addr, sizeof(mac->mac_addr));
 
-       mac->dma_if = mac_to_intf(mac);
-       if (mac->dma_if < 0) {
+       ret = mac_to_intf(mac);
+       if (ret < 0) {
                dev_err(&mac->pdev->dev, "Can't map DMA interface\n");
                err = -ENODEV;
                goto out;
        }
+       mac->dma_if = ret;
 
        switch (pdev->device) {
        case 0xa005:
@@ -1818,19 +1811,11 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto out;
        }
 
-       dev->open = pasemi_mac_open;
-       dev->stop = pasemi_mac_close;
-       dev->hard_start_xmit = pasemi_mac_start_tx;
-       dev->set_multicast_list = pasemi_mac_set_rx_mode;
-       dev->set_mac_address = pasemi_mac_set_mac_addr;
+       dev->netdev_ops = &pasemi_netdev_ops;
        dev->mtu = PE_DEF_MTU;
        /* 1500 MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */
        mac->bufsz = dev->mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       dev->poll_controller = pasemi_mac_netpoll;
-#endif
 
-       dev->change_mtu = pasemi_mac_change_mtu;
        dev->ethtool_ops = &pasemi_mac_ethtool_ops;
 
        if (err)
@@ -1890,7 +1875,7 @@ static void __devexit pasemi_mac_remove(struct pci_dev *pdev)
        free_netdev(netdev);
 }
 
-static struct pci_device_id pasemi_mac_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(pasemi_mac_pci_tbl) = {
        { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa005) },
        { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa006) },
        { },