From patchwork Mon Dec 7 07:43:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 7781331 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4847EBEEE1 for ; Mon, 7 Dec 2015 07:46:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 75A162038A for ; Mon, 7 Dec 2015 07:46:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7508D2039E for ; Mon, 7 Dec 2015 07:46:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753222AbbLGHoL (ORCPT ); Mon, 7 Dec 2015 02:44:11 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:14790 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753102AbbLGHny (ORCPT ); Mon, 7 Dec 2015 02:43:54 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie3.idc.renesas.com with ESMTP; 07 Dec 2015 16:43:53 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 1180A4D74A; Mon, 7 Dec 2015 16:43:53 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id EBFE32806E; Mon, 7 Dec 2015 16:43:52 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id E7DB32806D; Mon, 7 Dec 2015 16:43:52 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id SBP19866; Mon, 7 Dec 2015 16:43:52 +0900 X-IronPort-AV: E=Sophos;i="5.20,393,1444662000"; d="scan'";a="200013677" Received: from mail-sg2apc01lp0245.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.245]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 07 Dec 2015 16:43:51 +0900 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by HKXPR06MB1016.apcprd06.prod.outlook.com (10.161.181.156) with Microsoft SMTP Server (TLS) id 15.1.337.19; Mon, 7 Dec 2015 07:43:49 +0000 Message-ID: <87si3e66zs.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 4/8 v3] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") To: Simon , Zhang Rui , Eduardo Valentin , Geert Uytterhoeven CC: Magnus , , , , "devicetree@vger.kernel.org" In-Reply-To: <87y4d6672t.wl%kuninori.morimoto.gx@renesas.com> References: <87y4d6672t.wl%kuninori.morimoto.gx@renesas.com> Date: Mon, 7 Dec 2015 07:43:49 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HKXPR03CA0041.apcprd03.prod.outlook.com (10.141.129.31) To HKXPR06MB1016.apcprd06.prod.outlook.com (25.161.181.156) X-Microsoft-Exchange-Diagnostics: 1; HKXPR06MB1016; 2:/zHTEMsQXXGxV6NtR6vtAwtBlDEkYgTnS9R/jAChkQVYJSL75clXNP+6PNMk6b39i555rXmg+3DWYhNX5SwdHN6313xg76XGdsfXWS1zMuaFENU/mDyWRcId3N48/4IFwbm5JcgdWOzVA/ffh5b1mA==; 3:7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9ILoy1Vfa8rbZEyJpvDu4T3jO9AEzjfq9P8U/+knBzqLJPNwlmRiCoJqSUg7YUxXfUJnn65Tq1lSAmaJVt87MTNu7Mi7SSj6E7rJIHpvhMippb/3mo/Bwflf9fnmgwQN5rv0vYHGeVuZPIiPAf3RLmMXRj6lkuYLbq9RB7d+cyLnc2/q3C45cM5DbgcjpyeNAYYJylo28daSVRXBYRueQqisDVly0B0oJHaJmMhHEe0H4UE3RUQV0R/eU0UxzLnzlBJmuXWz0aIOGlLlsXcx/M55Fy7QT6B5fIU3fPuhFfhYcqk5XdGnJM+YEXzW4pgpy8Ysc+TrOYopRl6Av7X6O/H8u5VG3+s462vpLHERO5rK5kp 7VrBogVEg/dwvDXK2xcaFp7Uqb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046); SRVR:HKXPR06MB1016; BCL:0; PCL:0; RULEID:; SRVR:HKXPR06MB1016; X-Forefront-PRVS: 078310077C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(586003)(86362001)(6116002)(105586002)(42186005)(69596002)(3846002)(5004730100002)(5008740100001)(19580395003)(23726003)(53416004)(40100003)(106356001)(1096002)(19580405001)(92566002)(122386002)(33646002)(76176999)(97736004)(81156007)(36756003)(77096005)(50986999)(4001350100001)(5001770100001)(46406003)(229853001)(189998001)(54356999)(5001960100002)(87976001)(47776003)(2950100001)(101416001)(83506001)(50466002)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:HKXPR06MB1016; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HKXPR06MB1016; 23:RasSxDvD+Euw0/oEItFbTKnbFDd/OxafWn3uGnD+2?= =?us-ascii?Q?5rMoQwtsNR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?= =?us-ascii?Q?gOriQbtG53i/0lgHTAfNUt54zlXWnA2ZSbgN8o7643423oKhBEsc0UVUASOS?= =?us-ascii?Q?nkJvdy5RnSvAHj1RbfciUVaXQ1iBzFCkLYlyM1tNtT4fCBGdSpptxHGdNnf9?= =?us-ascii?Q?rDffpyLsJFaxzHtHLU6RC/Qs5AOlEP6QyOOzelH+SVaDe9al0kIdPp4KEhDV?= =?us-ascii?Q?GM3IEaGE2w=3D?= X-Microsoft-Exchange-Diagnostics: 1; HKXPR06MB1016; 5:GBEZcMZ6dcwrEVfwFtXc6GAP+aTM8cfuF7jfWZO5KX1v65Z0wGwYB6uCjalVAn4lD120j4D0f4rGGyKkePoy9q8pTLw3RLnlxlTPTdL8RPD/8rWwlbO/i3njfK7L7Mwq/Ie82id7j+bTOaiOi7Tgow==; 24:nxl6ikhz3DGiP0g2CcZY+ZxmtUzT94w1gZfF4excCvHxXuUOEeAZdqKpIPsUXrB5nNlgp7rdWbE9y8WgyHAqshRdEdVkmzEIEQNTbRehhdU=; 20:56tZMc/hN1iXwCJalQVf5JNyKhI/PeQEWCBbCyGNY0AoGmsUKCREZqkiRdSkxWfC7XaxH74mNEXmV9FOdB9Fv3oqJIKhJgUv66cb1JP4mLey64C+75a3+TWTSXOgTxE/R+BV3Z2sjNPLFL5Zl2f0fdbREYqIP3jfk0ajgB0f66Q= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2015 07:43:49.5577 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKXPR06MB1016 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current rcar_thermal_get_temp() returns latest temperature, but it might not be updated if some HW issue happend. This means user might get wrong temperature. This patch solved this issue. Signed-off-by: Kuninori Morimoto --- v2 -> v3 - no change drivers/thermal/rcar_thermal.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index aaedf37..52493b4 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -199,9 +199,9 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv) dev_dbg(dev, "thermal%d %d -> %d\n", priv->id, priv->ctemp, ctemp); - priv->ctemp = ctemp; ret = 0; err_out_unlock: + priv->ctemp = ctemp; mutex_unlock(&priv->lock); return ret; } @@ -209,6 +209,7 @@ err_out_unlock: static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) { struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + int tmp; if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) { int ret = rcar_thermal_update_temp(priv); @@ -217,9 +218,18 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) } mutex_lock(&priv->lock); - *temp = MCELSIUS((priv->ctemp * 5) - 65); + tmp = MCELSIUS((priv->ctemp * 5) - 65); mutex_unlock(&priv->lock); + if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) { + struct device *dev = rcar_priv_to_dev(priv); + + dev_err(dev, "it couldn't measure temperature correctly\n"); + return -EIO; + } + + *temp = tmp; + return 0; }