]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/net/pcmcia/pcnet_cs.c
pcnet_cs: Use proper netdev_*-printouts
[net-next-2.6.git] / drivers / net / pcmcia / pcnet_cs.c
index bfdef72c5d5ea6371b2fc634c9e2a8476d13fa33..296f8a8e57ca9e44d76de37ac377dfe88197e1ef 100644 (file)
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/delay.h>
-#include <linux/ethtool.h>
 #include <linux/netdevice.h>
 #include <linux/log2.h>
 #include <linux/etherdevice.h>
 #include <linux/mii.h>
 #include "../8390.h"
 
-#include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
 #include <pcmcia/ciscode.h>
@@ -101,7 +99,6 @@ static void pcnet_release(struct pcmcia_device *link);
 static int pcnet_open(struct net_device *dev);
 static int pcnet_close(struct net_device *dev);
 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-static const struct ethtool_ops netdev_ethtool_ops;
 static irqreturn_t ei_irq_wrapper(int irq, void *dev_id);
 static void ei_watchdog(u_long arg);
 static void pcnet_reset_8390(struct net_device *dev);
@@ -113,8 +110,6 @@ static int setup_dma_config(struct pcmcia_device *link, int start_pg,
 
 static void pcnet_detach(struct pcmcia_device *p_dev);
 
-static dev_info_t dev_info = "pcnet_cs";
-
 /*====================================================================*/
 
 typedef struct hw_info_t {
@@ -304,7 +299,6 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
 {
     struct net_device *dev = link->priv;
     win_req_t req;
-    memreq_t mem;
     u_char __iomem *base, *virt;
     int i, j;
 
@@ -317,10 +311,8 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
        return NULL;
 
     virt = ioremap(req.Base, req.Size);
-    mem.Page = 0;
     for (i = 0; i < NR_INFO; i++) {
-       mem.CardOffset = hw_info[i].offset & ~(req.Size-1);
-       pcmcia_map_mem_page(link, link->win, &mem);
+       pcmcia_map_mem_page(link, link->win, hw_info[i].offset & ~(req.Size-1));
        base = &virt[hw_info[i].offset & (req.Size-1)];
        if ((readb(base+0) == hw_info[i].a0) &&
            (readb(base+2) == hw_info[i].a1) &&
@@ -480,29 +472,31 @@ static hw_info_t *get_hwired(struct pcmcia_device *link)
 static int try_io_port(struct pcmcia_device *link)
 {
     int j, ret;
-    if (link->io.NumPorts1 == 32) {
-       link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
-       if (link->io.NumPorts2 > 0) {
+    link->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
+    link->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
+    if (link->resource[0]->end == 32) {
+       link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
+       if (link->resource[1]->end > 0) {
            /* for master/slave multifunction cards */
-           link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
+           link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
        }
     } else {
        /* This should be two 16-port windows */
-       link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-       link->io.Attributes2 = IO_DATA_PATH_WIDTH_16;
+       link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
+       link->resource[1]->flags |= IO_DATA_PATH_WIDTH_16;
     }
-    if (link->io.BasePort1 == 0) {
-       link->io.IOAddrLines = 16;
+    if (link->resource[0]->start == 0) {
        for (j = 0; j < 0x400; j += 0x20) {
-           link->io.BasePort1 = j ^ 0x300;
-           link->io.BasePort2 = (j ^ 0x300) + 0x10;
-           ret = pcmcia_request_io(link, &link->io);
+           link->resource[0]->start = j ^ 0x300;
+           link->resource[1]->start = (j ^ 0x300) + 0x10;
+           link->io_lines = 16;
+           ret = pcmcia_request_io(link);
            if (ret == 0)
                    return ret;
        }
        return ret;
     } else {
-       return pcmcia_request_io(link, &link->io);
+       return pcmcia_request_io(link);
     }
 }
 
@@ -523,18 +517,18 @@ static int pcnet_confcheck(struct pcmcia_device *p_dev,
           network function with window 0, and serial with window 1 */
        if (io->nwin > 1) {
                i = (io->win[1].len > io->win[0].len);
-               p_dev->io.BasePort2 = io->win[1-i].base;
-               p_dev->io.NumPorts2 = io->win[1-i].len;
+               p_dev->resource[1]->start = io->win[1-i].base;
+               p_dev->resource[1]->end = io->win[1-i].len;
        } else {
-               i = p_dev->io.NumPorts2 = 0;
+               i = p_dev->resource[1]->end = 0;
        }
 
        *has_shmem = ((cfg->mem.nwin == 1) &&
                      (cfg->mem.win[0].len >= 0x4000));
-       p_dev->io.BasePort1 = io->win[i].base;
-       p_dev->io.NumPorts1 = io->win[i].len;
-       p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
-       if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32)
+       p_dev->resource[0]->start = io->win[i].base;
+       p_dev->resource[0]->end = io->win[i].len;
+       p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
+       if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32)
                return try_io_port(p_dev);
 
        return 0;
@@ -557,7 +551,7 @@ static int pcnet_config(struct pcmcia_device *link)
     if (!link->irq)
            goto failed;
 
-    if (link->io.NumPorts2 == 8) {
+    if (resource_size(link->resource[1]) == 8) {
        link->conf.Attributes |= CONF_ENABLE_SPKR;
        link->conf.Status = CCSR_AUDIO_ENA;
     }
@@ -569,7 +563,7 @@ static int pcnet_config(struct pcmcia_device *link)
     if (ret)
            goto failed;
     dev->irq = link->irq;
-    dev->base_addr = link->io.BasePort1;
+    dev->base_addr = link->resource[0]->start;
     if (info->flags & HAS_MISC_REG) {
        if ((if_port == 1) || (if_port == 2))
            dev->if_port = if_port;
@@ -632,8 +626,6 @@ static int pcnet_config(struct pcmcia_device *link)
     ei_status.word16 = 1;
     ei_status.reset_8390 = &pcnet_reset_8390;
 
-    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
-
     if (info->flags & (IS_DL10019|IS_DL10022))
        mii_phy_probe(dev);
 
@@ -646,12 +638,12 @@ static int pcnet_config(struct pcmcia_device *link)
 
     if (info->flags & (IS_DL10019|IS_DL10022)) {
        u_char id = inb(dev->base_addr + 0x1a);
-       printk(KERN_INFO "%s: NE2000 (DL100%d rev %02x): ",
-              dev->name, ((info->flags & IS_DL10022) ? 22 : 19), id);
+       netdev_info(dev, "NE2000 (DL100%d rev %02x): ",
+              (info->flags & IS_DL10022) ? 22 : 19, id);
        if (info->pna_phy)
            printk("PNA, ");
     } else {
-       printk(KERN_INFO "%s: NE2000 Compatible: ", dev->name);
+       netdev_info(dev, "NE2000 Compatible: ");
     }
     printk("io %#3lx, irq %d,", dev->base_addr, dev->irq);
     if (info->flags & USE_SHMEM)
@@ -932,7 +924,7 @@ static void mii_phy_probe(struct net_device *dev)
        phyid = tmp << 16;
        phyid |= mdio_read(mii_addr, i, MII_PHYID_REG2);
        phyid &= MII_PHYID_REV_MASK;
-       pr_debug("%s: MII at %d is 0x%08x\n", dev->name, i, phyid);
+       netdev_dbg(dev, "MII at %d is 0x%08x\n", i, phyid);
        if (phyid == AM79C9XX_HOME_PHY) {
            info->pna_phy = i;
        } else if (phyid != AM79C9XX_ETH_PHY) {
@@ -956,7 +948,7 @@ static int pcnet_open(struct net_device *dev)
     set_misc_reg(dev);
 
     outb_p(0xFF, nic_base + EN0_ISR); /* Clear bogus intr. */
-    ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev_info, dev);
+    ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev->name, dev);
     if (ret)
            return ret;
 
@@ -1018,8 +1010,8 @@ static void pcnet_reset_8390(struct net_device *dev)
     outb_p(ENISR_RESET, nic_base + EN0_ISR); /* Ack intr. */
 
     if (i == 100)
-       printk(KERN_ERR "%s: pcnet_reset_8390() did not complete.\n",
-              dev->name);
+       netdev_err(dev, "pcnet_reset_8390() did not complete.\n");
+
     set_misc_reg(dev);
 
 } /* pcnet_reset_8390 */
@@ -1035,8 +1027,7 @@ static int set_config(struct net_device *dev, struct ifmap *map)
        else if ((map->port < 1) || (map->port > 2))
            return -EINVAL;
        dev->if_port = map->port;
-       printk(KERN_INFO "%s: switched to %s port\n",
-              dev->name, if_names[dev->if_port]);
+       netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]);
        NS8390_init(dev, 1);
     }
     return 0;
@@ -1071,7 +1062,7 @@ static void ei_watchdog(u_long arg)
        this, we can limp along even if the interrupt is blocked */
     if (info->stale++ && (inb_p(nic_base + EN0_ISR) & ENISR_ALL)) {
        if (!info->fast_poll)
-           printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
+           netdev_info(dev, "interrupt(s) dropped!\n");
        ei_irq_wrapper(dev->irq, dev);
        info->fast_poll = HZ;
     }
@@ -1091,7 +1082,7 @@ static void ei_watchdog(u_long arg)
        if (info->eth_phy) {
            info->phy_id = info->eth_phy = 0;
        } else {
-           printk(KERN_INFO "%s: MII is missing!\n", dev->name);
+           netdev_info(dev, "MII is missing!\n");
            info->flags &= ~HAS_MII;
        }
        goto reschedule;
@@ -1100,8 +1091,7 @@ static void ei_watchdog(u_long arg)
     link &= 0x0004;
     if (link != info->link_status) {
        u_short p = mdio_read(mii_addr, info->phy_id, 5);
-       printk(KERN_INFO "%s: %s link beat\n", dev->name,
-              (link) ? "found" : "lost");
+       netdev_info(dev, "%s link beat\n", link ? "found" : "lost");
        if (link && (info->flags & IS_DL10022)) {
            /* Disable collision detection on full duplex links */
            outb((p & 0x0140) ? 4 : 0, nic_base + DLINK_DIAG);
@@ -1112,13 +1102,12 @@ static void ei_watchdog(u_long arg)
        if (link) {
            if (info->phy_id == info->eth_phy) {
                if (p)
-                   printk(KERN_INFO "%s: autonegotiation complete: "
-                          "%sbaseT-%cD selected\n", dev->name,
+                   netdev_info(dev, "autonegotiation complete: "
+                          "%sbaseT-%cD selected\n",
                           ((p & 0x0180) ? "100" : "10"),
                           ((p & 0x0140) ? 'F' : 'H'));
                else
-                   printk(KERN_INFO "%s: link partner did not "
-                          "autonegotiate\n", dev->name);
+                   netdev_info(dev, "link partner did not autonegotiate\n");
            }
            NS8390_init(dev, 1);
        }
@@ -1131,7 +1120,7 @@ static void ei_watchdog(u_long arg)
            /* isolate this MII and try flipping to the other one */
            mdio_write(mii_addr, info->phy_id, 0, 0x0400);
            info->phy_id ^= info->pna_phy ^ info->eth_phy;
-           printk(KERN_INFO "%s: switched to %s transceiver\n", dev->name,
+           netdev_info(dev, "switched to %s transceiver\n",
                   (info->phy_id == info->eth_phy) ? "ethernet" : "PNA");
            mdio_write(mii_addr, info->phy_id, 0,
                       (info->phy_id == info->eth_phy) ? 0x1000 : 0);
@@ -1147,18 +1136,6 @@ reschedule:
 
 /*====================================================================*/
 
-static void netdev_get_drvinfo(struct net_device *dev,
-                              struct ethtool_drvinfo *info)
-{
-       strcpy(info->driver, "pcnet_cs");
-}
-
-static const struct ethtool_ops netdev_ethtool_ops = {
-       .get_drvinfo            = netdev_get_drvinfo,
-};
-
-/*====================================================================*/
-
 
 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
@@ -1191,9 +1168,9 @@ static void dma_get_8390_hdr(struct net_device *dev,
     unsigned int nic_base = dev->base_addr;
 
     if (ei_status.dmaing) {
-       printk(KERN_NOTICE "%s: DMAing conflict in dma_block_input."
+       netdev_notice(dev, "DMAing conflict in dma_block_input."
               "[DMAstat:%1x][irqlock:%1x]\n",
-              dev->name, ei_status.dmaing, ei_status.irqlock);
+              ei_status.dmaing, ei_status.irqlock);
        return;
     }
 
@@ -1224,11 +1201,11 @@ static void dma_block_input(struct net_device *dev, int count,
     char *buf = skb->data;
 
     if ((ei_debug > 4) && (count != 4))
-       pr_debug("%s: [bi=%d]\n", dev->name, count+4);
+       netdev_dbg(dev, "[bi=%d]\n", count+4);
     if (ei_status.dmaing) {
-       printk(KERN_NOTICE "%s: DMAing conflict in dma_block_input."
+       netdev_notice(dev, "DMAing conflict in dma_block_input."
               "[DMAstat:%1x][irqlock:%1x]\n",
-              dev->name, ei_status.dmaing, ei_status.irqlock);
+              ei_status.dmaing, ei_status.irqlock);
        return;
     }
     ei_status.dmaing |= 0x01;
@@ -1258,9 +1235,9 @@ static void dma_block_input(struct net_device *dev, int count,
                break;
        } while (--tries > 0);
        if (tries <= 0)
-           printk(KERN_NOTICE "%s: RX transfer address mismatch,"
+           netdev_notice(dev, "RX transfer address mismatch,"
                   "%#4.4x (expected) vs. %#4.4x (actual).\n",
-                  dev->name, ring_offset + xfer_count, addr);
+                  ring_offset + xfer_count, addr);
     }
 #endif
     outb_p(ENISR_RDC, nic_base + EN0_ISR);     /* Ack intr. */
@@ -1281,7 +1258,7 @@ static void dma_block_output(struct net_device *dev, int count,
 
 #ifdef PCMCIA_DEBUG
     if (ei_debug > 4)
-       printk(KERN_DEBUG "%s: [bo=%d]\n", dev->name, count);
+       netdev_dbg(dev, "[bo=%d]\n", count);
 #endif
 
     /* Round the count up for word writes.  Do we need to do this?
@@ -1290,9 +1267,9 @@ static void dma_block_output(struct net_device *dev, int count,
     if (count & 0x01)
        count++;
     if (ei_status.dmaing) {
-       printk(KERN_NOTICE "%s: DMAing conflict in dma_block_output."
+       netdev_notice(dev, "DMAing conflict in dma_block_output."
               "[DMAstat:%1x][irqlock:%1x]\n",
-              dev->name, ei_status.dmaing, ei_status.irqlock);
+              ei_status.dmaing, ei_status.irqlock);
        return;
     }
     ei_status.dmaing |= 0x01;
@@ -1329,9 +1306,9 @@ static void dma_block_output(struct net_device *dev, int count,
                break;
        } while (--tries > 0);
        if (tries <= 0) {
-           printk(KERN_NOTICE "%s: Tx packet transfer address mismatch,"
+           netdev_notice(dev, "Tx packet transfer address mismatch,"
                   "%#4.4x (expected) vs. %#4.4x (actual).\n",
-                  dev->name, (start_page << 8) + count, addr);
+                  (start_page << 8) + count, addr);
            if (retries++ == 0)
                goto retry;
        }
@@ -1340,8 +1317,7 @@ static void dma_block_output(struct net_device *dev, int count,
 
     while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
        if (time_after(jiffies, dma_start + PCNET_RDC_TIMEOUT)) {
-           printk(KERN_NOTICE "%s: timeout waiting for Tx RDC.\n",
-                  dev->name);
+           netdev_notice(dev, "timeout waiting for Tx RDC.\n");
            pcnet_reset_8390(dev);
            NS8390_init(dev, 1);
            break;
@@ -1464,7 +1440,6 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
     struct net_device *dev = link->priv;
     pcnet_dev_t *info = PRIV(dev);
     win_req_t req;
-    memreq_t mem;
     int i, window_size, offset, ret;
 
     window_size = (stop_pg - start_pg) << 8;
@@ -1483,11 +1458,9 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
     if (ret)
            goto failed;
 
-    mem.CardOffset = (start_pg << 8) + cm_offset;
-    offset = mem.CardOffset % window_size;
-    mem.CardOffset -= offset;
-    mem.Page = 0;
-    ret = pcmcia_map_mem_page(link, link->win, &mem);
+    offset = (start_pg << 8) + cm_offset;
+    offset -= offset % window_size;
+    ret = pcmcia_map_mem_page(link, link->win, offset);
     if (ret)
            goto failed;