diff mbox series

ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable

Message ID 2a984a94017247d58e93d936e0f4f368@realtek.com
State New
Headers show
Series ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable | expand

Commit Message

Jack Yu Oct. 14, 2024, 8:53 a.m. UTC
If det_mode is not 0, 3 or 5 then function will return
jack_type with an uninitialzed value.
Enhance switch case to prevent uninitialized variable issue.

Signed-off-by: Jack Yu <jack.yu@realtek.com>
---
 sound/soc/codecs/rt-sdw-common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt-sdw-common.c b/sound/soc/codecs/rt-sdw-common.c
index a422da6cf702..3ec576c576be 100644
--- a/sound/soc/codecs/rt-sdw-common.c
+++ b/sound/soc/codecs/rt-sdw-common.c
@@ -150,15 +150,14 @@  int rt_sdca_headset_detect(struct regmap *map, unsigned int entity_id)
 		goto io_error;
 
 	switch (det_mode) {
-	case 0x00:
-		jack_type = 0;
-		break;
 	case 0x03:
 		jack_type = SND_JACK_HEADPHONE;
 		break;
 	case 0x05:
 		jack_type = SND_JACK_HEADSET;
 		break;
+	default:
+		jack_type = 0;
 	}
 
 	/* write selected_mode */