aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm80.c
diff options
context:
space:
mode:
authorFrans Meulenbroeks <fransmeulenbroeks@gmail.com>2012-01-04 14:58:53 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-01-05 11:19:34 -0500
commit66b3b1f757f5cfccedab9f39e7ef176342060735 (patch)
treef7942278228a1285cb3ece3f597a56c86b4450b6 /drivers/hwmon/lm80.c
parent179c4fdb565dd2157e5dfe89318b74868e3b523d (diff)
hwmon: (lm80) fix checkpatch messages
Fixed all checkpatch messages except simple_strto* -> kstr* This will be addressed in a separate patch Also left one line-too-long message as it was only a little bit too long and would become less readable compile-tested: no warnings or errors Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/lm80.c')
-rw-r--r--drivers/hwmon/lm80.c70
1 files changed, 42 insertions, 28 deletions
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index 18a0e6c5fe8..0891b38ffec 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -66,19 +66,19 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
66 these macros are called: arguments may be evaluated more than once. 66 these macros are called: arguments may be evaluated more than once.
67 Fixing this is just not worth it. */ 67 Fixing this is just not worth it. */
68 68
69#define IN_TO_REG(val) (SENSORS_LIMIT(((val)+5)/10,0,255)) 69#define IN_TO_REG(val) (SENSORS_LIMIT(((val) + 5) / 10, 0, 255))
70#define IN_FROM_REG(val) ((val)*10) 70#define IN_FROM_REG(val) ((val) * 10)
71 71
72static inline unsigned char FAN_TO_REG(unsigned rpm, unsigned div) 72static inline unsigned char FAN_TO_REG(unsigned rpm, unsigned div)
73{ 73{
74 if (rpm == 0) 74 if (rpm == 0)
75 return 255; 75 return 255;
76 rpm = SENSORS_LIMIT(rpm, 1, 1000000); 76 rpm = SENSORS_LIMIT(rpm, 1, 1000000);
77 return SENSORS_LIMIT((1350000 + rpm*div / 2) / (rpm*div), 1, 254); 77 return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
78} 78}
79 79
80#define FAN_FROM_REG(val,div) ((val)==0?-1:\ 80#define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : \
81 (val)==255?0:1350000/((div)*(val))) 81 (val) == 255 ? 0 : 1350000/((div) * (val)))
82 82
83static inline long TEMP_FROM_REG(u16 temp) 83static inline long TEMP_FROM_REG(u16 temp)
84{ 84{
@@ -93,10 +93,11 @@ static inline long TEMP_FROM_REG(u16 temp)
93 return res / 10; 93 return res / 10;
94} 94}
95 95
96#define TEMP_LIMIT_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) 96#define TEMP_LIMIT_FROM_REG(val) (((val) > 0x80 ? \
97 (val) - 0x100 : (val)) * 1000)
97 98
98#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val)<0?\ 99#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) < 0 ? \
99 ((val)-500)/1000:((val)+500)/1000,0,255) 100 ((val) - 500) / 1000 : ((val) + 500) / 1000, 0, 255)
100 101
101#define DIV_FROM_REG(val) (1 << (val)) 102#define DIV_FROM_REG(val) (1 << (val))
102 103
@@ -164,7 +165,8 @@ static struct i2c_driver lm80_driver = {
164 */ 165 */
165 166
166#define show_in(suffix, value) \ 167#define show_in(suffix, value) \
167static ssize_t show_in_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ 168static ssize_t show_in_##suffix(struct device *dev, \
169 struct device_attribute *attr, char *buf) \
168{ \ 170{ \
169 int nr = to_sensor_dev_attr(attr)->index; \ 171 int nr = to_sensor_dev_attr(attr)->index; \
170 struct lm80_data *data = lm80_update_device(dev); \ 172 struct lm80_data *data = lm80_update_device(dev); \
@@ -175,14 +177,14 @@ show_in(max, in_max)
175show_in(input, in) 177show_in(input, in)
176 178
177#define set_in(suffix, value, reg) \ 179#define set_in(suffix, value, reg) \
178static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ 180static ssize_t set_in_##suffix(struct device *dev, \
179 size_t count) \ 181 struct device_attribute *attr, const char *buf, size_t count) \
180{ \ 182{ \
181 int nr = to_sensor_dev_attr(attr)->index; \ 183 int nr = to_sensor_dev_attr(attr)->index; \
182 struct i2c_client *client = to_i2c_client(dev); \ 184 struct i2c_client *client = to_i2c_client(dev); \
183 struct lm80_data *data = i2c_get_clientdata(client); \ 185 struct lm80_data *data = i2c_get_clientdata(client); \
184 long val = simple_strtol(buf, NULL, 10); \ 186 long val = simple_strtol(buf, NULL, 10); \
185 \ 187\
186 mutex_lock(&data->update_lock);\ 188 mutex_lock(&data->update_lock);\
187 data->value[nr] = IN_TO_REG(val); \ 189 data->value[nr] = IN_TO_REG(val); \
188 lm80_write_value(client, reg(nr), data->value[nr]); \ 190 lm80_write_value(client, reg(nr), data->value[nr]); \
@@ -193,7 +195,8 @@ set_in(min, in_min, LM80_REG_IN_MIN)
193set_in(max, in_max, LM80_REG_IN_MAX) 195set_in(max, in_max, LM80_REG_IN_MAX)
194 196
195#define show_fan(suffix, value) \ 197#define show_fan(suffix, value) \
196static ssize_t show_fan_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ 198static ssize_t show_fan_##suffix(struct device *dev, \
199 struct device_attribute *attr, char *buf) \
197{ \ 200{ \
198 int nr = to_sensor_dev_attr(attr)->index; \ 201 int nr = to_sensor_dev_attr(attr)->index; \
199 struct lm80_data *data = lm80_update_device(dev); \ 202 struct lm80_data *data = lm80_update_device(dev); \
@@ -245,10 +248,18 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
245 DIV_FROM_REG(data->fan_div[nr])); 248 DIV_FROM_REG(data->fan_div[nr]));
246 249
247 switch (val) { 250 switch (val) {
248 case 1: data->fan_div[nr] = 0; break; 251 case 1:
249 case 2: data->fan_div[nr] = 1; break; 252 data->fan_div[nr] = 0;
250 case 4: data->fan_div[nr] = 2; break; 253 break;
251 case 8: data->fan_div[nr] = 3; break; 254 case 2:
255 data->fan_div[nr] = 1;
256 break;
257 case 4:
258 data->fan_div[nr] = 2;
259 break;
260 case 8:
261 data->fan_div[nr] = 3;
262 break;
252 default: 263 default:
253 dev_err(&client->dev, "fan_div value %ld not " 264 dev_err(&client->dev, "fan_div value %ld not "
254 "supported. Choose one of 1, 2, 4 or 8!\n", val); 265 "supported. Choose one of 1, 2, 4 or 8!\n", val);
@@ -268,14 +279,16 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
268 return count; 279 return count;
269} 280}
270 281
271static ssize_t show_temp_input1(struct device *dev, struct device_attribute *attr, char *buf) 282static ssize_t show_temp_input1(struct device *dev,
283 struct device_attribute *attr, char *buf)
272{ 284{
273 struct lm80_data *data = lm80_update_device(dev); 285 struct lm80_data *data = lm80_update_device(dev);
274 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp)); 286 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp));
275} 287}
276 288
277#define show_temp(suffix, value) \ 289#define show_temp(suffix, value) \
278static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ 290static ssize_t show_temp_##suffix(struct device *dev, \
291 struct device_attribute *attr, char *buf) \
279{ \ 292{ \
280 struct lm80_data *data = lm80_update_device(dev); \ 293 struct lm80_data *data = lm80_update_device(dev); \
281 return sprintf(buf, "%d\n", TEMP_LIMIT_FROM_REG(data->value)); \ 294 return sprintf(buf, "%d\n", TEMP_LIMIT_FROM_REG(data->value)); \
@@ -286,13 +299,13 @@ show_temp(os_max, temp_os_max);
286show_temp(os_hyst, temp_os_hyst); 299show_temp(os_hyst, temp_os_hyst);
287 300
288#define set_temp(suffix, value, reg) \ 301#define set_temp(suffix, value, reg) \
289static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ 302static ssize_t set_temp_##suffix(struct device *dev, \
290 size_t count) \ 303 struct device_attribute *attr, const char *buf, size_t count) \
291{ \ 304{ \
292 struct i2c_client *client = to_i2c_client(dev); \ 305 struct i2c_client *client = to_i2c_client(dev); \
293 struct lm80_data *data = i2c_get_clientdata(client); \ 306 struct lm80_data *data = i2c_get_clientdata(client); \
294 long val = simple_strtoul(buf, NULL, 10); \ 307 long val = simple_strtoul(buf, NULL, 10); \
295 \ 308\
296 mutex_lock(&data->update_lock); \ 309 mutex_lock(&data->update_lock); \
297 data->value = TEMP_LIMIT_TO_REG(val); \ 310 data->value = TEMP_LIMIT_TO_REG(val); \
298 lm80_write_value(client, reg, data->value); \ 311 lm80_write_value(client, reg, data->value); \
@@ -366,13 +379,13 @@ static SENSOR_DEVICE_ATTR(fan2_div, S_IWUSR | S_IRUGO,
366 show_fan_div, set_fan_div, 1); 379 show_fan_div, set_fan_div, 1);
367static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); 380static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL);
368static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_hot_max, 381static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_hot_max,
369 set_temp_hot_max); 382 set_temp_hot_max);
370static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, show_temp_hot_hyst, 383static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, show_temp_hot_hyst,
371 set_temp_hot_hyst); 384 set_temp_hot_hyst);
372static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_os_max, 385static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_os_max,
373 set_temp_os_max); 386 set_temp_os_max);
374static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_os_hyst, 387static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_os_hyst,
375 set_temp_os_hyst); 388 set_temp_os_hyst);
376static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 389static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
377static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); 390static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
378static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); 391static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
@@ -459,7 +472,7 @@ static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info)
459 if ((i2c_smbus_read_byte_data(client, i + 0x40) != cur) 472 if ((i2c_smbus_read_byte_data(client, i + 0x40) != cur)
460 || (i2c_smbus_read_byte_data(client, i + 0x80) != cur) 473 || (i2c_smbus_read_byte_data(client, i + 0x80) != cur)
461 || (i2c_smbus_read_byte_data(client, i + 0xc0) != cur)) 474 || (i2c_smbus_read_byte_data(client, i + 0xc0) != cur))
462 return -ENODEV; 475 return -ENODEV;
463 } 476 }
464 477
465 strlcpy(info->type, "lm80", I2C_NAME_SIZE); 478 strlcpy(info->type, "lm80", I2C_NAME_SIZE);
@@ -490,7 +503,8 @@ static int lm80_probe(struct i2c_client *client,
490 data->fan_min[1] = lm80_read_value(client, LM80_REG_FAN_MIN(2)); 503 data->fan_min[1] = lm80_read_value(client, LM80_REG_FAN_MIN(2));
491 504
492 /* Register sysfs hooks */ 505 /* Register sysfs hooks */
493 if ((err = sysfs_create_group(&client->dev.kobj, &lm80_group))) 506 err = sysfs_create_group(&client->dev.kobj, &lm80_group);
507 if (err)
494 goto error_free; 508 goto error_free;
495 509
496 data->hwmon_dev = hwmon_device_register(&client->dev); 510 data->hwmon_dev = hwmon_device_register(&client->dev);