net: usb: raw-ip: Fix autopm / system suspend issues.
[linux-2.6.git] / drivers / net / de620.c
index bdfa894..1c51a75 100644 (file)
@@ -48,7 +48,6 @@ static const char version[] =
  * Compile-time options: (see below for descriptions)
  * -DDE620_IO=0x378    (lpt1)
  * -DDE620_IRQ=7       (lpt1)
- * -DDE602_DEBUG=...
  * -DSHUTDOWN_WHEN_LOST
  * -DCOUNT_LOOPS
  * -DLOWSPEED
@@ -98,15 +97,6 @@ static const char version[] =
 #define SHUTDOWN_WHEN_LOST
  */
 
-/*
- * Enable debugging by "-DDE620_DEBUG=3" when compiling,
- * OR by enabling the following #define
- *
- * use 0 for production, 1 for verification, >2 for debug
- *
-#define DE620_DEBUG 3
- */
-
 #ifdef LOWSPEED
 /*
  * Enable this #define if you want to see debugging output that show how long
@@ -160,14 +150,6 @@ typedef unsigned char byte;
 #define RUNT 60                /* Too small Ethernet packet */
 #define GIANT 1514     /* largest legal size packet, no fcs */
 
-#ifdef DE620_DEBUG /* Compile-time configurable */
-#define PRINTK(x) if (de620_debug >= 2) printk x
-#else
-#define DE620_DEBUG 0
-#define PRINTK(x) /**/
-#endif
-
-
 /*
  * Force media with insmod:
  *     insmod de620.o bnc=1
@@ -186,8 +168,6 @@ static int io  = DE620_IO;
 static int irq = DE620_IRQ;
 static int clone = DE620_CLONE;
 
-static unsigned int de620_debug = DE620_DEBUG;
-
 static spinlock_t de620_lock;
 
 module_param(bnc, int, 0);
@@ -195,13 +175,11 @@ module_param(utp, int, 0);
 module_param(io, int, 0);
 module_param(irq, int, 0);
 module_param(clone, int, 0);
-module_param(de620_debug, int, 0);
 MODULE_PARM_DESC(bnc, "DE-620 set BNC medium (0-1)");
 MODULE_PARM_DESC(utp, "DE-620 set UTP medium (0-1)");
 MODULE_PARM_DESC(io, "DE-620 I/O base address,required");
 MODULE_PARM_DESC(irq, "DE-620 IRQ number,required");
 MODULE_PARM_DESC(clone, "Check also for non-D-Link DE-620 clones (0-1)");
-MODULE_PARM_DESC(de620_debug, "DE-620 debug level (0-2)");
 
 /***********************************************
  *                                             *
@@ -486,7 +464,7 @@ static int de620_close(struct net_device *dev)
 
 static void de620_set_multicast_list(struct net_device *dev)
 {
-       if (dev->mc_count || dev->flags&(IFF_ALLMULTI|IFF_PROMISC))
+       if (!netdev_mc_empty(dev) || dev->flags&(IFF_ALLMULTI|IFF_PROMISC))
        { /* Enable promiscuous mode */
                de620_set_register(dev, W_TCR, (TCR_DEF & ~RXPBM) | RXALL);
        }
@@ -533,9 +511,9 @@ static int de620_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        /* Start real output */
 
-       spin_lock_irqsave(&de620_lock, flags)
-       PRINTK(("de620_start_xmit: len=%d, bufs 0x%02x\n",
-               (int)skb->len, using_txbuf));
+       spin_lock_irqsave(&de620_lock, flags);
+       pr_debug("de620_start_xmit: len=%d, bufs 0x%02x\n",
+               (int)skb->len, using_txbuf);
 
        /* select a free tx buffer. if there is one... */
        switch (using_txbuf) {
@@ -553,18 +531,17 @@ static int de620_start_xmit(struct sk_buff *skb, struct net_device *dev)
        case (TXBF0 | TXBF1): /* NONE!!! */
                printk(KERN_WARNING "%s: No tx-buffer available!\n", dev->name);
                spin_unlock_irqrestore(&de620_lock, flags);
-               return 1;
+               return NETDEV_TX_BUSY;
        }
        de620_write_block(dev, buffer, skb->len, len-skb->len);
 
-       dev->trans_start = jiffies;
        if(!(using_txbuf == (TXBF0 | TXBF1)))
                netif_wake_queue(dev);
 
        dev->stats.tx_packets++;
        spin_unlock_irqrestore(&de620_lock, flags);
        dev_kfree_skb (skb);
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /*****************************************************
@@ -585,12 +562,12 @@ de620_interrupt(int irq_in, void *dev_id)
        /* Read the status register (_not_ the status port) */
        irq_status = de620_get_register(dev, R_STS);
 
