From patchwork Tue Feb 27 15:14:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10245665 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 E09AB60362 for ; Tue, 27 Feb 2018 15:14:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEF642894C for ; Tue, 27 Feb 2018 15:14:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C399A2894F; Tue, 27 Feb 2018 15:14:17 +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 27FDE28952 for ; Tue, 27 Feb 2018 15:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754108AbeB0POO (ORCPT ); Tue, 27 Feb 2018 10:14:14 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:45338 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753292AbeB0POM (ORCPT ); Tue, 27 Feb 2018 10:14:12 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180227151410euoutp01209fa8f0ca6787ed22ce896858b9d83f~XN4aNRtbs2939829398euoutp01J; Tue, 27 Feb 2018 15:14:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180227151410euoutp01209fa8f0ca6787ed22ce896858b9d83f~XN4aNRtbs2939829398euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519744450; bh=Ng2MKMRlruW1K0uQKjbwFPyC4WFUcZm5UKyyP7+9pAM=; h=From:To:Cc:Subject:Date:References:From; b=abpxwyv0TN0N/cXFkox79+9wtR9qykt12nMe0MJ56H+41FKQEqv0S0OBoAGkuAB/I I/LwMb2nQ+PdPu1Hz/7j5ogSMAMioiB7JUleNmhC+wX6/dK8n9rpyBoPjPu05ZzM4y CBOVAAHmmD7azgk8F5TTTj28dZCWwu42wCvz2YU0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180227151409eucas1p1726f62e7b897ee6445561f2d61d3e3fb~XN4ZWWMFA2888028880eucas1p1x; Tue, 27 Feb 2018 15:14:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id BA.19.05700.1C5759A5; Tue, 27 Feb 2018 15:14:09 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180227151408eucas1p20dc5f0974dda96b4ebaff7948eda766a~XN4Yq1YIJ1178911789eucas1p28; Tue, 27 Feb 2018 15:14:08 +0000 (GMT) X-AuditID: cbfec7f2-1c1ff70000011644-89-5a9575c1bdb2 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C5.A4.04178.0C5759A5; Tue, 27 Feb 2018 15:14:08 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4T00GNKEBHY250@eusync4.samsung.com>; Tue, 27 Feb 2018 15:14:08 +0000 (GMT) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org Cc: stable@vger.kernel.org, Marek Szyprowski , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Eduardo Valentin , Zhang Rui Subject: [PATCH] thermal: exynos: Propagate error value from tmu_read() Date: Tue, 27 Feb 2018 16:14:05 +0100 Message-id: <20180227151405.9618-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRmVeSWpSXmKPExsWy7djPc7oHS6dGGRz4wGSxccZ6Vov5V66x Wpw/v4Hd4nPvEUaLGef3MVmsPXKX3eLJwz42iwUbHzE6cHjsnHWX3WPxnpdMHptWdbJ59G1Z xejxeZNcAGsUl01Kak5mWWqRvl0CV8aZH39YCl7zVuzespylgXE3dxcjJ4eEgInEhCMP2LsY uTiEBFYwSuybvJwRJCEk8JlRYsLzGpiii9NfM0EULWOU+HehmwXCaWCSOL1lHitIFZuAoUTX 2y42EFtEwF7i9pNlYGOZQSbtaZjEDpIQFnCX6DxwBqyIRUBV4vfsW2A2r4CNxOyp91kg1slL LP6+kw3C/soqsfSgGoTtItH05CEzhC0s8er4FnYIW0ais+Mg2HkSAv1A5/1/CeXMYJRY/7EV qspa4vDxi2CnMgvwSUzaNh1oEgdQnFeio00IosRDovNTEyuE7Shxd/FmVkhYxEpcf/uWaQKj 5AJGhlWM4qmlxbnpqcWGeanlesWJucWleel6yfm5mxiBsXj63/FPOxi/Xko6xCjAwajEw5uR PTVKiDWxrLgy9xCjBAezkgjvysWTo4R4UxIrq1KL8uOLSnNSiw8xSnOwKInzxmnURQkJpCeW pGanphakFsFkmTg4pRoYK53Ma9/L8Hx98OaPxoTq94fV6q6z5t+QcfIvb3ydkn7kl72k1Jb+ 5tcBskc2WHuq//6gFderZ6h88oku5+aK654OE+YtjdKetIz3i6SDXBzDhT634jUnpqRPuO2l 7BG6cP7X8qglr3JfH3n8+eITfrG1YRYeq/59OmJp+7TSnjUpdKra3F2BSizFGYmGWsxFxYkA 3S+RlcECAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKJMWRmVeSWpSXmKPExsVy+t/xa7oHSqdGGZzZpmqxccZ6Vov5V66x Wpw/v4Hd4nPvEUaLGef3MVmsPXKX3eLJwz42iwUbHzE6cHjsnHWX3WPxnpdMHptWdbJ59G1Z xejxeZNcAGsUl01Kak5mWWqRvl0CV8aZH39YCl7zVuzespylgXE3dxcjJ4eEgInExemvmboY uTiEBJYwShw4d5MRwmlikmjccJQVpIpNwFCi620XG4gtImAvcfvJMnaQImaBz4wSW7e3sYAk hAXcJToPnAErYhFQlfg9+xaYzStgIzF76n0WiHXyEou/72SbwMi1gJFhFaNIamlxbnpusaFe cWJucWleul5yfu4mRmBgbDv2c/MOxksbgw8xCnAwKvHwZmRPjRJiTSwrrsw9xCjBwawkwrty 8eQoId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rznDSqjhATSE0tSs1NTC1KLYLJMHJxSDYysXYqH Nt9/bjj93rLZ2fPdZeOv1Cd/ujR755lpgqev1l24vW3Z36OvL9/XcFCrFts09XEZg23Z5jyr U2nlKV9FVN6+vBxXUpXx/dPrkz29PUyWeYctk7f+OKZ1a/07J/s03hfdsd83/5yy/1SQ60KG mzOsHXQvnF2htM5KMF9GntGsVOtv4ce1SizFGYmGWsxFxYkAeaYUGQgCAAA= X-CMS-MailID: 20180227151408eucas1p20dc5f0974dda96b4ebaff7948eda766a X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180227151408eucas1p20dc5f0974dda96b4ebaff7948eda766a X-RootMTR: 20180227151408eucas1p20dc5f0974dda96b4ebaff7948eda766a References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP tmu_read() in case of Exynos4210 might return error for out of bound values. Current code ignores such value, what leads to reporting critical temperature value. Add proper error code propagation to exynos_get_temp() function. Signed-off-by: Marek Szyprowski CC: stable@vger.kernel.org # v4.6+ Acked-by: Bartlomiej Zolnierkiewicz --- This patch is prepared on top of "thermal: exynos: Reading temperature makes sense only when TMU is turned on" patch. Both are required to finally fix thermal support on Exynos4210 based boards. This patch only applies cleanly together with the mentioned "thermal: exynos: Reading temperature makes sense only when TMU is turned on" patch on v4.6+ kernels. --- drivers/thermal/samsung/exynos_tmu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 986cbd01aaaa..74adeb1d2daf 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -892,6 +892,7 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on) static int exynos_get_temp(void *p, int *temp) { struct exynos_tmu_data *data = p; + int value, ret = 0; if (!data || !data->tmu_read || !data->enabled) return -EINVAL; @@ -899,12 +900,16 @@ static int exynos_get_temp(void *p, int *temp) mutex_lock(&data->lock); clk_enable(data->clk); - *temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS; + value = data->tmu_read(data); + if (value < 0) + ret = value; + else + *temp = code_to_temp(data, value) * MCELSIUS; clk_disable(data->clk); mutex_unlock(&data->lock); - return 0; + return ret; } #ifdef CONFIG_THERMAL_EMULATION