diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2008-08-15 03:40:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-15 11:35:44 -0400 |
commit | bb15e7f286e3ecf3e85e06ad9b0019096e43a613 (patch) | |
tree | 88fd7cb042f3477699cb05c780518dc7dc1ed5a5 /drivers/hwmon/ibmaem.c | |
parent | 9c5413eac5199b8457689eb2c9d9e75138356bd6 (diff) |
ibmaem: don't query the entire sensor repository when reading energy meter
Currently, all sensors are read when the energy meter is queried via
sysfs. This introduces a considerable amount of delay and variation in
the sysfs reading, which is not desirable when trying to profile energy
use. Therefore, read only the energy meters when a sysfs query comes in
for them, and don't cache the results so that we always get the latest
reading.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/ibmaem.c')
-rw-r--r-- | drivers/hwmon/ibmaem.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c index 08c5179e6d84..0f70dc204105 100644 --- a/drivers/hwmon/ibmaem.c +++ b/drivers/hwmon/ibmaem.c | |||
@@ -463,12 +463,18 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg, | |||
463 | } | 463 | } |
464 | 464 | ||
465 | /* Update AEM energy registers */ | 465 | /* Update AEM energy registers */ |
466 | static void update_aem_energy_one(struct aem_data *data, int which) | ||
467 | { | ||
468 | aem_read_sensor(data, AEM_ENERGY_ELEMENT, which, | ||
469 | &data->energy[which], 8); | ||
470 | } | ||
471 | |||
466 | static void update_aem_energy(struct aem_data *data) | 472 | static void update_aem_energy(struct aem_data *data) |
467 | { | 473 | { |
468 | aem_read_sensor(data, AEM_ENERGY_ELEMENT, 0, &data->energy[0], 8); | 474 | update_aem_energy_one(data, 0); |
469 | if (data->ver_major < 2) | 475 | if (data->ver_major < 2) |
470 | return; | 476 | return; |
471 | aem_read_sensor(data, AEM_ENERGY_ELEMENT, 1, &data->energy[1], 8); | 477 | update_aem_energy_one(data, 1); |
472 | } | 478 | } |
473 | 479 | ||
474 | /* Update all AEM1 sensors */ | 480 | /* Update all AEM1 sensors */ |
@@ -850,7 +856,7 @@ static ssize_t aem_show_power(struct device *dev, | |||
850 | struct timespec b, a; | 856 | struct timespec b, a; |
851 | 857 | ||
852 | mutex_lock(&data->lock); | 858 | mutex_lock(&data->lock); |
853 | update_aem_energy(data); | 859 | update_aem_energy_one(data, attr->index); |
854 | getnstimeofday(&b); | 860 | getnstimeofday(&b); |
855 | before = data->energy[attr->index]; | 861 | before = data->energy[attr->index]; |
856 | 862 | ||
@@ -862,7 +868,7 @@ static ssize_t aem_show_power(struct device *dev, | |||
862 | return 0; | 868 | return 0; |
863 | } | 869 | } |
864 | 870 | ||
865 | update_aem_energy(data); | 871 | update_aem_energy_one(data, attr->index); |
866 | getnstimeofday(&a); | 872 | getnstimeofday(&a); |
867 | after = data->energy[attr->index]; | 873 | after = data->energy[attr->index]; |
868 | mutex_unlock(&data->lock); | 874 | mutex_unlock(&data->lock); |
@@ -881,7 +887,9 @@ static ssize_t aem_show_energy(struct device *dev, | |||
881 | { | 887 | { |
882 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 888 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
883 | struct aem_data *a = dev_get_drvdata(dev); | 889 | struct aem_data *a = dev_get_drvdata(dev); |
884 | a->update(a); | 890 | mutex_lock(&a->lock); |
891 | update_aem_energy_one(a, attr->index); | ||
892 | mutex_unlock(&a->lock); | ||
885 | 893 | ||
886 | return sprintf(buf, "%llu\n", | 894 | return sprintf(buf, "%llu\n", |
887 | (unsigned long long)a->energy[attr->index] * 1000); | 895 | (unsigned long long)a->energy[attr->index] * 1000); |