]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: soc-component: add snd_soc_component_regmap_val_bytes()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 12 Mar 2026 00:15:03 +0000 (00:15 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 20 Mar 2026 12:55:36 +0000 (12:55 +0000)
component has component->val_bytes which is set via
snd_soc_component_setup_regmap(). But it can be calculated via
component->regmap. No need to keep it as component->val_bytes.

Add snd_soc_component_regmap_val_bytes() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/878qbxzywo.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-component.h
sound/soc/soc-component.c

index 2a2b74b24a6096d5dcdcd3a02d5e2f8e8a4596e3..c08922290cf1a26ef01d3a3754c116df4f3be7aa 100644 (file)
@@ -327,6 +327,7 @@ int snd_soc_component_stream_event(struct snd_soc_component *component,
 int snd_soc_component_set_bias_level(struct snd_soc_component *component,
                                     enum snd_soc_bias_level level);
 
+int snd_soc_component_regmap_val_bytes(struct snd_soc_component *component);
 void snd_soc_component_setup_regmap(struct snd_soc_component *component);
 #ifdef CONFIG_REGMAP
 void snd_soc_component_init_regmap(struct snd_soc_component *component,
index 89f236ab303414ef3d37556d772dbe8133d291d8..9dc2cbdc2dda7582f7a544b75d6d282e1bb20848 100644 (file)
@@ -351,6 +351,23 @@ void snd_soc_component_setup_regmap(struct snd_soc_component *component)
                component->val_bytes = val_bytes;
 }
 
+int snd_soc_component_regmap_val_bytes(struct snd_soc_component *component)
+{
+       int val_bytes;
+
+       /* Errors are legitimate for non-integer byte multiples */
+
+       if (!component->regmap)
+               return 0;
+
+       val_bytes = regmap_get_val_bytes(component->regmap);
+       if (val_bytes < 0)
+               return 0;
+
+       return val_bytes;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_regmap_val_bytes);
+
 #ifdef CONFIG_REGMAP
 
 /**