From: Gabriel Shahrouzi Date: Sun, 20 Apr 2025 01:30:09 +0000 (-0400) Subject: staging: iio: ad5933: Correct settling cycles encoding per datasheet X-Git-Tag: v6.16-rc1~30^2~4^2~60 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=60638e2a2d4bc03798f00d5ab65ce9b83cb8b03b;p=linux-block.git staging: iio: ad5933: Correct settling cycles encoding per datasheet The AD5933 datasheet (Table 13) lists the maximum cycles to be 0x7FC (2044). Clamp the user input to the maximum effective value of 0x7FC cycles. Fixes: f94aa354d676 ("iio: impedance-analyzer: New driver for AD5933/4 Impedance Converter, Network Analyzer") Cc: stable@vger.kernel.org Signed-off-by: Gabriel Shahrouzi Reviewed-by: Marcelo Schmitt Link: https://patch.msgid.link/20250420013009.847851-1-gshahrouzi@gmail.com Signed-off-by: Jonathan Cameron --- diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 6b3e2319e791..85a4223295cd 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -413,7 +413,7 @@ static ssize_t ad5933_store(struct device *dev, ret = ad5933_cmd(st, 0); break; case AD5933_OUT_SETTLING_CYCLES: - val = clamp(val, (u16)0, (u16)0x7FF); + val = clamp(val, (u16)0, (u16)0x7FC); st->settling_cycles = val; /* 2x, 4x handling, see datasheet */