From: Hans de Goede Date: Tue, 8 Feb 2022 12:43:36 +0000 (+0100) Subject: iio: mma8452: Add support for the "mount-matrix" device property X-Git-Tag: v6.6.17~7878^2~55^2~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b863f2e3a83f990752410851ab02a36c8c740008;p=platform%2Fkernel%2Flinux-rpi.git iio: mma8452: Add support for the "mount-matrix" device property Add support for the standard "mount-matrix" device property to the mma8452 driver. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20220208124336.511884-2-hdegoede@redhat.com Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 09c82ab..6ea1070 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -104,6 +104,7 @@ struct mma8452_data { struct i2c_client *client; struct mutex lock; + struct iio_mount_matrix orientation; u8 ctrl_reg1; u8 data_cfg; const struct mma_chip_info *chip_info; @@ -1190,6 +1191,20 @@ static const struct attribute_group mma8452_event_attribute_group = { .attrs = mma8452_event_attributes, }; +static const struct iio_mount_matrix * +mma8452_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct mma8452_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info mma8452_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, mma8452_get_mount_matrix), + { } +}; + #define MMA8452_FREEFALL_CHANNEL(modifier) { \ .type = IIO_ACCEL, \ .modified = 1, \ @@ -1228,6 +1243,7 @@ static const struct attribute_group mma8452_event_attribute_group = { }, \ .event_spec = mma8452_transient_event, \ .num_event_specs = ARRAY_SIZE(mma8452_transient_event), \ + .ext_info = mma8452_ext_info, \ } #define MMA8652_CHANNEL(axis, idx, bits) { \ @@ -1249,6 +1265,7 @@ static const struct attribute_group mma8452_event_attribute_group = { }, \ .event_spec = mma8452_motion_event, \ .num_event_specs = ARRAY_SIZE(mma8452_motion_event), \ + .ext_info = mma8452_ext_info, \ } static const struct iio_chan_spec mma8451_channels[] = { @@ -1546,6 +1563,10 @@ static int mma8452_probe(struct i2c_client *client, return -ENODEV; } + ret = iio_read_mount_matrix(&client->dev, &data->orientation); + if (ret) + return ret; + data->vdd_reg = devm_regulator_get(&client->dev, "vdd"); if (IS_ERR(data->vdd_reg)) return dev_err_probe(&client->dev, PTR_ERR(data->vdd_reg),