From 466c5501bce7a4429fb44f5423c75a18c4c1f075 Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Wed, 8 Mar 2023 15:47:32 -0600 Subject: [PATCH] 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 --- drivers/sensor/hts221/hts221.h | 2 +- drivers/sensor/hts221/hts221_trigger.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/sensor/hts221/hts221.h b/drivers/sensor/hts221/hts221.h index a20f57a173..e0af57c132 100644 --- a/drivers/sensor/hts221/hts221.h +++ b/drivers/sensor/hts221/hts221.h @@ -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) diff --git a/drivers/sensor/hts221/hts221_trigger.c b/drivers/sensor/hts221/hts221_trigger.c index 314b666ab3..404f84d941 100644 --- a/drivers/sensor/hts221/hts221_trigger.c +++ b/drivers/sensor/hts221/hts221_trigger.c @@ -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);