Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp875069pxk; Thu, 17 Sep 2020 20:00:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4gqf4J9+zfRwk81MCdij8zjF8tf/QBg8bHLyELjJ3/iIbVZ/cfqbBZ3eiEs47KWCPm7J8 X-Received: by 2002:a17:906:a98a:: with SMTP id jr10mr32286887ejb.229.1600398032294; Thu, 17 Sep 2020 20:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398032; cv=none; d=google.com; s=arc-20160816; b=nzQXg7wS/uTrD3cHfg+wkmLxiRtO5m3vUpU6nr3A8So0vB4U2oJekJNDRQ6YGJiIr7 sUvBuj0P7Qj6aVnXKswFh385vbnFE5y81RwpCWMPtYvUzcDZ6XXun95c8d3bZ+BEVwqG 3hr0c6W5pJiO15I9YjZl4JLdeE+1qcw72ShuSr2FZUhO/qML46uWInPKrrS8oZ32M1Ad 9Zt0lkIddmoKY7tN414IXT1iv1hzioQjxi2ECxfXXRdfkPCxp/ZPLxCiuz+ELne0negr YMKydcGNP3+LxZLZnzuPPqWIyh1CDzABZA5OjUwsoH9Y/l6vvV8yCON3Zsio9oq3gaFL jJgw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LNlX0oyqOlWezJ8SfaETB7ka28+9n0sDHQnTPTjmT+M=; b=cOwdymZeua8DCuTYZ5YeucZWjSAfvuFZk1SAFosMLmqOZ/g19/XUSiRn98pDb8P37l QbhPU5sEa/1kOJ6uqdsfWAB3/qA2VIreTJhNLTOwBx9OfY3YgZra3T7yavk1V0s4aCwR UqcDDeHwNCO/W0bombYEtRUqHUQYmdMzTCA5LzbM00Bd9yA614sBsrnFG2Rh1OOxWTSD YM5awLFbNNaweyLH+wnjA9QqihUmoJQXDKNErXKChk6+/0EcpEcRs9RopV63Dg7BRukB irRuNaN3wl5yZC4eND7O13vSYOvgCqeUeiNXRWfmnbpoPeAXxsPYq1TzjgRRzDEp/hIE 6jkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iNTwE+dJ; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr3si1292354ejb.744.2020.09.17.20.00.09; Thu, 17 Sep 2020 20:00:32 -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=@kernel.org header.s=default header.b=iNTwE+dJ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730012AbgIRC53 (ORCPT + 99 others); Thu, 17 Sep 2020 22:57:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:55092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727774AbgIRCGc (ORCPT ); Thu, 17 Sep 2020 22:06:32 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 359782399C; Fri, 18 Sep 2020 02:06:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394788; bh=ie++nir9f+2nD4AZK2bbGTkmWoKC3p+A/hsee9XYrIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iNTwE+dJ1g+apDM9ANSTT+zZagt7rz0Qn4+sshEB5NvLv3kTpboM+/SrlzgxRQzc4 7KugYqaBQGdGOxcYjLZduck+KvMQKl1u9mIqHtM2TgTmFbPLQCQqbpXNNp1bLtsdgR Zhs+iUIWWaGVU7/zRiCz9WvLwMdgD58vWXkQqAmU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jonathan Bakker , Sebastian Reichel , Sasha Levin , linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 259/330] power: supply: max17040: Correct voltage reading Date: Thu, 17 Sep 2020 21:59:59 -0400 Message-Id: <20200918020110.2063155-259-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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