• Alexandru Ardelean's avatar
    iio: buffer: group attr count and attr alloc · e2b4d7ac
    Alexandru Ardelean authored
    If we want to merge the attributes of the buffer/ and scan_elements/
    directories, we'll need to count all attributes first, then (depending on
    the attribute group) either allocate 2 attribute groups, or a single one.
    Historically an IIO buffer was described by 2 subdirectories under
    /sys/bus/iio/iio:devicesX (i.e. buffer/ and scan_elements/); these subdirs
    were actually 2 separate attribute groups on the iio_buffer object.
    
    Moving forward, if we want to allow more than one buffer per IIO device,
    keeping 2 subdirectories for each IIO buffer is a bit cumbersome
    (especially for userpace ABI). So, we will merge the attributes of these 2
    subdirs under a /sys/bus/iio/iio:devicesX/bufferY subdirectory. To do this,
    we need to count all attributes first, and then distribute them based on
    which buffer this is. For the first buffer, we'll need to also allocate the
    legacy 2 attribute groups (for buffer/ and scan_elements/), and also a
    /sys/bus/iio/iio:devicesX/buffer0 attribute group.
    
    For buffer1 and above, just a single attribute group will be allocated (the
    merged one).
    Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
    Link: https://lore.kernel.org/r/20210215104043.91251-12-alexandru.ardelean@analog.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    e2b4d7ac
industrialio-buffer.c 37.9 KB