diff options
author | Paul Cercueil <paul.cercueil@analog.com> | 2015-05-15 11:18:36 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-05-16 05:58:36 -0400 |
commit | c2a8b623a089d52c199e305e7905829907db8ec8 (patch) | |
tree | 5c9cc6e73c81dd98a7aa6ba6b5b5d47babab3a09 | |
parent | 7323d59862802ca109451eeda9777024a7625509 (diff) |
iio: adis16400: Compute the scan mask from channel indices
We unfortunately can't use ~0UL for the scan mask to indicate that the
only valid scan mask is all channels selected. The IIO core needs the exact
mask to work correctly and not a super-set of it. So calculate the masked
based on the channels that are available for a particular device.
Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Fixes: 5eda3550a3cc ("staging:iio:adis16400: Preallocate transfer message")
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/imu/adis16400.h | 1 | ||||
-rw-r--r-- | drivers/iio/imu/adis16400_core.c | 25 |
2 files changed, 19 insertions, 7 deletions
diff --git a/drivers/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h index 0916bf6b6c31..1e8fd2e81d45 100644 --- a/drivers/iio/imu/adis16400.h +++ b/drivers/iio/imu/adis16400.h | |||
@@ -165,6 +165,7 @@ struct adis16400_state { | |||
165 | int filt_int; | 165 | int filt_int; |
166 | 166 | ||
167 | struct adis adis; | 167 | struct adis adis; |
168 | unsigned long avail_scan_mask[2]; | ||
168 | }; | 169 | }; |
169 | 170 | ||
170 | /* At the moment triggers are only used for ring buffer | 171 | /* At the moment triggers are only used for ring buffer |
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index 7b63788c7d1c..7b06e058b000 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c | |||
@@ -796,11 +796,6 @@ static const struct iio_info adis16400_info = { | |||
796 | .debugfs_reg_access = adis_debugfs_reg_access, | 796 | .debugfs_reg_access = adis_debugfs_reg_access, |
797 | }; | 797 | }; |
798 | 798 | ||
799 | static const unsigned long adis16400_burst_scan_mask[] = { | ||
800 | ~0UL, | ||
801 | 0, | ||
802 | }; | ||
803 | |||
804 | static const char * const adis16400_status_error_msgs[] = { | 799 | static const char * const adis16400_status_error_msgs[] = { |
805 | [ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure", | 800 | [ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure", |
806 | [ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure", | 801 | [ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure", |
@@ -848,6 +843,20 @@ static const struct adis_data adis16400_data = { | |||
848 | BIT(ADIS16400_DIAG_STAT_POWER_LOW), | 843 | BIT(ADIS16400_DIAG_STAT_POWER_LOW), |
849 | }; | 844 | }; |
850 | 845 | ||
846 | static void adis16400_setup_chan_mask(struct adis16400_state *st) | ||
847 | { | ||
848 | const struct adis16400_chip_info *chip_info = st->variant; | ||
849 | unsigned i; | ||
850 | |||
851 | for (i = 0; i < chip_info->num_channels; i++) { | ||
852 | const struct iio_chan_spec *ch = &chip_info->channels[i]; | ||
853 | |||
854 | if (ch->scan_index >= 0 && | ||
855 | ch->scan_index != ADIS16400_SCAN_TIMESTAMP) | ||
856 | st->avail_scan_mask[0] |= BIT(ch->scan_index); | ||
857 | } | ||
858 | } | ||
859 | |||
851 | static int adis16400_probe(struct spi_device *spi) | 860 | static int adis16400_probe(struct spi_device *spi) |
852 | { | 861 | { |
853 | struct adis16400_state *st; | 862 | struct adis16400_state *st; |
@@ -871,8 +880,10 @@ static int adis16400_probe(struct spi_device *spi) | |||
871 | indio_dev->info = &adis16400_info; | 880 | indio_dev->info = &adis16400_info; |
872 | indio_dev->modes = INDIO_DIRECT_MODE; | 881 | indio_dev->modes = INDIO_DIRECT_MODE; |
873 | 882 | ||
874 | if (!(st->variant->flags & ADIS16400_NO_BURST)) | 883 | if (!(st->variant->flags & ADIS16400_NO_BURST)) { |
875 | indio_dev->available_scan_masks = adis16400_burst_scan_mask; | 884 | adis16400_setup_chan_mask(st); |
885 | indio_dev->available_scan_masks = st->avail_scan_mask; | ||
886 | } | ||
876 | 887 | ||
877 | ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data); | 888 | ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data); |
878 | if (ret) | 889 | if (ret) |