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

Fixes the hts221 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-08 15:47:32 -06:00 committed by Carles Cufí
parent 73ddc98ea0
commit 466c5501bc
2 changed files with 3 additions and 3 deletions

View file

@ -43,7 +43,7 @@ struct hts221_data {
const struct device *dev;
struct gpio_callback drdy_cb;
struct sensor_trigger data_ready_trigger;
const struct sensor_trigger *data_ready_trigger;
sensor_trigger_handler_t data_ready_handler;
#if defined(CONFIG_HTS221_TRIGGER_OWN_THREAD)

View file

@ -45,7 +45,7 @@ static void process_drdy(const struct device *dev)
struct hts221_data *data = dev->data;
if (data->data_ready_handler != NULL) {
data->data_ready_handler(dev, &data->data_ready_trigger);
data->data_ready_handler(dev, data->data_ready_trigger);
}
if (data->data_ready_handler != NULL) {
@ -69,7 +69,7 @@ int hts221_trigger_set(const struct device *dev,
return 0;
}
data->data_ready_trigger = *trig;
data->data_ready_trigger = trig;
setup_drdy(dev, true);