diff options
author | Stephan Guilloux <stephan.guilloux@free.fr> | 2009-06-01 22:07:52 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-06-01 22:07:52 +0000 |
commit | 21dd55b49e6601a1c7af00fe028c6e62126ebdb9 (patch) | |
tree | 60f163ae5f9b69b6b6965979b72b251f74d4b3c4 | |
parent | 5a8b24478f09c186f89c9ad2d1bc3fb534014d8e (diff) | |
download | flashrom-21dd55b49e6601a1c7af00fe028c6e62126ebdb9.tar.gz flashrom-21dd55b49e6601a1c7af00fe028c6e62126ebdb9.tar.bz2 flashrom-21dd55b49e6601a1c7af00fe028c6e62126ebdb9.zip |
Use read_flash() when flash chip probe is forced
Corresponding to flashrom svn r563.
Signed-off-by: Stephan Guilloux <stephan.guilloux@free.fr>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
-rw-r--r-- | flashrom.c | 35 |
1 files changed, 6 insertions, 29 deletions
@@ -314,6 +314,11 @@ int read_flash(struct flashchip *flash, char *filename, unsigned int exclude_sta FILE *image; unsigned long size = flash->total_size * 1024; unsigned char *buf = calloc(size, sizeof(char)); + + if (!filename) { + printf("Error: No filename specified.\n"); + return 1; + } if ((image = fopen(filename, "w")) == NULL) { perror(filename); exit(1); @@ -670,35 +675,7 @@ int main(int argc, char *argv[]) printf("Run flashrom -L to view the hardware supported in this flashrom version.\n"); exit(1); } - if (!filename) { - printf("Error: No filename specified.\n"); - exit(1); - } - size = flashes[0]->total_size * 1024; - buf = (uint8_t *) calloc(size, sizeof(char)); - - if ((image = fopen(filename, "w")) == NULL) { - perror(filename); - exit(1); - } - printf("Force reading flash... "); - if (!flashes[0]->read) { - printf("FAILED!\n"); - fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); - return 1; - } else - flashes[0]->read(flashes[0], buf); - - if (exclude_end_position - exclude_start_position > 0) - memset(buf + exclude_start_position, 0, - exclude_end_position - - exclude_start_position); - - numbytes = fwrite(buf, 1, size, image); - fclose(image); - printf("%s.\n", numbytes == size ? "done" : "FAILED"); - free(buf); - return numbytes != size; + return read_flash(flashes[0], filename, exclude_start_position, exclude_end_position); } // FIXME: flash writes stay enabled! exit(1); |