From patchwork Fri Dec 4 08:33:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 7766051 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 C87D8BEEE1 for ; Fri, 4 Dec 2015 08:33:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E0E55204A2 for ; Fri, 4 Dec 2015 08:33:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EBA1D204A0 for ; Fri, 4 Dec 2015 08:33:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755472AbbLDIdx (ORCPT ); Fri, 4 Dec 2015 03:33:53 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:34084 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755335AbbLDIdv (ORCPT ); Fri, 4 Dec 2015 03:33:51 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 04 Dec 2015 17:33:50 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 746D24C150; Fri, 4 Dec 2015 17:33:50 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 668398002E; Fri, 4 Dec 2015 17:33:50 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 601428002D; Fri, 4 Dec 2015 17:33:50 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id TAD03642; Fri, 4 Dec 2015 17:33:50 +0900 X-IronPort-AV: E=Sophos;i="5.20,380,1444662000"; d="scan'";a="201127200" Received: from mail-pu1apc01lp0015.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.15]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 04 Dec 2015 17:33:49 +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 HK2PR06MB1010.apcprd06.prod.outlook.com (10.161.187.27) with Microsoft SMTP Server (TLS) id 15.1.331.20; Fri, 4 Dec 2015 08:33:47 +0000 Message-ID: <87bna6fwdr.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 4/8 v2] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Simon , Zhang Rui , Eduardo Valentin CC: Magnus , , , In-Reply-To: <87h9jyfwj7.wl%kuninori.morimoto.gx@renesas.com> References: <87h9jyfwj7.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 4 Dec 2015 08:33:47 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR0201CA0031.apcprd02.prod.outlook.com (25.164.90.169) To HK2PR06MB1010.apcprd06.prod.outlook.com (25.161.187.27) X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1010; 2:IcgwmQmlpeIgesTe6jg/anOeRoTNetNLBgHJUNf+7JLbwcJYvGAVdLGqwE6CAFD9p9vX0Uf9V8TmW05laqSucqj/RWa1wLOQIhjylRxiocjVNi+yNHgZuUipp0sj+wKFe3ZESkyY2yAsOjKJx9H9nw==; 3:j+bn7FGnhXp8kzE4URpoY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IG9RrvjLFjbhCDKIY5XfHvgX5lwir89fq0LqfZRawDAbFDW05Si+2dKO4lZPdg1GmlUQ7AUoWb+TfAbM0lqnSc1Mimfk8ZKMJE56fa2iyfKceVpRzRrbf1f0j/y0o2Mt1uES9WaAUVv1JfUexMa/ywTHWvcv2YzYYetWotE2zHrifWH6UU22hJPNm3w4rvsD0EBUxpgWJzdRZND9SgHrJQySsfMoVthIIJcc9upOXnIYf/uSYNWcmHZ+IofNZGV6RvenYPHWrW/MGQTKkmgsDwrW4qE1xMVDX3S+c083WVWjaRTipMGFm7hrh+qPPHalYgJ/pL7Z4VMfi/7zuRDzFPkkWEpWvIAO9HVQgwW2qcirtD 0oKd71v4Fjq+BbVj3AxStxylwM X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:HK2PR06MB1010; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB1010; X-Forefront-PRVS: 07807C55DC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(46406003)(92566002)(40100003)(122386002)(2950100001)(87976001)(69596002)(83506001)(19580405001)(19580395003)(54356999)(101416001)(105586002)(106356001)(76176999)(586003)(23726003)(50986999)(6116002)(229853001)(3846002)(66066001)(47776003)(33646002)(77096005)(50466002)(86362001)(42186005)(53416004)(1096002)(5008740100001)(5004730100002)(5001960100002)(189998001)(81156007)(4001350100001)(97736004)(36756003)(5001770100001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1010; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1010; 23:eaf5P3Bm6R9Af50RJ5+hYhpwDV45rXXh81NGgJnC8?= =?us-ascii?Q?pUubjhW2mIbfS3mynJSB6e9/TAK1wAq9RLyaiyABnSnImpS9LNNEayRbyf5g?= =?us-ascii?Q?uOenml0zyyJ/0/Yqz5KkKBaaXKNNdpptA+ZTGqZ2Krs/S1uAiW0Emth0WQH3?= =?us-ascii?Q?FY8QgXxVarvVTPk5O4AwQyw74KT608oDaQTPT/o0CAmrS906GrGZgIhrwZ+U?= =?us-ascii?Q?OU3HtmsTRWma2FAGnOBGEtB4RPADELCLeQp2XauDdku3Xkz7Uba0VUzUdlgY?= =?us-ascii?Q?pdRijRT1iViWJG8rFHn09eid8+HkcQHkKCWqm3bWRemjnN2pvQB9DbbJS9Es?= =?us-ascii?Q?P4s+gMWYo43IeNf7tmrxFmCYUTp5c2DiTYWXl4lGIMczPKiZ3qr+j7dbnrsH?= =?us-ascii?Q?UoKQAtlYYRZMtvJoQh5te53S1pdsHJIT7rJicFet600ml42GyKjoqTia5CgL?= =?us-ascii?Q?lI4H5YkY2mCAvxki2JA/BA9b91k1xV49LXh9o8I1NgtajPKzn2vbyFYU6C15?= =?us-ascii?Q?wRrzphljeF6RDqWJqN2YTiQSGK+YLidc35uoSw5YErncPmkuBNOtlBES+9XY?= =?us-ascii?Q?LBnElLO6jAQDVEJ/OckmQlKepI3fPQtjaIXw9GoVV2QG+kRj/+evxK3qhdgV?= =?us-ascii?Q?GCo4koFT/6b5+6HZ7MtC24XweIA3W9ZiSMKxShmab6VpomJxVItdy2+L/JCl?= =?us-ascii?Q?PRbH+CKL4RvuH8dmp8mr/bweGKbEmclFl76ejsxO+/kpPwx21uo1vIMlKNQd?= =?us-ascii?Q?QyHy2KB0kMfNq/aQ6cBB9GTKgcoHyV5+BB63aaJjUsO772Lkb+NTWbHLSHqU?= =?us-ascii?Q?KZrqkiz5141xMFciPzhhvgjbXHLCQswjeGaFZaiDP5dMfkPmuL3q5Dlz9EHo?= =?us-ascii?Q?ID7Twm3FxTIHnclMewnafaGAvslMqLF4H1Jq4iepLmwCC84/cs9fk5Y3/Mv8?= =?us-ascii?Q?USGS7fEB7CbnIBfSJu8oLYPWzBEmoyp4vWQfi98xuZaw5lyPsc/5RmFRponu?= =?us-ascii?Q?PIyiU1sCqm+pR1l9T6MuU9XZmyG9ayFUi3vL5sebKPHbcVLLYnz5SGz9tw+u?= =?us-ascii?Q?mPsCY6VS1ZBFbPBJ3W8KO6llEcSKVThmN3pf/7CmgMHgwKQixK4NehiMk8jP?= =?us-ascii?Q?2F4V8gUiXw=3D?= X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1010; 5:CKSpV0IWnpZJBb2MQvlxrGnkKA9ORN8pNXIxnj+FRNSA/ekWjzOdupoTyQkBSsjRSMKFCDZ5ot5VH81UAT5VfZA4tJ7YjENoRnVk60bZhYOECySDLygL/akD3OsqDOLuMVjmunzrnGlwhJgVALEQUw==; 24:ulJk5t3IghMq0T8ee/1CwqgJChp5nKy1amgiWmLA4Rh92EDv/mwab4035HOrxRDQkyZ72eYQJJFw7nl8REULpF8OfAGW8Iabkje2KUos90E=; 20:R70CfCNhQPpnSqfbUjrTiSdE/zdyFIneIMrEwqGAK+e6mc/bwxkNPjEmwsb8VQ78IrARUXf8+JAGWXSAcIRXySPj22/viM+a2CwBAatQ2tHvD+qzYZZvVMJ+8/oWk6Aa03wcdBU+E9o0T7s1D3/AT7ePH+P5avzl65ExSqHv4h8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2015 08:33:47.9889 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB1010 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 --- v1 -> v2 - new patch 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; }