summaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-02-04 14:53:04 +0100
committerTakashi Iwai <tiwai@suse.de>2019-02-06 18:11:55 +0100
commit7453e1dafdec076f87384c8647d2960affd57ecc (patch)
tree2d82ae43f4669c943af79f50fc78793e6eac6000 /sound/core
parenteaffef0d5fca38939ac986de4625f4f070c49346 (diff)
downloadlinux-7453e1dafdec076f87384c8647d2960affd57ecc.tar.gz
linux-7453e1dafdec076f87384c8647d2960affd57ecc.tar.bz2
linux-7453e1dafdec076f87384c8647d2960affd57ecc.zip
ALSA: info: Add standard helpers for card proc file entries
Two new helper functions are added here for cleaning up the existing lengthy calls. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/info.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sound/core/info.c b/sound/core/info.c
index 5cd00629c0f5..6c149fa54d2d 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -866,6 +866,38 @@ int snd_info_register(struct snd_info_entry *entry)
}
EXPORT_SYMBOL(snd_info_register);
+/**
+ * snd_card_rw_proc_new - Create a read/write text proc file entry for the card
+ * @card: the card instance
+ * @name: the file name
+ * @private_data: the arbitrary private data
+ * @read: the read callback
+ * @write: the write callback, NULL for read-only
+ *
+ * This proc file entry will be registered via snd_card_register() call, and
+ * it will be removed automatically at the card removal, too.
+ */
+int snd_card_rw_proc_new(struct snd_card *card, const char *name,
+ void *private_data,
+ void (*read)(struct snd_info_entry *,
+ struct snd_info_buffer *),
+ void (*write)(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer))
+{
+ struct snd_info_entry *entry;
+
+ entry = snd_info_create_card_entry(card, name, card->proc_root);
+ if (!entry)
+ return -ENOMEM;
+ snd_info_set_text_ops(entry, private_data, read);
+ if (write) {
+ entry->mode |= 0200;
+ entry->c.text.write = write;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_card_rw_proc_new);
+
/*
*/