fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / sound / oss / emu10k1 / audio.c
index 1aac365..efcf589 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/bitops.h>
 #include <asm/io.h>
 #include <linux/sched.h>
+#include <linux/mm.h>
 #include <linux/smp_lock.h>
 
 #include "hwaccess.h"
@@ -49,6 +50,9 @@
 static void calculate_ofrag(struct woinst *);
 static void calculate_ifrag(struct wiinst *);
 
+static void emu10k1_waveout_bh(unsigned long refdata);
+static void emu10k1_wavein_bh(unsigned long refdata);
+
 /* Audio file operations */
 static ssize_t emu10k1_audio_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
 {
@@ -59,9 +63,6 @@ static ssize_t emu10k1_audio_read(struct file *file, char __user *buffer, size_t
 
        DPD(3, "emu10k1_audio_read(), buffer=%p, count=%d\n", buffer, (u32) count);
 
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
-
        if (!access_ok(VERIFY_WRITE, buffer, count))
                return -EFAULT;
 
@@ -110,9 +111,15 @@ static ssize_t emu10k1_audio_read(struct file *file, char __user *buffer, size_t
 
                if ((bytestocopy >= wiinst->buffer.fragment_size)
                    || (bytestocopy >= count)) {
+                       int rc;
+
                        bytestocopy = min_t(u32, bytestocopy, count);
 
-                       emu10k1_wavein_xferdata(wiinst, (u8 __user *)buffer, &bytestocopy);
+                       rc = emu10k1_wavein_xferdata(wiinst,
+                                                    (u8 __user *)buffer,
+                                                    &bytestocopy);
+                       if (rc)
+                               return rc;
 
                        count -= bytestocopy;
                        buffer += bytestocopy;
@@ -146,9 +153,6 @@ static ssize_t emu10k1_audio_write(struct file *file, const char __user *buffer,
 
        DPD(3, "emu10k1_audio_write(), buffer=%p, count=%d\n", buffer, (u32) count);
 
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
-
        if (!access_ok(VERIFY_READ, buffer, count))
                return -EFAULT;
 
@@ -1038,7 +1042,7 @@ static struct page *emu10k1_mm_nopage (struct vm_area_struct * vma, unsigned lon
        return dmapage;
 }
 
-struct vm_operations_struct emu10k1_mm_ops = {
+static struct vm_operations_struct emu10k1_mm_ops = {
        .nopage         = emu10k1_mm_nopage,
 };
 
@@ -1135,7 +1139,7 @@ static int emu10k1_audio_open(struct inode *inode, struct file *file)
 
 match:
 
-       wave_dev = (struct emu10k1_wavedevice *) kmalloc(sizeof(struct emu10k1_wavedevice), GFP_KERNEL);
+       wave_dev = kmalloc(sizeof(struct emu10k1_wavedevice), GFP_KERNEL);
 
        if (wave_dev == NULL) { 
                ERROR();
@@ -1151,7 +1155,7 @@ match:
                /* Recording */
                struct wiinst *wiinst;
 
-               if ((wiinst = (struct wiinst *) kmalloc(sizeof(struct wiinst), GFP_KERNEL)) == NULL) {
+               if ((wiinst = kmalloc(sizeof(struct wiinst), GFP_KERNEL)) == NULL) {
                        ERROR();
                        kfree(wave_dev);
                        return -ENOMEM;
@@ -1197,7 +1201,7 @@ match:
                wiinst->mmapped = 0;
                wiinst->total_recorded = 0;
                wiinst->blocks = 0;
-               wiinst->lock = SPIN_LOCK_UNLOCKED;
+               spin_lock_init(&wiinst->lock);
                tasklet_init(&wiinst->timer.tasklet, emu10k1_wavein_bh, (unsigned long) wave_dev);
                wave_dev->wiinst = wiinst;
                emu10k1_wavein_setformat(wave_dev, &wiinst->format);
@@ -1207,7 +1211,7 @@ match:
                struct woinst *woinst;
                int i;
 
-               if ((woinst = (struct woinst *) kmalloc(sizeof(struct woinst), GFP_KERNEL)) == NULL) {
+               if ((woinst = kmalloc(sizeof(struct woinst), GFP_KERNEL)) == NULL) {
                        ERROR();
                        kfree(wave_dev);
                        return -ENOMEM;
@@ -1241,7 +1245,7 @@ match:
                woinst->total_copied = 0;
                woinst->total_played = 0;
                woinst->blocks = 0;
-               woinst->lock = SPIN_LOCK_UNLOCKED;
+               spin_lock_init(&woinst->lock);
                tasklet_init(&woinst->timer.tasklet, emu10k1_waveout_bh, (unsigned long) wave_dev);
                wave_dev->woinst = woinst;
                emu10k1_waveout_setformat(wave_dev, &woinst->format);
@@ -1249,7 +1253,7 @@ match:
 
        file->private_data = (void *) wave_dev;
 
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 static int emu10k1_audio_release(struct inode *inode, struct file *file)
@@ -1512,7 +1516,7 @@ static void calculate_ifrag(struct wiinst *wiinst)
        return;
 }
 
-void emu10k1_wavein_bh(unsigned long refdata)
+static void emu10k1_wavein_bh(unsigned long refdata)
 {
        struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) refdata;
        struct wiinst *wiinst = wave_dev->wiinst;
@@ -1543,7 +1547,7 @@ void emu10k1_wavein_bh(unsigned long refdata)
        return;
 }
 
-void emu10k1_waveout_bh(unsigned long refdata)
+static void emu10k1_waveout_bh(unsigned long refdata)
 {
        struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) refdata;
        struct woinst *woinst = wave_dev->woinst;