-       PRINTK(("de620_interrupt (%2.2X)\n", irq_status));
+       pr_debug("de620_interrupt (%2.2X)\n", irq_status);
 
        if (irq_status & RXGOOD) {
                do {
                        again = de620_rx_intr(dev);
-                       PRINTK(("again=%d\n", again));
+                       pr_debug("again=%d\n", again);
                }
                while (again && (++bogus_count < 100));
        }
@@ -622,7 +599,7 @@ static int de620_rx_intr(struct net_device *dev)
        byte pagelink;
        byte curr_page;
 
-       PRINTK(("de620_rx_intr: next_rx_page = %d\n", next_rx_page));
+       pr_debug("de620_rx_intr: next_rx_page = %d\n", next_rx_page);
 
        /* Tell the adapter that we are going to read data, and from where */
        de620_send_command(dev, W_CR | RRN);
@@ -631,8 +608,9 @@ static int de620_rx_intr(struct net_device *dev)
 
        /* Deep breath, and away we goooooo */
        de620_read_block(dev, (byte *)&header_buf, sizeof(struct header_buf));
-       PRINTK(("page status=0x%02x, nextpage=%d, packetsize=%d\n",
-       header_buf.status, header_buf.Rx_NextPage, header_buf.Rx_ByteCount));
+       pr_debug("page status=0x%02x, nextpage=%d, packetsize=%d\n",
+               header_buf.status, header_buf.Rx_NextPage,
+               header_buf.Rx_ByteCount);
 
        /* Plausible page header? */
        pagelink = header_buf.Rx_NextPage;
@@ -683,7 +661,7 @@ static int de620_rx_intr(struct net_device *dev)
                        buffer = skb_put(skb,size);
                        /* copy the packet into the buffer */
                        de620_read_block(dev, buffer, size);
-                       PRINTK(("Read %d bytes\n", size));
+                       pr_debug("Read %d bytes\n", size);
                        skb->protocol=eth_type_trans(skb,dev);
                        netif_rx(skb); /* deliver it "upstairs" */
                        /* count all receives */
@@ -696,9 +674,9 @@ static int de620_rx_intr(struct net_device *dev)
        /* NOTE! We're _not_ checking the 'EMPTY'-flag! This seems better... */
        curr_page = de620_get_register(dev, R_CPR);
        de620_set_register(dev, W_NPRF, next_rx_page);
-       PRINTK(("next_rx_page=%d CPR=%d\n", next_rx_page, curr_page));
+       pr_debug("next_rx_page=%d CPR=%d\n", next_rx_page, curr_page);
 
-       return (next_rx_page != curr_page); /* That was slightly tricky... */
+       return next_rx_page != curr_page; /* That was slightly tricky... */
 }
 
 /*********************************************
@@ -784,6 +762,17 @@ static int adapter_init(struct net_device *dev)
        return 0; /* all ok */
 }
 
+static const struct net_device_ops de620_netdev_ops = {
+       .ndo_open               = de620_open,
+       .ndo_stop               = de620_close,
+       .ndo_start_xmit         = de620_start_xmit,
+       .ndo_tx_timeout         = de620_timeout,
+       .ndo_set_multicast_list = de620_set_multicast_list,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 /******************************************************************************
  *
  * Only start-up code below
@@ -819,8 +808,7 @@ struct net_device * __init de620_probe(int unit)
                netdev_boot_setup_check(dev);
        }
 
-       if (de620_debug)
-               printk(version);
+       pr_debug("%s", version);
 
        printk(KERN_INFO "D-Link DE-620 pocket adapter");
 
@@ -861,24 +849,19 @@ struct net_device * __init de620_probe(int unit)
        else
                printk(" UTP)\n");
 
-       dev->open               = de620_open;
-       dev->stop               = de620_close;
-       dev->hard_start_xmit    = de620_start_xmit;
-       dev->tx_timeout         = de620_timeout;
+       dev->netdev_ops = &de620_netdev_ops;
        dev->watchdog_timeo     = HZ*2;
-       dev->set_multicast_list = de620_set_multicast_list;
 
        /* base_addr and irq are already set, see above! */
 
        /* dump eeprom */
-       if (de620_debug) {
-               printk("\nEEPROM contents:\n");
-               printk("RAM_Size = 0x%02X\n", nic_data.RAM_Size);
-               printk("NodeID = %pM\n", nic_data.NodeID);
-               printk("Model = %d\n", nic_data.Model);
-               printk("Media = %d\n", nic_data.Media);
-               printk("SCR = 0x%02x\n", nic_data.SCR);
-       }
+       pr_debug("\nEEPROM contents:\n"
+               "RAM_Size = 0x%02X\n"
+               "NodeID = %pM\n"
+               "Model = %d\n"
+               "Media = %d\n"
+               "SCR = 0x%02x\n", nic_data.RAM_Size, nic_data.NodeID,
+               nic_data.Model, nic_data.Media, nic_data.SCR);
 
        err = register_netdev(dev);
        if (err)