Skip to contentSkip to conversation

ASoC: add new Component functions

PATCH Superseded Kuninori Morimoto 3 participants 45 messages Nov 10 – Nov 11

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: add new Component functions

Hi Mark

I'm now posting ASoC Capsuling patches.
Current status, and this patch-set postion is below. This patch-set moves Card related functions to soc-card.c

x: done
o: This patch-set

[x] move DAI functions
[x] add new DAI functions
[x] move Component functions
[x] move Card functions
[o] add new Component functions
[ ] rename DAI/Component list
[ ] move Card functions v2
[ ] add new Card functions
[ ] adjust Test
[ ] use new Card register
[ ] use new functions on all drivers
[ ] Capsule DAI/Component/Card

Kuninori Morimoto (20):
ASoC: soc-generic-dmaengine-pcm: move devm_snd_dmaengine_pcm_register()
ASoC: soc-component: rename snd_soc_component_{init/exit}_regmap() to snd_soc_component_regmap_{init/exit}()
ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c
ASoC: soc-component: move devm_snd_soc_component_register()
ASoC: soc-component: move snd_soc_of_xlate_dai_name() to soc-component.c
ASoC: soc-component: makes regmap function to inline macro
ASoC: soc-component: add snd_soc_component_name_prefix()
ASoC: soc-component: add snd_soc_component_to_dev()
ASoC: soc-component: add snd_soc_component_to_driver()
ASoC: soc-component: add snd_soc_component_to_card()
ASoC: soc-component: add snd_soc_component_to_debugfs_root()
ASoC: soc-component: add snd_soc_component_to_regmap()
ASoC: soc-component: add snd_soc_component_regcache_mark_dirty()
ASoC: soc-component: add snd_soc_component_regcache_cache_only()
ASoC: soc-component: add snd_soc_component_regcache_cache_bypass()
ASoC: soc-component: add snd_soc_component_regmap_multi_reg_write_bypassed()
ASoC: soc-component: add snd_soc_component_num_dai()
ASoC: soc-component: add snd_soc_component_connect_dai()
ASoC: soc-component: add snd_soc_component_active_update()
ASoC: soc-component: add snd_soc_component_device_link_{add/del}()

 include/sound/soc-component.h         | 118 ++++++-
 include/sound/soc.h                   |  14 -
 sound/soc/soc-card.c                  |  22 +-
 sound/soc/soc-component.c             | 432 ++++++++++++++++++++++----
 sound/soc/soc-core.c                  | 245 ---------------
 sound/soc/soc-dai.c                   |   5 +-
 sound/soc/soc-devres.c                |  80 -----
 sound/soc/soc-generic-dmaengine-pcm.c |  36 +++
 sound/soc/soc-internal.h              |   4 +
 sound/soc/soc-pcm.c                   |   2 +-
 10 files changed, 530 insertions(+), 428 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/20 ASoC: soc-generic-dmaengine-pcm: move devm_snd_dmaengine_pcm_register()

We don't need to have dmaengine related function in soc-devres.c. Let's move it.

---
 sound/soc/soc-devres.c                | 40 ---------------------------
 sound/soc/soc-generic-dmaengine-pcm.c | 36 ++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 40 deletions(-)
sound/soc/soc-devres.c +0 -40
index 718165ba84ac8..ca6c29b54f6ab 100644
@@ -63,43 +63,3 @@ int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
 	return snd_soc_register_card(card);
 }
 EXPORT_SYMBOL_GPL(devm_snd_soc_register_card);
