Skip to content

Commit

Permalink
[ALSA] Optimize for config without PROC_FS
Browse files Browse the repository at this point in the history
Modules: HWDEP Midlevel,ALSA Core,PCM Midlevel,Timer Midlevel

Optimize the code when compiled without CONFIG_PROC_FS.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai authored and Jaroslav Kysela committed Jan 3, 2006
1 parent 7cd01dd commit e28563c
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 124 deletions.
13 changes: 9 additions & 4 deletions include/sound/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ struct snd_info_entry {
struct semaphore access;
};

int snd_info_check_reserved_words(const char *str);

#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
int snd_info_minor_register(void);
int snd_info_minor_unregister(void);
Expand Down Expand Up @@ -142,6 +140,7 @@ static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
entry->c.text.read = read;
}

int snd_info_check_reserved_words(const char *str);

#else

Expand All @@ -164,8 +163,14 @@ static inline int snd_info_card_free(struct snd_card * card) { return 0; }
static inline int snd_info_register(struct snd_info_entry * entry) { return 0; }
static inline int snd_info_unregister(struct snd_info_entry * entry) { return 0; }

#define snd_card_proc_new(card,name,entryp) 0 /* always success */
#define snd_info_set_text_ops(entry,private_data,read_size,read) /*NOP*/
static inline int snd_card_proc_new(struct snd_card *card, const char *name,
struct snd_info_entry **entryp) { return -EINVAL; }
static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
void *private_data,
long read_size,
void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}

static inline int snd_info_check_reserved_words(const char *str) { return 1; }

#endif

Expand Down
33 changes: 23 additions & 10 deletions sound/core/hwdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device)
return snd_hwdep_free(hwdep);
}

#ifdef CONFIG_PROC_FS
/*
* Info interface
*/
Expand All @@ -477,13 +478,9 @@ static void snd_hwdep_proc_read(struct snd_info_entry *entry,
up(&register_mutex);
}

/*
* ENTRY functions
*/
static struct snd_info_entry *snd_hwdep_proc_entry;

static struct snd_info_entry *snd_hwdep_proc_entry = NULL;

static int __init alsa_hwdep_init(void)
static void __init snd_hwdep_proc_init(void)
{
struct snd_info_entry *entry;

Expand All @@ -496,6 +493,25 @@ static int __init alsa_hwdep_init(void)
}
}
snd_hwdep_proc_entry = entry;
}

static void __exit snd_hwdep_proc_done(void)
{
snd_info_unregister(snd_hwdep_proc_entry);
}
#else /* !CONFIG_PROC_FS */
#define snd_hwdep_proc_init()
#define snd_hwdep_proc_done()
#endif /* CONFIG_PROC_FS */


/*
* ENTRY functions
*/

