Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1409521
| Path | csiph.com!feeder.erje.net!1.us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Eduardo Valentin <edubezval@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCHv2 06/40] thermal: core: move mode attribute to tz->device.groups |
| Date | Mon, 30 May 2016 23:30:04 +0200 |
| Message-ID | <rECV6-1mL-87@gated-at.bofh.it> (permalink) |
| References | <rECV3-1mL-7@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=+ZEDoDP4N5ZDL0dpso+GYy2k5XYHR6LVq9fITWkT1vQ=; b=chf1kh7l/IgO3lILQJ4CIaUXqr8aUQ8OmkBCcUaWvj99p+/u5fni2qDWw+mwU3DHu9 diKgLV3XxVN8Iwj94c/ohGD0Z/DDf+AxvU8y1rbQYZELZq7LaXRdS8uHOkKn3MgGTj8P 2OdamxMHT8MBPLJqOXPZBqobKqzyW6b1+AmOUWgJAj/qX2YDbY6wNzfMXz47XBXMVpbP slTnWayCuZJq8knY5xtQXM0RelHemMqBzvkdO8EfWiyELNXUWzXL8zdsIVi2mNcMxiES 9TTXyLZIkZpg+QVZy+EOfhfVEhgiBXahhtTbwVKUVH9ztwXk0vzi6djcWNaPc2DE6gh9 db2g== |
| 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=+ZEDoDP4N5ZDL0dpso+GYy2k5XYHR6LVq9fITWkT1vQ=; b=Q08wO2t7NhJg2ChiXYmzH7PPJyI4uYf8hdqZ97odREdNNrLXpRub/I4N+ZPp8ZZ79M 9BlwQ7kZzklIQ09D53b8Z1hQbFbWgj1XW8tit+qi0oP7P8Ul0JMZVYCQPier2NozVyZH YO1TcKUR8F0oqGdT/TczYB0+G4khscY3AMaap+k76Q2D/bPf0KS2W/bnIFKMkvrTRVGq ISqtSNvKL7ZjyE1nnom9Q+kwvpytKiBosyTXgaiZe4yI+ILpOqD7hvI2ohjFcbnT4NCf rjaxPBPcdB1koAbYVoi02nm2OJwb7kvac7JB7CvY6EibC01QmCld2h0KhV3mFjQVZZ0I HbLA== |
| X-Gm-Message-State | ALyK8tJFSJzAr0X3oHQOjAIUrGW8pFN2FCNp09ihiIyh89kgDziHI8hGJgFLsMaJAoeR1g== |
| X-Received | by 10.98.42.206 with SMTP id q197mr37999187pfq.108.1464643701152; Mon, 30 May 2016 14:28:21 -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 | 84 |
| 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 | Mon, 30 May 2016 14:27:25 -0700 |
| X-Original-Message-ID | <1464643679-2733-7-git-send-email-edubezval@gmail.com> |
| X-Original-References | <1464643679-2733-1-git-send-email-edubezval@gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1409521 |
Show key headers only | View raw
Moving mode attribute to tz->device.groups requires the implementation
of a .is_visible() callback. The condition returned by .is_visible() of
the mode attribute group is kept the same, we allow the attribute to be
visible only if ops->get_mode() is set by the thermal driver.
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 | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 1398c9d..e65c9b8 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1006,6 +1006,7 @@ static DEVICE_ATTR(sustainable_power, S_IWUSR | S_IRUGO, sustainable_power_show,
static DEVICE_ATTR(mode, 0644, mode_show, mode_store);
static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store);
+/* These attributes are unconditionally added to a thermal zone */
static struct attribute *thermal_zone_dev_attrs[] = {
&dev_attr_type.attr,
&dev_attr_temp.attr,
@@ -1028,8 +1029,34 @@ static struct attribute_group thermal_zone_attribute_group = {
.attrs = thermal_zone_dev_attrs,
};
+/* We expose mode only if .get_mode is present */
+static struct attribute *thermal_zone_mode_attrs[] = {
+ &dev_attr_mode.attr,
+};
+
+static umode_t thermal_zone_mode_is_visible(struct kobject *kobj,
+ struct attribute *attr,
+ int attrno)
+{
+ struct device *dev = container_of(kobj, struct device, kobj);
+ struct thermal_zone_device *tz;
+
+ tz = container_of(dev, struct thermal_zone_device, device);
+
+ if (tz->ops->get_mode)
+ return attr->mode;
+
+ return 0;
+}
+
+static struct attribute_group thermal_zone_mode_attribute_group = {
+ .attrs = thermal_zone_mode_attrs,
+ .is_visible = thermal_zone_mode_is_visible,
+};
+
static const struct attribute_group *thermal_zone_attribute_groups[] = {
&thermal_zone_attribute_group,
+ &thermal_zone_mode_attribute_group,
NULL
};
@@ -1868,12 +1895,6 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
}
/* sys I/F */
- if (ops->get_mode) {
- result = device_create_file(&tz->device, &dev_attr_mode);
- if (result)
- goto unregister;
- }
-
result = create_trip_attrs(tz, mask);
if (result)
goto unregister;
@@ -1990,8 +2011,6 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
thermal_zone_device_set_polling(tz, 0);
- if (tz->ops->get_mode)
- device_remove_file(&tz->device, &dev_attr_mode);
remove_trip_attrs(tz);
thermal_set_governor(tz, NULL);
--
2.1.4
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCHv2 06/40] thermal: core: move mode attribute to tz->device.groups Eduardo Valentin <edubezval@gmail.com> - 2016-05-30 23:30 +0200
csiph-web