From 3dea4c44db1ebdf2e59356b589c3f9af389f07ad Mon Sep 17 00:00:00 2001 From: Phani Kumar Uppalapati Date: Sun, 28 Jun 2015 23:42:59 -0700 Subject: [PATCH] ALSA: core: Add an API to create and register module Add an API to create a module under the given parent directory and then register the info entry. This API can be used to expose ID and version related information. Change-Id: I06f8bc1d8f649e6db37eb65303e948bc58eab7da Signed-off-by: Phani Kumar Uppalapati --- include/sound/info.h | 8 ++++++-- sound/core/info.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/sound/info.h b/include/sound/info.h index 67390ee846aa..3f0ceb511bff 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_register_module_info(struct module *module, + 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_register_module_info( + struct module *module, const char *name, + struct snd_info_entry *parent) { return NULL; } #endif /* diff --git a/sound/core/info.c b/sound/core/info.c index 895362a696c9..b5158b5673f1 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -612,6 +612,36 @@ int snd_info_card_free(struct snd_card *card) return 0; } +/* + * snd_register_module_info - create and register module + * @module: the module pointer + * @name: the module name + * @parent: the parent directory + * + * Creates and registers new module entry. + * + * Return: The pointer of the new instance, or NULL on failure. + */ +struct snd_info_entry *snd_register_module_info(struct module *module, + const char *name, + struct snd_info_entry *parent) +{ + struct snd_info_entry *entry; + + entry = snd_info_create_module_entry(module, name, parent); + if (!entry) + return NULL; + + entry->mode = S_IFDIR | S_IRUGO | S_IXUGO; + + if (snd_info_register(entry) < 0) { + snd_info_free_entry(entry); + return NULL; + } + + return entry; +} +EXPORT_SYMBOL(snd_register_module_info); /** * snd_info_get_line - read one line from the procfs buffer