1. 12 Oct, 2013 9 commits
    • Lars-Peter Clausen's avatar
      iio:max1363: Switch to new event config interface · e4ec84f8
      Lars-Peter Clausen authored
      Switch the max1363 driver to the new IIO event config interface as the old one
      is going to be removed.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      e4ec84f8
    • Lars-Peter Clausen's avatar
      iio: Extend the event config interface · b4e3ac0a
      Lars-Peter Clausen authored
      The event configuration interface of the IIO framework has not been getting the
      same attention as other parts. As a result it has not seen the same improvements
      as e.g. the channel interface has seen with the introduction of the channel spec
      struct. Currently all the event config callbacks take a u64 (the so called event
      code) to pass all the different information about for which event the callback
      is invoked. The callback function then has to extract the information it is
      interested in using some macros with rather long names. Most information encoded
      in the event code comes straight from the iio_chan_spec struct the event was
      registered for. Since we always have a handle to the channel spec when we call
      the event callbacks the first step is to add the channel spec as a parameter to
      the event callbacks. The two remaining things encoded in the event code are the
      type and direction of the event. Instead of passing them in one parameter, add
      one parameter for each of them and remove the eventcode from the event
      callbacks. The patch also adds a new iio_event_info parameter to the
      {read,write}_event_value callbacks. This makes it possible, similar to the
      iio_chan_info_enum for channels, to specify additional properties other than
      just the value for an event. Furthermore the new interface will allow to
      register shared events. This is e.g. useful if a device allows configuring a
      threshold event, but the threshold setting is the same for all channels.
      
      To implement this the patch adds a new iio_event_spec struct which is similar to
      the iio_chan_spec struct. It as two field to specify the type and the direction
      of the event. Furthermore it has a mask field for each one of the different
      iio_shared_by types. These mask fields holds which kind of attributes should be
      registered for the event. Creation of the attributes follows the same rules as
      the for the channel attributes. E.g. for the separate_mask there will be a
      attribute for each channel with this event, for the shared_by_type there will
      only be one attribute per channel type. The iio_chan_spec struct gets two new
      fields, 'event_spec' and 'num_event_specs', which is used to specify which the
      events for this channel. These two fields are going to replace the channel's
      event_mask field.
      
      For now both the old and the new event config interface coexist, but over the
      few patches all drivers will be converted from the old to the new interface.
      Once that is done all code for supporting the old interface will be removed.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      b4e3ac0a
    • Lars-Peter Clausen's avatar
    • Sebastian Andrzej Siewior's avatar
      staging: iio: generic_buffer: initialize ret · 11cb454f
      Sebastian Andrzej Siewior authored
      The `ret´ variable is only initialized in the error case. For some reason
      it was always != 0 while I played with generic_buffer so here is a patch.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      11cb454f
    • Lars-Peter Clausen's avatar
      iio: Add a helper to free a list of IIO device attributes · 84088ebd
      Lars-Peter Clausen authored
      We have the same code to free a IIO device attribute list in multiple place.
      This patch adds a new helper function to take care of this and replaces the
      custom instances with a call to the helper function. Note that we do not need to
      call list_del() for each of the list items since we will never look at any of
      the list items nor the list itself again.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      84088ebd
    • Lars-Peter Clausen's avatar
      iio:buffer: Add proper locking for iio_update_buffers() · a9519456
      Lars-Peter Clausen authored
      We need to make sure that in-kernel users of iio_update_buffers() do not race
      against each other or against unregistration of the device. So we need to take
      both the mlock and the info_exist_lock when calling iio_update_buffers() from a
      in-kernel consumer.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      a9519456
    • Lars-Peter Clausen's avatar
      iio: Wakeup poll and blocking reads when the device is unregistered · d2f0a48f
      Lars-Peter Clausen authored
      Once the device has been unregistered there won't be any new data no matter how
      long a userspace application waits, so we might as well wake them up and let
      them know.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      d2f0a48f
    • 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 2 commits