]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: cs530x: Check the DEVID matches the devtype
authorSimon Trimmer <simont@opensource.cirrus.com>
Thu, 23 Oct 2025 09:03:16 +0000 (10:03 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 27 Oct 2025 11:10:29 +0000 (11:10 +0000)
If the read device ID is not the expected devtype derived from the
compatible device match then fail the probe as other configuration
details may be incorrect.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://patch.msgid.link/20251023090327.58275-9-vitalyr@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs530x.c
sound/soc/codecs/cs530x.h

index abe3fe365425480b92f6729a4beadb159d138ffa..6552bef0577b0a02579dcabfb7744223e1b5916b 100644 (file)
@@ -1181,6 +1181,12 @@ static int cs530x_check_device_id(struct cs530x_priv *cs530x)
                                     dev_id);
        }
 
+       if (cs530x->devtype != dev_id) {
+               dev_err(dev, "Read device ID 0x%x is not the expected devtype 0x%x\n",
+                       dev_id, cs530x->devtype);
+               return -EINVAL;
+       }
+
        dev_dbg(dev, "Device ID 0x%x Rev ID 0x%x (%d in %d out)\n", dev_id, rev,
                cs530x->num_adcs, cs530x->num_dacs);
 
index 52fb148df36ae3c77fa11a22bca2fa7dc48264d4..d11711715ba802fcaac8d98c0989a2ac6631d984 100644 (file)
 #define CS530X_NUM_SUPPLIES            2
 
 enum cs530x_type {
-       CS4282,
-       CS4302,
-       CS4304,
-       CS4308,
-       CS5302,
-       CS5304,
-       CS5308,
+       CS4282 = CS530X_2CH_CODEC_DEV_ID,
+       CS4302 = CS530X_2CH_DAC_DEV_ID,
+       CS4304 = CS530X_4CH_DAC_DEV_ID,
+       CS4308 = CS530X_8CH_DAC_DEV_ID,
+       CS5302 = CS530X_2CH_ADC_DEV_ID,
+       CS5304 = CS530X_4CH_ADC_DEV_ID,
+       CS5308 = CS530X_8CH_ADC_DEV_ID,
 };
 
 /* codec private data */