Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3508300pxb; Tue, 19 Apr 2022 04:18:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAX7AEbbkJ5V5t9I6cnRC8O82+QJupLlqrp56VnHKMmTFHCovij31IO59I7+19Gfm2u3/8 X-Received: by 2002:a05:6a00:a85:b0:4e0:57a7:2d5d with SMTP id b5-20020a056a000a8500b004e057a72d5dmr17231024pfl.81.1650367099567; Tue, 19 Apr 2022 04:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650367099; cv=none; d=google.com; s=arc-20160816; b=rRN/FbxF+jvJu/IA2g9MbdunphcU8WWO3qJ4nmAEN6+nW8PHBkvBZH+RZmF6NhVGe3 z8UAwahnLd1rPLP/Rqdq9psiFLM3MiG8Sqodkhcae5GQFirgFJgM5GSmBMPnYWEg5YLQ fkJF4P07SL0sN+r0Ppb+Vd4N3ve69WevVWC4ZXna28Ohxz65363pYBUjFBfTSNOHLJsk /YqWbXhE+ZybVX0tp26dIm83+MbBzj+DuiHa+39tzZ5VDZAmu+LnUk0LtMKCPi+3TyZ/ zfhN/Al0O5eO4OW81+2ZPRMsBBjJKxLyiatjtdqN6VbdsQ7cTUIGgXxKDD88mAQ3gWnE Oi5g== 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=8J9wNp0o8l0RrBsLIHZPULBq2tp41MmLeBAAwmp9Dn8=; b=jP9Ud+JXss0jLFpYZxrrs5FeFqD9CMe5zNDdOWKCuA9kG373kQdycQv/6q/gPVNOPU cGyIm1iv1k7cbdYpuYaqc916cfRY4NJyHqDZM6rRG1VnUQnyVBm5e4gRhJIXIJMepj0W /bUZPhRx8eMg2v6aHpJ5xyf/NcBuddWq363/vpfu6JuG1h+dPHZGxmblZK2qBRtPZsqr 2NZNt+A0Bwisou5MOYtBVY7eG55Oiyz64bdiRjBy8C+jN9FPUUx6iRRiwX9WBMl1AdYE t4HO/g5d4YNWTh3SWdwdv4wgfjYqnN7AsGOn3iwsCu0j1ANd03XHo/cDKlfi6M8LRAbg 4tYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=psHjd+DM; 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 f20-20020a056a00239400b004fae70007c5si12218757pfc.78.2022.04.19.04.18.04; Tue, 19 Apr 2022 04:18:19 -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=psHjd+DM; 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 S243678AbiDRNeN (ORCPT + 99 others); Mon, 18 Apr 2022 09:34:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241391AbiDRNHw (ORCPT ); Mon, 18 Apr 2022 09:07:52 -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 DA1392AC66; Mon, 18 Apr 2022 05:47:34 -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 329FE6124A; Mon, 18 Apr 2022 12:47:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 406A5C385A7; Mon, 18 Apr 2022 12:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286053; bh=iPfEOOaZY6SngMtkH2EjLZFnoqkLvslAt+rH43/wWIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=psHjd+DMRGpDidX3kq8vcxoXBqXWOJ/3d1R318lG/gpl0mhoMMzgnQjQUQ67XYW64 fPvPI/k6fwXOgTlcAHQ/lj+RI3BrH24zijjmLsozxWXGcBCTNY2qJ36Od/lCz6mzSY usH0T68aGZA4WVd7zEMf4riX1daFX7UOjWGzvKD8= 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 015/284] iio: inkern: apply consumer scale on IIO_VAL_INT cases Date: Mon, 18 Apr 2022 14:09:56 +0200 Message-Id: <20220418121211.131642179@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 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 @@ -612,7 +612,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)