From 26f267a2f3bbe9c9f25dfdc3d223c30fe5d7219a Mon Sep 17 00:00:00 2001 From: Jeff LaBundy Date: Wed, 28 Feb 2018 21:18:44 -0600 Subject: [PATCH] misc: cs40l20: Update wavetable validation scheme * Corrected the calculation of algorithm revision * Limited the comparison of algorithm revisions to the MAJOR field Change-Id: I903802f98c472109aa5d62915ab611b1ff869c80 Signed-off-by: Jeff LaBundy Signed-off-by: Ravi Vembu --- drivers/misc/cs40l20.c | 16 ++++++++++------ drivers/misc/cs40l20.h | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/misc/cs40l20.c b/drivers/misc/cs40l20.c index 16803a809910..535040590f3a 100644 --- a/drivers/misc/cs40l20.c +++ b/drivers/misc/cs40l20.c @@ -1032,11 +1032,13 @@ static void cs40l20_waveform_load(const struct firmware *fw, void *context) goto err_rls_fw; } - if (algo_rev != cs40l20->vibegen_rev) { + if (((algo_rev >> 8) & CS40L20_ALGO_REV_MASK) + != (cs40l20->vibegen_rev + & CS40L20_ALGO_REV_MASK)) { dev_err(dev, "Invalid algo. rev.: %d.%d.%d\n", + (algo_rev & 0xFF000000) >> 24, (algo_rev & 0xFF0000) >> 16, - (algo_rev & 0xFF00) >> 8, - algo_rev & 0xFF); + (algo_rev & 0xFF00) >> 8); goto err_rls_fw; } @@ -1065,11 +1067,13 @@ static void cs40l20_waveform_load(const struct firmware *fw, void *context) goto err_rls_fw; } - if (algo_rev != cs40l20->vibegen_rev) { + if (((algo_rev >> 8) & CS40L20_ALGO_REV_MASK) + != (cs40l20->vibegen_rev + & CS40L20_ALGO_REV_MASK)) { dev_err(dev, "Invalid algo. rev.: %d.%d.%d\n", + (algo_rev & 0xFF000000) >> 24, (algo_rev & 0xFF0000) >> 16, - (algo_rev & 0xFF00) >> 8, - algo_rev & 0xFF); + (algo_rev & 0xFF00) >> 8); goto err_rls_fw; } diff --git a/drivers/misc/cs40l20.h b/drivers/misc/cs40l20.h index 305057a83f29..4096372c0911 100644 --- a/drivers/misc/cs40l20.h +++ b/drivers/misc/cs40l20.h @@ -702,6 +702,7 @@ #define CS40L20_ALGO_YM_SIZE_OFFSET 20 #define CS40L20_ALGO_ENTRY_SIZE 24 #define CS40L20_ALGO_LIST_TERM 0xBEDEAD +#define CS40L20_ALGO_REV_MASK 0xFF0000 #define CS40L20_NUM_ALGOS_MAX 16 #define CS40L20_FW_REV_MIN 0x000300