From patchwork Thu Sep 27 20:08:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11783 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A0E3624140 for ; Thu, 27 Sep 2012 20:09:34 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 68311A18B18 for ; Thu, 27 Sep 2012 20:09:34 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5234801iej.11 for ; Thu, 27 Sep 2012 13:09:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=6rlm29mEltqQGjsH/z585TjoL/6YYXoE/GuH3oG06og=; b=SN53Q9R7sRWiqoOYEKZHU/9dA7oTZ1KwVsvtfKW1OEJ7bSM23tG05CkqJXdR/qXNpb z+kewcstB3IE2zNBbeoRHrW4tyySVppLlbD/cHr/XkHYJ3wXI6ejPbIshcXTiIu98Rzf +pcdEa7wRmsr3vypzcGmfzeUiSpI1Xrzo9FmXxgopsZhRsCgaOa2js+GXw0N8I1JEKeA 0p2g1AOV6xr09GMqkMbUkAGtAIFBMsCZfsl8PKwbgr966lGtklE0NNi9X9REIyt4PHcJ kJ2WDN5T9c26QS1f9nykAHUuyAgebJfoCfLYEpX12bOAoo4wq+vopks+N6IdzkV//aNf lBiQ== Received: by 10.50.217.229 with SMTP id pb5mr4698107igc.28.1348776574204; Thu, 27 Sep 2012 13:09:34 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp436279igc; Thu, 27 Sep 2012 13:09:33 -0700 (PDT) Received: by 10.68.200.8 with SMTP id jo8mr14268140pbc.148.1348776573556; Thu, 27 Sep 2012 13:09:33 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id pi9si5467641pbb.12.2012.09.27.13.09.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) smtp.mail=mathieu.poirier@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md4so1686045pbc.37 for ; Thu, 27 Sep 2012 13:09:33 -0700 (PDT) Received: by 10.66.88.3 with SMTP id bc3mr12121300pab.51.1348776573328; Thu, 27 Sep 2012 13:09:33 -0700 (PDT) Received: from localhost.localdomain (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPS id sa2sm1587890pbc.4.2012.09.27.13.09.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:32 -0700 (PDT) From: mathieu.poirier@linaro.org To: patches@linaro.org Subject: [PATCH 10/57] power: ab8500_charger: Handle gpadc errors Date: Thu, 27 Sep 2012 14:08:27 -0600 Message-Id: <1348776554-10019-11-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> References: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> X-Gm-Message-State: ALoCoQmp/UAuA24JMheBsyFsMx/wvySbpQ4njVrggopslUemWiiL5kvdT5mczEXT+ZYgxFIYhVrW From: Jonas Aaberg Gracefully handle gpadc conversion errors. Signed-off-by: Jonas Aaberg Signed-off-by: Mathieu Poirier Reviewed-by: Johan BJORNSTEDT --- drivers/power/ab8500_charger.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index f7bba07..06a7c8b 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -157,6 +157,7 @@ struct ab8500_charger_info { int charger_voltage; int cv_active; bool wd_expired; + int charger_current; }; struct ab8500_charger_event_flags { @@ -2341,6 +2342,7 @@ static int ab8500_charger_ac_get_property(struct power_supply *psy, union power_supply_propval *val) { struct ab8500_charger *di; + int ret; di = to_ab8500_charger_ac_device_info(psy_to_ux500_charger(psy)); @@ -2362,7 +2364,10 @@ static int ab8500_charger_ac_get_property(struct power_supply *psy, val->intval = di->ac.charger_connected; break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: - di->ac.charger_voltage = ab8500_charger_get_ac_voltage(di); + ret = ab8500_charger_get_ac_voltage(di); + if (ret >= 0) + di->ac.charger_voltage = ret; + /* On error, use previous value */ val->intval = di->ac.charger_voltage * 1000; break; case POWER_SUPPLY_PROP_VOLTAGE_AVG: @@ -2374,7 +2379,10 @@ static int ab8500_charger_ac_get_property(struct power_supply *psy, val->intval = di->ac.cv_active; break; case POWER_SUPPLY_PROP_CURRENT_NOW: - val->intval = ab8500_charger_get_ac_current(di) * 1000; + ret = ab8500_charger_get_ac_current(di); + if (ret >= 0) + di->ac.charger_current = ret; + val->intval = di->ac.charger_current * 1000; break; default: return -EINVAL; @@ -2401,6 +2409,7 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy, union power_supply_propval *val) { struct ab8500_charger *di; + int ret; di = to_ab8500_charger_usb_device_info(psy_to_ux500_charger(psy)); @@ -2424,7 +2433,9 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy, val->intval = di->usb.charger_connected; break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: - di->usb.charger_voltage = ab8500_charger_get_vbus_voltage(di); + ret = ab8500_charger_get_vbus_voltage(di); + if (ret >= 0) + di->usb.charger_voltage = ret; val->intval = di->usb.charger_voltage * 1000; break; case POWER_SUPPLY_PROP_VOLTAGE_AVG: @@ -2436,7 +2447,10 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy, val->intval = di->usb.cv_active; break; case POWER_SUPPLY_PROP_CURRENT_NOW: - val->intval = ab8500_charger_get_usb_current(di) * 1000; + ret = ab8500_charger_get_usb_current(di); + if (ret >= 0) + di->usb.charger_current = ret; + val->intval = di->usb.charger_current * 1000; break; case POWER_SUPPLY_PROP_CURRENT_AVG: /*