Add a scan_mask and scan_index to the iio channel. The scan_index
prepares the buffer usage. According to the datasheet, the ADXL313
uses 13 bit in full resolution. Add signedness, storage bits and
endianness.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
drivers/iio/accel/adxl313_core.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
index 2f26da5857d4..06a771bb4726 100644
--- a/drivers/iio/accel/adxl313_core.c
+++ b/drivers/iio/accel/adxl313_core.c
@@ -171,9 +171,10 @@ static const int adxl313_odr_freqs[][2] = {
[9] = { 3200, 0 },
};
-#define ADXL313_ACCEL_CHANNEL(index, axis) { \
+#define ADXL313_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
- .address = index, \
+ .scan_index = (index), \
+ .address = (reg), \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
@@ -183,14 +184,26 @@ static const int adxl313_odr_freqs[][2] = {
.info_mask_shared_by_type_available = \
BIT(IIO_CHAN_INFO_SAMP_FREQ), \
.scan_type = { \
+ .sign = 's', \
.realbits = 13, \
+ .storagebits = 16, \
+ .endianness = IIO_BE, \
}, \
}
+enum adxl313_chans {
+ chan_x, chan_y, chan_z,
+};
+
static const struct iio_chan_spec adxl313_channels[] = {
- ADXL313_ACCEL_CHANNEL(0, X),
- ADXL313_ACCEL_CHANNEL(1, Y),
- ADXL313_ACCEL_CHANNEL(2, Z),
+ ADXL313_ACCEL_CHANNEL(0, chan_x, X),
+ ADXL313_ACCEL_CHANNEL(1, chan_y, Y),
+ ADXL313_ACCEL_CHANNEL(2, chan_z, Z),
+};
+
+static const unsigned long adxl313_scan_masks[] = {
+ BIT(chan_x) | BIT(chan_y) | BIT(chan_z),
+ 0
};
static int adxl313_set_odr(struct adxl313_data *data,
@@ -419,6 +432,7 @@ int adxl313_core_probe(struct device *dev,
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = adxl313_channels;
indio_dev->num_channels = ARRAY_SIZE(adxl313_channels);
+ indio_dev->available_scan_masks = adxl313_scan_masks;
ret = adxl313_setup(dev, data, setup);
if (ret) {
--
2.39.5
On Sun, 1 Jun 2025 17:21:30 +0000
Lothar Rubusch <l.rubusch@gmail.com> wrote:
> Add a scan_mask and scan_index to the iio channel. The scan_index
> prepares the buffer usage. According to the datasheet, the ADXL313
> uses 13 bit in full resolution. Add signedness, storage bits and
> endianness.
>
> Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
I'd normally expect to see this in the same patch where it is first used.
There is little benefit in adding unused data on it's own - so combine this
with patch 6. If there was something particularly unusual to discuss
and highlight for review, a separate patch might make sense, but I'm not
seeing that here.
Jonathan
> ---
> drivers/iio/accel/adxl313_core.c | 24 +++++++++++++++++++-----
> 1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
> index 2f26da5857d4..06a771bb4726 100644
> --- a/drivers/iio/accel/adxl313_core.c
> +++ b/drivers/iio/accel/adxl313_core.c
> @@ -171,9 +171,10 @@ static const int adxl313_odr_freqs[][2] = {
> [9] = { 3200, 0 },
> };
>
> -#define ADXL313_ACCEL_CHANNEL(index, axis) { \
> +#define ADXL313_ACCEL_CHANNEL(index, reg, axis) { \
> .type = IIO_ACCEL, \
> - .address = index, \
> + .scan_index = (index), \
> + .address = (reg), \
> .modified = 1, \
> .channel2 = IIO_MOD_##axis, \
> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> @@ -183,14 +184,26 @@ static const int adxl313_odr_freqs[][2] = {
> .info_mask_shared_by_type_available = \
> BIT(IIO_CHAN_INFO_SAMP_FREQ), \
> .scan_type = { \
> + .sign = 's', \
> .realbits = 13, \
> + .storagebits = 16, \
> + .endianness = IIO_BE, \
> }, \
> }
>
> +enum adxl313_chans {
> + chan_x, chan_y, chan_z,
> +};
> +
> static const struct iio_chan_spec adxl313_channels[] = {
> - ADXL313_ACCEL_CHANNEL(0, X),
> - ADXL313_ACCEL_CHANNEL(1, Y),
> - ADXL313_ACCEL_CHANNEL(2, Z),
> + ADXL313_ACCEL_CHANNEL(0, chan_x, X),
> + ADXL313_ACCEL_CHANNEL(1, chan_y, Y),
> + ADXL313_ACCEL_CHANNEL(2, chan_z, Z),
> +};
> +
> +static const unsigned long adxl313_scan_masks[] = {
> + BIT(chan_x) | BIT(chan_y) | BIT(chan_z),
> + 0
> };
>
> static int adxl313_set_odr(struct adxl313_data *data,
> @@ -419,6 +432,7 @@ int adxl313_core_probe(struct device *dev,
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->channels = adxl313_channels;
> indio_dev->num_channels = ARRAY_SIZE(adxl313_channels);
> + indio_dev->available_scan_masks = adxl313_scan_masks;
>
> ret = adxl313_setup(dev, data, setup);
> if (ret) {
On Sun, Jun 1, 2025 at 8:21 PM Lothar Rubusch <l.rubusch@gmail.com> wrote: > > Add a scan_mask and scan_index to the iio channel. The scan_index IIO > prepares the buffer usage. According to the datasheet, the ADXL313 > uses 13 bit in full resolution. Add signedness, storage bits and bits ...OR... 13-bit wide data field > endianness. -- With Best Regards, Andy Shevchenko
Hi Andy, On Sun, Jun 1, 2025 at 9:08 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > > On Sun, Jun 1, 2025 at 8:21 PM Lothar Rubusch <l.rubusch@gmail.com> wrote: > > > > Add a scan_mask and scan_index to the iio channel. The scan_index > > IIO > > > prepares the buffer usage. According to the datasheet, the ADXL313 > > uses 13 bit in full resolution. Add signedness, storage bits and > > bits > ...OR... > 13-bit wide data field > > > endianness. As this is getting very annoying, I tried to set something up involving checkpatch, codespell and ispell. But I guess w/o grammatical checking. Just, in case, do I miss some simple tooling here, any suggestions? As a consequence, the alternative in the year 2025 is probably using chatGPT for the commit messages and we probably never will have this discussion anymore. Hum... ? > > -- > With Best Regards, > Andy Shevchenko
On Wed, Jun 11, 2025 at 10:01:39AM +0200, Lothar Rubusch wrote: > On Sun, Jun 1, 2025 at 9:08 PM Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: > > > > On Sun, Jun 1, 2025 at 8:21 PM Lothar Rubusch <l.rubusch@gmail.com> wrote: > > > > > > Add a scan_mask and scan_index to the iio channel. The scan_index > > > > IIO > > > > > prepares the buffer usage. According to the datasheet, the ADXL313 > > > uses 13 bit in full resolution. Add signedness, storage bits and > > > > bits > > ...OR... > > 13-bit wide data field > > > > > endianness. > > As this is getting very annoying, I tried to set something up > involving checkpatch, codespell and ispell. But I guess w/o > grammatical checking. Just, in case, do I miss some simple tooling > here, any suggestions? > > As a consequence, the alternative in the year 2025 is probably using > chatGPT for the commit messages and we probably never will have this > discussion anymore. Hum... ? It would be nice to have tool and not waste time on the commit message unification. -- With Best Regards, Andy Shevchenko
© 2016 - 2026 Red Hat, Inc.