sensor: adxl3xx: Move run-time modification of ODR from cfg to data
Config struct is constant and attempting to modify it triggers a fault. Signed-off-by: Luis Ubieda <luisf@croxel.com>
This commit is contained in:
parent
0a71e95c5a
commit
5a9ff03c21
6 changed files with 8 additions and 6 deletions
|
@ -229,7 +229,7 @@ static int adxl345_attr_set_odr(const struct device *dev,
|
|||
const struct sensor_value *val)
|
||||
{
|
||||
enum adxl345_odr odr;
|
||||
struct adxl345_dev_config *cfg = (struct adxl345_dev_config *)dev->config;
|
||||
struct adxl345_dev_data *data = dev->data;
|
||||
|
||||
switch (val->val1) {
|
||||
case 12:
|
||||
|
@ -257,7 +257,7 @@ static int adxl345_attr_set_odr(const struct device *dev,
|
|||
int ret = adxl345_set_odr(dev, odr);
|
||||
|
||||
if (ret == 0) {
|
||||
cfg->odr = odr;
|
||||
data->odr = odr;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -156,6 +156,7 @@ struct adxl345_dev_data {
|
|||
struct adxl345_fifo_config fifo_config;
|
||||
uint8_t is_full_res;
|
||||
uint8_t selected_range;
|
||||
enum adxl345_odr odr;
|
||||
#ifdef CONFIG_ADXL345_TRIGGER
|
||||
struct gpio_callback gpio_cb;
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ static void adxl345_process_fifo_samples_cb(struct rtio *r, const struct rtio_sq
|
|||
hdr->int_status = data->status1;
|
||||
hdr->is_full_res = data->is_full_res;
|
||||
hdr->selected_range = data->selected_range;
|
||||
hdr->accel_odr = cfg->odr;
|
||||
hdr->accel_odr = data->odr;
|
||||
hdr->sample_set_size = sample_set_size;
|
||||
|
||||
uint32_t buf_avail = buf_len;
|
||||
|
|
|
@ -550,7 +550,7 @@ static int adxl372_attr_set_odr(const struct device *dev,
|
|||
const struct sensor_value *val)
|
||||
{
|
||||
enum adxl372_odr odr;
|
||||
struct adxl372_dev_config *cfg = (struct adxl372_dev_config *)dev->config;
|
||||
struct adxl372_data *data = dev->data;
|
||||
|
||||
switch (val->val1) {
|
||||
case 400:
|
||||
|
@ -575,7 +575,7 @@ static int adxl372_attr_set_odr(const struct device *dev,
|
|||
int ret = adxl372_set_odr(dev, odr);
|
||||
|
||||
if (ret == 0) {
|
||||
cfg->odr = odr;
|
||||
data->odr = odr;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -312,6 +312,7 @@ struct adxl372_data {
|
|||
const struct adxl372_transfer_function *hw_tf;
|
||||
struct adxl372_fifo_config fifo_config;
|
||||
enum adxl372_act_proc_mode act_proc_mode;
|
||||
enum adxl372_odr odr;
|
||||
#ifdef CONFIG_ADXL372_TRIGGER
|
||||
struct gpio_callback gpio_cb;
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ static void adxl372_process_fifo_samples_cb(struct rtio *r, const struct rtio_sq
|
|||
hdr->is_fifo = 1;
|
||||
hdr->timestamp = data->timestamp;
|
||||
hdr->int_status = data->status1;
|
||||
hdr->accel_odr = cfg->odr;
|
||||
hdr->accel_odr = data->odr;
|
||||
hdr->sample_set_size = sample_set_size;
|
||||
|
||||
if ((cfg->fifo_config.fifo_format == ADXL372_X_FIFO) ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue