From patchwork Thu Apr 26 11:51:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 10365857 X-Patchwork-Delegate: eduardo.valentin@ti.com 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 B866E602DC for ; Thu, 26 Apr 2018 11:57:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8D7128EBD for ; Thu, 26 Apr 2018 11:57:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D25528ED5; Thu, 26 Apr 2018 11:57:15 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 47E8928EBD for ; Thu, 26 Apr 2018 11:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754905AbeDZL5M (ORCPT ); Thu, 26 Apr 2018 07:57:12 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:21273 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755973AbeDZLwQ (ORCPT ); Thu, 26 Apr 2018 07:52:16 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180426115215epoutp03b14be3c332b5b5c59e4c7aceff5f3573~o_iqv0zYj2180121801epoutp03M; Thu, 26 Apr 2018 11:52:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180426115215epoutp03b14be3c332b5b5c59e4c7aceff5f3573~o_iqv0zYj2180121801epoutp03M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1524743535; bh=xEO8bfVl/ij0UZIJXd7sK4oUwExDKQ9jbXYNX85ZtvI=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=vJCdxBMBcGcSeU9t+umN6D95dZHVF9yZGnIaNKN7Nh0DWTdpPVXRv/KBnGUPsnwvV 6tc4R3q1z4IYGoSUgzNu/KrSL0UEqt2lxjeMsFl+YUJiOF3N1tRnqmAyBM1YC95FWM Opf96yAQQjDs2rsH+S/N3tAKgcvT2/B43/0HdObo= Received: from epsmges2p3.samsung.com (unknown [182.195.42.71]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20180426115214epcas2p3d46b13c7b9445ece2148531689a52ac0~o_iqYLFG-0036100361epcas2p3s; Thu, 26 Apr 2018 11:52:14 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 46.6D.04113.E6DB1EA5; Thu, 26 Apr 2018 20:52:14 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20180426115214epcas2p33003bbbe84310405c6871853f0df40e3~o_ip7iR370036100361epcas2p3q; Thu, 26 Apr 2018 11:52:14 +0000 (GMT) X-AuditID: b6c32a47-bdfff70000001011-af-5ae1bd6ee72b Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id CE.2B.03817.D6DB1EA5; Thu, 26 Apr 2018 20:52:14 +0900 (KST) Received: from AMDC3058.DIGITAL.local ([106.120.53.102]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P7S00GD7JMBQG00@mmp2.samsung.com>; Thu, 26 Apr 2018 20:52:13 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Eduardo Valentin Cc: Zhang Rui , linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com Subject: [PATCH 06/18] thermal: exynos: fix trips limit checking in get_th_reg() Date: Thu, 26 Apr 2018 13:51:21 +0200 Message-id: <1524743493-28113-7-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1524743493-28113-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRmVeSWpSXmKPExsWy7bCmqW7e3odRBjdPqFlsnLGe1WL+lWus Fpd3zWGz+Nx7hNFixvl9TBZPHvaxObB57Jx1l91j8Z6XTB59W1YxenzeJBfAEsVlk5Kak1mW WqRvl8CVcePFK9aCnRwVvRMaWBsYm9m7GDk5JARMJDY+P83cxcjFISSwg1Hix5KNbBDOd0aJ Ndd+MMNUXT8/lR0isYFRYsqKfSwQzi9GiZtXHjCBVLEJWElMbF/FCGKLCGhJnLi0nQmkiFlg DqPErIbdQB0cHMICQRL/n8WD1LAIqEpsn9nLAmLzCnhItDd9YYXYJidx8thkMJtTwFPiwpEm sGUSAn9ZJfa3vWAEmSMh4CIx+UoaRL2wxKvjW6D+kZZ4tmojI0R9M6PEtx17oF6YwCixZ70Q hG0tcfj4RbAFzAJ8Eh2H/7JDzOSV6GiDKvGQuN69DyrsKNE/NwXiX6BXLsx6zDyBUWoBI8Mq RrHUguLc9NRiowJjveLE3OLSvHS95PzcTYzgCNRy38G47ZzPIUYBDkYlHt6AhQ+ihFgTy4or cw8xSnAwK4nwxrc+jBLiTUmsrEotyo8vKs1JLT7EKM3BoiTO2+B7JkpIID2xJDU7NbUgtQgm y8TBKdXAKPbg2cqlH5esd7+57OLTYPkjYZpWRldNZ5wQ/v+y4Db/ofwzv5mKuVPcDrAe1am6 7/GTKWXeiVmMd2JZVtnksyxrdTns/ilcOnZdqerdyev45trbaNm2rYiM63j+YMtmDcHfEVIT bVXZM+/H3Xo98ZWClvbWMN1tX71yZoQqXF7LXXicc3q0iBJLcUaioRZzUXEiAAKYWVa8AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpiluLIzCtJLcpLzFFi42I5/e+xoG7e3odRBreXsVtsnLGe1WL+lWus Fpd3zWGz+Nx7hNFixvl9TBZPHvaxObB57Jx1l91j8Z6XTB59W1YxenzeJBfAEsVlk5Kak1mW WqRvl8CVcePFK9aCnRwVvRMaWBsYm9m7GDk5JARMJK6fnwpkc3EICaxjlHj0/zYrSEJI4Bej xKvzWSA2m4CVxMT2VYwgtoiAlsSJS9uZQBqYBeYwSjxfMYcJJCEsECDRdvUxmM0ioCqxfWYv C4jNK+Ah0d70hRVim5zEyWOTwWxOAU+JC0eaWCCWeUjc73vPNoGRZwEjwypGydSC4tz03GKj AqO81HK94sTc4tK8dL3k/NxNjMCQ2XZYq38H4+Ml8YcYBTgYlXh4AxY+iBJiTSwrrsw9xCjB wawkwhvf+jBKiDclsbIqtSg/vqg0J7X4EKM0B4uSOC9//rFIIYH0xJLU7NTUgtQimCwTB6dU A2N8iVtuRa7n1PKVK6eePLTi3YJ5d4xMNNgLJ00/I/rn86Hj277xK6m1+6Rvv/buW1zHquvM ejJsXxrvmqz9YrP/6PSLTouLLudPPKxveeZKyovKo6uU7ir75q7QfiIYz7npwRWx+4wHL0w+ cvVxxz2V0AXv17UVPDFZamPWVTCr1Erzb1Z1+WoHJZbijERDLeai4kQAfUXgKhUCAAA= X-CMS-MailID: 20180426115214epcas2p33003bbbe84310405c6871853f0df40e3 X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180426115214epcas2p33003bbbe84310405c6871853f0df40e3 X-RootMTR: 20180426115214epcas2p33003bbbe84310405c6871853f0df40e3 References: <1524743493-28113-1-git-send-email-b.zolnierkie@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP of_thermal_get_ntrips() may return value bigger than supported by a given SoC (i.e. on Exynos5422/5800) so fix the code to not iterate the loop for i values >= data->ntrip. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz Reviewed-by: Daniel Lezcano --- drivers/thermal/samsung/exynos_tmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 5a64879..58cd68e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -311,9 +311,9 @@ static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling) const struct thermal_trip * const trips = of_thermal_get_trip_points(tz); unsigned long temp; - int i; + int i, ntrips = min_t(int, of_thermal_get_ntrips(tz), data->ntrip); - for (i = 0; i < of_thermal_get_ntrips(tz); i++) { + for (i = 0; i < ntrips; i++) { if (trips[i].type == THERMAL_TRIP_CRITICAL) continue;