1. 07 Jul, 2020 10 commits
  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 6 commits
    • Keyur Patel's avatar
      iio: cros_ec: fix spelling mistake · d18ffd83
      Keyur Patel authored
      Fix typo: "tigger" --> "trigger"
      Signed-off-by: default avatarKeyur Patel <iamkeyur96@gmail.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      d18ffd83
    • Lars-Peter Clausen's avatar
      iio: Remove superfluous of_node assignments · 8cb631cc
      Lars-Peter Clausen authored
      If a driver does not assign an of_node to a IIO device to IIO core will
      automatically assign the of_node of the parent device. This automatic
      assignment is done in the iio_device_register() function.
      
      There is a fair amount of drivers that currently manually assign the
      of_node of the IIO device. All but 4 of them can make use of the automatic
      assignment though.
      
      The exceptions are:
       * mxs-lradc-adc: Which uses the of_node of the parent of the parent.
       * stm32-dfsdm-adc, stm32-adc and stm32-dac: Which reference the of_node
         assigned to the IIO device before iio_device_register() is called.
      
      All other drivers are updated to use automatic assignment. This reduces
      the amount of boilerplate code involved in setting up the IIO device.
      
      The patch has mostly been auto-generated with the following semantic patch
      
      // <smpl>
      @exists@
      expression indio_dev;
      expression parent;
      @@
      indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(&parent, ...)
      ...
      -indio_dev->dev.of_node = parent.of_node;
      
      @exists@
      expression indio_dev;
      expression parent;
      @@
      indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(parent, ...)
      ...
      -indio_dev->dev.of_node = parent->of_node;
      // </smpl>
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      8cb631cc
    • Alexandru Ardelean's avatar
      iio: remove left-over parent assignments · 8f73a13f
      Alexandru Ardelean authored
      These were found by doing some shell magic:
      ------------
      for file in $(git grep -w devm_iio_device_alloc | cut -d: -f1 | sort | uniq) ; do
      	if grep 'parent =' $file | grep -v trig | grep -vq devm_; then
      		echo "$file -> $(grep "parent =" $file)"
      	fi
      done
      -----------
      
      The output is bearable [after the semantic patch is applied].
      There is a mix of trigger assignments with some iio device parent
      assignments that are removed via this patch.
      
      JC: A few more added via inspection of all parent =
      statements in drivers/iio. Some of these may just have crossed with this
      series, others were less obvious to scripting due to some cross
      file / module boundary calls.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      8f73a13f
    • Alexandru Ardelean's avatar
      iio: light: lm3533-als: use iio_device_set_parent() to assign parent · 2c9d8e1a
      Alexandru Ardelean authored
      This assignment is the more peculiar as it assigns the parent of the
      platform-device's device (i.e. pdev->dev.parent) as the IIO device's
      parent.
      
      Since the devm_iio_device_alloc() [now] assigns the device argument as the
      default parent (and since this is the more common case), for cases
      where the parent needs to be different, the iio_device_set_parent helper
      should be used.
      
      That makes things a bit more obvious about the new behavior of
      devm_iio_device_alloc() and makes it clearer that iio_device_set_parent()
      should be used.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      2c9d8e1a
    • Alexandru Ardelean's avatar
      iio: remove left-over comments about parent assignment · 2cbd5412
      Alexandru Ardelean authored
      These were obtained by doing a 'git diff | grep \/\*', in the previous diff
      to find comments. These needed a bit more manual review, as the semantic
      patch isn't great for catching these.
      
      The result is:
       	/* Initialize Counter device and driver data */
       	/* Initialize IIO device */
       	/* Establish that the iio_dev is a child of the spi device */
       	/* Estabilish that the iio_dev is a child of the spi device */
       	/* Initiate the Industrial I/O device */
       	/* Establish that the iio_dev is a child of the device */
      -	/* establish that the iio_dev is a child of the i2c device */
      -	/* establish that the iio_dev is a child of the i2c device */
       	/* This is only used for removal purposes */
       	/* setup the industrialio driver allocated elements */
       	/* variant specific configuration */
       	/* Setup for userspace synchronous on demand sampling. */
       	st->readback_delay_us += 5; /* Add tWAIT */
      -	/* Establish that the iio_dev is a child of the i2c device */
       	/* Establish that the iio_dev is a child of the i2c device */
      
      Out of which, 4 are really left-over comments about parent assignment.
      3 of them are removed by the semantic patch, as the comment removed (by
      spatch) would be for an empty line.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      2cbd5412
    • Alexandru Ardelean's avatar
      iio: remove explicit IIO device parent assignment · d3be8324
      Alexandru Ardelean authored
      This patch applies the semantic patch:
      @@
      expression I, P, SP;
      @@
         I = devm_iio_device_alloc(P, SP);
         ...
      -  I->dev.parent = P;
      
      It updates 302 files and does 307 deletions.
      This semantic patch also removes some comments like
      '/* Establish that the iio_dev is a child of the i2c device */'
      
      But this is is only done in case where the block is left empty.
      
      The patch does not seem to cover all cases. It looks like in some cases a
      different variable is used in some cases to assign the parent, but it
      points to the same reference.
      In other cases, the block covered by ... may be just too big to be covered
      by the semantic patch.
      
      However, this looks pretty good as well, as it does cover a big bulk of the
      drivers that should remove the parent assignment.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      d3be8324