diff options
Diffstat (limited to 'drivers/hwmon/ibmaem.c')
-rw-r--r-- | drivers/hwmon/ibmaem.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c index c9416e657487..0f70dc204105 100644 --- a/drivers/hwmon/ibmaem.c +++ b/drivers/hwmon/ibmaem.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * A hwmon driver for the IBM Active Energy Manager temperature/power sensors | 2 | * A hwmon driver for the IBM System Director Active Energy Manager (AEM) |
3 | * and capping functionality. | 3 | * temperature/power/energy sensors and capping functionality. |
4 | * Copyright (C) 2008 IBM | 4 | * Copyright (C) 2008 IBM |
5 | * | 5 | * |
6 | * Author: Darrick J. Wong <djwong@us.ibm.com> | 6 | * Author: Darrick J. Wong <djwong@us.ibm.com> |
@@ -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 */ |
@@ -676,7 +682,8 @@ static int aem_find_aem2(struct aem_ipmi_data *data, | |||
676 | return -ETIMEDOUT; | 682 | return -ETIMEDOUT; |
677 | 683 | ||
678 | if (data->rx_result || data->rx_msg_len != sizeof(*fi_resp) || | 684 | if (data->rx_result || data->rx_msg_len != sizeof(*fi_resp) || |
679 | memcmp(&fi_resp->id, &system_x_id, sizeof(system_x_id))) | 685 | memcmp(&fi_resp->id, &system_x_id, sizeof(system_x_id)) || |
686 | fi_resp->num_instances <= instance_num) | ||
680 | return -ENOENT; | 687 | return -ENOENT; |
681 | 688 | ||
682 | return 0; | 689 | return 0; |
@@ -849,7 +856,7 @@ static ssize_t aem_show_power(struct device *dev, | |||
849 | struct timespec b, a; | 856 | struct timespec b, a; |
850 | 857 | ||
851 | mutex_lock(&data->lock); | 858 | mutex_lock(&data->lock); |
852 | update_aem_energy(data); | 859 | update_aem_energy_one(data, attr->index); |
853 | getnstimeofday(&b); | 860 | getnstimeofday(&b); |
854 | before = data->energy[attr->index]; | 861 | before = data->energy[attr->index]; |
855 | 862 | ||
@@ -861,7 +868,7 @@ static ssize_t aem_show_power(struct device *dev, | |||
861 | return 0; | 868 | return 0; |
862 | } | 869 | } |
863 | 870 | ||
864 | update_aem_energy(data); | 871 | update_aem_energy_one(data, attr->index); |
865 | getnstimeofday(&a); | 872 | getnstimeofday(&a); |
866 | after = data->energy[attr->index]; | 873 | after = data->energy[attr->index]; |
867 | mutex_unlock(&data->lock); | 874 | mutex_unlock(&data->lock); |
@@ -880,7 +887,9 @@ static ssize_t aem_show_energy(struct device *dev, | |||
880 | { | 887 | { |
881 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 888 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
882 | struct aem_data *a = dev_get_drvdata(dev); | 889 | struct aem_data *a = dev_get_drvdata(dev); |
883 | a->update(a); | 890 | mutex_lock(&a->lock); |
891 | update_aem_energy_one(a, attr->index); | ||
892 | mutex_unlock(&a->lock); | ||
884 | 893 | ||
885 | return sprintf(buf, "%llu\n", | 894 | return sprintf(buf, "%llu\n", |
886 | (unsigned long long)a->energy[attr->index] * 1000); | 895 | (unsigned long long)a->energy[attr->index] * 1000); |
@@ -1104,7 +1113,7 @@ static void __exit aem_exit(void) | |||
1104 | } | 1113 | } |
1105 | 1114 | ||
1106 | MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>"); | 1115 | MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>"); |
1107 | MODULE_DESCRIPTION("IBM Active Energy Manager power/temp sensor driver"); | 1116 | MODULE_DESCRIPTION("IBM AEM power/temp/energy sensor driver"); |
1108 | MODULE_LICENSE("GPL"); | 1117 | MODULE_LICENSE("GPL"); |
1109 | 1118 | ||
1110 | module_init(aem_init); | 1119 | module_init(aem_init); |