From patchwork Mon Apr 16 10:11:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 10342579 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 09933601C2 for ; Mon, 16 Apr 2018 10:17:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE7EB28632 for ; Mon, 16 Apr 2018 10:17:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0B412863B; Mon, 16 Apr 2018 10:17:20 +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=unavailable 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 7766928632 for ; Mon, 16 Apr 2018 10:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752975AbeDPKN4 (ORCPT ); Mon, 16 Apr 2018 06:13:56 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:31932 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753630AbeDPKNx (ORCPT ); Mon, 16 Apr 2018 06:13:53 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180416101351epoutp030e554f210e7368b5ee891fe3bcd70d9b~l4v6OxTQe1183911839epoutp03j; Mon, 16 Apr 2018 10:13:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180416101351epoutp030e554f210e7368b5ee891fe3bcd70d9b~l4v6OxTQe1183911839epoutp03j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1523873631; bh=x6pNjcyDccdULlnK2SzGdFFxNe8u0Y8YnzguHaESH1k=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=ErQrFzbpd8+8E/EsYunBI/rdSCB+UrXrKR/faUN0zu+DKClZnE/4boxq0e+XuDHyx OqTCQd682v/Ggf96tQdmqkynGKyvP8BBVzXQFwkFNc3fpYOwYxIO0NyX3eFkIvTo7b tGTqu9K8MnSqoQF43EQqG0a/CzV9Zt6FrBLv7g8s= Received: from epsmges1p5.samsung.com (unknown [182.195.42.57]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180416101351epcas1p38fa88f5ee25e510d8c14bfef9c839e26~l4v58EKXK0733907339epcas1p3g; Mon, 16 Apr 2018 10:13:51 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 75.8F.04084.F5774DA5; Mon, 16 Apr 2018 19:13:51 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180416101350epcas1p46d9415458ec463afb2a071a9f765f0ed~l4v441jHd2200722007epcas1p4p; Mon, 16 Apr 2018 10:13:50 +0000 (GMT) X-AuditID: b6c32a39-591ff70000000ff4-59-5ad4775fc631 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 23.AB.03849.E5774DA5; Mon, 16 Apr 2018 19:13:50 +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 <0P79000EEWCHS590@mmp2.samsung.com>; Mon, 16 Apr 2018 19:13:50 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Eduardo Valentin Cc: Zhang Rui , Krzysztof Kozlowski , Kukjin Kim , Daniel Lezcano , linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com, Marek Szyprowski Subject: [PATCH 02/14] thermal: exynos: Propagate error value from tmu_read() Date: Mon, 16 Apr 2018 12:11:53 +0200 Message-id: <1523873525-23718-3-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1523873525-23718-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsWy7bCmgW58+ZUog2krFCw2zljPajHvs6zF /CvXWC36H79mtjh/fgO7xeVdc9gsPvceYbSYcX4fk8XaI3fZLZ487GNz4PLYOesuu8fiPS+Z PDat6mTzuHNtD5tH35ZVjB6fN8kFsEVx2aSk5mSWpRbp2yVwZbxc9ZG94AV3xYW2k0wNjO85 uxg5OSQETCQe9N9jB7GFBHYwSmydI9fFyAVkf2eUeNx4lxWm6NTa/cwQiQ2MEm9/fmSCcH4x SkybOgusnU3ASmJi+ypGEFtEQEvixKXtYEXMAvuZJHqXzQUbJSzgLzF/bydYEYuAqsTO+V/B 4rwCHhJ3X79mg1gnJ3Hy2GSwOKeAp0TTmmtsIIMkBFawSXQemAeU4AByXCQap8dB1AtLvDq+ hR0iLC1x6agtRHkzo8S3HXuYIWomMErsWS8EYVtLHD5+EWw+swCfxLuvPVAjeSU62qBKPCRO X/wAdY6jRPOBs4wQD89hlDh6aTfTBEapBYwMqxjFUguKc9NTiw0LTPWKE3OLS/PS9ZLzczcx gmNXy3IH47FzPocYBTgYlXh4d5y9HCXEmlhWXJl7iFGCg1lJhHdZIlCINyWxsiq1KD++qDQn tfgQozQHi5I471OfM1FCAumJJanZqakFqUUwWSYOTqkGRnO/boO58Yvv63W2mW/5sal5kzCn CXcYQ+/jAy6bD8zlC3gbufaqgvOVopMHncqLH9gZifYefvH7pHry2sbHM21+Bd74eGri4odS f2olH3r0tAQKW7SuKd/E/7f918MJ7TeDKip9vZyFBVbKZKy4Xz1Xwkt8R3n7zi2Oaa6lb2/M 2rvonNxJSSWW4oxEQy3mouJEANM5E0XZAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPLMWRmVeSWpSXmKPExsVy+t9jQd248itRBrumSVhsnLGe1WLeZ1mL +VeusVr0P37NbHH+/AZ2i8u75rBZfO49wmgx4/w+Jou1R+6yWzx52MfmwOWxc9Zddo/Fe14y eWxa1cnmcefaHjaPvi2rGD0+b5ILYIvisklJzcksSy3St0vgyni56iN7wQvuigttJ5kaGN9z djFyckgImEicWrufGcQWEljHKLFplWAXIxeQ/YtRYs7m86wgCTYBK4mJ7asYQWwRAS2JE5e2 M4EUMQvsZ5L4MO06C0hCWMBXonlmExOIzSKgKrFz/lewZl4BD4m7r1+zQWyTkzh5bDJYnFPA U6JpzTU2iM0eEo0TrzJOYORZwMiwilEytaA4Nz232KjAMC+1XK84Mbe4NC9dLzk/dxMjMNi2 Hdbq28F4f0n8IUYBDkYlHt4dZy9HCbEmlhVX5h5ilOBgVhLhXZYIFOJNSaysSi3Kjy8qzUkt PsQozcGiJM57O+9YpJBAemJJanZqakFqEUyWiYNTqoFx2vwi1fl/X53/5Vl+lzHGWpvJR2L2 Zc2jhkLpkZvnFpS8sxVkPXotk+07N3f5NxnLWTuyJ368taKotL7XbE6JW+GOf0Jqk8w9RK4c vM8XNkNsRqVertbzCMaS3rLlpRZsj6fV1d6rWLRB1IzjtNh8j6m/Nj8rP/FGMy9Y4HVzs6TF lQaG6ONKLMUZiYZazEXFiQCNtNHPMgIAAA== X-CMS-MailID: 20180416101350epcas1p46d9415458ec463afb2a071a9f765f0ed X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20180416101350epcas1p46d9415458ec463afb2a071a9f765f0ed X-RootMTR: 20180416101350epcas1p46d9415458ec463afb2a071a9f765f0ed References: <1523873525-23718-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 From: Marek Szyprowski 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+ Signed-off-by: Bartlomiej Zolnierkiewicz --- 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 986cbd0..ac83f72 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