summaryrefslogtreecommitdiffstats
path: root/include/sound/info.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-04-22 16:10:22 +0200
committerTakashi Iwai <tiwai@suse.de>2015-04-23 17:11:02 +0200
commit4adb7bcbcb69d3bee0ed72de83adaee27daccdd8 (patch)
treea2011f7aae6bbd32371242ac529b245d3b5bf834 /include/sound/info.h
parent412b979ccceff448dccea54bdb616c85781bc0ba (diff)
downloadop-kernel-dev-4adb7bcbcb69d3bee0ed72de83adaee27daccdd8.zip
op-kernel-dev-4adb7bcbcb69d3bee0ed72de83adaee27daccdd8.tar.gz
ALSA: core: Use seq_file for text proc file reads
seq_file is _the_ standard interface for simple text proc files. Though, we still need to support the binary proc files and the text file write, and also we need to manage the device disconnection gracefully. Thus this patch just replaces the text file read code with seq_file while keeping the rest intact. snd_iprintf() helper function is now a macro to expand itself to seq_printf() to be compatible with the existing code. The seq_file object is stored to the unused entry->rbuffer->buffer pointer. When the output size is expected to be large (greater than PAGE_SIZE), the driver should set entry->size field beforehand. Then the given size will be preallocated and the multiple show calls can be avoided. Acked-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound/info.h')
-rw-r--r--include/sound/info.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/include/sound/info.h b/include/sound/info.h
index 9ca1a49..ff8962eb 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -23,6 +23,7 @@
*/
#include <linux/poll.h>
+#include <linux/seq_file.h>
/* buffer for information */
struct snd_info_buffer {
@@ -110,8 +111,18 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer);
static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
#endif
-__printf(2, 3)
-int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...);
+/**
+ * snd_iprintf - printf on the procfs buffer
+ * @buf: the procfs buffer
+ * @fmt: the printf format
+ *
+ * Outputs the string on the procfs buffer just like printf().
+ *
+ * Return: zero for success, or a negative error code.
+ */
+#define snd_iprintf(buf, fmt, args...) \
+ seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
+
int snd_info_init(void);
int snd_info_done(void);
@@ -175,7 +186,6 @@ static inline int snd_card_proc_new(struct snd_card *card, const char *name,
static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
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; }
#endif
OpenPOWER on IntegriCloud