From patchwork Fri Nov 18 23:52:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9437677 X-Patchwork-Delegate: rui.zhang@intel.com 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 80F0960237 for ; Fri, 18 Nov 2016 23:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A42029A5D for ; Fri, 18 Nov 2016 23:53:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B87228B98; Fri, 18 Nov 2016 23:53: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 BEF4228B98 for ; Fri, 18 Nov 2016 23:53:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753118AbcKRXxC (ORCPT ); Fri, 18 Nov 2016 18:53:02 -0500 Received: from mail-pg0-f53.google.com ([74.125.83.53]:35478 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752513AbcKRXxC (ORCPT ); Fri, 18 Nov 2016 18:53:02 -0500 Received: by mail-pg0-f53.google.com with SMTP id p66so107708914pga.2 for ; Fri, 18 Nov 2016 15:53:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=JrUeBbK1LxL+wM8dY+uBcURffn44eBjrTPYnMU8+7Hs=; b=FyZQbCKj23CK6BHaqsPAabBc7tm5ejDaDex/V8oINJbTR2K2m41Y27gCxNSaeCU1B9 LU2nga1RQoSaev1ruSNcKmCVhHODeVCp6jtHLHZhqGsS3eaJFAIeN/B+BlcgXtfOspSa r97+Mv6TE78CDeoTyTcnDOsv3AWJgJNT2x46w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JrUeBbK1LxL+wM8dY+uBcURffn44eBjrTPYnMU8+7Hs=; b=Vmwyfm/2WV0+7vI5oSkzQSnb+SmxytaXf7p/K8LZzkCrqLaXcC9qCeoeahkr64FLqt J8gIjDRhirp65ri66Vc265uriz/7gka/gFmKuTjoiptyEN/GcDaTi5T+JNIWXk5Cjpyn cbAwpAcmrfU35UjLbgRmK2KPXA6P+hoCHE/vhX3F5gSQcVQZaHCNngRe64pWnCJtObfn 5ye5k1c27LWQWAJZ1uympuroZTNYxNS1BAxFYLS0la6VRZMTeeLmPGiW2nZVCZcEBFbM +r6t30hJU0jnUU1Z6/nIlLHsNXfq+sGpw+luKfuLX9sUi1viswsSYIw8R04+eG6AGetl uFIQ== X-Gm-Message-State: AKaTC01dkPz+wX0t2b1T4iQcJfzwza0xqBVor8Z/Me1qGFzKvqaenCXT4apctBme++zB6lo6 X-Received: by 10.99.113.5 with SMTP id m5mr4848398pgc.34.1479513181296; Fri, 18 Nov 2016 15:53:01 -0800 (PST) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id t21sm20428247pfa.1.2016.11.18.15.53.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Nov 2016 15:53:00 -0800 (PST) From: Brian Norris To: Zhang Rui , Eduardo Valentin Cc: Heiko Stuebner , linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Caesar Wang , Stephen Barber , Brian Norris Subject: [PATCH 1/3] thermal: handle get_temp() errors properly Date: Fri, 18 Nov 2016 15:52:55 -0800 Message-Id: <1479513177-81504-1-git-send-email-briannorris@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 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 If using CONFIG_THERMAL_EMULATION, there's a corner case where we might get an error from the zone's get_temp() callback, but we'll ignore that and keep using its value. Let's just error out properly instead. Signed-off-by: Brian Norris Tested-by: Caesar Wang --- drivers/thermal/thermal_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 911fd964c742..0fa497f10d25 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -494,6 +494,8 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) mutex_lock(&tz->lock); ret = tz->ops->get_temp(tz, temp); + if (ret) + goto exit_unlock; if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { for (count = 0; count < tz->trips; count++) { @@ -514,6 +516,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) *temp = tz->emul_temperature; } +exit_unlock: mutex_unlock(&tz->lock); exit: return ret;