Skip to contentSkip to conversation

ASoC: Use card as parameter to exported PM functions

PATCH In review Stephen Warren 2 participants 2 messages Jan 27, 2011 – Jan 28, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Use card as parameter to exported PM functions

If a machine driver is going to use the exported snd_soc_suspend/resume, at present, the platform device's drvdata must be the snd_soc_card. This prevents the machine driver from placing its own custom drvdata into the platform device.

This patch reworks the exported PM functions to take the card instead of the dev, thus allowing machine drivers to use a custom drvdata type. The disadvantage is that every machine driver that does this must then implement something similar to the soc_suspend/resume_dev functions in this patch.

An alternative might be to add a drvdata field to struct snd_soc_card, accompanied by snd_soc_set/get_drvdata functions.

Another alternative would be to wrap the snd_soc_card stored in the drvdata within another type, and use container_of whenever the machine driver needed the data in the wrapper type.

This patch is hence more of a question of "do we want to do it this way", rather than a concrete proposed patch.

---
 include/sound/soc.h  |    6 +++---
 sound/soc/soc-core.c |   46 ++++++++++++++++++++++++++++++++--------------
 2 files changed, 35 insertions(+), 17 deletions(-)
include/sound/soc.h +3 -3
index 7ecdaef..96ae31d 100644
@@ -260,9 +260,9 @@ enum snd_soc_compress_type {
 
 int snd_soc_register_card(struct snd_soc_card *card);
 int snd_soc_unregister_card(struct snd_soc_card *card);
-int snd_soc_suspend(struct device *dev);
-int snd_soc_resume(struct device *dev);
-int snd_soc_poweroff(struct device *dev);
+int snd_soc_suspend(struct snd_soc_card *card);
+int snd_soc_resume(struct snd_soc_card *card);
+int snd_soc_poweroff(struct snd_soc_card *card);
 int snd_soc_register_platform(struct device *dev,
 		struct snd_soc_platform_driver *platform_drv);
 void snd_soc_unregister_platform(struct device *dev);
sound/soc/soc-core.c +32 -14

96 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw
Quoted 4 lines · Stephen Warren

This patch reworks the exported PM functions to take the card instead of the dev, thus allowing machine drivers to use a custom drvdata type. The disadvantage is that every machine driver that does this must then implement something similar to the soc_suspend/resume_dev functions in this patch.

This is exactly why I didn't implement them this way - almost all drivers are just going to want to use the exact same boilerplate pm_ops so we don't want them having to all implement the same mapping functions. There's also enough callbacks from the core into the machine drivers to mean that I'm not sure we'd need to do anything else, and keeping things in the ASoC model is much more in the flow of pushing PM into the core.

Quoted 6 lines

An alternative might be to add a drvdata field to struct snd_soc_card, accompanied by snd_soc_set/get_drvdata functions.

Another alternative would be to wrap the snd_soc_card stored in the drvdata within another type, and use container_of whenever the machine driver needed the data in the wrapper type.

Either of these would work. The former is going to be much more friendly for users.