]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: sx9310: Fix write_.._debounce()
authorGwendal Grignou <gwendal@chromium.org>
Wed, 31 Mar 2021 18:22:22 +0000 (11:22 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 08:49:24 +0000 (10:49 +0200)
commitba72b507f7d4a377d3fae67a797a933951a8e3e1
treea7265325dce44a23eba23a95bc9315ca9823c60c
parent3453d4c5f92309db71f9e981fa025ebe49fcb4c3
iio: sx9310: Fix write_.._debounce()

commit fc948409ccc1e8afe8655cee77c686eedbfbee60 upstream.

Check input to be sure it matches Semtech sx9310 specification and
can fit into debounce register.
Compare argument writen to thresh_.._period with read from same
sysfs attribute:

Before:                   Afer:
write   |  read           write   |  read
-1      |     8           -1 fails: -EINVAL
0       |     8           0       |     0
1       |     0           1       |     0
2..15   |  2^log2(N)      2..15   |  2^log2(N)
16      |     0           >= 16 fails: -EINVAL

Fixes: 1b6872015f0b ("iio: sx9310: Support setting debounce values")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Cc: stable@vger.kernel.org
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20210331182222.219533-1-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/proximity/sx9310.c