Merge tag 'v3.10.107' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / core / seq / seq_fifo.c
index 0d75afa786bc6ffebe8ffd8dc5bde065397c00a8..490b697e83ff59ba0bb67bb8291cced5cdf8302b 100644 (file)
@@ -72,6 +72,9 @@ void snd_seq_fifo_delete(struct snd_seq_fifo **fifo)
                return;
        *fifo = NULL;
 
+       if (f->pool)
+               snd_seq_pool_mark_closing(f->pool);
+
        snd_seq_fifo_clear(f);
 
        /* wake up clients if any */
@@ -137,6 +140,7 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
        f->tail = cell;
        if (f->head == NULL)
                f->head = cell;
+       cell->next = NULL;
        f->cells++;
        spin_unlock_irqrestore(&f->lock, flags);
 
@@ -216,6 +220,8 @@ void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f,
                spin_lock_irqsave(&f->lock, flags);
                cell->next = f->head;
                f->head = cell;
+               if (!f->tail)
+                       f->tail = cell;
                f->cells++;
                spin_unlock_irqrestore(&f->lock, flags);
        }
@@ -261,6 +267,10 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
        /* NOTE: overflow flag is not cleared */
        spin_unlock_irqrestore(&f->lock, flags);
 
+       /* close the old pool and wait until all users are gone */
+       snd_seq_pool_mark_closing(oldpool);
+       snd_use_lock_sync(&f->use_lock);
+
        /* release cells in old pool */
        for (cell = oldhead; cell; cell = next) {
                next = cell->next;