Skip to content
  1. Mar 10, 2017
    • Gregory Nutt's avatar
      Cosmetic · a93e46d0
      Gregory Nutt authored
      a93e46d0
    • Freddie Chopin's avatar
      ave elapsed time before handling I2C in stm32_i2c_sem_waitstop() · 3cd66af8
      Freddie Chopin authored
      This patch follows the same logic as in previous fix to
      stm32_i2c_sem_waitdone().
      
      It is possible that a context switch occurs after I2C registers are read
      but before elapsed time is saved in stm32_i2c_sem_waitstop(). It is then
      possible that the registers were read only once with "elapsed time"
      equal 0. When scheduler resumes this thread it is quite possible that
      now "elapsed time" will be well above timeout threshold. In that case
      the function returns and reports a timeout, even though the registers
      were not read "recently".
      
      Fix this by inverting the order of operations in the loop - save elapsed
      time before reading registers. This way a context switch anywhere in the
      loop will not cause an erroneous "timeout" error.
      3cd66af8
  2. Mar 09, 2017