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 / drivers / opl4 / opl4_proc.c
index 2b346d6..e552ec3 100644 (file)
 
 #ifdef CONFIG_PROC_FS
 
-static int snd_opl4_mem_proc_open(snd_info_entry_t *entry,
+static int snd_opl4_mem_proc_open(struct snd_info_entry *entry,
                                  unsigned short mode, void **file_private_data)
 {
-       opl4_t *opl4 = snd_magic_cast(opl4_t, entry->private_data, return -ENXIO);
+       struct snd_opl4 *opl4 = entry->private_data;
 
-       down(&opl4->access_mutex);
+       mutex_lock(&opl4->access_mutex);
        if (opl4->memory_access) {
-               up(&opl4->access_mutex);
+               mutex_unlock(&opl4->access_mutex);
                return -EBUSY;
        }
        opl4->memory_access++;
-       up(&opl4->access_mutex);
+       mutex_unlock(&opl4->access_mutex);
        return 0;
 }
 
-static int snd_opl4_mem_proc_release(snd_info_entry_t *entry,
+static int snd_opl4_mem_proc_release(struct snd_info_entry *entry,
                                     unsigned short mode, void *file_private_data)
 {
-       opl4_t *opl4 = snd_magic_cast(opl4_t, entry->private_data, return -ENXIO);
+       struct snd_opl4 *opl4 = entry->private_data;
 
-       down(&opl4->access_mutex);
+       mutex_lock(&opl4->access_mutex);
        opl4->memory_access--;
-       up(&opl4->access_mutex);
+       mutex_unlock(&opl4->access_mutex);
        return 0;
 }
 
-static long snd_opl4_mem_proc_read(snd_info_entry_t *entry, void *file_private_data,
-                                  struct file *file, char *_buf, long count)
+static long snd_opl4_mem_proc_read(struct snd_info_entry *entry, void *file_private_data,
+                                  struct file *file, char __user *_buf,
+                                  unsigned long count, unsigned long pos)
 {
-       opl4_t *opl4 = snd_magic_cast(opl4_t, entry->private_data, return -ENXIO);
+       struct snd_opl4 *opl4 = entry->private_data;
        long size;
        char* buf;
 
        size = count;
-       if (file->f_pos + size > entry->size)
-               size = entry->size - file->f_pos;
+       if (pos + size > entry->size)
+               size = entry->size - pos;
        if (size > 0) {
                buf = vmalloc(size);
                if (!buf)
                        return -ENOMEM;
-               snd_opl4_read_memory(opl4, buf, file->f_pos, size);
+               snd_opl4_read_memory(opl4, buf, pos, size);
                if (copy_to_user(_buf, buf, size)) {
                        vfree(buf);
                        return -EFAULT;
                }
                vfree(buf);
-               file->f_pos += size;
                return size;
        }
        return 0;
 }
 
-static long snd_opl4_mem_proc_write(snd_info_entry_t *entry, void *file_private_data,
-                                   struct file *file, const char *_buf, long count)
+static long snd_opl4_mem_proc_write(struct snd_info_entry *entry, void *file_private_data,
+                                   struct file *file, const char __user *_buf,
+                                   unsigned long count, unsigned long pos)
 {
-       opl4_t *opl4 = snd_magic_cast(opl4_t, entry->private_data, return -ENXIO);
+       struct snd_opl4 *opl4 = entry->private_data;
        long size;
        char *buf;
 
        size = count;
-       if (file->f_pos + size > entry->size)
-               size = entry->size - file->f_pos;
+       if (pos + size > entry->size)
+               size = entry->size - pos;
        if (size > 0) {
                buf = vmalloc(size);
                if (!buf)
@@ -93,15 +94,14 @@ static long snd_opl4_mem_proc_write(snd_info_entry_t *entry, void *file_private_
                        vfree(buf);
                        return -EFAULT;
                }
-               snd_opl4_write_memory(opl4, buf, file->f_pos, size);
+               snd_opl4_write_memory(opl4, buf, pos, size);
                vfree(buf);
-               file->f_pos += size;
                return size;
        }
        return 0;
 }
 
-static long long snd_opl4_mem_proc_llseek(snd_info_entry_t *entry, void *file_private_data,
+static long long snd_opl4_mem_proc_llseek(struct snd_info_entry *entry, void *file_private_data,
                                          struct file *file, long long offset, int orig)
 {
        switch (orig) {
@@ -130,9 +130,9 @@ static struct snd_info_entry_ops snd_opl4_mem_proc_ops = {
        .llseek = snd_opl4_mem_proc_llseek,
 };
 
-int snd_opl4_create_proc(opl4_t *opl4)
+int snd_opl4_create_proc(struct snd_opl4 *opl4)
 {
-       snd_info_entry_t *entry;
+       struct snd_info_entry *entry;
 
        entry = snd_info_create_card_entry(opl4->card, "opl4-mem", opl4->card->proc_root);
        if (entry) {
@@ -157,7 +157,7 @@ int snd_opl4_create_proc(opl4_t *opl4)
        return 0;
 }
 
-void snd_opl4_free_proc(opl4_t *opl4)
+void snd_opl4_free_proc(struct snd_opl4 *opl4)
 {
        if (opl4->proc_entry)
                snd_info_unregister(opl4->proc_entry);