Skip to content

Unable to set buffer watermark correctly #780

@HiFiPhile

Description

@HiFiPhile

Hi,

I'm reading from a SPI ADC which use software buffer to offload frequent Kernel-user space copy overhead, and I need to set watermark attribute of the buffer to enable this.

However, watermark needed to be set after length and before enable.
Here is the kernel soruce: https://github.com/linux4sam/linux-at91/blob/ea5298f615584931c389b14c81af4c1b5da6fbba/drivers/iio/industrialio-buffer.c#L1182

If I use iio_device_buffer_attr_write(mcp3913, "watermark", "20"); before iio_device_create_buffer(mcp3913, BUFFER_SIZE, false); I got invalid argument since buffer length is still 1.

If I use iio_device_buffer_attr_write(mcp3913, "watermark", "20"); afteriio_device_create_buffer(mcp3913, BUFFER_SIZE, false); I got ressource busy since buffer is already enabled.

The workaround is iio_device_create_buffer -> iio_buffer_destroy -> iio_device_buffer_attr_write -> iio_device_create_buffer but it's ugly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions