Changeset 560 for trunk/flashrom.c


Ignore:
Timestamp:
Jun 1, 2009, 4:08:58 AM (5 years ago)
Author:
hailfinger
Message:

Only probe for chips with compatible bus protocols.
It doesn't make sense to probe for SPI chips on a LPC host, nor does it
make sense to probe for LPC chips on a Parallel host.

This change is backwards compatible, but adding host protocol info to
chipset init functions will speed up probing.

Once all chipset init functions are updated and the Winbond W29EE011 and
AMIC A49LF040A chip definitions are updated, the W29EE011 workaround can
be deleted as the W29/A49 conflict magically disappears.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>
Tested on real hardware and
Acked-by: Uwe Hermann <uwe@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/flashrom.c

    r559 r560  
    175175} 
    176176 
     177char *strcat_realloc(char *dest, const char *src) 
     178{ 
     179        dest = realloc(dest, strlen(dest) + strlen(src) + 1); 
     180        if (!dest) 
     181                return NULL; 
     182        strcat(dest, src); 
     183        return dest; 
     184} 
     185 
     186/* Return a string corresponding to the bustype parameter. 
     187 * Memory is obtained with malloc() and can be freed with free(). 
     188 */ 
     189char *flashbuses_to_text(enum chipbustype bustype) 
     190{ 
     191        char *ret = calloc(1, 1); 
     192        if (bustype == CHIP_BUSTYPE_UNKNOWN) { 
     193                ret = strcat_realloc(ret, "Unknown,"); 
     194        /* FIXME: Once all chipsets and flash chips have been updated, NONSPI 
     195         * will cease to exist and should be eliminated here as well. 
     196         */ 
     197        } else if (bustype == CHIP_BUSTYPE_NONSPI) { 
     198                ret = strcat_realloc(ret, "Non-SPI,"); 
     199        } else { 
     200                if (bustype & CHIP_BUSTYPE_PARALLEL) 
     201                        ret = strcat_realloc(ret, "Parallel,"); 
     202                if (bustype & CHIP_BUSTYPE_LPC) 
     203                        ret = strcat_realloc(ret, "LPC,"); 
     204                if (bustype & CHIP_BUSTYPE_FWH) 
     205                        ret = strcat_realloc(ret, "FWH,"); 
     206                if (bustype & CHIP_BUSTYPE_SPI) 
     207                        ret = strcat_realloc(ret, "SPI,"); 
     208                if (bustype == CHIP_BUSTYPE_NONE) 
     209                        ret = strcat_realloc(ret, "None,"); 
     210        } 
     211        /* Kill last comma. */ 
     212        ret[strlen(ret) - 1] = '\0'; 
     213        ret = realloc(ret, strlen(ret) + 1); 
     214        return ret; 
     215} 
     216 
    177217struct flashchip *probe_flash(struct flashchip *first_flash, int force) 
    178218{ 
    179219        struct flashchip *flash; 
    180220        unsigned long base = 0, size; 
     221        char *tmp; 
    181222 
    182223        for (flash = first_flash; flash && flash->name; flash++) { 
     
    187228                if (!flash->probe && !force) { 
    188229                        printf_debug("failed! flashrom has no probe function for this flash chip.\n"); 
     230                        continue; 
     231                } 
     232                if (!(buses_supported & flash->bustype)) { 
     233                        tmp = flashbuses_to_text(buses_supported); 
     234                        printf_debug("skipped. Host bus type %s ", tmp); 
     235                        free(tmp); 
     236                        tmp = flashbuses_to_text(flash->bustype); 
     237                        printf_debug("and chip bus type %s are incompatible.\n", tmp); 
     238                        free(tmp); 
    189239                        continue; 
    190240                } 
Note: See TracChangeset for help on using the changeset viewer.