1. 12 Oct, 2013 2 commits
    • Lars-Peter Clausen's avatar
      iio: Return -ENODEV for file operations if the device has been unregistered · f18e7a06
      Lars-Peter Clausen authored
      If the IIO device has been unregistered return -ENODEV for any further file
      operations like read() and ioctl(). This avoids userspace being able to grab new
      references to the device.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      f18e7a06
    • Lars-Peter Clausen's avatar
      iio: Add reference counting for buffers · 9e69c935
      Lars-Peter Clausen authored
      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: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      9e69c935
  2. 09 Oct, 2013 2 commits
  3. 07 Oct, 2013 27 commits
  4. 06 Oct, 2013 9 commits