Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp829402imm; Wed, 17 Oct 2018 08:57:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV61i+QrSMujy28tqXZrK4EfaPPbZZdqd82uaD1lJnuO/58i3Vo3iHhPTTu/moctzBwmEx8tP X-Received: by 2002:a17:902:8a8c:: with SMTP id p12-v6mr26336101plo.133.1539791855340; Wed, 17 Oct 2018 08:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539791855; cv=none; d=google.com; s=arc-20160816; b=ShNYY78apP/0ng+EU8ZoC0uGQFcjZcPk18fUtVB4PsJrcBs0AIzRm6lv9gUEvPfY9C UtspaJOIH2roJZjRrONf6+r+yoewJCsociGmQxnaZHAkOFS5AgfvTe/wiU4fj9EOL/78 OVnPH9+iMXvU6E8+qVQb4zCoJwGqKw6O8/jt8BZgEmjawockTcBgMaL+YSToHC9zCLkL 4x4S3DC/1SZOmmcb6EC8uTj9dAa+7CDtUX63+dlnjGeJZ7ZUxfe/jfYCvGp6mmSdgUNP EGxuVMu8Fl3doqJz6KNoni5cQgDNUXoVeAZIIt7qypx/LNveFB5g431CU58eacoG4SZX 2inw== 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; bh=pxP8DeqDYXDPZXv4SFu8SA/qiItJUsaW7Awn5Qn1Be0=; b=Z08kacrSycR6zcB4D/db+nfvjBkiWYifCpTHs78lt87v9ivgmAbiNJjWTZs5ouNqec rL+5R2PLmCb2Zqp3dLY2tXpuA1CjmlDrvG5h2HOYOYKe2z7PFscHJFO5RQlDXM8rcu/k i+2bcqgeTetUbcireugUMkDrnQbjAL4wa5PMaAIaU43JpFxx257l/qXjOO4RavJ+z+9v SFk0rukDKc4Ox2YRAMAxmEcWcMszP4CSOJEl6xKxQwe5fpti35AqCoUuJgYLnKTpUGKS B1miBN9WaCV7LaWRg7+oXaBjVJLfgmwcqd95j7LuY/LqXonQYDDCi90Y5xM75dKNn3Uf w+OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=dAMSNETS; 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 x186-v6si18816930pfx.19.2018.10.17.08.57.18; Wed, 17 Oct 2018 08:57:35 -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=dAMSNETS; 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 S1728176AbeJQXvX (ORCPT + 99 others); Wed, 17 Oct 2018 19:51:23 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:13018 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbeJQXvX (ORCPT ); Wed, 17 Oct 2018 19:51:23 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20181017155501epoutp045191e2d958d75bf6499617949fd5cccc~ecGUCVN1e0668806688epoutp04A; Wed, 17 Oct 2018 15:55:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20181017155501epoutp045191e2d958d75bf6499617949fd5cccc~ecGUCVN1e0668806688epoutp04A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539791701; bh=pxP8DeqDYXDPZXv4SFu8SA/qiItJUsaW7Awn5Qn1Be0=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=dAMSNETSIcj8dLe9dodtUIqpMspcbShWqKbbkEH/ZjZY4cJw8/uhF2ulkl9KN9d23 G3eQiWQUEqtyCyjEJIPARt6u35BYyt/H/UzBNtR4q9640lPwi+yjCHZVi6ecaQPA6m XlfzdgDiqGAVA8efkz6KSG9OH5Na9X+e1E6Rnv/M= Received: from epsmges1p1.samsung.com (unknown [182.195.42.53]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20181017155500epcas1p30b76f626586f26847a992f2333dc01dc~ecGSsGYO40486304863epcas1p3l; Wed, 17 Oct 2018 15:55:00 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 0F.3F.04073.45B57CB5; Thu, 18 Oct 2018 00:55:00 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20181017155459epcas1p470bd73f433cdbb0f7a11aa8d46212e4e~ecGSCM97Z0540205402epcas1p4a; Wed, 17 Oct 2018 15:54:59 +0000 (GMT) X-AuditID: b6c32a35-69fff70000000fe9-0b-5bc75b548924 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id EE.A6.03743.35B57CB5; Thu, 18 Oct 2018 00:54:59 +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 <0PGR00KZM2SD3M00@mmp2.samsung.com>; Thu, 18 Oct 2018 00:54:59 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Zhang Rui , Eduardo Valentin Cc: Amit kucheria , 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 v2 17/17] thermal: warn on attempts to read temperature on disabled sensors Date: Wed, 17 Oct 2018 17:52:43 +0200 Message-id: <1539791563-5959-18-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1539791563-5959-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0hTYRjHfXcuO4qzwzR9VTAaSGhqCUkvXaQPSgf1Q0EYNDVHHlTadOyo pRF4WWrWpMhSl5rmpRBFHTMvKYi6rQ0TzUtiamhmmmblKNGw1Tz67fd/nt/D87zwUpj4DuFF JaeksaoUmVxCOuGvBvyCAi9JTdLj40suKC+7VoDayloItGQ1AdSsMeDo2fgkgfpyxgCyLawS yNKRK0Bq7XMc1S3OC9FYdwWJrJpBgCrWPwjR4nwxiZb1Hkj3copEW91VOOqds4JzYib3u5Fk tB/fkkyXdlbItE+HMLU9KwJG13iXZGYme0hGk7dOMsX6RsB0TFZhzJvSTZwxTXUIGKvO54Lo itOZBFaenMGqjoXGOyUZ84YIZfGBm3NbZiwbdDgXAUcK0idgbqsNKwJOlJjuBFA7mUfyYRNA y5dmsG+VzPYRfKMVwC5LKc6HbQDV9U27Fkmfgg8LGv8zRbnRkVDfRNnLGG3A4Sern51d6Vi4 sNCM2xmnfeGTIT1mZxHNwPLVcZJf5gPNxkeEnR3/14dt1bsXQbpUCMt/FGC8FAbXXmuEPLvC rya90L4X0t7wneHsng/g2nY9zocWAJuGjAJ+4DQcMI0S/HUucP3XfYIfFsHCfDGvMNBc1rb3 yKcAlhRWkA+AZzVwaATurJJTJLJcsDI4iJMpuPSUxKBrqQod2P0c/iGdoGQ4qh/Q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7OCrq7x 1FE9PUlY/vDm9G1lJy96C8u+Wl2ju1IoLLr205+fzV+VWIozEg21mIuKEwGb2RIwfAIAAA== X-CMS-MailID: 20181017155459epcas1p470bd73f433cdbb0f7a11aa8d46212e4e X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20181017155459epcas1p470bd73f433cdbb0f7a11aa8d46212e4e References: <1539791563-5959-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 523ac5c..912bd85 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -378,6 +378,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 14b7a7e..12d1f53 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -84,6 +84,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 92c460e..2215e11 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -115,6 +115,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