diff options
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/info.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/sound/core/info.c b/sound/core/info.c index f90a6fd43fb4..b70564ed8b37 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -164,39 +164,43 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) | |||
164 | { | 164 | { |
165 | struct snd_info_private_data *data; | 165 | struct snd_info_private_data *data; |
166 | struct snd_info_entry *entry; | 166 | struct snd_info_entry *entry; |
167 | loff_t ret; | 167 | loff_t ret = -EINVAL, size; |
168 | 168 | ||
169 | data = file->private_data; | 169 | data = file->private_data; |
170 | entry = data->entry; | 170 | entry = data->entry; |
171 | mutex_lock(&entry->access); | 171 | mutex_lock(&entry->access); |
172 | switch (entry->content) { | 172 | if (entry->content == SNDRV_INFO_CONTENT_DATA && |
173 | case SNDRV_INFO_CONTENT_TEXT: | 173 | entry->c.ops->llseek) { |
174 | switch (orig) { | 174 | offset = entry->c.ops->llseek(entry, |
175 | case SEEK_SET: | 175 | data->file_private_data, |
176 | file->f_pos = offset; | 176 | file, offset, orig); |
177 | ret = file->f_pos; | 177 | goto out; |
178 | goto out; | 178 | } |
179 | case SEEK_CUR: | 179 | if (entry->content == SNDRV_INFO_CONTENT_DATA) |
180 | file->f_pos += offset; | 180 | size = entry->size; |
181 | ret = file->f_pos; | 181 | else |
182 | goto out; | 182 | size = 0; |
183 | case SEEK_END: | 183 | switch (orig) { |
184 | default: | 184 | case SEEK_SET: |
185 | ret = -EINVAL; | ||
186 | goto out; | ||
187 | } | ||
188 | break; | 185 | break; |
189 | case SNDRV_INFO_CONTENT_DATA: | 186 | case SEEK_CUR: |
190 | if (entry->c.ops->llseek) { | 187 | offset += file->f_pos; |
191 | ret = entry->c.ops->llseek(entry, | 188 | break; |
192 | data->file_private_data, | 189 | case SEEK_END: |
193 | file, offset, orig); | 190 | if (!size) |
194 | goto out; | 191 | goto out; |
195 | } | 192 | offset += size; |
196 | break; | 193 | break; |
197 | } | 194 | default: |
198 | ret = -ENXIO; | 195 | goto out; |
199 | out: | 196 | } |
197 | if (offset < 0) | ||
198 | goto out; | ||
199 | if (size && offset > size) | ||
200 | offset = size; | ||
201 | file->f_pos = offset; | ||
202 | ret = offset; | ||
203 | out: | ||
200 | mutex_unlock(&entry->access); | 204 | mutex_unlock(&entry->access); |
201 | return ret; | 205 | return ret; |
202 | } | 206 | } |