bnx2: Refine VPD logic.
[safe/jmp/linux-2.6] / drivers / net / sunqe.c
index 81604ca..45c383f 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;
@@ -622,12 +621,12 @@ 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 sunqe *qep = netdev_priv(dev);
        struct dev_mc_list *dmi = dev->mc_list;
        u8 new_mconfig = qep->mconfig;
        char *addrs;
@@ -693,7 +692,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");
@@ -708,7 +707,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;
 
@@ -808,7 +807,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;
@@ -830,6 +829,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;
@@ -894,15 +904,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)
@@ -965,7 +971,7 @@ static int __devexit qec_sbus_remove(struct of_device *op)
        return 0;
 }
 
-static struct of_device_id qec_sbus_match[] = {
+static const struct of_device_id qec_sbus_match[] = {
        {
                .name = "qe",
        },