Skip to content

CTRL7 INTERRUPTS_ENABLE missing validation on interrupt route set #3

@KaDw

Description

@KaDw

lis2dw12_pin_int1_route_set() and lis2dw12_pin_int2_route_set() functions besides configuring interrupt routing also set/reset global interrupts enable flag in CTRL7. The issue is not all interrupts are checked and it is possible to have the a valid interrupt flag for specific case enabled while global interrupts enable will be reset.

Here are the conditions for lis2dw12_pin_int1_route_set()

  if (ret == 0)
  {
    if ((val->int1_tap |
         val->int1_ff |
         val->int1_wu |
         val->int1_single_tap |
         val->int1_6d |
         ctrl5_int2_pad_ctrl.int2_sleep_state |
         ctrl5_int2_pad_ctrl.int2_sleep_chg) != PROPERTY_DISABLE)
    {
      reg.interrupts_enable = PROPERTY_ENABLE;
    }

    else
    {
      reg.interrupts_enable = PROPERTY_DISABLE;
    }

lis2dw12_pin_int2_route_set() :

  if (ret == 0)
  {
    if ((ctrl4_int1_pad_ctrl.int1_tap |
         ctrl4_int1_pad_ctrl.int1_ff |
         ctrl4_int1_pad_ctrl.int1_wu |
         ctrl4_int1_pad_ctrl.int1_single_tap |
         ctrl4_int1_pad_ctrl.int1_6d |
         val->int2_sleep_state | val->int2_sleep_chg) != PROPERTY_DISABLE)
    {
      reg.interrupts_enable = PROPERTY_ENABLE;
    }

    else
    {
      reg.interrupts_enable = PROPERTY_DISABLE;
    }

Consider scenario where INT1 is configured for wake-up (int1_wu) and INT2 for fifo threshold (int2_fth). Now if the user wants to disable int1_wu, the int2_fth won't be checked by the condition in the code snippet above. This results in resetting CTRL7 interrupts enable flag even though there is an interrupt enabled!

In my opinion the interrupts should be disabled only when both CTRL4_INT1_PAD_CTRL or CTRL5_INT2_PAD_CTRL are zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions