iio: Move attach/detach of the poll func to the core

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: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Tested-by: Eugen Hristev <eugen.hristev@microchip.com> #for at91-sama5d2-adc
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Lars-Peter Clausen 2020-05-25 14:38:53 +03:00 committed by Jonathan Cameron
parent 044d406a84
commit f11d59d87b
49 changed files with 93 additions and 429 deletions

View file

@ -20,6 +20,7 @@
#include <linux/iio/iio.h>
#include "iio_core.h"
#include "iio_core_trigger.h"
#include <linux/iio/sysfs.h>
#include <linux/iio/buffer.h>
#include <linux/iio/buffer_impl.h>
@ -972,6 +973,13 @@ static int iio_enable_buffers(struct iio_dev *indio_dev,
}
}
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
ret = iio_trigger_attach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
if (ret)
goto err_disable_buffers;
}
return 0;
err_disable_buffers:
@ -998,6 +1006,11 @@ static int iio_disable_buffers(struct iio_dev *indio_dev)
if (list_empty(&indio_dev->buffer_list))
return 0;
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
iio_trigger_detach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
/*
* If things go wrong at some step in disable we still need to continue
* to perform the other steps, otherwise we leave the device in a