Skip to content

Commit 24af824

Browse files
dlechjic23
authored andcommitted
iio: imu: bno055: make bno055_sysfs_attr const
Add const qualifier to struct bno055_sysfs_attr and its array fields. All of this is read-only data so it can be made const. Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250628-iio-const-data-19-v1-1-a17e7c16b122@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 1e5b514 commit 24af824

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

drivers/iio/imu/bno055/bno055.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,31 +114,31 @@
114114
#define BNO055_UID_LEN 16
115115

116116
struct bno055_sysfs_attr {
117-
int *vals;
117+
const int *vals;
118118
int len;
119-
int *fusion_vals;
120-
int *hw_xlate;
119+
const int *fusion_vals;
120+
const int *hw_xlate;
121121
int type;
122122
};
123123

124-
static int bno055_acc_lpf_vals[] = {
124+
static const int bno055_acc_lpf_vals[] = {
125125
7, 810000, 15, 630000, 31, 250000, 62, 500000,
126126
125, 0, 250, 0, 500, 0, 1000, 0,
127127
};
128128

129-
static struct bno055_sysfs_attr bno055_acc_lpf = {
129+
static const struct bno055_sysfs_attr bno055_acc_lpf = {
130130
.vals = bno055_acc_lpf_vals,
131131
.len = ARRAY_SIZE(bno055_acc_lpf_vals),
132-
.fusion_vals = (int[]){62, 500000},
132+
.fusion_vals = (const int[]){62, 500000},
133133
.type = IIO_VAL_INT_PLUS_MICRO,
134134
};
135135

136-
static int bno055_acc_range_vals[] = {
136+
static const int bno055_acc_range_vals[] = {
137137
/* G: 2, 4, 8, 16 */
138138
1962, 3924, 7848, 15696
139139
};
140140

141-
static struct bno055_sysfs_attr bno055_acc_range = {
141+
static const struct bno055_sysfs_attr bno055_acc_range = {
142142
.vals = bno055_acc_range_vals,
143143
.len = ARRAY_SIZE(bno055_acc_range_vals),
144144
.fusion_vals = (int[]){3924}, /* 4G */
@@ -165,33 +165,33 @@ static struct bno055_sysfs_attr bno055_acc_range = {
165165
* = hwval * (dps_range/(2^15 * k))
166166
* where k is rad-to-deg factor
167167
*/
168-
static int bno055_gyr_scale_vals[] = {
168+
static const int bno055_gyr_scale_vals[] = {
169169
125, 1877467, 250, 1877467, 500, 1877467,
170170
1000, 1877467, 2000, 1877467,
171171
};
172172

173-
static struct bno055_sysfs_attr bno055_gyr_scale = {
173+
static const struct bno055_sysfs_attr bno055_gyr_scale = {
174174
.vals = bno055_gyr_scale_vals,
175175
.len = ARRAY_SIZE(bno055_gyr_scale_vals),
176-
.fusion_vals = (int[]){1, 900},
177-
.hw_xlate = (int[]){4, 3, 2, 1, 0},
176+
.fusion_vals = (const int[]){1, 900},
177+
.hw_xlate = (const int[]){4, 3, 2, 1, 0},
178178
.type = IIO_VAL_FRACTIONAL,
179179
};
180180

181-
static int bno055_gyr_lpf_vals[] = {12, 23, 32, 47, 64, 116, 230, 523};
182-
static struct bno055_sysfs_attr bno055_gyr_lpf = {
181+
static const int bno055_gyr_lpf_vals[] = {12, 23, 32, 47, 64, 116, 230, 523};
182+
static const struct bno055_sysfs_attr bno055_gyr_lpf = {
183183
.vals = bno055_gyr_lpf_vals,
184184
.len = ARRAY_SIZE(bno055_gyr_lpf_vals),
185-
.fusion_vals = (int[]){32},
186-
.hw_xlate = (int[]){5, 4, 7, 3, 6, 2, 1, 0},
185+
.fusion_vals = (const int[]){32},
186+
.hw_xlate = (const int[]){5, 4, 7, 3, 6, 2, 1, 0},
187187
.type = IIO_VAL_INT,
188188
};
189189

190-
static int bno055_mag_odr_vals[] = {2, 6, 8, 10, 15, 20, 25, 30};
191-
static struct bno055_sysfs_attr bno055_mag_odr = {
190+
static const int bno055_mag_odr_vals[] = {2, 6, 8, 10, 15, 20, 25, 30};
191+
static const struct bno055_sysfs_attr bno055_mag_odr = {
192192
.vals = bno055_mag_odr_vals,
193193
.len = ARRAY_SIZE(bno055_mag_odr_vals),
194-
.fusion_vals = (int[]){20},
194+
.fusion_vals = (const int[]){20},
195195
.type = IIO_VAL_INT,
196196
};
197197

@@ -548,7 +548,8 @@ static const struct iio_chan_spec bno055_channels[] = {
548548
};
549549

550550
static int bno055_get_regmask(struct bno055_priv *priv, int *val, int *val2,
551-
int reg, int mask, struct bno055_sysfs_attr *attr)
551+
int reg, int mask,
552+
const struct bno055_sysfs_attr *attr)
552553
{
553554
const int shift = __ffs(mask);
554555
int hwval, idx;
@@ -577,7 +578,8 @@ static int bno055_get_regmask(struct bno055_priv *priv, int *val, int *val2,
577578
}
578579

579580
static int bno055_set_regmask(struct bno055_priv *priv, int val, int val2,
580-
int reg, int mask, struct bno055_sysfs_attr *attr)
581+
int reg, int mask,
582+
const struct bno055_sysfs_attr *attr)
581583
{
582584
const int shift = __ffs(mask);
583585
int best_delta;
@@ -758,7 +760,8 @@ static int bno055_read_simple_chan(struct iio_dev *indio_dev,
758760
}
759761
}
760762

761-
static int bno055_sysfs_attr_avail(struct bno055_priv *priv, struct bno055_sysfs_attr *attr,
763+
static int bno055_sysfs_attr_avail(struct bno055_priv *priv,
764+
const struct bno055_sysfs_attr *attr,
762765
const int **vals, int *length)
763766
{
764767
if (priv->operation_mode != BNO055_OPR_MODE_AMG) {

0 commit comments

Comments
 (0)