drivers/net: Use kcalloc or kzalloc
[safe/jmp/linux-2.6] / drivers / net / sunqe.c
index 8f1e7ff..a7542d2 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);
@@ -512,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 |
@@ -522,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;
@@ -548,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);
@@ -574,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;
@@ -602,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++;
@@ -621,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;
@@ -636,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)
@@ -650,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;
@@ -692,7 +688,7 @@ 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");
@@ -707,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;
 
@@ -807,7 +803,7 @@ static struct sunqec * __devinit get_qec(struct of_device *child)
 
                        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;
@@ -829,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;
@@ -893,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)