ALSA: OSS sequencer should be initialized after snd_seq_system_client_init
[safe/jmp/linux-2.6] / sound / core / memalloc.c
index 4a64997..1b3534d 100644 (file)
@@ -33,9 +33,6 @@
 #include <linux/moduleparam.h>
 #include <linux/mutex.h>
 #include <sound/memalloc.h>
-#ifdef CONFIG_SBUS
-#include <asm/sbus.h>
-#endif
 
 
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>");
@@ -46,14 +43,6 @@ MODULE_LICENSE("GPL");
 /*
  */
 
-void *snd_malloc_sgbuf_pages(struct device *device,
-                             size_t size, struct snd_dma_buffer *dmab,
-                            size_t *res_size);
-int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab);
-
-/*
- */
-
 static DEFINE_MUTEX(list_mutex);
 static LIST_HEAD(mem_list_head);
 
@@ -170,39 +159,6 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr,
 }
 #endif /* CONFIG_HAS_DMA */
 
-#ifdef CONFIG_SBUS
-
-static void *snd_malloc_sbus_pages(struct device *dev, size_t size,
-                                  dma_addr_t *dma_addr)
-{
-       struct sbus_dev *sdev = (struct sbus_dev *)dev;
-       int pg;
-       void *res;
-
-       if (WARN_ON(!dma_addr))
-               return NULL;
-       pg = get_order(size);
-       res = sbus_alloc_consistent(sdev, PAGE_SIZE * (1 << pg), dma_addr);
-       if (res != NULL)
-               inc_snd_pages(pg);
-       return res;
-}
-
-static void snd_free_sbus_pages(struct device *dev, size_t size,
-                               void *ptr, dma_addr_t dma_addr)
-{
-       struct sbus_dev *sdev = (struct sbus_dev *)dev;
-       int pg;
-
-       if (ptr == NULL)
-               return;
-       pg = get_order(size);
-       dec_snd_pages(pg);
-       sbus_free_consistent(sdev, PAGE_SIZE * (1 << pg), ptr, dma_addr);
-}
-
-#endif /* CONFIG_SBUS */
-
 /*
  *
  *  ALSA generic memory management
@@ -239,11 +195,6 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
                dmab->area = snd_malloc_pages(size, (unsigned long)device);
                dmab->addr = 0;
                break;
-#ifdef CONFIG_SBUS
-       case SNDRV_DMA_TYPE_SBUS:
-               dmab->area = snd_malloc_sbus_pages(device, size, &dmab->addr);
-               break;
-#endif
 #ifdef CONFIG_HAS_DMA
        case SNDRV_DMA_TYPE_DEV:
                dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr);
@@ -285,11 +236,16 @@ int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size,
        int err;
 
        while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) {
+               size_t aligned_size;
                if (err != -ENOMEM)
                        return err;
-               size >>= 1;
                if (size <= PAGE_SIZE)
                        return -ENOMEM;
+               aligned_size = PAGE_SIZE << get_order(size);
+               if (size != aligned_size)
+                       size = aligned_size;
+               else
+                       size >>= 1;
        }
        if (! dmab->area)
                return -ENOMEM;
@@ -309,11 +265,6 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
        case SNDRV_DMA_TYPE_CONTINUOUS:
                snd_free_pages(dmab->area, dmab->bytes);
                break;
-#ifdef CONFIG_SBUS
-       case SNDRV_DMA_TYPE_SBUS:
-               snd_free_sbus_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
-               break;
-#endif
 #ifdef CONFIG_HAS_DMA
        case SNDRV_DMA_TYPE_DEV:
                snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
@@ -422,7 +373,7 @@ static int snd_mem_proc_read(struct seq_file *seq, void *offset)
        long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
        struct snd_mem_list *mem;
        int devno;
-       static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
+       static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG" };
 
        mutex_lock(&list_mutex);
        seq_printf(seq, "pages  : %li bytes (%li pages per %likB)\n",