[PATCH v6 04/16] ASoC: rsnd: Support hyphen or dot in indexed clock and reset names

From: John Madieu

Date: Tue May 12 2026 - 14:30:44 EST


The rsnd driver historically looks up per-instance clocks and resets
using dot-separated names matching the ones declared in R-Car device
tree bindings ("ssi.0", "src.0", "adg.ssi.0", ...). The dot separator
is unusual for device tree clock-names / reset-names and newer
Renesas SoC bindings (RZ/G3E and later) use the more standard hyphen
form ("ssi-0", "src-0", ...).

Rather than force every existing R-Car user to rename their DT entries,
add a small set of helpers that try the hyphen form first and fall
back to the dot form. While at it, convert the existing indexed
devm_clk_get() call sites in the SSI, SRC, CTU, DVC and MIX probes to use
the new helpers and drop the now unused per-module name buffers and
NAME_SIZE defines.

Signed-off-by: John Madieu <john.madieu.xa@xxxxxxxxxxxxxx>
---

Changes:

v6: New patch

sound/soc/renesas/rcar/core.c | 67 +++++++++++++++++++++++++++++++++++
sound/soc/renesas/rcar/ctu.c | 7 +---
sound/soc/renesas/rcar/dvc.c | 7 +---
sound/soc/renesas/rcar/mix.c | 7 +---
sound/soc/renesas/rcar/rsnd.h | 19 ++++++++++
sound/soc/renesas/rcar/src.c | 7 +---
sound/soc/renesas/rcar/ssi.c | 7 +---
7 files changed, 91 insertions(+), 30 deletions(-)

diff --git a/sound/soc/renesas/rcar/core.c b/sound/soc/renesas/rcar/core.c
index c3c139a6fc60..5f3841565d49 100644
--- a/sound/soc/renesas/rcar/core.c
+++ b/sound/soc/renesas/rcar/core.c
@@ -1233,6 +1233,73 @@ int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name
return i;
}

+/*
+ * Build "<base>-<index>" or "<base>.<index>" and try the hyphen form first,
+ * falling back to the dot form if the hyphen form is not present. This lets
+ * the driver accept both the new DT convention ("ssi-0", "src-0", ...) and
+ * the legacy R-Car convention ("ssi.0", "src.0", ...) transparently.
+ *
+ * @base: name prefix ("ssi", "src", "ctu", "mix", "dvc", "adg.ssi", ...)
+ * @index: integer suffix
+ *
+ * On ENODEV from the hyphen form, the dot form is tried. All other errors
+ * (including -EPROBE_DEFER) are returned to the caller unchanged, so
+ * behaviour against the clock and reset frameworks is preserved.
+ */
+#define RSND_INDEXED_NAME_MAX 32
+
+static void rsnd_format_indexed_name(char *buf, size_t buflen, char sep,
+ const char *base, int index)
+{
+ snprintf(buf, buflen, "%s%c%d", base, sep, index);
+}
+
+struct clk *rsnd_devm_clk_get_indexed(struct device *dev,
+ const char *base, int index)
+{
+ char name[RSND_INDEXED_NAME_MAX];
+ struct clk *clk;
+
+ rsnd_format_indexed_name(name, sizeof(name), '-', base, index);
+ clk = devm_clk_get(dev, name);
+ if (!IS_ERR(clk) || PTR_ERR(clk) != -ENOENT)
+ return clk;
+
+ rsnd_format_indexed_name(name, sizeof(name), '.', base, index);
+ return devm_clk_get(dev, name);
+}
+
+struct clk *rsnd_devm_clk_get_optional_indexed(struct device *dev,
+ const char *base, int index)
+{
+ char name[RSND_INDEXED_NAME_MAX];
+ struct clk *clk;
+
+ rsnd_format_indexed_name(name, sizeof(name), '-', base, index);
+ clk = devm_clk_get_optional(dev, name);
+ if (IS_ERR(clk) || clk)
+ return clk;
+
+ rsnd_format_indexed_name(name, sizeof(name), '.', base, index);
+ return devm_clk_get_optional(dev, name);
+}
+
+struct reset_control *
+rsnd_devm_reset_control_get_optional_indexed(struct device *dev,
+ const char *base, int index)
+{
+ char name[RSND_INDEXED_NAME_MAX];
+ struct reset_control *rstc;
+
+ rsnd_format_indexed_name(name, sizeof(name), '-', base, index);
+ rstc = devm_reset_control_get_optional(dev, name);
+ if (IS_ERR(rstc) || rstc)
+ return rstc;
+
+ rsnd_format_indexed_name(name, sizeof(name), '.', base, index);
+ return devm_reset_control_get_optional(dev, name);
+}
+
static struct device_node*
rsnd_pick_endpoint_node_for_ports(struct device_node *e_ports,
struct device_node *e_port)
diff --git a/sound/soc/renesas/rcar/ctu.c b/sound/soc/renesas/rcar/ctu.c
index 81bba6a1af6e..293b0eec1ded 100644
--- a/sound/soc/renesas/rcar/ctu.c
+++ b/sound/soc/renesas/rcar/ctu.c
@@ -6,7 +6,6 @@

