aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ibmaem.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-07-16 17:04:47 -0400
committerJohn Stultz <john.stultz@linaro.org>2014-07-23 18:01:44 -0400
commitd659f9b135fe26b966a6a4ad7281d35d7dbb1366 (patch)
tree3416ee5247b9dae698bedf918ecfa7e96c2d473b /drivers/hwmon/ibmaem.c
parent5eaaed4fe23247f0784edc2973f04134f8180251 (diff)
hwmon: ibmaem: Use ktime_get_ns()
Using the wall clock time for delta time calculations is wrong to begin with because wall clock time can be set from userspace and NTP. Such data wants to be based on clock monotonic. The calculations also are done on a nanosecond basis. Use the nanoseconds based interface right away. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Jean Delvare <jdelvare@suse.de> Acked-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'drivers/hwmon/ibmaem.c')
-rw-r--r--drivers/hwmon/ibmaem.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index 632f1dc0fe1f..7a8a6fbf11ff 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -842,11 +842,10 @@ static ssize_t aem_show_power(struct device *dev,
842 struct aem_data *data = dev_get_drvdata(dev); 842 struct aem_data *data = dev_get_drvdata(dev);
843 u64 before, after, delta, time; 843 u64 before, after, delta, time;
844 signed long leftover; 844 signed long leftover;
845 struct timespec b, a;
846 845
847 mutex_lock(&data->lock); 846 mutex_lock(&data->lock);
848 update_aem_energy_one(data, attr->index); 847 update_aem_energy_one(data, attr->index);
849 getnstimeofday(&b); 848 time = ktime_get_ns();
850 before = data->energy[attr->index]; 849 before = data->energy[attr->index];
851 850
852 leftover = schedule_timeout_interruptible( 851 leftover = schedule_timeout_interruptible(
@@ -858,11 +857,10 @@ static ssize_t aem_show_power(struct device *dev,
858 } 857 }
859 858
860 update_aem_energy_one(data, attr->index); 859 update_aem_energy_one(data, attr->index);
861 getnstimeofday(&a); 860 time = ktime_get_ns() - time;
862 after = data->energy[attr->index]; 861 after = data->energy[attr->index];
863 mutex_unlock(&data->lock); 862 mutex_unlock(&data->lock);
864 863
865 time = timespec_to_ns(&a) - timespec_to_ns(&b);
866 delta = (after - before) * UJ_PER_MJ; 864 delta = (after - before) * UJ_PER_MJ;
867 865
868 return sprintf(buf, "%llu\n", 866 return sprintf(buf, "%llu\n",