[S390] convert dcssblk and extmem printks messages to pr_xxx macros.
[safe/jmp/linux-2.6] / drivers / net / eepro100.c
index bccb12e..e3e26c5 100644 (file)
@@ -28,7 +28,7 @@
 */
 
 static const char * const version =
-"eepro100.c:v1.09j-t 9/29/99 Donald Becker http://www.scyld.com/network/eepro100.html\n"
+"eepro100.c:v1.09j-t 9/29/99 Donald Becker\n"
 "eepro100.c: $Revision: 1.36 $ 2000/11/17 Modified by Andrey V. Savochkin <saw@saw.sw.com.sg> and others\n";
 
 /* A few user-configurable values that apply to all boards.
@@ -304,13 +304,7 @@ enum commands {
 #if defined(__alpha__)
 # define clear_suspend(cmd)  clear_bit(30, &(cmd)->cmd_status);
 #else
-# if defined(__LITTLE_ENDIAN)
-#  define clear_suspend(cmd)  ((__u16 *)&(cmd)->cmd_status)[1] &= ~0x4000
-# elif defined(__BIG_ENDIAN)
-#  define clear_suspend(cmd)  ((__u16 *)&(cmd)->cmd_status)[1] &= ~0x0040
-# else
-#  error Unsupported byteorder
-# endif
+# define clear_suspend(cmd)  ((__le16 *)&(cmd)->cmd_status)[1] &= ~cpu_to_le16(1<<14)
 #endif
 
 enum SCBCmdBits {
@@ -331,17 +325,17 @@ enum SCBPort_cmds {
 
 /* The Speedo3 Rx and Tx frame/buffer descriptors. */
 struct descriptor {                        /* A generic descriptor. */
-       volatile s32 cmd_status;        /* All command and status fields. */
-       u32 link;                                   /* struct descriptor *  */
+       volatile __le32 cmd_status;     /* All command and status fields. */
+       __le32 link;                                /* struct descriptor *  */
        unsigned char params[0];
 };
 
 /* The Speedo3 Rx and Tx buffer descriptors. */
 struct RxFD {                                  /* Receive frame descriptor. */
-       volatile s32 status;
-       u32 link;                                       /* struct RxFD * */
-       u32 rx_buf_addr;                        /* void * */
-       u32 count;
+       volatile __le32 status;
+       __le32 link;                                    /* struct RxFD * */
+       __le32 rx_buf_addr;                     /* void * */
+       __le32 count;
 } RxFD_ALIGNMENT;
 
 /* Selected elements of the Tx/RxFD.status word. */