-
-#ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM
-
-static void devm_dmaengine_pcm_release(struct device *dev, void *res)
-{
-	snd_dmaengine_pcm_unregister(*(struct device **)res);
-}
-
-/**
- * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration
- * @dev: The parent device for the PCM device
- * @config: Platform specific PCM configuration
- * @flags: Platform specific quirks
- *
- * Register a dmaengine based PCM device with automatic unregistration when the
- * device is unregistered.
- */
-int devm_snd_dmaengine_pcm_register(struct device *dev,
-	const struct snd_dmaengine_pcm_config *config, unsigned int flags)
-{
-	struct device **ptr;
-	int ret;
-
-	ptr = devres_alloc(devm_dmaengine_pcm_release, sizeof(*ptr), GFP_KERNEL);
-	if (!ptr)
-		return -ENOMEM;
-
-	ret = snd_dmaengine_pcm_register(dev, config, flags);
-	if (ret == 0) {
-		*ptr = dev;
-		devres_add(dev, ptr);
-	} else {
-		devres_free(ptr);
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register);
-
-#endif
sound/soc/soc-generic-dmaengine-pcm.c +36 -0
index c7523bae45af7..1ecf3feb2bed0 100644
@@ -520,5 +520,41 @@ void snd_dmaengine_pcm_unregister(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_unregister);
 
+static void devm_dmaengine_pcm_release(struct device *dev, void *res)
+{
+	snd_dmaengine_pcm_unregister(*(struct device **)res);
+}
+
+/**
+ * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration
+ * @dev: The parent device for the PCM device
+ * @config: Platform specific PCM configuration
+ * @flags: Platform specific quirks
+ *
+ * Register a dmaengine based PCM device with automatic unregistration when the
+ * device is unregistered.
+ */
+int devm_snd_dmaengine_pcm_register(struct device *dev,
+				const struct snd_dmaengine_pcm_config *config, unsigned int flags)
+{
+	struct device **ptr;
+	int ret;
+
+	ptr = devres_alloc(devm_dmaengine_pcm_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+
+	ret = snd_dmaengine_pcm_register(dev, config, flags);
+	if (ret == 0) {
+		*ptr = dev;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register);
+
 MODULE_DESCRIPTION("ASoC helpers for generic PCM dmaengine API");
 MODULE_LICENSE("GPL");
Signature · 1 line
2.53.0
Reviewed-by on v1 1/20
#2 lore raw

Re: [PATCH 01/20] ASoC: soc-generic-dmaengine-pcm: move devm_snd_dmaengine_pcm_register()

Quoted 4 lines · Kuninori Morimoto

We don't need to have dmaengine related function in soc-devres.c. Let's move it.

Quoted 4 lines
---
 sound/soc/soc-devres.c                | 40 ---------------------------
 sound/soc/soc-generic-dmaengine-pcm.c | 36 ++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 40 deletions(-)
#3 lore raw

PATCH 2/20 ASoC: soc-component: rename snd_soc_component_{init/exit}_regmap() to snd_soc_component_regmap_{init/exit}()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

We already have snd_soc_component_regmap_xxx() functions. Let's standardize the function names.
- snd_soc_component_{init/exit}_regmap()
+ snd_soc_component_regmap_{init/exit}()

And no need to have CONFIG_REGMAP, remove #if-#endif

---
 include/sound/soc-component.h | 10 +++++-----
 sound/soc/soc-component.c     | 16 ++++++----------
 2 files changed, 11 insertions(+), 15 deletions(-)
include/sound/soc-component.h +5 -5
index 73d66c9766944..0d565b6c1f611 100644
@@ -333,14 +333,12 @@ 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);
 
+void snd_soc_component_regmap_init(struct snd_soc_component *component,
+				   struct regmap *regmap);
+void snd_soc_component_regmap_exit(struct snd_soc_component *component);
 int snd_soc_component_regmap_val_bytes(struct snd_soc_component *component);
 int snd_soc_component_regmap_cache_sync(struct snd_soc_component *component);
 void snd_soc_component_regmap_async_complete(struct snd_soc_component *component);
-#ifdef CONFIG_REGMAP
-void snd_soc_component_init_regmap(struct snd_soc_component *component,
-				   struct regmap *regmap);
-void snd_soc_component_exit_regmap(struct snd_soc_component *component);
-#endif
 
 int snd_soc_component_fixup_controls(struct snd_soc_component *component);
 int snd_soc_component_add_controls(struct snd_soc_component *component,
@@ -445,6 +443,8 @@ void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,
 				 snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay);
 
 /* REMOVE ME */
+#define snd_soc_component_init_regmap			snd_soc_component_regmap_init
+#define snd_soc_component_exit_regmap			snd_soc_component_regmap_exit
 #define snd_soc_component_cache_sync			snd_soc_component_regmap_cache_sync
 #define snd_soc_component_async_complete		snd_soc_component_regmap_async_complete
 #define snd_soc_lookup_component_nolocked		snd_soc_component_lookup_nolock
sound/soc/soc-component.c +6 -10
index a6e280c798f3d..6dad994009bdb 100644
@@ -432,10 +432,8 @@ void snd_soc_component_regmap_async_complete(struct snd_soc_component *component
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_regmap_async_complete);
 
-#ifdef CONFIG_REGMAP
-
 /**
- * snd_soc_component_init_regmap() - Initialize regmap instance for the
+ * snd_soc_component_regmap_init() - Initialize regmap instance for the
  *                                   component
  * @component: The component for which to initialize the regmap instance
  * @regmap: The regmap instance that should be used by the component
@@ -445,15 +443,15 @@ EXPORT_SYMBOL_GPL(snd_soc_component_regmap_async_complete);
  * yet ready when the component is registered. The function must also be called
  * before the first IO attempt of the component.
  */
-void snd_soc_component_init_regmap(struct snd_soc_component *component,
+void snd_soc_component_regmap_init(struct snd_soc_component *component,
 				   struct regmap *regmap)
 {
 	component->regmap = regmap;
 }
-EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
+EXPORT_SYMBOL_GPL(snd_soc_component_regmap_init);
 
 /**
- * snd_soc_component_exit_regmap() - De-initialize regmap instance for the
+ * snd_soc_component_regmap_exit() - De-initialize regmap instance for the
  *                                   component
  * @component: The component for which to de-initialize the regmap instance
  *
@@ -463,14 +461,12 @@ EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
  * This function should only be used if snd_soc_component_init_regmap() was used
  * to initialize the regmap instance.
  */
-void snd_soc_component_exit_regmap(struct snd_soc_component *component)
+void snd_soc_component_regmap_exit(struct snd_soc_component *component)
 {
 	regmap_exit(component->regmap);
 	component->regmap = NULL;
 }
-EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
-
-#endif
+EXPORT_SYMBOL_GPL(snd_soc_component_regmap_exit);
 
 int snd_soc_component_compr_open(struct snd_soc_component *component,
 				 struct snd_compr_stream *cstream)
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH 02/20] ASoC: soc-component: rename snd_soc_component_{init/exit}_regmap() to snd_soc_component_regmap_{init/exit}()

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ASoC: soc-component: build failure in snd_soc_component_regmap_exit() when !CONFIG_REGMAP --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] ASoC: soc-component: build failure in snd_soc_component_regmap_exit() when !CONFIG_REGMAP
--

commit b2a7793f33b0c23793a100c7c2aba1692324766a
Author: Kuninori Morimoto <[email protected]>

ASoC: soc-component: rename snd_soc_component_{init/exit}_regmap() to snd_soc_component_regmap_{init/exit}()

This commit renames snd_soc_component_{init,exit}_regmap() to snd_soc_component_regmap_{init,exit}(), provides compatibility macros for the old names, and removes the #ifdef CONFIG_REGMAP guards around them.

Quoted 39 lines
sound/soc/soc-component.c +4 -6
index a6e280c798f3d..6dad994009bdb 100644
@@ -432,10 +432,8 @@ void snd_soc_component_regmap_async_complete(struct snd_soc_component *component
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_regmap_async_complete);
 
-#ifdef CONFIG_REGMAP
-
 /**
- * snd_soc_component_init_regmap() - Initialize regmap instance for the
+ * snd_soc_component_regmap_init() - Initialize regmap instance for the
  *                                   component
  * @component: The component for which to initialize the regmap instance
  * @regmap: The regmap instance that should be used by the component
@@ -445,15 +443,15 @@ EXPORT_SYMBOL_GPL(snd_soc_component_regmap_async_complete);
  * yet ready when the component is registered. The function must also be called
  * before the first IO attempt of the component.
  */
-void snd_soc_component_init_regmap(struct snd_soc_component *component,
+void snd_soc_component_regmap_init(struct snd_soc_component *component,
 				   struct regmap *regmap)
 {
 	component->regmap = regmap;
 }
-EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
+EXPORT_SYMBOL_GPL(snd_soc_component_regmap_init);
 
 /**
- * snd_soc_component_exit_regmap() - De-initialize regmap instance for the
+ * snd_soc_component_regmap_exit() - De-initialize regmap instance for the
  *                                   component
  * @component: The component for which to de-initialize the regmap instance
  *
@@ -463,14 +461,12 @@ EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
  * This function should only be used if snd_soc_component_init_regmap() was used
  * to initialize the regmap instance.
  */

sound/soc/soc-component.c EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap); · line 469

Quoted 10 lines
sound/soc/soc-component.c +2 -4
-void snd_soc_component_exit_regmap(struct snd_soc_component *component)
+void snd_soc_component_regmap_exit(struct snd_soc_component *component)
 {
 	regmap_exit(component->regmap);
 	component->regmap = NULL;
 }
-EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
-
-#endif
+EXPORT_SYMBOL_GPL(snd_soc_component_regmap_exit);

[Severity: Medium]
Does removing the #ifdef CONFIG_REGMAP guard around snd_soc_component_regmap_exit() break builds when CONFIG_SND_SOC is enabled and CONFIG_REGMAP is disabled?

In sound/soc/Kconfig, SND_SOC only selects REGMAP_I2C if I2C and REGMAP_SPI if SPI_MASTER, so CONFIG_REGMAP can remain unset. Unlike regmap_get_val_bytes(), regcache_sync(), and regmap_async_complete(), regmap_exit() is only declared inside the #ifdef CONFIG_REGMAP block in include/linux/regmap.h and has no stub when CONFIG_REGMAP is disabled, causing an implicit function declaration error here.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw

PATCH 3/20 ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

move snd_soc_register_[un]component() to soc-component.c

---
 include/sound/soc-component.h |  10 ++
 include/sound/soc.h           |  11 --
 sound/soc/soc-component.c     | 214 ++++++++++++++++++++++++++++++++++
 sound/soc/soc-core.c          | 212 ---------------------------------
 4 files changed, 224 insertions(+), 223 deletions(-)
include/sound/soc-component.h +10 -0
index 0d565b6c1f611..009e0140a15cb 100644
@@ -278,6 +278,16 @@ struct snd_soc_component *snd_soc_component_new(struct device *dev, const char *
 int snd_soc_component_register(struct snd_soc_component *component,
 			       struct snd_soc_dai_driver *dai_drv,
 			       int num_dai);
+int snd_soc_register_component(struct device *dev,
+			       const struct snd_soc_component_driver *component_driver,
+			       struct snd_soc_dai_driver *dai_drv, int num_dai);
+
+int devm_snd_soc_register_component(struct device *dev,
+				    const struct snd_soc_component_driver *component_driver,
+				    struct snd_soc_dai_driver *dai_drv, int num_dai);
+#define snd_soc_unregister_component(dev) snd_soc_unregister_component_by_driver(dev, NULL)
+void snd_soc_unregister_component_by_driver(struct device *dev,
+					const struct snd_soc_component_driver *component_driver);
 
 const char *snd_soc_component_name(struct snd_soc_component *component);
 
include/sound/soc.h +0 -11
index 338662645b42f..338ba5cf85fb3 100644
@@ -447,17 +447,6 @@ static inline int snd_soc_resume(struct device *dev)
 }
 #endif
 int snd_soc_poweroff(struct device *dev);
-int snd_soc_register_component(struct device *dev,
-			       const struct snd_soc_component_driver *component_driver,
-			       struct snd_soc_dai_driver *dai_drv, int num_dai);
-
-int devm_snd_soc_register_component(struct device *dev,
-			 const struct snd_soc_component_driver *component_driver,
-			 struct snd_soc_dai_driver *dai_drv, int num_dai);
-#define snd_soc_unregister_component(dev) snd_soc_unregister_component_by_driver(dev, NULL)
-void snd_soc_unregister_component_by_driver(struct device *dev,
-			 const struct snd_soc_component_driver *component_driver);
-
 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd);
 #ifdef CONFIG_SND_SOC_COMPRESS
 int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd);
sound/soc/soc-component.c +214 -0

217 lines not on this page · raw message

sound/soc/soc-core.c +0 -212

218 lines not on this page · raw message

Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH 03/20] ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c

Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Medium] ASoC: dmaengine: memory leak in…

Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [Medium] ASoC: dmaengine: memory leak in snd_dmaengine_pcm_unregister() [1]
--

