diff options
Diffstat (limited to 'drivers')
-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); |