From patchwork Fri Jan 11 13:12:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13978 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 2C26E23E27 for ; Fri, 11 Jan 2013 13:13:33 +0000 (UTC) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by fiordland.canonical.com (Postfix) with ESMTP id CA5C6A1849E for ; Fri, 11 Jan 2013 13:13:32 +0000 (UTC) Received: by mail-vb0-f46.google.com with SMTP id b13so1376224vby.19 for ; Fri, 11 Jan 2013 05:13:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=5208rJ2f8qcOFnbdHVeBw1dof7lWvB1jLAm3kE9ypN8=; b=iHO8l9U/eo2K6zGN0sB8E0ssBImWwsNz8Ja1OjA4rV6RqRx6yaWQKgnAVRfYilipXP AcZtxu2J6rUQaboXZNZj6ZrFMKp+MwPSoGHsZK8tHABS8hZT/QjdcN2I+qToJ8BA6sSu 1HsiidjPjhFdDpcqjLrKoatrGRu3wWT7W6WTT7WfP/9mLmzG+i/1qBnHBpKyRgDU7X8o UVFfxa9MGWP/OjdStCQn5NTRIlD5Lerro+M0r35SsSGr+dqDDYj3KbtqbNT3JUFl+Kzv U0YCj0Oy0ARcE9rpsxiGoUCsRQ6l6t/OBZUDy7Z8uz9SRXfRgILgGy7SJkodE8u5UCqZ 7fpA== X-Received: by 10.52.88.168 with SMTP id bh8mr80222571vdb.51.1357910012344; Fri, 11 Jan 2013 05:13:32 -0800 (PST) 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.58.145.101 with SMTP id st5csp111231veb; Fri, 11 Jan 2013 05:13:31 -0800 (PST) X-Received: by 10.181.13.75 with SMTP id ew11mr15589507wid.9.1357910011363; Fri, 11 Jan 2013 05:13:31 -0800 (PST) Received: from mail-we0-f173.google.com (mail-we0-f173.google.com [74.125.82.173]) by mx.google.com with ESMTPS id br1si8666916wjc.54.2013.01.11.05.13.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Jan 2013 05:13:31 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.173 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.173; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.173 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-we0-f173.google.com with SMTP id z2so822957wey.18 for ; Fri, 11 Jan 2013 05:13:31 -0800 (PST) X-Received: by 10.194.142.162 with SMTP id rx2mr8870989wjb.17.1357910010979; Fri, 11 Jan 2013 05:13:30 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id p2sm7204515wic.7.2013.01.11.05.13.29 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Jan 2013 05:13:30 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, cbouatmailru@gmail.com, Jonas Aaberg , Lee Jones Subject: [PATCH 05/18] power: ab8500_charger: Handle gpadc errors Date: Fri, 11 Jan 2013 13:12:53 +0000 Message-Id: <1357909986-9262-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357909986-9262-1-git-send-email-lee.jones@linaro.org> References: <1357909986-9262-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQltjaiat+Qf5FzGqvMuW4WKwCBffqrK/KndxMiz1lRLY8QX4n/RsuWKgvVfP/IlgAHvA1+d From: Jonas Aaberg Gracefully handle gpadc conversion errors. Signed-off-by: Lee Jones Signed-off-by: Jonas Aaberg Reviewed-by: Johan BJORNSTEDT --- drivers/power/ab8500_charger.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index bbf7782e..919d156 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -160,6 +160,7 @@ struct ab8500_charger_info { int charger_voltage; int cv_active; bool wd_expired; + int charger_current; }; struct ab8500_charger_event_flags { @@ -2358,6 +2359,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)); @@ -2379,7 +2381,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: @@ -2391,7 +2396,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; @@ -2418,6 +2426,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)); @@ -2441,7 +2450,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: @@ -2453,7 +2464,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: /*