]> git.baikalelectronics.ru Git - kernel.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:53:43 +0000 (16:53 +0200)
commit5f4f9d0ef8879f3798cfc0db0080bb81a9ed43c6
tree6034cd874bc3303f6cb00b89dfee53f07cce0bf7
parent352f360d16444fc71db42143b38e24924e864348
iio: at91-sama5d2_adc: remove usage of iio_priv_to_dev() helper

[ Upstream commit ebf35aad0baa05823df31fda42df4b67f72e6e72 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/adc/at91-sama5d2_adc.c