diff options
-rw-r--r-- | drivers/net/sunhme.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index f02fe4119b2c..9f046cae2f71 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -2954,7 +2954,7 @@ static int is_quattro_p(struct pci_dev *pdev) | |||
2954 | } | 2954 | } |
2955 | 2955 | ||
2956 | /* Fetch MAC address from vital product data of PCI ROM. */ | 2956 | /* Fetch MAC address from vital product data of PCI ROM. */ |
2957 | static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr) | 2957 | static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr) |
2958 | { | 2958 | { |
2959 | int this_offset; | 2959 | int this_offset; |
2960 | 2960 | ||
@@ -2977,42 +2977,33 @@ static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, uns | |||
2977 | 2977 | ||
2978 | for (i = 0; i < 6; i++) | 2978 | for (i = 0; i < 6; i++) |
2979 | dev_addr[i] = readb(p + i); | 2979 | dev_addr[i] = readb(p + i); |
2980 | break; | 2980 | return 1; |
2981 | } | 2981 | } |
2982 | index--; | 2982 | index--; |
2983 | } | 2983 | } |
2984 | return 0; | ||
2984 | } | 2985 | } |
2985 | 2986 | ||
2986 | static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr) | 2987 | static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr) |
2987 | { | 2988 | { |
2988 | u32 rom_reg_orig; | 2989 | size_t size; |
2989 | void __iomem *p; | 2990 | void __iomem *p = pci_map_rom(pdev, &size); |
2990 | int index; | ||
2991 | 2991 | ||
2992 | index = 0; | 2992 | if (p) { |
2993 | if (is_quattro_p(pdev)) | 2993 | int index = 0; |
2994 | index = PCI_SLOT(pdev->devfn); | 2994 | int found; |
2995 | |||
2996 | if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) { | ||
2997 | if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0) | ||
2998 | goto use_random; | ||
2999 | } | ||
3000 | 2995 | ||
3001 | pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); | 2996 | if (is_quattro_p(pdev)) |
3002 | pci_write_config_dword(pdev, pdev->rom_base_reg, | 2997 | index = PCI_SLOT(pdev->devfn); |
3003 | rom_reg_orig | PCI_ROM_ADDRESS_ENABLE); | ||
3004 | 2998 | ||
3005 | p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); | 2999 | found = readb(p) == 0x55 && |
3006 | if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) | 3000 | readb(p + 1) == 0xaa && |
3007 | find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); | 3001 | find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); |
3008 | 3002 | pci_unmap_rom(pdev, p); | |
3009 | if (p != NULL) | 3003 | if (found) |
3010 | iounmap(p); | 3004 | return; |
3011 | 3005 | } | |
3012 | pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig); | ||
3013 | return; | ||
3014 | 3006 | ||
3015 | use_random: | ||
3016 | /* Sun MAC prefix then 3 random bytes. */ | 3007 | /* Sun MAC prefix then 3 random bytes. */ |
3017 | dev_addr[0] = 0x08; | 3008 | dev_addr[0] = 0x08; |
3018 | dev_addr[1] = 0x00; | 3009 | dev_addr[1] = 0x00; |