[ALSA] Remove spinlocks around proc prints
[pandora-kernel.git] / sound / core / pcm.c
index 3da6a38..4f52041 100644 (file)
@@ -142,7 +142,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
        return -ENOIOCTLCMD;
 }
 
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_SND_VERBOSE_PROCFS)
+#ifdef CONFIG_SND_VERBOSE_PROCFS
 
 #define STATE(v) [SNDRV_PCM_STATE_##v] = #v
 #define STREAM(v) [SNDRV_PCM_STREAM_##v] = #v
@@ -196,7 +196,7 @@ static char *snd_pcm_format_names[] = {
        FORMAT(U18_3BE),
 };
 
-const char *snd_pcm_format_name(snd_pcm_format_t format)
+static const char *snd_pcm_format_name(snd_pcm_format_t format)
 {
        return snd_pcm_format_names[format];
 }
@@ -351,10 +351,8 @@ static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry,
                snd_iprintf(buffer, "closed\n");
                return;
        }
-       snd_pcm_stream_lock_irq(substream);
        if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
                snd_iprintf(buffer, "no setup\n");
-               snd_pcm_stream_unlock_irq(substream);
                return;
        }
        snd_iprintf(buffer, "access: %s\n", snd_pcm_access_name(runtime->access));
@@ -375,7 +373,6 @@ static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry,
                snd_iprintf(buffer, "OSS period frames: %lu\n", (unsigned long)runtime->oss.period_frames);
        }
 #endif
-       snd_pcm_stream_unlock_irq(substream);
 }
 
 static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry,
@@ -387,10 +384,8 @@ static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry,
                snd_iprintf(buffer, "closed\n");
                return;
        }
-       snd_pcm_stream_lock_irq(substream);
        if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
                snd_iprintf(buffer, "no setup\n");
-               snd_pcm_stream_unlock_irq(substream);
                return;
        }
        snd_iprintf(buffer, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(runtime->tstamp_mode));
@@ -403,7 +398,6 @@ static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry,
        snd_iprintf(buffer, "silence_threshold: %lu\n", runtime->silence_threshold);
        snd_iprintf(buffer, "silence_size: %lu\n", runtime->silence_size);
        snd_iprintf(buffer, "boundary: %lu\n", runtime->boundary);
-       snd_pcm_stream_unlock_irq(substream);
 }
 
 static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
@@ -436,7 +430,7 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
        snd_iprintf(buffer, "appl_ptr    : %ld\n", runtime->control->appl_ptr);
 }
 
-#ifdef CONFIG_SND_DEBUG
+#ifdef CONFIG_SND_PCM_XRUN_DEBUG
 static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry,
                                    struct snd_info_buffer *buffer)
 {
@@ -472,7 +466,7 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
        pstr->proc_root = entry;
 
        if ((entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root)) != NULL) {
-               snd_info_set_text_ops(entry, pstr, 256, snd_pcm_stream_proc_info_read);
+               snd_info_set_text_ops(entry, pstr, snd_pcm_stream_proc_info_read);
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
                        entry = NULL;
@@ -480,12 +474,10 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
        }
        pstr->proc_info_entry = entry;
 
-#ifdef CONFIG_SND_DEBUG
+#ifdef CONFIG_SND_PCM_XRUN_DEBUG
        if ((entry = snd_info_create_card_entry(pcm->card, "xrun_debug",
                                                pstr->proc_root)) != NULL) {
-               entry->c.text.read_size = 64;
                entry->c.text.read = snd_pcm_xrun_debug_read;
-               entry->c.text.write_size = 64;
                entry->c.text.write = snd_pcm_xrun_debug_write;
                entry->mode |= S_IWUSR;
                entry->private_data = pstr;
@@ -501,7 +493,7 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
 
 static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr)
 {
-#ifdef CONFIG_SND_DEBUG
+#ifdef CONFIG_SND_PCM_XRUN_DEBUG
        if (pstr->proc_xrun_debug_entry) {
                snd_info_unregister(pstr->proc_xrun_debug_entry);
                pstr->proc_xrun_debug_entry = NULL;
@@ -537,7 +529,8 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
        substream->proc_root = entry;
 
        if ((entry = snd_info_create_card_entry(card, "info", substream->proc_root)) != NULL) {
-               snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_info_read);
+               snd_info_set_text_ops(entry, substream,
+                                     snd_pcm_substream_proc_info_read);
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
                        entry = NULL;
@@ -546,7 +539,8 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
        substream->proc_info_entry = entry;
 
        if ((entry = snd_info_create_card_entry(card, "hw_params", substream->proc_root)) != NULL) {
-               snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_hw_params_read);
+               snd_info_set_text_ops(entry, substream,
+                                     snd_pcm_substream_proc_hw_params_read);
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
                        entry = NULL;
@@ -555,7 +549,8 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
        substream->proc_hw_params_entry = entry;
 
        if ((entry = snd_info_create_card_entry(card, "sw_params", substream->proc_root)) != NULL) {
-               snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_sw_params_read);
+               snd_info_set_text_ops(entry, substream,
+                                     snd_pcm_substream_proc_sw_params_read);
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
                        entry = NULL;
@@ -564,7 +559,8 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
        substream->proc_sw_params_entry = entry;
 
        if ((entry = snd_info_create_card_entry(card, "status", substream->proc_root)) != NULL) {
-               snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_status_read);
+               snd_info_set_text_ops(entry, substream,
+                                     snd_pcm_substream_proc_status_read);
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
                        entry = NULL;
@@ -599,12 +595,12 @@ static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream)
        }
        return 0;
 }
