Skip to content
Permalink
Browse files

drivers: adxl362: don't skip mutex unlocking in error path

The default case of the switch statement jumps over the unlocking of the
trigger mutex. This has been fixed with more granular locking which has
the added benefit of being more explicit about what is being protected.

Signed-off-by: Brett Witherspoon <spoonb@cdspooner.com>
  • Loading branch information...
bwitherspoon authored and MaureenHelm committed May 5, 2019
1 parent 29deef2 commit ae9905232c42bfb39fb1b7ce47f315219facf753
Showing with 4 additions and 2 deletions.
  1. +4 −2 drivers/sensor/adxl362/adxl362_trigger.c
@@ -96,25 +96,27 @@ int adxl362_trigger_set(struct device *dev,

gpio_pin_disable_callback(drv_data->gpio, cfg->int_gpio);

k_mutex_lock(&drv_data->trigger_mutex, K_FOREVER);
switch (trig->type) {
case SENSOR_TRIG_THRESHOLD:
k_mutex_lock(&drv_data->trigger_mutex, K_FOREVER);
drv_data->th_handler = handler;
drv_data->th_trigger = *trig;
k_mutex_unlock(&drv_data->trigger_mutex);
int_mask = ADXL362_INTMAP1_ACT |
ADXL362_INTMAP1_INACT;
break;
case SENSOR_TRIG_DATA_READY:
k_mutex_lock(&drv_data->trigger_mutex, K_FOREVER);
drv_data->drdy_handler = handler;
drv_data->drdy_trigger = *trig;
k_mutex_unlock(&drv_data->trigger_mutex);
int_mask = ADXL362_INTMAP1_DATA_READY;
break;
default:
LOG_ERR("Unsupported sensor trigger");
ret = -ENOTSUP;
goto out;
}
k_mutex_unlock(&drv_data->trigger_mutex);

if (handler) {
int_en = int_mask;

0 comments on commit ae99052

Please sign in to comment.
You can’t perform that action at this time.