static int __init alsa_hwdep_init(void)
{
snd_hwdep_proc_init();
snd_ctl_register_ioctl(snd_hwdep_control_ioctl);
snd_ctl_register_ioctl_compat(snd_hwdep_control_ioctl);
return 0;
Expand All @@ -505,10 +521,7 @@ static void __exit alsa_hwdep_exit(void)
{
snd_ctl_unregister_ioctl(snd_hwdep_control_ioctl);
snd_ctl_unregister_ioctl_compat(snd_hwdep_control_ioctl);
if (snd_hwdep_proc_entry) {
snd_info_unregister(snd_hwdep_proc_entry);
snd_hwdep_proc_entry = NULL;
}
snd_hwdep_proc_done();
}

module_init(alsa_hwdep_init)
Expand Down
13 changes: 6 additions & 7 deletions sound/core/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
*
*/

#ifdef CONFIG_PROC_FS

int snd_info_check_reserved_words(const char *str)
{
static char *reserved[] =
Expand Down Expand Up @@ -66,8 +68,6 @@ int snd_info_check_reserved_words(const char *str)
return 1;
}

#ifdef CONFIG_PROC_FS

static DECLARE_MUTEX(info_mutex);

struct snd_info_private_data {
Expand Down Expand Up @@ -580,12 +580,10 @@ int __exit snd_info_done(void)
snd_info_version_done();
if (snd_proc_root) {
#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
if (snd_seq_root)
snd_info_unregister(snd_seq_root);
snd_info_unregister(snd_seq_root);
#endif
#ifdef CONFIG_SND_OSSEMUL
if (snd_oss_root)
snd_info_unregister(snd_oss_root);
snd_info_unregister(snd_oss_root);
#endif
snd_remove_proc_entry(&proc_root, snd_proc_root);
}
Expand Down Expand Up @@ -937,7 +935,8 @@ int snd_info_unregister(struct snd_info_entry * entry)
{
struct proc_dir_entry *root;

snd_assert(entry != NULL, return -ENXIO);
if (! entry)
return 0;
snd_assert(entry->p != NULL, return -ENXIO);
root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
snd_assert(root, return -ENXIO);
Expand Down
59 changes: 35 additions & 24 deletions sound/core/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,39 @@ DEFINE_RWLOCK(snd_card_rwlock);
int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
#endif

#ifdef CONFIG_PROC_FS
static void snd_card_id_read(struct snd_info_entry *entry,
struct snd_info_buffer *buffer)
{
snd_iprintf(buffer, "%s\n", entry->card->id);
}

static inline int init_info_for_card(struct snd_card *card)
{
int err;
struct snd_info_entry *entry;

if ((err = snd_info_card_register(card)) < 0) {
snd_printd("unable to create card info\n");
return err;
}
if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) {
snd_printd("unable to create card entry\n");
return err;
}
entry->c.text.read_size = PAGE_SIZE;
entry->c.text.read = snd_card_id_read;
if (snd_info_register(entry) < 0) {
snd_info_free_entry(entry);
entry = NULL;
}
card->proc_id = entry;
return 0;
}
#else /* !CONFIG_PROC_FS */
#define init_info_for_card(card)
#endif

static void snd_card_free_thread(void * __card);

/**
Expand Down Expand Up @@ -273,8 +300,7 @@ int snd_card_free(struct snd_card *card)
}
if (card->private_free)
card->private_free(card);
if (card->proc_id)
snd_info_unregister(card->proc_id);
snd_info_unregister(card->proc_id);
if (snd_info_card_free(card) < 0) {
snd_printk(KERN_WARNING "unable to free card info\n");
/* Not fatal error */
Expand Down Expand Up @@ -414,7 +440,6 @@ static void choose_default_id(struct snd_card *card)
int snd_card_register(struct snd_card *card)
{
int err;
struct snd_info_entry *entry;

snd_assert(card != NULL, return -EINVAL);
if ((err = snd_device_register_all(card)) < 0)
Expand All @@ -429,29 +454,15 @@ int snd_card_register(struct snd_card *card)
choose_default_id(card);
snd_cards[card->number] = card;
write_unlock(&snd_card_rwlock);
if ((err = snd_info_card_register(card)) < 0) {
snd_printd("unable to create card info\n");
goto __skip_info;
}
if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) {
snd_printd("unable to create card entry\n");
goto __skip_info;
}
entry->c.text.read_size = PAGE_SIZE;
entry->c.text.read = snd_card_id_read;
if (snd_info_register(entry) < 0) {
snd_info_free_entry(entry);
entry = NULL;
}
card->proc_id = entry;
__skip_info:
init_info_for_card(card);
#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
if (snd_mixer_oss_notify_callback)
snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER);
#endif
return 0;
}

#ifdef CONFIG_PROC_FS
static struct snd_info_entry *snd_card_info_entry = NULL;

static void snd_card_info_read(struct snd_info_entry *entry,
Expand All @@ -478,7 +489,7 @@ static void snd_card_info_read(struct snd_info_entry *entry,
snd_iprintf(buffer, "--- no soundcards ---\n");
}

#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
#ifdef CONFIG_SND_OSSEMUL

void snd_card_info_read_oss(struct snd_info_buffer *buffer)
{
Expand Down Expand Up @@ -550,15 +561,15 @@ int __init snd_card_info_init(void)

int __exit snd_card_info_done(void)
{
if (snd_card_info_entry)
snd_info_unregister(snd_card_info_entry);
snd_info_unregister(snd_card_info_entry);
#ifdef MODULE
if (snd_card_module_info_entry)
snd_info_unregister(snd_card_module_info_entry);
snd_info_unregister(snd_card_module_info_entry);
#endif
return 0;
}

#endif /* CONFIG_PROC_FS */

/**
* snd_component_add - add a component string
* @card: soundcard structure
Expand Down
Loading

0 comments on commit e28563c

Please sign in to comment.