Skip to content

Commit 62a30a2

Browse files
commodoJonathan Cameron
authored andcommitted
iio: buffer: fix attach/detach pollfunc order
The original patch was error-ed by the submitter (me) and not by the author (Lars). After looking through the discussion logs (on email), it seems that this order was wrong for the start, even though the order implemented in the drivers was correct. Discussions: - first RFC: https://lore.kernel.org/linux-iio/20180622135322.3459-1-alexandru.ardelean@analog.com/ - 2nd patch: https://lore.kernel.org/linux-iio/20181219140912.22582-1-alexandru.ardelean@analog.com/ - final patch-sets: https://lore.kernel.org/linux-iio/20200522104632.517470-1-alexandru.ardelean@analog.com/ https://lore.kernel.org/linux-iio/20200525113855.178821-1-alexandru.ardelean@analog.com/ The last one was applied. The idea is that pollfunc should be attached before calling the 'indio_dev->setup_ops->postenable' hook and should be detached after calling the 'indio_dev->setup_ops->predisable' hook. While the drivers were updated to take this into account, the change to the IIO core was somehow omitted and was made wrong. This change fixes the order to the proper form. Fixes f11d59d: ("iio: Move attach/detach of the poll func to the core") Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent f4bf09d commit 62a30a2

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

‎drivers/iio/industrialio-buffer.c‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -971,24 +971,29 @@ static int iio_enable_buffers(struct iio_dev *indio_dev,
971971
goto err_disable_buffers;
972972
}
973973

974+
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
975+
ret = iio_trigger_attach_poll_func(indio_dev->trig,
976+
indio_dev->pollfunc);
977+
if (ret)
978+
goto err_disable_buffers;
979+
}
980+
974981
if (indio_dev->setup_ops->postenable) {
975982
ret = indio_dev->setup_ops->postenable(indio_dev);
976983
if (ret) {
977984
dev_dbg(&indio_dev->dev,
978985
"Buffer not started: postenable failed (%d)\n", ret);
979-
goto err_disable_buffers;
986+
goto err_detach_pollfunc;
980987
}
981988
}
982989

983-
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
984-
ret = iio_trigger_attach_poll_func(indio_dev->trig,
985-
indio_dev->pollfunc);
986-
if (ret)
987-
goto err_disable_buffers;
988-
}
989-
990990
return 0;
991991

992+
err_detach_pollfunc:
993+
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
994+
iio_trigger_detach_poll_func(indio_dev->trig,
995+
indio_dev->pollfunc);
996+
}
992997
err_disable_buffers:
993998
list_for_each_entry_continue_reverse(buffer, &iio_dev_opaque->buffer_list,
994999
buffer_list)
@@ -1014,11 +1019,6 @@ static int iio_disable_buffers(struct iio_dev *indio_dev)
10141019
if (list_empty(&iio_dev_opaque->buffer_list))
10151020
return 0;
10161021

1017-
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
1018-
iio_trigger_detach_poll_func(indio_dev->trig,
1019-
indio_dev->pollfunc);
1020-
}
1021-
10221022
/*
10231023
* If things go wrong at some step in disable we still need to continue
10241024
* to perform the other steps, otherwise we leave the device in a
@@ -1032,6 +1032,11 @@ static int iio_disable_buffers(struct iio_dev *indio_dev)
10321032
ret = ret2;
10331033
}
10341034

1035+
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
1036+
iio_trigger_detach_poll_func(indio_dev->trig,
1037+
indio_dev->pollfunc);
1038+
}
1039+
10351040
list_for_each_entry(buffer, &iio_dev_opaque->buffer_list, buffer_list) {
10361041
ret2 = iio_buffer_disable(buffer, indio_dev);
10371042
if (ret2 && !ret)

0 commit comments

Comments
 (0)