[U-Boot] [PATCH 3/5 v4] gen: Change return type to int for hash_func_ws function pointer

Simon Glass sjg at chromium.org
Wed Mar 6 02:42:55 CET 2013


Hi Akshay,

On Tue, Mar 5, 2013 at 5:19 AM, Akshay Saraswat <akshay.s at samsung.com> wrote:
> This patch changes return type for hash_func_ws function pointer to
> int because hash.c is the host for all the crypto algorithm requests.
> Ace h/w acceleration as of now and many more to be included in future
> may require a type to convey the result ("encoding success or failure")
> to the caller.
>
> Signed-off-by: Akshay Saraswat <akshay.s at samsung.com>

This looks OK except that unluckily mainline has just changed so that
crc32 has been brought in also. Can you please update your patch to
take account of this?

Regards,
Simon

> ---
> Changes since v3:
>         - New patch.
>
>  include/hash.h   | 2 +-
>  include/sha1.h   | 2 +-
>  include/sha256.h | 2 +-
>  lib/sha1.c       | 4 +++-
>  lib/sha256.c     | 4 +++-
>  5 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/include/hash.h b/include/hash.h
> index 34ba558..3d7200e 100644
> --- a/include/hash.h
> +++ b/include/hash.h
> @@ -40,7 +40,7 @@ struct hash_algo {
>          * @output:     Checksum result (length depends on algorithm)
>          * @chunk_sz:   Trigger watchdog after processing this many bytes
>          */
> -       void (*hash_func_ws)(const unsigned char *input, unsigned int ilen,
> +       int (*hash_func_ws)(const unsigned char *input, unsigned int ilen,
>                 unsigned char *output, unsigned int chunk_sz);
>         int chunk_size;                         /* Watchdog chunk size */
>  };
> diff --git a/include/sha1.h b/include/sha1.h
> index da09dab..3f45b3c 100644
> --- a/include/sha1.h
> +++ b/include/sha1.h
> @@ -88,7 +88,7 @@ void sha1_csum(const unsigned char *input, unsigned int ilen,
>   * \param output   SHA-1 checksum result
>   * \param chunk_sz watchdog triggering period (in bytes of input processed)
>   */
> -void sha1_csum_wd(const unsigned char *input, unsigned int ilen,
> +int sha1_csum_wd(const unsigned char *input, unsigned int ilen,
>                 unsigned char *output, unsigned int chunk_sz);
>
>  /**
> diff --git a/include/sha256.h b/include/sha256.h
> index beadab3..07b80c8 100644
> --- a/include/sha256.h
> +++ b/include/sha256.h
> @@ -16,7 +16,7 @@ void sha256_starts(sha256_context * ctx);
>  void sha256_update(sha256_context *ctx, const uint8_t *input, uint32_t length);
>  void sha256_finish(sha256_context * ctx, uint8_t digest[SHA256_SUM_LEN]);
>
> -void sha256_csum_wd(const unsigned char *input, unsigned int ilen,
> +int sha256_csum_wd(const unsigned char *input, unsigned int ilen,
>                 unsigned char *output, unsigned int chunk_sz);
>
>  #endif /* _SHA256_H */
> diff --git a/lib/sha1.c b/lib/sha1.c
> index a121224..f272c48 100644
> --- a/lib/sha1.c
> +++ b/lib/sha1.c
> @@ -320,7 +320,7 @@ void sha1_csum(const unsigned char *input, unsigned int ilen,
>   * Output = SHA-1( input buffer ). Trigger the watchdog every 'chunk_sz'
>   * bytes of input processed.
>   */
> -void sha1_csum_wd(const unsigned char *input, unsigned int ilen,
> +int sha1_csum_wd(const unsigned char *input, unsigned int ilen,
>                   unsigned char *output, unsigned int chunk_sz)
>  {
>         sha1_context ctx;
> @@ -347,6 +347,8 @@ void sha1_csum_wd(const unsigned char *input, unsigned int ilen,
>  #endif
>
>         sha1_finish (&ctx, output);
> +
> +       return 0;
>  }
>
>  /*
> diff --git a/lib/sha256.c b/lib/sha256.c
> index ab2db48..ea16d03 100644
> --- a/lib/sha256.c
> +++ b/lib/sha256.c
> @@ -265,7 +265,7 @@ void sha256_finish(sha256_context * ctx, uint8_t digest[32])
>   * Output = SHA-256( input buffer ). Trigger the watchdog every 'chunk_sz'
>   * bytes of input processed.
>   */
> -void sha256_csum_wd(const unsigned char *input, unsigned int ilen,
> +int sha256_csum_wd(const unsigned char *input, unsigned int ilen,
>                 unsigned char *output, unsigned int chunk_sz)
>  {
>         sha256_context ctx;
> @@ -292,4 +292,6 @@ void sha256_csum_wd(const unsigned char *input, unsigned int ilen,
>  #endif
>
>         sha256_finish(&ctx, output);
> +
> +       return 0;
>  }
> --
> 1.8.0
>


More information about the U-Boot mailing list