Blob Blame History Raw
From 98b6b8df06c7929de65ca3bf28a13b11170943e3 Mon Sep 17 00:00:00 2001
From: Shuming Fan <shumingf@realtek.com>
Date: Thu, 31 Oct 2019 19:54:36 +0800
Subject: [PATCH] ASoC: rt1011: add the range check for temperature_calib from device property
Git-commit: 98b6b8df06c7929de65ca3bf28a13b11170943e3
Patch-mainline: v5.5-rc1
References: jsc#SLE-16518

The driver will check the range for temperature_calib.
It should be from 1 to 255.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20191031115436.21055-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 sound/soc/codecs/rt1011.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt1011.c b/sound/soc/codecs/rt1011.c
index 2f1de933f3ac..f2c581b66d32 100644
--- a/sound/soc/codecs/rt1011.c
+++ b/sound/soc/codecs/rt1011.c
@@ -2341,7 +2341,8 @@ static void rt1011_calibration_work(struct work_struct *work)
 	rt1011_reg_init(component);
 
 	/* Apply temperature and calibration data from device property */
-	if (rt1011->temperature_calib) {
+	if (rt1011->temperature_calib <= 0xff &&
+		rt1011->temperature_calib > 0) {
 		snd_soc_component_update_bits(component,
 			RT1011_STP_INITIAL_RESISTANCE_TEMP, 0x3ff,
 			(rt1011->temperature_calib << 2));
-- 
2.16.4