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: 663401 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sMhvS60Q1z9s9c for ; Mon, 29 Aug 2016 03:43:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755834AbcH1Rmk (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) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on gagarine.paulk.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 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-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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;