From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4382C4727C for ; Tue, 29 Sep 2020 11:58:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65C19206F7 for ; Tue, 29 Sep 2020 11:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601380736; bh=ie++nir9f+2nD4AZK2bbGTkmWoKC3p+A/hsee9XYrIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YhAaA5gpDFrNTQC7EdjHy/KzQwfU1BQ+gvRhzfRHibtSL8xuuowJ7EDRUPmM0pEer JNxqk9ejoqx4PRQ3VneBbx3hlLWbBqkDPWYr8hXsKVMB4qM884fOjdlVRNthgIDxnf X8m+o6GO4zBjVdqbNjRvF2HIzJ0qQOEx0LaEdF/g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731000AbgI2L6z (ORCPT ); Tue, 29 Sep 2020 07:58:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:38492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730349AbgI2Lll (ORCPT ); Tue, 29 Sep 2020 07:41:41 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E2EB62083B; Tue, 29 Sep 2020 11:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379700; bh=ie++nir9f+2nD4AZK2bbGTkmWoKC3p+A/hsee9XYrIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0e+L0QKq5zmvXdPbaDP6bFIhUPjChpuUb6rbrcPIY2A5cwG989qMbObYgcpkGRoc g9x90OM8qNVsX74y9QonU3gqsYBde+qFbFPljSua0V5dGW4QptizaWgrfaB4akm/XK eL1zoCOF50xh2qczETYdShaKAJgmGitfsDk9l1D0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Bakker , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.4 252/388] power: supply: max17040: Correct voltage reading Date: Tue, 29 Sep 2020 12:59:43 +0200 Message-Id: <20200929110022.681056757@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@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: Jonathan Bakker [ Upstream commit 0383024f811aa469df258039807810fc3793a105 ] According to the datasheet available at (1), the bottom four bits are always zero and the actual voltage is 1.25x this value in mV. Since the kernel API specifies that voltages should be in uV, it should report 1250x the shifted value. 1) https://datasheets.maximintegrated.com/en/ds/MAX17040-MAX17041.pdf Signed-off-by: Jonathan Bakker Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/max17040_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index 62499018e68bf..2e845045a3fc0 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -105,7 +105,7 @@ static void max17040_get_vcell(struct i2c_client *client) vcell = max17040_read_reg(client, MAX17040_VCELL); - chip->vcell = vcell; + chip->vcell = (vcell >> 4) * 1250; } static void max17040_get_soc(struct i2c_client *client) -- 2.25.1