Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp649428pxb; Tue, 5 Apr 2022 17:16:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziDmWQ2k0uldN8VX9fr+3bdz2qhdJWtcLOt37eaVSOqOWEyg6nfpjX8jwsjdBPE4vtLdZj X-Received: by 2002:a05:6a00:114b:b0:4f7:915:3ec3 with SMTP id b11-20020a056a00114b00b004f709153ec3mr6345923pfm.8.1649204219410; Tue, 05 Apr 2022 17:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649204219; cv=none; d=google.com; s=arc-20160816; b=AwreBgtmirllPFcZxxuYCeO3z1aKiPYjbRFN9mF09+n2CaohwYWrkttgR4qEBgXQj+ bL/WJWiSBdrNIRisT47S0MQPXAh18Uuams3/zLxcDoR5B9BjlsIU1Fd5mcwy58HlmOfv A37ukjscHWN1s0pAQKH87hlZfS1wk13vXkKyaGDr1v213lsiXkWYOZawbT1aIPhZTzOk lzUxe7iARN7+/0yHikeulRVTDTH+udweli58XHSwpB2Der2F59Mv+j1+PHZ6GhAF5znN Z43lGCCz0SD9HnEoIXmmDVHiUGgHcVBAvYJxNXIi2rv4aKuS1/op+IZsgGx2xj5CqRL0 b9jg== 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=LQ7xOAo36HbO1Etw1I9z/HYzforYbtdVR9XxDWmicW0=; b=riAUwN1JA8Em35xJ5n+yoEf+N5u8F9j3ukMNta1c6oRfZyHjTWm874XmCkY4FCKBgB pwtE+MpyfEkjNMYjIZKpt9hKtG581CpgHna4YkXu7buD67U20IZoSnzvSePGQQj+6Ud1 yjo8K1RJQ+mZ7v/4u9EbIY0AZKvEbFz0g7Q4Fsl40WYfU3XCzWyqTH95WV8LFNslPWpH lVUaS4SwmKyBej6oSsDeyHYwAUcUSV11tcTKHFhtIumlEJTa6wA1Pc7EFJvpSuf9NThh iKB8Adl9hlwNb8+LFiy9VYrf05wgIya5a5Tr00LbDoqRxl/k6rtOWPaMMh9/wxNXPJes LyYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=owynYmSB; 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 a5-20020a17090a70c500b001ca88b83401si3107646pjm.184.2022.04.05.17.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 17:16:59 -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=owynYmSB; 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 9363099694; Tue, 5 Apr 2022 17:01:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379130AbiDELkZ (ORCPT + 99 others); Tue, 5 Apr 2022 07:40:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244773AbiDEIwi (ORCPT ); Tue, 5 Apr 2022 04:52:38 -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 E873762C9; Tue, 5 Apr 2022 01:33: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 A48C0B81B92; Tue, 5 Apr 2022 08:33:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09AC5C385A0; Tue, 5 Apr 2022 08:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147586; bh=mhiSGor9ixVK1nQxRH8akaxf9Gzwa492ylxvfFErLK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owynYmSBhKM3vncc4GX+96S0oyTwZuIcuXWQsDd1vnHlG8rysGdti8bxvHebRTcTX EM/va403IV96rEuWSeGGK+7afbX6kGrS+ds+7MQC4+3VQ8n3//3q4LsJr8cREmvQBQ 1ztKAe1CD0pHz5Bk3+EbMwVfhKjCrCNJJt6xkFhY= 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.16 0049/1017] iio: inkern: apply consumer scale when no channel scale is available Date: Tue, 5 Apr 2022 09:16:02 +0200 Message-Id: <20220405070355.639445951@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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 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 @@ -607,10 +607,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; }