From b224f6a82fcccf9806011dddb10ff8b7e37469a4 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Thu, 7 Sep 2017 14:03:23 +0800 Subject: [PATCH] ANDROID: GKI: ALSA: core: modify, rename and export create_subdir API Modify create_subdir API, so that it can create a subdir under a given parent directory and then register the info entry. Also rename and export the API so that it can be used to expose ID and version related information. Test: build Bug: 151372815 Signed-off-by: Phani Kumar Uppalapati Signed-off-by: Banajit Goswami Signed-off-by: Meng Wang (cherry picked from commit 454c5b5c345ab299b054b093ae6bb95e939a48b0) Signed-off-by: Hridya Valsaraju Change-Id: I8876b7ab22594766c9ec08c7289d8f38de7f00fa --- include/sound/info.h | 8 ++++++-- sound/core/info.c | 25 ++++++++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/sound/info.h b/include/sound/info.h index becdf66d2825..af580398e936 100644 --- a/include/sound/info.h +++ b/include/sound/info.h @@ -161,7 +161,9 @@ static inline void snd_info_set_text_ops(struct snd_info_entry *entry, } int snd_info_check_reserved_words(const char *str); - +struct snd_info_entry *snd_info_create_subdir(struct module *mod, + const char *name, + struct snd_info_entry *parent); #else #define snd_seq_root NULL @@ -190,7 +192,9 @@ static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribut void *private_data, void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {} static inline int snd_info_check_reserved_words(const char *str) { return 1; } - +static inline struct snd_info_entry *snd_info_create_subdir( + struct module *mod, const char *name, + struct snd_info_entry *parent) { return NULL; } #endif /* diff --git a/sound/core/info.c b/sound/core/info.c index 679136fba730..fefcb4eca78c 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -446,12 +446,23 @@ static const struct file_operations snd_info_text_entry_ops = .read = seq_read, }; -static struct snd_info_entry *create_subdir(struct module *mod, - const char *name) +/* + * snd_info_create_subdir - create and register a subdir for a given parent + * @mod: the module pointer + * @name: the module name + * @parent: the parent directory + * + * Creates and registers new subdir entry inside a given parent. + * + * Return: The pointer of the new instance, or NULL on failure. + */ +struct snd_info_entry *snd_info_create_subdir(struct module *mod, + const char *name, + struct snd_info_entry *parent) { struct snd_info_entry *entry; - entry = snd_info_create_module_entry(mod, name, NULL); + entry = snd_info_create_module_entry(mod, name, parent); if (!entry) return NULL; entry->mode = S_IFDIR | 0555; @@ -461,6 +472,7 @@ static struct snd_info_entry *create_subdir(struct module *mod, } return entry; } +EXPORT_SYMBOL(snd_info_create_subdir); static struct snd_info_entry * snd_info_create_entry(const char *name, struct snd_info_entry *parent); @@ -475,12 +487,12 @@ int __init snd_info_init(void) if (!snd_proc_root->p) goto error; #ifdef CONFIG_SND_OSSEMUL - snd_oss_root = create_subdir(THIS_MODULE, "oss"); + snd_oss_root = snd_info_create_subdir(THIS_MODULE, "oss", NULL); if (!snd_oss_root) goto error; #endif #if IS_ENABLED(CONFIG_SND_SEQUENCER) - snd_seq_root = create_subdir(THIS_MODULE, "seq"); + snd_seq_root = snd_info_create_subdir(THIS_MODULE, "seq", NULL); if (!snd_seq_root) goto error; #endif @@ -516,7 +528,7 @@ int snd_info_card_create(struct snd_card *card) return -ENXIO; sprintf(str, "card%i", card->number); - entry = create_subdir(card->module, str); + entry = snd_info_create_subdir(card->module, str, NULL); if (!entry) return -ENOMEM; card->proc_root = entry; @@ -619,7 +631,6 @@ int snd_info_card_free(struct snd_card *card) return 0; } - /** * snd_info_get_line - read one line from the procfs buffer * @buffer: the procfs buffer