diff options
author | H. Nikolaus Schaller <hns@goldelico.com> | 2019-02-21 18:02:52 +0100 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-04-04 20:19:48 +0100 |
commit | d9842c770a47e35a3264359989fff69d58e5cbaa (patch) | |
tree | cf9c505ce9f4b4618b3fdb61708772cce5e86633 /drivers/iio/magnetometer | |
parent | 70b5fdbb2eaea57e3025081b1dfbabf12a4d91ee (diff) | |
download | lwn-d9842c770a47e35a3264359989fff69d58e5cbaa.tar.gz lwn-d9842c770a47e35a3264359989fff69d58e5cbaa.zip |
iio: magnetometer: bmc150: add mount matrix support
This patch allows to read a mount-matrix device tree
property and report to user-space or in-kernel iio
clients.
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/magnetometer')
-rw-r--r-- | drivers/iio/magnetometer/bmc150_magn.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index d91cb845e3d6..b0d8b036d9bb 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -143,6 +143,7 @@ struct bmc150_magn_data { */ struct mutex mutex; struct regmap *regmap; + struct iio_mount_matrix orientation; /* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */ s32 buffer[6]; struct iio_trigger *dready_trig; @@ -612,6 +613,20 @@ static ssize_t bmc150_magn_show_samp_freq_avail(struct device *dev, return len; } +static const struct iio_mount_matrix * +bmc150_magn_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct bmc150_magn_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info bmc150_magn_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bmc150_magn_get_mount_matrix), + { } +}; + static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(bmc150_magn_show_samp_freq_avail); static struct attribute *bmc150_magn_attributes[] = { @@ -638,6 +653,7 @@ static const struct attribute_group bmc150_magn_attrs_group = { .storagebits = 32, \ .endianness = IIO_LE \ }, \ + .ext_info = bmc150_magn_ext_info, \ } static const struct iio_chan_spec bmc150_magn_channels[] = { @@ -861,6 +877,11 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap, data->irq = irq; data->dev = dev; + ret = iio_read_mount_matrix(dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + if (!name && ACPI_HANDLE(dev)) name = bmc150_magn_match_acpi_device(dev); |