iio: magnetometer: ak8975: add scan mask index enum

Add an enum to explicitly define scan mask indexes for the X, Y, Z and
timestamp channels. Also, update the struct iio_chan_spec to use said
enum for the .scan_index parameter.

This prevents magic numbers from obscuring the hardware channel mapping
and improves code style.

No functional change.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
Joshua Crofts 2026-09-20 20:05:26 +02:00 committed by Jonathan Cameron
parent 250db4e304
commit b3f6dc30e2

View File

@ -237,6 +237,13 @@ enum ak_ctrl_mode {
MODE_END,
};
enum ak_chan_index {
AK8975_CHAN_X,
AK8975_CHAN_Y,
AK8975_CHAN_Z,
AK8975_CHAN_TS,
};
struct ak_def {
enum asahi_compass_chipset type;
long (*raw_to_gauss)(u16 data);
@ -842,8 +849,10 @@ static const struct iio_chan_spec_ext_info ak8975_ext_info[] = {
}
static const struct iio_chan_spec ak8975_channels[] = {
AK8975_CHANNEL(X, 0), AK8975_CHANNEL(Y, 1), AK8975_CHANNEL(Z, 2),
IIO_CHAN_SOFT_TIMESTAMP(3),
AK8975_CHANNEL(X, AK8975_CHAN_X),
AK8975_CHANNEL(Y, AK8975_CHAN_Y),
AK8975_CHANNEL(Z, AK8975_CHAN_Z),
IIO_CHAN_SOFT_TIMESTAMP(AK8975_CHAN_TS),
};
static const unsigned long ak8975_scan_masks[] = { 0x7, 0 };