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

nfc: s3fwrn5: Use shash

This patch replaces uses of the long obsolete hash interface with
shash.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+27 -9
+27 -9
drivers/nfc/s3fwrn5/firmware.c
··· 19 19 20 20 #include <linux/completion.h> 21 21 #include <linux/firmware.h> 22 - #include <linux/crypto.h> 22 + #include <crypto/hash.h> 23 23 #include <crypto/sha.h> 24 24 25 25 #include "s3fwrn5.h" ··· 429 429 { 430 430 struct s3fwrn5_fw_image *fw = &fw_info->fw; 431 431 u8 hash_data[SHA1_DIGEST_SIZE]; 432 - struct scatterlist sg; 433 - struct hash_desc desc; 432 + struct crypto_shash *tfm; 434 433 u32 image_size, off; 435 434 int ret; 436 435 ··· 437 438 438 439 /* Compute SHA of firmware data */ 439 440 440 - sg_init_one(&sg, fw->image, image_size); 441 - desc.tfm = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC); 442 - crypto_hash_init(&desc); 443 - crypto_hash_update(&desc, &sg, image_size); 444 - crypto_hash_final(&desc, hash_data); 445 - crypto_free_hash(desc.tfm); 441 + tfm = crypto_alloc_shash("sha1", 0, 0); 442 + if (IS_ERR(tfm)) { 443 + ret = PTR_ERR(tfm); 444 + dev_err(&fw_info->ndev->nfc_dev->dev, 445 + "Cannot allocate shash (code=%d)\n", ret); 446 + goto out; 447 + } 448 + 449 + { 450 + SHASH_DESC_ON_STACK(desc, tfm); 451 + 452 + desc->tfm = tfm; 453 + desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 454 + 455 + ret = crypto_shash_digest(desc, fw->image, image_size, 456 + hash_data); 457 + shash_desc_zero(desc); 458 + } 459 + 460 + crypto_free_shash(tfm); 461 + if (ret) { 462 + dev_err(&fw_info->ndev->nfc_dev->dev, 463 + "Cannot compute hash (code=%d)\n", ret); 464 + goto out; 465 + } 446 466 447 467 /* Firmware update process */ 448 468