diff options
author | Irina Tirdea <irina.tirdea@intel.com> | 2016-03-24 05:29:28 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-04-03 05:27:44 -0400 |
commit | ee8c5419e06e3a002995f5d1f57c9b5aead331e6 (patch) | |
tree | 84a704d6bee1e040d9d2c3cc644a4ffcda107320 /drivers/iio | |
parent | 1715e0ccd3b8cd4c1ee76076e1e7452b113be193 (diff) |
iio: gyro: bmg160: use available_scan_masks
Use available_scan_masks to allow the iio core to select
the data to send to userspace depending on which axes are
enabled, instead of doing this in the driver's interrupt
handler.
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/gyro/bmg160_core.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index bbce3b09ac45..8d6e5b132016 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c | |||
@@ -116,6 +116,7 @@ enum bmg160_axis { | |||
116 | AXIS_X, | 116 | AXIS_X, |
117 | AXIS_Y, | 117 | AXIS_Y, |
118 | AXIS_Z, | 118 | AXIS_Z, |
119 | AXIS_MAX, | ||
119 | }; | 120 | }; |
120 | 121 | ||
121 | static const struct { | 122 | static const struct { |
@@ -763,6 +764,10 @@ static const struct iio_info bmg160_info = { | |||
763 | .driver_module = THIS_MODULE, | 764 | .driver_module = THIS_MODULE, |
764 | }; | 765 | }; |
765 | 766 | ||
767 | static const unsigned long bmg160_accel_scan_masks[] = { | ||
768 | BIT(AXIS_X) | BIT(AXIS_Y) | BIT(AXIS_Z), | ||
769 | 0}; | ||
770 | |||
766 | static irqreturn_t bmg160_trigger_handler(int irq, void *p) | 771 | static irqreturn_t bmg160_trigger_handler(int irq, void *p) |
767 | { | 772 | { |
768 | struct iio_poll_func *pf = p; | 773 | struct iio_poll_func *pf = p; |
@@ -772,8 +777,7 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p) | |||
772 | unsigned int val; | 777 | unsigned int val; |
773 | 778 | ||
774 | mutex_lock(&data->mutex); | 779 | mutex_lock(&data->mutex); |
775 | for_each_set_bit(bit, indio_dev->active_scan_mask, | 780 | for (bit = 0; bit < AXIS_MAX; bit++) { |
776 | indio_dev->masklength) { | ||
777 | ret = regmap_bulk_read(data->regmap, BMG160_AXIS_TO_REG(bit), | 781 | ret = regmap_bulk_read(data->regmap, BMG160_AXIS_TO_REG(bit), |
778 | &val, 2); | 782 | &val, 2); |
779 | if (ret < 0) { | 783 | if (ret < 0) { |
@@ -1019,6 +1023,7 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, | |||
1019 | indio_dev->channels = bmg160_channels; | 1023 | indio_dev->channels = bmg160_channels; |
1020 | indio_dev->num_channels = ARRAY_SIZE(bmg160_channels); | 1024 | indio_dev->num_channels = ARRAY_SIZE(bmg160_channels); |
1021 | indio_dev->name = name; | 1025 | indio_dev->name = name; |
1026 | indio_dev->available_scan_masks = bmg160_accel_scan_masks; | ||
1022 | indio_dev->modes = INDIO_DIRECT_MODE; | 1027 | indio_dev->modes = INDIO_DIRECT_MODE; |
1023 | indio_dev->info = &bmg160_info; | 1028 | indio_dev->info = &bmg160_info; |
1024 | 1029 | ||