Sun GEM ethernet: enable and map PCI ROM properly

This same patch was reported to fix the MAC address detection on sunhme
(next patch). Most people seem to be running this on Sparcs or PPC
machines, where we get the MAC address from their respective firmware
rather than from the (previously broken) ROM mapping routines.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>

+14 -22
+14 -22
drivers/net/sungem.c
··· 2817 2818 #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC)) 2819 /* Fetch MAC address from vital product data of PCI ROM. */ 2820 - static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) 2821 { 2822 int this_offset; 2823 ··· 2838 2839 for (i = 0; i < 6; i++) 2840 dev_addr[i] = readb(p + i); 2841 - break; 2842 } 2843 } 2844 2845 static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr) 2846 { 2847 - u32 rom_reg_orig; 2848 - void __iomem *p; 2849 2850 - if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) { 2851 - if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0) 2852 - goto use_random; 2853 } 2854 2855 - pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); 2856 - pci_write_config_dword(pdev, pdev->rom_base_reg, 2857 - rom_reg_orig | PCI_ROM_ADDRESS_ENABLE); 2858 - 2859 - p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); 2860 - if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) 2861 - find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); 2862 - 2863 - if (p != NULL) 2864 - iounmap(p); 2865 - 2866 - pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig); 2867 - return; 2868 - 2869 - use_random: 2870 /* Sun MAC prefix then 3 random bytes. */ 2871 dev_addr[0] = 0x08; 2872 dev_addr[1] = 0x00;
··· 2817 2818 #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC)) 2819 /* Fetch MAC address from vital product data of PCI ROM. */ 2820 + static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) 2821 { 2822 int this_offset; 2823 ··· 2838 2839 for (i = 0; i < 6; i++) 2840 dev_addr[i] = readb(p + i); 2841 + return 1; 2842 } 2843 + return 0; 2844 } 2845 2846 static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr) 2847 { 2848 + size_t size; 2849 + void __iomem *p = pci_map_rom(pdev, &size); 2850 2851 + if (p) { 2852 + int found; 2853 + 2854 + found = readb(p) == 0x55 && 2855 + readb(p + 1) == 0xaa && 2856 + find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); 2857 + pci_unmap_rom(pdev, p); 2858 + if (found) 2859 + return; 2860 } 2861 2862 /* Sun MAC prefix then 3 random bytes. */ 2863 dev_addr[0] = 0x08; 2864 dev_addr[1] = 0x00;