@@ -354,16 +348,16 @@ enum RxFD_bits {
 
 #define CONFIG_DATA_SIZE 22
 struct TxFD {                                  /* Transmit frame descriptor set. */
-       s32 status;
-       u32 link;                                       /* void * */
-       u32 tx_desc_addr;                       /* Always points to the tx_buf_addr element. */
-       s32 count;                                      /* # of TBD (=1), Tx start thresh., etc. */
+       __le32 status;
+       __le32 link;                                    /* void * */
+       __le32 tx_desc_addr;                    /* Always points to the tx_buf_addr element. */
+       __le32 count;                                   /* # of TBD (=1), Tx start thresh., etc. */
        /* This constitutes two "TBD" entries -- we only use one. */
 #define TX_DESCR_BUF_OFFSET 16
-       u32 tx_buf_addr0;                       /* void *, frame to be transmitted.  */
-       s32 tx_buf_size0;                       /* Length of Tx frame. */
-       u32 tx_buf_addr1;                       /* void *, frame to be transmitted.  */
-       s32 tx_buf_size1;                       /* Length of Tx frame. */
+       __le32 tx_buf_addr0;                    /* void *, frame to be transmitted.  */
+       __le32 tx_buf_size0;                    /* Length of Tx frame. */
+       __le32 tx_buf_addr1;                    /* void *, frame to be transmitted.  */
+       __le32 tx_buf_size1;                    /* Length of Tx frame. */
        /* the structure must have space for at least CONFIG_DATA_SIZE starting
         * from tx_desc_addr field */
 };
@@ -379,23 +373,23 @@ struct speedo_mc_block {
 
 /* Elements of the dump_statistics block. This block must be lword aligned. */
 struct speedo_stats {
-       u32 tx_good_frames;
-       u32 tx_coll16_errs;
-       u32 tx_late_colls;
-       u32 tx_underruns;
-       u32 tx_lost_carrier;
-       u32 tx_deferred;
-       u32 tx_one_colls;
-       u32 tx_multi_colls;
-       u32 tx_total_colls;
-       u32 rx_good_frames;
-       u32 rx_crc_errs;
-       u32 rx_align_errs;
-       u32 rx_resource_errs;
-       u32 rx_overrun_errs;
-       u32 rx_colls_errs;
-       u32 rx_runt_errs;
-       u32 done_marker;
+       __le32 tx_good_frames;
+       __le32 tx_coll16_errs;
+       __le32 tx_late_colls;
+       __le32 tx_underruns;
+       __le32 tx_lost_carrier;
+       __le32 tx_deferred;
+       __le32 tx_one_colls;
+       __le32 tx_multi_colls;
+       __le32 tx_total_colls;
+       __le32 rx_good_frames;
+       __le32 rx_crc_errs;
+       __le32 rx_align_errs;
+       __le32 rx_resource_errs;
+       __le32 rx_overrun_errs;
+       __le32 rx_colls_errs;
+       __le32 rx_runt_errs;
+       __le32 done_marker;
 };
 
 enum Rx_ring_state_bits {
@@ -488,15 +482,15 @@ static int speedo_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static void speedo_refill_rx_buffers(struct net_device *dev, int force);
 static int speedo_rx(struct net_device *dev);
 static void speedo_tx_buffer_gc(struct net_device *dev);
-static irqreturn_t speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t speedo_interrupt(int irq, void *dev_instance);
 static int speedo_close(struct net_device *dev);
 static struct net_device_stats *speedo_get_stats(struct net_device *dev);
 static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void set_rx_mode(struct net_device *dev);
 static void speedo_show_state(struct net_device *dev);
-static struct ethtool_ops ethtool_ops;
+static const struct ethtool_ops ethtool_ops;
+
 
-\f
 
 #ifdef honor_default_port
 /* Optional driver feature to allow forcing the transceiver setting.
@@ -555,14 +549,12 @@ static int __devinit eepro100_init_one (struct pci_dev *pdev,
 
        if (!request_region(pci_resource_start(pdev, 1),
                        pci_resource_len(pdev, 1), "eepro100")) {
-               dev_printk (KERN_ERR, &pdev->dev,
-                       "eepro100: cannot reserve I/O ports\n");
+               dev_err(&pdev->dev, "eepro100: cannot reserve I/O ports\n");
                goto err_out_none;
        }
        if (!request_mem_region(pci_resource_start(pdev, 0),
                        pci_resource_len(pdev, 0), "eepro100")) {
-               dev_printk (KERN_ERR, &pdev->dev,
-                       "eepro100: cannot reserve MMIO region\n");
+               dev_err(&pdev->dev, "eepro100: cannot reserve MMIO region\n");
                goto err_out_free_pio_region;
        }
 
@@ -575,7 +567,7 @@ static int __devinit eepro100_init_one (struct pci_dev *pdev,
 
        ioaddr = pci_iomap(pdev, pci_bar, 0);
        if (!ioaddr) {
-               dev_printk (KERN_ERR, &pdev->dev, "eepro100: cannot remap IO\n");
+               dev_err(&pdev->dev, "eepro100: cannot remap IO\n");
                goto err_out_free_mmio_region;
        }
 
@@ -608,7 +600,7 @@ static void poll_speedo (struct net_device *dev)
        /* disable_irq is not very nice, but with the funny lockless design
           we have no other choice. */
        disable_irq(dev->irq);
-       speedo_interrupt (dev->irq, dev, NULL);
+       speedo_interrupt (dev->irq, dev);
        enable_irq(dev->irq);
 }
 #endif
@@ -624,6 +616,7 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
        int size;
        void *tx_ring_space;
        dma_addr_t tx_ring_dma;
+       DECLARE_MAC_BUF(mac);
 
        size = TX_RING_SIZE * sizeof(struct TxFD) + sizeof(struct speedo_stats);
        tx_ring_space = pci_alloc_consistent(pdev, size, &tx_ring_dma);
@@ -637,7 +630,6 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
                return -1;
        }
 
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        if (dev->mem_start > 0)
@@ -648,7 +640,7 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
                option = 0;
 
        rtnl_lock();
-       if (dev_alloc_name(dev, dev->name) < 0) 
+       if (dev_alloc_name(dev, dev->name) < 0)
                goto err_free_unlock;
 
        /* Read the station address EEPROM before doing the reset.
@@ -708,12 +700,8 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
        else
                product = pci_name(pdev);
 
-       printk(KERN_INFO "%s: %s, ", dev->name, product);
-
-       for (i = 0; i < 5; i++)
-               printk("%2.2X:", dev->dev_addr[i]);
-       printk("%2.2X, ", dev->dev_addr[i]);
-       printk("IRQ %d.\n", pdev->irq);
+       printk(KERN_INFO "%s: %s, %s, IRQ %d.\n", dev->name, product,
+                  print_mac(mac, dev->dev_addr), pdev->irq);
 
        sp = netdev_priv(dev);
 
@@ -827,10 +815,10 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
        sp->mii_if.dev = dev;
        sp->mii_if.mdio_read = mdio_read;
        sp->mii_if.mdio_write = mdio_write;
-       
+
        sp->rx_bug = (eeprom[3] & 0x03) == 3 ? 0 : 1;
-       if (((pdev->device > 0x1030 && (pdev->device < 0x103F))) 
-           || (pdev->device == 0x2449) || (pdev->device == 0x2459) 
+       if (((pdev->device > 0x1030 && (pdev->device < 0x103F)))
+           || (pdev->device == 0x2449) || (pdev->device == 0x2459)
             || (pdev->device == 0x245D)) {
                sp->chip_id = 1;
        }
@@ -1145,7 +1133,7 @@ speedo_rx_soft_reset(struct net_device *dev)
 
        rfd = sp->rx_ringp[sp->cur_rx % RX_RING_SIZE];
 
-       rfd->rx_buf_addr = 0xffffffff;
+       rfd->rx_buf_addr = cpu_to_le32(0xffffffff);
 
        if (wait_for_cmd_done(dev, sp) != 0) {
                printk("%s: RxAbort command stalled\n", dev->name);
@@ -1210,7 +1198,7 @@ static void speedo_show_state(struct net_device *dev)
        int i;
 
        if (netif_msg_pktdata(sp)) {
-               printk(KERN_DEBUG "%s: Tx ring dump,  Tx queue %u / %u:\n", 
+               printk(KERN_DEBUG "%s: Tx ring dump,  Tx queue %u / %u:\n",
                    dev->name, sp->cur_tx, sp->dirty_tx);
                for (i = 0; i < TX_RING_SIZE; i++)
                        printk(KERN_DEBUG "%s:  %c%c%2d %8.8x.\n", dev->name,
@@ -1281,7 +1269,7 @@ speedo_init_rx_ring(struct net_device *dev)
                rxf->status = cpu_to_le32(0x00000001);  /* '1' is flag value only. */
                rxf->link = 0;                                          /* None yet. */
                /* This field unused by i82557. */
-               rxf->rx_buf_addr = 0xffffffff;
+               rxf->rx_buf_addr = cpu_to_le32(0xffffffff);
                rxf->count = cpu_to_le32(PKT_BUF_SZ << 16);
                pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[i],
                                                                           sizeof(struct RxFD), PCI_DMA_TODEVICE);
