forked from luck/tmp_suning_uos_patched
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>
This commit is contained in:
parent
eaffef0d5f
commit
7453e1dafd
|
@ -160,6 +160,13 @@ static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
|
||||||
entry->c.text.read = read;
|
entry->c.text.read = read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
int snd_info_check_reserved_words(const char *str);
|
int snd_info_check_reserved_words(const char *str);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -189,10 +196,38 @@ 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)),
|
static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
|
||||||
void *private_data,
|
void *private_data,
|
||||||
void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
|
void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
|
||||||
|
static inline 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))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
static inline int snd_info_check_reserved_words(const char *str) { return 1; }
|
static inline int snd_info_check_reserved_words(const char *str) { return 1; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* snd_card_ro_proc_new - Create a read-only 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
|
||||||
|
*
|
||||||
|
* This proc file entry will be registered via snd_card_register() call, and
|
||||||
|
* it will be removed automatically at the card removal, too.
|
||||||
|
*/
|
||||||
|
static inline int
|
||||||
|
snd_card_ro_proc_new(struct snd_card *card, const char *name,
|
||||||
|
void *private_data,
|
||||||
|
void (*read)(struct snd_info_entry *,
|
||||||
|
struct snd_info_buffer *))
|
||||||
|
{
|
||||||
|
return snd_card_rw_proc_new(card, name, private_data, read, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OSS info part
|
* OSS info part
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -866,6 +866,38 @@ int snd_info_register(struct snd_info_entry *entry)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(snd_info_register);
|
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);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user