#include "rsnd.h"

-#define CTU_NAME_SIZE 16
#define CTU_NAME "ctu"

/*
@@ -319,7 +318,6 @@ int rsnd_ctu_probe(struct rsnd_priv *priv)
struct device *dev = rsnd_priv_to_dev(priv);
struct rsnd_ctu *ctu;
struct clk *clk;
- char name[CTU_NAME_SIZE];
int i, nr, ret;

node = rsnd_ctu_of_node(priv);
@@ -350,10 +348,7 @@ int rsnd_ctu_probe(struct rsnd_priv *priv)
* CTU00, CTU01, CTU02, CTU03 => CTU0
* CTU10, CTU11, CTU12, CTU13 => CTU1
*/
- snprintf(name, CTU_NAME_SIZE, "%s.%d",
- CTU_NAME, i / 4);
-
- clk = devm_clk_get(dev, name);
+ clk = rsnd_devm_clk_get_indexed(dev, CTU_NAME, i / 4);
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
goto rsnd_ctu_probe_done;
diff --git a/sound/soc/renesas/rcar/dvc.c b/sound/soc/renesas/rcar/dvc.c
index bf7146ceb5f6..26f80d542da8 100644
--- a/sound/soc/renesas/rcar/dvc.c
+++ b/sound/soc/renesas/rcar/dvc.c
@@ -29,7 +29,6 @@

#include "rsnd.h"

-#define RSND_DVC_NAME_SIZE 16

#define DVC_NAME "dvc"

@@ -327,7 +326,6 @@ int rsnd_dvc_probe(struct rsnd_priv *priv)
struct device *dev = rsnd_priv_to_dev(priv);
struct rsnd_dvc *dvc;
struct clk *clk;
- char name[RSND_DVC_NAME_SIZE];
int i, nr, ret;

