From 87699e7f2357b9448ad9d7f0b777a110babd3f05 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 8 Nov 2021 13:54:49 +0000 Subject: [PATCH] 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 --- CMakeLists.txt | 2 ++ iio-config.h.cmakein | 1 + local.c | 12 +++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b583a4a9..30576c045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,6 +247,7 @@ if(WITH_LOCAL_BACKEND) list(APPEND LIBIIO_CFILES ./libini/libini.c) endif() + option(WITH_LOCAL_MMAP_API "Use the mmap API provided in Analog Devices' kernel (not upstream)" ON) option(WITH_HWMON "Add compatibility with the hardware monitoring (hwmon) subsystem" OFF) endif() @@ -621,6 +622,7 @@ list(APPEND IIO_FEATURES_${HAVE_BONJOUR} bonjour) list(APPEND IIO_FEATURES_${ENABLE_IPV6} ipv6) list(APPEND IIO_FEATURES_${WITH_SERIAL_BACKEND} serial) list(APPEND IIO_FEATURES_${WITH_LOCAL_BACKEND} local) +list(APPEND IIO_FEATURES_${WITH_LOCAL_MMAP_API} local-mmap) list(APPEND IIO_FEATURES_${WITH_HWMON} hwmon) list(APPEND IIO_FEATURES_${WITH_USB_BACKEND} usb) list(APPEND IIO_FEATURES_${WITH_TESTS} utils) diff --git a/iio-config.h.cmakein b/iio-config.h.cmakein index a6cc0160c..ab2687dc2 100644 --- a/iio-config.h.cmakein +++ b/iio-config.h.cmakein @@ -18,6 +18,7 @@ #cmakedefine01 WITH_IIOD_USBD #cmakedefine01 WITH_IIOD_SERIAL #cmakedefine01 WITH_LOCAL_CONFIG +#cmakedefine01 WITH_LOCAL_MMAP_API #cmakedefine01 WITH_HWMON #cmakedefine01 WITH_AIO #cmakedefine01 HAVE_DNS_SD diff --git a/local.c b/local.c index daa39dc90..10a4a993d 100644 --- a/local.c +++ b/local.c @@ -439,7 +439,7 @@ static ssize_t local_get_buffer(const struct iio_device *dev, int f = pdata->fd; ssize_t ret; - if (!pdata->is_high_speed) + if (!WITH_LOCAL_MMAP_API || !pdata->is_high_speed) return -ENOSYS; if (f == -1) return -EBADF; @@ -957,11 +957,13 @@ static int local_open(const struct iio_device *dev, pdata->cyclic_buffer_enqueued = false; pdata->samples_count = samples_count; - ret = enable_high_speed(dev); - if (ret < 0 && ret != -ENOSYS) - goto err_close; + if (WITH_LOCAL_MMAP_API) { + ret = enable_high_speed(dev); + if (ret < 0 && ret != -ENOSYS) + goto err_close; - pdata->is_high_speed = !ret; + pdata->is_high_speed = !ret; + } if (!pdata->is_high_speed) { unsigned long size = samples_count * pdata->max_nb_blocks;