ALSA: usb-audio: parse more format descriptors with structs
[safe/jmp/linux-2.6] / drivers / net / ne2k-pci.c
index ced9fdb..85aec4f 100644 (file)
@@ -62,9 +62,9 @@ static int options[MAX_UNITS];
 #include "8390.h"
 
 /* These identify the driver base version and may not be removed. */
-static char version[] __devinitdata =
-KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " D. Becker/P. Gortmaker\n"
-KERN_INFO "  http://www.scyld.com/network/ne2k-pci.html\n";
+static const char version[] __devinitconst =
+       KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE
+       " D. Becker/P. Gortmaker\n";
 
 #if defined(__powerpc__)
 #define inl_le(addr)  le32_to_cpu(inl(addr))
@@ -136,7 +136,7 @@ static struct {
 };
 
 
-static struct pci_device_id ne2k_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(ne2k_pci_tbl) = {
        { 0x10ec, 0x8029, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RealTek_RTL_8029 },
        { 0x1050, 0x0940, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Winbond_89C940 },
        { 0x11f6, 0x1401, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Compex_RL2000 },
@@ -175,9 +175,9 @@ static void ne2k_pci_block_input(struct net_device *dev, int count,
                          struct sk_buff *skb, int ring_offset);
 static void ne2k_pci_block_output(struct net_device *dev, const int count,
                const unsigned char *buf, const int start_page);
-static struct ethtool_ops ne2k_pci_ethtool_ops;
+static const struct ethtool_ops ne2k_pci_ethtool_ops;
+
 
-\f
 
 /* There is no room in the standard 8390 structure for extra info we need,
    so we build a meta/outer-wrapper structure.. */
@@ -201,6 +201,20 @@ struct ne2k_pci_card {
   in the 'dev' and 'ei_status' structures.
 */
 
+static const struct net_device_ops ne2k_netdev_ops = {
+       .ndo_open               = ne2k_pci_open,
+       .ndo_stop               = ne2k_pci_close,
+       .ndo_start_xmit         = ei_start_xmit,
+       .ndo_tx_timeout         = ei_tx_timeout,
+       .ndo_get_stats          = ei_get_stats,
+       .ndo_set_multicast_list = ei_set_multicast_list,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_change_mtu         = eth_change_mtu,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller = ei_poll,
+#endif
+};
 
 static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
                                     const struct pci_device_id *ent)
@@ -231,12 +245,12 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
        irq = pdev->irq;
 
        if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) {
-               printk (KERN_ERR PFX "no I/O resource at PCI BAR #0\n");
+               dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n");
                return -ENODEV;
        }
 
        if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) {
-               printk (KERN_ERR PFX "I/O resource 0x%x @ 0x%lx busy\n",
+               dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n",
                        NE_IO_EXTENT, ioaddr);
                return -EBUSY;
        }
@@ -263,10 +277,11 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
        /* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */
        dev = alloc_ei_netdev();
        if (!dev) {
-               printk (KERN_ERR PFX "cannot allocate ethernet device\n");
+               dev_err(&pdev->dev, "cannot allocate ethernet device\n");
                goto err_out_free_res;
        }
-       SET_MODULE_OWNER(dev);
+       dev->netdev_ops = &ne2k_netdev_ops;
+
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        /* Reset card. Who knows what dain-bramaged state it was left in. */
@@ -281,7 +296,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
                while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
                        /* Limit wait: '2' avoids jiffy roll-over. */
                        if (jiffies - reset_start_time > 2) {
-                               printk(KERN_ERR PFX "Card failure (no reset ack).\n");
+                               dev_err(&pdev->dev,
+                                       "Card failure (no reset ack).\n");
                                goto err_out_free_netdev;
                        }
 
@@ -308,7 +324,7 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
                        {0x00,  EN0_RSARHI},
                        {E8390_RREAD+E8390_START, E8390_CMD},
                };
-               for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
+               for (i = 0; i < ARRAY_SIZE(program_seq); i++)
                        outb(program_seq[i].value, ioaddr + program_seq[i].offset);
 
        }
@@ -354,25 +370,20 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
        ei_status.block_output = &ne2k_pci_block_output;
        ei_status.get_8390_hdr = &ne2k_pci_get_8390_hdr;
        ei_status.priv = (unsigned long) pdev;
-       dev->open = &ne2k_pci_open;
-       dev->stop = &ne2k_pci_close;
+
        dev->ethtool_ops = &ne2k_pci_ethtool_ops;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       dev->poll_controller = ei_poll;
-#endif
        NS8390_init(dev, 0);
 
