1. 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
  2. 22 9月, 2013 1 次提交
  3. 21 9月, 2013 2 次提交
    • L
      iio: Stop sampling when the device is removed · a87c82e4
      Lars-Peter Clausen 提交于
      Make sure to stop sampling when the device is removed, otherwise it will
      continue to sample forever.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      a87c82e4
    • P
      iio: Fix crash when scan_bytes is computed with active_scan_mask == NULL · d66e0452
      Peter Meerwald 提交于
      if device has available_scan_masks set and the buffer is enabled without
      any scan_elements enabled, in a NULL pointer is dereferenced in iio_compute_scan_bytes()
      
      [   18.993713] Unable to handle kernel NULL pointer dereference at virtual address 00000000
      [   19.002593] pgd = debd4000
      [   19.005432] [00000000] *pgd=9ebc0831, *pte=00000000, *ppte=00000000
      [   19.012329] Internal error: Oops: 17 [#1] PREEMPT ARM
      [   19.017639] Modules linked in:
      [   19.020843] CPU: 0    Not tainted  (3.9.11-00036-g75c888a-dirty #207)
      [   19.027587] PC is at _find_first_bit_le+0xc/0x2c
      [   19.032440] LR is at iio_compute_scan_bytes+0x2c/0xf4
      [   19.037719] pc : [<c021dc60>]    lr : [<c03198d0>]    psr: 200d0013
      [   19.037719] sp : debd9ed0  ip : 00000000  fp : 000802bc
      [   19.049713] r10: 00000000  r9 : 00000000  r8 : deb67250
      [   19.055206] r7 : 00000000  r6 : 00000000  r5 : 00000000  r4 : deb67000
      [   19.062011] r3 : de96ec00  r2 : 00000000  r1 : 00000004  r0 : 00000000
      [   19.068847] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
      [   19.076324] Control: 10c5387d  Table: 9ebd4019  DAC: 00000015
      
      problem is the rollback code in iio_update_buffers(), old_mask may be NULL (e.g. on first
      call)
      
      I'm not too confident about the fix; works for me...
      Signed-off-by: NPeter Meerwald <pmeerw@pmeerw.net>
      Reviewed-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      d66e0452
  4. 19 9月, 2013 1 次提交
  5. 16 9月, 2013 3 次提交
  6. 23 5月, 2013 1 次提交
  7. 10 11月, 2012 1 次提交
  8. 20 10月, 2012 1 次提交
  9. 08 9月, 2012 1 次提交
  10. 04 9月, 2012 1 次提交
  11. 10 7月, 2012 2 次提交
    • L
      iio: Introduce iio_validate_scan_mask_onehot · 81636632
      Lars-Peter Clausen 提交于
      Add a helper function for validating a scan mask for devices where exactly one
      channel must be selected during sampling. This is a common case among devices
      which have scan mask restrictions so it makes sense to provide this function in
      the core.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      81636632
    • L
      iio: Add callback to check whether a scan mask is valid · 939546d1
      Lars-Peter Clausen 提交于
      This is useful for cases where the number of valid scan masks grows
      exponentially, but it is rather easy to check whether a mask is valid or not
      programmatically.
      
      An example of such a case is a device with multiple ADCs where each ADC has a
      upstream MUX, which allows to select from a number of physical channels.
      
        +-------+   +-------+
        |       |   |       | --- Channel 1
        | ADC 1 |---| MUX 1 | ---   ...
        |       |   |       | --- Channel M
        +-------+   +-------+
      
           .            .            .
           .            .            .
           .            .            .
      
        +-------+   +-------+
        |       |   |       | --- Channel M * N + 1
        | ADC N |---| MUX N | ---       ...
        |       |   |       | --- Channel M * N + M
        +-------+   +-------+
      
      The number of necessary scan masks for this case is (M+1)**N - 1, on the other
      hand it is easy to check whether subsets for each ADC of the scanmask have only
      one bit set.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      939546d1
  12. 09 7月, 2012 1 次提交
  13. 19 6月, 2012 1 次提交
  14. 16 6月, 2012 1 次提交
  15. 15 5月, 2012 1 次提交
  16. 26 4月, 2012 2 次提交
  17. 25 4月, 2012 6 次提交
  18. 25 2月, 2012 1 次提交
  19. 23 12月, 2011 7 次提交
  20. 09 12月, 2011 5 次提交