drivers: sensor: mpu9250: Store sensor trigger as a pointer

Fixes the mpu9250 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
This commit is contained in:
Maureen Helm 2023-04-07 15:41:28 -05:00 committed by Carles Cufí
parent b7e97e2807
commit 19b9bb800a
2 changed files with 3 additions and 3 deletions

View file

@ -41,7 +41,7 @@ struct mpu9250_data {
const struct device *dev;
struct gpio_callback gpio_cb;
struct sensor_trigger data_ready_trigger;
const struct sensor_trigger *data_ready_trigger;
sensor_trigger_handler_t data_ready_handler;
#if defined(CONFIG_MPU9250_TRIGGER_OWN_THREAD)

View file

@ -39,7 +39,7 @@ int mpu9250_trigger_set(const struct device *dev,
return 0;
}
drv_data->data_ready_trigger = *trig;
drv_data->data_ready_trigger = trig;
ret = gpio_pin_interrupt_configure_dt(&cfg->int_pin,
GPIO_INT_EDGE_TO_ACTIVE);
@ -82,7 +82,7 @@ static void mpu9250_thread_cb(const struct device *dev)
if (drv_data->data_ready_handler != NULL) {
drv_data->data_ready_handler(dev,
&drv_data->data_ready_trigger);
drv_data->data_ready_trigger);
}
ret = gpio_pin_interrupt_configure_dt(&cfg->int_pin,