commit a5f7b09ef3fb2f0bb4b4617d3a6ce6f9faafae80
Author: Kuninori Morimoto <[email protected]>

ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c

This commit moves component registration and unregistration functions and their declarations from soc-core.c and soc.h to soc-component.c and soc-component.h.

Quoted 5 lines
sound/soc/soc-component.c +0 -0
index 6dad994009bdb..a2f079cd8aae2 100644
@@ -1549,3 +1549,217 @@ struct snd_soc_component *snd_soc_component_lookup_by_name(const char *component

[ ... ]

Quoted 10 lines
sound/soc/soc-component.c +10 -0
+void snd_soc_unregister_component_by_driver(struct device *dev,
+					    const struct snd_soc_component_driver *component_driver)
+{
+	const char *driver_name = NULL;
+
+	if (component_driver)
+		driver_name = component_driver->name;
+
+	guard(mutex)(&client_mutex);
+

sound/soc/soc-component.c struct snd_soc_component *snd_soc_component_lookup_by_name(const char *component · line 1764

Quoted 10 lines
sound/soc/soc-component.c +10 -0
+	while (1) {
+		struct snd_soc_component *component;
+
+		component = snd_soc_lookup_component_nolocked(dev, driver_name);
+		if (!component)
+			break;
+
+		snd_soc_del_component_unlocked(component);
+	}
+}

[Severity: Medium]
This problem wasn't introduced by this patch, but can this loop cause snd_dmaengine_pcm_unregister() to leak dmaengine_pcm structures and DMA channels [1] when a device registers multiple dmaengine PCMs?

sound/soc/soc-generic-dmaengine-pcm.c:snd_dmaengine_pcm_unregister() {
	component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME);
	if (!component)
		return;

	pcm = snd_soc_component_to_priv(component);

	snd_soc_unregister_component_by_driver(dev, component->driver);
	dmaengine_pcm_release_chan(pcm);
	kfree(pcm);
}

When devres releases multiple PCMs registered via devm_snd_dmaengine_pcm_register() on the same device, the first call to snd_dmaengine_pcm_unregister() removes all components matching SND_DMAENGINE_PCM_DRV_NAME. Subsequent release callbacks then get NULL from snd_soc_lookup_component() and return early without releasing their DMA channels or freeing their pcm structures.

[1] https://sashiko.dev/#/bug/linux-259df7eb-71d4-4d88-9686-fca9af84a4de

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#7 lore raw

Re: [PATCH 03/20] ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c

Hi ALSA ML

Quoted 17 lines

[Severity: Medium]
This problem wasn't introduced by this patch, but can this loop cause snd_dmaengine_pcm_unregister() to leak dmaengine_pcm structures and DMA channels [1] when a device registers multiple dmaengine PCMs?

sound/soc/soc-generic-dmaengine-pcm.c:snd_dmaengine_pcm_unregister() {
        component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME);
        if (!component)
                return;

        pcm = snd_soc_component_to_priv(component);

        snd_soc_unregister_component_by_driver(dev, component->driver);
        dmaengine_pcm_release_chan(pcm);
        kfree(pcm);
}
Quoted 6 lines

When devres releases multiple PCMs registered via devm_snd_dmaengine_pcm_register() on the same device, the first call to snd_dmaengine_pcm_unregister() removes all components matching SND_DMAENGINE_PCM_DRV_NAME. Subsequent release callbacks then get NULL from snd_soc_lookup_component() and return early without releasing their DMA channels or freeing their pcm structures.

This is not related to this patch, but indeed issue. I will solve this issue too in v2 patch.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

Reviewed-by on v1 3/20
#8 lore raw

Re: [PATCH 03/20] ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c

In reply to Kuninori Morimoto
Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

move snd_soc_register_[un]component() to soc-component.c

Quoted 6 lines
---
 include/sound/soc-component.h |  10 ++
 include/sound/soc.h           |  11 --
 sound/soc/soc-component.c     | 214 ++++++++++++++++++++++++++++++++++
 sound/soc/soc-core.c          | 212 ---------------------------------
 4 files changed, 224 insertions(+), 223 deletions(-)
#9 lore raw

PATCH 4/20 ASoC: soc-component: move devm_snd_soc_component_register()

In reply to Kuninori Morimoto

We don't need to have component related function in soc-devres.c. Let's move it.

---
 sound/soc/soc-component.c | 40 +++++++++++++++++++++++++++++++++++++++
 sound/soc/soc-devres.c    | 40 ---------------------------------------
 2 files changed, 40 insertions(+), 40 deletions(-)
sound/soc/soc-component.c +40 -0
index a2f079cd8aae2..080568810ea5d 100644
@@ -1763,3 +1763,43 @@ void snd_soc_unregister_component_by_driver(struct device *dev,
 	}
 }
 EXPORT_SYMBOL_GPL(snd_soc_unregister_component_by_driver);
