nfc: s3fwrn5: Use SHA-1 library instead of crypto_shash

Now that a SHA-1 library API is available, use it instead of
crypto_shash.  This is simpler and faster.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250815022329.28672-1-ebiggers@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Eric Biggers 2025-08-14 19:23:29 -07:00 committed by Jakub Kicinski
parent 05f8b341d5
commit 661bfb4699
2 changed files with 2 additions and 18 deletions

View File

@ -1,8 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
config NFC_S3FWRN5 config NFC_S3FWRN5
tristate tristate
select CRYPTO select CRYPTO_LIB_SHA1
select CRYPTO_HASH
help help
Core driver for Samsung S3FWRN5 NFC chip. Contains core utilities Core driver for Samsung S3FWRN5 NFC chip. Contains core utilities
of chip. It's intended to be used by PHYs to avoid duplicating lots of chip. It's intended to be used by PHYs to avoid duplicating lots

View File

@ -8,7 +8,6 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <crypto/hash.h>
#include <crypto/sha1.h> #include <crypto/sha1.h>
#include "s3fwrn5.h" #include "s3fwrn5.h"
@ -411,27 +410,13 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
struct device *dev = &fw_info->ndev->nfc_dev->dev; struct device *dev = &fw_info->ndev->nfc_dev->dev;
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 crypto_shash *tfm;
u32 image_size, off; u32 image_size, off;
int ret; int ret;
image_size = fw_info->sector_size * fw->image_sectors; image_size = fw_info->sector_size * fw->image_sectors;
/* Compute SHA of firmware data */ /* Compute SHA of firmware data */
sha1(fw->image, image_size, hash_data);
tfm = crypto_alloc_shash("sha1", 0, 0);
if (IS_ERR(tfm)) {
dev_err(dev, "Cannot allocate shash (code=%pe)\n", tfm);
return PTR_ERR(tfm);
}
ret = crypto_shash_tfm_digest(tfm, fw->image, image_size, hash_data);
crypto_free_shash(tfm);
if (ret) {
dev_err(dev, "Cannot compute hash (code=%d)\n", ret);
return ret;
}
/* Firmware update process */ /* Firmware update process */