node = rsnd_dvc_of_node(priv);
@@ -354,10 +352,7 @@ int rsnd_dvc_probe(struct rsnd_priv *priv)
for_each_child_of_node_scoped(node, np) {
dvc = rsnd_dvc_get(priv, i);

- snprintf(name, RSND_DVC_NAME_SIZE, "%s.%d",
- DVC_NAME, i);
-
- clk = devm_clk_get(dev, name);
+ clk = rsnd_devm_clk_get_indexed(dev, DVC_NAME, i);
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
goto rsnd_dvc_probe_done;
diff --git a/sound/soc/renesas/rcar/mix.c b/sound/soc/renesas/rcar/mix.c
index 566e9b2a488c..9ffa591aa4a4 100644
--- a/sound/soc/renesas/rcar/mix.c
+++ b/sound/soc/renesas/rcar/mix.c
@@ -32,7 +32,6 @@

#include "rsnd.h"

-#define MIX_NAME_SIZE 16
#define MIX_NAME "mix"

struct rsnd_mix {
@@ -291,7 +290,6 @@ int rsnd_mix_probe(struct rsnd_priv *priv)
struct device *dev = rsnd_priv_to_dev(priv);
struct rsnd_mix *mix;
struct clk *clk;
- char name[MIX_NAME_SIZE];
int i, nr, ret;

node = rsnd_mix_of_node(priv);
@@ -318,10 +316,7 @@ int rsnd_mix_probe(struct rsnd_priv *priv)
for_each_child_of_node_scoped(node, np) {
mix = rsnd_mix_get(priv, i);

- snprintf(name, MIX_NAME_SIZE, "%s.%d",
- MIX_NAME, i);
-
- clk = devm_clk_get(dev, name);
+ clk = rsnd_devm_clk_get_indexed(dev, MIX_NAME, i);
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
goto rsnd_mix_probe_done;
diff --git a/sound/soc/renesas/rcar/rsnd.h b/sound/soc/renesas/rcar/rsnd.h
index 3d419b31cf40..f3f1ad1180f8 100644
--- a/sound/soc/renesas/rcar/rsnd.h
+++ b/sound/soc/renesas/rcar/rsnd.h
@@ -476,6 +476,25 @@ int rsnd_runtime_is_multi_ssi(struct rsnd_dai_stream *io);
int rsnd_runtime_is_tdm(struct rsnd_dai_stream *io);
int rsnd_runtime_is_tdm_split(struct rsnd_dai_stream *io);

+/*
+ * Indexed clock and reset name helpers.
+ *
+ * Historically the rsnd driver has looked up per-instance clocks and
+ * resets using dot-separated names (e.g. "ssi.0", "src.0", "adg.ssi.0").
+ * Newer Renesas SoC bindings (RZ/G3E and later) use hyphen-separated
+ * names ("ssi-0", "src-0", ...) to follow the standard Device Tree
+ * naming convention. These helpers look up the hyphenated name first
+ * and transparently fall back to the dotted name, so a single driver
+ * build supports both conventions.
+ */
+struct clk *rsnd_devm_clk_get_indexed(struct device *dev,
+ const char *base, int index);
+struct clk *rsnd_devm_clk_get_optional_indexed(struct device *dev,
+ const char *base, int index);
+struct reset_control *
+rsnd_devm_reset_control_get_optional_indexed(struct device *dev,
+ const char *base, int index);
+
/*
* DT
*/
diff --git a/sound/soc/renesas/rcar/src.c b/sound/soc/renesas/rcar/src.c
index 8b58cc20e7a8..43abe13137bf 100644
--- a/sound/soc/renesas/rcar/src.c
+++ b/sound/soc/renesas/rcar/src.c
@@ -39,7 +39,6 @@ struct rsnd_src {
int irq;
};

-#define RSND_SRC_NAME_SIZE 16

#define rsnd_src_get(priv, id) ((struct rsnd_src *)(priv->src) + id)
#define rsnd_src_nr(priv) ((priv)->src_nr)
@@ -715,7 +714,6 @@ int rsnd_src_probe(struct rsnd_priv *priv)
struct device *dev = rsnd_priv_to_dev(priv);
struct rsnd_src *src;
struct clk *clk;
- char name[RSND_SRC_NAME_SIZE];
int i, nr, ret;

node = rsnd_src_of_node(priv);
@@ -750,16 +748,13 @@ int rsnd_src_probe(struct rsnd_priv *priv)

src = rsnd_src_get(priv, i);

- snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d",
- SRC_NAME, i);
-
src->irq = irq_of_parse_and_map(np, 0);
if (!src->irq) {
ret = -EINVAL;
goto rsnd_src_probe_done;
}

- clk = devm_clk_get(dev, name);
+ clk = rsnd_devm_clk_get_indexed(dev, SRC_NAME, i);
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
goto rsnd_src_probe_done;
diff --git a/sound/soc/renesas/rcar/ssi.c b/sound/soc/renesas/rcar/ssi.c
index c06cebb36170..cf98cc9ee44c 100644
--- a/sound/soc/renesas/rcar/ssi.c
+++ b/sound/soc/renesas/rcar/ssi.c
@@ -21,7 +21,6 @@
#include <linux/of_irq.h>
#include <linux/delay.h>
#include "rsnd.h"
-#define RSND_SSI_NAME_SIZE 16

/*
* SSICR
@@ -1163,7 +1162,6 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)
struct rsnd_mod_ops *ops;
struct clk *clk;
struct rsnd_ssi *ssi;
- char name[RSND_SSI_NAME_SIZE];
int i, nr, ret;

node = rsnd_ssi_of_node(priv);
@@ -1198,10 +1196,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)

ssi = rsnd_ssi_get(priv, i);

- snprintf(name, RSND_SSI_NAME_SIZE, "%s.%d",
- SSI_NAME, i);
-
- clk = devm_clk_get(dev, name);
+ clk = rsnd_devm_clk_get_indexed(dev, SSI_NAME, i);
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
goto rsnd_ssi_probe_done;
--
2.25.1