+       memcpy(dev->dev_addr, SA_prom, dev->addr_len);
+       memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
+
        i = register_netdev(dev);
        if (i)
                goto err_out_free_netdev;
 
-       printk("%s: %s found at %#lx, IRQ %d, ",
-                  dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq);
-       for(i = 0; i < 6; i++) {
-               printk("%2.2X%s", SA_prom[i], i == 5 ? ".\n": ":");
-               dev->dev_addr[i] = SA_prom[i];
-       }
-       memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
+       printk("%s: %s found at %#lx, IRQ %d, %pM.\n",
+              dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq,
+              dev->dev_addr);
 
        return 0;
 
@@ -385,7 +396,7 @@ err_out_free_res:
 
 }
 
-/* 
+/*
  * Magic incantation sequence for full duplex on the supported cards.
  */
 static inline int set_realtek_fdx(struct net_device *dev)
@@ -410,7 +421,7 @@ static inline int set_holtek_fdx(struct net_device *dev)
 
 static int ne2k_pci_set_fdx(struct net_device *dev)
 {
-       if (ei_status.ne2k_flags & REALTEK_FDX) 
+       if (ei_status.ne2k_flags & REALTEK_FDX)
                return set_realtek_fdx(dev);
        else if (ei_status.ne2k_flags & HOLTEK_FDX)
                return set_holtek_fdx(dev);
@@ -420,7 +431,7 @@ static int ne2k_pci_set_fdx(struct net_device *dev)
 
 static int ne2k_pci_open(struct net_device *dev)
 {
-       int ret = request_irq(dev->irq, ei_interrupt, SA_SHIRQ, dev->name, dev);
+       int ret = request_irq(dev->irq, ei_interrupt, IRQF_SHARED, dev->name, dev);
        if (ret)
                return ret;
 
@@ -535,9 +546,9 @@ static void ne2k_pci_block_input(struct net_device *dev, int count,
                if (count & 3) {
                        buf += count & ~3;
                        if (count & 2) {
-                               u16 *b = (u16 *)buf;
+                               __le16 *b = (__le16 *)buf;
 
-                               *b++ = le16_to_cpu(inw(NE_BASE + NE_DATAPORT));
+                               *b++ = cpu_to_le16(inw(NE_BASE + NE_DATAPORT));
                                buf = (char *)b;
                        }
                        if (count & 1)
@@ -600,9 +611,9 @@ static void ne2k_pci_block_output(struct net_device *dev, int count,
                if (count & 3) {
                        buf += count & ~3;
                        if (count & 2) {
-                               u16 *b = (u16 *)buf;
+                               __le16 *b = (__le16 *)buf;
 
-                               outw(cpu_to_le16(*b++), NE_BASE + NE_DATAPORT);
+                               outw(le16_to_cpu(*b++), NE_BASE + NE_DATAPORT);
                                buf = (char *)b;
                        }
                }
@@ -626,7 +637,7 @@ static void ne2k_pci_block_output(struct net_device *dev, int count,
 static void ne2k_pci_get_drvinfo(struct net_device *dev,
                                 struct ethtool_drvinfo *info)
 {
-       struct ei_device *ei = dev->priv;
+       struct ei_device *ei = netdev_priv(dev);
        struct pci_dev *pci_dev = (struct pci_dev *) ei->priv;
 
        strcpy(info->driver, DRV_NAME);
@@ -634,11 +645,8 @@ static void ne2k_pci_get_drvinfo(struct net_device *dev,
        strcpy(info->bus_info, pci_name(pci_dev));
 }
 
-static struct ethtool_ops ne2k_pci_ethtool_ops = {
+static const struct ethtool_ops ne2k_pci_ethtool_ops = {
        .get_drvinfo            = ne2k_pci_get_drvinfo,
-       .get_tx_csum            = ethtool_op_get_tx_csum,
-       .get_sg                 = ethtool_op_get_sg,
-       .get_perm_addr          = ethtool_op_get_perm_addr,
 };
 
 static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
@@ -669,10 +677,15 @@ static int ne2k_pci_suspend (struct pci_dev *pdev, pm_message_t state)
 static int ne2k_pci_resume (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
+       int rc;
 
        pci_set_power_state(pdev, 0);
        pci_restore_state(pdev);
-       pci_enable_device(pdev);
+
+       rc = pci_enable_device(pdev);
+       if (rc)
+               return rc;
+
        NS8390_init(dev, 1);
        netif_device_attach(dev);
 
@@ -701,7 +714,7 @@ static int __init ne2k_pci_init(void)
 #ifdef MODULE
        printk(version);
 #endif
-       return pci_module_init (&ne2k_driver);
+       return pci_register_driver(&ne2k_driver);
 }