natsemi: fix MMIO for PPC 44x platforms
[safe/jmp/linux-2.6] / drivers / net / sunlance.c
index 2c239ab..26ade68 100644 (file)
  *               David S. Miller (davem@redhat.com)
  * 2.01:
  *      11/08/01: Use library crc32 functions (Matt_Domsch@dell.com)
- *               
+ *
  */
 
 #undef DEBUG_DRIVER
 
 static char lancestr[] = "LANCE";
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -100,8 +99,7 @@ static char lancestr[] = "LANCE";
 #include <asm/byteorder.h>     /* Used by the checksum routines */
 #include <asm/idprom.h>
 #include <asm/sbus.h>
-#include <asm/openprom.h>
-#include <asm/oplib.h>
+#include <asm/prom.h>
 #include <asm/auxio.h>         /* For tpe-link-test? setting */
 #include <asm/irq.h>
 
@@ -210,7 +208,7 @@ struct lance_tx_desc {
        s16     length;         /* Length is 2s complement (negative)! */
        u16     misc;
 };
-               
+
 /* The LANCE initialization block, described in databook. */
 /* On the Sparc, this block should be on a DMA region     */
 struct lance_init_block {
@@ -223,11 +221,11 @@ struct lance_init_block {
        u16     rx_len;         /* receive len and high addr */
        u16     tx_ptr;         /* transmit descriptor addr */
        u16     tx_len;         /* transmit len and high addr */
-    
+
        /* The Tx and Rx ring entries must aligned on 8-byte boundaries. */
        struct lance_rx_desc brx_ring[RX_RING_SIZE];
        struct lance_tx_desc btx_ring[TX_RING_SIZE];
-    
+
        u8      tx_buf [TX_RING_SIZE][TX_BUFF_SIZE];
        u8      pad[2];         /* align rx_buf for copy_and_sum(). */
        u8      rx_buf [RX_RING_SIZE][RX_BUFF_SIZE];
@@ -244,13 +242,12 @@ struct lance_private {
        void __iomem    *dregs;         /* DMA controller regs.         */
        struct lance_init_block __iomem *init_block_iomem;
        struct lance_init_block *init_block_mem;
-    
+
        spinlock_t      lock;
 
        int             rx_new, tx_new;
        int             rx_old, tx_old;
-    
-       struct net_device_stats stats;
+
        struct sbus_dma *ledma; /* If set this points to ledma  */
        char            tpe;            /* cable-selection is TPE       */
        char            auto_select;    /* cable-selection by carrier   */
@@ -326,7 +323,7 @@ static void lance_init_ring_dvma(struct net_device *dev)
        dma_addr_t aib = lp->init_block_dvma;
        __u32 leptr;
        int i;
-    
+
        /* Lock out other processes while setting up hardware */
        netif_stop_queue(dev);
        lp->rx_new = lp->tx_new = 0;
@@ -364,12 +361,12 @@ static void lance_init_ring_dvma(struct net_device *dev)
        }
 
        /* Setup the initialization block */
-    
+
        /* Setup rx descriptor pointer */
        leptr = LANCE_ADDR(aib + libdesc_offset(brx_ring, 0));
        ib->rx_len = (LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16);
        ib->rx_ptr = leptr;
-    
+
        /* Setup tx descriptor pointer */
        leptr = LANCE_ADDR(aib + libdesc_offset(btx_ring, 0));
        ib->tx_len = (LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16);
@@ -382,7 +379,7 @@ static void lance_init_ring_pio(struct net_device *dev)
        struct lance_init_block __iomem *ib = lp->init_block_iomem;
        u32 leptr;
        int i;
-    
+
        /* Lock out other processes while setting up hardware */
        netif_stop_queue(dev);
        lp->rx_new = lp->tx_new = 0;
@@ -423,13 +420,13 @@ static void lance_init_ring_pio(struct net_device *dev)
        }
 
        /* Setup the initialization block */
-    
+
        /* Setup rx descriptor pointer */
        leptr = libdesc_offset(brx_ring, 0);
        sbus_writew((LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16),
                    &ib->rx_len);
        sbus_writew(leptr, &ib->rx_ptr);
-    
+
        /* Setup tx descriptor pointer */
        leptr = libdesc_offset(btx_ring, 0);
        sbus_writew((LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16),
@@ -521,17 +518,17 @@ static void lance_rx_dvma(struct net_device *dev)
 
                /* We got an incomplete frame? */
                if ((bits & LE_R1_POK) != LE_R1_POK) {
-                       lp->stats.rx_over_errors++;
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_over_errors++;
+                       dev->stats.rx_errors++;
                } else if (bits & LE_R1_ERR) {
                        /* Count only the end frame as a rx error,
                         * not the beginning
                         */
-                       if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++;
-                       if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++;
-                       if (bits & LE_R1_OFL) lp->stats.rx_over_errors++;
-                       if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++;
-                       if (bits & LE_R1_EOP) lp->stats.rx_errors++;
+                       if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++;
+                       if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++;
+                       if (bits & LE_R1_OFL) dev->stats.rx_over_errors++;
+                       if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++;
+                       if (bits & LE_R1_EOP) dev->stats.rx_errors++;
                } else {
                        len = (rd->mblength & 0xfff) - 4;
                        skb = dev_alloc_skb(len + 2);
@@ -539,25 +536,24 @@ static void lance_rx_dvma(struct net_device *dev)
                        if (skb == NULL) {
                                printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n",
                                       dev->name);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                rd->mblength = 0;
                                rd->rmd1_bits = LE_R1_OWN;
                                lp->rx_new = RX_NEXT(entry);
                                return;
                        }
-           
-                       lp->stats.rx_bytes += len;
 
-                       skb->dev = dev;
+                       dev->stats.rx_bytes += len;
+
                        skb_reserve(skb, 2);            /* 16 byte align */
                        skb_put(skb, len);              /* make room */
-                       eth_copy_and_sum(skb,
+                       skb_copy_to_linear_data(skb,
                                         (unsigned char *)&(ib->rx_buf [entry][0]),
-                                        len, 0);
+                                        len);
                        skb->protocol = eth_type_trans(skb, dev);
                        netif_rx(skb);
                        dev->last_rx = jiffies;
-                       lp->stats.rx_packets++;
+                       dev->stats.rx_packets++;
                }
 
                /* Return the packet to the pool */
@@ -585,16 +581,16 @@ static void lance_tx_dvma(struct net_device *dev)
                /* If we hit a packet not owned by us, stop */
                if (bits & LE_T1_OWN)
                        break;
-               
+
                if (bits & LE_T1_ERR) {
                        u16 status = td->misc;
-           
-                       lp->stats.tx_errors++;
-                       if (status & LE_T3_RTY)  lp->stats.tx_aborted_errors++;
-                       if (status & LE_T3_LCOL) lp->stats.tx_window_errors++;
+
+                       dev->stats.tx_errors++;
+                       if (status & LE_T3_RTY)  dev->stats.tx_aborted_errors++;
+                       if (status & LE_T3_LCOL) dev->stats.tx_window_errors++;
 
                        if (status & LE_T3_CLOS) {
-                               lp->stats.tx_carrier_errors++;
+                               dev->stats.tx_carrier_errors++;
                                if (lp->auto_select) {
                                        lp->tpe = 1 - lp->tpe;
                                        printk(KERN_NOTICE "%s: Carrier Lost, trying %s\n",
@@ -611,7 +607,7 @@ static void lance_tx_dvma(struct net_device *dev)
                         * transmitter, restart the adapter.
                         */
                        if (status & (LE_T3_BUF|LE_T3_UFL)) {
-                               lp->stats.tx_fifo_errors++;
+                               dev->stats.tx_fifo_errors++;
 
                                printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, restarting\n",
                                       dev->name);
@@ -629,15 +625,15 @@ static void lance_tx_dvma(struct net_device *dev)
 
                        /* One collision before packet was sent. */
                        if (bits & LE_T1_EONE)
-                               lp->stats.collisions++;
+                               dev->stats.collisions++;
 
                        /* More than one collision, be optimistic. */
                        if (bits & LE_T1_EMORE)
-                               lp->stats.collisions += 2;
+                               dev->stats.collisions += 2;
 
-                       lp->stats.tx_packets++;
+                       dev->stats.tx_packets++;
                }
-       
+
                j = TX_NEXT(j);
        }
        lp->tx_old = j;
@@ -695,17 +691,17 @@ static void lance_rx_pio(struct net_device *dev)
 
                /* We got an incomplete frame? */
                if ((bits & LE_R1_POK) != LE_R1_POK) {
-                       lp->stats.rx_over_errors++;
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_over_errors++;
+                       dev->stats.rx_errors++;
                } else if (bits & LE_R1_ERR) {
                        /* Count only the end frame as a rx error,
                         * not the beginning
                         */
-                       if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++;
-                       if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++;
-                       if (bits & LE_R1_OFL) lp->stats.rx_over_errors++;
-                       if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++;
-                       if (bits & LE_R1_EOP) lp->stats.rx_errors++;
+                       if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++;
+                       if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++;
+                       if (bits & LE_R1_OFL) dev->stats.rx_over_errors++;
+                       if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++;
+                       if (bits & LE_R1_EOP) dev->stats.rx_errors++;
                } else {
                        len = (sbus_readw(&rd->mblength) & 0xfff) - 4;
                        skb = dev_alloc_skb(len + 2);
@@ -713,23 +709,22 @@ static void lance_rx_pio(struct net_device *dev)
                        if (skb == NULL) {
                                printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n",
                                       dev->name);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                sbus_writew(0, &rd->mblength);
                                sbus_writeb(LE_R1_OWN, &rd->rmd1_bits);
                                lp->rx_new = RX_NEXT(entry);
                                return;
                        }
-           
-                       lp->stats.rx_bytes += len;
 
-                       skb->dev = dev;
+                       dev->stats.rx_bytes += len;
+
                        skb_reserve (skb, 2);           /* 16 byte align */
                        skb_put(skb, len);              /* make room */
                        lance_piocopy_to_skb(skb, &(ib->rx_buf[entry][0]), len);
                        skb->protocol = eth_type_trans(skb, dev);
                        netif_rx(skb);
                        dev->last_rx = jiffies;
-                       lp->stats.rx_packets++;
+                       dev->stats.rx_packets++;
                }
 
                /* Return the packet to the pool */
@@ -757,16 +752,16 @@ static void lance_tx_pio(struct net_device *dev)
                /* If we hit a packet not owned by us, stop */
                if (bits & LE_T1_OWN)
                        break;
-               
+
                if (bits & LE_T1_ERR) {
                        u16 status = sbus_readw(&td->misc);
-           
-                       lp->stats.tx_errors++;
-                       if (status & LE_T3_RTY)  lp->stats.tx_aborted_errors++;
-                       if (status & LE_T3_LCOL) lp->stats.tx_window_errors++;
+
+                       dev->stats.tx_errors++;
+                       if (status & LE_T3_RTY)  dev->stats.tx_aborted_errors++;
+                       if (status & LE_T3_LCOL) dev->stats.tx_window_errors++;
 
                        if (status & LE_T3_CLOS) {
-                               lp->stats.tx_carrier_errors++;
+                               dev->stats.tx_carrier_errors++;
                                if (lp->auto_select) {
                                        lp->tpe = 1 - lp->tpe;
                                        printk(KERN_NOTICE "%s: Carrier Lost, trying %s\n",
@@ -783,7 +778,7 @@ static void lance_tx_pio(struct net_device *dev)
                         * transmitter, restart the adapter.
                         */
                        if (status & (LE_T3_BUF|LE_T3_UFL)) {
-                               lp->stats.tx_fifo_errors++;
+                               dev->stats.tx_fifo_errors++;
 
                                printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, restarting\n",
                                       dev->name);
@@ -801,15 +796,15 @@ static void lance_tx_pio(struct net_device *dev)
 
                        /* One collision before packet was sent. */
                        if (bits & LE_T1_EONE)
-                               lp->stats.collisions++;
+                               dev->stats.collisions++;
 
                        /* More than one collision, be optimistic. */
                        if (bits & LE_T1_EMORE)
-                               lp->stats.collisions += 2;
+                               dev->stats.collisions += 2;
 
-                       lp->stats.tx_packets++;
+                       dev->stats.tx_packets++;
                }
-       
+
                j = TX_NEXT(j);
        }
        lp->tx_old = j;
@@ -821,37 +816,37 @@ out:
        spin_unlock(&lp->lock);
 }
 
-static irqreturn_t lance_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t lance_interrupt(int irq, void *dev_id)
 {
-       struct net_device *dev = (struct net_device *)dev_id;
+       struct net_device *dev = dev_id;
        struct lance_private *lp = netdev_priv(dev);
        int csr0;
-    
+
        sbus_writew(LE_CSR0, lp->lregs + RAP);
        csr0 = sbus_readw(lp->lregs + RDP);
 
        /* Acknowledge all the interrupt sources ASAP */
        sbus_writew(csr0 & (LE_C0_INTR | LE_C0_TINT | LE_C0_RINT),
                    lp->lregs + RDP);
-    
+
        if ((csr0 & LE_C0_ERR) != 0) {
                /* Clear the error condition */
                sbus_writew((LE_C0_BABL | LE_C0_ERR | LE_C0_MISS |
                             LE_C0_CERR | LE_C0_MERR),
                            lp->lregs + RDP);
        }
-    
+
        if (csr0 & LE_C0_RINT)
                lp->rx(dev);
-    
+
        if (csr0 & LE_C0_TINT)
                lp->tx(dev);
-    
+
        if (csr0 & LE_C0_BABL)
-               lp->stats.tx_errors++;
+               dev->stats.tx_errors++;
 
        if (csr0 & LE_C0_MISS)
-               lp->stats.rx_errors++;
+               dev->stats.rx_errors++;
 
        if (csr0 & LE_C0_MERR) {
                if (lp->dregs) {
@@ -931,7 +926,7 @@ static int lance_open(struct net_device *dev)
 
        STOP_LANCE(lp);
 
-       if (request_irq(dev->irq, &lance_interrupt, SA_SHIRQ,
+       if (request_irq(dev->irq, &lance_interrupt, IRQF_SHARED,
                        lancestr, (void *) dev)) {
                printk(KERN_ERR "Lance: Can't get irq %d\n", dev->irq);
                return -EAGAIN;
@@ -993,7 +988,7 @@ static int lance_reset(struct net_device *dev)
 {
        struct lance_private *lp = netdev_priv(dev);
        int status;
-    
+
        STOP_LANCE(lp);
 
        /* On the 4m, reset the dma too */
@@ -1131,7 +1126,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        spin_lock_irq(&lp->lock);
 
-       lp->stats.tx_bytes += len;
+       dev->stats.tx_bytes += len;
 
        entry = lp->tx_new & TX_RING_MOD_MASK;
        if (lp->pio_buffer) {
@@ -1146,7 +1141,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
                struct lance_init_block *ib = lp->init_block_mem;
                ib->btx_ring [entry].length = (-len) | 0xf000;
                ib->btx_ring [entry].misc = 0;
-               memcpy((char *)&ib->tx_buf [entry][0], skb->data, skblen);
+               skb_copy_from_linear_data(skb, &ib->tx_buf [entry][0], skblen);
                if (len != skblen)
                        memset((char *) &ib->tx_buf [entry][skblen], 0, len - skblen);
                ib->btx_ring [entry].tmd1_bits = (LE_T1_POK | LE_T1_OWN);
@@ -1170,15 +1165,8 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        dev->trans_start = jiffies;
        dev_kfree_skb(skb);
-    
-       return 0;
-}
 
-static struct net_device_stats *lance_get_stats(struct net_device *dev)
-{
-       struct lance_private *lp = netdev_priv(dev);
-
-       return &lp->stats;
+       return 0;
 }
 
 /* taken from the depca driver */
@@ -1190,7 +1178,7 @@ static void lance_load_multicast(struct net_device *dev)
        int i;
        u32 crc;
        u32 val;
-       
+
        /* set all multicast bits */
        if (dev->flags & IFF_ALLMULTI)
                val = ~0;
@@ -1209,7 +1197,7 @@ static void lance_load_multicast(struct net_device *dev)
 
        if (dev->flags & IFF_ALLMULTI)
                return;
-       
+
        /* Add addresses */
        for (i = 0; i < dev->mc_count; i++) {
                addrs = dmi->dmi_addr;
@@ -1319,26 +1307,27 @@ static u32 sparc_lance_get_link(struct net_device *dev)
        return 1;
 }
 
-static struct ethtool_ops sparc_lance_ethtool_ops = {
+static const struct ethtool_ops sparc_lance_ethtool_ops = {
        .get_drvinfo            = sparc_lance_get_drvinfo,
        .get_link               = sparc_lance_get_link,
 };
 
-static int __init sparc_lance_probe_one(struct sbus_dev *sdev,
-                                       struct sbus_dma *ledma,
-                                       struct sbus_dev *lebuffer)
+static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
+                                          struct sbus_dma *ledma,
+                                          struct sbus_dev *lebuffer)
 {
        static unsigned version_printed;
+       struct device_node *dp = sdev->ofdev.node;
        struct net_device *dev;
        struct lance_private *lp;
        int    i;
+       DECLARE_MAC_BUF(mac);
 
        dev = alloc_etherdev(sizeof(struct lance_private) + 8);
        if (!dev)
                return -ENOMEM;
 
        lp = netdev_priv(dev);
-       memset(lp, 0, sizeof(*lp));
 
        if (sparc_lance_debug && version_printed++ == 0)
                printk (KERN_INFO "%s", version);
@@ -1392,54 +1381,46 @@ static int __init sparc_lance_probe_one(struct sbus_dev *sdev,
                lp->rx = lance_rx_dvma;
                lp->tx = lance_tx_dvma;
        }
-       lp->busmaster_regval = prom_getintdefault(sdev->prom_node,
-                                                 "busmaster-regval",
-                                                 (LE_C3_BSWP | LE_C3_ACON |
-                                                  LE_C3_BCON));
+       lp->busmaster_regval = of_getintprop_default(dp,  "busmaster-regval",
+                                                    (LE_C3_BSWP |
+                                                     LE_C3_ACON |
+                                                     LE_C3_BCON));
 
        lp->name = lancestr;
        lp->ledma = ledma;
 
        lp->burst_sizes = 0;
        if (lp->ledma) {
-               char prop[6];
+               struct device_node *ledma_dp = ledma->sdev->ofdev.node;
+               const char *prop;
                unsigned int sbmask;
                u32 csr;
 
                /* Find burst-size property for ledma */
-               lp->burst_sizes = prom_getintdefault(ledma->sdev->prom_node,
-                                                    "burst-sizes", 0);
+               lp->burst_sizes = of_getintprop_default(ledma_dp,
+                                                       "burst-sizes", 0);
 
                /* ledma may be capable of fast bursts, but sbus may not. */
-               sbmask = prom_getintdefault(ledma->sdev->bus->prom_node,
-                                           "burst-sizes", DMA_BURSTBITS);
+               sbmask = of_getintprop_default(ledma_dp, "burst-sizes",
+                                              DMA_BURSTBITS);
                lp->burst_sizes &= sbmask;
 
                /* Get the cable-selection property */
-               memset(prop, 0, sizeof(prop));
-               prom_getstring(ledma->sdev->prom_node, "cable-selection",
-                              prop, sizeof(prop));
-               if (prop[0] == 0) {
-                       int topnd, nd;
-
-                       printk(KERN_INFO "SunLance: using auto-carrier-detection.\n");
+               prop = of_get_property(ledma_dp, "cable-selection", NULL);
+               if (!prop || prop[0] == '\0') {
+                       struct device_node *nd;
 
-                       /* Is this found at /options .attributes in all
-                        * Prom versions? XXX
-                        */
-                       topnd = prom_getchild(prom_root_node);
+                       printk(KERN_INFO "SunLance: using "
+                              "auto-carrier-detection.\n");
 
-                       nd = prom_searchsiblings(topnd, "options");
+                       nd = of_find_node_by_path("/options");
                        if (!nd)
                                goto no_link_test;
 
-                       if (!prom_node_has_property(nd, "tpe-link-test?"))
+                       prop = of_get_property(nd, "tpe-link-test?", NULL);
+                       if (!prop)
                                goto no_link_test;
 
-                       memset(prop, 0, sizeof(prop));
-                       prom_getstring(nd, "tpe-link-test?", prop,
-                                      sizeof(prop));
-
                        if (strcmp(prop, "true")) {
                                printk(KERN_NOTICE "SunLance: warning: overriding option "
                                       "'tpe-link-test?'\n");
@@ -1469,14 +1450,12 @@ no_link_test:
                lp->dregs = NULL;
 
        lp->dev = dev;
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &sdev->ofdev.dev);
        dev->open = &lance_open;
        dev->stop = &lance_close;
        dev->hard_start_xmit = &lance_start_xmit;
        dev->tx_timeout = &lance_tx_timeout;
        dev->watchdog_timeo = 5*HZ;
-       dev->get_stats = &lance_get_stats;
        dev->set_multicast_list = &lance_set_multicast;
        dev->ethtool_ops = &sparc_lance_ethtool_ops;
 
@@ -1500,12 +1479,8 @@ no_link_test:
 
        dev_set_drvdata(&sdev->ofdev.dev, lp);
 
-       printk(KERN_INFO "%s: LANCE ", dev->name);
-
-       for (i = 0; i < 6; i++)
-               printk("%2.2x%c", dev->dev_addr[i],
-                      i == 5 ? ' ': ':');
-       printk("\n");
+       printk(KERN_INFO "%s: LANCE %s\n",
+              dev->name, print_mac(mac, dev->dev_addr));
 
        return 0;
 
@@ -1516,7 +1491,7 @@ fail:
 }
 
 /* On 4m, find the associated dma for the lance chip */
-static inline struct sbus_dma *find_ledma(struct sbus_dev *sdev)
+static struct sbus_dma * __devinit find_ledma(struct sbus_dev *sdev)
 {
        struct sbus_dma *p;
 
@@ -1534,11 +1509,11 @@ static inline struct sbus_dma *find_ledma(struct sbus_dev *sdev)
 
 /* Find all the lance cards on the system and initialize them */
 static struct sbus_dev sun4_sdev;
-static int __init sparc_lance_init(void)
+static int __devinit sparc_lance_init(void)
 {
        if ((idprom->id_machtype == (SM_SUN4|SM_4_330)) ||
            (idprom->id_machtype == (SM_SUN4|SM_4_470))) {
-               memset(&sun4_sdev, 0, sizeof(sdev));
+               memset(&sun4_sdev, 0, sizeof(struct sbus_dev));
                sun4_sdev.reg_addrs[0].phys_addr = sun4_eth_physaddr;
                sun4_sdev.irqs[0] = 6;
                return sparc_lance_probe_one(&sun4_sdev, NULL, NULL);
@@ -1548,16 +1523,16 @@ static int __init sparc_lance_init(void)
 
 static int __exit sunlance_sun4_remove(void)
 {
-       struct lance_private *lp = dev_get_drvdata(&sun4_sdev->dev);
+       struct lance_private *lp = dev_get_drvdata(&sun4_sdev.ofdev.dev);
        struct net_device *net_dev = lp->dev;
 
-       unregister_netdevice(net_dev);
+       unregister_netdev(net_dev);
 
-       lance_free_hwresources(root_lance_dev);
+       lance_free_hwresources(lp);
 
        free_netdev(net_dev);
 
-       dev_set_drvdata(&sun4_sdev->dev, NULL);
+       dev_set_drvdata(&sun4_sdev.ofdev.dev, NULL);
 
        return 0;
 }
@@ -1567,20 +1542,21 @@ static int __exit sunlance_sun4_remove(void)
 static int __devinit sunlance_sbus_probe(struct of_device *dev, const struct of_device_id *match)
 {
        struct sbus_dev *sdev = to_sbus_device(&dev->dev);
-       struct device_node *dp = dev->node;
        int err;
 
-       if (!strcmp(dp->name, "le")) {
-               err = sparc_lance_probe_one(sdev, NULL, NULL);
-       } else if (!strcmp(dp->name, "ledma")) {
-               struct sbus_dma *ledma = find_ledma(sdev);
+       if (sdev->parent) {
+               struct of_device *parent = &sdev->parent->ofdev;
 
-               err = sparc_lance_probe_one(sdev->child, ledma, NULL);
-       } else {
-               BUG_ON(strcmp(dp->name, "lebuffer"));
+               if (!strcmp(parent->node->name, "ledma")) {
+                       struct sbus_dma *ledma = find_ledma(to_sbus_device(&parent->dev));
 
-               err = sparc_lance_probe_one(sdev->child, NULL, sdev);
-       }
+                       err = sparc_lance_probe_one(sdev, ledma, NULL);
+               } else if (!strcmp(parent->node->name, "lebuffer")) {
+                       err = sparc_lance_probe_one(sdev, NULL, to_sbus_device(&parent->dev));
+               } else
+                       err = sparc_lance_probe_one(sdev, NULL, NULL);
+       } else
+               err = sparc_lance_probe_one(sdev, NULL, NULL);
 
        return err;
 }
@@ -1590,7 +1566,7 @@ static int __devexit sunlance_sbus_remove(struct of_device *dev)
        struct lance_private *lp = dev_get_drvdata(&dev->dev);
        struct net_device *net_dev = lp->dev;
 
-       unregister_netdevice(net_dev);
+       unregister_netdev(net_dev);
 
        lance_free_hwresources(lp);
 
@@ -1605,12 +1581,6 @@ static struct of_device_id sunlance_sbus_match[] = {
        {
                .name = "le",
        },
-       {
-               .name = "ledma",
-       },
-       {
-               .name = "lebuffer",
-       },
        {},
 };