Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2848905pxb; Mon, 18 Apr 2022 09:29:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH0dU43d4ag8qSNwfPzfWi5fh/Av1zm+mGv2Y+jZvr+t0xbwIKo7Ip6grVGW2cC8Tfq3YS X-Received: by 2002:a17:90b:201:b0:1cb:a159:65ce with SMTP id fy1-20020a17090b020100b001cba15965cemr19624650pjb.104.1650299375056; Mon, 18 Apr 2022 09:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650299375; cv=none; d=google.com; s=arc-20160816; b=TiYVz7SHbC2+rm98lxxQvBOuQyPRqLCYDEUiBwvUCwUPnXypi+RjCogSixh/XycGOt 0tfLizTStuI1ggKIemCwfZP1eY7d4mPYJmaYL6F4T0P0423s5KStm1pS4sBRrccoCk/0 5V9qfeWDR8EboWx0DPpK/24J8xVPDH/u5/bg8XRKJvlufsA5kBtAJsvIQyhenYmtVoYS to+CIm1WE9X33M+7AptxaNUrPAF26yAXJfqQqt0IYIFRLewx512Y5/6w47lykAVN7D2T QfkK8JeCzJ6Sfbp8z9vk01/dzSh2WGoQn63oEYLxMSeei0//+dGfsgAiPmBRqRuOqXwN V0xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F1L//VS+hr/hFBE/rwmYGgixV90jbFyV5KJ9CPX+GHk=; b=cckXdNkUDqU0Wd9DfJsFrJfQBvmvyjd8nd1DfeEA5WZbgdWqupM1U53jdrAVIDGinG sdyDom7nnv5cBthryGVSMAlnN2XLSn4cCUCp9EKSen48A2pluO2D9fZHJzdZylMC/GHa xEhQ/rrFyDcuLMLGLRmuAP4WtOXA6C8lG89hCMe5w6PCSgwxOxwmBrSJX/RuD2KCuiYX 96bw9xxg262G5aTOS8KbZ2F4tPqpD5cj+cmQbFUr0Oq+8RUEQENcqF8KviD7eioXJnhI Utbs9/fPmQ8nYJrFXsfbcnjFQhi6LSro6HBq3TW71C5cQTQtGoQ0uUCVh5AdfVgEsiNl XaJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dz8W+l8A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h17-20020a170902f71100b00153be6474c2si8723562plo.531.2022.04.18.09.29.19; Mon, 18 Apr 2022 09:29:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dz8W+l8A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243933AbiDRNm7 (ORCPT + 99 others); Mon, 18 Apr 2022 09:42:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241457AbiDRNH6 (ORCPT ); Mon, 18 Apr 2022 09:07:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200402AE29; Mon, 18 Apr 2022 05:47:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3419161253; Mon, 18 Apr 2022 12:47:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43BCCC385A1; Mon, 18 Apr 2022 12:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286056; bh=7kX7CnvluiWbJU3rkOnN9B/tJ1K7lAW9rQihbi123BI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dz8W+l8AD3iJmvHm2wxnROmgzhrp5J1GXtUochxruuYfnKOUk2Ka+bbLDABqfWTLY sMTfl/JuLnbl3hIrnYjww1rTlfPWnNMYsSO9l42FnAKuAwxJVHsLVybJurwppDoJlF nWdXYUvfa7EREr6h5iutTdxxCoBIh8hNPvfcU34U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liam Beguin , Peter Rosin , Andy Shevchenko , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 4.14 016/284] iio: inkern: apply consumer scale when no channel scale is available Date: Mon, 18 Apr 2022 14:09:57 +0200 Message-Id: <20220418121211.159619760@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liam Beguin commit 14b457fdde38de594a4bc4bd9075019319d978da upstream. When a consumer calls iio_read_channel_processed() and no channel scale is available, it's assumed that the scale is one and the raw value is returned as expected. On the other hand, if the consumer calls iio_convert_raw_to_processed() the scaling factor requested by the consumer is not applied. This for example causes the consumer to process mV when expecting uV. Make sure to always apply the scaling factor requested by the consumer. Fixes: adc8ec5ff183 ("iio: inkern: pass through raw values if no scaling") Signed-off-by: Liam Beguin Reviewed-by: Peter Rosin Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220108205319.2046348-3-liambeguin@gmail.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/inkern.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -603,10 +603,10 @@ static int iio_convert_raw_to_processed_ IIO_CHAN_INFO_SCALE); if (scale_type < 0) { /* - * Just pass raw values as processed if no scaling is - * available. + * If no channel scaling is available apply consumer scale to + * raw value and return. */ - *processed = raw; + *processed = raw * scale; return 0; }