+
+static void devm_component_release(struct device *dev, void *res)
+{
+	const struct snd_soc_component_driver **cmpnt_drv = res;
+
+	snd_soc_unregister_component_by_driver(dev, *cmpnt_drv);
+}
+
+/**
+ * devm_snd_soc_register_component - resource managed component registration
+ * @dev: Device used to manage component
+ * @cmpnt_drv: Component driver
+ * @dai_drv: DAI driver
+ * @num_dai: Number of DAIs to register
+ *
+ * Register a component with automatic unregistration when the device is
+ * unregistered.
+ */
+int devm_snd_soc_register_component(struct device *dev,
+				    const struct snd_soc_component_driver *cmpnt_drv,
+				    struct snd_soc_dai_driver *dai_drv, int num_dai)
+{
+	const struct snd_soc_component_driver **ptr;
+	int ret;
+
+	ptr = devres_alloc(devm_component_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+
+	ret = snd_soc_register_component(dev, cmpnt_drv, dai_drv, num_dai);
+	if (ret == 0) {
+		*ptr = cmpnt_drv;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
sound/soc/soc-devres.c +0 -40
index ca6c29b54f6ab..431bb366468ac 100644
@@ -9,46 +9,6 @@
 #include <sound/soc.h>
 #include <sound/dmaengine_pcm.h>
 
-static void devm_component_release(struct device *dev, void *res)
-{
-	const struct snd_soc_component_driver **cmpnt_drv = res;
-
-	snd_soc_unregister_component_by_driver(dev, *cmpnt_drv);
-}
-
-/**
- * devm_snd_soc_register_component - resource managed component registration
- * @dev: Device used to manage component
- * @cmpnt_drv: Component driver
- * @dai_drv: DAI driver
- * @num_dai: Number of DAIs to register
- *
- * Register a component with automatic unregistration when the device is
- * unregistered.
- */
-int devm_snd_soc_register_component(struct device *dev,
-			 const struct snd_soc_component_driver *cmpnt_drv,
-			 struct snd_soc_dai_driver *dai_drv, int num_dai)
-{
-	const struct snd_soc_component_driver **ptr;
-	int ret;
-
-	ptr = devres_alloc(devm_component_release, sizeof(*ptr), GFP_KERNEL);
-	if (!ptr)
-		return -ENOMEM;
-
-	ret = snd_soc_register_component(dev, cmpnt_drv, dai_drv, num_dai);
-	if (ret == 0) {
-		*ptr = cmpnt_drv;
-		devres_add(dev, ptr);
-	} else {
-		devres_free(ptr);
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
-
 /**
  * devm_snd_soc_register_card - resource managed card registration
  * @dev: Device used to manage card
Signature · 1 line
2.53.0
Reviewed-by on v1 4/20
#10 lore raw

Re: [PATCH 04/20] ASoC: soc-component: move devm_snd_soc_component_register()

Quoted 4 lines · Kuninori Morimoto

We don't need to have component related function in soc-devres.c. Let's move it.

Quoted 4 lines
---
 sound/soc/soc-component.c | 40 +++++++++++++++++++++++++++++++++++++++
 sound/soc/soc-devres.c    | 40 ---------------------------------------
 2 files changed, 40 insertions(+), 40 deletions(-)
#11 lore raw

PATCH 5/20 ASoC: soc-component: move snd_soc_of_xlate_dai_name() to soc-component.c

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

move snd_soc_of_xlate_dai_name() to soc-component.c

---
 include/sound/soc-component.h |  5 ++++-
 include/sound/soc.h           |  3 ---
 sound/soc/soc-component.c     | 33 +++++++++++++++++++++++++++++++++
 sound/soc/soc-core.c          | 33 ---------------------------------
 4 files changed, 37 insertions(+), 37 deletions(-)
include/sound/soc-component.h +4 -1
index 009e0140a15cb..6d5740d5a5e21 100644
@@ -400,6 +400,9 @@ int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
 int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
 					const struct of_phandle_args *args,
 					const char **dai_name);
+int snd_soc_component_of_simple_xlate_dai_name(struct snd_soc_component *component,
+					       const struct of_phandle_args *args,
+					       const char **dai_name);
 int snd_soc_component_compr_open(struct snd_soc_component *component,
 				 struct snd_compr_stream *cstream);
 void snd_soc_component_compr_free(struct snd_soc_component *component,
@@ -460,5 +463,5 @@ void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,
 #define snd_soc_lookup_component_nolocked		snd_soc_component_lookup_nolock
 #define snd_soc_lookup_component			snd_soc_component_lookup
 #define snd_soc_lookup_component_by_name		snd_soc_component_lookup_by_name
-
+#define snd_soc_of_xlate_dai_name			snd_soc_component_of_simple_xlate_dai_name
 #endif /* __SOC_COMPONENT_H */
include/sound/soc.h +0 -3
index 338ba5cf85fb3..5abebfa329b52 100644
@@ -1303,9 +1303,6 @@ int snd_soc_of_parse_tdm_slot(struct device_node *np,
 			      unsigned int *rx_mask,
 			      unsigned int *slots,
 			      unsigned int *slot_width);
-int snd_soc_of_xlate_dai_name(struct snd_soc_component *component,
-			      const struct of_phandle_args *args,
-			      const char **dai_name);
 void snd_soc_of_parse_node_prefix(struct device_node *np,
 				   struct snd_soc_codec_conf *codec_conf,
 				   struct device_node *of_node,
sound/soc/soc-component.c +33 -0
index 080568810ea5d..f717204fec60d 100644
@@ -1803,3 +1803,36 @@ int devm_snd_soc_register_component(struct device *dev,
 	return ret;
 }
 EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
+
+/**
+ * snd_soc_component_of_simple_xlate_dai_name - Resolve a sound-dai phandle argument to a
+ *                             DAI name by searching the component DAI list.
+ * @component: ASoC component to search.
+ * @args:      Phandle arguments from the sound-dai property; args[0] is the
+ *             DAI ID.
+ * @dai_name:  Output pointer set to the matched DAI name on success.
+ *
+ * Return: 0 on success, -EINVAL if args_count != 1 or no match is found.
+ */
+int snd_soc_component_of_simple_xlate_dai_name(struct snd_soc_component *component,
+					       const struct of_phandle_args *args,
+					       const char **dai_name)
+{
+	struct snd_soc_dai *dai;
+	int id;
+
+	if (args->args_count != 1)
+		return -EINVAL;
+
+	id = args->args[0];
+
+	for_each_component_dais(component, dai) {
+		if (dai->driver->id == id) {
+			*dai_name = snd_soc_dai_name(dai);
+			return 0;
+		}
+	}
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_of_simple_xlate_dai_name);
sound/soc/soc-core.c +0 -33
index b0dfdfe8d4a29..54a6d696d59cf 100644
@@ -1593,39 +1593,6 @@ int snd_soc_of_parse_tdm_slot(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_tdm_slot);
 
-/**
- * snd_soc_of_xlate_dai_name - Resolve a sound-dai phandle argument to a
- *                             DAI name by searching the component DAI list.
- * @component: ASoC component to search.
- * @args:      Phandle arguments from the sound-dai property; args[0] is the
- *             DAI ID.
- * @dai_name:  Output pointer set to the matched DAI name on success.
- *
- * Return: 0 on success, -EINVAL if args_count != 1 or no match is found.
- */
-int snd_soc_of_xlate_dai_name(struct snd_soc_component *component,
-			      const struct of_phandle_args *args,
-			      const char **dai_name)
-{
-	struct snd_soc_dai *dai;
-	int id;
-
-	if (args->args_count != 1)
-		return -EINVAL;
-
-	id = args->args[0];
-
-	for_each_component_dais(component, dai) {
-		if (dai->driver->id == id) {
-			*dai_name = snd_soc_dai_name(dai);
-			return 0;
-		}
-	}
-
-	return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(snd_soc_of_xlate_dai_name);
-
 void snd_soc_dlc_use_cpu_as_platform(struct snd_soc_dai_link_component *platforms,
 				     struct snd_soc_dai_link_component *cpus)
 {
Signature · 1 line
2.53.0
Reviewed-by on v1 5/20
#12 lore raw

Re: [PATCH 05/20] ASoC: soc-component: move snd_soc_of_xlate_dai_name() to soc-component.c

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

move snd_soc_of_xlate_dai_name() to soc-component.c

Quoted 6 lines
---
 include/sound/soc-component.h |  5 ++++-
 include/sound/soc.h           |  3 ---
 sound/soc/soc-component.c     | 33 +++++++++++++++++++++++++++++++++
 sound/soc/soc-core.c          | 33 ---------------------------------
 4 files changed, 37 insertions(+), 37 deletions(-)
#13 lore raw

PATCH 6/20 ASoC: soc-component: makes regmap function to inline macro

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Component regmap related function is almost rapper, thus very redundant. No need to makes it as function, but inline macro is very enough.

Let's standardize inline function naming conventions.

	snd_soc_component_${regmap_func}(...);
---
 include/sound/soc-component.h | 52 +++++++++++++++++++++++++++++------
 sound/soc/soc-component.c     | 46 -------------------------------
 2 files changed, 44 insertions(+), 54 deletions(-)
include/sound/soc-component.h +44 -8
index 6d5740d5a5e21..4e538942df643 100644
@@ -343,13 +343,6 @@ 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);
 
-void snd_soc_component_regmap_init(struct snd_soc_component *component,
-				   struct regmap *regmap);
-void snd_soc_component_regmap_exit(struct snd_soc_component *component);
-int snd_soc_component_regmap_val_bytes(struct snd_soc_component *component);
-int snd_soc_component_regmap_cache_sync(struct snd_soc_component *component);
-void snd_soc_component_regmap_async_complete(struct snd_soc_component *component);
-
 int snd_soc_component_fixup_controls(struct snd_soc_component *component);
 int snd_soc_component_add_controls(struct snd_soc_component *component,
 				const struct snd_kcontrol_new *controls, unsigned int num_controls);
@@ -455,10 +448,53 @@ int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
 void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,
 				 snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay);
 
+/*
+ * regmap
+ */
+void snd_soc_component_regmap_init(struct snd_soc_component *component,
+				   struct regmap *regmap);
+void snd_soc_component_regmap_exit(struct snd_soc_component *component);
+
+static inline int snd_soc_component_regmap_get_val_bytes(struct snd_soc_component *component)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+	int val_bytes;
+
+	/* Errors are legitimate for non-integer byte multiples */
+
+	if (!regmap)
+		return 0;
+
+	val_bytes = regmap_get_val_bytes(regmap);
+	if (val_bytes < 0)
+		return 0;
+
+	return val_bytes;
+}
+
+static inline int snd_soc_component_regcache_sync(struct snd_soc_component *component)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (!regmap)
+		return 0;
+
+	return regcache_sync(regmap);
+}
+
+static inline void snd_soc_component_regmap_async_complete(struct snd_soc_component *component)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (regmap)
+		regmap_async_complete(regmap);
+}
+
 /* REMOVE ME */
 #define snd_soc_component_init_regmap			snd_soc_component_regmap_init
 #define snd_soc_component_exit_regmap			snd_soc_component_regmap_exit
-#define snd_soc_component_cache_sync			snd_soc_component_regmap_cache_sync
+#define snd_soc_component_regmap_val_bytes		snd_soc_component_regmap_get_val_bytes
+#define snd_soc_component_cache_sync			snd_soc_component_regcache_sync
 #define snd_soc_component_async_complete		snd_soc_component_regmap_async_complete
 #define snd_soc_lookup_component_nolocked		snd_soc_component_lookup_nolock
 #define snd_soc_lookup_component			snd_soc_component_lookup
sound/soc/soc-component.c +0 -46

52 lines not on this page · raw message

Signature · 1 line
2.53.0
#14 lore raw

Re: [PATCH 06/20] ASoC: soc-component: makes regmap function to inline macro

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] ASoC: soc-component: undeclared snd_soc_component_to_regmap() breaks build --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] ASoC: soc-component: undeclared snd_soc_component_to_regmap() breaks build
--

commit f289bf9367f01f6ee0716c3f431535b8a1efc6e9
Author: Kuninori Morimoto <[email protected]>

ASoC: soc-component: makes regmap function to inline macro

This commit moves snd_soc_component_regmap_val_bytes(), snd_soc_component_regmap_cache_sync(), and snd_soc_component_regmap_async_complete() from sound/soc/soc-component.c to static inline helpers in include/sound/soc-component.h.

Quoted 4 lines
include/sound/soc-component.h +0 -0
index 6d5740d5a5e21..4e538942df643 100644

[ ... ]

Quoted 35 lines
include/sound/soc-component.h +31 -0
@@ -455,10 +448,53 @@ int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
 void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,
 				 snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay);
 
