From patchwork Thu Feb 22 20:23:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 10236335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 49A0560349 for ; Thu, 22 Feb 2018 20:24:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DCBC23B32 for ; Thu, 22 Feb 2018 20:24:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 313DD28DF0; Thu, 22 Feb 2018 20:24:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD0D723B32 for ; Thu, 22 Feb 2018 20:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751165AbeBVUYD (ORCPT ); Thu, 22 Feb 2018 15:24:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:33228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbeBVUYD (ORCPT ); Thu, 22 Feb 2018 15:24:03 -0500 Received: from mail.kernel.org (unknown [185.189.112.11]) (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 D88572178B; Thu, 22 Feb 2018 20:24:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D88572178B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sre@kernel.org From: Sebastian Reichel To: Sebastian Reichel , =?UTF-8?q?Pali=20Roh=C3=A1r?= , "Andrew F. Davis" , Merlijn Wajer , Tony Lindgren Cc: linux-omap@vger.kernel.org, linux-pm@vger.kernel.org, Sebastian Reichel Subject: [PATCHv1 1/3] power: supply: bq27xxx: support missing supplier device Date: Thu, 22 Feb 2018 21:23:47 +0100 Message-Id: <20180222202349.23411-2-sre@kernel.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180222202349.23411-1-sre@kernel.org> References: <20180222202349.23411-1-sre@kernel.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sebastian Reichel power_supply_am_i_supplied() can return negative error codes. In this case we should assume, that no charger is connected and the battery should be marked as DISCHARGING instead of NOT_CHARGING. Reported-by: Merlijn Wajer Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index d99981542a46..7ce60519b1bc 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -1670,7 +1670,7 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di, status = POWER_SUPPLY_STATUS_FULL; else if (di->cache.flags & BQ27000_FLAG_CHGS) status = POWER_SUPPLY_STATUS_CHARGING; - else if (power_supply_am_i_supplied(di->bat)) + else if (power_supply_am_i_supplied(di->bat) > 0) status = POWER_SUPPLY_STATUS_NOT_CHARGING; else status = POWER_SUPPLY_STATUS_DISCHARGING;