Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2093939ybl; Thu, 30 Jan 2020 11:14:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwkm5oxaVWxX/nz6cq73Nfenbso2n9m1t/8MXGpooxBTeoksl6UR973XGiXhN5lT4HvtRMV X-Received: by 2002:aca:1005:: with SMTP id 5mr3996403oiq.16.1580411693932; Thu, 30 Jan 2020 11:14:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411693; cv=none; d=google.com; s=arc-20160816; b=JA/ibZS2Rcs341fKgXU9aPy11kxUo5+chHFIhhLIMk/u+8YB+YxA0yNJcHZBLjZxNn bQUNO/ujKXr8sdQXvy/md5/fuH3WWy6qJstFyZtUYXKXOvct3DsyYPwvcM5oUnfP11c1 QCD3vbADm3zJSyfx/YCtHIAJskVzsZiHQYHZmlAHH/0oSEM2K0pdYr/MqaLm5xIwEYkw 2qj8XdSJacsJdvnKLnpab4mWOL2q3GiK/iVWniRJeQpAqdTq7tZGCHvqsDb2B6tc4/hE 8Y+S+rG70SSxbUCPjYmk1tvEiFD0NJ+usYUuG9lEnctPonEZU5AWOUA1YVCw9lXmVlrj 4QvA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lfCF25J/iS2uPKxj8uug8xpLcWishvX0tvp1kzDc3a0=; b=S/ZE0xWodxm6NHlwUuVIJuZxdYTdhFVvbv7MSL3No3+PCWBhk5Ecnz7b6hPTLXMfEu DGJg7ivP3I1Ta5Wq4MzWSPfL4qysRgZKmM4Cd3m062fo5W+T1vQK8aCsH8gCUT0H3W5E rDsCKF7QIYnXPD3+JpW5QUIuw6ngvDJ+Vc5GOlfK2q2zzjSpUdUeg9Vp+x1Dxndf465N WmnU0taO251PsPfTZXdxZIWPemy5kRL+ktI+hHTUzoUYqaSDu039fm3+8Bely5HVBESP Frd137Ohtx6zuzzllSRBsRPSKcqm8xGSKk+MgabHjI3ReZlZxKKFN001K5Gj50sKf701 nJHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zuLpxkRC; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 107si3454153oth.14.2020.01.30.11.14.42; Thu, 30 Jan 2020 11:14:53 -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=pass header.i=@kernel.org header.s=default header.b=zuLpxkRC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730241AbgA3Slq (ORCPT + 99 others); Thu, 30 Jan 2020 13:41:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:49736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729435AbgA3Sln (ORCPT ); Thu, 30 Jan 2020 13:41:43 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 9EA00205F4; Thu, 30 Jan 2020 18:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409703; bh=VqDmHkwwQXUzjmkuYi1yVAWOTe1K9YymAZQllXMZIEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zuLpxkRCBTfLL1UxoJT2CfA//Z8FvFGOH1uwFCTJVJCep+wt7JgCE7SeMIy/56vNN fgmnQCjmWJF+lftcEj/Bna1G/01+Wnhi3qgGEVPeb/7Yh+Z3AF4gFm62EUFKf+uKLf Wa2Ku6Kbhb0tGjyBpZOsk8twuGIMJjLk/2TsU2/A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Cercueil , Artur Rojek , Sebastian Reichel Subject: [PATCH 5.5 56/56] power/supply: ingenic-battery: Dont change scale if theres only one Date: Thu, 30 Jan 2020 19:39:13 +0100 Message-Id: <20200130183619.041405246@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183608.849023566@linuxfoundation.org> References: <20200130183608.849023566@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul Cercueil commit 86b9182df8bb12610d4d6feac45a69f3ed57bfd2 upstream. 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 Acked-by: Artur Rojek Cc: stable@vger.kernel.org Signed-off-by: Sebastian Reichel Signed-off-by: Greg Kroah-Hartman --- drivers/power/supply/ingenic-battery.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/drivers/power/supply/ingenic-battery.c +++ b/drivers/power/supply/ingenic-battery.c @@ -100,10 +100,17 @@ static int ingenic_battery_set_scale(str return -EINVAL; } - return iio_write_channel_attribute(bat->channel, - scale_raw[best_idx], - scale_raw[best_idx + 1], - IIO_CHAN_INFO_SCALE); + /* Only set scale if there is more than one (fractional) entry */ + if (scale_len > 2) { + ret = iio_write_channel_attribute(bat->channel, + scale_raw[best_idx], + scale_raw[best_idx + 1], + IIO_CHAN_INFO_SCALE); + if (ret) + return ret; + } + + return 0; } static enum power_supply_property ingenic_battery_properties[] = {