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>
This commit is contained in:
parent
9eccca0843
commit
1055b5f904
1 changed files with 5 additions and 6 deletions
|
@ -397,14 +397,13 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev,
|
||||||
struct device_attribute *devattr, char *buf) = {
|
struct device_attribute *devattr, char *buf) = {
|
||||||
show_label, show_crit_alarm, show_temp, show_tjmax,
|
show_label, show_crit_alarm, show_temp, show_tjmax,
|
||||||
show_ttarget };
|
show_ttarget };
|
||||||
static const char *const names[TOTAL_ATTRS] = {
|
static const char *const suffixes[TOTAL_ATTRS] = {
|
||||||
"temp%d_label", "temp%d_crit_alarm",
|
"label", "crit_alarm", "input", "crit", "max"
|
||||||
"temp%d_input", "temp%d_crit",
|
};
|
||||||
"temp%d_max" };
|
|
||||||
|
|
||||||
for (i = 0; i < tdata->attr_size; i++) {
|
for (i = 0; i < tdata->attr_size; i++) {
|
||||||
snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH, names[i],
|
snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH,
|
||||||
attr_no);
|
"temp%d_%s", attr_no, suffixes[i]);
|
||||||
sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr);
|
sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr);
|
||||||
tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i];
|
tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i];
|
||||||
tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO;
|
tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO;
|
||||||
|
|
Loading…
Reference in a new issue