+/*
+ * regmap
+ */
+void snd_soc_component_regmap_init(struct snd_soc_component *component,
+				   struct regmap *regmap);
+void snd_soc_component_regmap_exit(struct snd_soc_component *component);
+
+static inline int snd_soc_component_regmap_get_val_bytes(struct snd_soc_component *component)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+	int val_bytes;
+
+	/* Errors are legitimate for non-integer byte multiples */
+
+	if (!regmap)
+		return 0;
+
+	val_bytes = regmap_get_val_bytes(regmap);
+	if (val_bytes < 0)
+		return 0;
+
+	return val_bytes;
+}
+
+static inline int snd_soc_component_regcache_sync(struct snd_soc_component *component)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (!regmap)
+		return 0;
+

include/sound/soc-component.h int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream); · line 491

Quoted 10 lines
include/sound/soc-component.h +10 -0
+	return regcache_sync(regmap);
+}
+
+static inline void snd_soc_component_regmap_async_complete(struct snd_soc_component *component)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (regmap)
+		regmap_async_complete(regmap);
+}

[Severity: High]
Does calling snd_soc_component_to_regmap() in these three static inline functions break compilation at this commit?

snd_soc_component_to_regmap() is not declared or defined until a later patch in the series, commit "ASoC: soc-component: add snd_soc_component_to_regmap()". Because these helpers are static inline functions rather than macros, every translation unit that includes include/sound/soc-component.h fails to compile with an implicit function declaration error until that patch is applied, breaking git bisect across the intermediate commits. Ordering commit "ASoC: soc-component: add snd_soc_component_to_regmap()" before this patch would keep the series bisectable.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Reviewed-by on v1 6/20
#15 lore raw

Re: [PATCH 06/20] ASoC: soc-component: makes regmap function to inline macro

In reply to Kuninori Morimoto
Quoted 11 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Component regmap related function is almost rapper, thus very redundant. No need to makes it as function, but inline macro is very enough.

Let's standardize inline function naming conventions.

	snd_soc_component_${regmap_func}(...);

sashiko is right about the order, but the patch itself is fine

Quoted 4 lines
---
 include/sound/soc-component.h | 52 +++++++++++++++++++++++++++++------
 sound/soc/soc-component.c     | 46 -------------------------------
 2 files changed, 44 insertions(+), 54 deletions(-)
#16 lore raw

PATCH 7/20 ASoC: soc-component: add snd_soc_component_name_prefix()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_name_prefix() to soc-component.c

---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
index 4e538942df643..ad148e341fdf0 100644
@@ -290,6 +290,7 @@ void snd_soc_unregister_component_by_driver(struct device *dev,
 					const struct snd_soc_component_driver *component_driver);
 
 const char *snd_soc_component_name(struct snd_soc_component *component);
+const char *snd_soc_component_name_prefix(struct snd_soc_component *component);
 
 void snd_soc_component_set_priv(struct snd_soc_component *component, void *priv);
 void *snd_soc_component_to_priv(struct snd_soc_component *component);
sound/soc/soc-component.c +6 -0
index 838a00c2b325b..0dd0008ac59b9 100644
@@ -43,6 +43,12 @@ const char *snd_soc_component_name(struct snd_soc_component *component)
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_name);
 
+const char *snd_soc_component_name_prefix(struct snd_soc_component *component)
+{
+	return component->name_prefix;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_name_prefix);
+
 void snd_soc_component_set_priv(struct snd_soc_component *component, void *priv)
 {
 	component->priv = priv;
Signature · 1 line
2.53.0
Reviewed-by on v1 7/20
#17 lore raw

Re: [PATCH 07/20] ASoC: soc-component: add snd_soc_component_name_prefix()

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_name_prefix() to soc-component.c

Quoted 4 lines
---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
#18 lore raw

PATCH 8/20 ASoC: soc-component: add snd_soc_component_to_dev()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_to_dev() to soc-component.c

---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
index ad148e341fdf0..960645fde8e31 100644
@@ -272,6 +272,7 @@ struct snd_soc_component {
 	     snd_soc_dai_to_list(dai) != &(component)->dai_list;		\
 	     dai = _dai, _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(_dai)->next))
 
+struct device *snd_soc_component_to_dev(struct snd_soc_component *component);
 struct snd_soc_dapm_context *snd_soc_component_to_dapm(struct snd_soc_component *component);
 struct snd_soc_component *snd_soc_component_new(struct device *dev, const char *name,
 						const struct snd_soc_component_driver *driver);
sound/soc/soc-component.c +6 -0
index 0dd0008ac59b9..abb8cc843662d 100644
@@ -61,6 +61,12 @@ void *snd_soc_component_to_priv(struct snd_soc_component *component)
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_to_priv);
 
