aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2015-02-12 09:15:17 -0500
committerGuenter Roeck <linux@roeck-us.net>2015-03-09 12:59:35 -0400
commita0fc74d42d2215496302a0e2c03e9f2db30cc1b7 (patch)
treebcbe52b3a1d0e1ad4aeb5df2e4649d0dd72aa291 /drivers/hwmon
parent1055b5f90424056432430fa06f94f1d12db07fba (diff)
hwmon: (ibmpex) Allow format string checking
The only difference between the three power_sensor_name_templates is whether there is a suffix of "", "_lowest" or "_highest". We might as well pull those into an array and use a literal format string, allowing gcc to do type checking of the arguments to sprintf. Incidentially, the same three suffixes are used in the temp_sensor_name_templates case, so we end up eliminating one static array. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> [Guenter Roeck: Fixed line length over 80 characters] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ibmpex.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index 030e7ff589be..21b9c72f16bd 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -56,15 +56,10 @@ static u8 const temp_sensor_sig[] = {0x74, 0x65, 0x6D};
56static u8 const watt_sensor_sig[] = {0x41, 0x43}; 56static u8 const watt_sensor_sig[] = {0x41, 0x43};
57 57
58#define PEX_NUM_SENSOR_FUNCS 3 58#define PEX_NUM_SENSOR_FUNCS 3
59static char const * const power_sensor_name_templates[] = { 59static const char * const sensor_name_suffixes[] = {
60 "%s%d_average", 60 "",
61 "%s%d_average_lowest", 61 "_lowest",
62 "%s%d_average_highest" 62 "_highest"
63};
64static char const * const temp_sensor_name_templates[] = {
65 "%s%d_input",
66 "%s%d_input_lowest",
67 "%s%d_input_highest"
68}; 63};
69 64
70static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data); 65static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data);
@@ -355,9 +350,11 @@ static int create_sensor(struct ibmpex_bmc_data *data, int type,
355 return -ENOMEM; 350 return -ENOMEM;
356 351
357 if (type == TEMP_SENSOR) 352 if (type == TEMP_SENSOR)
358 sprintf(n, temp_sensor_name_templates[func], "temp", counter); 353 sprintf(n, "temp%d_input%s",
354 counter, sensor_name_suffixes[func]);
359 else if (type == POWER_SENSOR) 355 else if (type == POWER_SENSOR)
360 sprintf(n, power_sensor_name_templates[func], "power", counter); 356 sprintf(n, "power%d_average%s",
357 counter, sensor_name_suffixes[func]);
361 358
362 sysfs_attr_init(&data->sensors[sensor].attr[func].dev_attr.attr); 359 sysfs_attr_init(&data->sensors[sensor].attr[func].dev_attr.attr);
363 data->sensors[sensor].attr[func].dev_attr.attr.name = n; 360 data->sensors[sensor].attr[func].dev_attr.attr.name = n;