diff options
author | Stephen Warren | 2011-12-12 23:55:34 +0100 |
---|---|---|
committer | Mark Brown | 2011-12-20 02:05:34 +0100 |
commit | bec4fa05e25f7e78ec67df389539acc6bb352a2a (patch) | |
tree | ddde93b4ca9604bf586bde2381cdb8c0dffd3f07 /sound/soc/soc-core.c | |
parent | ASoC: Rename rt562[1|2]_vol_snd_controls to alc562[1|2]_vol_snd_controls (diff) | |
download | kernel-qcow2-linux-bec4fa05e25f7e78ec67df389539acc6bb352a2a.tar.gz kernel-qcow2-linux-bec4fa05e25f7e78ec67df389539acc6bb352a2a.tar.xz kernel-qcow2-linux-bec4fa05e25f7e78ec67df389539acc6bb352a2a.zip |
ASoC: Add utility to set a card's name from device tree
Implement snd_soc_of_parse_card_name(), a utility function that sets a
card's name from device tree. The machine driver specifies the DT
property to use, since this is binding-specific.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1252ab1ebf69..51eef9b7b53f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -32,6 +32,7 @@ #include <linux/platform_device.h> #include <linux/ctype.h> #include <linux/slab.h> +#include <linux/of.h> #include <sound/ac97_codec.h> #include <sound/core.h> #include <sound/jack.h> @@ -3317,6 +3318,30 @@ found: } EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); +/* Retrieve a card's name from device tree */ +int snd_soc_of_parse_card_name(struct snd_soc_card *card, + const char *propname) +{ + struct device_node *np = card->dev->of_node; + int ret; + + ret = of_property_read_string_index(np, propname, 0, &card->name); + /* + * EINVAL means the property does not exist. This is fine providing + * card->name was previously set, which is checked later in + * snd_soc_register_card. + */ + if (ret < 0 && ret != -EINVAL) { + dev_err(card->dev, + "Property '%s' could not be read: %d\n", + propname, ret); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name); + static int __init snd_soc_init(void) { #ifdef CONFIG_DEBUG_FS |