Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3033428pxb; Mon, 18 Oct 2021 07:01:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ9puo6+x2VjHriY9iTBxMX6EmDm/S7EF62Nt93TWORLux8pj0rf9qfxldrNtWj+Fq4iwD X-Received: by 2002:a17:90b:4a51:: with SMTP id lb17mr33473966pjb.41.1634565667564; Mon, 18 Oct 2021 07:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565667; cv=none; d=google.com; s=arc-20160816; b=OG+BoaRkGU4LlrCsosWhTmA2IS3tikcFDXTE9Ocsy816rEd/WfxV8SAkQesH5ksBvw iKomfVSWLHbbun6vh2LT/uuCEzaVbCJgcoje/lsPFaZnDM4uOH66MLMIq8bmh7l41Iwy l6C70wswxi1EWBid3lhfTGA2CMUfrmBslONDH4RVARclxUjFJV5SshyAmTedjNKeqsN7 Z0/+8xsoerKQCo6ktgAhTkEdfUBVWQ1UanaZgmQveP4o2B379dTBRHPpMqc/TbiaZvQ9 5kc8suasBOnYfRVUSVyX+M1RX8iU5CU0OLQH+dDDtcNaAE35h0ShksN46vO/cemCCZM7 PAiA== 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=l8Kghldn1zJ7C5vmrjFCWsL9MnLN20oUmoMcIn9i+zE=; b=HTESSSzeDHZdoVNjDUPtnuq+BHLrE7dBYiDaNx3EVE9RP3kC3HfExny+HQQ4r3rfjV abkzqLZ089Z5WA3sCR3Dnch/TIA+DUt0Yp1VOvSInc1MYRBMUAEqO2HlCVue1CSu/FPY 1WdWvuuzYqx3aUmePDkPQVZBDkP5/0T0hb9u7+LGRHKJPH6ef1SxJilKTmK4afR4GPmI AaijenenKxzGZS8FTTwnsZP/+x4kU/1YZMtSMLnLwqDR2brzOHfpeNO71ccbQt4D6XzF Y7sM4Ip3+9Y0W4oYA+1NE4/rqrV/e/HaBzIvSAutA8cUY3WJKeApCBahyUqkI14fxP1B nTmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bFMp8YWs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u187si19542593pfc.174.2021.10.18.07.00.54; Mon, 18 Oct 2021 07:01:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bFMp8YWs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234623AbhJROAp (ORCPT + 99 others); Mon, 18 Oct 2021 10:00:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:38300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234695AbhJRN6c (ORCPT ); Mon, 18 Oct 2021 09:58:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1939B61414; Mon, 18 Oct 2021 13:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564489; bh=lZ6e+SSnM1TUAUTuKQCwy6hZ3pcXZx5MHel341hCe4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bFMp8YWsiOYgq1VDsQPywMc5SesigWCT034cL6qa8uXbmbUOaE2cqiViRIZGoNlPl KBU3Z8Ux2/bQlf7g0NUyDE0iXQfMUV+3tO1prPo7xGfdgRbXYwamYcq5rj3Iz2NUeA CPkzwXDjULGNZmI95Bw4yAm2GM51loZuGkCVX90k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Liu , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.14 075/151] iio: mtk-auxadc: fix case IIO_CHAN_INFO_PROCESSED Date: Mon, 18 Oct 2021 15:24:14 +0200 Message-Id: <20211018132343.126141539@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hui Liu commit c2980c64c7fd4585d684574c92d1624d44961edd upstream. The previous driver does't apply the necessary scaling to take the voltage range into account. We change readback value from raw data to input voltage to fix case IIO_CHAN_INFO_PROCESSED. Fixes: ace4cdfe67be ("iio: adc: mt2701: Add Mediatek auxadc driver for mt2701.") Signed-off-by: Hui Liu Link: https://lore.kernel.org/r/20210926073028.11045-2-hui.liu@mediatek.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/mt6577_auxadc.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -82,6 +82,10 @@ static const struct iio_chan_spec mt6577 MT6577_AUXADC_CHANNEL(15), }; +/* For Voltage calculation */ +#define VOLTAGE_FULL_RANGE 1500 /* VA voltage */ +#define AUXADC_PRECISE 4096 /* 12 bits */ + static int mt_auxadc_get_cali_data(int rawdata, bool enable_cali) { return rawdata; @@ -191,6 +195,10 @@ static int mt6577_auxadc_read_raw(struct } if (adc_dev->dev_comp->sample_data_cali) *val = mt_auxadc_get_cali_data(*val, true); + + /* Convert adc raw data to voltage: 0 - 1500 mV */ + *val = *val * VOLTAGE_FULL_RANGE / AUXADC_PRECISE; + return IIO_VAL_INT; default: