diff options
| author | Alex Murray <murray.alex@gmail.com> | 2010-05-03 20:19:13 +0930 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-05-03 18:12:44 +0200 |
| commit | fa95b7df25753ca791974b24efeb55ab49e2e2bf (patch) | |
| tree | 2f8ff4fb840635a4ecb558a1b3dc2a50a4529f9e | |
| parent | 833c34f893aa0472f36dee037986d138076c8237 (diff) | |
Add sysfs entry for temperature sensor labels
This allows userspace applications to determine which temperature sensor value
entry corresponds to which sensor say to easily determine which sensor is the
CPU temperature
Signed-off-by: Alex Murray <murray.alex@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | debian/changelog | 6 | ||||
| -rw-r--r-- | debian/postinst | 2 | ||||
| -rw-r--r-- | debian/postrm | 2 | ||||
| -rw-r--r-- | debian/prerm | 2 | ||||
| -rwxr-xr-x | debian/rules | 2 | ||||
| -rw-r--r-- | usr/src/dkms_source_tree/applesmc.c | 145 | ||||
| -rw-r--r-- | usr/src/dkms_source_tree/dkms.conf | 2 |
8 files changed, 156 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | NAME = applesmc | 1 | NAME = applesmc |
| 2 | VERSION = 0.15.2 | 2 | VERSION = 0.16.0 |
| 3 | SRC = usr/src | 3 | SRC = usr/src |
| 4 | 4 | ||
| 5 | TARBALL = $(NAME)-$(VERSION).dkms.tar.gz | 5 | TARBALL = $(NAME)-$(VERSION).dkms.tar.gz |
diff --git a/debian/changelog b/debian/changelog index 3238ff7..6354545 100644 --- a/debian/changelog +++ b/debian/changelog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | applesmc-dkms (0.16.0) unstable; urgency=low | ||
| 2 | |||
| 3 | * Add names for temperature sensors to sysfs | ||
| 4 | |||
| 5 | -- Alex Murray <murray.alex@gmail.com> Sun, 02 May 2010 23:50:41 +0930 | ||
| 6 | |||
| 1 | applesmc-dkms (0.15.2~rc1) unstable; urgency=low | 7 | applesmc-dkms (0.15.2~rc1) unstable; urgency=low |
| 2 | 8 | ||
| 3 | * Support for models MBP5,3, MBP5,4, MBP6 and MBP7 | 9 | * Support for models MBP5,3, MBP5,4, MBP6 and MBP7 |
diff --git a/debian/postinst b/debian/postinst index ad053c6..284cb05 100644 --- a/debian/postinst +++ b/debian/postinst | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | set -e | 3 | set -e |
| 4 | 4 | ||
| 5 | NAME=applesmc | 5 | NAME=applesmc |
| 6 | VERSION=0.15.2 | 6 | VERSION=0.16.0 |
| 7 | 7 | ||
| 8 | case "$1" in | 8 | case "$1" in |
| 9 | configure) | 9 | configure) |
diff --git a/debian/postrm b/debian/postrm index ed01ca4..f3fdfa8 100644 --- a/debian/postrm +++ b/debian/postrm | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | NAME=applesmc | 3 | NAME=applesmc |
| 4 | VERSION=0.15.2 | 4 | VERSION=0.16.0 |
| 5 | 5 | ||
| 6 | set -e | 6 | set -e |
| 7 | 7 | ||
diff --git a/debian/prerm b/debian/prerm index 37e3329..289774d 100644 --- a/debian/prerm +++ b/debian/prerm | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | NAME=applesmc | 3 | NAME=applesmc |
| 4 | VERSION=0.15.2 | 4 | VERSION=0.16.0 |
| 5 | 5 | ||
| 6 | set -e | 6 | set -e |
| 7 | 7 | ||
diff --git a/debian/rules b/debian/rules index cdfee50..cb78873 100755 --- a/debian/rules +++ b/debian/rules | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #export DH_VERBOSE=1 | 5 | #export DH_VERBOSE=1 |
| 6 | 6 | ||
| 7 | NAME=applesmc | 7 | NAME=applesmc |
| 8 | VERSION=0.15.2 | 8 | VERSION=0.16.0 |
| 9 | 9 | ||
| 10 | configure: configure-stamp | 10 | configure: configure-stamp |
| 11 | configure-stamp: | 11 | configure-stamp: |
diff --git a/usr/src/dkms_source_tree/applesmc.c b/usr/src/dkms_source_tree/applesmc.c index 36a0d62..7af6fe0 100644 --- a/usr/src/dkms_source_tree/applesmc.c +++ b/usr/src/dkms_source_tree/applesmc.c | |||
| @@ -657,6 +657,17 @@ out: | |||
| 657 | return snprintf(sysfsbuf, PAGE_SIZE, "(%d,%d)\n", left, right); | 657 | return snprintf(sysfsbuf, PAGE_SIZE, "(%d,%d)\n", left, right); |
| 658 | } | 658 | } |
| 659 | 659 | ||
| 660 | /* Displays sensor key as label */ | ||
| 661 | static ssize_t applesmc_show_sensor_label(struct device *dev, | ||
| 662 | struct device_attribute *devattr, char *sysfsbuf) | ||
| 663 | { | ||
| 664 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
| 665 | const char *key = | ||
| 666 | temperature_sensors_sets[applesmc_temperature_set][attr->index]; | ||
| 667 | |||
| 668 | return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", key); | ||
| 669 | } | ||
| 670 | |||
| 660 | /* Displays degree Celsius * 1000 */ | 671 | /* Displays degree Celsius * 1000 */ |
| 661 | static ssize_t applesmc_show_temperature(struct device *dev, | 672 | static ssize_t applesmc_show_temperature(struct device *dev, |
| 662 | struct device_attribute *devattr, char *sysfsbuf) | 673 | struct device_attribute *devattr, char *sysfsbuf) |
| @@ -1124,6 +1135,86 @@ static const struct attribute_group fan_attribute_groups[] = { | |||
| 1124 | /* | 1135 | /* |
| 1125 | * Temperature sensors sysfs entries. | 1136 | * Temperature sensors sysfs entries. |
| 1126 | */ | 1137 | */ |
| 1138 | static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, | ||
| 1139 | applesmc_show_sensor_label, NULL, 0); | ||
| 1140 | static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, | ||
| 1141 | applesmc_show_sensor_label, NULL, 1); | ||
| 1142 | static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, | ||
| 1143 | applesmc_show_sensor_label, NULL, 2); | ||
| 1144 | static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, | ||
| 1145 | applesmc_show_sensor_label, NULL, 3); | ||
| 1146 | static SENSOR_DEVICE_ATTR(temp5_label, S_IRUGO, | ||
| 1147 | applesmc_show_sensor_label, NULL, 4); | ||
| 1148 | static SENSOR_DEVICE_ATTR(temp6_label, S_IRUGO, | ||
| 1149 | applesmc_show_sensor_label, NULL, 5); | ||
| 1150 | static SENSOR_DEVICE_ATTR(temp7_label, S_IRUGO, | ||
| 1151 | applesmc_show_sensor_label, NULL, 6); | ||
| 1152 | static SENSOR_DEVICE_ATTR(temp8_label, S_IRUGO, | ||
| 1153 | applesmc_show_sensor_label, NULL, 7); | ||
| 1154 | static SENSOR_DEVICE_ATTR(temp9_label, S_IRUGO, | ||
| 1155 | applesmc_show_sensor_label, NULL, 8); | ||
| 1156 | static SENSOR_DEVICE_ATTR(temp10_label, S_IRUGO, | ||
| 1157 | applesmc_show_sensor_label, NULL, 9); | ||
| 1158 | static SENSOR_DEVICE_ATTR(temp11_label, S_IRUGO, | ||
| 1159 | applesmc_show_sensor_label, NULL, 10); | ||
| 1160 | static SENSOR_DEVICE_ATTR(temp12_label, S_IRUGO, | ||
| 1161 | applesmc_show_sensor_label, NULL, 11); | ||
| 1162 | static SENSOR_DEVICE_ATTR(temp13_label, S_IRUGO, | ||
| 1163 | applesmc_show_sensor_label, NULL, 12); | ||
| 1164 | static SENSOR_DEVICE_ATTR(temp14_label, S_IRUGO, | ||
| 1165 | applesmc_show_sensor_label, NULL, 13); | ||
| 1166 | static SENSOR_DEVICE_ATTR(temp15_label, S_IRUGO, | ||
| 1167 | applesmc_show_sensor_label, NULL, 14); | ||
| 1168 | static SENSOR_DEVICE_ATTR(temp16_label, S_IRUGO, | ||
| 1169 | applesmc_show_sensor_label, NULL, 15); | ||
| 1170 | static SENSOR_DEVICE_ATTR(temp17_label, S_IRUGO, | ||
| 1171 | applesmc_show_sensor_label, NULL, 16); | ||
| 1172 | static SENSOR_DEVICE_ATTR(temp18_label, S_IRUGO, | ||
| 1173 | applesmc_show_sensor_label, NULL, 17); | ||
| 1174 | static SENSOR_DEVICE_ATTR(temp19_label, S_IRUGO, | ||
| 1175 | applesmc_show_sensor_label, NULL, 18); | ||
| 1176 | static SENSOR_DEVICE_ATTR(temp20_label, S_IRUGO, | ||
| 1177 | applesmc_show_sensor_label, NULL, 19); | ||
| 1178 | static SENSOR_DEVICE_ATTR(temp21_label, S_IRUGO, | ||
| 1179 | applesmc_show_sensor_label, NULL, 20); | ||
| 1180 | static SENSOR_DEVICE_ATTR(temp22_label, S_IRUGO, | ||
| 1181 | applesmc_show_sensor_label, NULL, 21); | ||
| 1182 | static SENSOR_DEVICE_ATTR(temp23_label, S_IRUGO, | ||
| 1183 | applesmc_show_sensor_label, NULL, 22); | ||
| 1184 | static SENSOR_DEVICE_ATTR(temp24_label, S_IRUGO, | ||
| 1185 | applesmc_show_sensor_label, NULL, 23); | ||
| 1186 | static SENSOR_DEVICE_ATTR(temp25_label, S_IRUGO, | ||
| 1187 | applesmc_show_sensor_label, NULL, 24); | ||
| 1188 | static SENSOR_DEVICE_ATTR(temp26_label, S_IRUGO, | ||
| 1189 | applesmc_show_sensor_label, NULL, 25); | ||
| 1190 | static SENSOR_DEVICE_ATTR(temp27_label, S_IRUGO, | ||
| 1191 | applesmc_show_sensor_label, NULL, 26); | ||
| 1192 | static SENSOR_DEVICE_ATTR(temp28_label, S_IRUGO, | ||
| 1193 | applesmc_show_sensor_label, NULL, 27); | ||
| 1194 | static SENSOR_DEVICE_ATTR(temp29_label, S_IRUGO, | ||
| 1195 | applesmc_show_sensor_label, NULL, 28); | ||
| 1196 | static SENSOR_DEVICE_ATTR(temp30_label, S_IRUGO, | ||
| 1197 | applesmc_show_sensor_label, NULL, 29); | ||
| 1198 | static SENSOR_DEVICE_ATTR(temp31_label, S_IRUGO, | ||
| 1199 | applesmc_show_sensor_label, NULL, 30); | ||
| 1200 | static SENSOR_DEVICE_ATTR(temp32_label, S_IRUGO, | ||
| 1201 | applesmc_show_sensor_label, NULL, 31); | ||
| 1202 | static SENSOR_DEVICE_ATTR(temp33_label, S_IRUGO, | ||
| 1203 | applesmc_show_sensor_label, NULL, 32); | ||
| 1204 | static SENSOR_DEVICE_ATTR(temp34_label, S_IRUGO, | ||
| 1205 | applesmc_show_sensor_label, NULL, 33); | ||
| 1206 | static SENSOR_DEVICE_ATTR(temp35_label, S_IRUGO, | ||
| 1207 | applesmc_show_sensor_label, NULL, 34); | ||
| 1208 | static SENSOR_DEVICE_ATTR(temp36_label, S_IRUGO, | ||
| 1209 | applesmc_show_sensor_label, NULL, 35); | ||
| 1210 | static SENSOR_DEVICE_ATTR(temp37_label, S_IRUGO, | ||
| 1211 | applesmc_show_sensor_label, NULL, 36); | ||
| 1212 | static SENSOR_DEVICE_ATTR(temp38_label, S_IRUGO, | ||
| 1213 | applesmc_show_sensor_label, NULL, 37); | ||
| 1214 | static SENSOR_DEVICE_ATTR(temp39_label, S_IRUGO, | ||
| 1215 | applesmc_show_sensor_label, NULL, 38); | ||
| 1216 | static SENSOR_DEVICE_ATTR(temp40_label, S_IRUGO, | ||
| 1217 | applesmc_show_sensor_label, NULL, 39); | ||
| 1127 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, | 1218 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, |
| 1128 | applesmc_show_temperature, NULL, 0); | 1219 | applesmc_show_temperature, NULL, 0); |
| 1129 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, | 1220 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, |
| @@ -1205,6 +1296,50 @@ static SENSOR_DEVICE_ATTR(temp39_input, S_IRUGO, | |||
| 1205 | static SENSOR_DEVICE_ATTR(temp40_input, S_IRUGO, | 1296 | static SENSOR_DEVICE_ATTR(temp40_input, S_IRUGO, |
| 1206 | applesmc_show_temperature, NULL, 39); | 1297 | applesmc_show_temperature, NULL, 39); |
| 1207 | 1298 | ||
| 1299 | static struct attribute *label_attributes[] = { | ||
| 1300 | &sensor_dev_attr_temp1_label.dev_attr.attr, | ||
| 1301 | &sensor_dev_attr_temp2_label.dev_attr.attr, | ||
| 1302 | &sensor_dev_attr_temp3_label.dev_attr.attr, | ||
| 1303 | &sensor_dev_attr_temp4_label.dev_attr.attr, | ||
| 1304 | &sensor_dev_attr_temp5_label.dev_attr.attr, | ||
| 1305 | &sensor_dev_attr_temp6_label.dev_attr.attr, | ||
| 1306 | &sensor_dev_attr_temp7_label.dev_attr.attr, | ||
| 1307 | &sensor_dev_attr_temp8_label.dev_attr.attr, | ||
| 1308 | &sensor_dev_attr_temp9_label.dev_attr.attr, | ||
| 1309 | &sensor_dev_attr_temp10_label.dev_attr.attr, | ||
| 1310 | &sensor_dev_attr_temp11_label.dev_attr.attr, | ||
| 1311 | &sensor_dev_attr_temp12_label.dev_attr.attr, | ||
| 1312 | &sensor_dev_attr_temp13_label.dev_attr.attr, | ||
| 1313 | &sensor_dev_attr_temp14_label.dev_attr.attr, | ||
| 1314 | &sensor_dev_attr_temp15_label.dev_attr.attr, | ||
| 1315 | &sensor_dev_attr_temp16_label.dev_attr.attr, | ||
| 1316 | &sensor_dev_attr_temp17_label.dev_attr.attr, | ||
| 1317 | &sensor_dev_attr_temp18_label.dev_attr.attr, | ||
| 1318 | &sensor_dev_attr_temp19_label.dev_attr.attr, | ||
| 1319 | &sensor_dev_attr_temp20_label.dev_attr.attr, | ||
| 1320 | &sensor_dev_attr_temp21_label.dev_attr.attr, | ||
| 1321 | &sensor_dev_attr_temp22_label.dev_attr.attr, | ||
| 1322 | &sensor_dev_attr_temp23_label.dev_attr.attr, | ||
| 1323 | &sensor_dev_attr_temp24_label.dev_attr.attr, | ||
| 1324 | &sensor_dev_attr_temp25_label.dev_attr.attr, | ||
| 1325 | &sensor_dev_attr_temp26_label.dev_attr.attr, | ||
| 1326 | &sensor_dev_attr_temp27_label.dev_attr.attr, | ||
| 1327 | &sensor_dev_attr_temp28_label.dev_attr.attr, | ||
| 1328 | &sensor_dev_attr_temp29_label.dev_attr.attr, | ||
| 1329 | &sensor_dev_attr_temp30_label.dev_attr.attr, | ||
| 1330 | &sensor_dev_attr_temp31_label.dev_attr.attr, | ||
| 1331 | &sensor_dev_attr_temp32_label.dev_attr.attr, | ||
| 1332 | &sensor_dev_attr_temp33_label.dev_attr.attr, | ||
| 1333 | &sensor_dev_attr_temp34_label.dev_attr.attr, | ||
| 1334 | &sensor_dev_attr_temp35_label.dev_attr.attr, | ||
| 1335 | &sensor_dev_attr_temp36_label.dev_attr.attr, | ||
| 1336 | &sensor_dev_attr_temp37_label.dev_attr.attr, | ||
| 1337 | &sensor_dev_attr_temp38_label.dev_attr.attr, | ||
| 1338 | &sensor_dev_attr_temp39_label.dev_attr.attr, | ||
| 1339 | &sensor_dev_attr_temp40_label.dev_attr.attr, | ||
| 1340 | NULL | ||
| 1341 | }; | ||
| 1342 | |||
| 1208 | static struct attribute *temperature_attributes[] = { | 1343 | static struct attribute *temperature_attributes[] = { |
| 1209 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 1344 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
| 1210 | &sensor_dev_attr_temp2_input.dev_attr.attr, | 1345 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
| @@ -1252,6 +1387,9 @@ static struct attribute *temperature_attributes[] = { | |||
| 1252 | static const struct attribute_group temperature_attributes_group = | 1387 | static const struct attribute_group temperature_attributes_group = |
| 1253 | { .attrs = temperature_attributes }; | 1388 | { .attrs = temperature_attributes }; |
| 1254 | 1389 | ||
| 1390 | static const struct attribute_group label_attributes_group = | ||
| 1391 | { .attrs = label_attributes }; | ||
| 1392 | |||
| 1255 | /* Module stuff */ | 1393 | /* Module stuff */ |
| 1256 | 1394 | ||
| 1257 | /* | 1395 | /* |
| @@ -1568,7 +1706,8 @@ static int __init applesmc_init(void) | |||
| 1568 | for (i = 0; | 1706 | for (i = 0; |
| 1569 | temperature_sensors_sets[applesmc_temperature_set][i] != NULL; | 1707 | temperature_sensors_sets[applesmc_temperature_set][i] != NULL; |
| 1570 | i++) { | 1708 | i++) { |
| 1571 | if (temperature_attributes[i] == NULL) { | 1709 | if (temperature_attributes[i] == NULL || |
| 1710 | label_attributes[i] == NULL) { | ||
| 1572 | printk(KERN_ERR "applesmc: More temperature sensors " | 1711 | printk(KERN_ERR "applesmc: More temperature sensors " |
| 1573 | "in temperature_sensors_sets (at least %i)" | 1712 | "in temperature_sensors_sets (at least %i)" |
| 1574 | "than available sysfs files in " | 1713 | "than available sysfs files in " |
| @@ -1578,6 +1717,8 @@ static int __init applesmc_init(void) | |||
| 1578 | } | 1717 | } |
| 1579 | ret = sysfs_create_file(&pdev->dev.kobj, | 1718 | ret = sysfs_create_file(&pdev->dev.kobj, |
| 1580 | temperature_attributes[i]); | 1719 | temperature_attributes[i]); |
| 1720 | ret = sysfs_create_file(&pdev->dev.kobj, | ||
| 1721 | label_attributes[i]); | ||
| 1581 | if (ret) | 1722 | if (ret) |
| 1582 | goto out_temperature; | 1723 | goto out_temperature; |
| 1583 | } | 1724 | } |
| @@ -1630,6 +1771,7 @@ out_accelerometer: | |||
| 1630 | if (applesmc_accelerometer) | 1771 | if (applesmc_accelerometer) |
| 1631 | applesmc_release_accelerometer(); | 1772 | applesmc_release_accelerometer(); |
| 1632 | out_temperature: | 1773 | out_temperature: |
| 1774 | sysfs_remove_group(&pdev->dev.kobj, &label_attributes_group); | ||
| 1633 | sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); | 1775 | sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); |
| 1634 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]); | 1776 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]); |
| 1635 | out_fan_1: | 1777 | out_fan_1: |
| @@ -1659,6 +1801,7 @@ static void __exit applesmc_exit(void) | |||
| 1659 | } | 1801 | } |
| 1660 | if (applesmc_accelerometer) | 1802 | if (applesmc_accelerometer) |
| 1661 | applesmc_release_accelerometer(); | 1803 | applesmc_release_accelerometer(); |
| 1804 | sysfs_remove_group(&pdev->dev.kobj, &label_attributes_group); | ||
| 1662 | sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); | 1805 | sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); |
| 1663 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]); | 1806 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]); |
| 1664 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]); | 1807 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]); |
diff --git a/usr/src/dkms_source_tree/dkms.conf b/usr/src/dkms_source_tree/dkms.conf index df2247d..141298a 100644 --- a/usr/src/dkms_source_tree/dkms.conf +++ b/usr/src/dkms_source_tree/dkms.conf | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | NAME=applesmc | 1 | NAME=applesmc |
| 2 | VERSION=0.15.2 | 2 | VERSION=0.16.0 |
| 3 | PACKAGE_NAME="$NAME" | 3 | PACKAGE_NAME="$NAME" |
| 4 | PACKAGE_VERSION="$VERSION" | 4 | PACKAGE_VERSION="$VERSION" |
| 5 | MAKE[0]="make -C ${kernel_source_dir} | 5 | MAKE[0]="make -C ${kernel_source_dir} |
