1. 16 10月, 2013 3 次提交
    • L
      iio:kfifo: Empty buffer on update · 5b78e513
      Lars-Peter Clausen 提交于
      The kfifo's request_update callback will free the current buffer and allocate a
      new one if the size has changed. This will remove any samples that might still
      be left in the buffer. If the size has not changed the buffer content is
      left untouched though. This is a bit inconsistent and might cause an application
      to see data from a previous capture. This patch inserts a call to
      kfifo_reset_out() when the size did not change. This makes sure that any pending
      samples are removed from the buffer.
      
      Note, due to a different bug the buffer is currently always re-allocated, even
      if the size did not change. So this patch will not change the behavior. In the
      next patch the bug will be fixed and this patch makes sure that the current
      behavior is kept.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      5b78e513
    • L
      iio:kfifo: Protect against concurrent access from userspace · 0894d80d
      Lars-Peter Clausen 提交于
      It is possible for userspace to concurrently access the buffer from multiple
      threads or processes. To avoid corruption of the internal state of the buffer we
      need to add proper locking. It is possible for multiple processes to try to read
      from the buffer concurrently and it is also possible that one process causes a
      buffer re-allocation while a different process still access the buffer. Both can
      be fixed by protecting the calls to kfifo_to_user() and kfifo_alloc() by the
      same mutex. In iio_read_first_n_kfifo() we also use kfifo_recsize() instead of
      the buffers bytes_per_datum to avoid a race that can happen if bytes_per_datum
      has been changed, but the buffer has not been reallocated yet.
      
      Note that all access to the buffer from within the kernel is already properly
      synchronized, so there is no need for extra locking in iio_store_to_kfifo().
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      0894d80d
    • L
      iio:kfifo: Fix memory leak · f6c23f48
      Lars-Peter Clausen 提交于
      We need to free the kfifo when we release the buffer, otherwise the fifos memory
      will be leaked.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      f6c23f48
  2. 12 10月, 2013 1 次提交
    • L
      iio: Add reference counting for buffers · 9e69c935
      Lars-Peter Clausen 提交于
      Since the buffer is accessed by userspace we can not just free the buffers
      memory once we are done with it in kernel space. There might still be open file
      descriptors and userspace still might be accessing the buffer. This patch adds
      support for reference counting to the IIO buffers. When a buffer is created and
      initialized its initial reference count is set to 1. Instead of freeing the
      memory of the buffer the buffer's _free() function will drop that reference
      again. But only after the last reference to the buffer has been dropped the
      buffer the buffer's memory will be freed. The IIO device will take a reference
      to its primary buffer. The patch adds a small helper function for this called
      iio_device_attach_buffer() which will get a reference to the buffer and assign
      the buffer to the IIO device. This function must be used instead of assigning
      the buffer to the device by hand. The reference is only dropped once the IIO
      device is freed and we can be sure that there are no more open file handles. A
      reference to a buffer will also be taken whenever the buffer is active to avoid
      the buffer being freed while data is still being send to it.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      9e69c935
  3. 16 9月, 2013 2 次提交
  4. 01 2月, 2013 1 次提交
  5. 08 9月, 2012 1 次提交
  6. 28 8月, 2012 3 次提交
  7. 26 4月, 2012 2 次提交
  8. 10 2月, 2012 1 次提交
  9. 23 12月, 2011 2 次提交
    • L
      staging:iio: Drop {mark,unmark}_in_use callbacks · 79335140
      Lars-Peter Clausen 提交于
      These callbacks are currently used by the individual buffer implementations to
      ensure that the request_update callback is not issued while the buffer is in use.
      But the core already provides sufficient measures to prevent this from happening
      in the first place. So it is safe to remove them.
      
      There is one functional change due to this patch. Since the buffer is no longer
      marked as in use when the chrdev is opened, it is now possible to enable the
      buffer while it is opened. This did not work before, because mark_param_change
      did fail if the buffer was marked as in use.
      Acked-by: NJonathan Cameron <jic23@kernel.org>
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      79335140
    • L
      staging:iio: Drop buffer mark_param_change callback · 869871b5
      Lars-Peter Clausen 提交于
      Right now we have a mark_param_change callback in the buffer access
      functions struct, which should be called whenever the parameters (length,
      bytes per datum) of the buffer change. But it is only called when the user
      changes the buffer size, not when the bytes per datum change. Additionally each
      buffer implementation already keeps track internally whether its parameters
      have changed, making the call to mark_param_change after changing the buffer
      length redundant. Since each buffer implementation knows best when one of its
      parameters has changed just make tracking of this internal and drop the
      mark_param_change callback.
      Acked-by: NJonathan Cameron <jic23@kernel.org>
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      869871b5
  10. 13 12月, 2011 1 次提交
  11. 09 12月, 2011 2 次提交
  12. 27 11月, 2011 1 次提交
  13. 27 9月, 2011 1 次提交
  14. 07 9月, 2011 2 次提交
  15. 19 7月, 2011 1 次提交
  16. 20 5月, 2011 2 次提交
  17. 26 4月, 2011 1 次提交
  18. 19 2月, 2011 1 次提交