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. 24 9月, 2013 2 次提交
  3. 22 9月, 2013 1 次提交
    • L
      iio: Add iio_push_buffers_with_timestamp() helper · d2c3d072
      Lars-Peter Clausen 提交于
      Drivers using software buffers often store the timestamp in their data buffer
      before calling iio_push_to_buffers() with that data buffer. Storing the
      timestamp in the buffer usually involves some ugly pointer arithmetic. This
      patch adds a new helper function called iio_push_buffers_with_timestamp() which
      is similar to iio_push_to_buffers but takes an additional timestamp parameter.
      The function will help to hide to uglyness in one central place instead of
      exposing it in every driver. If timestamps are enabled for the IIO device
      iio_push_buffers_with_timestamp() will store the timestamp as the last element
      in buffer, before passing the buffer on to iio_push_buffers(). The buffer needs
      large enough to hold the timestamp in this case. If timestamps are disabled
      iio_push_buffers_with_timestamp() will behave just like iio_push_buffers().
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
      Cc: Josh Wu <josh.wu@atmel.com>
      Cc: Denis Ciocca <denis.ciocca@gmail.com>
      Cc: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
      Cc: Ge Gao <ggao@invensense.com>
      Cc: Peter Meerwald <pmeerw@pmeerw.net>
      Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
      Cc: Fabio Estevam <fabio.estevam@freescale.com>
      Cc: Marek Vasut <marex@denx.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      d2c3d072
  4. 16 9月, 2013 4 次提交
  5. 15 9月, 2013 2 次提交
    • L
      iio: pressure-core: st: Allow for number of channels to vary · ea01f2c1
      Lee Jones 提交于
      At the moment the number of channels specified is dictated by the first
      sensor supported by the driver. As we add support for more sensors this
      is likely to vary. Instead of using the ARRAY_SIZE() of the LPS331AP's
      channel specifier we'll use a new adaptable 'struct st_sensors' element
      instead.
      Signed-off-by: NLee Jones <lee.jones@linaro.org>
      Acked-by: NDenis Ciocca <denis.ciocca@st.com>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      ea01f2c1
    • P
      iio: Add INT_TIME (integration time) channel info attribute · 899d90bd
      Peter Meerwald 提交于
      Integration time is in seconds; it controls the measurement
      time and influences the gain of a sensor.
      
      There are two typical ways that scaling is implemented in a device:
      1) input amplifier,
      2) reference to the ADC is changed.
      These both result in the accuracy of the ADC varying (by applying its
      sampling over a more relevant range).
      
      Integration time is a way of dealing with noise inherent in the analog
      sensor itself.  In the case of a light sensor, a mixture of photon noise
      and device specific noise.  Photon noise is dealt with by either improving
      the efficiency of the sensor, (more photons actually captured) which is not
      easily varied dynamically, or by integrating the measurement over a longer
      time period.  Note that this can also be thought of as an averaging of a
      number of individual samples and is infact sometimes implemented this way.
      Altering integration time implies that the duration of a measurement changes,
      a fact the device's user may be interested in.
      
      Hence it makes sense to distinguish between integration time and simple
      scale. In some devices both types of control are present and whilst they
      will have similar effects on the amplitude of the reading, their effect
      on the noise of the measurements will differ considerably.
      
      Used by adjd_s311, tsl4531, tcs3472
      The following drivers have similar controls (and could be adapted):
      * tsl2563 (integration time is controlled via CALIBSCALE among other things)
      * tsl2583 (has integration_time device_attr, but driver doesn't use channels yet)
      * tsl2x7x (has integration_time attr)
      Signed-off-by: NPeter Meerwald <pmeerw@pmeerw.net>
      Cc: Jon Brenner <jon.brenner@ams.com>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      899d90bd
  6. 01 9月, 2013 1 次提交
  7. 18 8月, 2013 1 次提交
  8. 04 8月, 2013 4 次提交
  9. 20 7月, 2013 1 次提交
    • L
      iio:trigger: Fix use_count race condition · a1a8e1dc
      Lars-Peter Clausen 提交于
      When using more than one trigger consumer it can happen that multiple threads
      perform a read-modify-update cycle on 'use_count' concurrently. This can cause
      updates to be lost and use_count can get stuck at non-zero value, in which case
      the IIO core assumes that at least one thread is still running and will wait for
      it to finish before running any trigger handlers again. This effectively renders
      the trigger disabled and a reboot is necessary before it can be used again. To
      fix this make use_count an atomic variable. Also set it to the number of
      consumers before starting the first consumer, otherwise it might happen that
      use_count drops to 0 even though not all consumers have been run yet.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Tested-by: NDenis Ciocca <denis.ciocca@st.com>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      a1a8e1dc
  10. 03 7月, 2013 1 次提交
  11. 06 6月, 2013 1 次提交
  12. 05 6月, 2013 2 次提交
  13. 26 3月, 2013 2 次提交
  14. 18 3月, 2013 6 次提交
  15. 03 3月, 2013 1 次提交
    • G
      iio: Fix build error seen if IIO_TRIGGER is defined but IIO_BUFFER is not · 5a4d7291
      Guenter Roeck 提交于
      If CONFIG_IIO_TRIGGER is defined but CONFIG_IIO_BUFFER is not, the following
      build error is seen.
      
      drivers/iio/common/st_sensors/st_sensors_trigger.c:21:5: error:
      redefinition of ‘st_sensors_allocate_trigger’
      In file included from
      drivers/iio/common/st_sensors/st_sensors_trigger.c:18:0:
      include/linux/iio/common/st_sensors.h:239:19: note: previous
      definition of ‘st_sensors_allocate_trigger’ was here
      drivers/iio/common/st_sensors/st_sensors_trigger.c:65:6: error:
      redefinition of ‘st_sensors_deallocate_trigger’
      In file included from
      drivers/iio/common/st_sensors/st_sensors_trigger.c:18:0:
      include/linux/iio/common/st_sensors.h:244:20: note: previous
      definition of ‘st_sensors_deallocate_trigger’ was here
      
      This occurs because st_sensors_deallocate_trigger is built if CONFIG_IIO_TRIGGER
      is defined, but the dummy function is compiled if CONFIG_IIO_BUFFER is defined.
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Acked-by: NDenis Ciocca <denis.ciocca@st.com>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      5a4d7291
  16. 09 2月, 2013 2 次提交
  17. 07 2月, 2013 1 次提交
  18. 02 2月, 2013 4 次提交
  19. 01 2月, 2013 2 次提交
  20. 21 11月, 2012 1 次提交