Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3403295ybc; Thu, 14 Nov 2019 08:37:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwVRxI/HygWK4TT3BN95TENoEVVNjaofKzBKHVBCppmkceGN+xH2/xO8gu3JNYmmrmV+drV X-Received: by 2002:a17:906:3919:: with SMTP id f25mr9546851eje.210.1573749432181; Thu, 14 Nov 2019 08:37:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573749432; cv=none; d=google.com; s=arc-20160816; b=p5E2It86L5kozp3P6Ic7AgdWMxmlbmL7y9ADeq1eNodR72UuHLAQy7vrE3SjEHDNrt mbvSBrCMs/s0HNaMurgeFyZDIblkIrW9V+MMONvRAhXmr7aYiYEIjeWIo2srIEivj15Z Qg+LMhkIs5jzfA8x+BXxU37h+0Hx9IQevte3mUH0CJCPCO9CGdtNbSKDg+B2GFPB54DU wauoelFRk/4WCyZnSrhY5YvVEkLXgiUveIIOsgsdm22VzV9UVEhqU+673rVva0QXEoLK 810q5vln9wyZxIRm+xTGjv6eRXtYRO7KbbGJjEmyXLbnWERS2F66//Qo9VTLBZjZpCPa ZIzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2hOlbk6iAq+UU7QhjPD6XaltGVEyMEJe7yJQLIlOvew=; b=iKkeVU/VEhHCL5TO6BOYKpjm5MFxjJQxc4hv+ON0sw8rExW7t0r28aA93QyVZv3Km+ 1FhIC/9tL4pL0HYknAcqpW9uloqE2AESzJe7NNrnDbX7VFituI7yPaDedybNsymJj4Yb xgwa5mltpZ/y0HejhKqgb05+hTKfudd5tQEiuFpgsHwG8VVXpbNopne0V13iYQYC+9I1 86nAh1ytO9UIH/qHwBLXjmhEr6aDV6VIyBw7e7ZqpB5uZnyxpYSi5/Soys3nE/2IOwCO MLxxgyZ8iKNA0b0LMuH4Zc20z2+/DKTRyG/q1wsbH9dmQk7s/AsCDk8zz0g9UEg31LaH DONA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=S0ZW2Hue; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si3967043eds.434.2019.11.14.08.36.46; Thu, 14 Nov 2019 08:37:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=S0ZW2Hue; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbfKNQfT (ORCPT + 99 others); Thu, 14 Nov 2019 11:35:19 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:37374 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbfKNQfR (ORCPT ); Thu, 14 Nov 2019 11:35:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1573749314; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=2hOlbk6iAq+UU7QhjPD6XaltGVEyMEJe7yJQLIlOvew=; b=S0ZW2Hues0ig2tyT7NeZj8q1wLhYZ/X+RXFEzcthF1fpv/26gO0tH68SPpkz7sHt+AQ6O8 BHXYKJfX3Ker3OxsEp58hDfGRjHXhsstPzIkWSMOptDoNWczciO+l+GKudjzwQj8EQnZ+x O5bugp3OAcvQBL4J/Ag3qbHGT4n4nf4= From: Paul Cercueil To: Sebastian Reichel , Artur Rojek , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Cercueil , stable@vger.kernel.org Subject: [PATCH v2] power/supply: ingenic-battery: Don't change scale if there's only one Date: Thu, 14 Nov 2019 17:35:00 +0100 Message-Id: <20191114163500.57384-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ADC in the JZ4740 can work either in high-precision mode with a 2.5V range, or in low-precision mode with a 7.5V range. The code in place in this driver will select the proper scale according to the maximum voltage of the battery. The JZ4770 however only has one mode, with a 6.6V range. If only one scale is available, there's no need to change it (and nothing to change it to), and trying to do so will fail with -EINVAL. Fixes: fb24ccfbe1e0 ("power: supply: add Ingenic JZ47xx battery driver.") Signed-off-by: Paul Cercueil Cc: stable@vger.kernel.org --- Notes: v2: Rebased on v5.4-rc7 drivers/power/supply/ingenic-battery.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/power/supply/ingenic-battery.c b/drivers/power/supply/ingenic-battery.c index 35816d4b3012..5a53057b4f64 100644 --- a/drivers/power/supply/ingenic-battery.c +++ b/drivers/power/supply/ingenic-battery.c @@ -80,6 +80,10 @@ static int ingenic_battery_set_scale(struct ingenic_battery *bat) if (ret != IIO_AVAIL_LIST || scale_type != IIO_VAL_FRACTIONAL_LOG2) return -EINVAL; + /* Only one (fractional) entry - nothing to change */ + if (scale_len == 2) + return 0; + max_mV = bat->info.voltage_max_design_uv / 1000; for (i = 0; i < scale_len; i += 2) { -- 2.24.0