aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArd Biesheuvel <[email protected]>2020-05-15 12:03:09 +0200
committerMark Brown <[email protected]>2020-05-15 11:56:52 +0100
commit93fa0af4790abdabf80ca0c4fff3f1629c84a56f (patch)
tree348b7072b905b6af5e6098f84c58e1e53b13758f
parent5ae5eb48ca046adffbdff56a2f297d0896b83186 (diff)
ASoC: cros_ec_codec: switch to library API for SHA-256
The CrOS EC codec driver uses SHA-256 explicitly, and not in a performance critical manner, so there is really no point in using the SHASH crypto API here. Let's switch to the library API instead. Signed-off-by: Ard Biesheuvel <[email protected]> Reviewed-by: Tzung-Bi Shih <[email protected]> Cc: Cheng-Yi Chiang <[email protected]> Cc: Enric Balletbo i Serra <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Benson Leung <[email protected]> Cc: Liam Girdwood <[email protected]> Cc: Mark Brown <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Eric Biggers <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Tzung-Bi Shih <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
-rw-r--r--sound/soc/codecs/Kconfig3
-rw-r--r--sound/soc/codecs/cros_ec_codec.c23
2 files changed, 5 insertions, 21 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 44b8c4cde4f3..2d4f1b4bc011 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -538,8 +538,7 @@ config SND_SOC_CQ0093VC
config SND_SOC_CROS_EC_CODEC
tristate "codec driver for ChromeOS EC"
depends on CROS_EC
- select CRYPTO
- select CRYPTO_SHA256
+ select CRYPTO_LIB_SHA256
help
If you say yes here you will get support for the
ChromeOS Embedded Controller's Audio Codec.
diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c
index 1948bc6971f6..8d45c628e988 100644
--- a/sound/soc/codecs/cros_ec_codec.c
+++ b/sound/soc/codecs/cros_ec_codec.c
@@ -8,7 +8,6 @@
* EC for audio function.
*/
-#include <crypto/hash.h>
#include <crypto/sha.h>
#include <linux/acpi.h>
#include <linux/delay.h>
@@ -107,25 +106,11 @@ error:
static int calculate_sha256(struct cros_ec_codec_priv *priv,
uint8_t *buf, uint32_t size, uint8_t *digest)
{
- struct crypto_shash *tfm;
- struct shash_desc *desc;
+ struct sha256_state sctx;
- tfm = crypto_alloc_shash("sha256", CRYPTO_ALG_TYPE_SHASH, 0);
- if (IS_ERR(tfm)) {
- dev_err(priv->dev, "can't alloc shash\n");
- return PTR_ERR(tfm);
- }
- desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(tfm), GFP_KERNEL);
- if (!desc) {
- crypto_free_shash(tfm);
- return -ENOMEM;
- }
- desc->tfm = tfm;
- crypto_shash_digest(desc, buf, size, digest);
- shash_desc_zero(desc);
-
- kfree(desc);
- crypto_free_shash(tfm);
+ sha256_init(&sctx);
+ sha256_update(&sctx, buf, size);
+ sha256_final(&sctx, digest);
#ifdef DEBUG
{