Skip to content

Commit 9decacd

Browse files
linuswjic23
authored andcommitted
iio: afe: rescale: Fix boolean logic bug
When introducing support for processed channels I needed to invert the expression: if (!iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) || !iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE)) dev_err(dev, "source channel does not support raw/scale\n"); To the inverse, meaning detect when we can usse raw+scale rather than when we can not. This was the result: if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) || iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE)) dev_info(dev, "using raw+scale source channel\n"); Ooops. Spot the error. Yep old George Boole came up and bit me. That should be an &&. The current code "mostly works" because we have not run into systems supporting only raw but not scale or only scale but not raw, and I doubt there are few using the rescaler on anything such, but let's fix the logic. Cc: Liam Beguin <[email protected]> Cc: [email protected] Fixes: 53ebee9 ("iio: afe: iio-rescale: Support processed channels") Signed-off-by: Linus Walleij <[email protected]> Reviewed-by: Liam Beguin <[email protected]> Acked-by: Peter Rosin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 8a2b6b5 commit 9decacd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/afe/iio-rescale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static int rescale_configure_channel(struct device *dev,
278278
chan->ext_info = rescale->ext_info;
279279
chan->type = rescale->cfg->type;
280280

281-
if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) ||
281+
if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) &&
282282
iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE)) {
283283
dev_info(dev, "using raw+scale source channel\n");
284284
} else if (iio_channel_has_info(schan, IIO_CHAN_INFO_PROCESSED)) {

0 commit comments

Comments
 (0)