diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-02-12 09:15:16 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2015-03-09 12:59:35 -0400 |
commit | 1055b5f90424056432430fa06f94f1d12db07fba (patch) | |
tree | 63240950ae973e3447442e462e83d0c0a71a0b3c | |
parent | 9eccca0843205f87c00404b663188b88eb248051 (diff) |
hwmon: (coretemp) Allow format checking
By extracting the only part that differs we can allow static checking
of the format string, and possibly save a little .rodata.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
[Guenter Roeck: continuation line alignment]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/coretemp.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 5b7fec824f10..ed303ba3a593 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
@@ -397,14 +397,13 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev, | |||
397 | struct device_attribute *devattr, char *buf) = { | 397 | struct device_attribute *devattr, char *buf) = { |
398 | show_label, show_crit_alarm, show_temp, show_tjmax, | 398 | show_label, show_crit_alarm, show_temp, show_tjmax, |
399 | show_ttarget }; | 399 | show_ttarget }; |
400 | static const char *const names[TOTAL_ATTRS] = { | 400 | static const char *const suffixes[TOTAL_ATTRS] = { |
401 | "temp%d_label", "temp%d_crit_alarm", | 401 | "label", "crit_alarm", "input", "crit", "max" |
402 | "temp%d_input", "temp%d_crit", | 402 | }; |
403 | "temp%d_max" }; | ||
404 | 403 | ||
405 | for (i = 0; i < tdata->attr_size; i++) { | 404 | for (i = 0; i < tdata->attr_size; i++) { |
406 | snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH, names[i], | 405 | snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH, |
407 | attr_no); | 406 | "temp%d_%s", attr_no, suffixes[i]); |
408 | sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr); | 407 | sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr); |
409 | tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i]; | 408 | tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i]; |
410 | tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO; | 409 | tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO; |