Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / sound / core / seq / oss / seq_oss_readq.c
index dfe6a5c..f5de79f 100644 (file)
@@ -24,6 +24,7 @@
 #include "seq_oss_event.h"
 #include <sound/seq_oss_legacy.h>
 #include "../seq_lock.h"
+#include <linux/wait.h>
 
 /*
  * constants
 /*
  * create a read queue
  */
-seq_oss_readq_t *
-snd_seq_oss_readq_new(seq_oss_devinfo_t *dp, int maxlen)
+struct seq_oss_readq *
+snd_seq_oss_readq_new(struct seq_oss_devinfo *dp, int maxlen)
 {
-       seq_oss_readq_t *q;
+       struct seq_oss_readq *q;
 
-       if ((q = kcalloc(1, sizeof(*q), GFP_KERNEL)) == NULL) {
+       if ((q = kzalloc(sizeof(*q), GFP_KERNEL)) == NULL) {
                snd_printk(KERN_ERR "can't malloc read queue\n");
                return NULL;
        }
 
-       if ((q->q = kcalloc(maxlen, sizeof(evrec_t), GFP_KERNEL)) == NULL) {
+       if ((q->q = kcalloc(maxlen, sizeof(union evrec), GFP_KERNEL)) == NULL) {
                snd_printk(KERN_ERR "can't malloc read queue buffer\n");
                kfree(q);
                return NULL;
@@ -71,11 +72,10 @@ snd_seq_oss_readq_new(seq_oss_devinfo_t *dp, int maxlen)
  * delete the read queue
  */
 void
-snd_seq_oss_readq_delete(seq_oss_readq_t *q)
+snd_seq_oss_readq_delete(struct seq_oss_readq *q)
 {
        if (q) {
-               if (q->q)
-                       kfree(q->q);
+               kfree(q->q);
                kfree(q);
        }
 }
@@ -84,7 +84,7 @@ snd_seq_oss_readq_delete(seq_oss_readq_t *q)
  * reset the read queue
  */
 void
-snd_seq_oss_readq_clear(seq_oss_readq_t *q)
+snd_seq_oss_readq_clear(struct seq_oss_readq *q)
 {
        if (q->qlen) {
                q->qlen = 0;
@@ -100,9 +100,9 @@ snd_seq_oss_readq_clear(seq_oss_readq_t *q)
  * put a midi byte
  */
 int
-snd_seq_oss_readq_puts(seq_oss_readq_t *q, int dev, unsigned char *data, int len)
+snd_seq_oss_readq_puts(struct seq_oss_readq *q, int dev, unsigned char *data, int len)
 {
-       evrec_t rec;
+       union evrec rec;
        int result;
 
        memset(&rec, 0, sizeof(rec));
@@ -123,7 +123,7 @@ snd_seq_oss_readq_puts(seq_oss_readq_t *q, int dev, unsigned char *data, int len
  * return zero if enqueued
  */
 int
-snd_seq_oss_readq_put_event(seq_oss_readq_t *q, evrec_t *ev)
+snd_seq_oss_readq_put_event(struct seq_oss_readq *q, union evrec *ev)
 {
        unsigned long flags;
 
@@ -152,7 +152,7 @@ snd_seq_oss_readq_put_event(seq_oss_readq_t *q, evrec_t *ev)
  * caller must hold lock
  */
 int
-snd_seq_oss_readq_pick(seq_oss_readq_t *q, evrec_t *rec)
+snd_seq_oss_readq_pick(struct seq_oss_readq *q, union evrec *rec)
 {
        if (q->qlen == 0)
                return -EAGAIN;
@@ -164,9 +164,11 @@ snd_seq_oss_readq_pick(seq_oss_readq_t *q, evrec_t *rec)
  * sleep until ready
  */
 void
-snd_seq_oss_readq_wait(seq_oss_readq_t *q)
+snd_seq_oss_readq_wait(struct seq_oss_readq *q)
 {
-       interruptible_sleep_on_timeout(&q->midi_sleep, q->pre_event_timeout);
+       wait_event_interruptible_timeout(q->midi_sleep,
+                                        (q->qlen > 0 || q->head == q->tail),
+                                        q->pre_event_timeout);
 }
 
 /*
@@ -174,7 +176,7 @@ snd_seq_oss_readq_wait(seq_oss_readq_t *q)
  * caller must hold lock
  */
 void
-snd_seq_oss_readq_free(seq_oss_readq_t *q)
+snd_seq_oss_readq_free(struct seq_oss_readq *q)
 {
        if (q->qlen > 0) {
                q->head = (q->head + 1) % q->maxlen;
@@ -187,7 +189,7 @@ snd_seq_oss_readq_free(seq_oss_readq_t *q)
  * return non-zero if readq is not empty.
  */
 unsigned int
-snd_seq_oss_readq_poll(seq_oss_readq_t *q, struct file *file, poll_table *wait)
+snd_seq_oss_readq_poll(struct seq_oss_readq *q, struct file *file, poll_table *wait)
 {
        poll_wait(file, &q->midi_sleep, wait);
        return q->qlen;
@@ -197,10 +199,10 @@ snd_seq_oss_readq_poll(seq_oss_readq_t *q, struct file *file, poll_table *wait)
  * put a timestamp
  */
 int
-snd_seq_oss_readq_put_timestamp(seq_oss_readq_t *q, unsigned long curt, int seq_mode)
+snd_seq_oss_readq_put_timestamp(struct seq_oss_readq *q, unsigned long curt, int seq_mode)
 {
        if (curt != q->input_time) {
-               evrec_t rec;
+               union evrec rec;
                memset(&rec, 0, sizeof(rec));
                switch (seq_mode) {
                case SNDRV_SEQ_OSS_MODE_SYNTH:
@@ -220,13 +222,15 @@ snd_seq_oss_readq_put_timestamp(seq_oss_readq_t *q, unsigned long curt, int seq_
 }
 
 
+#ifdef CONFIG_PROC_FS
 /*
  * proc interface
  */
 void
-snd_seq_oss_readq_info_read(seq_oss_readq_t *q, snd_info_buffer_t *buf)
+snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf)
 {
        snd_iprintf(buf, "  read queue [%s] length = %d : tick = %ld\n",
                    (waitqueue_active(&q->midi_sleep) ? "sleeping":"running"),
                    q->qlen, q->input_time);
 }
+#endif /* CONFIG_PROC_FS */