Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1385751
| Path | csiph.com!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Eduardo Valentin <edubezval@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | [RFC PATCH 07/11] thermal: move passive attr to tz->device.groups |
| Date | Sun, 24 Apr 2016 01:40:03 +0200 |
| Message-ID | <rrfjB-31p-33@gated-at.bofh.it> (permalink) |
| References | <rrfjz-31p-5@gated-at.bofh.it> |
| X-Original-To | Rui Zhang <rui.zhang@intel.com> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i6slp5jnXDSBANv6wF2bRa9G9NLOMoP1Aq6SUmDH0No=; b=IVEEWqJXNnumw85hTxAhgFu+TF7FYwPBKLwdF1Gt6IyFNVBsDbBJ1obkUIHxZZcAV/ 83c7/2p+GGSN3AW9txBs/77VuhgyeKd7iGBl7VDEZMkfLfqtzmyw/CqYWVV8ogZR8tEr 6A5agPHpfgznDjHw+AlTfu2YCtI+Z7VvEOEJI+phIEANvxpa32d03Br+/3j0x1B02gQg sT2faTdfTKQYjnGH42RAob115mb/i5/Cdt0qjVVWEtAznyyz62EGdbr9nuLtXDduOWUA Nbyysrkx+2SeAASFdYBqFeB+3mhnmypLcsoq5ieVN/j3DecvQYYgJajPeZga98/61441 CWxw== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i6slp5jnXDSBANv6wF2bRa9G9NLOMoP1Aq6SUmDH0No=; b=Vl/toE1okNjmHp5GTpuvnPU7W9uN9Ys8rVJvAcPBw644g4D6k6AsAaiG1PO13FaNmw HPc9Wc7s6+wxM/KurQQzC+R7snsENAfwEma9eOteHcSTRmRxAU8j3X63IwaofPybtRur cFmeQzyOghS9ZHT5h2RWAlXjOUrKVE8JeLpHrWl5ruDGHXSq39Z/vMgxu3a60O3N6AnQ 6qotY1ZATfvAJ4mXy1jfNL8QmpqymT6Mpc1nYit2aRxPORO8aT1ddxl6iG69dofWWOqt tNQB7RFUnLyKDIBjwQT2eu9dJSZe50XlFdZfDpfn72mAqb3W1SZ9D+c5oZeCOwv0QX4p rHlw== |
| X-Gm-Message-State | AOPr4FUzsGsCfpTRRw80csfea+1vc4B+ZfPdGyUiZ/ZUSqJpveZ2PAAbRGUOEF+Fp5JY8Q== |
| X-Received | by 10.66.40.236 with SMTP id a12mr38898656pal.58.1461454494924; Sat, 23 Apr 2016 16:34:54 -0700 (PDT) |
| X-Mailer | git-send-email 2.1.4 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 94 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Linux PM <linux-pm@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Eduardo Valentin <edubezval@gmail.com> |
| X-Original-Date | Sat, 23 Apr 2016 16:34:26 -0700 |
| X-Original-Message-ID | <1461454470-27714-8-git-send-email-edubezval@gmail.com> |
| X-Original-References | <1461454470-27714-1-git-send-email-edubezval@gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1385751 |
Show key headers only | View raw
This patch moves the passive attribute to tz->device.groups. Moving the
passive attribute also requires a .is_visible() callback implementation
for its attribute group.
The logic behind the visibility of passive attribute is kept the same.
We only expose the passive attribute if the thermal driver has exposed
at least one passive trip point.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/thermal_core.c | 41 ++++++++++++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 6e44038..e48c720 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1054,9 +1054,41 @@ static struct attribute_group thermal_zone_mode_attribute_group = {
.is_visible = thermal_zone_mode_is_visible,
};
+/* We expose passive only if passive trips are present */
+static struct attribute *thermal_zone_passive_attrs[] = {
+ &dev_attr_passive.attr,
+};
+
+static umode_t thermal_zone_passive_is_visible(struct kobject *kobj,
+ struct attribute *attr,
+ int attrno)
+{
+ struct device *dev = container_of(kobj, struct device, kobj);
+ struct thermal_zone_device *tz;
+ enum thermal_trip_type trip_type;
+ int count;
+
+ tz = container_of(dev, struct thermal_zone_device, device);
+
+ for (count = 0; count < tz->trips; count++) {
+ tz->ops->get_trip_type(tz, count, &trip_type);
+
+ if (trip_type == THERMAL_TRIP_PASSIVE)
+ return attr->mode;
+ }
+
+ return 0;
+}
+
+static struct attribute_group thermal_zone_passive_attribute_group = {
+ .attrs = thermal_zone_passive_attrs,
+ .is_visible = thermal_zone_passive_is_visible,
+};
+
static const struct attribute_group *thermal_zone_attribute_groups[] = {
&thermal_zone_attribute_group,
&thermal_zone_mode_attribute_group,
+ &thermal_zone_passive_attribute_group,
NULL
};
@@ -1841,7 +1873,6 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
int trip_temp;
int result;
int count;
- int passive = 0;
struct thermal_governor *governor;
if (!type || strlen(type) == 0)
@@ -1902,8 +1933,6 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
for (count = 0; count < trips; count++) {
if (tz->ops->get_trip_type(tz, count, &trip_type))
set_bit(count, &tz->trips_disabled);
- if (trip_type == THERMAL_TRIP_PASSIVE)
- passive = 1;
if (tz->ops->get_trip_temp(tz, count, &trip_temp))
set_bit(count, &tz->trips_disabled);
/* Check for bogus trip points */
@@ -1911,12 +1940,6 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
set_bit(count, &tz->trips_disabled);
}
- if (!passive) {
- result = device_create_file(&tz->device, &dev_attr_passive);
- if (result)
- goto unregister;
- }
-
/* Update 'this' zone's governor information */
mutex_lock(&thermal_governor_lock);
--
2.1.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC PATCH 00/11] thermal: sysfs rework Eduardo Valentin <edubezval@gmail.com> - 2016-04-24 01:40 +0200 [RFC PATCH 10/11] thermal: create tz->device.groups dynamically Eduardo Valentin <edubezval@gmail.com> - 2016-04-24 01:40 +0200 [RFC PATCH 07/11] thermal: move passive attr to tz->device.groups Eduardo Valentin <edubezval@gmail.com> - 2016-04-24 01:40 +0200 [RFC PATCH 04/11] thermal: use dev.groups to manage always present tz attributes Eduardo Valentin <edubezval@gmail.com> - 2016-04-24 01:40 +0200 [RFC PATCH 01/11] thermal: prevent zones with no types to be registered Eduardo Valentin <edubezval@gmail.com> - 2016-04-24 01:40 +0200 [RFC PATCH 11/11] thermal: move trips attributes to tz->device.groups Eduardo Valentin <edubezval@gmail.com> - 2016-04-24 01:40 +0200
csiph-web