ARM: 6165/1: trap overflows on highmem pages from kmap_atomic when debugging
[safe/jmp/linux-2.6] / drivers / net / sunqe.c
index f636447..72b579c 100644 (file)
@@ -227,7 +227,7 @@ static int qe_init(struct sunqe *qep, int from_irq)
        if (!(sbus_readb(mregs + MREGS_PHYCONFIG) & MREGS_PHYCONFIG_LTESTDIS)) {
                int tries = 50;
 
-               while (tries--) {
+               while (--tries) {
                        u8 tmp;
 
                        mdelay(5);
@@ -446,7 +446,6 @@ static void qe_rx(struct sunqe *qep)
                                                 len);
                                skb->protocol = eth_type_trans(skb, qep->dev);
                                netif_rx(skb);
-                               qep->dev->last_rx = jiffies;
                                dev->stats.rx_packets++;
                                dev->stats.rx_bytes += len;
                        }
@@ -513,7 +512,7 @@ static irqreturn_t qec_interrupt(int irq, void *dev_id)
 
 static int qe_open(struct net_device *dev)
 {
-       struct sunqe *qep = (struct sunqe *) dev->priv;
+       struct sunqe *qep = netdev_priv(dev);
 
        qep->mconfig = (MREGS_MCONFIG_TXENAB |
                        MREGS_MCONFIG_RXENAB |
@@ -523,7 +522,7 @@ static int qe_open(struct net_device *dev)
 
 static int qe_close(struct net_device *dev)
 {
-       struct sunqe *qep = (struct sunqe *) dev->priv;
+       struct sunqe *qep = netdev_priv(dev);
 
        qe_stop(qep);
        return 0;
@@ -549,7 +548,7 @@ static void qe_tx_reclaim(struct sunqe *qep)
 
 static void qe_tx_timeout(struct net_device *dev)
 {
-       struct sunqe *qep = (struct sunqe *) dev->priv;
+       struct sunqe *qep = netdev_priv(dev);
        int tx_full;
 
        spin_lock_irq(&qep->lock);
@@ -575,7 +574,7 @@ out:
 /* Get a packet queued to go onto the wire. */
 static int qe_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-       struct sunqe *qep = (struct sunqe *) dev->priv;
+       struct sunqe *qep = netdev_priv(dev);
        struct sunqe_buffers *qbufs = qep->buffers;
        __u32 txbuf_dvma, qbufs_dvma = qep->buffers_dvma;
        unsigned char *txbuf;
@@ -603,7 +602,6 @@ static int qe_start_xmit(struct sk_buff *skb, struct net_device *dev)
        qep->tx_new = NEXT_TX(entry);
 
        /* Get it going. */
-       dev->trans_start = jiffies;
        sbus_writel(CREG_CTRL_TWAKEUP, qep->qcregs + CREG_CTRL);
 
        dev->stats.tx_packets++;
@@ -622,13 +620,13 @@ static int qe_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        dev_kfree_skb(skb);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void qe_set_multicast(struct net_device *dev)
 {
-       struct sunqe *qep = (struct sunqe *) dev->priv;
-       struct dev_mc_list *dmi = dev->mc_list;
+       struct sunqe *qep = netdev_priv(dev);
+       struct netdev_hw_addr *ha;
        u8 new_mconfig = qep->mconfig;
        char *addrs;
        int i;
@@ -637,7 +635,7 @@ static void qe_set_multicast(struct net_device *dev)
        /* Lock out others. */
        netif_stop_queue(dev);
 
-       if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 64)) {
+       if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 64)) {
                sbus_writeb(MREGS_IACONFIG_ACHNGE | MREGS_IACONFIG_LARESET,
                            qep->mregs + MREGS_IACONFIG);
                while ((sbus_readb(qep->mregs + MREGS_IACONFIG) & MREGS_IACONFIG_ACHNGE) != 0)
@@ -651,12 +649,9 @@ static void qe_set_multicast(struct net_device *dev)
                u16 hash_table[4];
                u8 *hbytes = (unsigned char *) &hash_table[0];
 
-               for (i = 0; i < 4; i++)
-                       hash_table[i] = 0;
-
-               for (i = 0; i < dev->mc_count; i++) {
-                       addrs = dmi->dmi_addr;
-                       dmi = dmi->next;
+               memset(hash_table, 0, sizeof(hash_table));
+               netdev_for_each_mc_addr(ha, dev) {
+                       addrs = ha->addr;
 
                        if (!(*addrs & 1))
                                continue;
@@ -693,14 +688,14 @@ static void qe_set_multicast(struct net_device *dev)
 static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
        const struct linux_prom_registers *regs;
-       struct sunqe *qep = dev->priv;
+       struct sunqe *qep = netdev_priv(dev);
        struct of_device *op;
 
        strcpy(info->driver, "sunqe");
        strcpy(info->version, "3.0");
 
        op = qep->op;
-       regs = of_get_property(op->node, "reg", NULL);
+       regs = of_get_property(op->dev.of_node, "reg", NULL);
        if (regs)
                sprintf(info->bus_info, "SBUS:%d", regs->which_io);
 
@@ -708,7 +703,7 @@ static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 
 static u32 qe_get_link(struct net_device *dev)
 {
-       struct sunqe *qep = dev->priv;
+       struct sunqe *qep = netdev_priv(dev);
        void __iomem *mregs = qep->mregs;
        u8 phyconfig;
 
@@ -804,11 +799,11 @@ static struct sunqec * __devinit get_qec(struct of_device *child)
                        if (qec_global_reset(qecp->gregs))
                                goto fail;
 
-                       qecp->qec_bursts = qec_get_burst(op->node);
+                       qecp->qec_bursts = qec_get_burst(op->dev.of_node);
 
                        qec_init_once(qecp, op);
 
-                       if (request_irq(op->irqs[0], &qec_interrupt,
+                       if (request_irq(op->irqs[0], qec_interrupt,
                                        IRQF_SHARED, "qec", (void *) qecp)) {
                                printk(KERN_ERR "qec: Can't register irq.\n");
                                goto fail;
@@ -830,6 +825,17 @@ fail:
        return NULL;
 }
 
+static const struct net_device_ops qec_ops = {
+       .ndo_open               = qe_open,
+       .ndo_stop               = qe_close,
+       .ndo_start_xmit         = qe_start_xmit,
+       .ndo_set_multicast_list = qe_set_multicast,
+       .ndo_tx_timeout         = qe_tx_timeout,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static int __devinit qec_ether_init(struct of_device *op)
 {
        static unsigned version_printed;
@@ -851,7 +857,7 @@ static int __devinit qec_ether_init(struct of_device *op)
 
        res = -ENODEV;
 
-       i = of_getintprop_default(op->node, "channel#", -1);
+       i = of_getintprop_default(op->dev.of_node, "channel#", -1);
        if (i == -1)
                goto fail;
        qe->channel = i;
@@ -894,15 +900,11 @@ static int __devinit qec_ether_init(struct of_device *op)
 
        SET_NETDEV_DEV(dev, &op->dev);
 
-       dev->open = qe_open;
-       dev->stop = qe_close;
-       dev->hard_start_xmit = qe_start_xmit;
-       dev->set_multicast_list = qe_set_multicast;
-       dev->tx_timeout = qe_tx_timeout;
        dev->watchdog_timeo = 5*HZ;
        dev->irq = op->irqs[0];
        dev->dma = 0;
        dev->ethtool_ops = &qe_ethtool_ops;
+       dev->netdev_ops = &qec_ops;
 
        res = register_netdev(dev);
        if (res)
@@ -975,8 +977,11 @@ static const struct of_device_id qec_sbus_match[] = {
 MODULE_DEVICE_TABLE(of, qec_sbus_match);
 
 static struct of_platform_driver qec_sbus_driver = {
-       .name           = "qec",
-       .match_table    = qec_sbus_match,
+       .driver = {
+               .name = "qec",
+               .owner = THIS_MODULE,
+               .of_match_table = qec_sbus_match,
+       },
        .probe          = qec_sbus_probe,
        .remove         = __devexit_p(qec_sbus_remove),
 };