spi: cadence: Fix encoded CS mode

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
ARM: dts: fmcadc3: Enable chip-select decoding

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
iio: ad9467: Fix ad9234 configured as 16-bit instead of 12-bit

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
iio:cf_axi_dds: Check spidev in cf_axi_dds_reg_access() before dereferencing it

Don't dereference st->spidev for standalone converters, otherwise we'll get
a NULL pointer deref.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:buffer: Fix bitmap compare function signature

The signature of bitmap_compare and bitmap_subset were recently updated to
take a unsigned int instead of a int for the nbits parameter.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:buffer: Fix mismerge

Fix the mismerge with v3.17 in iio_buffer_update_demux().

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:buffer: Don't allow buffers without any channels enabled to be activated

Before activating a buffer make sure that at least one channel is enabled.
Activating a buffer with 0 channels enabled doesn't make too much sense and
disallowing this case makes sure that individual driver don't have to add
special case code to handle it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
staging:iio:ade7758: Fix check if channels are enabled in prenable

We should check if a channel is enabled, not if no channels are enabled.

Fixes: 550268ca1111 ("staging:iio: scrap scan_count and ensure all drivers use active_scan_mask")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
staging:iio:ade7758: Remove "raw" from channel name

"raw" is a property of a channel, but should not be part of the name of
channel.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
staging:iio:ade7758: Fix NULL pointer deref when enabling buffer

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
staging:iio:sca3000: Register same channels for device and buffer

In preparation for moving the buffer registration to the core make sure to
register the same channel array for the device and the buffer.  Currently
the temperature channel is not registered for the buffer, setting its scan
index to -1 will make sure that it is skipped for the buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
staging:iio:dummy: Register same channels for device and buffer

In preparation for moving the buffer registration to the core make sure to
register the same channel array for the device and the buffer. Currently
the output voltage channel is not registered for the buffer, setting its
scan index to -1 will make sure that it is skipped for the buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: Move buffer registration to the core

Originally device and buffer registration were kept as separate operations
in IIO to allow to register two distinct sets of channels for buffered and
non-buffered operations. This has since already been further restricted and
the channel set registered for the buffer needs to be a subset of the
channel set registered for the device. Additionally the possibility to not
have a raw (or processed) attribute for a channel which was registered for
the device was added a while ago, which means it is possible to not register
any device level attributes for a channel even if it is registered for the
device. Also if a channel's scan_index is set to -1 and the channel is
registered for the buffer it is ignored.

So in summery it means it is possible to register the same channel array for
both the device and the buffer yet still end up with distinctive sets of
channels for both of them. This makes the argument for having to have to
manually register the channels for both the device and the buffer invalid.
Considering that the vast majority of all drivers want to register the same
set of channels for both the buffer and the device it makes sense to move
the buffer registration into the core to avoid some boiler-plate code in the
device driver setup path.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: Remove get_bytes_per_datum() from iio_buffer_access_funcs

There haven't been any users of the get_bytes_per_datum() callback for a
while. The core assumes that the number of bytes per datum can be calculated
based on the enabled channels and the storage size of the channel and
iio_compute_scan_bytes() is used to compute this number. So remove the
callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: buffer: Allocate standard attributes in the core

All buffers want at least the length and the enable attribute. Move the
creation of those attributes to the core instead of having to do this in
each individual buffer implementation. This allows us to get rid of some
boiler-plate code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: buffer: Make length attribute read only for buffers without set_length

If a buffer implementation does not implement the set_length() callback the
length will be static and can not be changed by userspace. Mark the length
attribute as a read only property in this case so userspace is aware of this
rather than just silently accepting any length value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: buffer: Drop get_length callback

The buffer length field is supposed to have the current length of the
buffer. Having a separate get_length callback doesn't seem to add much value
and all implementations just return buffer->length (or a static value). So
remove the callback and just use buffer->length directly in the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Revert "spi: cadence: Fix encoded CS mode"

This reverts commit eff2ab05a41f65e52679e630da7d5046a69bc4bc.
spi: cadence: Fix 3-to-8 mux mode

In 3-to-8 mux mode for the CS pins we need to set the PERI_SEL bit in the
control register. Currently the driver never sets this bit even when
configured for 3-to-8 mux mode. This patch adds code which sets the bit
during device initialization when necessary.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>