mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] soundwire: bus: iterate DT compatibles for class-ID match
@ 2026-09-07  9:14 Srinivas Kandagatla
  2026-09-07 10:51 ` Charles Keepax
  2026-09-08 13:58 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2026-09-07  9:14 UTC (permalink / raw)
  To: Vinod Koul; +Cc: Bard Liao, Pierre-Louis Bossart, linux-sound, linux-kernel

sdw_of_find_slaves() reads only the first "compatible" string on a
SoundWire slave DT node and rejects the node if that string does not
parse as sdwVMMMPPPPXX.  This prevents the standard DT convention of
placing a vendor-variant compatible ahead of the SoundWire class-ID
compatible:

    compatible = "vendor,partname", "sdwVMMMPPPPXX";

Iterate every string in the compatible property and accept the first
one that parses as a SoundWire class ID.  The vendor-variant string
remains visible to driver probe callbacks via device_is_compatible()
for mode/variant disambiguation.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
 drivers/soundwire/slave.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
index e0c49cbcb1ba..a7d2938b031d 100644
--- a/drivers/soundwire/slave.c
+++ b/drivers/soundwire/slave.c
@@ -243,17 +243,27 @@ int sdw_of_find_slaves(struct sdw_bus *bus)
 		const char *compat = NULL;
 		struct sdw_slave_id id;
 		const __be32 *addr;
+		struct property *prop;
+		bool matched = false;
 
-		ret = of_property_read_string(node, "compatible", &compat);
-		if (ret)
-			continue;
-
-		ret = sscanf(compat, "sdw%01x%04hx%04hx%02hhx", &sdw_version,
-			     &id.mfg_id, &id.part_id, &id.class_id);
+		/*
+		 * Iterate the compatible list so DT nodes can carry a
+		 * vendor-variant compatible ahead of the SoundWire class-ID
+		 * compatible (e.g. "vendor,part", "sdwVMMMPPPPXX").
+		 */
+		of_property_for_each_string(node, "compatible", prop, compat) {
+			ret = sscanf(compat, "sdw%01x%04hx%04hx%02hhx",
+				     &sdw_version, &id.mfg_id, &id.part_id,
+				     &id.class_id);
+			if (ret == 4) {
+				matched = true;
+				break;
+			}
+		}
 
-		if (ret != 4) {
-			dev_err(dev, "Invalid compatible string found %s\n",
-				compat);
+		if (!matched) {
+			dev_err(dev, "%pOFn: no SoundWire class-ID compatible\n",
+				node);
 			continue;
 		}
 
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] soundwire: bus: iterate DT compatibles for class-ID match
  2026-09-07  9:14 [PATCH] soundwire: bus: iterate DT compatibles for class-ID match Srinivas Kandagatla
@ 2026-09-07 10:51 ` Charles Keepax
  2026-09-08 13:58 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2026-09-07 10:51 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Vinod Koul, Bard Liao, Pierre-Louis Bossart, linux-sound, linux-kernel

On Mon, Sep 07, 2026 at 10:14:21AM +0100, Srinivas Kandagatla wrote:
> sdw_of_find_slaves() reads only the first "compatible" string on a
> SoundWire slave DT node and rejects the node if that string does not
> parse as sdwVMMMPPPPXX.  This prevents the standard DT convention of
> placing a vendor-variant compatible ahead of the SoundWire class-ID
> compatible:
> 
>     compatible = "vendor,partname", "sdwVMMMPPPPXX";
> 
> Iterate every string in the compatible property and accept the first
> one that parses as a SoundWire class ID.  The vendor-variant string
> remains visible to driver probe callbacks via device_is_compatible()
> for mode/variant disambiguation.
> 
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] soundwire: bus: iterate DT compatibles for class-ID match
  2026-09-07  9:14 [PATCH] soundwire: bus: iterate DT compatibles for class-ID match Srinivas Kandagatla
  2026-09-07 10:51 ` Charles Keepax
@ 2026-09-08 13:58 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2026-09-08 13:58 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Bard Liao, Pierre-Louis Bossart, linux-sound, linux-kernel


On Mon, 07 Sep 2026 10:14:21 +0100, Srinivas Kandagatla wrote:
> sdw_of_find_slaves() reads only the first "compatible" string on a
> SoundWire slave DT node and rejects the node if that string does not
> parse as sdwVMMMPPPPXX.  This prevents the standard DT convention of
> placing a vendor-variant compatible ahead of the SoundWire class-ID
> compatible:
> 
>     compatible = "vendor,partname", "sdwVMMMPPPPXX";
> 
> [...]

Applied, thanks!

[1/1] soundwire: bus: iterate DT compatibles for class-ID match
      commit: 659d6f148a88467817e9531a6c793ae022661bab

Best regards,
-- 
~Vinod



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-08 13:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-07  9:14 [PATCH] soundwire: bus: iterate DT compatibles for class-ID match Srinivas Kandagatla
2026-09-07 10:51 ` Charles Keepax
2026-09-08 13:58 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®