devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
To: Mark Brown <broonie@kernel.org>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
	David Rhodes <david.rhodes@cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Rob Herring <robh@kernel.org>, Conor Dooley <conor+dt@kernel.org>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	patches@opensource.cirrus.com, devicetree@vger.kernel.org,
	Simon Trimmer <simont@opensource.cirrus.com>,
	Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Subject: [PATCH v2 07/11] ASoC: cs530x: Check the DEVID matches the devtype
Date: Thu, 16 Oct 2025 17:48:25 +0100	[thread overview]
Message-ID: <20251016164847.138826-8-vitalyr@opensource.cirrus.com> (raw)
In-Reply-To: <20251016164847.138826-1-vitalyr@opensource.cirrus.com>

From: Simon Trimmer <simont@opensource.cirrus.com>

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>
---
 sound/soc/codecs/cs530x.c |  6 ++++++
 sound/soc/codecs/cs530x.h | 14 +++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/cs530x.c b/sound/soc/codecs/cs530x.c
index 25dbf401b15d..cdd050c0fa2b 100644
--- a/sound/soc/codecs/cs530x.c
+++ b/sound/soc/codecs/cs530x.c
@@ -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);
 
diff --git a/sound/soc/codecs/cs530x.h b/sound/soc/codecs/cs530x.h
index c10a6766cc7a..758d9b1eb39d 100644
--- a/sound/soc/codecs/cs530x.h
+++ b/sound/soc/codecs/cs530x.h
@@ -185,13 +185,13 @@
 #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 */
-- 
2.43.0


  parent reply	other threads:[~2025-10-16 16:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16 16:48 [PATCH v2 00/11] Add support for Cirrus Logic CS530x DAC and CODEC variants Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 01/11] ASoC: cs530x: Correct log message with expected variable Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 02/11] ASoC: cs530x: Update the copyright headers Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 03/11] ASoC: cs530x: Sort #include directives and tydy up whitespaces Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 04/11] ASoC: cs530x: Remove unused struct members and constants Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 05/11] ASoC: cs530x: Correct constant naming Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 06/11] ASoC: cs530x: Add CODEC and DAC support Vitaly Rodionov
2025-10-16 16:48 ` Vitaly Rodionov [this message]
2025-10-16 16:48 ` [PATCH v2 08/11] ASoC: cs530x: Correct MCLK reference frequency values Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 09/11] ASoC: cs530x: Rename i2c related structures Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 10/11] ASoC: cs530x: Add SPI bus support for cs530x parts Vitaly Rodionov
2025-10-16 16:48 ` [PATCH v2 11/11] dt-bindings: sound: cirrus: cs530x: Add additional cs530x family variants Vitaly Rodionov
2025-10-16 19:21 ` [PATCH v2 00/11] Add support for Cirrus Logic CS530x DAC and CODEC variants Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251016164847.138826-8-vitalyr@opensource.cirrus.com \
    --to=vitalyr@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=david.rhodes@cirrus.com \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=rf@opensource.cirrus.com \
    --cc=robh@kernel.org \
    --cc=simont@opensource.cirrus.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).