OSDN Git Service

crypto: atmel-sha - fix error management in atmel_sha_start()
authorCyrille Pitchen <cyrille.pitchen@atmel.com>
Thu, 9 Feb 2017 16:51:21 +0000 (17:51 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 15 Feb 2017 05:23:33 +0000 (13:23 +0800)
commit19998acb0ff67cb8843668f3b94bdbe6018fa7d8
tree30c4a789fee823f608a4496661d05e3094dd955e
parentdd3f9f40b58168f91f27ab686c7bae1f35edd3d4
crypto: atmel-sha - fix error management in atmel_sha_start()

This patch clarifies and fixes how errors should be handled by
atmel_sha_start().

For update operations, the previous code wrongly assumed that
(err != -EINPROGRESS) implies (err == 0). It's wrong because that doesn't
take the error cases (err < 0) into account.

This patch also adds many comments to detail all the possible returned
values and what should be done in each case.

Especially, when an error occurs, since atmel_sha_complete() has already
been called, hence releasing the hardware, atmel_sha_start() must not call
atmel_sha_finish_req() later otherwise atmel_sha_complete() would be
called a second time.

Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/atmel-sha.c