Skip to content

Commit 9a8ecf0

Browse files
aviscontikartben
authored andcommitted
sensor: lsm6dsv16x: fix place where gyro_freq get set
Move gyro_freq setting inside lsm6dsv16x_gyro_set_odr_raw() routine, so that it is properly saved in all cases (i.e. from DT configuration and from runtime ATTR set case). Signed-off-by: Armando Visconti <[email protected]>
1 parent 1fac1b9 commit 9a8ecf0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/sensor/st/lsm6dsv16x/lsm6dsv16x.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,13 @@ static int lsm6dsv16x_gyro_set_odr_raw(const struct device *dev, uint8_t odr)
198198
{
199199
const struct lsm6dsv16x_config *cfg = dev->config;
200200
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
201+
struct lsm6dsv16x_data *data = dev->data;
201202

202203
if (lsm6dsv16x_gy_data_rate_set(ctx, odr) < 0) {
203204
return -EIO;
204205
}
205206

207+
data->gyro_freq = odr;
206208
return 0;
207209
}
208210

@@ -1162,7 +1164,6 @@ static int lsm6dsv16x_init_chip(const struct device *dev)
11621164

11631165
odr = cfg->gyro_odr;
11641166
LOG_DBG("gyro odr is %d", odr);
1165-
lsm6dsv16x->gyro_freq = odr;
11661167
if (lsm6dsv16x_gyro_set_odr_raw(dev, odr) < 0) {
11671168
LOG_ERR("failed to set gyroscope odr %d", odr);
11681169
return -EIO;

0 commit comments

Comments
 (0)