Skip to content

Commit

Permalink
drivers: sensor: wsen_hids: Store sensor trigger as a pointer
Browse files Browse the repository at this point in the history
Fixes the wsen_hids 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 <[email protected]>
  • Loading branch information
MaureenHelm authored and carlescufi committed Apr 8, 2023
1 parent 0780245 commit cb28e83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/sensor/wsen_hids/wsen_hids.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct hids_data {
const struct device *dev;
struct gpio_callback data_ready_cb;

struct sensor_trigger data_ready_trigger;
const struct sensor_trigger *data_ready_trigger;
sensor_trigger_handler_t data_ready_handler;

#if defined(CONFIG_WSEN_HIDS_TRIGGER_OWN_THREAD)
Expand Down
4 changes: 2 additions & 2 deletions drivers/sensor/wsen_hids/wsen_hids_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void hids_process_drdy_interrupt(const struct device *dev)
struct hids_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) {
Expand All @@ -64,7 +64,7 @@ int hids_trigger_set(const struct device *dev, const struct sensor_trigger *trig
return 0;
}

data->data_ready_trigger = *trig;
data->data_ready_trigger = trig;

hids_setup_drdy_interrupt(dev, true);

Expand Down

0 comments on commit cb28e83

Please sign in to comment.