iio: buffer: remove usage of list iterator variable for list_for_each_entry_continue_reverse()
In preparation to limit the scope of the list iterator variable to the list traversal loop, use a dedicated pointer to iterate through the list [1]. Since that variable should not be used past the loop iteration, a separate variable is used to 'remember the current location within the loop'. To either continue iterating from that position or start a new iteration (if the previous iteration was complete) list_prepare_entry() is used. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20220331230632.957634-1-jakobkoschel@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
a8e1f0ba13
commit
c22e60c315
1 changed files with 5 additions and 2 deletions
|
@ -1059,7 +1059,7 @@ static int iio_enable_buffers(struct iio_dev *indio_dev,
|
||||||
struct iio_device_config *config)
|
struct iio_device_config *config)
|
||||||
{
|
{
|
||||||
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
|
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
|
||||||
struct iio_buffer *buffer;
|
struct iio_buffer *buffer, *tmp = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
indio_dev->active_scan_mask = config->scan_mask;
|
indio_dev->active_scan_mask = config->scan_mask;
|
||||||
|
@ -1097,9 +1097,11 @@ static int iio_enable_buffers(struct iio_dev *indio_dev,
|
||||||
|
|
||||||
list_for_each_entry(buffer, &iio_dev_opaque->buffer_list, buffer_list) {
|
list_for_each_entry(buffer, &iio_dev_opaque->buffer_list, buffer_list) {
|
||||||
ret = iio_buffer_enable(buffer, indio_dev);
|
ret = iio_buffer_enable(buffer, indio_dev);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
tmp = buffer;
|
||||||
goto err_disable_buffers;
|
goto err_disable_buffers;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
|
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
|
||||||
ret = iio_trigger_attach_poll_func(indio_dev->trig,
|
ret = iio_trigger_attach_poll_func(indio_dev->trig,
|
||||||
|
@ -1125,6 +1127,7 @@ err_detach_pollfunc:
|
||||||
indio_dev->pollfunc);
|
indio_dev->pollfunc);
|
||||||
}
|
}
|
||||||
err_disable_buffers:
|
err_disable_buffers:
|
||||||
|
buffer = list_prepare_entry(tmp, &iio_dev_opaque->buffer_list, buffer_list);
|
||||||
list_for_each_entry_continue_reverse(buffer, &iio_dev_opaque->buffer_list,
|
list_for_each_entry_continue_reverse(buffer, &iio_dev_opaque->buffer_list,
|
||||||
buffer_list)
|
buffer_list)
|
||||||
iio_buffer_disable(buffer, indio_dev);
|
iio_buffer_disable(buffer, indio_dev);
|
||||||
|
|
Loading…
Add table
Reference in a new issue