From patchwork Sun Aug 28 17:34:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 9302869 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 8FA8A6086B for ; Sun, 28 Aug 2016 17:43:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87243287CE for ; Sun, 28 Aug 2016 17:43:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75FD8287D0; Sun, 28 Aug 2016 17:43: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 1A204287D0 for ; Sun, 28 Aug 2016 17:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755654AbcH1Rmk (ORCPT ); Sun, 28 Aug 2016 13:42:40 -0400 Received: from gagarine.paulk.fr ([109.190.93.129]:53911 "EHLO gagarine.paulk.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753429AbcH1Rmj (ORCPT ); Sun, 28 Aug 2016 13:42:39 -0400 Received: by gagarine.paulk.fr (Postfix, from userid 65534) id D2C052040F; Sun, 28 Aug 2016 19:35:00 +0200 (CEST) Received: from localhost.localdomain (collins [192.168.1.129]) by gagarine.paulk.fr (Postfix) with ESMTP id AB8F7202EC; Sun, 28 Aug 2016 19:34:53 +0200 (CEST) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org Cc: linux-tegra@vger.kernel.org, Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , linux-pm@vger.kernel.org, Paul Kocialkowski Subject: [PATCH 2/2] power: bq24735-charger: Assume not charging when charger is missing Date: Sun, 28 Aug 2016 19:34:46 +0200 Message-Id: <20160828173446.32728-2-contact@paulk.fr> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160828173446.32728-1-contact@paulk.fr> References: <20160828173446.32728-1-contact@paulk.fr> 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 When the charger is missing (disconnected), it is safe to assume that the charger chip is no charging. This is especially relevant when a status GPIO is present and the charger is getting disconnected. bq24735_charger_is_charging will be triggered due to the interrupt then, it will attempt to read whether it is charging through i2c, which will fail as the charger is disconnected. This also fixes that specific issue. Signed-off-by: Paul Kocialkowski --- drivers/power/bq24735-charger.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/power/bq24735-charger.c b/drivers/power/bq24735-charger.c index 361a047..0b5b247 100644 --- a/drivers/power/bq24735-charger.c +++ b/drivers/power/bq24735-charger.c @@ -201,8 +201,12 @@ static bool bq24735_charger_is_present(struct bq24735 *charger) static int bq24735_charger_is_charging(struct bq24735 *charger) { - int ret = bq24735_read_word(charger->client, BQ24735_CHG_OPT); + int ret; + + if (!bq24735_charger_is_present(charger)) + return 0; + ret = bq24735_read_word(charger->client, BQ24735_CHG_OPT); if (ret < 0) return ret;