Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp927634pxb; Wed, 6 Apr 2022 04:32:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5tu5dBno+U0nYRQr+5yqReGjbIt14X3wP1F7Db4nfoULABg8n1cdtlbiRB1p9iVIKQhpZ X-Received: by 2002:a17:902:f683:b0:153:ee22:18b7 with SMTP id l3-20020a170902f68300b00153ee2218b7mr8061548plg.159.1649244730314; Wed, 06 Apr 2022 04:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649244730; cv=none; d=google.com; s=arc-20160816; b=ilQar8Xq9U0FAaBzFa1YxC+mxLds1Yzz9GfKMzxAx8MHWFQMv5ZbfNzg4sbDueHGad mWWGT3Dx8YeCU3+eBfuVPVGeqR6nauMlzsn2M/clZZ4SNMhTk8XukBzzgJsyBKx0haB3 vj0LwpcKQBjzJynow80sV+L6fvUnTe2xAveFRr4Mz7nMmrKNe6zEt4HRKqhKOEb47+ge OAXRS64yQtiUekMr/6A+/2sHPr0im3Iouh6xhl0gXk83zVNQIXV3XXKREm2wK16x+FWg c6DEMvXaUfAkkHNy5JamqKiFnTNeOyFmZQSCXtubhCLhNPZuHG4K7rsyEzVDQnASovvA lwvQ== 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=6U7rtZ65XgJiRg8sHo3nARrZupVJ0fqfZVxWEKrjO/E=; b=hEJAhAqVkiMnGps1gjVu5I7tNGc4tPso7Dgsw1Iwhq4we/9Bt3AkfNvRvMoz3/PPtp 8epVnjw7PYTZ444WvvNs4m6qkXeSG1TUC36sRGBH4AcMlgygujGMRlbrJqCRyoxfLhbT 5rGqqwmnVGmdnWH9XO3JjxRWQFrZr7jlV5ThiozghOJMG8zp4d57cLneBB/nZtR9eOsQ qwxklQYaEzih4JoTyJxy8Orr3DUBOY3OBYPKmpQM7nQ065h6jAwVzD6luQQGA+Oj1WW8 YBnQk5iTJiPijLEWCO53gvkzfhS4PKK5ji16KP0V9cveN4o9zaMAw+tdNWHNfH2Z72lj dwFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=emS12iRw; 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 t22-20020a634616000000b003993a4f24desi7061925pga.441.2022.04.06.04.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:32:10 -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=emS12iRw; 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 D71E753F789; Wed, 6 Apr 2022 02:54:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443577AbiDEWUe (ORCPT + 99 others); Tue, 5 Apr 2022 18:20:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354648AbiDEKO5 (ORCPT ); Tue, 5 Apr 2022 06:14:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E4756C1ED; Tue, 5 Apr 2022 03:02:18 -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 3CD10B81C83; Tue, 5 Apr 2022 10:02:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83D38C385A1; Tue, 5 Apr 2022 10:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152935; bh=gfV629Zgz/51l+/HtStoc6+xPlrAsyPHiNc5Qtfgl50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=emS12iRw6EHfmVh+DpR9Po0LRA9HmErfdCNwW4Ch3J0ydU50zEnHv52C4fPDufOST PTzAU2ZHlzp3MAIhjE0gX2gW6x4ZzO2UsTE0dfKoUZm2WFNqrla0wT098/cZN9F1J3 S27vZyMa/kovuMi6p69Tlxb8+K1ffxXLjTPyw148= 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 035/599] iio: inkern: apply consumer scale when no channel scale is available Date: Tue, 5 Apr 2022 09:25:29 +0200 Message-Id: <20220405070259.867876473@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 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 @@ -573,10 +573,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; }