diff options
| author | Stephen Warren <swarren@nvidia.com> | 2011-12-12 17:55:34 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-12-19 20:05:34 -0500 |
| commit | bec4fa05e25f7e78ec67df389539acc6bb352a2a (patch) | |
| tree | ddde93b4ca9604bf586bde2381cdb8c0dffd3f07 | |
| parent | 6048ef768e7bec7e1e17f48fe8d5360021928b4a (diff) | |
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>
| -rw-r--r-- | include/sound/soc.h | 3 | ||||
| -rw-r--r-- | sound/soc/soc-core.c | 25 |
2 files changed, 28 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index a35cf14a8eb1..278f3b892ca6 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
| @@ -961,6 +961,9 @@ static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) | |||
| 961 | int snd_soc_util_init(void); | 961 | int snd_soc_util_init(void); |
| 962 | void snd_soc_util_exit(void); | 962 | void snd_soc_util_exit(void); |
| 963 | 963 | ||
| 964 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, | ||
| 965 | const char *propname); | ||
| 966 | |||
| 964 | #include <sound/soc-dai.h> | 967 | #include <sound/soc-dai.h> |
| 965 | 968 | ||
| 966 | #ifdef CONFIG_DEBUG_FS | 969 | #ifdef CONFIG_DEBUG_FS |
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 @@ | |||
| 32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
| 33 | #include <linux/ctype.h> | 33 | #include <linux/ctype.h> |
| 34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
| 35 | #include <linux/of.h> | ||
| 35 | #include <sound/ac97_codec.h> | 36 | #include <sound/ac97_codec.h> |
| 36 | #include <sound/core.h> | 37 | #include <sound/core.h> |
| 37 | #include <sound/jack.h> | 38 | #include <sound/jack.h> |
| @@ -3317,6 +3318,30 @@ found: | |||
| 3317 | } | 3318 | } |
| 3318 | EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); | 3319 | EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); |
| 3319 | 3320 | ||
| 3321 | /* Retrieve a card's name from device tree */ | ||
| 3322 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, | ||
| 3323 | const char *propname) | ||
| 3324 | { | ||
| 3325 | struct device_node *np = card->dev->of_node; | ||
| 3326 | int ret; | ||
| 3327 | |||
| 3328 | ret = of_property_read_string_index(np, propname, 0, &card->name); | ||
| 3329 | /* | ||
| 3330 | * EINVAL means the property does not exist. This is fine providing | ||
| 3331 | * card->name was previously set, which is checked later in | ||
| 3332 | * snd_soc_register_card. | ||
| 3333 | */ | ||
| 3334 | if (ret < 0 && ret != -EINVAL) { | ||
| 3335 | dev_err(card->dev, | ||
| 3336 | "Property '%s' could not be read: %d\n", | ||
| 3337 | propname, ret); | ||
| 3338 | return ret; | ||
| 3339 | } | ||
| 3340 | |||
| 3341 | return 0; | ||
| 3342 | } | ||
| 3343 | EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name); | ||
| 3344 | |||
| 3320 | static int __init snd_soc_init(void) | 3345 | static int __init snd_soc_init(void) |
| 3321 | { | 3346 | { |
| 3322 | #ifdef CONFIG_DEBUG_FS | 3347 | #ifdef CONFIG_DEBUG_FS |
