From patchwork Tue Dec 8 05:28:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 7794371 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 CDE22BEEE5 for ; Tue, 8 Dec 2015 05:28:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1424A20527 for ; Tue, 8 Dec 2015 05:28:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1AA4520532 for ; Tue, 8 Dec 2015 05:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932624AbbLHF2W (ORCPT ); Tue, 8 Dec 2015 00:28:22 -0500 Received: from relmlor3.renesas.com ([210.160.252.173]:57943 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932577AbbLHF2S (ORCPT ); Tue, 8 Dec 2015 00:28:18 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie2.idc.renesas.com with ESMTP; 08 Dec 2015 14:28:16 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id DF32844021; Tue, 8 Dec 2015 14:28:16 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id D30E6480A3; Tue, 8 Dec 2015 14:28:16 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id CD4E348014; Tue, 8 Dec 2015 14:28:16 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac4.idc.renesas.com with ESMTP id QAB26297; Tue, 8 Dec 2015 14:28:16 +0900 X-IronPort-AV: E=Sophos;i="5.20,397,1444662000"; d="scan'";a="201319653" Received: from mail-hk2apc01lp0211.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.211]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 08 Dec 2015 14:28:15 +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 SG2PR06MB1018.apcprd06.prod.outlook.com (10.161.9.26) with Microsoft SMTP Server (TLS) id 15.1.337.19; Tue, 8 Dec 2015 05:28:13 +0000 Message-ID: <87poyh5x69.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 4/8 v4] 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 CC: Geert Uytterhoeven , Magnus , , , , "devicetree@vger.kernel.org" In-Reply-To: <87vb895x9d.wl%kuninori.morimoto.gx@renesas.com> References: <87vb895x9d.wl%kuninori.morimoto.gx@renesas.com> Date: Tue, 8 Dec 2015 05:28:13 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HK2PR02CA0008.apcprd02.prod.outlook.com (25.163.104.146) To SG2PR06MB1018.apcprd06.prod.outlook.com (25.161.9.26) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1018; 2:kT2u3hqJMI/Im3U49XCpS3mVh11TGwbhWfgSWNe5ALGLfERfqd2PEBd1+/TRmlQhFF+ZHiO/0NZVqttjMhdKyYMTYlJrAFIOKnhWJq2T1NfN5qDzKcgK8a8C1PIb2Nx139c6M87YIDkoD4E3/NEC5g==;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+xPxne7d7XS7y0nQMKU1VppttsRqv1WrCesbwO+KOSTc0hwDijYyFioG/uDEu5REY3lP0n8syWm68YcFnTuVDgTpMbOjf5XF9Y8/uDypV+csCbfM08jNzQLDRfuBegIlt/LFEbuY3zqez1wlG1GAV94jnfalngYmlzMrggKvZKvdyepKhUSVL66fl3BAizy3+A3qHHkSneGMuVIVSBli30sfAlMC5jo6vw7UKbqDqiStqmSmWCmFuOdO10y+PJQ8h/Gp3w+dEy+nX43HSPvHXGoe76rewFuoa+WzmfQXheUKImrqwBrMoBks8KD5FCihu+Fwk5E46CwVCU3cKiTcW53FadubU7aP6IJq1rRSOoz5A qdCqmi+4vi9ib5E+9Kaz3AedkX 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)(3002001)(10201501046); SRVR:SG2PR06MB1018; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1018; X-Forefront-PRVS: 0784C803FD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(6116002)(19580405001)(19580395003)(97736004)(36756003)(50466002)(5001770100001)(69596002)(81156007)(83506001)(87976001)(105586002)(4001350100001)(66066001)(101416001)(5001960100002)(77096005)(92566002)(33646002)(46406003)(40100003)(23726003)(106356001)(586003)(3846002)(2950100001)(229853001)(189998001)(1096002)(5008740100001)(50986999)(122386002)(5004730100002)(86362001)(47776003)(42186005)(76176999)(53416004)(54356999); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB1018; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB1018; 23:mrDeKN/8D8xPCEbcyGr/FH0AcyWCz9RlvsbbkF8iJ?= =?us-ascii?Q?7vazZErWSwYkB96Y1jKBTALfRxohEfvk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?Q?CxsWssIzdp9kWTaXgVhgm8j9mwBQ0wrZq46Pt5QWuGhEWBHXDNbUDlMwExpQ?= =?us-ascii?Q?10cEPLGIe0OKpo+JXmE4s+zY9+2e90pwCR9j7+Sfj8ZHWApChej3oYdyfHFZ?= =?us-ascii?Q?xdy9le6NLRz2LAA5w7To67sDNmIOtYMWTGVsdaFaQf2iWOmXj3ExvrLuO1Lq?= =?us-ascii?Q?Til+SEoiJg=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1018; 5:bGgDQ2NyRWXTIJhP2kj2P4bfAv5bEwnPM3cCd02SpaU8eMrzPO/BoShxv+w5PX+fRONOE5oC/0iOxvX9poh3kN4dgES1zXkrFlXUFK313I7TszrigGsSLrFQ1XLzzhhN3/pMNjhBLXdgT4Dv5xJe1Q==; 24:hi/rKFOgyIk/zdntRGQdLcCjxbShtmLFdMifTmal87DsXcPmT9hgsUU6dK6XSUjhpP+2yNc3itMLlk/3k5j5Coa3FwQrGoZSxcNZHJ/gmnk=; 20:EevRJGB91wa7p1YFx7OpUIDuTYyNSPJyjiZgekIGG7ZIsKlToCiJrgVcjiYbnPXLMfSYnZUTSsChmX0pSFrM/4aNtFbb1gan4A2wFL00s/febjZnEIGecZSO5ZAmGyZDDem0D1mci7jPJHe4uZ3WI4IgoTozrBDQI0RBrwntBJ4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2015 05:28:13.4578 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1018 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=unavailable 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 happened. This means user might get wrong temperature. This patch solved this issue. Signed-off-by: Kuninori Morimoto --- v3 -> v4 - "happend" -> "happened" 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 67b5216..40c3ba5 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); @@ -218,9 +219,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; }