[flashrom] [PATCH] Remove exit calls from sp_sync_read_timeout and sp_synchronize.

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Fri Sep 7 09:10:43 CEST 2012


On Thu,  6 Sep 2012 23:52:01 +0200
Stefan Tauner <stefan.tauner at student.tuwien.ac.at> wrote:

> Add return values to sp_synchronize so we can signal a failure to the
> only upstream caller (serprog_init), which is prepared to propagate a failure.
> 
> sp_sync_read_timeout was harder to fix because it already used a return
> value, but we needed to distinguish two different failure modes. This
> solution distinguishes them by the sign of the return values, which maintains
> readability as much as possible.
> 
> Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
> ---
>  serial.c  |    1 +
>  serprog.c |   76 ++++++++++++++++++++++++++++++++++++++-----------------------
>  2 files changed, 49 insertions(+), 28 deletions(-)
> 
>> diff --git a/serprog.c b/serprog.c
> index dd86fd3..957e38f 100644
> --- a/serprog.c
> +++ b/serprog.c
> @@ -184,36 +190,48 @@ static void sp_synchronize(void)
>>  		for (n = 0; n < 10; n++) {
> -			c = sp_sync_read_timeout(5);	/* wait up to 50ms */
> -			if (c != S_NAK)
> +			unsigned char ret = sp_sync_read_timeout(50, &c);
> +			if (ret < 0)

ouch :)

but apart from that it seemed ok and i also tested it on hardware.
i self-acked and committed the refined version in r1595. thanks niklas!

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner




More information about the flashrom mailing list