ASoC: Move card field form platform/codec to component
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 17 Jul 2014 20:01:07 +0000 (22:01 +0200)
committerMark Brown <broonie@linaro.org>
Tue, 22 Jul 2014 22:15:57 +0000 (23:15 +0100)
Both the snd_soc_codec and snd_soc_platform struct do have a pointer to the
parent card and both handle this pointer in mostly the same way. This patch
moves the card field to the component level which will allow further code
consolidation between platforms and CODECS.

Since there are only a handful of users of the snd_soc_codec struct's card field
(and none of the snd_soc_platform's) these are update in this patch as well,
which allows it to be removed from the snd_soc_codec struct.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
include/sound/soc.h
sound/soc/codecs/ac97.c
sound/soc/codecs/cx20442.c
sound/soc/codecs/uda134x.c
sound/soc/codecs/wm8960.c
sound/soc/codecs/wm_adsp.c
sound/soc/omap/ams-delta.c
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/soc-jack.c

index 1f5b4901415e38deb8aa6b7b2c1bc572fbd0e564..5ee6ddde4831add502f6fe0004d53565a25e746a 100644 (file)
@@ -691,6 +691,7 @@ struct snd_soc_component {
        int id;
        const char *name_prefix;
        struct device *dev;
+       struct snd_soc_card *card;
 
        unsigned int active;
 
@@ -725,7 +726,6 @@ struct snd_soc_codec {
        const struct snd_soc_codec_driver *driver;
 
        struct mutex mutex;
-       struct snd_soc_card *card;
        struct list_head list;
        struct list_head card_list;
 
@@ -863,7 +863,6 @@ struct snd_soc_platform {
        unsigned int suspended:1; /* platform is suspended */
        unsigned int probed:1;
 
-       struct snd_soc_card *card;
        struct list_head list;
 
        struct snd_soc_component component;
index 8d9ba4ba4bfe0b2fece2dc5c30f955fd5d6dcc00..e889e1b84192bcc8d0baf354e1a66a8892c72e4f 100644 (file)
@@ -89,8 +89,8 @@ static int ac97_soc_probe(struct snd_soc_codec *codec)
        int ret;
 
        /* add codec as bus device for standard ac97 */
-       ret = snd_ac97_bus(codec->card->snd_card, 0, soc_ac97_ops, NULL,
-                          &ac97_bus);
+       ret = snd_ac97_bus(codec->component.card->snd_card, 0, soc_ac97_ops,
+                          NULL, &ac97_bus);
        if (ret < 0)
                return ret;
 
index d5fd00a64748097ad1794ed9cc45178c513c6b68..4ba60eb2cde1136c7942f785366ebf932deeaba7 100644 (file)
@@ -253,7 +253,7 @@ static void v253_close(struct tty_struct *tty)
        /* Prevent the codec driver from further accessing the modem */
        codec->hw_write = NULL;
        cx20442->control_data = NULL;
-       codec->card->pop_time = 0;
+       codec->component.card->pop_time = 0;
 }
 
 /* Line discipline .hangup() */
@@ -281,7 +281,7 @@ static void v253_receive(struct tty_struct *tty,
                /* Set up codec driver access to modem controls */
                cx20442->control_data = tty;
                codec->hw_write = (hw_write_t)tty->ops->write;
-               codec->card->pop_time = 1;
+               codec->component.card->pop_time = 1;
        }
 }
 
@@ -372,7 +372,7 @@ static int cx20442_codec_probe(struct snd_soc_codec *codec)
 
        snd_soc_codec_set_drvdata(codec, cx20442);
        codec->hw_write = NULL;
-       codec->card->pop_time = 0;
+       codec->component.card->pop_time = 0;
 
        return 0;
 }
index edf27acc1d77da6ba457cef5e8a403867e753fb2..12fc0aed7503188390a96966ff4c59626cb66325 100644 (file)
@@ -479,7 +479,7 @@ static struct snd_soc_dai_driver uda134x_dai = {
 static int uda134x_soc_probe(struct snd_soc_codec *codec)
 {
        struct uda134x_priv *uda134x;
-       struct uda134x_platform_data *pd = codec->card->dev->platform_data;
+       struct uda134x_platform_data *pd = codec->component.card->dev->platform_data;
        const struct snd_soc_dapm_widget *widgets;
        unsigned num_widgets;
 
index a145d0431b63dbc11c975f8b226a6f250ed17008..e96349b04ba6553a1c26b6a4bc532cb3d7d364de 100644 (file)
@@ -472,7 +472,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec)
         * list each time to find the desired power state do so now
         * and save the result.
         */
-       list_for_each_entry(w, &codec->card->widgets, list) {
+       list_for_each_entry(w, &codec->component.card->widgets, list) {
                if (w->dapm != &codec->dapm)
                        continue;
                if (strcmp(w->name, "LOUT1 PGA") == 0)
index 060027182dcb0bcd57a87600d987d294cab06847..fb86f072fa67defc6864b25f7a9462025e3bcc44 100644 (file)
@@ -1382,7 +1382,7 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w,
        int ret;
        int val;
 
-       dsp->card = codec->card;
+       dsp->card = codec->component.card;
 
        switch (event) {
        case SND_SOC_DAPM_POST_PMU:
@@ -1617,7 +1617,7 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,
        struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
        struct wm_adsp *dsp = &dsps[w->shift];
 
-       dsp->card = codec->card;
+       dsp->card = codec->component.card;
 
        switch (event) {
        case SND_SOC_DAPM_PRE_PMU:
index 0cc41f94de4e591b617486a7982327eb0a7eec13..8c9cc64a9dfb320a62ec0c204b57b1d5fcaae8f3 100644 (file)
@@ -301,7 +301,7 @@ static int cx81801_open(struct tty_struct *tty)
 static void cx81801_close(struct tty_struct *tty)
 {
        struct snd_soc_codec *codec = tty->disc_data;
-       struct snd_soc_dapm_context *dapm = &codec->card->dapm;
+       struct snd_soc_dapm_context *dapm = &codec->component.card->dapm;
 
        del_timer_sync(&cx81801_timer);
 
index a5edb31ddfffd7b513947047e6216f70ab063f7b..a0ae3d2263d1f79a07cd4562522830adc2b5ece7 100644 (file)
@@ -292,7 +292,7 @@ static struct dentry *soc_debugfs_create_dir(struct dentry *parent,
 
 static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
 {
-       struct dentry *debugfs_card_root = codec->card->debugfs_card_root;
+       struct dentry *debugfs_card_root = codec->component.card->debugfs_card_root;
 
        codec->debugfs_codec_root = soc_debugfs_create_dir(debugfs_card_root,
                                                "codec:%s",
@@ -325,7 +325,7 @@ static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
 
 static void soc_init_platform_debugfs(struct snd_soc_platform *platform)
 {
-       struct dentry *debugfs_card_root = platform->card->debugfs_card_root;
+       struct dentry *debugfs_card_root = platform->component.card->debugfs_card_root;
 
        platform->debugfs_platform_root = soc_debugfs_create_dir(debugfs_card_root,
                                                "platform:%s",
@@ -546,11 +546,12 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
        int err;
 
        codec->ac97->dev.bus = &ac97_bus_type;
-       codec->ac97->dev.parent = codec->card->dev;
+       codec->ac97->dev.parent = codec->component.card->dev;
        codec->ac97->dev.release = soc_ac97_device_release;
 
        dev_set_name(&codec->ac97->dev, "%d-%d:%s",
-                    codec->card->snd_card->number, 0, codec->component.name);
+                    codec->component.card->snd_card->number, 0,
+                    codec->component.name);
        err = device_register(&codec->ac97->dev);
        if (err < 0) {
                dev_err(codec->dev, "ASoC: Can't register ac97 bus\n");
@@ -1179,7 +1180,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
        const struct snd_soc_codec_driver *driver = codec->driver;
        struct snd_soc_dai *dai;
 
-       codec->card = card;
+       codec->component.card = card;
        codec->dapm.card = card;
        soc_set_name_prefix(card, &codec->component);
 
@@ -1255,7 +1256,7 @@ static int soc_probe_platform(struct snd_soc_card *card,
        struct snd_soc_component *component;
        struct snd_soc_dai *dai;
 
-       platform->card = card;
+       platform->component.card = card;
        platform->component.dapm.card = card;
 
        if (!try_module_get(platform->dev->driver->owner))
@@ -2406,7 +2407,7 @@ EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol);
 int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
        const struct snd_kcontrol_new *controls, int num_controls)
 {
-       struct snd_card *card = codec->card->snd_card;
+       struct snd_card *card = codec->component.card->snd_card;
 
        return snd_soc_add_controls(card, codec->dev, controls, num_controls,
                        codec->component.name_prefix, &codec->component);
@@ -2426,7 +2427,7 @@ EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls);
 int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
        const struct snd_kcontrol_new *controls, int num_controls)
 {
-       struct snd_card *card = platform->card->snd_card;
+       struct snd_card *card = platform->component.card->snd_card;
 
        return snd_soc_add_controls(card, platform->dev, controls, num_controls,
                        NULL, &platform->component);
@@ -3101,7 +3102,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_range);
 int snd_soc_limit_volume(struct snd_soc_codec *codec,
        const char *name, int max)
 {
-       struct snd_card *card = codec->card->snd_card;
+       struct snd_card *card = codec->component.card->snd_card;
        struct snd_kcontrol *kctl;
        struct soc_mixer_control *mc;
        int found = 0;
index 8cb68a38ad19a0e700378f6604a65158672ff4fa..8348352dc2c62c484a1efba6f04c290367b93864 100644 (file)
@@ -2090,7 +2090,7 @@ static ssize_t dapm_widget_show_codec(struct snd_soc_codec *codec, char *buf)
        int count = 0;
        char *state = "not set";
 
-       list_for_each_entry(w, &codec->card->widgets, list) {
+       list_for_each_entry(w, &codec->component.card->widgets, list) {
                if (w->dapm != &codec->dapm)
                        continue;
 
index d0d98810af9170baf86120b77767d6b365745f86..ab47fea997a3cd4d9b8897ab9e2ea6cf495c56dc 100644 (file)
@@ -43,7 +43,7 @@ int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
        INIT_LIST_HEAD(&jack->jack_zones);
        BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
 
-       return snd_jack_new(codec->card->snd_card, id, type, &jack->jack);
+       return snd_jack_new(codec->component.card->snd_card, id, type, &jack->jack);
 }
 EXPORT_SYMBOL_GPL(snd_soc_jack_new);
 
@@ -260,7 +260,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
 static irqreturn_t gpio_handler(int irq, void *data)
 {
        struct snd_soc_jack_gpio *gpio = data;
-       struct device *dev = gpio->jack->codec->card->dev;
+       struct device *dev = gpio->jack->codec->component.card->dev;
 
        trace_snd_soc_jack_irq(gpio->name);