iio: trigger: stm32-timer: fix quadrature mode get routine
authorFabrice Gasnier <fabrice.gasnier@st.com>
Thu, 27 Jul 2017 16:18:57 +0000 (18:18 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 30 Jul 2017 13:43:10 +0000 (14:43 +0100)
commit50b39608efb1e60f334f9b59128fd6d970bfd5a6
tree7e3403479f4e4fac29105478f9d53b2f08ad3a6b
parenteb92b4183d93a6f101a6bd3aaae651de404c119a
iio: trigger: stm32-timer: fix quadrature mode get routine

Fixes: 4adec7da0536 ("iio: stm32 trigger: Add quadrature encoder device")

SMS bitfiled is mode + 1. After reset, upon boot, SMS = 0. When reading
from sysfs, stm32_get_quadrature_mode() returns -1 (e.g. -EPERM) which is
wrong error code here. So, check SMS bitfiled matches valid encoder mode,
or return -EINVAL.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Acked-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/trigger/stm32-timer-trigger.c