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 <ardb@kernel.org> Reviewed-by: Tzung-Bi Shih <tzungbi@google.com> Cc: Cheng-Yi Chiang <cychiang@chromium.org> Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com> Cc: Guenter Roeck <groeck@chromium.org> Cc: Benson Leung <bleung@chromium.org> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Eric Biggers <ebiggers@kernel.org> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Tzung-Bi Shih <tzungbi@google.com> Link: https://lore.kernel.org/r/20200515100309.20795-1-ardb@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
5ae5eb48ca
commit
93fa0af479
2 changed files with 5 additions and 21 deletions
|
@ -538,8 +538,7 @@ config SND_SOC_CQ0093VC
|
||||||
config SND_SOC_CROS_EC_CODEC
|
config SND_SOC_CROS_EC_CODEC
|
||||||
tristate "codec driver for ChromeOS EC"
|
tristate "codec driver for ChromeOS EC"
|
||||||
depends on CROS_EC
|
depends on CROS_EC
|
||||||
select CRYPTO
|
select CRYPTO_LIB_SHA256
|
||||||
select CRYPTO_SHA256
|
|
||||||
help
|
help
|
||||||
If you say yes here you will get support for the
|
If you say yes here you will get support for the
|
||||||
ChromeOS Embedded Controller's Audio Codec.
|
ChromeOS Embedded Controller's Audio Codec.
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* EC for audio function.
|
* EC for audio function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <crypto/hash.h>
|
|
||||||
#include <crypto/sha.h>
|
#include <crypto/sha.h>
|
||||||
#include <linux/acpi.h>
|
#include <linux/acpi.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
@ -107,25 +106,11 @@ error:
|
||||||
static int calculate_sha256(struct cros_ec_codec_priv *priv,
|
static int calculate_sha256(struct cros_ec_codec_priv *priv,
|
||||||
uint8_t *buf, uint32_t size, uint8_t *digest)
|
uint8_t *buf, uint32_t size, uint8_t *digest)
|
||||||
{
|
{
|
||||||
struct crypto_shash *tfm;
|
struct sha256_state sctx;
|
||||||
struct shash_desc *desc;
|
|
||||||
|
|
||||||
tfm = crypto_alloc_shash("sha256", CRYPTO_ALG_TYPE_SHASH, 0);
|
sha256_init(&sctx);
|
||||||
if (IS_ERR(tfm)) {
|
sha256_update(&sctx, buf, size);
|
||||||
dev_err(priv->dev, "can't alloc shash\n");
|
sha256_final(&sctx, digest);
|
||||||
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);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue