From a23b0d82b22d98999787f0b916bedcc04fc78f32 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 12 Dec 2011 15:55:34 -0700 Subject: [PATCH] --- yaml --- r: 283984 b: refs/heads/master c: bec4fa05e25f7e78ec67df389539acc6bb352a2a h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/sound/soc.h | 3 +++ trunk/sound/soc/soc-core.c | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index c2d008d5fdb2..96ec098cea83 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 6048ef768e7bec7e1e17f48fe8d5360021928b4a +refs/heads/master: bec4fa05e25f7e78ec67df389539acc6bb352a2a diff --git a/trunk/include/sound/soc.h b/trunk/include/sound/soc.h index a35cf14a8eb1..278f3b892ca6 100644 --- a/trunk/include/sound/soc.h +++ b/trunk/include/sound/soc.h @@ -961,6 +961,9 @@ static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) int snd_soc_util_init(void); void snd_soc_util_exit(void); +int snd_soc_of_parse_card_name(struct snd_soc_card *card, + const char *propname); + #include #ifdef CONFIG_DEBUG_FS diff --git a/trunk/sound/soc/soc-core.c b/trunk/sound/soc/soc-core.c index 1252ab1ebf69..51eef9b7b53f 100644 --- a/trunk/sound/soc/soc-core.c +++ b/trunk/sound/soc/soc-core.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -3317,6 +3318,30 @@ void snd_soc_unregister_codec(struct device *dev) } 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