X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fcore%2Finfo.c;h=0b08203d50e5a743b5e13ab81db1d69e6f922ce7;hb=043471a130a8787b4b470bb4400b780bf615b019;hp=1eb7d916a365159827d7fc688313c4639ea850c6;hpb=a91482bdcc2e0f6035702e46f1b99043a0893346;p=linux-2.6.git diff --git a/sound/core/info.c b/sound/core/info.c index 1eb7d916a..0b08203d5 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -181,37 +181,30 @@ static ssize_t snd_info_entry_read(struct file *file, char __user *buffer, struct snd_info_entry *entry; snd_info_buffer_t *buf; size_t size = 0; - loff_t pos; data = snd_magic_cast(snd_info_private_data_t, file->private_data, return -ENXIO); snd_assert(data != NULL, return -ENXIO); - pos = *offset; - if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) - return -EIO; - if ((unsigned long) pos + (unsigned long) count < (unsigned long) pos) - return -EIO; entry = data->entry; switch (entry->content) { case SNDRV_INFO_CONTENT_TEXT: buf = data->rbuffer; if (buf == NULL) return -EIO; - if (pos >= buf->size) + if (file->f_pos >= (long)buf->size) return 0; - size = buf->size - pos; + size = buf->size - file->f_pos; size = min(count, size); - if (copy_to_user(buffer, buf->buffer + pos, size)) + if (copy_to_user(buffer, buf->buffer + file->f_pos, size)) return -EFAULT; + file->f_pos += size; break; case SNDRV_INFO_CONTENT_DATA: if (entry->c.ops->read) - size = entry->c.ops->read(entry, + return entry->c.ops->read(entry, data->file_private_data, - file, buffer, count, pos); + file, buffer, count); break; } - if ((ssize_t) size > 0) - *offset = pos + size; return size; } @@ -222,39 +215,34 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer struct snd_info_entry *entry; snd_info_buffer_t *buf; size_t size = 0; - loff_t pos; data = snd_magic_cast(snd_info_private_data_t, file->private_data, return -ENXIO); snd_assert(data != NULL, return -ENXIO); entry = data->entry; - pos = *offset; - if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) - return -EIO; - if ((unsigned long) pos + (unsigned long) count < (unsigned long) pos) - return -EIO; switch (entry->content) { case SNDRV_INFO_CONTENT_TEXT: buf = data->wbuffer; if (buf == NULL) return -EIO; - if (pos >= buf->len) + if (file->f_pos < 0) + return -EINVAL; + if (file->f_pos >= (long)buf->len) return -ENOMEM; - size = buf->len - pos; + size = buf->len - file->f_pos; size = min(count, size); - if (copy_from_user(buf->buffer + pos, buffer, size)) + if (copy_from_user(buf->buffer + file->f_pos, buffer, size)) return -EFAULT; - if ((long)buf->size < pos + size) - buf->size = pos + size; + if ((long)buf->size < file->f_pos + size) + buf->size = file->f_pos + size; + file->f_pos += size; break; case SNDRV_INFO_CONTENT_DATA: if (entry->c.ops->write) - size = entry->c.ops->write(entry, + return entry->c.ops->write(entry, data->file_private_data, - file, buffer, count, pos); + file, buffer, count); break; } - if ((ssize_t) size > 0) - *offset = pos + size; return size; }