diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-09-15 18:19:07 +0100 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-09-16 14:14:02 +0100 |
commit | f320878032be5c755509583c8a24b57d2ee50b20 (patch) | |
tree | 0c93ef9f5470c924626437f842365b4999aad3ad | |
parent | c3c5a19a50866869996cc219aed2021acf091d6e (diff) |
ASoC: Add DAI list to debugfs
Allow the user to inspect the list of registered DAIs at runtime to
improve diagnostics for machine driver setup.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-rw-r--r-- | sound/soc/soc-core.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 94a2edf9cfd..63d93b3b7b7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -297,6 +297,32 @@ static const struct file_operations codec_list_fops = { .llseek = default_llseek,/* read accesses f_pos */ }; +static ssize_t dai_list_read_file(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); + ssize_t ret = 0; + struct snd_soc_dai *dai; + + if (!buf) + return -ENOMEM; + + list_for_each_entry(dai, &dai_list, list) + ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name); + + if (ret >= 0) + ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); + + kfree(buf); + + return ret; +} + +static const struct file_operations dai_list_fops = { + .read = dai_list_read_file, + .llseek = default_llseek,/* read accesses f_pos */ +}; + #else static inline void soc_init_codec_debugfs(struct snd_soc_codec *codec) @@ -3223,6 +3249,9 @@ static int __init snd_soc_init(void) &codec_list_fops)) pr_warn("ASoC: Failed to create CODEC list debugfs file\n"); + if (!debugfs_create_file("dais", 0444, debugfs_root, NULL, + &dai_list_fops)) + pr_warn("ASoC: Failed to create DAI list debugfs file\n"); #endif return platform_driver_register(&soc_driver); |