Commit 4a31340b authored by Herbert Xu's avatar Herbert Xu

nfc: s3fwrn5: Use shash

This patch replaces uses of the long obsolete hash interface with
shash.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 9534d671
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/crypto.h> #include <crypto/hash.h>
#include <crypto/sha.h> #include <crypto/sha.h>
#include "s3fwrn5.h" #include "s3fwrn5.h"
...@@ -429,8 +429,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info) ...@@ -429,8 +429,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
{ {
struct s3fwrn5_fw_image *fw = &fw_info->fw; struct s3fwrn5_fw_image *fw = &fw_info->fw;
u8 hash_data[SHA1_DIGEST_SIZE]; u8 hash_data[SHA1_DIGEST_SIZE];
struct scatterlist sg; struct crypto_shash *tfm;
struct hash_desc desc;
u32 image_size, off; u32 image_size, off;
int ret; int ret;
...@@ -438,12 +437,31 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info) ...@@ -438,12 +437,31 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
/* Compute SHA of firmware data */ /* Compute SHA of firmware data */
sg_init_one(&sg, fw->image, image_size); tfm = crypto_alloc_shash("sha1", 0, 0);
desc.tfm = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm)) {
crypto_hash_init(&desc); ret = PTR_ERR(tfm);
crypto_hash_update(&desc, &sg, image_size); dev_err(&fw_info->ndev->nfc_dev->dev,
crypto_hash_final(&desc, hash_data); "Cannot allocate shash (code=%d)\n", ret);
crypto_free_hash(desc.tfm); goto out;
}
{
SHASH_DESC_ON_STACK(desc, tfm);
desc->tfm = tfm;
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
ret = crypto_shash_digest(desc, fw->image, image_size,
hash_data);
shash_desc_zero(desc);
}
crypto_free_shash(tfm);
if (ret) {
dev_err(&fw_info->ndev->nfc_dev->dev,
"Cannot compute hash (code=%d)\n", ret);
goto out;
}
/* Firmware update process */ /* Firmware update process */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment