Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3014183pxb; Mon, 18 Oct 2021 06:37:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAtYpsp4q73wOeGn/dhIa34Wx6z40UNunQwLdgcYiJhz1UANuuTbVprpCNt+aM/LOcUTj6 X-Received: by 2002:a17:90b:694:: with SMTP id m20mr47937023pjz.160.1634564260664; Mon, 18 Oct 2021 06:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564260; cv=none; d=google.com; s=arc-20160816; b=ZZ3GlifuqDdZ75QvCYc98gFSOizTHTaQuqh9InVIvZAonesLwAQI6SBo8evfVsBAWQ pf6ahWmagEOQQvs53aQ8RE30OpyhGIX4jkbQotD144AOSyLYmn4828unhbpgUa7HWah3 R8n9MeYxJpK8XpRs4dLV1k+ybDgxycMrg+IvKoKh1IqyF5K/gVfnKlNTsyzK1hDpJaDa dbnfDKEZ6RTs0LGVP95EtI5mrPup8i+pBeu2CDwnS6tsg/FDP13I4Lm6taobpk5/a1W6 VOZ1kAuk5qJ9YluRa76ZNvB7Qv1cbfutf/X+6TGB8zHOOXREW/bGigNxWKtM+tlchuJI qLGw== 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=VOIKN134TEVMapGHFLOdzi+J/596MwPYDG1XUOAlcY4CycFDw0bZH4/GNXIdBMLVpm KJ0vKwKrTpB2OSDx8g117FcDjH+F7uxdaWA7TdBRA1CYTlxctidnhjM0xD3+4Lax8ke/ sE5Dke8n31HwGRvNyqlb11sOh5JGM+buXqOb2gvX4qnzhW709xkd77VoaZafaHclKBh8 aTa/pW9mceM3HcMdLU0NZB8L3jcNtUFE5K5fiVW0lhb3a1DUce6rEsRLX9THcjc4W3gN FEV4NXPNAdJLtmhbpjEJxs+VYL7alRF6Xlc4iwfybSgmUb3pzgqMTThN2rqcQxLtVQLL STBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GqDRo3rG; 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 n13si1192201pfv.162.2021.10.18.06.37.27; Mon, 18 Oct 2021 06:37:40 -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=GqDRo3rG; 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 S232908AbhJRNhx (ORCPT + 99 others); Mon, 18 Oct 2021 09:37:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:54404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233205AbhJRNfr (ORCPT ); Mon, 18 Oct 2021 09:35:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 62DE5613B1; Mon, 18 Oct 2021 13:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563854; bh=lZ6e+SSnM1TUAUTuKQCwy6hZ3pcXZx5MHel341hCe4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqDRo3rGKnwVzU4BuyGXkTNZkwgXJBDQbTm6ho26Dt67zZjgQybVwyUYKprQJE5qo vMQmw/BJdFUrIpSE54oBzVdK2osGubov/xcOB9L9TP9N56WE3WrpwlOPoHngiY7TRT CpgjgOrOZJ793g0TLMKPg3SwVcY/VjpCnfVjjZwg= 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.4 40/69] iio: mtk-auxadc: fix case IIO_CHAN_INFO_PROCESSED Date: Mon, 18 Oct 2021 15:24:38 +0200 Message-Id: <20211018132330.801284592@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@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: