1. 07 Jul, 2020 3 commits
    • Alexandru Ardelean's avatar
      iio: core: remove padding from private information · 09673d5e
      Alexandru Ardelean authored
      There was a recent discussion about this code:
        https://lore.kernel.org/linux-iio/20200322165317.0b1f0674@archlinux/
      
      This looks like a good time to removed this, since any issues about it
      should pop-up under testing, because the iio_dev is having a bit of an
      overhaul and stuff being moved to iio_dev_opaque.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      09673d5e
    • Alexandru Ardelean's avatar
      iio: core: wrap IIO device into an iio_dev_opaque object · 6d4ebd56
      Alexandru Ardelean authored
      There are plenty of bad designs we want to discourage or not have to review
      manually usually about accessing private (marked as [INTERN]) fields of
      'struct iio_dev'.
      
      Sometimes users copy drivers that are not always the best examples.
      
      A better idea is to hide those fields into the framework.
      For 'struct iio_dev' this is a 'struct iio_dev_opaque' which wraps a public
      'struct iio_dev' object.
      
      In the next series, some fields will be moved to this new struct, each with
      it's own rework.
      
      This rework will not be complete-able for a while, as many fields need some
      drivers to be reworked in order to finalize them (e.g. 'indio_dev->mlock').
      
      But some fields can already be moved, and in time, all of them may get
      there (in the 'struct iio_dev_opaque' object).
      
      Since a lot of drivers also call 'iio_priv()', in order to preserve
      fast-paths (where this matters), the public iio_dev object will have a
      'priv' field that will have the pointer to the private information already
      computed. The reference returned by this field should be guaranteed to be
      cacheline aligned.
      
      The opaque parts will be moved into the 'include/linux/iio/iio-opaque.h'
      header. Should the hidden information be required for some debugging or
      some special needs, it can be made available via this header.
      Otherwise, only the IIO core files should include this file.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      6d4ebd56
    • Alexandru Ardelean's avatar
      iio: at91-sama5d2_adc: remove usage of iio_priv_to_dev() helper · ebf35aad
      Alexandru Ardelean authored
      We may want to get rid of the iio_priv_to_dev() helper. The reason is that
      we will hide some of the members of the iio_dev structure (to prevent
      drivers from accessing them directly), and that will also mean hiding the
      implementation of the iio_priv_to_dev() helper inside the IIO core.
      
      Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
      may not be fast anymore, so a general idea is to try to get rid of the
      iio_priv_to_dev() altogether.
      The iio_priv() helper won't be affected by the rework, as the iio_dev
      struct will keep a reference to the private information.
      
      For this driver, not using iio_priv_to_dev(), means reworking some paths to
      pass the iio device and using iio_priv() to access the private information,
      and also keeping a reference to the iio device for some quirky paths.
      
      One [quirky] path is the at91_adc_workq_handler() which requires the IIO
      device & the state struct to push to buffers.
      Since this requires the back-ref to the IIO device, the
      at91_adc_touch_pos() also uses it. This simplifies the patch a bit. The
      information required in this function is mostly for debugging purposes.
      Replacing it with a reference to the IIO device would have been a slightly
      bigger change, which may not be worth it (for just the debugging purpose
      and given that we need the back-ref to the IIO device anyway).
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      ebf35aad
  2. 27 Jun, 2020 21 commits
  3. 20 Jun, 2020 3 commits
    • Lars-Peter Clausen's avatar
      iio: Move attach/detach of the poll func to the core · f11d59d8
      Lars-Peter Clausen authored
      All devices using a triggered buffer need to attach and detach the trigger
      to the device in order to properly work. Instead of doing this in each and
      every driver by hand move this into the core.
      
      At this point in time, all drivers should have been resolved to
      attach/detach the poll-function in the same order.
      
      This patch removes all explicit calls of iio_triggered_buffer_postenable()
      & iio_triggered_buffer_predisable() in all drivers, since the core handles
      now the pollfunc attach/detach.
      
      The more peculiar change is for the 'at91-sama5d2_adc' driver, since it's
      not immediately obvious that removing the hooks doesn't break anything.
      Eugen was able to test on at91-sama5d2-adc driver, sama5d2-xplained board.
      All seems to be fine.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Tested-by: Eugen Hristev <eugen.hristev@microchip.com> #for at91-sama5d2-adc
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      f11d59d8
    • Alexandru Ardelean's avatar
      iio: at91_adc: remove usage of iio_priv_to_dev() helper · 044d406a
      Alexandru Ardelean authored
      We may want to get rid of the iio_priv_to_dev() helper. The reason is that
      we will hide some of the members of the iio_dev structure (to prevent
      drivers from accessing them directly), and that will also mean hiding the
      implementation of the iio_priv_to_dev() helper inside the IIO core.
      
      Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
      may not be fast anymore, so a general idea is to try to get rid of the
      iio_priv_to_dev() altogether.
      The iio_priv() helper won't be affected by the rework, as the iio_dev
      struct will keep a reference to the private information.
      
      For this driver, not using iio_priv_to_dev(), means reworking some paths to
      pass the iio device and using iio_priv() to access the private information.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Tested-by: default avatarEugen Hristev <eugen.hristev@microchip.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      044d406a
    • Alexandru Ardelean's avatar
      iio: stm32-dfsdm-adc: remove usage of iio_priv_to_dev() helper · 07b6c9dc
      Alexandru Ardelean authored
      We may want to get rid of the iio_priv_to_dev() helper. The reason is that
      we will hide some of the members of the iio_dev structure (to prevent
      drivers from accessing them directly), and that will also mean hiding the
      implementation of the iio_priv_to_dev() helper inside the IIO core.
      
      Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
      may not be fast anymore, so a general idea is to try to get rid of the
      iio_priv_to_dev() altogether.
      The iio_priv() helper won't be affected by the rework, as the iio_dev
      struct will keep a reference to the private information.
      
      For this driver, not using iio_priv_to_dev(), means reworking some paths to
      pass the iio device and using iio_priv() to access the private information.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      07b6c9dc
  4. 14 Jun, 2020 13 commits