From patchwork Wed Aug 30 08:52:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13370484 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC870C83F1C for ; Wed, 30 Aug 2023 18:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237722AbjH3Sgk (ORCPT ); Wed, 30 Aug 2023 14:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242495AbjH3IxF (ORCPT ); Wed, 30 Aug 2023 04:53:05 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C877CCB for ; Wed, 30 Aug 2023 01:53:02 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-500b0f06136so6232142e87.0 for ; Wed, 30 Aug 2023 01:53:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693385580; x=1693990380; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=a7IUUKRo18kc1SIdFh7Gpb3hs7/PPc93dlBfA1+9r5g=; b=J2TXaDKL0Lkt3UKz9MFW0KciUwTa9go+L5IhE9L3ANepHfb1webQYdRQvvA8dknC/E t453VO2vN7OSoVb7Dv93mxCLY2NYHuEvrew8Cbleou54zF5RxnV6cBG081t6vfeaJAZq cadLaDnHyo/ayGBU36HrKsrnlOyaBatFHJhG8+W3udK+3ka2o7RcxRU2vQcHpht2xJ6r qej1EdJSzwDIeURCZ655m3VNVocUTrETA/F2X+lkO7icPdc7uOoNjvl6f3748kvcGe76 L5Q6Xnus+5y8NDDKhAtVXM7LLSsdzXLe5VEdQgR0hp567mTkZSxiiUPbWno83vMQJKiu 9i6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693385580; x=1693990380; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a7IUUKRo18kc1SIdFh7Gpb3hs7/PPc93dlBfA1+9r5g=; b=kvdu77AyEULg/BvGVUIUrhqjPH6KGVKZ6H7X1nCaUmHZHbSc9lpygHNsbwL0G8Lie/ ja8fv1OcCZKj4Tk8PH8jWnjnNHQHQDtnXFHRBRDgF0fUYXbmN+0tPHIoh9M+kIR0hqTp +y6D7j1txmzL4OQrwnV6/wF50faulvrMFksi8L5RCaIlrrq8Z62uvXG9+Curr7+SmehP Dw9NSeL1MaP4+5hUOEc7TvI3EOdq+GO8PHfQDI4ksBhqoKkESVFn/XCX4pb6JtVLCc3/ vaaVpmAD8ICCHgOGuNST1Qqsxn8fqK5GgUG0oSOA4ym1anM/P+y3OHeqyPXO5iw1Qw/N t0aQ== X-Gm-Message-State: AOJu0YwSUgUS5lcEzYnrP6v8WiTOfIPNOhwNKSym23vymayE3edVcVO6 wfrFdL0LG5W3nUEUwV7IWROgcw== X-Google-Smtp-Source: AGHT+IE+jxbyjKkaU0CTSRVGxTD8FSRj4bUC++kmj65m2HoeIl/YH3+1mOCN2srawPv2yzHUPshMFg== X-Received: by 2002:a19:4314:0:b0:4f9:5519:78b8 with SMTP id q20-20020a194314000000b004f9551978b8mr910521lfa.63.1693385580391; Wed, 30 Aug 2023 01:53:00 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id p3-20020a19f003000000b004fbc6a8ad08sm2296971lfc.306.2023.08.30.01.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 01:52:59 -0700 (PDT) From: Linus Walleij Date: Wed, 30 Aug 2023 10:52:59 +0200 Subject: [PATCH] iio: afe: rescale: Accept only offset channels MIME-Version: 1.0 Message-Id: <20230830-iio-rescale-only-offset-v1-1-40ab9f4436c7@linaro.org> X-B4-Tracking: v=1; b=H4sIAGoD72QC/x3MwQpAQBRG4VfRXbs1RkpeRRaYf7ilGc2VSN7dZ PktznlIkQRKXfFQwikqMWRUZUHzOoYFLC6brLG1aWvDIpETdB43cAzbzdF7xcHetjDN5KzDRLn eE7xc/7kf3vcDbeA1yWkAAAA= To: Peter Rosin , Jonathan Cameron , Lars-Peter Clausen , Liam Beguin Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org As noted by Jonathan Cameron: it is perfectly legal for a channel to have an offset but no scale in addition to the raw interface. The conversion will imply that scale is 1:1. Make rescale_configure_channel() accept just scale, or just offset to process a channel. The code to handle channels with just offset is already there. Link: https://lore.kernel.org/linux-iio/CACRpkdZXBjHU4t-GVOCFxRO-AHGxKnxMeHD2s4Y4PuC29gBq6g@mail.gmail.com/ Fixes: 53ebee949980 ("iio: afe: iio-rescale: Support processed channels") Fixes: 9decacd8b3a4 ("iio: afe: rescale: Fix boolean logic bug") Reported-by: Jonathan Cameron Signed-off-by: Linus Walleij --- drivers/iio/afe/iio-rescale.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- base-commit: 2dde18cd1d8fac735875f2e4987f11817cc0bc2c change-id: 20230830-iio-rescale-only-offset-f28e05bd2deb Best regards, diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c index 1f280c360701..18aafb4bdda0 100644 --- a/drivers/iio/afe/iio-rescale.c +++ b/drivers/iio/afe/iio-rescale.c @@ -280,8 +280,9 @@ static int rescale_configure_channel(struct device *dev, chan->type = rescale->cfg->type; 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"); + (iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE) || + iio_channel_has_info(schan, IIO_CHAN_INFO_OFFSET))) { + dev_info(dev, "using raw+scale/offset source channel\n"); } else if (iio_channel_has_info(schan, IIO_CHAN_INFO_PROCESSED)) { dev_info(dev, "using processed channel\n"); rescale->chan_processed = true;