Skip to content

Commit

Permalink
Add option to disable MMAP API
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pcercuei committed Jan 18, 2022
1 parent 28e0434 commit 87699e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions iio-config.h.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 87699e7

Please sign in to comment.