+struct device *snd_soc_component_to_dev(struct snd_soc_component *component)
+{
+	return component->dev;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_to_dev);
+
 struct snd_soc_dapm_context *snd_soc_component_to_dapm(struct snd_soc_component *component)
 {
 	return component->dapm;
Signature · 1 line
2.53.0
Reviewed-by on v1 8/20
#19 lore raw

Re: [PATCH 08/20] ASoC: soc-component: add snd_soc_component_to_dev()

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_to_dev() to soc-component.c

Quoted 4 lines
---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
#20 lore raw

PATCH 9/20 ASoC: soc-component: add snd_soc_component_to_driver()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_to_driver() to soc-component.c

---
 include/sound/soc-component.h | 2 ++
 sound/soc/soc-component.c     | 7 +++++++
 2 files changed, 9 insertions(+)
include/sound/soc-component.h +2 -0
index 960645fde8e31..23a41fbe55abc 100644
@@ -274,6 +274,8 @@ struct snd_soc_component {
 
 struct device *snd_soc_component_to_dev(struct snd_soc_component *component);
 struct snd_soc_dapm_context *snd_soc_component_to_dapm(struct snd_soc_component *component);
+const struct snd_soc_component_driver
+*snd_soc_component_to_driver(struct snd_soc_component *component);
 struct snd_soc_component *snd_soc_component_new(struct device *dev, const char *name,
 						const struct snd_soc_component_driver *driver);
 int snd_soc_component_register(struct snd_soc_component *component,
sound/soc/soc-component.c +7 -0
index abb8cc843662d..e42e5152a9f93 100644
@@ -73,6 +73,13 @@ struct snd_soc_dapm_context *snd_soc_component_to_dapm(struct snd_soc_component
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_to_dapm);
 
+const struct snd_soc_component_driver *
+snd_soc_component_to_driver(struct snd_soc_component *component)
+{
+	return component->driver;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_to_driver);
+
 unsigned int snd_soc_component_active(struct snd_soc_component *component)
 {
 	return component->active;
Signature · 1 line
2.53.0
Reviewed-by on v1 9/20
#21 lore raw

Re: [PATCH 09/20] ASoC: soc-component: add snd_soc_component_to_driver()

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_to_driver() to soc-component.c

Quoted 4 lines
---
 include/sound/soc-component.h | 2 ++
 sound/soc/soc-component.c     | 7 +++++++
 2 files changed, 9 insertions(+)
#22 lore raw

PATCH 10/20 ASoC: soc-component: add snd_soc_component_to_card()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_to_card() to soc-component.c

---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
index 23a41fbe55abc..64aca0083c98e 100644
@@ -276,6 +276,7 @@ struct device *snd_soc_component_to_dev(struct snd_soc_component *component);
 struct snd_soc_dapm_context *snd_soc_component_to_dapm(struct snd_soc_component *component);
 const struct snd_soc_component_driver
 *snd_soc_component_to_driver(struct snd_soc_component *component);
+struct snd_soc_card *snd_soc_component_to_card(struct snd_soc_component *component);
 struct snd_soc_component *snd_soc_component_new(struct device *dev, const char *name,
 						const struct snd_soc_component_driver *driver);
 int snd_soc_component_register(struct snd_soc_component *component,
sound/soc/soc-component.c +6 -0
index e42e5152a9f93..bf7c0fcbbb8ce 100644
@@ -80,6 +80,12 @@ snd_soc_component_to_driver(struct snd_soc_component *component)
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_to_driver);
 
+struct snd_soc_card *snd_soc_component_to_card(struct snd_soc_component *component)
+{
+	return component->card;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_to_card);
+
 unsigned int snd_soc_component_active(struct snd_soc_component *component)
 {
 	return component->active;
Signature · 1 line
2.53.0
Reviewed-by on v1 10/20
#23 lore raw

Re: [PATCH 10/20] ASoC: soc-component: add snd_soc_component_to_card()

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_to_card() to soc-component.c

Quoted 4 lines
---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
#24 lore raw

PATCH 11/20 ASoC: soc-component: add snd_soc_component_to_debugfs_root()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_debugfs_root() to get component->debugfs_root.

---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
index 64aca0083c98e..3ba4e2c84e4b4 100644
@@ -277,6 +277,7 @@ struct snd_soc_dapm_context *snd_soc_component_to_dapm(struct snd_soc_component
 const struct snd_soc_component_driver
 *snd_soc_component_to_driver(struct snd_soc_component *component);
 struct snd_soc_card *snd_soc_component_to_card(struct snd_soc_component *component);
+struct dentry *snd_soc_component_to_debugfs_root(struct snd_soc_component *component);
 struct snd_soc_component *snd_soc_component_new(struct device *dev, const char *name,
 						const struct snd_soc_component_driver *driver);
 int snd_soc_component_register(struct snd_soc_component *component,
sound/soc/soc-component.c +6 -0
index bf7c0fcbbb8ce..ebeac81355901 100644
@@ -86,6 +86,12 @@ struct snd_soc_card *snd_soc_component_to_card(struct snd_soc_component *compone
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_to_card);
 
+struct dentry *snd_soc_component_to_debugfs_root(struct snd_soc_component *component)
+{
+	return component->debugfs_root;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_to_debugfs_root);
+
 unsigned int snd_soc_component_active(struct snd_soc_component *component)
 {
 	return component->active;
Signature · 1 line
2.53.0
Reviewed-by on v1 11/20
#25 lore raw

Re: [PATCH 11/20] ASoC: soc-component: add snd_soc_component_to_debugfs_root()

Quoted 7 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_debugfs_root() to get component->debugfs_root.

Quoted 4 lines
---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
#26 lore raw

PATCH 12/20 ASoC: soc-component: add snd_soc_component_to_regmap()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_to_regmap() to soc-component.c

---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
index 3ba4e2c84e4b4..4a72cfb5401a9 100644
@@ -278,6 +278,7 @@ const struct snd_soc_component_driver
 *snd_soc_component_to_driver(struct snd_soc_component *component);
 struct snd_soc_card *snd_soc_component_to_card(struct snd_soc_component *component);
 struct dentry *snd_soc_component_to_debugfs_root(struct snd_soc_component *component);
+struct regmap *snd_soc_component_to_regmap(struct snd_soc_component *component);
 struct snd_soc_component *snd_soc_component_new(struct device *dev, const char *name,
 						const struct snd_soc_component_driver *driver);
 int snd_soc_component_register(struct snd_soc_component *component,
sound/soc/soc-component.c +6 -0
index ebeac81355901..d8274273bb013 100644
@@ -92,6 +92,12 @@ struct dentry *snd_soc_component_to_debugfs_root(struct snd_soc_component *compo
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_to_debugfs_root);
 
+struct regmap *snd_soc_component_to_regmap(struct snd_soc_component *component)
+{
+	return component->regmap;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_to_regmap);
+
 unsigned int snd_soc_component_active(struct snd_soc_component *component)
 {
 	return component->active;
Signature · 1 line
2.53.0
#27 lore raw

Re: [PATCH 12/20] ASoC: soc-component: add snd_soc_component_to_regmap()

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ASoC: soc-component: snd_soc_component_to_regmap() ordered after its callers --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] ASoC: soc-component: snd_soc_component_to_regmap() ordered after its callers
--

commit 1b181762257030814f72c0850502aed04e2f536a
Author: Kuninori Morimoto <[email protected]>

ASoC: soc-component: add snd_soc_component_to_regmap()

This commit adds the snd_soc_component_to_regmap() helper function to retrieve the regmap pointer from struct snd_soc_component.

Quoted 17 lines
include/sound/soc-component.h +1 -0
index 3ba4e2c84e4b4..4a72cfb5401a9 100644
@@ -278,6 +278,7 @@ const struct snd_soc_component_driver
 *snd_soc_component_to_driver(struct snd_soc_component *component);
 struct snd_soc_card *snd_soc_component_to_card(struct snd_soc_component *component);
 struct dentry *snd_soc_component_to_debugfs_root(struct snd_soc_component *component);
+struct regmap *snd_soc_component_to_regmap(struct snd_soc_component *component);
 struct snd_soc_component *snd_soc_component_new(struct device *dev, const char *name,
 						const struct snd_soc_component_driver *driver);
 int snd_soc_component_register(struct snd_soc_component *component,
sound/soc/soc-component.c +0 -0
index ebeac81355901..d8274273bb013 100644

sound/soc/soc-component.c struct dentry *snd_soc_component_to_debugfs_root(struct snd_soc_component *compo · line 99

Quoted 8 lines
sound/soc/soc-component.c +5 -0
@@ -92,6 +92,12 @@ struct dentry *snd_soc_component_to_debugfs_root(struct snd_soc_component *compo
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_to_debugfs_root);
 
+struct regmap *snd_soc_component_to_regmap(struct snd_soc_component *component)
+{
+	return component->regmap;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_to_regmap);

[Severity: Medium]
Should this patch be ordered before commit "ASoC: soc-component: makes regmap function to inline macro" in the series?

That earlier commit converts snd_soc_component_regmap_get_val_bytes() and related helpers in include/sound/soc-component.h into static inline functions that call snd_soc_component_to_regmap(), so the six intermediate commits fail to compile with an implicit function declaration error and break git bisect.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
Reviewed-by on v1 12/20
#28 lore raw

Re: [PATCH 12/20] ASoC: soc-component: add snd_soc_component_to_regmap()

In reply to Kuninori Morimoto
Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Add snd_soc_component_to_regmap() to soc-component.c

Quoted 4 lines
---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
#29 lore raw

PATCH 13/20 ASoC: soc-component: add snd_soc_component_regcache_mark_dirty()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Adds snd_soc_component_regcache_mark_dirty().

---
 include/sound/soc-component.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/sound/soc-component.h +9 -0
index 4a72cfb5401a9..25b25389bf0fa 100644
@@ -497,6 +497,15 @@ static inline void snd_soc_component_regmap_async_complete(struct snd_soc_compon
 		regmap_async_complete(regmap);
 }
 
+static inline void snd_soc_component_regcache_mark_dirty(struct snd_soc_component *component)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (regmap)
+		regcache_mark_dirty(regmap);
+}
+
+
 /* REMOVE ME */
 #define snd_soc_component_init_regmap			snd_soc_component_regmap_init
 #define snd_soc_component_exit_regmap			snd_soc_component_regmap_exit
Signature · 1 line
2.53.0
Reviewed-by on v1 13/20
#30 lore raw

Re: [PATCH 13/20] ASoC: soc-component: add snd_soc_component_regcache_mark_dirty()

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Adds snd_soc_component_regcache_mark_dirty().

Quoted 3 lines
---
 include/sound/soc-component.h | 9 +++++++++
 1 file changed, 9 insertions(+)
#31 lore raw

PATCH 14/20 ASoC: soc-component: add snd_soc_component_regcache_cache_only()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Adds snd_soc_component_regcache_cache_only().

---
 include/sound/soc-component.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/sound/soc-component.h +8 -0
index 25b25389bf0fa..5e43d559b2005 100644
@@ -505,6 +505,14 @@ static inline void snd_soc_component_regcache_mark_dirty(struct snd_soc_componen
 		regcache_mark_dirty(regmap);
 }
 
+static inline void snd_soc_component_regcache_cache_only(struct snd_soc_component *component,
+							 bool enable)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (regmap)
+		regcache_cache_only(regmap, enable);
+}
 
 /* REMOVE ME */
 #define snd_soc_component_init_regmap			snd_soc_component_regmap_init
Signature · 1 line
2.53.0
Reviewed-by on v1 14/20
#32 lore raw

Re: [PATCH 14/20] ASoC: soc-component: add snd_soc_component_regcache_cache_only()

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Adds snd_soc_component_regcache_cache_only().

Quoted 3 lines
---
 include/sound/soc-component.h | 8 ++++++++
 1 file changed, 8 insertions(+)
#33 lore raw

PATCH 15/20 ASoC: soc-component: add snd_soc_component_regcache_cache_bypass()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Adds snd_soc_component_regcache_cache_bypass().

---
 include/sound/soc-component.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/sound/soc-component.h +9 -0
index 5e43d559b2005..89ae650b74f87 100644
@@ -514,6 +514,15 @@ static inline void snd_soc_component_regcache_cache_only(struct snd_soc_componen
 		regcache_cache_only(regmap, enable);
 }
 
+static inline void snd_soc_component_regcache_cache_bypass(struct snd_soc_component *component,
+							   bool enable)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (regmap)
+		regcache_cache_bypass(regmap, enable);
+}
+
 /* REMOVE ME */
 #define snd_soc_component_init_regmap			snd_soc_component_regmap_init
 #define snd_soc_component_exit_regmap			snd_soc_component_regmap_exit
Signature · 1 line
2.53.0
Reviewed-by on v1 15/20
#34 lore raw

Re: [PATCH 15/20] ASoC: soc-component: add snd_soc_component_regcache_cache_bypass()

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Adds snd_soc_component_regcache_cache_bypass().

Quoted 3 lines
---
 include/sound/soc-component.h | 9 +++++++++
 1 file changed, 9 insertions(+)
#35 lore raw

PATCH 16/20 ASoC: soc-component: add snd_soc_component_regmap_multi_reg_write_bypassed()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

Adds snd_soc_component_regmap_multi_reg_write_bypassed().

---
 include/sound/soc-component.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
include/sound/soc-component.h +13 -0
index 89ae650b74f87..0a8beebd7b038 100644
@@ -489,6 +489,19 @@ static inline int snd_soc_component_regcache_sync(struct snd_soc_component *comp
 	return regcache_sync(regmap);
 }
 
+static inline int
+snd_soc_component_regmap_multi_reg_write_bypassed(struct snd_soc_component *component,
+						  const struct reg_sequence *regs,
+						  int num_regs)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (!regmap)
+		return 0;
+
+	return regmap_multi_reg_write_bypassed(regmap, regs, num_regs);
+}
+
 static inline void snd_soc_component_regmap_async_complete(struct snd_soc_component *component)
 {
 	struct regmap *regmap = snd_soc_component_to_regmap(component);
Signature · 1 line
2.53.0
#36 lore raw

Re: [PATCH 16/20] ASoC: soc-component: add snd_soc_component_regmap_multi_reg_write_bypassed()

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] ASoC: build failure in snd_soc_component_regmap_multi_reg_write_bypassed() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] ASoC: build failure in snd_soc_component_regmap_multi_reg_write_bypassed()
--

commit 57b5a81c5a120fd92608fae86a8fb5b252d6cb73
Author: Kuninori Morimoto <[email protected]>

ASoC: soc-component: add snd_soc_component_regmap_multi_reg_write_bypassed()

This commit adds the snd_soc_component_regmap_multi_reg_write_bypassed() static inline helper to wrap regmap_multi_reg_write_bypassed() on a component's regmap.

Quoted 10 lines
include/sound/soc-component.h +2 -0
index 89ae650b74f87..0a8beebd7b038 100644
@@ -489,6 +489,19 @@ static inline int snd_soc_component_regcache_sync(struct snd_soc_component *comp
 	return regcache_sync(regmap);
 }
 
+static inline int
+snd_soc_component_regmap_multi_reg_write_bypassed(struct snd_soc_component *component,

include/sound/soc-component.h static inline int snd_soc_component_regcache_sync(struct snd_soc_component *comp · line 503

Quoted 10 lines
include/sound/soc-component.h +10 -0
+						  const struct reg_sequence *regs,
+						  int num_regs)
+{
+	struct regmap *regmap = snd_soc_component_to_regmap(component);
+
+	if (!regmap)
+		return 0;
+
+	return regmap_multi_reg_write_bypassed(regmap, regs, num_regs);
+}

[Severity: High]
Does calling regmap_multi_reg_write_bypassed() from a static inline helper break the build when regmap support is disabled?

Unlike regcache_sync() and the other helpers in this header, include/linux/regmap.h only declares regmap_multi_reg_write_bypassed() inside its #ifdef CONFIG_REGMAP block and provides no fallback stub in the #else section. Any translation unit that includes sound/soc-component.h (or sound/soc.h) when regmap is disabled will fail to compile with an implicit function declaration error.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16
#37 lore raw

PATCH 17/20 ASoC: soc-component: add snd_soc_component_num_dai()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_num_dai() to get component->num_dai.

---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
index 0a8beebd7b038..f60d797b2c4e9 100644
@@ -379,6 +379,7 @@ static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
 }
 
 unsigned int snd_soc_component_active(struct snd_soc_component *component);
+int snd_soc_component_num_dai(struct snd_soc_component *component);
 
 /* component controls */
 struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component,
sound/soc/soc-component.c +6 -0
index d8274273bb013..93978fae9b840 100644
@@ -104,6 +104,12 @@ unsigned int snd_soc_component_active(struct snd_soc_component *component)
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_active);
 
+int snd_soc_component_num_dai(struct snd_soc_component *component)
+{
+	return component->num_dai;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_num_dai);
+
 /*
  * We might want to check substream by using list.
  * In such case, we can update these macros.
Signature · 1 line
2.53.0
Reviewed-by on v1 17/20
#38 lore raw

Re: [PATCH 17/20] ASoC: soc-component: add snd_soc_component_num_dai()

Quoted 6 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_num_dai() to get component->num_dai.

Quoted 4 lines
---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-component.c     | 6 ++++++
 2 files changed, 7 insertions(+)
#39 lore raw

PATCH 18/20 ASoC: soc-component: add snd_soc_component_connect_dai()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_connect_dai() to connect DAI to Component.

---
 sound/soc/soc-component.c | 7 +++++++
 sound/soc/soc-dai.c       | 3 +--
 sound/soc/soc-internal.h  | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
sound/soc/soc-component.c +7 -0
index 93978fae9b840..50101d16f8539 100644
@@ -110,6 +110,13 @@ int snd_soc_component_num_dai(struct snd_soc_component *component)
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_num_dai);
 
+void snd_soc_component_connect_dai(struct snd_soc_component *component, struct snd_soc_dai *dai)
+{
+	/* dai->list <-> component->dai_list */
+	list_add_tail(snd_soc_dai_to_list(dai), &component->dai_list);
+	component->num_dai++;
+}
+
 /*
  * We might want to check substream by using list.
  * In such case, we can update these macros.
sound/soc/soc-dai.c +1 -2
index d124b6afb1b8d..e222268d8466a 100644
@@ -1265,8 +1265,7 @@ struct snd_soc_dai *snd_soc_dai_register(struct snd_soc_component *component,
 	dai->driver = dai_drv;
 
 	/* see for_each_component_dais */
-	list_add_tail(&dai->list, &component->dai_list);
-	component->num_dai++;
+	snd_soc_component_connect_dai(component, dai);
 
 	dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name);
 	return dai;
sound/soc/soc-internal.h +1 -0
index e09d283d443a8..98ff0e2fc2e1d 100644
@@ -69,6 +69,7 @@ bool snd_soc_component_matches_dlc(struct snd_soc_component *component,
 void snd_soc_component_remove(struct snd_soc_component *component, int probed);
 int snd_soc_component_probe(struct snd_soc_component *component, struct snd_soc_card *card);
 struct list_head *snd_soc_component_get_list_head(void);
+void snd_soc_component_connect_dai(struct snd_soc_component *component, struct snd_soc_dai *dai);
 
 #define for_each_component(component)					\
 	list_for_each_entry(component, snd_soc_component_get_list_head(), list)
Signature · 1 line
2.53.0
Reviewed-by on v1 18/20
#40 lore raw

Re: [PATCH 18/20] ASoC: soc-component: add snd_soc_component_connect_dai()

Quoted 7 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_connect_dai() to connect DAI to Component.

Quoted 5 lines
---
 sound/soc/soc-component.c | 7 +++++++
 sound/soc/soc-dai.c       | 3 +--
 sound/soc/soc-internal.h  | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
#41 lore raw

PATCH 19/20 ASoC: soc-component: add snd_soc_component_active_update()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_active_update() to handle Component acitive count.

---
 sound/soc/soc-component.c | 5 +++++
 sound/soc/soc-dai.c       | 2 +-
 sound/soc/soc-internal.h  | 1 +
 sound/soc/soc-pcm.c       | 2 +-
 4 files changed, 8 insertions(+), 2 deletions(-)
sound/soc/soc-component.c +5 -0
index 50101d16f8539..fa5dd07bf498e 100644
@@ -104,6 +104,11 @@ unsigned int snd_soc_component_active(struct snd_soc_component *component)
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_active);
 
+void snd_soc_component_active_update(struct snd_soc_component *component, int action)
+{
+	component->active += action;
+}
+
 int snd_soc_component_num_dai(struct snd_soc_component *component)
 {
 	return component->num_dai;
sound/soc/soc-dai.c +1 -1
index e222268d8466a..dffb265fd38bb 100644
@@ -713,7 +713,7 @@ void snd_soc_dai_active_update(struct snd_soc_dai *dai, int stream, int action)
 	dai->stream[stream].active	+= action;
 
 	/* see snd_soc_component_active() */
-	dai->component->active		+= action;
+	snd_soc_component_active_update(dai->component, action);
 }
 
 int snd_soc_dai_active(const struct snd_soc_dai *dai)
sound/soc/soc-internal.h +1 -0
index 98ff0e2fc2e1d..1190be669eae3 100644
@@ -70,6 +70,7 @@ void snd_soc_component_remove(struct snd_soc_component *component, int probed);
 int snd_soc_component_probe(struct snd_soc_component *component, struct snd_soc_card *card);
 struct list_head *snd_soc_component_get_list_head(void);
 void snd_soc_component_connect_dai(struct snd_soc_component *component, struct snd_soc_dai *dai);
+void snd_soc_component_active_update(struct snd_soc_component *component, int action);
 
 #define for_each_component(component)					\
 	list_for_each_entry(component, snd_soc_component_get_list_head(), list)
sound/soc/soc-pcm.c +1 -1
index ef8ccf52798eb..dac353fec4bcf 100644
@@ -374,7 +374,7 @@ void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
 	for_each_rtd_components(rtd, i, component) {
 		if (component->num_dai)
 			continue;
-		component->active += action;
+		snd_soc_component_active_update(component, action);
 	}
 }
 EXPORT_SYMBOL_GPL(snd_soc_runtime_action);
Signature · 1 line
2.53.0
Reviewed-by on v1 19/20
#42 lore raw

Re: [PATCH 19/20] ASoC: soc-component: add snd_soc_component_active_update()

Quoted 7 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_active_update() to handle Component acitive count.

Quoted 6 lines
---
 sound/soc/soc-component.c | 5 +++++
 sound/soc/soc-dai.c       | 2 +-
 sound/soc/soc-internal.h  | 1 +
 sound/soc/soc-pcm.c       | 2 +-
 4 files changed, 8 insertions(+), 2 deletions(-)
#43 lore raw

PATCH 20/20 ASoC: soc-component: add snd_soc_component_device_link_{add/del}()

In reply to Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_device_link_{add/del}() to handle Component device_link.

---
 sound/soc/soc-card.c      | 22 ++++------------------
 sound/soc/soc-component.c | 28 ++++++++++++++++++++++++++++
 sound/soc/soc-internal.h  |  2 ++
 3 files changed, 34 insertions(+), 18 deletions(-)
sound/soc/soc-card.c +4 -18
index 6544dbf2ee260..079312216a3b2 100644
@@ -884,12 +884,8 @@ static void snd_soc_remove_device_links(struct snd_soc_card *card)
 {
 	struct snd_soc_component *component;
 
-	for_each_card_components(card, component) {
-		if (component->card_device_link) {
-			device_link_del(component->card_device_link);
-			component->card_device_link = NULL;
-		}
-	}
+	for_each_card_components(card, component)
+		snd_soc_component_device_link_del(component);
 }
 
 void snd_soc_card_unbind(struct snd_soc_card *card, bool reuse)
@@ -1043,18 +1039,8 @@ static int snd_soc_card_bind(struct snd_soc_card *card)
 	 * If a driver pair already have a link in the opposite direction
 	 * they must manage their own suspend order.
 	 */
-	for_each_card_components(card, component) {
-		if (card->dev == component->dev)
-			continue;
-
-		component->card_device_link = device_link_add(card->dev,
-							      component->dev,
-							      DL_FLAG_STATELESS);
-		if (!component->card_device_link) {
-			dev_warn(card->dev, "Could not create device link to %s\n",
-				 dev_name(component->dev));
-		}
-	}
+	for_each_card_components(card, component)
+		snd_soc_component_device_link_add(component);
 
 	ret = snd_soc_card_late_probe(card);
 	if (ret < 0)
sound/soc/soc-component.c +28 -0
index fa5dd07bf498e..1597acbe1a965 100644
@@ -122,6 +122,34 @@ void snd_soc_component_connect_dai(struct snd_soc_component *component, struct s
 	component->num_dai++;
 }
 
+void snd_soc_component_device_link_del(struct snd_soc_component *component)
+{
+	if (component->card_device_link) {
+		device_link_del(component->card_device_link);
+		component->card_device_link = NULL;
+	}
+}
+
+int snd_soc_component_device_link_add(struct snd_soc_component *component)
+{
+	struct snd_soc_card *card = snd_soc_component_to_card(component);
+	struct device *card_dev = card->dev;
+	struct device *component_dev = snd_soc_component_to_dev(component);
+
+	if (card_dev == component_dev)
+		return 0;
+
+	component->card_device_link = device_link_add(card_dev, component_dev,
+						      DL_FLAG_STATELESS);
+	if (!component->card_device_link) {
+		dev_warn(card_dev, "Could not create device link to %s\n",
+			 dev_name(component_dev));
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * We might want to check substream by using list.
  * In such case, we can update these macros.
sound/soc/soc-internal.h +2 -0
index 1190be669eae3..e713d13543b2d 100644
@@ -71,6 +71,8 @@ int snd_soc_component_probe(struct snd_soc_component *component, struct snd_soc_
 struct list_head *snd_soc_component_get_list_head(void);
 void snd_soc_component_connect_dai(struct snd_soc_component *component, struct snd_soc_dai *dai);
 void snd_soc_component_active_update(struct snd_soc_component *component, int action);
+void snd_soc_component_device_link_del(struct snd_soc_component *component);
+int snd_soc_component_device_link_add(struct snd_soc_component *component);
 
 #define for_each_component(component)					\
 	list_for_each_entry(component, snd_soc_component_get_list_head(), list)
Signature · 1 line
2.53.0
Reviewed-by on v1 20/20
#44 lore raw

Re: [PATCH 20/20] ASoC: soc-component: add snd_soc_component_device_link_{add/del}()

Quoted 7 lines · Kuninori Morimoto

struct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.

This patch adds snd_soc_component_device_link_{add/del}() to handle Component device_link.

Quoted 5 lines
---
 sound/soc/soc-card.c      | 22 ++++------------------
 sound/soc/soc-component.c | 28 ++++++++++++++++++++++++++++
 sound/soc/soc-internal.h  |  2 ++
 3 files changed, 34 insertions(+), 18 deletions(-)