diff options
-rw-r--r-- | include/sound/soc.h | 20 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 122 |
2 files changed, 67 insertions, 75 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index be6ecae247b0..0ab8b1e4a5d2 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -728,9 +728,24 @@ struct snd_soc_component { | |||
728 | 728 | ||
729 | struct mutex io_mutex; | 729 | struct mutex io_mutex; |
730 | 730 | ||
731 | #ifdef CONFIG_DEBUG_FS | ||
732 | struct dentry *debugfs_root; | ||
733 | #endif | ||
734 | |||
735 | /* | ||
736 | * DO NOT use any of the fields below in drivers, they are temporary and | ||
737 | * are going to be removed again soon. If you use them in driver code the | ||
738 | * driver will be marked as BROKEN when these fields are removed. | ||
739 | */ | ||
740 | |||
731 | /* Don't use these, use snd_soc_component_get_dapm() */ | 741 | /* Don't use these, use snd_soc_component_get_dapm() */ |
732 | struct snd_soc_dapm_context dapm; | 742 | struct snd_soc_dapm_context dapm; |
733 | struct snd_soc_dapm_context *dapm_ptr; | 743 | struct snd_soc_dapm_context *dapm_ptr; |
744 | |||
745 | #ifdef CONFIG_DEBUG_FS | ||
746 | void (*init_debugfs)(struct snd_soc_component *component); | ||
747 | const char *debugfs_prefix; | ||
748 | #endif | ||
734 | }; | 749 | }; |
735 | 750 | ||
736 | /* SoC Audio Codec device */ | 751 | /* SoC Audio Codec device */ |
@@ -766,7 +781,6 @@ struct snd_soc_codec { | |||
766 | struct snd_soc_dapm_context dapm; | 781 | struct snd_soc_dapm_context dapm; |
767 | 782 | ||
768 | #ifdef CONFIG_DEBUG_FS | 783 | #ifdef CONFIG_DEBUG_FS |
769 | struct dentry *debugfs_codec_root; | ||
770 | struct dentry *debugfs_reg; | 784 | struct dentry *debugfs_reg; |
771 | #endif | 785 | #endif |
772 | }; | 786 | }; |
@@ -879,10 +893,6 @@ struct snd_soc_platform { | |||
879 | struct list_head list; | 893 | struct list_head list; |
880 | 894 | ||
881 | struct snd_soc_component component; | 895 | struct snd_soc_component component; |
882 | |||
883 | #ifdef CONFIG_DEBUG_FS | ||
884 | struct dentry *debugfs_platform_root; | ||
885 | #endif | ||
886 | }; | 896 | }; |
887 | 897 | ||
888 | struct snd_soc_dai_link { | 898 | struct snd_soc_dai_link { |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d4bfd4a9076f..79371a77f324 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -270,79 +270,56 @@ static const struct file_operations codec_reg_fops = { | |||
270 | .llseek = default_llseek, | 270 | .llseek = default_llseek, |
271 | }; | 271 | }; |
272 | 272 | ||
273 | static struct dentry *soc_debugfs_create_dir(struct dentry *parent, | 273 | static void soc_init_component_debugfs(struct snd_soc_component *component) |
274 | const char *fmt, ...) | ||
275 | { | 274 | { |
276 | struct dentry *de; | 275 | if (component->debugfs_prefix) { |
277 | va_list ap; | 276 | char *name; |
278 | char *s; | ||
279 | 277 | ||
280 | va_start(ap, fmt); | 278 | name = kasprintf(GFP_KERNEL, "%s:%s", |
281 | s = kvasprintf(GFP_KERNEL, fmt, ap); | 279 | component->debugfs_prefix, component->name); |
282 | va_end(ap); | 280 | if (name) { |
281 | component->debugfs_root = debugfs_create_dir(name, | ||
282 | component->card->debugfs_card_root); | ||
283 | kfree(name); | ||
284 | } | ||
285 | } else { | ||
286 | component->debugfs_root = debugfs_create_dir(component->name, | ||
287 | component->card->debugfs_card_root); | ||
288 | } | ||
283 | 289 | ||
284 | if (!s) | 290 | if (!component->debugfs_root) { |
285 | return NULL; | 291 | dev_warn(component->dev, |
292 | "ASoC: Failed to create component debugfs directory\n"); | ||
293 | return; | ||
294 | } | ||
286 | 295 | ||
287 | de = debugfs_create_dir(s, parent); | 296 | snd_soc_dapm_debugfs_init(snd_soc_component_get_dapm(component), |
288 | kfree(s); | 297 | component->debugfs_root); |
289 | 298 | ||
290 | return de; | 299 | if (component->init_debugfs) |
300 | component->init_debugfs(component); | ||
291 | } | 301 | } |
292 | 302 | ||
293 | static void soc_init_codec_debugfs(struct snd_soc_codec *codec) | 303 | static void soc_cleanup_component_debugfs(struct snd_soc_component *component) |
294 | { | 304 | { |
295 | struct dentry *debugfs_card_root = codec->component.card->debugfs_card_root; | 305 | debugfs_remove_recursive(component->debugfs_root); |
306 | } | ||
296 | 307 | ||
297 | codec->debugfs_codec_root = soc_debugfs_create_dir(debugfs_card_root, | 308 | static void soc_init_codec_debugfs(struct snd_soc_component *component) |
298 | "codec:%s", | 309 | { |
299 | codec->component.name); | 310 | struct snd_soc_codec *codec = snd_soc_component_to_codec(component); |
300 | if (!codec->debugfs_codec_root) { | ||
301 | dev_warn(codec->dev, | ||
302 | "ASoC: Failed to create codec debugfs directory\n"); | ||
303 | return; | ||
304 | } | ||
305 | 311 | ||
306 | debugfs_create_bool("cache_sync", 0444, codec->debugfs_codec_root, | 312 | debugfs_create_bool("cache_sync", 0444, codec->component.debugfs_root, |
307 | &codec->cache_sync); | 313 | &codec->cache_sync); |
308 | debugfs_create_bool("cache_only", 0444, codec->debugfs_codec_root, | 314 | debugfs_create_bool("cache_only", 0444, codec->component.debugfs_root, |
309 | &codec->cache_only); | 315 | &codec->cache_only); |
310 | 316 | ||
311 | codec->debugfs_reg = debugfs_create_file("codec_reg", 0644, | 317 | codec->debugfs_reg = debugfs_create_file("codec_reg", 0644, |
312 | codec->debugfs_codec_root, | 318 | codec->component.debugfs_root, |
313 | codec, &codec_reg_fops); | 319 | codec, &codec_reg_fops); |
314 | if (!codec->debugfs_reg) | 320 | if (!codec->debugfs_reg) |
315 | dev_warn(codec->dev, | 321 | dev_warn(codec->dev, |
316 | "ASoC: Failed to create codec register debugfs file\n"); | 322 | "ASoC: Failed to create codec register debugfs file\n"); |
317 | |||
318 | snd_soc_dapm_debugfs_init(&codec->dapm, codec->debugfs_codec_root); | ||
319 | } | ||
320 | |||
321 | static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec) | ||
322 | { | ||
323 | debugfs_remove_recursive(codec->debugfs_codec_root); | ||
324 | } | ||
325 | |||
326 | static void soc_init_platform_debugfs(struct snd_soc_platform *platform) | ||
327 | { | ||
328 | struct dentry *debugfs_card_root = platform->component.card->debugfs_card_root; | ||
329 | |||
330 | platform->debugfs_platform_root = soc_debugfs_create_dir(debugfs_card_root, | ||
331 | "platform:%s", | ||
332 | platform->component.name); | ||
333 | if (!platform->debugfs_platform_root) { | ||
334 | dev_warn(platform->dev, | ||
335 | "ASoC: Failed to create platform debugfs directory\n"); | ||
336 | return; | ||
337 | } | ||
338 | |||
339 | snd_soc_dapm_debugfs_init(&platform->component.dapm, | ||
340 | platform->debugfs_platform_root); | ||
341 | } | ||
342 | |||
343 | static void soc_cleanup_platform_debugfs(struct snd_soc_platform *platform) | ||
344 | { | ||
345 | debugfs_remove_recursive(platform->debugfs_platform_root); | ||
346 | } | 323 | } |
347 | 324 | ||
348 | static ssize_t codec_list_read_file(struct file *file, char __user *user_buf, | 325 | static ssize_t codec_list_read_file(struct file *file, char __user *user_buf, |
@@ -474,19 +451,15 @@ static void soc_cleanup_card_debugfs(struct snd_soc_card *card) | |||
474 | 451 | ||
475 | #else | 452 | #else |
476 | 453 | ||
477 | static inline void soc_init_codec_debugfs(struct snd_soc_codec *codec) | 454 | #define soc_init_codec_debugfs NULL |
478 | { | ||
479 | } | ||
480 | 455 | ||
481 | static inline void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec) | 456 | static inline void soc_init_component_debugfs( |
457 | struct snd_soc_component *component) | ||
482 | { | 458 | { |
483 | } | 459 | } |
484 | 460 | ||
485 | static inline void soc_init_platform_debugfs(struct snd_soc_platform *platform) | 461 | static inline void soc_cleanup_component_debugfs( |
486 | { | 462 | struct snd_soc_component *component) |
487 | } | ||
488 | |||
489 | static inline void soc_cleanup_platform_debugfs(struct snd_soc_platform *platform) | ||
490 | { | 463 | { |
491 | } | 464 | } |
492 | 465 | ||
@@ -1026,7 +999,7 @@ static int soc_remove_platform(struct snd_soc_platform *platform) | |||
1026 | /* Make sure all DAPM widgets are freed */ | 999 | /* Make sure all DAPM widgets are freed */ |
1027 | snd_soc_dapm_free(&platform->component.dapm); | 1000 | snd_soc_dapm_free(&platform->component.dapm); |
1028 | 1001 | ||
1029 | soc_cleanup_platform_debugfs(platform); | 1002 | soc_cleanup_component_debugfs(&platform->component); |
1030 | platform->probed = 0; | 1003 | platform->probed = 0; |
1031 | module_put(platform->dev->driver->owner); | 1004 | module_put(platform->dev->driver->owner); |
1032 | 1005 | ||
@@ -1046,7 +1019,7 @@ static void soc_remove_codec(struct snd_soc_codec *codec) | |||
1046 | /* Make sure all DAPM widgets are freed */ | 1019 | /* Make sure all DAPM widgets are freed */ |
1047 | snd_soc_dapm_free(&codec->dapm); | 1020 | snd_soc_dapm_free(&codec->dapm); |
1048 | 1021 | ||
1049 | soc_cleanup_codec_debugfs(codec); | 1022 | soc_cleanup_component_debugfs(&codec->component); |
1050 | codec->probed = 0; | 1023 | codec->probed = 0; |
1051 | list_del(&codec->card_list); | 1024 | list_del(&codec->card_list); |
1052 | module_put(codec->dev->driver->owner); | 1025 | module_put(codec->dev->driver->owner); |
@@ -1187,7 +1160,7 @@ static int soc_probe_codec(struct snd_soc_card *card, | |||
1187 | if (!try_module_get(codec->dev->driver->owner)) | 1160 | if (!try_module_get(codec->dev->driver->owner)) |
1188 | return -ENODEV; | 1161 | return -ENODEV; |
1189 | 1162 | ||
1190 | soc_init_codec_debugfs(codec); | 1163 | soc_init_component_debugfs(&codec->component); |
1191 | 1164 | ||
1192 | if (driver->dapm_widgets) { | 1165 | if (driver->dapm_widgets) { |
1193 | ret = snd_soc_dapm_new_controls(&codec->dapm, | 1166 | ret = snd_soc_dapm_new_controls(&codec->dapm, |
@@ -1242,7 +1215,7 @@ static int soc_probe_codec(struct snd_soc_card *card, | |||
1242 | return 0; | 1215 | return 0; |
1243 | 1216 | ||
1244 | err_probe: | 1217 | err_probe: |
1245 | soc_cleanup_codec_debugfs(codec); | 1218 | soc_cleanup_component_debugfs(&codec->component); |
1246 | module_put(codec->dev->driver->owner); | 1219 | module_put(codec->dev->driver->owner); |
1247 | 1220 | ||
1248 | return ret; | 1221 | return ret; |
@@ -1262,7 +1235,7 @@ static int soc_probe_platform(struct snd_soc_card *card, | |||
1262 | if (!try_module_get(platform->dev->driver->owner)) | 1235 | if (!try_module_get(platform->dev->driver->owner)) |
1263 | return -ENODEV; | 1236 | return -ENODEV; |
1264 | 1237 | ||
1265 | soc_init_platform_debugfs(platform); | 1238 | soc_init_component_debugfs(&platform->component); |
1266 | 1239 | ||
1267 | if (driver->dapm_widgets) | 1240 | if (driver->dapm_widgets) |
1268 | snd_soc_dapm_new_controls(&platform->component.dapm, | 1241 | snd_soc_dapm_new_controls(&platform->component.dapm, |
@@ -1302,7 +1275,7 @@ static int soc_probe_platform(struct snd_soc_card *card, | |||
1302 | return 0; | 1275 | return 0; |
1303 | 1276 | ||
1304 | err_probe: | 1277 | err_probe: |
1305 | soc_cleanup_platform_debugfs(platform); | 1278 | soc_cleanup_component_debugfs(&platform->component); |
1306 | module_put(platform->dev->driver->owner); | 1279 | module_put(platform->dev->driver->owner); |
1307 | 1280 | ||
1308 | return ret; | 1281 | return ret; |
@@ -4266,6 +4239,10 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, | |||
4266 | if (platform_drv->read) | 4239 | if (platform_drv->read) |
4267 | platform->component.read = snd_soc_platform_drv_read; | 4240 | platform->component.read = snd_soc_platform_drv_read; |
4268 | 4241 | ||
4242 | #ifdef CONFIG_DEBUG_FS | ||
4243 | platform->component.debugfs_prefix = "platform"; | ||
4244 | #endif | ||
4245 | |||
4269 | mutex_lock(&client_mutex); | 4246 | mutex_lock(&client_mutex); |
4270 | snd_soc_component_add_unlocked(&platform->component); | 4247 | snd_soc_component_add_unlocked(&platform->component); |
4271 | list_add(&platform->list, &platform_list); | 4248 | list_add(&platform->list, &platform_list); |
@@ -4455,6 +4432,11 @@ int snd_soc_register_codec(struct device *dev, | |||
4455 | codec->component.val_bytes = codec_drv->reg_word_size; | 4432 | codec->component.val_bytes = codec_drv->reg_word_size; |
4456 | mutex_init(&codec->mutex); | 4433 | mutex_init(&codec->mutex); |
4457 | 4434 | ||
4435 | #ifdef CONFIG_DEBUG_FS | ||
4436 | codec->component.init_debugfs = soc_init_codec_debugfs; | ||
4437 | codec->component.debugfs_prefix = "codec"; | ||
4438 | #endif | ||
4439 | |||
4458 | if (!codec->component.write) { | 4440 | if (!codec->component.write) { |
4459 | if (codec_drv->get_regmap) | 4441 | if (codec_drv->get_regmap) |
4460 | regmap = codec_drv->get_regmap(dev); | 4442 | regmap = codec_drv->get_regmap(dev); |