Received: by 10.213.65.68 with SMTP id h4csp3853947imn; Tue, 10 Apr 2018 05:49:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Q7nh+Blt7KNO2EgIf+TWGv0Fgme7WlK6844sYYQdqsOxN1Ow4vhsWuTqsyDCGq9GCyYmI X-Received: by 10.98.65.220 with SMTP id g89mr230346pfd.97.1523364541550; Tue, 10 Apr 2018 05:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523364541; cv=none; d=google.com; s=arc-20160816; b=XSRHfPVUWBpc6jBaPZOHqZa3rx+Q/tcYdVO9c3HKuIGk75cWC+iEQHGHjiAxsPJ7DC yuPQ7TFjyFa7K0LxSl32hTha082oMEFZyUD1FbXMXzBbXe6TBWS9XmkiLZZhkMQwaGr1 d0YP6Z87gJTTqztGSuA9Knom0z/8RNiS8OcJM16zkkWE19QPW4H+fPbm4UkOBTKejRmd tNd/OdOcncyyd1c8FrtKDKO7yyB8yFXTFOZIjha584CIe8/l6BVn5MKYFhTTcpV7nKww OV4+2qnrQr6Lbpr5ARykaA1KLO7U5aAe/q6KLBAJCNvVqW+aQwbNHoEiyBdGR6IuVtE/ TKww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=EPQ9NDCFygwChVS4LAUTPHr4OFImeLXjNjNB6+HZjLI=; b=g+nACBzFoDPNCzCAjGRP1kUEgRvlUlxlDIrWP5GBtSsMApSsnIoXGsfCpllnQjgXfX rew6i/B75YkKPWb+jRBBmUIZ4m4VDF2UDjDT6BVxxe3N1Ni4joclp8rteU5rxS/7Xt9r 1CjPN8PfbgCf6paQvHwZJGJRjjhJ3f4uFve2Yb1miW297qSOG5DenzZR2nwUJFOPSpBe b+XWnqPph5jDQ2kygNvwFMWs3Fn2vBPzOf55RX4wvEIrTk/OhXW1ggTtXt6rplCuxIaT BTRRzf8oQA8JBhiKSIIRcpJyc9CxVKAsa6HWG3fRJFMYAEa+Y8ElqByKCiHgnvoN54ip bS+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=RewxGhcI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si1736490pgf.512.2018.04.10.05.48.24; Tue, 10 Apr 2018 05:49:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=RewxGhcI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753888AbeDJMpE (ORCPT + 99 others); Tue, 10 Apr 2018 08:45:04 -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 MfHtxZD2gG+7gjg/E8ClVvP20iIAzQ0ijo/Czp6hrQKM3g1ti4UEd1cIc7O3FQZq1ha3xyeh Va/i3q4H8N1fYRFwrwG7DMCVVaoVMlbtrwzwVUsV6qR4mW9UgsIItv6H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JQ2OeJ7g+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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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 { -- 1.9.1