Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / net / sunhme.c
index 2cb1ac9..9f046ca 100644 (file)
@@ -13,9 +13,6 @@
  *     argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
  */
 
-static char version[] =
-        "sunhme.c:v2.02 24/Aug/2003 David S. Miller (davem@redhat.com)\n";
-
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -36,9 +33,9 @@ static char version[] =
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/byteorder.h>
@@ -67,15 +64,24 @@ static char version[] =
 
 #include "sunhme.h"
 
+#define DRV_NAME       "sunhme"
+#define DRV_VERSION    "2.02"
+#define DRV_RELDATE    "8/24/03"
+#define DRV_AUTHOR     "David S. Miller (davem@redhat.com)"
+
+static char version[] =
+       DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
 
-#define DRV_NAME "sunhme"
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR(DRV_AUTHOR);
+MODULE_DESCRIPTION("Sun HappyMealEthernet(HME) 10/100baseT ethernet driver");
+MODULE_LICENSE("GPL");
 
 static int macaddr[6];
 
 /* accept MAC address of the form macaddr=0x08,0x00,0x20,0x30,0x40,0x50 */
-MODULE_PARM(macaddr, "6i");
+module_param_array(macaddr, int, NULL, 0);
 MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set");
-MODULE_LICENSE("GPL");
 
 static struct happy_meal *root_happy_dev;
 
@@ -175,13 +181,13 @@ static __inline__ void tx_dump_ring(struct happy_meal *hp)
 #define DEFAULT_IPG2       4 /* For all modes */
 #define DEFAULT_JAMSIZE    4 /* Toe jam */
 
-#ifdef CONFIG_PCI
+#if defined(CONFIG_PCI) && defined(MODULE)
 /* This happy_pci_ids is declared __initdata because it is only used
    as an advisory to depmod.  If this is ported to the new PCI interface
    where it could be referenced at any time due to hot plugging,
    the __initdata reference should be removed. */
 
-struct pci_device_id happymeal_pci_ids[] = {
+static struct pci_device_id happymeal_pci_ids[] = {
        {
          .vendor       = PCI_VENDOR_ID_SUN,
          .device       = PCI_DEVICE_ID_SUN_HAPPYMEAL,
@@ -2948,12 +2954,12 @@ static int is_quattro_p(struct pci_dev *pdev)
 }
 
 /* Fetch MAC address from vital product data of PCI ROM. */
-static void find_eth_addr_in_vpd(void *rom_base, int len, int index, unsigned char *dev_addr)
+static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr)
 {
        int this_offset;
 
        for (this_offset = 0x20; this_offset < len; this_offset++) {
-               void *p = rom_base + this_offset;
+               void __iomem *p = rom_base + this_offset;
 
                if (readb(p + 0) != 0x90 ||
                    readb(p + 1) != 0x00 ||
@@ -2971,42 +2977,33 @@ static void find_eth_addr_in_vpd(void *rom_base, int len, int index, unsigned ch
 
                        for (i = 0; i < 6; i++)
                                dev_addr[i] = readb(p + i);
-                       break;
+                       return 1;
                }
                index--;
        }
+       return 0;
 }
 
 static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr)
 {
-       u32 rom_reg_orig;
-       void *p;
-       int index;
-
-       index = 0;
-       if (is_quattro_p(pdev))
-               index = PCI_SLOT(pdev->devfn);
-
-       if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) {
-               if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0)
-                       goto use_random;
-       }
-
-       pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig);
-       pci_write_config_dword(pdev, pdev->rom_base_reg,
-                              rom_reg_orig | PCI_ROM_ADDRESS_ENABLE);
+       size_t size;
+       void __iomem *p = pci_map_rom(pdev, &size);
 
-       p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024));
-       if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa)
-               find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr);
+       if (p) {
+               int index = 0;
+               int found;
 
-       if (p != NULL)
-               iounmap(p);
+               if (is_quattro_p(pdev))
+                       index = PCI_SLOT(pdev->devfn);
 
-       pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig);
-       return;
+               found = readb(p) == 0x55 &&
+                       readb(p + 1) == 0xaa &&
+                       find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr);
+               pci_unmap_rom(pdev, p);
+               if (found)
+                       return;
+       }
 
-use_random:
        /* Sun MAC prefix then 3 random bytes. */
        dev_addr[0] = 0x08;
        dev_addr[1] = 0x00;
@@ -3257,7 +3254,7 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
        return 0;
 
 err_out_iounmap:
-       iounmap((void *)hp->gregs);
+       iounmap(hp->gregs);
 
 err_out_free_res:
        pci_release_regions(pdev);
@@ -3390,7 +3387,7 @@ static void __exit happy_meal_cleanup_module(void)
                                            PAGE_SIZE,
                                            hp->happy_block,
                                            hp->hblock_dvma);
-                       iounmap((void *)hp->gregs);
+                       iounmap(hp->gregs);
                        pci_release_regions(hp->happy_dev);
                }
 #endif