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

Fixes the bmc150_magn 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-03-07 13:03:35 -06:00 committed by Carles Cufí
parent ad07044679
commit 7875025cdb
2 changed files with 3 additions and 3 deletions

View file

@ -120,7 +120,7 @@ struct bmc150_magn_data {
const struct device *gpio_drdy;
const struct device *dev;
struct gpio_callback gpio_cb;
struct sensor_trigger trigger_drdy;
const struct sensor_trigger *trigger_drdy;
sensor_trigger_handler_t handler_drdy;
#endif

View file

@ -49,7 +49,7 @@ int bmc150_magn_trigger_set(const struct device *dev,
}
data->handler_drdy = handler;
data->trigger_drdy = *trig;
data->trigger_drdy = trig;
if (i2c_reg_update_byte_dt(&config->i2c,
BMC150_MAGN_REG_INT_DRDY,
@ -96,7 +96,7 @@ static void bmc150_magn_thread_main(struct bmc150_magn_data *data)
}
if (data->handler_drdy) {
data->handler_drdy(data->dev, &data->trigger_drdy);
data->handler_drdy(data->dev, data->trigger_drdy);
}
setup_drdy(data->dev, true);