diff mbox series

[2/5] Revert "ASoC: soc-devres: add devm_snd_soc_register_dai()"

Message ID 20210120152846.1703655-3-amadeuszx.slawinski@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Add KUNIT tests for ASoC topology | expand

Commit Message

Amadeusz Sławiński Jan. 20, 2021, 3:28 p.m. UTC
As described in preceding patch, waiting with DAI removal until device
is being unregistered can lead to working on freed memory, hence having
DAIs managed by resource managed memory is a bad idea, revert commit
creating devm_ API for this, so no one makes a mistake of using it.

This reverts commit 0fae253af563cf5d1f5dc651d520c3eafd74f183.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 include/sound/soc.h    |  4 ----
 sound/soc/soc-devres.c | 37 -------------------------------------
 2 files changed, 41 deletions(-)

Comments

Mark Brown Jan. 20, 2021, 5:29 p.m. UTC | #1
On Wed, Jan 20, 2021 at 04:28:43PM +0100, Amadeusz Sławiński wrote:
> As described in preceding patch, waiting with DAI removal until device
> is being unregistered can lead to working on freed memory, hence having

There is a potential for misuse with essentially all devm functions -
why is this one so special?  

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

> DAIs managed by resource managed memory is a bad idea, revert commit
> creating devm_ API for this, so no one makes a mistake of using it.
> 
> This reverts commit 0fae253af563cf5d1f5dc651d520c3eafd74f183.

Please include human readable descriptions of things like commits and
issues being discussed in e-mail in your mails, this makes them much
easier for humans to read especially when they have no internet access.
I do frequently catch up on my mail on flights or while otherwise
travelling so this is even more pressing for me than just being about
making things a bit easier to read.
Amadeusz Sławiński Jan. 21, 2021, 3:08 p.m. UTC | #2
On 1/20/2021 6:29 PM, Mark Brown wrote:
> On Wed, Jan 20, 2021 at 04:28:43PM +0100, Amadeusz Sławiński wrote:
>> As described in preceding patch, waiting with DAI removal until device
>> is being unregistered can lead to working on freed memory, hence having
> 
> There is a potential for misuse with essentially all devm functions -
> why is this one so special?

Hm... right, I blinded myself thinking too much about specific use case 
where it was used in topology. As topology is used with drivers split 
into multiple modules where it caused problem. It should work fine if 
someone writes monolithic module and needs to register DAI. I guess we 
can skip this patch then.

> 
> Please submit patches using subject lines reflecting the style for the
> subsystem, this makes it easier for people to identify relevant patches.
> Look at what existing commits in the area you're changing are doing and
> make sure your subject lines visually resemble what they're doing.
> There's no need to resubmit to fix this alone.
> 
>> DAIs managed by resource managed memory is a bad idea, revert commit
>> creating devm_ API for this, so no one makes a mistake of using it.
>>
>> This reverts commit 0fae253af563cf5d1f5dc651d520c3eafd74f183.
> 
> Please include human readable descriptions of things like commits and
> issues being discussed in e-mail in your mails, this makes them much
> easier for humans to read especially when they have no internet access.
> I do frequently catch up on my mail on flights or while otherwise
> travelling so this is even more pressing for me than just being about
> making things a bit easier to read.
>
diff mbox series

Patch

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 3fa6c40a63b7..69cb19a93765 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1236,10 +1236,6 @@  void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
 struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
 					 struct snd_soc_dai_driver *dai_drv,
 					 bool legacy_dai_naming);
-struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
-					      struct snd_soc_component *component,
-					      struct snd_soc_dai_driver *dai_drv,
-					      bool legacy_dai_naming);
 void snd_soc_unregister_dai(struct snd_soc_dai *dai);
 
 struct snd_soc_dai *snd_soc_find_dai(
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index 4534a1c03e8e..c6364caabc0e 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -9,43 +9,6 @@ 
 #include <sound/soc.h>
 #include <sound/dmaengine_pcm.h>
 
-static void devm_dai_release(struct device *dev, void *res)
-{
-	snd_soc_unregister_dai(*(struct snd_soc_dai **)res);
-}
-
-/**
- * devm_snd_soc_register_dai - resource-managed dai registration
- * @dev: Device used to manage component
- * @component: The component the DAIs are registered for
- * @dai_drv: DAI driver to use for the DAI
- * @legacy_dai_naming: if %true, use legacy single-name format;
- *	if %false, use multiple-name format;
- */
-struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
-					      struct snd_soc_component *component,
-					      struct snd_soc_dai_driver *dai_drv,
-					      bool legacy_dai_naming)
-{
-	struct snd_soc_dai **ptr;
-	struct snd_soc_dai *dai;
-
-	ptr = devres_alloc(devm_dai_release, sizeof(*ptr), GFP_KERNEL);
-	if (!ptr)
-		return NULL;
-
-	dai = snd_soc_register_dai(component, dai_drv, legacy_dai_naming);
-	if (dai) {
-		*ptr = dai;
-		devres_add(dev, ptr);
-	} else {
-		devres_free(ptr);
-	}
-
-	return dai;
-}
-EXPORT_SYMBOL_GPL(devm_snd_soc_register_dai);
-
 static void devm_component_release(struct device *dev, void *res)
 {
 	const struct snd_soc_component_driver **cmpnt_drv = res;