Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp984298pxb; Wed, 6 Apr 2022 06:02:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkM1ukrQaSEgqonCruS4TR0/xCIIf2NCjq2gvnYI0zN+w6I39dgXTb2L7NBUS0c08DMSB2 X-Received: by 2002:a05:6602:1645:b0:646:4780:fc28 with SMTP id y5-20020a056602164500b006464780fc28mr4022429iow.194.1649250174930; Wed, 06 Apr 2022 06:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649250174; cv=none; d=google.com; s=arc-20160816; b=YGnnkEClPExmOX0+5r2O2nsm+MmFaapf8YZTs6xc0trDr1b51R2w0t3QURpIPDMguT s15W496NdR2oylstmR8Nzu67kuja6Q+4XNway8GLjKCkwBXFzhkKoePrqeUOVeovc29f ptPZm4hFp5e1aLqpcIP54L3uvRNz0ElsQjp8iMuaTDniDh7f3aZAL8fJm7j2GGB7KLzM 1n5MmYEsJSddIHwAMRyr41D6vR44lg/y1vUn2zStqZusCfdvgRRWpHf63FpmOx1dGhiT 7gdZkIAUaJBNNwbPDyv0StyFco/hLYVWx+rKImoev1+Y0maVXkNSRfLGTRJMvCfW34v7 CoSA== 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=jJrfjGyyHmY9Vz9oegLTaEDkzH6ja8dmnsxJNYkgqIw=; b=U/jqWmx0UJUOp3xoPTB9g0bkxRrpaoZpeuR5rq5TDGO6JjFUZLrpSdhFs7ASOR6EZx ZsmImYcrW/Vz/VhUPu531jp7GlHeIhHbRqlG/I4JjBqod+xVHPiJZEjcpeI8xTGyhXTC zz/IwsNtBWWPWOnBlbB0xn3F5YUR2i6SK49fvmR3yPo6aEkY6xKTH7OE31SWBZDqwqGz RTTgFXk1wPQU/f6IvG4VuxquND2oPneuzegmSEzq71xGK4sFgga2wBMTVwnLtrUbyOPR 8aAx1TdtC+6gPCaqe5jDS6Ja+eZN6F2uaUuI7oO3zARID1qzJSD+w4Amq/LcEqLGGAT1 /kvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aGY7p+eB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r10-20020a922a0a000000b002c7c7bfb713si9469699ile.177.2022.04.06.06.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:02:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aGY7p+eB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E51B23E8FC4; Wed, 6 Apr 2022 03:20:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389212AbiDEV7C (ORCPT + 99 others); Tue, 5 Apr 2022 17:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354933AbiDEKQg (ORCPT ); Tue, 5 Apr 2022 06:16:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEF321818; Tue, 5 Apr 2022 03:04:08 -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 ams.source.kernel.org (Postfix) with ESMTPS id 46684B81C8B; Tue, 5 Apr 2022 10:04:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B70F0C385A2; Tue, 5 Apr 2022 10:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649153046; bh=kSdGlvD8ZiXBvi/chcD7vZ/P+j4sw/QMAyDaUs8nof0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aGY7p+eBgZ7lMZjQjMgxyG1HC7bj/y7amrRs8X6VsChmazMBegYiyShzWqaFOmu2g 43azgj8Vs8qdHhEz+k74CXEOypfldziT7puyzVexVJ83LKYnaUT604/qai+GqOTw7T qTEiqlXmG86dvcrb4pHJEomAYuW22lq/q8vDCtC4= 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 5.10 034/599] iio: inkern: apply consumer scale on IIO_VAL_INT cases Date: Tue, 5 Apr 2022 09:25:28 +0200 Message-Id: <20220405070259.838133693@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 1bca97ff95c732a516ebb68da72814194980e0a5 upstream. When a consumer calls iio_read_channel_processed() and the channel has an integer scale, the scale channel scale is applied and the processed 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: 48e44ce0f881 ("iio:inkern: Add function to read the processed value") Signed-off-by: Liam Beguin Reviewed-by: Peter Rosin Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220108205319.2046348-2-liambeguin@gmail.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/inkern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -582,7 +582,7 @@ static int iio_convert_raw_to_processed_ switch (scale_type) { case IIO_VAL_INT: - *processed = raw64 * scale_val; + *processed = raw64 * scale_val * scale; break; case IIO_VAL_INT_PLUS_MICRO: if (scale_val2 < 0)