Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTRL7 INTERRUPTS_ENABLE missing validation on interrupt route set #3

Open
KaDw opened this issue Jun 14, 2024 · 0 comments
Open

CTRL7 INTERRUPTS_ENABLE missing validation on interrupt route set #3

KaDw opened this issue Jun 14, 2024 · 0 comments

Comments

@KaDw
Copy link

KaDw commented Jun 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant