Commit e28563cc authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela
Browse files

[ALSA] Optimize for config without PROC_FS



Modules: HWDEP Midlevel,ALSA Core,PCM Midlevel,Timer Midlevel

Optimize the code when compiled without CONFIG_PROC_FS.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7cd01dd8
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -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);
@@ -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

@@ -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

+23 −10
Original line number Diff line number Diff line
@@ -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
 */
@@ -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;

@@ -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;
@@ -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)
+6 −7
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@
 *
 */

#ifdef CONFIG_PROC_FS

int snd_info_check_reserved_words(const char *str)
{
	static char *reserved[] =
@@ -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 {
@@ -580,11 +580,9 @@ 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);
#endif
#ifdef CONFIG_SND_OSSEMUL
		if (snd_oss_root)
		snd_info_unregister(snd_oss_root);
#endif
		snd_remove_proc_entry(&proc_root, snd_proc_root);
@@ -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);
+35 −24
Original line number Diff line number Diff line
@@ -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);

/**
@@ -273,7 +300,6 @@ 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);
	if (snd_info_card_free(card) < 0) {
		snd_printk(KERN_WARNING "unable to free card info\n");
@@ -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)
@@ -429,22 +454,7 @@ 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);
@@ -452,6 +462,7 @@ int snd_card_register(struct snd_card *card)
	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,
@@ -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)
{
@@ -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);
#ifdef MODULE
	if (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
+62 −42
Original line number Diff line number Diff line
@@ -151,30 +151,6 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
#define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v
#define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v 

static char *snd_pcm_stream_names[] = {
	STREAM(PLAYBACK),
	STREAM(CAPTURE),
};

static char *snd_pcm_state_names[] = {
	STATE(OPEN),
	STATE(SETUP),
	STATE(PREPARED),
	STATE(RUNNING),
	STATE(XRUN),
	STATE(DRAINING),
	STATE(PAUSED),
	STATE(SUSPENDED),
};

static char *snd_pcm_access_names[] = {
	ACCESS(MMAP_INTERLEAVED), 
	ACCESS(MMAP_NONINTERLEAVED),
	ACCESS(MMAP_COMPLEX),
	ACCESS(RW_INTERLEAVED),
	ACCESS(RW_NONINTERLEAVED),
};

static char *snd_pcm_format_names[] = {
	FORMAT(S8),
	FORMAT(U8),
@@ -216,6 +192,36 @@ static char *snd_pcm_format_names[] = {
	FORMAT(U18_3BE),
};

const char *snd_pcm_format_name(snd_pcm_format_t format)
{
	return snd_pcm_format_names[format];
}

#ifdef CONFIG_PROC_FS
static char *snd_pcm_stream_names[] = {
	STREAM(PLAYBACK),
	STREAM(CAPTURE),
};

static char *snd_pcm_state_names[] = {
	STATE(OPEN),
	STATE(SETUP),
	STATE(PREPARED),
	STATE(RUNNING),
	STATE(XRUN),
	STATE(DRAINING),
	STATE(PAUSED),
	STATE(SUSPENDED),
};

static char *snd_pcm_access_names[] = {
	ACCESS(MMAP_INTERLEAVED), 
	ACCESS(MMAP_NONINTERLEAVED),
	ACCESS(MMAP_COMPLEX),
	ACCESS(RW_INTERLEAVED),
	ACCESS(RW_NONINTERLEAVED),
};

static char *snd_pcm_subformat_names[] = {
	SUBFORMAT(STD), 
};
@@ -236,11 +242,6 @@ static const char *snd_pcm_access_name(snd_pcm_access_t access)
	return snd_pcm_access_names[access];
}

const char *snd_pcm_format_name(snd_pcm_format_t format)
{
	return snd_pcm_format_names[format];
}

static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
{
	return snd_pcm_subformat_names[subformat];
@@ -288,7 +289,6 @@ static const char *snd_pcm_oss_format_name(int format)
}
#endif

#ifdef CONFIG_PROC_FS
static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream,
				   struct snd_info_buffer *buffer)
{
@@ -431,7 +431,6 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
	snd_iprintf(buffer, "hw_ptr      : %ld\n", runtime->status->hw_ptr);
	snd_iprintf(buffer, "appl_ptr    : %ld\n", runtime->control->appl_ptr);
}
#endif

#ifdef CONFIG_SND_DEBUG
static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry,
@@ -596,6 +595,12 @@ static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream)
	}
	return 0;
}
#else /* !CONFIG_PROC_FS */
static inline int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { return 0; }
static inline int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { return 0; }
static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { return 0; }
static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { return 0; }
#endif /* CONFIG_PROC_FS */

/**
 * snd_pcm_new_stream - create a new PCM stream
@@ -1013,6 +1018,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
	return 0;
}

#ifdef CONFIG_PROC_FS
/*
 *  Info interface
 */
@@ -1039,18 +1045,12 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry,
	up(&register_mutex);
}

/*
 *  ENTRY functions
 */

static struct snd_info_entry *snd_pcm_proc_entry = NULL;

static int __init alsa_pcm_init(void)
static void snd_pcm_proc_init(void)
{
	struct snd_info_entry *entry;

	snd_ctl_register_ioctl(snd_pcm_control_ioctl);
	snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl);
	if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) {
		snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128,
				      snd_pcm_proc_read);
@@ -1060,6 +1060,29 @@ static int __init alsa_pcm_init(void)
		}
	}
	snd_pcm_proc_entry = entry;
}

static void snd_pcm_proc_done(void)
{
	if (snd_pcm_proc_entry)
		snd_info_unregister(snd_pcm_proc_entry);
}

#else /* !CONFIG_PROC_FS */
#define snd_pcm_proc_init()
#define snd_pcm_proc_done()
#endif /* CONFIG_PROC_FS */


/*
 *  ENTRY functions
 */

static int __init alsa_pcm_init(void)
{
	snd_ctl_register_ioctl(snd_pcm_control_ioctl);
	snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl);
	snd_pcm_proc_init();
	return 0;
}

@@ -1067,10 +1090,7 @@ static void __exit alsa_pcm_exit(void)
{
	snd_ctl_unregister_ioctl(snd_pcm_control_ioctl);
	snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl);
	if (snd_pcm_proc_entry) {
		snd_info_unregister(snd_pcm_proc_entry);
		snd_pcm_proc_entry = NULL;
	}
	snd_pcm_proc_done();
}

module_init(alsa_pcm_init)
Loading