Ticket #98: fr.onlyfirstunknown.patch

File fr.onlyfirstunknown.patch, 1.3 KB (added by stuge, 5 months ago)
  • flashrom.c

    flashrom: Only find "unknown .. SPI chip" if no other chip was found
    
    This removes the false positive matches we've been seeing, and also removes
    the true positive match in case there is more than one flash chip and the 2nd
    or 3rd are unknown - but I think that case is uncommon enough to warrant the
    improvement in the common case. Use flashrom -frc forced read if you
    encounter the uncommon case, and/or add the flash chip to the flashchips array.
    
    Signed-off-by: Peter Stuge <peter@stuge.se>
    
    old new  
    9999        return 0; 
    100100} 
    101101 
    102 struct flashchip *probe_flash(struct flashchip *flash, int force) 
     102struct flashchip *probe_flash(struct flashchip *first_flash, int force) 
    103103{ 
    104104        volatile uint8_t *bios; 
     105        struct flashchip *flash; 
    105106        unsigned long flash_baseaddr = 0, size; 
    106107 
    107         for (; flash && flash->name; flash++) { 
     108        for (flash = first_flash; flash && flash->name; flash++) { 
    108109                if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) 
    109110                        continue; 
    110111                printf_debug("Probing for %s %s, %d KB: ", 
     
    150151                if (force) 
    151152                        break; 
    152153 
    153                 if (flash->probe(flash) == 1) 
     154                if (flash->probe(flash) != 1) 
     155                        goto notfound; 
     156 
     157                if (first_flash == flashchips || flash->model_id != GENERIC_DEVICE_ID) 
    154158                        break; 
    155159 
     160notfound: 
    156161                munmap((void *)bios, size); 
    157162        } 
    158163