iio: at91-sama5d2_adc: remove usage of iio_priv_to_dev() helper
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Mon, 25 May 2020 10:53:41 +0000 (13:53 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 7 Jul 2020 19:24:05 +0000 (20:24 +0100)
commitebf35aad0baa05823df31fda42df4b67f72e6e72
treedfa58ccf169c7c061ca5d40d39ad7d8b71bcaf8e
parentb77652072975e4e766e108699a611a2eaa56634b
iio: at91-sama5d2_adc: remove usage of iio_priv_to_dev() helper

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: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/at91-sama5d2_adc.c