Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932979AbbLHF2W (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 X-IronPort-AV: E=Sophos;i="5.20,397,1444662000"; d="scan'";a="201319653" Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; 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> Content-Type: text/plain; charset="US-ASCII" 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==;3:o1H5Fdyu4sANggiPBlYa2TcCBUYDEZsBh/Y6Yt1kFBslZP+ILKNDQfXl954b327V5JjVySZwWuwt0aj7TPb5H7HAoSd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uDypV+csCbfM08jNzQLDRfuBegIlt/LFEbuY3zqez1wlG1GAV94jnfalngYmlzMrggKvZKvdyepKhUSVL66fl3BAizy3+A3qHHkSneGMuVIVSBli30sfAlMC5jo6vw7UKbqDqiStqmSmWCmFuOdO10y+PJQ8h/Gp3w+dEy+nX43HSPvHXGoe76rewFuoa+WzmfQXheUKImrqwBrMoBks8KD5FCihu+Fwk5E46CwVCU3cKiTcW53FadubU7aP6IJq1rRSOoz5AqdCqmi+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?7vazZErWSwYkB96Y1jKBTALfRxohEfvkCZPaaw8Immk6K/z9Jk4WXWCNPsk4?= =?us-ascii?Q?WtZGwBdMx/Gh8ZUrKLUMvsXZKMKmkDkFtu5N299vubaPhjqEsL/G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mE4s+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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1966 Lines: 66 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; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/