Commit ce1289adeb67b5480f35cb257cbf6e9881153783
Committed by
Linus Torvalds
1 parent
4120b028dd
Exists in
master
and in
39 other branches
[PATCH] Sun HME: enable and map PCI ROM properly
This ports the Sun GEM ROM mapping/enable fixes it sunhme (which used the same PCI ROM mapping code). Without this, I get NULL MAC addresses for all 4 ports (it's a SUN QFE). With it, I get the correct addresses (the ones printed on the label on the card). Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 17 additions and 26 deletions Side-by-side Diff
drivers/net/sunhme.c
... | ... | @@ -2954,7 +2954,7 @@ |
2954 | 2954 | } |
2955 | 2955 | |
2956 | 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 | 2959 | int this_offset; |
2960 | 2960 | |
2961 | 2961 | |
2962 | 2962 | |
2963 | 2963 | |
2964 | 2964 | |
2965 | 2965 | |
... | ... | @@ -2977,42 +2977,33 @@ |
2977 | 2977 | |
2978 | 2978 | for (i = 0; i < 6; i++) |
2979 | 2979 | dev_addr[i] = readb(p + i); |
2980 | - break; | |
2980 | + return 1; | |
2981 | 2981 | } |
2982 | 2982 | index--; |
2983 | 2983 | } |
2984 | + return 0; | |
2984 | 2985 | } |
2985 | 2986 | |
2986 | 2987 | static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr) |
2987 | 2988 | { |
2988 | - u32 rom_reg_orig; | |
2989 | - void __iomem *p; | |
2990 | - int index; | |
2989 | + size_t size; | |
2990 | + void __iomem *p = pci_map_rom(pdev, &size); | |
2991 | 2991 | |
2992 | - index = 0; | |
2993 | - if (is_quattro_p(pdev)) | |
2994 | - index = PCI_SLOT(pdev->devfn); | |
2992 | + if (p) { | |
2993 | + int index = 0; | |
2994 | + int found; | |
2995 | 2995 | |
2996 | - if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) { | |
2997 | - if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0) | |
2998 | - goto use_random; | |
2996 | + if (is_quattro_p(pdev)) | |
2997 | + index = PCI_SLOT(pdev->devfn); | |
2998 | + | |
2999 | + found = readb(p) == 0x55 && | |
3000 | + readb(p + 1) == 0xaa && | |
3001 | + find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); | |
3002 | + pci_unmap_rom(pdev, p); | |
3003 | + if (found) | |
3004 | + return; | |
2999 | 3005 | } |
3000 | 3006 | |
3001 | - pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); | |
3002 | - pci_write_config_dword(pdev, pdev->rom_base_reg, | |
3003 | - rom_reg_orig | PCI_ROM_ADDRESS_ENABLE); | |
3004 | - | |
3005 | - p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); | |
3006 | - if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) | |
3007 | - find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); | |
3008 | - | |
3009 | - if (p != NULL) | |
3010 | - iounmap(p); | |
3011 | - | |
3012 | - pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig); | |
3013 | - return; | |
3014 | - | |
3015 | -use_random: | |
3016 | 3007 | /* Sun MAC prefix then 3 random bytes. */ |
3017 | 3008 | dev_addr[0] = 0x08; |
3018 | 3009 | dev_addr[1] = 0x00; |