Skip to content

Commit 87699e7

Browse files
committed
Add option to disable MMAP API
Since the high-speed MMAP API is specific to Analog Devices' Linux kernel, add an option to disable it. Signed-off-by: Paul Cercueil <[email protected]>
1 parent 28e0434 commit 87699e7

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ if(WITH_LOCAL_BACKEND)
247247
list(APPEND LIBIIO_CFILES ./libini/libini.c)
248248
endif()
249249

250+
option(WITH_LOCAL_MMAP_API "Use the mmap API provided in Analog Devices' kernel (not upstream)" ON)
250251
option(WITH_HWMON "Add compatibility with the hardware monitoring (hwmon) subsystem" OFF)
251252
endif()
252253

@@ -621,6 +622,7 @@ list(APPEND IIO_FEATURES_${HAVE_BONJOUR} bonjour)
621622
list(APPEND IIO_FEATURES_${ENABLE_IPV6} ipv6)
622623
list(APPEND IIO_FEATURES_${WITH_SERIAL_BACKEND} serial)
623624
list(APPEND IIO_FEATURES_${WITH_LOCAL_BACKEND} local)
625+
list(APPEND IIO_FEATURES_${WITH_LOCAL_MMAP_API} local-mmap)
624626
list(APPEND IIO_FEATURES_${WITH_HWMON} hwmon)
625627
list(APPEND IIO_FEATURES_${WITH_USB_BACKEND} usb)
626628
list(APPEND IIO_FEATURES_${WITH_TESTS} utils)

iio-config.h.cmakein

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#cmakedefine01 WITH_IIOD_USBD
1919
#cmakedefine01 WITH_IIOD_SERIAL
2020
#cmakedefine01 WITH_LOCAL_CONFIG
21+
#cmakedefine01 WITH_LOCAL_MMAP_API
2122
#cmakedefine01 WITH_HWMON
2223
#cmakedefine01 WITH_AIO
2324
#cmakedefine01 HAVE_DNS_SD

local.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static ssize_t local_get_buffer(const struct iio_device *dev,
439439
int f = pdata->fd;
440440
ssize_t ret;
441441

442-
if (!pdata->is_high_speed)
442+
if (!WITH_LOCAL_MMAP_API || !pdata->is_high_speed)
443443
return -ENOSYS;
444444
if (f == -1)
445445
return -EBADF;
@@ -957,11 +957,13 @@ static int local_open(const struct iio_device *dev,
957957
pdata->cyclic_buffer_enqueued = false;
958958
pdata->samples_count = samples_count;
959959

960-
ret = enable_high_speed(dev);
961-
if (ret < 0 && ret != -ENOSYS)
962-
goto err_close;
960+
if (WITH_LOCAL_MMAP_API) {
961+
ret = enable_high_speed(dev);
962+
if (ret < 0 && ret != -ENOSYS)
963+
goto err_close;
963964

964-
pdata->is_high_speed = !ret;
965+
pdata->is_high_speed = !ret;
966+
}
965967

966968
if (!pdata->is_high_speed) {
967969
unsigned long size = samples_count * pdata->max_nb_blocks;

0 commit comments

Comments
 (0)