Changeset 45678


Ignore:
Timestamp:
2015-05-13T10:30:45+02:00 (3 years ago)
Author:
rmilecki
Message:

bcm53xx: sync NVRAM and SPROM drivers with upstream version

Signed-off-by: Rafał Miłecki <zajec5@…>

Location:
trunk/target/linux/bcm53xx/files/drivers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/bcm53xx/files/drivers/firmware/broadcom/bcm47xx_nvram.c

    r45204 r45678  
    9999        if (header->len > NVRAM_SPACE) 
    100100                pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n", 
    101                        header->len, NVRAM_SPACE); 
     101                       header->len, NVRAM_SPACE - 1); 
    102102 
    103103        src = (u32 *)header; 
     
    107107        for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4) 
    108108                *dst++ = readl(src++); 
     109        nvram_buf[NVRAM_SPACE - 1] = '\0'; 
    109110 
    110111        return 0; 
     
    151152                size_t len = header.len; 
    152153 
    153                 if (header.len > NVRAM_SPACE) { 
     154                if (len >= NVRAM_SPACE) { 
     155                        len = NVRAM_SPACE - 1; 
    154156                        pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n", 
    155                                 header.len, NVRAM_SPACE); 
    156                         len = NVRAM_SPACE; 
     157                                header.len, len); 
    157158                } 
    158159 
     
    171172{ 
    172173        char *var, *value, *end, *eq; 
    173         int data_left, err; 
     174        int err; 
    174175 
    175176        if (!name) 
     
    184185        /* Look for name=value and return value */ 
    185186        var = &nvram_buf[sizeof(struct nvram_header)]; 
    186         end = nvram_buf + sizeof(nvram_buf) - 2; 
    187         end[0] = '\0'; 
    188         end[1] = '\0'; 
    189         for (; *var; var = value + strlen(value) + 1) { 
    190                 data_left = end - var; 
    191  
    192                 eq = strnchr(var, data_left, '='); 
     187        end = nvram_buf + sizeof(nvram_buf); 
     188        while (var < end && *var) { 
     189                eq = strchr(var, '='); 
    193190                if (!eq) 
    194191                        break; 
     
    197194                    strncmp(var, name, eq - var) == 0) 
    198195                        return snprintf(val, val_len, "%s", value); 
     196                var = value + strlen(value) + 1; 
    199197        } 
    200198        return -ENOENT; 
  • trunk/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c

    r45230 r45678  
    213213 
    214214        ENTRY(0xfffffffe, u16, pre, "boardrev", board_rev, 0, true); 
     215        ENTRY(0xfffffffe, u32, pre, "boardflags", boardflags, 0, fb); 
     216        ENTRY(0xfffffff0, u32, pre, "boardflags2", boardflags2, 0, fb); 
     217        ENTRY(0xfffff800, u32, pre, "boardflags3", boardflags3, 0, fb); 
    215218        ENTRY(0x00000002, u16, pre, "boardflags", boardflags_lo, 0, fb); 
    216219        ENTRY(0xfffffffc, u16, pre, "boardtype", board_type, 0, true); 
     
    540543                                        const char *prefix, bool fallback) 
    541544{ 
     545        bool fb = fallback; 
     546 
    542547        nvram_read_macaddr(prefix, "et0macaddr", sprom->et0mac, fallback); 
    543548        nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0, 
     
    551556        nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0, 
    552557                      fallback); 
     558 
     559        nvram_read_macaddr(prefix, "et2macaddr", sprom->et2mac, fb); 
     560        nvram_read_u8(prefix, NULL, "et2mdcport", &sprom->et2mdcport, 0, fb); 
     561        nvram_read_u8(prefix, NULL, "et2phyaddr", &sprom->et2phyaddr, 0, fb); 
    553562 
    554563        nvram_read_macaddr(prefix, "macaddr", sprom->il0mac, fallback); 
     
    630639} 
    631640 
     641/* 
     642 * Having many NVRAM entries for PCI devices led to repeating prefixes like 
     643 * pci/1/1/ all the time and wasting flash space. So at some point Broadcom 
     644 * decided to introduce prefixes like 0: 1: 2: etc. 
     645 * If we find e.g. devpath0=pci/2/1 or devpath0=pci/2/1/ we should use 0: 
     646 * instead of pci/2/1/. 
     647 */ 
    632648static void bcm47xx_sprom_apply_prefix_alias(char *prefix, size_t prefix_size) 
    633649{ 
     
    638654        int i; 
    639655 
    640         if (prefix_len <= 0 || prefix[prefix_len - 1] != '/') { 
    641                 pr_warn("Invalid prefix: \"%s\"\n", prefix); 
    642                 return; 
    643         } 
     656        if (prefix_len <= 0 || prefix[prefix_len - 1] != '/') 
     657                return; 
    644658 
    645659        for (i = 0; i < 3; i++) { 
Note: See TracChangeset for help on using the changeset viewer.