aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-04-22 10:10:22 -0400
committerTakashi Iwai <tiwai@suse.de>2015-04-23 11:11:02 -0400
commit4adb7bcbcb69d3bee0ed72de83adaee27daccdd8 (patch)
treea2011f7aae6bbd32371242ac529b245d3b5bf834 /include/sound
parent412b979ccceff448dccea54bdb616c85781bc0ba (diff)
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')
-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 9ca1a493d370..ff8962ebece5 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/poll.h> 25#include <linux/poll.h>
26#include <linux/seq_file.h>
26 27
27/* buffer for information */ 28/* buffer for information */
28struct snd_info_buffer { 29struct snd_info_buffer {
@@ -110,8 +111,18 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer);
110static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {} 111static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
111#endif 112#endif
112 113
113__printf(2, 3) 114/**
114int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...); 115 * snd_iprintf - printf on the procfs buffer
116 * @buf: the procfs buffer
117 * @fmt: the printf format
118 *
119 * Outputs the string on the procfs buffer just like printf().
120 *
121 * Return: zero for success, or a negative error code.
122 */
123#define snd_iprintf(buf, fmt, args...) \
124 seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
125
115int snd_info_init(void); 126int snd_info_init(void);
116int snd_info_done(void); 127int snd_info_done(void);
117 128
@@ -175,7 +186,6 @@ static inline int snd_card_proc_new(struct snd_card *card, const char *name,
175static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)), 186static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
176 void *private_data, 187 void *private_data,
177 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {} 188 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
178
179static inline int snd_info_check_reserved_words(const char *str) { return 1; } 189static inline int snd_info_check_reserved_words(const char *str) { return 1; }
180 190
181#endif 191#endif