Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp704561pxb; Tue, 5 Apr 2022 19:32:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOuaU6eppydXRBkNnWv9/FnLJTmiYejVrmXt97rSTVU1DusIl8ETicMVtixx+xg2S0/8p3 X-Received: by 2002:a63:3606:0:b0:398:5225:b7c7 with SMTP id d6-20020a633606000000b003985225b7c7mr5268040pga.462.1649212373610; Tue, 05 Apr 2022 19:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649212373; cv=none; d=google.com; s=arc-20160816; b=rgHV/igBxBCtPI0Dt8adJoP/FV2JXfAPmkjCBo2GtdYCQ0jrnBysTq5CyV834nJ6CR jB7MXVeGdxDcIARRvcT+Ylc1SDagRN/MnNzRg2WCy+ysLtKG2YX6dHM47b7EoDnJbjff B9uuyz5aB8413pDT0cSW4n4ZUw56qggcTiUJ3ezJcYiWwVWuW9WoTHQTYcWJe/QiC39N q3fvpPqTIvs1ydi2IxvcoM6FTzl3qzm9PmGG8/HEH6lfzCqJKA+F2LE/EHYwzLcZZKq9 WPdn51VJ6RyaBFuy6IJAp0vVwzad492YKx242vcFK3YSgJ9dzdkhD5sOFBZQDb6cNJRF lZMw== 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=nxvGyBfrAearzVA8f/Cq5LWKmhIoXX2QStvoA8Y//iU=; b=U5su3hcKnYEF2vB9uFnxqpnikWmH3o6bwQ4342qkb3/i39yH/oB8SJWc8Ma7m62KkB sJ6bF7Htg2Ob0NVY7PX+dt311XoZMNAefjtFSDSaaWTfu20kC8BySu4Rru9tt6LTgRhI ZvsFGSnelvC5rI27YV20iZkBE+r3Yoz5QPle0dfaNrt0i/CfjSmblotGCPSI/XQERM7o kTUxjSQ1aXaeVYpctfkeUUFDAcLCEG2PWG4Rz5mDY9AxjKDQK/QYAE6U+WBdnsdAReEA 6p9kB1zoZEZENYcG/W+ASt0hFa4CZO1KyBc5ch0Io9vNppRuCNbBZi3cZHXjx5ox95mF ZlbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cE6YFRef; 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 h13-20020a056a00170d00b004fb806eb0e6si16810336pfc.80.2022.04.05.19.32.38; Tue, 05 Apr 2022 19:32:53 -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=cE6YFRef; 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 S1383901AbiDEORi (ORCPT + 99 others); Tue, 5 Apr 2022 10:17:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239485AbiDEJdj (ORCPT ); Tue, 5 Apr 2022 05:33:39 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B95D4B1F0; Tue, 5 Apr 2022 02:22:07 -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 sin.source.kernel.org (Postfix) with ESMTPS id DAC97CE1C75; Tue, 5 Apr 2022 09:22:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1E1DC385A2; Tue, 5 Apr 2022 09:22:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150523; bh=2C3A1eQ6if+uET8hbiuap7T2nhNv5yT8rH9N60eA7j0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cE6YFRefU8rhyU17MqEkFlB62B3xugkxTJ/ABOMyQFn7BbJrMjROM2edZtL4vmtYK GXPHIrSZfu6ov85grqq8wZC6QDf2mJf/VMCo8fKFPovN4WiUhKpFW4diibya6YsdHb 1r+6G+Bz9t9Mxex0Ts9c/OwZQqgiHsj+VSq+8crU= 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.15 047/913] iio: inkern: apply consumer scale when no channel scale is available Date: Tue, 5 Apr 2022 09:18:29 +0200 Message-Id: <20220405070341.229447245@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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.1 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 @@ -590,10 +590,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; }