diff options
Diffstat (limited to 'sound/drivers/opl4/opl4_proc.c')
| -rw-r--r-- | sound/drivers/opl4/opl4_proc.c | 83 |
1 files changed, 25 insertions, 58 deletions
diff --git a/sound/drivers/opl4/opl4_proc.c b/sound/drivers/opl4/opl4_proc.c index 1679300b7583..df850b8830a5 100644 --- a/sound/drivers/opl4/opl4_proc.c +++ b/sound/drivers/opl4/opl4_proc.c | |||
| @@ -49,77 +49,45 @@ static int snd_opl4_mem_proc_release(struct snd_info_entry *entry, | |||
| 49 | return 0; | 49 | return 0; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | static long snd_opl4_mem_proc_read(struct snd_info_entry *entry, void *file_private_data, | 52 | static ssize_t snd_opl4_mem_proc_read(struct snd_info_entry *entry, |
| 53 | struct file *file, char __user *_buf, | 53 | void *file_private_data, |
| 54 | unsigned long count, unsigned long pos) | 54 | struct file *file, char __user *_buf, |
| 55 | size_t count, loff_t pos) | ||
| 55 | { | 56 | { |
| 56 | struct snd_opl4 *opl4 = entry->private_data; | 57 | struct snd_opl4 *opl4 = entry->private_data; |
| 57 | long size; | ||
| 58 | char* buf; | 58 | char* buf; |
| 59 | 59 | ||
| 60 | size = count; | 60 | buf = vmalloc(count); |
| 61 | if (pos + size > entry->size) | 61 | if (!buf) |
| 62 | size = entry->size - pos; | 62 | return -ENOMEM; |
| 63 | if (size > 0) { | 63 | snd_opl4_read_memory(opl4, buf, pos, count); |
| 64 | buf = vmalloc(size); | 64 | if (copy_to_user(_buf, buf, count)) { |
| 65 | if (!buf) | ||
| 66 | return -ENOMEM; | ||
| 67 | snd_opl4_read_memory(opl4, buf, pos, size); | ||
| 68 | if (copy_to_user(_buf, buf, size)) { | ||
| 69 | vfree(buf); | ||
| 70 | return -EFAULT; | ||
| 71 | } | ||
| 72 | vfree(buf); | 65 | vfree(buf); |
| 73 | return size; | 66 | return -EFAULT; |
| 74 | } | 67 | } |
| 75 | return 0; | 68 | vfree(buf); |
| 69 | return count; | ||
| 76 | } | 70 | } |
| 77 | 71 | ||
| 78 | static long snd_opl4_mem_proc_write(struct snd_info_entry *entry, void *file_private_data, | 72 | static ssize_t snd_opl4_mem_proc_write(struct snd_info_entry *entry, |
| 79 | struct file *file, const char __user *_buf, | 73 | void *file_private_data, |
| 80 | unsigned long count, unsigned long pos) | 74 | struct file *file, |
| 75 | const char __user *_buf, | ||
| 76 | size_t count, loff_t pos) | ||
| 81 | { | 77 | { |
| 82 | struct snd_opl4 *opl4 = entry->private_data; | 78 | struct snd_opl4 *opl4 = entry->private_data; |
| 83 | long size; | ||
| 84 | char *buf; | 79 | char *buf; |
| 85 | 80 | ||
| 86 | size = count; | 81 | buf = vmalloc(count); |
| 87 | if (pos + size > entry->size) | 82 | if (!buf) |
| 88 | size = entry->size - pos; | 83 | return -ENOMEM; |
| 89 | if (size > 0) { | 84 | if (copy_from_user(buf, _buf, count)) { |
| 90 | buf = vmalloc(size); | ||
| 91 | if (!buf) | ||
| 92 | return -ENOMEM; | ||
| 93 | if (copy_from_user(buf, _buf, size)) { | ||
| 94 | vfree(buf); | ||
| 95 | return -EFAULT; | ||
| 96 | } | ||
| 97 | snd_opl4_write_memory(opl4, buf, pos, size); | ||
| 98 | vfree(buf); | 85 | vfree(buf); |
| 99 | return size; | 86 | return -EFAULT; |
| 100 | } | ||
| 101 | return 0; | ||
| 102 | } | ||
| 103 | |||
| 104 | static long long snd_opl4_mem_proc_llseek(struct snd_info_entry *entry, void *file_private_data, | ||
| 105 | struct file *file, long long offset, int orig) | ||
| 106 | { | ||
| 107 | switch (orig) { | ||
| 108 | case SEEK_SET: | ||
| 109 | file->f_pos = offset; | ||
| 110 | break; | ||
| 111 | case SEEK_CUR: | ||
| 112 | file->f_pos += offset; | ||
| 113 | break; | ||
| 114 | case SEEK_END: /* offset is negative */ | ||
| 115 | file->f_pos = entry->size + offset; | ||
| 116 | break; | ||
| 117 | default: | ||
| 118 | return -EINVAL; | ||
| 119 | } | 87 | } |
| 120 | if (file->f_pos > entry->size) | 88 | snd_opl4_write_memory(opl4, buf, pos, count); |
| 121 | file->f_pos = entry->size; | 89 | vfree(buf); |
| 122 | return file->f_pos; | 90 | return count; |
| 123 | } | 91 | } |
| 124 | 92 | ||
| 125 | static struct snd_info_entry_ops snd_opl4_mem_proc_ops = { | 93 | static struct snd_info_entry_ops snd_opl4_mem_proc_ops = { |
| @@ -127,7 +95,6 @@ static struct snd_info_entry_ops snd_opl4_mem_proc_ops = { | |||
| 127 | .release = snd_opl4_mem_proc_release, | 95 | .release = snd_opl4_mem_proc_release, |
| 128 | .read = snd_opl4_mem_proc_read, | 96 | .read = snd_opl4_mem_proc_read, |
| 129 | .write = snd_opl4_mem_proc_write, | 97 | .write = snd_opl4_mem_proc_write, |
| 130 | .llseek = snd_opl4_mem_proc_llseek, | ||
| 131 | }; | 98 | }; |
| 132 | 99 | ||
| 133 | int snd_opl4_create_proc(struct snd_opl4 *opl4) | 100 | int snd_opl4_create_proc(struct snd_opl4 *opl4) |
