Am 30.06.2011 22:37 schrieb Stefan Tauner:
> add count_usable_erasers which returns the number of well-defined erasers for 
> a chip
>
> This can be used in various situations (including one in the upcoming SFDP 
> patch) and
> removes one FIXME in current HEAD. Needed to add a declaration of 
> check_block_eraser.
>
> Signed-off-by: Stefan Tauner <[email protected]>
>
> diff --git a/flashrom.c b/flashrom.c
> index 13d398e..10035c4 100644
> --- a/flashrom.c
> +++ b/flashrom.c
> @@ -1818,13 +1830,13 @@ int chip_safety_check(struct flashchip *flash, int 
> force, int read_it, int write
>       }
>       if (erase_it || write_it) {
>               /* Write needs erase. */
> -             if (flash->tested & TEST_BAD_ERASE) {
> +             if (flash->tested & TEST_BAD_ERASE ||
> +                 !count_usable_erasers(flash, 0)) {
>   

Please split that if statement. Allowing --force makes sense for
TEST_BAD_ERASE, but it makes no sense if no erase functions are present.
You can reuse the error message, the compiler/linker will only store the
string once.


>                       msg_cerr("Erase is not working on this chip. ");
>                       if (!force)
>                               return 1;
>                       msg_cerr("Continuing anyway.\n");
>               }
> -             /* FIXME: Check if at least one erase function exists. */
>       }
>       if (write_it) {
>               if (flash->tested & TEST_BAD_WRITE) {
>   

With the split if statement, this is
Acked-by: Carl-Daniel Hailfinger <[email protected]>

Regards,
Carl-Daniel

-- 
http://www.hailfinger.org/


_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to