summaryrefslogtreecommitdiffstats
path: root/drivers/powercap
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2013-12-04 11:12:59 -0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-12-05 02:05:48 +0100
commit95677a9a3847de4f37e0f463aeb94aa8d5cccc50 (patch)
treee26ce006b6ad9735d7b85290a567713f8fd10f7e /drivers/powercap
parent08ff4cbe10da402e7c493ac72e298975f62a9e78 (diff)
downloadlinux-95677a9a3847de4f37e0f463aeb94aa8d5cccc50.tar.gz
linux-95677a9a3847de4f37e0f463aeb94aa8d5cccc50.tar.bz2
linux-95677a9a3847de4f37e0f463aeb94aa8d5cccc50.zip
PowerCap: Fix mode for energy counter
As per the documentation of powercap sysfs, energy_uj field is read only, if it can't be reset. Currently it always allows write but will fail, if there is no reset callback. Changing mode field, to read only if there is no reset callback. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reported-by: Dirk Brandewie <dirk.j.brandewie@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/powercap')
-rw-r--r--drivers/powercap/powercap_sys.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
index 8d0fe431dbdd..84419af16f77 100644
--- a/drivers/powercap/powercap_sys.c
+++ b/drivers/powercap/powercap_sys.c
@@ -377,9 +377,14 @@ static void create_power_zone_common_attributes(
if (power_zone->ops->get_max_energy_range_uj)
power_zone->zone_dev_attrs[count++] =
&dev_attr_max_energy_range_uj.attr;
- if (power_zone->ops->get_energy_uj)
+ if (power_zone->ops->get_energy_uj) {
+ if (power_zone->ops->reset_energy_uj)
+ dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
+ else
+ dev_attr_energy_uj.attr.mode = S_IRUGO;
power_zone->zone_dev_attrs[count++] =
&dev_attr_energy_uj.attr;
+ }
if (power_zone->ops->get_power_uw)
power_zone->zone_dev_attrs[count++] =
&dev_attr_power_uw.attr;