@@ -1543,7 +1531,7 @@ static void speedo_tx_buffer_gc(struct net_device *dev)
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static irqreturn_t speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t speedo_interrupt(int irq, void *dev_instance)
 {
        struct net_device *dev = (struct net_device *)dev_instance;
        struct speedo_private *sp;
@@ -1588,7 +1576,7 @@ static irqreturn_t speedo_interrupt(int irq, void *dev_instance, struct pt_regs
 
                /* Always check if all rx buffers are allocated.  --SAW */
                speedo_refill_rx_buffers(dev, 0);
-               
+
                spin_lock(&sp->lock);
                /*
                 * The chip may have suspended reception for various reasons.
@@ -1609,8 +1597,8 @@ static irqreturn_t speedo_interrupt(int irq, void *dev_instance, struct pt_regs
                        /* these are all reserved values */
                        break;
                }
-               
-               
+
+
                /* User interrupt, Command/Tx unit interrupt or CU not active. */
                if (status & 0xA400) {
                        speedo_tx_buffer_gc(dev);
@@ -1621,7 +1609,7 @@ static irqreturn_t speedo_interrupt(int irq, void *dev_instance, struct pt_regs
                                netif_wake_queue(dev); /* Attention: under a spinlock.  --SAW */
                        }
                }
-               
+
                spin_unlock(&sp->lock);
 
                if (--boguscnt < 0) {
@@ -1663,7 +1651,7 @@ static inline struct RxFD *speedo_rx_alloc(struct net_device *dev, int entry)
                                           PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
        skb->dev = dev;
        skb_reserve(skb, sizeof(struct RxFD));
-       rxf->rx_buf_addr = 0xffffffff;
+       rxf->rx_buf_addr = cpu_to_le32(0xffffffff);
        pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[entry],
                                                                   sizeof(struct RxFD), PCI_DMA_TODEVICE);
        return rxf;
@@ -1794,8 +1782,7 @@ speedo_rx(struct net_device *dev)
                        /* Check if the packet is long enough to just accept without
                           copying to a properly sized skbuff. */
                        if (pkt_len < rx_copybreak
-                               && (skb = dev_alloc_skb(pkt_len + 2)) != 0) {
-                               skb->dev = dev;
+                               && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
                                skb_reserve(skb, 2);    /* Align IP on 16 byte boundaries */
                                /* 'skb_put()' points to the start of sk_buff data area. */
                                pci_dma_sync_single_for_cpu(sp->pdev, sp->rx_ring_dma[entry],
@@ -1804,11 +1791,12 @@ speedo_rx(struct net_device *dev)
 
 #if 1 || USE_IP_CSUM
                                /* Packet is in one chunk -- we can copy + cksum. */
-                               eth_copy_and_sum(skb, sp->rx_skbuff[entry]->data, pkt_len, 0);
+                               skb_copy_to_linear_data(skb, sp->rx_skbuff[entry]->data, pkt_len);
                                skb_put(skb, pkt_len);
 #else
-                               memcpy(skb_put(skb, pkt_len), sp->rx_skbuff[entry]->data,
-                                          pkt_len);
+                               skb_copy_from_linear_data(sp->rx_skbuff[entry],
+                                                         skb_put(skb, pkt_len),
+                                                         pkt_len);
 #endif
                                pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[entry],
                                                                                           sizeof(struct RxFD) + pkt_len,
@@ -1939,7 +1927,7 @@ speedo_get_stats(struct net_device *dev)
        void __iomem *ioaddr = sp->regs;
 
        /* Update only if the previous dump finished. */
-       if (sp->lstats->done_marker == le32_to_cpu(0xA007)) {
+       if (sp->lstats->done_marker == cpu_to_le32(0xA007)) {
                sp->stats.tx_aborted_errors += le32_to_cpu(sp->lstats->tx_coll16_errs);
                sp->stats.tx_window_errors += le32_to_cpu(sp->lstats->tx_late_colls);
                sp->stats.tx_fifo_errors += le32_to_cpu(sp->lstats->tx_underruns);
@@ -2017,7 +2005,7 @@ static void speedo_set_msglevel(struct net_device *dev, u32 v)
        sp->msg_enable = v;
 }
 
-static struct ethtool_ops ethtool_ops = {
+static const struct ethtool_ops ethtool_ops = {
        .get_drvinfo = speedo_get_drvinfo,
        .get_settings = speedo_get_settings,
        .set_settings = speedo_set_settings,
@@ -2148,7 +2136,7 @@ static void set_rx_mode(struct net_device *dev)
                /* The simple case of 0-3 multicast list entries occurs often, and
                   fits within one tx_ring[] entry. */
                struct dev_mc_list *mclist;
-               u16 *setup_params, *eaddrs;
+               __le16 *setup_params, *eaddrs;
 
                spin_lock_irqsave(&sp->lock, flags);
                entry = sp->cur_tx++ % TX_RING_SIZE;
@@ -2160,12 +2148,12 @@ static void set_rx_mode(struct net_device *dev)
                sp->tx_ring[entry].link =
                        cpu_to_le32(TX_RING_ELEM_DMA(sp, (entry + 1) % TX_RING_SIZE));
                sp->tx_ring[entry].tx_desc_addr = 0; /* Really MC list count. */
-               setup_params = (u16 *)&sp->tx_ring[entry].tx_desc_addr;
+               setup_params = (__le16 *)&sp->tx_ring[entry].tx_desc_addr;
                *setup_params++ = cpu_to_le16(dev->mc_count*6);
                /* Fill in the multicast addresses. */
                for (i = 0, mclist = dev->mc_list; i < dev->mc_count;
                         i++, mclist = mclist->next) {
-                       eaddrs = (u16 *)mclist->dmi_addr;
+                       eaddrs = (__le16 *)mclist->dmi_addr;
                        *setup_params++ = *eaddrs++;
                        *setup_params++ = *eaddrs++;
                        *setup_params++ = *eaddrs++;
@@ -2183,7 +2171,7 @@ static void set_rx_mode(struct net_device *dev)
                spin_unlock_irqrestore(&sp->lock, flags);
        } else if (new_rx_mode == 0) {
                struct dev_mc_list *mclist;
-               u16 *setup_params, *eaddrs;
+               __le16 *setup_params, *eaddrs;
                struct speedo_mc_block *mc_blk;
                struct descriptor *mc_setup_frm;
                int i;
@@ -2210,12 +2198,12 @@ static void set_rx_mode(struct net_device *dev)
                mc_setup_frm->cmd_status =
                        cpu_to_le32(CmdSuspend | CmdIntr | CmdMulticastList);
                /* Link set below. */
-               setup_params = (u16 *)&mc_setup_frm->params;
+               setup_params = (__le16 *)&mc_setup_frm->params;
                *setup_params++ = cpu_to_le16(dev->mc_count*6);
                /* Fill in the multicast addresses. */
                for (i = 0, mclist = dev->mc_list; i < dev->mc_count;
                         i++, mclist = mclist->next) {
-                       eaddrs = (u16 *)mclist->dmi_addr;
+                       eaddrs = (__le16 *)mclist->dmi_addr;
                        *setup_params++ = *eaddrs++;
                        *setup_params++ = *eaddrs++;
                        *setup_params++ = *eaddrs++;
@@ -2265,7 +2253,7 @@ static void set_rx_mode(struct net_device *dev)
 
        sp->rx_mode = new_rx_mode;
 }
-\f
+
 #ifdef CONFIG_PM
 static int eepro100_suspend(struct pci_dev *pdev, pm_message_t state)
 {
@@ -2277,12 +2265,12 @@ static int eepro100_suspend(struct pci_dev *pdev, pm_message_t state)
 
        if (!netif_running(dev))
                return 0;
-               
+
        del_timer_sync(&sp->timer);
 
        netif_device_detach(dev);
        iowrite32(PortPartialReset, ioaddr + SCBPort);
-       
+
        /* XXX call pci_set_power_state ()? */
        pci_disable_device(pdev);
        pci_set_power_state (pdev, PCI_D3hot);
@@ -2294,10 +2282,15 @@ static int eepro100_resume(struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata (pdev);
        struct speedo_private *sp = netdev_priv(dev);
        void __iomem *ioaddr = sp->regs;
+       int rc;
 
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
-       pci_enable_device(pdev);
+
+       rc = pci_enable_device(pdev);
+       if (rc)
+               return rc;
+
        pci_set_master(pdev);
 
        if (!netif_running(dev))
@@ -2326,7 +2319,7 @@ static void __devexit eepro100_remove_one (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
        struct speedo_private *sp = netdev_priv(dev);
-       
+
        unregister_netdev(dev);
 
        release_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1));
@@ -2339,7 +2332,7 @@ static void __devexit eepro100_remove_one (struct pci_dev *pdev)
        pci_disable_device(pdev);
        free_netdev(dev);
 }
-\f
+
 static struct pci_device_id eepro100_pci_tbl[] = {
        { PCI_VENDOR_ID_INTEL, 0x1229, PCI_ANY_ID, PCI_ANY_ID, },
        { PCI_VENDOR_ID_INTEL, 0x1209, PCI_ANY_ID, PCI_ANY_ID, },
@@ -2370,7 +2363,7 @@ static struct pci_device_id eepro100_pci_tbl[] = {
        { 0,}
 };
 MODULE_DEVICE_TABLE(pci, eepro100_pci_tbl);
-       
+
 static struct pci_driver eepro100_driver = {
        .name           = "eepro100",
        .id_table       = eepro100_pci_tbl,
@@ -2387,7 +2380,7 @@ static int __init eepro100_init_module(void)
 #ifdef MODULE
        printk(version);
 #endif
-       return pci_module_init(&eepro100_driver);
+       return pci_register_driver(&eepro100_driver);
 }
 
 static void __exit eepro100_cleanup_module(void)
@@ -2397,7 +2390,7 @@ static void __exit eepro100_cleanup_module(void)
 
 module_init(eepro100_init_module);
 module_exit(eepro100_cleanup_module);
-\f
+
 /*
  * Local variables:
  *  compile-command: "gcc -DMODULE -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -c eepro100.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`"