-#else /* !CONFIG_PROC_FS */
+#else /* !CONFIG_SND_VERBOSE_PROCFS */
 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 */
+#endif /* CONFIG_SND_VERBOSE_PROCFS */
 
 /**
  * snd_pcm_new_stream - create a new PCM stream
@@ -671,6 +667,8 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
        return 0;
 }                              
 
+EXPORT_SYMBOL(snd_pcm_new_stream);
+
 /**
  * snd_pcm_new - create a new PCM instance
  * @card: the card instance
@@ -730,6 +728,8 @@ int snd_pcm_new(struct snd_card *card, char *id, int device,
        return 0;
 }
 
+EXPORT_SYMBOL(snd_pcm_new);
+
 static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
 {
        struct snd_pcm_substream *substream, *substream_next;
@@ -777,8 +777,9 @@ static void snd_pcm_tick_timer_func(unsigned long data)
        snd_pcm_tick_elapsed(substream);
 }
 
-int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
-                          struct snd_pcm_substream **rsubstream)
+int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
+                            struct file *file,
+                            struct snd_pcm_substream **rsubstream)
 {
        struct snd_pcm_str * pstr;
        struct snd_pcm_substream *substream;
@@ -793,7 +794,7 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
        *rsubstream = NULL;
        snd_assert(pcm != NULL, return -ENXIO);
        pstr = &pcm->streams[stream];
-       if (pstr->substream == NULL)
+       if (pstr->substream == NULL || pstr->substream_count == 0)
                return -ENODEV;
 
        card = pcm->card;
@@ -807,8 +808,6 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
        }
        up_read(&card->controls_rwsem);
 
-       if (pstr->substream_count == 0)
-               return -ENODEV;
        switch (stream) {
        case SNDRV_PCM_STREAM_PLAYBACK:
                if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) {
@@ -874,12 +873,13 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
 
        substream->runtime = runtime;
        substream->private_data = pcm->private_data;
+       substream->ffile = file;
        pstr->substream_opened++;
        *rsubstream = substream;
        return 0;
 }
 
-void snd_pcm_release_substream(struct snd_pcm_substream *substream)
+void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime;
        substream->file = NULL;
@@ -1022,6 +1022,8 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
        return 0;
 }
 
+EXPORT_SYMBOL(snd_pcm_notify);
+
 #ifdef CONFIG_PROC_FS
 /*
  *  Info interface
@@ -1056,8 +1058,7 @@ static void snd_pcm_proc_init(void)
        struct snd_info_entry *entry;
 
        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);
+               snd_info_set_text_ops(entry, NULL, snd_pcm_proc_read);
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);
                        entry = NULL;
@@ -1099,35 +1100,3 @@ static void __exit alsa_pcm_exit(void)
 
 module_init(alsa_pcm_init)
 module_exit(alsa_pcm_exit)
-
-EXPORT_SYMBOL(snd_pcm_new);
-EXPORT_SYMBOL(snd_pcm_new_stream);
-EXPORT_SYMBOL(snd_pcm_notify);
-EXPORT_SYMBOL(snd_pcm_open_substream);
-EXPORT_SYMBOL(snd_pcm_release_substream);
-  /* pcm_native.c */
-EXPORT_SYMBOL(snd_pcm_link_rwlock);
-#ifdef CONFIG_PM
-EXPORT_SYMBOL(snd_pcm_suspend);
-EXPORT_SYMBOL(snd_pcm_suspend_all);
-#endif
-EXPORT_SYMBOL(snd_pcm_kernel_playback_ioctl);
-EXPORT_SYMBOL(snd_pcm_kernel_capture_ioctl);
-EXPORT_SYMBOL(snd_pcm_kernel_ioctl);
-EXPORT_SYMBOL(snd_pcm_mmap_data);
-#if SNDRV_PCM_INFO_MMAP_IOMEM
-EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem);
-#endif
- /* pcm_misc.c */
-EXPORT_SYMBOL(snd_pcm_format_signed);
-EXPORT_SYMBOL(snd_pcm_format_unsigned);
-EXPORT_SYMBOL(snd_pcm_format_linear);
-EXPORT_SYMBOL(snd_pcm_format_little_endian);
-EXPORT_SYMBOL(snd_pcm_format_big_endian);
-EXPORT_SYMBOL(snd_pcm_format_width);
-EXPORT_SYMBOL(snd_pcm_format_physical_width);
-EXPORT_SYMBOL(snd_pcm_format_size);
-EXPORT_SYMBOL(snd_pcm_format_silence_64);
-EXPORT_SYMBOL(snd_pcm_format_set_silence);
-EXPORT_SYMBOL(snd_pcm_build_linear_format);
-EXPORT_SYMBOL(snd_pcm_limit_hw_rates);