Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Eric Biggers and committed by
Jakub Kicinski
661bfb46 05f8b341

+2 -18
+1 -2
drivers/nfc/s3fwrn5/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 config NFC_S3FWRN5 3 3 tristate 4 - select CRYPTO 5 - select CRYPTO_HASH 4 + select CRYPTO_LIB_SHA1 6 5 help 7 6 Core driver for Samsung S3FWRN5 NFC chip. Contains core utilities 8 7 of chip. It's intended to be used by PHYs to avoid duplicating lots
+1 -16
drivers/nfc/s3fwrn5/firmware.c
··· 8 8 9 9 #include <linux/completion.h> 10 10 #include <linux/firmware.h> 11 - #include <crypto/hash.h> 12 11 #include <crypto/sha1.h> 13 12 14 13 #include "s3fwrn5.h" ··· 410 411 struct device *dev = &fw_info->ndev->nfc_dev->dev; 411 412 struct s3fwrn5_fw_image *fw = &fw_info->fw; 412 413 u8 hash_data[SHA1_DIGEST_SIZE]; 413 - struct crypto_shash *tfm; 414 414 u32 image_size, off; 415 415 int ret; 416 416 417 417 image_size = fw_info->sector_size * fw->image_sectors; 418 418 419 419 /* Compute SHA of firmware data */ 420 - 421 - tfm = crypto_alloc_shash("sha1", 0, 0); 422 - if (IS_ERR(tfm)) { 423 - dev_err(dev, "Cannot allocate shash (code=%pe)\n", tfm); 424 - return PTR_ERR(tfm); 425 - } 426 - 427 - ret = crypto_shash_tfm_digest(tfm, fw->image, image_size, hash_data); 428 - 429 - crypto_free_shash(tfm); 430 - if (ret) { 431 - dev_err(dev, "Cannot compute hash (code=%d)\n", ret); 432 - return ret; 433 - } 420 + sha1(fw->image, image_size, hash_data); 434 421 435 422 /* Firmware update process */ 436 423