From patchwork Tue Apr 10 12:42:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 10332985 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 4773E6053B for ; Tue, 10 Apr 2018 12:45:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F6D28BC4 for ; Tue, 10 Apr 2018 12:45:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D0EE28CDA; Tue, 10 Apr 2018 12:45:18 +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 A711D28BC4 for ; Tue, 10 Apr 2018 12:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752952AbeDJMpD (ORCPT ); Tue, 10 Apr 2018 08:45:03 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:33140 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752810AbeDJMpA (ORCPT ); Tue, 10 Apr 2018 08:45:00 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180410124458epoutp0148ec1f418a2cb2f4a361d0c776d5d825~kE8ImMDeQ2465424654epoutp01e; Tue, 10 Apr 2018 12:44:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180410124458epoutp0148ec1f418a2cb2f4a361d0c776d5d825~kE8ImMDeQ2465424654epoutp01e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1523364298; bh=EPQ9NDCFygwChVS4LAUTPHr4OFImeLXjNjNB6+HZjLI=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=RewxGhcI0UP7VI0lT8F+VkOmwaW/SyqwHD/mxO0OYElY1/3ZiqnLofamLTt79cYmP 9ZMtZ6fLsyPuIDeBU5LKSu8u9HBx6Q3RVvSSLQ2bLzCcI7C3IBGBqi+oBBFPEHLYSX weq5dSdV4WKwLwL7AYUYbxc0M/bUkqJTEBRJmAh0= Received: from epsmges1p4.samsung.com (unknown [182.195.42.56]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20180410124458epcas1p1286d646a58cc8b8e7e50d90c7396569c~kE8IRv1Rq0303203032epcas1p1A; Tue, 10 Apr 2018 12:44:58 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id 50.16.04226.AC1BCCA5; Tue, 10 Apr 2018 21:44:58 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180410124457epcas1p33e959cf61c2a7f54227e29ef5ba9b0eb~kE8HhcR8w2610126101epcas1p3C; Tue, 10 Apr 2018 12:44:57 +0000 (GMT) X-AuditID: b6c32a38-d73ff70000001082-df-5accb1caafb5 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id D6.41.03849.9C1BCCA5; Tue, 10 Apr 2018 21:44:57 +0900 (KST) Received: from AMDC3058.DIGITAL.local ([106.120.53.102]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P6Y00EUVZATQUB0@mmp1.samsung.com>; Tue, 10 Apr 2018 21:44:57 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Zhang Rui , Eduardo Valentin Cc: Eric Anholt , Stefan Wahren , Markus Mayer , bcm-kernel-feedback-list@broadcom.com, Heiko Stuebner , Thierry Reding , Jonathan Hunter , Keerthy , Masahiro Yamada , Jun Nie , Baoyou Xie , Shawn Guo , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com Subject: [PATCH 17/17] thermal: warn on attempts to read temperature on disabled sensors Date: Tue, 10 Apr 2018 14:42:11 +0200 Message-id: <1523364131-31059-18-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1523364131-31059-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSfyzUYRzHe+77476Oq2/HeMamdps/WJHG9qySmqZv8Uet+uf+iItvh+64 3WFYrfMjv+9iJOxC9Ee7JTkX4m4V+ZEfbSKziJRa1J2W/Igo58t/r+fzfj2f957toTBRLuFO xcYnsqp4qVxMCvDmTm+/g32NA5JDzdMkaixvINDXhR6A6rVdOKoeGSXQi/RhgP59+k6gvpYM HsqqrMXRg5lpPhpu05NoQfsKIL1tnI9mpnUk+mZyQ8aHYyT601aFI8vkAjixl8mY7yaZyqlB knlW+YHPPH0fyNSZZ3mM0ZBHMhOjZpLRZtpIRmcyAKZltApjeu8u40zPWAuPWTB6nhNKBMei WXlsMqvyOx4piOlsuqrU7UkZas/FNKDFKR84UJAOgKWDI1g+EFAiuhXA9I1FPndYBvBHWwZ/ x8rOyttiEd0O4PPJw5y0CqAuYxazByR9BBbnGEA+oCgXOgyaHlF2B6MrcPhzomvLcaYl0PzE itsZp72g9uM6aWchfQaOj9ZhXJknfN1dQtjZYXO+Zpkn7IsgfZsPjW02wEmnYElZA86xM5zr MfHtx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Sqlz2PnP2DXV7eGNRqX9n1RO8b1ec7vPXlj533FOEd+ICQuOLFlxuSNBlSeqJSv+nWv2 1pMrj10IYstr66opT1IoN1iZzPjQLLTy7PcIOz4O9q9PGRh2z4sVNVZf8vJQ2OeJ7g+C1t9d d3WP1VTRvcy7Q0RNy6Ue3N5hMWHT/o0SdQneSizFGYmGWsxFxYkAzgJugnUCAAA= X-CMS-MailID: 20180410124457epcas1p33e959cf61c2a7f54227e29ef5ba9b0eb X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20180410124457epcas1p33e959cf61c2a7f54227e29ef5ba9b0eb X-RootMTR: 20180410124457epcas1p33e959cf61c2a7f54227e29ef5ba9b0eb References: <1523364131-31059-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 * Add ops_of_thermal flag to struct thermal_zone_device_ops and set it in of-thermal.c. * Add checking sensor mode for drivers using of-thermal.c to thermal_zone_get_temp() (print a warning if sensor is disabled). Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/thermal/of-thermal.c | 2 ++ drivers/thermal/thermal_helpers.c | 12 ++++++++++++ include/linux/thermal.h | 1 + 3 files changed, 15 insertions(+) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index f60ccf1..68ebcda 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -392,6 +392,8 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, .bind = of_thermal_bind, .unbind = of_thermal_unbind, + + .ops_of_thermal = true, }; /*** sensor API ***/ diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index bd10b4d..e3fc1c6 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -87,6 +87,18 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) if (!tz || IS_ERR(tz) || !tz->ops->get_temp) goto exit; + if (tz->ops->ops_of_thermal) { + enum thermal_device_mode mode; + + ret = tz->ops->get_mode(tz, &mode); + if (ret) + goto exit; + + if (mode == THERMAL_DEVICE_DISABLED) + dev_warn_once(&tz->device, + "trying to read out disabled thermal zone\n"); + } + mutex_lock(&tz->lock); ret = tz->ops->get_temp(tz, temp); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 7de102f..31560b4 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -130,6 +130,7 @@ struct thermal_zone_device_ops { enum thermal_trip_type); bool set_mode_skip_check; + bool ops_of_thermal; }; struct thermal_cooling_device_ops {