.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * BMG160 Gyro Sensor driver |
---|
3 | 4 | * Copyright (c) 2014, Intel Corporation. |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify it |
---|
6 | | - * under the terms and conditions of the GNU General Public License, |
---|
7 | | - * version 2, as published by the Free Software Foundation. |
---|
8 | | - * |
---|
9 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
---|
10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
12 | | - * more details. |
---|
13 | 5 | */ |
---|
14 | 6 | |
---|
15 | 7 | #include <linux/module.h> |
---|
.. | .. |
---|
102 | 94 | struct regmap *regmap; |
---|
103 | 95 | struct iio_trigger *dready_trig; |
---|
104 | 96 | struct iio_trigger *motion_trig; |
---|
| 97 | + struct iio_mount_matrix orientation; |
---|
105 | 98 | struct mutex mutex; |
---|
106 | 99 | /* Ensure naturally aligned timestamp */ |
---|
107 | 100 | struct { |
---|
.. | .. |
---|
798 | 791 | return 0; |
---|
799 | 792 | } |
---|
800 | 793 | |
---|
| 794 | +static const struct iio_mount_matrix * |
---|
| 795 | +bmg160_get_mount_matrix(const struct iio_dev *indio_dev, |
---|
| 796 | + const struct iio_chan_spec *chan) |
---|
| 797 | +{ |
---|
| 798 | + struct bmg160_data *data = iio_priv(indio_dev); |
---|
| 799 | + |
---|
| 800 | + return &data->orientation; |
---|
| 801 | +} |
---|
| 802 | + |
---|
| 803 | +static const struct iio_chan_spec_ext_info bmg160_ext_info[] = { |
---|
| 804 | + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bmg160_get_mount_matrix), |
---|
| 805 | + { } |
---|
| 806 | +}; |
---|
| 807 | + |
---|
801 | 808 | static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100 200 400 1000 2000"); |
---|
802 | 809 | |
---|
803 | 810 | static IIO_CONST_ATTR(in_anglvel_scale_available, |
---|
.. | .. |
---|
835 | 842 | .storagebits = 16, \ |
---|
836 | 843 | .endianness = IIO_LE, \ |
---|
837 | 844 | }, \ |
---|
| 845 | + .ext_info = bmg160_ext_info, \ |
---|
838 | 846 | .event_spec = &bmg160_event, \ |
---|
839 | 847 | .num_event_specs = 1 \ |
---|
840 | 848 | } |
---|
.. | .. |
---|
1047 | 1055 | |
---|
1048 | 1056 | static const struct iio_buffer_setup_ops bmg160_buffer_setup_ops = { |
---|
1049 | 1057 | .preenable = bmg160_buffer_preenable, |
---|
1050 | | - .postenable = iio_triggered_buffer_postenable, |
---|
1051 | | - .predisable = iio_triggered_buffer_predisable, |
---|
1052 | 1058 | .postdisable = bmg160_buffer_postdisable, |
---|
1053 | 1059 | }; |
---|
1054 | 1060 | |
---|
.. | .. |
---|
1079 | 1085 | data->irq = irq; |
---|
1080 | 1086 | data->regmap = regmap; |
---|
1081 | 1087 | |
---|
| 1088 | + ret = iio_read_mount_matrix(dev, "mount-matrix", |
---|
| 1089 | + &data->orientation); |
---|
| 1090 | + if (ret) |
---|
| 1091 | + return ret; |
---|
| 1092 | + |
---|
1082 | 1093 | ret = bmg160_chip_init(data); |
---|
1083 | 1094 | if (ret < 0) |
---|
1084 | 1095 | return ret; |
---|
.. | .. |
---|
1088 | 1099 | if (ACPI_HANDLE(dev)) |
---|
1089 | 1100 | name = bmg160_match_acpi_device(dev); |
---|
1090 | 1101 | |
---|
1091 | | - indio_dev->dev.parent = dev; |
---|
1092 | 1102 | indio_dev->channels = bmg160_channels; |
---|
1093 | 1103 | indio_dev->num_channels = ARRAY_SIZE(bmg160_channels); |
---|
1094 | 1104 | indio_dev->name = name; |
---|
.. | .. |
---|
1160 | 1170 | ret = iio_device_register(indio_dev); |
---|
1161 | 1171 | if (ret < 0) { |
---|
1162 | 1172 | dev_err(dev, "unable to register iio device\n"); |
---|
1163 | | - goto err_buffer_cleanup; |
---|
| 1173 | + goto err_pm_cleanup; |
---|
1164 | 1174 | } |
---|
1165 | 1175 | |
---|
1166 | 1176 | return 0; |
---|
1167 | 1177 | |
---|
| 1178 | +err_pm_cleanup: |
---|
| 1179 | + pm_runtime_dont_use_autosuspend(dev); |
---|
| 1180 | + pm_runtime_disable(dev); |
---|
1168 | 1181 | err_buffer_cleanup: |
---|
1169 | 1182 | iio_triggered_buffer_cleanup(indio_dev); |
---|
1170 | 1183 | err_trigger_unregister: |
---|